src/mess/drivers/digel804.c
| r12436 | r12437 | |
| 6 | 6 | * |
| 7 | 7 | * DONE: |
| 8 | 8 | * 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) |
| 10 | 10 | * 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) |
| 11 | 12 | * tentatively figure out how flow control from ACIA works (/NMI)? |
| 12 | 13 | * hook up the speaker/beeper (port 0x45) |
| 13 | 14 | * hook up vfd controller (done to stderr, no artwork) |
| 14 | 15 | * hook up leds on front panel (done to stderr) |
| 16 | * hook up r6551 serial |
| 15 | 17 | * |
| 16 | 18 | * TODO: |
| 17 | 19 | * 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 |
| 19 | 21 | * actually hook up interrupts and nmi |
| 20 | | * hook up r6551 serial and attach terminal to it |
| 22 | * attach terminal to 6551 serial |
| 21 | 23 | * correctly hook up 10937 vfd controller |
| 22 | 24 | * hook up keypad and mode buttons |
| 23 | | |
| 24 | 25 | * artwork |
| 25 | 26 | * |
| 26 | 27 | ******************************************************************************/ |
| 27 | 28 | |
| 28 | 29 | #define ADDRESS_MAP_MODERN |
| 29 | 30 | |
| 31 | #define VFD_SERIAL_VERBOSE 1 |
| 32 | #undef VFD_VERBOSE |
| 33 | #undef LED_VERBOSE |
| 34 | |
| 30 | 35 | /* Core includes */ |
| 31 | 36 | #include "emu.h" |
| 32 | 37 | #include "cpu/z80/z80.h" |
| 33 | 38 | #include "machine/terminal.h" |
| 34 | 39 | #include "sound/speaker.h" |
| 35 | 40 | #include "machine/roc10937.h" |
| 41 | #include "machine/6551.h" |
| 36 | 42 | |
| 37 | 43 | |
| 38 | 44 | class digel804_state : public driver_device |
| r12436 | r12437 | |
| 42 | 48 | : driver_device(mconfig, type, tag), |
| 43 | 49 | m_maincpu(*this, "maincpu"), |
| 44 | 50 | m_terminal(*this, TERMINAL_TAG), |
| 45 | | m_speaker(*this, "speaker") |
| 51 | m_speaker(*this, "speaker"), |
| 52 | m_acia(*this, "acia") |
| 46 | 53 | { } |
| 47 | 54 | |
| 48 | 55 | required_device<cpu_device> m_maincpu; |
| 49 | 56 | required_device<device_t> m_terminal; |
| 50 | 57 | required_device<device_t> m_speaker; |
| 58 | required_device<device_t> m_acia; |
| 51 | 59 | DECLARE_WRITE8_MEMBER( port_43_w ); |
| 52 | 60 | DECLARE_READ8_MEMBER( port_43_r ); |
| 53 | 61 | DECLARE_WRITE8_MEMBER( port_44_w ); |
| 54 | 62 | DECLARE_WRITE8_MEMBER( speaker_w ); |
| 55 | 63 | DECLARE_WRITE8_MEMBER( led_control_w ); |
| 56 | 64 | 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 ); |
| 57 | 73 | // return for port 43 (mode/status reg) |
| 58 | 74 | UINT8 port43_rtn; |
| 59 | 75 | // vfd helper stuff for port 44, should be unnecessary after 10937 gets a proper device |
| r12436 | r12437 | |
| 63 | 79 | // current speaker state for port 45 |
| 64 | 80 | UINT8 speaker_state; |
| 65 | 81 | // ram stuff for future banking |
| 82 | UINT8 m_ram_bank; |
| 66 | 83 | UINT8 *m_main_ram; |
| 67 | 84 | }; |
| 68 | 85 | |
| r12436 | r12437 | |
| 78 | 95 | ROC10937_init(0,0,0); // TODO: replace this with a proper device |
| 79 | 96 | state->vfd_old = state->vfd_data = state->vfd_count = 0; |
| 80 | 97 | 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 )); |
| 84 | 101 | } |
| 85 | 102 | |
| 86 | 103 | static MACHINE_RESET( digel804 ) |
| r12436 | r12437 | |
| 92 | 109 | |
| 93 | 110 | READ8_MEMBER( digel804_state::port_43_r ) |
| 94 | 111 | { |
| 95 | | /* Register 0x43: status/mode register |
| 112 | /* Register 0x43: status/mode register read |
| 96 | 113 | 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) / |
| 102 | 120 | |\------- 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) |
| 104 | 122 | after power failure (in key mode): |
| 105 | 123 | 0xEE 11101110 when no keypad key pressed |
| 106 | 124 | 0xEA 11101010 when keypad key pressed |
| r12436 | r12437 | |
| 125 | 143 | |
| 126 | 144 | WRITE8_MEMBER( digel804_state::port_43_w ) |
| 127 | 145 | { |
| 128 | | //m_ram_bank = data&7; |
| 146 | m_ram_bank = data&7; |
| 129 | 147 | //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); |
| 132 | 150 | } |
| 133 | 151 | |
| 134 | 152 | WRITE8_MEMBER( digel804_state::port_44_w ) |
| 135 | 153 | { |
| 136 | | /* writes to 0x44 control the 10937 vfd chip |
| 154 | /* writes to 0x44 control the 10937 vfd chip and z80 power and related stuff |
| 137 | 155 | * 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 | |
| 142 | 165 | */ |
| 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 |
| 145 | 169 | // latch vfd data on falling edge of clock only; this should really be part of the 10937 device, not here! |
| 146 | 170 | if ((vfd_old&1) && ((data&1)==0)) |
| 147 | 171 | { |
| r12436 | r12437 | |
| 150 | 174 | vfd_count++; |
| 151 | 175 | if (vfd_count == 8) |
| 152 | 176 | { |
| 177 | #ifdef VFD_VERBOSE |
| 153 | 178 | logerror("Digel804: Full byte written to port 44 vfd: %02X '%c'\n", vfd_data, vfd_data); |
| 179 | #endif |
| 154 | 180 | ROC10937_newdata(0,vfd_data); |
| 155 | 181 | vfd_data = 0; |
| 156 | 182 | vfd_count = 0; |
| r12436 | r12437 | |
| 162 | 188 | WRITE8_MEMBER( digel804_state::speaker_w ) |
| 163 | 189 | { |
| 164 | 190 | // 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)) |
| 166 | 192 | logerror("Digel804: port 0x45 speaker control had %02x written to it!\n", data); |
| 167 | 193 | speaker_state ^= 0xFF; |
| 168 | 194 | speaker_level_w(m_speaker, speaker_state); |
| r12436 | r12437 | |
| 178 | 204 | * |\------- this bit controls the 'busy' led; 1 = on |
| 179 | 205 | * \-------- this bit controls the 'input' led; 1 = on |
| 180 | 206 | */ |
| 207 | #ifdef LED_VERBOSE |
| 181 | 208 | logerror("Digel804: port 0x46 LED control had %02x written to it!\n", data); |
| 209 | #endif |
| 182 | 210 | fprintf(stderr,"LEDS: "); |
| 183 | 211 | if (data&0x80) fprintf(stderr,"INPUT "); else fprintf(stderr,"----- "); |
| 184 | 212 | if (data&0x40) fprintf(stderr,"BUSY "); else fprintf(stderr,"---- "); |
| r12436 | r12437 | |
| 202 | 230 | return 0xF0; // enter |
| 203 | 231 | } |
| 204 | 232 | |
| 233 | /* ACIA Trampolines */ |
| 234 | READ8_MEMBER( digel804_state::acia_rxd_r ) |
| 235 | { |
| 236 | return acia_6551_r(m_acia, 0); |
| 237 | } |
| 238 | |
| 239 | WRITE8_MEMBER( digel804_state::acia_txd_w ) |
| 240 | { |
| 241 | acia_6551_w(m_acia, 0, data); |
| 242 | } |
| 243 | |
| 244 | READ8_MEMBER( digel804_state::acia_status_r ) |
| 245 | { |
| 246 | return acia_6551_r(m_acia, 1); |
| 247 | } |
| 248 | |
| 249 | WRITE8_MEMBER( digel804_state::acia_reset_w ) |
| 250 | { |
| 251 | acia_6551_w(m_acia, 1, data); |
| 252 | } |
| 253 | |
| 254 | READ8_MEMBER( digel804_state::acia_command_r ) |
| 255 | { |
| 256 | return acia_6551_r(m_acia, 2); |
| 257 | } |
| 258 | |
| 259 | WRITE8_MEMBER( digel804_state::acia_command_w ) |
| 260 | { |
| 261 | acia_6551_w(m_acia, 2, data); |
| 262 | } |
| 263 | |
| 264 | READ8_MEMBER( digel804_state::acia_control_r ) |
| 265 | { |
| 266 | return acia_6551_r(m_acia, 3); |
| 267 | } |
| 268 | |
| 269 | WRITE8_MEMBER( digel804_state::acia_control_w ) |
| 270 | { |
| 271 | acia_6551_w(m_acia, 3, data); |
| 272 | } |
| 273 | |
| 205 | 274 | /****************************************************************************** |
| 206 | 275 | Address Maps |
| 207 | 276 | ******************************************************************************/ |
| r12436 | r12437 | |
| 230 | 299 | //AM_RANGE(0xa000, 0xbfff) AM_RAM AM_BASE(m_main_ram) // 7d in mapper = RAM O3 (6164) |
| 231 | 300 | AM_RANGE(0x4000,0xbfff) AM_RAMBANK("bankedram") |
| 232 | 301 | // 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 |
| 233 | 303 | AM_RANGE(0xd000, 0xd7ff) AM_RAM // 7e in mapper = RAM P3 (6116) |
| 234 | 304 | // d800-ffff is open bus in mapper, 7f |
| 235 | 305 | ADDRESS_MAP_END |
| r12436 | r12437 | |
| 237 | 307 | static ADDRESS_MAP_START(z80_io, AS_IO, 8, digel804_state) |
| 238 | 308 | ADDRESS_MAP_UNMAP_HIGH |
| 239 | 309 | 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 | |
| 249 | 332 | ADDRESS_MAP_END |
| 250 | 333 | |
| 251 | 334 | |
| r12436 | r12437 | |
| 277 | 360 | MCFG_FRAGMENT_ADD( generic_terminal ) |
| 278 | 361 | MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, digel804_terminal_intf) |
| 279 | 362 | |
| 363 | /* acia */ |
| 364 | MCFG_ACIA6551_ADD("acia") |
| 365 | |
| 280 | 366 | /* sound hardware */ |
| 281 | 367 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 282 | 368 | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| r12436 | r12437 | |
| 297 | 383 | MCFG_FRAGMENT_ADD( generic_terminal ) |
| 298 | 384 | MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, digel804_terminal_intf) |
| 299 | 385 | |
| 386 | /* acia */ |
| 387 | MCFG_ACIA6551_ADD("acia") |
| 388 | |
| 300 | 389 | /* sound hardware */ |
| 301 | 390 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 302 | 391 | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |