Rev 23 | 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 |
||
22 | daniel-mar | 4 | ; Revision 2018-12-07 |
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 | |||
22 | daniel-mar | 14 | exename1 db "AYDOS1.GAM", 0 |
15 | exename2 db "AYDOS2.GAM", 0 |
||
16 | cmdargs db 0, '', 0Dh |
||
9 | daniel-mar | 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 | |||
22 | daniel-mar | 28 | menu1 db 13, 10, \ |
29 | 13, 10, \ |
||
30 | 13, 10, \ |
||
31 | 13, 10, \ |
||
32 | ' Aysalia DOS', 13, 10, \ |
||
33 | 13, 10, \ |
||
34 | 13, 10, \ |
||
35 | ' Welches Spiel soll gestartet werden?', 13, 10, \ |
||
36 | 13, 10, \ |
||
37 | ' Dr', 81h, 'cke eine der folgenden Tasten:', 13, 10, \ |
||
38 | 13, 10, \ |
||
39 | ' 1 Aysalia DOS I', 13, 10, \ |
||
40 | ' 2 Aysalia DOS II', 13, 10, \ |
||
41 | 13, 10, \ |
||
42 | ' 9 Beenden', 13, 10, \ |
||
43 | 13, 10, \ |
||
44 | 13, 10, \ |
||
45 | 13, 10, 0 |
||
17 | daniel-mar | 46 | |
22 | daniel-mar | 47 | error1 db 13, 10, \ |
48 | 'Fehler: Spiel kann nicht gestartet werden. Fehlt eine Datei?', 13, 10, \ |
||
49 | 13, 10, 0 |
||
9 | daniel-mar | 50 | |
22 | daniel-mar | 51 | gameover1 db 13, 10, \ |
52 | 'Spiel zu Ende!', 13, 10, \ |
||
53 | 13, 10, 0 |
||
9 | daniel-mar | 54 | |
11 | daniel-mar | 55 | ; ------------------------------------------------------- |
56 | |||
9 | daniel-mar | 57 | .code |
58 | |||
59 | clear_vga PROC |
||
22 | daniel-mar | 60 | mov ax, 0A000h |
9 | daniel-mar | 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 |
||
22 | daniel-mar | 87 | mov ds, ax ; Go to BIOS Data Area ( http://stanislavs.org/helppc/bios_data_area.html ) |
11 | daniel-mar | 88 | mov bx, 17h ; Load Keyboard flag byte 0 |
22 | daniel-mar | 89 | mov al, [bx] ; Read |
90 | or al, 20h ; Set bit 5 (numlock) to 1 |
||
91 | mov [bx], al ; Write |
||
11 | daniel-mar | 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 |
22 | daniel-mar | 104 | mov ah, 4Ch |
11 | daniel-mar | 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 |
22 | daniel-mar | 114 | jg sleep_5_upperhalf |
115 | sleep_5_lowerhalf: |
||
21 | daniel-mar | 116 | mov bx, dx |
22 | daniel-mar | 117 | add bx, 91 ; 18.2 = 1 sec (therefore 91 = 5 sec) |
118 | sleep_5_lowerhalf_again: |
||
21 | daniel-mar | 119 | int 1Ah |
17 | daniel-mar | 120 | cmp dx, bx |
22 | daniel-mar | 121 | jl sleep_5_lowerhalf_again |
11 | daniel-mar | 122 | ret |
22 | daniel-mar | 123 | sleep_5_upperhalf: |
21 | daniel-mar | 124 | mov bx, dx |
125 | sub bx, 7FFFh |
||
22 | daniel-mar | 126 | add bx, 91 ; 18.2 = 1 sec (therefore 91 = 5 sec) |
127 | sleep_5_upperhalf_again: |
||
21 | daniel-mar | 128 | int 1Ah |
129 | sub dx, 7FFFh |
||
130 | cmp dx, bx |
||
22 | daniel-mar | 131 | jl sleep_5_upperhalf_again |
21 | daniel-mar | 132 | ret |
11 | daniel-mar | 133 | sleep_5 ENDP |
9 | daniel-mar | 134 | |
22 | daniel-mar | 135 | print_color_string PROC |
136 | ; This function requires: |
||
137 | ; dx = Pointer to zero terminated string |
||
138 | ; cl = Color |
||
139 | mov ah, 0Eh |
||
140 | print_color_string_again: |
||
141 | mov bx, dx |
||
25 | daniel-mar | 142 | mov al, [bx] |
143 | cmp al, 0 ; is the character zero? then we are done |
||
22 | daniel-mar | 144 | je print_color_string_end |
145 | mov bl, cl |
||
146 | int 10h |
||
25 | daniel-mar | 147 | add dx, 1 ; go to next character |
22 | daniel-mar | 148 | jmp print_color_string_again |
149 | print_color_string_end: |
||
150 | ret |
||
151 | print_color_string ENDP |
||
152 | |||
153 | set_bg_color PROC |
||
154 | ; This function requires: |
||
155 | ; bl = Color |
||
21 | daniel-mar | 156 | mov ah, 0Bh |
157 | mov bh, 00h |
||
158 | int 10h |
||
22 | daniel-mar | 159 | ret |
160 | set_bg_color ENDP |
||
21 | daniel-mar | 161 | |
22 | daniel-mar | 162 | print_menu_screen PROC |
23 | daniel-mar | 163 | ; Clear screen |
164 | call clear_vga |
||
22 | daniel-mar | 165 | |
166 | ; Set background color |
||
167 | mov bl, 8 ; dark green background |
||
168 | call set_bg_color |
||
169 | |||
170 | ; Set text color |
||
171 | mov cl, 0Fh ; white font |
||
9 | daniel-mar | 172 | lea dx, menu1 |
22 | daniel-mar | 173 | call print_color_string |
174 | |||
11 | daniel-mar | 175 | ret |
176 | print_menu_screen ENDP |
||
177 | |||
17 | daniel-mar | 178 | print_error_screen PROC |
23 | daniel-mar | 179 | ; Clear screen |
180 | call clear_vga |
||
21 | daniel-mar | 181 | |
22 | daniel-mar | 182 | ; Set background color |
183 | mov bl, 4 ; dark red background |
||
184 | call set_bg_color |
||
185 | |||
186 | ; Set text color |
||
187 | mov cl, 0Fh ; white font |
||
17 | daniel-mar | 188 | lea dx, error1 |
22 | daniel-mar | 189 | call print_color_string |
190 | |||
17 | daniel-mar | 191 | ret |
192 | print_error_screen ENDP |
||
193 | |||
23 | daniel-mar | 194 | print_gameover_message PROC |
22 | daniel-mar | 195 | ; Keep cursor position |
21 | daniel-mar | 196 | |
22 | daniel-mar | 197 | ; Set background color |
198 | mov bl, 4 ; dark red background |
||
199 | call set_bg_color |
||
200 | |||
201 | ; Set text color |
||
202 | mov cl, 0Fh ; white font |
||
11 | daniel-mar | 203 | lea dx, gameover1 |
22 | daniel-mar | 204 | call print_color_string |
205 | |||
11 | daniel-mar | 206 | ret |
23 | daniel-mar | 207 | print_gameover_message ENDP |
11 | daniel-mar | 208 | |
209 | ; ------------------------------------------------------- |
||
210 | |||
211 | start: |
||
212 | ; Setup data segment |
||
213 | mov ax, @data ; moving base address of data to ax |
||
214 | mov ds, ax ; moving contents of ax into ds |
||
215 | ; data section now gets initialized |
||
216 | |||
217 | ; Preserve the original screen mode |
||
218 | mov ah, 0Fh ; Query screen mode |
||
219 | int 10h |
||
220 | push ax ; actually, we are only interested in register al (screen mode), not in ah (column count) |
||
9 | daniel-mar | 221 | |
11 | daniel-mar | 222 | ; Change numlock to ON |
223 | ; DOSBox has a bug where the NumLock is not correctly set to the setting of the host system, |
||
224 | ; so you have to press the NumLock key twice so that DOSBox recognizes the status. |
||
225 | ; see: https://sourceforge.net/p/dosbox/bugs/71/ |
||
226 | ; https://superuser.com/questions/255102/is-there-a-way-to-use-the-numeric-keypad-in-dosbox/1146986 |
||
227 | ; Since the game uses number keys very often, we set NumLock to ON |
||
228 | call set_numlock_on |
||
229 | |||
230 | ; Reduce size of own application to give the called applications more space |
||
231 | ; see https://stackoverflow.com/a/10067627 |
||
232 | mov ah, 4Ah |
||
14 | daniel-mar | 233 | mov bx, 100 ; 100 paragraphs a 16 bytes = 1600 bytes |
11 | daniel-mar | 234 | int 21h |
235 | |||
236 | menu: |
||
237 | ; Video Mode VGA 12 |
||
238 | call set_screen12 |
||
239 | |||
240 | ; Flush keyboard buffer |
||
241 | call flush_keyb_buf |
||
242 | |||
243 | ; Print menu screen |
||
244 | call print_menu_screen |
||
245 | |||
9 | daniel-mar | 246 | retry: |
247 | ; Query keyboard input |
||
11 | daniel-mar | 248 | mov ah, 07h ; Direct character input, without echo |
9 | daniel-mar | 249 | int 21h |
250 | cmp al, '1' |
||
251 | je prog1 |
||
252 | cmp al, '2' |
||
253 | je prog2 |
||
254 | cmp al, '9' |
||
11 | daniel-mar | 255 | je exit |
9 | daniel-mar | 256 | |
257 | ; Invalid input |
||
258 | jmp retry |
||
259 | |||
260 | prog1: |
||
261 | ; Clear screen |
||
262 | call clear_vga |
||
263 | |||
264 | ; Setup parameter block for the EXEC command |
||
265 | call setup_paramblk |
||
266 | |||
267 | ; Start game 1 |
||
11 | daniel-mar | 268 | mov ah, 4Bh ; execute |
269 | mov al, 00h ; load and execute |
||
9 | daniel-mar | 270 | mov bx, paramblk |
271 | lea dx, exename1 |
||
272 | int 21h |
||
273 | |||
17 | daniel-mar | 274 | ; Is everything OK? Or is the GAM file missing? |
275 | jc error |
||
276 | |||
11 | daniel-mar | 277 | ; Notify the player that the game has finished |
9 | daniel-mar | 278 | jmp gameover |
279 | |||
280 | prog2: |
||
281 | ; Clear screen |
||
282 | call clear_vga |
||
283 | |||
284 | ; Setup parameter block for the EXEC command |
||
285 | call setup_paramblk |
||
286 | |||
287 | ; Start game 2 |
||
11 | daniel-mar | 288 | mov ah, 4Bh ; execute |
289 | mov al, 00h ; load and execute |
||
9 | daniel-mar | 290 | mov bx, paramblk |
291 | lea dx, exename2 |
||
292 | int 21h |
||
17 | daniel-mar | 293 | |
294 | ; Is everything OK? Or is the GAM file missing? |
||
295 | jc error |
||
9 | daniel-mar | 296 | |
11 | daniel-mar | 297 | ; Notify the player that the game has finished |
9 | daniel-mar | 298 | jmp gameover |
11 | daniel-mar | 299 | |
17 | daniel-mar | 300 | error: |
301 | ; Video Mode VGA 12 |
||
302 | call set_screen12 |
||
303 | |||
304 | ; Print error |
||
305 | call print_error_screen |
||
306 | |||
307 | ; Give the player time to read the error message (approx 5 seconds) |
||
308 | call sleep_5 |
||
309 | |||
310 | ; Go back to the menu |
||
311 | jmp menu |
||
312 | |||
9 | daniel-mar | 313 | gameover: |
23 | daniel-mar | 314 | ; Print gameover message |
315 | call print_gameover_message |
||
9 | daniel-mar | 316 | |
11 | daniel-mar | 317 | ; Give the player time to read the game over message (approx 5 seconds) |
318 | call sleep_5 |
||
9 | daniel-mar | 319 | |
11 | daniel-mar | 320 | ; Go back to the menu |
9 | daniel-mar | 321 | jmp menu |
322 | |||
11 | daniel-mar | 323 | exit: |
9 | daniel-mar | 324 | ; Reset video mode to DOS default |
11 | daniel-mar | 325 | pop ax ; the video mode we have preserved at program start |
326 | mov ah, 0 ; set screen mode |
||
9 | daniel-mar | 327 | int 10h |
328 | |||
329 | ; Return to DOS |
||
11 | daniel-mar | 330 | call exit_to_dos |
9 | daniel-mar | 331 | |
11 | daniel-mar | 332 | ; ------------------------------------------------------- |
333 | |||
9 | daniel-mar | 334 | end start |