src/mess/drivers/zrt80.c
| r10463 | r10464 | |
| 4 | 4 | |
| 5 | 5 | 12/05/2009 Skeleton driver. |
| 6 | 6 | |
| 7 | 16/02/2011 Working. |
| 8 | |
| 9 | The beeper is external, frequency not known. I've made a reasonable |
| 10 | assumption of frequency and lengths. |
| 11 | |
| 12 | Make sure 'mode' dipswitch is set to 'local' so you can see your |
| 13 | typing. |
| 14 | |
| 7 | 15 | ****************************************************************************/ |
| 16 | #define ADDRESS_MAP_MODERN |
| 8 | 17 | |
| 9 | 18 | #include "emu.h" |
| 10 | 19 | #include "cpu/z80/z80.h" |
| 11 | 20 | #include "video/mc6845.h" |
| 12 | 21 | #include "machine/ins8250.h" |
| 22 | #include "machine/terminal.h" |
| 23 | #include "sound/beep.h" |
| 13 | 24 | |
| 14 | 25 | |
| 15 | 26 | class zrt80_state : public driver_device |
| 16 | 27 | { |
| 17 | 28 | public: |
| 18 | 29 | zrt80_state(running_machine &machine, const driver_device_config_base &config) |
| 19 | | : driver_device(machine, config) { } |
| 30 | : driver_device(machine, config), |
| 31 | m_maincpu(*this, "maincpu"), |
| 32 | m_terminal(*this, TERMINAL_TAG), |
| 33 | m_crtc(*this, "crtc"), |
| 34 | m_8250(*this, "ins8250"), |
| 35 | m_beep(*this, "beep") |
| 36 | { } |
| 20 | 37 | |
| 21 | | UINT8 *video_ram; |
| 38 | required_device<cpu_device> m_maincpu; |
| 39 | required_device<device_t> m_terminal; |
| 40 | required_device<device_t> m_crtc; |
| 41 | required_device<device_t> m_8250; |
| 42 | required_device<device_t> m_beep; |
| 43 | DECLARE_READ8_MEMBER( zrt80_10_r ); |
| 44 | DECLARE_WRITE8_MEMBER( zrt80_30_w ); |
| 45 | DECLARE_WRITE8_MEMBER( zrt80_38_w ); |
| 46 | DECLARE_WRITE8_MEMBER( zrt80_kbd_put ); |
| 47 | UINT8 term_data; |
| 48 | UINT8 *videoram; |
| 49 | UINT8 *FNT; |
| 22 | 50 | }; |
| 23 | 51 | |
| 52 | READ8_MEMBER( zrt80_state::zrt80_10_r ) |
| 53 | { |
| 54 | UINT8 ret = term_data; |
| 55 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, CLEAR_LINE); |
| 56 | return ret; |
| 57 | } |
| 24 | 58 | |
| 59 | static TIMER_CALLBACK( zrt80_beepoff ) |
| 60 | { |
| 61 | zrt80_state *state = machine->driver_data<zrt80_state>(); |
| 62 | beep_set_state(state->m_beep, 0); |
| 63 | } |
| 25 | 64 | |
| 26 | | static ADDRESS_MAP_START(zrt80_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 65 | WRITE8_MEMBER(zrt80_state::zrt80_30_w) |
| 66 | { |
| 67 | machine->scheduler().timer_set(attotime::from_msec(100), FUNC(zrt80_beepoff)); |
| 68 | beep_set_state(m_beep, 1); |
| 69 | } |
| 70 | |
| 71 | WRITE8_MEMBER(zrt80_state::zrt80_38_w) |
| 72 | { |
| 73 | machine->scheduler().timer_set(attotime::from_msec(400), FUNC(zrt80_beepoff)); |
| 74 | beep_set_state(m_beep, 1); |
| 75 | } |
| 76 | |
| 77 | static ADDRESS_MAP_START(zrt80_mem, ADDRESS_SPACE_PROGRAM, 8, zrt80_state) |
| 27 | 78 | ADDRESS_MAP_UNMAP_HIGH |
| 28 | 79 | AM_RANGE(0x0000, 0x0fff) AM_ROM // Z25 - Main firmware |
| 29 | 80 | AM_RANGE(0x1000, 0x1fff) AM_ROM // Z24 - Expansion |
| 30 | 81 | AM_RANGE(0x4000, 0x43ff) AM_RAM // Board RAM |
| 31 | | // Normaly video RAM is 0x800 but could be expanded up to 8K |
| 32 | | AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE_MEMBER(zrt80_state, video_ram) // Video RAM |
| 82 | // Normally video RAM is 0x800 but could be expanded up to 8K |
| 83 | AM_RANGE(0xc000, 0xdfff) AM_RAM AM_BASE(videoram) // Video RAM |
| 33 | 84 | |
| 34 | 85 | ADDRESS_MAP_END |
| 35 | 86 | |
| 36 | | static ADDRESS_MAP_START( zrt80_io , ADDRESS_SPACE_IO, 8) |
| 87 | static ADDRESS_MAP_START( zrt80_io, ADDRESS_SPACE_IO, 8, zrt80_state) |
| 37 | 88 | ADDRESS_MAP_UNMAP_HIGH |
| 38 | 89 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 39 | | AM_RANGE(0x00, 0x07) AM_DEVREADWRITE("ins8250", ins8250_r, ins8250_w ) |
| 40 | | AM_RANGE(0x08, 0x08) AM_DEVWRITE("crtc", mc6845_address_w) |
| 41 | | AM_RANGE(0x09, 0x09) AM_DEVREADWRITE("crtc", mc6845_register_r , mc6845_register_w) |
| 42 | | AM_RANGE(0x18, 0x18) AM_READ_PORT("DIPSW2") |
| 43 | | AM_RANGE(0x20, 0x20) AM_READ_PORT("DIPSW3") |
| 90 | AM_RANGE(0x00, 0x07) AM_DEVREADWRITE_LEGACY("ins8250", ins8250_r, ins8250_w ) |
| 91 | AM_RANGE(0x08, 0x08) AM_DEVWRITE_LEGACY("crtc", mc6845_address_w) |
| 92 | AM_RANGE(0x09, 0x09) AM_DEVREADWRITE_LEGACY("crtc", mc6845_register_r, mc6845_register_w) |
| 93 | AM_RANGE(0x10, 0x17) AM_READ(zrt80_10_r) |
| 94 | AM_RANGE(0x18, 0x1F) AM_READ_PORT("DIPSW2") |
| 95 | AM_RANGE(0x20, 0x27) AM_READ_PORT("DIPSW3") |
| 96 | AM_RANGE(0x30, 0x37) AM_WRITE(zrt80_30_w) |
| 97 | AM_RANGE(0x38, 0x3F) AM_WRITE(zrt80_38_w) |
| 44 | 98 | ADDRESS_MAP_END |
| 45 | 99 | |
| 46 | 100 | /* Input ports */ |
| r10463 | r10464 | |
| 114 | 168 | PORT_DIPSETTING( 0x08, "Beehive" ) |
| 115 | 169 | PORT_DIPSETTING( 0x10, "LSI ADM-3" ) |
| 116 | 170 | PORT_DIPSETTING( 0x18, "Heath H-19" ) |
| 117 | | PORT_DIPNAME( 0x20, 0x20, "Mode" ) |
| 171 | PORT_DIPNAME( 0x20, 0x00, "Mode" ) |
| 118 | 172 | PORT_DIPSETTING( 0x20, "Line" ) |
| 119 | 173 | PORT_DIPSETTING( 0x00, "Local" ) |
| 120 | 174 | PORT_DIPNAME( 0x40, 0x40, "Duplex" ) |
| r10463 | r10464 | |
| 128 | 182 | |
| 129 | 183 | static MACHINE_RESET(zrt80) |
| 130 | 184 | { |
| 185 | zrt80_state *state = machine->driver_data<zrt80_state>(); |
| 186 | beep_set_frequency(state->m_beep, 800); |
| 131 | 187 | } |
| 132 | 188 | |
| 133 | 189 | static VIDEO_START( zrt80 ) |
| 134 | 190 | { |
| 191 | zrt80_state *state = machine->driver_data<zrt80_state>(); |
| 192 | state->FNT = machine->region("chargen")->base(); |
| 135 | 193 | } |
| 136 | 194 | |
| 137 | 195 | static VIDEO_UPDATE( zrt80 ) |
| r10463 | r10464 | |
| 144 | 202 | static MC6845_UPDATE_ROW( zrt80_update_row ) |
| 145 | 203 | { |
| 146 | 204 | zrt80_state *state = device->machine->driver_data<zrt80_state>(); |
| 147 | | UINT8 *charrom = device->machine->region("chargen")->base(); |
| 205 | UINT8 chr,gfx,inv; |
| 206 | UINT16 mem,x; |
| 207 | UINT16 *p = BITMAP_ADDR16(bitmap, y, 0); |
| 208 | UINT8 polarity = input_port_read(device->machine, "DIPSW1") & 4 ? 0xff : 0; |
| 148 | 209 | |
| 149 | | int column, bit; |
| 150 | | |
| 151 | | for (column = 0; column < x_count; column++) |
| 210 | for (x = 0; x < x_count; x++) |
| 152 | 211 | { |
| 153 | | UINT8 code = state->video_ram[ma + column] & 0x7f; |
| 154 | | UINT16 addr = code << 4 | (ra & 0x0f); |
| 155 | | UINT8 data = charrom[addr & 0x7ff]; |
| 212 | inv = polarity; |
| 213 | if (x == cursor_x) inv ^= 0xff; |
| 214 | mem = (ma + x) & 0x1fff; |
| 215 | chr = state->videoram[mem]; |
| 156 | 216 | |
| 157 | | for (bit = 0; bit < 8; bit++) |
| 217 | if BIT(chr, 7) |
| 158 | 218 | { |
| 159 | | int x = (column * 8) + bit; |
| 160 | | int color = BIT(data, 7) ? 1 : 0; |
| 161 | | if (input_port_read(device->machine, "DIPSW1") & 0x04) { |
| 162 | | color = color ? 0 : 1; |
| 163 | | } |
| 219 | inv ^= 0xff; |
| 220 | chr &= 0x7f; |
| 221 | } |
| 164 | 222 | |
| 165 | | *BITMAP_ADDR16(bitmap, y, x) = color; |
| 223 | gfx = state->FNT[(chr<<4) | ra] ^ inv; |
| 166 | 224 | |
| 167 | | data <<= 1; |
| 168 | | } |
| 225 | /* Display a scanline of a character */ |
| 226 | *p++ = ( gfx & 0x80 ) ? 1 : 0; |
| 227 | *p++ = ( gfx & 0x40 ) ? 1 : 0; |
| 228 | *p++ = ( gfx & 0x20 ) ? 1 : 0; |
| 229 | *p++ = ( gfx & 0x10 ) ? 1 : 0; |
| 230 | *p++ = ( gfx & 0x08 ) ? 1 : 0; |
| 231 | *p++ = ( gfx & 0x04 ) ? 1 : 0; |
| 232 | *p++ = ( gfx & 0x02 ) ? 1 : 0; |
| 233 | *p++ = ( gfx & 0x01 ) ? 1 : 0; |
| 169 | 234 | } |
| 170 | 235 | } |
| 171 | 236 | |
| r10463 | r10464 | |
| 186 | 251 | static INS8250_INTERRUPT( zrt80_com_interrupt ) |
| 187 | 252 | { |
| 188 | 253 | logerror("com int\r\n"); |
| 254 | cputag_set_input_line(device->machine, "maincpu", INPUT_LINE_IRQ0, state); |
| 189 | 255 | } |
| 190 | 256 | |
| 191 | 257 | static const ins8250_interface zrt80_com_interface = |
| r10463 | r10464 | |
| 197 | 263 | NULL |
| 198 | 264 | }; |
| 199 | 265 | |
| 266 | WRITE8_MEMBER( zrt80_state::zrt80_kbd_put ) |
| 267 | { |
| 268 | term_data = data; |
| 269 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_NMI, ASSERT_LINE); |
| 270 | } |
| 271 | |
| 272 | static GENERIC_TERMINAL_INTERFACE( zrt80_terminal_intf ) |
| 273 | { |
| 274 | DEVCB_DRIVER_MEMBER(zrt80_state, zrt80_kbd_put) |
| 275 | }; |
| 276 | |
| 277 | |
| 200 | 278 | /* F4 Character Displayer */ |
| 201 | 279 | static const gfx_layout zrt80_charlayout = |
| 202 | 280 | { |
| r10463 | r10464 | |
| 240 | 318 | MCFG_VIDEO_UPDATE(zrt80) |
| 241 | 319 | |
| 242 | 320 | MCFG_INS8250_ADD( "ins8250", zrt80_com_interface ) |
| 321 | MCFG_GENERIC_TERMINAL_ADD(TERMINAL_TAG, zrt80_terminal_intf) |
| 322 | |
| 323 | /* sound hardware */ |
| 324 | MCFG_SPEAKER_STANDARD_MONO("mono") |
| 325 | MCFG_SOUND_ADD("beep", BEEP, 0) |
| 326 | MCFG_SOUND_ROUTE(ALL_OUTPUTS, "mono", 0.50) |
| 243 | 327 | MACHINE_CONFIG_END |
| 244 | 328 | |
| 245 | 329 | /* ROM definition */ |
| r10463 | r10464 | |
| 247 | 331 | ROM_REGION( 0x10000, "maincpu", ROMREGION_ERASEFF ) |
| 248 | 332 | ROM_LOAD( "zrt80mon.z25", 0x0000, 0x1000, CRC(e6ea96dc) SHA1(e3075e30bb2b85f9288d0b8b8cdf1d2b4f7586fd)) |
| 249 | 333 | //z24 is 2nd chip, used as expansion |
| 334 | |
| 250 | 335 | ROM_REGION( 0x0800, "chargen", 0 ) |
| 251 | 336 | ROM_LOAD( "zrt80chr.z30", 0x0000, 0x0800, CRC(4dbdc60f) SHA1(20e393f7207a8440029c8290cdf2f121d317a37e)) |
| 252 | 337 | ROM_END |
| r10463 | r10464 | |
| 254 | 339 | /* Driver */ |
| 255 | 340 | |
| 256 | 341 | /* YEAR NAME PARENT COMPAT MACHINE INPUT INIT COMPANY FULLNAME FLAGS */ |
| 257 | | COMP( 1982, zrt80, 0, 0, zrt80, zrt80, 0, "Digital Research Computers", "ZRT-80", GAME_NOT_WORKING | GAME_NO_SOUND) |
| 342 | COMP( 1982, zrt80, 0, 0, zrt80, zrt80, 0, "Digital Research Computers", "ZRT-80", 0) |
| 258 | 343 | |