05352e324db263bea67579c9a887e4ba86131109
Retroprogramming/NES/Contra_analysis.md
| ... | ... | @@ -35,17 +35,16 @@ I have a rough outline of where I’d like to go from here with this series but |
| 35 | 35 | Each level in the game is made up of a series of independent screens. The image below shows an overview of the first level of the game divided up into the 13 screens that comprise the stage. |
| 36 | 36 | |
| 37 | 37 |  |
| 38 | -screens |
|
| 39 | 38 | |
| 40 | 39 | Each screen is built from a collection of non-overlapping super tiles which each take up 32×32 pixels worth of screen space. A screen is always made of exactly 8 super tiles across and 7 from top to bottom. This results in a final screen size of 256×224 pixels. The native resolution of the NES is 256×240 pixels so Contra leaves some of the screen space unused rather than trying to deal with splitting super tiles in half to perfectly fill up the display. It was fairly common at the time for console games to not care what they were displaying at the very top and bottom of the screen because it often wasn’t visible on CRT TVs. |
| 41 | 40 | |
| 42 | 41 | The image below shows the 7th screen of the first level of Contra divided up into the 56 super tiles that make up the background. |
| 43 | 42 | |
| 44 | -supertiles |
|
| 43 | + |
|
| 45 | 44 | |
| 46 | 45 | Each super tile is in turn made up of 4×4 regular tiles which are 8×8 pixels each in size. These regular tiles are what the NES hardware actually uses to display background maps so all games need to break their maps down into 8×8 pixel tiles at some point. |
| 47 | 46 | |
| 48 | -Collision Data |
|
| 47 | +## Collision Data |
|
| 49 | 48 | |
| 50 | 49 | The collision information for each screen is derived from the final layout of the regular tiles as opposed to being explicitly authored as a separate map. The resulting collision map is made up of 16×16 pixel blocks of the screen. This means that there are 2×2 regular tiles that make up each block of collision data, but when deriving the collision type for each block, only the upper left regular tile is considered. |
| 51 | 50 | |
| ... | ... | @@ -53,9 +52,9 @@ Each level defines 4 ranges of tile indices with all of the tiles in each range |
| 53 | 52 | |
| 54 | 53 | The image below shows a part of the first level of the game with the resulting collision map overlaid. Blocks with collision type water are colored blue and blocks with collision that allows you to walk on them but also move through them are colored green. Empty space collision blocks are black and completely solid collision blocks are not used in this section of the level. |
| 55 | 54 | |
| 56 | -collision |
|
| 55 | + |
|
| 57 | 56 | |
| 58 | -Enemies |
|
| 57 | +## Enemies |
|
| 59 | 58 | |
| 60 | 59 | Each screen has a list of the enemies that need to be spawned into the world as you scroll through it. The list is presorted according to the distance you need to have scrolled the screen in order to spawn the enemy. For example, the first enemy in the first level has a scroll value of 16, so once you start playing and move far enough to the right to scroll the screen 16 pixels, that first enemy is spawned. Because the list is sorted by scroll distance and the screen can only scroll in 1 direction, there is always exactly 1 candidate for the next enemy to be spawned. |
| 61 | 60 |