OSDN Git Service

[VM] Add PC-8001/mk2/8801/mk2.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pv2000 / cmt.cpp
index 4a5c3e2..6117e09 100644 (file)
@@ -8,7 +8,8 @@
 */
 
 #include "cmt.h"
-#include "../../fileio.h"
+
+namespace PV2000 {
 
 void CMT::initialize()
 {
@@ -31,7 +32,7 @@ void CMT::reset()
        close_tape();
 }
 
-void CMT::write_io8(uint32 addr, uint32 data)
+void CMT::write_io8(uint32_t addr, uint32_t data)
 {
        switch(addr & 0xff) {
        case 0x00:
@@ -72,10 +73,10 @@ void CMT::write_io8(uint32 addr, uint32 data)
        }
 }
 
-uint32 CMT::read_io8(uint32 addr)
+uint32_t CMT::read_io8(uint32_t addr)
 {
        // bit0 = signal
-       uint32 val = 2;
+       uint32_t val = 2;
        if((start & 0x9) == 0x9 && play) {
                val |= (buffer[bufcnt] & bit ? 1 : 0);
                if(!(bit & 0x80)) {
@@ -92,7 +93,7 @@ uint32 CMT::read_io8(uint32 addr)
        return val;
 }
 
-void CMT::play_tape(_TCHAR* file_path)
+void CMT::play_tape(const _TCHAR* file_path)
 {
        close_tape();
        
@@ -105,7 +106,7 @@ void CMT::play_tape(_TCHAR* file_path)
        }
 }
 
-void CMT::rec_tape(_TCHAR* file_path)
+void CMT::rec_tape(const _TCHAR* file_path)
 {
        close_tape();
        
@@ -132,33 +133,21 @@ void CMT::close_tape()
 
 #define STATE_VERSION  1
 
-void CMT::save_state(FILEIO* state_fio)
-{
-       state_fio->FputUint32(STATE_VERSION);
-       state_fio->FputInt32(this_device_id);
-       
-       state_fio->FputInt32(bufcnt);
-       state_fio->Fwrite(buffer, sizeof(buffer), 1);
-       state_fio->FputBool(play);
-       state_fio->FputBool(rec);
-       state_fio->FputUint8(start);
-       state_fio->FputUint8(bit);
-}
-
-bool CMT::load_state(FILEIO* state_fio)
+bool CMT::process_state(FILEIO* state_fio, bool loading)
 {
-       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;
        }
-       bufcnt = state_fio->FgetInt32();
-       state_fio->Fread(buffer, sizeof(buffer), 1);
-       play = state_fio->FgetBool();
-       rec = state_fio->FgetBool();
-       start = state_fio->FgetUint8();
-       bit = state_fio->FgetUint8();
+       state_fio->StateValue(bufcnt);
+       state_fio->StateArray(buffer, sizeof(buffer), 1);
+       state_fio->StateValue(play);
+       state_fio->StateValue(rec);
+       state_fio->StateValue(start);
+       state_fio->StateValue(bit);
        return true;
 }
 
+}