Moved DIMouse::DirectInputInit() from WM_CREATE to main init-loop (just before msg-pump)

. Only call DIMouse::DirectInputInit() if there's a mousecard in slot-4
Extended logging: output cmd line & any unsupported args
Fixes for SCREENSHOT_280x192:
. B#18928: correction for left edge loss of scaled scanline (Bill Buckel)
. Start on odd scanline (otherwise for 50% scanline mode get an all black image!)
This commit is contained in:
tomch 2013-03-28 22:28:42 +00:00
parent a99df90c25
commit 6728c75357
4 changed files with 173 additions and 152 deletions

View File

@ -116,7 +116,7 @@ ULONGLONG g_nPerfFreq = 0;
static bool g_bPriorityNormal = true;
// Make APPLEWIN process higher priority
void SetPriorityAboveNormal()
void SetPriorityAboveNormal(void)
{
if (!g_bPriorityNormal)
return;
@ -129,7 +129,7 @@ void SetPriorityAboveNormal()
}
// Make APPLEWIN process normal priority
void SetPriorityNormal()
void SetPriorityNormal(void)
{
if (g_bPriorityNormal)
return;
@ -143,7 +143,7 @@ void SetPriorityNormal()
//---------------------------------------------------------------------------
void ContinueExecution()
void ContinueExecution(void)
{
static BOOL pageflipping = 0; //?
@ -304,7 +304,7 @@ void ContinueExecution()
//===========================================================================
void SetCurrentCLK6502()
void SetCurrentCLK6502(void)
{
static DWORD dwPrevSpeed = (DWORD) -1;
@ -335,7 +335,7 @@ void SetCurrentCLK6502()
}
//===========================================================================
void EnterMessageLoop ()
void EnterMessageLoop(void)
{
MSG message;
@ -384,21 +384,25 @@ void EnterMessageLoop ()
}
//===========================================================================
void GetProgramDirectory () {
void GetProgramDirectory(void)
{
GetModuleFileName((HINSTANCE)0, g_sProgramDir, MAX_PATH);
g_sProgramDir[MAX_PATH-1] = 0;
int loop = _tcslen(g_sProgramDir);
while (loop--)
if ((g_sProgramDir[loop] == TEXT('\\')) ||
(g_sProgramDir[loop] == TEXT(':'))) {
{
if ((g_sProgramDir[loop] == TEXT('\\')) || (g_sProgramDir[loop] == TEXT(':')))
{
g_sProgramDir[loop+1] = 0;
break;
}
}
}
//===========================================================================
//Reads configuration from the registry entries
void LoadConfiguration()
void LoadConfiguration(void)
{
DWORD dwComputerType;
@ -550,7 +554,7 @@ void LoadConfiguration()
//===========================================================================
void SetCurrentImageDir()
void SetCurrentImageDir(void)
{
SetCurrentDirectory(g_sCurrentDir);
}
@ -558,15 +562,15 @@ void SetCurrentImageDir()
//===========================================================================
// TODO: Added dialog option of which file extensions to registry
bool g_bRegisterFileTypes = true;
//bool g_bRegistryFileBin = false;
bool g_bRegistryFileDo = true;
bool g_bRegistryFileDsk = true;
bool g_bRegistryFileNib = true;
bool g_bRegistryFilePo = true;
static bool g_bRegisterFileTypes = true;
//static bool g_bRegistryFileBin = false;
static bool g_bRegistryFileDo = true;
static bool g_bRegistryFileDsk = true;
static bool g_bRegistryFileNib = true;
static bool g_bRegistryFilePo = true;
void RegisterExtensions()
void RegisterExtensions(void)
{
TCHAR szCommandTmp[MAX_PATH];
GetModuleFileName((HMODULE)0,szCommandTmp,MAX_PATH);
@ -632,7 +636,7 @@ void RegisterExtensions()
}
//===========================================================================
void AppleWin_RegisterHotKeys()
void AppleWin_RegisterHotKeys(void)
{
BOOL bStatus = true;
@ -729,12 +733,22 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
bool bBoot = false;
LPSTR szImageName_drive1 = NULL;
LPSTR szImageName_drive2 = NULL;
const std::string strCmdLine(lpCmdLine); // Keep a copy for log ouput
while (*lpCmdLine)
{
LPSTR lpNextArg = GetNextArg(lpCmdLine);
if(strcmp(lpCmdLine, "-noreg") == 0)
if (((strcmp(lpCmdLine, "-l") == 0) || (strcmp(lpCmdLine, "-log") == 0)) && (g_fh == NULL))
{
g_fh = fopen("AppleWin.log", "a+t"); // Open log file (append & text mode)
setvbuf(g_fh, NULL, _IONBF, 0); // No buffering (so implicit fflush after every fprintf)
CHAR aDateStr[80], aTimeStr[80];
GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aDateStr, sizeof(aDateStr));
GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aTimeStr, sizeof(aTimeStr));
fprintf(g_fh, "*** Logging started: %s %s\n", aDateStr, aTimeStr);
}
else if (strcmp(lpCmdLine, "-noreg") == 0)
{
g_bRegisterFileTypes = false;
}
@ -754,15 +768,6 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{
bSetFullScreen = true;
}
else if(((strcmp(lpCmdLine, "-l") == 0) || (strcmp(lpCmdLine, "-log") == 0)) && (g_fh == NULL))
{
g_fh = fopen("AppleWin.log", "a+t"); // Open log file (append & text mode)
setvbuf(g_fh, NULL, _IONBF, 0); // No buffering (so implicit fflush after every fprintf)
CHAR aDateStr[80], aTimeStr[80];
GetDateFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aDateStr, sizeof(aDateStr));
GetTimeFormat(LOCALE_SYSTEM_DEFAULT, 0, NULL, NULL, (LPTSTR)aTimeStr, sizeof(aTimeStr));
fprintf(g_fh, "*** Logging started: %s %s\n", aDateStr, aTimeStr);
}
else if (strcmp(lpCmdLine, "-no-di") == 0)
{
g_bDisableDirectInput = true;
@ -825,9 +830,16 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
{
g_bMultiMon = true;
}
else // unsupported
{
LogFileOutput("Unsupported arg: %s\n", lpCmdLine);
}
lpCmdLine = lpNextArg;
}
LogFileOutput("CmdLine: %s\n", strCmdLine.c_str());
#if 0
#ifdef RIFF_SPKR
RiffInitWriteFile("Spkr.wav", SPKR_SAMPLE_RATE, 1);
@ -946,31 +958,31 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
g_nAppMode = MODE_LOGO;
LoadConfiguration();
LogFileOutput("Init: LoadConfiguration()\n");
LogFileOutput("Main: LoadConfiguration()\n");
DebugInitialize();
LogFileOutput("Init: DebugInitialize()\n");
LogFileOutput("Main: DebugInitialize()\n");
JoyInitialize();
LogFileOutput("Init: JoyInitialize()\n");
LogFileOutput("Main: JoyInitialize()\n");
MemInitialize();
LogFileOutput("Init: MemInitialize()\n");
LogFileOutput("Main: MemInitialize()\n");
VideoInitialize(); // g_pFramebufferinfo been created now
LogFileOutput("Init: VideoInitialize()\n");
LogFileOutput("Main: VideoInitialize()\n");
LogFileOutput("Init: FrameCreateWindow() - pre\n");
LogFileOutput("Main: FrameCreateWindow() - pre\n");
FrameCreateWindow();
LogFileOutput("Init: FrameCreateWindow() - post\n");
LogFileOutput("Main: FrameCreateWindow() - post\n");
// PrintScrn support
AppleWin_RegisterHotKeys(); // needs valid g_hFrameWindow
LogFileOutput("Init: AppleWin_RegisterHotKeys()\n");
LogFileOutput("Main: AppleWin_RegisterHotKeys()\n");
// Need to test if it's safe to call ResetMachineState(). In the meantime, just call DiskReset():
DiskReset(); // Switch from a booting A][+ to a non-autostart A][, so need to turn off floppy motor
LogFileOutput("Init: DiskReset()\n");
LogFileOutput("Main: DiskReset()\n");
if (!bSysClkOK)
{
@ -985,10 +997,16 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
}
tfe_init();
LogFileOutput("Init: tfe_init()\n");
LogFileOutput("Main: tfe_init()\n");
if (g_Slot4 == CT_MouseInterface) // TODO: Check all slots for MouseInterface card
{
DIMouse::DirectInputInit(g_hFrameWindow);
LogFileOutput("Main: DIMouse::DirectInputInit()\n");
}
Snapshot_Startup(); // Do this after everything has been init'ed
LogFileOutput("Init: Snapshot_Startup()\n");
LogFileOutput("Main: Snapshot_Startup()\n");
if (bSetFullScreen)
{
@ -1003,15 +1021,15 @@ int APIENTRY WinMain (HINSTANCE passinstance, HINSTANCE, LPSTR lpCmdLine, int)
}
// ENTER THE MAIN MESSAGE LOOP
LogFileOutput("Init: EnterMessageLoop()\n");
LogFileOutput("Main: EnterMessageLoop()\n");
EnterMessageLoop();
LogFileOutput("Init: LeaveMessageLoop()\n");
LogFileOutput("Main: LeaveMessageLoop()\n");
MB_Reset();
LogFileOutput("Init: MB_Reset()\n");
LogFileOutput("Main: MB_Reset()\n");
sg_Mouse.Uninitialize(); // Maybe restarting due to switching slot-4 card from mouse to MB
LogFileOutput("Init: sg_Mouse.Uninitialize()\n");
sg_Mouse.Uninitialize(); // Maybe restarting due to switching slot-4 card from MouseCard to Mockingboard
LogFileOutput("Main: sg_Mouse.Uninitialize()\n");
}
while (restart);

View File

@ -41,7 +41,7 @@ Input
Sound
. MB/Phasor/None WM_USER_RESTART
Disk
. Enhanced disk speed WM_USER_RESTART Why?
. Enhanced disk speed WM_USER_RESTART Why? (used to patch Disk][ f/w - but not anymore)
. HDD enable WM_USER_RESTART
Advanced
. Save State WM_USER_SAVESTATE

View File

@ -742,7 +742,7 @@ LRESULT CALLBACK FrameWndProc (
case WM_CREATE:
LogFileOutput("WM_CREATE\n");
g_hFrameWindow = window;
g_hFrameWindow = window; // NB. g_hFrameWindow by CreateWindow()
CreateGdiObjects();
LogFileOutput("WM_CREATE: CreateGdiObjects()\n");
@ -750,8 +750,8 @@ LRESULT CALLBACK FrameWndProc (
DSInit();
LogFileOutput("WM_CREATE: DSInit()\n");
DIMouse::DirectInputInit(window);
LogFileOutput("WM_CREATE: DIMouse::DirectInputInit()\n");
// DIMouse::DirectInputInit(window);
// LogFileOutput("WM_CREATE: DIMouse::DirectInputInit()\n");
MB_Initialize();
LogFileOutput("WM_CREATE: MB_Initialize()\n");
@ -816,7 +816,7 @@ LRESULT CALLBACK FrameWndProc (
VideoDestroy();
MB_Destroy();
DeleteGdiObjects();
DIMouse::DirectInputUninit(window);
DIMouse::DirectInputUninit(window); // NB. do before window is destroyed
PostQuitMessage(0); // Post WM_QUIT message to the thread's message queue
LogFileOutput("WM_DESTROY (done)\n");
break;
@ -2043,6 +2043,7 @@ void FrameCreateWindow(void)
GetAppleWindowTitle();
// NB. g_hFrameWindow also set by WM_CREATE - NB. CreateWindow() must synchronously send WM_CREATE
g_hFrameWindow = CreateWindow(
TEXT("APPLE2FRAME"),
g_pAppTitle, // SetWindowText() // WindowTitle

View File

@ -4056,6 +4056,8 @@ void Video_MakeScreenShot(FILE *pFile)
if( g_iScreenshotType == SCREENSHOT_280x192 )
{
pSrc += FRAMEBUFFER_W; // Start on odd scanline (otherwise for 50% scanline mode get an all black image!)
u8 aScanLine[ 280 ];
u8 *pDst;
@ -4067,7 +4069,7 @@ void Video_MakeScreenShot(FILE *pFile)
pDst = aScanLine;
for( int x = 0; x < FRAMEBUFFER_W/2; x++ )
{
*pDst++ = *pSrc;
*pDst++ = pSrc[1]; // correction for left edge loss of scaled scanline [Bill Buckel, B#18928]
pSrc += 2; // skip odd pixels
}
fwrite( aScanLine, FRAMEBUFFER_W/2, 1, pFile );