Previous 15994 Revisions Next

r14606 Friday 24th February, 2012 at 07:39:38 UTC by Miodrag Milanović
Modernized terminal device and added possibility to change comm parameters [Carl]
[src/mess/drivers]68ksbc.c altair.c apollo.c bullet.c ccs2422.c ccs2810.c cm1800.c czk80.c d6809.c dectalk.c dms86.c dual68.c exp85.c h89.c ht68k.c ipc.c isbc.c mccpm.c microdec.c mits680b.c mod8.c mpz80.c ob68k1a.c okean240.c pdp11.c pes.c pimps.c qtsbc.c sacstate.c sage2.c sgi_ip2.c sun1.c super6.c swtpc.c systec.c tricep.c vector4.c votrpss.c votrtnt.c xor100.c zexall.c zsbc3.c
[src/mess/includes]bullet.h exp85.h mpz80.h ob68k1a.h pes.h sage2.h super6.h xor100.h
[src/mess/machine]teleprinter.c teleprinter.h terminal.c terminal.h

src/mess/machine/teleprinter.c
r14605r14606
1#include "emu.h"
21#include "machine/teleprinter.h"
3#include "machine/terminal.h"
42
5/***************************************************************************
6    TYPE DEFINITIONS
7***************************************************************************/
8#define TELEPRINTER_WIDTH 80
9#define TELEPRINTER_HEIGHT 50
10typedef struct _teleprinter_state teleprinter_state;
11struct _teleprinter_state
12{
13   UINT8 buffer[TELEPRINTER_WIDTH*TELEPRINTER_HEIGHT];
14   UINT8 x_pos;
15   UINT8 last_code;
16   UINT8 scan_line;
17   devcb_resolved_write8 teleprinter_keyboard_func;
18};
19
20/*****************************************************************************
21    INLINE FUNCTIONS
22*****************************************************************************/
23INLINE teleprinter_state *get_safe_token(device_t *device)
24{
25   assert(device != NULL);
26   assert(device->type() == GENERIC_TELEPRINTER);
27
28   return (teleprinter_state *)downcast<legacy_device_base *>(device)->token();
29}
30
31INLINE const teleprinter_interface *get_interface(device_t *device)
32{
33   assert(device != NULL);
34   assert(device->type() == GENERIC_TELEPRINTER);
35   return (const teleprinter_interface *) device->static_config();
36}
37
38/***************************************************************************
39    IMPLEMENTATION
40***************************************************************************/
41
423static const UINT8 teleprinter_font[128*8] =
434{
445  0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
r14605r14606
171132  0x2a,0x15,0x2a,0x15,0x2a,0x15,0x2a,0x15
172133};
173134
174static void teleprinter_scroll_line(device_t *device)
135teleprinter_device::teleprinter_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
136   : generic_terminal_device(mconfig, TELEPRINTER, "Teleprinter", tag, owner, clock)
175137{
176   teleprinter_state *term = get_safe_token(device);
138}
177139
178   memcpy(term->buffer,term->buffer+TELEPRINTER_WIDTH,(TELEPRINTER_HEIGHT-1)*TELEPRINTER_WIDTH);
179   memset(term->buffer + TELEPRINTER_WIDTH*(TELEPRINTER_HEIGHT-1),0x20,TELEPRINTER_WIDTH);
140void teleprinter_device::scroll_line()
141{
142   memcpy(m_buffer,m_buffer+TELEPRINTER_WIDTH,(TELEPRINTER_HEIGHT-1)*TELEPRINTER_WIDTH);
143   memset(m_buffer + TELEPRINTER_WIDTH*(TELEPRINTER_HEIGHT-1),0x20,TELEPRINTER_WIDTH);
180144}
181145
182static void teleprinter_write_char(device_t *device,UINT8 data) {
183   teleprinter_state *term = get_safe_token(device);
184
185   term->buffer[(TELEPRINTER_HEIGHT-1)*TELEPRINTER_WIDTH+term->x_pos] = data;
186   term->x_pos++;
187   if (term->x_pos >= TELEPRINTER_WIDTH)
146void teleprinter_device::write_char(UINT8 data) {
147   m_buffer[(TELEPRINTER_HEIGHT-1)*TELEPRINTER_WIDTH+m_x_pos] = data;
148   m_x_pos++;
149   if (m_x_pos >= TELEPRINTER_WIDTH)
188150   {
189      term->x_pos = 0;
190      teleprinter_scroll_line(device);
151      m_x_pos = 0;
152      scroll_line();
191153   }
192154}
193155
194static void teleprinter_clear(device_t *device) {
195   teleprinter_state *term = get_safe_token(device);
196
197   memset(term->buffer,0,TELEPRINTER_WIDTH*TELEPRINTER_HEIGHT);
198   term->x_pos = 0;
156void teleprinter_device::clear() {
157   memset(m_buffer,0,TELEPRINTER_WIDTH*TELEPRINTER_HEIGHT);
158   m_x_pos = 0;
199159}
200160
201WRITE8_DEVICE_HANDLER ( teleprinter_write )
161void teleprinter_device::term_write(UINT8 data)
202162{
203   teleprinter_state *term = get_safe_token(device);
204163   switch(data) {
205      case 10: term->x_pos = 0;
206            teleprinter_scroll_line(device);
164      case 10: m_x_pos = 0;
165            scroll_line();
207166            break;
208      case 13: term->x_pos = 0; break;
209      case  9: term->x_pos = (term->x_pos & 0xf8) + 8;
210            if (term->x_pos >= TELEPRINTER_WIDTH)
211               term->x_pos = TELEPRINTER_WIDTH-1;
167      case 13: m_x_pos = 0; break;
168      case  9: m_x_pos = (m_x_pos & 0xf8) + 8;
169            if (m_x_pos >= TELEPRINTER_WIDTH)
170               m_x_pos = TELEPRINTER_WIDTH-1;
212171
213172            break;
214173      case 16: break;
215      default: teleprinter_write_char(device,data); break;
174      default: write_char(data); break;
216175   }
217176}
218177
219178/***************************************************************************
220179    VIDEO HARDWARE
221180***************************************************************************/
222static void generic_teleprinter_update(device_t *device, bitmap_ind16 &bitmap, const rectangle &cliprect)
181UINT32 teleprinter_device::tp_update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect)
223182{
224183   UINT8 code;
225184   int y, c, x, b;
226   teleprinter_state *term = get_safe_token(device);
227185
228186   for (y = 0; y < TELEPRINTER_HEIGHT; y++)
229187   {
r14605r14606
232190         int horpos = 0;
233191         for (x = 0; x < TELEPRINTER_WIDTH; x++)
234192         {
235            code = teleprinter_font[(term->buffer[y*TELEPRINTER_WIDTH + x]  & 0x7f) *8 + c];
193            code = teleprinter_font[(m_buffer[y*TELEPRINTER_WIDTH + x]  & 0x7f) *8 + c];
236194            for (b = 0; b < 8; b++)
237195            {
238               bitmap.pix16(y*8 + c, horpos++) =  (code >> b) & 0x01 ? 0 : 1;
196               bitmap.pix32(y*8 + c, horpos++) =  (code >> b) & 0x01 ? 0 : 0x00ffffff;
239197            }
240198         }
241199      }
242200   }
201   return 0;
243202}
244203
245static TIMER_CALLBACK(keyboard_callback)
246{
247   UINT8 new_code;
248   teleprinter_state *term = get_safe_token((device_t *)ptr);
249   new_code = terminal_keyboard_handler(machine, term->last_code, &term->scan_line, NULL, NULL, (device_t *)ptr);
250
251   if(new_code != term->last_code)
252      term->teleprinter_keyboard_func(0, new_code);
253   term->last_code = new_code;
254}
255
256204/***************************************************************************
257205    VIDEO HARDWARE
258206***************************************************************************/
259static VIDEO_START( teleprinter )
260{
261
262}
263
264static SCREEN_UPDATE_IND16(teleprinter )
265{
266   device_t *devconf = screen.machine().device(TELEPRINTER_TAG);
267   generic_teleprinter_update( devconf, bitmap, cliprect);
268   return 0;
269}
270
271207MACHINE_CONFIG_FRAGMENT( generic_teleprinter )
272208   MCFG_SCREEN_ADD(TELEPRINTER_SCREEN_TAG, RASTER)
273209   MCFG_SCREEN_REFRESH_RATE(50)
274210   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
275211   MCFG_SCREEN_SIZE(TELEPRINTER_WIDTH*8, TELEPRINTER_HEIGHT*8)
276212   MCFG_SCREEN_VISIBLE_AREA(0, TELEPRINTER_WIDTH*8-1, 0, TELEPRINTER_HEIGHT*8-1)
277   MCFG_SCREEN_UPDATE_STATIC(teleprinter)
278
279   MCFG_PALETTE_LENGTH(2)
280   MCFG_PALETTE_INIT(black_and_white)
281
282   MCFG_VIDEO_START(teleprinter)
213   MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, teleprinter_device, tp_update)
283214MACHINE_CONFIG_END
284215
285
286/*-------------------------------------------------
287    DEVICE_START( teleprinter )
288-------------------------------------------------*/
289
290static DEVICE_START( teleprinter )
216machine_config_constructor teleprinter_device::device_mconfig_additions() const
291217{
292   teleprinter_state *term = get_safe_token(device);
293   const teleprinter_interface *intf = get_interface(device);
294
295   term->teleprinter_keyboard_func.resolve(intf->teleprinter_keyboard_func, *device);
296
297   if (!term->teleprinter_keyboard_func.isnull())
298      device->machine().scheduler().timer_pulse(attotime::from_hz(240), FUNC(keyboard_callback), 0, (void*)device);
218      return MACHINE_CONFIG_NAME(generic_teleprinter);
299219}
300220
301221/*-------------------------------------------------
302222    DEVICE_RESET( teleprinter )
303223-------------------------------------------------*/
304224
305static DEVICE_RESET( teleprinter )
225void teleprinter_device::device_reset()
306226{
307   teleprinter_state *term = get_safe_token(device);
308
309   teleprinter_clear(device);
310   term->last_code = 0;
311   term->scan_line = 0;
227   clear();
228   generic_terminal_device::device_reset();
312229}
313230
314/*-------------------------------------------------
315    DEVICE_GET_INFO( teleprinter )
316-------------------------------------------------*/
317
318DEVICE_GET_INFO( teleprinter )
319{
320   switch (state)
321   {
322      /* --- the following bits of info are returned as 64-bit signed integers --- */
323      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
324      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(teleprinter_state);                     break;
325
326      /* --- the following bits of info are returned as pointers to data or functions --- */
327      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(teleprinter);               break;
328      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
329      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(teleprinter);               break;
330
331      case DEVINFO_PTR_INPUT_PORTS:               info->ipt = INPUT_PORTS_NAME(generic_terminal);            break;
332      /* --- the following bits of info are returned as NULL-terminated strings --- */
333      case DEVINFO_STR_NAME:                     strcpy(info->s, "Generic Teleprinter");                  break;
334      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Teleprinter");                        break;
335      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
336      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
337      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
338   }
339}
340
341DEFINE_LEGACY_DEVICE(GENERIC_TELEPRINTER, teleprinter);
231const device_type TELEPRINTER = &device_creator<teleprinter_device>;
src/mess/machine/teleprinter.h
r14605r14606
11#ifndef __TELEPRINTER_H__
22#define __TELEPRINTER_H__
33
4#include "devcb.h"
4#include "machine/terminal.h"
55
6/***************************************************************************
7    TYPE DEFINITIONS
8***************************************************************************/
6#define TELEPRINTER_WIDTH 80
7#define TELEPRINTER_HEIGHT 50
98
10typedef struct _teleprinter_interface teleprinter_interface;
11struct _teleprinter_interface
12{
13   devcb_write8 teleprinter_keyboard_func;
14};
9#define GENERIC_TELEPRINTER_INTERFACE GENERIC_TERMINAL_INTERFACE
1510
16#define GENERIC_TELEPRINTER_INTERFACE(name) const teleprinter_interface (name) =
17
1811/***************************************************************************
1912    DEVICE CONFIGURATION MACROS
2013***************************************************************************/
2114#define TELEPRINTER_TAG "teleprinter"
2215#define TELEPRINTER_SCREEN_TAG "tty_screen"
2316
24DECLARE_LEGACY_DEVICE(GENERIC_TELEPRINTER, teleprinter);
25
2617#define MCFG_GENERIC_TELEPRINTER_ADD(_tag, _intrf) \
27   MCFG_DEVICE_ADD(_tag, GENERIC_TELEPRINTER, 0) \
18   MCFG_DEVICE_ADD(_tag, TELEPRINTER, 0) \
2819   MCFG_DEVICE_CONFIG(_intrf)
2920
3021#define MCFG_GENERIC_TELEPRINTER_REMOVE(_tag)      \
3122    MCFG_DEVICE_REMOVE(_tag)
3223
33
3424/***************************************************************************
3525    FUNCTION PROTOTYPES
3626***************************************************************************/
3727
38WRITE8_DEVICE_HANDLER ( teleprinter_write );
28class teleprinter_device : public generic_terminal_device
29{
30public:
31   teleprinter_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
32   UINT32 tp_update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect);
33protected:
34   virtual void term_write(UINT8 data);
35   virtual void device_reset();
36   machine_config_constructor device_mconfig_additions() const;
37private:
38   void scroll_line();
39   void write_char(UINT8 data);
40   void clear();
41};
3942
40MACHINE_CONFIG_EXTERN( generic_teleprinter );
43extern const device_type TELEPRINTER;
4144
4245#endif /* __TELEPRINTER_H__ */
src/mess/machine/terminal.c
r14605r14606
1#include "emu.h"
21#include "machine/terminal.h"
32
43/***************************************************************************
5    TYPE DEFINITIONS
6***************************************************************************/
7enum
8{
9   START = 0,
10   STOP = 9,
11   DONE = 10
12};
13
14#define TERMINAL_WIDTH 80
15#define TERMINAL_HEIGHT 24
16typedef struct _terminal_state terminal_state;
17struct _terminal_state
18{
19   UINT8 framecnt;
20   UINT8 buffer[TERMINAL_WIDTH*TERMINAL_HEIGHT];
21   UINT8 x_pos;
22   UINT8 y_pos;
23   UINT8 last_code;
24   UINT8 scan_line;
25   int rx_state;
26   int tx_state;
27   UINT8 rx_shift;
28   UINT8 tx_shift;
29   devcb_resolved_write8 terminal_keyboard_func;
30};
31
32/*****************************************************************************
33    INLINE FUNCTIONS
34*****************************************************************************/
35INLINE terminal_state *get_safe_token(device_t *device)
36{
37   assert(device != NULL);
38   assert(device->type() == GENERIC_TERMINAL);
39
40   return (terminal_state *)downcast<legacy_device_base *>(device)->token();
41}
42
43INLINE const terminal_interface *get_interface(device_t *device)
44{
45   assert(device != NULL);
46   assert(device->type() == GENERIC_TERMINAL);
47   return (const terminal_interface *) device->static_config();
48}
49
50/***************************************************************************
514    IMPLEMENTATION
525***************************************************************************/
536
r14605r14606
183136   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
184137};
185138
186static void terminal_scroll_line(device_t *device)
139generic_terminal_device::generic_terminal_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock)
140   : device_t(mconfig, type, name, tag, owner, clock)
187141{
188   terminal_state *term = get_safe_token(device);
189
190   memcpy(term->buffer,term->buffer+TERMINAL_WIDTH,(TERMINAL_HEIGHT-1)*TERMINAL_WIDTH);
191   memset(term->buffer + TERMINAL_WIDTH*(TERMINAL_HEIGHT-1),0x20,TERMINAL_WIDTH);
192142}
193143
194static void terminal_write_char(device_t *device,UINT8 data) {
195   terminal_state *term = get_safe_token(device);
196
197   term->buffer[term->y_pos*TERMINAL_WIDTH+term->x_pos] = data;
198   term->x_pos++;
199   if (term->x_pos >= TERMINAL_WIDTH)
200   {
201      term->x_pos = 0;
202      term->y_pos++;
203      if (term->y_pos >= TERMINAL_HEIGHT)
204      {
205         terminal_scroll_line(device);
206         term->y_pos = TERMINAL_HEIGHT-1;
207      }
208   }
144generic_terminal_device::generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
145   : device_t(mconfig, GENERIC_TERMINAL, "Generic Terminal", tag, owner, clock)
146{
209147}
210148
211static void terminal_clear(device_t *device) {
212   terminal_state *term = get_safe_token(device);
213
214   memset(term->buffer,0x20,TERMINAL_WIDTH*TERMINAL_HEIGHT);
215   term->x_pos = 0;
216   term->y_pos = 0;
149void generic_terminal_device::scroll_line()
150{
151   memcpy(m_buffer,m_buffer+TERMINAL_WIDTH,(TERMINAL_HEIGHT-1)*TERMINAL_WIDTH);
152   memset(m_buffer + TERMINAL_WIDTH*(TERMINAL_HEIGHT-1),0x20,TERMINAL_WIDTH);
217153}
218154
219READ_LINE_DEVICE_HANDLER( terminal_serial_r )
155void generic_terminal_device::write_char(UINT8 data)
220156{
221   terminal_state *term = get_safe_token(device);
222
223   UINT8 data = 1;
224
225   switch (term->tx_state)
157   m_buffer[m_y_pos*TERMINAL_WIDTH+m_x_pos] = data;
158   m_x_pos++;
159   if (m_x_pos >= TERMINAL_WIDTH)
226160   {
227   case DONE:
228      break;
229   case STOP:
230      data = 1;
231      term->tx_state++;
232      break;
233
234   case START:
235      data = 0;
236      term->tx_state++;
237      break;
238
239   default:
240      data = BIT(term->tx_shift, 0);
241      term->tx_shift >>= 1;
242      term->tx_state++;
243      break;
161      m_x_pos = 0;
162      m_y_pos++;
163      if (m_y_pos >= TERMINAL_HEIGHT)
164      {
165         scroll_line();
166         m_y_pos = TERMINAL_HEIGHT-1;
167      }
244168   }
245
246   return data;
247169}
248170
249WRITE_LINE_DEVICE_HANDLER( terminal_serial_w )
171void generic_terminal_device::clear()
250172{
251   terminal_state *term = get_safe_token(device);
252
253   switch (term->rx_state)
254   {
255   case START:
256      if (!state) term->rx_state++;
257      break;
258
259   case STOP:
260      terminal_write(device, 0, term->rx_shift);
261      term->rx_state = START;
262      break;
263
264   default:
265      term->rx_shift >>= 1;
266      term->rx_shift |= (state << 7);
267      term->rx_state++;
268      break;
269   }
173   memset(m_buffer,0x20,TERMINAL_WIDTH*TERMINAL_HEIGHT);
174   m_x_pos = 0;
175   m_y_pos = 0;
270176}
271177
272WRITE8_DEVICE_HANDLER ( terminal_write )
178void generic_terminal_device::term_write(UINT8 data)
273179{
274   terminal_state *term = get_safe_token(device);
275180   if (data > 0x1f)
276181   {
277182      // printable char
278      if (data!=0x7f) terminal_write_char(device,data);
183      if (data!=0x7f) write_char(data);
279184   }
280185   else
281186   {
r14605r14606
284189         case 0x07 : // bell
285190               break;
286191
287         case 0x08:   if (term->x_pos) term->x_pos--;
192         case 0x08:   if (m_x_pos) m_x_pos--;
288193               break;
289194
290         case 0x09:   term->x_pos = (term->x_pos & 0xf8) + 8;
291               if (term->x_pos >= TERMINAL_WIDTH)
292                  term->x_pos = TERMINAL_WIDTH-1;
195         case 0x09:   m_x_pos = (m_x_pos & 0xf8) + 8;
196               if (m_x_pos >= TERMINAL_WIDTH)
197                  m_x_pos = TERMINAL_WIDTH-1;
293198               break;
294199
295         case 0x0a:   term->y_pos++;
296               term->x_pos = 0;
297               if (term->y_pos >= TERMINAL_HEIGHT)
200         case 0x0a:   m_y_pos++;
201               m_x_pos = 0;
202               if (m_y_pos >= TERMINAL_HEIGHT)
298203               {
299                  terminal_scroll_line(device);
300                  term->y_pos = TERMINAL_HEIGHT-1;
204                  scroll_line();
205                  m_y_pos = TERMINAL_HEIGHT-1;
301206               }
302207               break;
303208
304         case 0x0b:   if (term->y_pos) term->y_pos--;
209         case 0x0b:   if (m_y_pos) m_y_pos--;
305210               break;
306211
307         case 0x0d:   term->x_pos = 0;
212         case 0x0d:   m_x_pos = 0;
308213               break;
309214
310         case 0x1e:   term->x_pos = 0;
311               term->y_pos = 0;
215         case 0x1e:   m_x_pos = 0;
216               m_y_pos = 0;
312217               break;
313218      }
314219   }
r14605r14606
317222/***************************************************************************
318223    VIDEO HARDWARE
319224***************************************************************************/
320static void generic_terminal_update(device_t *device, bitmap_rgb32 &bitmap, const rectangle &cliprect)
225UINT32 generic_terminal_device::update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect)
321226{
322   terminal_state *term = get_safe_token(device);
323   UINT8 options = input_port_read(*device, "TERM_CONF");
324   UINT16 cursor = term->y_pos * TERMINAL_WIDTH + term->x_pos;
227   UINT8 options = input_port_read(*this, "TERM_CONF");
228   UINT16 cursor = m_y_pos * TERMINAL_WIDTH + m_x_pos;
325229   UINT8 y,ra,chr,gfx;
326230   UINT16 sy=0,ma=0,x;
327231   UINT32 font_color;
r14605r14606
338242      break;
339243   }
340244
341   term->framecnt++;
245   m_framecnt++;
342246
343247   for (y = 0; y < TERMINAL_HEIGHT; y++)
344248   {
r14605r14606
348252
349253         for (x = ma; x < ma + TERMINAL_WIDTH; x++)
350254         {
351            chr = term->buffer[x];
255            chr = m_buffer[x];
352256            gfx = terminal_font[(chr<<4) | ra ];
353257
354258            if ((x == cursor) && (options & 1)) // at cursor position and want a cursor
355259            {
356260               if ((options & 2) || (ra == 9)) // block, or underline & at bottom line
357261               {
358                  if ((options & 4) && (term->framecnt & 8)) // want blink & time to blink
262                  if ((options & 4) && (m_framecnt & 8)) // want blink & time to blink
359263                  {
360264                  }
361265                  else
r14605r14606
381285      }
382286      ma+=TERMINAL_WIDTH;
383287   }
288   return 0;
384289}
385290
386static UINT8 row_number(UINT8 code) {
291UINT8 generic_terminal_device::row_number(UINT8 code) {
387292   if BIT(code,0) return 0;
388293   if BIT(code,1) return 1;
389294   if BIT(code,2) return 2;
r14605r14606
395300   return 0;
396301}
397302
398UINT8 terminal_keyboard_handler(running_machine &machine, UINT8 last_code, UINT8 *scan_line, UINT8 *tx_shift, int *tx_state, device_t *device)
303UINT8 generic_terminal_device::keyboard_handler(UINT8 last_code, UINT8 *scan_line)
399304{
400305   static const char *const keynames[] = { "TERM_LINE0", "TERM_LINE1", "TERM_LINE2", "TERM_LINE3", "TERM_LINE4", "TERM_LINE5", "TERM_LINE6", "TERM_LINE7" };
401306   int i;
402307   UINT8 code;
403308   UINT8 key_code = 0;
404309   UINT8 retVal = 0;
405   UINT8 shift = BIT(input_port_read(*device, "TERM_LINEC"), 1);
406   UINT8 caps  = BIT(input_port_read(*device, "TERM_LINEC"), 2);
407   UINT8 ctrl  = BIT(input_port_read(*device, "TERM_LINEC"), 0);
310   UINT8 shift = BIT(input_port_read(*this, "TERM_LINEC"), 1);
311   UINT8 caps  = BIT(input_port_read(*this, "TERM_LINEC"), 2);
312   UINT8 ctrl  = BIT(input_port_read(*this, "TERM_LINEC"), 0);
408313   i = *scan_line;
409314   {
410      code =   input_port_read(*device, keynames[i]);
315      code =   input_port_read(*this, keynames[i]);
411316      if (code != 0)
412317      {
413318         if (i==0 && shift==0) {
r14605r14606
484389               case 0: key_code = 0x1B; break; // Escape
485390            }
486391         }
487         if (last_code != key_code ) {
488            if (tx_shift) *tx_shift = key_code;
489            if (tx_state) *tx_state = START;
490         }
491392         retVal = key_code;
492393      } else {
493394         *scan_line += 1;
r14605r14606
499400   return retVal;
500401}
501402
502static TIMER_CALLBACK(keyboard_callback)
403void generic_terminal_device::device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr)
503404{
504405   UINT8 new_code;
505   terminal_state *term = get_safe_token((device_t *)ptr);
506   new_code = terminal_keyboard_handler(machine, term->last_code, &term->scan_line, &term->tx_shift, &term->tx_state, (device_t *)ptr);
507   if(term->last_code != new_code)
508      term->terminal_keyboard_func(0, new_code);
509   term->last_code = new_code;
406   new_code = keyboard_handler(m_last_code, &m_scan_line);
407   if(m_last_code != new_code)
408      send_key(new_code);
409   m_last_code = new_code;
510410}
511411
512static TIMER_CALLBACK(serial_callback)
513{
514   static int count = 0;
515   terminal_state *term = get_safe_token((device_t *)ptr);
516   if(term->tx_state == DONE) {
517      if(count == 0) {
518         term->last_code = terminal_keyboard_handler(machine, term->last_code, &term->scan_line, &term->tx_shift, &term->tx_state, (device_t *)ptr);
519      } else
520         ++count %= 8;
521   } else
522      term->terminal_keyboard_func(0, terminal_serial_r((device_t *)ptr));
523}
524
525412/***************************************************************************
526413    VIDEO HARDWARE
527414***************************************************************************/
528415
529static SCREEN_UPDATE_RGB32(terminal )
530{
531   device_t *devconf = screen.owner();
532   generic_terminal_update( devconf, bitmap, cliprect);
533   return 0;
534}
535
536416static MACHINE_CONFIG_FRAGMENT( generic_terminal )
537417   MCFG_SCREEN_ADD(TERMINAL_SCREEN_TAG, RASTER)
538418   MCFG_SCREEN_REFRESH_RATE(50)
539419   MCFG_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
540420   MCFG_SCREEN_SIZE(TERMINAL_WIDTH*8, TERMINAL_HEIGHT*10)
541421   MCFG_SCREEN_VISIBLE_AREA(0, TERMINAL_WIDTH*8-1, 0, TERMINAL_HEIGHT*10-1)
542   MCFG_SCREEN_UPDATE_STATIC(terminal)
422   MCFG_SCREEN_UPDATE_DEVICE(DEVICE_SELF, generic_terminal_device, update)
543423MACHINE_CONFIG_END
544424
425machine_config_constructor generic_terminal_device::device_mconfig_additions() const
426{
427      return MACHINE_CONFIG_NAME(generic_terminal);
428}
545429
546/*-------------------------------------------------
547    DEVICE_START( terminal )
548-------------------------------------------------*/
549
550static DEVICE_START( terminal )
430void generic_terminal_device::device_start()
551431{
552   terminal_state *term = get_safe_token(device);
553   const terminal_interface *intf = get_interface(device);
554   term->terminal_keyboard_func.resolve(intf->terminal_keyboard_func, *device);
432   m_keyboard_func.resolve(m_keyboard_cb, *this);
433   m_timer = timer_alloc();
434}
555435
556   if (device->clock())
557      device->machine().scheduler().timer_pulse(attotime::from_hz(device->clock()), FUNC(serial_callback), 0, (void*)device);
558   else if (!term->terminal_keyboard_func.isnull())
559      device->machine().scheduler().timer_pulse(attotime::from_hz(2400), FUNC(keyboard_callback), 0, (void*)device);
436void generic_terminal_device::device_config_complete()
437{
438   const _terminal_interface *intf = reinterpret_cast<const _terminal_interface *>(static_config());
439   if(intf != NULL)
440   {
441      *static_cast<_terminal_interface *>(this) = *intf;
442   }
443   else
444   {     
445      memset(&m_keyboard_cb, 0, sizeof(m_keyboard_cb));
446   }
560447}
561448
562/*-------------------------------------------------
563    DEVICE_RESET( terminal )
564-------------------------------------------------*/
565
566static DEVICE_RESET( terminal )
449void generic_terminal_device::device_reset()
567450{
568   terminal_state *term = get_safe_token(device);
569   terminal_clear(device);
570   term->last_code = 0;
571   term->scan_line = 0;
572   term->rx_state = START;
573   term->tx_state = DONE;
451   clear();
452   m_last_code = 0;
453   m_scan_line = 0;
454   m_timer->adjust(attotime::from_hz(2400), 0, attotime::from_hz(2400));
574455}
575456
576457/*
r14605r14606
610491(us)   31 0037 0x1f | ?      63 0077 0x3f | _      95 0137 0x5f | (del) 127 0177 0x7f
611492
612493*/
613INPUT_PORTS_START( generic_terminal )
494static INPUT_PORTS_START( generic_terminal )
614495   PORT_START("TERM_LINEC")
615496   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Ctrl") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL)
616497   PORT_BIT(0x02, IP_ACTIVE_HIGH, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_LSHIFT)  PORT_CODE(KEYCODE_RSHIFT) PORT_CHAR(UCHAR_SHIFT_1)
r14605r14606
713594   PORT_CONFSETTING(    0x20, "White")
714595INPUT_PORTS_END
715596
716/*-------------------------------------------------
717    DEVICE_GET_INFO( terminal )
718-------------------------------------------------*/
597ioport_constructor generic_terminal_device::device_input_ports() const
598{
599   return INPUT_PORTS_NAME(generic_terminal);
600}
719601
720DEVICE_GET_INFO( terminal )
602const device_type GENERIC_TERMINAL = &device_creator<generic_terminal_device>;
603
604static INPUT_PORTS_START(serial_terminal)
605   PORT_INCLUDE(generic_terminal)
606   PORT_START("TERM_FRAME")
607   PORT_CONFNAME(0x0f, 0x06, "Baud") PORT_CHANGED_MEMBER(DEVICE_SELF, serial_terminal_device, update_frame, 0)
608   PORT_CONFSETTING( 0x00, "150")
609   PORT_CONFSETTING( 0x01, "300")
610   PORT_CONFSETTING( 0x02, "600")
611   PORT_CONFSETTING( 0x03, "1200")
612   PORT_CONFSETTING( 0x04, "2400")
613   PORT_CONFSETTING( 0x05, "4800")
614   PORT_CONFSETTING( 0x06, "9600")
615   PORT_CONFSETTING( 0x07, "14400")
616   PORT_CONFSETTING( 0x08, "19200")
617   PORT_CONFSETTING( 0x09, "28800")
618   PORT_CONFSETTING( 0x0a, "38400")
619   PORT_CONFSETTING( 0x0b, "57600")
620   PORT_CONFSETTING( 0x0c, "115200")
621   PORT_CONFNAME(0x30, 0x00, "Format") PORT_CHANGED_MEMBER(DEVICE_SELF, serial_terminal_device, update_frame, 0)
622   PORT_CONFSETTING( 0x00, "8N1")
623   PORT_CONFSETTING( 0x10, "7E1")
624INPUT_PORTS_END
625
626ioport_constructor serial_terminal_device::device_input_ports() const
721627{
722   switch (state)
628   return INPUT_PORTS_NAME(serial_terminal);
629}
630
631serial_terminal_device::serial_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
632   : generic_terminal_device(mconfig, SERIAL_TERMINAL, "Serial Terminal", tag, owner, clock),
633     device_serial_interface(mconfig, *this),
634     device_serial_port_interface(mconfig, *this)
635{
636}
637
638void serial_terminal_device::device_config_complete()
639{
640   const serial_terminal_interface *intf = reinterpret_cast<const serial_terminal_interface *>(static_config());
641   if(intf != NULL)
723642   {
724      /* --- the following bits of info are returned as 64-bit signed integers --- */
725      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                                    break;
726      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(terminal_state);                     break;
643      *static_cast<serial_terminal_interface *>(this) = *intf;
644   }
645   else
646   {     
647      memset(&m_out_tx_cb, 0, sizeof(m_out_tx_cb));
648   }
649   m_shortname = "serial_terminal";
650}
727651
728      /* --- the following bits of info are returned as pointers to data or functions --- */
729      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(terminal);               break;
730      case DEVINFO_FCT_STOP:                     /* Nothing */                                    break;
731      case DEVINFO_FCT_RESET:                     info->reset = DEVICE_RESET_NAME(terminal);               break;
652static int rates[] = {150, 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200};
732653
733      case DEVINFO_PTR_INPUT_PORTS:               info->ipt = INPUT_PORTS_NAME(generic_terminal);            break;
734      case DEVINFO_PTR_MACHINE_CONFIG:            info->machine_config = MACHINE_CONFIG_NAME(generic_terminal); break;
735      /* --- the following bits of info are returned as NULL-terminated strings --- */
736      case DEVINFO_STR_NAME:                     strcpy(info->s, "Generic Terminal");                  break;
737      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "Terminal");                        break;
738      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                              break;
739      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);                           break;
740      case DEVINFO_STR_CREDITS:                  strcpy(info->s, "Copyright the MESS Team");             break;
654void serial_terminal_device::device_start()
655{
656   int baud = clock();
657   if(!baud) baud = 9600;
658   m_owner = dynamic_cast<serial_port_device *>(owner());
659   m_out_tx_func.resolve(m_out_tx_cb, *this);
660   m_slot = m_owner && 1;
661   m_timer = timer_alloc();
662   set_rcv_rate(baud);
663   set_tra_rate(baud);
664   set_data_frame(8, 1, SERIAL_PARITY_NONE);
665}
666
667INPUT_CHANGED_MEMBER(serial_terminal_device::update_frame)
668{
669   set_tra_rate(rates[newval & 0x0f]);
670   set_rcv_rate(rates[newval & 0x0f]);
671
672   switch(newval & 0x30)
673   {
674   case 0x10:
675      set_data_frame(7, 1, SERIAL_PARITY_EVEN);
676      break;
677   case 0x00:
678   default:
679      set_data_frame(8, 1, SERIAL_PARITY_NONE);
680      break;
741681   }
742682}
743683
744DEFINE_LEGACY_DEVICE(GENERIC_TERMINAL, terminal);
684void serial_terminal_device::device_reset()
685{
686   generic_terminal_device::device_reset();
687   m_rbit = 1;
688   if(m_slot)
689      m_owner->out_rx(m_rbit);
690   else
691      m_out_tx_func(m_rbit);
692}
745693
746serial_terminal_device::serial_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock)
747      : device_t(mconfig, SERIAL_TERMINAL, "Serial Terminal", tag, owner, clock),
748        device_serial_port_interface(mconfig, *this),
749        m_terminal(*this, TERMINAL_TAG)
694void serial_terminal_device::send_key(UINT8 code)
750695{
696   if(is_transmit_register_empty())
697   {
698      transmit_register_setup(code);
699      return;
700   }
701   m_key_valid = true;
702   m_curr_key = code;
751703}
752704
753static const terminal_interface serial_terminal_terminal_interface = {
754      DEVCB_DEVICE_MEMBER(DEVICE_SELF_OWNER, serial_terminal_device, serial_keyboard_func)
755};
705void serial_terminal_device::tra_callback()
706{
707   m_rbit = transmit_register_get_data_bit();
708   if(m_slot)
709      m_owner->out_rx(m_rbit);
710   else
711      m_out_tx_func(m_rbit);
712}
756713
757static MACHINE_CONFIG_FRAGMENT(serial_terminal_config)
758      MCFG_SERIAL_TERMINAL_ADD(TERMINAL_TAG, serial_terminal_terminal_interface, 9600)
759MACHINE_CONFIG_END
714void serial_terminal_device::tra_complete()
715{
716   if(m_key_valid)
717   {
718      transmit_register_setup(m_curr_key);
719      m_key_valid = false;
720   }
721}
760722
761const device_type SERIAL_TERMINAL = &device_creator<serial_terminal_device>;
723void serial_terminal_device::rcv_complete()
724{
725   receive_register_extract();
726   term_write(get_received_char());
727}
762728
763machine_config_constructor serial_terminal_device::device_mconfig_additions() const
729READ_LINE_MEMBER(serial_terminal_device::tx_r)
764730{
765      return MACHINE_CONFIG_NAME(serial_terminal_config);
731   return m_rbit;
766732}
733
734const device_type SERIAL_TERMINAL = &device_creator<serial_terminal_device>;
src/mess/machine/terminal.h
r14605r14606
33
44#include "emu.h"
55#include "machine/serial.h"
6#include "devcb.h"
76
87/***************************************************************************
98    TYPE DEFINITIONS
r14605r14606
1211typedef struct _terminal_interface terminal_interface;
1312struct _terminal_interface
1413{
15   devcb_write8 terminal_keyboard_func;
14   devcb_write8 m_keyboard_cb;
1615};
1716
1817#define GENERIC_TERMINAL_INTERFACE(name) const terminal_interface (name) =
1918
19struct serial_terminal_interface
20{
21   devcb_write_line m_out_tx_cb;
22};
23
2024/***************************************************************************
2125    DEVICE CONFIGURATION MACROS
2226***************************************************************************/
2327#define TERMINAL_TAG "terminal"
2428#define TERMINAL_SCREEN_TAG "terminal_screen"
2529
26DECLARE_LEGACY_DEVICE(GENERIC_TERMINAL, terminal);
27
2830#define MCFG_GENERIC_TERMINAL_ADD(_tag, _intrf) \
2931   MCFG_DEVICE_ADD(_tag, GENERIC_TERMINAL, 0) \
3032   MCFG_DEVICE_CONFIG(_intrf)
r14605r14606
3234#define MCFG_GENERIC_TERMINAL_REMOVE(_tag)      \
3335    MCFG_DEVICE_REMOVE(_tag)
3436
35#define MCFG_SERIAL_TERMINAL_ADD(_tag, _intrf, _baud) \
36   MCFG_DEVICE_ADD(_tag, GENERIC_TERMINAL, _baud) \
37#define MCFG_SERIAL_TERMINAL_ADD(_tag, _intrf, _clock) \
38   MCFG_DEVICE_ADD(_tag, SERIAL_TERMINAL, _clock) \
3739   MCFG_DEVICE_CONFIG(_intrf)
3840
3941/***************************************************************************
4042    FUNCTION PROTOTYPES
4143***************************************************************************/
4244
43READ_LINE_DEVICE_HANDLER( terminal_serial_r );
44WRITE_LINE_DEVICE_HANDLER( terminal_serial_w );
45#define TERMINAL_WIDTH 80
46#define TERMINAL_HEIGHT 24
4547
46WRITE8_DEVICE_HANDLER ( terminal_write );
48class generic_terminal_device :
49   public device_t,
50   public _terminal_interface
51{
52public:
53   generic_terminal_device(const machine_config &mconfig, device_type type, const char *name, const char *tag, device_t *owner, UINT32 clock);
54   generic_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
55   DECLARE_WRITE8_MEMBER(write) { term_write(data); }
56   UINT32 update(screen_device &device, bitmap_rgb32 &bitmap, const rectangle &cliprect);
4757
48INPUT_PORTS_EXTERN(generic_terminal);
58   virtual ioport_constructor device_input_ports() const;
59   virtual machine_config_constructor device_mconfig_additions() const;
60protected:
61   virtual void term_write(UINT8 data);
62   virtual void device_start();
63   virtual void device_reset();
64   virtual void device_timer(emu_timer &timer, device_timer_id id, int param, void *ptr);
65   virtual void device_config_complete();
66   virtual void send_key(UINT8 code) { m_keyboard_func(0, code); }
67   UINT8 m_buffer[TERMINAL_WIDTH*50]; // make big enough for teleprinter
68   UINT8 m_x_pos;
69   emu_timer *m_timer;
70private:
71   UINT8 keyboard_handler(UINT8 last_code, UINT8 *scan_line);
72   void scroll_line();
73   void write_char(UINT8 data);
74   void clear();
75   UINT8 row_number(UINT8 code);
4976
50UINT8 terminal_keyboard_handler(running_machine &machine, UINT8 last_code, UINT8 *scan_line, UINT8 *tx_shift, int *tx_state, device_t *device);
77   UINT8 m_framecnt;
78   UINT8 m_y_pos;
79   UINT8 m_last_code;
80   UINT8 m_scan_line;
5181
82   devcb_resolved_write8 m_keyboard_func;
83};
84
85extern const device_type GENERIC_TERMINAL;
86
5287class serial_terminal_device :
53      public device_t,
54      public device_serial_port_interface
88   public generic_terminal_device,
89   public device_serial_interface,
90   public device_serial_port_interface,
91   public serial_terminal_interface
5592{
5693public:
5794   serial_terminal_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock);
58   virtual machine_config_constructor device_mconfig_additions() const;
59   virtual void tx(UINT8 state) { terminal_serial_w(m_terminal, state); }
60   DECLARE_WRITE8_MEMBER(serial_keyboard_func) { m_rbit = data&&1; m_owner->out_rx(m_rbit); }
95
96   DECLARE_WRITE_LINE_MEMBER(rx_w) { m_tbit = state; check_for_start(state); }
97   DECLARE_READ_LINE_MEMBER(tx_r);
98   virtual ioport_constructor device_input_ports() const;
99
100   DECLARE_INPUT_CHANGED_MEMBER(update_frame);
61101protected:
62   virtual void device_start() { m_owner = dynamic_cast<serial_port_device *>(owner()); }
63   virtual void device_reset() { m_owner->out_rx(1); m_rbit = 1; }
64   virtual void device_config_complete() { m_shortname = "serial_terminal"; }
102   virtual void device_start();
103   virtual void device_config_complete();
104   virtual void device_reset();
105   virtual void tra_callback();
106   virtual void tra_complete();
107   virtual void rcv_complete();
108   virtual void input_callback(UINT8 state) { m_input_state = state; }
109   virtual void send_key(UINT8 code);
65110private:
66   required_device<device_t> m_terminal;
67111   serial_port_device *m_owner;
112   bool m_slot;
113   UINT8 m_curr_key;
114   bool m_key_valid;
115   devcb_resolved_write_line m_out_tx_func;
68116};
69117
70118extern const device_type SERIAL_TERMINAL;
src/mess/includes/exp85.h
r14605r14606
1818   { }
1919
2020   required_device<cpu_device> m_maincpu;
21   required_device<device_t> m_terminal;
21   required_device<serial_terminal_device> m_terminal;
2222   required_device<cassette_image_device> m_cassette;
2323   required_device<device_t> m_speaker;
2424
r14605r14606
2828   DECLARE_WRITE8_MEMBER( i8355_a_w );
2929   DECLARE_READ_LINE_MEMBER( sid_r );
3030   DECLARE_WRITE_LINE_MEMBER( sod_w );
31   DECLARE_WRITE_LINE_MEMBER( terminal_w );
3132
3233   /* cassette state */
3334   int m_tape_control;
src/mess/includes/pes.h
r14605r14606
2222      { }
2323
2424   required_device<cpu_device> m_maincpu;
25   required_device<device_t> m_terminal;
25   required_device<generic_terminal_device> m_terminal;
2626   required_device<device_t> m_speech;
2727
2828   UINT8 m_wsstate;         // /WS
src/mess/includes/xor100.h
r14605r14606
3737   required_device<device_t> m_fdc;
3838   required_device<device_t> m_ctc;
3939   required_device<ram_device> m_ram;
40   required_device<device_t> m_terminal;
40   required_device<generic_terminal_device> m_terminal;
4141   required_device<device_t> m_floppy0;
4242   required_device<device_t> m_floppy1;
4343
src/mess/includes/bullet.h
r14605r14606
5454   required_device<ram_device> m_ram;
5555   required_device<device_t> m_floppy0;
5656   required_device<device_t> m_floppy1;
57   required_device<device_t> m_terminal;
57   required_device<serial_terminal_device> m_terminal;
5858   required_device<centronics_device> m_centronics;
5959
6060   virtual void machine_start();
src/mess/includes/mpz80.h
r14605r14606
4545
4646   required_device<cpu_device> m_maincpu;
4747   required_device<ram_device> m_ram;
48   required_device<device_t> m_terminal;
48   required_device<generic_terminal_device> m_terminal;
4949   required_device<s100_device> m_s100;
5050
5151   virtual void machine_start();
src/mess/includes/super6.h
r14605r14606
4343        m_brg(*this, BR1945_TAG),
4444        m_ram(*this, RAM_TAG),
4545        m_floppy0(*this, FLOPPY_0),
46        m_floppy1(*this, FLOPPY_1)
46        m_floppy1(*this, FLOPPY_1),
47        m_terminal(*this, TERMINAL_TAG)
4748   { }
4849
4950   required_device<cpu_device> m_maincpu;
r14605r14606
5657   required_device<ram_device> m_ram;
5758   required_device<device_t> m_floppy0;
5859   required_device<device_t> m_floppy1;
60   required_device<serial_terminal_device> m_terminal;
5961
6062   virtual void machine_start();
6163   virtual void machine_reset();
src/mess/includes/sage2.h
r14605r14606
4040        m_floppy1(*this, FLOPPY_1),
4141        m_centronics(*this, CENTRONICS_TAG),
4242        m_ieee488(*this, IEEE488_TAG),
43        m_terminal(*this, TERMINAL_TAG),
4344        m_reset(1),
4445        m_fdc_int(0),
4546        m_fdie(0),
r14605r14606
5758   required_device<device_t> m_floppy1;
5859   required_device<centronics_device> m_centronics;
5960   required_device<ieee488_device> m_ieee488;
61   required_device<generic_terminal_device> m_terminal;
6062 
6163   virtual void machine_reset();
6264 
src/mess/includes/ob68k1a.h
r14605r14606
3232   required_device<device_t> m_acia0;
3333   required_device<pia6821_device> m_pia0;
3434   required_device<pia6821_device> m_pia1;
35   required_device<device_t> m_terminal;
35   required_device<serial_terminal_device> m_terminal;
3636   required_device<ram_device> m_ram;
3737
3838   virtual void machine_start();
src/mess/drivers/dectalk.c
r14605r14606
152152{
153153public:
154154   dectalk_state(const machine_config &mconfig, device_type type, const char *tag)
155      : driver_device(mconfig, type, tag) { }
155      : driver_device(mconfig, type, tag),
156        m_terminal(*this, TERMINAL_TAG) { }
156157
157158   UINT8 m_data[8]; // hack to prevent gcc bitching about struct pointers. not used.
158159   UINT8 m_x2214_sram[256]; // NVRAM chip's temp sram space
r14605r14606
176177   UINT8 m_duart_inport; // low 4 bits of duart input
177178   UINT8 m_duart_outport; // most recent duart output
178179   UINT8 m_hack_self_test; // temp variable for hack below
180
181   required_device<generic_terminal_device> m_terminal;
179182};
180183
181184
r14605r14606
210213static void duart_tx(device_t *device, int channel, UINT8 data)
211214{
212215   device_t *devconf = device->machine().device(TERMINAL_TAG);
213   terminal_write(devconf,0,data);
216   dynamic_cast<generic_terminal_device *>(devconf)->write(*memory_nonspecific_space(devconf->machine()), 0, data);
214217#ifdef SERIAL_TO_STDERR
215218   fprintf(stderr, "%02X ",data);
216219#endif
src/mess/drivers/pes.c
r14605r14606
115115static void data_from_i8031(device_t *device, int data)
116116{
117117   pes_state *state = device->machine().driver_data<pes_state>();
118   terminal_write(state->m_terminal,0,data);
118   state->m_terminal->write(*memory_nonspecific_space(device->machine()),0,data);
119119#ifdef DEBUG_SERIAL_CB
120120   fprintf(stderr,"callback: output from i8031/pes to pc/terminal: %02X\n",data);
121121#endif
src/mess/drivers/xor100.c
r14605r14606
169169WRITE8_MEMBER( xor100_state::i8251_b_data_w )
170170{
171171   m_uart_b->data_w(space, 0, data);
172   terminal_write(m_terminal, 0, data);
172   m_terminal->write(space, 0, data);
173173}
174174
175175READ8_MEMBER( xor100_state::fdc_wait_r )
src/mess/drivers/zexall.c
r14605r14606
3535   { }
3636
3737   required_device<cpu_device> m_maincpu;
38   required_device<device_t> m_terminal;
38   required_device<generic_terminal_device> m_terminal;
3939   DECLARE_READ8_MEMBER( zexall_output_ack_r );
4040   DECLARE_READ8_MEMBER( zexall_output_req_r );
4141   DECLARE_READ8_MEMBER( zexall_output_data_r );
r14605r14606
7474// spit out the byte in out_byte if out_req is not equal to out_req_last
7575   if (m_out_req != m_out_req_last)
7676   {
77      terminal_write(m_terminal,0,m_out_data);
77      m_terminal->write(space,0,m_out_data);
7878      fprintf(stderr,"%c",m_out_data);
7979      m_out_req_last = m_out_req;
8080      m_out_ack++;
src/mess/drivers/h89.c
r14605r14606
3030   h89_state(const machine_config &mconfig, device_type type, const char *tag)
3131      : driver_device(mconfig, type, tag),
3232        m_maincpu(*this, "maincpu"),
33        m_uart(*this, "ins8250")
33        m_uart(*this, "ins8250"),
34        m_terminal(*this, TERMINAL_TAG)
3435   { }
3536
3637   required_device<cpu_device> m_maincpu;
3738   required_device<ins8250_device> m_uart;
39   required_device<serial_terminal_device> m_terminal;
3840
39   DECLARE_WRITE_LINE_MEMBER( h89_terminal_out );
40   DECLARE_WRITE8_MEMBER( h89_terminal_in );
4141   DECLARE_WRITE8_MEMBER( port_f2_w );
4242
4343   UINT8 m_port_f2;
r14605r14606
110110   m_port_f2 = data;
111111}
112112
113WRITE_LINE_MEMBER( h89_state::h89_terminal_out )
113static const serial_terminal_interface terminal_intf =
114114{
115   device_t *terminal = machine().device(TERMINAL_TAG);
116   terminal_serial_w(terminal, state);
117}
118
119WRITE8_MEMBER( h89_state::h89_terminal_in )
120{
121   m_uart->rx_w(data&&1);
122}
123
124static GENERIC_TERMINAL_INTERFACE( terminal_intf )
125{
126   DEVCB_DRIVER_MEMBER(h89_state, h89_terminal_in)
115   DEVCB_DEVICE_LINE_MEMBER("ins8250", ins8250_uart_device, rx_w)
127116};
128117
129118static const ins8250_interface h89_ins8250_interface =
130119{
131   DEVCB_DRIVER_LINE_MEMBER(h89_state, h89_terminal_out),
120   DEVCB_DEVICE_LINE_MEMBER(TERMINAL_TAG, serial_terminal_device, rx_w),
132121   DEVCB_NULL,
133122   DEVCB_NULL,
134123   DEVCB_NULL,
src/mess/drivers/zsbc3.c
r14605r14606
4848   { }
4949
5050   required_device<cpu_device> m_maincpu;
51   required_device<device_t> m_terminal;
51   required_device<generic_terminal_device> m_terminal;
5252   DECLARE_READ8_MEMBER(zsbc3_28_r);
5353   DECLARE_READ8_MEMBER(zsbc3_2a_r);
5454   DECLARE_WRITE8_MEMBER(kbd_put);
r14605r14606
7777static ADDRESS_MAP_START(zsbc3_io, AS_IO, 8, zsbc3_state)
7878   ADDRESS_MAP_UNMAP_HIGH
7979   ADDRESS_MAP_GLOBAL_MASK(0xff)
80   AM_RANGE(0x28, 0x28) AM_READ(zsbc3_28_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
80   AM_RANGE(0x28, 0x28) AM_READ(zsbc3_28_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
8181   AM_RANGE(0x2a, 0x2a) AM_READ(zsbc3_2a_r)
8282ADDRESS_MAP_END
8383
src/mess/drivers/dual68.c
r14605r14606
2323   { }
2424
2525   required_device<cpu_device> m_maincpu;
26   required_device<device_t> m_terminal;
26   required_device<generic_terminal_device> m_terminal;
2727   DECLARE_WRITE8_MEMBER( kbd_put );
2828   DECLARE_WRITE16_MEMBER( dual68_terminal_w );
2929   //UINT8 m_term_data;
r14605r14606
3434
3535WRITE16_MEMBER( dual68_state::dual68_terminal_w )
3636{
37   terminal_write(m_terminal, 0, data >> 8);
37   m_terminal->write(space, 0, data >> 8);
3838}
3939
4040static ADDRESS_MAP_START(dual68_mem, AS_PROGRAM, 16, dual68_state)
src/mess/drivers/d6809.c
r14605r14606
9696   { }
9797
9898   required_device<cpu_device> m_maincpu;
99   required_device<device_t> m_terminal;
99   required_device<generic_terminal_device> m_terminal;
100100   DECLARE_WRITE8_MEMBER( kbd_put );
101101   DECLARE_READ8_MEMBER( term_r );
102102   DECLARE_WRITE8_MEMBER( term_w );
r14605r14606
113113WRITE8_MEMBER( d6809_state::term_w )
114114{
115115   if ((data > 0) && (data < 0x80))
116      terminal_write(m_terminal, 0, data);
116      m_terminal->write(space, 0, data);
117117}
118118
119119static ADDRESS_MAP_START( d6809_mem, AS_PROGRAM, 8, d6809_state )
src/mess/drivers/isbc.c
r14605r14606
2828   { }
2929
3030   required_device<cpu_device> m_maincpu;
31   required_device<device_t> m_terminal;
31   required_device<generic_terminal_device> m_terminal;
3232   DECLARE_READ16_MEMBER(isbc_terminal_status_r);
3333   DECLARE_READ16_MEMBER(isbc_terminal_r);
3434   DECLARE_WRITE8_MEMBER(kbd_put);
r14605r14606
6868
6969static ADDRESS_MAP_START(isbc86_io, AS_IO, 16, isbc_state)
7070   ADDRESS_MAP_UNMAP_HIGH
71   AM_RANGE(0x00d8, 0x00d9) AM_READ(isbc_terminal_r) AM_DEVWRITE8_LEGACY(TERMINAL_TAG, terminal_write, 0xff)
71   AM_RANGE(0x00d8, 0x00d9) AM_READ(isbc_terminal_r) AM_DEVWRITE8(TERMINAL_TAG, generic_terminal_device, write, 0xff)
7272   AM_RANGE(0x00da, 0x00db) AM_READ(isbc_terminal_status_r)
7373ADDRESS_MAP_END
7474
src/mess/drivers/sacstate.c
r14605r14606
2727   { }
2828
2929   required_device<cpu_device> m_maincpu;
30   required_device<device_t> m_terminal;
30   required_device<generic_terminal_device> m_terminal;
3131   DECLARE_READ8_MEMBER(status_r);
3232   DECLARE_READ8_MEMBER(tty_r);
3333   DECLARE_READ8_MEMBER(unknown_r);
r14605r14606
7070   AM_RANGE(0x00,0x00) AM_READ(tty_r)
7171   AM_RANGE(0x01,0x01) AM_READ(status_r)
7272   AM_RANGE(0x04,0x04) AM_READ(unknown_r)
73   AM_RANGE(0x16,0x16) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
73   AM_RANGE(0x16,0x16) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
7474ADDRESS_MAP_END
7575
7676/* Input ports */
src/mess/drivers/qtsbc.c
r14605r14606
2525   { }
2626
2727   required_device<cpu_device> m_maincpu;
28   required_device<device_t> m_terminal;
28   required_device<generic_terminal_device> m_terminal;
2929   DECLARE_READ8_MEMBER( qtsbc_06_r );
3030   DECLARE_READ8_MEMBER( qtsbc_43_r );
3131   DECLARE_WRITE8_MEMBER( kbd_put );
r14605r14606
5555static ADDRESS_MAP_START( qtsbc_io, AS_IO, 8, qtsbc_state)
5656   ADDRESS_MAP_UNMAP_HIGH
5757   ADDRESS_MAP_GLOBAL_MASK(0xff)
58   AM_RANGE(0x06, 0x06) AM_READ(qtsbc_06_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
58   AM_RANGE(0x06, 0x06) AM_READ(qtsbc_06_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
5959   AM_RANGE(0x43, 0x43) AM_READ(qtsbc_43_r)
6060ADDRESS_MAP_END
6161
src/mess/drivers/mits680b.c
r14605r14606
3838   { }
3939
4040   required_device<cpu_device> m_maincpu;
41   required_device<device_t> m_terminal;
41   required_device<generic_terminal_device> m_terminal;
4242   DECLARE_READ8_MEMBER(terminal_status_r);
4343   DECLARE_READ8_MEMBER(terminal_r);
4444   DECLARE_READ8_MEMBER(status_check_r);
r14605r14606
7070   AM_RANGE( 0x0000, 0x03ff ) AM_RAM // 1024 bytes RAM
7171   //AM_RANGE( 0xf000, 0xf003 ) AM_DEVREADWRITE("acia",  acia6551_device, read, write )
7272   AM_RANGE( 0xf000, 0xf000 ) AM_READ(terminal_status_r)
73   AM_RANGE( 0xf001, 0xf001 ) AM_READ(terminal_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
73   AM_RANGE( 0xf001, 0xf001 ) AM_READ(terminal_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
7474   AM_RANGE( 0xf002, 0xf002 ) AM_READ(status_check_r)
7575   AM_RANGE( 0xff00, 0xffff ) AM_ROM
7676ADDRESS_MAP_END
src/mess/drivers/votrpss.c
r14605r14606
8383   { }
8484
8585   required_device<cpu_device> m_maincpu;
86   required_device<device_t> m_terminal;
86   required_device<generic_terminal_device> m_terminal;
8787   DECLARE_READ8_MEMBER(votrpss_00_r);
8888   DECLARE_READ8_MEMBER(votrpss_02_r);
8989   DECLARE_READ8_MEMBER(votrpss_41_r);
r14605r14606
126126static ADDRESS_MAP_START(votrpss_io, AS_IO, 8, votrpss_state)
127127   ADDRESS_MAP_GLOBAL_MASK(0xff)
128128   AM_RANGE(0x00, 0x00) AM_READ(votrpss_00_r)
129   AM_RANGE(0x01, 0x01) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
129   AM_RANGE(0x01, 0x01) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
130130   AM_RANGE(0x02, 0x02) AM_READ(votrpss_02_r)
131131   AM_RANGE(0x41, 0x41) AM_READ(votrpss_41_r)
132132   //AM_RANGE(0x00, 0xff) AM_NOP /* temporary */
src/mess/drivers/ccs2422.c
r14605r14606
2525   { }
2626
2727   required_device<cpu_device> m_maincpu;
28   required_device<device_t> m_terminal;
28   required_device<generic_terminal_device> m_terminal;
2929   DECLARE_READ8_MEMBER( ccs2422_10_r );
3030   DECLARE_READ8_MEMBER( ccs2422_11_r );
3131   DECLARE_WRITE8_MEMBER( ccs2422_10_w );
r14605r14606
5050
5151WRITE8_MEMBER( ccs2422_state::ccs2422_10_w )
5252{
53   terminal_write(m_terminal, 0, data & 0x7f);
53   m_terminal->write(space, 0, data & 0x7f);
5454}
5555
5656static ADDRESS_MAP_START(ccs2422_mem, AS_PROGRAM, 8, ccs2422_state)
src/mess/drivers/bullet.c
r14605r14606
719719{
720720   0, 0, 0, 0,
721721
722   DEVCB_DEVICE_LINE(TERMINAL_TAG, terminal_serial_r),
723   DEVCB_DEVICE_LINE(TERMINAL_TAG, terminal_serial_w),
722   DEVCB_DEVICE_LINE_MEMBER(TERMINAL_TAG, serial_terminal_device, tx_r),
723   DEVCB_DEVICE_LINE_MEMBER(TERMINAL_TAG, serial_terminal_device, rx_w),
724724   DEVCB_NULL,
725725   DEVCB_NULL,
726726   DEVCB_DRIVER_LINE_MEMBER(bullet_state, dartardy_w),
r14605r14606
10591059};
10601060
10611061
1062//-------------------------------------------------
1063//  GENERIC_TERMINAL_INTERFACE( terminal_intf )
1064//-------------------------------------------------
1065
1066static WRITE8_DEVICE_HANDLER( dummy_w )
1062static serial_terminal_interface terminal_intf =
10671063{
1068   // handled in Z80DART_INTERFACE
1069}
1070
1071static GENERIC_TERMINAL_INTERFACE( terminal_intf )
1072{
1073   DEVCB_HANDLER(dummy_w)
1064   DEVCB_NULL
10741065};
10751066
10761067
r14605r14606
11911182   MCFG_MB8877_ADD(MB8877_TAG, fdc_intf)
11921183   MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(bullet_floppy_interface)
11931184   MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, standard_centronics)
1194   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
1185   MCFG_SERIAL_TERMINAL_ADD(TERMINAL_TAG, terminal_intf, 4800)
11951186
11961187   // internal ram
11971188   MCFG_RAM_ADD(RAM_TAG)
r14605r14606
12191210   MCFG_MB8877_ADD(MB8877_TAG, bulletf_fdc_intf)
12201211   MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(bullet_floppy_interface)
12211212   MCFG_CENTRONICS_PRINTER_ADD(CENTRONICS_TAG, standard_centronics)
1222   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
1213   MCFG_SERIAL_TERMINAL_ADD(TERMINAL_TAG, terminal_intf, 4800)
12231214    MCFG_SCSIBUS_ADD(SCSIBUS_TAG, scsi_intf)
12241215   MCFG_HARDDISK_ADD("harddisk0")
12251216
src/mess/drivers/mccpm.c
r14605r14606
6868   { }
6969
7070   required_device<cpu_device> m_maincpu;
71   required_device<device_t> m_terminal;
71   required_device<generic_terminal_device> m_terminal;
7272   DECLARE_READ8_MEMBER(mccpm_f0_r);
7373   DECLARE_READ8_MEMBER(mccpm_f1_r);
7474   DECLARE_WRITE8_MEMBER(kbd_put);
r14605r14606
101101static ADDRESS_MAP_START( mccpm_io, AS_IO, 8, mccpm_state)
102102   ADDRESS_MAP_UNMAP_HIGH
103103   ADDRESS_MAP_GLOBAL_MASK(0xff)
104   AM_RANGE(0xf0, 0xf0) AM_READ(mccpm_f0_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
104   AM_RANGE(0xf0, 0xf0) AM_READ(mccpm_f0_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
105105   AM_RANGE(0xf1, 0xf1) AM_READ(mccpm_f1_r)
106106ADDRESS_MAP_END
107107
src/mess/drivers/systec.c
r14605r14606
4747   { }
4848
4949   required_device<cpu_device> m_maincpu;
50   required_device<device_t> m_terminal;
50   required_device<generic_terminal_device> m_terminal;
5151   DECLARE_READ8_MEMBER(systec_c4_r);
5252   DECLARE_READ8_MEMBER(systec_c6_r);
5353   DECLARE_WRITE8_MEMBER( kbd_put );
r14605r14606
8484
8585static ADDRESS_MAP_START(systec_io, AS_IO, 8, systec_state)
8686   ADDRESS_MAP_GLOBAL_MASK(0xff)
87   AM_RANGE(0xc4, 0xc4) AM_READ(systec_c4_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
87   AM_RANGE(0xc4, 0xc4) AM_READ(systec_c4_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
8888   AM_RANGE(0xc6, 0xc6) AM_READ(systec_c6_r)
8989ADDRESS_MAP_END
9090
src/mess/drivers/ipc.c
r14605r14606
5555   { }
5656
5757   required_device<cpu_device> m_maincpu;
58   required_device<device_t> m_terminal;
58   required_device<generic_terminal_device> m_terminal;
5959   DECLARE_READ8_MEMBER( ipc_f4_r );
6060   DECLARE_READ8_MEMBER( ipc_f5_r );
6161   DECLARE_WRITE8_MEMBER( kbd_put );
r14605r14606
8787static ADDRESS_MAP_START( ipc_io, AS_IO, 8, ipc_state)
8888   ADDRESS_MAP_UNMAP_HIGH
8989   ADDRESS_MAP_GLOBAL_MASK(0xff)
90   AM_RANGE(0xf4, 0xf4) AM_READ(ipc_f4_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
90   AM_RANGE(0xf4, 0xf4) AM_READ(ipc_f4_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
9191   AM_RANGE(0xf5, 0xf5) AM_READ(ipc_f5_r)
9292ADDRESS_MAP_END
9393
src/mess/drivers/tricep.c
r14605r14606
2222   { }
2323
2424   required_device<cpu_device> m_maincpu;
25   required_device<device_t> m_terminal;
25   required_device<generic_terminal_device> m_terminal;
2626   DECLARE_READ16_MEMBER(tricep_terminal_r);
2727   DECLARE_WRITE16_MEMBER(tricep_terminal_w);
2828   DECLARE_WRITE8_MEMBER(kbd_put);
r14605r14606
3838
3939WRITE16_MEMBER( tricep_state::tricep_terminal_w )
4040{
41   terminal_write(m_terminal, 0, data >> 8);
41   m_terminal->write(space, 0, data >> 8);
4242}
4343
4444static ADDRESS_MAP_START(tricep_mem, AS_PROGRAM, 16, tricep_state)
src/mess/drivers/sage2.c
r14605r14606
9393   AM_RANGE(0xffc050, 0xffc051) AM_DEVREAD8_LEGACY(UPD765_TAG, upd765_status_r, 0x00ff)
9494   AM_RANGE(0xffc052, 0xffc053) AM_DEVREADWRITE8_LEGACY(UPD765_TAG, upd765_data_r, upd765_data_w, 0x00ff)
9595   AM_RANGE(0xffc060, 0xffc067) AM_DEVREADWRITE8(I8255A_0_TAG, i8255_device, read, write, 0x00ff) // i8255, Printer
96   AM_RANGE(0xffc070, 0xffc071) AM_DEVREAD8(I8251_0_TAG, i8251_device, data_r, 0x00ff) AM_DEVWRITE8_LEGACY(TERMINAL_TAG, terminal_write, 0x00ff)
96   AM_RANGE(0xffc070, 0xffc071) AM_DEVREAD8(I8251_0_TAG, i8251_device, data_r, 0x00ff) AM_DEVWRITE8(TERMINAL_TAG, generic_terminal_device, write, 0x00ff)
9797//  AM_RANGE(0xffc070, 0xffc071) AM_DEVREADWRITE8(I8251_0_TAG, i8251_device, data_r, data_w, 0x00ff)
9898   AM_RANGE(0xffc072, 0xffc073) AM_DEVREADWRITE8(I8251_0_TAG, i8251_device, status_r, control_w, 0x00ff)
9999   AM_RANGE(0xffc080, 0xffc087) AM_MIRROR(0x78) AM_DEVREADWRITE8_LEGACY(I8253_0_TAG, pit8253_r, pit8253_w, 0x00ff)
src/mess/drivers/mod8.c
r14605r14606
2828   m_teleprinter(*this, TELEPRINTER_TAG)
2929   { }
3030
31   required_device<device_t> m_teleprinter;
31   required_device<teleprinter_device> m_teleprinter;
3232   DECLARE_WRITE8_MEMBER(out_w);
3333   DECLARE_WRITE8_MEMBER(tty_w);
3434   DECLARE_WRITE8_MEMBER(kbd_put);
r14605r14606
4646
4747   if (m_tty_cnt == 10)
4848   {
49      teleprinter_write(m_teleprinter, 0, (m_tty_data >> 7) & 0x7f);
49      m_teleprinter->write(space, 0, (m_tty_data >> 7) & 0x7f);
5050      m_tty_cnt = 0;
5151   }
5252}
r14605r14606
112112   MCFG_MACHINE_RESET(mod8)
113113
114114   /* video hardware */
115   MCFG_FRAGMENT_ADD( generic_teleprinter )
116115   MCFG_GENERIC_TELEPRINTER_ADD(TELEPRINTER_TAG, teleprinter_intf)
117116MACHINE_CONFIG_END
118117
src/mess/drivers/cm1800.c
r14605r14606
4040{
4141public:
4242   cm1800_state(const machine_config &mconfig, device_type type, const char *tag)
43      : driver_device(mconfig, type, tag) { }
43      : driver_device(mconfig, type, tag),
44        m_terminal(*this, TERMINAL_TAG) { }
4445
4546   DECLARE_READ8_MEMBER( term_status_r );
4647   DECLARE_READ8_MEMBER( term_r );
4748   DECLARE_WRITE8_MEMBER( kbd_put );
4849   UINT8 m_term_data;
50
51   required_device<generic_terminal_device> m_terminal;
4952};
5053
5154READ8_MEMBER( cm1800_state::term_status_r )
r14605r14606
7376
7477static ADDRESS_MAP_START( cm1800_io , AS_IO, 8, cm1800_state)
7578   ADDRESS_MAP_UNMAP_HIGH
76   AM_RANGE(0x00, 0x00) AM_READ(term_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
79   AM_RANGE(0x00, 0x00) AM_READ(term_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
7780   AM_RANGE(0x01, 0x01) AM_READ(term_status_r)
7881ADDRESS_MAP_END
7982
src/mess/drivers/ob68k1a.c
r14605r14606
214214   DEVCB_NULL
215215};
216216
217
218217//-------------------------------------------------
219218//  ACIA6850_INTERFACE( acia0_intf )
220219//-------------------------------------------------
r14605r14606
223222{
224223   9600*16, // HACK for terminal
225224   9600*16, // HACK for terminal
226   DEVCB_DEVICE_LINE(TERMINAL_TAG, terminal_serial_r),
227   DEVCB_DEVICE_LINE(TERMINAL_TAG, terminal_serial_w),
225   DEVCB_DEVICE_LINE_MEMBER(TERMINAL_TAG, serial_terminal_device, tx_r),
226   DEVCB_DEVICE_LINE_MEMBER(TERMINAL_TAG, serial_terminal_device, rx_w),
228227   DEVCB_LINE_GND, // HACK for terminal
229228   DEVCB_NULL,
230229   DEVCB_LINE_GND, // HACK for terminal
r14605r14606
273272//  GENERIC_TERMINAL_INTERFACE( terminal_intf )
274273//-------------------------------------------------
275274
276static WRITE8_DEVICE_HANDLER( dummy_w )
275static serial_terminal_interface terminal_intf =
277276{
278   // this is here only so that terminal.c will initialize the keyboard scan timer
279}
280
281static GENERIC_TERMINAL_INTERFACE( terminal_intf )
282{
283   DEVCB_HANDLER(dummy_w)
277   DEVCB_NULL
284278};
285279
286280
r14605r14606
350344   MCFG_ACIA6850_ADD(MC6850_0_TAG, acia0_intf)
351345   MCFG_ACIA6850_ADD(MC6850_1_TAG, acia1_intf)
352346   MCFG_COM8116_ADD(COM8116_TAG, XTAL_5_0688MHz, dbrg_intf)
353   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
347   MCFG_SERIAL_TERMINAL_ADD(TERMINAL_TAG, terminal_intf, 9600)
354348
355349   // internal ram
356350   MCFG_RAM_ADD(RAM_TAG)
src/mess/drivers/czk80.c
r14605r14606
3030   { }
3131
3232   required_device<cpu_device> m_maincpu;
33   required_device<device_t> m_terminal;
33   required_device<generic_terminal_device> m_terminal;
3434   DECLARE_READ8_MEMBER( czk80_80_r );
3535   DECLARE_READ8_MEMBER( czk80_81_r );
3636   DECLARE_READ8_MEMBER( czk80_c0_r );
r14605r14606
6565
6666static ADDRESS_MAP_START(czk80_io, AS_IO, 8, czk80_state)
6767   ADDRESS_MAP_GLOBAL_MASK(0xff)
68   AM_RANGE(0x80, 0x80) AM_READ(czk80_80_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
68   AM_RANGE(0x80, 0x80) AM_READ(czk80_80_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
6969   AM_RANGE(0x81, 0x81) AM_READ(czk80_81_r)
7070   AM_RANGE(0xc0, 0xc0) AM_READ(czk80_c0_r)
7171ADDRESS_MAP_END
src/mess/drivers/exp85.c
r14605r14606
143143   }
144144   else
145145   {
146      data = terminal_serial_r(m_terminal);
146      data = m_terminal->tx_r();
147147   }
148148
149149   return data;
r14605r14606
157157   }
158158   else
159159   {
160      terminal_serial_w(m_terminal, state);
160      m_terminal->rx_w(state);
161161   }
162162}
163163
r14605r14606
171171
172172/* Terminal Interface */
173173
174static GENERIC_TERMINAL_INTERFACE( terminal_intf )
174static const serial_terminal_interface terminal_intf =
175175{
176176   DEVCB_NULL
177177};
r14605r14606
217217   MCFG_I8155_ADD(I8155_TAG, XTAL_6_144MHz/2, i8155_intf)
218218   MCFG_I8355_ADD(I8355_TAG, XTAL_6_144MHz/2, i8355_intf)
219219   MCFG_CASSETTE_ADD(CASSETTE_TAG, exp85_cassette_interface)
220   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
220   MCFG_SERIAL_TERMINAL_ADD(TERMINAL_TAG, terminal_intf,9600)
221221
222222   /* internal ram */
223223   MCFG_RAM_ADD(RAM_TAG)
src/mess/drivers/votrtnt.c
r14605r14606
6161   { }
6262
6363   required_device<cpu_device> m_maincpu;
64   required_device<device_t> m_terminal;
64   required_device<generic_terminal_device> m_terminal;
6565   //required_device<device_t> m_acia;
6666   required_device<votrax_device> m_votrax;
6767   DECLARE_READ8_MEMBER( votrtnt_acia_status_r );
r14605r14606
103103   //AM_RANGE(0x2000, 0x2000) AM_NOP AM_MIRROR(0xffe)//AM_DEVREADWRITE("acia_0",aciastat_r,aciactrl_w)/* 6850 ACIA */
104104   //AM_RANGE(0x2001, 0x2001) AM_NOP AM_MIRROR(0xffe)//AM_DEVREADWRITE("acia_0",aciadata_r,aciadata_w)/* 6850 ACIA */
105105   AM_RANGE(0x2000, 0x2000) AM_MIRROR(0xffe) AM_READ(votrtnt_acia_status_r) AM_WRITENOP// temp testing
106   AM_RANGE(0x2001, 0x2001) AM_MIRROR(0xffe) AM_READ(votrtnt_acia_data_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write) // temp testing
106   AM_RANGE(0x2001, 0x2001) AM_MIRROR(0xffe) AM_READ(votrtnt_acia_data_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write) // temp testing
107107   AM_RANGE(0x4000, 0x5fff) AM_WRITE(votrtnt_votrax_w) /* low 6 bits write to 6 bit input of sc-01-a; high 2 bits are ignored (but by adding a buffer chip could be made to control the inflection bits of the sc-01-a which are normally grounded on the tnt) */
108108   AM_RANGE(0x6000, 0x6fff) AM_ROM /* ROM in potted block */
109109ADDRESS_MAP_END
src/mess/drivers/pdp11.c
r14605r14606
8181   { }
8282
8383   required_device<cpu_device> m_maincpu;
84   required_device<device_t> m_terminal;
84   required_device<generic_terminal_device> m_terminal;
8585   DECLARE_READ16_MEMBER( term_r );
8686   DECLARE_READ16_MEMBER( term_tx_status_r );
8787   DECLARE_READ16_MEMBER( term_rx_status_r );
r14605r14606
9393
9494WRITE16_MEMBER(pdp11_state::term_w)
9595{
96   terminal_write(m_terminal, 0, data);
96   m_terminal->write(space, 0, data);
9797}
9898
9999READ16_MEMBER(pdp11_state::term_r)
src/mess/drivers/dms86.c
r14605r14606
3838   { }
3939
4040   required_device<cpu_device> m_maincpu;
41   required_device<device_t> m_terminal;
41   required_device<generic_terminal_device> m_terminal;
4242   DECLARE_READ16_MEMBER( dms86_82_r );
4343   DECLARE_READ16_MEMBER( dms86_84_r );
4444   DECLARE_READ16_MEMBER( dms86_86_r );
r14605r14606
8383   ADDRESS_MAP_UNMAP_HIGH
8484   ADDRESS_MAP_GLOBAL_MASK(0xff)
8585   AM_RANGE(0x82, 0x83) AM_READ(dms86_82_r)
86   AM_RANGE(0x84, 0x85) AM_READ(dms86_84_r) AM_DEVWRITE8_LEGACY(TERMINAL_TAG, terminal_write, 0xff)
86   AM_RANGE(0x84, 0x85) AM_READ(dms86_84_r) AM_DEVWRITE8(TERMINAL_TAG, generic_terminal_device, write, 0xff)
8787   AM_RANGE(0x86, 0x87) AM_READ(dms86_86_r)
8888   AM_RANGE(0x9A, 0x9B) AM_READ(dms86_9a_r)
89   AM_RANGE(0x9c, 0x9d) AM_DEVWRITE8_LEGACY(TERMINAL_TAG, terminal_write, 0xff)
89   AM_RANGE(0x9c, 0x9d) AM_DEVWRITE8(TERMINAL_TAG, generic_terminal_device, write, 0xff)
9090ADDRESS_MAP_END
9191
9292/* Input ports */
src/mess/drivers/okean240.c
r14605r14606
6262      : driver_device(mconfig, type, tag),
6363   m_term_data(0),
6464   m_j(0),
65   m_scroll(0)
65   m_scroll(0),
66   m_terminal(*this, TERMINAL_TAG)
6667   { }
6768
6869   DECLARE_READ8_MEMBER(okean240_kbd_status_r);
r14605r14606
8081   UINT8 m_scroll;
8182   virtual void machine_reset();
8283   virtual void video_start();
84
85   required_device<generic_terminal_device> m_terminal;
8386};
8487
8588// okean240 requires bit 4 to change
r14605r14606
227230   ADDRESS_MAP_GLOBAL_MASK(0xff)
228231   AM_RANGE(0x40, 0x42) AM_READWRITE(okean240_keyboard_r,okean240_keyboard_w)
229232   AM_RANGE(0x80, 0x80) AM_READ(okean240_kbd_status_r)
230   AM_RANGE(0xa0, 0xa0) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
233   AM_RANGE(0xa0, 0xa0) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
231234   AM_RANGE(0xa0, 0xa0) AM_READ(term_r)
232235   AM_RANGE(0xa1, 0xa1) AM_READ(term_status_r)
233236   AM_RANGE(0xc0, 0xc0) AM_WRITE(scroll_w)
src/mess/drivers/sgi_ip2.c
r14605r14606
5353{
5454public:
5555   sgi_ip2_state(const machine_config &mconfig, device_type type, const char *tag)
56      : driver_device(mconfig, type, tag) { }
56      : driver_device(mconfig, type, tag),
57        m_terminal(*this, TERMINAL_TAG) { }
5758
5859   UINT8 m_mbut;
5960   UINT16 m_mquad;
r14605r14606
6667   UINT32 *m_bss;
6768   UINT8 m_parctl;
6869   UINT8 m_mbp;
70
71   required_device<generic_terminal_device> m_terminal;
6972};
7073
7174
r14605r14606
414417{
415418   device_t *devconf = device->machine().device(TERMINAL_TAG);
416419   verboselog(device->machine(), 0, "duarta_tx: %02x\n", data);
417   terminal_write(devconf,0,data);
420   dynamic_cast<generic_terminal_device *>(devconf)->write(*memory_nonspecific_space(devconf->machine()), 0, data);
418421}
419422
420423static const duart68681_config sgi_ip2_duart68681a_config =
src/mess/drivers/ht68k.c
r14605r14606
4444   { }
4545
4646   required_device<cpu_device> m_maincpu;
47   required_device<device_t> m_terminal;
47   required_device<generic_terminal_device> m_terminal;
4848   required_device<device_t> m_duart;
4949   required_device<device_t> m_fdc;
5050   DECLARE_WRITE8_MEMBER(kbd_put);
r14605r14606
8787static void duart_tx(device_t *device, int channel, UINT8 data)
8888{
8989   ht68k_state *state = device->machine().driver_data<ht68k_state>();
90   terminal_write(state->m_terminal, 0, data);
90   state->m_terminal->write(*memory_nonspecific_space(device->machine()), 0, data);
9191}
9292
9393static UINT8 duart_input(device_t *device)
src/mess/drivers/microdec.c
r14605r14606
1818{
1919public:
2020   microdec_state(const machine_config &mconfig, device_type type, const char *tag)
21      : driver_device(mconfig, type, tag) { }
21      : driver_device(mconfig, type, tag),
22        m_terminal(*this, TERMINAL_TAG) { }
2223
2324   DECLARE_READ8_MEMBER(terminal_status_r);
2425   DECLARE_READ8_MEMBER(terminal_r);
2526   DECLARE_WRITE8_MEMBER(kbd_put);
2627   DECLARE_WRITE_LINE_MEMBER(microdec_irq_w);
2728   UINT8 m_term_data;
29
30   required_device<generic_terminal_device> m_terminal;
2831};
2932
3033
r14605r14606
5154   ADDRESS_MAP_GLOBAL_MASK(0xff)
5255   AM_RANGE(0xfa, 0xfa) AM_DEVREAD_LEGACY("upd765", upd765_status_r)
5356   AM_RANGE(0xfb, 0xfb) AM_DEVREADWRITE_LEGACY("upd765", upd765_data_r, upd765_data_w)
54   AM_RANGE(0xfc, 0xfc) AM_READ(terminal_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
57   AM_RANGE(0xfc, 0xfc) AM_READ(terminal_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
5558   AM_RANGE(0xfd, 0xfd) AM_READ(terminal_status_r)
5659ADDRESS_MAP_END
5760
src/mess/drivers/apollo.c
r14605r14606
11761176void apollo_terminal_write(UINT8 data) {
11771177   if (dsp_terminal != NULL) {
11781178      // output data to the terminal emulator
1179      terminal_write(dsp_terminal, 0,   data);
1179      dynamic_cast<generic_terminal_device *>(dsp_terminal)->write(*memory_nonspecific_space(dsp_terminal->machine()), 0, data);
11801180   }
11811181}
11821182
src/mess/drivers/pimps.c
r14605r14606
3131{
3232public:
3333   pimps_state(const machine_config &mconfig, device_type type, const char *tag)
34      : driver_device(mconfig, type, tag) { }
34      : driver_device(mconfig, type, tag),
35        m_terminal(*this, TERMINAL_TAG) { }
3536
3637   DECLARE_READ8_MEMBER(term_status_r);
3738   DECLARE_READ8_MEMBER(term_r);
3839   DECLARE_WRITE8_MEMBER(kbd_put);
3940   UINT8 m_term_data;
4041   virtual void machine_reset();
42
43   required_device<generic_terminal_device> m_terminal;
4144};
4245
4346
r14605r14606
6467
6568static ADDRESS_MAP_START(pimps_io, AS_IO, 8, pimps_state)
6669   ADDRESS_MAP_UNMAP_HIGH
67   AM_RANGE(0xf0, 0xf0) AM_READ(term_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
70   AM_RANGE(0xf0, 0xf0) AM_READ(term_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
6871   AM_RANGE(0xf1, 0xf1) AM_READ(term_status_r)
6972ADDRESS_MAP_END
7073
src/mess/drivers/vector4.c
r14605r14606
2222   { }
2323
2424   required_device<cpu_device> m_maincpu;
25   required_device<device_t> m_terminal;
25   required_device<generic_terminal_device> m_terminal;
2626   DECLARE_READ8_MEMBER(vector4_02_r);
2727   DECLARE_READ8_MEMBER(vector4_03_r);
2828   DECLARE_WRITE8_MEMBER(vector4_02_w);
r14605r14606
3535WRITE8_MEMBER( vector4_state::vector4_02_w )
3636{
3737   if (data < 0xff)
38      terminal_write(m_terminal, 0, data);
38      m_terminal->write(space, 0, data);
3939}
4040
4141READ8_MEMBER( vector4_state::vector4_03_r )
src/mess/drivers/68ksbc.c
r14605r14606
4242   { }
4343
4444   required_device<cpu_device> m_maincpu;
45   required_device<device_t> m_terminal;
45   required_device<generic_terminal_device> m_terminal;
4646   DECLARE_READ16_MEMBER( c68ksbc_status_r );
4747   DECLARE_READ16_MEMBER( c68ksbc_terminal_r );
4848   DECLARE_WRITE8_MEMBER( kbd_put );
r14605r14606
6969   AM_RANGE(0x000000, 0x002fff) AM_ROM
7070   AM_RANGE(0x003000, 0x5fffff) AM_RAM
7171   AM_RANGE(0x600000, 0x600001) AM_READ(c68ksbc_status_r)
72   AM_RANGE(0x600002, 0x600003) AM_READ(c68ksbc_terminal_r) AM_DEVWRITE8_LEGACY(TERMINAL_TAG, terminal_write, 0xff)
72   AM_RANGE(0x600002, 0x600003) AM_READ(c68ksbc_terminal_r) AM_DEVWRITE8(TERMINAL_TAG, generic_terminal_device, write, 0xff)
7373ADDRESS_MAP_END
7474
7575
src/mess/drivers/altair.c
r14605r14606
2828public:
2929   altair_state(const machine_config &mconfig, device_type type, const char *tag)
3030      : driver_device(mconfig, type, tag),
31   m_maincpu(*this, "maincpu")
31   m_maincpu(*this, "maincpu"),
32   m_terminal(*this, TERMINAL_TAG)
3233   { }
3334
3435   required_device<cpu_device> m_maincpu;
36   required_device<generic_terminal_device> m_terminal;
3537   DECLARE_READ8_MEMBER(sio_status_r);
3638   DECLARE_READ8_MEMBER(sio_data_r);
3739   DECLARE_READ8_MEMBER(sio_key_status_r);
r14605r14606
7678   ADDRESS_MAP_UNMAP_HIGH
7779   ADDRESS_MAP_GLOBAL_MASK(0xff)
7880   AM_RANGE( 0x00, 0x00 ) AM_READ(sio_key_status_r)
79   AM_RANGE( 0x01, 0x01 ) AM_MIRROR(0x10) AM_READ(sio_data_r) AM_DEVWRITE_LEGACY(TERMINAL_TAG, terminal_write)
81   AM_RANGE( 0x01, 0x01 ) AM_MIRROR(0x10) AM_READ(sio_data_r) AM_DEVWRITE(TERMINAL_TAG, generic_terminal_device, write)
8082   AM_RANGE( 0x10, 0x10 ) AM_READWRITE(sio_status_r,sio_command_w)
8183ADDRESS_MAP_END
8284
src/mess/drivers/sun1.c
r14605r14606
6565   { }
6666
6767   required_device<cpu_device> m_maincpu;
68   required_device<device_t> m_terminal;
68   required_device<generic_terminal_device> m_terminal;
6969   DECLARE_READ16_MEMBER(sun1_upd7201_r);
7070   DECLARE_WRITE16_MEMBER(sun1_upd7201_w);
7171   DECLARE_WRITE8_MEMBER(kbd_put);
r14605r14606
9595WRITE16_MEMBER( sun1_state::sun1_upd7201_w )
9696{
9797   if (offset == 0)
98      terminal_write(m_terminal, 0, data >> 8);
98      m_terminal->write(space, 0, data >> 8);
9999}
100100
101101static ADDRESS_MAP_START(sun1_mem, AS_PROGRAM, 16, sun1_state)
src/mess/drivers/mpz80.c
r14605r14606
698698   DEVCB_CPU_INPUT_LINE(Z80_TAG, Z80_INPUT_LINE_WAIT),
699699   DEVCB_NULL,
700700   DEVCB_NULL,
701   DEVCB_DEVICE_HANDLER(TERMINAL_TAG, terminal_write)
701   DEVCB_DEVICE_MEMBER(TERMINAL_TAG, generic_terminal_device, write)
702702};
703703
704704static SLOT_INTERFACE_START( mpz80_s100_cards )
src/mess/drivers/ccs2810.c
r14605r14606
4848   { }
4949
5050   required_device<cpu_device> m_maincpu;
51   required_device<device_t> m_terminal;
51   required_device<generic_terminal_device> m_terminal;
5252   DECLARE_READ8_MEMBER( ccs2810_20_r );
5353   DECLARE_READ8_MEMBER( ccs2810_25_r );
5454   DECLARE_READ8_MEMBER( ccs2810_26_r );
r14605r14606
7979
8080WRITE8_MEMBER( ccs2810_state::ccs2810_20_w )
8181{
82   terminal_write(m_terminal, 0, data & 0x7f);
82   m_terminal->write(space, 0, data & 0x7f);
8383}
8484
8585static ADDRESS_MAP_START(ccs2810_mem, AS_PROGRAM, 8, ccs2810_state)
src/mess/drivers/super6.c
r14605r14606
375375{
376376   0, 0, 0, 0,
377377
378   DEVCB_DEVICE_LINE(TERMINAL_TAG, terminal_serial_r),
379   DEVCB_DEVICE_LINE(TERMINAL_TAG, terminal_serial_w),
378   DEVCB_DEVICE_LINE_MEMBER(TERMINAL_TAG, serial_terminal_device, tx_r),
379   DEVCB_DEVICE_LINE_MEMBER(TERMINAL_TAG, serial_terminal_device, rx_w),
380380   DEVCB_NULL,
381381   DEVCB_NULL,
382382   DEVCB_NULL,
r14605r14606
578578   MCFG_WD2793_ADD(WD2793_TAG, fdc_intf)
579579   MCFG_COM8116_ADD(BR1945_TAG, XTAL_5_0688MHz, brg_intf)
580580   MCFG_LEGACY_FLOPPY_2_DRIVES_ADD(super6_floppy_interface)
581   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, terminal_intf)
581   MCFG_SERIAL_TERMINAL_ADD(TERMINAL_TAG, terminal_intf, 4800)
582582
583583   // internal ram
584584   MCFG_RAM_ADD(RAM_TAG)
src/mess/drivers/swtpc.c
r14605r14606
3939   { }
4040
4141   required_device<cpu_device> m_maincpu;
42   required_device<device_t> m_terminal;
42   required_device<generic_terminal_device> m_terminal;
4343   DECLARE_READ8_MEMBER(swtpc_status_r);
4444   DECLARE_READ8_MEMBER(swtpc_terminal_r);
4545   DECLARE_READ8_MEMBER(swtpc_tricky_r);
r14605r14606
7171WRITE8_MEMBER(swtpc_state::swtpc_terminal_w)
7272{
7373   if (data)
74      terminal_write(m_terminal, 0, data);
74      m_terminal->write(space, 0, data);
7575}
7676
7777

Previous 15994 Revisions Next


© 1998-2018 The MESS Team