changeset 49:139178c4d843

clojure can now drive vba
author Robert McIntyre <rlm@mit.edu>
date Wed, 07 Mar 2012 01:17:53 -0600
parents 75349da4c344
children e643f55bc886
files src/clojure/Makefile.am src/clojure/clojure.c src/clojure/clojure.cpp src/sdl/Drive.h src/sdl/SDL.cpp
diffstat 5 files changed, 49 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
     1.1 --- a/src/clojure/Makefile.am	Wed Mar 07 00:36:53 2012 -0600
     1.2 +++ b/src/clojure/Makefile.am	Wed Mar 07 01:17:53 2012 -0600
     1.3 @@ -1,7 +1,7 @@
     1.4  lib_LTLIBRARIES = libvba.la
     1.5  
     1.6  libvba_la_SOURCES = \
     1.7 -	clojure.c
     1.8 +	clojure.cpp
     1.9  
    1.10  libvba_la_LIBADD =   	\
    1.11  	../common/libgbcom.la		\
     2.1 --- a/src/clojure/clojure.c	Wed Mar 07 00:36:53 2012 -0600
     2.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.3 @@ -1,26 +0,0 @@
     2.4 -#include "com_aurellem_gb_Gb.h"
     2.5 -
     2.6 -#define UNUSED(x)  (void)(x)
     2.7 -
     2.8 -
     2.9 -/*
    2.10 - * Class:     com_aurellem_gb_Gb
    2.11 - * Method:    sayHello
    2.12 - * Signature: ()V
    2.13 - */
    2.14 -JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_sayHello
    2.15 -(JNIEnv *env, jclass clazz){
    2.16 -  UNUSED(env);UNUSED(clazz);
    2.17 -  printf("Hello from GB\n");  
    2.18 -}
    2.19 -
    2.20 -/*
    2.21 - * Class:     com_aurellem_gb_Gb
    2.22 - * Method:    startEmulator
    2.23 - * Signature: (Ljava/lang/String;)V
    2.24 - */
    2.25 -JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_startEmulator
    2.26 -(JNIEnv *env, jclass clazz, jstring str){
    2.27 -  UNUSED(env);UNUSED(clazz);UNUSED(str);
    2.28 -}
    2.29 -
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/clojure/clojure.cpp	Wed Mar 07 01:17:53 2012 -0600
     3.3 @@ -0,0 +1,39 @@
     3.4 +#include "com_aurellem_gb_Gb.h"
     3.5 +#include "../sdl/Drive.h"
     3.6 +
     3.7 +#include <string.h>
     3.8 +
     3.9 +#define UNUSED(x)  (void)(x)
    3.10 +
    3.11 +
    3.12 +/*
    3.13 + * Class:     com_aurellem_gb_Gb
    3.14 + * Method:    sayHello
    3.15 + * Signature: ()V
    3.16 + */
    3.17 +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_sayHello
    3.18 +(JNIEnv *env, jclass clazz){
    3.19 +  UNUSED(env);UNUSED(clazz);
    3.20 +  printf("Hello from GB\n");  
    3.21 +}
    3.22 +
    3.23 +/*
    3.24 + * Class:     com_aurellem_gb_Gb
    3.25 + * Method:    startEmulator
    3.26 + * Signature: (Ljava/lang/String;)V
    3.27 + */
    3.28 +JNIEXPORT void JNICALL Java_com_aurellem_gb_Gb_startEmulator
    3.29 +(JNIEnv *env, jclass clazz, jstring str){
    3.30 +  UNUSED(env);UNUSED(clazz);UNUSED(str);
    3.31 +
    3.32 +  const char *_romName = env->GetStringUTFChars(str, 0);
    3.33 +  size_t len = strlen(_romName);
    3.34 +  
    3.35 +  char romName[len + 1];
    3.36 +
    3.37 +  strcpy(romName, _romName);
    3.38 + 
    3.39 +  char* arguments[] = {"vba-rlm", romName};
    3.40 +  runVBA(2, arguments);
    3.41 +}
    3.42 +
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/sdl/Drive.h	Wed Mar 07 01:17:53 2012 -0600
     4.3 @@ -0,0 +1,2 @@
     4.4 +int runVBA(int, char**);
     4.5 +
     5.1 --- a/src/sdl/SDL.cpp	Wed Mar 07 00:36:53 2012 -0600
     5.2 +++ b/src/sdl/SDL.cpp	Wed Mar 07 01:17:53 2012 -0600
     5.3 @@ -44,7 +44,7 @@
     5.4  #include "common/inputGlobal.h"
     5.5  #include "../common/vbalua.h"
     5.6  #include "SoundSDL.h"
     5.7 -
     5.8 +#include "Drive.h"
     5.9  
    5.10  #define GBC_CAPABLE ((gbRom[0x143] & 0x80) != 0)
    5.11  #define SGB_CAPABLE (gbRom[0x146] == 0x03)
    5.12 @@ -2705,6 +2705,12 @@
    5.13    return 0;
    5.14  }
    5.15  
    5.16 +// RLM
    5.17 +int runVBA(int argc, char **argv){
    5.18 +  return main(argc, argv);
    5.19 +}
    5.20 +
    5.21 +
    5.22  void systemMessage(int num, const char *msg, ...)
    5.23  {
    5.24    char buffer[2048];