- Addition of the -f command line option to lower the FPS if needed.
64-bit. Fixed.
- Memory was leaked everytime the title screen was displayed in the
form of unnecessarily created pads that were never deleted.
+- The refresh function forced a full screen refresh everytime,
+ making user input unresponsive whenever a terminal was slightly
+ restricted in bandwidth.
IMPROVEMENTS
- Add high score keeping and display the scores on the title screen.
+- Bandwidth efficiency improvent and addition of the -f option to
+ lower the frame rate from the default (very high) 50, if necessary.
+
TODO
void showUsage(void)
{
- fprintf(stderr, "\n\nUsage: nInvaders [-l skill] [-L]\n");
- fprintf(stderr, " where -l 0=NIGHTMARE\n");
- fprintf(stderr, " -l 1=okay\n");
- fprintf(stderr, " -l 9=May I play daddy?!\n");
- fprintf(stderr, "\n -L display the distribution license\n");
+ fprintf(stderr, "\n\nUsage: nInvaders [-f <fps>] [-l skill] [-L]\n");
+ fprintf(stderr,
+ " Where:\n\n"
+ " -f <fps> - Frame rate, lower if unresponsive on low bps\n\n"
+ " -l 0=NIGHTMARE\n"
+ " -l 1=okay\n"
+ " -l 9=May I play daddy?!\n\n"
+ " -L display the distribution license\n");
+ fprintf(stderr, "\n");
}
#include "aliens.h"
#include "ufo.h"
-#define FPS 50
+#define DEFAULT_FPS 50
+
+int fps = DEFAULT_FPS;
int lives;
long score = 0, hiscore = 0;
{
int ch, i;
- while ((ch = getopt(argc, argv, "?l:L")) != -1) {
+ while ((ch = getopt(argc, argv, "?f:l:L")) != -1) {
switch (ch) {
+ case 'f':
+ if ((i = atoi(optarg)) >= 5 && i <= 50)
+ fps = i;
+ break;
case 'l':
if ((i = atoi(optarg)) > -1 && i < 10)
skill_level = i;
struct itimerval myTimer;
struct sigaction myAction;
myTimer.it_value.tv_sec = 0;
- myTimer.it_value.tv_usec = 1000000 / FPS;
+ myTimer.it_value.tv_usec = 1000000 / fps;
myTimer.it_interval.tv_sec = 0;
- myTimer.it_interval.tv_usec = 1000000 / FPS;
+ myTimer.it_interval.tv_usec = 1000000 / fps;
setitimer(ITIMER_REAL, &myTimer, NULL);
myAction.sa_handler = handleTimer;
*/
void refreshScreen(void)
{
- redrawwin(wBattleField); // needed to display graphics properly at startup on some terminals
+ /*
+ * The following is claimed to be necessary on some terminals for
+ * graphics to properly display at startup. It however is prohibitive
+ * in that it forces a full refresh every FPS, which by default is 50.
+ * For this reason, whenever a terminal is restricted in bandwidth,
+ * even with speeds as high as 19200bps, it becomes completely
+ * unresponsive to user input, even with the added -f option to lower
+ * the FPS. Without the following line, everything is fine.
+ * If the issue was really at startup, it theoretically would be
+ * possible to only force this refresh once or twice. Disabled for
+ * now.
+ */
+ /* redrawwin(wBattleField); XXX */
wrefresh(wBattleField);
-
}