src/mess/drivers/coupe.c
| r2127 | r2128 | |
| 52 | 52 | |
| 53 | 53 | ***************************************************************************/ |
| 54 | 54 | |
| 55 | /* core includes */ |
| 55 | 56 | #include "driver.h" |
| 56 | | #include "deprecat.h" |
| 57 | #include "includes/coupe.h" |
| 58 | |
| 59 | /* components */ |
| 57 | 60 | #include "cpu/z80/z80.h" |
| 58 | | #include "includes/coupe.h" |
| 59 | 61 | #include "machine/wd17xx.h" |
| 60 | | #include "devices/basicdsk.h" |
| 61 | 62 | #include "sound/saa1099.h" |
| 62 | 63 | #include "sound/speaker.h" |
| 63 | 64 | |
| 64 | | static ADDRESS_MAP_START( coupe_mem , ADDRESS_SPACE_PROGRAM, 8) |
| 65 | | AM_RANGE( 0x0000, 0x3FFF) AM_RAMBANK(1) |
| 66 | | AM_RANGE( 0x4000, 0x7FFF) AM_RAMBANK(2) |
| 67 | | AM_RANGE( 0x8000, 0xBFFF) AM_RAMBANK(3) |
| 68 | | AM_RANGE( 0xC000, 0xFFFF) AM_RAMBANK(4) |
| 69 | | ADDRESS_MAP_END |
| 65 | /* devices */ |
| 66 | #include "devices/basicdsk.h" |
| 70 | 67 | |
| 71 | | static INTERRUPT_GEN( coupe_line_interrupt ) |
| 72 | | { |
| 73 | | int interrupted=0; /* This is used to allow me to clear the STAT flag (easiest way I can do it!) */ |
| 74 | 68 | |
| 75 | | HPEN = CURLINE; |
| 76 | 69 | |
| 77 | | if (LINE_INT<192) |
| 78 | | { |
| 79 | | if (CURLINE == LINE_INT) |
| 80 | | { |
| 81 | | /* No other interrupts can occur - NOT CORRECT!!! */ |
| 82 | | STAT=0x1E; |
| 83 | | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 84 | | interrupted=1; |
| 85 | | } |
| 86 | | } |
| 70 | static unsigned char getSamKey1(unsigned char hi); |
| 71 | static unsigned char getSamKey2(unsigned char hi); |
| 87 | 72 | |
| 88 | | CURLINE = (CURLINE + 1) % (192+10); |
| 89 | 73 | |
| 90 | | if (CURLINE == 193) |
| 91 | | { |
| 92 | | if (interrupted) |
| 93 | | STAT&=~0x08; |
| 94 | | else |
| 95 | | STAT=0x17; |
| 96 | | |
| 97 | | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 98 | | interrupted=1; |
| 99 | | } |
| 100 | | |
| 101 | | if (!interrupted) |
| 102 | | STAT=0x1F; |
| 103 | | } |
| 104 | | |
| 105 | | static unsigned char getSamKey1(unsigned char hi) |
| 106 | | { |
| 107 | | unsigned char result; |
| 108 | | |
| 109 | | hi=~hi; |
| 110 | | result=0xFF; |
| 111 | | |
| 112 | | if (hi==0x00) |
| 113 | | result &=readinputport(8) & 0x1F; |
| 114 | | else |
| 115 | | { |
| 116 | | if (hi&0x80) result &= readinputport(7) & 0x1F; |
| 117 | | if (hi&0x40) result &= readinputport(6) & 0x1F; |
| 118 | | if (hi&0x20) result &= readinputport(5) & 0x1F; |
| 119 | | if (hi&0x10) result &= readinputport(4) & 0x1F; |
| 120 | | if (hi&0x08) result &= readinputport(3) & 0x1F; |
| 121 | | if (hi&0x04) result &= readinputport(2) & 0x1F; |
| 122 | | if (hi&0x02) result &= readinputport(1) & 0x1F; |
| 123 | | if (hi&0x01) result &= readinputport(0) & 0x1F; |
| 124 | | } |
| 125 | | |
| 126 | | return result; |
| 127 | | } |
| 128 | | |
| 129 | | static unsigned char getSamKey2(unsigned char hi) |
| 130 | | { |
| 131 | | unsigned char result; |
| 132 | | |
| 133 | | hi=~hi; |
| 134 | | result=0xFF; |
| 135 | | |
| 136 | | if (hi==0x00) |
| 137 | | { |
| 138 | | /* does not map to any keys? */ |
| 139 | | } |
| 140 | | else |
| 141 | | { |
| 142 | | if (hi&0x80) result &= readinputport(7) & 0xE0; |
| 143 | | if (hi&0x40) result &= readinputport(6) & 0xE0; |
| 144 | | if (hi&0x20) result &= readinputport(5) & 0xE0; |
| 145 | | if (hi&0x10) result &= readinputport(4) & 0xE0; |
| 146 | | if (hi&0x08) result &= readinputport(3) & 0xE0; |
| 147 | | if (hi&0x04) result &= readinputport(2) & 0xE0; |
| 148 | | if (hi&0x02) result &= readinputport(1) & 0xE0; |
| 149 | | if (hi&0x01) result &= readinputport(0) & 0xE0; |
| 150 | | } |
| 151 | | |
| 152 | | return result; |
| 153 | | } |
| 154 | | |
| 155 | | |
| 156 | 74 | static READ8_HANDLER( coupe_port_r ) |
| 157 | 75 | { |
| 158 | 76 | if (offset==SSND_ADDR) /* Sound address request */ |
| r2127 | r2128 | |
| 181 | 99 | return wd17xx_data_r(machine, 0); |
| 182 | 100 | case LPEN_PORT: |
| 183 | 101 | return LPEN; |
| 184 | | case STAT_PORT: |
| 102 | case STAT_PORT: |
| 185 | 103 | return ((getSamKey2((offset >> 8)&0xFF))&0xE0) | STAT; |
| 186 | 104 | case LMPR_PORT: |
| 187 | 105 | return LMPR; |
| r2127 | r2128 | |
| 268 | 186 | } |
| 269 | 187 | } |
| 270 | 188 | |
| 271 | | static ADDRESS_MAP_START( coupe_io , ADDRESS_SPACE_IO, 8) |
| 272 | | AM_RANGE( 0x0000, 0x0ffff) AM_READWRITE( coupe_port_r, coupe_port_w ) |
| 189 | |
| 190 | |
| 191 | /************************************* |
| 192 | * |
| 193 | * Address maps |
| 194 | * |
| 195 | *************************************/ |
| 196 | |
| 197 | static ADDRESS_MAP_START( coupe_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 198 | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) |
| 199 | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK(2) |
| 200 | AM_RANGE(0x8000, 0xbfff) AM_RAMBANK(3) |
| 201 | AM_RANGE(0xc000, 0xffff) AM_RAMBANK(4) |
| 273 | 202 | ADDRESS_MAP_END |
| 274 | 203 | |
| 275 | | static GFXDECODE_START( coupe_gfxdecodeinfo ) |
| 276 | | GFXDECODE_END |
| 204 | static ADDRESS_MAP_START( coupe_io, ADDRESS_SPACE_IO, 8 ) |
| 205 | AM_RANGE(0x0000, 0x0ffff) AM_READWRITE(coupe_port_r, coupe_port_w) |
| 206 | ADDRESS_MAP_END |
| 277 | 207 | |
| 208 | |
| 209 | |
| 210 | /************************************* |
| 211 | * |
| 212 | * Interrupts |
| 213 | * |
| 214 | *************************************/ |
| 215 | |
| 216 | static TIMER_CALLBACK( irq_off ) |
| 217 | { |
| 218 | /* clear interrupt */ |
| 219 | cpunum_set_input_line(machine, 0, 0, CLEAR_LINE); |
| 220 | |
| 221 | /* adjust STATUS register */ |
| 222 | STAT |= param; |
| 223 | } |
| 224 | |
| 225 | |
| 226 | void coupe_irq(running_machine *machine, UINT8 src) |
| 227 | { |
| 228 | /* set irq and a timer to set it off again */ |
| 229 | cpunum_set_input_line(machine, 0, 0, HOLD_LINE); |
| 230 | timer_set(ATTOTIME_IN_USEC(20), NULL, src, irq_off); |
| 231 | |
| 232 | /* adjust STATUS register */ |
| 233 | STAT &= ~src; |
| 234 | } |
| 235 | |
| 236 | |
| 237 | static INTERRUPT_GEN( coupe_frame_interrupt ) |
| 238 | { |
| 239 | /* signal frame interrupt */ |
| 240 | coupe_irq(machine, 0x08); |
| 241 | } |
| 242 | |
| 243 | |
| 244 | |
| 245 | /************************************* |
| 246 | * |
| 247 | * Inputs |
| 248 | * |
| 249 | *************************************/ |
| 250 | |
| 251 | static unsigned char getSamKey1(unsigned char hi) |
| 252 | { |
| 253 | unsigned char result; |
| 254 | |
| 255 | hi=~hi; |
| 256 | result=0xFF; |
| 257 | |
| 258 | if (hi==0x00) |
| 259 | result &=readinputport(8) & 0x1F; |
| 260 | else |
| 261 | { |
| 262 | if (hi&0x80) result &= readinputport(7) & 0x1F; |
| 263 | if (hi&0x40) result &= readinputport(6) & 0x1F; |
| 264 | if (hi&0x20) result &= readinputport(5) & 0x1F; |
| 265 | if (hi&0x10) result &= readinputport(4) & 0x1F; |
| 266 | if (hi&0x08) result &= readinputport(3) & 0x1F; |
| 267 | if (hi&0x04) result &= readinputport(2) & 0x1F; |
| 268 | if (hi&0x02) result &= readinputport(1) & 0x1F; |
| 269 | if (hi&0x01) result &= readinputport(0) & 0x1F; |
| 270 | } |
| 271 | |
| 272 | return result; |
| 273 | } |
| 274 | |
| 275 | |
| 276 | static unsigned char getSamKey2(unsigned char hi) |
| 277 | { |
| 278 | unsigned char result; |
| 279 | |
| 280 | hi=~hi; |
| 281 | result=0xFF; |
| 282 | |
| 283 | if (hi==0x00) |
| 284 | { |
| 285 | /* does not map to any keys? */ |
| 286 | } |
| 287 | else |
| 288 | { |
| 289 | if (hi&0x80) result &= readinputport(7) & 0xE0; |
| 290 | if (hi&0x40) result &= readinputport(6) & 0xE0; |
| 291 | if (hi&0x20) result &= readinputport(5) & 0xE0; |
| 292 | if (hi&0x10) result &= readinputport(4) & 0xE0; |
| 293 | if (hi&0x08) result &= readinputport(3) & 0xE0; |
| 294 | if (hi&0x04) result &= readinputport(2) & 0xE0; |
| 295 | if (hi&0x02) result &= readinputport(1) & 0xE0; |
| 296 | if (hi&0x01) result &= readinputport(0) & 0xE0; |
| 297 | } |
| 298 | |
| 299 | return result; |
| 300 | } |
| 301 | |
| 302 | |
| 278 | 303 | static INPUT_PORTS_START( coupe ) |
| 279 | 304 | PORT_START // FE 0 |
| 280 | 305 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("SHIFT") PORT_CODE(KEYCODE_LSHIFT) |
| r2127 | r2128 | |
| 414 | 439 | |
| 415 | 440 | |
| 416 | 441 | |
| 442 | /************************************* |
| 443 | * |
| 444 | * Machine drivers |
| 445 | * |
| 446 | *************************************/ |
| 447 | |
| 417 | 448 | static MACHINE_DRIVER_START( coupe ) |
| 418 | 449 | /* basic machine hardware */ |
| 419 | 450 | MDRV_CPU_ADD(Z80, 6000000) /* 6 Mhz */ |
| 420 | 451 | MDRV_CPU_PROGRAM_MAP(coupe_mem, 0) |
| 421 | 452 | MDRV_CPU_IO_MAP(coupe_io, 0) |
| 422 | | MDRV_CPU_VBLANK_INT_HACK(coupe_line_interrupt, 192 + 10) /* 192 scanlines + 10 lines of vblank (approx).. */ |
| 423 | | MDRV_SCREEN_ADD("main", RASTER) |
| 424 | | MDRV_SCREEN_REFRESH_RATE(50) |
| 425 | | MDRV_SCREEN_VBLANK_TIME(0) |
| 426 | | MDRV_INTERLEAVE(1) |
| 427 | | |
| 453 | MDRV_CPU_VBLANK_INT("main", coupe_frame_interrupt) |
| 428 | 454 | MDRV_MACHINE_START( coupe ) |
| 429 | 455 | |
| 430 | 456 | /* video hardware */ |
| 457 | MDRV_SCREEN_ADD("main", RASTER) |
| 458 | MDRV_SCREEN_REFRESH_RATE(50) |
| 459 | MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) |
| 431 | 460 | MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16) |
| 432 | | MDRV_SCREEN_SIZE(64*8, 24*8) |
| 461 | MDRV_SCREEN_SIZE(64*8, 24*8 + 10) |
| 433 | 462 | MDRV_SCREEN_VISIBLE_AREA(0, 64*8-1, 0, 24*8-1) |
| 434 | | MDRV_GFXDECODE( coupe_gfxdecodeinfo ) |
| 435 | 463 | MDRV_PALETTE_LENGTH(128) |
| 436 | 464 | MDRV_PALETTE_INIT(coupe) |
| 437 | 465 | |
| r2127 | r2128 | |
| 446 | 474 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 447 | 475 | MACHINE_DRIVER_END |
| 448 | 476 | |
| 449 | | /*************************************************************************** |
| 450 | 477 | |
| 451 | | Game driver(s) |
| 452 | 478 | |
| 453 | | ***************************************************************************/ |
| 479 | /************************************* |
| 480 | * |
| 481 | * ROM definitions |
| 482 | * |
| 483 | *************************************/ |
| 454 | 484 | |
| 455 | 485 | ROM_START(coupe) |
| 456 | 486 | ROM_REGION(0x8000,REGION_CPU1,0) |
| r2127 | r2128 | |
| 489 | 519 | ROMX_LOAD("rom30", 0x0000, 0x8000, CRC(e535c25d) SHA1(d390f0be420dfb12b1e54a4f528b5055d7d97e2a), ROM_BIOS(14)) |
| 490 | 520 | ROM_END |
| 491 | 521 | |
| 522 | |
| 523 | |
| 524 | /************************************* |
| 525 | * |
| 526 | * Devices |
| 527 | * |
| 528 | *************************************/ |
| 529 | |
| 492 | 530 | static void coupe_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 493 | 531 | { |
| 494 | 532 | /* floppy */ |
| 495 | 533 | switch(state) |
| 496 | 534 | { |
| 497 | 535 | /* --- the following bits of info are returned as 64-bit signed integers --- */ |
| 498 | | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 536 | case MESS_DEVINFO_INT_COUNT: info->i = 2; break; |
| 499 | 537 | |
| 500 | 538 | /* --- the following bits of info are returned as pointers to data or functions --- */ |
| 501 | | case MESS_DEVINFO_PTR_LOAD: info->load = device_load_coupe_floppy; break; |
| 539 | case MESS_DEVINFO_PTR_LOAD: info->load = device_load_coupe_floppy; break; |
| 502 | 540 | |
| 503 | 541 | /* --- the following bits of info are returned as NULL-terminated strings --- */ |
| 504 | | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break; |
| 542 | case MESS_DEVINFO_STR_FILE_EXTENSIONS: strcpy(info->s = device_temp_str(), "dsk"); break; |
| 505 | 543 | |
| 506 | | default: legacybasicdsk_device_getinfo(devclass, state, info); break; |
| 544 | default: legacybasicdsk_device_getinfo(devclass, state, info); break; |
| 507 | 545 | } |
| 508 | 546 | } |
| 509 | 547 | |
| 548 | |
| 510 | 549 | SYSTEM_CONFIG_START(coupe) |
| 511 | 550 | CONFIG_RAM_DEFAULT(256 * 1024) |
| 512 | 551 | CONFIG_RAM(512 * 1024) |
| r2127 | r2128 | |
| 514 | 553 | CONFIG_DEVICE(coupe_floppy_getinfo) |
| 515 | 554 | SYSTEM_CONFIG_END |
| 516 | 555 | |
| 517 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME */ |
| 518 | | COMP( 1989, coupe, 0, 0, coupe, coupe, 0, coupe, "Miles Gordon Technology plc", "Sam Coupe" , 0) |
| 556 | |
| 557 | |
| 558 | /************************************* |
| 559 | * |
| 560 | * Game drivers |
| 561 | * |
| 562 | *************************************/ |
| 563 | |
| 564 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 565 | COMP( 1989, coupe, 0, 0, coupe, coupe, 0, coupe, "Miles Gordon Technology plc", "Sam Coupe", 0 ) |