diff --git a/core/hw/maple/maple_devs.cpp b/core/hw/maple/maple_devs.cpp index 0bd2d06c4..d71fc5921 100755 --- a/core/hw/maple/maple_devs.cpp +++ b/core/hw/maple/maple_devs.cpp @@ -541,6 +541,7 @@ struct maple_sega_vmu: maple_base } } config->SetImage(lcd_data_decoded); + push_vmu_screen(lcd_data_decoded); #if 0 // Update LCD window if (!dev->lcd.visible) diff --git a/core/hw/maple/maple_devs.h b/core/hw/maple/maple_devs.h index 936fc4fd6..7d2146548 100644 --- a/core/hw/maple/maple_devs.h +++ b/core/hw/maple/maple_devs.h @@ -31,3 +31,4 @@ struct maple_device maple_device* maple_Create(MapleDeviceType type); #define SIZE_OF_MIC_DATA 480 //ALSO DEFINED IN SipEmulator.java int get_mic_data(u8* buffer); //implemented in Android.cpp +int push_vmu_screen(u8* buffer); //implemented in Android.cpp diff --git a/shell/android/jni/src/Android.cpp b/shell/android/jni/src/Android.cpp index 4d4c7e931..235152883 100644 --- a/shell/android/jni/src/Android.cpp +++ b/shell/android/jni/src/Android.cpp @@ -40,6 +40,7 @@ extern "C" JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupMic(JNIEnv *env,jobject obj,jobject sip) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_vmuSwap(JNIEnv *env,jobject obj) __attribute__((visibility("default"))); + JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupVmu(JNIEnv *env,jobject obj,jobject sip) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_dynarec(JNIEnv *env,jobject obj, jint dynarec) __attribute__((visibility("default"))); JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_idleskip(JNIEnv *env,jobject obj, jint idleskip) __attribute__((visibility("default"))); @@ -283,12 +284,18 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_init(JNIEnv *env,jobj #define SAMPLE_COUNT 512 JNIEnv* jenv; +//stuff for audio jshortArray jsamples; jmethodID writemid; jobject track; - +//stuff for microphone jobject sipemu; jmethodID getmicdata; +//stuff for vmu lcd +jobject vmulcd; +jbyteArray jpix; +jmethodID updatevmuscreen; + JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_run(JNIEnv *env,jobject obj,jobject trk) { @@ -311,6 +318,13 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupMic(JNIEnv *env, mcfg_Create(MDT_Microphone,0,1); } +JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_setupVmu(JNIEnv *env,jobject obj,jobject vmu) +{ + vmulcd = env->NewGlobalRef(vmu); + updatevmuscreen = env->GetMethodID(env->GetObjectClass(vmu),"updateBytes","([B)V"); + jpix=jenv->NewByteArray(1536); +} + JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_stop(JNIEnv *env,jobject obj) { dc_term(); @@ -318,8 +332,6 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_stop(JNIEnv *env,jobj JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_vmuSwap(JNIEnv *env,jobject obj) { - LOGD("vmuSwap go!"); - maple_device* olda = MapleDevices[0][0]; maple_device* oldb = MapleDevices[0][1]; MapleDevices[0][0] = NULL; @@ -328,9 +340,6 @@ JNIEXPORT void JNICALL Java_com_reicast_emulator_emu_JNIdc_vmuSwap(JNIEnv *env,j MapleDevices[0][0] = oldb; MapleDevices[0][1] = olda; - - LOGD("vmuSwap done"); - } JNIEXPORT jint JNICALL Java_com_reicast_emulator_emu_JNIdc_send(JNIEnv *env,jobject obj,jint cmd, jint param) @@ -466,3 +475,10 @@ int get_mic_data(u8* buffer) jenv->DeleteLocalRef(jdata); return 1; } + +int push_vmu_screen(u8* buffer) +{ + jenv->SetByteArrayRegion(jpix,0,1536,(jbyte*)buffer); + jenv->CallVoidMethod(vmulcd,updatevmuscreen,jpix); + return 1; +} diff --git a/shell/android/src/com/reicast/emulator/config/InputModFragment.java b/shell/android/src/com/reicast/emulator/config/InputModFragment.java index ece965b2a..8d823b47b 100644 --- a/shell/android/src/com/reicast/emulator/config/InputModFragment.java +++ b/shell/android/src/com/reicast/emulator/config/InputModFragment.java @@ -60,7 +60,6 @@ public class InputModFragment extends Fragment { public void onViewCreated(View view, Bundle savedInstanceState) { parentActivity = getActivity(); - Runtime.getRuntime().freeMemory(); System.gc(); mPrefs = PreferenceManager.getDefaultSharedPreferences(parentActivity); @@ -413,7 +412,6 @@ public class InputModFragment extends Fragment { return getButtonImage(x, y); } else { E.printStackTrace(); - Runtime.getRuntime().freeMemory(); System.gc(); } } diff --git a/shell/android/src/com/reicast/emulator/emu/GL2JNIActivity.java b/shell/android/src/com/reicast/emulator/emu/GL2JNIActivity.java index b6b0d25b9..1e72e0eca 100644 --- a/shell/android/src/com/reicast/emulator/emu/GL2JNIActivity.java +++ b/shell/android/src/com/reicast/emulator/emu/GL2JNIActivity.java @@ -10,6 +10,7 @@ import android.app.Activity; import android.content.Intent; import android.content.SharedPreferences; import android.content.res.Configuration; +import android.graphics.Color; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -58,6 +59,7 @@ public class GL2JNIActivity extends Activity { ConfigureFragment.getCurrentConfiguration(prefs); menu = new OnScreenMenu(GL2JNIActivity.this, prefs); popUp = menu.createPopup(); + /* * try { //int rID = * getResources().getIdentifier("fortyonepost.com.lfas:raw/syms.map", @@ -279,6 +281,10 @@ public class GL2JNIActivity extends Activity { sip.startRecording(); JNIdc.setupMic(sip); } + + //setup vmu screen + JNIdc.setupVmu(menu.getVmuLcd()); + } private void runCompatibilityMode() { diff --git a/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java b/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java index 042a73383..5529f7e97 100644 --- a/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java +++ b/shell/android/src/com/reicast/emulator/emu/GL2JNIView.java @@ -103,7 +103,6 @@ public class GL2JNIView extends GLSurfaceView vib=(Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); - Runtime.getRuntime().freeMemory(); System.gc(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); diff --git a/shell/android/src/com/reicast/emulator/emu/JNIdc.java b/shell/android/src/com/reicast/emulator/emu/JNIdc.java index 02b992704..fd1f57a83 100644 --- a/shell/android/src/com/reicast/emulator/emu/JNIdc.java +++ b/shell/android/src/com/reicast/emulator/emu/JNIdc.java @@ -25,7 +25,7 @@ public class JNIdc public static native void setupMic(Object sip); public static native void vmuSwap(); - + public static native void setupVmu(Object sip); public static native void dynarec(int dynarec); public static native void idleskip(int idleskip); public static native void unstable(int unstable); diff --git a/shell/android/src/com/reicast/emulator/emu/OnScreenMenu.java b/shell/android/src/com/reicast/emulator/emu/OnScreenMenu.java index bff96a62c..164bcfbc2 100644 --- a/shell/android/src/com/reicast/emulator/emu/OnScreenMenu.java +++ b/shell/android/src/com/reicast/emulator/emu/OnScreenMenu.java @@ -29,6 +29,7 @@ public class OnScreenMenu { private boolean widescreen; private boolean limitframes; private boolean audiodisabled; + private VmuLcd vmuLcd; private Vector popups; @@ -64,6 +65,9 @@ public class OnScreenMenu { popUp.dismiss(); } }), params); + + vmuLcd = new VmuLcd(mContext); + hlay.addView(vmuLcd, params); hlay.addView(addbut(R.drawable.vmu_swap, new OnClickListener() { public void onClick(View v) { @@ -319,4 +323,8 @@ public class OnScreenMenu { return but; } + + public VmuLcd getVmuLcd(){ + return vmuLcd; + } } diff --git a/shell/android/src/com/reicast/emulator/emu/VmuLcd.java b/shell/android/src/com/reicast/emulator/emu/VmuLcd.java new file mode 100644 index 000000000..66027fe5a --- /dev/null +++ b/shell/android/src/com/reicast/emulator/emu/VmuLcd.java @@ -0,0 +1,42 @@ +package com.reicast.emulator.emu; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Canvas; +import android.graphics.Color; +import android.util.Log; +import android.view.View; + +public class VmuLcd extends View { + + public final static int w = 48; + public final static int h = 32; + + private int[] image = new int[w*h]; + private Bitmap current = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888); + private float scale; + + public VmuLcd(Context context) { + super(context); + + scale = (float)OnScreenMenu.getPixelsFromDp(60, getContext()) / w; + Log.d("VmuLcd", "scale: "+scale); + } + + public void updateBytes(byte[] data){ + for(int i=0; i