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

  1. ; Program to illustrate operation of set/reset circuitry to force
  2. ;  setting to 0 of 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. 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 640x350 graphics mode.
  50. ;
  51.         mov     ax,010h
  52.         int     10h
  53. ;
  54.         mov     ax,EGA_VIDEO_SEGMENT
  55.         mov     es,ax                   ;point to video memory
  56. ;
  57. ; Draw 18 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,18           ;# 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 1s and all
  72. ; other plane to 0s.
  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
  80.                                         ; plane 0 (the blue plane)
  81.                                         ; and 0 for other planes
  82.         sub     di,di
  83.         mov     cx,80*350               ;# bytes per screen
  84.         mov     al,0ffh                 ;since set/reset is enabled for
  85.                                         ; all planes, the CPU data is
  86.                                         ; ignored--only the act of
  87.                                         ; writing is 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. ; Exit to DOS. (Still in graphics mode; the MODE CO80 command
  95. ; can be used to restore the screen to text mode.)
  96. ;
  97.         mov     ah,4ch
  98.         int     21h
  99. start   endp
  100. cseg    ends
  101.         end     start