2 BANDAI RX-78 Emulator 'eRX-78'
4 Author : Takeda.Toshiya
11 #include "../datarec.h"
13 void CMT::initialize()
16 in = out = remote = now_acc = false;
19 // register event to detect the end of access
20 register_frame_event(this);
23 void CMT::write_io8(uint32_t addr, uint32_t data)
28 d_drec->write_signal(SIG_DATAREC_REMOTE, 1, 1);
31 bool signal = ((data & 1) != 0);
33 d_drec->write_signal(SIG_DATAREC_MIC, signal ? 1 : 0, 1);
39 uint32_t CMT::read_io8(uint32_t addr)
43 d_drec->write_signal(SIG_DATAREC_REMOTE, 1, 1);
50 void CMT::write_signal(int id, uint32_t data, uint32_t mask)
52 if(id == SIG_CMT_IN) {
53 in = ((data & mask) != 0);
57 void CMT::event_frame()
62 } else if(++framecnt >= FRAMES_PER_SEC) {
63 // motor off if not accessed for past 1 sec
64 d_drec->write_signal(SIG_DATAREC_REMOTE, 0, 1);
71 #define STATE_VERSION 1
73 #include "../../statesub.h"
75 void CMT::decl_state()
77 enter_decl_state(STATE_VERSION);
79 DECL_STATE_ENTRY_BOOL(in);
80 DECL_STATE_ENTRY_BOOL(out);
81 DECL_STATE_ENTRY_BOOL(remote);
82 DECL_STATE_ENTRY_BOOL(now_acc);
83 DECL_STATE_ENTRY_INT32(framecnt);
88 void CMT::save_state(FILEIO* state_fio)
90 if(state_entry != NULL) {
91 state_entry->save_state(state_fio);
93 // state_fio->FputUint32(STATE_VERSION);
94 // state_fio->FputInt32(this_device_id);
96 // state_fio->FputBool(in);
97 // state_fio->FputBool(out);
98 // state_fio->FputBool(remote);
99 // state_fio->FputBool(now_acc);
100 // state_fio->FputInt32(framecnt);
103 bool CMT::load_state(FILEIO* state_fio)
106 if(state_entry != NULL) {
107 mb = state_entry->load_state(state_fio);
112 // if(state_fio->FgetUint32() != STATE_VERSION) {
115 // if(state_fio->FgetInt32() != this_device_id) {
118 // in = state_fio->FgetBool();
119 // out = state_fio->FgetBool();
120 // remote = state_fio->FgetBool();
121 // now_acc = state_fio->FgetBool();
122 // framecnt = state_fio->FgetInt32();