home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / QC25-10.ZIP / SAMPLES / DEMO.IN$ / DEMO.bin
Encoding:
Text File  |  1989-04-27  |  4.6 KB  |  160 lines

  1. BUFFER_SIZE    EQU    2048        ; Buffer size in bytes for disk I/O
  2. CR        EQU    13        ; ASCII code for Return
  3. ESCAPE        EQU    27        ; ASCII code for Esc key
  4.  
  5. MDA        EQU    0        ; Adapter constants
  6. CGA        EQU    1
  7. MCGA        EQU    2
  8. EGA        EQU    3
  9. VGA        EQU    4
  10. MONO        EQU    0        ; Display constants
  11. COLOR        EQU    1
  12.  
  13.  
  14. ;* LoadPtr - Macro to load far address into segment:register pair, or
  15. ;* near address into register.
  16. ;*
  17. ;* Params:  sgmnt - Segment to be loaded with segment address
  18. ;*        reg - Register to be loaded with offset address
  19. ;*        ptr - Pointer to address
  20. ;*
  21. ;* Shows:   Instructions - lds       les
  22. ;*        Directives - MACRO       IF         IFIDNI    ELSE      ELSEIF
  23. ;*             ENDIF       .ERR      %OUT    EXITM      ENDM
  24. ;*        Operators - < >      ;;
  25.  
  26. LoadPtr MACRO sgmnt, reg, ptr        ;; Macro definition
  27.     IF @DataSize            ;; If far pointer, and
  28.     IFIDNI <sgmnt>, <ds>        ;;   if 1st argument is DS,
  29.         lds reg, ptr        ;;   load DS:reg with far address
  30.         EXITM
  31.     ENDIF
  32.     IFIDNI <sgmnt>, <es>        ;;   or if 1st argument is ES,
  33.         les reg, ptr        ;;   load ES:reg with far address
  34.         EXITM
  35.     ENDIF
  36.     .ERR                ;; Generate error if not DS or ES
  37.     %OUT 1st macro argument must be DS or ES
  38.  
  39.     ELSE                ;; If near pointer,
  40.     IFIDNI <sgmnt>, <es>        ;;   and if segment is ES,
  41.         push ds            ;;   ensure ES points to
  42.         pop  es            ;;   same segment as DS
  43.     ENDIF
  44.     mov reg, ptr            ;; Then load reg with near address
  45.     ENDIF
  46. ENDM
  47.  
  48.  
  49. ;* GetVidOffset - Macro to determine offset in video segment that corresponds
  50. ;* to given screen coordinates.
  51. ;*
  52. ;* Params:  row - Screen row (top line = 0)
  53. ;*        col - Screen column (leftmost column = 0)
  54.  
  55. GetVidOffset MACRO row, col        ;; Macro definition
  56.     mov ax, row
  57.     mov bl, 80                ;; Number of columns per row *
  58.     mul bl                ;;   current row + current column =
  59.     add ax, col             ;;   character byte #
  60.     shl ax, 1                ;; Double to account for cell size
  61. ENDM                    ;; Result in AX register
  62.  
  63.  
  64. ;* DispText - Macro to display text at given screen coordinates.
  65. ;*
  66. ;* Shows:   Equates - @DataSize     @data
  67. ;*
  68. ;* Params:  row - Screen row (top line = 0)
  69. ;*        col - Screen column (leftmost column = 0)
  70. ;*        str - Pointer to ASCIIZ string
  71.  
  72. DispText MACRO row, col, str        ;; Macro definition
  73.     IF @DataSize            ;; If far pointer required,
  74.     mov ax, @data            ;;   pass data segment
  75.     push ax
  76.     ENDIF
  77.     mov  ax, str            ;; Pointer to ASCIIZ text
  78.     push ax
  79.     mov  ax, col            ;; Screen column
  80.     push ax
  81.     mov  ax, row            ;; Screen row
  82.     push ax
  83.     call StrWrite
  84.     IF @DataSize
  85.     add sp, 8            ;; Clean stack for far data
  86.     ELSE
  87.     add sp, 6            ;; Clean stack for near data
  88.     ENDIF
  89. ENDM
  90.  
  91.  
  92. ;* Vector - Macro to read current interrupt vector, store it, and replace it.
  93. ;*
  94. ;* Shows:   Equates - @CodeSize     @code
  95. ;*
  96. ;* Params:  num - Vector number
  97. ;*        old - Pointer to doubleword for storing old vector
  98. ;*        new - Pointer to new handler
  99.  
  100. Vector MACRO num, old, new        ;; Macro definition
  101.     push ds                ;; Save DS and ES registers
  102.     push es
  103.     mov ah, 35h             ;; AH = DOS function number
  104.     mov al, num             ;; AL = interrupt number
  105.     int 21h                ;; Get Interrupt Vector
  106.     mov WORD PTR old[0], bx        ;; Store it
  107.     mov WORD PTR old[2], es
  108.     IF @CodeSize            ;; If medium or large model,
  109.     lds dx, new            ;;    load DS from parameter
  110.     ELSE
  111.     mov bx, @code            ;; Else ensure DS points to
  112.     mov ds, bx            ;;    to code segment
  113.     mov dx, new            ;; DS:DX equals new vector
  114.     ENDIF
  115.     mov ah, 25h             ;; AH = DOS function number
  116.     int 21h                ;; Set Interrupt Vector
  117.     pop es                ;; Restore ES and DS
  118.     pop ds
  119. ENDM
  120.  
  121.  
  122. ;* Declare structure for disk statistics.
  123. disk_stat    STRUC
  124.   total     DW    ?        ; total clusters
  125.   avail     DW    ?        ; available clusters
  126.   sects     DW    ?        ; sectors per cluster
  127.   bytes     DW    ?        ; bytes per sector
  128. disk_stat    ENDS
  129.  
  130.  
  131. ;* Declare structure for parameter block.
  132. parmblk     STRUC
  133.   env        DW    ?        ; Segment address of environment block
  134.   taddr     DD    WORD PTR ?    ; Segment:offset address of tail
  135.   fcb1        DD    WORD PTR ?    ; Segment:offset address of 1st FCB
  136.   fcb2        DD    WORD PTR ?    ; Segment:offset address of 2nd FCB
  137. parmblk     ENDS
  138.  
  139.  
  140. ;* Declare structure for video configuration.
  141. ;*
  142. ;* Shows:   STRUC    ENDS    COMM
  143.  
  144. vid_config    STRUC
  145.   mode        DB    ?        ; Current mode
  146.   dpage     DB    ?        ; Current display page
  147.   rows        DB    ?        ; Number of display rows - 1
  148.   display    DB    ?        ; Either MONO or COLOR
  149.   adapter    DB    ?        ; Adapter code
  150.   CGAvalue    DB    ?        ; Enable value for CGA
  151.   sgmnt     DW    ?        ; Video segment with page offset
  152. vid_config    ENDS
  153.  
  154.  
  155. ;* Declare communal variables.
  156.  
  157.     COMM    NEAR vconfig:vid_config ; Video configuration structure
  158.     COMM    NEAR _psp:WORD        ; Segment address of Pgm Segment Prefix
  159.     COMM    NEAR _env:WORD        ; Segment address of environment block
  160.