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 +++++++++++++++++++++++++++++++++++++++++++++++++------- nEs.nes | Bin 40976 -> 40976 bytes nEslabels.mlb | 34 ++++++++++------- spritesheet.chr | Bin 0 -> 8192 bytes 4 files changed, 122 insertions(+), 28 deletions(-) create mode 100644 spritesheet.chr 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") diff --git a/nEs.nes b/nEs.nes index 2893029..80e4f39 100644 Binary files a/nEs.nes and b/nEs.nes differ diff --git a/nEslabels.mlb b/nEslabels.mlb index 8098217..a1ecaa9 100644 --- a/nEslabels.mlb +++ b/nEslabels.mlb @@ -1,16 +1,20 @@ -NesPrgRom:000631:calc_next_cell@0_0: -NesPrgRom:00052C:calc_and_advance_gen@0_0: -NesPrgRom:000535:calc_and_advance_gen@0_0_entry: -NesPrgRom:0005B6:main_nmi@0_1: -NesPrgRom:0004A7:main@0_0: -NesPrgRom:000230:ppu_upload_palette@0_0: +NesPrgRom:000B0D:calc_next_cell@0_0: +NesPrgRom:000988:calc_and_advance_gen@0_0: +NesPrgRom:000991:calc_and_advance_gen@0_0_entry: +NesPrgRom:000A92:eca_nmi@0_1: +NesPrgRom:000A12:eca_main@0_0: +NesPrgRom:0007F8:main_nmi@0_1: +NesPrgRom:0007FB:main_nmi@0_1_entry: +NesPrgRom:000250:main@0_0: +NesPrgRom:00073F:ppu_upload_palette@0_0: +NesPrgRom:00035F-00073E:title@0_0: NesPrgRom:007FFA-007FFF:runtime_vectors@0_0: NesPrgRom:00011C-00012F:runtime_nmi@0_1: NesPrgRom:000130-000137:runtime_nmi_exit@0_1: NesPrgRom:000139-000147:runtime_wait_nmi@0_0: -NesPrgRom:00022A-00022B:runtime_nmi_lo_table@0_0: -NesPrgRom:00022C-00022D:runtime_nmi_hi_table@0_0: -NesPrgRom:00022E-00022F:runtime_nmi_bank_table@0_0: +NesPrgRom:00022C-00022E:runtime_nmi_lo_table@0_0: +NesPrgRom:000230-000232:runtime_nmi_hi_table@0_0: +NesPrgRom:000234-000236:runtime_nmi_bank_table@0_0: NesPrgRom:000138-000138:runtime_irq@0_2: NesPrgRom:000138-000138:runtime_irq_exit@0_2: NesPrgRom:000148-00014D:runtime_reset@0_0: @@ -25,11 +29,13 @@ NesPrgRom:000100-00010F:runtime_shl4_table@0_0: NesPrgRom:000110-000117:runtime_shl5_table@0_0: NesPrgRom:000118-00011B:runtime_shl6_table@0_0: R:031F:buf@0: -R:000F:curr_gen@0: -R:000D:next_gen@0: -R:0010:drawing_row_offset@0: -R:0011:drawing_row_offset@1: -R:000E:current_rule@0: +R:000D:curr_gen@0: +R:0010:next_gen@0: +R:000E:drawing_row_offset@0: +R:000F:drawing_row_offset@1: +R:0011:current_rule@0: +R:0014:wipeline@0: +R:0015:wipeline@1: R:0200:oam@0: R:0319:pads@0: R:031B:pads@1: diff --git a/spritesheet.chr b/spritesheet.chr new file mode 100644 index 0000000..93d1ad4 Binary files /dev/null and b/spritesheet.chr differ -- cgit v1.2.3