home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 19 / CD_ASCQ_19_010295.iso / vrac / babys203.zip / FORPGMRS.EXE / TDSPCTL.ASM < prev    next >
Assembly Source File  |  1993-01-19  |  7KB  |  196 lines

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ; TDSPCTL - Demonstrates the usage of the DSPCTLx.OBJ's                  ;
  3. ;                                                                        ;
  4. ; (C)opyright - Budget Software Company                                  ;
  5. ;                                                                        ;
  6. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  7.  
  8. MODEL COMPACT
  9. LOCALS
  10. JUMPS
  11.  
  12. global cpp _dspctl_init_me:far
  13. global cpp _dspctl_request_print:far
  14. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  15. ; The following STRUC is passed to _dspctl_init_me
  16. ;
  17. init_dspctl STRUC
  18. original_int8     dd ?
  19. original_int16  dd ?
  20. original_intb    dd ?
  21. original_intc    dd ?
  22. original_intf   dd ?
  23. callback    dd ?
  24. com1_int8_bytes dw ?
  25. com2_int8_bytes dw ?
  26. com3_int8_bytes dw ?
  27. com4_int8_bytes dw ?
  28. lpt1_int8_bytes dw ?
  29. lpt2_int8_bytes dw ?
  30. lpt3_int8_bytes dw ?
  31. lpt4_int8_bytes dw ?
  32. com_port_intb    db ?
  33. com_port_intc    db ?
  34. indicate_bios    db ?
  35. indicate_direct    db ?
  36. nbr_10000ths    dw ?
  37. ENDS
  38. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  39.  
  40. DATASEG
  41.  
  42. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  43. ; Create an instance of my_init_dspclt
  44. ;
  45. my_init_dspctl init_dspctl ?
  46. ;
  47. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  48. ; Define an LPT1 data stream
  49. ;
  50. some_lpt1_data db "Here's some LPT1 data. I am going to print it 50 times.",0dh,0ah
  51. size_of_lpt1_data dw $ - offset some_lpt1_data
  52. number_of_lpt1_lines    db 50
  53. ;
  54. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  55. ; Define a COM1 data stream
  56. ;
  57. some_com1_data db "Here's some COM1 data. I am going to print it 200 times.",0dh,0ah
  58. size_of_com1_data dw $ - offset some_com1_data
  59. number_of_com1_lines    db 200
  60.  
  61.  
  62. CODESEG
  63.     startupcode
  64. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  65. ; Place the required data into my_init_dspctl
  66. ;
  67.     push ds                         ;
  68.     pop es                          ;
  69.     mov ax,0                        ;
  70.     mov ds,ax                       ;
  71.     mov di,offset my_init_dspctl    ;
  72.     mov si,8*4                      ;Get INT8 data.
  73.     mov ax,[si]                     ;
  74.     stosw                           ;
  75.     mov ax,[si+2]                   ;
  76.     stosw                           ;
  77.     mov si,16h*4                    ;Get INT16h data.
  78.     mov ax,[si]                     ;
  79.     stosw                           ;
  80.     mov ax,[si+2]                   ;
  81.     stosw                           ;
  82.     mov ax,0                        ;Don't hook intb, intc, or intf.
  83.     mov cx,6                        ;
  84.     rep stosw                       ;
  85.     mov ax,offset my_callback       ;Pass far pointer to my "callback"
  86.     stosw                           ; procedure.
  87.     mov ax,@code                    ;
  88.     stosw                           ;
  89.     mov ax,100                     ;Set each port so that 100 bytes
  90.     mov cx,8                        ; will be attempted in an int8.
  91.     rep stosw                       ; (Only 1 port gets a crack at it
  92.                     ;  during a given timer interrupt.)
  93.     mov al,2                        ;Indicate intb is for COM2.
  94.     stosb                           ; (This isn't really necessary in
  95.                     ;  this example, since I'm not
  96.                     ;  hooking intb.)
  97.     mov al,1                        ;Indicate intc is for COM1.
  98.     stosb                           ; (This isn't really necessary in
  99.                     ;  this example, since I'm not
  100.                     ;  hooking intc.)
  101.     mov al,0ffh                     ;Indicate that all 8 ports should
  102.     stosb                ;  use the BIOS for outputting.
  103.     mov al,00h                      ;Indicate that no ports should
  104.     stosb                ;  print directly to the port.
  105.     mov ax,10h                      ;Indicate 10  10,000ths of a second
  106.     stosw                ; as the maximum amount of time
  107.                     ; in int8
  108. ;
  109. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  110. ; Call the init routine.
  111. ;
  112.     mov ax,@data                    ;
  113.     mov ds,ax                       ;
  114.     mov dx,@data            ;Point DX:AX to STRUC.
  115.     mov ax,offset my_init_dspctl    ;
  116.     call _dspctl_init_me            ;Init me.
  117. ;
  118. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  119. ; Send a stream of data for LPT1 printing.
  120. ;
  121.     mov cx,size_of_lpt1_data    ;CX=size of stream.
  122.     mov bh,00001000b                ;Bit 3 is for LPT1.
  123.     mov dx,@data                    ;Point DX:AX to stream.
  124.     mov ax,offset some_lpt1_data    ;
  125.     call _dspctl_request_print      ;Call routine.
  126.     dec number_of_lpt1_lines        ;I'm keeping a counter of the
  127.                     ; number of times I've printed
  128.                     ; this stream.
  129. ;
  130. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  131. ; Send a stream of data for COM1 printing.
  132. ;
  133.       mov cx,size_of_com1_data        ;CX=size of stream.
  134.       mov bh,10000000b                ;Bit 7 is for COM1.
  135.       mov dx,@data                    ;Point DX:AX to stream.
  136.       mov ax,offset some_com1_data    ;
  137.       call _dspctl_request_print      ;Call routine.
  138.       dec number_of_com1_lines        ;I'm keeping a counter of the
  139.                     ; number of times I've printed
  140.                     ; this stream.
  141. ;
  142. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  143. ; T and SR
  144. ;
  145.     mov dx,offset end_of_pgm
  146.     shr dx,4
  147.     inc dx
  148.     mov ah,31h
  149.     mov al,0
  150.     int  21h
  151. ;
  152. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  153. ; This procedure is the one I indicated should be
  154. ; called when DSPCTLx has finished printing a stream.
  155. ;
  156. my_callback PROC NOLANGUAGE FAR
  157.     push es ds
  158.     mov ax,@data
  159.     mov ds,ax
  160.     cmp bl,4                        ;BL=4->LPT1 stream is finished.
  161.     jne @@not_lpt1                  ;
  162.     cmp number_of_lpt1_lines,0      ;I'm keeping a counter of the
  163.                     ; number of times I've printed
  164.                     ; this stream.
  165.     je @@not_lpt1                   ;If it's 0, then we're done with LPT1.
  166.     mov cx,size_of_lpt1_data    ;Otherwise, CX=size of stream.
  167.     mov bh,00001000b                ;Bit 3 indicates LPT1.
  168.     mov dx,@data                    ;Point DX:AX to stream.
  169.     mov ax,offset some_lpt1_data    ;
  170.     dec number_of_lpt1_lines        ;Decrement my counter.
  171.     call _dspctl_request_print      ;Request print.
  172.     jmp @@exit                      ;
  173. @@not_lpt1:
  174.     cmp bl,0                        ;BL=0->COM1 stream finished.
  175.     jne @@not_com1                  ;
  176.     cmp number_of_com1_lines,0      ;I'm keeping a counter of the
  177.                     ; number of times I've printed
  178.                     ; this stream.
  179.     je @@not_com1                   ;If it's 0, then we're done with COM1.
  180.     mov cx,size_of_com1_data        ;Otherwise, CX=size of stream.
  181.     mov bh,10000000b                ;Bit 7 indicates COM1.
  182.     mov dx,@data                    ;Point DX:AX to stream.
  183.     mov ax,offset some_com1_data    ;
  184.     dec number_of_com1_lines        ;Decrement my counter.
  185.     call _dspctl_request_print      ;Request print.
  186. @@not_com1:
  187. @@exit:
  188.     pop ds es
  189.     ret
  190. ENDP
  191. end_of_pgm label byte
  192.  
  193.  
  194.  
  195. END
  196.