OSDN Git Service

[VM][WIP] Use namespace to devices per VMs.
[csp-qt/common_source_project-fm7.git] / source / src / vm / mz80k / memory.h
index eebf9f6..75e080d 100644 (file)
@@ -1,5 +1,5 @@
 /*
-       SHARP MZ-80K Emulator 'EmuZ-80K'
+       SHARP MZ-80K/C Emulator 'EmuZ-80K'
        SHARP MZ-1200 Emulator 'EmuZ-1200'
 
        Author : Takeda.Toshiya
        [ memory ]
 */
 
-#ifndef _MEMORY_H_
-#define _MEMORY_H_
+#ifndef _MZ80A_MEMORY_H_
+#define _MZ80A_MEMORY_H_
 
 #include "../vm.h"
 #include "../../emu.h"
 #include "../device.h"
 
+#define SIG_MEMORY_VGATE       0
 #if defined(SUPPORT_MZ80AIF)
 #define SIG_MEMORY_FDC_IRQ     1
 #define SIG_MEMORY_FDC_DRQ     2
 #endif
 
+namespace MZ80 {
+
 class MEMORY : public DEVICE
 {
 private:
        DEVICE *d_ctc, *d_pio;
-#if defined(_MZ1200) || defined(_MZ80A)
-       DEVICE *d_disp;
-#endif
        
-       uint8* rbank[64];
-       uint8* wbank[64];
-       uint8 wdmy[0x400];
-       uint8 rdmy[0x400];
+       uint8_t* rbank[64];
+       uint8_t* wbank[64];
+       uint8_t wdmy[0x400];
+       uint8_t rdmy[0x400];
        
-       uint8 ram[0xd000];      // RAM 48KB + swap 4KB
+       uint8_t ram[0xd000];    // RAM 48KB + swap 4KB
 #if defined(_MZ1200) || defined(_MZ80A)
-       uint8 vram[0x800];      // VRAM 2KB
+       uint8_t vram[0x800];    // VRAM 2KB
 #else
-       uint8 vram[0x400];      // VRAM 1KB
+       uint8_t vram[0x400];    // VRAM 1KB
 #endif
-       uint8 ipl[0x1000];      // IPL 4KB
+       uint8_t ipl[0x1000];    // IPL 4KB
 #if defined(_MZ1200) || defined(_MZ80A)
-       uint8 ext[0x800];       // EXT 2KB
+       uint8_t ext[0x800];     // EXT 2KB
 #endif
        
        bool tempo, blink;
@@ -54,18 +54,39 @@ private:
        bool memory_swap;
        void update_memory_swap();
 #endif
-#if defined(_MZ80A)
-       uint8 e200;             // scroll
-#endif
        
 #if defined(SUPPORT_MZ80AIF)
-       uint8 fdif[0x800];      // FD IF ROM 2KB
+       uint8_t fdif[0x800];    // FD IF ROM 2KB
        bool fdc_irq, fdc_drq;
        void update_fdif_rom_bank();
+#elif defined(SUPPORT_MZ80FIO)
+       uint8_t fdif[0x400];    // FD IF ROM 1KB
 #endif
        
+       uint8_t screen[200][320];
+       uint8_t font[0x800];
+#if defined(_MZ1200)
+       uint8_t pcg[0x1000];    // PCG-1200
+#else
+       uint8_t pcg[0x800];     // PCG-8000
+#endif
+       scrntype_t palette_pc[2];
+       bool vgate;
+#if defined(_MZ1200) || defined(_MZ80A)
+       bool reverse;
+#endif
+#if defined(_MZ80A)
+       uint32_t e200;          // scroll
+#endif
+       uint8_t pcg_data;
+       uint8_t pcg_addr;
+       uint8_t pcg_ctrl;
+       
 public:
-       MEMORY(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) {}
+       MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu)
+       {
+               set_device_name(_T("Memory Bus"));
+       }
        ~MEMORY() {}
        
        // common functions
@@ -73,13 +94,13 @@ public:
        void reset();
        void event_vline(int v, int clock);
        void event_callback(int event_id, int err);
-       void write_data8(uint32 addr, uint32 data);
-       uint32 read_data8(uint32 addr);
-#if defined(SUPPORT_MZ80AIF)
-       void write_signal(int id, uint32 data, uint32 mask);
+       void write_data8(uint32_t addr, uint32_t data);
+       uint32_t read_data8(uint32_t addr);
+       void write_signal(int id, uint32_t data, uint32_t mask);
+#if defined(_MZ80K)
+       void update_config();
 #endif
-       void save_state(FILEIO* state_fio);
-       bool load_state(FILEIO* state_fio);
+       bool process_state(FILEIO* state_fio, bool loading);
        
        // unique functions
        void set_context_ctc(DEVICE* device)
@@ -90,23 +111,9 @@ public:
        {
                d_pio = device;
        }
-#if defined(_MZ1200) || defined(_MZ80A)
-       void set_context_disp(DEVICE* device)
-       {
-               d_disp = device;
-       }
-#endif
-#if defined(_MZ80A)
-       uint8* get_e200()
-       {
-               return &e200;
-       }
-#endif
-       uint8* get_vram()
-       {
-               return vram;
-       }
+       void draw_screen();
 };
 
+}
 #endif