Skip to content

Commit

Permalink
Fix NesHawk tracelogs sometimes using 32-bit addrs (squashed PR #3964)
Browse files Browse the repository at this point in the history
specifically, only for the few instructions in this diff, and only when the PC would over- or underflow as a result of the offset
  • Loading branch information
100thCoin committed Jul 8, 2024
1 parent 81e2b5b commit 45002e6
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/BizHawk.Emulation.Cores/CPUs/MOS 6502X/Disassembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static string Disassemble(ushort pc, out int bytesToAdvance, Func<ushort,
case 0x0C: bytesToAdvance = 3; return $"NOP (${peeker_word(++pc, peeker):X4})";
case 0x0D: bytesToAdvance = 3; return $"ORA ${peeker_word(++pc, peeker):X4}";
case 0x0E: bytesToAdvance = 3; return $"ASL ${peeker_word(++pc, peeker):X4}";
case 0x10: bytesToAdvance = 2; return $"BPL ${pc + 2 + (sbyte)peeker(++pc):X4}";
case 0x10: bytesToAdvance = 2; return $"BPL ${(ushort)(pc + 2 + (sbyte)peeker(++pc)):X4}";
case 0x11: bytesToAdvance = 2; return $"ORA (${peeker(++pc):X2}),Y *";
case 0x14: bytesToAdvance = 2; return $"NOP ${peeker(++pc):X2},X";
case 0x15: bytesToAdvance = 2; return $"ORA ${peeker(++pc):X2},X";
Expand All @@ -81,7 +81,7 @@ public static string Disassemble(ushort pc, out int bytesToAdvance, Func<ushort,
case 0x2C: bytesToAdvance = 3; return $"BIT ${peeker_word(++pc, peeker):X4}";
case 0x2D: bytesToAdvance = 3; return $"AND ${peeker_word(++pc, peeker):X4}";
case 0x2E: bytesToAdvance = 3; return $"ROL ${peeker_word(++pc, peeker):X4}";
case 0x30: bytesToAdvance = 2; return $"BMI ${pc + 2 + (sbyte)peeker(++pc):X4}";
case 0x30: bytesToAdvance = 2; return $"BMI ${(ushort)(pc + 2 + (sbyte)peeker(++pc)):X4}";
case 0x31: bytesToAdvance = 2; return $"AND (${peeker(++pc):X2}),Y *";
case 0x34: bytesToAdvance = 2; return $"NOP ${peeker(++pc):X2},X";
case 0x35: bytesToAdvance = 2; return $"AND ${peeker(++pc):X2},X";
Expand All @@ -103,7 +103,7 @@ public static string Disassemble(ushort pc, out int bytesToAdvance, Func<ushort,
case 0x4C: bytesToAdvance = 3; return $"JMP ${peeker_word(++pc, peeker):X4}";
case 0x4D: bytesToAdvance = 3; return $"EOR ${peeker_word(++pc, peeker):X4}";
case 0x4E: bytesToAdvance = 3; return $"LSR ${peeker_word(++pc, peeker):X4}";
case 0x50: bytesToAdvance = 2; return $"BVC ${pc + 2 + (sbyte)peeker(++pc):X4}";
case 0x50: bytesToAdvance = 2; return $"BVC ${(ushort)(pc + 2 + (sbyte)peeker(++pc)):X4}";
case 0x51: bytesToAdvance = 2; return $"EOR (${peeker(++pc):X2}),Y *";
case 0x54: bytesToAdvance = 2; return $"NOP ${peeker(++pc):X2},X";
case 0x55: bytesToAdvance = 2; return $"EOR ${peeker(++pc):X2},X";
Expand All @@ -125,7 +125,7 @@ public static string Disassemble(ushort pc, out int bytesToAdvance, Func<ushort,
case 0x6C: bytesToAdvance = 3; return $"JMP (${peeker_word(++pc, peeker):X4})";
case 0x6D: bytesToAdvance = 3; return $"ADC ${peeker_word(++pc, peeker):X4}";
case 0x6E: bytesToAdvance = 3; return $"ROR ${peeker_word(++pc, peeker):X4}";
case 0x70: bytesToAdvance = 2; return $"BVS ${pc + 2 + (sbyte)peeker(++pc):X4}";
case 0x70: bytesToAdvance = 2; return $"BVS ${(ushort)(pc + 2 + (sbyte)peeker(++pc)):X4}";
case 0x71: bytesToAdvance = 2; return $"ADC (${peeker(++pc):X2}),Y *";
case 0x74: bytesToAdvance = 2; return $"NOP ${peeker(++pc):X2},X";
case 0x75: bytesToAdvance = 2; return $"ADC ${peeker(++pc):X2},X";
Expand All @@ -148,7 +148,7 @@ public static string Disassemble(ushort pc, out int bytesToAdvance, Func<ushort,
case 0x8C: bytesToAdvance = 3; return $"STY ${peeker_word(++pc, peeker):X4}";
case 0x8D: bytesToAdvance = 3; return $"STA ${peeker_word(++pc, peeker):X4}";
case 0x8E: bytesToAdvance = 3; return $"STX ${peeker_word(++pc, peeker):X4}";
case 0x90: bytesToAdvance = 2; return $"BCC ${pc + 2 + (sbyte)peeker(++pc):X4}";
case 0x90: bytesToAdvance = 2; return $"BCC ${(ushort)(pc + 2 + (sbyte)peeker(++pc)):X4}";
case 0x91: bytesToAdvance = 2; return $"STA (${peeker(++pc):X2}),Y";
case 0x94: bytesToAdvance = 2; return $"STY ${peeker(++pc):X2},X";
case 0x95: bytesToAdvance = 2; return $"STA ${peeker(++pc):X2},X";
Expand All @@ -169,7 +169,7 @@ public static string Disassemble(ushort pc, out int bytesToAdvance, Func<ushort,
case 0xAC: bytesToAdvance = 3; return $"LDY ${peeker_word(++pc, peeker):X4}";
case 0xAD: bytesToAdvance = 3; return $"LDA ${peeker_word(++pc, peeker):X4}";
case 0xAE: bytesToAdvance = 3; return $"LDX ${peeker_word(++pc, peeker):X4}";
case 0xB0: bytesToAdvance = 2; return $"BCS ${pc + 2 + (sbyte)peeker(++pc):X4}";
case 0xB0: bytesToAdvance = 2; return $"BCS ${(ushort)(pc + 2 + (sbyte)peeker(++pc)):X4}";
case 0xB1: bytesToAdvance = 2; return $"LDA (${peeker(++pc):X2}),Y *";
case 0xB3: bytesToAdvance = 2; return $"LAX (${peeker(++pc):X2}),Y *";
case 0xB4: bytesToAdvance = 2; return $"LDY ${peeker(++pc):X2},X";
Expand All @@ -194,7 +194,7 @@ public static string Disassemble(ushort pc, out int bytesToAdvance, Func<ushort,
case 0xCC: bytesToAdvance = 3; return $"CPY ${peeker_word(++pc, peeker):X4}";
case 0xCD: bytesToAdvance = 3; return $"CMP ${peeker_word(++pc, peeker):X4}";
case 0xCE: bytesToAdvance = 3; return $"DEC ${peeker_word(++pc, peeker):X4}";
case 0xD0: bytesToAdvance = 2; return $"BNE ${pc + 2 + (sbyte)peeker(++pc):X4}";
case 0xD0: bytesToAdvance = 2; return $"BNE ${(ushort)(pc + 2 + (sbyte)peeker(++pc)):X4}";
case 0xD1: bytesToAdvance = 2; return $"CMP (${peeker(++pc):X2}),Y *";
case 0xD4: bytesToAdvance = 2; return $"NOP ${peeker(++pc):X2},X";
case 0xD5: bytesToAdvance = 2; return $"CMP ${peeker(++pc):X2},X";
Expand All @@ -217,7 +217,7 @@ public static string Disassemble(ushort pc, out int bytesToAdvance, Func<ushort,
case 0xEC: bytesToAdvance = 3; return $"CPX ${peeker_word(++pc, peeker):X4}";
case 0xED: bytesToAdvance = 3; return $"SBC ${peeker_word(++pc, peeker):X4}";
case 0xEE: bytesToAdvance = 3; return $"INC ${peeker_word(++pc, peeker):X4}";
case 0xF0: bytesToAdvance = 2; return $"BEQ ${pc + 2 + (sbyte)peeker(++pc):X4}";
case 0xF0: bytesToAdvance = 2; return $"BEQ ${(ushort)(pc + 2 + (sbyte)peeker(++pc)):X4}";
case 0xF1: bytesToAdvance = 2; return $"SBC (${peeker(++pc):X2}),Y *";
case 0xF4: bytesToAdvance = 2; return $"NOP ${peeker(++pc):X2},X";
case 0xF5: bytesToAdvance = 2; return $"SBC ${peeker(++pc):X2},X";
Expand Down

1 comment on commit 45002e6

@YoshiRulz
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh yeah resolves #3963

Please sign in to comment.