From 23184e86d2a627855bd6e9b71a77ee6884ee89a3 Mon Sep 17 00:00:00 2001 From: dgis Date: Sun, 15 Nov 2020 16:42:39 +0100 Subject: [PATCH] Version 2.0 (2020-11-15) --- ReadMe.txt | 10 +- app/src/main/assets/ReadMe.txt | 3 +- app/src/main/cpp/emu-jni.c | 12 +- app/src/main/cpp/win32-layer.c | 36 +- .../forty/eight/SettingsFragment.java | 40 +- app/src/main/res/values/strings.xml | 6 +- app/src/main/res/xml/pref_general.xml | 359 ++++++++---------- 7 files changed, 234 insertions(+), 232 deletions(-) diff --git a/ReadMe.txt b/ReadMe.txt index bd747ac..792cc15 100644 --- a/ReadMe.txt +++ b/ReadMe.txt @@ -63,7 +63,7 @@ LINKS CHANGES -Version 2.0 (2020-11-XX) +Version 2.0 (2020-11-15) - Updated source code from Eric Rechlin's Emu48 version 1.62+ that was merged from Christoph Gießelink's Emu48 version 1.63. - For the HP49/50 port 2, it is now possible to load a new Flash ROM file (It fully replaces the ROM). @@ -72,6 +72,7 @@ Version 2.0 (2020-11-XX) - Fix a printer issue from Christoph Gießelink's HP82240B Printer Simulator version 1.12. - Fix the KML button Type 3 with a Background offset which was not display at the right location (Fix #15). - Fix a timer issue. +- Fix a freeze with a hp48 sx or gx, when switching on/off several times port 1 and 2! Version 1.9 (2020-09-07) @@ -219,21 +220,18 @@ TODO - Manage the HP 48 port 2 with the same kind of interface for the memory card. - The render pixels are very nice. A solution to obtain uniform pixel size could be a preset (a multiplier, auto) so the user could decide and upscale/downscale (Michael P). -- Bug: In Xiaomi mi A3 under Android10, the haptic feedback does not work (add an intensity setting). - Somehow LEFT (Shift on the keyboard) + 7 activates the DIVIDE-key (z-Key)..., but with the NUM-Key it can make it work without problems... I think it might have something to do with the "/" sign on the Shifted-7-key. - The clock seems unsynchronized sometimes (Michael P). - Retain a key by right clicking if it is from a mouse. -- Add the possibility to load and save the flash in another file. - Sometimes, the calculator seems to lag and finally freeze. -- In Chrome OS: - - sometimes there is no OK button in the KML Script Compilation Result. +- In Chrome OS, sometimes there is no OK button in the KML Script Compilation Result. - Add KML script loading dependencies fallback to the inner ROM (and may be KML include?). BUILD -Emu48 for Android is built with Android Studio 4.0 (2020). +Emu48 for Android is built with Android Studio 4.1 (2020). And to generate an installable APK file with a real Android device, it MUST be signed. Either use Android Studio: diff --git a/app/src/main/assets/ReadMe.txt b/app/src/main/assets/ReadMe.txt index 4f15d42..119409b 100644 --- a/app/src/main/assets/ReadMe.txt +++ b/app/src/main/assets/ReadMe.txt @@ -63,7 +63,7 @@ LINKS CHANGES -Version 2.0 (2020-11-XX) +Version 2.0 (2020-11-15) - Updated source code from Eric Rechlin's Emu48 version 1.62+ that was merged from Christoph Gießelink's Emu48 version 1.63. - For the HP49/50 port 2, it is now possible to load a new Flash ROM file (It fully replaces the ROM). @@ -72,6 +72,7 @@ Version 2.0 (2020-11-XX) - Fix a printer issue from Christoph Gießelink's HP82240B Printer Simulator version 1.12. - Fix the KML button Type 3 with a Background offset which was not display at the right location (Fix #15). - Fix a timer issue. +- Fix a freeze with a hp48 sx or gx, when switching on/off several times port 1 and 2! Version 1.9 (2020-09-07) diff --git a/app/src/main/cpp/emu-jni.c b/app/src/main/cpp/emu-jni.c index 44762c7..066f314 100644 --- a/app/src/main/cpp/emu-jni.c +++ b/app/src/main/cpp/emu-jni.c @@ -1047,7 +1047,9 @@ JNIEXPORT void JNICALL Java_org_emulator_calculator_NativeLib_setConfiguration(J const char *configKey = (*env)->GetStringUTFChars(env, key, NULL) ; const char *configStringValue = stringValue ? (*env)->GetStringUTFChars(env, stringValue, NULL) : NULL; - bAutoSave = FALSE; + //LOGE("NativeLib_setConfiguration(%s, %d, %d, %s)", configKey, intValue1, intValue2, configStringValue); + + bAutoSave = FALSE; bAutoSaveOnExit = FALSE; bLoadObjectWarning = FALSE; bAlwaysDisplayLog = TRUE; @@ -1081,7 +1083,9 @@ JNIEXPORT void JNICALL Java_org_emulator_calculator_NativeLib_setConfiguration(J if (Chipset.Port1Size && (cCurrentRomType!='X' || cCurrentRomType!='2' || cCurrentRomType!='Q')) // CdB for HP: add apples { UINT nOldState = SwitchToState(SM_SLEEP); - // save old card status + //LOGE("NativeLib_setConfiguration port1 start SwitchToState %d -> SM_SLEEP", nOldState); + + // save old card status BYTE byCardsStatus = Chipset.cards_status; // port1 disabled? @@ -1103,7 +1107,9 @@ JNIEXPORT void JNICALL Java_org_emulator_calculator_NativeLib_setConfiguration(J Chipset.SoftInt = TRUE; // set interrupt bInterrupt = TRUE; } + //LOGE("NativeLib_setConfiguration port1 end SwitchToState %d", nOldState); SwitchToState(nOldState); + while (nState!=nNextState) Sleep(0); } } else if(_tcscmp(_T("settings_port2"), configKey) == 0) { settingsPort2en = (BOOL)intValue1; @@ -1139,6 +1145,7 @@ JNIEXPORT void JNICALL Java_org_emulator_calculator_NativeLib_setConfiguration(J if (bPort2CfgChange) // slot2 configuration changed { UINT nOldState = SwitchToState(SM_INVALID); + //LOGE("NativeLib_setConfiguration port2 start SwitchToState %d -> SM_INVALID", nOldState); UnmapPort2(); // unmap port2 @@ -1159,6 +1166,7 @@ JNIEXPORT void JNICALL Java_org_emulator_calculator_NativeLib_setConfiguration(J // save fingerprint of port2 Chipset.wPort2Crc = wPort2Crc; } + //LOGE("NativeLib_setConfiguration port2 end SwitchToState %d", nOldState); SwitchToState(nOldState); } } diff --git a/app/src/main/cpp/win32-layer.c b/app/src/main/cpp/win32-layer.c index 1ce2db3..a795b96 100644 --- a/app/src/main/cpp/win32-layer.c +++ b/app/src/main/cpp/win32-layer.c @@ -612,8 +612,19 @@ DWORD ResumeThread(HANDLE hThread) { BOOL SetThreadPriority(HANDLE hThread, int nPriority) { THREAD_LOGD("SetThreadPriority()"); - //TODO - return 0; +// if(hThread->handleType == HANDLE_TYPE_THREAD) { +// int policy; +// struct sched_param param; +// int result = pthread_getschedparam(hThread->threadId, &policy, ¶m); +// if(nPriority == THREAD_PRIORITY_HIGHEST) { +// param.sched_priority = sched_get_priority_min(policy); +// param.sched_priority = sched_get_priority_max(policy); +// } +// result = pthread_setschedparam(hThread->threadId, policy, ¶m); +// // THIS DOES NOT WORK WITH ANDROID! +// return TRUE; +// } + return FALSE; } @@ -733,14 +744,19 @@ BOOL WINAPI CloseHandle(HANDLE hObject) { return FALSE; } -void Sleep(int ms) -{ - time_t seconds = ms / 1000; - long milliseconds = ms - 1000 * seconds; - struct timespec timeOut, remains; - timeOut.tv_sec = seconds; - timeOut.tv_nsec = milliseconds * 1000000; /* 50 milliseconds */ - nanosleep(&timeOut, &remains); +void Sleep(int ms) { + if(ms == 0) { + // Because sched_yield() does not seem to work with Android, try to increase the pause duration, + // hoping to switch to the others thread (WorkerThread). + ms = 1; + } + sched_yield(); + time_t seconds = ms / 1000; + long milliseconds = ms - 1000 * seconds; + struct timespec timeOut, remains; + timeOut.tv_sec = seconds; + timeOut.tv_nsec = milliseconds * 1000000; + nanosleep(&timeOut, &remains); } BOOL QueryPerformanceFrequency(PLARGE_INTEGER l) { diff --git a/app/src/main/java/org/emulator/forty/eight/SettingsFragment.java b/app/src/main/java/org/emulator/forty/eight/SettingsFragment.java index 5edf2cd..85e3018 100644 --- a/app/src/main/java/org/emulator/forty/eight/SettingsFragment.java +++ b/app/src/main/java/org/emulator/forty/eight/SettingsFragment.java @@ -350,25 +350,27 @@ public class SettingsFragment extends AppCompatDialogFragment { Preference preferenceFlashPort2 = findPreference("settings_flash_port2"); if(preferenceFlashPort2 != null) { - String flashPort2Filename = settings.getString(preferenceFlashPort2.getKey(), ""); - String displayName = flashPort2Filename; - try { - displayName = Utils.getFileName(getActivity(), flashPort2Filename); - } catch (Exception e) { - // Do nothing - } - preferenceFlashPort2.setSummary(displayName); - //TODO offer the possibility to manage the Flash from here too. -// preferenceFlashPort2.setOnPreferenceClickListener(preference -> { -// Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); -// intent.addCategory(Intent.CATEGORY_OPENABLE); -// intent.setType("*/*"); -// intent.putExtra(Intent.EXTRA_TITLE, "shared.bin"); -// Fragment parentFragment = getParentFragment(); -// if (parentFragment != null) -// parentFragment.startActivityForResult(intent, MainActivity.INTENT_PORT2LOAD); -// return true; -// }); + int cCurrentRomType = NativeLib.getCurrentModel(); + if(cCurrentRomType == 'X' || cCurrentRomType == 'Q') { + String flashPort2Filename = settings.getString(preferenceFlashPort2.getKey(), ""); + String displayName = flashPort2Filename; + try { + displayName = Utils.getFileName(getActivity(), flashPort2Filename); + } catch (Exception e) { + // Do nothing + } + preferenceFlashPort2.setSummary(displayName); + //TODO offer the possibility to manage the Flash from here too. + preferenceFlashPort2.setOnPreferenceClickListener(preference -> { + new AlertDialog.Builder(requireContext()) + .setTitle(getString(R.string.settings_flash_port2_title)) + .setMessage(getString(R.string.settings_flash_port2_dialog_description)) + .setPositiveButton(android.R.string.ok, (dialog1, which1) -> { + }).show(); + return true; + }); + } else + preferenceFlashPort2.setEnabled(false); } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7b0486d..149f477 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -47,7 +47,7 @@ Change KML Script... Show the Printer Simulator... Tool - Create RAM Card... + Create RAM Card (HP48)... Manage Flash ROM (HP49)... Record Macro... Play Macro... @@ -175,13 +175,15 @@ Custom color Used when selecting the \'Custom color\' in the \'Other possible colors\' - Memory Cards + Memory Cards HP48 Port 1 is Plugged Port 1 is Writable Port 2 is Plugged Port 2 is Writable Port 2 File + Memory Cards HP49/50 Port 2 Flash File + This file can be set from the main menu item "Manage Flash ROM (HP49)...". Printer Simulator Printer Model diff --git a/app/src/main/res/xml/pref_general.xml b/app/src/main/res/xml/pref_general.xml index c082869..9c5c20b 100644 --- a/app/src/main/res/xml/pref_general.xml +++ b/app/src/main/res/xml/pref_general.xml @@ -1,204 +1,179 @@ - - - - - - - - + + + + + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - - - - - - - - + + + + + + + + + + - - - + + + + + + + - - - - + + + + + + + - - - - - - - - - - - - - - - - - - - - - + + +