Page 1 of 1

VBLK timing

Posted: Wed Mar 21, 2007 9:56 am
by ob1
Hi you all.
I'm currently working on vSync, and experience some strange behaviour.
First of all, here's my V_INT code :

Code: Select all

V_INT:
	mov	#0,R0
	mov.w	R0,@($16,GBR)	; Clear VINT
	rte
	add	#1,R13		; Executes ADD before branching
Then, here's my main loop :

Code: Select all

main:
	bsr	waitForVBLK	; wait for V_INT to happen
	nop

	add	#1,R12

	bsr	waitForDISP	; wait for V_INT to finish, and display to begin
	nop

	bra	main
	nop
with

Code: Select all

waitForVBLK:
	mov.l	REG_VDP,R1
	mov.w	VALUE_8000h,R2
whileDISP:
	mov.w	@($A,R1),R0	; while (FB_CTRL_REG & 8000h == 0) ;
	and	R2,R0
	cmp/eq	#0,R0
	bt	whileDISP
	rts
	nop			; Executes NOP before branching
and

Code: Select all

waitForDISP:
	mov.l	REG_VDP,R1
	mov.w	VALUE_8000h,R2
whileVBLK:
	mov.w	@($A,R1),R0	; while (FB_CTRL_REG & 8000h == 8000h) ;
	and	R2,R0
	cmp/eq	R2,R0
	bt	whileVBLK
	rts
	nop			; Executes NOP before branching
And, guess what ... R12 is sensibly different from R13 !!!
I've benchmarked R13 (the V_INT code) and I know it is true. But R12 is more than twice bigger !!! Does anyone know where this gap come from ?

Re: VBLK timing

Posted: Wed Mar 21, 2007 10:26 am
by Stef
ob1 wrote:Hi you all.
I'm currently working on vSync, and experience some strange behaviour.
First of all, here's my V_INT code :

Code: Select all

V_INT:
	mov	#0,R0
	mov.w	R0,@($16,GBR)	; Clear VINT
	rte
	add	#1,R13		; Executes ADD before branching
Then, here's my main loop :

Code: Select all

main:
	bsr	waitForVBLK	; wait for V_INT to happen
	nop

	add	#1,R12

	bsr	waitForDISP	; wait for V_INT to finish, and display to begin
	nop

	bra	main
	nop
with

Code: Select all

waitForVBLK:
	mov.l	REG_VDP,R1
	mov.w	VALUE_8000h,R2
whileDISP:
	mov.w	@($A,R1),R0	; while (FB_CTRL_REG & 8000h == 0) ;
	and	R2,R0
	cmp/eq	#0,R0
	bt	whileDISP
	rts
	nop			; Executes NOP before branching
and

Code: Select all

waitForDISP:
	mov.l	REG_VDP,R1
	mov.w	VALUE_8000h,R2
whileVBLK:
	mov.w	@($A,R1),R0	; while (FB_CTRL_REG & 8000h == 8000h) ;
	and	R2,R0
	cmp/eq	R2,R0
	bt	whileVBLK
	rts
	nop			; Executes NOP before branching
And, guess what ... R12 is sensibly different from R13 !!!
I've benchmarked R13 (the V_INT code) and I know it is true. But R12 is more than twice bigger !!! Does anyone know where this gap come from ?
Shouldn't your V_INT code having some push pop for R0 register ?

Re: VBLK timing

Posted: Wed Mar 21, 2007 10:53 am
by ob1
Stef wrote:Shouldn't your V_INT code having some push pop for R0 register ?

Code: Select all

+----------+
| APPLAUSE |
+----------+

Posted: Wed Mar 21, 2007 11:42 am
by Stef
Does it fixed your problem O_o ?

Posted: Wed Mar 21, 2007 1:03 pm
by ob1
Sure it did !!
You rock !

Posted: Wed Mar 21, 2007 2:10 pm
by Stef
hehe, cool :) i though another problem left ^^