OSDN Git Service

[VM][PC9801] Enable to build PC-9801 with upstream 2018-10-05.
[csp-qt/common_source_project-fm7.git] / source / src / vm / pc9801 / cmt.cpp
index 792679d..4196372 100644 (file)
 
 #include "cmt.h"
 #include "../i8251.h"
-#include "../../fileio.h"
 
 void CMT::initialize()
 {
        fio = new FILEIO();
        play = rec = remote = false;
-       buffer_size = BUFFER_SIZE;
 }
 
 void CMT::release()
@@ -31,12 +29,17 @@ void CMT::reset()
        play = rec = remote = false;
 }
 
-void CMT::write_io8(uint32 addr, uint32 data)
+void CMT::write_io8(uint32_t addr, uint32_t data)
 {
-       remote = ((data & 0x20) != 0);
+       switch(addr) {
+       case 0x0095:
+       case 0x0097:
+               remote = ((data & 0x20) != 0);
+               break;
+       }
 }
 
-void CMT::write_signal(int id, uint32 data, uint32 mask)
+void CMT::write_signal(int id, uint32_t data, uint32_t mask)
 {
        if(id == SIG_CMT_OUT) {
                if(rec && remote) {
@@ -50,7 +53,7 @@ void CMT::write_signal(int id, uint32 data, uint32 mask)
        }
 }
 
-void CMT::play_tape(_TCHAR* file_path)
+void CMT::play_tape(const _TCHAR* file_path)
 {
        close_tape();
        
@@ -59,7 +62,6 @@ void CMT::play_tape(_TCHAR* file_path)
                int size = (fio->Ftell() + 9) & (BUFFER_SIZE - 1);
                fio->Fseek(0, FILEIO_SEEK_SET);
                memset(buffer, 0, sizeof(buffer));
-               buffer_size = size; 
                fio->Fread(buffer, sizeof(buffer), 1);
                
                // send data to sio
@@ -71,7 +73,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();
        
@@ -85,7 +87,7 @@ void CMT::close_tape()
 {
        // close file
        release_tape();
-       buffer_size = BUFFER_SIZE;
+       
        // clear sio buffer
        d_sio->write_signal(SIG_I8251_CLEAR, 0, 0);
 }
@@ -102,41 +104,21 @@ void CMT::release_tape()
        play = rec = false;
 }
 
-#ifdef DATAREC_SOUND
-void CMT::mix(int32 *buffer, int cnt)
-{
-  if(!cmt_mix) return;
-  // Not implemented yet :) 
-}    
-#endif
-
 #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->FputBool(remote);
-}
-
-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();
-       remote = state_fio->FgetBool();
+       state_fio->StateInt32(bufcnt);
+       state_fio->StateBuffer(buffer, sizeof(buffer), 1);
+       state_fio->StateBool(play);
+       state_fio->StateBool(rec);
+       state_fio->StateBool(remote);
        return true;
 }