#include "membus.h"
+namespace BUBCOM80 {
void MEMBUS::initialize()
{
MEMORY::initialize();
#define STATE_VERSION 1
-#include "../../statesub.h"
-
-void MEMBUS::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_PAIR(basic_addr);
- DECL_STATE_ENTRY_BOOL(ram_selected);
-
- leave_decl_state();
-
-// MEMORY::decl_state(); // ??
-}
-void MEMBUS::save_state(FILEIO* state_fio)
+bool MEMBUS::process_state(FILEIO* state_fio, bool loading)
{
- 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->FputUint32(basic_addr.d);
-// state_fio->FputBool(ram_selected);
-
- MEMORY::save_state(state_fio); // OK?
-}
-
-bool MEMBUS::load_state(FILEIO* state_fio)
-{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
}
- if(!mb) {
+ if(!state_fio->StateCheckInt32(this_device_id)) {
return false;
}
-
-// if(state_fio->FgetUint32() != STATE_VERSION) {
-// return false;
-// }
-// if(state_fio->FgetInt32() != this_device_id) {
-// return false;
-// }
-
- if(!MEMORY::load_state(state_fio)) { // OK?
+ if(!MEMORY::process_state(state_fio, loading)) {
return false;
}
-
-// state_fio->Fread(ram, sizeof(ram), 1);
-// basic_addr.d = state_fio->FgetUint32();
-// ram_selected = state_fio->FgetBool();
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateUint32(basic_addr.d);
+ state_fio->StateBool(ram_selected);
// post process
- update_bank();
+ if(loading) {
+ update_bank();
+ }
return true;
}
+}