summaryrefslogtreecommitdiff
path: root/PropGadgets.c
blob: dbbbd8e29758e462efb8c01bbffd4ddd1888fc82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
#include <proto/dos.h>

#include "Bobi.h"
#include "BobStructure.h"

extern struct MyBob *BobTable[];
extern struct Window *mainwindow;
extern struct Gadget PosPropGadget;
extern struct PropInfo PosPropGadgetSInfo;
extern WORD numbobs,actbobnum;

/*************************************************************************/

void MovePosFunc()
{
	register struct Message *msg;
	register WORD oldnum=-1;

	for(;;)
	{
		WaitTOF();
		if(msg = GetMsg(mainwindow->UserPort))
		{
			ReplyMsg(msg);
			break;
		}
		actbobnum = ReadBobNum();
		if(actbobnum != oldnum)
		{
			ShowFrame(actbobnum);
			/* ShowBob(BobTable[actbobnum]); */
			oldnum = actbobnum;
		}
	}
	actbobnum = ReadBobNum();
	ShowFrame(actbobnum);
}

/*************************************************************************/

WORD ReadBobNum()
{
	return((WORD)((((UWORD)numbobs*PosPropGadgetSInfo.VertPot)+0x7fffL)>>16));
}

/*************************************************************************/

void RefreshBobNum()
{
	PosPropGadgetSInfo.VertBody = 0xffffL/(numbobs+1);
	if(numbobs>0)
	{
		PosPropGadgetSInfo.VertPot  = (actbobnum*0xffffL)/numbobs;
	}
	else PosPropGadgetSInfo.VertPot = 0;

	RefreshGList(&PosPropGadget,mainwindow,0,1);
}