Consistently use conio (instead of mixing with stdio).
git-svn-id: svn://svn.cc65.org/cc65/trunk@5912 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <mouse.h>
|
#include <mouse.h>
|
||||||
@@ -65,7 +64,7 @@ static const unsigned char MouseSprite[64] = {
|
|||||||
static void CheckError (const char* S, unsigned char Error)
|
static void CheckError (const char* S, unsigned char Error)
|
||||||
{
|
{
|
||||||
if (Error != MOUSE_ERR_OK) {
|
if (Error != MOUSE_ERR_OK) {
|
||||||
printf ("%s: %s(%d)\n", S, mouse_geterrormsg (Error), Error);
|
cprintf ("%s: %s(%d)\r\n", S, mouse_geterrormsg (Error), Error);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,15 +74,15 @@ static void CheckError (const char* S, unsigned char Error)
|
|||||||
static void DoWarning (void)
|
static void DoWarning (void)
|
||||||
/* Warn the user that a mouse driver is needed for this program */
|
/* Warn the user that a mouse driver is needed for this program */
|
||||||
{
|
{
|
||||||
printf ("Warning: This program needs the mouse\n"
|
cprintf ("Warning: This program needs the mouse\r\n"
|
||||||
"driver with the name\n"
|
"driver with the name\r\n"
|
||||||
" %s\n"
|
" %s\r\n"
|
||||||
"on disk! Press 'y' if you have it or\n"
|
"on disk! Press 'y' if you have it or\r\n"
|
||||||
"any other key to exit.\n", mouse_stddrv);
|
"any other key to exit.\r\n", mouse_stddrv);
|
||||||
if (tolower (cgetc ()) != 'y') {
|
if (tolower (cgetc ()) != 'y') {
|
||||||
exit (EXIT_SUCCESS);
|
exit (EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
printf ("Ok. Please wait patiently...\n");
|
cprintf ("Ok. Please wait patiently...\r\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -111,9 +110,6 @@ int main (void)
|
|||||||
/* Initialize the debugger */
|
/* Initialize the debugger */
|
||||||
DbgInit (0);
|
DbgInit (0);
|
||||||
|
|
||||||
/* Output a warning about the driver that is needed */
|
|
||||||
DoWarning ();
|
|
||||||
|
|
||||||
/* Clear the screen, set white on black */
|
/* Clear the screen, set white on black */
|
||||||
(void) bordercolor (COLOR_BLACK);
|
(void) bordercolor (COLOR_BLACK);
|
||||||
(void) bgcolor (COLOR_BLACK);
|
(void) bgcolor (COLOR_BLACK);
|
||||||
@@ -137,6 +133,9 @@ int main (void)
|
|||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Output a warning about the driver that is needed */
|
||||||
|
DoWarning ();
|
||||||
|
|
||||||
/* Load and install the mouse driver */
|
/* Load and install the mouse driver */
|
||||||
CheckError ("mouse_load_driver",
|
CheckError ("mouse_load_driver",
|
||||||
mouse_load_driver (&mouse_def_callbacks, mouse_stddrv));
|
mouse_load_driver (&mouse_def_callbacks, mouse_stddrv));
|
||||||
@@ -145,6 +144,7 @@ int main (void)
|
|||||||
mouse_getbox (&full_box);
|
mouse_getbox (&full_box);
|
||||||
|
|
||||||
/* Print a help line */
|
/* Print a help line */
|
||||||
|
clrscr ();
|
||||||
revers (1);
|
revers (1);
|
||||||
cputsxy (0, 0, "d)ebug h)ide q)uit s)how j)ail ");
|
cputsxy (0, 0, "d)ebug h)ide q)uit s)how j)ail ");
|
||||||
revers (0);
|
revers (0);
|
||||||
@@ -156,29 +156,29 @@ int main (void)
|
|||||||
ShowState (Jailed, Invisible);
|
ShowState (Jailed, Invisible);
|
||||||
while (!Done) {
|
while (!Done) {
|
||||||
|
|
||||||
/* Get the current mouse coordinates and button states and print them */
|
/* Get the current mouse coordinates and button states and print them */
|
||||||
mouse_info (&info);
|
mouse_info (&info);
|
||||||
gotoxy (0, 2);
|
gotoxy (0, 2);
|
||||||
cprintf ("X = %3d", info.pos.x);
|
cprintf ("X = %3d", info.pos.x);
|
||||||
gotoxy (0, 3);
|
gotoxy (0, 3);
|
||||||
cprintf ("Y = %3d", info.pos.y);
|
cprintf ("Y = %3d", info.pos.y);
|
||||||
gotoxy (0, 4);
|
gotoxy (0, 4);
|
||||||
cprintf ("LB = %c", (info.buttons & MOUSE_BTN_LEFT)? '1' : '0');
|
cprintf ("LB = %c", (info.buttons & MOUSE_BTN_LEFT)? '1' : '0');
|
||||||
gotoxy (0, 5);
|
gotoxy (0, 5);
|
||||||
cprintf ("RB = %c", (info.buttons & MOUSE_BTN_RIGHT)? '1' : '0');
|
cprintf ("RB = %c", (info.buttons & MOUSE_BTN_RIGHT)? '1' : '0');
|
||||||
|
|
||||||
/* Handle user input */
|
/* Handle user input */
|
||||||
if (kbhit ()) {
|
if (kbhit ()) {
|
||||||
switch (tolower (cgetc ())) {
|
switch (tolower (cgetc ())) {
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
BREAK();
|
BREAK();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'h':
|
case 'h':
|
||||||
ShowState (Jailed, ++Invisible);
|
ShowState (Jailed, ++Invisible);
|
||||||
mouse_hide ();
|
mouse_hide ();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'j':
|
case 'j':
|
||||||
if (Jailed) {
|
if (Jailed) {
|
||||||
@@ -195,18 +195,18 @@ int main (void)
|
|||||||
ShowState (Jailed, Invisible);
|
ShowState (Jailed, Invisible);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
if (Invisible) {
|
if (Invisible) {
|
||||||
ShowState (Jailed, --Invisible);
|
ShowState (Jailed, --Invisible);
|
||||||
mouse_show ();
|
mouse_show ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'q':
|
case 'q':
|
||||||
Done = 1;
|
Done = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -219,6 +219,3 @@ int main (void)
|
|||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user