Fds::~Fds() { EjectDisk(); if (!disks.writeProtected) disks.sides.Save(); }
/************************************ * Main program * ************************************/ int32_t main() { int32_t quit = 0,i, correct,number; char buf[257]; char *langs[]={ "US\0","DE\0","SE\0","FR\0","IT\0", }; /* Read UAE configuration */ i = GetUaeConfig( &config ); while( quit == 0 ) { printf(" UAE-Control v0.1\n\n"); printf(" 1) Reset\n"); printf(" 2) Debug\n"); printf(" 3) Exit Emulator\n"); printf(" 4) Change framerate (Currently : %ld)\n", config.framerate); printf(" 5) Toggle sound (Currently : %s)\n", config.do_output_sound ? "ON" : "OFF"); printf(" 6) Toggle fake joystick (Currently : %s)\n", config.do_fake_joystick ? "ON" : "OFF"); printf(" 7) Change language (Currently : %s)\n", langs[config.keyboard]); printf(" 8) Eject a disk\n"); printf(" 9) Insert a disk\n"); printf("10) Exit UAE-Control\n\n"); correct = 0; while( correct == 0 ) { printf(" Command : "); gets( buf ); i = atoi( buf ); if ((i > 0) && (i < 11)) correct = 1; } switch( i ) { case 1: HardReset(); break; case 2: DebugFunc(); break; case 3: ExitEmu(); break; case 4: printf(" Enter new framerate (1-20) :"); gets( buf ); number = atoi( buf ); if (SetFrameRate (number)) GetUaeConfig(&config); else printf(" Illegal value, not changed.\n"); break; case 5: if (config.do_output_sound) DisableSound(); else EnableSound(); GetUaeConfig( &config ); break; case 6: if (config.do_fake_joystick) DisableJoystick(); else EnableJoystick(); GetUaeConfig( &config ); break; case 7: printf(" 1 = US, 2 = DE, 3 = SE, 4 = FR, 5 = IT\n"); printf(" What will it be : "); gets( buf ); number = atoi( buf ); if ((number >= 1) && (number <= 5)) { ChangeLanguage( number-1 ); GetUaeConfig( &config ); } else { printf(" Illegal value, not changed.\n"); } break; case 8: print_drive_status(); printf(" Eject which drive (1-4): "); gets( buf ); number = atoi( buf ); if ((number >= 1) && (number <=4 )) { EjectDisk( number-1 ); GetUaeConfig( &config ); } else { printf(" Illegal drive, not changed.\n"); } break; case 9: print_drive_status(); printf(" Enter disk to drive (1-4): "); gets( buf ); number = atoi( buf ); if ((number >= 1) && (number <= 4)) { printf("Name of diskfile :"); gets( buf ); InsertDisk( (UBYTE *)&buf, number - 1 ); GetUaeConfig( &config ); } else { printf(" Illegal drive, not changed.\n"); } break; case 10: quit = 1; break; } } quit_program(0, ""); return(0); }
void Fds::LoadState(State::Loader& state) { uint saveDisks[3] = {~0U,~0U,~0U}; while (const dword chunk = state.Begin()) { switch (chunk) { case AsciiId<'I','O'>::V: { State::Loader::Data<4> data( state ); io.ctrl = data[0]; io.port = data[1]; break; } case AsciiId<'R','A','M'>::V: state.Uncompress( ram.mem ); break; case AsciiId<'C','H','R'>::V: state.Uncompress( ppu.GetChrMem().Source().Mem(), SIZE_8K ); break; case AsciiId<'I','R','Q'>::V: case AsciiId<'D','R','V'>::V: adapter.LoadState( state, chunk, ppu ); break; case AsciiId<'D','S','K'>::V: { State::Loader::Data<4> data( state ); if (data[0] != disks.sides.count) throw RESULT_ERR_INVALID_FILE; saveDisks[0] = data[1]; saveDisks[1] = data[2]; saveDisks[2] = data[3]; break; } case AsciiId<'S','N','D'>::V: sound.LoadState( state ); break; default: for (uint i=0; i < disks.sides.count; ++i) { if (chunk == AsciiId<'D','0','A'>::R( 0, i / 2, i % 2 )) { byte* const data = disks.sides[i]; state.Uncompress( data, SIDE_SIZE ); for (uint j=0; j < SIDE_SIZE; ++j) data[j] ^= 0xFFU; break; } } break; } state.End(); } disks.mounting = 0; if (saveDisks[0] != ~0U) { disks.writeProtected = saveDisks[0] & 0x2U; if (saveDisks[0] & 0x1U) { if (NES_FAILED(InsertDisk( saveDisks[1] / 2, saveDisks[1] % 2 ))) throw RESULT_ERR_CORRUPT_FILE; disks.mounting = saveDisks[2]; } else { EjectDisk(); } } adapter.Mount ( disks.current != Disks::EJECTED && !disks.mounting ? disks.sides[disks.current] : NULL, disks.writeProtected ); }
ImageError_e Disk2InterfaceCard::InsertDisk(const int drive, LPCTSTR pszImageFilename, const bool bForceWriteProtected, const bool bCreateIfNecessary) { FloppyDrive* pDrive = &m_floppyDrive[drive]; FloppyDisk* pFloppy = &pDrive->m_disk; if (pFloppy->m_imagehandle) RemoveDisk(drive); // Reset the disk's attributes, but preserve the drive's attributes (GH#138/Platoon, GH#640) // . Changing the disk (in the drive) doesn't affect the drive's attributes. pFloppy->clear(); const DWORD dwAttributes = GetFileAttributes(pszImageFilename); if(dwAttributes == INVALID_FILE_ATTRIBUTES) pFloppy->m_bWriteProtected = false; // Assume this is a new file to create else pFloppy->m_bWriteProtected = bForceWriteProtected ? true : (dwAttributes & FILE_ATTRIBUTE_READONLY); // Check if image is being used by the other drive, and if so remove it in order so it can be swapped { const char* pszOtherPathname = DiskGetFullPathName(!drive); char szCurrentPathname[MAX_PATH]; DWORD uNameLen = GetFullPathName(pszImageFilename, MAX_PATH, szCurrentPathname, NULL); if (uNameLen == 0 || uNameLen >= MAX_PATH) strcpy_s(szCurrentPathname, MAX_PATH, pszImageFilename); if (!strcmp(pszOtherPathname, szCurrentPathname)) { EjectDisk(!drive); FrameRefreshStatus(DRAW_LEDS | DRAW_BUTTON_DRIVES); } } ImageError_e Error = ImageOpen(pszImageFilename, &pFloppy->m_imagehandle, &pFloppy->m_bWriteProtected, bCreateIfNecessary, pFloppy->m_strFilenameInZip); if (Error == eIMAGE_ERROR_NONE && ImageIsMultiFileZip(pFloppy->m_imagehandle)) { TCHAR szText[100+MAX_PATH]; szText[sizeof(szText)-1] = 0; _snprintf(szText, sizeof(szText)-1, "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); if (nRes == IDNO) { RemoveDisk(drive); Error = eIMAGE_ERROR_REJECTED_MULTI_ZIP; } } if (Error == eIMAGE_ERROR_NONE) { GetImageTitle(pszImageFilename, pFloppy->m_imagename, pFloppy->m_fullname); Video_ResetScreenshotCounter(pFloppy->m_imagename); } else { Video_ResetScreenshotCounter(NULL); } SaveLastDiskImage(drive); return Error; }
/***************************************** * Main program * *****************************************/ int main() { int quit = 0, i; struct IntuiMessage *msg; struct Gadget *button; struct StringInfo *strinfo; char buf[257]; UWORD koodi, msgID; ULONG classi, number; APTR address; ULONG CycleTags[3]; CycleTags[0] = GTCY_Active; CycleTags[1] = (ULONG) & number; CycleTags[2] = TAG_DONE; /* Read UAE configuration */ i = GetUaeConfig(&config); i = setup_window(); if (i == 0) { quit_program(1, "Cannot setup a window!"); return 1; } while (quit == 0) { WaitPort(window->UserPort); while (msg = (struct IntuiMessage *) GT_GetIMsg(window->UserPort)) { classi = msg->Class; koodi = msg->Code; address = msg->IAddress; if (classi == IDCMP_GADGETUP) { msgID = ((struct Gadget *) msg->IAddress)->GadgetID; button = (struct Gadget *) msg->IAddress; if (button->SpecialInfo) { strinfo = (struct StringInfo *) button->SpecialInfo; } } else msgID = msg->Code; GT_ReplyIMsg((struct IntuiMessage *) msg); switch (classi) { case IDCMP_CLOSEWINDOW: quit = 1; break; case IDCMP_GADGETUP: switch (msgID) { case GAD_EXITEMU: ExitEmu(); break; case GAD_EJECT_DF0: EjectDisk(0); Delay(30); GetUaeConfig(&config); print_drive_status(); break; case GAD_EJECT_DF1: EjectDisk(1); Delay(30); GetUaeConfig(&config); print_drive_status(); break; case GAD_EJECT_DF2: EjectDisk(2); Delay(30); GetUaeConfig(&config); print_drive_status(); break; case GAD_EJECT_DF3: EjectDisk(3); Delay(30); GetUaeConfig(&config); print_drive_status(); break; case GAD_SOUND: if (config.do_output_sound) DisableSound(); else EnableSound(); Delay(30); GetUaeConfig(&config); break; case GAD_JOYSTICK: if (config.do_fake_joystick) DisableJoystick(); else EnableJoystick(); Delay(30); GetUaeConfig(&config); break; case GAD_FRAMERATE: SetFrameRate(strinfo->LongInt); Delay(30); GetUaeConfig(&config); break; case GAD_INSERT_DF0: strcpy(buf, config.df0_name); if (get_string(buf, 255)) { InsertDisk((UBYTE *) buf, 0); Delay(30); GetUaeConfig(&config); print_drive_status(); } break; case GAD_INSERT_DF1: strcpy(buf, config.df1_name); if (get_string(buf, 255)) { InsertDisk((UBYTE *) buf, 1); Delay(30); GetUaeConfig(&config); print_drive_status(); } break; case GAD_INSERT_DF2: strcpy(buf, config.df2_name); if (get_string(buf, 255)) { InsertDisk((UBYTE *) buf, 2); Delay(30); GetUaeConfig(&config); print_drive_status(); } break; case GAD_INSERT_DF3: strcpy(buf, config.df3_name); if (get_string(buf, 255)) { InsertDisk((UBYTE *) buf, 3); Delay(30); GetUaeConfig(&config); print_drive_status(); } break; case GAD_LANGUAGE: number = config.keyboard; number++; if (number == 5) number = 0; ChangeLanguage(number); Delay(30); GetUaeConfig(&config); break; case GAD_RESET: ColdReboot(); break; case GAD_DEBUG: DebugFunc(); break; default: break; } break; default: break; } } } quit_program(0, ""); return (0); }