Skip to content

Commit

Permalink
Release 0.7.0.14
Browse files Browse the repository at this point in the history
----------------
Added loading of 16x16 and 8x8 sprites in asset loader.
Fixed a bug with sprites not shown when posY >= height - spriteSize or posX >= width - spriteSize.
Fixed issue with WindowX and large tiles.  Also fixed the off by 1 issue with small tiles.
When resetting the machine, reset the tilestride...
Fixed SBC (substraction) bug when in decimal mode and the subtrahend is larger than the minuend (difference is negative).
  • Loading branch information
Daniel Tremblay committed Nov 4, 2024
1 parent 9d3cda4 commit f2fb052
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 2 deletions.
39 changes: 39 additions & 0 deletions FoenixIDETester/CpuTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -435,5 +435,44 @@ public void CheckContentOfBIsValid()
Assert.AreEqual(0x1235, cpu.A.Value);
}

/**
* Bug reported by @Minstrel Dragon on Discord
*
* I'll perform the test in 6502 mode
*
* sed
* sec
* lda #$55
* sbc #$61
*
* A register should contain #$94
*/
[TestMethod]
public void SubstractNegative()
{
ClearCarry();
// SED - switch to decimal
MemMgr.RAM.WriteByte(cpu.PC, OpcodeList.SED_Implied);
cpu.ExecuteNext();

// SEC - set the carry bit
MemMgr.RAM.WriteByte(cpu.PC, OpcodeList.SEC_Implied);
cpu.ExecuteNext();

// LDA #$55
MemMgr.RAM.WriteByte(cpu.PC, OpcodeList.LDA_Immediate);
MemMgr.RAM.WriteByte(cpu.PC + 1, 0x55);
cpu.ExecuteNext();

// SBC #$61
MemMgr.RAM.WriteByte(cpu.PC, OpcodeList.SBC_Immediate);
MemMgr.RAM.WriteByte(cpu.PC + 1, 0x61);
cpu.ExecuteNext();

// The result should be #$94
Assert.AreEqual(0x94, cpu.A.Value);

}

}
}
27 changes: 27 additions & 0 deletions FoenixIDETester/app.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Collections.Immutable" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.0" newVersion="8.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Reflection.Metadata" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-8.0.0.1" newVersion="8.0.0.1" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
11 changes: 10 additions & 1 deletion Main/Processor/Operations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,7 +1013,16 @@ public void ExecuteSBC(byte instruction, AddressModes addressMode, int signature
int val = GetValue(addressMode, signature, cpu.A.Width);
int nv;
if (cpu.Flags.Decimal)
nv = HexVal(BCDVal(cpu.A.Value) - BCDVal(val + 1) + cpu.Flags.CarryBit);
{
if (val < cpu.A.Value)
{
nv = HexVal(BCDVal(cpu.A.Value) - BCDVal(val + 1) + cpu.Flags.CarryBit);
}
else
{
nv = HexVal(0x64 + BCDVal(cpu.A.Value) - BCDVal(val + 1) + cpu.Flags.CarryBit);
}
}
else
{
nv = cpu.A.Value - val - 1 + cpu.Flags.CarryBit;
Expand Down
2 changes: 1 addition & 1 deletion Main/Processor/Register.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public virtual int Value
{
get
{
return byteLength == 1 ? (int)(this._value & 0xff) : this._value;
return byteLength == 1 ? (int)(this._value & 0xff) : this._value & 0xffff;
}

set
Expand Down
1 change: 1 addition & 0 deletions Release Notes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Added loading of 16x16 and 8x8 sprites in asset loader.
Fixed a bug with sprites not shown when posY >= height - spriteSize or posX >= width - spriteSize.
Fixed issue with WindowX and large tiles. Also fixed the off by 1 issue with small tiles.
When resetting the machine, reset the tilestride...
Fixed SBC (substraction) bug when in decimal mode and the subtrahend is larger than the minuend (difference is negative).

** TODO: Users can now modify the CPU registers when in debug mode. The registers have a white background when editable.
** TODO: Implemented the various cursor modes and rates.
Expand Down

0 comments on commit f2fb052

Please sign in to comment.