src/mess/machine/geneve.c
| r3832 | r3833 | |
| 5 | 5 | |
| 6 | 6 | #include <math.h> |
| 7 | 7 | #include "driver.h" |
| 8 | | #include "deprecat.h" |
| 9 | 8 | #include "tms9901.h" |
| 10 | 9 | #include "mm58274c.h" |
| 11 | 10 | #include "video/v9938.h" |
| r3832 | r3833 | |
| 31 | 30 | static void poll_keyboard(running_machine *machine); |
| 32 | 31 | static void poll_mouse(running_machine *machine); |
| 33 | 32 | |
| 34 | | static void tms9901_interrupt_callback(const device_config *device,int intreq, int ic); |
| 35 | | static int R9901_0(int offset); |
| 36 | | static int R9901_1(int offset); |
| 37 | | static int R9901_2(int offset); |
| 38 | | static int R9901_3(int offset); |
| 39 | | |
| 40 | | static void W9901_PE_bus_reset(int offset, int data); |
| 41 | | static void W9901_VDP_reset(int offset, int data); |
| 42 | | static void W9901_JoySel(int offset, int data); |
| 43 | | static void W9901_KeyboardReset(int offset, int data); |
| 44 | | static void W9901_ext_mem_wait_states(int offset, int data); |
| 45 | | static void W9901_VDP_wait_states(int offset, int data); |
| 46 | | |
| 47 | 33 | /* |
| 48 | 34 | pointers to memory areas |
| 49 | 35 | */ |
| r3832 | r3833 | |
| 75 | 61 | /* TRUE if we are using the alternative boot ROM */ |
| 76 | 62 | static char has_alt_boot; |
| 77 | 63 | |
| 78 | | /* tms9901 setup */ |
| 79 | | const tms9901_interface tms9901reset_param_ti99 = |
| 80 | | { |
| 81 | | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INT8 | TMS9901_INTB | TMS9901_INTC, /* only input pins whose state is always known */ |
| 82 | | |
| 83 | | { /* read handlers */ |
| 84 | | R9901_0, |
| 85 | | R9901_1, |
| 86 | | R9901_2, |
| 87 | | R9901_3 |
| 88 | | }, |
| 89 | | |
| 90 | | { /* write handlers */ |
| 91 | | W9901_PE_bus_reset, |
| 92 | | W9901_VDP_reset, |
| 93 | | W9901_JoySel, |
| 94 | | NULL, |
| 95 | | NULL, |
| 96 | | NULL, |
| 97 | | W9901_KeyboardReset, |
| 98 | | W9901_ext_mem_wait_states, |
| 99 | | NULL, |
| 100 | | W9901_VDP_wait_states, |
| 101 | | NULL, |
| 102 | | NULL, |
| 103 | | NULL, |
| 104 | | NULL, |
| 105 | | NULL, |
| 106 | | NULL |
| 107 | | }, |
| 108 | | |
| 109 | | /* interrupt handler */ |
| 110 | | tms9901_interrupt_callback, |
| 111 | | |
| 112 | | /* clock rate = 3MHz */ |
| 113 | | 3000000. |
| 114 | | }; |
| 115 | | |
| 116 | 64 | /* keyboard interface */ |
| 117 | 65 | static int JoySel; |
| 118 | 66 | enum |
| r3832 | r3833 | |
| 1339 | 1287 | /* |
| 1340 | 1288 | Called by the 9901 core whenever the state of INTREQ and IC0-3 changes |
| 1341 | 1289 | */ |
| 1342 | | static void tms9901_interrupt_callback(const device_config *device, int intreq, int ic) |
| 1290 | static TMS9910_INT_CALLBACK( tms9901_interrupt_callback ) |
| 1343 | 1291 | { |
| 1344 | 1292 | /* INTREQ is connected to INT1 (IC0-3 are not connected) */ |
| 1345 | 1293 | cpu_set_input_line(device->machine->cpu[0], 0, intreq ? ASSERT_LINE : CLEAR_LINE); |
| r3832 | r3833 | |
| 1353 | 1301 | (bit 2: INT2 status) |
| 1354 | 1302 | bit 3-7: joystick status |
| 1355 | 1303 | */ |
| 1356 | | static int R9901_0(int offset) |
| 1304 | static READ8_HANDLER( R9901_0 ) |
| 1357 | 1305 | { |
| 1358 | 1306 | int answer; |
| 1359 | 1307 | |
| 1360 | | answer = input_port_read(Machine, "JOY") >> (JoySel * 8); |
| 1308 | answer = input_port_read(space->machine, "JOY") >> (JoySel * 8); |
| 1361 | 1309 | |
| 1362 | 1310 | return (answer); |
| 1363 | 1311 | } |
| r3832 | r3833 | |
| 1374 | 1322 | bit 5 & 7: used as output |
| 1375 | 1323 | bit 6: unused |
| 1376 | 1324 | */ |
| 1377 | | static int R9901_1(int offset) |
| 1325 | static READ8_HANDLER( R9901_1 ) |
| 1378 | 1326 | { |
| 1379 | 1327 | int answer; |
| 1380 | 1328 | |
| 1381 | | answer = (input_port_read(Machine, "MOUSE0") & 4) ^ 4; |
| 1329 | answer = (input_port_read(space->machine, "MOUSE0") & 4) ^ 4; |
| 1382 | 1330 | |
| 1383 | 1331 | return answer; |
| 1384 | 1332 | } |
| r3832 | r3833 | |
| 1386 | 1334 | /* |
| 1387 | 1335 | Read pins P0-P7 of Geneve 9901. |
| 1388 | 1336 | */ |
| 1389 | | static int R9901_2(int offset) |
| 1337 | static READ8_HANDLER( R9901_2 ) |
| 1390 | 1338 | { |
| 1391 | 1339 | return 0; |
| 1392 | 1340 | } |
| r3832 | r3833 | |
| 1395 | 1343 | Read pins P8-P15 of Geneve 9901. |
| 1396 | 1344 | bit 4: mouse right button |
| 1397 | 1345 | */ |
| 1398 | | static int R9901_3(int offset) |
| 1346 | static READ8_HANDLER( R9901_3 ) |
| 1399 | 1347 | { |
| 1400 | 1348 | int answer = 0; |
| 1401 | 1349 | |
| 1402 | | if (! (input_port_read(Machine, "MOUSE0") & 4)) |
| 1350 | if (! (input_port_read(space->machine, "MOUSE0") & 4)) |
| 1403 | 1351 | answer |= 0x10; |
| 1404 | 1352 | |
| 1405 | 1353 | return answer; |
| r3832 | r3833 | |
| 1409 | 1357 | /* |
| 1410 | 1358 | Write PE bus reset line |
| 1411 | 1359 | */ |
| 1412 | | static void W9901_PE_bus_reset(int offset, int data) |
| 1360 | static WRITE8_HANDLER( W9901_PE_bus_reset ) |
| 1413 | 1361 | { |
| 1414 | 1362 | } |
| 1415 | 1363 | |
| 1416 | 1364 | /* |
| 1417 | 1365 | Write VDP reset line |
| 1418 | 1366 | */ |
| 1419 | | static void W9901_VDP_reset(int offset, int data) |
| 1367 | static WRITE8_HANDLER( W9901_VDP_reset ) |
| 1420 | 1368 | { |
| 1421 | 1369 | } |
| 1422 | 1370 | |
| 1423 | 1371 | /* |
| 1424 | 1372 | Write joystick select line |
| 1425 | 1373 | */ |
| 1426 | | static void W9901_JoySel(int offset, int data) |
| 1374 | static WRITE8_HANDLER( W9901_JoySel ) |
| 1427 | 1375 | { |
| 1428 | 1376 | JoySel = data; |
| 1429 | 1377 | } |
| 1430 | 1378 | |
| 1431 | | static void W9901_KeyboardReset(int offset, int data) |
| 1379 | static WRITE8_HANDLER( W9901_KeyboardReset ) |
| 1432 | 1380 | { |
| 1433 | 1381 | KeyReset = ! data; |
| 1434 | 1382 | if (KeyReset) |
| r3832 | r3833 | |
| 1445 | 1393 | KeyAutoRepeatKey = 0; |
| 1446 | 1394 | } |
| 1447 | 1395 | /*else |
| 1448 | | poll_keyboard(Machine);*/ |
| 1396 | poll_keyboard(space->machine);*/ |
| 1449 | 1397 | } |
| 1450 | 1398 | |
| 1451 | 1399 | /* |
| 1452 | 1400 | Write external mem cycles (0=long, 1=short) |
| 1453 | 1401 | */ |
| 1454 | | static void W9901_ext_mem_wait_states(int offset, int data) |
| 1402 | static WRITE8_HANDLER( W9901_ext_mem_wait_states ) |
| 1455 | 1403 | { |
| 1456 | 1404 | } |
| 1457 | 1405 | |
| 1458 | 1406 | /* |
| 1459 | 1407 | Write vdp wait cycles (1=add 15 cycles, 0=add none) |
| 1460 | 1408 | */ |
| 1461 | | static void W9901_VDP_wait_states(int offset, int data) |
| 1409 | static WRITE8_HANDLER( W9901_VDP_wait_states ) |
| 1462 | 1410 | { |
| 1463 | 1411 | } |
| 1464 | 1412 | |
| 1413 | /* tms9901 setup */ |
| 1414 | const tms9901_interface tms9901reset_param_ti99 = |
| 1415 | { |
| 1416 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INT8 | TMS9901_INTB | TMS9901_INTC, /* only input pins whose state is always known */ |
| 1465 | 1417 | |
| 1418 | { /* read handlers */ |
| 1419 | R9901_0, |
| 1420 | R9901_1, |
| 1421 | R9901_2, |
| 1422 | R9901_3 |
| 1423 | }, |
| 1466 | 1424 | |
| 1425 | { /* write handlers */ |
| 1426 | W9901_PE_bus_reset, |
| 1427 | W9901_VDP_reset, |
| 1428 | W9901_JoySel, |
| 1429 | NULL, |
| 1430 | NULL, |
| 1431 | NULL, |
| 1432 | W9901_KeyboardReset, |
| 1433 | W9901_ext_mem_wait_states, |
| 1434 | NULL, |
| 1435 | W9901_VDP_wait_states, |
| 1436 | NULL, |
| 1437 | NULL, |
| 1438 | NULL, |
| 1439 | NULL, |
| 1440 | NULL, |
| 1441 | NULL |
| 1442 | }, |
| 1443 | |
| 1444 | /* interrupt handler */ |
| 1445 | tms9901_interrupt_callback, |
| 1446 | |
| 1447 | /* clock rate = 3MHz */ |
| 1448 | 3000000. |
| 1449 | }; |
| 1450 | |
| 1451 | |
src/mess/machine/ti99_4x.c
| r3832 | r3833 | |
| 77 | 77 | static WRITE16_HANDLER ( ti99_wspeech_w ); |
| 78 | 78 | |
| 79 | 79 | static void tms9901_set_int1(running_machine *machine, int state); |
| 80 | | static void tms9901_interrupt_callback(const device_config *device, int intreq, int ic); |
| 81 | | static int ti99_R9901_0(int offset); |
| 82 | | static int ti99_R9901_1(int offset); |
| 83 | | static int ti99_R9901_2(int offset); |
| 84 | | static int ti99_R9901_3(int offset); |
| 85 | 80 | |
| 86 | | static void ti99_handset_set_ack(int offset, int data); |
| 87 | 81 | static void ti99_handset_task(running_machine *machine); |
| 88 | 82 | static void mecmouse_poll(running_machine *machine); |
| 89 | | static void ti99_KeyC(int offset, int data); |
| 90 | | static void ti99_AlphaW(int offset, int data); |
| 91 | 83 | |
| 92 | | static int ti99_8_R9901_0(int offset); |
| 93 | | static int ti99_8_R9901_1(int offset); |
| 94 | | static void ti99_8_KeyC(int offset, int data); |
| 95 | | static void ti99_8_WCRUS(int offset, int data); |
| 96 | | static void ti99_8_PTGEN(int offset, int data); |
| 97 | | |
| 98 | | static void ti99_CS_motor(int offset, int data); |
| 99 | | static void ti99_audio_gate(int offset, int data); |
| 100 | | static void ti99_CS_output(int offset, int data); |
| 101 | | |
| 102 | 84 | static void ti99_8_internal_dsr_reset(running_machine *machine); |
| 103 | 85 | |
| 104 | 86 | static void ti99_4p_internal_dsr_reset(running_machine *machine); |
| r3832 | r3833 | |
| 145 | 127 | /* TRUE if usb-sm card present */ |
| 146 | 128 | static char has_usb_sm; |
| 147 | 129 | |
| 148 | | |
| 149 | | /* tms9901 setup */ |
| 150 | | const tms9901_interface tms9901reset_param_ti99_4x = |
| 151 | | { |
| 152 | | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 153 | | |
| 154 | | { /* read handlers */ |
| 155 | | ti99_R9901_0, |
| 156 | | ti99_R9901_1, |
| 157 | | ti99_R9901_2, |
| 158 | | ti99_R9901_3 |
| 159 | | }, |
| 160 | | |
| 161 | | { /* write handlers */ |
| 162 | | ti99_handset_set_ack, |
| 163 | | NULL, |
| 164 | | ti99_KeyC, |
| 165 | | ti99_KeyC, |
| 166 | | ti99_KeyC, |
| 167 | | ti99_AlphaW, |
| 168 | | ti99_CS_motor, |
| 169 | | ti99_CS_motor, |
| 170 | | ti99_audio_gate, |
| 171 | | ti99_CS_output, |
| 172 | | NULL, |
| 173 | | NULL, |
| 174 | | NULL, |
| 175 | | NULL, |
| 176 | | NULL, |
| 177 | | NULL |
| 178 | | }, |
| 179 | | |
| 180 | | /* interrupt handler */ |
| 181 | | tms9901_interrupt_callback, |
| 182 | | |
| 183 | | /* clock rate = 3MHz */ |
| 184 | | 3000000. |
| 185 | | }; |
| 186 | | |
| 187 | | const tms9901_interface tms9901reset_param_ti99_8 = |
| 188 | | { |
| 189 | | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 190 | | |
| 191 | | { /* read handlers */ |
| 192 | | ti99_8_R9901_0, |
| 193 | | ti99_8_R9901_1, |
| 194 | | ti99_R9901_2, |
| 195 | | ti99_R9901_3 |
| 196 | | }, |
| 197 | | |
| 198 | | { /* write handlers */ |
| 199 | | ti99_8_KeyC, |
| 200 | | ti99_8_KeyC, |
| 201 | | ti99_8_KeyC, |
| 202 | | ti99_8_KeyC, |
| 203 | | ti99_8_WCRUS, |
| 204 | | ti99_8_PTGEN, |
| 205 | | ti99_CS_motor, |
| 206 | | NULL, |
| 207 | | ti99_audio_gate, |
| 208 | | ti99_CS_output, |
| 209 | | NULL, |
| 210 | | NULL, |
| 211 | | NULL, |
| 212 | | NULL, |
| 213 | | NULL, |
| 214 | | NULL |
| 215 | | }, |
| 216 | | |
| 217 | | /* interrupt handler */ |
| 218 | | tms9901_interrupt_callback, |
| 219 | | |
| 220 | | /* clock rate = 3.58MHz??? 2.68MHz??? */ |
| 221 | | /*3579545.*/2684658.75 |
| 222 | | }; |
| 223 | | |
| 224 | 130 | /* handset interface */ |
| 225 | 131 | static int handset_buf; |
| 226 | 132 | static int handset_buflen; |
| r3832 | r3833 | |
| 1803 | 1709 | |
| 1804 | 1710 | Handler for tms9901 P0 pin (handset data acknowledge) |
| 1805 | 1711 | */ |
| 1806 | | static void ti99_handset_set_ack(int offset, int data) |
| 1712 | WRITE8_HANDLER( ti99_handset_set_ack ) |
| 1807 | 1713 | { |
| 1808 | 1714 | if (has_handset && handset_buflen && (data != handset_ack)) |
| 1809 | 1715 | { |
| 1810 | 1716 | handset_ack = data; |
| 1811 | 1717 | if (data == handset_clock) |
| 1812 | 1718 | /* I don't know what the real delay is, but 30us apears to be enough */ |
| 1813 | | timer_set(Machine, ATTOTIME_IN_USEC(30), NULL, 0, ti99_handset_ack_callback); |
| 1719 | timer_set(space->machine, ATTOTIME_IN_USEC(30), NULL, 0, ti99_handset_ack_callback); |
| 1814 | 1720 | } |
| 1815 | 1721 | } |
| 1816 | 1722 | |
| r3832 | r3833 | |
| 2226 | 2132 | /* |
| 2227 | 2133 | Called by the 9901 core whenever the state of INTREQ and IC0-3 changes |
| 2228 | 2134 | */ |
| 2229 | | static void tms9901_interrupt_callback(const device_config *device, int intreq, int ic) |
| 2135 | static TMS9910_INT_CALLBACK( tms9901_interrupt_callback ) |
| 2230 | 2136 | { |
| 2231 | 2137 | if (intreq) |
| 2232 | 2138 | { |
| r3832 | r3833 | |
| 2248 | 2154 | (bit 2: INT2 status) |
| 2249 | 2155 | bit 3-7: keyboard status bits 0 to 4 |
| 2250 | 2156 | */ |
| 2251 | | static int ti99_R9901_0(int offset) |
| 2157 | static READ8_HANDLER( ti99_R9901_0 ) |
| 2252 | 2158 | { |
| 2253 | | running_machine *machine = Machine; |
| 2254 | 2159 | int answer; |
| 2255 | 2160 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" }; |
| 2256 | 2161 | |
| r3832 | r3833 | |
| 2258 | 2163 | answer = (ti99_handset_poll_bus() << 3) | 0x80; |
| 2259 | 2164 | else if (has_mecmouse && (KeyCol == ((ti99_model == model_99_4) ? 6 : 7))) |
| 2260 | 2165 | { |
| 2261 | | int buttons = input_port_read(machine, "MOUSE0") & 3; |
| 2166 | int buttons = input_port_read(space->machine, "MOUSE0") & 3; |
| 2262 | 2167 | |
| 2263 | 2168 | answer = (mecmouse_read_y ? mecmouse_y_buf : mecmouse_x_buf) << 4; |
| 2264 | 2169 | |
| r3832 | r3833 | |
| 2271 | 2176 | } |
| 2272 | 2177 | else |
| 2273 | 2178 | { |
| 2274 | | answer = ((input_port_read(machine, keynames[KeyCol >> 1]) >> ((KeyCol & 1) * 8)) << 3) & 0xF8; |
| 2179 | answer = ((input_port_read(space->machine, keynames[KeyCol >> 1]) >> ((KeyCol & 1) * 8)) << 3) & 0xF8; |
| 2275 | 2180 | } |
| 2276 | 2181 | |
| 2277 | 2182 | if ((ti99_model == model_99_4a) || (ti99_model == model_99_4p)) |
| 2278 | 2183 | { |
| 2279 | 2184 | if (! AlphaLockLine) |
| 2280 | | answer &= ~ (input_port_read(machine, "ALPHA") << 3); |
| 2185 | answer &= ~ (input_port_read(space->machine, "ALPHA") << 3); |
| 2281 | 2186 | } |
| 2282 | 2187 | |
| 2283 | 2188 | return answer; |
| r3832 | r3833 | |
| 2292 | 2197 | (bit 4: IR remote handset interrupt) |
| 2293 | 2198 | bit 5-7: weird, not emulated |
| 2294 | 2199 | */ |
| 2295 | | static int ti99_R9901_1(int offset) |
| 2200 | static READ8_HANDLER( ti99_R9901_1 ) |
| 2296 | 2201 | { |
| 2297 | | running_machine *machine = Machine; |
| 2298 | 2202 | int answer; |
| 2299 | 2203 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3" }; |
| 2300 | 2204 | |
| r3832 | r3833 | |
| 2302 | 2206 | answer = 0x07; |
| 2303 | 2207 | else |
| 2304 | 2208 | { |
| 2305 | | answer = ((input_port_read(machine, keynames[KeyCol >> 1]) >> ((KeyCol & 1) * 8)) >> 5) & 0x07; |
| 2209 | answer = ((input_port_read(space->machine, keynames[KeyCol >> 1]) >> ((KeyCol & 1) * 8)) >> 5) & 0x07; |
| 2306 | 2210 | } |
| 2307 | 2211 | |
| 2308 | 2212 | /* we don't take CS2 into account, as CS2 is a write-only unit */ |
| r3832 | r3833 | |
| 2317 | 2221 | |
| 2318 | 2222 | bit 1: handset data clock pin |
| 2319 | 2223 | */ |
| 2320 | | static int ti99_R9901_2(int offset) |
| 2224 | static READ8_HANDLER( ti99_R9901_2 ) |
| 2321 | 2225 | { |
| 2322 | 2226 | return (has_handset && handset_clock) ? 2 : 0; |
| 2323 | 2227 | } |
| r3832 | r3833 | |
| 2328 | 2232 | bit 26: IR handset interrupt |
| 2329 | 2233 | bit 27: tape input |
| 2330 | 2234 | */ |
| 2331 | | static int ti99_R9901_3(int offset) |
| 2235 | static READ8_HANDLER( ti99_R9901_3 ) |
| 2332 | 2236 | { |
| 2333 | | running_machine *machine = Machine; |
| 2334 | 2237 | int answer; |
| 2335 | 2238 | |
| 2336 | 2239 | if (has_handset && (handset_buflen == 3)) |
| r3832 | r3833 | |
| 2341 | 2244 | /* we don't take CS2 into account, as CS2 is a write-only unit */ |
| 2342 | 2245 | if ( ti99_model != model_99_8 ) |
| 2343 | 2246 | { |
| 2344 | | if (cassette_input(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette1" )) > 0) |
| 2247 | if (cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette1" )) > 0) |
| 2345 | 2248 | answer |= 8; |
| 2346 | 2249 | } |
| 2347 | 2250 | else |
| 2348 | 2251 | { |
| 2349 | | if (cassette_input(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" )) > 0) |
| 2252 | if (cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" )) > 0) |
| 2350 | 2253 | answer |= 8; |
| 2351 | 2254 | } |
| 2352 | 2255 | |
| r3832 | r3833 | |
| 2357 | 2260 | /* |
| 2358 | 2261 | WRITE key column select (P2-P4) |
| 2359 | 2262 | */ |
| 2360 | | static void ti99_KeyC(int offset, int data) |
| 2263 | static WRITE8_HANDLER( ti99_KeyC ) |
| 2361 | 2264 | { |
| 2362 | 2265 | if (data) |
| 2363 | 2266 | KeyCol |= 1 << (offset-2); |
| r3832 | r3833 | |
| 2372 | 2275 | /* |
| 2373 | 2276 | WRITE alpha lock line - TI99/4a only (P5) |
| 2374 | 2277 | */ |
| 2375 | | static void ti99_AlphaW(int offset, int data) |
| 2278 | static WRITE8_HANDLER( ti99_AlphaW ) |
| 2376 | 2279 | { |
| 2377 | 2280 | if ((ti99_model == model_99_4a) || (ti99_model == model_99_4p)) |
| 2378 | 2281 | AlphaLockLine = data; |
| r3832 | r3833 | |
| 2388 | 2291 | bit 5: ??? |
| 2389 | 2292 | bit 6-7: keyboard status bits 0 through 1 |
| 2390 | 2293 | */ |
| 2391 | | static int ti99_8_R9901_0(int offset) |
| 2294 | static READ8_HANDLER( ti99_8_R9901_0 ) |
| 2392 | 2295 | { |
| 2393 | | running_machine *machine = Machine; |
| 2394 | 2296 | int answer; |
| 2395 | 2297 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7", |
| 2396 | 2298 | "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15" }; |
| 2397 | 2299 | |
| 2398 | 2300 | if (has_mecmouse && (KeyCol == 15)) |
| 2399 | 2301 | { |
| 2400 | | int buttons = input_port_read(machine, "MOUSE0") & 3; |
| 2302 | int buttons = input_port_read(space->machine, "MOUSE0") & 3; |
| 2401 | 2303 | |
| 2402 | 2304 | answer = ((mecmouse_read_y ? mecmouse_y_buf : mecmouse_x_buf) << 7) & 0x80; |
| 2403 | 2305 | |
| r3832 | r3833 | |
| 2407 | 2309 | } |
| 2408 | 2310 | else |
| 2409 | 2311 | { |
| 2410 | | answer = (input_port_read(machine, keynames[KeyCol]) << 6) & 0xC0; |
| 2312 | answer = (input_port_read(space->machine, keynames[KeyCol]) << 6) & 0xC0; |
| 2411 | 2313 | } |
| 2412 | 2314 | |
| 2413 | 2315 | return answer; |
| r3832 | r3833 | |
| 2422 | 2324 | (bit 4: IR remote handset interrupt) |
| 2423 | 2325 | bit 5-7: weird, not emulated |
| 2424 | 2326 | */ |
| 2425 | | static int ti99_8_R9901_1(int offset) |
| 2327 | static READ8_HANDLER( ti99_8_R9901_1 ) |
| 2426 | 2328 | { |
| 2427 | | running_machine *machine = Machine; |
| 2428 | 2329 | int answer; |
| 2429 | 2330 | static const char *const keynames[] = { "KEY0", "KEY1", "KEY2", "KEY3", "KEY4", "KEY5", "KEY6", "KEY7", |
| 2430 | 2331 | "KEY8", "KEY9", "KEY10", "KEY11", "KEY12", "KEY13", "KEY14", "KEY15" }; |
| 2431 | 2332 | |
| 2432 | 2333 | if (has_mecmouse && (KeyCol == 15)) |
| 2433 | 2334 | { |
| 2434 | | int buttons = input_port_read(machine, "MOUSE0") & 3; |
| 2335 | int buttons = input_port_read(space->machine, "MOUSE0") & 3; |
| 2435 | 2336 | |
| 2436 | 2337 | answer = ((mecmouse_read_y ? mecmouse_y_buf : mecmouse_x_buf) << 1) & 0x03; |
| 2437 | 2338 | |
| r3832 | r3833 | |
| 2441 | 2342 | } |
| 2442 | 2343 | else |
| 2443 | 2344 | { |
| 2444 | | answer = (input_port_read(machine, keynames[KeyCol]) >> 2) & 0x07; |
| 2345 | answer = (input_port_read(space->machine, keynames[KeyCol]) >> 2) & 0x07; |
| 2445 | 2346 | } |
| 2446 | 2347 | |
| 2447 | 2348 | /* we don't take CS2 into account, as CS2 is a write-only unit */ |
| r3832 | r3833 | |
| 2454 | 2355 | /* |
| 2455 | 2356 | WRITE key column select (P0-P3) |
| 2456 | 2357 | */ |
| 2457 | | static void ti99_8_KeyC(int offset, int data) |
| 2358 | static WRITE8_HANDLER( ti99_8_KeyC ) |
| 2458 | 2359 | { |
| 2459 | 2360 | if (data) |
| 2460 | 2361 | KeyCol |= 1 << offset; |
| r3832 | r3833 | |
| 2465 | 2366 | mecmouse_select(KeyCol, 14, 15); |
| 2466 | 2367 | } |
| 2467 | 2368 | |
| 2468 | | static void ti99_8_WCRUS(int offset, int data) |
| 2369 | static WRITE8_HANDLER( ti99_8_WCRUS ) |
| 2469 | 2370 | { |
| 2470 | 2371 | ti99_8_CRUS = data; |
| 2471 | 2372 | } |
| 2472 | 2373 | |
| 2473 | | static void ti99_8_PTGEN(int offset, int data) |
| 2374 | static WRITE8_HANDLER( ti99_8_PTGEN ) |
| 2474 | 2375 | { |
| 2475 | 2376 | /* ... */ |
| 2476 | 2377 | } |
| r3832 | r3833 | |
| 2478 | 2379 | /* |
| 2479 | 2380 | command CS1/CS2 tape unit motor (P6-P7) |
| 2480 | 2381 | */ |
| 2481 | | static void ti99_CS_motor(int offset, int data) |
| 2382 | static WRITE8_HANDLER( ti99_CS_motor ) |
| 2482 | 2383 | { |
| 2483 | | running_machine *machine = Machine; |
| 2484 | 2384 | const device_config *img; |
| 2485 | 2385 | |
| 2486 | 2386 | if ( ti99_model != model_99_8 ) |
| 2487 | 2387 | { |
| 2488 | | img = device_list_find_by_tag( machine->config->devicelist, CASSETTE, ( offset-6 ) ? "cassette2" : "cassette1" ); |
| 2388 | img = device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, ( offset-6 ) ? "cassette2" : "cassette1" ); |
| 2489 | 2389 | } |
| 2490 | 2390 | else |
| 2491 | 2391 | { |
| 2492 | | img = device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ); |
| 2392 | img = device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" ); |
| 2493 | 2393 | } |
| 2494 | 2394 | cassette_change_state(img, data ? CASSETTE_MOTOR_ENABLED : CASSETTE_MOTOR_DISABLED, CASSETTE_MASK_MOTOR); |
| 2495 | 2395 | } |
| r3832 | r3833 | |
| 2503 | 2403 | We do not really need to emulate this as the tape recorder generates sound |
| 2504 | 2404 | on its own. |
| 2505 | 2405 | */ |
| 2506 | | static void ti99_audio_gate(int offset, int data) |
| 2406 | static WRITE8_HANDLER( ti99_audio_gate ) |
| 2507 | 2407 | { |
| 2508 | 2408 | } |
| 2509 | 2409 | |
| r3832 | r3833 | |
| 2511 | 2411 | tape output (P9) |
| 2512 | 2412 | I think polarity is correct, but don't take my word for it. |
| 2513 | 2413 | */ |
| 2514 | | static void ti99_CS_output(int offset, int data) |
| 2414 | static WRITE8_HANDLER( ti99_CS_output ) |
| 2515 | 2415 | { |
| 2516 | | running_machine *machine = Machine; |
| 2517 | | |
| 2518 | 2416 | if (ti99_model != model_99_8) /* 99/8 only has one tape port!!! */ |
| 2519 | 2417 | { |
| 2520 | | cassette_output(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette1" ), data ? +1 : -1); |
| 2521 | | cassette_output(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette2" ), data ? +1 : -1); |
| 2418 | cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette1" ), data ? +1 : -1); |
| 2419 | cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette2" ), data ? +1 : -1); |
| 2522 | 2420 | } |
| 2523 | 2421 | else |
| 2524 | 2422 | { |
| 2525 | | cassette_output(device_list_find_by_tag( machine->config->devicelist, CASSETTE, "cassette" ), data ? +1 : -1); |
| 2423 | cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" ), data ? +1 : -1); |
| 2526 | 2424 | } |
| 2527 | 2425 | } |
| 2528 | 2426 | |
| r3832 | r3833 | |
| 3375 | 3273 | } |
| 3376 | 3274 | } |
| 3377 | 3275 | } |
| 3276 | |
| 3277 | /* tms9901 setup */ |
| 3278 | const tms9901_interface tms9901reset_param_ti99_4x = |
| 3279 | { |
| 3280 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 3281 | |
| 3282 | { /* read handlers */ |
| 3283 | ti99_R9901_0, |
| 3284 | ti99_R9901_1, |
| 3285 | ti99_R9901_2, |
| 3286 | ti99_R9901_3 |
| 3287 | }, |
| 3288 | |
| 3289 | { /* write handlers */ |
| 3290 | ti99_handset_set_ack, |
| 3291 | NULL, |
| 3292 | ti99_KeyC, |
| 3293 | ti99_KeyC, |
| 3294 | ti99_KeyC, |
| 3295 | ti99_AlphaW, |
| 3296 | ti99_CS_motor, |
| 3297 | ti99_CS_motor, |
| 3298 | ti99_audio_gate, |
| 3299 | ti99_CS_output, |
| 3300 | NULL, |
| 3301 | NULL, |
| 3302 | NULL, |
| 3303 | NULL, |
| 3304 | NULL, |
| 3305 | NULL |
| 3306 | }, |
| 3307 | |
| 3308 | /* interrupt handler */ |
| 3309 | tms9901_interrupt_callback, |
| 3310 | |
| 3311 | /* clock rate = 3MHz */ |
| 3312 | 3000000. |
| 3313 | }; |
| 3314 | |
| 3315 | const tms9901_interface tms9901reset_param_ti99_8 = |
| 3316 | { |
| 3317 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INTC, /* only input pins whose state is always known */ |
| 3318 | |
| 3319 | { /* read handlers */ |
| 3320 | ti99_8_R9901_0, |
| 3321 | ti99_8_R9901_1, |
| 3322 | ti99_R9901_2, |
| 3323 | ti99_R9901_3 |
| 3324 | }, |
| 3325 | |
| 3326 | { /* write handlers */ |
| 3327 | ti99_8_KeyC, |
| 3328 | ti99_8_KeyC, |
| 3329 | ti99_8_KeyC, |
| 3330 | ti99_8_KeyC, |
| 3331 | ti99_8_WCRUS, |
| 3332 | ti99_8_PTGEN, |
| 3333 | ti99_CS_motor, |
| 3334 | NULL, |
| 3335 | ti99_audio_gate, |
| 3336 | ti99_CS_output, |
| 3337 | NULL, |
| 3338 | NULL, |
| 3339 | NULL, |
| 3340 | NULL, |
| 3341 | NULL, |
| 3342 | NULL |
| 3343 | }, |
| 3344 | |
| 3345 | /* interrupt handler */ |
| 3346 | tms9901_interrupt_callback, |
| 3347 | |
| 3348 | /* clock rate = 3.58MHz??? 2.68MHz??? */ |
| 3349 | /*3579545.*/2684658.75 |
| 3350 | }; |
src/mess/drivers/tm990189.c
| r3832 | r3833 | |
| 38 | 38 | */ |
| 39 | 39 | |
| 40 | 40 | #include "driver.h" |
| 41 | | #include "deprecat.h" |
| 42 | 41 | #include "cpu/tms9900/tms9900.h" |
| 43 | 42 | #include "machine/tms9901.h" |
| 44 | 43 | #include "machine/tms9902.h" |
| r3832 | r3833 | |
| 81 | 80 | |
| 82 | 81 | static void hold_load(running_machine *machine); |
| 83 | 82 | |
| 84 | | static void usr9901_interrupt_callback(const device_config *device, int intreq, int ic); |
| 85 | | static void sys9901_interrupt_callback(const device_config *device, int intreq, int ic); |
| 86 | | |
| 87 | | static void usr9901_led_w(int offset, int data); |
| 88 | | |
| 89 | | static int sys9901_r0(int offset); |
| 90 | | static void sys9901_digitsel_w(int offset, int data); |
| 91 | | static void sys9901_segment_w(int offset, int data); |
| 92 | | static void sys9901_dsplytrgr_w(int offset, int data); |
| 93 | | static void sys9901_shiftlight_w(int offset, int data); |
| 94 | | static void sys9901_spkrdrive_w(int offset, int data); |
| 95 | | static void sys9901_tapewdata_w(int offset, int data); |
| 96 | | |
| 97 | | |
| 98 | | /* user tms9901 setup */ |
| 99 | | static const tms9901_interface usr9901reset_param = |
| 100 | | { |
| 101 | | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INT3 | TMS9901_INT4 | TMS9901_INT5 | TMS9901_INT6, /* only input pins whose state is always known */ |
| 102 | | |
| 103 | | { /* read handlers */ |
| 104 | | NULL |
| 105 | | /*usr9901_r0, |
| 106 | | usr9901_r1, |
| 107 | | usr9901_r2, |
| 108 | | usr9901_r3*/ |
| 109 | | }, |
| 110 | | |
| 111 | | { /* write handlers */ |
| 112 | | usr9901_led_w, |
| 113 | | usr9901_led_w, |
| 114 | | usr9901_led_w, |
| 115 | | usr9901_led_w/*, |
| 116 | | usr9901_w, |
| 117 | | usr9901_w, |
| 118 | | usr9901_w, |
| 119 | | usr9901_w, |
| 120 | | usr9901_w, |
| 121 | | usr9901_w, |
| 122 | | usr9901_w, |
| 123 | | usr9901_w, |
| 124 | | usr9901_w, |
| 125 | | usr9901_w, |
| 126 | | usr9901_w, |
| 127 | | usr9901_w*/ |
| 128 | | }, |
| 129 | | |
| 130 | | /* interrupt handler */ |
| 131 | | usr9901_interrupt_callback, |
| 132 | | |
| 133 | | /* clock rate = 2MHz */ |
| 134 | | 2000000. |
| 135 | | }; |
| 136 | | |
| 137 | | /* system tms9901 setup */ |
| 138 | | static const tms9901_interface sys9901reset_param = |
| 139 | | { |
| 140 | | 0, /* only input pins whose state is always known */ |
| 141 | | |
| 142 | | { /* read handlers */ |
| 143 | | sys9901_r0, |
| 144 | | NULL, |
| 145 | | NULL, |
| 146 | | NULL |
| 147 | | }, |
| 148 | | |
| 149 | | { /* write handlers */ |
| 150 | | sys9901_digitsel_w, |
| 151 | | sys9901_digitsel_w, |
| 152 | | sys9901_digitsel_w, |
| 153 | | sys9901_digitsel_w, |
| 154 | | sys9901_segment_w, |
| 155 | | sys9901_segment_w, |
| 156 | | sys9901_segment_w, |
| 157 | | sys9901_segment_w, |
| 158 | | sys9901_segment_w, |
| 159 | | sys9901_segment_w, |
| 160 | | sys9901_segment_w, |
| 161 | | sys9901_segment_w, |
| 162 | | sys9901_dsplytrgr_w, |
| 163 | | sys9901_shiftlight_w, |
| 164 | | sys9901_spkrdrive_w, |
| 165 | | sys9901_tapewdata_w |
| 166 | | }, |
| 167 | | |
| 168 | | /* interrupt handler */ |
| 169 | | sys9901_interrupt_callback, |
| 170 | | |
| 171 | | /* clock rate = 2MHz */ |
| 172 | | 2000000. |
| 173 | | }; |
| 174 | | |
| 175 | 83 | static void rts_callback(int which, int RTS); |
| 176 | 84 | static void xmit_callback(int which, int data); |
| 177 | 85 | |
| r3832 | r3833 | |
| 370 | 278 | tms9901 code |
| 371 | 279 | */ |
| 372 | 280 | |
| 373 | | static void usr9901_interrupt_callback(const device_config *device, int intreq, int ic) |
| 281 | static TMS9910_INT_CALLBACK ( usr9901_interrupt_callback ) |
| 374 | 282 | { |
| 375 | 283 | ic_state = ic & 7; |
| 376 | 284 | |
| 377 | 285 | if (!load_state) |
| 378 | | field_interrupts(Machine); |
| 286 | field_interrupts(device->machine); |
| 379 | 287 | } |
| 380 | 288 | |
| 381 | | static void usr9901_led_w(int offset, int data) |
| 289 | static WRITE8_HANDLER( usr9901_led_w ) |
| 382 | 290 | { |
| 383 | 291 | if (data) |
| 384 | 292 | LED_state |= (1 << offset); |
| r3832 | r3833 | |
| 386 | 294 | LED_state &= ~(1 << offset); |
| 387 | 295 | } |
| 388 | 296 | |
| 389 | | static void sys9901_interrupt_callback(const device_config *device,int intreq, int ic) |
| 297 | static TMS9910_INT_CALLBACK( sys9901_interrupt_callback ) |
| 390 | 298 | { |
| 391 | 299 | (void)ic; |
| 392 | 300 | |
| 393 | 301 | tms9901_set_single_int(device_list_find_by_tag(device->machine->config->devicelist, TMS9901, "tms9901_0"), 5, intreq); |
| 394 | 302 | } |
| 395 | 303 | |
| 396 | | static int sys9901_r0(int offset) |
| 304 | static READ8_HANDLER( sys9901_r0 ) |
| 397 | 305 | { |
| 398 | 306 | int reply = 0x00; |
| 399 | 307 | static const char *const keynames[] = { "LINE0", "LINE1", "LINE2", "LINE3", "LINE4", "LINE5", "LINE6", "LINE7", "LINE8" }; |
| 400 | 308 | |
| 401 | 309 | /* keyboard read */ |
| 402 | 310 | if (digitsel < 9) |
| 403 | | reply |= input_port_read(Machine, keynames[digitsel]) << 1; |
| 311 | reply |= input_port_read(space->machine, keynames[digitsel]) << 1; |
| 404 | 312 | |
| 405 | 313 | /* tape input */ |
| 406 | | if (cassette_input(device_list_find_by_tag( Machine->config->devicelist, CASSETTE, "cassette" )) > 0.0) |
| 314 | if (cassette_input(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" )) > 0.0) |
| 407 | 315 | reply |= 0x40; |
| 408 | 316 | |
| 409 | 317 | return reply; |
| 410 | 318 | } |
| 411 | 319 | |
| 412 | | static void sys9901_digitsel_w(int offset, int data) |
| 320 | static WRITE8_HANDLER( sys9901_digitsel_w ) |
| 413 | 321 | { |
| 414 | 322 | if (data) |
| 415 | 323 | digitsel |= 1 << offset; |
| r3832 | r3833 | |
| 417 | 325 | digitsel &= ~ (1 << offset); |
| 418 | 326 | } |
| 419 | 327 | |
| 420 | | static void sys9901_segment_w(int offset, int data) |
| 328 | static WRITE8_HANDLER( sys9901_segment_w ) |
| 421 | 329 | { |
| 422 | 330 | if (data) |
| 423 | 331 | segment |= 1 << (offset-4); |
| r3832 | r3833 | |
| 429 | 337 | } |
| 430 | 338 | } |
| 431 | 339 | |
| 432 | | static void sys9901_dsplytrgr_w(int offset, int data) |
| 340 | static WRITE8_HANDLER( sys9901_dsplytrgr_w ) |
| 433 | 341 | { |
| 434 | 342 | if ((!data) && (digitsel < 10)) |
| 435 | 343 | { |
| r3832 | r3833 | |
| 438 | 346 | } |
| 439 | 347 | } |
| 440 | 348 | |
| 441 | | static void sys9901_shiftlight_w(int offset, int data) |
| 349 | static WRITE8_HANDLER( sys9901_shiftlight_w ) |
| 442 | 350 | { |
| 443 | 351 | if (data) |
| 444 | 352 | LED_state |= 0x10; |
| r3832 | r3833 | |
| 446 | 354 | LED_state &= ~0x10; |
| 447 | 355 | } |
| 448 | 356 | |
| 449 | | static void sys9901_spkrdrive_w(int offset, int data) |
| 357 | static WRITE8_HANDLER( sys9901_spkrdrive_w ) |
| 450 | 358 | { |
| 451 | 359 | speaker_level_w(0, data); |
| 452 | 360 | } |
| 453 | 361 | |
| 454 | | static void sys9901_tapewdata_w(int offset, int data) |
| 362 | static WRITE8_HANDLER( sys9901_tapewdata_w ) |
| 455 | 363 | { |
| 456 | | cassette_output(device_list_find_by_tag( Machine->config->devicelist, CASSETTE, "cassette" ), data ? +1.0 : -1.0); |
| 364 | cassette_output(device_list_find_by_tag( space->machine->config->devicelist, CASSETTE, "cassette" ), data ? +1.0 : -1.0); |
| 457 | 365 | } |
| 458 | 366 | |
| 459 | 367 | /* |
| r3832 | r3833 | |
| 645 | 553 | timer_reset(joy2y_timer, ATTOTIME_IN_USEC(input_port_read(space->machine, "JOY2_Y")*28+28)); |
| 646 | 554 | } |
| 647 | 555 | |
| 556 | /* user tms9901 setup */ |
| 557 | static const tms9901_interface usr9901reset_param = |
| 558 | { |
| 559 | TMS9901_INT1 | TMS9901_INT2 | TMS9901_INT3 | TMS9901_INT4 | TMS9901_INT5 | TMS9901_INT6, /* only input pins whose state is always known */ |
| 648 | 560 | |
| 561 | { /* read handlers */ |
| 562 | NULL |
| 563 | /*usr9901_r0, |
| 564 | usr9901_r1, |
| 565 | usr9901_r2, |
| 566 | usr9901_r3*/ |
| 567 | }, |
| 568 | |
| 569 | { /* write handlers */ |
| 570 | usr9901_led_w, |
| 571 | usr9901_led_w, |
| 572 | usr9901_led_w, |
| 573 | usr9901_led_w/*, |
| 574 | usr9901_w, |
| 575 | usr9901_w, |
| 576 | usr9901_w, |
| 577 | usr9901_w, |
| 578 | usr9901_w, |
| 579 | usr9901_w, |
| 580 | usr9901_w, |
| 581 | usr9901_w, |
| 582 | usr9901_w, |
| 583 | usr9901_w, |
| 584 | usr9901_w, |
| 585 | usr9901_w*/ |
| 586 | }, |
| 587 | |
| 588 | /* interrupt handler */ |
| 589 | usr9901_interrupt_callback, |
| 590 | |
| 591 | /* clock rate = 2MHz */ |
| 592 | 2000000. |
| 593 | }; |
| 594 | |
| 595 | /* system tms9901 setup */ |
| 596 | static const tms9901_interface sys9901reset_param = |
| 597 | { |
| 598 | 0, /* only input pins whose state is always known */ |
| 599 | |
| 600 | { /* read handlers */ |
| 601 | sys9901_r0, |
| 602 | NULL, |
| 603 | NULL, |
| 604 | NULL |
| 605 | }, |
| 606 | |
| 607 | { /* write handlers */ |
| 608 | sys9901_digitsel_w, |
| 609 | sys9901_digitsel_w, |
| 610 | sys9901_digitsel_w, |
| 611 | sys9901_digitsel_w, |
| 612 | sys9901_segment_w, |
| 613 | sys9901_segment_w, |
| 614 | sys9901_segment_w, |
| 615 | sys9901_segment_w, |
| 616 | sys9901_segment_w, |
| 617 | sys9901_segment_w, |
| 618 | sys9901_segment_w, |
| 619 | sys9901_segment_w, |
| 620 | sys9901_dsplytrgr_w, |
| 621 | sys9901_shiftlight_w, |
| 622 | sys9901_spkrdrive_w, |
| 623 | sys9901_tapewdata_w |
| 624 | }, |
| 625 | |
| 626 | /* interrupt handler */ |
| 627 | sys9901_interrupt_callback, |
| 628 | |
| 629 | /* clock rate = 2MHz */ |
| 630 | 2000000. |
| 631 | }; |
| 632 | |
| 649 | 633 | /* |
| 650 | 634 | Memory map: |
| 651 | 635 | |