git @ Cat's Eye Technologies SixtyPical / 5e8f413
Give the "game" a "title screen" of sorts; click to begin. Chris Pressey 4 years ago
2 changed file(s) with 68 addition(s) and 27 deletion(s). Raw diff Collapse all Expand all
4545 the joystick (i.e. bring it up to par with the original demo game that was written
4646 for SixtyPical)
4747
48 ### Self-reference in signatures
48 ### `call` routines that are defined further down in the source code
4949
50 A vector might store [the address of] a routine which changes the vector. Thus its
51 signature might look like `vector foo outputs foo`. Thus we need to support that.
50 We might have a graph of states that refer to each other and that want to `goto`
51 each other. Thus we need this. We have it for vectors, but we need it for `call`.
52
53 ### Allow branches to diverge in what they touch
54
55 For example, if the routine inputs and outputs `foo`, and one branch of an `if`
56 sets `foo` and the other does not touch it, that should be OK.
5257
5358 ### `vector table` type
5459
22 // ****************************
33
44 // ----------------------------------------------------------------
5 // Global Variables and System Locations
5 // System Locations
66 // ----------------------------------------------------------------
77
88 byte vic_border @ 53280
2121 buffer[2048] screen @ 1024
2222 byte joy2 @ $dc00
2323
24 // ----------------------------------------------------------------
25 // Global Variables
26 // ----------------------------------------------------------------
27
2428 pointer ptr @ 254
2529 word pos
2630 word delta
31 byte button_down : 0 // effectively static-local to check_button
2732
2833 //
2934 // Points to the routine that implements the current game state.
3035 //
3136
3237 vector dispatch_game_state
33 inputs joy2, pos
34 outputs delta, pos, screen, screen1, dispatch_game_state
38 inputs joy2, pos, button_down, dispatch_game_state
39 outputs delta, pos, screen, screen1, button_down, dispatch_game_state
3540 trashes a, x, y, c, z, n, v, ptr
3641
3742 //
4752 //
4853
4954 vector cinv
50 inputs joy2, pos
51 outputs delta, pos, dispatch_game_state, screen, screen1
55 inputs joy2, pos, button_down, dispatch_game_state
56 outputs delta, pos, screen, screen1, button_down, dispatch_game_state
5257 trashes a, x, y, c, z, n, v, ptr
5358 @ 788
5459
5560 vector save_cinv
56 inputs joy2, pos
57 outputs delta, pos, dispatch_game_state, screen, screen1
58 trashes a, x, y, c, z, n, v, ptr
59
61 inputs joy2, pos, button_down, dispatch_game_state
62 outputs delta, pos, screen, screen1, button_down, dispatch_game_state
63 trashes a, x, y, c, z, n, v, ptr
6064
6165 // ----------------------------------------------------------------
6266 // Utility Routines
9599 }
96100 }
97101
102 // You can repeatedly (i.e. as part of actor logic or an IRQ handler)
103 // call this routine.
104 // Upon return, if carry is set, the button was pressed then released.
105
106 routine check_button
107 inputs joy2, button_down
108 outputs c, button_down
109 trashes a, z, n
110 {
111 ld a, button_down
112 if z {
113 ld a, joy2
114 and a, $10
115 if z {
116 ld a, 1
117 st a, button_down
118 }
119 st off, c
120 } else {
121 ld a, joy2
122 and a, $10
123 if not z {
124 ld a, 0
125 st a, button_down
126 st on, c
127 } else {
128 st off, c
129 }
130 }
131 }
132
98133 routine clear_screen
99134 outputs screen1, screen2, screen3, screen4, colormap1, colormap2, colormap3, colormap4
100135 trashes a, y, c, n, z
127162 //
128163
129164 routine game_state_play
130 inputs joy2, pos
131 outputs delta, pos, dispatch_game_state, screen, screen1
165 inputs joy2, pos, button_down, dispatch_game_state
166 outputs delta, pos, screen, screen1, button_down, dispatch_game_state
132167 trashes a, x, y, c, z, n, v, ptr
133168 {
134169 call read_stick
147182 }
148183
149184 routine game_state_title_screen
150 inputs joy2, pos
151 outputs delta, pos, screen, screen1, dispatch_game_state
152 trashes a, x, y, c, z, n, v, ptr
153 {
154 ld y, 0
185 inputs joy2, pos, button_down, dispatch_game_state
186 outputs delta, pos, screen, screen1, button_down, dispatch_game_state
187 trashes a, x, y, c, z, n, v, ptr
188 {
189 ld y, 10
155190 repeat {
156 ld a, 82
191 ld a, 90
157192 st a, screen1 + y
158193 inc y
159 cmp y, 18
160 } until not z
194 cmp y, 20
195 } until z
161196
162197 st off, c
163 // jsr check_button
198 call check_button
164199
165200 if c {
166201 // call clear_screen
167 // jsr init_game
202 // call init_game
168203 copy game_state_play, dispatch_game_state
169204 } else {
170 copy game_state_play, dispatch_game_state
205 // This is sort of a hack. FIXME: let `if` branches diverge this much.
206 copy dispatch_game_state, dispatch_game_state
171207 }
172208
173209 goto save_cinv
178214 // *************************
179215
180216 routine our_cinv
181 inputs joy2, pos
182 outputs delta, pos, dispatch_game_state, screen, screen1
217 inputs joy2, pos, button_down, dispatch_game_state
218 outputs delta, pos, screen, screen1, button_down, dispatch_game_state
183219 trashes a, x, y, c, z, n, v, ptr
184220 {
185221 goto dispatch_game_state