Subversion Repositories aysalia

Rev

Rev 14 | Rev 21 | 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
17 daniel-mar 111
    mov     ah, 0         ; function no. for read
112
    int     1Ah           ; get the time of day count
113
    add     dx, 65        ; dx=9 is 0.5 sec
114
    mov     bx, dx        ; store end of delay value in bx
115
again:
116
    int     1Ah
117
    cmp     dx, bx
118
    jne     again
11 daniel-mar 119
    ret
120
sleep_5 ENDP
9 daniel-mar 121
 
11 daniel-mar 122
print_menu_screen PROC
9 daniel-mar 123
    mov     ah, 9
124
    lea     dx, menu1
125
    int     21h
126
    lea     dx, menu2
127
    int     21h
128
    lea     dx, menu3
129
    int     21h
130
    lea     dx, menu4
131
    int     21h
132
    lea     dx, menu5
133
    int     21h
134
    lea     dx, menu6
135
    int     21h
136
    lea     dx, menu7
137
    int     21h
138
    lea     dx, menu8
139
    int     21h
140
    lea     dx, menu9
141
    int     21h
142
    lea     dx, menu10
143
    int     21h
144
    lea     dx, menu11
145
    int     21h
146
    lea     dx, menu12
147
    int     21h
148
    lea     dx, menu13
149
    int     21h
150
    lea     dx, menu14
151
    int     21h
152
    lea     dx, menu15
153
    int     21h
154
    lea     dx, menu16
155
    int     21h
156
    lea     dx, menu17
157
    int     21h
158
    lea     dx, menu18
159
    int     21h
11 daniel-mar 160
    ret
161
print_menu_screen ENDP
162
 
17 daniel-mar 163
print_error_screen PROC
164
    mov     ah, 9
165
    lea     dx, error1
166
    int     21h
167
    lea     dx, error2
168
    int     21h
169
    lea     dx, error3
170
    int     21h
171
    ret
172
print_error_screen ENDP
173
 
11 daniel-mar 174
print_gameover_screen PROC
175
    mov     ah, 9
176
    lea     dx, gameover1
177
    int     21h
178
    lea     dx, gameover2
179
    int     21h
180
    lea     dx, gameover3
181
    int     21h
182
    ret
183
print_gameover_screen ENDP
184
 
185
; -------------------------------------------------------
186
 
187
start:
188
    ; Setup data segment
189
    mov     ax, @data     ; moving base address of data to ax
190
    mov     ds, ax        ; moving contents of ax into ds
191
                          ; data section now gets initialized                                        
192
 
193
    ; Preserve the original screen mode
194
    mov     ah, 0Fh       ; Query screen mode
195
    int     10h
196
    push    ax            ; actually, we are only interested in register al (screen mode), not in ah (column count)
9 daniel-mar 197
 
11 daniel-mar 198
    ; Change numlock to ON
199
    ; DOSBox has a bug where the NumLock is not correctly set to the setting of the host system,
200
    ; so you have to press the NumLock key twice so that DOSBox recognizes the status.
201
    ; see: https://sourceforge.net/p/dosbox/bugs/71/
202
    ;      https://superuser.com/questions/255102/is-there-a-way-to-use-the-numeric-keypad-in-dosbox/1146986
203
    ; Since the game uses number keys very often, we set NumLock to ON
204
    call    set_numlock_on
205
 
206
    ; Reduce size of own application to give the called applications more space
207
    ; see https://stackoverflow.com/a/10067627
208
    mov     ah, 4Ah
14 daniel-mar 209
    mov     bx, 100       ; 100 paragraphs a 16 bytes = 1600 bytes
11 daniel-mar 210
    int     21h
211
 
212
menu:
213
    ; Video Mode VGA 12
214
    call    set_screen12
215
 
216
    ; Flush keyboard buffer    
217
    call    flush_keyb_buf
218
 
219
    ; Print menu screen
220
    call    print_menu_screen
221
 
9 daniel-mar 222
retry:
223
    ; Query keyboard input
11 daniel-mar 224
    mov     ah, 07h       ; Direct character input, without echo
9 daniel-mar 225
    int     21h
226
    cmp     al, '1'
227
    je      prog1
228
    cmp     al, '2'
229
    je      prog2
230
    cmp     al, '9'
11 daniel-mar 231
    je      exit
9 daniel-mar 232
 
233
    ; Invalid input
234
    jmp     retry
235
 
236
prog1:
237
    ; Clear screen
238
    call    clear_vga
239
 
240
    ; Setup parameter block for the EXEC command
241
    call    setup_paramblk
242
 
243
    ; Start game 1
11 daniel-mar 244
    mov     ah, 4Bh       ; execute 
245
    mov     al, 00h       ; load and execute 
9 daniel-mar 246
    mov     bx, paramblk
247
    lea     dx, exename1
248
    int     21h
249
 
17 daniel-mar 250
    ; Is everything OK? Or is the GAM file missing?
251
    jc      error
252
 
11 daniel-mar 253
    ; Notify the player that the game has finished
9 daniel-mar 254
    jmp     gameover
255
 
256
prog2:
257
    ; Clear screen
258
    call    clear_vga
259
 
260
    ; Setup parameter block for the EXEC command
261
    call    setup_paramblk
262
 
263
    ; Start game 2
11 daniel-mar 264
    mov     ah, 4Bh       ; execute 
265
    mov     al, 00h       ; load and execute 
9 daniel-mar 266
    mov     bx, paramblk
267
    lea     dx, exename2
268
    int     21h
17 daniel-mar 269
 
270
    ; Is everything OK? Or is the GAM file missing?
271
    jc      error
9 daniel-mar 272
 
11 daniel-mar 273
    ; Notify the player that the game has finished
9 daniel-mar 274
    jmp     gameover
11 daniel-mar 275
 
17 daniel-mar 276
error:
277
    ; Video Mode VGA 12
278
    call    set_screen12
279
 
280
    ; Clear screen
281
    ; call    clear_vga
282
 
283
    ; Print error
284
    call    print_error_screen
285
 
286
    ; Give the player time to read the error message (approx 5 seconds)
287
    call    sleep_5
288
 
289
    ; Go back to the menu
290
    jmp     menu
291
 
9 daniel-mar 292
gameover:
11 daniel-mar 293
    ; Print gameover screen
294
    call    print_gameover_screen
9 daniel-mar 295
 
11 daniel-mar 296
    ; Give the player time to read the game over message (approx 5 seconds)
297
    call    sleep_5
9 daniel-mar 298
 
11 daniel-mar 299
    ; Go back to the menu
9 daniel-mar 300
    jmp     menu
301
 
11 daniel-mar 302
exit:
9 daniel-mar 303
    ; Reset video mode to DOS default
11 daniel-mar 304
    pop     ax            ; the video mode we have preserved at program start
305
    mov     ah, 0         ; set screen mode
9 daniel-mar 306
    int     10h
307
 
308
    ; Return to DOS
11 daniel-mar 309
    call    exit_to_dos
9 daniel-mar 310
 
11 daniel-mar 311
; -------------------------------------------------------
312
 
9 daniel-mar 313
end start