@@ -180,7 +180,7 @@ static bool g_play_level(const u8 level, const u8 gems) {
180180
181181 volatile bool finished = false, success = false;
182182 volatile u16 count = 0 ;
183- bool moved , eaten , move_l = false, move_r = false;
183+ bool paused , moved , eaten , move_l = false, move_r = false;
184184 u16 key_l , key_r ;
185185 u8 c_offset = g_options [1 ] ? 0 : 2 ;
186186 u8 gems_left = gems ;
@@ -195,26 +195,43 @@ static bool g_play_level(const u8 level, const u8 gems) {
195195 cpct_waitVSYNC ();
196196
197197 /* Keep going until we've lost a life or cleared the level */
198+ paused = false;
198199 while (!finished ) {
199200
200201 /* Work out Controls */
201- key_l = controls [sn .direction ][c_offset ];
202- key_r = controls [sn .direction ][c_offset + 1 ];
203-
204- cpct_scanKeyboard ();
205- move_l = cpct_isKeyPressed (key_l );
206- move_r = cpct_isKeyPressed (key_r );
202+ if (frame_c % 3 == 0 ) {
203+ key_l = controls [sn .direction ][c_offset ];
204+ key_r = controls [sn .direction ][c_offset + 1 ];
205+
206+ //cpct_scanKeyboard();
207+ cpct_scanKeyboard ();
208+ move_l = cpct_isKeyPressed (key_l );
209+ move_r = cpct_isKeyPressed (key_r );
210+
211+ /* Quit Key */
212+ if (cpct_isKeyPressed (Key_Q )) {
213+ finished = true;
214+ success = false;
215+ lives = 0 ;
216+ }
207217
208- /* Check for Quit */
209- if (cpct_isKeyPressed (Key_Q ))
210- finished = true;
218+ /* Cheat Key */
219+ if (cpct_isKeyPressed (Key_C )) {
220+ finished = true;
221+ success = true;
222+ }
211223
212- /* Cheat Key */
213- if (cpct_isKeyPressed (Key_C )) {
214- finished = true;
215- success = true;
224+ /* Pause Key */
225+ if (cpct_isKeyPressed (Key_P )) {
226+ paused = !paused ;
227+ if (paused )
228+ u_wait (1000 );
229+ }
216230 }
217231
232+ if (paused )
233+ continue ;
234+
218235 /* Main Loop */
219236 if (frame_c % 2 == 0 ) {
220237
@@ -235,12 +252,6 @@ static bool g_play_level(const u8 level, const u8 gems) {
235252 g_redraw_score (score );
236253 }
237254
238- /* Check for Collision */
239- if (s_check_collide (& sn )) {
240- success = false;
241- break ;
242- }
243-
244255 /* If we have eaten all the Gems! */
245256 if (gems_left == 0 ) {
246257
@@ -290,6 +301,15 @@ static bool g_play_level(const u8 level, const u8 gems) {
290301
291302 cpct_waitVSYNC ();
292303 }
304+
305+ if (frame_c % 5 == 0 ) {
306+
307+ /* Check for Collision */
308+ if (s_check_collide (& sn )) {
309+ success = false;
310+ break ;
311+ }
312+ }
293313 }
294314
295315 if (!success )
0 commit comments