Mercurial > repos > blastem
comparison segacd.c @ 2669:c6bc66b16392
Less broken Sega CD emulation with new 68K core
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 08 Mar 2025 11:45:58 -0800 |
parents | 0fae9d6a77c4 |
children | 07cc0f7109f0 |
comparison
equal
deleted
inserted
replaced
2668:b0b6c6042103 | 2669:c6bc66b16392 |
---|---|
14 #define TIMER_TICK_CLKS 1536/*1792*/ | 14 #define TIMER_TICK_CLKS 1536/*1792*/ |
15 | 15 |
16 //TODO: do some logic analyzer captuers to get actual values | 16 //TODO: do some logic analyzer captuers to get actual values |
17 #define REFRESH_INTERVAL 259 | 17 #define REFRESH_INTERVAL 259 |
18 #define REFRESH_DELAY 2 | 18 #define REFRESH_DELAY 2 |
19 | |
20 #ifdef NEW_CORE | |
21 #define int_num int_priority | |
22 #endif | |
19 | 23 |
20 enum { | 24 enum { |
21 GA_SUB_CPU_CTRL, | 25 GA_SUB_CPU_CTRL, |
22 GA_MEM_MODE, | 26 GA_MEM_MODE, |
23 GA_CDC_CTRL, | 27 GA_CDC_CTRL, |
590 } | 594 } |
591 } | 595 } |
592 if (mask < 5) { | 596 if (mask < 5) { |
593 if (cd->gate_array[GA_INT_MASK] & BIT_MASK_IEN5) { | 597 if (cd->gate_array[GA_INT_MASK] & BIT_MASK_IEN5) { |
594 cdc_cycle = lc8951_next_interrupt(&cd->cdc); | 598 cdc_cycle = lc8951_next_interrupt(&cd->cdc); |
599 #ifdef NEW_CORE | |
600 //should this maybe happen with the old core too? | |
601 if (cdc_cycle == cd->cdc.cycle) { | |
602 cdc_cycle = context->cycles; | |
603 } | |
604 #endif | |
595 //CDC interrupts only generated on falling edge of !INT signal | 605 //CDC interrupts only generated on falling edge of !INT signal |
596 if (cd->cdc_int_ack) { | 606 if (cd->cdc_int_ack) { |
597 if (cdc_cycle > cd->cdc.cycle) { | 607 if (cdc_cycle > cd->cdc.cycle) { |
598 cd->cdc_int_ack = 0; | 608 cd->cdc_int_ack = 0; |
599 } else { | 609 } else { |
641 if (context->int_cycle > context->cycles && context->int_pending == INT_PENDING_SR_CHANGE) { | 651 if (context->int_cycle > context->cycles && context->int_pending == INT_PENDING_SR_CHANGE) { |
642 context->int_pending = INT_PENDING_NONE; | 652 context->int_pending = INT_PENDING_NONE; |
643 } | 653 } |
644 if (context->cycles >= context->sync_cycle) { | 654 if (context->cycles >= context->sync_cycle) { |
645 context->should_return = 1; | 655 context->should_return = 1; |
646 context->target_cycle = context->cycles; | 656 context->target_cycle = context->cycles + 1; |
647 return; | 657 return; |
648 } | 658 } |
649 if (context->status & M68K_STATUS_TRACE || context->trace_pending) { | 659 if (context->status & M68K_STATUS_TRACE || context->trace_pending) { |
650 context->target_cycle = context->cycles; | 660 context->target_cycle = context->cycles + 1; |
651 return; | 661 return; |
652 } | 662 } |
653 context->target_cycle = context->sync_cycle < context->int_cycle ? context->sync_cycle : context->int_cycle; | 663 context->target_cycle = context->sync_cycle < context->int_cycle ? context->sync_cycle : context->int_cycle; |
654 if (context->int_cycle == cdc_cycle && context->int_num == 5) { | 664 if (context->int_cycle == cdc_cycle && context->int_num == 5) { |
655 uint32_t before = cdc_cycle - cd->m68k->opts->gen.clock_divider * 158; //divs worst case | 665 uint32_t before = cdc_cycle - cd->m68k->opts->gen.clock_divider * 158; //divs worst case |
659 } | 669 } |
660 if (before < context->target_cycle) { | 670 if (before < context->target_cycle) { |
661 context->target_cycle = context->sync_cycle = before; | 671 context->target_cycle = context->sync_cycle = before; |
662 } | 672 } |
663 } | 673 } |
674 } | |
675 if (context->target_cycle <= context->cycles) { | |
676 context->target_cycle = context->cycles + 1; | |
664 } | 677 } |
665 } | 678 } |
666 | 679 |
667 static uint16_t sub_gate_read16(uint32_t address, void *vcontext) | 680 static uint16_t sub_gate_read16(uint32_t address, void *vcontext) |
668 { | 681 { |