[demo] SNES Sonic

A place where you can keep others updated about your SNES-related projects through screenshots, videos or information in general.

Moderator: Moderators

User avatar
TOUKO
Posts: 306
Joined: Mon Mar 30, 2015 10:14 am
Location: FRANCE

Re: [demo] SNES Sonic

Post by TOUKO »

This port is incredible,even at this stage really .
I thought tiago was a megadrive fan and he wasn't very good(or even interested) at SNES coding,i was wrong.
93143
Posts: 1718
Joined: Fri Jul 04, 2014 9:31 pm

Re: [demo] SNES Sonic

Post by 93143 »

How many enemies appear onscreen at one time in the original game? Not just within 128 pixels, but actually onscreen and visible?

VBlank is about 6 KB long minus overhead. A few enemies made of a handful of 16x16 sprites each should easily fit with no special measures, even if they all animate on the same frame. I figure that if you combine rows of sprites so that you only need to do two DMA transfers per enemy, and you use a tight DMA control loop that only updates the DMA parameters that actually need refreshing between transfers, you should be able to do (for example) four enemies made of roughly four 16x16 sprites each in a little over a third of VBlank.
Stef
Posts: 263
Joined: Mon Jul 01, 2013 11:25 am

Re: [demo] SNES Sonic

Post by Stef »

Sonic 1 engine isn't optimal in the way it handles active objects, it just clips them horizontally (128 px off screen) while all the vertical area is still active. The problem is that Sonic levels can be quite large even on the vertical axis so that raise quite a lot the number of active objects at same time. Note that Sonic 3 engine is more optimized on that aspect.

@TiagoSC> Amazing work ! It's just impressive how well you actually replicated it, i know you don't plan to push further the demo but still i can't imagine how many hours you spent just to get to that point. Well done !
TiagoSC
Posts: 25
Joined: Sun Feb 26, 2017 3:44 pm

Re: [demo] SNES Sonic

Post by TiagoSC »

psycopathicteen wrote: Sun Aug 09, 2020 10:51 am What animation frames are missing? They looked the same to me.
The missing animation frames are from enemies Crabmeat and Neutron,
and some sprites that use backdrop tiles.

Image
Last edited by TiagoSC on Tue Aug 11, 2020 4:55 pm, edited 1 time in total.
TiagoSC
Posts: 25
Joined: Sun Feb 26, 2017 3:44 pm

Re: [demo] SNES Sonic

Post by TiagoSC »

TOUKO wrote: Mon Aug 10, 2020 8:35 am This port is incredible,even at this stage really .
I thought tiago was a megadrive fan and he wasn't very good(or even interested) at SNES coding,i was wrong.
Thanks!
I'm actually a multi-system fan! (from 8bit to psx/saturn).
I still want to try something on the PC-Engine,
that HuC6280 is a rocket!
Last edited by TiagoSC on Tue Aug 11, 2020 4:36 pm, edited 1 time in total.
User avatar
Nikku4211
Posts: 569
Joined: Sun Dec 15, 2019 1:28 pm
Location: Florida
Contact:

Re: [demo] SNES Sonic

Post by Nikku4211 »

TiagoSC wrote: Tue Aug 11, 2020 4:13 pm Thanks!
I'm actually a multi-system fan kkk (from 8bit to psx/saturn).
I still want to try something on the PC-Engine,
that HuC6280 is a rocket!
Oh, that's a pleasant surprise. I'm a multi-system fan too.

Also watch where you type those Ks. I know they mean lol in Portuguese, but in an English-language forum they mean something... bad...
I have an ASD, so empathy is not natural for me. If I hurt you, I apologise.
TiagoSC
Posts: 25
Joined: Sun Feb 26, 2017 3:44 pm

Re: [demo] SNES Sonic

Post by TiagoSC »

93143 wrote: Mon Aug 10, 2020 11:34 pm How many enemies appear onscreen at one time in the original game? Not just within 128 pixels, but actually onscreen and visible?

VBlank is about 6 KB long minus overhead. A few enemies made of a handful of 16x16 sprites each should easily fit with no special measures, even if they all animate on the same frame. I figure that if you combine rows of sprites so that you only need to do two DMA transfers per enemy, and you use a tight DMA control loop that only updates the DMA parameters that actually need refreshing between transfers, you should be able to do (for example) four enemies made of roughly four 16x16 sprites each in a little over a third of VBlank.
In the original Sonic I think it can happen to have 4 to 7 enemies at the same time.

In this demo there are 2 enemies that fly through the stage, they would have to be static tiles,
the others could have their tiles loaded when the camera gets close to them, MegaManX has a similar scheme,
but what makes this difficult in Sonic, is that the scroll is multi-directional all the time; I know that DonkeyKongCountry has a engine with static sprites + dynamic sprites in free slots, but the bad thing is the delay in the animation, sometimes it is noticeable, in the Coral Capers water level, when there are many sharks on the screen you notice some frames delayed, but the idea is very good!
Last edited by TiagoSC on Tue Aug 11, 2020 6:11 pm, edited 2 times in total.
TiagoSC
Posts: 25
Joined: Sun Feb 26, 2017 3:44 pm

Re: [demo] SNES Sonic

Post by TiagoSC »

Nikku4211 wrote: Tue Aug 11, 2020 4:16 pm
TiagoSC wrote: Tue Aug 11, 2020 4:13 pm Thanks!
I'm actually a multi-system fan kkk (from 8bit to psx/saturn).
I still want to try something on the PC-Engine,
that HuC6280 is a rocket!
Oh, that's a pleasant surprise. I'm a multi-system fan too.

Also watch where you type those Ks. I know they mean lol in Portuguese, but in an English-language forum they mean something... bad...
Thanks for the tip!
I'm not very good at grammar and I'm using a translator, but I can read English reasonably.
TiagoSC
Posts: 25
Joined: Sun Feb 26, 2017 3:44 pm

Re: [demo] SNES Sonic

Post by TiagoSC »

Stef wrote: Tue Aug 11, 2020 6:50 am Sonic 1 engine isn't optimal in the way it handles active objects, it just clips them horizontally (128 px off screen) while all the vertical area is still active. The problem is that Sonic levels can be quite large even on the vertical axis so that raise quite a lot the number of active objects at same time. Note that Sonic 3 engine is more optimized on that aspect.

@TiagoSC> Amazing work ! It's just impressive how well you actually replicated it, i know you don't plan to push further the demo but still i can't imagine how many hours you spent just to get to that point. Well done !
Thank you Stef! I know that there are many programmers like you who can do much better than I did.

This engine was made at the same time as the MegaManx-Megadrive, even sharing code and tools.
There are still a lot of bugs to fix, and at the moment I'm finishing the sound driver.

I redid some things and the performance has now improved a lot, I can even drop 32 rings when Sonic is hurt, just like the original.

Image
Stef
Posts: 263
Joined: Mon Jul 01, 2013 11:25 am

Re: [demo] SNES Sonic

Post by Stef »

TiagoSC wrote: Tue Aug 11, 2020 4:54 pm Thank you Stef! I know that there are many programmers like you who can do much better than I did.
Are you kidding ? :D Don't be that modest :p With your MD's Megaman X port and now this SNES Sonic demo you already proven that you're a very skilled developer !
This engine was made at the same time as the MegaManx-Megadrive, even sharing code and tools.
There are still a lot of bugs to fix, and at the moment I'm finishing the sound driver.
I guess both engine share similarities, that shows the base engine is flexible enough :)
Something i was wondering is about the level encoding, did you keep the same method as Sonic 1 engine (if i remember correctly it's 256x256 RLE compressed block with 16x16 tiles) ? Hopefully the SNES support natively 16x16 tile which should make that part even easier than on MD but still i think it's something than can cost quite a bit of CPU time and i'm not sure the doubled RAM capacity on SNES is enough to store a whole map (as they can be huge).
I redid some things and the performance has now improved a lot, I can even drop 32 rings when Sonic is hurt, just like the original.

Image
Haha really well done ! I've to admit this is the first thing i've tested in your demo as i would had expected to see slowdowns here but i saw you limited the ring number to avoid that. It's really impressive you were able to bring back the original number of rings now !
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: [demo] SNES Sonic

Post by tokumaru »

Stef wrote: Wed Aug 12, 2020 1:50 ammethod as Sonic 1 engine (if i remember correctly it's 256x256 RLE compressed block with 16x16 tiles) ?
It's not RLE, it's Kosinski compression, based on LZSS.
Hopefully the SNES support natively 16x16 tile which should make that part even easier than on MD
I doubt it, considering that the attributes of each 8x8-pixel tile (palette and flipping) can be controlled individually in the Sonic engine.
i'm not sure the doubled RAM capacity on SNES is enough to store a whole map (as they can be huge).
Sonic maps are kept entirely in RAM even on the MD, as they're not made of unique 256x256-pixel blocks, these are indexed by the plane maps and reused extensively.
Stef
Posts: 263
Joined: Mon Jul 01, 2013 11:25 am

Re: [demo] SNES Sonic

Post by Stef »

tokumaru wrote: Wed Aug 12, 2020 2:34 am It's not RLE, it's Kosinski compression, based on LZSS.
Even worse for CPU but better for the compression :)
I doubt it, considering that the attributes of each 8x8-pixel tile (palette and flipping) can be controlled individually in the Sonic engine.
but that is just for metatile definition right ? so not needed anymore as soon your metatiles are "unpacked / decoded".
Sonic maps are kept entirely in RAM even on the MD, as they're not made of unique 256x256-pixel blocks, these are indexed by the plane maps and reused extensively.
I'm not sure about what you mean by "maps are kept entirely in RAM", the "compressed" version of course, the final unpacked / decoded version.. no way. Still i think i need to check on Sega retro how maps are exactly encoded, in my mind it was definitely not so trivial to decode the map live (i mean : one row + one map column per frame).
User avatar
tokumaru
Posts: 12427
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: [demo] SNES Sonic

Post by tokumaru »

Stef wrote: Wed Aug 12, 2020 5:09 amI'm not sure about what you mean by "maps are kept entirely in RAM", the "compressed" version of course, the final unpacked / decoded version.. no way.
There's no "final/decoded" version, what's in RAM is decoded on the fly. It's not as complex/slow as it sounds: use bits 8-15 of the coordinates to look up the index of a 256x256-pixel block in the level map, and then bits 4-7 to look up 16x16-pixel blocks within the 256x256. From there you can either lookup the individual tiles for VRAM updates or the collision information for physics. I've done much more complex map decoding on the fly on the NES.

I've never done any Genesis coding, but I've played with the RAM as the game was running in order to see the changes, and indeed changing the "compressed" data structures resulted in live changes to the level map.
CloudStrife1992
Posts: 1
Joined: Wed Aug 12, 2020 1:26 pm

Re: [demo] SNES Sonic

Post by CloudStrife1992 »

TiagoSC wrote: Tue Aug 11, 2020 4:54 pm
Stef wrote: Tue Aug 11, 2020 6:50 am Sonic 1 engine isn't optimal in the way it handles active objects, it just clips them horizontally (128 px off screen) while all the vertical area is still active. The problem is that Sonic levels can be quite large even on the vertical axis so that raise quite a lot the number of active objects at same time. Note that Sonic 3 engine is more optimized on that aspect.

@TiagoSC> Amazing work ! It's just impressive how well you actually replicated it, i know you don't plan to push further the demo but still i can't imagine how many hours you spent just to get to that point. Well done !
Thank you Stef! I know that there are many programmers like you who can do much better than I did.

This engine was made at the same time as the MegaManx-Megadrive, even sharing code and tools.
There are still a lot of bugs to fix, and at the moment I'm finishing the sound driver.

I redid some things and the performance has now improved a lot, I can even drop 32 rings when Sonic is hurt, just like the original.

Image
Congratulations, you can make the updates available for us to test ?
Stef
Posts: 263
Joined: Mon Jul 01, 2013 11:25 am

Re: [demo] SNES Sonic

Post by Stef »

tokumaru wrote: Wed Aug 12, 2020 7:52 am There's no "final/decoded" version, what's in RAM is decoded on the fly. It's not as complex/slow as it sounds: use bits 8-15 of the coordinates to look up the index of a 256x256-pixel block in the level map, and then bits 4-7 to look up 16x16-pixel blocks within the 256x256. From there you can either lookup the individual tiles for VRAM updates or the collision information for physics. I've done much more complex map decoding on the fly on the NES.

I've never done any Genesis coding, but I've played with the RAM as the game was running in order to see the changes, and indeed changing the "compressed" data structures resulted in live changes to the level map.

Ok, well the format matches the one i had in mind but for some reason i over estimated the required decoding processing for it. When you need to update both a column and and row of data, you still need to update at min about 42/2 + 30/2 = 36 "16x16 tiles", convert them to 2x2 "8x8 tiles" so about 144 tiles to update in the tilemap (and properly arranged). And this at every frame when scrolling is at max speed (16 px per frame)...
Ok not that intensive but still, for me that is definitely not free :p
Post Reply