home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / c / pas_sdk1 / pas / subs / video / video.asm < prev   
Encoding:
Assembly Source File  |  1992-06-15  |  23.2 KB  |  1,206 lines

  1. ;$Author:   BCRANE  $
  2. ;$Date:   15 Jun 1992 09:45:32  $
  3. ;$Header:   W:/sccs/video/video.asv   1.0   15 Jun 1992 09:45:32   BCRANE  $
  4. ;$Log:   W:/sccs/video/video.asv  $
  5. ;  
  6. ;     Rev 1.0   15 Jun 1992 09:45:32   BCRANE
  7. ;  Initial revision.
  8. ;$Logfile:   W:/sccs/video/video.asv  $
  9. ;$Modtimes$
  10. ;$Revision:   1.0  $
  11. ;$Workfile:   video.asm  $ 
  12.  
  13.     Title    Video.asm  -- Media Vision simple video routines
  14.     page    64,131
  15.  
  16. ;   /*\
  17. ;   |*|
  18. ;   |*|----=====< Video.asm >====-----
  19. ;   |*|
  20. ;   |*| This module provides video bios services for the caller.
  21. ;   |*|
  22. ;   \*/
  23.  
  24.         .xlist
  25.     include model.inc
  26.     include masm.inc
  27.     .list
  28.  
  29. ;
  30. ;   /*\
  31. ;   |*|----====< _ttyout ( char *, char *,...0 ) >====----
  32. ;   |*|
  33. ;   |*|  This routine writes the text strings out via TTY
  34. ;   |*|
  35. ;   |*|  On Entry:
  36. ;   |*|     int1 is the AND mask
  37. ;   |*|     int2 is the XOR mask
  38. ;   |*|     rect * is rectangle to pop
  39. ;   |*|
  40. ;   |*|  On Exit:
  41. ;   |*|     Nothing
  42. ;   |*|
  43. ;   |*|----====< _videoattr (int1, int2, rect * ) >====----
  44. ;   |*|
  45. ;   |*|  This routine will AND/XOR the contents of the rectangle
  46. ;   |*|
  47. ;   |*|  On Entry:
  48. ;   |*|     int1 is the AND mask
  49. ;   |*|     int2 is the XOR mask
  50. ;   |*|     rect * is rectangle to pop
  51. ;   |*|
  52. ;   |*|  On Exit:
  53. ;   |*|     Nothing
  54. ;   |*|
  55. ;   |*|----====< int _videocard () >====----
  56. ;   |*|
  57. ;   |*|  This routine returns the active adapter type
  58. ;   |*|
  59. ;   |*|  On Entry:
  60. ;   |*|         Nothing
  61. ;   |*|
  62. ;   |*|  On Exit:
  63. ;   |*|     ax = 1=hgc/mono,2=cga,4=ega,8=vga, 0=error
  64. ;   |*|
  65. ;   |*|----====< _videofill (int1, int2, rect * ) >====----
  66. ;   |*|
  67. ;   |*|  This routine will FILL the contents of the rectangle
  68. ;   |*|
  69. ;   |*|  On Entry:
  70. ;   |*|     int1 is the character
  71. ;   |*|     int2 is the attribute
  72. ;   |*|     rect * is rectangle to pop
  73. ;   |*|
  74. ;   |*|  On Exit:
  75. ;   |*|     Nothing
  76. ;   |*|
  77. ;   |*|
  78. ;   |*|----=====< long _videogetcurs () >====-----
  79. ;   |*|
  80. ;   |*| This function returns the cursor position
  81. ;   |*|
  82. ;   |*|   On Exit:
  83. ;   |*|
  84. ;   |*|     DX holds the column position
  85. ;   |*|     AX holds the row    position
  86. ;   |*|
  87. ;   |*|
  88. ;   |*|----=====< void _videosetcurs ( int1, int2 ) >====-----
  89. ;   |*|
  90. ;   |*| This function sets the cursor position
  91. ;   |*|
  92. ;   |*|   On Entry:
  93. ;   |*|
  94. ;   |*|     int1 is the row
  95. ;   |*|     int2 is the column
  96. ;   |*|
  97. ;   |*|
  98. ;   |*|----=====< void _videopage ( int1 ) >====-----
  99. ;   |*|
  100. ;   |*| This function sets the current video page
  101. ;   |*|
  102. ;   |*|   On Entry:
  103. ;   |*|
  104. ;   |*|     int1 is the page #
  105. ;   |*|
  106. ;   |*|
  107. ;   |*|----=====< void _videocshape  ( int1, int2 ) >====-----
  108. ;   |*|
  109. ;   |*| This function sets the cursor shape
  110. ;   |*|
  111. ;   |*|   On Entry:
  112. ;   |*|
  113. ;   |*|     int1 is the starting cursor scan line
  114. ;   |*|     int2 is the ending   cursor scan line
  115. ;   |*|
  116. ;   |*|
  117. ;   |*|----=====< void _videoint     ( &int1, &int2, &int3, &int4 ) >====-----
  118. ;   |*|
  119. ;   |*| This module provides any video bios services for the caller.
  120. ;   |*|
  121. ;   |*|   On Entry:
  122. ;   |*|
  123. ;   |*|     &int1-int4 are pointers to integers for registers AX,BX,CX,DX
  124. ;   |*|
  125. ;   |*|   On Exit:
  126. ;   |*|
  127. ;   |*|     AX,BX,CX,DX returned in &int1-int4 respectively
  128. ;   |*|
  129. ;   |*|----=====< void _zipout ( char * ) >====-----
  130. ;   |*|
  131. ;   |*| This routine writes an ASCIIZ string to the screen at the
  132. ;   |*| current cursor position.
  133. ;   |*|
  134. ;   |*|   On Entry:
  135. ;   |*|
  136. ;   |*|     char * is a pointer to the string
  137. ;   |*|
  138. ;   |*|   On Exit:
  139. ;   |*|
  140. ;   |*|     AX,BX,CX,DX returned in &int1-int4 respectively
  141. ;   |*|
  142. ;   \*/
  143.  
  144.         .data
  145.  
  146. rect    struc
  147.  xmin    dw    0
  148.  ymin    dw    0
  149.  xmax    dw    0
  150.  ymax    dw    0
  151. rect    ends
  152.  
  153. video    struc
  154.  wndr    dw    4 dup (0)    ; screen X,Y
  155.  row    dw    0        ; current cursor row
  156.  col    dw    0        ; current cursor column
  157.  attr    db    0        ; attribute
  158.  wrap    db    0        ; wrap flag
  159.  soff    dw    0        ; current screen offset
  160.  sseg    dw    0        ; current screen segment
  161. video    ends
  162.  
  163. VideoPage    db     0    ; save a copy for speed!
  164. OrigCursShape    dw    -1    ; cursor shape
  165.  
  166. if @datasize
  167.     Extrn    CurWnd:dword    ; pointer to window block
  168. else
  169.     Extrn    CurWnd:word    ; pointer to window block
  170. endif
  171.  
  172. BLACK_bk    equ    000h
  173. BLUE_bk     equ    010h
  174. GREEN_bk    equ    020h
  175. CYAN_bk     equ    030h
  176. RED_bk        equ    040h
  177. PURPLE_bk    equ    050h
  178. BROWN_bk    equ    060h
  179. GREY_bk     equ    070h
  180.  
  181. BLACK_fg    equ    000h
  182. BLUE_fg     equ    001h
  183. GREEN_fg    equ    002h
  184. CYAN_fg     equ    003h
  185. RED_fg        equ    004h
  186. PURPLE_fg    equ    005h
  187. BROWN_fg    equ    006h
  188. GREY_fg     equ    007h
  189. IBLACK_fg    equ    008h
  190. IBLUE_fg    equ    009h
  191. IGREEN_fg    equ    00Ah
  192. ICYAN_fg    equ    00Bh
  193. IRED_fg     equ    00Ch
  194. IPURPLE_fg    equ    00Dh
  195. IBROWN_fg    equ    00Eh
  196. WHITE_fg    equ    00Fh
  197.  
  198. attributetable    label    byte
  199.     db    GREY_fg     ;  0    CYAN_bk +
  200.     db    IGREEN_fg    ;  1    CYAN_bk +
  201.     db    GREY_fg     ;  2    CYAN_bk +
  202.     db    GREY_fg     ;  3    CYAN_bk +
  203.     db    GREY_fg     ;  4    CYAN_bk +
  204.     db    GREY_fg     ;  5    CYAN_bk +
  205.     db    GREY_fg     ;  6    CYAN_bk +
  206.     db    IGREEN_fg    ;  7    CYAN_bk +
  207.     db    GREY_fg     ;  8    CYAN_bk +
  208.     db    GREY_fg     ;  9    CYAN_bk +
  209.     db    GREY_fg     ;  a    CYAN_bk +
  210.     db    GREY_fg     ;  b    CYAN_bk +
  211.     db    GREY_fg     ;  c    CYAN_bk +
  212.     db    GREY_fg     ;  d    CYAN_bk +
  213.     db    GREY_fg     ;  e    CYAN_bk +
  214.     db    GREY_fg     ;  f    CYAN_bk +
  215.  
  216.     db    IGREEN_fg    ; 10    CYAN_bk +
  217.     db    IGREEN_fg    ; 11    CYAN_bk +
  218.     db    GREY_fg     ; 12    CYAN_bk +
  219.     db    GREY_fg     ; 13    CYAN_bk +
  220.     db    GREY_fg     ; 14    CYAN_bk +
  221.     db    GREY_fg     ; 15    CYAN_bk +
  222.     db    GREY_fg     ; 16    CYAN_bk +
  223.     db    GREY_fg     ; 17    CYAN_bk +
  224.     db    GREY_fg     ; 18    CYAN_bk +
  225.     db    GREY_fg     ; 19    CYAN_bk +
  226.     db    0        ; 1a    0
  227.     db    0        ; 1b    0
  228.     db    GREY_fg     ; 1c    CYAN_bk +
  229.     db    GREY_fg     ; 1d    CYAN_bk +
  230.     db    GREY_fg     ; 1e    CYAN_bk +
  231.     db    GREY_fg     ; 1f    CYAN_bk +
  232.  
  233.     db    0        ; 20
  234.     db    BLACK_fg    ; 21    CYAN_bk +
  235.     db    BLACK_fg    ; 22    CYAN_bk +
  236.     db    BLACK_fg    ; 23    CYAN_bk +
  237.     db    BLACK_fg    ; 24    CYAN_bk +
  238.     db    BLACK_fg    ; 25    CYAN_bk +
  239.     db    BLACK_fg    ; 26    CYAN_bk +
  240.     db    BLACK_fg    ; 27    CYAN_bk +
  241.     db    BLACK_fg    ; 28    CYAN_bk +
  242.     db    BLACK_fg    ; 29    CYAN_bk +
  243.     db    BLACK_fg    ; 2a    CYAN_bk +
  244.     db    BLACK_fg    ; 2b    CYAN_bk +
  245.     db    BLACK_fg    ; 2c    CYAN_bk +
  246.     db    BLACK_fg    ; 2d    CYAN_bk +
  247.     db    BLACK_fg    ; 2e    CYAN_bk +
  248.     db    BLACK_fg    ; 2f    CYAN_bk +
  249.  
  250.     db    BLACK_fg    ; 30    CYAN_bk +
  251.     db    BLACK_fg    ; 31    CYAN_bk +
  252.     db    BLACK_fg    ; 32    CYAN_bk +
  253.     db    BLACK_fg    ; 33    CYAN_bk +
  254.     db    BLACK_fg    ; 34    CYAN_bk +
  255.     db    BLACK_fg    ; 35    CYAN_bk +
  256.     db    BLACK_fg    ; 36    CYAN_bk +
  257.     db    BLACK_fg    ; 37    CYAN_bk +
  258.     db    BLACK_fg    ; 38    CYAN_bk +
  259.     db    BLACK_fg    ; 39    CYAN_bk +
  260.     db    BLACK_fg    ; 3a    CYAN_bk +
  261.     db    BLACK_fg    ; 3b    CYAN_bk +
  262.     db    BLACK_fg    ; 3c    CYAN_bk +
  263.     db    BLACK_fg    ; 3d    CYAN_bk +
  264.     db    BLACK_fg    ; 3e    CYAN_bk +
  265.     db    BLACK_fg    ; 3f    CYAN_bk +
  266.  
  267.     db    BLACK_fg    ; 40    CYAN_bk +
  268.     db    BLACK_fg    ; 41    CYAN_bk +
  269.     db    BLACK_fg    ; 42    CYAN_bk +
  270.     db    BLACK_fg    ; 43    CYAN_bk +
  271.     db    BLACK_fg    ; 44    CYAN_bk +
  272.     db    BLACK_fg    ; 45    CYAN_bk +
  273.     db    BLACK_fg    ; 46    CYAN_bk +
  274.     db    BLACK_fg    ; 47    CYAN_bk +
  275.     db    BLACK_fg    ; 48    CYAN_bk +
  276.     db    BLACK_fg    ; 49    CYAN_bk +
  277.     db    BLACK_fg    ; 4a    CYAN_bk +
  278.     db    BLACK_fg    ; 4b    CYAN_bk +
  279.     db    BLACK_fg    ; 4c    CYAN_bk +
  280.     db    BLACK_fg    ; 4d    CYAN_bk +
  281.     db    BLACK_fg    ; 4e    CYAN_bk +
  282.     db    BLACK_fg    ; 4f    CYAN_bk +
  283.  
  284.     db    BLACK_fg    ; 50    CYAN_bk +
  285.     db    BLACK_fg    ; 51    CYAN_bk +
  286.     db    BLACK_fg    ; 52    CYAN_bk +
  287.     db    BLACK_fg    ; 53    CYAN_bk +
  288.     db    BLACK_fg    ; 54    CYAN_bk +
  289.     db    BLACK_fg    ; 55    CYAN_bk +
  290.     db    BLACK_fg    ; 56    CYAN_bk +
  291.     db    BLACK_fg    ; 57    CYAN_bk +
  292.     db    BLACK_fg    ; 58    CYAN_bk +
  293.     db    BLACK_fg    ; 59    CYAN_bk +
  294.     db    BLACK_fg    ; 5a    CYAN_bk +
  295.     db    BLACK_fg    ; 5b    CYAN_bk +
  296.     db    BLACK_fg    ; 5c    CYAN_bk +
  297.     db    BLACK_fg    ; 5d    CYAN_bk +
  298.     db    BLACK_fg    ; 5e    CYAN_bk +
  299.     db    BLACK_fg    ; 5f    CYAN_bk +
  300.  
  301.     db    BLACK_fg    ; 60    CYAN_bk +
  302.     db    BLACK_fg    ; 61    CYAN_bk +
  303.     db    BLACK_fg    ; 62    CYAN_bk +
  304.     db    BLACK_fg    ; 63    CYAN_bk +
  305.     db    BLACK_fg    ; 64    CYAN_bk +
  306.     db    BLACK_fg    ; 65    CYAN_bk +
  307.     db    BLACK_fg    ; 66    CYAN_bk +
  308.     db    BLACK_fg    ; 67    CYAN_bk +
  309.     db    BLACK_fg    ; 68    CYAN_bk +
  310.     db    BLACK_fg    ; 69    CYAN_bk +
  311.     db    BLACK_fg    ; 6a    CYAN_bk +
  312.     db    BLACK_fg    ; 6b    CYAN_bk +
  313.     db    BLACK_fg    ; 6c    CYAN_bk +
  314.     db    BLACK_fg    ; 6d    CYAN_bk +
  315.     db    BLACK_fg    ; 6e    CYAN_bk +
  316.     db    BLACK_fg    ; 6f    CYAN_bk +
  317.  
  318.     db    BLACK_fg    ; 70    CYAN_bk +
  319.     db    BLACK_fg    ; 71    CYAN_bk +
  320.     db    BLACK_fg    ; 72    CYAN_bk +
  321.     db    BLACK_fg    ; 73    CYAN_bk +
  322.     db    BLACK_fg    ; 74    CYAN_bk +
  323.     db    BLACK_fg    ; 75    CYAN_bk +
  324.     db    BLACK_fg    ; 76    CYAN_bk +
  325.     db    BLACK_fg    ; 77    CYAN_bk +
  326.     db    BLACK_fg    ; 78    CYAN_bk +
  327.     db    BLACK_fg    ; 79    CYAN_bk +
  328.     db    BLACK_fg    ; 7a    CYAN_bk +
  329.     db    BLACK_fg    ; 7b    CYAN_bk +
  330.     db    BLACK_fg    ; 7c    CYAN_bk +
  331.     db    BLACK_fg    ; 7d    CYAN_bk +
  332.     db    BLACK_fg    ; 7e    CYAN_bk +
  333.     db    BLACK_fg    ; 7f    CYAN_bk +
  334.  
  335.         .code
  336.  
  337. ;
  338. ;   /*\
  339. ;---|*|----====< BackupVideo ( rect *, char far *, int, int ) >====----
  340. ;---|*|
  341. ;---|*| Back up a rectangle in the current window
  342. ;---|*|
  343. ;---|*| void BackupVideo (rect *r, char far *b, int morex, int morey);
  344. ;---|*| Save the screen contents of rectangle X, plus some...
  345. ;---|*|
  346. ;---|*| Entry Conditions.
  347. ;---|*|     parm1 is a pointer to the rectangle
  348. ;---|*|     parm2 is a far pointer to the target buffer
  349. ;---|*|     parm3 is an int requesting x more rows to be save
  350. ;---|*|     parm4 is an int requesting x more colums to be save
  351. ;---|*|
  352. ;---|*| Exit Conditions:
  353. ;---|*|     nothing
  354. ;---|*|
  355. ;   \*/
  356.     public    BackupVideo
  357. BackupVideo    proc    near
  358.     push    bp
  359.     mov    bp,sp
  360.     push    si
  361.     push    di
  362.     push    ds
  363.     push    es
  364. ;
  365. ; calculate the screen area
  366. ;
  367.     call    calcarea
  368. ;
  369. a00:
  370.     push    cx
  371.     mov    cx,bx
  372.     rep    movsw
  373.     add    si,dx
  374.     pop    cx
  375.     loop    a00
  376.  
  377.     pop    es
  378.     pop    ds
  379.     pop    di
  380.     pop    si
  381.     pop    bp
  382.         ret
  383.  
  384. BackupVideo    endp
  385.  
  386. ;
  387. ;   /*\
  388. ;---|*|----====< calcarea >====----
  389. ;---|*|
  390. ;---|*| calculate the area to be moved
  391. ;---|*| the stack frame is pointed to by bp, as it entered into
  392. ;---|*| the caller's routine.
  393. ;---|*|
  394. ;---|*| Entry Conditions.
  395. ;---|*|     BP points to:
  396. ;---|*|       parm1 is a pointer to the rectangle
  397. ;---|*|       parm2 is a far pointer to the target buffer
  398. ;---|*|       parm3 is an int requesting xxx more rows to be save
  399. ;---|*|       parm4 is an int requesting xxx more colums to be save
  400. ;---|*|
  401. ;---|*| Exit Conditions:
  402. ;---|*|     ES:DI point to the char far * buffer
  403. ;---|*|     DS:SI point to the video screen
  404. ;---|*|     CX holds the # of rows to move
  405. ;---|*|     BX holds the # of columns to save (word count)
  406. ;---|*|     DX holds the # of columns to skip (byte count)
  407. ;---|*|     direction flag is set
  408. ;---|*|
  409. ;   \*/
  410.  
  411. calcarea        proc    near
  412.  
  413.     mov    si,wParm1        ; get the rect *
  414. ;
  415. ; get the number of rows to be saved into cx
  416. ;
  417.     mov    cx,[si.xmax]        ; calculate the # of rows
  418.     mov    ax,[si.xmin]
  419.     sub    cx,ax
  420.     inc    cx
  421.  
  422.     mov    ah,80*2         ; ax holds the offset to the
  423.     mul    ah            ; start of the video buffer
  424.  
  425.     add    cx,wParm4        ; add in any more lines
  426. ;
  427. ; get the number of columns to save in bx, columns to skip in dx
  428. ;
  429.     mov    bx,[si.ymax]        ; calculate the number of colums
  430.     sub    bx,[si.ymin]
  431.     add    ax,[si.ymin]
  432.         add     ax,[si.ymin]
  433.     inc    bx
  434.  
  435.     add    bx,wParm5        ; add in any more columns
  436.  
  437.     mov    dx,80            ; calc the # of columns to skip
  438.     sub    dx,bx            ; bx holds the # of ints to move
  439.     shl    dx,1            ; dx holds the # of characters to skip
  440. ;
  441. ; load the screen segment:offset into ds:si
  442. ;
  443. if @datasize
  444.     les    di,CurWnd        ; get the segment of the window pointer
  445.     mov    ds,es:[di.sseg]
  446. else
  447.     mov    di,CurWnd        ; get the segment of the window pointer
  448.     mov    ds,[di.sseg]
  449. endif
  450.         mov     si,ax                   ; si points to the start
  451. ;
  452. ; get the buffer pointer into es:di
  453. ;
  454.     les    di,wParm2        ; get the buffer pointer
  455.  
  456.     cld                ; make sure we move forward
  457.     ret
  458.  
  459. calcarea    endp
  460.  
  461. ;
  462. ;   /*\
  463. ;---|*|----====< ChangeAttributes ( int, int, int, int ) >====----
  464. ;---|*|
  465. ;---|*| Change some attributes in the rectangle
  466. ;---|*|
  467. ;   \*/
  468.     public    ChangeAttributes
  469. ChangeAttributes proc
  470.     push    bp
  471.     mov    bp,sp
  472.     push    es
  473.     push    di
  474.  
  475. if @datasize
  476.     les    di,[CurWnd]
  477.     mov    es,es:[di.sseg]
  478. else
  479.     mov    di,[CurWnd]
  480.     mov    es,[di.sseg]
  481. endif
  482. ;
  483. chat00:
  484.     mov    cx,wParm4        ; get the ending column
  485.     mov    bx,wParm2        ; get the starting column
  486.     sub    cx,bx            ; cx holds the length
  487.     jb    chat20            ; skip if inverted
  488.  
  489.     inc    cx            ; include the starting columm
  490.  
  491.     mov    di,wParm1        ; get the row #
  492.     cmp    di,wParm3        ; skip out if past the end
  493.     ja    chatdone        ; exit now
  494.  
  495.     mov    ax,80*2
  496.     mul    di
  497.     xchg    ax,di
  498.     add    di,bx
  499.     add    di,bx            ; di points to the end
  500.  
  501.     lea    bx,attributetable    ; get the attribute xlate table
  502.     ;
  503.     chat05:
  504.         mov     al,es:[di]
  505.     test    al,80h
  506.     jnz    chat07
  507.     xlat
  508.     or    al,al
  509.     jz    chat10
  510.     and    bptr es:[di+1],070h
  511.     or    es:[di+1],al
  512.     jmp    short chat10
  513.     ;
  514.     chat07:
  515.     and    bptr es:[di+1],77h
  516.     or    bptr es:[di+1],0Fh
  517.     ;
  518.     chat10:
  519.     inc    di
  520.         inc     di
  521.     loop    chat05            ; go for more
  522. ;
  523. chat20:
  524.     inc    wptr wParm1        ; move down the screen
  525.     jmp    short chat00
  526. ;
  527. chatdone:
  528.     pop    di
  529.     pop    es
  530.     pop    bp
  531.     ret
  532.  
  533. ChangeAttributes endp
  534.  
  535. ;
  536. ;   /*\
  537. ;---|*|----====< RestoreVideo ( rect *, char far *, int, int ) >====----
  538. ;---|*|
  539. ;---|*| void RestoreVideo (rect *r, char far *b, int morex, int morey);
  540. ;---|*|
  541. ;---|*| restore the screen contents of rectangle X, plus some...
  542. ;---|*|
  543. ;---|*| Entry Conditions.
  544. ;---|*|     parm1 is a pointer to the rectangle
  545. ;---|*|     parm2 is a far pointer to the source buffer
  546. ;---|*|     parm3 is an int requesting x more rows to be save
  547. ;---|*|     parm4 is an int requesting x more colums to be save
  548. ;---|*|
  549. ;---|*| Exit Conditions:
  550. ;---|*|     nothing
  551. ;---|*|
  552. ;   \*/
  553.     public    RestoreVideo
  554. RestoreVideo    proc    near
  555.         push    bp
  556.     mov    bp,sp
  557.     push    si
  558.     push    di
  559.     push    ds
  560.     push    es
  561. ;
  562. ; calculate the screen area
  563. ;
  564.     call    calcarea
  565. ;
  566. ; swap the pointers
  567. ;
  568.     push    es
  569.     push    ds
  570.     pop    es
  571.     pop    ds
  572.     xchg    si,di
  573. ;
  574. vr00:
  575. ;
  576. ; move the data back into the video buffer
  577. ;
  578.         push    cx
  579.     mov    cx,bx
  580.     rep    movsw
  581.     add    di,dx
  582.     pop    cx
  583.     loop    vr00
  584. ;
  585. ; all done, return home
  586. ;
  587.     pop    es
  588.     pop    ds
  589.     pop    di
  590.     pop    si
  591.     pop    bp
  592.         ret
  593.  
  594. RestoreVideo    endp
  595.  
  596. ;
  597. ;   /*\
  598. ;---|*|----====< _ttyout ( char *, char *,...0 );
  599. ;---|*|
  600. ;---|*|  This routine writes the text strings out via TTY
  601. ;---|*|
  602. ;---|*|  On Entry:
  603. ;---|*|     int1 is the AND mask
  604. ;---|*|     int2 is the XOR mask
  605. ;---|*|     rect * is rectangle to pop
  606. ;---|*|
  607. ;---|*|  On Exit:
  608. ;---|*|     Nothing
  609. ;---|*|
  610. ;   \*/
  611.     public    _ttyout
  612. _ttyout proc
  613.     push    bp
  614.     mov    bp,sp
  615.     push    ds
  616.     push    si
  617.  
  618.     lea    bp,wParm1        ; bp points to the next string
  619.     mov    bh,VideoPage        ; get the current page
  620.     cld
  621. ;
  622. to_05:
  623. if @datasize
  624.     lds    si,[bp]         ; get the next string
  625.     add    bp,4
  626.     mov    ax,ds
  627.     or    ax,si
  628. else
  629.     mov    si,[bp]         ; get the next string
  630.     add    bp,2
  631.     or    si,si
  632. endif
  633.     jz    to_exit         ; all done, exit home
  634.     mov    ah,0eh
  635. ;
  636. to_10:
  637.     lodsb                ; get the character
  638.     or    al,al
  639.     jz    to_05            ; go get the next string
  640.     int    10h
  641.     jmp    short to_10
  642. ;
  643. to_exit:
  644.     pop    si
  645.     pop    ds
  646.     pop    bp
  647.     ret
  648.  
  649. _ttyout endp
  650.  
  651. ;
  652. ;   /*\
  653. ;---|*|----====< _videoattr (int1, int2, rect * );
  654. ;---|*|
  655. ;---|*|  This routine will AND/XOR the contents of the rectangle
  656. ;---|*|
  657. ;---|*|  On Entry:
  658. ;---|*|     int1 is the AND mask
  659. ;---|*|     int2 is the XOR mask
  660. ;---|*|     rect * is rectangle to pop
  661. ;---|*|
  662. ;---|*|  On Exit:
  663. ;---|*|     Nothing
  664. ;   \*/
  665.  
  666.     public    _videoattr
  667. _videoattr      proc
  668.     push    bp
  669.     mov    bp,sp
  670.     push    ds
  671.         push    es
  672.     push    di
  673.     push    si
  674.  
  675. @psh    equ    (4*2)+2         ; 4 more words stored
  676.  
  677. lRows        equ    wptr [bp-@psh-0] ; # of rows to hit
  678. lCols        equ    wptr [bp-@psh-2] ; # of columns to hit
  679. lPtr        equ    wptr [bp-@psh-4] ; starting address
  680. lNext        equ    wptr [bp-@psh-6] ; offset to next address
  681.     sub    sp,8            ; save some more space
  682.  
  683. if @datasize
  684.     lds    si,wParm3        ; get the rectangle pointer
  685. else
  686.     mov    si,wParm3        ; get the rectangle pointer
  687. endif
  688.  
  689.         mov     ax,[si.xmin]
  690.     mov    dx,[si.xmax]
  691.     sub    dx,ax
  692.     inc    dx            ; bx has max rows
  693.     mov    lRows,dx
  694.  
  695.     mov    bl,80*2
  696.     mul    bl
  697.  
  698.     mov    cx,[si.ymin]
  699.     add    ax,cx
  700.     add    ax,cx            ; ax holds offset to video
  701.     mov    bx,[si.ymax]
  702.     sub    bx,cx
  703.     inc    bx            ; bx has max rows
  704.  
  705.     mov    lCols,bx
  706.  
  707.     cmp    dx,0            ; no rows, bomb out...
  708.     jbe    ViAt_exit
  709.     cmp    bx,0            ; no colums, bomb out...
  710.     jbe    ViAt_exit
  711.  
  712.     sub    bx,80            ; get next ptr count
  713.         neg     bx
  714.     add    bx,bx            ; double
  715.  
  716.     mov    lNext,bx
  717.  
  718. if @datasize
  719.     les    di,[CurWnd]
  720.     mov    es,es:[di.sseg]
  721. else
  722.     mov    di,[CurWnd]
  723.     mov    es,[di.sseg]
  724. endif
  725.  
  726.     mov    di,ax
  727.     inc    di            ; point to attributes
  728.  
  729.     mov    al,bptr wParm1        ; AND mask
  730.     mov    ah,wParm2        ; XOR mask
  731. ;
  732. ViAt_05:
  733.     mov    cx,lCols        ; refresh the column count
  734. ;
  735. ViAt_10:
  736.     and    es:[di],al
  737.     xor    es:[di],ah
  738.     add    di,2
  739.     loop    ViAt_10
  740.     add    di,lNext
  741.     dec    lRows
  742.     jnz    ViAt_05
  743. ;
  744. ; all done, exit home...
  745. ;
  746. ViAt_exit:
  747.     add    sp,8            ; toss out the local storage
  748.         pop     si
  749.         pop     di
  750.     pop    es
  751.     pop    ds
  752.     pop    bp
  753.     ret
  754.  
  755. _videoattr    endp
  756.  
  757. ;
  758. ;   /*\
  759. ;---|*|----====< int _videocard () >====----
  760. ;---|*|
  761. ;---|*|  This routine returns the active adapter type
  762. ;---|*|
  763. ;---|*|  On Entry:
  764. ;---|*|     Nothing
  765. ;---|*|
  766. ;---|*|  On Exit:
  767. ;---|*|     ax = 1=hgc/mono,2=cga,3=ega,4=vga
  768. ;   \*/
  769.     public    _videocard
  770. _videocard    proc            ; was a near here kdn
  771.     mov    ah,0fh            ; check for MONO card being active now
  772.     int    10h
  773.     cmp    al,07h            ; current mono mode?
  774.     mov    ax,1            ; (set just in case)
  775.     jz    vc_exit         ; yes, return it...
  776.  
  777.     mov    ax,1c00h
  778.     mov    cx,7
  779.     int    10h
  780.     cmp    al,1ch            ; VGA?
  781.     mov    al,08            ; (setup just in case)
  782.     jz    vc_exit         ; yes, exit now.
  783.  
  784.     mov    ah,12h            ; check EGA
  785.     mov    bl,10h
  786.     int    10h
  787.     cmp    bl,10h            ; changed? (EGA card?)
  788.     mov    al,04
  789.     jnz    vc_exit         ; yes, exit now
  790.  
  791.     mov    al,02            ; return CGA
  792. ;
  793. vc_exit:
  794.     cbw
  795.     ret
  796.  
  797. _videocard     endp
  798.  
  799. ;
  800. ;   /*\
  801. ;---|*|----====< _videofill (int1, int2, rect * );
  802. ;---|*|
  803. ;---|*|  This routine will fill the contents of the rectangle
  804. ;---|*|
  805. ;---|*|  On Entry:
  806. ;---|*|     int1 is the CHARACTER
  807. ;---|*|     int2 is the ATTRIBUTE
  808. ;---|*|     rect * is rectangle to pop
  809. ;---|*|
  810. ;---|*|  On Exit:
  811. ;---|*|     Nothing
  812. ;   \*/
  813.  
  814.     public    _videofill
  815. _videofill      proc
  816.     push    bp
  817.     mov    bp,sp
  818.     push    ds
  819.         push    es
  820.     push    di
  821.     push    si
  822.  
  823. @psh    equ    (4*2)+2         ; 4 registers stored
  824.  
  825. vfRows        equ    wptr [bp-@psh-0] ; # of rows to hit
  826. vfCols        equ    wptr [bp-@psh-2] ; # of columns to hit
  827. vfPtr        equ    wptr [bp-@psh-4] ; starting address
  828. vfNext        equ    wptr [bp-@psh-6] ; offset to next address
  829.         sub     sp,8                    ; save some more space
  830.  
  831. if @datasize
  832.     lds    si,wParm3        ; get the rectangle pointer
  833. else
  834.     mov    si,wParm3        ; get the rectangle pointer
  835. endif
  836.  
  837.         mov     ax,[si.xmin]
  838.     mov    dx,[si.xmax]
  839.     sub    dx,ax
  840.     inc    dx            ; bx has max rows
  841.     mov    vfRows,dx
  842.  
  843.     mov    bl,80*2
  844.     mul    bl
  845.  
  846.     mov    cx,[si.ymin]
  847.     add    ax,cx
  848.     add    ax,cx            ; ax holds offset to video
  849.     mov    bx,[si.ymax]
  850.     sub    bx,cx
  851.     inc    bx            ; bx has max rows
  852.  
  853.     mov    vfCols,bx
  854.  
  855.     cmp    dx,0            ; no rows, bomb out...
  856.     jbe    ViFi_exit
  857.     cmp    bx,0            ; no colums, bomb out...
  858.     jbe    ViFi_exit
  859.  
  860.     sub    bx,80            ; get next ptr count
  861.     neg    bx
  862.     add    bx,bx            ; double
  863.  
  864.     mov    vfNext,bx
  865.  
  866.  
  867. if @datasize
  868.     les    di,dptr [CurWnd]
  869.     mov    es,es:[di.sseg]
  870. else
  871.     mov    di,[CurWnd]
  872.     mov    es,[di.sseg]
  873. endif
  874.     mov    di,ax
  875.  
  876.     mov    al,wParm1        ; character
  877.     mov    ah,wParm2        ; attribute
  878.     cld
  879. ;
  880. ViFi_05:
  881.     mov    cx,vfCols        ; refresh the column count
  882.     rep    stosw
  883.     add    di,vfNext
  884.     dec    vfRows
  885.     jnz    ViFi_05
  886. ;
  887. ViFi_exit:
  888. ;
  889. ; all done, exit home...
  890. ;
  891.     add    sp,8            ; toss out the local storage
  892.         pop     si
  893.         pop     di
  894.     pop    es
  895.     pop    ds
  896.     pop    bp
  897.     ret
  898.  
  899. _videofill    endp
  900.  
  901. ;
  902. ;   /*\
  903. ;---|*|
  904. ;---|*|----=====< long _videogetcurs () >====-----
  905. ;---|*|
  906. ;---|*| This function returns the cursor position
  907. ;---|*|
  908. ;---|*|   On Exit:
  909. ;---|*|
  910. ;---|*|     DX holds the column position
  911. ;---|*|     AX holds the row    position
  912. ;---|*|
  913. ;---|*|
  914. ;   \*/
  915.     public    _videogetcurs
  916. _videogetcurs    proc
  917.     push    bp
  918.     mov    bp,sp
  919.  
  920.     mov    ah,03h
  921.     mov    bh,VideoPage
  922.     int    10h
  923.  
  924.     sub    ax,ax
  925.     xchg    al,dh
  926.  
  927.     pop    bp
  928.     ret
  929.  
  930. _videogetcurs    endp
  931.  
  932. ;
  933. ;   /*\
  934. ;---|*|
  935. ;---|*|----=====< void _videosetcurs ( int1, int2 ) >====-----
  936. ;---|*|
  937. ;---|*| This function sets the cursor position
  938. ;---|*|
  939. ;---|*|   On Entry:
  940. ;---|*|
  941. ;---|*|     int1 is the row
  942. ;---|*|     int2 is the column
  943. ;---|*|
  944. ;   \*/
  945.     public    _videosetcurs
  946. _videosetcurs    proc
  947.     push    bp
  948.     mov    bp,sp
  949.  
  950.     mov    ah,02h
  951.         mov     bh,VideoPage
  952.     mov    dl,byte ptr wParm2
  953.     mov    dh,byte ptr wParm1
  954.     int    10h
  955.  
  956.     pop    bp
  957.     ret
  958.  
  959. _videosetcurs    endp
  960.  
  961. ;
  962. ;   /*\
  963. ;---|*|
  964. ;---|*|----=====< void _videopage ( int1 ) >====-----
  965. ;---|*|
  966. ;---|*| This function sets the current video page
  967. ;---|*|
  968. ;---|*|   On Entry:
  969. ;---|*|
  970. ;---|*|     int1 is the page #
  971. ;---|*|
  972. ;---|*|
  973. ;   \*/
  974.  
  975.     public    _videopage
  976. _videopage      proc
  977.     push    bp
  978.     mov    bp,sp
  979.  
  980.     mov    ah,05h
  981.     mov    al,byte ptr wParm1
  982.     mov    VideoPage,al
  983.         int     10h
  984.  
  985.     pop    bp
  986.     ret
  987.  
  988. _videopage      endp
  989.  
  990. ;
  991. ;   /*\
  992. ;---|*|
  993. ;---|*|----=====< void _videocshape  ( int1, int2 ) >====-----
  994. ;---|*|
  995. ;---|*| This function sets the cursor shape
  996. ;---|*|
  997. ;---|*|   On Entry:
  998. ;---|*|
  999. ;---|*|     int1 is the starting cursor scan line
  1000. ;---|*|     int2 is the ending   cursor scan line
  1001. ;---|*|
  1002. ;   \*/
  1003.  
  1004.     public    _videocshape
  1005. _videocshape    proc
  1006.     push    bp
  1007.     mov    bp,sp
  1008.  
  1009.     cmp    OrigCursShape,-1    ; is it -1?
  1010.     jnz    vish_found        ; no, already fetched...
  1011.     mov    ah,3            ; yes, get the original shape
  1012.     int    10h
  1013.     mov    OrigCursShape,cx    ; save the new shape
  1014. ;
  1015. vish_found:
  1016.     mov    cl,byte ptr wParm1    ; get the new shape
  1017.     mov    ch,byte ptr wParm2
  1018.     cmp    cx,-1            ; restoration request?
  1019.     jnz    vish_new
  1020.     mov    cx,OrigCursShape    ; yes, use it!
  1021.     cmp    cx,-1            ; oops it was never set
  1022.     jz    vish_done
  1023. ;
  1024. vish_new:
  1025.     mov    ah,01h
  1026.         int     10h
  1027. ;
  1028. vish_done:
  1029.     pop    bp
  1030.     ret
  1031.  
  1032. _videocshape    endp
  1033.  
  1034. ;
  1035. ;   /*\
  1036. ;---|*|
  1037. ;---|*|----=====< void _videoint     ( &int1, &int2, &int3, &int4 ) >====-----
  1038. ;---|*|
  1039. ;---|*| This module provides any video bios services for the caller.
  1040. ;---|*|
  1041. ;---|*|   On Entry:
  1042. ;---|*|
  1043. ;---|*|     &int1-int4 are pointers to integers for registers AX,BX,CX,DX
  1044. ;---|*|
  1045. ;---|*|   On Exit:
  1046. ;---|*|
  1047. ;---|*|     AX,BX,CX,DX returned in &int1-int4 respectively
  1048. ;---|*|
  1049. ;   \*/
  1050. ;
  1051.  
  1052.     public    _videoint
  1053. _videoint       proc
  1054.     push    bp
  1055.     mov    bp,sp
  1056. if @datasize
  1057.     push    es
  1058. endif
  1059.         push    si
  1060.  
  1061. if @datasize
  1062.     les    si,dParm1
  1063.     mov    ax,es:[si]
  1064. else
  1065.     mov    si,wParm1
  1066.     mov    ax,[si]
  1067. endif
  1068.  
  1069. if @datasize
  1070.     les    si,dParm2
  1071.     mov    bx,es:[si]
  1072. else
  1073.     mov    si,wParm2
  1074.     mov    bx,[si]
  1075. endif
  1076.  
  1077. if @datasize
  1078.     les    si,dParm3
  1079.     mov    cx,es:[si]
  1080. else
  1081.     mov    si,wParm3
  1082.     mov    cx,[si]
  1083. endif
  1084.  
  1085. if @datasize
  1086.     les    si,dParm4
  1087.     mov    dx,es:[si]
  1088. else
  1089.     mov    si,wParm4
  1090.     mov    dx,[si]
  1091. endif
  1092.  
  1093.         int     10h
  1094.  
  1095. if @datasize
  1096.     mov    es:[si],dx
  1097. else
  1098.     mov    [si],dx
  1099. endif
  1100. if @datasize
  1101.     les    si,dParm3
  1102.     mov    es:[si],cx
  1103. else
  1104.     mov    si,wParm3
  1105.     mov    [si],cx
  1106. endif
  1107.  
  1108. if @datasize
  1109.     les    si,dParm2
  1110.     mov    es:[si],bx
  1111. else
  1112.     mov    si,wParm2
  1113.     mov    [si],bx
  1114. endif
  1115.  
  1116. if @datasize
  1117.     les    si,dParm1
  1118.     mov    es:[si],ax
  1119. else
  1120.     mov    si,wParm1
  1121.     mov    [si],ax
  1122. endif
  1123.  
  1124.     pop    si
  1125. if @datasize
  1126.         pop     es
  1127. endif
  1128.         pop     bp
  1129.     ret
  1130.  
  1131. _videoint    endp
  1132.  
  1133. ;
  1134. ;   /*\
  1135. ;---|*|----====< _zipout ( char * ) >====----
  1136. ;---|*|
  1137. ;---|*| print the string at the current cursor position
  1138. ;---|*|
  1139. ;   \*/
  1140.  
  1141.     public    _zipout
  1142. _zipout proc                ;was a near here kdn
  1143.     push    bp
  1144.     mov    bp,sp
  1145.     push    ds
  1146.         push    es
  1147.     push    di
  1148.     push    si
  1149. ;
  1150. ; calculate the starting position
  1151. ;
  1152.     sub    bx,bx
  1153.     mov    es,bx
  1154.         mov     ah,0fh                  ; get the page number
  1155.     int    10h
  1156.     xchg    bh,bl            ; bx holds the cursor index
  1157.  
  1158.     mov    bx,es:[0450h]        ; get the x,y
  1159.  
  1160.     mov    di,0b000h        ; mono segment
  1161.     cmp    al,7
  1162.     jz    @F
  1163.     mov    di,0b800h
  1164.    @@:    mov    es,di
  1165.  
  1166.     mov    al,80*2         ; get the column width
  1167.     mul    bh            ; ax = row offset
  1168.     sub    bh,bh
  1169.     shl    bx,1            ; add colume offset
  1170.     add    ax,bx
  1171.  
  1172.     mov    di,ax            ; es:di point to the screen
  1173. ;
  1174. ; load other registers & rip!
  1175. ;
  1176.  
  1177. if @datasize
  1178.     lds    si,wParm1        ; get the next string
  1179. else
  1180.         mov     si,wParm1               ; get the string address
  1181. endif
  1182.  
  1183.     cld
  1184. ;
  1185. _zi05:
  1186.     lodsb                ; get the next character
  1187.     or    al,al
  1188.     jz    _zi10            ; done...
  1189.     stosb
  1190.     inc    di
  1191.     jmp    short _zi05
  1192. ;
  1193. _zi10:
  1194.     pop    si
  1195.     pop    di
  1196.     pop    es
  1197.     pop    ds
  1198.     pop    bp
  1199.     ret
  1200.  
  1201. _zipout endp
  1202.  
  1203.     end
  1204.  
  1205.  
  1206.