mirror of
https://github.com/dgis/emu48android
synced 2024-12-26 09:58:49 +01:00
This commit is contained in:
parent
d76f121e8c
commit
2fadb7d2d7
9 changed files with 101 additions and 93 deletions
|
@ -23,7 +23,7 @@ add_library( # Sets the name of the library.
|
|||
# src/main/cpp/cursor.c
|
||||
# src/main/cpp/ddeserv.c
|
||||
# src/main/cpp/debugger.c
|
||||
# src/main/cpp/disasm.c
|
||||
src/main/cpp/disasm.c
|
||||
src/main/cpp/dismem.c
|
||||
src/main/cpp/display.c
|
||||
src/main/cpp/disrpl.c
|
||||
|
@ -34,7 +34,7 @@ add_library( # Sets the name of the library.
|
|||
src/main/cpp/files.c
|
||||
src/main/cpp/i28f160.c
|
||||
src/main/cpp/keyboard.c
|
||||
# src/main/cpp/keymacro.c
|
||||
src/main/cpp/keymacro.c
|
||||
src/main/cpp/kml.c
|
||||
src/main/cpp/lodepng.c
|
||||
src/main/cpp/lowbat.c
|
||||
|
|
|
@ -2251,6 +2251,9 @@ BOOL emu48Start()
|
|||
// no default document, ask for new one
|
||||
if (NewDocument()) SetWindowTitle(_T("Untitled"));
|
||||
|
||||
mainViewResizeCallback(nBackgroundW, nBackgroundH);
|
||||
|
||||
|
||||
//BitBlt(hWindowDC, 0, 0, hMainDC->selectedBitmap->bitmapInfoHeader->biWidth, hMainDC->selectedBitmap->bitmapInfoHeader->biHeight, hMainDC, 0, 0, 0);
|
||||
OnPaint(NULL);
|
||||
//start:
|
||||
|
@ -2314,8 +2317,6 @@ void draw() {
|
|||
OnPaint(NULL);
|
||||
}
|
||||
|
||||
INT nMacroState = MACRO_OFF;
|
||||
|
||||
void buttonDown(int x, int y) {
|
||||
OnLButtonDown(0, x, y);
|
||||
}
|
||||
|
|
|
@ -31,63 +31,8 @@ VOID SoundOut(CHIPSET* w, WORD wOut) {
|
|||
VOID SoundBeep(DWORD dwFrequency, DWORD dwDuration) {
|
||||
}
|
||||
|
||||
// Emu48.c
|
||||
|
||||
#define VERSION "1.59+"
|
||||
|
||||
//static BOOL bOwnCursor = FALSE;
|
||||
//static BOOL bTitleBar = TRUE;
|
||||
//
|
||||
//CRITICAL_SECTION csGDILock; // critical section for hWindowDC
|
||||
//CRITICAL_SECTION csLcdLock; // critical section for display update
|
||||
//CRITICAL_SECTION csKeyLock; // critical section for key scan
|
||||
//CRITICAL_SECTION csIOLock; // critical section for I/O access
|
||||
//CRITICAL_SECTION csT1Lock; // critical section for timer1 access
|
||||
//CRITICAL_SECTION csT2Lock; // critical section for timer2 access
|
||||
//CRITICAL_SECTION csTxdLock; // critical section for transmit byte
|
||||
//CRITICAL_SECTION csRecvLock; // critical section for receive byte
|
||||
//CRITICAL_SECTION csSlowLock; // critical section for speed slow down
|
||||
//CRITICAL_SECTION csDbgLock; // critical section for debugger purpose
|
||||
//INT nArgc; // no. of command line arguments
|
||||
//LPCTSTR *ppArgv; // command line arguments
|
||||
//LARGE_INTEGER lFreq; // high performance counter frequency
|
||||
//LARGE_INTEGER lAppStart; // high performance counter value at Appl. start
|
||||
//DWORD idDdeInst; // DDE server id
|
||||
//UINT uCF_HpObj; // DDE clipboard format
|
||||
//HANDLE hThread;
|
||||
//HANDLE hEventShutdn; // event handle to stop cpu thread
|
||||
//
|
||||
//HINSTANCE hApp = NULL;
|
||||
//HWND hWnd = NULL;
|
||||
//HWND hDlgDebug = NULL; // handle for debugger dialog
|
||||
//HWND hDlgFind = NULL; // handle for debugger find dialog
|
||||
//HWND hDlgProfile = NULL; // handle for debugger profile dialog
|
||||
//HWND hDlgRplObjView = NULL; // handle for debugger rpl object viewer
|
||||
//HDC hWindowDC = NULL;
|
||||
//HPALETTE hPalette = NULL;
|
||||
//HPALETTE hOldPalette = NULL; // old palette of hWindowDC
|
||||
//DWORD dwTColor = (DWORD) -1; // transparency color
|
||||
//DWORD dwTColorTol = 0; // transparency color tolerance
|
||||
//HRGN hRgn = NULL;
|
||||
//HCURSOR hCursorArrow = NULL;
|
||||
//HCURSOR hCursorHand = NULL;
|
||||
//UINT uWaveDevId = WAVE_MAPPER; // default audio device
|
||||
//DWORD dwWakeupDelay = 200; // ON key hold time to switch on calculator
|
||||
//BOOL bAutoSave = FALSE;
|
||||
//BOOL bAutoSaveOnExit = TRUE;
|
||||
//BOOL bSaveDefConfirm = TRUE; // yes
|
||||
//BOOL bStartupBackup = FALSE;
|
||||
//BOOL bAlwaysDisplayLog = TRUE;
|
||||
//BOOL bLoadObjectWarning = TRUE;
|
||||
//BOOL bShowTitle = TRUE; // show main window title bar
|
||||
//BOOL bShowMenu = TRUE; // show main window menu bar
|
||||
//BOOL bAlwaysOnTop = FALSE; // emulator window always on top
|
||||
//BOOL bActFollowsMouse = FALSE; // emulator window activation follows mouse
|
||||
//BOOL bClientWinMove = FALSE; // emulator window can be moved over client area
|
||||
//BOOL bSingleInstance = FALSE; // multiple emulator instances allowed
|
||||
|
||||
// udp.c
|
||||
|
||||
TCHAR szUdpServer[1024] = _T("localhost");
|
||||
WORD wUdpPort = 5025; // scpi-raw
|
||||
|
||||
|
@ -127,25 +72,4 @@ VOID CreateBackupBreakpointList(VOID) {
|
|||
VOID RestoreBackupBreakpointList(VOID) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Disasm.c
|
||||
BOOL disassembler_mode = HP_MNEMONICS;
|
||||
BOOL disassembler_symb = FALSE;
|
||||
DWORD disassemble(DWORD addr, LPTSTR out) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Keymacro.c
|
||||
//INT nMacroState;
|
||||
INT nMacroTimeout;
|
||||
BOOL bMacroRealSpeed;
|
||||
DWORD dwMacroMinDelay;
|
||||
VOID KeyMacroRecord(BOOL bPress, UINT out, UINT in) {
|
||||
return;
|
||||
}
|
||||
//LRESULT OnToolMacroNew(VOID);
|
||||
//LRESULT OnToolMacroPlay(VOID);
|
||||
LRESULT OnToolMacroStop(VOID) {
|
||||
return 0;
|
||||
}
|
||||
//LRESULT OnToolMacroSettings(VOID);
|
||||
;
|
|
@ -31,8 +31,28 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
|||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/9630134/jni-how-to-callback-from-c-or-c-to-java
|
||||
enum CALLBACK_TYPE {
|
||||
CALLBACK_TYPE_INVALIDATE = 0,
|
||||
CALLBACK_TYPE_WINDOW_RESIZE = 1
|
||||
};
|
||||
|
||||
void mainViewUpdateCallback() {
|
||||
mainViewCallback(CALLBACK_TYPE_INVALIDATE, 0, 0);
|
||||
}
|
||||
|
||||
void mainViewResizeCallback(int x, int y) {
|
||||
mainViewCallback(CALLBACK_TYPE_WINDOW_RESIZE, x, y);
|
||||
|
||||
JNIEnv * jniEnv;
|
||||
int ret = (*java_machine)->GetEnv(java_machine, &jniEnv, JNI_VERSION_1_6);
|
||||
ret = AndroidBitmap_getInfo(jniEnv, bitmapMainScreen, &androidBitmapInfo);
|
||||
if (ret < 0) {
|
||||
LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
|
||||
}
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/9630134/jni-how-to-callback-from-c-or-c-to-java
|
||||
int mainViewCallback(int type, int param1, int param2) {
|
||||
if (viewToUpdate) {
|
||||
JNIEnv * jniEnv;
|
||||
jint ret;
|
||||
|
@ -47,10 +67,12 @@ void mainViewUpdateCallback() {
|
|||
}
|
||||
|
||||
jclass viewToUpdateClass = (*jniEnv)->GetObjectClass(jniEnv, viewToUpdate);
|
||||
jmethodID midStr = (*jniEnv)->GetMethodID(jniEnv, viewToUpdateClass, "updateCallback", "()V");
|
||||
(*jniEnv)->CallVoidMethod(jniEnv, viewToUpdate, midStr);
|
||||
//jmethodID midStr = (*jniEnv)->GetMethodID(jniEnv, viewToUpdateClass, "updateCallback", "()V");
|
||||
jmethodID midStr = (*jniEnv)->GetMethodID(jniEnv, viewToUpdateClass, "updateCallback", "(III)I");
|
||||
int result = (*jniEnv)->CallIntMethod(jniEnv, viewToUpdate, midStr, type, param1, param2);
|
||||
// if(needDetach)
|
||||
// ret = (*java_machine)->DetachCurrentThread(java_machine);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#define LOGD(...) ((void)__android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__))
|
||||
#define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__))
|
||||
extern void mainViewUpdateCallback();
|
||||
|
||||
extern void mainViewResizeCallback(int x, int y);
|
||||
#include "win32-layer.h"
|
||||
|
||||
|
||||
|
|
|
@ -661,7 +661,13 @@ BOOL DestroyWindow(HWND hWnd) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
BOOL GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl) { return 0; }
|
||||
BOOL GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl) {
|
||||
if(lpwndpl) {
|
||||
lpwndpl->rcNormalPosition.left = 0;
|
||||
lpwndpl->rcNormalPosition.top = 0;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
BOOL SetWindowPlacement(HWND hWnd, CONST WINDOWPLACEMENT *lpwndpl) { return 0; }
|
||||
BOOL InvalidateRect(HWND hWnd, CONST RECT *lpRect, BOOL bErase) { return 0; }
|
||||
BOOL AdjustWindowRect(LPRECT lpRect, DWORD dwStyle, BOOL bMenu) { return 0; }
|
||||
|
@ -1099,6 +1105,11 @@ VOID GetLocalTime(LPSYSTEMTIME lpSystemTime) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
WORD GetTickCount(VOID) {
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
BOOL EnableWindow(HWND hWnd, BOOL bEnable) {
|
||||
//TODO
|
||||
|
@ -1119,6 +1130,10 @@ BOOL SetDlgItemText(HWND hDlg, int nIDDlgItem, LPCSTR lpString) {
|
|||
//TODO
|
||||
return 0;
|
||||
}
|
||||
LRESULT SendDlgItemMessage(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam) {
|
||||
//TODO
|
||||
return 0;
|
||||
}
|
||||
BOOL CheckDlgButton(HWND hDlg, int nIDButton, UINT uCheck) {
|
||||
//TODO
|
||||
return 0;
|
||||
|
|
|
@ -332,6 +332,7 @@ enum {
|
|||
|
||||
#define TEXT(x) @x
|
||||
#define LOWORD(x) x
|
||||
#define MAKELONG(a, b) ((LONG)(((WORD)(((DWORD_PTR)(a)) & 0xffff)) | ((DWORD)((WORD)(((DWORD_PTR)(b)) & 0xffff))) << 16))
|
||||
|
||||
#define HIBYTE(i) ((i)>>8)
|
||||
#define LOBYTE(i) (i)
|
||||
|
@ -445,6 +446,11 @@ extern HANDLE LoadImage(HINSTANCE hInst, LPCSTR name, UINT type, int cx, int cy,
|
|||
#define BFFM_SETSELECTION BFFM_SETSELECTIONA
|
||||
#define CB_GETITEMDATA 0x0150
|
||||
#define CB_SETITEMDATA 0x0151
|
||||
#define TBM_GETPOS (WM_USER)
|
||||
#define TBM_SETPOS (WM_USER+5)
|
||||
#define TBM_SETRANGE (WM_USER+6)
|
||||
#define TBM_SETTICFREQ (WM_USER+20)
|
||||
#define BST_CHECKED 0x0001
|
||||
extern LRESULT SendMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
extern BOOL PostMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
extern int MessageBox(HANDLE, LPCTSTR szMessage, LPCTSTR szTitle, int flags);
|
||||
|
@ -780,13 +786,14 @@ extern MMRESULT timeGetDevCaps(LPTIMECAPS ptc, UINT cbtc);
|
|||
extern MMRESULT timeBeginPeriod(UINT uPeriod);
|
||||
extern MMRESULT timeEndPeriod(UINT uPeriod);
|
||||
extern VOID GetLocalTime(LPSYSTEMTIME lpSystemTime);
|
||||
|
||||
extern WORD GetTickCount(VOID);
|
||||
|
||||
extern BOOL EnableWindow(HWND hWnd, BOOL bEnable);
|
||||
extern HWND GetDlgItem(HWND hDlg, int nIDDlgItem);
|
||||
extern UINT GetDlgItemTextA(HWND hDlg, int nIDDlgItem, LPSTR lpString,int cchMax);
|
||||
#define GetDlgItemText GetDlgItemTextA
|
||||
extern BOOL SetDlgItemText(HWND hDlg, int nIDDlgItem, LPCSTR lpString);
|
||||
extern LRESULT SendDlgItemMessage(HWND hDlg, int nIDDlgItem, UINT Msg, WPARAM wParam, LPARAM lParam);
|
||||
extern BOOL CheckDlgButton(HWND hDlg, int nIDButton, UINT uCheck);
|
||||
extern UINT IsDlgButtonChecked(HWND hDlg, int nIDButton);
|
||||
extern BOOL EndDialog(HWND hDlg, INT_PTR nResult);
|
||||
|
|
|
@ -29,7 +29,9 @@ public class MainScreenView extends SurfaceView {
|
|||
protected static final String TAG = "MainScreenView";
|
||||
private Bitmap bitmapMainScreen;
|
||||
private HashMap<Integer, Integer> vkmap;
|
||||
private float screenScale = 3.0f;
|
||||
private float screenScale = 1.0f;
|
||||
private float screenOffsetX = 0.0f;
|
||||
private float screenOffsetY= 0.0f;
|
||||
|
||||
public MainScreenView(Context context) {
|
||||
super(context);
|
||||
|
@ -149,12 +151,12 @@ public class MainScreenView extends SurfaceView {
|
|||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
//Log.d(TAG, "ACTION_DOWN count: " + touchCount + ", PanPrevious: " + mPanPrevious.toString());
|
||||
NativeLib.buttonDown((int)(event.getX(0) / screenScale), (int)(event.getY(0) / screenScale));
|
||||
NativeLib.buttonDown((int)((event.getX(0) - screenOffsetX) / screenScale), (int)((event.getY(0) - screenOffsetY) / screenScale));
|
||||
break;
|
||||
// case MotionEvent.ACTION_MOVE:
|
||||
// break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
NativeLib.buttonUp((int)(event.getX(0) / screenScale), (int)(event.getY(0) / screenScale));
|
||||
NativeLib.buttonUp((int)((event.getX(0) - screenOffsetX) / screenScale), (int)((event.getY(0) - screenOffsetY) / screenScale));
|
||||
break;
|
||||
// case MotionEvent.ACTION_CANCEL:
|
||||
// break;
|
||||
|
@ -210,6 +212,29 @@ public class MainScreenView extends SurfaceView {
|
|||
protected void onSizeChanged(int viewWidth, int viewHeight, int oldViewWidth, int oldViewHeight) {
|
||||
super.onSizeChanged(viewWidth, viewHeight, oldViewWidth, oldViewHeight);
|
||||
|
||||
float imageSizeX = bitmapMainScreen.getWidth();
|
||||
float imageSizeY = bitmapMainScreen.getHeight();
|
||||
|
||||
if(imageSizeX > 0 && imageSizeY > 0 && viewWidth > 0.0f && viewHeight > 0.0f) {
|
||||
// Find the scale factor and the translate offset to fit and to center the vectors in the view bounds.
|
||||
float translateX, translateY, scale;
|
||||
float viewRatio = (float)viewHeight / (float)viewWidth;
|
||||
float imageRatio = imageSizeY / imageSizeX;
|
||||
if(viewRatio > imageRatio) {
|
||||
scale = viewWidth / imageSizeX;
|
||||
translateX = 0.0f;
|
||||
translateY = (viewHeight - scale * imageSizeY) / 2.0f;
|
||||
} else {
|
||||
scale = viewHeight / imageSizeY;
|
||||
translateX = (viewWidth - scale * imageSizeX) / 2.0f;
|
||||
translateY = 0.0f;
|
||||
}
|
||||
|
||||
screenScale = scale;
|
||||
screenOffsetX = translateX;
|
||||
screenOffsetY = translateY;
|
||||
}
|
||||
|
||||
NativeLib.resize(viewWidth, viewHeight);
|
||||
}
|
||||
|
||||
|
@ -218,13 +243,26 @@ public class MainScreenView extends SurfaceView {
|
|||
//Log.d(TAG, "onDraw() mIsScaling: " + mIsScaling + ", mIsPanning: " + mIsPanning + ", mIsFlinging: " + mIsFlinging);
|
||||
//NativeLib.draw();
|
||||
canvas.save();
|
||||
//canvas.translate(mViewPanOffsetX, mViewPanOffsetY);
|
||||
canvas.translate(screenOffsetX, screenOffsetY);
|
||||
canvas.scale(screenScale, screenScale);
|
||||
canvas.drawBitmap(bitmapMainScreen, 0, 0, null);
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
void updateCallback() {
|
||||
postInvalidate();
|
||||
final int CALLBACK_TYPE_INVALIDATE = 0;
|
||||
final int CALLBACK_TYPE_WINDOW_RESIZE = 1;
|
||||
|
||||
int updateCallback(int type, int param1, int param2) {
|
||||
switch (type) {
|
||||
case CALLBACK_TYPE_INVALIDATE:
|
||||
postInvalidate();
|
||||
break;
|
||||
case CALLBACK_TYPE_WINDOW_RESIZE:
|
||||
// New Bitmap size
|
||||
bitmapMainScreen.reconfigure(/* x */ param1, /* y */ param2, Bitmap.Config.ARGB_8888);
|
||||
bitmapMainScreen.eraseColor(Color.LTGRAY);
|
||||
break;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="bottom|end"
|
||||
android:layout_margin="@dimen/fab_margin"
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@android:drawable/ic_dialog_email" />
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
Loading…
Reference in a new issue