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