OSDN Git Service

[VM] MEMORY:: class within some VM will change Foo_MEMORY:: to reduce misundestanding...
[csp-qt/common_source_project-fm7.git] / source / src / vm / fmr50 / cmos.cpp
index 0459cd1..847c18e 100644 (file)
@@ -17,7 +17,7 @@ void CMOS::initialize()
        modified = false;
        
        FILEIO* fio = new FILEIO();
-       if(fio->Fopen(emu->bios_path(_T("CMOS.BIN")), FILEIO_READ_BINARY)) {
+       if(fio->Fopen(create_local_path(_T("CMOS.BIN")), FILEIO_READ_BINARY)) {
                fio->Fread(cmos, sizeof(cmos), 1);
                fio->Fclose();
        }
@@ -28,7 +28,7 @@ void CMOS::release()
 {
        if(modified) {
                FILEIO* fio = new FILEIO();
-               if(fio->Fopen(emu->bios_path(_T("CMOS.BIN")), FILEIO_WRITE_BINARY)) {
+               if(fio->Fopen(create_local_path(_T("CMOS.BIN")), FILEIO_WRITE_BINARY)) {
                        fio->Fwrite(cmos, sizeof(cmos), 1);
                        fio->Fclose();
                }
@@ -41,7 +41,7 @@ void CMOS::reset()
        bank = 0;
 }
 
-void CMOS::write_io8(uint32 addr, uint32 data)
+void CMOS::write_io8(uint32_t addr, uint32_t data)
 {
        switch(addr) {
        case 0x90:
@@ -58,7 +58,7 @@ void CMOS::write_io8(uint32 addr, uint32 data)
        }
 }
 
-uint32 CMOS::read_io8(uint32 addr)
+uint32_t CMOS::read_io8(uint32_t addr)
 {
        if(!(addr & 1)) {
                return cmos[bank][(addr >> 1) & 0x7ff];
@@ -68,27 +68,16 @@ uint32 CMOS::read_io8(uint32 addr)
 
 #define STATE_VERSION  1
 
-void CMOS::save_state(FILEIO* state_fio)
+bool CMOS::process_state(FILEIO* state_fio, bool loading)
 {
-       state_fio->FputUint32(STATE_VERSION);
-       state_fio->FputInt32(this_device_id);
-       
-       state_fio->Fwrite(cmos, sizeof(cmos), 1);
-       state_fio->FputBool(modified);
-       state_fio->FputUint8(bank);
-}
-
-bool CMOS::load_state(FILEIO* state_fio)
-{
-       if(state_fio->FgetUint32() != STATE_VERSION) {
+       if(!state_fio->StateCheckUint32(STATE_VERSION)) {
                return false;
        }
-       if(state_fio->FgetInt32() != this_device_id) {
+       if(!state_fio->StateCheckInt32(this_device_id)) {
                return false;
        }
-       state_fio->Fread(cmos, sizeof(cmos), 1);
-       modified = state_fio->FgetBool();
-       bank = state_fio->FgetUint8();
+       state_fio->StateBuffer(cmos, sizeof(cmos), 1);
+       state_fio->StateBool(modified);
+       state_fio->StateUint8(bank);
        return true;
 }
-