diff --git a/include/setup.h b/include/setup.h index ae526d686..d9fcdaa9c 100644 --- a/include/setup.h +++ b/include/setup.h @@ -298,8 +298,8 @@ enum vm_event { VM_EVENT_DOS_EXIT_REBOOT_KERNEL=15, // DOS kernel has just finished exiting (hard reset) VM_EVENT_DOS_SURPRISE_REBOOT, // DOS kernel asked to boot, when apparently having never been shut down (jmp to FFFF:0000) - VM_EVENT_ENTER_PC98_MODE, // Switching into PC-98 emulation mode, phase 1 (unregistering devices) (NOTE: This is TEMPORARY until full implementation is complete) - VM_EVENT_ENTER_PC98_MODE_END, // Switching into PC-98 emulation mode, phase 2 (registering devices) (NOTE: This is TEMPORARY until full implementation is complete) + __DEAD__VM_EVENT_ENTER_PC98_MODE, // Switching into PC-98 emulation mode, phase 1 (unregistering devices) (NOTE: This is TEMPORARY until full implementation is complete) + __DEAD__VM_EVENT_ENTER_PC98_MODE_END, // Switching into PC-98 emulation mode, phase 2 (registering devices) (NOTE: This is TEMPORARY until full implementation is complete) VM_EVENT_MAX }; diff --git a/src/gui/sdlmain.cpp b/src/gui/sdlmain.cpp index e2c369460..bab0e8a7a 100644 --- a/src/gui/sdlmain.cpp +++ b/src/gui/sdlmain.cpp @@ -5660,6 +5660,12 @@ int main(int argc, char* argv[]) { MAPPER_RunInternal(); } + /* if we're supposed to run in PC-98 mode, then do it NOW */ + if (enable_pc98_jump) { + machine = MCH_PC98; + enable_pc98_jump = false; + } + /* The machine just "powered on", and then reset finished */ if (!VM_PowerOn()) E_Exit("VM failed to power on"); diff --git a/src/hardware/cmos.cpp b/src/hardware/cmos.cpp index d99f8ff1d..e8fbab8d6 100644 --- a/src/hardware/cmos.cpp +++ b/src/hardware/cmos.cpp @@ -550,14 +550,6 @@ static IO_WriteHandleObject WriteHandler[2]; void CMOS_Destroy(Section* sec) { } -void CMOS_EnterPC98(Section* sec) { - /* No such device on PC-98 */ - WriteHandler[0].Uninstall(); - WriteHandler[1].Uninstall(); - ReadHandler[0].Uninstall(); - ReadHandler[1].Uninstall(); -} - void CMOS_Reset(Section* sec) { LOG(LOG_MISC,LOG_DEBUG)("CMOS_Reset(): reinitializing CMOS/RTC controller"); @@ -613,7 +605,5 @@ void CMOS_Init() { AddExitFunction(AddExitFunctionFuncPair(CMOS_Destroy),true); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(CMOS_Reset)); - - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(CMOS_EnterPC98)); } diff --git a/src/hardware/disney.cpp b/src/hardware/disney.cpp index 8d12f587e..ee58ffcf4 100644 --- a/src/hardware/disney.cpp +++ b/src/hardware/disney.cpp @@ -425,13 +425,6 @@ static void DISNEY_ShutDown(Section* sec){ } } -static void DISNEY_OnEnterPC98(Section* sec){ - if (test) { - delete test; - test = NULL; - } -} - Bitu DISNEY_BasePort() { return DISNEY_BASE; } @@ -458,11 +451,5 @@ void DISNEY_Init() { LOG(LOG_MISC,LOG_DEBUG)("Initializing Disney Sound Source emulation"); AddExitFunction(AddExitFunctionFuncPair(DISNEY_ShutDown),true); - - /* FIXME: We *could* emulate a Disney Sound Source / LPT DAC / etc. attached to the parallel port - * of a PC-98 system, but, since this code attaches to the I/O ports to emulate the hardware - * we have to disable it in PC-98 mode until such time that this code can remap to emulate - * the PC-98's printer port. */ - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(DISNEY_OnEnterPC98)); } diff --git a/src/hardware/dma.cpp b/src/hardware/dma.cpp index 3b1daeb3d..ad24d65ee 100644 --- a/src/hardware/dma.cpp +++ b/src/hardware/dma.cpp @@ -480,10 +480,6 @@ void DMA_Destroy(Section* /*sec*/) { DMA_FreeControllers(); } -void DMA_OnEnterPC98(Section* /*sec*/) { - DMA_FreeControllers(); -} - void DMA_Reset(Section* /*sec*/) { Bitu i; @@ -568,6 +564,5 @@ void Init_DMA() { AddExitFunction(AddExitFunctionFuncPair(DMA_Destroy)); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(DMA_Reset)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(DMA_OnEnterPC98)); } diff --git a/src/hardware/dongle.cpp b/src/hardware/dongle.cpp index aefc2d168..6f5848b54 100644 --- a/src/hardware/dongle.cpp +++ b/src/hardware/dongle.cpp @@ -180,13 +180,6 @@ static void DONGLE_ShutDown(Section* sec){ } } -static void DONGLE_OnEnterPC98(Section* sec){ - if (test) { - delete test; - test = NULL; - } -} - void DONGLE_OnReset(Section* sec) { if (test == NULL && !IS_PC98_ARCH) { LOG(LOG_MISC,LOG_DEBUG)("Allocating parallel dongle emulation"); @@ -199,5 +192,4 @@ void DONGLE_Init() { AddExitFunction(AddExitFunctionFuncPair(DONGLE_ShutDown),true); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(DONGLE_OnReset)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(DONGLE_OnEnterPC98)); } diff --git a/src/hardware/floppy.cpp b/src/hardware/floppy.cpp index 8fb0a5eac..952967c4b 100644 --- a/src/hardware/floppy.cpp +++ b/src/hardware/floppy.cpp @@ -315,25 +315,10 @@ void FDC_OnReset(Section *sec) { FDC_Init(control->GetSection("fdc, primary"),0); } -void FDC_OnEnterPC98(Section *sec) { - for (unsigned int i=0;i < MAX_FLOPPY_CONTROLLERS;i++) { - if (floppycontroller[i] != NULL) { - delete floppycontroller[i]; - floppycontroller[i] = NULL; - } - } - - init_floppy = 0; -} - void FDC_Primary_Init() { LOG(LOG_MISC,LOG_DEBUG)("Initializing floppy controller emulation"); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(FDC_OnReset)); - - // TODO: I *think* the floppy controller is the same NEC chipset as used on IBM. - // However I don't know what the I/O ports and IRQ are yet. - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(FDC_OnEnterPC98)); } void FloppyController::update_ST3() { diff --git a/src/hardware/gus.cpp b/src/hardware/gus.cpp index e587d1542..195a681d8 100644 --- a/src/hardware/gus.cpp +++ b/src/hardware/gus.cpp @@ -2234,16 +2234,6 @@ void GUS_DOS_Boot(Section *sec) { if (test != NULL) test->DOS_Startup(); } -void GUS_OnEnterPC98(Section *sec) { - /* PC-98 does not have Gravis Ultrasound. - * Upon entry, remove all I/O ports and shutdown emulation */ - GUS_DOS_Shutdown(); - if (test != NULL) { - delete test; - test = NULL; - } -} - void GUS_Init() { LOG(LOG_MISC,LOG_DEBUG)("Initializing Gravis Ultrasound emulation"); @@ -2253,7 +2243,5 @@ void GUS_Init() { AddVMEventFunction(VM_EVENT_DOS_SURPRISE_REBOOT,AddVMEventFunctionFuncPair(GUS_DOS_Exit)); AddVMEventFunction(VM_EVENT_DOS_EXIT_REBOOT_BEGIN,AddVMEventFunctionFuncPair(GUS_DOS_Exit)); AddVMEventFunction(VM_EVENT_DOS_INIT_SHELL_READY,AddVMEventFunctionFuncPair(GUS_DOS_Boot)); - - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(GUS_OnEnterPC98)); } diff --git a/src/hardware/ide.cpp b/src/hardware/ide.cpp index f7b23a335..1f6621ab1 100644 --- a/src/hardware/ide.cpp +++ b/src/hardware/ide.cpp @@ -3933,28 +3933,10 @@ void IDE_OnReset(Section *sec) { for (size_t i=0;i < MAX_IDE_CONTROLLERS;i++) ide_inits[i](control->GetSection(ide_names[i])); } -void IDE_OnEnterPC98(Section *sec) { - /* TODO: Late PC-9801 and PC-9821 have IDE controllers. - * What I'm not familiar with is what I/O ports the IDE controller is mapped at - * and what IRQ is used by IDE. - * - * When I better understand the IDE controller I will reenable this code to match it */ - for (unsigned int i=0;i < MAX_IDE_CONTROLLERS;i++) { - if (idecontroller[i] != NULL) { - delete idecontroller[i]; - idecontroller[i] = NULL; - } - } - - init_ide = 0; -} - void IDE_Init() { LOG(LOG_MISC,LOG_DEBUG)("Initializing IDE controllers"); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(IDE_OnReset)); - - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(IDE_OnEnterPC98)); } void BIOS_Post_register_IDE() { diff --git a/src/hardware/innova.cpp b/src/hardware/innova.cpp index c0c7e4519..e548c8042 100644 --- a/src/hardware/innova.cpp +++ b/src/hardware/innova.cpp @@ -120,14 +120,6 @@ static void INNOVA_ShutDown(Section* sec){ } } -static void INNOVA_OnEnterPC98(Section* sec){ - /* No such device on PC-98 */ - if (test != NULL) { - delete test; - test = NULL; - } -} - void INNOVA_OnReset(Section *sec) { if (test == NULL && !IS_PC98_ARCH) { LOG(LOG_MISC,LOG_DEBUG)("Allocating Innova emulation"); @@ -140,7 +132,5 @@ void INNOVA_Init() { AddExitFunction(AddExitFunctionFuncPair(INNOVA_ShutDown),true); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(INNOVA_OnReset)); - - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(INNOVA_OnEnterPC98)); } diff --git a/src/hardware/joystick.cpp b/src/hardware/joystick.cpp index ddcd0aaec..baec9e1f7 100644 --- a/src/hardware/joystick.cpp +++ b/src/hardware/joystick.cpp @@ -220,13 +220,6 @@ void JOYSTICK_OnPowerOn(Section* sec) { } } -void JOYSTICK_OnEnterPC98(Section* sec) { - if (test != NULL) { - delete test; - test = NULL; - } -} - void JOYSTICK_Init() { LOG(LOG_MISC,LOG_DEBUG)("Initializing joystick emulation"); @@ -256,9 +249,9 @@ void JOYSTICK_Init() { stick[1].ytick = PIC_FullIndex(); } - AddExitFunction(AddExitFunctionFuncPair(JOYSTICK_Destroy),true); - AddVMEventFunction(VM_EVENT_POWERON,AddVMEventFunctionFuncPair(JOYSTICK_OnPowerOn)); + AddExitFunction(AddExitFunctionFuncPair(JOYSTICK_Destroy),true); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(JOYSTICK_OnEnterPC98)); + if (!IS_PC98_ARCH) + AddVMEventFunction(VM_EVENT_POWERON,AddVMEventFunctionFuncPair(JOYSTICK_OnPowerOn)); } diff --git a/src/hardware/keyboard.cpp b/src/hardware/keyboard.cpp index cae32fd64..1f6427b7c 100644 --- a/src/hardware/keyboard.cpp +++ b/src/hardware/keyboard.cpp @@ -2209,6 +2209,7 @@ void KEYBOARD_OnReset(Section *sec) { if (IS_PC98_ARCH) { KEYBOARD_OnEnterPC98(NULL); + KEYBOARD_OnEnterPC98_phase2(NULL); } else { IO_RegisterWriteHandler(0x60,write_p60,IO_MB); @@ -2231,9 +2232,6 @@ void KEYBOARD_Init() { AddExitFunction(AddExitFunctionFuncPair(KEYBOARD_ShutDown)); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(KEYBOARD_OnReset)); - - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(KEYBOARD_OnEnterPC98)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE_END,AddVMEventFunctionFuncPair(KEYBOARD_OnEnterPC98_phase2)); } void AUX_Reset() { diff --git a/src/hardware/memory.cpp b/src/hardware/memory.cpp index 44b61ae8a..f79ee284d 100644 --- a/src/hardware/memory.cpp +++ b/src/hardware/memory.cpp @@ -1804,19 +1804,10 @@ void PS2Port92_OnReset(Section *sec) { } } -void PS2Port92_OnEnterPC98(Section *sec) { - PS2_Port_92h_WriteHandler2.Uninstall(); - PS2_Port_92h_WriteHandler.Uninstall(); - PS2_Port_92h_ReadHandler.Uninstall(); -} - void Init_PS2_Port_92h() { LOG(LOG_MISC,LOG_DEBUG)("Initializing PS/2 port 92h emulation"); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(PS2Port92_OnReset)); - - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(PS2Port92_OnEnterPC98)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE_END,AddVMEventFunctionFuncPair(PS2Port92_OnReset)); } void Init_MemHandles() { diff --git a/src/hardware/mpu401.cpp b/src/hardware/mpu401.cpp index eea224311..536f01266 100644 --- a/src/hardware/mpu401.cpp +++ b/src/hardware/mpu401.cpp @@ -730,15 +730,6 @@ void MPU401_Destroy(Section* sec){ } } -void MPU401_EnterPC98(Section* sec){ - /* NTS: PC-98 systems do have add-in cards for MIDI, but not in the same - * way that IBM PC/XT/AT systems present it to the software. */ - if (test != NULL) { - delete test; - test = NULL; - } -} - void MPU401_Reset(Section* sec) { if (test == NULL) { LOG(LOG_MISC,LOG_DEBUG)("Allocating MPU401 emulation"); @@ -765,9 +756,6 @@ void MPU401_Init() { AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(MPU401_Reset)); AddExitFunction(AddExitFunctionFuncPair(MPU401_Destroy),true); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(MPU401_EnterPC98)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE_END,AddVMEventFunctionFuncPair(MPU401_Reset)); - control->GetSection("midi")->onpropchange.push_back(&MIDI_OnSectionPropChange); } diff --git a/src/hardware/ne2000.cpp b/src/hardware/ne2000.cpp index 4c275d59e..2a0607bb3 100644 --- a/src/hardware/ne2000.cpp +++ b/src/hardware/ne2000.cpp @@ -1670,13 +1670,6 @@ void NE2K_ShutDown(Section* sec) { } } -void NE2k_OnEnterPC98(Section* sec) { - if (test) { - delete test; - test = NULL; - } -} - void NE2K_OnReset(Section* sec) { if (test == NULL && !IS_PC98_ARCH) { LOG(LOG_MISC,LOG_DEBUG)("Allocating NE2000 emulation"); @@ -1695,7 +1688,6 @@ void NE2K_Init() { AddExitFunction(AddExitFunctionFuncPair(NE2K_ShutDown),true); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(NE2K_OnReset)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(NE2k_OnEnterPC98)); } #endif // C_NE2000 diff --git a/src/hardware/parport/parport.cpp b/src/hardware/parport/parport.cpp index 17eee43c7..9b15909f8 100644 --- a/src/hardware/parport/parport.cpp +++ b/src/hardware/parport/parport.cpp @@ -319,6 +319,9 @@ public: PARPORTS (Section * configuration):Module_base (configuration) { + // TODO: PC-98 does have one parallel port, if at all + if (IS_PC98_ARCH) return; + // default ports & interrupts Bit8u defaultirq[] = { 7, 5, 12}; Section_prop *section = static_cast (configuration); @@ -434,31 +437,16 @@ void PARALLEL_OnReset (Section * sec) { } } -void PARALLEL_OnPC98Enter (Section * sec) { - /* TODO: PC-98 systems do have parallel ports. - * Update this code to match when I figure out how they work and what I/O ports are involved. */ - unsigned int i; - - for (i=0;i < 3;i++) { - if (parallelPortObjects[i] != NULL) - parallelPortObjects[i]->unregisterDOSDevice(); - } - - if (testParallelPortsBaseclass != NULL) { - delete testParallelPortsBaseclass; - testParallelPortsBaseclass = NULL; - } -} - void PARALLEL_Init () { LOG(LOG_MISC,LOG_DEBUG)("Initializing parallel port emulation"); AddExitFunction(AddExitFunctionFuncPair(PARALLEL_Destroy),true); - AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(PARALLEL_OnReset)); - AddVMEventFunction(VM_EVENT_POWERON,AddVMEventFunctionFuncPair(PARALLEL_OnPowerOn)); - AddVMEventFunction(VM_EVENT_DOS_EXIT_BEGIN,AddVMEventFunctionFuncPair(PARALLEL_OnDOSKernelExit)); - AddVMEventFunction(VM_EVENT_DOS_INIT_KERNEL_READY,AddVMEventFunctionFuncPair(PARALLEL_OnDOSKernelInit)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(PARALLEL_OnPC98Enter)); + if (!IS_PC98_ARCH) { + AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(PARALLEL_OnReset)); + AddVMEventFunction(VM_EVENT_POWERON,AddVMEventFunctionFuncPair(PARALLEL_OnPowerOn)); + AddVMEventFunction(VM_EVENT_DOS_EXIT_BEGIN,AddVMEventFunctionFuncPair(PARALLEL_OnDOSKernelExit)); + AddVMEventFunction(VM_EVENT_DOS_INIT_KERNEL_READY,AddVMEventFunctionFuncPair(PARALLEL_OnDOSKernelInit)); + } } diff --git a/src/hardware/pic.cpp b/src/hardware/pic.cpp index 75b8ae4c9..413244075 100644 --- a/src/hardware/pic.cpp +++ b/src/hardware/pic.cpp @@ -811,22 +811,6 @@ void PIC_Reset(Section *sec) { void PIC_Destroy(Section* sec) { } -void PIC_EnterPC98_Phase1(Section* sec) { - ReadHandler[0].Uninstall(); - ReadHandler[1].Uninstall(); - WriteHandler[0].Uninstall(); - WriteHandler[1].Uninstall(); - ReadHandler[2].Uninstall(); - ReadHandler[3].Uninstall(); - WriteHandler[2].Uninstall(); - WriteHandler[3].Uninstall(); - PCXT_NMI_WriteHandler.Uninstall(); -} - -void PIC_EnterPC98_Phase2(Section* sec) { - PIC_Reset(sec); -} - void Init_PIC() { Bitu i; @@ -845,7 +829,5 @@ void Init_PIC() { AddExitFunction(AddExitFunctionFuncPair(PIC_Destroy)); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(PIC_Reset)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(PIC_EnterPC98_Phase1)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE_END,AddVMEventFunctionFuncPair(PIC_EnterPC98_Phase2)); } diff --git a/src/hardware/ps1_sound.cpp b/src/hardware/ps1_sound.cpp index 576524d49..596b78fd5 100644 --- a/src/hardware/ps1_sound.cpp +++ b/src/hardware/ps1_sound.cpp @@ -395,13 +395,6 @@ void PS1SOUND_ShutDown(Section* sec) { } } -void PS1SOUND_OnEnterPC98(Section* sec) { - if (test) { - delete test; - test = NULL; - } -} - void PS1SOUND_OnReset(Section* sec) { if (test == NULL && !IS_PC98_ARCH) { LOG(LOG_MISC,LOG_DEBUG)("Allocating PS/1 sound emulation"); @@ -414,7 +407,5 @@ void PS1SOUND_Init() { AddExitFunction(AddExitFunctionFuncPair(PS1SOUND_ShutDown),true); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(PS1SOUND_OnReset)); - - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(PS1SOUND_OnEnterPC98)); } diff --git a/src/hardware/sblaster.cpp b/src/hardware/sblaster.cpp index 0c28fd2c9..43e8f3051 100644 --- a/src/hardware/sblaster.cpp +++ b/src/hardware/sblaster.cpp @@ -3584,17 +3584,6 @@ void SBLASTER_DOS_Boot(Section *sec) { if (test != NULL) test->DOS_Startup(); } -void SBLASTER_OnEnterPC98(Section *sec) { - /* PC-98 does not have Sound Blaster (that I'm aware of anyway). - * Upon entry, remove all I/O ports and shutdown emulation */ - SBLASTER_DOS_Shutdown(); - if (test != NULL) { - delete test; - test = NULL; - } - HWOPL_Cleanup(); -} - void SBLASTER_Init() { LOG(LOG_MISC,LOG_DEBUG)("Initializing Sound Blaster emulation"); @@ -3604,7 +3593,5 @@ void SBLASTER_Init() { AddVMEventFunction(VM_EVENT_DOS_SURPRISE_REBOOT,AddVMEventFunctionFuncPair(SBLASTER_DOS_Exit)); AddVMEventFunction(VM_EVENT_DOS_EXIT_REBOOT_BEGIN,AddVMEventFunctionFuncPair(SBLASTER_DOS_Exit)); AddVMEventFunction(VM_EVENT_DOS_INIT_SHELL_READY,AddVMEventFunctionFuncPair(SBLASTER_DOS_Boot)); - - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(SBLASTER_OnEnterPC98)); } diff --git a/src/hardware/serialport/serialport.cpp b/src/hardware/serialport/serialport.cpp index f8f640e27..97201b872 100644 --- a/src/hardware/serialport/serialport.cpp +++ b/src/hardware/serialport/serialport.cpp @@ -1304,6 +1304,10 @@ public: SERIALPORTS (Section * configuration):Module_base (configuration) { Section_prop *section = static_cast (configuration); + // TODO: PC-98 does have serial ports, though differently. + // COM1 is a 8251 UART, while COM2 and higher if they exist are 8250/16xxx UARTs + if (IS_PC98_ARCH) return; + char s_property[] = "serialx"; for(Bitu i = 0; i < 4; i++) { // get the configuration property @@ -1413,39 +1417,16 @@ void SERIAL_OnReset (Section * sec) { } } -void SERIAL_OnEnterPC98Mode (Section * sec) { - // TODO: PC-98 systems do have serial port(s). - // - // I will update the code to match when I better understand them. - // - // Note that up to two different chipsets are involved. - // - // COM1 is usually an Intel 8251, which is completely different from the 8250/16550 used on IBM PC. - // - // COM2 however, is usually an 16550. - unsigned int i; - - for (i=0;i < 3;i++) { - if (serialports[i] != NULL) - serialports[i]->unregisterDOSDevice(); - } - - if (testSerialPortsBaseclass) { - LOG(LOG_MISC,LOG_DEBUG)("Deleting serial port base class"); - delete testSerialPortsBaseclass; - testSerialPortsBaseclass = NULL; - } -} - void SERIAL_Init () { LOG(LOG_MISC,LOG_DEBUG)("Initializing serial port emulation"); AddExitFunction(AddExitFunctionFuncPair(SERIAL_Destroy),true); - AddVMEventFunction(VM_EVENT_POWERON,AddVMEventFunctionFuncPair(SERIAL_OnPowerOn)); - AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(SERIAL_OnReset)); - AddVMEventFunction(VM_EVENT_DOS_EXIT_BEGIN,AddVMEventFunctionFuncPair(SERIAL_OnDOSKernelExit)); - AddVMEventFunction(VM_EVENT_DOS_INIT_KERNEL_READY,AddVMEventFunctionFuncPair(SERIAL_OnDOSKernelInit)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(SERIAL_OnEnterPC98Mode)); + if (!IS_PC98_ARCH) { + AddVMEventFunction(VM_EVENT_POWERON,AddVMEventFunctionFuncPair(SERIAL_OnPowerOn)); + AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(SERIAL_OnReset)); + AddVMEventFunction(VM_EVENT_DOS_EXIT_BEGIN,AddVMEventFunctionFuncPair(SERIAL_OnDOSKernelExit)); + AddVMEventFunction(VM_EVENT_DOS_INIT_KERNEL_READY,AddVMEventFunctionFuncPair(SERIAL_OnDOSKernelInit)); + } } diff --git a/src/hardware/tandy_sound.cpp b/src/hardware/tandy_sound.cpp index 6af4212bf..de08cd34b 100644 --- a/src/hardware/tandy_sound.cpp +++ b/src/hardware/tandy_sound.cpp @@ -520,13 +520,6 @@ void TANDYSOUND_ShutDown(Section* /*sec*/) { } } -void TANDYSOUND_OnEnterPC98(Section* /*sec*/) { - if (test) { - delete test; - test = NULL; - } -} - void TANDYSOUND_OnReset(Section* sec) { if (test == NULL && !IS_PC98_ARCH) { LOG(LOG_MISC,LOG_DEBUG)("Allocating Tandy speaker emulation"); @@ -539,7 +532,5 @@ void TANDYSOUND_Init() { AddExitFunction(AddExitFunctionFuncPair(TANDYSOUND_ShutDown),true); AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(TANDYSOUND_OnReset)); - - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(TANDYSOUND_OnEnterPC98)); } diff --git a/src/hardware/timer.cpp b/src/hardware/timer.cpp index 62a073989..318b7a19e 100644 --- a/src/hardware/timer.cpp +++ b/src/hardware/timer.cpp @@ -542,6 +542,11 @@ void TIMER_OnPowerOn(Section*) { latched_timerstatus_locked=false; gate2 = false; + + if (IS_PC98_ARCH) { + void TIMER_OnEnterPC98_Phase2(Section*); + TIMER_OnEnterPC98_Phase2(NULL); + } } /* NTS: This comes in two phases because we're taking ports 0x71-0x77 which overlap @@ -553,19 +558,6 @@ void TIMER_OnPowerOn(Section*) { * Phase 2 is where we can then claim the I/O ports without our claim getting * overwritten by CMOS emulation unregistering the I/O port. */ -void TIMER_OnEnterPC98_Phase1(Section*) { - PIC_RemoveEvents(PIT0_Event); - - WriteHandler[0].Uninstall(); - WriteHandler[1].Uninstall(); - WriteHandler[2].Uninstall(); - WriteHandler[3].Uninstall(); - ReadHandler[0].Uninstall(); - ReadHandler[1].Uninstall(); - ReadHandler[2].Uninstall(); - ReadHandler[3].Uninstall(); -} - void TIMER_OnEnterPC98_Phase2(Section*) { Section_prop * section=static_cast(control->GetSection("dosbox")); assert(section != NULL); @@ -663,7 +655,5 @@ void TIMER_Init() { AddExitFunction(AddExitFunctionFuncPair(TIMER_Destroy)); AddVMEventFunction(VM_EVENT_POWERON,AddVMEventFunctionFuncPair(TIMER_OnPowerOn)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(TIMER_OnEnterPC98_Phase1)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE_END,AddVMEventFunctionFuncPair(TIMER_OnEnterPC98_Phase2)); } diff --git a/src/hardware/vga.cpp b/src/hardware/vga.cpp index 4d7e485d6..041140531 100644 --- a/src/hardware/vga.cpp +++ b/src/hardware/vga.cpp @@ -727,9 +727,13 @@ void VGA_Reset(Section*) { if (IS_PC98_ARCH) { void VGA_OnEnterPC98(Section *sec); void VGA_OnEnterPC98_phase2(Section *sec); + void PC98_FM_OnEnterPC98(Section *sec); VGA_OnEnterPC98(NULL); VGA_OnEnterPC98_phase2(NULL); + + // TODO: Move to separate file + PC98_FM_OnEnterPC98(NULL); } } @@ -860,8 +864,6 @@ void VGA_OnEnterPC98(Section *sec) { void MEM_ResetPageHandler_Unmapped(Bitu phys_page, Bitu pages); -void PC98_FM_OnEnterPC98(Section *sec); - void VGA_OnEnterPC98_phase2(Section *sec) { VGA_SetupHandlers(); @@ -1020,11 +1022,6 @@ void VGA_Init() { } AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(VGA_Reset)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(VGA_OnEnterPC98)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE_END,AddVMEventFunctionFuncPair(VGA_OnEnterPC98_phase2)); - - // TODO: Move to separate file - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE_END,AddVMEventFunctionFuncPair(PC98_FM_OnEnterPC98)); } void SVGA_Setup_Driver(void) { diff --git a/src/ints/bios.cpp b/src/ints/bios.cpp index d7c73f3c9..75a6277a0 100644 --- a/src/ints/bios.cpp +++ b/src/ints/bios.cpp @@ -4259,14 +4259,6 @@ private: for (Bit16u i=0x400;i<0x8000;i++) real_writeb(0x0,i,0); } - /* if we're supposed to run in PC-98 mode, then do it NOW */ - if (enable_pc98_jump) { - machine = MCH_PC98; - enable_pc98_jump = false; - DispatchVMEvent(VM_EVENT_ENTER_PC98_MODE); /* IBM PC unregistration/shutdown */ - DispatchVMEvent(VM_EVENT_ENTER_PC98_MODE_END); /* PC-98 registration/startup */ - } - if (IS_PC98_ARCH) { for (unsigned int i=0;i < 20;i++) callback[i].Uninstall(); diff --git a/src/ints/mouse.cpp b/src/ints/mouse.cpp index 8e216f685..5eb4ff662 100644 --- a/src/ints/mouse.cpp +++ b/src/ints/mouse.cpp @@ -1238,6 +1238,15 @@ Bitu MOUSE_UserInt_CB_Handler(void) { bool MouseTypeNone(); +void MOUSE_OnReset(Section *sec) { + if (IS_PC98_ARCH) + MOUSE_IRQ = 13; // PC-98 standard + else + MOUSE_IRQ = 12; // IBM PC/AT standard + + PIC_SetIRQMask(MOUSE_IRQ,true); +} + void MOUSE_ShutDown(Section *sec) { } @@ -1346,24 +1355,10 @@ void MOUSE_Startup(Section *sec) { Mouse_SetSensitivity(50,50,50); } -void MOUSE_OnEnterPC98(Section *sec) { -} - -void MOUSE_OnEnterPC98_phase2(Section *sec) { - // PC-98 change mouse to IRQ 13 (same as Neko Project II) - MOUSE_IRQ = 13; // NTS: Based on NKII pic_setirq(0x0D) - PIC_SetIRQMask(MOUSE_IRQ,true); - - // FIXME: This doesn't explain why Puyo Puyo sets up an interrupt handler - // that blows up and hangs if IRQ 5 is fired... what's that about? --J.C. -} - void MOUSE_Init() { LOG(LOG_MISC,LOG_DEBUG)("Initializing mouse interface emulation"); // TODO: We need a DOSBox shutdown callback, and we need a shutdown callback for when the DOS kernel begins to unload and on system reset - AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(MOUSE_ShutDown)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE,AddVMEventFunctionFuncPair(MOUSE_OnEnterPC98)); - AddVMEventFunction(VM_EVENT_ENTER_PC98_MODE_END,AddVMEventFunctionFuncPair(MOUSE_OnEnterPC98_phase2)); + AddVMEventFunction(VM_EVENT_RESET,AddVMEventFunctionFuncPair(MOUSE_OnReset)); } diff --git a/src/misc/setup.cpp b/src/misc/setup.cpp index 6c908c394..3200d85b4 100644 --- a/src/misc/setup.cpp +++ b/src/misc/setup.cpp @@ -819,6 +819,9 @@ void DispatchVMEvent(enum vm_event event) { LOG(LOG_MISC,LOG_DEBUG)("Dispatching VM event %s",GetVMEventName(event)); + if (event == __DEAD__VM_EVENT_ENTER_PC98_MODE || event == __DEAD__VM_EVENT_ENTER_PC98_MODE_END) + E_Exit("Obsolete VM event PC-98 switch"); + vm_dispatch_state.begin_event(event); for (std::list::iterator i=vm_event_functions[event].begin();i!=vm_event_functions[event].end();i++) { LOG(LOG_MISC,LOG_DEBUG)("Calling event %s handler (%p) '%s'",GetVMEventName(event),(void*)((*i).function),(*i).name.c_str());