X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=source%2Fsrc%2Fvm%2Fmz3500%2Fmain.cpp;h=290e34774d2de24248fa364057a72ebff4eccdf7;hb=1a7386afa4c2ce25de158ba8285bc795446a8584;hp=b36fe9934f123544c4c775cd846adaf690edd7ca;hpb=2ac613a399830170988cc5000bb8649c37a9c0d5;p=csp-qt%2Fcommon_source_project-fm7.git diff --git a/source/src/vm/mz3500/main.cpp b/source/src/vm/mz3500/main.cpp index b36fe9934..290e34774 100644 --- a/source/src/vm/mz3500/main.cpp +++ b/source/src/vm/mz3500/main.cpp @@ -10,6 +10,8 @@ #include "./main.h" #include "../upd765a.h" +namespace MZ3500 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 11, eb = (e) >> 11; \ for(int i = sb; i <= eb; i++) { \ @@ -391,116 +393,44 @@ void MAIN::update_bank() #define STATE_VERSION 2 -#include "../../statesub.h" - -void MAIN::decl_state() -{ - enter_decl_state(STATE_VERSION); - - DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram)); - DECL_STATE_ENTRY_1D_ARRAY(common, sizeof(common)); - DECL_STATE_ENTRY_UINT8(ma); - DECL_STATE_ENTRY_UINT8(ms); - DECL_STATE_ENTRY_UINT8(mo); - DECL_STATE_ENTRY_BOOL(me1); - DECL_STATE_ENTRY_BOOL(me2); - DECL_STATE_ENTRY_UINT8(srqb); - DECL_STATE_ENTRY_UINT8(sres); - DECL_STATE_ENTRY_BOOL(sack); - DECL_STATE_ENTRY_BOOL(srdy); - DECL_STATE_ENTRY_BOOL(intfd); - DECL_STATE_ENTRY_BOOL(int0); - DECL_STATE_ENTRY_BOOL(int1); - DECL_STATE_ENTRY_BOOL(int2); - DECL_STATE_ENTRY_BOOL(int3); - DECL_STATE_ENTRY_BOOL(int4); - DECL_STATE_ENTRY_BOOL(me); - DECL_STATE_ENTRY_BOOL(e1); - DECL_STATE_ENTRY_UINT8(inp); - DECL_STATE_ENTRY_BOOL(motor); - DECL_STATE_ENTRY_BOOL(drq); - DECL_STATE_ENTRY_BOOL(index); - DECL_STATE_ENTRY_BOOL(crt_400line); - - leave_decl_state(); -} - -void MAIN::save_state(FILEIO* state_fio) +bool MAIN::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->Fwrite(common, sizeof(common), 1); -// state_fio->FputUint8(ma); -// state_fio->FputUint8(ms); -// state_fio->FputUint8(mo); -// state_fio->FputBool(me1); -// state_fio->FputBool(me2); -// state_fio->FputUint8(srqb); -// state_fio->FputUint8(sres); -// state_fio->FputBool(sack); -// state_fio->FputBool(srdy); -// state_fio->FputBool(intfd); -// state_fio->FputBool(int0); -// state_fio->FputBool(int1); -// state_fio->FputBool(int2); -// state_fio->FputBool(int3); -// state_fio->FputBool(int4); -// state_fio->FputBool(me); -// state_fio->FputBool(e1); -// state_fio->FputUint8(inp); -// state_fio->FputBool(motor); -// state_fio->FputBool(drq); -// state_fio->FputBool(index); -// state_fio->FputBool(crt_400line); -} - -bool MAIN::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; -// } -// state_fio->Fread(ram, sizeof(ram), 1); -// state_fio->Fread(common, sizeof(common), 1); -// ma = state_fio->FgetUint8(); -// ms = state_fio->FgetUint8(); -// mo = state_fio->FgetUint8(); -// me1 = state_fio->FgetBool(); -// me2 = state_fio->FgetBool(); -// srqb = state_fio->FgetUint8(); -// sres = state_fio->FgetUint8(); -// sack = state_fio->FgetBool(); -// srdy = state_fio->FgetBool(); -// intfd = state_fio->FgetBool(); -// int0 = state_fio->FgetBool(); -// int1 = state_fio->FgetBool(); -// int2 = state_fio->FgetBool(); -// int3 = state_fio->FgetBool(); -// int4 = state_fio->FgetBool(); -// me = state_fio->FgetBool(); -// e1 = state_fio->FgetBool(); -// inp = state_fio->FgetUint8(); -// motor = state_fio->FgetBool(); -// drq = state_fio->FgetBool(); -// index = state_fio->FgetBool(); -// crt_400line = state_fio->FgetBool(); + 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 - update_bank(); + if(loading) { + update_bank(); + } return true; } +}