From 315ed8e040f5388e164313e30b43ae17a35abc57 Mon Sep 17 00:00:00 2001 From: Adrian Conlon <98398945+AdrianConlon@users.noreply.github.com> Date: Sat, 14 Sep 2024 10:06:00 +0100 Subject: [PATCH] Work in progress to correct fixup effect storage --- M6502/M6502.cs | 24 ++++++++++++++++++++++-- M6502/M6502Core.cs | 11 +++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/M6502/M6502.cs b/M6502/M6502.cs index edf93cd..64fd372 100644 --- a/M6502/M6502.cs +++ b/M6502/M6502.cs @@ -223,8 +223,28 @@ namespace EightBit private void StoreFixupEffect(byte data) { - var fixedAddress = (byte)(this.Bus.Address.High + 1); - this.MemoryWrite((byte)(data & fixedAddress)); + ////var fixedAddress = (byte)(this.Bus.Address.High + 1); + //var fixedAddress = this.FixedPage + 1; + //var updated = (byte)(data & fixedAddress); + //if (this.Fixed) + //{ + // this.Bus.Address.High = updated; + //} + + //this.MemoryWrite(updated); + + byte updated; + if (this.Fixed) + { + updated = (byte)(data & this.FixedPage); + this.Bus.Address.High = updated; + } + else + { + updated = (byte)(data & this.UnfixedPage); + this.Bus.Address.High = updated; + } + this.MemoryWrite(updated); } private void SHA() => this.StoreFixupEffect((byte)(this.A & this.X)); diff --git a/M6502/M6502Core.cs b/M6502/M6502Core.cs index a4542c7..5acfc5c 100644 --- a/M6502/M6502Core.cs +++ b/M6502/M6502Core.cs @@ -646,12 +646,22 @@ namespace EightBit private byte fixedPage; + private byte unfixedPage; + public byte FixedPage { get => this.fixedPage; protected set => this.fixedPage = value; } + public byte UnfixedPage + { + get => this.unfixedPage; + protected set => this.unfixedPage = value; + } + + public bool Fixed => this.FixedPage != this.UnfixedPage; + protected void MaybeFixup() { if (this.Bus.Address.High != this.FixedPage) @@ -685,6 +695,7 @@ namespace EightBit protected void NoteFixedAddress(ushort address) { + this.UnfixedPage = this.Bus.Address.High; this.Intermediate.Word = address; this.FixedPage = this.Intermediate.High; this.Bus.Address.Low = this.Intermediate.Low;