#define STATE_VERSION 1
-void CMT::save_state(FILEIO* state_fio)
+#include "../../statesub.h"
+
+void CMT::decl_state()
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_BOOL(is_wav);
+ DECL_STATE_ENTRY_BOOL(rec);
+ DECL_STATE_ENTRY_BOOL(remote);
+ DECL_STATE_ENTRY_STRING(rec_file_path, sizeof(rec_file_path));
+ DECL_STATE_ENTRY_CMT_RECORDING(fio, rec, rec_file_path);
- state_fio->FputBool(is_wav);
- state_fio->FputBool(rec);
- state_fio->FputBool(remote);
- state_fio->Fwrite(rec_file_path, sizeof(rec_file_path), 1);
- if(rec && fio->IsOpened()) {
- int length_tmp = (int)fio->Ftell();
- fio->Fseek(0, FILEIO_SEEK_SET);
- state_fio->FputInt32(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(0);
+ DECL_STATE_ENTRY_INT32(bufcnt);
+ DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
+ DECL_STATE_ENTRY_INT32(prev_signal);
+ DECL_STATE_ENTRY_UINT32(prev_clock);
+
+ leave_decl_state();
+}
+
+void CMT::save_state(FILEIO* state_fio)
+{
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
}
- state_fio->FputInt32(bufcnt);
- state_fio->Fwrite(buffer, sizeof(buffer), 1);
- state_fio->FputInt32(prev_signal);
- state_fio->FputUint32(prev_clock);
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+//
+// state_fio->FputBool(is_wav);
+// state_fio->FputBool(rec);
+// state_fio->FputBool(remote);
+// state_fio->Fwrite(rec_file_path, sizeof(rec_file_path), 1);
+// if(rec && fio->IsOpened()) {
+// int length_tmp = (int)fio->Ftell();
+// fio->Fseek(0, FILEIO_SEEK_SET);
+// state_fio->FputInt32(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(0);
+// }
+// state_fio->FputInt32(bufcnt);
+// state_fio->Fwrite(buffer, sizeof(buffer), 1);
+// state_fio->FputInt32(prev_signal);
+// state_fio->FputUint32(prev_clock);
}
bool CMT::load_state(FILEIO* state_fio)
{
close_tape();
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- is_wav = state_fio->FgetBool();
- rec = state_fio->FgetBool();
- remote = state_fio->FgetBool();
- state_fio->Fread(rec_file_path, sizeof(rec_file_path), 1);
- int length_tmp = state_fio->FgetInt32();
- 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;
- }
- }
- bufcnt = state_fio->FgetInt32();
- state_fio->Fread(buffer, sizeof(buffer), 1);
- prev_signal = state_fio->FgetInt32();
- prev_clock = state_fio->FgetUint32();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// is_wav = state_fio->FgetBool();
+// rec = state_fio->FgetBool();
+// remote = state_fio->FgetBool();
+// state_fio->Fread(rec_file_path, sizeof(rec_file_path), 1);
+// int length_tmp = state_fio->FgetInt32();
+// 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;
+// }
+// }
+// bufcnt = state_fio->FgetInt32();
+// state_fio->Fread(buffer, sizeof(buffer), 1);
+// prev_signal = state_fio->FgetInt32();
+// prev_clock = state_fio->FgetUint32();
return true;
}
void release();
void reset();
void write_signal(int id, uint32_t data, uint32_t mask);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
+#include "../../statesub.h"
+
+void KEYBOARD::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_UINT16(column);
+ DECL_STATE_ENTRY_BOOL(caps);
+ DECL_STATE_ENTRY_BOOL(kana);
+
+ leave_decl_state();
+}
+
void KEYBOARD::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->FputUint16(column);
- state_fio->FputBool(caps);
- state_fio->FputBool(kana);
+// state_fio->FputUint16(column);
+// state_fio->FputBool(caps);
+// state_fio->FputBool(kana);
}
bool KEYBOARD::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- column = state_fio->FgetUint16();
- caps = state_fio->FgetBool();
- kana = state_fio->FgetBool();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// column = state_fio->FgetUint16();
+// caps = state_fio->FgetBool();
+// kana = state_fio->FgetBool();
return true;
}
void initialize();
uint32_t read_io8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
+#include "../../statesub.h"
+
+void LCD::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ for(int i = 0; i < 10; i++) {
+ DECL_STATE_ENTRY_2D_ARRAY_MEMBER((seg[i].vram), 4, 50, i);
+ DECL_STATE_ENTRY_INT32_MEMBER((seg[i].updown), i);
+ DECL_STATE_ENTRY_INT32_MEMBER((seg[i].disp), i);
+ DECL_STATE_ENTRY_INT32_MEMBER((seg[i].spg), i);
+ DECL_STATE_ENTRY_INT32_MEMBER((seg[i].page), i);
+ DECL_STATE_ENTRY_INT32_MEMBER((seg[i].ofs), i);
+ DECL_STATE_ENTRY_INT32_MEMBER((seg[i].ofs2), i);
+ }
+ DECL_STATE_ENTRY_UINT16(sel);
+
+ leave_decl_state();
+}
+
void LCD::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->Fwrite(seg, sizeof(seg), 1);
- state_fio->FputUint16(sel);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+//
+// state_fio->Fwrite(seg, sizeof(seg), 1);
+// state_fio->FputUint16(sel);
}
bool LCD::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- state_fio->Fread(seg, sizeof(seg), 1);
- sel = state_fio->FgetUint16();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(seg, sizeof(seg), 1);
+// sel = state_fio->FgetUint16();
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);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
+#include "../../statesub.h"
+
+void MEMORY::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
+ DECL_STATE_ENTRY_UINT8(sio);
+ DECL_STATE_ENTRY_UINT8(bank);
+
+ leave_decl_state();
+}
+
void MEMORY::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->Fwrite(ram, sizeof(ram), 1);
- state_fio->FputUint8(sio);
- state_fio->FputUint8(bank);
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->FputUint8(sio);
+// state_fio->FputUint8(bank);
}
bool MEMORY::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- state_fio->Fread(ram, sizeof(ram), 1);
- sio = state_fio->FgetUint8();
- bank = state_fio->FgetUint8();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(ram, sizeof(ram), 1);
+// sio = state_fio->FgetUint8();
+// bank = state_fio->FgetUint8();
// post process
update_bank();
uint32_t read_data8(uint32_t addr);
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#ifdef _PC98HA
#define STATE_VERSION 1
+#include "../../statesub.h"
+
+void CALENDAR::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_UINT8(ch);
+
+ leave_decl_state();
+}
+
void CALENDAR::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->FputUint8(ch);
+// state_fio->FputUint8(ch);
}
bool CALENDAR::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- ch = state_fio->FgetUint8();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// ch = state_fio->FgetUint8();
return true;
}
#endif
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
#ifdef _PC98HA
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#endif
#define STATE_VERSION 1
+
+#include "../../statesub.h"
+
+void FLOPPY::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_UINT8(ctrlreg);
+ DECL_STATE_ENTRY_UINT8(modereg);
+
+ leave_decl_state();
+}
+
void FLOPPY::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->FputUint8(ctrlreg);
- state_fio->FputUint8(modereg);
+// state_fio->FputUint8(ctrlreg);
+// state_fio->FputUint8(modereg);
}
bool FLOPPY::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- ctrlreg = state_fio->FgetUint8();
- modereg = state_fio->FgetUint8();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// ctrlreg = state_fio->FgetUint8();
+// modereg = state_fio->FgetUint8();
return true;
}
void reset();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
+#include "../../statesub.h"
+
+void KEYBOARD::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_BOOL(kana);
+ DECL_STATE_ENTRY_BOOL(caps);
+ DECL_STATE_ENTRY_1D_ARRAY(flag, sizeof(flag));
+
+ leave_decl_state();
+}
+
void KEYBOARD::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->FputBool(kana);
- state_fio->FputBool(caps);
- state_fio->Fwrite(flag, sizeof(flag), 1);
+// state_fio->FputBool(kana);
+// state_fio->FputBool(caps);
+// state_fio->Fwrite(flag, sizeof(flag), 1);
}
bool KEYBOARD::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- kana = state_fio->FgetBool();
- caps = state_fio->FgetBool();
- state_fio->Fread(flag, sizeof(flag), 1);
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// kana = state_fio->FgetBool();
+// caps = state_fio->FgetBool();
+// state_fio->Fread(flag, sizeof(flag), 1);
return true;
}
// common functions
void initialize();
void reset();
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
-void MEMORY::save_state(FILEIO* state_fio)
+#include "../../statesub.h"
+
+void MEMORY::decl_state()
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->Fwrite(ram, sizeof(ram), 1);
- state_fio->Fwrite(vram, sizeof(vram), 1);
- state_fio->Fwrite(learn, sizeof(learn), 1);
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
+ DECL_STATE_ENTRY_1D_ARRAY(learn, sizeof(learn));
#ifdef _PC98HA
- state_fio->Fwrite(ramdrv, sizeof(ramdrv), 1);
- state_fio->Fwrite(ems, sizeof(ems), 1);
- state_fio->Fwrite(memcard, sizeof(memcard), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(ramdrv, sizeof(ramdrv));
+ DECL_STATE_ENTRY_1D_ARRAY(ems, sizeof(ems));
+ DECL_STATE_ENTRY_1D_ARRAY(memcard, sizeof(memcard));
#endif
- state_fio->FputUint32(learn_crc32);
+ DECL_STATE_ENTRY_UINT32(learn_crc32);
#ifdef _PC98HA
- state_fio->FputUint32(ramdrv_crc32);
- state_fio->FputUint32(memcard_crc32);
+ DECL_STATE_ENTRY_UINT32(ramdrv_crc32);
+ DECL_STATE_ENTRY_UINT32(memcard_crc32);
#endif
- state_fio->FputUint8(learn_bank);
- state_fio->FputUint8(dic_bank);
- state_fio->FputUint8(kanji_bank);
- state_fio->FputUint8(romdrv_bank);
+ DECL_STATE_ENTRY_UINT8(learn_bank);
+ DECL_STATE_ENTRY_UINT8(dic_bank);
+ DECL_STATE_ENTRY_UINT8(kanji_bank);
+ DECL_STATE_ENTRY_UINT8(romdrv_bank);
#ifdef _PC98HA
- state_fio->FputUint8(ramdrv_bank);
- state_fio->FputUint8(ramdrv_sel);
- state_fio->Fwrite(ems_bank, sizeof(ems_bank), 1);
+ DECL_STATE_ENTRY_UINT8(ramdrv_bank);
+ DECL_STATE_ENTRY_UINT8(ramdrv_sel);
+ DECL_STATE_ENTRY_1D_ARRAY(ems_bank, sizeof(ems_bank));
#endif
+
+ leave_decl_state();
+}
+
+void MEMORY::save_state(FILEIO* state_fio)
+{
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->Fwrite(vram, sizeof(vram), 1);
+// state_fio->Fwrite(learn, sizeof(learn), 1);
+//#ifdef _PC98HA
+// state_fio->Fwrite(ramdrv, sizeof(ramdrv), 1);
+// state_fio->Fwrite(ems, sizeof(ems), 1);
+// state_fio->Fwrite(memcard, sizeof(memcard), 1);
+//#endif
+// state_fio->FputUint32(learn_crc32);
+//#ifdef _PC98HA
+// state_fio->FputUint32(ramdrv_crc32);
+// state_fio->FputUint32(memcard_crc32);
+//#endif
+// state_fio->FputUint8(learn_bank);
+// state_fio->FputUint8(dic_bank);
+// state_fio->FputUint8(kanji_bank);
+// state_fio->FputUint8(romdrv_bank);
+//#ifdef _PC98HA
+// state_fio->FputUint8(ramdrv_bank);
+// state_fio->FputUint8(ramdrv_sel);
+// state_fio->Fwrite(ems_bank, sizeof(ems_bank), 1);
+//#endif
}
bool MEMORY::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- state_fio->Fread(ram, sizeof(ram), 1);
- state_fio->Fread(vram, sizeof(vram), 1);
- state_fio->Fread(learn, sizeof(learn), 1);
-#ifdef _PC98HA
- state_fio->Fread(ramdrv, sizeof(ramdrv), 1);
- state_fio->Fread(ems, sizeof(ems), 1);
- state_fio->Fread(memcard, sizeof(memcard), 1);
-#endif
- learn_crc32 = state_fio->FgetUint32();
-#ifdef _PC98HA
- ramdrv_crc32 = state_fio->FgetUint32();
- memcard_crc32 = state_fio->FgetUint32();
-#endif
- learn_bank = state_fio->FgetUint8();
- dic_bank = state_fio->FgetUint8();
- kanji_bank = state_fio->FgetUint8();
- romdrv_bank = state_fio->FgetUint8();
-#ifdef _PC98HA
- ramdrv_bank = state_fio->FgetUint8();
- ramdrv_sel = state_fio->FgetUint8();
- state_fio->Fread(ems_bank, sizeof(ems_bank), 1);
-#endif
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(ram, sizeof(ram), 1);
+// state_fio->Fread(vram, sizeof(vram), 1);
+// state_fio->Fread(learn, sizeof(learn), 1);
+//#ifdef _PC98HA
+// state_fio->Fread(ramdrv, sizeof(ramdrv), 1);
+// state_fio->Fread(ems, sizeof(ems), 1);
+// state_fio->Fread(memcard, sizeof(memcard), 1);
+//#endif
+// learn_crc32 = state_fio->FgetUint32();
+//#ifdef _PC98HA
+// ramdrv_crc32 = state_fio->FgetUint32();
+// memcard_crc32 = state_fio->FgetUint32();
+//#endif
+// learn_bank = state_fio->FgetUint8();
+// dic_bank = state_fio->FgetUint8();
+// kanji_bank = state_fio->FgetUint8();
+// romdrv_bank = state_fio->FgetUint8();
+//#ifdef _PC98HA
+// ramdrv_bank = state_fio->FgetUint8();
+// ramdrv_sel = state_fio->FgetUint8();
+// state_fio->Fread(ems_bank, sizeof(ems_bank), 1);
+//#endif
// post process
update_bank();
uint32_t read_data8(uint32_t addr);
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
+#include "../../statesub.h"
+
+void NOTE::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_UINT8(ch);
+ DECL_STATE_ENTRY_1D_ARRAY(regs, sizeof(regs));
+
+ leave_decl_state();
+}
+
void NOTE::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->FputUint8(ch);
- state_fio->Fwrite(regs, sizeof(regs), 1);
+// state_fio->FputUint8(ch);
+// state_fio->Fwrite(regs, sizeof(regs), 1);
}
bool NOTE::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- ch = state_fio->FgetUint8();
- state_fio->Fread(regs, sizeof(regs), 1);
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// ch = state_fio->FgetUint8();
+// state_fio->Fread(regs, sizeof(regs), 1);
return true;
}
void initialize();
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
-void DISPLAY::save_state(FILEIO* state_fio)
+#include "../../statesub.h"
+
+void DISPLAY::decl_state()
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
+ enter_decl_state(STATE_VERSION);
+
#if defined(_TK80BS)
- state_fio->FputInt32(mode);
+ DECL_STATE_ENTRY_INT32(mode);
#endif
- state_fio->FputBool(dma);
+ DECL_STATE_ENTRY_BOOL(dma);
+
+ leave_decl_state();
+}
+
+void DISPLAY::save_state(FILEIO* state_fio)
+{
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+//
+//#if defined(_TK80BS)
+// state_fio->FputInt32(mode);
+//#endif
+// state_fio->FputBool(dma);
}
bool DISPLAY::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
-#if defined(_TK80BS)
- mode = state_fio->FgetInt32();
-#endif
- dma = state_fio->FgetBool();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+//#if defined(_TK80BS)
+// mode = state_fio->FgetInt32();
+//#endif
+// dma = state_fio->FgetBool();
return true;
}
// common functions
void initialize();
void write_signal(int id, uint32_t data, uint32_t mask);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 2
-void KEYBOARD::save_state(FILEIO* state_fio)
+#include "../../statesub.h"
+
+void KEYBOARD::decl_state()
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
+ enter_decl_state(STATE_VERSION);
+
#if defined(_TK80BS)
- state_fio->FputUint8(prev_type);
- state_fio->FputUint8(prev_brk);
- state_fio->FputUint8(prev_kana);
- state_fio->FputBool(kana_lock);
- state_fio->FputUint32(kb_type);
+ DECL_STATE_ENTRY_UINT8(prev_type);
+ DECL_STATE_ENTRY_UINT8(prev_brk);
+ DECL_STATE_ENTRY_UINT8(prev_kana);
+ DECL_STATE_ENTRY_BOOL(kana_lock);
+ DECL_STATE_ENTRY_UINT32(kb_type);
#endif
- state_fio->FputUint32(column);
+ DECL_STATE_ENTRY_UINT32(column);
+
+ leave_decl_state();
+}
+
+void KEYBOARD::save_state(FILEIO* state_fio)
+{
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+
+//#if defined(_TK80BS)
+// state_fio->FputUint8(prev_type);
+// state_fio->FputUint8(prev_brk);
+// state_fio->FputUint8(prev_kana);
+// state_fio->FputBool(kana_lock);
+// state_fio->FputUint32(kb_type);
+//#endif
+// state_fio->FputUint32(column);
}
bool KEYBOARD::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
-#if defined(_TK80BS)
- prev_type = state_fio->FgetUint8();
- prev_brk = state_fio->FgetUint8();
- prev_kana = state_fio->FgetUint8();
- kana_lock = state_fio->FgetBool();
- kb_type = state_fio->FgetUint32();
-#endif
- column = state_fio->FgetUint32();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+//#if defined(_TK80BS)
+// prev_type = state_fio->FgetUint8();
+// prev_brk = state_fio->FgetUint8();
+// prev_kana = state_fio->FgetUint8();
+// kana_lock = state_fio->FgetBool();
+// kb_type = state_fio->FgetUint32();
+//#endif
+// column = state_fio->FgetUint32();
return true;
}
return kb_type & 3;
}
#endif
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
-void MEMBUS::save_state(FILEIO* state_fio)
+#include "../../statesub.h"
+
+void MEMBUS::decl_state()
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
+ enter_decl_state(STATE_VERSION);
+
#if defined(_TK85)
- state_fio->FputUint32(pc7);
- state_fio->FputUint32(count);
+ DECL_STATE_ENTRY_UINT32(pc7);
+ DECL_STATE_ENTRY_UINT32(count);
#endif
+ MEMORY::decl_state();
+
+ leave_decl_state();
+}
+
+void MEMBUS::save_state(FILEIO* state_fio)
+{
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+
+//#if defined(_TK85)
+// state_fio->FputUint32(pc7);
+// state_fio->FputUint32(count);
+//#endif
MEMORY::save_state(state_fio);
}
bool MEMBUS::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
- }
- if(state_fio->FgetInt32() != this_device_id) {
- return false;
- }
-#if defined(_TK85)
- pc7 = state_fio->FgetUint32();
- count = state_fio->FgetUint32();
-#endif
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+//#if defined(_TK85)
+// pc7 = state_fio->FgetUint32();
+// count = state_fio->FgetUint32();
+//#endif
return MEMORY::load_state(state_fio);
}
#if defined(_TK85)
void write_signal(int id, uint32_t data, uint32_t mask);
#endif
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
+void MEMORY::decl_state(FILEIO* state_fio)
+{
+ // enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
+ // leave_decl_state();
+}
+
void MEMORY::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->Fwrite(ram, sizeof(ram), 1);
- state_fio->Fwrite(vram, sizeof(vram), 1);
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->Fwrite(vram, sizeof(vram), 1);
}
bool MEMORY::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(state_fio->FgetInt32() != this_device_id) {
+ if(!mb) {
return false;
}
- state_fio->Fread(ram, sizeof(ram), 1);
- state_fio->Fread(vram, sizeof(vram), 1);
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(ram, sizeof(ram), 1);
+// state_fio->Fread(vram, sizeof(vram), 1);
+ return true;
}
void write_data8(uint32_t addr, uint32_t data);
uint32_t read_data8(uint32_t addr);
uint32_t fetch_op(uint32_t addr, int *wait);
- void save_state(FILEIO* state_fio);
- bool load_state(FILEIO* state_fio);
+ virtual void decl_state();
+ virtual void save_state(FILEIO* state_fio);
+ virtual bool load_state(FILEIO* state_fio);
// unique functions
void set_context_cpu(DEVICE* device)