Basics — ppuReset(): the next screen starts from a clean PPU. More...
#include <snes.h>Macros | |
| #define | SCREEN_A_FRAMES 120 |
| How long screen A stays, in frames (two seconds at 60 Hz). | |
Functions | |
| int | main (void) |
| Entry point: screen A for two seconds, ppuReset(), screen B. | |
| void | screen_a_setup (void) |
| Screen A: text on BG3 of Mode 1, and every other PPU register changed on purpose. | |
| void | screen_b_setup (void) |
| Screen B: set up exactly like a first screen. | |
Basics — ppuReset(): the next screen starts from a clean PPU.
A game is a chain of screens: title, game, game over, title again. Each one sets the PPU registers it needs, and every register it does not set keeps the value the previous screen left. consoleInit() rewrites only a few of them; ppuReset() rewrites all of them, to their power-on value.
Screen A changes nearly every PPU register: the BG mode (Mode 1, text on BG3), the sprite size and tile base, the map and tile bases of the four layers, the scrolls, main and sub screen, a window, color math (a tint), mosaic, the Mode 7 matrix, SETINI, the brightness, and an HDMA wave on BG3. Two seconds later the program calls ppuReset() and sets up screen B the way any first screen is set up. Screen B shows no trace of screen A. Remove the ppuReset() call and screen B inherits the scroll of BG1 and the tint.
| #define SCREEN_A_FRAMES 120 |
How long screen A stays, in frames (two seconds at 60 Hz).
| int main | ( | void | ) |
Entry point: screen A for two seconds, ppuReset(), screen B.
| void screen_a_setup | ( | void | ) |
Screen A: text on BG3 of Mode 1, and every other PPU register changed on purpose.
The visible part is the text (BG3), its scroll, the tint, the mosaic and the wave. The rest (BG1, BG2, BG4, OBJSEL, the window, the sub screen, Mode 7, SETINI) is invisible here and changed so that ppuReset() has something to undo; the manifest reads it back from the PPU.
| void screen_b_setup | ( | void | ) |
Screen B: set up exactly like a first screen.
Nothing here undoes screen A: ppuReset() did. The manifest reads the PPU at the first instruction of this function, right after ppuReset(), and finds the values it reads at main().