src/mess/drivers/pc8401a.c
| r4762 | r4763 | |
| 1 | 1 | #include "driver.h" |
| 2 | #include "includes/pc8401a.h" |
| 3 | #include "devices/cartslot.h" |
| 4 | #include "machine/8255ppi.h" |
| 2 | 5 | #include "cpu/z80/z80.h" |
| 3 | 6 | |
| 4 | 7 | /* Read/Write Handlers */ |
| 5 | 8 | |
| 6 | | #ifdef UNUSED_CODE |
| 7 | | static WRITE8_HANDLER( mmr_w ) |
| 9 | static void pc8401a_bankswitch(running_machine *machine, UINT8 data) |
| 8 | 10 | { |
| 9 | | /* |
| 11 | const address_space *program = cputag_get_address_space(machine, Z80_TAG, ADDRESS_SPACE_PROGRAM); |
| 10 | 12 | |
| 11 | | Memory Mapping Register |
| 13 | int rombank = data & 0x03; |
| 14 | int ram0000 = (data >> 2) & 0x03; |
| 15 | int ram8000 = (data >> 4) & 0x03; |
| 12 | 16 | |
| 13 | | RAM USER MODE (0-ffff=RAM) |
| 14 | | b6b5b4b3b2b1b0 |
| 15 | | 0 1 0 1 0 x x |
| 17 | switch (ram0000) |
| 18 | { |
| 19 | case 0: /* ROM 0000H to 7FFFH */ |
| 20 | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_BANK(1), SMH_UNMAP); |
| 21 | memory_set_bank(machine, 1, rombank); |
| 22 | logerror("0x0000-0x7fff = ROM %u\n", rombank); |
| 23 | break; |
| 16 | 24 | |
| 17 | | ROM USER MODE (0-7ffff=ROM, 8000-ffff=RAM) |
| 25 | case 1: /* RAM 0000H to 7FFFH */ |
| 26 | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_BANK(1), SMH_BANK(1)); |
| 27 | memory_set_bank(machine, 1, 4); |
| 28 | logerror("0x0000-0x7fff = RAM 0-7fff\n"); |
| 29 | break; |
| 18 | 30 | |
| 19 | | 0 1 0 0 0 0 0 AP is in ROM #0 |
| 20 | | 0 1 0 0 0 0 1 AP is in ROM #1 |
| 21 | | 0 1 0 0 0 1 0 AP is in ROM #2 |
| 22 | | 0 1 0 0 0 1 1 ROM cartridge AP |
| 31 | case 2: /* RAM 8000H to FFFFH */ |
| 32 | memory_install_readwrite8_handler(program, 0x0000, 0x7fff, 0, 0, SMH_BANK(1), SMH_BANK(1)); |
| 33 | memory_set_bank(machine, 1, 5); |
| 34 | logerror("0x0000-0x7fff = RAM 8000-ffff\n"); |
| 35 | break; |
| 23 | 36 | |
| 24 | | CCP MODE (MENU, 0-7ffff=ROM, 8000-ffff=RAM) |
| 37 | case 3: /* invalid */ |
| 38 | logerror("0x0000-0x7fff = invalid\n"); |
| 39 | break; |
| 40 | } |
| 25 | 41 | |
| 26 | | 0 1 0 0 0 0 0 |
| 42 | switch (ram8000) |
| 43 | { |
| 44 | case 0: /* cell addresses 0000H to 03FFFH */ |
| 45 | memory_install_readwrite8_handler(program, 0x8000, 0xbfff, 0, 0, SMH_BANK(3), SMH_BANK(3)); |
| 46 | memory_set_bank(machine, 3, 0); |
| 47 | logerror("0x8000-0xbfff = RAM 0-3fff\n"); |
| 48 | break; |
| 27 | 49 | |
| 28 | | KERNEL MODE (0-7ffff=ROM, 8000-ffff=RAM) |
| 50 | case 1: /* cell addresses 4000H to 7FFFH */ |
| 51 | memory_install_readwrite8_handler(program, 0x8000, 0xbfff, 0, 0, SMH_BANK(3), SMH_BANK(3)); |
| 52 | memory_set_bank(machine, 3, 1); |
| 53 | logerror("0x8000-0xbfff = RAM 4000-7fff\n"); |
| 54 | break; |
| 29 | 55 | |
| 30 | | 0 0 0 0 0 0 0 S0 access |
| 31 | | 0 0 1 0 0 0 0 S1 access |
| 32 | | 0 1 1 0 0 0 0 RAM cartridge |
| 33 | | 1 x x 0 0 0 0 CRT access |
| 56 | case 2: /* cell addresses 8000H to BFFFH */ |
| 57 | memory_install_readwrite8_handler(program, 0x8000, 0xbfff, 0, 0, SMH_BANK(3), SMH_BANK(3)); |
| 58 | memory_set_bank(machine, 3, 2); |
| 59 | logerror("0x8000-0xbfff = RAM 8000-bfff\n"); |
| 60 | break; |
| 34 | 61 | |
| 35 | | etc... |
| 62 | case 3: /* RAM cartridge */ |
| 63 | memory_install_readwrite8_handler(program, 0x8000, 0xbfff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 64 | // memory_set_bank(machine, 3, 3); // TODO or 4 |
| 65 | logerror("0x8000-0xbfff = RAM cartridge\n"); |
| 66 | break; |
| 67 | } |
| 36 | 68 | |
| 69 | if (BIT(data, 6)) |
| 70 | { |
| 71 | /* CRT video RAM */ |
| 72 | memory_install_readwrite8_handler(program, 0xc000, 0xdfff, 0, 0, SMH_BANK(4), SMH_BANK(4)); |
| 73 | memory_install_readwrite8_handler(program, 0xe000, 0xe7ff, 0, 0, SMH_UNMAP, SMH_UNMAP); |
| 74 | memory_set_bank(machine, 4, 1); |
| 75 | logerror("0xc000-0xdfff = video RAM\n"); |
| 76 | } |
| 77 | else |
| 78 | { |
| 79 | /* RAM */ |
| 80 | memory_install_readwrite8_handler(program, 0xc000, 0xe7ff, 0, 0, SMH_BANK(4), SMH_BANK(4)); |
| 81 | memory_set_bank(machine, 4, 0); |
| 82 | logerror("0xc000-0e7fff = RAM c000-e7fff\n"); |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | static WRITE8_HANDLER( mmr_w ) |
| 87 | { |
| 88 | |
| 89 | /* |
| 90 | |
| 91 | bit description |
| 92 | |
| 93 | 0 ROM section bit 0 |
| 94 | 1 ROM section bit 1 |
| 95 | 2 mapping for CPU addresses 0000H to 7FFFH bit 0 |
| 96 | 3 mapping for CPU addresses 0000H to 7FFFH bit 1 |
| 97 | 4 mapping for CPU addresses 8000H to BFFFH bit 0 |
| 98 | 5 mapping for CPU addresses 8000H to BFFFH bit 1 |
| 99 | 6 mapping for CPU addresses C000H to E7FFH |
| 100 | 7 |
| 101 | |
| 37 | 102 | */ |
| 103 | |
| 104 | pc8401a_bankswitch(space->machine, data); |
| 38 | 105 | } |
| 39 | | #endif |
| 40 | 106 | |
| 41 | 107 | /* Memory Maps */ |
| 42 | 108 | |
| 43 | 109 | static ADDRESS_MAP_START( pc8401a_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 44 | 110 | ADDRESS_MAP_UNMAP_HIGH |
| 45 | | AM_RANGE(0x0000, 0xffff) AM_ROM |
| 46 | | // AM_RANGE(0x0000, 0x7fff) AM_RAMBANK(1) |
| 47 | | // AM_RANGE(0x8000, 0xffff) AM_RAMBANK(2) |
| 111 | AM_RANGE(0x0000, 0x7fff) AM_RAMBANK(1) |
| 112 | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK(3) |
| 113 | AM_RANGE(0xc000, 0xe7ff) AM_RAMBANK(4) |
| 114 | AM_RANGE(0xe800, 0xffff) AM_RAMBANK(5) |
| 48 | 115 | ADDRESS_MAP_END |
| 49 | 116 | |
| 50 | 117 | static ADDRESS_MAP_START( pc8401a_io, ADDRESS_SPACE_IO, 8 ) |
| 51 | 118 | ADDRESS_MAP_UNMAP_HIGH |
| 119 | AM_RANGE(0x31, 0x31) AM_MASK(0xff) AM_WRITE(mmr_w) |
| 120 | AM_RANGE(0xfc, 0xff) AM_MASK(0xff) AM_DEVREADWRITE(PPI8255_TAG, ppi8255_r, ppi8255_w) |
| 52 | 121 | ADDRESS_MAP_END |
| 53 | 122 | |
| 54 | 123 | /* Input Ports */ |
| r4762 | r4763 | |
| 60 | 129 | |
| 61 | 130 | static MACHINE_START( pc8401a ) |
| 62 | 131 | { |
| 132 | pc8401a_state *state = machine->driver_data; |
| 133 | |
| 134 | /* allocate video memory */ |
| 135 | state->video_ram = auto_alloc_array(machine, UINT8, PC8401A_VIDEORAM_SIZE); |
| 136 | |
| 137 | /* set up A0/A1 memory banking */ |
| 138 | memory_configure_bank(machine, 1, 0, 4, memory_region(machine, Z80_TAG), 0x8000); |
| 139 | memory_configure_bank(machine, 1, 4, 2, mess_ram, 0x8000); |
| 140 | memory_set_bank(machine, 1, 0); |
| 141 | |
| 142 | /* set up A2 memory banking */ |
| 143 | memory_configure_bank(machine, 3, 0, 5, mess_ram, 0x4000); |
| 144 | memory_set_bank(machine, 3, 0); |
| 145 | |
| 146 | /* set up A3 memory banking */ |
| 147 | memory_configure_bank(machine, 4, 0, 1, mess_ram + 0xc000, 0); |
| 148 | memory_configure_bank(machine, 4, 1, 1, state->video_ram, 0); |
| 149 | memory_set_bank(machine, 4, 0); |
| 150 | |
| 151 | /* set up A4 memory banking */ |
| 152 | memory_configure_bank(machine, 5, 0, 1, mess_ram + 0xe800, 0); |
| 153 | memory_set_bank(machine, 5, 0); |
| 154 | |
| 155 | pc8401a_bankswitch(machine, 0); |
| 63 | 156 | } |
| 64 | 157 | |
| 158 | static READ8_DEVICE_HANDLER( pc8401a_ppi8255_c_r ) |
| 159 | { |
| 160 | /* |
| 161 | |
| 162 | bit signal description |
| 163 | |
| 164 | PC0 |
| 165 | PC1 |
| 166 | PC2 |
| 167 | PC3 |
| 168 | PC4 PC-8431A DAV data valid |
| 169 | PC5 PC-8431A RFD ready for data |
| 170 | PC6 PC-8431A DAC data accepted |
| 171 | PC7 PC-8431A ATN attention |
| 172 | |
| 173 | */ |
| 174 | |
| 175 | return 0; |
| 176 | } |
| 177 | |
| 178 | static WRITE8_DEVICE_HANDLER( pc8401a_ppi8255_c_w ) |
| 179 | { |
| 180 | /* |
| 181 | |
| 182 | bit signal description |
| 183 | |
| 184 | PC0 |
| 185 | PC1 |
| 186 | PC2 |
| 187 | PC3 |
| 188 | PC4 PC-8431A DAV data valid |
| 189 | PC5 PC-8431A RFD ready for data |
| 190 | PC6 PC-8431A DAC data accepted |
| 191 | PC7 PC-8431A ATN attention |
| 192 | |
| 193 | */ |
| 194 | } |
| 195 | |
| 196 | static const ppi8255_interface pc8401a_ppi8255_interface = |
| 197 | { |
| 198 | DEVCB_NULL, |
| 199 | DEVCB_NULL, |
| 200 | DEVCB_HANDLER(pc8401a_ppi8255_c_r), |
| 201 | DEVCB_NULL, |
| 202 | DEVCB_NULL, |
| 203 | DEVCB_HANDLER(pc8401a_ppi8255_c_w), |
| 204 | }; |
| 205 | |
| 65 | 206 | /* Machine Drivers */ |
| 66 | 207 | |
| 67 | 208 | static MACHINE_DRIVER_START( pc8401a ) |
| 68 | | // MDRV_DRIVER_DATA(pc8401a_state) |
| 209 | MDRV_DRIVER_DATA(pc8401a_state) |
| 69 | 210 | |
| 70 | 211 | /* basic machine hardware */ |
| 71 | | MDRV_CPU_ADD("maincpu", Z80, 4000000) |
| 212 | MDRV_CPU_ADD(Z80_TAG, Z80, 4000000) |
| 72 | 213 | MDRV_CPU_PROGRAM_MAP(pc8401a_mem) |
| 73 | 214 | MDRV_CPU_IO_MAP(pc8401a_io) |
| 74 | 215 | |
| r4762 | r4763 | |
| 82 | 223 | MDRV_SCREEN_VISIBLE_AREA(0, 480-1, 0, 128-1) |
| 83 | 224 | // MDRV_DEFAULT_LAYOUT(layout_pc8401a) |
| 84 | 225 | MDRV_PALETTE_LENGTH(2) |
| 226 | |
| 227 | /* devices */ |
| 228 | MDRV_PPI8255_ADD(PPI8255_TAG, pc8401a_ppi8255_interface) |
| 229 | |
| 230 | /* option ROM cartridge */ |
| 231 | MDRV_CARTSLOT_ADD("cart") |
| 232 | MDRV_CARTSLOT_EXTENSION_LIST("rom,bin") |
| 233 | MDRV_CARTSLOT_NOT_MANDATORY |
| 85 | 234 | MACHINE_DRIVER_END |
| 86 | 235 | |
| 87 | 236 | static MACHINE_DRIVER_START( pc8500 ) |
| 88 | | // MDRV_DRIVER_DATA(pc8401a_state) |
| 237 | MDRV_DRIVER_DATA(pc8401a_state) |
| 89 | 238 | |
| 90 | 239 | /* basic machine hardware */ |
| 91 | | MDRV_CPU_ADD("maincpu", Z80, 4000000) |
| 240 | MDRV_CPU_ADD(Z80_TAG, Z80, 4000000) |
| 92 | 241 | MDRV_CPU_PROGRAM_MAP(pc8401a_mem) |
| 93 | 242 | MDRV_CPU_IO_MAP(pc8401a_io) |
| 94 | 243 | |
| r4762 | r4763 | |
| 102 | 251 | MDRV_SCREEN_VISIBLE_AREA(0, 480-1, 0, 200-1) |
| 103 | 252 | // MDRV_DEFAULT_LAYOUT(layout_pc8500) |
| 104 | 253 | MDRV_PALETTE_LENGTH(2) |
| 254 | |
| 255 | /* devices */ |
| 256 | MDRV_PPI8255_ADD(PPI8255_TAG, pc8401a_ppi8255_interface) |
| 257 | |
| 258 | /* option ROM cartridge */ |
| 259 | MDRV_CARTSLOT_ADD("cart") |
| 260 | MDRV_CARTSLOT_EXTENSION_LIST("rom,bin") |
| 261 | MDRV_CARTSLOT_NOT_MANDATORY |
| 105 | 262 | MACHINE_DRIVER_END |
| 106 | 263 | |
| 107 | 264 | /* ROMs */ |
| 108 | 265 | |
| 109 | 266 | ROM_START( pc8401a ) |
| 110 | | ROM_REGION( 0x18000, "maincpu", 0 ) |
| 267 | ROM_REGION( 0x20000, Z80_TAG, 0 ) |
| 111 | 268 | ROM_LOAD( "pc8401a.bin", 0x0000, 0x18000, NO_DUMP ) |
| 269 | ROM_CART_LOAD("cart", 0x18000, 0x8000, ROM_NOMIRROR | ROM_OPTIONAL) |
| 112 | 270 | ROM_END |
| 113 | 271 | |
| 114 | 272 | ROM_START( pc8500 ) |
| 115 | | ROM_REGION( 0x10000, "maincpu", 0 ) |
| 273 | ROM_REGION( 0x20000, Z80_TAG, 0 ) |
| 116 | 274 | ROM_LOAD( "pc8500.bin", 0x0000, 0x10000, CRC(c2749ef0) SHA1(f766afce9fda9ec84ed5b39ebec334806798afb3) ) |
| 275 | ROM_CART_LOAD("cart", 0x18000, 0x8000, ROM_NOMIRROR | ROM_OPTIONAL) |
| 117 | 276 | ROM_END |
| 118 | 277 | |
| 119 | 278 | /* System Configurations */ |