home *** CD-ROM | disk | FTP | other *** search
/ Dave Lowe: Street Fighter 2 PC Disk 1 / Lowe_StreetFighter2PCDisk1.img / PCDRIV.ASM < prev    next >
Encoding:
Assembly Source File  |  1992-10-29  |  16.3 KB  |  836 lines

  1. ;**************************************************************************
  2. ;                                                                         *
  3. ;     PC DRIVER TO RUN MUSIC ON ROLAND/ADLIB and FX ON ROLAND                                      *
  4. ;                                      *
  5. ;**************************************************************************
  6.  
  7. ;  
  8. ;  note ..this driver does not run the ADLIB FX..as they do not use
  9. ;  Midi data files......see ADFX DIRECTORY on disk for the adlib fx driver
  10.  
  11.  
  12. ;        --------------------------------
  13.  
  14. ;  The variables :boardflg: and :mode_flag: must be set before calling
  15. ;  any of the following procedures
  16.  
  17. public    do_music        ;call to start music playing
  18. public    load_files        ;call to load Midi files from current dir.
  19. public  terminate        ;call to kill boards
  20. public  fx_mode_on        ;call to initiliase driver for ROLAND FX
  21.                 ;sets up the timer etc.  
  22. public    trigger_fx        ;call to start fx.(see list)with number in al
  23.  
  24. public  boardflg        ;byte variable 0 = ROLAND/1 = ADLib
  25. public  mode_flag        ;byte variable 0 = MUSIC(both boards)/1 = ROLAND FX
  26.  
  27. ;  examples....
  28. ;  if boardflg =1 and mode_flag = 0 then the driver will run MUSIC on ADLIB
  29. ;  if boardflg =0 and mode_flag = 1 then driver will run FX on ROLAND
  30. ;  if boardflg =0 and mode_flag = 0 then driver will run MUSIC on ROLAND
  31.  
  32. ;      see fx_table or included list for sound fx numbers
  33.  
  34.  
  35. ;        --------------------------------
  36.  
  37.         ;    DATA FILES
  38.  
  39.  
  40. csongseg1 segment para  'DATA'
  41. MIDIPlayBuffer1 db 43000 dup (?)
  42. csongseg1 ends
  43.  
  44.  
  45. csongseg2 segment para  'DATA'
  46. MIDIPlayBuffer2 db 10 dup (?)
  47. csongseg2 ends
  48.  
  49.  
  50.  
  51.  
  52. fx_segment    segment para  'DATA'
  53. fxd:
  54. punch1        db    74 dup (?)
  55. lose        db    175 dup (?)
  56. punch2        db    196 dup (?)
  57. slap1        db    226 dup (?)
  58. fscream        db    75 dup (?)
  59. mscream        db    309 dup (?)
  60. monscrea    db    122 dup (?)
  61. girlaugh    db    197 dup (?)
  62. smash        db    75 dup (?)
  63. karatec        db    365 dup (?)
  64. electric    db    672 dup (?)
  65. beep1        db    77 dup (?)
  66. beep2        db    77 dup (?)
  67. beep3        db    135 dup (?)
  68. win        db    135 dup (?)
  69. ping        db    77 dup (?)
  70. jump        db    164 dup (?)
  71.  
  72.  
  73.  
  74.  
  75. zb        db    100 dup (?)
  76. fx_segment    ends
  77.  
  78. ;______________________________________________________________________
  79.  
  80. dseg    segment para 'DATA'
  81.  
  82.  
  83. ;    messages used for testing /debugging etc...can be deleted
  84.  
  85. load_mess    db    'loading files...Please Wait',13,10,'$'
  86. board_mess    db    'Select which board..R/A',13,10,'$'
  87. mode_mess    db    'STREET FIGHTER II....Music or FX ????   M/F',13,10,'$'
  88. fin_mess    db    '1 for DOS/2 to RESELECT',13,10,'$'
  89. fx_mess        db    13,10,' ********* KEYS A-Z for jingles 1 to 26 + KEYS 3-8 for jingles 27 to 32 ********',13,10,13,10,'$'
  90. roland_mess    db    13,10,' ************** PLAYING ROLAND STREET FIGHTER II MUSIC ***************',13,10,13,10,'$'
  91. adlib_mess    db    13,10,' ********************* PLAYING  ADLIB STREET FIGHTER II MUSIC *********************',13,10,13,10,'$'
  92. select_tune_mess db    13,10,' SELECT TUNES A TO E ',13,10,'$'
  93.  
  94. ch1mess        db    '1 ','$'
  95. ch2mess        db    '2 ','$'
  96.  
  97. ;-----------------------------------------------------------------------
  98. ;  offsets into midi fx file....1= loop 0 = no loop
  99. fx_table    dw punch1-fxd,0    
  100.         dw lose-fxd,0
  101.         dw punch2-fxd,0
  102.         dw slap1-fxd,0
  103.         dw fscream-fxd,0
  104.         dw mscream-fxd,0
  105.         dw monscrea-fxd,0
  106.         dw girlaugh-fxd,0
  107.         dw smash-fxd,0
  108.         dw karatec-fxd,0
  109.         dw electric-fxd,0
  110.         dw beep1-fxd,0
  111.         dw beep2-fxd,0
  112.         dw beep3-fxd,0
  113.         dw win-fxd,0
  114.         dw ping-fxd,0
  115.         dw jump-fxd,0
  116.  
  117.  
  118.  
  119. ;---------------------------------------------------------------
  120. include rolvars.asm
  121. include advars.asm
  122. include nwsongs.asm
  123.  
  124. dseg    ends
  125. ;--------------------------
  126. CStack    segment    para stack 'STACK'        ;for stand alone assembly
  127.     db    128 dup(?)
  128. CStack    ends
  129. ;--------------------------
  130. cseg    segment    para public 'CODE'
  131.     assume    cs:cseg,ds:dseg
  132. ;************************************************************************
  133.  
  134.     ;    TEST CONTROL SECTION to allow stand alone testing
  135.     ;          can be deleted when not required
  136.  
  137.  
  138. Start proc near
  139.     mov    dx,ds
  140.     mov    si,2
  141.     mov    bx,[si]
  142.     mov    ax,dseg
  143.     mov    ds,ax
  144.     cld            ;default direction flag
  145.     call resetall
  146.  
  147.  
  148. ;-------------------------------
  149. board_select:
  150.     ;  SELECT WHICH BOARD TO USE
  151.  
  152.     mov    dx,offset board_mess
  153.     call    print
  154.  
  155.  
  156. GBrd:    call    GetKey        ;Roland or Adlib?
  157.     cmp    al,'a'    
  158.     jne    checkROL        ;Adlib
  159.     jmp    play_ad_board
  160. checkROL:
  161.     cmp    al,'r'
  162.     jne    GBrd        ;CHANGED
  163.  
  164.     ;    PLAY SONG ON ROLAND
  165.  
  166.     mov    BoardFlg,0
  167.     mov    dx,offset roland_mess
  168.     call     print
  169.  
  170.  
  171.     jmp    choose_mode
  172. play_ad_board:
  173.     mov    boardFlg,1
  174.     mov    mode_flag,0    ;music only on adlib
  175.     mov    dx,offset adlib_mess
  176.     call     print
  177.     jmp    adj1
  178. ;---------------------------------
  179.  
  180.     ;  CHOOSE MUSIC OR FX ON  ROLAND
  181.  
  182. ;   test wait for key loop
  183. choose_mode:
  184.  
  185.         ;    test for fx or music here
  186.  
  187.     mov    dx,offset mode_mess
  188.     call print
  189.     call getkey
  190.             ;choose music or fx
  191.     cmp    al,'m'
  192.     jne    check_fx
  193.     mov    dx,offset roland_mess
  194.     call print
  195.  
  196.     ;-----------------------------
  197.     mov    mode_flag,0    ;music mode
  198.     mov    dx,offset select_tune_mess
  199.     call     print
  200.     call    getkey
  201. newr:    sub    al,97    
  202.     mov [Rsong_number],al
  203.     call far ptr load_files    ; get em in
  204.     call    far ptr do_music
  205.     jmp    test_loop
  206.  
  207.  
  208. ;********************************************************
  209. ;        PLAY MUSIC ONLY ON ADLIB
  210.  
  211. adj1:    mov    mode_flag,0    ;  music mode
  212.     mov    dx,offset select_tune_mess
  213.     call print
  214.     call   getkey
  215. newa:    sub    al,82        ;15 roland files first    
  216.     mov [Asong_number],al
  217.     call far ptr load_files    ; get em in
  218.     call    far ptr do_music
  219.     jmp test_loop
  220. ;***********************************************************
  221.  
  222. check_fx:
  223.     cmp    al,'f'
  224.     jne    choose_mode    ;error
  225.     mov    mode_flag,1
  226.  
  227. set_fx_mode:
  228.     call    far ptr fx_mode_on    ;ROLAND FX MODE SET UP
  229.     mov    dx,offset fx_mess
  230.     call print
  231.  
  232. ;--------------------------------------------
  233. ;       TEST LOOP......IE SITS IN THIS LOOP WHILE RUNNING MIDI
  234.     ;  interrupts play music
  235. test_loop:
  236.  
  237.     ;  test only
  238.     ;jmp    testrun
  239.  
  240.  
  241.     mov    dx,offset fin_mess
  242.     call print
  243.     
  244. test_loop1:            ; TEST FOR KEY PRESS TO FINISH
  245.     call    CheckKey
  246.     jz    test_loop1
  247.     call    GetKey
  248.     cmp    al,'1'        ;  quit altogether
  249.     je    back_to_dos
  250.     cmp    al,'2'        ;   reset to choose mode
  251.     je    reset
  252.  
  253.  
  254. ;    must be key to trigger fx
  255.     cmp    al,127
  256.     jae    test_loop1
  257.     cmp    al,49
  258.     jbe    test_loop1
  259.  
  260.  
  261.                 ;manipulate key number
  262.     cmp al,97     
  263.     jae isletk
  264.     add al,72
  265. isletk:
  266.     sub    al,96    
  267.     call  far ptr    trigger_fx
  268.     jmp     test_loop1
  269.  
  270. ;------------------------
  271.  
  272. back_to_dos:
  273.  
  274.     call resetall
  275.     call far ptr terminate
  276.     mov    ah,4ch
  277.     int 21h
  278.     ret
  279. reset:
  280.     push ax
  281.     call resetall
  282.     call far ptr terminate
  283.     ;mov    al,[boardflg]
  284.     ;cmp     al,0
  285.     ;jne    reseta
  286.     ;pop ax
  287.     jmp start
  288. reseta:
  289.     pop ax
  290.     jmp start
  291.  
  292.  
  293. start    endp
  294. ;---------------------------------
  295. print    proc near
  296.         ;  input  dx    points to message
  297.  
  298.     push    ax
  299.     mov    ah,9
  300.     int 21h
  301.     pop     ax
  302.     ret
  303.     
  304. print    endp
  305.  
  306. ;        END OF CONTROL TEST (deletable) SECTION
  307. ;************************************************************************
  308. ;************************************************************************
  309. ;************************************************************************
  310. ;************************************************************************
  311.  
  312.     ;          ACTUAL DRIVER ROUTINES
  313.  
  314.     ;        call here to start music
  315.     ;    boardflg must be set 0= ROLAND 1 = ADLIB 
  316.  
  317.  
  318. ;----------------------------------------------
  319. ;;;;;;;DO MUSIC ROUTINE
  320.  
  321. do_music  proc far
  322.  
  323.     mov    dx,ds
  324.     mov    si,2
  325.     mov    bx,[si]
  326.     mov    ax,dseg
  327.     mov    ds,ax
  328.     cld            ;default direction flag
  329.  
  330.     mov    [tickspq],96    ;standard seq
  331.             ;   choose which music and set it running
  332.     cmp    boardFlg,0
  333.     jne    playad
  334.     call    resetall
  335.     mov    al,[Rsong_number]
  336.     xor     ah,ah
  337.     call    makesound    ;al = tune to play on ROLAND
  338.     ret 
  339. playad:
  340.     mov    al,[Asong_number]
  341.     xor     ah,ah
  342. nocorr:    call    playsad
  343.     ret
  344. do_music endp 
  345. ;*************************************
  346. load_files proc far
  347.             ;  call here to load required MIDI files
  348.             ;  The files must be in the current directory
  349.             ;  and the boardflg must be set
  350.  
  351.     mov    dx,ds
  352.     mov    si,2
  353.     mov    bx,[si]
  354.     mov    ax,dseg
  355.     mov    ds,ax
  356.     cld            ;default direction flag
  357.     call    LOAD_MIDI_FILES
  358.     ret
  359.  
  360. load_files endp
  361. ;************************************
  362. terminate proc far
  363.  
  364.             ;  call here to stop sound on both boards
  365.             ;  boardflg must be set.
  366.  
  367.     mov    dx,ds
  368.     mov    si,2
  369.     mov    bx,[si]
  370.     mov    ax,dseg
  371.     mov    ds,ax
  372.     cld            ;default direction flag
  373.     cmp boardflg,0
  374.     jne    stop_ad
  375.     mov    ch1_flag,0
  376.     mov    ch2_flag,0    ;clear fx flags
  377.     call rcc10
  378.     call rcc2
  379.     call ano2
  380.     call ano10
  381.  
  382.     call stopMusicR
  383.     ret
  384. stop_ad:
  385.     call stopmidiplayadlib
  386.     ret
  387. terminate endp
  388. ;-------------------------------------------------------
  389. fx_mode_on proc far
  390.     ;   play fx
  391.     ;   SEt UP THE TIMER AND FLAGS TO RUN THE FX DRIVER
  392.  
  393. ;-------------------------------
  394. ;;load midi fx file for ROLAND
  395.  
  396.     mov bx,5    ;6 name in list
  397.     shl    bx,1
  398.     mov    dx,SongNames[bx]
  399.     mov    di,offset fxd
  400.     mov    ax,fx_segment
  401.     push ds
  402.     call    LoadSegFile
  403.     pop ds
  404.     
  405. ;---------------------------------
  406.         ;board to reset status
  407.  
  408.     mov    dx,ds
  409.     mov    si,2
  410.     mov    bx,[si]
  411.     mov    ax,dseg
  412.     mov    ds,ax
  413.     cld            ;default direction flag
  414. ;    call    resetall        ;not implemented
  415.     mov    fx_flag,1    ;set flag for interrupt routine
  416.     mov    DonePlay,0
  417.     mov    recordflg,0
  418.     mov    timeover,0    
  419. ;    reset fx vars
  420.     mov    ch1_pattp,0
  421.     mov    ch2_pattp,0
  422.     mov    ch1_flag,0
  423.     mov    ch2_flag,0
  424.     mov    ch1_intc,0
  425.     mov    ch2_intc,0
  426.     call installTimer
  427.     mov    tickspq,96        ;ticks per quarter beat
  428.     mov    ax,120        ; tempo to give 76 hz
  429.     mov    tempo,ax
  430.     call setTimerTempo
  431.     call switchlapc1touart
  432.     call    rcc2
  433.     call    ano2
  434.     call    rcc10
  435.     
  436.     SnLA    setvol
  437.     mov    cs:eventdelay,1        ;run interrupt routine on next 50th
  438.     mov    musicPlayFlg,-1        ;to allow event routine to run
  439.     ret
  440.  
  441. fx_mode_on endp     
  442. ;*************************************************
  443. trigger_fx proc far
  444.  
  445.  
  446.     push ax            ;fx number
  447.     mov [curr_fx],ax
  448.     mov    dx,ds
  449.     mov    si,2
  450.     mov    bx,[si]
  451.     mov    ax,dseg
  452.     mov    ds,ax
  453.     cld            ;default direction flag
  454.     pop ax
  455.  
  456.             ;mov    dx,offset ch1mess
  457.             ;call print
  458.  
  459.     ;   sort fx offset from fx list
  460.     dec    al
  461.     add     al,al    ;*2    
  462.     add    al,al    ;*4    ;double word table
  463.     mov    bl,al
  464.     xor    bh,bh
  465.     mov    ax,fx_table[bx]
  466.  
  467.     add    ax,03bh        ;header
  468.     mov    [startptr],ax
  469.     push     ax        ; offset
  470.     inc     bx
  471.     inc    bx
  472.     mov    ax,fx_table[bx]
  473.     mov [loop_flag],ax
  474.     jmp    use2
  475.  
  476.  
  477.  
  478.     ;   use driver channel 1
  479. use1:
  480.     pop     ax
  481.     mov    ch1_pattp,ax
  482.     mov    int_flag,1    ;disable interrupt routine
  483.     mov    ch1_flag,1    ;enable channel 1
  484.     mov    ch1_intc,0    ;reset any interrupt count
  485.     mov    int_flag,0    ;enable interrupt routine
  486.     ;call    rcc10        ;reset controllers 10        
  487.     ;call    ano10
  488.     call resetall
  489.  
  490.     ret
  491. use2:
  492.     ;  always overwrite on channel 2
  493.     ;  always send all notes off mchannel 2
  494.  
  495.             ;mov    dx,offset ch2mess
  496.             ;call    print
  497. ;-----------------------
  498. ;reset all controllers  and notes
  499.  
  500.  
  501.     ;call    ano2
  502.     call    rcc2
  503.     ;call    rcc10        ;reset controllers 10        
  504.     ;call    ano10
  505.     call resetall
  506.     pop     ax
  507. ;-------------------------
  508.     ;   sort fx offset from fx list
  509.     ;    use channel 2
  510.     mov    ch2_pattp,ax
  511.     mov    int_flag,1    ;disable interrupt routine
  512.     mov    ch2_flag,1    ;enable channel 1
  513.     mov    ch2_intc,0    ;reset any interrupt count
  514.     mov    int_flag,0    ;enable interrupt routine
  515.     ret
  516.  
  517. trigger_fx endp
  518.  
  519. ;------------------------------------------------
  520.     ; controller subroutines
  521. rcc2:            ;reset cont. ch2
  522.     mov    al,0B1h
  523.     call     TXLAData
  524.     mov    al,79h
  525.     call    TXLAData
  526.     mov    al,0
  527.     call    TXLAData
  528.     ret
  529.  
  530. ano2:    ;  all notes off two
  531.     mov    al,0B1h        ;all notes off ch2
  532.     call    TxLAData
  533.     mov    al,07Bh    
  534.     call    TxLAData
  535.     ret
  536.  
  537. rcc10:                ;reset all controllers
  538.     mov    al,0B9h
  539.     call     TXLAData
  540.     mov    al,79h
  541.     call    TXLAData
  542.     mov    al,0
  543.     call    TXLAData
  544.     ret
  545.  
  546.  
  547. ano10:    ;  all notes off 10
  548.     mov    al,0B9h        ;all notes off ch10
  549.     call    TxLAData
  550.     mov    al,07Bh    
  551.     call    TxLAData
  552.     mov    al,0
  553.     call    Txladata
  554.     ret
  555.  
  556.  
  557. resetall:
  558.  
  559.     mov al,0B0h
  560. dorlooc:
  561.     push    ax
  562.     call    TxLAData
  563.     mov    al,079h    
  564.     call    TxLAData
  565.     mov    al,0
  566.     call    Txladata
  567.     pop ax
  568.     inc al
  569.     cmp al,0Bah
  570.     jne    dorlooc
  571.  
  572.  
  573.     mov al,0B0h
  574. dorloop:
  575.     push    ax
  576.     call    TxLAData
  577.     mov    al,07Bh    
  578.     call    TxLAData
  579.     mov    al,0
  580.     call    Txladata
  581.     pop ax
  582.     inc al
  583.     cmp al,0Bah
  584.     jne    dorloop
  585.     ret
  586.  
  587.  
  588. ;*************************************************
  589.  
  590. ;   THIS ROUTINE IS CALLED BY THE TIMER INTERRUPT WHEN PLAYING ROLAND FX.
  591.  
  592.  
  593. rol_fx_driver proc near
  594.  
  595.     cmp    int_flag,1    ;fx being set up/miss one
  596.     je    fin_fx_call    
  597.     
  598.     mov    ax,fx_segment
  599.     mov    es,ax
  600.  
  601. ;- - - - - - - - - - - - - - - - - - - - 
  602. ;    THIS SECTION IS CHANNEL SPECIFIC
  603.     ; test for fx playing on channel 1
  604.     
  605.     cmp    ch1_flag,0
  606.     je    ch2        ; should go next chann
  607.             ;   channel 1 playing
  608.  
  609.     mov    run1,1            ;which channel flag
  610.     mov    si,ch1_pattp
  611.     cmp    ch1_intc,0
  612.     jne    ch1_wait
  613.  
  614. ;                          check for end of current fx
  615. next_event_now1:
  616.     mov    al,es:[si]
  617.     cmp    al,255
  618.     je     ch1_off
  619.     call    process_data        ;next event ready to process
  620.     call    getvarlength
  621.     cmp    ax,0
  622.     je    next_event_now1
  623.     mov    ch1_pattp,si    ;store offset
  624.     mov    ch1_intc,ax
  625. ch1_wait:
  626.     mov    ax,ch1_intc
  627.     dec    ax
  628.     mov    ch1_intc,ax
  629. ;**********
  630. ch2:    
  631.     ; test for fx playing on channel 2
  632.     cmp    ch2_flag,0
  633.     je    fin_fx_call    
  634.             ;   channel 2 playing
  635.  
  636.     mov    run1,0        ;which channel 0 =2
  637.     mov    si,ch2_pattp
  638.     cmp    ch2_intc,0
  639.     jne    ch2_wait
  640. ;                          check for end of current fx
  641. next_event_now2:
  642.     mov    al,es:[si]
  643.     cmp    al,255
  644.     je     ch2_off
  645.     call    process_data        ;next event ready to process
  646.     call    getvarlength
  647.     cmp    ax,0
  648.     je    next_event_now2
  649.     mov    ch2_pattp,si    ;store offset
  650.     mov    ch2_intc,ax
  651. ch2_wait:
  652.     mov    ax,ch2_intc
  653.     dec    ax
  654.     mov    ch2_intc,ax
  655.  
  656. ;**********
  657. fin_fx_call:
  658.     mov    ax,1    ;  next delay 
  659.     ret
  660. ;--------------------------------------------
  661. ch1_off:
  662.     call    rcc10
  663.     mov    ch1_flag,0
  664.     jmp    ch2
  665. ch2_off:
  666.     call    rcc2
  667.     mov    ch2_flag,0
  668.     mov ax,[loop_flag]
  669.     cmp ax,1
  670.     jne fin_fx_call
  671.     mov ax,[curr_fx]
  672.     call far ptr trigger_fx
  673.     jmp    fin_fx_call
  674. ;****************************************
  675. process_data:
  676.     ;input    si with event offset pointer
  677.     ;output    ax = no of event delays to next event
  678.     ;first check for end of fx
  679.     call    send_next_event
  680.             ; now store frame delay + pointer    
  681.     ret
  682. ;----------------------------------
  683. send_next_event:
  684.         ;input si holding  current event offset
  685.     mov     al,es:[si]
  686. ;  test for new status byte
  687.     test    al,128    
  688.     jz    old_status
  689.  
  690. ;  only here if new status byte
  691.     cmp    run1,0
  692.     jne    running1
  693.     mov    csb2,al    ;store status+channel for 2
  694.     jmp running2
  695. running1:
  696.     mov    csb1,al    ;store status+channel for 1
  697. running2:
  698.     xor     ah,ah    
  699.     mov     bl,al
  700.     xor    bh,bh
  701.     mov    cl,4
  702.     shr    bx,cl
  703.     mov    cl,MIDIDataSizes[bx]    ;value -1
  704.     inc    cl
  705.     xor     ch,ch
  706.     mov     MIDIDataSiz,cx
  707.     cmp     cx,0
  708.     je    event_fin
  709.     cmp    run1,0
  710.     jne    save_len1
  711.     mov    cel2,cx    ;store event  len
  712.     jmp    output_event
  713. save_len1:
  714.     mov    cel1,cx    ;store event  len
  715.     jmp    output_event    ;new 
  716. ;-------------------------------------
  717. old_status:
  718.     cmp    run1,0
  719.     jne    get1
  720.     mov    al,csb2
  721.     mov    cx,cel2
  722.     jmp    old_event_entry
  723. get1:
  724.     mov    al,csb1
  725.     mov    cx,cel1
  726.     jmp    old_event_entry
  727. ;------------------------------------
  728. output_event:
  729.     mov     al,es:[si]    ;status from file
  730.     inc     si
  731. old_event_entry:
  732.     call TxLAData
  733.     loop    output_event
  734. event_fin:
  735.     ret
  736.  
  737. rol_fx_driver endp
  738. ;***************************************************    
  739. StopMusicR:
  740.     call    StopMIDIPlayLAPC1
  741.     ret
  742. ;play song on AdLib
  743. PlaySAd:
  744.     call    PlaySongAdLib
  745.     ret
  746. ;------------------------------Start endp
  747.  
  748. GetKey proc near
  749.     mov    ah,0    ;do DOS getkey
  750.     int    16h    ;ASCII in al
  751.     ret
  752. GetKey     endp
  753.  
  754. CheckKey proc near
  755.     mov    ah,1    ;do DOS checkkey
  756.     int    16h
  757.     ret
  758. CheckKey endp
  759.  
  760. ;--------------------------------------------------------------------------------
  761. ;LoadSegFile
  762. ;
  763. ;loads a file into a specified segment
  764. ;
  765. ;inputs:
  766. ;
  767. ;ax:    load segment
  768. ;dx:    pointer to filename
  769. ;di:    load offset
  770. ;
  771. ;--------------------------------------------------------------------------------
  772.  
  773. LoadSegFile proc near
  774.     push    ax
  775.     mov    al,0
  776.     mov    ah,3Dh            ;open file
  777.     int    21h
  778.     jc    LSFError
  779.     pop    ds
  780.     jmp    LFOpen
  781. LSFError:
  782.     pop    ax
  783.     ret
  784. LoadSegFile endp
  785.  
  786. LoadFile proc near
  787.     mov    al,0
  788.     mov    ah,3Dh
  789.     int    21h            ;open file
  790.     jnc    LFOpen
  791.     jmp    LFError
  792. LFOpen:
  793.     mov    bx,ax
  794.     mov    cx,0
  795.     mov    dx,0
  796.     mov    ax,4202h
  797.     int    21h
  798.     push    ax         ;find size
  799.     mov    cx,0
  800.     mov    dx,0
  801.     mov    ax,4200h
  802.     int    21h
  803.     pop    cx
  804.  
  805.     push    cx
  806.     mov    dx,di        ;buffer
  807.     push    di
  808.     mov    ah,3Fh
  809.     int    21h
  810.     mov    ah,3Eh
  811.     int    21h           ;close
  812.     pop    di
  813.     pop    bx
  814. LFSafe:
  815.     mov    ax,0
  816.     ret
  817. LFError:
  818.     mov    ax,-1
  819.     ret
  820.  
  821. LoadFile endp
  822.  
  823. ;-----------------------------------------------------------------------------
  824. include roland.asm
  825. ;-----------------------------------------------------------------------------
  826. include adlib.asm
  827. ;-----------------------------------------------------------------------------
  828. include adtimer.asm
  829. ;-----------------------------------------------------------------------------
  830.  
  831. EndCode:
  832.  
  833. cseg    ends
  834.  
  835.     end Start
  836.