From 787aba9b4ec6f83a3bc703a36c4c83cdd8e6ac0d Mon Sep 17 00:00:00 2001 From: mpohoreski Date: Sun, 2 Jul 2006 09:56:50 +0000 Subject: [PATCH] instance -> g_hInstance --- source/Applewin.cpp | 7 +++-- source/Applewin.h | 4 ++- source/Disk.cpp | 2 +- source/Frame.cpp | 38 +++++++++++++++------------ source/Frame.h | 2 ++ source/Harddisk.cpp | 2 +- source/PropertySheetPage.cpp | 14 +++++----- source/Video.cpp | 50 ++++++++++++++++++------------------ source/Video.h | 23 +++++++++++++++++ 9 files changed, 88 insertions(+), 54 deletions(-) diff --git a/source/Applewin.cpp b/source/Applewin.cpp index f6f0efdc..58f4cc4b 100644 --- a/source/Applewin.cpp +++ b/source/Applewin.cpp @@ -42,7 +42,10 @@ DWORD cyclenum = 0; // Used by SpkrToggle() for non-wave sound DWORD emulmsec = 0; static DWORD emulmsec_frac = 0; bool g_bFullSpeed = false; -HINSTANCE instance = (HINSTANCE)0; + +// Win32 +HINSTANCE g_hInstance = (HINSTANCE)0; + static DWORD lastfastpaging = 0; static DWORD lasttrimimages = 0; @@ -639,7 +642,7 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int) // DSInit(); // Done when g_hFrameWindow is created (WM_CREATE) // DO ONE-TIME INITIALIZATION - instance = passinstance; + g_hInstance = passinstance; GdiSetBatchLimit(512); GetProgramDirectory(); RegisterExtensions(); diff --git a/source/Applewin.h b/source/Applewin.h index 5b830ff9..3164ab9d 100644 --- a/source/Applewin.h +++ b/source/Applewin.h @@ -12,7 +12,9 @@ extern DWORD cumulativecycles; extern DWORD cyclenum; extern DWORD emulmsec; extern bool g_bFullSpeed; -extern HINSTANCE instance; + +// Win32 +extern HINSTANCE g_hInstance; extern AppMode_e g_nAppMode; diff --git a/source/Disk.cpp b/source/Disk.cpp index 876a9ce7..e1a1d462 100644 --- a/source/Disk.cpp +++ b/source/Disk.cpp @@ -482,7 +482,7 @@ void DiskSelectImage (int drive, LPSTR pszFilename) ZeroMemory(&ofn,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_hFrameWindow; - ofn.hInstance = instance; + ofn.hInstance = g_hInstance; ofn.lpstrFilter = TEXT("All Images\0*.apl;*.bin;*.do;*.dsk;*.iie;*.nib;*.po\0") TEXT("Disk Images (*.bin,*.do,*.dsk,*.iie,*.nib,*.po)\0*.bin;*.do;*.dsk;*.iie;*.nib;*.po\0") TEXT("All Files\0*.*\0"); diff --git a/source/Frame.cpp b/source/Frame.cpp index 683c00fb..f4b0a6a7 100644 --- a/source/Frame.cpp +++ b/source/Frame.cpp @@ -68,7 +68,7 @@ static int buttonover = -1; static int buttonx = BUTTONX; static int buttony = BUTTONY; static HRGN clipregion = (HRGN)0; -static HDC framedc = (HDC)0; +static HDC g_hFrameDC = (HDC)0; static RECT framerect = {0,0,0,0}; HWND g_hFrameWindow = (HWND)0; BOOL fullscreen = 0; @@ -95,7 +95,7 @@ void SetUsingCursor (BOOL); //=========================================================================== void CreateGdiObjects () { ZeroMemory(buttonbitmap,BUTTONS*sizeof(HBITMAP)); -#define LOADBUTTONBITMAP(bitmapname) LoadImage(instance,bitmapname, \ +#define LOADBUTTONBITMAP(bitmapname) LoadImage(g_hInstance,bitmapname, \ IMAGE_BITMAP,0,0, \ LR_CREATEDIBSECTION | \ LR_LOADMAP3DCOLORS | \ @@ -1005,7 +1005,7 @@ void ProcessDiskPopupMenu(HWND hwnd, POINT pt, const int iDrive) // Load the menu template containing the shortcut menu from the // application's resources. - hmenu = LoadMenu(instance, MAKEINTRESOURCE(ID_MENU_DISK_POPUP)); + hmenu = LoadMenu(g_hInstance, MAKEINTRESOURCE(ID_MENU_DISK_POPUP)); if (hmenu == NULL) return; @@ -1201,20 +1201,24 @@ void FrameCreateWindow () WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX | WS_VISIBLE, xpos,ypos,width,height, - HWND_DESKTOP,(HMENU)0,instance,NULL ); + HWND_DESKTOP, + (HMENU)0, + g_hInstance,NULL ); InitCommonControls(); tooltipwindow = CreateWindow( TOOLTIPS_CLASS,NULL,TTS_ALWAYSTIP, CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, - g_hFrameWindow,(HMENU)0,instance,NULL ); + g_hFrameWindow, + (HMENU)0, + g_hInstance,NULL ); TOOLINFO toolinfo; toolinfo.cbSize = sizeof(toolinfo); toolinfo.uFlags = TTF_CENTERTIP; toolinfo.hwnd = g_hFrameWindow; - toolinfo.hinst = instance; + toolinfo.hinst = g_hInstance; toolinfo.lpszText = LPSTR_TEXTCALLBACK; toolinfo.rect.left = BUTTONX; toolinfo.rect.right = toolinfo.rect.left+BUTTONCX+1; @@ -1230,11 +1234,11 @@ void FrameCreateWindow () //=========================================================================== HDC FrameGetDC () { - if (!framedc) { - framedc = GetDC(g_hFrameWindow); - SetViewportOrgEx(framedc,viewportx,viewporty,NULL); + if (!g_hFrameDC) { + g_hFrameDC = GetDC(g_hFrameWindow); + SetViewportOrgEx(g_hFrameDC,viewportx,viewporty,NULL); } - return framedc; + return g_hFrameDC; } //=========================================================================== @@ -1269,25 +1273,25 @@ void FrameRegisterClass () { wndclass.cbSize = sizeof(WNDCLASSEX); wndclass.style = CS_OWNDC | CS_BYTEALIGNCLIENT; wndclass.lpfnWndProc = FrameWndProc; - wndclass.hInstance = instance; - wndclass.hIcon = LoadIcon(instance,TEXT("APPLEWIN_ICON")); + wndclass.hInstance = g_hInstance; + wndclass.hIcon = LoadIcon(g_hInstance,TEXT("APPLEWIN_ICON")); wndclass.hCursor = LoadCursor(0,IDC_ARROW); wndclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); #if ENABLE_MENU wndclass.lpszMenuName = (LPCSTR)IDR_MENU1; #endif wndclass.lpszClassName = TEXT("APPLE2FRAME"); - wndclass.hIconSm = (HICON)LoadImage(instance,TEXT("APPLEWIN_ICON"), + wndclass.hIconSm = (HICON)LoadImage(g_hInstance,TEXT("APPLEWIN_ICON"), IMAGE_ICON,16,16,LR_DEFAULTCOLOR); RegisterClassEx(&wndclass); } //=========================================================================== void FrameReleaseDC () { - if (framedc) { - SetViewportOrgEx(framedc,0,0,NULL); - ReleaseDC(g_hFrameWindow,framedc); - framedc = (HDC)0; + if (g_hFrameDC) { + SetViewportOrgEx(g_hFrameDC,0,0,NULL); + ReleaseDC(g_hFrameWindow,g_hFrameDC); + g_hFrameDC = (HDC)0; } } diff --git a/source/Frame.h b/source/Frame.h index 076fcf98..bc6b32f4 100644 --- a/source/Frame.h +++ b/source/Frame.h @@ -2,7 +2,9 @@ enum {NOT_ASCII=0, ASCII}; +// Win32 extern HWND g_hFrameWindow; + extern BOOL fullscreen; void FrameCreateWindow (); diff --git a/source/Harddisk.cpp b/source/Harddisk.cpp index a1403744..7d781b96 100644 --- a/source/Harddisk.cpp +++ b/source/Harddisk.cpp @@ -321,7 +321,7 @@ void HD_Select(int nDrive) ZeroMemory(&ofn,sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = g_hFrameWindow; - ofn.hInstance = instance; + ofn.hInstance = g_hInstance; ofn.lpstrFilter = TEXT("Hard Disk Images (*.hdv)\0*.hdv\0"); ofn.lpstrFile = filename; ofn.nMaxFile = MAX_PATH; diff --git a/source/PropertySheetPage.cpp b/source/PropertySheetPage.cpp index d49a19db..dc338092 100644 --- a/source/PropertySheetPage.cpp +++ b/source/PropertySheetPage.cpp @@ -722,7 +722,7 @@ static int SaveStateSelectImage(HWND hWindow, TCHAR* pszTitle, bool bSave) ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hWindow; - ofn.hInstance = instance; + ofn.hInstance = g_hInstance; ofn.lpstrFilter = TEXT("Save State files (*.aws)\0*.aws\0") TEXT("All Files\0*.*\0"); ofn.lpstrFile = szFilename; @@ -1185,7 +1185,7 @@ static BOOL CALLBACK TfeDlgProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lpara void ui_tfe_settings_dialog(HWND hwnd) { - DialogBox(instance, (LPCTSTR)IDD_TFE_SETTINGS_DIALOG, hwnd, + DialogBox(g_hInstance, (LPCTSTR)IDD_TFE_SETTINGS_DIALOG, hwnd, TfeDlgProc); } @@ -1198,31 +1198,31 @@ void PSP_Init() PropSheetPages[PG_CONFIG].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_CONFIG].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_CONFIG].hInstance = instance; + PropSheetPages[PG_CONFIG].hInstance = g_hInstance; PropSheetPages[PG_CONFIG].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_CONFIG); PropSheetPages[PG_CONFIG].pfnDlgProc = (DLGPROC)ConfigDlgProc; PropSheetPages[PG_INPUT].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_INPUT].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_INPUT].hInstance = instance; + PropSheetPages[PG_INPUT].hInstance = g_hInstance; PropSheetPages[PG_INPUT].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_INPUT); PropSheetPages[PG_INPUT].pfnDlgProc = (DLGPROC)InputDlgProc; PropSheetPages[PG_SOUND].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_SOUND].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_SOUND].hInstance = instance; + PropSheetPages[PG_SOUND].hInstance = g_hInstance; PropSheetPages[PG_SOUND].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_SOUND); PropSheetPages[PG_SOUND].pfnDlgProc = (DLGPROC)SoundDlgProc; PropSheetPages[PG_SAVESTATE].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_SAVESTATE].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_SAVESTATE].hInstance = instance; + PropSheetPages[PG_SAVESTATE].hInstance = g_hInstance; PropSheetPages[PG_SAVESTATE].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_SAVESTATE); PropSheetPages[PG_SAVESTATE].pfnDlgProc = (DLGPROC)SaveStateDlgProc; PropSheetPages[PG_DISK].dwSize = sizeof(PROPSHEETPAGE); PropSheetPages[PG_DISK].dwFlags = PSP_DEFAULT; - PropSheetPages[PG_DISK].hInstance = instance; + PropSheetPages[PG_DISK].hInstance = g_hInstance; PropSheetPages[PG_DISK].pszTemplate = MAKEINTRESOURCE(IDD_PROPPAGE_DISK); PropSheetPages[PG_DISK].pfnDlgProc = (DLGPROC)DiskDlgProc; diff --git a/source/Video.cpp b/source/Video.cpp index 20ca665e..0f9fae80 100644 --- a/source/Video.cpp +++ b/source/Video.cpp @@ -204,9 +204,6 @@ static LPBYTE g_pHiresBank0; static HBITMAP g_hLogoBitmap; static HPALETTE g_hPalette; - -const int APPLE_FONT_WIDTH = 14; -const int APPLE_FONT_HEIGHT = 16; static HBITMAP g_hSourceBitmap; static LPBYTE g_pSourcePixels; static LPBITMAPINFO g_pSourceHeader; @@ -932,33 +929,36 @@ void DrawMonoLoResSource () { } //=========================================================================== -void DrawMonoTextSource (HDC dc) { - HDC memdc = CreateCompatibleDC(dc); - HBITMAP bitmap = LoadBitmap(instance,TEXT("CHARSET40")); - HBRUSH brush; - switch (videotype) - { - case VT_MONO_AMBER: brush = CreateSolidBrush(RGB(0xFF,0x80,0x00)); break; - case VT_MONO_GREEN: brush = CreateSolidBrush(RGB(0x00,0xC0,0x00)); break; - case VT_MONO_WHITE: brush = CreateSolidBrush(RGB(0xFF,0xFF,0xFF)); break; - default : brush = CreateSolidBrush(monochrome); break; - } - SelectObject(memdc,bitmap); - SelectObject(dc,brush); - BitBlt(dc,SRCOFFS_40COL,0,256,512,memdc,0,0,MERGECOPY); - BitBlt(dc,SRCOFFS_IIPLUS,0,256,256,memdc,0,512,MERGECOPY); - StretchBlt(dc,SRCOFFS_80COL,0,128,512,memdc,0,0,256,512,MERGECOPY); - SelectObject(dc,GetStockObject(NULL_BRUSH)); - DeleteObject(brush); - DeleteDC(memdc); - DeleteObject(bitmap); +void DrawMonoTextSource (HDC hDstDC) +{ + HDC hSrcDC = CreateCompatibleDC(hDstDC); + HBITMAP hBitmap = LoadBitmap(g_hInstance,TEXT("CHARSET40")); + HBRUSH hBrush; + switch (videotype) + { + case VT_MONO_AMBER: hBrush = CreateSolidBrush(RGB(0xFF,0x80,0x00)); break; + case VT_MONO_GREEN: hBrush = CreateSolidBrush(RGB(0x00,0xC0,0x00)); break; + case VT_MONO_WHITE: hBrush = CreateSolidBrush(RGB(0xFF,0xFF,0xFF)); break; + default : hBrush = CreateSolidBrush(monochrome); break; + } + SelectObject(hSrcDC,hBitmap); + SelectObject(hDstDC,hBrush); + + // TODO: Update with APPLE_FONT_Y_ values + BitBlt(hDstDC,SRCOFFS_40COL,0,256,512,hSrcDC,0,0,MERGECOPY); + BitBlt(hDstDC,SRCOFFS_IIPLUS,0,256,256,hSrcDC,0,512,MERGECOPY); + StretchBlt(hDstDC,SRCOFFS_80COL,0,128,512,hSrcDC,0,0,256,512,MERGECOPY); + SelectObject(hDstDC,GetStockObject(NULL_BRUSH)); + DeleteObject(hBrush); + DeleteDC(hSrcDC); + DeleteObject(hBitmap); } //=========================================================================== void DrawTextSource (HDC dc) { HDC memdc = CreateCompatibleDC(dc); - HBITMAP bitmap = LoadBitmap(instance,TEXT("CHARSET40")); + HBITMAP bitmap = LoadBitmap(g_hInstance,TEXT("CHARSET40")); SelectObject(memdc,bitmap); BitBlt( @@ -1774,7 +1774,7 @@ void VideoInitialize () { ZeroMemory(vidlastmem,0x10000); // LOAD THE LOGO - g_hLogoBitmap = (HBITMAP)LoadImage(instance, MAKEINTRESOURCE(IDB_APPLEWIN), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); + g_hLogoBitmap = (HBITMAP)LoadImage(g_hInstance, MAKEINTRESOURCE(IDB_APPLEWIN), IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION); // CREATE A BITMAPINFO STRUCTURE FOR THE FRAME BUFFER framebufferinfo = (LPBITMAPINFO)VirtualAlloc(NULL, diff --git a/source/Video.h b/source/Video.h index 000f90bf..20d1ffb5 100644 --- a/source/Video.h +++ b/source/Video.h @@ -17,6 +17,29 @@ extern BOOL graphicsmode; extern COLORREF monochrome; extern DWORD videotype; +enum AppleFont_e +{ + // 40-Column mode is 2x Zoom (default) + // 80-Column mode is 1.5x Zoom (7 x 16) + // Tiny mode is 1x zoom (7x8) for debugger + APPLE_FONT_WIDTH = 14, // in pixels + APPLE_FONT_HEIGHT = 16, // in pixels + + // Each cell has a reserved aligned pixel area + APPLE_FONT_CELL_WIDTH = 16, + APPLE_FONT_CELL_HEIGHT = 16, + + // The bitmap contains 3 regions + // Each region is 256x256 pixels = 16x16 chars + APPLE_FONT_X_REGIONSIZE = 256, // in pixelx + APPLE_FONT_Y_REGIONSIZE = 256, // in pixels + + // Starting Y offsets (pixels) for the regions + APPLE_FONT_Y_APPLE_2PLUS = 0, // ][+ + APPLE_FONT_Y_APPLE_80COL = 256, // //e (inc. Mouse Text) + APPLE_FONT_Y_APPLE_40COL = 512, // ][ +}; + void CreateColorMixMap(); BOOL VideoApparentlyDirty ();