blob: 8624f9dd5cc040728eb975a1610f0f55032f7883 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
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")
|