rlm@43
|
1 package com.aurellem.gb;
|
rlm@43
|
2
|
rlm@43
|
3 import java.nio.ByteBuffer;
|
rlm@60
|
4 import java.nio.IntBuffer;
|
rlm@56
|
5 import java.nio.ByteOrder;
|
rlm@43
|
6
|
rlm@43
|
7 public class Gb {
|
rlm@43
|
8
|
rlm@43
|
9
|
rlm@43
|
10 public Gb(){}
|
rlm@43
|
11
|
rlm@43
|
12
|
rlm@43
|
13 /**
|
rlm@43
|
14 * Hello World! This is just to test the native interface.
|
rlm@43
|
15 */
|
rlm@48
|
16 public static native void sayHello();
|
rlm@43
|
17
|
rlm@43
|
18 /**
|
rlm@43
|
19 * Run the emulator on a given rom
|
rlm@43
|
20 * @param rom - the name of the rom.
|
rlm@43
|
21 */
|
rlm@48
|
22 public static native void startEmulator(String rom);
|
rlm@48
|
23
|
rlm@48
|
24
|
rlm@48
|
25 public static void loadVBA(){
|
rlm@48
|
26 System.loadLibrary("vba");
|
rlm@48
|
27 }
|
rlm@43
|
28
|
rlm@53
|
29 public static native void step();
|
rlm@53
|
30
|
rlm@55
|
31 public static native void step(int keymask);
|
rlm@55
|
32
|
rlm@53
|
33 public static native void shutdown();
|
rlm@50
|
34
|
rlm@56
|
35 public static native void saveState(ByteBuffer buffer, int size);
|
rlm@56
|
36
|
rlm@56
|
37 public static native void loadState(ByteBuffer buffer, int size);
|
rlm@56
|
38
|
rlm@58
|
39 public static final int SAVE_SIZE = 90000;
|
rlm@56
|
40
|
rlm@56
|
41 public static ByteBuffer saveState(){
|
rlm@56
|
42 ByteBuffer buf =
|
rlm@56
|
43 ByteBuffer.allocateDirect(SAVE_SIZE)
|
rlm@56
|
44 .order(ByteOrder.nativeOrder());
|
rlm@56
|
45 buf.clear();
|
rlm@56
|
46 saveState(buf, SAVE_SIZE);
|
rlm@56
|
47 buf.flip();
|
rlm@56
|
48 return buf;
|
rlm@56
|
49 }
|
rlm@56
|
50
|
rlm@56
|
51 public static void loadState(ByteBuffer saveState){
|
rlm@56
|
52 loadState(saveState, SAVE_SIZE);
|
rlm@56
|
53 }
|
rlm@56
|
54
|
rlm@59
|
55 public static native int getROMSize();
|
rlm@59
|
56 public static native int getRAMSize();
|
rlm@59
|
57
|
rlm@59
|
58
|
rlm@59
|
59 public static final int WRAM_SIZE = 0x8000;
|
rlm@59
|
60
|
rlm@59
|
61 public static final int VRAM_SIZE = 0x4000;
|
rlm@59
|
62
|
rlm@62
|
63 public static final int NUM_REGISTERS = 27;
|
rlm@62
|
64
|
rlm@60
|
65 public static native void getRAM(int[] store);
|
rlm@59
|
66
|
rlm@60
|
67 public static native void getROM(int[] store);
|
rlm@59
|
68
|
rlm@60
|
69 public static native void getWRAM(int[] store);
|
rlm@60
|
70
|
rlm@60
|
71 public static native void getVRAM(int[] store);
|
rlm@62
|
72
|
rlm@62
|
73 public static native void getRegisters(int[] store);
|
rlm@43
|
74 }
|