src/mess/drivers/samcoupe.c
| r5726 | r5727 | |
| 42 | 42 | #include "sound/speaker.h" |
| 43 | 43 | |
| 44 | 44 | /* devices */ |
| 45 | #include "devices/cassette.h" |
| 45 | 46 | #include "devices/flopdrv.h" |
| 46 | 47 | #include "formats/coupedsk.h" |
| 47 | 48 | #include "formats/dsk_dsk.h" |
| r5726 | r5727 | |
| 126 | 127 | { |
| 127 | 128 | coupe_asic *asic = space->machine->driver_data; |
| 128 | 129 | UINT8 data = 0xe0; |
| 129 | | UINT8 row = ~(offset >> 8); |
| 130 | 130 | |
| 131 | | if (row & 0x80) data &= input_port_read(space->machine, "keyboard_row_7f") & 0xe0; |
| 132 | | if (row & 0x40) data &= input_port_read(space->machine, "keyboard_row_bf") & 0xe0; |
| 133 | | if (row & 0x20) data &= input_port_read(space->machine, "keyboard_row_df") & 0xe0; |
| 134 | | if (row & 0x10) data &= input_port_read(space->machine, "keyboard_row_ef") & 0xe0; |
| 135 | | if (row & 0x08) data &= input_port_read(space->machine, "keyboard_row_f7") & 0xe0; |
| 136 | | if (row & 0x04) data &= input_port_read(space->machine, "keyboard_row_fb") & 0xe0; |
| 137 | | if (row & 0x02) data &= input_port_read(space->machine, "keyboard_row_fd") & 0xe0; |
| 138 | | if (row & 0x01) data &= input_port_read(space->machine, "keyboard_row_fe") & 0xe0; |
| 131 | /* bit 5-7, keyboard input */ |
| 132 | if (!BIT(offset, 8)) data &= input_port_read(space->machine, "keyboard_row_fe") & 0xe0; |
| 133 | if (!BIT(offset, 9)) data &= input_port_read(space->machine, "keyboard_row_fd") & 0xe0; |
| 134 | if (!BIT(offset, 10)) data &= input_port_read(space->machine, "keyboard_row_fb") & 0xe0; |
| 135 | if (!BIT(offset, 11)) data &= input_port_read(space->machine, "keyboard_row_f7") & 0xe0; |
| 136 | if (!BIT(offset, 12)) data &= input_port_read(space->machine, "keyboard_row_ef") & 0xe0; |
| 137 | if (!BIT(offset, 13)) data &= input_port_read(space->machine, "keyboard_row_df") & 0xe0; |
| 138 | if (!BIT(offset, 14)) data &= input_port_read(space->machine, "keyboard_row_bf") & 0xe0; |
| 139 | if (!BIT(offset, 15)) data &= input_port_read(space->machine, "keyboard_row_7f") & 0xe0; |
| 139 | 140 | |
| 140 | | return data | asic->status; |
| 141 | /* bit 0-4, interrupt source */ |
| 142 | data |= asic->status; |
| 143 | |
| 144 | return data; |
| 141 | 145 | } |
| 142 | 146 | |
| 143 | 147 | static WRITE8_HANDLER( samcoupe_line_int_w ) |
| r5726 | r5727 | |
| 204 | 208 | |
| 205 | 209 | static READ8_HANDLER( samcoupe_keyboard_r ) |
| 206 | 210 | { |
| 207 | | UINT8 data = 0xff; |
| 208 | | UINT8 row = ~(offset >> 8); |
| 211 | const device_config *cassette = devtag_get_device(space->machine, "cassette"); |
| 212 | UINT8 data = 0x1f; |
| 209 | 213 | |
| 210 | | if (row == 0) |
| 211 | | { |
| 212 | | data &= input_port_read(space->machine, "keyboard_row_ff") & 0x1f; |
| 213 | | } |
| 214 | | else |
| 215 | | { |
| 216 | | if (row & 0x80) data &= input_port_read(space->machine, "keyboard_row_7f") & 0x1f; |
| 217 | | if (row & 0x40) data &= input_port_read(space->machine, "keyboard_row_bf") & 0x1f; |
| 218 | | if (row & 0x20) data &= input_port_read(space->machine, "keyboard_row_df") & 0x1f; |
| 219 | | if (row & 0x10) data &= input_port_read(space->machine, "keyboard_row_ef") & 0x1f; |
| 220 | | if (row & 0x08) data &= input_port_read(space->machine, "keyboard_row_f7") & 0x1f; |
| 221 | | if (row & 0x04) data &= input_port_read(space->machine, "keyboard_row_fb") & 0x1f; |
| 222 | | if (row & 0x02) data &= input_port_read(space->machine, "keyboard_row_fd") & 0x1f; |
| 223 | | if (row & 0x01) data &= input_port_read(space->machine, "keyboard_row_fe") & 0x1f; |
| 224 | | } |
| 214 | /* bit 0-4, keyboard input */ |
| 215 | if (!BIT(offset, 8)) data &= input_port_read(space->machine, "keyboard_row_fe") & 0x1f; |
| 216 | if (!BIT(offset, 9)) data &= input_port_read(space->machine, "keyboard_row_fd") & 0x1f; |
| 217 | if (!BIT(offset, 10)) data &= input_port_read(space->machine, "keyboard_row_fb") & 0x1f; |
| 218 | if (!BIT(offset, 11)) data &= input_port_read(space->machine, "keyboard_row_f7") & 0x1f; |
| 219 | if (!BIT(offset, 12)) data &= input_port_read(space->machine, "keyboard_row_ef") & 0x1f; |
| 220 | if (!BIT(offset, 13)) data &= input_port_read(space->machine, "keyboard_row_df") & 0x1f; |
| 221 | if (!BIT(offset, 14)) data &= input_port_read(space->machine, "keyboard_row_bf") & 0x1f; |
| 222 | if (!BIT(offset, 15)) data &= input_port_read(space->machine, "keyboard_row_7f") & 0x1f; |
| 223 | if (offset == 0xff00) data &= input_port_read(space->machine, "keyboard_row_ff") & 0x1f; |
| 225 | 224 | |
| 226 | | return data | 0xe0; |
| 225 | /* bit 5, lightpen strobe */ |
| 226 | data |= 1 << 5; |
| 227 | |
| 228 | /* bit 6, cassette input */ |
| 229 | data |= (cassette_input(cassette) > 0 ? 1 : 0) << 6; |
| 230 | |
| 231 | /* bit 7, external memory */ |
| 232 | data |= 1 << 7; |
| 233 | |
| 234 | logerror("data = %02x\n", data); |
| 235 | |
| 236 | return data; |
| 227 | 237 | } |
| 228 | 238 | |
| 229 | 239 | static WRITE8_HANDLER( samcoupe_border_w ) |
| 230 | 240 | { |
| 241 | const device_config *cassette = devtag_get_device(space->machine, "cassette"); |
| 231 | 242 | const device_config *speaker = devtag_get_device(space->machine, "speaker"); |
| 232 | 243 | coupe_asic *asic = space->machine->driver_data; |
| 244 | |
| 233 | 245 | asic->border = data; |
| 234 | 246 | |
| 235 | | /* DAC output state */ |
| 236 | | speaker_level_w(speaker, (data >> 4) & 0x01); |
| 247 | /* bit 3, cassette output */ |
| 248 | cassette_output(cassette, BIT(data, 3) ? -1.0 : +1.0); |
| 249 | |
| 250 | /* bit 4, beep */ |
| 251 | speaker_level_w(speaker, BIT(data, 4)); |
| 237 | 252 | } |
| 238 | 253 | |
| 239 | 254 | static READ8_HANDLER( samcoupe_attributes_r ) |
| r5726 | r5727 | |
| 482 | 497 | MACHINE DRIVERS |
| 483 | 498 | ***************************************************************************/ |
| 484 | 499 | |
| 500 | static const cassette_config samcoupe_cassette_config = |
| 501 | { |
| 502 | cassette_default_formats, |
| 503 | NULL, |
| 504 | CASSETTE_STOPPED | CASSETTE_SPEAKER_ENABLED | CASSETTE_MOTOR_ENABLED |
| 505 | }; |
| 506 | |
| 485 | 507 | static MACHINE_DRIVER_START( samcoupe ) |
| 486 | 508 | /* basic machine hardware */ |
| 487 | | MDRV_CPU_ADD("maincpu", Z80, SAMCOUPE_XTAL_X1/4) /* 6 MHz */ |
| 509 | MDRV_CPU_ADD("maincpu", Z80, SAMCOUPE_XTAL_X1 / 4) /* 6 MHz */ |
| 488 | 510 | MDRV_CPU_PROGRAM_MAP(samcoupe_mem) |
| 489 | 511 | MDRV_CPU_IO_MAP(samcoupe_io) |
| 490 | 512 | MDRV_CPU_VBLANK_INT("screen", samcoupe_frame_interrupt) |
| 491 | 513 | |
| 492 | 514 | MDRV_MACHINE_RESET(samcoupe) |
| 515 | MDRV_DRIVER_DATA(coupe_asic) |
| 493 | 516 | |
| 494 | 517 | /* video hardware */ |
| 495 | 518 | MDRV_SCREEN_ADD("screen", RASTER) |
| r5726 | r5727 | |
| 502 | 525 | MDRV_VIDEO_ATTRIBUTES(VIDEO_UPDATE_SCANLINE) |
| 503 | 526 | |
| 504 | 527 | /* devices */ |
| 505 | | MDRV_DRIVER_DATA(coupe_asic) |
| 506 | 528 | MDRV_CENTRONICS_ADD("lpt1", standard_centronics) |
| 507 | 529 | MDRV_CENTRONICS_ADD("lpt2", standard_centronics) |
| 508 | 530 | MDRV_MSM6242_ADD("sambus_clock") |
| 531 | MDRV_WD1772_ADD("wd1772", default_wd17xx_interface) |
| 532 | MDRV_CASSETTE_ADD("cassette", samcoupe_cassette_config) |
| 509 | 533 | |
| 510 | 534 | /* sound hardware */ |
| 511 | 535 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| r5726 | r5727 | |
| 513 | 537 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 514 | 538 | MDRV_SOUND_ADD("saa1099", SAA1099, SAMCOUPE_XTAL_X1/3) /* 8 MHz */ |
| 515 | 539 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 516 | | |
| 517 | | MDRV_WD1772_ADD("wd1772", default_wd17xx_interface ) |
| 518 | 540 | MACHINE_DRIVER_END |
| 519 | 541 | |
| 520 | 542 | |