HBlank Timings

For anything related to VDP (plane, color, sprite, tiles)

Moderators: BigEvilCorporation, Mask of Destiny

Post Reply
mickagame
Very interested
Posts: 256
Joined: Sat Jun 07, 2008 7:37 am

Post by mickagame »

With hblank flag end at h-int + 860 it's correct.
mickagame
Very interested
Posts: 256
Joined: Sat Jun 07, 2008 7:37 am

Post by mickagame »

Other supposition :

To determine where hblank flag is set to ON/OFF we have only h-counter value.
So imagine that in fact the h-counter begins to 0 after left border at the start of active display (as Charles MC Donald said in his doc) .
So The problem is gone out and we respect his values ...
Eke
Very interested
Posts: 885
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke »

mickagame wrote:With hblank flag end at h-int + 860 it's correct.
sure it is.. from the code disassembling, any value below 924 would work
mickagame wrote:Other supposition :

To determine where hblank flag is set to ON/OFF we have only h-counter value.
So imagine that in fact the h-counter begins to 0 after left border at the start of active display (as Charles MC Donald said in his doc) .
So The problem is gone out and we respect his values ...
in this case, this would mean Hblank flag is cleared even later regarding to Hint... so the problem is still there, on the contrary

as i said, this need to be tested again to be sure of values, as well as Hcounter value when Hint is processed and the VBLANK flag

actually, the only thing we are sure is Interrupt occurences regarding to active display/borders area

Using interrupt routines to read VDP status flags could provide some valuable informations.
mickagame
Very interested
Posts: 256
Joined: Sat Jun 07, 2008 7:37 am

Post by mickagame »

My solution is bad.
The only way to be sure is to have the value of hcounter when horizontal interrupt occurs, but i don't have programming cart :-(
Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno »

Is this a good way?

Code: Select all

HBL2:		
		;a6 is $C00004 on this Hint execution
		MOVE.w	$4(a6),			-(a7)		;Get HVcounter	
		MOVE.w	(a6),				-(a7)		;Get VDPstatus
		MOVE.l	(a7)+,			$E01000		;Save both values to a known location and restore stack position
		RTE

Burning eprom... 8)
mickagame
Very interested
Posts: 256
Joined: Sat Jun 07, 2008 7:37 am

Post by mickagame »

Cool that you have possibility to test that !!!
Perhaps it will be more precise to make a loop reading hv counter and when the interrupt occurs to know the last value readed?

Because with this methode you have latency between the moment the h-int occurs and the moment the register is readed (308 MCLKS), it's the time necessary to 68k before executing the first instruction.

That's why i think it will be better to do like that.

Thank you very much for your test :-)
Eke
Very interested
Posts: 885
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke »

I think it's a better approach to read the Hcounter value in the Hint routine: you can still substract the interrupt cycles later to get an estimated value

Having the main program reading the HV counter then writing RAM introduces more latency... and the interrupt could be taken between a read and a write and you could not know.


About the VDP status flag, it would be better to have a loop which starts reading the status value as soon as Hint is processed and store successively read values in consectutive RAM addresses until the desired bit changes its value (quite like Sonic 2 Hint routine does btw)


Testing HCounter and VDP status separately is also better imo



Thanks for this anyway, can't wait for you results ;-)

PS:

some other stuff you could test when you have time:
- when VBLANK flag is being set/cleared ?
- when VINT flag is being set (relative to VINT occurence)
- how long does VINT (HINT) irq lines remains pending when interrupt are masked on 68k side (i.e does the VDP clear IRQ lines after a while) ?
- is VINT flag set when VINT interrupt is disabled on VDP side ?
- is VINT flag cleared by reading the VDP status when VINT interrupt is enable on VDP side but masked on 68k side ?
Last edited by Eke on Thu Mar 12, 2009 4:54 pm, edited 1 time in total.
mickagame
Very interested
Posts: 256
Joined: Sat Jun 07, 2008 7:37 am

Post by mickagame »

I thought to read hvcounter in a loop and write to ram only in interrupt routine, not each time you read it :)

Perhaps the vdp timings won't be a secret after these tests !!!

Can't wait your result too !!!
Eke
Very interested
Posts: 885
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke »

mickagame wrote:I thought to read hvcounter in a loop and write to ram only in interrupt routine, not each time you read it :)
oh well, something like this ?

Code: Select all

Main:
LEA       $C00004,A6

Loop:
MOVE.w   (a6),         D0     ;Get HVcounter 
BRA Loop;


Hint:
MOVE.w   D0   $E01000
// DISPLAY STORED VALUE ON SCREEN
RTE;
I don't know if this is possible with the 68k but it would be damn precise yes ;-)
Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno »

Jorge Nuno wrote:Is this a good way?

Code: Select all

HBL2:		
		;a6 is $C00004 on this Hint execution
		MOVE.w	$4(a6),			-(a7)		;Get HVcounter	
		MOVE.w	(a6),				-(a7)		;Get VDPstatus
		MOVE.l	(a7)+,			$E01000		;Save both values to a known location and restore stack position
		RTE

Burning eprom... 8)

In PAL:
Minimum value from $E01002 was #$80ED and max was #$80F6
From $E01000 was #$8205

In NTSC:
Min: #$80EC, max #$80F5
$E01000: #$8204


I obtain those values with about 40 readings


My MD has a 53.2034MHz osc


I can post a pic later if anyone wants.
mickagame
Very interested
Posts: 256
Joined: Sat Jun 07, 2008 7:37 am

Post by mickagame »

Thank you veru much !!!

To be more precise can you test with a loop like Eke wrote?

In fact there are too much latency with your loop.

It's very precious tests :wink:
Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno »

mickagame wrote:Thank you veru much !!!

To be more precise can you test with a loop like Eke wrote?

In fact there are too much latency with your loop.

It's very precious tests :wink:

I could but it will be a while to integrate that into my code, probably by monday I'll have results
mickagame
Very interested
Posts: 256
Joined: Sat Jun 07, 2008 7:37 am

Post by mickagame »

Could it be possible to have all the 40 values you had during your test?
Jorge Nuno
Very interested
Posts: 374
Joined: Mon Jun 11, 2007 3:09 am
Location: Azeitão, PT

Post by Jorge Nuno »

I have to redo them all... I just took note of the min and max
mickagame
Very interested
Posts: 256
Joined: Sat Jun 07, 2008 7:37 am

Post by mickagame »

The differences comes from the latency depending of the instruction that occurs at the moment the interrupt occurs.
I prefer waiting tests with other loop that would give more valuable informations.

Thank you for all Jorge.
Post Reply