Move interface into a class FrameBase. (PR #893)

. Move the Win32  implementation into Win32Frame.
This commit is contained in:
Andrea 2020-12-24 15:08:50 +00:00 committed by GitHub
parent 6ec47a357d
commit e27879ac99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 348 additions and 267 deletions

View File

@ -78,6 +78,7 @@
<ClInclude Include="source\DiskImageHelper.h" /> <ClInclude Include="source\DiskImageHelper.h" />
<ClInclude Include="source\DiskLog.h" /> <ClInclude Include="source\DiskLog.h" />
<ClInclude Include="source\Frame.h" /> <ClInclude Include="source\Frame.h" />
<ClInclude Include="source\FrameBase.h" />
<ClInclude Include="source\Harddisk.h" /> <ClInclude Include="source\Harddisk.h" />
<ClInclude Include="source\Interface.h" /> <ClInclude Include="source\Interface.h" />
<ClInclude Include="source\Joystick.h" /> <ClInclude Include="source\Joystick.h" />
@ -120,6 +121,7 @@
<ClInclude Include="source\Video.h" /> <ClInclude Include="source\Video.h" />
<ClInclude Include="source\Windows\AppleWin.h" /> <ClInclude Include="source\Windows\AppleWin.h" />
<ClInclude Include="source\Windows\DirectInput.h" /> <ClInclude Include="source\Windows\DirectInput.h" />
<ClInclude Include="source\Windows\Win32Frame.h" />
<ClInclude Include="source\Windows\WinFrame.h" /> <ClInclude Include="source\Windows\WinFrame.h" />
<ClInclude Include="source\Windows\WinVideo.h" /> <ClInclude Include="source\Windows\WinVideo.h" />
<ClInclude Include="source\YamlHelper.h" /> <ClInclude Include="source\YamlHelper.h" />
@ -155,6 +157,7 @@
<ClCompile Include="source\Core.cpp" /> <ClCompile Include="source\Core.cpp" />
<ClCompile Include="source\CPU.cpp" /> <ClCompile Include="source\CPU.cpp" />
<ClCompile Include="source\Disk2CardManager.cpp" /> <ClCompile Include="source\Disk2CardManager.cpp" />
<ClCompile Include="source\FrameBase.cpp" />
<ClCompile Include="source\RGBMonitor.cpp" /> <ClCompile Include="source\RGBMonitor.cpp" />
<ClCompile Include="source\SAM.cpp" /> <ClCompile Include="source\SAM.cpp" />
<ClCompile Include="source\Debugger\Debug.cpp" /> <ClCompile Include="source\Debugger\Debug.cpp" />
@ -240,6 +243,7 @@
<ClCompile Include="source\Video.cpp" /> <ClCompile Include="source\Video.cpp" />
<ClCompile Include="source\Windows\AppleWin.cpp" /> <ClCompile Include="source\Windows\AppleWin.cpp" />
<ClCompile Include="source\Windows\DirectInput.cpp" /> <ClCompile Include="source\Windows\DirectInput.cpp" />
<ClCompile Include="source\Windows\Win32Frame.cpp" />
<ClCompile Include="source\Windows\WinFrame.cpp" /> <ClCompile Include="source\Windows\WinFrame.cpp" />
<ClCompile Include="source\Windows\WinVideo.cpp" /> <ClCompile Include="source\Windows\WinVideo.cpp" />
<ClCompile Include="source\YamlHelper.cpp" /> <ClCompile Include="source\YamlHelper.cpp" />

View File

@ -220,6 +220,12 @@
<ClCompile Include="source\CmdLine.cpp"> <ClCompile Include="source\CmdLine.cpp">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="source\FrameBase.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="source\Windows\Win32Frame.cpp">
<Filter>Source Files\Windows</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ClInclude Include="source\CommonVICE\6510core.h"> <ClInclude Include="source\CommonVICE\6510core.h">
@ -525,6 +531,12 @@
<ClInclude Include="source\Interface.h"> <ClInclude Include="source\Interface.h">
<Filter>Source Files</Filter> <Filter>Source Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="source\FrameBase.h">
<Filter>Source Files</Filter>
</ClInclude>
<ClInclude Include="source\Windows\Win32Frame.h">
<Filter>Source Files\Windows</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Image Include="resource\Applewin.bmp"> <Image Include="resource\Applewin.bmp">

View File

@ -214,13 +214,13 @@ bool ProcessCmdLine(LPSTR lpCmdLine)
bool bRes = false; bool bRes = false;
if (strcmp(lpTmp, "best") == 0) if (strcmp(lpTmp, "best") == 0)
{ {
bRes = GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight); bRes = GetFrame().GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight);
} }
else else
{ {
UINT userSpecifiedHeight = atoi(lpTmp); UINT userSpecifiedHeight = atoi(lpTmp);
if (userSpecifiedHeight) if (userSpecifiedHeight)
bRes = GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight, userSpecifiedHeight); bRes = GetFrame().GetBestDisplayResolutionForFullScreen(g_cmdLine.bestWidth, g_cmdLine.bestHeight, userSpecifiedHeight);
else else
LogFileOutput("Invalid cmd-line parameter for -fs-height=x switch\n"); 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"; std::string msg = "Failed to load video rom (not found or not exactly 2/4/8/16KiB)\n";
LogFileOutput("%s", msg.c_str()); 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 else
{ {
@ -387,7 +387,7 @@ bool ProcessCmdLine(LPSTR lpCmdLine)
} }
else if (strcmp(lpCmdLine, "-multimon") == 0) 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 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 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 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 else if (strcmp(lpCmdLine, "-video-mode=idealized") == 0) // GH#616
{ {

View File

@ -64,7 +64,7 @@ static BOOL CALLBACK DlgProcAbout(HWND hWnd, UINT message, WPARAM wparam, LPARAM
case WM_INITDIALOG: 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); SendDlgItemMessage(hWnd, IDC_APPLEWIN_ICON, STM_SETIMAGE, IMAGE_ICON, (LPARAM)hIcon);
TCHAR szAppleWinVersion[50]; TCHAR szAppleWinVersion[50];
@ -81,5 +81,5 @@ static BOOL CALLBACK DlgProcAbout(HWND hWnd, UINT message, WPARAM wparam, LPARAM
bool AboutDlg(void) 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;
} }

View File

@ -199,7 +199,7 @@ BOOL CPageConfig::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM
m_PropertySheetHelper.FillComboBox(hWnd, IDC_COMPUTER, m_ComputerChoices, nCurrentChoice); 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()); m_PropertySheetHelper.FillComboBox(hWnd,IDC_VIDEOTYPE, g_aVideoChoices, GetVideoType());
CheckDlgButton(hWnd, IDC_CHECK_HALF_SCAN_LINES, IsVideoStyle(VS_HALF_SCANLINES) ? BST_CHECKED : BST_UNCHECKED); 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(); Config_Save_Video();
FrameRefreshStatus(DRAW_TITLE, false); GetFrame().FrameRefreshStatus(DRAW_TITLE, false);
VideoReinitialize(); VideoReinitialize();
if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
{ {
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
} }
} }
@ -329,19 +329,19 @@ void CPageConfig::DlgOK(HWND hWnd)
if (GetFullScreenShowSubunitStatus() != bNewFSSubunitStatus) if (GetFullScreenShowSubunitStatus() != bNewFSSubunitStatus)
{ {
REGSAVE(TEXT(REGVALUE_FS_SHOW_SUBUNIT_STATUS), bNewFSSubunitStatus ? 1 : 0); REGSAVE(TEXT(REGVALUE_FS_SHOW_SUBUNIT_STATUS), bNewFSSubunitStatus ? 1 : 0);
SetFullScreenShowSubunitStatus(bNewFSSubunitStatus); GetFrame().SetFullScreenShowSubunitStatus(bNewFSSubunitStatus);
if (IsFullScreen()) 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; 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); 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) 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) bool CPageConfig::IsOkToBenchmark(HWND hWnd, const bool bConfigChanged)

View File

@ -92,14 +92,14 @@ BOOL CPageDisk::DlgProcInternal(HWND hWnd, UINT message, WPARAM wparam, LPARAM l
if (HIWORD(wparam) == CBN_SELCHANGE) if (HIWORD(wparam) == CBN_SELCHANGE)
{ {
HandleFloppyDriveCombo(hWnd, DRIVE_1, LOWORD(wparam)); HandleFloppyDriveCombo(hWnd, DRIVE_1, LOWORD(wparam));
FrameRefreshStatus(DRAW_BUTTON_DRIVES); GetFrame().FrameRefreshStatus(DRAW_BUTTON_DRIVES);
} }
break; break;
case IDC_COMBO_DISK2: case IDC_COMBO_DISK2:
if (HIWORD(wparam) == CBN_SELCHANGE) if (HIWORD(wparam) == CBN_SELCHANGE)
{ {
HandleFloppyDriveCombo(hWnd, DRIVE_2, LOWORD(wparam)); HandleFloppyDriveCombo(hWnd, DRIVE_2, LOWORD(wparam));
FrameRefreshStatus(DRAW_BUTTON_DRIVES); GetFrame().FrameRefreshStatus(DRAW_BUTTON_DRIVES);
} }
break; break;
case IDC_COMBO_HDD1: case IDC_COMBO_HDD1:
@ -413,7 +413,7 @@ UINT CPageDisk::RemovalConfirmation(UINT uCommand)
if (bMsgBox) 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) if (nRes == IDNO)
uCommand = 0; uCommand = 0;
} }

View File

@ -41,31 +41,31 @@ void CPropertySheet::Init(void)
PropSheetPages[PG_CONFIG].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_CONFIG].dwSize = sizeof(PROPSHEETPAGE);
PropSheetPages[PG_CONFIG].dwFlags = PSP_DEFAULT; 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].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_CONFIG);
PropSheetPages[PG_CONFIG].pfnDlgProc = (DLGPROC)CPageConfig::DlgProc; PropSheetPages[PG_CONFIG].pfnDlgProc = (DLGPROC)CPageConfig::DlgProc;
PropSheetPages[PG_INPUT].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_INPUT].dwSize = sizeof(PROPSHEETPAGE);
PropSheetPages[PG_INPUT].dwFlags = PSP_DEFAULT; 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].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_INPUT);
PropSheetPages[PG_INPUT].pfnDlgProc = (DLGPROC)CPageInput::DlgProc; PropSheetPages[PG_INPUT].pfnDlgProc = (DLGPROC)CPageInput::DlgProc;
PropSheetPages[PG_SOUND].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_SOUND].dwSize = sizeof(PROPSHEETPAGE);
PropSheetPages[PG_SOUND].dwFlags = PSP_DEFAULT; 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].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_SOUND);
PropSheetPages[PG_SOUND].pfnDlgProc = (DLGPROC)CPageSound::DlgProc; PropSheetPages[PG_SOUND].pfnDlgProc = (DLGPROC)CPageSound::DlgProc;
PropSheetPages[PG_DISK].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_DISK].dwSize = sizeof(PROPSHEETPAGE);
PropSheetPages[PG_DISK].dwFlags = PSP_DEFAULT; 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].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_DISK);
PropSheetPages[PG_DISK].pfnDlgProc = (DLGPROC)CPageDisk::DlgProc; PropSheetPages[PG_DISK].pfnDlgProc = (DLGPROC)CPageDisk::DlgProc;
PropSheetPages[PG_ADVANCED].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_ADVANCED].dwSize = sizeof(PROPSHEETPAGE);
PropSheetPages[PG_ADVANCED].dwFlags = PSP_DEFAULT; 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].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_ADVANCED);
PropSheetPages[PG_ADVANCED].pfnDlgProc = (DLGPROC)CPageAdvanced::DlgProc; PropSheetPages[PG_ADVANCED].pfnDlgProc = (DLGPROC)CPageAdvanced::DlgProc;
@ -73,7 +73,7 @@ void CPropertySheet::Init(void)
PropSheetHeader.dwSize = sizeof(PROPSHEETHEADER); PropSheetHeader.dwSize = sizeof(PROPSHEETHEADER);
PropSheetHeader.dwFlags = PSH_NOAPPLYNOW | /* PSH_NOCONTEXTHELP | */ PSH_PROPSHEETPAGE; PropSheetHeader.dwFlags = PSH_NOAPPLYNOW | /* PSH_NOCONTEXTHELP | */ PSH_PROPSHEETPAGE;
PropSheetHeader.hwndParent = g_hFrameWindow; PropSheetHeader.hwndParent = GetFrame().g_hFrameWindow;
PropSheetHeader.pszCaption = "AppleWin Configuration"; PropSheetHeader.pszCaption = "AppleWin Configuration";
PropSheetHeader.nPages = PG_NUM_SHEETS; PropSheetHeader.nPages = PG_NUM_SHEETS;
PropSheetHeader.nStartPage = m_PropertySheetHelper.GetLastPage(); PropSheetHeader.nStartPage = m_PropertySheetHelper.GetLastPage();

View File

@ -163,7 +163,7 @@ std::string CPropertySheetHelper::BrowseToFile(HWND hWindow, TCHAR* pszTitle, TC
ofn.lStructSize = sizeof(OPENFILENAME); ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWindow; ofn.hwndOwner = hWindow;
ofn.hInstance = g_hInstance; ofn.hInstance = GetFrame().g_hInstance;
ofn.lpstrFilter = FILEMASKS; ofn.lpstrFilter = FILEMASKS;
/*ofn.lpstrFilter = TEXT("Applications (*.exe)\0*.exe\0") /*ofn.lpstrFilter = TEXT("Applications (*.exe)\0*.exe\0")
TEXT("Text files (*.txt)\0*.txt\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.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = hWindow; ofn.hwndOwner = hWindow;
ofn.hInstance = g_hInstance; ofn.hInstance = GetFrame().g_hInstance;
ofn.lpstrFilter = TEXT("Save State files (*.aws.yaml)\0*.aws.yaml\0"); ofn.lpstrFilter = TEXT("Save State files (*.aws.yaml)\0*.aws.yaml\0");
TEXT("All Files\0*.*\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 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())) if (m_ConfigNew.m_uSaveLoadStateMsg && IsOkToSaveLoadState(hWnd, IsConfigChanged()))
{ {
// Drop any config change, and do load/save state // 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; return;
} }
if (m_bDoBenchmark) if (m_bDoBenchmark)
{ {
// Drop any config change, and do benchmark // 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; return;
} }
@ -316,7 +316,7 @@ void CPropertySheetHelper::PostMsgAfterClose(HWND hWnd, PAGETYPE page)
} }
if (uAfterClose) if (uAfterClose)
PostMessage(g_hFrameWindow, uAfterClose, 0, 0); PostMessage(GetFrame().g_hFrameWindow, uAfterClose, 0, 0);
} }
bool CPropertySheetHelper::CheckChangesForRestart(HWND hWnd) bool CPropertySheetHelper::CheckChangesForRestart(HWND hWnd)

View File

@ -754,8 +754,8 @@ Update_t CmdBenchmarkStop (int nArgs)
g_bBenchmarking = false; g_bBenchmarking = false;
DebugEnd(); DebugEnd();
FrameRefreshStatus(DRAW_TITLE); GetFrame().FrameRefreshStatus(DRAW_TITLE);
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
DWORD currtime = GetTickCount(); DWORD currtime = GetTickCount();
while ((extbench = GetTickCount()) != currtime) while ((extbench = GetTickCount()) != currtime)
; // intentional busy-waiting ; // intentional busy-waiting
@ -1964,7 +1964,7 @@ static Update_t CmdGo (int nArgs, const bool bFullSpeed)
g_bGoCmd_ReinitFlag = true; g_bGoCmd_ReinitFlag = true;
g_nAppMode = MODE_STEPPING; g_nAppMode = MODE_STEPPING;
FrameRefreshStatus(DRAW_TITLE); GetFrame().FrameRefreshStatus(DRAW_TITLE);
SoundCore_SetFade(FADE_IN); SoundCore_SetFade(FADE_IN);
@ -2033,7 +2033,7 @@ Update_t CmdTrace (int nArgs)
g_nDebugStepStart = regs.pc; g_nDebugStepStart = regs.pc;
g_nDebugStepUntil = -1; g_nDebugStepUntil = -1;
g_nAppMode = MODE_STEPPING; g_nAppMode = MODE_STEPPING;
FrameRefreshStatus(DRAW_TITLE); GetFrame().FrameRefreshStatus(DRAW_TITLE);
DebugContinueStepping(true); DebugContinueStepping(true);
return UPDATE_ALL; // TODO: Verify // 0 return UPDATE_ALL; // TODO: Verify // 0
@ -2093,7 +2093,7 @@ Update_t CmdTraceLine (int nArgs)
g_nDebugStepUntil = -1; g_nDebugStepUntil = -1;
g_nAppMode = MODE_STEPPING; g_nAppMode = MODE_STEPPING;
FrameRefreshStatus(DRAW_TITLE); GetFrame().FrameRefreshStatus(DRAW_TITLE);
DebugContinueStepping(true); DebugContinueStepping(true);
return UPDATE_ALL; // TODO: Verify // 0 return UPDATE_ALL; // TODO: Verify // 0
@ -2227,7 +2227,7 @@ void _CmdColorGet( const int iScheme, const int iColor )
{ {
TCHAR sText[ CONSOLE_WIDTH ]; TCHAR sText[ CONSOLE_WIDTH ];
wsprintf( sText, "Color: %d\nOut of range!", iColor ); 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" "\tLen: %04X\n"
"\tMissed: %04X"), "\tMissed: %04X"),
g_nDisasmCurAddress - nLen, nLen, g_nDisasmCurAddress ); g_nDisasmCurAddress - nLen, nLen, g_nDisasmCurAddress );
MessageBox( g_hFrameWindow, sText, "ERROR", MB_OK ); MessageBox( GetFrame().g_hFrameWindow, sText, "ERROR", MB_OK );
#endif #endif
} }
} }
@ -3773,7 +3773,7 @@ Update_t CmdDisk ( int nArgs)
return HelpLastCommand(); return HelpLastCommand();
diskCard.EjectDisk( iDrive ); diskCard.EjectDisk( iDrive );
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
} }
else else
if (iParam == PARAM_DISK_PROTECT) if (iParam == PARAM_DISK_PROTECT)
@ -3787,7 +3787,7 @@ Update_t CmdDisk ( int nArgs)
bProtect = g_aArgs[ 3 ].nValue ? true : false; bProtect = g_aArgs[ 3 ].nValue ? true : false;
diskCard.SetProtect( iDrive, bProtect ); diskCard.SetProtect( iDrive, bProtect );
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
} }
else else
{ {
@ -3798,7 +3798,7 @@ Update_t CmdDisk ( int nArgs)
// DISK # "Diskname" // DISK # "Diskname"
diskCard.InsertDisk( iDrive, pDiskName, IMAGE_FORCE_WRITE_PROTECTED, IMAGE_DONT_CREATE ); 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; return UPDATE_CONSOLE_DISPLAY;
@ -7448,7 +7448,7 @@ Update_t CmdWindowViewData (int nArgs)
//=========================================================================== //===========================================================================
Update_t CmdWindowViewOutput (int nArgs) Update_t CmdWindowViewOutput (int nArgs)
{ {
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
DebugVideoMode::Instance().Set(g_uVideoMode); DebugVideoMode::Instance().Set(g_uVideoMode);
@ -8549,7 +8549,7 @@ void DebugBegin ()
GetDebuggerMemDC(); GetDebuggerMemDC();
g_nAppMode = MODE_DEBUG; g_nAppMode = MODE_DEBUG;
FrameRefreshStatus(DRAW_TITLE); GetFrame().FrameRefreshStatus(DRAW_TITLE);
if (GetMainCpu() == CPU_6502) 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 SoundCore_SetFade(FADE_OUT); // NB. Call when MODE_STEPPING (not MODE_DEBUG) - see function
g_nAppMode = MODE_DEBUG; g_nAppMode = MODE_DEBUG;
FrameRefreshStatus(DRAW_TITLE); GetFrame().FrameRefreshStatus(DRAW_TITLE);
// BUG: PageUp, Trace - doesn't center cursor // BUG: PageUp, Trace - doesn't center cursor
g_nDisasmCurAddress = regs.pc; g_nDisasmCurAddress = regs.pc;
@ -9064,7 +9064,7 @@ void DebuggerInputConsoleChar( TCHAR ch )
if (!IsClipboardFormatAvailable(CF_TEXT)) if (!IsClipboardFormatAvailable(CF_TEXT))
return; return;
if (!OpenClipboard( g_hFrameWindow )) if (!OpenClipboard(GetFrame().g_hFrameWindow ))
return; return;
HGLOBAL hClipboard; HGLOBAL hClipboard;

View File

@ -471,7 +471,7 @@ int _6502_GetOpmodeOpbyte ( const int nBaseAddress, int & iOpmode_, int & nOpby
#if _DEBUG #if _DEBUG
if (! g_aOpcodes) 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_aOpcodes = & g_aOpcodes65C02[ 0 ]; // Enhanced Apple //e
g_aOpmodes[ AM_2 ].m_nBytes = 2; g_aOpmodes[ AM_2 ].m_nBytes = 2;

View File

@ -518,7 +518,7 @@ void VerifyDebuggerCommandTable()
if ( g_aCommands[ iCmd ].iCommand != iCmd) if ( g_aCommands[ iCmd ].iCommand != iCmd)
{ {
sprintf( sText, "*** ERROR *** Enumerated Commands mis-matched at #%d!", 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 ); PostQuitMessage( 1 );
} }
} }
@ -527,14 +527,14 @@ void VerifyDebuggerCommandTable()
if (strcmp( g_aCommands[ NUM_COMMANDS ].m_sName, DEBUGGER__COMMANDS_VERIFY_TXT__)) if (strcmp( g_aCommands[ NUM_COMMANDS ].m_sName, DEBUGGER__COMMANDS_VERIFY_TXT__))
{ {
sprintf( sText, "*** ERROR *** Total Commands mis-matched!" ); 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 ); PostQuitMessage( 1 );
} }
if (strcmp( g_aParameters[ NUM_PARAMS ].m_sName, DEBUGGER__PARAMS_VERIFY_TXT__)) if (strcmp( g_aParameters[ NUM_PARAMS ].m_sName, DEBUGGER__PARAMS_VERIFY_TXT__))
{ {
sprintf( sText, "*** ERROR *** Total Parameters mis-matched!" ); 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 ); PostQuitMessage( 2 );
} }
} }

View File

@ -633,7 +633,7 @@ HDC GetConsoleFontDC(void)
// DRAW THE SOURCE IMAGE INTO THE SOURCE BIT BUFFER // DRAW THE SOURCE IMAGE INTO THE SOURCE BIT BUFFER
HDC tmpDC = CreateCompatibleDC(hFrameDC); HDC tmpDC = CreateCompatibleDC(hFrameDC);
// Pre-scaled bitmap // 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); SelectObject(tmpDC, tmpFont);
BitBlt(g_hConsoleFontDC, 0, 0, CONSOLE_FONT_BITMAP_WIDTH, CONSOLE_FONT_BITMAP_HEIGHT, BitBlt(g_hConsoleFontDC, 0, 0, CONSOLE_FONT_BITMAP_WIDTH, CONSOLE_FONT_BITMAP_HEIGHT,
tmpDC, 0, 0, tmpDC, 0, 0,
@ -754,7 +754,7 @@ static void PrintGlyph( const int xDst, const int yDst, const int glyph )
{ {
#if _DEBUG #if _DEBUG
if ((xDst < 0) || (yDst < 0)) 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 #endif
int col = xDst / CONSOLE_FONT_WIDTH ; int col = xDst / CONSOLE_FONT_WIDTH ;
int row = yDst / CONSOLE_FONT_HEIGHT; int row = yDst / CONSOLE_FONT_HEIGHT;
@ -870,7 +870,7 @@ int PrintText ( const char * pText, RECT & rRect )
{ {
#if _DEBUG #if _DEBUG
if (! pText) if (! pText)
MessageBox( g_hFrameWindow, "pText = NULL!", "DrawText()", MB_OK ); MessageBox(GetFrame().g_hFrameWindow, "pText = NULL!", "DrawText()", MB_OK );
#endif #endif
int nLen = strlen( pText ); int nLen = strlen( pText );
@ -4116,7 +4116,7 @@ void UpdateDisplay (Update_t bUpdate)
if (spDrawMutex) if (spDrawMutex)
{ {
#if DEBUG #if DEBUG
MessageBox( g_hFrameWindow, "Already drawing!", "!", MB_OK ); MessageBox( GetFrame().g_hFrameWindow, "Already drawing!", "!", MB_OK );
#endif #endif
} }
spDrawMutex = true; spDrawMutex = true;

View File

@ -219,7 +219,7 @@ void Disk2InterfaceCard::CheckSpinning(const bool stateChanged, const ULONG uExe
m_floppyDrive[m_currDrive].m_spinning = SPINNING_CYCLES; m_floppyDrive[m_currDrive].m_spinning = SPINNING_CYCLES;
if (modeChanged) if (modeChanged)
FrameDrawDiskLEDS( (HDC)0 ); GetFrame().FrameDrawDiskLEDS( (HDC)0 );
if (modeChanged) if (modeChanged)
{ {
@ -511,7 +511,7 @@ void __stdcall Disk2InterfaceCard::ControlStepper(WORD, WORD address, BYTE, BYTE
pDrive->m_phasePrecise = newPhasePrecise; pDrive->m_phasePrecise = newPhasePrecise;
pFloppy->m_trackimagedata = false; pFloppy->m_trackimagedata = false;
m_formatTrack.DriveNotWritingTrack(); m_formatTrack.DriveNotWritingTrack();
FrameDrawDiskStatus((HDC)0); // Show track status (GH#201) GetFrame().FrameDrawDiskStatus((HDC)0); // Show track status (GH#201)
} }
#if LOG_DISK_PHASES #if LOG_DISK_PHASES
@ -683,7 +683,7 @@ ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFil
if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname)) if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname))
{ {
EjectDisk(!drive); 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]; 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()); 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) if (nRes == IDNO)
{ {
EjectDisk(drive); EjectDisk(drive);
@ -827,7 +827,7 @@ void Disk2InterfaceCard::NotifyInvalidImage(const int drive, LPCTSTR pszImageFil
} }
MessageBox( MessageBox(
g_hFrameWindow, GetFrame().g_hFrameWindow,
szBuffer, szBuffer,
g_pAppTitle.c_str(), g_pAppTitle.c_str(),
MB_ICONEXCLAMATION | MB_SETFOREGROUND); 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!!! // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!!
if ((pFloppy->m_byte & 0xFF) == 0) 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!!! // Show track status (GH#201) - NB. Prevent flooding of forcing UI to redraw!!!
if ((floppy.m_byte & 0xFF) == 0) if ((floppy.m_byte & 0xFF) == 0)
FrameDrawDiskStatus((HDC)0); GetFrame().FrameDrawDiskStatus((HDC)0);
} }
void Disk2InterfaceCard::DataLatchReadWOZ(WORD pc, WORD addr, UINT bitCellRemainder) 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_spinning = 0;
m_floppyDrive[DRIVE_2].m_writelight = 0; m_floppyDrive[DRIVE_2].m_writelight = 0;
FrameRefreshStatus(DRAW_LEDS, false); GetFrame().FrameRefreshStatus(DRAW_LEDS, false);
} }
InitFirmware(GetCxRomPeripheral()); InitFirmware(GetCxRomPeripheral());
FrameRefreshStatus(DRAW_TITLE, false); GetFrame().FrameRefreshStatus(DRAW_TITLE, false);
} }
void Disk2InterfaceCard::ResetSwitches(void) void Disk2InterfaceCard::ResetSwitches(void)
@ -1564,7 +1564,7 @@ bool Disk2InterfaceCard::UserSelectNewDiskImage(const int drive, LPCSTR pszFilen
{ {
if (!IsDriveConnected(drive)) 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; return false;
} }
@ -1582,8 +1582,8 @@ bool Disk2InterfaceCard::UserSelectNewDiskImage(const int drive, LPCSTR pszFilen
OPENFILENAME ofn; OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME)); memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME); ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = g_hFrameWindow; ofn.hwndOwner = GetFrame().g_hFrameWindow;
ofn.hInstance = g_hInstance; ofn.hInstance = GetFrame().g_hInstance;
ofn.lpstrFilter = TEXT("All Images\0*.bin;*.do;*.dsk;*.nib;*.po;*.gz;*.woz;*.zip;*.2mg;*.2img;*.iie;*.apl\0") 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("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"); 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; m_floppyDrive[m_currDrive].m_writelight = WRITELIGHT_CYCLES;
if (modechange) 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))) if (!(pDrive->m_spinning -= MIN(pDrive->m_spinning, cycles)))
{ {
FrameDrawDiskLEDS( (HDC)0 ); GetFrame().FrameDrawDiskLEDS( (HDC)0 );
FrameDrawDiskStatus( (HDC)0 ); GetFrame().FrameDrawDiskStatus( (HDC)0 );
} }
} }
@ -1716,8 +1716,8 @@ void Disk2InterfaceCard::UpdateDriveState(DWORD cycles)
{ {
if (!(pDrive->m_writelight -= MIN(pDrive->m_writelight, cycles))) if (!(pDrive->m_writelight -= MIN(pDrive->m_writelight, cycles)))
{ {
FrameDrawDiskLEDS( (HDC)0 ); GetFrame().FrameDrawDiskLEDS( (HDC)0 );
FrameDrawDiskStatus( (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 // 1.26.2.4 Prompt when trying to swap disks while drive is on instead of silently failing
int status = MessageBox( int status = MessageBox(
g_hFrameWindow, GetFrame().g_hFrameWindow,
"WARNING:\n" "WARNING:\n"
"\n" "\n"
"\tAttempting to swap a disk while a drive is on\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_1);
SaveLastDiskImage(DRIVE_2); SaveLastDiskImage(DRIVE_2);
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES, false); GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES, false);
return true; return true;
} }
@ -2264,7 +2264,7 @@ bool Disk2InterfaceCard::LoadSnapshot(class YamlLoadHelper& yamlLoadHelper, UINT
LoadSnapshotDriveUnit(yamlLoadHelper, DRIVE_1, version); LoadSnapshotDriveUnit(yamlLoadHelper, DRIVE_1, version);
LoadSnapshotDriveUnit(yamlLoadHelper, DRIVE_2, version); LoadSnapshotDriveUnit(yamlLoadHelper, DRIVE_2, version);
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
return true; return true;
} }

17
source/FrameBase.cpp Normal file
View File

@ -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()
{
}

29
source/FrameBase.h Normal file
View File

@ -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;
};

View File

@ -417,7 +417,7 @@ BOOL HD_Insert(const int iDrive, const std::string & pszImageFilename)
if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname)) if (!strcmp(pszOtherPathname.c_str(), szCurrentPathname))
{ {
HD_Unplug(!iDrive); 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; OPENFILENAME ofn;
memset(&ofn, 0, sizeof(OPENFILENAME)); memset(&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME); ofn.lStructSize = sizeof(OPENFILENAME);
ofn.hwndOwner = g_hFrameWindow; ofn.hwndOwner = GetFrame().g_hFrameWindow;
ofn.hInstance = g_hInstance; 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") 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"); TEXT("All Files\0*.*\0");
ofn.lpstrFile = filename; 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 if( pHDD->hd_status_prev != pHDD->hd_status_next ) // Update LEDs if state changes
{ {
pHDD->hd_status_prev = pHDD->hd_status_next; pHDD->hd_status_prev = pHDD->hd_status_next;
FrameRefreshStatus(DRAW_LEDS); GetFrame().FrameRefreshStatus(DRAW_LEDS);
} }
#endif #endif
@ -742,7 +742,7 @@ bool HD_ImageSwap(void)
HD_SaveLastDiskImage(HARDDISK_1); HD_SaveLastDiskImage(HARDDISK_1);
HD_SaveLastDiskImage(HARDDISK_2); HD_SaveLastDiskImage(HARDDISK_2);
FrameRefreshStatus(DRAW_LEDS, false); GetFrame().FrameRefreshStatus(DRAW_LEDS, false);
return true; return true;
} }
@ -902,7 +902,7 @@ bool HD_LoadSnapshot(YamlLoadHelper& yamlLoadHelper, UINT slot, UINT version, co
HD_SetEnabled(true); HD_SetEnabled(true);
FrameRefreshStatus(DRAW_LEDS); GetFrame().FrameRefreshStatus(DRAW_LEDS);
return true; return true;
} }

View File

@ -1,25 +1,15 @@
#pragma once #pragma once
class IPropertySheet; // an AppleWin frontend must provide the implementation of these 2 methods
//
extern HINSTANCE g_hInstance; // once this is done,
extern HWND g_hFrameWindow; // the core emulator files (i.e. almost all the .cpp directly in Source)
extern BOOL g_bConfirmReboot; // saved PageConfig REGSAVE // can compile, link and run properly
extern BOOL g_bMultiMon; // this does not include the main event loop which is left in the arch specific area
extern bool g_bFreshReset; // nor the actual rendering of the video buffer to screen
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);
#include "Configuration/PropertySheet.h"
IPropertySheet& GetPropertySheet(); IPropertySheet& GetPropertySheet();
#include "FrameBase.h"
FrameBase& GetFrame();

View File

@ -126,13 +126,13 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII)
{ {
if (bASCII == ASCII) // WM_CHAR 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 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 if ((key > 0x7F) && !g_bTK3KModeKey) // When in TK3000 mode, we have special keys which need remapping
return; return;
@ -285,7 +285,7 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII)
// Note: VK_CANCEL is Control-Break // Note: VK_CANCEL is Control-Break
if ((key == VK_CANCEL) && (GetKeyState(VK_CONTROL) < 0)) if ((key == VK_CANCEL) && (GetKeyState(VK_CONTROL) < 0))
{ {
g_bFreshReset = true; GetFrame().g_bFreshReset = true;
CtrlReset(); CtrlReset();
return; return;
} }
@ -302,8 +302,8 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII)
if (g_Apple2Type == A2TYPE_TK30002E) if (g_Apple2Type == A2TYPE_TK30002E)
{ {
g_bTK3KModeKey = (GetKeyState(VK_SCROLL) & 1) ? true : false; // Sync with the Scroll Lock status 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 GetFrame().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().VideoRedrawScreen(); // TODO: Still need to implement page mode switching and 'whatnot'
} }
return; return;
} }
@ -332,7 +332,7 @@ void KeybQueueKeypress (WPARAM key, Keystroke_e bASCII)
newKey -= 'A' - 1; // convert to control-key newKey -= 'A' - 1; // convert to control-key
} }
PostMessage(g_hFrameWindow, WM_CHAR, newKey, 0); PostMessage(GetFrame().g_hFrameWindow, WM_CHAR, newKey, 0);
} }
return; return;
@ -378,7 +378,7 @@ static void ClipboardInit()
if (!IsClipboardFormatAvailable(CF_TEXT)) if (!IsClipboardFormatAvailable(CF_TEXT))
return; return;
if (!OpenClipboard(g_hFrameWindow)) if (!OpenClipboard(GetFrame().g_hFrameWindow))
return; return;
hglb = GetClipboardData(CF_TEXT); hglb = GetClipboardData(CF_TEXT);
@ -538,7 +538,7 @@ void KeybToggleCapsLock ()
if (!IS_APPLE2) if (!IS_APPLE2)
{ {
g_bCapsLock = (GetKeyState(VK_CAPITAL) & 1); g_bCapsLock = (GetKeyState(VK_CAPITAL) & 1);
FrameRefreshStatus(DRAW_LEDS); GetFrame().FrameRefreshStatus(DRAW_LEDS);
} }
} }
@ -547,7 +547,7 @@ void KeybToggleP8ACapsLock ()
{ {
_ASSERT(g_Apple2Type == A2TYPE_PRAVETS8A); _ASSERT(g_Apple2Type == A2TYPE_PRAVETS8A);
P8CAPS_ON = !P8CAPS_ON; P8CAPS_ON = !P8CAPS_ON;
FrameRefreshStatus(DRAW_LEDS); GetFrame().FrameRefreshStatus(DRAW_LEDS);
// g_bP8CapsLock= g_bP8CapsLock?false:true; //The same as the upper, but slower // g_bP8CapsLock= g_bP8CapsLock?false:true; //The same as the upper, but slower
} }

View File

@ -1646,7 +1646,7 @@ void MemInitializeCustomF8ROM(void)
} }
catch (bool) 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) 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); CloseHandle(g_hCustomRomF8);
g_hCustomRomF8 = INVALID_HANDLE_VALUE; g_hCustomRomF8 = INVALID_HANDLE_VALUE;
// Failed, so use default rom... // Failed, so use default rom...
@ -1723,7 +1723,7 @@ void MemInitializeCustomROM(void)
if (!bRes) 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); CloseHandle(g_hCustomRom);
g_hCustomRom = INVALID_HANDLE_VALUE; g_hCustomRom = INVALID_HANDLE_VALUE;
// Failed, so use default rom... // Failed, so use default rom...

View File

@ -588,7 +588,7 @@ void CMouseInterface::SetPositionAbs(int x, int y)
{ {
m_iX = x; m_iX = x;
m_iY = y; m_iY = y;
FrameSetCursorPosByMousePos(); GetFrame().FrameSetCursorPosByMousePos();
} }
void CMouseInterface::SetPositionRel(long dX, long dY, int* pOutOfBoundsX, int* pOutOfBoundsY) void CMouseInterface::SetPositionRel(long dX, long dY, int* pOutOfBoundsX, int* pOutOfBoundsY)

View File

@ -77,7 +77,7 @@ static void get_csbits(csbits_t csbits, const char* resourceName, const UINT cy0
const UINT bufferSize = bitmapWidthBytes*bitmapHeight; const UINT bufferSize = bitmapWidthBytes*bitmapHeight;
BYTE* pBuffer = new BYTE [bufferSize]; BYTE* pBuffer = new BYTE [bufferSize];
HBITMAP hCharBitmap = LoadBitmap(g_hInstance, resourceName); HBITMAP hCharBitmap = LoadBitmap(GetFrame().g_hInstance, resourceName);
GetBitmapBits(hCharBitmap, bufferSize, pBuffer); GetBitmapBits(hCharBitmap, bufferSize, pBuffer);
for (UINT cy=cy0, ch=0; cy<cy0+16; cy++) for (UINT cy=cy0, ch=0; cy<cy0+16; cy++)

View File

@ -44,6 +44,6 @@ void PravetsReset(void)
{ {
P8CAPS_ON = false; P8CAPS_ON = false;
TapeWrite(0, 0, 0, 0 ,0); TapeWrite(0, 0, 0, 0 ,0);
FrameRefreshStatus(DRAW_LEDS); GetFrame().FrameRefreshStatus(DRAW_LEDS);
} }
} }

View File

@ -289,7 +289,7 @@ static void ParseUnitApple2(YamlLoadHelper& yamlLoadHelper, UINT version)
// g_Apple2Type may've changed: so redraw frame (title, buttons, leds, etc) // g_Apple2Type may've changed: so redraw frame (title, buttons, leds, etc)
VideoReinitialize(); // g_CharsetType changed VideoReinitialize(); // g_CharsetType changed
FrameUpdateApple2Type(); // Calls VideoRedrawScreen() before the aux mem has been loaded (so if DHGR is enabled, then aux mem will be zeros at this stage) GetFrame().FrameUpdateApple2Type(); // Calls VideoRedrawScreen() before the aux mem has been loaded (so if DHGR is enabled, then aux mem will be zeros at this stage)
} }
//--- //---
@ -508,7 +508,7 @@ static void Snapshot_LoadState_v2(void)
} }
MB_SetCumulativeCycles(); MB_SetCumulativeCycles();
SetLoadedSaveStateFlag(true); GetFrame().SetLoadedSaveStateFlag(true);
// NB. The following disparity should be resolved: // NB. The following disparity should be resolved:
// . A change in h/w via the Configuration property sheets results in a the VM completely restarting (via WM_USER_RESTART) // . A change in h/w via the Configuration property sheets results in a the VM completely restarting (via WM_USER_RESTART)
@ -531,13 +531,13 @@ static void Snapshot_LoadState_v2(void)
} }
catch(std::string szMessage) catch(std::string szMessage)
{ {
MessageBox( g_hFrameWindow, MessageBox( GetFrame().g_hFrameWindow,
szMessage.c_str(), szMessage.c_str(),
TEXT("Load State"), TEXT("Load State"),
MB_ICONEXCLAMATION | MB_SETFOREGROUND); MB_ICONEXCLAMATION | MB_SETFOREGROUND);
if (restart) if (restart)
PostMessage(g_hFrameWindow, WM_USER_RESTART, 0, 0); // Power-cycle VM (undoing all the new state just loaded) PostMessage(GetFrame().g_hFrameWindow, WM_USER_RESTART, 0, 0); // Power-cycle VM (undoing all the new state just loaded)
} }
SetCursor(oldcursor); SetCursor(oldcursor);
@ -550,7 +550,7 @@ void Snapshot_LoadState()
const size_t pos = g_strSaveStatePathname.size() - ext_aws.size(); const size_t pos = g_strSaveStatePathname.size() - ext_aws.size();
if (g_strSaveStatePathname.find(ext_aws, pos) != std::string::npos) // find ".aws" at end of pathname if (g_strSaveStatePathname.find(ext_aws, pos) != std::string::npos) // find ".aws" at end of pathname
{ {
MessageBox( g_hFrameWindow, MessageBox( GetFrame().g_hFrameWindow,
"Save-state v1 no longer supported.\n" "Save-state v1 no longer supported.\n"
"Please load using AppleWin 1.27, and re-save as a v2 state file.", "Please load using AppleWin 1.27, and re-save as a v2 state file.",
TEXT("Load State"), TEXT("Load State"),
@ -647,7 +647,7 @@ void Snapshot_SaveState(void)
} }
catch(std::string szMessage) catch(std::string szMessage)
{ {
MessageBox( g_hFrameWindow, MessageBox( GetFrame().g_hFrameWindow,
szMessage.c_str(), szMessage.c_str(),
TEXT("Save State"), TEXT("Save State"),
MB_ICONEXCLAMATION | MB_SETFOREGROUND); MB_ICONEXCLAMATION | MB_SETFOREGROUND);

View File

@ -243,7 +243,7 @@ bool CSuperSerialCard::CheckComm()
// now send async events to our app's message handler // now send async events to our app's message handler
if (WSAAsyncSelect( if (WSAAsyncSelect(
/* SOCKET s */ m_hCommListenSocket, /* SOCKET s */ m_hCommListenSocket,
/* HWND hWnd */ g_hFrameWindow, /* HWND hWnd */ GetFrame().g_hFrameWindow,
/* unsigned int wMsg */ WM_USER_TCP_SERIAL, /* unsigned int wMsg */ WM_USER_TCP_SERIAL,
/* long lEvent */ (FD_ACCEPT | FD_CONNECT | FD_READ | FD_CLOSE)) != 0) /* long lEvent */ (FD_ACCEPT | FD_CONNECT | FD_READ | FD_CLOSE)) != 0)
{ {
@ -315,7 +315,7 @@ void CSuperSerialCard::CommTcpSerialCleanup()
{ {
if (m_hCommListenSocket != INVALID_SOCKET) if (m_hCommListenSocket != INVALID_SOCKET)
{ {
WSAAsyncSelect(m_hCommListenSocket, g_hFrameWindow, 0, 0); // Stop event messages WSAAsyncSelect(m_hCommListenSocket, GetFrame().g_hFrameWindow, 0, 0); // Stop event messages
closesocket(m_hCommListenSocket); closesocket(m_hCommListenSocket);
m_hCommListenSocket = INVALID_SOCKET; m_hCommListenSocket = INVALID_SOCKET;

View File

@ -522,7 +522,7 @@ bool DSInit()
return false; return false;
} }
hr = g_lpDS->SetCooperativeLevel(g_hFrameWindow, DSSCL_NORMAL); hr = g_lpDS->SetCooperativeLevel(GetFrame().g_hFrameWindow, DSSCL_NORMAL);
if(FAILED(hr)) if(FAILED(hr))
{ {
if(g_fh) fprintf(g_fh, "SetCooperativeLevel failed (%08X)\n",hr); if(g_fh) fprintf(g_fh, "SetCooperativeLevel failed (%08X)\n",hr);

View File

@ -97,13 +97,13 @@ static void Spkr_DSUninit();
static void DisplayBenchmarkResults () static void DisplayBenchmarkResults ()
{ {
DWORD totaltime = GetTickCount()-extbench; DWORD totaltime = GetTickCount()-extbench;
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
TCHAR buffer[64]; TCHAR buffer[64];
wsprintf(buffer, wsprintf(buffer,
TEXT("This benchmark took %u.%02u seconds."), TEXT("This benchmark took %u.%02u seconds."),
(unsigned)(totaltime / 1000), (unsigned)(totaltime / 1000),
(unsigned)((totaltime / 10) % 100)); (unsigned)((totaltime / 10) % 100));
MessageBox(g_hFrameWindow, MessageBox(GetFrame().g_hFrameWindow,
buffer, buffer,
TEXT("Benchmark Results"), TEXT("Benchmark Results"),
MB_ICONINFORMATION | MB_SETFOREGROUND); MB_ICONINFORMATION | MB_SETFOREGROUND);

View File

@ -208,7 +208,7 @@ void LoadConfiguration(void)
DWORD dwTmp = 0; DWORD dwTmp = 0;
if(REGLOAD(TEXT(REGVALUE_FS_SHOW_SUBUNIT_STATUS), &dwTmp)) 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)) if(REGLOAD(TEXT(REGVALUE_THE_FREEZES_F8_ROM), &dwTmp))
GetPropertySheet().SetTheFreezesF8Rom(dwTmp); GetPropertySheet().SetTheFreezesF8Rom(dwTmp);
@ -313,10 +313,10 @@ void LoadConfiguration(void)
Printer_SetIdleLimit(dwTmp); Printer_SetIdleLimit(dwTmp);
if (REGLOAD(TEXT(REGVALUE_WINDOW_SCALE), &dwTmp)) if (REGLOAD(TEXT(REGVALUE_WINDOW_SCALE), &dwTmp))
SetViewportScale(dwTmp); GetFrame().SetViewportScale(dwTmp);
if (REGLOAD(TEXT(REGVALUE_CONFIRM_REBOOT), &dwTmp)) if (REGLOAD(TEXT(REGVALUE_CONFIRM_REBOOT), &dwTmp))
g_bConfirmReboot = dwTmp; GetFrame().g_bConfirmReboot = dwTmp;
} }
static std::string GetFullPath(LPCSTR szFileName) 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]); bRes = DoDiskInsert(slot, DRIVE_1, szImageName_drive[DRIVE_1]);
LogFileOutput("Init: S%d, DoDiskInsert(D1), res=%d\n", slot, bRes); 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; bBoot = true;
} }
@ -418,7 +418,7 @@ void InsertFloppyDisks(const UINT slot, LPSTR szImageName_drive[NUM_DRIVES], boo
} }
if (!bRes) 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) 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]); bRes = DoHardDiskInsert(HARDDISK_1, szImageName_harddisk[HARDDISK_1]);
LogFileOutput("Init: DoHardDiskInsert(HDD1), res=%d\n", bRes); LogFileOutput("Init: DoHardDiskInsert(HDD1), res=%d\n", bRes);
FrameRefreshStatus(DRAW_LEDS); // harddisk activity LED GetFrame().FrameRefreshStatus(DRAW_LEDS); // harddisk activity LED
bBoot = true; bBoot = true;
} }
@ -454,7 +454,7 @@ void InsertHardDisks(LPSTR szImageName_harddisk[NUM_HARDDISKS], bool& bBoot)
} }
if (!bRes) 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) void UnplugHardDiskControllerCard(void)
@ -593,5 +593,5 @@ void CtrlReset()
#endif #endif
CpuReset(); CpuReset();
g_bFreshReset = true; GetFrame().g_bFreshReset = true;
} }

View File

@ -476,7 +476,7 @@ void Video_TakeScreenShot( const VideoScreenShot_e ScreenShotType )
{ {
TCHAR msg[512]; 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 ); 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; g_nLastScreenShot = 0;
return; return;
} }
@ -574,9 +574,9 @@ static void Video_MakeScreenShot(FILE *pFile, const VideoScreenShot_e ScreenShot
// char sText[256]; // char sText[256];
// sprintf( sText, "sizeof: BITMAPFILEHEADER = %d\n", sizeof(BITMAPFILEHEADER) ); // = 14 // 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 // 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) ]; char sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[ sizeof( WinBmpHeader_t ) == (14 + 40) ];
/**/ sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[0]=0; /**/ sIfSizeZeroOrUnknown_BadWinBmpHeaderPackingSize54[0]=0;
@ -661,7 +661,7 @@ void Video_SaveScreenShot( const VideoScreenShot_e ScreenShotType, const TCHAR *
if( g_bDisplayPrintScreenFileName ) if( g_bDisplayPrintScreenFileName )
{ {
MessageBox( g_hFrameWindow, pScreenShotFileName, "Screen Captured", MB_OK ); MessageBox( GetFrame().g_hFrameWindow, pScreenShotFileName, "Screen Captured", MB_OK );
} }
} }

View File

@ -47,6 +47,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "Speech.h" #include "Speech.h"
#endif #endif
#include "Windows/WinVideo.h" #include "Windows/WinVideo.h"
#include "Windows/Win32Frame.h"
#include "Windows/WinFrame.h" #include "Windows/WinFrame.h"
#include "RGBMonitor.h" #include "RGBMonitor.h"
#include "NTSC.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_bLoadedSaveState = false;
static bool g_bSysClkOK = false; static bool g_bSysClkOK = false;
@ -72,7 +70,7 @@ bool GetLoadedSaveStateFlag(void)
return g_bLoadedSaveState; return g_bLoadedSaveState;
} }
void SetLoadedSaveStateFlag(const bool bFlag) void Win32Frame::SetLoadedSaveStateFlag(const bool bFlag)
{ {
g_bLoadedSaveState = bFlag; g_bLoadedSaveState = bFlag;
} }
@ -85,7 +83,7 @@ bool GetHookAltGrControl(void)
static void ResetToLogoMode(void) static void ResetToLogoMode(void)
{ {
g_nAppMode = MODE_LOGO; g_nAppMode = MODE_LOGO;
SetLoadedSaveStateFlag(false); GetFrame().SetLoadedSaveStateFlag(false);
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -453,21 +451,21 @@ static void RegisterHotKeys(void)
BOOL bStatus[3] = {0,0,0}; BOOL bStatus[3] = {0,0,0};
bStatus[0] = RegisterHotKey( bStatus[0] = RegisterHotKey(
g_hFrameWindow , // HWND hWnd GetFrame().g_hFrameWindow , // HWND hWnd
VK_SNAPSHOT_560, // int id (user/custom id) VK_SNAPSHOT_560, // int id (user/custom id)
0 , // UINT fsModifiers 0 , // UINT fsModifiers
VK_SNAPSHOT // UINT vk = PrintScreen VK_SNAPSHOT // UINT vk = PrintScreen
); );
bStatus[1] = RegisterHotKey( bStatus[1] = RegisterHotKey(
g_hFrameWindow , // HWND hWnd GetFrame().g_hFrameWindow , // HWND hWnd
VK_SNAPSHOT_280, // int id (user/custom id) VK_SNAPSHOT_280, // int id (user/custom id)
MOD_SHIFT , // UINT fsModifiers MOD_SHIFT , // UINT fsModifiers
VK_SNAPSHOT // UINT vk = PrintScreen VK_SNAPSHOT // UINT vk = PrintScreen
); );
bStatus[2] = RegisterHotKey( bStatus[2] = RegisterHotKey(
g_hFrameWindow , // HWND hWnd GetFrame().g_hFrameWindow , // HWND hWnd
VK_SNAPSHOT_TEXT, // int id (user/custom id) VK_SNAPSHOT_TEXT, // int id (user/custom id)
MOD_CONTROL , // UINT fsModifiers MOD_CONTROL , // UINT fsModifiers
VK_SNAPSHOT // UINT vk = PrintScreen VK_SNAPSHOT // UINT vk = PrintScreen
@ -485,7 +483,7 @@ static void RegisterHotKeys(void)
msg += "\n. Ctrl+PrintScreen"; msg += "\n. Ctrl+PrintScreen";
if (g_bShowPrintScreenWarningDialog) 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"; msg += "\n";
LogFileOutput(msg.c_str()); LogFileOutput(msg.c_str());
@ -505,12 +503,12 @@ static bool HookFilterForKeyboard()
{ {
g_hinstDLL = LoadLibrary(TEXT("HookFilter.dll")); g_hinstDLL = LoadLibrary(TEXT("HookFilter.dll"));
_ASSERT(g_hFrameWindow); _ASSERT(GetFrame().g_hFrameWindow);
typedef void (*RegisterHWNDProc)(HWND, bool, bool); typedef void (*RegisterHWNDProc)(HWND, bool, bool);
RegisterHWNDProc RegisterHWND = (RegisterHWNDProc) GetProcAddress(g_hinstDLL, "RegisterHWND"); RegisterHWNDProc RegisterHWND = (RegisterHWNDProc) GetProcAddress(g_hinstDLL, "RegisterHWND");
if (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"); HOOKPROC hkprcLowLevelKeyboardProc = (HOOKPROC) GetProcAddress(g_hinstDLL, "LowLevelKeyboardProc");
@ -520,7 +518,7 @@ static bool HookFilterForKeyboard()
g_hinstDLL, g_hinstDLL,
0); 0);
if (g_hhook != 0 && g_hFrameWindow != 0) if (g_hhook != 0 && GetFrame().g_hFrameWindow != 0)
return true; return true;
std::string msg("Failed to install hook filter for system keys"); std::string msg("Failed to install hook filter for system keys");
@ -603,7 +601,7 @@ static void UninitHookThread()
static void ExceptionHandler(const char* pError) static void ExceptionHandler(const char* pError)
{ {
MessageBox( g_hFrameWindow, MessageBox( GetFrame().g_hFrameWindow,
pError, pError,
TEXT("Runtime Exception"), TEXT("Runtime Exception"),
MB_ICONEXCLAMATION | MB_SETFOREGROUND); MB_ICONEXCLAMATION | MB_SETFOREGROUND);
@ -760,7 +758,7 @@ static void OneTimeInitialization(HINSTANCE passinstance)
DDInit(); // For WaitForVerticalBlank() DDInit(); // For WaitForVerticalBlank()
#endif #endif
g_hInstance = passinstance; GetFrame().g_hInstance = passinstance;
GdiSetBatchLimit(512); GdiSetBatchLimit(512);
LogFileOutput("Init: GdiSetBatchLimit()\n"); LogFileOutput("Init: GdiSetBatchLimit()\n");
@ -848,7 +846,7 @@ static void RepeatInitialization(void)
LogFileOutput("Main: VideoInitialize()\n"); LogFileOutput("Main: VideoInitialize()\n");
LogFileOutput("Main: FrameCreateWindow() - pre\n"); LogFileOutput("Main: FrameCreateWindow() - pre\n");
FrameCreateWindow(); // g_hFrameWindow is now valid FrameCreateWindow(); // GetFrame().g_hFrameWindow is now valid
LogFileOutput("Main: FrameCreateWindow() - post\n"); LogFileOutput("Main: FrameCreateWindow() - post\n");
// Init palette color // Init palette color
@ -936,7 +934,7 @@ static void RepeatInitialization(void)
if (!g_bSysClkOK) 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; g_cmdLine.bShutdown = true;
} }
@ -947,7 +945,7 @@ static void RepeatInitialization(void)
: "Unsupported -rom and -f8rom being used at the same time\n"; : "Unsupported -rom and -f8rom being used at the same time\n";
LogFileOutput("%s", msg.c_str()); 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; g_cmdLine.bShutdown = true;
} }
@ -985,7 +983,7 @@ static void RepeatInitialization(void)
if (g_cmdLine.bShutdown) 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) // NB. If shutting down, then don't post any other messages (GH#286)
} }
else else
@ -1007,13 +1005,13 @@ static void RepeatInitialization(void)
if (g_cmdLine.bSetFullScreen) 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; g_cmdLine.bSetFullScreen = false;
} }
if (g_cmdLine.bBoot) 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; g_cmdLine.bBoot = false;
} }
} }
@ -1054,3 +1052,9 @@ IPropertySheet& GetPropertySheet()
static CPropertySheet sg_PropertySheet; static CPropertySheet sg_PropertySheet;
return sg_PropertySheet; return sg_PropertySheet;
} }
FrameBase& GetFrame()
{
static Win32Frame sg_Win32Frame;
return sg_Win32Frame;
}

View File

@ -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.

View File

@ -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);
};

View File

@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h" #include "StdAfx.h"
#include "Windows/WinFrame.h" #include "Windows/WinFrame.h"
#include "Windows/Win32Frame.h"
#include "Windows/AppleWin.h" #include "Windows/AppleWin.h"
#include "Interface.h" #include "Interface.h"
#include "Keyboard.h" #include "Keyboard.h"
@ -119,10 +120,7 @@ static int buttony = BUTTONY;
static HDC g_hFrameDC = (HDC)0; static HDC g_hFrameDC = (HDC)0;
static RECT framerect = {0,0,0,0}; static RECT framerect = {0,0,0,0};
HWND g_hFrameWindow = (HWND)0;
static bool g_bIsFullScreen = false; 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 BOOL helpquit = 0;
static HFONT smallfont = (HFONT)0; static HFONT smallfont = (HFONT)0;
@ -147,7 +145,6 @@ static void SetUsingCursor(BOOL);
static bool FileExists(std::string strFilename); static bool FileExists(std::string strFilename);
bool g_bScrollLock_FullSpeed = false; bool g_bScrollLock_FullSpeed = false;
bool g_bFreshReset = false;
static bool g_bFullScreen32Bit = true; static bool g_bFullScreen32Bit = true;
#if 0 // enable non-integral full-screen scaling #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 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; 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, \ IMAGE_BITMAP,0,0, \
LR_CREATEDIBSECTION | \ LR_CREATEDIBSECTION | \
LR_LOADMAP3DCOLORS | \ 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) { static void DrawButton (HDC passdc, int number) {
FrameReleaseDC(); FrameReleaseDC();
HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow));
int x = buttonx; int x = buttonx;
int y = buttony+number*BUTTONCY; int y = buttony+number*BUTTONCY;
if (number == buttondown) { if (number == buttondown) {
@ -441,7 +438,7 @@ static void DrawButton (HDC passdc, int number) {
NULL); NULL);
} }
if (!passdc) 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 lastx = 0;
static int lasty = 0; static int lasty = 0;
FrameReleaseDC(); 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); #define LINE(x1,y1,x2,y2) MoveToEx(dc,x1,y1,NULL); LineTo(dc,x2,y2);
// ERASE THE OLD CROSSHAIRS // ERASE THE OLD CROSSHAIRS
@ -536,7 +533,7 @@ static void DrawCrosshairs (int x, int y) {
#undef LINE #undef LINE
lastx = x; lastx = x;
lasty = y; lasty = y;
ReleaseDC(g_hFrameWindow,dc); ReleaseDC(GetFrame().g_hFrameWindow,dc);
} }
//=========================================================================== //===========================================================================
@ -546,8 +543,8 @@ static void DrawFrameWindow (bool bPaintingWindow/*=false*/)
FrameReleaseDC(); FrameReleaseDC();
PAINTSTRUCT ps; PAINTSTRUCT ps;
HDC dc = bPaintingWindow HDC dc = bPaintingWindow
? BeginPaint(g_hFrameWindow,&ps) ? BeginPaint(GetFrame().g_hFrameWindow,&ps)
: GetDC(g_hFrameWindow); : GetDC(GetFrame().g_hFrameWindow);
if (!g_bIsFullScreen) if (!g_bIsFullScreen)
{ {
@ -593,12 +590,12 @@ static void DrawFrameWindow (bool bPaintingWindow/*=false*/)
else if (g_nAppMode == MODE_DEBUG) else if (g_nAppMode == MODE_DEBUG)
DebugDisplay(); DebugDisplay();
else else
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
if (bPaintingWindow) if (bPaintingWindow)
EndPaint(g_hFrameWindow,&ps); EndPaint(GetFrame().g_hFrameWindow,&ps);
else else
ReleaseDC(g_hFrameWindow,dc); ReleaseDC(GetFrame().g_hFrameWindow,dc);
} }
@ -615,13 +612,13 @@ bool GetFullScreenShowSubunitStatus(void)
return g_bFullScreen_ShowSubunitStatus; return g_bFullScreen_ShowSubunitStatus;
} }
void SetFullScreenShowSubunitStatus(bool bShow) void Win32Frame::SetFullScreenShowSubunitStatus(bool bShow)
{ {
g_bFullScreen_ShowSubunitStatus = bShow; g_bFullScreen_ShowSubunitStatus = bShow;
} }
//=========================================================================== //===========================================================================
void FrameDrawDiskLEDS( HDC passdc ) void Win32Frame::FrameDrawDiskLEDS( HDC passdc )
{ {
g_eStatusDrive1 = DISK_STATUS_OFF; g_eStatusDrive1 = DISK_STATUS_OFF;
g_eStatusDrive2 = DISK_STATUS_OFF; g_eStatusDrive2 = DISK_STATUS_OFF;
@ -643,7 +640,7 @@ void FrameDrawDiskLEDS( HDC passdc )
// Draw Track/Sector // Draw Track/Sector
FrameReleaseDC(); FrameReleaseDC();
HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow));
int x = buttonx; int x = buttonx;
int y = buttony+BUTTONS*BUTTONCY+1; int y = buttony+BUTTONS*BUTTONCY+1;
@ -675,7 +672,7 @@ void FrameDrawDiskLEDS( HDC passdc )
// Feature Request #201 Show track status // Feature Request #201 Show track status
// https://github.com/AppleWin/AppleWin/issues/201 // https://github.com/AppleWin/AppleWin/issues/201
//=========================================================================== //===========================================================================
void FrameDrawDiskStatus( HDC passdc ) void Win32Frame::FrameDrawDiskStatus( HDC passdc )
{ {
if (mem == NULL) if (mem == NULL)
return; return;
@ -767,7 +764,7 @@ void FrameDrawDiskStatus( HDC passdc )
// Draw Track/Sector // Draw Track/Sector
FrameReleaseDC(); FrameReleaseDC();
HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow));
int x = buttonx; int x = buttonx;
int y = buttony+BUTTONS*BUTTONCY+4; int y = buttony+BUTTONS*BUTTONCY+4;
@ -830,16 +827,16 @@ void FrameDrawDiskStatus( HDC passdc )
//=========================================================================== //===========================================================================
static void DrawStatusArea (HDC passdc, int drawflags) 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: // TC: Fix drawing of drive buttons before frame created:
// . Main init loop: LoadConfiguration() called before FrameCreateWindow(), eg: // . Main init loop: LoadConfiguration() called before FrameCreateWindow(), eg:
// LoadConfiguration() -> Disk_LoadLastDiskImage() -> DiskInsert() -> FrameRefreshStatus() // LoadConfiguration() -> Disk_LoadLastDiskImage() -> DiskInsert() -> GetFrame().FrameRefreshStatus()
return; return;
} }
FrameReleaseDC(); FrameReleaseDC();
HDC dc = (passdc ? passdc : GetDC(g_hFrameWindow)); HDC dc = (passdc ? passdc : GetDC(GetFrame().g_hFrameWindow));
int x = buttonx; int x = buttonx;
int y = buttony+BUTTONS*BUTTONCY+1; int y = buttony+BUTTONS*BUTTONCY+1;
const bool bCaps = KeybGetCapsStatus(); const bool bCaps = KeybGetCapsStatus();
@ -864,7 +861,7 @@ static void DrawStatusArea (HDC passdc, int drawflags)
SelectObject(dc,smallfont); SelectObject(dc,smallfont);
if (drawflags & DRAW_DISK_STATUS) if (drawflags & DRAW_DISK_STATUS)
FrameDrawDiskStatus( dc ); GetFrame().FrameDrawDiskStatus( dc );
#if HD_LED #if HD_LED
SetTextAlign(dc, TA_RIGHT | TA_TOP); SetTextAlign(dc, TA_RIGHT | TA_TOP);
@ -931,10 +928,10 @@ static void DrawStatusArea (HDC passdc, int drawflags)
if (drawflags & DRAW_LEDS) if (drawflags & DRAW_LEDS)
{ {
FrameDrawDiskLEDS( dc ); GetFrame().FrameDrawDiskLEDS( dc );
if (drawflags & DRAW_DISK_STATUS) if (drawflags & DRAW_DISK_STATUS)
FrameDrawDiskStatus( dc ); GetFrame().FrameDrawDiskStatus( dc );
if (!IS_APPLE2) if (!IS_APPLE2)
{ {
@ -962,7 +959,7 @@ static void DrawStatusArea (HDC passdc, int drawflags)
if (drawflags & DRAW_TITLE) if (drawflags & DRAW_TITLE)
{ {
GetAppleWindowTitle(); // SetWindowText() // WindowTitle 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) if (drawflags & DRAW_BUTTON_DRIVES)
@ -973,7 +970,7 @@ static void DrawStatusArea (HDC passdc, int drawflags)
} }
if (!passdc) 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.top = buttony+number*BUTTONCY;
rect.bottom = rect.top+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) 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); LogFileOutput("KillTimer(g_TimerIDEvent_100msec), res=%d\n", bRes ? 1 : 0);
g_TimerIDEvent_100msec = 0; g_TimerIDEvent_100msec = 0;
} }
@ -1078,7 +1075,7 @@ LRESULT CALLBACK FrameWndProc (
case WM_CREATE: case WM_CREATE:
LogFileOutput("WM_CREATE\n"); LogFileOutput("WM_CREATE\n");
g_hFrameWindow = window; // NB. g_hFrameWindow by CreateWindow() GetFrame().g_hFrameWindow = window; // NB. g_hFrameWindow by CreateWindow()
CreateGdiObjects(); CreateGdiObjects();
LogFileOutput("WM_CREATE: CreateGdiObjects()\n"); LogFileOutput("WM_CREATE: CreateGdiObjects()\n");
@ -1191,7 +1188,7 @@ LRESULT CALLBACK FrameWndProc (
if (wparam == VK_SNAPSHOT_560) if (wparam == VK_SNAPSHOT_560)
{ {
#if _DEBUG #if _DEBUG
// MessageBox( g_hFrameWindow, "Double 580x384 size!", "PrintScreen", MB_OK ); // MessageBox( GetFrame().g_hFrameWindow, "Double 580x384 size!", "PrintScreen", MB_OK );
#endif #endif
Video_TakeScreenShot( SCREENSHOT_560x384 ); Video_TakeScreenShot( SCREENSHOT_560x384 );
} }
@ -1199,7 +1196,7 @@ LRESULT CALLBACK FrameWndProc (
if (wparam == VK_SNAPSHOT_280) // ( lparam & MOD_SHIFT ) if (wparam == VK_SNAPSHOT_280) // ( lparam & MOD_SHIFT )
{ {
#if _DEBUG #if _DEBUG
// MessageBox( g_hFrameWindow, "Normal 280x192 size!", "PrintScreen", MB_OK ); // MessageBox( GetFrame().g_hFrameWindow, "Normal 280x192 size!", "PrintScreen", MB_OK );
#endif #endif
Video_TakeScreenShot( SCREENSHOT_280x192 ); Video_TakeScreenShot( SCREENSHOT_280x192 );
} }
@ -1336,7 +1333,7 @@ LRESULT CALLBACK FrameWndProc (
} }
DrawStatusArea((HDC)0,DRAW_TITLE); DrawStatusArea((HDC)0,DRAW_TITLE);
if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
} }
else if ((wparam == VK_SCROLL) && GetPropertySheet().GetScrollLockToggle()) else if ((wparam == VK_SCROLL) && GetPropertySheet().GetScrollLockToggle())
{ {
@ -1440,7 +1437,7 @@ LRESULT CALLBACK FrameWndProc (
const int iDrive = wparam - VK_F3; const int iDrive = wparam - VK_F3;
ProcessDiskPopupMenu( window, pt, iDrive ); ProcessDiskPopupMenu( window, pt, iDrive );
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
DrawButton((HDC)0, iButton); DrawButton((HDC)0, iButton);
} }
else else
@ -1511,7 +1508,7 @@ LRESULT CALLBACK FrameWndProc (
POINT Point; POINT Point;
GetCursorPos(&Point); GetCursorPos(&Point);
ScreenToClient(g_hFrameWindow, &Point); ScreenToClient(GetFrame().g_hFrameWindow, &Point);
const int iOutOfBoundsX=0, iOutOfBoundsY=0; const int iOutOfBoundsX=0, iOutOfBoundsY=0;
UpdateMouseInAppleViewport(iOutOfBoundsX, iOutOfBoundsY, Point.x, Point.y); UpdateMouseInAppleViewport(iOutOfBoundsX, iOutOfBoundsY, Point.x, Point.y);
@ -1748,7 +1745,7 @@ LRESULT CALLBACK FrameWndProc (
ProcessDiskPopupMenu( window, pt, iDrive ); ProcessDiskPopupMenu( window, pt, iDrive );
} }
FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); GetFrame().FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES);
DrawButton((HDC)0, iButton); DrawButton((HDC)0, iButton);
} }
} }
@ -1941,10 +1938,10 @@ static void ScreenWindowResize(const bool bCtrlKey)
static bool ConfirmReboot(bool bFromButtonUI) static bool ConfirmReboot(bool bFromButtonUI)
{ {
if (!bFromButtonUI || !g_bConfirmReboot) if (!bFromButtonUI || !GetFrame().g_bConfirmReboot)
return true; return true;
int res = MessageBox(g_hFrameWindow, int res = MessageBox(GetFrame().g_hFrameWindow,
"Are you sure you want to reboot?\n" "Are you sure you want to reboot?\n"
"(All data will be lost!)\n" "(All data will be lost!)\n"
"\n" "\n"
@ -1982,7 +1979,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
DeleteFile(filename_with_zone_identifier.c_str()); 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; helpquit = 1;
} }
break; break;
@ -2019,7 +2016,7 @@ static void ProcessButtonClick(int button, bool bFromButtonUI /*=false*/)
} }
DrawStatusArea((HDC)0,DRAW_TITLE); DrawStatusArea((HDC)0,DRAW_TITLE);
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
break; break;
case BTN_DRIVE1: 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 // Load the menu template containing the shortcut menu from the
// application's resources. // 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) if (hmenu == NULL)
return; 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("\"\"") == false) //Do not use this, for some reason it does not work!!!
if(!filename1.compare(sFileNameEmpty) ) 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 (MB_Result == IDYES)
{ {
if (FileExists (PathToCiderPress )) if (FileExists (PathToCiderPress ))
@ -2185,7 +2182,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive)
} }
else 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 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) if (g_bIsFullScreen)
return; return;
MSG msg; MSG msg;
msg.hwnd = g_hFrameWindow; msg.hwnd = GetFrame().g_hFrameWindow;
msg.message = message; msg.message = message;
msg.wParam = wparam; msg.wParam = wparam;
msg.lParam = lparam; msg.lParam = lparam;
@ -2247,14 +2244,14 @@ void SetFullScreenMode ()
buttonover = -1; buttonover = -1;
g_main_window_saved_style = GetWindowLong(g_hFrameWindow, GWL_STYLE); g_main_window_saved_style = GetWindowLong(GetFrame().g_hFrameWindow, GWL_STYLE);
g_main_window_saved_exstyle = GetWindowLong(g_hFrameWindow, GWL_EXSTYLE); g_main_window_saved_exstyle = GetWindowLong(GetFrame().g_hFrameWindow, GWL_EXSTYLE);
GetWindowRect(g_hFrameWindow, &g_main_window_saved_rect); GetWindowRect(GetFrame().g_hFrameWindow, &g_main_window_saved_rect);
SetWindowLong(g_hFrameWindow, GWL_STYLE , g_main_window_saved_style & ~(WS_CAPTION | WS_THICKFRAME)); SetWindowLong(GetFrame().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)); 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); 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; left = monitor_info.rcMonitor.left;
top = monitor_info.rcMonitor.top; top = monitor_info.rcMonitor.top;
@ -2268,17 +2265,17 @@ void SetFullScreenMode ()
g_win_fullscreen_scale = (scalex <= scaley) ? scalex : scaley; g_win_fullscreen_scale = (scalex <= scaley) ? scalex : scaley;
g_win_fullscreen_offsetx = ((int)width - (int)(g_win_fullscreen_scale * GetFrameBufferBorderlessWidth())) / 2; 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; 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; g_bIsFullScreen = true;
SetViewportScale(g_win_fullscreen_scale, true); GetFrame().SetViewportScale(g_win_fullscreen_scale, true);
buttonx = GetFullScreenOffsetX() + g_nViewportCX + VIEWPORTX*2; buttonx = GetFullScreenOffsetX() + g_nViewportCX + VIEWPORTX*2;
buttony = GetFullScreenOffsetY(); buttony = GetFullScreenOffsetY();
viewportx = VIEWPORTX; // TC-TODO: Should be zero too? (Since there's no 3D border in full-screen) viewportx = VIEWPORTX; // TC-TODO: Should be zero too? (Since there's no 3D border in full-screen)
viewporty = 0; // GH#464 viewporty = 0; // GH#464
InvalidateRect(g_hFrameWindow,NULL,1); InvalidateRect(GetFrame().g_hFrameWindow,NULL,1);
#endif // NO_DIRECT_X #endif // NO_DIRECT_X
} }
@ -2297,9 +2294,9 @@ void SetNormalMode ()
g_win_fullscreen_offsetx = 0; g_win_fullscreen_offsetx = 0;
g_win_fullscreen_offsety = 0; g_win_fullscreen_offsety = 0;
g_win_fullscreen_scale = 1; g_win_fullscreen_scale = 1;
SetWindowLong(g_hFrameWindow, GWL_STYLE, g_main_window_saved_style); SetWindowLong(GetFrame().g_hFrameWindow, GWL_STYLE, g_main_window_saved_style);
SetWindowLong(g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle); SetWindowLong(GetFrame().g_hFrameWindow, GWL_EXSTYLE, g_main_window_saved_exstyle);
SetWindowPos(g_hFrameWindow, NULL, SetWindowPos(GetFrame().g_hFrameWindow, NULL,
g_main_window_saved_rect.left, g_main_window_saved_rect.left,
g_main_window_saved_rect.top, g_main_window_saved_rect.top,
g_main_window_saved_rect.right - g_main_window_saved_rect.left, g_main_window_saved_rect.right - g_main_window_saved_rect.left,
@ -2321,18 +2318,18 @@ static void SetUsingCursor (BOOL bNewValue)
// Set TRUE when: // Set TRUE when:
// . Using mouse for joystick emulation // . Using mouse for joystick emulation
// . Using mousecard and mouse is restricted to window // . Using mousecard and mouse is restricted to window
SetCapture(g_hFrameWindow); SetCapture(GetFrame().g_hFrameWindow);
RECT rect = { viewportx+2, // left RECT rect = { viewportx+2, // left
viewporty+2, // top viewporty+2, // top
viewportx+g_nViewportCX-1, // right viewportx+g_nViewportCX-1, // right
viewporty+g_nViewportCY-1}; // bottom viewporty+g_nViewportCY-1}; // bottom
ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.left); ClientToScreen(GetFrame().g_hFrameWindow,(LPPOINT)&rect.left);
ClientToScreen(g_hFrameWindow,(LPPOINT)&rect.right); ClientToScreen(GetFrame().g_hFrameWindow,(LPPOINT)&rect.right);
ClipCursor(&rect); ClipCursor(&rect);
FrameShowCursor(FALSE); FrameShowCursor(FALSE);
POINT pt; POINT pt;
GetCursorPos(&pt); GetCursorPos(&pt);
ScreenToClient(g_hFrameWindow,&pt); ScreenToClient(GetFrame().g_hFrameWindow,&pt);
DrawCrosshairs(pt.x,pt.y); DrawCrosshairs(pt.x,pt.y);
} }
else else
@ -2349,7 +2346,7 @@ int GetViewportScale(void)
return g_nViewportScale; return g_nViewportScale;
} }
int SetViewportScale(int nNewScale, bool bForce /*=false*/) int Win32Frame::SetViewportScale(int nNewScale, bool bForce /*=false*/)
{ {
if (!bForce && nNewScale > g_nMaxViewportScale) if (!bForce && nNewScale > g_nMaxViewportScale)
nNewScale = g_nMaxViewportScale; nNewScale = g_nMaxViewportScale;
@ -2366,8 +2363,8 @@ static void SetupTooltipControls(void)
TOOLINFO toolinfo; TOOLINFO toolinfo;
toolinfo.cbSize = sizeof(toolinfo); toolinfo.cbSize = sizeof(toolinfo);
toolinfo.uFlags = TTF_CENTERTIP; toolinfo.uFlags = TTF_CENTERTIP;
toolinfo.hwnd = g_hFrameWindow; toolinfo.hwnd = GetFrame().g_hFrameWindow;
toolinfo.hinst = g_hInstance; toolinfo.hinst = GetFrame().g_hInstance;
toolinfo.lpszText = LPSTR_TEXTCALLBACK; toolinfo.lpszText = LPSTR_TEXTCALLBACK;
toolinfo.rect.left = BUTTONX; toolinfo.rect.left = BUTTONX;
toolinfo.rect.right = toolinfo.rect.left+BUTTONCX+1; toolinfo.rect.right = toolinfo.rect.left+BUTTONCX+1;
@ -2417,9 +2414,9 @@ static void FrameResizeWindow(int nNewScale)
int nOldWidth, nOldHeight; int nOldWidth, nOldHeight;
GetWidthHeight(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 nXPos = framerect.left;
int nYPos = framerect.top; int nYPos = framerect.top;
@ -2434,20 +2431,20 @@ static void FrameResizeWindow(int nNewScale)
irect.left = irect.top = 0; irect.left = irect.top = 0;
irect.right = nOldWidth; irect.right = nOldWidth;
irect.bottom = nOldHeight; irect.bottom = nOldHeight;
InvalidateRect(g_hFrameWindow, &irect, TRUE); InvalidateRect(GetFrame().g_hFrameWindow, &irect, TRUE);
} }
// Resize the window // Resize the window
int nNewWidth, nNewHeight; int nNewWidth, nNewHeight;
GetWidthHeight(nNewWidth, nNewHeight); GetWidthHeight(nNewWidth, nNewHeight);
MoveWindow(g_hFrameWindow, nXPos, nYPos, nNewWidth, nNewHeight, TRUE); MoveWindow(GetFrame().g_hFrameWindow, nXPos, nYPos, nNewWidth, nNewHeight, TRUE);
UpdateWindow(g_hFrameWindow); UpdateWindow(GetFrame().g_hFrameWindow);
// Remove the tooltips for the old window size // Remove the tooltips for the old window size
TOOLINFO toolinfo = {0}; TOOLINFO toolinfo = {0};
toolinfo.cbSize = sizeof(toolinfo); toolinfo.cbSize = sizeof(toolinfo);
toolinfo.hwnd = g_hFrameWindow; toolinfo.hwnd = GetFrame().g_hFrameWindow;
toolinfo.uId = 0; toolinfo.uId = 0;
SendMessage(tooltipwindow, TTM_DELTOOL, 0, (LPARAM)&toolinfo); SendMessage(tooltipwindow, TTM_DELTOOL, 0, (LPARAM)&toolinfo);
toolinfo.uId = 1; toolinfo.uId = 1;
@ -2489,7 +2486,7 @@ void FrameCreateWindow(void)
if (g_nViewportScale == 2 && (nWidth > GetSystemMetrics(SM_CXSCREEN) || nHeight > GetSystemMetrics(SM_CYSCREEN))) if (g_nViewportScale == 2 && (nWidth > GetSystemMetrics(SM_CXSCREEN) || nHeight > GetSystemMetrics(SM_CYSCREEN)))
{ {
g_nMaxViewportScale = 1; g_nMaxViewportScale = 1;
SetViewportScale(1); GetFrame().SetViewportScale(1);
GetWidthHeight(nWidth, nHeight); 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 (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 nXPos = -1; // Not fully visible, so default to centre position
} }
if ((nXPos == -1) && !g_bMultiMon) if ((nXPos == -1) && !GetFrame().g_bMultiMon)
nXPos = nXScreen / 2; 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 (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 nYPos = -1; // Not fully visible, so default to centre position
} }
if ((nYPos == -1) && !g_bMultiMon) if ((nYPos == -1) && !GetFrame().g_bMultiMon)
nYPos = nYScreen / 2; nYPos = nYScreen / 2;
} }
@ -2531,7 +2528,7 @@ void FrameCreateWindow(void)
GetAppleWindowTitle(); GetAppleWindowTitle();
// NB. g_hFrameWindow also set by WM_CREATE - NB. CreateWindow() must synchronously send WM_CREATE // NB. g_hFrameWindow also set by WM_CREATE - NB. CreateWindow() must synchronously send WM_CREATE
g_hFrameWindow = CreateWindow( GetFrame().g_hFrameWindow = CreateWindow(
TEXT("APPLE2FRAME"), TEXT("APPLE2FRAME"),
g_pAppTitle.c_str(), g_pAppTitle.c_str(),
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
@ -2539,27 +2536,27 @@ void FrameCreateWindow(void)
nXPos, nYPos, nWidth, nHeight, nXPos, nYPos, nWidth, nHeight,
HWND_DESKTOP, HWND_DESKTOP,
(HMENU)0, (HMENU)0,
g_hInstance, NULL ); GetFrame().g_hInstance, NULL );
InitCommonControls(); InitCommonControls();
tooltipwindow = CreateWindow( tooltipwindow = CreateWindow(
TOOLTIPS_CLASS,NULL,TTS_ALWAYSTIP, TOOLTIPS_CLASS,NULL,TTS_ALWAYSTIP,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
g_hFrameWindow, GetFrame().g_hFrameWindow,
(HMENU)0, (HMENU)0,
g_hInstance,NULL ); GetFrame().g_hInstance,NULL );
SetupTooltipControls(); SetupTooltipControls();
_ASSERT(g_TimerIDEvent_100msec == 0); _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); LogFileOutput("FrameCreateWindow: SetTimer(), id=0x%08X\n", g_TimerIDEvent_100msec);
} }
//=========================================================================== //===========================================================================
HDC FrameGetDC () { HDC FrameGetDC () {
if (!g_hFrameDC) { if (!g_hFrameDC) {
g_hFrameDC = GetDC(g_hFrameWindow); g_hFrameDC = GetDC(GetFrame().g_hFrameWindow);
SetViewportOrgEx(g_hFrameDC,viewportx,viewporty,NULL); SetViewportOrgEx(g_hFrameDC,viewportx,viewporty,NULL);
} }
return g_hFrameDC; return g_hFrameDC;
@ -2569,13 +2566,13 @@ HDC FrameGetDC () {
void FrameReleaseDC () { void FrameReleaseDC () {
if (g_hFrameDC) { if (g_hFrameDC) {
SetViewportOrgEx(g_hFrameDC,0,0,NULL); SetViewportOrgEx(g_hFrameDC,0,0,NULL);
ReleaseDC(g_hFrameWindow,g_hFrameDC); ReleaseDC(GetFrame().g_hFrameWindow,g_hFrameDC);
g_hFrameDC = (HDC)0; 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. // NB. 99% of the time we draw the disk status. On DiskDriveSwap() we don't.
drawflags |= bUpdateDiskStatus ? DRAW_DISK_STATUS : 0; drawflags |= bUpdateDiskStatus ? DRAW_DISK_STATUS : 0;
DrawStatusArea((HDC)0,drawflags); DrawStatusArea((HDC)0,drawflags);
@ -2588,15 +2585,15 @@ void FrameRegisterClass () {
wndclass.cbSize = sizeof(WNDCLASSEX); wndclass.cbSize = sizeof(WNDCLASSEX);
wndclass.style = CS_OWNDC | CS_BYTEALIGNCLIENT; wndclass.style = CS_OWNDC | CS_BYTEALIGNCLIENT;
wndclass.lpfnWndProc = FrameWndProc; wndclass.lpfnWndProc = FrameWndProc;
wndclass.hInstance = g_hInstance; wndclass.hInstance = GetFrame().g_hInstance;
wndclass.hIcon = LoadIcon(g_hInstance,TEXT("APPLEWIN_ICON")); wndclass.hIcon = LoadIcon(GetFrame().g_hInstance,TEXT("APPLEWIN_ICON"));
wndclass.hCursor = LoadCursor(0,IDC_ARROW); wndclass.hCursor = LoadCursor(0,IDC_ARROW);
wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
#if ENABLE_MENU #if ENABLE_MENU
wndclass.lpszMenuName = (LPCSTR)IDR_MENU1; wndclass.lpszMenuName = (LPCSTR)IDR_MENU1;
#endif #endif
wndclass.lpszClassName = TEXT("APPLE2FRAME"); 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); IMAGE_ICON,16,16,LR_DEFAULTCOLOR);
RegisterClassEx(&wndclass); RegisterClassEx(&wndclass);
} }
@ -2615,13 +2612,13 @@ static bool FileExists(std::string strFilename)
// Called when: // Called when:
// . Mouse f/w sets abs position // . Mouse f/w sets abs position
// . UpdateMouseInAppleViewport() is called and inside Apple screen // . 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 // _ASSERT(GetCardMgr().IsMouseCardInstalled()); // CMouseInterface::ctor calls this function, ie. before GetCardMgr()::m_pMouseCard is setup
if (!GetCardMgr().IsMouseCardInstalled()) if (!GetCardMgr().IsMouseCardInstalled())
return; return;
if (!g_hFrameWindow || g_bShowingCursor) if (!GetFrame().g_hFrameWindow || g_bShowingCursor)
return; return;
int iX, iMinX, iMaxX; int iX, iMinX, iMaxX;
@ -2635,7 +2632,7 @@ void FrameSetCursorPosByMousePos()
int iWindowY = (int)(fScaleY * (float)g_nViewportCY); int iWindowY = (int)(fScaleY * (float)g_nViewportCY);
POINT Point = {viewportx+2, viewporty+2}; // top-left 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); SetCursorPos(Point.x+iWindowX-VIEWPORTX, Point.y+iWindowY-VIEWPORTY);
#if defined(_DEBUG) && 0 // OutputDebugString() when cursor position changes since last time #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; return;
// char szDbg[200]; // char szDbg[200];
if (!g_hFrameWindow || (g_bShowingCursor && bLeavingAppleScreen) || (!g_bShowingCursor && !bLeavingAppleScreen)) if (!GetFrame().g_hFrameWindow || (g_bShowingCursor && bLeavingAppleScreen) || (!g_bShowingCursor && !bLeavingAppleScreen))
return; return;
int iX, iMinX, iMaxX; 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; int iWindowY = (int)(fScaleY * (float)g_nViewportCY) + dy;
POINT Point = {viewportx+2, viewporty+2}; // top-left 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); 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); // 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 else
{ {
FrameSetCursorPosByMousePos(); // Set cursor to Apple position each time GetFrame().FrameSetCursorPosByMousePos(); // Set cursor to Apple position each time
} }
DrawCrosshairsMouse(); DrawCrosshairsMouse();
@ -2795,7 +2792,7 @@ void GetViewportCXCY(int& nViewportCX, int& nViewportCY)
} }
// Call all funcs with dependency on g_Apple2Type // Call all funcs with dependency on g_Apple2Type
void FrameUpdateApple2Type(void) void Win32Frame::FrameUpdateApple2Type(void)
{ {
DeleteGdiObjects(); DeleteGdiObjects();
CreateGdiObjects(); CreateGdiObjects();
@ -2808,7 +2805,7 @@ void FrameUpdateApple2Type(void)
DrawFrameWindow(); 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<UINT,UINT> > VEC_PAIR; typedef std::vector< std::pair<UINT,UINT> > VEC_PAIR;
VEC_PAIR vecDisplayResolutions; VEC_PAIR vecDisplayResolutions;

View File

@ -29,6 +29,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "StdAfx.h" #include "StdAfx.h"
#include "Windows/WinVideo.h" #include "Windows/WinVideo.h"
#include "Windows/Win32Frame.h"
#include "Windows/WinFrame.h" #include "Windows/WinFrame.h"
#include "Windows/AppleWin.h" #include "Windows/AppleWin.h"
#include "Interface.h" #include "Interface.h"
@ -90,7 +91,7 @@ void WinVideoInitialize()
VideoResetState(); VideoResetState();
// LOAD THE LOGO // 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 // CREATE A BITMAPINFO STRUCTURE FOR THE FRAME BUFFER
g_pFramebufferinfo = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)]; g_pFramebufferinfo = (LPBITMAPINFO) new BYTE[sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD)];
@ -153,7 +154,7 @@ void VideoBenchmark () {
g_uVideoMode = VF_TEXT; g_uVideoMode = VF_TEXT;
memset(mem+0x400,0x14,0x400); memset(mem+0x400,0x14,0x400);
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
DWORD milliseconds = GetTickCount(); DWORD milliseconds = GetTickCount();
while (GetTickCount() == milliseconds) ; while (GetTickCount() == milliseconds) ;
milliseconds = GetTickCount(); milliseconds = GetTickCount();
@ -175,7 +176,7 @@ void VideoBenchmark () {
DWORD totalhiresfps = 0; DWORD totalhiresfps = 0;
g_uVideoMode = VF_HIRES; g_uVideoMode = VF_HIRES;
memset(mem+0x2000,0x14,0x2000); memset(mem+0x2000,0x14,0x2000);
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
milliseconds = GetTickCount(); milliseconds = GetTickCount();
while (GetTickCount() == milliseconds) ; while (GetTickCount() == milliseconds) ;
milliseconds = GetTickCount(); milliseconds = GetTickCount();
@ -209,7 +210,7 @@ void VideoBenchmark () {
// IF THE PROGRAM COUNTER IS NOT IN THE EXPECTED RANGE AT THE END OF THE // 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 // CPU BENCHMARK, REPORT AN ERROR AND OPTIONALLY TRACK IT DOWN
if ((regs.pc < 0x300) || (regs.pc > 0x400)) 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 emulator has detected a problem while running ")
TEXT("the CPU benchmark. Would you like to gather more ") TEXT("the CPU benchmark. Would you like to gather more ")
TEXT("information?"), TEXT("information?"),
@ -238,13 +239,13 @@ void VideoBenchmark () {
(unsigned)loop, (unsigned)loop,
(unsigned)lastpc, (unsigned)lastpc,
(unsigned)regs.pc); (unsigned)regs.pc);
MessageBox(g_hFrameWindow, MessageBox(GetFrame().g_hFrameWindow,
outstr, outstr,
TEXT("Benchmarks"), TEXT("Benchmarks"),
MB_ICONINFORMATION | MB_SETFOREGROUND); MB_ICONINFORMATION | MB_SETFOREGROUND);
} }
else else
MessageBox(g_hFrameWindow, MessageBox(GetFrame().g_hFrameWindow,
TEXT("The emulator was unable to locate the exact ") TEXT("The emulator was unable to locate the exact ")
TEXT("point of the error. This probably means that ") TEXT("point of the error. This probably means that ")
TEXT("the problem is external to the emulator, ") TEXT("the problem is external to the emulator, ")
@ -259,7 +260,7 @@ void VideoBenchmark () {
// THE SAME TIME // THE SAME TIME
DWORD realisticfps = 0; DWORD realisticfps = 0;
memset(mem+0x2000,0xAA,0x2000); memset(mem+0x2000,0xAA,0x2000);
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
milliseconds = GetTickCount(); milliseconds = GetTickCount();
while (GetTickCount() == milliseconds) ; while (GetTickCount() == milliseconds) ;
milliseconds = GetTickCount(); milliseconds = GetTickCount();
@ -278,7 +279,7 @@ void VideoBenchmark () {
memset(mem+0x2000,0xAA,0x2000); memset(mem+0x2000,0xAA,0x2000);
else else
memcpy(mem+0x2000,mem+((cycle & 2) ? 0x4000 : 0x6000),0x2000); memcpy(mem+0x2000,mem+((cycle & 2) ? 0x4000 : 0x6000),0x2000);
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
if (cycle++ >= 3) if (cycle++ >= 3)
cycle = 0; cycle = 0;
realisticfps++; realisticfps++;
@ -298,7 +299,7 @@ void VideoBenchmark () {
(unsigned)(totalmhz10[0] / 10), (unsigned)(totalmhz10[0] % 10), (LPCTSTR)(IS_APPLE2 ? TEXT(" (6502)") : TEXT("")), (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)(totalmhz10[1] / 10), (unsigned)(totalmhz10[1] % 10), (LPCTSTR)(IS_APPLE2 ? TEXT(" (6502)") : TEXT("")),
(unsigned)realisticfps); (unsigned)realisticfps);
MessageBox(g_hFrameWindow, MessageBox(GetFrame().g_hFrameWindow,
outstr, outstr,
TEXT("Benchmarks"), TEXT("Benchmarks"),
MB_ICONINFORMATION | MB_SETFOREGROUND); MB_ICONINFORMATION | MB_SETFOREGROUND);
@ -311,7 +312,7 @@ void VideoChooseMonochromeColor ()
CHOOSECOLOR cc; CHOOSECOLOR cc;
memset(&cc, 0, sizeof(CHOOSECOLOR)); memset(&cc, 0, sizeof(CHOOSECOLOR));
cc.lStructSize = sizeof(CHOOSECOLOR); cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = g_hFrameWindow; cc.hwndOwner = GetFrame().g_hFrameWindow;
cc.rgbResult = g_nMonochromeRGB; cc.rgbResult = g_nMonochromeRGB;
cc.lpCustColors = customcolors + 1; cc.lpCustColors = customcolors + 1;
cc.Flags = CC_RGBINIT | CC_SOLIDCOLOR; cc.Flags = CC_RGBINIT | CC_SOLIDCOLOR;
@ -321,7 +322,7 @@ void VideoChooseMonochromeColor ()
VideoReinitialize(); VideoReinitialize();
if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG)) if ((g_nAppMode != MODE_LOGO) && (g_nAppMode != MODE_DEBUG))
{ {
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
} }
Config_Save_Video(); Config_Save_Video();
} }
@ -489,12 +490,12 @@ void VideoRedrawScreenDuringFullSpeed(DWORD dwCyclesThisFrame, bool bInit /*=fal
void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame) void VideoRedrawScreenAfterFullSpeed(DWORD dwCyclesThisFrame)
{ {
NTSC_VideoClockResync(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. // 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 ); VideoRefreshScreen( g_uVideoMode, true );
@ -632,6 +633,6 @@ void Video_RedrawAndTakeScreenShot(const char* pScreenshotFilename)
if (!pScreenshotFilename) if (!pScreenshotFilename)
return; return;
VideoRedrawScreen(); GetFrame().VideoRedrawScreen();
Video_SaveScreenShot(SCREENSHOT_560x384, pScreenshotFilename); Video_SaveScreenShot(SCREENSHOT_560x384, pScreenshotFilename);
} }