src/mess/machine/apple1.c
| r4392 | r4393 | |
| 44 | 44 | |
| 45 | 45 | ***************************************************************************/ |
| 46 | 46 | |
| 47 | | #include <stdarg.h> |
| 48 | 47 | #include "driver.h" |
| 49 | 48 | #include "includes/apple1.h" |
| 50 | | #include "machine/6821pia.h" |
| 49 | #include "machine/6821new.h" |
| 51 | 50 | #include "cpu/m6502/m6502.h" |
| 52 | 51 | #include "image.h" |
| 53 | 52 | #include "devices/cassette.h" |
| r4392 | r4393 | |
| 55 | 54 | static TIMER_CALLBACK(apple1_kbd_poll); |
| 56 | 55 | static TIMER_CALLBACK(apple1_kbd_strobe_end); |
| 57 | 56 | |
| 58 | | static READ8_HANDLER( apple1_pia0_kbdin ); |
| 59 | | static WRITE8_HANDLER( apple1_pia0_dspout ); |
| 60 | | static WRITE8_HANDLER( apple1_pia0_dsp_write_signal ); |
| 57 | static READ8_DEVICE_HANDLER( apple1_pia0_kbdin ); |
| 58 | static WRITE8_DEVICE_HANDLER( apple1_pia0_dspout ); |
| 59 | static WRITE8_DEVICE_HANDLER( apple1_pia0_dsp_write_signal ); |
| 61 | 60 | |
| 62 | 61 | static TIMER_CALLBACK(apple1_dsp_ready_start); |
| 63 | 62 | static TIMER_CALLBACK(apple1_dsp_ready_end); |
| r4392 | r4393 | |
| 71 | 70 | rather than updating them when they are read; thus they don't need |
| 72 | 71 | handler functions. */ |
| 73 | 72 | |
| 74 | | static const pia6821_interface apple1_pia0 = |
| 73 | const pia6821_interface apple1_pia0 = |
| 75 | 74 | { |
| 76 | | apple1_pia0_kbdin, /* Port A input (keyboard) */ |
| 77 | | 0, /* Port B input (display status) */ |
| 78 | | 0, /* CA1 input (key pressed) */ |
| 79 | | 0, /* CB1 input (display ready) */ |
| 80 | | 0, /* CA2 not used as input */ |
| 81 | | 0, /* CB2 not used as input */ |
| 82 | | 0, /* Port A not used as output */ |
| 83 | | apple1_pia0_dspout, /* Port B output (display) */ |
| 84 | | 0, /* CA2 not used as output */ |
| 85 | | apple1_pia0_dsp_write_signal, /* CB2 output (display write) */ |
| 86 | | 0, /* IRQA not connected */ |
| 87 | | 0 /* IRQB not connected */ |
| 75 | DEVCB_HANDLER(apple1_pia0_kbdin), /* Port A input (keyboard) */ |
| 76 | DEVCB_NULL, /* Port B input (display status) */ |
| 77 | DEVCB_NULL, /* CA1 input (key pressed) */ |
| 78 | DEVCB_NULL, /* CB1 input (display ready) */ |
| 79 | DEVCB_NULL, /* CA2 not used as input */ |
| 80 | DEVCB_NULL, /* CB2 not used as input */ |
| 81 | DEVCB_NULL, /* Port A not used as output */ |
| 82 | DEVCB_HANDLER(apple1_pia0_dspout), /* Port B output (display) */ |
| 83 | DEVCB_NULL, /* CA2 not used as output */ |
| 84 | DEVCB_HANDLER(apple1_pia0_dsp_write_signal), /* CB2 output (display write) */ |
| 85 | DEVCB_NULL, /* IRQA not connected */ |
| 86 | DEVCB_NULL /* IRQB not connected */ |
| 88 | 87 | }; |
| 89 | 88 | |
| 90 | 89 | /* Use the same keyboard mapping as on a modern keyboard. This is not |
| r4392 | r4393 | |
| 153 | 152 | 0x0000, mess_ram_size - 1, 0, 0, SMH_BANK1); |
| 154 | 153 | memory_set_bankptr(machine,1, mess_ram); |
| 155 | 154 | |
| 156 | | pia_config(machine, 0, &apple1_pia0); |
| 157 | | |
| 158 | 155 | /* Poll the keyboard input ports periodically. These include both |
| 159 | 156 | ordinary keys and the RESET and CLEAR SCREEN pushbutton |
| 160 | 157 | switches. We can't handle these switches in a VBLANK_INT or |
| r4392 | r4393 | |
| 175 | 172 | |
| 176 | 173 | MACHINE_RESET( apple1 ) |
| 177 | 174 | { |
| 178 | | /* Reset the PIA and the display hardware. */ |
| 179 | | pia_reset(); |
| 175 | /* Reset the display hardware. */ |
| 180 | 176 | apple1_vh_dsp_clr(); |
| 181 | 177 | } |
| 182 | 178 | |
| r4392 | r4393 | |
| 289 | 285 | int port, bit; |
| 290 | 286 | int key_pressed; |
| 291 | 287 | UINT32 shiftkeys, ctrlkeys; |
| 288 | const device_config *pia = devtag_get_device( machine, PIA6821, "pia" ); |
| 292 | 289 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" }; |
| 293 | 290 | |
| 294 | 291 | /* This holds the values of all the input ports for ordinary keys |
| r4392 | r4393 | |
| 306 | 303 | reset_flag = 1; |
| 307 | 304 | /* using PULSE_LINE does not allow us to press and hold key */ |
| 308 | 305 | cpu_set_input_line(machine->cpu[0], INPUT_LINE_RESET, ASSERT_LINE); |
| 309 | | pia_reset(); |
| 306 | device_reset( pia ); |
| 310 | 307 | } |
| 311 | 308 | } |
| 312 | 309 | else if (reset_flag) { |
| r4392 | r4393 | |
| 339 | 336 | key_pressed = 0; |
| 340 | 337 | |
| 341 | 338 | /* The keyboard strobe line should always be low when a scan starts. */ |
| 342 | | pia_set_input_ca1(0, 0); |
| 339 | pia_ca1_w(pia, 0, 0); |
| 343 | 340 | |
| 344 | 341 | shiftkeys = input_port_read(machine, "KEY4") & 0x0003; |
| 345 | 342 | ctrlkeys = input_port_read(machine, "KEY4") & 0x000c; |
| r4392 | r4393 | |
| 373 | 370 | { |
| 374 | 371 | /* The keyboard will pulse its strobe line when a key is |
| 375 | 372 | pressed. A 10-usec pulse is typical. */ |
| 376 | | pia_set_input_ca1(0, 1); |
| 373 | pia_ca1_w(pia, 0, 1); |
| 377 | 374 | timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, apple1_kbd_strobe_end); |
| 378 | 375 | } |
| 379 | 376 | } |
| 380 | 377 | |
| 381 | 378 | static TIMER_CALLBACK(apple1_kbd_strobe_end) |
| 382 | 379 | { |
| 380 | const device_config *pia = devtag_get_device( machine, PIA6821, "pia" ); |
| 381 | |
| 383 | 382 | /* End of the keyboard strobe pulse. */ |
| 384 | | pia_set_input_ca1(0, 0); |
| 383 | pia_ca1_w(pia, 0, 0); |
| 385 | 384 | } |
| 386 | 385 | |
| 387 | 386 | |
| 388 | 387 | /***************************************************************************** |
| 389 | 388 | ** READ/WRITE HANDLERS |
| 390 | 389 | *****************************************************************************/ |
| 391 | | static READ8_HANDLER( apple1_pia0_kbdin ) |
| 390 | static READ8_DEVICE_HANDLER( apple1_pia0_kbdin ) |
| 392 | 391 | { |
| 393 | 392 | /* Bit 7 of the keyboard input is permanently wired high. This is |
| 394 | 393 | what the ROM Monitor software expects. */ |
| 395 | 394 | return apple1_kbd_data | 0x80; |
| 396 | 395 | } |
| 397 | 396 | |
| 398 | | static WRITE8_HANDLER( apple1_pia0_dspout ) |
| 397 | static WRITE8_DEVICE_HANDLER( apple1_pia0_dspout ) |
| 399 | 398 | { |
| 400 | 399 | /* Send an ASCII character to the video hardware. */ |
| 401 | 400 | apple1_vh_dsp_w(data); |
| 402 | 401 | } |
| 403 | 402 | |
| 404 | | static WRITE8_HANDLER( apple1_pia0_dsp_write_signal ) |
| 403 | static WRITE8_DEVICE_HANDLER( apple1_pia0_dsp_write_signal ) |
| 405 | 404 | { |
| 406 | 405 | /* PIA output CB2 is inverted to become the DA signal, used to |
| 407 | 406 | signal a display write to the video hardware. */ |
| r4392 | r4393 | |
| 409 | 408 | /* DA is directly connected to PIA input PB7, so the processor can |
| 410 | 409 | read bit 7 of port B to test whether the display has completed |
| 411 | 410 | a write. */ |
| 412 | | pia_set_input_b(0, (!data) << 7); |
| 411 | pia_portb_w(device, 0, (!data) << 7); |
| 413 | 412 | |
| 414 | 413 | /* Once DA is asserted, the display will wait until it can perform |
| 415 | 414 | the write, when the cursor position is about to be refreshed. |
| r4392 | r4393 | |
| 417 | 416 | write. Thus the write delay depends on the cursor position and |
| 418 | 417 | where the display is in the refresh cycle. */ |
| 419 | 418 | if (!data) |
| 420 | | timer_set(space->machine, apple1_vh_dsp_time_to_ready(space->machine), NULL, 0, apple1_dsp_ready_start); |
| 419 | timer_set(device->machine, apple1_vh_dsp_time_to_ready(device->machine), NULL, 0, apple1_dsp_ready_start); |
| 421 | 420 | } |
| 422 | 421 | |
| 423 | 422 | static TIMER_CALLBACK(apple1_dsp_ready_start) |
| 424 | 423 | { |
| 424 | const device_config *pia = devtag_get_device( machine, PIA6821, "pia" ); |
| 425 | |
| 425 | 426 | /* When the display asserts \RDA to signal it is ready, it |
| 426 | 427 | triggers a 74123 one-shot to send a 3.5-usec low pulse to PIA |
| 427 | 428 | input CB1. The end of this pulse will tell the PIA that the |
| 428 | 429 | display is ready for another write. */ |
| 429 | | pia_set_input_cb1(0, 0); |
| 430 | pia_cb1_w(pia, 0, 0); |
| 430 | 431 | timer_set(machine, ATTOTIME_IN_NSEC(3500), NULL, 0, apple1_dsp_ready_end); |
| 431 | 432 | } |
| 432 | 433 | |
| 433 | 434 | static TIMER_CALLBACK(apple1_dsp_ready_end) |
| 434 | 435 | { |
| 436 | const device_config *pia = devtag_get_device( machine, PIA6821, "pia" ); |
| 437 | |
| 435 | 438 | /* The one-shot pulse has ended; return CB1 to high, so we can do |
| 436 | 439 | another display write. */ |
| 437 | | pia_set_input_cb1(0, 1); |
| 440 | pia_cb1_w(pia, 0, 1); |
| 438 | 441 | } |
| 439 | 442 | |
| 440 | 443 | |
src/mess/drivers/atari.c
| r4392 | r4393 | |
| 12 | 12 | #include "includes/atari.h" |
| 13 | 13 | #include "devices/cartslot.h" |
| 14 | 14 | #include "sound/pokey.h" |
| 15 | | #include "machine/6821pia.h" |
| 15 | #include "machine/6821new.h" |
| 16 | 16 | #include "video/gtia.h" |
| 17 | 17 | #include "sound/dac.h" |
| 18 | 18 | |
| r4392 | r4393 | |
| 212 | 212 | AM_RANGE(0xd000, 0xd0ff) AM_READWRITE(atari_gtia_r, atari_gtia_w) |
| 213 | 213 | AM_RANGE(0xd100, 0xd1ff) AM_NOP |
| 214 | 214 | AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE(SOUND, "pokey", pokey_r, pokey_w) |
| 215 | | AM_RANGE(0xd300, 0xd3ff) AM_READWRITE(pia_0_alt_r, pia_0_alt_w) |
| 215 | AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE(PIA6821, "pia", pia_alt_r, pia_alt_w) |
| 216 | 216 | AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w) |
| 217 | 217 | AM_RANGE(0xd500, 0xd7ff) AM_NOP |
| 218 | 218 | AM_RANGE(0xd800, 0xffff) AM_ROM |
| r4392 | r4393 | |
| 226 | 226 | AM_RANGE(0xd000, 0xd0ff) AM_READWRITE(atari_gtia_r, atari_gtia_w) |
| 227 | 227 | AM_RANGE(0xd100, 0xd1ff) AM_NOP |
| 228 | 228 | AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE(SOUND, "pokey", pokey_r, pokey_w) |
| 229 | | AM_RANGE(0xd300, 0xd3ff) AM_READWRITE(pia_0_alt_r, pia_0_alt_w) |
| 229 | AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE(PIA6821, "pia", pia_alt_r, pia_alt_w) |
| 230 | 230 | AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w) |
| 231 | 231 | AM_RANGE(0xd500, 0xd7ff) AM_NOP |
| 232 | 232 | AM_RANGE(0xd800, 0xffff) AM_ROM |
| r4392 | r4393 | |
| 242 | 242 | AM_RANGE(0xd000, 0xd0ff) AM_READWRITE(atari_gtia_r, atari_gtia_w) |
| 243 | 243 | AM_RANGE(0xd100, 0xd1ff) AM_NOP |
| 244 | 244 | AM_RANGE(0xd200, 0xd2ff) AM_DEVREADWRITE(SOUND, "pokey", pokey_r, pokey_w) |
| 245 | | AM_RANGE(0xd300, 0xd3ff) AM_READWRITE(pia_0_alt_r, pia_0_alt_w) |
| 245 | AM_RANGE(0xd300, 0xd3ff) AM_DEVREADWRITE(PIA6821, "pia", pia_alt_r, pia_alt_w) |
| 246 | 246 | AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w) |
| 247 | 247 | AM_RANGE(0xd500, 0xd7ff) AM_NOP |
| 248 | 248 | AM_RANGE(0xd800, 0xffff) AM_READWRITE(SMH_BANK4, SMH_BANK4) |
| r4392 | r4393 | |
| 673 | 673 | }; |
| 674 | 674 | |
| 675 | 675 | |
| 676 | static const pia6821_interface pia_dummy_intf = |
| 677 | { |
| 678 | DEVCB_NULL, |
| 679 | DEVCB_NULL, |
| 680 | DEVCB_NULL, |
| 681 | DEVCB_NULL, |
| 682 | DEVCB_NULL, |
| 683 | DEVCB_NULL, |
| 684 | DEVCB_NULL, |
| 685 | DEVCB_NULL, |
| 686 | DEVCB_NULL, |
| 687 | DEVCB_NULL, |
| 688 | DEVCB_NULL, |
| 689 | DEVCB_NULL |
| 690 | }; |
| 691 | |
| 692 | |
| 676 | 693 | static MACHINE_DRIVER_START( a400_cartslot ) |
| 677 | 694 | MDRV_CARTSLOT_ADD("cart1") |
| 678 | 695 | MDRV_CARTSLOT_EXTENSION_LIST("rom,bin") |
| r4392 | r4393 | |
| 710 | 727 | MDRV_VIDEO_START(atari) |
| 711 | 728 | MDRV_VIDEO_UPDATE(atari) |
| 712 | 729 | |
| 730 | MDRV_PIA6821_ADD( "pia", pia_dummy_intf ) |
| 731 | |
| 713 | 732 | /* sound hardware */ |
| 714 | 733 | MDRV_SPEAKER_STANDARD_MONO("mono") |
| 715 | 734 | MDRV_SOUND_ADD("pokey", POKEY, FREQ_17_EXACT) |