From: K.Ohta Date: Mon, 22 Oct 2018 15:20:35 +0000 (+0900) Subject: [VM][STATE] Use namespace {VMNAME} to separate per VMs. X-Git-Url: http://git.osdn.net/view?p=csp-qt%2Fcommon_source_project-fm7.git;a=commitdiff_plain;h=1a7386afa4c2ce25de158ba8285bc795446a8584 [VM][STATE] Use namespace {VMNAME} to separate per VMs. --- diff --git a/source/src/vm/babbage2nd/babbage2nd.h b/source/src/vm/babbage2nd/babbage2nd.h index 114e98a51..df6f5d478 100644 --- a/source/src/vm/babbage2nd/babbage2nd.h +++ b/source/src/vm/babbage2nd/babbage2nd.h @@ -102,7 +102,6 @@ class VM : public VM_TEMPLATE { protected: //EMU* emu; - //csp_state_utils* state_entry; // devices //EVENT* event; diff --git a/source/src/vm/device.h b/source/src/vm/device.h index edb36613a..bae0fef4e 100644 --- a/source/src/vm/device.h +++ b/source/src/vm/device.h @@ -54,8 +54,6 @@ #if defined(_USE_QT) class CSP_Logger; -class csp_state_utils; - extern CSP_Logger *csp_logger; #endif @@ -67,7 +65,6 @@ protected: OSD* osd; #if defined(_USE_QT) CSP_Logger *p_logger; - csp_state_utils *state_entry; #endif public: @@ -76,7 +73,6 @@ public: #if defined(_USE_QT) osd = emu->get_osd(); p_logger = csp_logger; - state_entry = NULL; #else osd = NULL; #endif @@ -107,8 +103,6 @@ public: virtual void initialize() { /* osd = emu->get_osd(); */ /* Initializing VM must be after initializing OSD. */ } #if defined(_USE_QT) virtual void release() { - if(state_entry != NULL) delete state_entry; - state_entry = NULL; } #else virtual void release() {} diff --git a/source/src/vm/disk.h b/source/src/vm/disk.h index ba7e90cbe..3d60d1258 100644 --- a/source/src/vm/disk.h +++ b/source/src/vm/disk.h @@ -55,7 +55,6 @@ typedef struct { bool mfm; } fd_format_t; -class csp_state_utils; class CSP_Logger; class FILEIO; class OSD; @@ -66,7 +65,6 @@ protected: EMU* emu; OSD* osd; #endif - csp_state_utils *state_entry; private: uint8_t buffer[DISK_BUFFER_SIZE + TRACK_BUFFER_SIZE]; _TCHAR orig_path[_MAX_PATH]; diff --git a/source/src/vm/mz2800/crtc.cpp b/source/src/vm/mz2800/crtc.cpp index 8afaea53d..909e0cba6 100644 --- a/source/src/vm/mz2800/crtc.cpp +++ b/source/src/vm/mz2800/crtc.cpp @@ -17,6 +17,8 @@ #define SCRN_640x400 1 #define SCRN_640x200 2 +namespace MZ2800 { + void CRTC::initialize() { // set 16/4096 palette @@ -1482,3 +1484,5 @@ bool CRTC::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(trans_init); return true; } + +} diff --git a/source/src/vm/mz2800/crtc.h b/source/src/vm/mz2800/crtc.h index 336ea6200..abb266f96 100644 --- a/source/src/vm/mz2800/crtc.h +++ b/source/src/vm/mz2800/crtc.h @@ -18,6 +18,8 @@ #define SIG_CRTC_PALLETE 1 #define SIG_CRTC_MASK 2 +namespace MZ2800 { + class CRTC : public DEVICE { private: @@ -133,5 +135,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/mz2800/floppy.cpp b/source/src/vm/mz2800/floppy.cpp index e9636d9af..fd9d6e2d4 100644 --- a/source/src/vm/mz2800/floppy.cpp +++ b/source/src/vm/mz2800/floppy.cpp @@ -11,6 +11,8 @@ #include "../mb8877.h" #include "../disk.h" +namespace MZ2800 { + void FLOPPY::reset() { for(int i = 0; i < 4; i++) { @@ -48,3 +50,4 @@ void FLOPPY::write_io8(uint32_t addr, uint32_t data) } } +} diff --git a/source/src/vm/mz2800/floppy.h b/source/src/vm/mz2800/floppy.h index 911e6f538..4a67351e2 100644 --- a/source/src/vm/mz2800/floppy.h +++ b/source/src/vm/mz2800/floppy.h @@ -16,6 +16,8 @@ class MB8877; +namespace MZ2800 { + class FLOPPY : public DEVICE { private: @@ -39,5 +41,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz2800/joystick.cpp b/source/src/vm/mz2800/joystick.cpp index 10d17d7db..510b32619 100644 --- a/source/src/vm/mz2800/joystick.cpp +++ b/source/src/vm/mz2800/joystick.cpp @@ -9,6 +9,8 @@ #include "joystick.h" +namespace MZ2800 { + void JOYSTICK::initialize() { mode = 0xf; @@ -64,3 +66,5 @@ bool JOYSTICK::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint32(mode); return true; } + +} diff --git a/source/src/vm/mz2800/joystick.h b/source/src/vm/mz2800/joystick.h index 43f21cf9b..d7b1fd473 100644 --- a/source/src/vm/mz2800/joystick.h +++ b/source/src/vm/mz2800/joystick.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace MZ2800 { + class JOYSTICK : public DEVICE { private: @@ -33,4 +35,5 @@ public: bool process_state(FILEIO* state_fio, bool loading); }; +} #endif diff --git a/source/src/vm/mz2800/keyboard.cpp b/source/src/vm/mz2800/keyboard.cpp index 5767fb271..61f9e7132 100644 --- a/source/src/vm/mz2800/keyboard.cpp +++ b/source/src/vm/mz2800/keyboard.cpp @@ -11,6 +11,8 @@ #include "../i8255.h" #include "../z80pio.h" +namespace MZ2800 { + static const int key_map[14][8] = { {0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77}, {0x78, 0x79, 0x68, 0x69, 0x6c, 0x6e, 0x6b, 0x6d}, @@ -98,3 +100,5 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(column); return true; } + +} diff --git a/source/src/vm/mz2800/keyboard.h b/source/src/vm/mz2800/keyboard.h index b6c939a74..22cf93067 100644 --- a/source/src/vm/mz2800/keyboard.h +++ b/source/src/vm/mz2800/keyboard.h @@ -16,6 +16,8 @@ #define SIG_KEYBOARD_COLUMN 0 +namespace MZ2800 { + class KEYBOARD : public DEVICE { private: @@ -52,5 +54,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz2800/memory.cpp b/source/src/vm/mz2800/memory.cpp index d7555595d..2aec94497 100644 --- a/source/src/vm/mz2800/memory.cpp +++ b/source/src/vm/mz2800/memory.cpp @@ -9,6 +9,8 @@ #include "./memory.h" +namespace MZ2800 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 11, eb = (e) >> 11; \ for(int i = sb; i <= eb; i++) { \ @@ -25,7 +27,7 @@ } \ } -void MZ2800_MEMORY::initialize() +void MEMORY::initialize() { // init memory memset(ram, 0, sizeof(ram)); @@ -61,7 +63,7 @@ void MZ2800_MEMORY::initialize() delete fio; } -void MZ2800_MEMORY::reset() +void MEMORY::reset() { SET_BANK(0x000000, 0x0bffff, ram, ram); SET_BANK(0x0c0000, 0x0dffff, vram, vram); @@ -79,7 +81,7 @@ void MZ2800_MEMORY::reset() vram_bank = dic_bank = kanji_bank = 0; } -void MZ2800_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { if((addr & 0xfc0000) == 0x80000) { write_dma_data8((addr & 0x3ffff) | mem_window, data); @@ -90,7 +92,7 @@ void MZ2800_MEMORY::write_data8(uint32_t addr, uint32_t data) } } -uint32_t MZ2800_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { if((addr & 0xfc0000) == 0x80000) { return read_dma_data8((addr & 0x3ffff) | mem_window); @@ -101,17 +103,17 @@ uint32_t MZ2800_MEMORY::read_data8(uint32_t addr) } } -void MZ2800_MEMORY::write_dma_data8(uint32_t addr, uint32_t data) +void MEMORY::write_dma_data8(uint32_t addr, uint32_t data) { wbank[addr >> 11][addr & 0x7ff] = data; } -uint32_t MZ2800_MEMORY::read_dma_data8(uint32_t addr) +uint32_t MEMORY::read_dma_data8(uint32_t addr) { return rbank[addr >> 11][addr & 0x7ff]; } -void MZ2800_MEMORY::write_io8(uint32_t addr, uint32_t data) +void MEMORY::write_io8(uint32_t addr, uint32_t data) { switch(addr & 0x7fff) { case 0x8c: @@ -160,7 +162,7 @@ void MZ2800_MEMORY::write_io8(uint32_t addr, uint32_t data) } } -uint32_t MZ2800_MEMORY::read_io8(uint32_t addr) +uint32_t MEMORY::read_io8(uint32_t addr) { switch(addr & 0x7fff) { case 0x8c: @@ -177,7 +179,7 @@ uint32_t MZ2800_MEMORY::read_io8(uint32_t addr) #define STATE_VERSION 2 -bool MZ2800_MEMORY::process_state(FILEIO* state_fio, bool loading) +bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -220,3 +222,5 @@ bool MZ2800_MEMORY::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/mz2800/memory.h b/source/src/vm/mz2800/memory.h index 26fc92ff0..a115de8e4 100644 --- a/source/src/vm/mz2800/memory.h +++ b/source/src/vm/mz2800/memory.h @@ -14,7 +14,9 @@ #include "../../emu.h" #include "../device.h" -class MZ2800_MEMORY : public DEVICE +namespace MZ2800 { + +class MEMORY : public DEVICE { private: DEVICE* d_crtc; @@ -36,11 +38,11 @@ private: uint8_t vram_bank, dic_bank, kanji_bank; public: - MZ2800_MEMORY(VM_TEMPLATE* 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")); } - ~MZ2800_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -76,5 +78,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz2800/mouse.cpp b/source/src/vm/mz2800/mouse.cpp index 2305de828..826b1f50a 100644 --- a/source/src/vm/mz2800/mouse.cpp +++ b/source/src/vm/mz2800/mouse.cpp @@ -10,6 +10,8 @@ #include "mouse.h" #include "../z80sio.h" +namespace MZ2800 { + void MOUSE::initialize() { stat = emu->get_mouse_buffer(); @@ -51,3 +53,5 @@ bool MOUSE::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(select); return true; } + +} diff --git a/source/src/vm/mz2800/mouse.h b/source/src/vm/mz2800/mouse.h index 6f5b9a619..1bc4bc8c7 100644 --- a/source/src/vm/mz2800/mouse.h +++ b/source/src/vm/mz2800/mouse.h @@ -17,6 +17,8 @@ #define SIG_MOUSE_SEL 0 #define SIG_MOUSE_DTR 1 +namespace MZ2800 { + class MOUSE : public DEVICE { private: @@ -45,5 +47,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz2800/mz2800.cpp b/source/src/vm/mz2800/mz2800.cpp index 5915fde2a..4e14eb85d 100644 --- a/source/src/vm/mz2800/mz2800.cpp +++ b/source/src/vm/mz2800/mz2800.cpp @@ -50,6 +50,18 @@ #include "serial.h" #include "sysport.h" +using MZ2800::CRTC; +using MZ2800::FLOPPY; +using MZ2800::JOYSTICK; +using MZ2800::KEYBOARD; +using MZ2800::MEMORY; +using MZ2800::MOUSE; +using MZ2800::PRINTER; +using MZ2800::RESET; +using MZ2800::SASI; +using MZ2800::SERIAL; +using MZ2800::SYSPORT; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -95,7 +107,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) floppy = new FLOPPY(this, emu); joystick = new JOYSTICK(this, emu); keyboard = new KEYBOARD(this, emu); - memory = new MZ2800_MEMORY(this, emu); + memory = new MEMORY(this, emu); mouse = new MOUSE(this, emu); printer = new PRINTER(this, emu); rst = new RESET(this, emu); diff --git a/source/src/vm/mz2800/mz2800.h b/source/src/vm/mz2800/mz2800.h index 59903cf76..8aebedcff 100644 --- a/source/src/vm/mz2800/mz2800.h +++ b/source/src/vm/mz2800/mz2800.h @@ -78,17 +78,19 @@ class YM2203; class Z80PIO; class Z80SIO; -class CRTC; -class FLOPPY; -class JOYSTICK; -class KEYBOARD; -class MZ2800_MEMORY; -class MOUSE; -class PRINTER; -class RESET; -class SASI; -class SERIAL; -class SYSPORT; +namespace MZ2800 { + class CRTC; + class FLOPPY; + class JOYSTICK; + class KEYBOARD; + class MEMORY; + class MOUSE; + class PRINTER; + class RESET; + class SASI; + class SERIAL; + class SYSPORT; +} class VM : public VM_TEMPLATE { @@ -115,17 +117,17 @@ protected: Z80PIO* pio1; Z80SIO* sio; - CRTC* crtc; - FLOPPY* floppy; - JOYSTICK* joystick; - KEYBOARD* keyboard; - MZ2800_MEMORY* memory; - MOUSE* mouse; - PRINTER* printer; - RESET* rst; - SASI* sasi; - SERIAL* serial; - SYSPORT* sysport; + MZ2800::CRTC* crtc; + MZ2800::FLOPPY* floppy; + MZ2800::JOYSTICK* joystick; + MZ2800::KEYBOARD* keyboard; + MZ2800::MEMORY* memory; + MZ2800::MOUSE* mouse; + MZ2800::PRINTER* printer; + MZ2800::RESET* rst; + MZ2800::SASI* sasi; + MZ2800::SERIAL* serial; + MZ2800::SYSPORT* sysport; public: // ---------------------------------------- diff --git a/source/src/vm/mz2800/printer.cpp b/source/src/vm/mz2800/printer.cpp index cff3a245f..02982c428 100644 --- a/source/src/vm/mz2800/printer.cpp +++ b/source/src/vm/mz2800/printer.cpp @@ -9,6 +9,8 @@ #include "printer.h" +namespace MZ2800 { + void PRINTER::write_io8(uint32_t addr, uint32_t data) { switch(addr & 0x7fff) { @@ -31,3 +33,4 @@ uint32_t PRINTER::read_io8(uint32_t addr) return 0xff; } +} diff --git a/source/src/vm/mz2800/printer.h b/source/src/vm/mz2800/printer.h index a8c9e8423..28d12b56f 100644 --- a/source/src/vm/mz2800/printer.h +++ b/source/src/vm/mz2800/printer.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace MZ2800 { + class PRINTER : public DEVICE { private: @@ -37,5 +39,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz2800/reset.cpp b/source/src/vm/mz2800/reset.cpp index a999525d8..ceb8180f5 100644 --- a/source/src/vm/mz2800/reset.cpp +++ b/source/src/vm/mz2800/reset.cpp @@ -9,6 +9,8 @@ #include "reset.h" +namespace MZ2800 { + void RESET::initialize() { prev = 0xff; @@ -39,3 +41,5 @@ bool RESET::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(prev); return true; } + +} diff --git a/source/src/vm/mz2800/reset.h b/source/src/vm/mz2800/reset.h index da781aaf0..a66498299 100644 --- a/source/src/vm/mz2800/reset.h +++ b/source/src/vm/mz2800/reset.h @@ -16,6 +16,8 @@ #define SIG_RESET_CONTROL 0 +namespace MZ2800 { + class RESET : public DEVICE { private: @@ -34,5 +36,6 @@ public: bool process_state(FILEIO* state_fio, bool loading); }; +} #endif diff --git a/source/src/vm/mz2800/sasi.cpp b/source/src/vm/mz2800/sasi.cpp index 388ba978f..4ff82992a 100644 --- a/source/src/vm/mz2800/sasi.cpp +++ b/source/src/vm/mz2800/sasi.cpp @@ -20,6 +20,8 @@ #define STATUS_ACK 0x40 #define STATUS_REQ 0x80 +namespace MZ2800 { + void SASI::reset() { control = 0x00; @@ -136,3 +138,5 @@ bool SASI::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(drq_status); return true; } + +} diff --git a/source/src/vm/mz2800/sasi.h b/source/src/vm/mz2800/sasi.h index 93e8cc81d..e5c7abbe7 100644 --- a/source/src/vm/mz2800/sasi.h +++ b/source/src/vm/mz2800/sasi.h @@ -17,6 +17,8 @@ #define SIG_SASI_IRQ 0 #define SIG_SASI_DRQ 1 +namespace MZ2800 { + class SASI : public DEVICE { private: @@ -59,5 +61,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz2800/serial.cpp b/source/src/vm/mz2800/serial.cpp index 6959ab297..02ff7ec13 100644 --- a/source/src/vm/mz2800/serial.cpp +++ b/source/src/vm/mz2800/serial.cpp @@ -10,6 +10,8 @@ #include "serial.h" #include "../z80sio.h" +namespace MZ2800 { + void SERIAL::reset() { addr_a0 = true; @@ -80,3 +82,5 @@ bool SERIAL::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(addr_a0); return true; } + +} diff --git a/source/src/vm/mz2800/serial.h b/source/src/vm/mz2800/serial.h index e72620f51..540f74e30 100644 --- a/source/src/vm/mz2800/serial.h +++ b/source/src/vm/mz2800/serial.h @@ -16,6 +16,8 @@ class Z80SIO; +namespace MZ2800 { + class SERIAL : public DEVICE { private: @@ -42,5 +44,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz2800/sysport.cpp b/source/src/vm/mz2800/sysport.cpp index 7e172933c..8e2a825e1 100644 --- a/source/src/vm/mz2800/sysport.cpp +++ b/source/src/vm/mz2800/sysport.cpp @@ -10,6 +10,8 @@ #include "sysport.h" #include "../i8253.h" +namespace MZ2800 { + void SYSPORT::write_io8(uint32_t addr, uint32_t data) { switch(addr & 0x7fff) { @@ -34,3 +36,4 @@ uint32_t SYSPORT::read_io8(uint32_t addr) return 0xff; } +} diff --git a/source/src/vm/mz2800/sysport.h b/source/src/vm/mz2800/sysport.h index a815288c7..214436ac9 100644 --- a/source/src/vm/mz2800/sysport.h +++ b/source/src/vm/mz2800/sysport.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace MZ2800 { + class SYSPORT : public DEVICE { private: @@ -41,5 +43,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz3500/keyboard.cpp b/source/src/vm/mz3500/keyboard.cpp index eabcaa5c9..028aaf62d 100644 --- a/source/src/vm/mz3500/keyboard.cpp +++ b/source/src/vm/mz3500/keyboard.cpp @@ -61,6 +61,8 @@ // PRO Page Up // OP Page Down +namespace MZ3500 { + static const uint16_t key_table[256] = { 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x00f, 0x1f4, 0x000, 0x000, 0x000, 0x00d, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x0fe, 0x000, 0x0fe, 0x000, 0x000, 0x000, 0x000, @@ -485,3 +487,5 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(pro_mode); return true; } + +} diff --git a/source/src/vm/mz3500/keyboard.h b/source/src/vm/mz3500/keyboard.h index 31c677037..eeaeb15a6 100644 --- a/source/src/vm/mz3500/keyboard.h +++ b/source/src/vm/mz3500/keyboard.h @@ -20,6 +20,8 @@ class FIFO; +namespace MZ3500 { + class KEYBOARD : public DEVICE { private: @@ -77,4 +79,5 @@ public: } }; +} #endif diff --git a/source/src/vm/mz3500/main.cpp b/source/src/vm/mz3500/main.cpp index 88233d60c..290e34774 100644 --- a/source/src/vm/mz3500/main.cpp +++ b/source/src/vm/mz3500/main.cpp @@ -10,6 +10,8 @@ #include "./main.h" #include "../upd765a.h" +namespace MZ3500 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 11, eb = (e) >> 11; \ for(int i = sb; i <= eb; i++) { \ @@ -430,3 +432,5 @@ bool MAIN::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/mz3500/main.h b/source/src/vm/mz3500/main.h index 8d1314d52..9e5e6acf3 100644 --- a/source/src/vm/mz3500/main.h +++ b/source/src/vm/mz3500/main.h @@ -25,6 +25,8 @@ #define SIG_MAIN_DRQ 8 #define SIG_MAIN_INDEX 9 +namespace MZ3500 { + class MAIN : public DEVICE { private: @@ -98,5 +100,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz3500/mz3500.cpp b/source/src/vm/mz3500/mz3500.cpp index dea738d94..a888ccce0 100644 --- a/source/src/vm/mz3500/mz3500.cpp +++ b/source/src/vm/mz3500/mz3500.cpp @@ -36,6 +36,10 @@ #include "./sub.h" #include "keyboard.h" +using MZ3500::MAIN; +using MZ3500::SUB; +using MZ3500::KEYBOARD; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- diff --git a/source/src/vm/mz3500/mz3500.h b/source/src/vm/mz3500/mz3500.h index bdaaa80f8..985208001 100644 --- a/source/src/vm/mz3500/mz3500.h +++ b/source/src/vm/mz3500/mz3500.h @@ -77,9 +77,11 @@ class UPD7220; class UPD765A; class Z80; -class MAIN; -class SUB; -class KEYBOARD; +namespace MZ3500 { + class MAIN; + class SUB; + class KEYBOARD; +} class VM : public VM_TEMPLATE { @@ -94,7 +96,7 @@ protected: IO* mainio; UPD765A* fdc; Z80* maincpu; - MAIN* mainbus; + MZ3500::MAIN* mainbus; // for sub cpu DEVICE* printer; @@ -117,8 +119,8 @@ protected: UPD7220* gdc_chr; UPD7220* gdc_gfx; Z80* subcpu; - SUB* subbus; - KEYBOARD* kbd; + MZ3500::SUB* subbus; + MZ3500::KEYBOARD* kbd; uint8_t halt; diff --git a/source/src/vm/mz3500/sub.cpp b/source/src/vm/mz3500/sub.cpp index fd7de6e75..c4a51c517 100644 --- a/source/src/vm/mz3500/sub.cpp +++ b/source/src/vm/mz3500/sub.cpp @@ -10,6 +10,8 @@ #include "./sub.h" #include "./main.h" +namespace MZ3500 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 11, eb = (e) >> 11; \ for(int i = sb; i <= eb; i++) { \ @@ -585,3 +587,5 @@ bool SUB::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(crt_400line); return true; } + +} diff --git a/source/src/vm/mz3500/sub.h b/source/src/vm/mz3500/sub.h index 92bb0d2f5..614af9477 100644 --- a/source/src/vm/mz3500/sub.h +++ b/source/src/vm/mz3500/sub.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace MZ3500 { + class SUB : public DEVICE { private: @@ -123,5 +125,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/mz5500/display.cpp b/source/src/vm/mz5500/display.cpp index 5a0a84668..713cdb656 100644 --- a/source/src/vm/mz5500/display.cpp +++ b/source/src/vm/mz5500/display.cpp @@ -9,6 +9,8 @@ #include "display.h" +namespace MZ5500 { + static const int plane_priority[8][8] = { {0, 1, 2, 3, 0, 1, 2, 3}, {0, 1, 2, 3, 4, 1, 2, 3}, {0, 1, 2, 3, 4, 4, 2, 3}, {0, 1, 2, 3, 4, 4, 4, 3}, @@ -545,3 +547,5 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(mode_p); return true; } + +} diff --git a/source/src/vm/mz5500/display.h b/source/src/vm/mz5500/display.h index 65d76b3a5..96e3c1a82 100644 --- a/source/src/vm/mz5500/display.h +++ b/source/src/vm/mz5500/display.h @@ -18,6 +18,8 @@ class UPD7220; +namespace MZ5500 { + class DISPLAY : public DEVICE { private: @@ -82,5 +84,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/mz5500/keyboard.cpp b/source/src/vm/mz5500/keyboard.cpp index 312a96f76..e5e676267 100644 --- a/source/src/vm/mz5500/keyboard.cpp +++ b/source/src/vm/mz5500/keyboard.cpp @@ -61,6 +61,8 @@ #define TIMEOUT_500MSEC 30 #define TIMEOUT_100MSEC 6 +namespace MZ5500 { + static const int key_table[256] = { 0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x008,0x009,0x000,0x000,0x000,0x00d,0x000,0x000, 0x000,0x000,0x000,0x006,0x000,0x000,0x000,0x000,0x000,0x000,0x000,0x01b,0x000,0x000,0x000,0x000, @@ -493,3 +495,5 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) state_fio->StateInt32(timeout); return true; } + +} diff --git a/source/src/vm/mz5500/keyboard.h b/source/src/vm/mz5500/keyboard.h index 4233cef15..57bb4e307 100644 --- a/source/src/vm/mz5500/keyboard.h +++ b/source/src/vm/mz5500/keyboard.h @@ -18,6 +18,8 @@ class FIFO; +namespace MZ5500 { + class KEYBOARD : public DEVICE { private: @@ -71,4 +73,5 @@ public: } }; +} #endif diff --git a/source/src/vm/mz5500/memory.cpp b/source/src/vm/mz5500/memory.cpp index 812364991..16ff67b75 100644 --- a/source/src/vm/mz5500/memory.cpp +++ b/source/src/vm/mz5500/memory.cpp @@ -9,6 +9,8 @@ #include "./memory.h" +namespace MZ5500 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 14, eb = (e) >> 14; \ for(int i = sb; i <= eb; i++) { \ @@ -25,7 +27,7 @@ } \ } -void MZ5500_MEMORY::initialize() +void MEMORY::initialize() { // init memory memset(ram, 0, sizeof(ram)); @@ -84,14 +86,14 @@ void MZ5500_MEMORY::initialize() haddr = 0; } -void MZ5500_MEMORY::reset() +void MEMORY::reset() { bank1 = 0xe0; bank2 = 0; update_bank(); } -void MZ5500_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { addr &= 0xfffff; // if((0x80000 <= addr && addr < 0xa0000) || (0xf0000 <= addr && addr < 0xfc000)) { @@ -100,7 +102,7 @@ void MZ5500_MEMORY::write_data8(uint32_t addr, uint32_t data) wbank[addr >> 14][addr & 0x3fff] = data; } -uint32_t MZ5500_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { addr &= 0xfffff; // if((0x80000 <= addr && addr < 0xa0000) || (0xf0000 <= addr && addr < 0xfc000)) { @@ -109,7 +111,7 @@ uint32_t MZ5500_MEMORY::read_data8(uint32_t addr) return rbank[addr >> 14][addr & 0x3fff]; } -void MZ5500_MEMORY::write_dma_data8(uint32_t addr, uint32_t data) +void MEMORY::write_dma_data8(uint32_t addr, uint32_t data) { addr = (addr & 0xffff) | haddr; // if((0x80000 <= addr && addr < 0xa0000) || (0xf0000 <= addr && addr < 0xfc000)) { @@ -118,7 +120,7 @@ void MZ5500_MEMORY::write_dma_data8(uint32_t addr, uint32_t data) wbank[addr >> 14][addr & 0x3fff] = data; } -uint32_t MZ5500_MEMORY::read_dma_data8(uint32_t addr) +uint32_t MEMORY::read_dma_data8(uint32_t addr) { addr = (addr & 0xffff) | haddr; // if((0x80000 <= addr && addr < 0xa0000) || (0xf0000 <= addr && addr < 0xfc000)) { @@ -127,7 +129,7 @@ uint32_t MZ5500_MEMORY::read_dma_data8(uint32_t addr) return rbank[addr >> 14][addr & 0x3fff]; } -void MZ5500_MEMORY::write_io8(uint32_t addr, uint32_t data) +void MEMORY::write_io8(uint32_t addr, uint32_t data) { switch(addr & 0xff) { case 0x50: @@ -145,12 +147,12 @@ void MZ5500_MEMORY::write_io8(uint32_t addr, uint32_t data) } } -uint32_t MZ5500_MEMORY::read_io8(uint32_t addr) +uint32_t MEMORY::read_io8(uint32_t addr) { return 0xf0 | bank2; // ??? } -void MZ5500_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) +void MEMORY::write_signal(int id, uint32_t data, uint32_t mask) { if(bank1 != data) { bank1 = data; @@ -158,7 +160,7 @@ void MZ5500_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) } } -void MZ5500_MEMORY::update_bank() +void MEMORY::update_bank() { switch(bank1 & 0xe0) { case 0xe0: @@ -190,7 +192,7 @@ void MZ5500_MEMORY::update_bank() #define STATE_VERSION 1 -bool MZ5500_MEMORY::process_state(FILEIO* state_fio, bool loading) +bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -213,3 +215,5 @@ bool MZ5500_MEMORY::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/mz5500/memory.h b/source/src/vm/mz5500/memory.h index 779ddd032..b9dffbb20 100644 --- a/source/src/vm/mz5500/memory.h +++ b/source/src/vm/mz5500/memory.h @@ -16,7 +16,9 @@ #define SIG_MEMORY_BANK 0 -class MZ5500_MEMORY : public DEVICE +namespace MZ5500 { + +class MEMORY : public DEVICE { private: DEVICE* d_cpu; @@ -50,11 +52,11 @@ private: void update_bank(); public: - MZ5500_MEMORY(VM_TEMPLATE* 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")); } - ~MZ5500_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -79,5 +81,6 @@ public: } }; +} #endif diff --git a/source/src/vm/mz5500/mz5500.cpp b/source/src/vm/mz5500/mz5500.cpp index 3f7e3e717..e8548f276 100644 --- a/source/src/vm/mz5500/mz5500.cpp +++ b/source/src/vm/mz5500/mz5500.cpp @@ -44,6 +44,11 @@ #include "./memory.h" #include "sysport.h" +using MZ5500::DISPLAY; +using MZ5500::KEYBOARD; +using MZ5500::MEMORY; +using MZ5500::SYSPORT; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -107,7 +112,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) display = new DISPLAY(this, emu); keyboard = new KEYBOARD(this, emu); - memory = new MZ5500_MEMORY(this, emu); + memory = new MEMORY(this, emu); sysport = new SYSPORT(this, emu); // set contexts diff --git a/source/src/vm/mz5500/mz5500.h b/source/src/vm/mz5500/mz5500.h index b67aebd21..26a8ef810 100644 --- a/source/src/vm/mz5500/mz5500.h +++ b/source/src/vm/mz5500/mz5500.h @@ -101,10 +101,12 @@ class AY_3_891X; class Z80CTC; class Z80SIO; -class DISPLAY; -class KEYBOARD; -class MZ5500_MEMORY; -class SYSPORT; +namespace MZ5500 { + class DISPLAY; + class KEYBOARD; + class MEMORY; + class SYSPORT; +} class VM : public VM_TEMPLATE { @@ -146,10 +148,10 @@ protected: #endif Z80SIO* sio; - DISPLAY* display; - KEYBOARD* keyboard; - MZ5500_MEMORY* memory; - SYSPORT* sysport; + MZ5500::DISPLAY* display; + MZ5500::KEYBOARD* keyboard; + MZ5500::MEMORY* memory; + MZ5500::SYSPORT* sysport; public: // ---------------------------------------- diff --git a/source/src/vm/mz5500/sysport.cpp b/source/src/vm/mz5500/sysport.cpp index 96a9b49ce..99d6afec0 100644 --- a/source/src/vm/mz5500/sysport.cpp +++ b/source/src/vm/mz5500/sysport.cpp @@ -9,6 +9,8 @@ #include "sysport.h" +namespace MZ5500 { + void SYSPORT::initialize() { rst = 0; @@ -80,3 +82,5 @@ bool SYSPORT::process_state(FILEIO* state_fio, bool loading) state_fio->StateInt32(highden); return true; } + +} diff --git a/source/src/vm/mz5500/sysport.h b/source/src/vm/mz5500/sysport.h index 3bcc4be40..27b12e4ee 100644 --- a/source/src/vm/mz5500/sysport.h +++ b/source/src/vm/mz5500/sysport.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace MZ5500 { + class SYSPORT : public DEVICE { private: @@ -53,5 +55,6 @@ public: } }; +} #endif diff --git a/source/src/vm/n5200/display.cpp b/source/src/vm/n5200/display.cpp index cc17b70c5..2bb96888e 100644 --- a/source/src/vm/n5200/display.cpp +++ b/source/src/vm/n5200/display.cpp @@ -10,6 +10,8 @@ #include "display.h" #include "../i8259.h" +namespace N5200 { + void DISPLAY::initialize() { register_vline_event(this); @@ -42,3 +44,4 @@ void DISPLAY::draw_screen() emu->screen_skip_line(false); } +} diff --git a/source/src/vm/n5200/display.h b/source/src/vm/n5200/display.h index df30d64a0..c96586170 100644 --- a/source/src/vm/n5200/display.h +++ b/source/src/vm/n5200/display.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace N5200 { + class DISPLAY : public DEVICE { private: @@ -51,5 +53,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/n5200/floppy.cpp b/source/src/vm/n5200/floppy.cpp index 940894d86..52588717f 100644 --- a/source/src/vm/n5200/floppy.cpp +++ b/source/src/vm/n5200/floppy.cpp @@ -12,6 +12,8 @@ #include "floppy.h" #include "../i8237.h" +namespace N5200 { + void FLOPPY::reset() { chgreg = 3; @@ -81,3 +83,4 @@ void FLOPPY::write_signal(int id, uint32_t data, uint32_t mask) d_dma->write_signal(dma_ids[chgreg & 1], data, mask); } +} diff --git a/source/src/vm/n5200/floppy.h b/source/src/vm/n5200/floppy.h index 2836f2a01..c99127bfd 100644 --- a/source/src/vm/n5200/floppy.h +++ b/source/src/vm/n5200/floppy.h @@ -16,6 +16,8 @@ #define SIG_FLOPPY_DRQ 0 +namespace N5200 { + class FLOPPY : public DEVICE { private: @@ -47,5 +49,6 @@ public: } }; +} #endif diff --git a/source/src/vm/n5200/keyboard.cpp b/source/src/vm/n5200/keyboard.cpp index 5b2632ffe..afcba7f9b 100644 --- a/source/src/vm/n5200/keyboard.cpp +++ b/source/src/vm/n5200/keyboard.cpp @@ -10,6 +10,8 @@ #include "keyboard.h" #include "../i8251.h" +namespace N5200 { + static const int key_table[256] = { -1, -1, -1, -1, -1, -1, -1, -1,0x0e,0x0f, -1, -1, -1,0x1c, -1, -1, 0x70,0x74,0x73,0x60, -1, -1, -1, -1, -1, -1, -1,0x00,0x35,0x51, -1, -1, @@ -94,3 +96,4 @@ void KEYBOARD::key_up(int code) } } +} diff --git a/source/src/vm/n5200/keyboard.h b/source/src/vm/n5200/keyboard.h index a659dc79f..7dd39ad5b 100644 --- a/source/src/vm/n5200/keyboard.h +++ b/source/src/vm/n5200/keyboard.h @@ -17,6 +17,8 @@ #define SIG_KEYBOARD_RST 0 #define SIG_KEYBOARD_RECV 1 +namespace N5200 { + class KEYBOARD : public DEVICE { private: @@ -54,4 +56,5 @@ public: } }; +} #endif diff --git a/source/src/vm/n5200/memory.cpp b/source/src/vm/n5200/memory.cpp index 40d602ad7..be8b8ef8c 100644 --- a/source/src/vm/n5200/memory.cpp +++ b/source/src/vm/n5200/memory.cpp @@ -9,6 +9,8 @@ #include "./memory.h" +namespace N5200 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 11, eb = (e) >> 11; \ for(int i = sb; i <= eb; i++) { \ @@ -25,7 +27,7 @@ } \ } -void N5200_MEMORY::initialize() +void MEMORY::initialize() { // init memory memset(ram, 0, sizeof(ram)); @@ -48,7 +50,7 @@ void N5200_MEMORY::initialize() delete fio; } -void N5200_MEMORY::release() +void MEMORY::release() { // save ram image FILEIO* fio = new FILEIO(); @@ -59,7 +61,7 @@ void N5200_MEMORY::release() delete fio; } -void N5200_MEMORY::reset() +void MEMORY::reset() { SET_BANK(0x000000, 0xffffff, wdmy, rdmy); SET_BANK(0x000000, 0x0bffff, ram, ram); @@ -73,7 +75,7 @@ void N5200_MEMORY::reset() protect = true; } -void N5200_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { addr &= 0xffffff; if(0xe7800 <= addr && addr < 0xf0000 && protect) { @@ -82,13 +84,13 @@ void N5200_MEMORY::write_data8(uint32_t addr, uint32_t data) wbank[addr >> 11][addr & 0x7ff] = data; } -uint32_t N5200_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { addr &= 0xffffff; return rbank[addr >> 11][addr & 0x7ff]; } -void N5200_MEMORY::write_io8(uint32_t addr, uint32_t data) +void MEMORY::write_io8(uint32_t addr, uint32_t data) { switch(addr) { case 0x74: @@ -97,8 +99,9 @@ void N5200_MEMORY::write_io8(uint32_t addr, uint32_t data) } } -uint32_t N5200_MEMORY::read_io8(uint32_t addr) +uint32_t MEMORY::read_io8(uint32_t addr) { return 0xff; } +} diff --git a/source/src/vm/n5200/memory.h b/source/src/vm/n5200/memory.h index 1ecc5a69f..fb9b2f1ef 100644 --- a/source/src/vm/n5200/memory.h +++ b/source/src/vm/n5200/memory.h @@ -14,7 +14,9 @@ #include "../../emu.h" #include "../device.h" -class N5200_MEMORY : public DEVICE +namespace N5200 { + +class MEMORY : public DEVICE { private: uint8_t* rbank[8192]; // 16MB / 2KB @@ -32,11 +34,11 @@ private: bool protect; public: - N5200_MEMORY(VM_TEMPLATE* 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")); } - ~N5200_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -58,5 +60,6 @@ public: } }; +} #endif diff --git a/source/src/vm/n5200/n5200.cpp b/source/src/vm/n5200/n5200.cpp index 20fcba8d8..feeb53b07 100644 --- a/source/src/vm/n5200/n5200.cpp +++ b/source/src/vm/n5200/n5200.cpp @@ -35,6 +35,12 @@ #include "./memory.h" #include "system.h" +using N5200::DISPLAY; +using N5200::FLOPPY; +using N5200::KEYBOARD; +using N5200::MEMORY; +using N5200::SYSTEM; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -74,7 +80,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) display = new DISPLAY(this, emu); floppy = new FLOPPY(this, emu); keyboard = new KEYBOARD(this, emu); - memory = new N5200_MEMORY(this, emu); + memory = new MEMORY(this, emu); system = new SYSTEM(this, emu); // set contexts diff --git a/source/src/vm/n5200/n5200.h b/source/src/vm/n5200/n5200.h index 0a9cfb20f..738c03557 100644 --- a/source/src/vm/n5200/n5200.h +++ b/source/src/vm/n5200/n5200.h @@ -65,11 +65,13 @@ class UPD1990A; class UPD7220; class UPD765A; -class DISPLAY; -class FLOPPY; -class KEYBOARD; -class N5200_MEMORY; -class SYSTEM; +namespace N5200 { + class DISPLAY; + class FLOPPY; + class KEYBOARD; + class MEMORY; + class SYSTEM; +} class VM : public VM_TEMPLATE { @@ -94,11 +96,11 @@ protected: UPD7220* gdc_g; UPD765A* fdc; - DISPLAY* display; - FLOPPY* floppy; - KEYBOARD* keyboard; - N5200_MEMORY* memory; - SYSTEM* system; + N5200::DISPLAY* display; + N5200::FLOPPY* floppy; + N5200::KEYBOARD* keyboard; + N5200::MEMORY* memory; + N5200::SYSTEM* system; public: // ---------------------------------------- diff --git a/source/src/vm/n5200/system.cpp b/source/src/vm/n5200/system.cpp index 6bc875e3c..5c0a99ac3 100644 --- a/source/src/vm/n5200/system.cpp +++ b/source/src/vm/n5200/system.cpp @@ -12,6 +12,8 @@ #include "system.h" #include "../i8237.h" +namespace N5200 { + void SYSTEM::reset() { mode = 0; @@ -62,3 +64,5 @@ uint32_t SYSTEM::read_io8(uint32_t addr) return 0xff; } +} + diff --git a/source/src/vm/n5200/system.h b/source/src/vm/n5200/system.h index 9cb7844a8..bbfe64995 100644 --- a/source/src/vm/n5200/system.h +++ b/source/src/vm/n5200/system.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace N5200 { + class SYSTEM : public DEVICE { private: @@ -41,5 +43,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pasopia/display.cpp b/source/src/vm/pasopia/display.cpp index e2d3fc23d..c3af671a7 100644 --- a/source/src/vm/pasopia/display.cpp +++ b/source/src/vm/pasopia/display.cpp @@ -9,6 +9,8 @@ #include "display.h" +namespace PASOPIA { + void DISPLAY::initialize() { // load rom image @@ -644,3 +646,5 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint16(cblink); return true; } + +} diff --git a/source/src/vm/pasopia/display.h b/source/src/vm/pasopia/display.h index 346ea70d3..80397f431 100644 --- a/source/src/vm/pasopia/display.h +++ b/source/src/vm/pasopia/display.h @@ -16,6 +16,8 @@ #define SIG_DISPLAY_I8255_1_A 0 +namespace PASOPIA { + class DISPLAY : public DEVICE { private: @@ -74,5 +76,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/pasopia/floppy.cpp b/source/src/vm/pasopia/floppy.cpp index d6a875bd2..00bc3245f 100644 --- a/source/src/vm/pasopia/floppy.cpp +++ b/source/src/vm/pasopia/floppy.cpp @@ -10,6 +10,8 @@ #include "floppy.h" #include "../upd765a.h" +namespace PASOPIA { + void FLOPPY::initialize() { intr = false; @@ -85,3 +87,5 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(supported); return true; } + +} diff --git a/source/src/vm/pasopia/floppy.h b/source/src/vm/pasopia/floppy.h index 45a46e50f..490c85ad9 100644 --- a/source/src/vm/pasopia/floppy.h +++ b/source/src/vm/pasopia/floppy.h @@ -16,6 +16,8 @@ #define SIG_FLOPPY_INTR 0 +namespace PASOPIA { + class FLOPPY : public DEVICE { private: @@ -44,5 +46,6 @@ public: bool supported; }; +} #endif diff --git a/source/src/vm/pasopia/joypac2.cpp b/source/src/vm/pasopia/joypac2.cpp index 65ee64b1d..f53096927 100644 --- a/source/src/vm/pasopia/joypac2.cpp +++ b/source/src/vm/pasopia/joypac2.cpp @@ -10,6 +10,8 @@ #include "joypac2.h" +namespace PASOPIA { + void JOYPAC2::initialize(int id) { joy = emu->get_joy_buffer(); @@ -45,3 +47,4 @@ uint32_t JOYPAC2::read_io8(uint32_t addr) return 0xff; } +} diff --git a/source/src/vm/pasopia/joypac2.h b/source/src/vm/pasopia/joypac2.h index f2052d5b0..7756c6bf9 100644 --- a/source/src/vm/pasopia/joypac2.h +++ b/source/src/vm/pasopia/joypac2.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "pac2dev.h" +namespace PASOPIA { + class JOYPAC2 : public PAC2DEV { private: @@ -32,5 +34,6 @@ public: uint32_t read_io8(uint32_t addr); }; +} #endif diff --git a/source/src/vm/pasopia/kanjipac2.cpp b/source/src/vm/pasopia/kanjipac2.cpp index 47927ee0a..b788f57c7 100644 --- a/source/src/vm/pasopia/kanjipac2.cpp +++ b/source/src/vm/pasopia/kanjipac2.cpp @@ -10,6 +10,8 @@ #include "kanjipac2.h" +namespace PASOPIA { + void KANJIPAC2::initialize(int id) { FILEIO* fio = new FILEIO(); @@ -52,3 +54,5 @@ bool KANJIPAC2::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint32(ptr); return true; } + +} diff --git a/source/src/vm/pasopia/kanjipac2.h b/source/src/vm/pasopia/kanjipac2.h index 6b9741e99..47cb83e46 100644 --- a/source/src/vm/pasopia/kanjipac2.h +++ b/source/src/vm/pasopia/kanjipac2.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "pac2dev.h" +namespace PASOPIA { + class KANJIPAC2 : public PAC2DEV { private: @@ -34,5 +36,6 @@ public: bool process_state(FILEIO* state_fio, bool loading); }; +} #endif diff --git a/source/src/vm/pasopia/keyboard.cpp b/source/src/vm/pasopia/keyboard.cpp index 0a38215a9..d8fbe43bb 100644 --- a/source/src/vm/pasopia/keyboard.cpp +++ b/source/src/vm/pasopia/keyboard.cpp @@ -10,6 +10,8 @@ #include "keyboard.h" #include "../z80pio.h" +namespace PASOPIA { + static const int key_map[12][8] = { { 0x12, 0x10, 0x14, 0x00, 0x11, 0x15, 0x00, 0x00 }, { 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67 }, @@ -85,3 +87,5 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(sel); return true; } + +} diff --git a/source/src/vm/pasopia/keyboard.h b/source/src/vm/pasopia/keyboard.h index 1076d596d..5935754e0 100644 --- a/source/src/vm/pasopia/keyboard.h +++ b/source/src/vm/pasopia/keyboard.h @@ -16,6 +16,8 @@ #define SIG_KEYBOARD_Z80PIO_A 0 +namespace PASOPIA { + class KEYBOARD : public DEVICE { private: @@ -45,5 +47,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pasopia/memory.cpp b/source/src/vm/pasopia/memory.cpp index 7be0c14df..eba8d7d93 100644 --- a/source/src/vm/pasopia/memory.cpp +++ b/source/src/vm/pasopia/memory.cpp @@ -10,6 +10,8 @@ #include "./memory.h" #include "../i8255.h" +namespace PASOPIA { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 12, eb = (e) >> 12; \ for(int i = sb; i <= eb; i++) { \ @@ -26,7 +28,7 @@ } \ } -void PASOPIA_MEMORY::initialize() +void MEMORY::initialize() { // load ipl memset(rdmy, 0xff, sizeof(rdmy)); @@ -39,7 +41,7 @@ void PASOPIA_MEMORY::initialize() vram_data = mem_map = 0; } -void PASOPIA_MEMORY::load_ipl() +void MEMORY::load_ipl() { // load ipl memset(rom, 0xff, sizeof(rom)); @@ -76,24 +78,24 @@ void PASOPIA_MEMORY::load_ipl() } -void PASOPIA_MEMORY::reset() +void MEMORY::reset() { memset(vram, 0, sizeof(vram)); } -void PASOPIA_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { addr &= 0xffff; wbank[addr >> 12][addr & 0xfff] = data; } -uint32_t PASOPIA_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { addr &= 0xffff; return rbank[addr >> 12][addr & 0xfff]; } -void PASOPIA_MEMORY::write_io8(uint32_t addr, uint32_t data) +void MEMORY::write_io8(uint32_t addr, uint32_t data) { mem_map = data; @@ -109,7 +111,7 @@ void PASOPIA_MEMORY::write_io8(uint32_t addr, uint32_t data) d_pio2->write_signal(SIG_I8255_PORT_C, (mem_map & 2) ? 4 : 0, 4); } -void PASOPIA_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) +void MEMORY::write_signal(int id, uint32_t data, uint32_t mask) { // vram control if(id == SIG_MEMORY_I8255_0_A) { @@ -141,7 +143,7 @@ void PASOPIA_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) #define STATE_VERSION 1 -bool PASOPIA_MEMORY::process_state(FILEIO* state_fio, bool loading) +bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -166,3 +168,5 @@ bool PASOPIA_MEMORY::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/pasopia/memory.h b/source/src/vm/pasopia/memory.h index 610119d15..f27f8b3f9 100644 --- a/source/src/vm/pasopia/memory.h +++ b/source/src/vm/pasopia/memory.h @@ -18,7 +18,9 @@ #define SIG_MEMORY_I8255_0_B 1 #define SIG_MEMORY_I8255_1_C 2 -class PASOPIA_MEMORY : public DEVICE +namespace PASOPIA { + +class MEMORY : public DEVICE { private: DEVICE *d_pio0, *d_pio1, *d_pio2; @@ -35,11 +37,11 @@ private: uint8_t vram_data, mem_map; public: - PASOPIA_MEMORY(VM_TEMPLATE* 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")); } - ~PASOPIA_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -74,4 +76,5 @@ public: void load_ipl(); }; +} #endif diff --git a/source/src/vm/pasopia/pac2.cpp b/source/src/vm/pasopia/pac2.cpp index 10de0a455..41d94549b 100644 --- a/source/src/vm/pasopia/pac2.cpp +++ b/source/src/vm/pasopia/pac2.cpp @@ -13,6 +13,13 @@ #include "kanjipac2.h" #include "joypac2.h" +using PASOPIA::RAMPAC2; +using PASOPIA::KANJIPAC2; +using PASOPIA::JOYPAC2; +using PASOPIA::PAC2DEV; + +namespace PASOPIA { + void PAC2::initialize() { rampac2 = new RAMPAC2(static_cast(vm), emu); @@ -88,3 +95,5 @@ bool PAC2::process_state(FILEIO* state_fio, bool loading) state_fio->StateInt32(device_type); return get_device()->process_state(state_fio, loading); } + +} diff --git a/source/src/vm/pasopia/pac2.h b/source/src/vm/pasopia/pac2.h index c7e052dd6..80234d8f7 100644 --- a/source/src/vm/pasopia/pac2.h +++ b/source/src/vm/pasopia/pac2.h @@ -14,22 +14,26 @@ #include "../../emu.h" #include "../device.h" -class PAC2DEV; -class RAMPAC2; -class KANJIPAC2; -class JOYPAC2; +namespace PASOPIA { + class PAC2DEV; + class RAMPAC2; + class KANJIPAC2; + class JOYPAC2; +} + +namespace PASOPIA { class PAC2 : public DEVICE { private: int device_type; - RAMPAC2* rampac2; - KANJIPAC2* kanji; - JOYPAC2* joy; - PAC2DEV* dummy; + PASOPIA::RAMPAC2* rampac2; + PASOPIA::KANJIPAC2* kanji; + PASOPIA::JOYPAC2* joy; + PASOPIA::PAC2DEV* dummy; - PAC2DEV* get_device(); + PASOPIA::PAC2DEV* get_device(); public: PAC2(VM* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) @@ -50,5 +54,6 @@ public: void open_rampac2(const _TCHAR* file_path); }; +} #endif diff --git a/source/src/vm/pasopia/pac2dev.h b/source/src/vm/pasopia/pac2dev.h index a08f00aa8..df1caf5ae 100644 --- a/source/src/vm/pasopia/pac2dev.h +++ b/source/src/vm/pasopia/pac2dev.h @@ -14,13 +14,13 @@ #include "../vm.h" #include "../../emu.h" -class csp_state_utils; +namespace PASOPIA { + class PAC2DEV { protected: VM* vm; EMU* emu; - csp_state_utils *state_entry; public: PAC2DEV(VM* parent_vm, EMU* parent_emu) : vm(parent_vm), emu(parent_emu) @@ -59,5 +59,6 @@ public: _TCHAR this_device_name[128]; }; +} #endif diff --git a/source/src/vm/pasopia/pasopia.cpp b/source/src/vm/pasopia/pasopia.cpp index b3edcfb30..c2d93ce11 100644 --- a/source/src/vm/pasopia/pasopia.cpp +++ b/source/src/vm/pasopia/pasopia.cpp @@ -36,6 +36,13 @@ #include "./memory.h" #include "pac2.h" +using PASOPIA::DISPLAY; +using PASOPIA::FLOPPY; +using PASOPIA::KEYBOARD; +using PASOPIA::MEMORY; +using PASOPIA::PAC2; + + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -76,7 +83,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) floppy = new FLOPPY(this, emu); display = new DISPLAY(this, emu); key = new KEYBOARD(this, emu); - memory = new PASOPIA_MEMORY(this, emu); + memory = new MEMORY(this, emu); pac2 = new PAC2(this, emu); // set contexts event->set_context_cpu(cpu); diff --git a/source/src/vm/pasopia/pasopia.h b/source/src/vm/pasopia/pasopia.h index f31d6fa9d..4c6bda15f 100644 --- a/source/src/vm/pasopia/pasopia.h +++ b/source/src/vm/pasopia/pasopia.h @@ -83,7 +83,6 @@ static const _TCHAR *sound_device_caption[] = { }; #endif -class csp_state_utils; class EMU; class DEVICE; class EVENT; @@ -100,11 +99,13 @@ class Z80; class Z80CTC; class Z80PIO; -class FLOPPY; -class DISPLAY; -class KEYBOARD; -class PASOPIA_MEMORY; -class PAC2; +namespace PASOPIA { + class FLOPPY; + class DISPLAY; + class KEYBOARD; + class MEMORY; + class PAC2; +} class VM : public VM_TEMPLATE { @@ -129,11 +130,11 @@ protected: Z80CTC* ctc; Z80PIO* pio; - FLOPPY* floppy; - DISPLAY* display; - KEYBOARD* key; - PASOPIA_MEMORY* memory; - PAC2* pac2; + PASOPIA::FLOPPY* floppy; + PASOPIA::DISPLAY* display; + PASOPIA::KEYBOARD* key; + PASOPIA::MEMORY* memory; + PASOPIA::PAC2* pac2; int boot_mode; diff --git a/source/src/vm/pasopia/rampac2.cpp b/source/src/vm/pasopia/rampac2.cpp index f09139073..9b0d6563b 100644 --- a/source/src/vm/pasopia/rampac2.cpp +++ b/source/src/vm/pasopia/rampac2.cpp @@ -10,6 +10,8 @@ #include "rampac2.h" +namespace PASOPIA { + static const uint8_t header[16] = { 0xaa, 0x1f, 0x04, 0x00, 0x04, 0x80, 0x00, 0x01, 0x04, 0x04, 0x01, 0x03, 0x08, 0x00, 0x00, 0x00 }; @@ -107,3 +109,5 @@ bool RAMPAC2::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(modified); return true; } + +} diff --git a/source/src/vm/pasopia/rampac2.h b/source/src/vm/pasopia/rampac2.h index d26ed7e1d..b9f0d8ffa 100644 --- a/source/src/vm/pasopia/rampac2.h +++ b/source/src/vm/pasopia/rampac2.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "pac2dev.h" +namespace PASOPIA { + class RAMPAC2 : public PAC2DEV { private: @@ -40,5 +42,6 @@ public: bool process_state(FILEIO* state_fio, bool loading); }; +} #endif diff --git a/source/src/vm/pasopia7/display.cpp b/source/src/vm/pasopia7/display.cpp index 5889a5d81..f0244b55d 100644 --- a/source/src/vm/pasopia7/display.cpp +++ b/source/src/vm/pasopia7/display.cpp @@ -9,6 +9,8 @@ #include "display.h" +namespace PASOPIA7 { + void DISPLAY::initialize() { // load rom image @@ -774,3 +776,5 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(pal_dis); return true; } + +} diff --git a/source/src/vm/pasopia7/display.h b/source/src/vm/pasopia7/display.h index a6662695a..b07b06219 100644 --- a/source/src/vm/pasopia7/display.h +++ b/source/src/vm/pasopia7/display.h @@ -18,6 +18,8 @@ #define SIG_DISPLAY_I8255_1_B 1 #define SIG_DISPLAY_I8255_1_C 2 +namespace PASOPIA7 { + class DISPLAY : public DEVICE { private: @@ -74,5 +76,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/pasopia7/floppy.cpp b/source/src/vm/pasopia7/floppy.cpp index 28fdf6f0b..97bb94505 100644 --- a/source/src/vm/pasopia7/floppy.cpp +++ b/source/src/vm/pasopia7/floppy.cpp @@ -10,6 +10,8 @@ #include "floppy.h" #include "../upd765a.h" +namespace PASOPIA7 { + void FLOPPY::initialize() { intr = false; @@ -67,3 +69,5 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(intr); return true; } + +} diff --git a/source/src/vm/pasopia7/floppy.h b/source/src/vm/pasopia7/floppy.h index 7e2ffbd24..db60495a7 100644 --- a/source/src/vm/pasopia7/floppy.h +++ b/source/src/vm/pasopia7/floppy.h @@ -16,6 +16,8 @@ #define SIG_FLOPPY_INTR 0 +namespace PASOPIA7 { + class FLOPPY : public DEVICE { private: @@ -43,5 +45,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pasopia7/iobus.cpp b/source/src/vm/pasopia7/iobus.cpp index 7a6e203e8..18c9086be 100644 --- a/source/src/vm/pasopia7/iobus.cpp +++ b/source/src/vm/pasopia7/iobus.cpp @@ -9,6 +9,8 @@ #include "iobus.h" +namespace PASOPIA7 { + void IOBUS::reset() { mio = false; @@ -54,3 +56,5 @@ bool IOBUS::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(mio); return true; } + +} diff --git a/source/src/vm/pasopia7/iobus.h b/source/src/vm/pasopia7/iobus.h index ac8fd9729..7bb602fde 100644 --- a/source/src/vm/pasopia7/iobus.h +++ b/source/src/vm/pasopia7/iobus.h @@ -16,6 +16,8 @@ #define SIG_IOBUS_MIO 0 +namespace PASOPIA7 { + class IOBUS : public DEVICE { private: @@ -48,5 +50,7 @@ public: } }; +} + #endif diff --git a/source/src/vm/pasopia7/iotrap.cpp b/source/src/vm/pasopia7/iotrap.cpp index 38c870f31..33f0ef691 100644 --- a/source/src/vm/pasopia7/iotrap.cpp +++ b/source/src/vm/pasopia7/iotrap.cpp @@ -10,6 +10,8 @@ #include "iotrap.h" #include "../i8255.h" +namespace PASOPIA7 { + void IOTRAP::initialize() { nmi_mask = pasopia = false; @@ -91,3 +93,5 @@ bool IOTRAP::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(pasopia); return true; } + +} diff --git a/source/src/vm/pasopia7/iotrap.h b/source/src/vm/pasopia7/iotrap.h index d927494e7..d59f06928 100644 --- a/source/src/vm/pasopia7/iotrap.h +++ b/source/src/vm/pasopia7/iotrap.h @@ -17,6 +17,8 @@ #define SIG_IOTRAP_I8255_2_A 0 #define SIG_IOTRAP_I8255_2_C 1 +namespace PASOPIA7 { + class IOTRAP : public DEVICE { private: @@ -49,5 +51,6 @@ public: void do_reset(); }; +} #endif diff --git a/source/src/vm/pasopia7/joypac2.cpp b/source/src/vm/pasopia7/joypac2.cpp index 65ee64b1d..db21b2b6a 100644 --- a/source/src/vm/pasopia7/joypac2.cpp +++ b/source/src/vm/pasopia7/joypac2.cpp @@ -10,6 +10,8 @@ #include "joypac2.h" +namespace PASOPIA7 { + void JOYPAC2::initialize(int id) { joy = emu->get_joy_buffer(); @@ -45,3 +47,4 @@ uint32_t JOYPAC2::read_io8(uint32_t addr) return 0xff; } +} diff --git a/source/src/vm/pasopia7/joypac2.h b/source/src/vm/pasopia7/joypac2.h index f2052d5b0..75b01fad1 100644 --- a/source/src/vm/pasopia7/joypac2.h +++ b/source/src/vm/pasopia7/joypac2.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "pac2dev.h" +namespace PASOPIA7 { + class JOYPAC2 : public PAC2DEV { private: @@ -32,5 +34,6 @@ public: uint32_t read_io8(uint32_t addr); }; +} #endif diff --git a/source/src/vm/pasopia7/kanjipac2.cpp b/source/src/vm/pasopia7/kanjipac2.cpp index 3d6ea5dc8..a8e1dac0e 100644 --- a/source/src/vm/pasopia7/kanjipac2.cpp +++ b/source/src/vm/pasopia7/kanjipac2.cpp @@ -10,6 +10,8 @@ #include "kanjipac2.h" +namespace PASOPIA7 { + void KANJIPAC2::initialize(int id) { FILEIO* fio = new FILEIO(); @@ -55,3 +57,5 @@ bool KANJIPAC2::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint32(ptr); return true; } + +} diff --git a/source/src/vm/pasopia7/kanjipac2.h b/source/src/vm/pasopia7/kanjipac2.h index 95a9d6ca3..b6c5c4d70 100644 --- a/source/src/vm/pasopia7/kanjipac2.h +++ b/source/src/vm/pasopia7/kanjipac2.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "pac2dev.h" +namespace PASOPIA7 { + class KANJIPAC2 : public PAC2DEV { private: @@ -35,5 +37,6 @@ public: bool process_state(FILEIO* state_fio, bool loading); }; +} #endif diff --git a/source/src/vm/pasopia7/keyboard.cpp b/source/src/vm/pasopia7/keyboard.cpp index 9e3723254..a647ff71f 100644 --- a/source/src/vm/pasopia7/keyboard.cpp +++ b/source/src/vm/pasopia7/keyboard.cpp @@ -10,6 +10,8 @@ #include "keyboard.h" #include "../z80pio.h" +namespace PASOPIA7 { + static const int key_map[12][8] = { { 0x12, 0x10, 0x14, 0x00, 0x11, 0x15, 0x00, 0x00 }, { 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67 }, @@ -90,3 +92,5 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(sel); return true; } + +} diff --git a/source/src/vm/pasopia7/keyboard.h b/source/src/vm/pasopia7/keyboard.h index 9c5ab3055..488cffdf8 100644 --- a/source/src/vm/pasopia7/keyboard.h +++ b/source/src/vm/pasopia7/keyboard.h @@ -16,6 +16,8 @@ #define SIG_KEYBOARD_Z80PIO_A 0 +namespace PASOPIA7 { + class KEYBOARD : public DEVICE { private: @@ -45,5 +47,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pasopia7/memory.cpp b/source/src/vm/pasopia7/memory.cpp index 312dc7544..f54e8f1a8 100644 --- a/source/src/vm/pasopia7/memory.cpp +++ b/source/src/vm/pasopia7/memory.cpp @@ -11,6 +11,8 @@ #include "iobus.h" #include "../i8255.h" +namespace PASOPIA7 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 12, eb = (e) >> 12; \ for(int i = sb; i <= eb; i++) { \ @@ -27,7 +29,7 @@ } \ } -void PASOPIA7_MEMORY::initialize() +void MEMORY::initialize() { memset(bios, 0xff, sizeof(bios)); memset(basic, 0xff, sizeof(basic)); @@ -52,12 +54,12 @@ void PASOPIA7_MEMORY::initialize() vram_sel = pal_sel = attr_wrap = false; } -void PASOPIA7_MEMORY::reset() +void MEMORY::reset() { memset(vram, 0, sizeof(vram)); } -void PASOPIA7_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { addr &= 0xffff; if(vram_sel && (addr & 0xc000) == 0x8000) { @@ -84,7 +86,7 @@ void PASOPIA7_MEMORY::write_data8(uint32_t addr, uint32_t data) wbank[addr >> 12][addr & 0xfff] = data; } -uint32_t PASOPIA7_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { addr &= 0xffff; if(vram_sel && (addr & 0xc000) == 0x8000) { @@ -109,7 +111,7 @@ uint32_t PASOPIA7_MEMORY::read_data8(uint32_t addr) return rbank[addr >> 12][addr & 0xfff]; } -void PASOPIA7_MEMORY::write_io8(uint32_t addr, uint32_t data) +void MEMORY::write_io8(uint32_t addr, uint32_t data) { if(mem_map != (data & 7)) { mem_map = data & 7; @@ -124,7 +126,7 @@ void PASOPIA7_MEMORY::write_io8(uint32_t addr, uint32_t data) d_pio2->write_signal(SIG_I8255_PORT_C, data, 3); } -void PASOPIA7_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) +void MEMORY::write_signal(int id, uint32_t data, uint32_t mask) { if(id == SIG_MEMORY_I8255_1_A) { plane = data; @@ -136,7 +138,7 @@ void PASOPIA7_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) } } -void PASOPIA7_MEMORY::update_memory_map() +void MEMORY::update_memory_map() { if(mem_map == 0xff) { SET_BANK(0x0000, 0x3fff, wdmy, bios); @@ -167,7 +169,7 @@ void PASOPIA7_MEMORY::update_memory_map() #define STATE_VERSION 1 -bool PASOPIA7_MEMORY::process_state(FILEIO* state_fio, bool loading) +bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -192,3 +194,5 @@ bool PASOPIA7_MEMORY::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/pasopia7/memory.h b/source/src/vm/pasopia7/memory.h index 04d3bf8f0..aa582fe5d 100644 --- a/source/src/vm/pasopia7/memory.h +++ b/source/src/vm/pasopia7/memory.h @@ -18,7 +18,9 @@ #define SIG_MEMORY_I8255_1_B 1 #define SIG_MEMORY_I8255_1_C 2 -class PASOPIA7_MEMORY : public DEVICE +namespace PASOPIA7 { + +class MEMORY : public DEVICE { private: DEVICE *d_iobus, *d_pio0, *d_pio2; @@ -39,11 +41,11 @@ private: void update_memory_map(); public: - PASOPIA7_MEMORY(VM_TEMPLATE* 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")); } - ~PASOPIA7_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -81,5 +83,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pasopia7/pac2.cpp b/source/src/vm/pasopia7/pac2.cpp index 0400d9575..5ea1c73e8 100644 --- a/source/src/vm/pasopia7/pac2.cpp +++ b/source/src/vm/pasopia7/pac2.cpp @@ -13,6 +13,13 @@ #include "kanjipac2.h" #include "joypac2.h" +using PASOPIA7::PAC2DEV; +using PASOPIA7::RAMPAC2; +using PASOPIA7::KANJIPAC2; +using PASOPIA7::JOYPAC2; + +namespace PASOPIA7 { + void PAC2::initialize() { // slot 4 : ram pack #5 @@ -110,3 +117,5 @@ bool PAC2::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/pasopia7/pac2.h b/source/src/vm/pasopia7/pac2.h index d300ea2a1..0411bab2d 100644 --- a/source/src/vm/pasopia7/pac2.h +++ b/source/src/vm/pasopia7/pac2.h @@ -14,10 +14,14 @@ #include "../../emu.h" #include "../device.h" -class PAC2DEV; -class RAMPAC2; -class KANJIPAC2; -class JOYPAC2; +namespace PASOPIA7 { + class PAC2DEV; + class RAMPAC2; + class KANJIPAC2; + class JOYPAC2; +} + +namespace PASOPIA7 { class PAC2 : public DEVICE { @@ -25,10 +29,10 @@ private: PAC2DEV* dev[8]; int sel; - RAMPAC2* rampac2[2]; - KANJIPAC2* kanji; - JOYPAC2* joy; - PAC2DEV* dummy; + PASOPIA7::RAMPAC2* rampac2[2]; + PASOPIA7::KANJIPAC2* kanji; + PASOPIA7::JOYPAC2* joy; + PASOPIA7::PAC2DEV* dummy; public: PAC2(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) @@ -49,5 +53,6 @@ public: void open_rampac2(int drv, const _TCHAR* file_path); }; +} #endif diff --git a/source/src/vm/pasopia7/pac2dev.h b/source/src/vm/pasopia7/pac2dev.h index a0fb49ee9..f26f09c13 100644 --- a/source/src/vm/pasopia7/pac2dev.h +++ b/source/src/vm/pasopia7/pac2dev.h @@ -14,13 +14,13 @@ #include "../vm.h" #include "../../emu.h" -class csp_state_utils; +namespace PASOPIA7 { + class PAC2DEV { protected: VM* vm; EMU* emu; - csp_state_utils *state_entry; public: PAC2DEV(VM* parent_vm, EMU* parent_emu) : vm(parent_vm), emu(parent_emu) { @@ -58,5 +58,6 @@ public: _TCHAR this_device_name[128]; }; +} #endif diff --git a/source/src/vm/pasopia7/pasopia7.cpp b/source/src/vm/pasopia7/pasopia7.cpp index a2c988dae..e5cdb5c57 100644 --- a/source/src/vm/pasopia7/pasopia7.cpp +++ b/source/src/vm/pasopia7/pasopia7.cpp @@ -39,6 +39,14 @@ #include "./memory.h" #include "pac2.h" +using PASOPIA7::DISPLAY; +using PASOPIA7::FLOPPY; +using PASOPIA7::IOBUS; +using PASOPIA7::IOTRAP; +using PASOPIA7::KEYBOARD; +using PASOPIA7::MEMORY; +using PASOPIA7::PAC2; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -82,7 +90,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) iobus = new IOBUS(this, emu); iotrap = new IOTRAP(this, emu); key = new KEYBOARD(this, emu); - memory = new PASOPIA7_MEMORY(this, emu); + memory = new MEMORY(this, emu); pac2 = new PAC2(this, emu); // set contexts diff --git a/source/src/vm/pasopia7/pasopia7.h b/source/src/vm/pasopia7/pasopia7.h index ac289623a..6f3e25ada 100644 --- a/source/src/vm/pasopia7/pasopia7.h +++ b/source/src/vm/pasopia7/pasopia7.h @@ -89,13 +89,15 @@ class Z80; class Z80CTC; class Z80PIO; -class FLOPPY; -class DISPLAY; -class IOBUS; -class IOTRAP; -class KEYBOARD; -class PASOPIA7_MEMORY; -class PAC2; +namespace PASOPIA7 { + class FLOPPY; + class DISPLAY; + class IOBUS; + class IOTRAP; + class KEYBOARD; + class MEMORY; + class PAC2; +} class VM : public VM_TEMPLATE { @@ -122,13 +124,13 @@ protected: Z80CTC* ctc; Z80PIO* pio; - FLOPPY* floppy; - DISPLAY* display; - IOBUS* iobus; - IOTRAP* iotrap; - KEYBOARD* key; - PASOPIA7_MEMORY* memory; - PAC2* pac2; + PASOPIA7::FLOPPY* floppy; + PASOPIA7::DISPLAY* display; + PASOPIA7::IOBUS* iobus; + PASOPIA7::IOTRAP* iotrap; + PASOPIA7::KEYBOARD* key; + PASOPIA7::MEMORY* memory; + PASOPIA7::PAC2* pac2; public: // ---------------------------------------- diff --git a/source/src/vm/pasopia7/rampac2.cpp b/source/src/vm/pasopia7/rampac2.cpp index f09139073..c2109d3cc 100644 --- a/source/src/vm/pasopia7/rampac2.cpp +++ b/source/src/vm/pasopia7/rampac2.cpp @@ -10,6 +10,8 @@ #include "rampac2.h" +namespace PASOPIA7 { + static const uint8_t header[16] = { 0xaa, 0x1f, 0x04, 0x00, 0x04, 0x80, 0x00, 0x01, 0x04, 0x04, 0x01, 0x03, 0x08, 0x00, 0x00, 0x00 }; @@ -107,3 +109,5 @@ bool RAMPAC2::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(modified); return true; } + +} diff --git a/source/src/vm/pasopia7/rampac2.h b/source/src/vm/pasopia7/rampac2.h index d7a30ba64..0923ce0bb 100644 --- a/source/src/vm/pasopia7/rampac2.h +++ b/source/src/vm/pasopia7/rampac2.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "pac2dev.h" +namespace PASOPIA7 { + class RAMPAC2 : public PAC2DEV { private: @@ -42,5 +44,6 @@ public: bool process_state(FILEIO* state_fio, bool loading); }; +} #endif diff --git a/source/src/vm/pc100/crtc.cpp b/source/src/vm/pc100/crtc.cpp index ecf3eb015..ff121fd3c 100644 --- a/source/src/vm/pc100/crtc.cpp +++ b/source/src/vm/pc100/crtc.cpp @@ -10,6 +10,8 @@ #include "crtc.h" #include "../i8259.h" +namespace PC100 { + void CRTC::initialize() { // init vram @@ -354,3 +356,5 @@ bool CRTC::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint32(read_plane); return true; } + +} diff --git a/source/src/vm/pc100/crtc.h b/source/src/vm/pc100/crtc.h index 5e49d7687..e26bf6058 100644 --- a/source/src/vm/pc100/crtc.h +++ b/source/src/vm/pc100/crtc.h @@ -18,6 +18,8 @@ #define SIG_CRTC_BITMASK_HIGH 1 #define SIG_CRTC_VRAM_PLANE 2 +namespace PC100 { + class CRTC : public DEVICE { private: @@ -61,5 +63,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/pc100/ioctrl.cpp b/source/src/vm/pc100/ioctrl.cpp index df8204f1b..7e2bac689 100644 --- a/source/src/vm/pc100/ioctrl.cpp +++ b/source/src/vm/pc100/ioctrl.cpp @@ -14,6 +14,8 @@ #include "../upd765a.h" #include "../../fifo.h" +namespace PC100 { + static const int key_table[256] = { -1, -1, -1, -1, -1, -1, -1, -1,0x18,0x12, -1, -1, -1,0x38, -1, -1, -1,0x04,0x05,0x09, -1, -1, -1, -1, -1,0x10, -1,0x11, -1, -1, -1, -1, @@ -241,3 +243,5 @@ bool IOCTRL::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(ts); return true; } + +} diff --git a/source/src/vm/pc100/ioctrl.h b/source/src/vm/pc100/ioctrl.h index 9dfa96fa2..eb09f68d1 100644 --- a/source/src/vm/pc100/ioctrl.h +++ b/source/src/vm/pc100/ioctrl.h @@ -18,6 +18,8 @@ class FIFO; +namespace PC100 { + class IOCTRL : public DEVICE { private: @@ -81,5 +83,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc100/kanji.cpp b/source/src/vm/pc100/kanji.cpp index 2139a11e5..ef3cf25f1 100644 --- a/source/src/vm/pc100/kanji.cpp +++ b/source/src/vm/pc100/kanji.cpp @@ -9,6 +9,8 @@ #include "kanji.h" +namespace PC100 { + void KANJI::initialize() { // init image @@ -69,3 +71,5 @@ bool KANJI::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(strobe); return true; } + +} diff --git a/source/src/vm/pc100/kanji.h b/source/src/vm/pc100/kanji.h index 57eddea76..94aaa6136 100644 --- a/source/src/vm/pc100/kanji.h +++ b/source/src/vm/pc100/kanji.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace PC100 { + class KANJI : public DEVICE { private: @@ -35,5 +37,6 @@ public: bool process_state(FILEIO* state_fio, bool loading); }; +} #endif diff --git a/source/src/vm/pc100/pc100.cpp b/source/src/vm/pc100/pc100.cpp index 8b63c15c8..d65915480 100644 --- a/source/src/vm/pc100/pc100.cpp +++ b/source/src/vm/pc100/pc100.cpp @@ -34,6 +34,10 @@ #include "ioctrl.h" #include "kanji.h" +using PC100::CRTC; +using PC100::IOCTRL; +using PC100::KANJI; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- diff --git a/source/src/vm/pc100/pc100.h b/source/src/vm/pc100/pc100.h index 08dba065e..4fc85e9b7 100644 --- a/source/src/vm/pc100/pc100.h +++ b/source/src/vm/pc100/pc100.h @@ -76,9 +76,11 @@ class MSM58321; class PCM1BIT; class UPD765A; -class CRTC; -class IOCTRL; -class KANJI; +namespace PC100 { + class CRTC; + class IOCTRL; + class KANJI; +} class VM : public VM_TEMPLATE { @@ -102,9 +104,9 @@ protected: PCM1BIT* pcm; UPD765A* fdc; - CRTC* crtc; - IOCTRL* ioctrl; - KANJI* kanji; + PC100::CRTC* crtc; + PC100::IOCTRL* ioctrl; + PC100::KANJI* kanji; // memory uint8_t ram[0xc0000]; // Main RAM 768KB diff --git a/source/src/vm/pc2001/io.cpp b/source/src/vm/pc2001/io.cpp index 0cd908843..383b4a89d 100644 --- a/source/src/vm/pc2001/io.cpp +++ b/source/src/vm/pc2001/io.cpp @@ -17,20 +17,22 @@ #define EVENT_TIMER 0 -void PC2001_IO::initialize() +namespace PC2001 { + +void IO::initialize() { register_event(this, EVENT_TIMER, 20000, true, NULL); key_stat = emu->get_key_buffer(); } -void PC2001_IO::reset() +void IO::reset() { port_a = port_b = port_s = 0xff; drec_in = rtc_in = false; key_strobe = 0xffff; } -void PC2001_IO::write_io8(uint32_t addr, uint32_t data) +void IO::write_io8(uint32_t addr, uint32_t data) { switch(addr) { case UPD7807_PORTA: @@ -81,7 +83,7 @@ void PC2001_IO::write_io8(uint32_t addr, uint32_t data) } } -uint32_t PC2001_IO::read_io8(uint32_t addr) +uint32_t IO::read_io8(uint32_t addr) { uint32_t value = 0xff; @@ -110,7 +112,7 @@ uint32_t PC2001_IO::read_io8(uint32_t addr) return value; } -void PC2001_IO::write_io16(uint32_t addr, uint32_t data) +void IO::write_io16(uint32_t addr, uint32_t data) { switch(addr) { case UPD7807_PORTE: @@ -122,7 +124,7 @@ void PC2001_IO::write_io16(uint32_t addr, uint32_t data) } } -void PC2001_IO::write_signal(int id, uint32_t data, uint32_t mask) +void IO::write_signal(int id, uint32_t data, uint32_t mask) { switch(id) { case SIG_IO_DREC_IN: @@ -135,14 +137,14 @@ void PC2001_IO::write_signal(int id, uint32_t data, uint32_t mask) } } -void PC2001_IO::event_callback(int event_id, int err) +void IO::event_callback(int event_id, int err) { if(event_id == EVENT_TIMER) { d_cpu->write_signal(SIG_UPD7810_INTF1, 1, 1); } } -uint8_t PC2001_IO::get_key() +uint8_t IO::get_key() { uint8_t data = 0x3f; @@ -267,7 +269,7 @@ uint8_t PC2001_IO::get_key() return data; } -bool PC2001_IO::key_hit(int code) +bool IO::key_hit(int code) { bool value = (key_stat[code] != 0); return value; @@ -275,7 +277,7 @@ bool PC2001_IO::key_hit(int code) #define STATE_VERSION 2 -bool PC2001_IO::process_state(FILEIO* state_fio, bool loading) +bool IO::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -291,3 +293,5 @@ bool PC2001_IO::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint16(key_strobe); return true; } + +} diff --git a/source/src/vm/pc2001/io.h b/source/src/vm/pc2001/io.h index 11b4ff764..674c19afd 100644 --- a/source/src/vm/pc2001/io.h +++ b/source/src/vm/pc2001/io.h @@ -20,7 +20,9 @@ class UPD16434; -class PC2001_IO : public DEVICE +namespace PC2001 { + +class IO : public DEVICE { private: UPD16434 *d_lcd[4]; @@ -38,11 +40,11 @@ private: bool key_hit(int code); public: - PC2001_IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) + IO(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("I/O Bus")); } - ~PC2001_IO() {} + ~IO() {} // common functions void initialize(); @@ -73,4 +75,5 @@ public: } }; +} #endif diff --git a/source/src/vm/pc2001/pc2001.cpp b/source/src/vm/pc2001/pc2001.cpp index a2c5b5575..b6a17534f 100644 --- a/source/src/vm/pc2001/pc2001.cpp +++ b/source/src/vm/pc2001/pc2001.cpp @@ -27,6 +27,8 @@ #include "./io.h" +using PC2001::IO; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -55,7 +57,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) rtc = new UPD1990A(this, emu); cpu = new UPD7810(this, emu); - io = new PC2001_IO(this, emu); + io = new PC2001::IO(this, emu); // set contexts event->set_context_cpu(cpu); diff --git a/source/src/vm/pc2001/pc2001.h b/source/src/vm/pc2001/pc2001.h index 1dee026e9..2b148f0e5 100644 --- a/source/src/vm/pc2001/pc2001.h +++ b/source/src/vm/pc2001/pc2001.h @@ -61,7 +61,9 @@ class UPD16434; class UPD1990A; class UPD7810; -class PC2001_IO; +namespace PC2001 { + class IO; +} class VM : public VM_TEMPLATE { protected: @@ -78,7 +80,7 @@ protected: UPD1990A* rtc; UPD7810* cpu; - PC2001_IO* io; + PC2001::IO* io; // memory uint8_t ram[0x5000]; diff --git a/source/src/vm/pc6001/display.cpp b/source/src/vm/pc6001/display.cpp index 4b71ce7ca..1dfac9258 100644 --- a/source/src/vm/pc6001/display.cpp +++ b/source/src/vm/pc6001/display.cpp @@ -11,6 +11,8 @@ #include "timer.h" #include "../mc6847.h" +namespace PC6001 { + void DISPLAY::reset() { vram_ptr = ram_ptr + 0xe000; @@ -61,3 +63,5 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/pc6001/display.h b/source/src/vm/pc6001/display.h index 0110dac2d..c29bd7a1c 100644 --- a/source/src/vm/pc6001/display.h +++ b/source/src/vm/pc6001/display.h @@ -15,13 +15,17 @@ #include "../device.h" class MC6847; -class TIMER; + +namespace PC6001 { + class TIMER; +} +namespace PC6001 { class DISPLAY : public DEVICE { private: MC6847 *d_vdp; - TIMER *d_timer; + PC6001::TIMER *d_timer; uint8_t *ram_ptr; uint8_t *vram_ptr; @@ -48,10 +52,12 @@ public: { ram_ptr = vram_ptr = ptr; } - void set_context_timer(TIMER* device) + void set_context_timer(PC6001::TIMER* device) { d_timer = device; } void draw_screen(); }; + +} #endif diff --git a/source/src/vm/pc6001/floppy.cpp b/source/src/vm/pc6001/floppy.cpp index 033687d0e..d373294d4 100644 --- a/source/src/vm/pc6001/floppy.cpp +++ b/source/src/vm/pc6001/floppy.cpp @@ -19,6 +19,8 @@ #include "../disk.h" #include "../noise.h" +namespace PC6001 { + int FLOPPY::Seek88(int drvno, int trackno, int sectno) { if(drvno < 2) { @@ -652,3 +654,5 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(Status); return true; } + +} diff --git a/source/src/vm/pc6001/floppy.h b/source/src/vm/pc6001/floppy.h index e2c3d8c9c..9f7467a5f 100644 --- a/source/src/vm/pc6001/floppy.h +++ b/source/src/vm/pc6001/floppy.h @@ -25,6 +25,8 @@ class DISK; class NOISE; +namespace PC6001 { + class FLOPPY : public DEVICE { private: @@ -160,5 +162,6 @@ public: bool is_disk_protected(int drv); }; +} #endif diff --git a/source/src/vm/pc6001/joystick.cpp b/source/src/vm/pc6001/joystick.cpp index 110218593..a8a7622eb 100644 --- a/source/src/vm/pc6001/joystick.cpp +++ b/source/src/vm/pc6001/joystick.cpp @@ -18,6 +18,8 @@ #include "../ay_3_891x.h" #endif +namespace PC6001 { + void JOYSTICK::initialize() { joy_stat = emu->get_joy_buffer(); @@ -36,3 +38,5 @@ void JOYSTICK::event_frame() d_psg->write_signal(SIG_AY_3_891X_PORT_B, ~(joy_stat[1] & 0x1f), 0xff); #endif } + +} diff --git a/source/src/vm/pc6001/joystick.h b/source/src/vm/pc6001/joystick.h index 35a83c9c9..d7704d4b9 100644 --- a/source/src/vm/pc6001/joystick.h +++ b/source/src/vm/pc6001/joystick.h @@ -18,6 +18,8 @@ #include "../../emu.h" #include "../device.h" +namespace PC6001 { + class JOYSTICK : public DEVICE { private: @@ -41,4 +43,6 @@ public: d_psg = device; } }; + +} #endif diff --git a/source/src/vm/pc6001/memory.cpp b/source/src/vm/pc6001/memory.cpp index d69686886..2362b18ec 100644 --- a/source/src/vm/pc6001/memory.cpp +++ b/source/src/vm/pc6001/memory.cpp @@ -39,7 +39,9 @@ #define SYSTEMROM2 (MEMORY_BASE + SYSTEMROM2_BASE) #define CGROM6 (MEMORY_BASE + CGROM6_BASE) -void PC6001_MEMORY::initialize() +namespace PC6001 { + +void MEMORY::initialize() { FILEIO* fio = new FILEIO(); #if defined(_PC6001) @@ -167,7 +169,7 @@ void PC6001_MEMORY::initialize() #endif } -void PC6001_MEMORY::reset() +void MEMORY::reset() { #ifdef _PC6001 int J; @@ -256,7 +258,7 @@ void PC6001_MEMORY::reset() #endif } -void PC6001_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { #if defined(_PC6601SR) || defined(_PC6001MK2SR) /* Graphics Vram Write (SR basic) */ @@ -269,7 +271,7 @@ void PC6001_MEMORY::write_data8(uint32_t addr, uint32_t data) WrMem[addr >> 13][addr & 0x1FFF] = data; } -uint32_t PC6001_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { #if defined(_PC6601SR) || defined(_PC6001MK2SR) /* Graphics Vram Read (SR basic) */ @@ -279,7 +281,7 @@ uint32_t PC6001_MEMORY::read_data8(uint32_t addr) return(RdMem[addr >> 13][addr & 0x1FFF]); } -void PC6001_MEMORY::write_io8(uint32_t addr, uint32_t data) +void MEMORY::write_io8(uint32_t addr, uint32_t data) { unsigned int VRAMHead[2][4] = { { 0xc000, 0xe000, 0x8000, 0xa000 }, @@ -581,7 +583,7 @@ void PC6001_MEMORY::write_io8(uint32_t addr, uint32_t data) } #ifndef _PC6001 -uint32_t PC6001_MEMORY::read_io8(uint32_t addr) +uint32_t MEMORY::read_io8(uint32_t addr) { uint16_t port=(addr & 0x00ff); uint8_t Value=0xff; @@ -604,7 +606,7 @@ uint32_t PC6001_MEMORY::read_io8(uint32_t addr) #define EVENT_HBLANK 1 -void PC6001_MEMORY::event_vline(int v, int clock) +void MEMORY::event_vline(int v, int clock) { #if defined(_PC6601SR) || defined(_PC6001MK2SR) if(static_cast(vm)->sr_mode) { @@ -626,7 +628,7 @@ void PC6001_MEMORY::event_vline(int v, int clock) } } -void PC6001_MEMORY::event_callback(int event_id, int err) +void MEMORY::event_callback(int event_id, int err) { if(event_id == EVENT_HBLANK) { d_cpu->write_signal(SIG_CPU_BUSREQ, 0, 0); @@ -634,7 +636,7 @@ void PC6001_MEMORY::event_callback(int event_id, int err) } #endif -void PC6001_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) +void MEMORY::write_signal(int id, uint32_t data, uint32_t mask) { if(id == SIG_MEMORY_PIO_PORT_C) { #ifdef _PC6001 @@ -654,7 +656,7 @@ void PC6001_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) } } -void PC6001_MEMORY::open_cart(const _TCHAR* file_path) +void MEMORY::open_cart(const _TCHAR* file_path) { FILEIO* fio = new FILEIO(); if(fio->Fopen(file_path, FILEIO_READ_BINARY)) { @@ -674,7 +676,7 @@ void PC6001_MEMORY::open_cart(const _TCHAR* file_path) delete fio; } -void PC6001_MEMORY::close_cart() +void MEMORY::close_cart() { /// EXTROM1 = EXTROM2 = EmptyRAM; EXTROM1 = RAM + 0x4000; @@ -685,7 +687,7 @@ void PC6001_MEMORY::close_cart() #define STATE_VERSION 1 -bool PC6001_MEMORY::process_state(FILEIO* state_fio, bool loading) +bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -757,3 +759,5 @@ bool PC6001_MEMORY::process_state(FILEIO* state_fio, bool loading) #endif return true; } + +} diff --git a/source/src/vm/pc6001/memory.h b/source/src/vm/pc6001/memory.h index 5b6982702..ab95f0270 100644 --- a/source/src/vm/pc6001/memory.h +++ b/source/src/vm/pc6001/memory.h @@ -27,7 +27,9 @@ #define SIG_MEMORY_PIO_PORT_C 0 #ifndef _PC6001 -class TIMER; +namespace PC6001 { + class TIMER; +} #endif // memory offset @@ -65,12 +67,14 @@ class TIMER; #define MEMORY_SIZE (CGROM6_BASE + CGROM6_SIZE) #endif -class PC6001_MEMORY : public DEVICE +namespace PC6001 { + +class MEMORY : public DEVICE { private: DEVICE *d_cpu; #ifndef _PC6001 - TIMER *d_timer; + PC6001::TIMER *d_timer; #endif uint8_t MEMORY_BASE[MEMORY_SIZE]; // uint8_t RAM[0x10000]; @@ -165,12 +169,12 @@ private: #endif public: - PC6001_MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) + MEMORY(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) { inserted = false; set_device_name(_T("Memory Bus")); } - ~PC6001_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -195,7 +199,7 @@ public: d_cpu = device; } #ifndef _PC6001 - void set_context_timer(TIMER* device) + void set_context_timer(PC6001::TIMER* device) { d_timer = device; } @@ -217,4 +221,6 @@ public: } #endif }; + +} #endif diff --git a/source/src/vm/pc6001/memory_draw.cpp b/source/src/vm/pc6001/memory_draw.cpp index db21fe555..455325e74 100644 --- a/source/src/vm/pc6001/memory_draw.cpp +++ b/source/src/vm/pc6001/memory_draw.cpp @@ -35,7 +35,9 @@ #define SeqPix21(c) dest[X*8+W]=c;W++; #define SeqPix41(c) dest[X*8+W]=c;W++;dest[X*8+W]=c;W++; -void PC6001_MEMORY::draw_screen() +namespace PC6001 { + +void MEMORY::draw_screen() { if (CRTKILL) { for(int y = 0; y < 400; y++) { @@ -137,7 +139,7 @@ void PC6001_MEMORY::draw_screen() } // RefreshScr10: N60-BASIC select function -void PC6001_MEMORY::RefreshScr10() +void MEMORY::RefreshScr10() { if ((*VRAM&0x80) == 0x00) RefreshScr11(); @@ -159,7 +161,7 @@ void PC6001_MEMORY::RefreshScr10() } // RefreshScr11: N60-BASIC screen 1,2 -void PC6001_MEMORY::RefreshScr11() +void MEMORY::RefreshScr11() { uint8_t X,Y,K; int FC,BC; @@ -197,7 +199,7 @@ W=0; } // RefreshScr13: N60-BASIC screen 3,4 -void PC6001_MEMORY::RefreshScr13() +void MEMORY::RefreshScr13() { uint8_t X,Y; uint8_t *T1,*T2; @@ -233,7 +235,7 @@ W=0; } // RefreshScr13a: N60-BASIC screen 3,4 -void PC6001_MEMORY::RefreshScr13a() /* 64x 64 color / 128x 64 */ +void MEMORY::RefreshScr13a() /* 64x 64 color / 128x 64 */ { uint8_t X,Y; uint8_t *T1,*T2; @@ -275,7 +277,7 @@ W=0; } // RefreshScr13b: N60-BASIC screen 3,4 -void PC6001_MEMORY::RefreshScr13b() /* 128x 64 color */ +void MEMORY::RefreshScr13b() /* 128x 64 color */ { uint8_t X,Y; uint8_t *T1,*T2; @@ -299,7 +301,7 @@ W=0; } // RefreshScr13c: N60-BASIC screen 3,4 -void PC6001_MEMORY::RefreshScr13c() /* 128x 96 */ +void MEMORY::RefreshScr13c() /* 128x 96 */ { uint8_t X,Y; uint8_t *T1,*T2; @@ -327,7 +329,7 @@ W=0; } // RefreshScr13d: N60-BASIC screen 3,4 -void PC6001_MEMORY::RefreshScr13d() /* 128x 96 color */ +void MEMORY::RefreshScr13d() /* 128x 96 color */ { uint8_t X,Y; uint8_t *T1,*T2; @@ -351,7 +353,7 @@ W=0; } // RefreshScr13e: N60-BASIC screen 3,4 -void PC6001_MEMORY::RefreshScr13e() /* 128x192 */ +void MEMORY::RefreshScr13e() /* 128x192 */ { uint8_t X,Y; uint8_t *T1,*T2; @@ -378,7 +380,7 @@ W=0; } // RefreshScr51: N60m/66-BASIC screen 1,2 -void PC6001_MEMORY::RefreshScr51() +void MEMORY::RefreshScr51() { uint8_t X,Y,K; int FC,BC; @@ -406,7 +408,7 @@ W=0; } // RefreshScr53: N60m/66-BASIC screen 3 -void PC6001_MEMORY::RefreshScr53() +void MEMORY::RefreshScr53() { uint8_t X,Y; uint8_t *T1,*T2; @@ -427,7 +429,7 @@ W=0; } // RefreshScr54: N60m/66-BASIC screen 4 -void PC6001_MEMORY::RefreshScr54() +void MEMORY::RefreshScr54() { uint8_t X,Y; uint8_t *T1,*T2; @@ -456,7 +458,7 @@ W=0; #if defined(_PC6601SR) || defined(_PC6001MK2SR) // RefreshScr61: N66-SR BASIC screen 1 -void PC6001_MEMORY::RefreshScr61() +void MEMORY::RefreshScr61() { uint8_t X,Y,K; register int FC,BC; @@ -490,7 +492,7 @@ W=0; } // RefreshScr62 N66-SR BASIC screen 2 -void PC6001_MEMORY::RefreshScr62() +void MEMORY::RefreshScr62() { uint8_t X,Y; uint8_t *T1,*T2; @@ -524,7 +526,7 @@ W=0; } // RefreshScr63 N66-SR BASIC screen 3 -void PC6001_MEMORY::RefreshScr63() +void MEMORY::RefreshScr63() { uint8_t X,Y; uint8_t *T1,*T2; @@ -566,7 +568,7 @@ W=0; } } -void PC6001_MEMORY::do_palet(int dest,int src) +void MEMORY::do_palet(int dest,int src) { int textpalet2[16]={0,4,1,5,2,6,3,7,8,12,9,13,10,14,11,15}; /* color code-> VRAM code*/ // *************** for RefreshScr 53/54/62/63 *************************** @@ -596,7 +598,7 @@ void PC6001_MEMORY::do_palet(int dest,int src) BPal[textpalet2[dest]]= BPal61[ textpalet2[src]]; } -void PC6001_MEMORY::make_semigraph(void) +void MEMORY::make_semigraph(void) { uint8_t *P; unsigned int i, j, m1, m2; @@ -638,14 +640,14 @@ void PC6001_MEMORY::make_semigraph(void) } } -int PC6001_MEMORY::chk_gvram(uint32_t A,int flag) +int MEMORY::chk_gvram(uint32_t A,int flag) { if (port60[ (A>>13)+flag ]==0x00 && bitmap) // VRAM ‚̐擪‚©‚ACRT‚ª BITMAP mode return 1; return 0; } -uint8_t PC6001_MEMORY::gvram_read(uint32_t A) +uint8_t MEMORY::gvram_read(uint32_t A) { uint8_t* adr; uint8_t ret; @@ -669,7 +671,7 @@ uint8_t PC6001_MEMORY::gvram_read(uint32_t A) return (ret); } -void PC6001_MEMORY::gvram_write(uint32_t A, uint32_t V) +void MEMORY::gvram_write(uint32_t A, uint32_t V) { uint8_t* adr; int x,y,z,w,off; @@ -693,3 +695,5 @@ void PC6001_MEMORY::gvram_write(uint32_t A, uint32_t V) } #endif +} + diff --git a/source/src/vm/pc6001/pc6001.cpp b/source/src/vm/pc6001/pc6001.cpp index 54c86dff8..57333a3c4 100644 --- a/source/src/vm/pc6001/pc6001.cpp +++ b/source/src/vm/pc6001/pc6001.cpp @@ -53,6 +53,19 @@ #include "sub.h" #include "timer.h" +#ifdef _PC6001 +using PC6001::DISPLAY; +#endif +#if defined(_PC6601) || defined(_PC6601SR) +using PC6001::FLOPPY; +#endif + +using PC6001::JOYSTICK; +using PC6001::MEMORY; +using PC6001::PSUB; +using PC6001::SUB; +using PC6001::TIMER; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -96,7 +109,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) // floppy->set_context_noise_head_up(noise_head_up); #endif joystick = new JOYSTICK(this, emu); - memory = new PC6001_MEMORY(this, emu); + memory = new MEMORY(this, emu); timer = new TIMER(this, emu); // set contexts diff --git a/source/src/vm/pc6001/pc6001.h b/source/src/vm/pc6001/pc6001.h index 4f7fa0705..a02cc0a32 100644 --- a/source/src/vm/pc6001/pc6001.h +++ b/source/src/vm/pc6001/pc6001.h @@ -121,8 +121,6 @@ static const _TCHAR *sound_device_caption[] = { _T("CMT (Signal)"), _T("Noise (FDD)"), _T("Noise (CMT)"), }; #endif - -class csp_state_utils; class EMU; class DEVICE; class EVENT; @@ -149,22 +147,28 @@ class DATAREC; class MCS48; #ifdef _PC6001 -class DISPLAY; +namespace PC6001 { + class DISPLAY; +} #endif #if defined(_PC6601) || defined(_PC6601SR) -class FLOPPY; +namespace PC6001 { + class FLOPPY; +} #endif -class JOYSTICK; -class PC6001_MEMORY; -class PSUB; -class SUB; -class TIMER; + +namespace PC6001 { + class JOYSTICK; + class MEMORY; + class PSUB; + class SUB; + class TIMER; +} class VM : public VM_TEMPLATE { protected: //EMU* emu; - //csp_state_utils *state_entry; int vdata; @@ -185,20 +189,20 @@ protected: Z80* cpu; #ifdef _PC6001 MC6847* vdp; - DISPLAY* display; + PC6001::DISPLAY* display; #else UPD7752* voice; #endif #if defined(_PC6601) || defined(_PC6601SR) - FLOPPY* floppy; + PC6001::FLOPPY* floppy; #endif - JOYSTICK* joystick; - PC6001_MEMORY* memory; - PSUB* psub; - TIMER* timer; + PC6001::JOYSTICK* joystick; + PC6001::MEMORY* memory; + PC6001::PSUB* psub; + PC6001::TIMER* timer; MCS48* cpu_sub; - SUB* sub; + PC6001::SUB* sub; DATAREC* drec; PC6031* pc6031; diff --git a/source/src/vm/pc6001/psub.cpp b/source/src/vm/pc6001/psub.cpp index 349762c22..ea594b35d 100644 --- a/source/src/vm/pc6001/psub.cpp +++ b/source/src/vm/pc6001/psub.cpp @@ -41,6 +41,8 @@ #define EVENT_CASSETTE 0 #define EVENT_STRIG 1 +namespace PC6001 { + /* normal (small alphabet) */ uint8_t Keys1[256][2] = { @@ -1170,3 +1172,5 @@ bool PSUB::process_state(FILEIO* state_fio, bool loading) state_fio->StateInt32(StrigEventID); return true; } + +} diff --git a/source/src/vm/pc6001/psub.h b/source/src/vm/pc6001/psub.h index fa8e66bc7..94d1bb494 100644 --- a/source/src/vm/pc6001/psub.h +++ b/source/src/vm/pc6001/psub.h @@ -20,6 +20,8 @@ class FILEIO; +namespace PC6001 { + class PSUB : public DEVICE { private: @@ -88,4 +90,6 @@ public: void key_down(int code); void key_up(int code); }; + +} #endif diff --git a/source/src/vm/pc6001/sub.cpp b/source/src/vm/pc6001/sub.cpp index bbac82910..9960a143a 100644 --- a/source/src/vm/pc6001/sub.cpp +++ b/source/src/vm/pc6001/sub.cpp @@ -20,6 +20,8 @@ #define EVENT_PLAY 0 #define EVENT_STOP 1 +namespace PC6001 { + static const uint8_t key_matrix[16][8] = { {0x00, 0x11, 0x10, 0x12, 0x00, 0x00, 0x00, 0x00}, {0x31, 0x51, 0x41, 0x5a, 0x4b, 0x49, 0x38, 0xbc}, @@ -441,3 +443,6 @@ bool SUB::process_state(FILEIO* state_fio, bool loading) state_fio->StateBuffer(buffer, sizeof(buffer), 1); return true; } + +} + diff --git a/source/src/vm/pc6001/sub.h b/source/src/vm/pc6001/sub.h index 2401fe409..14228787f 100644 --- a/source/src/vm/pc6001/sub.h +++ b/source/src/vm/pc6001/sub.h @@ -23,6 +23,8 @@ class FILEIO; +namespace PC6001 { + class SUB : public DEVICE { private: @@ -78,4 +80,6 @@ public: return rec; } }; + +} #endif diff --git a/source/src/vm/pc6001/timer.cpp b/source/src/vm/pc6001/timer.cpp index deb4b57fb..e455d7783 100644 --- a/source/src/vm/pc6001/timer.cpp +++ b/source/src/vm/pc6001/timer.cpp @@ -18,6 +18,8 @@ #define EVENT_TIMER 0 +namespace PC6001 { + void TIMER::initialize() { #if defined(_PC6601SR) || defined(_PC6001MK2SR) @@ -306,3 +308,6 @@ bool TIMER::process_state(FILEIO* state_fio, bool loading) #endif return true; } + +} + diff --git a/source/src/vm/pc6001/timer.h b/source/src/vm/pc6001/timer.h index f050867a3..d4ed70a05 100644 --- a/source/src/vm/pc6001/timer.h +++ b/source/src/vm/pc6001/timer.h @@ -28,15 +28,18 @@ #define SIG_TIMER_IRQ_EXT_INT 7 #ifndef _PC6001 -class PC6001_MEMORY; +namespace PC6001 { + class MEMORY; +} #endif +namespace PC6001 { class TIMER : public DEVICE { private: DEVICE *d_cpu, *d_sub; #ifndef _PC6001 - PC6001_MEMORY *d_mem; + PC6001::MEMORY *d_mem; #endif uint8_t IRQ, NewIRQ; @@ -83,11 +86,12 @@ public: d_sub = device; } #ifndef _PC6001 - void set_context_memory(PC6001_MEMORY* device) + void set_context_memory(PC6001::MEMORY* device) { d_mem = device; } #endif void set_portB0(uint32_t data); }; +} #endif diff --git a/source/src/vm/pc8201/cmt.cpp b/source/src/vm/pc8201/cmt.cpp index 7b98ca553..58c8f4df8 100644 --- a/source/src/vm/pc8201/cmt.cpp +++ b/source/src/vm/pc8201/cmt.cpp @@ -11,6 +11,8 @@ #define SAMPLE_RATE 48000 +namespace PC8201 { + void CMT::initialize() { fio = new FILEIO(); @@ -230,3 +232,5 @@ bool CMT::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint32(prev_clock); return true; } + +} diff --git a/source/src/vm/pc8201/cmt.h b/source/src/vm/pc8201/cmt.h index 377fb0b48..ddfdf86c6 100644 --- a/source/src/vm/pc8201/cmt.h +++ b/source/src/vm/pc8201/cmt.h @@ -20,6 +20,8 @@ // max 256kbytes #define BUFFER_SIZE 0x40000 +namespace PC8201 { + class CMT : public DEVICE { private: @@ -69,5 +71,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc8201/keyboard.cpp b/source/src/vm/pc8201/keyboard.cpp index 73fa4966f..9b82f03f8 100644 --- a/source/src/vm/pc8201/keyboard.cpp +++ b/source/src/vm/pc8201/keyboard.cpp @@ -9,6 +9,8 @@ #include "keyboard.h" +namespace PC8201 { + static const int key_map[9][8] = { {0x5a, 0x58, 0x43, 0x56, 0x42, 0x4e, 0x4d, 0x4c}, // Z X C V B N M L {0x41, 0x53, 0x44, 0x46, 0x47, 0x48, 0x4a, 0x4b}, // A S D F G H J K @@ -96,3 +98,5 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(kana); return true; } + +} diff --git a/source/src/vm/pc8201/keyboard.h b/source/src/vm/pc8201/keyboard.h index c965c49dd..1e976be42 100644 --- a/source/src/vm/pc8201/keyboard.h +++ b/source/src/vm/pc8201/keyboard.h @@ -17,6 +17,8 @@ #define SIG_KEYBOARD_COLUMN_L 0 #define SIG_KEYBOARD_COLUMN_H 1 +namespace PC8201 { + class KEYBOARD : public DEVICE { private: @@ -49,4 +51,5 @@ public: } }; +} #endif diff --git a/source/src/vm/pc8201/lcd.cpp b/source/src/vm/pc8201/lcd.cpp index 4bf0f97ac..2265e9e51 100644 --- a/source/src/vm/pc8201/lcd.cpp +++ b/source/src/vm/pc8201/lcd.cpp @@ -9,6 +9,8 @@ #include "lcd.h" +namespace PC8201 { + void LCD::initialize() { memset(seg, 0, sizeof(seg)); @@ -184,3 +186,5 @@ bool LCD::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint16(sel); return true; } + +} diff --git a/source/src/vm/pc8201/lcd.h b/source/src/vm/pc8201/lcd.h index d7e2fa870..9dd304d41 100644 --- a/source/src/vm/pc8201/lcd.h +++ b/source/src/vm/pc8201/lcd.h @@ -17,6 +17,8 @@ #define SIG_LCD_CHIPSEL_L 0 #define SIG_LCD_CHIPSEL_H 1 +namespace PC8201 { + class LCD : public DEVICE { private: @@ -46,4 +48,5 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/pc8201/memory.cpp b/source/src/vm/pc8201/memory.cpp index b2f197ace..138acab25 100644 --- a/source/src/vm/pc8201/memory.cpp +++ b/source/src/vm/pc8201/memory.cpp @@ -12,6 +12,8 @@ #include "../datarec.h" #include "../upd1990a.h" +namespace PC8201 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 12, eb = (e) >> 12; \ for(int i = sb; i <= eb; i++) { \ @@ -28,7 +30,7 @@ } \ } -void PC8201_MEMORY::initialize() +void MEMORY::initialize() { // init memory memset(ram, 0, sizeof(ram)); @@ -53,7 +55,7 @@ void PC8201_MEMORY::initialize() delete fio; } -void PC8201_MEMORY::release() +void MEMORY::release() { // save ram image FILEIO* fio = new FILEIO(); @@ -64,25 +66,25 @@ void PC8201_MEMORY::release() delete fio; } -void PC8201_MEMORY::reset() +void MEMORY::reset() { sio = bank = 0; update_bank(); } -void PC8201_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { addr &= 0xffff; wbank[addr >> 12][addr & 0xfff] = data; } -uint32_t PC8201_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { addr &= 0xffff; return rbank[addr >> 12][addr & 0xfff]; } -void PC8201_MEMORY::write_io8(uint32_t addr, uint32_t data) +void MEMORY::write_io8(uint32_t addr, uint32_t data) { switch(addr & 0xf0) { case 0x90: @@ -104,13 +106,13 @@ void PC8201_MEMORY::write_io8(uint32_t addr, uint32_t data) } } -uint32_t PC8201_MEMORY::read_io8(uint32_t addr) +uint32_t MEMORY::read_io8(uint32_t addr) { // $A0: bank status return (sio & 0xc0) | (bank & 0xf); } -void PC8201_MEMORY::update_bank() +void MEMORY::update_bank() { switch(bank & 3) { case 0: @@ -144,7 +146,7 @@ void PC8201_MEMORY::update_bank() #define STATE_VERSION 1 -bool PC8201_MEMORY::process_state(FILEIO* state_fio, bool loading) +bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -162,3 +164,5 @@ bool PC8201_MEMORY::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/pc8201/memory.h b/source/src/vm/pc8201/memory.h index 26869aaeb..36f2ddc8a 100644 --- a/source/src/vm/pc8201/memory.h +++ b/source/src/vm/pc8201/memory.h @@ -14,7 +14,9 @@ #include "../../emu.h" #include "../device.h" -class PC8201_MEMORY : public DEVICE +namespace PC8201 { + +class MEMORY : public DEVICE { private: DEVICE *d_cmt, *d_drec, *d_rtc; @@ -31,11 +33,11 @@ private: void update_bank(); public: - PC8201_MEMORY(VM_TEMPLATE* 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")); } - ~PC8201_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -62,5 +64,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc8201/pc8201.cpp b/source/src/vm/pc8201/pc8201.cpp index e2055eca0..32d6d115e 100644 --- a/source/src/vm/pc8201/pc8201.cpp +++ b/source/src/vm/pc8201/pc8201.cpp @@ -29,6 +29,11 @@ #include "lcd.h" #include "./memory.h" +using PC8201::CMT; +using PC8201::KEYBOARD; +using PC8201::LCD; +using PC8201::MEMORY; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -53,7 +58,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) cmt = new CMT(this, emu); keyboard = new KEYBOARD(this, emu); lcd = new LCD(this, emu); - memory = new PC8201_MEMORY(this, emu); + memory = new MEMORY(this, emu); // set contexts event->set_context_cpu(cpu); diff --git a/source/src/vm/pc8201/pc8201.h b/source/src/vm/pc8201/pc8201.h index d5e30d29d..30e536f6d 100644 --- a/source/src/vm/pc8201/pc8201.h +++ b/source/src/vm/pc8201/pc8201.h @@ -63,10 +63,12 @@ class IO; class PCM1BIT; class UPD1990A; -class CMT; -class KEYBOARD; -class LCD; -class PC8201_MEMORY; +namespace PC8201 { + class CMT; + class KEYBOARD; + class LCD; + class MEMORY; +} class VM :public VM_TEMPLATE { @@ -84,10 +86,10 @@ protected: PCM1BIT* pcm; UPD1990A* rtc; - CMT* cmt; - KEYBOARD* keyboard; - LCD* lcd; - PC8201_MEMORY* memory; + PC8201::CMT* cmt; + PC8201::KEYBOARD* keyboard; + PC8201::LCD* lcd; + PC8201::MEMORY* memory; public: // ---------------------------------------- diff --git a/source/src/vm/pc9801/cmt.cpp b/source/src/vm/pc9801/cmt.cpp index 4196372b6..d91c1c8e9 100644 --- a/source/src/vm/pc9801/cmt.cpp +++ b/source/src/vm/pc9801/cmt.cpp @@ -11,6 +11,8 @@ #include "cmt.h" #include "../i8251.h" +namespace PC9801 { + void CMT::initialize() { fio = new FILEIO(); @@ -122,3 +124,4 @@ bool CMT::process_state(FILEIO* state_fio, bool loading) return true; } +} diff --git a/source/src/vm/pc9801/cmt.h b/source/src/vm/pc9801/cmt.h index 2fd51725c..1cc870d99 100644 --- a/source/src/vm/pc9801/cmt.h +++ b/source/src/vm/pc9801/cmt.h @@ -23,6 +23,8 @@ // max 256kbytes #define BUFFER_SIZE 0x40000 +namespace PC9801 { + class CMT : public DEVICE { private: @@ -64,5 +66,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc9801/cpureg.cpp b/source/src/vm/pc9801/cpureg.cpp index c28d0d197..f9186bd8c 100644 --- a/source/src/vm/pc9801/cpureg.cpp +++ b/source/src/vm/pc9801/cpureg.cpp @@ -18,6 +18,8 @@ #include "../i286.h" #endif +namespace PC9801 { + void CPUREG::reset() { d_cpu->set_address_mask(0x000fffff); @@ -117,3 +119,6 @@ bool CPUREG::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(nmi_enabled); return true; } + +} + diff --git a/source/src/vm/pc9801/cpureg.h b/source/src/vm/pc9801/cpureg.h index 77982b6a2..a24575e9c 100644 --- a/source/src/vm/pc9801/cpureg.h +++ b/source/src/vm/pc9801/cpureg.h @@ -24,6 +24,8 @@ class I386; class I286; #endif +namespace PC9801 { + class CPUREG : public DEVICE { private: @@ -58,5 +60,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc9801/display.cpp b/source/src/vm/pc9801/display.cpp index 7b575b69b..e1e7aa2ec 100644 --- a/source/src/vm/pc9801/display.cpp +++ b/source/src/vm/pc9801/display.cpp @@ -73,6 +73,8 @@ #define ATTR_VL 0x10 #define ATTR_COL 0xe0 +namespace PC9801 { + static const uint8_t memsw_default[] = { 0xe1, 0x48, 0xe1, 0x05, 0xe1, 0x04, 0xe1, 0x00, 0xe1, 0x01, 0xe1, 0x00, 0xe1, 0x00, 0xe1, 0x00, @@ -2715,3 +2717,4 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading) return true; } +} diff --git a/source/src/vm/pc9801/display.h b/source/src/vm/pc9801/display.h index ae8eff5ab..117f72881 100644 --- a/source/src/vm/pc9801/display.h +++ b/source/src/vm/pc9801/display.h @@ -26,6 +26,8 @@ class UPD7220; +namespace PC9801 { + class DISPLAY : public DEVICE { private: @@ -243,5 +245,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/pc9801/dmareg.cpp b/source/src/vm/pc9801/dmareg.cpp index 56eabe9f5..4578c28ef 100644 --- a/source/src/vm/pc9801/dmareg.cpp +++ b/source/src/vm/pc9801/dmareg.cpp @@ -14,6 +14,8 @@ #include "dmareg.h" #include "../i8237.h" +namespace PC9801 { + static const int bank_lo_id[] = { SIG_I8237_BANK1, SIG_I8237_BANK2, SIG_I8237_BANK3, SIG_I8237_BANK0, }; @@ -94,3 +96,6 @@ bool DMAREG::process_state(FILEIO* state_fio, bool loading) } */ + +} + diff --git a/source/src/vm/pc9801/dmareg.h b/source/src/vm/pc9801/dmareg.h index ea3335a35..7c4412c3e 100644 --- a/source/src/vm/pc9801/dmareg.h +++ b/source/src/vm/pc9801/dmareg.h @@ -18,6 +18,8 @@ #include "../../emu.h" #include "../device.h" +namespace PC9801 { + class DMAREG : public DEVICE { private: @@ -42,5 +44,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc9801/floppy.cpp b/source/src/vm/pc9801/floppy.cpp index fa2bae893..a033dff23 100644 --- a/source/src/vm/pc9801/floppy.cpp +++ b/source/src/vm/pc9801/floppy.cpp @@ -25,6 +25,8 @@ #define EVENT_TIMER 0 +namespace PC9801 { + void FLOPPY::reset() { #if defined(SUPPORT_2HD_FDD_IF) @@ -341,3 +343,4 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading) return true; } +} diff --git a/source/src/vm/pc9801/floppy.h b/source/src/vm/pc9801/floppy.h index 4cc7a2453..a47eaad76 100644 --- a/source/src/vm/pc9801/floppy.h +++ b/source/src/vm/pc9801/floppy.h @@ -39,6 +39,8 @@ class UPD765A; +namespace PC9801 { + class FLOPPY : public DEVICE { private: @@ -102,5 +104,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc9801/fmsound.cpp b/source/src/vm/pc9801/fmsound.cpp index 941bb592a..e85a4be3d 100644 --- a/source/src/vm/pc9801/fmsound.cpp +++ b/source/src/vm/pc9801/fmsound.cpp @@ -22,6 +22,8 @@ // PC-98DO+ #define BOARD_ID 0 +namespace PC9801 { + #ifdef SUPPORT_PC98_OPNA void FMSOUND::reset() { @@ -97,3 +99,4 @@ bool FMSOUND::process_state(FILEIO* state_fio, bool loading) } #endif +} diff --git a/source/src/vm/pc9801/fmsound.h b/source/src/vm/pc9801/fmsound.h index f2aff1c16..a6dd9e558 100644 --- a/source/src/vm/pc9801/fmsound.h +++ b/source/src/vm/pc9801/fmsound.h @@ -24,6 +24,8 @@ #include "../../emu.h" #include "../device.h" +namespace PC9801 { + class FMSOUND : public DEVICE { private: @@ -60,5 +62,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc9801/joystick.cpp b/source/src/vm/pc9801/joystick.cpp index 8ffe42215..f7a0e3774 100644 --- a/source/src/vm/pc9801/joystick.cpp +++ b/source/src/vm/pc9801/joystick.cpp @@ -20,6 +20,8 @@ #include "joystick.h" #include "../ym2203.h" +namespace PC9801 { + void JOYSTICK::initialize() { joy_status = emu->get_joy_buffer(); @@ -55,3 +57,4 @@ bool JOYSTICK::process_state(FILEIO* state_fio, bool loading) return true; } +} diff --git a/source/src/vm/pc9801/joystick.h b/source/src/vm/pc9801/joystick.h index 22a9e3899..26b4b4c41 100644 --- a/source/src/vm/pc9801/joystick.h +++ b/source/src/vm/pc9801/joystick.h @@ -26,6 +26,8 @@ #define SIG_JOYSTICK_SELECT 0 +namespace PC9801 { + class JOYSTICK : public DEVICE { private: @@ -54,4 +56,5 @@ public: } }; +} #endif diff --git a/source/src/vm/pc9801/keyboard.cpp b/source/src/vm/pc9801/keyboard.cpp index d6107ba7a..8b5e83816 100644 --- a/source/src/vm/pc9801/keyboard.cpp +++ b/source/src/vm/pc9801/keyboard.cpp @@ -20,6 +20,8 @@ #include "keyboard.h" #include "../i8251.h" +namespace PC9801 { + static const int key_table[256] = { -1, -1, -1, -1, -1, -1, -1, -1,0x0e,0x0f, -1, -1, -1,0x1c, -1, -1, 0x70,0x74,0x73,0x60, -1, -1, -1, -1, -1, -1, -1,0x00,0x35, -1, -1, -1, @@ -99,3 +101,4 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) return true; } +} diff --git a/source/src/vm/pc9801/keyboard.h b/source/src/vm/pc9801/keyboard.h index b3f99f81b..e3e6d3dbb 100644 --- a/source/src/vm/pc9801/keyboard.h +++ b/source/src/vm/pc9801/keyboard.h @@ -26,6 +26,8 @@ #define SIG_KEYBOARD_RECV 0 +namespace PC9801 { + class KEYBOARD : public DEVICE { private: @@ -63,4 +65,5 @@ public: } }; +} #endif diff --git a/source/src/vm/pc9801/membus.cpp b/source/src/vm/pc9801/membus.cpp index 485d0416b..933ae6f5a 100644 --- a/source/src/vm/pc9801/membus.cpp +++ b/source/src/vm/pc9801/membus.cpp @@ -52,6 +52,8 @@ F0000h - FFFFFh: BIOS */ +namespace PC9801 { + void MEMBUS::initialize() { MEMORY::initialize(); @@ -605,3 +607,5 @@ bool MEMBUS::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/pc9801/membus.h b/source/src/vm/pc9801/membus.h index 8380d31a4..fe008234f 100644 --- a/source/src/vm/pc9801/membus.h +++ b/source/src/vm/pc9801/membus.h @@ -22,8 +22,9 @@ #include "../memory.h" -class DISPLAY; - +namespace PC9801 { + class DISPLAY; +} #if defined(SUPPORT_32BIT_ADDRESS) #define RAM_SIZE 0x800000 // 8MB #elif defined(SUPPORT_24BIT_ADDRESS) @@ -34,6 +35,8 @@ class DISPLAY; //class csp_state_utils; +namespace PC9801 { + class MEMBUS : public MEMORY { private: @@ -138,4 +141,5 @@ public: } }; +} #endif diff --git a/source/src/vm/pc9801/mouse.cpp b/source/src/vm/pc9801/mouse.cpp index 7d03df035..24f96953d 100644 --- a/source/src/vm/pc9801/mouse.cpp +++ b/source/src/vm/pc9801/mouse.cpp @@ -23,6 +23,8 @@ #define EVENT_TIMER 0 +namespace PC9801 { + static const int freq_table[4] = {120, 60, 30, 15}; void MOUSE::initialize() @@ -146,3 +148,4 @@ bool MOUSE::process_state(FILEIO* state_fio, bool loading) return true; } +} diff --git a/source/src/vm/pc9801/mouse.h b/source/src/vm/pc9801/mouse.h index 03d7c932f..1ca5fd007 100644 --- a/source/src/vm/pc9801/mouse.h +++ b/source/src/vm/pc9801/mouse.h @@ -26,6 +26,8 @@ #define SIG_MOUSE_PORT_C 0 +namespace PC9801 { + class MOUSE : public DEVICE { private: @@ -68,5 +70,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc9801/pc9801.cpp b/source/src/vm/pc9801/pc9801.cpp index 0326bffd8..8e21b1510 100644 --- a/source/src/vm/pc9801/pc9801.cpp +++ b/source/src/vm/pc9801/pc9801.cpp @@ -86,6 +86,30 @@ #include "ide.h" #endif +#if defined(SUPPORT_CMT_IF) +using PC9801::CMT; +#endif +#if defined(SUPPORT_24BIT_ADDRESS) || defined(SUPPORT_32BIT_ADDRESS) +using PC9801::CPUREG; +#endif +using PC9801::DISPLAY; +using PC9801::DMAREG; +using PC9801::FLOPPY; +using PC9801::FMSOUND; +using PC9801::JOYSTICK; +using PC9801::KEYBOARD; +using PC9801::MEMBUS; +using PC9801::MOUSE; +#if defined(SUPPORT_SASI_IF) +using PC9801::SASI; +#endif +#if defined(SUPPORT_SCSI_IF) +using PC9801::SCSI; +#endif +#if defined(SUPPORT_IDE_IF) +using PC9801::IDE; +#endif + #if defined(SUPPORT_320KB_FDD_IF) #include "../pc80s31k.h" #include "../z80.h" @@ -100,6 +124,9 @@ #include "../pc8801/pc88.h" #endif +#if defined(_PC98DO) || defined(_PC98DOPLUS) +using PC88DEV::PC88; +#endif // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- diff --git a/source/src/vm/pc9801/pc9801.h b/source/src/vm/pc9801/pc9801.h index df1aacb5d..e11882924 100644 --- a/source/src/vm/pc9801/pc9801.h +++ b/source/src/vm/pc9801/pc9801.h @@ -375,29 +375,31 @@ class UPD7220; class UPD765A; class YM2203; +namespace PC9801 { #if defined(SUPPORT_CMT_IF) -class CMT; + class CMT; #endif #if defined(SUPPORT_24BIT_ADDRESS) || defined(SUPPORT_32BIT_ADDRESS) -class CPUREG; -#endif -class DISPLAY; -class DMAREG; -class FLOPPY; -class FMSOUND; -class JOYSTICK; -class KEYBOARD; -class MEMBUS; -class MOUSE; + class CPUREG; +#endif + class DISPLAY; + class DMAREG; + class FLOPPY; + class FMSOUND; + class JOYSTICK; + class KEYBOARD; + class MEMBUS; + class MOUSE; #if defined(SUPPORT_SASI_IF) -class SASI; + class SASI; #endif #if defined(SUPPORT_SCSI_IF) -class SCSI; + class SCSI; #endif #if defined(SUPPORT_IDE_IF) -class IDE; + class IDE; #endif +} #if defined(SUPPORT_320KB_FDD_IF) // 320kb fdd drives @@ -407,7 +409,9 @@ class Z80; #if defined(_PC98DO) || defined(_PC98DOPLUS) class PC80S31K; -class PC88; +namespace PC88DEV { + class PC88; +} class Z80; #endif @@ -480,27 +484,27 @@ protected: YM2203* opn; #if defined(SUPPORT_CMT_IF) - CMT* cmt; + PC9801::CMT* cmt; #endif #if defined(SUPPORT_24BIT_ADDRESS) || defined(SUPPORT_32BIT_ADDRESS) - CPUREG* cpureg; -#endif - DISPLAY* display; - DMAREG* dmareg; - FLOPPY* floppy; - FMSOUND* fmsound; - JOYSTICK* joystick; - KEYBOARD* keyboard; - MEMBUS* memory; - MOUSE* mouse; + PC9801::CPUREG* cpureg; +#endif + PC9801::DISPLAY* display; + PC9801::DMAREG* dmareg; + PC9801::FLOPPY* floppy; + PC9801::FMSOUND* fmsound; + PC9801::JOYSTICK* joystick; + PC9801::KEYBOARD* keyboard; + PC9801::MEMBUS* memory; + PC9801::MOUSE* mouse; #if defined(SUPPORT_SASI_IF) - SASI* sasi; + PC9801::SASI* sasi; #endif #if defined(SUPPORT_SCSI_IF) - SCSI* scsi; + PC9801::SCSI* scsi; #endif #if defined(SUPPORT_IDE_IF) - IDE* ide; + PC9801::IDE* ide; #endif // PC-9801-14 @@ -524,7 +528,7 @@ protected: #if defined(_PC98DO) || defined(_PC98DOPLUS) EVENT* pc88event; - PC88* pc88; + PC88DEV::PC88* pc88; DEVICE* pc88prn; I8251* pc88sio; I8255* pc88pio; diff --git a/source/src/vm/pc9801/sasi.cpp b/source/src/vm/pc9801/sasi.cpp index 67da95292..f4a2856c0 100644 --- a/source/src/vm/pc9801/sasi.cpp +++ b/source/src/vm/pc9801/sasi.cpp @@ -33,6 +33,8 @@ #define ISR_IXO 0x04 #define ISR_INT 0x01 +namespace PC9801 { + void SASI::reset() { ocr = 0; @@ -211,3 +213,5 @@ bool SASI::process_state(FILEIO* state_fio, bool loading) return true; } +} + diff --git a/source/src/vm/pc9801/sasi.h b/source/src/vm/pc9801/sasi.h index eaca08d96..71c226127 100644 --- a/source/src/vm/pc9801/sasi.h +++ b/source/src/vm/pc9801/sasi.h @@ -24,6 +24,8 @@ class SASI_HDD; +namespace PC9801 { + class SASI : public DEVICE { private: @@ -70,5 +72,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc98ha/bios.cpp b/source/src/vm/pc98ha/bios.cpp index 0fb76817b..62621e2c3 100644 --- a/source/src/vm/pc98ha/bios.cpp +++ b/source/src/vm/pc98ha/bios.cpp @@ -12,6 +12,8 @@ #include "../upd765a.h" #include "../disk.h" +namespace PC98HA { + // regs #define AL regs8[0] #define AH regs8[1] @@ -45,3 +47,5 @@ bool BIOS::bios_int_i86(int intnum, uint16_t regs[], uint16_t sregs[], int32_t* } return false; } + +} diff --git a/source/src/vm/pc98ha/bios.h b/source/src/vm/pc98ha/bios.h index 37b8538a3..b334cce93 100644 --- a/source/src/vm/pc98ha/bios.h +++ b/source/src/vm/pc98ha/bios.h @@ -17,6 +17,8 @@ class UPD765A; +namespace PC98HA { + class BIOS : public DEVICE { private: @@ -39,5 +41,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc98ha/calendar.cpp b/source/src/vm/pc98ha/calendar.cpp index 6b3f65aca..56facd087 100644 --- a/source/src/vm/pc98ha/calendar.cpp +++ b/source/src/vm/pc98ha/calendar.cpp @@ -13,6 +13,8 @@ #include "../upd1990a.h" #endif +namespace PC98HA { + void CALENDAR::initialize() { #ifdef _PC98HA @@ -68,3 +70,4 @@ bool CALENDAR::process_state(FILEIO* state_fio, bool loading) } #endif +} diff --git a/source/src/vm/pc98ha/calendar.h b/source/src/vm/pc98ha/calendar.h index f5b63acdc..b587e1cd3 100644 --- a/source/src/vm/pc98ha/calendar.h +++ b/source/src/vm/pc98ha/calendar.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "../device.h" +namespace PC98HA { + class CALENDAR : public DEVICE { private: @@ -45,5 +47,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc98ha/floppy.cpp b/source/src/vm/pc98ha/floppy.cpp index d0e0f5e6c..c60135fe0 100644 --- a/source/src/vm/pc98ha/floppy.cpp +++ b/source/src/vm/pc98ha/floppy.cpp @@ -12,6 +12,8 @@ #include "../disk.h" #include "../upd765a.h" +namespace PC98HA { + void FLOPPY::reset() { /* @@ -81,3 +83,5 @@ bool FLOPPY::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(modereg); return true; } + +} diff --git a/source/src/vm/pc98ha/floppy.h b/source/src/vm/pc98ha/floppy.h index 158248bef..2426e1626 100644 --- a/source/src/vm/pc98ha/floppy.h +++ b/source/src/vm/pc98ha/floppy.h @@ -19,6 +19,8 @@ class UPD765A; +namespace PC98HA { + class FLOPPY : public DEVICE { private: @@ -46,5 +48,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc98ha/keyboard.cpp b/source/src/vm/pc98ha/keyboard.cpp index 0cbc46a8c..214c02ef1 100644 --- a/source/src/vm/pc98ha/keyboard.cpp +++ b/source/src/vm/pc98ha/keyboard.cpp @@ -11,6 +11,8 @@ #include "keyboard.h" #include "../i8251.h" +namespace PC98HA { + static const int key_table[256] = { -1, -1, -1, -1, -1, -1, -1, -1,0x0e,0x0f, -1, -1, -1,0x1c, -1, -1, 0x70,0x74,0x73,0x60, -1, -1, -1, -1, -1, -1, -1,0x00,0x35,0x51, -1, -1, @@ -85,3 +87,5 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) state_fio->StateBuffer(flag, sizeof(flag), 1); return true; } + +} diff --git a/source/src/vm/pc98ha/keyboard.h b/source/src/vm/pc98ha/keyboard.h index 148712e29..75bdddef5 100644 --- a/source/src/vm/pc98ha/keyboard.h +++ b/source/src/vm/pc98ha/keyboard.h @@ -17,6 +17,8 @@ #define SIG_KEYBOARD_RECV 0 +namespace PC98HA { + class KEYBOARD : public DEVICE { private: @@ -54,4 +56,5 @@ public: } }; +} #endif diff --git a/source/src/vm/pc98ha/memory.cpp b/source/src/vm/pc98ha/memory.cpp index 1c7e7cbd2..81433fb20 100644 --- a/source/src/vm/pc98ha/memory.cpp +++ b/source/src/vm/pc98ha/memory.cpp @@ -10,6 +10,8 @@ #include "./memory.h" +namespace PC98HA { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 14, eb = (e) >> 14; \ for(int i = sb; i <= eb; i++) { \ @@ -26,7 +28,7 @@ } \ } -void PC98LT_MEMORY::initialize() +void MEMORY::initialize() { // init memory memset(ram, 0, sizeof(ram)); @@ -87,7 +89,7 @@ void PC98LT_MEMORY::initialize() #endif } -void PC98LT_MEMORY::release() +void MEMORY::release() { // save ram images FILEIO* fio = new FILEIO(); @@ -114,7 +116,7 @@ void PC98LT_MEMORY::release() delete fio; } -void PC98LT_MEMORY::reset() +void MEMORY::reset() { // set memory bank learn_bank = dic_bank = kanji_bank = romdrv_bank = 0; @@ -126,7 +128,7 @@ void PC98LT_MEMORY::reset() update_bank(); } -void PC98LT_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { addr &= 0xfffff; wbank[addr >> 14][addr & 0x3fff] = data; @@ -138,13 +140,13 @@ void PC98LT_MEMORY::write_data8(uint32_t addr, uint32_t data) #endif } -uint32_t PC98LT_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { addr &= 0xfffff; return rbank[addr >> 14][addr & 0x3fff]; } -void PC98LT_MEMORY::write_io8(uint32_t addr, uint32_t data) +void MEMORY::write_io8(uint32_t addr, uint32_t data) { switch(addr & 0xffff) { #ifdef _PC98HA @@ -205,7 +207,7 @@ void PC98LT_MEMORY::write_io8(uint32_t addr, uint32_t data) } } -uint32_t PC98LT_MEMORY::read_io8(uint32_t addr) +uint32_t MEMORY::read_io8(uint32_t addr) { switch(addr & 0xffff) { case 0x0c10: @@ -220,7 +222,7 @@ uint32_t PC98LT_MEMORY::read_io8(uint32_t addr) return 0xff; } -void PC98LT_MEMORY::update_bank() +void MEMORY::update_bank() { SET_BANK(0x00000, 0xfffff, wdmy, rdmy); @@ -253,7 +255,7 @@ void PC98LT_MEMORY::update_bank() SET_BANK(0xf0000, 0xfffff, wdmy, ipl); } -void PC98LT_MEMORY::draw_screen() +void MEMORY::draw_screen() { // draw to real screen scrntype_t cd = RGB_COLOR(48, 56, 16); @@ -278,7 +280,7 @@ void PC98LT_MEMORY::draw_screen() #define STATE_VERSION 1 -bool PC98LT_MEMORY::process_state(FILEIO* state_fio, bool loading) +bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -315,3 +317,5 @@ bool PC98LT_MEMORY::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/pc98ha/memory.h b/source/src/vm/pc98ha/memory.h index 716fac0d2..1331ac838 100644 --- a/source/src/vm/pc98ha/memory.h +++ b/source/src/vm/pc98ha/memory.h @@ -17,7 +17,9 @@ #define SIG_MEMORY_IR2 0 -class PC98LT_MEMORY : public DEVICE +namespace PC98HA { + +class MEMORY : public DEVICE { private: uint8_t* rbank[64]; // 1MB / 16KB @@ -57,11 +59,11 @@ private: #endif public: - PC98LT_MEMORY(VM_TEMPLATE* 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")); } - ~PC98LT_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -81,5 +83,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/pc98ha/note.cpp b/source/src/vm/pc98ha/note.cpp index 381010ef6..7512986c9 100644 --- a/source/src/vm/pc98ha/note.cpp +++ b/source/src/vm/pc98ha/note.cpp @@ -11,6 +11,8 @@ #include "note.h" #include "../i8259.h" +namespace PC98HA { + void NOTE::initialize() { ch = 0; @@ -92,3 +94,6 @@ bool NOTE::process_state(FILEIO* state_fio, bool loading) state_fio->StateBuffer(regs, sizeof(regs), 1); return true; } + +} + diff --git a/source/src/vm/pc98ha/note.h b/source/src/vm/pc98ha/note.h index df495612a..e90864cf4 100644 --- a/source/src/vm/pc98ha/note.h +++ b/source/src/vm/pc98ha/note.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "../device.h" +namespace PC98HA { + class NOTE : public DEVICE { private: @@ -41,5 +43,6 @@ public: } }; +} #endif diff --git a/source/src/vm/pc98ha/pc98ha.cpp b/source/src/vm/pc98ha/pc98ha.cpp index 96fa8d937..98e7d79c5 100644 --- a/source/src/vm/pc98ha/pc98ha.cpp +++ b/source/src/vm/pc98ha/pc98ha.cpp @@ -47,6 +47,13 @@ #include "./memory.h" #include "note.h" +using PC98HA::BIOS; +using PC98HA::CALENDAR; +using PC98HA::FLOPPY; +using PC98HA::KEYBOARD; +using PC98HA::MEMORY; +using PC98HA::NOTE; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -103,7 +110,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) calendar = new CALENDAR(this, emu); floppy = new FLOPPY(this, emu); keyboard = new KEYBOARD(this, emu); - memory = new PC98LT_MEMORY(this, emu); + memory = new MEMORY(this, emu); note = new NOTE(this, emu); // set contexts event->set_context_cpu(cpu); diff --git a/source/src/vm/pc98ha/pc98ha.h b/source/src/vm/pc98ha/pc98ha.h index ddbeeb40b..2a0111ee3 100644 --- a/source/src/vm/pc98ha/pc98ha.h +++ b/source/src/vm/pc98ha/pc98ha.h @@ -93,12 +93,14 @@ class UPD1990A; class UPD71071; class UPD765A; -class BIOS; -class CALENDAR; -class FLOPPY; -class KEYBOARD; -class PC98LT_MEMORY; -class NOTE; +namespace PC98HA { + class BIOS; + class CALENDAR; + class FLOPPY; + class KEYBOARD; + class MEMORY; + class NOTE; +} class VM : public VM_TEMPLATE { @@ -132,12 +134,12 @@ protected: UPD71071* dma; UPD765A* fdc; - BIOS* bios; - CALENDAR* calendar; - FLOPPY* floppy; - KEYBOARD* keyboard; - PC98LT_MEMORY* memory; - NOTE* note; + PC98HA::BIOS* bios; + PC98HA::CALENDAR* calendar; + PC98HA::FLOPPY* floppy; + PC98HA::KEYBOARD* keyboard; + PC98HA::MEMORY* memory; + PC98HA::NOTE* note; public: // ---------------------------------------- diff --git a/source/src/vm/pcengine/pce.cpp b/source/src/vm/pcengine/pce.cpp index 46b18fee2..949d8f5aa 100644 --- a/source/src/vm/pcengine/pce.cpp +++ b/source/src/vm/pcengine/pce.cpp @@ -52,6 +52,8 @@ #define DCR_DVC 0x02 /* VRAM > VRAM EOT interrupt enable */ #define DCR_DSC 0x01 /* VRAM > SATB EOT interrupt enable */ +namespace PCEDEV { + /* just to keep things simple... */ enum vdc_regs {MAWR = 0, MARR, VxR, reg3, reg4, CR, RCR, BXR, BYR, MWR, HSR, HDR, VPR, VDW, VCR, DCR, SOUR, DESR, LENR, DVSSR }; @@ -2610,3 +2612,5 @@ bool PCE::process_state(FILEIO* state_fio, bool loading) #endif return true; } + +} diff --git a/source/src/vm/pcengine/pce.h b/source/src/vm/pcengine/pce.h index e071010ea..0098b5f0b 100644 --- a/source/src/vm/pcengine/pce.h +++ b/source/src/vm/pcengine/pce.h @@ -41,6 +41,8 @@ class SCSI_HOST; class SCSI_CDROM; #endif +namespace PCEDEV { + class PCE : public DEVICE { private: @@ -278,4 +280,5 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/pcengine/pcengine.cpp b/source/src/vm/pcengine/pcengine.cpp index f821e4c5f..5811dd2ab 100644 --- a/source/src/vm/pcengine/pcengine.cpp +++ b/source/src/vm/pcengine/pcengine.cpp @@ -23,6 +23,7 @@ #include "pce.h" +using PCEDEV::PCE; // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- diff --git a/source/src/vm/pcengine/pcengine.h b/source/src/vm/pcengine/pcengine.h index 8b11fd959..ca8c6ffef 100644 --- a/source/src/vm/pcengine/pcengine.h +++ b/source/src/vm/pcengine/pcengine.h @@ -76,8 +76,10 @@ class HUC6280; class MSM5205; class SCSI_HOST; class SCSI_CDROM; -class PCE; +namespace PCEDEV { + class PCE; +} class VM : public VM_TEMPLATE { protected: @@ -91,7 +93,7 @@ protected: MSM5205* adpcm; SCSI_HOST* scsi_host; SCSI_CDROM* scsi_cdrom; - PCE* pce; + PCEDEV::PCE* pce; public: // ---------------------------------------- diff --git a/source/src/vm/phc20/memory.cpp b/source/src/vm/phc20/memory.cpp index 558480a7b..262dc6ef1 100644 --- a/source/src/vm/phc20/memory.cpp +++ b/source/src/vm/phc20/memory.cpp @@ -10,6 +10,8 @@ #include "./memory.h" #include "../datarec.h" +namespace PHC20 { + static const uint8_t key_map[9][8] = { {0x31, 0x57, 0x53, 0x58, 0x00, 0x28, 0xba, 0xbd}, // 1 W S X DOWN : - {0x1b, 0x51, 0x41, 0x5a, 0x00, 0x0d, 0xbb, 0xbf}, // ESC??? Q A Z RET ; / @@ -38,7 +40,7 @@ static const uint8_t key_map[9][8] = { } \ } -void PHC20_MEMORY::initialize() +void MEMORY::initialize() { memset(rom, 0xff, sizeof(rom)); memset(rdmy, 0xff, sizeof(rdmy)); @@ -64,7 +66,7 @@ void PHC20_MEMORY::initialize() register_frame_event(this); } -void PHC20_MEMORY::reset() +void MEMORY::reset() { memset(ram, 0, sizeof(ram)); memset(vram, 0, sizeof(vram)); @@ -73,7 +75,7 @@ void PHC20_MEMORY::reset() sysport = 0; } -void PHC20_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { addr &= 0xffff; if((0x3000 <= addr && addr < 0x4000) || 0x4400 <= addr) { @@ -104,7 +106,7 @@ void PHC20_MEMORY::write_data8(uint32_t addr, uint32_t data) wbank[addr >> 10][addr & 0x3ff] = data; } -uint32_t PHC20_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { addr &= 0xffff; if((0x3000 <= addr && addr < 0x4000) || 0x4400 <= addr) { @@ -134,7 +136,7 @@ uint32_t PHC20_MEMORY::read_data8(uint32_t addr) return rbank[addr >> 10][addr & 0x3ff]; } -void PHC20_MEMORY::event_frame() +void MEMORY::event_frame() { memset(status, 0, sizeof(status)); @@ -147,7 +149,7 @@ void PHC20_MEMORY::event_frame() } } -void PHC20_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) +void MEMORY::write_signal(int id, uint32_t data, uint32_t mask) { if(data & mask) { sysport |= mask; @@ -158,7 +160,7 @@ void PHC20_MEMORY::write_signal(int id, uint32_t data, uint32_t mask) #define STATE_VERSION 1 -bool PHC20_MEMORY::process_state(FILEIO* state_fio, bool loading) +bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -172,3 +174,5 @@ bool PHC20_MEMORY::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(sysport); return true; } + +} diff --git a/source/src/vm/phc20/memory.h b/source/src/vm/phc20/memory.h index e4d3b3f19..2c2d0a283 100644 --- a/source/src/vm/phc20/memory.h +++ b/source/src/vm/phc20/memory.h @@ -16,7 +16,9 @@ #define SIG_MEMORY_SYSPORT 0 -class PHC20_MEMORY : public DEVICE +namespace PHC20 { + +class MEMORY : public DEVICE { private: DEVICE *d_drec; @@ -35,11 +37,11 @@ private: uint8_t sysport; public: - PHC20_MEMORY(VM_TEMPLATE* 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")); } - ~PHC20_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -61,5 +63,6 @@ public: } }; +} #endif diff --git a/source/src/vm/phc20/phc20.cpp b/source/src/vm/phc20/phc20.cpp index c1a53a6f0..53e80b179 100644 --- a/source/src/vm/phc20/phc20.cpp +++ b/source/src/vm/phc20/phc20.cpp @@ -23,6 +23,8 @@ #include "./memory.h" +using PHC20::MEMORY; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -41,7 +43,7 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) drec->set_context_noise_fast(new NOISE(this, emu)); vdp = new MC6847(this, emu); cpu = new Z80(this, emu); - memory = new PHC20_MEMORY(this, emu); + memory = new MEMORY(this, emu); // set contexts event->set_context_cpu(cpu); event->set_context_sound(drec); diff --git a/source/src/vm/phc20/phc20.h b/source/src/vm/phc20/phc20.h index db243520a..c4082ead3 100644 --- a/source/src/vm/phc20/phc20.h +++ b/source/src/vm/phc20/phc20.h @@ -45,8 +45,6 @@ static const _TCHAR *sound_device_caption[] = { }; #endif -class csp_state_utils; - class EMU; class DEVICE; class EVENT; @@ -55,7 +53,9 @@ class DATAREC; class MC6847; class Z80; -class PHC20_MEMORY; +namespace PHC20 { + class MEMORY; +} class VM : public VM_TEMPLATE { @@ -70,7 +70,7 @@ protected: MC6847* vdp; Z80* cpu; - PHC20_MEMORY* memory; + PHC20::MEMORY* memory; public: // ---------------------------------------- diff --git a/source/src/vm/phc25/joystick.cpp b/source/src/vm/phc25/joystick.cpp index 4a3634c46..ebdee0f5b 100644 --- a/source/src/vm/phc25/joystick.cpp +++ b/source/src/vm/phc25/joystick.cpp @@ -11,6 +11,8 @@ #include "joystick.h" #include "../ay_3_891x.h" +namespace PHC25 { + void JOYSTICK::initialize() { joy_stat = emu->get_joy_buffer(); @@ -24,3 +26,5 @@ void JOYSTICK::event_frame() d_psg->write_signal(SIG_AY_3_891X_PORT_A, ~(joy_stat[0] & 0x1f), 0xff); d_psg->write_signal(SIG_AY_3_891X_PORT_B, ~(joy_stat[1] & 0x1f), 0xff); } + +} diff --git a/source/src/vm/phc25/joystick.h b/source/src/vm/phc25/joystick.h index 01c47db95..a7d5d04bc 100644 --- a/source/src/vm/phc25/joystick.h +++ b/source/src/vm/phc25/joystick.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "../device.h" +namespace PHC25 { + class JOYSTICK : public DEVICE { private: @@ -39,4 +41,5 @@ public: } }; +} #endif diff --git a/source/src/vm/phc25/keyboard.cpp b/source/src/vm/phc25/keyboard.cpp index 17574abcb..25e4c6830 100644 --- a/source/src/vm/phc25/keyboard.cpp +++ b/source/src/vm/phc25/keyboard.cpp @@ -10,6 +10,8 @@ #include "keyboard.h" +namespace PHC25 { + #ifdef _MAP1010 static const uint8_t key_map[0x50] = { /* @@ -135,3 +137,5 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) #endif return true; } + +} diff --git a/source/src/vm/phc25/keyboard.h b/source/src/vm/phc25/keyboard.h index c9c8a0c14..c79a1c195 100644 --- a/source/src/vm/phc25/keyboard.h +++ b/source/src/vm/phc25/keyboard.h @@ -15,6 +15,8 @@ #include "../../emu.h" #include "../device.h" +namespace PHC25 { + class KEYBOARD : public DEVICE { private: @@ -41,4 +43,5 @@ public: bool process_state(FILEIO* state_fio, bool loading); }; +} #endif diff --git a/source/src/vm/phc25/memory.cpp b/source/src/vm/phc25/memory.cpp index 7ae17e696..ca12d0161 100644 --- a/source/src/vm/phc25/memory.cpp +++ b/source/src/vm/phc25/memory.cpp @@ -10,6 +10,8 @@ #include "./memory.h" +namespace PHC25 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 11, eb = (e) >> 11; \ for(int i = sb; i <= eb; i++) { \ @@ -26,7 +28,7 @@ } \ } -void PHC25_MEMORY::initialize() +void MEMORY::initialize() { memset(rom, 0xff, sizeof(rom)); memset(rdmy, 0xff, sizeof(rdmy)); @@ -53,13 +55,13 @@ void PHC25_MEMORY::initialize() #endif } -void PHC25_MEMORY::reset() +void MEMORY::reset() { memset(ram, 0, sizeof(ram)); memset(vram, 0, sizeof(vram)); } -void PHC25_MEMORY::write_data8(uint32_t addr, uint32_t data) +void MEMORY::write_data8(uint32_t addr, uint32_t data) { addr &= 0xffff; #ifdef _MAP1010 @@ -71,7 +73,7 @@ void PHC25_MEMORY::write_data8(uint32_t addr, uint32_t data) wbank[addr >> 11][addr & 0x7ff] = data; } -uint32_t PHC25_MEMORY::read_data8(uint32_t addr) +uint32_t MEMORY::read_data8(uint32_t addr) { addr &= 0xffff; #ifdef _MAP1010 @@ -87,7 +89,7 @@ uint32_t PHC25_MEMORY::read_data8(uint32_t addr) #define STATE_VERSION 1 -bool PHC25_MEMORY::process_state(FILEIO* state_fio, bool loading) +bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -99,3 +101,5 @@ bool PHC25_MEMORY::process_state(FILEIO* state_fio, bool loading) state_fio->StateBuffer(vram, sizeof(vram), 1); return true; } + +} diff --git a/source/src/vm/phc25/memory.h b/source/src/vm/phc25/memory.h index 1a511662b..1d98ee564 100644 --- a/source/src/vm/phc25/memory.h +++ b/source/src/vm/phc25/memory.h @@ -15,7 +15,9 @@ #include "../../emu.h" #include "../device.h" -class PHC25_MEMORY : public DEVICE +namespace PHC25 { + +class MEMORY : public DEVICE { private: DEVICE *d_kbd; @@ -34,11 +36,11 @@ private: uint8_t* rbank[32]; public: - PHC25_MEMORY(VM_TEMPLATE* 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")); } - ~PHC25_MEMORY() {} + ~MEMORY() {} // common functions void initialize(); @@ -58,5 +60,6 @@ public: } }; +} #endif diff --git a/source/src/vm/phc25/phc25.cpp b/source/src/vm/phc25/phc25.cpp index 0987d12b6..38ac63483 100644 --- a/source/src/vm/phc25/phc25.cpp +++ b/source/src/vm/phc25/phc25.cpp @@ -31,6 +31,11 @@ #include "./memory.h" #include "./system.h" +using PHC25::JOYSTICK; +using PHC25::KEYBOARD; +using PHC25::MEMORY; +using PHC25::SYSTEM; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -57,8 +62,8 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) joystick = new JOYSTICK(this, emu); keyboard = new KEYBOARD(this, emu); - memory = new PHC25_MEMORY(this, emu); - system = new PHC25_SYSTEM(this, emu); + memory = new MEMORY(this, emu); + system = new SYSTEM(this, emu); // set contexts event->set_context_cpu(cpu); event->set_context_sound(psg); diff --git a/source/src/vm/phc25/phc25.h b/source/src/vm/phc25/phc25.h index 72f86983c..4dc2426ec 100644 --- a/source/src/vm/phc25/phc25.h +++ b/source/src/vm/phc25/phc25.h @@ -69,10 +69,12 @@ class NOT; class AY_3_891X; class Z80; -class JOYSTICK; -class KEYBOARD; -class PHC25_MEMORY; -class PHC25_SYSTEM; +namespace PHC25 { + class JOYSTICK; + class KEYBOARD; + class MEMORY; + class SYSTEM; +} class VM : public VM_TEMPLATE { @@ -91,10 +93,10 @@ protected: AY_3_891X* psg; Z80* cpu; - JOYSTICK* joystick; - KEYBOARD* keyboard; - PHC25_MEMORY* memory; - PHC25_SYSTEM* system; + PHC25::JOYSTICK* joystick; + PHC25::KEYBOARD* keyboard; + PHC25::MEMORY* memory; + PHC25::SYSTEM* system; public: // ---------------------------------------- diff --git a/source/src/vm/phc25/system.cpp b/source/src/vm/phc25/system.cpp index 2a6e4734f..d024d779f 100644 --- a/source/src/vm/phc25/system.cpp +++ b/source/src/vm/phc25/system.cpp @@ -12,17 +12,19 @@ #include "../datarec.h" #include "../mc6847.h" -void PHC25_SYSTEM::initialize() +namespace PHC25 { + +void SYSTEM::initialize() { sysport = 0; } -void PHC25_SYSTEM::reset() +void SYSTEM::reset() { d_vdp->write_signal(SIG_MC6847_INTEXT, 1, 1); } -void PHC25_SYSTEM::write_io8(uint32_t addr, uint32_t data) +void SYSTEM::write_io8(uint32_t addr, uint32_t data) { d_drec->write_signal(SIG_DATAREC_MIC, data, 0x01); d_drec->write_signal(SIG_DATAREC_REMOTE, ~data, 0x02); @@ -33,60 +35,19 @@ void PHC25_SYSTEM::write_io8(uint32_t addr, uint32_t data) d_vdp->write_signal(SIG_MC6847_AG, data, 0x80); } -uint32_t PHC25_SYSTEM::read_io8(uint32_t addr) +uint32_t SYSTEM::read_io8(uint32_t addr) { return sysport; } -void PHC25_SYSTEM::write_signal(int id, uint32_t data, uint32_t mask) +void SYSTEM::write_signal(int id, uint32_t data, uint32_t mask) { sysport = (sysport & ~mask) | (data & mask); } #define STATE_VERSION 1 -#include "../../statesub.h" - -void PHC25_SYSTEM::decl_state() -{ - enter_decl_state(STATE_VERSION); - - DECL_STATE_ENTRY_UINT8(sysport); - - leave_decl_state(); -} - -void PHC25_SYSTEM::save_state(FILEIO* state_fio) -{ - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); - -// state_fio->FputUint8(sysport); -} - -bool PHC25_SYSTEM::load_state(FILEIO* state_fio) -{ - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - return false; - } -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -// sysport = state_fio->FgetUint8(); - return true; -} - -bool PHC25_SYSTEM::process_state(FILEIO* state_fio, bool loading) +bool SYSTEM::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; @@ -97,3 +58,5 @@ bool PHC25_SYSTEM::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint8(sysport); return true; } + +} diff --git a/source/src/vm/phc25/system.h b/source/src/vm/phc25/system.h index bf2cdc55f..df1498455 100644 --- a/source/src/vm/phc25/system.h +++ b/source/src/vm/phc25/system.h @@ -17,7 +17,9 @@ #define SIG_SYSTEM_PORT 0 -class PHC25_SYSTEM : public DEVICE +namespace PHC25 { + +class SYSTEM : public DEVICE { private: DEVICE *d_drec, *d_vdp; @@ -25,11 +27,11 @@ private: uint8_t sysport; public: - PHC25_SYSTEM(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) + SYSTEM(VM_TEMPLATE* parent_vm, EMU* parent_emu) : DEVICE(parent_vm, parent_emu) { set_device_name(_T("System I/O")); } - ~PHC25_SYSTEM() {} + ~SYSTEM() {} // common functions void initialize(); @@ -50,5 +52,6 @@ public: } }; +} #endif diff --git a/source/src/vm/qc10/display.cpp b/source/src/vm/qc10/display.cpp index 3203148bd..33e45340e 100644 --- a/source/src/vm/qc10/display.cpp +++ b/source/src/vm/qc10/display.cpp @@ -11,6 +11,8 @@ #include "display.h" #include "../upd7220.h" +namespace QC10 { + void DISPLAY::initialize() { #ifdef _COLOR_MONITOR @@ -307,71 +309,6 @@ void DISPLAY::draw_screen() #define STATE_VERSION 1 -#include "../../statesub.h" - -void DISPLAY::decl_state() -{ - enter_decl_state(STATE_VERSION); - -#ifdef _COLOR_MONITOR - DECL_STATE_ENTRY_1D_ARRAY(vram_r, sizeof(vram_r)); - DECL_STATE_ENTRY_1D_ARRAY(vram_g, sizeof(vram_g)); - DECL_STATE_ENTRY_1D_ARRAY(vram_b, sizeof(vram_b)); -#else - DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram)); -#endif - DECL_STATE_ENTRY_UINT8(bank); - DECL_STATE_ENTRY_INT32(blink); - - leave_decl_state(); -} - -void DISPLAY::save_state(FILEIO* state_fio) -{ - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); - -//#ifdef _COLOR_MONITOR -// state_fio->Fwrite(vram_r, sizeof(vram_r), 1); -// state_fio->Fwrite(vram_g, sizeof(vram_g), 1); -// state_fio->Fwrite(vram_b, sizeof(vram_b), 1); -//#else -// state_fio->Fwrite(vram, sizeof(vram), 1); -//#endif -// state_fio->FputUint8(bank); -// state_fio->FputInt32(blink); -} - -bool DISPLAY::load_state(FILEIO* state_fio) -{ - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - return false; - } -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -//#ifdef _COLOR_MONITOR -// state_fio->Fread(vram_r, sizeof(vram_r), 1); -// state_fio->Fread(vram_g, sizeof(vram_g), 1); -// state_fio->Fread(vram_b, sizeof(vram_b), 1); -//#else -// state_fio->Fread(vram, sizeof(vram), 1); -//#endif -// bank = state_fio->FgetUint8(); -// blink = state_fio->FgetInt32(); - return true; -} - bool DISPLAY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { @@ -391,3 +328,5 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading) state_fio->StateInt32(blink); return true; } + +} diff --git a/source/src/vm/qc10/display.h b/source/src/vm/qc10/display.h index 3eb965b09..576b8193e 100644 --- a/source/src/vm/qc10/display.h +++ b/source/src/vm/qc10/display.h @@ -18,6 +18,8 @@ class UPD7220; +namespace QC10 { + class DISPLAY : public DEVICE { private: @@ -54,9 +56,7 @@ public: void write_io8(uint32_t addr, uint32_t data); uint32_t read_io8(uint32_t addr); void event_frame(); - void decl_state(); - 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_gdc(UPD7220* device) @@ -94,5 +94,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/qc10/floppy.cpp b/source/src/vm/qc10/floppy.cpp index 1e643a3c1..ccb7ecb03 100644 --- a/source/src/vm/qc10/floppy.cpp +++ b/source/src/vm/qc10/floppy.cpp @@ -11,9 +11,12 @@ #include "memory.h" #include "../upd765a.h" +namespace QC10 { + void FLOPPY::write_io8(uint32_t addr, uint32_t data) { d_fdc->write_signal(SIG_UPD765A_MOTOR, 1, 1); d_mem->write_signal(SIG_MEMORY_MOTOR, 1, 1); } +} diff --git a/source/src/vm/qc10/floppy.h b/source/src/vm/qc10/floppy.h index 994417701..5d70b3c19 100644 --- a/source/src/vm/qc10/floppy.h +++ b/source/src/vm/qc10/floppy.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace QC10 { + class FLOPPY : public DEVICE { private: @@ -40,5 +42,6 @@ public: } }; +} #endif diff --git a/source/src/vm/qc10/keyboard.cpp b/source/src/vm/qc10/keyboard.cpp index 09797d13c..920dc1c2b 100644 --- a/source/src/vm/qc10/keyboard.cpp +++ b/source/src/vm/qc10/keyboard.cpp @@ -26,6 +26,8 @@ SHIFT + F4 -> VK_F24 */ +namespace QC10 { + // pc key code -> qc-10 key code static const int key_map[256] = { 0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00, 0x6d,0x77,0x00,0x00, 0x00,0x4e,0x00,0x00, // 0 @@ -148,53 +150,6 @@ void KEYBOARD::process_cmd(uint8_t val) #define STATE_VERSION 1 -#include "../../statesub.h" - -void KEYBOARD::decl_state() -{ - enter_decl_state(STATE_VERSION); - - DECL_STATE_ENTRY_1D_ARRAY(led, sizeof(led) / sizeof(bool)); - DECL_STATE_ENTRY_BOOL(repeat); - DECL_STATE_ENTRY_BOOL(enable); - - leave_decl_state(); -} - -void KEYBOARD::save_state(FILEIO* state_fio) -{ - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); - -// state_fio->Fwrite(led, sizeof(led), 1); -// state_fio->FputBool(repeat); -// state_fio->FputBool(enable); -} - -bool KEYBOARD::load_state(FILEIO* state_fio) -{ - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - return false; - } -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -// state_fio->Fread(led, sizeof(led), 1); -// repeat = state_fio->FgetBool(); -// enable = state_fio->FgetBool(); - return true; -} - bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { @@ -203,8 +158,13 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) if(!state_fio->StateCheckInt32(this_device_id)) { return false; } - state_fio->StateBuffer(led, sizeof(led), 1); + //state_fio->StateBuffer(led, sizeof(led), 1); + for(int i = 0; i < 8; i++) { + state_fio->StateBool(led[i]); + } state_fio->StateBool(repeat); state_fio->StateBool(enable); return true; } + +} diff --git a/source/src/vm/qc10/keyboard.h b/source/src/vm/qc10/keyboard.h index 82fe073fe..30601b438 100644 --- a/source/src/vm/qc10/keyboard.h +++ b/source/src/vm/qc10/keyboard.h @@ -16,6 +16,8 @@ #define SIG_KEYBOARD_RECV 0 +namespace QC10 { + class KEYBOARD : public DEVICE { private: @@ -36,9 +38,7 @@ public: // common functions void initialize(); void write_signal(int id, uint32_t data, uint32_t mask); - void decl_state(); - 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_sio(DEVICE* device) @@ -49,4 +49,5 @@ public: void key_up(int code); }; +} #endif diff --git a/source/src/vm/qc10/memory.cpp b/source/src/vm/qc10/memory.cpp index 5adab54c6..05b19120f 100644 --- a/source/src/vm/qc10/memory.cpp +++ b/source/src/vm/qc10/memory.cpp @@ -12,7 +12,9 @@ #include "../pcm1bit.h" #include "../upd765a.h" -#define SET_BANK(s, e, w, r) { \ +namespace QC10 { + +#define SET_BANK(s, e, w, r) { \ int sb = (s) >> 11, eb = (e) >> 11; \ for(int i = sb; i <= eb; i++) { \ wbank[i] = (w) + 0x800 * (i - sb); \ @@ -182,80 +184,6 @@ void MEMORY::update_pcm() #define STATE_VERSION 1 -#include "../../statesub.h" - -void MEMORY::decl_state() -{ - enter_decl_state(STATE_VERSION); - - DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram)); - DECL_STATE_ENTRY_1D_ARRAY(cmos, sizeof(cmos)); - DECL_STATE_ENTRY_UINT32(cmos_crc32); - DECL_STATE_ENTRY_UINT8(bank); - DECL_STATE_ENTRY_UINT8(psel); - DECL_STATE_ENTRY_UINT8(csel); - DECL_STATE_ENTRY_BOOL(pcm_on); - DECL_STATE_ENTRY_BOOL(pcm_cont); - DECL_STATE_ENTRY_BOOL(pcm_pit); - DECL_STATE_ENTRY_BOOL(fdc_irq); - DECL_STATE_ENTRY_BOOL(motor); - - leave_decl_state(); -} - -void MEMORY::save_state(FILEIO* state_fio) -{ - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); - -// state_fio->Fwrite(ram, sizeof(ram), 1); -// state_fio->Fwrite(cmos, sizeof(cmos), 1); -// state_fio->FputUint32(cmos_crc32); -// state_fio->FputUint8(bank); -// state_fio->FputUint8(psel); -// state_fio->FputUint8(csel); -// state_fio->FputBool(pcm_on); -// state_fio->FputBool(pcm_cont); -// state_fio->FputBool(pcm_pit); -// state_fio->FputBool(fdc_irq); -// state_fio->FputBool(motor); -} - -bool MEMORY::load_state(FILEIO* state_fio) -{ - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - return false; - } -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -// state_fio->Fread(ram, sizeof(ram), 1); -// state_fio->Fread(cmos, sizeof(cmos), 1); -// cmos_crc32 = state_fio->FgetUint32(); -// bank = state_fio->FgetUint8(); -// psel = state_fio->FgetUint8(); -// csel = state_fio->FgetUint8(); -// pcm_on = state_fio->FgetBool(); -// pcm_cont = state_fio->FgetBool(); -// pcm_pit = state_fio->FgetBool(); -// fdc_irq = state_fio->FgetBool(); -// motor = state_fio->FgetBool(); - - // post process - update_map(); - return true; -} - bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { @@ -282,3 +210,5 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/qc10/memory.h b/source/src/vm/qc10/memory.h index f059c66bd..5a76b82c4 100644 --- a/source/src/vm/qc10/memory.h +++ b/source/src/vm/qc10/memory.h @@ -20,6 +20,8 @@ class UPD765A; +namespace QC10 { + class MEMORY : public DEVICE { private: @@ -58,9 +60,7 @@ public: void write_io8(uint32_t addr, uint32_t data); uint32_t read_io8(uint32_t addr); void write_signal(int id, uint32_t data, uint32_t mask); - void decl_state(); - 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_pit(DEVICE* device) @@ -77,5 +77,6 @@ public: } }; +} #endif diff --git a/source/src/vm/qc10/mfont.cpp b/source/src/vm/qc10/mfont.cpp index 2477c8ad3..55913509f 100644 --- a/source/src/vm/qc10/mfont.cpp +++ b/source/src/vm/qc10/mfont.cpp @@ -15,6 +15,8 @@ #define BIT_ERR 2 #define BIT_OBF 1 +namespace QC10 { + void MFONT::initialize() { memset(mfont, 0xff, sizeof(mfont)); @@ -94,57 +96,6 @@ uint32_t MFONT::read_io8(uint32_t addr) #define STATE_VERSION 1 -#include "../../statesub.h" - -void MFONT::decl_state() -{ - enter_decl_state(STATE_VERSION); - - DECL_STATE_ENTRY_UINT8(status); - DECL_STATE_ENTRY_FIFO(cmd); - DECL_STATE_ENTRY_FIFO(res); - - leave_decl_state(); -} - -void MFONT::save_state(FILEIO* state_fio) -{ - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); - -// state_fio->FputUint8(status); -// cmd->save_state((void *)state_fio); -// res->save_state((void *)state_fio); -} - -bool MFONT::load_state(FILEIO* state_fio) -{ - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - return false; - } -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -// status = state_fio->FgetUint8(); -// if(!cmd->load_state((void *)state_fio)) { -// return false; -// } -// if(!res->load_state((void *)state_fio)) { -// return false; -// } - return true; -} - bool MFONT::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { @@ -162,3 +113,5 @@ bool MFONT::process_state(FILEIO* state_fio, bool loading) } return true; } + +} diff --git a/source/src/vm/qc10/mfont.h b/source/src/vm/qc10/mfont.h index 4fe6e4d6e..69c063342 100644 --- a/source/src/vm/qc10/mfont.h +++ b/source/src/vm/qc10/mfont.h @@ -16,6 +16,8 @@ class FIFO; +namespace QC10 { + class MFONT : public DEVICE { private: @@ -38,9 +40,7 @@ public: void release(); void write_io8(uint32_t addr, uint32_t data); uint32_t read_io8(uint32_t addr); - void decl_state(); - void save_state(FILEIO* state_fio); - bool load_state(FILEIO* state_fio); + bool process_state(FILEIO* state_fio, bool loading); // unique function void set_context_pic(DEVICE* device) @@ -49,5 +49,6 @@ public: } }; +} #endif diff --git a/source/src/vm/qc10/qc10.cpp b/source/src/vm/qc10/qc10.cpp index e5bfee6ce..5de7c588b 100644 --- a/source/src/vm/qc10/qc10.cpp +++ b/source/src/vm/qc10/qc10.cpp @@ -36,6 +36,12 @@ #include "memory.h" #include "mfont.h" +using QC10::DISPLAY; +using QC10::FLOPPY; +using QC10::KEYBOARD; +using QC10::MEMORY; +using QC10::MFONT; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -174,7 +180,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) for(DEVICE* device = first_device; device; device = device->next_device) { device->initialize(); } - decl_state(); //pcm->set_realtime_render(true); for(int i = 0; i < 4; i++) { fdc->set_drive_type(i, DRIVE_TYPE_2D); @@ -345,73 +350,37 @@ void VM::update_config() #define STATE_VERSION 3 -#include "../../statesub.h" -#include "../../qt/gui/csp_logger.h" -extern CSP_Logger DLL_PREFIX_I *csp_logger; - -void VM::decl_state(void) -{ -#ifdef _COLOR_MONITOR - state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::QC_10_WITH_COLOR_MONITOR_HEAD")), csp_logger); -#else - state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::QC_10_HEAD")), csp_logger); -#endif - for(DEVICE* device = first_device; device; device = device->next_device) { - device->decl_state(); - } -} - -void VM::save_state(FILEIO* state_fio) -{ - //state_fio->FputUint32(STATE_VERSION); - - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } - for(DEVICE* device = first_device; device; device = device->next_device) { - device->save_state(state_fio); - } -} - -bool VM::load_state(FILEIO* state_fio) -{ - //if(state_fio->FgetUint32() != STATE_VERSION) { - // return false; - //} - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - emu->out_debug_log("INFO: HEADER DATA ERROR"); - return false; - } - for(DEVICE* device = first_device; device; device = device->next_device) { - if(!device->load_state(state_fio)) { - return false; - } - } - return true; -} - bool VM::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; } - for(DEVICE* device = first_device; device; device = device->next_device) { - const char *name = typeid(*device).name() + 6; // skip "class " + for(DEVICE* device = first_device; device; device = device->next_device) { + // Note: typeid(foo).name is fixed by recent ABI.Not dec 6. + // const char *name = typeid(*device).name(); + // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O + const char *name = device->get_device_name(); int len = strlen(name); if(!state_fio->StateCheckInt32(len)) { + if(loading) { + printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name); + } return false; } if(!state_fio->StateCheckBuffer(name, len, 1)) { - return false; - } + if(loading) { + printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name); + } + return false; + } if(!device->process_state(state_fio, loading)) { - return false; - } - } + if(loading) { + printf("Data loading Error: DEVID=%d\n", device->this_device_id); + } + return false; + } + } + // Machine specified. return true; } diff --git a/source/src/vm/qc10/qc10.h b/source/src/vm/qc10/qc10.h index 89e7ae91a..5a821a4ae 100644 --- a/source/src/vm/qc10/qc10.h +++ b/source/src/vm/qc10/qc10.h @@ -65,8 +65,6 @@ static const _TCHAR *sound_device_caption[] = { }; #endif -class csp_state_utils; - class EMU; class DEVICE; class EVENT; @@ -83,12 +81,14 @@ class UPD765A; class Z80; class Z80SIO; -class DISPLAY; -class FLOPPY; -class KEYBOARD; -class MEMORY; -class MFONT; - +namespace QC10 { + class DISPLAY; + class FLOPPY; + class KEYBOARD; + class MEMORY; + class MFONT; +} + class VM : public VM_TEMPLATE { protected: @@ -112,11 +112,11 @@ protected: Z80* cpu; Z80SIO* sio; - DISPLAY* display; - FLOPPY* floppy; - KEYBOARD* keyboard; - MEMORY* memory; - MFONT* mfont; + QC10::DISPLAY* display; + QC10::FLOPPY* floppy; + QC10::KEYBOARD* keyboard; + QC10::MEMORY* memory; + QC10::MFONT* mfont; public: // ---------------------------------------- @@ -165,9 +165,7 @@ public: bool is_frame_skippable(); void update_config(); - void decl_state(); - void save_state(FILEIO* state_fio); - bool load_state(FILEIO* state_fio); + bool process_state(FILEIO* state_fio, bool loading); // ---------------------------------------- // for each device diff --git a/source/src/vm/tk80bs/cmt.cpp b/source/src/vm/tk80bs/cmt.cpp index 8da4c8665..aa58cb00a 100644 --- a/source/src/vm/tk80bs/cmt.cpp +++ b/source/src/vm/tk80bs/cmt.cpp @@ -17,6 +17,8 @@ #define EVENT_PULSE 0 +namespace TK80 { + void CMT::initialize() { mic = ear = pulse = false; @@ -142,108 +144,6 @@ void CMT::release_tape() #define STATE_VERSION 2 -#include "../../statesub.h" - -void CMT::decl_state() -{ - enter_decl_state(STATE_VERSION); - - DECL_STATE_ENTRY_BOOL(mic); - DECL_STATE_ENTRY_BOOL(ear); - DECL_STATE_ENTRY_BOOL(pulse); - DECL_STATE_ENTRY_INT32(pulse_count); -#if defined(_TK80BS) - DECL_STATE_ENTRY_BOOL(play); - DECL_STATE_ENTRY_BOOL(rec); - DECL_STATE_ENTRY_STRING(rec_file_path, sizeof(rec_file_path) / sizeof(_TCHAR)); - - DECL_STATE_ENTRY_CMT_RECORDING(fio, rec, rec_file_path); - - DECL_STATE_ENTRY_INT32(bufcnt); - DECL_STATE_ENTRY_1D_ARRAY(buffer, sizeof(buffer)); -#endif - leave_decl_state(); -} - -void CMT::save_state(FILEIO* state_fio) -{ - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); - -// state_fio->FputBool(mic); -// state_fio->FputBool(ear); -// state_fio->FputBool(pulse); -// state_fio->FputInt32(pulse_count); -#if defined(_TK80BS) -// state_fio->FputBool(play); -// state_fio->FputBool(rec); -// state_fio->Fwrite(rec_file_path, sizeof(rec_file_path), 1); -// if(rec && fio->IsOpened()) { -// int length_tmp = (int)fio->Ftell(); -// fio->Fseek(0, FILEIO_SEEK_SET); -// state_fio->FputInt32(length_tmp); -// while(length_tmp != 0) { -// uint8_t buffer_tmp[1024]; -// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp)); -// fio->Fread(buffer_tmp, length_rw, 1); -// state_fio->Fwrite(buffer_tmp, length_rw, 1); -// length_tmp -= length_rw; -// } -// } else { -// state_fio->FputInt32(0); -// } -// state_fio->FputInt32(bufcnt); -// state_fio->Fwrite(buffer, sizeof(buffer), 1); -#endif -} - -bool CMT::load_state(FILEIO* state_fio) -{ - release_tape(); - - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - return false; - } -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -// mic = state_fio->FgetBool(); -// ear = state_fio->FgetBool(); -// pulse = state_fio->FgetBool(); -// pulse_count = state_fio->FgetInt32(); -//#if defined(_TK80BS) -// play = state_fio->FgetBool(); -// rec = state_fio->FgetBool(); -// state_fio->Fread(rec_file_path, sizeof(rec_file_path), 1); -// int length_tmp = state_fio->FgetInt32(); -// if(rec) { -// fio->Fopen(rec_file_path, FILEIO_READ_WRITE_NEW_BINARY); -// while(length_tmp != 0) { -// uint8_t buffer_tmp[1024]; -// int length_rw = min(length_tmp, (int)sizeof(buffer_tmp)); -// state_fio->Fread(buffer_tmp, length_rw, 1); -// if(fio->IsOpened()) { -// fio->Fwrite(buffer_tmp, length_rw, 1); -// } -// length_tmp -= length_rw; -// } -// } -// bufcnt = state_fio->FgetInt32(); -// state_fio->Fread(buffer, sizeof(buffer), 1); -//#endif - return true; -} - bool CMT::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { @@ -295,3 +195,5 @@ bool CMT::process_state(FILEIO* state_fio, bool loading) #endif return true; } + +} diff --git a/source/src/vm/tk80bs/cmt.h b/source/src/vm/tk80bs/cmt.h index 7e26cfcd6..c772edf1b 100644 --- a/source/src/vm/tk80bs/cmt.h +++ b/source/src/vm/tk80bs/cmt.h @@ -24,6 +24,8 @@ // max 256kbytes #define BUFFER_SIZE 0x40000 +namespace TK80 { + class CMT : public DEVICE { private: @@ -61,9 +63,7 @@ public: #endif void write_signal(int id, uint32_t data, uint32_t mask); void event_callback(int event_id, int err); - void decl_state(); - 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_drec(DEVICE* device) @@ -101,5 +101,6 @@ public: #endif }; +} #endif diff --git a/source/src/vm/tk80bs/display.cpp b/source/src/vm/tk80bs/display.cpp index c54379e77..28a4d7b76 100644 --- a/source/src/vm/tk80bs/display.cpp +++ b/source/src/vm/tk80bs/display.cpp @@ -11,6 +11,8 @@ #include "display.h" +namespace TK80 { + static const int led_pattern[LED_SIZE_Y][LED_SIZE_X] = { #if defined(_TK80BS) || defined(_TK80) {9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9}, @@ -210,56 +212,6 @@ void DISPLAY::draw_screen() #define STATE_VERSION 1 -#include "../../statesub.h" - -void DISPLAY::decl_state() -{ - enter_decl_state(STATE_VERSION); - -#if defined(_TK80BS) - DECL_STATE_ENTRY_INT32(mode); -#endif - DECL_STATE_ENTRY_BOOL(dma); - - leave_decl_state(); -} - -void DISPLAY::save_state(FILEIO* state_fio) -{ - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); -// -//#if defined(_TK80BS) -// state_fio->FputInt32(mode); -//#endif -// state_fio->FputBool(dma); -} - -bool DISPLAY::load_state(FILEIO* state_fio) -{ - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - return false; - } -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -//#if defined(_TK80BS) -// mode = state_fio->FgetInt32(); -//#endif -// dma = state_fio->FgetBool(); - return true; -} - bool DISPLAY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { @@ -274,3 +226,5 @@ bool DISPLAY::process_state(FILEIO* state_fio, bool loading) state_fio->StateBool(dma); return true; } + +} diff --git a/source/src/vm/tk80bs/display.h b/source/src/vm/tk80bs/display.h index d9822ae70..9262e5daa 100644 --- a/source/src/vm/tk80bs/display.h +++ b/source/src/vm/tk80bs/display.h @@ -19,6 +19,8 @@ #define SIG_DISPLAY_MODE 0 #define SIG_DISPLAY_DMA 1 +namespace TK80 { + class DISPLAY : public DEVICE { private: @@ -40,9 +42,7 @@ public: // common functions void initialize(); void write_signal(int id, uint32_t data, uint32_t mask); - void decl_state(); - void save_state(FILEIO* state_fio); - bool load_state(FILEIO* state_fio); + bool process_state(FILEIO* state_fio, bool loading); // unique functions #if defined(_TK80BS) @@ -58,5 +58,6 @@ public: void draw_screen(); }; +} #endif diff --git a/source/src/vm/tk80bs/keyboard.cpp b/source/src/vm/tk80bs/keyboard.cpp index 69ae962c5..b2ac7f89e 100644 --- a/source/src/vm/tk80bs/keyboard.cpp +++ b/source/src/vm/tk80bs/keyboard.cpp @@ -12,6 +12,8 @@ #include "keyboard.h" #include "../i8255.h" +namespace TK80 { + #if defined(_TK80BS) static const uint8_t matrix[256] = { 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x08,0x00,0x00,0x00,0x00,0x0a,0x00,0x00, @@ -283,68 +285,6 @@ void KEYBOARD::update_tk80() #define STATE_VERSION 2 -#include "../../statesub.h" - -void KEYBOARD::decl_state() -{ - enter_decl_state(STATE_VERSION); - -#if defined(_TK80BS) - DECL_STATE_ENTRY_UINT8(prev_type); - DECL_STATE_ENTRY_UINT8(prev_brk); - DECL_STATE_ENTRY_UINT8(prev_kana); - DECL_STATE_ENTRY_BOOL(kana_lock); - DECL_STATE_ENTRY_UINT32(kb_type); -#endif - DECL_STATE_ENTRY_UINT32(column); - - leave_decl_state(); -} - -void KEYBOARD::save_state(FILEIO* state_fio) -{ - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); - -//#if defined(_TK80BS) -// state_fio->FputUint8(prev_type); -// state_fio->FputUint8(prev_brk); -// state_fio->FputUint8(prev_kana); -// state_fio->FputBool(kana_lock); -// state_fio->FputUint32(kb_type); -//#endif -// state_fio->FputUint32(column); -} - -bool KEYBOARD::load_state(FILEIO* state_fio) -{ - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - return false; - } -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -//#if defined(_TK80BS) -// prev_type = state_fio->FgetUint8(); -// prev_brk = state_fio->FgetUint8(); -// prev_kana = state_fio->FgetUint8(); -// kana_lock = state_fio->FgetBool(); -// kb_type = state_fio->FgetUint32(); -//#endif -// column = state_fio->FgetUint32(); - return true; -} - bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { @@ -363,3 +303,5 @@ bool KEYBOARD::process_state(FILEIO* state_fio, bool loading) state_fio->StateUint32(column); return true; } + +} diff --git a/source/src/vm/tk80bs/keyboard.h b/source/src/vm/tk80bs/keyboard.h index bb3304625..d2fcf06d7 100644 --- a/source/src/vm/tk80bs/keyboard.h +++ b/source/src/vm/tk80bs/keyboard.h @@ -18,6 +18,8 @@ #define SIG_KEYBOARD_COLUMN 0 +namespace TK80 { + class KEYBOARD : public DEVICE { private: @@ -54,9 +56,7 @@ public: return kb_type & 3; } #endif - void decl_state(); - void save_state(FILEIO* state_fio); - bool load_state(FILEIO* state_fio); + bool process_state(FILEIO* state_fio, bool loading); // unique functions #if defined(_TK80BS) @@ -90,5 +90,6 @@ public: } }; +} #endif diff --git a/source/src/vm/tk80bs/membus.cpp b/source/src/vm/tk80bs/membus.cpp index 3aecc1b80..08d4726b5 100644 --- a/source/src/vm/tk80bs/membus.cpp +++ b/source/src/vm/tk80bs/membus.cpp @@ -12,6 +12,8 @@ #include "membus.h" #include "../i8080.h" +namespace TK80 { + void MEMBUS::reset() { #if defined(_TK85) @@ -51,47 +53,6 @@ void MEMBUS::write_signal(int id, uint32_t data, uint32_t mask) #define STATE_VERSION 1 -#include "../../statesub.h" - -void MEMBUS::decl_state() -{ - enter_decl_state(STATE_VERSION); - -#if defined(_TK85) - DECL_STATE_ENTRY_UINT32(pc7); - DECL_STATE_ENTRY_UINT32(count); -#endif - MEMORY::decl_state(); - - leave_decl_state(); -} - -void MEMBUS::save_state(FILEIO* state_fio) -{ -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); - -//#if defined(_TK85) -// state_fio->FputUint32(pc7); -// state_fio->FputUint32(count); -//#endif - MEMORY::save_state(state_fio); -} - -bool MEMBUS::load_state(FILEIO* state_fio) -{ -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -//#if defined(_TK85) -// pc7 = state_fio->FgetUint32(); -// count = state_fio->FgetUint32(); -//#endif - return MEMORY::load_state(state_fio); -} bool MEMBUS::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { @@ -106,3 +67,5 @@ bool MEMBUS::process_state(FILEIO* state_fio, bool loading) #endif return MEMORY::process_state(state_fio, loading); } + +} diff --git a/source/src/vm/tk80bs/membus.h b/source/src/vm/tk80bs/membus.h index 98465c1d3..8bf0edbac 100644 --- a/source/src/vm/tk80bs/membus.h +++ b/source/src/vm/tk80bs/membus.h @@ -19,14 +19,13 @@ #endif //class csp_state_utils; +namespace TK80 { class MEMBUS : public MEMORY { private: DEVICE *d_cpu; -// csp_state_utils *state_entry; - #if defined(_TK85) uint32_t pc7, count; #endif @@ -44,9 +43,7 @@ public: #if defined(_TK85) void write_signal(int id, uint32_t data, uint32_t mask); #endif - void decl_state(); - void save_state(FILEIO* state_fio); - bool load_state(FILEIO* state_fio); + bool process_state(FILEIO* state_fio, bool loading); // unique function void set_context_cpu(DEVICE* device) @@ -55,4 +52,6 @@ public: } }; +} + #endif diff --git a/source/src/vm/tk80bs/memory.cpp b/source/src/vm/tk80bs/memory.cpp index 63c6c179e..1b8f0b85f 100644 --- a/source/src/vm/tk80bs/memory.cpp +++ b/source/src/vm/tk80bs/memory.cpp @@ -10,9 +10,11 @@ // AUTO/STEPƒXƒCƒbƒ`‚Ì‚½‚ß‚ÉŽÀ‘•’†‚̃\[ƒX // ŽÀÛ‚ÉŽg—p‚·‚é‚©‚Í–¢’è -#include "memory.h" +#include "./memory.h" #include "../i8080.h" +namespace TK80 { + #define SET_BANK(s, e, w, r) { \ int sb = (s) >> 9, eb = (e) >> 9; \ for(int i = sb; i <= eb; i++) { \ @@ -161,47 +163,6 @@ void MEMORY::save_binary(const _TCHAR* file_path) #define STATE_VERSION 1 -void MEMORY::decl_state(FILEIO* state_fio) -{ - // enter_decl_state(STATE_VERSION); - - DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram)); - DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram)); - // leave_decl_state(); -} - -void MEMORY::save_state(FILEIO* state_fio) -{ - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } -// state_fio->FputUint32(STATE_VERSION); -// state_fio->FputInt32(this_device_id); - -// state_fio->Fwrite(ram, sizeof(ram), 1); -// state_fio->Fwrite(vram, sizeof(vram), 1); -} - -bool MEMORY::load_state(FILEIO* state_fio) -{ - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - return false; - } -// if(state_fio->FgetUint32() != STATE_VERSION) { -// return false; -// } -// if(state_fio->FgetInt32() != this_device_id) { -// return false; -// } -// state_fio->Fread(ram, sizeof(ram), 1); -// state_fio->Fread(vram, sizeof(vram), 1); - return true; -} - bool MEMORY::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { @@ -214,3 +175,5 @@ bool MEMORY::process_state(FILEIO* state_fio, bool loading) state_fio->StateBuffer(vram, sizeof(vram), 1); return true; } + +} diff --git a/source/src/vm/tk80bs/memory.h b/source/src/vm/tk80bs/memory.h index 69d0563cc..1ce2f86d4 100644 --- a/source/src/vm/tk80bs/memory.h +++ b/source/src/vm/tk80bs/memory.h @@ -14,6 +14,8 @@ #include "../../emu.h" #include "../device.h" +namespace TK80 { + class MEMORY : public DEVICE { private: @@ -46,9 +48,7 @@ public: void write_data8(uint32_t addr, uint32_t data); uint32_t read_data8(uint32_t addr); uint32_t fetch_op(uint32_t addr, int *wait); - virtual void decl_state(); - virtual void save_state(FILEIO* state_fio); - virtual bool load_state(FILEIO* state_fio); + virtual bool process_state(FILEIO* state_fio, bool loading); // unique functions void set_context_cpu(DEVICE* device) @@ -71,5 +71,6 @@ public: void save_binary(const _TCHAR* file_path); }; +} #endif diff --git a/source/src/vm/tk80bs/tk80bs.cpp b/source/src/vm/tk80bs/tk80bs.cpp index 5773ba090..185b7e7ce 100644 --- a/source/src/vm/tk80bs/tk80bs.cpp +++ b/source/src/vm/tk80bs/tk80bs.cpp @@ -36,6 +36,13 @@ #include "keyboard.h" #include "membus.h" +#if defined(_TK80BS) || defined(_TK80) +using TK80::CMT; +#endif +using TK80::DISPLAY; +using TK80::KEYBOARD; +using TK80::MEMBUS; + // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- @@ -208,7 +215,6 @@ VM::VM(EMU* parent_emu) : VM_TEMPLATE(parent_emu) for(DEVICE* device = first_device; device; device = device->next_device) { device->initialize(); } - decl_state(); } VM::~VM() @@ -547,100 +553,38 @@ void VM::update_config() #define STATE_VERSION 6 -#include "../../statesub.h" -#include "../../qt/gui/csp_logger.h" -extern CSP_Logger DLL_PREFIX_I *csp_logger; - -void VM::decl_state(void) -{ -#if defined(_TK80) - state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::TK_80_HEAD")), csp_logger); -#elif defined(_TK85) - state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::TK_85_HEAD")), csp_logger); -#elif defined(_TK80BS) - state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::TK_80BS_HEAD")), csp_logger); -#else - state_entry = new csp_state_utils(STATE_VERSION, 0, (_TCHAR *)(_T("CSP::TK_80_SERIES_HEAD")), csp_logger); -#endif - DECL_STATE_ENTRY_1D_ARRAY(ram, sizeof(ram)); -#if defined(_TK80BS) - DECL_STATE_ENTRY_1D_ARRAY(vram, sizeof(vram)); - DECL_STATE_ENTRY_INT32(boot_mode); - //DECL_STATE_ENTRY_INT32(draw_ranges); -#endif - for(DEVICE* device = first_device; device; device = device->next_device) { - device->decl_state(); - } -} - -void VM::save_state(FILEIO* state_fio) -{ - //state_fio->FputUint32(STATE_VERSION); - - if(state_entry != NULL) { - state_entry->save_state(state_fio); - } - for(DEVICE* device = first_device; device; device = device->next_device) { - device->save_state(state_fio); - } -// state_fio->Fwrite(ram, sizeof(ram), 1); -//#if defined(_TK80BS) -// state_fio->Fwrite(vram, sizeof(vram), 1); -// state_fio->FputInt32(boot_mode); -//// state_fio->FputInt32(draw_ranges); -//#endif -} - -bool VM::load_state(FILEIO* state_fio) -{ - //if(state_fio->FgetUint32() != STATE_VERSION) { - // return false; - //} - bool mb = false; - if(state_entry != NULL) { - mb = state_entry->load_state(state_fio); - } - if(!mb) { - emu->out_debug_log("INFO: HEADER DATA ERROR"); - return false; - } - for(DEVICE* device = first_device; device; device = device->next_device) { - if(!device->load_state(state_fio)) { - return false; - } - } -// state_fio->Fread(ram, sizeof(ram), 1); -#if defined(_TK80BS) -// state_fio->Fread(vram, sizeof(vram), 1); -// boot_mode = state_fio->FgetInt32(); -//// draw_ranges = state_fio->FgetInt32(); - - // post process - emu->reload_bitmap(); - draw_ranges = 8; -#endif - return true; -} - bool VM::process_state(FILEIO* state_fio, bool loading) { if(!state_fio->StateCheckUint32(STATE_VERSION)) { return false; } - for(DEVICE* device = first_device; device; device = device->next_device) { - const char *name = typeid(*device).name() + 6; // skip "class " + for(DEVICE* device = first_device; device; device = device->next_device) { + // Note: typeid(foo).name is fixed by recent ABI.Not dec 6. + // const char *name = typeid(*device).name(); + // But, using get_device_name() instead of typeid(foo).name() 20181008 K.O + const char *name = device->get_device_name(); int len = strlen(name); if(!state_fio->StateCheckInt32(len)) { + if(loading) { + printf("Class name len Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name); + } return false; } if(!state_fio->StateCheckBuffer(name, len, 1)) { - return false; - } + if(loading) { + printf("Class name Error: DEVID=%d EXPECT=%s\n", device->this_device_id, name); + } + return false; + } if(!device->process_state(state_fio, loading)) { - return false; - } - } + if(loading) { + printf("Data loading Error: DEVID=%d\n", device->this_device_id); + } + return false; + } + } + // Machine specified. state_fio->StateBuffer(ram, sizeof(ram), 1); #if defined(_TK80BS) state_fio->StateBuffer(vram, sizeof(vram), 1); diff --git a/source/src/vm/tk80bs/tk80bs.h b/source/src/vm/tk80bs/tk80bs.h index c4b5a6d26..ac2e399e0 100644 --- a/source/src/vm/tk80bs/tk80bs.h +++ b/source/src/vm/tk80bs/tk80bs.h @@ -182,8 +182,6 @@ const struct { #endif }; -class csp_state_utils; - class EMU; class DEVICE; class EVENT; @@ -195,21 +193,22 @@ class I8251; class IO; #endif class I8255; -//class MEMORY; class PCM1BIT; +namespace TK80 { #if defined(_TK80BS) -class CMT; + class CMT; #endif -class DISPLAY; -class KEYBOARD; -class MEMBUS; + //class MEMORY; + class DISPLAY; + class KEYBOARD; + class MEMBUS; +} class VM : public VM_TEMPLATE { protected: //EMU* emu; - //csp_state_utils* state_entry; // devices //EVENT* event; @@ -222,16 +221,16 @@ protected: IO* memio; #endif I8255* pio_t; -// MEMORY* memory; +// TK80::MEMORY* memory; PCM1BIT* pcm0; PCM1BIT* pcm1; #if defined(_TK80BS) - CMT* cmt; + TK80::CMT* cmt; #endif - DISPLAY* display; - KEYBOARD* keyboard; - MEMBUS* memory; + TK80::DISPLAY* display; + TK80::KEYBOARD* keyboard; + TK80::MEMBUS* memory; // memory uint8_t mon[0x800]; @@ -306,9 +305,7 @@ public: bool is_frame_skippable(); void update_config(); - void decl_state(); - void save_state(FILEIO* state_fio); - bool load_state(FILEIO* state_fio); + bool process_state(FILEIO* state_fio, bool loading); // ---------------------------------------- // for each device diff --git a/source/src/vm/x1/x1.cpp b/source/src/vm/x1/x1.cpp index 9378e3a31..a0ba139fb 100644 --- a/source/src/vm/x1/x1.cpp +++ b/source/src/vm/x1/x1.cpp @@ -64,6 +64,7 @@ #if defined(Q_OS_WIN) DLL_PREFIX_I struct cur_time_s cur_time; #endif + using X1::DISPLAY; using X1::EMM; using X1::FLOPPY; @@ -75,7 +76,9 @@ using X1::PSUB; using X1::SASI; using X1::SUB; using X1::KEYBOARD; - +#ifdef _X1TWIN +using PCEDEV::PCE; +#endif // ---------------------------------------------------------------------------- // initialize // ---------------------------------------------------------------------------- diff --git a/source/src/vm/x1/x1.h b/source/src/vm/x1/x1.h index 549335ced..fd45dcf30 100644 --- a/source/src/vm/x1/x1.h +++ b/source/src/vm/x1/x1.h @@ -293,7 +293,9 @@ namespace X1 { #ifdef _X1TWIN class HUC6280; -class PCE; +namespace PCEDEV { + class PCE; +} #define USE_CPU_HUC6280 #endif class VM : public VM_TEMPLATE @@ -350,7 +352,7 @@ protected: EVENT* pceevent; HUC6280* pcecpu; - PCE* pce; + PCEDEV::PCE* pce; #endif public: