Subversion Repositories aysalia

Rev

Rev 10 | Rev 14 | 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
11 daniel-mar 4
; Revision 2018-12-03
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, '$'       
46
 
47
    gameover1 db '',13,10,'$'
48
    gameover2 db 'Spiel zu Ende!',13,10,'$'
49
    gameover3 db '',13,10,'$'
50
 
11 daniel-mar 51
; -------------------------------------------------------
52
 
9 daniel-mar 53
.code
54
 
55
clear_vga PROC
56
    mov     ax, 0a000h
57
    mov     es, ax
58
    xor     di, di
59
    mov     ax, 0
60
    mov     cx, 64000
61
    rep     stosb
62
    ret
63
clear_vga ENDP
64
 
11 daniel-mar 65
set_screen12 PROC
66
    mov     ah, 0         ; set screen mode
67
    mov     al, 12h       ; graphic mode, 640x480 pixel, 16 colors (VGA)
68
    int     10h
69
    ret
70
set_screen12 ENDP
71
 
9 daniel-mar 72
setup_paramblk PROC
73
    mov     ax, cs
74
    mov     [paramblk +  4], ax   ; cmdargs_seg
75
    mov     [paramblk +  8], ax   ; fcb1_seg
76
    mov     [paramblk + 12], ax   ; fcb2_seg
77
    ret
78
setup_paramblk ENDP
79
 
11 daniel-mar 80
set_numlock_on PROC
81
    push    ds
82
    mov     ax, 40h
83
    mov     ds, ax        ; go to BIOS Data Area ( http://stanislavs.org/helppc/bios_data_area.html )
84
    mov     bx, 17h       ; Load Keyboard flag byte 0
85
    mov     al, [bx]      ; read
86
    or      al, 20h       ; set bit 5 (numlock) to 1
87
    mov     [bx], al      ; write
88
    pop     ds
89
    ret
90
set_numlock_on ENDP
9 daniel-mar 91
 
11 daniel-mar 92
flush_keyb_buf PROC
93
    mov     ah, 0Ch       ; Flush input buffer and input 
94
    mov     al, 0
9 daniel-mar 95
    int     21h
11 daniel-mar 96
    ret
97
flush_keyb_buf ENDP
9 daniel-mar 98
 
11 daniel-mar 99
exit_to_dos PROC
100
    mov     ah, 4ch
101
    mov     al, 00h
102
    int     21h
103
    ret
104
exit_to_dos ENDP
9 daniel-mar 105
 
11 daniel-mar 106
sleep_5 PROC
107
    mov     ah, 86h
108
    mov     cx, 004bh
109
    mov     dx, 4000h
110
    int     15h
111
    ret
112
sleep_5 ENDP
9 daniel-mar 113
 
11 daniel-mar 114
print_menu_screen PROC
9 daniel-mar 115
    mov     ah, 9
116
    lea     dx, menu1
117
    int     21h
118
    lea     dx, menu2
119
    int     21h
120
    lea     dx, menu3
121
    int     21h
122
    lea     dx, menu4
123
    int     21h
124
    lea     dx, menu5
125
    int     21h
126
    lea     dx, menu6
127
    int     21h
128
    lea     dx, menu7
129
    int     21h
130
    lea     dx, menu8
131
    int     21h
132
    lea     dx, menu9
133
    int     21h
134
    lea     dx, menu10
135
    int     21h
136
    lea     dx, menu11
137
    int     21h
138
    lea     dx, menu12
139
    int     21h
140
    lea     dx, menu13
141
    int     21h
142
    lea     dx, menu14
143
    int     21h
144
    lea     dx, menu15
145
    int     21h
146
    lea     dx, menu16
147
    int     21h
148
    lea     dx, menu17
149
    int     21h
150
    lea     dx, menu18
151
    int     21h
11 daniel-mar 152
    ret
153
print_menu_screen ENDP
154
 
155
print_gameover_screen PROC
156
    mov     ah, 9
157
    lea     dx, gameover1
158
    int     21h
159
    lea     dx, gameover2
160
    int     21h
161
    lea     dx, gameover3
162
    int     21h
163
    ret
164
print_gameover_screen ENDP
165
 
166
; -------------------------------------------------------
167
 
168
start:
169
    ; Setup data segment
170
    mov     ax, @data     ; moving base address of data to ax
171
    mov     ds, ax        ; moving contents of ax into ds
172
                          ; data section now gets initialized                                        
173
 
174
    ; Preserve the original screen mode
175
    mov     ah, 0Fh       ; Query screen mode
176
    int     10h
177
    push    ax            ; actually, we are only interested in register al (screen mode), not in ah (column count)
9 daniel-mar 178
 
11 daniel-mar 179
    ; Change numlock to ON
180
    ; DOSBox has a bug where the NumLock is not correctly set to the setting of the host system,
181
    ; so you have to press the NumLock key twice so that DOSBox recognizes the status.
182
    ; see: https://sourceforge.net/p/dosbox/bugs/71/
183
    ;      https://superuser.com/questions/255102/is-there-a-way-to-use-the-numeric-keypad-in-dosbox/1146986
184
    ; Since the game uses number keys very often, we set NumLock to ON
185
    call    set_numlock_on
186
 
187
    ; Reduce size of own application to give the called applications more space
188
    ; see https://stackoverflow.com/a/10067627
189
    mov     ah, 4Ah
190
    mov     al, 00h    
191
    mov     bx, 100       ; 100 paragraphs a 16 byte = 1600 byte
192
                          ; EXE size is 1188 byte
193
    int     21h
194
 
195
menu:
196
    ; Video Mode VGA 12
197
    call    set_screen12
198
 
199
    ; Flush keyboard buffer    
200
    call    flush_keyb_buf
201
 
202
    ; Print menu screen
203
    call    print_menu_screen
204
 
9 daniel-mar 205
retry:
206
    ; Query keyboard input
11 daniel-mar 207
    mov     ah, 07h       ; Direct character input, without echo
9 daniel-mar 208
    int     21h
209
    cmp     al, '1'
210
    je      prog1
211
    cmp     al, '2'
212
    je      prog2
213
    cmp     al, '9'
11 daniel-mar 214
    je      exit
9 daniel-mar 215
 
216
    ; Invalid input
217
    jmp     retry
218
 
219
prog1:
220
    ; Clear screen
221
    call    clear_vga
222
 
223
    ; Setup parameter block for the EXEC command
224
    call    setup_paramblk
225
 
226
    ; Start game 1
11 daniel-mar 227
    mov     ah, 4Bh       ; execute 
228
    mov     al, 00h       ; load and execute 
9 daniel-mar 229
    mov     bx, paramblk
230
    lea     dx, exename1
231
    int     21h
232
 
11 daniel-mar 233
    ; Notify the player that the game has finished
9 daniel-mar 234
    jmp     gameover
235
 
236
prog2:
237
    ; Clear screen
238
    call    clear_vga
239
 
240
    ; Setup parameter block for the EXEC command
241
    call    setup_paramblk
242
 
243
    ; Start game 2
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, exename2
248
    int     21h
249
 
11 daniel-mar 250
    ; Notify the player that the game has finished
9 daniel-mar 251
    jmp     gameover
11 daniel-mar 252
 
9 daniel-mar 253
gameover:
11 daniel-mar 254
    ; Print gameover screen
255
    call    print_gameover_screen
9 daniel-mar 256
 
11 daniel-mar 257
    ; Give the player time to read the game over message (approx 5 seconds)
258
    call    sleep_5
9 daniel-mar 259
 
11 daniel-mar 260
    ; Go back to the menu
9 daniel-mar 261
    jmp     menu
262
 
11 daniel-mar 263
exit:
9 daniel-mar 264
    ; Reset video mode to DOS default
11 daniel-mar 265
    pop     ax            ; the video mode we have preserved at program start
266
    mov     ah, 0         ; set screen mode
9 daniel-mar 267
    int     10h
268
 
269
    ; Return to DOS
11 daniel-mar 270
    call    exit_to_dos
9 daniel-mar 271
 
11 daniel-mar 272
; -------------------------------------------------------
273
 
9 daniel-mar 274
end start