Subversion Repositories aysalia

Rev

Rev 14 | Rev 21 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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