{
protected:
//EMU* emu;
- //csp_state_utils* state_entry;
// devices
//EVENT* event;
#if defined(_USE_QT)
class CSP_Logger;
-class csp_state_utils;
-
extern CSP_Logger *csp_logger;
#endif
OSD* osd;
#if defined(_USE_QT)
CSP_Logger *p_logger;
- csp_state_utils *state_entry;
#endif
public:
#if defined(_USE_QT)
osd = emu->get_osd();
p_logger = csp_logger;
- state_entry = NULL;
#else
osd = NULL;
#endif
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() {}
bool mfm;
} fd_format_t;
-class csp_state_utils;
class CSP_Logger;
class FILEIO;
class OSD;
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];
#define SCRN_640x400 1
#define SCRN_640x200 2
+namespace MZ2800 {
+
void CRTC::initialize()
{
// set 16/4096 palette
state_fio->StateBool(trans_init);
return true;
}
+
+}
#define SIG_CRTC_PALLETE 1
#define SIG_CRTC_MASK 2
+namespace MZ2800 {
+
class CRTC : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#include "../mb8877.h"
#include "../disk.h"
+namespace MZ2800 {
+
void FLOPPY::reset()
{
for(int i = 0; i < 4; i++) {
}
}
+}
class MB8877;
+namespace MZ2800 {
+
class FLOPPY : public DEVICE
{
private:
}
};
+}
#endif
#include "joystick.h"
+namespace MZ2800 {
+
void JOYSTICK::initialize()
{
mode = 0xf;
state_fio->StateUint32(mode);
return true;
}
+
+}
#include "../../emu.h"
#include "../device.h"
+namespace MZ2800 {
+
class JOYSTICK : public DEVICE
{
private:
bool process_state(FILEIO* state_fio, bool loading);
};
+}
#endif
#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},
state_fio->StateUint8(column);
return true;
}
+
+}
#define SIG_KEYBOARD_COLUMN 0
+namespace MZ2800 {
+
class KEYBOARD : public DEVICE
{
private:
}
};
+}
#endif
#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++) { \
} \
}
-void MZ2800_MEMORY::initialize()
+void MEMORY::initialize()
{
// init memory
memset(ram, 0, sizeof(ram));
delete fio;
}
-void MZ2800_MEMORY::reset()
+void MEMORY::reset()
{
SET_BANK(0x000000, 0x0bffff, ram, ram);
SET_BANK(0x0c0000, 0x0dffff, vram, vram);
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);
}
}
-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);
}
}
-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:
}
}
-uint32_t MZ2800_MEMORY::read_io8(uint32_t addr)
+uint32_t MEMORY::read_io8(uint32_t addr)
{
switch(addr & 0x7fff) {
case 0x8c:
#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;
}
return true;
}
+
+}
#include "../../emu.h"
#include "../device.h"
-class MZ2800_MEMORY : public DEVICE
+namespace MZ2800 {
+
+class MEMORY : public DEVICE
{
private:
DEVICE* d_crtc;
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();
}
};
+}
#endif
#include "mouse.h"
#include "../z80sio.h"
+namespace MZ2800 {
+
void MOUSE::initialize()
{
stat = emu->get_mouse_buffer();
state_fio->StateBool(select);
return true;
}
+
+}
#define SIG_MOUSE_SEL 0
#define SIG_MOUSE_DTR 1
+namespace MZ2800 {
+
class MOUSE : public DEVICE
{
private:
}
};
+}
#endif
#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
// ----------------------------------------------------------------------------
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);
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
{
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:
// ----------------------------------------
#include "printer.h"
+namespace MZ2800 {
+
void PRINTER::write_io8(uint32_t addr, uint32_t data)
{
switch(addr & 0x7fff) {
return 0xff;
}
+}
#include "../../emu.h"
#include "../device.h"
+namespace MZ2800 {
+
class PRINTER : public DEVICE
{
private:
}
};
+}
#endif
#include "reset.h"
+namespace MZ2800 {
+
void RESET::initialize()
{
prev = 0xff;
state_fio->StateUint8(prev);
return true;
}
+
+}
#define SIG_RESET_CONTROL 0
+namespace MZ2800 {
+
class RESET : public DEVICE
{
private:
bool process_state(FILEIO* state_fio, bool loading);
};
+}
#endif
#define STATUS_ACK 0x40
#define STATUS_REQ 0x80
+namespace MZ2800 {
+
void SASI::reset()
{
control = 0x00;
state_fio->StateBool(drq_status);
return true;
}
+
+}
#define SIG_SASI_IRQ 0
#define SIG_SASI_DRQ 1
+namespace MZ2800 {
+
class SASI : public DEVICE
{
private:
}
};
+}
#endif
#include "serial.h"
#include "../z80sio.h"
+namespace MZ2800 {
+
void SERIAL::reset()
{
addr_a0 = true;
state_fio->StateBool(addr_a0);
return true;
}
+
+}
class Z80SIO;
+namespace MZ2800 {
+
class SERIAL : public DEVICE
{
private:
}
};
+}
#endif
#include "sysport.h"
#include "../i8253.h"
+namespace MZ2800 {
+
void SYSPORT::write_io8(uint32_t addr, uint32_t data)
{
switch(addr & 0x7fff) {
return 0xff;
}
+}
#include "../../emu.h"
#include "../device.h"
+namespace MZ2800 {
+
class SYSPORT : public DEVICE
{
private:
}
};
+}
#endif
// 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,
state_fio->StateBool(pro_mode);
return true;
}
+
+}
class FIFO;
+namespace MZ3500 {
+
class KEYBOARD : public DEVICE
{
private:
}
};
+}
#endif
#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++) { \
}
return true;
}
+
+}
#define SIG_MAIN_DRQ 8
#define SIG_MAIN_INDEX 9
+namespace MZ3500 {
+
class MAIN : public DEVICE
{
private:
}
};
+}
#endif
#include "./sub.h"
#include "keyboard.h"
+using MZ3500::MAIN;
+using MZ3500::SUB;
+using MZ3500::KEYBOARD;
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
class UPD765A;
class Z80;
-class MAIN;
-class SUB;
-class KEYBOARD;
+namespace MZ3500 {
+ class MAIN;
+ class SUB;
+ class KEYBOARD;
+}
class VM : public VM_TEMPLATE
{
IO* mainio;
UPD765A* fdc;
Z80* maincpu;
- MAIN* mainbus;
+ MZ3500::MAIN* mainbus;
// for sub cpu
DEVICE* printer;
UPD7220* gdc_chr;
UPD7220* gdc_gfx;
Z80* subcpu;
- SUB* subbus;
- KEYBOARD* kbd;
+ MZ3500::SUB* subbus;
+ MZ3500::KEYBOARD* kbd;
uint8_t halt;
#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++) { \
state_fio->StateBool(crt_400line);
return true;
}
+
+}
#include "../../emu.h"
#include "../device.h"
+namespace MZ3500 {
+
class SUB : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#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},
state_fio->StateUint8(mode_p);
return true;
}
+
+}
class UPD7220;
+namespace MZ5500 {
+
class DISPLAY : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#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,
state_fio->StateInt32(timeout);
return true;
}
+
+}
class FIFO;
+namespace MZ5500 {
+
class KEYBOARD : public DEVICE
{
private:
}
};
+}
#endif
#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++) { \
} \
}
-void MZ5500_MEMORY::initialize()
+void MEMORY::initialize()
{
// init memory
memset(ram, 0, sizeof(ram));
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)) {
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)) {
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)) {
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)) {
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:
}
}
-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;
}
}
-void MZ5500_MEMORY::update_bank()
+void MEMORY::update_bank()
{
switch(bank1 & 0xe0) {
case 0xe0:
#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;
}
return true;
}
+
+}
#define SIG_MEMORY_BANK 0
-class MZ5500_MEMORY : public DEVICE
+namespace MZ5500 {
+
+class MEMORY : public DEVICE
{
private:
DEVICE* d_cpu;
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();
}
};
+}
#endif
#include "./memory.h"
#include "sysport.h"
+using MZ5500::DISPLAY;
+using MZ5500::KEYBOARD;
+using MZ5500::MEMORY;
+using MZ5500::SYSPORT;
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
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
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
{
#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:
// ----------------------------------------
#include "sysport.h"
+namespace MZ5500 {
+
void SYSPORT::initialize()
{
rst = 0;
state_fio->StateInt32(highden);
return true;
}
+
+}
#include "../../emu.h"
#include "../device.h"
+namespace MZ5500 {
+
class SYSPORT : public DEVICE
{
private:
}
};
+}
#endif
#include "display.h"
#include "../i8259.h"
+namespace N5200 {
+
void DISPLAY::initialize()
{
register_vline_event(this);
emu->screen_skip_line(false);
}
+}
#include "../../emu.h"
#include "../device.h"
+namespace N5200 {
+
class DISPLAY : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#include "floppy.h"
#include "../i8237.h"
+namespace N5200 {
+
void FLOPPY::reset()
{
chgreg = 3;
d_dma->write_signal(dma_ids[chgreg & 1], data, mask);
}
+}
#define SIG_FLOPPY_DRQ 0
+namespace N5200 {
+
class FLOPPY : public DEVICE
{
private:
}
};
+}
#endif
#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,
}
}
+}
#define SIG_KEYBOARD_RST 0
#define SIG_KEYBOARD_RECV 1
+namespace N5200 {
+
class KEYBOARD : public DEVICE
{
private:
}
};
+}
#endif
#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++) { \
} \
}
-void N5200_MEMORY::initialize()
+void MEMORY::initialize()
{
// init memory
memset(ram, 0, sizeof(ram));
delete fio;
}
-void N5200_MEMORY::release()
+void MEMORY::release()
{
// save ram image
FILEIO* fio = new FILEIO();
delete fio;
}
-void N5200_MEMORY::reset()
+void MEMORY::reset()
{
SET_BANK(0x000000, 0xffffff, wdmy, rdmy);
SET_BANK(0x000000, 0x0bffff, ram, ram);
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) {
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:
}
}
-uint32_t N5200_MEMORY::read_io8(uint32_t addr)
+uint32_t MEMORY::read_io8(uint32_t addr)
{
return 0xff;
}
+}
#include "../../emu.h"
#include "../device.h"
-class N5200_MEMORY : public DEVICE
+namespace N5200 {
+
+class MEMORY : public DEVICE
{
private:
uint8_t* rbank[8192]; // 16MB / 2KB
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();
}
};
+}
#endif
#include "./memory.h"
#include "system.h"
+using N5200::DISPLAY;
+using N5200::FLOPPY;
+using N5200::KEYBOARD;
+using N5200::MEMORY;
+using N5200::SYSTEM;
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
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
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
{
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:
// ----------------------------------------
#include "system.h"
#include "../i8237.h"
+namespace N5200 {
+
void SYSTEM::reset()
{
mode = 0;
return 0xff;
}
+}
+
#include "../../emu.h"
#include "../device.h"
+namespace N5200 {
+
class SYSTEM : public DEVICE
{
private:
}
};
+}
#endif
#include "display.h"
+namespace PASOPIA {
+
void DISPLAY::initialize()
{
// load rom image
state_fio->StateUint16(cblink);
return true;
}
+
+}
#define SIG_DISPLAY_I8255_1_A 0
+namespace PASOPIA {
+
class DISPLAY : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#include "floppy.h"
#include "../upd765a.h"
+namespace PASOPIA {
+
void FLOPPY::initialize()
{
intr = false;
state_fio->StateBool(supported);
return true;
}
+
+}
#define SIG_FLOPPY_INTR 0
+namespace PASOPIA {
+
class FLOPPY : public DEVICE
{
private:
bool supported;
};
+}
#endif
#include "joypac2.h"
+namespace PASOPIA {
+
void JOYPAC2::initialize(int id)
{
joy = emu->get_joy_buffer();
return 0xff;
}
+}
#include "../../emu.h"
#include "pac2dev.h"
+namespace PASOPIA {
+
class JOYPAC2 : public PAC2DEV
{
private:
uint32_t read_io8(uint32_t addr);
};
+}
#endif
#include "kanjipac2.h"
+namespace PASOPIA {
+
void KANJIPAC2::initialize(int id)
{
FILEIO* fio = new FILEIO();
state_fio->StateUint32(ptr);
return true;
}
+
+}
#include "../../emu.h"
#include "pac2dev.h"
+namespace PASOPIA {
+
class KANJIPAC2 : public PAC2DEV
{
private:
bool process_state(FILEIO* state_fio, bool loading);
};
+}
#endif
#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 },
state_fio->StateUint8(sel);
return true;
}
+
+}
#define SIG_KEYBOARD_Z80PIO_A 0
+namespace PASOPIA {
+
class KEYBOARD : public DEVICE
{
private:
}
};
+}
#endif
#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++) { \
} \
}
-void PASOPIA_MEMORY::initialize()
+void MEMORY::initialize()
{
// load ipl
memset(rdmy, 0xff, sizeof(rdmy));
vram_data = mem_map = 0;
}
-void PASOPIA_MEMORY::load_ipl()
+void MEMORY::load_ipl()
{
// load ipl
memset(rom, 0xff, sizeof(rom));
}
-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;
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) {
#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;
}
return true;
}
+
+}
#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;
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();
void load_ipl();
};
+}
#endif
#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 *>(vm), emu);
state_fio->StateInt32(device_type);
return get_device()->process_state(state_fio, loading);
}
+
+}
#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)
void open_rampac2(const _TCHAR* file_path);
};
+}
#endif
#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)
_TCHAR this_device_name[128];
};
+}
#endif
#include "./memory.h"
#include "pac2.h"
+using PASOPIA::DISPLAY;
+using PASOPIA::FLOPPY;
+using PASOPIA::KEYBOARD;
+using PASOPIA::MEMORY;
+using PASOPIA::PAC2;
+
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
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);
};
#endif
-class csp_state_utils;
class EMU;
class DEVICE;
class EVENT;
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
{
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;
#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
};
state_fio->StateBool(modified);
return true;
}
+
+}
#include "../../emu.h"
#include "pac2dev.h"
+namespace PASOPIA {
+
class RAMPAC2 : public PAC2DEV
{
private:
bool process_state(FILEIO* state_fio, bool loading);
};
+}
#endif
#include "display.h"
+namespace PASOPIA7 {
+
void DISPLAY::initialize()
{
// load rom image
state_fio->StateBool(pal_dis);
return true;
}
+
+}
#define SIG_DISPLAY_I8255_1_B 1
#define SIG_DISPLAY_I8255_1_C 2
+namespace PASOPIA7 {
+
class DISPLAY : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#include "floppy.h"
#include "../upd765a.h"
+namespace PASOPIA7 {
+
void FLOPPY::initialize()
{
intr = false;
state_fio->StateBool(intr);
return true;
}
+
+}
#define SIG_FLOPPY_INTR 0
+namespace PASOPIA7 {
+
class FLOPPY : public DEVICE
{
private:
}
};
+}
#endif
#include "iobus.h"
+namespace PASOPIA7 {
+
void IOBUS::reset()
{
mio = false;
state_fio->StateBool(mio);
return true;
}
+
+}
#define SIG_IOBUS_MIO 0
+namespace PASOPIA7 {
+
class IOBUS : public DEVICE
{
private:
}
};
+}
+
#endif
#include "iotrap.h"
#include "../i8255.h"
+namespace PASOPIA7 {
+
void IOTRAP::initialize()
{
nmi_mask = pasopia = false;
state_fio->StateBool(pasopia);
return true;
}
+
+}
#define SIG_IOTRAP_I8255_2_A 0
#define SIG_IOTRAP_I8255_2_C 1
+namespace PASOPIA7 {
+
class IOTRAP : public DEVICE
{
private:
void do_reset();
};
+}
#endif
#include "joypac2.h"
+namespace PASOPIA7 {
+
void JOYPAC2::initialize(int id)
{
joy = emu->get_joy_buffer();
return 0xff;
}
+}
#include "../../emu.h"
#include "pac2dev.h"
+namespace PASOPIA7 {
+
class JOYPAC2 : public PAC2DEV
{
private:
uint32_t read_io8(uint32_t addr);
};
+}
#endif
#include "kanjipac2.h"
+namespace PASOPIA7 {
+
void KANJIPAC2::initialize(int id)
{
FILEIO* fio = new FILEIO();
state_fio->StateUint32(ptr);
return true;
}
+
+}
#include "../../emu.h"
#include "pac2dev.h"
+namespace PASOPIA7 {
+
class KANJIPAC2 : public PAC2DEV
{
private:
bool process_state(FILEIO* state_fio, bool loading);
};
+}
#endif
#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 },
state_fio->StateUint8(sel);
return true;
}
+
+}
#define SIG_KEYBOARD_Z80PIO_A 0
+namespace PASOPIA7 {
+
class KEYBOARD : public DEVICE
{
private:
}
};
+}
#endif
#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++) { \
} \
}
-void PASOPIA7_MEMORY::initialize()
+void MEMORY::initialize()
{
memset(bios, 0xff, sizeof(bios));
memset(basic, 0xff, sizeof(basic));
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) {
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) {
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;
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;
}
}
-void PASOPIA7_MEMORY::update_memory_map()
+void MEMORY::update_memory_map()
{
if(mem_map == 0xff) {
SET_BANK(0x0000, 0x3fff, wdmy, bios);
#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;
}
return true;
}
+
+}
#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;
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();
}
};
+}
#endif
#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
}
return true;
}
+
+}
#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
{
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)
void open_rampac2(int drv, const _TCHAR* file_path);
};
+}
#endif
#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)
{
_TCHAR this_device_name[128];
};
+}
#endif
#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
// ----------------------------------------------------------------------------
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
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
{
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:
// ----------------------------------------
#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
};
state_fio->StateBool(modified);
return true;
}
+
+}
#include "../../emu.h"
#include "pac2dev.h"
+namespace PASOPIA7 {
+
class RAMPAC2 : public PAC2DEV
{
private:
bool process_state(FILEIO* state_fio, bool loading);
};
+}
#endif
#include "crtc.h"
#include "../i8259.h"
+namespace PC100 {
+
void CRTC::initialize()
{
// init vram
state_fio->StateUint32(read_plane);
return true;
}
+
+}
#define SIG_CRTC_BITMASK_HIGH 1
#define SIG_CRTC_VRAM_PLANE 2
+namespace PC100 {
+
class CRTC : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#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,
state_fio->StateUint8(ts);
return true;
}
+
+}
class FIFO;
+namespace PC100 {
+
class IOCTRL : public DEVICE
{
private:
}
};
+}
#endif
#include "kanji.h"
+namespace PC100 {
+
void KANJI::initialize()
{
// init image
state_fio->StateBool(strobe);
return true;
}
+
+}
#include "../../emu.h"
#include "../device.h"
+namespace PC100 {
+
class KANJI : public DEVICE
{
private:
bool process_state(FILEIO* state_fio, bool loading);
};
+}
#endif
#include "ioctrl.h"
#include "kanji.h"
+using PC100::CRTC;
+using PC100::IOCTRL;
+using PC100::KANJI;
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
class PCM1BIT;
class UPD765A;
-class CRTC;
-class IOCTRL;
-class KANJI;
+namespace PC100 {
+ class CRTC;
+ class IOCTRL;
+ class KANJI;
+}
class VM : public VM_TEMPLATE
{
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
#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:
}
}
-uint32_t PC2001_IO::read_io8(uint32_t addr)
+uint32_t IO::read_io8(uint32_t addr)
{
uint32_t value = 0xff;
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:
}
}
-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:
}
}
-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;
return data;
}
-bool PC2001_IO::key_hit(int code)
+bool IO::key_hit(int code)
{
bool value = (key_stat[code] != 0);
return value;
#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;
state_fio->StateUint16(key_strobe);
return true;
}
+
+}
class UPD16434;
-class PC2001_IO : public DEVICE
+namespace PC2001 {
+
+class IO : public DEVICE
{
private:
UPD16434 *d_lcd[4];
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();
}
};
+}
#endif
#include "./io.h"
+using PC2001::IO;
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
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);
class UPD1990A;
class UPD7810;
-class PC2001_IO;
+namespace PC2001 {
+ class IO;
+}
class VM : public VM_TEMPLATE
{
protected:
UPD1990A* rtc;
UPD7810* cpu;
- PC2001_IO* io;
+ PC2001::IO* io;
// memory
uint8_t ram[0x5000];
#include "timer.h"
#include "../mc6847.h"
+namespace PC6001 {
+
void DISPLAY::reset()
{
vram_ptr = ram_ptr + 0xe000;
}
return true;
}
+
+}
#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;
{
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
#include "../disk.h"
#include "../noise.h"
+namespace PC6001 {
+
int FLOPPY::Seek88(int drvno, int trackno, int sectno)
{
if(drvno < 2) {
state_fio->StateUint8(Status);
return true;
}
+
+}
class DISK;
class NOISE;
+namespace PC6001 {
+
class FLOPPY : public DEVICE
{
private:
bool is_disk_protected(int drv);
};
+}
#endif
#include "../ay_3_891x.h"
#endif
+namespace PC6001 {
+
void JOYSTICK::initialize()
{
joy_stat = emu->get_joy_buffer();
d_psg->write_signal(SIG_AY_3_891X_PORT_B, ~(joy_stat[1] & 0x1f), 0xff);
#endif
}
+
+}
#include "../../emu.h"
#include "../device.h"
+namespace PC6001 {
+
class JOYSTICK : public DEVICE
{
private:
d_psg = device;
}
};
+
+}
#endif
#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)
#endif
}
-void PC6001_MEMORY::reset()
+void MEMORY::reset()
{
#ifdef _PC6001
int J;
#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) */
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) */
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 },
}
#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;
#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 *>(vm)->sr_mode) {
}
}
-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);
}
#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
}
}
-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)) {
delete fio;
}
-void PC6001_MEMORY::close_cart()
+void MEMORY::close_cart()
{
/// EXTROM1 = EXTROM2 = EmptyRAM;
EXTROM1 = RAM + 0x4000;
#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;
#endif
return true;
}
+
+}
#define SIG_MEMORY_PIO_PORT_C 0
#ifndef _PC6001
-class TIMER;
+namespace PC6001 {
+ class TIMER;
+}
#endif
// memory offset
#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];
#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();
d_cpu = device;
}
#ifndef _PC6001
- void set_context_timer(TIMER* device)
+ void set_context_timer(PC6001::TIMER* device)
{
d_timer = device;
}
}
#endif
};
+
+}
#endif
#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++) {
}
// RefreshScr10: N60-BASIC select function
-void PC6001_MEMORY::RefreshScr10()
+void MEMORY::RefreshScr10()
{
if ((*VRAM&0x80) == 0x00)
RefreshScr11();
}
// RefreshScr11: N60-BASIC screen 1,2
-void PC6001_MEMORY::RefreshScr11()
+void MEMORY::RefreshScr11()
{
uint8_t X,Y,K;
int FC,BC;
}
// RefreshScr13: N60-BASIC screen 3,4
-void PC6001_MEMORY::RefreshScr13()
+void MEMORY::RefreshScr13()
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// 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;
}
// 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;
}
// 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;
}
// 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;
}
// RefreshScr13e: N60-BASIC screen 3,4
-void PC6001_MEMORY::RefreshScr13e() /* 128x192 */
+void MEMORY::RefreshScr13e() /* 128x192 */
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr51: N60m/66-BASIC screen 1,2
-void PC6001_MEMORY::RefreshScr51()
+void MEMORY::RefreshScr51()
{
uint8_t X,Y,K;
int FC,BC;
}
// RefreshScr53: N60m/66-BASIC screen 3
-void PC6001_MEMORY::RefreshScr53()
+void MEMORY::RefreshScr53()
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr54: N60m/66-BASIC screen 4
-void PC6001_MEMORY::RefreshScr54()
+void MEMORY::RefreshScr54()
{
uint8_t X,Y;
uint8_t *T1,*T2;
#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;
}
// RefreshScr62 N66-SR BASIC screen 2
-void PC6001_MEMORY::RefreshScr62()
+void MEMORY::RefreshScr62()
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
// RefreshScr63 N66-SR BASIC screen 3
-void PC6001_MEMORY::RefreshScr63()
+void MEMORY::RefreshScr63()
{
uint8_t X,Y;
uint8_t *T1,*T2;
}
}
-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 ***************************
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;
}
}
-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 \82Ì\90æ\93ª\82©\82Â\81ACRT\82ª 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;
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;
}
#endif
+}
+
#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
// ----------------------------------------------------------------------------
// 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
_T("CMT (Signal)"), _T("Noise (FDD)"), _T("Noise (CMT)"),
};
#endif
-
-class csp_state_utils;
class EMU;
class DEVICE;
class EVENT;
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;
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;
#define EVENT_CASSETTE 0
#define EVENT_STRIG 1
+namespace PC6001 {
+
/* normal (small alphabet) */
uint8_t Keys1[256][2] =
{
state_fio->StateInt32(StrigEventID);
return true;
}
+
+}
class FILEIO;
+namespace PC6001 {
+
class PSUB : public DEVICE
{
private:
void key_down(int code);
void key_up(int code);
};
+
+}
#endif
#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},
state_fio->StateBuffer(buffer, sizeof(buffer), 1);
return true;
}
+
+}
+
class FILEIO;
+namespace PC6001 {
+
class SUB : public DEVICE
{
private:
return rec;
}
};
+
+}
#endif
#define EVENT_TIMER 0
+namespace PC6001 {
+
void TIMER::initialize()
{
#if defined(_PC6601SR) || defined(_PC6001MK2SR)
#endif
return true;
}
+
+}
+
#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;
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
#define SAMPLE_RATE 48000
+namespace PC8201 {
+
void CMT::initialize()
{
fio = new FILEIO();
state_fio->StateUint32(prev_clock);
return true;
}
+
+}
// max 256kbytes
#define BUFFER_SIZE 0x40000
+namespace PC8201 {
+
class CMT : public DEVICE
{
private:
}
};
+}
#endif
#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
state_fio->StateBool(kana);
return true;
}
+
+}
#define SIG_KEYBOARD_COLUMN_L 0
#define SIG_KEYBOARD_COLUMN_H 1
+namespace PC8201 {
+
class KEYBOARD : public DEVICE
{
private:
}
};
+}
#endif
#include "lcd.h"
+namespace PC8201 {
+
void LCD::initialize()
{
memset(seg, 0, sizeof(seg));
state_fio->StateUint16(sel);
return true;
}
+
+}
#define SIG_LCD_CHIPSEL_L 0
#define SIG_LCD_CHIPSEL_H 1
+namespace PC8201 {
+
class LCD : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#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++) { \
} \
}
-void PC8201_MEMORY::initialize()
+void MEMORY::initialize()
{
// init memory
memset(ram, 0, sizeof(ram));
delete fio;
}
-void PC8201_MEMORY::release()
+void MEMORY::release()
{
// save ram image
FILEIO* fio = new FILEIO();
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:
}
}
-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:
#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;
}
return true;
}
+
+}
#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;
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();
}
};
+}
#endif
#include "lcd.h"
#include "./memory.h"
+using PC8201::CMT;
+using PC8201::KEYBOARD;
+using PC8201::LCD;
+using PC8201::MEMORY;
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
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);
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
{
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:
// ----------------------------------------
#include "cmt.h"
#include "../i8251.h"
+namespace PC9801 {
+
void CMT::initialize()
{
fio = new FILEIO();
return true;
}
+}
// max 256kbytes
#define BUFFER_SIZE 0x40000
+namespace PC9801 {
+
class CMT : public DEVICE
{
private:
}
};
+}
#endif
#include "../i286.h"
#endif
+namespace PC9801 {
+
void CPUREG::reset()
{
d_cpu->set_address_mask(0x000fffff);
state_fio->StateBool(nmi_enabled);
return true;
}
+
+}
+
class I286;
#endif
+namespace PC9801 {
+
class CPUREG : public DEVICE
{
private:
}
};
+}
#endif
#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,
return true;
}
+}
class UPD7220;
+namespace PC9801 {
+
class DISPLAY : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#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,
};
}
*/
+
+}
+
#include "../../emu.h"
#include "../device.h"
+namespace PC9801 {
+
class DMAREG : public DEVICE
{
private:
}
};
+}
#endif
#define EVENT_TIMER 0
+namespace PC9801 {
+
void FLOPPY::reset()
{
#if defined(SUPPORT_2HD_FDD_IF)
return true;
}
+}
class UPD765A;
+namespace PC9801 {
+
class FLOPPY : public DEVICE
{
private:
}
};
+}
#endif
// PC-98DO+
#define BOARD_ID 0
+namespace PC9801 {
+
#ifdef SUPPORT_PC98_OPNA
void FMSOUND::reset()
{
}
#endif
+}
#include "../../emu.h"
#include "../device.h"
+namespace PC9801 {
+
class FMSOUND : public DEVICE
{
private:
}
};
+}
#endif
#include "joystick.h"
#include "../ym2203.h"
+namespace PC9801 {
+
void JOYSTICK::initialize()
{
joy_status = emu->get_joy_buffer();
return true;
}
+}
#define SIG_JOYSTICK_SELECT 0
+namespace PC9801 {
+
class JOYSTICK : public DEVICE
{
private:
}
};
+}
#endif
#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,
return true;
}
+}
#define SIG_KEYBOARD_RECV 0
+namespace PC9801 {
+
class KEYBOARD : public DEVICE
{
private:
}
};
+}
#endif
F0000h - FFFFFh: BIOS
*/
+namespace PC9801 {
+
void MEMBUS::initialize()
{
MEMORY::initialize();
}
return true;
}
+
+}
#include "../memory.h"
-class DISPLAY;
-
+namespace PC9801 {
+ class DISPLAY;
+}
#if defined(SUPPORT_32BIT_ADDRESS)
#define RAM_SIZE 0x800000 // 8MB
#elif defined(SUPPORT_24BIT_ADDRESS)
//class csp_state_utils;
+namespace PC9801 {
+
class MEMBUS : public MEMORY
{
private:
}
};
+}
#endif
#define EVENT_TIMER 0
+namespace PC9801 {
+
static const int freq_table[4] = {120, 60, 30, 15};
void MOUSE::initialize()
return true;
}
+}
#define SIG_MOUSE_PORT_C 0
+namespace PC9801 {
+
class MOUSE : public DEVICE
{
private:
}
};
+}
#endif
#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"
#include "../pc8801/pc88.h"
#endif
+#if defined(_PC98DO) || defined(_PC98DOPLUS)
+using PC88DEV::PC88;
+#endif
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
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
#if defined(_PC98DO) || defined(_PC98DOPLUS)
class PC80S31K;
-class PC88;
+namespace PC88DEV {
+ class PC88;
+}
class Z80;
#endif
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
#if defined(_PC98DO) || defined(_PC98DOPLUS)
EVENT* pc88event;
- PC88* pc88;
+ PC88DEV::PC88* pc88;
DEVICE* pc88prn;
I8251* pc88sio;
I8255* pc88pio;
#define ISR_IXO 0x04
#define ISR_INT 0x01
+namespace PC9801 {
+
void SASI::reset()
{
ocr = 0;
return true;
}
+}
+
class SASI_HDD;
+namespace PC9801 {
+
class SASI : public DEVICE
{
private:
}
};
+}
#endif
#include "../upd765a.h"
#include "../disk.h"
+namespace PC98HA {
+
// regs
#define AL regs8[0]
#define AH regs8[1]
}
return false;
}
+
+}
class UPD765A;
+namespace PC98HA {
+
class BIOS : public DEVICE
{
private:
}
};
+}
#endif
#include "../upd1990a.h"
#endif
+namespace PC98HA {
+
void CALENDAR::initialize()
{
#ifdef _PC98HA
}
#endif
+}
#include "../../emu.h"
#include "../device.h"
+namespace PC98HA {
+
class CALENDAR : public DEVICE
{
private:
}
};
+}
#endif
#include "../disk.h"
#include "../upd765a.h"
+namespace PC98HA {
+
void FLOPPY::reset()
{
/*
state_fio->StateUint8(modereg);
return true;
}
+
+}
class UPD765A;
+namespace PC98HA {
+
class FLOPPY : public DEVICE
{
private:
}
};
+}
#endif
#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,
state_fio->StateBuffer(flag, sizeof(flag), 1);
return true;
}
+
+}
#define SIG_KEYBOARD_RECV 0
+namespace PC98HA {
+
class KEYBOARD : public DEVICE
{
private:
}
};
+}
#endif
#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++) { \
} \
}
-void PC98LT_MEMORY::initialize()
+void MEMORY::initialize()
{
// init memory
memset(ram, 0, sizeof(ram));
#endif
}
-void PC98LT_MEMORY::release()
+void MEMORY::release()
{
// save ram images
FILEIO* fio = new FILEIO();
delete fio;
}
-void PC98LT_MEMORY::reset()
+void MEMORY::reset()
{
// set memory bank
learn_bank = dic_bank = kanji_bank = romdrv_bank = 0;
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;
#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
}
}
-uint32_t PC98LT_MEMORY::read_io8(uint32_t addr)
+uint32_t MEMORY::read_io8(uint32_t addr)
{
switch(addr & 0xffff) {
case 0x0c10:
return 0xff;
}
-void PC98LT_MEMORY::update_bank()
+void MEMORY::update_bank()
{
SET_BANK(0x00000, 0xfffff, wdmy, rdmy);
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);
#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;
}
return true;
}
+
+}
#define SIG_MEMORY_IR2 0
-class PC98LT_MEMORY : public DEVICE
+namespace PC98HA {
+
+class MEMORY : public DEVICE
{
private:
uint8_t* rbank[64]; // 1MB / 16KB
#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();
void draw_screen();
};
+}
#endif
#include "note.h"
#include "../i8259.h"
+namespace PC98HA {
+
void NOTE::initialize()
{
ch = 0;
state_fio->StateBuffer(regs, sizeof(regs), 1);
return true;
}
+
+}
+
#include "../../emu.h"
#include "../device.h"
+namespace PC98HA {
+
class NOTE : public DEVICE
{
private:
}
};
+}
#endif
#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
// ----------------------------------------------------------------------------
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);
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
{
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:
// ----------------------------------------
#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 };
#endif
return true;
}
+
+}
class SCSI_CDROM;
#endif
+namespace PCEDEV {
+
class PCE : public DEVICE
{
private:
void draw_screen();
};
+}
#endif
#include "pce.h"
+using PCEDEV::PCE;
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
class MSM5205;
class SCSI_HOST;
class SCSI_CDROM;
-class PCE;
+namespace PCEDEV {
+ class PCE;
+}
class VM : public VM_TEMPLATE
{
protected:
MSM5205* adpcm;
SCSI_HOST* scsi_host;
SCSI_CDROM* scsi_cdrom;
- PCE* pce;
+ PCEDEV::PCE* pce;
public:
// ----------------------------------------
#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 ; /
} \
}
-void PHC20_MEMORY::initialize()
+void MEMORY::initialize()
{
memset(rom, 0xff, sizeof(rom));
memset(rdmy, 0xff, sizeof(rdmy));
register_frame_event(this);
}
-void PHC20_MEMORY::reset()
+void MEMORY::reset()
{
memset(ram, 0, sizeof(ram));
memset(vram, 0, sizeof(vram));
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) {
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) {
return rbank[addr >> 10][addr & 0x3ff];
}
-void PHC20_MEMORY::event_frame()
+void MEMORY::event_frame()
{
memset(status, 0, sizeof(status));
}
}
-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;
#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;
state_fio->StateUint8(sysport);
return true;
}
+
+}
#define SIG_MEMORY_SYSPORT 0
-class PHC20_MEMORY : public DEVICE
+namespace PHC20 {
+
+class MEMORY : public DEVICE
{
private:
DEVICE *d_drec;
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();
}
};
+}
#endif
#include "./memory.h"
+using PHC20::MEMORY;
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
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);
};
#endif
-class csp_state_utils;
-
class EMU;
class DEVICE;
class EVENT;
class MC6847;
class Z80;
-class PHC20_MEMORY;
+namespace PHC20 {
+ class MEMORY;
+}
class VM : public VM_TEMPLATE
{
MC6847* vdp;
Z80* cpu;
- PHC20_MEMORY* memory;
+ PHC20::MEMORY* memory;
public:
// ----------------------------------------
#include "joystick.h"
#include "../ay_3_891x.h"
+namespace PHC25 {
+
void JOYSTICK::initialize()
{
joy_stat = emu->get_joy_buffer();
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);
}
+
+}
#include "../../emu.h"
#include "../device.h"
+namespace PHC25 {
+
class JOYSTICK : public DEVICE
{
private:
}
};
+}
#endif
#include "keyboard.h"
+namespace PHC25 {
+
#ifdef _MAP1010
static const uint8_t key_map[0x50] = {
/*
#endif
return true;
}
+
+}
#include "../../emu.h"
#include "../device.h"
+namespace PHC25 {
+
class KEYBOARD : public DEVICE
{
private:
bool process_state(FILEIO* state_fio, bool loading);
};
+}
#endif
#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++) { \
} \
}
-void PHC25_MEMORY::initialize()
+void MEMORY::initialize()
{
memset(rom, 0xff, sizeof(rom));
memset(rdmy, 0xff, sizeof(rdmy));
#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
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
#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;
state_fio->StateBuffer(vram, sizeof(vram), 1);
return true;
}
+
+}
#include "../../emu.h"
#include "../device.h"
-class PHC25_MEMORY : public DEVICE
+namespace PHC25 {
+
+class MEMORY : public DEVICE
{
private:
DEVICE *d_kbd;
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();
}
};
+}
#endif
#include "./memory.h"
#include "./system.h"
+using PHC25::JOYSTICK;
+using PHC25::KEYBOARD;
+using PHC25::MEMORY;
+using PHC25::SYSTEM;
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
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);
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
{
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:
// ----------------------------------------
#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);
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;
state_fio->StateUint8(sysport);
return true;
}
+
+}
#define SIG_SYSTEM_PORT 0
-class PHC25_SYSTEM : public DEVICE
+namespace PHC25 {
+
+class SYSTEM : public DEVICE
{
private:
DEVICE *d_drec, *d_vdp;
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();
}
};
+}
#endif
#include "display.h"
#include "../upd7220.h"
+namespace QC10 {
+
void DISPLAY::initialize()
{
#ifdef _COLOR_MONITOR
#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)) {
state_fio->StateInt32(blink);
return true;
}
+
+}
class UPD7220;
+namespace QC10 {
+
class DISPLAY : public DEVICE
{
private:
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)
void draw_screen();
};
+}
#endif
#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);
}
+}
#include "../../emu.h"
#include "../device.h"
+namespace QC10 {
+
class FLOPPY : public DEVICE
{
private:
}
};
+}
#endif
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
#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)) {
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;
}
+
+}
#define SIG_KEYBOARD_RECV 0
+namespace QC10 {
+
class KEYBOARD : public DEVICE
{
private:
// 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)
void key_up(int code);
};
+}
#endif
#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); \
#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)) {
}
return true;
}
+
+}
class UPD765A;
+namespace QC10 {
+
class MEMORY : public DEVICE
{
private:
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)
}
};
+}
#endif
#define BIT_ERR 2
#define BIT_OBF 1
+namespace QC10 {
+
void MFONT::initialize()
{
memset(mfont, 0xff, sizeof(mfont));
#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)) {
}
return true;
}
+
+}
class FIFO;
+namespace QC10 {
+
class MFONT : public DEVICE
{
private:
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)
}
};
+}
#endif
#include "memory.h"
#include "mfont.h"
+using QC10::DISPLAY;
+using QC10::FLOPPY;
+using QC10::KEYBOARD;
+using QC10::MEMORY;
+using QC10::MFONT;
+
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
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);
#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;
}
};
#endif
-class csp_state_utils;
-
class EMU;
class DEVICE;
class EVENT;
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:
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:
// ----------------------------------------
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
#define EVENT_PULSE 0
+namespace TK80 {
+
void CMT::initialize()
{
mic = ear = pulse = false;
#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)) {
#endif
return true;
}
+
+}
// max 256kbytes
#define BUFFER_SIZE 0x40000
+namespace TK80 {
+
class CMT : public DEVICE
{
private:
#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)
#endif
};
+}
#endif
#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},
#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)) {
state_fio->StateBool(dma);
return true;
}
+
+}
#define SIG_DISPLAY_MODE 0
#define SIG_DISPLAY_DMA 1
+namespace TK80 {
+
class DISPLAY : public DEVICE
{
private:
// 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)
void draw_screen();
};
+}
#endif
#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,
#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)) {
state_fio->StateUint32(column);
return true;
}
+
+}
#define SIG_KEYBOARD_COLUMN 0
+namespace TK80 {
+
class KEYBOARD : public DEVICE
{
private:
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)
}
};
+}
#endif
#include "membus.h"
#include "../i8080.h"
+namespace TK80 {
+
void MEMBUS::reset()
{
#if defined(_TK85)
#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)) {
#endif
return MEMORY::process_state(state_fio, loading);
}
+
+}
#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
#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)
}
};
+}
+
#endif
// AUTO/STEP\83X\83C\83b\83`\82Ì\82½\82ß\82É\8eÀ\91\95\92\86\82Ì\83\\81[\83X
// \8eÀ\8dÛ\82É\8eg\97p\82·\82é\82©\82Í\96¢\92è
-#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++) { \
#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)) {
state_fio->StateBuffer(vram, sizeof(vram), 1);
return true;
}
+
+}
#include "../../emu.h"
#include "../device.h"
+namespace TK80 {
+
class MEMORY : public DEVICE
{
private:
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)
void save_binary(const _TCHAR* file_path);
};
+}
#endif
#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
// ----------------------------------------------------------------------------
for(DEVICE* device = first_device; device; device = device->next_device) {
device->initialize();
}
- decl_state();
}
VM::~VM()
#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);
#endif
};
-class csp_state_utils;
-
class EMU;
class DEVICE;
class EVENT;
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;
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];
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
#if defined(Q_OS_WIN)
DLL_PREFIX_I struct cur_time_s cur_time;
#endif
+
using X1::DISPLAY;
using X1::EMM;
using X1::FLOPPY;
using X1::SASI;
using X1::SUB;
using X1::KEYBOARD;
-
+#ifdef _X1TWIN
+using PCEDEV::PCE;
+#endif
// ----------------------------------------------------------------------------
// initialize
// ----------------------------------------------------------------------------
#ifdef _X1TWIN
class HUC6280;
-class PCE;
+namespace PCEDEV {
+ class PCE;
+}
#define USE_CPU_HUC6280
#endif
class VM : public VM_TEMPLATE
EVENT* pceevent;
HUC6280* pcecpu;
- PCE* pce;
+ PCEDEV::PCE* pce;
#endif
public: