From e27879ac99f55772c6ba55b58bf3e326a5d8526b Mon Sep 17 00:00:00 2001 From: Andrea Date: Thu, 24 Dec 2020 15:08:50 +0000 Subject: [PATCH] Move interface into a class FrameBase. (PR #893) . Move the Win32 implementation into Win32Frame. --- AppleWinExpress2019.vcxproj | 4 + AppleWinExpress2019.vcxproj.filters | 12 ++ source/CmdLine.cpp | 12 +- source/Configuration/About.cpp | 4 +- source/Configuration/PageConfig.cpp | 16 +- source/Configuration/PageDisk.cpp | 6 +- source/Configuration/PropertySheet.cpp | 12 +- source/Configuration/PropertySheetHelper.cpp | 10 +- source/Debugger/Debug.cpp | 28 +-- source/Debugger/Debugger_Assembler.cpp | 2 +- source/Debugger/Debugger_Commands.cpp | 6 +- source/Debugger/Debugger_Display.cpp | 8 +- source/Disk.cpp | 40 ++-- source/FrameBase.cpp | 17 ++ source/FrameBase.h | 29 +++ source/Harddisk.cpp | 12 +- source/Interface.h | 32 ++-- source/Keyboard.cpp | 20 +- source/Memory.cpp | 6 +- source/MouseInterface.cpp | 2 +- source/NTSC_CharSet.cpp | 2 +- source/Pravets.cpp | 2 +- source/SaveState.cpp | 12 +- source/SerialComms.cpp | 4 +- source/SoundCore.cpp | 2 +- source/Speaker.cpp | 4 +- source/Utilities.cpp | 16 +- source/Video.cpp | 8 +- source/Windows/AppleWin.cpp | 44 +++-- source/Windows/Win32Frame.cpp | 6 + source/Windows/Win32Frame.h | 21 +++ source/Windows/WinFrame.cpp | 187 +++++++++---------- source/Windows/WinVideo.cpp | 29 +-- 33 files changed, 348 insertions(+), 267 deletions(-) create mode 100644 source/FrameBase.cpp create mode 100644 source/FrameBase.h create mode 100644 source/Windows/Win32Frame.cpp create mode 100644 source/Windows/Win32Frame.h diff --git a/AppleWinExpress2019.vcxproj b/AppleWinExpress2019.vcxproj index 7b5778ee..09c5dca1 100644 --- a/AppleWinExpress2019.vcxproj +++ b/AppleWinExpress2019.vcxproj @@ -78,6 +78,7 @@ + @@ -120,6 +121,7 @@ + @@ -155,6 +157,7 @@ + @@ -240,6 +243,7 @@ + diff --git a/AppleWinExpress2019.vcxproj.filters b/AppleWinExpress2019.vcxproj.filters index 18756afd..a6025946 100644 --- a/AppleWinExpress2019.vcxproj.filters +++ b/AppleWinExpress2019.vcxproj.filters @@ -220,6 +220,12 @@ Source Files + + Source Files + + + Source Files\Windows + @@ -525,6 +531,12 @@ Source Files + + Source Files + + + Source Files\Windows + diff --git a/source/CmdLine.cpp b/source/CmdLine.cpp index 05a18f23..e57ff541 100644 --- a/source/CmdLine.cpp +++ b/source/CmdLine.cpp @@ -214,13 +214,13 @@ bool ProcessCmdLine(LPSTR lpCmdLine) bool bRes = false; if (strcmp(lpTmp, "best") == 0) { - bRes = GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight); + bRes = GetFrame().GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight); } else { UINT userSpecifiedHeight = atoi(lpTmp); if (userSpecifiedHeight) - bRes = GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight, userSpecifiedHeight); + bRes = GetFrame().GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight, userSpecifiedHeight); else LogFileOutput("Invalid cmd-line parameter for -fs-height=x switch\n"); } @@ -310,7 +310,7 @@ bool ProcessCmdLine(LPSTR lpCmdLine) { std::string msg = "Failed to load video rom (not found or not exactly 2/4/8/16KiB)\n"; LogFileOutput("%s", msg.c_str()); - MessageBox(g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK); + MessageBox(GetFrame().g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK); } else { @@ -387,7 +387,7 @@ bool ProcessCmdLine(LPSTR lpCmdLine) } else if (strcmp(lpCmdLine, "-multimon") == 0) { - g_bMultiMon = true; + GetFrame().g_bMultiMon = true; } else if ((strcmp(lpCmdLine, "-dcd") == 0) || (strcmp(lpCmdLine, "-modem") == 0)) // GH#386 { @@ -396,11 +396,11 @@ bool ProcessCmdLine(LPSTR lpCmdLine) } else if (strcmp(lpCmdLine, "-alt-enter=toggle-full-screen") == 0) // GH#556 { - SetAltEnterToggleFullScreen(true); + GetFrame().SetAltEnterToggleFullScreen(true); } else if (strcmp(lpCmdLine, "-alt-enter=open-apple-enter") == 0) // GH#556 { - SetAltEnterToggleFullScreen(false); + GetFrame().SetAltEnterToggleFullScreen(false); } else if (strcmp(lpCmdLine, "-video-mode=idealized") == 0) // GH#616 { diff --git a/source/Configuration/About.cpp b/source/Configuration/About.cpp index dab470bf..5dddcb39 100644 --- a/source/Configuration/About.cpp +++ b/source/Configuration/About.cpp @@ -64,7 +64,7 @@ static BOOL CALLBACK DlgProcAbout(HWND hWnd, UINT message, WPARAM wparam, LPARAM case WM_INITDIALOG: { - HICON hIcon = LoadIcon(g_hInstance, TEXT("APPLEWIN_ICON")); + HICON hIcon = LoadIcon(GetFrame().g_hInstance, TEXT("APPLEWIN_ICON")); SendDlgItemMessage(hWnd, IDC_APPLEWIN_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon); TCHAR szAppleWinVersion[50]; @@ -81,5 +81,5 @@ static BOOL CALLBACK DlgProcAbout(HWND hWnd, UINT message, WPARAM wparam, LPARAM bool AboutDlg(void) { - return DialogBox(g_hInstance, (LPCTSTR)IDD_ABOUT, g_hFrameWindow, DlgProcAbout) ? true : false; + return DialogBox(GetFrame().g_hInstance, (LPCTSTR)IDD_ABOUT, GetFrame().g_hFrameWindow, DlgProcAbout) ? true : false; } diff --git a/source/Configuration/PageConfig.cpp b/source/Configuration/PageConfig.cpp index b0944722..f810f152 100644 --- a/source/Configuration/PageConfig.cpp +++ b/source/Configuration/PageConfig.cpp @@ -199,7 +199,7 @@ BOOL CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMPUTER, m_ComputerChoices, nCurrentChoice); } - CheckDlgButton(hWnd, IDC_CHECK_CONFIRM_REBOOT, g_bConfirmReboot ? BST_CHECKED : BST_UNCHECKED ); + CheckDlgButton(hWnd, IDC_CHECK_CONFIRM_REBOOT, GetFrame().g_bConfirmReboot ? BST_CHECKED : BST_UNCHECKED ); m_PropertySheetHelper.FillComboBox(hWnd,IDC_VIDEOTYPE, g_aVideoChoices, GetVideoType()); CheckDlgButton(hWnd, IDC_CHECK_HALF_SCAN_LINES, IsVideoStyle(VS_HALF_SCANLINES) ? BST_CHECKED : BST_UNCHECKED); @@ -314,12 +314,12 @@ void CPageConfig::DlgOK(HWND hWnd) { Config_Save_Video(); - FrameRefreshStatus(DRAW_TITLE, false); + GetFrame().FrameRefreshStatus(DRAW_TITLE, false); VideoReinitialize(); if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) { - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); } } @@ -329,19 +329,19 @@ void CPageConfig::DlgOK(HWND hWnd) if (GetFullScreenShowSubunitStatus() != bNewFSSubunitStatus) { REGSAVE(TEXT(REGVALUE_FS_SHOW_SUBUNIT_STATUS), bNewFSSubunitStatus ? 1 : 0); - SetFullScreenShowSubunitStatus(bNewFSSubunitStatus); + GetFrame().SetFullScreenShowSubunitStatus(bNewFSSubunitStatus); if (IsFullScreen()) - FrameRefreshStatus(DRAW_BACKGROUND | DRAW_LEDS | DRAW_DISK_STATUS); + GetFrame().FrameRefreshStatus(DRAW_BACKGROUND | DRAW_LEDS | DRAW_DISK_STATUS); } // const BOOL bNewConfirmReboot = IsDlgButtonChecked(hWnd, IDC_CHECK_CONFIRM_REBOOT) ? 1 : 0; - if (g_bConfirmReboot != bNewConfirmReboot) + if (GetFrame().g_bConfirmReboot != bNewConfirmReboot) { REGSAVE(TEXT(REGVALUE_CONFIRM_REBOOT), bNewConfirmReboot); - g_bConfirmReboot = bNewConfirmReboot; + GetFrame().g_bConfirmReboot = bNewConfirmReboot; } // @@ -405,7 +405,7 @@ void CPageConfig::EnableTrackbar(HWND hWnd, BOOL enable) void CPageConfig::ui_tfe_settings_dialog(HWND hwnd) { - DialogBox(g_hInstance, (LPCTSTR)IDD_TFE_SETTINGS_DIALOG, hwnd, CPageConfigTfe::DlgProc); + DialogBox(GetFrame().g_hInstance, (LPCTSTR)IDD_TFE_SETTINGS_DIALOG, hwnd, CPageConfigTfe::DlgProc); } bool CPageConfig::IsOkToBenchmark(HWND hWnd, const bool bConfigChanged) diff --git a/source/Configuration/PageDisk.cpp b/source/Configuration/PageDisk.cpp index 6fb51f15..72634f16 100644 --- a/source/Configuration/PageDisk.cpp +++ b/source/Configuration/PageDisk.cpp @@ -92,14 +92,14 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l if (HIWORD(wparam) == CBN_SELCHANGE) { HandleFloppyDriveCombo(hWnd, DRIVE_1, LOWORD(wparam)); - FrameRefreshStatus(DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_BUTTON_DRIVES); } break; case IDC_COMBO_DISK2: if (HIWORD(wparam) == CBN_SELCHANGE) { HandleFloppyDriveCombo(hWnd, DRIVE_2, LOWORD(wparam)); - FrameRefreshStatus(DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_BUTTON_DRIVES); } break; case IDC_COMBO_HDD1: @@ -413,7 +413,7 @@ UINT CPageDisk::RemovalConfirmation(UINT uCommand) if (bMsgBox) { - int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Eject/Unplug Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); + int nRes = MessageBox(GetFrame().g_hFrameWindow, szText, TEXT("Eject/Unplug Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); if (nRes == IDNO) uCommand = 0; } diff --git a/source/Configuration/PropertySheet.cpp b/source/Configuration/PropertySheet.cpp index 018a8b37..8d8bed02 100644 --- a/source/Configuration/PropertySheet.cpp +++ b/source/Configuration/PropertySheet.cpp @@ -41,31 +41,31 @@ void CPropertySheet::Init(void) PropSheetPages[PG_CONFIG].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_CONFIG].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_CONFIG].hInstance = g_hInstance; + PropSheetPages[PG_CONFIG].hInstance = GetFrame().g_hInstance; PropSheetPages[PG_CONFIG].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_CONFIG); PropSheetPages[PG_CONFIG].pfnDlgProc = (DLGPROC)CPageConfig::DlgProc; PropSheetPages[PG_INPUT].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_INPUT].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_INPUT].hInstance = g_hInstance; + PropSheetPages[PG_INPUT].hInstance = GetFrame().g_hInstance; PropSheetPages[PG_INPUT].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_INPUT); PropSheetPages[PG_INPUT].pfnDlgProc = (DLGPROC)CPageInput::DlgProc; PropSheetPages[PG_SOUND].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_SOUND].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_SOUND].hInstance = g_hInstance; + PropSheetPages[PG_SOUND].hInstance = GetFrame().g_hInstance; PropSheetPages[PG_SOUND].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_SOUND); PropSheetPages[PG_SOUND].pfnDlgProc = (DLGPROC)CPageSound::DlgProc; PropSheetPages[PG_DISK].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_DISK].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_DISK].hInstance = g_hInstance; + PropSheetPages[PG_DISK].hInstance = GetFrame().g_hInstance; PropSheetPages[PG_DISK].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_DISK); PropSheetPages[PG_DISK].pfnDlgProc = (DLGPROC)CPageDisk::DlgProc; PropSheetPages[PG_ADVANCED].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_ADVANCED].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_ADVANCED].hInstance = g_hInstance; + PropSheetPages[PG_ADVANCED].hInstance = GetFrame().g_hInstance; PropSheetPages[PG_ADVANCED].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_ADVANCED); PropSheetPages[PG_ADVANCED].pfnDlgProc = (DLGPROC)CPageAdvanced::DlgProc; @@ -73,7 +73,7 @@ void CPropertySheet::Init(void) PropSheetHeader.dwSize = sizeof(PROPSHEETHEADER); PropSheetHeader.dwFlags = PSH_NOAPPLYNOW | /* PSH_NOCONTEXTHELP | */ PSH_PROPSHEETPAGE; - PropSheetHeader.hwndParent = g_hFrameWindow; + PropSheetHeader.hwndParent = GetFrame().g_hFrameWindow; PropSheetHeader.pszCaption = "AppleWin Configuration"; PropSheetHeader.nPages = PG_NUM_SHEETS; PropSheetHeader.nStartPage = m_PropertySheetHelper.GetLastPage(); diff --git a/source/Configuration/PropertySheetHelper.cpp b/source/Configuration/PropertySheetHelper.cpp index 9d30968b..236bc980 100644 --- a/source/Configuration/PropertySheetHelper.cpp +++ b/source/Configuration/PropertySheetHelper.cpp @@ -163,7 +163,7 @@ std::string CPropertySheetHelper::BrowseToFile(HWND hWindow, TCHAR* pszTitle, TC ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWindow; - ofn.hInstance = g_hInstance; + ofn.hInstance = GetFrame().g_hInstance; ofn.lpstrFilter = FILEMASKS; /*ofn.lpstrFilter = TEXT("Applications (*.exe)\0*.exe\0") TEXT("Text files (*.txt)\0*.txt\0") @@ -210,7 +210,7 @@ int CPropertySheetHelper::SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bo ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWindow; - ofn.hInstance = g_hInstance; + ofn.hInstance = GetFrame().g_hInstance; ofn.lpstrFilter = TEXT("Save State files (*.aws.yaml)\0*.aws.yaml\0"); TEXT("All Files\0*.*\0"); ofn.lpstrFile = szFilename; // Dialog strips the last .EXT from this string (eg. file.aws.yaml is displayed as: file.aws @@ -276,14 +276,14 @@ void CPropertySheetHelper::PostMsgAfterClose(HWND hWnd, PAGETYPE page) if (m_ConfigNew.m_uSaveLoadStateMsg && IsOkToSaveLoadState(hWnd, IsConfigChanged())) { // Drop any config change, and do load/save state - PostMessage(g_hFrameWindow, m_ConfigNew.m_uSaveLoadStateMsg, 0, 0); + PostMessage(GetFrame().g_hFrameWindow, m_ConfigNew.m_uSaveLoadStateMsg, 0, 0); return; } if (m_bDoBenchmark) { // Drop any config change, and do benchmark - PostMessage(g_hFrameWindow, WM_USER_BENCHMARK, 0, 0); // NB. doesn't do WM_USER_RESTART + PostMessage(GetFrame().g_hFrameWindow, WM_USER_BENCHMARK, 0, 0); // NB. doesn't do WM_USER_RESTART return; } @@ -316,7 +316,7 @@ void CPropertySheetHelper::PostMsgAfterClose(HWND hWnd, PAGETYPE page) } if (uAfterClose) - PostMessage(g_hFrameWindow, uAfterClose, 0, 0); + PostMessage(GetFrame().g_hFrameWindow, uAfterClose, 0, 0); } bool CPropertySheetHelper::CheckChangesForRestart(HWND hWnd) diff --git a/source/Debugger/Debug.cpp b/source/Debugger/Debug.cpp index 4f714fc2..daa6da3b 100644 --- a/source/Debugger/Debug.cpp +++ b/source/Debugger/Debug.cpp @@ -754,8 +754,8 @@ Update_t CmdBenchmarkStop (int nArgs) g_bBenchmarking = false; DebugEnd(); - FrameRefreshStatus(DRAW_TITLE); - VideoRedrawScreen(); + GetFrame().FrameRefreshStatus(DRAW_TITLE); + GetFrame().VideoRedrawScreen(); DWORD currtime = GetTickCount(); while ((extbench = GetTickCount()) != currtime) ; // intentional busy-waiting @@ -1964,7 +1964,7 @@ static Update_t CmdGo (int nArgs, const bool bFullSpeed) g_bGoCmd_ReinitFlag = true; g_nAppMode = MODE_STEPPING; - FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE); SoundCore_SetFade(FADE_IN); @@ -2033,7 +2033,7 @@ Update_t CmdTrace (int nArgs) g_nDebugStepStart = regs.pc; g_nDebugStepUntil = -1; g_nAppMode = MODE_STEPPING; - FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE); DebugContinueStepping(true); return UPDATE_ALL; // TODO: Verify // 0 @@ -2093,7 +2093,7 @@ Update_t CmdTraceLine (int nArgs) g_nDebugStepUntil = -1; g_nAppMode = MODE_STEPPING; - FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE); DebugContinueStepping(true); return UPDATE_ALL; // TODO: Verify // 0 @@ -2227,7 +2227,7 @@ void _CmdColorGet( const int iScheme, const int iColor ) { TCHAR sText[ CONSOLE_WIDTH ]; wsprintf( sText, "Color: %d\nOut of range!", iColor ); - MessageBox( g_hFrameWindow, sText, TEXT("ERROR"), MB_OK ); + MessageBox(GetFrame().g_hFrameWindow, sText, TEXT("ERROR"), MB_OK ); } } @@ -3042,7 +3042,7 @@ void DisasmCalcTopFromCurAddress( bool bUpdateTop ) "\tLen: %04X\n" "\tMissed: %04X"), g_nDisasmCurAddress - nLen, nLen, g_nDisasmCurAddress ); - MessageBox( g_hFrameWindow, sText, "ERROR", MB_OK ); + MessageBox( GetFrame().g_hFrameWindow, sText, "ERROR", MB_OK ); #endif } } @@ -3773,7 +3773,7 @@ Update_t CmdDisk ( int nArgs) return HelpLastCommand(); diskCard.EjectDisk( iDrive ); - FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } else if (iParam == PARAM_DISK_PROTECT) @@ -3787,7 +3787,7 @@ Update_t CmdDisk ( int nArgs) bProtect = g_aArgs[ 3 ].nValue ? true : false; diskCard.SetProtect( iDrive, bProtect ); - FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } else { @@ -3798,7 +3798,7 @@ Update_t CmdDisk ( int nArgs) // DISK # "Diskname" diskCard.InsertDisk( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE ); - FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } return UPDATE_CONSOLE_DISPLAY; @@ -7448,7 +7448,7 @@ Update_t CmdWindowViewData (int nArgs) //=========================================================================== Update_t CmdWindowViewOutput (int nArgs) { - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); DebugVideoMode::Instance().Set(g_uVideoMode); @@ -8549,7 +8549,7 @@ void DebugBegin () GetDebuggerMemDC(); g_nAppMode = MODE_DEBUG; - FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE); if (GetMainCpu() == CPU_6502) { @@ -8736,7 +8736,7 @@ void DebugContinueStepping(const bool bCallerWillUpdateDisplay/*=false*/) SoundCore_SetFade(FADE_OUT); // NB. Call when MODE_STEPPING (not MODE_DEBUG) - see function g_nAppMode = MODE_DEBUG; - FrameRefreshStatus(DRAW_TITLE); + GetFrame().FrameRefreshStatus(DRAW_TITLE); // BUG: PageUp, Trace - doesn't center cursor g_nDisasmCurAddress = regs.pc; @@ -9064,7 +9064,7 @@ void DebuggerInputConsoleChar( TCHAR ch ) if (!IsClipboardFormatAvailable(CF_TEXT)) return; - if (!OpenClipboard( g_hFrameWindow )) + if (!OpenClipboard(GetFrame().g_hFrameWindow )) return; HGLOBAL hClipboard; diff --git a/source/Debugger/Debugger_Assembler.cpp b/source/Debugger/Debugger_Assembler.cpp index 7cfdddf1..d9154675 100644 --- a/source/Debugger/Debugger_Assembler.cpp +++ b/source/Debugger/Debugger_Assembler.cpp @@ -471,7 +471,7 @@ int _6502_GetOpmodeOpbyte ( const int nBaseAddress, int & iOpmode_, int & nOpby #if _DEBUG if (! g_aOpcodes) { - MessageBox( g_hFrameWindow, "Debugger not properly initialized", "ERROR", MB_OK ); + MessageBox(GetFrame().g_hFrameWindow, "Debugger not properly initialized", "ERROR", MB_OK ); g_aOpcodes = & g_aOpcodes65C02[ 0 ]; // Enhanced Apple //e g_aOpmodes[ AM_2 ].m_nBytes = 2; diff --git a/source/Debugger/Debugger_Commands.cpp b/source/Debugger/Debugger_Commands.cpp index 1a75bbe4..005b62b4 100644 --- a/source/Debugger/Debugger_Commands.cpp +++ b/source/Debugger/Debugger_Commands.cpp @@ -518,7 +518,7 @@ void VerifyDebuggerCommandTable() if ( g_aCommands[ iCmd ].iCommand != iCmd) { sprintf( sText, "*** ERROR *** Enumerated Commands mis-matched at #%d!", iCmd ); - MessageBoxA( g_hFrameWindow, sText, TEXT("ERROR"), MB_OK ); + MessageBoxA(GetFrame().g_hFrameWindow, sText, TEXT("ERROR"), MB_OK ); PostQuitMessage( 1 ); } } @@ -527,14 +527,14 @@ void VerifyDebuggerCommandTable() if (strcmp( g_aCommands[ NUM_COMMANDS ].m_sName, DEBUGGER__COMMANDS_VERIFY_TXT__)) { sprintf( sText, "*** ERROR *** Total Commands mis-matched!" ); - MessageBoxA( g_hFrameWindow, sText, TEXT("ERROR"), MB_OK ); + MessageBoxA(GetFrame().g_hFrameWindow, sText, TEXT("ERROR"), MB_OK ); PostQuitMessage( 1 ); } if (strcmp( g_aParameters[ NUM_PARAMS ].m_sName, DEBUGGER__PARAMS_VERIFY_TXT__)) { sprintf( sText, "*** ERROR *** Total Parameters mis-matched!" ); - MessageBoxA( g_hFrameWindow, sText, TEXT("ERROR"), MB_OK ); + MessageBoxA(GetFrame().g_hFrameWindow, sText, TEXT("ERROR"), MB_OK ); PostQuitMessage( 2 ); } } diff --git a/source/Debugger/Debugger_Display.cpp b/source/Debugger/Debugger_Display.cpp index fdbe117d..8dd670db 100644 --- a/source/Debugger/Debugger_Display.cpp +++ b/source/Debugger/Debugger_Display.cpp @@ -633,7 +633,7 @@ HDC GetConsoleFontDC(void) // DRAW THE SOURCE IMAGE INTO THE SOURCE BIT BUFFER HDC tmpDC = CreateCompatibleDC(hFrameDC); // Pre-scaled bitmap - HBITMAP tmpFont = LoadBitmap(g_hInstance, TEXT("IDB_DEBUG_FONT_7x8")); // Bitmap must be 112x128 as defined above + HBITMAP tmpFont = LoadBitmap(GetFrame().g_hInstance, TEXT("IDB_DEBUG_FONT_7x8")); // Bitmap must be 112x128 as defined above SelectObject(tmpDC, tmpFont); BitBlt(g_hConsoleFontDC, 0, 0, CONSOLE_FONT_BITMAP_WIDTH, CONSOLE_FONT_BITMAP_HEIGHT, tmpDC, 0, 0, @@ -754,7 +754,7 @@ static void PrintGlyph( const int xDst, const int yDst, const int glyph ) { #if _DEBUG if ((xDst < 0) || (yDst < 0)) - MessageBox( g_hFrameWindow, "X or Y out of bounds!", "PrintGlyph()", MB_OK ); + MessageBox(GetFrame().g_hFrameWindow, "X or Y out of bounds!", "PrintGlyph()", MB_OK ); #endif int col = xDst / CONSOLE_FONT_WIDTH ; int row = yDst / CONSOLE_FONT_HEIGHT; @@ -870,7 +870,7 @@ int PrintText ( const char * pText, RECT & rRect ) { #if _DEBUG if (! pText) - MessageBox( g_hFrameWindow, "pText = NULL!", "DrawText()", MB_OK ); + MessageBox(GetFrame().g_hFrameWindow, "pText = NULL!", "DrawText()", MB_OK ); #endif int nLen = strlen( pText ); @@ -4116,7 +4116,7 @@ void UpdateDisplay (Update_t bUpdate) if (spDrawMutex) { #if DEBUG - MessageBox( g_hFrameWindow, "Already drawing!", "!", MB_OK ); + MessageBox( GetFrame().g_hFrameWindow, "Already drawing!", "!", MB_OK ); #endif } spDrawMutex = true; diff --git a/source/Disk.cpp b/source/Disk.cpp index a91f13f2..7eac5512 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -219,7 +219,7 @@ void Disk2InterfaceCard::CheckSpinning(const bool stateChanged, const ULONG uExe m_floppyDrive[m_currDrive].m_spinning = SPINNING_CYCLES; if (modeChanged) - FrameDrawDiskLEDS( (HDC)0 ); + GetFrame().FrameDrawDiskLEDS( (HDC)0 ); if (modeChanged) { @@ -511,7 +511,7 @@ void __stdcall Disk2InterfaceCard::ControlStepper(WORD, WORD address, BYTE, BYTE pDrive->m_phasePrecise = newPhasePrecise; pFloppy->m_trackimagedata = false; m_formatTrack.DriveNotWritingTrack(); - FrameDrawDiskStatus((HDC)0); // Show track status (GH#201) + GetFrame().FrameDrawDiskStatus((HDC)0); // Show track status (GH#201) } #if LOG_DISK_PHASES @@ -683,7 +683,7 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname)) { EjectDisk(!drive); - FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } } @@ -697,7 +697,7 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil { TCHAR szText[100+MAX_PATH]; StringCbPrintf(szText, sizeof(szText), "Only the first file in a multi-file zip is supported\nUse disk image '%s' ?", pFloppy->m_strFilenameInZip.c_str()); - int nRes = MessageBox(g_hFrameWindow, szText, TEXT("Multi-Zip Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); + int nRes = MessageBox(GetFrame().g_hFrameWindow, szText, TEXT("Multi-Zip Warning"), MB_ICONWARNING | MB_YESNO | MB_SETFOREGROUND); if (nRes == IDNO) { EjectDisk(drive); @@ -827,7 +827,7 @@ void Disk2InterfaceCard::NotifyInvalidImage(const int drive, LPCTSTR pszImageFil } MessageBox( - g_hFrameWindow, + GetFrame().g_hFrameWindow, szBuffer, g_pAppTitle.c_str(), MB_ICONEXCLAMATION | MB_SETFOREGROUND); @@ -1033,7 +1033,7 @@ void __stdcall Disk2InterfaceCard::ReadWrite(WORD pc, WORD addr, BYTE bWrite, BY // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!! if ((pFloppy->m_byte & 0xFF) == 0) - FrameDrawDiskStatus( (HDC)0 ); + GetFrame().FrameDrawDiskStatus( (HDC)0 ); } //=========================================================================== @@ -1184,7 +1184,7 @@ void __stdcall Disk2InterfaceCard::DataLatchReadWriteWOZ(WORD pc, WORD addr, BYT // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!! if ((floppy.m_byte & 0xFF) == 0) - FrameDrawDiskStatus((HDC)0); + GetFrame().FrameDrawDiskStatus((HDC)0); } void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemainder) @@ -1543,11 +1543,11 @@ void Disk2InterfaceCard::Reset(const bool bIsPowerCycle) m_floppyDrive[DRIVE_2].m_spinning = 0; m_floppyDrive[DRIVE_2].m_writelight = 0; - FrameRefreshStatus(DRAW_LEDS, false); + GetFrame().FrameRefreshStatus(DRAW_LEDS, false); } InitFirmware(GetCxRomPeripheral()); - FrameRefreshStatus(DRAW_TITLE, false); + GetFrame().FrameRefreshStatus(DRAW_TITLE, false); } void Disk2InterfaceCard::ResetSwitches(void) @@ -1564,7 +1564,7 @@ bool Disk2InterfaceCard::UserSelectNewDiskImage(const int drive, LPCSTR pszFilen { if (!IsDriveConnected(drive)) { - MessageBox(g_hFrameWindow, "Drive not connected!", "Insert disk", MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_OK); + MessageBox(GetFrame().g_hFrameWindow, "Drive not connected!", "Insert disk", MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_OK); return false; } @@ -1582,8 +1582,8 @@ bool Disk2InterfaceCard::UserSelectNewDiskImage(const int drive, LPCSTR pszFilen OPENFILENAME ofn; memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = g_hFrameWindow; - ofn.hInstance = g_hInstance; + ofn.hwndOwner = GetFrame().g_hFrameWindow; + ofn.hInstance = GetFrame().g_hInstance; ofn.lpstrFilter = TEXT("All Images\0*.bin;*.do;*.dsk;*.nib;*.po;*.gz;*.woz;*.zip;*.2mg;*.2img;*.iie;*.apl\0") TEXT("Disk Images (*.bin,*.do,*.dsk,*.nib,*.po,*.gz,*.woz,*.zip,*.2mg,*.2img,*.iie)\0*.bin;*.do;*.dsk;*.nib;*.po;*.gz;*.woz;*.zip;*.2mg;*.2img;*.iie\0") TEXT("All Files\0*.*\0"); @@ -1687,7 +1687,7 @@ void __stdcall Disk2InterfaceCard::SetWriteMode(WORD, WORD, BYTE, BYTE, ULONG uE m_floppyDrive[m_currDrive].m_writelight = WRITELIGHT_CYCLES; if (modechange) - FrameDrawDiskLEDS( (HDC)0 ); + GetFrame().FrameDrawDiskLEDS( (HDC)0 ); } //=========================================================================== @@ -1703,8 +1703,8 @@ void Disk2InterfaceCard::UpdateDriveState(DWORD cycles) { if (!(pDrive->m_spinning -= MIN(pDrive->m_spinning, cycles))) { - FrameDrawDiskLEDS( (HDC)0 ); - FrameDrawDiskStatus( (HDC)0 ); + GetFrame().FrameDrawDiskLEDS( (HDC)0 ); + GetFrame().FrameDrawDiskStatus( (HDC)0 ); } } @@ -1716,8 +1716,8 @@ void Disk2InterfaceCard::UpdateDriveState(DWORD cycles) { if (!(pDrive->m_writelight -= MIN(pDrive->m_writelight, cycles))) { - FrameDrawDiskLEDS( (HDC)0 ); - FrameDrawDiskStatus( (HDC)0 ); + GetFrame().FrameDrawDiskLEDS( (HDC)0 ); + GetFrame().FrameDrawDiskStatus( (HDC)0 ); } } } @@ -1733,7 +1733,7 @@ bool Disk2InterfaceCard::DriveSwap(void) { // 1.26.2.4 Prompt when trying to swap disks while drive is on instead of silently failing int status = MessageBox( - g_hFrameWindow, + GetFrame().g_hFrameWindow, "WARNING:\n" "\n" "\tAttempting to swap a disk while a drive is on\n" @@ -1773,7 +1773,7 @@ bool Disk2InterfaceCard::DriveSwap(void) SaveLastDiskImage(DRIVE_1); SaveLastDiskImage(DRIVE_2); - FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES, false); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES, false); return true; } @@ -2264,7 +2264,7 @@ bool Disk2InterfaceCard::LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT LoadSnapshotDriveUnit(yamlLoadHelper, DRIVE_1, version); LoadSnapshotDriveUnit(yamlLoadHelper, DRIVE_2, version); - FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); return true; } diff --git a/source/FrameBase.cpp b/source/FrameBase.cpp new file mode 100644 index 00000000..1c4722be --- /dev/null +++ b/source/FrameBase.cpp @@ -0,0 +1,17 @@ +#include "StdAfx.h" + +#include "FrameBase.h" + +FrameBase::FrameBase() +{ + g_hFrameWindow = (HWND)0; + g_bConfirmReboot = 1; // saved PageConfig REGSAVE + g_bMultiMon = 0; // OFF = load window position & clamp initial frame to screen, ON = use window position as is + g_bFreshReset = false; + g_hInstance = (HINSTANCE)0; +} + +FrameBase::~FrameBase() +{ + +} diff --git a/source/FrameBase.h b/source/FrameBase.h new file mode 100644 index 00000000..c409fac6 --- /dev/null +++ b/source/FrameBase.h @@ -0,0 +1,29 @@ +#pragma once + +class FrameBase +{ +public: + FrameBase(); + + virtual ~FrameBase(); + + HINSTANCE g_hInstance; + HWND g_hFrameWindow; + BOOL g_bConfirmReboot; // saved PageConfig REGSAVE + BOOL g_bMultiMon; + bool g_bFreshReset; + + virtual void FrameDrawDiskLEDS(HDC hdc) = 0; + virtual void FrameDrawDiskStatus(HDC hdc) = 0; + virtual void FrameRefreshStatus(int, bool bUpdateDiskStatus = true) = 0; + virtual void FrameUpdateApple2Type() = 0; + virtual void FrameSetCursorPosByMousePos() = 0; + + virtual void VideoRedrawScreen() = 0; + virtual void SetFullScreenShowSubunitStatus(bool bShow) = 0; + virtual bool GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& bestHeight, UINT userSpecifiedHeight = 0) = 0; + virtual int SetViewportScale(int nNewScale, bool bForce = false) = 0; + virtual void SetAltEnterToggleFullScreen(bool mode) = 0; + + virtual void SetLoadedSaveStateFlag(const bool bFlag) = 0; +}; diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index 3bc27345..25c4fd77 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -417,7 +417,7 @@ BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename) if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname)) { HD_Unplug(!iDrive); - FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS); } } @@ -465,8 +465,8 @@ static bool HD_SelectImage(const int drive, LPCSTR pszFilename) OPENFILENAME ofn; memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); - ofn.hwndOwner = g_hFrameWindow; - ofn.hInstance = g_hInstance; + ofn.hwndOwner = GetFrame().g_hFrameWindow; + ofn.hInstance = GetFrame().g_hInstance; ofn.lpstrFilter = TEXT("Hard Disk Images (*.hdv,*.po,*.2mg,*.2img,*.gz,*.zip)\0*.hdv;*.po;*.2mg;*.2img;*.gz;*.zip\0") TEXT("All Files\0*.*\0"); ofn.lpstrFile = filename; @@ -713,7 +713,7 @@ static BYTE __stdcall HD_IO_EMUL(WORD pc, WORD addr, BYTE bWrite, BYTE d, ULONG if( pHDD->hd_status_prev != pHDD->hd_status_next ) // Update LEDs if state changes { pHDD->hd_status_prev = pHDD->hd_status_next; - FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS); } #endif @@ -742,7 +742,7 @@ bool HD_ImageSwap(void) HD_SaveLastDiskImage(HARDDISK_1); HD_SaveLastDiskImage(HARDDISK_2); - FrameRefreshStatus(DRAW_LEDS, false); + GetFrame().FrameRefreshStatus(DRAW_LEDS, false); return true; } @@ -902,7 +902,7 @@ bool HD_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version, co HD_SetEnabled(true); - FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS); return true; } diff --git a/source/Interface.h b/source/Interface.h index dd4b45b8..f2d0db47 100644 --- a/source/Interface.h +++ b/source/Interface.h @@ -1,25 +1,15 @@ #pragma once -class IPropertySheet; - -extern HINSTANCE g_hInstance; -extern HWND g_hFrameWindow; -extern BOOL g_bConfirmReboot; // saved PageConfig REGSAVE -extern BOOL g_bMultiMon; -extern bool g_bFreshReset; - -void FrameDrawDiskLEDS(HDC hdc); -void FrameDrawDiskStatus(HDC hdc); -void FrameRefreshStatus(int, bool bUpdateDiskStatus = true); -void FrameUpdateApple2Type(); -void FrameSetCursorPosByMousePos(); - -void VideoRedrawScreen(); -void SetFullScreenShowSubunitStatus(bool bShow); -bool GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& bestHeight, UINT userSpecifiedHeight = 0); -int SetViewportScale(int nNewScale, bool bForce = false); -void SetAltEnterToggleFullScreen(bool mode); - -void SetLoadedSaveStateFlag(const bool bFlag); +// an AppleWin frontend must provide the implementation of these 2 methods +// +// once this is done, +// the core emulator files (i.e. almost all the .cpp directly in Source) +// can compile, link and run properly +// this does not include the main event loop which is left in the arch specific area +// nor the actual rendering of the video buffer to screen +#include "Configuration/PropertySheet.h" IPropertySheet& GetPropertySheet(); + +#include "FrameBase.h" +FrameBase& GetFrame(); diff --git a/source/Keyboard.cpp b/source/Keyboard.cpp index 20b577c0..f31c69e3 100644 --- a/source/Keyboard.cpp +++ b/source/Keyboard.cpp @@ -126,13 +126,13 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII) { if (bASCII == ASCII) // WM_CHAR { - if (g_bFreshReset && key == VK_CANCEL) // OLD HACK: 0x03 + if (GetFrame().g_bFreshReset && key == VK_CANCEL) // OLD HACK: 0x03 { - g_bFreshReset = false; + GetFrame().g_bFreshReset = false; return; // Swallow spurious CTRL-C caused by CTRL-BREAK } - g_bFreshReset = false; + GetFrame().g_bFreshReset = false; if ((key > 0x7F) && !g_bTK3KModeKey) // When in TK3000 mode, we have special keys which need remapping return; @@ -285,7 +285,7 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII) // Note: VK_CANCEL is Control-Break if ((key == VK_CANCEL) && (GetKeyState(VK_CONTROL) < 0)) { - g_bFreshReset = true; + GetFrame().g_bFreshReset = true; CtrlReset(); return; } @@ -302,8 +302,8 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII) if (g_Apple2Type == A2TYPE_TK30002E) { g_bTK3KModeKey = (GetKeyState(VK_SCROLL) & 1) ? true : false; // Sync with the Scroll Lock status - FrameRefreshStatus(DRAW_LEDS); // TODO: Implement |Mode| LED in the UI; make it appear only when in TK3000 mode - VideoRedrawScreen(); // TODO: Still need to implement page mode switching and 'whatnot' + GetFrame().FrameRefreshStatus(DRAW_LEDS); // TODO: Implement |Mode| LED in the UI; make it appear only when in TK3000 mode + GetFrame().VideoRedrawScreen(); // TODO: Still need to implement page mode switching and 'whatnot' } return; } @@ -332,7 +332,7 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII) newKey -= 'A' - 1; // convert to control-key } - PostMessage(g_hFrameWindow, WM_CHAR, newKey, 0); + PostMessage(GetFrame().g_hFrameWindow, WM_CHAR, newKey, 0); } return; @@ -378,7 +378,7 @@ static void ClipboardInit() if (!IsClipboardFormatAvailable(CF_TEXT)) return; - if (!OpenClipboard(g_hFrameWindow)) + if (!OpenClipboard(GetFrame().g_hFrameWindow)) return; hglb = GetClipboardData(CF_TEXT); @@ -538,7 +538,7 @@ void KeybToggleCapsLock () if (!IS_APPLE2) { g_bCapsLock = (GetKeyState(VK_CAPITAL) & 1); - FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS); } } @@ -547,7 +547,7 @@ void KeybToggleP8ACapsLock () { _ASSERT(g_Apple2Type == A2TYPE_PRAVETS8A); P8CAPS_ON = !P8CAPS_ON; - FrameRefreshStatus(DRAW_LEDS); + GetFrame().FrameRefreshStatus(DRAW_LEDS); // g_bP8CapsLock= g_bP8CapsLock?false:true; //The same as the upper, but slower } diff --git a/source/Memory.cpp b/source/Memory.cpp index 72bbf516..6640a844 100644 --- a/source/Memory.cpp +++ b/source/Memory.cpp @@ -1646,7 +1646,7 @@ void MemInitializeCustomF8ROM(void) } catch (bool) { - MessageBox( g_hFrameWindow, "Failed to read F8 (auto-start) ROM for language card in original Apple][", TEXT("AppleWin Error"), MB_OK ); + MessageBox( GetFrame().g_hFrameWindow, "Failed to read F8 (auto-start) ROM for language card in original Apple][", TEXT("AppleWin Error"), MB_OK ); } } @@ -1667,7 +1667,7 @@ void MemInitializeCustomF8ROM(void) if (!bRes) { - MessageBox( g_hFrameWindow, "Failed to read custom F8 rom", TEXT("AppleWin Error"), MB_OK ); + MessageBox( GetFrame().g_hFrameWindow, "Failed to read custom F8 rom", TEXT("AppleWin Error"), MB_OK ); CloseHandle(g_hCustomRomF8); g_hCustomRomF8 = INVALID_HANDLE_VALUE; // Failed, so use default rom... @@ -1723,7 +1723,7 @@ void MemInitializeCustomROM(void) if (!bRes) { - MessageBox( g_hFrameWindow, "Failed to read custom rom", TEXT("AppleWin Error"), MB_OK ); + MessageBox( GetFrame().g_hFrameWindow, "Failed to read custom rom", TEXT("AppleWin Error"), MB_OK ); CloseHandle(g_hCustomRom); g_hCustomRom = INVALID_HANDLE_VALUE; // Failed, so use default rom... diff --git a/source/MouseInterface.cpp b/source/MouseInterface.cpp index 1e3a025f..a5085523 100644 --- a/source/MouseInterface.cpp +++ b/source/MouseInterface.cpp @@ -588,7 +588,7 @@ void CMouseInterface::SetPositionAbs(int x, int y) { m_iX = x; m_iY = y; - FrameSetCursorPosByMousePos(); + GetFrame().FrameSetCursorPosByMousePos(); } void CMouseInterface::SetPositionRel(long dX, long dY, int* pOutOfBoundsX, int* pOutOfBoundsY) diff --git a/source/NTSC_CharSet.cpp b/source/NTSC_CharSet.cpp index 2c8b2b82..a19da5fd 100644 --- a/source/NTSC_CharSet.cpp +++ b/source/NTSC_CharSet.cpp @@ -77,7 +77,7 @@ static void get_csbits(csbits_t csbits, const char* resourceName, const UINT cy0 const UINT bufferSize = bitmapWidthBytes*bitmapHeight; BYTE* pBuffer = new BYTE [bufferSize]; - HBITMAP hCharBitmap = LoadBitmap(g_hInstance, resourceName); + HBITMAP hCharBitmap = LoadBitmap(GetFrame().g_hInstance, resourceName); GetBitmapBits(hCharBitmap, bufferSize, pBuffer); for (UINT cy=cy0, ch=0; cySetCooperativeLevel(g_hFrameWindow, DSSCL_NORMAL); + hr = g_lpDS->SetCooperativeLevel(GetFrame().g_hFrameWindow, DSSCL_NORMAL); if(FAILED(hr)) { if(g_fh) fprintf(g_fh, "SetCooperativeLevel failed (%08X)\n",hr); diff --git a/source/Speaker.cpp b/source/Speaker.cpp index 617e459e..ef68e96e 100644 --- a/source/Speaker.cpp +++ b/source/Speaker.cpp @@ -97,13 +97,13 @@ static void Spkr_DSUninit(); static void DisplayBenchmarkResults () { DWORD totaltime = GetTickCount()-extbench; - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); TCHAR buffer[64]; wsprintf(buffer, TEXT("This benchmark took %u.%02u seconds."), (unsigned)(totaltime / 1000), (unsigned)((totaltime / 10) % 100)); - MessageBox(g_hFrameWindow, + MessageBox(GetFrame().g_hFrameWindow, buffer, TEXT("Benchmark Results"), MB_ICONINFORMATION | MB_SETFOREGROUND); diff --git a/source/Utilities.cpp b/source/Utilities.cpp index 3f6bfd74..e9d56174 100644 --- a/source/Utilities.cpp +++ b/source/Utilities.cpp @@ -208,7 +208,7 @@ void LoadConfiguration(void) DWORD dwTmp = 0; if(REGLOAD(TEXT(REGVALUE_FS_SHOW_SUBUNIT_STATUS), &dwTmp)) - SetFullScreenShowSubunitStatus(dwTmp ? true : false); + GetFrame().SetFullScreenShowSubunitStatus(dwTmp ? true : false); if(REGLOAD(TEXT(REGVALUE_THE_FREEZES_F8_ROM), &dwTmp)) GetPropertySheet().SetTheFreezesF8Rom(dwTmp); @@ -313,10 +313,10 @@ void LoadConfiguration(void) Printer_SetIdleLimit(dwTmp); if (REGLOAD(TEXT(REGVALUE_WINDOW_SCALE), &dwTmp)) - SetViewportScale(dwTmp); + GetFrame().SetViewportScale(dwTmp); if (REGLOAD(TEXT(REGVALUE_CONFIRM_REBOOT), &dwTmp)) - g_bConfirmReboot = dwTmp; + GetFrame().g_bConfirmReboot = dwTmp; } static std::string GetFullPath(LPCSTR szFileName) @@ -403,7 +403,7 @@ void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], boo { bRes = DoDiskInsert(slot, DRIVE_1, szImageName_drive[DRIVE_1]); LogFileOutput("Init: S%d, DoDiskInsert(D1), res=%d\n", slot, bRes); - FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); // floppy activity LEDs and floppy buttons + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); // floppy activity LEDs and floppy buttons bBoot = true; } @@ -418,7 +418,7 @@ void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], boo } if (!bRes) - MessageBox(g_hFrameWindow, "Failed to insert floppy disk(s) - see log file", "Warning", MB_ICONASTERISK | MB_OK); + MessageBox(GetFrame().g_hFrameWindow, "Failed to insert floppy disk(s) - see log file", "Warning", MB_ICONASTERISK | MB_OK); } void InsertHardDisks(LPSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot) @@ -443,7 +443,7 @@ void InsertHardDisks(LPSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot) { bRes = DoHardDiskInsert(HARDDISK_1, szImageName_harddisk[HARDDISK_1]); LogFileOutput("Init: DoHardDiskInsert(HDD1), res=%d\n", bRes); - FrameRefreshStatus(DRAW_LEDS); // harddisk activity LED + GetFrame().FrameRefreshStatus(DRAW_LEDS); // harddisk activity LED bBoot = true; } @@ -454,7 +454,7 @@ void InsertHardDisks(LPSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot) } if (!bRes) - MessageBox(g_hFrameWindow, "Failed to insert harddisk(s) - see log file", "Warning", MB_ICONASTERISK | MB_OK); + MessageBox(GetFrame().g_hFrameWindow, "Failed to insert harddisk(s) - see log file", "Warning", MB_ICONASTERISK | MB_OK); } void UnplugHardDiskControllerCard(void) @@ -593,5 +593,5 @@ void CtrlReset() #endif CpuReset(); - g_bFreshReset = true; + GetFrame().g_bFreshReset = true; } diff --git a/source/Video.cpp b/source/Video.cpp index 68e69c23..dee05601 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -476,7 +476,7 @@ void Video_TakeScreenShot( const VideoScreenShot_e ScreenShotType ) { TCHAR msg[512]; StringCbPrintf( msg, 512, "You have more then %d screenshot filenames! They will no longer be saved.\n\nEither move some of your screenshots or increase the maximum in video.cpp\n", nMaxScreenShot ); - MessageBox( g_hFrameWindow, msg, "Warning", MB_OK ); + MessageBox( GetFrame().g_hFrameWindow, msg, "Warning", MB_OK ); g_nLastScreenShot = 0; return; } @@ -574,9 +574,9 @@ static void Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShot // char sText[256]; // sprintf( sText, "sizeof: BITMAPFILEHEADER = %d\n", sizeof(BITMAPFILEHEADER) ); // = 14 -// MessageBox( g_hFrameWindow, sText, "Info 1", MB_OK ); +// MessageBox( GetFrame().g_hFrameWindow, sText, "Info 1", MB_OK ); // sprintf( sText, "sizeof: BITMAPINFOHEADER = %d\n", sizeof(BITMAPINFOHEADER) ); // = 40 -// MessageBox( g_hFrameWindow, sText, "Info 2", MB_OK ); +// MessageBox( GetFrame().g_hFrameWindow, sText, "Info 2", MB_OK ); char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[ sizeof( WinBmpHeader_t ) == (14 + 40) ]; /**/ sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[0]=0; @@ -661,7 +661,7 @@ void Video_SaveScreenShot( const VideoScreenShot_e ScreenShotType, const TCHAR * if( g_bDisplayPrintScreenFileName ) { - MessageBox( g_hFrameWindow, pScreenShotFileName, "Screen Captured", MB_OK ); + MessageBox( GetFrame().g_hFrameWindow, pScreenShotFileName, "Screen Captured", MB_OK ); } } diff --git a/source/Windows/AppleWin.cpp b/source/Windows/AppleWin.cpp index ca3ae324..d881890d 100644 --- a/source/Windows/AppleWin.cpp +++ b/source/Windows/AppleWin.cpp @@ -47,6 +47,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "Speech.h" #endif #include "Windows/WinVideo.h" +#include "Windows/Win32Frame.h" #include "Windows/WinFrame.h" #include "RGBMonitor.h" #include "NTSC.h" @@ -57,9 +58,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //================================================= -// Win32 -HINSTANCE g_hInstance = (HINSTANCE)0; - static bool g_bLoadedSaveState = false; static bool g_bSysClkOK = false; @@ -72,7 +70,7 @@ bool GetLoadedSaveStateFlag(void) return g_bLoadedSaveState; } -void SetLoadedSaveStateFlag(const bool bFlag) +void Win32Frame::SetLoadedSaveStateFlag(const bool bFlag) { g_bLoadedSaveState = bFlag; } @@ -85,7 +83,7 @@ bool GetHookAltGrControl(void) static void ResetToLogoMode(void) { g_nAppMode = MODE_LOGO; - SetLoadedSaveStateFlag(false); + GetFrame().SetLoadedSaveStateFlag(false); } //--------------------------------------------------------------------------- @@ -453,21 +451,21 @@ static void RegisterHotKeys(void) BOOL bStatus[3] = {0,0,0}; bStatus[0] = RegisterHotKey( - g_hFrameWindow , // HWND hWnd + GetFrame().g_hFrameWindow , // HWND hWnd VK_SNAPSHOT_560, // int id (user/custom id) 0 , // UINT fsModifiers VK_SNAPSHOT // UINT vk = PrintScreen ); bStatus[1] = RegisterHotKey( - g_hFrameWindow , // HWND hWnd + GetFrame().g_hFrameWindow , // HWND hWnd VK_SNAPSHOT_280, // int id (user/custom id) MOD_SHIFT , // UINT fsModifiers VK_SNAPSHOT // UINT vk = PrintScreen ); bStatus[2] = RegisterHotKey( - g_hFrameWindow , // HWND hWnd + GetFrame().g_hFrameWindow , // HWND hWnd VK_SNAPSHOT_TEXT, // int id (user/custom id) MOD_CONTROL , // UINT fsModifiers VK_SNAPSHOT // UINT vk = PrintScreen @@ -485,7 +483,7 @@ static void RegisterHotKeys(void) msg += "\n. Ctrl+PrintScreen"; if (g_bShowPrintScreenWarningDialog) - MessageBox( g_hFrameWindow, msg.c_str(), "Warning", MB_ICONASTERISK | MB_OK ); + MessageBox( GetFrame().g_hFrameWindow, msg.c_str(), "Warning", MB_ICONASTERISK | MB_OK ); msg += "\n"; LogFileOutput(msg.c_str()); @@ -505,12 +503,12 @@ static bool HookFilterForKeyboard() { g_hinstDLL = LoadLibrary(TEXT("HookFilter.dll")); - _ASSERT(g_hFrameWindow); + _ASSERT(GetFrame().g_hFrameWindow); typedef void (*RegisterHWNDProc)(HWND, bool, bool); RegisterHWNDProc RegisterHWND = (RegisterHWNDProc) GetProcAddress(g_hinstDLL, "RegisterHWND"); if (RegisterHWND) - RegisterHWND(g_hFrameWindow, g_bHookAltTab, g_bHookAltGrControl); + RegisterHWND(GetFrame().g_hFrameWindow, g_bHookAltTab, g_bHookAltGrControl); HOOKPROC hkprcLowLevelKeyboardProc = (HOOKPROC) GetProcAddress(g_hinstDLL, "LowLevelKeyboardProc"); @@ -520,7 +518,7 @@ static bool HookFilterForKeyboard() g_hinstDLL, 0); - if (g_hhook != 0 && g_hFrameWindow != 0) + if (g_hhook != 0 && GetFrame().g_hFrameWindow != 0) return true; std::string msg("Failed to install hook filter for system keys"); @@ -603,7 +601,7 @@ static void UninitHookThread() static void ExceptionHandler(const char* pError) { - MessageBox( g_hFrameWindow, + MessageBox( GetFrame().g_hFrameWindow, pError, TEXT("Runtime Exception"), MB_ICONEXCLAMATION | MB_SETFOREGROUND); @@ -760,7 +758,7 @@ static void OneTimeInitialization(HINSTANCE passinstance) DDInit(); // For WaitForVerticalBlank() #endif - g_hInstance = passinstance; + GetFrame().g_hInstance = passinstance; GdiSetBatchLimit(512); LogFileOutput("Init: GdiSetBatchLimit()\n"); @@ -848,7 +846,7 @@ static void RepeatInitialization(void) LogFileOutput("Main: VideoInitialize()\n"); LogFileOutput("Main: FrameCreateWindow() - pre\n"); - FrameCreateWindow(); // g_hFrameWindow is now valid + FrameCreateWindow(); // GetFrame().g_hFrameWindow is now valid LogFileOutput("Main: FrameCreateWindow() - post\n"); // Init palette color @@ -936,7 +934,7 @@ static void RepeatInitialization(void) if (!g_bSysClkOK) { - MessageBox(g_hFrameWindow, "DirectX failed to create SystemClock instance", TEXT("AppleWin Error"), MB_OK); + MessageBox(GetFrame().g_hFrameWindow, "DirectX failed to create SystemClock instance", TEXT("AppleWin Error"), MB_OK); g_cmdLine.bShutdown = true; } @@ -947,7 +945,7 @@ static void RepeatInitialization(void) : "Unsupported -rom and -f8rom being used at the same time\n"; LogFileOutput("%s", msg.c_str()); - MessageBox(g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK); + MessageBox(GetFrame().g_hFrameWindow, msg.c_str(), TEXT("AppleWin Error"), MB_OK); g_cmdLine.bShutdown = true; } @@ -985,7 +983,7 @@ static void RepeatInitialization(void) if (g_cmdLine.bShutdown) { - PostMessage(g_hFrameWindow, WM_DESTROY, 0, 0); // Close everything down + PostMessage(GetFrame().g_hFrameWindow, WM_DESTROY, 0, 0); // Close everything down // NB. If shutting down, then don't post any other messages (GH#286) } else @@ -1007,13 +1005,13 @@ static void RepeatInitialization(void) if (g_cmdLine.bSetFullScreen) { - PostMessage(g_hFrameWindow, WM_USER_FULLSCREEN, 0, 0); + PostMessage(GetFrame().g_hFrameWindow, WM_USER_FULLSCREEN, 0, 0); g_cmdLine.bSetFullScreen = false; } if (g_cmdLine.bBoot) { - PostMessage(g_hFrameWindow, WM_USER_BOOT, 0, 0); + PostMessage(GetFrame().g_hFrameWindow, WM_USER_BOOT, 0, 0); g_cmdLine.bBoot = false; } } @@ -1054,3 +1052,9 @@ IPropertySheet& GetPropertySheet() static CPropertySheet sg_PropertySheet; return sg_PropertySheet; } + +FrameBase& GetFrame() +{ + static Win32Frame sg_Win32Frame; + return sg_Win32Frame; +} diff --git a/source/Windows/Win32Frame.cpp b/source/Windows/Win32Frame.cpp new file mode 100644 index 00000000..0545b7af --- /dev/null +++ b/source/Windows/Win32Frame.cpp @@ -0,0 +1,6 @@ +#include "StdAfx.h" + +#include "Windows/Win32Frame.h" + +// Win32Frame methods are implemented in AppleWin, WinFrame and WinVideo. +// in time they should be brought together and more freestanding functions added to Win32Frame. diff --git a/source/Windows/Win32Frame.h b/source/Windows/Win32Frame.h new file mode 100644 index 00000000..8c978ffa --- /dev/null +++ b/source/Windows/Win32Frame.h @@ -0,0 +1,21 @@ +#pragma once + +#include "FrameBase.h" + +class Win32Frame : public FrameBase +{ +public: + virtual void FrameDrawDiskLEDS(HDC hdc); + virtual void FrameDrawDiskStatus(HDC hdc); + virtual void FrameRefreshStatus(int, bool bUpdateDiskStatus = true); + virtual void FrameUpdateApple2Type(); + virtual void FrameSetCursorPosByMousePos(); + + virtual void VideoRedrawScreen(); + virtual void SetFullScreenShowSubunitStatus(bool bShow); + virtual bool GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& bestHeight, UINT userSpecifiedHeight = 0); + virtual int SetViewportScale(int nNewScale, bool bForce = false); + virtual void SetAltEnterToggleFullScreen(bool mode); + + virtual void SetLoadedSaveStateFlag(const bool bFlag); +}; diff --git a/source/Windows/WinFrame.cpp b/source/Windows/WinFrame.cpp index 03bed907..db841d72 100644 --- a/source/Windows/WinFrame.cpp +++ b/source/Windows/WinFrame.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "StdAfx.h" #include "Windows/WinFrame.h" +#include "Windows/Win32Frame.h" #include "Windows/AppleWin.h" #include "Interface.h" #include "Keyboard.h" @@ -119,10 +120,7 @@ static int buttony = BUTTONY; static HDC g_hFrameDC = (HDC)0; static RECT framerect = {0,0,0,0}; - HWND g_hFrameWindow = (HWND)0; static bool g_bIsFullScreen = false; - BOOL g_bConfirmReboot = 1; // saved PageConfig REGSAVE - BOOL g_bMultiMon = 0; // OFF = load window position & clamp initial frame to screen, ON = use window position as is static BOOL helpquit = 0; static HFONT smallfont = (HFONT)0; @@ -147,7 +145,6 @@ static void SetUsingCursor(BOOL); static bool FileExists(std::string strFilename); bool g_bScrollLock_FullSpeed = false; -bool g_bFreshReset = false; static bool g_bFullScreen32Bit = true; #if 0 // enable non-integral full-screen scaling @@ -179,7 +176,7 @@ void FrameResizeWindow(int nNewScale); static bool g_bAltEnter_ToggleFullScreen = true; // Default for ALT+ENTER is to toggle between windowed and full-screen modes -void SetAltEnterToggleFullScreen(bool mode) +void Win32Frame::SetAltEnterToggleFullScreen(bool mode) { g_bAltEnter_ToggleFullScreen = mode; } @@ -277,7 +274,7 @@ static void FullScreenRevealCursor(void) //=========================================================================== -#define LOADBUTTONBITMAP(bitmapname) LoadImage(g_hInstance,bitmapname, \ +#define LOADBUTTONBITMAP(bitmapname) LoadImage(GetFrame().g_hInstance,bitmapname, \ IMAGE_BITMAP,0,0, \ LR_CREATEDIBSECTION | \ LR_LOADMAP3DCOLORS | \ @@ -404,7 +401,7 @@ static void DrawBitmapRect (HDC dc, int x, int y, LPRECT rect, HBITMAP bitmap) { //=========================================================================== static void DrawButton (HDC passdc, int number) { FrameReleaseDC(); - HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); + HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow)); int x = buttonx; int y = buttony+number*BUTTONCY; if (number == buttondown) { @@ -441,7 +438,7 @@ static void DrawButton (HDC passdc, int number) { NULL); } if (!passdc) - ReleaseDC(g_hFrameWindow,dc); + ReleaseDC(GetFrame().g_hFrameWindow,dc); } //=========================================================================== @@ -451,7 +448,7 @@ static void DrawCrosshairs (int x, int y) { static int lastx = 0; static int lasty = 0; FrameReleaseDC(); - HDC dc = GetDC(g_hFrameWindow); + HDC dc = GetDC(GetFrame().g_hFrameWindow); #define LINE(x1,y1,x2,y2) MoveToEx(dc,x1,y1,NULL); LineTo(dc,x2,y2); // ERASE THE OLD CROSSHAIRS @@ -536,7 +533,7 @@ static void DrawCrosshairs (int x, int y) { #undef LINE lastx = x; lasty = y; - ReleaseDC(g_hFrameWindow,dc); + ReleaseDC(GetFrame().g_hFrameWindow,dc); } //=========================================================================== @@ -546,8 +543,8 @@ static void DrawFrameWindow (bool bPaintingWindow/*=false*/) FrameReleaseDC(); PAINTSTRUCT ps; HDC dc = bPaintingWindow - ? BeginPaint(g_hFrameWindow,&ps) - : GetDC(g_hFrameWindow); + ? BeginPaint(GetFrame().g_hFrameWindow,&ps) + : GetDC(GetFrame().g_hFrameWindow); if (!g_bIsFullScreen) { @@ -593,12 +590,12 @@ static void DrawFrameWindow (bool bPaintingWindow/*=false*/) else if (g_nAppMode == MODE_DEBUG) DebugDisplay(); else - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); if (bPaintingWindow) - EndPaint(g_hFrameWindow,&ps); + EndPaint(GetFrame().g_hFrameWindow,&ps); else - ReleaseDC(g_hFrameWindow,dc); + ReleaseDC(GetFrame().g_hFrameWindow,dc); } @@ -615,13 +612,13 @@ bool GetFullScreenShowSubunitStatus(void) return g_bFullScreen_ShowSubunitStatus; } -void SetFullScreenShowSubunitStatus(bool bShow) +void Win32Frame::SetFullScreenShowSubunitStatus(bool bShow) { g_bFullScreen_ShowSubunitStatus = bShow; } //=========================================================================== -void FrameDrawDiskLEDS( HDC passdc ) +void Win32Frame::FrameDrawDiskLEDS( HDC passdc ) { g_eStatusDrive1 = DISK_STATUS_OFF; g_eStatusDrive2 = DISK_STATUS_OFF; @@ -643,7 +640,7 @@ void FrameDrawDiskLEDS( HDC passdc ) // Draw Track/Sector FrameReleaseDC(); - HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); + HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow)); int x = buttonx; int y = buttony+BUTTONS*BUTTONCY+1; @@ -675,7 +672,7 @@ void FrameDrawDiskLEDS( HDC passdc ) // Feature Request #201 Show track status // https://github.com/AppleWin/AppleWin/issues/201 //=========================================================================== -void FrameDrawDiskStatus( HDC passdc ) +void Win32Frame::FrameDrawDiskStatus( HDC passdc ) { if (mem == NULL) return; @@ -767,7 +764,7 @@ void FrameDrawDiskStatus( HDC passdc ) // Draw Track/Sector FrameReleaseDC(); - HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); + HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow)); int x = buttonx; int y = buttony+BUTTONS*BUTTONCY+4; @@ -830,16 +827,16 @@ void FrameDrawDiskStatus( HDC passdc ) //=========================================================================== static void DrawStatusArea (HDC passdc, int drawflags) { - if (g_hFrameWindow == NULL) + if (GetFrame().g_hFrameWindow == NULL) { // TC: Fix drawing of drive buttons before frame created: // . Main init loop: LoadConfiguration() called before FrameCreateWindow(), eg: - // LoadConfiguration() -> Disk_LoadLastDiskImage() -> DiskInsert() -> FrameRefreshStatus() + // LoadConfiguration() -> Disk_LoadLastDiskImage() -> DiskInsert() -> GetFrame().FrameRefreshStatus() return; } FrameReleaseDC(); - HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); + HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow)); int x = buttonx; int y = buttony+BUTTONS*BUTTONCY+1; const bool bCaps = KeybGetCapsStatus(); @@ -864,7 +861,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) SelectObject(dc,smallfont); if (drawflags & DRAW_DISK_STATUS) - FrameDrawDiskStatus( dc ); + GetFrame().FrameDrawDiskStatus( dc ); #if HD_LED SetTextAlign(dc, TA_RIGHT | TA_TOP); @@ -931,10 +928,10 @@ static void DrawStatusArea (HDC passdc, int drawflags) if (drawflags & DRAW_LEDS) { - FrameDrawDiskLEDS( dc ); + GetFrame().FrameDrawDiskLEDS( dc ); if (drawflags & DRAW_DISK_STATUS) - FrameDrawDiskStatus( dc ); + GetFrame().FrameDrawDiskStatus( dc ); if (!IS_APPLE2) { @@ -962,7 +959,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) if (drawflags & DRAW_TITLE) { GetAppleWindowTitle(); // SetWindowText() // WindowTitle - SendMessage(g_hFrameWindow,WM_SETTEXT,0,(LPARAM)g_pAppTitle.c_str()); + SendMessage(GetFrame().g_hFrameWindow,WM_SETTEXT,0,(LPARAM)g_pAppTitle.c_str()); } if (drawflags & DRAW_BUTTON_DRIVES) @@ -973,7 +970,7 @@ static void DrawStatusArea (HDC passdc, int drawflags) } if (!passdc) - ReleaseDC(g_hFrameWindow,dc); + ReleaseDC(GetFrame().g_hFrameWindow,dc); } //=========================================================================== @@ -984,7 +981,7 @@ static void EraseButton (int number) { rect.top = buttony+number*BUTTONCY; rect.bottom = rect.top+BUTTONCY; - InvalidateRect(g_hFrameWindow,&rect,1); + InvalidateRect(GetFrame().g_hFrameWindow,&rect,1); } //=========================================================================== @@ -1044,7 +1041,7 @@ LRESULT CALLBACK FrameWndProc ( } if (g_TimerIDEvent_100msec) { - BOOL bRes = KillTimer(g_hFrameWindow, g_TimerIDEvent_100msec); + BOOL bRes = KillTimer(GetFrame().g_hFrameWindow, g_TimerIDEvent_100msec); LogFileOutput("KillTimer(g_TimerIDEvent_100msec), res=%d\n", bRes ? 1 : 0); g_TimerIDEvent_100msec = 0; } @@ -1078,7 +1075,7 @@ LRESULT CALLBACK FrameWndProc ( case WM_CREATE: LogFileOutput("WM_CREATE\n"); - g_hFrameWindow = window; // NB. g_hFrameWindow by CreateWindow() + GetFrame().g_hFrameWindow = window; // NB. g_hFrameWindow by CreateWindow() CreateGdiObjects(); LogFileOutput("WM_CREATE: CreateGdiObjects()\n"); @@ -1191,7 +1188,7 @@ LRESULT CALLBACK FrameWndProc ( if (wparam == VK_SNAPSHOT_560) { #if _DEBUG -// MessageBox( g_hFrameWindow, "Double 580x384 size!", "PrintScreen", MB_OK ); +// MessageBox( GetFrame().g_hFrameWindow, "Double 580x384 size!", "PrintScreen", MB_OK ); #endif Video_TakeScreenShot( SCREENSHOT_560x384 ); } @@ -1199,7 +1196,7 @@ LRESULT CALLBACK FrameWndProc ( if (wparam == VK_SNAPSHOT_280) // ( lparam & MOD_SHIFT ) { #if _DEBUG -// MessageBox( g_hFrameWindow, "Normal 280x192 size!", "PrintScreen", MB_OK ); +// MessageBox( GetFrame().g_hFrameWindow, "Normal 280x192 size!", "PrintScreen", MB_OK ); #endif Video_TakeScreenShot( SCREENSHOT_280x192 ); } @@ -1336,7 +1333,7 @@ LRESULT CALLBACK FrameWndProc ( } DrawStatusArea((HDC)0,DRAW_TITLE); if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); } else if ((wparam == VK_SCROLL) && GetPropertySheet().GetScrollLockToggle()) { @@ -1440,7 +1437,7 @@ LRESULT CALLBACK FrameWndProc ( const int iDrive = wparam - VK_F3; ProcessDiskPopupMenu( window, pt, iDrive ); - FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); DrawButton((HDC)0, iButton); } else @@ -1511,7 +1508,7 @@ LRESULT CALLBACK FrameWndProc ( POINT Point; GetCursorPos(&Point); - ScreenToClient(g_hFrameWindow, &Point); + ScreenToClient(GetFrame().g_hFrameWindow, &Point); const int iOutOfBoundsX=0, iOutOfBoundsY=0; UpdateMouseInAppleViewport(iOutOfBoundsX, iOutOfBoundsY, Point.x, Point.y); @@ -1748,7 +1745,7 @@ LRESULT CALLBACK FrameWndProc ( ProcessDiskPopupMenu( window, pt, iDrive ); } - FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); + GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); DrawButton((HDC)0, iButton); } } @@ -1941,10 +1938,10 @@ static void ScreenWindowResize(const bool bCtrlKey) static bool ConfirmReboot(bool bFromButtonUI) { - if (!bFromButtonUI || !g_bConfirmReboot) + if (!bFromButtonUI || !GetFrame().g_bConfirmReboot) return true; - int res = MessageBox(g_hFrameWindow, + int res = MessageBox(GetFrame().g_hFrameWindow, "Are you sure you want to reboot?\n" "(All data will be lost!)\n" "\n" @@ -1982,7 +1979,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) DeleteFile(filename_with_zone_identifier.c_str()); } - HtmlHelp(g_hFrameWindow,filename.c_str(),HH_DISPLAY_TOC,0); + HtmlHelp(GetFrame().g_hFrameWindow,filename.c_str(),HH_DISPLAY_TOC,0); helpquit = 1; } break; @@ -2019,7 +2016,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/) } DrawStatusArea((HDC)0,DRAW_TITLE); - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); break; case BTN_DRIVE1: @@ -2116,7 +2113,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) // Load the menu template containing the shortcut menu from the // application's resources. - HMENU hmenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(IDR_MENU_DISK_POPUP)); // menu template + HMENU hmenu = LoadMenu(GetFrame().g_hInstance, MAKEINTRESOURCE(IDR_MENU_DISK_POPUP)); // menu template if (hmenu == NULL) return; @@ -2176,7 +2173,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) //if(!filename1.compare("\"\"") == false) //Do not use this, for some reason it does not work!!! if(!filename1.compare(sFileNameEmpty) ) { - int MB_Result = MessageBox(g_hFrameWindow, "No disk image loaded. Do you want to run CiderPress anyway?" ,"No disk image.", MB_ICONINFORMATION|MB_YESNO); + int MB_Result = MessageBox(GetFrame().g_hFrameWindow, "No disk image loaded. Do you want to run CiderPress anyway?" ,"No disk image.", MB_ICONINFORMATION|MB_YESNO); if (MB_Result == IDYES) { if (FileExists (PathToCiderPress )) @@ -2185,7 +2182,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) } else { - MessageBox(g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); + MessageBox(GetFrame().g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); } } } @@ -2197,7 +2194,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) } else { - MessageBox(g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); + MessageBox(GetFrame().g_hFrameWindow, szCiderpressNotFoundText, szCiderpressNotFoundCaption, MB_ICONINFORMATION|MB_OK); } } } @@ -2213,7 +2210,7 @@ void RelayEvent (UINT message, WPARAM wparam, LPARAM lparam) { if (g_bIsFullScreen) return; MSG msg; - msg.hwnd = g_hFrameWindow; + msg.hwnd = GetFrame().g_hFrameWindow; msg.message = message; msg.wParam = wparam; msg.lParam = lparam; @@ -2247,14 +2244,14 @@ void SetFullScreenMode () buttonover = -1; - g_main_window_saved_style = GetWindowLong(g_hFrameWindow, GWL_STYLE); - g_main_window_saved_exstyle = GetWindowLong(g_hFrameWindow, GWL_EXSTYLE); - GetWindowRect(g_hFrameWindow, &g_main_window_saved_rect); - SetWindowLong(g_hFrameWindow, GWL_STYLE , g_main_window_saved_style & ~(WS_CAPTION | WS_THICKFRAME)); - SetWindowLong(g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); + g_main_window_saved_style = GetWindowLong(GetFrame().g_hFrameWindow, GWL_STYLE); + g_main_window_saved_exstyle = GetWindowLong(GetFrame().g_hFrameWindow, GWL_EXSTYLE); + GetWindowRect(GetFrame().g_hFrameWindow, &g_main_window_saved_rect); + SetWindowLong(GetFrame().g_hFrameWindow, GWL_STYLE , g_main_window_saved_style & ~(WS_CAPTION | WS_THICKFRAME)); + SetWindowLong(GetFrame().g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle & ~(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE)); monitor_info.cbSize = sizeof(monitor_info); - GetMonitorInfo(MonitorFromWindow(g_hFrameWindow, MONITOR_DEFAULTTONEAREST), &monitor_info); + GetMonitorInfo(MonitorFromWindow(GetFrame().g_hFrameWindow, MONITOR_DEFAULTTONEAREST), &monitor_info); left = monitor_info.rcMonitor.left; top = monitor_info.rcMonitor.top; @@ -2268,17 +2265,17 @@ void SetFullScreenMode () g_win_fullscreen_scale = (scalex <= scaley) ? scalex : scaley; g_win_fullscreen_offsetx = ((int)width - (int)(g_win_fullscreen_scale * GetFrameBufferBorderlessWidth())) / 2; g_win_fullscreen_offsety = ((int)height - (int)(g_win_fullscreen_scale * GetFrameBufferBorderlessHeight())) / 2; - SetWindowPos(g_hFrameWindow, NULL, left, top, (int)width, (int)height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); + SetWindowPos(GetFrame().g_hFrameWindow, NULL, left, top, (int)width, (int)height, SWP_NOZORDER | SWP_NOACTIVATE | SWP_FRAMECHANGED); g_bIsFullScreen = true; - SetViewportScale(g_win_fullscreen_scale, true); + GetFrame().SetViewportScale(g_win_fullscreen_scale, true); buttonx = GetFullScreenOffsetX() + g_nViewportCX + VIEWPORTX*2; buttony = GetFullScreenOffsetY(); viewportx = VIEWPORTX; // TC-TODO: Should be zero too? (Since there's no 3D border in full-screen) viewporty = 0; // GH#464 - InvalidateRect(g_hFrameWindow,NULL,1); + InvalidateRect(GetFrame().g_hFrameWindow,NULL,1); #endif // NO_DIRECT_X } @@ -2297,9 +2294,9 @@ void SetNormalMode () g_win_fullscreen_offsetx = 0; g_win_fullscreen_offsety = 0; g_win_fullscreen_scale = 1; - SetWindowLong(g_hFrameWindow, GWL_STYLE, g_main_window_saved_style); - SetWindowLong(g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle); - SetWindowPos(g_hFrameWindow, NULL, + SetWindowLong(GetFrame().g_hFrameWindow, GWL_STYLE, g_main_window_saved_style); + SetWindowLong(GetFrame().g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle); + SetWindowPos(GetFrame().g_hFrameWindow, NULL, g_main_window_saved_rect.left, g_main_window_saved_rect.top, g_main_window_saved_rect.right - g_main_window_saved_rect.left, @@ -2321,18 +2318,18 @@ static void SetUsingCursor (BOOL bNewValue) // Set TRUE when: // . Using mouse for joystick emulation // . Using mousecard and mouse is restricted to window - SetCapture(g_hFrameWindow); + SetCapture(GetFrame().g_hFrameWindow); RECT rect = { viewportx+2, // left viewporty+2, // top viewportx+g_nViewportCX-1, // right viewporty+g_nViewportCY-1}; // bottom - ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.left); - ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.right); + ClientToScreen(GetFrame().g_hFrameWindow,(LPPOINT)&rect.left); + ClientToScreen(GetFrame().g_hFrameWindow,(LPPOINT)&rect.right); ClipCursor(&rect); FrameShowCursor(FALSE); POINT pt; GetCursorPos(&pt); - ScreenToClient(g_hFrameWindow,&pt); + ScreenToClient(GetFrame().g_hFrameWindow,&pt); DrawCrosshairs(pt.x,pt.y); } else @@ -2349,7 +2346,7 @@ int GetViewportScale(void) return g_nViewportScale; } -int SetViewportScale(int nNewScale, bool bForce /*=false*/) +int Win32Frame::SetViewportScale(int nNewScale, bool bForce /*=false*/) { if (!bForce && nNewScale > g_nMaxViewportScale) nNewScale = g_nMaxViewportScale; @@ -2366,8 +2363,8 @@ static void SetupTooltipControls(void) TOOLINFO toolinfo; toolinfo.cbSize = sizeof(toolinfo); toolinfo.uFlags = TTF_CENTERTIP; - toolinfo.hwnd = g_hFrameWindow; - toolinfo.hinst = g_hInstance; + toolinfo.hwnd = GetFrame().g_hFrameWindow; + toolinfo.hinst = GetFrame().g_hInstance; toolinfo.lpszText = LPSTR_TEXTCALLBACK; toolinfo.rect.left = BUTTONX; toolinfo.rect.right = toolinfo.rect.left+BUTTONCX+1; @@ -2417,9 +2414,9 @@ static void FrameResizeWindow(int nNewScale) int nOldWidth, nOldHeight; GetWidthHeight(nOldWidth, nOldHeight); - nNewScale = SetViewportScale(nNewScale); + nNewScale = GetFrame().SetViewportScale(nNewScale); - GetWindowRect(g_hFrameWindow, &framerect); + GetWindowRect(GetFrame().g_hFrameWindow, &framerect); int nXPos = framerect.left; int nYPos = framerect.top; @@ -2434,20 +2431,20 @@ static void FrameResizeWindow(int nNewScale) irect.left = irect.top = 0; irect.right = nOldWidth; irect.bottom = nOldHeight; - InvalidateRect(g_hFrameWindow, &irect, TRUE); + InvalidateRect(GetFrame().g_hFrameWindow, &irect, TRUE); } // Resize the window int nNewWidth, nNewHeight; GetWidthHeight(nNewWidth, nNewHeight); - MoveWindow(g_hFrameWindow, nXPos, nYPos, nNewWidth, nNewHeight, TRUE); - UpdateWindow(g_hFrameWindow); + MoveWindow(GetFrame().g_hFrameWindow, nXPos, nYPos, nNewWidth, nNewHeight, TRUE); + UpdateWindow(GetFrame().g_hFrameWindow); // Remove the tooltips for the old window size TOOLINFO toolinfo = {0}; toolinfo.cbSize = sizeof(toolinfo); - toolinfo.hwnd = g_hFrameWindow; + toolinfo.hwnd = GetFrame().g_hFrameWindow; toolinfo.uId = 0; SendMessage(tooltipwindow, TTM_DELTOOL, 0, (LPARAM)&toolinfo); toolinfo.uId = 1; @@ -2489,7 +2486,7 @@ void FrameCreateWindow(void) if (g_nViewportScale == 2 && (nWidth > GetSystemMetrics(SM_CXSCREEN) || nHeight > GetSystemMetrics(SM_CYSCREEN))) { g_nMaxViewportScale = 1; - SetViewportScale(1); + GetFrame().SetViewportScale(1); GetWidthHeight(nWidth, nHeight); } @@ -2500,11 +2497,11 @@ void FrameCreateWindow(void) if (RegLoadValue(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_WINDOW_X_POS), 1, (DWORD*)&nXPos)) { - if ((nXPos > nXScreen) && !g_bMultiMon) + if ((nXPos > nXScreen) && !GetFrame().g_bMultiMon) nXPos = -1; // Not fully visible, so default to centre position } - if ((nXPos == -1) && !g_bMultiMon) + if ((nXPos == -1) && !GetFrame().g_bMultiMon) nXPos = nXScreen / 2; } @@ -2515,11 +2512,11 @@ void FrameCreateWindow(void) if (RegLoadValue(TEXT(REG_PREFS), TEXT(REGVALUE_PREF_WINDOW_Y_POS), 1, (DWORD*)&nYPos)) { - if ((nYPos > nYScreen) && !g_bMultiMon) + if ((nYPos > nYScreen) && !GetFrame().g_bMultiMon) nYPos = -1; // Not fully visible, so default to centre position } - if ((nYPos == -1) && !g_bMultiMon) + if ((nYPos == -1) && !GetFrame().g_bMultiMon) nYPos = nYScreen / 2; } @@ -2531,7 +2528,7 @@ void FrameCreateWindow(void) GetAppleWindowTitle(); // NB. g_hFrameWindow also set by WM_CREATE - NB. CreateWindow() must synchronously send WM_CREATE - g_hFrameWindow = CreateWindow( + GetFrame().g_hFrameWindow = CreateWindow( TEXT("APPLE2FRAME"), g_pAppTitle.c_str(), WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | @@ -2539,27 +2536,27 @@ void FrameCreateWindow(void) nXPos, nYPos, nWidth, nHeight, HWND_DESKTOP, (HMENU)0, - g_hInstance, NULL ); + GetFrame().g_hInstance, NULL ); InitCommonControls(); tooltipwindow = CreateWindow( TOOLTIPS_CLASS,NULL,TTS_ALWAYSTIP, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, - g_hFrameWindow, + GetFrame().g_hFrameWindow, (HMENU)0, - g_hInstance,NULL ); + GetFrame().g_hInstance,NULL ); SetupTooltipControls(); _ASSERT(g_TimerIDEvent_100msec == 0); - g_TimerIDEvent_100msec = SetTimer(g_hFrameWindow, IDEVENT_TIMER_100MSEC, 100, NULL); + g_TimerIDEvent_100msec = SetTimer(GetFrame().g_hFrameWindow, IDEVENT_TIMER_100MSEC, 100, NULL); LogFileOutput("FrameCreateWindow: SetTimer(), id=0x%08X\n", g_TimerIDEvent_100msec); } //=========================================================================== HDC FrameGetDC () { if (!g_hFrameDC) { - g_hFrameDC = GetDC(g_hFrameWindow); + g_hFrameDC = GetDC(GetFrame().g_hFrameWindow); SetViewportOrgEx(g_hFrameDC,viewportx,viewporty,NULL); } return g_hFrameDC; @@ -2569,13 +2566,13 @@ HDC FrameGetDC () { void FrameReleaseDC () { if (g_hFrameDC) { SetViewportOrgEx(g_hFrameDC,0,0,NULL); - ReleaseDC(g_hFrameWindow,g_hFrameDC); + ReleaseDC(GetFrame().g_hFrameWindow,g_hFrameDC); g_hFrameDC = (HDC)0; } } //=========================================================================== -void FrameRefreshStatus (int drawflags, bool bUpdateDiskStatus) { +void Win32Frame::FrameRefreshStatus (int drawflags, bool bUpdateDiskStatus) { // NB. 99% of the time we draw the disk status. On DiskDriveSwap() we don't. drawflags |= bUpdateDiskStatus ? DRAW_DISK_STATUS : 0; DrawStatusArea((HDC)0,drawflags); @@ -2588,15 +2585,15 @@ void FrameRegisterClass () { wndclass.cbSize = sizeof(WNDCLASSEX); wndclass.style = CS_OWNDC | CS_BYTEALIGNCLIENT; wndclass.lpfnWndProc = FrameWndProc; - wndclass.hInstance = g_hInstance; - wndclass.hIcon = LoadIcon(g_hInstance,TEXT("APPLEWIN_ICON")); + wndclass.hInstance = GetFrame().g_hInstance; + wndclass.hIcon = LoadIcon(GetFrame().g_hInstance,TEXT("APPLEWIN_ICON")); wndclass.hCursor = LoadCursor(0,IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); #if ENABLE_MENU wndclass.lpszMenuName = (LPCSTR)IDR_MENU1; #endif wndclass.lpszClassName = TEXT("APPLE2FRAME"); - wndclass.hIconSm = (HICON)LoadImage(g_hInstance,TEXT("APPLEWIN_ICON"), + wndclass.hIconSm = (HICON)LoadImage(GetFrame().g_hInstance,TEXT("APPLEWIN_ICON"), IMAGE_ICON,16,16,LR_DEFAULTCOLOR); RegisterClassEx(&wndclass); } @@ -2615,13 +2612,13 @@ static bool FileExists(std::string strFilename) // Called when: // . Mouse f/w sets abs position // . UpdateMouseInAppleViewport() is called and inside Apple screen -void FrameSetCursorPosByMousePos() +void Win32Frame::FrameSetCursorPosByMousePos() { // _ASSERT(GetCardMgr().IsMouseCardInstalled()); // CMouseInterface::ctor calls this function, ie. before GetCardMgr()::m_pMouseCard is setup if (!GetCardMgr().IsMouseCardInstalled()) return; - if (!g_hFrameWindow || g_bShowingCursor) + if (!GetFrame().g_hFrameWindow || g_bShowingCursor) return; int iX, iMinX, iMaxX; @@ -2635,7 +2632,7 @@ void FrameSetCursorPosByMousePos() int iWindowY = (int)(fScaleY * (float)g_nViewportCY); POINT Point = {viewportx+2, viewporty+2}; // top-left - ClientToScreen(g_hFrameWindow, &Point); + ClientToScreen(GetFrame().g_hFrameWindow, &Point); SetCursorPos(Point.x+iWindowX-VIEWPORTX, Point.y+iWindowY-VIEWPORTY); #if defined(_DEBUG) && 0 // OutputDebugString() when cursor position changes since last time @@ -2661,7 +2658,7 @@ static void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeav return; // char szDbg[200]; - if (!g_hFrameWindow || (g_bShowingCursor && bLeavingAppleScreen) || (!g_bShowingCursor && !bLeavingAppleScreen)) + if (!GetFrame().g_hFrameWindow || (g_bShowingCursor && bLeavingAppleScreen) || (!g_bShowingCursor && !bLeavingAppleScreen)) return; int iX, iMinX, iMaxX; @@ -2683,7 +2680,7 @@ static void FrameSetCursorPosByMousePos(int x, int y, int dx, int dy, bool bLeav int iWindowY = (int)(fScaleY * (float)g_nViewportCY) + dy; POINT Point = {viewportx+2, viewporty+2}; // top-left - ClientToScreen(g_hFrameWindow, &Point); + ClientToScreen(GetFrame().g_hFrameWindow, &Point); SetCursorPos(Point.x+iWindowX-VIEWPORTX, Point.y+iWindowY-VIEWPORTY); // sprintf(szDbg, "[MOUSE_LEAVING ] x=%d, y=%d (Scale: x,y=%f,%f; iX,iY=%d,%d)\n", iWindowX, iWindowY, fScaleX, fScaleY, iX, iY); OutputDebugString(szDbg); } @@ -2781,7 +2778,7 @@ static void UpdateMouseInAppleViewport(int iOutOfBoundsX, int iOutOfBoundsY, int } else { - FrameSetCursorPosByMousePos(); // Set cursor to Apple position each time + GetFrame().FrameSetCursorPosByMousePos(); // Set cursor to Apple position each time } DrawCrosshairsMouse(); @@ -2795,7 +2792,7 @@ void GetViewportCXCY(int& nViewportCX, int& nViewportCY) } // Call all funcs with dependency on g_Apple2Type -void FrameUpdateApple2Type(void) +void Win32Frame::FrameUpdateApple2Type(void) { DeleteGdiObjects(); CreateGdiObjects(); @@ -2808,7 +2805,7 @@ void FrameUpdateApple2Type(void) DrawFrameWindow(); } -bool GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& bestHeight, UINT userSpecifiedHeight /*= 0*/) +bool Win32Frame::GetBestDisplayResolutionForFullScreen(UINT& bestWidth, UINT& bestHeight, UINT userSpecifiedHeight /*= 0*/) { typedef std::vector< std::pair > VEC_PAIR; VEC_PAIR vecDisplayResolutions; diff --git a/source/Windows/WinVideo.cpp b/source/Windows/WinVideo.cpp index dc06b16f..9787e680 100644 --- a/source/Windows/WinVideo.cpp +++ b/source/Windows/WinVideo.cpp @@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #include "StdAfx.h" #include "Windows/WinVideo.h" +#include "Windows/Win32Frame.h" #include "Windows/WinFrame.h" #include "Windows/AppleWin.h" #include "Interface.h" @@ -90,7 +91,7 @@ void WinVideoInitialize() VideoResetState(); // LOAD THE LOGO - g_hLogoBitmap = LoadBitmap(g_hInstance, MAKEINTRESOURCE(IDB_APPLEWIN)); + g_hLogoBitmap = LoadBitmap(GetFrame().g_hInstance, MAKEINTRESOURCE(IDB_APPLEWIN)); // CREATE A BITMAPINFO STRUCTURE FOR THE FRAME BUFFER g_pFramebufferinfo = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)]; @@ -153,7 +154,7 @@ void VideoBenchmark () { g_uVideoMode = VF_TEXT; memset(mem+0x400,0x14,0x400); - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); DWORD milliseconds = GetTickCount(); while (GetTickCount() == milliseconds) ; milliseconds = GetTickCount(); @@ -175,7 +176,7 @@ void VideoBenchmark () { DWORD totalhiresfps = 0; g_uVideoMode = VF_HIRES; memset(mem+0x2000,0x14,0x2000); - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); milliseconds = GetTickCount(); while (GetTickCount() == milliseconds) ; milliseconds = GetTickCount(); @@ -209,7 +210,7 @@ void VideoBenchmark () { // IF THE PROGRAM COUNTER IS NOT IN THE EXPECTED RANGE AT THE END OF THE // CPU BENCHMARK, REPORT AN ERROR AND OPTIONALLY TRACK IT DOWN if ((regs.pc < 0x300) || (regs.pc > 0x400)) - if (MessageBox(g_hFrameWindow, + if (MessageBox(GetFrame().g_hFrameWindow, TEXT("The emulator has detected a problem while running ") TEXT("the CPU benchmark. Would you like to gather more ") TEXT("information?"), @@ -238,13 +239,13 @@ void VideoBenchmark () { (unsigned)loop, (unsigned)lastpc, (unsigned)regs.pc); - MessageBox(g_hFrameWindow, + MessageBox(GetFrame().g_hFrameWindow, outstr, TEXT("Benchmarks"), MB_ICONINFORMATION | MB_SETFOREGROUND); } else - MessageBox(g_hFrameWindow, + MessageBox(GetFrame().g_hFrameWindow, TEXT("The emulator was unable to locate the exact ") TEXT("point of the error. This probably means that ") TEXT("the problem is external to the emulator, ") @@ -259,7 +260,7 @@ void VideoBenchmark () { // THE SAME TIME DWORD realisticfps = 0; memset(mem+0x2000,0xAA,0x2000); - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); milliseconds = GetTickCount(); while (GetTickCount() == milliseconds) ; milliseconds = GetTickCount(); @@ -278,7 +279,7 @@ void VideoBenchmark () { memset(mem+0x2000,0xAA,0x2000); else memcpy(mem+0x2000,mem+((cycle & 2) ? 0x4000 : 0x6000),0x2000); - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); if (cycle++ >= 3) cycle = 0; realisticfps++; @@ -298,7 +299,7 @@ void VideoBenchmark () { (unsigned)(totalmhz10[0] / 10), (unsigned)(totalmhz10[0] % 10), (LPCTSTR)(IS_APPLE2 ? TEXT(" (6502)") : TEXT("")), (unsigned)(totalmhz10[1] / 10), (unsigned)(totalmhz10[1] % 10), (LPCTSTR)(IS_APPLE2 ? TEXT(" (6502)") : TEXT("")), (unsigned)realisticfps); - MessageBox(g_hFrameWindow, + MessageBox(GetFrame().g_hFrameWindow, outstr, TEXT("Benchmarks"), MB_ICONINFORMATION | MB_SETFOREGROUND); @@ -311,7 +312,7 @@ void VideoChooseMonochromeColor () CHOOSECOLOR cc; memset(&cc, 0, sizeof(CHOOSECOLOR)); cc.lStructSize = sizeof(CHOOSECOLOR); - cc.hwndOwner = g_hFrameWindow; + cc.hwndOwner = GetFrame().g_hFrameWindow; cc.rgbResult = g_nMonochromeRGB; cc.lpCustColors = customcolors + 1; cc.Flags = CC_RGBINIT | CC_SOLIDCOLOR; @@ -321,7 +322,7 @@ void VideoChooseMonochromeColor () VideoReinitialize(); if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) { - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); } Config_Save_Video(); } @@ -489,12 +490,12 @@ void VideoRedrawScreenDuringFullSpeed(DWORD dwCyclesThisFrame, bool bInit /*=fal void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame) { NTSC_VideoClockResync(dwCyclesThisFrame); - VideoRedrawScreen(); // Better (no flicker) than using: NTSC_VideoReinitialize() or VideoReinitialize() + GetFrame().VideoRedrawScreen(); // Better (no flicker) than using: NTSC_VideoReinitialize() or VideoReinitialize() } //=========================================================================== -void VideoRedrawScreen (void) +void Win32Frame::VideoRedrawScreen (void) { // NB. Can't rely on g_uVideoMode being non-zero (ie. so it can double up as a flag) since 'GR,PAGE1,non-mixed' mode == 0x00. VideoRefreshScreen( g_uVideoMode, true ); @@ -632,6 +633,6 @@ void Video_RedrawAndTakeScreenShot(const char* pScreenshotFilename) if (!pScreenshotFilename) return; - VideoRedrawScreen(); + GetFrame().VideoRedrawScreen(); Video_SaveScreenShot(SCREENSHOT_560x384, pScreenshotFilename); }