Previous 15994 Revisions Next

r4248 Wednesday 11th February, 2009 at 10:27:44 UTC by Dirk Best
[ATOM] Rewrote printer interface
[src/mess/drivers]atom.c
[src/mess/machine]atom.c

src/mess/machine/atom.c
r4247r4248
1818#include "driver.h"
1919#include "machine/8255ppi.h"
2020#include "video/m6847.h"
21#include "machine/ctronics.h"
2122#include "machine/i8271.h"
2223#include "machine/6522via.h"
2324#include "devices/basicdsk.h"
2425#include "devices/flopdrv.h"
2526#include "devices/cassette.h"
26#include "devices/printer.h"
2727#include "devices/snapquik.h"
2828#include "includes/atom.h"
2929#include "sound/speaker.h"
r4247r4248
3333static UINT8 atom_8255_portb;
3434UINT8 atom_8255_portc;
3535
36/* printer data written */
37static char atom_printer_data = 0x07f;
3836
3937/* I am not sure if this is correct, the atom appears to have a 2.4 kHz timer used for reading tapes?? */
4038static int   timer_state = 0;
4139
42static void atom_via_irq_func(const device_config *device, int state)
43{
44   if (state)
45   {
46      cpu_set_input_line(device->machine->cpu[0], 0, HOLD_LINE);
47   }
48   else
49   {
50      cpu_set_input_line(device->machine->cpu[0], 0, CLEAR_LINE);
51   }
52}
53
5440static const device_config *cassette_device_image(running_machine *machine)
5541{
5642   return devtag_get_device(machine, CASSETTE, "cassette");
5743}
5844
59static const device_config *printer_image(running_machine *machine)
60{
61   return devtag_get_device(machine, PRINTER, "printer");
62}
6345
64/* printer status */
65static READ8_DEVICE_HANDLER(atom_via_in_a_func)
66{
67   unsigned char data;
6846
69   data = atom_printer_data;
47/***************************************************************************
48    PRINTER INTERFACE
49***************************************************************************/
7050
71   if (!printer_is_ready(printer_image(device->machine)))
72   {
73      /* offline */
74      data |=0x080;
75   }
76
77   return data;
51static void atom_via_irq_func(const device_config *device, int state)
52{
53   cpu_set_input_line(device->machine->cpu[0], 0, state);
7854}
7955
80/* printer data */
81static WRITE8_DEVICE_HANDLER(atom_via_out_a_func)
56/* BUSY from the centronics interface is connected to PA7 of the via */
57static READ8_DEVICE_HANDLER( atom_printer_busy )
8258{
83   /* data is written to port, this causes a pulse on ca2 (printer /strobe input),
84   and data is written */
85   /* atom has a 7-bit printer port */
86   atom_printer_data = data & 0x07f;
59   const device_config *printer = devtag_get_device(device->machine, CENTRONICS, "centronics");
60   return centronics_busy_r(printer) << 7;
8761}
8862
89static unsigned char previous_ca2_data = 0;
90
91/* one of these is pulsed! */
92static WRITE8_DEVICE_HANDLER(atom_via_out_ca2_func)
63/* DATA lines 0 to 6 are connected to PA0 to PA6 of the via */
64static WRITE8_DEVICE_HANDLER( atom_printer_data )
9365{
94   /* change in state of ca2 output? */
95   if (((previous_ca2_data^data)&0x01)!=0)
96   {
97      /* only look for one transition state */
98      if (data & 0x01)
99      {
100         /* output data to printer */
101         printer_output(printer_image(device->machine), atom_printer_data);
102      }
103   }
66   const device_config *printer = devtag_get_device(device->machine, CENTRONICS, "centronics");
67   centronics_data_w(printer, 0, data & 0x7f);
68}
10469
105   previous_ca2_data = data;
70/* the CA2 output is connected to the STROBE signal on the centronics */
71static WRITE8_DEVICE_HANDLER( atom_printer_strobe )
72{
73   const device_config *printer = devtag_get_device(device->machine, CENTRONICS, "centronics");
74   centronics_strobe_w(printer, data);
10675}
10776
10877const via6522_interface atom_6522_interface =
10978{
110   atom_via_in_a_func,      /* printer status */
79   atom_printer_busy,
11180   NULL,
11281   NULL,
11382   NULL,
11483   NULL,
11584   NULL,
116   atom_via_out_a_func,   /* printer data */
85   atom_printer_data,
11786   NULL,
11887   NULL,
11988   NULL,
120   atom_via_out_ca2_func,   /* printer strobe */
89   atom_printer_strobe,
12190   NULL,
12291   atom_via_irq_func,
12392};
r4247r4248
349318READ8_DEVICE_HANDLER ( atom_8255_portb_r )
350319{
351320   int row;
352   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5",
321   static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5",
353322                              "KEY6", "KEY7", "KEY8", "KEY9", "KEY10", "KEY11" };
354   
323
355324   row = atom_8255_porta & 0x0f;
356   /* logerror("8255: Read port b: %02X %02X\n", input_port_read(machine, port),
325   /* logerror("8255: Read port b: %02X %02X\n", input_port_read(machine, port),
357326                           input_port_read(machine, "KEY10") & 0xc0); */
358327   return ((input_port_read(device->machine, keynames[row]) & 0x3f) | (input_port_read(device->machine, "KEY10") & 0xc0));
359328}
src/mess/drivers/atom.c
r4247r4248
6262#include "cpu/m6502/m6502.h"
6363
6464/* Components */
65#include "machine/centroni.h"
65#include "machine/ctronics.h"
6666#include "machine/i8271.h"
6767#include "machine/8255ppi.h"
6868#include "machine/6522via.h"
r4247r4248
7171/* Devices */
7272#include "devices/basicdsk.h"
7373#include "devices/flopdrv.h"
74#include "devices/printer.h"
7574#include "devices/cassette.h"
7675#include "devices/snapquik.h"
7776#include "sound/speaker.h"
r4247r4248
248247   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_UNUSED)
249248INPUT_PORTS_END
250249
251/* sound output */
252250
251/* centronics interface */
252static const centronics_interface atom_centronics_config =
253{
254   FALSE,
255   DEVCB_DEVICE_HANDLER(VIA6522, "via6522_0", via_ca1_w),
256   DEVCB_NULL,
257   DEVCB_NULL
258};
259
260
253261/* machine definition */
254262static MACHINE_DRIVER_START( atom )
255263   /* basic machine hardware */
r4247r4248
276284   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.00)
277285
278286   /* printer */
279   MDRV_PRINTER_ADD("printer")
287   MDRV_CENTRONICS_ADD("centronics", atom_centronics_config)
280288
281289   /* quickload */
282290   MDRV_QUICKLOAD_ADD(atom, "atm", 0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team