Rev 17 | Rev 22 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9 | daniel-mar | 1 | |
2 | ; Aysalia DOS Launcher |
||
3 | ; Launches aydos1.gam and aydos2.gam |
||
17 | daniel-mar | 4 | ; Revision 2018-12-06 |
9 | daniel-mar | 5 | ; (C) 2018 Daniel Marschall, ViaThinkSoft |
6 | |||
7 | .model small |
||
8 | .stack 10h |
||
11 | daniel-mar | 9 | |
10 | ; ------------------------------------------------------- |
||
11 | |||
9 | daniel-mar | 12 | .data |
13 | |||
14 | exename1 db "AYDOS1.GAM",0 |
||
15 | exename2 db "AYDOS2.GAM",0 |
||
16 | cmdargs db 0,'',0dh |
||
17 | |||
18 | dummy_fcb db 36 dup(0) |
||
19 | |||
20 | paramblk dw 0 ; use environment of parent |
||
21 | dw cmdargs ; command line arguments |
||
22 | dw 0 ; cmdargs_seg |
||
23 | dw dummy_fcb ; fcb1 |
||
24 | dw 0 ; fcb1_seg |
||
25 | dw dummy_fcb ; fcb2 |
||
26 | dw 0 ; fcb2_seg |
||
27 | |||
28 | menu1 db '', 13, 10, '$' |
||
29 | menu2 db '', 13, 10, '$' |
||
30 | menu3 db '', 13, 10, '$' |
||
31 | menu4 db '', 13, 10, '$' |
||
32 | menu5 db ' Aysalia DOS',13,10,'$' |
||
33 | menu6 db '', 13, 10, '$' |
||
34 | menu7 db '', 13, 10, '$' |
||
35 | menu8 db ' Welches Spiel soll gestartet werden?',13,10,'$' |
||
36 | menu9 db '', 13, 10, '$' |
||
37 | menu10 db ' Dr',81h,'cke eine der folgenden Tasten:',13,10,'$' |
||
38 | menu11 db '', 13, 10, '$' |
||
39 | menu12 db ' 1 Aysalia DOS I',13,10,'$' |
||
40 | menu13 db ' 2 Aysalia DOS II',13,10,'$' |
||
41 | menu14 db '', 13, 10, '$' |
||
42 | menu15 db ' 9 Beenden',13,10,'$' |
||
43 | menu16 db '', 13, 10, '$' |
||
44 | menu17 db '', 13, 10, '$' |
||
45 | menu18 db '', 13, 10, '$' |
||
17 | daniel-mar | 46 | |
47 | error1 db '',13,10,'$' |
||
48 | error2 db 'Fehler: Spiel kann nicht gestartet werden. Fehlt eine Datei?',13,10,'$' |
||
49 | error3 db '',13,10,'$' |
||
9 | daniel-mar | 50 | |
51 | gameover1 db '',13,10,'$' |
||
52 | gameover2 db 'Spiel zu Ende!',13,10,'$' |
||
53 | gameover3 db '',13,10,'$' |
||
54 | |||
11 | daniel-mar | 55 | ; ------------------------------------------------------- |
56 | |||
9 | daniel-mar | 57 | .code |
58 | |||
59 | clear_vga PROC |
||
60 | mov ax, 0a000h |
||
61 | mov es, ax |
||
62 | xor di, di |
||
63 | mov ax, 0 |
||
64 | mov cx, 64000 |
||
65 | rep stosb |
||
66 | ret |
||
67 | clear_vga ENDP |
||
68 | |||
11 | daniel-mar | 69 | set_screen12 PROC |
70 | mov ah, 0 ; set screen mode |
||
71 | mov al, 12h ; graphic mode, 640x480 pixel, 16 colors (VGA) |
||
72 | int 10h |
||
73 | ret |
||
74 | set_screen12 ENDP |
||
75 | |||
9 | daniel-mar | 76 | setup_paramblk PROC |
77 | mov ax, cs |
||
78 | mov [paramblk + 4], ax ; cmdargs_seg |
||
79 | mov [paramblk + 8], ax ; fcb1_seg |
||
80 | mov [paramblk + 12], ax ; fcb2_seg |
||
81 | ret |
||
82 | setup_paramblk ENDP |
||
83 | |||
11 | daniel-mar | 84 | set_numlock_on PROC |
85 | push ds |
||
86 | mov ax, 40h |
||
87 | mov ds, ax ; go to BIOS Data Area ( http://stanislavs.org/helppc/bios_data_area.html ) |
||
88 | mov bx, 17h ; Load Keyboard flag byte 0 |
||
89 | mov al, [bx] ; read |
||
90 | or al, 20h ; set bit 5 (numlock) to 1 |
||
91 | mov [bx], al ; write |
||
92 | pop ds |
||
93 | ret |
||
94 | set_numlock_on ENDP |
||
9 | daniel-mar | 95 | |
11 | daniel-mar | 96 | flush_keyb_buf PROC |
97 | mov ah, 0Ch ; Flush input buffer and input |
||
98 | mov al, 0 |
||
9 | daniel-mar | 99 | int 21h |
11 | daniel-mar | 100 | ret |
101 | flush_keyb_buf ENDP |
||
9 | daniel-mar | 102 | |
11 | daniel-mar | 103 | exit_to_dos PROC |
104 | mov ah, 4ch |
||
105 | mov al, 00h |
||
106 | int 21h |
||
107 | ret |
||
108 | exit_to_dos ENDP |
||
9 | daniel-mar | 109 | |
11 | daniel-mar | 110 | sleep_5 PROC |
21 | daniel-mar | 111 | mov ah, 00h |
17 | daniel-mar | 112 | int 1Ah |
21 | daniel-mar | 113 | cmp dx, 7FFFh |
114 | jg upperhalf |
||
115 | lowerhalf: |
||
116 | mov bx, dx |
||
117 | add bx, 91 ; 18.2 = 1 sec (therefore 91 = 5 sec) |
||
118 | lowerhalf_again: |
||
119 | int 1Ah |
||
17 | daniel-mar | 120 | cmp dx, bx |
21 | daniel-mar | 121 | jl lowerhalf_again |
11 | daniel-mar | 122 | ret |
21 | daniel-mar | 123 | upperhalf: |
124 | mov bx, dx |
||
125 | sub bx, 7FFFh |
||
126 | add bx, 91 ; 18.2 = 1 sec (therefore 91 = 5 sec) |
||
127 | upperhalf_again: |
||
128 | int 1Ah |
||
129 | sub dx, 7FFFh |
||
130 | cmp dx, bx |
||
131 | jl upperhalf_again |
||
132 | ret |
||
11 | daniel-mar | 133 | sleep_5 ENDP |
9 | daniel-mar | 134 | |
11 | daniel-mar | 135 | print_menu_screen PROC |
21 | daniel-mar | 136 | mov ah, 0Bh |
137 | mov bh, 00h |
||
138 | mov bl, 8 ; green |
||
139 | int 10h |
||
140 | |||
9 | daniel-mar | 141 | mov ah, 9 |
142 | lea dx, menu1 |
||
143 | int 21h |
||
144 | lea dx, menu2 |
||
145 | int 21h |
||
146 | lea dx, menu3 |
||
147 | int 21h |
||
148 | lea dx, menu4 |
||
149 | int 21h |
||
150 | lea dx, menu5 |
||
151 | int 21h |
||
152 | lea dx, menu6 |
||
153 | int 21h |
||
154 | lea dx, menu7 |
||
155 | int 21h |
||
156 | lea dx, menu8 |
||
157 | int 21h |
||
158 | lea dx, menu9 |
||
159 | int 21h |
||
160 | lea dx, menu10 |
||
161 | int 21h |
||
162 | lea dx, menu11 |
||
163 | int 21h |
||
164 | lea dx, menu12 |
||
165 | int 21h |
||
166 | lea dx, menu13 |
||
167 | int 21h |
||
168 | lea dx, menu14 |
||
169 | int 21h |
||
170 | lea dx, menu15 |
||
171 | int 21h |
||
172 | lea dx, menu16 |
||
173 | int 21h |
||
174 | lea dx, menu17 |
||
175 | int 21h |
||
176 | lea dx, menu18 |
||
177 | int 21h |
||
11 | daniel-mar | 178 | ret |
179 | print_menu_screen ENDP |
||
180 | |||
17 | daniel-mar | 181 | print_error_screen PROC |
21 | daniel-mar | 182 | mov ah, 0Bh |
183 | mov bh, 00h |
||
184 | mov bl, 4 ; red |
||
185 | int 10h |
||
186 | |||
17 | daniel-mar | 187 | mov ah, 9 |
188 | lea dx, error1 |
||
189 | int 21h |
||
190 | lea dx, error2 |
||
191 | int 21h |
||
192 | lea dx, error3 |
||
193 | int 21h |
||
194 | ret |
||
195 | print_error_screen ENDP |
||
196 | |||
11 | daniel-mar | 197 | print_gameover_screen PROC |
21 | daniel-mar | 198 | mov ah, 0Bh |
199 | mov bh, 00h |
||
200 | mov bl, 4 ; red |
||
201 | int 10h |
||
202 | |||
11 | daniel-mar | 203 | mov ah, 9 |
204 | lea dx, gameover1 |
||
205 | int 21h |
||
206 | lea dx, gameover2 |
||
207 | int 21h |
||
208 | lea dx, gameover3 |
||
209 | int 21h |
||
210 | ret |
||
211 | print_gameover_screen ENDP |
||
212 | |||
213 | ; ------------------------------------------------------- |
||
214 | |||
215 | start: |
||
216 | ; Setup data segment |
||
217 | mov ax, @data ; moving base address of data to ax |
||
218 | mov ds, ax ; moving contents of ax into ds |
||
219 | ; data section now gets initialized |
||
220 | |||
221 | ; Preserve the original screen mode |
||
222 | mov ah, 0Fh ; Query screen mode |
||
223 | int 10h |
||
224 | push ax ; actually, we are only interested in register al (screen mode), not in ah (column count) |
||
9 | daniel-mar | 225 | |
11 | daniel-mar | 226 | ; Change numlock to ON |
227 | ; DOSBox has a bug where the NumLock is not correctly set to the setting of the host system, |
||
228 | ; so you have to press the NumLock key twice so that DOSBox recognizes the status. |
||
229 | ; see: https://sourceforge.net/p/dosbox/bugs/71/ |
||
230 | ; https://superuser.com/questions/255102/is-there-a-way-to-use-the-numeric-keypad-in-dosbox/1146986 |
||
231 | ; Since the game uses number keys very often, we set NumLock to ON |
||
232 | call set_numlock_on |
||
233 | |||
234 | ; Reduce size of own application to give the called applications more space |
||
235 | ; see https://stackoverflow.com/a/10067627 |
||
236 | mov ah, 4Ah |
||
14 | daniel-mar | 237 | mov bx, 100 ; 100 paragraphs a 16 bytes = 1600 bytes |
11 | daniel-mar | 238 | int 21h |
239 | |||
240 | menu: |
||
241 | ; Video Mode VGA 12 |
||
242 | call set_screen12 |
||
243 | |||
244 | ; Flush keyboard buffer |
||
245 | call flush_keyb_buf |
||
246 | |||
247 | ; Print menu screen |
||
248 | call print_menu_screen |
||
249 | |||
9 | daniel-mar | 250 | retry: |
251 | ; Query keyboard input |
||
11 | daniel-mar | 252 | mov ah, 07h ; Direct character input, without echo |
9 | daniel-mar | 253 | int 21h |
254 | cmp al, '1' |
||
255 | je prog1 |
||
256 | cmp al, '2' |
||
257 | je prog2 |
||
258 | cmp al, '9' |
||
11 | daniel-mar | 259 | je exit |
9 | daniel-mar | 260 | |
261 | ; Invalid input |
||
262 | jmp retry |
||
263 | |||
264 | prog1: |
||
265 | ; Clear screen |
||
266 | call clear_vga |
||
267 | |||
268 | ; Setup parameter block for the EXEC command |
||
269 | call setup_paramblk |
||
270 | |||
271 | ; Start game 1 |
||
11 | daniel-mar | 272 | mov ah, 4Bh ; execute |
273 | mov al, 00h ; load and execute |
||
9 | daniel-mar | 274 | mov bx, paramblk |
275 | lea dx, exename1 |
||
276 | int 21h |
||
277 | |||
17 | daniel-mar | 278 | ; Is everything OK? Or is the GAM file missing? |
279 | jc error |
||
280 | |||
11 | daniel-mar | 281 | ; Notify the player that the game has finished |
9 | daniel-mar | 282 | jmp gameover |
283 | |||
284 | prog2: |
||
285 | ; Clear screen |
||
286 | call clear_vga |
||
287 | |||
288 | ; Setup parameter block for the EXEC command |
||
289 | call setup_paramblk |
||
290 | |||
291 | ; Start game 2 |
||
11 | daniel-mar | 292 | mov ah, 4Bh ; execute |
293 | mov al, 00h ; load and execute |
||
9 | daniel-mar | 294 | mov bx, paramblk |
295 | lea dx, exename2 |
||
296 | int 21h |
||
17 | daniel-mar | 297 | |
298 | ; Is everything OK? Or is the GAM file missing? |
||
299 | jc error |
||
9 | daniel-mar | 300 | |
11 | daniel-mar | 301 | ; Notify the player that the game has finished |
9 | daniel-mar | 302 | jmp gameover |
11 | daniel-mar | 303 | |
17 | daniel-mar | 304 | error: |
305 | ; Video Mode VGA 12 |
||
306 | call set_screen12 |
||
307 | |||
308 | ; Clear screen |
||
309 | ; call clear_vga |
||
310 | |||
311 | ; Print error |
||
312 | call print_error_screen |
||
313 | |||
314 | ; Give the player time to read the error message (approx 5 seconds) |
||
315 | call sleep_5 |
||
316 | |||
317 | ; Go back to the menu |
||
318 | jmp menu |
||
319 | |||
9 | daniel-mar | 320 | gameover: |
11 | daniel-mar | 321 | ; Print gameover screen |
322 | call print_gameover_screen |
||
9 | daniel-mar | 323 | |
11 | daniel-mar | 324 | ; Give the player time to read the game over message (approx 5 seconds) |
325 | call sleep_5 |
||
9 | daniel-mar | 326 | |
11 | daniel-mar | 327 | ; Go back to the menu |
9 | daniel-mar | 328 | jmp menu |
329 | |||
11 | daniel-mar | 330 | exit: |
9 | daniel-mar | 331 | ; Reset video mode to DOS default |
11 | daniel-mar | 332 | pop ax ; the video mode we have preserved at program start |
333 | mov ah, 0 ; set screen mode |
||
9 | daniel-mar | 334 | int 10h |
335 | |||
336 | ; Return to DOS |
||
11 | daniel-mar | 337 | call exit_to_dos |
9 | daniel-mar | 338 | |
11 | daniel-mar | 339 | ; ------------------------------------------------------- |
340 | |||
9 | daniel-mar | 341 | end start |