Skip to content

Commit 9568931

Browse files
committed
Refactor: Rename ScreenMemoryUpdatedEvent to MemoryUpdatedEvent and update the related event logic
1 parent 8634f76 commit 9568931

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

src/Spectron.Emulation/Devices/Memory/IEmulatorMemory.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace OldBit.Spectron.Emulation.Devices.Memory;
44

5-
public delegate void ScreenMemoryUpdatedEvent(Word address);
5+
public delegate void MemoryUpdatedEvent(Word address);
66

77
internal interface IEmulatorMemory : IMemory, IDevice
88
{
@@ -12,5 +12,5 @@ void Reset() { }
1212

1313
void ShadowRom(IRomMemory? shadowRom);
1414

15-
event ScreenMemoryUpdatedEvent? ScreenMemoryUpdated;
15+
event MemoryUpdatedEvent? MemoryUpdated;
1616
}

src/Spectron.Emulation/Devices/Memory/Memory128K.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,7 @@ public void Write(Word address, byte data)
7575

7676
bank[relativeAddress] = data;
7777

78-
if (address < 0x5B00)
79-
{
80-
ScreenMemoryUpdated?.Invoke(address);
81-
}
78+
MemoryUpdated?.Invoke(address);
8279
}
8380

8481
public void ShadowRom(IRomMemory? shadowRom)
@@ -88,7 +85,7 @@ public void ShadowRom(IRomMemory? shadowRom)
8885
_activeRom = shadowRom ?? RomBank1;
8986
}
9087

91-
public event ScreenMemoryUpdatedEvent? ScreenMemoryUpdated;
88+
public event MemoryUpdatedEvent? MemoryUpdated;
9289

9390
public void WritePort(Word address, byte data)
9491
{

src/Spectron.Emulation/Devices/Memory/Memory16K.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,10 @@ public void Write(Word address, byte data)
4343

4444
_memory[address] = data;
4545

46-
if (address < 0x5B00)
47-
{
48-
ScreenMemoryUpdated?.Invoke(address);
49-
}
46+
MemoryUpdated?.Invoke(address);
5047
}
5148

5249
public void ShadowRom(IRomMemory? shadowRom) => _activeRom = shadowRom ?? _normalRom;
5350

54-
public event ScreenMemoryUpdatedEvent? ScreenMemoryUpdated;
51+
public event MemoryUpdatedEvent? MemoryUpdated;
5552
}

src/Spectron.Emulation/Devices/Memory/Memory48K.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,10 @@ public void Write(Word address, byte data)
3838

3939
_memory[address] = data;
4040

41-
if (address < 0x5B00)
42-
{
43-
ScreenMemoryUpdated?.Invoke(address);
44-
}
41+
MemoryUpdated?.Invoke(address);
4542
}
4643

4744
public void ShadowRom(IRomMemory? shadowRom) => _activeRom = shadowRom ?? _normalRom;
4845

49-
public event ScreenMemoryUpdatedEvent? ScreenMemoryUpdated;
46+
public event MemoryUpdatedEvent? MemoryUpdated;
5047
}

src/Spectron.Emulation/Emulator.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,13 @@ private void OnTimerElapsed(EventArgs e)
205205

206206
private void SetupEventHandlers()
207207
{
208-
_memory.ScreenMemoryUpdated += address => ScreenBuffer.UpdateScreen(address);
208+
_memory.MemoryUpdated += address =>
209+
{
210+
if (address < 0x5B00)
211+
{
212+
ScreenBuffer.UpdateScreen(address);
213+
}
214+
};
209215
Cpu.Clock.TicksAdded += (_, previousFrameTicks, _) => ScreenBuffer.UpdateScreen(previousFrameTicks);
210216
Cpu.BeforeInstruction += BeforeInstruction;
211217
UlaPlus.ActiveChanged += (_) => _invalidateScreen = true;

0 commit comments

Comments
 (0)