-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtestloop.c
101 lines (78 loc) · 2.11 KB
/
testloop.c
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*
@Copyright Looking Glass Studios, Inc.
1996,1997,1998,1999,2000 Unpublished Work.
*/
#include <stdlib.h>
#include <config.h>
#include <cfgdbg.h>
#include <loopapi.h>
#include <comtools.h>
#include <appagg.h>
#include <2d.h>
#include <mprintf.h>
#include <mouse.h>
#include <testloop.h>
#include <gamemode.h>
#include <rand.h>
#include <memall.h>
#include <dbmem.h> // must be last header!
void draw_random_stuff(void)
{
short w,h,x,y,c;
// gr_set_canvas(grd_visible_canvas);
w = grd_canvas->bm.w;
h = grd_canvas->bm.h;
x = Rand()%w;
y = Rand()%h;
c = Rand()%256;
// mprintf("Color %d is %d %d %d\n",c,grd_pal[c*3],grd_pal[c*3+1],grd_pal[c*3+2]);
// gr_clear(c);
gr_set_fcolor(c);
gr_box(x,y,x+Rand()%(w-x+1),y+Rand()%(h-y+1));
}
#pragma off(unreferenced)
eLoopMessageResult LGAPI TestLoopFunc(void* context, eLoopMessage msg, tLoopMessageData hdata)
{
static bool spew_num = FALSE;
eLoopMessageResult result = kLoopDispatchContinue;
sLoopFrameInfo* info = (msg & kMsgsFrame) ? (sLoopFrameInfo*)hdata : NULL;
switch(msg)
{
case kMsgEnterMode:
spew_num = config_is_defined("frame_no");
break;
case kMsgBeginFrame:
break;
case kMsgEndFrame:
break;
case kMsgExitMode:
spew_num = FALSE;
break;
case kMsgNormalFrame:
if (spew_num)
mprintf("[%d %d %d]",info->nCount,info->nTicks,info->dTicks);
// if (config_is_defined("rectangles"))
// draw_random_stuff();
break;
}
return result;
}
#pragma off(unreferenced)
ILoopClient* LGAPI CreateTestClient(sLoopClientDesc * pDesc, tLoopClientData data)
{
return CreateSimpleLoopClient(TestLoopFunc,NULL,&TestLoopClientDesc);
}
#pragma on(unreferenced)
sLoopClientDesc TestLoopClientDesc =
{
&LOOPID_Test,
"Test Client",
kPriorityNormal,
kMsgsMode|kMsgsFrame,
kLCF_Callback,
CreateTestClient,
NO_LC_DATA,
{
{kNullConstraint} // terminator
}
};