home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ddkx86v5.zip / DDKX86 / SRC / VDH / CGARTRC.ASM < prev    next >
Assembly Source File  |  1995-04-14  |  34KB  |  635 lines

  1. ;*DDK*************************************************************************/
  2. ;
  3. ; COPYRIGHT (C) Microsoft Corporation, 1989
  4. ; COPYRIGHT    Copyright (C) 1995 IBM Corporation
  5. ;
  6. ;    The following IBM OS/2 WARP source code is provided to you solely for
  7. ;    the purpose of assisting you in your development of OS/2 WARP device
  8. ;    drivers. You may use this code in accordance with the IBM License
  9. ;    Agreement provided in the IBM Device Driver Source Kit for OS/2. This
  10. ;    Copyright statement may not be removed.;
  11. ;*****************************************************************************/
  12.         PAGE    60,132
  13.         TITLE   VDHRTRC.ASM -- CGA Retrace Routines
  14. ;/*****************************************************************************
  15. ;*
  16. ;* SOURCE FILE NAME = VDHRTRC.ASM
  17. ;*
  18. ;* DESCRIPTIVE NAME = CGA Retrace Routines 
  19. ;*
  20. ;*
  21. ;* VERSION      V2.0
  22. ;*
  23. ;* DATE         
  24. ;*
  25. ;* DESCRIPTION  Video Device Handler Retrace Routines   
  26. ;*
  27. ;* FUNCTIONS    CGA_REP_MOVSB_INCDI_LOOP   
  28. ;*              CGA_REP_MOVSB_INCSI_LOOP                           
  29. ;*              CGA_REP_MOVSW_ADDSI2_LOOP                          
  30. ;*              CGA_REP_LODSB_STOSW_LOOP                           
  31. ;*              CGA_REP_MOVSW_STOSW_LOOP                           
  32. ;*              CGA_REP_MOVSW  
  33. ;*              CGA_REP_STOSB_INCDI_LOOP                           
  34. ;*              CGA_REP_INCDI_STOSB_LOOP                           
  35. ;*              CGA_REP_STOSW  
  36. ;*                                                                         
  37. ;* NOTES        NONE
  38. ;*             
  39. ;* STRUCTURES   NONE
  40. ;*
  41. ;* EXTERNAL REFERENCES   
  42. ;*
  43. ;* EXTERNAL FUNCTIONS
  44. ;*
  45. ;*              NONE
  46. ;*
  47. ;* CHANGE ACTIVIY =
  48. ;*   DATE      FLAG       APAR    CHANGE DESCRIPTION
  49. ;*   --------  ---------- -----   --------------------------------------
  50. ;*   mm/dd/yy  @Vr.mpppxx xxxxx   xxxxxxx
  51. ;*   03/25/89  @P1        D132    TPL, DCR 132 changes
  52. ;*   06/25/89  @T37       B703759 TPL, DCR 132 fix, 
  53. ;*   01/29/91  MS00               TPL, Convert IFDEF to IF
  54. ;*   01/29/91  MS01               TPL, Rollover MS's runtime
  55. ;*                                check for CGA speedup
  56. ;*   01/29/91  MS27               TPL, add OEM detection logic
  57. ;*****************************************************************************/
  58.  
  59.         .286c                           ; 286 protect mode instructions
  60.  
  61.         .xlist
  62.         INCLUDE struc.inc               ; Structure macro
  63.         INCLUDE error2.inc              ; Subsystem error equates
  64.         INCLUDE vdhstruc.inc            ; Buffer update data structures
  65.         INCLUDE vdhctl.inc              ; Conditional assembly control  ;MS00
  66.         INCLUDE vdhequ.inc              ; Buffer update equates
  67.         .list
  68.  
  69. ;/*
  70. ;** If CGA video memory accesses may need to wait for retrace,        ;MS00
  71. ;** these routines are necessary.  (See MAKEFILE)                     ;MS00
  72. ;*/
  73.  
  74. IFE CGA_ALWAYS_FAST     ; IF NOT CGA_ALWAYS_FAST                      ;MS00
  75.  
  76. extrn   _OEMFlags:word                  ; OEM specific features       ;MS27
  77.  
  78. HORZWAIT MACRO                          ; Wait for horizontal retrace only
  79.         .repeat                         ; 
  80.             in      al, dx              ; 
  81.             test    al, 1               ; 
  82.         .until  <z>                     ; Wait until retrace appears
  83.         cli                             ; Disable interrupts
  84.         .repeat                         ; 
  85.             in      al, dx              ; 
  86.             test    al, 1               ; 
  87.         .until  <nz>                    ; Wait until retrace disappears
  88.          ENDM                           ; 
  89.  
  90.  
  91. ALLWAIT  MACRO                          ; Wait for all retraces
  92.         .repeat                         ; 
  93.             in      al, dx              ; 
  94.             test    al, 9               ; 
  95.         .until  <z>                     ; Wait until no retrace of any kind
  96.         cli                             ; Disable interrupts
  97.         .repeat                         ; 
  98.             in      al, dx              ; 
  99.             test    al, 1               ; 
  100.         .until  <nz>                    ; Wait for start of horizontal retrace
  101.          ENDM                           ; 
  102.  
  103.  
  104. R2SEG   SEGMENT WORD    PUBLIC 'CODE'
  105.         ASSUME  CS:R2SEG,DS:NOTHING,ES:NOTHING
  106.  
  107.         PUBLIC  CGA_REP_MOVSB_INCDI_LOOP                                ;@P1
  108. CGA_REP_MOVSB_INCDI_LOOP    PROC    FAR                                 ;@P1
  109.  
  110. ;/*
  111. ;** If CGA adapter was identified as FAST during BVH initialization,    ;MS01
  112. ;** don't need retrace logic -- use direct data move.                   ;MS01
  113. ;*/
  114.  
  115.         push    ds                                                      ;MS01
  116.         push    ax                                                      ;MS01
  117.         mov     ax,seg _OEMFlags                                        ;MS01
  118.         mov     ds,ax                                                   ;MS01
  119.         test    ds:word ptr[_OEMFlags],FAST_CGA                         ;MS01
  120.         pop     ax                                                      ;MS01
  121.         pop     ds                                                      ;MS01
  122.         .if     <nz>                                                    ;MS01
  123.             .repeat                                                     ;MS01
  124.                 movsb                                                   ;MS01
  125.                 inc     di                                              ;MS01
  126.             .loop                                                       ;MS01
  127.             ret                                                         ;MS01
  128.         .endif                                                          ;MS01
  129.  
  130. ;/*
  131. ;**   CGA is slow -- need retrace logic:     
  132. ;*/
  133.  
  134.         push    ax                      ;                               ;@T37
  135.         push    dx                      ; 
  136.         mov     dx, STATUS_PORT         ; Setup CGA retrace status port
  137.         test    cl, 1                   ; 
  138.         .if     <nz>                    ; Odd byte?
  139.             HORZWAIT                    ; Wait for horizontal retrace
  140.             movsb                       ; Transfer 1 byte to PVB
  141.             sti                         ; Enable interrupt as soon as possible
  142.             inc     di                  ; Skip pass attribute byte
  143.         .endif                          ; 
  144.         shr     cx, 1                   ; Setup to move 2 bytes
  145.         .if     <ncxz>                  ; Anything to move?
  146.             .repeat                     ; 
  147.                 HORZWAIT                ; Wait for horizontal retrace
  148.                 movsb                   ; Transfer to bytes to PVB
  149.                 inc     di              ; Skip pass attribute byte
  150.                 movsb                   ; 
  151.                 sti                     ; Enable interrupt as soon as possible
  152.                 inc     di              ; 
  153.             .loop                       ; 
  154.         .endif                          ; 
  155.         pop     dx                      ; 
  156.         pop     ax                      ;                               ;@T37
  157.         ret
  158.  
  159. CGA_REP_MOVSB_INCDI_LOOP    ENDP                                        ;@P1
  160.  
  161.         PUBLIC  CGA_REP_MOVSB_INCSI_LOOP                                ;@P1
  162. CGA_REP_MOVSB_INCSI_LOOP   PROC    FAR                                  ;@P1
  163.  
  164. ;/*
  165. ;**  If CGA adapter was identified as FAST during BVH initialization,   
  166. ;**  don't need retrace logic -- use direct data move.                  
  167. ;*/
  168.  
  169.         push    ds                                                      ;MS01
  170.         push    ax                                                      ;MS01
  171.         mov     ax,seg _OEMFlags                                        ;MS01
  172.         mov     ds,ax                                                   ;MS01
  173.         test    ds:word ptr[_OEMFlags],FAST_CGA                         ;MS01
  174.         pop     ax                                                      ;MS01
  175.         pop     ds                                                      ;MS01
  176.         .if     <nz>                                                    ;MS01
  177.             .repeat                                                     ;MS01
  178.                 movsb                                                   ;MS01
  179.                 inc     si                                              ;MS01
  180.             .loop                                                       ;MS01
  181.             ret                                                         ;MS01
  182.         .endif                                                          ;MS01
  183.  
  184. ;/*
  185. ;**   CGA is slow -- need retrace logic:    
  186. ;*/
  187.  
  188.         push    dx                      ; 
  189.         mov     dx, STATUS_PORT         ; Setup CGA retrace status port
  190.         test    cl, 1                   ; 
  191.         .if     <nz>                    ; Odd byte?
  192.             HORZWAIT                    ; Wait for horizontal retrace
  193.             movsb                       ; Transfer 1 byte from PVB
  194.             sti                         ; Enable interrupt as soon as possible
  195.             inc     si                  ; Skip pass attribute byte
  196.         .endif                          ; 
  197.         shr     cx, 1                   ; Setup to move 2 bytes
  198.         .if     <ncxz>                  ; Anything to move?
  199.             .repeat                     ; 
  200.                 HORZWAIT                ; Wait for horizontal retrace
  201.                 movsb                   ; Transfer two bytes from PVB
  202.                 inc     si              ; Skip pass attribute byte
  203.                 movsb                   ; 
  204.                 sti                     ; Enable interrupt as soon as possible
  205.                 inc     si              ; 
  206.             .loop                       ; 
  207.         .endif                          ; 
  208.         pop     dx                      ; 
  209.         ret                             ; 
  210.  
  211. CGA_REP_MOVSB_INCSI_LOOP    ENDP                                        ;@P1
  212.  
  213.         PUBLIC  CGA_REP_MOVSW_ADDSI2_LOOP                               ;@P1
  214. CGA_REP_MOVSW_ADDSI2_LOOP   PROC    FAR                                 ;@P1
  215.  
  216. ;/*
  217. ;** If CGA adapter was identified as FAST during BVH initialization, 
  218. ;** don't need retrace logic -- use direct data move.
  219. ;*/
  220.  
  221.         push    ds                                                      ;MS01
  222.         push    ax                                                      ;MS01
  223.         mov     ax,seg _OEMFlags                                        ;MS01
  224.         mov     ds,ax                                                   ;MS01
  225.         test    ds:word ptr[_OEMFlags],FAST_CGA                         ;MS01
  226.         pop     ax                                                      ;MS01
  227.         pop     ds                                                      ;MS01
  228.         .if     <nz>                                                    ;MS01
  229.             .repeat                                                     ;MS01
  230.                 movsw                                                   ;MS01
  231.                 add     si,2                                            ;MS01
  232.             .loop                                                       ;MS01
  233.             ret                                                         ;MS01
  234.         .endif                                                          ;MS01
  235.  
  236. ;/*
  237. ;**   CGA is slow -- need retrace logic:                         
  238. ;*/
  239.  
  240.         push    dx                      ;                               ;@P1
  241.         mov     dx, STATUS_PORT         ; Setup CGA retrace status port ;@P1
  242.         test    cl, 1                   ;                               ;@P1
  243.         .if     <nz>                    ; Odd byte?                     ;@P1
  244.             HORZWAIT                    ; Wait for horizontal retrace   ;@P1
  245.             movsw                       ; Transfer 1 byte from PVB      ;@P1
  246.             sti                         ; Enable interrupt as soon as possible
  247.             add     si,2                ; Skip pass attribute byte      ;@P1
  248.         .endif                          ;                               ;@P1
  249.         shr     cx, 1                   ; Setup to move 2 bytes         ;@P1
  250.         .if     <ncxz>                  ; Anything to move?             ;@P1
  251.             .repeat                     ;                               ;@P1
  252.                 HORZWAIT                ; Wait for horizontal retrace   ;@P1
  253.                 movsw                   ; Transfer two bytes from PVB   ;@P1
  254.                 add     si,2            ; Skip pass attribute byte      ;@P1
  255.                 movsw                   ;                               ;@P1
  256.                 sti                     ; Enable interrupt as soon as possible
  257.                 add     si,2            ;                               ;@P1
  258.             .loop                       ;                               ;@P1
  259.         .endif                          ;                               ;@P1
  260.         pop     dx                      ;                               ;@P1
  261.         ret                             ;                               ;@P1
  262.  
  263. CGA_REP_MOVSW_ADDSI2_LOOP   ENDP                                        ;@P1
  264.  
  265.         PUBLIC  CGA_REP_LODSB_STOSW_LOOP                                ;@P1
  266. CGA_REP_LODSB_STOSW_LOOP    PROC    FAR                                 ;@P1
  267.  
  268. ;/*
  269. ;**  If CGA adapter was identified as FAST during BVH initialization,   
  270. ;**  don't need retrace logic -- use direct data move.                  
  271. ;*/
  272.  
  273.         push    ds                                                      ;MS01
  274.         push    ax                                                      ;MS01
  275.         mov     ax,seg _OEMFlags                                        ;MS01
  276.         mov     ds,ax                                                   ;MS01
  277.         test    ds:word ptr[_OEMFlags],FAST_CGA                         ;MS01
  278.         pop     ax                                                      ;MS01
  279.         pop     ds                                                      ;MS01
  280.         .if     <nz>                                                    ;MS01
  281.             .repeat                                                     ;MS01
  282.                 lodsb                                                   ;MS01
  283.                 stosw                                                   ;MS01
  284.             .loop                                                       ;MS01
  285.             ret                                                         ;MS01
  286.         .endif                                                          ;MS01
  287.  
  288. ;/*
  289. ;**  CGA is slow -- need retrace logic:                  
  290. ;*/
  291.  
  292.         push    bx                      ;                               ;@P1
  293.         push    dx                      ;                               ;@P1
  294.         mov     dx, STATUS_PORT         ; Setup CGA retrace status port ;@P1
  295.         test    cl, 1                   ;                               ;@P1
  296.         .if     <nz>                    ; Odd byte?                     ;@P1
  297.             HORZWAIT                    ; Wait for horizontal retrace   ;@P1
  298.             lodsb                       ; Get character from DS:SI      ;@P1
  299.             stosw                       ; Transfer the attribute        ;@P1
  300.             sti                         ; Enable interrupts             ;@P1
  301.         .endif                          ;                               ;@P1
  302.         shr     cx, 1                   ; Setup to move 2 bytes         ;@P1
  303.         .if     <ncxz>                  ;                               ;@P1
  304.             mov     bx, ax              ; BH = Attribute                ;@P1
  305.             .repeat                     ;                               ;@P1
  306.                 HORZWAIT                ; Wait for horizontal retrace   ;@P1
  307.                 mov     ax, bx          ; AH = Attribute byte           ;@P1
  308.                 lodsb                   ; Get 1st character from DS:SI  ;@P1
  309.                 stosw                   ; Transfer the 1st cell         ;@P1
  310.                 lodsb                   ; Get 2nd character from DS:SI  ;@P1
  311.                 stosw                   ; Transfer the 2nd cell         ;@P1
  312.                 sti                     ; Enable interrupts             ;@P1
  313.             .loop                       ;                               ;@P1
  314.         .endif                          ;                               ;@P1
  315.         pop     dx                      ;                           @T37,@P1
  316.         pop     bx                      ;                           @T37,@P1
  317.         ret                             ;                               ;@P1
  318.  
  319. CGA_REP_LODSB_STOSW_LOOP    ENDP                                        ;@P1
  320.  
  321.         PUBLIC  CGA_REP_MOVSW_STOSW_LOOP                                ;@P1
  322. CGA_REP_MOVSW_STOSW_LOOP    PROC    FAR                                 ;@P1
  323.  
  324. ;/*
  325. ;**  If CGA adapter was identified as FAST during BVH initialization,
  326. ;**  don't need retrace logic -- use direct data move.
  327. ;*/
  328.  
  329.         push    ds                                                      ;MS01
  330.         push    ax                                                      ;MS01
  331.         mov     ax,seg _OEMFlags                                        ;MS01
  332.         mov     ds,ax                                                   ;MS01
  333.         test    ds:word ptr[_OEMFlags],FAST_CGA                         ;MS01
  334.         pop     ax                                                      ;MS01
  335.         pop     ds                                                      ;MS01
  336.         .if     <nz>                                                    ;MS01
  337.             .repeat                                                     ;MS01
  338.                 movsw                                                   ;MS01
  339.                 stosw                                                   ;MS01
  340.             .loop                                                       ;MS01
  341.             ret                                                         ;MS01
  342.         .endif                                                          ;MS01
  343.  
  344. ;/*
  345. ;**  CGA is slow -- need retrace logic:                             
  346. ;*/
  347.  
  348.         push    bx                      ;                               ;@P1
  349.         push    dx                      ;                               ;@P1
  350.         mov     dx, STATUS_PORT         ; Setup CGA retrace status port ;@P1
  351.         test    cl, 1                   ;                               ;@P1
  352.         mov     bx, ax                  ; BH = Final word of cell       ;@P1
  353.         .if     <nz>                    ; Odd byte?                     ;@P1
  354.             HORZWAIT                    ; Wait for horizontal retrace   ;@P1
  355.             movsw                       ; Get character from DS:SI      ;@P1
  356.             stosw                       ; Transfer the attribute        ;@P1
  357.             sti                         ; Enable interrupts             ;@P1
  358.         .endif                          ;                               ;@P1
  359.         shr     cx, 1                   ; Setup to move 2 bytes         ;@P1
  360.         .if     <ncxz>                  ;                               ;@P1
  361.             .repeat                     ;                               ;@P1
  362.                 HORZWAIT                ; Wait for horizontal retrace   ;@P1
  363.                 mov     ax, bx          ; AH = Attribute byte           ;@P1
  364.                 movsw                   ; Get 1st character from DS:SI  ;@P1
  365.                 stosw                   ; Transfer the 1st cell         ;@P1
  366.                 movsw                   ; Get 2nd character from DS:SI  ;@P1
  367.                 stosw                   ; Transfer the 2nd cell         ;@P1
  368.                 sti                     ; Enable interrupts             ;@P1
  369.             .loop                       ;                               ;@P1
  370.         .endif                          ;                               ;@P1
  371.         pop     dx                      ;                           @T37,@P1
  372.         pop     bx                      ;                           @T37,@P1
  373.         ret                             ;                               ;@P1
  374.  
  375. CGA_REP_MOVSW_STOSW_LOOP    ENDP                                        ;@P1
  376.  
  377.         PUBLIC  CGA_REP_MOVSW                                           ;@P1
  378. CGA_REP_MOVSW   PROC    FAR                                             ;@P1
  379.  
  380. ;/*
  381. ;**  If CGA adapter was identified as FAST during BVH initialization,
  382. ;**  don't need retrace logic -- use direct data move.
  383. ;*/
  384.  
  385.         push    ds                                                      ;MS01
  386.         push    ax                                                      ;MS01
  387.         mov     ax,seg _OEMFlags                                        ;MS01
  388.         mov     ds,ax                                                   ;MS01
  389.         test    ds:word ptr[_OEMFlags],FAST_CGA                         ;MS01
  390.         pop     ax                                                      ;MS01
  391.         pop     ds                                                      ;MS01
  392.         .if     <nz>                                                    ;MS01
  393.             rep     movsw                                               ;MS01
  394.             ret                                                         ;MS01
  395.         .endif                                                          ;MS01
  396.  
  397. ;/*
  398. ;**  CGA is slow -- need retrace logic:                            
  399. ;*/
  400.  
  401.         push    ax                      ; 
  402.         push    dx                      ; 
  403.         mov     dx, STATUS_PORT         ; Setup CGA retrace status port
  404.         .repeat                         ; 
  405.             ALLWAIT                     ; Wait for horizontal retrace
  406.             movsw                       ; Transfer 1 word
  407.             dec     cx                  ; Adjust transfer count
  408.             .repeat                     ; 
  409.                 in      al, dx          ; 
  410.                 test    al, 1           ; 
  411.             .leave  <z>                 ; Retraces have passed?
  412.                 test    al, 8           ; 
  413.                 .if     <nz>            ; Vertical retrace has begun?
  414.                     mov     ax, 312     ; 
  415.                     .if     <ax a cx>   ; 
  416.                         mov     ax, cx  ; 
  417.                     .endif              ; 
  418.                     sub     cx, ax      ; 
  419.                     push    cx          ; 
  420.                     mov     cx, ax      ; 
  421.                     rep     movsw       ; 
  422.                     pop     cx          ; 
  423.             .leave                      ; 
  424.                 .endif                  ; 
  425.             .until                      ; 
  426.             sti                         ; Enable interrupts
  427.             or      cx, cx              ; 
  428.         .until  <z>                     ; 
  429.         pop    dx                       ; 
  430.         pop    ax                       ; 
  431.         ret                             ; 
  432.  
  433. CGA_REP_MOVSW   ENDP                                                    ;@P1
  434.  
  435.         PUBLIC  CGA_REP_STOSB_INCDI_LOOP                                ;@P1
  436. CGA_REP_STOSB_INCDI_LOOP    PROC    FAR                                 ;@P1
  437.  
  438. ;/*
  439. ;**  If CGA adapter was identified as FAST during BVH initialization,
  440. ;**  don't need retrace logic -- use direct data move.
  441. ;*/
  442.  
  443.         push    ds                                                      ;MS01
  444.         push    ax                                                      ;MS01
  445.         mov     ax,seg _OEMFlags                                        ;MS01
  446.         mov     ds,ax                                                   ;MS01
  447.         test    ds:word ptr[_OEMFlags],FAST_CGA                         ;MS01
  448.         pop     ax                                                      ;MS01
  449.         pop     ds                                                      ;MS01
  450.         .if     <nz>                                                    ;MS01
  451.             .repeat                                                     ;MS01
  452.                 stosb                                                   ;MS01
  453.                 inc     di                                              ;MS01
  454.             .loop                                                       ;MS01
  455.             ret                                                         ;MS01
  456.         .endif                                                          ;MS01
  457.  
  458. ;/*
  459. ;**  CGA is slow -- need retrace logic:                                    ;MS01
  460. ;*/
  461.  
  462.         push    ax                      ; 
  463.         push    dx                      ; 
  464.         push    si                      ; 
  465.         mov     si, ax                  ; SI = character or attribute
  466.         mov     dx, STATUS_PORT         ; Setup CGA retrace status port
  467.         test    cl, 1                   ; 
  468.         .if     <nz>                    ; Odd byte?
  469.             HORZWAIT                    ; Wait for horizontal retrace
  470.             mov     ax, si              ; 
  471.             stosb                       ; Transfer 1 byte
  472.             sti                         ; Enable interrupts
  473.             inc     di                  ; 
  474.         .endif                          ; 
  475.         shr     cx, 1                   ; Setup to move 2 bytes
  476.         .if     <ncxz>                  ; More to transfer?
  477.             .repeat                     ; 
  478.                 HORZWAIT                ; Wait for horizontal retrace
  479.                 mov     ax, si          ; Restore attribute byte
  480.                 stosb                   ; 
  481.                 inc     di              ; 
  482.                 stosb                   ; 
  483.                 sti                     ; Enable interrupts
  484.                 inc     di              ; 
  485.             .loop                       ; 
  486.         .endif                          ; 
  487.         pop     si                      ; 
  488.         pop     dx                      ; 
  489.         pop     ax                      ; 
  490.         ret                             ; 
  491.  
  492. CGA_REP_STOSB_INCDI_LOOP    ENDP                                        ;@P1
  493.  
  494.         PUBLIC  CGA_REP_INCDI_STOSB_LOOP                                ;@P1
  495. CGA_REP_INCDI_STOSB_LOOP    PROC    FAR                                 ;@P1
  496.  
  497. ;/*
  498. ;**  If CGA adapter was identified as FAST during BVH initialization,
  499. ;**  don't need retrace logic -- use direct data move.
  500. ;*/
  501.  
  502.         push    ds                                                      ;MS01
  503.         push    ax                                                      ;MS01
  504.         mov     ax,seg _OEMFlags                                        ;MS01
  505.         mov     ds,ax                                                   ;MS01
  506.         test    ds:word ptr[_OEMFlags],FAST_CGA                         ;MS01
  507.         pop     ax                                                      ;MS01
  508.         pop     ds                                                      ;MS01
  509.         .if     <nz>                                                    ;MS01
  510.             .repeat                                                     ;MS01
  511.                 inc     di                                              ;MS01
  512.                 stosb                                                   ;MS01
  513.             .loop                                                       ;MS01
  514.             ret                                                         ;MS01
  515.         .endif                                                          ;MS01
  516.  
  517. ;/*
  518. ;**  CGA is slow -- need retrace logic:                                
  519. ;*/
  520.  
  521.         push    ax                      ;                               ;@P1
  522.         push    dx                      ;                               ;@P1
  523.         push    si                      ;                               ;@P1
  524.         mov     si, ax                  ; SI = character or attribute   ;@P1
  525.         mov     dx, STATUS_PORT         ; Setup CGA retrace status port ;@P1
  526.         test    cl, 1                   ;                               ;@P1
  527.         .if     <nz>                    ; Odd byte?                     ;@P1
  528.             inc     di                  ;                               ;@P1
  529.             HORZWAIT                    ; Wait for horizontal retrace   ;@P1
  530.             mov     ax, si              ;                               ;@P1
  531.             stosb                       ; Transfer 1 byte               ;@P1
  532.             sti                         ; Enable interrupts             ;@P1
  533.         .endif                          ;                               ;@P1
  534.         shr     cx, 1                   ; Setup to move 2 bytes         ;@P1
  535.         .if     <ncxz>                  ; More to transfer?             ;@P1
  536.             .repeat                     ;                               ;@P1
  537.                 inc     di              ;                               ;@P1
  538.                 HORZWAIT                ; Wait for horizontal retrace   ;@P1
  539.                 mov     ax, si          ; Restore attribute byte        ;@P1
  540.                 stosb                   ;                               ;@P1
  541.                 inc     di              ;                               ;@P1
  542.                 stosb                   ;                               ;@P1
  543.                 sti                     ; Enable interrupts             ;@P1
  544.             .loop                       ;                               ;@P1
  545.         .endif                          ;                               ;@P1
  546.         pop     si                      ;                               ;@P1
  547.         pop     dx                      ;                               ;@P1
  548.         pop     ax                      ;                               ;@P1
  549.         ret                             ;                               ;@P1
  550.  
  551. CGA_REP_INCDI_STOSB_LOOP    ENDP                                        ;@P1
  552.  
  553.         PUBLIC  CGA_REP_STOSW                                           ;@P1
  554. CGA_REP_STOSW   PROC    FAR                                             ;@P1
  555.  
  556. ;/*
  557. ;**  If CGA adapter was identified as FAST during BVH initialization,
  558. ;**  don't need retrace logic -- use direct data move.
  559. ;*/
  560.  
  561.         push    ds                                                      ;MS01
  562.         push    ax                                                      ;MS01
  563.         mov     ax,seg _OEMFlags                                        ;MS01
  564.         mov     ds,ax                                                   ;MS01
  565.         test    ds:word ptr[_OEMFlags],FAST_CGA                         ;MS01
  566.         pop     ax                                                      ;MS01
  567.         pop     ds                                                      ;MS01
  568.         .if     <nz>                                                    ;MS01
  569.             rep     stosw                                               ;MS01
  570.             ret                                                         ;MS01
  571.         .endif                                                          ;MS01
  572.  
  573. ;/*
  574. ;**  CGA is slow -- need retrace logic:
  575. ;*/
  576.  
  577.         push    ax                      ; 
  578.         push    bx                      ; 
  579.         push    dx                      ; 
  580.         push    si                      ; 
  581.         mov     si, ax                  ; SI = char/attr pair
  582.         mov     dx, STATUS_PORT         ; Setup CGA retrace status port
  583.         test    cl, 1                   ; 
  584.         .if     <nz>                    ; Odd byte?
  585.             HORZWAIT                    ; Wait for horizontal retrace
  586.             mov     ax, si              ; Get char/attr pair
  587.             stosw                       ; 
  588.             sti                         ; Enable interrupts
  589.             dec     cx                  ; 
  590.         .endif                          ; 
  591.         .if     <ncxz>                  ; More to transfer?
  592.             .repeat                     ; 
  593.                 ALLWAIT                 ; 
  594.                 mov     ax, si          ; Restore Cell
  595.                 stosw                   ; 
  596.                 stosw                   ; 
  597.                 dec     cx              ; 
  598.                 dec     cx              ; 
  599.                 .repeat                 ; 
  600.                     in      al, dx      ; 
  601.                     test    al, 1       ; 
  602.                 .leave  <z>             ; Retraces have passed
  603.                     test    al, 8       ; 
  604.                     .if     <nz>        ; Vertical retrace has begun
  605.                         mov     bx, 624 ; 
  606.                         .if     <bx a cx>
  607.                             mov     bx, cx
  608.                         .endif          ; 
  609.                         sub     cx, bx  ; 
  610.                         push    cx      ; 
  611.                         mov     cx, bx  ; 
  612.                         mov     ax, si  ; 
  613.                         rep     stosw   ; 
  614.                         pop     cx      ; 
  615.                 .leave                  ; 
  616.                     .endif              ; 
  617.                 .until                  ; 
  618.                 sti                     ; Enable interrupts
  619.                 or      cx, cx          ; 
  620.             .until  <z>                 ; 
  621.         .endif                          ; 
  622.         pop     si                      ; 
  623.         pop     dx                      ; 
  624.         pop     bx                      ; 
  625.         pop     ax                      ; 
  626.         ret                             ; 
  627.  
  628. CGA_REP_STOSW   ENDP                                                    ;@P1
  629.  
  630. R2SEG   ENDS
  631.  
  632. ENDIF   ;NOT CGA_ALWAYS_FAST                                            ;MS00
  633.         END
  634.  
  635.