Previous 15994 Revisions Next

r9897 Monday 3rd January, 2011 at 01:15:01 UTC by Robbbert
[D6800] Attempted conversion to MODERN
[src/mess/drivers]d6800.c

src/mess/drivers/d6800.c
r9896r9897
3030   - Keyboard (should work but it doesn't)
3131*/
3232
33#define ADDRESS_MAP_MODERN
34
3335#include "emu.h"
3436#include "cpu/m6800/m6800.h"
3537#include "sound/beep.h"
r9896r9897
3739#include "sound/wave.h"
3840#include "sound/speaker.h"
3941#include "machine/6821pia.h"
40#include "machine/rescap.h"
4142
4243
4344class d6800_state : public driver_device
4445{
4546public:
4647   d6800_state(running_machine &machine, const driver_device_config_base &config)
47      : driver_device(machine, config) { }
48      : driver_device(machine, config),
49        m_maincpu(*this, "maincpu"),
50        m_cass(*this, "cassette"),
51        m_pia(*this, "pia"),
52        m_speaker(*this, "speaker")
53   { }
4854
49   UINT8 dummy;
50   UINT8 keylatch;
51   UINT8 keydown;
52   UINT8 screen;
53   UINT8 rtc;
54   device_t *cassette;
55   device_t *speaker;
55   required_device<cpu_device> m_maincpu;
56   required_device<device_t> m_cass;
57   required_device<device_t> m_pia;
58   required_device<device_t> m_speaker;
59   DECLARE_READ8_MEMBER( d6800_cassette_r );
60   DECLARE_WRITE8_MEMBER( d6800_cassette_w );
61   DECLARE_READ8_MEMBER( d6800_keyboard_r );
62   DECLARE_WRITE8_MEMBER( d6800_keyboard_w );
63   DECLARE_READ_LINE_MEMBER( d6800_fn_key_r );
64   DECLARE_READ_LINE_MEMBER( d6800_keydown_r );
65   DECLARE_READ_LINE_MEMBER( d6800_rtc_pulse );
66   DECLARE_WRITE_LINE_MEMBER( d6800_screen_w );
67   UINT8 m_keylatch;
68   UINT8 m_keydown;
69   UINT8 m_screen;
70   UINT8 m_rtc;
71   UINT8 *m_videoram;
5672};
5773
5874
5975/* Memory Maps */
6076
61static ADDRESS_MAP_START( d6800_map, ADDRESS_SPACE_PROGRAM, 8 )
62   AM_RANGE(0x0000, 0x07ff) AM_RAM AM_REGION("maincpu", 0x0000)
63   AM_RANGE(0x8010, 0x8013) AM_DEVREADWRITE("pia", pia6821_r, pia6821_w)
77static ADDRESS_MAP_START( d6800_map, ADDRESS_SPACE_PROGRAM, 8, d6800_state )
78   AM_RANGE(0x0000, 0x00ff) AM_RAM
79   AM_RANGE(0x0100, 0x01ff) AM_RAM AM_BASE( m_videoram )
80   AM_RANGE(0x0200, 0x07ff) AM_RAM
81   AM_RANGE(0x8010, 0x8013) AM_DEVREADWRITE_LEGACY("pia", pia6821_r, pia6821_w)
6482   AM_RANGE(0xc000, 0xc3ff) AM_MIRROR(0x3c00) AM_ROM
6583ADDRESS_MAP_END
6684
r9896r9897
105123{
106124   d6800_state *state = screen->machine->driver_data<d6800_state>();
107125   UINT8 x,y,gfx=0;
108   UINT8 *RAM = screen->machine->region("maincpu")->base();
109126
110127   for (y = 0; y < 32; y++)
111128   {
r9896r9897
113130
114131      for (x = 0; x < 8; x++)
115132      {
116         if (state->screen)
117            gfx = RAM[0x100 | x | (y<<3)];
133         if (state->m_screen)
134            gfx = state->m_videoram[ x | (y<<3)];
118135
119136         *p++ = ( gfx & 0x80 ) ? 1 : 0;
120137         *p++ = ( gfx & 0x40 ) ? 1 : 0;
r9896r9897
134151static INTERRUPT_GEN( d6800_interrupt )
135152{
136153   d6800_state *state = device->machine->driver_data<d6800_state>();
137   state->rtc = 1;
154   state->m_rtc = 1;
138155}
139156
140static READ_LINE_DEVICE_HANDLER( d6800_rtc_pulse )
157READ_LINE_MEMBER( d6800_state::d6800_rtc_pulse )
141158{
142   d6800_state *state = device->machine->driver_data<d6800_state>();
143   UINT8 res = state->rtc;
144   state->rtc = 0;
159   UINT8 res = m_rtc;
160   m_rtc = 0;
145161   return res;
146162}
147163
148static READ_LINE_DEVICE_HANDLER( d6800_keydown_r )
164READ_LINE_MEMBER( d6800_state::d6800_keydown_r )
149165{
150   d6800_state *state = device->machine->driver_data<d6800_state>();
151   return state->keydown;
166   return m_keydown;
152167}
153168
154static READ_LINE_DEVICE_HANDLER( d6800_fn_key_r )
169READ_LINE_MEMBER( d6800_state::d6800_fn_key_r )
155170{
156   return input_port_read(device->machine, "SPECIAL");
171   return input_port_read(machine, "SPECIAL");
157172}
158173
159static WRITE_LINE_DEVICE_HANDLER( d6800_screen_w )
174WRITE_LINE_MEMBER( d6800_state::d6800_screen_w )
160175{
161   d6800_state *drvstate = device->machine->driver_data<d6800_state>();
162   drvstate->screen = state;
176   m_screen = state;
163177}
164178
165static READ8_DEVICE_HANDLER( d6800_cassette_r )
179READ8_MEMBER( d6800_state::d6800_cassette_r )
166180{
167181   /*
168182   Cassette circuit consists of a 741 op-amp, a 74121 oneshot, and a 74LS74.
r9896r9897
174188   return 0xff;
175189}
176190
177static WRITE8_DEVICE_HANDLER( d6800_cassette_w )
191WRITE8_MEMBER( d6800_state::d6800_cassette_w )
178192{
179   d6800_state *state = device->machine->driver_data<d6800_state>();
180193   /*
181194   Cassette circuit consists of a 566 and a transistor. The 556 runs at 2400
182195   or 1200 Hz depending on the state of the transistor. This is controlled by
183196   bit 0 of the PIA. Bit 6 drives the speaker.
184197   */
185198
186   speaker_level_w(state->speaker, (data & 0x40) ? 0 : 1);
199   speaker_level_w(m_speaker, (data & 0x40) ? 0 : 1);
187200}
188201
189static READ8_DEVICE_HANDLER( d6800_keyboard_r )
202READ8_MEMBER( d6800_state::d6800_keyboard_r )
190203{
191   d6800_state *state = device->machine->driver_data<d6800_state>();
192204   UINT8 data = 0xff;
193205
194   if (!BIT(state->keylatch, 4)) data &= input_port_read(device->machine, "LINE0");
195   if (!BIT(state->keylatch, 5)) data &= input_port_read(device->machine, "LINE1");
196   if (!BIT(state->keylatch, 6)) data &= input_port_read(device->machine, "LINE2");
197   if (!BIT(state->keylatch, 7)) data &= input_port_read(device->machine, "LINE3");
206   if (!BIT(m_keylatch, 4)) data &= input_port_read(machine, "LINE0");
207   if (!BIT(m_keylatch, 5)) data &= input_port_read(machine, "LINE1");
208   if (!BIT(m_keylatch, 6)) data &= input_port_read(machine, "LINE2");
209   if (!BIT(m_keylatch, 7)) data &= input_port_read(machine, "LINE3");
198210
199   state->keydown = (data==0xff) ? 0 : 1;
211   m_keydown = (data==0xff) ? 0 : 1;
200212
201213   return data;
202214}
203215
204static WRITE8_DEVICE_HANDLER( d6800_keyboard_w )
216WRITE8_MEMBER( d6800_state::d6800_keyboard_w )
205217{
206   d6800_state *state = device->machine->driver_data<d6800_state>();
207218   /*
208219
209220        bit     description
r9896r9897
220231    */
221232
222233
223   state->keylatch = data & 0xf0;
234   m_keylatch = data & 0xf0;
224235}
225236
226237static const pia6821_interface d6800_mc6821_intf =
227238{
228   DEVCB_HANDLER(d6800_keyboard_r),         /* port A input */
229   DEVCB_HANDLER(d6800_cassette_r),         /* port B input */
230   DEVCB_LINE(d6800_keydown_r),            /* CA1 input */
231   DEVCB_LINE(d6800_rtc_pulse),            /* CB1 input */
232   DEVCB_LINE(d6800_fn_key_r),            /* CA2 input */
239   DEVCB_DRIVER_MEMBER(d6800_state, d6800_keyboard_r),   /* port A input */
240   DEVCB_DRIVER_MEMBER(d6800_state, d6800_cassette_r),   /* port B input */
241   DEVCB_DRIVER_LINE_MEMBER(d6800_state, d6800_keydown_r),   /* CA1 input */
242   DEVCB_DRIVER_LINE_MEMBER(d6800_state, d6800_rtc_pulse),   /* CB1 input */
243   DEVCB_DRIVER_LINE_MEMBER(d6800_state, d6800_fn_key_r),   /* CA2 input */
233244   DEVCB_NULL,                  /* CB2 input */
234   DEVCB_HANDLER(d6800_keyboard_w),         /* port A output */
235   DEVCB_HANDLER(d6800_cassette_w),         /* port B output */
245   DEVCB_DRIVER_MEMBER(d6800_state, d6800_keyboard_w),   /* port A output */
246   DEVCB_DRIVER_MEMBER(d6800_state, d6800_cassette_w),   /* port B output */
236247   DEVCB_NULL,                  /* CA2 output */
237   DEVCB_LINE(d6800_screen_w),            /* CB2 output */
248   DEVCB_DRIVER_LINE_MEMBER(d6800_state, d6800_screen_w),   /* CB2 output */
238249   DEVCB_CPU_INPUT_LINE("maincpu", M6800_IRQ_LINE),   /* IRQA output */
239250   DEVCB_CPU_INPUT_LINE("maincpu", M6800_IRQ_LINE)      /* IRQB output */
240251};
r9896r9897
243254
244255static MACHINE_START( d6800 )
245256{
246   d6800_state *state = machine->driver_data<d6800_state>();
247   state->speaker = machine->device("speaker");
248   state->cassette = machine->device("cassette");
249257}
250258
251259static MACHINE_RESET( d6800 )

Previous 15994 Revisions Next


© 1998-2018 The MESS Team