Skip to content

Commit

Permalink
This is probably closer
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathanpeppers committed Sep 25, 2024
1 parent 4ee093f commit d0ea565
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
5 changes: 2 additions & 3 deletions src/dotnes.tasks/Utilities/IL2NESWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,9 @@ public void Write(ILInstruction instruction, int operand, ushort sizeOfMain)
Write(NESInstruction.BNE_rel, NumberOfInstructionsForBranch(instruction.Offset + operand + 2, sizeOfMain));
break;
case ILOpCode.Brtrue_s:
//TODO: implement
break;
case ILOpCode.Brfalse_s:
//TODO: implement
Write(NESInstruction.CMP, 0);
Write(instruction.OpCode == ILOpCode.Brtrue_s ? NESInstruction.BNE_rel : NESInstruction.BEQ_rel, NumberOfInstructionsForBranch(instruction.Offset + operand + 2, sizeOfMain));
break;
default:
throw new NotImplementedException($"OpCode {instruction.OpCode} with Int32 operand is not implemented!");
Expand Down
28 changes: 15 additions & 13 deletions src/dotnes.tests/RoslynTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,34 +446,36 @@ public void PadInput()
""",
expectedAssembly:
"""
A9F6
A9FA
A285
201182 ; JSR _pal_all
208982 ; JSR _ppu_on_all
201182 ; JSR pal_all
208982 ; JSR ppu_on_all
A928
8D2403
A922
A286
A900
202286
202686 ; JSR pad_poll
C900
F015
AD2403
20A785 ; JSR popa
A929
20AB85 ; JSR popa
A92A
8D2403
A922
A286
AD2403
20A785 ; JSR popa
20AB85 ; JSR popa
AD2403
20A785 ; JSR popa
20AB85 ; JSR popa
A910
20A785 ; JSR popa
20AB85 ; JSR popa
A903
20A785 ; JSR popa
20AB85 ; JSR popa
A900
20F685 ; JSR _oam_spr
20DB82 ; JSR _ppu_wait_frame
4C4585 ; JMP $8512
20FA85 ; JSR oam_spr
20DB82 ; JSR ppu_wait_frame
4C4985 ; JMP $8512
""");
}
}

0 comments on commit d0ea565

Please sign in to comment.