diff --git a/src/Cryogenic/Overrides/MT32DriverCode.cs b/src/Cryogenic/Overrides/MT32DriverCode.cs index 7582f78..001f27b 100644 --- a/src/Cryogenic/Overrides/MT32DriverCode.cs +++ b/src/Cryogenic/Overrides/MT32DriverCode.cs @@ -1,33 +1,55 @@ namespace Cryogenic.Overrides; + +using Spice86.Shared.Emulator.Memory; + using System; public partial class Overrides { public void DefineMT32DriverCodeOverrides() { - DefineFunction(0xF000, 0x100, DNMID_entry_00, true, nameof(DNMID_entry_00)); - DefineFunction(0xF000, 0x100 + 0x17b, DNMID_entry_01, true, nameof(DNMID_entry_01)); - DefineFunction(0xF000, 0x1CB, DNMID_internal_function_00, true, nameof(DNMID_internal_function_00)); + DefineFunction(0xF000, 0x100, DNMID_Driver_JumpTable, true, nameof(DNMID_Driver_JumpTable)); + DefineFunction(0xF000, 0x01CB, DNMID_internal_function_0xF000_0x1CB, true, nameof(DNMID_internal_function_0xF000_0x1CB)); } - private Action DNMID_entry_01(int arg) { - var result = Alu16.Xor(AX, AX); - if (result == 0) { - return NearJump(0x04); + private Action DNMID_Driver_JumpTable(int arg) { + if(arg == 0) { + NearCall(0xF000, 0x100, DNMID_internal_function_0xF000_0x1CB); } - Cpu.Out16(0x330, AX); - return NearJump(0x0); + //jmp near ptr 01CBh (E9C800 (3)) + //jmp near ptr 0250h (E94A01 (3)) + //jmp near ptr 01E1h (E9D800 (3)) + //jmp near ptr 023Bh (E92F01 (3)) + //jmp near ptr 01EEh (E9DF00(3)) + //jmp near ptr 022Bh (E91601 (3)) + //jmp near ptr 022Bh (E91601 (3)) + return NearRet(); } - private Action DNMID_entry_00(int arg) { - return DNMID_entry_01(0); - //return NearJump(0x17b); - } - /// - /// Never called...?! - /// + private Action DNMID_internal_function_0xF000_0x1CB(int arg) { + //push DS + Stack.Push16(DS); + //mov AX,CS + AX = CS; + //mov DS,AX + DS = AX; + //mov AL,DS:[0x0139] + AL = UInt8[new SegmentedAddress(DS, 0x0139)]; + //or AL,AL + State.ZeroFlag = (AL == 0); + //jns SHORT 0x033C + if (!State.SignFlag) { + //dec BYTE PTR DS:[0x011E] + UInt16[DS, 0x011E] = Alu16.Dec(UInt16[DS, 0x011E]); + } + //call DS:0x0349 + //TODO + NearCall(0xF000, 10, DS_0x0349); + return NearRet(); + } - private Action DNMID_internal_function_00(int arg) { + private Action DS_0x0349(int arg) { return NearRet(); + // Implementation of DS:0x0349 } }