home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0020 - 0029 / ibm0020-0029 / ibm0028.tar / ibm0028 / GRLF-C-2.ZIP / GFUNC / FVIDEO.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-05-30  |  33.7 KB  |  1,511 lines

  1.         page    58,132
  2. ;/*
  3. ;** fvideo.asm
  4. ;** contains: setfdrvr(),fgetchat(),fwstr(),frwstr(),fatwstr(),fratwstr(),
  5. ;**          fatwch(),getscrn(),putscrn()
  6. ;*/
  7.  
  8.         ifndef    _LCODE
  9.          include model.h
  10.         endif
  11.         include prologue.h
  12.         name    fastvideo
  13.  
  14. CGAGRSTATUS    equ    03dah            ;CGA status register
  15. CGAREGENSEG    equ    0b800h            ;Segment of CGA regen buffer
  16. MDAREGENSEG    equ    0b000h            ;Segment of Monochrome regen buffer
  17.  
  18. BIOSVIDEO    equ    010h            ;Rom Bios Video Interrupt #
  19. GETCURSPOS    equ    03h            ;Rom Bios Get cursor position
  20. SETCURSPOS    equ    02h            ;Rom Bios Set cursor position
  21. GETCURVIDMODE    equ    15            ;Rom Bios Get current video mode
  22.  
  23.  
  24.         ;CRTWAIT:  Assume: DX=0x3da
  25.         ;       Uses AL register
  26.         ; Waits for Horizontal sync pulse as read from
  27.         ; status register.
  28.         ;
  29.         CRTWAIT macro
  30.         local    looph3,looph4
  31.         cli
  32. looph3:     in    al,dx
  33.         rcr    al,1
  34.         jb    looph3            ;;wait till not in again
  35. looph4:     in    al,dx
  36.         rcr    al,1
  37.         jnb    looph4            ;;wait till in horizontal again
  38.         endm
  39.  
  40.  
  41.         dseg    dfastvideo
  42.  
  43. disptable    dw    offset trapstub1    ;CGA write string at specified cursor
  44.         dw    offset trapstub2    ;CGA write string & attribute at specified cursor
  45.         dw    offset trapstub3    ;CGA read character & attribute at specified cursor
  46.         dw    offset trapstub4    ;CGA write character & attribute
  47.         dw    offset trapstub5    ;CGA get region
  48.         dw    offset trapstub6    ;CGA put region
  49.  
  50. tablesize    equ ($-disptable)/2
  51.  
  52.  
  53. ;==>--    Low level routines for Monochrome Display Adapter (MDA)
  54. ;
  55. montbl        dw    offset mwsacur        ;mono write string at specified cursor
  56.         dw    offset mwsaaccur    ;mono write string & attribute at specified cursor
  57.         dw    offset mrchatatcur    ;mono read character & attribute at specified cursor
  58.         dw    offset mwachat        ;mono write character & attribute at specified cursor
  59.         dw    offset mdgetregion    ;mono get region to buffer
  60.         dw    offset mdputregion    ;mono put buffer to region
  61.  
  62. ;==>--    Low level routines for Color Graphics Adapter (CGA) with horizontal
  63. ;    retrace checking to eliminate snow.
  64. ;
  65. cgartbl     dw    offset cgracur        ;CGA write string at specified cursor
  66.         dw    offset cgraaccur    ;CGA write string & attribute at specified cursor
  67.         dw    offset cgrrchatatcur    ;CGA read character & attribute at specified cursor
  68.         dw    offset cgrachat     ;CGA write character & attribute
  69.         dw    offset cgrgetregion    ;CGA get region
  70.         dw    offset cgrputregion    ;CGA put region
  71.  
  72. ;==>--    Low level routines for Color Graphics Adapter (CGA) without horizontal
  73. ;    retrace checking to eliminate snow.  Faster than cgartbl routines and
  74. ;    acceptable on EGA & VGA and other adapters that do not have the snow
  75. ;    problem.
  76. ;
  77. cgatbl        dw    offset cgacur        ;CGA write string at specified cursor
  78.         dw    offset cgaaaccur    ;CGA write string & attribute at specified cursor
  79.         dw    offset cgrchatatcur    ;CGA read character & attribute at specified cursor
  80.         dw    offset cgawchat     ;CGA write character & attribute
  81.         dw    offset cggetregion    ;CGA get region
  82.         dw    offset cgputregion    ;CGA put region
  83.  
  84.  
  85.         endds
  86.  
  87.  
  88.         pseg    cfastvideo
  89.  
  90.         subttl    [C functions]
  91.         page
  92.  
  93.  
  94. ;/*
  95. ;**  void
  96. ;** setfdrvr(int driverid)
  97. ;**
  98. ;** ARGUMENT(s)
  99. ;**  driverid        -    i.d. of driver to set:
  100. ;**                0 =  monochrome driver
  101. ;**                1 =  CGA driver without retrace checking
  102. ;**                2 =  CGA driver with retrace checking
  103. ;**
  104. ;**            -    -1 = do automatic "best guess" setup.
  105. ;**
  106. ;**
  107. ;** DESCRIPTION
  108. ;**  Permits user program to determine which of the low level drivers will
  109. ;**  be used with the fast video functions.  Calling this function is not
  110. ;**  normally necessary.
  111. ;**
  112. ;** RETURNS
  113. ;**  void.
  114. ;**
  115. ;** AUTHOR
  116. ;**  ""   Thu 08-Dec-1988    15:02:21
  117. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  118. ;**
  119. ;** MODIFICATIONS
  120. ;**
  121. ;*/
  122.         cproc    setfdrvr
  123.         mov    dx,parm1_        ;dx = option
  124.         cmp    dx,0ffffh        ;auto requested?
  125.         jnz    setman            ;if not use parameter
  126.         call    autosetup        ;else do auto setup
  127.         jmp    short setexit
  128. setman:     call    setdriver
  129. setexit:
  130.         cproce
  131.  
  132.  
  133.  
  134.  
  135.  
  136. ;/*
  137. ;**  unsigned 
  138. ;** fgetchat(int row,int col)
  139. ;**
  140. ;** ARGUMENT(s)
  141. ;**  row        -        Row to read
  142. ;**  col        -        Column to read
  143. ;**
  144. ;** DESCRIPTION
  145. ;**  Returns the character and attribute at the specified row/column.
  146. ;**
  147. ;**
  148. ;** RETURNS
  149. ;**  The Character is returned in the lower 8 bits of the 16 bit value, the
  150. ;**  attribute is returned in the upper 8 bits of the 16 bit value.
  151. ;**
  152. ;** AUTHOR
  153. ;**  ""   Thu 08-Dec-1988    10:12:13
  154. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  155. ;**
  156. ;** MODIFICATIONS
  157. ;**
  158. ;*/
  159.         cproc    fgetchat
  160.         mov    al,parm1_
  161.         mov    cl,parm2_
  162.         call    disptable+4
  163.         cproce
  164.  
  165.  
  166. ;/*
  167. ;**  void
  168. ;** fwstr(char *string)
  169. ;**
  170. ;** ARGUMENT(s)
  171. ;**  string        -    points to null terminated string to write
  172. ;**
  173. ;** DESCRIPTION
  174. ;**  Writes string at current cursor location.    Moves cursor to new location
  175. ;**  when finished.  Does not modify attribute.
  176. ;**
  177. ;** RETURNS
  178. ;**  void
  179. ;**
  180. ;** AUTHOR
  181. ;**  ""   Wed 07-Dec-1988    16:03:51
  182. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  183. ;**
  184. ;** MODIFICATIONS
  185. ;**
  186. ;*/
  187.         cproc    fwstr
  188.         mov    ah,GETCURSPOS
  189.         xor    bh,bh            ;page 0
  190.         int    BIOSVIDEO        ;get cursor row/col to dh/dl
  191.         push    dx            ;save for later
  192.         if    _LDATA
  193.          les    di,parm1_        ;ES:DI point to string
  194.         else
  195.          mov    ax,ds
  196.          mov    es,ax
  197.          mov    di,parm1_        ;ES:DI point to string
  198.         endif
  199.         mov    al,dh            ;AL = row number
  200.         mov    cl,dl            ;CL = column number
  201.         call    disptable        ;call via table
  202.         pop    dx
  203.         add    dl,al            ;adjust cursor column
  204.         cmp    dl,80            ;see if above max column
  205.         jb    fwstrnotend
  206.         mov    dl,79            ;stop at max column
  207. fwstrnotend:    xor    bh,bh
  208.         mov    ah,SETCURSPOS
  209.         int    BIOSVIDEO
  210.         cproce
  211.  
  212.  
  213.  
  214. ;/*
  215. ;**  void
  216. ;** frwstr(int color,char *string)
  217. ;**
  218. ;** ARGUMENT(s)
  219. ;**  color        -    color to  write
  220. ;**  string        -    points to null terminated string to write
  221. ;**
  222. ;** DESCRIPTION
  223. ;**  Writes string in color attribute at current cursor location.  Moves cursor to
  224. ;**  new location when finished.
  225. ;**
  226. ;** RETURNS
  227. ;**  void
  228. ;**
  229. ;** AUTHOR
  230. ;**  "" Thu 08-Dec-1988 10:00:43
  231. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  232. ;**
  233. ;** MODIFICATIONS
  234. ;**
  235. ;*/
  236.          cproc    frwstr
  237.         mov    ah,GETCURSPOS
  238.         xor    bh,bh            ;page 0
  239.         int    BIOSVIDEO        ;get cursor row/col to dh/dl
  240.         push    dx            ;save for later
  241.         if    _LDATA
  242.          les    di,parm2_        ;ES:DI point to string
  243.         else
  244.          mov    ax,ds
  245.          mov    es,ax
  246.          mov    di,parm2_        ;ES:DI point to string
  247.         endif
  248.         mov    al,dh            ;AL = row number
  249.         mov    cl,dl            ;CL = column number
  250.         mov    ch,parm1_        ;CH = attribute to use
  251.         call    disptable+2        ;call via table
  252.         pop    dx
  253.         add    dl,al            ;adjust cursor column
  254.         cmp    dl,80            ;see if above max column
  255.         jb    frwstrnotend
  256.         mov    dl,79            ;stop at max column
  257. frwstrnotend:    xor    bh,bh
  258.         mov    ah,SETCURSPOS
  259.         int    BIOSVIDEO
  260.         cproce
  261.  
  262. ;/*
  263. ;**  void
  264. ;** fatwstr(int row,int col,char *string)
  265. ;**
  266. ;** ARGUMENT(s)
  267. ;**  row        -    Y position for write (row #)
  268. ;**  col        -    X position for write (column #)
  269. ;**  string        -    points to null terminated string to write
  270. ;**
  271. ;** DESCRIPTION
  272. ;**  Writes string at specified cursor location.  Moves cursor to new location
  273. ;**  when finished.  Does not modify attribute.
  274. ;**
  275. ;** RETURNS
  276. ;**  void
  277. ;**
  278. ;** AUTHOR
  279. ;**  "" Thu 08-Dec-1988 09:09:49
  280. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  281. ;**
  282. ;** MODIFICATIONS
  283. ;**
  284. ;*/
  285.         cproc    fatwstr
  286.         if    _LDATA
  287.          les    di,parm3_        ;ES:DI point to string
  288.         else
  289.          mov    ax,ds
  290.          mov    es,ax
  291.          mov    di,parm3_        ;ES:DI point to string
  292.         endif
  293.         mov    al,parm1_        ;AL = row number
  294.         mov    cl,parm2_        ;CL = column number
  295.         call    disptable        ;call via table
  296.         mov    dl,parm2_        ;DL = column
  297.         mov    dh,parm1_        ;DH = row number
  298.         add    dl,al            ;adjust cursor column
  299.         cmp    dl,80            ;see if above max column
  300.         jb    fatwstrnotend
  301.         mov    dl,79            ;stop at max column
  302. fatwstrnotend:    xor    bh,bh            ;set new cursor position
  303.         mov    ah,SETCURSPOS
  304.         int    BIOSVIDEO
  305.         cproce
  306.  
  307.  
  308. ;/*
  309. ;**  void
  310. ;** fratwstr(int row,int col,int color,char *string)
  311. ;**
  312. ;** ARGUMENT(s)
  313. ;**  row        -    Y position for write (row #)
  314. ;**  col        -    X position for write (column #)
  315. ;**  color        -    Attribute (color) to use
  316. ;**  string        -    points to null terminated string to write
  317. ;**
  318. ;** DESCRIPTION
  319. ;**  Writes string at specified cursor location using specified attribute.
  320. ;**  Moves cursor to new location when finished.
  321. ;**
  322. ;** RETURNS
  323. ;**  void
  324. ;**
  325. ;** AUTHOR
  326. ;**  "" Thu 08-Dec-1988 10:07:58
  327. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  328. ;**
  329. ;** MODIFICATIONS
  330. ;**
  331. ;*/
  332.         cproc    fratwstr
  333.         if    _LDATA
  334.          les    di,parm4_        ;ES:DI point to string
  335.         else
  336.          mov    ax,ds
  337.          mov    es,ax
  338.          mov    di,parm4_        ;ES:DI point to string
  339.         endif
  340.         mov    al,parm1_        ;AL = row number
  341.         mov    cl,parm2_        ;CL = column number
  342.         mov    ch,parm3_        ;CH = attribute
  343.         call    disptable+2        ;call via table
  344.         mov    dl,parm2_        ;DL = column
  345.         mov    dh,parm1_        ;DH = row number
  346.         add    dl,al            ;adjust cursor column
  347.         cmp    dl,80            ;see if above max column
  348.         jb    fratwstrnotend
  349.         mov    dl,79            ;stop at max column
  350. fratwstrnotend: xor    bh,bh            ;set new cursor position
  351.         mov    ah,SETCURSPOS
  352.         int    BIOSVIDEO
  353.         cproce
  354.  
  355.  
  356. ;/*
  357. ;**  void
  358. ;** fatwch(int row,int col,int character,unsigned char attribute)
  359. ;**
  360. ;** ARGUMENT(s)
  361. ;**
  362. ;**    row        -        row to put character on
  363. ;**    col        -        column to put character on
  364. ;**    character    -        character to be displayed
  365. ;**    attribute    -        attribute to be displayed
  366. ;**
  367. ;** DESCRIPTION
  368. ;**  Puts character/attribute at row/col specified.  Increments cursor to the
  369. ;**  next character position.
  370. ;**
  371. ;** RETURNS
  372. ;**  void
  373. ;**
  374. ;** AUTHOR
  375. ;**  ""   Thu 08-Dec-1988    13:20:23
  376. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  377. ;**
  378. ;** MODIFICATIONS
  379. ;**
  380. ;*/
  381.         cproc    fatwch
  382.         mov    al,parm1_        ;AL = row
  383.         mov    cl,parm2_        ;CL = column
  384.         mov    dl,parm3_        ;DL = character
  385.         mov    dh,parm4_        ;DH = attribute
  386.         call    disptable+6
  387.         mov    dh,parm1_        ;DH = row
  388.         mov    dl,parm2_        ;DL = col
  389.         inc    dl                    ;increment cursor position
  390.         cmp    dl,80
  391.         jb    notend1
  392.         mov    dl,79
  393. notend1:    xor    bh,bh
  394.         mov    ah,SETCURSPOS
  395.         int    BIOSVIDEO
  396.         cproce
  397.  
  398.  
  399.  
  400. ;/*
  401. ;**  void
  402. ;** getscrn(int ulrow,int ulcol,int lrrow,int lrcol,unsigned *buffer)
  403. ;**
  404. ;** ARGUMENT(s)
  405. ;**  ulrow        -    upper left row of region
  406. ;**  ulcol        -    upper left column of region
  407. ;**  lrrow        -    lower right row of region
  408. ;**  lrcol        -    lower right column of region
  409. ;**  buffer        -    buffer to receive information
  410. ;**
  411. ;** DESCRIPTION
  412. ;**  Moves characters and attributes from the rectangular region defined
  413. ;**  by the ulrow/ulcol and lrrow/lrcol to the buffer.
  414. ;**
  415. ;** RETURNS
  416. ;**  void
  417. ;**
  418. ;** AUTHOR
  419. ;**  ""   Thu 08-Dec-1988    13:42:01
  420. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  421. ;**
  422. ;** MODIFICATIONS
  423. ;**
  424. ;*/
  425.         cproc    getscrn
  426.         mov    al,parm1_        ;AL = ulrow
  427.         mov    cl,parm2_        ;CL = ulcol
  428.         mov    dh,parm3_        ;DH = lrrow
  429.         sub    dh,al            ;calculate total number
  430.         inc    dh
  431.         mov    dl,parm4_        ;DL = lrcol
  432.         sub    dl,cl            ;calculate total number
  433.         inc    dl
  434.         if    _LDATA
  435.          les    di,parm5_
  436.         else
  437.          mov    bx,ds
  438.          mov    es,bx
  439.          mov    di,parm5_
  440.         endif
  441.         call    disptable+8
  442.         cproce
  443.  
  444. ;/*
  445. ;**  void
  446. ;** putscrn(int ulrow,int ulcol,int lrrow,int lrcol,unsigned *buffer)
  447. ;**
  448. ;** ARGUMENT(s)
  449. ;**  ulrow        -    upper left row of region
  450. ;**  ulcol        -    upper left column of region
  451. ;**  lrrow        -    lower right row of region
  452. ;**  lrcol        -    lower right column of region
  453. ;**  buffer        -    buffer holding information
  454. ;**
  455. ;** DESCRIPTION
  456. ;**  Moves characters and attributes from the buffer to the rectangular region
  457. ;**  defined by the ulrow/ulcol and lrrow/lrcol.
  458. ;**
  459. ;** RETURNS
  460. ;**  void
  461. ;**
  462. ;** AUTHOR
  463. ;**  "" Thu 08-Dec-1988 14:15:10
  464. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  465. ;**
  466. ;** MODIFICATIONS
  467. ;**
  468. ;*/
  469.         cproc    putscrn
  470.         mov    al,parm1_        ;AL = ulrow
  471.         mov    cl,parm2_        ;CL = ulcol
  472.         mov    dh,parm3_        ;DH = lrrow
  473.         sub    dh,al            ;calculate total number
  474.         inc    dh
  475.         mov    dl,parm4_        ;DL = lrcol
  476.         sub    dl,cl            ;calculate total number
  477.         inc    dl
  478.         if    _LDATA
  479.          les    di,parm5_
  480.         else
  481.          mov    bx,ds
  482.          mov    es,bx
  483.          mov    di,parm5_
  484.         endif
  485.         call    disptable+10
  486.         cproce
  487.  
  488.  
  489.  
  490.  
  491.         subttl    [CGA (With Retrace) Fast video routines]
  492.         page
  493. ;/*
  494. ;** DESCRIPTION
  495. ;**  CGA (with retrace) write string at cursor location.  (Does not write
  496. ;**  attributes.
  497. ;**
  498. ;**    Entry:
  499. ;**        ES:DI    ->    point to string
  500. ;**        AL    ->    row number
  501. ;**        CL    ->    column number
  502. ;**
  503. ;** RETURNS
  504. ;**        AX    ->    number of characters written
  505. ;**
  506. ;** AUTHOR
  507. ;**  ""   Wed 07-Dec-1988    12:51:42
  508. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  509. ;**
  510. ;** MODIFICATIONS
  511. ;**
  512. ;*/
  513. cgracur     proc    near
  514.         xor    ah,ah
  515.         mov    bx,ax
  516.         shl    ax,1            ;y*2
  517.         shl    ax,1            ;y*4
  518.         add    ax,bx            ;y*5
  519.         shl    ax,1            ;y*10
  520.         add    ax,CGAREGENSEG        ;+starting segment of display
  521.         xor    bh,bh
  522.         mov    bl,cl
  523.         shl    bx,1            ;x*2
  524.         push    ds
  525.         mov    dx,CGAGRSTATUS        ;dx=CGA status register
  526.         mov    ds,ax            ;ds points to start of CRT + ROW
  527.         xor    si,si            ;si=counter
  528. cgracurloop:    mov    ah,es:[di]        ;get character
  529.         or    ah,ah            ;terminator?
  530.         jz    cgracurex
  531.         CRTWAIT
  532.         mov    [bx],ah         ;save character in CRT memory
  533.         sti
  534.         inc    bx            ;move bx past attribute
  535.         inc    bx
  536.         inc    si            ;increment counter
  537.         inc    di            ;increment source pointer
  538.         jmp    short cgracurloop    ;repeat
  539. cgracurex:    mov    ax,si            ;return AX=number of characters
  540.         pop    ds            ;get DS back
  541.         ret
  542. cgracur     endp
  543.  
  544.  
  545. ;/*
  546. ;** DESCRIPTION
  547. ;**  CGA (with retrace) write string and attribute at cursor location.
  548. ;**
  549. ;**    Entry:
  550. ;**        ES:DI    ->    point to string
  551. ;**        AL    ->    row number
  552. ;**        CL    ->    column number
  553. ;**        CH    ->    Attribute
  554. ;**
  555. ;** RETURNS
  556. ;**        AX    ->    number of characters written
  557. ;**
  558. ;** AUTHOR
  559. ;**  "" Wed 07-Dec-1988 13:15:11
  560. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  561. ;**
  562. ;** MODIFICATIONS
  563. ;**
  564. ;*/
  565. cgraaccur    proc    near
  566.         xor    ah,ah
  567.         mov    bx,ax
  568.         shl    ax,1            ;y*2
  569.         shl    ax,1            ;y*4
  570.         add    ax,bx            ;y*5
  571.         shl    ax,1            ;y*10
  572.         add    ax,CGAREGENSEG        ;+starting segment of display
  573.         xor    bh,bh
  574.         mov    bl,cl
  575.         shl    bx,1            ;x*2
  576.         push    ds            ;save ds
  577.         mov    ds,ax            ;ds points to start of CRT + ROW
  578.         mov    dx,CGAGRSTATUS        ;dx= CGA status register
  579.         xor    si,si            ;si=counter
  580. cgraaccurloop:    mov    ah,es:[di]        ;get character
  581.         or    ah,ah            ;terminator?
  582.         jz    cgraaccurex
  583.         CRTWAIT
  584.         mov    [bx],ah         ;save character in CRT memory
  585.         sti
  586.         inc    bx
  587.         CRTWAIT
  588.         mov    [bx],ch         ;save attribute in CRT memory
  589.         sti
  590.         inc    bx
  591.         inc    si            ;increment counter
  592.         inc    di            ;increment source pointer
  593.         jmp    short cgraaccurloop    ;repeat
  594. cgraaccurex:    mov    ax,si            ;return AX=number of characters
  595.         pop    ds            ;get DS back
  596.         ret
  597. cgraaccur    endp
  598.  
  599. ;/*
  600. ;** DESCRIPTION
  601. ;**  CGA (with retrace) read character and attribute at cursor location.
  602. ;**
  603. ;**    Entry:
  604. ;**        AL    ->    row number
  605. ;**        CL    ->    column number
  606. ;**
  607. ;** RETURNS
  608. ;**        AX    ->    (AL = character, AH = attribute)
  609. ;**
  610. ;** AUTHOR
  611. ;**  "" Wed 07-Dec-1988 13:28:40
  612. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  613. ;**
  614. ;** MODIFICATIONS
  615. ;**
  616. ;*/
  617. cgrrchatatcur    proc    near
  618.         xor    ah,ah
  619.         mov    bx,ax
  620.         shl    ax,1            ;y*2
  621.         shl    ax,1            ;y*4
  622.         add    ax,bx            ;y*5
  623.         shl    ax,1            ;y*10
  624.         add    ax,CGAREGENSEG        ;+starting segment of display
  625.         xor    bh,bh
  626.         mov    bl,cl            ;bl=column number
  627.         shl    bx,1            ;x*2
  628.         mov    si,ds            ;save ds
  629.         mov    ds,ax            ;ds points to start of CRT + ROW
  630.         mov    dx,CGAGRSTATUS
  631.         CRTWAIT
  632.         mov    cl,[bx]         ;CL=character
  633.         sti
  634.         inc    bx
  635.         CRTWAIT
  636.         mov    ch,[bx]
  637.         sti
  638.         mov    ax,cx            ;return value in AX
  639.         mov    ds,si            ;restore ds
  640.         ret
  641. cgrrchatatcur    endp
  642.  
  643.  
  644.  
  645. ;/*
  646. ;** DESCRIPTION
  647. ;**  CGA (with retrace) write character and attribute at cursor location.
  648. ;**
  649. ;**    Entry:
  650. ;**        AL    ->    row number
  651. ;**        CL    ->    column number
  652. ;**        DL    ->    Character
  653. ;**        DH    ->    Attribute
  654. ;**
  655. ;** RETURNS
  656. ;**  void
  657. ;**
  658. ;** AUTHOR
  659. ;**  "" Thu 08-Dec-1988 13:05:57
  660. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  661. ;**
  662. ;** MODIFICATIONS
  663. ;**
  664. ;*/
  665. cgrachat    proc    near
  666.         xor    ah,ah
  667.         mov    bx,ax
  668.         shl    ax,1            ;y*2
  669.         shl    ax,1            ;y*4
  670.         add    ax,bx            ;y*5
  671.         shl    ax,1            ;y*10
  672.         add    ax,CGAREGENSEG        ;+starting segment of display
  673.         xor    bh,bh
  674.         mov    bl,cl
  675.         shl    bx,1            ;x*2
  676.         push    ds            ;save ds
  677.         mov    ds,ax            ;ds points to start of CRT + ROW
  678.         mov    cx,dx            ;CH=attribute, CL=character
  679.         mov    dx,CGAGRSTATUS        ;dx= CGA status register
  680.         CRTWAIT
  681.         mov    [bx],cl         ;save character in CRT memory
  682.         sti
  683.         inc    bx
  684.         CRTWAIT
  685.         mov    [bx],ch         ;save attribute in CRT memory
  686.         sti
  687.         pop    ds            ;get DS back
  688.         ret
  689. cgrachat    endp
  690.  
  691.  
  692.  
  693. ;/*
  694. ;** DESCRIPTION
  695. ;**  CGA (with retrace) get region to buffer.
  696. ;**
  697. ;**    Entry:
  698. ;**        AL    ->    row number
  699. ;**        CL    ->    column number
  700. ;**        DH    ->    number of rows
  701. ;**        DL    ->    number of columns
  702. ;**        ES:DI    ->    points to buffer that receives information
  703. ;**
  704. ;** RETURNS
  705. ;**  void
  706. ;**
  707. ;** AUTHOR
  708. ;**  "" Thu 08-Dec-1988 13:42:01
  709. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  710. ;**
  711. ;** MODIFICATIONS
  712. ;**
  713. ;*/
  714. cgrgetregion    proc    near
  715.         xor    ah,ah
  716.         mov    bx,ax
  717.         shl    ax,1            ;y*2
  718.         shl    ax,1            ;y*4
  719.         add    ax,bx            ;y*5
  720.         shl    ax,1            ;y*10
  721.         add    ax,CGAREGENSEG        ;+starting segment of display
  722.         xor    bh,bh
  723.         mov    bl,cl            ;bl=column number
  724.         shl    bx,1            ;x*2
  725.         push    ds            ;save ds
  726.         mov    ds,ax            ;ds points to start of CRT + ROW
  727.         mov    cx,dx            ;CH =number of rows, CL=number of cols
  728.         mov    si,bx            ;save starting position in SI
  729.         mov    dx,CGAGRSTATUS        ;DX=crt status port
  730. cgrgetrlp2:    push    cx
  731. cgrgetrlp1:
  732.         CRTWAIT
  733.         mov    al,[bx]         ;AL=character
  734.         sti
  735.         mov    es:[di],al
  736.         inc    di
  737.         inc    bx
  738.         CRTWAIT
  739.         mov    al,[bx]
  740.         sti
  741.         mov    es:[di],al
  742.         inc    di
  743.         inc    bx
  744.         dec    cl            ;decrement column count
  745.         jnz    cgrgetrlp1        ;do next character
  746.         pop    cx            ;get orig. cx back
  747.         dec    ch            ;decrement row count
  748.         jz    cgrgetfin        ;if zero then done
  749.         add    si,160            ;adjust si for next row
  750.         mov    bx,si            ;set bx for next row
  751.         jmp    cgrgetrlp2        ;do next row
  752.  
  753. cgrgetfin:
  754.  
  755.         pop    ds            ;restore DS
  756.         ret
  757. cgrgetregion    endp
  758.  
  759. ;/*
  760. ;** DESCRIPTION
  761. ;**  CGA (with retrace) put buffer to region.
  762. ;**
  763. ;**    Entry:
  764. ;**        AL    ->    row number
  765. ;**        CL    ->    column number
  766. ;**        DH    ->    number of rows
  767. ;**        DL    ->    number of columns
  768. ;**        ES:DI    ->    points to buffer that contains
  769. ;**
  770. ;** RETURNS
  771. ;**  void
  772. ;**
  773. ;** AUTHOR
  774. ;**  "" Thu 08-Dec-1988 14:15:10
  775. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  776. ;**
  777. ;** MODIFICATIONS
  778. ;**
  779. ;*/
  780. cgrputregion    proc    near
  781.         xor    ah,ah
  782.         mov    bx,ax
  783.         shl    ax,1            ;y*2
  784.         shl    ax,1            ;y*4
  785.         add    ax,bx            ;y*5
  786.         shl    ax,1            ;y*10
  787.         add    ax,CGAREGENSEG        ;+starting segment of display
  788.         xor    bh,bh
  789.         mov    bl,cl            ;bl=column number
  790.         shl    bx,1            ;x*2
  791.         push    ds            ;save ds
  792.         mov    ds,ax            ;ds points to start of CRT + ROW
  793.         mov    cx,dx            ;CH =number of rows, CL=number of cols
  794.         mov    si,bx            ;save starting position in SI
  795.         mov    dx,CGAGRSTATUS        ;DX=crt status port
  796. cgrputrlp2:    push    cx
  797. cgrputrlp1:
  798.         mov    ah,es:[di]
  799.         CRTWAIT
  800.         mov    [bx],ah         ;save character
  801.         sti
  802.         inc    di
  803.         mov    ah,es:[di]        ;ah=attribute
  804.         inc    bx
  805.         CRTWAIT
  806.         mov    [bx],ah
  807.         sti
  808.         inc    di
  809.         inc    bx
  810.         dec    cl            ;decrement column count
  811.         jnz    cgrputrlp1        ;do next character
  812.         pop    cx            ;get orig. cx back
  813.         dec    ch            ;decrement row count
  814.         jz    cgrputfin        ;if zero then done
  815.         add    si,160            ;adjust si for next row
  816.         mov    bx,si            ;set bx for next row
  817.         jmp    cgrputrlp2        ;do next row
  818.  
  819. cgrputfin:
  820.  
  821.         pop    ds            ;restore DS
  822.         ret
  823. cgrputregion    endp
  824.  
  825.  
  826.  
  827.  
  828.  
  829.         subttl    [CGA (Without Retrace) Fast video routines]
  830.         page
  831. ;/*
  832. ;** DESCRIPTION
  833. ;**  CGA write string at cursor location.  (Does not write attributes.)
  834. ;**    also does NOT wait on horizontal retrace.
  835. ;**
  836. ;**    Entry:
  837. ;**        ES:DI    ->    point to string
  838. ;**        AL    ->    row number
  839. ;**        CL    ->    column number
  840. ;**
  841. ;** RETURNS
  842. ;**        AX    ->    number of characters written
  843. ;**
  844. ;** AUTHOR
  845. ;**  "" Wed 07-Dec-1988 15:18:17
  846. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  847. ;**
  848. ;** MODIFICATIONS
  849. ;**
  850. ;*/
  851. cgacur        proc    near
  852.         xor    ah,ah
  853.         mov    bx,ax
  854.         shl    ax,1            ;y*2
  855.         shl    ax,1            ;y*4
  856.         add    ax,bx            ;y*5
  857.         shl    ax,1            ;y*10
  858.         add    ax,CGAREGENSEG        ;+starting segment of display
  859.         xor    bh,bh
  860.         mov    bl,cl
  861.         shl    bx,1            ;x*2
  862.         mov    dx,ds            ;save ds
  863.         mov    ds,ax            ;ds points to start of CRT + ROW
  864.         xor    si,si            ;si=counter
  865. cgacurloop:    mov    al,es:[di]        ;get character
  866.         or    al,al            ;terminator?
  867.         jz    cgacurex
  868.         mov    [bx],al         ;save character in CRT memory
  869.         inc    bx            ;move bx past attribute
  870.         inc    bx
  871.         inc    si            ;increment counter
  872.         inc    di            ;increment source pointer
  873.         jmp    short cgacurloop    ;repeat
  874. cgacurex:    mov    ds,dx            ;restore ds
  875.         mov    ax,si            ;return AX=number of characters
  876.         ret
  877. cgacur        endp
  878.  
  879.  
  880. ;/*
  881. ;** DESCRIPTION
  882. ;**  CGA write string and attribute at cursor location (without retrace)
  883. ;**
  884. ;**    Entry:
  885. ;**        ES:DI    ->    point to string
  886. ;**        AL    ->    row number
  887. ;**        CL    ->    column number
  888. ;**        CH    ->    Attribute
  889. ;**
  890. ;** RETURNS
  891. ;**        AX    ->    number of characters written
  892. ;**
  893. ;** AUTHOR
  894. ;**  "" Wed 07-Dec-1988 15:22:13
  895. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  896. ;**
  897. ;** MODIFICATIONS
  898. ;**
  899. ;*/
  900. cgaaaccur    proc    near
  901.         xor    ah,ah
  902.         mov    bx,ax
  903.         shl    ax,1            ;y*2
  904.         shl    ax,1            ;y*4
  905.         add    ax,bx            ;y*5
  906.         shl    ax,1            ;y*10
  907.         add    ax,CGAREGENSEG        ;+starting segment of display
  908.         xor    bh,bh
  909.         mov    bl,cl
  910.         shl    bx,1            ;x*2
  911.         mov    dx,ds            ;save ds
  912.         mov    ds,ax            ;ds points to start of CRT + ROW
  913.         xor    si,si            ;si=counter
  914. cgaaaccurloop:    mov    al,es:[di]        ;get character
  915.         or    al,al            ;terminator?
  916.         jz    cgaaaccurex
  917.         mov    [bx],al         ;save character in CRT memory
  918.         inc    bx
  919.         mov    [bx],ch         ;save attribute in CRT memory
  920.         inc    bx
  921.         inc    si            ;increment counter
  922.         inc    di            ;increment source pointer
  923.         jmp    short cgaaaccurloop    ;repeat
  924. cgaaaccurex:    mov    ds,dx            ;restore ds
  925.         mov    ax,si            ;return AX=number of characters
  926.         ret
  927. cgaaaccur    endp
  928.  
  929. ;/*
  930. ;** DESCRIPTION
  931. ;**  CGA read character and attribute at cursor location (without retrace)
  932. ;**
  933. ;**    Entry:
  934. ;**        AL    ->    row number
  935. ;**        CL    ->    column number
  936. ;**
  937. ;** RETURNS
  938. ;**        AX    ->    (AL = character, AH = attribute)
  939. ;**
  940. ;** AUTHOR
  941. ;**  "" Wed 07-Dec-1988 15:18:17
  942. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  943. ;**
  944. ;** MODIFICATIONS
  945. ;**
  946. ;*/
  947. cgrchatatcur    proc    near
  948.         xor    ah,ah
  949.         mov    bx,ax
  950.         shl    ax,1            ;y*2
  951.         shl    ax,1            ;y*4
  952.         add    ax,bx            ;y*5
  953.         shl    ax,1            ;y*10
  954.         add    ax,CGAREGENSEG        ;+starting segment of display
  955.         xor    bh,bh
  956.         mov    bl,cl            ;bl=column number
  957.         shl    bx,1            ;x*2
  958.         mov    dx,ds            ;save ds
  959.         mov    ds,ax            ;ds points to start of CRT + ROW
  960.         mov    ax,[bx]         ;get character/attribute
  961.         mov    ds,dx            ;restore ds
  962.         ret
  963. cgrchatatcur    endp
  964.  
  965. ;/*
  966. ;** DESCRIPTION
  967. ;**  CGA write character and attribute at cursor location (without retrace)
  968. ;**
  969. ;**    Entry:
  970. ;**        AL    ->    row number
  971. ;**        CL    ->    column number
  972. ;**        DL    ->    Character
  973. ;**        DH    ->    Attribute
  974. ;**
  975. ;** RETURNS
  976. ;**  void
  977. ;**
  978. ;** AUTHOR
  979. ;**  "" Thu 08-Dec-1988 13:05:57
  980. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  981. ;**
  982. ;** MODIFICATIONS
  983. ;**
  984. ;*/
  985. cgawchat    proc    near
  986.         xor    ah,ah
  987.         mov    bx,ax
  988.         shl    ax,1            ;y*2
  989.         shl    ax,1            ;y*4
  990.         add    ax,bx            ;y*5
  991.         shl    ax,1            ;y*10
  992.         add    ax,CGAREGENSEG        ;+starting segment of display
  993.         xor    bh,bh
  994.         mov    bl,cl
  995.         shl    bx,1            ;x*2
  996.         mov    cx,ds            ;save ds
  997.         mov    ds,ax            ;ds points to start of CRT + ROW
  998.         mov    [bx],dx         ;save character & attribute in CRT memory
  999.         mov    ds,cx            ;get DS back
  1000.         ret
  1001. cgawchat    endp
  1002.  
  1003. ;/*
  1004. ;** DESCRIPTION
  1005. ;**  CGA (without retrace) get region to buffer.
  1006. ;**
  1007. ;**    Entry:
  1008. ;**        AL    ->    row number
  1009. ;**        CL    ->    column number
  1010. ;**        DH    ->    number of rows
  1011. ;**        DL    ->    number of columns
  1012. ;**        ES:DI    ->    points to buffer that receives information
  1013. ;**
  1014. ;** RETURNS
  1015. ;**  void
  1016. ;**
  1017. ;** AUTHOR
  1018. ;**  "" Thu 08-Dec-1988 14:24:23
  1019. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  1020. ;**
  1021. ;** MODIFICATIONS
  1022. ;**
  1023. ;*/
  1024. cggetregion    proc    near
  1025.         xor    ah,ah
  1026.         mov    bx,ax
  1027.         shl    ax,1            ;y*2
  1028.         shl    ax,1            ;y*4
  1029.         add    ax,bx            ;y*5
  1030.         shl    ax,1            ;y*10
  1031.         add    ax,CGAREGENSEG        ;+starting segment of display
  1032.         xor    bh,bh
  1033.         mov    bl,cl            ;bl=column number
  1034.         shl    bx,1            ;x*2
  1035.         push    ds            ;save ds
  1036.         mov    ds,ax            ;ds points to start of CRT + ROW
  1037.         mov    cx,dx            ;CH =number of rows, CL=number of cols
  1038.         mov    si,bx            ;save starting position in SI
  1039. cggetrlp2:    push    cx
  1040. cggetrlp1:    mov    ax,[bx]
  1041.         mov    es:[di],ax
  1042.         inc    di
  1043.         inc    di
  1044.         inc    bx
  1045.         inc    bx
  1046.         dec    cl            ;decrement column count
  1047.         jnz    cggetrlp1        ;do next character
  1048.         pop    cx            ;get orig. cx back
  1049.         dec    ch            ;decrement row count
  1050.         jz    cggetfin        ;if zero then done
  1051.         add    si,160            ;adjust si for next row
  1052.         mov    bx,si            ;set bx for next row
  1053.         jmp    cggetrlp2        ;do next row
  1054. cggetfin:    pop    ds            ;restore DS
  1055.         ret
  1056. cggetregion    endp
  1057.  
  1058. ;/*
  1059. ;** DESCRIPTION
  1060. ;**  CGA (without retrace) put buffer to region.
  1061. ;**
  1062. ;**    Entry:
  1063. ;**        AL    ->    row number
  1064. ;**        CL    ->    column number
  1065. ;**        DH    ->    number of rows
  1066. ;**        DL    ->    number of columns
  1067. ;**        ES:DI    ->    points to buffer that contains
  1068. ;**
  1069. ;** RETURNS
  1070. ;**  void
  1071. ;**
  1072. ;** AUTHOR
  1073. ;**  "" Thu 08-Dec-1988 14:24:23
  1074. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  1075. ;**
  1076. ;** MODIFICATIONS
  1077. ;**
  1078. ;*/
  1079. cgputregion    proc    near
  1080.         xor    ah,ah
  1081.         mov    bx,ax
  1082.         shl    ax,1            ;y*2
  1083.         shl    ax,1            ;y*4
  1084.         add    ax,bx            ;y*5
  1085.         shl    ax,1            ;y*10
  1086.         add    ax,CGAREGENSEG        ;+starting segment of display
  1087.         xor    bh,bh
  1088.         mov    bl,cl            ;bl=column number
  1089.         shl    bx,1            ;x*2
  1090.         push    ds            ;save ds
  1091.         mov    ds,ax            ;ds points to start of CRT + ROW
  1092.         mov    cx,dx            ;CH =number of rows, CL=number of cols
  1093.         mov    si,bx            ;save starting position in SI
  1094. cgputrlp2:    push    cx
  1095. cgputrlp1:    mov    ax,es:[di]
  1096.         mov    [bx],ax         ;save character
  1097.         inc    di
  1098.         inc    bx
  1099.         inc    di
  1100.         inc    bx
  1101.         dec    cl            ;decrement column count
  1102.         jnz    cgputrlp1        ;do next character
  1103.         pop    cx            ;get orig. cx back
  1104.         dec    ch            ;decrement row count
  1105.         jz    cgputfin        ;if zero then done
  1106.         add    si,160            ;adjust si for next row
  1107.         mov    bx,si            ;set bx for next row
  1108.         jmp    cgputrlp2        ;do next row
  1109. cgputfin:    pop    ds            ;restore DS
  1110.         ret
  1111. cgputregion    endp
  1112.  
  1113.  
  1114.         subttl    [Monochrome Fast video routines]
  1115.         page
  1116.  
  1117. ;/*
  1118. ;** DESCRIPTION
  1119. ;**  monochrome write string at cursor location.  (Does not write attributes.
  1120. ;**
  1121. ;**    Entry:
  1122. ;**        ES:DI    ->    point to string
  1123. ;**        AL    ->    row number
  1124. ;**        CL    ->    column number
  1125. ;**
  1126. ;** RETURNS
  1127. ;**        AX    ->    number of characters written
  1128. ;**
  1129. ;** AUTHOR
  1130. ;**  ""   Wed 07-Dec-1988    12:51:42
  1131. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  1132. ;**
  1133. ;** MODIFICATIONS
  1134. ;**
  1135. ;*/
  1136. mwsacur     proc    near
  1137.         xor    ah,ah
  1138.         mov    bx,ax
  1139.         shl    ax,1            ;y*2
  1140.         shl    ax,1            ;y*4
  1141.         add    ax,bx            ;y*5
  1142.         shl    ax,1            ;y*10
  1143.         add    ax,MDAREGENSEG        ;+starting segment of display
  1144.         xor    bh,bh
  1145.         mov    bl,cl
  1146.         shl    bx,1            ;x*2
  1147.         mov    dx,ds            ;save ds
  1148.         mov    ds,ax            ;ds points to start of CRT + ROW
  1149.         xor    si,si            ;si=counter
  1150.  
  1151. mwsacurloop:    mov    al,es:[di]        ;get character
  1152.         or    al,al            ;terminator?
  1153.         jz    mwsacurex
  1154.         mov    [bx],al         ;save character in CRT memory
  1155.         inc    bx            ;move bx past attribute
  1156.         inc    bx
  1157.         inc    si            ;increment counter
  1158.         inc    di            ;increment source pointer
  1159.         jmp    short mwsacurloop    ;repeat
  1160. mwsacurex:    mov    ds,dx            ;restore ds
  1161.         mov    ax,si            ;return AX=number of characters
  1162.         ret
  1163. mwsacur     endp
  1164.  
  1165.  
  1166. ;/*
  1167. ;** DESCRIPTION
  1168. ;**  monochrome write string and attribute at cursor location.
  1169. ;**
  1170. ;**    Entry:
  1171. ;**        ES:DI    ->    point to string
  1172. ;**        AL    ->    row number
  1173. ;**        CL    ->    column number
  1174. ;**        CH    ->    Attribute
  1175. ;**
  1176. ;** RETURNS
  1177. ;**        AX    ->    number of characters written
  1178. ;**
  1179. ;** AUTHOR
  1180. ;**  "" Wed 07-Dec-1988 13:15:11
  1181. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  1182. ;**
  1183. ;** MODIFICATIONS
  1184. ;**
  1185. ;*/
  1186. mwsaaccur    proc    near
  1187.         xor    ah,ah
  1188.         mov    bx,ax
  1189.         shl    ax,1            ;y*2
  1190.         shl    ax,1            ;y*4
  1191.         add    ax,bx            ;y*5
  1192.         shl    ax,1            ;y*10
  1193.         add    ax,MDAREGENSEG        ;+starting segment of display
  1194.         xor    bh,bh
  1195.         mov    bl,cl
  1196.         shl    bx,1            ;x*2
  1197.         mov    dx,ds            ;save ds
  1198.         mov    ds,ax            ;ds points to start of CRT + ROW
  1199.         xor    si,si            ;si=counter
  1200. mwsaaccurloop:    mov    al,es:[di]        ;get character
  1201.         or    al,al            ;terminator?
  1202.         jz    mwsaaccurex
  1203.         mov    [bx],al         ;save character in CRT memory
  1204.         inc    bx
  1205.         mov    [bx],ch         ;save attribute in CRT memory
  1206.         inc    bx
  1207.         inc    si            ;increment counter
  1208.         inc    di            ;increment source pointer
  1209.         jmp    short mwsaaccurloop    ;repeat
  1210. mwsaaccurex:    mov    ds,dx            ;restore ds
  1211.         mov    ax,si            ;return AX=number of characters
  1212.         ret
  1213. mwsaaccur    endp
  1214.  
  1215.  
  1216. ;/*
  1217. ;** DESCRIPTION
  1218. ;**  Monochrome read character and attribute at cursor location.
  1219. ;**
  1220. ;**    Entry:
  1221. ;**        AL    ->    row number
  1222. ;**        CL    ->    column number
  1223. ;**
  1224. ;** RETURNS
  1225. ;**        AX    ->    (AL = character, AH = attribute)
  1226. ;**
  1227. ;** AUTHOR
  1228. ;**  "" Wed 07-Dec-1988 15:18:17
  1229. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  1230. ;**
  1231. ;** MODIFICATIONS
  1232. ;**
  1233. ;*/
  1234. mrchatatcur    proc    near
  1235.         xor    ah,ah
  1236.         mov    bx,ax
  1237.         shl    ax,1            ;y*2
  1238.         shl    ax,1            ;y*4
  1239.         add    ax,bx            ;y*5
  1240.         shl    ax,1            ;y*10
  1241.         add    ax,MDAREGENSEG        ;+starting segment of display
  1242.         xor    bh,bh
  1243.         mov    bl,cl            ;bl=column number
  1244.         shl    bx,1            ;x*2
  1245.         mov    dx,ds            ;save ds
  1246.         mov    ds,ax            ;ds points to start of CRT + ROW
  1247.         mov    ax,[bx]         ;get character/attribute
  1248.         mov    ds,dx            ;restore ds
  1249.         ret
  1250. mrchatatcur    endp
  1251.  
  1252.  
  1253. ;/*
  1254. ;** DESCRIPTION
  1255. ;**  Monochrome write character and attribute at cursor location.
  1256. ;**
  1257. ;**    Entry:
  1258. ;**        AL    ->    row number
  1259. ;**        CL    ->    column number
  1260. ;**        DL    ->    Character
  1261. ;**        DH    ->    Attribute
  1262. ;**
  1263. ;** RETURNS
  1264. ;**  void
  1265. ;**
  1266. ;** AUTHOR
  1267. ;**  "" Thu 08-Dec-1988 13:05:57
  1268. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  1269. ;**
  1270. ;** MODIFICATIONS
  1271. ;**
  1272. ;*/
  1273. mwachat     proc    near
  1274.         xor    ah,ah
  1275.         mov    bx,ax
  1276.         shl    ax,1            ;y*2
  1277.         shl    ax,1            ;y*4
  1278.         add    ax,bx            ;y*5
  1279.         shl    ax,1            ;y*10
  1280.         add    ax,MDAREGENSEG        ;+starting segment of display
  1281.         xor    bh,bh
  1282.         mov    bl,cl
  1283.         shl    bx,1            ;x*2
  1284.         mov    cx,ds            ;save ds
  1285.         mov    ds,ax            ;ds points to start of CRT + ROW
  1286.         mov    [bx],dx         ;save character & attribute in CRT memory
  1287.         mov    ds,cx            ;get DS back
  1288.         ret
  1289. mwachat     endp
  1290.  
  1291.  
  1292. ;/*
  1293. ;** DESCRIPTION
  1294. ;**  Monochrome get region to buffer.
  1295. ;**
  1296. ;**    Entry:
  1297. ;**        AL    ->    row number
  1298. ;**        CL    ->    column number
  1299. ;**        DH    ->    number of rows
  1300. ;**        DL    ->    number of columns
  1301. ;**        ES:DI    ->    points to buffer that receives information
  1302. ;**
  1303. ;** RETURNS
  1304. ;**  void
  1305. ;**
  1306. ;** AUTHOR
  1307. ;**  "" Thu 08-Dec-1988 14:34:25
  1308. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  1309. ;**
  1310. ;** MODIFICATIONS
  1311. ;**
  1312. ;*/
  1313. mdgetregion    proc    near
  1314.         xor    ah,ah
  1315.         mov    bx,ax
  1316.         shl    ax,1            ;y*2
  1317.         shl    ax,1            ;y*4
  1318.         add    ax,bx            ;y*5
  1319.         shl    ax,1            ;y*10
  1320.         add    ax,MDAREGENSEG        ;+starting segment of display
  1321.         xor    bh,bh
  1322.         mov    bl,cl            ;bl=column number
  1323.         shl    bx,1            ;x*2
  1324.         push    ds            ;save ds
  1325.         mov    ds,ax            ;ds points to start of CRT + ROW
  1326.         mov    cx,dx            ;CH =number of rows, CL=number of cols
  1327.         mov    si,bx            ;save starting position in SI
  1328. mdgetrlp2:    push    cx
  1329. mdgetrlp1:    mov    ax,[bx]
  1330.         mov    es:[di],ax
  1331.         inc    di
  1332.         inc    di
  1333.         inc    bx
  1334.         inc    bx
  1335.         dec    cl            ;decrement column count
  1336.         jnz    mdgetrlp1        ;do next character
  1337.         pop    cx            ;get orig. cx back
  1338.         dec    ch            ;decrement row count
  1339.         jz    mdgetfin        ;if zero then done
  1340.         add    si,160            ;adjust si for next row
  1341.         mov    bx,si            ;set bx for next row
  1342.         jmp    mdgetrlp2        ;do next row
  1343. mdgetfin:    pop    ds            ;restore DS
  1344.         ret
  1345. mdgetregion    endp
  1346.  
  1347. ;/*
  1348. ;** DESCRIPTION
  1349. ;**  Monochrome put buffer to region.
  1350. ;**
  1351. ;**    Entry:
  1352. ;**        AL    ->    row number
  1353. ;**        CL    ->    column number
  1354. ;**        DH    ->    number of rows
  1355. ;**        DL    ->    number of columns
  1356. ;**        ES:DI    ->    points to buffer that contains
  1357. ;**
  1358. ;** RETURNS
  1359. ;**  void
  1360. ;**
  1361. ;** AUTHOR
  1362. ;**  "" Thu 08-Dec-1988 14:34:25
  1363. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  1364. ;**
  1365. ;** MODIFICATIONS
  1366. ;**
  1367. ;*/
  1368. mdputregion    proc    near
  1369.         xor    ah,ah
  1370.         mov    bx,ax
  1371.         shl    ax,1            ;y*2
  1372.         shl    ax,1            ;y*4
  1373.         add    ax,bx            ;y*5
  1374.         shl    ax,1            ;y*10
  1375.         add    ax,MDAREGENSEG        ;+starting segment of display
  1376.         xor    bh,bh
  1377.         mov    bl,cl            ;bl=column number
  1378.         shl    bx,1            ;x*2
  1379.         push    ds            ;save ds
  1380.         mov    ds,ax            ;ds points to start of CRT + ROW
  1381.         mov    cx,dx            ;CH =number of rows, CL=number of cols
  1382.         mov    si,bx            ;save starting position in SI
  1383. mdputrlp2:    push    cx
  1384. mdputrlp1:    mov    ax,es:[di]
  1385.         mov    [bx],ax         ;save character
  1386.         inc    di
  1387.         inc    bx
  1388.         inc    di
  1389.         inc    bx
  1390.         dec    cl            ;decrement column count
  1391.         jnz    mdputrlp1        ;do next character
  1392.         pop    cx            ;get orig. cx back
  1393.         dec    ch            ;decrement row count
  1394.         jz    mdputfin        ;if zero then done
  1395.         add    si,160            ;adjust si for next row
  1396.         mov    bx,si            ;set bx for next row
  1397.         jmp    mdputrlp2        ;do next row
  1398. mdputfin:    pop    ds            ;restore DS
  1399.         ret
  1400. mdputregion    endp
  1401.  
  1402.  
  1403. ;/*
  1404. ;** DESCRIPTION
  1405. ;**  sets the low level driver according to value in DX:
  1406. ;**
  1407. ;**    DX    =     0 = Monochrome driver
  1408. ;**            1 = CGA driver without retrace (ie EGA/VGA)
  1409. ;**            2 = CGA driver with retrace (ie CGA)
  1410. ;**
  1411. ;** RETURNS
  1412. ;**  void
  1413. ;**
  1414. ;** AUTHOR
  1415. ;**  ""   Thu 08-Dec-1988    15:19:22
  1416. ;**   Copyright (C)1988-1990 Greenleaf Software Inc. All Rights Reserved.
  1417. ;**
  1418. ;** MODIFICATIONS
  1419. ;**
  1420. ;*/
  1421. setdriver    proc    near
  1422.         lea    di,disptable        ;di points to destination
  1423.         mov    cx,tablesize        ;cx = how many words to move
  1424.         lea    si,montbl        ;assume monochrome
  1425.         cmp    dx,0            ;is it true
  1426.         jz    setmovit
  1427.         lea    si,cgatbl        ;assume cga/no retrace
  1428.         cmp    dx,1
  1429.         jz    setmovit
  1430.         lea    si,cgartbl
  1431. setmovit:    mov    ax,[si]
  1432.         mov    [di],ax
  1433.         add    di,2
  1434.         add    si,2
  1435.         loop    setmovit
  1436.         ret
  1437. setdriver    endp
  1438.  
  1439.  
  1440. autosetup    proc    near
  1441.         push    ax
  1442.         push    bx
  1443.         push    cx
  1444.         push    dx
  1445.         push    es
  1446.         push    di
  1447.         mov    ah,GETCURVIDMODE    ;get current video mode to AL
  1448.         int    BIOSVIDEO
  1449.         xor    dx,dx            ;assume Monochrome
  1450.         cmp    al,7            ;check assumption
  1451.         jz    autosetit
  1452.         inc    dx            ;assume we won't need retrace
  1453.         mov    ax,01a00h        ;Read display combination code
  1454.         push    dx
  1455.         int    BIOSVIDEO
  1456.         pop    dx
  1457.         cmp    al,01ah         ;AL=0x1a if VGA
  1458.         jz    autosetit
  1459.         mov    ah,12h
  1460.         mov    bl,10h            ;check for EGA
  1461.         push    dx
  1462.         int    BIOSVIDEO
  1463.         pop    dx
  1464.         cmp    bl,10h            ;bl!=0x10 if EGA
  1465.         jnz    autosetit
  1466.         mov    dx,2            ;else assume no ega/vga and
  1467.                         ;do retrace checking
  1468. autosetit:    call    setdriver
  1469.         pop    di
  1470.         pop    es
  1471.         pop    dx
  1472.         pop    cx
  1473.         pop    bx
  1474.         pop    ax
  1475.         ret
  1476. autosetup    endp
  1477.  
  1478.  
  1479. trapstub1    proc    near
  1480.         call    autosetup
  1481.         jmp    disptable
  1482. trapstub1    endp
  1483.  
  1484. trapstub2    proc    near
  1485.         call    autosetup
  1486.         jmp    disptable+2
  1487. trapstub2    endp
  1488.  
  1489. trapstub3    proc    near
  1490.         call    autosetup
  1491.         jmp    disptable+4
  1492. trapstub3    endp
  1493.  
  1494. trapstub4    proc    near
  1495.         call    autosetup
  1496.         jmp    disptable+6
  1497. trapstub4    endp
  1498.  
  1499. trapstub5    proc    near
  1500.         call    autosetup
  1501.         jmp    disptable+8
  1502. trapstub5    endp
  1503.  
  1504. trapstub6    proc    near
  1505.         call    autosetup
  1506.         jmp    disptable+10
  1507. trapstub6    endp
  1508.  
  1509.         endps
  1510.         end
  1511.