		
	org	hcoreStartPc
	
	.def	pixelCount	20250	;5062	;720*450/8 (8 cores) / 8 loads	
	.def	pixelOffset	324000	;81000	;720*450*2/8 (8cores)
	
	nop
	nop
	
	move	hold,pixelOffset
	moveh	hold,last,>>pixelOffset
	or	r0,last,0	;
	gssr	hold,0			;get core number
	fead	last,r0	
	nop
	mul	r21			;offset = pixel count * core number
	
	move	r30,$100		;counter
	
doAgain	
	
	move	hold,testPic
	moveh	hold,last,>>testPic
	add	r0,last,r21		;source+offset
	
	move	hold,frame
	moveh	hold,last,>>frame
	add	r1,last,r21		;dest+offset
	
	move	hold,pixelCount
	moveh	hold,last,>>pixelCount	
	or	r2,last,0		;count
	
	move	hold,$ffff
	moveh	hold,last,$00ff	
	or	r5,last,0		;
	move	r4,$ff
	move	r3,1			;
	
	rqld	r0,0
	rqld	r0,2
	rqld	r0,4
	rqld	r0,6
	rqld	r0,8
	rqld	r0,10
	rqld	r0,12
	rqld	r0,14
	
loop
	ld	r13		;00RRGGBB
	ld	r14		;00RRGGBB
	ld	r15		;00RRGGBB
	ld	r16		;00RRGGBB
	ld	r17		;00RRGGBB
	ld	r18		;00RRGGBB
	ld	r19		;00RRGGBB
	ld	r20		;00RRGGBB

	cmpeq	r3,r2
	rqld.tc	r0,16		;request next
	rqld.tc	r0,18		;request next
	rqld.tc	r0,20		;request next
	rqld.tc	r0,22		;request next
	rqld.tc	r0,24		;request next
	rqld.tc	r0,26		;request next
	rqld.tc	r0,28		;request next
	rqld.tc	r0,30		;request next
	
	st	r13,r1,0
	st	r14,r1,2
	st	r15,r1,4
	st	r16,r1,6
	st	r17,r1,8
	st	r18,r1,10
	st	r19,r1,12
	st	r20,r1,14
	
	cmpeq	r3,r2
	br.tc	loop
	add	r3,r3,1		;delay slot
	add	r0,r0,16	;delay slot
	add	r1,r1,16	;delay slot
	nop			;delay slot
	
	br	doAgain	
	;over	br	over		
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	nop			;delay slot
	