drhelius / Gearsystem

Sega Master System / Game Gear / SG-1000 emulator and debugger for macOS, Windows, Linux, BSD and RetroArch.
https://x.com/drhelius
GNU General Public License v3.0
267 stars 48 forks source link

The timing of rendering scanline will off by 1 line #33

Closed suzukiplan closed 3 years ago

suzukiplan commented 4 years ago
The relationship between the timing at which the scan line I recognize is drawn and the value of the V counter: V counter render scanline
$17 $18
$18 $19
$19 $1A
: :
Your implementation may be following: V counter render scanline
$18 $18
$19 $19
$1A $1A
: :

As a result, the execution timing of the H interrupt will shifted by 1 line, I confirmed: image

drhelius commented 4 years ago

Thanks for reporting. Could you share the method you used to confirm this? Is the last corrupted line in the girl's image what you're talking about?

suzukiplan commented 4 years ago

I'm also making GameGear emulator (*for test my Z80 emulator), and faced the same problem. image

suzukiplan commented 4 years ago

This problem can see in the opening of Madou Monogatari 1 (JP):

drhelius commented 4 years ago

I can see this issue in Genesis Plus GX too, it also shows a glitch but is different.

Screen Shot 2020-07-26 at 13 50 42
drhelius commented 4 years ago

I have tested it on a real GG and you are completely right, my version of Genesis Plus looks like it's doing it badly too. Are you using this https://www.smspower.org/Homebrew/SMSVDPTest-SMS in your emulator?

suzukiplan commented 4 years ago

My GG emulator not has SMS compatible mode, so cannot use SMSVDPTest-SMS yet now...

Just to be sure, I have checked the code for Genesis Plus GX and it seems that the similar issue will occurs, because the v counter and draw scanline values are the same: https://github.com/ekeeke/Genesis-Plus-GX/blob/15722b16ab5a539b14dba024bb008b5c6f22c202/core/vdp_ctrl.c#L2887-L2891

suzukiplan commented 4 years ago

FYI: I ported my GG emulator for SMS and tested with SMSVDPTest-SMS

data test misc test sprite test XScroll timing
image image image image

My HCounter emulation is not perfect, but others may be okay.

drhelius commented 4 years ago

Thanks for all the feedback, I'm going to decouple the sprite rendering code from sprite processing in my emulator, in order to achieve this off by one issue and other colision and flag issues with sprites.

drhelius commented 4 years ago

Also note that these sms tests fail in a real gg because hcount timing is quite different between sms and gg, so if you are emulating both machines you have to take into account these differences.