home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 15 / CDACTUAL15.iso / cdactual / program / asm / PJGRAPH.ZIP / CHAP04.1 < prev    next >
Encoding:
Text File  |  1989-09-26  |  2.3 KB  |  74 lines

  1. ; Program to illustrate operation of Map Mask register when drawing
  2. ;  to memory that already contains data.
  3. ; Assembled with MASM 4.0, linked with LINK 3.51.
  4. ; By Michael Abrash, 4/26/87.
  5. ; Updated 6/25/89.
  6. ;
  7. stackseg        segment para stack 'STACK'
  8.         db      512 dup(?)
  9. stackseg        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 640x350 graphics mode.
  35. ;
  36.         mov     ax,010h
  37.         int     10h
  38. ;
  39.         mov     ax,EGA_VIDEO_SEGMENT
  40.         mov     es,ax                   ;point to video memory
  41. ;
  42. ; Draw 18 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,18           ;# 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 plane 0, the 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*350               ;# bytes per screen
  63.         mov     al,0ffh
  64.         rep stosb                       ;perform fill (affects only
  65.                                         ; plane 0, the blue plane)
  66. ;
  67. ; Exit to DOS. (Still in graphics mode; the MODE CO80 command
  68. ; can be used to restore the screen to text mode.)
  69. ;
  70.         mov     ah,4ch
  71.         int     21h
  72. start   endp
  73. cseg    ends
  74.         end     start