**-lh0-    )w)  Chunky\Conv24To8.assE; Conv24To8(d0:LONG)(L)

	machine	mc68020

	xdef	_Conv24To8

_Conv24To8
	move.l	d2,a0
	move.l	d0,d1
	move.l	d0,d2
	lsr.l	#8,d1
	lsr.l	#8,d2
	lsr.l	#8,d2
	and.l	#$ff,d0
	and.l	#$ff,d1
	and.l	#$ff,d2
	add.l	d1,d0
	add.l	d2,d0
	divs.l	#3,d0
	move.l	a0,d2
	rts
(-lh0-      -w) Chunky\Conv24To8.o|     Develop:Sources/PowerD/DStuff/Lib/Chunky/Conv24To8       CODE      B" $    ¼   ļ   ЁЂL|    $NuNq    _Conv24To8            --lh0-    V.*  Chunky\Conv24ToGrey.ass i; Conv24ToGrey(dst:a0:PTR TO chunky,src:a1:PTR TO chunky32)

	machine	mc68020

	xdef	_Conv24ToGrey
_Conv24ToGrey
	movem.l	d2-d3,-(a7)
	move.l	(4,a0),d2
	muls.l	(a0),d2		; d2 contains count of pixels
	move.l	(8,a0),a0		; dst8
	move.l	(8,a1),a1		; src32
.loop	move.l	(a1)+,d0

	move.l	d0,d1
	move.l	d0,d3
	lsr.l	#8,d1
	lsr.l	#8,d3
	lsr.l	#8,d3
	and.l	#$ff,d0
	and.l	#$ff,d1
	and.l	#$ff,d3
	add.l	d1,d0
	add.l	d3,d0
	divs.l	#3,d0

	move.b	d0,(a0)+
	subq.l	#1,d2
	bgt.s	.loop
	movem.l	(a7)+,d2-d3
	rts
+-lh0-      V.* Chunky\Conv24ToGrey.oy     Develop:Sources/PowerD/DStuff/Lib/Chunky/Conv24ToGrey        CODE     H0 $( L( h "i  " &    ¼   Ƽ   ЁЃL|    SnL NuNq    _Conv24ToGrey             +E-lh0-    I)  Chunky\CopyChunky.ass.; CopyChunky(dst:a0:PTR TO chunky,dx:d0:LONG,dy:d1:LONG,
;            src:a1:PTR TO chunky,sx:d2:LONG,sy:d3:LONG,
;            w:d4:LONG,h:d5:LONG)

	machine	mc68020

	xdef	_CopyChunky
_CopyChunky
	movem.l	d2-d7/a2-a3,-(a7)

; DESTINATION BOUNDS
	tst.l	d0		; left bound
	bge.s	.leftdone
	move.l	d0,d7			; store left negative offset
	neg.l	d7
	cmp.l	d4,d7
	bge.s	.finish			; out of bounds
	moveq	#0,d0			; left position
	add.l	d7,d2
	sub.l	d7,d4			; new width
.leftdone
	tst.l	d1		; top bound
	bge.s	.topdone
	move.l	d1,d7			; store top negative offset
	neg.l	d7
	cmp.l	d5,d7
	bge.s	.finish			; out of bounds
	moveq	#0,d1			; top position
	add.l	d7,d3
	sub.l	d7,d5			; new height
.topdone
	cmp.l	(a0),d0		; right bound
	bgt.s	.finish
	move.l	(a0),d7			; store maximal width
	sub.l	d0,d7			; change width
	cmp.l	d4,d7			; check if we can fit
	bgt.s	.rightdone		; we can fit
	move.l	d7,d4			; new width, we can't fit
.rightdone
	cmp.l	(4,a0),d1		; bottom bound
	bgt.s	.finish
	move.l	(4,a0),d7			; store maximal width
	sub.l	d1,d7			; change width
	cmp.l	d5,d7			; check if we can fit
	bgt.s	.bottomdone		; we can fit
	move.l	d7,d5			; new width, we can't fit
.bottomdone

	move.l	(a0),d6		; get dest width to d6
	muls.l	d1,d6
	add.l	d6,d0		; now we have start position in dest buffer
	move.l	(8,a0),a2
	add.l	d0,a2

	move.l	(a1),d6
	muls.l	d3,d6
	add.l	d6,d2
	move.l	(8,a1),a3
	add.l	d2,a3		; and start position in source buffer

	move.l	(a0),d2		; get the d2 and d3 values
	sub.l	d4,d2
	move.l	(a1),d3
	sub.l	d4,d3

	subq.l	#1,d4
	subq.l	#1,d5
	move.l	d4,d6		; store width
.loopy	move.l	d6,d4		; restore width
.loopx	move.b	(a3)+,(a2)+	; copy pixel
	dbra.s	d4,.loopx
	adda.l	d2,a2
	adda.l	d3,a3
	dbra.s	d5,.loopy
.finish	movem.l	(a7)+,d2-d7/a2-a3
	rts
)-lh0-      sn) Chunky\CopyChunky.o     Develop:Sources/PowerD/DStuff/Lib/Chunky/CopyChunky      CODE     "H?0Jl. Dlrp ԇJl.Dl`r ևnV.n( nF.( n*,LhІ$h ,LhԆ&i $&SS,(QQLNu    _CopyChunky           1(-lh0-    P)  Chunky\CopyChunkyBright.ass-; this function writes a coloured pixel into the chunky buffer and returns
; colour of pixel that was in these coords originaly

; CopyChunkyBright(a0:PTR TO chunky,d0,d1,a1:PTR TO chunky,d2,d3,d4,d5)

	machine	mc68020

	xdef	_CopyChunkyBright
_CopyChunkyBright
	movem.l	d2-d7/a2-a3,-(a7)

; DESTINATION BOUNDS
	tst.l	d0		; left bound
	bge.s	.leftdone
	move.l	d0,d7			; store left negative offset
	neg.l	d7
	cmp.l	d4,d7
	bge.s	.finish			; out of bounds
	moveq	#0,d0			; left position
	add.l	d7,d2
	sub.l	d7,d4			; new width
.leftdone
	tst.l	d1		; top bound
	bge.s	.topdone
	move.l	d1,d7			; store top negative offset
	neg.l	d7
	cmp.l	d5,d7
	bge.s	.finish			; out of bounds
	moveq	#0,d1			; top position
	add.l	d7,d3
	sub.l	d7,d5			; new height
.topdone
	cmp.l	(a0),d0		; right bound
	bgt.s	.finish
	move.l	(a0),d7			; store maximal width
	sub.l	d0,d7			; change width
	cmp.l	d4,d7			; check if we can fit
	bgt.s	.rightdone		; we can fit
	move.l	d7,d4			; new width, we can't fit
.rightdone
	cmp.l	(4,a0),d1		; bottom bound
	bgt.s	.finish
	move.l	(4,a0),d7			; store maximal width
	sub.l	d1,d7			; change width
	cmp.l	d5,d7			; check if we can fit
	bgt.s	.bottomdone		; we can fit
	move.l	d7,d5			; new width, we can't fit
.bottomdone

	move.l	(a0),d6		; get dest width to d6
	muls.l	d1,d6
	add.l	d6,d0		; now we have start position in dest buffer
	move.l	(8,a0),a2
	add.l	d0,a2

	move.l	(a1),d6
	muls.l	d3,d6
	add.l	d6,d2
	move.l	(8,a1),a3
	add.l	d2,a3		; and start position in source buffer

	move.l	(a0),d2		; get the d2 and d3 values
	sub.l	d4,d2
	move.l	(a1),d3
	sub.l	d4,d3

	subq.l	#1,d4
	subq.l	#1,d5
	move.l	d4,d6		; store width
.loopy	move.l	d6,d4		; restore width
.loopx	move.b	(a3)+,d0		; get brightness
	move.b	(a2),d1		; get destination colour
	move.l	d1,d7
	andi.b	#%11110000,d7	; store colour level
	andi.b	#%00001111,d1	; get colour index
	subq.b	#8,d0		; get central value
	add.b	d0,d1
	tst.b	d1
	ble.s	.zero
	cmp.b	#15,d1
	bge.s	.max
	move.b	d1,d0
	or.b	d7,d0
	bra.s	.goon
.max	moveq	#15,d0
	or.b	d7,d0
	bra.s	.goon
.zero	move.l	d7,d0
.goon	move.b	d0,(a2)+		; copy pixel
	dbra.s	d4,.loopx
	adda.l	d2,a2
	adda.l	d3,a3
	dbra.s	d5,.loopy
.finish	movem.l	(a7)+,d2-d7/a2-a3
	rts
/%-lh0-8  8  tn) Chunky\CopyChunkyBright.o     Develop:Sources/PowerD/DStuff/Lib/Chunky/CopyChunkyBright        CODE     .H?0Jl. Dl  p ԇJl.Dl  r ևn  .n( np.( n*,LhІ$h ,LhԆ&i $&SS,(.  Q  Jo l`p` QQLNu    _CopyChunkyBright             0-lh0-Y  Y  m)  Chunky\CopyChunkyField.ass; CopyChunkyField(a0:PTR TO chunky,d0,d1,a1:PTR TO chunky,d2,d3,d4,d5,a2:PTR TO UBYTE)

	machine	mc68020

	xdef	_CopyChunkyField
_CopyChunkyField
	movem.l	d2-d7/a2-a4,-(a7)

; DESTINATION BOUNDS
	tst.l	d0		; left bound
	bge.s	.leftdone
	move.l	d0,d7			; store left negative offset
	neg.l	d7
	cmp.l	d4,d7
	bge.s	.finish			; out of bounds
	moveq	#0,d0			; left position
	add.l	d7,d2
	sub.l	d7,d4			; new width
.leftdone
	tst.l	d1		; top bound
	bge.s	.topdone
	move.l	d1,d7			; store top negative offset
	neg.l	d7
	cmp.l	d5,d7
	bge.s	.finish			; out of bounds
	moveq	#0,d1			; top position
	add.l	d7,d3
	sub.l	d7,d5			; new height
.topdone
	cmp.l	(a0),d0		; right bound
	bgt.s	.finish
	move.l	(a0),d7			; store maximal width
	sub.l	d0,d7			; change width
	cmp.l	d4,d7			; check if we can fit
	bgt.s	.rightdone		; we can fit
	move.l	d7,d4			; new width, we can't fit
.rightdone
	cmp.l	(4,a0),d1		; bottom bound
	bgt.s	.finish
	move.l	(4,a0),d7			; store maximal width
	sub.l	d1,d7			; change width
	cmp.l	d5,d7			; check if we can fit
	bgt.s	.bottomdone		; we can fit
	move.l	d7,d5			; new width, we can't fit
.bottomdone

	move.l	a2,a4

	move.l	(a0),d7		; get dest width to d6
	muls.l	d1,d7
	add.l	d7,d0		; now we have start position in dest buffer
	move.l	(8,a0),a2
	add.l	d0,a2
	add.l	d0,a4		; and start position in mask buffer

	move.l	(a1),d7
	muls.l	d3,d7
	add.l	d7,d2
	move.l	(8,a1),a3
	add.l	d2,a3		; and start position in source buffer

	move.l	(a0),d2		; get the d2 and d3 values
	sub.l	d4,d2
	move.l	(a1),d3
	sub.l	d4,d3

	subq.l	#1,d4
	subq.l	#1,d5
	move.l	d4,d7		; store width
.loopy	move.l	d7,d4		; restore width
.loopx	move.b	(a4)+,d0		; get mask bool
	bne.s	.noskip
	addq.l	#1,a3
	addq.l	#1,a2
	bra.s	.skip
.noskip	move.b	(a3)+,(a2)+	; copy pixel
.skip	dbra.s	d4,.loopx
	adda.l	d2,a2
	adda.l	d2,a4
	adda.l	d3,a3
	dbra.s	d5,.loopy
.finish	movem.l	(a7)+,d2-d7/a2-a4
	rts
.P-lh0-    tn) Chunky\CopyChunkyField.oB~     Develop:Sources/PowerD/DStuff/Lib/Chunky/CopyChunkyField     CODE     'H?8Jl. Dl  p ԇJl.Dlpr ևnf.n( nV.( n*(J.LxЇ$h .Lxԇ&i $&SS.(fRR`QQLNuNq    _CopyChunkyField          /-lh0-    y)  Chunky\CopyChunkyMask.ass; CopyChunkyMask(a0:PTR TO chunky,d0,d1,a1:PTR TO chunky,d2,d3,d4,d5,d6)

	machine	mc68020

	xdef	_CopyChunkyMask
_CopyChunkyMask
	movem.l	d2-d7/a2-a3,-(a7)

; DESTINATION BOUNDS
	tst.l	d0		; left bound
	bge.s	.leftdone
	move.l	d0,d7			; store left negative offset
	neg.l	d7
	cmp.l	d4,d7
	bge.s	.finish			; out of bounds
	moveq	#0,d0			; left position
	add.l	d7,d2
	sub.l	d7,d4			; new width
.leftdone
	tst.l	d1		; top bound
	bge.s	.topdone
	move.l	d1,d7			; store top negative offset
	neg.l	d7
	cmp.l	d5,d7
	bge.s	.finish			; out of bounds
	moveq	#0,d1			; top position
	add.l	d7,d3
	sub.l	d7,d5			; new height
.topdone
	cmp.l	(a0),d0		; right bound
	bgt.s	.finish
	move.l	(a0),d7			; store maximal width
	sub.l	d0,d7			; change width
	cmp.l	d4,d7			; check if we can fit
	bgt.s	.rightdone		; we can fit
	move.l	d7,d4			; new width, we can't fit
.rightdone
	cmp.l	(4,a0),d1		; bottom bound
	bgt.s	.finish
	move.l	(4,a0),d7			; store maximal width
	sub.l	d1,d7			; change width
	cmp.l	d5,d7			; check if we can fit
	bgt.s	.bottomdone		; we can fit
	move.l	d7,d5			; new width, we can't fit
.bottomdone

	move.l	(a0),d7		; get dest width to d6
	muls.l	d1,d7
	add.l	d7,d0		; now we have start position in dest buffer
	move.l	(8,a0),a2
	add.l	d0,a2

	move.l	(a1),d7
	muls.l	d3,d7
	add.l	d7,d2
	move.l	(8,a1),a3
	add.l	d2,a3		; and start position in source buffer

	move.l	(a0),d2		; get the d2 and d3 values
	sub.l	d4,d2
	move.l	(a1),d3
	sub.l	d4,d3

	subq.l	#1,d4
	subq.l	#1,d5
	move.l	d4,d7		; store width
.loopy	move.l	d7,d4		; restore width
.loopx	move.b	(a3)+,d0		; get source colour
	cmp.b	d6,d0
	bne.s	.noskip
	addq.l	#1,a2
	bra.s	.skip
.noskip	move.b	d0,(a2)+		; copy pixel
.skip	dbra.s	d4,.loopx
	adda.l	d2,a2
	adda.l	d3,a3
	dbra.s	d5,.loopy
.finish	movem.l	(a7)+,d2-d7/a2-a3
	rts
--lh0-    tn) Chunky\CopyChunkyMask.o     Develop:Sources/PowerD/DStuff/Lib/Chunky/CopyChunkyMask      CODE     %H?0Jl. Dl|p ԇJl.Dljr ևn`.n( nP.( n*.LxЇ$h .Lxԇ&i $&SS.(fR`QQLNuNq    _CopyChunkyMask           +-lh0-!  !  L`*  Chunky\CreateChunky.dOPT	NOEXE

MODULE	'exec/memory'

OBJECT chunky
	wi/he:L,
	pixel:PTR TO UB

PROC CreateChunky(wi,he)(PTR TO chunky)
	DEF	ch:PTR TO chunky
	IFN ch:=AllocVec(SIZEOF_chunky+wi*he*SIZEOF_UBYTE,MEMF_PUBLIC|MEMF_CLEAR) THEN RETURN NIL
	ch.wi:=wi
	ch.he:=he
	ch.pixel:=ch+SIZEOF_chunky
ENDPROC ch
+-lh0-      W`* Chunky\CreateChunky.oH     Develop:Sources/PowerD/DStuff/Lib/Chunky/CreateChunky        CODE     NUH p"- L- tLЁ"<  ,x NT+@Jfp `& m   m!m   -rЁ m!@  -L@N]NuNq    _CreateChunky             --lh0-=  =  O`*  Chunky\CreateChunky32.d0OPT	NOEXE

MODULE	'exec/memory'

OBJECT chunky32
	wi/he:L,
	pixel:PTR TO L,
	zbuff:PTR TO F

PROC CreateChunky32Z(wi,he)(PTR TO chunky32)
	DEF	ch:PTR TO chunky32
	IFN ch:=AllocVec(SIZEOF_chunky32+wi*he*SIZEOF_LONG,MEMF_PUBLIC|MEMF_CLEAR) THEN RETURN NIL
	ch.wi:=wi
	ch.he:=he
	ch.pixel:=ch+SIZEOF_chunky32
ENDPROC ch
--lh0-      Y`* Chunky\CreateChunky32.ok     Develop:Sources/PowerD/DStuff/Lib/Chunky/CreateChunky32      CODE     NUH p"- L- tLЁ"<  ,x NT+@Jfp `& m   m!m   -rЁ m!@  -L@N]NuNq    _CreateChunky32Z          .^-lh0-|  |  R`*  Chunky\CreateChunky32Z.dOPT	NOEXE

MODULE	'exec/memory'

OBJECT chunky32
	wi/he:L,
	pixel:PTR TO L,
	zbuff:PTR TO F

PROC CreateChunky32Z(wi,he)(PTR TO chunky32)
	DEF	ch:PTR TO chunky32
	IFN ch:=AllocVec(SIZEOF_chunky32+wi*he*(SIZEOF_LONG+SIZEOF_FLOAT),MEMF_PUBLIC|MEMF_CLEAR) THEN RETURN NIL
	ch.wi:=wi
	ch.he:=he
	ch.pixel:=ch+SIZEOF_chunky32
	ch.zbuff:=ch+SIZEOF_chunky32+wi*he*SIZEOF_LONG
ENDPROC ch
.-lh0-      Z`* Chunky\CreateChunky32Z.o=     Develop:Sources/PowerD/DStuff/Lib/Chunky/CreateChunky32Z     CODE     "NUH p"- L- tLЁ"<  ,x NT+@Jfp `H m   m!m   -rЁ m!@  -rЁ"- L- tLЁ m!@  -L@N]Nu    _CreateChunky32Z          +-lh0-      A`*  Chunky\DeleteChunky.dOPT	NOEXE

OBJECT chunky32
	wi/he:L,
	pixel:PTR TO L,
	zbuff:PTR TO F

PROC DeleteChunky(ch:PTR TO chunky32)
	FreeVec(ch)
ENDPROC
+-lh0-      E`* Chunky\DeleteChunky.o\     Develop:Sources/PowerD/DStuff/Lib/Chunky/DeleteChunky        CODE     NU  /"m ,x NNp ,_N]NuNq    _DeleteChunky             --lh0-)  )  4X)  Chunky\DrawTriangle.ass	machine	mc68020
	fpu	1

*******************************************************************************
* name      	 offset
* n         	 -4
* ch        	 -8
* list      	 -12
* y2        	 -16
* y1        	 -20
* y0        	 -24
* x2        	 -28
* x1        	 -32
* x0        	 -36
* drx       	 -40
* rx        	 -44
* dlx       	 -48
* lx        	 -52
* y         	 -56
* args
* dest      	 16
* dc        	 12
* c         	 8
	xdef	_DrawTriangle
_DrawTriangle
	link	a5,#-56
	movem.l	d2-d6,-(a7)
	lea	(-24,a7),a7
	movea.l	(12,a5),a0
	moveq	#0,d0
	lea	(a0,d0.l*8),a0
	move.l	(a0),(a7)
	movea.l	(12,a5),a0
	moveq	#0,d0
	lea	(a0,d0.l*8),a0
	move.l	(4,a0),(4,a7)
	movea.l	(12,a5),a0
	moveq	#1,d0
	lea	(a0,d0.l*8),a0
	move.l	(a0),(8,a7)
	movea.l	(12,a5),a0
	moveq	#1,d0
	lea	(a0,d0.l*8),a0
	move.l	(4,a0),(12,a7)
	movea.l	(12,a5),a0
	moveq	#2,d0
	lea	(a0,d0.l*8),a0
	move.l	(a0),(16,a7)
	movea.l	(12,a5),a0
	moveq	#2,d0
	lea	(a0,d0.l*8),a0
	move.l	(4,a0),(20,a7)
	lea	list0,a0
	move.l	(a7)+,(a0)
	move.l	(a7)+,(4,a0)
	move.l	(a7)+,(8,a0)
	move.l	(a7)+,(12,a0)
	move.l	(a7)+,(16,a0)
	move.l	(a7)+,(20,a0)
	move.l	a0,(-12,a5)
repeat0
	clr.l	(-8,a5)
	clr.l	(-4,a5)
for1
if2
	movea.l	(-12,a5),a0
	move.l	(-4,a5),d1
	lea	(a0,d1.l*8),a0
	fmove.s	(4,a0),fp0
	movea.l	(-12,a5),a0
	move.l	(-4,a5),d2
	addq.l	#1,d2
	move.l	d2,d1
	lea	(a0,d1.l*8),a0
	fcmp.s	(4,a0),fp0
	fble	end2
	movea.l	(-12,a5),a0
	move.l	(-4,a5),d1
	addq.l	#1,d1
	move.l	d1,d0
	lea	(a0,d0.l*8),a0
	movea.l	(-12,a5),a1
	move.l	(-4,a5),d0
	lea	(a1,d0.l*8),a1
	move.l	(a1),d0
	move.l	(a0),(a1)
	move.l	d0,(a0)
	movea.l	(-12,a5),a0
	move.l	(-4,a5),d1
	addq.l	#1,d1
	move.l	d1,d0
	lea	(a0,d0.l*8),a0
	movea.l	(-12,a5),a1
	move.l	(-4,a5),d0
	lea	(a1,d0.l*8),a1
	move.l	(4,a1),d0
	move.l	(4,a0),(4,a1)
	move.l	d0,(4,a0)
	move.l	#-1,(-8,a5)
end2
nextfor1
	addq.l	#1,(-4,a5)
	cmpi.l	#1,(-4,a5)
	ble	for1
end1
	move.l	(-8,a5),d0
	moveq	#0,d1
	cmp.l	d1,d0
	bne	repeat0
end0
	movea.l	(-12,a5),a0
	moveq	#0,d0
	lea	(a0,d0.l*8),a0
	move.l	(a0),(-36,a5)
	movea.l	(-12,a5),a0
	moveq	#0,d0
	lea	(a0,d0.l*8),a0
	move.l	(4,a0),(-24,a5)
	movea.l	(-12,a5),a0
	moveq	#1,d0
	lea	(a0,d0.l*8),a0
	move.l	(a0),(-32,a5)
	movea.l	(-12,a5),a0
	moveq	#1,d0
	lea	(a0,d0.l*8),a0
	move.l	(4,a0),(-20,a5)
	movea.l	(-12,a5),a0
	moveq	#2,d0
	lea	(a0,d0.l*8),a0
	move.l	(a0),(-28,a5)
	movea.l	(-12,a5),a0
	moveq	#2,d0
	lea	(a0,d0.l*8),a0
	move.l	(4,a0),(-16,a5)
if4
	fmove.s	(-24,a5),fp0
	fcmp.s	(-20,a5),fp0
	fseq	d1
	extb.l	d1
	move.l	d1,d0
	fmove.s	(-36,a5),fp0
	fcmp.s	(-32,a5),fp0
	fsgt	d1
	extb.l	d1
	and.l	d1,d0
	tst.l	d0
	beq	end4
	move.l	(-36,a5),d0
	move.l	(-32,a5),(-36,a5)
	move.l	d0,(-32,a5)
end4
if6
	fmove.s	(-20,a5),fp0
	fcmp.s	(-16,a5),fp0
	fseq	d1
	extb.l	d1
	move.l	d1,d0
	fmove.s	(-32,a5),fp0
	fcmp.s	(-28,a5),fp0
	fsgt	d1
	extb.l	d1
	and.l	d1,d0
	tst.l	d0
	beq	end6
	move.l	(-32,a5),d0
	move.l	(-28,a5),(-32,a5)
	move.l	d0,(-28,a5)
end6
if8
	fmove.s	(-24,a5),fp0
	ftst.d	fp0
	fslt	d1
	extb.l	d1
	move.l	d1,d0
	fmove.s	(-20,a5),fp0
	ftst.d	fp0
	fslt	d1
	extb.l	d1
	and.l	d1,d0
	fmove.s	(-16,a5),fp0
	ftst.d	fp0
	fslt	d1
	extb.l	d1
	and.l	d1,d0
	tst.l	d0
	beq	end8
	moveq	#0,d0
	bra	DrawTrianglefinish
end8
if10
	fmove.s	(-36,a5),fp0
	ftst.d	fp0
	fslt	d1
	extb.l	d1
	move.l	d1,d0
	fmove.s	(-32,a5),fp0
	ftst.d	fp0
	fslt	d1
	extb.l	d1
	and.l	d1,d0
	fmove.s	(-28,a5),fp0
	ftst.d	fp0
	fslt	d1
	extb.l	d1
	and.l	d1,d0
	tst.l	d0
	beq	end10
	moveq	#0,d0
	bra	DrawTrianglefinish
end10
if12
	fmove.s	(-24,a5),fp0
	movea.l	(16,a5),a0
	fcmp.l	(4,a0),fp0
	fsge	d1
	extb.l	d1
	move.l	d1,d0
	fmove.s	(-20,a5),fp0
	movea.l	(16,a5),a0
	fcmp.l	(4,a0),fp0
	fsge	d1
	extb.l	d1
	and.l	d1,d0
	fmove.s	(-16,a5),fp0
	movea.l	(16,a5),a0
	fcmp.l	(4,a0),fp0
	fsge	d1
	extb.l	d1
	and.l	d1,d0
	tst.l	d0
	beq	end12
	moveq	#0,d0
	bra	DrawTrianglefinish
end12
if14
	fmove.s	(-36,a5),fp0
	movea.l	(16,a5),a0
	fcmp.l	(a0),fp0
	fsge	d1
	extb.l	d1
	move.l	d1,d0
	fmove.s	(-32,a5),fp0
	movea.l	(16,a5),a0
	fcmp.l	(a0),fp0
	fsge	d1
	extb.l	d1
	and.l	d1,d0
	fmove.s	(-28,a5),fp0
	movea.l	(16,a5),a0
	fcmp.l	(a0),fp0
	fsge	d1
	extb.l	d1
	and.l	d1,d0
	tst.l	d0
	beq	end14
	moveq	#0,d0
	bra	DrawTrianglefinish
end14
if16
	fmove.s	(-24,a5),fp0
	fcmp.s	(-20,a5),fp0
	fbne	elseif16_1
	move.l	(-36,a5),(-52,a5)
	move.l	(-32,a5),(-44,a5)
	fmove.s	(-28,a5),fp1
	fsub.s	(-52,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-16,a5),fp1
	fsub.s	(-24,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-48,a5)
	fmove.s	(-28,a5),fp1
	fsub.s	(-44,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-16,a5),fp1
	fsub.s	(-24,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-40,a5)
	fmove.s	(-24,a5),fp0
	fmove.l	fp0,(-56,a5)
for18
if19
	move.l	(-56,a5),d0
	movea.l	(16,a5),a0
	cmp.l	(4,a0),d0
	blt	end19
	moveq	#0,d0
	bra	DrawTrianglefinish
end19
if21
	move.l	(-56,a5),d0
	moveq	#0,d1
	cmp.l	d1,d0
	blt	end21
	movea.l	(16,a5),a0
	fmove.s	(-52,a5),fp0
	fmove.l	fp0,d0
	fmove.s	(-44,a5),fp0
	fmove.l	fp0,d1
	move.l	(-56,a5),d2
	move.l	(8,a5),d3
	jsr	_HLine		; HLine
end21
	fmove.s	(-52,a5),fp0
	fadd.s	(-48,a5),fp0
	fmove.s	fp0,(-52,a5)
	fmove.s	(-44,a5),fp0
	fadd.s	(-40,a5),fp0
	fmove.s	fp0,(-44,a5)
nextfor18
	addq.l	#1,(-56,a5)
	fmove.l	(-56,a5),fp0
	fcmp.s	(-16,a5),fp0
	fble	for18
end18
	bra	end16
elseif16_1
	fmove.s	(-20,a5),fp0
	fcmp.s	(-16,a5),fp0
	fbne	elseif16_2
	move.l	(-36,a5),(-44,a5)
	move.l	(-44,a5),(-52,a5)
	fmove.s	(-32,a5),fp1
	fsub.s	(-52,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-16,a5),fp1
	fsub.s	(-24,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-48,a5)
	fmove.s	(-28,a5),fp1
	fsub.s	(-44,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-16,a5),fp1
	fsub.s	(-24,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-40,a5)
	fmove.s	(-24,a5),fp0
	fmove.l	fp0,(-56,a5)
for25
if26
	move.l	(-56,a5),d0
	movea.l	(16,a5),a0
	cmp.l	(4,a0),d0
	blt	end26
	moveq	#0,d0
	bra	DrawTrianglefinish
end26
if28
	move.l	(-56,a5),d0
	moveq	#0,d1
	cmp.l	d1,d0
	blt	end28
	movea.l	(16,a5),a0
	fmove.s	(-52,a5),fp0
	fmove.l	fp0,d0
	fmove.s	(-44,a5),fp0
	fmove.l	fp0,d1
	move.l	(-56,a5),d2
	move.l	(8,a5),d3
	jsr	_HLine		; HLine
end28
	fmove.s	(-52,a5),fp0
	fadd.s	(-48,a5),fp0
	fmove.s	fp0,(-52,a5)
	fmove.s	(-44,a5),fp0
	fadd.s	(-40,a5),fp0
	fmove.s	fp0,(-44,a5)
nextfor25
	addq.l	#1,(-56,a5)
	fmove.s	(-20,a5),fp0
	fsub.w	#1,fp0
	fmove.l	(-56,a5),fp1
	fcmp.x	fp0,fp1
	fble	for25
end25
	bra	end16
elseif16_2
	movem.l	d0,-(a7)
	move.l	(-24,a5),-(a7)
	move.l	(-16,a5),-(a7)
	move.l	(-20,a5),-(a7)
	move.l	(-36,a5),-(a7)
	move.l	(-28,a5),-(a7)
	jsr	_GetXLine		; GetXLine
	lea	(20,a7),a7
	movem.l	(a7)+,d0
	fcmp.s	(-32,a5),fp0
	fble	elseif16_3
	move.l	(-36,a5),(-44,a5)
	move.l	(-44,a5),(-52,a5)
	fmove.s	(-32,a5),fp1
	fsub.s	(-52,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-20,a5),fp1
	fsub.s	(-24,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-48,a5)
	fmove.s	(-28,a5),fp1
	fsub.s	(-44,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-16,a5),fp1
	fsub.s	(-24,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-40,a5)
	fmove.s	(-24,a5),fp0
	fmove.l	fp0,(-56,a5)
for32
if33
	move.l	(-56,a5),d0
	movea.l	(16,a5),a0
	cmp.l	(4,a0),d0
	blt	end33
	moveq	#0,d0
	bra	DrawTrianglefinish
end33
if35
	move.l	(-56,a5),d0
	moveq	#0,d1
	cmp.l	d1,d0
	blt	end35
	movea.l	(16,a5),a0
	fmove.s	(-52,a5),fp0
	fmove.l	fp0,d0
	fmove.s	(-44,a5),fp0
	fmove.l	fp0,d1
	move.l	(-56,a5),d2
	move.l	(8,a5),d3
	jsr	_HLine		; HLine
end35
	fmove.s	(-52,a5),fp0
	fadd.s	(-48,a5),fp0
	fmove.s	fp0,(-52,a5)
	fmove.s	(-44,a5),fp0
	fadd.s	(-40,a5),fp0
	fmove.s	fp0,(-44,a5)
nextfor32
	addq.l	#1,(-56,a5)
	fmove.s	(-20,a5),fp0
	fsub.w	#1,fp0
	fmove.l	(-56,a5),fp1
	fcmp.x	fp0,fp1
	fble	for32
end32
	fmove.s	(-28,a5),fp1
	fsub.s	(-52,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-16,a5),fp1
	fsub.s	(-20,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-48,a5)
	fmove.s	(-20,a5),fp0
	fmove.l	fp0,(-56,a5)
for37
if38
	move.l	(-56,a5),d0
	movea.l	(16,a5),a0
	cmp.l	(4,a0),d0
	blt	end38
	moveq	#0,d0
	bra	DrawTrianglefinish
end38
if40
	move.l	(-56,a5),d0
	moveq	#0,d1
	cmp.l	d1,d0
	blt	end40
	movea.l	(16,a5),a0
	fmove.s	(-52,a5),fp0
	fmove.l	fp0,d0
	fmove.s	(-44,a5),fp0
	fmove.l	fp0,d1
	move.l	(-56,a5),d2
	move.l	(8,a5),d3
	jsr	_HLine		; HLine
end40
	fmove.s	(-52,a5),fp0
	fadd.s	(-48,a5),fp0
	fmove.s	fp0,(-52,a5)
	fmove.s	(-44,a5),fp0
	fadd.s	(-40,a5),fp0
	fmove.s	fp0,(-44,a5)
nextfor37
	addq.l	#1,(-56,a5)
	fmove.s	(-16,a5),fp0
	fsub.w	#1,fp0
	fmove.l	(-56,a5),fp1
	fcmp.x	fp0,fp1
	fble	for37
end37
	bra	end16
elseif16_3
	move.l	(-36,a5),(-44,a5)
	move.l	(-44,a5),(-52,a5)
	fmove.s	(-28,a5),fp1
	fsub.s	(-52,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-16,a5),fp1
	fsub.s	(-24,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-48,a5)
	fmove.s	(-32,a5),fp1
	fsub.s	(-44,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-20,a5),fp1
	fsub.s	(-24,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-40,a5)
	fmove.s	(-24,a5),fp0
	fmove.l	fp0,(-56,a5)
for44
if45
	move.l	(-56,a5),d0
	movea.l	(16,a5),a0
	cmp.l	(4,a0),d0
	blt	end45
	moveq	#0,d0
	bra	DrawTrianglefinish
end45
if47
	move.l	(-56,a5),d0
	moveq	#0,d1
	cmp.l	d1,d0
	blt	end47
	movea.l	(16,a5),a0
	fmove.s	(-52,a5),fp0
	fmove.l	fp0,d0
	fmove.s	(-44,a5),fp0
	fmove.l	fp0,d1
	move.l	(-56,a5),d2
	move.l	(8,a5),d3
	jsr	_HLine		; HLine
end47
	fmove.s	(-52,a5),fp0
	fadd.s	(-48,a5),fp0
	fmove.s	fp0,(-52,a5)
	fmove.s	(-44,a5),fp0
	fadd.s	(-40,a5),fp0
	fmove.s	fp0,(-44,a5)
nextfor44
	addq.l	#1,(-56,a5)
	fmove.s	(-20,a5),fp0
	fsub.w	#1,fp0
	fmove.l	(-56,a5),fp1
	fcmp.x	fp0,fp1
	fble	for44
end44
	fmove.s	(-28,a5),fp1
	fsub.s	(-44,a5),fp1
	fmove.x	fp1,fp0
	fmove.s	(-16,a5),fp1
	fsub.s	(-20,a5),fp1
	fdiv.x	fp1,fp0
	fmove.s	fp0,(-40,a5)
	fmove.s	(-20,a5),fp0
	fmove.l	fp0,(-56,a5)
for49
if50
	move.l	(-56,a5),d0
	movea.l	(16,a5),a0
	cmp.l	(4,a0),d0
	blt	end50
	moveq	#0,d0
	bra	DrawTrianglefinish
end50
if52
	move.l	(-56,a5),d0
	moveq	#0,d1
	cmp.l	d1,d0
	blt	end52
	movea.l	(16,a5),a0
	fmove.s	(-52,a5),fp0
	fmove.l	fp0,d0
	fmove.s	(-44,a5),fp0
	fmove.l	fp0,d1
	move.l	(-56,a5),d2
	move.l	(8,a5),d3
	jsr	_HLine		; HLine
end52
	fmove.s	(-52,a5),fp0
	fadd.s	(-48,a5),fp0
	fmove.s	fp0,(-52,a5)
	fmove.s	(-44,a5),fp0
	fadd.s	(-40,a5),fp0
	fmove.s	fp0,(-44,a5)
nextfor49
	addq.l	#1,(-56,a5)
	fmove.s	(-16,a5),fp0
	fsub.w	#1,fp0
	fmove.l	(-56,a5),fp1
	fcmp.x	fp0,fp1
	fble	for49
end49
end16
DrawTriangleend
	moveq	#0,d0
DrawTrianglefinish
	movem.l	(a7)+,d2-d6
	unlk	a5
	rts
*******************************************************************************
* name      	 offset
* args
* y1        	 24
* y2        	 20
* y3        	 16
* x1        	 12
* x2        	 8
	xdef	_GetXLine
_GetXLine
	link	a5,#0
	fmovem.x	fp2,-(a7)
	fmove.s	(12,a5),fp2
	fsub.s	(8,a5),fp2
	fmove.x	fp2,fp1
	fmove.s	(20,a5),fp2
	fsub.s	(16,a5),fp2
	fmul.x	fp2,fp1
	fmove.s	(20,a5),fp2
	fsub.s	(24,a5),fp2
	fdiv.x	fp2,fp1
	fmove.x	fp1,fp0
	fadd.s	(8,a5),fp0
GetXLineend
GetXLinefinish
	fmovem.x	(a7)+,fp2
	unlk	a5
	rts
	xref	_HLine
	section	".tocd",data
list0	dc.s	0
	dc.s	0
	dc.s	0
	dc.s	0
	dc.s	0
	dc.s	0
	cnop	0,2
+-lh0-    .X) Chunky\DrawTriangle.d>OPT	NOEXE,OPTIMIZE

MODULE	'lib/chunky'

OBJECT xy
	x/y:F

OBJECT chunky
	wi/he:L,
	data:PTR TO UBYTE

PROC DrawTriangle(dest:PTR TO chunky,dc:PTR TO xy,c)
	DEFL	y
	DEFF	lx,dlx,rx,drx		// coords on destination chunky
	DEFF	x0,x1,x2,y0,y1,y2,list:PTR TO xy

	list:=[dc[0].x,dc[0].y,dc[1].x,dc[1].y,dc[2].x,dc[2].y]:xy

	DEF	ch,n
	REPEAT
		ch:=FALSE
		FOR n:=0 TO 1
			IF list[n].y>list[n+1].y
				list[n].x:=:list[n+1].x
				list[n].y:=:list[n+1].y
				ch:=TRUE
			ENDIF
		ENDFOR
	UNTIL ch=FALSE

	x0:=list[0].x
	y0:=list[0].y
	x1:=list[1].x
	y1:=list[1].y
	x2:=list[2].x
	y2:=list[2].y

	IF y0=y1 AND x0>x1 THEN x0:=:x1
	IF y1=y2 AND x1>x2 THEN x1:=:x2

	IF y0<0 AND y1<0 AND y2<0 THEN RETURN
	IF x0<0 AND x1<0 AND x2<0 THEN RETURN
	IF y0>=dest.he AND y1>=dest.he AND y2>=dest.he THEN RETURN
	IF x0>=dest.wi AND x1>=dest.wi AND x2>=dest.wi THEN RETURN

	IF y0=y1
// +-------+
//  \     /
//   \   /
//    \ /
//     +
		// initialize coords (and deltas) for destination chunky

		lx:=x0				// first point x
		rx:=x1				// second point x
		dlx:=(x2-lx)/(y2-y0)	// left side delta
		drx:=(x2-rx)/(y2-y0)	// right side delta

		FOR y:=y0 TO y2
			IF y>=dest.he THEN RETURN
			IF y>=0 THEN HLine(dest,lx,rx,y,c)
			lx+=dlx
			rx+=drx
		ENDFOR

//		Triangle1(dest,y0,y2,x0,x1,x2,c)
	ELSEIF y1=y2
//     +
//    / \
//   /   \
//  /     \
// +-------+
		// initialize coords (and deltas) for destination chunky
		lx:=rx:=x0			// first point
		dlx:=(x1-lx)/(y2-y0)	// left side delta
		drx:=(x2-rx)/(y2-y0)	// right side delta

		FOR y:=y0 TO y1-1
			IF y>=dest.he THEN RETURN
			IF y>=0 THEN HLine(dest,lx,rx,y,c)
			lx+=dlx
			rx+=drx
		ENDFOR

	ELSEIF GetXLine(y0,y2,y1,x0,x2)>x1
//    +            +
//   / \          /|
//  /   \        / |
// +_    \      +  |
//   --__ \      \ |
//       --+      \+
		// central point on the left side

		// initialize coords (and deltas) for destination chunky
		lx:=rx:=x0			// first point
		dlx:=(x1-lx)/(y1-y0)	// left side delta
		drx:=(x2-rx)/(y2-y0)	// right side delta

		FOR y:=y0 TO y1-1
			IF y>=dest.he THEN RETURN
			IF y>=0 THEN HLine(dest,lx,rx,y,c)
			lx+=dlx
			rx+=drx
		ENDFOR

		dlx:=(x2-lx)/(y2-y1)	// new left side delta
		FOR y:=y1 TO y2-1
			IF y>=dest.he THEN RETURN
			IF y>=0 THEN HLine(dest,lx,rx,y,c)
			lx+=dlx
			rx+=drx
		ENDFOR
	ELSE
//     +            +
//    / \          /|
//   /   \        / |
//  /     \      +  |
// / ___---+      \ |
//+--              \+
		// central point on the right side

		// initialize coords (and deltas) for destination chunky
		lx:=rx:=x0			// first point
		dlx:=(x2-lx)/(y2-y0)	// left side delta
		drx:=(x1-rx)/(y1-y0)	// right side delta

		FOR y:=y0 TO y1-1
			IF y>=dest.he THEN RETURN
			IF y>=0 THEN HLine(dest,lx,rx,y,c)
			lx+=dlx
			rx+=drx
		ENDFOR

		drx:=(x2-rx)/(y2-y1)	// new right side delta

		FOR y:=y1 TO y2-1
			IF y>=dest.he THEN RETURN
			IF y>=0 THEN HLine(dest,lx,rx,y,c)
			lx+=dlx
			rx+=drx
		ENDFOR
	ENDIF
ENDPROC

PROC GetXLine(y1:F,y2:F,y3:F,x1:F,x2:F)(F) IS
	(x1-x2)*(y2-y3)/(y2-y1)+x2
+-lh0-	  	  5X) Chunky\DrawTriangle.ok     Develop:Sources/PowerD/DStuff/Lib/Chunky/DrawTriangle        CODE    3NUH> O m p A . m p A /h   m pA /P  m pA /h   m pA /P  m pA /h  A     !_ !_ !_ !_ !_ +HBB m"-A (D   m$-R"A (D8  V m"-R A "m -C  "  m"-R A "m -C  ) #h  !@ +|R   o r -r f ^ mp A +P mp A +h  mpA +P mpA +h  mpA +P mpA +h -D -D8A I -D -D8A IJg -+m+@-D -D8A I -D -D8A IJg -+m+@-D   :A I -D   :A I-D   :A IJgp ` D-D   :A I -D   :A I-D   :A IJgp ` -D  m (@8 A I -D  m (@8 A I-D  m (@8 A IJgp ` -D  m @8A I -D  m @8A I-D  m @8A IJgp ` f-D -D8 +m+m-D-D  -D-D  -d -D-D  -D-D  -d -D -`  - m  mp `  -r m& m -D  ` -D ` $-&- N    -D -D"-d -D -D"-d R-@ -D8` p-D -D8 +m+m-D-D  -D-D  -d -D-D  -D-D  -d -D -`  - m  mp `  -r m& m -D  ` -D ` $-&- N    -D -D"-d -D -D"-d R-D <P( -@  |` r/ /-/-/-/-/-a bO  -D8+m+m-D-D  -D-D  -d -D-D  -D-D  -d -D -`  - m  mp `  -r m& m -D  ` -D ` $-&- N    -D -D"-d -D -D"-d R-D <P( -@  |-D-D  -D-D  -d -D -`  - m  mp `  -r m& m -D  ` -D ` $-&- N    -D -D"-d -D -D"-d R-D <P( -@  |` +m+m-D-D  -D-D  -d -D-D  -D-D  -d -D -`  - m  mp ` , -r m& m -D  ` -D ` $-&- N    -D -D"-d -D -D"-d R-D <P( -@  |-D-D  -D-D  -d -D -`  - m  mp `t -r m& m -D  ` -D ` $-&- N    -D -D"-d -D -D"-d R-D <P( -@  ~p L |N]NuNU  '-E  -E(  -E  -E(  -E  -E(    -D"  N]NuNq           f        _DrawTriangle         _GetXLine       _HLine               z  0           .tocd                                  +Y-lh0-l  l  ,)  Chunky\FillChunky.ass; FillChunky(dst:a0:PTR TO chunky,colour:d0:LONG)

	machine	mc68020

	xdef	_FillChunky
_FillChunky
	and.l	#$ff,d0
	move.l	d0,d1
	lsl.l	#8,d1
	or.l	d1,d0
	move.l	d0,d1
	swap	d1
	or.l	d1,d0		; d0 contains four times the coloour

	move.l	(4,a0),d1
	muls.l	(a0),d1
	lsr.l	#2,d1		; divide by four
	move.l	(8,a0),a1
.loop	move.l	d0,(a1)+
	subq.l	#1,d1
	bgt.s	.loop
	rts
)u-lh0-      .) Chunky\FillChunky.og     Develop:Sources/PowerD/DStuff/Lib/Chunky/FillChunky      CODE     
   " ቀ" HA"( L"h "SnNu    _FillChunky           -%-lh0-      ݑ8*  Chunky\FillChunky32.ass.k; FillChunky32(dst:a0:PTR TO chunky,colour:d0:LONG)

	machine	mc68020

	xdef	_FillChunky32
_FillChunky32
	move.l	(4,a0),d1
	muls.l	(a0),d1
	move.l	(8,a0),a1
.loop	move.l	d0,(a1)+
	subq.l	#1,d1
	bgt.s	.loop
	rts
+n-lh0-      8* Chunky\FillChunky32.o B     Develop:Sources/PowerD/DStuff/Lib/Chunky/FillChunky32        CODE     "( L"h "SnNu    _FillChunky32             .-lh0-;  ;  )  Chunky\FillChunky32Z.ass:; FillChunky32Z(dst:a0:PTR TO chunky,colour:d0:LONG,z:fp0:F)

	machine	mc68020
	fpu	1

	xdef	_FillChunky32Z
_FillChunky32Z
	move.l	d2,-(a7)
	fmove.s	fp0,d1
	move.l	(4,a0),d2
	muls.l	(a0),d2
	move.l	(8,a0),a1
	move.l	(12,a0),a0
.loop	move.l	d0,(a1)+
	move.l	d1,(a0)+
	subq.l	#1,d2
	bgt.s	.loop
	move.l	(a7)+,d2
	rts
,t-lh0-      ) Chunky\FillChunky32Z.o     Develop:Sources/PowerD/DStuff/Lib/Chunky/FillChunky32Z       CODE     	/d $( L("h  h " Sn$NuNq    _FillChunky32Z            )[-lh0-S  S  +8*  Chunky\GetPixel.ass
; GetPixelchunky:a0:PTR TO chunky,x:d0:LONG,y:d1:LONG)(LONG)

	machine	mc68020
	fpu	1

	xdef	_GetPixel

_GetPixel
	cmpa.l	#0,a0
	beq.s	.out
	tst.l	d0
	blt.s	.out
	tst.l	d1
	blt.s	.out
	cmp.l	(a0),d0
	bge.s	.out
	cmp.l	(4,a0),d1
	bge.s	.out

	muls.l	(a0),d1
	add.l	d0,d1
	movea.l	(8,a0),a1
	move.b	(a1,d1.l),d0
	rts
.out	moveq	#-1,d0
	rts
'-lh0-      38* Chunky\GetPixel.o     Develop:Sources/PowerD/DStuff/Lib/Chunky/GetPixel        CODE     Jg"JmJml lLҀ"h 1 NupNuNq    _GetPixel             +-lh0-    B)  Chunky\GetPixel32.assNj
; GetPixel32(chunky:a0:PTR TO chunky,x:d0:LONG,y:d1:LONG)(LONG)

	machine	mc68020
	fpu	1

	xdef	_GetPixel32

_GetPixel32
	cmpa.l	#0,a0
	beq.s	.out
	tst.l	d0
	blt.s	.out
	tst.l	d1
	blt.s	.out
	cmp.l	(a0),d0
	bge.s	.out
	cmp.l	(4,a0),d1
	bge.s	.out

	muls.l	(a0),d1
	add.l	d0,d1
	lsl.l	#2,d1		; d1 now contains position in buffer
	movea.l	(8,a0),a1
	move.l	(a1,d1.l),d0
	rts
.out	moveq	#-1,d0
	rts
)-lh0-      un) Chunky\GetPixel32.o     Develop:Sources/PowerD/DStuff/Lib/Chunky/GetPixel32      CODE     Jg$Jm Jml lLҀ"h  1 NupNu    _GetPixel32           1-lh0-    $*  Chunky\GetPixel32Smooth.ass
; GetPixel32Smooth(chunky:a0:PTR TO chunky,x:fp0:FLOAT,y:fp1:FLOAT)(LONG)

	machine	mc68020
	fpu	1

	xdef	_GetPixel32Smooth

_GetPixel32Smooth
	fmovem.x	fp2-fp3,-(a7)
	movem.l	d2-d6,-(a7)
	cmpa.l	#0,a0
	beq.w	.out
	ftst.x	fp0
	fblt.w	.out
	ftst.x	fp1
	fblt.w	.out
	fcmp.l	(a0),fp0
	fbge.w	.out
	fcmp.l	(4,a0),fp1
	fbge.w	.out

; fp0 and fp1 are float positions in the chunky and we want to get an exact
; interpolated value of the colour
	fmove.l	fp0,d0		; get integer x and y
	fmove.l	fp1,d1
	fsub.l	d0,fp0		; get the difference (0.0..1.0)
	fsub.l	d1,fp1

	muls.l	(a0),d3
	add.l	d0,d3
	lsl.l	#2,d3		; d1 now contains position in buffer
	movea.l	(8,a0),a1
	move.l	(0,a1,d3.l),d0	; x,y
	move.l	(1,a1,d3.l),d1	; x+1,y
	add.l	(a0),d3
	move.l	(-1,a1,d3.l),d2	; x,y+1
	move.l	(0,a1,d3.l),d3	; x+1,y+1
; here we got four colours:
;d0*--*d1
;  |  |
;d2*--*d3
	move.l	d0,d4
	bsr	UnPack32
	movem.l	d1-d3,-(a7)
	movem.l	d4-d6,-(a7)
	move.l	d1,d4
	bsr	UnPack32
	movem.l	(a7)+,d1-d3	; now I have d1,d2,d3 as colour x+1,y and d4,d5,d6 as colour x,y

	fmove.l	d4,fp3		; red
	fmove.w	#1,fp2
	fsub	fp0,fp2
	fmul	fp2,fp3		; fp3:=a*(1-t)
	fmove.l	d1,fp2
	fmul	fp0,fp2		; fp2:=b*t
	fadd	fp3,fp2
	fmove.l	fp2,d4		; a:=a*(1-t)+b*t

	fmove.l	d5,fp3		; green
	fmove.w	#1,fp2
	fsub	fp0,fp2
	fmul	fp2,fp3		; fp3:=a*(1-t)
	fmove.l	d2,fp2
	fmul	fp0,fp2		; fp2:=b*t
	fadd	fp3,fp2
	fmove.l	fp2,d5		; a:=a*(1-t)+b*t

	fmove.l	d6,fp3		; blue
	fmove.w	#1,fp2
	fsub	fp0,fp2
	fmul	fp2,fp3		; fp3:=a*(1-t)
	fmove.l	d3,fp2
	fmul	fp0,fp2		; fp2:=b*t
	fadd	fp3,fp2
	fmove.l	fp2,d6		; a:=a*(1-t)+b*t

	movem.l	(a7)+,d1-d3	; restore old values
	movem.l	d4-d6,-(a7)	; store first colour

	move.l	d2,d4
	bsr	UnPack32
	movem.l	d4-d6,-(a7)
	move.l	d3,d4
	bsr	UnPack32
	movem.l	(a7)+,d1-d3	; now I have d1,d2,d3 as colour x+1,y and d4,d5,d6 as colour x,y

	fmove.l	d4,fp3		; red
	fmove.w	#1,fp2
	fsub	fp0,fp2
	fmul	fp2,fp3		; fp3:=a*(1-t)
	fmove.l	d1,fp2
	fmul	fp0,fp2		; fp2:=b*t
	fadd	fp3,fp2
	fmove.l	fp2,d4		; a:=a*(1-t)+b*t

	fmove.l	d5,fp3		; green
	fmove.w	#1,fp2
	fsub	fp0,fp2
	fmul	fp2,fp3		; fp3:=a*(1-t)
	fmove.l	d2,fp2
	fmul	fp0,fp2		; fp2:=b*t
	fadd	fp3,fp2
	fmove.l	fp2,d5		; a:=a*(1-t)+b*t

	fmove.l	d6,fp3		; blue
	fmove.w	#1,fp2
	fsub	fp0,fp2
	fmul	fp2,fp3		; fp3:=a*(1-t)
	fmove.l	d3,fp2
	fmul	fp0,fp2		; fp2:=b*t
	fadd	fp3,fp2
	fmove.l	fp2,d6		; a:=a*(1-t)+b*t

	movem.l	(a7)+,d1-d3	; restore first colour (from d4,d5,d6)

	fmove.l	d4,fp3		; red
	fmove.w	#1,fp2
	fsub	fp0,fp2
	fmul	fp2,fp3		; fp3:=a*(1-t)
	fmove.l	d1,fp2
	fmul	fp0,fp2		; fp2:=b*t
	fadd	fp3,fp2
	fmove.l	fp2,d1		; b:=a*(1-t)+b*t

	fmove.l	d5,fp3		; green
	fmove.w	#1,fp2
	fsub	fp0,fp2
	fmul	fp2,fp3		; fp3:=a*(1-t)
	fmove.l	d2,fp2
	fmul	fp0,fp2		; fp2:=b*t
	fadd	fp3,fp2
	fmove.l	fp2,d2		; b:=a*(1-t)+b*t

	fmove.l	d6,fp3		; blue
	fmove.w	#1,fp2
	fsub	fp0,fp2
	fmul	fp2,fp3		; fp3:=a*(1-t)
	fmove.l	d3,fp2
	fmul	fp0,fp2		; fp2:=b*t
	fadd	fp3,fp2
	fmove.l	fp2,d3		; b:=a*(1-t)+b*t

	moveq	#0,d0
	swap	d1	; 00rr0000
	lsl	#8,d2	; 0000gg00
	or.l	d1,d0
	or.l	d2,d0
	or.l	d3,d0	; 00rrggbb

	movem.l	(a7)+,d2-d6
	fmovem.x	(a7)+,fp2-fp3
	rts
.out	moveq	#-1,d0
	movem.l	(a7)+,d2-d6
	fmovem.x	(a7)+,fp2-fp3
	rts

; UnPack32(d4:UL)(d4:L,d5:L,d6:L)
UnPack32
	clr.l	d5
	move.b	d4,d6
	lsr.l	#8,d4
	clr.l	d5
	move.b	d4,d5
	lsr.l	#8,d4
	andi.l	#$ff,d4	; clear alpha
	rts
/-lh0-    $* Chunky\GetPixel32Smooth.oq     Develop:Sources/PowerD/DStuff/Lib/Chunky/GetPixel32Smooth        CODE     'H> Jg   : :@8(@  ` ` @(@L8ր"h  18 "18֐$18&18 ( a Hp H (a zL A<Q   ( 	A  # "a A<Q   ( 	A  # "a A<Q   ( 	A  # "a L H (a H (a  L A<Q   ( 	A  # "a A<Q   ( 	A  # "a A<Q   ( 	A  # "a L A<Q   ( 	A  # "a A<Q   ( 	A  # "a A<Q   ( 	A  # "a p HAJL |0NupL |0Nuz z    NuNq    _GetPixel32Smooth             ,-lh0-    3)  Chunky\GetPixel32Z.ass
; GetPixel32Z(chunky:a0:PTR TO chunky,x:d0:LONG,y:d1:LONG)(L,F)

	machine	mc68020
	fpu	1

	xdef	_GetPixel32Z

_GetPixel32Z
	cmpa.l	#0,a0
	beq.s	.out
	tst.l	d0
	blt.s	.out
	tst.l	d1
	blt.s	.out
	cmp.l	(a0),d0
	bge.s	.out
	cmp.l	(4,a0),d1
	bge.s	.out

	muls.l	(a0),d1
	add.l	d0,d1
	lsl.l	#2,d1		; d1 now contains position in buffer
	movea.l	(8,a0),a1
	move.l	(a1,d1.l),d0
	movea.l	(12,a0),a1
	fmove.s	(a1,d1.l),fp0
	rts
.out	moveq	#-1,d0
	fmove.s	#0,fp0
	rts
*T-lh0-      un) Chunky\GetPixel32Z.oYH     Develop:Sources/PowerD/DStuff/Lib/Chunky/GetPixel32Z     CODE     Jg.Jm*Jm&l" lLҀ"h  1 "h 1D  Nup<D     NuNq    _GetPixel32Z          &`-lh0-F  F  Ik)  Chunky\HLine.asszO
; HLine(chunky:a0:PTR TO chunky,x1:d0:LONG,x2:d1:LONG,y:d2:LONG,colour:d3:LONG)(LONG)

	machine	mc68020

	xdef	_HLine

_HLine
	movem.l	d2-d5,-(a7)
	move.l	(a0),d4
	move.l	(4,a0),d5
	movea.l	(8,a0),a1
	tst.l	d2
	blt.s	.finish		; above screen
	cmp.l	d2,d5
	ble.s	.finish		; below screen
	cmp.l	d0,d1
	bge.s	.continue
	exg	d0,d1		; forces d0 to contain lower value
.continue	tst.l	d1
	blt.s	.finish		; left to the screen
	cmp.l	d0,d4
	ble.s	.finish		; right to the screen

	tst.l	d0
	bge.s	.next1		; clip by left side
	moveq	#0,d0
.next1	cmp.l	d1,d4
	bgt.s	.next2		; clip by right side
	move.l	d4,d1
	subq.w	#1,d1
.next2
	muls.l	d4,d2
	add.l	d0,d2		; d2 contains position of first pixel
	sub.l	d0,d1		; d1 contains count of pixels
	add.l	d2,a1		; set first position

.loop	move.b	d3,(a1)+
	dbra.s	d1,.loop

.finish	movem.l	(a7)+,d2-d5
	rts
$-lh0-      un) Chunky\HLine.oy     Develop:Sources/PowerD/DStuff/Lib/Chunky/HLine       CODE     H< (*( "h Jm0o,lAJm"oJlp n"SAL(ԀQL <Nu    _HLine            *-lh0-v  v  Kk)  Chunky\HLineFast.assP
; HLineFast(chunky:a0:PTR TO chunky,x1:d0:LONG,x2:d1:LONG,y:d2:LONG,colour:d3:LONG)(LONG)

	machine	mc68020

	xdef	_HLineFast

_HLineFast
	move.l	d2,-(a7)

	muls.l	(a0),d2
	add.l	d0,d2		; d2 contains position of first pixel
	sub.l	d0,d1		; d1 contains count of pixels
	add.l	d2,a1		; set first position

.loop	move.b	d3,(a1)+
	dbra.s	d1,.loop

.finish	move.l	(a7)+,d2
	rts
(-lh0-      vn) Chunky\HLineFast.o7     Develop:Sources/PowerD/DStuff/Lib/Chunky/HLineFast       CODE     /L(ԀQ$NuNq    _HLineFast            'i-lh0-    i)  Chunky\Pack32.ass; Pack32(d0:L,d1:L,d2:L,d3:L)(L)

	machine	mc68020

	xdef	_Pack32

_Pack32
	andi.l	#$ff,d0
	andi.l	#$ff,d1
	andi.l	#$ff,d2
	andi.l	#$ff,d3	; 000000bb
	ror.l	#8,d0	; aa000000
	swap	d1	; 00rr0000
	lsl	#8,d2	; 0000gg00
	or.l	d1,d0
	or.l	d2,d0
	or.l	d3,d0	; aarrggbb
	rts
%-lh0-      i) Chunky\Pack32.oI     Develop:Sources/PowerD/DStuff/Lib/Chunky/Pack32      CODE     
            HAJNuNq    _Pack32           )-lh0-&  &  )  Chunky\PutPixel.ass; this function writes a coloured pixel into the chunky buffer and returns
; colour of pixel that was in these coords originaly

; PutPixel(chunky:a0:PTR TO chunky,x:d0:LONG,y:d1:LONG,colour:d2:LONG)(LONG)

	machine	mc68020

	xdef	_PutPixel

_PutPixel
	cmpa.l	#0,a0
	beq.s	.finish
	tst.l	d0
	blt.s	.finish
	tst.l	d1
	blt.s	.finish
	cmp.l	(a0),d0
	bge.s	.finish
	cmp.l	(4,a0),d1
	bge.s	.finish

	movea.l	(8,a0),a1
	muls.l	(a0),d1
	add.l	d0,d1		; d1 now contains position in buffer
	move.b	(a1,d1.l),d0
	and.l	#$ff,d0
	move.b	d2,(a1,d1.l)

.finish	rts
's-lh0-      vn) Chunky\PutPixel.o     Develop:Sources/PowerD/DStuff/Lib/Chunky/PutPixel        CODE     Jg*Jm&Jm"l l"h LҀ1     Nu    _PutPixel             +A-lh0-    )  Chunky\PutPixel32.assM)
; PutPixel32(chunky:a0:PTR TO chunky,x:d0:LONG,y:d1:LONG,colour:d2:LONG)(LONG)

	machine	mc68020
	fpu	1

	xdef	_PutPixel32

_PutPixel32
	cmpa.l	#0,a0
	beq.s	.finish
	tst.l	d0
	blt.s	.finish
	tst.l	d1
	blt.s	.finish
	cmp.l	(a0),d0
	bge.s	.finish
	cmp.l	(4,a0),d1
	bge.s	.finish

	muls.l	(a0),d1
	add.l	d0,d1
	lsl.l	#2,d1		; d1 now contains position in buffer
	movea.l	(8,a0),a1
	move.l	d2,(a1,d1.l)

.finish	rts
)-lh0-      vn) Chunky\PutPixel32.ogF     Develop:Sources/PowerD/DStuff/Lib/Chunky/PutPixel32      CODE     
Jg"JmJml lLҀ"h # Nu    _PutPixel32           ,e-lh0-    ܍)  Chunky\PutPixel32Z.ass
; PutPixel32Z(chunky:a0:PTR TO chunky,x:d0:LONG,y:d1:LONG,colour:d2:LONG,z:fp0:F)(LONG)

	machine	mc68020
	fpu	1

	xdef	_PutPixel32Z

_PutPixel32Z
	cmpa.l	#0,a0
	beq.s	.finish
	tst.l	d0
	blt.s	.finish
	tst.l	d1
	blt.s	.finish
	cmp.l	(a0),d0
	bge.s	.finish
	cmp.l	(4,a0),d1
	bge.s	.finish

	muls.l	(a0),d1
	add.l	d0,d1
	lsl.l	#2,d1		; d1 now contains position in buffer
	movea.l	(8,a0),a1
	movea.l	(12,a0),a0
	fcmp.s	(a0,d1.l),fp0
	fbgt.s	.finish
	move.l	d2,(a1,d1.l)
	fmove.s	fp0,(a0,d1.l)

.finish	rts
*&-lh0-      ) Chunky\PutPixel32Z.o"     Develop:Sources/PowerD/DStuff/Lib/Chunky/PutPixel32Z     CODE     Jg6Jm2Jm.l* l$LҀ"h  h 0D8  # 0d  Nu    _PutPixel32Z          --lh0-    Kc(  Chunky\PutPixelFast.assZ; this function writes a coloured pixel into the chunky buffer

; use this function with care, it doesn't check for bounds or if chunky array is correct

; PutPixelFast(chunky:a0:PTR TO chunky,x:d0:LONG,y:d1:LONG,colour:d2:LONG)

	machine	mc68020

	xdef	_PutPixelFast

_PutPixelFast
	movea.l	(8,a0),a1
	muls.l	(a0),d1
	add.l	d0,d1		; d1 now contains position in buffer
	move.b	d2,(a1,d1.l)
	rts
+y-lh0-      vn) Chunky\PutPixelFast.o     Develop:Sources/PowerD/DStuff/Lib/Chunky/PutPixelFast        CODE     "h LҀ Nu    _PutPixelFast             )-lh0-      Og)  Chunky\UnPack32.ass,; UnPack32(d0:UL)(L,L,L,L)

	machine	mc68020

	xdef	_UnPack32

_UnPack32
	move.l	d0,d3
	clr.l	d2
	move.b	d3,d2
	lsr.l	#8,d3
	clr.l	d1
	move.b	d3,d1
	lsr.l	#8,d3
	clr.l	d0
	move.b	d3,d0
	lsr.l	#8,d3
	rts
'-lh0-      Sg) Chunky\UnPack32.oWu     Develop:Sources/PowerD/DStuff/Lib/Chunky/UnPack32        CODE     & t r p NuNq    _UnPack32             .7-lh0-    )  Chunky_PPC\Conv24To8.ass`# Conv24To8(r3:L)(L)

	.text
	.global	_Conv24To8

_Conv24To8:
	srwi	r4,r3,8
	srwi	r5,r3,16
	andi.	r3,r3,0xff
	andi.	r4,r4,0xff
	andi.	r5,r5,0xff
	add	r3,r3,r4
	add	r3,r3,r5
	li	r0,3
	divw	r3,r3,r0
	blr

	.type	_Conv24To8,@function
	.size	_Conv24To8,$-_Conv24To8
,-lh0-      )  Chunky_PPC\Conv24To8.o|           .text        
Td>Te>pc p p |c"|c*8  |cN      _Conv24To8               _Conv24To8            1-lh0-    
9*  Chunky_PPC\Conv24ToGrey.ass<# Conv24ToGrey(dst:r3:PTR TO chunky,src:r4:PTR TO chunky32)


	.text
	.global	_Conv24ToGrey

_Conv24ToGrey:
	mfctr	r9

	lwz	r5,4(r3)
	lwz	r0,0(r3)
	mullw	r5,r5,r0
	lwz	r3,8(r3)		# get dst data address
	lwz	r4,8(r4)		# get src data address
	subi	r3,r3,1
	subi	r4,r4,4

	mtctr	r5
	li	r0,3
.loop:	lwzu	r6,4(r4)
	srwi	r7,r6,8
	srwi	r8,r6,16
	andi.	r6,r6,0xff
	andi.	r7,r7,0xff
	andi.	r8,r8,0xff
	add	r6,r6,r7
	add	r6,r6,r8
	divw	r6,r6,r0
	stbu	r6,1(r3)

	bdnz	.loop

	mtctr	r9
	blr
/-lh0-      ƙ9*  Chunky_PPC\Conv24ToGrey.o7           .text        })   |րc  8c8|8   T>TȄ>p p q |:|B|֜ B })N      _Conv24ToGrey                _Conv24ToGrey             /K-lh0-    ՠ*  Chunky_PPC\CopyChunky.assp# copies chunky data from source to destination with clipping

# CopyChunky(dst:r3:PTR TO chunky,dx:r4:LONG,dy:r5:LONG,
#            src:r6:PTR TO chunky,sx:r7:LONG,sy:r8:LONG,
#            w:r9:LONG,h:r10:LONG)

	.text
	.global	_CopyChunky
_CopyChunky:
	mr.	r11,r4	# clip left
	blt	.ok1
	li	r4,0
	sub	r7,r7,r11
.ok1:
	mr.	r11,r5	# clip top
	blt	.ok2
	li	r5,0
	sub	r8,r8,r11
.ok2:
	lwz	r0,0(r3)	# clip right
	sub.	r11,r0,r4
	blt	.finish		# whole source is behind right side of the dest
	add.	r11,r4,r9
	blt	.finish		# whole source is behind left side of the dest
	sub.	r11,r0,r11
	bgt	.ok3
	add	r9,r9,r11
.ok3:
	lwz	r0,4(r3)	# clip bottom
	sub.	r11,r0,r5
	blt	.finish		# whole source is below the dest
	add.	r11,r5,r10
	blt	.finish		# whole source is above the dest
	sub.	r11,r0,r11
	bgt	.ok4
	add	r10,r10,r11
.ok4:
	lwz	r0,0(r3)
	mullw	r5,r5,r0
	add	r5,r5,r4	# offset of the first pixel in the dest
	lwz	r3,8(r3)
	add	r3,r3,r5	# jump to the offset
	sub	r4,r0,r9	# rest width of the dest

	lwz	r0,0(r6)
	mullw	r8,r8,r0
	add	r8,r8,r7	# offset of the first pixel in the source
	lwz	r6,8(r6)
	add	r6,r6,r8	# jump to the offset
	sub	r7,r0,r10	# rest width of the source

	mr	r11,r9	# store width
.loopy:
	mr	r9,r11	# restore width
	subi	r3,r3,1
	subi	r6,r6,1
.loopx:
	lbzu	r0,1(r6)
	stbu	r0,1(r3)
	subic.	r9,r9,1
	bgt	.loopx

	add	r3,r3,r4	# add the rest
	add	r6,r6,r7

	subic.	r10,r10,1
	bgt	.loopy

.finish:	blr
--lh0-      *  Chunky_PPC\CopyChunky.oV           .text        1|#yA 8  |8P|+yA 8  }@P  }d QA }dJA }k QA })Z }e QA x}eRA p}k QA }JZ  ||"c |c*| P  }}: |B| P}+Kx}i[x8c8  5)A|c"|:5JAN      _CopyChunky              _CopyChunky           3-lh0-    0*  Chunky_PPC\CopyChunkyMask.assB# copies chunky data from source to destination with clipping, leaves colour 0

# CopyChunkyMask(dst:r3:PTR TO chunky,dx:r4:LONG,dy:r5:LONG,
#            src:r6:PTR TO chunky,sx:r7:LONG,sy:r8:LONG,
#            w:r9:LONG,h:r10:LONG)

	.text
	.global	_CopyChunkyMask
_CopyChunkyMask:
	mr.	r11,r4	# clip left
	blt	.ok1
	li	r4,0
	sub	r7,r7,r11
.ok1:
	mr.	r11,r5	# clip top
	blt	.ok2
	li	r5,0
	sub	r8,r8,r11
.ok2:
	lwz	r0,0(r3)	# clip right
	sub.	r11,r0,r4
	blt	.finish		# whole source is behind right side of the dest
	add.	r11,r4,r9
	blt	.finish		# whole source is behind left side of the dest
	sub.	r11,r0,r11
	bgt	.ok3
	add	r9,r9,r11
.ok3:
	lwz	r0,4(r3)	# clip bottom
	sub.	r11,r0,r5
	blt	.finish		# whole source is below the dest
	add.	r11,r5,r10
	blt	.finish		# whole source is above the dest
	sub.	r11,r0,r11
	bgt	.ok4
	add	r10,r10,r11
.ok4:
	lwz	r0,0(r3)
	mullw	r5,r5,r0
	add	r5,r5,r4	# offset of the first pixel in the dest
	lwz	r3,8(r3)
	add	r3,r3,r5	# jump to the offset
	sub	r4,r0,r9	# rest width of the dest

	lwz	r0,0(r6)
	mullw	r8,r8,r0
	add	r8,r8,r7	# offset of the first pixel in the source
	lwz	r6,8(r6)
	add	r6,r6,r8	# jump to the offset
	sub	r7,r0,r10	# rest width of the source

	mr	r11,r9	# store width
.loopy:
	mr	r9,r11	# restore width
	subi	r3,r3,1
	subi	r6,r6,1
.loopx:
	lbzu	r0,1(r6)
	mr.	r0,r0
	beq	.skip	# skip colour 0
	stbu	r0,1(r3)
.skip:
	subic.	r9,r9,1
	bgt	.loopx

	add	r3,r3,r4	# add the rest
	add	r6,r6,r7

	subic.	r10,r10,1
	bgt	.loopy

.finish:	blr
1E-lh0-0  0  9*  Chunky_PPC\CopyChunkyMask.o           .text        3|#yA 8  |8P|+yA 8  }@P  }d QA }dJA }k QA })Z }e QA }eRA x}k QA }JZ  ||"c |c*| P  }}: |B| P}+Kx}i[x8c8 | yA  5)A|c"|:5JAN      _CopyChunkyMask              _CopyChunkyMask           /U-lh0-(  (  q*  Chunky_PPC\CreateChunky.drOPT	NOEXE,PPC

MODULE	'exec/memory'

OBJECT chunky
	wi/he:L,
	pixel:PTR TO UB

PROC CreateChunky(wi,he)(PTR TO chunky)
	DEF	ch:PTR TO chunky
	IFN ch:=AllocVecPPC(SIZEOF_chunky+wi*he*SIZEOF_UBYTE,MEMF_PUBLIC|MEMF_CLEAR) THEN RETURN NIL
	ch.wi:=wi
	ch.he:=he
	ch.pixel:=ch+SIZEOF_chunky
ENDPROC ch
/-lh0-(  (  *  Chunky_PPC\CreateChunky.o           .text        +| !ؑ |-xm   $8`    $|) |c"|dx< ` 8  b  |N !m  | y@ 8`  H  0m   d  m $ d m 8c  d m  8! ( |N      _PowerPCBase      F  _CreateChunky                _CreateChunky             11-lh0-D  D  }*  Chunky_PPC\CreateChunky32.dOPT	NOEXE,PPC

MODULE	'exec/memory'

OBJECT chunky32
	wi/he:L,
	pixel:PTR TO L,
	zbuff:PTR TO F

PROC CreateChunky32Z(wi,he)(PTR TO chunky32)
	DEF	ch:PTR TO chunky32
	IFN ch:=AllocVecPPC(SIZEOF_chunky32+wi*he*SIZEOF_LONG,MEMF_PUBLIC|MEMF_CLEAR) THEN RETURN NIL
	ch.wi:=wi
	ch.he:=he
	ch.pixel:=ch+SIZEOF_chunky32
ENDPROC ch
1-lh0-(  (  *  Chunky_PPC\CreateChunky32.o\           .text        +| !ؑ |-xm   $8`    $|) |c"|dx< ` 8  b  |N !m  | y@ 8`  H  0m   d  m $ d m 8c  d m  8! ( |N      _PowerPCBase      F  _CreateChunky32Z             _CreateChunky32Z          2
-lh0-    *  Chunky_PPC\CreateChunky32Z.dOPT	NOEXE,PPC

MODULE	'exec/memory'

OBJECT chunky32
	wi/he:L,
	pixel:PTR TO L,
	zbuff:PTR TO F

PROC CreateChunky32Z(wi,he)(PTR TO chunky32)
	DEF	ch:PTR TO chunky32
	IFN ch:=AllocVecPPC(SIZEOF_chunky32+wi*he*(SIZEOF_LONG+SIZEOF_FLOAT),MEMF_PUBLIC|MEMF_CLEAR) THEN RETURN NIL
	ch.wi:=wi
	ch.he:=he
	ch.pixel:=ch+SIZEOF_chunky32
	ch.zbuff:=ch+SIZEOF_chunky32+wi*he*SIZEOF_LONG
ENDPROC ch
2-lh0-L  L  *  Chunky_PPC\CreateChunky32Z.o           .text        4| !ؑ |-xm   $8`    $|) |c"|dx< ` 8  b  |N !m  | y@ 8`  H  Tm   d  m $ d m 8c  d m 8c    $|) |c" d m  8! ( |N      _PowerPCBase      F  _CreateChunky32Z             _CreateChunky32Z          /-lh0-      *  Chunky_PPC\DeleteChunky.dOPT	NOEXE,PPC

OBJECT chunky32
	wi/he:L,
	pixel:PTR TO L,
	zbuff:PTR TO F

PROC DeleteChunky(ch:PTR TO chunky32)
	FreeVecPPC(ch)
ENDPROC
/5-lh0-      *  Chunky_PPC\DeleteChunky.o           .text        | ! |-xm  b  |N !8`   8!   |N      _PowerPCBase        _DeleteChunky                _DeleteChunky             /-lh0-    8*  Chunky_PPC\FillChunky.assN# FillChunky(chunky:r3:PTR TO chunky,colour:r4:LONG)

	.text
	.global	_FillChunky

_FillChunky:
	andi.	r4,r4,0xff
	slwi	r5,r4,8
	ori	r4,r4,r5
	slwi	r5,r4,16
	ori	r4,r4,r5		# we have $cocococo in r4

	mfctr	r9

	lwz	r5,4(r3)
	lwz	r0,0(r3)
	mullw	r5,r5,r0
	srwi	r5,r5,2
	mtctr	r5

	lwz	r3,8(r3)
	subi	r3,r3,4

.loop:	stwu	r4,4(r3)
	bdnz	.loop
	mtctr	r9
	blr

	.type	_FillChunky,@function
	.size	_FillChunky,$-_FillChunky
-]-lh0-      8*  Chunky_PPC\FillChunky.ov           .text        p T@.` T` })   |T|c 8c B })N      _FillChunky              _FillChunky           1-lh0-:  :  `8*  Chunky_PPC\FillChunky32.ass-S# FillChunky32(chunky:r3:PTR TO chunky,colour:r4:LONG)

	.text
	.global	_FillChunky32

_FillChunky32:
	mfctr	r9

	lwz	r5,4(r3)
	lwz	r0,0(r3)
	mullw	r5,r5,r0
	mtctr	r5

	lwz	r3,8(r3)
	subi	r3,r3,4

.loop:	stwu	r4,4(r3)
	bdnz	.loop
	mtctr	r9
	blr

	.type	_FillChunky32,@function
	.size	_FillChunky32,$-_FillChunky32
/-lh0-      e8*  Chunky_PPC\FillChunky32.oJ           .text        })   ||c 8c B })N      _FillChunky32                _FillChunky32             2T-lh0-x  x  D8*  Chunky_PPC\FillChunky32Z.ass[# FillChunky32Z(chunky:r3:PTR TO chunky,colour:r4:LONG,zdist:f1:F)

	.text
	.global	_FillChunky32Z

_FillChunky32Z:
	mfctr	r9

	lwz	r5,4(r3)
	lwz	r0,0(r3)
	mullw	r5,r5,r0
	mtctr	r5

	lwz	r5,12(r3)
	lwz	r3,8(r3)
	subi	r5,r5,4
	subi	r3,r3,4

.loop:	stwu	r4,4(r3)
	stfsu	f1,4(r5)
	bdnz	.loop
	mtctr	r9
	blr

	.type	_FillChunky32Z,@function
	.size	_FillChunky32Z,$-_FillChunky32Z
0-lh0-      H8*  Chunky_PPC\FillChunky32Z.o            .text        })   || c 88c % B })N      _FillChunky32Z               _FillChunky32Z            -;-lh0-    D8*  Chunky_PPC\GetPixel.ass-# GetPixel(chunky:r3:PTR TO chunky,x:r4:LONG,y:r5:LONG)

	.text
	.global	_GetPixel

_GetPixel:
	mr.	r7,r3
	beq	.finish
	mr.	r4,r4
	blt	.finish
	mr.	r5,r5
	blt	.finish
	lwz	r8,0(r7)
	cmpw	r4,r8
	bge	.finish
	lwz	r0,4(r7)
	cmpw	r5,r0
	bge	.finish

	lwz	r7,8(r7)
	mullw	r5,r5,r8
	add	r5,r5,r4
	lbzx	r3,r7,r5
	andi.	r3,r3,0xff
.finish:	blr

	.type	_GetPixel,@function
	.size	_GetPixel,$-_GetPixel
+-lh0-      	8*  Chunky_PPC\GetPixel.o(           .text        |gyA @|#yA 8|+yA 0  |@ @ $ |  @  |A|"|g(pc N      _GetPixel                _GetPixel             /,-lh0-    c9*  Chunky_PPC\GetPixel32.assk# GetPixel32(chunky:r3:PTR TO chunky,x:r4:LONG,y:r5:LONG)(r3:L)

	.text
	.global	_GetPixel32

_GetPixel32:
	mr.	r7,r3
	beq	.finish
	mr.	r4,r4
	blt	.finish
	mr.	r5,r5
	blt	.finish
	lwz	r8,0(r7)
	cmpw	r4,r8
	bge	.finish
	lwz	r0,4(r7)
	cmpw	r5,r0
	bge	.finish

	lwz	r7,8(r7)
	mullw	r5,r5,r8
	add	r5,r5,r4
	slwi	r5,r5,2
	lwzx	r3,r7,r5
.finish:	blr

	.type	_GetPixel32,@function
	.size	_GetPixel32,$-_GetPixel32
-p-lh0-      l9*  Chunky_PPC\GetPixel32.o\           .text        |gyA @|#yA 8|+yA 0  |@ @ $ |  @  |A|"T:|g(.N      _GetPixel32              _GetPixel32           0-lh0-    r9*  Chunky_PPC\GetPixel32Z.ass# GetPixel32Z(chunky:r3:PTR TO chunky,x:r4:LONG,y:r5:LONG)(r3:L,f1:F)

	.text
	.global	_GetPixel32Z

_GetPixel32Z:
	mr.	r7,r3
	beq	.finish
	mr.	r4,r4
	blt	.finish
	mr.	r5,r5
	blt	.finish
	lwz	r8,0(r7)
	cmpw	r4,r8
	bge	.finish
	lwz	r0,4(r7)
	cmpw	r5,r0
	bge	.finish

	lwz	r9,8(r7)
	mullw	r5,r5,r8
	add	r5,r5,r4
	slwi	r5,r5,2
	lwzx	r3,r9,r5
	lwz	r9,12(r7)
	lfsx	f1,r9,r5
.finish:	blr

	.type	_GetPixel32Z,@function
	.size	_GetPixel32Z,$-_GetPixel32Z
.r-lh0-      v9*  Chunky_PPC\GetPixel32Z.o           .text        |gyA H|#yA @|+yA 8  |@ @ , |  @  ' |A|"T:|i(.' |),.N      _GetPixel32Z             _GetPixel32Z          +-lh0-    |)  Chunky_PPC\Pack32.ass# Pack32(r3:L,r4:L,r5:L,r6:L)(L)

	.text
	.global	_Pack32

_Pack32:
	andi.	r3,r3,0xff
	andi.	r4,r4,0xff
	andi.	r5,r5,0xff
	andi.	r6,r6,0xff

	slwi	r3,r3,24
	slwi	r4,r4,16
	slwi	r5,r5,8

	or	r5,r5,r6
	or	r3,r3,r4
	or	r3,r3,r5
	blr

	.type	_Pack32,@function
	.size	_Pack32,$-_Pack32
)l-lh0-      A)  Chunky_PPC\Pack32.oq           .text        pc p p p TcTT@.|3x|c#x|c+xN      _Pack32              _Pack32           --lh0-    *dy)  Chunky_PPC\PutPixel.ass# PutPixel(chunky:r3:PTR TO chunky,x:r4:LONG,y:r5:LONG,colour:r6:LONG)

	.text
	.global	_PutPixel

_PutPixel:
	mr.	r7,r3
	beq	.finish
	mr.	r4,r4
	blt	.finish
	mr.	r5,r5
	blt	.finish
	lwz	r8,0(r7)
	cmpw	r4,r8
	bge	.finish
	lwz	r0,4(r7)
	cmpw	r5,r0
	bge	.finish

	lwz	r7,8(r7)
	mullw	r5,r5,r8
	add	r5,r5,r4
	lbzx	r3,r7,r5
	stbx	r6,r7,r5
	andi.	r3,r3,0xff
.finish:	blr

	.type	_PutPixel,@function
	.size	_PutPixel,$-_PutPixel
+-lh0-      -dy)  Chunky_PPC\PutPixel.o\           .text        |gyA D|#yA <|+yA 4  |@ @ ( |  @  |A|"|g(|)pc N      _PutPixel                _PutPixel             /-lh0-    S9*  Chunky_PPC\PutPixel32.ass # PutPixel32(chunky:r3:PTR TO chunky,x:r4:LONG,y:r5:LONG,colour:r6:LONG)

	.text
	.global	_PutPixel32

_PutPixel32:
	mr.	r7,r3
	beq	.finish
	mr.	r4,r4
	blt	.finish
	mr.	r5,r5
	blt	.finish
	lwz	r8,0(r7)
	cmpw	r4,r8
	bge	.finish
	lwz	r0,4(r7)
	cmpw	r5,r0
	bge	.finish

	lwz	r7,8(r7)
	mullw	r5,r5,r8
	add	r5,r5,r4
	slwi	r5,r5,2
	stwx	r6,r7,r5
.finish:	blr

	.type	_PutPixel32,@function
	.size	_PutPixel32,$-_PutPixel32
--lh0-      h9*  Chunky_PPC\PutPixel32.o           .text        |gyA @|#yA 8|+yA 0  |@ @ $ |  @  |A|"T:|).N      _PutPixel32              _PutPixel32           0-lh0-    E9*  Chunky_PPC\PutPixel32Z.ass # PutPixel32Z(chunky:r3:PTR TO chunky,x:r4:LONG,y:r5:LONG,colour:r6:LONG,zdist:f1:F)

	.text
	.global	_PutPixel32Z

_PutPixel32Z:
	mr.	r7,r3
	beq	.finish
	mr.	r4,r4
	blt	.finish
	mr.	r5,r5
	blt	.finish
	lwz	r8,0(r7)
	cmpw	r4,r8
	bge	.finish
	lwz	r0,4(r7)
	cmpw	r5,r0
	bge	.finish

	mullw	r5,r5,r8
	lwz	r9,8(r7)
	add	r5,r5,r4
	slwi	r5,r5,2
	stwx	r6,r9,r5
	lwz	r9,12(r7)
	lfsx	f2,r9,r5
	fcmpo	0,f1,f2
	bgt	.finish
	stfsx	f1,r9,r5
.finish:	blr

	.type	_PutPixel32Z,@function
	.size	_PutPixel32Z,$-_PutPixel32Z
.g-lh0-      M9*  Chunky_PPC\PutPixel32Z.o           .text        |gyA T|#yA L|+yA D  |@ @ 8 |  @ ,|Aց' |"T:|).' |I,.@A |)-.N      _PutPixel32Z             _PutPixel32Z          1h-lh0-    d(  Chunky_PPC\PutPixelFast.assҧ# this function writes a coloured pixel into the chunky buffer

# use this function with care, it doesn't check for bounds or if chunky array is correct

# PutPixelFast(chunky:r3:PTR TO chunky,x:r4:LONG,y:r5:LONG,colour:r6:LONG)

	.text
	.global	_PutPixelFast

_PutPixelFast:
	lwz	r0,0(r3)
	mullw	r5,r5,r0
	add	r4,r5,r4		# r4 now contains position in buffer
	lwz	r3,8(r3)		# r3 now contains pointer to chunky buffer
	stbx	r6,r3,r4
	blr

	.type	_PutPixelFast,@function
	.size	_PutPixelFast,$-_PutPixelFast
/-lh0-|   |   d(  Chunky_PPC\PutPixelFast.oL           .text          ||"c |!N      _PutPixelFast                _PutPixelFast             --lh0-      /)  Chunky_PPC\UnPack32.ass;# UnPack32(r3:UL)(L,L,L,L)

	.text
	.global	_UnPack32

_UnPack32:
	srwi	r4,r3,8
	srwi	r5,r3,16
	srwi	r6,r3,24
	andi.	r3,r3,0xff
	andi.	r4,r4,0xff
	andi.	r5,r5,0xff
	blr

	.type	_UnPack32,@function
	.size	_UnPack32,$-_UnPack32
+-lh0-x   x   B)  Chunky_PPC\UnPack32.o           .text        Td>Te>TfF>pc p p N      _UnPack32                _UnPack32              