VirtualComputer/libpxc/pxc.c

47 lines
1.1 KiB
C
Raw Normal View History

#include <stdio.h>
2018-11-14 22:53:03 +00:00
#include <stdlib.h>
2018-11-14 22:53:03 +00:00
#define MAPSIZE 128
typedef long long int addr;
void* image=NULL;
2018-11-14 22:53:03 +00:00
const void* maps=NULL; //Per map data (1st map, second map etc.)
int width, height, mapc;
2018-11-14 22:53:03 +00:00
void setSource(addr address, int w, int h, int mc) {
image=(void*)address;
2018-11-14 22:53:03 +00:00
maps=malloc(MAPSIZE*MAPSIZE*mc); //1 byte per pixel
width=w, height=h, mapc=mc;
}
//May return 0
addr updateAndGetMap(short mapnum) {
if(mapnum<0||mapnum>=mapc) return 0; //Out of bounds
//TODO: Converter
//return (long)map+mapx*MAPSIZE + mapy*MAPSIZE*width; - not good, we need to order the data per map
return (long)maps + MAPSIZE*MAPSIZE*mapnum;
}
2018-11-14 22:53:03 +00:00
//Testing only
int convert(int px[], int *out[]) {
printf("convert...\n");
printf("px0: %d\n", px[0]);
*out[0]=19;
return 0;
}
void __attribute__ ((constructor)) initLibrary(void) {
//
// Function that is called when the library is loaded
//
printf("Library is initialized\n");
}
void __attribute__ ((destructor)) cleanUpLibrary(void) {
//
// Function that is called when the library is »closed«.
//
printf("Library is exited\n");
}