#include "psg_stereo.h"
#endif
+using MSX::JOYSTICK;
+using MSX::KEYBOARD;
+using MSX::MEMORY_EX;
+#if !defined(_MSX1_VARIANTS)
+using MSX::RTCIF;
+#endif
+using MSX::SLOT_MAINROM;
+using MSX::SLOT_CART;
+using MSX::SOUND_CART;
+using MSX::KANJIROM;
+#if defined(MSX_PSG_STEREO)
+using MSX::PSG_STEREO;
+#endif
+#ifdef USE_PRINTER
+using MSX::PRINTER;
+#endif
+#if defined(LDC_SLOT)
+using MSX::SLOT_LDC;
+#endif
+#if defined(MAPPERRAM_SLOT)
+using MSX::SLOT_MAPPERRAM;
+#endif
+#if defined(RAM64K_SLOT)
+using MSX::SLOT_RAM64K;
+#endif
+#if defined(SUBROM_SLOT)
+using MSX::SLOT_SUBROM;
+#endif
+#if defined(FIRMWARE32K1_SLOT)
+using MSX::SLOT_FIRMWARE32K;
+#endif
+#if defined(FIRMWARE32K2_SLOT)
+using MSX::SLOT_FIRMWARE32K;
+#endif
+#if defined(FDD_PATCH_SLOT)
+using MSX::SLOT_FDD_PATCH;
+#endif
+#if defined(MSXDOS2_SLOT)
+using MSX::SLOT_MSXDOS2;
+#endif
+#if defined(MSXMUSIC_SLOT)
+using MSX::SLOT_MSXMUSIC;
+#endif
+
+
#ifdef USE_PORT_F4
class PORT_F4 : public DEVICE
{
uint8_t port;
public:
- PORT_F4(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {
+ PORT_F4(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {
port = 0;
}
~PORT_F4() {}
// initialize
// ----------------------------------------------------------------------------
-VM::VM(EMU* parent_emu) : emu(parent_emu)
+VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu)
{
// create devices
first_device = last_device = NULL;
#endif
#ifdef USE_PRINTER
- if(config.printer_device_type == 0) {
+ if(config.printer_type == 0) {
printer->set_context_prn(new PRNFILE(this, emu));
#if defined(_MZP)
- } else if(config.printer_device_type == 1) {
+ } else if(config.printer_type == 1) {
MZ1P17 *mz1p17 = new MZ1P17(this, emu);
mz1p17->mode = MZ1P17_MODE_X1;
printer->set_context_prn(mz1p17);
- } else if(config.printer_device_type == 2) {
+ } else if(config.printer_type == 2) {
MZ1P17 *mz1p17 = new MZ1P17(this, emu);
mz1p17->mode = MZ1P17_MODE_MZ80P4;
printer->set_context_prn(mz1p17);
#else
-// } else if(config.printer_device_type == 1) {
+// } else if(config.printer_type == 1) {
// HXP560 *hxp560 = new HXP560(this, emu);
// printer->set_context_prn(hxp560);
-// } else if(config.printer_device_type == 2) {
+// } else if(config.printer_type == 2) {
// printer->set_context_prn(new PCPR201(this, emu));
#endif
} else {
#endif
// initialize all devices
+#if defined(__GIT_REPO_VERSION)
+ strncpy(_git_revision, __GIT_REPO_VERSION, sizeof(_git_revision) - 1);
+#endif
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
}
}
-void VM::play_tape(const _TCHAR* file_path)
+void VM::play_tape(int drv, const _TCHAR* file_path)
{
drec->play_tape(file_path);
+// drec->set_remote(true);
}
-void VM::rec_tape(const _TCHAR* file_path)
+void VM::rec_tape(int drv, const _TCHAR* file_path)
{
drec->rec_tape(file_path);
+// drec->set_remote(true);
}
-void VM::close_tape()
+void VM::close_tape(int drv)
{
+ emu->lock_vm();
drec->close_tape();
+ emu->unlock_vm();
+// drec->set_remote(false);
}
-bool VM::is_tape_inserted()
+bool VM::is_tape_inserted(int drv)
{
return drec->is_tape_inserted();
}
-bool VM::is_tape_playing()
+bool VM::is_tape_playing(int drv)
{
return drec->is_tape_playing();
}
-bool VM::is_tape_recording()
+bool VM::is_tape_recording(int drv)
{
return drec->is_tape_recording();
}
-int VM::get_tape_position()
+int VM::get_tape_position(int drv)
{
return drec->get_tape_position();
}
+const _TCHAR* VM::get_tape_message(int drv)
+{
+ return drec->get_message();
+}
+
+void VM::push_play(int drv)
+{
+ drec->set_ff_rew(0);
+ drec->set_remote(true);
+}
+
+void VM::push_stop(int drv)
+{
+ drec->set_remote(false);
+}
+
+void VM::push_fast_forward(int drv)
+{
+ drec->set_ff_rew(1);
+ drec->set_remote(true);
+}
+
+void VM::push_fast_rewind(int drv)
+{
+ drec->set_ff_rew(-1);
+ drec->set_remote(true);
+}
+
#if defined(LDC_SLOT)
-void VM::open_laser_disc(const _TCHAR* file_path)
+void VM::open_laser_disc(int drv, const _TCHAR* file_path)
{
ldp->open_disc(file_path);
}
-void VM::close_laser_disc()
+void VM::close_laser_disc(int drv)
{
ldp->close_disc();
}
-bool VM::is_laser_disc_inserted()
+bool VM::is_laser_disc_inserted(int drv)
{
return ldp->is_disc_inserted();
}
+
+uint32_t VM::is_laser_disc_accessed()
+{
+ return ldp->read_signal(0);
+}
#endif
+
#if defined(FDD_PATCH_SLOT)
void VM::open_floppy_disk(int drv, const _TCHAR* file_path, int bank)
{
{
return memory->is_disk_protected(drv);
}
+
+uint32_t VM::is_floppy_disk_accessed()
+{
+ return memory->read_signal(0);
+}
#endif
bool VM::is_frame_skippable()
}
}
-#define STATE_VERSION 4
-
-void VM::save_state(FILEIO* state_fio)
-{
- state_fio->FputUint32(STATE_VERSION);
-
- for(DEVICE* device = first_device; device; device = device->next_device) {
- device->save_state(state_fio);
- }
-}
+#define STATE_VERSION 5
-bool VM::load_state(FILEIO* state_fio)
+bool VM::process_state(FILEIO* state_fio, bool loading)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- for(DEVICE* device = first_device; device; device = device->next_device) {
- if(!device->load_state(state_fio)) {
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ // Note: typeid(foo).name is fixed by recent ABI.Not dec 6.
+ // const char *name = typeid(*device).name();
+ // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O
+ const char *name = device->get_device_name();
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ if(loading) {
+ printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
return false;
}
- }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ if(loading) {
+ printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name);
+ }
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ if(loading) {
+ printf("Data loading Error: DEVID=%d\n", device->this_device_id);
+ }
+ return false;
+ }
+ }
+ // Machine specified.
return true;
}
-