src/mess/drivers/samcoupe.c
| r5674 | r5675 | |
| 1 | 1 | /*************************************************************************** |
| 2 | 2 | |
| 3 | | SAM Coupe Driver - Written By Lee Hammerton |
| 3 | SAM Coupe |
| 4 | 4 | |
| 5 | Miles Gordon Technology, 1989 |
| 5 | 6 | |
| 6 | | Sam Coupe Memory Map - Based around the current spectrum.c (for obvious reasons!!) |
| 7 | Driver by Lee Hammerton, Dirk Best |
| 7 | 8 | |
| 8 | | CPU: |
| 9 | | 0000-7fff Banked rom/ram |
| 10 | | 8000-ffff Banked rom/ram |
| 11 | 9 | |
| 10 | Notes: |
| 11 | ------ |
| 12 | 12 | |
| 13 | | Interrupts: |
| 13 | Beware - the early ROMs are very buggy, and tend to go mad once BASIC |
| 14 | starts paging. ROM 10 (version 1.0) requires the CALL after F9 or BOOT |
| 15 | because the ROM loads the bootstrap but fails to execute it. The address |
| 16 | depends on the RAM size: |
| 14 | 17 | |
| 15 | | Changes: |
| 18 | On a 256K SAM: CALL 229385 |
| 19 | Or on a 512K (or larger) machine: CALL 491529 |
| 16 | 20 | |
| 17 | | V0.2 - Added FDC support. - Based on 1771 document. Coupe had a 1772... (any difference?) |
| 18 | | floppy supports only read sector single mode at present will add write sector |
| 19 | | in next version. |
| 20 | | Fixed up palette - had red & green wrong way round. |
| 21 | 21 | |
| 22 | Todo: |
| 23 | ----- |
| 22 | 24 | |
| 23 | | KT 26-Aug-2000 - Changed to use wd179x code. This is the same as the 1772. |
| 24 | | - Coupe supports the basic disk image format, but can be changed in |
| 25 | | the future to support others |
| 25 | - Tape |
| 26 | - Attribute read |
| 27 | - Better timing |
| 28 | - Harddisk interfaces |
| 26 | 29 | |
| 27 | | Note on the bioses: |
| 28 | | SAM Coupe ROM Images |
| 29 | | -------------------- |
| 30 | | |
| 31 | | This archive contains many versions of the SAM Coupe 32K ROM image, released |
| 32 | | with kind permission from the ROM author, Dr Andy Wright. |
| 33 | | |
| 34 | | Thanks to Simon N Goodwin for supplying the files, which include two dumped |
| 35 | | from pre-production hardware (and which only work with the early hardware!). |
| 36 | | |
| 37 | | Beware - the early ROMs are very buggy, and tend to go mad once BASIC starts |
| 38 | | paging. ROM 10 (version 1.0) requires the CALL after F9 or BOOT because the |
| 39 | | ROM loads the bootstrap but fails to execute it. The address depends on the |
| 40 | | RAM size: |
| 41 | | |
| 42 | | On a 256K SAM: |
| 43 | | |
| 44 | | CALL 229385 |
| 45 | | |
| 46 | | Or on a 512K (or larger) machine: |
| 47 | | |
| 48 | | CALL 491529 |
| 49 | | |
| 50 | | -- |
| 51 | | Uploaded by Simon Owen <simon.owen@simcoupe.org> |
| 52 | | |
| 53 | 30 | ***************************************************************************/ |
| 54 | 31 | |
| 55 | 32 | /* core includes */ |
| r5674 | r5675 | |
| 69 | 46 | #include "formats/coupedsk.h" |
| 70 | 47 | |
| 71 | 48 | |
| 49 | /*************************************************************************** |
| 50 | CONSTANTS |
| 51 | ***************************************************************************/ |
| 52 | |
| 72 | 53 | #define SAMCOUPE_XTAL_X1 XTAL_24MHz |
| 73 | 54 | #define SAMCOUPE_XTAL_X2 XTAL_4_433619MHz |
| 74 | 55 | |
| 75 | 56 | |
| 57 | /*************************************************************************** |
| 58 | I/O PORTS |
| 59 | ***************************************************************************/ |
| 76 | 60 | |
| 77 | | /************************************* |
| 78 | | * |
| 79 | | * I/O port handling |
| 80 | | * |
| 81 | | *************************************/ |
| 82 | | |
| 83 | 61 | static READ8_HANDLER( samcoupe_disk_r ) |
| 84 | 62 | { |
| 85 | 63 | const device_config *fdc = devtag_get_device(space->machine, "wd1772"); |
| r5674 | r5675 | |
| 100 | 78 | return 0xff; |
| 101 | 79 | } |
| 102 | 80 | |
| 103 | | |
| 104 | 81 | static WRITE8_HANDLER( samcoupe_disk_w ) |
| 105 | 82 | { |
| 106 | 83 | const device_config *fdc = devtag_get_device(space->machine, "wd1772"); |
| r5674 | r5675 | |
| 119 | 96 | } |
| 120 | 97 | } |
| 121 | 98 | |
| 122 | | |
| 123 | 99 | static READ8_HANDLER( samcoupe_pen_r ) |
| 124 | 100 | { |
| 125 | 101 | const device_config *scr = space->machine->primary_screen; |
| r5674 | r5675 | |
| 139 | 115 | return data; |
| 140 | 116 | } |
| 141 | 117 | |
| 142 | | |
| 143 | 118 | static WRITE8_HANDLER( samcoupe_clut_w ) |
| 144 | 119 | { |
| 145 | 120 | coupe_asic *asic = space->machine->driver_data; |
| 146 | 121 | asic->clut[(offset >> 8) & 0x0f] = data & 0x7f; |
| 147 | 122 | } |
| 148 | 123 | |
| 149 | | |
| 150 | 124 | static READ8_HANDLER( samcoupe_status_r ) |
| 151 | 125 | { |
| 152 | 126 | coupe_asic *asic = space->machine->driver_data; |
| r5674 | r5675 | |
| 165 | 139 | return data | asic->status; |
| 166 | 140 | } |
| 167 | 141 | |
| 168 | | |
| 169 | 142 | static WRITE8_HANDLER( samcoupe_line_int_w ) |
| 170 | 143 | { |
| 171 | 144 | coupe_asic *asic = space->machine->driver_data; |
| 172 | 145 | asic->line_int = data; |
| 173 | 146 | } |
| 174 | 147 | |
| 175 | | |
| 176 | 148 | static READ8_HANDLER( samcoupe_lmpr_r ) |
| 177 | 149 | { |
| 178 | 150 | coupe_asic *asic = space->machine->driver_data; |
| 179 | 151 | return asic->lmpr; |
| 180 | 152 | } |
| 181 | 153 | |
| 182 | | |
| 183 | 154 | static WRITE8_HANDLER( samcoupe_lmpr_w ) |
| 184 | 155 | { |
| 185 | 156 | const address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| r5674 | r5675 | |
| 189 | 160 | samcoupe_update_memory(space_program); |
| 190 | 161 | } |
| 191 | 162 | |
| 192 | | |
| 193 | 163 | static READ8_HANDLER( samcoupe_hmpr_r ) |
| 194 | 164 | { |
| 195 | 165 | coupe_asic *asic = space->machine->driver_data; |
| 196 | 166 | return asic->hmpr; |
| 197 | 167 | } |
| 198 | 168 | |
| 199 | | |
| 200 | 169 | static WRITE8_HANDLER( samcoupe_hmpr_w ) |
| 201 | 170 | { |
| 202 | 171 | const address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| r5674 | r5675 | |
| 206 | 175 | samcoupe_update_memory(space_program); |
| 207 | 176 | } |
| 208 | 177 | |
| 209 | | |
| 210 | 178 | static READ8_HANDLER( samcoupe_vmpr_r ) |
| 211 | 179 | { |
| 212 | 180 | coupe_asic *asic = space->machine->driver_data; |
| 213 | 181 | return asic->vmpr; |
| 214 | 182 | } |
| 215 | 183 | |
| 216 | | |
| 217 | 184 | static WRITE8_HANDLER( samcoupe_vmpr_w ) |
| 218 | 185 | { |
| 219 | 186 | const address_space *space_program = cputag_get_address_space(space->machine, "maincpu", ADDRESS_SPACE_PROGRAM); |
| r5674 | r5675 | |
| 223 | 190 | samcoupe_update_memory(space_program); |
| 224 | 191 | } |
| 225 | 192 | |
| 226 | | |
| 227 | 193 | static READ8_HANDLER( samcoupe_midi_r ) |
| 228 | 194 | { |
| 229 | 195 | logerror("%s: read from midi port\n", cpuexec_describe_context(space->machine)); |
| 230 | 196 | return 0xff; |
| 231 | 197 | } |
| 232 | 198 | |
| 233 | | |
| 234 | 199 | static WRITE8_HANDLER( samcoupe_midi_w ) |
| 235 | 200 | { |
| 236 | 201 | logerror("%s: write to midi port: 0x%02x\n", cpuexec_describe_context(space->machine), data); |
| 237 | 202 | } |
| 238 | 203 | |
| 239 | | |
| 240 | 204 | static READ8_HANDLER( samcoupe_keyboard_r ) |
| 241 | 205 | { |
| 242 | 206 | UINT8 data = 0xff; |
| r5674 | r5675 | |
| 261 | 225 | return data | 0xe0; |
| 262 | 226 | } |
| 263 | 227 | |
| 264 | | |
| 265 | 228 | static WRITE8_HANDLER( samcoupe_border_w ) |
| 266 | 229 | { |
| 267 | 230 | const device_config *speaker = devtag_get_device(space->machine, "speaker"); |
| r5674 | r5675 | |
| 272 | 235 | speaker_level_w(speaker, (data >> 4) & 0x01); |
| 273 | 236 | } |
| 274 | 237 | |
| 275 | | |
| 276 | 238 | static READ8_HANDLER( samcoupe_attributes_r ) |
| 277 | 239 | { |
| 278 | 240 | if (video_screen_get_vblank(space->machine->primary_screen)) |
| r5674 | r5675 | |
| 288 | 250 | } |
| 289 | 251 | } |
| 290 | 252 | |
| 291 | | |
| 292 | 253 | static READ8_DEVICE_HANDLER( samcoupe_lpt1_busy_r ) |
| 293 | 254 | { |
| 294 | 255 | return centronics_busy_r(device); |
| 295 | 256 | } |
| 296 | 257 | |
| 297 | | |
| 298 | 258 | static WRITE8_DEVICE_HANDLER( samcoupe_lpt1_strobe_w ) |
| 299 | 259 | { |
| 300 | 260 | centronics_strobe_w(device, data); |
| 301 | 261 | } |
| 302 | 262 | |
| 303 | | |
| 304 | 263 | static READ8_DEVICE_HANDLER( samcoupe_lpt2_busy_r ) |
| 305 | 264 | { |
| 306 | 265 | return centronics_busy_r(device); |
| 307 | 266 | } |
| 308 | 267 | |
| 309 | | |
| 310 | 268 | static WRITE8_DEVICE_HANDLER( samcoupe_lpt2_strobe_w ) |
| 311 | 269 | { |
| 312 | 270 | centronics_strobe_w(device, data); |
| 313 | 271 | } |
| 314 | 272 | |
| 315 | 273 | |
| 274 | /*************************************************************************** |
| 275 | ADDRESS MAPS |
| 276 | ***************************************************************************/ |
| 316 | 277 | |
| 317 | | /************************************* |
| 318 | | * |
| 319 | | * Address maps |
| 320 | | * |
| 321 | | *************************************/ |
| 322 | | |
| 323 | 278 | static ADDRESS_MAP_START( samcoupe_mem, ADDRESS_SPACE_PROGRAM, 8 ) |
| 324 | 279 | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) |
| 325 | 280 | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK(2) |
| r5674 | r5675 | |
| 327 | 282 | AM_RANGE(0xc000, 0xffff) AM_RAMBANK(4) |
| 328 | 283 | ADDRESS_MAP_END |
| 329 | 284 | |
| 330 | | |
| 331 | 285 | static ADDRESS_MAP_START( samcoupe_io, ADDRESS_SPACE_IO, 8 ) |
| 332 | 286 | AM_RANGE(0x0080, 0x0081) AM_MIRROR(0xff00) AM_MASK(0xffff) AM_WRITE(samcoupe_ext_mem_w) |
| 333 | 287 | AM_RANGE(0x00e0, 0x00e7) AM_MIRROR(0xff10) AM_MASK(0xffff) AM_READWRITE(samcoupe_disk_r, samcoupe_disk_w) |
| r5674 | r5675 | |
| 348 | 302 | ADDRESS_MAP_END |
| 349 | 303 | |
| 350 | 304 | |
| 305 | /*************************************************************************** |
| 306 | INTERRUPTS |
| 307 | ***************************************************************************/ |
| 351 | 308 | |
| 352 | | /************************************* |
| 353 | | * |
| 354 | | * Interrupts |
| 355 | | * |
| 356 | | *************************************/ |
| 357 | | |
| 358 | 309 | static TIMER_CALLBACK( irq_off ) |
| 359 | 310 | { |
| 360 | 311 | coupe_asic *asic = machine->driver_data; |
| r5674 | r5675 | |
| 366 | 317 | asic->status |= param; |
| 367 | 318 | } |
| 368 | 319 | |
| 369 | | |
| 370 | 320 | void samcoupe_irq(const device_config *device, UINT8 src) |
| 371 | 321 | { |
| 372 | 322 | coupe_asic *asic = device->machine->driver_data; |
| r5674 | r5675 | |
| 379 | 329 | asic->status &= ~src; |
| 380 | 330 | } |
| 381 | 331 | |
| 382 | | |
| 383 | 332 | static INTERRUPT_GEN( samcoupe_frame_interrupt ) |
| 384 | 333 | { |
| 385 | 334 | /* signal frame interrupt */ |
| 386 | | samcoupe_irq(device, 0x08); |
| 335 | samcoupe_irq(device, SAM_FRAME_INT); |
| 387 | 336 | } |
| 388 | 337 | |
| 389 | 338 | |
| 339 | /*************************************************************************** |
| 340 | INPUT PORTS |
| 341 | ***************************************************************************/ |
| 390 | 342 | |
| 391 | | /************************************* |
| 392 | | * |
| 393 | | * Input ports |
| 394 | | * |
| 395 | | *************************************/ |
| 396 | | |
| 397 | 343 | static INPUT_PORTS_START( samcoupe ) |
| 398 | 344 | PORT_START("keyboard_row_fe") |
| 399 | 345 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_CODE(KEYCODE_LSHIFT) PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1) |
| r5674 | r5675 | |
| 489 | 435 | INPUT_PORTS_END |
| 490 | 436 | |
| 491 | 437 | |
| 438 | /*************************************************************************** |
| 439 | PALETTE |
| 440 | ***************************************************************************/ |
| 492 | 441 | |
| 493 | | /************************************* |
| 494 | | * |
| 495 | | * Palette |
| 496 | | * |
| 497 | | *************************************/ |
| 498 | | |
| 499 | 442 | /* |
| 500 | 443 | Decode colours for the palette as follows: |
| 501 | 444 | |
| r5674 | r5675 | |
| 534 | 477 | } |
| 535 | 478 | |
| 536 | 479 | |
| 480 | /*************************************************************************** |
| 481 | MACHINE DRIVERS |
| 482 | ***************************************************************************/ |
| 537 | 483 | |
| 538 | | /************************************* |
| 539 | | * |
| 540 | | * Machine drivers |
| 541 | | * |
| 542 | | *************************************/ |
| 543 | | |
| 544 | 484 | static MACHINE_DRIVER_START( samcoupe ) |
| 545 | 485 | /* basic machine hardware */ |
| 546 | 486 | MDRV_CPU_ADD("maincpu", Z80, SAMCOUPE_XTAL_X1/4) /* 6 MHz */ |
| r5674 | r5675 | |
| 577 | 517 | MACHINE_DRIVER_END |
| 578 | 518 | |
| 579 | 519 | |
| 580 | | /************************************* |
| 581 | | * |
| 582 | | * ROM definitions |
| 583 | | * |
| 584 | | *************************************/ |
| 520 | /*************************************************************************** |
| 521 | ROM DEFINITIONS |
| 522 | ***************************************************************************/ |
| 585 | 523 | |
| 586 | 524 | /* |
| 587 | 525 | The bios is actually 32K. This is the combined version of the two old 16K MESS roms. |
| r5674 | r5675 | |
| 621 | 559 | ROM_END |
| 622 | 560 | |
| 623 | 561 | |
| 562 | /*************************************************************************** |
| 563 | SYSTEM CONFIG |
| 564 | ***************************************************************************/ |
| 624 | 565 | |
| 625 | | /************************************* |
| 626 | | * |
| 627 | | * Devices |
| 628 | | * |
| 629 | | *************************************/ |
| 630 | | |
| 631 | 566 | static void samcoupe_floppy_getinfo(const mess_device_class *devclass, UINT32 state, union devinfo *info) |
| 632 | 567 | { |
| 633 | 568 | /* floppy */ |
| r5674 | r5675 | |
| 643 | 578 | } |
| 644 | 579 | } |
| 645 | 580 | |
| 646 | | |
| 647 | | static SYSTEM_CONFIG_START(samcoupe) |
| 581 | static SYSTEM_CONFIG_START( samcoupe ) |
| 648 | 582 | CONFIG_RAM(256 * 1024) |
| 649 | 583 | CONFIG_RAM_DEFAULT(512 * 1024) |
| 650 | 584 | CONFIG_RAM(256 * 1024 + 1 * 1024 * 1024) |
| r5674 | r5675 | |
| 659 | 593 | SYSTEM_CONFIG_END |
| 660 | 594 | |
| 661 | 595 | |
| 596 | /*************************************************************************** |
| 597 | GAME DRIVERS |
| 598 | ***************************************************************************/ |
| 662 | 599 | |
| 663 | | /************************************* |
| 664 | | * |
| 665 | | * Game drivers |
| 666 | | * |
| 667 | | *************************************/ |
| 668 | | |
| 669 | | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 670 | | COMP( 1989, samcoupe, 0, 0, samcoupe, samcoupe, 0, samcoupe, "Miles Gordon Technology plc", "Sam Coupe", 0 ) |
| 600 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT CONFIG COMPANY FULLNAME FLAGS */ |
| 601 | COMP( 1989, samcoupe, 0, 0, samcoupe, samcoupe, 0, samcoupe, "Miles Gordon Technology plc", "SAM Coupe", 0 ) |