2018-11-14 18:15:58 +00:00
|
|
|
#include <stdio.h>
|
2018-11-14 22:53:03 +00:00
|
|
|
#include <stdlib.h>
|
2018-11-14 18:15:58 +00:00
|
|
|
|
2018-11-14 22:53:03 +00:00
|
|
|
#define MAPSIZE 128
|
|
|
|
|
|
|
|
typedef long long int addr;
|
2018-11-14 22:00:25 +00:00
|
|
|
|
|
|
|
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:00:25 +00:00
|
|
|
|
2018-11-14 22:53:03 +00:00
|
|
|
void setSource(addr address, int w, int h, int mc) {
|
2018-11-14 22:00:25 +00:00
|
|
|
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:00:25 +00:00
|
|
|
}
|
|
|
|
|
2018-11-14 22:53:03 +00:00
|
|
|
//Testing only
|
2018-11-14 18:15:58 +00:00
|
|
|
int convert(int px[], int *out[]) {
|
|
|
|
printf("convert...\n");
|
2018-11-14 22:00:25 +00:00
|
|
|
printf("px0: %d\n", px[0]);
|
|
|
|
*out[0]=19;
|
2018-11-14 18:15:58 +00:00
|
|
|
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");
|
|
|
|
}
|