src/mess/drivers/pasopia.c
| r8526 | r8527 | |
| 17 | 17 | #include "sound/sn76496.h" |
| 18 | 18 | #include "video/mc6845.h" |
| 19 | 19 | |
| 20 | | static UINT8 vram_sel; |
| 20 | static UINT8 vram_sel,mio_sel; |
| 21 | 21 | static UINT8 *p7_vram; |
| 22 | 22 | static UINT8 bank_reg; |
| 23 | 23 | static UINT16 cursor_addr; |
| r8526 | r8527 | |
| 66 | 66 | p7_vram[offset] = data; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | | static WRITE8_HANDLER( paso7_bankswitch ) |
| 69 | static WRITE8_HANDLER( pasopia7_memory_ctrl_w ) |
| 70 | 70 | { |
| 71 | 71 | UINT8 *cpu = memory_region(space->machine, "maincpu"); |
| 72 | 72 | UINT8 *basic = memory_region(space->machine, "basic"); |
| r8526 | r8527 | |
| 90 | 90 | |
| 91 | 91 | bank_reg = data & 3; |
| 92 | 92 | vram_sel = data & 4; |
| 93 | mio_sel = data & 8; |
| 93 | 94 | |
| 94 | | if(data & 8) // as far as I can see, this enables a RAM bankswitch mapped on i/o ports ... |
| 95 | | printf("Warning: i/o bank write enabled\n"); |
| 96 | | |
| 97 | 95 | // bank4 is always RAM |
| 98 | 96 | |
| 99 | 97 | // printf("%02x\n",data); |
| r8526 | r8527 | |
| 126 | 124 | case 0: pac2_index[pac2_bank_select] = (pac2_index[pac2_bank_select] & 0x7f00) | (data & 0xff); break; |
| 127 | 125 | case 1: pac2_index[pac2_bank_select] = (pac2_index[pac2_bank_select] & 0xff) | ((data & 0x7f) << 8); break; |
| 128 | 126 | case 2: // RAM write |
| 127 | printf("Warning: write to RAM packs\n"); |
| 129 | 128 | break; |
| 130 | 129 | case 3: |
| 131 | 130 | { |
| r8526 | r8527 | |
| 180 | 179 | } |
| 181 | 180 | } |
| 182 | 181 | |
| 182 | static READ8_HANDLER( pasopia7_io_r ) |
| 183 | { |
| 184 | static UINT16 io_port; |
| 183 | 185 | |
| 186 | if(mio_sel) |
| 187 | { |
| 188 | const address_space *ram_space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 189 | mio_sel = 0; |
| 190 | //return 0x0d; // hack: this is used for reading the keyboard data, we can fake it a little ... (modify fda4) |
| 191 | return memory_read_byte(ram_space, offset); |
| 192 | } |
| 193 | |
| 194 | io_port = offset & 0xff; //trim down to 8-bit bus |
| 195 | |
| 196 | if(io_port >= 0x08 && io_port <= 0x0b) { return i8255a_r(devtag_get_device(space->machine, "ppi8255_0"), (io_port-0x08) & 3); } |
| 197 | else if(io_port >= 0x0c && io_port <= 0x0f) { return i8255a_r(devtag_get_device(space->machine, "ppi8255_1"), (io_port-0x0c) & 3); } |
| 198 | // else if(io_port == 0x10 || io_port == 0x11) { M6845 read } |
| 199 | else if(io_port >= 0x18 && io_port <= 0x1b) { return pac2_r(space, io_port-0x1b); } |
| 200 | else if(io_port >= 0x20 && io_port <= 0x23) { return i8255a_r(devtag_get_device(space->machine, "ppi8255_2"), (io_port-0x20) & 3); } |
| 201 | else if(io_port >= 0x28 && io_port <= 0x2b) { return z80ctc_r(devtag_get_device(space->machine, "ctc"), io_port-0x28); } |
| 202 | else if(io_port >= 0x30 && io_port <= 0x33) { return z80pio_cd_ba_r(devtag_get_device(space->machine, "z80pio_0"), (io_port-0x30) & 3); } |
| 203 | // else if(io_port == 0x3a) { SN1 } |
| 204 | // else if(io_port == 0x3b) { SN2 } |
| 205 | // else if(io_port == 0x3c) { bankswitch } |
| 206 | // else if(io_port >= 0xe0 && io_port <= 0xe6) { fdc } |
| 207 | else |
| 208 | { |
| 209 | logerror("(PC=%06x) Read i/o address %02x\n",cpu_get_pc(space->cpu),io_port); |
| 210 | } |
| 211 | return 0xff; |
| 212 | } |
| 213 | |
| 214 | static WRITE8_HANDLER( pasopia7_io_w ) |
| 215 | { |
| 216 | static UINT16 io_port; |
| 217 | |
| 218 | if(mio_sel) |
| 219 | { |
| 220 | const address_space *ram_space = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| 221 | mio_sel = 0; |
| 222 | memory_write_byte(ram_space, offset, data); |
| 223 | return; |
| 224 | } |
| 225 | |
| 226 | io_port = offset & 0xff; //trim down to 8-bit bus |
| 227 | |
| 228 | if(io_port >= 0x08 && io_port <= 0x0b) { i8255a_w(devtag_get_device(space->machine, "ppi8255_0"), (io_port-0x08) & 3, data); } |
| 229 | else if(io_port >= 0x0c && io_port <= 0x0f) { i8255a_w(devtag_get_device(space->machine, "ppi8255_1"), (io_port-0x0c) & 3, data); } |
| 230 | else if(io_port >= 0x10 && io_port <= 0x11) { pasopia7_6845_w(space, io_port-0x10, data); } |
| 231 | else if(io_port >= 0x18 && io_port <= 0x1b) { pac2_w(space, io_port-0x1b, data); } |
| 232 | else if(io_port >= 0x20 && io_port <= 0x23) { i8255a_w(devtag_get_device(space->machine, "ppi8255_2"), (io_port-0x20) & 3, data); } |
| 233 | else if(io_port >= 0x28 && io_port <= 0x2b) { z80ctc_w(devtag_get_device(space->machine, "ctc"), io_port-0x28,data); } |
| 234 | else if(io_port >= 0x30 && io_port <= 0x33) { z80pio_cd_ba_w(devtag_get_device(space->machine, "z80pio_0"), (io_port-0x30) & 3, data); } |
| 235 | else if(io_port == 0x3a) { sn76496_w(devtag_get_device(space->machine, "sn1"), 0, data); } |
| 236 | else if(io_port == 0x3b) { sn76496_w(devtag_get_device(space->machine, "sn2"), 0, data); } |
| 237 | else if(io_port == 0x3c) { pasopia7_memory_ctrl_w(space,0, data); } |
| 238 | // else if(io_port >= 0xe0 && io_port <= 0xe6) { fdc } |
| 239 | else |
| 240 | { |
| 241 | logerror("(PC=%06x) Write i/o address %02x = %02x\n",cpu_get_pc(space->cpu),offset,data); |
| 242 | } |
| 243 | } |
| 244 | |
| 184 | 245 | static ADDRESS_MAP_START(paso7_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 185 | 246 | ADDRESS_MAP_UNMAP_HIGH |
| 186 | 247 | AM_RANGE( 0x0000, 0x7fff ) AM_WRITE( ram_bank_w ) |
| r8526 | r8527 | |
| 192 | 253 | |
| 193 | 254 | static ADDRESS_MAP_START( paso7_io , ADDRESS_SPACE_IO, 8) |
| 194 | 255 | ADDRESS_MAP_UNMAP_HIGH |
| 195 | | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 196 | | AM_RANGE( 0x08, 0x0b ) AM_DEVREADWRITE("ppi8255_0", i8255a_r, i8255a_w) |
| 197 | | AM_RANGE( 0x0c, 0x0f ) AM_DEVREADWRITE("ppi8255_1", i8255a_r, i8255a_w) |
| 198 | | AM_RANGE( 0x10, 0x11 ) AM_WRITE(pasopia7_6845_w) |
| 199 | | AM_RANGE( 0x18, 0x1b ) AM_READWRITE( pac2_r, pac2_w ) |
| 200 | | AM_RANGE( 0x20, 0x23 ) AM_DEVREADWRITE("ppi8255_2", i8255a_r, i8255a_w) |
| 201 | | AM_RANGE( 0x28, 0x2b ) AM_DEVREADWRITE("ctc", z80ctc_r, z80ctc_w) |
| 202 | | AM_RANGE( 0x30, 0x33 ) AM_DEVREADWRITE("z80pio_0", z80pio_cd_ba_r, z80pio_cd_ba_w) |
| 203 | | AM_RANGE( 0x3a, 0x3a ) AM_DEVWRITE("sn1", sn76496_w) |
| 204 | | AM_RANGE( 0x3b, 0x3b ) AM_DEVWRITE("sn2", sn76496_w) |
| 205 | | AM_RANGE( 0x3c, 0x3c ) AM_WRITE(paso7_bankswitch) |
| 206 | | // AM_RANGE( 0xe0, 0xe6 ) AM_READWRITE( fdc_r, fregdc_w ) |
| 256 | AM_RANGE( 0x0000, 0xffff) AM_READWRITE( pasopia7_io_r, pasopia7_io_w ) |
| 207 | 257 | ADDRESS_MAP_END |
| 208 | 258 | |
| 209 | 259 | /* Input ports */ |