Previous 15994 Revisions Next

r5193 Thursday 9th July, 2009 at 16:00:05 UTC by Dirk Best
[LX800] Added some meat to the bones, made the gate array into a device
[src/mess]mess.mak
[src/mess/drivers]lx800.c
[src/mess/machine]e05a03.c* e05a03.h*

src/mess/machine/e05a03.c
r0r5193
1/***************************************************************************
2 
3    E05A03 Gate Array (used in the Epson LX-800)
4 
5***************************************************************************/
6 
7#include "driver.h"
8#include "e05a03.h"
9 
10 
11/***************************************************************************
12    TYPE DEFINITIONS
13***************************************************************************/
14 
15typedef struct _e05a03_state e05a03_state;
16struct _e05a03_state
17{
18   /* 24-bit shift register, port 0x00, 0x01 and 0x02 */
19   UINT32 shift;
20 
21   /* port 0x03 */
22   int busy_leading;
23   int busy_software;
24   int nlqlp;
25   int cndlp;
26 
27#if 0
28   int pe;
29   int pelp;
30#endif
31 
32   /* port 0x04 and 0x05 (9-bit) */
33   UINT16 printhead;
34 
35   /* port 0x06 (4-bit) */
36   UINT8 pf_motor;
37 
38   /* port 0x07 (4-bit) */
39   UINT8 cr_motor;
40 
41   /* callbacks */
42   devcb_resolved_write_line out_nlq_lp_func; /* pin 2, nlq lamp output */
43   devcb_resolved_write_line out_pe_lp_func;  /* pin 3, paper empty lamp output */
44   devcb_resolved_write_line out_reso_func;   /* pin 25, reset output */
45   devcb_resolved_write_line out_pe_func;     /* pin 35, centronics pe output */
46   devcb_resolved_read8 in_data_func;         /* pin 47-54, centronics data input */
47};
48 
49 
50/*****************************************************************************
51    INLINE FUNCTIONS
52*****************************************************************************/
53 
54INLINE e05a03_state *get_safe_token(const device_config *device)
55{
56   assert(device != NULL);
57   assert(device->token != NULL);
58   assert(device->type == E05A03);
59 
60   return (e05a03_state *)device->token;
61}
62 
63 
64/*****************************************************************************
65    DEVICE INTERFACE
66*****************************************************************************/
67 
68static DEVICE_START( e05a03 )
69{
70   e05a03_state *e05a03 = get_safe_token(device);
71   const e05a03_interface *intf = device->static_config;
72 
73   /* validate some basic stuff */
74   assert(device->static_config != NULL);
75 
76   /* resolve callbacks */
77   devcb_resolve_write_line(&e05a03->out_nlq_lp_func, &intf->out_nlq_lp_func, device);
78   devcb_resolve_write_line(&e05a03->out_pe_lp_func, &intf->out_pe_lp_func, device);
79   devcb_resolve_write_line(&e05a03->out_reso_func, &intf->out_reso_func, device);
80   devcb_resolve_write_line(&e05a03->out_pe_func, &intf->out_pe_func, device);
81   devcb_resolve_read8(&e05a03->in_data_func, &intf->in_data_func, device);
82 
83   /* register for state saving */
84   state_save_register_device_item(device, 0, e05a03->shift);
85   state_save_register_device_item(device, 0, e05a03->busy_leading);
86   state_save_register_device_item(device, 0, e05a03->busy_software);
87   state_save_register_device_item(device, 0, e05a03->nlqlp);
88   state_save_register_device_item(device, 0, e05a03->cndlp);
89#if 0
90   state_save_register_device_item(device, 0, e05a03->pe);
91   state_save_register_device_item(device, 0, e05a03->pelp);
92#endif
93   state_save_register_device_item(device, 0, e05a03->printhead);
94   state_save_register_device_item(device, 0, e05a03->pf_motor);
95   state_save_register_device_item(device, 0, e05a03->cr_motor);
96}
97 
98static DEVICE_RESET( e05a03 )
99{
100   e05a03_state *e05a03 = get_safe_token(device);
101 
102   e05a03->printhead = 0x00;
103   e05a03->pf_motor = 0x00;
104   e05a03->cr_motor = 0x0f;
105 
106   devcb_call_write_line(&e05a03->out_pe_func, 0);
107   devcb_call_write_line(&e05a03->out_pe_lp_func, 1);
108 
109   e05a03->busy_software = 1;
110   e05a03->nlqlp = 1;
111   e05a03->cndlp = 1;
112}
113 
114DEVICE_GET_INFO( e05a03 )
115{
116   switch (state)
117   {
118      /* --- the following bits of info are returned as 64-bit signed integers --- */
119      case DEVINFO_INT_TOKEN_BYTES:         info->i = sizeof(e05a03_state);               break;
120      case DEVINFO_INT_INLINE_CONFIG_BYTES:   info->i = 0;                           break;
121      case DEVINFO_INT_CLASS:               info->i = DEVICE_CLASS_OTHER;               break;
122 
123      /* --- the following bits of info are returned as pointers to data or functions --- */
124      case DEVINFO_FCT_START:               info->start = DEVICE_START_NAME(e05a03);      break;
125      case DEVINFO_FCT_STOP:               /* Nothing */                           break;
126      case DEVINFO_FCT_RESET:               info->reset = DEVICE_RESET_NAME(e05a03);      break;
127 
128      /* --- the following bits of info are returned as NULL-terminated strings --- */
129      case DEVINFO_STR_NAME:               strcpy(info->s, "E05A03");                  break;
130      case DEVINFO_STR_FAMILY:            strcpy(info->s, "Epson printer gate array");   break;
131      case DEVINFO_STR_VERSION:            strcpy(info->s, "1.0");                     break;
132      case DEVINFO_STR_SOURCE_FILE:         strcpy(info->s, __FILE__);                  break;
133      case DEVINFO_STR_CREDITS:            strcpy(info->s, "Copyright MESS Team");         break;
134   }
135}
136 
137 
138/***************************************************************************
139    IMPLEMENTATION
140***************************************************************************/
141 
142WRITE8_DEVICE_HANDLER( e05a03_w )
143{
144   e05a03_state *e05a03 = get_safe_token(device);
145 
146   logerror("%s: e05a03_w(%02x): %02x\n", cpuexec_describe_context(device->machine), offset, data);
147 
148   switch (offset)
149   {
150   /* shift register */
151   case 0x00: e05a03->shift = (e05a03->shift & 0x00ffff) | (data << 16); break;
152   case 0x01: e05a03->shift = (e05a03->shift & 0xff00ff) | (data << 8); break;
153   case 0x02: e05a03->shift = (e05a03->shift & 0xffff00) | (data << 0); break;
154 
155   case 0x03:
156      e05a03->busy_leading = BIT(data, 7);
157      e05a03->busy_software = BIT(data, 6);
158      e05a03->nlqlp = BIT(data, 4);
159      e05a03->cndlp = BIT(data, 3);
160 
161      devcb_call_write_line(&e05a03->out_pe_func, BIT(data, 2));
162      devcb_call_write_line(&e05a03->out_pe_lp_func, !BIT(data, 2));
163 
164#if 0
165      e05a03->pe = BIT(data, 2);
166      e05a03->pelp = !BIT(data, 2);
167#endif
168 
169      break;
170 
171   /* printhead */
172   case 0x04: e05a03->printhead = (e05a03->printhead & 0x100) | !data; break;
173   case 0x05: e05a03->printhead = (e05a03->printhead & 0x0ff) | (!(BIT(data, 7) << 8)); break;
174 
175   /* paper feed and carriage motor phase data*/
176   case 0x06: e05a03->pf_motor = (data & 0xf0) >> 4; break;
177   case 0x07: e05a03->cr_motor = (data & 0x0f) >> 0; break;
178   }
179}
180 
181READ8_DEVICE_HANDLER( e05a03_r )
182{
183   e05a03_state *e05a03 = get_safe_token(device);
184   UINT8 result = 0;
185 
186   logerror("%s: e05a03_r(%02x)\n", cpuexec_describe_context(device->machine), offset);
187 
188   switch (offset)
189   {
190   case 0x00:
191      break;
192 
193   case 0x01:
194      break;
195 
196   case 0x02:
197      result = devcb_call_read8(&e05a03->in_data_func, 0);
198      break;
199 
200   case 0x03:
201      result |= BIT(e05a03->shift, 23) << 7;
202      e05a03->shift <<= 1;
203      break;
204   }
205 
206   return result;
207}
208 
209/* home position signal */
210WRITE_LINE_DEVICE_HANDLER( e05a03_home_w )
211{
212}
213 
214/* printhead solenoids trigger */
215WRITE_LINE_DEVICE_HANDLER( e05a03_fire_w )
216{
217}
218 
219WRITE_LINE_DEVICE_HANDLER( e05a03_strobe_w )
220{
221}
222 
223READ_LINE_DEVICE_HANDLER( e05a03_busy_r )
224{
225   return 1;
226}
227 
228WRITE_LINE_DEVICE_HANDLER( e05a03_resi_w )
229{
230   e05a03_state *e05a03 = get_safe_token(device);
231 
232   if (!state)
233   {
234      device_reset_e05a03(device);
235      devcb_call_write_line(&e05a03->out_reso_func, 1);
236   }
237}
238 
239WRITE_LINE_DEVICE_HANDLER( e05a03_init_w )
240{
241   e05a03_resi_w(device, state);
242}
src/mess/machine/e05a03.h
r0r5193
1/***************************************************************************
2 
3    E05A03 Gate Array (used in the Epson LX-800)
4 
5***************************************************************************/
6 
7#ifndef __E05A03_H__
8#define __E05A03_H__
9 
10#include "devcb.h"
11 
12 
13/***************************************************************************
14    TYPE DEFINITIONS
15***************************************************************************/
16 
17typedef struct _e05a03_interface e05a03_interface;
18struct _e05a03_interface
19{
20   devcb_read8 in_data_func;
21 
22   devcb_write_line out_nlq_lp_func;
23   devcb_write_line out_pe_lp_func;
24   devcb_write_line out_pe_func;
25   devcb_write_line out_reso_func;
26};
27 
28 
29/***************************************************************************
30    FUNCTION PROTOTYPES
31***************************************************************************/
32 
33DEVICE_GET_INFO( e05a03 );
34 
35WRITE8_DEVICE_HANDLER( e05a03_w );
36READ8_DEVICE_HANDLER( e05a03_r );
37 
38WRITE_LINE_DEVICE_HANDLER( e05a03_home_w ); /* home position signal */
39WRITE_LINE_DEVICE_HANDLER( e05a03_fire_w ); /* printhead solenoids trigger */
40WRITE_LINE_DEVICE_HANDLER( e05a03_strobe_w );
41READ_LINE_DEVICE_HANDLER( e05a03_busy_r );
42WRITE_LINE_DEVICE_HANDLER( e05a03_resi_w ); /* reset input */
43WRITE_LINE_DEVICE_HANDLER( e05a03_init_w ); /* centronics init */
44 
45 
46/***************************************************************************
47    DEVICE CONFIGURATION MACROS
48***************************************************************************/
49 
50#define E05A03 DEVICE_GET_INFO_NAME(e05a03)
51 
52#define MDRV_E05A03_ADD(_tag, _intf) \
53   MDRV_DEVICE_ADD(_tag, E05A03, 0) \
54   MDRV_DEVICE_CONFIG(_intf)
55 
56 
57#endif /* __E05A03_H__ */
src/mess/mess.mak
r5192r5193
805805$(MESSOBJ)/epson.a:            \
806806   $(MESS_DRIVERS)/ex800.o      \
807807   $(MESS_DRIVERS)/lx800.o      \
808   $(MESS_MACHINE)/e05a03.o   \
808809   $(MESS_DRIVERS)/px4.o      \
809810   $(MESS_DRIVERS)/px8.o      \
810811   $(MESS_DRIVERS)/qx10.o      \
src/mess/drivers/lx800.c
r5192r5193
88 
99#include "driver.h"
1010#include "cpu/upd7810/upd7810.h"
11#include "machine/e05a03.h"
1112#include "sound/beep.h"
1213#include "lx800.lh"
1314 
1415 
1516/***************************************************************************
16    GATE ARRAY
17    TYPE DEFINITIONS
1718***************************************************************************/
1819 
19static READ8_HANDLER( lx800_ga_r )
20typedef struct _lx800_state lx800_state;
21struct _lx800_state
2022{
21   logerror("%s: lx800_ga_r(%02x)\n", cpuexec_describe_context(space->machine), offset);
23   const device_config *speaker;
24};
2225 
23   return 0xff;
24}
2526 
26static WRITE8_HANDLER( lx800_ga_w )
27{
28   logerror("%s: lx800_ga_w(%02x): %02x\n", cpuexec_describe_context(space->machine), offset, data);
29}
30 
31 
3227/***************************************************************************
3328    I/O PORTS
3429***************************************************************************/
3530 
31/* PA0   W  CRCOM  carriage motor, 0 = holding voltage, 1 = drive voltage
32 * PA1             not used
33 * PA2   W  PFCOM  paper feed motor, 0 = holding voltage, 1 = drive voltage
34 * PA3  R   LF SW  line feed switch
35 * PA4  R   FF SW  form feed switch
36 * PA5  R   PE SW  paper end sensor, 0 = no paper, 1 = paper
37 * PA6             not used
38 * PA7  R   P/S    P/S signal from the optional interface
39 */
3640static READ8_HANDLER( lx800_porta_r )
3741{
42   UINT8 result = 0;
43 
3844   logerror("%s: lx800_porta_r(%02x)\n", cpuexec_describe_context(space->machine), offset);
3945 
40   return 0xff;
46   result |= input_port_read(space->machine, "LINEFEED") << 3;
47   result |= input_port_read(space->machine, "FORMFEED") << 4;
48   result |= 1 << 5;
49 
50   result |= 1 << 7;
51 
52   return result;
4153}
4254 
4355static WRITE8_HANDLER( lx800_porta_w )
4456{
4557   logerror("%s: lx800_porta_w(%02x): %02x\n", cpuexec_describe_context(space->machine), offset, data);
58   logerror("--> carriage: %d, paper feed: %d\n", BIT(data, 0), BIT(data, 2));
4659}
4760 
61/* PC0   W  TXD        serial i/o txd
62 * PC1  R   RXD        serial i/o rxd
63 * PC2   W  ONLINE LP  online led
64 * PC3  R   ONLINE SW  online switch
65 * PC4   W  ERR        centronics error
66 * PC5   W  ACK        centronics acknowledge
67 * PC6   W  FIRE       drive pulse width signal
68 * PC7   W  BUZZER     buzzer signal
69 */
4870static READ8_HANDLER( lx800_portc_r )
4971{
72   UINT8 result = 0;
73 
5074   logerror("%s: lx800_portc_r(%02x)\n", cpuexec_describe_context(space->machine), offset);
5175 
52   return 0xff;
76   result |= input_port_read(space->machine, "ONLINE") << 3;
77 
78   return result;
5379}
5480 
5581static WRITE8_HANDLER( lx800_portc_w )
5682{
83   lx800_state *lx800 = space->machine->driver_data;
84 
5785   logerror("%s: lx800_portc_w(%02x): %02x\n", cpuexec_describe_context(space->machine), offset, data);
86   logerror("--> err: %d, ack: %d, fire: %d, buzzer: %d\n", BIT(data, 4), BIT(data, 5), BIT(data, 6), BIT(data, 7));
87 
88   output_set_value("online_led", !BIT(data, 2));
89   beep_set_state(lx800->speaker, !BIT(data, 7));
5890}
5991 
6092 
6193/***************************************************************************
94    GATE ARRAY
95***************************************************************************/
96 
97static READ8_DEVICE_HANDLER( lx800_centronics_data_r )
98{
99   logerror("centronics: data read\n");
100   return 0x55;
101}
102 
103static WRITE_LINE_DEVICE_HANDLER( lx800_centronics_pe_w )
104{
105   logerror("centronics: pe = %d\n", state);
106}
107 
108static WRITE_LINE_DEVICE_HANDLER( lx800_paperempty_led_w )
109{
110   output_set_value("paperout_led", state);
111}
112 
113static WRITE_LINE_DEVICE_HANDLER( lx800_reset_w )
114{
115   cputag_reset(device->machine, "maincpu");
116}
117 
118 
119/***************************************************************************
120    MACHINE EMULATION
121***************************************************************************/
122 
123static MACHINE_START( lx800 )
124{
125   lx800_state *lx800 = machine->driver_data;
126 
127   lx800->speaker = devtag_get_device(machine, "beep");
128 
129   beep_set_state(lx800->speaker, 0);
130   beep_set_frequency(lx800->speaker, 4000); /* ? */
131}
132 
133 
134/***************************************************************************
62135    ADDRESS MAPS
63136***************************************************************************/
64137 
r5192r5193
66139   AM_RANGE(0x0000, 0x7fff) AM_ROM /* 32k firmware */
67140   AM_RANGE(0x8000, 0x9fff) AM_RAM /* 8k external RAM */
68141   AM_RANGE(0xa000, 0xbfff) AM_NOP /* not used */
69   AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x1ff8) AM_READWRITE(lx800_ga_r, lx800_ga_w)
142   AM_RANGE(0xc000, 0xdfff) AM_MIRROR(0x1ff8) AM_DEVREADWRITE("ic3b", e05a03_r, e05a03_w)
70143   AM_RANGE(0xe000, 0xfeff) AM_NOP /* not used */
71144   AM_RANGE(0xff00, 0xffff) AM_RAM /* internal CPU RAM */
72145ADDRESS_MAP_END
r5192r5193
83156***************************************************************************/
84157 
85158static INPUT_PORTS_START( lx800 )
159   PORT_START("ONLINE")
160   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("On Line") PORT_CODE(KEYCODE_O)
161 
162   PORT_START("FORMFEED")
163   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Form Feed") PORT_CODE(KEYCODE_F)
164 
165   PORT_START("LINEFEED")
166   PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Line Feed") PORT_CODE(KEYCODE_L)
167 
86168   PORT_START("DIPSW1")
87169   PORT_DIPNAME(0x01, 0x00, "Typeface")
88170   PORT_DIPLOCATION("DIP:8")
r5192r5193
145227    0
146228};
147229 
230static const e05a03_interface lx800_e05a03_intf =
231{
232   DEVCB_HANDLER(lx800_centronics_data_r),
233   DEVCB_NULL,
234   DEVCB_LINE(lx800_paperempty_led_w),
235   DEVCB_LINE(lx800_centronics_pe_w),
236   DEVCB_LINE(lx800_reset_w)
237};
238 
148239static MACHINE_DRIVER_START( lx800 )
149240   /* basic machine hardware */
150241   MDRV_CPU_ADD("maincpu", UPD7810, XTAL_14_7456MHz)
r5192r5193
152243   MDRV_CPU_PROGRAM_MAP(lx800_mem)
153244   MDRV_CPU_IO_MAP(lx800_io)
154245 
246   MDRV_MACHINE_START(lx800)
247 
248   MDRV_DRIVER_DATA(lx800_state)
249 
155250   MDRV_DEFAULT_LAYOUT(layout_lx800)
156251 
157252   /* audio hardware */
158253   MDRV_SPEAKER_STANDARD_MONO("mono")
159254   MDRV_SOUND_ADD("beep", BEEP, 0)
160255   MDRV_SOUND_ROUTE(ALL_OUTPUTS, "mono", 1.0)
256 
257   /* gate array */
258   MDRV_E05A03_ADD("ic3b", lx800_e05a03_intf)
161259MACHINE_DRIVER_END
162260 
163261 
r5192r5193
167265 
168266ROM_START( lx800 )
169267    ROM_REGION(0x8000, "maincpu", 0)
170    ROM_LOAD("lx800.bin", 0x0000, 0x8000, CRC(da06c45b) SHA1(9618c940dd10d5b43cd1edd5763b90e6447de667))
268    ROM_LOAD("lx800.ic3c", 0x0000, 0x8000, CRC(da06c45b) SHA1(9618c940dd10d5b43cd1edd5763b90e6447de667))
171269ROM_END
172270 
173271 

Previous 15994 Revisions Next


© 1998-2018 The MESS Team