Remove the exit(0), and implemented a mechanism for seamless emulation

exit
This commit is contained in:
shagrath 2012-11-15 21:55:07 +01:00
parent cb9056f215
commit 067b23ced8
7 changed files with 26 additions and 51 deletions

View file

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.ab.x48" android:installLocation="auto" android:versionCode="42" android:versionName="1.42">
package="org.ab.x48" android:installLocation="auto" android:versionCode="43" android:versionName="1.43">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".X48"
android:label="@string/app_name"

View file

@ -2483,7 +2483,7 @@ emulate()
{
schedule();
}
} while (!enter_debugger); // exit_state
} while (!enter_debugger && exit_state); // exit_state
return 0;
}

View file

@ -161,8 +161,6 @@ unsigned short nibbles_short [16][8] =
static unsigned char nibble_bits[16];
jshortArray array;
jbooleanArray ann_array;
int flipable = 0;
@ -199,19 +197,22 @@ Java_org_ab_x48_X48_flipScreen( JNIEnv* env,
jint
Java_org_ab_x48_X48_fillScreenData( JNIEnv* env,
jobject this, jshortArray array) {
jobject this, jshortArray array, jbooleanArray ann_array) {
if (flipable == 1)
{
(*env)->SetShortArrayRegion(env, array, 0, ANDROID_BUF_HEADER_LENGTH, disp_buf_header_short);
(*env)->SetShortArrayRegion(env, array, ANDROID_BUF_HEADER_LENGTH, ANDROID_BUF_LENGTH, disp_buf_short);
(*env)->SetBooleanArrayRegion(env, ann_array, 0, 6, ann_boolean);
flipable = 0;
return 1;
}
return 0;
}
/*
void
#ifdef __FunctionProto__
android_refresh_screen(void)
@ -234,7 +235,7 @@ android_refresh_screen()
flipable = 0;
}
return;
}
}*/
void
#ifdef __FunctionProto__
@ -598,34 +599,11 @@ draw_annunc()
if (val == last_annunc_state)
return;
last_annunc_state = val;
/*for (i = 0; ann_tbl[i].bit; i++)
{
if ((ann_tbl[i].bit & val) == ann_tbl[i].bit)
{
XCopyPlane(dpy, ann_tbl[i].pixmap, disp.win, disp.gc, 0, 0,
ann_tbl[i].width, ann_tbl[i].height,
ann_tbl[i].x, ann_tbl[i].y, 1);
}
else
{
XClearArea(dpy, disp.win, ann_tbl[i].x, ann_tbl[i].y,
ann_tbl[i].width, ann_tbl[i].height, 0);
}
}
refresh_icon();*/
if (!ann_array)
{
ann_array = (*android_env)->NewBooleanArray(android_env, 6);
}
if(ann_array) {
for (i = 0; ann_tbl[i].bit; i++) {
ann_boolean[i] = ((ann_tbl[i].bit & val) == ann_tbl[i].bit);
}
(*android_env)->SetBooleanArrayRegion(android_env, ann_array, 0, 6, ann_boolean);
(*android_env)->CallVoidMethod(android_env, android_callback, refreshIcons, ann_array);
for (i = 0; ann_tbl[i].bit; i++) {
ann_boolean[i] = ((ann_tbl[i].bit & val) == ann_tbl[i].bit);
}
flipable = 1;
}

View file

@ -285,10 +285,7 @@ jstring port1, jstring port2 )
jclass x48 = (*android_env)->GetObjectClass(env, android_callback);
LOGI("--x48 registered--");
refreshMainScreen = (*android_env)->GetMethodID(android_env, x48, "refreshMainScreen", "([S)V");
waitEvent = (*android_env)->GetMethodID(android_env, x48, "waitEvent", "()I");
refreshIcons = (*android_env)->GetMethodID(android_env, x48, "refreshIcons", "([Z)V");
emulatorReady = (*android_env)->GetMethodID(android_env, x48, "emulatorReady", "()V");
pauseEvent = (*android_env)->GetMethodID(android_env, x48, "pauseEvent", "()V");
LOGI("--methods registered--");
}
@ -296,8 +293,10 @@ jstring port1, jstring port2 )
void
Java_org_ab_x48_X48_stopHPEmulator( JNIEnv* env, jobject thiz )
{
exit (0);
//exit_state = 0;
//exit (0);
LOGI("exit_state = 0");
exit_state = 0;
}
void
@ -376,7 +375,7 @@ sigset_t set;
LOGI("emulate loop");
(*android_env)->CallVoidMethod(android_env, android_callback, emulatorReady);
//(*android_env)->CallVoidMethod(android_env, android_callback, emulatorReady);
do {

View file

@ -123,11 +123,9 @@ static int last_icon_state = -1;
JNIEnv *android_env;
jobject android_callback;
jmethodID refreshMainScreen;
jmethodID waitEvent;
jmethodID refreshIcons;
jmethodID emulatorReady;
jmethodID pauseEvent;
int dynamic_color;
int direct_color;
int does_backing_store;

View file

@ -148,10 +148,7 @@ extern disp_t disp;
extern JNIEnv *android_env;
extern jobject android_callback;
extern jmethodID refreshMainScreen;
extern jmethodID waitEvent;
extern jmethodID refreshIcons;
extern jmethodID emulatorReady;
extern jmethodID pauseEvent;
extern Display *dpy;

View file

@ -24,6 +24,7 @@ import android.view.WindowManager.LayoutParams;
public class X48 extends Activity {
private HPView mainView;
private boolean need_to_quit;
static final private int LOAD_ID = Menu.FIRST +1;
static final private int SAVE_ID = Menu.FIRST +2;
static final private int SETTINGS_ID = Menu.FIRST +5 ;
@ -60,7 +61,7 @@ public class X48 extends Activity {
thread = new EmulatorThread(this);
thread.start();
mainView.resume();
}
public void checkPrefs() {
@ -124,7 +125,7 @@ public class X48 extends Activity {
public native int buttonReleased(int code);
public native void registerClass(X48 instance, String rom_filename, String ram_filename, String conf_filename, String port1_filename, String port2_filename);
public native int fillAudioData(short data []);
public native int fillScreenData(short data []);
public native int fillScreenData(short data [], boolean ann []);
public native void flipScreen();
public native int loadProg(String filename);
public native void setBlankColor(short s);
@ -180,9 +181,10 @@ public class X48 extends Activity {
switch (item.getItemId()) {
case RESET_ID:
AssetUtil.copyAsset(getResources().getAssets(), true);
stopHPEmulator();
//stopHPEmulator();
finish();
return true;
need_to_quit = true;
return true;
case SAVE_ID:
saveState();
return true;
@ -402,7 +404,8 @@ private void managePort(int number, String value) {
stopHPEmulator();
if (mainView != null)
mainView.unpauseEvent();
if (need_to_quit)
System.exit(0);
}
@Override