Re: [cc65] Input string routine for a line of data?

From: Karri Kaksonen <karri1sipo.fi>
Date: 2011-06-07 06:55:23
In games you cannot use blocking inputs. The cc65 also supports kbhit().

An non-blocking input module could look like:

check_for_user_input() {
   char joy;
   if (kbhit()) {
     char ch = cgetc();
     ... // Append one character to your input string
   }
   joy = joy_read(JOY_1);
   if (JOY_BTN_UP(joy)) {
   }
     ...
   }
}

Basically most (all?) Lynx games follow a very simple pattern.

initialize();
while (running) {
   advance_game();
   check_for_user_input();
   if (display_not_busy()) {
     update_display();
   }
   update_sound();
}

Using blocking input would cause the game to break animation and sound.

The other choice is to use threads and allow the input thread to use 
blocking input.
--
Karri

----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Tue Jun 7 06:55:48 2011

This archive was generated by hypermail 2.1.8 : 2011-06-07 06:55:50 CEST