home *** CD-ROM | disk | FTP | other *** search
- /* event.c */
- /* */
- /* Okay, this is handleevent(): If I call it with a pointer to an */
- /* IntuiMessage structure, the events in which I have an interest get */
- /* processed and the proper functions are called. */
- /* Please note that for a quick reply to an Intuition message, I will */
- /* deal with a copy of the original IntuiMessage, so even if I don't */
- /* respond to that message very quicly, Intuition won't eat away at my */
- /* free memory (for more infos see the PROGRAMMER'S GUIDE TO THE AMIGA */
- /* by Robert A. Peck, SYBEX 1987.) */
-
- handleevent(ms)
- struct IntuiMessage *ms;
- {
- struct IntuiMessage localms; /* Our private copy of ms */
- int i, result;
- UBYTE *s, *d;
-
- s = (UBYTE *)ms; /* Point to the original ms */
- d = (UBYTE *)&localms; /* Point to destination */
-
- for (i = 0; i < sizeof(struct IntuiMessage); i++)
- *d++ = *s++;
-
- ReplyMsg(ms); /* Reply to the original ms */
-
-
-
- /* Okay, from now on I'll work only with this private copy of the */
- /* original IntuiMessage... */
-
-
-
- switch(localms.Class)
- {
- case MOUSEBUTTONS:
- result = mousebuttons(&localms);
- break;
- case GADGETUP:
- result = gadgetup(&localms);
- break;
- case MENUPICK:
- result = menupick(&localms);
- break;
- default:
- break;
- }
- return(result);
- }
-
- mousebuttons(ms)
- struct IntuiMessage *ms;
- {
- extern int selectbutton;
- extern int currentmousex;
- extern int currentmousey;
-
- if (ms -> Code == SELECTDOWN)
- {
- selectbutton = TRUE;
- currentmousex = ms -> MouseX;
- currentmousey = ms -> MouseY;
- return(DUMMY_VALUE);
- }
-
- if (ms -> Code == SELECTUP)
- {
- selectbutton = FALSE;
- return(DUMMY_VALUE);
- }
-
- return(DUMMY_VALUE);
- }
-
-
-
- gadgetup(ms)
- struct IntuiMessage *ms;
- {
- extern struct Window *w;
- extern struct RastPort *rp;
- extern int score1, score2;
- extern int turn1, turn2;
- extern int peek1, peek2;
- extern int movingplayer;
- extern int peektime;
- extern int percentage;
- extern int calling;
-
- struct Gadget *g;
- int id;
- int result;
-
- g = (struct Gadget *)(ms -> IAddress);
- id = g -> GadgetID;
-
- switch(id)
- {
- case 1:
- result = PICKED_NAAH;
- break;
- case 2:
- result = PICKED_YEAH;
- if(calling == 1)
- {
- percentage += 10;
-
- OffMenu(w, 0x3f00); /* Menu 0: all */
- OffMenu(w, 0x3f01); /* Menu 1: all */
- OffMenu(w, 0x3f02); /* Menu 2: all */
- OffMenu(w, 0x3f03); /* Menu 3: all */
-
- writestring(rp, PICK_FIRST_STRING, FALSE);
- displaycards(TRUE); /* Display all cards */
- writestring(rp, PEEK_STRING, COLOR3);
- Delay(50 * peektime); /* Wait... */
- writestring(rp, PEEK_STRING, FALSE);
- if (movingplayer == 1)
- {
- peek1 += 1;
- score1 -= (score1 * 25 / 100);
- update(FIRST, turn1, score1);
- writestring(rp, PICK_FIRST_STRING, COLOR1);
- }
- else
- {
- peek2 += 1;
- score2 -= (score2 * 25 / 100);
- update(SECOND, turn2, score2);
- writestring(rp, PICK_FIRST_STRING, COLOR2);
- }
-
- OnMenu(w, 0x3f00); /* Re-enable Menu 0 */
- OnMenu(w, 0x3f01); /* Re-enable Menu 1 */
- OffMenu(w, 0x0001); /* Except Item 0! */
- OnMenu(w, 0x0021); /* Now enable Menu 1: Item 1 */
- OnMenu(w, 0x0041); /* Now enable Menu 1: Item 2 */
- displaycards(FALSE); /* Cover all cards */
- }
- if(calling == 2)
- {
- SetRast(rp, 6);
-
- OnMenu(w, 0x0001); /* Menu 1: Item 0 */
- OnMenu(w, 0x3f02); /* Menu 2: all */
- OnMenu(w, 0x3f03); /* Menu 3: all */
-
- OffMenu(w, 0x0021); /* Disable Menu 1 - Item 1 */
- OffMenu(w, 0x0041); /* Disable Menu 1 - Item 2 */
-
- result = PICKED_QUIT;
- }
- if (calling == 3)
- {
- cleanup();
- exit(0);
- }
- break;
- case 3:
- result = PICKED_CLICK;
- break;
- default:
- break;
- }
- return(result);
- }
-