Skip to content

Commit

Permalink
docs: README.md code snippets (#1004)
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilien Noal <noal.maximilien@gmail.com>
  • Loading branch information
maximilien-noal authored Dec 29, 2024
1 parent 699cd45 commit ae581f1
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ public class MyProgramOverrideSupplier : IOverrideSupplier {
public class MyOverrides : CSharpOverrideHelper {
private MyOverridesGlobalsOnDs globalsOnDs;

public MyOverrides(IDictionary<SegmentedAddress, FunctionInformation> functionInformations, int segment, Machine machine) {
public MyOverrides(IDictionary<SegmentedAddress, FunctionInformation> functionInformations, ushort entrySegment, Machine machine, ILoggerService loggerService, Configuration configuration) {
// "myOverides" is a prefix that will be appended to all the function names defined in this class
base(functionInformations, "myOverides", machine);
base(functionInformations, machine, loggerService, configuration);
globalsOnDs = new MyOverridesGlobalsOnDs(machine);
// incUnknown47A8_0x1ED_0xA1E8_0xC0B8 will get executed instead of the assembly code when a call to 1ED:A1E8 is performed.
// Also when dumping functions, the name myOverides.incUnknown47A8 or instead of unknown
Expand Down Expand Up @@ -236,18 +236,26 @@ public class MyOverrides : CSharpOverrideHelper {
}

// Memory accesses can be encapsulated into classes like this to give names to addresses and make the code shorter.
public class MyOverridesGlobalsOnDs : MemoryBasedDataStructureWithDsBaseAddress {
public DialoguesGlobalsOnDs(Machine machine) {
base(machine);
}

public void SetDialogueCount47A8(int value) {
this.SetUint8(0x47A8, value);
}

public int GetDialogueCount47A8() {
return this.GetUint8(0x47A8);
}
public class GlobalsOnDs : MemoryBasedDataStructureWithDsBaseAddress {
public GlobalsOnDs(IByteReaderWriter memory, SegmentRegisters segmentRegisters) : base(memory, segmentRegisters) {
}

// Getters and Setters for address 0x1DD:0x2/0x1DD2.
// Was accessed via the following registers: DS
public int Get01DD_0002_Word16() {
return UInt16[0x2];
}

// Operation not registered by running code
public void Set01DD_0002_Word16(byte value) {
UInt16[0x2] = value;
}

// Getters and Setters for address 0x1138:0x0/0x11380.
// Operation not registered by running code
public int Get1138_0000_Word16() {
return UInt16[0x0];
}
}
```

Expand Down Expand Up @@ -336,7 +344,7 @@ Compatibility list available [here](COMPATIBILITY.md).

### How to build on your machine

- Install the .NET 8 SDK (once)
- Install the [.NET 9 SDK](https://dotnet.microsoft.com/en-us/download/dotnet/9.0) (once)
- clone the repo
- run this where Spice86.sln is located:

Expand Down

0 comments on commit ae581f1

Please sign in to comment.