Update the mouse demo to run with the new mouse API that uses loadable
drivers. Remove Atari support because there are no loadable drivers for the Atari. git-svn-id: svn://svn.cc65.org/cc65/trunk@3292 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
@@ -12,4 +12,5 @@ tgidemo
|
|||||||
*.d64
|
*.d64
|
||||||
*.s
|
*.s
|
||||||
*.lbl
|
*.lbl
|
||||||
|
*.mou
|
||||||
*.tgi
|
*.tgi
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ Platforms: Runs on all platforms that support conio, which means:
|
|||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
Name: mandelbrot
|
Name: mandelbrot
|
||||||
Description: A mandelbrot demo using integer arithmetic. The demo was
|
Description: A mandelbrot demo using integer arithmetic. The demo was
|
||||||
written by groepaz/hitmen and converted to cc65 using TGI
|
written by groepaz/hitmen and converted to cc65 using TGI
|
||||||
graphics by Stephan Haubenthal.
|
graphics by Stephan Haubenthal.
|
||||||
Platforms: All systems with TGI support. You may have to change the
|
Platforms: All systems with TGI support. You may have to change the
|
||||||
driver/resolution definition in the source.
|
driver/resolution definition in the source.
|
||||||
@@ -57,8 +57,8 @@ Platforms: All systems with TGI support. You may have to change the
|
|||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
Name: mousedemo
|
Name: mousedemo
|
||||||
Description: Shows how to use the mouse.
|
Description: Shows how to use the mouse.
|
||||||
Platforms: All systems with mouse and conio support:
|
Platforms: All systems with mouse and conio support:
|
||||||
Atari (untested), C64, C128 and CBM510
|
C64, C128
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
Name: nachtm
|
Name: nachtm
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <mouse.h>
|
#include <mouse.h>
|
||||||
@@ -21,12 +22,15 @@
|
|||||||
#if defined(__C64__)
|
#if defined(__C64__)
|
||||||
# define SPRITE0_DATA 0x0340
|
# define SPRITE0_DATA 0x0340
|
||||||
# define SPRITE0_PTR 0x07F8
|
# define SPRITE0_PTR 0x07F8
|
||||||
|
# define DRIVER "c64-1351.mou"
|
||||||
#elif defined(__C128__)
|
#elif defined(__C128__)
|
||||||
# define SPRITE0_DATA 0x0E00
|
# define SPRITE0_DATA 0x0E00
|
||||||
# define SPRITE0_PTR 0x07F8
|
# define SPRITE0_PTR 0x07F8
|
||||||
|
# define DRIVER "c128-1351.mou"
|
||||||
#elif defined(__CBM510__)
|
#elif defined(__CBM510__)
|
||||||
# define SPRITE0_DATA 0xF400
|
# define SPRITE0_DATA 0xF400
|
||||||
# define SPRITE0_PTR 0xF3F8
|
# define SPRITE0_PTR 0xF3F8
|
||||||
|
# define DRIVER "" /* Currently unavailable */
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* The mouse sprite (an arrow) */
|
/* The mouse sprite (an arrow) */
|
||||||
@@ -59,6 +63,32 @@ static const unsigned char MouseSprite[64] = {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void CheckError (const char* S, unsigned char Error)
|
||||||
|
{
|
||||||
|
if (Error != MOUSE_ERR_OK) {
|
||||||
|
printf ("%s: %s(%d)\n", S, mouse_geterrormsg (Error), Error);
|
||||||
|
exit (EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
static void DoWarning (void)
|
||||||
|
/* Warn the user that a mouse driver is needed for this program */
|
||||||
|
{
|
||||||
|
printf ("Warning: This program needs the mouse\n"
|
||||||
|
"driver with the name\n"
|
||||||
|
" %s\n"
|
||||||
|
"on disk! Press 'y' if you have it or\n"
|
||||||
|
"any other key to exit.\n", DRIVER);
|
||||||
|
if (cgetc () != 'y') {
|
||||||
|
exit (EXIT_SUCCESS);
|
||||||
|
}
|
||||||
|
printf ("Ok. Please wait patiently...\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void ShowState (unsigned char Invisible)
|
static void ShowState (unsigned char Invisible)
|
||||||
/* Display cursor visibility */
|
/* Display cursor visibility */
|
||||||
{
|
{
|
||||||
@@ -75,13 +105,13 @@ int main (void)
|
|||||||
struct mouse_info info;
|
struct mouse_info info;
|
||||||
unsigned char Invisible;
|
unsigned char Invisible;
|
||||||
unsigned char Done;
|
unsigned char Done;
|
||||||
#if defined(__ATARI__)
|
|
||||||
unsigned char type;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* 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 */
|
||||||
bordercolor (COLOR_BLACK);
|
bordercolor (COLOR_BLACK);
|
||||||
bgcolor (COLOR_BLACK);
|
bgcolor (COLOR_BLACK);
|
||||||
@@ -103,29 +133,11 @@ int main (void)
|
|||||||
VIC.spr0_color = COLOR_WHITE;
|
VIC.spr0_color = COLOR_WHITE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize the mouse */
|
|
||||||
mouse_init (MOUSE_CBM1351);
|
|
||||||
|
|
||||||
#elif defined(__ATARI__)
|
|
||||||
|
|
||||||
do {
|
|
||||||
cputs("\r\n");
|
|
||||||
cputs("0 = trak-ball\r\n");
|
|
||||||
cputs("1 = ST mouse\r\n");
|
|
||||||
cputs("2 = Amiga mouse\r\n");
|
|
||||||
cputs("Enter type (0-2): ");
|
|
||||||
type = cgetc();
|
|
||||||
cputc(type);
|
|
||||||
} while (type < '0' || type > '2');
|
|
||||||
type -= '0';
|
|
||||||
|
|
||||||
/* Initialize the mouse */
|
|
||||||
mouse_init (type);
|
|
||||||
*(unsigned char *)0x2c0 = 15; /* set mouse cursor color (PM0) */
|
|
||||||
clrscr ();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Load and install the mouse driver */
|
||||||
|
CheckError ("mouse_load_driver", mouse_load_driver (&mouse_def_callbacks, DRIVER));
|
||||||
|
|
||||||
/* Print a help line */
|
/* Print a help line */
|
||||||
revers (1);
|
revers (1);
|
||||||
cputsxy (0, 0, "d: debug h: hide q: quit s: show ");
|
cputsxy (0, 0, "d: debug h: hide q: quit s: show ");
|
||||||
@@ -169,7 +181,10 @@ int main (void)
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mouse_done ();
|
/* Uninstall and unload the mouse driver */
|
||||||
|
CheckError ("mouse_unload", mouse_unload ());
|
||||||
|
|
||||||
|
/* Say goodbye */
|
||||||
clrscr ();
|
clrscr ();
|
||||||
cputs ("Goodbye!\r\n");
|
cputs ("Goodbye!\r\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user