Update the Win32 layer from the Emu42 one and improve UI.

This commit is contained in:
dgis 2019-05-02 23:57:15 +02:00
parent 54833e4abd
commit c6afc54a62
9 changed files with 124 additions and 22 deletions

View file

@ -56,7 +56,7 @@ NOT WORKING YET
CHANGES
Version 1.4 (2019-04-xx)
Version 1.4 (2019-05-xx)
- Add a RAM card generator for the port 2 of the HP48SX and HP48GX.
- Add the possibility to hide the status and/or the navigation bars.
@ -134,7 +134,6 @@ TODO
- Sometimes the "busy" annunciator gets stuck
- Add KML script loading dependencies fallback to the inner ROM (and may be KML include?)
- Add a separation between the pixels (Suggestion from Jaime Meza)
- Add a true fullscreen mode under the status bar and the bottom buttons
- Improve the access to the menu
- Change the logo following the template

View file

@ -41,7 +41,7 @@ android {
cmake {
//abiFilters 'arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64'
//abiFilters 'x86_64'
version "3.10.2"
//version "3.10.2"
}
}
}

View file

@ -56,7 +56,7 @@ NOT WORKING YET
CHANGES
Version 1.4 (2019-04-xx)
Version 1.4 (2019-05-xx)
- Add a RAM card generator for the port 2 of the HP48SX and HP48GX.
- Add the possibility to hide the status and/or the navigation bars.

View file

@ -18,6 +18,7 @@ static jobject viewToUpdate = NULL;
static jobject mainActivity = NULL;
jobject bitmapMainScreen;
AndroidBitmapInfo androidBitmapInfo;
enum DialogBoxMode currentDialogBoxMode;
enum ChooseKmlMode chooseCurrentKmlMode;
TCHAR szChosenCurrentKml[MAX_PATH];
TCHAR szKmlLog[10240];
@ -905,6 +906,9 @@ JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onBackupSave(JNIE
JNIEXPORT void JNICALL Java_org_emulator_forty_eight_NativeLib_onBackupRestore(JNIEnv *env, jobject thisz) {
SwitchToState(SM_INVALID);
RestoreBackup();
if(hLcdDC && hLcdDC->selectedBitmap) {
hLcdDC->selectedBitmap->bitmapInfoHeader->biHeight = -abs(hLcdDC->selectedBitmap->bitmapInfoHeader->biHeight);
}
if (pbyRom) SwitchToState(SM_RUN);
}

View file

@ -788,7 +788,18 @@ HGLOBAL WINAPI GlobalFree(HGLOBAL hMem) {
BOOL GetOpenFileName(LPOPENFILENAME openFilename) {
return FALSE;
}
TCHAR getSaveObjectFilenameResult[MAX_PATH];
BOOL GetSaveFileName(LPOPENFILENAME openFilename) {
if(openFilename) {
if(currentDialogBoxMode == DialogBoxMode_SET_USRPRG32
|| currentDialogBoxMode == DialogBoxMode_SET_USRPRG42) {
openFilename->nMaxFile = MAX_PATH;
openFilename->nFileExtension = 1;
openFilename->lpstrFile = getSaveObjectFilenameResult;
return TRUE;
}
}
return FALSE;
}
@ -797,14 +808,41 @@ HANDLE LoadImage(HINSTANCE hInst, LPCSTR name, UINT type, int cx, int cy, UINT f
return NULL;
}
LPARAM itemData[MAX_ITEMDATA];
TCHAR *itemString[MAX_ITEMDATA];
int itemDataCount = 0;
int selItemDataIndex[MAX_ITEMDATA];
int selItemDataCount = 0;
TCHAR labels[MAX_LABEL_SIZE];
LRESULT SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
//TODO
if(currentDialogBoxMode == DialogBoxMode_GET_USRPRG32
|| currentDialogBoxMode == DialogBoxMode_GET_USRPRG42
|| currentDialogBoxMode == DialogBoxMode_SET_USRPRG32
|| currentDialogBoxMode == DialogBoxMode_SET_USRPRG42) {
if (Msg == LB_ADDSTRING && itemDataCount < MAX_ITEMDATA) {
itemString[itemDataCount] = (TCHAR *)lParam;
return itemDataCount++;
} else if (Msg == LB_SETITEMDATA && wParam < MAX_ITEMDATA) {
itemData[wParam] = lParam;
} else if (Msg == LB_GETITEMDATA && wParam < MAX_ITEMDATA) {
return itemData[wParam];
} else if (Msg == LB_GETCOUNT) {
return itemDataCount;
} else if (Msg == LB_GETSELCOUNT) {
return selItemDataCount;
} else if (Msg == LB_GETSEL && wParam < itemDataCount && wParam < MAX_ITEMDATA) {
return selItemDataIndex[wParam];
}
}
return NULL;
}
BOOL PostMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) {
//TODO
if(hWnd == 0 && Msg == WM_COMMAND) {
int menuCommand = (wParam & 0xffff) - 40000;
int menuCommand = (int) ((wParam & 0xffff) - 40000);
LOGD("Menu Item %d", menuCommand);
sendMenuItemCommand(menuCommand);
}
@ -1714,8 +1752,13 @@ BOOL StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdc
brushColor = hdcDest->selectedBrushColor->brushColor;
}
COLORREF backgroundColor = 0xFF000000; // 0xAABBGGRR
if(hdcDest->isBackgroundColorSet) {
brushColor = hdcDest->backgroundColor;
if(sourceBitCount > 1 && destinationBitCount == 1 && hdcSrc->isBackgroundColorSet)
{
backgroundColor = hdcSrc->backgroundColor;
}
else if(sourceBitCount == 1 && destinationBitCount > 1 && hdcDest->isBackgroundColorSet)
{
backgroundColor = hdcDest->backgroundColor;
}
int dst_maxx = xDest + wDest;
@ -1762,13 +1805,15 @@ BOOL StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdc
BYTE * sourcePixel = sourcePixelBase + ((UINT)src_curx >> (UINT)3);
UINT bitNumber = (UINT) (src_curx % 8);
if(*sourcePixel & ((UINT)1 << bitNumber)) {
sourceColorPointer[0] = 0;
sourceColorPointer[1] = 0;
sourceColorPointer[2] = 0;
} else {
// Monochrome 1=White
sourceColorPointer[0] = 255;
sourceColorPointer[1] = 255;
sourceColorPointer[2] = 255;
} else {
// Monochrome 0=Black
sourceColorPointer[0] = 0;
sourceColorPointer[1] = 0;
sourceColorPointer[2] = 0;
}
sourceColorPointer[3] = 255;
break;
@ -1833,10 +1878,10 @@ BOOL StretchBlt(HDC hdcDest, int xDest, int yDest, int wDest, int hDest, HDC hdc
// black pixels on a white background.
BYTE * destinationPixel = destinationPixelBase + (x >> 3);
UINT bitNumber = x % 8;
if(brushColor == sourceColor) {
*destinationPixel |= (1 << bitNumber);
if(backgroundColor == sourceColor) {
*destinationPixel |= (1 << bitNumber); // 1 White
} else {
*destinationPixel &= ~(1 << bitNumber);
*destinationPixel &= ~(1 << bitNumber); // 0 Black
}
break;
}
@ -2013,6 +2058,12 @@ COLORREF GetPixel(HDC hdc, int x ,int y) {
x -= hdc->windowOriginX;
y -= hdc->windowOriginY;
if(!reverseHeight) {
// int YY = sourceHeight - y;
// y = YY;
y = sourceHeight - y;
}
HPALETTE palette = hdc->realizedPalette;
if(!palette)
palette = hdc->selectedPalette;
@ -2029,7 +2080,7 @@ COLORREF GetPixel(HDC hdc, int x ,int y) {
COLORREF resultColor = CLR_INVALID; // 0xAABBGGRR
if(x >= 0 && y >= 0 && x < sourceWidth && y < sourceHeight) {
BYTE * sourcePixel = pixelsSource + sourceStride * y + 4 * x;
BYTE * sourcePixel = pixelsSource + sourceStride * y;
// -> ARGB_8888
switch (sourceBitCount) {
@ -2037,6 +2088,7 @@ COLORREF GetPixel(HDC hdc, int x ,int y) {
//TODO
break;
case 4: {
sourcePixel += x >> 2;
BYTE colorIndex = (x & 0x1 ? sourcePixel[0] & (BYTE)0x0F : sourcePixel[0] >> 4);
if (palPalEntry) {
resultColor = 0xFF000000 | RGB(palPalEntry[colorIndex].peRed, palPalEntry[colorIndex].peGreen, palPalEntry[colorIndex].peBlue);
@ -2046,6 +2098,7 @@ COLORREF GetPixel(HDC hdc, int x ,int y) {
break;
}
case 8: {
sourcePixel += x;
BYTE colorIndex = sourcePixel[0];
if (palPalEntry) {
resultColor = 0xFF000000 | RGB(palPalEntry[colorIndex].peRed, palPalEntry[colorIndex].peGreen, palPalEntry[colorIndex].peBlue);
@ -2055,9 +2108,11 @@ COLORREF GetPixel(HDC hdc, int x ,int y) {
break;
}
case 24:
sourcePixel += 3 * x;
resultColor = 0xFF000000 | RGB(sourcePixel[2], sourcePixel[1], sourcePixel[0]);
break;
case 32:
sourcePixel += 4 * x;
resultColor = 0xFF000000 | RGB(sourcePixel[2], sourcePixel[1], sourcePixel[0]);
break;
default:
@ -2301,6 +2356,13 @@ UINT IsDlgButtonChecked(HWND hDlg, int nIDButton) {
}
BOOL EndDialog(HWND hDlg, INT_PTR nResult) {
//TODO
if(currentDialogBoxMode == DialogBoxMode_GET_USRPRG32
|| currentDialogBoxMode == DialogBoxMode_GET_USRPRG42
|| currentDialogBoxMode == DialogBoxMode_SET_USRPRG32
|| currentDialogBoxMode == DialogBoxMode_SET_USRPRG42) {
itemDataCount = 0;
selItemDataCount = 0;
}
return 0;
}
HANDLE FindFirstFileA(LPCSTR lpFileName, LPWIN32_FIND_DATAA lpFindFileData) {
@ -2327,6 +2389,9 @@ PIDLIST_ABSOLUTE SHBrowseForFolderA(LPBROWSEINFOA lpbi) {
//TODO
return NULL;
}
#ifndef IDD_USERCODE
#define IDD_USERCODE 121
#endif
INT_PTR DialogBoxParam(HINSTANCE hInstance, LPCTSTR lpTemplateName, HWND hWndParent, DLGPROC lpDialogFunc, LPARAM dwInitParam) {
//TODO
if(lpTemplateName == MAKEINTRESOURCE(IDD_CHOOSEKML)) {
@ -2344,6 +2409,27 @@ INT_PTR DialogBoxParam(HINSTANCE hInstance, LPCTSTR lpTemplateName, HWND hWndPar
}
} else if(lpTemplateName == MAKEINTRESOURCE(IDD_KMLLOG)) {
lpDialogFunc(NULL, WM_INITDIALOG, 0, 0);
} else if(lpTemplateName == MAKEINTRESOURCE(IDD_USERCODE)) {
if(currentDialogBoxMode == DialogBoxMode_GET_USRPRG32
|| currentDialogBoxMode == DialogBoxMode_GET_USRPRG42) {
itemDataCount = 0;
selItemDataCount = 0;
lpDialogFunc(NULL, WM_INITDIALOG, 0, 0);
LPTSTR lpLabel = labels;
for(int i = 0; i < itemDataCount; i++) {
_tcscpy(lpLabel, itemString[i]);
lpLabel += _tcslen(itemString[i]) * sizeof(TCHAR);
*lpLabel = 9; // Separator (TAB)
lpLabel++;
}
*lpLabel = 0; // End of string
lpDialogFunc(NULL, WM_COMMAND, IDCANCEL, 0);
} else if(currentDialogBoxMode == DialogBoxMode_SET_USRPRG32
|| currentDialogBoxMode == DialogBoxMode_SET_USRPRG42) {
itemDataCount = 0;
lpDialogFunc(NULL, WM_INITDIALOG, 0, 0);
lpDialogFunc(NULL, WM_COMMAND, IDOK, 0);
}
}
return IDOK;
}

View file

@ -1231,6 +1231,20 @@ enum ChooseKmlMode {
ChooseKmlMode_CHANGE_KML
};
extern enum ChooseKmlMode chooseCurrentKmlMode;
enum DialogBoxMode {
DialogBoxMode_UNKNOWN,
DialogBoxMode_GET_USRPRG32,
DialogBoxMode_SET_USRPRG32,
DialogBoxMode_GET_USRPRG42,
DialogBoxMode_SET_USRPRG42
};
extern enum DialogBoxMode currentDialogBoxMode;
#define MAX_LABEL_SIZE 5000
extern TCHAR labels[MAX_LABEL_SIZE];
#define MAX_ITEMDATA 100
extern int selItemDataIndex[MAX_ITEMDATA];
extern int selItemDataCount;
extern TCHAR getSaveObjectFilenameResult[MAX_PATH];
BOOL getFirstKMLFilenameForType(BYTE chipsetType, TCHAR * firstKMLFilename, size_t firstKMLFilenameSize);
void clipboardCopyText(const TCHAR * text);
const TCHAR * clipboardPasteText();

View file

@ -781,11 +781,12 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
kmlScriptsForCurrentModel = kmlScripts;
final int lastIndex = kmlScriptsForCurrentModel.size();
final String[] kmlScriptTitles = new String[lastIndex + 2];
final String[] kmlScriptTitles = new String[lastIndex + (lastIndex > 0 ? 2 : 1)];
for (int i = 0; i < kmlScriptsForCurrentModel.size(); i++)
kmlScriptTitles[i] = kmlScriptsForCurrentModel.get(i).title;
kmlScriptTitles[lastIndex] = getResources().getString(R.string.load_custom_kml);
kmlScriptTitles[lastIndex + 1] = getResources().getString(R.string.load_default_kml);
if(lastIndex > 0)
kmlScriptTitles[lastIndex + 1] = getResources().getString(R.string.load_default_kml);
new AlertDialog.Builder(MainActivity.this)
.setTitle(getResources().getString(R.string.pick_calculator))
.setItems(kmlScriptTitles, new DialogInterface.OnClickListener() {
@ -798,7 +799,6 @@ public class MainActivity extends AppCompatActivity implements NavigationView.On
// Reset to default KML folder
SharedPreferences.Editor editor = sharedPreferences.edit();
editor.putBoolean("settings_kml_default", true);
//editor.putString("settings_kml_folder", url);
editor.apply();
updateFromPreferences("settings_kml", true);
if(changeKML)

View file

@ -46,8 +46,8 @@
<string name="nav_item_help">Help</string>
<string name="nav_about">About Emu48...</string>
<string name="load_custom_kml">[Custom KML script...]</string>
<string name="load_default_kml">[Default KML script]</string>
<string name="load_custom_kml">[Select a Custom KML script folder...]</string>
<string name="load_default_kml">[Default KML script folder]</string>
<string name="pick_calculator">Pick a calculator</string>
<string name="create_ram_card_title">Create RAM Card</string>

View file

@ -1,5 +1,4 @@
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<!-- General -->
<PreferenceCategory android:title="@string/settings_category_general_title">