About Genesis emulation timings

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

Moderators: BigEvilCorporation, Mask of Destiny

Post Reply
Eke
Very interested
Posts: 885
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

About Genesis emulation timings

Post by Eke » Wed Feb 28, 2007 3:23 pm

Hi, I'm currently working on the compatibility improvment of my Genesis Plus port and find this board, so I join your for a few questions ;

I found that some games (i'm actually testing together Skitchin', Lotus 2 Recs and Legend of Galahad) are very timing sensitive, especially regarding H & V interrupts timing, hblanking period and VDP access timing (DMA or not) and wanted to understand some things:

1/ what happens if an interrupt occurs as the 68000 is frozen (for example during DMA "copy to VRAM" operation) ?

2/ in documentation, Hint is said to happen "just before" H Retrace and Vint "after" V Retrace begins but did someone now the exact timings ?
I only know that there is 14.7 us (aprox. 112 cycles) between Hint and Vint, and, according to Charles McDonald VDP doc, that Vint occurs quite as the same time as H Retrace's ending (Hblank flag set to 0 again)

3/ what is the duration for Hblanking period ? Again, according to some Charles McDonald's note about HVcounter event values, I calculate it should be 84 or 88 cycles, depending of the H mode. Is that correct ?

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: About Genesis emulation timings

Post by Stef » Wed Feb 28, 2007 7:42 pm

Eke wrote:Hi, I'm currently working on the compatibility improvment of my Genesis Plus port and find this board, so I join your for a few questions ;

I found that some games (i'm actually testing together Skitchin', Lotus 2 Recs and Legend of Galahad) are very timing sensitive, especially regarding H & V interrupts timing, hblanking period and VDP access timing (DMA or not) and wanted to understand some things:

1/ what happens if an interrupt occurs as the 68000 is frozen (for example during DMA "copy to VRAM" operation) ?

2/ in documentation, Hint is said to happen "just before" H Retrace and Vint "after" V Retrace begins but did someone now the exact timings ?
I only know that there is 14.7 us (aprox. 112 cycles) between Hint and Vint, and, according to Charles McDonald VDP doc, that Vint occurs quite as the same time as H Retrace's ending (Hblank flag set to 0 again)

3/ what is the duration for Hblanking period ? Again, according to some Charles McDonald's note about HVcounter event values, I calculate it should be 84 or 88 cycles, depending of the H mode. Is that correct ?
Hi, welcome on the board :)
You originally worked on the GC port of Genesis Plus right ?

I'll try to help you a bit on these questions :
1) Interrupt is acknowledged by the 68000 at end DMA period.
2) I don't have the perfect timing but in Gens i assume HBlank arrive at same time than Hint even if in reality Hint is the first (from some cycles, i don't know exactly). VBlank occurs at end of 224's HBlank. Vint occurs about 136 cycles after VBlank. I'm giving these values from head, you can check in Gens sources for more informations.
3) 84 cycles is the value i'm using in Gens and from my (tons of) tests, seems to be the good one :)

Eke
Very interested
Posts: 885
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Wed Feb 28, 2007 8:53 pm

Hi Stef,
yes i'm the one who bothers you last year with the GP gamecube's port , I managed to solve my previous problems and also improve overall compatibility and functionality... thanks for having made Gens open-source :wink:


My last problem is with Hint occurence: if this should happen before hblank period, I didn't understand why, in your code, you are doing it after running the 84 hblank cycles (except for line 224 in fact)...

When doing like this, I have one raster glitch in Galahad's intro (this happens also in Gens) but if I make Hint happen at the very beginning of the line (cycle 0), the glitch disappear... but that way, in Lotus 2 recs, the top half of the screen becomes blank (border color)


Another weird thing is with HV counter values... if I keep the original GP tables (beginning at 00), everything is fine but if I take yours (beginning at E4 or E8), which should be more correct since I've changed the frame timing to begin with Hblank, there's also one raster glitch appearing in Skitchin (same thing appears in Gens by the way)

I know these are very minor emulation bug for specific games but I'm very interested in understanding all the timing mechanism

:wink:

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Thu Mar 01, 2007 8:28 am

Eke wrote:Hi Stef,
yes i'm the one who bothers you last year with the GP gamecube's port , I managed to solve my previous problems and also improve overall compatibility and functionality... thanks for having made Gens open-source :wink:


My last problem is with Hint occurence: if this should happen before hblank period, I didn't understand why, in your code, you are doing it after running the 84 hblank cycles (except for line 224 in fact)...

When doing like this, I have one raster glitch in Galahad's intro (this happens also in Gens) but if I make Hint happen at the very beginning of the line (cycle 0), the glitch disappear... but that way, in Lotus 2 recs, the top half of the screen becomes blank (border color)


Another weird thing is with HV counter values... if I keep the original GP tables (beginning at 00), everything is fine but if I take yours (beginning at E4 or E8), which should be more correct since I've changed the frame timing to begin with Hblank, there's also one raster glitch appearing in Skitchin (same thing appears in Gens by the way)

I know these are very minor emulation bug for specific games but I'm very interested in understanding all the timing mechanism

:wink:
To be honest i spent many hours in adjusting timings in Gens. I never found something which make all games looks perfect. So i tried to find the best compromise. I surprised that i'm doing Hint after HBlank period in Gens, that doesn't sound correct at all...
Anyway by modifying a timing you'll fix some game but for sure you'll break some others :-/
Try all these games on Fusion, it emulated timings more accuratly then Gens. Actually there are many latencies on real hardware which aren't emulated by Gens nor by Kega. Almost of time stuff are slower on real thing then... Have you already tried to contact Steve Snake ? the author of Kega Fusion ?

Eke
Very interested
Posts: 885
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Thu Mar 01, 2007 9:08 am

yes, it's what I noticed... it's very difficult to find correct timings which work for every games

considering latencies, i implemented vdp access latency on vram writes, as specified in Genesis manual, and it corrected screen flickering in Chaos Engine for example, but for others timing, it's very difficult to know what the correct ones should be :?

anyway, I will try to contact Steve Snake, thank you for your help again :)

Stef
Very interested
Posts: 3131
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Post by Stef » Thu Mar 01, 2007 10:56 am

Eke wrote:yes, it's what I noticed... it's very difficult to find correct timings which work for every games

considering latencies, i implemented vdp access latency on vram writes, as specified in Genesis manual, and it corrected screen flickering in Chaos Engine for example, but for others timing, it's very difficult to know what the correct ones should be :?

anyway, I will try to contact Steve Snake, thank you for your help again :)
The Chaos engine are one of those i didn't fixed in Gens, but i do know they were caused by these VRAM latency writes. Anyway, i'm too lazy to implement it for only one game as i far i know, only this game requires it !

Post Reply