trunk/src/mame/drivers/cubo.c
| r30675 | r30676 | |
| 328 | 328 | m_cdda(*this, "cdda") |
| 329 | 329 | { } |
| 330 | 330 | |
| 331 | | DECLARE_WRITE8_MEMBER(microtouch_tx); |
| 332 | | |
| 333 | 331 | DECLARE_CUSTOM_INPUT_MEMBER(cubo_input); |
| 334 | 332 | DECLARE_CUSTOM_INPUT_MEMBER(cd32_sel_mirror_input); |
| 335 | 333 | |
| r30675 | r30676 | |
| 353 | 351 | UINT16 m_potgo_value; |
| 354 | 352 | |
| 355 | 353 | protected: |
| 356 | | virtual void serdat_w(UINT16 data); |
| 354 | virtual void rs232_tx(int state); |
| 357 | 355 | virtual void potgo_w(UINT16 data); |
| 358 | 356 | |
| 359 | 357 | private: |
| 360 | | required_device<microtouch_device> m_microtouch; |
| 358 | required_device<microtouch_serial_device> m_microtouch; |
| 361 | 359 | required_device<cdda_device> m_cdda; |
| 362 | 360 | |
| 363 | 361 | typedef void (cubo_state::*input_hack_func)(); |
| r30675 | r30676 | |
| 430 | 428 | * |
| 431 | 429 | *************************************/ |
| 432 | 430 | |
| 431 | void cubo_state::rs232_tx(int state) |
| 432 | { |
| 433 | m_microtouch->rx_w(state); |
| 434 | } |
| 435 | |
| 433 | 436 | void cubo_state::potgo_w(UINT16 data) |
| 434 | 437 | { |
| 435 | 438 | int i; |
| r30675 | r30676 | |
| 1070 | 1073 | MCFG_DEVICE_ADD("cia_1", MOS8520, amiga_state::CLK_E_PAL) |
| 1071 | 1074 | MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(amiga_state, cia_1_irq)) |
| 1072 | 1075 | |
| 1073 | | MCFG_MICROTOUCH_ADD("microtouch", WRITE8(cubo_state, microtouch_tx)) |
| 1076 | MCFG_MICROTOUCH_SERIAL_ADD("microtouch", 9600, WRITELINE(cubo_state, rs232_rx_w)) |
| 1074 | 1077 | |
| 1075 | 1078 | MCFG_CDROM_ADD("cd32_cdrom") |
| 1076 | 1079 | MCFG_CDROM_INTERFACE("cd32_cdrom") |
| r30675 | r30676 | |
| 1342 | 1345 | INPUT_PORTS_END |
| 1343 | 1346 | |
| 1344 | 1347 | |
| 1345 | | void cubo_state::serdat_w(UINT16 data) |
| 1346 | | { |
| 1347 | | data &= 0xff; |
| 1348 | | if (data) |
| 1349 | | m_microtouch->rx(generic_space(), 0, data); |
| 1350 | | } |
| 1351 | 1348 | |
| 1352 | | WRITE8_MEMBER( cubo_state::microtouch_tx ) |
| 1353 | | { |
| 1354 | | serial_in_w(data); |
| 1355 | | } |
| 1356 | | |
| 1357 | | |
| 1358 | | |
| 1359 | 1349 | GAME( 1993, cubo, 0, cubo, cubo, cubo_state, cubo, ROT0, "Commodore", "Cubo BIOS", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND | GAME_IS_BIOS_ROOT ) |
| 1360 | 1350 | GAME( 1995, cndypuzl, cubo, cubo, cndypuzl, cubo_state, cndypuzl, ROT0, "CD Express", "Candy Puzzle (v1.0)", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
| 1361 | 1351 | GAME( 1995, haremchl, cubo, cubo, haremchl, cubo_state, haremchl, ROT0, "CD Express", "Harem Challenge", GAME_IMPERFECT_GRAPHICS | GAME_IMPERFECT_SOUND ) |
trunk/src/mame/drivers/alg.c
| r30675 | r30676 | |
| 53 | 53 | TIMER_CALLBACK_MEMBER(response_timer); |
| 54 | 54 | |
| 55 | 55 | protected: |
| 56 | | // driver_device overrides |
| 57 | | virtual void machine_start(); |
| 58 | | |
| 59 | 56 | // amiga_state overrides |
| 60 | | virtual void vblank(); |
| 61 | | virtual void serdat_w(UINT16 data); |
| 62 | 57 | virtual void potgo_w(UINT16 data); |
| 63 | 58 | |
| 64 | 59 | private: |
| 65 | 60 | required_device<sony_ldp1450_device> m_laserdisc; |
| 66 | 61 | |
| 67 | | emu_timer *m_serial_timer; |
| 68 | | UINT8 m_serial_timer_active; |
| 69 | | |
| 70 | 62 | UINT16 m_input_select; |
| 71 | 63 | }; |
| 72 | 64 | |
| r30675 | r30676 | |
| 97 | 89 | |
| 98 | 90 | |
| 99 | 91 | |
| 92 | |
| 100 | 93 | /************************************* |
| 101 | 94 | * |
| 102 | 95 | * Video startup |
| r30675 | r30676 | |
| 115 | 108 | |
| 116 | 109 | |
| 117 | 110 | |
| 118 | | /************************************* |
| 119 | | * |
| 120 | | * Machine start/reset |
| 121 | | * |
| 122 | | *************************************/ |
| 123 | 111 | |
| 124 | | void alg_state::machine_start() |
| 125 | | { |
| 126 | | amiga_state::machine_start(); |
| 127 | | |
| 128 | | m_serial_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(alg_state::response_timer),this)); |
| 129 | | m_serial_timer_active = FALSE; |
| 130 | | } |
| 131 | | |
| 132 | | |
| 133 | | |
| 134 | 112 | /************************************* |
| 135 | 113 | * |
| 136 | | * Laserdisc communication |
| 137 | | * |
| 138 | | *************************************/ |
| 139 | | |
| 140 | | TIMER_CALLBACK_MEMBER(alg_state::response_timer) |
| 141 | | { |
| 142 | | /* if we still have data to send, do it now */ |
| 143 | | if (m_laserdisc->data_available_r() == ASSERT_LINE) |
| 144 | | { |
| 145 | | UINT8 data = m_laserdisc->data_r(); |
| 146 | | if (data != 0x0a) |
| 147 | | osd_printf_debug("Sending serial data = %02X\n", data); |
| 148 | | serial_in_w(data); |
| 149 | | } |
| 150 | | |
| 151 | | /* if there's more to come, set another timer */ |
| 152 | | if (m_laserdisc->data_available_r() == ASSERT_LINE) |
| 153 | | m_serial_timer->adjust(serial_char_period()); |
| 154 | | else |
| 155 | | m_serial_timer_active = FALSE; |
| 156 | | } |
| 157 | | |
| 158 | | |
| 159 | | void alg_state::vblank() |
| 160 | | { |
| 161 | | amiga_state::vblank(); |
| 162 | | |
| 163 | | /* if we have data available, set a timer to read it */ |
| 164 | | if (!m_serial_timer_active && m_laserdisc->data_available_r() == ASSERT_LINE) |
| 165 | | { |
| 166 | | m_serial_timer->adjust(serial_char_period()); |
| 167 | | m_serial_timer_active = TRUE; |
| 168 | | } |
| 169 | | } |
| 170 | | |
| 171 | | |
| 172 | | void alg_state::serdat_w(UINT16 data) |
| 173 | | { |
| 174 | | /* write to the laserdisc player */ |
| 175 | | m_laserdisc->data_w(data & 0xff); |
| 176 | | |
| 177 | | /* if we have data available, set a timer to read it */ |
| 178 | | if (!m_serial_timer_active && m_laserdisc->data_available_r() == ASSERT_LINE) |
| 179 | | { |
| 180 | | m_serial_timer->adjust(serial_char_period()); |
| 181 | | m_serial_timer_active = TRUE; |
| 182 | | } |
| 183 | | } |
| 184 | | |
| 185 | | |
| 186 | | |
| 187 | | /************************************* |
| 188 | | * |
| 189 | 114 | * I/O ports |
| 190 | 115 | * |
| 191 | 116 | *************************************/ |
| r30675 | r30676 | |
| 622 | 547 | |
| 623 | 548 | DRIVER_INIT_MEMBER( alg_state, ntsc ) |
| 624 | 549 | { |
| 625 | | m_agnus_id = AGNUS_HR_NTSC; |
| 550 | m_agnus_id = AGNUS_NTSC; |
| 626 | 551 | m_denise_id = DENISE; |
| 627 | 552 | } |
| 628 | 553 | |
| 629 | 554 | DRIVER_INIT_MEMBER( alg_state, pal ) |
| 630 | 555 | { |
| 631 | | m_agnus_id = AGNUS_HR_PAL; |
| 556 | m_agnus_id = AGNUS_PAL; |
| 632 | 557 | m_denise_id = DENISE; |
| 633 | 558 | } |
| 634 | 559 | |
trunk/src/mame/machine/amiga.c
| r30675 | r30676 | |
| 22 | 22 | #define LOG_CUSTOM 0 |
| 23 | 23 | #define LOG_CIA 0 |
| 24 | 24 | #define LOG_BLITS 0 |
| 25 | #define LOG_SERIAL 1 |
| 25 | 26 | |
| 26 | 27 | |
| 27 | 28 | |
| r30675 | r30676 | |
| 239 | 240 | // setup the timers |
| 240 | 241 | m_irq_timer = timer_alloc(TIMER_AMIGA_IRQ); |
| 241 | 242 | m_blitter_timer = timer_alloc(TIMER_AMIGA_BLITTER); |
| 243 | m_serial_timer = timer_alloc(TIMER_SERIAL); |
| 242 | 244 | |
| 243 | 245 | // start the scanline timer |
| 244 | 246 | timer_set(m_screen->time_until_pos(0), TIMER_SCANLINE); |
| r30675 | r30676 | |
| 290 | 292 | case TIMER_AMIGA_BLITTER: |
| 291 | 293 | amiga_blitter_proc(ptr, param); |
| 292 | 294 | break; |
| 293 | | case TIMER_FINISH_SERIAL_WRITE: |
| 294 | | finish_serial_write(ptr, param); |
| 295 | case TIMER_SERIAL: |
| 296 | serial_shift(); |
| 295 | 297 | break; |
| 296 | 298 | default: |
| 297 | | assert_always(FALSE, "Unknown id in amiga_state::device_timer"); |
| 299 | fatalerror("Invalid timer: %d\n", id); |
| 300 | break; |
| 298 | 301 | } |
| 299 | 302 | } |
| 300 | 303 | |
| r30675 | r30676 | |
| 412 | 415 | |
| 413 | 416 | UINT16 amiga_state::joy0dat_r() |
| 414 | 417 | { |
| 418 | if (m_input_device == NULL) |
| 419 | return m_joy0dat_port->read_safe(0xffff); |
| 420 | |
| 415 | 421 | if (m_input_device->read_safe(0xff) & 0x10) |
| 416 | 422 | return m_joy0dat_port->read_safe(0xffff); |
| 417 | 423 | else |
| r30675 | r30676 | |
| 420 | 426 | |
| 421 | 427 | UINT16 amiga_state::joy1dat_r() |
| 422 | 428 | { |
| 429 | if (m_input_device == NULL) |
| 430 | return m_joy1dat_port->read_safe(0xffff); |
| 431 | |
| 423 | 432 | if (m_input_device->read_safe(0xff) & 0x20) |
| 424 | 433 | return m_joy1dat_port->read_safe(0xffff); |
| 425 | 434 | else |
| r30675 | r30676 | |
| 1130 | 1139 | { |
| 1131 | 1140 | UINT8 data = 0; |
| 1132 | 1141 | |
| 1133 | | // centronics |
| 1142 | // bit 0 to 2, centronics |
| 1134 | 1143 | data |= m_centronics_busy << 0; |
| 1135 | 1144 | data |= m_centronics_perror << 1; |
| 1136 | | data |= m_centronics_select << 2; // shared with rs232 "ring indicator" (not emulated) |
| 1145 | data |= m_centronics_select << 2; |
| 1137 | 1146 | |
| 1138 | | // bit 3 to 7, serial line (not emulated) |
| 1147 | // bit 2 to 7, serial line |
| 1148 | data |= m_rs232_ri << 2; |
| 1149 | data |= m_rs232_dsr << 3; |
| 1150 | data |= m_rs232_cts << 4; |
| 1151 | data |= m_rs232_dcd << 5; |
| 1139 | 1152 | |
| 1140 | 1153 | return data; |
| 1141 | 1154 | } |
| 1142 | 1155 | |
| 1156 | WRITE8_MEMBER( amiga_state::cia_1_port_a_write ) |
| 1157 | { |
| 1158 | if (m_rs232) |
| 1159 | { |
| 1160 | m_rs232->write_rts(BIT(data, 6)); |
| 1161 | m_rs232->write_dtr(BIT(data, 7)); |
| 1162 | } |
| 1163 | } |
| 1164 | |
| 1143 | 1165 | WRITE_LINE_MEMBER( amiga_state::cia_1_irq ) |
| 1144 | 1166 | { |
| 1145 | 1167 | if (LOG_CIA) |
| r30675 | r30676 | |
| 1163 | 1185 | CUSTOM_REG(REG_DDFSTRT) = 0x18; |
| 1164 | 1186 | CUSTOM_REG(REG_DDFSTOP) = 0xd8; |
| 1165 | 1187 | CUSTOM_REG(REG_INTENA) = 0x0000; |
| 1166 | | CUSTOM_REG(REG_SERDATR) = 0x3000; |
| 1188 | CUSTOM_REG(REG_SERDATR) = SERDATR_RXD | SERDATR_TSRE | SERDATR_TBE; |
| 1167 | 1189 | CUSTOM_REG(REG_BEAMCON0) = (m_agnus_id & 0x10) ? 0x0000 : 0x0020; |
| 1168 | 1190 | } |
| 1169 | 1191 | |
| r30675 | r30676 | |
| 1193 | 1215 | return amiga_gethvpos(*m_screen) & 0xffff; |
| 1194 | 1216 | |
| 1195 | 1217 | case REG_SERDATR: |
| 1196 | | CUSTOM_REG(REG_SERDATR) &= ~0x4000; |
| 1197 | | CUSTOM_REG(REG_SERDATR) |= (CUSTOM_REG(REG_INTREQ) & INTENA_RBF) ? 0x4000 : 0x0000; |
| 1218 | if (LOG_SERIAL) |
| 1219 | logerror("r SERDATR: %04x\n", CUSTOM_REG(REG_SERDATR)); |
| 1220 | |
| 1198 | 1221 | return CUSTOM_REG(REG_SERDATR); |
| 1199 | 1222 | |
| 1200 | 1223 | case REG_JOY0DAT: |
| r30675 | r30676 | |
| 1301 | 1324 | break; |
| 1302 | 1325 | |
| 1303 | 1326 | case REG_SERDAT: |
| 1304 | | serdat_w(data); |
| 1305 | | CUSTOM_REG(REG_SERDATR) &= ~0x3000; |
| 1306 | | timer_set(serial_char_period(), TIMER_FINISH_SERIAL_WRITE); |
| 1307 | | break; |
| 1327 | if (LOG_SERIAL) |
| 1328 | logerror("w SERDAT: %04x\n", data); |
| 1308 | 1329 | |
| 1330 | CUSTOM_REG(REG_SERDAT) = data; |
| 1331 | |
| 1332 | // transmit shift register currently empty? |
| 1333 | if (CUSTOM_REG(REG_SERDATR) & SERDATR_TSRE) |
| 1334 | { |
| 1335 | // transfer new data to shift register |
| 1336 | m_tx_shift = CUSTOM_REG(REG_SERDAT); |
| 1337 | CUSTOM_REG(REG_SERDAT) = 0; |
| 1338 | |
| 1339 | // and signal transmit buffer empty |
| 1340 | CUSTOM_REG(REG_SERDATR) &= ~SERDATR_TSRE; |
| 1341 | CUSTOM_REG(REG_SERDATR) |= SERDATR_TBE; |
| 1342 | set_interrupt(INTENA_SETCLR | INTENA_TBE); |
| 1343 | } |
| 1344 | else |
| 1345 | { |
| 1346 | // transmit buffer now full |
| 1347 | CUSTOM_REG(REG_SERDATR) &= ~SERDATR_TBE; |
| 1348 | } |
| 1349 | |
| 1350 | return; |
| 1351 | |
| 1352 | case REG_SERPER: |
| 1353 | if (LOG_SERIAL) |
| 1354 | logerror("w SERPER: %04x\n", data); |
| 1355 | |
| 1356 | CUSTOM_REG(REG_SERPER) = data; |
| 1357 | serial_adjust(); |
| 1358 | |
| 1359 | return; |
| 1360 | |
| 1309 | 1361 | case REG_BLTSIZE: |
| 1310 | 1362 | CUSTOM_REG(REG_BLTSIZE) = data; |
| 1311 | 1363 | CUSTOM_REG(REG_BLTSIZV) = (data >> 6) & 0x3ff; |
| r30675 | r30676 | |
| 1418 | 1470 | |
| 1419 | 1471 | case REG_INTREQ: |
| 1420 | 1472 | temp = data; |
| 1421 | | // update serial data line status if appropriate */ |
| 1473 | |
| 1474 | // clear receive buffer full? |
| 1422 | 1475 | if (!(data & INTENA_SETCLR) && (data & INTENA_RBF)) |
| 1423 | | CUSTOM_REG(REG_SERDATR) &= ~INTENA_SETCLR; |
| 1476 | { |
| 1477 | CUSTOM_REG(REG_SERDATR) &= ~SERDATR_OVRUN; |
| 1478 | CUSTOM_REG(REG_SERDATR) &= ~SERDATR_RBF; |
| 1479 | } |
| 1424 | 1480 | |
| 1481 | // clear transmit buffer empty? |
| 1482 | if (!(data & INTENA_SETCLR) && (data & INTENA_TBE)) |
| 1483 | CUSTOM_REG(REG_SERDATR) |= SERDATR_TBE; |
| 1484 | |
| 1425 | 1485 | data = (data & INTENA_SETCLR) ? (CUSTOM_REG(offset) | (data & 0x7fff)) : (CUSTOM_REG(offset) & ~(data & 0x7fff)); |
| 1426 | 1486 | CUSTOM_REG(offset) = data; |
| 1427 | 1487 | |
| r30675 | r30676 | |
| 1519 | 1579 | // SERIAL |
| 1520 | 1580 | //************************************************************************** |
| 1521 | 1581 | |
| 1522 | | TIMER_CALLBACK_MEMBER( amiga_state::finish_serial_write ) |
| 1582 | void amiga_state::serial_adjust() |
| 1523 | 1583 | { |
| 1524 | | amiga_state *state = machine().driver_data<amiga_state>(); |
| 1584 | amiga_state *state = this; |
| 1525 | 1585 | |
| 1526 | | // mark the transfer buffer empty |
| 1527 | | CUSTOM_REG(REG_SERDATR) |= 0x3000; |
| 1586 | UINT32 divisor = (CUSTOM_REG(REG_SERPER) & 0x7fff) + 1; |
| 1587 | UINT32 baud = m_sound->clock() / divisor; |
| 1528 | 1588 | |
| 1529 | | // signal an interrupt |
| 1530 | | set_interrupt(INTENA_SETCLR | INTENA_TBE); |
| 1589 | m_serial_timer->adjust(attotime::from_hz(baud) / 2, 0, attotime::from_hz(baud)); |
| 1531 | 1590 | } |
| 1532 | 1591 | |
| 1533 | | void amiga_state::serial_in_w(UINT16 data) |
| 1592 | void amiga_state::serial_shift() |
| 1534 | 1593 | { |
| 1535 | 1594 | amiga_state *state = this; |
| 1536 | | int mask = (CUSTOM_REG(REG_SERPER) & 0x8000) ? 0x1ff : 0xff; |
| 1537 | 1595 | |
| 1538 | | // copy the data to the low 8 bits of SERDATR and set RBF |
| 1539 | | CUSTOM_REG(REG_SERDATR) &= ~0x3ff; |
| 1540 | | CUSTOM_REG(REG_SERDATR) |= (data & mask) | (mask + 1) | 0x4000; |
| 1596 | if (CUSTOM_REG(REG_ADKCON) & ADKCON_UARTBRK) |
| 1597 | { |
| 1598 | // break active, force low |
| 1599 | rs232_tx(0); |
| 1600 | } |
| 1601 | else |
| 1602 | { |
| 1603 | // transmit shift register not empty? |
| 1604 | if ((CUSTOM_REG(REG_SERDATR) & SERDATR_TSRE) == 0) |
| 1605 | { |
| 1606 | if (m_tx_state == 0) |
| 1607 | { |
| 1608 | // transmit start bit |
| 1609 | rs232_tx(0); |
| 1610 | m_tx_state++; |
| 1611 | } |
| 1612 | else if (m_tx_state <= 8 + BIT(CUSTOM_REG(REG_SERPER), 15)) |
| 1613 | { |
| 1614 | // send data bits |
| 1615 | rs232_tx(m_tx_shift & 1); |
| 1616 | m_tx_shift >>= 1; |
| 1617 | m_tx_state++; |
| 1618 | } |
| 1619 | else |
| 1620 | { |
| 1621 | // send stop bits until we run out |
| 1622 | if (m_tx_shift & 1) |
| 1623 | { |
| 1624 | rs232_tx(m_tx_shift & 1); |
| 1625 | m_tx_shift >>= 1; |
| 1626 | } |
| 1627 | else |
| 1628 | { |
| 1629 | // more data? |
| 1630 | if (CUSTOM_REG(REG_SERDAT)) |
| 1631 | { |
| 1632 | // transfer to shift register |
| 1633 | m_tx_shift = CUSTOM_REG(REG_SERDAT); |
| 1634 | CUSTOM_REG(REG_SERDAT) = 0; |
| 1541 | 1635 | |
| 1542 | | // set overrun if we weren't cleared |
| 1543 | | if (CUSTOM_REG(REG_INTREQ) & INTENA_RBF) |
| 1636 | // signal buffer empty |
| 1637 | CUSTOM_REG(REG_SERDATR) |= SERDATR_TBE; |
| 1638 | set_interrupt(INTENA_SETCLR | INTENA_TBE); |
| 1639 | } |
| 1640 | else |
| 1641 | { |
| 1642 | // we're done |
| 1643 | CUSTOM_REG(REG_SERDATR) |= SERDATR_TSRE; |
| 1644 | } |
| 1645 | |
| 1646 | m_tx_state = 0; |
| 1647 | } |
| 1648 | } |
| 1649 | } |
| 1650 | else |
| 1651 | { |
| 1652 | // transmit register empty |
| 1653 | rs232_tx(1); |
| 1654 | } |
| 1655 | } |
| 1656 | |
| 1657 | // waiting for start bit? |
| 1658 | if (m_rx_state == 0) |
| 1544 | 1659 | { |
| 1545 | | osd_printf_debug("Serial data overflow\n"); |
| 1546 | | CUSTOM_REG(REG_SERDATR) |= 0x8000; |
| 1660 | // start bit seen (high to low transition) |
| 1661 | if (m_rx_previous && (CUSTOM_REG(REG_SERDATR) & SERDATR_RXD) == 0) |
| 1662 | { |
| 1663 | m_rx_state++; |
| 1664 | } |
| 1547 | 1665 | } |
| 1666 | else if (m_rx_state <= 8 + BIT(CUSTOM_REG(REG_SERPER), 15)) |
| 1667 | { |
| 1668 | // receive data |
| 1669 | m_rx_shift >>= 1; |
| 1670 | m_rx_shift = (m_rx_shift & 0x7fff) | (BIT(CUSTOM_REG(REG_SERDATR), 11) << 15); |
| 1671 | m_rx_state++; |
| 1672 | } |
| 1673 | else |
| 1674 | { |
| 1675 | // stop bit |
| 1676 | m_rx_shift >>= 1; |
| 1677 | m_rx_shift = (m_rx_shift & 0x7fff) | (BIT(CUSTOM_REG(REG_SERDATR), 11) << 15); |
| 1548 | 1678 | |
| 1549 | | // signal an interrupt |
| 1550 | | set_interrupt(INTENA_SETCLR | INTENA_RBF); |
| 1679 | // shift to start |
| 1680 | m_rx_shift >>= (15 - (8 + BIT(CUSTOM_REG(REG_SERPER), 15))); |
| 1681 | |
| 1682 | // save data |
| 1683 | CUSTOM_REG(REG_SERDATR) &= ~0x3ff; |
| 1684 | CUSTOM_REG(REG_SERDATR) |= m_rx_shift & 0x3ff; |
| 1685 | |
| 1686 | // overrun? |
| 1687 | if (CUSTOM_REG(REG_SERDATR) & SERDATR_RBF) |
| 1688 | CUSTOM_REG(REG_SERDATR) |= SERDATR_OVRUN; |
| 1689 | |
| 1690 | // set ready and signal interrupt |
| 1691 | CUSTOM_REG(REG_SERDATR) |= SERDATR_RBF; |
| 1692 | set_interrupt(INTENA_SETCLR | INTENA_RBF); |
| 1693 | |
| 1694 | m_rx_shift = 0; |
| 1695 | m_rx_state = 0; |
| 1696 | } |
| 1551 | 1697 | } |
| 1552 | 1698 | |
| 1553 | | attotime amiga_state::serial_char_period() |
| 1699 | void amiga_state::rs232_tx(int state) |
| 1554 | 1700 | { |
| 1555 | | amiga_state *state = this; |
| 1701 | if (m_rs232) |
| 1702 | m_rs232->write_txd(state); |
| 1703 | } |
| 1556 | 1704 | |
| 1557 | | UINT32 divisor = (CUSTOM_REG(REG_SERPER) & 0x7fff) + 1; |
| 1558 | | UINT32 baud = m_maincpu->unscaled_clock() / 2 / divisor; |
| 1559 | | UINT32 numbits = 2 + ((CUSTOM_REG(REG_SERPER) & 0x8000) ? 9 : 8); |
| 1705 | void amiga_state::rx_write(amiga_state *state, int level) |
| 1706 | { |
| 1707 | m_rx_previous = BIT(CUSTOM_REG(REG_SERDATR), 11); |
| 1708 | CUSTOM_REG(REG_SERDATR) &= ~SERDATR_RXD; |
| 1709 | CUSTOM_REG(REG_SERDATR) |= level << 11; |
| 1710 | } |
| 1560 | 1711 | |
| 1561 | | return attotime::from_hz(baud) * numbits; |
| 1712 | WRITE_LINE_MEMBER( amiga_state::rs232_rx_w ) |
| 1713 | { |
| 1714 | rx_write(this, state); |
| 1715 | |
| 1716 | // start bit received? |
| 1717 | if (m_rx_state == 1) |
| 1718 | serial_adjust(); |
| 1562 | 1719 | } |
| 1720 | |
| 1721 | WRITE_LINE_MEMBER( amiga_state::rs232_dcd_w ) |
| 1722 | { |
| 1723 | m_rs232_dcd = state; |
| 1724 | } |
| 1725 | |
| 1726 | WRITE_LINE_MEMBER( amiga_state::rs232_dsr_w ) |
| 1727 | { |
| 1728 | m_rs232_dsr = state; |
| 1729 | } |
| 1730 | |
| 1731 | WRITE_LINE_MEMBER( amiga_state::rs232_ri_w ) |
| 1732 | { |
| 1733 | m_rs232_ri = state; |
| 1734 | } |
| 1735 | |
| 1736 | WRITE_LINE_MEMBER( amiga_state::rs232_cts_w ) |
| 1737 | { |
| 1738 | m_rs232_cts = state; |
| 1739 | } |
trunk/src/mame/includes/amiga.h
| r30675 | r30676 | |
| 12 | 12 | |
| 13 | 13 | #include "cpu/m68000/m68000.h" |
| 14 | 14 | #include "machine/bankdev.h" |
| 15 | #include "bus/rs232/rs232.h" |
| 15 | 16 | #include "bus/centronics/ctronics.h" |
| 16 | 17 | #include "machine/mos6526.h" |
| 17 | 18 | #include "machine/amigafdc.h" |
| r30675 | r30676 | |
| 332 | 333 | m_maincpu(*this, "maincpu"), |
| 333 | 334 | m_cia_0(*this, "cia_0"), |
| 334 | 335 | m_cia_1(*this, "cia_1"), |
| 336 | m_rs232(*this, "rs232"), |
| 335 | 337 | m_centronics(*this, "centronics"), |
| 336 | 338 | m_sound(*this, "amiga"), |
| 337 | 339 | m_fdc(*this, "fdc"), |
| r30675 | r30676 | |
| 358 | 360 | m_centronics_busy(0), |
| 359 | 361 | m_centronics_perror(0), |
| 360 | 362 | m_centronics_select(0), |
| 361 | | m_gayle_reset(false) |
| 363 | m_gayle_reset(false), |
| 364 | m_rx_shift(0), |
| 365 | m_tx_shift(0), |
| 366 | m_rx_state(0), |
| 367 | m_tx_state(0), |
| 368 | m_rx_previous(1) |
| 362 | 369 | { } |
| 363 | 370 | |
| 364 | 371 | |
| r30675 | r30676 | |
| 417 | 424 | TIMER_CALLBACK_MEMBER( scanline_callback ); |
| 418 | 425 | TIMER_CALLBACK_MEMBER (amiga_irq_proc ); |
| 419 | 426 | TIMER_CALLBACK_MEMBER( amiga_blitter_proc ); |
| 420 | | TIMER_CALLBACK_MEMBER( finish_serial_write ); |
| 421 | | |
| 422 | 427 | void update_irqs(); |
| 423 | 428 | |
| 424 | | void serial_in_w(UINT16 data); |
| 425 | | attotime serial_char_period(); |
| 426 | | |
| 427 | 429 | DECLARE_CUSTOM_INPUT_MEMBER( amiga_joystick_convert ); |
| 428 | 430 | DECLARE_CUSTOM_INPUT_MEMBER( floppy_drive_status ); |
| 429 | 431 | |
| r30675 | r30676 | |
| 435 | 437 | DECLARE_WRITE8_MEMBER( cia_0_port_a_write ); |
| 436 | 438 | DECLARE_WRITE_LINE_MEMBER( cia_0_irq ); |
| 437 | 439 | DECLARE_READ8_MEMBER( cia_1_port_a_read ); |
| 440 | DECLARE_WRITE8_MEMBER( cia_1_port_a_write ); |
| 438 | 441 | DECLARE_WRITE_LINE_MEMBER( cia_1_irq ); |
| 439 | 442 | |
| 443 | DECLARE_WRITE_LINE_MEMBER( rs232_rx_w ); |
| 444 | DECLARE_WRITE_LINE_MEMBER( rs232_dcd_w ); |
| 445 | DECLARE_WRITE_LINE_MEMBER( rs232_dsr_w ); |
| 446 | DECLARE_WRITE_LINE_MEMBER( rs232_ri_w ); |
| 447 | DECLARE_WRITE_LINE_MEMBER( rs232_cts_w ); |
| 448 | |
| 440 | 449 | DECLARE_WRITE_LINE_MEMBER( centronics_ack_w ); |
| 441 | 450 | DECLARE_WRITE_LINE_MEMBER( centronics_busy_w ); |
| 442 | 451 | DECLARE_WRITE_LINE_MEMBER( centronics_perror_w ); |
| r30675 | r30676 | |
| 524 | 533 | virtual void vblank(); |
| 525 | 534 | |
| 526 | 535 | virtual void potgo_w(UINT16 data) {}; |
| 527 | | virtual void serdat_w(UINT16 data) {}; |
| 528 | 536 | |
| 529 | 537 | // joystick/mouse |
| 530 | 538 | virtual UINT16 joy0dat_r(); |
| 531 | 539 | virtual UINT16 joy1dat_r(); |
| 532 | 540 | |
| 541 | // serial |
| 542 | virtual void rs232_tx(int state); |
| 543 | |
| 533 | 544 | // devices |
| 534 | 545 | required_device<m68000_base_device> m_maincpu; |
| 535 | 546 | required_device<mos8520_device> m_cia_0; |
| 536 | 547 | required_device<mos8520_device> m_cia_1; |
| 548 | optional_device<rs232_port_device> m_rs232; |
| 537 | 549 | optional_device<centronics_device> m_centronics; |
| 538 | 550 | required_device<amiga_sound_device> m_sound; |
| 539 | 551 | optional_device<amiga_fdc> m_fdc; |
| r30675 | r30676 | |
| 569 | 581 | TIMER_SCANLINE, |
| 570 | 582 | TIMER_AMIGA_IRQ, |
| 571 | 583 | TIMER_AMIGA_BLITTER, |
| 572 | | TIMER_FINISH_SERIAL_WRITE |
| 584 | TIMER_SERIAL |
| 573 | 585 | }; |
| 574 | 586 | |
| 587 | enum |
| 588 | { |
| 589 | ADKCON_UARTBRK = 0x800 // send break |
| 590 | }; |
| 591 | |
| 592 | // serial port flags |
| 593 | enum |
| 594 | { |
| 595 | SERDATR_RXD = 0x0800, // serial data |
| 596 | SERDATR_TSRE = 0x1000, // transmit ready |
| 597 | SERDATR_TBE = 0x2000, // transmit buffer empty |
| 598 | SERDATR_RBF = 0x4000, // receive buffer full |
| 599 | SERDATR_OVRUN = 0x8000 // receive buffer overrun |
| 600 | }; |
| 601 | |
| 602 | enum |
| 603 | { |
| 604 | SERPER_LONG = 0x8000 // 9-bit mode |
| 605 | }; |
| 606 | |
| 575 | 607 | int m_centronics_busy; |
| 576 | 608 | int m_centronics_perror; |
| 577 | 609 | int m_centronics_select; |
| 578 | 610 | |
| 579 | 611 | emu_timer *m_irq_timer; |
| 612 | emu_timer *m_serial_timer; |
| 580 | 613 | |
| 581 | 614 | bool m_gayle_reset; |
| 582 | 615 | |
| 583 | 616 | bitmap_ind16 m_flickerfixer; |
| 617 | |
| 618 | UINT16 m_rx_shift; |
| 619 | UINT16 m_tx_shift; |
| 620 | |
| 621 | int m_rx_state; |
| 622 | int m_tx_state; |
| 623 | int m_rx_previous; |
| 624 | |
| 625 | int m_rs232_dcd; |
| 626 | int m_rs232_dsr; |
| 627 | int m_rs232_ri; |
| 628 | int m_rs232_cts; |
| 629 | |
| 630 | void serial_adjust(); |
| 631 | void serial_shift(); |
| 632 | void rx_write(amiga_state *state, int level); |
| 584 | 633 | }; |
| 585 | 634 | |
| 586 | 635 | |
trunk/src/mess/drivers/amiga.c
| r30675 | r30676 | |
| 1255 | 1255 | MCFG_DEVICE_ADD("cia_1", MOS8520, amiga_state::CLK_E_PAL) |
| 1256 | 1256 | MCFG_MOS6526_IRQ_CALLBACK(WRITELINE(amiga_state, cia_1_irq)) |
| 1257 | 1257 | MCFG_MOS6526_PA_INPUT_CALLBACK(READ8(amiga_state, cia_1_port_a_read)) |
| 1258 | MCFG_MOS6526_PA_OUTPUT_CALLBACK(WRITE8(amiga_state, cia_1_port_a_write)) |
| 1258 | 1259 | MCFG_MOS6526_PB_OUTPUT_CALLBACK(DEVWRITE8("fdc", amiga_fdc, ciaaprb_w)) |
| 1259 | 1260 | |
| 1260 | 1261 | // audio |
| r30675 | r30676 | |
| 1272 | 1273 | MCFG_FLOPPY_DRIVE_ADD("fdc:2", amiga_floppies, 0, amiga_fdc::floppy_formats) |
| 1273 | 1274 | MCFG_FLOPPY_DRIVE_ADD("fdc:3", amiga_floppies, 0, amiga_fdc::floppy_formats) |
| 1274 | 1275 | |
| 1276 | // rs232 |
| 1277 | MCFG_RS232_PORT_ADD("rs232", default_rs232_devices, NULL) |
| 1278 | MCFG_RS232_RXD_HANDLER(WRITELINE(amiga_state, rs232_rx_w)) |
| 1279 | MCFG_RS232_DCD_HANDLER(WRITELINE(amiga_state, rs232_dcd_w)) |
| 1280 | MCFG_RS232_DSR_HANDLER(WRITELINE(amiga_state, rs232_dsr_w)) |
| 1281 | MCFG_RS232_RI_HANDLER(WRITELINE(amiga_state, rs232_ri_w)) |
| 1282 | MCFG_RS232_CTS_HANDLER(WRITELINE(amiga_state, rs232_cts_w)) |
| 1283 | |
| 1275 | 1284 | // centronics |
| 1276 | 1285 | MCFG_CENTRONICS_ADD("centronics", centronics_printers, "printer") |
| 1277 | 1286 | MCFG_CENTRONICS_ACK_HANDLER(WRITELINE(amiga_state, centronics_ack_w)) |
| r30675 | r30676 | |
| 1280 | 1289 | MCFG_CENTRONICS_SELECT_HANDLER(WRITELINE(amiga_state, centronics_select_w)) |
| 1281 | 1290 | MCFG_CENTRONICS_OUTPUT_LATCH_ADD("cent_data_out", "centronics") |
| 1282 | 1291 | |
| 1283 | | // todo: rs232 |
| 1284 | | |
| 1285 | 1292 | // keyboard |
| 1286 | 1293 | MCFG_DEVICE_ADD("kbd", AMIGAKBD, 0) |
| 1287 | 1294 | MCFG_AMIGA_KEYBOARD_KCLK_CALLBACK(DEVWRITELINE("cia_0", mos8520_device, cnt_w)) |