Slightly frustrating, but illuminating, attempt to title screen.
Chris Pressey
7 years ago
4 | 4 | // ---------------------------------------------------------------- |
5 | 5 | // Global Variables and System Locations |
6 | 6 | // ---------------------------------------------------------------- |
7 | ||
8 | byte vic_border @ 53280 | |
9 | byte vic_bg @ 53281 | |
7 | 10 | |
8 | 11 | byte table screen1 @ 1024 |
9 | 12 | byte table screen2 @ 1274 |
21 | 24 | pointer ptr @ 254 |
22 | 25 | word pos |
23 | 26 | word delta |
27 | ||
28 | // | |
29 | // Points to the routine that implements the current game state. | |
30 | // | |
31 | ||
32 | vector dispatch_game_state | |
33 | inputs joy2, pos | |
34 | outputs delta, pos, screen, vic_border, vic_bg, screen1 | |
35 | trashes a, x, y, c, z, n, v, ptr | |
24 | 36 | |
25 | 37 | // |
26 | 38 | // The constraints on these 2 vectors are kind-of sort-of big fibs. |
36 | 48 | |
37 | 49 | vector cinv |
38 | 50 | inputs joy2, pos |
39 | outputs delta, pos, screen | |
51 | outputs delta, pos, screen, vic_border, vic_bg, screen1 | |
40 | 52 | trashes a, x, y, c, z, n, v, ptr |
41 | 53 | @ 788 |
42 | 54 | |
43 | 55 | vector save_cinv |
44 | 56 | inputs joy2, pos |
45 | outputs delta, pos, screen | |
46 | trashes a, x, y, c, z, n, v, ptr | |
47 | ||
48 | // (This one is less fibby.) | |
49 | ||
50 | vector dispatch_game_state | |
51 | inputs joy2, pos | |
52 | outputs delta, pos, screen | |
53 | trashes a, x, y, c, z, n, v, ptr | |
57 | outputs delta, pos, screen, vic_border, vic_bg, screen1 | |
58 | trashes a, x, y, c, z, n, v, ptr | |
59 | ||
54 | 60 | |
55 | 61 | // ---------------------------------------------------------------- |
56 | 62 | // Utility Routines |
118 | 124 | |
119 | 125 | routine game_state_play |
120 | 126 | inputs joy2, pos |
121 | outputs delta, pos, screen | |
127 | outputs delta, pos, screen, vic_border, vic_bg, screen1 | |
122 | 128 | trashes a, x, y, c, z, n, v, ptr |
123 | 129 | { |
124 | 130 | call read_stick |
136 | 142 | goto save_cinv |
137 | 143 | } |
138 | 144 | |
145 | routine game_state_title_screen | |
146 | inputs joy2, pos | |
147 | outputs delta, pos, screen, vic_border, vic_bg, screen1 | |
148 | trashes a, x, y, c, z, n, v, ptr | |
149 | { | |
150 | ld a, 5 | |
151 | st a, vic_border | |
152 | ld a, 0 | |
153 | st a, vic_bg | |
154 | ld y, 0 | |
155 | ||
156 | repeat { | |
157 | ld a, 82 | |
158 | st a, screen1 + y | |
159 | inc y | |
160 | cmp y, 18 | |
161 | } until not z | |
162 | ||
163 | st off, c | |
164 | // jsr check_button | |
165 | ||
166 | if c { | |
167 | // call clear_screen | |
168 | // jsr init_game | |
169 | // FIXME various reasons we can't do this, mainly that self-reference | |
170 | // is disallowed: we would need to put "outputs dispatch_game_state" in | |
171 | // the signature of dispatch_game_state! | |
172 | // copy game_state_play, dispatch_game_state | |
173 | } | |
174 | ||
175 | goto save_cinv | |
176 | } | |
177 | ||
139 | 178 | // ************************* |
140 | 179 | // * Main Game Loop Driver * |
141 | 180 | // ************************* |
142 | 181 | |
143 | 182 | routine our_cinv |
144 | 183 | inputs joy2, pos |
145 | outputs delta, pos, screen | |
184 | outputs delta, pos, screen, vic_border, vic_bg, screen1 | |
146 | 185 | trashes a, x, y, c, z, n, v, ptr |
147 | 186 | { |
148 | 187 | goto dispatch_game_state |
152 | 191 | inputs cinv |
153 | 192 | outputs cinv, save_cinv, pos, dispatch_game_state, |
154 | 193 | screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4 |
155 | trashes a, y, n, c, z | |
194 | trashes a, y, n, c, z, vic_border, vic_bg | |
156 | 195 | { |
157 | 196 | call clear_screen |
158 | copy game_state_play, dispatch_game_state | |
197 | copy game_state_title_screen, dispatch_game_state | |
159 | 198 | |
160 | 199 | copy word 0, pos |
161 | 200 | with interrupts off { |