[VM][STATE][TK80BS] CMT: OOPs.
#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_1D_ARRAY(vram, sizeof(vram));
+ DECL_STATE_ENTRY_1D_ARRAY(status, sizeof(status));
+ DECL_STATE_ENTRY_UINT8(sysport);
+
+ 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(status, sizeof(status), 1);
- state_fio->FputUint8(sysport);
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->Fwrite(vram, sizeof(vram), 1);
+// state_fio->Fwrite(status, sizeof(status), 1);
+// state_fio->FputUint8(sysport);
}
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(status, sizeof(status), 1);
- sysport = 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);
+// state_fio->Fread(vram, sizeof(vram), 1);
+// state_fio->Fread(status, sizeof(status), 1);
+// sysport = state_fio->FgetUint8();
return true;
}
uint32_t read_data8(uint32_t addr);
void event_frame();
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
-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);
#ifdef _MAP1010
- state_fio->FputInt32(kana_pressed);
+ DECL_STATE_ENTRY_INT32(kana_pressed);
#else
- state_fio->Fwrite(status, sizeof(status), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(status, sizeof(status));
#endif
+ 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);
+//
+//#ifdef _MAP1010
+// state_fio->FputInt32(kana_pressed);
+//#else
+// state_fio->Fwrite(status, sizeof(status), 1);
+//#endif
}
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;
}
-#ifdef _MAP1010
- kana_pressed = state_fio->FgetInt32();
-#else
- state_fio->Fread(status, sizeof(status), 1);
-#endif
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+//#ifdef _MAP1010
+// kana_pressed = state_fio->FgetInt32();
+//#else
+// state_fio->Fread(status, sizeof(status), 1);
+//#endif
return true;
}
void reset();
uint32_t read_io8(uint32_t addr);
void event_frame();
+ 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_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 reset();
void write_data8(uint32_t addr, uint32_t data);
uint32_t read_data8(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 SYSTEM::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_UINT8(sysport);
+
+ leave_decl_state();
+}
+
void SYSTEM::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(sysport);
+// state_fio->FputUint8(sysport);
}
bool SYSTEM::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;
}
- sysport = state_fio->FgetUint8();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// sysport = state_fio->FgetUint8();
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 JOYSTICK::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_UINT8(column);
+ DECL_STATE_ENTRY_UINT8(status);
+
+ leave_decl_state();
+}
+
void JOYSTICK::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(column);
- state_fio->FputUint8(status);
+// state_fio->FputUint8(column);
+// state_fio->FputUint8(status);
}
bool JOYSTICK::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->FgetUint8();
- status = state_fio->FgetUint8();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// column = state_fio->FgetUint8();
+// status = state_fio->FgetUint8();
return true;
}
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
void event_frame();
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
};
#define STATE_VERSION 1
-void PSG::save_state(FILEIO* state_fio)
+#include "../../statesub.h"
+
+void PSG::decl_state()
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_INT32_STRIDE((ch[0].period), 3, sizeof(ch[0]));
- for(int i = 0; i < 3; i++) {
- state_fio->FputInt32(ch[i].period);
+ leave_decl_state();
+}
+
+void PSG::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);
+
+// for(int i = 0; i < 3; i++) {
+// state_fio->FputInt32(ch[i].period);
+// }
}
bool PSG::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;
}
- for(int i = 0; i < 3; i++) {
- ch[i].period = state_fio->FgetInt32();
- }
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// for(int i = 0; i < 3; i++) {
+// ch[i].period = state_fio->FgetInt32();
+// }
return true;
}
void write_io8(uint32_t addr, uint32_t data);
void mix(int32_t* buffer, int cnt);
void set_volume(int ch, int decibel_l, int decibel_r);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
+#include "../../statesub.h"
+
+void VDP::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_INT32(tmp_vram_size); // (int)(vram - base);
+ DECL_STATE_ENTRY_INT32(tmp_pcg_size); // (int)(pcg - base);
+ DECL_STATE_ENTRY_INT32(tmp_pattern_size); // (int)(pattern - base);
+ DECL_STATE_ENTRY_BOOL(force_pattern);
+
+ leave_decl_state();
+}
+
void VDP::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ tmp_vram_size = (int)(vram - base);
+ tmp_pcg_size = (int)(pcg - base);
+ tmp_pattern_size = (int)(pattern - base);
+
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->FputInt32((int)(vram - base));
- state_fio->FputInt32((int)(pcg - base));
- state_fio->FputInt32((int)(pattern - base));
- state_fio->FputBool(force_pattern);
+// state_fio->FputInt32((int)(vram - base));
+// state_fio->FputInt32((int)(pcg - base));
+// state_fio->FputInt32((int)(pattern - base));
+// state_fio->FputBool(force_pattern);
}
bool VDP::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;
}
- vram = base + state_fio->FgetInt32();
- pcg = base + state_fio->FgetInt32();
- pattern = base + state_fio->FgetInt32();
- force_pattern = state_fio->FgetBool();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// vram = base + state_fio->FgetInt32();
+// pcg = base + state_fio->FgetInt32();
+// pattern = base + state_fio->FgetInt32();
+// force_pattern = state_fio->FgetBool();
+ vram = base + tmp_vram_size;
+ pcg = base + tmp_pcg_size;
+ pattern = base + tmp_pattern_size;
return true;
}
uint8_t* pattern;
uint8_t* base;
bool force_pattern;
+
+ int tmp_vram_size;
+ int tmp_pcg_size;
+ int tmp_pattern_size;
void draw_pattern(int x8, int y8, uint16_t top);
void draw_pcg(int x8, int y8, uint16_t top);
void write_io8(uint32_t addr, uint32_t data);
void event_callback(int event_id, int err);
void event_vline(int v, int clock);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
+#include "../../statesub.h"
+
+void CMT::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_INT32(bufcnt);
+ DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
+ DECL_STATE_ENTRY_BOOL(play);
+ DECL_STATE_ENTRY_BOOL(rec);
+ DECL_STATE_ENTRY_UINT8(start);
+ DECL_STATE_ENTRY_UINT8(bit);
+
+ leave_decl_state();
+}
+
void CMT::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->FputInt32(bufcnt);
- state_fio->Fwrite(buffer, sizeof(buffer), 1);
- state_fio->FputBool(play);
- state_fio->FputBool(rec);
- state_fio->FputUint8(start);
- state_fio->FputUint8(bit);
+// state_fio->FputInt32(bufcnt);
+// state_fio->Fwrite(buffer, sizeof(buffer), 1);
+// state_fio->FputBool(play);
+// state_fio->FputBool(rec);
+// state_fio->FputUint8(start);
+// state_fio->FputUint8(bit);
}
bool CMT::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;
}
- bufcnt = state_fio->FgetInt32();
- state_fio->Fread(buffer, sizeof(buffer), 1);
- play = state_fio->FgetBool();
- rec = state_fio->FgetBool();
- start = state_fio->FgetUint8();
- bit = state_fio->FgetUint8();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// bufcnt = state_fio->FgetInt32();
+// state_fio->Fread(buffer, sizeof(buffer), 1);
+// play = state_fio->FgetBool();
+// rec = state_fio->FgetBool();
+// start = state_fio->FgetUint8();
+// bit = 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_1D_ARRAY(key_stat, sizeof(key_stat));
+ DECL_STATE_ENTRY_INT32(key_no);
+ DECL_STATE_ENTRY_BOOL(intr_enb);
+
+ 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);
+ }
+// if(state_entry != NULL) {
+// state_entry->save_state(state_fio);
+// }
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->Fwrite(key_stat, sizeof(key_stat), 1);
- state_fio->FputInt32(key_no);
- state_fio->FputBool(intr_enb);
+// state_fio->Fwrite(key_stat, sizeof(key_stat), 1);
+// state_fio->FputInt32(key_no);
+// state_fio->FputBool(intr_enb);
}
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;
}
- state_fio->Fread(key_stat, sizeof(key_stat), 1);
- key_no = state_fio->FgetInt32();
- intr_enb = state_fio->FgetBool();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(key_stat, sizeof(key_stat), 1);
+// key_no = state_fio->FgetInt32();
+// intr_enb = state_fio->FgetBool();
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 PRINTER::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_UINT8(out);
+ DECL_STATE_ENTRY_UINT8(ctrl0);
+ DECL_STATE_ENTRY_UINT8(ctrl1);
+ DECL_STATE_ENTRY_BOOL(busy);
+
+ leave_decl_state();
+}
+
void PRINTER::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(out);
- state_fio->FputUint8(ctrl0);
- state_fio->FputUint8(ctrl1);
- state_fio->FputBool(busy);
+// state_fio->FputUint8(out);
+// state_fio->FputUint8(ctrl0);
+// state_fio->FputUint8(ctrl1);
+// state_fio->FputBool(busy);
}
bool PRINTER::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;
}
- out = state_fio->FgetUint8();
- ctrl0 = state_fio->FgetUint8();
- ctrl1 = state_fio->FgetUint8();
- busy = state_fio->FgetBool();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// out = state_fio->FgetUint8();
+// ctrl0 = state_fio->FgetUint8();
+// ctrl1 = state_fio->FgetUint8();
+// busy = state_fio->FgetBool();
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
+#include "../../statesub.h"
+
+void MEMORY::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_BOOL(cmt_signal);
+ DECL_STATE_ENTRY_BOOL(cmt_remote);
+ DECL_STATE_ENTRY_BOOL(has_extrom);
+ DECL_STATE_ENTRY_BOOL(cart_enabled);
+ DECL_STATE_ENTRY_INT32(ctype);
+
+ 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->FputBool(cmt_signal);
- state_fio->FputBool(cmt_remote);
- state_fio->FputBool(has_extrom);
- state_fio->FputBool(cart_enabled);
- state_fio->FputInt32(ctype);
+// state_fio->FputBool(cmt_signal);
+// state_fio->FputBool(cmt_remote);
+// state_fio->FputBool(has_extrom);
+// state_fio->FputBool(cart_enabled);
+// state_fio->FputInt32(ctype);
}
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;
}
- cmt_signal = state_fio->FgetBool();
- cmt_remote = state_fio->FgetBool();
- has_extrom = state_fio->FgetBool();
- cart_enabled = state_fio->FgetBool();
- ctype = state_fio->FgetInt32();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// cmt_signal = state_fio->FgetBool();
+// cmt_remote = state_fio->FgetBool();
+// has_extrom = state_fio->FgetBool();
+// cart_enabled = state_fio->FgetBool();
+// ctype = state_fio->FgetInt32();
// post process
if(cart_enabled) {
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
-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);
+
#ifdef _COLOR_MONITOR
- state_fio->Fwrite(vram_r, sizeof(vram_r), 1);
- state_fio->Fwrite(vram_g, sizeof(vram_g), 1);
- state_fio->Fwrite(vram_b, sizeof(vram_b), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(vram_r, sizeof(vram_r));
+ DECL_STATE_ENTRY_1D_ARRAY(vram_g, sizeof(vram_g));
+ DECL_STATE_ENTRY_1D_ARRAY(vram_b, sizeof(vram_b));
#else
- state_fio->Fwrite(vram, sizeof(vram), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
#endif
- state_fio->FputUint8(bank);
- state_fio->FputInt32(blink);
+ DECL_STATE_ENTRY_UINT8(bank);
+ DECL_STATE_ENTRY_INT32(blink);
+
+ 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);
+
+//#ifdef _COLOR_MONITOR
+// state_fio->Fwrite(vram_r, sizeof(vram_r), 1);
+// state_fio->Fwrite(vram_g, sizeof(vram_g), 1);
+// state_fio->Fwrite(vram_b, sizeof(vram_b), 1);
+//#else
+// state_fio->Fwrite(vram, sizeof(vram), 1);
+//#endif
+// state_fio->FputUint8(bank);
+// state_fio->FputInt32(blink);
}
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;
}
-#ifdef _COLOR_MONITOR
- state_fio->Fread(vram_r, sizeof(vram_r), 1);
- state_fio->Fread(vram_g, sizeof(vram_g), 1);
- state_fio->Fread(vram_b, sizeof(vram_b), 1);
-#else
- state_fio->Fread(vram, sizeof(vram), 1);
-#endif
- bank = state_fio->FgetUint8();
- blink = state_fio->FgetInt32();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+//#ifdef _COLOR_MONITOR
+// state_fio->Fread(vram_r, sizeof(vram_r), 1);
+// state_fio->Fread(vram_g, sizeof(vram_g), 1);
+// state_fio->Fread(vram_b, sizeof(vram_b), 1);
+//#else
+// state_fio->Fread(vram, sizeof(vram), 1);
+//#endif
+// bank = state_fio->FgetUint8();
+// blink = state_fio->FgetInt32();
return true;
}
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
void event_frame();
+ 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_1D_ARRAY(led, sizeof(led) / sizeof(bool));
+ DECL_STATE_ENTRY_BOOL(repeat);
+ DECL_STATE_ENTRY_BOOL(enable);
+
+ 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->Fwrite(led, sizeof(led), 1);
- state_fio->FputBool(repeat);
- state_fio->FputBool(enable);
+// state_fio->Fwrite(led, sizeof(led), 1);
+// state_fio->FputBool(repeat);
+// state_fio->FputBool(enable);
}
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;
}
- state_fio->Fread(led, sizeof(led), 1);
- repeat = state_fio->FgetBool();
- enable = state_fio->FgetBool();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(led, sizeof(led), 1);
+// repeat = state_fio->FgetBool();
+// enable = 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 1
+#include "../../statesub.h"
+
+void MEMORY::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
+ DECL_STATE_ENTRY_1D_ARRAY(cmos, sizeof(cmos));
+ DECL_STATE_ENTRY_UINT32(cmos_crc32);
+ DECL_STATE_ENTRY_UINT8(bank);
+ DECL_STATE_ENTRY_UINT8(psel);
+ DECL_STATE_ENTRY_UINT8(csel);
+ DECL_STATE_ENTRY_BOOL(pcm_on);
+ DECL_STATE_ENTRY_BOOL(pcm_cont);
+ DECL_STATE_ENTRY_BOOL(pcm_pit);
+ DECL_STATE_ENTRY_BOOL(fdc_irq);
+ DECL_STATE_ENTRY_BOOL(motor);
+
+ 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(cmos, sizeof(cmos), 1);
- state_fio->FputUint32(cmos_crc32);
- state_fio->FputUint8(bank);
- state_fio->FputUint8(psel);
- state_fio->FputUint8(csel);
- state_fio->FputBool(pcm_on);
- state_fio->FputBool(pcm_cont);
- state_fio->FputBool(pcm_pit);
- state_fio->FputBool(fdc_irq);
- state_fio->FputBool(motor);
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->Fwrite(cmos, sizeof(cmos), 1);
+// state_fio->FputUint32(cmos_crc32);
+// state_fio->FputUint8(bank);
+// state_fio->FputUint8(psel);
+// state_fio->FputUint8(csel);
+// state_fio->FputBool(pcm_on);
+// state_fio->FputBool(pcm_cont);
+// state_fio->FputBool(pcm_pit);
+// state_fio->FputBool(fdc_irq);
+// state_fio->FputBool(motor);
}
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(cmos, sizeof(cmos), 1);
- cmos_crc32 = state_fio->FgetUint32();
- bank = state_fio->FgetUint8();
- psel = state_fio->FgetUint8();
- csel = state_fio->FgetUint8();
- pcm_on = state_fio->FgetBool();
- pcm_cont = state_fio->FgetBool();
- pcm_pit = state_fio->FgetBool();
- fdc_irq = state_fio->FgetBool();
- motor = state_fio->FgetBool();
+// 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(cmos, sizeof(cmos), 1);
+// cmos_crc32 = state_fio->FgetUint32();
+// bank = state_fio->FgetUint8();
+// psel = state_fio->FgetUint8();
+// csel = state_fio->FgetUint8();
+// pcm_on = state_fio->FgetBool();
+// pcm_cont = state_fio->FgetBool();
+// pcm_pit = state_fio->FgetBool();
+// fdc_irq = state_fio->FgetBool();
+// motor = state_fio->FgetBool();
// post process
update_map();
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 MFONT::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_UINT8(status);
+ DECL_STATE_ENTRY_FIFO(cmd);
+ DECL_STATE_ENTRY_FIFO(res);
+
+ leave_decl_state();
+}
+
void MFONT::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(status);
- cmd->save_state((void *)state_fio);
- res->save_state((void *)state_fio);
+// state_fio->FputUint8(status);
+// cmd->save_state((void *)state_fio);
+// res->save_state((void *)state_fio);
}
bool MFONT::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != STATE_VERSION) {
- return false;
- }
- if(state_fio->FgetInt32() != this_device_id) {
- return false;
- }
- status = state_fio->FgetUint8();
- if(!cmd->load_state((void *)state_fio)) {
- return false;
+ bool mb = false;
+ if(state_entry != NULL) {
+ mb = state_entry->load_state(state_fio);
}
- if(!res->load_state((void *)state_fio)) {
+ if(!mb) {
return false;
}
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// status = state_fio->FgetUint8();
+// if(!cmd->load_state((void *)state_fio)) {
+// return false;
+// }
+// if(!res->load_state((void *)state_fio)) {
+// return false;
+// }
return true;
}
void release();
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 CMT::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_BOOL(in);
+ DECL_STATE_ENTRY_BOOL(out);
+ DECL_STATE_ENTRY_BOOL(remote);
+ DECL_STATE_ENTRY_BOOL(now_acc);
+ DECL_STATE_ENTRY_INT32(framecnt);
+
+ leave_decl_state();
+}
+
void CMT::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(in);
- state_fio->FputBool(out);
- state_fio->FputBool(remote);
- state_fio->FputBool(now_acc);
- state_fio->FputInt32(framecnt);
+// state_fio->FputBool(in);
+// state_fio->FputBool(out);
+// state_fio->FputBool(remote);
+// state_fio->FputBool(now_acc);
+// state_fio->FputInt32(framecnt);
}
bool CMT::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;
}
- in = state_fio->FgetBool();
- out = state_fio->FgetBool();
- remote = state_fio->FgetBool();
- now_acc = state_fio->FgetBool();
- framecnt = state_fio->FgetInt32();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// in = state_fio->FgetBool();
+// out = state_fio->FgetBool();
+// remote = state_fio->FgetBool();
+// now_acc = state_fio->FgetBool();
+// framecnt = state_fio->FgetInt32();
return true;
}
uint32_t read_io8(uint32_t addr);
void write_signal(int id, uint32_t data, uint32_t mask);
void event_frame();
+ 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_1D_ARRAY(status, sizeof(status));
+ DECL_STATE_ENTRY_UINT8(column);
+
+ 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->Fwrite(status, sizeof(status), 1);
- state_fio->FputUint8(column);
+// state_fio->Fwrite(status, sizeof(status), 1);
+// state_fio->FputUint8(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;
}
- state_fio->Fread(status, sizeof(status), 1);
- column = state_fio->FgetUint8();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(status, sizeof(status), 1);
+// column = state_fio->FgetUint8();
return true;
}
void write_io8(uint32_t addr, uint32_t data);
uint32_t read_io8(uint32_t addr);
void event_frame();
+ 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_1D_ARRAY(ext, sizeof(ext));
+ DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram));
+ DECL_STATE_ENTRY_INT32(rpage);
+ DECL_STATE_ENTRY_INT32(wpage);
+ DECL_STATE_ENTRY_BOOL(inserted);
+
+ 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(ext, sizeof(ext), 1);
- state_fio->Fwrite(vram, sizeof(vram), 1);
- state_fio->FputInt32(rpage);
- state_fio->FputInt32(wpage);
- state_fio->FputBool(inserted);
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->Fwrite(ext, sizeof(ext), 1);
+// state_fio->Fwrite(vram, sizeof(vram), 1);
+// state_fio->FputInt32(rpage);
+// state_fio->FputInt32(wpage);
+// state_fio->FputBool(inserted);
}
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(ext, sizeof(ext), 1);
- state_fio->Fread(vram, sizeof(vram), 1);
- rpage = state_fio->FgetInt32();
- wpage = state_fio->FgetInt32();
- inserted = state_fio->FgetBool();
+// 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(ext, sizeof(ext), 1);
+// state_fio->Fread(vram, sizeof(vram), 1);
+// rpage = state_fio->FgetInt32();
+// wpage = state_fio->FgetInt32();
+// inserted = state_fio->FgetBool();
return true;
}
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 decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);
#define STATE_VERSION 1
+#include "../../statesub.h"
+
+void PRINTER::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_BOOL(strobe);
+ DECL_STATE_ENTRY_BOOL(busy);
+ DECL_STATE_ENTRY_UINT8(out);
+
+ leave_decl_state();
+}
+
void PRINTER::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(strobe);
- state_fio->FputBool(busy);
- state_fio->FputUint8(out);
+// state_fio->FputBool(strobe);
+// state_fio->FputBool(busy);
+// state_fio->FputUint8(out);
}
bool PRINTER::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;
}
- strobe = state_fio->FgetBool();
- busy = state_fio->FgetBool();
- out = state_fio->FgetUint8();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// strobe = state_fio->FgetBool();
+// busy = state_fio->FgetBool();
+// out = state_fio->FgetUint8();
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 VDP::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_SCRNTYPE_T_1D_ARRAY(palette_pc, 17);
+ DECL_STATE_ENTRY_1D_ARRAY(reg, sizeof(reg));
+ DECL_STATE_ENTRY_UINT8(bg);
+ DECL_STATE_ENTRY_UINT8(cmask);
+ DECL_STATE_ENTRY_UINT8(pmask);
+
+ leave_decl_state();
+}
+
void VDP::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(palette_pc, sizeof(palette_pc), 1);
- state_fio->Fwrite(reg, sizeof(reg), 1);
- state_fio->FputUint8(bg);
- state_fio->FputUint8(cmask);
- state_fio->FputUint8(pmask);
+// state_fio->Fwrite(palette_pc, sizeof(palette_pc), 1);
+// state_fio->Fwrite(reg, sizeof(reg), 1);
+// state_fio->FputUint8(bg);
+// state_fio->FputUint8(cmask);
+// state_fio->FputUint8(pmask);
}
bool VDP::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(palette_pc, sizeof(palette_pc), 1);
- state_fio->Fread(reg, sizeof(reg), 1);
- bg = state_fio->FgetUint8();
- cmask = state_fio->FgetUint8();
- pmask = state_fio->FgetUint8();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(palette_pc, sizeof(palette_pc), 1);
+// state_fio->Fread(reg, sizeof(reg), 1);
+// bg = state_fio->FgetUint8();
+// cmask = state_fio->FgetUint8();
+// pmask = state_fio->FgetUint8();
return true;
}
void initialize();
void write_io8(uint32_t addr, uint32_t data);
void event_vline(int v, int clock);
+ 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_UINT8(column);
+ DECL_STATE_ENTRY_BOOL(break_pressed);
+
+ 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->FputUint8(column);
- state_fio->FputBool(break_pressed);
+// state_fio->FputUint8(column);
+// state_fio->FputBool(break_pressed);
}
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->FgetUint8();
- break_pressed = state_fio->FgetBool();
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// column = state_fio->FgetUint8();
+// break_pressed = state_fio->FgetBool();
return true;
}
void initialize();
void event_frame();
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
+#include "../../statesub.h"
+
+void MEMORY::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
+ DECL_STATE_ENTRY_BOOL(inserted);
+ DECL_STATE_ENTRY_BOOL(ram_selected);
+ DECL_STATE_ENTRY_1D_ARRAY(bank, sizeof(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->FputBool(inserted);
- state_fio->FputBool(ram_selected);
- state_fio->Fwrite(bank, sizeof(bank), 1);
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->FputBool(inserted);
+// state_fio->FputBool(ram_selected);
+// state_fio->Fwrite(bank, sizeof(bank), 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);
- inserted = state_fio->FgetBool();
- ram_selected = state_fio->FgetBool();
- state_fio->Fread(bank, sizeof(bank), 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);
+// inserted = state_fio->FgetBool();
+// ram_selected = state_fio->FgetBool();
+// state_fio->Fread(bank, sizeof(bank), 1);
// post process
update_bank();
void write_data8(uint32_t addr, uint32_t data);
uint32_t read_data8(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 2
-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);
- state_fio->FputBool(mic);
- state_fio->FputBool(ear);
- state_fio->FputBool(pulse);
- state_fio->FputInt32(pulse_count);
+ DECL_STATE_ENTRY_BOOL(mic);
+ DECL_STATE_ENTRY_BOOL(ear);
+ DECL_STATE_ENTRY_BOOL(pulse);
+ DECL_STATE_ENTRY_INT32(pulse_count);
#if defined(_TK80BS)
- state_fio->FputBool(play);
- state_fio->FputBool(rec);
- 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_BOOL(play);
+ DECL_STATE_ENTRY_BOOL(rec);
+ DECL_STATE_ENTRY_STRING(rec_file_path, sizeof(rec_file_path) / sizeof(_TCHAR));
+
+ DECL_STATE_ENTRY_CMT_RECORDING(fio, rec, rec_file_path);
+
+ DECL_STATE_ENTRY_INT32(bufcnt);
+ DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer));
+#endif
+ 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->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+
+// state_fio->FputBool(mic);
+// state_fio->FputBool(ear);
+// state_fio->FputBool(pulse);
+// state_fio->FputInt32(pulse_count);
+#if defined(_TK80BS)
+// state_fio->FputBool(play);
+// state_fio->FputBool(rec);
+// 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);
#endif
}
{
release_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;
}
- mic = state_fio->FgetBool();
- ear = state_fio->FgetBool();
- pulse = state_fio->FgetBool();
- pulse_count = state_fio->FgetInt32();
-#if defined(_TK80BS)
- play = state_fio->FgetBool();
- rec = 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);
-#endif
+// if(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// mic = state_fio->FgetBool();
+// ear = state_fio->FgetBool();
+// pulse = state_fio->FgetBool();
+// pulse_count = state_fio->FgetInt32();
+//#if defined(_TK80BS)
+// play = state_fio->FgetBool();
+// rec = 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);
+//#endif
return true;
}
#endif
void write_signal(int id, uint32_t data, uint32_t mask);
void event_callback(int event_id, int err);
+ void decl_state();
void save_state(FILEIO* state_fio);
bool load_state(FILEIO* state_fio);