diff --git a/VirtualComputer/src/sznp/virtualcomputer/PXCLib.java b/VirtualComputer/src/sznp/virtualcomputer/PXCLib.java index eb373a1..dc62f5a 100644 --- a/VirtualComputer/src/sznp/virtualcomputer/PXCLib.java +++ b/VirtualComputer/src/sznp/virtualcomputer/PXCLib.java @@ -1,5 +1,27 @@ package sznp.virtualcomputer; public interface PXCLib { + /** + * Testing only + * @param px Input array + * @param out Output array + * @return 0 + */ 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) } diff --git a/VirtualComputer/src/sznp/virtualcomputer/Test.java b/VirtualComputer/src/sznp/virtualcomputer/Test.java index 6d6f171..28ce9de 100644 --- a/VirtualComputer/src/sznp/virtualcomputer/Test.java +++ b/VirtualComputer/src/sznp/virtualcomputer/Test.java @@ -14,6 +14,6 @@ public class Test { ByteBuffer bb = ByteBuffer.allocateDirect(2); long[] x = new long[]{Pointer.nativeValue(Native.getDirectBufferPointer(bb))}; 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 } } diff --git a/libpxc/pxc.c b/libpxc/pxc.c index bc47f53..fa067f9 100644 --- a/libpxc/pxc.c +++ b/libpxc/pxc.c @@ -1,13 +1,30 @@ #include +#include -typedef long long int lli; +#define MAPSIZE 128 + +typedef long long int addr; 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; + 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[]) { printf("convert...\n"); printf("px0: %d\n", px[0]);