home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / VOGLE.ZIP / VOGLE / DRIVERS / IBMPC / CGA_BUF.ASM next >
Assembly Source File  |  2000-02-11  |  1KB  |  106 lines

  1.     COMMENT    $
  2.  
  3.         Handles Double Buffering on the CGA.
  4.     $
  5.  
  6.         extrn    __buffer_segment:word
  7.         extrn    __buffer_offset:word
  8.  
  9.         public    _cga_swapbuf, _cga_frontbuf
  10.  
  11. CGAA_TEXT    SEGMENT    byte    public    'CODE'
  12.          ASSUME    cs:CGAA_TEXT
  13.  
  14.     COMMENT    $
  15.         Copies the RAM buffer to display buffer.
  16.     $
  17.  
  18. _cga_swapbuf    proc    far
  19.     push        bp
  20.     mov        bp, sp
  21.     sub        sp, 8
  22.  
  23.     push        es
  24.     push        ds
  25.     push        si
  26.     push        di
  27.  
  28.     mov        ax, 0b800h    
  29.     mov        es, ax        ; ES:DI -> video buffer
  30.     xor        di, di
  31.  
  32.     mov        ax, __buffer_segment
  33.     mov        ds, ax
  34.     mov        si, __buffer_offset    ; DS:SI -> buffer in RAM
  35.  
  36.     ;jmp        bonk
  37.  
  38.  
  39.     ; Wait for verticle blanking interval
  40.     mov        dx, 3DAh    ; CGA status port
  41. L01:
  42.     mov        cx, 22        ; HRT timeout val
  43. L02:    
  44.     in        al, dx
  45.     test        al, 8
  46.     jnz        L02
  47.     test        al, 1
  48.     jnz        L02
  49.  
  50.     cli
  51. L03:
  52.     in        al, dx
  53.     test        al, 1
  54.     loopnz        L03
  55.  
  56.     sti
  57.  
  58.     jz        L01
  59.     
  60.     ; Blank the display
  61.     mov        dl, 0D8h
  62.     mov        al, ((1 SHL 4) OR (1 SHL 5))
  63.     out        dx, al
  64.  
  65.     ; Move the data
  66.     mov        cx, 2000h        ; Size of buffer.
  67. bonk:
  68.     cld
  69.     rep        movsw 
  70.  
  71.     ; Reenable the Display
  72.  
  73.     or        al, (1 SHL 5)
  74.     out        dx, al
  75.  
  76.     pop        di
  77.     pop        si
  78.     pop        ds
  79.     pop        es
  80.     
  81.     mov        sp, bp
  82.     pop        bp
  83.     ret
  84. _cga_swapbuf        endp
  85.  
  86.  
  87.     COMMENT    $
  88.         Write into the screen buffer.
  89.     $
  90.  
  91. _cga_frontbuf    proc    far
  92.     push        bp
  93.     mov        bp, sp
  94.     
  95.     mov        __buffer_segment, 0b800h
  96.     mov        __buffer_offset, 0
  97.  
  98.     mov        sp, bp
  99.     pop        bp
  100.     ret
  101. _cga_frontbuf        endp
  102.  
  103. CGAA_TEXT        ends
  104.  
  105.             end
  106.