This commit is contained in:
dgis 2018-11-22 23:04:50 +00:00
parent c7ab221065
commit f27ee86714
5 changed files with 72 additions and 50 deletions

View file

@ -801,7 +801,7 @@ static LRESULT OnCreate(HWND hWindow)
// InitializeCriticalSection(&csRecvLock); // InitializeCriticalSection(&csRecvLock);
// InitializeCriticalSection(&csSlowLock); // InitializeCriticalSection(&csSlowLock);
// InitializeCriticalSection(&csDbgLock); // InitializeCriticalSection(&csDbgLock);
//
// // load cursors // // load cursors
// hCursorArrow = LoadCursor(NULL,IDC_ARROW); // hCursorArrow = LoadCursor(NULL,IDC_ARROW);
// hCursorHand = LoadCursor(NULL,IDC_HAND); // hCursorHand = LoadCursor(NULL,IDC_HAND);
@ -2016,7 +2016,7 @@ LRESULT CALLBACK MainWndProc(HWND hWindow, UINT uMsg, WPARAM wParam, LPARAM lPar
return NULL; return NULL;
} }
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow) BOOL emu48Start()
{ {
// typedef DWORD (WINAPI *LPFN_STIP)(HANDLE hThread,DWORD dwIdealProcessor); // typedef DWORD (WINAPI *LPFN_STIP)(HANDLE hThread,DWORD dwIdealProcessor);
// //
@ -2064,12 +2064,12 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
// _T("This application will now terminate.")); // _T("This application will now terminate."));
// return FALSE; // return FALSE;
// } // }
//
// // read emulator settings // read emulator settings
// GetCurrentDirectory(ARRAYSIZEOF(szCurrentDirectory),szCurrentDirectory); GetCurrentDirectory(ARRAYSIZEOF(szCurrentDirectory),szCurrentDirectory);
// ReadSettings(); ReadSettings();
//
// // running an instance of me? // running an instance of me?
// if (bSingleInstance && (hWnd = FindWindow(MAKEINTATOM(classAtom),NULL)) != NULL) // if (bSingleInstance && (hWnd = FindWindow(MAKEINTATOM(classAtom),NULL)) != NULL)
// { // {
// COPYDATASTRUCT sCDS; // COPYDATASTRUCT sCDS;
@ -2144,49 +2144,49 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
// } // }
// //
// VERIFY(hAccel = LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_MENU))); // VERIFY(hAccel = LoadAccelerators(hInst, MAKEINTRESOURCE(IDR_MENU)));
//
// // initialization // initialization
// QueryPerformanceFrequency(&lFreq); // init high resolution counter QueryPerformanceFrequency(&lFreq); // init high resolution counter
// QueryPerformanceCounter(&lAppStart); QueryPerformanceCounter(&lAppStart);
//
// szCurrentKml[0] = 0; // no KML file selected szCurrentKml[0] = 0; // no KML file selected
// SetSpeed(bRealSpeed); // set speed SetSpeed(bRealSpeed); // set speed
// MruInit(4); // init MRU entries // MruInit(4); // init MRU entries
//
// // create auto event handle // create auto event handle
// hEventShutdn = CreateEvent(NULL,FALSE,FALSE,NULL); hEventShutdn = CreateEvent(NULL,FALSE,FALSE,NULL);
// if (hEventShutdn == NULL) if (hEventShutdn == NULL)
// { {
// AbortMessage(_T("Event creation failed.")); AbortMessage(_T("Event creation failed."));
// DestroyWindow(hWnd); // DestroyWindow(hWnd);
// return FALSE; return FALSE;
// } }
//
// nState = SM_RUN; // init state must be <> nNextState nState = SM_RUN; // init state must be <> nNextState
// nNextState = SM_INVALID; // go into invalid state nNextState = SM_INVALID; // go into invalid state
// hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&WorkerThread, NULL, CREATE_SUSPENDED, &dwThreadId); hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&WorkerThread, NULL, CREATE_SUSPENDED, &dwThreadId);
// if (hThread == NULL) if (hThread == NULL)
// { {
// CloseHandle(hEventShutdn); // close event handle CloseHandle(hEventShutdn); // close event handle
// AbortMessage(_T("Thread creation failed.")); AbortMessage(_T("Thread creation failed."));
// DestroyWindow(hWnd); // DestroyWindow(hWnd);
// return FALSE; return FALSE;
// } }
//
// // SetThreadIdealProcessor() is available since Windows NT4.0 // SetThreadIdealProcessor() is available since Windows NT4.0
// fnSetThreadIdealProcessor = (LPFN_STIP) GetProcAddress(GetModuleHandle(_T("kernel32")), // fnSetThreadIdealProcessor = (LPFN_STIP) GetProcAddress(GetModuleHandle(_T("kernel32")),
// "SetThreadIdealProcessor"); // "SetThreadIdealProcessor");
//
// // bind Saturn CPU emulation thread to current ideal processor // // bind Saturn CPU emulation thread to current ideal processor
// dwProcessor = (fnSetThreadIdealProcessor != NULL) // running on NT4.0 or later // dwProcessor = (fnSetThreadIdealProcessor != NULL) // running on NT4.0 or later
// ? fnSetThreadIdealProcessor(hThread,MAXIMUM_PROCESSORS) // get ideal processor no. // ? fnSetThreadIdealProcessor(hThread,MAXIMUM_PROCESSORS) // get ideal processor no.
// : 0; // select 1st processor // : 0; // select 1st processor
//
// // on multiprocessor machines for QueryPerformanceCounter() // on multiprocessor machines for QueryPerformanceCounter()
// VERIFY(SetThreadAffinityMask(hThread,(DWORD_PTR) (1 << dwProcessor))); // VERIFY(SetThreadAffinityMask(hThread,(DWORD_PTR) (1 << dwProcessor)));
// ResumeThread(hThread); // start thread ResumeThread(hThread); // start thread
// while (nState!=nNextState) Sleep(0); // wait for thread initialized while (nState!=nNextState) Sleep(0); // wait for thread initialized
//
// idDdeInst = 0; // initialize DDE server // idDdeInst = 0; // initialize DDE server
// if (DdeInitialize(&idDdeInst,(PFNCALLBACK) &DdeCallback, // if (DdeInitialize(&idDdeInst,(PFNCALLBACK) &DdeCallback,
// APPCLASS_STANDARD | // APPCLASS_STANDARD |
@ -2199,7 +2199,7 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
// DestroyWindow(hWnd); // DestroyWindow(hWnd);
// return FALSE; // return FALSE;
// } // }
//
// // init clipboard format and name service // // init clipboard format and name service
// uCF_HpObj = RegisterClipboardFormat(_T(CF_HPOBJ)); // uCF_HpObj = RegisterClipboardFormat(_T(CF_HPOBJ));
// hszService = DdeCreateStringHandle(idDdeInst,szAppName,0); // hszService = DdeCreateStringHandle(idDdeInst,szAppName,0);
@ -2235,14 +2235,14 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC
// //
// SetWindowTitle(_T("New Document")); // SetWindowTitle(_T("New Document"));
// ShowWindow(hWnd,nCmdShow); // show emulator menu // ShowWindow(hWnd,nCmdShow); // show emulator menu
//
// // no default document, ask for new one // no default document, ask for new one
// if (NewDocument()) SetWindowTitle(_T("Untitled")); if (NewDocument()) SetWindowTitle(_T("Untitled"));
//
//start: //start:
// if (bStartupBackup) SaveBackup(); // make a RAM backup at startup if (bStartupBackup) SaveBackup(); // make a RAM backup at startup
// if (pbyRom) SwitchToState(SM_RUN); if (pbyRom) SwitchToState(SM_RUN);
//
// while (GetMessage(&msg, NULL, 0, 0)) // while (GetMessage(&msg, NULL, 0, 0))
// { // {
// if ( !TranslateAccelerator(hWnd, hAccel, &msg) // if ( !TranslateAccelerator(hWnd, hAccel, &msg)

View file

@ -12,3 +12,9 @@ Java_com_regis_cosnier_emu48_MainActivity_stringFromJNI(
// return env->NewStringUTF(hello.c_str()); // return env->NewStringUTF(hello.c_str());
return (*env)->NewStringUTF(env, "Hello from JNI !"); return (*env)->NewStringUTF(env, "Hello from JNI !");
} }
extern void emu48Start();
JNIEXPORT void JNICALL Java_com_regis_cosnier_emu48_MainActivity_emu48Start(JNIEnv *env, jobject thisz) {
emu48Start();
}

View file

@ -10,6 +10,13 @@ LPTSTR szTitle;
static HANDLE gEventId; static HANDLE gEventId;
DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer) {
if(getcwd(lpBuffer, nBufferLength)) {
return nBufferLength;
}
return 0;
}
BOOL SetCurrentDirectory(LPCTSTR path) BOOL SetCurrentDirectory(LPCTSTR path)
{ {
if(path == NULL) if(path == NULL)
@ -481,7 +488,10 @@ HANDLE WINAPI CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwSt
//TODO //TODO
return NULL; return NULL;
} }
DWORD ResumeThread(HANDLE hThread) {
//TODO
return 0;
}
BOOL WINAPI CloseHandle(HANDLE hObject) { BOOL WINAPI CloseHandle(HANDLE hObject) {
//TODO //TODO
// Can be a thread/event/file hande! // Can be a thread/event/file hande!

View file

@ -350,6 +350,7 @@ typedef struct _OVERLAPPED {
} OVERLAPPED, *LPOVERLAPPED; } OVERLAPPED, *LPOVERLAPPED;
extern DWORD GetCurrentDirectory(DWORD nBufferLength, LPTSTR lpBuffer);
extern BOOL SetCurrentDirectory(LPCTSTR); // returns NO if fails extern BOOL SetCurrentDirectory(LPCTSTR); // returns NO if fails
extern int CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPVOID lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, LPVOID hTemplateFile); extern int CreateFile(LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPVOID lpSecurityAttributes, DWORD dwCreationDisposition, DWORD dwFlagsAndAttributes, LPVOID hTemplateFile);
extern BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped); extern BOOL ReadFile(HANDLE hFile, LPVOID lpBuffer, DWORD nNumberOfBytesToRead, LPDWORD lpNumberOfBytesRead, LPOVERLAPPED lpOverlapped);
@ -470,6 +471,7 @@ typedef DWORD (*PTHREAD_START_ROUTINE)(
); );
typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE; typedef PTHREAD_START_ROUTINE LPTHREAD_START_ROUTINE;
extern HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId); extern HANDLE CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, SIZE_T dwStackSize, LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpParameter, DWORD dwCreationFlags, LPDWORD lpThreadId);
extern DWORD ResumeThread(HANDLE hThread);
extern BOOL CloseHandle(HANDLE hObject); extern BOOL CloseHandle(HANDLE hObject);
#define OBJ_BITMAP 7 #define OBJ_BITMAP 7
extern int GetObject(HANDLE h, int c, LPVOID pv); extern int GetObject(HANDLE h, int c, LPVOID pv);

View file

@ -36,6 +36,8 @@ public class MainActivity extends AppCompatActivity {
// Example of a call to a native method // Example of a call to a native method
TextView tv = (TextView) findViewById(R.id.sample_text); TextView tv = (TextView) findViewById(R.id.sample_text);
tv.setText(stringFromJNI()); tv.setText(stringFromJNI());
emu48Start();
} }
@Override @Override
@ -65,4 +67,6 @@ public class MainActivity extends AppCompatActivity {
* which is packaged with this application. * which is packaged with this application.
*/ */
public native String stringFromJNI(); public native String stringFromJNI();
public native void emu48Start();
} }