Previous 15994 Revisions Next

r15447 Tuesday 12th June, 2012 at 12:27:38 UTC by Robbbert
D6800 - fixed keyboard
[src/mess/drivers]d6800.c eacc.c

src/mess/drivers/d6800.c
r15446r15447
55    in May 1979. It has 1k of ROM and 1k of RAM. The video consists of 64x32
66    pixels. The keyboard is a hexcode 4x4 matrix, plus a Function key.
77
8    Designed by Michael Bauer, of the Division of Computing and Mathematics
9    at Deakin University, Australia.
10
11    NOTE that the display only updates after each 4 digits is entered, and
12    you can't see what you type as you change bytes. This is by design.
13    The speaker is supposed to bleep on each keystroke, but it only gets
14    one pulse - which is almost inaudible.
15
816    Function keys:
917    FN 0 - Modify memory - firstly enter a 4-digit address, then 2-digit data
1018                    the address will increment by itself, enter the next byte.
r15446r15447
1220
1321    FN 1 - Tape load
1422
15    FN 2 - Tape save
23    FN 2 - Tape save. You must have entered the start address at 0002, and
24           the end address+1 at 0004 (big-endian).
1625
17    FN 3 - Run. Enter the 4-digit go address, then it starts executing.
26    FN 3 - Run. You must have entered the 4-digit go address first.
1827
28    All CHIP-8 programs load at 0x200 (max size 4k), and exec address
29    is C000.
1930
2031    Information and programs can be found at http://chip8.com/?page=78
2132
2233
23    To change the large numbers at the bottom, start in debug mode, enter
24    some data at memory 6 and 7, then G to run.
25
26
2734    TODO:
2835    - Cassette
29    - CPU should freeze while screen is being drawn
30    - Keyboard (should work but it doesn't, due to inadequate PIA emulation)
3136
32    Current situation:
33    - It starts, displays initial screen
34    - It checks the status bits looking for a keypress
35    - When a key is pressed, it gets into a loop at C2E8-C2EB, waiting for
36      a memory location to change. This means it needs an interrupt to kick
37      in, from a keypress.
38    - The pia only looks for an interrupt when it gets polled, which is
39      not the case here, so the emulation hangs.
4037*/
4138
4239
r15446r15447
4542#include "sound/beep.h"
4643#include "imagedev/cassette.h"
4744#include "sound/wave.h"
48#include "sound/speaker.h"
45#include "sound/dac.h"
4946#include "machine/6821pia.h"
5047
5148
r15446r15447
5754        m_maincpu(*this, "maincpu"),
5855        m_cass(*this, CASSETTE_TAG),
5956        m_pia(*this, "pia"),
60        m_speaker(*this, SPEAKER_TAG),
57        m_dac(*this, "dac"),
6158        m_videoram(*this, "videoram") { }
6259
63   required_device<cpu_device> m_maincpu;
64   required_device<cassette_image_device> m_cass;
65   required_device<device_t> m_pia;
66   required_device<device_t> m_speaker;
6760   DECLARE_READ8_MEMBER( d6800_cassette_r );
6861   DECLARE_WRITE8_MEMBER( d6800_cassette_w );
6962   DECLARE_READ8_MEMBER( d6800_keyboard_r );
r15446r15447
7265   DECLARE_READ_LINE_MEMBER( d6800_keydown_r );
7366   DECLARE_READ_LINE_MEMBER( d6800_rtc_pulse );
7467   DECLARE_WRITE_LINE_MEMBER( d6800_screen_w );
75   UINT8 m_keylatch;
76   UINT8 m_screen_on;
7768   UINT8 m_rtc;
69   bool m_screen_on;
70   required_device<cpu_device> m_maincpu;
71   required_device<cassette_image_device> m_cass;
72   required_device<device_t> m_pia;
73   required_device<device_t> m_dac;
7874   required_shared_ptr<UINT8> m_videoram;
75private:
76   UINT8 m_kbd_s;
77   UINT8 m_portb;
7978};
8079
8180
r15446r15447
9291/* Input Ports */
9392
9493static INPUT_PORTS_START( d6800 )
95   PORT_START("LINE0")
94   PORT_START("X0")
9695   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
9796   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')
9897   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2')
9998   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3')
100   PORT_BIT( 0xf0, 0xf0, IPT_UNUSED )
10199
102   PORT_START("LINE1")
100   PORT_START("X1")
103101   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4')
104102   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5')
105103   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6')
106104   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7')
107   PORT_BIT( 0xf0, 0xf0, IPT_UNUSED )
108105
109   PORT_START("LINE2")
106   PORT_START("X2")
110107   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8')
111108   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9')
112109   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
113110   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
114   PORT_BIT( 0xf0, 0xf0, IPT_UNUSED )
115111
116   PORT_START("LINE3")
112   PORT_START("X3")
117113   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
118114   PORT_BIT( 0x02, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
119115   PORT_BIT( 0x04, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
120116   PORT_BIT( 0x08, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
121   PORT_BIT( 0xf0, 0xf0, IPT_UNUSED )
122117
123   PORT_START("SPECIAL")
118   PORT_START("Y0")
119   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_0) PORT_CHAR('0')
120   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_4) PORT_CHAR('4')
121   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_8) PORT_CHAR('8')
122   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_C) PORT_CHAR('C')
123
124   PORT_START("Y1")
125   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_1) PORT_CHAR('1')
126   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_5) PORT_CHAR('5')
127   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_9) PORT_CHAR('9')
128   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_D) PORT_CHAR('D')
129
130   PORT_START("Y2")
131   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_2) PORT_CHAR('2')
132   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_6) PORT_CHAR('6')
133   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_A) PORT_CHAR('A')
134   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_E) PORT_CHAR('E')
135
136   PORT_START("Y3")
137   PORT_BIT( 0x10, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_3) PORT_CHAR('3')
138   PORT_BIT( 0x20, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_7) PORT_CHAR('7')
139   PORT_BIT( 0x40, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_B) PORT_CHAR('B')
140   PORT_BIT( 0x80, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_CODE(KEYCODE_F) PORT_CHAR('F')
141
142   PORT_START("SHIFT")
124143   PORT_BIT( 0x01, IP_ACTIVE_LOW, IPT_KEYBOARD ) PORT_NAME("FN") PORT_CODE(KEYCODE_LSHIFT)
144
145   PORT_START("VS")
146   /* vblank */
147   PORT_BIT(0x01, IP_ACTIVE_HIGH, IPT_CUSTOM) PORT_VBLANK("screen")
125148INPUT_PORTS_END
126149
127150/* Video */
r15446r15447
129152static SCREEN_UPDATE_IND16( d6800 )
130153{
131154   d6800_state *state = screen.machine().driver_data<d6800_state>();
132   UINT8 x,y,gfx=0,i;
155   UINT8 x,y,gfx=0;
133156
134157   for (y = 0; y < 32; y++)
135158   {
r15446r15447
140163         if (state->m_screen_on)
141164            gfx = state->m_videoram[ x | (y<<3)];
142165
143         for (i = 0; i < 8; i++)
144            *p++ = BIT(gfx, 7-i);
166         *p++ = BIT(gfx, 7);
167         *p++ = BIT(gfx, 6);
168         *p++ = BIT(gfx, 5);
169         *p++ = BIT(gfx, 4);
170         *p++ = BIT(gfx, 3);
171         *p++ = BIT(gfx, 2);
172         *p++ = BIT(gfx, 1);
173         *p++ = BIT(gfx, 0);
145174      }
146175   }
147176   return 0;
r15446r15447
149178
150179/* PIA6821 Interface */
151180
152static INTERRUPT_GEN( d6800_interrupt )
181static TIMER_DEVICE_CALLBACK( d6800_p )
153182{
154   d6800_state *state = device->machine().driver_data<d6800_state>();
155   state->m_rtc = 1;
183   d6800_state *state = timer.machine().driver_data<d6800_state>();
184   state->m_rtc++;
185   device_set_input_line(state->m_maincpu, M6800_IRQ_LINE, (state->m_rtc > 0xf8) ? ASSERT_LINE : CLEAR_LINE);
156186}
157187
188
189// not used
158190READ_LINE_MEMBER( d6800_state::d6800_rtc_pulse )
159191{
160   UINT8 res = m_rtc;
161   m_rtc = 0;
162   return res;
192   return 1;
163193}
164194
165195READ_LINE_MEMBER( d6800_state::d6800_keydown_r )
166196{
167   UINT8 data = ioport("LINE0")->read()
168              & ioport("LINE1")->read()
169              & ioport("LINE2")->read()
170              & ioport("LINE3")->read();
197   UINT8 data = ioport("X0")->read()
198              & ioport("X1")->read()
199              & ioport("X2")->read()
200              & ioport("X3")->read();
171201
172   return (data==0xff) ? 0 : 1;
202   m_kbd_s = (data == 15) ? 0 : 1;
203
204   return m_kbd_s;
173205}
174206
175207READ_LINE_MEMBER( d6800_state::d6800_fn_key_r )
176208{
177   return ioport("SPECIAL")->read();
209   return ioport("SHIFT")->read();
178210}
179211
180212WRITE_LINE_MEMBER( d6800_state::d6800_screen_w )
r15446r15447
191223    knows if the tone is 1200 or 2400 Hz. Input to PIA is bit 7.
192224    */
193225
194   return 0xff;
226   return ((m_cass->input() > 0.03) ? 1 : 0) | m_portb;
195227}
196228
197229WRITE8_MEMBER( d6800_state::d6800_cassette_w )
r15446r15447
202234    bit 0 of the PIA. Bit 6 drives the speaker.
203235    */
204236
205   speaker_level_w(m_speaker, BIT(data, 6));
237   m_cass->output(BIT(data, 0) ? -1.0 : +1.0);
238
239   dac_data_w(m_dac, data);
240   m_portb = data;
206241}
207242
208243READ8_MEMBER( d6800_state::d6800_keyboard_r )
209244{
210   UINT8 data = 15;
245   /*
246    This system reads the key matrix one way, then swaps the input and output
247    lines around and reads it another way. This isolates the key that was pressed.
248    */
211249
212   if (!BIT(m_keylatch, 4)) data &= ioport("LINE0")->read();
213   if (!BIT(m_keylatch, 5)) data &= ioport("LINE1")->read();
214   if (!BIT(m_keylatch, 6)) data &= ioport("LINE2")->read();
215   if (!BIT(m_keylatch, 7)) data &= ioport("LINE3")->read();
250   m_kbd_s++;
216251
217   return data | m_keylatch;
252   if (m_kbd_s == 3)
253      return 0x0f & ioport("X0")->read() & ioport("X1")->read() & ioport("X2")->read() & ioport("X3")->read();
254   else
255   if (m_kbd_s == 6)
256      return 0xf0 & ioport("Y0")->read() & ioport("Y1")->read() & ioport("Y2")->read() & ioport("Y3")->read();
257   else
258      return 0xff;
218259}
219260
220261WRITE8_MEMBER( d6800_state::d6800_keyboard_w )
r15446r15447
234275
235276    */
236277
237
238   m_keylatch = data & 0xf0;
239278}
240279
241280static const pia6821_interface d6800_mc6821_intf =
r15446r15447
279318   /* basic machine hardware */
280319   MCFG_CPU_ADD("maincpu",M6800, XTAL_4MHz/4)
281320   MCFG_CPU_PROGRAM_MAP(d6800_map)
282   MCFG_CPU_VBLANK_INT("screen", d6800_interrupt)
283321
284322   MCFG_MACHINE_START(d6800)
285323   MCFG_MACHINE_RESET(d6800)
r15446r15447
297335   /* sound hardware */
298336   MCFG_SPEAKER_STANDARD_MONO("mono")
299337   MCFG_SOUND_WAVE_ADD(WAVE_TAG, CASSETTE_TAG)
300   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25)
301   MCFG_SOUND_ADD(SPEAKER_TAG, SPEAKER_SOUND, 0)
302338   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
339   MCFG_SOUND_ADD("dac", DAC, 0)
340   MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50)
303341
304342   /* devices */
305343   MCFG_PIA6821_ADD("pia", d6800_mc6821_intf)
306344   MCFG_CASSETTE_ADD(CASSETTE_TAG, d6800_cassette_interface)
345   MCFG_TIMER_ADD_PERIODIC("d6800_p", d6800_p, attotime::from_hz(40000) )
307346MACHINE_CONFIG_END
308347
309348/* ROMs */
r15446r15447
313352   ROM_LOAD( "d6800.bin", 0xc000, 0x0400, CRC(3f97ca2e) SHA1(60f26e57a058262b30befceceab4363a5d65d877) )
314353ROM_END
315354
316/*    YEAR  NAME        PARENT  COMPAT  MACHINE     INPUT       INIT        COMPANY                             FULLNAME                FLAGS */
317COMP( 1979, d6800,   0,   0,   d6800,       d6800,   0,   "Electronics Australia",   "Dream 6800",   GAME_NOT_WORKING | GAME_NO_SOUND )
355/*    YEAR  NAME   PARENT  COMPAT  MACHINE   INPUT       INIT        COMPANY             FULLNAME      FLAGS */
356COMP( 1979, d6800, 0,      0,      d6800,    d6800,      0,   "Electronics Australia", "Dream 6800", GAME_NOT_WORKING )
src/mess/drivers/eacc.c
r15446r15447
138138   eacc_state *state = timer.machine().driver_data<eacc_state>();
139139   state->m_cb1 ^= 1; // 15hz
140140   if (state->m_cb2)
141      device_set_input_line(timer.machine().device("maincpu"), M6800_IRQ_LINE, ASSERT_LINE);
141      device_set_input_line(state->m_maincpu, M6800_IRQ_LINE, ASSERT_LINE);
142142}
143143
144144static TIMER_DEVICE_CALLBACK( eacc_nmi )
r15446r15447
148148   if (state->m_cb2)
149149   {
150150      state->m_nmi = true;
151      device_set_input_line(timer.machine().device("maincpu"), INPUT_LINE_NMI, ASSERT_LINE);
151      device_set_input_line(state->m_maincpu, INPUT_LINE_NMI, ASSERT_LINE);
152152   }
153153}
154154
r15446r15447
226226{
227227   if (m_nmi)
228228   {
229      device_set_input_line(machine().device("maincpu"), INPUT_LINE_NMI, CLEAR_LINE);
229      device_set_input_line(m_maincpu, INPUT_LINE_NMI, CLEAR_LINE);
230230      m_nmi = false;
231231   }
232232   m_digit = data & 0xf8;

Previous 15994 Revisions Next


© 1998-2018 The MESS Team