Module checked in last time was wrong version
git-svn-id: svn://svn.cc65.org/cc65/trunk@884 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
c090f90172
commit
cf4555f101
1 changed files with 102 additions and 11 deletions
|
@ -1,32 +1,123 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
#include <mouse.h>
|
#include <mouse.h>
|
||||||
#include <conio.h>
|
#include <conio.h>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__C64__) || defined(__C128__)
|
||||||
|
|
||||||
|
/* Address of data for sprite 1 */
|
||||||
|
#define SPRITE1_DATA 0x340
|
||||||
|
|
||||||
|
/* The mouse sprite (an arrow) */
|
||||||
|
static const unsigned char MouseSprite[64] = {
|
||||||
|
0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00,
|
||||||
|
0x0F, 0xE0, 0x00,
|
||||||
|
0x0F, 0xC0, 0x00,
|
||||||
|
0x0F, 0x80, 0x00,
|
||||||
|
0x0F, 0xC0, 0x00,
|
||||||
|
0x0D, 0xE0, 0x00,
|
||||||
|
0x08, 0xF0, 0x00,
|
||||||
|
0x00, 120, 0x00,
|
||||||
|
0x00, 60, 0x00,
|
||||||
|
0x00, 30, 0x00,
|
||||||
|
0x00, 0x0F, 0x00,
|
||||||
|
0x00, 0x07, 0x80,
|
||||||
|
0x00, 0x03, 0x80,
|
||||||
|
0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00,
|
||||||
|
0x00, 0x00, 0x00,
|
||||||
|
0x00
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void ShowState (unsigned char Invisible)
|
||||||
|
/* Display cursor visibility */
|
||||||
|
{
|
||||||
|
gotoxy (0, 6);
|
||||||
|
cclear (40);
|
||||||
|
gotoxy (0, 6);
|
||||||
|
cprintf ("Mouse cursor %svisible", Invisible? "in" : "");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
int main (void)
|
int main (void)
|
||||||
{
|
{
|
||||||
struct mouse_pos pos;
|
struct mouse_info info;
|
||||||
|
unsigned char Invisible;
|
||||||
|
|
||||||
|
/* Clear the screen, set white on black */
|
||||||
|
bordercolor (COLOR_BLACK);
|
||||||
|
bgcolor (COLOR_BLACK);
|
||||||
|
textcolor (COLOR_GRAY3);
|
||||||
|
cursor (0);
|
||||||
clrscr ();
|
clrscr ();
|
||||||
mouse_init (1, 1, MOUSE_C64);
|
|
||||||
/* mouse_box (0, 29, 344, 250); */
|
/* Print a help line */
|
||||||
|
cputsxy (0, 0, "s = show h = hide q = quit");
|
||||||
|
|
||||||
|
#if defined(__C64__) || defined(__C128__)
|
||||||
|
/* Copy the sprite data */
|
||||||
|
memcpy ((void*) SPRITE1_DATA, MouseSprite, sizeof (MouseSprite));
|
||||||
|
|
||||||
|
/* Set the VIC sprite pointer */
|
||||||
|
*(unsigned char*)0x7F8 = SPRITE1_DATA / 64;
|
||||||
|
|
||||||
|
/* Set the color of sprite 0 */
|
||||||
|
VIC.spr0_color = COLOR_WHITE;
|
||||||
|
|
||||||
|
/* Initialize the mouse */
|
||||||
|
mouse_init (0, 1, MOUSE_C64);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Move the mouse to the center of the screen */
|
||||||
|
mouse_move (160, 100);
|
||||||
|
|
||||||
|
/* Test loop */
|
||||||
|
ShowState (Invisible = 1);
|
||||||
while (1) {
|
while (1) {
|
||||||
if (kbhit()) {
|
if (kbhit()) {
|
||||||
switch (cgetc()) {
|
switch (cgetc()) {
|
||||||
case 's': mouse_show (); break;
|
case 's':
|
||||||
case 'h': mouse_hide (); break;
|
if (Invisible) {
|
||||||
case 'q': mouse_done (); exit (0);
|
ShowState (--Invisible);
|
||||||
|
mouse_show ();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'h':
|
||||||
|
ShowState (++Invisible);
|
||||||
|
mouse_hide ();
|
||||||
|
break;
|
||||||
|
case 'q':
|
||||||
|
mouse_done ();
|
||||||
|
exit (0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mouse_pos (&pos);
|
|
||||||
gotoxy (0, 0);
|
/* Get the current mouse coordinates and button states and print them */
|
||||||
cprintf ("%04X", pos.x);
|
mouse_info (&info);
|
||||||
gotoxy (0, 1);
|
gotoxy (0, 2);
|
||||||
cprintf ("%04X", pos.y);
|
cprintf ("X = %3d", info.pos.x);
|
||||||
|
gotoxy (0, 3);
|
||||||
|
cprintf ("Y = %3d", info.pos.y);
|
||||||
|
gotoxy (0, 4);
|
||||||
|
cprintf ("LB = %c", (info.buttons & MOUSE_BTN_LEFT)? '1' : '0');
|
||||||
|
gotoxy (0, 5);
|
||||||
|
cprintf ("RB = %c", (info.buttons & MOUSE_BTN_RIGHT)? '1' : '0');
|
||||||
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue