Added functions

This commit is contained in:
Norbi Peti 2018-11-14 23:53:03 +01:00
parent 026edffed4
commit 2ea5c1c4bd
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
3 changed files with 42 additions and 3 deletions

View file

@ -1,5 +1,27 @@
package sznp.virtualcomputer; package sznp.virtualcomputer;
public interface PXCLib { public interface PXCLib {
/**
* Testing only
* @param px Input array
* @param out Output array
* @return 0
*/
int convert(int[] px, long[] out); int convert(int[] px, long[] out);
/**
* Set source bitmap
* @param address Bitmap address from VirtualBox
* @param w Width of the screen
* @param h Height of the screen
* @param mc Total count of maps used for the screen
*/
void setSource(long address, int w, int h, int mc);
/**
* Updates map and returns it's content
* @param mapnum Number of the map (0 is first)
* @return Address of the map data
*/
long updateAndGetMap(short mapnum); //TODO: Only update parts that actually updated and return them per-map (flagDirty)
} }

View file

@ -14,6 +14,6 @@ public class Test {
ByteBuffer bb = ByteBuffer.allocateDirect(2); ByteBuffer bb = ByteBuffer.allocateDirect(2);
long[] x = new long[]{Pointer.nativeValue(Native.getDirectBufferPointer(bb))}; long[] x = new long[]{Pointer.nativeValue(Native.getDirectBufferPointer(bb))};
pxc.convert(new int[]{5, 10}, x); pxc.convert(new int[]{5, 10}, x);
System.out.println(bb.get(0)); //19 AYY System.out.println(bb.get(0)); //19 AYY //TO!DO: Use setSource, we don't want to wrap the native array
} }
} }

View file

@ -1,13 +1,30 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
typedef long long int lli; #define MAPSIZE 128
typedef long long int addr;
void* image=NULL; void* image=NULL;
const void* maps=NULL; //Per map data (1st map, second map etc.)
void setSource(lli address) { int width, height, mapc;
void setSource(addr address, int w, int h, int mc) {
image=(void*)address; image=(void*)address;
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;
}
//Testing only
int convert(int px[], int *out[]) { int convert(int px[], int *out[]) {
printf("convert...\n"); printf("convert...\n");
printf("px0: %d\n", px[0]); printf("px0: %d\n", px[0]);