#define STATE_VERSION 1
-#include "../statesub.h"
-
-void TF20::decl_state()
-{
- enter_decl_state(STATE_VERSION);
-
- DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram));
- DECL_STATE_ENTRY_BOOL(rom_selected);
-
- leave_decl_state();
-}
-void TF20::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->FputBool(rom_selected);
-}
-
-bool TF20::load_state(FILEIO* state_fio)
+bool TF20::process_state(FILEIO* state_fio, bool loading)
{
- bool mb = false;
- if(state_entry != NULL) {
- mb = state_entry->load_state(state_fio);
- }
- if(!mb) 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);
-// rom_selected = state_fio->FgetBool();
-
- // post process
- if(rom_selected) {
- SET_BANK(0x0000, 0x07ff, ram, rom);
- } else {
- SET_BANK(0x0000, 0x07ff, ram, ram);
- }
- return true;
+ if(!state_fio->StateCheckUint32(STATE_VERSION)) {
+ return false;
+ }
+ if(!state_fio->StateCheckInt32(this_device_id)) {
+ return false;
+ }
+ state_fio->StateBuffer(ram, sizeof(ram), 1);
+ state_fio->StateBool(rom_selected);
+
+ // post process
+ if(loading) {
+ if(rom_selected) {
+ SET_BANK(0x0000, 0x07ff, ram, rom);
+ } else {
+ SET_BANK(0x0000, 0x07ff, ram, ram);
+ }
+ }
+ return true;
}
-