home *** CD-ROM | disk | FTP | other *** search
/ Sound Sensations! / sound_sensations.iso / demos / promidi7 / sda_user.arc / SDA_USER.ASM < prev    next >
Assembly Source File  |  1986-12-16  |  6KB  |  351 lines

  1. page
  2. name    SDA_USER_ROUTINES
  3.  
  4. code    segment public 'code'
  5.     assume cs:code,ds:code
  6.  
  7.  
  8. ;******************************************************************
  9. ;*
  10. ;* See companion file 'SDA_USER.DOC' for more information on 
  11. ;* these subroutines.
  12. ;*
  13. ;******************************************************************
  14.  
  15.  
  16.  
  17.  
  18. ;******************************************************************
  19. ;*
  20. ;* This software is intended to provide access to a running
  21. ;* Promidi system from co-resident software which receives
  22. ;* control via INT 16 (function 1).  Two prerequisites are
  23. ;* necessary before the service routines may be called:
  24. ;*  1. The interrupting routine must immediately save the Promid's
  25. ;*     DS register in _SDA_DSEG.
  26. ;*  2. The routine _CHECK4_SDA must be called successfully
  27. ;*     (RET = 1).  This routine binds the two programs together.
  28. ;*
  29. ;* If it is desired to have Promidi continue to read from the disk
  30. ;* (as when playing a file/track), the routine _SDA_EXEC must be
  31. ;* called periodically.
  32. ;*
  33. ;******************************************************************
  34.  
  35.  
  36. ;*************************************************************************
  37. ;*
  38. ;* The source file 'SDA_USER.ASM' is provided free of charge by Systems 
  39. ;* Design Associates, Inc.  SDA does not in any way warranty this software 
  40. ;* nor is it liable for any damages resulting from its use.
  41. ;*
  42. ;*************************************************************************
  43.  
  44.  
  45.  
  46.  
  47.  
  48. PUBLIC    _SDA_DSEG
  49.  
  50.  
  51. _SDA_DSEG    DW    0    ; SDA's Data Segment
  52.                 ; Must be saved by the user upon
  53.                 ;  entrance via INT 16.
  54.  
  55. SDA_SS        DW    0    ; SAVED IN SDAKI BEFORE THE INT 16.
  56. SDA_SP        DW    0
  57. SDA_BP        DW    0
  58. SDA_SI        DW    0
  59. SDA_DI        DW    0
  60.  
  61. USER_SS        DW    0    ; SAVED IN THE USER ROUTINES
  62. USER_DS        DW    0    ;  THAT CALL EXEC.
  63. USER_SP        DW    0
  64. USER_BP        DW    0
  65. USER_DI        DW    0
  66. USER_ES        DW    0
  67.  
  68. IRLOC2        dw    (8 + 2) * 4    ; Interrupt locations.
  69. IRLOC7        dw    (8 + 7) * 4
  70. IRLOC5        dw    (8 + 5) * 4
  71. IRLOC4        dw    (8 + 4) * 4
  72.  
  73.  
  74.  
  75. PUBLIC    _CHECK4_SDA,_SDA_GETB,_SDA_PUTB,_SDA_EXEC,_SDA_RECON
  76. PUBLIC    _SDA_RECOFF
  77. page
  78.  
  79.  
  80.  
  81. ; _CHECK4_SDA
  82. ;
  83. ; *** DANGER *** THIS ROUTINE MUST BE CALLED SUCCESSFULLY (RET = 1)
  84. ;         IN ORDER TO USE ANY OF THE SDA USER FUNCTIONS.
  85. ;
  86. ; If SDA interface (Midicard) interrupt handler is
  87. ;  in place, this routine fills SDA_SEG & SDA_OFST with the
  88. ;  addr. of USER_CALL.
  89. ;
  90. ;    Returns:    ax = 0        Handler not present.
  91. ;            ax = 1        Is present - data filled.
  92. ;
  93. ;    Regs altered - ax,bx,dx
  94.  
  95. _CHECK4_SDA proc far
  96.     push    es
  97.     push    si
  98.     push    bp
  99.  
  100.     mov    si,[IRLOC2]
  101.     call    SDA_MATCH
  102.     cmp    ax,1
  103.     je    GOT_MATCH
  104.  
  105.     mov    si,[IRLOC7]
  106.     call    SDA_MATCH
  107.     cmp    ax,1
  108.     je    GOT_MATCH
  109.  
  110.     mov    si,[IRLOC5]
  111.     call    SDA_MATCH
  112.     cmp    ax,1
  113.     je    GOT_MATCH
  114.  
  115.     mov    si,[IRLOC4]
  116.     call    SDA_MATCH
  117.     cmp    ax,1
  118.     je    GOT_MATCH
  119.  
  120.     xor    ax,ax         ; No match - don't use card.
  121.     jmp    CHKRET
  122.  
  123. GOT_MATCH:
  124.  
  125. ; si = int. vector offset.
  126.  
  127.     xor    ax,ax
  128.     mov    es,ax
  129.  
  130.     mov    ax,es:[si + 2]        ; Get segment of int. rout.
  131.     mov    bx,es:[si]        ; Get offset   "    "
  132.     sub    bx,8            ;  minus 8.
  133.     mov    es,ax
  134.     mov    ax,es:[bx + 2]    ; Get USER_CALL segment
  135.     mov    dx,es:[bx]    ; Get offset.
  136.  
  137.     mov    cs:[SDA_SEG],ax
  138.     mov    cs:[SDA_OFST],dx
  139.  
  140.     mov    ax,1
  141. CHKRET:
  142.     pop    bp
  143.     pop    si
  144.     pop    es
  145.     ret
  146. _CHECK4_SDA endp
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155. ; SDA_MATCH
  156. ;
  157. ; This routine looks for the string "SDA " above the interrupt
  158. ; location indicated by the vector offset in 'si'.
  159. ;
  160. ;    Returns:    ax = 0        No match
  161. ;            ax = 1        Match
  162. ;
  163. ;    Regs altered    ax,bx,es
  164.  
  165. SDA_MATCH proc near
  166.     xor    ax,ax
  167.     mov    es,ax
  168.     mov    bx,si
  169.     mov    ax, word ptr es:[bx] + 2
  170.     mov    bx, word ptr es:[bx]
  171.     mov    es,ax
  172.  
  173.     cmp    byte ptr es:[bx] - 4,'S'
  174.     jne    matret
  175.  
  176.     cmp    byte ptr es:[bx] - 3,'D'
  177.     jne    matret
  178.  
  179.     cmp    byte ptr es:[bx] - 2,'A'
  180.     jne    matret
  181.  
  182.     cmp    byte ptr es:[bx] - 1,' '
  183.     jne    matret
  184.     mov    ax,1
  185. matret:    
  186.     ret
  187. SDA_MATCH endp
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196. ; _SDA_GETB  -  If in sda record mode, get a byte from midi in.
  197. ;
  198. ;  c  call    c = sda_getb();
  199. ;
  200. ;  asm  call    call    _sda_getb    ; Byte or ret. code in ax.  
  201. ;    (far)
  202. ;
  203. ;    RETURNS:    byte
  204. ;            100H        Buffer empty
  205. ;            2nnH        Buffer overflow (byte in LSB).
  206. ;
  207. ;    Regs Altered: ax,bx,cx,dx
  208.  
  209. _SDA_GETB    proc    far
  210.  
  211.     push    si
  212.     mov    si,1
  213.     call    DOUC
  214.     pop    si
  215.     ret
  216. _SDA_GETB    endp
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225. ; _SDA_PUTB  -  send a byte (of a complete midi msg.) out midi out.
  226. ;
  227. ;  c call    sda_putb(c);
  228. ;
  229. ;  asm call    push    ax        ; Push byte on stack
  230. ;   (far)    call    _sda_putb
  231. ;        add    sp,2
  232. ;
  233. ;    Regs Altered: ax,bx,cx,dx
  234.  
  235.  
  236. _SDA_PUTB    proc    far
  237.  
  238.     push    bp
  239.     mov    bp,sp
  240.     push    si
  241.     mov    cx,[bp+6]    ; Get parameter.
  242.     mov    si,2
  243.     call    DOUC
  244.     pop    si
  245.     pop    bp
  246.     ret
  247. _SDA_PUTB    endp
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254. ; _SDA_RECON  -  Go into SDA record mode.
  255. ;
  256. ;  c  call    sda_recon();
  257. ;
  258. ;  asm  call    call    _sda_recon
  259. ;    (far)
  260. ;
  261. ;    Returns:    non-0    No. of bytes allocated to receive buffer.
  262. ;            0    Fail - already recording or 
  263. ;                not enough memory.
  264. ;
  265. ;    Regs Altered: ax,bx,cx,dx
  266.  
  267.  
  268. _SDA_RECON    proc    far
  269.  
  270.     push    si
  271.     mov    si,3
  272.     call    DOUC
  273.     pop    si
  274.     ret
  275. _SDA_RECON    endp
  276.  
  277.  
  278.  
  279.  
  280. ; _SDA_RECOFF  -  Leave SDA record mode.
  281. ;
  282. ;  c  call    sda_recoff();
  283. ;
  284. ;  asm  call    call    _sda_recoff
  285. ;    (far)
  286. ;
  287. ;    Regs Altered: ax,bx,cx,dx
  288.  
  289.  
  290. _SDA_RECOFF    proc    far
  291.  
  292.     push    si
  293.     mov    si,4
  294.     call    DOUC
  295.     pop    si
  296.     ret
  297. _SDA_RECOFF    endp
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305. ; _SDA_EXEC  -  Call Promidi's multi-tasking exec.
  306. ;        This gives Promidi a chance to replenish
  307. ;        its disk buffers when playing.
  308. ;
  309. ;  c  call    sda_exec();
  310. ;
  311. ;  asm  call    call    _sda_exec
  312. ;    (far)
  313. ;
  314. ;    Regs Altered: ax,bx,cx,dx
  315.  
  316.  
  317. _SDA_EXEC    proc    far
  318.  
  319.     push    si
  320.     mov    si,5
  321.     call    DOUC
  322.     pop    si
  323.     ret
  324. _SDA_EXEC    endp
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332. ; The DOUC sub-routine vectors into the Promidi software.
  333. ; The 2-word address must have been set up via a successful
  334. ;  call to _check4_sda.
  335.  
  336. DOUC        proc    near
  337.  
  338.         mov    ax,[_SDA_DSEG]    ; Get the SDA data seg.
  339.         db    9AH
  340. SDA_OFST    dw    0    ; USER_CALL offset.
  341. SDA_SEG        dw    0    ; USER_CALL segment.
  342.         ret
  343. DOUC        endp
  344.  
  345.     code    ends
  346.  
  347.     END
  348.  successfully
  349. ;*     (RET = 1).  This routine binds the two programs together.
  350. ;*
  351. ;* If it is desired to h