home *** CD-ROM | disk | FTP | other *** search
/ Graphics Programming Black Book (Special Edition) / BlackBook.bin / disk1 / source / chapter25 / l25-3.asm < prev    next >
Assembly Source File  |  1997-06-18  |  4KB  |  112 lines

  1. ; Listing 3.3.
  2. ; Program to illustrate operation of set/reset circuitry to force
  3. ;  setting of memory that already contains data.
  4. ; Assembled with TASM 4.0, linked with TLINK 6.10
  5. ; Checked by Jim Mischel 11/21/94
  6. ;
  7. stack   segment para stack 'STACK'
  8.         db      512 dup(?)
  9. stack   ends
  10. ;
  11. EGA_VIDEO_SEGMENT       equ     0a000h  ;EGA display memory segment
  12. ;
  13. ; EGA register equates.
  14. ;
  15. SC_INDEX        equ     3c4h    ;SC index register
  16. SC_MAP_MASK     equ     2       ;SC map mask register
  17. GC_INDEX        equ     3ceh    ;GC index register
  18. GC_SET_RESET    equ     0       ;GC set/reset register
  19. GC_ENABLE_SET_RESET equ 1       ;GC enable set/reset register
  20. ;
  21. ; Macro to set indexed register INDEX of SC chip to SETTING.
  22. ;
  23. SETSC   macro   INDEX, SETTING
  24.         mov     dx,SC_INDEX
  25.         mov     al,INDEX
  26.         out     dx,al
  27.         inc     dx
  28.         mov     al,SETTING
  29.         out     dx,al
  30.         dec     dx
  31.         endm
  32. ;
  33. ; Macro to set indexed register INDEX of GC chip to SETTING.
  34. ;
  35. SETGC   macro   INDEX, SETTING
  36.         mov     dx,GC_INDEX
  37.         mov     al,INDEX
  38.         out     dx,al
  39.         inc     dx
  40.         mov     al,SETTING
  41.         out     dx,al
  42.         dec     dx
  43.         endm
  44. ;
  45. cseg    segment para public 'CODE'
  46.         assume  cs:cseg
  47. start   proc    near
  48. ;
  49. ; Select 640x480 graphics mode.
  50. ;
  51.         mov     ax,012h
  52.         int     10h
  53. ;
  54.         mov     ax,EGA_VIDEO_SEGMENT
  55.         mov     es,ax                   ;point to video memory
  56. ;
  57. ; Draw 24 10-scan-line high horizontal bars in green, 10 scan lines apart.
  58. ;
  59.         SETSC   SC_MAP_MASK,02h         ;map mask setting enables only
  60.                                         ; plane 1, the green plane
  61.         sub     di,di           ;start at beginning of video memory
  62.         mov     al,0ffh
  63.         mov     bp,24           ;# bars to draw
  64. HorzBarLoop:
  65.         mov     cx,80*10        ;# bytes per horizontal bar
  66.         rep stosb               ;draw bar
  67.         add     di,80*10        ;point to start of next bar
  68.         dec     bp
  69.         jnz     HorzBarLoop
  70. ;
  71. ; Fill screen with blue, using set/reset to force plane 0 to 1's and all
  72. ; other plane to 0's.
  73. ;
  74.         SETSC   SC_MAP_MASK,0fh         ;must set map mask to enable all
  75.                                         ; planes, so set/reset values can
  76.                                         ; be written to memory
  77.         SETGC   GC_ENABLE_SET_RESET,0fh ;CPU data to all planes will be
  78.                                         ; replaced by set/reset value
  79.         SETGC   GC_SET_RESET,01h        ;set/reset value is 0ffh for plane 0
  80.                                         ; (the blue plane) and 0 for other
  81.                                         ; planes
  82.         sub     di,di
  83.         mov     cx,80*480               ;# bytes per screen
  84.         mov     al,0ffh                 ;since set/reset is enabled for all
  85.                                         ; planes, the CPU data is ignored-
  86.                                         ; only the act of writing is
  87.                                         ; important
  88.         rep stosb                       ;perform fill (affects all planes)
  89. ;
  90. ; Turn off set/reset.
  91. ;
  92.         SETGC   GC_ENABLE_SET_RESET,0
  93. ;
  94. ; Wait for a keystroke.
  95. ;
  96.         mov     ah,1
  97.         int     21h
  98. ;
  99. ; Restore text mode.
  100. ;
  101.         mov     ax,03h
  102.         int     10h
  103. ;
  104. ; Exit to DOS.
  105. ;
  106.         mov     ah,4ch
  107.         int     21h
  108. start   endp
  109. cseg    ends
  110.         end     start
  111.  
  112.