vars U[8] buf // A buffer that can store the current and next row U row_a = 0 // We swap back and forth between these two offsets for each row U row_b = 4 UU drawing_row_offset = 0// Use this to track which row we're drawing U current_rule = %00011110 U next_cell = 0 fn init_screen() ppu_reset_addr($2000) // Set background tiles for UU i = 0; i < 960; i += 1 {PPUDATA}(1) U i = 0 // Set attributes for background for i = 0; i < 64; i+= 1 {PPUDATA}(%00011011) // Init the buffers to 0 for i = 0; i < 8; i += 1 buf[i] = 0 fn calc_and_upload_next_row() // "scroll" to the row we're at UU row_start = $2000 row_start += (drawing_row_offset * 32) ppu_reset_addr(row_start) for UU i = 0; i < 32; i += 1 //next_cell = 0 //get_next_gen(i) {PPUDATA}(next_cell) drawing_row_offset += 1 if drawing_row_offset == 30 drawing_row_offset = 0 if next_cell next_cell = 0 else next_cell = 1 nmi main_nmi() ppu_upload_oam_poll_pads(0) calc_and_upload_next_row() // Turn on rendering sprites and bg {PPUMASK}(PPUMASK_ON | PPUMASK_NO_CLIP) ppu_reset_scroll(0, 0) mode main() : nmi main_nmi // Set the palette: palette = example_palette ppu_upload_palette() // Load the background init_screen() // Turn the NMI on {PPUCTRL}(PPUCTRL_NMI_ON) // Loop forever: while true update_pads() nmi // Define the tileset (commonly called CHR): chrrom file(fmt, "tiles.png")