home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / VLA_FONT.ZIP / PRINTSUB.INC < prev    next >
Text File  |  1993-09-28  |  5KB  |  254 lines

  1.     ────────────────────────────────────────────────────────────────────
  2.     ;Waits until either Yy or Nn is pressed, returns CF=1 for YES
  3.     ; and CF=0 for NO
  4.     ────────────────────────────────────────────────────────────────────
  5. PROC YesNo
  6.     push    ax
  7.  
  8. @@TopOLoop:
  9.     mov     ah,0
  10.     int     16h
  11.     cmp     al,"Y"
  12.     je      @@Yes
  13.     cmp     al,"y"
  14.     je      @@Yes
  15.     cmp     al,"N"
  16.     je      @@No
  17.     cmp     al,"n"
  18.     je      @@No
  19.     jmp     @@TopOLoop
  20. @@Yes:
  21.     stc
  22.     pop     ax
  23.     ret
  24. @@NO:
  25.     clc
  26.     pop     ax
  27.     ret
  28. ENDP
  29.     ────────────────────────────────────────────────────────────────────
  30.     ;   Prints azero terminating string
  31.     ;
  32.     ; IN: ds:si = source
  33.     ;OUT:    cx = # of char written
  34.     ────────────────────────────────────────────────────────────────────
  35. PROC PrintZ
  36.     push    si dx ax
  37.     cld
  38.     xor     cx,cx
  39. @@TheLoop:
  40.     mov     dl,[si]
  41.     or      dl,dl
  42.     je      @@Done
  43.     mov     ah,2
  44.     int     21h
  45.  
  46.     inc     cx
  47.     inc     si
  48.     jmp     @@TheLoop
  49.  
  50. @@Done:
  51.     pop     ax dx si
  52.     ret
  53. ENDP
  54.  
  55.     ────────────────────────────────────────────────────────────────────
  56.     ; Print a number to memory
  57.     ; does not print leading zeros... prints spaces instead  
  58.     ; & tacks on a zero at the end
  59.     ;
  60.     ;IN: eax = number to print
  61.     ;     cx = number of digits to print (max 11)
  62.     ────────────────────────────────────────────────────────────────────
  63. PROC DEC_Print2Mem NEAR
  64.     push    bp cx eax edx ebx si
  65.     cld
  66.     mov     bp,cx
  67.     
  68.     cld
  69.     xor     si,si
  70.     or      eax,eax
  71.     jns     @@NoPrintSign
  72.     inc     si              ;si not zero means we print a sign
  73.     dec     bp              ;count the sign
  74.     neg     eax
  75. @@NoPrintSign:
  76.  
  77.     mov     cx,11
  78.     mov     ebx,10
  79. @@DLNum:
  80.     xor     edx,edx
  81.     div     ebx
  82.     add     dl,'0'
  83.     push    dx      ;push the result
  84.     loop    @@DLNum
  85.  
  86.     mov     cx,11
  87.     mov     dh,0    ;flag if we hit non-zero yet
  88. @@DLNum2:
  89.     pop     ax
  90.     cmp     cx,bp
  91.     ja      @@DontPrintThisYet
  92.     cmp     al,"0"
  93.     jne     @@NotZero
  94.     or      dh,dh
  95.     jne     @@NotZero
  96.     cmp     cx,1
  97.     je      @@NotZero   ;print last zero if its leading
  98.     mov     al,' '
  99.     jmp     @@PrintIt
  100. @@NotZero:
  101.     inc     dh
  102.     dec     si
  103.     js      @@PrintIt
  104.     mov     [BYTE es:di],"-"
  105.     inc     di
  106. @@Printit:
  107.     stosb
  108. @@DontPrintThisYet:
  109.     loop    @@DLNum2
  110.  
  111.     pop     si ebx edx eax cx bp
  112.     ret
  113. ENDP
  114.     ────────────────────────────────────────────────────────────────────
  115.     ; Print a number to the screen
  116.     ; does not print leading zeros... prints spaces instead
  117.     ;
  118.     ;IN: eax = number to print
  119.     ;     cx = number of digits to print (max 11)
  120.     ────────────────────────────────────────────────────────────────────
  121. PROC DEC_Print NEAR
  122.     push    bp cx eax edx ebx si
  123.     cld
  124.     mov     bp,cx
  125.     
  126.     xor     si,si
  127.     or      eax,eax
  128.     jns     @@PrintSign
  129.     inc     si              ;si not zero means we print a sign
  130.     dec     bp              ;count the sign
  131.     neg     eax
  132. @@PrintSign:
  133.  
  134.     mov     cx,11
  135.     mov     ebx,10
  136. @@DLNum:
  137.     xor     edx,edx
  138.     div     ebx
  139.     add     dl,'0'
  140.     push    dx      ;push the result
  141.     loop    @@DLNum
  142.  
  143.     mov     cx,11
  144.     mov     dh,0    ;flag if we hit non-zero yet
  145. @@DLNum2:
  146.     pop     ax
  147.     cmp     cx,bp
  148.     ja      @@DontPrintThisYet
  149.     cmp     al,"0"
  150.     jne     @@NotZero
  151.     or      dh,dh
  152.     jne     @@NotZero
  153.     cmp     cx,1
  154.     je      @@NotZero   ;print last zero if its leading
  155.     mov     al,' '
  156.     jmp     @@PrintIt
  157. @@NotZero:
  158.     inc     dh
  159.     dec     si
  160.     js      @@PrintIt
  161.     push    ax
  162.     mov     ah,2
  163.     mov     dl,"-"
  164.     int     21h
  165.     pop     ax
  166. @@Printit:
  167.     mov     ah,2
  168.     mov     dl,al
  169.     int     21h
  170. @@DontPrintThisYet:
  171.     loop    @@DLNum2
  172.  
  173.     pop     si ebx edx eax cx bp
  174.     ret
  175. ENDP
  176.     ────────────────────────────────────────────────────────────────────
  177.     ; Prints A HEX number to memory.. 
  178.     ;
  179.     ;IN: es:di = points to start of 8 byte buffer to throw results in
  180.     ;    eax   = number to display
  181.     ;    cx    = # of hex to display MAX 8
  182.     ────────────────────────────────────────────────────────────────────
  183. HexChart    db  "0123456789ABCDEF"
  184.  
  185. PROC Hex_Print2Mem NEAR
  186.         pusha
  187.         cld
  188.         mov     bp,cx
  189.  
  190.         mov     dx,8
  191.         xor     bx,bx
  192. @@PHexLoop:
  193.         mov     bl,al
  194.         and     bl,0fh
  195.         mov     cl,[cs:HexChart+bx]
  196.         push    cx
  197.  
  198.         shr     eax,4
  199.         dec     dx
  200.         jne     @@PhexLoop
  201.  
  202.         mov     cx,8
  203. @@PhexLoop2:
  204.         pop     ax
  205.         cmp     cx,bp
  206.         ja      @@NoPrintHex
  207.         stosb
  208. @@NoPrintHex:
  209.         loop    @@PhexLoop2
  210.         
  211.         popa
  212.         ret
  213. ENDP
  214.     ────────────────────────────────────────────────────────────────────
  215.     ; Prints a HEX number to the screen
  216.     ;
  217.     ;IN:    eax = number to display
  218.     ;       cx  = # of hex to display MAX 8
  219.     ────────────────────────────────────────────────────────────────────
  220. PROC Hex_Print NEAR
  221.         pusha
  222.         push    ds
  223.         cld
  224.         mov     bp,cx
  225.  
  226.         mov     dx,8
  227.         xor     bx,bx
  228. @@PHexLoop:
  229.         mov     bl,al
  230.         and     bl,0fh
  231.         mov     cl,[cs:HexChart + bx]
  232.         push    cx
  233.  
  234.         shr     eax,4
  235.         dec     dx
  236.         jne     @@PhexLoop
  237.  
  238.         mov     cx,8
  239.         mov     ah,2
  240. @@PhexLoop2:
  241.         pop     dx          ;dl = char to print
  242.  
  243.         cmp     cx,bp
  244.         ja      @@NoPrintHex
  245.  
  246.         int     21h
  247. @@NoPrintHex:
  248.         loop    @@PhexLoop2
  249.         
  250.         pop     ds
  251.         popa
  252.         ret
  253. ENDP
  254.