Previous 15994 Revisions Next

r5156 Sunday 5th July, 2009 at 19:55:21 UTC by Curt Coder
[C80] System is now fully working.
[docs]messnew.txt
[src/mess/drivers]c80.c
[src/mess/includes]c80.h*

src/mess/includes/c80.h
r0r5156
1#ifndef __C80__
2#define __C80__
3
4#define SCREEN_TAG      "screen"
5#define Z80_TAG         "d2"
6#define Z80PIO1_TAG      "d11"
7#define Z80PIO2_TAG      "d12"
8#define CASSETTE_TAG   "cassette"
9
10typedef struct _c80_state c80_state;
11struct _c80_state
12{
13   /* keyboard state */
14   int keylatch;
15
16   /* display state */
17   int digit;
18   int pio1_a5;
19   int pio1_brdy;
20
21   /* devices */
22   const device_config *z80pio;
23};
24
25#endif
src/mess/drivers/c80.c
r5155r5156
11/***************************************************************************
22
3        C-80
3    C-80
44
5        12/05/2009 Skeleton driver.
5    12/05/2009 Skeleton driver.
66
77****************************************************************************/
88
99#include "driver.h"
10#include "includes/c80.h"
1011#include "cpu/z80/z80.h"
12#include "cpu/z80/z80daisy.h"
13#include "machine/z80pio.h"
14#include "devices/cassette.h"
15#include "vcs80.lh"
1116
12static ADDRESS_MAP_START(c80_mem, ADDRESS_SPACE_PROGRAM, 8)
17static const device_config *cassette_device_image(running_machine *machine)
18{
19   return devtag_get_device(machine, CASSETTE_TAG);
20}
21
22/* Memory Maps */
23
24static ADDRESS_MAP_START( c80_mem, ADDRESS_SPACE_PROGRAM, 8 )
1325   ADDRESS_MAP_UNMAP_HIGH
14   AM_RANGE( 0x0000, 0x03ff ) AM_ROM
15   AM_RANGE( 0x0400, 0xffff ) AM_RAM
26   AM_RANGE(0x0000, 0x07ff) AM_ROM
27   AM_RANGE(0x0800, 0x0bff) AM_MIRROR(0x400) AM_RAM
1628ADDRESS_MAP_END
1729
18static ADDRESS_MAP_START( c80_io , ADDRESS_SPACE_IO, 8)
19   ADDRESS_MAP_UNMAP_HIGH
30static ADDRESS_MAP_START( c80_io, ADDRESS_SPACE_IO, 8 )
31   ADDRESS_MAP_GLOBAL_MASK(0xff)
32   AM_RANGE(0x7c, 0x7f) AM_DEVREADWRITE(Z80PIO2_TAG, z80pio_r, z80pio_w)
33   AM_RANGE(0xbc, 0xbf) AM_DEVREADWRITE(Z80PIO1_TAG, z80pio_r, z80pio_w)
2034ADDRESS_MAP_END
2135
22/* Input ports */
36/* Input Ports */
37
38static INPUT_CHANGED( trigger_reset )
39{
40   cputag_set_input_line(field->port->machine, Z80_TAG, INPUT_LINE_RESET, newval ? CLEAR_LINE : ASSERT_LINE);
41}
42
43static INPUT_CHANGED( trigger_nmi )
44{
45   cputag_set_input_line(field->port->machine, Z80_TAG, INPUT_LINE_NMI, newval ? CLEAR_LINE : ASSERT_LINE);
46}
47
2348static INPUT_PORTS_START( c80 )
49   PORT_START("ROW0")
50   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("REG") PORT_CODE(KEYCODE_R)
51   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("GO") PORT_CODE(KEYCODE_G)
52   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
53   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
54   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7')
55   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4')
56   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')
57   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("FCN") PORT_CODE(KEYCODE_F1)
58
59   PORT_START("ROW1")
60   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("+") PORT_CODE(KEYCODE_UP)
61   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("-") PORT_CODE(KEYCODE_DOWN)
62   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
63   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
64   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8')
65   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5')
66   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2')
67   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
68
69   PORT_START("ROW2")
70   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_UNUSED )
71   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_UNUSED )
72   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
73   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
74   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9')
75   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6')
76   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3')
77   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("MEM") PORT_CODE(KEYCODE_M)
78
79   PORT_START("SPECIAL")
80   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("RES") PORT_CODE(KEYCODE_F10) PORT_CHANGED(trigger_reset, 0)
81   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("BRK") PORT_CODE(KEYCODE_ESC) PORT_CHANGED(trigger_nmi, 0)
2482INPUT_PORTS_END
2583
84/* Z80-PIO Interface */
2685
27static MACHINE_RESET(c80)
86static READ8_DEVICE_HANDLER( pio1_port_a_r )
2887{
88   /*
89     
90      bit      description
91
92      PA0      keyboard row 0 input
93      PA1      keyboard row 1 input
94      PA2      keyboard row 2 input
95      PA3     
96      PA4      _BSTB input
97      PA5      display enable output (0=enabled, 1=disabled)
98      PA6      tape output
99      PA7      tape input
100
101   */
102
103   c80_state *state = device->machine->driver_data;
104
105   UINT8 data = !state->pio1_brdy << 4 | 0x07;
106
107   int i;
108
109   for (i = 0; i < 8; i++)
110   {
111      if (!BIT(state->keylatch, i))
112      {
113         if (!BIT(input_port_read(device->machine, "ROW0"), i)) data &= ~0x01;
114         if (!BIT(input_port_read(device->machine, "ROW1"), i)) data &= ~0x02;
115         if (!BIT(input_port_read(device->machine, "ROW2"), i)) data &= ~0x04;
116      }
117   }
118
119   data |= (cassette_input(cassette_device_image(device->machine)) < +0.0) << 7;
120
121   return data;
29122}
30123
31static VIDEO_START( c80 )
124static WRITE8_DEVICE_HANDLER( pio1_port_a_w )
32125{
126   /*
127     
128      bit      description
129
130      PA0      keyboard row 0 input
131      PA1      keyboard row 1 input
132      PA2      keyboard row 2 input
133      PA3     
134      PA4      _BSTB input
135      PA5      display enable output (0=enabled, 1=disabled)
136      PA6      tape output
137      PA7      tape input
138
139   */
140   
141   c80_state *state = device->machine->driver_data;
142
143   state->pio1_a5 = BIT(data, 5);
144
145   if (!BIT(data, 5))
146   {
147      state->digit = 0;
148   }
149
150   cassette_output(cassette_device_image(device->machine), BIT(data, 6) ? +1.0 : -1.0);
33151}
34152
35static VIDEO_UPDATE( c80 )
153static WRITE8_DEVICE_HANDLER( pio1_port_b_w )
36154{
37    return 0;
155   /*
156     
157      bit      description
158
159      PB0      VQD30 segment A
160      PB1      VQD30 segment B
161      PB2      VQD30 segment C
162      PB3      VQD30 segment D
163      PB4      VQD30 segment E
164      PB5      VQD30 segment F
165      PB6      VQD30 segment G
166      PB7      VQD30 segment P
167
168   */
169
170   c80_state *state = device->machine->driver_data;
171
172   if (!state->pio1_a5)
173   {
174      output_set_digit_value(state->digit, data);
175   }
176
177   state->keylatch = data;
38178}
39179
180static WRITE_LINE_DEVICE_HANDLER( pio1_brdy_w )
181{
182   c80_state *driver_state = device->machine->driver_data;
183
184   driver_state->pio1_brdy = state;
185
186   if (state)
187   {
188      if (!driver_state->pio1_a5)
189      {
190         driver_state->digit++;
191      }
192
193      z80pio_bstb_w(device, 1);
194      z80pio_bstb_w(device, 0);
195   }
196}
197
198static const z80pio_interface pio1_intf =
199{
200   DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0),   /* callback when change interrupt status */
201   DEVCB_HANDLER(pio1_port_a_r),   /* port A read callback */
202   DEVCB_NULL,                  /* port B read callback */
203   DEVCB_HANDLER(pio1_port_a_w),   /* port A write callback */
204   DEVCB_HANDLER(pio1_port_b_w),   /* port B write callback */
205   DEVCB_NULL,                  /* portA ready active callback */
206   DEVCB_LINE(pio1_brdy_w)         /* portB ready active callback */
207};
208
209static const z80pio_interface pio2_intf =
210{
211   DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0),   /* callback when change interrupt status */
212   DEVCB_NULL,                  /* port A read callback */
213   DEVCB_NULL,                  /* port B read callback */
214   DEVCB_NULL,                  /* port A write callback */
215   DEVCB_NULL,                  /* port B write callback */
216   DEVCB_NULL,                  /* portA ready active callback */
217   DEVCB_NULL                  /* portB ready active callback */
218};
219
220/* Z80 Daisy Chain */
221
222static const z80_daisy_chain c80_daisy_chain[] =
223{
224   { Z80PIO1_TAG },
225   { Z80PIO2_TAG },
226   { NULL }
227};
228
229/* Machine Initialization */
230
231static MACHINE_START( c80 )
232{
233   c80_state *state = machine->driver_data;
234
235   /* register for state saving */
236   state_save_register_global(machine, state->keylatch);
237   state_save_register_global(machine, state->digit);
238   state_save_register_global(machine, state->pio1_a5);
239   state_save_register_global(machine, state->pio1_brdy);
240}
241
242/* Machine Driver */
243
244static const cassette_config c80_cassette_config =
245{
246   cassette_default_formats,
247   NULL,
248   CASSETTE_STOPPED | CASSETTE_MOTOR_ENABLED | CASSETTE_SPEAKER_MUTED
249};
250
40251static MACHINE_DRIVER_START( c80 )
41    /* basic machine hardware */
42    MDRV_CPU_ADD("maincpu",Z80, XTAL_4MHz)
252   MDRV_DRIVER_DATA(c80_state)
253
254   /* basic machine hardware */
255    MDRV_CPU_ADD(Z80_TAG, Z80, 2500000) /* U880D */
43256    MDRV_CPU_PROGRAM_MAP(c80_mem)
44257    MDRV_CPU_IO_MAP(c80_io)
258   MDRV_CPU_CONFIG(c80_daisy_chain)
45259
46    MDRV_MACHINE_RESET(c80)
260    MDRV_MACHINE_START(c80)
47261
48262    /* video hardware */
49    MDRV_SCREEN_ADD("screen", RASTER)
50    MDRV_SCREEN_REFRESH_RATE(50)
51    MDRV_SCREEN_VBLANK_TIME(ATTOSECONDS_IN_USEC(2500)) /* not accurate */
52    MDRV_SCREEN_FORMAT(BITMAP_FORMAT_INDEXED16)
53    MDRV_SCREEN_SIZE(640, 480)
54    MDRV_SCREEN_VISIBLE_AREA(0, 640-1, 0, 480-1)
55    MDRV_PALETTE_LENGTH(2)
56    MDRV_PALETTE_INIT(black_and_white)
263   MDRV_DEFAULT_LAYOUT( layout_vcs80 )
57264
58    MDRV_VIDEO_START(c80)
59    MDRV_VIDEO_UPDATE(c80)
265   /* devices */
266   MDRV_Z80PIO_ADD(Z80PIO1_TAG, pio1_intf)
267   MDRV_Z80PIO_ADD(Z80PIO2_TAG, pio2_intf)
268   MDRV_CASSETTE_ADD(CASSETTE_TAG, c80_cassette_config)
60269MACHINE_DRIVER_END
61270
62static SYSTEM_CONFIG_START(c80)
63SYSTEM_CONFIG_END
271/* ROMs */
64272
65/* ROM definition */
66273ROM_START( c80 )
67   ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF )
68   ROM_LOAD( "c80.rom", 0x0000, 0x0400, CRC(ad2b3296) SHA1(14f72cb73a4068b7a5d763cc0e254639c251ce2e))
274   ROM_REGION( 0x10000, Z80_TAG, 0 )
275   ROM_LOAD( "c80.d3", 0x0000, 0x0400, CRC(ad2b3296) SHA1(14f72cb73a4068b7a5d763cc0e254639c251ce2e) )
69276ROM_END
70277
71/* Driver */
278/* System Configuration */
72279
73/*    YEAR  NAME    PARENT  COMPAT   MACHINE    INPUT    INIT    CONFIG COMPANY   FULLNAME       FLAGS */
74COMP( ????, c80,  0,       0,    c80,    c80,     0,       c80,      "Joachim Czepa",   "C-80",      GAME_NOT_WORKING)
280static SYSTEM_CONFIG_START( c80 )
281   CONFIG_RAM_DEFAULT( 1 * 1024 )
282SYSTEM_CONFIG_END
75283
284/* System Drivers */
285
286/*    YEAR   NAME   PARENT   COMPAT   MACHINE   INPUT   INIT   CONFIG   COMPANY            FULLNAME   FLAGS */
287COMP( 1986, c80,   0,      0,      c80,   c80,   0,      c80,   "Joachim Czepa",   "C-80",      GAME_SUPPORTS_SAVE )
docs/messnew.txt
r5155r5156
1313- Bondwell 12 [Curt Coder, Tomas Karlsson]
1414- Bondwell 14 [Curt Coder, Tomas Karlsson]
1515- CCE MC-1000 [Curt Coder]
16- C-80 [Curt Coder]
1617- TI-83 [Xander]
1718- KONTIKI 100 [Curt Coder]
1819- TIKI 100 [Curt Coder]
r5155r5156
4142- [BW12] System is now fully working. Disk operations are very slow, so set
4243  maximum speed to unlimited while loading. [Curt Coder, Tomas Karlsson]
4344
45- [C80] System is now fully working. [Curt Coder]
46
4447- [EINSTEIN] Largely rewritten and lots of cleanups.  [Dirk Best]
4548
4649- [GENESIS] Save RAM emulation improved for several games (bugs #1691, #1696,

Previous 15994 Revisions Next


© 1998-2018 The MESS Team