Mercurial > vba-clojure
diff java/src/com/aurellem/gb/Gb.java @ 56:ba4fdfb722ed
emabled loading and saving CPU state from clojure.
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Wed, 07 Mar 2012 14:18:44 -0600 |
parents | 719d910c90f8 |
children | 431ee7ee12de |
line wrap: on
line diff
1.1 --- a/java/src/com/aurellem/gb/Gb.java Wed Mar 07 13:24:32 2012 -0600 1.2 +++ b/java/src/com/aurellem/gb/Gb.java Wed Mar 07 14:18:44 2012 -0600 1.3 @@ -1,7 +1,7 @@ 1.4 package com.aurellem.gb; 1.5 1.6 import java.nio.ByteBuffer; 1.7 - 1.8 +import java.nio.ByteOrder; 1.9 1.10 public class Gb { 1.11 1.12 @@ -25,11 +25,30 @@ 1.13 System.loadLibrary("vba"); 1.14 } 1.15 1.16 - 1.17 public static native void step(); 1.18 1.19 public static native void step(int keymask); 1.20 1.21 public static native void shutdown(); 1.22 1.23 + public static native void saveState(ByteBuffer buffer, int size); 1.24 + 1.25 + public static native void loadState(ByteBuffer buffer, int size); 1.26 + 1.27 + public static final int SAVE_SIZE = 9000; 1.28 + 1.29 + public static ByteBuffer saveState(){ 1.30 + ByteBuffer buf = 1.31 + ByteBuffer.allocateDirect(SAVE_SIZE) 1.32 + .order(ByteOrder.nativeOrder()); 1.33 + buf.clear(); 1.34 + saveState(buf, SAVE_SIZE); 1.35 + buf.flip(); 1.36 + return buf; 1.37 + } 1.38 + 1.39 + public static void loadState(ByteBuffer saveState){ 1.40 + loadState(saveState, SAVE_SIZE); 1.41 + } 1.42 + 1.43 }