git @ Cat's Eye Technologies SixtyPical / e46c6f6
Improve error messaging yet more. Game kind of has game states now. Chris Pressey 4 years ago
2 changed file(s) with 26 addition(s) and 21 deletion(s). Raw diff Collapse all Expand all
3131
3232 vector dispatch_game_state
3333 inputs joy2, pos
34 outputs delta, pos, screen, screen1
34 outputs delta, pos, screen, screen1, dispatch_game_state
3535 trashes a, x, y, c, z, n, v, ptr
3636
3737 //
4848
4949 vector cinv
5050 inputs joy2, pos
51 outputs delta, pos, screen, screen1
51 outputs delta, pos, dispatch_game_state, screen, screen1
5252 trashes a, x, y, c, z, n, v, ptr
5353 @ 788
5454
5555 vector save_cinv
5656 inputs joy2, pos
57 outputs delta, pos, screen, screen1
57 outputs delta, pos, dispatch_game_state, screen, screen1
5858 trashes a, x, y, c, z, n, v, ptr
5959
6060
124124
125125 routine game_state_play
126126 inputs joy2, pos
127 outputs delta, pos, screen, screen1
127 outputs delta, pos, dispatch_game_state, screen, screen1
128128 trashes a, x, y, c, z, n, v, ptr
129129 {
130130 call read_stick
144144
145145 routine game_state_title_screen
146146 inputs joy2, pos
147 outputs delta, pos, screen, screen1
147 outputs delta, pos, screen, screen1, dispatch_game_state
148148 trashes a, x, y, c, z, n, v, ptr
149149 {
150150 ld y, 0
161161 if c {
162162 // call clear_screen
163163 // jsr init_game
164 // FIXME various reasons we can't do this, mainly that self-reference
165 // is disallowed: we would need to put "outputs dispatch_game_state" in
166 // the signature of dispatch_game_state!
167 // copy game_state_play, dispatch_game_state
164 copy game_state_play, dispatch_game_state
165 } else {
166 copy game_state_play, dispatch_game_state
168167 }
169168
170169 goto save_cinv
176175
177176 routine our_cinv
178177 inputs joy2, pos
179 outputs delta, pos, screen, screen1
178 outputs delta, pos, dispatch_game_state, screen, screen1
180179 trashes a, x, y, c, z, n, v, ptr
181180 {
182181 goto dispatch_game_state
196195
197196 call clear_screen
198197
199 copy game_state_play, dispatch_game_state
200 // copy game_state_title_screen, dispatch_game_state
198 copy game_state_title_screen, dispatch_game_state
201199
202200 copy word 0, pos
203201 with interrupts off {
184184 )
185185
186186 def assert_affected_within(self, name, affected, limited_to):
187
188 def format(loc):
189 assert isinstance(loc, LocationRef)
190 return loc.name
191
192 if affected <= limited_to:
187 # We reduce the set of LocationRefs to a set of strings (their labels).
188 # This is necessary because currently, two LocationRefs that refer to the
189 # same location are not considered euqal. (But two LocationRefs with the
190 # same label should always be the same type.)
191
192 affected = set([loc.name for loc in affected])
193 limited_to = set([loc.name for loc in limited_to])
194
195 def loc_list(label_set):
196 return ', '.join(sorted(label_set))
197
198 overage = affected - limited_to
199 if not overage:
193200 return
194 overage = affected - limited_to
195 overage_s = ', '.join(sorted([format(loc) for loc in overage]))
196 message = 'affected beyond %s: {%s} in %s' % (name, overage_s, self.current_routine.name)
201 message = 'in %s: %s are {%s} but affects {%s} which exceeds by: {%s} ' % (
202 self.current_routine.name, name, loc_list(limited_to), loc_list(affected), loc_list(overage)
203 )
197204 raise IncompatibleConstraintsError(message)
198205
199206 def analyze_program(self, program):