then break out, THEN worry about user input. Replace scanf nonsense with
simple getch() and keyboard response, since the prompt shown to the user
doesn't say to hit ENTER after typing 1, 2, 3, 4, 6, or 0, or "65536"
for changing the tile variable.
#ifdef BOINK
while(d>0) // on!
{
#ifdef BOINK
while(d>0) // on!
{
- if(!kbhit())
- { // conditions of screen saver
+ /* run screensaver routine until keyboard input */
+ while (key > 0) {
+ if (kbhit()) {
+ getch(); // eat keyboard input
+ break;
+ }
+
ding(&gvar.video.page[0], &bakapee, key);
}
ding(&gvar.video.page[0], &bakapee, key);
}
# ifndef MXLIB
# error REMOVED // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
// we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
# ifndef MXLIB
# error REMOVED // this code is written around modex16 which so far is a better fit than using DOSLIB vga directly, so leave MXLIB code in.
// we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
# endif
// user imput switch
fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
# endif
// user imput switch
fprintf(stderr, "xx=%d yy=%d tile=%d\n", bakapee.xx, bakapee.yy, bakapee.tile);
- printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n", getch()); // prompt the user
- //scanf("%d", &key);
- if(scanf("%d", &key) != 1)
- {
- printf("%d\n", key);
- }
- getch();
- //if(key==3){xx=yy=0;} // crazy screen saver wwww
- switch (key)
- {
- case 0:
+ printf("Enter 1, 2, 3, 4, or 6 to run a screensaver, or enter 0 to quit.\n");
+
+ c = getch();
+ switch (c) {
+ case 27: /* Escape key */
+ case '0':
+ break;
+ case 'b': // test tile change
switch (bakapee.tile)
{
case 0:
switch (bakapee.tile)
{
case 0:
+ key=0;
+ break;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ key = c - '0';
# ifdef MXLIB
gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
gvar.video.page[0].width += (TILEWH*2);
# ifdef MXLIB
gvar.video.page[0] = modexDefaultPage(&gvar.video.page[0]);
gvar.video.page[0].width += (TILEWH*2);
// we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
# endif
modexShowPage(&gvar.video.page[0]);
// we'll integrate DOSLIB vga into that part of the code instead for less disruption. -- J.C.
# endif
modexShowPage(&gvar.video.page[0]);
+ break;
+ default:
+ key=0;
+ break;