Previous 15994 Revisions Next

r4910 Monday 1st June, 2009 at 18:51:09 UTC by Curt Coder
[XEROX820] Added COM8116 baud generator skeleton.
[src/mess]mess.mak
[src/mess/drivers]xerox820.c
[src/mess/includes]xerox820.h
[src/mess/machine]com8116.c* com8116.h*

src/mess/includes/xerox820.h
r4909r4910
3636   /* devices */
3737   const device_config *kbpio;
3838   const device_config *z80ctc;
39   const device_config *com8116;
4039   const device_config *wd1771;
4140};
4241
src/mess/machine/com8116.c
r0r4910
1/**********************************************************************
2
3   COM8116 - Dual Baud Rate Generator (Programmable Divider) emulation
4
5   Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8*********************************************************************/
9
10/*
11
12   TODO:
13
14   - everything
15
16*/
17
18#include "driver.h"
19#include "com8116.h"
20
21/***************************************************************************
22    PARAMETERS
23***************************************************************************/
24
25#define LOG 0
26
27/***************************************************************************
28    TYPE DEFINITIONS
29***************************************************************************/
30
31typedef struct _com8116_t com8116_t;
32struct _com8116_t
33{
34   devcb_resolved_write_line   out_fx4_func;
35   devcb_resolved_write_line   out_fr_func;
36   devcb_resolved_write_line   out_ft_func;
37
38   /* timers */
39   emu_timer *fx4_timer;
40   emu_timer *fr_timer;
41   emu_timer *ft_timer;
42};
43
44/***************************************************************************
45    INLINE FUNCTIONS
46***************************************************************************/
47
48INLINE com8116_t *get_safe_token(const device_config *device)
49{
50   assert(device != NULL);
51   assert(device->token != NULL);
52   assert(device->type == COM8116);
53   return (com8116_t *)device->token;
54}
55
56INLINE const com8116_interface *get_interface(const device_config *device)
57{
58   assert(device != NULL);
59   assert((device->type == COM8116));
60   return (const com8116_interface *) device->static_config;
61}
62
63/***************************************************************************
64    IMPLEMENTATION
65***************************************************************************/
66
67/*-------------------------------------------------
68    com8116_str_w - receiver strobe write
69-------------------------------------------------*/
70
71WRITE8_DEVICE_HANDLER( com8116_str_w )
72{
73//   com8116_t *com8116 = get_safe_token(device);
74
75   if (LOG) logerror("COM8116 '%s' Receiver Divider %01x\n", device->tag, data & 0x0f);
76
77//   timer_adjust_periodic(com8116->fr_timer, attotime_zero, 0, ATTOTIME_IN_HZ(1));
78}
79
80/*-------------------------------------------------
81    com8116_stt_w - transmitter strobe write
82-------------------------------------------------*/
83
84WRITE8_DEVICE_HANDLER( com8116_stt_w )
85{
86//   com8116_t *com8116 = get_safe_token(device);
87
88   if (LOG) logerror("COM8116 '%s' Transmitter Divider %01x\n", device->tag, data & 0x0f);
89
90//   timer_adjust_periodic(com8116->ft_timer, attotime_zero, 0, ATTOTIME_IN_HZ(1));
91}
92
93/*-------------------------------------------------
94    TIMER_CALLBACK( fx4_tick )
95-------------------------------------------------*/
96
97static TIMER_CALLBACK( fx4_tick )
98{
99   const device_config *device = ptr;
100   com8116_t *com8116 = get_safe_token(device);
101
102   devcb_call_write_line(&com8116->out_fx4_func, 1);
103}
104
105/*-------------------------------------------------
106    TIMER_CALLBACK( fr_tick )
107-------------------------------------------------*/
108
109static TIMER_CALLBACK( fr_tick )
110{
111   const device_config *device = ptr;
112   com8116_t *com8116 = get_safe_token(device);
113
114   devcb_call_write_line(&com8116->out_fr_func, 1);
115}
116
117/*-------------------------------------------------
118    TIMER_CALLBACK( ft_tick )
119-------------------------------------------------*/
120
121static TIMER_CALLBACK( ft_tick )
122{
123   const device_config *device = ptr;
124   com8116_t *com8116 = get_safe_token(device);
125
126   devcb_call_write_line(&com8116->out_ft_func, 1);
127}
128
129/*-------------------------------------------------
130    DEVICE_START( com8116 )
131-------------------------------------------------*/
132
133static DEVICE_START( com8116 )
134{
135   com8116_t *com8116 = get_safe_token(device);
136   const com8116_interface *intf = get_interface(device);
137
138   /* resolve callbacks */
139   devcb_resolve_write_line(&com8116->out_fx4_func, &intf->out_fx4_func, device);
140   devcb_resolve_write_line(&com8116->out_fr_func, &intf->out_fr_func, device);
141   devcb_resolve_write_line(&com8116->out_ft_func, &intf->out_ft_func, device);
142
143   /* create the timers */
144   if (com8116->out_fx4_func.target)
145   {
146      com8116->fx4_timer = timer_alloc(device->machine, fx4_tick, (void *)device);
147      timer_adjust_periodic(com8116->fx4_timer, attotime_zero, 0, ATTOTIME_IN_HZ(device->clock / 4));
148   }
149
150   com8116->fr_timer = timer_alloc(device->machine, fr_tick, (void *)device);
151   com8116->ft_timer = timer_alloc(device->machine, ft_tick, (void *)device);
152
153   /* register for state saving */
154//    state_save_register_global(device->machine, com8116->);
155}
156
157/*-------------------------------------------------
158    DEVICE_GET_INFO( com8116 )
159-------------------------------------------------*/
160
161DEVICE_GET_INFO( com8116 )
162{
163   switch (state)
164   {
165      /* --- the following bits of info are returned as 64-bit signed integers --- */
166      case DEVINFO_INT_TOKEN_BYTES:               info->i = sizeof(com8116_t);            break;
167      case DEVINFO_INT_INLINE_CONFIG_BYTES:         info->i = 0;                        break;
168      case DEVINFO_INT_CLASS:                     info->i = DEVICE_CLASS_PERIPHERAL;         break;
169
170      /* --- the following bits of info are returned as pointers to data or functions --- */
171      case DEVINFO_FCT_START:                     info->start = DEVICE_START_NAME(com8116);   break;
172      case DEVINFO_FCT_STOP:                     /* Nothing */                        break;
173      case DEVINFO_FCT_RESET:                     /* Nothing */                        break;
174
175      /* --- the following bits of info are returned as NULL-terminated strings --- */
176      case DEVINFO_STR_NAME:                     strcpy(info->s, "COM8116");               break;
177      case DEVINFO_STR_FAMILY:                  strcpy(info->s, "COM8116");               break;
178      case DEVINFO_STR_VERSION:                  strcpy(info->s, "1.0");                  break;
179      case DEVINFO_STR_SOURCE_FILE:               strcpy(info->s, __FILE__);               break;
180      case DEVINFO_STR_CREDITS:                  /* Nothing */                        break;
181   }
182}
src/mess/machine/com8116.h
r0r4910
1/**********************************************************************
2
3   COM8116 - Dual Baud Rate Generator (Programmable Divider) emulation
4
5   Copyright MESS Team.
6    Visit http://mamedev.org for licensing and usage restrictions.
7
8**********************************************************************
9                     _____   _____
10          XTAL/EXT1    1 |*    \_/     | 18  XTAL/EXT2
11               +5V    2 |          | 17  fT
12               fR    3 |          | 16  Ta
13                Ra    4 |   COM8116    | 15  Tb
14               Rb    5 |   COM8116T    | 14  Tc
15               Rc    6 |   COM8136    | 13  Td
16               Rd    7 |   COM8136T    | 12  STT
17               STR    8 |          | 11  GND
18                NC   9 |_____________| 10  fX/4
19
20**********************************************************************/
21
22#ifndef __COM8116__
23#define __COM8116__
24
25#include "devcb.h"
26
27/***************************************************************************
28    MACROS / CONSTANTS
29***************************************************************************/
30
31#define COM8116 DEVICE_GET_INFO_NAME(com8116)
32
33#define MDRV_COM8116_ADD(_tag, _clock, _config) \
34   MDRV_DEVICE_ADD(_tag, COM8116, _clock) \
35   MDRV_DEVICE_CONFIG(_config)
36
37#define MDRV_COM8116_REMOVE(_tag) \
38   MDRV_DEVICE_REMOVE(_tag)
39
40#define COM8116_INTERFACE(name) \
41   const com8116_interface (name)=
42
43/***************************************************************************
44    TYPE DEFINITIONS
45***************************************************************************/
46
47typedef struct _com8116_interface com8116_interface;
48struct _com8116_interface
49{
50   /* this gets called for every change of the fX/4 pin (pin 10) */
51   devcb_write_line      out_fx4_func;
52
53   /* this gets called for every change of the fR pin (pin 3) */
54   devcb_write_line      out_fr_func;
55
56   /* this gets called for every change of the fT pin (pin 17) */
57   devcb_write_line      out_ft_func;
58
59   /* receiver divisor ROM */
60   UINT32 fr_dividers[16];
61
62   /* transmitter divisor ROM */
63   UINT32 ft_dividers[16];
64};
65
66/***************************************************************************
67    PROTOTYPES
68***************************************************************************/
69
70/* device interface */
71DEVICE_GET_INFO( com8116 );
72
73/* receiver strobe */
74WRITE8_DEVICE_HANDLER( com8116_str_w );
75
76/* transmitter strobe */
77WRITE8_DEVICE_HANDLER( com8116_stt_w );
78
79#endif /* __COM8116__ */
src/mess/mess.mak
r4909r4910
13751375   
13761376$(MESSOBJ)/xerox.a: \
13771377   $(MESS_DRIVERS)/xerox820.o \
1378   $(MESS_MACHINE)/com8116.o
13781379
13791380$(MESSOBJ)/skeleton.a: \
13801381   $(MESS_DRIVERS)/a6809.o \
src/mess/drivers/xerox820.c
r4909r4910
1212   TODO:
1313
1414   - add xtals.h
15   - baud A/B (COM8116 chip)
15   - COM8116
1616   - type in Monitor v1.0 from manual
1717   - proper keyboard emulation (MCU?)
1818
r4909r4910
3030#include "machine/z80ctc.h"
3131#include "machine/z80sio.h"
3232#include "machine/wd17xx.h"
33#include "machine/com8116.h"
3334#include "devices/basicdsk.h"
3435
3536INLINE const device_config *get_floppy_image(running_machine *machine, int drive)
r4909r4910
170171      z80pio_d_w(device, channel, data);
171172}
172173
173static WRITE8_HANDLER( bauda_w )
174{
175//   xerox820_state *state = space->machine->driver_data;
176
177//   com8116_str_w(state->com8116, data & 0x0f);
178}
179
180static WRITE8_HANDLER( baudb_w )
181{
182//   xerox820_state *state = space->machine->driver_data;
183
184//   com8116_stt_w(state->com8116, data & 0x0f);
185}
186
187174static WRITE8_HANDLER( scroll_w )
188175{
189176   xerox820_state *state = space->machine->driver_data;
r4909r4910
203190
204191static ADDRESS_MAP_START( xerox820_io, ADDRESS_SPACE_IO, 8 )
205192   ADDRESS_MAP_GLOBAL_MASK(0xff)
206   AM_RANGE(0x00, 0x00) AM_MIRROR(0x03) AM_WRITE(bauda_w)
193   AM_RANGE(0x00, 0x00) AM_MIRROR(0x03) AM_DEVWRITE(COM8116_TAG, com8116_str_w)
207194   AM_RANGE(0x04, 0x04) AM_MIRROR(0x02) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_d_r, z80sio_d_w)
208195   AM_RANGE(0x05, 0x05) AM_MIRROR(0x02) AM_DEVREADWRITE(Z80SIO_TAG, z80sio_c_r, z80sio_c_w)
209196   AM_RANGE(0x08, 0x0b) AM_DEVREADWRITE(Z80GPPIO_TAG, z80pio_alt_r, z80pio_alt_w)
210   AM_RANGE(0x0c, 0x0c) AM_MIRROR(0x03) AM_WRITE(baudb_w)
197   AM_RANGE(0x0c, 0x0c) AM_MIRROR(0x03) AM_DEVWRITE(COM8116_TAG, com8116_stt_w)
211198   AM_RANGE(0x10, 0x13) AM_DEVREADWRITE(WD1771_TAG, wd17xx_r, wd17xx_w)
212199   AM_RANGE(0x14, 0x14) AM_MIRROR(0x03) AM_WRITE(scroll_w)
213200   AM_RANGE(0x18, 0x1b) AM_DEVREADWRITE(Z80CTC_TAG, z80ctc_r, z80ctc_w)
r4909r4910
506493   case WD17XX_DRQ_SET: driver_state->fdc_drq = 1; break;
507494   }
508495
509   logerror("halt %u FDC IRQ %u DRQ %u\n", halt, driver_state->fdc_irq, driver_state->fdc_drq);
510
511496   if (halt && (driver_state->fdc_irq | driver_state->fdc_drq))
512497   {
513498      cputag_set_input_line(device->machine, Z80_TAG, INPUT_LINE_NMI, ASSERT_LINE);
r4909r4910
524509   NULL
525510};
526511
512/* COM8116 Interface */
513
514static COM8116_INTERFACE( com8116_intf )
515{
516   DEVCB_NULL,      /* fX/4 output */
517   DEVCB_NULL,      /* fR output */
518   DEVCB_NULL,      /* fT output */
519   {},            /* receiver ROM */
520   {}            /* transmitter ROM */
521};
522
527523/* Video */
528524
529525static VIDEO_START( xerox820 )
r4909r4910
654650   MDRV_Z80PIO_ADD(Z80GPPIO_TAG, gppio_intf)
655651   MDRV_Z80CTC_ADD(Z80CTC_TAG, XTAL_20MHz/8, ctc_intf)
656652   MDRV_WD1773_ADD(WD1771_TAG, wd1771_intf) // workaround wd17xx.c ready state bug, should be MDRV_WD177X_ADD
657//   MDRV_COM8116_ADD(COM8116_TAG, 5068800, com8116_intf)
653   MDRV_COM8116_ADD(COM8116_TAG, 5068800, com8116_intf)
658654MACHINE_DRIVER_END
659655
660656static MACHINE_DRIVER_START( xerox820ii )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team