Skip to content

Commit f61d0c8

Browse files
committed
Optimizations so app runs with both compilers.
1 parent 939ba9c commit f61d0c8

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

examples/sms/chicken.c

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ unsigned char pal1[] = {0x2A, 0x3F, 0x0F, 0x00, 0x01, 0x02, 0x03, 0x17,
1111
unsigned char pal2[] = {0x2A, 0x3F, 0x0F, 0x00, 0x10, 0x20, 0x30, 0x35,
1212
0x15, 0x35, 0x1D, 0x3D, 0x17, 0x10, 0x20, 0x03};
1313

14+
unsigned char *pal[] = {&pal1[4], &pal2[4]};
15+
1416
unsigned int road_pattern[] = {0x0001, 0x0002,
1517
0x0000, 0x0000};
1618

@@ -34,9 +36,9 @@ int rand_speed() {
3436
}
3537

3638
void main() {
37-
int x = 0;
38-
int y = 0;
39-
int i, j;
39+
unsigned char x = 0;
40+
unsigned char y = 0;
41+
unsigned char i, j;
4042
int ply_x = 120;
4143
int ply_y = 92;
4244
int ply_tile = 'H';
@@ -95,26 +97,23 @@ void main() {
9597
while (y < 176) {
9698
while (get_vcount() < y) {
9799
}
98-
// load_palette() is too slow for this to work
99-
if (j & 0x01) {
100-
load_palette(&pal1[4], 4, 4);
101-
} else {
102-
load_palette(&pal2[4], 4, 4);
103-
}
100+
101+
load_palette(pal[j], 4, 4);
102+
104103
scroll_bkg(x, 0);
105104
(*p) += (*p2);
106105
p++;
107106
p2++;
108107
x = (*p) >> 4;
109-
y += 13;
110-
j++;
108+
y += 14;
109+
j ^= 1;
111110

112111
while (get_vcount() < y) {
113112
}
114113
scroll_bkg(0, 0);
115-
y += 3;
114+
y += 2;
116115
}
117-
load_palette(&pal1[4], 4, 4);
116+
load_palette(pal[0], 4, 4);
118117
scroll_bkg(0, 0);
119118
}
120119
}

0 commit comments

Comments
 (0)