view java/src/com/aurellem/gb/Gb.java @ 59:3ce48d803e74

added functions to get rom/ram sizes
author Robert McIntyre <rlm@mit.edu>
date Wed, 07 Mar 2012 17:40:00 -0600
parents 431ee7ee12de
children ef59aee6d715
line wrap: on
line source
1 package com.aurellem.gb;
3 import java.nio.ByteBuffer;
4 import java.nio.ByteOrder;
6 public class Gb {
9 public Gb(){}
12 /**
13 * Hello World! This is just to test the native interface.
14 */
15 public static native void sayHello();
17 /**
18 * Run the emulator on a given rom
19 * @param rom - the name of the rom.
20 */
21 public static native void startEmulator(String rom);
24 public static void loadVBA(){
25 System.loadLibrary("vba");
26 }
28 public static native void step();
30 public static native void step(int keymask);
32 public static native void shutdown();
34 public static native void saveState(ByteBuffer buffer, int size);
36 public static native void loadState(ByteBuffer buffer, int size);
38 public static final int SAVE_SIZE = 90000;
40 public static ByteBuffer saveState(){
41 ByteBuffer buf =
42 ByteBuffer.allocateDirect(SAVE_SIZE)
43 .order(ByteOrder.nativeOrder());
44 buf.clear();
45 saveState(buf, SAVE_SIZE);
46 buf.flip();
47 return buf;
48 }
50 public static void loadState(ByteBuffer saveState){
51 loadState(saveState, SAVE_SIZE);
52 }
54 public static native int getROMSize();
55 public static native int getRAMSize();
58 public static final int WRAM_SIZE = 0x8000;
60 public static final int VRAM_SIZE = 0x4000;
65 }