home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 500-599 / ff588.lza / MandelSquare / Source / Plot.asm < prev    next >
Assembly Source File  |  1992-01-04  |  3KB  |  110 lines

  1. ** Revision Header * Header built automatically - do not edit! *************
  2. *
  3. *    (C) Copyright 1991 by Olaf `Olsen' Barthel, all rights reserved
  4. *
  5. *    Name .....: Plot.asm
  6. *    Created ..: Monday 26-Aug-91 11:20
  7. *    Revision .: 1
  8. *
  9. *    Date            Author          Comment
  10. *    =========       ========        ====================
  11. *    26-Aug-91    Olsen        Created this file!
  12. *
  13. ****************************************************************************
  14.  
  15.     include    "graphics/gfx.i"
  16.  
  17.     csect    text,0,0,1,2
  18.  
  19.     xdef    _Plot
  20.     xdef    _Test
  21.  
  22. ;    VOID __asm Plot(register __a0 struct BitMap *,register __d0 WORD X,register __d1 WORD Y,register __d2 WORD Colour);
  23. ;
  24. ;        Fast pixel drawing routine, somewhat equivalent to
  25. ;    graphics.library/WritePixel.
  26. ;
  27. ;    Register usage is as follows:
  28. ;
  29. ;        d1    = Byte offset into bitplane
  30. ;        d2    = Pixel colour
  31. ;        d3    = Number of bitplanes
  32. ;        d4    = Line modulo/pixel number
  33. ;        a0    = Pointer to array of bitplanes
  34. ;        a1    = Pointer to bitplane
  35.  
  36. _Plot:    movem.l    d3/d4,-(sp)        ; Save registerrs
  37.  
  38.     moveq    #0,d4            ; Clear d3 & d4
  39.     move.l    d4,d3
  40.  
  41.     move.w    bm_BytesPerRow(a0),d4    ; Get line modulo
  42.     move.b    bm_Depth(a0),d3        ; Get bitmap depth
  43.     lea.l    bm_Planes(a0),a0    ; Get array of planes
  44.  
  45.     mulu.l    d4,d1            ; Multiply Y-position by modulo
  46.     move.l    d0,d4            ; Save X-position
  47.     lsr    #3,d0            ; Get byte offset of X-position 
  48.     add    d0,d1            ; Add byte offsets
  49.     not    d4            ; Get bit number
  50.     subq    #1,d3            ; One plane less (for dbra)
  51.  
  52. loop    move.l    (a0)+,a1        ; Get next plane
  53.     lsr.b    #1,d2            ; Clear or set the pixel?
  54.     bcc    clear
  55.     bset    d4,0(a1,d1)        ; Set pixel
  56.     dbra    d3,loop            ; Loop until all planes are done
  57.  
  58. exit    movem.l    (sp)+,d3/d4        ; Restore registers
  59.     rts
  60.  
  61. clear    bclr    d4,0(a1,d1)        ; Clear pixel
  62.     dbra    d3,loop            ; Loop until all planes are done
  63.     bra    exit
  64.  
  65. ;    BYTE __asm Test(register __a0 struct BitMap *,register __d0 WORD X,register __d1 WORD Y);
  66. ;
  67. ;        Fast pixel reading routine, somewhat equivalent to
  68. ;    graphics.library/ReadPixel, returns 1 if there is a pixel in
  69. ;    the given position in bitmap, else 0.
  70. ;
  71. ;    Register usage is as follows:
  72. ;
  73. ;        d1    = Byte offset into bitplane
  74. ;        d3    = Number of bitplanes
  75. ;        d4    = Line modulo/pixel number
  76. ;        a0    = Pointer to array of bitplanes
  77. ;        a1    = Pointer to bitplane
  78.  
  79. _Test:    movem.l    d3/d4,-(sp)        ; Save registerrs
  80.  
  81.     moveq    #0,d4            ; Clear d3 & d4
  82.     move.l    d4,d3
  83.  
  84.     move.w    bm_BytesPerRow(a0),d4    ; Get line modulo
  85.     move.b    bm_Depth(a0),d3        ; Get bitmap depth
  86.     lea.l    bm_Planes(a0),a0    ; Get array of planes
  87.  
  88.     mulu.l    d4,d1            ; Multiply Y-position by modulo
  89.     move.l    d0,d4            ; Save X-position
  90.     lsr    #3,d0            ; Get byte offset of X-position
  91.     add    d0,d1            ; Add byte offsets
  92.     not    d4            ; Get bit number
  93.     sub.w    #1,d3            ; One plane less (for dbra)
  94.     moveq    #0,d0            ; So we have valid return code
  95.  
  96. tloop    move.l    (a0)+,a1        ; Get next plane
  97.     btst    d4,0(a1,d1)        ; Is a pixel in this position?
  98.     bne.s    go            ; Yes, there is
  99.     dbra    d3,tloop        ; Test next plane
  100.  
  101.     movem.l    (sp)+,d3/d4        ; Restore registers
  102.     rts
  103.  
  104. go    moveq    #1,d0            ; Got a pixel
  105.  
  106.     movem.l    (sp)+,d3/d4        ; Restore registers
  107.     rts
  108.  
  109.     end
  110.