2 SHARP MZ-2200 Emulator 'EmuZ-2200'
\r
4 Author : Takeda.Toshiya
\r
7 [ MZ-1M01 (16bit Board) ]
\r
11 #include "../z80pio.h"
\r
12 #include "../../fileio.h"
\r
14 #define SET_BANK(s, e, w, r) { \
\r
15 int sb = (s) >> 13, eb = (e) >> 13; \
\r
16 for(int i = sb; i <= eb; i++) { \
\r
20 wbank[i] = (w) + 0x2000 * (i - sb); \
\r
25 rbank[i] = (r) + 0x2000 * (i - sb); \
\r
30 void MZ1M01::initialize()
\r
32 memset(ram, 0, sizeof(ram));
\r
33 memset(ipl, 0xff, sizeof(ipl));
\r
34 memset(kanji, 0xff, sizeof(kanji));
\r
35 memset(rdmy, 0xff, sizeof(rdmy));
\r
37 FILEIO* fio = new FILEIO();
\r
38 if(fio->Fopen(emu->bios_path(_T("MZ-1M01.ROM")), FILEIO_READ_BINARY)) {
\r
39 fio->Fread(ipl, sizeof(ipl), 1);
\r
42 d_cpu->write_signal(SIG_CPU_BUSREQ, 1, 1);
\r
44 if(fio->Fopen(emu->bios_path(_T("MZ-1R08.ROM")), FILEIO_READ_BINARY)) {
\r
45 fio->Fread(kanji, sizeof(kanji), 1);
\r
50 SET_BANK(0x00000, 0x1ffff, ram, ram);
\r
51 SET_BANK(0x20000, 0x3ffff, wdmy, rdmy);
\r
52 SET_BANK(0x40000, 0x5ffff, wdmy, kanji);
\r
53 SET_BANK(0x60000, 0xfdfff, wdmy, rdmy);
\r
54 SET_BANK(0xfe000, 0xfffff, wdmy, ipl);
\r
57 void MZ1M01::reset()
\r
59 port[0] = port[1] = 0xff;
\r
62 void MZ1M01::write_data8(uint32 addr, uint32 data)
\r
65 wbank[addr >> 13][addr & 0x1fff] = data;
\r
68 uint32 MZ1M01::read_data8(uint32 addr)
\r
71 return rbank[addr >> 13][addr & 0x1fff];
\r
74 void MZ1M01::write_io8(uint32 addr, uint32 data)
\r
76 switch(addr & 0xff) {
\r
79 d_pic->write_io8(addr, data);
\r
82 d_pio->write_signal(SIG_Z80PIO_PORT_A, data, 0xff);
\r
83 d_pio->write_signal(SIG_Z80PIO_STROBE_B, 1, 1);
\r
86 d_pio->write_signal(SIG_Z80PIO_PORT_B, data, 0x7f);
\r
87 port[1] = (port[1] & 0x80) | (data & 0x7f);
\r
92 uint32 MZ1M01::read_io8(uint32 addr)
\r
94 switch(addr & 0xff) {
\r
97 return d_pic->read_io8(addr);
\r
99 d_pio->write_signal(SIG_Z80PIO_STROBE_A, 1, 1);
\r
101 return port[addr & 1];
\r
106 void MZ1M01::write_signal(int id, uint32 data, uint32 mask)
\r
108 if(id == SIG_MZ1M01_PORT_A) {
\r
109 port[0] = (port[0] & ~mask) | (data & mask);
\r
110 } else if(id == SIG_MZ1M01_PORT_B) {
\r
111 port[1] = (port[1] & ~mask) | (data & mask);
\r
115 #define STATE_VERSION 1
\r
117 void MZ1M01::save_state(FILEIO* state_fio)
\r
119 state_fio->FputUint32(STATE_VERSION);
\r
120 state_fio->FputInt32(this_device_id);
\r
122 state_fio->Fwrite(ram, sizeof(ram), 1);
\r
123 state_fio->Fwrite(port, sizeof(port), 1);
\r
126 bool MZ1M01::load_state(FILEIO* state_fio)
\r
128 if(state_fio->FgetUint32() != STATE_VERSION) {
\r
131 if(state_fio->FgetInt32() != this_device_id) {
\r
134 state_fio->Fread(ram, sizeof(ram), 1);
\r
135 state_fio->Fread(port, sizeof(port), 1);
\r