src/mess/drivers/samcoupe.c
| r4093 | r4094 | |
| 54 | 54 | |
| 55 | 55 | /* core includes */ |
| 56 | 56 | #include "driver.h" |
| 57 | | #include "cpu/z80/z80.h" |
| 58 | 57 | #include "includes/samcoupe.h" |
| 59 | 58 | |
| 60 | 59 | /* components */ |
| 60 | #include "cpu/z80/z80.h" |
| 61 | 61 | #include "machine/wd17xx.h" |
| 62 | #include "machine/msm6242.h" |
| 62 | 63 | #include "sound/saa1099.h" |
| 63 | 64 | #include "sound/speaker.h" |
| 64 | | #include "machine/msm6242.h" |
| 65 | 65 | |
| 66 | 66 | /* devices */ |
| 67 | 67 | #include "devices/mflopimg.h" |
| r4093 | r4094 | |
| 81 | 81 | |
| 82 | 82 | static READ8_HANDLER( samcoupe_disk_r ) |
| 83 | 83 | { |
| 84 | | device_config *fdc = (device_config*)devtag_get_device(space->machine, WD1772, "wd1772"); |
| 85 | | |
| 84 | const device_config *fdc = devtag_get_device(space->machine, WD1772, "wd1772"); |
| 85 | |
| 86 | 86 | /* drive and side is encoded into bit 5 and 3 */ |
| 87 | | wd17xx_set_drive(fdc,(offset >> 4) & 1); |
| 88 | | wd17xx_set_side(fdc,(offset >> 2) & 1); |
| 87 | wd17xx_set_drive(fdc, (offset >> 4) & 1); |
| 88 | wd17xx_set_side(fdc, (offset >> 2) & 1); |
| 89 | 89 | |
| 90 | 90 | /* bit 1 and 2 select the controller register */ |
| 91 | 91 | switch (offset & 0x03) |
| r4093 | r4094 | |
| 102 | 102 | |
| 103 | 103 | static WRITE8_HANDLER( samcoupe_disk_w ) |
| 104 | 104 | { |
| 105 | | device_config *fdc = (device_config*)devtag_get_device(space->machine, WD1772, "wd1772"); |
| 105 | const device_config *fdc = devtag_get_device(space->machine, WD1772, "wd1772"); |
| 106 | 106 | |
| 107 | 107 | /* drive and side is encoded into bit 5 and 3 */ |
| 108 | | wd17xx_set_drive(fdc,(offset >> 4) & 1); |
| 109 | | wd17xx_set_side(fdc,(offset >> 2) & 1); |
| 108 | wd17xx_set_drive(fdc, (offset >> 4) & 1); |
| 109 | wd17xx_set_side(fdc, (offset >> 2) & 1); |
| 110 | 110 | |
| 111 | 111 | /* bit 1 and 2 select the controller register */ |
| 112 | 112 | switch (offset & 0x03) |
| r4093 | r4094 | |
| 121 | 121 | |
| 122 | 122 | static READ8_HANDLER( samcoupe_pen_r ) |
| 123 | 123 | { |
| 124 | const device_config *scr = space->machine->primary_screen; |
| 124 | 125 | UINT8 data; |
| 125 | 126 | |
| 126 | 127 | if (offset & 0x100) |
| 127 | 128 | { |
| 128 | 129 | /* return either the current line or 192 for the vblank area */ |
| 129 | | data = video_screen_get_vblank(space->machine->primary_screen) ? 192 : video_screen_get_vpos(space->machine->primary_screen); |
| 130 | data = video_screen_get_vblank(scr) ? 192 : video_screen_get_vpos(scr); |
| 130 | 131 | } |
| 131 | 132 | else |
| 132 | 133 | { |
| 133 | 134 | /* horizontal position is encoded into bits 3 to 8 */ |
| 134 | | data = video_screen_get_hpos(space->machine->primary_screen) & 0xfc; |
| 135 | data = video_screen_get_hpos(scr) & 0xfc; |
| 135 | 136 | } |
| 136 | 137 | |
| 137 | 138 | return data; |
| r4093 | r4094 | |
| 180 | 181 | |
| 181 | 182 | static WRITE8_HANDLER( samcoupe_lmpr_w ) |
| 182 | 183 | { |
| 183 | | const address_space *space_program = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 184 | const address_space *space_program = cputag_get_address_space(space->machine, "main", ADDRESS_SPACE_PROGRAM); |
| 184 | 185 | coupe_asic *asic = space->machine->driver_data; |
| 186 | |
| 185 | 187 | asic->lmpr = data; |
| 186 | 188 | samcoupe_update_memory(space_program); |
| 187 | 189 | } |
| r4093 | r4094 | |
| 196 | 198 | |
| 197 | 199 | static WRITE8_HANDLER( samcoupe_hmpr_w ) |
| 198 | 200 | { |
| 199 | | const address_space *space_program = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 201 | const address_space *space_program = cputag_get_address_space(space->machine, "main", ADDRESS_SPACE_PROGRAM); |
| 200 | 202 | coupe_asic *asic = space->machine->driver_data; |
| 203 | |
| 201 | 204 | asic->hmpr = data; |
| 202 | 205 | samcoupe_update_memory(space_program); |
| 203 | 206 | } |
| r4093 | r4094 | |
| 212 | 215 | |
| 213 | 216 | static WRITE8_HANDLER( samcoupe_vmpr_w ) |
| 214 | 217 | { |
| 215 | | const address_space *space_program = cpu_get_address_space(space->machine->cpu[0], ADDRESS_SPACE_PROGRAM); |
| 218 | const address_space *space_program = cputag_get_address_space(space->machine, "main", ADDRESS_SPACE_PROGRAM); |
| 216 | 219 | coupe_asic *asic = space->machine->driver_data; |
| 220 | |
| 217 | 221 | asic->vmpr = data; |
| 218 | 222 | samcoupe_update_memory(space_program); |
| 219 | 223 | } |
| r4093 | r4094 | |
| 221 | 225 | |
| 222 | 226 | static READ8_HANDLER( samcoupe_midi_r ) |
| 223 | 227 | { |
| 224 | | logerror("Read from midi port\n"); |
| 228 | logerror("%s: read from midi port\n", cpuexec_describe_context(space->machine)); |
| 225 | 229 | return 0xff; |
| 226 | 230 | } |
| 227 | 231 | |
| 228 | 232 | |
| 229 | 233 | static WRITE8_HANDLER( samcoupe_midi_w ) |
| 230 | 234 | { |
| 231 | | logerror("Write to midi port: 0x%02x\n", data); |
| 235 | logerror("%s: write to midi port: 0x%02x\n", cpuexec_describe_context(space->machine), data); |
| 232 | 236 | } |
| 233 | 237 | |
| 234 | 238 | |
| r4093 | r4094 | |
| 263 | 267 | asic->border = data; |
| 264 | 268 | |
| 265 | 269 | /* DAC output state */ |
| 266 | | speaker_level_w(0,(data >> 4) & 0x01); |
| 270 | speaker_level_w(0, (data >> 4) & 0x01); |
| 267 | 271 | } |
| 268 | 272 | |
| 269 | 273 | |
| r4093 | r4094 | |
| 333 | 337 | coupe_asic *asic = machine->driver_data; |
| 334 | 338 | |
| 335 | 339 | /* clear interrupt */ |
| 336 | | cpu_set_input_line(machine->cpu[0], 0, CLEAR_LINE); |
| 340 | cputag_set_input_line(machine, "main", 0, CLEAR_LINE); |
| 337 | 341 | |
| 338 | 342 | /* adjust STATUS register */ |
| 339 | 343 | asic->status |= param; |
| r4093 | r4094 | |
| 344 | 348 | { |
| 345 | 349 | coupe_asic *asic = device->machine->driver_data; |
| 346 | 350 | |
| 347 | | /* set irq and a timer to set it off again */ |
| 348 | | cpu_set_input_line(device, 0, HOLD_LINE); |
| 351 | /* assert irq and a timer to set it off again */ |
| 352 | cpu_set_input_line(device, 0, ASSERT_LINE); |
| 349 | 353 | timer_set(device->machine, ATTOTIME_IN_USEC(20), NULL, src, irq_off); |
| 350 | 354 | |
| 351 | 355 | /* adjust STATUS register */ |
| r4093 | r4094 | |
| 543 | 547 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 544 | 548 | MDRV_SOUND_ADD("saa1099", SAA1099, SAMCOUPE_XTAL_X1/3) /* 8 MHz */ |
| 545 | 549 | MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 546 | | |
| 547 | | MDRV_WD1772_ADD("wd1772", default_wd17xx_interface ) |
| 550 | |
| 551 | MDRV_WD1772_ADD("wd1772", default_wd17xx_interface ) |
| 548 | 552 | MACHINE_DRIVER_END |
| 549 | 553 | |
| 550 | 554 | |