From 87ad58a7f05534218613d229e5d0f5f72a3f323b Mon Sep 17 00:00:00 2001 From: Patrick Kingston Date: Sat, 14 Feb 2026 20:08:44 -0500 Subject: Use spritesheet, make titlescreen - Moves to using a yychr spritesheet instead of the included png file - Sets up and scrolls away a titlescreen! --- main.fab | 116 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 102 insertions(+), 14 deletions(-) (limited to 'main.fab') diff --git a/main.fab b/main.fab index a47ec27..deb58f8 100644 --- a/main.fab +++ b/main.fab @@ -1,21 +1,17 @@ -vars +vars /allvars U[64] buf // A buffer that can store the current and next row U curr_gen = 0 // Swap these offsets back and forth per generation U next_gen = 32 UU drawing_row_offset = 0 // Use this to track which row we're drawing - U current_rule = %00011110 + U current_rule = 73 -fn init_screen() +fn init_eca_state() // Scroll to attributes ppu_reset_addr($2000 + 960) // Set attributes for background for U i = 0; i < 64; i+= 1 {PPUDATA}(%11111111) - //// Init the buffers to 0 - //for i = 0; i < 64; i += 1 - // buf[i] = 0 - // Init the buffer to zero buf = U[64]() // Add an initial cell @@ -107,7 +103,7 @@ fn upload_curr_gen() {PPUDATA}(buf[i+curr_gen]) -nmi main_nmi() +nmi eca_nmi() // Turn on rendering sprites and bg {PPUMASK}(PPUMASK_ON | PPUMASK_NO_CLIP) @@ -115,24 +111,116 @@ nmi main_nmi() ppu_reset_scroll(0, 0) +// Main mode for running the ECA +mode eca_main() +: nmi eca_nmi + // Initialize the screen + init_eca_state() + // Wait 10 frames + nmi + nmi + nmi + nmi + nmi + nmi + nmi + nmi + nmi + nmi + // Loop forever: + while true + nmi + calc_and_advance_gen() + +charmap(".#-=n!@~E$%^S&*(C)_+A{}|12345678qwertyuiop") + +data /titlescreen + [] title + ("................................" + "................................" + "................................" + "................................" + "..........############.........." + ".........##############........." + ".........##..........##........." + ".........##..........##........." + ".........##..n!E$S&..##........." + ".........##..@~%^*(..##........." + ".........##....C)....##........." + ".........##...._+....##........." + ".........##....A{....##........." + ".........##....}|....##........." + ".........##..........##........." + ".........##..........##........." + ".........##############........." + "..........############.........." + "................................" + "................................" + "...........###########.........." + "..........#..........#.........." + "..........#.12345678.#.........." + "..........#...<...>..#.........." + "..........#..........#.........." + "..........###########..........." + "................................" + "................................" + "................................" + "................................" + "................................") + +vars /titlescreen + UU wipeline = 0 + +// nmi for entrypoint for the program +nmi main_nmi() + // Turn on rendering sprites and bg + {PPUMASK}(PPUMASK_ON | PPUMASK_NO_CLIP) + ppu_reset_scroll(0, 0) + + if wipeline + UU row_start = $2000 + row_start += ((wipeline - 1) * 32) + ppu_reset_addr(row_start) + for U i = 0; i < 32; i += 1 //32 columns + //next_cell = 0 //get_next_gen(i) + {PPUDATA}(0) + +// The main entry point for the program mode main() : nmi main_nmi // Set the palette: palette = example_palette ppu_upload_palette() - // Initialize the screen - init_screen() + ppu_reset_addr($2000) + + // Load the title screen + CCC/titlescreen titlep = @title + for UU i = 0; i < 960; i += 1 + {PPUDATA}(titlep{i}) + + for UU i = 0; i < 64; i += 1 + {PPUDATA}(%00000000) + + // Turn rendering on + {PPUMASK}(PPUMASK_BG_ON) // Turn the NMI on {PPUCTRL}(PPUCTRL_NMI_ON) - // Loop forever: - while true + // Display title screen for 120 frames + for U i = 0; i < 120; i += 1 nmi - calc_and_advance_gen() + + for U i = 1; i <= 30; i += 1 // use this to wipe the screen + wipeline = i + nmi + + // Go to the main eca mode + goto mode eca_main() + : preserves /allvars // Define the tileset (commonly called CHR): chrrom - file(fmt, "tiles.png") + file(fmt, "spritesheet.chr") -- cgit v1.2.3