[net.sources.mac] D'Lab: QPlot.asm

maclab@reed.UUCP (Mac DLab) (12/20/85)

High Speed Plotting Routines
----------------------------

Below you will find a slick piece of 68000 code (Lisa assembler, 
but translation to MDS6800 is a piece of cake) -- these routines will
blast black or white dots on your Macintosh screen *very* quickly.

The procedures qplotblack and qplotwhite are called like so, from
Rascal:
  QPlotWhite(x,y);
  QPlotBlack(x,y);

The x and y are in global coordinates.  You must make sure not
to draw on a non-sceen position -- it is possible to plot right
into other parts of memory with these routines.


--------------------------------------------------------------------------

Happy Holidays from the Reed Academic Software Development Laboratory!

  Richard Crandall
  Marianne Colgrove
  Josh Doenias
  Scott Gillespie
  Michael McGreevy
  Greg Stein (in absentia)
  Ann Muir Thomas
   and :-)

  "That's what he *does*. That's *all* he does." (Sgt. Kyle Reese, Tech Com).

{decvax, ucbvax, pur-ee, uw-beaver, masscomp, cbosg, aat,
 mit-ems, psu-cs, uoregon, orstcs, ihnp4, uf-cgrl, ssc-vax}!tektronix 
								\
						                 +--!reed!maclab 
{teneron, ogcvax, muddcs, cadic, oresoft, grpwre,     		/
 	  harvard, psu-cs, omen, isonvax, nsc-pdc}-------------+

------------------------------------------------------------------------------
;
; High-speed plotting
;
; Written by Greg Stein
;   84.09.27.gjs
;   85.12.10.spg --- Made compatible with all mac configurations.
;
; Procedure QPlotWhite(x,y : integer);
; Procedure QPlotBlack(x,y : Integer);
;


ScreenBase   .EQU   $824         ; top of screen screen address
ScreenRow    .EQU   $106         ; screen rowbytes


          .PROC QPlotWhite

          move.l    (sp)+,a1     ; save return address
          move.w    (sp)+,d0     ; y value
          move.w    (sp)+,d1     ; x value

          ext.l     d0               ; clear upper bits
          muls      ScreenRow,d0 ; multiply y by 64 to find line base

          move.w    d1,d2
          and.w     #$07,d2        ; obtain bit number
          move.b    WhiteTable(d2),d2   ; get mask bits

          move.l    ScreenBase,a0  ; get screen base

          lsr.w     #$3,d1   ; divide x by 8 to obtain byte offset
          add.w     d1,a0   ; add x byte offset to line base

          and.b     d2,0(a0,d0)

          jmp       (a1)   ; done, return

WhiteTable:
          .byte    $7f, $bf, $df, $ef, $f7, $fb, $fd, $fe



          .PROC QPlotBlack

          move.l    (sp)+,a1   ; save return address
          move.w    (sp)+,d0   ; y value
          move.w    (sp)+,d1   ; x value

          ext.l     d0   ; clear upper bits
          muls      screenRow,d0 ; multiply y by 64 to find line base

          move.w    d1,d2
          and.w     #$07,d2        ; obtain bit number
          move.b    BlackTable(d2),d2   ; get mask bits

          move.l    ScreenBase,a0  ; get screen base

          lsr.w     #$3,d1   ; divide x by 8 to obtain byte offset
          add.w     d1,a0   ; add x byte offset to line base

          or.b      d2,0(a0,d0)

          jmp       (a1)   ; done, return

BlackTable:
          .byte    $80, $40, $20, $10, $08, $04, $02, $01


          .end