Sprites emulation and how they work on Exodus

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

Moderators: BigEvilCorporation, Mask of Destiny

Post Reply
DarkMoe
Newbie
Posts: 3
Joined: Tue May 09, 2017 3:03 pm

Sprites emulation and how they work on Exodus

Post by DarkMoe » Tue May 30, 2017 12:35 pm

Hi all !

Been waiting a lot to finally write in here, looks like the best place to post noob emulation questions.

So, Ive been coding my own emu for the last 6 months, as a learning exercise, using Exodus as a holy bible when in doubt, and stumbled upon some weird things.

Every doc I read, says that in the SAT, the vertical position of each sprite is byte 0-9 of the first word. However, Snow Bros sets its sprites using the whole word, for example, FF3A. Now using the incredible Exodus plane viewer, those sprites are way out of screen, cannot really be seen, and my emu doesnt show them logically. But, they should be rendered somehow, since they are the characters sprites.

Fiddling with it, I found out that if I discard the MSB bit (bit 9), the sprites go to their correct location. Is this something I'm missing like in H32 mode that bit is not read ? Why is Exodus plane viewer showing one thing, and rendering other ?

Thanks for your help !

Mask of Destiny
Very interested
Posts: 615
Joined: Thu Nov 30, 2006 6:30 am

Re: Sprites emulation and how they work on Exodus

Post by Mask of Destiny » Tue May 30, 2017 6:14 pm

So I can't speak to what's going on in Exodus, but I think your problem is that you're not subtracting 128 from the 9-bit coordinate. To make it easier to have sprites that are partially offscreen, the Genesis/MD VDP uses a 9-bit coordinate system in which the top left corner of the screen has the coordinates 128,128 and the bottom right is 448,352 in H40 and 384,352 in H32 (assuming V28 anyway). Once masked to a 9-bit value, $FF3A becomes $13A which is 314 decimal which corresponds to 186 in screen space.

DarkMoe
Newbie
Posts: 3
Joined: Tue May 09, 2017 3:03 pm

Re: Sprites emulation and how they work on Exodus

Post by DarkMoe » Tue May 30, 2017 6:24 pm

Yes, I was already substracting 128, and sprites work in most other games.

The thing is, document:
http://md.squee.co/VDP#Sprite_Attribute_Table

Says that bits 0-9 are used for the position (10 bits), that would be (word1 & 0x3FF), meaning position FF3A is 33A = decimal 826 .. minus 128 = 698. So all my sprites (as well as Exodus debug plane viewer) end up outside the screen.

Natsumi
Very interested
Posts: 82
Joined: Mon Oct 05, 2015 3:00 pm
Location: 0x0
Contact:

Re: Sprites emulation and how they work on Exodus

Post by Natsumi » Tue May 30, 2017 6:43 pm

In interlace mode 2, the range is & 0x3FF, but in interlace mode 0 or 1, its 0x1FF :P
The document doesn't say it properly, but its actually either 8 or 9 bits, depending on interlace mode.

DarkMoe
Newbie
Posts: 3
Joined: Tue May 09, 2017 3:03 pm

Re: Sprites emulation and how they work on Exodus

Post by DarkMoe » Tue May 30, 2017 6:47 pm

That's it. Interlace mode, haha

So dumb, thank you !

Mask of Destiny
Very interested
Posts: 615
Joined: Thu Nov 30, 2006 6:30 am

Re: Sprites emulation and how they work on Exodus

Post by Mask of Destiny » Tue May 30, 2017 8:36 pm

DarkMoe wrote:Says that bits 0-9 are used for the position (10 bits)
Ah sorry, I got my bit counts and bit numbers crossed when reading your post originally.
Natsumi wrote:In interlace mode 2, the range is & 0x3FF, but in interlace mode 0 or 1, its 0x1FF :P
The document doesn't say it properly, but its actually either 8 or 9 bits, depending on interlace mode.
It's 9 or 10 bits, but yes. And it's worth noting that only the y-coordinate gets an extra bit in double resolution interlace mode, though I guess that might be already clear given that the linked doc only shows 9 bits for x.

Sik
Very interested
Posts: 939
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Sprites emulation and how they work on Exodus

Post by Sik » Wed May 31, 2017 3:03 am

Something to note is that it should be very common for a whole 16-bit worth of coordinate data to end up in the sprite table. The VDP ignores it, makes things easier on the 68000 and sprites off-screen should have been removed by the game anyway (how far off-screen, depends on the game).

In other words, if the upper bits of the sprite coordinates get set even though they normally go unused, just assume the game copied the coordinates as-is.
Sik is pronounced as "seek", not as "sick".

Post Reply