80 lines
1.6 KiB
Plaintext
80 lines
1.6 KiB
Plaintext
; File: hacks.a
|
|
;
|
|
; These are some assembly language hacks to speed things up
|
|
; a bit.
|
|
|
|
|
|
; This one uses the fmod instruction to compute the color
|
|
; value.
|
|
;
|
|
; unsigned char __asm getColor(register __fp0 double zValue)
|
|
;
|
|
; This is to be called from the loop in makeBytemap.
|
|
; We assume that floating point registers have been set up
|
|
; as follows:
|
|
;
|
|
; fp1 = zMin
|
|
; fp2 = zMax
|
|
; fp3 = deltaZ
|
|
;
|
|
; Color spectrum is 2-15 and 18-31 with 1 as undercolor and 16
|
|
; as overcolor. Colors 0 and 17 are reserved for other use, namely
|
|
; background and pointer.
|
|
|
|
xdef _getColor
|
|
xdef _loadMinMax
|
|
xdef _loadY
|
|
|
|
section CODE
|
|
|
|
_getColor:
|
|
|
|
fcmp.x fp2,fp0
|
|
fbge.w toobig
|
|
fsub.x fp1,fp0
|
|
fblt.w toosmall
|
|
fmod.x fp3,fp0
|
|
fmove.l fpsr,d0
|
|
swap d0
|
|
andi #255,d0
|
|
addq #2,d0
|
|
cmpi #16,d0
|
|
blt done
|
|
addi #2,d0
|
|
done:
|
|
rts
|
|
|
|
toobig:
|
|
moveq #16,d0 ; OVERCOLOR = 16
|
|
rts
|
|
|
|
toosmall:
|
|
moveq #1,d0 ; UNDERCOLOR = 1
|
|
rts
|
|
|
|
|
|
|
|
; Here is a way to get the registers set up. We declare a function
|
|
; void __asm loadMinMax(register __fp1 double zMin,
|
|
; register __fp2 double zMax,
|
|
; register __fp3 double deltaZ);
|
|
; that does nothing except return.
|
|
|
|
|
|
_loadMinMax:
|
|
rts
|
|
|
|
; The evaluation function assumes that x and y have been loaded into
|
|
; fp5 and fp6. But it is silly to pass both as register arguments
|
|
; because we compute across rows, so y does not change until the end
|
|
; of the row. If we declare this as
|
|
; void __asm loadY(register __fp6 double Y);
|
|
; it allows us to load y into fp6;
|
|
|
|
_loadY:
|
|
rts
|
|
|
|
END
|
|
|
|
|