
	opt at-
	opt m-
	opt c+

	SECTION .text
	
	xdef transformVertexListA
	xdef f1

	cnop 0,4
f1
	; simple leaf function
	;.frame sp,0,ra	; frame pointer is sp+0, return address in ra
	; incoming args: a0..a3 & 4*4(sp)
	; regs available: t0..t9
	; a0 = addr of string
	
	move	t1,a0
@b1
	lbu		t0,(a0)		; load unsigned byte pointed to by a0 into t0
	addu	a0,1		; add 1 to a0
	bne		t0,zero,@b1	; branch back to 1 if t0!=0
	subu	v0,a0,t1	; subtract t1 for a0, result in v0
	subu	v0,1		; subtract 1 from v0

	; v0 = length of string
	; ret values = v0..v1

	j	ra				; return to caller


	cnop 0,4
transformVertexListA
	; args are VERT *, long numverts, long *transverts, long *transdepths

	sll		a1,a1,2		; multiply by four
	addu	a1,a3

	lw		t0,(a0)		; load xy
	lw		t1,4(a0)	; load z
	lw		t2,8(a0)	; load xy
	lw		t3,12(a0)	; load z
	lw		t4,16(a0)	; load xy
	lw		t5,20(a0)	; load z

@transVertexLoop
	mtc2	t0, r0		; load gte registers
	mtc2	t1, r1	
	mtc2	t2, r2	
	mtc2	t3, r3	
	mtc2	t4, r4	
	mtc2	t5, r5

	lw		t0,24(a0)	; load xy (using delay slots)	
	lw		t1,28(a0)	; load z
	lw		t2,32(a0)		


	RTPT				; equiv. gte_rtpt_b

	lw		t3,36(a0)	
	lw		t4,40(a0)	
	lw		t5,44(a0)


	swc2	r12,(a2)	; store screen verts
	swc2	r13,4(a2)
	swc2	r14,8(a2)

	swc2	r17,(a3)	; store screen depths
	swc2	r18,4(a3)
	swc2	r19,8(a3)

	;addu	a0,24
	addu	a2,12
	addu	a3,12

	slt		at,a3,a1
	bne		at,zero,@transVertexLoop
	addu	a0,24		; use branch delay slot!

	j	ra
	nop

