Super FX game skeleton — a game loop at 60 fps while the GSU renders. More...
Macros | |
| #define | LETTERBOX_BOTTOM 40 |
| Bottom band: at least one line keeps force blank across line 0. | |
| #define | LETTERBOX_TOP 40 |
| Letterbox bands (lines): the NMI moves frames in VBlank + top band. | |
| #define | VRAM_BG1_A 0x0000 |
| VRAM word addresses: two BG1 char blocks, the map, the sprite. | |
| #define | VRAM_BG1_B 0x2000 |
| #define | VRAM_BG1_MAP 0x4000 |
| #define | VRAM_OBJ 0x6000 |
Functions | |
| void | buildEdges (void) |
| Build edge buffer from projected vertices. | |
| int | main (void) |
| static void | prepareFrame (u8 angle_y, u8 angle_x) |
| Rotate the cube to the given angles and upload its edges. | |
| void | rotateVertex (u16 idx) |
| Rotate one vertex, store projected screen coords (clamped). | |
| static void | startJob (void) |
| Start the renderer from the code cache; returns at once. | |
| void | writeEdgesToSRAM (void) |
Variables | |
| static const u8 | ce [] |
| The 12 edges, as vertex index pairs. | |
| static const u16 | crosshair_pal [16] |
| OBJ palette 0: transparent, then the crosshair's yellow. | |
| static const u8 | crosshair_tile [32] |
| The crosshair: one 8x8 4bpp tile, colour 1 (original art). | |
| static const u16 | cube_pal [] |
| BG palette 0: the GSU bitmap colours. | |
| static const s16 | cvx [] = {-25, 25, 25,-25,-25, 25, 25,-25} |
| Cube vertices, x. | |
| static const s16 | cvy [] = {-25,-25, 25, 25,-25,-25, 25, 25} |
| Cube vertices, y. | |
| static const s16 | cvz [] = {-25,-25,-25,-25, 25, 25, 25, 25} |
| Cube vertices, z. | |
| u8 | edge_buffer [48] |
| s16 | g_cax |
| s16 | g_cay |
| u8 | g_px [8] |
| Projected vertices, x (0-255). | |
| u8 | g_py [8] |
| Projected vertices, y (0-127). | |
| s16 | g_sax |
| s16 | g_say |
| Sines and cosines of the two rotation angles. | |
| const u8 | gsu_cube [] |
| const u8 | gsu_cube_end [] |
| u16 | r_game_frames |
| Game-loop frames (one per WaitForVBlank). | |
| u16 | r_jobs |
| GSU jobs started. | |
| u16 | r_music_pos |
| The module's pattern position, sampled every frame. | |
| u16 | r_ship_x |
| Crosshair position (the game's state). | |
| u16 | r_ship_y |
| static const s8 | sin_tab [256] |
| Sine table, 256 steps per turn, amplitude 127. | |
Super FX game skeleton — a game loop at 60 fps while the GSU renders.
The shape of a Super FX game: the CPU runs the game every frame (here, a crosshair steered with the D-pad, and music), the GSU renders the 3D view on its own clock (here, superfx_3d's rotating cube), and the NMI moves each finished frame to VRAM. Nothing waits for anything else.
| #define LETTERBOX_BOTTOM 40 |
Bottom band: at least one line keeps force blank across line 0.
| #define LETTERBOX_TOP 40 |
Letterbox bands (lines): the NMI moves frames in VBlank + top band.
| #define VRAM_BG1_A 0x0000 |
VRAM word addresses: two BG1 char blocks, the map, the sprite.
| #define VRAM_BG1_B 0x2000 |
| #define VRAM_BG1_MAP 0x4000 |
| #define VRAM_OBJ 0x6000 |
| void buildEdges | ( | void | ) |
Build edge buffer from projected vertices.
| int main | ( | void | ) |
Rotate the cube to the given angles and upload its edges.
| void rotateVertex | ( | u16 | idx | ) |
Rotate one vertex, store projected screen coords (clamped).
|
static |
Start the renderer from the code cache; returns at once.
|
extern |
|
static |
The 12 edges, as vertex index pairs.
|
static |
|
static |
The crosshair: one 8x8 4bpp tile, colour 1 (original art).
|
static |
|
static |
Cube vertices, x.
|
static |
Cube vertices, y.
|
static |
Cube vertices, z.
|
extern |
| s16 g_cax |
| s16 g_cay |
| u8 g_px[8] |
Projected vertices, x (0-255).
| u8 g_py[8] |
Projected vertices, y (0-127).
| s16 g_sax |
| s16 g_say |
Sines and cosines of the two rotation angles.
|
extern |
| const u8 gsu_cube_end[] |
the cache-resident renderer
| u16 r_game_frames |
Game-loop frames (one per WaitForVBlank).
| u16 r_jobs |
GSU jobs started.
| u16 r_music_pos |
The module's pattern position, sampled every frame.
| u16 r_ship_x |
Crosshair position (the game's state).
| u16 r_ship_y |
|
static |
Sine table, 256 steps per turn, amplitude 127.