trunk/src/mess/drivers/ng_aes.c
| r19379 | r19380 | |
| 107 | 107 | NeoCDDMAValue2 = 0; |
| 108 | 108 | NeoCDDMACount = 0; |
| 109 | 109 | NeoCDDMAMode = 0; |
| 110 | nIRQAcknowledge = ~0; |
| 111 | nNeoCDIRQVectorAck = 0; |
| 112 | nNeoCDIRQVector = 0; |
| 110 | 113 | |
| 111 | 114 | } |
| 112 | 115 | |
| r19379 | r19380 | |
| 152 | 155 | INT32 NeoCDDMAValue2; |
| 153 | 156 | INT32 NeoCDDMACount; |
| 154 | 157 | INT32 NeoCDDMAMode; |
| 158 | INT32 nIRQAcknowledge; |
| 159 | int nNeoCDIRQVectorAck; |
| 160 | int nNeoCDIRQVector; |
| 155 | 161 | |
| 162 | int get_nNeoCDIRQVectorAck(void) { return nNeoCDIRQVectorAck; } |
| 163 | void set_nNeoCDIRQVectorAck(int val) { nNeoCDIRQVectorAck = val; } |
| 164 | int get_nNeoCDIRQVector(void) { return nNeoCDIRQVector; } |
| 165 | void NeoCDIRQUpdate(UINT8 byteValue); |
| 166 | |
| 167 | // from the CDC |
| 168 | void interrupt_callback_type1(void); |
| 169 | void interrupt_callback_type2(void); |
| 170 | void interrupt_callback_type3(void); |
| 171 | |
| 156 | 172 | UINT8 nTransferWriteEnable; |
| 157 | 173 | |
| 158 | 174 | address_space* curr_space; |
| r19379 | r19380 | |
| 323 | 339 | break; |
| 324 | 340 | |
| 325 | 341 | case 0x000E: |
| 326 | | m_tempcdc->NeoCDIRQUpdate(wordValue); // irqack |
| 342 | NeoCDIRQUpdate(wordValue); // irqack |
| 327 | 343 | break; |
| 328 | 344 | |
| 329 | 345 | case 0x0016: |
| r19379 | r19380 | |
| 447 | 463 | break; |
| 448 | 464 | |
| 449 | 465 | case 0x0180: { |
| 450 | | static UINT8 clara = 0; |
| 451 | | if (!byteValue && clara) { |
| 452 | | // bprintf(PRINT_IMPORTANT, _T(" - NGCD CD communication reset (PC: 0x%06X)\n"), SekGetPC(-1)); |
| 453 | | // NeoCDCommsReset(); |
| 466 | // 1 during CD access, 0 otherwise, written frequently |
| 467 | //printf("reset cdc %04x %04x\n",data, mem_mask); |
| 468 | |
| 469 | if (ACCESSING_BITS_0_7) |
| 470 | { |
| 471 | if (data==0x00) |
| 472 | { |
| 473 | m_tempcdc->NeoCDCommsReset(); |
| 474 | } |
| 454 | 475 | } |
| 455 | | clara = byteValue; |
| 456 | 476 | break; |
| 457 | 477 | } |
| 458 | 478 | case 0x0182: { |
| r19379 | r19380 | |
| 1509 | 1529 | |
| 1510 | 1530 | if (irqline==4) |
| 1511 | 1531 | { |
| 1512 | | if (state->m_tempcdc->get_nNeoCDIRQVectorAck()) { |
| 1513 | | state->m_tempcdc->set_nNeoCDIRQVectorAck(0); |
| 1514 | | return state->m_tempcdc->get_nNeoCDIRQVector(); |
| 1532 | if (state->get_nNeoCDIRQVectorAck()) { |
| 1533 | state->set_nNeoCDIRQVectorAck(0); |
| 1534 | return state->get_nNeoCDIRQVector(); |
| 1515 | 1535 | } |
| 1516 | 1536 | } |
| 1517 | 1537 | |
| 1518 | 1538 | return (0x60+irqline*4)/4; |
| 1519 | 1539 | } |
| 1520 | 1540 | |
| 1541 | void ng_aes_state::interrupt_callback_type1(void) |
| 1542 | { |
| 1543 | nIRQAcknowledge &= ~0x20; |
| 1544 | NeoCDIRQUpdate(0); |
| 1545 | } |
| 1521 | 1546 | |
| 1547 | void ng_aes_state::interrupt_callback_type2(void) |
| 1548 | { |
| 1549 | nIRQAcknowledge &= ~0x10; |
| 1550 | NeoCDIRQUpdate(0); |
| 1551 | } |
| 1522 | 1552 | |
| 1553 | void ng_aes_state::interrupt_callback_type3(void) |
| 1554 | { |
| 1555 | nIRQAcknowledge &= ~0x08; |
| 1556 | NeoCDIRQUpdate(0); |
| 1557 | } |
| 1558 | |
| 1559 | |
| 1560 | void ng_aes_state::NeoCDIRQUpdate(UINT8 byteValue) |
| 1561 | { |
| 1562 | // do we also need to check the regular interrupts like FBA? |
| 1563 | |
| 1564 | nIRQAcknowledge |= (byteValue & 0x38); |
| 1565 | |
| 1566 | if ((nIRQAcknowledge & 0x08) == 0) { |
| 1567 | nNeoCDIRQVector = 0x17; |
| 1568 | nNeoCDIRQVectorAck = 1; |
| 1569 | machine().device("maincpu")->execute().set_input_line(4, HOLD_LINE); |
| 1570 | return; |
| 1571 | } |
| 1572 | if ((nIRQAcknowledge & 0x10) == 0) { |
| 1573 | nNeoCDIRQVector = 0x16; |
| 1574 | nNeoCDIRQVectorAck = 1; |
| 1575 | machine().device("maincpu")->execute().set_input_line(4, HOLD_LINE); |
| 1576 | return; |
| 1577 | } |
| 1578 | if ((nIRQAcknowledge & 0x20) == 0) { |
| 1579 | nNeoCDIRQVector = 0x15; |
| 1580 | nNeoCDIRQVectorAck = 1; |
| 1581 | machine().device("maincpu")->execute().set_input_line(4, HOLD_LINE); |
| 1582 | return; |
| 1583 | } |
| 1584 | } |
| 1585 | |
| 1523 | 1586 | struct cdrom_interface neocd_cdrom = |
| 1524 | 1587 | { |
| 1525 | 1588 | "neocd_cdrom", |
| r19379 | r19380 | |
| 1538 | 1601 | // temporary until things are cleaned up |
| 1539 | 1602 | MCFG_DEVICE_ADD("tempcdc", LC89510_TEMP, 0) // cd controller |
| 1540 | 1603 | MCFG_SEGACD_HACK_SET_NEOCD |
| 1604 | MCFG_SET_TYPE1_INTERRUPT_CALLBACK( ng_aes_state, interrupt_callback_type1 ) |
| 1605 | MCFG_SET_TYPE2_INTERRUPT_CALLBACK( ng_aes_state, interrupt_callback_type2 ) |
| 1606 | MCFG_SET_TYPE3_INTERRUPT_CALLBACK( ng_aes_state, interrupt_callback_type3 ) |
| 1541 | 1607 | |
| 1608 | |
| 1542 | 1609 | MCFG_MEMCARD_HANDLER(neogeo_aes) |
| 1543 | 1610 | |
| 1544 | 1611 | MCFG_MACHINE_START_OVERRIDE(ng_aes_state,neocd) |
trunk/src/mame/machine/megacdcd.c
| r19379 | r19380 | |
| 14 | 14 | : device_t(mconfig, LC89510_TEMP, "lc89510_temp_device", tag, owner, clock) |
| 15 | 15 | { |
| 16 | 16 | segacd_dma_callback = segacd_dma_delegate(FUNC(lc89510_temp_device::Fake_CDC_Do_DMA), this); |
| 17 | type1_interrupt_callback = interrupt_delegate(FUNC(lc89510_temp_device::dummy_interrupt_callback), this); |
| 18 | type2_interrupt_callback = interrupt_delegate(FUNC(lc89510_temp_device::dummy_interrupt_callback), this); |
| 19 | type3_interrupt_callback = interrupt_delegate(FUNC(lc89510_temp_device::dummy_interrupt_callback), this); |
| 20 | |
| 17 | 21 | is_neoCD = false; |
| 18 | 22 | |
| 19 | 23 | nff0002 = 0; |
| 20 | | nIRQAcknowledge = ~0; |
| 21 | 24 | for (int i=0;i<10;i++) |
| 22 | 25 | CDD_TX[i] = 0; |
| 23 | 26 | for (int i=0;i<10;i++) |
| r19379 | r19380 | |
| 27 | 30 | SCD_CURLBA = 0; |
| 28 | 31 | |
| 29 | 32 | CDC_REG0 = 0; |
| 30 | | nNeoCDIRQVectorAck = 0; |
| 31 | | nNeoCDIRQVector = 0; |
| 32 | 33 | } |
| 33 | 34 | |
| 35 | void lc89510_temp_device::dummy_interrupt_callback(void) |
| 36 | { |
| 34 | 37 | |
| 38 | } |
| 35 | 39 | |
| 36 | 40 | void lc89510_temp_device::set_CDC_Do_DMA(device_t &device,segacd_dma_delegate new_segacd_dma_callback) |
| 37 | 41 | { |
| r19379 | r19380 | |
| 39 | 43 | dev.segacd_dma_callback = new_segacd_dma_callback; |
| 40 | 44 | } |
| 41 | 45 | |
| 46 | void lc89510_temp_device::set_type1_interrupt_callback(device_t &device,interrupt_delegate interrupt_callback) |
| 47 | { |
| 48 | lc89510_temp_device &dev = downcast<lc89510_temp_device &>(device); |
| 49 | dev.type1_interrupt_callback = interrupt_callback; |
| 50 | } |
| 51 | |
| 52 | void lc89510_temp_device::set_type2_interrupt_callback(device_t &device,interrupt_delegate interrupt_callback) |
| 53 | { |
| 54 | lc89510_temp_device &dev = downcast<lc89510_temp_device &>(device); |
| 55 | dev.type2_interrupt_callback = interrupt_callback; |
| 56 | } |
| 57 | |
| 58 | void lc89510_temp_device::set_type3_interrupt_callback(device_t &device,interrupt_delegate interrupt_callback) |
| 59 | { |
| 60 | lc89510_temp_device &dev = downcast<lc89510_temp_device &>(device); |
| 61 | dev.type3_interrupt_callback = interrupt_callback; |
| 62 | } |
| 63 | |
| 42 | 64 | void lc89510_temp_device::set_is_neoCD(device_t &device, bool is_neoCD) |
| 43 | 65 | { |
| 44 | 66 | lc89510_temp_device &dev = downcast<lc89510_temp_device &>(device); |
| r19379 | r19380 | |
| 54 | 76 | void lc89510_temp_device::device_start() |
| 55 | 77 | { |
| 56 | 78 | segacd_dma_callback.bind_relative_to(*owner()); |
| 79 | type1_interrupt_callback.bind_relative_to(*owner()); |
| 80 | type2_interrupt_callback.bind_relative_to(*owner()); |
| 81 | type3_interrupt_callback.bind_relative_to(*owner()); |
| 82 | |
| 57 | 83 | m_cdda = (cdda_device*)subdevice("cdda"); |
| 58 | 84 | } |
| 59 | 85 | |
| r19379 | r19380 | |
| 1019 | 1045 | { |
| 1020 | 1046 | if (nff0002 & 0x0050) |
| 1021 | 1047 | { |
| 1022 | | nIRQAcknowledge &= ~0x10; |
| 1023 | | NeoCDIRQUpdate(0); |
| 1048 | type2_interrupt_callback(); |
| 1024 | 1049 | } |
| 1025 | 1050 | } |
| 1026 | 1051 | |
| r19379 | r19380 | |
| 1192 | 1217 | if (LC8951RegistersW[REG_W_IFCTRL] & 0x20) |
| 1193 | 1218 | { |
| 1194 | 1219 | |
| 1195 | | // todo: handle as interrupt callback |
| 1196 | 1220 | if (is_neoCD) |
| 1197 | 1221 | { |
| 1198 | | nIRQAcknowledge &= ~0x20; |
| 1199 | | NeoCDIRQUpdate(0); |
| 1222 | type1_interrupt_callback(); |
| 1200 | 1223 | } |
| 1201 | 1224 | else |
| 1202 | 1225 | { |
| 1226 | // todo: make callback |
| 1203 | 1227 | CHECK_SCD_LV5_INTERRUPT |
| 1204 | 1228 | } |
| 1205 | 1229 | |
| r19379 | r19380 | |
| 1293 | 1317 | |
| 1294 | 1318 | |
| 1295 | 1319 | |
| 1296 | | void lc89510_temp_device::NeoCDIRQUpdate(UINT8 byteValue) |
| 1297 | | { |
| 1298 | | // do we also need to check the regular interrupts like FBA? |
| 1299 | 1320 | |
| 1300 | | nIRQAcknowledge |= (byteValue & 0x38); |
| 1301 | 1321 | |
| 1302 | | if ((nIRQAcknowledge & 0x08) == 0) { |
| 1303 | | nNeoCDIRQVector = 0x17; |
| 1304 | | nNeoCDIRQVectorAck = 1; |
| 1305 | | machine().device("maincpu")->execute().set_input_line(4, HOLD_LINE); |
| 1306 | | return; |
| 1307 | | } |
| 1308 | | if ((nIRQAcknowledge & 0x10) == 0) { |
| 1309 | | nNeoCDIRQVector = 0x16; |
| 1310 | | nNeoCDIRQVectorAck = 1; |
| 1311 | | machine().device("maincpu")->execute().set_input_line(4, HOLD_LINE); |
| 1312 | | return; |
| 1313 | | } |
| 1314 | | if ((nIRQAcknowledge & 0x20) == 0) { |
| 1315 | | nNeoCDIRQVector = 0x15; |
| 1316 | | nNeoCDIRQVectorAck = 1; |
| 1317 | | machine().device("maincpu")->execute().set_input_line(4, HOLD_LINE); |
| 1318 | | return; |
| 1319 | | } |
| 1320 | | } |
| 1321 | | |
| 1322 | 1322 | void lc89510_temp_device::nff0002_set(UINT16 wordValue) |
| 1323 | 1323 | { |
| 1324 | 1324 | nff0002 = wordValue; |
trunk/src/mame/machine/megacdcd.h
| r19379 | r19380 | |
| 5 | 5 | |
| 6 | 6 | typedef device_delegate<void (int&, UINT8*, UINT16&, UINT16&)> segacd_dma_delegate; |
| 7 | 7 | |
| 8 | typedef device_delegate<void (void)> interrupt_delegate; |
| 8 | 9 | |
| 9 | 10 | |
| 10 | 11 | #define READ_MAIN (0x0200) |
| r19379 | r19380 | |
| 136 | 137 | #define MCFG_SEGACD_HACK_SET_NEOCD \ |
| 137 | 138 | lc89510_temp_device::set_is_neoCD(*device, true); \ |
| 138 | 139 | |
| 140 | #define MCFG_SET_TYPE1_INTERRUPT_CALLBACK( _class, _method) \ |
| 141 | lc89510_temp_device::set_type1_interrupt_callback(*device, interrupt_delegate(&_class::_method, #_class "::" #_method, NULL, (_class *)0)); \ |
| 139 | 142 | |
| 143 | #define MCFG_SET_TYPE2_INTERRUPT_CALLBACK( _class, _method) \ |
| 144 | lc89510_temp_device::set_type2_interrupt_callback(*device, interrupt_delegate(&_class::_method, #_class "::" #_method, NULL, (_class *)0)); \ |
| 145 | |
| 146 | #define MCFG_SET_TYPE3_INTERRUPT_CALLBACK( _class, _method) \ |
| 147 | lc89510_temp_device::set_type3_interrupt_callback(*device, interrupt_delegate(&_class::_method, #_class "::" #_method, NULL, (_class *)0)); \ |
| 148 | |
| 140 | 149 | /* neocd */ |
| 141 | 150 | |
| 142 | 151 | #define CD_FRAMES_MINUTE (60 * 75) |
| r19379 | r19380 | |
| 156 | 165 | |
| 157 | 166 | // HACK for DMA handling |
| 158 | 167 | segacd_dma_delegate segacd_dma_callback; |
| 168 | interrupt_delegate type1_interrupt_callback; |
| 169 | interrupt_delegate type2_interrupt_callback; |
| 170 | interrupt_delegate type3_interrupt_callback; |
| 171 | |
| 159 | 172 | void Fake_CDC_Do_DMA(int &dmacount, UINT8 *CDC_BUFFER, UINT16 &dma_addrc, UINT16 &destination ); |
| 160 | 173 | static void set_CDC_Do_DMA(device_t &device,segacd_dma_delegate new_segacd_dma_callback); |
| 174 | |
| 175 | void dummy_interrupt_callback(void); |
| 176 | static void set_type1_interrupt_callback(device_t &device,interrupt_delegate interrupt_callback); |
| 177 | static void set_type2_interrupt_callback(device_t &device,interrupt_delegate interrupt_callback); |
| 178 | static void set_type3_interrupt_callback(device_t &device,interrupt_delegate interrupt_callback); |
| 161 | 179 | |
| 180 | |
| 162 | 181 | static void set_is_neoCD(device_t &device, bool is_neoCD); |
| 163 | 182 | |
| 164 | 183 | |
| r19379 | r19380 | |
| 268 | 287 | cdda_device* m_cdda; |
| 269 | 288 | |
| 270 | 289 | /* NeoCD */ |
| 271 | | INT32 nIRQAcknowledge; |
| 272 | 290 | UINT16 nff0002; |
| 273 | 291 | UINT16 nff0016; |
| 274 | 292 | |
| r19379 | r19380 | |
| 286 | 304 | |
| 287 | 305 | |
| 288 | 306 | |
| 289 | | int nNeoCDIRQVectorAck; |
| 290 | | int get_nNeoCDIRQVectorAck(void) { return nNeoCDIRQVectorAck; } |
| 291 | | void set_nNeoCDIRQVectorAck(int val) { nNeoCDIRQVectorAck = val; } |
| 292 | | int nNeoCDIRQVector; |
| 293 | | int get_nNeoCDIRQVector(void) { return nNeoCDIRQVector; } |
| 294 | 307 | |
| 295 | | void NeoCDIRQUpdate(UINT8 byteValue); |
| 296 | 308 | void NeoCDCommsControl(UINT8 clock, UINT8 send); |
| 297 | 309 | void LC8951UpdateHeader(); |
| 298 | 310 | char* LC8915InitTransfer(int NeoCDDMACount); |