MCPcopy Create free account
hub / github.com/TASEmulators/fceux / DebugCycle

Function DebugCycle

src/debug.cpp:931–993  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

929//bbit edited: this is the end of the inserted code
930
931void DebugCycle()
932{
933 uint8 opcode[3] = {0};
934 uint16 A = 0, tmp;
935 int size;
936
937 if (scanline == 240)
938 {
939 vblankScanLines = (PAL?int((double)timestamp / ((double)341 / (double)3.2)):timestamp / 114); //114 approximates the number of timestamps per scanline during vblank. Approx 2508. NTSC: (341 / 3.0) PAL: (341 / 3.2). Uses (3.? * cpu_cycles) / 341.0, and assumes 1 cpu cycle.
940 if (vblankScanLines) vblankPixel = 341 / vblankScanLines; //341 pixels per scanline
941 //FCEUI_printf("vbPixel = %d",vblankPixel); //Debug
942 //FCEUI_printf("ts: %d line: %d\n", timestamp, vblankScanLines); //Debug
943 }
944 else
945 vblankScanLines = 0;
946
947 if (GameInfo->type==GIT_NSF)
948 {
949 if ((_PC >= 0x3801) && (_PC <= 0x3824)) return;
950 }
951
952 opcode[0] = GetMem(_PC);
953 size = opsize[opcode[0]];
954 switch (size)
955 {
956 default:
957 case 1: break;
958 case 2:
959 opcode[1] = GetMem(_PC + 1);
960 break;
961 case 0: // illegal instructions may have operands
962 case 3:
963 opcode[1] = GetMem(_PC + 1);
964 opcode[2] = GetMem(_PC + 2);
965 break;
966 }
967
968 switch (optype[opcode[0]])
969 {
970 case 0: break;
971 case 1:
972 tmp = (opcode[1] + _X) & 0xFF;
973 A = GetMem(tmp);
974 tmp = (opcode[1] + _X + 1) & 0xFF;
975 A |= (GetMem(tmp) << 8);
976 break;
977 case 2: A = opcode[1]; break;
978 case 3: A = opcode[1] | (opcode[2] << 8); break;
979 case 4: A = (GetMem(opcode[1]) | (GetMem((opcode[1] + 1) & 0xFF) << 8)) + _Y; break;
980 case 5: A = opcode[1] + _X; break;
981 case 6: A = (opcode[1] | (opcode[2] << 8)) + _Y; break;
982 case 7: A = (opcode[1] | (opcode[2] << 8)) + _X; break;
983 case 8: A = opcode[1] + _Y; break;
984 }
985
986 if (numWPs || dbgstate.step || dbgstate.runline || dbgstate.stepout || watchpoint[64].flags || dbgstate.badopbreak || break_on_cycles || break_on_instructions || break_asap)
987 breakpoint(opcode, A, size);
988

Callers 1

X6502_RunFunction · 0.85

Calls 4

GetMemFunction · 0.85
breakpointFunction · 0.85
LogCDDataFunction · 0.85
FCEUD_TraceInstructionFunction · 0.50

Tested by

no test coverage detected