Subversion Repositories aysalia

Rev

Rev 11 | Rev 17 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

  1.  
  2. ; Aysalia DOS Launcher
  3. ; Launches aydos1.gam and aydos2.gam
  4. ; Revision 2018-12-05
  5. ; (C) 2018 Daniel Marschall, ViaThinkSoft
  6.  
  7. .model small
  8. .stack 10h
  9.  
  10. ; -------------------------------------------------------
  11.  
  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.  
  51. ; -------------------------------------------------------
  52.  
  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.  
  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.  
  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.  
  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
  91.  
  92. flush_keyb_buf PROC
  93.     mov     ah, 0Ch       ; Flush input buffer and input
  94.     mov     al, 0
  95.     int     21h
  96.     ret
  97. flush_keyb_buf ENDP
  98.  
  99. exit_to_dos PROC
  100.     mov     ah, 4ch
  101.     mov     al, 00h
  102.     int     21h
  103.     ret
  104. exit_to_dos ENDP
  105.  
  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
  113.  
  114. print_menu_screen PROC
  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
  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)
  178.    
  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     bx, 100       ; 100 paragraphs a 16 bytes = 1600 bytes
  191.     int     21h
  192.  
  193. menu:
  194.     ; Video Mode VGA 12
  195.     call    set_screen12
  196.  
  197.     ; Flush keyboard buffer    
  198.     call    flush_keyb_buf
  199.  
  200.     ; Print menu screen
  201.     call    print_menu_screen
  202.    
  203. retry:
  204.     ; Query keyboard input
  205.     mov     ah, 07h       ; Direct character input, without echo
  206.     int     21h
  207.     cmp     al, '1'
  208.     je      prog1
  209.     cmp     al, '2'
  210.     je      prog2
  211.     cmp     al, '9'
  212.     je      exit
  213.  
  214.     ; Invalid input
  215.     jmp     retry
  216.  
  217. prog1:
  218.     ; Clear screen
  219.     call    clear_vga
  220.  
  221.     ; Setup parameter block for the EXEC command
  222.     call    setup_paramblk
  223.  
  224.     ; Start game 1
  225.     mov     ah, 4Bh       ; execute
  226.     mov     al, 00h       ; load and execute
  227.     mov     bx, paramblk
  228.     lea     dx, exename1
  229.     int     21h
  230.    
  231.     ; Notify the player that the game has finished
  232.     jmp     gameover
  233.  
  234. prog2:
  235.     ; Clear screen
  236.     call    clear_vga
  237.    
  238.     ; Setup parameter block for the EXEC command
  239.     call    setup_paramblk
  240.  
  241.     ; Start game 2
  242.     mov     ah, 4Bh       ; execute
  243.     mov     al, 00h       ; load and execute
  244.     mov     bx, paramblk
  245.     lea     dx, exename2
  246.     int     21h
  247.  
  248.     ; Notify the player that the game has finished
  249.     jmp     gameover
  250.    
  251. gameover:
  252.     ; Print gameover screen
  253.     call    print_gameover_screen
  254.  
  255.     ; Give the player time to read the game over message (approx 5 seconds)
  256.     call    sleep_5
  257.  
  258.     ; Go back to the menu
  259.     jmp     menu
  260.    
  261. exit:
  262.     ; Reset video mode to DOS default
  263.     pop     ax            ; the video mode we have preserved at program start
  264.     mov     ah, 0         ; set screen mode
  265.     int     10h
  266.  
  267.     ; Return to DOS
  268.     call    exit_to_dos
  269.  
  270. ; -------------------------------------------------------
  271.  
  272. end start