src/mess/drivers/digel804.c
| r15883 | r15884 | |
| 52 | 52 | |
| 53 | 53 | // port 47 write is tim0-tim7 |
| 54 | 54 | |
| 55 | | // collated serial data sent to vfd |
| 56 | | #undef VFD_VERBOSE |
| 57 | 55 | |
| 58 | | |
| 59 | 56 | /* Core includes */ |
| 60 | 57 | #include "emu.h" |
| 61 | 58 | #include "cpu/z80/z80.h" |
| r15883 | r15884 | |
| 64 | 61 | #include "machine/roc10937.h" |
| 65 | 62 | #include "machine/6551acia.h" |
| 66 | 63 | #include "machine/mm74c922.h" |
| 64 | #include "machine/ram.h" |
| 67 | 65 | #include "digel804.lh" |
| 68 | 66 | |
| 69 | 67 | |
| r15883 | r15884 | |
| 77 | 75 | m_speaker(*this, "speaker"), |
| 78 | 76 | m_acia(*this, "acia"), |
| 79 | 77 | m_vfd(*this, "vfd"), |
| 80 | | m_kb(*this, "74c923") |
| 78 | m_kb(*this, "74c923"), |
| 79 | m_ram(*this, RAM_TAG) |
| 81 | 80 | //, m_main_ram(*this, "main_ram") |
| 82 | 81 | { } |
| 83 | 82 | |
| r15883 | r15884 | |
| 87 | 86 | required_device<acia6551_device> m_acia; |
| 88 | 87 | required_device<roc10937_t> m_vfd; |
| 89 | 88 | required_device<mm74c922_device> m_kb; |
| 89 | required_device<ram_device> m_ram; |
| 90 | 90 | |
| 91 | 91 | virtual void machine_reset(); |
| 92 | DECLARE_DRIVER_INIT(digel804); |
| 93 | DECLARE_WRITE8_MEMBER( op00 ); |
| 92 | 94 | DECLARE_READ8_MEMBER( ip40 ); |
| 93 | 95 | DECLARE_WRITE8_MEMBER( op40 ); |
| 94 | 96 | DECLARE_WRITE8_MEMBER( op41 ); |
| 95 | 97 | DECLARE_WRITE8_MEMBER( op42 ); |
| 96 | 98 | DECLARE_READ8_MEMBER( ip43 ); |
| 97 | 99 | DECLARE_WRITE8_MEMBER( op43 ); |
| 100 | DECLARE_WRITE8_MEMBER( op43_1_4 ); |
| 98 | 101 | DECLARE_WRITE8_MEMBER( op44 ); |
| 99 | 102 | DECLARE_WRITE8_MEMBER( op45 ); |
| 100 | 103 | DECLARE_READ8_MEMBER( ip46 ); |
| r15883 | r15884 | |
| 111 | 114 | DECLARE_WRITE_LINE_MEMBER( da_w ); |
| 112 | 115 | DECLARE_INPUT_CHANGED_MEMBER(mode_change); |
| 113 | 116 | // vfd helper stuff for port 44, should be unnecessary after 10937 gets a proper device |
| 114 | | UINT8 vfd_data; |
| 115 | | UINT8 vfd_old; |
| 116 | | UINT8 vfd_count; |
| 117 | UINT8 m_vfd_sclk; |
| 117 | 118 | // current speaker state for port 45 |
| 118 | 119 | UINT8 m_speaker_state; |
| 119 | 120 | // ram stuff for banking |
| r15883 | r15884 | |
| 130 | 131 | UINT8 m_chipinsert_state; |
| 131 | 132 | UINT8 m_keyen_state; |
| 132 | 133 | UINT8 m_op41; |
| 133 | | DECLARE_DRIVER_INIT(digel804); |
| 134 | 134 | }; |
| 135 | 135 | |
| 136 | 136 | |
| r15883 | r15884 | |
| 139 | 139 | |
| 140 | 140 | DRIVER_INIT_MEMBER(digel804_state,digel804) |
| 141 | 141 | { |
| 142 | | vfd_old = vfd_data = vfd_count = 0; |
| 143 | 142 | m_speaker_state = 0; |
| 144 | 143 | //port43_rtn = 0xEE;//0xB6; |
| 145 | 144 | m_acia_intq = 1; // /INT source 1 |
| r15883 | r15884 | |
| 153 | 152 | m_ram_bank = 0; |
| 154 | 153 | m_op41 = 0; |
| 155 | 154 | m_keyen_state = 1; // /KEYEN |
| 156 | | membank( "bankedram" )->set_base( memregion("user_ram")->base() + ( m_ram_bank * 0x10000 )); |
| 155 | |
| 156 | membank( "bankedram" )->set_base(m_ram->pointer()); |
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | void digel804_state::machine_reset() |
| 160 | 160 | { |
| 161 | 161 | m_vfd->reset(); |
| 162 | | vfd_old = vfd_data = vfd_count = 0; |
| 162 | m_vfd_sclk = 0; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | 165 | READ8_MEMBER( digel804_state::ip40 ) // eprom data bus read |
| r15883 | r15884 | |
| 178 | 178 | { |
| 179 | 179 | // TODO: would be nice to have a 'fake eprom' here |
| 180 | 180 | logerror("Digel804: port 41, eprom address low/sim/memorybank had %02X written to it!\n", data); |
| 181 | | fprintf(stderr,"op41 write of %02X, ram mapper bit is %d\n", data, (data&0x40)?1:0); |
| 181 | //fprintf(stderr,"op41 write of %02X, ram mapper bit is %d\n", data, (data&0x40)?1:0); |
| 182 | 182 | m_op41 = data; |
| 183 | 183 | } |
| 184 | 184 | |
| r15883 | r15884 | |
| 216 | 216 | 0xFE 11111110 |
| 217 | 217 | |
| 218 | 218 | */ |
| 219 | | // HACK to dump display contents to stderr |
| 220 | | // FIXME : not sure what to do here with the new device! 201207 |
| 221 | | // fprintf(stderr,"%s\n",ROC10937_get_string(0)); |
| 219 | |
| 222 | 220 | #ifdef PORT43_R_VERBOSE |
| 223 | 221 | logerror("Digel804: returning %02X for port 43 status read\n", port43_rtn); |
| 224 | 222 | #endif |
| r15883 | r15884 | |
| 233 | 231 | |
| 234 | 232 | } |
| 235 | 233 | |
| 234 | WRITE8_MEMBER( digel804_state::op00 ) |
| 235 | { |
| 236 | m_ram_bank = data; |
| 237 | membank( "bankedram" )->set_base(m_ram->pointer() + ((m_ram_bank * 0x8000) & m_ram->mask())); |
| 238 | } |
| 239 | |
| 236 | 240 | WRITE8_MEMBER( digel804_state::op43 ) |
| 237 | 241 | { |
| 238 | 242 | /* writes to 0x43 control the ram banking on firmware which supports it |
| r15883 | r15884 | |
| 250 | 254 | m_ram_bank = data&7; |
| 251 | 255 | if ((data&0xF8)!=0) |
| 252 | 256 | logerror("Digel804: port 0x43 ram bank had unexpected data %02x written to it!\n", data); |
| 253 | | membank( "bankedram" )->set_base( memregion("user_ram")->base() + ( m_ram_bank * 0x10000 )); |
| 254 | 257 | |
| 258 | membank( "bankedram" )->set_base(m_ram->pointer() + ((m_ram_bank * 0x8000) & m_ram->mask())); |
| 255 | 259 | } |
| 256 | 260 | |
| 261 | WRITE8_MEMBER( digel804_state::op43_1_4 ) |
| 262 | { |
| 263 | m_overload_state = 0; // writes to port 43 clear overload state |
| 264 | } |
| 265 | |
| 257 | 266 | WRITE8_MEMBER( digel804_state::op44 ) // state write |
| 258 | 267 | { |
| 259 | 268 | /* writes to 0x44 control the 10937 vfd chip, z80 power/busrq, eprom driving and some eprom power ctl lines |
| r15883 | r15884 | |
| 275 | 284 | logerror("Digel804: port 0x44 vfd/state control had %02x written to it!\n", data); |
| 276 | 285 | #endif |
| 277 | 286 | // latch vfd data on falling edge of clock only; this should really be part of the 10937 device, not here! |
| 278 | | if ((vfd_old&1) && ((data&1)==0)) |
| 287 | if (m_vfd_sclk && ((data&1)==0)) |
| 279 | 288 | { |
| 280 | 289 | m_vfd->shift_data((data & 0x80) ? 0 : 1); |
| 281 | | |
| 282 | | vfd_data <<= 1; |
| 283 | | vfd_data |= (data&0x80)?1:0; |
| 284 | | vfd_count++; |
| 285 | | if (vfd_count == 8) |
| 286 | | { |
| 287 | | #ifdef VFD_VERBOSE |
| 288 | | logerror("Digel804: Full byte written to port 44 vfd: %02X '%c'\n", vfd_data, vfd_data); |
| 289 | | #endif |
| 290 | | vfd_data = 0; |
| 291 | | vfd_count = 0; |
| 292 | | } |
| 293 | 290 | } |
| 294 | | vfd_old = data; |
| 291 | m_vfd_sclk = data & 1; |
| 295 | 292 | } |
| 296 | 293 | |
| 297 | 294 | WRITE8_MEMBER( digel804_state::op45 ) // speaker write |
| r15883 | r15884 | |
| 337 | 334 | #ifdef PORT46_W_VERBOSE |
| 338 | 335 | logerror("Digel804: port 0x46 LED control had %02x written to it!\n", data); |
| 339 | 336 | #endif |
| 340 | | popmessage("LEDS: %s %s %s Func: %s%d\n", (data&0x80)?"INPUT":"-----", (data&0x40)?"BUSY":"----", (data&0x20)?"ERROR":"-----", (data&0x10)?"None":"", (data&0x10)?-1:(~data&0xF)); |
| 337 | //popmessage("LEDS: %s %s %s Func: %s%d\n", (data&0x80)?"INPUT":"-----", (data&0x40)?"BUSY":"----", (data&0x20)?"ERROR":"-----", (data&0x10)?"None":"", (data&0x10)?-1:(~data&0xF)); |
| 341 | 338 | //fprintf("LEDS: %s %s %s Func: %s%d\n", (data&0x80)?"INPUT":"-----", (data&0x40)?"BUSY":"----", (data&0x20)?"ERROR":"-----", (data&0x10)?"None":"", (data&0x10)?-1:(~data&0xF)); |
| 342 | 339 | |
| 343 | 340 | output_set_value("input_led", BIT(data,7)); |
| r15883 | r15884 | |
| 457 | 454 | // d800-ffff is open bus in mapper, 7f |
| 458 | 455 | ADDRESS_MAP_END |
| 459 | 456 | |
| 460 | | static ADDRESS_MAP_START(z80_io, AS_IO, 8, digel804_state) |
| 457 | static ADDRESS_MAP_START(z80_io_1_4, AS_IO, 8, digel804_state) |
| 461 | 458 | ADDRESS_MAP_UNMAP_HIGH |
| 462 | 459 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 463 | 460 | // io bits: x 1 x x x * * * |
| 464 | 461 | // 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 |
| 462 | AM_RANGE(0x00, 0x00) AM_MIRROR(0xB8) AM_WRITE(op00) // W, banked ram |
| 465 | 463 | AM_RANGE(0x40, 0x40) AM_MIRROR(0xB8) AM_READWRITE(ip40, op40) // RW, eprom socket data bus input/output value |
| 466 | 464 | AM_RANGE(0x41, 0x41) AM_MIRROR(0xB8) AM_WRITE(op41) // W, eprom socket address low out |
| 467 | 465 | AM_RANGE(0x42, 0x42) AM_MIRROR(0xB8) AM_WRITE(op42) // W, eprom socket address hi/control out |
| 466 | AM_RANGE(0x43, 0x43) AM_MIRROR(0xB8) AM_READWRITE(ip43, op43_1_4) // RW, mode and status register, also checks if keypad is pressed; write is unknown |
| 467 | AM_RANGE(0x44, 0x44) AM_MIRROR(0xB8) AM_WRITE(op44) // W, 10937 vfd controller, z80 power and state control reg |
| 468 | AM_RANGE(0x45, 0x45) AM_MIRROR(0xB8) AM_WRITE(op45) // W, speaker bit; every write inverts state |
| 469 | AM_RANGE(0x46, 0x46) AM_MIRROR(0xB8) AM_READWRITE(ip46, op46) // RW, reads keypad, writes controls the front panel leds. |
| 470 | AM_RANGE(0x47, 0x47) AM_MIRROR(0xB8) AM_WRITE(op47) // W eprom socket power and timing control |
| 471 | // io bits: 1 0 x x x * * * |
| 472 | // writes to 80, 88, 90, 98, a0, a8, b0, b8 all go to 80, same with reads |
| 473 | AM_RANGE(0x80, 0x80) AM_MIRROR(0x38) AM_WRITE(acia_txd_w) // (ACIA xmit reg) |
| 474 | AM_RANGE(0x81, 0x81) AM_MIRROR(0x38) AM_READ(acia_rxd_r) // (ACIA rcv reg) |
| 475 | AM_RANGE(0x82, 0x82) AM_MIRROR(0x38) AM_WRITE(acia_reset_w) // (ACIA reset reg) |
| 476 | AM_RANGE(0x83, 0x83) AM_MIRROR(0x38) AM_READ(acia_status_r) // (ACIA status reg) |
| 477 | AM_RANGE(0x84, 0x84) AM_MIRROR(0x38) AM_WRITE(acia_command_w) // (ACIA command reg) |
| 478 | AM_RANGE(0x85, 0x85) AM_MIRROR(0x38) AM_READ(acia_command_r) // (ACIA command reg) |
| 479 | AM_RANGE(0x86, 0x86) AM_MIRROR(0x38) AM_WRITE(acia_control_w) // (ACIA control reg) |
| 480 | AM_RANGE(0x87, 0x87) AM_MIRROR(0x38) AM_READ(acia_control_r) // (ACIA control reg) |
| 481 | //AM_RANGE(0x80,0x87) AM_MIRROR(0x38) AM_SHIFT(-1) AM_DEVREADWRITE("acia", acia6551_device, read, write) // this doesn't work since we lack an AM_SHIFT command |
| 482 | |
| 483 | ADDRESS_MAP_END |
| 484 | |
| 485 | static ADDRESS_MAP_START(z80_io_1_2, AS_IO, 8, digel804_state) |
| 486 | ADDRESS_MAP_UNMAP_HIGH |
| 487 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 488 | // io bits: x 1 x x x * * * |
| 489 | // 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 |
| 490 | AM_RANGE(0x40, 0x40) AM_MIRROR(0xB8) AM_READWRITE(ip40, op40) // RW, eprom socket data bus input/output value |
| 491 | AM_RANGE(0x41, 0x41) AM_MIRROR(0xB8) AM_WRITE(op41) // W, eprom socket address low out |
| 492 | AM_RANGE(0x42, 0x42) AM_MIRROR(0xB8) AM_WRITE(op42) // W, eprom socket address hi/control out |
| 468 | 493 | AM_RANGE(0x43, 0x43) AM_MIRROR(0xB8) AM_READWRITE(ip43, op43) // RW, mode and status register, also checks if keypad is pressed; write is unknown |
| 469 | 494 | AM_RANGE(0x44, 0x44) AM_MIRROR(0xB8) AM_WRITE(op44) // W, 10937 vfd controller, z80 power and state control reg |
| 470 | 495 | AM_RANGE(0x45, 0x45) AM_MIRROR(0xB8) AM_WRITE(op45) // W, speaker bit; every write inverts state |
| r15883 | r15884 | |
| 564 | 589 | /* basic machine hardware */ |
| 565 | 590 | MCFG_CPU_ADD("maincpu", Z80, XTAL_3_6864MHz/2) /* Z80A, X1(aka E0 on schematics): 3.6864Mhz */ |
| 566 | 591 | MCFG_CPU_PROGRAM_MAP(z80_mem_804_1_4) |
| 567 | | MCFG_CPU_IO_MAP(z80_io) |
| 592 | MCFG_CPU_IO_MAP(z80_io_1_4) |
| 568 | 593 | MCFG_QUANTUM_TIME(attotime::from_hz(60)) |
| 569 | 594 | |
| 570 | 595 | MCFG_ROC10937_ADD("vfd",0,RIGHT_TO_LEFT) |
| r15883 | r15884 | |
| 579 | 604 | /* acia */ |
| 580 | 605 | MCFG_ACIA6551_ADD("acia") |
| 581 | 606 | |
| 607 | MCFG_RAM_ADD(RAM_TAG) |
| 608 | MCFG_RAM_DEFAULT_SIZE("256K") |
| 609 | MCFG_RAM_EXTRA_OPTIONS("32K,64K,128K") |
| 610 | |
| 582 | 611 | /* sound hardware */ |
| 583 | 612 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 584 | 613 | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 585 | 614 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 586 | 615 | MACHINE_CONFIG_END |
| 587 | 616 | |
| 588 | | /* TODO: make this copy the digel804 machine config and modify the program map! */ |
| 589 | | static MACHINE_CONFIG_START( ep804, digel804_state ) |
| 617 | static MACHINE_CONFIG_DERIVED( ep804, digel804 ) |
| 590 | 618 | /* basic machine hardware */ |
| 591 | | MCFG_CPU_ADD("maincpu", Z80, XTAL_3_6864MHz/2) /* Z80, X1(aka E0 on schematics): 3.6864Mhz */ |
| 619 | MCFG_CPU_MODIFY("maincpu") /* Z80, X1(aka E0 on schematics): 3.6864Mhz */ |
| 592 | 620 | MCFG_CPU_PROGRAM_MAP(z80_mem_804_1_2) |
| 593 | | MCFG_CPU_IO_MAP(z80_io) |
| 594 | | MCFG_QUANTUM_TIME(attotime::from_hz(60)) |
| 621 | MCFG_CPU_IO_MAP(z80_io_1_2) |
| 595 | 622 | |
| 596 | | MCFG_ROC10937_ADD("vfd",0,RIGHT_TO_LEFT) |
| 597 | | |
| 598 | | /* video hardware */ |
| 599 | | MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, digel804_terminal_intf) |
| 600 | | |
| 601 | | MCFG_DEFAULT_LAYOUT(layout_digel804) |
| 602 | | |
| 603 | | MCFG_MM74C923_ADD("74c923", digel804_keypad_intf) |
| 604 | | |
| 605 | | /* acia */ |
| 606 | | MCFG_ACIA6551_ADD("acia") |
| 607 | | |
| 608 | | /* sound hardware */ |
| 609 | | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 610 | | MCFG_SOUND_ADD("speaker", SPEAKER_SOUND, 0) |
| 611 | | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.25) |
| 623 | MCFG_RAM_MODIFY(RAM_TAG) |
| 624 | MCFG_RAM_DEFAULT_SIZE("32K") |
| 625 | MCFG_RAM_EXTRA_OPTIONS("64K") |
| 612 | 626 | MACHINE_CONFIG_END |
| 613 | 627 | |
| 614 | 628 | |
| r15883 | r15884 | |
| 660 | 674 | */ |
| 661 | 675 | |
| 662 | 676 | ROM_START(digel804) // address mapper 804-1-4 |
| 663 | | ROM_REGION(0x80000, "user_ram", ROMREGION_ERASEFF) |
| 664 | 677 | ROM_REGION(0x10000, "maincpu", 0) |
| 665 | 678 | ROM_LOAD("1-04__76f1.27128.d41", 0x0000, 0x4000, CRC(61b50b61) SHA1(ad717fcbf3387b0a8fb0546025d3c527792eb3f0)) |
| 666 | 679 | // the second rom here is loaded bizarrely: the first 3/4 appears at e000-f7ff and the last 1/4 appears at d800-dfff |
| r15883 | r15884 | |
| 671 | 684 | ROM_END |
| 672 | 685 | |
| 673 | 686 | ROM_START(ep804) // address mapper 804-1-2 |
| 674 | | ROM_REGION(0x80000, "user_ram", ROMREGION_ERASEFF) |
| 675 | 687 | ROM_REGION(0x10000, "maincpu", 0) |
| 676 | 688 | ROM_DEFAULT_BIOS("ep804_v1.6") |
| 677 | 689 | ROM_SYSTEM_BIOS( 0, "ep804_v1.6", "Wavetek/Digelec EP804 FWv1.6") // hardware 1.1 |