-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathexeload.asm
More file actions
158 lines (127 loc) · 2.83 KB
/
Copy pathexeload.asm
File metadata and controls
158 lines (127 loc) · 2.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
.model small
.stack 200h
ptr16 struc ; sizeof=0x4
ofs dw ?
segm dw ?
ptr16 ends
dseg segment 'DATA'
game_exe db 'ega_vga.exe',0
adlib_com db 's_adlib.com',0
commandline db ' ',0dh
params:
dw 0 ; copy caller environment if 0
dw offset commandline
dw seg commandline
dw 0ffffh,0ffffh ; fcb1
dw 0ffffh,0ffffh ; fcb2
error_msg_tsr db 'exec tsr failed',0dh,0ah,'$'
error_msg_game db 'exec game failed',0dh,0ah,'$'
dseg ends
cseg segment 'CODE'
assume cs:cseg
feature_flags dw 0C001h
dos_version db 5
gfx_mode dw 4 ; 4=VGA
interrupt_97h:
mov ax,cs:feature_flags
iret
interrupt_24h:
mov al, cs:dos_version
iret
start:
mov ax,dseg
mov ds,ax
mov es,ax
; set interrupt 97h
push ds
mov ah,25h
mov al,97h ; ivt[0x97]
push cs
pop ds
mov dx,offset interrupt_97h
int 21h
pop ds
; or patch the exe itself
; at fileoffset 57DA in ae_vga.exe replace bytes {CD 97 8B D8 25 00 C0} with {bb 01 c0 b8 00 c0 90}
; gets you only EGA colors due to missing Interrupt[9Fh].offset overwrite with gfx_mode
; set interrupt 24h
push ds
mov ah,25h
mov al,24h ; ivt[0x24]
push cs
pop ds
mov dx,offset interrupt_24h
int 21h
pop ds
; overwrite Interrupt 9Fh offset with gfx_mode value
push ds
mov bx,cs:gfx_mode ; gfx_mode = VGA - or else the colors look like the EGA version
xor ax, ax
mov ds, ax
assume ds:nothing
mov ds:(9Fh*sizeof ptr16), bx ; ivt[0x9F]
pop ds
; ---- start adlib sound TSR
mov dx,offset adlib_com
mov bx,offset params
mov ax,4B00h
push ds ; save ds for return
push es ; save es for return
; seems to be needed for old dos versions
mov cs:[stk_seg],ss ; save stack seg and
mov cs:[stk_ptr],sp ; stack pointer in cseg
; starts sound TSR
int 21h
jnc start_game
; ax = 8 = Insufficient memory
mov dx,offset error_msg_tsr
mov ah,09h
int 21h
jmp exit
start_game:
mov dx,offset game_exe
mov bx,offset params
mov ax,4B00h
push ds ; save ds for return
push es ; save es for return
; seems to be needed for old dos versions
mov cs:[stk_seg],ss ; save stack seg and
mov cs:[stk_ptr],sp ; stack pointer in cseg
; starts game
int 21h
jnc execute_ok
; ax = 8 = Insufficient memory
mov dx,offset error_msg_game
mov ah,09h
int 21h
jmp exit
execute_ok:
cli
mov ss,cs:[stk_seg]
mov sp,cs:[stk_ptr]
pop es
pop ds
sti
; shutdown adlib tsr
xor ax,ax
mov es,ax
lds si, es:(0F0h*sizeof ptr16)
mov ax, ds
or ax, si
jz short exit
; starts at offset 2 of interrupt F0 with 'IFGM ADLIB' if adlib tsr loaded
mov cx, [si+2]
mov dx, [si+4]
cmp cx, 'FI'
jnz short exit
cmp dx, 'MG'
jnz short exit
mov ah, 0Eh
int 0F0h ; Int 0xF0 gets overwritten by ADLIB.COM TSR
exit:
mov ax,4C00h
int 21h
stk_ptr dw 0
stk_seg dw 0
cseg ends
end start