
; 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
