Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Interrupts & Ports - Norton Guide http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]

        Port 3DA-R  -  Color/VGA Input Status register 1


        Read-only

                xxxx 1xxx  1=Vertical retrace in progress
                             When set to 1, This bit indicates a vertical
                             retrace interval.
                             VGA only: This bit can be programmed,
                             through the Vertical Retrace End register,
                             to generate an interrupt at the start of the
                             vertical retrace.
                xxxx x1xx  1=Light pen switched on (not VGA)
                xxxx xx1x  1=Light pen trigger set (not VGA)
                xxxx xxx1  0=Video enabled
                             This bit indicates that a horizontal retrace
                             is taking place right now. D

        On the Color/Graphics Adapter (NOT on the VGA or Monochrome
        adapter), the hardware don't like when itself and the CPU (8088
        or 80x86) is using the display RAM at the same time (it will cause
        "snow" on the screen). To prevent snow, all accesses must be done
        in one of the retrace periods.

                   The Cathode Ray
                +-------------------------------------------+
                |  + - - - - - - - - - - - - - - - - - - - -|- -   V
                |                                           |   |  E
                |  +-------------------------------------+  |      R
                |  + - - - - - - - - - - - - - - - - - - +  |   |  T
                |  +-------------------------------------+  |      I
                |  + - - - - - - - - - - - - - - - - - - +  |   |  C
                |  +-------------------------------------+  |      A
                |  + - - - - - - - - - - - - - - - - - - +  |   |  L R
                |  +-------------------------------------+  |        E
                |  + - - - - - - - - - - - - - - - - - - +  |   |    T
                |  +-------------------------------------+  |        R
                |  + - - - - - - - - - - - - - - - - - - +  |   |    A
                |           .HORIZONTAL RETRACE.            |        C
                |  +------------------------------------- - | - +    E
                +-------------------------------------------+
                   ----- Screen border
                   ----- Cathode Ray when it is "painting" on the
                         screen
                   - - - Cathode Ray when it isn't "painting" on
                         the screen

        When a program has to access display RAM, it is best to wait for
        Horizontal Retrace, since it occurs 100 times as often as Vertical
        Retrace. However, the Horizontal Retrace interval is short and
        therefore timing is critical. The following program will do the
        job:

                ; Assume character+attribute is in AX and
                ; DS:DI holds address in display RAM.

                mov     bx,ax        ; Store character for later use
                mov     dx,03DAh     ; Load 6845 status reg. addr.
             w1:
                in      al,dx        ; Get status!
                test    al,00000001b ; Is horizontal retrace in process?
                jnz     w1           ; Yes - wait until it isn't
                cli                  ; Don't want to be disturbed,
                                     ; because timing is critical
             w2:
                in      al,dx        ; Get status!
                test    al,00000001b ; Is horizontal retrace in process?
                jnz     w1           ; No - wait until it is.

                mov     ds:[di],bx   ; Store character in display RAM
                sti                  ; That's it!

See Also: 3BA-R

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson