src/mess/machine/ti99/genboard.c
| r12423 | r12424 | |
| 136 | 136 | int keyAutoRepeatTimer; |
| 137 | 137 | |
| 138 | 138 | /* Mode flags */ |
| 139 | | int palvideo; |
| 140 | | int capslock; |
| 141 | | int keyboard_clock; |
| 142 | | int keep_keybuf; |
| 143 | | int zero_wait; |
| 139 | bool palvideo; |
| 140 | bool capslock; |
| 141 | bool keyboard_clock; |
| 142 | bool keep_keybuf; |
| 143 | bool zero_wait; |
| 144 | 144 | |
| 145 | | int genmod; |
| 146 | | int turbo; |
| 147 | | int timode; |
| 145 | bool genmod; |
| 146 | bool turbo; |
| 147 | bool timode; |
| 148 | 148 | |
| 149 | 149 | /* GROM simulation */ |
| 150 | 150 | int grom_address; |
| 151 | | int gromraddr_LSB; |
| 152 | | int gromwaddr_LSB; |
| 151 | bool gromraddr_LSB; |
| 152 | bool gromwaddr_LSB; |
| 153 | 153 | |
| 154 | 154 | /* Memory */ |
| 155 | 155 | UINT8 *sram; |
| r12423 | r12424 | |
| 158 | 158 | int sram_mask, sram_val; |
| 159 | 159 | |
| 160 | 160 | /* Mapper */ |
| 161 | | int geneve_mode; |
| 162 | | int direct_mode; |
| 163 | | int cartridge_size_8K; |
| 164 | | int cartridge_secondpage; |
| 165 | | int cartridge6_writable; |
| 166 | | int cartridge7_writable; |
| 161 | bool geneve_mode; |
| 162 | bool direct_mode; |
| 163 | bool cartridge_size_8K; |
| 164 | bool cartridge_secondpage; |
| 165 | bool cartridge6_writable; |
| 166 | bool cartridge7_writable; |
| 167 | 167 | int map[8]; |
| 168 | 168 | |
| 169 | 169 | int line_count; |
| r12423 | r12424 | |
| 171 | 171 | /* Devices */ |
| 172 | 172 | device_t *cpu; |
| 173 | 173 | device_t *video; |
| 174 | | device_t *tms9901; |
| 174 | device_t *tms9901; |
| 175 | 175 | device_t *clock; |
| 176 | 176 | device_t *peribox; |
| 177 | 177 | device_t *sound; |
| r12423 | r12424 | |
| 244 | 244 | { |
| 245 | 245 | // Turbo switch. May be changed at any time. |
| 246 | 246 | logerror("Genmod: Setting turbo flag to %d\n", value); |
| 247 | | ((genboard_state*)board)->turbo = value; |
| 247 | ((genboard_state*)board)->turbo = (value!=0); |
| 248 | 248 | } |
| 249 | 249 | else |
| 250 | 250 | { |
| 251 | 251 | // TIMode switch. Causes reset when changed. |
| 252 | 252 | logerror("Genmod: Setting timode flag to %d\n", value); |
| 253 | | ((genboard_state*)board)->timode = value; |
| 253 | ((genboard_state*)board)->timode = (value!=0); |
| 254 | 254 | board->machine().schedule_hard_reset(); |
| 255 | 255 | } |
| 256 | 256 | } |
| r12423 | r12424 | |
| 271 | 271 | if (offset & 0x0002) |
| 272 | 272 | { |
| 273 | 273 | // GROM address handling |
| 274 | | board->gromwaddr_LSB = FALSE; |
| 274 | board->gromwaddr_LSB = false; |
| 275 | 275 | |
| 276 | 276 | if (board->gromraddr_LSB) |
| 277 | 277 | { |
| 278 | 278 | reply = board->grom_address & 0xff; |
| 279 | | board->gromraddr_LSB = FALSE; |
| 279 | board->gromraddr_LSB = false; |
| 280 | 280 | } |
| 281 | 281 | else |
| 282 | 282 | { |
| 283 | 283 | reply = (board->grom_address >> 8) & 0xff; |
| 284 | | board->gromraddr_LSB = TRUE; |
| 284 | board->gromraddr_LSB = true; |
| 285 | 285 | } |
| 286 | 286 | } |
| 287 | 287 | else |
| r12423 | r12424 | |
| 291 | 291 | int page = 0x38; |
| 292 | 292 | reply = board->dram[page*0x2000 + board->grom_address]; |
| 293 | 293 | board->grom_address = (board->grom_address + 1) & 0xffff; |
| 294 | | board->gromraddr_LSB = board->gromwaddr_LSB = FALSE; |
| 294 | board->gromraddr_LSB = board->gromwaddr_LSB = false; |
| 295 | 295 | } |
| 296 | 296 | return reply; |
| 297 | 297 | } |
| r12423 | r12424 | |
| 306 | 306 | if (offset & 0x0002) |
| 307 | 307 | { |
| 308 | 308 | // set address |
| 309 | | board->gromraddr_LSB = FALSE; |
| 309 | board->gromraddr_LSB = false; |
| 310 | 310 | if (board->gromwaddr_LSB) |
| 311 | 311 | { |
| 312 | 312 | board->grom_address = (board->grom_address & 0xff00) | data; |
| 313 | 313 | board->grom_address = (board->grom_address + 1) & 0xffff; |
| 314 | | board->gromwaddr_LSB = FALSE; |
| 314 | board->gromwaddr_LSB = false; |
| 315 | 315 | } |
| 316 | 316 | else |
| 317 | 317 | { |
| 318 | 318 | board->grom_address = (board->grom_address & 0x00ff) | ((UINT16)data<<8); |
| 319 | | board->gromwaddr_LSB = TRUE; |
| 319 | board->gromwaddr_LSB = true; |
| 320 | 320 | } |
| 321 | 321 | } |
| 322 | 322 | else |
| 323 | 323 | { // write GPL data |
| 324 | 324 | // TODO: Check whether available in the real hardware. |
| 325 | 325 | board->grom_address = (board->grom_address + 1) & 0xffff; |
| 326 | | board->gromraddr_LSB = board->gromwaddr_LSB = FALSE; |
| 326 | board->gromraddr_LSB = board->gromwaddr_LSB = false; |
| 327 | 327 | logerror("Geneve: GROM write ignored\n"); |
| 328 | 328 | } |
| 329 | 329 | } |
| r12423 | r12424 | |
| 356 | 356 | // Premature access. The CPU reads the start vector before RESET. |
| 357 | 357 | if (board->peribox==NULL) return 0; |
| 358 | 358 | |
| 359 | // Add two wait states (checked with a real Geneve) |
| 359 | 360 | if (!board->zero_wait) |
| 360 | | device_adjust_icount(board->cpu, -4); |
| 361 | device_adjust_icount(board->cpu, -8); |
| 361 | 362 | |
| 362 | 363 | UINT32 physaddr; |
| 363 | 364 | |
| r12423 | r12424 | |
| 372 | 373 | // 1111 0001 0000 0010 |
| 373 | 374 | // 1111 0001 0000 1000 |
| 374 | 375 | // 1111 0001 0000 1010 |
| 376 | device_adjust_icount(board->cpu, -4); |
| 375 | 377 | gen_v9938_rz(board->video, offset, &value); |
| 376 | 378 | return value; |
| 377 | 379 | } |
| r12423 | r12424 | |
| 419 | 421 | // video |
| 420 | 422 | // ++++ ++-- ---- ---+ |
| 421 | 423 | // 1000 1000 0000 00x0 |
| 424 | device_adjust_icount(board->cpu, -4); |
| 422 | 425 | gen_v9938_rz(board->video, offset, &value); |
| 423 | 426 | return value; |
| 424 | 427 | } |
| r12423 | r12424 | |
| 551 | 554 | if (board->peribox==NULL) return; |
| 552 | 555 | |
| 553 | 556 | if (!board->zero_wait) |
| 554 | | device_adjust_icount(board->cpu, -4); |
| 557 | device_adjust_icount(board->cpu, -8); |
| 555 | 558 | |
| 556 | 559 | if (board->geneve_mode) |
| 557 | 560 | { |
| r12423 | r12424 | |
| 560 | 563 | // video |
| 561 | 564 | // ++++ ++++ ++++ ---+ |
| 562 | 565 | // 1111 0001 0000 .cc0 |
| 566 | device_adjust_icount(board->cpu, -4); |
| 563 | 567 | gen_v9938_w(board->video, offset, data); |
| 564 | 568 | return; |
| 565 | 569 | } |
| r12423 | r12424 | |
| 613 | 617 | // video |
| 614 | 618 | // ++++ ++-- ---- ---+ |
| 615 | 619 | // 1000 1100 0000 00c0 |
| 620 | device_adjust_icount(board->cpu, -4); |
| 616 | 621 | gen_v9938_w(board->video, offset, data); |
| 617 | 622 | return; |
| 618 | 623 | } |
| r12423 | r12424 | |
| 769 | 774 | genboard_state *board = get_safe_token(device); |
| 770 | 775 | |
| 771 | 776 | int addroff = offset << 1; |
| 772 | | int rising_edge = FALSE; |
| 773 | | int falling_edge = FALSE; |
| 777 | bool rising_edge = false; |
| 778 | bool falling_edge = false; |
| 774 | 779 | |
| 775 | | if ((addroff & 0x1fe0) == CRU_CONTROL_BASE) |
| 780 | if ((addroff & 0xffe0) == CRU_CONTROL_BASE) |
| 776 | 781 | { |
| 777 | 782 | int bit = (addroff & 0x0001e)>>1; |
| 778 | 783 | switch (bit) |
| 779 | 784 | { |
| 780 | 785 | case 5: |
| 781 | | board->palvideo = data; |
| 786 | board->palvideo = (data!=0); |
| 782 | 787 | break; |
| 783 | 788 | case 7: |
| 784 | | board->capslock = data; |
| 789 | board->capslock = (data!=0); |
| 785 | 790 | break; |
| 786 | 791 | case 8: |
| 787 | | rising_edge = (!board->keyboard_clock && data); |
| 788 | | board->keyboard_clock = data; |
| 792 | rising_edge = (!board->keyboard_clock && (data!=0)); |
| 793 | board->keyboard_clock = (data!=0); |
| 789 | 794 | if (rising_edge) |
| 790 | 795 | read_key_if_possible(board); |
| 791 | 796 | break; |
| 792 | 797 | case 9: |
| 793 | | rising_edge = (!board->keep_keybuf && data); |
| 794 | | falling_edge = (board->keep_keybuf && !data); |
| 795 | | board->keep_keybuf = data; |
| 798 | rising_edge = (!board->keep_keybuf && (data!=0)); |
| 799 | falling_edge = (board->keep_keybuf && (data==0)); |
| 800 | board->keep_keybuf = (data!=0); |
| 796 | 801 | |
| 797 | 802 | if (rising_edge) |
| 798 | 803 | read_key_if_possible(board); |
| r12423 | r12424 | |
| 812 | 817 | } |
| 813 | 818 | break; |
| 814 | 819 | case 10: |
| 815 | | board->geneve_mode = data; |
| 820 | board->geneve_mode = (data!=0); |
| 816 | 821 | break; |
| 817 | 822 | case 11: |
| 818 | | board->direct_mode = data; |
| 823 | board->direct_mode = (data!=0); |
| 819 | 824 | break; |
| 820 | 825 | case 12: |
| 821 | | board->cartridge_size_8K = data; |
| 826 | board->cartridge_size_8K = (data!=0); |
| 822 | 827 | break; |
| 823 | 828 | case 13: |
| 824 | | board->cartridge6_writable = data; |
| 829 | board->cartridge6_writable = (data!=0); |
| 825 | 830 | break; |
| 826 | 831 | case 14: |
| 827 | | board->cartridge7_writable = data; |
| 832 | board->cartridge7_writable = (data!=0); |
| 828 | 833 | break; |
| 829 | 834 | case 15: |
| 830 | | board->zero_wait = data; |
| 835 | board->zero_wait = (data!=0); |
| 831 | 836 | break; |
| 832 | 837 | default: |
| 833 | 838 | logerror("geneve: set CRU address %04x=%02x ignored\n", addroff, data); |
| r12423 | r12424 | |
| 1207 | 1212 | */ |
| 1208 | 1213 | static WRITE8_DEVICE_HANDLER( W9901_PE_bus_reset ) |
| 1209 | 1214 | { |
| 1215 | logerror("genboard: PE bus reset request, ignoring.\n"); |
| 1210 | 1216 | } |
| 1211 | 1217 | |
| 1212 | 1218 | /* |
| r12423 | r12424 | |
| 1214 | 1220 | */ |
| 1215 | 1221 | static WRITE8_DEVICE_HANDLER( W9901_VDP_reset ) |
| 1216 | 1222 | { |
| 1223 | logerror("genboard: Video reset request, ignoring.\n"); |
| 1217 | 1224 | } |
| 1218 | 1225 | |
| 1219 | 1226 | /* |
| r12423 | r12424 | |
| 1255 | 1262 | */ |
| 1256 | 1263 | static WRITE8_DEVICE_HANDLER( W9901_ext_mem_wait_states ) |
| 1257 | 1264 | { |
| 1265 | logerror("genboard: external bus wait states set to %d, not implemented yet.\n", data); |
| 1258 | 1266 | } |
| 1259 | 1267 | |
| 1260 | 1268 | /* |
| r12423 | r12424 | |
| 1262 | 1270 | */ |
| 1263 | 1271 | static WRITE8_DEVICE_HANDLER( W9901_VDP_wait_states ) |
| 1264 | 1272 | { |
| 1273 | logerror("genboard: vdp wait states set to %d, not implemented yet.\n", data); |
| 1265 | 1274 | } |
| 1266 | 1275 | |
| 1267 | 1276 | /* tms9901 setup */ |
| r12423 | r12424 | |
| 1367 | 1376 | assert(board->peribox && board->cpu); |
| 1368 | 1377 | assert(board->sound && board->clock); |
| 1369 | 1378 | assert(board->eprom); |
| 1370 | | board->geneve_mode = 0; |
| 1371 | | board->direct_mode = 1; |
| 1379 | board->geneve_mode = false; |
| 1380 | board->direct_mode = true; |
| 1372 | 1381 | |
| 1373 | 1382 | memset(board->sram, 0x00, SRAM_SIZE); |
| 1374 | 1383 | memset(board->dram, 0x00, DRAM_SIZE); |
| r12423 | r12424 | |
| 1402 | 1411 | board->last_my = 0; |
| 1403 | 1412 | board->line_count = 0; |
| 1404 | 1413 | |
| 1405 | | board->palvideo = 0; |
| 1406 | | board->capslock = 0; |
| 1407 | | board->keyboard_clock = 0; |
| 1408 | | board->keep_keybuf = 0; |
| 1409 | | board->zero_wait = 1; |
| 1414 | board->palvideo = false; |
| 1415 | board->capslock = false; |
| 1416 | board->keyboard_clock = false; |
| 1417 | board->keep_keybuf = false; |
| 1418 | board->zero_wait = true; |
| 1410 | 1419 | |
| 1411 | | board->geneve_mode = 0; |
| 1412 | | board->direct_mode = 1; |
| 1413 | | board->cartridge_size_8K = 0; |
| 1414 | | board->cartridge_secondpage = 0; |
| 1415 | | board->cartridge6_writable = 0; |
| 1416 | | board->cartridge7_writable = 0; |
| 1420 | board->geneve_mode =false; |
| 1421 | board->direct_mode = true; |
| 1422 | board->cartridge_size_8K = false; |
| 1423 | board->cartridge_secondpage = false; |
| 1424 | board->cartridge6_writable = false; |
| 1425 | board->cartridge7_writable = false; |
| 1417 | 1426 | for (int i=0; i < 8; i++) board->map[i] = 0; |
| 1418 | 1427 | |
| 1419 | | board->genmod = FALSE; |
| 1428 | board->genmod = false; |
| 1420 | 1429 | if (input_port_read(device->machine(), "MODE")==0) |
| 1421 | 1430 | { |
| 1422 | 1431 | switch (input_port_read(device->machine(), "BOOTROM")) |
| r12423 | r12424 | |
| 1439 | 1448 | { |
| 1440 | 1449 | fatalerror("GenMod boot rom missing.\n"); |
| 1441 | 1450 | } |
| 1442 | | board->genmod = TRUE; |
| 1443 | | board->turbo = input_port_read(device->machine(), "GENMODDIPS") & GM_TURBO; |
| 1444 | | board->timode = input_port_read(device->machine(), "GENMODDIPS") & GM_TIM; |
| 1451 | board->genmod = true; |
| 1452 | board->turbo = ((input_port_read(device->machine(), "GENMODDIPS") & GM_TURBO)!=0); |
| 1453 | board->timode = ((input_port_read(device->machine(), "GENMODDIPS") & GM_TIM)!=0); |
| 1445 | 1454 | } |
| 1446 | 1455 | |
| 1447 | 1456 | switch (input_port_read(device->machine(), "SRAM")) |
src/mess/machine/ti99/ti_rs232.c
| r12423 | r12424 | |
| 1 | 1 | /* |
| 2 | 2 | TI-99 RS232 and Parallel interface card |
| 3 | 3 | |
| 4 | TI99 RS232 card ('rs232') |
| 5 | TMS9902 ('rs232:tms9902_0') |
| 6 | TMS9902 ('rs232:tms9902_1') |
| 7 | TI99 RS232 attached serial device ('rs232:serdev0') |
| 8 | TI99 RS232 attached serial device ('rs232:serdev1') |
| 9 | TI99 PIO attached parallel device ('rs232:piodev') |
| 10 | |
| 4 | 11 | Currently this emulation does not directly interact with the serial |
| 5 | | interface on the host computer. |
| 12 | interface on the host computer. However, using a socket connection it is |
| 13 | possible to attach an external bridge which interacts with a real UART. |
| 6 | 14 | |
| 7 | | However, using a socket connection it is possible to attach an external |
| 8 | | bridge which interacts with a real UART. |
| 9 | | |
| 10 | 15 | This implementation can make use of such an external bridge. Normal data |
| 11 | 16 | are forwarded to the bridge and back, while line control is organized via |
| 12 | 17 | special byte sequences. These sequences are introduced by a 0x1B byte (ESC). |
| r12423 | r12424 | |
| 19 | 24 | 01ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f |
| 20 | 25 | 00gh i000 = exception g=BRK, h=FRMERR, i=PARERR |
| 21 | 26 | |
| 22 | | TI99 RS232 card ('rs232') |
| 23 | | TMS9902 ('rs232:tms9902_0') |
| 24 | | TMS9902 ('rs232:tms9902_1') |
| 25 | | TI99 RS232 attached serial device ('rs232:serdev0') |
| 26 | | TI99 RS232 attached serial device ('rs232:serdev1') |
| 27 | | TI99 PIO attached parallel device ('rs232:piodev') |
| 28 | | |
| 29 | 27 | TI RS232 card wiring |
| 30 | 28 | -------------------- |
| 31 | 29 | The card uses this wiring (inverters not included) |
| r12423 | r12424 | |
| 43 | 41 | | CRU |--+ |
| 44 | 42 | +-----+ |
| 45 | 43 | |
| 46 | | Obviously we have a wiring which is typical for a DCE, not a DTE. The TI |
| 47 | | RS232 was designed to look like a modem. |
| 44 | This wiring is typical for a DCE, not a DTE. The TI RS232 was obviously |
| 45 | designed to look like a modem. The advantage is that you can use the same |
| 46 | cables for connecting a modem to the RS232 interface or for connecting |
| 47 | a second TI via its interface. To connect to a DTE you can use a 1-1 |
| 48 | wiring cable (1 on 1, 2 on 2 ...) |
| 48 | 49 | |
| 49 | | The advantage is that you can use the same cables for connecting a modem |
| 50 | | to the RS232 interface or for connecting a second TI via its interface. To |
| 51 | | connect to a DTE you can use a 1-1 wiring cable (1 on 1, 2 on 2 ...) |
| 52 | | |
| 53 | 50 | The TI manual for the RS232 card suggests the following cables: |
| 54 | 51 | |
| 55 | 52 | TI RS232 - Modem or other TI RS232 |
| r12423 | r12424 | |
| 70 | 67 | interface we have to map the TI wiring to a suitable wiring for PC |
| 71 | 68 | interfaces which are designed as DTEs. |
| 72 | 69 | |
| 73 | | From the signals used in the suggested cables we can conclude that we just |
| 74 | | need to do the following conversion if we want a PC serial interface |
| 75 | | to play the role of the TI RS232: |
| 70 | See the functions map_lines_in/out. |
| 76 | 71 | |
| 77 | | Emulated PC serial |
| 78 | | TI RS232 interface |
| 79 | | 2 -----------( 3) ---> |
| 80 | | 3 -----------( 2) <--- |
| 81 | | 4 (nc) ------( 5) <--- (cable) |
| 82 | | 5 -----------( 4) ---> |
| 83 | | 6 -----------(20) ---> |
| 84 | | 8 ---| nc |--( 8) <--- |
| 85 | | 20 -----------( 6) <--- |
| 72 | However, due to the way the board is designed, a proper hardware |
| 73 | handshaking between a real TI and the TI emulation is impossible. |
| 86 | 74 | |
| 87 | | Note that we now have to swap the cable types: Use a 1-1 cable to connect |
| 88 | | another TI or a modem on the other end, and use a crossover cable for |
| 89 | | another PC (the usual way of connecting). |
| 75 | Note that we now have to swap the cable types: Use a 1-1 cable to connect |
| 76 | another TI or a modem on the other end, and use a crossover cable for |
| 77 | another PC (the usual way of connecting). |
| 90 | 78 | */ |
| 91 | 79 | |
| 92 | 80 | #include "emu.h" |
| r12423 | r12424 | |
| 106 | 94 | |
| 107 | 95 | #define VERBOSE 1 |
| 108 | 96 | |
| 97 | #define LOG logerror |
| 98 | |
| 109 | 99 | // Second card: Change CRU base to 0x1500 |
| 110 | 100 | // #define CRU_BASE 0x1500 |
| 111 | 101 | |
| r12423 | r12424 | |
| 219 | 209 | } |
| 220 | 210 | else |
| 221 | 211 | { |
| 222 | | logerror("ti99/rs232: Could not find device tag number\n"); |
| 212 | LOG("ti99/rs232: Could not find device tag number\n"); |
| 223 | 213 | return IMAGE_INIT_FAIL; |
| 224 | 214 | } |
| 225 | 215 | |
| r12423 | r12424 | |
| 410 | 400 | |
| 411 | 401 | case 5: |
| 412 | 402 | // Set the CTS line for RS232/1 |
| 403 | LOG("TI-RS232/1: Setting CTS via CRU to %d\n", data); |
| 413 | 404 | output_line_state(card->uart[0], CTS, (data)? CTS : 0); |
| 414 | 405 | break; |
| 415 | 406 | |
| 416 | 407 | case 6: |
| 417 | 408 | // Set the CTS line for RS232/2 |
| 409 | LOG("TI-RS232/2: Setting CTS via CRU to %d\n", data); |
| 418 | 410 | output_line_state(card->uart[1], CTS, (data)? CTS : 0); |
| 419 | 411 | break; |
| 420 | 412 | |
| r12423 | r12424 | |
| 435 | 427 | |
| 436 | 428 | if (card->senila) |
| 437 | 429 | { |
| 438 | | if (VERBOSE>3) logerror("ti99/rs232: Sensing ILA\n"); |
| 430 | if (VERBOSE>3) LOG("ti99/rs232: Sensing ILA\n"); |
| 439 | 431 | *value = card->ila; |
| 440 | 432 | // The card ROM must be unselected, or we get two values |
| 441 | 433 | // on the data bus |
| r12423 | r12424 | |
| 503 | 495 | ti_rs232_state *card = get_safe_token(tms9902->owner()); |
| 504 | 496 | int uartind = (tms9902==card->uart[0])? 0 : 1; |
| 505 | 497 | |
| 506 | | if (VERBOSE>2) logerror("TI-RS232/%d: incoming DTR = %d\n", uartind+1, (value==ASSERT_LINE)? 1:0); |
| 498 | if (VERBOSE>2) LOG("TI-RS232/%d: incoming DTR = %d\n", uartind+1, (value==ASSERT_LINE)? 1:0); |
| 507 | 499 | |
| 508 | 500 | tms9902_rcv_cts(tms9902, value); |
| 509 | 501 | tms9902_rcv_dsr(tms9902, value); |
| r12423 | r12424 | |
| 522 | 514 | serial = dynamic_cast<device_image_interface *>(card->serdev[uartind]); |
| 523 | 515 | if (!serial->exists()) |
| 524 | 516 | { |
| 525 | | if (VERBOSE>1) logerror("TI-RS232/%d: No serial output attached\n", uartind+1); |
| 517 | if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1); |
| 526 | 518 | return; |
| 527 | 519 | } |
| 528 | 520 | |
| 529 | 521 | // Send a double ESC if this is not a control operation |
| 530 | 522 | if (buf==0x1b) |
| 531 | 523 | { |
| 532 | | if (VERBOSE>2) logerror("TI-RS232/%d: send ESC (requires another ESC)\n", uartind+1); |
| 524 | if (VERBOSE>2) LOG("TI-RS232/%d: send ESC (requires another ESC)\n", uartind+1); |
| 533 | 525 | serial->fwrite(&buf, 1); |
| 534 | 526 | } |
| 535 | | if (VERBOSE>3) logerror("TI-RS232/%d: send %c <%02x>\n", uartind+1, buf, buf); |
| 527 | if (VERBOSE>3) LOG("TI-RS232/%d: send %c <%02x>\n", uartind+1, buf, buf); |
| 536 | 528 | serial->fwrite(&buf, 1); |
| 537 | 529 | } |
| 538 | 530 | |
| 539 | 531 | /* |
| 540 | 532 | Map the DCE-like wiring to a DTE-like wiring (and vice versa) |
| 541 | | If suffices to swap RTS/CTS and DTR/DSR. We can use this function for |
| 542 | | either direction; note that the RTS pin in the TI RS232 connector is not used. |
| 533 | |
| 534 | Emulated PC serial |
| 535 | TI RS232 interface |
| 536 | XOUT 2 -----------( 3) ---> TXD |
| 537 | RIN 3 -----------( 2) <--- RXD |
| 538 | nc 4 -----------( 5) <--- CTS (cable) |
| 539 | CRU 5 -| |-( 8) <--- DCD |
| 540 | DSR+CTS 20 -----------( 6) <--- DSR |
| 541 | +12V 6 -----------(20) ---> DTR |
| 542 | RTS 8 -----------( 4) ---> RTS |
| 543 | 543 | */ |
| 544 | | static UINT8 map_lines(int uartind, UINT8 value) |
| 544 | static UINT8 map_lines_out(int uartind, UINT8 value) |
| 545 | 545 | { |
| 546 | 546 | UINT8 ret = 0; |
| 547 | 547 | |
| 548 | 548 | // 00ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f |
| 549 | 549 | |
| 550 | | if (VERBOSE>3) logerror("TI-RS232/%d: connector pins = 0x%02x; translate for DTE\n", uartind+1, value); |
| 550 | if (VERBOSE>3) LOG("TI-RS232/%d: out connector pins = 0x%02x; translate for DTE\n", uartind+1, value); |
| 551 | 551 | |
| 552 | 552 | if (value & CTS) |
| 553 | 553 | { |
| 554 | if (VERBOSE>5) LOG("TI-RS232/%d: ... cannot map CTS line, ignoring\n", uartind+1); |
| 555 | } |
| 556 | if (value & DSR) |
| 557 | { |
| 558 | ret |= DTR; |
| 559 | if (VERBOSE>5) LOG("TI-RS232/%d: ... setting DTR line\n", uartind+1); |
| 560 | } |
| 561 | if (value & DCD) |
| 562 | { |
| 554 | 563 | ret |= RTS; |
| 555 | | if (VERBOSE>5) logerror("TI-RS232/%d: ... setting RTS line\n", uartind+1); |
| 564 | if (VERBOSE>5) LOG("TI-RS232/%d: ... setting RTS line\n", uartind+1); |
| 556 | 565 | } |
| 566 | if (value & BRK) |
| 567 | { |
| 568 | if (VERBOSE>5) LOG("TI-RS232/%d: ... sending BRK\n", uartind+1); |
| 569 | ret |= EXCEPT | BRK; |
| 570 | } |
| 571 | |
| 572 | return ret; |
| 573 | } |
| 574 | |
| 575 | static UINT8 map_lines_in(int uartind, UINT8 value) |
| 576 | { |
| 577 | UINT8 ret = 0; |
| 578 | |
| 579 | // 00ab cdef = setting line RTS=a, CTS=b, DSR=c, DCD=d, DTR=e, RI=f |
| 580 | |
| 581 | if (VERBOSE>3) LOG("TI-RS232/%d: in connector pins = 0x%02x; translate for DTE\n", uartind+1, value); |
| 582 | |
| 583 | if (value & CTS) |
| 584 | { |
| 585 | if (VERBOSE>5) LOG("TI-RS232/%d: ... cannot map CTS line, ignoring\n", uartind+1); |
| 586 | } |
| 557 | 587 | if (value & DSR) |
| 558 | 588 | { |
| 559 | 589 | ret |= DTR; |
| 560 | | if (VERBOSE>5) logerror("TI-RS232/%d: ... setting DTR line\n", uartind+1); |
| 590 | if (VERBOSE>5) LOG("TI-RS232/%d: ... setting DTR line\n", uartind+1); |
| 561 | 591 | } |
| 562 | 592 | if (value & DCD) |
| 563 | 593 | { |
| 564 | | if (VERBOSE>5) logerror("TI-RS232/%d: ... cannot map DCD line, ignoring\n", uartind+1); |
| 594 | if (VERBOSE>5) LOG("TI-RS232/%d: ... cannot map DCD line, ignoring\n", uartind+1); |
| 565 | 595 | } |
| 566 | 596 | if (value & BRK) |
| 567 | 597 | { |
| 568 | | if (VERBOSE>5) logerror("TI-RS232/%d: ... sending BRK\n", uartind+1); |
| 598 | if (VERBOSE>5) LOG("TI-RS232/%d: ... sending BRK\n", uartind+1); |
| 569 | 599 | ret |= EXCEPT | BRK; |
| 570 | 600 | } |
| 571 | 601 | |
| 572 | 602 | return ret; |
| 573 | 603 | } |
| 574 | | |
| 575 | 604 | /* |
| 576 | 605 | Receive a character or a line state from the remote site. This method |
| 577 | 606 | is called by a timer with some sufficiently high polling frequency. Note |
| r12423 | r12424 | |
| 598 | 627 | |
| 599 | 628 | if (!serial->exists()) |
| 600 | 629 | { |
| 601 | | if (VERBOSE>1) logerror("TI-RS232/%d: No serial input attached\n", uartind+1); |
| 630 | if (VERBOSE>1) LOG("TI-RS232/%d: No serial input attached\n", uartind+1); |
| 602 | 631 | return; |
| 603 | 632 | } |
| 604 | 633 | |
| r12423 | r12424 | |
| 622 | 651 | case RECV_MODE_NORMAL: |
| 623 | 652 | if (buffer==0x1b) |
| 624 | 653 | { |
| 625 | | if (VERBOSE>2) logerror("TI-RS232/%d: received: %c <%02x>, switch to ESC mode\n", uartind+1, buffer, buffer); |
| 654 | if (VERBOSE>2) LOG("TI-RS232/%d: received: %c <%02x>, switch to ESC mode\n", uartind+1, buffer, buffer); |
| 626 | 655 | card->recv_mode[uartind] = RECV_MODE_ESC; |
| 627 | 656 | } |
| 628 | 657 | else |
| 629 | 658 | { |
| 630 | | if (VERBOSE>3) logerror("TI-RS232/%d: received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer); |
| 659 | if (VERBOSE>3) LOG("TI-RS232/%d: received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer); |
| 631 | 660 | tms9902_rcv_data(tms9902, buffer); |
| 632 | 661 | card->time_hold[uartind] = 0.0; |
| 633 | 662 | } |
| r12423 | r12424 | |
| 636 | 665 | if (buffer==0x1b) |
| 637 | 666 | { |
| 638 | 667 | card->recv_mode[uartind] = RECV_MODE_NORMAL; |
| 639 | | if (VERBOSE>2) logerror("TI-RS232/%d: leaving ESC mode, received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer); |
| 668 | if (VERBOSE>2) LOG("TI-RS232/%d: leaving ESC mode, received: %c <%02x>, pass to UART\n", uartind+1, buffer, buffer); |
| 640 | 669 | tms9902_rcv_data(tms9902, buffer); |
| 641 | 670 | card->time_hold[uartind] = 0.0; |
| 642 | 671 | } |
| 643 | 672 | else |
| 644 | 673 | { |
| 645 | 674 | // the byte in buffer is the length byte |
| 646 | | if (VERBOSE>3) logerror("TI-RS232/%d: received length byte <%02x> in ESC mode\n", uartind+1, buffer); |
| 675 | if (VERBOSE>3) LOG("TI-RS232/%d: received length byte <%02x> in ESC mode\n", uartind+1, buffer); |
| 647 | 676 | if (buffer != 1) |
| 648 | 677 | { |
| 649 | | logerror("TI-RS232/%d: expected length 1 but got %02x, leaving ESC mode.\n", uartind+1, buffer); |
| 678 | LOG("TI-RS232/%d: expected length 1 but got %02x, leaving ESC mode.\n", uartind+1, buffer); |
| 650 | 679 | card->recv_mode[uartind] = RECV_MODE_NORMAL; |
| 651 | 680 | } |
| 652 | 681 | else |
| r12423 | r12424 | |
| 669 | 698 | } |
| 670 | 699 | else |
| 671 | 700 | { |
| 672 | | buffer = map_lines(uartind, buffer); |
| 673 | | if (VERBOSE>2) logerror("TI-RS232/%d: received (remapped) <%02x> in ESC mode\n", uartind+1, buffer); |
| 701 | buffer = map_lines_in(uartind, buffer); |
| 702 | if (VERBOSE>2) LOG("TI-RS232/%d: received (remapped) <%02x> in ESC mode\n", uartind+1, buffer); |
| 674 | 703 | |
| 675 | 704 | // The DTR line on the RS232 connector of the board is wired to both the |
| 676 | 705 | // CTS and the DSR pin of the TMS9902 |
| r12423 | r12424 | |
| 682 | 711 | break; |
| 683 | 712 | |
| 684 | 713 | default: |
| 685 | | logerror("TI-RS232/%d: unknown mode: %d\n", uartind+1, card->recv_mode[uartind]); |
| 714 | LOG("TI-RS232/%d: unknown mode: %d\n", uartind+1, card->recv_mode[uartind]); |
| 686 | 715 | } |
| 687 | 716 | } |
| 688 | 717 | |
| r12423 | r12424 | |
| 715 | 744 | |
| 716 | 745 | if (!serial->exists()) |
| 717 | 746 | { |
| 718 | | if (VERBOSE>1) logerror("TI-RS232/%d: No serial output attached\n", uartind+1); |
| 747 | if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1); |
| 719 | 748 | return; |
| 720 | 749 | } |
| 721 | 750 | |
| r12423 | r12424 | |
| 725 | 754 | |
| 726 | 755 | switch (type) { |
| 727 | 756 | case RATERECV: |
| 728 | | if (VERBOSE>2) logerror("TI-RS232/%d: send receive rate %04x\n", uartind+1, value); |
| 757 | if (VERBOSE>2) LOG("TI-RS232/%d: send receive rate %04x\n", uartind+1, value); |
| 729 | 758 | // value has 12 bits |
| 730 | 759 | // 1ccc xaaa = config adapter type a |
| 731 | 760 | // 1111 xaaa rrrr rrrr rrrr 0000 = config receive rate on a |
| r12423 | r12424 | |
| 736 | 765 | bufctrl[3] = (value & 0x0f)<<4; |
| 737 | 766 | break; |
| 738 | 767 | case RATEXMIT: |
| 739 | | if (VERBOSE>2) logerror("TI-RS232/%d: send transmit rate %04x\n", uartind+1, value); |
| 768 | if (VERBOSE>2) LOG("TI-RS232/%d: send transmit rate %04x\n", uartind+1, value); |
| 740 | 769 | bufctrl[0] = 0x03; // length |
| 741 | 770 | bufctrl[1] |= RATEXMIT; |
| 742 | 771 | bufctrl[2] = (value & 0x0ff0)>>4; |
| 743 | 772 | bufctrl[3] = (value & 0x0f)<<4; |
| 744 | 773 | break; |
| 745 | 774 | case STOPBITS: |
| 746 | | if (VERBOSE>2) logerror("TI-RS232/%d: send stop bit config %02x\n", uartind+1, value&0x03); |
| 775 | if (VERBOSE>2) LOG("TI-RS232/%d: send stop bit config %02x\n", uartind+1, value&0x03); |
| 747 | 776 | bufctrl[1] |= STOPBITS; |
| 748 | 777 | bufctrl[2] = (value & 0x03); |
| 749 | 778 | break; |
| 750 | 779 | case DATABITS: |
| 751 | | if (VERBOSE>2) logerror("TI-RS232/%d: send data bit config %02x\n", uartind+1, value&0x03); |
| 780 | if (VERBOSE>2) LOG("TI-RS232/%d: send data bit config %02x\n", uartind+1, value&0x03); |
| 752 | 781 | bufctrl[1] |= DATABITS; |
| 753 | 782 | bufctrl[2] = (value & 0x03); |
| 754 | 783 | break; |
| 755 | 784 | case PARITY: |
| 756 | | if (VERBOSE>2) logerror("TI-RS232/%d: send parity config %02x\n", uartind+1, value&0x03); |
| 785 | if (VERBOSE>2) LOG("TI-RS232/%d: send parity config %02x\n", uartind+1, value&0x03); |
| 757 | 786 | bufctrl[1] |= PARITY; |
| 758 | 787 | bufctrl[2] = (value & 0x03); |
| 759 | 788 | break; |
| 760 | 789 | default: |
| 761 | | if (VERBOSE>1) logerror("TI-RS232/%d: error - unknown config type %02x\n", uartind+1, type); |
| 790 | if (VERBOSE>1) LOG("TI-RS232/%d: error - unknown config type %02x\n", uartind+1, type); |
| 762 | 791 | } |
| 763 | 792 | |
| 764 | 793 | serial->fwrite(bufctrl, bufctrl[0]+1); |
| r12423 | r12424 | |
| 771 | 800 | { |
| 772 | 801 | switch (line) |
| 773 | 802 | { |
| 774 | | case CTS: logerror("TI-RS232/%d: set CTS(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break; |
| 775 | | case DCD: logerror("TI-RS232/%d: set DCD(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break; |
| 776 | | case BRK: logerror("TI-RS232/%d: set BRK(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break; |
| 803 | case CTS: LOG("TI-RS232/%d: set CTS(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break; |
| 804 | case DCD: LOG("TI-RS232/%d: set DCD(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break; |
| 805 | case BRK: LOG("TI-RS232/%d: set BRK(out)=%s\n", uartind+1, (value)? "asserted" : "cleared"); break; |
| 777 | 806 | } |
| 778 | 807 | } |
| 779 | 808 | |
| r12423 | r12424 | |
| 799 | 828 | |
| 800 | 829 | if (!serial->exists()) |
| 801 | 830 | { |
| 802 | | if (VERBOSE>1) logerror("TI-RS232/%d: No serial output attached\n", uartind+1); |
| 831 | if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1); |
| 803 | 832 | return; |
| 804 | 833 | } |
| 805 | 834 | |
| r12423 | r12424 | |
| 828 | 857 | |
| 829 | 858 | if (!serial->exists()) |
| 830 | 859 | { |
| 831 | | if (VERBOSE>1) logerror("TI-RS232/%d: No serial output attached\n", uartind+1); |
| 860 | if (VERBOSE>1) LOG("TI-RS232/%d: No serial output attached\n", uartind+1); |
| 832 | 861 | return; |
| 833 | 862 | } |
| 834 | 863 | |
| r12423 | r12424 | |
| 852 | 881 | // Now translate the signals of the board to those of a DTE-like device |
| 853 | 882 | // so that we can pass the signal to the real PC serial interface |
| 854 | 883 | // (can be imagined as if we emulated the cable) |
| 855 | | bufctrl[1] = map_lines(uartind, card->signals[uartind]); |
| 884 | bufctrl[1] = map_lines_out(uartind, card->signals[uartind]); |
| 856 | 885 | serial->fwrite(bufctrl, 2); |
| 857 | 886 | } |
| 858 | 887 | |
| r12423 | r12424 | |
| 874 | 903 | { |
| 875 | 904 | // put the value on the data bus. We store it in a state variable. |
| 876 | 905 | ti_rs232_state *card = get_safe_token(device); |
| 877 | | if (VERBOSE>3) logerror("TI-RS232/1-2: Setting SENILA=%d\n", state); |
| 906 | if (VERBOSE>3) LOG("TI-RS232/1-2: Setting SENILA=%d\n", state); |
| 878 | 907 | card->senila = state; |
| 879 | 908 | } |
| 880 | 909 | |
src/mess/machine/tms9902.c
| r12423 | r12424 | |
| 39 | 39 | #include "tms9902.h" |
| 40 | 40 | |
| 41 | 41 | #define VERBOSE 1 |
| 42 | #define LOG logerror |
| 42 | 43 | |
| 43 | 44 | // Polling frequency. We use a much higher value to allow for line state changes |
| 44 | 45 | // happening between character transmissions (which happen in parallel in real |
| r12423 | r12424 | |
| 180 | 181 | || (tms9902->RBRL && tms9902->RIENB) |
| 181 | 182 | || (tms9902->XBRE && tms9902->XBIENB) |
| 182 | 183 | || (tms9902->TIMELP && tms9902->TIMENB); |
| 183 | | // if (VERBOSE>3) logerror("TMS9902: interrupt flags (DSCH = %02x, DSCENB = %02x), (RBRL = %02x, RIENB = %02x), (XBRE = %02x, XBIENB = %02x), (TIMELP = %02x, TIMENB = %02x)\n", |
| 184 | // if (VERBOSE>3) LOG("TMS9902: interrupt flags (DSCH = %02x, DSCENB = %02x), (RBRL = %02x, RIENB = %02x), (XBRE = %02x, XBIENB = %02x), (TIMELP = %02x, TIMENB = %02x)\n", |
| 184 | 185 | // tms9902->DSCH, tms9902->DSCENB, tms9902->RBRL, tms9902->RIENB, tms9902->XBRE, tms9902->XBIENB, tms9902->TIMELP, tms9902->TIMENB); |
| 185 | 186 | if (new_int != tms9902->INT) |
| 186 | 187 | { |
| 187 | 188 | // Only consider edges |
| 188 | 189 | tms9902->INT = new_int; |
| 189 | | if (VERBOSE>3) logerror("TMS9902: /INT = %s\n", (tms9902->INT)? "asserted" : "cleared"); |
| 190 | if (VERBOSE>3) LOG("TMS9902: /INT = %s\n", (tms9902->INT)? "asserted" : "cleared"); |
| 190 | 191 | if (tms9902->intf->int_callback) |
| 191 | 192 | (*tms9902->intf->int_callback)(device, tms9902->INT? ASSERT_LINE : CLEAR_LINE); |
| 192 | 193 | } |
| r12423 | r12424 | |
| 204 | 205 | tms9902->CTSflag = (state==ASSERT_LINE)? 1:0; |
| 205 | 206 | tms9902->DSCH = 1; |
| 206 | 207 | |
| 207 | | if (VERBOSE>3) logerror("TMS9902: CTS* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared"); |
| 208 | if (VERBOSE>3) LOG("TMS9902: CTS* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared"); |
| 208 | 209 | |
| 209 | 210 | if (tms9902->CTSflag != previous) |
| 210 | 211 | { |
| r12423 | r12424 | |
| 237 | 238 | { |
| 238 | 239 | tms9902_t *tms9902 = get_token(device); |
| 239 | 240 | bool previous = tms9902->DSRflag; |
| 240 | | if (VERBOSE>3) logerror("TMS9902: DSR* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared"); |
| 241 | if (VERBOSE>3) LOG("TMS9902: DSR* = %s\n", (state==ASSERT_LINE)? "asserted" : "cleared"); |
| 241 | 242 | tms9902->DSRflag = (state==ASSERT_LINE)? true:false; |
| 242 | 243 | tms9902->DSCH = 1; |
| 243 | 244 | |
| r12423 | r12424 | |
| 267 | 268 | { |
| 268 | 269 | // Receive buffer was empty |
| 269 | 270 | tms9902->RBRL = 1; |
| 270 | | if (VERBOSE>3) logerror("TMS9902: Receive buffer loaded with byte %02x\n", data); |
| 271 | if (VERBOSE>3) LOG("TMS9902: Receive buffer loaded with byte %02x\n", data); |
| 271 | 272 | field_interrupts(device); |
| 272 | 273 | } |
| 273 | 274 | else |
| 274 | 275 | { |
| 275 | 276 | // Receive buffer was full |
| 276 | 277 | tms9902->ROVER = 1; |
| 277 | | if (VERBOSE>1) logerror("TMS9902: Receive buffer still loaded; overflow error\n"); |
| 278 | if (VERBOSE>1) LOG("TMS9902: Receive buffer still loaded; overflow error\n"); |
| 278 | 279 | } |
| 279 | 280 | } |
| 280 | 281 | |
| r12423 | r12424 | |
| 289 | 290 | void tms9902_rcv_framing_error(device_t *device) |
| 290 | 291 | { |
| 291 | 292 | tms9902_t *tms9902 = get_token(device); |
| 292 | | if (VERBOSE>2) logerror("TMS9902: Detected framing error\n"); |
| 293 | if (VERBOSE>2) LOG("TMS9902: Detected framing error\n"); |
| 293 | 294 | tms9902->RFER = 1; |
| 294 | 295 | } |
| 295 | 296 | |
| r12423 | r12424 | |
| 302 | 303 | void tms9902_rcv_parity_error(device_t *device) |
| 303 | 304 | { |
| 304 | 305 | tms9902_t *tms9902 = get_token(device); |
| 305 | | if (VERBOSE>2) logerror("TMS9902: Detected parity error\n"); |
| 306 | if (VERBOSE>2) LOG("TMS9902: Detected parity error\n"); |
| 306 | 307 | tms9902->RPER = 1; |
| 307 | 308 | } |
| 308 | 309 | |
| r12423 | r12424 | |
| 314 | 315 | */ |
| 315 | 316 | void tms9902_rcv_break(device_t *device, bool value) |
| 316 | 317 | { |
| 317 | | if (VERBOSE>2) logerror("TMS9902: Receive BREAK=%d (no effect)\n", value? 1:0); |
| 318 | if (VERBOSE>2) LOG("TMS9902: Receive BREAK=%d (no effect)\n", value? 1:0); |
| 318 | 319 | } |
| 319 | 320 | |
| 320 | 321 | //------------------------------------------------ |
| r12423 | r12424 | |
| 403 | 404 | { |
| 404 | 405 | tms9902_t *tms9902 = get_token(device); |
| 405 | 406 | int value = (tms9902->CLK4M? 0x800 : 0) | (tms9902->RDV8? 0x400 : 0) | tms9902->RDR; |
| 406 | | if (VERBOSE>3) logerror("receive rate = %04x\n", value); |
| 407 | if (VERBOSE>3) LOG("receive rate = %04x\n", value); |
| 407 | 408 | |
| 408 | 409 | // Calculate the ratio between receive baud rate and polling frequency |
| 409 | 410 | double fint = tms9902->clock_rate / ((tms9902->CLK4M) ? 4.0 : 3.0); |
| r12423 | r12424 | |
| 414 | 415 | // Thus the callback function should add up this value on each poll |
| 415 | 416 | // and deliver a data input not before it sums up to 1. |
| 416 | 417 | tms9902->baudpoll = (double)(baud / (10*POLLING_FREQ)); |
| 417 | | if (VERBOSE>3) logerror ("baudpoll = %lf\n", tms9902->baudpoll); |
| 418 | if (VERBOSE>3) LOG ("baudpoll = %lf\n", tms9902->baudpoll); |
| 418 | 419 | |
| 419 | 420 | if (tms9902->intf->ctrl_callback) |
| 420 | 421 | (*tms9902->intf->ctrl_callback)(device, CONFIG, RATERECV, value); |
| r12423 | r12424 | |
| 428 | 429 | { |
| 429 | 430 | tms9902_t *tms9902 = get_token(device); |
| 430 | 431 | int value = (tms9902->CLK4M? 0x800 : 0) | (tms9902->XDV8? 0x400 : 0) | tms9902->XDR; |
| 431 | | if (VERBOSE>3) logerror("transmit rate = %04x\n", value); |
| 432 | if (VERBOSE>3) LOG("transmit rate = %04x\n", value); |
| 432 | 433 | if (tms9902->intf->ctrl_callback) |
| 433 | 434 | (*tms9902->intf->ctrl_callback)(device, CONFIG, RATEXMIT, value); |
| 434 | 435 | } |
| r12423 | r12424 | |
| 476 | 477 | if (lstate != tms9902->RTSflag) |
| 477 | 478 | { |
| 478 | 479 | // Signal RTS to the modem |
| 479 | | if (VERBOSE>3) logerror("TMS9902: Set RTS=%d\n", lstate? 1:0); |
| 480 | if (VERBOSE>3) LOG("TMS9902: Set RTS=%d\n", lstate? 1:0); |
| 480 | 481 | tms9902->RTSflag = lstate; |
| 481 | 482 | transmit_line_state(device); |
| 482 | 483 | } |
| r12423 | r12424 | |
| 495 | 496 | |
| 496 | 497 | field_interrupts(device); |
| 497 | 498 | |
| 498 | | if (VERBOSE>4) logerror("TMS9902: transmit XSR=%02x, RCL=%02x\n", tms9902->XSR, tms9902->RCL); |
| 499 | if (VERBOSE>4) LOG("TMS9902: transmit XSR=%02x, RCL=%02x\n", tms9902->XSR, tms9902->RCL); |
| 499 | 500 | |
| 500 | 501 | if (tms9902->intf->xmit_callback) |
| 501 | 502 | (*tms9902->intf->xmit_callback)(device, tms9902->XSR & (0xff >> (3-tms9902->RCL))); |
| r12423 | r12424 | |
| 574 | 575 | |
| 575 | 576 | case 0: |
| 576 | 577 | answer = tms9902->RBR; |
| 577 | | if (VERBOSE>3) logerror("TMS9902: Reading receive buffer\n"); |
| 578 | if (VERBOSE>3) LOG("TMS9902: Reading receive buffer\n"); |
| 578 | 579 | break; |
| 579 | 580 | } |
| 580 | 581 | return answer; |
| r12423 | r12424 | |
| 646 | 647 | set_stop_bits(device); |
| 647 | 648 | break; |
| 648 | 649 | default: |
| 649 | | if (VERBOSE>1) logerror("tms9902: Invalid control register address %d\n", offset); |
| 650 | if (VERBOSE>1) LOG("tms9902: Invalid control register address %d\n", offset); |
| 650 | 651 | } |
| 651 | 652 | } |
| 652 | 653 | else if (tms9902->register_select & register_select_LDIR) |
| r12423 | r12424 | |
| 758 | 759 | |
| 759 | 760 | if (offset == 0x11) |
| 760 | 761 | { |
| 761 | | if (VERBOSE>3) logerror("TMS9902: set BRKON=%d; BRK=%d\n", data, tms9902->BRKflag? 1:0); |
| 762 | if (VERBOSE>3) LOG("TMS9902: set BRKON=%d; BRK=%d\n", data, tms9902->BRKflag? 1:0); |
| 762 | 763 | tms9902->BRKON = (data!=0); |
| 763 | 764 | if (tms9902->BRKflag && data==0) |
| 764 | 765 | { |
| r12423 | r12424 | |
| 788 | 789 | // (the only way to clear the flag!) |
| 789 | 790 | tms9902->RIENB = (data!=0); |
| 790 | 791 | tms9902->RBRL = false; |
| 791 | | if (VERBOSE>4) logerror("TMS9902: set RBRL=0, set RIENB=%d\n", data); |
| 792 | if (VERBOSE>4) LOG("TMS9902: set RBRL=0, set RIENB=%d\n", data); |
| 792 | 793 | field_interrupts(device); |
| 793 | 794 | return; |
| 794 | 795 | } |
| r12423 | r12424 | |
| 797 | 798 | { |
| 798 | 799 | /* Transmit Buffer Interrupt Enable */ |
| 799 | 800 | tms9902->XBIENB = (data!=0); |
| 800 | | if (VERBOSE>4) logerror("TMS9902: set XBIENB=%d\n", data); |
| 801 | if (VERBOSE>4) LOG("TMS9902: set XBIENB=%d\n", data); |
| 801 | 802 | field_interrupts(device); |
| 802 | 803 | return; |
| 803 | 804 | } |
| r12423 | r12424 | |
| 817 | 818 | /* Data Set Change Interrupt Enable */ |
| 818 | 819 | tms9902->DSCENB = (data!=0); |
| 819 | 820 | tms9902->DSCH = false; |
| 820 | | if (VERBOSE>4) logerror("TMS9902: set DSCH=0, set DSCENB=%d\n", data); |
| 821 | if (VERBOSE>4) LOG("TMS9902: set DSCH=0, set DSCENB=%d\n", data); |
| 821 | 822 | field_interrupts(device); |
| 822 | 823 | return; |
| 823 | 824 | } |
| r12423 | r12424 | |
| 831 | 832 | return; |
| 832 | 833 | } |
| 833 | 834 | else |
| 834 | | if (VERBOSE>1) logerror("tms9902: Write to undefined address %0x ignored.\n", offset); |
| 835 | if (VERBOSE>1) LOG("tms9902: Write to undefined address %0x ignored.\n", offset); |
| 835 | 836 | } |
| 836 | 837 | |
| 837 | 838 | |