return true;
}
+bool CMOS::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(cmos, sizeof(cmos), 1);
+ state_fio->StateBool(modified);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
-1, -1, 0x34, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
};
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!key_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateInt32(kbstat);
+ state_fio->StateInt32(kbdata);
+ state_fio->StateBuffer(table, sizeof(table), 1);
+ return true;
+}
--- /dev/null
+bool MAIN::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ return true;
+}
return true;
}
+bool SUB::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ return MEMORY::process_state(state_fio, loading);
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
return true;
}
+bool SUB::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!key_buffer->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateUint8(key_data);
+ state_fio->StateBool(key_irq);
+ state_fio->StateUint8(fdc_drive);
+ state_fio->StateUint8(fdc_side);
+ state_fio->StateUint8(rtc_data);
+ return true;
+}
return true;
}
+bool CMOS::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(cmos, sizeof(cmos), 1);
+ state_fio->StateBool(modified);
+ return true;
+}
return true;
}
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(fdcr);
+ state_fio->StateUint8(fdsl);
+ state_fio->StateUint8(fdst);
+ state_fio->StateInt32(drvsel);
+ state_fio->StateBool(irq);
+ state_fio->StateBuffer(changed, sizeof(changed), 1);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(cvram, sizeof(cvram), 1);
+ state_fio->StateBuffer(kvram, sizeof(kvram), 1);
+ state_fio->StateUint8(mcr1);
+ state_fio->StateUint8(mcr2);
+ state_fio->StateUint8(a20);
+ state_fio->StateUint8(lcdadr);
+ state_fio->StateBuffer(lcdreg, sizeof(lcdreg), 1);
+ state_fio->StateUint16(dcr1);
+ state_fio->StateUint16(dcr2);
+ state_fio->StateInt32(kj_h);
+ state_fio->StateInt32(kj_l);
+ state_fio->StateInt32(kj_ofs);
+ state_fio->StateInt32(kj_row);
+ state_fio->StateInt32(blinkcnt);
+
+ // post process
+ if(loading) {
+ update_bank();
+ }
+ return true;
+}
return true;
}
+bool RTC::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!cur_time.process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateInt32(register_id);
+ state_fio->StateUint16(rtcmr);
+ state_fio->StateUint16(rtdsr);
+ state_fio->StateUint16(rtadr);
+ state_fio->StateUint16(rtobr);
+ state_fio->StateUint16(rtibr);
+ state_fio->StateBuffer(regs, sizeof(regs), 1);
+ return true;
+}
return true;
}
+bool SCSI::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(ctrl_reg);
+ state_fio->StateUint8(intm_reg);
+ state_fio->StateBool(phase_status);
+ state_fio->StateBool(eop_status);
+ return true;
+}
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_dma(DEVICE* device)
return true;
}
+bool SERIAL::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(sioctrl, sizeof(sioctrl), 1);
+ return true;
+}
return true;
}
+bool SYSTEM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(arr);
+ state_fio->StateUint8(nmistat);
+ state_fio->StateUint8(nmimask);
+ return true;
+}
return true;
}
+bool TIMER::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(ctrl);
+ state_fio->StateUint8(status);
+ return true;
+}
return true;
}
+bool BIOS::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ for(int i = 0; i < MAX_DRIVE; i++) {
+ if(!disk[i]->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateInt32(secnum);
+ state_fio->StateInt32(timeout);
+ state_fio->StateBuffer(drive_mode1, sizeof(drive_mode1), 1);
+ state_fio->StateBuffer(drive_mode2, sizeof(drive_mode2), 1);
+ state_fio->StateBuffer(scsi_blocks, sizeof(scsi_blocks), 1);
+ return true;
+}
return true;
}
+bool CMOS::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(cmos, sizeof(cmos), 1);
+ state_fio->StateBool(modified);
+ state_fio->StateUint8(bank);
+ return true;
+}
return true;
}
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateInt32(drvreg);
+ state_fio->StateInt32(drvsel);
+ state_fio->StateBool(irq);
+ state_fio->StateBool(irqmsk);
+ state_fio->StateBuffer(changed, sizeof(changed), 1);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!key_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateUint8(kbstat);
+ state_fio->StateUint8(kbdata);
+ state_fio->StateUint8(kbint);
+ state_fio->StateUint8(kbmsk);
+ state_fio->StateBuffer(table, sizeof(table), 1);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(cvram, sizeof(cvram), 1);
+#ifdef _FMR60
+ state_fio->StateBuffer(avram, sizeof(avram), 1);
+#else
+ state_fio->StateBuffer(kvram, sizeof(kvram), 1);
+#endif
+ state_fio->StateUint8(machine_id);
+ state_fio->StateUint8(protect);
+ state_fio->StateUint8(rst);
+ state_fio->StateUint8(mainmem);
+ state_fio->StateUint8(rplane);
+ state_fio->StateUint8(wplane);
+ state_fio->StateUint8(dma_addr_reg);
+ state_fio->StateUint8(dma_wrap_reg);
+ state_fio->StateUint32(dma_addr_mask);
+ state_fio->StateBool(disp);
+ state_fio->StateBool(vsync);
+ state_fio->StateInt32(blink);
+ state_fio->StateBuffer(apal, sizeof(apal), 1);
+ state_fio->StateUint8(apalsel);
+ state_fio->StateBuffer(dpal, sizeof(dpal), 1);
+ state_fio->StateUint8(outctrl);
+#ifndef _FMR60
+ state_fio->StateUint8(pagesel);
+ state_fio->StateUint8(ankcg);
+ state_fio->StateUint8(dispctrl);
+ state_fio->StateUint8(mix);
+ state_fio->StateUint16(accaddr);
+ state_fio->StateUint16(dispaddr);
+ state_fio->StateInt32(kj_h);
+ state_fio->StateInt32(kj_l);
+ state_fio->StateInt32(kj_ofs);
+ state_fio->StateInt32(kj_row);
+ state_fio->StateUint8(cmdreg);
+ state_fio->StateUint8(imgcol);
+ state_fio->StateUint8(maskreg);
+ state_fio->StateBuffer(compreg, sizeof(compreg), 1);
+ state_fio->StateUint8(compbit);
+ state_fio->StateUint8(bankdis);
+ state_fio->StateBuffer(tilereg, sizeof(tilereg), 1);
+ state_fio->StateUint16(lofs);
+ state_fio->StateUint16(lsty);
+ state_fio->StateUint16(lsx);
+ state_fio->StateUint16(lsy);
+ state_fio->StateUint16(lex);
+ state_fio->StateUint16(ley);
+#endif
+ state_fio->StateBuffer(palette_cg, sizeof(palette_cg), 1);
+
+ // post process
+ if(loading) {
+ update_bank();
+ }
+ return true;
+}
return true;
}
+bool SCSI::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(ctrl_reg);
+ state_fio->StateBool(irq_status);
+ return true;
+}
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_dma(DEVICE* device)
return true;
}
+bool TIMER::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint16(free_run_counter);
+ state_fio->StateUint8(intr_reg);
+ state_fio->StateUint8(rtc_data);
+ state_fio->StateBool(tmout0);
+ state_fio->StateBool(tmout1);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool MAIN::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint8(comm_data);
+ state_fio->StateBool(rom_sel);
+ state_fio->StateUint8(slot_sel);
+ state_fio->StateBuffer(slot_exp, sizeof(slot_exp), 1);
+ state_fio->StateUint8(intr_mask);
+ state_fio->StateUint8(intr_request);
+ state_fio->StateUint8(intr_in_service);
+
+ // post process
+ if(loading) {
+ update_memory_map();
+ }
+ return true;
+}
return true;
}
+bool RAMPACK::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBool(modified);
+ return true;
+}
return true;
}
+bool SUB::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram_b, sizeof(vram_b), 1);
+ state_fio->StateBuffer(vram_r, sizeof(vram_r), 1);
+ state_fio->StateBuffer(vram_g, sizeof(vram_g), 1);
+ state_fio->StateUint8(pa);
+ state_fio->StateUint8(pb);
+ state_fio->StateUint8(pc);
+ state_fio->StateUint8(comm_data);
+ state_fio->StateBool(so);
+ state_fio->StateUint8(clock);
+ state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
+ state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
+ state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
+ state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
+ state_fio->StateBuffer(&c15, sizeof(c15), 1);
+ state_fio->StateBuffer(&c16, sizeof(c16), 1);
+ state_fio->StateBuffer(&f21, sizeof(f21), 1);
+ state_fio->StateUint8(key_sel);
+ state_fio->StateUint8(key_data);
+ state_fio->StateUint8(color_reg);
+ state_fio->StateBool(hsync);
+ state_fio->StateBool(wait);
+ state_fio->StateUint8(cblink);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
__riff_chunk_size.d = length - 8;
__fmt_chunk_size.d = 16;
- __fmt_id.w = 1;
- __channels.w = 1;
+ __fmt_id.u16 = 1;
+ __channels.u16 = 1;
__sample_rate.d = CMT_SAMPLE_RATE;
- __block_size.w = 1;
- __sample_bits.w = 8;
+ __block_size.u16 = 1;
+ __sample_bits.u16 = 8;
memcpy(wav_header.riff_chunk.id, "RIFF", 4);
wav_header.riff_chunk.size = __riff_chunk_size.get_4bytes_le_to();
return true;
}
+bool IO::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ // pre process
+ if(loading) {
+ close_tape();
+ }
+ state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+ state_fio->StateInt32(lcd_status);
+ state_fio->StateInt32(lcd_addr);
+ state_fio->StateBool(lcd_text);
+ state_fio->StateBool(cmt_selected);
+ state_fio->StateUint8(cmt_mode);
+ state_fio->StateBool(cmt_play_ready);
+ state_fio->StateBool(cmt_play_signal);
+ state_fio->StateBool(cmt_rec_ready);
+ state_fio->StateBool(cmt_rec);
+ state_fio->StateBool(cmt_is_wav);
+ state_fio->StateBuffer(cmt_rec_file_path, sizeof(cmt_rec_file_path), 1);
+ if(loading) {
+ int length_tmp = state_fio->FgetInt32_LE();
+ if(cmt_rec) {
+ cmt_fio->Fopen(cmt_rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ state_fio->Fread(buffer_tmp, length_rw, 1);
+ if(cmt_fio->IsOpened()) {
+ cmt_fio->Fwrite(buffer_tmp, length_rw, 1);
+ }
+ length_tmp -= length_rw;
+ }
+ }
+ } else {
+ if(cmt_rec && cmt_fio->IsOpened()) {
+ int length_tmp = (int)cmt_fio->Ftell();
+ cmt_fio->Fseek(0, FILEIO_SEEK_SET);
+ state_fio->FputInt32_LE(length_tmp);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ cmt_fio->Fread(buffer_tmp, length_rw, 1);
+ state_fio->Fwrite(buffer_tmp, length_rw, 1);
+ length_tmp -= length_rw;
+ }
+ } else {
+ state_fio->FputInt32_LE(0);
+ }
+ }
+ state_fio->StateInt32(cmt_bufcnt);
+ state_fio->StateBuffer(cmt_buffer, cmt_bufcnt, 1);
+ state_fio->StateUint8(cmt_clock);
+ state_fio->StateBuffer(&b16_1, sizeof(b16_1), 1);
+ state_fio->StateBuffer(&b16_2, sizeof(b16_2), 1);
+ state_fio->StateBuffer(&g21_1, sizeof(g21_1), 1);
+ state_fio->StateBuffer(&g21_2, sizeof(g21_2), 1);
+ state_fio->StateBuffer(&c15, sizeof(c15), 1);
+ state_fio->StateBuffer(&c16, sizeof(c16), 1);
+ state_fio->StateBuffer(&f21, sizeof(f21), 1);
+ state_fio->StateUint8(key_column);
+ return true;
+}
}
}
+#define STATE_VERSION 1
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
bool is_frame_skippable();
void update_config();
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device
device->update_config();
}
}
+
+#define STATE_VERSION 1
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
bool is_frame_skippable();
void update_config();
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ bool wr = false;
+ bool rd = false;
+
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(loading) {
+ wr = state_fio->FgetBool();
+ rd = state_fio->FgetBool();
+ } else {
+ state_fio->FputBool(wbank[0x8000 >> 13] == ext);
+ state_fio->FputBool(rbank[0x8000 >> 13] == ext);
+ }
+ state_fio->StateBuffer(rom, sizeof(rom), 1);
+ state_fio->StateBuffer(ext, sizeof(ext), 1);
+ if(!cmd_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateBool(sio_select);
+ state_fio->StateBool(special_cmd_masked);
+ state_fio->StateBuffer(slave_mem, sizeof(slave_mem), 1);
+ state_fio->StateBuffer(sound, sizeof(sound), 1);
+ state_fio->StateInt32(sound_ptr);
+ state_fio->StateInt32(sound_count);
+ state_fio->StateUint8(sound_reply);
+ state_fio->StateDouble(sound_freq);
+ state_fio->StateBuffer(key_stat, sizeof(key_stat), 1);
+ state_fio->StateBuffer(key_flag, sizeof(key_flag), 1);
+ state_fio->StateInt32(key_data);
+ state_fio->StateInt32(key_strobe);
+ state_fio->StateInt32(key_intmask);
+ state_fio->StateBool(cmt_play);
+ state_fio->StateBool(cmt_rec);
+ state_fio->StateBuffer(cmt_file_path, sizeof(cmt_file_path), 1);
+ if(loading) {
+ int length_tmp = state_fio->FgetInt32_LE();
+ if(cmt_rec) {
+ cmt_fio->Fopen(cmt_file_path, FILEIO_READ_WRITE_NEW_BINARY);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ state_fio->Fread(buffer_tmp, length_rw, 1);
+ if(cmt_fio->IsOpened()) {
+ cmt_fio->Fwrite(buffer_tmp, length_rw, 1);
+ }
+ length_tmp -= length_rw;
+ }
+ }
+ } else {
+ if(cmt_rec && cmt_fio->IsOpened()) {
+ int length_tmp = (int)cmt_fio->Ftell();
+ cmt_fio->Fseek(0, FILEIO_SEEK_SET);
+ state_fio->FputInt32_LE(length_tmp);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ cmt_fio->Fread(buffer_tmp, length_rw, 1);
+ state_fio->Fwrite(buffer_tmp, length_rw, 1);
+ length_tmp -= length_rw;
+ }
+ } else {
+ state_fio->FputInt32_LE(0);
+ }
+ }
+ state_fio->StateInt32(cmt_count);
+ state_fio->StateBuffer(cmt_buffer, sizeof(cmt_buffer), 1);
+ state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+ state_fio->StateUint8(lcd_select);
+ state_fio->StateUint8(lcd_data);
+ state_fio->StateInt32(lcd_clock);
+ state_fio->StateInt32(int_status);
+ state_fio->StateInt32(int_mask);
+
+ // post process
+ if(loading) {
+ SET_BANK(0x8000, 0xbfff, wr ? ext : wdmy, rd ? ext : rom);
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool IO::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint32(cur_clock);
+ state_fio->StateUint8(bcr);
+ state_fio->StateUint8(slbcr);
+ state_fio->StateUint8(isr);
+ state_fio->StateUint8(ier);
+ state_fio->StateUint8(bankr);
+ state_fio->StateUint8(ioctlr);
+ state_fio->StateUint32(icrc);
+ state_fio->StateUint32(icrb);
+ state_fio->StateBool(ear);
+ state_fio->StateUint8(vadr);
+ state_fio->StateUint8(yoff);
+ if(!cmd_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ if(!rsp_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ if(!cur_time.process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateInt32(register_id_1sec);
+ state_fio->StateBool(onesec_intr);
+ state_fio->StateBool(onesec_intr_enb);
+ state_fio->StateBool(alarm_intr);
+ state_fio->StateBool(alarm_intr_enb);
+ state_fio->StateBuffer(alarm, sizeof(alarm), 1);
+ if(!key_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateBool(kb_intr_enb);
+ state_fio->StateBool(kb_rep_enb);
+ state_fio->StateBool(kb_caps);
+ state_fio->StateUint8(kb_rep_spd1);
+ state_fio->StateUint8(kb_rep_spd2);
+ if(!art_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateUint8(artsr);
+ state_fio->StateUint8(artdir);
+ state_fio->StateBool(txen);
+ state_fio->StateBool(rxen);
+ state_fio->StateBool(dsr);
+ state_fio->StateInt32(register_id_art);
+ state_fio->StateBool(beep);
+ state_fio->StateBool(res_z80);
+ state_fio->StateBool(res_7508);
+ state_fio->StateBuffer(ext, sizeof(ext), 1);
+ state_fio->StateUint32(extar);
+ state_fio->StateUint8(extcr);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint8(bank);
+
+ // post process
+ if(loading) {
+ set_bank(bank);
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool IO::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint32(cur_clock);
+ state_fio->StateUint8(bcr);
+ state_fio->StateUint8(slbcr);
+ state_fio->StateUint8(isr);
+ state_fio->StateUint8(ier);
+ state_fio->StateUint8(ioctlr);
+ state_fio->StateUint32(icrc);
+ state_fio->StateUint32(icrb);
+ state_fio->StateBool(ear);
+ state_fio->StateUint8(vadr);
+ state_fio->StateUint8(yoff);
+ if(!cmd7508_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ if(!rsp7508_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ if(!cur_time.process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateInt32(register_id);
+ state_fio->StateBool(onesec_intr);
+ state_fio->StateBool(onesec_intr_enb);
+ state_fio->StateBool(alarm_intr);
+ state_fio->StateBool(alarm_intr_enb);
+ state_fio->StateBuffer(alarm, sizeof(alarm), 1);
+ if(!key_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateBool(kb_intr_enb);
+ state_fio->StateBool(kb_rep_enb);
+ state_fio->StateBool(kb_caps);
+ state_fio->StateUint8(kb_rep_spd1);
+ state_fio->StateUint8(kb_rep_spd2);
+ state_fio->StateBool(beep);
+ state_fio->StateBool(res_z80);
+ state_fio->StateBool(res_7508);
+ state_fio->StateUint8(cmd6303);
+ state_fio->StateUint8(psr);
+ if(!cmd6303_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ if(!rsp6303_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint16(cs_addr);
+ state_fio->StateUint16(gs_addr);
+ state_fio->StateUint8(lcd_on);
+ state_fio->StateUint8(scr_mode);
+ state_fio->StateUint16(scr_ptr);
+ state_fio->StateUint8(num_lines);
+ state_fio->StateUint8(curs_mode);
+ state_fio->StateUint8(curs_x);
+ state_fio->StateUint8(curs_y);
+ state_fio->StateUint8(wnd_ptr_x);
+ state_fio->StateUint8(wnd_ptr_y);
+ state_fio->StateUint8(flash_block);
+ state_fio->StateUint8(cs_blocks);
+ state_fio->StateBuffer(cs_block, sizeof(cs_block), 1);
+ state_fio->StateUint8(gs_blocks);
+ state_fio->StateBuffer(gs_block, sizeof(gs_block), 1);
+ state_fio->StateBuffer(font, sizeof(font), 1);
+ state_fio->StateBuffer(udgc, sizeof(udgc), 1);
+ state_fio->StateBuffer(mov, sizeof(mov), 1);
+ state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+ state_fio->StateInt32(blink);
+ if(!tf20_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateInt32(device_type);
+ state_fio->StateBuffer(ext, sizeof(ext), 1);
+ state_fio->StateUint32(extar);
+ state_fio->StateUint8(extcr);
+ state_fio->StateBuffer(iramdisk_sectors, sizeof(iramdisk_sectors), 1);
+ state_fio->StateUint8(iramdisk_cmd);
+ state_fio->StateInt32(iramdisk_count);
+ state_fio->StateInt32(iramdisk_dest);
+ state_fio->StateBuffer(iramdisk_buf, sizeof(iramdisk_buf), 1);
+ if(loading) {
+ iramdisk_ptr = iramdisk_buf + state_fio->FgetInt32_LE();
+ } else {
+ state_fio->FputInt32_LE((int)(iramdisk_ptr - iramdisk_buf));
+ }
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint8(bank);
+
+ // post process
+ if(loading) {
+ set_bank(bank);
+ }
+ return true;
+}
}
}
+#define STATE_VERSION 1
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
bool is_frame_skippable();
void update_config();
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateInt32(key_column);
+ state_fio->StateBool(cmode);
+ return true;
+}
return true;
}
+bool IO::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
// TODO
}
+#define STATE_VERSION 1
+
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(extvram, sizeof(extvram), 1);
+ state_fio->StateBuffer(vgarray, sizeof(vgarray), 1);
+ state_fio->StateBuffer(palette, sizeof(palette), 1);
+ state_fio->StateInt32(vgarray_num);
+ state_fio->StateBuffer(bankreg, sizeof(bankreg), 1);
+ state_fio->StateInt32(bankreg_num);
+ state_fio->StateUint8(hires_mode);
+ state_fio->StateUint8(page);
+ state_fio->StateUint8(status);
+ state_fio->StateInt32(cblink);
+ return true;
+}
+
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(extvram, sizeof(extvram), 1);
+ state_fio->StateBuffer(vgarray, sizeof(vgarray), 1);
+ state_fio->StateBuffer(palette, sizeof(palette), 1);
+ state_fio->StateInt32(vgarray_num);
+ state_fio->StateBuffer(bankreg, sizeof(bankreg), 1);
+ state_fio->StateInt32(bankreg_num);
+ state_fio->StateUint8(hires_mode);
+ state_fio->StateUint8(page);
+ state_fio->StateUint8(status);
+ state_fio->StateInt32(cblink);
+ return true;
+}
uint32_t read_io8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
void event_frame();
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_mem(MEMORY* device)
register_id = -1;
}
+#define STATE_VERSION 1
+
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(prev);
+ state_fio->StateInt32(register_id);
+ return true;
+}
+
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(prev);
+ state_fio->StateInt32(register_id);
+ return true;
+}
void reset();
void write_io8(uint32_t addr, uint32_t data);
void event_callback(int event_id, int err);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_fdc(DEVICE* device)
#define STATE_VERSION 4
-void I286::save_state(FILEIO* state_fio)
+bool I286::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
- state_fio->Fwrite(opaque, sizeof(cpu_state), 1);
+ // post process
+ if(loading) {
+ cpu_state *cpustate = (cpu_state *)opaque;
+ cpustate->pic = d_pic;
+ cpustate->program = d_mem;
+ cpustate->io = d_io;
+#ifdef I86_PSEUDO_BIOS
+ cpustate->bios = d_bios;
+#endif
+#ifdef SINGLE_MODE_DMA
+ cpustate->dma = d_dma;
+#endif
+#ifdef USE_DEBUGGER
+ cpustate->emu = emu;
+ cpustate->debugger = d_debugger;
+ cpustate->program_stored = d_mem;
+ cpustate->io_stored = d_io;
+ cpustate->prev_total_icount = cpustate->total_icount;
+#endif
+ }
+ return true;
}
-bool I286::load_state(FILEIO* state_fio)
+bool I286::process_state(FILEIO* state_fio, bool loading)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- state_fio->Fread(opaque, sizeof(cpu_state), 1);
+ state_fio->StateBuffer(opaque, sizeof(cpu_state), 1);
// post process
- cpu_state *cpustate = (cpu_state *)opaque;
- cpustate->pic = d_pic;
- cpustate->program = d_mem;
- cpustate->io = d_io;
+ if(loading) {
+ cpu_state *cpustate = (cpu_state *)opaque;
+ cpustate->pic = d_pic;
+ cpustate->program = d_mem;
+ cpustate->io = d_io;
#ifdef I86_PSEUDO_BIOS
- cpustate->bios = d_bios;
+ cpustate->bios = d_bios;
#endif
#ifdef SINGLE_MODE_DMA
- cpustate->dma = d_dma;
+ cpustate->dma = d_dma;
#endif
#ifdef USE_DEBUGGER
- cpustate->emu = emu;
- cpustate->debugger = d_debugger;
- cpustate->program_stored = d_mem;
- cpustate->io_stored = d_io;
+ cpustate->emu = emu;
+ cpustate->debugger = d_debugger;
+ cpustate->program_stored = d_mem;
+ cpustate->io_stored = d_io;
+ cpustate->prev_total_icount = cpustate->total_icount;
#endif
+ }
return true;
}
-
void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
#endif
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique function
void set_context_mem(DEVICE* device)
}
}
+#define STATE_VERSION 1
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
bool is_frame_skippable();
void update_config();
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device
}
}
+#define STATE_VERSION 1
+
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!key_buf->process_state(state_fio, loading)) {
+ return false;
+ }
+#ifndef KEYBOARD_HACK
+ state_fio->StateUint64(send_data);
+ state_fio->StateInt32(send_count);
+#endif
+ state_fio->StateBool(key_latched);
+ state_fio->StateUint8(nmi_reg);
+ return true;
+}
+
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!key_buf->process_state(state_fio, loading)) {
+ return false;
+ }
+#ifndef KEYBOARD_HACK
+ state_fio->StateUint64(send_data);
+ state_fio->StateInt32(send_count);
+#endif
+ state_fio->StateBool(key_latched);
+ state_fio->StateUint8(nmi_reg);
+ return true;
+}
uint32_t read_io8(uint32_t addr);
void event_callback(int event_id, int err);
void write_signal(int id, uint32_t data, uint32_t mask);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_cpu(DEVICE* device)
return true;
}
+bool CMT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(in);
+ state_fio->StateBool(out);
+ state_fio->StateBool(remote);
+ state_fio->StateBool(eot);
+ state_fio->StateUint8(pout);
+ state_fio->StateBool(strobe);
+ state_fio->StateBool(busy);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(ext, sizeof(ext), 1);
+ state_fio->StateBool(inserted);
+ return true;
+}
return true;
}
+bool JOYSTICK::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateInt32(select);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(column);
+// state_fio->StateBool(break_pressed);
+ return true;
+}
#define SLOT0_STATE_VERSION 1
-void SLOT0::save_state(FILEIO* state_fio)
+bool SLOT0::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(SLOT0_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
-#if defined(_PX7)
- state_fio->Fwrite(ram, sizeof(ram), 1);
-#endif
-}
-
-bool SLOT0::load_state(FILEIO* state_fio)
-{
- if(state_fio->FgetUint32() != SLOT0_STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(SLOT0_STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
#if defined(_PX7)
- state_fio->Fread(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
#endif
return true;
}
#define SLOT1_STATE_VERSION 1
-void SLOT1::save_state(FILEIO* state_fio)
-{
- state_fio->FputUint32(SLOT1_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->FputBool(inserted);
-#if defined(_MSX2)
- state_fio->Fwrite(mapper, sizeof(mapper), 1);
-#endif
-}
-
-bool SLOT1::load_state(FILEIO* state_fio)
+bool SLOT1::process_state(FILEIO* state_fio, bool loading)
{
- if(state_fio->FgetUint32() != SLOT1_STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(SLOT1_STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- inserted = state_fio->FgetBool();
+ state_fio->StateBool(inserted);
#if defined(_MSX2)
- state_fio->Fread(mapper, sizeof(mapper), 1);
+ state_fio->StateBuffer(mapper, sizeof(mapper), 1);
#endif
// post process
- if(inserted) {
- SET_BANK(0x0000, 0xffff, wdmy, rom);
+ if(loading) {
+ if(inserted) {
+ SET_BANK(0x0000, 0xffff, wdmy, rom);
#if defined(_MSX2)
- } else if(mapper[0] < 4) {
- SET_BANK(0x0000, 0x3fff, wdmy, rdmy);
- SET_BANK(0x4000, 0x7fff, wdmy, rom + mapper[0] * 0x4000);
- SET_BANK(0x8000, 0xbfff, wdmy, rom + mapper[1] * 0x4000);
- SET_BANK(0xc000, 0xffff, wdmy, rdmy);
+ } else if(mapper[0] < 4) {
+ SET_BANK(0x0000, 0x3fff, wdmy, rdmy);
+ SET_BANK(0x4000, 0x7fff, wdmy, rom + mapper[0] * 0x4000);
+ SET_BANK(0x8000, 0xbfff, wdmy, rom + mapper[1] * 0x4000);
+ SET_BANK(0xc000, 0xffff, wdmy, rdmy);
#endif
- } else {
- SET_BANK(0x0000, 0xffff, wdmy, rdmy);
+ } else {
+ SET_BANK(0x0000, 0xffff, wdmy, rdmy);
+ }
}
return true;
}
#define SLOT2_STATE_VERSION 1
-void SLOT2::save_state(FILEIO* state_fio)
+bool SLOT2::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(SLOT2_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->FputBool(clock);
- state_fio->FputBool(exv);
- state_fio->FputBool(ack);
- state_fio->FputBool(super_impose);
- state_fio->FputBool(req_intr);
- state_fio->FputBool(pc4);
- state_fio->FputBool(mute_l);
- state_fio->FputBool(mute_r);
-}
-
-bool SLOT2::load_state(FILEIO* state_fio)
-{
- if(state_fio->FgetUint32() != SLOT2_STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(SLOT2_STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- clock = state_fio->FgetBool();
- exv = state_fio->FgetBool();
- ack = state_fio->FgetBool();
- super_impose = state_fio->FgetBool();
- req_intr = state_fio->FgetBool();
- pc4 = state_fio->FgetBool();
- mute_l = state_fio->FgetBool();
- mute_r = state_fio->FgetBool();
+ state_fio->StateBool(clock);
+ state_fio->StateBool(exv);
+ state_fio->StateBool(ack);
+ state_fio->StateBool(super_impose);
+ state_fio->StateBool(req_intr);
+ state_fio->StateBool(pc4);
+ state_fio->StateBool(mute_l);
+ state_fio->StateBool(mute_r);
return true;
}
#else
#define SLOT3_STATE_VERSION 1
-void SLOT3::save_state(FILEIO* state_fio)
+bool SLOT3::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(SLOT3_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->Fwrite(ram, sizeof(ram), 1);
- state_fio->FputBool(inserted);
- state_fio->Fwrite(mapper, sizeof(mapper), 1);
-}
-
-bool SLOT3::load_state(FILEIO* state_fio)
-{
- if(state_fio->FgetUint32() != SLOT3_STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(SLOT3_STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- state_fio->Fread(ram, sizeof(ram), 1);
- inserted = state_fio->FgetBool();
- state_fio->Fread(mapper, sizeof(mapper), 1);
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBool(inserted);
+ state_fio->StateBuffer(mapper, sizeof(mapper), 1);
// post process
- if(inserted) {
- SET_BANK(0x0000, 0xffff, wdmy, rom);
- } else {
- SET_BANK(0x0000, 0x3fff, ram + mapper[0] * 0x4000, ram + mapper[0] * 0x4000);
- SET_BANK(0x4000, 0x7fff, ram + mapper[1] * 0x4000, ram + mapper[1] * 0x4000);
- SET_BANK(0x8000, 0xbfff, ram + mapper[2] * 0x4000, ram + mapper[2] * 0x4000);
- SET_BANK(0xc000, 0xffff, ram + mapper[3] * 0x4000, ram + mapper[3] * 0x4000);
+ if(loading) {
+ if(inserted) {
+ SET_BANK(0x0000, 0xffff, wdmy, rom);
+ } else {
+ SET_BANK(0x0000, 0x3fff, ram + mapper[0] * 0x4000, ram + mapper[0] * 0x4000);
+ SET_BANK(0x4000, 0x7fff, ram + mapper[1] * 0x4000, ram + mapper[1] * 0x4000);
+ SET_BANK(0x8000, 0xbfff, ram + mapper[2] * 0x4000, ram + mapper[2] * 0x4000);
+ SET_BANK(0xc000, 0xffff, ram + mapper[3] * 0x4000, ram + mapper[3] * 0x4000);
+ }
}
return true;
}
#define STATE_VERSION 1
-void MEMORY::save_state(FILEIO* state_fio)
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
#if !defined(_PX7)
for(int i = 0; i < MAX_DRIVE; i++) {
- disk[i]->save_state(state_fio);
+ if(!disk[i]->process_state(state_fio, loading)) {
+ return false;
+ }
}
#endif
- state_fio->FputUint32(slot_select);
+ state_fio->StateUint32(slot_select);
+
+ // post process
+ if(loading) {
+ update_map(slot_select);
+ }
+ return true;
}
-bool MEMORY::load_state(FILEIO* state_fio)
+bool SLOT0::process_state(FILEIO* state_fio, bool loading)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(SLOT0_STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+#if defined(_PX7)
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+#endif
+ return true;
+}
+bool SLOT1::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(SLOT1_STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(inserted);
+#if defined(_MSX2)
+ state_fio->StateBuffer(mapper, sizeof(mapper), 1);
+#endif
+
+ // post process
+ if(loading) {
+ if(inserted) {
+ SET_BANK(0x0000, 0xffff, wdmy, rom);
+#if defined(_MSX2)
+ } else if(mapper[0] < 4) {
+ SET_BANK(0x0000, 0x3fff, wdmy, rdmy);
+ SET_BANK(0x4000, 0x7fff, wdmy, rom + mapper[0] * 0x4000);
+ SET_BANK(0x8000, 0xbfff, wdmy, rom + mapper[1] * 0x4000);
+ SET_BANK(0xc000, 0xffff, wdmy, rdmy);
+#endif
+ } else {
+ SET_BANK(0x0000, 0xffff, wdmy, rdmy);
+ }
+ }
+ return true;
+}
+bool SLOT2::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(SLOT2_STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(clock);
+ state_fio->StateBool(exv);
+ state_fio->StateBool(ack);
+ state_fio->StateBool(super_impose);
+ state_fio->StateBool(req_intr);
+ state_fio->StateBool(pc4);
+ state_fio->StateBool(mute_l);
+ state_fio->StateBool(mute_r);
+ return true;
+}
+bool SLOT3::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(SLOT3_STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBool(inserted);
+ state_fio->StateBuffer(mapper, sizeof(mapper), 1);
+
+ // post process
+ if(loading) {
+ if(inserted) {
+ SET_BANK(0x0000, 0xffff, wdmy, rom);
+ } else {
+ SET_BANK(0x0000, 0x3fff, ram + mapper[0] * 0x4000, ram + mapper[0] * 0x4000);
+ SET_BANK(0x4000, 0x7fff, ram + mapper[1] * 0x4000, ram + mapper[1] * 0x4000);
+ SET_BANK(0x8000, 0xbfff, ram + mapper[2] * 0x4000, ram + mapper[2] * 0x4000);
+ SET_BANK(0xc000, 0xffff, ram + mapper[3] * 0x4000, ram + mapper[3] * 0x4000);
+ }
+ }
+ return true;
+}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
#if !defined(_PX7)
for(int i = 0; i < MAX_DRIVE; i++) {
- if(!disk[i]->load_state(state_fio)) {
+ if(!disk[i]->process_state(state_fio, loading)) {
return false;
}
}
#endif
- slot_select = state_fio->FgetUint32();
+ state_fio->StateUint32(slot_select);
// post process
- update_map(slot_select);
+ if(loading) {
+ update_map(slot_select);
+ }
return true;
}
-
void initialize();
void write_data8(uint32_t addr, uint32_t data);
uint32_t read_data8(uint32_t addr);
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
};
// slot #1
void initialize();
void write_data8(uint32_t addr, uint32_t data);
uint32_t read_data8(uint32_t addr);
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void open_cart(const _TCHAR *file_path);
uint32_t read_data8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
void event_callback(int event_id, int err);
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_cpu(DEVICE* device)
void write_data8(uint32_t addr, uint32_t data);
uint32_t read_data8(uint32_t addr);
void write_io8(uint32_t addr, uint32_t data);
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void open_cart(const _TCHAR *file_path);
uint32_t read_signal(int id);
bool bios_ret_z80(uint16_t PC, pair_t* af, pair_t* bc, pair_t* de, pair_t* hl, pair_t* ix, pair_t* iy, uint8_t* iff1);
#endif
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique functions
void set_context_slot(int drv, DEVICE *device)
return true;
}
+bool SLOT_MAINROM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(SLOT_MAINROM_STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+#ifdef MAINROM_PLUS_RAM_32K
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+#endif
+ return true;
+}
+bool SLOT_CART::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(SLOT_CART_STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(inserted);
+#ifdef USE_MEGAROM
+ state_fio->StateInt32(type);
+ state_fio->StateBool(bank_scc);
+ /* Todo: MEGA ROM bank select */
+ /* is this OK? */
+ if(loading) {
+ if(inserted) {
+ SET_BANK(0x0000, 0xffff, wdmy, rom);
+ int i32;
+ i32 = state_fio->FgetInt32_LE() ; rbank[0] = ((i32 == -1) ? rdmy : rom + i32);
+ i32 = state_fio->FgetInt32_LE() ; rbank[1] = ((i32 == -1) ? rdmy : rom + i32);
+ i32 = state_fio->FgetInt32_LE() ; rbank[2] = ((i32 == -1) ? rdmy : rom + i32);
+ i32 = state_fio->FgetInt32_LE() ; rbank[3] = ((i32 == -1) ? rdmy : rom + i32);
+ i32 = state_fio->FgetInt32_LE() ; rbank[4] = ((i32 == -1) ? rdmy : rom + i32);
+ i32 = state_fio->FgetInt32_LE() ; rbank[5] = ((i32 == -1) ? rdmy : rom + i32);
+ i32 = state_fio->FgetInt32_LE() ; rbank[6] = ((i32 == -1) ? rdmy : rom + i32);
+ i32 = state_fio->FgetInt32_LE() ; rbank[7] = ((i32 == -1) ? rdmy : rom + i32);
+ } else {
+ SET_BANK(0x0000, 0xffff, wdmy, rdmy);
+ }
+ } else {
+ if(inserted) {
+ state_fio->FputInt32_LE(rbank[0]==rdmy ? (-1) : rbank[0] - rom);
+ state_fio->FputInt32_LE(rbank[1]==rdmy ? (-1) : rbank[1] - rom);
+ state_fio->FputInt32_LE(rbank[2]==rdmy ? (-1) : rbank[2] - rom);
+ state_fio->FputInt32_LE(rbank[3]==rdmy ? (-1) : rbank[3] - rom);
+ state_fio->FputInt32_LE(rbank[4]==rdmy ? (-1) : rbank[4] - rom);
+ state_fio->FputInt32_LE(rbank[5]==rdmy ? (-1) : rbank[5] - rom);
+ state_fio->FputInt32_LE(rbank[6]==rdmy ? (-1) : rbank[6] - rom);
+ state_fio->FputInt32_LE(rbank[7]==rdmy ? (-1) : rbank[7] - rom);
+ }
+ }
+#else
+ // post process
+ if(loading) {
+ if(inserted) {
+ SET_BANK(0x0000, 0xffff, wdmy, rom);
+ } else {
+ SET_BANK(0x0000, 0xffff, wdmy, rdmy);
+ }
+ }
+#endif
+ return true;
+}
+bool SLOT_MSXDOS2::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(SLOT_MSXDOS2_STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(mapper, sizeof(mapper), 1);
+
+ // post process
+ if(loading) {
+ if(mapper[0] < 4) {
+ SET_BANK(0x0000, 0x3fff, wdmy, rdmy);
+ SET_BANK(0x4000, 0x7fff, wdmy, rom + mapper[0] * 0x4000);
+ SET_BANK(0x8000, 0xbfff, wdmy, rom + mapper[1] * 0x4000);
+ SET_BANK(0xc000, 0xffff, wdmy, rdmy);
+ } else {
+ SET_BANK(0x0000, 0xffff, wdmy, rdmy);
+ }
+ }
+ return true;
+}
+bool SLOT_LDC::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(SLOT_LDC_STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(clock);
+ state_fio->StateBool(exv);
+ state_fio->StateBool(ack);
+ state_fio->StateBool(super_impose);
+ state_fio->StateBool(req_intr);
+ state_fio->StateBool(pc4);
+ state_fio->StateBool(mute_l);
+ state_fio->StateBool(mute_r);
+ return true;
+}
+bool SLOT_MAPPERRAM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(SLOT_MAPPERRAM_STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(mapper, sizeof(mapper), 1);
+
+ // post process
+ if(loading) {
+ SET_BANK(0x0000, 0x3fff, ram + mapper[0] * 0x4000, ram + mapper[0] * 0x4000);
+ SET_BANK(0x4000, 0x7fff, ram + mapper[1] * 0x4000, ram + mapper[1] * 0x4000);
+ SET_BANK(0x8000, 0xbfff, ram + mapper[2] * 0x4000, ram + mapper[2] * 0x4000);
+ SET_BANK(0xc000, 0xffff, ram + mapper[3] * 0x4000, ram + mapper[3] * 0x4000);
+ }
+ return true;
+}
+bool SLOT_RAM64K::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(SLOT_RAM64K_STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
+bool MEMORY_EX::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+#if defined(FDD_PATCH_SLOT)
+ for(int i = 0; i < MAX_DRIVE; i++) {
+ if(!disk[i]->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+#endif
+ state_fio->StateUint8(psl);
+ state_fio->StateUint8(ssl[0]);
+ state_fio->StateUint8(ssl[1]);
+ state_fio->StateUint8(ssl[2]);
+ state_fio->StateUint8(ssl[3]);
+
+ // post process
+ if(loading) {
+ update_map(psl);
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
bool is_frame_skippable();
void update_config();
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool RTCIF::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(adrs);
+ return true;
+}
return;
}
+bool SCC::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ save_load_state(state_fio, !loading);
+ return true;
+}
return true;
}
+bool CMT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(play);
+ state_fio->StateBool(rec);
+ state_fio->StateBool(remote);
+ state_fio->StateBuffer(rec_file_path, sizeof(rec_file_path), 1);
+ if(loading) {
+ int length_tmp = state_fio->FgetInt32_LE();
+ if(rec) {
+ fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ state_fio->Fread(buffer_tmp, length_rw, 1);
+ if(fio->IsOpened()) {
+ fio->Fwrite(buffer_tmp, length_rw, 1);
+ }
+ length_tmp -= length_rw;
+ }
+ }
+ } else {
+ if(rec && fio->IsOpened()) {
+ int length_tmp = (int)fio->Ftell();
+ fio->Fseek(0, FILEIO_SEEK_SET);
+ state_fio->FputInt32_LE(length_tmp);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ fio->Fread(buffer_tmp, length_rw, 1);
+ state_fio->Fwrite(buffer_tmp, length_rw, 1);
+ length_tmp -= length_rw;
+ }
+ } else {
+ state_fio->FputInt32_LE(0);
+ }
+ }
+ state_fio->StateInt32(bufcnt);
+ state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+ return true;
+}
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(pal, sizeof(pal), 1);
+ state_fio->StateBool(text_wide);
+ state_fio->StateBool(text_color);
+ state_fio->StateUint8(graph_color);
+ state_fio->StateUint8(graph_page);
+ state_fio->StateUint16(cursor);
+ state_fio->StateUint16(cblink);
+ state_fio->StateBool(hsync);
+ state_fio->StateBool(vsync);
+ state_fio->StateBool(display);
+ state_fio->StateBool(blink);
+ return true;
+}
return true;
}
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(drq);
+ return true;
+}
return true;
}
+bool KANJI::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint32(ptr);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateInt32(init);
+ state_fio->StateUint8(code);
+ state_fio->StateUint8(code_prev);
+ state_fio->StateUint8(stat);
+ state_fio->StateBool(caps);
+ state_fio->StateBool(caps_prev);
+ state_fio->StateBool(graph);
+ state_fio->StateBool(graph_prev);
+ state_fio->StateBool(kana);
+ state_fio->StateBool(kana_prev);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram0, sizeof(ram0), 1);
+ state_fio->StateBuffer(ram1, sizeof(ram1), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateUint8(map1);
+ state_fio->StateUint8(map2);
+
+ // post process
+ if(loading) {
+ update_map();
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(chr);
+ state_fio->StateBool(wide);
+ state_fio->StateUint16(cursor);
+ state_fio->StateUint16(cblink);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateUint16(vram_addr);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!key_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateInt32(key_code);
+ state_fio->StateBool(kana);
+ state_fio->StateInt32(event_cnt);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint32(addr_mask);
+ state_fio->StateBool(rom_sel);
+
+ // post process
+ if(loading) {
+ update_memory_map();
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool CMT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(pa);
+ state_fio->StateUint8(pc);
+ state_fio->StateBool(play);
+ state_fio->StateBool(rec);
+ state_fio->StateBool(now_play);
+ state_fio->StateBool(now_rewind);
+ state_fio->StateInt32(register_id_frew);
+ state_fio->StateInt32(register_id_ffwd);
+ state_fio->StateInt32(register_id_fwd);
+ state_fio->StateInt32(register_id_stop);
+ state_fio->StateInt32(register_id_eject);
+#ifndef _MZ80B
+ state_fio->StateInt32(register_id_apss);
+ state_fio->StateBool(now_apss);
+ state_fio->StateBool(now_apss_tmp);
+#endif
+ state_fio->StateInt32(register_id_ipl);
+ return true;
+}
return true;
}
+bool CRTC::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(scan_line);
+ state_fio->StateBool(scan_tmp);
+ state_fio->StateBool(monitor_200line);
+ state_fio->StateBool(monitor_digital);
+ state_fio->StateBool(monitor_tmp);
+ state_fio->StateUint8(textreg_num);
+ state_fio->StateBuffer(textreg, sizeof(textreg), 1);
+ state_fio->StateUint8(cgreg_num);
+ state_fio->StateBuffer(cgreg, sizeof(cgreg), 1);
+ state_fio->StateUint8(scrn_size);
+ state_fio->StateUint8(cg_mask);
+ state_fio->StateUint8(cg_mask256);
+ state_fio->StateBool(cg_mask256_init);
+ state_fio->StateBool(font_size);
+ state_fio->StateBool(column_size);
+ state_fio->StateBuffer(latch, sizeof(latch), 1);
+ state_fio->StateUint16(GDEVS);
+ state_fio->StateUint16(GDEVE);
+ state_fio->StateUint8(GDEHS);
+ state_fio->StateUint8(GDEHE);
+ state_fio->StateInt32(GDEHSC);
+ state_fio->StateInt32(GDEHEC);
+ state_fio->StateBool(hblank);
+ state_fio->StateBool(vblank);
+ state_fio->StateBool(blink);
+ state_fio->StateUint8(clear_flag);
+ state_fio->StateBuffer(palette_reg, sizeof(palette_reg), 1);
+ state_fio->StateBool(pal_select);
+ state_fio->StateBool(screen_mask);
+ state_fio->StateBuffer(priority16, sizeof(priority16), 1);
+ state_fio->StateBuffer(palette16, sizeof(palette16), 1);
+ state_fio->StateBuffer(palette4096, sizeof(palette4096), 1);
+ state_fio->StateBuffer(palette4096r, sizeof(palette4096r), 1);
+ state_fio->StateBuffer(palette4096g, sizeof(palette4096g), 1);
+ state_fio->StateBuffer(palette4096b, sizeof(palette4096b), 1);
+ state_fio->StateBuffer(palette16txt, sizeof(palette16txt), 1);
+ state_fio->StateBuffer(palette4096txt, sizeof(palette4096txt), 1);
+ state_fio->StateBuffer(palette16pri, sizeof(palette16pri), 1);
+ state_fio->StateBuffer(palette4096pri, sizeof(palette4096pri), 1);
+ state_fio->StateUint8(prev16);
+ state_fio->StateBool(update16);
+ state_fio->StateBuffer(priority256, sizeof(priority256), 1);
+ state_fio->StateBuffer(palette256, sizeof(palette256), 1);
+ state_fio->StateBuffer(palette256txt, sizeof(palette256txt), 1);
+ state_fio->StateBuffer(palette256pri, sizeof(palette256pri), 1);
+ state_fio->StateUint32((uint32_t)prev256);
+ state_fio->StateBool(update256);
+ state_fio->StateBuffer(map_addr, sizeof(map_addr), 1);
+ state_fio->StateBuffer(map_hdsc, sizeof(map_hdsc), 1);
+ state_fio->StateBuffer(text_matrix, sizeof(text_matrix), 1);
+ state_fio->StateBuffer(text_matrixw, sizeof(text_matrixw), 1);
+ state_fio->StateUint8(trans_color);
+ state_fio->StateBool(map_init);
+ state_fio->StateBool(trans_init);
+ return true;
+}
}
#endif
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(reversed);
+ return true;
+}
return true;
}
+bool INTERRUPT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(select);
+ state_fio->StateBuffer(irq, sizeof(irq), 1);
+ state_fio->StateInt32(req_intr_ch);
+ state_fio->StateBool(iei);
+ state_fio->StateBool(oei);
+ state_fio->StateUint32(intr_bit);
+ return true;
+}
return true;
}
+bool JOYSTICK::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint32(mode);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(column);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(tvram, sizeof(tvram), 1);
+ state_fio->StateBuffer(pcg, sizeof(pcg), 1);
+ state_fio->StateUint8(bank);
+ state_fio->StateBuffer(page, sizeof(page), 1);
+ state_fio->StateUint8(dic_bank);
+ state_fio->StateUint8(kanji_bank);
+ state_fio->StateBool(blank);
+ state_fio->StateBool(hblank);
+ state_fio->StateBool(vblank);
+ state_fio->StateBool(busreq);
+
+ // post process
+ if(loading) {
+ uint8_t bank_tmp = bank;
+ bank = 0;
+ for(int i = 0; i < 8; i++) {
+ set_map(page[i]);
+ }
+ bank = bank_tmp;
+ }
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(tvram, sizeof(tvram), 1);
+ state_fio->StateBool(ipl_selected);
+ state_fio->StateUint8(vram_sel);
+ state_fio->StateUint8(vram_page);
+ state_fio->StateUint8(back_color);
+ state_fio->StateUint8(text_color);
+ state_fio->StateUint8(vram_mask);
+ state_fio->StateBool(width80);
+ state_fio->StateBool(reverse);
+ state_fio->StateBool(vgate);
+ state_fio->StateBool(hblank);
+#ifdef _MZ80B
+ state_fio->StateBuffer(pio3039_palette, sizeof(pio3039_palette), 1);
+ state_fio->StateBool(pio3039_txt_sw);
+ state_fio->StateUint8(pio3039_data);
+#endif
+
+ // post process
+ if(loading) {
+ if(ipl_selected) {
+ SET_BANK(0x0000, 0x07ff, wdmy, ipl, false);
+ SET_BANK(0x0800, 0x7fff, wdmy, rdmy, false);
+ SET_BANK(0x8000, 0xffff, ram, ram, false);
+ } else {
+ SET_BANK(0x0000, 0xffff, ram, ram, false);
+ }
+ update_vram_map();
+#ifndef _MZ80B
+ update_green_palette();
+#endif
+ }
+ return true;
+}
return true;
}
+bool MOUSE::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(select);
+ return true;
+}
return true;
}
+bool MZ1E30::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint32(rom_address);
+ state_fio->StateBool(irq_status);
+ state_fio->StateBool(drq_status);
+ return true;
+}
return true;
}
+bool MZ1M01::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(port, sizeof(port), 1);
+ return true;
+}
return true;
}
+bool MZ1R12::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(sram, sizeof(sram), 1);
+ state_fio->StateBool(read_only);
+ state_fio->StateUint16(address);
+ state_fio->StateUint32(crc32);
+ return true;
+}
return true;
}
+bool MZ1R13::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint16(address);
+ state_fio->StateBool(select_kanji);
+ return true;
+}
return true;
}
+bool MZ1R37::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(buffer, EMM_SIZE, 1);
+ state_fio->StateUint32(address);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateInt32(monitor_type);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool SERIAL::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(addr_a0);
+ return true;
+}
return true;
}
+bool CRTC::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(textreg_num);
+ state_fio->StateBuffer(textreg, sizeof(textreg), 1);
+ state_fio->StateBuffer(rmwreg_num, sizeof(rmwreg_num), 1);
+ state_fio->StateBuffer(rmwreg, sizeof(rmwreg), 1);
+ state_fio->StateUint8(cgreg_num);
+ state_fio->StateBuffer(cgreg, sizeof(cgreg), 1);
+ state_fio->StateUint8(scrn_size);
+ state_fio->StateUint8(cg_mask);
+ state_fio->StateBool(font_size);
+ state_fio->StateBool(column_size);
+ state_fio->StateBuffer(latch, sizeof(latch), 1);
+ state_fio->StateUint16(GDEVS);
+ state_fio->StateUint16(GDEVE);
+ state_fio->StateUint8(GDEHS);
+ state_fio->StateUint8(GDEHE);
+ state_fio->StateInt32(GDEHSC);
+ state_fio->StateInt32(GDEHEC);
+ state_fio->StateBool(blank);
+ state_fio->StateBool(hblank);
+ state_fio->StateBool(vblank);
+ state_fio->StateBool(blink);
+ state_fio->StateUint8(clear_flag);
+ state_fio->StateBuffer(palette_reg, sizeof(palette_reg), 1);
+ state_fio->StateBool(pal_select);
+ state_fio->StateBool(screen_mask);
+ state_fio->StateBuffer(priority16, sizeof(priority16), 1);
+ state_fio->StateBuffer(palette16, sizeof(palette16), 1);
+ state_fio->StateBuffer(palette4096, sizeof(palette4096), 1);
+ state_fio->StateBuffer(palette4096r, sizeof(palette4096r), 1);
+ state_fio->StateBuffer(palette4096g, sizeof(palette4096g), 1);
+ state_fio->StateBuffer(palette4096b, sizeof(palette4096b), 1);
+ state_fio->StateBuffer(palette16txt, sizeof(palette16txt), 1);
+ state_fio->StateBuffer(palette4096txt, sizeof(palette4096txt), 1);
+ state_fio->StateBuffer(palette16pri, sizeof(palette16pri), 1);
+ state_fio->StateBuffer(palette4096pri, sizeof(palette4096pri), 1);
+ state_fio->StateUint8(prev16);
+ state_fio->StateBool(update16);
+ state_fio->StateBuffer(map_addr, sizeof(map_addr), 1);
+ state_fio->StateBuffer(map_hdsc, sizeof(map_hdsc), 1);
+ state_fio->StateBuffer(text_matrix, sizeof(text_matrix), 1);
+ state_fio->StateBuffer(text_matrixw, sizeof(text_matrixw), 1);
+ state_fio->StateUint8(trans_color);
+ state_fio->StateBool(map_init);
+ state_fio->StateBool(trans_init);
+ return true;
+}
return true;
}
+bool JOYSTICK::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint32(mode);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(column);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(ext, sizeof(ext), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(tvram, sizeof(tvram), 1);
+ state_fio->StateBuffer(pcg, sizeof(pcg), 1);
+ state_fio->StateUint32(mem_window);
+ state_fio->StateUint8(vram_bank);
+ state_fio->StateUint8(dic_bank);
+ state_fio->StateUint8(kanji_bank);
+
+ // post process
+ if(loading) {
+ if(vram_bank == 4) {
+ SET_BANK(0x0c0000, 0x0dffff, vram + 0x00000, vram + 0x00000);
+ } else if(vram_bank == 5) {
+ SET_BANK(0x0c0000, 0x0dffff, vram + 0x20000, vram + 0x20000);
+ } else if(vram_bank == 6) {
+ SET_BANK(0x0c0000, 0x0dffff, vram + 0x40000, vram + 0x40000);
+ } else if(vram_bank == 7) {
+ SET_BANK(0x0c0000, 0x0dffff, vram + 0x60000, vram + 0x60000);
+ } else {
+ SET_BANK(0x0c0000, 0x0dffff, vram + 0x00000, vram + 0x00000);
+ }
+ SET_BANK(0x0e0000, 0x0effff, wdmy, dic + ((dic_bank & 0x18) >> 3) * 0x10000);
+ if(kanji_bank & 0x80) {
+ SET_BANK(0x0f0000, 0x0f0fff, wdmy, kanji + 0x1000 * (kanji_bank & 0x7f));
+ } else {
+ SET_BANK(0x0f0000, 0x0f0fff, pcg, pcg);
+ }
+ SET_BANK(0x0f1000, 0x0f3fff, pcg + 0x1000, pcg + 0x1000);
+ SET_BANK(0x0f4000, 0x0f5fff, tvram, tvram);
+ SET_BANK(0x0f6000, 0x0f7fff, tvram, tvram);
+ }
+ return true;
+}
return true;
}
+bool MOUSE::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(select);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool RESET::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(prev);
+ return true;
+}
#define STATE_VERSION 2
-void SASI::save_state(FILEIO* state_fio)
+bool SASI::process_state(FILEIO* state_fio, bool loading)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->FputUint8(control);
- state_fio->FputBool(irq_status);
- state_fio->FputBool(drq_status);
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(control);
+ state_fio->StateBool(irq_status);
+ state_fio->StateBool(drq_status);
+ return true;
}
-bool SASI::load_state(FILEIO* state_fio)
+bool SASI::process_state(FILEIO* state_fio, bool loading)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
return false;
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
- control = state_fio->FgetUint8();
- irq_status = state_fio->FgetBool();
- drq_status = state_fio->FgetBool();
+ state_fio->StateUint8(control);
+ state_fio->StateBool(irq_status);
+ state_fio->StateBool(drq_status);
return true;
}
-
void write_dma_io8(uint32_t addr, uint32_t data);
uint32_t read_dma_io8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ bool process_state(FILEIO* state_fio, bool loading);
// unique function
void set_context_host(DEVICE* device)
return true;
}
+bool SERIAL::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(addr_a0);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!key_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateInt32(phase);
+ state_fio->StateUint16(send_data);
+ state_fio->StateUint32(stc_clock);
+ state_fio->StateUint8(recv_data);
+ state_fio->StateBool(recv_ok);
+ state_fio->StateBool(stc);
+ state_fio->StateBool(dc);
+ state_fio->StateBool(caps);
+ state_fio->StateBool(kana);
+ state_fio->StateBool(pro_mode);
+ return true;
+}
return true;
}
+bool MAIN::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(common, sizeof(common), 1);
+ state_fio->StateUint8(ma);
+ state_fio->StateUint8(ms);
+ state_fio->StateUint8(mo);
+ state_fio->StateBool(me1);
+ state_fio->StateBool(me2);
+ state_fio->StateUint8(srqb);
+ state_fio->StateUint8(sres);
+ state_fio->StateBool(sack);
+ state_fio->StateBool(srdy);
+ state_fio->StateBool(intfd);
+ state_fio->StateBool(int0);
+ state_fio->StateBool(int1);
+ state_fio->StateBool(int2);
+ state_fio->StateBool(int3);
+ state_fio->StateBool(int4);
+ state_fio->StateBool(me);
+ state_fio->StateBool(e1);
+ state_fio->StateUint8(inp);
+ state_fio->StateBool(motor);
+ state_fio->StateBool(drq);
+ state_fio->StateBool(index);
+ state_fio->StateBool(crt_400line);
+
+ // post process
+ if(loading) {
+ update_bank();
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateUint8(halt);
+ return true;
+}
return true;
}
+bool SUB::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram_chr, sizeof(vram_chr), 1);
+ state_fio->StateBuffer(vram_gfx, sizeof(vram_gfx), 1);
+ state_fio->StateBuffer(disp, sizeof(disp), 1);
+ state_fio->StateInt32(cblink);
+ state_fio->StateBool(crt_400line);
+ return true;
+}
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+ state_fio->StateBuffer(palette, sizeof(palette), 1);
+ state_fio->StateBuffer(back, sizeof(back), 1);
+ state_fio->StateBuffer(reverse, sizeof(reverse), 1);
+ state_fio->StateUint8(rno);
+ state_fio->StateBuffer(wregs, sizeof(wregs), 1);
+ state_fio->StateBuffer(pri, sizeof(pri), 1);
+ state_fio->StateBuffer(vma, sizeof(vma), 1);
+ state_fio->StateBuffer(vds, sizeof(vds), 1);
+ state_fio->StateUint8(mode_r);
+ state_fio->StateUint8(mode_c);
+ state_fio->StateUint8(mode_p);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!key_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ if(!rsp_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateBool(caps);
+ state_fio->StateBool(kana);
+ state_fio->StateBool(graph);
+ state_fio->StateInt32(dk);
+ state_fio->StateInt32(srk);
+ state_fio->StateInt32(dc);
+ state_fio->StateInt32(stc);
+ state_fio->StateInt32(send);
+ state_fio->StateInt32(recv);
+ state_fio->StateInt32(phase);
+ state_fio->StateInt32(timeout);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+#if defined(_MZ6500) || defined(_MZ6550)
+ state_fio->StateBuffer(mz1r32, sizeof(mz1r32), 1);
+#endif
+ state_fio->StateUint8(bank1);
+ state_fio->StateUint8(bank2);
+ state_fio->StateUint32(haddr);
+
+ // post process
+ if(loading) {
+ update_bank();
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool SYSPORT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateInt32(rst);
+ state_fio->StateInt32(highden);
+ return true;
+}
return true;
}
+bool CMOS::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(data_buffer, DATA_SIZE, 1);
+ state_fio->StateUint32(data_addr);
+ state_fio->StateBool(modified);
+ return true;
+}
return true;
}
+bool EMM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(data_buffer, DATA_SIZE, 1);
+ state_fio->StateUint32(data_addr);
+ return true;
+}
return true;
}
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint32(prev_dc);
+ state_fio->StateInt32(register_id);
+ state_fio->StateBool(motor_on);
+ state_fio->StateBool(irq_enabled);
+ return true;
+}
return true;
}
+bool KANJI::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint32(control_reg);
+ state_fio->StateUint32(kanji_addr);
+ state_fio->StateUint32(dic_addr);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(column);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+#if defined(_MZ700)
+ state_fio->StateBuffer(pcg + 0x400, 0x400, 1);
+ state_fio->StateBuffer(pcg + 0xc00, 0x400, 1);
+#elif defined(_MZ1500)
+ state_fio->StateBuffer(pcg, sizeof(pcg), 1);
+#endif
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateUint8(mem_bank);
+#if defined(_MZ700)
+ state_fio->StateUint8(pcg_data);
+ state_fio->StateUint8(pcg_addr);
+ state_fio->StateUint8(pcg_ctrl);
+#elif defined(_MZ800)
+ state_fio->StateUint8(wf);
+ state_fio->StateUint8(rf);
+ state_fio->StateUint8(dmd);
+ state_fio->StateUint32(vram_addr_top);
+ state_fio->StateBool(is_mz800);
+#elif defined(_MZ1500)
+ state_fio->StateUint8(pcg_bank);
+#endif
+#if defined(_MZ800)
+ state_fio->StateUint16(sof);
+ state_fio->StateUint8(sw);
+ state_fio->StateUint8(ssa);
+ state_fio->StateUint8(sea);
+ state_fio->StateUint8(palette_sw);
+ state_fio->StateBuffer(palette, sizeof(palette), 1);
+ state_fio->StateBuffer(palette16, sizeof(palette16), 1);
+#elif defined(_MZ1500)
+ state_fio->StateUint8(priority);
+ state_fio->StateBuffer(palette, sizeof(palette), 1);
+#endif
+ state_fio->StateBool(blink);
+ state_fio->StateBool(tempo);
+ state_fio->StateBool(hblank);
+ state_fio->StateBool(hsync);
+ state_fio->StateBool(vblank);
+ state_fio->StateBool(vsync);
+#if defined(_MZ700) || defined(_MZ1500)
+ state_fio->StateBool(hblank_vram);
+#endif
+#if defined(_MZ1500)
+ state_fio->StateBool(hblank_pcg);
+#endif
+#if defined(_MZ800)
+ state_fio->StateBuffer(palette_mz800_pc, sizeof(palette_mz800_pc), 1);
+#endif
+ state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+
+ // post process
+ if(loading) {
+ update_map_low();
+ update_map_middle();
+ update_map_high();
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+#if defined(_MZ800)
+ state_fio->StateInt32(boot_mode);
+#endif
+ return true;
+}
return true;
}
+bool QUICKDISK::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(file_path, sizeof(file_path), 1);
+ state_fio->StateBool(insert);
+ state_fio->StateBool(protect);
+ state_fio->StateBool(home);
+ state_fio->StateBool(modified);
+ state_fio->StateBool(accessed);
+ state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+ state_fio->StateInt32(buffer_ptr);
+ state_fio->StateInt32(write_ptr);
+ state_fio->StateBool(first_data);
+ state_fio->StateBool(send_break);
+ state_fio->StateBool(wrga);
+ state_fio->StateBool(mton);
+ state_fio->StateBool(sync);
+ state_fio->StateBool(motor_on);
+ state_fio->StateInt32(restore_id);
+ state_fio->StateInt32(end_id);
+ return true;
+}
return true;
}
+bool RAMFILE::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(data_buffer, DATA_SIZE, 1);
+ state_fio->StateUint32(data_addr);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(column);
+ state_fio->StateBool(kana);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBool(tempo);
+ state_fio->StateBool(blink);
+#if defined(_MZ1200) || defined(_MZ80A)
+ state_fio->StateBool(hblank);
+ state_fio->StateBool(memory_swap);
+#endif
+#if defined(SUPPORT_MZ80AIF)
+ state_fio->StateBool(fdc_irq);
+ state_fio->StateBool(fdc_drq);
+#endif
+ state_fio->StateBool(vgate);
+#if defined(_MZ1200) || defined(_MZ80A)
+ state_fio->StateBool(reverse);
+#endif
+#if defined(_MZ80A)
+ state_fio->StateUint32(e200);
+#endif
+ state_fio->StateBuffer(pcg + 0x400, 0x400, 1);
+#if defined(_MZ1200)
+ state_fio->StateBuffer(pcg + 0xc00, 0x400, 1);
+#endif
+ state_fio->StateUint8(pcg_data);
+ state_fio->StateUint8(pcg_addr);
+ state_fio->StateUint8(pcg_ctrl);
+
+ // post process
+ if(loading) {
+#if defined(_MZ1200) || defined(_MZ80A)
+ update_memory_swap();
+#endif
+#if defined(SUPPORT_MZ80AIF)
+ update_fdif_rom_bank();
+#endif
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
}
#endif
+bool PRINTER::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(out_ch);
+ return true;
+}
}
}
+#define STATE_VERSION 1
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
+
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
bool is_frame_skippable();
void update_config();
+ bool process_state(FILEIO* state_fio, bool loading);
// ----------------------------------------
// for each device
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(mode);
+ state_fio->StateUint16(cursor);
+ state_fio->StateUint16(cblink);
+ return true;
+}
return true;
}
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(intr);
+ state_fio->StateBool(supported);
+ return true;
+}
return true;
}
+bool KANJIPAC2::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ state_fio->StateUint32(ptr);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(sel);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(attr, sizeof(attr), 1);
+ state_fio->StateUint16(vram_ptr);
+ state_fio->StateUint8(vram_data);
+ state_fio->StateUint8(mem_map);
+
+ // post process
+ if(loading) {
+ if(mem_map & 2) {
+ SET_BANK(0x0000, 0x7fff, ram, ram);
+ } else {
+ SET_BANK(0x0000, 0x7fff, ram, rom);
+ }
+ }
+ return true;
+}
return true;
}
+bool PAC2::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateInt32(device_type);
+ return get_device()->process_state(state_fio, loading);
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateInt32(boot_mode);
+ return true;
+}
return true;
}
+bool RAMPAC2::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint32(ptr);
+ state_fio->StateBool(opened);
+ state_fio->StateBool(modified);
+ return true;
+}
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(mode);
+ state_fio->StateUint8(text_page);
+ state_fio->StateUint16(cursor);
+ state_fio->StateUint16(cblink);
+ state_fio->StateUint16(flash_cnt);
+ state_fio->StateBool(blink);
+ state_fio->StateBool(pal_dis);
+ return true;
+}
return true;
}
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(intr);
+ return true;
+}
return true;
}
+bool IOBUS::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(mio);
+ return true;
+}
return true;
}
+bool IOTRAP::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(nmi_mask);
+ state_fio->StateBool(pasopia);
+ return true;
+}
return true;
}
+bool KANJIPAC2::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ state_fio->StateUint32(ptr);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(sel);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(pal, sizeof(pal), 1);
+ state_fio->StateUint8(mem_map);
+ state_fio->StateUint8(plane);
+ state_fio->StateUint8(attr_data);
+ state_fio->StateUint8(attr_latch);
+ state_fio->StateBool(vram_sel);
+ state_fio->StateBool(pal_sel);
+ state_fio->StateBool(attr_wrap);
+
+ // post process
+ if(loading) {
+ update_memory_map();
+ }
+ return true;
+}
return true;
}
+bool PAC2::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateInt32(sel);
+ if(!rampac2[0]->process_state(state_fio, loading)) {
+ return false;
+ }
+ if(!rampac2[1]->process_state(state_fio, loading)) {
+ return false;
+ }
+ if(!kanji->process_state(state_fio, loading)) {
+ return false;
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool RAMPAC2::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint32(ptr);
+ state_fio->StateBool(opened);
+ state_fio->StateBool(modified);
+ return true;
+}
return true;
}
+bool CRTC::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+ state_fio->StateBuffer(palette, sizeof(palette), 1);
+ state_fio->StateUint8(sel);
+ state_fio->StateBuffer(regs, sizeof(regs), 1);
+ state_fio->StateUint16(vs);
+ state_fio->StateUint16(cmd);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateUint32(shift);
+ state_fio->StateUint32(maskl);
+ state_fio->StateUint32(maskh);
+ state_fio->StateUint32(busl);
+ state_fio->StateUint32(bush);
+ state_fio->StateUint32(write_plane);
+ state_fio->StateUint32(read_plane);
+ return true;
+}
return true;
}
+bool IOCTRL::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(caps);
+ state_fio->StateBool(kana);
+ if(!key_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateUint32(key_val);
+ state_fio->StateUint32(key_mouse);
+ state_fio->StateInt32(key_prev);
+ state_fio->StateBool(key_res);
+ state_fio->StateBool(key_done);
+ state_fio->StateInt32(register_id);
+ state_fio->StateUint8(ts);
+ return true;
+}
return true;
}
+bool KANJI::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint16(ptr);
+ state_fio->StateBool(strobe);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
return true;
}
+bool IO::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(port_a);
+ state_fio->StateUint8(port_b);
+ state_fio->StateUint8(port_s);
+ state_fio->StateBool(drec_in);
+ state_fio->StateBool(rtc_in);
+ state_fio->StateUint16(key_strobe);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(loading) {
+ vram_ptr = ram_ptr + state_fio->FgetInt32_LE();
+ } else {
+ state_fio->FputInt32_LE((int)(vram_ptr - ram_ptr));
+ }
+ return true;
+}
return true;
}
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(io_B1H);
+ for(int i = 0; i < 2; i++) {
+ if(!disk[i]->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(cur_trk, sizeof(cur_trk), 1);
+ state_fio->StateBuffer(cur_sct, sizeof(cur_sct), 1);
+ state_fio->StateBuffer(cur_pos, sizeof(cur_pos), 1);
+ state_fio->StateBuffer(access, sizeof(access), 1);
+ state_fio->StateBuffer(Data, sizeof(Data), 1);
+ state_fio->StateBuffer(Index, sizeof(Index), 1);
+ state_fio->StateBuffer(&CmdIn, sizeof(CmdBuffer), 1);
+ state_fio->StateBuffer(&CmdOut, sizeof(CmdBuffer), 1);
+ state_fio->StateUint8(SeekST0);
+ state_fio->StateUint8(LastCylinder);
+ state_fio->StateInt32(SeekEnd);
+ state_fio->StateUint8(SendSectors);
+ state_fio->StateInt32(DIO);
+ state_fio->StateUint8(Status);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(RAM, RAM_SIZE, 1);
+ if(loading) {
+ CGROM = MEMORY_BASE + state_fio->FgetInt32_LE();
+ EXTROM1 = MEMORY_BASE + state_fio->FgetInt32_LE();
+ EXTROM2 = MEMORY_BASE + state_fio->FgetInt32_LE();
+ for(int i = 0; i < 8; i++) {
+ RdMem[i] = MEMORY_BASE + state_fio->FgetInt32_LE();
+ WrMem[i] = MEMORY_BASE + state_fio->FgetInt32_LE();
+ }
+ VRAM = MEMORY_BASE + state_fio->FgetInt32_LE();
+ } else {
+ state_fio->FputInt32_LE((int)(CGROM - MEMORY_BASE));
+ state_fio->FputInt32_LE((int)(EXTROM1 - MEMORY_BASE));
+ state_fio->FputInt32_LE((int)(EXTROM2 - MEMORY_BASE));
+ for(int i = 0; i < 8; i++) {
+ state_fio->FputInt32_LE((int)(RdMem[i] - MEMORY_BASE));
+ state_fio->FputInt32_LE((int)(WrMem[i] - MEMORY_BASE));
+ }
+ state_fio->FputInt32_LE((int)(VRAM - MEMORY_BASE));
+ }
+ state_fio->StateBuffer(EnWrite, sizeof(EnWrite), 1);
+ state_fio->StateUint8(CGSW93);
+ state_fio->StateBool(inserted);
+#ifndef _PC6001
+ state_fio->StateUint8(CRTKILL);
+ if(loading) {
+ CurKANJIROM = MEMORY_BASE + state_fio->FgetInt32_LE();
+ } else {
+ state_fio->FputInt32_LE((int)(CurKANJIROM - MEMORY_BASE));
+ }
+ state_fio->StateUint8(CRTMode1);
+ state_fio->StateUint8(CRTMode2);
+ state_fio->StateUint8(CRTMode3);
+ state_fio->StateUint8(CSS1);
+ state_fio->StateUint8(CSS2);
+ state_fio->StateUint8(CSS3);
+ state_fio->StateUint8(portF0);
+ state_fio->StateUint8(portF1);
+#if defined(_PC6601SR) || defined(_PC6001MK2SR)
+ state_fio->StateInt32(bitmap);
+ state_fio->StateInt32(cols);
+ state_fio->StateInt32(rows);
+ state_fio->StateInt32(lines);
+ if(loading) {
+ TEXTVRAM = MEMORY_BASE + state_fio->FgetInt32_LE();
+ SYSROM2 = MEMORY_BASE + state_fio->FgetInt32_LE();
+ } else {
+ state_fio->FputInt32_LE((int)(TEXTVRAM - MEMORY_BASE));
+ state_fio->FputInt32_LE((int)(SYSROM2 - MEMORY_BASE));
+ }
+ state_fio->StateBuffer(EXTRAM, EXTRAM_SIZE, 1);
+ state_fio->StateBuffer(port60, sizeof(port60), 1);
+ state_fio->StateUint8(portC1);
+ state_fio->StateUint8(portC8);
+ state_fio->StateUint8(portCA);
+ state_fio->StateUint8(portCB);
+ state_fio->StateUint8(portCC);
+ state_fio->StateUint8(portCE);
+ state_fio->StateUint8(portCF);
+ state_fio->StateBuffer(palet, sizeof(palet), 1);
+#endif
+#endif
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateInt32(sr_mode);
+ return true;
+}
return true;
}
+bool PSUB::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ // pre process
+ if(loading) {
+ close_tape();
+ }
+ state_fio->StateBool(play);
+ state_fio->StateBool(rec);
+ state_fio->StateBool(is_wav);
+ state_fio->StateBool(is_p6t);
+ state_fio->StateBuffer(rec_file_path, sizeof(rec_file_path), 1);
+ if(loading) {
+ int length_tmp = state_fio->FgetInt32_LE();
+ if(rec) {
+ fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ state_fio->Fread(buffer_tmp, length_rw, 1);
+ if(fio->IsOpened()) {
+ fio->Fwrite(buffer_tmp, length_rw, 1);
+ }
+ length_tmp -= length_rw;
+ }
+ }
+ } else {
+ if(rec && fio->IsOpened()) {
+ int length_tmp = (int)fio->Ftell();
+ fio->Fseek(0, FILEIO_SEEK_SET);
+ state_fio->FputInt32_LE(length_tmp);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ fio->Fread(buffer_tmp, length_rw, 1);
+ state_fio->Fwrite(buffer_tmp, length_rw, 1);
+ length_tmp -= length_rw;
+ }
+ } else {
+ state_fio->FputInt32_LE(0);
+ }
+ }
+ state_fio->StateInt32(CasIntFlag);
+ state_fio->StateInt32(CasIndex);
+ state_fio->StateInt32(CasRecv);
+ state_fio->StateInt32(CasMode);
+ state_fio->StateInt32(CasBaud);
+ state_fio->StateInt32(FileBaud);
+ state_fio->StateBuffer(CasData, sizeof(CasData), 1);
+ state_fio->StateInt32(CasLength);
+ state_fio->StateInt32(CasSkipFlag);
+ state_fio->StateInt32(kbFlagFunc);
+ state_fio->StateInt32(kbFlagGraph);
+ state_fio->StateInt32(kbFlagCtrl);
+ state_fio->StateInt32(kanaMode);
+ state_fio->StateInt32(katakana);
+ state_fio->StateInt32(p6key);
+ state_fio->StateInt32(stick0);
+ state_fio->StateInt32(StrigIntFlag);
+ state_fio->StateInt32(StrigEventID);
+ return true;
+}
return true;
}
+bool SUB::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateInt32(p1_out);
+ state_fio->StateInt32(p2_in);
+ state_fio->StateBool(drec_in);
+ state_fio->StateBool(rxrdy_in);
+ state_fio->StateBool(update_key);
+ state_fio->StateBool(rec);
+ state_fio->StateBool(is_wav);
+ state_fio->StateBool(is_p6t);
+ state_fio->StateBuffer(rec_file_path, sizeof(rec_file_path), 1);
+ if(loading) {
+ int length_tmp = state_fio->FgetInt32_LE();
+ if(rec) {
+ fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ state_fio->Fread(buffer_tmp, length_rw, 1);
+ if(fio->IsOpened()) {
+ fio->Fwrite(buffer_tmp, length_rw, 1);
+ }
+ length_tmp -= length_rw;
+ }
+ }
+ } else {
+ if(rec && fio->IsOpened()) {
+ int length_tmp = (int)fio->Ftell();
+ fio->Fseek(0, FILEIO_SEEK_SET);
+ state_fio->FputInt32_LE(length_tmp);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ fio->Fread(buffer_tmp, length_rw, 1);
+ state_fio->Fwrite(buffer_tmp, length_rw, 1);
+ length_tmp -= length_rw;
+ }
+ } else {
+ state_fio->FputInt32_LE(0);
+ }
+ }
+ state_fio->StateInt32(prev_command);
+ state_fio->StateInt32(baud);
+ state_fio->StateInt32(index);
+ state_fio->StateBool(skip);
+ state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+ return true;
+}
return true;
}
+bool TIMER::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(IRQ);
+ state_fio->StateUint8(NewIRQ);
+ state_fio->StateInt32(timer_id);
+#ifndef _PC6001
+#if defined(_PC6601SR) || defined(_PC6001MK2SR)
+ state_fio->StateBuffer(sr_vectors, sizeof(sr_vectors), 1);
+ state_fio->StateUint8(portFA);
+ state_fio->StateUint8(portFB);
+#endif
+ state_fio->StateUint8(portF3);
+ state_fio->StateUint8(portF4);
+ state_fio->StateUint8(portF5);
+ state_fio->StateUint8(portF6);
+ state_fio->StateUint8(portF7);
+#endif
+ return true;
+}
return true;
}
+bool CMT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(is_wav);
+ state_fio->StateBool(rec);
+ state_fio->StateBool(remote);
+ state_fio->StateBuffer(rec_file_path, sizeof(rec_file_path), 1);
+ if(loading) {
+ int length_tmp = state_fio->FgetInt32_LE();
+ if(rec) {
+ fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ state_fio->Fread(buffer_tmp, length_rw, 1);
+ if(fio->IsOpened()) {
+ fio->Fwrite(buffer_tmp, length_rw, 1);
+ }
+ length_tmp -= length_rw;
+ }
+ }
+ } else {
+ if(rec && fio->IsOpened()) {
+ int length_tmp = (int)fio->Ftell();
+ fio->Fseek(0, FILEIO_SEEK_SET);
+ state_fio->FputInt32_LE(length_tmp);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ fio->Fread(buffer_tmp, length_rw, 1);
+ state_fio->Fwrite(buffer_tmp, length_rw, 1);
+ length_tmp -= length_rw;
+ }
+ } else {
+ state_fio->FputInt32_LE(0);
+ }
+ }
+ state_fio->StateInt32(bufcnt);
+ state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+ state_fio->StateInt32(prev_signal);
+ state_fio->StateUint32(prev_clock);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint16(column);
+ state_fio->StateBool(caps);
+ state_fio->StateBool(kana);
+ return true;
+}
return true;
}
+bool LCD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(seg, sizeof(seg), 1);
+ state_fio->StateUint16(sel);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint8(sio);
+ state_fio->StateUint8(bank);
+
+ // post process
+ if(loading) {
+ update_bank();
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
}
#endif
+bool CALENDAR::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(ch);
+ return true;
+}
return true;
}
+bool FLOPPY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(ctrlreg);
+ state_fio->StateUint8(modereg);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(kana);
+ state_fio->StateBool(caps);
+ state_fio->StateBuffer(flag, sizeof(flag), 1);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(learn, sizeof(learn), 1);
+#ifdef _PC98HA
+ state_fio->StateBuffer(ramdrv, sizeof(ramdrv), 1);
+ state_fio->StateBuffer(ems, sizeof(ems), 1);
+ state_fio->StateBuffer(memcard, sizeof(memcard), 1);
+#endif
+ state_fio->StateUint32(learn_crc32);
+#ifdef _PC98HA
+ state_fio->StateUint32(ramdrv_crc32);
+ state_fio->StateUint32(memcard_crc32);
+#endif
+ state_fio->StateUint8(learn_bank);
+ state_fio->StateUint8(dic_bank);
+ state_fio->StateUint8(kanji_bank);
+ state_fio->StateUint8(romdrv_bank);
+#ifdef _PC98HA
+ state_fio->StateUint8(ramdrv_bank);
+ state_fio->StateUint8(ramdrv_sel);
+ state_fio->StateBuffer(ems_bank, sizeof(ems_bank), 1);
+#endif
+
+ // post process
+ if(loading) {
+ update_bank();
+ }
+ return true;
+}
return true;
}
+bool NOTE::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(ch);
+ state_fio->StateBuffer(regs, sizeof(regs), 1);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(status, sizeof(status), 1);
+ state_fio->StateUint8(sysport);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+#ifdef _MAP1010
+ state_fio->StateInt32(kana_pressed);
+#else
+ state_fio->StateBuffer(status, sizeof(status), 1);
+#endif
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool SYSTEM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(sysport);
+ return true;
+}
return true;
}
+bool JOYSTICK::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(column);
+ state_fio->StateUint8(status);
+ return true;
+}
return true;
}
+bool PSG::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ for(int i = 0; i < 3; i++) {
+ state_fio->StateInt32(ch[i].period);
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(mem, sizeof(mem), 1);
+ state_fio->StateBool(inserted);
+ return true;
+}
return true;
}
+bool VDP::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(loading) {
+ vram = base + state_fio->FgetInt32_LE();
+ pcg = base + state_fio->FgetInt32_LE();
+ pattern = base + state_fio->FgetInt32_LE();
+ } else {
+ state_fio->FputInt32_LE((int)(vram - base));
+ state_fio->FputInt32_LE((int)(pcg - base));
+ state_fio->FputInt32_LE((int)(pattern - base));
+ }
+ state_fio->StateBool(force_pattern);
+ return true;
+}
return true;
}
+bool CMT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateInt32(bufcnt);
+ state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+ state_fio->StateBool(play);
+ state_fio->StateBool(rec);
+ state_fio->StateUint8(start);
+ state_fio->StateUint8(bit);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(key_stat, sizeof(key_stat), 1);
+ state_fio->StateInt32(key_no);
+ state_fio->StateBool(intr_enb);
+ return true;
+}
return true;
}
+bool PRINTER::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(out);
+ state_fio->StateUint8(ctrl0);
+ state_fio->StateUint8(ctrl1);
+ state_fio->StateBool(busy);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(ext, sizeof(ext), 1);
+ state_fio->StateBool(inserted);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(cmt_signal);
+ state_fio->StateBool(cmt_remote);
+ state_fio->StateBool(has_extrom);
+ state_fio->StateBool(cart_enabled);
+ state_fio->StateInt32(ctype);
+
+ // post process
+ if(loading) {
+ if(cart_enabled) {
+ ENABLE_CART();
+ } else {
+ DISABLE_CART();
+ }
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+#ifdef _COLOR_MONITOR
+ state_fio->StateBuffer(vram_r, sizeof(vram_r), 1);
+ state_fio->StateBuffer(vram_g, sizeof(vram_g), 1);
+ state_fio->StateBuffer(vram_b, sizeof(vram_b), 1);
+#else
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+#endif
+ state_fio->StateUint8(bank);
+ state_fio->StateInt32(blink);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(led, sizeof(led), 1);
+ state_fio->StateBool(repeat);
+ state_fio->StateBool(enable);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(cmos, sizeof(cmos), 1);
+ state_fio->StateUint32(cmos_crc32);
+ state_fio->StateUint8(bank);
+ state_fio->StateUint8(psel);
+ state_fio->StateUint8(csel);
+ state_fio->StateBool(pcm_on);
+ state_fio->StateBool(pcm_cont);
+ state_fio->StateBool(pcm_pit);
+ state_fio->StateBool(fdc_irq);
+ state_fio->StateBool(motor);
+
+ // post process
+ if(loading) {
+ update_map();
+ }
+ return true;
+}
return true;
}
+bool MFONT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(status);
+ if(!cmd->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ if(!res->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool CMT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(in);
+ state_fio->StateBool(out);
+ state_fio->StateBool(remote);
+ state_fio->StateBool(now_acc);
+ state_fio->StateInt32(framecnt);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(status, sizeof(status), 1);
+ state_fio->StateUint8(column);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(ext, sizeof(ext), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateInt32(rpage);
+ state_fio->StateInt32(wpage);
+ state_fio->StateBool(inserted);
+ return true;
+}
return true;
}
+bool PRINTER::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(strobe);
+ state_fio->StateBool(busy);
+ state_fio->StateUint8(out);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool VDP::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+ state_fio->StateBuffer(reg, sizeof(reg), 1);
+ state_fio->StateUint8(bg);
+ state_fio->StateUint8(cmask);
+ state_fio->StateUint8(pmask);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(column);
+ state_fio->StateBool(break_pressed);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBool(inserted);
+ state_fio->StateBool(ram_selected);
+ state_fio->StateBuffer(bank, sizeof(bank), 1);
+
+ // post process
+ if(loading) {
+ update_bank();
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool IO::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(pa);
+ state_fio->StateUint8(pb);
+ state_fio->StateUint8(pc);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(save_path, sizeof(save_path), 1);
+ state_fio->StateBuffer(&header, sizeof(header), 1);
+ state_fio->StateBool(inserted);
+ state_fio->StateUint32(sram_crc32);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateBuffer(wreg, sizeof(wreg), 1);
+ state_fio->StateBuffer(sram, sizeof(sram), 1);
+ state_fio->StateUint8(cur_bank);
+
+ // post process
+ if(loading) {
+ set_bank(cur_bank);
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool SOUND::process_state(FILEIO* state_fio, bool loading)
+{
+ // pre process
+ int tone_diff = tone.diff;
+ int noise_diff = noise.diff;
+ int square1_diff = square1.diff;
+ int square2_diff = square2.diff;
+ int square3_diff = square3.diff;
+ int pcm_diff = pcm.diff;
+
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(&tone, sizeof(tone), 1);
+ state_fio->StateBuffer(&noise, sizeof(noise), 1);
+ state_fio->StateBuffer(&square1, sizeof(square1), 1);
+ state_fio->StateBuffer(&square2, sizeof(square2), 1);
+ state_fio->StateBuffer(&square3, sizeof(square3), 1);
+ state_fio->StateBuffer(&pcm, sizeof(pcm), 1);
+ state_fio->StateBuffer(pcm_table, sizeof(pcm_table), 1);
+ state_fio->StateUint32(cmd_addr);
+ state_fio->StateInt32(pcm_len);
+ state_fio->StateInt32(param_cnt);
+ state_fio->StateInt32(param_ptr);
+ state_fio->StateInt32(register_id);
+ state_fio->StateBuffer(params, sizeof(params), 1);
+
+ // post process
+ if(loading) {
+ tone.diff = tone_diff;
+ noise.diff = noise_diff;
+ square1.diff = square1_diff;
+ square2.diff = square2_diff;
+ square3.diff = square3_diff;
+ pcm.diff = pcm_diff;
+ }
+ return true;
+}
return true;
}
+bool VDP::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(vdc0);
+ state_fio->StateUint8(vdc1);
+ state_fio->StateUint8(vdc2);
+ state_fio->StateUint8(vdc3);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint8(pio1_pa);
+ state_fio->StateUint8(pio1_pb);
+ state_fio->StateUint8(shift_reg);
+ state_fio->StateUint32(a15_mask);
+ state_fio->StateBool(led);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(cram, sizeof(cram), 1);
+ state_fio->StateBuffer(aram, sizeof(aram), 1);
+ state_fio->StateBuffer(pcg, sizeof(pcg), 1);
+ state_fio->StateBuffer(gram, sizeof(gram), 1);
+ state_fio->StateBool(rom_selected);
+ state_fio->StateInt32(rom_switch_wait);
+ state_fio->StateInt32(ram_switch_wait);
+ state_fio->StateBuffer(keytable, sizeof(keytable), 1);
+ state_fio->StateBuffer(keytable_shift, sizeof(keytable_shift), 1);
+ state_fio->StateBuffer(keytable_ctrl, sizeof(keytable_ctrl), 1);
+ state_fio->StateBuffer(keytable_kana, sizeof(keytable_kana), 1);
+ state_fio->StateBuffer(keytable_kana_shift, sizeof(keytable_kana_shift), 1);
+ state_fio->StateUint8(key_code);
+ state_fio->StateUint8(key_status);
+ state_fio->StateUint8(key_cmd);
+ state_fio->StateInt32(key_repeat_start);
+ state_fio->StateInt32(key_repeat_interval);
+ state_fio->StateInt32(key_repeat_event);
+ state_fio->StateUint8(funckey_code);
+ state_fio->StateInt32(funckey_index);
+ state_fio->StateBool(caps);
+ state_fio->StateBool(kana);
+ state_fio->StateUint8(gcw);
+ state_fio->StateBool(vsup);
+ state_fio->StateBool(vsync);
+ state_fio->StateBool(disp);
+ state_fio->StateInt32(cblink);
+#if defined(_SMC777)
+ state_fio->StateBool(use_palette_text);
+ state_fio->StateBool(use_palette_graph);
+ state_fio->StateBuffer(pal, sizeof(pal), 1);
+ state_fio->StateBuffer(palette_pc, sizeof(palette_pc), 1);
+#endif
+ state_fio->StateInt32(kanji_hi);
+ state_fio->StateInt32(kanji_lo);
+ state_fio->StateBool(ief_key);
+ state_fio->StateBool(ief_vsync);
+ state_fio->StateBool(fdc_irq);
+ state_fio->StateBool(fdc_drq);
+ state_fio->StateBool(drec_in);
+#if defined(_SMC70)
+ state_fio->StateUint8(rtc_data);
+ state_fio->StateBool(rtc_busy);
+#endif
+
+ // post process
+ if(loading) {
+ if(rom_selected) {
+ SET_BANK(0x0000, sizeof(rom) - 1, wdmy, rom);
+ } else {
+ SET_BANK(0x0000, sizeof(rom) - 1, ram, ram);
+ }
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool CMT::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBool(mic);
+ state_fio->StateBool(ear);
+ state_fio->StateBool(pulse);
+ state_fio->StateInt32(pulse_count);
+#if defined(_TK80BS)
+ state_fio->StateBool(play);
+ state_fio->StateBool(rec);
+ state_fio->StateBuffer(rec_file_path, sizeof(rec_file_path), 1);
+ if(loading) {
+ int length_tmp = state_fio->FgetInt32_LE();
+ if(rec) {
+ fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ state_fio->Fread(buffer_tmp, length_rw, 1);
+ if(fio->IsOpened()) {
+ fio->Fwrite(buffer_tmp, length_rw, 1);
+ }
+ length_tmp -= length_rw;
+ }
+ }
+ } else {
+ if(rec && fio->IsOpened()) {
+ int length_tmp = (int)fio->Ftell();
+ fio->Fseek(0, FILEIO_SEEK_SET);
+ state_fio->FputInt32_LE(length_tmp);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ fio->Fread(buffer_tmp, length_rw, 1);
+ state_fio->Fwrite(buffer_tmp, length_rw, 1);
+ length_tmp -= length_rw;
+ }
+ } else {
+ state_fio->FputInt32_LE(0);
+ }
+ }
+ state_fio->StateInt32(bufcnt);
+ state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+#endif
+ return true;
+}
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+#if defined(_TK80BS)
+ state_fio->StateInt32(mode);
+#endif
+ state_fio->StateBool(dma);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+#if defined(_TK80BS)
+ state_fio->StateUint8(prev_type);
+ state_fio->StateUint8(prev_brk);
+ state_fio->StateUint8(prev_kana);
+ state_fio->StateBool(kana_lock);
+ state_fio->StateUint32(kb_type);
+#endif
+ state_fio->StateUint32(column);
+ return true;
+}
//#endif
return MEMORY::load_state(state_fio);
}
+bool MEMBUS::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+#if defined(_TK85)
+ state_fio->StateUint32(pc7);
+ state_fio->StateUint32(count);
+#endif
+ return MEMORY::process_state(state_fio, loading);
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+#if defined(_TK80BS)
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ state_fio->StateInt32(boot_mode);
+// state_fio->StateInt32(draw_ranges);
+
+ // post process
+ if(loading) {
+ emu->reload_bitmap();
+ draw_ranges = 8;
+ }
+#endif
+ return true;
+}
return true;
}
+bool IO::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(rregs, sizeof(rregs), 1);
+ state_fio->StateBuffer(wregs, sizeof(wregs), 1);
+ if(!cur_time.process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateInt32(register_id_1sec);
+ if(!cmd_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ if(!rsp_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateUint8(sub_int);
+ state_fio->StateBuffer(wram, sizeof(wram), 1);
+ state_fio->StateBuffer(alarm, sizeof(alarm), 1);
+ if(!key_buf->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateBool(ctrl);
+ state_fio->StateBool(shift);
+ state_fio->StateBool(kana);
+ state_fio->StateBool(graph);
+ state_fio->StateBool(brk);
+ state_fio->StateUint8(stick);
+ state_fio->StateUint8(strig);
+ state_fio->StateUint8(strig1);
+ state_fio->StateBool(cmt_play);
+ state_fio->StateBool(cmt_rec);
+ state_fio->StateBool(cmt_mode);
+ state_fio->StateBuffer(rec_file_path, sizeof(rec_file_path), 1);
+ if(loading) {
+ int length_tmp = state_fio->FgetInt32_LE();
+ if(cmt_rec) {
+ cmt_fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ state_fio->Fread(buffer_tmp, length_rw, 1);
+ if(cmt_fio->IsOpened()) {
+ cmt_fio->Fwrite(buffer_tmp, length_rw, 1);
+ }
+ length_tmp -= length_rw;
+ }
+ }
+ } else {
+ if(cmt_rec && cmt_fio->IsOpened()) {
+ int length_tmp = (int)cmt_fio->Ftell();
+ cmt_fio->Fseek(0, FILEIO_SEEK_SET);
+ state_fio->FputInt32_LE(length_tmp);
+ while(length_tmp != 0) {
+ uint8_t buffer_tmp[1024];
+ int length_rw = min(length_tmp, (int)sizeof(buffer_tmp));
+ cmt_fio->Fread(buffer_tmp, length_rw, 1);
+ state_fio->Fwrite(buffer_tmp, length_rw, 1);
+ length_tmp -= length_rw;
+ }
+ } else {
+ state_fio->FputInt32_LE(0);
+ }
+ }
+ state_fio->StateInt32(cmt_len);
+ state_fio->StateInt32(cmt_ptr);
+ state_fio->StateBuffer(cmt_buf, sizeof(cmt_buf), 1);
+ state_fio->StateBool(vblank);
+ state_fio->StateUint8(font_code);
+ state_fio->StateBuffer(udc, sizeof(udc), 1);
+ state_fio->StateBuffer(lcd, sizeof(lcd), 1);
+ state_fio->StateBool(locate_on);
+ state_fio->StateBool(cursor_on);
+ state_fio->StateBool(udk_on);
+ state_fio->StateInt32(locate_x);
+ state_fio->StateInt32(locate_y);
+ state_fio->StateInt32(cursor_x);
+ state_fio->StateInt32(cursor_y);
+ state_fio->StateInt32(cursor_blink);
+ state_fio->StateInt32(scroll_min);
+ state_fio->StateInt32(scroll_max);
+ state_fio->StateInt32(register_id_beep);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ return true;
+}
return true;
}
+bool IO::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(pb);
+ state_fio->StateUint8(pc);
+ state_fio->StateUint8(div_counter);
+ state_fio->StateUint8(counter);
+ state_fio->StateInt32(posi_counter);
+ state_fio->StateInt32(nega_counter);
+ state_fio->StateBool(drec_in);
+ state_fio->StateBool(drec_toggle);
+ state_fio->StateUint32(prev_clock);
+ state_fio->StateInt32(register_id);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBuffer(vram, sizeof(vram), 1);
+ return true;
+}
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ if(!cmd_buffer->process_state((void *)state_fio, loading)) {
+ return false;
+ }
+ state_fio->StateInt32(active_cmd);
+ state_fio->StateUint8(dpp_data);
+ state_fio->StateUint8(dpp_ctrl);
+ state_fio->StateInt32(scroll_x0);
+ state_fio->StateInt32(scroll_y0);
+ state_fio->StateInt32(scroll_x1);
+ state_fio->StateInt32(scroll_y1);
+ state_fio->StateInt32(cursor_x);
+ state_fio->StateInt32(cursor_y);
+ state_fio->StateInt32(read_x);
+ state_fio->StateInt32(read_y);
+ state_fio->StateUint8(mode1);
+ state_fio->StateUint8(mode2);
+ state_fio->StateUint8(mode3);
+ state_fio->StateUint32(report);
+ state_fio->StateBool(write_cr);
+ state_fio->StateBuffer(cvram, sizeof(cvram), 1);
+ state_fio->StateBuffer(gvram, sizeof(gvram), 1);
+ state_fio->StateInt32(window_x0);
+ state_fio->StateInt32(window_y0);
+ state_fio->StateInt32(window_x1);
+ state_fio->StateInt32(window_y1);
+ state_fio->StateInt32(view_x0);
+ state_fio->StateInt32(view_y0);
+ state_fio->StateInt32(view_x1);
+ state_fio->StateInt32(view_y1);
+ state_fio->StateDouble(expand);
+ state_fio->StateInt32(rotate);
+ state_fio->StateInt32(translate_x);
+ state_fio->StateInt32(translate_y);
+ state_fio->StateInt32(point_x);
+ state_fio->StateInt32(point_y);
+ state_fio->StateInt32(fore_color);
+ state_fio->StateInt32(back_color);
+ state_fio->StateBool(erase);
+ state_fio->StateInt32(texture);
+ state_fio->StateInt32(texture_index);
+ state_fio->StateInt32(pattern);
+ state_fio->StateBuffer(palette_graph, sizeof(palette_graph), 1);
+ state_fio->StateInt32(blink);
+ return true;
+}
return true;
}
+bool KEYBOARD::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateUint8(column);
+ state_fio->StateBool(caps_locked);
+ state_fio->StateBool(kana_locked);
+ return true;
+}
return true;
}
+bool MAPPER::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint8(mapper_reg);
+ state_fio->StateBuffer(bank_reg, sizeof(bank_reg), 1);
+// state_fio->StateBuffer(cur_bank, sizeof(cur_bank), 1);
+
+ // post process
+ if(loading) {
+ for(int i = 0; i < 15; i++) {
+ cur_bank[i] = -1;
+ update_bank(i);
+ }
+ }
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}
return true;
}
+bool DISPLAY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(seg, sizeof(seg), 1);
+ state_fio->StateUint8(pb);
+ state_fio->StateUint8(pc);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ return true;
+}
return true;
}
+bool MEMORY::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBool(inserted);
+ return true;
+}
return true;
}
+bool VM::process_state(FILEIO* state_fio, bool loading)
+{
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ for(DEVICE* device = first_device; device; device = device->next_device) {
+ const char *name = typeid(*device).name() + 6; // skip "class "
+ int len = strlen(name);
+
+ if(!state_fio->StateCheckInt32(len)) {
+ return false;
+ }
+ if(!state_fio->StateCheckBuffer(name, len, 1)) {
+ return false;
+ }
+ if(!device->process_state(state_fio, loading)) {
+ return false;
+ }
+ }
+ return true;
+}