OSDN Git Service

[VM][STATE] Use namespace {VMNAME} to separate per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz2800 / joystick.cpp
index 0a6344b..510b326 100644 (file)
@@ -9,22 +9,22 @@
 
 #include "joystick.h"
 
+namespace MZ2800 {
+
 void JOYSTICK::initialize()
 {
        mode = 0xf;
-       full_auto = 0;
-       joy_stat = emu->joy_buffer();
-       register_frame_event(this);
+       joy_stat = emu->get_joy_buffer();
 }
 
-void JOYSTICK::write_io8(uint32 addr, uint32 data)
+void JOYSTICK::write_io8(uint32_t addr, uint32_t data)
 {
        mode = data;
 }
 
-uint32 JOYSTICK::read_io8(uint32 addr)
+uint32_t JOYSTICK::read_io8(uint32_t addr)
 {
-       uint32 val = 0x3f;
+       uint32_t val = 0x3f;
        int num = (mode & 0x40) ? 1 : 0;
        bool dir = true;
        
@@ -50,40 +50,21 @@ uint32 JOYSTICK::read_io8(uint32 addr)
        // trigger
        if(joy_stat[num] & 0x10) val &= ~0x20;
        if(joy_stat[num] & 0x20) val &= ~0x10;
-       if(full_auto & 2) {
-               if(joy_stat[num] & 0x40) val &= ~0x20;
-               if(joy_stat[num] & 0x80) val &= ~0x10;
-       }
        return val;
 }
 
-void JOYSTICK::event_frame()
-{
-       // synch to vsync
-       full_auto = (full_auto + 1) & 3;
-}
-
-#define STATE_VERSION  1
+#define STATE_VERSION  2
 
-void JOYSTICK::save_state(FILEIO* state_fio)
+bool JOYSTICK::process_state(FILEIO* state_fio, bool loading)
 {
-       state_fio->FputUint32(STATE_VERSION);
-       state_fio->FputInt32(this_device_id);
-       
-       state_fio->FputUint32(mode);
-       state_fio->FputInt32(full_auto);
-}
-
-bool JOYSTICK::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;
        }
-       mode = state_fio->FgetUint32();
-       full_auto = state_fio->FgetInt32();
+       state_fio->StateUint32(mode);
        return true;
 }
 
+}