//=========================================================================== void ResetMachineState () { DiskReset(); // Set floppymotoron=0 g_bFullSpeed = 0; // Might've hit reset in middle of InternalCpuExecute() - so beep may get (partially) muted MemReset(); DiskBoot(); VideoResetState(); sg_SSC.CommReset(); PrintReset(); JoyReset(); MB_Reset(); SpkrReset(); // SoundCore_SetFade(FADE_NONE); }
/********************************* * * * ge_ProcessSetCommand * * * *********************************/ static void ge_ProcessSetCommand(PE_SETCOMM setcommand) { switch (setcommand.tag) { case REPLACE : if (strcmp(setcommand.info.replace.entryType, "functions") == 0) if (strcmp(setcommand.info.replace.doReplace, "true") == 0) { gb_ReplaceFunctions = BTRUE; printMsg(MSG, "All %s will now be replaced silently!", setcommand.info.replace.entryType); } else { gb_ReplaceFunctions = BFALSE; printMsg(MSG, "User will be prompted before replacing %s.", setcommand.info.replace.entryType); } else printMsg(MSG, "Silent replacement for %s is not implemented yet.", setcommand.info.replace.entryType); break; case INCLUDEDIRS : MemReset(incDirHD); g_strList_IncludeDirs = libStrListdup(incDirHD, setcommand.info.dirList); printMsg(MSG,"Search path set to %L.",(LIST *)g_strList_IncludeDirs); break; case APPENDDIRS : g_strList_IncludeDirs = StrListAppend(g_strList_IncludeDirs, libStrListdup(incDirHD, setcommand.info.dirList)); printMsg(MSG,"Search path set to %L.",(LIST *)g_strList_IncludeDirs); break; case QUERY : ge_ShowHelp(SETCOMMAND); break; case PRINTCTEXPR : if (strcmp(setcommand.info.doPrintCT_EXPR, "true") == 0) { printCT_EXPR = BTRUE; printMsg(MSG, "Core term logic will now be printed."); } else { printCT_EXPR = BFALSE; printMsg(MSG, "Core term logic will not be printed."); } break; default: printMsg(FATAL_MSG, "ge_ProcessSetCommand - Invalid tag (%d)", setcommand.tag); } }
void Snapshot_LoadState() { char szMessage[32 + MAX_PATH]; APPLEWIN_SNAPSHOT* pSS = (APPLEWIN_SNAPSHOT*) new char[sizeof(APPLEWIN_SNAPSHOT)]; try { if(pSS == NULL) throw(0); memset(pSS, 0, sizeof(APPLEWIN_SNAPSHOT)); // HANDLE hFile = CreateFile( g_szSaveStateFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile == INVALID_HANDLE_VALUE) { strcpy(szMessage, "File not found: "); strcpy(szMessage + strlen(szMessage), g_szSaveStateFilename); throw(0); } DWORD dwBytesRead; BOOL bRes = ReadFile( hFile, pSS, sizeof(APPLEWIN_SNAPSHOT), &dwBytesRead, NULL); CloseHandle(hFile); if(!bRes || (dwBytesRead != sizeof(APPLEWIN_SNAPSHOT))) { // File size wrong: probably because of version mismatch or corrupt file strcpy(szMessage, "File size mismatch"); throw(0); } if(pSS->Hdr.dwTag != AW_SS_TAG) { strcpy(szMessage, "File corrupt"); throw(0); } if(pSS->Hdr.dwVersion != MAKE_VERSION(1,0,0,1)) { strcpy(szMessage, "Version mismatch"); throw(0); } // TO DO: Verify checksum // // Reset all sub-systems MemReset(); if (apple2e) MemResetPaging(); DiskReset(); KeybReset(); VideoResetState(); MB_Reset(); // // Apple2 uint // CpuSetSnapshot(&pSS->Apple2Unit.CPU6502); CommSetSnapshot(&pSS->Apple2Unit.Comms); JoySetSnapshot(&pSS->Apple2Unit.Joystick); KeybSetSnapshot(&pSS->Apple2Unit.Keyboard); SpkrSetSnapshot(&pSS->Apple2Unit.Speaker); VideoSetSnapshot(&pSS->Apple2Unit.Video); MemSetSnapshot(&pSS->Apple2Unit.Memory); // // // Slot4: Mockingboard MB_SetSnapshot(&pSS->Mockingboard1, 4); // // Slot5: Mockingboard MB_SetSnapshot(&pSS->Mockingboard2, 5); // // Slot6: Disk][ DiskSetSnapshot(&pSS->Disk2, 6); } catch(int) { MessageBox( g_hFrameWindow, szMessage, TEXT("Load State"), MB_ICONEXCLAMATION | MB_SETFOREGROUND); } delete [] pSS; }
void Snapshot_LoadState() { char szMessage[32 + MAX_PATH]; APPLEWIN_SNAPSHOT* pSS = (APPLEWIN_SNAPSHOT*) new char[sizeof(APPLEWIN_SNAPSHOT)]; try { if(pSS == NULL) throw(0); memset(pSS, 0, sizeof(APPLEWIN_SNAPSHOT)); // /* HANDLE hFile = CreateFile( g_szSaveStateFilename, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);*/ HANDLE hFile = (FILE*)fopen(g_szSaveStateFilename, "rb"); if(hFile == INVALID_HANDLE_VALUE) { strcpy(szMessage, "File not found: "); strcpy(szMessage + strlen(szMessage), g_szSaveStateFilename); throw(0); } DWORD dwBytesRead; BOOL bRes = ReadFile( hFile, pSS, sizeof(APPLEWIN_SNAPSHOT), &dwBytesRead, NULL); CloseHandle(hFile); if(!bRes || (dwBytesRead != sizeof(APPLEWIN_SNAPSHOT))) { // File size wrong: probably because of version mismatch or corrupt file strcpy(szMessage, "File size mismatch"); throw(0); } if(pSS->Hdr.dwTag != (DWORD) AW_SS_TAG) { strcpy(szMessage, "File corrupt"); throw(0); } /* Let it be any version, never mind it! ^_^ */ if(pSS->Hdr.dwVersion != MAKE_VERSION(1,0,0,1)) { strcpy(szMessage, "Version mismatch"); throw(0); } // TO DO: Verify checksum // // Reset all sub-systems MemReset(); if (!IS_APPLE2) MemResetPaging(); DiskReset(); KeybReset(); VideoResetState(); MB_Reset(); // // Apple2 uint // CpuSetSnapshot(&pSS->Apple2Unit.CPU6502); sg_SSC.CommSetSnapshot(&pSS->Apple2Unit.Comms); JoySetSnapshot(&pSS->Apple2Unit.Joystick); KeybSetSnapshot(&pSS->Apple2Unit.Keyboard); SpkrSetSnapshot(&pSS->Apple2Unit.Speaker); VideoSetSnapshot(&pSS->Apple2Unit.Video); MemSetSnapshot(&pSS->Apple2Unit.Memory); // // // Slot4: Mockingboard MB_SetSnapshot(&pSS->Mockingboard1, 4); // // Slot5: Mockingboard MB_SetSnapshot(&pSS->Mockingboard2, 5); // // Slot6: Disk][ DiskSetSnapshot(&pSS->Disk2, 6); // Hmmm. And SLOT 7 (HDD1 and HDD2)? Where are they??? -- beom beotiger ^_^ } catch(int) { /* MessageBox( g_hFrameWindow, szMessage, TEXT("Load State"), MB_ICONEXCLAMATION | MB_SETFOREGROUND);*/ fprintf(stderr, "%s\n", szMessage); // instead of wndzoooe messagebox let's use powerful stderr } delete [] pSS; }