Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 39 additions & 17 deletions src/Cryogenic/Overrides/MT32DriverCode.cs
Original file line number Diff line number Diff line change
@@ -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);
}

/// <summary>
/// Never called...?!
/// </summary>
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
}
}