Skip to content

Commit

Permalink
Cleanup from #51
Browse files Browse the repository at this point in the history
* Found a spot we didn't pass `UsedMethods`
* `LastLDA` should be set to false in `SeekBack()`
* Duplicate `SetLabel()` call for `oam_spr`
  • Loading branch information
jonathanpeppers committed Sep 18, 2024
1 parent 1d3b3f7 commit 130c8bc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/dotnes.tasks/Utilities/IL2NESWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ void WriteLdloc(Local local, ushort sizeOfMain)

void SeekBack(int length)
{
LastLDA = false;
_logger.WriteLine($"Seek back {length} bytes");
if (_writer.BaseStream.Length < length)
{
Expand Down
3 changes: 1 addition & 2 deletions src/dotnes.tasks/Utilities/NESWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public NESWriter(Stream stream, bool leaveOpen = false, ILogger? logger = null)
protected readonly BinaryWriter _writer;
protected readonly ILogger _logger;

public bool LastLDA { get; private set; }
public bool LastLDA { get; protected set; }

public Stream BaseStream => _writer.BaseStream;

Expand Down Expand Up @@ -1095,7 +1095,6 @@ public void WriteBuiltIn(string name, ushort sizeOfMain)
Write(NESInstruction.RTS_impl);
break;
case nameof(NESLib.oam_spr):
SetLabel(nameof(NESLib.oam_spr), (ushort)(_writer.BaseStream.Position + BaseAddress));
/*
* 85B7  AA   TAX ; _oam_spr
* 85B8  A000 LDY #$00
Expand Down
5 changes: 4 additions & 1 deletion src/dotnes.tasks/Utilities/Transpiler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,10 @@ public Transpiler(Stream stream, IList<AssemblyReader> assemblyFiles, ILogger? l
private Dictionary<string, ushort> CalculateAddressLabels(ushort sizeOfMain)
{
using var ms = new MemoryStream();
using var writer = new IL2NESWriter(ms, logger: _logger);
using var writer = new IL2NESWriter(ms, logger: _logger)
{
UsedMethods = UsedMethods,
};

// Write built-in functions
writer.WriteBuiltIns(sizeOfMain);
Expand Down

0 comments on commit 130c8bc

Please sign in to comment.