2 * Demo program for mouse usage. Will work for the C64/C128/CBM510/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 0xF400
29 # define SPRITE0_PTR 0xF3F8
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;
78 #if defined(__ATARI__)
82 /* Initialize the debugger */
85 /* Clear the screen, set white on black */
86 bordercolor (COLOR_BLACK);
87 bgcolor (COLOR_BLACK);
88 textcolor (COLOR_GRAY3);
92 #if defined(__C64__) || defined(__C128__) || defined(__CBM510__)
93 /* Copy the sprite data */
94 memcpy ((void*) SPRITE0_DATA, MouseSprite, sizeof (MouseSprite));
96 /* Set the VIC sprite pointer */
97 *(unsigned char*)SPRITE0_PTR = SPRITE0_DATA / 64;
99 /* Set the color of sprite 0 */
101 pokebsys ((unsigned) &VIC.spr0_color, COLOR_WHITE);
103 VIC.spr0_color = COLOR_WHITE;
106 /* Initialize the mouse */
107 mouse_init (MOUSE_CBM1351);
109 #elif defined(__ATARI__)
113 cputs("0 = trak-ball\r\n");
114 cputs("1 = ST mouse\r\n");
115 cputs("2 = Amiga mouse\r\n");
116 cputs("Enter type (0-2): ");
119 } while (type < '0' || type > '2');
122 /* Initialize the mouse */
124 *(unsigned char *)0x2c0 = 15; /* set mouse cursor color (PM0) */
129 /* Print a help line */
131 cputsxy (0, 0, "d: debug h: hide q: quit s: show ");
136 ShowState (Invisible = 1);
144 ShowState (++Invisible);
149 ShowState (--Invisible);
159 /* Get the current mouse coordinates and button states and print them */
162 cprintf ("X = %3d", info.pos.x);
164 cprintf ("Y = %3d", info.pos.y);
166 cprintf ("LB = %c", (info.buttons & MOUSE_BTN_LEFT)? '1' : '0');
168 cprintf ("RB = %c", (info.buttons & MOUSE_BTN_RIGHT)? '1' : '0');
174 cputs ("Goodbye!\r\n");