diff --git a/EMU48.EXE b/EMU48.EXE deleted file mode 100755 index 8e19b45..0000000 Binary files a/EMU48.EXE and /dev/null differ diff --git a/Emu48.exe b/Emu48.exe new file mode 100755 index 0000000..50306b4 Binary files /dev/null and b/Emu48.exe differ diff --git a/PROBLEMS.TXT b/PROBLEMS.TXT index 1714efd..ade1a51 100644 --- a/PROBLEMS.TXT +++ b/PROBLEMS.TXT @@ -1,4 +1,4 @@ -Known bugs and restrictions of Emu48 V1.55 +Known bugs and restrictions of Emu48 V1.56 ------------------------------------------ - the following I/O bits aren't emulated (incomplete) @@ -47,4 +47,4 @@ Known bugs and restrictions of Emu48 V1.55 - quitting the emulator while programming the flash isn't allowed, because the content of flash state machine isn't saved so far -05/21/13 (c) by Christoph Gießelink, c dot giesselink at gmx dot de +04/29/14 (c) by Christoph Gießelink, c dot giesselink at gmx dot de diff --git a/Sources/Emu48/CHANGES.TXT b/Sources/Emu48/CHANGES.TXT index 6d481d1..c0481c2 100644 --- a/Sources/Emu48/CHANGES.TXT +++ b/Sources/Emu48/CHANGES.TXT @@ -1,3 +1,114 @@ +Service Pack 56 for Emu48 Version 1.0 + +DEBUGGER.C +- removed INSTRSIZE definition +- changed function GetAddr(), made function more general by adding + address range check and the ability of decoding a symbolic entry + into an address +- bugfix in function OnSetCursor(), on "Activation follows mouse" + enabled child dialogs lost focus when cursor moved over parent + debugger dialog +- changed function Debugger(), removed initialization of global + variable wInstrSize +- changed function EnterAddr(), changed parameter storage from + static variable to window user data and replaced address decoder + code by GetAddr() function call +- changed function EnterBreakpoint(), replaced address decoder code + by GetAddr() function call and so added decoding a symbolic entry + into an address +- bugfix in function LoadMemData(), forgot to check if file content + fit into Saturn address range, loading now stops also after last + Saturn address written +- changed function SaveMemData(), added assertion for Saturn address + verification +- bugfix in function DebugMemLoad() and DebugMemSave(), adjusted to + new prototype of function GetAddr() and so added checking if the + given addresses are in the Saturn address range because Saturn + read/write functions don't do the range check; this also cause a + change in behavior, on empty address fields the operation fails + and the dialog still remains open + +EMU48.C +- changed function SetSoundDeviceList(), replaced "Standard Audio" + device ID from constant to definition +- bugfix in function SettingsGeneralProc(), on "Activation follows + mouse" enabled debugger dialog maybe got focus even if it's not + the last active one +- bugfix in function SettingsPeripheralProc(), restart the sound + engine by calling the clean up and initialization functions now +- changed function OnFileNew(), removed call of function + SaveBackup() which is already a part of function NewDocument() +- changed function OnFileNew(), OnFileOpen(), OnFileMruOpen(), + OnFileSave(), OnFileSaveAs() and OnFileClose(), switched detection + of document is available from variable pbyRom (ROM image loaded) + to variable bDocumentAvail +- changed function OnViewCopy(), removed MONOCHROME source code part +- changed function WinMain(), added sound engine initialization and + clean up + +EMU48.RC +- changed version and copyright + +ENGINE.C +- initialized variable wInstrSize with size of last instruction + array (the circular buffer can hold (wInstrSize-1) instructions) +- bugfix in function WorkerThread(), moved sound engine + initialization and clean up from SM_RUN state to main function, + this prevents a non responding Saturn CPU emulation when changing + from SM_SLEEP to SM_RUN state during sound engine initialization + +FETCH.C +- made typedef of jump table struct constant, so the const keyword + was removed from all references of JMPTAB +- changed function EvalOpcode(), minor code optimization + +FILES.C +- bugfix in function PatchRom(), removed limitation that patch file + must have 6 characters minimum, fixed a buffer overflow when end + of patch file consists of white space characters, recalculate + CRC's only on address patch written and return failture on syntax + errors now + +PCH.H +- added GWLP_USERDATA, SetWindowLongPtr, GetWindowLongPtr and + LONG_PTR definitions for MSVC6.0 SDK and earlier + +SETTINGS.C +- changed function ReadSettings() and WriteSettings(), added item + "LastInstrBufSize" in section [Debugger] in the INI-File + +SOUND.C +- bugfix in function DestroyWaveThread(), the WM_QUIT message may + failed and so the sound message thread wasn't shut down +- changed function SoundOpen(), added additional check if the sound + device support the necessary audio format + +STACK.C +- added function Trim(), create a trimmed copy of the input string +- added function SetZInt(), contain implementation of prior function + RPL_SetZInt() +- changed function RPL_SetZInt(), wrapper for function SetZInt() to + trim data before decoding +- added function SetBcd(), contain implementation of prior function + RPL_SetBcd() +- changed function RPL_SetBcd(), wrapper for function SetBcd() to + trim data before decoding +- changed function RPL_SetComplex(), create a trimmed working copy + before decoding the outline brackets and because of the changed + function RPL_SetBcd() the real number arguments are accepted with + white spaces around now +- removed disabled function IsRealNumber(), it was more or less + functional compatible with actual modified function RPL_SetBcd() + +TIMER.C +- removed UNIX_0_TIME definition + +UDP.C +- changed function SendByteUdp(), replaced malloc() by _alloca() + call for UNICODE wchar to char string translation to get rid of + freeing the allocated memory manually + + Service Pack 55 for Emu48 Version 1.0 DISMEM.C diff --git a/Sources/Emu48/DEBUGGER.C b/Sources/Emu48/DEBUGGER.C index b1157f3..d0459a8 100644 --- a/Sources/Emu48/DEBUGGER.C +++ b/Sources/Emu48/DEBUGGER.C @@ -20,18 +20,16 @@ #define MAXMEMITEMS 16 // number of address items in a memory window line #define MAXBREAKPOINTS 256 // max. number of breakpoints -#define REG_START IDC_REG_A // first register in register update table -#define REG_STOP IDC_MISC_BS // last register in register update table +#define REG_START IDC_REG_A // first register in register update table +#define REG_STOP IDC_MISC_BS // last register in register update table #define REG_SIZE (REG_STOP-REG_START+1) // size of register update table // assert for register update #define _ASSERTREG(r) _ASSERT(r >= REG_START && r <= REG_STOP) -#define INSTRSIZE 256 // size of last instruction buffer - #define WM_UPDATE (WM_USER+0x1000) // update debugger dialog box -#define MEMWNDMAX (sizeof(nCol) / sizeof(nCol[0])) +#define MEMWNDMAX (sizeof(nCol) / sizeof(nCol[0])) #define RT_TOOLBAR MAKEINTRESOURCE(241) // MFC toolbar resource type @@ -158,6 +156,50 @@ static VOID DisableMenuKeys(HWND hDlg) return; } +// +// read edit control and decode content as hex number or if enabled as symbol name +// +static BOOL GetAddr(HWND hDlg,INT nID,DWORD *pdwAddr,DWORD dwMaxAddr,BOOL bSymbEnable) +{ + TCHAR szBuffer[48]; + INT i; + BOOL bSucc = TRUE; + + HWND hWnd = GetDlgItem(hDlg,nID); + + GetWindowText(hWnd,szBuffer,ARRAYSIZEOF(szBuffer)); + + if (*szBuffer != 0) + { + // if address is not a symbol name decode number + if ( !bSymbEnable || szBuffer[0] != _T('=') + || RplGetAddr(&szBuffer[1],pdwAddr)) + { + // test if valid hex address + for (i = 0; bSucc && i < (LONG) lstrlen(szBuffer); ++i) + { + bSucc = (_istxdigit(szBuffer[i]) != 0); + } + + if (bSucc) // valid characters + { + // convert string to number + *pdwAddr = _tcstoul(szBuffer,NULL,16); + } + } + + // inside address range? + bSucc = bSucc && (*pdwAddr <= dwMaxAddr); + + if (!bSucc) // invalid address + { + SendMessage(hWnd,EM_SETSEL,0,-1); + SetFocus(hWnd); // focus to edit control + } + } + return bSucc; +} + // // set mapping menu // @@ -1426,7 +1468,8 @@ static BOOL OnSetCursor(HWND hDlg) // debugger not active but cursor is over debugger window if (bActFollowsMouse && GetActiveWindow() != hDlg) { - ForceForegroundWindow(hDlg); // force debugger window to foreground + // force debugger window to foreground + ForceForegroundWindow(GetLastActivePopup(hDlg)); } return FALSE; } @@ -1866,8 +1909,7 @@ static INT_PTR CALLBACK Debugger(HWND hDlg, UINT message, WPARAM wParam, LPARAM SendDlgItemMessage(hDlg,IDC_STATIC_MISC, WM_SETFONT,(WPARAM)GetStockObject(DEFAULT_GUI_FONT),MAKELPARAM(FALSE,0)); // init last instruction circular buffer - pdwInstrArray = (DWORD *) malloc(INSTRSIZE*sizeof(*pdwInstrArray)); - wInstrSize = INSTRSIZE; // size of last instruction array + pdwInstrArray = (DWORD *) malloc(wInstrSize*sizeof(*pdwInstrArray)); wInstrWp = wInstrRp = 0; // write/read pointer // init "Follow" menu entry in debugger "Memory" context menu @@ -2003,10 +2045,10 @@ static INT_PTR CALLBACK Debugger(HWND hDlg, UINT message, WPARAM wParam, LPARAM { case VK_F2: return OnKeyF2(hDlg); // toggle breakpoint case VK_F5: return OnKeyF5(hDlg); // key run - case VK_F6: return OnKeyF6(hDlg); // key step cursor + case VK_F6: return OnKeyF6(hDlg); // key step cursor case VK_F7: return OnKeyF7(hDlg); // key step into case VK_F8: return OnKeyF8(hDlg); // key step over - case VK_F9: return OnKeyF9(hDlg); // key step out + case VK_F9: return OnKeyF9(hDlg); // key step out case VK_F11: return OnKeyF11(hDlg); // key break } @@ -2749,41 +2791,22 @@ static INT_PTR OnNewValue(LPTSTR lpszValue) // static INT_PTR CALLBACK EnterAddr(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { - static DWORD *pdwAddress; - - HWND hWnd; - TCHAR szBuffer[64]; - LONG i; - switch (message) { case WM_INITDIALOG: - pdwAddress = (DWORD *) lParam; + SetWindowLongPtr(hDlg,GWLP_USERDATA,(LONG_PTR) lParam); return TRUE; case WM_COMMAND: wParam = LOWORD(wParam); switch(wParam) { case IDOK: - hWnd = GetDlgItem(hDlg,IDC_ENTERADR); - GetWindowText(hWnd,szBuffer,ARRAYSIZEOF(szBuffer)); - - // if address is not a symbol name decode number - if ( !disassembler_symb || szBuffer[0] != _T('=') - || RplGetAddr(&szBuffer[1],pdwAddress)) - { - // test if valid hex address - for (i = 0; i < (LONG) lstrlen(szBuffer); ++i) - { - if (_istxdigit(szBuffer[i]) == 0) - { - SendMessage(hWnd,EM_SETSEL,0,-1); - SetFocus(hWnd); // focus to edit control - return FALSE; - } - } - if (*szBuffer) _stscanf(szBuffer,_T("%8X"),pdwAddress); - } + if (!GetAddr(hDlg, + IDC_ENTERADR, + (DWORD *) GetWindowLongPtr(hDlg,GWLP_USERDATA), + 0xFFFFFFFF, + disassembler_symb)) + return FALSE; // no break case IDCANCEL: EndDialog(hDlg,wParam); @@ -2813,10 +2836,8 @@ static VOID OnEnterAddress(HWND hDlg, DWORD *dwValue) static INT_PTR CALLBACK EnterBreakpoint(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) { static BP_T *sBp; - - HWND hWnd; - TCHAR szBuffer[8]; - LONG i; + + DWORD dwAddr; switch (message) { @@ -2836,19 +2857,9 @@ static INT_PTR CALLBACK EnterBreakpoint(HWND hDlg, UINT message, WPARAM wParam, case IDC_BPREAD: sBp->nType = BP_READ; return TRUE; case IDC_BPWRITE: sBp->nType = BP_WRITE; return TRUE; case IDOK: - hWnd = GetDlgItem(hDlg,IDC_ENTERADR); - GetWindowText(hWnd,szBuffer,ARRAYSIZEOF(szBuffer)); - // test if valid hex address - for (i = 0; i < (LONG) lstrlen(szBuffer); ++i) - { - if (_istxdigit(szBuffer[i]) == 0) - { - SendMessage(hWnd,EM_SETSEL,0,-1); - SetFocus(hWnd); - return FALSE; - } - } - if (*szBuffer) _stscanf(szBuffer,_T("%5X"),&sBp->dwAddr); + if (!GetAddr(hDlg,IDC_ENTERADR,&dwAddr,0xFFFFF,disassembler_symb)) + return FALSE; + sBp->dwAddr = dwAddr; // no break case IDCANCEL: EndDialog(hDlg,wParam); @@ -2986,11 +2997,11 @@ static INT_PTR CALLBACK EditBreakpoint(HWND hDlg, UINT message, WPARAM wParam, L { TEXTMETRIC tm; - HWND hWnd; - HDC hDC; - HFONT hFont; - BP_T sBp; - INT i,nItem; + HWND hWnd; + HDC hDC; + HFONT hFont; + BP_T sBp; + INT i,nItem; switch (message) { @@ -3448,13 +3459,22 @@ static BOOL LoadMemData(LPCTSTR lpszFilename,DWORD dwStartAddr) if (hFile == INVALID_HANDLE_VALUE) // error, couldn't create a new file return FALSE; - while (TRUE) // read until EOF + while (dwStartAddr <= 0xFFFFF) // read until EOF or end of Saturn address space { ReadFile(hFile,&byData,sizeof(byData),&dwRead,NULL); if (dwRead == 0) break; // EOF - Write2(dwStartAddr,byData); // write byte in map mode - dwStartAddr += 2; + if (dwStartAddr < 0xFFFFF) + { + Write2(dwStartAddr,byData); // write byte in map mode + dwStartAddr += 2; + } + else // special handling to avoid address wrap around + { + byData &= 0xF; + Nwrite(&byData,dwStartAddr,1); // write nibble in map mode + ++dwStartAddr; + } } CloseHandle(hFile); @@ -3476,6 +3496,7 @@ static BOOL SaveMemData(LPCTSTR lpszFilename,DWORD dwStartAddr,DWORD dwEndAddr) for (dwAddr = dwStartAddr; dwAddr <= dwEndAddr; dwAddr += 2) { + _ASSERT(dwAddr <= 0xFFFFF); byData = Read2(dwAddr); // read byte in map mode WriteFile(hFile,&byData,sizeof(byData),&dwWritten,NULL); } @@ -3484,32 +3505,6 @@ static BOOL SaveMemData(LPCTSTR lpszFilename,DWORD dwStartAddr,DWORD dwEndAddr) return TRUE; } -// -// read edit control and decode content as hex number -// -static BOOL GetAddr(HWND hDlg, INT nID, DWORD *pdwAddr) -{ - TCHAR szBuffer[8]; - INT i; - - HWND hWnd = GetDlgItem(hDlg,nID); - - GetWindowText(hWnd,szBuffer,ARRAYSIZEOF(szBuffer)); - - // test if valid hex address - for (i = 0; i < (LONG) lstrlen(szBuffer); ++i) - { - if (_istxdigit(szBuffer[i]) == 0) - { - SendMessage(hWnd,EM_SETSEL,0,-1); - SetFocus(hWnd); // focus to edit control - return FALSE; - } - } - _stscanf(szBuffer,_T("%6X"),pdwAddr); - return TRUE; -} - // // memory load data // @@ -3527,13 +3522,18 @@ static INT_PTR CALLBACK DebugMemLoad(HWND hDlg, UINT message, WPARAM wParam, LPA return OnBrowseLoadMem(hDlg); case IDOK: + dwStartAddr = -1; // no address given + // get filename GetDlgItemText(hDlg,IDC_DEBUG_DATA_FILE,szFilename,ARRAYSIZEOF(szFilename)); // decode address field - if (!GetAddr(hDlg,IDC_DEBUG_DATA_STARTADDR,&dwStartAddr)) + if ( !GetAddr(hDlg,IDC_DEBUG_DATA_STARTADDR,&dwStartAddr,0xFFFFF,FALSE) + || dwStartAddr == -1) return FALSE; + _ASSERT(dwStartAddr <= 0xFFFFF); + // load memory dump file if (!LoadMemData(szFilename,dwStartAddr)) return FALSE; @@ -3577,15 +3577,22 @@ static INT_PTR CALLBACK DebugMemSave(HWND hDlg, UINT message, WPARAM wParam, LPA return OnBrowseSaveMem(hDlg); case IDOK: + dwStartAddr = dwEndAddr = -1; // no address given + // get filename GetDlgItemText(hDlg,IDC_DEBUG_DATA_FILE,szFilename,ARRAYSIZEOF(szFilename)); // decode address fields - if (!GetAddr(hDlg,IDC_DEBUG_DATA_STARTADDR,&dwStartAddr)) + if ( !GetAddr(hDlg,IDC_DEBUG_DATA_STARTADDR,&dwStartAddr,0xFFFFF,FALSE) + || dwStartAddr == -1) return FALSE; - if (!GetAddr(hDlg,IDC_DEBUG_DATA_ENDADDR,&dwEndAddr)) + if ( !GetAddr(hDlg,IDC_DEBUG_DATA_ENDADDR,&dwEndAddr,0xFFFFF,FALSE) + || dwEndAddr == -1) return FALSE; + _ASSERT(dwStartAddr <= 0xFFFFF); + _ASSERT(dwEndAddr <= 0xFFFFF); + // save memory dump file if (!SaveMemData(szFilename,dwStartAddr,dwEndAddr)) return FALSE; diff --git a/Sources/Emu48/DISMEM.C b/Sources/Emu48/DISMEM.C index 7d11efb..2d6dd0c 100644 --- a/Sources/Emu48/DISMEM.C +++ b/Sources/Emu48/DISMEM.C @@ -39,7 +39,7 @@ static CONST MODEL_MAP_T MemMap[] = { '6', // HP38G (64K) &pbyRom, &dwRomSize, // ROM - &Port0, &Chipset.Port0Size, // RAM + &Port0, &Chipset.Port0Size, // RAM &pbyNoMEM, NULL, // nc. &pbyNoMEM, NULL, // nc. &pbyNoMEM, NULL // nc. @@ -47,7 +47,7 @@ static CONST MODEL_MAP_T MemMap[] = { 'A', // HP38G &pbyRom, &dwRomSize, // ROM - &Port0, &Chipset.Port0Size, // RAM + &Port0, &Chipset.Port0Size, // RAM &pbyNoMEM, NULL, // nc. &pbyNoMEM, NULL, // nc. &pbyNoMEM, NULL // nc. @@ -58,21 +58,21 @@ static CONST MODEL_MAP_T MemMap[] = &Port0, &Chipset.Port0Size, // RAM part 1 &pbyNoMEM, NULL, // BS &pbyNoMEM, NULL, // nc. - &Port2, &Chipset.Port2Size // RAM part 2 + &Port2, &Chipset.Port2Size // RAM part 2 }, { 'G', // HP48GX &pbyRom, &dwRomSize, // ROM &Port0, &Chipset.Port0Size, // RAM &pbyNoMEM, NULL, // BS - &Port1, &Chipset.Port1Size, // Card slot 1 + &Port1, &Chipset.Port1Size, // Card slot 1 &pbyPort2, &dwPort2Size // Card slot 2 }, { 'S', // HP48SX &pbyRom, &dwRomSize, // ROM &Port0, &Chipset.Port0Size, // RAM - &Port1, &Chipset.Port1Size, // Card slot 1 + &Port1, &Chipset.Port1Size, // Card slot 1 &pbyPort2, &dwPort2Size, // Card slot 2 &pbyNoMEM, NULL // nc. }, diff --git a/Sources/Emu48/EMU48.C b/Sources/Emu48/EMU48.C index 5bab536..8d5618c 100644 --- a/Sources/Emu48/EMU48.C +++ b/Sources/Emu48/EMU48.C @@ -13,9 +13,7 @@ #include "kml.h" #include "debugger.h" -#define VERSION "1.55" - -// #define MONOCHROME // CF_BITMAP clipboard format +#define VERSION "1.56" #ifdef _DEBUG LPCTSTR szNoTitle = _T("Emu48 ")_T(VERSION)_T(" Debug"); @@ -222,7 +220,7 @@ static VOID SetSoundDeviceList(HWND hWnd,UINT uDeviceID) // preset selector uSelectDevice = (UINT) SendMessage(hWnd,CB_ADDSTRING,0,(LPARAM) _T("Standard Audio")); - SendMessage(hWnd,CB_SETITEMDATA,uSelectDevice,(UINT) -1); + SendMessage(hWnd,CB_SETITEMDATA,uSelectDevice,WAVE_MAPPER); uDevNo = waveOutGetNumDevs(); for (uDevID = 0; uDevID < uDevNo; ++uDevID) @@ -374,7 +372,7 @@ static BOOL CALLBACK SettingsGeneralProc(HWND hDlg, UINT uMsg, DWORD wParam, LON SetWindowPos(hWnd,hWndInsertAfter,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); if (hDlgDebug != NULL) { - SetWindowPos(hDlgDebug,hWndInsertAfter,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); + SetWindowPos(GetLastActivePopup(hDlgDebug),hWndInsertAfter,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE); } return TRUE; } @@ -482,9 +480,9 @@ static BOOL CALLBACK SettingsMemoryProc(HWND hDlg, UINT uMsg, DWORD wParam, LONG && (Chipset.IORam[CARDCTL] & ECDT) != 0 && (Chipset.IORam[TIMER2_CTRL] & RUN) != 0 ) { - Chipset.HST |= MP; // set Module Pulled - IOBit(SRQ2,NINT,FALSE); // set NINT to low - Chipset.SoftInt = TRUE; // set interrupt + Chipset.HST |= MP; // set Module Pulled + IOBit(SRQ2,NINT,FALSE); // set NINT to low + Chipset.SoftInt = TRUE; // set interrupt bInterrupt = TRUE; } SwitchToState(nOldState); @@ -620,10 +618,17 @@ static BOOL CALLBACK SettingsPeripheralProc(HWND hDlg, UINT uMsg, DWORD wParam, uDevId = (UINT) SendDlgItemMessage(hDlg,IDC_SOUND_DEVICE,CB_GETITEMDATA,i,0); if (uWaveDevId != uDevId) // sound device id changed { + UINT nActState; + uWaveDevId = uDevId; // set new sound device id + nActState = SwitchToState(SM_SLEEP); + // restart sound engine with new device id - SwitchToState(SwitchToState(SM_SLEEP)); + SoundClose(); // close waveform-audio output device + SoundOpen(uWaveDevId); // open waveform-audio output device + + SwitchToState(nActState); } // UDP infrared printer settings GetDlgItemText(hDlg,IDC_IR_ADDR,szUdpServer,ARRAYSIZEOF(szUdpServer)); @@ -913,13 +918,11 @@ cancel: // static LRESULT OnFileNew(VOID) { - if (pbyRom) + if (bDocumentAvail) { SwitchToState(SM_INVALID); if (IDCANCEL == SaveChanges(bAutoSave)) goto cancel; - - SaveBackup(); } if (NewDocument()) SetWindowTitle(_T("Untitled")); cancel: @@ -932,7 +935,7 @@ cancel: // static LRESULT OnFileOpen(VOID) { - if (pbyRom) + if (bDocumentAvail) { SwitchToState(SM_INVALID); if (IDCANCEL == SaveChanges(bAutoSave)) @@ -941,7 +944,7 @@ static LRESULT OnFileOpen(VOID) if (GetOpenFilename()) { if (OpenDocument(szBufferFilename)) - MruAdd(szCurrentFilename); + MruAdd(szBufferFilename); } cancel: if (pbyRom) SwitchToState(SM_RUN); @@ -959,7 +962,7 @@ static LRESULT OnFileMruOpen(UINT wID) lpszFilename = MruFilename(wID); // full filename from MRU list if (lpszFilename == NULL) return 0; // MRU slot not filled - if (pbyRom) + if (bDocumentAvail) { SwitchToState(SM_INVALID); if (IDCANCEL == SaveChanges(bAutoSave)) @@ -983,10 +986,12 @@ cancel: // static LRESULT OnFileSave(VOID) { - if (pbyRom == NULL) return 0; - SwitchToState(SM_INVALID); - SaveChanges(TRUE); - SwitchToState(SM_RUN); + if (bDocumentAvail) + { + SwitchToState(SM_INVALID); + SaveChanges(TRUE); + SwitchToState(SM_RUN); + } return 0; } @@ -995,16 +1000,16 @@ static LRESULT OnFileSave(VOID) // static LRESULT OnFileSaveAs(VOID) { - if (pbyRom == NULL) return 0; - SwitchToState(SM_INVALID); - - if (GetSaveAsFilename()) + if (bDocumentAvail) { - if (SaveDocumentAs(szBufferFilename)) - MruAdd(szCurrentFilename); + SwitchToState(SM_INVALID); + if (GetSaveAsFilename()) + { + if (SaveDocumentAs(szBufferFilename)) + MruAdd(szCurrentFilename); + } + SwitchToState(SM_RUN); } - - SwitchToState(SM_RUN); return 0; } @@ -1013,16 +1018,18 @@ static LRESULT OnFileSaveAs(VOID) // static LRESULT OnFileClose(VOID) { - if (pbyRom == NULL) return 0; - SwitchToState(SM_INVALID); - if (SaveChanges(bAutoSave) != IDCANCEL) + if (bDocumentAvail) { - ResetDocument(); - SetWindowTitle(NULL); - } - else - { - SwitchToState(SM_RUN); + SwitchToState(SM_INVALID); + if (SaveChanges(bAutoSave) != IDCANCEL) + { + ResetDocument(); + SetWindowTitle(NULL); + } + else + { + SwitchToState(SM_RUN); + } } return 0; } @@ -1053,7 +1060,6 @@ static LRESULT OnViewCopy(VOID) { if (EmptyClipboard()) { -#if !defined MONOCHROME // DIB bitmap #define WIDTHBYTES(bits) (((bits) + 31) / 32 * 4) #define PALVERSION 0x300 @@ -1137,20 +1143,6 @@ static LRESULT OnViewCopy(VOID) DeleteObject(hBmp); #undef WIDTHBYTES #undef PALVERSION -#else - HBITMAP hOldBmp, hBmp; - HDC hBmpDC; - - // don't work with background index <> 0 - _ASSERT(nLcdZoom == 1 || nLcdZoom == 2 || nLcdZoom == 4); - hBmp = CreateBitmap(131*nLcdZoom,64*nLcdZoom,1,1,NULL); - hBmpDC = CreateCompatibleDC(NULL); - hOldBmp = (HBITMAP)SelectObject(hBmpDC,hBmp); - BitBlt(hBmpDC,0,0,131*nLcdZoom,64*nLcdZoom,hLcdDC,Chipset.boffset*nLcdZoom,0,SRCCOPY); - SetClipboardData(CF_BITMAP,hBmp); - SelectObject(hBmpDC,hOldBmp); - DeleteDC(hBmpDC); -#endif } CloseClipboard(); } @@ -1283,7 +1275,7 @@ static LRESULT OnViewScript(VOID) if (!DisplayChooseKml(cType)) // quit with Cancel { if (!bKMLChanged) // KML script not changed - break; // exit loop with current loaded KML script + break; // exit loop with current loaded KML script // restore KML script file name lstrcpyn(szCurrentKml,szKmlFile,ARRAYSIZEOF(szCurrentKml)); @@ -2021,6 +2013,8 @@ int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nC hszTopic = DdeCreateStringHandle(idDdeInst,szTopic,0); DdeNameService(idDdeInst,hszService,NULL,DNS_REGISTER); + SoundOpen(uWaveDevId); // open waveform-audio output device + _ASSERT(hWnd != NULL); _ASSERT(hWindowDC != NULL); @@ -2075,6 +2069,8 @@ start: DdeFreeStringHandle(idDdeInst, hszTopic); DdeUninitialize(idDdeInst); + SoundClose(); // close waveform-audio output device + // get full path name of szCurrentFilename if (GetFullPathName(szCurrentFilename,ARRAYSIZEOF(szBufferFilename),szBufferFilename,&lpFilePart) == 0) szBufferFilename[0] = 0; // no last document name diff --git a/Sources/Emu48/EMU48.RC b/Sources/Emu48/EMU48.RC index 07a24e9..dbe1c85 100644 --- a/Sources/Emu48/EMU48.RC +++ b/Sources/Emu48/EMU48.RC @@ -296,7 +296,7 @@ FONT 8, "MS Sans Serif" BEGIN ICON IDI_EMU48,IDC_STATIC,7,6,20,20,SS_REALSIZEIMAGE LTEXT "",IDC_VERSION,29,6,151,8,NOT WS_GROUP - LTEXT "Copyright © 2013 Christoph Gießelink && Sébastien Carlier", + LTEXT "Copyright © 2014 Christoph Gießelink && Sébastien Carlier", IDC_STATIC,29,18,181,8 DEFPUSHBUTTON "OK",IDOK,215,12,39,14 EDITTEXT IDC_LICENSE,7,33,247,112,ES_MULTILINE | ES_AUTOHSCROLL | @@ -687,8 +687,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,5,5,0 - PRODUCTVERSION 1,5,5,0 + FILEVERSION 1,5,6,0 + PRODUCTVERSION 1,5,6,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -705,12 +705,12 @@ BEGIN BEGIN VALUE "CompanyName", "Christoph Gießelink & Sebastien Carlier\0" VALUE "FileDescription", "HP38/39/40/48/49 Emulator\0" - VALUE "FileVersion", "1, 5, 5, 0\0" + VALUE "FileVersion", "1, 5, 6, 0\0" VALUE "InternalName", "Emu48\0" - VALUE "LegalCopyright", "Copyright © 2013\0" + VALUE "LegalCopyright", "Copyright © 2014\0" VALUE "OriginalFilename", "Emu48.exe\0" VALUE "ProductName", "Emu48\0" - VALUE "ProductVersion", "1, 5, 5, 0\0" + VALUE "ProductVersion", "1, 5, 6, 0\0" END END BLOCK "VarFileInfo" diff --git a/Sources/Emu48/ENGINE.C b/Sources/Emu48/ENGINE.C index 9c09a49..7d37211 100644 --- a/Sources/Emu48/ENGINE.C +++ b/Sources/Emu48/ENGINE.C @@ -51,7 +51,7 @@ DWORD dwDbgRstkp; // stack recursion level of step over end DWORD dwDbgRstk; // possible return address DWORD *pdwInstrArray = NULL; // last instruction array -WORD wInstrSize; // size of last instruction array +WORD wInstrSize = 256; // size of last instruction array WORD wInstrWp; // write pointer of instruction array WORD wInstrRp; // read pointer of instruction array @@ -566,7 +566,6 @@ loop: SetHP48Time(); // update HP48 time & date // start display counter/update engine StartDisplay((BYTE)(((Chipset.IORam[LINECOUNT+1]<<4)|Chipset.IORam[LINECOUNT])&0x3F)); - SoundOpen(uWaveDevId); // open waveform-audio output device StartBatMeasure(); // start battery measurement StartTimers(); } @@ -628,7 +627,6 @@ loop: StopDisplay(); // stop display counter/update StopBatMeasure(); // stop battery measurement StopTimers(); - SoundClose(); // close waveform-audio output device while (nNextState == SM_SLEEP) // go into sleep state { diff --git a/Sources/Emu48/EXTERNAL.C b/Sources/Emu48/EXTERNAL.C index 8d2f684..c7864db 100644 --- a/Sources/Emu48/EXTERNAL.C +++ b/Sources/Emu48/EXTERNAL.C @@ -16,16 +16,16 @@ // memory address for flags -53 to -56 #define SFLAG53_56 ( (cCurrentRomType=='6') \ - ? 0xE0E4F \ + ? 0xE0E4F \ : ( (cCurrentRomType=='A') \ - ? 0xF0E4F \ - : ( (cCurrentRomType!='E' && cCurrentRomType!='X') \ - ? ( (cCurrentRomType=='S') \ - ? 0x706D2 \ - : 0x80850 \ - ) \ + ? 0xF0E4F \ + : ( (cCurrentRomType!='E' && cCurrentRomType!='X') \ + ? ( (cCurrentRomType=='S') \ + ? 0x706D2 \ + : 0x80850 \ + ) \ : 0x80F0F \ - ) \ + ) \ ) \ ) diff --git a/Sources/Emu48/FETCH.C b/Sources/Emu48/FETCH.C index 66e0fef..705a45a 100644 --- a/Sources/Emu48/FETCH.C +++ b/Sources/Emu48/FETCH.C @@ -9,767 +9,767 @@ #include "pch.h" #include "Opcodes.h" -#define F 0xFF // F = function +#define F 0xFF // F = function -typedef struct +typedef const struct { const VOID *pLnk; const DWORD dwTyp; } JMPTAB, *PJMPTAB; // jump tables -static const JMPTAB oF_[] = +static JMPTAB oF_[] = { - oF0, F, - oF1, F, - oF2, F, - oF3, F, - oF4, F, - oF5, F, - oF6, F, - oF7, F, - oF8, F, - oF9, F, - oFA, F, - oFB, F, - oFC, F, - oFD, F, - oFE, F, - oFF, F + oF0, F, + oF1, F, + oF2, F, + oF3, F, + oF4, F, + oF5, F, + oF6, F, + oF7, F, + oF8, F, + oF9, F, + oFA, F, + oFB, F, + oFC, F, + oFD, F, + oFE, F, + oFF, F }; -static const JMPTAB oE_[] = +static JMPTAB oE_[] = { - oE0, F, - oE1, F, - oE2, F, - oE3, F, - oE4, F, - oE5, F, - oE6, F, - oE7, F, - oE8, F, - oE9, F, - oEA, F, - oEB, F, - oEC, F, - oED, F, - oEE, F, - oEF, F + oE0, F, + oE1, F, + oE2, F, + oE3, F, + oE4, F, + oE5, F, + oE6, F, + oE7, F, + oE8, F, + oE9, F, + oEA, F, + oEB, F, + oEC, F, + oED, F, + oEE, F, + oEF, F }; -static const JMPTAB oD_[] = +static JMPTAB oD_[] = { - oD0, F, - oD1, F, - oD2, F, - oD3, F, - oD4, F, - oD5, F, - oD6, F, - oD7, F, - oD8, F, - oD9, F, - oDA, F, - oDB, F, - oDC, F, - oDD, F, - oDE, F, - oDF, F + oD0, F, + oD1, F, + oD2, F, + oD3, F, + oD4, F, + oD5, F, + oD6, F, + oD7, F, + oD8, F, + oD9, F, + oDA, F, + oDB, F, + oDC, F, + oDD, F, + oDE, F, + oDF, F }; -static const JMPTAB oC_[] = +static JMPTAB oC_[] = { - oC0, F, - oC1, F, - oC2, F, - oC3, F, - oC4, F, - oC5, F, - oC6, F, - oC7, F, - oC8, F, - oC9, F, - oCA, F, - oCB, F, - oCC, F, - oCD, F, - oCE, F, - oCF, F + oC0, F, + oC1, F, + oC2, F, + oC3, F, + oC4, F, + oC5, F, + oC6, F, + oC7, F, + oC8, F, + oC9, F, + oCA, F, + oCB, F, + oCC, F, + oCD, F, + oCE, F, + oCF, F }; -static const JMPTAB oBb_[] = +static JMPTAB oBb_[] = { - oBb0, F, - oBb1, F, - oBb2, F, - oBb3, F, - oBb4, F, - oBb5, F, - oBb6, F, - oBb7, F, - oBb8, F, - oBb9, F, - oBbA, F, - oBbB, F, - oBbC, F, - oBbD, F, - oBbE, F, - oBbF, F + oBb0, F, + oBb1, F, + oBb2, F, + oBb3, F, + oBb4, F, + oBb5, F, + oBb6, F, + oBb7, F, + oBb8, F, + oBb9, F, + oBbA, F, + oBbB, F, + oBbC, F, + oBbD, F, + oBbE, F, + oBbF, F }; -static const JMPTAB oBa_[] = +static JMPTAB oBa_[] = { - oBa0, F, - oBa1, F, - oBa2, F, - oBa3, F, - oBa4, F, - oBa5, F, - oBa6, F, - oBa7, F, - oBa8, F, - oBa9, F, - oBaA, F, - oBaB, F, - oBaC, F, - oBaD, F, - oBaE, F, - oBaF, F + oBa0, F, + oBa1, F, + oBa2, F, + oBa3, F, + oBa4, F, + oBa5, F, + oBa6, F, + oBa7, F, + oBa8, F, + oBa9, F, + oBaA, F, + oBaB, F, + oBaC, F, + oBaD, F, + oBaE, F, + oBaF, F }; -static const JMPTAB oB_[] = +static JMPTAB oB_[] = { - oBa_, 2, - oBa_, 2, - oBa_, 2, - oBa_, 2, - oBa_, 2, - oBa_, 2, - oBa_, 2, - oBa_, 2, - oBb_, 2, - oBb_, 2, - oBb_, 2, - oBb_, 2, - oBb_, 2, - oBb_, 2, - oBb_, 2, - oBb_, 2 + oBa_, 2, + oBa_, 2, + oBa_, 2, + oBa_, 2, + oBa_, 2, + oBa_, 2, + oBa_, 2, + oBa_, 2, + oBb_, 2, + oBb_, 2, + oBb_, 2, + oBb_, 2, + oBb_, 2, + oBb_, 2, + oBb_, 2, + oBb_, 2 }; -static const JMPTAB oAb_[] = +static JMPTAB oAb_[] = { - oAb0, F, - oAb1, F, - oAb2, F, - oAb3, F, - oAb4, F, - oAb5, F, - oAb6, F, - oAb7, F, - oAb8, F, - oAb9, F, - oAbA, F, - oAbB, F, - oAbC, F, - oAbD, F, - oAbE, F, - oAbF, F + oAb0, F, + oAb1, F, + oAb2, F, + oAb3, F, + oAb4, F, + oAb5, F, + oAb6, F, + oAb7, F, + oAb8, F, + oAb9, F, + oAbA, F, + oAbB, F, + oAbC, F, + oAbD, F, + oAbE, F, + oAbF, F }; -static const JMPTAB oAa_[] = +static JMPTAB oAa_[] = { - oAa0, F, - oAa1, F, - oAa2, F, - oAa3, F, - oAa4, F, - oAa5, F, - oAa6, F, - oAa7, F, - oAa8, F, - oAa9, F, - oAaA, F, - oAaB, F, - oAaC, F, - oAaD, F, - oAaE, F, - oAaF, F + oAa0, F, + oAa1, F, + oAa2, F, + oAa3, F, + oAa4, F, + oAa5, F, + oAa6, F, + oAa7, F, + oAa8, F, + oAa9, F, + oAaA, F, + oAaB, F, + oAaC, F, + oAaD, F, + oAaE, F, + oAaF, F }; -static const JMPTAB oA_[] = +static JMPTAB oA_[] = { - oAa_, 2, - oAa_, 2, - oAa_, 2, - oAa_, 2, - oAa_, 2, - oAa_, 2, - oAa_, 2, - oAa_, 2, - oAb_, 2, - oAb_, 2, - oAb_, 2, - oAb_, 2, - oAb_, 2, - oAb_, 2, - oAb_, 2, - oAb_, 2 + oAa_, 2, + oAa_, 2, + oAa_, 2, + oAa_, 2, + oAa_, 2, + oAa_, 2, + oAa_, 2, + oAa_, 2, + oAb_, 2, + oAb_, 2, + oAb_, 2, + oAb_, 2, + oAb_, 2, + oAb_, 2, + oAb_, 2, + oAb_, 2 }; -static const JMPTAB o9b_[] = +static JMPTAB o9b_[] = { - o9b0, F, - o9b1, F, - o9b2, F, - o9b3, F, - o9b4, F, - o9b5, F, - o9b6, F, - o9b7, F, - o9b8, F, - o9b9, F, - o9bA, F, - o9bB, F, - o9bC, F, - o9bD, F, - o9bE, F, - o9bF, F + o9b0, F, + o9b1, F, + o9b2, F, + o9b3, F, + o9b4, F, + o9b5, F, + o9b6, F, + o9b7, F, + o9b8, F, + o9b9, F, + o9bA, F, + o9bB, F, + o9bC, F, + o9bD, F, + o9bE, F, + o9bF, F }; -static const JMPTAB o9a_[] = +static JMPTAB o9a_[] = { - o9a0, F, - o9a1, F, - o9a2, F, - o9a3, F, - o9a4, F, - o9a5, F, - o9a6, F, - o9a7, F, - o9a8, F, - o9a9, F, - o9aA, F, - o9aB, F, - o9aC, F, - o9aD, F, - o9aE, F, - o9aF, F + o9a0, F, + o9a1, F, + o9a2, F, + o9a3, F, + o9a4, F, + o9a5, F, + o9a6, F, + o9a7, F, + o9a8, F, + o9a9, F, + o9aA, F, + o9aB, F, + o9aC, F, + o9aD, F, + o9aE, F, + o9aF, F }; -static const JMPTAB o9_[] = +static JMPTAB o9_[] = { - o9a_, 2, - o9a_, 2, - o9a_, 2, - o9a_, 2, - o9a_, 2, - o9a_, 2, - o9a_, 2, - o9a_, 2, - o9b_, 2, - o9b_, 2, - o9b_, 2, - o9b_, 2, - o9b_, 2, - o9b_, 2, - o9b_, 2, - o9b_, 2 + o9a_, 2, + o9a_, 2, + o9a_, 2, + o9a_, 2, + o9a_, 2, + o9a_, 2, + o9a_, 2, + o9a_, 2, + o9b_, 2, + o9b_, 2, + o9b_, 2, + o9b_, 2, + o9b_, 2, + o9b_, 2, + o9b_, 2, + o9b_, 2 }; -static const JMPTAB o8B_[] = +static JMPTAB o8B_[] = { - o8B0, F, - o8B1, F, - o8B2, F, - o8B3, F, - o8B4, F, - o8B5, F, - o8B6, F, - o8B7, F, - o8B8, F, - o8B9, F, - o8BA, F, - o8BB, F, - o8BC, F, - o8BD, F, - o8BE, F, - o8BF, F + o8B0, F, + o8B1, F, + o8B2, F, + o8B3, F, + o8B4, F, + o8B5, F, + o8B6, F, + o8B7, F, + o8B8, F, + o8B9, F, + o8BA, F, + o8BB, F, + o8BC, F, + o8BD, F, + o8BE, F, + o8BF, F }; -static const JMPTAB o8A_[] = +static JMPTAB o8A_[] = { - o8A0, F, - o8A1, F, - o8A2, F, - o8A3, F, - o8A4, F, - o8A5, F, - o8A6, F, - o8A7, F, - o8A8, F, - o8A9, F, - o8AA, F, - o8AB, F, - o8AC, F, - o8AD, F, - o8AE, F, - o8AF, F + o8A0, F, + o8A1, F, + o8A2, F, + o8A3, F, + o8A4, F, + o8A5, F, + o8A6, F, + o8A7, F, + o8A8, F, + o8A9, F, + o8AA, F, + o8AB, F, + o8AC, F, + o8AD, F, + o8AE, F, + o8AF, F }; -static const JMPTAB o81B_[] = +static JMPTAB o81B_[] = { - o_invalid4, F, - o81B1, F, // normally o_invalid4, beep patch - o81B2, F, - o81B3, F, - o81B4, F, - o81B5, F, - o81B6, F, - o81B7, F, - o_invalid4, F, - o_invalid4, F, - o_invalid4, F, - o_invalid4, F, - o_invalid4, F, - o_invalid4, F, - o_invalid4, F, - o_invalid4, F + o_invalid4, F, + o81B1, F, // normally o_invalid4, beep patch + o81B2, F, + o81B3, F, + o81B4, F, + o81B5, F, + o81B6, F, + o81B7, F, + o_invalid4, F, + o_invalid4, F, + o_invalid4, F, + o_invalid4, F, + o_invalid4, F, + o_invalid4, F, + o_invalid4, F, + o_invalid4, F }; -static const JMPTAB o81Af2_[] = +static JMPTAB o81Af2_[] = { - o81Af20, F, - o81Af21, F, - o81Af22, F, - o81Af23, F, - o81Af24, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o81Af28, F, - o81Af29, F, - o81Af2A, F, - o81Af2B, F, - o81Af2C, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F + o81Af20, F, + o81Af21, F, + o81Af22, F, + o81Af23, F, + o81Af24, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o81Af28, F, + o81Af29, F, + o81Af2A, F, + o81Af2B, F, + o81Af2C, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F }; -static const JMPTAB o81Af1_[] = +static JMPTAB o81Af1_[] = { - o81Af10, F, - o81Af11, F, - o81Af12, F, - o81Af13, F, - o81Af14, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o81Af18, F, - o81Af19, F, - o81Af1A, F, - o81Af1B, F, - o81Af1C, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F + o81Af10, F, + o81Af11, F, + o81Af12, F, + o81Af13, F, + o81Af14, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o81Af18, F, + o81Af19, F, + o81Af1A, F, + o81Af1B, F, + o81Af1C, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F }; -static const JMPTAB o81Af0_[] = +static JMPTAB o81Af0_[] = { - o81Af00, F, - o81Af01, F, - o81Af02, F, - o81Af03, F, - o81Af04, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o81Af08, F, - o81Af09, F, - o81Af0A, F, - o81Af0B, F, - o81Af0C, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F + o81Af00, F, + o81Af01, F, + o81Af02, F, + o81Af03, F, + o81Af04, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o81Af08, F, + o81Af09, F, + o81Af0A, F, + o81Af0B, F, + o81Af0C, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F }; -static const JMPTAB o81A_[] = +static JMPTAB o81A_[] = { - o81Af0_, 5, - o81Af1_, 5, - o81Af2_, 5, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F + o81Af0_, 5, + o81Af1_, 5, + o81Af2_, 5, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F }; -static const JMPTAB o819_[] = +static JMPTAB o819_[] = { - o819f0, F, - o819f1, F, - o819f2, F, - o819f3, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F + o819f0, F, + o819f1, F, + o819f2, F, + o819f3, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F }; -static const JMPTAB o818_[] = +static JMPTAB o818_[] = { - o818f0x, F, - o818f1x, F, - o818f2x, F, - o818f3x, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o818f8x, F, - o818f9x, F, - o818fAx, F, - o818fBx, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F, - o_invalid6, F + o818f0x, F, + o818f1x, F, + o818f2x, F, + o818f3x, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o818f8x, F, + o818f9x, F, + o818fAx, F, + o818fBx, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F, + o_invalid6, F }; -static const JMPTAB o81_[] = +static JMPTAB o81_[] = { - o810, F, - o811, F, - o812, F, - o813, F, - o814, F, - o815, F, - o816, F, - o817, F, - o818_, 4, - o819_, 4, - o81A_, 4, - o81B_, 3, - o81C, F, - o81D, F, - o81E, F, - o81F, F + o810, F, + o811, F, + o812, F, + o813, F, + o814, F, + o815, F, + o816, F, + o817, F, + o818_, 4, + o819_, 4, + o81A_, 4, + o81B_, 3, + o81C, F, + o81D, F, + o81E, F, + o81F, F }; -static const JMPTAB o8081_[] = +static JMPTAB o8081_[] = { - o80810, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F, - o_invalid5, F + o80810, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F, + o_invalid5, F }; -static const JMPTAB o808_[] = +static JMPTAB o808_[] = { - o8080, F, - o8081_, 4, - o8082X, F, - o8083, F, - o8084n, F, - o8085n, F, - o8086n, F, - o8087n, F, - o8088n, F, - o8089n, F, - o808An, F, - o808Bn, F, - o808C, F, - o808D, F, - o808E, F, - o808F, F + o8080, F, + o8081_, 4, + o8082X, F, + o8083, F, + o8084n, F, + o8085n, F, + o8086n, F, + o8087n, F, + o8088n, F, + o8089n, F, + o808An, F, + o808Bn, F, + o808C, F, + o808D, F, + o808E, F, + o808F, F }; -static const JMPTAB o80_[] = +static JMPTAB o80_[] = { - o800, F, - o801, F, - o802, F, - o803, F, - o804, F, - o805, F, - o806, F, - o807, F, - o808_, 3, - o809, F, - o80A, F, - o80B, F, - o80Cn, F, - o80Dn, F, - o80E, F, - o80Fn, F + o800, F, + o801, F, + o802, F, + o803, F, + o804, F, + o805, F, + o806, F, + o807, F, + o808_, 3, + o809, F, + o80A, F, + o80B, F, + o80Cn, F, + o80Dn, F, + o80E, F, + o80Fn, F }; -static const JMPTAB o8_[] = +static JMPTAB o8_[] = { - o80_, 2, - o81_, 2, - o82n, F, - o83n, F, - o84n, F, - o85n, F, - o86n, F, - o87n, F, - o88n, F, - o89n, F, - o8A_, 2, - o8B_, 2, - o8Cd4, F, - o8Dd5, F, - o8Ed4, F, - o8Fd5, F + o80_, 2, + o81_, 2, + o82n, F, + o83n, F, + o84n, F, + o85n, F, + o86n, F, + o87n, F, + o88n, F, + o89n, F, + o8A_, 2, + o8B_, 2, + o8Cd4, F, + o8Dd5, F, + o8Ed4, F, + o8Fd5, F }; -static const JMPTAB o15_[] = +static JMPTAB o15_[] = { - o150a, F, - o151a, F, - o152a, F, - o153a, F, - o154a, F, - o155a, F, - o156a, F, - o157a, F, - o158x, F, - o159x, F, - o15Ax, F, - o15Bx, F, - o15Cx, F, - o15Dx, F, - o15Ex, F, - o15Fx, F + o150a, F, + o151a, F, + o152a, F, + o153a, F, + o154a, F, + o155a, F, + o156a, F, + o157a, F, + o158x, F, + o159x, F, + o15Ax, F, + o15Bx, F, + o15Cx, F, + o15Dx, F, + o15Ex, F, + o15Fx, F }; -static const JMPTAB o14_[] = +static JMPTAB o14_[] = { - o140, F, - o141, F, - o142, F, - o143, F, - o144, F, - o145, F, - o146, F, - o147, F, - o148, F, - o149, F, - o14A, F, - o14B, F, - o14C, F, - o14D, F, - o14E, F, - o14F, F + o140, F, + o141, F, + o142, F, + o143, F, + o144, F, + o145, F, + o146, F, + o147, F, + o148, F, + o149, F, + o14A, F, + o14B, F, + o14C, F, + o14D, F, + o14E, F, + o14F, F }; -static const JMPTAB o13_[] = +static JMPTAB o13_[] = { - o130, F, - o131, F, - o132, F, - o133, F, - o134, F, - o135, F, - o136, F, - o137, F, - o138, F, - o139, F, - o13A, F, - o13B, F, - o13C, F, - o13D, F, - o13E, F, - o13F, F + o130, F, + o131, F, + o132, F, + o133, F, + o134, F, + o135, F, + o136, F, + o137, F, + o138, F, + o139, F, + o13A, F, + o13B, F, + o13C, F, + o13D, F, + o13E, F, + o13F, F }; -static const JMPTAB o12_[] = +static JMPTAB o12_[] = { - o120, F, - o121, F, - o122, F, - o123, F, - o124, F, - o_invalid3, F, - o_invalid3, F, - o_invalid3, F, - o128, F, - o129, F, - o12A, F, - o12B, F, - o12C, F, - o_invalid3, F, - o_invalid3, F, - o_invalid3, F + o120, F, + o121, F, + o122, F, + o123, F, + o124, F, + o_invalid3, F, + o_invalid3, F, + o_invalid3, F, + o128, F, + o129, F, + o12A, F, + o12B, F, + o12C, F, + o_invalid3, F, + o_invalid3, F, + o_invalid3, F }; -static const JMPTAB o11_[] = +static JMPTAB o11_[] = { - o110, F, - o111, F, - o112, F, - o113, F, - o114, F, - o_invalid3, F, - o_invalid3, F, - o_invalid3, F, - o118, F, - o119, F, - o11A, F, - o11B, F, - o11C, F, - o_invalid3, F, - o_invalid3, F, - o_invalid3, F + o110, F, + o111, F, + o112, F, + o113, F, + o114, F, + o_invalid3, F, + o_invalid3, F, + o_invalid3, F, + o118, F, + o119, F, + o11A, F, + o11B, F, + o11C, F, + o_invalid3, F, + o_invalid3, F, + o_invalid3, F }; -static const JMPTAB o10_[] = +static JMPTAB o10_[] = { - o100, F, - o101, F, - o102, F, - o103, F, - o104, F, - o_invalid3, F, - o_invalid3, F, - o_invalid3, F, - o108, F, - o109, F, - o10A, F, - o10B, F, - o10C, F, - o_invalid3, F, - o_invalid3, F, - o_invalid3, F + o100, F, + o101, F, + o102, F, + o103, F, + o104, F, + o_invalid3, F, + o_invalid3, F, + o_invalid3, F, + o108, F, + o109, F, + o10A, F, + o10B, F, + o10C, F, + o_invalid3, F, + o_invalid3, F, + o_invalid3, F }; -static const JMPTAB o1_[] = +static JMPTAB o1_[] = { - o10_, 2, - o11_, 2, - o12_, 2, - o13_, 2, - o14_, 2, - o15_, 2, - o16x, F, - o17x, F, - o18x, F, - o19d2, F, - o1Ad4, F, - o1Bd5, F, - o1Cx, F, - o1Dd2, F, - o1Ed4, F, - o1Fd5, F + o10_, 2, + o11_, 2, + o12_, 2, + o13_, 2, + o14_, 2, + o15_, 2, + o16x, F, + o17x, F, + o18x, F, + o19d2, F, + o1Ad4, F, + o1Bd5, F, + o1Cx, F, + o1Dd2, F, + o1Ed4, F, + o1Fd5, F }; -static const JMPTAB o0E_[] = +static JMPTAB o0E_[] = { - o0Ef0, F, - o0Ef1, F, - o0Ef2, F, - o0Ef3, F, - o0Ef4, F, - o0Ef5, F, - o0Ef6, F, - o0Ef7, F, - o0Ef8, F, - o0Ef9, F, - o0EfA, F, - o0EfB, F, - o0EfC, F, - o0EfD, F, - o0EfE, F, - o0EfF, F + o0Ef0, F, + o0Ef1, F, + o0Ef2, F, + o0Ef3, F, + o0Ef4, F, + o0Ef5, F, + o0Ef6, F, + o0Ef7, F, + o0Ef8, F, + o0Ef9, F, + o0EfA, F, + o0EfB, F, + o0EfC, F, + o0EfD, F, + o0EfE, F, + o0EfF, F }; -static const JMPTAB o0_[] = +static JMPTAB o0_[] = { - o00, F, - o01, F, - o02, F, - o03, F, - o04, F, - o05, F, - o06, F, - o07, F, - o08, F, - o09, F, - o0A, F, - o0B, F, - o0C, F, - o0D, F, - o0E_, 3, - o0F, F + o00, F, + o01, F, + o02, F, + o03, F, + o04, F, + o05, F, + o06, F, + o07, F, + o08, F, + o09, F, + o0A, F, + o0B, F, + o0C, F, + o0D, F, + o0E_, 3, + o0F, F }; -static const JMPTAB o_[] = +static JMPTAB o_[] = { - o0_, 1, - o1_, 1, - o2n, F, - o3X, F, - o4d2, F, - o5d2, F, - o6d3, F, - o7d3, F, - o8_, 1, - o9_, 1, - oA_, 1, - oB_, 1, - oC_, 1, - oD_, 1, - oE_, 1, - oF_, 1 + o0_, 1, + o1_, 1, + o2n, F, + o3X, F, + o4d2, F, + o5d2, F, + o6d3, F, + o7d3, F, + o8_, 1, + o9_, 1, + oA_, 1, + oB_, 1, + oC_, 1, + oD_, 1, + oE_, 1, + oF_, 1 }; // opcode dispatcher VOID EvalOpcode(LPBYTE I) { - DWORD dwTemp,dwIndex = 0; - JMPTAB const *pJmpTab = o_; + DWORD dwIndex = 0; + PJMPTAB pJmpTab = o_; do { - dwTemp = I[dwIndex]; // table entry - _ASSERT(dwTemp <= 0xf); // found packed data - dwIndex = pJmpTab[dwTemp].dwTyp; // next pointer type - pJmpTab = (PJMPTAB) pJmpTab[dwTemp].pLnk; // next pointer to table/function + _ASSERT(I[dwIndex] <= 0xf); // found packed data + pJmpTab = &pJmpTab[I[dwIndex]]; // table entry by opcode + dwIndex = pJmpTab->dwTyp; // next pointer type + pJmpTab = (PJMPTAB) pJmpTab->pLnk; // next pointer to table/function } while (dwIndex != F); // reference to table? -> again diff --git a/Sources/Emu48/FILES.C b/Sources/Emu48/FILES.C index d4f8e8b..65ce3b0 100644 --- a/Sources/Emu48/FILES.C +++ b/Sources/Emu48/FILES.C @@ -312,6 +312,7 @@ BOOL PatchRom(LPCTSTR szFilename) PSZ lpStop,lpBuf = NULL; DWORD dwAddress = 0; UINT nPos = 0; + BOOL bSucc = TRUE; if (pbyRom == NULL) return FALSE; SetCurrentDirectory(szEmuDirectory); @@ -319,13 +320,8 @@ BOOL PatchRom(LPCTSTR szFilename) SetCurrentDirectory(szCurrentDirectory); if (hFile == INVALID_HANDLE_VALUE) return FALSE; dwFileSizeLow = GetFileSize(hFile, &dwFileSizeHigh); - if (dwFileSizeLow <= 5) - { // file is too small. - CloseHandle(hFile); - return FALSE; - } - if (dwFileSizeHigh != 0) - { // file is too large. + if (dwFileSizeHigh != 0 || dwFileSizeLow == 0) + { // file is too large or empty CloseHandle(hFile); return FALSE; } @@ -341,20 +337,15 @@ BOOL PatchRom(LPCTSTR szFilename) nPos = 0; while (lpBuf[nPos]) { - do // remove blank space - { - if ( (lpBuf[nPos]!=' ') - &&(lpBuf[nPos]!='\n') - &&(lpBuf[nPos]!='\r') - &&(lpBuf[nPos]!='\t')) break; - nPos++; - } while (lpBuf[nPos]); - if (lpBuf[nPos]==';') // comment ? + // skip whitespace characters + nPos += (UINT) strspn(&lpBuf[nPos]," \t\n\r"); + + if (lpBuf[nPos] == ';') // comment? { do { nPos++; - if (lpBuf[nPos]=='\n') + if (lpBuf[nPos] == '\n') { nPos++; break; @@ -363,23 +354,36 @@ BOOL PatchRom(LPCTSTR szFilename) continue; } dwAddress = strtoul(&lpBuf[nPos], &lpStop, 16); - nPos += (UINT) (lpStop - &lpBuf[nPos]) + 1; - if (*lpStop != ':' || *lpStop == 0) - continue; - while (lpBuf[nPos]) + nPos = (UINT) (lpStop - lpBuf); // position of lpStop + + if (*lpStop != 0) // data behind address { - if (isxdigit(lpBuf[nPos]) == FALSE) break; - if (dwAddress < dwRomSize) // patch ROM + if (*lpStop != ':') // invalid syntax { - // patch ROM and save original nibble - PatchNibble(dwAddress, Asc2Nib(lpBuf[nPos])); + // skip to end of line + while (lpBuf[nPos] != '\n' && lpBuf[nPos] != 0) + { + ++nPos; + } + bSucc = FALSE; + continue; + } + + while (lpBuf[++nPos]) + { + if (isxdigit(lpBuf[nPos]) == FALSE) break; + if (dwAddress < dwRomSize) // patch ROM + { + // patch ROM and save original nibble + PatchNibble(dwAddress, Asc2Nib(lpBuf[nPos])); + } + ++dwAddress; } - ++dwAddress; - ++nPos; } } + _ASSERT(nPos <= dwFileSizeLow); // buffer overflow? free(lpBuf); - return TRUE; + return bSucc; } diff --git a/Sources/Emu48/I28F160.H b/Sources/Emu48/I28F160.H index b95535b..a164678 100644 --- a/Sources/Emu48/I28F160.H +++ b/Sources/Emu48/I28F160.H @@ -14,14 +14,14 @@ typedef struct { BYTE byType[4]; // "WSM" UINT uSize; // size of this structure - BYTE byVersion; // WSM version + BYTE byVersion; // WSM version - BOOL bRomArray; // copy of bFlashRomArray - DWORD dwLockCnfg; // block lock table (32 entries) + BOOL bRomArray; // copy of bFlashRomArray + DWORD dwLockCnfg; // block lock table (32 entries) UINT uWrState; // state of write function WSM UINT uRdState; // state of read function WSM - BYTE byStatusReg; // status register - BYTE byExStatusReg; // extended status register + BYTE byStatusReg; // status register + BYTE byExStatusReg; // extended status register BYTE byWrite1No; // no. of written data in write buffer1 BYTE byWrite1Size; // no. of valid data in write buffer1 DWORD dwWrite1Addr; // destination address of buffer1 diff --git a/Sources/Emu48/MOPS.C b/Sources/Emu48/MOPS.C index c7b3db5..7c3dabe 100644 --- a/Sources/Emu48/MOPS.C +++ b/Sources/Emu48/MOPS.C @@ -1188,7 +1188,7 @@ VOID ReadIO(BYTE *a, DWORD d, DWORD s, BOOL bUpdate) if (cCurrentRomType=='E') // HP39/40G { Chipset.IORam[d] = (nCurrentClass != 40) - ? (Chipset.IORam[d] & ~IRI) // HP39G + ? (Chipset.IORam[d] & ~IRI) // HP39G : (Chipset.IORam[d] | IRI); // HP40G } *a = Chipset.IORam[d]; // return IR CONTROL value diff --git a/Sources/Emu48/MRU.C b/Sources/Emu48/MRU.C index c314780..be5b8d1 100644 --- a/Sources/Emu48/MRU.C +++ b/Sources/Emu48/MRU.C @@ -76,7 +76,7 @@ BOOL MruInit(INT nNum) if ((ppszFiles = (LPTSTR *) malloc(nEntry * sizeof(*ppszFiles))) == NULL) return TRUE; - // fill each entry + // fill each entry for (nNum = 0; nNum < nEntry; ++nNum) ppszFiles[nNum] = NULL; diff --git a/Sources/Emu48/PCH.H b/Sources/Emu48/PCH.H index cf7221d..e6ef4b8 100644 --- a/Sources/Emu48/PCH.H +++ b/Sources/Emu48/PCH.H @@ -37,12 +37,19 @@ #define INVALID_FILE_ATTRIBUTES ((DWORD)-1) #endif +#if !defined GWLP_USERDATA +#define GWLP_USERDATA GWL_USERDATA +#endif + #if !defined IDC_HAND // Win2k specific definition #define IDC_HAND MAKEINTRESOURCE(32649) #endif #if _MSC_VER <= 1200 // missing type definition in the MSVC6.0 SDK and earlier +#define SetWindowLongPtr SetWindowLong +#define GetWindowLongPtr GetWindowLong typedef SIZE_T DWORD_PTR, *PDWORD_PTR; +typedef LONG LONG_PTR, *PLONG_PTR; #endif #if _MSC_VER >= 1400 // valid for VS2005 and later diff --git a/Sources/Emu48/REDEYE.C b/Sources/Emu48/REDEYE.C index bd646fe..5577371 100644 --- a/Sources/Emu48/REDEYE.C +++ b/Sources/Emu48/REDEYE.C @@ -12,7 +12,7 @@ #define ERR_CHAR 127 // character for transfer error -#define H1 0x78 +#define H1 0x78 #define H2 0xE6 #define H3 0xD5 #define H4 0x8B diff --git a/Sources/Emu48/RPL.C b/Sources/Emu48/RPL.C index 2887bbd..1bd9ec7 100644 --- a/Sources/Emu48/RPL.C +++ b/Sources/Emu48/RPL.C @@ -89,7 +89,7 @@ static BOOL Metakernel(VOID) { // get version number WORD wVersion = ((Port1[30] * 10) + Port1[34]) * 10 - + Port1[36]; + + Port1[36]; // version newer then V2.30, then compatible with HP OS bMkDetect = (wVersion <= 230); @@ -208,8 +208,8 @@ DWORD RPL_SkipOb(DWORD d) case DOGROB: // Graphic case DOLIB: // Library case DOBAK: // Backup - case DOEXT0: // Library Data - case DOEXT1: // Reserved 1 + case DOEXT0: // Library Data + case DOEXT1: // Reserved 1 if (n == DOEXT1 && cCurrentRomType != 'S') { // on HP48G series and later interpreted as DOACPTR @@ -328,7 +328,7 @@ DWORD RPL_ObjectSize(BYTE *o,DWORD s) case DOLIB: // Library case DOBAK: // Backup case DOEXT0: // Library Data - case DOEXT1: // Reserved 1 + case DOEXT1: // Reserved 1 if (n == DOEXT1 && cCurrentRomType != 'S') { // on HP48G series and later interpreted as DOACPTR @@ -440,7 +440,7 @@ VOID RPL_Push(UINT l,DWORD n) if (METAKERNEL) ++l; // Metakernel, save MK object on stack level 1 stkp = Read5(DSKTOP) - 5; // get pointer of new stack level 1 - Write5(DSKTOP,stkp); // save it + Write5(DSKTOP,stkp); // save it for (i = 1; i < l; ++i) // move down stack level entries before insert pos { diff --git a/Sources/Emu48/SETTINGS.C b/Sources/Emu48/SETTINGS.C index e15a358..c6cb6b1 100644 --- a/Sources/Emu48/SETTINGS.C +++ b/Sources/Emu48/SETTINGS.C @@ -175,6 +175,8 @@ VOID ReadSettings(VOID) ReadString(_T("Port2"),_T("Filename"),_T("SHARED.BIN"),szPort2Filename,ARRAYSIZEOF(szPort2Filename)); // KML bAlwaysDisplayLog = ReadInt(_T("KML"),_T("AlwaysDisplayLog"),bAlwaysDisplayLog); + // Debugger + wInstrSize = ReadInt(_T("Debugger"),_T("LastInstrBufSize"),wInstrSize); // Disassembler disassembler_mode = ReadInt(_T("Disassembler"),_T("Mnemonics"),disassembler_mode); disassembler_symb = ReadInt(_T("Disassembler"),_T("Symbolic"),disassembler_symb); @@ -223,6 +225,8 @@ VOID WriteSettings(VOID) WriteString(_T("Port2"),_T("Filename"),szPort2Filename); // KML WriteInt(_T("KML"),_T("AlwaysDisplayLog"),bAlwaysDisplayLog); + // Debugger + WriteInt(_T("Debugger"),_T("LastInstrBufSize"),wInstrSize); // Disassembler WriteInt(_T("Disassembler"),_T("Mnemonics"),disassembler_mode); WriteInt(_T("Disassembler"),_T("Symbolic"),disassembler_symb); diff --git a/Sources/Emu48/SOUND.C b/Sources/Emu48/SOUND.C index aa88182..caeead0 100644 --- a/Sources/Emu48/SOUND.C +++ b/Sources/Emu48/SOUND.C @@ -96,7 +96,8 @@ static VOID DestroyWaveThread(VOID) if (hThreadWave != NULL) // sound message handler thread running { // shut down thread - PostThreadMessage(dwThreadWaveId,WM_QUIT,0,0); + while (!PostThreadMessage(dwThreadWaveId,WM_QUIT,0,0)) + Sleep(0); WaitForSingleObject(hThreadWave,INFINITE); CloseHandle(hThreadWave); hThreadWave = NULL; @@ -253,7 +254,7 @@ static BOOL AddSamples(DWORD dwSamples, BYTE byLevel) } if (dwSamples < dwBufSamples) // free sample buffer is larger then needed - dwBufSamples = dwSamples; // fill only the necessary no. of samples + dwBufSamples = dwSamples; // fill only the necessary no. of samples dwSamples -= dwBufSamples; // remaining samples after buffer fill @@ -345,7 +346,8 @@ BOOL SoundGetDeviceID(UINT *puDeviceID) // BOOL SoundOpen(UINT uDeviceID) { - if (hWaveDevice == NULL) // no sound device + // check if sound device is already open + if (hWaveDevice == NULL && SoundAvailable(uDeviceID)) { WAVEFORMATEX wf; BOOL bSucc; diff --git a/Sources/Emu48/STACK.C b/Sources/Emu48/STACK.C index 458066c..41915e1 100644 --- a/Sources/Emu48/STACK.C +++ b/Sources/Emu48/STACK.C @@ -27,6 +27,31 @@ BOOL bDetectClpObject = TRUE; // try to detect clipboard object //# //################ +static LPTSTR Trim(LPCTSTR cp) +{ + LPCTSTR pcWs = _T(" \t\n\r"); // valid whitespace characters + + LPTSTR pc; + DWORD dwFirst,dwLast; + + dwLast = lstrlen(cp); // last position in string (EOS) + + // trim leading and tailing whitespace characters + dwFirst = (DWORD) _tcsspn(cp,pcWs); // position of 1st non whitespace character + + // search for position behind last non whitespace character + while (dwLast > dwFirst && _tcschr(pcWs,cp[dwLast-1]) != NULL) + --dwLast; + + dwLast = 1 + dwLast - dwFirst; // calculate buffer length + + if ((pc = (LPTSTR) malloc(dwLast * sizeof(*pc))) != NULL) + { + lstrcpyn(pc,&cp[dwFirst],dwLast); // copy relevant data + EOS + } + return pc; +} + static INT RPL_GetZInt(BYTE CONST *pbyNum,INT nIntLen,LPTSTR cp,INT nSize) { INT i = 0; // character counter @@ -60,7 +85,7 @@ static INT RPL_GetZInt(BYTE CONST *pbyNum,INT nIntLen,LPTSTR cp,INT nSize) return i; } -static INT RPL_SetZInt(LPCTSTR cp,LPBYTE pbyNum,INT nSize) +static __inline INT SetZInt(LPCTSTR cp,LPBYTE pbyNum,INT nSize) { BYTE bySign; INT nStrLen,nNumSize; @@ -109,6 +134,20 @@ static INT RPL_SetZInt(LPCTSTR cp,LPBYTE pbyNum,INT nSize) return nNumSize; } +static INT RPL_SetZInt(LPCTSTR cp,LPBYTE pbyNum,INT nSize) +{ + LPTSTR pszData; + + INT s = 0; + + if ((pszData = Trim(cp)) != NULL) // create a trimmed working copy of the string + { + s = SetZInt(pszData,pbyNum,nSize); + free(pszData); + } + return s; +} + static INT RPL_GetBcd(BYTE CONST *pbyNum,INT nMantLen,INT nExpLen,CONST TCHAR cDec,LPTSTR cp,INT nSize) { BYTE byNib; @@ -198,7 +237,7 @@ static INT RPL_GetBcd(BYTE CONST *pbyNum,INT nMantLen,INT nExpLen,CONST TCHAR cD return i; } -static INT RPL_SetBcd(LPCTSTR cp,INT nMantLen,INT nExpLen,CONST TCHAR cDec,LPBYTE pbyNum,INT nSize) +static __inline INT SetBcd(LPCTSTR cp,INT nMantLen,INT nExpLen,CONST TCHAR cDec,LPBYTE pbyNum,INT nSize) { TCHAR cVc[] = _T(".0123456789eE+-"); @@ -318,6 +357,20 @@ static INT RPL_SetBcd(LPCTSTR cp,INT nMantLen,INT nExpLen,CONST TCHAR cDec,LPBYT return nMantLen + nExpLen + 1; } +static INT RPL_SetBcd(LPCTSTR cp,INT nMantLen,INT nExpLen,CONST TCHAR cDec,LPBYTE pbyNum,INT nSize) +{ + LPTSTR pszData; + + INT s = 0; + + if ((pszData = Trim(cp)) != NULL) // create a trimmed working copy of the string + { + s = SetBcd(pszData,nMantLen,nExpLen,cDec,pbyNum,nSize); + free(pszData); + } + return s; +} + static INT RPL_GetComplex(BYTE CONST *pbyNum,INT nMantLen,INT nExpLen,CONST TCHAR cDec,LPTSTR cp,INT nSize) { INT nLen,nPos; @@ -371,8 +424,7 @@ static INT RPL_SetComplex(LPCTSTR cp,INT nMantLen,INT nExpLen,CONST TCHAR cDec,L ? _T(',') // radix mark '.' -> ',' separator : _T(';'); // radix mark ',' -> ';' separator - // create a working copy of the string - if ((pszData = DuplicateString(cp)) != NULL) + if ((pszData = Trim(cp)) != NULL) // create a trimmed working copy of the string { INT nStrLength = lstrlen(pszData); // string length @@ -415,35 +467,6 @@ static INT RPL_SetComplex(LPCTSTR cp,INT nMantLen,INT nExpLen,CONST TCHAR cDec,L //# //################ -#if 0 -static INT IsRealNumber(LPCTSTR cp,INT nMantLen,INT nExpLen,CONST TCHAR cDec,LPBYTE pbyNum,INT nSize) -{ - LPTSTR lpszNumber; - INT nLength = 0; - - if ((lpszNumber = DuplicateString(cp)) != NULL) - { - LPTSTR p = lpszNumber; - INT i; - - // cut heading whitespaces - for (; *p == _T(' ') || *p == _T('\t'); ++p) { } - - // cut tailing whitespaces - for (i = lstrlen(p); --i >= 0;) - { - if (p[i] != _T(' ') && p[i] != _T('\t')) - break; - } - p[++i] = 0; // new EOS - - nLength = RPL_SetBcd(p,nMantLen,nExpLen,cDec,pbyNum,nSize); - HeapFree(hHeap,0,lpszNumber); - } - return nLength; -} -#endif - static TCHAR GetRadix(VOID) { // get locale decimal point diff --git a/Sources/Emu48/SYMBFILE.C b/Sources/Emu48/SYMBFILE.C index b565249..fb2be4a 100644 --- a/Sources/Emu48/SYMBFILE.C +++ b/Sources/Emu48/SYMBFILE.C @@ -181,7 +181,7 @@ BOOL RplLoadTable(LPCTSTR lpszFilename) ppsBase[dwHash] = pData; } - ++dwSymb; // got symbol + ++dwSymb; // got symbol } else // 42 byte fill reference { diff --git a/Sources/Emu48/TIMER.C b/Sources/Emu48/TIMER.C index 678ad02..ee34d51 100644 --- a/Sources/Emu48/TIMER.C +++ b/Sources/Emu48/TIMER.C @@ -11,10 +11,7 @@ #include "ops.h" #include "io.h" // I/O definitions -#define AUTO_OFF 10 // Time in minutes for 'auto off' - -// Ticks for 01.01.1970 00:00:00 -#define UNIX_0_TIME ((ULONGLONG) 0x0001cf2e8f800000) +#define AUTO_OFF 10 // Time in minutes for 'auto off' // Ticks for 'auto off' #define OFF_TIME ((ULONGLONG) (AUTO_OFF * 60) << 13) diff --git a/Sources/Emu48/TYPES.H b/Sources/Emu48/TYPES.H index bd61013..003d3ff 100644 --- a/Sources/Emu48/TYPES.H +++ b/Sources/Emu48/TYPES.H @@ -26,38 +26,38 @@ typedef struct DWORD Port0Size; // real size of module in KB DWORD Port1Size; // real size of module in KB DWORD Port2Size; // real size of module in KB (HP49G only) - DWORD dwUnused0; // not used, was memory pointer Port0 - DWORD dwUnused1; // not used, was memory pointer Port1 - DWORD dwUnused2; // not used, was memory pointer Port2 + DWORD dwUnused0; // not used, was memory pointer Port0 + DWORD dwUnused1; // not used, was memory pointer Port1 + DWORD dwUnused2; // not used, was memory pointer Port2 - DWORD pc; + DWORD pc; DWORD d0; DWORD d1; DWORD rstkp; DWORD rstk[8]; - BYTE A[16]; - BYTE B[16]; - BYTE C[16]; - BYTE D[16]; - BYTE R0[16]; - BYTE R1[16]; - BYTE R2[16]; - BYTE R3[16]; - BYTE R4[16]; - BYTE ST[4]; - BYTE HST; - BYTE P; - WORD out; + BYTE A[16]; + BYTE B[16]; + BYTE C[16]; + BYTE D[16]; + BYTE R0[16]; + BYTE R1[16]; + BYTE R2[16]; + BYTE R3[16]; + BYTE R4[16]; + BYTE ST[4]; + BYTE HST; + BYTE P; + WORD out; WORD in; BOOL SoftInt; BOOL Shutdn; - BOOL mode_dec; + BOOL mode_dec; BOOL inte; // interrupt status flag (FALSE = int in service) BOOL intk; // 1 ms keyboard scan flag (TRUE = enable) BOOL intd; // keyboard interrupt pending (TRUE = int pending) BOOL carry; - WORD crc; + WORD crc; WORD wPort2Crc; // fingerprint of port2 WORD wRomCrc; // fingerprint of ROM #if defined _USRDLL // DLL version @@ -68,36 +68,36 @@ typedef struct #endif DWORD dwKdnCycles; // cpu cycles at start of 1ms key handler - UINT Bank_FF; // save state of HP48GX port2 or state of HP49G ROM FF - UINT FlashRomState; // WSM state of flash memory (unused) - BYTE cards_status; - BYTE IORam[64]; // I/O hardware register - UINT IOBase; // address of I/O modules page - BOOL IOCfig; // I/O module configuration flag - BYTE P0Base, BSBase, P1Base, P2Base; // address of modules first 2KB page - BYTE P0Size, BSSize, P1Size, P2Size; // mapped size of module in 2KB - BYTE P0End, BSEnd, P1End, P2End; // address of modules last 2KB page - BOOL P0Cfig, BSCfig, P1Cfig, P2Cfig; // module address configuration flag - BOOL P0Cfg2, BSCfg2, P1Cfg2, P2Cfg2; // module size configuration flag + UINT Bank_FF; // save state of HP48GX port2 or state of HP49G ROM FF + UINT FlashRomState; // WSM state of flash memory (unused) + BYTE cards_status; + BYTE IORam[64]; // I/O hardware register + UINT IOBase; // address of I/O modules page + BOOL IOCfig; // I/O module configuration flag + BYTE P0Base, BSBase, P1Base, P2Base; // address of modules first 2KB page + BYTE P0Size, BSSize, P1Size, P2Size; // mapped size of module in 2KB + BYTE P0End, BSEnd, P1End, P2End; // address of modules last 2KB page + BOOL P0Cfig, BSCfig, P1Cfig, P2Cfig; // module address configuration flag + BOOL P0Cfg2, BSCfg2, P1Cfg2, P2Cfg2; // module size configuration flag - BYTE t1; - DWORD t2; + BYTE t1; + DWORD t2; - BOOL bShutdnWake; // flag for wake up from SHUTDN mode + BOOL bShutdnWake; // flag for wake up from SHUTDN mode - BYTE Keyboard_Row[9]; - WORD IR15X; - UINT Keyboard_State; // not used + BYTE Keyboard_Row[9]; + WORD IR15X; + UINT Keyboard_State; // not used signed short loffset; signed int width; - UINT boffset; - UINT lcounter; - UINT sync; // not used - BYTE contrast; - BOOL dispon; // not used - DWORD start1; - DWORD start12; - DWORD end1; - DWORD start2, end2; + UINT boffset; + UINT lcounter; + UINT sync; // not used + BYTE contrast; + BOOL dispon; // not used + DWORD start1; + DWORD start12; + DWORD end1; + DWORD start2, end2; } Chipset_t; diff --git a/Sources/Emu48/UDP.C b/Sources/Emu48/UDP.C index 753066a..e404943 100644 --- a/Sources/Emu48/UDP.C +++ b/Sources/Emu48/UDP.C @@ -37,7 +37,7 @@ BOOL SendByteUdp(BYTE byData) #if defined _UNICODE DWORD dwLength = lstrlen(szUdpServer) + 1; - if ((lpszIpAddr = (LPSTR) malloc(dwLength)) == NULL) + if ((lpszIpAddr = (LPSTR) _alloca(dwLength)) == NULL) return TRUE; // server not found WideCharToMultiByte(CP_ACP, WC_COMPOSITECHECK, @@ -55,17 +55,11 @@ BOOL SendByteUdp(BYTE byData) PHOSTENT host = gethostbyname(lpszIpAddr); if (host == NULL) { - #if defined _UNICODE - free(lpszIpAddr); - #endif return TRUE; // server not found } ip_addr.s_addr = ((PIN_ADDR) host->h_addr_list[0])->s_addr; } - #if defined _UNICODE - free(lpszIpAddr); - #endif } // create UDP socket diff --git a/Sources/GCCPatch/EMU48GCC.RC b/Sources/GCCPatch/EMU48GCC.RC index 67c4fbf..8a7c0f9 100644 --- a/Sources/GCCPatch/EMU48GCC.RC +++ b/Sources/GCCPatch/EMU48GCC.RC @@ -296,7 +296,7 @@ FONT 8, "MS Sans Serif" BEGIN ICON IDI_EMU48,IDC_STATIC,7,6,20,20,SS_REALSIZEIMAGE LTEXT "",IDC_VERSION,29,6,151,8,NOT WS_GROUP - LTEXT "Copyright © 2013 Christoph Gießelink && Sébastien Carlier", + LTEXT "Copyright © 2014 Christoph Gießelink && Sébastien Carlier", IDC_STATIC,29,18,181,8 DEFPUSHBUTTON "OK",IDOK,215,12,39,14 EDITTEXT IDC_LICENSE,7,33,247,112,ES_MULTILINE | ES_AUTOHSCROLL | @@ -715,8 +715,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,5,5,0 - PRODUCTVERSION 1,5,5,0 + FILEVERSION 1,5,6,0 + PRODUCTVERSION 1,5,6,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -733,12 +733,12 @@ BEGIN BEGIN VALUE "CompanyName", "Christoph Gießelink & Sebastien Carlier\0" VALUE "FileDescription", "HP38/39/40/48/49 Emulator\0" - VALUE "FileVersion", "1, 5, 5, 0\0" + VALUE "FileVersion", "1, 5, 6, 0\0" VALUE "InternalName", "Emu48\0" - VALUE "LegalCopyright", "Copyright © 2013\0" + VALUE "LegalCopyright", "Copyright © 2014\0" VALUE "OriginalFilename", "Emu48.exe\0" VALUE "ProductName", "Emu48\0" - VALUE "ProductVersion", "1, 5, 5, 0\0" + VALUE "ProductVersion", "1, 5, 6, 0\0" END END BLOCK "VarFileInfo" diff --git a/Sources/GCCPatch/Makefile b/Sources/GCCPatch/Makefile index a645179..9f68cba 100644 --- a/Sources/GCCPatch/Makefile +++ b/Sources/GCCPatch/Makefile @@ -45,10 +45,10 @@ cleanobj: cleanexe: -rm -f $(TARGET) -cursor.o: cursor.c pch.h emu48.h +cursor.o: cursor.c pch.h emu48.h types.h $(CC) $(CFLAGS) $(DEFINES) -c -o cursor.o cursor.c -ddeserv.o: ddeserv.c pch.h emu48.h types.h +ddeserv.o: ddeserv.c pch.h emu48.h types.h io.h $(CC) $(CFLAGS) $(DEFINES) -c -o ddeserv.o ddeserv.c debugger.o: debugger.c pch.h resource.h emu48.h \ @@ -65,24 +65,24 @@ display.o: display.c pch.h resource.h emu48.h \ types.h io.h kml.h $(CC) $(CFLAGS) $(DEFINES) -c -o display.o display.c -disrpl.o: disrpl.c pch.h Emu48.h disrpl.h +disrpl.o: disrpl.c pch.h Emu48.h types.h disrpl.h $(CC) $(CFLAGS) $(DEFINES) -c -o disrpl.o disrpl.c emu48.o: emu48.c pch.h resource.h emu48.h types.h \ io.h kml.h debugger.h $(CC) $(CFLAGS) $(DEFINES) -c -o emu48.o emu48.c -engine.o: engine.c pch.h emu48.h types.h opcodes.h \ - io.h debugger.h ops.h +engine.o: engine.c pch.h emu48.h types.h opcodes.h \ + io.h debugger.h $(CC) $(CFLAGS) $(DEFINES) -c -o engine.o engine.c -external.o: external.c pch.h emu48.h types.h +external.o: external.c pch.h emu48.h types.h ops.h $(CC) $(CFLAGS) $(DEFINES) -c -o external.o external.c fetch.o: fetch.c pch.h opcodes.h $(CC) $(CFLAGS) $(DEFINES) -c -o fetch.o fetch.c -files.o: files.c pch.h emu48.h types.h io.h \ +files.o: files.c pch.h emu48.h types.h ops.h io.h \ kml.h i28f160.h debugger.h $(CC) $(CFLAGS) $(DEFINES) -c -o files.o files.c @@ -92,33 +92,33 @@ i28f160.o: i28f160.c pch.h emu48.h types.h i28f160.h keyboard.o: keyboard.c pch.h emu48.h types.h io.h $(CC) $(CFLAGS) $(DEFINES) -c -o keyboard.o keyboard.c -keymacro.o: keymacro.c pch.h resource.h Emu48.h kml.h +keymacro.o: keymacro.c pch.h resource.h Emu48.h types.h kml.h $(CC) $(CFLAGS) $(DEFINES) -c -o keymacro.o keymacro.c kml.o: kml.c pch.h resource.h emu48.h types.h kml.h $(CC) $(CFLAGS) $(DEFINES) -c -o kml.o kml.c -lowbat.o: lowbat.c pch.h Emu48.h io.h +lowbat.o: lowbat.c pch.h emu48.h types.h io.h $(CC) $(CFLAGS) $(DEFINES) -c -o lowbat.o lowbat.c -mops.o: mops.c pch.h emu48.h types.h opcodes.h io.h \ +mops.o: mops.c pch.h emu48.h types.h ops.h opcodes.h io.h \ i28f160.h $(CC) $(CFLAGS) $(DEFINES) -c -o mops.o mops.c -mru.o: mru.c pch.h resource.h emu48.h +mru.o: mru.c pch.h resource.h emu48.h types.h $(CC) $(CFLAGS) $(DEFINES) -c -o mru.o mru.c opcodes.o: opcodes.c pch.h emu48.h types.h opcodes.h \ - io.h ops.h + io.h $(CC) $(CFLAGS) $(DEFINES) -c -o opcodes.o opcodes.c # pch.o: pch.c pch.h # $(CC) $(CFLAGS) $(DEFINES) -c -o pch.o pch.c -redeye.o: redeye.c pch.h emu48.h io.h +redeye.o: redeye.c pch.h emu48.h types.h io.h $(CC) $(CFLAGS) $(DEFINES) -c -o redeye.o redeye.c -rpl.o: rpl.c pch.h emu48.h types.h io.h +rpl.o: rpl.c pch.h emu48.h types.h ops.h io.h $(CC) $(CFLAGS) $(DEFINES) -c -o rpl.o rpl.c serial.o: serial.c pch.h emu48.h types.h io.h @@ -127,19 +127,19 @@ serial.o: serial.c pch.h emu48.h types.h io.h settings.o: settings.c pch.h emu48.h types.h i28f160.h $(CC) $(CFLAGS) $(DEFINES) -c -o settings.o settings.c -sound.o: sound.c pch.h emu48.h +sound.o: sound.c pch.h emu48.h types.h $(CC) $(CFLAGS) $(DEFINES) -c -o sound.o sound.c -stack.o: stack.c pch.h resource.h emu48.h io.h +stack.o: stack.c pch.h resource.h emu48.h types.h io.h $(CC) $(CFLAGS) $(DEFINES) -c -o stack.o stack.c -symbfile.o: symbfile.c pch.h emu48.h +symbfile.o: symbfile.c pch.h emu48.h types.h $(CC) $(CFLAGS) $(DEFINES) -c -o symbfile.o symbfile.c -timer.o: timer.c pch.h emu48.h types.h io.h +timer.o: timer.c pch.h emu48.h types.h ops.h io.h $(CC) $(CFLAGS) $(DEFINES) -c -o timer.o timer.c -udp.o: udp.c pch.h io.h +udp.o: udp.c pch.h emu48.h types.h $(CC) $(CFLAGS) $(DEFINES) -c -o udp.o udp.c $(RSRCOBJ): $(RSRC) resource.h emu48.ico dbgtool.bmp checkbox.bmp Emu48.xml diff --git a/Sources/GCCPatch/PCH.H b/Sources/GCCPatch/PCH.H index 14b8a42..c2b2426 100644 --- a/Sources/GCCPatch/PCH.H +++ b/Sources/GCCPatch/PCH.H @@ -18,14 +18,6 @@ #include // #include // missing file -#if !defined VERIFY -#if defined _DEBUG -#define VERIFY(f) _ASSERT(f) -#else // _DEBUG -#define VERIFY(f) ((VOID)(f)) -#endif // _DEBUG -#endif // _VERIFY - #if !defined IDC_HAND // Win2k specific definition #define IDC_HAND MAKEINTRESOURCE(32649) #endif @@ -38,12 +30,16 @@ #define __min(a,b) (((a) < (b)) ? (a) : (b)) #endif -// normally defined in CONIO.H -int __cdecl _inp(unsigned short); -int __cdecl _outp(unsigned short, int); - // normally defined in missing CRTDBG.H #if !defined _ASSERT #define _ASSERT(a) #endif -#define _CrtDumpMemoryLeaks() ((int)0) +#define _CrtDumpMemoryLeaks() + +#if !defined VERIFY +#if defined _DEBUG +#define VERIFY(f) _ASSERT(f) +#else // _DEBUG +#define VERIFY(f) ((VOID)(f)) +#endif // _DEBUG +#endif // VERIFY diff --git a/Sources/GCCPatch/README.TXT b/Sources/GCCPatch/README.TXT index 0c23bed..eb7b669 100644 --- a/Sources/GCCPatch/README.TXT +++ b/Sources/GCCPatch/README.TXT @@ -48,4 +48,4 @@ Many thanks to Pedro A. Arranda Guti compatible. -04/30/13 (c) by Christoph Gießelink +04/29/14 (c) by Christoph Gießelink diff --git a/uninst.exe b/uninst.exe index 51c8884..d07a9da 100755 Binary files a/uninst.exe and b/uninst.exe differ