blob: 1e7b5f0182aafd3c5a62599558d0ee0eaca19d80 [file] [log] [blame]
Jason Sams0f505e52009-10-13 17:18:35 -07001#pragma version(1)
2#pragma stateVertex(PV)
3#pragma stateFragment(PFTexLinear)
4#pragma stateStore(PSIcons)
5
6#define PI 3.14159f
7
Jason Sams41b61c82009-10-15 15:40:54 -07008int g_SpecialHWWar;
Jason Sams0f505e52009-10-13 17:18:35 -07009
10// Attraction to center values from page edge to page center.
11float g_AttractionTable[9];
Jason Sams2e19c052009-10-20 18:19:55 -070012float g_FrictionTable[9];
Jason Sams0f505e52009-10-13 17:18:35 -070013float g_PhysicsTableSize;
14
15float g_PosPage;
16float g_PosVelocity;
17float g_LastPositionX;
18int g_LastTouchDown;
19float g_DT;
20int g_LastTime;
21int g_PosMax;
22float g_Zoom;
23float g_OldPosPage;
24float g_OldPosVelocity;
25float g_OldZoom;
Jason Samsc1c521e2009-10-19 14:45:45 -070026float g_MoveToTotalTime;
27float g_MoveToTime;
28float g_MoveToOldPos;
29
Jason Sams0f505e52009-10-13 17:18:35 -070030
31// Drawing constants, should be parameters ======
32#define VIEW_ANGLE 1.28700222f
33
34int g_DrawLastFrame;
35int lastFrame(int draw) {
36 // We draw one extra frame to work around the last frame post bug.
37 // We also need to track if we drew the last frame to deal with large DT
38 // in the physics.
39 int ret = g_DrawLastFrame | draw;
40 g_DrawLastFrame = draw;
41 return ret; // should return draw instead.
42}
43
44void updateReadback() {
45 if ((g_OldPosPage != g_PosPage) ||
46 (g_OldPosVelocity != g_PosVelocity) ||
47 (g_OldZoom != g_Zoom)) {
48
49 g_OldPosPage = g_PosPage;
50 g_OldPosVelocity = g_PosVelocity;
51 g_OldZoom = g_Zoom;
52
53 int i[3];
54 i[0] = g_PosPage * (1 << 16);
55 i[1] = g_PosVelocity * (1 << 16);
56 i[2] = g_OldZoom * (1 << 16);
57 sendToClient(&i[0], 1, 12, 1);
58 }
59}
60
Jason Sams41b61c82009-10-15 15:40:54 -070061void setColor(float r, float g, float b, float a) {
62 if (g_SpecialHWWar) {
63 color(0, 0, 0, 0.001f);
64 } else {
65 color(r, g, b, a);
66 }
67}
Jason Sams0f505e52009-10-13 17:18:35 -070068
69void init() {
Jason Sams2e19c052009-10-20 18:19:55 -070070 g_AttractionTable[0] = 20.0f;
71 g_AttractionTable[1] = 20.0f;
72 g_AttractionTable[2] = 15.0f;
73 g_AttractionTable[3] = 10.0f;
74 g_AttractionTable[4] = -10.0f;
75 g_AttractionTable[5] = -15.0f;
76 g_AttractionTable[6] = -15.0f;
77 g_AttractionTable[7] = -20.0f;
78 g_AttractionTable[8] = -20.0f; // dup 7 to avoid a clamp later
79 g_FrictionTable[0] = 10.0f;
80 g_FrictionTable[1] = 10.0f;
81 g_FrictionTable[2] = 11.0f;
82 g_FrictionTable[3] = 15.0f;
83 g_FrictionTable[4] = 15.0f;
84 g_FrictionTable[5] = 11.0f;
85 g_FrictionTable[6] = 10.0f;
86 g_FrictionTable[7] = 10.0f;
87 g_FrictionTable[8] = 10.0f; // dup 7 to avoid a clamp later
Jason Sams0f505e52009-10-13 17:18:35 -070088 g_PhysicsTableSize = 7;
89
90 g_PosVelocity = 0;
91 g_PosPage = 0;
92 g_LastTouchDown = 0;
93 g_LastPositionX = 0;
94 g_Zoom = 0;
Jason Sams41b61c82009-10-15 15:40:54 -070095 g_SpecialHWWar = 1;
Jason Samsc1c521e2009-10-19 14:45:45 -070096 g_MoveToTime = 0;
97 g_MoveToOldPos = 0;
Mike Cleron7d5d7462009-10-20 14:06:00 -070098 g_MoveToTotalTime = 0.2f; // Duration of scrolling 1 line
Jason Sams41b61c82009-10-15 15:40:54 -070099}
100
101void resetHWWar() {
102 g_SpecialHWWar = 1;
Jason Sams0f505e52009-10-13 17:18:35 -0700103}
104
105void move() {
106 if (g_LastTouchDown) {
107 float dx = -(state->newPositionX - g_LastPositionX);
108 g_PosVelocity = 0;
109 g_PosPage += dx * 4;
110
111 float pmin = -0.25f;
112 float pmax = g_PosMax + 0.25f;
113 g_PosPage = clampf(g_PosPage, pmin, pmax);
114 }
115 g_LastTouchDown = state->newTouchDown;
116 g_LastPositionX = state->newPositionX;
Jason Samsc1c521e2009-10-19 14:45:45 -0700117 g_MoveToTime = 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700118 //debugF("Move P", g_PosPage);
119}
120
Jason Samsc1c521e2009-10-19 14:45:45 -0700121void moveTo() {
122 g_MoveToTime = g_MoveToTotalTime;
123 g_PosVelocity = 0;
124 g_MoveToOldPos = g_PosPage;
Jason Sams2e19c052009-10-20 18:19:55 -0700125
Mike Cleron7d5d7462009-10-20 14:06:00 -0700126 // debugF("======= moveTo", state->targetPos);
Jason Samsc1c521e2009-10-19 14:45:45 -0700127}
128
Jason Sams0f505e52009-10-13 17:18:35 -0700129void fling() {
130 g_LastTouchDown = 0;
Jason Sams37e7c2b2009-10-19 12:55:43 -0700131 g_PosVelocity = -state->flingVelocity * 4;
Jason Sams0f505e52009-10-13 17:18:35 -0700132 float av = fabsf(g_PosVelocity);
133 float minVel = 3.5f;
134
135 minVel *= 1.f - (fabsf(fracf(g_PosPage + 0.5f) - 0.5f) * 0.45f);
136
137 if (av < minVel && av > 0.2f) {
138 if (g_PosVelocity > 0) {
139 g_PosVelocity = minVel;
140 } else {
141 g_PosVelocity = -minVel;
142 }
143 }
144
145 if (g_PosPage <= 0) {
146 g_PosVelocity = maxf(0, g_PosVelocity);
147 }
148 if (g_PosPage > g_PosMax) {
149 g_PosVelocity = minf(0, g_PosVelocity);
150 }
151}
152
Jason Sams0f505e52009-10-13 17:18:35 -0700153float
154modf(float x, float y)
155{
156 return x-(y*floorf(x/y));
157}
158
Mike Cleron7d5d7462009-10-20 14:06:00 -0700159
160/*
161 * Interpolates values in the range 0..1 to a curve that eases in
162 * and out.
163 */
164float
165getInterpolation(float input) {
166 return (cosf((input + 1) * PI) / 2.0f) + 0.5f;
167}
168
169
Jason Sams0f505e52009-10-13 17:18:35 -0700170void updatePos() {
171 if (g_LastTouchDown) {
172 return;
173 }
174
175 int outOfRange = 0;
176 float tablePosNorm = fracf(g_PosPage + 0.5f);
177 float tablePosF = tablePosNorm * g_PhysicsTableSize;
178 int tablePosI = tablePosF;
179 float tablePosFrac = tablePosF - tablePosI;
180 float accel = lerpf(g_AttractionTable[tablePosI],
181 g_AttractionTable[tablePosI + 1],
182 tablePosFrac) * g_DT;
Jason Sams2e19c052009-10-20 18:19:55 -0700183 float friction = lerpf(g_FrictionTable[tablePosI],
184 g_FrictionTable[tablePosI + 1],
185 tablePosFrac) * g_DT;
Jason Sams0f505e52009-10-13 17:18:35 -0700186
Jason Samsc1c521e2009-10-19 14:45:45 -0700187 if (g_MoveToTime) {
Jason Sams2e19c052009-10-20 18:19:55 -0700188
Mike Cleron7d5d7462009-10-20 14:06:00 -0700189 /*
Jason Samsc1c521e2009-10-19 14:45:45 -0700190 float a = 2.f * (state->targetPos - g_MoveToOldPos) /
191 (g_MoveToTotalTime * g_MoveToTotalTime);
192 if (g_MoveToTime > (g_MoveToTotalTime * 0.5f)) {
193 // slowing
194 g_PosPage = state->targetPos - 0.5f * a * (g_MoveToTime * g_MoveToTime);
195 } else {
196 // accelerating.
197 float t = g_MoveToTotalTime - g_MoveToTime;
198 g_PosPage = g_MoveToOldPos + 0.5f * a * (t * t);
199 }
Mike Cleron7d5d7462009-10-20 14:06:00 -0700200 */
Jason Sams2e19c052009-10-20 18:19:55 -0700201
Mike Cleron7d5d7462009-10-20 14:06:00 -0700202 // New position is old posiition + (total distance) * (interpolated time)
203 g_PosPage = g_MoveToOldPos + (state->targetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime);
Jason Sams2e19c052009-10-20 18:19:55 -0700204
Jason Samsc1c521e2009-10-19 14:45:45 -0700205 g_MoveToTime -= g_DT;
206 if (g_MoveToTime <= 0) {
207 g_MoveToTime = 0;
208 g_PosPage = state->targetPos;
209 }
210 return;
211 }
212
Jason Sams0f505e52009-10-13 17:18:35 -0700213 if (g_PosPage < -0.5f) {
214 accel = g_AttractionTable[0] * g_DT;
Jason Sams0f505e52009-10-13 17:18:35 -0700215 outOfRange = 1;
216 }
217 if ((g_PosPage - g_PosMax) > 0.5f) {
218 accel = g_AttractionTable[(int)g_PhysicsTableSize] * g_DT;
Jason Sams0f505e52009-10-13 17:18:35 -0700219 outOfRange = 1;
220 }
221
222 // If our velocity is low OR acceleration is opposing it, apply it.
Jason Sams2e19c052009-10-20 18:19:55 -0700223 if (fabsf(g_PosVelocity) < 2.5f || (g_PosVelocity * accel) < 0 || outOfRange) {
Jason Sams0f505e52009-10-13 17:18:35 -0700224 g_PosVelocity += accel;
225 }
226
227 if ((friction > fabsf(g_PosVelocity)) &&
228 (friction > fabsf(accel)) &&
229 !outOfRange) {
230 // Special get back to center and overcome friction physics.
231 float t = tablePosNorm - 0.5f;
232 if (fabsf(t) < (friction * g_DT)) {
233 // really close, just snap
234 g_PosPage = roundf(g_PosPage);
235 g_PosVelocity = 0;
236 } else {
237 if (t > 0) {
238 g_PosVelocity = -friction;
239 } else {
240 g_PosVelocity = friction;
241 }
242 }
243 } else {
244 // Normal physics
245 if (g_PosVelocity > 0) {
246 g_PosVelocity -= friction;
247 g_PosVelocity = maxf(g_PosVelocity, 0);
248 } else {
249 g_PosVelocity += friction;
250 g_PosVelocity = minf(g_PosVelocity, 0);
251 }
252 }
253 g_PosPage += g_PosVelocity * g_DT;
254
255 // Check for out of boundry conditions.
256 if (g_PosPage < 0 && g_PosVelocity < 0) {
257 g_PosPage = maxf(g_PosPage, -0.49);
258 float damp = 1.0 + (g_PosPage * 4);
259 damp = clampf(damp, 0.f, 0.9f);
260 g_PosVelocity *= damp;
261 }
262 if (g_PosPage > g_PosMax && g_PosVelocity > 0) {
263 g_PosPage = minf(g_PosPage, g_PosMax + 0.49);
264 float damp = 1.0 - ((g_PosPage - g_PosMax) * 4);
265 damp = clampf(damp, 0.f, 0.9f);
266 g_PosVelocity *= damp;
267 }
268}
269
Jason Sams09c6fc02009-10-16 17:23:23 -0700270int positionStrip(float row, float column, int isTop, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700271{
272 float mat1[16];
Jason Sams0f505e52009-10-13 17:18:35 -0700273 float x = 0.5f * (column - 1.5f);
Jason Sams0f505e52009-10-13 17:18:35 -0700274 float scale = 72.f * 3 / getWidth();
Jason Sams0f505e52009-10-13 17:18:35 -0700275
276 if (isTop) {
277 matrixLoadTranslate(mat1, x, 0.8f, 0.f);
278 matrixScale(mat1, scale, scale, 1.f);
279 } else {
280 matrixLoadTranslate(mat1, x, -0.9f, 0.f);
281 matrixScale(mat1, scale, -scale, 1.f);
282 }
Jason Sams461073b2009-10-20 12:06:28 -0700283 matrixTranslate(mat1, 0, p * 2, 0.f);
284 matrixRotate(mat1, -p * 50, 1, 0, 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700285 vpLoadModelMatrix(mat1);
286
Jason Samsb52dfa02009-10-14 20:16:14 -0700287 float soff = -(row * 1.4);
Jason Sams0f505e52009-10-13 17:18:35 -0700288 if (isTop) {
289 matrixLoadScale(mat1, 1.f, -0.85f, 1.f);
Jason Samsb52dfa02009-10-14 20:16:14 -0700290 matrixTranslate(mat1, 0, soff - 0.97f, 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700291 } else {
292 matrixLoadScale(mat1, 1.f, 0.85f, 1.f);
Jason Samsb52dfa02009-10-14 20:16:14 -0700293 matrixTranslate(mat1, 0, soff - 0.45f, 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700294 }
295 vpLoadTextureMatrix(mat1);
Jason Samsb52dfa02009-10-14 20:16:14 -0700296 return -soff * 10.f;
Jason Sams0f505e52009-10-13 17:18:35 -0700297}
298
299void
300draw_home_button()
301{
Jason Sams41b61c82009-10-15 15:40:54 -0700302 setColor(1.0f, 1.0f, 1.0f, 1.0f);
Joe Onoratod63458b2009-10-15 21:19:09 -0700303 bindTexture(NAMED_PFTexLinear, 0, state->homeButtonId);
Jason Sams96b49d82009-10-20 14:28:53 -0700304 float x = (SCREEN_WIDTH_PX - params->homeButtonTextureWidth) / 2;
305 float y = (g_Zoom - 1.f) * params->homeButtonTextureHeight;
Jason Sams0f505e52009-10-13 17:18:35 -0700306
Jason Sams96b49d82009-10-20 14:28:53 -0700307 y -= 36; // move the house to the edge of the screen as it doesn't fill the texture.
308 drawSpriteScreenspace(x, y, 0, params->homeButtonTextureWidth, params->homeButtonTextureHeight);
Jason Sams0f505e52009-10-13 17:18:35 -0700309}
310
Jason Sams09c6fc02009-10-16 17:23:23 -0700311void drawFrontGrid(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700312{
313 float h = getHeight();
314 float w = getWidth();
315
316 int intRowOffset = rowOffset;
317 float rowFrac = rowOffset - intRowOffset;
318 float colWidth = getWidth() / 4;
319 float rowHeight = colWidth + 25.f;
320 float yoff = h - ((h - (rowHeight * 4.f)) / 2);
321
322 yoff -= 110;
323
324 int row, col;
325 int iconNum = intRowOffset * 4;
326 float ymax = yoff;
327 float ymin = yoff - (3 * rowHeight) - 70;
328
329 for (row = 0; row < 5; row++) {
330 float y = yoff - ((-rowFrac + row) * rowHeight);
331
332 for (col=0; col < 4; col++) {
333 if (iconNum >= state->iconCount) {
334 return;
335 }
336
337 if (iconNum >= 0) {
338 float x = colWidth * col - ((128 - colWidth) / 2);
339
340 if ((y >= ymin) && (y <= ymax)) {
Jason Sams41b61c82009-10-15 15:40:54 -0700341 setColor(1.f, 1.f, 1.f, 1.f);
Joe Onorato742d7fc2009-10-15 19:48:16 -0700342
Jason Sams09c6fc02009-10-16 17:23:23 -0700343 if (state->selectedIconIndex == iconNum && !p) {
Joe Onorato742d7fc2009-10-15 19:48:16 -0700344 bindTexture(NAMED_PFTexLinear, 0, state->selectedIconTexture);
345 drawSpriteScreenspace(x, y, 0, 128, 128);
346 }
347
Jason Sams0f505e52009-10-13 17:18:35 -0700348 bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_ICON_IDS, iconNum));
Jason Sams09c6fc02009-10-16 17:23:23 -0700349 if (!p) {
350 drawSpriteScreenspace(x, y, 0, 128, 128);
351 } else {
352 float px = ((x + 64) - (getWidth() / 2)) / (getWidth() / 2);
353 float py = ((y + 64) - (getHeight() / 2)) / (getWidth() / 2);
354 float d = 64.f / (getWidth() / 2);
355 px *= p + 1;
356 py *= p + 1;
357 drawQuadTexCoords(px - d, py - d, -p, 0, 1,
358 px - d, py + d, -p, 0, 0,
359 px + d, py + d, -p, 1, 0,
360 px + d, py - d, -p, 1, 1);
361 }
Jason Sams0f505e52009-10-13 17:18:35 -0700362 }
363
364 float y2 = y - 44;
365 float a = 1.f;
366 if (y2 < ymin) {
367 a = 1.f - (ymin - y2) * 0.02f;
368 }
369 if (y > (ymax + 40)) {
370 a = 1.f - (y - (ymax + 40)) * 0.02f;
371 }
372 a = clampf(a, 0, 1);
Jason Sams09c6fc02009-10-16 17:23:23 -0700373 a *= maxf(0, 1.f - p * 5.f);
Jason Sams0f505e52009-10-13 17:18:35 -0700374
Jason Sams41b61c82009-10-15 15:40:54 -0700375 setColor(1, 1, 1, a);
Jason Sams0f505e52009-10-13 17:18:35 -0700376 bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_LABEL_IDS, iconNum));
377 drawSpriteScreenspace(x, y - 44, 0,
378 params->bubbleBitmapWidth, params->bubbleBitmapHeight);
379 }
380 iconNum++;
381 }
382 }
383}
384
Jason Sams09c6fc02009-10-16 17:23:23 -0700385void drawStrip(float row, float column, int isTop, int iconNum, float p)
Jason Samsb52dfa02009-10-14 20:16:14 -0700386{
387 if (iconNum < 0) return;
Jason Sams09c6fc02009-10-16 17:23:23 -0700388 int offset = positionStrip(row, column, isTop, p);
Jason Samsb52dfa02009-10-14 20:16:14 -0700389 bindTexture(NAMED_PFTexLinear, 0, loadI32(ALLOC_ICON_IDS, iconNum));
390 if (offset < -20) return;
391 offset = clamp(offset, 0, 199 - 20);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700392 drawSimpleMeshRange(NAMED_SMMesh, offset * 6, 20 * 6);
Jason Samsb52dfa02009-10-14 20:16:14 -0700393}
394
Jason Sams461073b2009-10-20 12:06:28 -0700395void drawTop(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700396{
Jason Sams0f505e52009-10-13 17:18:35 -0700397 int row, col;
398 int iconNum = 0;
399 for (row = 0; row < rowOffset; row++) {
400 for (col=0; col < 4; col++) {
401 if (iconNum >= state->iconCount) {
402 return;
403 }
Jason Sams461073b2009-10-20 12:06:28 -0700404 drawStrip(rowOffset - row, col, 1, iconNum, p);
Jason Sams0f505e52009-10-13 17:18:35 -0700405 iconNum++;
406 }
407 }
408}
409
Jason Sams09c6fc02009-10-16 17:23:23 -0700410void drawBottom(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700411{
412 float pos = -1.f;
413 int intRowOffset = rowOffset;
414 pos -= rowOffset - intRowOffset;
415
416 int row, col;
417 int iconNum = (intRowOffset + 3) * 4;
418 while (1) {
419 for (col=0; col < 4; col++) {
420 if (iconNum >= state->iconCount) {
421 return;
422 }
423 if (pos > -1) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700424 drawStrip(pos, col, 0, iconNum, p);
Jason Sams0f505e52009-10-13 17:18:35 -0700425 }
426 iconNum++;
427 }
428 pos += 1.f;
429 }
430}
431
432int
433main(int launchID)
434{
435 // Compute dt in seconds.
436 int newTime = uptimeMillis();
437 g_DT = (newTime - g_LastTime) / 1000.f;
438 g_LastTime = newTime;
Jason Sams2e19c052009-10-20 18:19:55 -0700439
Jason Sams0f505e52009-10-13 17:18:35 -0700440 if (!g_DrawLastFrame) {
441 // If we stopped rendering we cannot use DT.
442 // assume 30fps in this case.
443 g_DT = 0.033f;
444 }
Jason Samsb52dfa02009-10-14 20:16:14 -0700445 // physics may break if DT is large.
446 g_DT = minf(g_DT, 0.2f);
Jason Sams0f505e52009-10-13 17:18:35 -0700447
448 if (g_Zoom != state->zoomTarget) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700449 float dz;
450 if (state->zoomTarget > 0.5f) {
451 dz = (1 - g_Zoom) * 0.2f;
452 } else {
453 dz = -g_DT - (1 - g_Zoom) * 0.2f;
454 }
455 if (dz && (fabsf(dz) < 0.02f)) {
Jason Sams0f505e52009-10-13 17:18:35 -0700456 if (dz > 0) {
Jason Sams09c6fc02009-10-16 17:23:23 -0700457 dz = 0.02f;
Jason Sams0f505e52009-10-13 17:18:35 -0700458 } else {
Jason Sams09c6fc02009-10-16 17:23:23 -0700459 dz = -0.02f;
Jason Sams0f505e52009-10-13 17:18:35 -0700460 }
461 }
462 if (fabsf(g_Zoom - state->zoomTarget) < fabsf(dz)) {
463 g_Zoom = state->zoomTarget;
464 } else {
465 g_Zoom += dz;
466 }
467 updateReadback();
468 }
469
470 // Set clear value to dim the background based on the zoom position.
Jason Sams41b61c82009-10-15 15:40:54 -0700471 if ((g_Zoom < 0.001f) && (state->zoomTarget < 0.001f) && !g_SpecialHWWar) {
Jason Sams0f505e52009-10-13 17:18:35 -0700472 pfClearColor(0.0f, 0.0f, 0.0f, 0.0f);
473 // When we're zoomed out and not tracking motion events, reset the pos to 0.
474 if (!g_LastTouchDown) {
475 g_PosPage = 0;
476 }
477 return lastFrame(0);
Jason Sams0f505e52009-10-13 17:18:35 -0700478 } else {
479 pfClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
480 }
481
482 // icons & labels
483 int iconCount = state->iconCount;
484 g_PosMax = ((iconCount + 3) / 4) - 4;
485 if (g_PosMax < 0) g_PosMax = 0;
486
487 updatePos(0.1f);
488 updateReadback();
489
490 //debugF(" draw g_PosPage", g_PosPage);
491
492 // Draw the icons ========================================
493
494 //bindProgramFragment(NAMED_PFColor);
495 //positionStrip(1, 0, 0);
Jason Sams37e7c2b2009-10-19 12:55:43 -0700496 //drawSimpleMesh(NAMED_SMMesh);
Jason Sams0f505e52009-10-13 17:18:35 -0700497
498 bindProgramFragment(NAMED_PFTexLinear);
499
500
Jason Sams461073b2009-10-20 12:06:28 -0700501 drawTop(g_PosPage, 1-g_Zoom);
Jason Sams09c6fc02009-10-16 17:23:23 -0700502 drawBottom(g_PosPage, 1-g_Zoom);
Jason Sams0f505e52009-10-13 17:18:35 -0700503
504 {
505 float mat1[16];
506 matrixLoadIdentity(mat1);
507 vpLoadModelMatrix(mat1);
508 vpLoadTextureMatrix(mat1);
509 }
Jason Sams09c6fc02009-10-16 17:23:23 -0700510 drawFrontGrid(g_PosPage, 1-g_Zoom);
Jason Samsb52dfa02009-10-14 20:16:14 -0700511 draw_home_button();
Jason Sams0f505e52009-10-13 17:18:35 -0700512
Jason Sams41b61c82009-10-15 15:40:54 -0700513
514 // This is a WAR to do a rendering pass without drawing during init to
515 // force the driver to preload and compile its shaders.
516 // Without this the first animation does not appear due to the time it
517 // takes to init the driver state.
518 if (g_SpecialHWWar) {
519 g_SpecialHWWar = 0;
520 return 1;
521 }
522
Jason Sams0f505e52009-10-13 17:18:35 -0700523 // Bug workaround where the last frame is not always displayed
524 // So we keep rendering until the bug is fixed.
Mike Cleron7d5d7462009-10-20 14:06:00 -0700525 return lastFrame((g_PosVelocity != 0) || fracf(g_PosPage) || g_Zoom != state->zoomTarget || (g_MoveToTime != 0));
Jason Sams0f505e52009-10-13 17:18:35 -0700526}
527