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

  1. ; Listing 3.2.
  2. ; Program to illustrate operation of Map Mask register when drawing
  3. ;  to 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. ;
  18. ; Macro to set indexed register INDEX of SC chip to SETTING.
  19. ;
  20. SETSC   macro   INDEX, SETTING
  21.         mov     dx,SC_INDEX
  22.         mov     al,INDEX
  23.         out     dx,al
  24.         inc     dx
  25.         mov     al,SETTING
  26.         out     dx,al
  27.         dec     dx
  28.         endm
  29. ;
  30. cseg    segment para public 'CODE'
  31.         assume  cs:cseg
  32. start   proc    near
  33. ;
  34. ; Select 640x480 graphics mode.
  35. ;
  36.         mov     ax,012h
  37.         int     10h
  38. ;
  39.         mov     ax,EGA_VIDEO_SEGMENT
  40.         mov     es,ax                   ;point to video memory
  41. ;
  42. ; Draw 24 10-scan-line high horizontal bars in green, 10 scan lines apart.
  43. ;
  44.         SETSC   SC_MAP_MASK,02h         ;map mask setting enables only
  45.                                         ; plane 1, the green plane
  46.         sub     di,di           ;start at beginning of video memory
  47.         mov     al,0ffh
  48.         mov     bp,24           ;# bars to draw
  49. HorzBarLoop:
  50.         mov     cx,80*10        ;# bytes per horizontal bar
  51.         rep stosb               ;draw bar
  52.         add     di,80*10        ;point to start of next bar
  53.         dec     bp
  54.         jnz     HorzBarLoop
  55. ;
  56. ; Fill screen with blue, using Map Mask register to enable writes
  57. ; to blue plane only.
  58. ;
  59.         SETSC   SC_MAP_MASK,01h         ;map mask setting enables only
  60.                                         ; plane 0, the blue plane
  61.         sub     di,di
  62.         mov     cx,80*480               ;# bytes per screen
  63.         mov     al,0ffh
  64.         rep stosb                       ;perform fill (affects only
  65.                                         ; plane 0, the blue plane)
  66. ;
  67. ; Wait for a keystroke.
  68. ;
  69.         mov     ah,1
  70.         int     21h
  71. ;
  72. ; Restore text mode.
  73. ;
  74.         mov     ax,03h
  75.         int     10h
  76. ;
  77. ; Exit to DOS.
  78. ;
  79.         mov     ah,4ch
  80.         int     21h
  81. start   endp
  82. cseg    ends
  83.         end     start
  84.  
  85.