How levels work
Guides
/
How levels work
Updated 6 years ago by droodbot

Where the level is located in RAM:

7E7620 is the start of the level data. I'm not sure on exactly how much space is allotted. 7ED930 is the beginning of a block of date equal to 55(hex).

How it is loaded:

Quite simply, it is stored one line at a time, starting from the block "0,0". This block is the top left block in every level. So, first the entire line of blocks that makes up the top most of the level is loaded. Then the line below that. All the way to the bottom most line and finally the bottom right block.

How it is checked if porky falls or passes through a block:

If Porky is at x-position 32 and y-position 64 then the game checks the block at memory offset (((yPosition / 16)+ 1)¤level_width)+((xPosition/16)+1). So, in this case, if the level was 16 blocks wide, it would check offset (((64/16)+1)¤16) + ((32/16)+1). Or, 80.

If Porky is on a block with hex value 00, then he falls. If it is 3A, then he does not fall. Other hex values will spawn swings, hearts, cupcakes, etc...

How Porky falls through some ramps when he jumps:

Some ramps are in the fashion

00 00 36 00 36 00 36 00 00

Where 36 is the ramp you can slide on and 00 is open air. When you descend from your jump your position in the future is checked against surrounding blocks. Since your going down and to the right, you end up on on of the bottom right open air squares, some times. The game takes no action and allows you to fall further, into more open air squares, and you have fallen past the ramp.

The reason for all those 55s at 7ED930:

When you got above the level, Porky's yPosition is 65532 or there abouts. This position equates to a memory offset well past the normal level data. It's set up so that this offset always points to these 55s.

55s are a special block that take on the attributes of the block below it. If you have a string of 55s and they're all directly above solid ground, they all become solid ground. Whatever the top layer of blocks is in a level is repeated for many blocks above.

What's below the level:

There seems to be random stuff loaded after the level. I am unsure how this works. Some looks like the remains of extra levels. Other stuff is just random looking. Either way, if it's possible to get below a level you can access memory that is treated as load blocks and other stuff in this data.