home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0000 - 0009 / ibm0000-0009 / ibm0003.tar / ibm0003 / TPOWER53.ZIP / TPASM.ARC / TPFAST2.ASM < prev    next >
Encoding:
Assembly Source File  |  1989-07-10  |  10.0 KB  |  368 lines

  1. ;******************************************************
  2. ;           TPFAST2.ASM 5.07
  3. ;        More fast screen writing routines
  4. ;     Copyright (c) TurboPower Software 1987.
  5. ; Portions copyright (c) Sunny Hill Software 1985, 1986
  6. ;     and used under license to    TurboPower Software
  7. ;         All rights reserved.
  8. ;******************************************************
  9.  
  10.     INCLUDE    TPCOMMON.ASM
  11.  
  12. ;******************************************************    Data
  13.  
  14. DATA    SEGMENT    BYTE PUBLIC
  15.  
  16.     ;Pascal    variables
  17.  
  18.     EXTRN    DirectVideo : BYTE        ;If false, use BIOS
  19.     EXTRN    WindMin    : WORD            ;Min. XY coordinates
  20.     EXTRN    WindMax    : WORD            ;Max. XY coordinates
  21.     EXTRN    CurrentPage : BYTE        ;Current video page
  22.     EXTRN    CurrentMode : BYTE        ;Current video mode
  23.     EXTRN    ScreenWidth : BYTE        ;Current width of display
  24.     EXTRN    InTextMode : BYTE        ;False if in graphics mode
  25.     EXTRN    TextAttr : BYTE            ;Current video attribute
  26.     EXTRN    NormalAttr : BYTE        ;Attribute for NormVideo
  27.     EXTRN    CheckSnow : BYTE        ;If true, check    for retrace
  28.     EXTRN    VideoSegment : WORD        ;Segment of Video Memory
  29.     EXTRN    VirtualSegment : WORD        ;Segment of Video Memory--alt
  30.  
  31. DATA    ENDS
  32.  
  33.  
  34. CODE    SEGMENT    BYTE PUBLIC
  35.  
  36.     ASSUME    CS:CODE, DS:DATA
  37.  
  38.     PUBLIC    FastText, FastTextWindow, FastVert, FastVertWindow
  39.     PUBLIC    FastFill, FastFillWindow, FastCenter, FastFlush
  40.     PUBLIC    WriteAttribute,    WriteAttributeWindow
  41.  
  42.     EXTRN    CalcOffset : NEAR        ;in TPFAST.OBJ
  43.     EXTRN    FastWrite : FAR
  44.  
  45.     EXTRN    MapColor : FAR            ;Pascal    routine
  46.  
  47. ;******************************************************    WriteAttributeWindow
  48.  
  49. ;procedure WriteAttributeWindow(St : String; Row, Col :    Byte);
  50. ;Write string of attributes St at window Row,Col without changing characters
  51.  
  52. WriteAttributeWindow    PROC FAR
  53.  
  54.     MOV    SI,1            ;Write attributes
  55.     JMP    SHORT FastTextWindowPrim
  56.  
  57. WriteAttributeWindow    ENDP
  58.  
  59. ;******************************************************    FastTextWindow
  60.  
  61. ;procedure FastTextWindow(St : string; Row, Col    : Byte);
  62. ;Write St at window Row,Col without changing the underlying video attribute.
  63.  
  64. FTCol        EQU    BYTE PTR SS:[BX+4]
  65. FTRow        EQU    BYTE PTR SS:[BX+6]
  66. FTStr        EQU    DWORD PTR SS:[BX+8]
  67.  
  68. FastTextWindow    PROC FAR
  69.  
  70.     SetZero    SI            ;Write characters
  71.  
  72. FastTextWindowPrim:
  73.  
  74.     StackFrame
  75.     MOV    AL,FTRow        ;AL = Row
  76.     ADD    AL,WindMin.YLow        ;Adjust    for current window
  77.     MOV    FTRow,AL        ;Reload    Row
  78.     MOV    AL,FTCol        ;AL = Col
  79.     ADD    AL,WindMin.XLow        ;Adjust    for current window
  80.     MOV    FTCol,AL        ;Reload    Col
  81.     JMP    SHORT FastTextPrim    ;Let FastText do the rest
  82.  
  83. FastTextWindow    ENDP
  84.  
  85. ;******************************************************    WriteAttribute
  86.  
  87. ;procedure WriteAttribute(St : String; Row, Col    : Byte);
  88. ;Write string of attributes St at Row,Col without changing characters
  89.  
  90. WriteAttribute    PROC FAR
  91.  
  92.     MOV    SI,1            ;Write attributes
  93.     JMP    SHORT FastTextPrim
  94.  
  95. WriteAttribute    ENDP
  96.  
  97. ;******************************************************    FastText
  98.  
  99. ;procedure FastText(St : string; Row, Col : Byte);
  100. ;Write St at Row,Col without changing the underlying video attribute.
  101.  
  102. FastText    PROC FAR
  103.  
  104.     SetZero    SI            ;Write characters
  105.  
  106. FastTextPrim:
  107.  
  108.     StackFrame
  109.     PUSH    DS            ;Save DS
  110.     SetZero    AH            ;AH = 0
  111.     MOV    AL,FTRow        ;AX = Row
  112.     SetZero    CH            ;CH = 0
  113.     MOV    CL,FTCol        ;CX = Column
  114.     MOV    DI,CX            ;DI = Column
  115.     CALL    CalcOffset        ;Call routine to calculate offset
  116.     ADD    DI,SI            ;adjust    for attributes if necessary
  117.     GetDSPtr    FTStr        ;DS:SI points to St[0]
  118.     SetZero    CX            ;CX = 0
  119.     LODSB                ;AL = Length(St); DS:SI    -> St[1]
  120.     MOV    CL,AL            ;CX = Length
  121.     JCXZ    FTExit            ;If string empty, exit
  122.     SHR    DL,1            ;If snow checking is off...
  123.     JNC    FTNoWait        ; use FTNoWait routine
  124.     MOV    DX,03DAh        ;Point DX to CGA status    port
  125. FTGetNext:
  126.     LODSB                ;Load next character into AL
  127.                     ; AH already has Attr
  128.     MOV    AH,AL            ;Store char in AH
  129.     WaitForRetrace            ;Wait for an opportunity to write
  130.     MOV    AL,AH            ;Move char back    to AL
  131.     STOSB                ;And then to screen
  132.     STI                ;Allow interrupts
  133.     INC    DI            ;Skip attribute    bytes
  134.     LOOP    FTGetNext        ;Get next character
  135.     JMP    SHORT FTExit        ;Done
  136. FTNoWait:
  137.     MOVSB                ;Move character    to screen
  138.     INC DI                ;Skip attribute    bytes
  139.     LOOP    FTNoWait        ;Get next character
  140. FTExit:
  141.     POP    DS            ;Restore DS
  142.     RET    8
  143.  
  144. FastText    ENDP
  145.  
  146. ;******************************************************    FastFillWindow
  147.  
  148. ;procedure FastFillWindow(Number : word; Ch : Char; Row, Col, Attr : Byte);
  149. ;Write Num Chs using window-relative coordinates
  150.  
  151. FFAttr        EQU    BYTE PTR SS:[BX+4]
  152. FFCol        EQU    BYTE PTR SS:[BX+6]
  153. FFRow        EQU    BYTE PTR SS:[BX+8]
  154. FFCh        EQU    BYTE PTR SS:[BX+10]
  155. FFNumber    EQU    WORD PTR SS:[BX+12]
  156.  
  157. FastFillWindow    PROC FAR
  158.  
  159.     StackFrame
  160.     MOV    AL,FFAttr        ;Load Attribute    into AL
  161.     PUSH    AX            ;PUSH parameter    onto stack
  162.     CALL    MapColor        ;Call color mapping routine
  163.     StackFrame            ;Set up    stack frame again
  164.     MOV    FFAttr,AL        ;Reload    Attr with mapped attribute
  165.     MOV    AL,FFRow        ;AL = Row
  166.     ADD    AL,WindMin.YLow        ;Adjust    for current window
  167.     MOV    FFRow,AL        ;Reload    Row
  168.     MOV    AL,FFCol        ;AL = Col
  169.     ADD    AL,WindMin.XLow        ;Adjust    for current window
  170.     MOV    FFCol,AL        ;Reload    Col
  171.  
  172.     ;Let FastFill do the rest
  173.  
  174. FastFillWindow    ENDP
  175.  
  176. ;******************************************************    FastFill
  177.  
  178. ;procedure FastFill(Number : word; Ch :    Char; Row, Col,    Attr : Byte);
  179. ;Write Num Chs at Row,Col in Attr (video attribute) without snow
  180.  
  181. FastFill    PROC FAR
  182.  
  183.     StackFrame
  184.     PUSH    DS            ;Save DS
  185.     SetZero    AH            ;AH = 0
  186.     MOV    AL,FFRow        ;AX = Row
  187.     SetZero    CH            ;CH = 0
  188.     MOV    CL,FFCol        ;CX = Column
  189.     MOV    DI,CX            ;DI = Column
  190.     CALL    CalcOffset        ;Call routine to calculate offset
  191.     MOV    CX,FFNumber        ;CX = Number to    write
  192.     JCXZ    FFExit            ;If zero, exit
  193.     MOV    AH,FFAttr        ;AH = Attribute
  194.     MOV    AL,FFCh            ;AL = Char
  195.     SHR    DL,1            ;If snow checking is off...
  196.     JNC    FFNoWait        ; use FFNoWait routine
  197.     MOV    DX,03DAh        ;Point DX to CGA status    port
  198.     MOV    BX,AX            ;Store video word in BX
  199. FFGetNext:
  200.     WaitForRetrace            ;Wait for an opportunity to write
  201.     WordToCGA    BX        ;Move the word
  202.     LOOP    FFGetNext        ;Get next character
  203.     JMP    SHORT FFExit        ;Done
  204. FFNoWait:
  205.     STOSW                ;Move video word into place
  206.     LOOP    FFNoWait        ;Get next character
  207. FFExit:
  208.     POP    DS            ;Restore DS
  209.     RET    10
  210.  
  211. FastFill    ENDP
  212.  
  213. ;******************************************************    FastCenter
  214.  
  215. ;procedure FastCenter(St : String; Row,    Attr : Byte);
  216. ;Write St centered on window Row in Attr (video    attribute) without snow
  217.  
  218. FCAttr        EQU    BYTE PTR SS:[BX+4]
  219. FCRow        EQU    BYTE PTR SS:[BX+6]
  220. FCSt        EQU    DWORD PTR SS:[BX+8]
  221.  
  222. FastCenter    PROC FAR
  223.  
  224.     StackFrame
  225.     GetPtr    FCSt            ;ES:DI points to St
  226.     SetZero    DH            ;DX = (Length /    2)
  227.     MOV    DL,ES:[DI]
  228.     SHR    DX,1
  229.     SetZero    AH            ;AX = Succ(LeftEdge+RightEdge)/2
  230.     MOV    AL,WindMin.XLow
  231.     ADD    AL,WindMax.XHigh
  232.     INC    AX
  233.     SHR    AX,1
  234.     SUB    AX,DX            ;AX has    column for St
  235.     INC    AX            ;convert to 1-base
  236.  
  237.     ;now set up the    stack the way FastWrite    wants it
  238.  
  239.     POP    CX            ;get the return    address    into DX:CX
  240.     POP    DX
  241.     POP    DI            ;get the attribute into    DI
  242.     POP    BX            ;get the row into BX
  243.     ADD    BL,WindMin.YLow        ;adjust    the row    and put    it back
  244.     PUSH    BX
  245.     PUSH    AX            ;push the column for St
  246.     PUSH    DI            ;put back the attribute    and return addr
  247.     PUSH    DX
  248.     PUSH    CX
  249.     JMP    FastWrite        ;let FastWrite do the rest
  250.  
  251. FastCenter    ENDP
  252.  
  253. ;******************************************************    FastFlush
  254.  
  255. ;procedure FastFlush(St    : String; Row, Attr : Byte);
  256. ;Write St flush    right on window    Row in Attr (video attribute) without snow
  257.  
  258. FastFlush    PROC FAR
  259.  
  260.     StackFrame
  261.     GetPtr    FCSt            ;ES:DI points to St
  262.     SetZero    DH            ;DX = Length(St)
  263.     MOV    DL,ES:[DI]
  264.     SetZero    AH
  265.     MOV    AL,WindMax.XHigh
  266.     INC    AX            ;convert to 1-base
  267.     SUB    AX,DX            ;AX will have column for St
  268.     INC    AX
  269.  
  270.     ;now set up the    stack the way FastWrite    wants it
  271.  
  272.     POP    CX            ;get the return    address    into DX:CX
  273.     POP    DX
  274.     POP    DI            ;get the attribute into    DI
  275.     POP    BX            ;get the row into BX
  276.     ADD    BL,WindMin.YLow        ;adjust    the row    and put    it back
  277.     PUSH    BX
  278.     PUSH    AX            ;push the column for St
  279.     PUSH    DI            ;put back the attribute    and return addr
  280.     PUSH    DX
  281.     PUSH    CX
  282.     JMP    FastWrite        ;let FastWrite do the rest
  283.  
  284. FastFlush    ENDP
  285.  
  286. ;******************************************************    FastVertWindow
  287.  
  288. ;procedure FastVertWindow(S : string; Row, Col,    Attr : Byte);
  289. ;Write a string    vertically using window-relative coordinates.
  290.  
  291. FVAttr        EQU    BYTE PTR SS:[BX+4]
  292. FVCol        EQU    BYTE PTR SS:[BX+6]
  293. FVRow        EQU    BYTE PTR SS:[BX+8]
  294. FVSt        EQU    DWORD PTR SS:[BX+10]
  295.  
  296. FastVertWindow    PROC FAR
  297.  
  298.     StackFrame
  299.     MOV    AL,FVAttr        ;Load Attribute    into AL
  300.     PUSH    AX            ;PUSH parameter    onto stack
  301.     CALL    MapColor        ;Call color mapping routine
  302.     StackFrame            ;Set up    stack frame again
  303.     MOV    FVAttr,AL        ;Reload    Attr with mapped attribute
  304.     MOV    AL,FVRow        ;AL = Row
  305.     ADD    AL,WindMin.YLow        ;Adjust    for current window
  306.     MOV    FVRow,AL        ;Reload    Row
  307.     MOV    AL,FVCol        ;AL = Col
  308.     ADD    AL,WindMin.XLow        ;Adjust    for current window
  309.     MOV    FVCol,AL        ;Reload    Col
  310.  
  311.     ;Let FastVert do the rest
  312.  
  313. FastVertWindow    ENDP
  314.  
  315. ;******************************************************    FastVert
  316.  
  317. ;procedure FastVert(St : String; Row, Col, Attr    : Byte);
  318. ;Write St vertically at    Row,Col    in Attr    (video attribute)
  319.  
  320. FastVert      PROC FAR
  321.  
  322.     StackFrame
  323.     PUSH    DS            ;Save DS
  324.     PUSH    BP            ;Save BP
  325.     SetZero    AH            ;AH = 0
  326.     MOV    AL,FVRow        ;AX = Row
  327.     SetZero    CH            ;CH = 0
  328.     MOV    CL,FVCol        ;CX = Column
  329.     MOV    DI,CX            ;DI = Column
  330.     CALL    CalcOffset        ;Call routine to calculate offset
  331.     MOV    BP,WP ScreenWidth    ;BP = 2*(ScreenWidth-1)
  332.     DEC    BP
  333.     SHL    BP,1
  334.     GetDSPtr FVSt            ;DS:SI points to St[0]
  335.     LODSB                ;AL = Length(St); DS:SI    -> St[1]
  336.     SetZero    CH            ;CH = 0
  337.     MOV    CL,AL            ;CX = Length
  338.     JCXZ    FVExit            ;If string empty, exit
  339.     MOV    AH,FVAttr        ;AH = Attribute
  340.     SHR    DL,1            ;If snow checking is off...
  341.     JNC    FVNoWait        ; use FVNoWait routine
  342.     MOV    DX,03DAh        ;Point DX to CGA status    port
  343. FVGetNext:
  344.     LODSB                ;Load next character into AL
  345.                     ; AH already has Attr
  346.     MOV    BX,AX            ;Store video word in BX
  347.     WaitForRetrace            ;Wait for an opportunity to write
  348.     WordToCGA    BX        ;Move the word
  349.     ADD    DI,BP            ;Next row
  350.     LOOP    FVGetNext        ;Get next character
  351.     JMP    SHORT FVExit        ;Done
  352. FVNoWait:
  353.     LODSB                ;Load next character into AL
  354.                     ; AH already has Attr
  355.     STOSW                ;Move video word into place
  356.     ADD    DI,BP            ;Next row
  357.     LOOP    FVNoWait        ;Get next character
  358. FVExit:
  359.     POP    BP            ;Restore regs
  360.     POP    DS
  361.     RET    10
  362.  
  363. FastVert    ENDP
  364.  
  365. CODE    ENDS
  366.  
  367.     END
  368.