home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / source / chapter51 / l49-6.asm < prev    next >
Assembly Source File  |  1997-06-18  |  2KB  |  50 lines

  1. ; Shows the page at the specified offset in the bitmap. Page is displayed when 
  2. ; this routine returns. 
  3. ; Tested with TASM 4.0 by Jim Mischel 12/16/94.
  4. ; C near-callable as: void ShowPage(unsigned int StartOffset);
  5.  
  6. INPUT_STATUS_1  equ     03dah   ;Input Status 1 register
  7. CRTC_INDEX      equ     03d4h   ;CRT Controller Index reg
  8. START_ADDRESS_HIGH equ  0ch     ;bitmap start address high byte
  9. START_ADDRESS_LOW equ   0dh     ;bitmap start address low byte
  10.  
  11. ShowPageParms   struc
  12.         dw      2 dup (?) ;pushed BP and return address
  13. StartOffset dw  ?       ;offset in bitmap of page to display
  14. ShowPageParms   ends
  15.         .model  small
  16.         .code
  17.         public  _ShowPage
  18. _ShowPage       proc    near
  19.         push    bp      ;preserve caller's stack frame
  20.         mov     bp,sp   ;point to local stack frame
  21. ; Wait for display enable to be active (status is active low), to be
  22. ; sure both halves of the start address will take in the same frame.
  23.         mov     bl,START_ADDRESS_LOW        ;preload for fastest
  24.         mov     bh,byte ptr StartOffset[bp] ; flipping once display
  25.         mov     cl,START_ADDRESS_HIGH       ; enable is detected
  26.         mov     ch,byte ptr StartOffset+1[bp]
  27.         mov     dx,INPUT_STATUS_1
  28. WaitDE:
  29.         in      al,dx
  30.         test    al,01h
  31.         jnz     WaitDE  ;display enable is active low (0 = active)
  32. ; Set the start offset in display memory of the page to display.
  33.         mov     dx,CRTC_INDEX
  34.         mov     ax,bx
  35.         out     dx,ax   ;start address low
  36.         mov     ax,cx
  37.         out     dx,ax   ;start address high
  38. ; Now wait for vertical sync, so the other page will be invisible when
  39. ; we start drawing to it.
  40.         mov     dx,INPUT_STATUS_1
  41. WaitVS:
  42.         in      al,dx
  43.         test    al,08h
  44.         jz      WaitVS  ;vertical sync is active high (1 = active)
  45.         pop     bp      ;restore caller's stack frame
  46.         ret
  47. _ShowPage       endp
  48.         end
  49.  
  50.