return rbank[addr >> 13][addr & 0x1fff];
}
+#include "../../statesub.h"
+
#define SLOT_MAINROM_STATE_VERSION 1
-void SLOT_MAINROM::save_state(FILEIO* state_fio)
+
+void SLOT_MAINROM::decl_state()
{
- state_fio->FputUint32(SLOT_MAINROM_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
+ enter_decl_state(SLOT_MAINROM_STATE_VERSION);
+
#ifdef MAINROM_PLUS_RAM_32K
- state_fio->Fwrite(ram, sizeof(ram), 1);
+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
#endif
+
+ leave_decl_state();
+}
+
+void SLOT_MAINROM::save_state(FILEIO* state_fio)
+{
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(SLOT_MAINROM_STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+
+//#ifdef MAINROM_PLUS_RAM_32K
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+//#endif
}
bool SLOT_MAINROM::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != SLOT_MAINROM_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 MAINROM_PLUS_RAM_32K
- state_fio->Fread(ram, sizeof(ram), 1);
-#endif
+// if(state_fio->FgetUint32() != SLOT_MAINROM_STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+//#ifdef MAINROM_PLUS_RAM_32K
+// state_fio->Fread(ram, sizeof(ram), 1);
+//#endif
return true;
}
#define SLOT_CART_STATE_VERSION 1
-void SLOT_CART::save_state(FILEIO* state_fio)
+void SLOT_CART::decl_state()
{
- state_fio->FputUint32(SLOT_CART_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
-
- state_fio->FputBool(inserted);
+ enter_decl_state(SLOT_CART_STATE_VERSION);
+
+ DECL_STATE_ENTRY_BOOL(inserted);
#ifdef USE_MEGAROM
- state_fio->FputInt32(type);
- state_fio->FputBool(bank_scc);
+ DECL_STATE_ENTRY_INT32(type);
+ DECL_STATE_ENTRY_BOOL(bank_scc);
/* Todo: MEGA ROM bank select */
/* is this OK? */
- if(inserted) {
- state_fio->FputInt32(rbank[0]==rdmy ? (-1) : rbank[0] - rom);
- state_fio->FputInt32(rbank[1]==rdmy ? (-1) : rbank[1] - rom);
- state_fio->FputInt32(rbank[2]==rdmy ? (-1) : rbank[2] - rom);
- state_fio->FputInt32(rbank[3]==rdmy ? (-1) : rbank[3] - rom);
- state_fio->FputInt32(rbank[4]==rdmy ? (-1) : rbank[4] - rom);
- state_fio->FputInt32(rbank[5]==rdmy ? (-1) : rbank[5] - rom);
- state_fio->FputInt32(rbank[6]==rdmy ? (-1) : rbank[6] - rom);
- state_fio->FputInt32(rbank[7]==rdmy ? (-1) : rbank[7] - rom);
+ DECL_STATE_ENTRY_1D_ARRAY(tmp_rbank_ptr, 8);
+
+ //DECL_STATE_ENTRY_INT32(rbank[0]==rdmy ? (-1) : rbank[0] - rom);
+ //DECL_STATE_ENTRY_INT32(rbank[1]==rdmy ? (-1) : rbank[1] - rom);
+ //DECL_STATE_ENTRY_INT32(rbank[2]==rdmy ? (-1) : rbank[2] - rom);
+ //DECL_STATE_ENTRY_INT32(rbank[3]==rdmy ? (-1) : rbank[3] - rom);
+ //DECL_STATE_ENTRY_INT32(rbank[4]==rdmy ? (-1) : rbank[4] - rom);
+ //DECL_STATE_ENTRY_INT32(rbank[5]==rdmy ? (-1) : rbank[5] - rom);
+ //DECL_STATE_ENTRY_INT32(rbank[6]==rdmy ? (-1) : rbank[6] - rom);
+ //DECL_STATE_ENTRY_INT32(rbank[7]==rdmy ? (-1) : rbank[7] - rom);
+#endif
+
+ leave_decl_state();
+}
+void SLOT_CART::save_state(FILEIO* state_fio)
+{
+#ifdef USE_MEGAROM
+ for(int i = 0; i < 8; i++) {
+ tmp_rbank_ptr[i] = (rbank[i]==rdmy) ? (-1) : (int)(rbank[i] - rom);
}
#endif
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(SLOT_CART_STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+
+// state_fio->FputBool(inserted);
+//#ifdef USE_MEGAROM
+// state_fio->FputInt32(type);
+// state_fio->FputBool(bank_scc);
+ /* Todo: MEGA ROM bank select */
+ /* is this OK? */
+// if(inserted) {
+// state_fio->FputInt32(rbank[0]==rdmy ? (-1) : rbank[0] - rom);
+// state_fio->FputInt32(rbank[1]==rdmy ? (-1) : rbank[1] - rom);
+// state_fio->FputInt32(rbank[2]==rdmy ? (-1) : rbank[2] - rom);
+// state_fio->FputInt32(rbank[3]==rdmy ? (-1) : rbank[3] - rom);
+// state_fio->FputInt32(rbank[4]==rdmy ? (-1) : rbank[4] - rom);
+// state_fio->FputInt32(rbank[5]==rdmy ? (-1) : rbank[5] - rom);
+// state_fio->FputInt32(rbank[6]==rdmy ? (-1) : rbank[6] - rom);
+// state_fio->FputInt32(rbank[7]==rdmy ? (-1) : rbank[7] - rom);
+// }
+//#endif
}
bool SLOT_CART::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != SLOT_CART_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;
}
- inserted = state_fio->FgetBool();
+// if(state_fio->FgetUint32() != SLOT_CART_STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// inserted = state_fio->FgetBool();
// post process
#ifdef USE_MEGAROM
- type = state_fio->FgetInt32();
- bank_scc = state_fio->FgetBool();
+// type = state_fio->FgetInt32();
+// bank_scc = state_fio->FgetBool();
/* Todo: MEGA ROM bank select */
/* is this OK? */
if(inserted) {
SET_BANK(0x0000, 0xffff, wdmy, rom);
- int i32;
- i32 = state_fio->FgetInt32() ; rbank[0] = ((i32 == -1) ? rdmy : rom + i32);
- i32 = state_fio->FgetInt32() ; rbank[1] = ((i32 == -1) ? rdmy : rom + i32);
- i32 = state_fio->FgetInt32() ; rbank[2] = ((i32 == -1) ? rdmy : rom + i32);
- i32 = state_fio->FgetInt32() ; rbank[3] = ((i32 == -1) ? rdmy : rom + i32);
- i32 = state_fio->FgetInt32() ; rbank[4] = ((i32 == -1) ? rdmy : rom + i32);
- i32 = state_fio->FgetInt32() ; rbank[5] = ((i32 == -1) ? rdmy : rom + i32);
- i32 = state_fio->FgetInt32() ; rbank[6] = ((i32 == -1) ? rdmy : rom + i32);
- i32 = state_fio->FgetInt32() ; rbank[7] = ((i32 == -1) ? rdmy : rom + i32);
+// int i32;
+// i32 = state_fio->FgetInt32() ; rbank[0] = ((i32 == -1) ? rdmy : rom + i32);
+// i32 = state_fio->FgetInt32() ; rbank[1] = ((i32 == -1) ? rdmy : rom + i32);
+// i32 = state_fio->FgetInt32() ; rbank[2] = ((i32 == -1) ? rdmy : rom + i32);
+// i32 = state_fio->FgetInt32() ; rbank[3] = ((i32 == -1) ? rdmy : rom + i32);
+// i32 = state_fio->FgetInt32() ; rbank[4] = ((i32 == -1) ? rdmy : rom + i32);
+// i32 = state_fio->FgetInt32() ; rbank[5] = ((i32 == -1) ? rdmy : rom + i32);
+// i32 = state_fio->FgetInt32() ; rbank[6] = ((i32 == -1) ? rdmy : rom + i32);
+// i32 = state_fio->FgetInt32() ; rbank[7] = ((i32 == -1) ? rdmy : rom + i32);
+ for(int i = 0; i < 8; i++) {
+ rbank[i] = ((tmp_rbank_ptr[i] == -1) ? rdmy : rom + tmp_rbank_ptr[i]);
+ }
} else {
SET_BANK(0x0000, 0xffff, wdmy, rdmy);
}
#define SLOT_MSXDOS2_STATE_VERSION 1
+void SLOT_MSXDOS2::decl_state()
+{
+ enter_decl_state(SLOT_MSXDOS2_STATE_VERSION);
+
+ DECL_STATE_ENTRY_1D_ARRAY(mapper, sizeof(mapper));
+
+ leave_decl_state();
+}
+
void SLOT_MSXDOS2::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(SLOT_MSXDOS2_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(SLOT_MSXDOS2_STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->Fwrite(mapper, sizeof(mapper), 1);
+// state_fio->Fwrite(mapper, sizeof(mapper), 1);
}
bool SLOT_MSXDOS2::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != SLOT_MSXDOS2_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(mapper, sizeof(mapper), 1);
+// if(state_fio->FgetUint32() != SLOT_MSXDOS2_STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(mapper, sizeof(mapper), 1);
// post process
if(mapper[0] < 4) {
#define SLOT_LDC_STATE_VERSION 1
+void SLOT_LDC::decl_state()
+{
+ enter_decl_state(SLOT_LDC_STATE_VERSION);
+
+ DECL_STATE_ENTRY_BOOL(clock);
+ DECL_STATE_ENTRY_BOOL(exv);
+ DECL_STATE_ENTRY_BOOL(ack);
+ DECL_STATE_ENTRY_BOOL(super_impose);
+ DECL_STATE_ENTRY_BOOL(req_intr);
+ DECL_STATE_ENTRY_BOOL(pc4);
+ DECL_STATE_ENTRY_BOOL(mute_l);
+ DECL_STATE_ENTRY_BOOL(mute_r);
+
+ leave_decl_state();
+}
+
void SLOT_LDC::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(SLOT_LDC_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(SLOT_LDC_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);
+// 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 SLOT_LDC::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != SLOT_LDC_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;
}
- 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();
+// if(state_fio->FgetUint32() != SLOT_LDC_STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != 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();
return true;
}
#endif
#define SLOT_MAPPERRAM_STATE_VERSION 1
+void SLOT_MAPPERRAM::decl_state()
+{
+ enter_decl_state(SLOT_MAPPERRAM_STATE_VERSION);
+
+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
+ DECL_STATE_ENTRY_1D_ARRAY(mapper, sizeof(mapper));
+
+ leave_decl_state();
+}
+
void SLOT_MAPPERRAM::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(SLOT_MAPPERRAM_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(SLOT_MAPPERRAM_STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->Fwrite(ram, sizeof(ram), 1);
- state_fio->Fwrite(mapper, sizeof(mapper), 1);
+// state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->Fwrite(mapper, sizeof(mapper), 1);
}
bool SLOT_MAPPERRAM::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != SLOT_MAPPERRAM_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(mapper, sizeof(mapper), 1);
+// if(state_fio->FgetUint32() != SLOT_MAPPERRAM_STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(ram, sizeof(ram), 1);
+// state_fio->Fread(mapper, sizeof(mapper), 1);
// post process
SET_BANK(0x0000, 0x3fff, ram + mapper[0] * 0x4000, ram + mapper[0] * 0x4000);
#define SLOT_RAM64K_STATE_VERSION 1
+void SLOT_RAM64K::decl_state()
+{
+ enter_decl_state(SLOT_RAM64K_STATE_VERSION);
+
+ DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
+
+ leave_decl_state();
+}
+
void SLOT_RAM64K::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(SLOT_RAM64K_STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
+// state_fio->FputUint32(SLOT_RAM64K_STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
- state_fio->Fwrite(ram, sizeof(ram), 1);
+// state_fio->Fwrite(ram, sizeof(ram), 1);
}
bool SLOT_RAM64K::load_state(FILEIO* state_fio)
{
- if(state_fio->FgetUint32() != SLOT_RAM64K_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);
+// if(state_fio->FgetUint32() != SLOT_RAM64K_STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
+// state_fio->Fread(ram, sizeof(ram), 1);
return true;
}
#endif
#define STATE_VERSION 1
+void MEMORY_EX::decl_state()
+{
+ enter_decl_state(STATE_VERSION);
+
+ DECL_STATE_ENTRY_UINT8(psl);
+ DECL_STATE_ENTRY_UINT8(ssl[0]);
+ DECL_STATE_ENTRY_UINT8(ssl[1]);
+ DECL_STATE_ENTRY_UINT8(ssl[2]);
+ DECL_STATE_ENTRY_UINT8(ssl[3]);
+
+ leave_decl_state();
+
+#if defined(FDD_PATCH_SLOT)
+ for(int i = 0; i < MAX_DRIVE; i++) {
+ if(disk[i] != NULL) disk[i]->decl_state((void *)p_logger);
+ }
+#endif
+}
+
void MEMORY_EX::save_state(FILEIO* state_fio)
{
- state_fio->FputUint32(STATE_VERSION);
- state_fio->FputInt32(this_device_id);
+// state_fio->FputUint32(STATE_VERSION);
+// state_fio->FputInt32(this_device_id);
+ if(state_entry != NULL) {
+ state_entry->save_state(state_fio);
+ }
#if defined(FDD_PATCH_SLOT)
for(int i = 0; i < MAX_DRIVE; i++) {
disk[i]->save_state(state_fio);
}
#endif
- state_fio->FputUint8(psl);
- state_fio->FputUint8(ssl[0]);
- state_fio->FputUint8(ssl[1]);
- state_fio->FputUint8(ssl[2]);
- state_fio->FputUint8(ssl[3]);
+// DECL_STATE_ENTRY_UINT8(psl);
+// DECL_STATE_ENTRY_UINT8(ssl[0]);
+// DECL_STATE_ENTRY_UINT8(ssl[1]);
+// DECL_STATE_ENTRY_UINT8(ssl[2]);
+// DECL_STATE_ENTRY_UINT8(ssl[3]);
}
bool MEMORY_EX::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(state_fio->FgetUint32() != STATE_VERSION) {
+// return false;
+// }
+// if(state_fio->FgetInt32() != this_device_id) {
+// return false;
+// }
#if defined(FDD_PATCH_SLOT)
for(int i = 0; i < MAX_DRIVE; i++) {
if(!disk[i]->load_state(state_fio)) {
}
}
#endif
- psl = state_fio->FgetUint8();
- ssl[0] = state_fio->FgetUint8();
- ssl[1] = state_fio->FgetUint8();
- ssl[2] = state_fio->FgetUint8();
- ssl[3] = state_fio->FgetUint8();
+// psl = state_fio->FgetUint8();
+// ssl[0] = state_fio->FgetUint8();
+// ssl[1] = state_fio->FgetUint8();
+// ssl[2] = state_fio->FgetUint8();
+// ssl[3] = state_fio->FgetUint8();
// post process
update_map(psl);