Previous 15994 Revisions Next

r12437 Monday 1st August, 2011 at 08:11:26 UTC by Jonathan Gevaryahu
digel804: Hook up ACIA; add proper mirrors to i/o areas; hook up ram banking (still has some issues needing to be worked out); document what a whole lot more of the i/o bits do. [Lord Nightmare]
[src/mess/drivers]digel804.c

src/mess/drivers/digel804.c
r12436r12437
66*
77*  DONE:
88*  figure out z80 address space and hook up roms and rams (done)
9*  figure out where 10937 vfd controller lives (port 0x44 bits 7 and 0)
9*  figure out where 10937 vfd controller lives (port 0x44 bits 7 and 0, POR has not been found yet)
1010*  figure out how keypresses are detected (/INT, port 0x43, and port 0x46)
11*  figure out how the banked ram works on fw4.x (writes to port 0x43 select a ram bank)
1112*  tentatively figure out how flow control from ACIA works (/NMI)?
1213*  hook up the speaker/beeper (port 0x45)
1314*  hook up vfd controller (done to stderr, no artwork)
1415*  hook up leds on front panel (done to stderr)
16*  hook up r6551 serial
1517*
1618*  TODO:
1719*  figure out the rest of the i/o map
18*  figure out how the banked ram works on fw4.x
20*  figure out why banked ram on 4.x causes glitches/sys errors; it works on 2.2
1921*  actually hook up interrupts and nmi
20*  hook up r6551 serial and attach terminal to it
22*  attach terminal to 6551 serial
2123*  correctly hook up 10937 vfd controller
2224*  hook up keypad and mode buttons
23
2425*  artwork
2526*
2627******************************************************************************/
2728
2829#define ADDRESS_MAP_MODERN
2930
31#define VFD_SERIAL_VERBOSE 1
32#undef VFD_VERBOSE
33#undef LED_VERBOSE
34
3035/* Core includes */
3136#include "emu.h"
3237#include "cpu/z80/z80.h"
3338#include "machine/terminal.h"
3439#include "sound/speaker.h"
3540#include "machine/roc10937.h"
41#include "machine/6551.h"
3642
3743
3844class digel804_state : public driver_device
r12436r12437
4248      : driver_device(mconfig, type, tag),
4349        m_maincpu(*this, "maincpu"),
4450        m_terminal(*this, TERMINAL_TAG),
45        m_speaker(*this, "speaker")
51        m_speaker(*this, "speaker"),
52        m_acia(*this, "acia")
4653   { }
4754
4855   required_device<cpu_device> m_maincpu;
4956   required_device<device_t> m_terminal;
5057   required_device<device_t> m_speaker;
58   required_device<device_t> m_acia;
5159   DECLARE_WRITE8_MEMBER( port_43_w );
5260   DECLARE_READ8_MEMBER( port_43_r );
5361   DECLARE_WRITE8_MEMBER( port_44_w );
5462   DECLARE_WRITE8_MEMBER( speaker_w );
5563   DECLARE_WRITE8_MEMBER( led_control_w );
5664   DECLARE_READ8_MEMBER( keypad_r );
65   DECLARE_READ8_MEMBER( acia_rxd_r );
66   DECLARE_WRITE8_MEMBER( acia_txd_w );
67   DECLARE_READ8_MEMBER( acia_status_r );
68   DECLARE_WRITE8_MEMBER( acia_reset_w );
69   DECLARE_READ8_MEMBER( acia_command_r );
70   DECLARE_WRITE8_MEMBER( acia_command_w );
71   DECLARE_READ8_MEMBER( acia_control_r );
72   DECLARE_WRITE8_MEMBER( acia_control_w );
5773   // return for port 43 (mode/status reg)
5874   UINT8 port43_rtn;
5975   // vfd helper stuff for port 44, should be unnecessary after 10937 gets a proper device
r12436r12437
6379   // current speaker state for port 45
6480   UINT8 speaker_state;
6581   // ram stuff for future banking
82   UINT8 m_ram_bank;
6683   UINT8 *m_main_ram;
6784};
6885
r12436r12437
7895   ROC10937_init(0,0,0); // TODO: replace this with a proper device
7996   state->vfd_old = state->vfd_data = state->vfd_count = 0;
8097   state->speaker_state = 0;
81   state->port43_rtn = 0xEE;
82   //state->m_ram_bank = 0;
83   //memory_set_bankptr( machine, "bankedram", machine.region("user_ram")->base() + ( state->m_ram_bank * 0x10000 ));
98   state->port43_rtn = 0xEE;//0xB6;
99   state->m_ram_bank = 0;
100   memory_set_bankptr( machine, "bankedram", machine.region("user_ram")->base() + ( state->m_ram_bank * 0x10000 ));
84101}
85102
86103static MACHINE_RESET( digel804 )
r12436r12437
92109
93110READ8_MEMBER( digel804_state::port_43_r )
94111{
95   /* Register 0x43: status/mode register
112   /* Register 0x43: status/mode register read
96113    bits 76543210
97         |||||||\- unknown, always 0?
98         ||||||\-- unknown, always 1?
99         |||||\--- any key pressed on keypad (0 = one or more pressed, 1 = none pressed) * if upper byte is 0xF and this bit is set, unit is about to turn off
100         |||\\---- mode selected? (01 = key, 10 = remote, 11 = sim)
101         ||\------ ram enable for internal use? (not sure, clear in sim mode)
114         |||||||\- overload state (0 = not overloaded; 1 = overload detected, led on and power disconnected to ic)
115         ||||||\-- unknown, always 1? may be acia related
116         |||||\--- any key pressed on keypad (0 = one or more pressed, 1 = none pressed or unit is about to go to standby)
117         ||||\---- remote mode selected (0 = selected, 1 = not) \
118         |||\----- key mode selected (0 = selected, 1 = not)     > if all 3 of these are 1, unit is going to standby
119         ||\------ sim mode selected (0 = selected, 1 = not)    /
102120         |\------- power failure status (1 = power has failed, 0 = ok)
103         \-------- unknown, always 1?
121         \-------- chip insert detect state (1 = no chip or cmos chip which ammeter cannot detect; 0 = nmos or detectable chip inserted)
104122    after power failure (in key mode):
105123    0xEE 11101110 when no keypad key pressed
106124    0xEA 11101010 when keypad key pressed
r12436r12437
125143
126144WRITE8_MEMBER( digel804_state::port_43_w )
127145{
128   //m_ram_bank = data&7;
146   m_ram_bank = data&7;
129147   //digel804_set_ram_bank( machine() );
130   //memory_set_bankptr( machine(), "bankedram", machine().region("user_ram")->base() + ( m_ram_bank * 0x10000 ));
131   logerror("Digel804: port 0x43 unknown had %02x written to it!\n", data);
148   memory_set_bankptr( machine(), "bankedram", machine().region("user_ram")->base() + ( m_ram_bank * 0x10000 ));
149   logerror("Digel804: port 0x43 ram bank had %02x written to it!\n", data);
132150}
133151
134152WRITE8_MEMBER( digel804_state::port_44_w )
135153{
136   /* writes to 0x44 control the 10937 vfd chip
154   /* writes to 0x44 control the 10937 vfd chip and z80 power and related stuff
137155    * bits:76543210
138    *      |||||||\- VFD chip clock
139    *      ||||||\-- unknown, always 1?
140    *      |\\\\\--- unknown, always 0?
141    *      \-------- VFD chip data
156    *      |||||||\- 10937 VFDC '/SCK' serial clock
157    *      ||||||\-- unknown, is sometimes written 1 and sometimes 0, purpose unclear. is NOT /RES for ACIA and is NOT apparently POR on the VFDC
158    *      |||||\--- z80 and system power control (0 = power on, 1 = power off/standby)
159    *      ||||\---- controls, somehow, the z80 /BUSRQ line (0 = idle/high, 1 = asserted/low)
160    *      |||\----- unknown, always 0?
161    *      ||\------ unknown, always 0?
162    *      |\------- unknown, is sometimes written 1 but usually 0, purpose unclear, but implied to have something to do with eprom socket power
163    *      \-------- 10937 VFDC 'DATA' serial data
164   
142165    */
143   if ((data&0x7E) != 0x02)
144      logerror("Digel804: port 0x44 vfd control had %02x written to it!\n", data);
166#ifdef VFD_SERIAL_VERBOSE
167   logerror("Digel804: port 0x44 vfd control had %02x written to it!\n", data);
168#endif
145169   // latch vfd data on falling edge of clock only; this should really be part of the 10937 device, not here!
146170   if ((vfd_old&1) && ((data&1)==0))
147171   {
r12436r12437
150174      vfd_count++;
151175      if (vfd_count == 8)
152176      {
177#ifdef VFD_VERBOSE
153178         logerror("Digel804: Full byte written to port 44 vfd: %02X '%c'\n", vfd_data, vfd_data);
179#endif
154180         ROC10937_newdata(0,vfd_data);
155181         vfd_data = 0;
156182         vfd_count = 0;
r12436r12437
162188WRITE8_MEMBER( digel804_state::speaker_w )
163189{
164190   // it APPEARS all writes here invert the speaker state, but not certain!
165   if ((data != 0x00) && (data != 0x01))
191   if ((data != 0x00) && (data != 0x01) && (data != 0x03))
166192      logerror("Digel804: port 0x45 speaker control had %02x written to it!\n", data);
167193   speaker_state ^= 0xFF;
168194   speaker_level_w(m_speaker, speaker_state);
r12436r12437
178204    *      |\------- this bit controls the 'busy' led; 1 = on
179205    *      \-------- this bit controls the 'input' led; 1 = on
180206    */
207#ifdef LED_VERBOSE
181208    logerror("Digel804: port 0x46 LED control had %02x written to it!\n", data);
209#endif
182210    fprintf(stderr,"LEDS: ");
183211    if (data&0x80) fprintf(stderr,"INPUT "); else fprintf(stderr,"----- ");
184212    if (data&0x40) fprintf(stderr,"BUSY "); else fprintf(stderr,"---- ");
r12436r12437
202230   return 0xF0; // enter
203231}
204232
233/* ACIA Trampolines */
234READ8_MEMBER( digel804_state::acia_rxd_r )
235{
236   return acia_6551_r(m_acia, 0);
237}
238
239WRITE8_MEMBER( digel804_state::acia_txd_w )
240{
241   acia_6551_w(m_acia, 0, data);
242}
243
244READ8_MEMBER( digel804_state::acia_status_r )
245{
246   return acia_6551_r(m_acia, 1);
247}
248
249WRITE8_MEMBER( digel804_state::acia_reset_w )
250{
251   acia_6551_w(m_acia, 1, data);
252}
253
254READ8_MEMBER( digel804_state::acia_command_r )
255{
256   return acia_6551_r(m_acia, 2);
257}
258
259WRITE8_MEMBER( digel804_state::acia_command_w )
260{
261   acia_6551_w(m_acia, 2, data);
262}
263
264READ8_MEMBER( digel804_state::acia_control_r )
265{
266   return acia_6551_r(m_acia, 3);
267}
268
269WRITE8_MEMBER( digel804_state::acia_control_w )
270{
271   acia_6551_w(m_acia, 3, data);
272}
273
205274/******************************************************************************
206275 Address Maps
207276******************************************************************************/
r12436r12437
230299   //AM_RANGE(0xa000, 0xbfff) AM_RAM AM_BASE(m_main_ram) // 7d in mapper = RAM O3 (6164)
231300   AM_RANGE(0x4000,0xbfff) AM_RAMBANK("bankedram")
232301   // c000-cfff is open bus in mapper, 7f
302   //AM_RANGE(0xc000, 0xc7ff) AM_RAM // hack for now to test, since sometimes it writes to c3ff
233303   AM_RANGE(0xd000, 0xd7ff) AM_RAM // 7e in mapper = RAM P3 (6116)
234304   // d800-ffff is open bus in mapper, 7f
235305ADDRESS_MAP_END
r12436r12437
237307static ADDRESS_MAP_START(z80_io, AS_IO, 8, digel804_state)
238308   ADDRESS_MAP_UNMAP_HIGH
239309   ADDRESS_MAP_GLOBAL_MASK(0xff)
240   //AM_RANGE(0x40, 0x40) AM_WRITE // W, unknown
241   //AM_RANGE(0x41, 0x41) AM_WRITE // W, unknown
242   //AM_RANGE(0x42, 0x42) AM_WRITE // W, gets 00 written to it
243   AM_RANGE(0x43, 0x43) AM_READWRITE(port_43_r, port_43_w) // RW, mode and status register, also checks if keypad is pressed
244   AM_RANGE(0x44, 0x44) AM_WRITE(port_44_w) // W, 10937 vfd controller clock on d0, data on d8; other bits unknown
245   AM_RANGE(0x45, 0x45) AM_WRITE(speaker_w) // W, speaker bit; every write inverts state
246   AM_RANGE(0x46, 0x46) AM_READWRITE(keypad_r, led_control_w) // RW, reads keypad, writes controls the front panel leds.
247   //AM_RANGE(0x47, 0x47) AM_WRITE // gets 00 written to it
248   //AM_RANGE(0x83, 0x83) AM_WRITE // may be acia?
310   // io bits: x 1 x x x * * *
311   // writes to 47, 4e, 57, 5e, 67, 6e, 77, 7e, c7, ce, d7, de, e7, ee, f7, fe all go to 47, same with reads
312   //AM_RANGE(0x40, 0x40) AM_MIRROR(0xB8) AM_WRITE // W, unknown
313   //AM_RANGE(0x41, 0x41) AM_MIRROR(0xB8) AM_WRITE // W, unknown
314   //AM_RANGE(0x42, 0x42) AM_MIRROR(0xB8) AM_WRITE // W, gets 00 written to it
315   AM_RANGE(0x43, 0x43) AM_MIRROR(0xB8) AM_READWRITE(port_43_r, port_43_w) // RW, mode and status register, also checks if keypad is pressed; write is unknown
316   AM_RANGE(0x44, 0x44) AM_MIRROR(0xB8) AM_WRITE(port_44_w) // W, 10937 vfd controller and z80 power control reg
317   AM_RANGE(0x45, 0x45) AM_MIRROR(0xB8) AM_WRITE(speaker_w) // W, speaker bit; every write inverts state, values written are 00, 01, 03
318   AM_RANGE(0x46, 0x46) AM_MIRROR(0xB8) AM_READWRITE(keypad_r, led_control_w) // RW, reads keypad, writes controls the front panel leds.
319   //AM_RANGE(0x47, 0x47) AM_MIRROR(0xB8) AM_WRITE // W gets 00 written to it
320   // io bits: 1 0 x x x * * *
321   // writes to 80, 88, 90, 98, a0, a8, b0, b8 all go to 80, same with reads
322   AM_RANGE(0x80, 0x80) AM_MIRROR(0x38) AM_WRITE(acia_txd_w) // (ACIA xmit reg)
323   AM_RANGE(0x81, 0x81) AM_MIRROR(0x38) AM_READ(acia_rxd_r) // (ACIA rcv reg)
324   AM_RANGE(0x82, 0x82) AM_MIRROR(0x38) AM_WRITE(acia_reset_w) // (ACIA reset reg)
325   AM_RANGE(0x83, 0x83) AM_MIRROR(0x38) AM_READ(acia_status_r) // (ACIA status reg)
326   AM_RANGE(0x84, 0x84) AM_MIRROR(0x38) AM_WRITE(acia_command_w) // (ACIA command reg)
327   AM_RANGE(0x85, 0x85) AM_MIRROR(0x38) AM_READ(acia_command_r) // (ACIA command reg)
328   AM_RANGE(0x86, 0x86) AM_MIRROR(0x38) AM_WRITE(acia_control_w) // (ACIA control reg)
329   AM_RANGE(0x87, 0x87) AM_MIRROR(0x38) AM_READ(acia_control_r) // (ACIA control reg)*/
330   //AM_RANGE(0x80,0x87) AM_MIRROR(0x38) AM_SHIFT(-1) AM_DEVREADWRITE_LEGACY("acia", acia_6551_r, acia_6551_w) // this doesn't work since we lack an AM_SHIFT command
331   
249332ADDRESS_MAP_END
250333
251334
r12436r12437
277360   MCFG_FRAGMENT_ADD( generic_terminal )
278361   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, digel804_terminal_intf)
279362
363   /* acia */
364   MCFG_ACIA6551_ADD("acia")
365
280366   /* sound hardware */
281367   MCFG_SPEAKER_STANDARD_MONO("mono")
282368   MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)
r12436r12437
297383   MCFG_FRAGMENT_ADD( generic_terminal )
298384   MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, digel804_terminal_intf)
299385
386   /* acia */
387   MCFG_ACIA6551_ADD("acia")
388
300389   /* sound hardware */
301390   MCFG_SPEAKER_STANDARD_MONO("mono")
302391   MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team