OSDN Git Service

[VM][WIP][STATE] Updating state framework to upstream 2018-10-05.Still may cause...
[csp-qt/common_source_project-fm7.git] / source / src / vm / libcpu_newdev / device.h
index 4fd95c1..3a659b2 100644 (file)
@@ -15,7 +15,7 @@
 #include "../emu.h"
 #if defined(_USE_QT)
 #include "osd.h"
-#include "csp_logger.h"
+
 //#define USE_DEVICE_NAME
 #endif
 // max devices connected to the output port
 #define SIG_SCSI_ACK           309
 #define SIG_SCSI_RST           310
 
+#include "vm_template.h"
 
-class VM;
+class CSP_Logger;
+class VM_TEMPLATE;
 class EMU;
 class OSD;
 class DEVICE
 {
 protected:
-       VM* vm;
+       VM_TEMPLATE* vm;
        EMU* emu;
        OSD* osd;
+       CSP_Logger *p_logger;
 public:
-       DEVICE(VM* parent_vm, EMU* parent_emu);
-       //ToDo: Will implement real destructor per real classes and below destructor decl. with "virtual".
-       // This makes warning:
-       //"deleting object of polymorphic class type 'DEVICE' which has non-virtual
-       // destructor might cause undefined behavior [-Wdelete-non-virtual-dtor]".
-       //~DEVICE(void);
-       virtual ~DEVICE() {}
-       
-       virtual void initialize() { /* osd = emu->get_osd(); */}
-       virtual void release() {}
+       DEVICE(VM_TEMPLATE* parent_vm, EMU* parent_emu);
+       ~DEVICE() {}
+
+       virtual void initialize() { }
+       virtual void release();
        
        virtual void update_config() {}
        virtual void save_state(FILEIO* state_fio) {}
@@ -81,6 +79,15 @@ public:
        {
                reset();
        }
+       virtual bool process_state(FILEIO* state_fio, bool loading)
+       {
+               if(loading) {
+                       return load_state(state_fio);
+               } else {
+                       save_state(state_fio);
+                       return true;
+               }
+       }
        
        // NOTE: the virtual bus interface functions for 16/32bit access invite the cpu is little endian.
        // if the cpu is big endian, you need to implement them in the virtual machine memory/io classes.
@@ -483,7 +490,7 @@ public:
        }
        
        // bios
-       virtual bool bios_call_i86(uint32_t PC, uint16_t regs[], uint16_t sregs[], int32_t* ZeroFlag, int32_t* CarryFlag)
+       virtual bool bios_call_far_i86(uint32_t PC, uint16_t regs[], uint16_t sregs[], int32_t* ZeroFlag, int32_t* CarryFlag)
        {
                return false;
        }
@@ -518,10 +525,15 @@ public:
        virtual uint32_t get_current_clock();
        virtual uint32_t get_passed_clock(uint32_t prev);
        virtual double get_passed_usec(uint32_t prev);
+       virtual uint32_t get_passed_clock_since_vline();
+       virtual double get_passed_usec_since_vline();
+       virtual int get_cur_vline();
+       virtual int get_cur_vline_clocks();
        virtual uint32_t get_cpu_pc(int index);
        virtual void request_skip_frames();
        virtual void set_frames_per_sec(double frames);
        virtual void set_lines_per_frame(int lines);
+       virtual int get_lines_per_frame(void);
        // Force render sound immediately when device's status has changed.
        // You must call this after you changing registers (or enything).
        // If has problems, try set_realtime_render.
@@ -550,7 +562,8 @@ public:
        virtual void set_volume(int ch, int decibel_l, int decibel_r) {} // +1 equals +0.5dB (same as fmgen)
        virtual void set_device_name(const _TCHAR *format, ...);
        virtual void out_debug_log(const char *fmt, ...);
-#if 1
+       virtual void force_out_debug_log(const char *fmt, ...);
+
        // debugger
        // DEBUGGER is enabled by default.
        virtual void *get_debugger();
@@ -571,9 +584,13 @@ public:
        virtual bool write_debug_reg(const _TCHAR *reg, uint32_t data);
        virtual void get_debug_regs_info(_TCHAR *buffer, size_t buffer_len);
        virtual int debug_dasm(uint32_t pc, _TCHAR *buffer, size_t buffer_len);
-#endif
+       
+       // misc
+       const _TCHAR *get_lib_common_vm_version(void);
+
        _TCHAR this_device_name[128];
        
+       // device node using with iterator.
        DEVICE* prev_device;
        DEVICE* next_device;
        int this_device_id;