src/mess/drivers/c80.c
| r5155 | r5156 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | C-80 |
| 3 | C-80 |
| 4 | 4 | |
| 5 | | 12/05/2009 Skeleton driver. |
| 5 | 12/05/2009 Skeleton driver. |
| 6 | 6 | |
| 7 | 7 | ****************************************************************************/ |
| 8 | 8 | |
| 9 | 9 | #include "driver.h" |
| 10 | #include "includes/c80.h" |
| 10 | 11 | #include "cpu/z80/z80.h" |
| 12 | #include "cpu/z80/z80daisy.h" |
| 13 | #include "machine/z80pio.h" |
| 14 | #include "devices/cassette.h" |
| 15 | #include "vcs80.lh" |
| 11 | 16 | |
| 12 | | static ADDRESS_MAP_START(c80_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 17 | static const device_config *cassette_device_image(running_machine *machine) |
| 18 | { |
| 19 | return devtag_get_device(machine, CASSETTE_TAG); |
| 20 | } |
| 21 | |
| 22 | /* Memory Maps */ |
| 23 | |
| 24 | static ADDRESS_MAP_START( c80_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 13 | 25 | ADDRESS_MAP_UNMAP_HIGH |
| 14 | | AM_RANGE( 0x0000, 0x03ff ) AM_ROM |
| 15 | | AM_RANGE( 0x0400, 0xffff ) AM_RAM |
| 26 | AM_RANGE(0x0000, 0x07ff) AM_ROM |
| 27 | AM_RANGE(0x0800, 0x0bff) AM_MIRROR(0x400) AM_RAM |
| 16 | 28 | ADDRESS_MAP_END |
| 17 | 29 | |
| 18 | | static ADDRESS_MAP_START( c80_io , ADDRESS_SPACE_IO, 8) |
| 19 | | ADDRESS_MAP_UNMAP_HIGH |
| 30 | static ADDRESS_MAP_START( c80_io, ADDRESS_SPACE_IO, 8 ) |
| 31 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 32 | AM_RANGE(0x7c, 0x7f) AM_DEVREADWRITE(Z80PIO2_TAG, z80pio_r, z80pio_w) |
| 33 | AM_RANGE(0xbc, 0xbf) AM_DEVREADWRITE(Z80PIO1_TAG, z80pio_r, z80pio_w) |
| 20 | 34 | ADDRESS_MAP_END |
| 21 | 35 | |
| 22 | | /* Input ports */ |
| 36 | /* Input Ports */ |
| 37 | |
| 38 | static INPUT_CHANGED( trigger_reset ) |
| 39 | { |
| 40 | cputag_set_input_line(field->port->machine, Z80_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE); |
| 41 | } |
| 42 | |
| 43 | static INPUT_CHANGED( trigger_nmi ) |
| 44 | { |
| 45 | cputag_set_input_line(field->port->machine, Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE); |
| 46 | } |
| 47 | |
| 23 | 48 | static INPUT_PORTS_START( c80 ) |
| 49 | PORT_START("ROW0") |
| 50 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("REG") PORT_CODE(KEYCODE_R) |
| 51 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("GO") PORT_CODE(KEYCODE_G) |
| 52 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D') |
| 53 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A') |
| 54 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7') |
| 55 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4') |
| 56 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1') |
| 57 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("FCN") PORT_CODE(KEYCODE_F1) |
| 58 | |
| 59 | PORT_START("ROW1") |
| 60 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("+") PORT_CODE(KEYCODE_UP) |
| 61 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("-") PORT_CODE(KEYCODE_DOWN) |
| 62 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E') |
| 63 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B') |
| 64 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8') |
| 65 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5') |
| 66 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2') |
| 67 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0') |
| 68 | |
| 69 | PORT_START("ROW2") |
| 70 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 71 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED ) |
| 72 | PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F') |
| 73 | PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C') |
| 74 | PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9') |
| 75 | PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6') |
| 76 | PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3') |
| 77 | PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("MEM") PORT_CODE(KEYCODE_M) |
| 78 | |
| 79 | PORT_START("SPECIAL") |
| 80 | PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RES") PORT_CODE(KEYCODE_F10) PORT_CHANGED(trigger_reset, 0) |
| 81 | PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("BRK") PORT_CODE(KEYCODE_ESC) PORT_CHANGED(trigger_nmi, 0) |
| 24 | 82 | INPUT_PORTS_END |
| 25 | 83 | |
| 84 | /* Z80-PIO Interface */ |
| 26 | 85 | |
| 27 | | static MACHINE_RESET(c80) |
| 86 | static READ8_DEVICE_HANDLER( pio1_port_a_r ) |
| 28 | 87 | { |
| 88 | /* |
| 89 | |
| 90 | bit description |
| 91 | |
| 92 | PA0 keyboard row 0 input |
| 93 | PA1 keyboard row 1 input |
| 94 | PA2 keyboard row 2 input |
| 95 | PA3 |
| 96 | PA4 _BSTB input |
| 97 | PA5 display enable output (0=enabled, 1=disabled) |
| 98 | PA6 tape output |
| 99 | PA7 tape input |
| 100 | |
| 101 | */ |
| 102 | |
| 103 | c80_state *state = device->machine->driver_data; |
| 104 | |
| 105 | UINT8 data = !state->pio1_brdy << 4 | 0x07; |
| 106 | |
| 107 | int i; |
| 108 | |
| 109 | for (i = 0; i < 8; i++) |
| 110 | { |
| 111 | if (!BIT(state->keylatch, i)) |
| 112 | { |
| 113 | if (!BIT(input_port_read(device->machine, "ROW0"), i)) data &= ~0x01; |
| 114 | if (!BIT(input_port_read(device->machine, "ROW1"), i)) data &= ~0x02; |
| 115 | if (!BIT(input_port_read(device->machine, "ROW2"), i)) data &= ~0x04; |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | data |= (cassette_input(cassette_device_image(device->machine)) < +0.0) << 7; |
| 120 | |
| 121 | return data; |
| 29 | 122 | } |
| 30 | 123 | |
| 31 | | static VIDEO_START( c80 ) |
| 124 | static WRITE8_DEVICE_HANDLER( pio1_port_a_w ) |
| 32 | 125 | { |
| 126 | /* |
| 127 | |
| 128 | bit description |
| 129 | |
| 130 | PA0 keyboard row 0 input |
| 131 | PA1 keyboard row 1 input |
| 132 | PA2 keyboard row 2 input |
| 133 | PA3 |
| 134 | PA4 _BSTB input |
| 135 | PA5 display enable output (0=enabled, 1=disabled) |
| 136 | PA6 tape output |
| 137 | PA7 tape input |
| 138 | |
| 139 | */ |
| 140 | |
| 141 | c80_state *state = device->machine->driver_data; |
| 142 | |
| 143 | state->pio1_a5 = BIT(data, 5); |
| 144 | |
| 145 | if (!BIT(data, 5)) |
| 146 | { |
| 147 | state->digit = 0; |
| 148 | } |
| 149 | |
| 150 | cassette_output(cassette_device_image(device->machine), BIT(data, 6) ? +1.0 : -1.0); |
| 33 | 151 | } |
| 34 | 152 | |
| 35 | | static VIDEO_UPDATE( c80 ) |
| 153 | static WRITE8_DEVICE_HANDLER( pio1_port_b_w ) |
| 36 | 154 | { |
| 37 | | return 0; |
| 155 | /* |
| 156 | |
| 157 | bit description |
| 158 | |
| 159 | PB0 VQD30 segment A |
| 160 | PB1 VQD30 segment B |
| 161 | PB2 VQD30 segment C |
| 162 | PB3 VQD30 segment D |
| 163 | PB4 VQD30 segment E |
| 164 | PB5 VQD30 segment F |
| 165 | PB6 VQD30 segment G |
| 166 | PB7 VQD30 segment P |
| 167 | |
| 168 | */ |
| 169 | |
| 170 | c80_state *state = device->machine->driver_data; |
| 171 | |
| 172 | if (!state->pio1_a5) |
| 173 | { |
| 174 | output_set_digit_value(state->digit, data); |
| 175 | } |
| 176 | |
| 177 | state->keylatch = data; |
| 38 | 178 | } |
| 39 | 179 | |
| 180 | static WRITE_LINE_DEVICE_HANDLER( pio1_brdy_w ) |
| 181 | { |
| 182 | c80_state *driver_state = device->machine->driver_data; |
| 183 | |
| 184 | driver_state->pio1_brdy = state; |
| 185 | |
| 186 | if (state) |
| 187 | { |
| 188 | if (!driver_state->pio1_a5) |
| 189 | { |
| 190 | driver_state->digit++; |
| 191 | } |
| 192 | |
| 193 | z80pio_bstb_w(device, 1); |
| 194 | z80pio_bstb_w(device, 0); |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | static const z80pio_interface pio1_intf = |
| 199 | { |
| 200 | DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0), /* callback when change interrupt status */ |
| 201 | DEVCB_HANDLER(pio1_port_a_r), /* port A read callback */ |
| 202 | DEVCB_NULL, /* port B read callback */ |
| 203 | DEVCB_HANDLER(pio1_port_a_w), /* port A write callback */ |
| 204 | DEVCB_HANDLER(pio1_port_b_w), /* port B write callback */ |
| 205 | DEVCB_NULL, /* portA ready active callback */ |
| 206 | DEVCB_LINE(pio1_brdy_w) /* portB ready active callback */ |
| 207 | }; |
| 208 | |
| 209 | static const z80pio_interface pio2_intf = |
| 210 | { |
| 211 | DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0), /* callback when change interrupt status */ |
| 212 | DEVCB_NULL, /* port A read callback */ |
| 213 | DEVCB_NULL, /* port B read callback */ |
| 214 | DEVCB_NULL, /* port A write callback */ |
| 215 | DEVCB_NULL, /* port B write callback */ |
| 216 | DEVCB_NULL, /* portA ready active callback */ |
| 217 | DEVCB_NULL /* portB ready active callback */ |
| 218 | }; |
| 219 | |
| 220 | /* Z80 Daisy Chain */ |
| 221 | |
| 222 | static const z80_daisy_chain c80_daisy_chain[] = |
| 223 | { |
| 224 | { Z80PIO1_TAG }, |
| 225 | { Z80PIO2_TAG }, |
| 226 | { NULL } |
| 227 | }; |
| 228 | |
| 229 | /* Machine Initialization */ |
| 230 | |
| 231 | static MACHINE_START( c80 ) |
| 232 | { |
| 233 | c80_state *state = machine->driver_data; |
| 234 | |
| 235 | /* register for state saving */ |
| 236 | state_save_register_global(machine, state->keylatch); |
| 237 | state_save_register_global(machine, state->digit); |
| 238 | state_save_register_global(machine, state->pio1_a5); |
| 239 | state_save_register_global(machine, state->pio1_brdy); |
| 240 | } |
| 241 | |
| 242 | /* Machine Driver */ |
| 243 | |
| 244 | static const cassette_config c80_cassette_config = |
| 245 | { |
| 246 | cassette_default_formats, |
| 247 | NULL, |
| 248 | CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_MUTED |
| 249 | }; |
| 250 | |
| 40 | 251 | static MACHINE_DRIVER_START( c80 ) |
| 41 | | /* basic machine hardware */ |
| 42 | | MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz) |
| 252 | MDRV_DRIVER_DATA(c80_state) |
| 253 | |
| 254 | /* basic machine hardware */ |
| 255 | MDRV_CPU_ADD(Z80_TAG, Z80, 2500000) /* U880D */ |
| 43 | 256 | MDRV_CPU_PROGRAM_MAP(c80_mem) |
| 44 | 257 | MDRV_CPU_IO_MAP(c80_io) |
| 258 | MDRV_CPU_CONFIG(c80_daisy_chain) |
| 45 | 259 | |
| 46 | | MDRV_MACHINE_RESET(c80) |
| 260 | MDRV_MACHINE_START(c80) |
| 47 | 261 | |
| 48 | 262 | /* video hardware */ |
| 49 | | MDRV_SCREEN_ADD("screen", RASTER) |
| 50 | | MDRV_SCREEN_REFRESH_RATE(50) |
| 51 | | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */ |
| 52 | | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 53 | | MDRV_SCREEN_SIZE(640, 480) |
| 54 | | MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1) |
| 55 | | MDRV_PALETTE_LENGTH(2) |
| 56 | | MDRV_PALETTE_INIT(black_and_white) |
| 263 | MDRV_DEFAULT_LAYOUT( layout_vcs80 ) |
| 57 | 264 | |
| 58 | | MDRV_VIDEO_START(c80) |
| 59 | | MDRV_VIDEO_UPDATE(c80) |
| 265 | /* devices */ |
| 266 | MDRV_Z80PIO_ADD(Z80PIO1_TAG, pio1_intf) |
| 267 | MDRV_Z80PIO_ADD(Z80PIO2_TAG, pio2_intf) |
| 268 | MDRV_CASSETTE_ADD(CASSETTE_TAG, c80_cassette_config) |
| 60 | 269 | MACHINE_DRIVER_END |
| 61 | 270 | |
| 62 | | static SYSTEM_CONFIG_START(c80) |
| 63 | | SYSTEM_CONFIG_END |
| 271 | /* ROMs */ |
| 64 | 272 | |
| 65 | | /* ROM definition */ |
| 66 | 273 | ROM_START( c80 ) |
| 67 | | ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) |
| 68 | | ROM_LOAD( "c80.rom", 0x0000, 0x0400, CRC(ad2b3296) SHA1(14f72cb73a4068b7a5d763cc0e254639c251ce2e)) |
| 274 | ROM_REGION( 0x10000, Z80_TAG, 0 ) |
| 275 | ROM_LOAD( "c80.d3", 0x0000, 0x0400, CRC(ad2b3296) SHA1(14f72cb73a4068b7a5d763cc0e254639c251ce2e) ) |
| 69 | 276 | ROM_END |
| 70 | 277 | |
| 71 | | /* Driver */ |
| 278 | /* System Configuration */ |
| 72 | 279 | |
| 73 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 74 | | COMP( ????, c80, 0, 0, c80, c80, 0, c80, "Joachim Czepa", "C-80", GAME_NOT_WORKING) |
| 280 | static SYSTEM_CONFIG_START( c80 ) |
| 281 | CONFIG_RAM_DEFAULT( 1 * 1024 ) |
| 282 | SYSTEM_CONFIG_END |
| 75 | 283 | |
| 284 | /* System Drivers */ |
| 285 | |
| 286 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 287 | COMP( 1986, c80, 0, 0, c80, c80, 0, c80, "Joachim Czepa", "C-80", GAME_SUPPORTS_SAVE ) |