Previous 15994 Revisions Next

r4393 Thursday 5th March, 2009 at 17:40:04 UTC by Wilbert Pol
[APPLE1][ATARI] Converted drivers to use the 6821 pia device implementation
[src/mess/drivers]atari.c
[src/mess/includes]apple1.h
[src/mess/machine]apple1.c atarifdc.c

src/mess/includes/apple1.h
r4392r4393
88#define APPLE1_H_
99
1010#include "devices/snapquik.h"
11#include "machine/6821new.h"
1112
1213
1314/*----------- defined in machine/apple1.c -----------*/
1415
16extern const pia6821_interface apple1_pia0;
17
1518DRIVER_INIT( apple1 );
1619MACHINE_RESET( apple1 );
1720SNAPSHOT_LOAD( apple1 );
src/mess/machine/apple1.c
r4392r4393
4444
4545***************************************************************************/
4646
47#include <stdarg.h>
4847#include "driver.h"
4948#include "includes/apple1.h"
50#include "machine/6821pia.h"
49#include "machine/6821new.h"
5150#include "cpu/m6502/m6502.h"
5251#include "image.h"
5352#include "devices/cassette.h"
r4392r4393
5554static TIMER_CALLBACK(apple1_kbd_poll);
5655static TIMER_CALLBACK(apple1_kbd_strobe_end);
5756
58static READ8_HANDLER( apple1_pia0_kbdin );
59static WRITE8_HANDLER( apple1_pia0_dspout );
60static WRITE8_HANDLER( apple1_pia0_dsp_write_signal );
57static READ8_DEVICE_HANDLER( apple1_pia0_kbdin );
58static WRITE8_DEVICE_HANDLER( apple1_pia0_dspout );
59static WRITE8_DEVICE_HANDLER( apple1_pia0_dsp_write_signal );
6160
6261static TIMER_CALLBACK(apple1_dsp_ready_start);
6362static TIMER_CALLBACK(apple1_dsp_ready_end);
r4392r4393
7170   rather than updating them when they are read; thus they don't need
7271   handler functions. */
7372
74static const pia6821_interface apple1_pia0 =
73const pia6821_interface apple1_pia0 =
7574{
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 */
8887};
8988
9089/* Use the same keyboard mapping as on a modern keyboard.  This is not
r4392r4393
153152                          0x0000, mess_ram_size - 1, 0, 0, SMH_BANK1);
154153   memory_set_bankptr(machine,1, mess_ram);
155154
156   pia_config(machine, 0, &apple1_pia0);
157
158155   /* Poll the keyboard input ports periodically.  These include both
159156      ordinary keys and the RESET and CLEAR SCREEN pushbutton
160157      switches.  We can't handle these switches in a VBLANK_INT or
r4392r4393
175172
176173MACHINE_RESET( apple1 )
177174{
178   /* Reset the PIA and the display hardware. */
179   pia_reset();
175   /* Reset the display hardware. */
180176   apple1_vh_dsp_clr();
181177}
182178
r4392r4393
289285   int port, bit;
290286   int key_pressed;
291287   UINT32 shiftkeys, ctrlkeys;
288   const device_config *pia = devtag_get_device( machine, PIA6821, "pia" );
292289   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" };
293290
294291   /* This holds the values of all the input ports for ordinary keys
r4392r4393
306303         reset_flag = 1;
307304         /* using PULSE_LINE does not allow us to press and hold key */
308305         cpu_set_input_line(machine->cpu[0], INPUT_LINE_RESET, ASSERT_LINE);
309         pia_reset();
306         device_reset( pia );
310307      }
311308   }
312309   else if (reset_flag) {
r4392r4393
339336   key_pressed = 0;
340337
341338   /* 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);
343340
344341   shiftkeys = input_port_read(machine, "KEY4") & 0x0003;
345342   ctrlkeys = input_port_read(machine, "KEY4") & 0x000c;
r4392r4393
373370   {
374371      /* The keyboard will pulse its strobe line when a key is
375372         pressed.  A 10-usec pulse is typical. */
376      pia_set_input_ca1(0, 1);
373      pia_ca1_w(pia, 0, 1);
377374      timer_set(machine, ATTOTIME_IN_USEC(10), NULL, 0, apple1_kbd_strobe_end);
378375   }
379376}
380377
381378static TIMER_CALLBACK(apple1_kbd_strobe_end)
382379{
380   const device_config *pia = devtag_get_device( machine, PIA6821, "pia" );
381
383382   /* End of the keyboard strobe pulse. */
384   pia_set_input_ca1(0, 0);
383   pia_ca1_w(pia, 0, 0);
385384}
386385
387386
388387/*****************************************************************************
389388**   READ/WRITE HANDLERS
390389*****************************************************************************/
391static READ8_HANDLER( apple1_pia0_kbdin )
390static READ8_DEVICE_HANDLER( apple1_pia0_kbdin )
392391{
393392   /* Bit 7 of the keyboard input is permanently wired high.  This is
394393      what the ROM Monitor software expects. */
395394   return apple1_kbd_data | 0x80;
396395}
397396
398static WRITE8_HANDLER( apple1_pia0_dspout )
397static WRITE8_DEVICE_HANDLER( apple1_pia0_dspout )
399398{
400399   /* Send an ASCII character to the video hardware. */
401400   apple1_vh_dsp_w(data);
402401}
403402
404static WRITE8_HANDLER( apple1_pia0_dsp_write_signal )
403static WRITE8_DEVICE_HANDLER( apple1_pia0_dsp_write_signal )
405404{
406405   /* PIA output CB2 is inverted to become the DA signal, used to
407406      signal a display write to the video hardware. */
r4392r4393
409408   /* DA is directly connected to PIA input PB7, so the processor can
410409      read bit 7 of port B to test whether the display has completed
411410      a write. */
412   pia_set_input_b(0, (!data) << 7);
411   pia_portb_w(device, 0, (!data) << 7);
413412
414413   /* Once DA is asserted, the display will wait until it can perform
415414      the write, when the cursor position is about to be refreshed.
r4392r4393
417416      write.  Thus the write delay depends on the cursor position and
418417      where the display is in the refresh cycle. */
419418   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);
421420}
422421
423422static TIMER_CALLBACK(apple1_dsp_ready_start)
424423{
424   const device_config *pia = devtag_get_device( machine, PIA6821, "pia" );
425
425426   /* When the display asserts \RDA to signal it is ready, it
426427      triggers a 74123 one-shot to send a 3.5-usec low pulse to PIA
427428      input CB1.  The end of this pulse will tell the PIA that the
428429      display is ready for another write. */
429   pia_set_input_cb1(0, 0);
430   pia_cb1_w(pia, 0, 0);
430431   timer_set(machine, ATTOTIME_IN_NSEC(3500), NULL, 0, apple1_dsp_ready_end);
431432}
432433
433434static TIMER_CALLBACK(apple1_dsp_ready_end)
434435{
436   const device_config *pia = devtag_get_device( machine, PIA6821, "pia" );
437
435438   /* The one-shot pulse has ended; return CB1 to high, so we can do
436439      another display write. */
437   pia_set_input_cb1(0, 1);
440   pia_cb1_w(pia, 0, 1);
438441}
439442
440443
src/mess/machine/atarifdc.c
r4392r4393
1414#include "cpu/m6502/m6502.h"
1515#include "includes/atari.h"
1616#include "sound/pokey.h"
17#include "machine/6821pia.h"
17#include "machine/6821new.h"
1818#include "image.h"
1919
2020#define VERBOSE_SERIAL   0
r4392r4393
695695
696696WRITE8_HANDLER ( atari_serout_w )
697697{
698   const device_config *pia = devtag_get_device( space->machine, PIA6821, "pia" );
699
698700   /* ignore serial commands if no floppy image is specified */
699701   if( !drv[0].image )
700702      return;
r4392r4393
712714         /* exclusive or written checksum with calculated */
713715         atari_fdc.serout_chksum ^= data;
714716         /* if the attention line is high, this should be data */
715         if (pia_get_irq_b(0))
717         if (pianew_get_irq_b(pia))
716718            a800_serial_write(space->machine);
717719      }
718720      else
src/mess/drivers/atari.c
r4392r4393
1212#include "includes/atari.h"
1313#include "devices/cartslot.h"
1414#include "sound/pokey.h"
15#include "machine/6821pia.h"
15#include "machine/6821new.h"
1616#include "video/gtia.h"
1717#include "sound/dac.h"
1818
r4392r4393
212212   AM_RANGE(0xd000, 0xd0ff) AM_READWRITE(atari_gtia_r, atari_gtia_w)
213213   AM_RANGE(0xd100, 0xd1ff) AM_NOP
214214   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)
216216   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
217217   AM_RANGE(0xd500, 0xd7ff) AM_NOP
218218   AM_RANGE(0xd800, 0xffff) AM_ROM
r4392r4393
226226   AM_RANGE(0xd000, 0xd0ff) AM_READWRITE(atari_gtia_r, atari_gtia_w)
227227   AM_RANGE(0xd100, 0xd1ff) AM_NOP
228228   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)
230230   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
231231   AM_RANGE(0xd500, 0xd7ff) AM_NOP
232232   AM_RANGE(0xd800, 0xffff) AM_ROM
r4392r4393
242242   AM_RANGE(0xd000, 0xd0ff) AM_READWRITE(atari_gtia_r, atari_gtia_w)
243243   AM_RANGE(0xd100, 0xd1ff) AM_NOP
244244   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)
246246   AM_RANGE(0xd400, 0xd4ff) AM_READWRITE(atari_antic_r, atari_antic_w)
247247   AM_RANGE(0xd500, 0xd7ff) AM_NOP
248248   AM_RANGE(0xd800, 0xffff) AM_READWRITE(SMH_BANK4, SMH_BANK4)
r4392r4393
673673};
674674
675675
676static 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
676693static MACHINE_DRIVER_START( a400_cartslot )
677694   MDRV_CARTSLOT_ADD("cart1")
678695   MDRV_CARTSLOT_EXTENSION_LIST("rom,bin")
r4392r4393
710727   MDRV_VIDEO_START(atari)
711728   MDRV_VIDEO_UPDATE(atari)
712729
730   MDRV_PIA6821_ADD( "pia", pia_dummy_intf )
731
713732   /* sound hardware */
714733   MDRV_SPEAKER_STANDARD_MONO("mono")
715734   MDRV_SOUND_ADD("pokey", POKEY, FREQ_17_EXACT)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team