*/
#include "cmt.h"
-#include "../../fileio.h"
+
+namespace PV2000 {
void CMT::initialize()
{
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:
}
}
-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)) {
return val;
}
-void CMT::play_tape(_TCHAR* file_path)
+void CMT::play_tape(const _TCHAR* file_path)
{
close_tape();
}
}
-void CMT::rec_tape(_TCHAR* file_path)
+void CMT::rec_tape(const _TCHAR* file_path)
{
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;
}
+}