home *** CD-ROM | disk | FTP | other *** search
- /***************************
- Slide ADT Implementation
- ***************************/
-
- #include "StrangeGlove.h"
- #include "Glove.h"
- #include "RecentADT.h"
-
- #define TOP 12
- #define LEFT 10
-
- extern WindowPtr gADTWindow;
- extern Boolean gShowADT, gUpdateSlide;
-
- static RecentType mySlide;
-
- /***** InitRecent *****/
- void InitRecent()
- {
- int i;
- i = 0;
- while (i < RECENTLENGTH)
- {
- mySlide.Items[i] = 0;
- i++;
- }
- mySlide.Front = 0;
- }
-
-
- /***** AddToRecent *****/
- void AddToRecent(char newItem)
- {
- mySlide.Items[mySlide.Front] = newItem;
- mySlide.Front = ((mySlide.Front + 1) % RECENTLENGTH);
- gUpdateSlide = TRUE;
- }
-
-
- /***** RecentToGlove *****/
- void RecentToGlove(GloveState *s)
- {
- int start;
- short fingers;
-
- /* Set start to position of flag, '\xA0' */
- start = 0;
- while ((start != RECENTLENGTH) && (mySlide.Items[start] != CONT_FLAG))
- start++;
-
- if (start == RECENTLENGTH) /* Error- No Start Flag in Slide */
- s->x = 666;
-
- else /* Transfer data to structure */
- {
- s->x = mySlide.Items[(start + 1) % RECENTLENGTH];
- s->y = mySlide.Items[(start + 2) % RECENTLENGTH];
- s->z = mySlide.Items[(start + 3) % RECENTLENGTH];
- s->rot = mySlide.Items[(start + 4) % RECENTLENGTH];
- fingers = mySlide.Items[(start + 5) % RECENTLENGTH]; /* Mask off individual fingers */
- s->thumb = (fingers & THUMB_MASK) >> 6;
- s->index = (fingers & INDEX_MASK) >> 4;
- s->middle = (fingers & MIDDLE_MASK) >> 2;
- s->ring = (fingers & RING_MASK);
- s->buttons = mySlide.Items[(start + 6) % RECENTLENGTH];
- }
- }
-
-
- /***** OneToGlove *****/
- void OneToGlove(GloveState *s)
- {
- int start;
- short fingers;
-
- start = ((mySlide.Front + 6) % RECENTLENGTH);
-
- s->x = mySlide.Items[(start + 1) % RECENTLENGTH];
- s->y = mySlide.Items[(start + 2) % RECENTLENGTH];
- s->z = mySlide.Items[(start + 3) % RECENTLENGTH];
- s->rot = mySlide.Items[(start + 4) % RECENTLENGTH];
- fingers = mySlide.Items[(start + 5) % RECENTLENGTH]; /* Mask off individual fingers */
- s->thumb = (fingers & THUMB_MASK) >> 6;
- s->index = (fingers & INDEX_MASK) >> 4;
- s->middle = (fingers & MIDDLE_MASK) >> 2;
- s->ring = (fingers & RING_MASK);
- s->buttons = mySlide.Items[(start + 6) % RECENTLENGTH];
- }
-
-
- /***** DumpRecent *****/
- void DumpRecent()
- {
- GrafPtr oldPort;
- int i, j, width;
- Str255 intString;
-
- GetPort(&oldPort);
- SetPort(gADTWindow);
- TextFont(monaco);
-
- EraseRect(&(gADTWindow->portRect));
-
- for (i = 0; i < 12; i++)
- {
- MoveTo(41 + (i * 35), 0);
- LineTo(41 + (i * 35), 30);
- }
- MoveTo(0, 14);
- LineTo(468, 14);
-
- MoveTo(LEFT, TOP);
- for (i = 0; i < RECENTLENGTH; i++) /* Draw as Characters */
- {
- DrawChar(' ');
- DrawChar(' ');
- if (CharWidth(mySlide.Items[(mySlide.Front + i) % RECENTLENGTH]) == 0)
- DrawChar(' ');
- else
- DrawChar(mySlide.Items[(mySlide.Front + i) % RECENTLENGTH]);
- DrawChar(' ');
- DrawChar(' ');
- }
- MoveTo(LEFT, TOP+15); /* Move to Next Line */
- for (i = 0; i < RECENTLENGTH; i++) /* Draw as Integers */
- {
- if (mySlide.Items[(mySlide.Front + i) % RECENTLENGTH] >= 0)
- {
- DrawChar(' ');
- NumToString(mySlide.Items[(mySlide.Front + i) % RECENTLENGTH], &intString);
- }
- else
- {
- DrawChar('-');
- NumToString(-(mySlide.Items[(mySlide.Front + i) % RECENTLENGTH]), &intString);
- }
- width = StringWidth(intString);
- for (j = 0; j < ((21 - width) / 7); j++)
- DrawChar('0');
- DrawString(intString);
- DrawChar(' ');
- }
-
- SetPort(oldPort);
- gUpdateSlide = FALSE;
- }
-
-
- /***** ShowADT *****/
- ShowADT()
- {
- GrafPtr oldPort;
-
- GetPort(&oldPort);
-
- SetPort(gADTWindow);
- gShowADT = TRUE;
- ShowWindow(gADTWindow);
- SelectWindow(gADTWindow);
- AdjustWindowMenu();
-
- SetPort(oldPort);
- }
-
-
- /***** HideADT *****/
- HideADT()
- {
- gShowADT = FALSE;
- HideWindow(gADTWindow);
- AdjustWindowMenu();
- }
-
-
-