summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2021-04-22 17:34:38 +0200
committerBad Diode <bd@badd10de.dev>2021-04-22 17:34:38 +0200
commit74d6b52636ecdd560995f22dff5b29a59fc62d5d (patch)
tree9d70d76694e13311cbd5ee7fa2c45cfdfed664bd
parenta3e96cb4b1abc95fba71fbd833f9378b6dc5fdca (diff)
downloadgba-experiments-74d6b52636ecdd560995f22dff5b29a59fc62d5d.tar.gz
gba-experiments-74d6b52636ecdd560995f22dff5b29a59fc62d5d.zip
Test background scrolling with input control
-rw-r--r--src/background-tiles.c297
-rw-r--r--src/main.c72
2 files changed, 361 insertions, 8 deletions
diff --git a/src/background-tiles.c b/src/background-tiles.c
new file mode 100644
index 0000000..9d1ad15
--- /dev/null
+++ b/src/background-tiles.c
@@ -0,0 +1,297 @@
1const u32 bg_data[792] = {
2 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
3 0x08000080,0x08000080,0x0866DD80,0x08000080,0x08000080,0x08000080,0x0866DD80,0x08000080,
4 0x0B000080,0x0B000080,0x0BDD6680,0x0B000080,0x0B000080,0x0B000080,0x0BDD6680,0x0B000080,
5 0x00000000,0x00000000,0x00000000,0x44444400,0x77777F40,0x44447FA4,0xEEEEEFF4,0xEEEEEEF4,
6 0x00000000,0x00000000,0x00000000,0x00044444,0x004F4747,0x04AF4444,0x04FFEEEE,0x04FEEEEE,
7 0x00000000,0x70000000,0x00000700,0x7000DDD0,0x0000700D,0x07770000,0x00000000,0x00000000,
8 0x00000077,0x00000777,0x00000707,0xD000D077,0x70000DDD,0x07770777,0x00000070,0x00000707,
9 0x00000000,0x00000000,0x00000007,0x0000000D,0x000000D0,0x00000000,0x00000000,0x00000000,
10
11 0x00040000,0x00404000,0x04050400,0x04050400,0x004D4000,0x004D4000,0x00080000,0x000D0000,
12 0xAAAAAA64,0x77FFFFF4,0xC7EEEEC4,0x44EEEEC4,0xFFEEEEC4,0xEEEEEFC4,0xCCCCCCC4,0x44444444,
13 0x046AAAAA,0x04FFFFF7,0x04CEEEE4,0x04CEEEE4,0x04CEEEEF,0x04CFEEEE,0x04CCCCCC,0x04444444,
14 0x00000000,0x00000000,0x70000000,0x70000000,0x70000000,0xDD000000,0x70000000,0x00000000,
15 0x00000070,0x00000777,0x00000700,0x00000700,0x00D07000,0x000DD00D,0x00070000,0x00000000,
16 0x55555550,0x22525555,0x25255555,0x22525525,0x22225252,0x22222222,0x22222225,0x22222225,
17 0x05555555,0x22222225,0x44222222,0x42422222,0x44222222,0x44222222,0x42422222,0x44422222,
18 0x55555555,0x65655656,0x55525555,0x65562255,0x22266222,0x02006662,0x22200606,0x22006666,
19
20 0x0B000084,0x0B000084,0x0BDD6684,0x0B000084,0x0B000084,0x0B000084,0x0BDD6684,0x0B000084,
21 0x05555555,0x02665555,0x02266265,0x02262226,0x00266666,0x02066002,0x02666602,0x00606000,
22 0x44222555,0x42222222,0x44222222,0x42424222,0x44442422,0x44444242,0x44444444,0x44444444,
23 0x42555552,0x42252555,0x42222255,0x42222525,0x42222252,0x42222222,0x44222224,0x44442244,
24 0x22222222,0x22222222,0x22222222,0x22222224,0x22222224,0x42222224,0x24242244,0x44444440,
25 0x44242222,0x44424422,0x44444222,0x44442422,0x44444224,0x44442442,0x44444424,0x04444444,
26 0x66606600,0x60000060,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
27 0x00066600,0x00600006,0x00006006,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
28
29 0x22222220,0x66262222,0x62622222,0x66262262,0x66662626,0x66666666,0x66666662,0x66666662,
30 0x02222222,0x66666662,0x44666666,0x46466666,0x44666666,0x44666666,0x46466666,0x44466666,
31 0x46222226,0x46626222,0x46666622,0x46666262,0x46666626,0x46666666,0x44666664,0x44446644,
32 0x06666666,0x66666666,0x66666660,0x66666000,0x06666006,0x00000066,0x00000066,0x00000066,
33 0x00000000,0x00000000,0x00000000,0x00B0000B,0x0B00000B,0x0B0B000B,0x010B00B1,0x01010B01,
34 0x00000000,0x00000000,0x00000B00,0x000000B0,0x000010B0,0x0B010010,0x01010010,0x01010001,
35 0x00000000,0x00000000,0x000000B0,0x0000000B,0x0000100B,0xB0001001,0x01010001,0x01010B01,
36 0x00000000,0x00000000,0x00000000,0x0B00000B,0x00B000B0,0x0B00B0B0,0x010B0001,0x01010B01,
37
38 0x66666666,0x66666666,0x66666666,0x66666664,0x66666664,0x46666664,0x64646644,0x44444440,
39 0x44646666,0x44464466,0x44444666,0x44446466,0x44444664,0x44446446,0x44444464,0x04444444,
40 0x05550555,0x02250225,0x06220622,0x06660666,0x00000000,0x06060606,0x00000000,0x00000000,
41 0x05520264,0x06220666,0x06660664,0x06440644,0x00000000,0x06040604,0x00000000,0x00000000,
42 0x00000000,0x00666660,0x00600060,0x00606060,0x00600060,0x00666660,0x00000000,0x00000000,
43 0x06666600,0x06666660,0x06666660,0x00066660,0x60066600,0x66000000,0x66000000,0x00000000,
44 0x00666000,0x06660066,0x06606666,0x00006666,0x00000660,0x06660000,0x06600666,0x00006666,
45 0x00000000,0xC444444C,0xFEEEEEEF,0xCFFFFFFC,0xFEECCEEF,0xCEECCEEC,0xCEEEEEEC,0xCCCCCCCC,
46
47 0x43999993,0x43393999,0x43333399,0x43333939,0x43333393,0x43333333,0x44333334,0x44443344,
48 0x4A33333A,0x4AA3A333,0x4AAAAA33,0x4AAAA3A3,0x4AAAAA3A,0x4AAAAAAA,0x44AAAAA4,0x4444AA44,
49 0x00000000,0xEEEEEEE0,0x44444440,0x44A8AAF0,0x44A8AAF0,0x44AA8AF0,0x444AAAE0,0x44444AE0,
50 0x00000000,0x0EEEEEEE,0x04444444,0x0FAAA444,0x0FA8A444,0x0FA8A444,0x0EA8A444,0x0EA8A444,
51 0x0B0000D0,0x06000080,0x060066D0,0x060000D0,0x00000060,0x06000060,0x06000660,0x00000060,
52 0x33333330,0xAA3A3333,0xA3A33333,0xAA3A33A3,0xAAAA3A3A,0xAAAAAAAA,0xAAAAAAA3,0xAAAAAAA3,
53 0x03333333,0xAAAAAAA3,0x44AAAAAA,0x4A4AAAAA,0x44AAAAAA,0x44AAAAAA,0x4A4AAAAA,0x444AAAAA,
54 0x4CCCCCCC,0x4C33333C,0x4C3CCC3C,0x4C3C3C3C,0x4C3C3C3C,0x4CCC333C,0x44CCCCCC,0x44444444,
55
56 0x44141111,0x44414411,0x44444111,0x44441411,0x44444114,0x44441441,0x44444414,0x04444444,
57 0x444444E0,0x444444E0,0x444444E0,0x444444E0,0x444444E0,0x444444E0,0x444444E0,0x444444E0,
58 0x0EA8A444,0x0EA8A444,0x0EA8A444,0x0EA8A444,0x0EA8A444,0x0EA8A444,0x0EA8A444,0x0EA8A444,
59 0x99999444,0x99999494,0x99999944,0x99999944,0x99999494,0x99999944,0xA9999999,0xAAAAAAA0,
60 0xAAAAAAA0,0x99A9AAAA,0x9A9AAAAA,0x99A9AA9A,0x9999A9A9,0x99999999,0x9999999A,0x9999999A,
61 0x44A4AAAA,0x444A44AA,0x44444AAA,0x4444A4AA,0x44444AA4,0x4444A44A,0x444444A4,0x04444444,
62 0x444444E0,0x444444E0,0x444444E0,0x444444E0,0x444444E0,0x444444E0,0x444444E0,0x44444440,
63 0x0EA8A444,0x0EA8A444,0x0EAAA444,0x0EAAA444,0x0EA8A444,0x0EA8A444,0x0EAAA444,0x04444444,
64
65 0xAAAAAAA0,0x11A1AAAA,0x1A1AAAAA,0x11A1AA1A,0x1111A1A1,0x11111111,0x1111111A,0x1111111A,
66 0x0AAAAAAA,0x1111111A,0x44111111,0x41411111,0x44111111,0x44111111,0x41411111,0x44411111,
67 0x00000000,0x88882D20,0x66D26602,0x0D0D080D,0xD0020602,0x88882D20,0x00000600,0x00000600,
68 0x00000000,0x88888888,0x66D666D6,0x0D000D00,0xD000D000,0x88888888,0x00000000,0x00000000,
69 0x00008800,0x888D8888,0x66D688D6,0x0D007700,0xD0007700,0x888D6688,0x00006600,0x00000000,
70 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00200000,0x20200000,0x02000000,
71 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x20000000,0x00000000,0x20000000,
72 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00020000,0x00002002,0x00020220,
73
74 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x07070000,0x00700000,0x00700700,
75 0x00100101,0x00100B0B,0xB0B00010,0xB1B000B0,0x0010B0B0,0x00BBB000,0x00000000,0x00000000,
76 0x99999999,0x99999999,0x99999999,0x99999994,0x99999994,0x49999994,0x94949944,0x44444440,
77 0x44949999,0x44494499,0x44444999,0x44449499,0x44444994,0x44449449,0x44444494,0x04444444,
78 0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAA4,0xAAAAAAA4,0x4AAAAAA4,0xA4A4AA44,0x44444440,
79 0x11111111,0x11111111,0x11111111,0x11111114,0x11111114,0x41111114,0x14141144,0x44444440,
80 0x00AAAA00,0x0AAA1110,0x0A111100,0x00111101,0x00000000,0x001AA000,0x01A11100,0x01100010,
81 0x00024000,0x00042000,0x000D4000,0x0004D000,0x0008D000,0x000D8000,0x000D8000,0x000DD000,
82
83 0x02000000,0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
84 0x00000000,0x00000000,0x70000222,0x000D2200,0x0DD22000,0xDDD20000,0xD2200000,0x22000000,
85 0x00000200,0x00000200,0x00022070,0x00220077,0x00220070,0x02220770,0x0222077D,0x022077DD,
86 0x00077000,0x00070700,0x00070000,0x00007700,0x00000700,0x00000700,0x00000770,0x00000777,
87 0x01000000,0x00100000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
88 0x20000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x20000000,0x02000000,
89 0x72227DD2,0x72222222,0x72222220,0x77222220,0x07722202,0x00712222,0x00011220,0x00010202,
90 0x00000077,0x00000077,0x00000077,0x00000007,0x00000000,0x00000000,0x00000000,0x00000000,
91
92 0x000B0010,0x010B00B0,0x010B00B0,0x011B00B0,0x00B000B0,0x00B000B0,0x00B00000,0x00B00000,
93 0x00000000,0x00000000,0x00000000,0x00000000,0x11100000,0x11111000,0x21111100,0x12121110,
94 0x22200000,0x02221000,0x20222100,0x22221211,0x11222111,0x11121211,0x11212121,0x00121212,
95 0x00011120,0x00001012,0x00001102,0x00001010,0x00011101,0x00011011,0x00101111,0x01010100,
96 0x41AAAAA1,0x411A1AAA,0x411111AA,0x41111A1A,0x411111A1,0x41111111,0x44111114,0x44441144,
97 0x33333330,0xA3333333,0xAAAA3333,0xAAAAA333,0xAAAAAAA3,0xAAAAAAAA,0xAAAAAAA4,0x44444440,
98 0x0AAAA333,0xAAAAAAAA,0xAAAAAAAA,0xAAAAAAAA,0x44AAAAAA,0x4444AAAA,0x4444444A,0x04444444,
99 0x04AAA333,0x4AAAAAAA,0x4A4AAAAA,0x44A4AAAA,0x444A4AAA,0x4444A4A4,0x4444444A,0x04444444,
100
101 0x03333333,0x3333333A,0x3333AAAA,0x333AAAAA,0x3AAAAAAA,0xAAAAAAAA,0x4AAAAAA4,0x04444444,
102 0x04AAAAA0,0x477AAAAA,0x47777AAA,0x47777AAA,0x477777AA,0x4777777A,0x44777774,0x04447740,
103 0x44AAAAAA,0x44AAAAAA,0x444AAAAA,0x4444AAAA,0x4444AAAA,0x4444AAAA,0x444444AA,0x04444444,
104 0x04333330,0x4AA33333,0x4AAAA333,0x4AAAA333,0x4AAAAA33,0x4AAAAAAA,0x44AAAAA4,0x0444AA40,
105 0x080000D0,0x06000080,0x060066D0,0x060000D0,0x00000060,0x06000060,0x06000660,0x00000060,
106 0x000AAAA0,0x10111AAA,0x1001111A,0x01011110,0x00000000,0x0000AA10,0x000111A1,0x00100011,
107 0x00AAAAAA,0x0111AAA1,0x011A1111,0x00111111,0x00011110,0x00001100,0x00000010,0x00000000,
108 0x0AAAAAA0,0x11AAA111,0x11111A11,0x01111110,0x00111100,0x00011000,0x00100000,0x00000000,
109
110 0x00000C00,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
111 0x0000000C,0x000000C0,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
112 0x0D000000,0x00D00000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,
113};
114
115const u16 bg_map[1024] = {
116 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
117 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
118 0x0000,0x0001,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
119 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
120 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
121 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
122 0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
123 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
124
125 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
126 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
127 0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
128 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
129 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
130 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
131 0x0000,0x0002,0x0003,0x0004,0x0000,0x0000,0x0000,0x0000,
132 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
133
134 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0005,
135 0x0006,0x0007,0x0000,0x0000,0x0000,0x0008,0x0000,0x0000,
136 0x0000,0x0002,0x0009,0x000A,0x0000,0x0000,0x0000,0x0000,
137 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
138 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x000B,
139 0x000C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
140 0x0000,0x0002,0x000D,0x000E,0x0000,0x0000,0x0000,0x0000,
141 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
142
143 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x000D,
144 0x000E,0x000F,0x0010,0x000F,0x000F,0x000F,0x000F,0x0011,
145 0x0012,0x0013,0x0014,0x0015,0x0000,0x0000,0x0000,0x0000,
146 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
147 0x0000,0x0000,0x0000,0x0008,0x0000,0x0000,0x0000,0x0014,
148 0x0015,0x0016,0x0002,0x0016,0x0016,0x0016,0x0016,0x0017,
149 0x0018,0x0019,0x001A,0x001B,0x0000,0x0000,0x0000,0x0000,
150 0x0000,0x0000,0x0000,0x0000,0x0008,0x0000,0x0000,0x0000,
151
152 0x0000,0x0000,0x001C,0x001D,0x001E,0x001F,0x0013,0x0018,
153 0x0019,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
154 0x0020,0x0021,0x001B,0x0000,0x0000,0x0000,0x0000,0x0000,
155 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
156 0x0022,0x0022,0x0012,0x001A,0x0019,0x0019,0x001A,0x0020,
157 0x0021,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
158 0x001A,0x001B,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
159 0x0000,0x0000,0x0023,0x0022,0x0022,0x0022,0x0022,0x0022,
160
161 0x0024,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0019,
162 0x0021,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
163 0x0025,0x0026,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
164 0x0000,0x0000,0x0024,0x0000,0x0024,0x0000,0x0024,0x0000,
165 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
166 0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
167 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
168 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
169
170 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
171 0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
172 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
173 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
174 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
175 0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
176 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
177 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
178
179 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
180 0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
181 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
182 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
183 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
184 0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
185 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
186 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
187
188 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
189 0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
190 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
191 0x1027,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
192 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
193 0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
194 0x0000,0x0000,0x0000,0x0000,0x0000,0x0008,0x0000,0x0000,
195 0x0028,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
196
197 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
198 0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,0x0000,
199 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0028,
200 0x0029,0x0000,0x0000,0x0000,0x0000,0x002A,0x002B,0x0000,
201 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
202 0x0000,0x0000,0x002C,0x0000,0x0000,0x0000,0x0000,0x0000,
203 0x0000,0x0000,0x0000,0x0002,0x002D,0x002E,0x0028,0x002F,
204 0x0030,0x0000,0x0000,0x0000,0x0000,0x0031,0x0032,0x0000,
205
206 0x001E,0x001F,0x0028,0x0000,0x0000,0x0000,0x0000,0x0000,
207 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
208 0x0000,0x0000,0x0000,0x0002,0x0033,0x0C33,0x0034,0x0035,
209 0x0435,0x0000,0x0034,0x0C33,0x0000,0x0036,0x0037,0x001E,
210 0x0038,0x0039,0x0035,0x0000,0x103A,0x003B,0x003C,0x043C,
211 0x043B,0x043A,0x103D,0x103E,0x103F,0x1040,0x0000,0x0000,
212 0x0000,0x0000,0x0000,0x0002,0x0000,0x0000,0x1041,0x1441,
213 0x0000,0x0000,0x1042,0x1043,0x0038,0x0039,0x0044,0x0035,
214
215 0x0045,0x0030,0x0046,0x0000,0x0047,0x0000,0x0000,0x0000,
216 0x0000,0x0047,0x1048,0x1049,0x104A,0x104B,0x0000,0x0000,
217 0x0000,0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,
218 0x0000,0x0000,0x0000,0x0000,0x0045,0x0030,0x0000,0x0000,
219 0x0000,0x0000,0x004C,0x0000,0x0047,0x0000,0x0000,0x0000,
220 0x0000,0x0047,0x0000,0x104D,0x104E,0x104F,0x0000,0x0008,
221 0x0000,0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,
222 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
223
224 0x0000,0x0000,0x0000,0x0000,0x0047,0x0000,0x1050,0x0000,
225 0x0000,0x0047,0x1051,0x1052,0x1053,0x0000,0x0000,0x001E,
226 0x001F,0x0000,0x0000,0x0002,0x0000,0x0000,0x0000,0x0000,
227 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
228 0x0000,0x0000,0x0000,0x0000,0x002D,0x002E,0x0029,0x0029,
229 0x0C33,0x0054,0x0055,0x0056,0x002E,0x0057,0x0058,0x0055,
230 0x0056,0x0401,0x0057,0x0059,0x0000,0x0000,0x0000,0x0000,
231 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
232
233 0x0000,0x0000,0x0000,0x0000,0x0044,0x0035,0x0000,0x1042,
234 0x1043,0x1042,0x1042,0x1042,0x005A,0x0044,0x0035,0x005B,
235 0x0059,0x005C,0x0044,0x0035,0x0000,0x0000,0x0000,0x0000,
236 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
237 0x0000,0x0000,0x0000,0x0000,0x005D,0x005E,0x0000,0x005F,
238 0x0046,0x0000,0x0000,0x181D,0x181E,0x181D,0x181E,0x0060,
239 0x0061,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
240 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
241
242 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x1062,
243 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
244 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
245 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
246 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
247 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
248 0x0000,0x0C5C,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
249 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
250
251 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
252 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
253 0x0000,0x0801,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
254 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
255 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
256 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
257 0x0000,0x0801,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
258 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
259};
260
261const u16 bg_palette[256] = {
262 0x0000,0x0846,0x310A,0x0015,0x1062,0x4DD0,0x18A5,0x4F5E,
263 0x31F2,0x007F,0x042B,0x0966,0x1D00,0x1D2D,0x1D75,0x10CF,
264 0x097F,0x04A4,0x10A7,0x3580,0x36DF,0x02BF,0x0865,0x1483,
265 0x2944,0x0867,0x1CE2,0x35F2,0x0886,0x0887,0x0000,0x0000,
266 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
267 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
268 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
269 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
270
271 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
272 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
273 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
274 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
275 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
276 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
277 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
278 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
279
280 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
281 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
282 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
283 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
284 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
285 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
286 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
287 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
288
289 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
290 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
291 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
292 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
293 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
294 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
295 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
296 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
297};
diff --git a/src/main.c b/src/main.c
index 0af41f8..4dd2554 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,6 +1,7 @@
1#include "shorthand.h" 1#include "shorthand.h"
2#include "bd-font.c" 2#include "bd-font.c"
3#include "gba-buttons.c" 3#include "gba-buttons.c"
4#include "background-tiles.c"
4 5
5// 6//
6// Memory sections. 7// Memory sections.
@@ -46,10 +47,34 @@
46#define DISP_ENABLE_SPRITES DISP_OBJ | DISP_OBJ_1D 47#define DISP_ENABLE_SPRITES DISP_OBJ | DISP_OBJ_1D
47 48
48// Registers to control of BG layers. 49// Registers to control of BG layers.
49#define BG_CTRL_0 *((vu16*)(0x04000008 + 0x0000)) 50#define BG_CTRL_0 *((vu16*)(0x04000008 + 0x0002 * 0))
50#define BG_CTRL_1 *((vu16*)(0x04000008 + 0x0002)) 51#define BG_CTRL_1 *((vu16*)(0x04000008 + 0x0002 * 1))
51#define BG_CTRL_2 *((vu16*)(0x04000008 + 0x0004)) 52#define BG_CTRL_2 *((vu16*)(0x04000008 + 0x0002 * 2))
52#define BG_CTRL_3 *((vu16*)(0x04000008 + 0x0006)) 53#define BG_CTRL_3 *((vu16*)(0x04000008 + 0x0002 * 3))
54
55// Bits to control the background.
56#define BG_PRIORITY_0 0x0
57#define BG_PRIORITY_1 0x1
58#define BG_PRIORITY_2 0x2
59#define BG_PRIORITY_3 0x3
60#define BG_CHARBLOCK(N) ((N) << 2)
61#define BG_MOSAIC (1 << 6)
62#define BG_HIGH_COLOR (1 << 7)
63#define BG_SCREENBLOCK(N) ((N) << 8)
64#define BG_AFFINE (1 << 0xD)
65#define BG_SIZE(N) ((N) << 0xE)
66
67// BG registers for horizontal displacement.
68#define BG_H_SCROLL_0 *((vu16*)(0x04000010 + 0x0004 * 0))
69#define BG_H_SCROLL_1 *((vu16*)(0x04000010 + 0x0004 * 1))
70#define BG_H_SCROLL_2 *((vu16*)(0x04000010 + 0x0004 * 2))
71#define BG_H_SCROLL_3 *((vu16*)(0x04000010 + 0x0004 * 3))
72
73// BG registers for vertical displacement.
74#define BG_V_SCROLL_0 *((vu16*)(0x04000012 + 0x0004 * 0))
75#define BG_V_SCROLL_1 *((vu16*)(0x04000012 + 0x0004 * 1))
76#define BG_V_SCROLL_2 *((vu16*)(0x04000012 + 0x0004 * 2))
77#define BG_V_SCROLL_3 *((vu16*)(0x04000012 + 0x0004 * 3))
53 78
54// Screen settings. 79// Screen settings.
55#define SCREEN_WIDTH 240 80#define SCREEN_WIDTH 240
@@ -69,9 +94,11 @@ typedef struct Tile {
69} Tile; 94} Tile;
70 95
71typedef Tile TileBlock[512]; 96typedef Tile TileBlock[512];
72
73#define TILE_MEM ((TileBlock*) MEM_VRAM) 97#define TILE_MEM ((TileBlock*) MEM_VRAM)
74 98
99typedef u16 ScreenBlock[1024];
100#define SCREENBLOCK_MEM ((ScreenBlock*)MEM_VRAM)
101
75// We can treat the screen as a HxW matrix. With the following macro we can 102// We can treat the screen as a HxW matrix. With the following macro we can
76// write a pixel to the screen at the (x, y) position using: 103// write a pixel to the screen at the (x, y) position using:
77// 104//
@@ -524,9 +551,6 @@ load_packed_sprite_data(u32 *sprite_data, size_t n_tiles, size_t n_frames) {
524} 551}
525 552
526int main(void) { 553int main(void) {
527 // Configure the display in mode 0 to show OBJs, where tile memory is
528 // sequential.
529 DISP_CTRL = DISP_MODE_0 | DISP_ENABLE_SPRITES | DISP_BG_2;
530 554
531 // Add colors to the sprite color palette. Tiles with color number 0 are 555 // Add colors to the sprite color palette. Tiles with color number 0 are
532 // treated as transparent. 556 // treated as transparent.
@@ -543,6 +567,21 @@ int main(void) {
543 sprite_tile_counter = 0; 567 sprite_tile_counter = 0;
544 sprite_memory = &TILE_MEM[4][sprite_tile_counter]; 568 sprite_memory = &TILE_MEM[4][sprite_tile_counter];
545 569
570 // Load background palette.
571 memcpy(&PAL_BUFFER_BG[0], &bg_palette, 512);
572 memcpy(&TILE_MEM[0][0], bg_data, 3168);
573 memcpy(&SCREENBLOCK_MEM[30][0], bg_map, 2048);
574
575 // Configure BG0 to use 4bpp, 64x32 tile map in charblock 0 and screenblock
576 // 31.
577 BG_CTRL_0 = BG_CHARBLOCK(0) | BG_SCREENBLOCK(30) | BG_SIZE(0);
578 BG_H_SCROLL_0 = 0;
579 BG_V_SCROLL_0 = 0;
580
581 // Configure the display in mode 0 to show OBJs, where tile memory is
582 // sequential.
583 DISP_CTRL = DISP_ENABLE_SPRITES | DISP_MODE_0 | DISP_BG_0;
584
546 // Initialize the A/B button sprites. 585 // Initialize the A/B button sprites.
547 int buttons_x = SCREEN_WIDTH / 2; 586 int buttons_x = SCREEN_WIDTH / 2;
548 int buttons_y = SCREEN_HEIGHT / 2; 587 int buttons_y = SCREEN_HEIGHT / 2;
@@ -635,6 +674,8 @@ int main(void) {
635 OBJ_ATTR_2(btn_r.id) = sprites[btn_r.id].tile_start; 674 OBJ_ATTR_2(btn_r.id) = sprites[btn_r.id].tile_start;
636 675
637 int frame_counter = 0; 676 int frame_counter = 0;
677 int x = 0;
678 int y = 0;
638 while(true) { 679 while(true) {
639 wait_vsync(); 680 wait_vsync();
640 poll_keys(); 681 poll_keys();
@@ -784,6 +825,19 @@ int main(void) {
784 } 825 }
785 } 826 }
786 827
828 if (key_hold(KEY_DOWN)) {
829 y += 3;
830 }
831 if (key_hold(KEY_UP)) {
832 y -= 3;
833 }
834 if (key_hold(KEY_LEFT)) {
835 x -= 3;
836 }
837 if (key_hold(KEY_RIGHT)) {
838 x += 3;
839 }
840
787 OBJ_ATTR_2(btn_b.id) = sprites[btn_b.id].tile_start + animation_states[btn_b.state]->tile_offsets[btn_b.frame]; 841 OBJ_ATTR_2(btn_b.id) = sprites[btn_b.id].tile_start + animation_states[btn_b.state]->tile_offsets[btn_b.frame];
788 OBJ_ATTR_2(btn_a.id) = sprites[btn_a.id].tile_start + animation_states[btn_a.state]->tile_offsets[btn_a.frame]; 842 OBJ_ATTR_2(btn_a.id) = sprites[btn_a.id].tile_start + animation_states[btn_a.state]->tile_offsets[btn_a.frame];
789 OBJ_ATTR_2(btn_up.id) = sprites[btn_up.id].tile_start + animation_states[btn_up.state]->tile_offsets[btn_up.frame]; 843 OBJ_ATTR_2(btn_up.id) = sprites[btn_up.id].tile_start + animation_states[btn_up.state]->tile_offsets[btn_up.frame];
@@ -793,6 +847,8 @@ int main(void) {
793 OBJ_ATTR_2(btn_l.id) = sprites[btn_l.id].tile_start + animation_states[btn_l.state]->tile_offsets[btn_l.frame]; 847 OBJ_ATTR_2(btn_l.id) = sprites[btn_l.id].tile_start + animation_states[btn_l.state]->tile_offsets[btn_l.frame];
794 OBJ_ATTR_2(btn_r.id) = sprites[btn_r.id].tile_start + animation_states[btn_r.state]->tile_offsets[btn_r.frame]; 848 OBJ_ATTR_2(btn_r.id) = sprites[btn_r.id].tile_start + animation_states[btn_r.state]->tile_offsets[btn_r.frame];
795 frame_counter++; 849 frame_counter++;
850 BG_H_SCROLL_0 = x;
851 BG_V_SCROLL_0 = y;
796 }; 852 };
797 853
798 return 0; 854 return 0;