comparison segacd.c @ 2073:c69e42444f96

Fix some cycle adjustment stuff and an off-by one on hte TOCT response
author Michael Pavone <pavone@retrodev.com>
date Mon, 31 Jan 2022 00:01:15 -0800
parents 8e51c0c3f2e3
children bafb757e1cd2
comparison
equal deleted inserted replaced
2072:cc13c100b027 2073:c69e42444f96
595 calculate_target_cycle(m68k); 595 calculate_target_cycle(m68k);
596 break; 596 break;
597 case GA_CDD_CTRL: { 597 case GA_CDD_CTRL: {
598 cdd_run(cd, m68k->current_cycle); 598 cdd_run(cd, m68k->current_cycle);
599 uint16_t changed = cd->gate_array[reg] ^ value; 599 uint16_t changed = cd->gate_array[reg] ^ value;
600 cd->gate_array[reg] &= ~BIT_HOCK;
601 cd->gate_array[reg] |= value & BIT_HOCK;
602 if (changed & BIT_HOCK) { 600 if (changed & BIT_HOCK) {
601 cd->gate_array[reg] &= ~BIT_HOCK;
602 cd->gate_array[reg] |= value & BIT_HOCK;
603 if (value & BIT_HOCK) { 603 if (value & BIT_HOCK) {
604 cdd_hock_enabled(&cd->cdd); 604 cdd_hock_enabled(&cd->cdd);
605 } else { 605 } else {
606 cdd_hock_disabled(&cd->cdd); 606 cdd_hock_disabled(&cd->cdd);
607 } 607 }
926 case GA_CDC_DMA_ADDR: 926 case GA_CDC_DMA_ADDR:
927 //TODO: open bus maybe? 927 //TODO: open bus maybe?
928 return 0xFFFF; 928 return 0xFFFF;
929 default: 929 default:
930 if (offset < GA_TIMER) { 930 if (offset < GA_TIMER) {
931 if (offset == GA_CDC_CTRL) {
932 printf("CDC read(main): %X - %X @ %u (%u)\n", address, cd->gate_array[offset], m68k->current_cycle, scd_cycle);
933 } else if (offset >= GA_COMM_FLAG && offset <= GA_COMM_STATUS7) {
934 printf("COMM read(main): %X - %X @ %u (%u)\n", address, cd->gate_array[offset], m68k->current_cycle, scd_cycle);
935 }
936 return cd->gate_array[offset]; 931 return cd->gate_array[offset];
937 } 932 }
938 //TODO: open bus maybe? 933 //TODO: open bus maybe?
939 return 0xFFFF; 934 return 0xFFFF;
940 } 935 }
1047 break; 1042 break;
1048 case GA_COMM_FLAG: 1043 case GA_COMM_FLAG:
1049 //Main CPU can only write the upper byte; 1044 //Main CPU can only write the upper byte;
1050 cd->gate_array[reg] &= 0xFF; 1045 cd->gate_array[reg] &= 0xFF;
1051 cd->gate_array[reg] |= value & 0xFF00; 1046 cd->gate_array[reg] |= value & 0xFF00;
1052 printf("COMM write(main): %X - %X @ %u (%u)\n", address, value, m68k->current_cycle, scd_cycle);
1053 break; 1047 break;
1054 case GA_COMM_CMD0: 1048 case GA_COMM_CMD0:
1055 case GA_COMM_CMD1: 1049 case GA_COMM_CMD1:
1056 case GA_COMM_CMD2: 1050 case GA_COMM_CMD2:
1057 case GA_COMM_CMD3: 1051 case GA_COMM_CMD3:
1058 case GA_COMM_CMD4: 1052 case GA_COMM_CMD4:
1059 case GA_COMM_CMD5: 1053 case GA_COMM_CMD5:
1060 case GA_COMM_CMD6: 1054 case GA_COMM_CMD6:
1061 case GA_COMM_CMD7: 1055 case GA_COMM_CMD7:
1062 //no effects for these other than saving the value 1056 //no effects for these other than saving the value
1063 printf("COMM write(main): %X - %X @ %u (%u)\n", address, value, m68k->current_cycle, scd_cycle);
1064 cd->gate_array[reg] = value; 1057 cd->gate_array[reg] = value;
1065 break; 1058 break;
1066 default: 1059 default:
1067 printf("Unhandled gate array write %X:%X\n", address, value); 1060 printf("Unhandled gate array write %X:%X\n", address, value);
1068 } 1061 }