convert line ends
[canaan.git] / prj / cam / src / shock / shkrloop.cpp
blobdf50dce1af540dbb80a11905adba85b1c0a209ee
1 /*
2 @Copyright Looking Glass Studios, Inc.
3 1996,1997,1998,1999,2000 Unpublished Work.
4 */
6 // $Header: r:/t2repos/thief2/src/shock/shkrloop.cpp,v 1.26 2000/02/19 13:26:07 toml Exp $
8 #include <lg.h>
9 #include <loopapi.h>
10 #include <mprintf.h>
12 #include <objsys.h>
13 #include <osysbase.h>
14 #include <objquery.h>
15 #include <appsfx.h>
17 #include <dispbase.h>
18 #include <loopmsg.h>
19 #include <bugterm.h>
21 #include <simflags.h>
22 #include <simstate.h>
23 #include <simloop.h>
24 #include <shkloop.h>
25 #include <rendloop.h>
26 #include <objloop.h>
27 #include <scrnloop.h>
28 #include <scrnman.h>
29 #include <uiloop.h>
31 #include <shkutils.h>
32 #include <shkgame.h>
33 #include <shkrend.h>
34 #include <mnumprop.h>
36 #include <shkovrly.h>
37 #include <shkrlup2.h>
38 #include <memall.h>
39 #include <dbmem.h> // must be last header!
41 extern BOOL g_lgd3d;
43 /////////////////////////////////////////////////////////////
44 // AIR SIMULATION LOOP CLIENT
45 ////////////////////////////////////////////////////////////
47 //////////////////
48 // CONSTANTS
50 // These are just here to separate out boiler-plate code and leave it untouched
54 #define MY_FACTORY ShockRenderLoopFactory
55 #define MY_GUID LOOPID_ShockRender
57 // My context data
58 typedef void Context;
60 // My state
61 typedef struct _StateRecord
63 Context* context; // a pointer to the context data I got.
64 BOOL initted;
65 // State fields go here
66 } StateRecord;
68 ////////////////////////////////////////
70 // LOOP/DISPATCH callback
71 // Here's where we do the dirty work.
74 #pragma off(unreferenced)
75 static eLoopMessageResult LGAPI _LoopFunc(void* data, eLoopMessage msg, tLoopMessageData hdata)
77 // useful stuff for most clients
78 eLoopMessageResult result = kLoopDispatchContinue;
79 StateRecord* state = (StateRecord*)data;
80 LoopMsg info;
82 info.raw = hdata;
85 switch(msg)
87 case kMsgResumeMode:
88 case kMsgEnterMode:
89 ShockOverlayInit();
90 state->initted = TRUE;
91 break;
92 case kMsgSuspendMode:
93 case kMsgExitMode:
94 if (state->initted)
95 ShockOverlayTerm();
96 state->initted = FALSE;
97 break;
98 break;
100 case kMsgNormalFrame:
101 //gr_pop_canvas(); // from the sub-canvas of before in shkrlup2
102 //gr_close_canvas(&shock_rend_canvas);
103 // a brutal, and godawful hack!
104 // someone kill me now.
106 if (SimStateCheckFlags(kSimRender))
108 ShockOverlayDrawBuffers();
110 ScrnLockDrawCanvas();
112 ShockOverlayDoFrame();
113 if (shock_mouse)
115 extern void ShockDrawCursor(Point pt);
116 Point pt;
117 mouse_get_xy(&pt.x,&pt.y);
118 ShockDrawCursor(pt);
119 //DrawByHandleCenter(gCursorHnd,pt);
122 //air_hud();
124 ScrnUnlockDrawCanvas();
126 // ShockOverlayDrawBuffers();
128 //update_player_medium_sounds();
129 //shock_rend_update_frame();
131 break;
133 case kMsgAppInit:
134 shock_init_object_rend();
135 shock_init_renderer();
136 break;
137 case kMsgAppTerm:
138 shock_term_object_rend();
139 shock_term_renderer();
140 break;
142 case kMsgEnd:
143 Free(state);
144 break;
146 return result;
149 ////////////////////////////////////////////////////////////
150 // Frome here on in is boiler plate code.
151 // Nothing need be changed.
156 // Loop client factory function.
159 #pragma off(unreferenced)
160 static ILoopClient* LGAPI _CreateClient(sLoopClientDesc * desc, tLoopClientData data)
162 StateRecord* state;
163 // allocate space for our state, and fill out the fields
164 state = (StateRecord*)Malloc(sizeof(StateRecord));
165 memset(state,0,sizeof(*state));
166 state->context = (Context*)data;
168 return CreateSimpleLoopClient(_LoopFunc,state,desc);
170 #pragma on(unreferenced)
172 ///////////////
173 // DESCRIPTOR
176 sLoopClientDesc ShockRenderClientDesc =
178 &MY_GUID, // GUID
179 "Shock Rendering", // NAME
180 kPriorityNormal, // PRIORITY
181 kMsgEnd | kMsgsMode | kMsgsFrameMid | kMsgsAppOuter, // INTERESTS
183 kLCF_Callback,
184 _CreateClient,
186 NO_LC_DATA,
189 {kConstrainAfter, &LOOPID_SimFinish, kMsgsFrame},
190 {kConstrainAfter, &LOOPID_Render, kMsgsFrameMid|kMsgsAppOuter},
191 {kConstrainAfter, &LOOPID_RenderBase, kMsgsAppOuter},
192 {kConstrainAfter, &LOOPID_ObjSys, kMsgsAppOuter},
193 {kConstrainAfter, &LOOPID_ScrnMan, kMsgsMode},
194 {kConstrainAfter, &LOOPID_UI, kMsgsMode},
195 {kNullConstraint} // terminator