Previous 15994 Revisions Next

r11025 Friday 1st April, 2011 at 05:17:22 UTC by Curt Coder
[POLY880] Modernized driver.
[src/mess/drivers]poly880.c
[src/mess/includes]poly880.h

src/mess/includes/poly880.h
r11024r11025
1#pragma once
2
13#ifndef __POLY880__
24#define __POLY880__
35
6#define ADDRESS_MAP_MODERN
7
8#include "emu.h"
9#include "cpu/z80/z80.h"
10#include "cpu/z80/z80daisy.h"
11#include "imagedev/cassette.h"
12#include "machine/z80pio.h"
13#include "machine/z80ctc.h"
14#include "machine/ram.h"
15
416#define SCREEN_TAG      "screen"
517#define Z80_TAG         "i1"
618#define Z80CTC_TAG      "i4"
r11024r11025
1224{
1325public:
1426   poly880_state(running_machine &machine, const driver_device_config_base &config)
15      : driver_device(machine, config) { }
27      : driver_device(machine, config),
28        m_maincpu(*this, Z80_TAG),
29        m_cassette(*this, CASSETTE_TAG)
30   { }
1631
32   required_device<cpu_device> m_maincpu;
33   required_device<device_t> m_cassette;
34
35   virtual void machine_start();
36
37   DECLARE_WRITE8_MEMBER( cldig_w );
38   DECLARE_WRITE_LINE_MEMBER( ctc_z0_w );
39   DECLARE_WRITE_LINE_MEMBER( ctc_z1_w );
40   DECLARE_WRITE8_MEMBER( pio1_pa_w );
41   DECLARE_READ8_MEMBER( pio1_pb_r );
42   DECLARE_WRITE8_MEMBER( pio1_pb_w );
43   
44   void update_display();
45   
1746   /* display state */
18   UINT8 digit;
19   UINT8 segment;
47   UINT8 m_digit;
48   UINT8 m_segment;
2049
2150   /* devices */
2251   device_t *cassette;
src/mess/drivers/poly880.c
r11024r11025
88
99****************************************************************************/
1010
11#include "emu.h"
1211#include "includes/poly880.h"
13#include "cpu/z80/z80.h"
14#include "cpu/z80/z80daisy.h"
15#include "imagedev/cassette.h"
16#include "machine/z80pio.h"
17#include "machine/z80ctc.h"
18#include "machine/ram.h"
1912#include "poly880.lh"
2013
2114/*
r11024r11025
3225
3326/* Read/Write Handlers */
3427
35static void update_display(poly880_state *state)
28void poly880_state::update_display()
3629{
3730   int i;
3831
3932   for (i = 0; i < 8; i++)
4033   {
41      if (BIT(state->digit, i)) output_set_digit_value(7 - i, state->segment);
34      if (BIT(m_digit, i)) output_set_digit_value(7 - i, m_segment);
4235   }
4336}
4437
45static WRITE8_HANDLER( cldig_w )
38WRITE8_MEMBER( poly880_state::cldig_w )
4639{
47   poly880_state *state = space->machine().driver_data<poly880_state>();
40   m_digit = data;
4841
49   state->digit = data;
50
51   update_display(state);
42   update_display();
5243}
5344
5445/* Memory Maps */
5546
56static ADDRESS_MAP_START( poly880_mem, AS_PROGRAM, 8 )
47static ADDRESS_MAP_START( poly880_mem, AS_PROGRAM, 8, poly880_state )
5748   AM_RANGE(0x0000, 0x03ff) AM_MIRROR(0x0c00) AM_ROM
5849   AM_RANGE(0x1000, 0x13ff) AM_MIRROR(0x0c00) AM_ROM
5950   AM_RANGE(0x2000, 0x23ff) AM_MIRROR(0x0c00) AM_ROM
r11024r11025
6253   AM_RANGE(0x8000, 0xffff) AM_RAMBANK("bank1")
6354ADDRESS_MAP_END
6455
65static ADDRESS_MAP_START( poly880_io, AS_IO, 8)
56static ADDRESS_MAP_START( poly880_io, AS_IO, 8, poly880_state )
6657   ADDRESS_MAP_GLOBAL_MASK(0xaf)
67   AM_RANGE(0x80, 0x83) AM_DEVREADWRITE(Z80PIO1_TAG, z80pio_ba_cd_r, z80pio_ba_cd_w)
68   AM_RANGE(0x84, 0x87) AM_DEVREADWRITE(Z80PIO2_TAG, z80pio_ba_cd_r, z80pio_ba_cd_w)
69   AM_RANGE(0x88, 0x8b) AM_DEVREADWRITE(Z80CTC_TAG, z80ctc_r, z80ctc_w)
58   AM_RANGE(0x80, 0x83) AM_DEVREADWRITE_LEGACY(Z80PIO1_TAG, z80pio_ba_cd_r, z80pio_ba_cd_w)
59   AM_RANGE(0x84, 0x87) AM_DEVREADWRITE_LEGACY(Z80PIO2_TAG, z80pio_ba_cd_r, z80pio_ba_cd_w)
60   AM_RANGE(0x88, 0x8b) AM_DEVREADWRITE_LEGACY(Z80CTC_TAG, z80ctc_r, z80ctc_w)
7061   AM_RANGE(0xa0, 0xa0) AM_MIRROR(0x0f) AM_WRITE(cldig_w)
7162ADDRESS_MAP_END
7263
r11024r11025
122113
123114/* Z80-CTC Interface */
124115
125static WRITE_LINE_DEVICE_HANDLER( ctc_z0_w )
116WRITE_LINE_MEMBER( poly880_state::ctc_z0_w )
126117{
127118   // SEND
128119}
129120
130static WRITE_LINE_DEVICE_HANDLER( ctc_z1_w )
121WRITE_LINE_MEMBER( poly880_state::ctc_z1_w )
131122{
132123}
133124
134static WRITE_LINE_DEVICE_HANDLER( ctc_z2_w )
135{
136   z80ctc_trg3_w(device, state);
137}
138
139125static Z80CTC_INTERFACE( ctc_intf )
140126{
141127   0,                 /* timer disables */
142128   DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0),   /* interrupt handler */
143   DEVCB_LINE(ctc_z0_w),   /* ZC/TO0 callback */
144   DEVCB_LINE(ctc_z1_w),   /* ZC/TO1 callback */
145   DEVCB_LINE(ctc_z2_w)    /* ZC/TO2 callback */
129   DEVCB_DRIVER_LINE_MEMBER(poly880_state, ctc_z0_w),   /* ZC/TO0 callback */
130   DEVCB_DRIVER_LINE_MEMBER(poly880_state, ctc_z1_w),   /* ZC/TO1 callback */
131   DEVCB_LINE(z80ctc_trg3_w)    /* ZC/TO2 callback */
146132};
147133
148134/* Z80-PIO Interface */
149135
150static WRITE8_DEVICE_HANDLER( pio1_port_a_w )
136WRITE8_MEMBER( poly880_state::pio1_pa_w )
151137{
152138   /*
153139
r11024r11025
164150
165151    */
166152
167   poly880_state *state = device->machine().driver_data<poly880_state>();
153   m_segment = BITSWAP8(data, 3, 4, 6, 0, 1, 2, 7, 5);
168154
169   state->segment = BITSWAP8(data, 3, 4, 6, 0, 1, 2, 7, 5);
170
171   update_display(state);
155   update_display();
172156}
173157
174static READ8_DEVICE_HANDLER( pio1_port_b_r )
158READ8_MEMBER( poly880_state::pio1_pb_r )
175159{
176160   /*
177161
r11024r11025
188172
189173    */
190174
191   poly880_state *state = device->machine().driver_data<poly880_state>();
192
193   UINT8 data = 0xf0 | ((cassette_input(state->cassette) < +0.0) << 1);
175   UINT8 data = 0xf0 | ((cassette_input(m_cassette) < +0.0) << 1);
194176   int i;
195177
196178   for (i = 0; i < 8; i++)
197179   {
198      if (BIT(state->digit, i))
180      if (BIT(m_digit, i))
199181      {
200         if (!BIT(input_port_read(device->machine(), "KI1"), i)) data &= ~0x10;
201         if (!BIT(input_port_read(device->machine(), "KI2"), i)) data &= ~0x20;
202         if (!BIT(input_port_read(device->machine(), "KI3"), i)) data &= ~0x80;
182         if (!BIT(input_port_read(m_machine, "KI1"), i)) data &= ~0x10;
183         if (!BIT(input_port_read(m_machine, "KI2"), i)) data &= ~0x20;
184         if (!BIT(input_port_read(m_machine, "KI3"), i)) data &= ~0x80;
203185      }
204186   }
205187
206188   return data;
207189}
208190
209static WRITE8_DEVICE_HANDLER( pio1_port_b_w )
191WRITE8_MEMBER( poly880_state::pio1_pb_w )
210192{
211193   /*
212194
r11024r11025
223205
224206    */
225207
226   poly880_state *state = device->machine().driver_data<poly880_state>();
227
228208   /* tape output */
229   cassette_output(state->cassette, BIT(data, 2) ? +1.0 : -1.0);
209   cassette_output(m_cassette, BIT(data, 2) ? +1.0 : -1.0);
230210}
231211
232212static Z80PIO_INTERFACE( pio1_intf )
233213{
234214   DEVCB_CPU_INPUT_LINE(Z80_TAG, INPUT_LINE_IRQ0),   /* callback when change interrupt status */
235215   DEVCB_NULL,                  /* port A read callback */
236   DEVCB_HANDLER(pio1_port_a_w),   /* port A write callback */
216   DEVCB_DRIVER_MEMBER(poly880_state, pio1_pa_w),   /* port A write callback */
237217   DEVCB_NULL,                  /* portA ready active callback */
238   DEVCB_HANDLER(pio1_port_b_r),   /* port B read callback */
239   DEVCB_HANDLER(pio1_port_b_w),   /* port B write callback */
218   DEVCB_DRIVER_MEMBER(poly880_state, pio1_pb_r),   /* port B read callback */
219   DEVCB_DRIVER_MEMBER(poly880_state, pio1_pb_w),   /* port B write callback */
240220   DEVCB_NULL                  /* portB ready active callback */
241221};
242222
r11024r11025
263243
264244/* Machine Initialization */
265245
266static MACHINE_START( poly880 )
246void poly880_state::machine_start()
267247{
268   poly880_state *state = machine.driver_data<poly880_state>();
269
270   /* find devices */
271   state->cassette = machine.device(CASSETTE_TAG);
272
273248   /* register for state saving */
274   state->save_item(NAME(state->digit));
275   state->save_item(NAME(state->segment));
249   save_item(NAME(m_digit));
250   save_item(NAME(m_segment));
276251}
277252
278253/* Machine Driver */
r11024r11025
286261};
287262
288263static MACHINE_CONFIG_START( poly880, poly880_state )
289
290264   /* basic machine hardware */
291265    MCFG_CPU_ADD(Z80_TAG, Z80, XTAL_7_3728MHz/8)
292266    MCFG_CPU_PROGRAM_MAP(poly880_mem)
293267    MCFG_CPU_IO_MAP(poly880_io)
294268
295    MCFG_MACHINE_START(poly880)
296
297269   /* video hardware */
298270   MCFG_DEFAULT_LAYOUT( layout_poly880 )
299271

Previous 15994 Revisions Next


© 1998-2018 The MESS Team