src/mess/drivers/tvc.c
| r6195 | r6196 | |
| 12 | 12 | #include "devices/messram.h" |
| 13 | 13 | |
| 14 | 14 | static UINT8 tvc_video_mode = 0; |
| 15 | static UINT8 tvc_keyline = 0; |
| 16 | static UINT8 tvc_flipflop = 0xff; |
| 15 | 17 | |
| 16 | 18 | static void tvc_set_mem_page(running_machine *machine, UINT8 data) |
| 17 | 19 | { |
| r6195 | r6196 | |
| 50 | 52 | break; |
| 51 | 53 | case 0x80 : // RAM selected |
| 52 | 54 | memory_install_readwrite8_handler(space, 0xc000, 0xffff, 0, 0, SMH_BANK(4), SMH_BANK(4)); |
| 53 | | memory_set_bankptr(space->machine, 4, messram_get_ptr(devtag_get_device(machine, "messram"))); |
| 55 | memory_set_bankptr(space->machine, 4, messram_get_ptr(devtag_get_device(machine, "messram"))+0xc000); |
| 54 | 56 | break; |
| 55 | 57 | case 0xc0 : // External ROM selected |
| 56 | 58 | memory_install_readwrite8_handler(space, 0xc000, 0xffff, 0, 0, SMH_BANK(4), SMH_NOP); |
| r6195 | r6196 | |
| 74 | 76 | |
| 75 | 77 | static WRITE8_HANDLER( tvc_palette_w ) |
| 76 | 78 | { |
| 77 | | // 0 I 0 G | 0 R 0 B |
| 79 | // 0 I 0 R | 0 G 0 B |
| 78 | 80 | // 0 0 0 0 | I R G B |
| 79 | | int i = ((data&0x40)>>3) | ((data&0x10)>>3) | (data&0x04) | (data&0x01); |
| 81 | int i = ((data&0x40)>>3) | ((data&0x10)>>2) | ((data&0x04)>>1) | (data&0x01); |
| 80 | 82 | |
| 81 | 83 | col[offset] = i; |
| 82 | 84 | } |
| 83 | 85 | |
| 86 | static WRITE8_HANDLER( tvc_keyboard_w ) |
| 87 | { |
| 88 | tvc_keyline = data; |
| 89 | } |
| 90 | |
| 91 | static READ8_HANDLER( tvc_keyboard_r ) |
| 92 | { |
| 93 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7", |
| 94 | "LINE8", "LINE9", "LINEA", "LINEB", "LINEC", "LINED", "LINEE", "LINEF"}; |
| 95 | return input_port_read(space->machine, keynames[tvc_keyline & 0x0f]); |
| 96 | } |
| 97 | |
| 98 | static READ8_HANDLER( tvc_flipflop_r ) |
| 99 | { |
| 100 | return tvc_flipflop; |
| 101 | } |
| 102 | |
| 103 | static WRITE8_HANDLER( tvc_flipflop_w ) |
| 104 | { |
| 105 | tvc_flipflop |= 0x10; |
| 106 | } |
| 107 | static READ8_HANDLER( tvc_port59_r ) |
| 108 | { |
| 109 | return 0xff; |
| 110 | } |
| 111 | |
| 112 | static WRITE8_HANDLER( tvc_port0_w ) |
| 113 | { |
| 114 | } |
| 84 | 115 | static ADDRESS_MAP_START(tvc_mem, ADDRESS_SPACE_PROGRAM, 8) |
| 85 | 116 | AM_RANGE(0x0000, 0x3fff) AM_RAMBANK(1) |
| 86 | 117 | AM_RANGE(0x4000, 0x7fff) AM_RAMBANK(2) |
| r6195 | r6196 | |
| 91 | 122 | static ADDRESS_MAP_START( tvc_io , ADDRESS_SPACE_IO, 8) |
| 92 | 123 | ADDRESS_MAP_UNMAP_HIGH |
| 93 | 124 | ADDRESS_MAP_GLOBAL_MASK(0xff) |
| 125 | AM_RANGE(0x00, 0x00) AM_WRITE(tvc_port0_w) |
| 94 | 126 | AM_RANGE(0x02, 0x02) AM_WRITE(tvc_bank_w) |
| 127 | AM_RANGE(0x03, 0x03) AM_WRITE(tvc_keyboard_w) |
| 95 | 128 | AM_RANGE(0x06, 0x06) AM_WRITE(tvc_video_mode_w) |
| 129 | AM_RANGE(0x07, 0x07) AM_WRITE(tvc_flipflop_w) |
| 130 | AM_RANGE(0x58, 0x58) AM_READ(tvc_keyboard_r) |
| 131 | AM_RANGE(0x59, 0x59) AM_READ(tvc_flipflop_r) |
| 132 | AM_RANGE(0x5a, 0x5a) AM_READ(tvc_port59_r) |
| 96 | 133 | AM_RANGE(0x60, 0x64) AM_WRITE(tvc_palette_w) |
| 97 | 134 | AM_RANGE(0x70, 0x70) AM_DEVWRITE("crtc", mc6845_address_w) |
| 98 | 135 | AM_RANGE(0x71, 0x71) AM_DEVREADWRITE("crtc", mc6845_register_r , mc6845_register_w) |
| r6195 | r6196 | |
| 100 | 137 | |
| 101 | 138 | /* Input ports */ |
| 102 | 139 | static INPUT_PORTS_START( tvc ) |
| 140 | PORT_START("LINE0") |
| 141 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("5") PORT_CODE(KEYCODE_5) |
| 142 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("3") PORT_CODE(KEYCODE_3) |
| 143 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("2") PORT_CODE(KEYCODE_2) |
| 144 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("0") PORT_CODE(KEYCODE_0) |
| 145 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("6") PORT_CODE(KEYCODE_6) |
| 146 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("I'") PORT_CODE(KEYCODE_TILDE) |
| 147 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("1") PORT_CODE(KEYCODE_1) |
| 148 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("4") PORT_CODE(KEYCODE_4) |
| 149 | PORT_START("LINE1") |
| 150 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("^") PORT_CODE(KEYCODE_TILDE) |
| 151 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("8") PORT_CODE(KEYCODE_8) |
| 152 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("9") PORT_CODE(KEYCODE_9) |
| 153 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("u''") PORT_CODE(KEYCODE_TILDE) |
| 154 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("*") PORT_CODE(KEYCODE_TILDE) |
| 155 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("O'") PORT_CODE(KEYCODE_TILDE) |
| 156 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("O''") PORT_CODE(KEYCODE_TILDE) |
| 157 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("7") PORT_CODE(KEYCODE_7) |
| 158 | PORT_START("LINE2") |
| 159 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("T") PORT_CODE(KEYCODE_T) |
| 160 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("E") PORT_CODE(KEYCODE_E) |
| 161 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("W") PORT_CODE(KEYCODE_W) |
| 162 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(";") PORT_CODE(KEYCODE_COLON) |
| 163 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Z") PORT_CODE(KEYCODE_Z) |
| 164 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("@") PORT_CODE(KEYCODE_TILDE) |
| 165 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Q") PORT_CODE(KEYCODE_Q) |
| 166 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("R") PORT_CODE(KEYCODE_R) |
| 167 | PORT_START("LINE3") |
| 168 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("]") PORT_CODE(KEYCODE_CLOSEBRACE) |
| 169 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("I") PORT_CODE(KEYCODE_I) |
| 170 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("O") PORT_CODE(KEYCODE_O) |
| 171 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("?") PORT_CODE(KEYCODE_SLASH) |
| 172 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("[") PORT_CODE(KEYCODE_OPENBRACE) |
| 173 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("U'") PORT_CODE(KEYCODE_TILDE) |
| 174 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("P") PORT_CODE(KEYCODE_P) |
| 175 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("U") PORT_CODE(KEYCODE_U) |
| 176 | PORT_START("LINE4") |
| 177 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("G") PORT_CODE(KEYCODE_G) |
| 178 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("D") PORT_CODE(KEYCODE_D) |
| 179 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("S") PORT_CODE(KEYCODE_S) |
| 180 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("\\") PORT_CODE(KEYCODE_BACKSLASH) |
| 181 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("H") PORT_CODE(KEYCODE_H) |
| 182 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("<") PORT_CODE(KEYCODE_TILDE) |
| 183 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A") PORT_CODE(KEYCODE_A) |
| 184 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("F") PORT_CODE(KEYCODE_F) |
| 185 | PORT_START("LINE5") |
| 186 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Backspace") PORT_CODE(KEYCODE_BACKSPACE) |
| 187 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("K") PORT_CODE(KEYCODE_K) |
| 188 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("L") PORT_CODE(KEYCODE_L) |
| 189 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("A'") PORT_CODE(KEYCODE_TILDE) |
| 190 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Enter") PORT_CODE(KEYCODE_ENTER) |
| 191 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("u''") PORT_CODE(KEYCODE_TILDE) |
| 192 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("e'") PORT_CODE(KEYCODE_TILDE) |
| 193 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("J") PORT_CODE(KEYCODE_J) |
| 194 | PORT_START("LINE6") |
| 195 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("B") PORT_CODE(KEYCODE_B) |
| 196 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("C") PORT_CODE(KEYCODE_C) |
| 197 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("X") PORT_CODE(KEYCODE_X) |
| 198 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Shift") PORT_CODE(KEYCODE_RSHIFT) PORT_CODE(KEYCODE_LSHIFT) |
| 199 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("N") PORT_CODE(KEYCODE_N) |
| 200 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Lock") PORT_CODE(KEYCODE_CAPSLOCK) |
| 201 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Y") PORT_CODE(KEYCODE_Y) |
| 202 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("V") PORT_CODE(KEYCODE_V) |
| 203 | PORT_START("LINE7") |
| 204 | PORT_BIT(0x01, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Alt") PORT_CODE(KEYCODE_RALT) PORT_CODE(KEYCODE_LALT) |
| 205 | PORT_BIT(0x02, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(",") PORT_CODE(KEYCODE_COMMA) |
| 206 | PORT_BIT(0x04, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME(".") PORT_CODE(KEYCODE_STOP) |
| 207 | PORT_BIT(0x08, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Esc") PORT_CODE(KEYCODE_ESC) |
| 208 | PORT_BIT(0x10, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Ctrl") PORT_CODE(KEYCODE_LCONTROL) PORT_CODE(KEYCODE_RCONTROL) |
| 209 | PORT_BIT(0x20, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("Space") PORT_CODE(KEYCODE_SPACE) |
| 210 | PORT_BIT(0x40, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("=") PORT_CODE(KEYCODE_EQUALS) |
| 211 | PORT_BIT(0x80, IP_ACTIVE_LOW, IPT_KEYBOARD) PORT_NAME("M") PORT_CODE(KEYCODE_M) |
| 212 | PORT_START("LINE8") |
| 213 | PORT_BIT(0xFF, IP_ACTIVE_LOW, IPT_UNUSED) |
| 214 | PORT_START("LINE9") |
| 215 | PORT_BIT(0xFF, IP_ACTIVE_LOW, IPT_UNUSED) |
| 216 | PORT_START("LINEA") |
| 217 | PORT_BIT(0xFF, IP_ACTIVE_LOW, IPT_UNUSED) |
| 218 | PORT_START("LINEB") |
| 219 | PORT_BIT(0xFF, IP_ACTIVE_LOW, IPT_UNUSED) |
| 220 | PORT_START("LINEC") |
| 221 | PORT_BIT(0xFF, IP_ACTIVE_LOW, IPT_UNUSED) |
| 222 | PORT_START("LINED") |
| 223 | PORT_BIT(0xFF, IP_ACTIVE_LOW, IPT_UNUSED) |
| 224 | PORT_START("LINEE") |
| 225 | PORT_BIT(0xFF, IP_ACTIVE_LOW, IPT_UNUSED) |
| 226 | PORT_START("LINEF") |
| 227 | PORT_BIT(0xFF, IP_ACTIVE_LOW, IPT_UNUSED) |
| 103 | 228 | INPUT_PORTS_END |
| 104 | 229 | |
| 105 | 230 | |
| r6195 | r6196 | |
| 217 | 342 | NULL |
| 218 | 343 | }; |
| 219 | 344 | |
| 345 | INTERRUPT_GEN( tvc_interrupt ) |
| 346 | { |
| 347 | tvc_flipflop &= ~0x10; |
| 348 | cpu_set_input_line(device, 0, HOLD_LINE); |
| 349 | } |
| 350 | |
| 220 | 351 | static MACHINE_DRIVER_START( tvc ) |
| 221 | 352 | /* basic machine hardware */ |
| 222 | 353 | MDRV_CPU_ADD("maincpu",Z80, 3125000) |
| r6195 | r6196 | |
| 225 | 356 | |
| 226 | 357 | MDRV_MACHINE_RESET(tvc) |
| 227 | 358 | |
| 359 | MDRV_CPU_VBLANK_INT("screen", tvc_interrupt) |
| 360 | |
| 228 | 361 | /* video hardware */ |
| 229 | 362 | MDRV_SCREEN_ADD("screen", RASTER) |
| 230 | 363 | MDRV_SCREEN_REFRESH_RATE(50) |