added global: g_pAppTitle

removed: define TITLE
indentation cleanup
This commit is contained in:
mpohoreski 2006-06-27 02:34:46 +00:00
parent dbbb5df19d
commit 9135e6e908
6 changed files with 160 additions and 121 deletions

View File

@ -31,6 +31,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
char VERSIONSTRING[] = "xx.yy.zz.ww"; char VERSIONSTRING[] = "xx.yy.zz.ww";
TCHAR *g_pAppTitle = TITLE_APPLE_2_E;
bool g_bApple2e = true; bool g_bApple2e = true;
bool g_bApple2plus = true; bool g_bApple2plus = true;

View File

@ -2,6 +2,8 @@
extern char VERSIONSTRING[]; // Contructed in WinMain() extern char VERSIONSTRING[]; // Contructed in WinMain()
extern TCHAR *g_pAppTitle;
extern bool g_bApple2e; extern bool g_bApple2e;
extern bool g_bApple2plus; extern bool g_bApple2plus;

View File

@ -56,7 +56,8 @@ enum AppMode_e
#define TITLE_APPLE_2 TEXT("Apple ][ Emulator") #define TITLE_APPLE_2 TEXT("Apple ][ Emulator")
#define TITLE_APPLE_2_PLUS TEXT("Apple ][+ Emulator") #define TITLE_APPLE_2_PLUS TEXT("Apple ][+ Emulator")
#define TITLE_APPLE_2_E TEXT("Apple //e Emulator") #define TITLE_APPLE_2_E TEXT("Apple //e Emulator")
#define TITLE TITLE_APPLE_2_E // #define TITLE TITLE_APPLE_2_E
#define TITLE_PAUSED TEXT(" Paused ") #define TITLE_PAUSED TEXT(" Paused ")
#define TITLE_STEPPING TEXT("Stepping") #define TITLE_STEPPING TEXT("Stepping")

View File

@ -371,8 +371,9 @@ int DiskInsert (int drive, LPCTSTR imagefilename, BOOL writeprotected, BOOL crea
} }
//=========================================================================== //===========================================================================
BOOL DiskIsSpinning () { BOOL DiskIsSpinning ()
return floppymotoron; {
return floppymotoron;
} }
//=========================================================================== //===========================================================================
@ -380,30 +381,34 @@ void DiskNotifyInvalidImage (LPCTSTR imagefilename,int error)
{ {
TCHAR buffer[MAX_PATH+128]; TCHAR buffer[MAX_PATH+128];
switch (error) { switch (error)
{
case 1: case 1:
wsprintf(buffer, wsprintf(
TEXT("Unable to open the file %s."), buffer,
(LPCTSTR)imagefilename); TEXT("Unable to open the file %s."),
break; (LPCTSTR)imagefilename);
break;
case 2: case 2:
wsprintf(buffer, wsprintf(
TEXT("Unable to use the file %s\nbecause the ") buffer,
TEXT("disk image format is not recognized."), TEXT("Unable to use the file %s\nbecause the ")
(LPCTSTR)imagefilename); TEXT("disk image format is not recognized."),
break; (LPCTSTR)imagefilename);
break;
default: default:
// IGNORE OTHER ERRORS SILENTLY
return;
}
// IGNORE OTHER ERRORS SILENTLY MessageBox(
return; g_hFrameWindow,
} buffer,
MessageBox(g_hFrameWindow, g_pAppTitle,
buffer, MB_ICONEXCLAMATION | MB_SETFOREGROUND);
TITLE,
MB_ICONEXCLAMATION | MB_SETFOREGROUND);
} }

View File

@ -1159,49 +1159,73 @@ void SetUsingCursor (BOOL newvalue) {
// //
//=========================================================================== //===========================================================================
void FrameCreateWindow () { void FrameCreateWindow ()
int width = VIEWPORTCX + (VIEWPORTX<<1) {
+ BUTTONCX int width = VIEWPORTCX + (VIEWPORTX<<1)
+ (GetSystemMetrics(SM_CXBORDER)<<1) + BUTTONCX
+ 5; + (GetSystemMetrics(SM_CXBORDER)<<1)
int height = VIEWPORTCY + (VIEWPORTY<<1) + 5;
+ GetSystemMetrics(SM_CYBORDER) int height = VIEWPORTCY + (VIEWPORTY<<1)
+ GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYBORDER)
+ 5; + GetSystemMetrics(SM_CYCAPTION)
int xpos; + 5;
if (!RegLoadValue(TEXT("Preferences"),TEXT("Window X-Position"),1,(DWORD *)&xpos)) int xpos;
xpos = (GetSystemMetrics(SM_CXSCREEN)-width) >> 1;
int ypos; if (!RegLoadValue(TEXT("Preferences"),TEXT("Window X-Position"),1,(DWORD *)&xpos))
if (!RegLoadValue(TEXT("Preferences"),TEXT("Window Y-Position"),1,(DWORD *)&ypos)) xpos = (GetSystemMetrics(SM_CXSCREEN)-width) >> 1;
ypos = (GetSystemMetrics(SM_CYSCREEN)-height) >> 1;
g_hFrameWindow = CreateWindow(TEXT("APPLE2FRAME"), int ypos;
g_bApple2e ? TITLE if (!RegLoadValue(TEXT("Preferences"),TEXT("Window Y-Position"),1,(DWORD *)&ypos))
: (g_bApple2plus ? TEXT("Apple ][+ Emulator") ypos = (GetSystemMetrics(SM_CYSCREEN)-height) >> 1;
: TEXT("Apple ][ Emulator")),
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | if (g_bApple2e)
WS_MINIMIZEBOX | WS_VISIBLE, {
xpos,ypos,width,height, g_pAppTitle = TITLE_APPLE_2_E;
HWND_DESKTOP,(HMENU)0,instance,NULL); }
InitCommonControls(); else
tooltipwindow = CreateWindow(TOOLTIPS_CLASS,NULL,TTS_ALWAYSTIP, {
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT, if (g_bApple2plus)
g_hFrameWindow,(HMENU)0,instance,NULL); g_pAppTitle = TITLE_APPLE_2_PLUS;
TOOLINFO toolinfo; else
toolinfo.cbSize = sizeof(toolinfo); g_pAppTitle = TITLE_APPLE_2;
toolinfo.uFlags = TTF_CENTERTIP; }
toolinfo.hwnd = g_hFrameWindow;
toolinfo.hinst = instance; g_hFrameWindow = CreateWindow(
toolinfo.lpszText = LPSTR_TEXTCALLBACK; TEXT("APPLE2FRAME"),
toolinfo.rect.left = BUTTONX; // g_bApple2e
toolinfo.rect.right = toolinfo.rect.left+BUTTONCX+1; // ? TITLE_APPLE_2_E
toolinfo.uId = 0; // : (g_bApple2plus
toolinfo.rect.top = BUTTONY+BTN_DRIVE1*BUTTONCY+1; // ? TITLE_APPLE_2_PLUS
toolinfo.rect.bottom = toolinfo.rect.top+BUTTONCY; // : TITLE_APPLE_2),
SendMessage(tooltipwindow,TTM_ADDTOOL,0,(LPARAM)&toolinfo); g_pAppTitle,
toolinfo.uId = 1; WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU |
toolinfo.rect.top = BUTTONY+BTN_DRIVE2*BUTTONCY+1; WS_MINIMIZEBOX | WS_VISIBLE,
toolinfo.rect.bottom = toolinfo.rect.top+BUTTONCY; xpos,ypos,width,height,
SendMessage(tooltipwindow,TTM_ADDTOOL,0,(LPARAM)&toolinfo); HWND_DESKTOP,(HMENU)0,instance,NULL );
InitCommonControls();
tooltipwindow = CreateWindow(
TOOLTIPS_CLASS,NULL,TTS_ALWAYSTIP,
CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,
g_hFrameWindow,(HMENU)0,instance,NULL );
TOOLINFO toolinfo;
toolinfo.cbSize = sizeof(toolinfo);
toolinfo.uFlags = TTF_CENTERTIP;
toolinfo.hwnd = g_hFrameWindow;
toolinfo.hinst = instance;
toolinfo.lpszText = LPSTR_TEXTCALLBACK;
toolinfo.rect.left = BUTTONX;
toolinfo.rect.right = toolinfo.rect.left+BUTTONCX+1;
toolinfo.uId = 0;
toolinfo.rect.top = BUTTONY+BTN_DRIVE1*BUTTONCY+1;
toolinfo.rect.bottom = toolinfo.rect.top+BUTTONCY;
SendMessage(tooltipwindow,TTM_ADDTOOL,0,(LPARAM)&toolinfo);
toolinfo.uId = 1;
toolinfo.rect.top = BUTTONY+BTN_DRIVE2*BUTTONCY+1;
toolinfo.rect.bottom = toolinfo.rect.top+BUTTONCY;
SendMessage(tooltipwindow,TTM_ADDTOOL,0,(LPARAM)&toolinfo);
} }
//=========================================================================== //===========================================================================

View File

@ -865,25 +865,28 @@ void MemInitialize () {
memimage = (LPBYTE)VirtualAlloc(NULL, memimage = (LPBYTE)VirtualAlloc(NULL,
MAX(0x30000,MAXIMAGES*0x10000), MAX(0x30000,MAXIMAGES*0x10000),
MEM_RESERVE,PAGE_NOACCESS); MEM_RESERVE,PAGE_NOACCESS);
if ((!memaux) || (!memdirty) || (!memimage) || (!memmain) || (!memrom)) {
MessageBox(GetDesktopWindow(), if ((!memaux) || (!memdirty) || (!memimage) || (!memmain) || (!memrom))
TEXT("The emulator was unable to allocate the memory it ") {
TEXT("requires. Further execution is not possible."), MessageBox(
TITLE, GetDesktopWindow(),
MB_ICONSTOP | MB_SETFOREGROUND); TEXT("The emulator was unable to allocate the memory it ")
ExitProcess(1); TEXT("requires. Further execution is not possible."),
} g_pAppTitle,
{ MB_ICONSTOP | MB_SETFOREGROUND);
LPVOID newloc = VirtualAlloc(memimage,0x30000,MEM_COMMIT,PAGE_READWRITE); ExitProcess(1);
if (newloc != memimage) }
MessageBox(GetDesktopWindow(),
TEXT("The emulator has detected a bug in your operating ") LPVOID newloc = VirtualAlloc(memimage,0x30000,MEM_COMMIT,PAGE_READWRITE);
TEXT("system. While changing the attributes of a memory ") if (newloc != memimage)
TEXT("object, the operating system also changed its ") MessageBox(
TEXT("location."), GetDesktopWindow(),
TITLE, TEXT("The emulator has detected a bug in your operating ")
MB_ICONEXCLAMATION | MB_SETFOREGROUND); TEXT("system. While changing the attributes of a memory ")
} TEXT("object, the operating system also changed its ")
TEXT("location."),
g_pAppTitle,
MB_ICONEXCLAMATION | MB_SETFOREGROUND);
#ifdef RAMWORKS #ifdef RAMWORKS
// allocate memory for RAMWorks III - up to 8MB // allocate memory for RAMWorks III - up to 8MB
@ -893,7 +896,7 @@ void MemInitialize () {
i++; i++;
#endif #endif
// READ THE APPLE FIRMWARE ROMS INTO THE ROM IMAGE // READ THE APPLE FIRMWARE ROMS INTO THE ROM IMAGE
const UINT ROM_SIZE = 0x5000; // HACK: Magic # -- $C000..$FFFF = 4K .. why 5K? const UINT ROM_SIZE = 0x5000; // HACK: Magic # -- $C000..$FFFF = 4K .. why 5K?
HRSRC hResInfo = HRSRC hResInfo =
@ -905,18 +908,22 @@ void MemInitialize () {
if(hResInfo == NULL) if(hResInfo == NULL)
{ {
TCHAR sRomFileName[ 128 ]; TCHAR sRomFileName[ MAX_PATH ];
_tcscpy( sRomFileName, g_bApple2e ? TEXT("APPLE2E.ROM") _tcscpy( sRomFileName,
: (g_bApple2plus ? TEXT("APPLE2PLUS.ROM") g_bApple2e
: TEXT("APPLE2ORIG.ROM"))); ? TEXT("APPLE2E.ROM")
: (g_bApple2plus
? TEXT("APPLE2PLUS.ROM")
: TEXT("APPLE2ORIG.ROM")));
TCHAR sText[ 256 ]; TCHAR sText[ MAX_PATH ];
wsprintf( sText, TEXT("Unable to open the required firmware ROM data file.\n\nFile: %s."), sRomFileName ); wsprintf( sText, TEXT("Unable to open the required firmware ROM data file.\n\nFile: %s."), sRomFileName );
MessageBox(GetDesktopWindow(), MessageBox(
sText, GetDesktopWindow(),
TITLE, sText,
MB_ICONSTOP | MB_SETFOREGROUND); g_pAppTitle,
MB_ICONSTOP | MB_SETFOREGROUND);
ExitProcess(1); ExitProcess(1);
} }
@ -929,41 +936,39 @@ void MemInitialize () {
return; return;
BYTE* pData = (BYTE*) LockResource(hResData); // NB. Don't need to unlock resource BYTE* pData = (BYTE*) LockResource(hResData); // NB. Don't need to unlock resource
if(pData == NULL) if (pData == NULL)
return; return;
memcpy(memrom, pData, ROM_SIZE); memcpy(memrom, pData, ROM_SIZE);
// TODO/FIXME: HACK! REMOVE A WAIT ROUTINE FROM THE DISK CONTROLLER'S FIRMWARE // TODO/FIXME: HACK! REMOVE A WAIT ROUTINE FROM THE DISK CONTROLLER'S FIRMWARE
{ *(memrom+0x064C) = 0xA9;
*(memrom+0x064C) = 0xA9; *(memrom+0x064D) = 0x00;
*(memrom+0x064D) = 0x00; *(memrom+0x064E) = 0xEA;
*(memrom+0x064E) = 0xEA;
}
HD_Load_Rom(memrom); // HDD f/w gets loaded to $C700 HD_Load_Rom(memrom); // HDD f/w gets loaded to $C700
MemReset(); MemReset();
} }
//=========================================================================== //===========================================================================
// Call by: // Called by:
// . ResetMachineState() eg. Power-cycle ('Apple-Go' button) // . ResetMachineState() eg. Power-cycle ('Apple-Go' button)
// . Snapshot_LoadState() // . Snapshot_LoadState()
void MemReset () void MemReset ()
{ {
// TURN OFF FAST PAGING IF IT IS CURRENTLY ACTIVE // TURN OFF FAST PAGING IF IT IS CURRENTLY ACTIVE
MemSetFastPaging(0); MemSetFastPaging(0);
// INITIALIZE THE PAGING TABLES // INITIALIZE THE PAGING TABLES
ZeroMemory(memshadow,MAXIMAGES*256*sizeof(LPBYTE)); ZeroMemory(memshadow,MAXIMAGES*256*sizeof(LPBYTE));
ZeroMemory(memwrite ,MAXIMAGES*256*sizeof(LPBYTE)); ZeroMemory(memwrite ,MAXIMAGES*256*sizeof(LPBYTE));
// INITIALIZE THE RAM IMAGES // INITIALIZE THE RAM IMAGES
ZeroMemory(memaux ,0x10000); ZeroMemory(memaux ,0x10000);
ZeroMemory(memmain,0x10000); ZeroMemory(memmain,0x10000);
int iByte; int iByte;
@ -979,16 +984,16 @@ void MemReset ()
} }
} }
// SET UP THE MEMORY IMAGE // SET UP THE MEMORY IMAGE
mem = memimage; mem = memimage;
image = 0; image = 0;
// INITIALIZE THE CPU // INITIALIZE THE CPU
CpuInitialize(); CpuInitialize();
// INITIALIZE PAGING, FILLING IN THE 64K MEMORY IMAGE // INITIALIZE PAGING, FILLING IN THE 64K MEMORY IMAGE
ResetPaging(1); ResetPaging(1);
regs.bRESET = 1; regs.bRESET = 1;
} }
//=========================================================================== //===========================================================================