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

  1. ; Program to illustrate operation of set/reset circuitry in conjunction
  2. ;  with CPU data to perform two-color modification of memory that
  3. ;  already contains data.
  4. ; Assembled with MASM 4.0, linked with LINK 3.51.
  5. ; By Michael Abrash, 4/26/87.
  6. ; Updated 6/25/89.
  7. ;
  8. stackseg        segment para stack 'STACK'
  9.         db      512 dup(?)
  10. stackseg        ends
  11. ;
  12. EGA_VIDEO_SEGMENT       equ     0a000h  ;EGA display memory segment
  13. ;
  14. ; EGA register equates.
  15. ;
  16. SC_INDEX        equ     3c4h    ;SC index register
  17. SC_MAP_MASK     equ     2       ;SC map mask register
  18. GC_INDEX        equ     3ceh    ;GC index register
  19. GC_SET_RESET    equ     0       ;GC set/reset register
  20. GC_ENABLE_SET_RESET equ 1       ;GC enable set/reset register
  21. ;
  22. ; Macro to set indexed register INDEX of SC chip to SETTING.
  23. ;
  24. SETSC   macro   INDEX, SETTING
  25.         mov     dx,SC_INDEX
  26.         mov     al,INDEX
  27.         out     dx,al
  28.         inc     dx
  29.         mov     al,SETTING
  30.         out     dx,al
  31.         dec     dx
  32.         endm
  33. ;
  34. ; Macro to set indexed register INDEX of GC chip to SETTING.
  35. ;
  36. SETGC   macro   INDEX, SETTING
  37.         mov     dx,GC_INDEX
  38.         mov     al,INDEX
  39.         out     dx,al
  40.         inc     dx
  41.         mov     al,SETTING
  42.         out     dx,al
  43.         dec     dx
  44.         endm
  45. ;
  46. cseg    segment para public 'CODE'
  47.         assume  cs:cseg
  48. start   proc    near
  49. ;
  50. ; Select 640x350 graphics mode.
  51. ;
  52.         mov     ax,010h
  53.         int     10h
  54. ;
  55.         mov     ax,EGA_VIDEO_SEGMENT
  56.         mov     es,ax                  ;point to video memory
  57. ;
  58. ; Draw 18 10-scan-line high horizontal bars in green, 10 scan lines apart.
  59. ;
  60.         SETSC   SC_MAP_MASK,02h         ;map mask setting enables only
  61.                                         ; plane 1, the green plane
  62.         sub     di,di           ;start at beginning of video memory
  63.         mov     al,0ffh
  64.         mov     bp,18           ;# bars to draw
  65. HorzBarLoop:
  66.         mov     cx,80*10        ;# bytes per horizontal bar
  67.         rep stosb               ;draw bar
  68.         add     di,80*10        ;point to start of next bar
  69.         dec     bp
  70.         jnz     HorzBarLoop
  71. ;
  72. ; Fill screen with alternating bars of red and brown, using CPU data
  73. ; to set plane 1 and set/reset to set planes 0, 2, & 3.
  74. ;
  75.         SETSC   SC_MAP_MASK,0fh         ;must set map mask to enable all
  76.                                         ; planes, so set/reset values can
  77.                                         ; be written to planes 0, 2, & 3
  78.                                         ; and CPU data can be written to
  79.                                         ; plane 1 (the green plane)
  80.         SETGC   GC_ENABLE_SET_RESET,0dh ;CPU data to planes 0, 2, & 3
  81.                                         ; will be replaced by set/reset
  82.                                         ; value
  83.         SETGC   GC_SET_RESET,04h        ;set/reset value is 0ffh for
  84.                                         ; plane 2 (the red plane) and
  85.                                         ; 0 for other planes
  86.         sub     di,di
  87.         mov     cx,80*350/2             ;# words per screen
  88.         mov     ax,07e0h                ;CPU data controls only plane 1;
  89.                                         ; set/reset controls other planes
  90.         rep stosw                       ;perform fill (affects all planes)
  91. ;
  92. ; Turn off set/reset.
  93. ;
  94.         SETGC   GC_ENABLE_SET_RESET,0
  95. ;
  96. ; Exit to DOS. (Still in graphics mode; the MODE CO80 command
  97. ; can be used to restore the screen to text mode.)
  98. ;
  99.         mov     ah,4ch
  100.         int     21h
  101. start   endp
  102. cseg    ends
  103.         end     start