This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [EntryPoint(0x0021)] | |
| public bool TextOut(HDC hDC, nint x, nint y, uint pszString, nint cbString) | |
| { | |
| // Get the buffer backing pszString | |
| int offset; | |
| var buf = _machine.GlobalHeap.GetBuffer(pszString, false, out offset); | |
| if (buf == null) | |
| return false; | |
| // Read the string from the buffer, using length param |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class CPU | |
| { | |
| // Registers | |
| public ushort ax; | |
| public ushort bx; | |
| // etc... | |
| // Busses | |
| public IMemoryBus MemoryBus { get; set; } | |
| public IPortBus PortBus { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void RunCode() | |
| { | |
| _cpu = new CPU(); | |
| _cpu.MemoryBus = new GlobalHeap(); | |
| while (!_theEndOfTime) | |
| { | |
| _cpu.Step(); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IDebugger | |
| { | |
| bool OnStep(); | |
| bool OnSoftwareInterrupt(byte interruptNumber); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public interface IDebugger | |
| { | |
| bool OnStep(); | |
| bool OnSoftwareInterrupt(byte interruptNumber); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class Disassembler | |
| { | |
| // Machine code read from here | |
| public IMemoryBus MemoryBus { get; set; } | |
| // Using this address | |
| public ushort cs { get; set; } | |
| public ushort ip { get; set; } | |
| // Read disassembled instruction here |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class BreakPoint | |
| { | |
| // Check if this break point wants the debugger to stop | |
| public abstract bool ShouldBreak(DebuggerCore debugger); | |
| [Json("number")] | |
| public int Number { get; set; } | |
| [Json("enabled")] | |
| public bool Enabled { get; set; } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CodeBreakPoint : BreakPoint | |
| { | |
| public CodeBreakPoint(ushort segment, ushort offset) | |
| { | |
| Segment = segment; | |
| Offset = offset; | |
| } | |
| public ushort Segment; | |
| public ushort Offset; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CodeBreakPoint : BreakPoint | |
| { | |
| public CodeBreakPoint(ushort segment, ushort offset) | |
| { | |
| Segment = segment; | |
| Offset = offset; | |
| } | |
| public ushort Segment; | |
| public ushort Offset; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void IDebugger.OnStep() | |
| { | |
| // Test all break points | |
| for (int i=0; i<_allBreakPoints.Count; i++) | |
| { | |
| if (bp.Enabled && bp.ShouldBreak(this)) | |
| { | |
| _break = true; | |
| } | |
| } |