home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / CRT4.ASM < prev    next >
Assembly Source File  |  1994-10-15  |  6KB  |  212 lines

  1.     page    66,132
  2. ;******************************** CRT4.ASM   *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     INCLUDE  COMMON.INC
  11. .list
  12. ;----------------------------------------------------------------------------
  13.     EXTRN    PUT_CRT_CHR:FAR
  14.     EXTRN    REPEAT_PUT_CRT:FAR
  15.     EXTRN    POSN_TO_ADR:NEAR
  16.     EXTRN    ADR_TO_POSN:NEAR
  17.     EXTRN    $PUT_CRT_BLK:NEAR
  18.     EXTRN    $REPEAT_PUT_CRT:NEAR
  19.     EXTRN    LIB_INFO:BYTE
  20. comment 
  21. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  22. CLEAR_SCREEN - fill screen with specified character and color
  23. ;
  24. ; inputs:    AH = color attribute
  25. ;            AL = fill character
  26. ;            
  27. ; output:    nothing
  28. ;
  29. ;* * * * * * * * * * * * * *
  30. 
  31.     PUBLIC    CLEAR_SCREEN
  32. CLEAR_SCREEN     PROC    FAR
  33.     APUSH   BX,CX,DX,DI,SI,ES,AX
  34.     mov     es,cs:lib_info.crt_seg
  35.     mov     di,0            ;page 0 offset
  36.     mov     al,lib_info.crt_rows
  37.     mul     lib_info.crt_columns
  38.     mov     cx,ax            ;put move count into -cx-
  39.     POP     AX
  40.     CALL    $REPEAT_PUT_CRT         ;put char to screen (es:di) cx times
  41.     APOP    ES,SI,DI,DX,CX,BX
  42.     RETF
  43. CLEAR_SCREEN    ENDP
  44. comment 
  45. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  46. DISPLAY_STRING - print string directly to video buffer.
  47. ;
  48. ; inputs: DS:[SI] = pointer to the string
  49. ;            DH = screen row, DL = screen column
  50. ;            AH = color attribute
  51. ;            
  52. ; output:    nothing
  53. ;
  54. ; notes:  String must be terminated by a NUL character.
  55. ;         cr/lf characters are handled & wrap to original column.
  56. ;
  57. ;* * * * * * * * * * * * * *
  58. 
  59.     PUBLIC    DISPLAY_STRING
  60. DISPLAY_STRING    PROC    FAR
  61.     push    bp
  62.     mov     bp,sp
  63.     APUSH   AX,BX,CX,DX,DI,SI
  64.     PUSHF
  65.     APUSH   ES
  66.     call    posn_to_adr
  67.  
  68. TP_LP1:
  69.     LODSB
  70.     OR      AL,AL
  71.     JZ      TP_DONE
  72.     CMP     AL,0dh
  73.     jbe     tp_special        ;jmp if possible cr/lf
  74. tp_out:    
  75.     STOSW
  76.     JMP    TP_LP1
  77. tp_special:
  78.     je      tp_return        ;jmp if carriage return (0dh)
  79.     cmp     al,0ah
  80.     je      tp_feed        ;jmp if line feed (0ah)
  81.     jmp     tp_out
  82. tp_return:
  83.     call    adr_to_posn
  84.     mov     dl,BYTE PTR [BP-8]    ;set origional column, -dl-
  85.     call    posn_to_adr
  86.     jmp     tp_lp1
  87. tp_feed:
  88.     call    adr_to_posn
  89.     inc     dh            ;move to next row
  90.     call    posn_to_adr
  91.     jmp     tp_lp1        
  92. ;
  93. TP_DONE:
  94.     POP     ES
  95.     POPF
  96.     APOP    SI,DI,DX,CX,BX,AX,BP
  97.     RETF
  98. DISPLAY_STRING    ENDP
  99. comment 
  100. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  101. DISPLAY_STRING_FILL - display string to screen at specified position.
  102. ;
  103. ; inputs:   DS:[SI] = pointer to the string
  104. ;            cx = maximum length of display line including fill at end
  105. ;            DH = screen row, DL = screen column
  106. ;            AH = color attribute
  107. ;            
  108. ;  output:   nothing
  109. ;  
  110. ;  notes:   If string is shorter than the display line length (cx), then
  111. ;           the remainder of the line is cleared.
  112. ;
  113. ;* * * * * * * * * * * * * *
  114. 
  115.     PUBLIC    DISPLAY_STRING_FILL
  116. DISPLAY_STRING_FILL    PROC     FAR
  117.     push    bp
  118.     mov     bp,sp
  119.     APUSH   AX,BX,CX,DX,DI,SI,ES
  120.     call    posn_to_adr
  121. TPC_LP1:
  122.     LODSB
  123.     OR      AL,AL
  124.     JZ      TPC_DONE
  125.     CMP     AL,0dh
  126.     jbe     tpC_special        ;jmp if possible cr/lf
  127. tpC_out:    
  128.     STOSW
  129.     loop   TPC_LP1
  130.     jmp    tpc_done2
  131. tpC_special:
  132.     je      tpC_return        ;jmp if carriage return (0dh)
  133.     cmp     al,0ah
  134.     je      tpC_feed        ;jmp if line feed (0ah)
  135.     jmp     tpC_out
  136. tpC_return:
  137.     call    adr_to_posn
  138.     call    fill_to_end
  139. tpc_return2:
  140.     mov     dl,byte ptr [bp-7]    ;restore origional column
  141.     mov     cx,word ptr [bp-6]    ;restore origional -cx-
  142.     call    posn_to_adr
  143.     jmp     tpC_lp1
  144. tpC_feed:
  145.     call    adr_to_posn
  146.     inc     dh            ;move to next row
  147.     call    posn_to_adr
  148.     jmp     tpC_lp1        
  149. ;
  150. TPC_DONE:
  151.     call    adr_to_posn
  152.     call    fill_to_end
  153. tpc_done2:
  154.     APOP    ES,SI,DI,DX,CX,BX,AX,bp
  155.     RETF
  156. DISPLAY_STRING_FILL    ENDP
  157. ;------------------------
  158. ; fill display from present address to right edge
  159. ;   inputs:  dx=row/column
  160. ;            ax=last display char.
  161. ;            cx=maximum display length
  162. ;  output:  all registers returned unchanged
  163. ;
  164. fill_to_end:
  165.     apush    ax,dx
  166.     mov    al,' '
  167. fte_loop:    
  168.     cmp    dl,lib_info.crt_columns
  169.     je    fte_exit
  170.     call    put_crt_chr
  171.     inc    dl
  172.     loop    fte_loop
  173. fte_exit:
  174.     apop    dx,ax    
  175.     ret
  176. comment 
  177. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -( DISPLAY )
  178. DISPLAY_STRING_LIST -  display a list of strings
  179. ;
  180.  
  181. ; inputs:  ds:bx points at table of offsets
  182. ;          ah= color
  183. ;
  184. ; output: none
  185. ;
  186. ; notes:  ds:bx points to a table of pointers.  The end of the table
  187. ;         is indicated by setting an entry to -1.  Each table entry
  188. ;         points to an asciiz string.
  189. ;* * * * * * * * * * * * * *
  190. 
  191.     PUBLIC    DISPLAY_STRING_LIST
  192. DISPLAY_STRING_LIST    PROC    FAR
  193.     apush   ax,bx,cx,dx,si,di,es
  194. dsl_loop:    
  195.     mov    si,word ptr ds:[bx]        ;get string ptr
  196.     mov    dx,word ptr ds:[si]        ;get row/col
  197.     add    si,2                ;move to start of string
  198.     call    posn_to_adr
  199.     xor    cx,cx                ;set max sting len
  200.     call    $put_crt_blk    
  201.     add    bx,2                ;move to next string
  202.     cmp    word ptr ds:[bx],-1
  203.     jne    dsl_loop                   ;jmp if more strings
  204.     apop    es,di,si,dx,cx,bx,ax
  205.     retf
  206. DISPLAY_STRING_LIST    ENDP
  207.  
  208.  
  209.  
  210. LIBSEG    ENDS
  211.     end
  212.