rlm@43: package com.aurellem.gb; rlm@43: rlm@43: import java.nio.ByteBuffer; rlm@60: import java.nio.IntBuffer; rlm@56: import java.nio.ByteOrder; rlm@43: rlm@43: public class Gb { rlm@43: rlm@43: rlm@43: public Gb(){} rlm@43: rlm@43: rlm@43: /** rlm@43: * Hello World! This is just to test the native interface. rlm@43: */ rlm@48: public static native void sayHello(); rlm@43: rlm@43: /** rlm@43: * Run the emulator on a given rom rlm@43: * @param rom - the name of the rom. rlm@43: */ rlm@48: public static native void startEmulator(String rom); rlm@48: rlm@48: rlm@48: public static void loadVBA(){ rlm@48: System.loadLibrary("vba"); rlm@48: } rlm@43: rlm@53: public static native void step(); rlm@53: rlm@55: public static native void step(int keymask); rlm@55: rlm@53: public static native void shutdown(); rlm@50: rlm@56: public static native void saveState(ByteBuffer buffer, int size); rlm@56: rlm@56: public static native void loadState(ByteBuffer buffer, int size); rlm@56: rlm@58: public static final int SAVE_SIZE = 90000; rlm@56: rlm@56: public static ByteBuffer saveState(){ rlm@56: ByteBuffer buf = rlm@56: ByteBuffer.allocateDirect(SAVE_SIZE) rlm@56: .order(ByteOrder.nativeOrder()); rlm@56: buf.clear(); rlm@56: saveState(buf, SAVE_SIZE); rlm@56: buf.flip(); rlm@56: return buf; rlm@56: } rlm@56: rlm@56: public static void loadState(ByteBuffer saveState){ rlm@56: loadState(saveState, SAVE_SIZE); rlm@56: } rlm@56: rlm@59: public static native int getROMSize(); rlm@59: public static native int getRAMSize(); rlm@59: rlm@59: rlm@59: public static final int WRAM_SIZE = 0x8000; rlm@59: rlm@59: public static final int VRAM_SIZE = 0x4000; rlm@59: rlm@60: public static native void getRAM(int[] store); rlm@59: rlm@60: public static native void getROM(int[] store); rlm@59: rlm@60: public static native void getWRAM(int[] store); rlm@60: rlm@60: public static native void getVRAM(int[] store); rlm@59: rlm@43: }