home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 14 / CDACTUAL.iso / cdactual / demobin / share / program / asm / RTGRAF.ZIP / SOURCE.ZIP / EPIXRT.ASM < prev    next >
Encoding:
Assembly Source File  |  1990-06-30  |  6.2 KB  |  189 lines

  1. ;========================================================================
  2. ; PIXEL_SET    set the pixel at given X,Y to the supplied color
  3. ;
  4. ;
  5. ; small model parms
  6. ;X              EQU     [BP+4]
  7. ;Y              EQU     [BP+6]
  8. ;COLOR          EQU     [BP+8]
  9. ; large model parms
  10. pX              EQU     [BP+6]
  11. pY              EQU     [BP+8]
  12. pCOLOR          EQU     [BP+10]
  13.  
  14.         PUBLIC  _Pix_Set
  15.  
  16. _pix_set      Proc far
  17.         push    bp
  18.         mov     bp,sp
  19.         push    es
  20.         push    bx
  21.         push    si
  22.         push    di
  23.         ;
  24.         ; figure out address of this pixel
  25.         ;
  26.         mov     cx,pX       ;set X coordinate
  27.         mov     bx,pY       ;set Y value
  28.         call    emapxy      ;di = offset
  29.         mov     es,_curr_vid_seg
  30.  
  31.         mov     dx,GRAPHIC12
  32.         ;
  33.         ; enable set/reset mode
  34.         ; then load reset register
  35.         ;
  36.         mov     al,SETRESET ;set SET/RESET register
  37.         out     dx,al
  38.         inc     dx          ;now data register
  39.  
  40.         mov     al,pCOLOR   ;what color was requested?
  41.         out     dx,al       ;Set the active (set) bits
  42.                             ; that loaded the color into the SETRESET reg.
  43.         dec     dx          ;now back to control register
  44.  
  45.         mov     al,ENABLERESET ;defines which planes will be modified
  46.                                ; from the SETRESET register
  47.         out     dx,al       ;
  48.         inc     dx          ;and back to data register
  49.  
  50.         mov     al,0ffh     ;work with all 4 planes
  51.         out     dx,al       ;0ffh should activate all planes
  52.         dec     dx          ;back to control
  53.         ;
  54.         ; now we are ready to put the color out there
  55.         ;
  56.         ;
  57.         ; build a 1-bit mask for the requested pixel
  58.         ;
  59.         mov     cx,pX       ;get the offset within the scan line
  60.         and     cx,07h      ;mod 8 - give bit within byte
  61.         mov     bl,80h      ;a high bit in bl
  62.         shr     bl,cl       ;slide it down to make the mask
  63.         ;
  64.         ; save the other seven bits that we are not messing with
  65.         ; 0 = old latched data, 1=new processor data
  66.         ;
  67.         mov     al,BIT_MASK_REG; select the mask register
  68.         out     dx,al       ;
  69.         mov     al,bl       ;get the mask we built, use it to set the BIT_MASK_REG
  70.         inc     dx          ;up to data
  71.         out     dx,al       ;out it goes
  72.         dec     dx          ;back to control
  73.         ;
  74.         ; set the pixel to new color
  75.         ; while it looks like we are writing 'al' we really have
  76.         ;  set the registers so that the masked bit will be set from
  77.         ;  the SETREST register, for all planes, and all processor
  78.         ;  data is ignored.
  79.         ;
  80.         mov     al,es:[di]  ;read the old to keep all 8 bits
  81.         mov     es:[di],al  ;now set the new pixel color
  82.         ;
  83.         ; finally, put everything back into a known state
  84.         ;
  85.         mov     al,ENABLERESET
  86.         out     dx,al
  87.         inc     dx
  88.         mov     al,00h       ;clear all planes for SETRESET
  89.                              ; this means all data comes from processor
  90.                              ; write, not the SETREST register
  91.         out     dx,al
  92.         dec     dx           ;back at control
  93.  
  94.         mov     al,BIT_MASK_REG ;set all planes as active
  95.         out     dx,al
  96.         inc     dx           ;back to data
  97.         mov     al,0ffh      ;all bits in byte active
  98.         out     dx,al
  99.         dec     dx           ;back to control
  100.         ;
  101.         ; restore what we saved at the start
  102.         ;
  103.         pop     di
  104.         pop     si
  105.         pop     bx
  106.         pop     es
  107.         mov     sp,bp
  108.         pop     bp
  109.         ret
  110. _pix_set      endp
  111.  
  112.  
  113. ;========================================================================
  114. ; Read the color value at the specified X,y
  115. ;  and return it in AX
  116. ;
  117. ; small parms
  118. X       EQU     [BP+4]
  119. Y       EQU     [BP+6]
  120.  
  121. ; large parms
  122. pX      EQU     [BP+6]
  123. pY      EQU     [BP+8]
  124.  
  125.         PUBLIC  _Pix_Read
  126.  
  127. _pix_read  proc far
  128.         push    bp
  129.         mov     bp,sp
  130.         push    es
  131.         push    di
  132.  
  133.         ;
  134.         ; figure out address of this pixel
  135.         ;
  136.         mov     cx,pX       ;set X coordinate
  137.         mov     bx,pY       ;set Y value
  138.         call    emapxy      ;di = offset
  139.         ;
  140.         ; build a 1-bit mask for the requested pixel
  141.         ;
  142.         mov     cx,pX       ;get the offset within the scan line
  143.         and     cx,07h      ;mod 8 - give bit within byte
  144.         mov     bl,80h      ;a high bit in bl
  145.         shr     bl,cl       ;slide it down to make the mask
  146.  
  147.         mov     es,_curr_vid_seg
  148.         ;
  149.         ;set the plane counter in CX so that LOOP can be used
  150.         ;
  151.         mov     cx,4        ;CX will be the plane number 3,2,1,0
  152.                             ; start at 4, decrement value to use in AL
  153.                             ; but allows the use of the LOOP cmd to control
  154.                             ; and branch on CX
  155.         mov     dx,GRAPHIC12; pich controller
  156.         mov     al,READ_PLANE_SEL
  157.         out     dx,al
  158.         inc     dx          ;leave DX pointing to data register
  159.  
  160.         xor     bh,bh       ;clear the storage for the color
  161.  
  162. epx_plane:
  163.                             ;These two line dup the end of the READ_PLANE
  164.                             ; macro, but inside of the loop we do not
  165.                             ; need to select the GRAPGIC12 reg again.
  166.         mov     al,cl       ;which plane +1
  167.         dec     al          ;which plane
  168.         out     dx,al       ;select next plane
  169.         shl     bh,1        ;move prior data up a bit
  170.  
  171.         mov     ah,es:[di]  ;get video byte (8 bits) for plane
  172.         and     ah,bl       ;look at the pixel we want
  173.         jz      pix_0       ;is it a zero
  174.         or      bh,1        ;no-put a one in our result
  175. pix_0:
  176.         loop    epx_plane   ;decrements  CX and branches if not 0
  177.  
  178.         mov     al,bh       ;all done, return must be in AX
  179.         xor     ah,ah       ;clear top of AX
  180.         ;
  181.         ; reset what we messed with
  182.         ;
  183.         pop     di
  184.         pop     es                      ;Restore registers
  185.         mov     sp,bp
  186.         pop     bp
  187.         ret
  188. _pix_read     ENDP
  189.