Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / Sonic Development Theory

Author
Message
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 12th Oct 2002 22:10
Just taking a cue from Rich on Sonic Development here from the '2D rocks' thread...

So, has anyone done a Sonic engine? The part I'm most curious about is the map design, development and rendering. There are some pretty cool things going on there.

First off, you have the curved corners (loops even) which are pretty neat. Sonic is realigned to match the angle of the curve.

Gravity is pretty straightforward, as is movement (although, our super hero does have the ability to change directions and pick up speed in mid air...).

The background movement is absolutely great. I'm just blown away by the design work involved there, not just backgrounds, but the whole game, top to bottom. There is so much art there it's not even funny. They must've worked for eons to put that game together.

So, as far as the map engine goes, how do you guys think they did it?

Did thy use several maps that act as one (several background levels, then the foreground)?

For the editor, would they have mocked up some kind of grid-based editor to place the map pieces?

What about an editor to configure the settings for each piece? Some things you can jump through, others you cannot. Where that gets interesting is where Sonic CAN jump through a tree (so, it's as though it's not really there), and yet, a bonus box (speed, sheild, etc.) can sit on TOP of a tree (whereas Sonic can't). So there's obviously some pretty serious configuration going on there.

What about the animated pieces that only start when Sonic actually touches them (bridges, continue points, crumbling sections of the map)?

Do all the map pieces conform to a certain set of size constraints (i.e., each dimension must be in a multiple of 8 pixels)?

What's amazing is the framerates those guys were able to achieve working off that z90 and hacking in pure machine code. I've seen far more trivial games use infinately more media and not look as good as this.

Comments appreciated.
-= i only do what my rice krispies tell me to do =-
Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 13th Oct 2002 01:20
I'm just going to point you and Nemesis in each other's directions. Look at his website and you'll see what I mean. He probably knows more about the Sonic games than the programmers did. And just off the top of my head, I think Sonic 2 took 6 months to make
http://homepages.ihug.com.au/~nemesis2k2/

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
Nemesis
21
Years of Service
User Offline
Joined: 18th Sep 2002
Location: Australia
Posted: 13th Oct 2002 03:36
Quote: "Gravity is pretty straightforward, as is movement (although, our super hero does have the ability to change directions and pick up speed in mid air...).
"

There is no global gravity as such. THe effect of gravity is defined on the characters only.

Quote: "The background movement is absolutely great. I'm just blown away by the design work involved there, not just backgrounds, but the whole game, top to bottom. There is so much art there it's not even funny. They must've worked for eons to put that game together"

The graphics processor in the genesis is known as the VDP, and it allows for some ancy effects in that regard. There are two main layers of tiles, those being a and b. You can perform raster effects on one layer without affecting the other whatsoever, and these raster effects are hardware supported, so they run lightning fast. They used these effects to create the background movement and 2 player splitscreen effect. The only limitation of these effects is that they have to be based on horizontal rows of pixels.

Quote: "Did thy use several maps that act as one (several background levels, then the foreground)?

For the editor, would they have mocked up some kind of grid-based editor to place the map pieces? "

Yes. Layer A and B are constructed out of rows of 128x128 pixel blocks, which are arranged in a fixed grid pattern.

Quote: "What about an editor to configure the settings for each piece? Some things you can jump through, others you cannot. Where that gets interesting is where Sonic CAN jump through a tree (so, it's as though it's not really there), and yet, a bonus box (speed, sheild, etc.) can sit on TOP of a tree (whereas Sonic can't). So there's obviously some pretty serious configuration going on there."

Each peice does not have an individual setting, but they did some very clever things with collision. I'll tell you about that later on.

Quote: "What about the animated pieces that only start when Sonic actually touches them (bridges, continue points, crumbling sections of the map)? "

There is a VRAM which buffers all the patterns that have to be used at any one given time. To create an animated effect, they could either load all the frames of the animation in the VRAM at one time, and just change the block numbers being used, or they could realod the appropriate patterns into the VRAM over the top of the old ones. The first method is preferred because it uses less power, but it also uses more video ram, so they sometimes have to settle for the second depending on how much has been used already.

Quote: "Do all the map pieces conform to a certain set of size constraints (i.e., each dimension must be in a multiple of 8 pixels)? "

Heh, you're not going to believe this part. Every single block you see in the game is made up of 8x8 pixel blocks, which is a requirement of the VDP. In order to construct the 128x128 pixel blocks used in the levels, they use what have been dubbed mappings to construct larger blocks out of these 8x8 blocks. First, there are the 16x16 block mappings. When defining the 16x16 block mappings, you can flip and mirror any of the 8x8 blocks being loaded in, and you specify the palette line to use for that block (The genesis has 4 16 colour palette lines). There's then the 128x128 block mappings, which are a collection of 16x16 block mappings. The only thing that can be directly placed into a level is a 128x128 block, and a sprite.

Quote: "What's amazing is the framerates those guys were able to achieve working off that z90 and hacking in pure machine code. I've seen far more trivial games use infinately more media and not look as good as this."

Well, the genesis used a M68K as the primary chipset. The Z80 was used as a sound processor. It was programmed very well though.


I'll also let you know how the collision works. First of all forget the image that the block contains. The image has absolutely nothing to do with the collision. There's basically in invisible collision box on top of every 16x16 block that sets what's solid and what's not. This collision box has two parts to it. The main part of it is the collision array. The collision array stores the actual data that says that is a block is solid in certain places. It does that through 16 bytes per collision box. To understand how those 16 bytes set what's solid, imagine a 16x16 block. Now imagine that 16x16 block with the numbers 1-10 (hex) down the side starting from the bottom and going up to the top, and starting from the left and going up as it moves right along the top, so that you can give an exact location of each pixel. (eg, the top left pixel would be 10,00) Now, in this array the first two bytes define what's solid for the row of pixels on the left side of that 16x16 block. Basically the first of those two bytes says where to start making things solid, and the second byte says where to stop making them solid. So if you entered the value 0010, the first row would be solid from the very bottom of the block all the way up to the top. If you were to enter the value 020E, there would be two pixels on either side of the block that are not solid, and everything in the middle would be. The next two bytes after that are for the next row, etc. After 16 bytes the definitions for the next collision box begin.

Now, to specify which blocks use which collision boxes, there are collision indexes, which give an array location for each 16x16 block. If you look at the space used by the collision array, you can divide that by 16 (the number of bytes used by each entry into the array) to give a one byte value, which represents the maximum number of collision boxes that the array can hold in the S2 platform, which is FF. Now, for each level there is at least one 16x16 collision index, and that index consists of a whole heap of array locations, one for each 16x16 block. If for example you wanted the 9th 16x16 block to use the collision box with an array location of 3E, you would give the 9th byte of the collision index for that level a value of 3E.

It is through collision indexes that the loops work in the game. For any levels that use multiple collision layers like that, there is a secondary 16x16 collision index. There is a sprite that switches between the 16x16 collision index in use.

Now just setting something as solid, doesn't give it the effect of having a slope. There's anotehr array in the rom, which has one byte in it for each collision array location. To understand how this value works, think of two lines running parallel to each other, both with the value 0-F along them. Now, the first value of the byte gives a point on the right line, and the second value gives a point on the left line. Now imagine drawing a line between these to points. If the points are different, the resulting gradient will be taken to create the effect of a slope and the resistance going up it on the box in the corresponding collision array location.

Sprite collision is handeled differently though. Sprites can have two collision boxes, one active, and one passive. The active one is used for effects, such as when two active boxes touch, run this section of code. They use this box for collisions with enemies. The second passive one is used for collision against the level itself.

I know everything! At least I don't know anything I don't know.
Nemesis
21
Years of Service
User Offline
Joined: 18th Sep 2002
Location: Australia
Posted: 13th Oct 2002 03:47
Quote: "What about the animated pieces that only start when Sonic actually touches them (bridges, continue points, crumbling sections of the map)? "

Sorry, I didn't read this thoroughly enough the first time. Each sprite in the game is hardcoded, and as such they can create pretty much any effect they care to. In the case of those examples, when the active collision boxes cross, it would run the code that makes that effect. Each sprite also has a few bytes of allocated memory to store miscelaneous values it may need. The VDP has a limitation of 80 sprites in the buffer range at one time though.

I know everything! At least I don't know anything I don't know.
Milamber
21
Years of Service
User Offline
Joined: 27th Sep 2002
Location: Australia
Posted: 13th Oct 2002 04:31

Did you understand all that?

System Specs: AMD Athlon 1700+ XP, GA-7VRX motherboard, 128MB DDR RAM, GeForce2 MX400 64MB VRAM
ChipOne
21
Years of Service
User Offline
Joined: 12th Sep 2002
Location: Canada
Posted: 13th Oct 2002 11:29
my God, Nem, you're my freekin' hero.

first off a couple things:
1) my reference to z90 (which should of been z80) was missing my reference to sound. oops. i just got excited as i was playing and started munging thoughts together (i have all my game systems hooked up next to my computer).

2) incredible depth to your analysis...i'm pouring through your site now, getting a better understanding of one of my all time fav's

3) 'gravity' was only meant as an effect on sprites. i was referring to the effect of gravity and movement and how to implement it programmatically.

well, thanks for the input...lots of questions left, but i've got a lot of reading to do now that i've been pointed towards your site.

cheers!

-= i only do what my rice krispies tell me to do =-
Seph
21
Years of Service
User Offline
Joined: 3rd Oct 2002
Location:
Posted: 23rd Oct 2002 02:54
Nemesis sounds like Cyan Helkaraxe. ;D

Kangaroo2
21
Years of Service
User Offline
Joined: 26th Sep 2002
Location: United Kingdom
Posted: 13th Dec 2002 02:09
WOW Kudos 2 Nemesis! Although I've got a pretty good Sonic demo running in DB1, wanna convert it to DBPro.

Havn't been to Nemesis' site (Will when I have the necessary hours to devour the info as I will) but have you researched into the 8bit versions as well? The movement/physics of Sonic were pretty good, especially in Sonic Chaos - 8bit Mobius strips and loop the loops

LOVE early Sonic games but Sonic Adventure 2 is sadly awful the GBA and NGPC versions are cool tho

* If the apocalypse comes, email me *

Login to post a reply

Server time is: 2024-04-20 06:29:57
Your offset time is: 2024-04-20 06:29:57