2 * Demo program for mouse usage. Will work for the C64/C128/Atari
4 * Ullrich von Bassewitz, 13.09.2001
18 #if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
20 /* Address of data for sprite 0 */
22 # define SPRITE0_DATA 0x0340
23 # define SPRITE0_PTR 0x07F8
24 #elif defined(__C128__)
25 # define SPRITE0_DATA 0x0E00
26 # define SPRITE0_PTR 0x07F8
27 #elif defined(__CBM510__)
28 # define SPRITE0_DATA 0xF800
29 # define SPRITE0_PTR 0xF7F8
32 /* The mouse sprite (an arrow) */
33 static const unsigned char MouseSprite[64] = {
58 #endif /* __C64__ or __C128__ */
62 static void ShowState (unsigned char Invisible)
63 /* Display cursor visibility */
68 cprintf ("Mouse cursor %svisible", Invisible? "in" : "");
75 struct mouse_info info;
76 unsigned char Invisible;
79 /* Initialize the debugger */
82 /* Clear the screen, set white on black */
83 bordercolor (COLOR_BLACK);
84 bgcolor (COLOR_BLACK);
85 textcolor (COLOR_GRAY3);
89 /* Print a help line */
91 cputsxy (0, 0, "d: debug h: hide q: quit s: show ");
94 #if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
95 /* Copy the sprite data */
96 memcpy ((void*) SPRITE0_DATA, MouseSprite, sizeof (MouseSprite));
98 /* Set the VIC sprite pointer */
99 *(unsigned char*)SPRITE0_PTR = SPRITE0_DATA / 64;
101 /* Set the color of sprite 0 */
102 VIC.spr0_color = COLOR_WHITE;
104 /* Initialize the mouse */
105 mouse_init (MOUSE_C64);
107 #elif defined(__ATARI__)
109 /* Initialize the mouse */
110 mouse_init (MOUSE_TRAKBALL);
116 ShowState (Invisible = 1);
124 ShowState (++Invisible);
129 ShowState (--Invisible);
139 /* Get the current mouse coordinates and button states and print them */
142 cprintf ("X = %3d", info.pos.x);
144 cprintf ("Y = %3d", info.pos.y);
146 cprintf ("LB = %c", (info.buttons & MOUSE_BTN_LEFT)? '1' : '0');
148 cprintf ("RB = %c", (info.buttons & MOUSE_BTN_RIGHT)? '1' : '0');
154 cputs ("Goodbye!\r\n");