blob: a9727fb95c63dbd05e925254aab15be92dd613e7 [file] [log] [blame]
Jason Sams0f505e52009-10-13 17:18:35 -07001#pragma version(1)
Jason Sams14f67ed2010-05-11 14:02:43 -07002
Shih-wei Liaoc8149652010-06-14 11:46:11 -07003#pragma rs java_package_name(com.android.launcher2)
4
Shih-wei Liaoafb81d42010-07-19 16:20:03 -07005#include "rs_graphics.rsh"
Jason Sams0f505e52009-10-13 17:18:35 -07006
7#define PI 3.14159f
8
Jason Sams14f67ed2010-05-11 14:02:43 -07009// Constants from Java
10int COLUMNS_PER_PAGE_PORTRAIT;
11int ROWS_PER_PAGE_PORTRAIT;
12int COLUMNS_PER_PAGE_LANDSCAPE;
13int ROWS_PER_PAGE_LANDSCAPE;
14
Jason Sams14f67ed2010-05-11 14:02:43 -070015int gIconCount;
Jason Sams1aa4ff02010-06-15 14:59:57 -070016int gSelectedIconIndex = -1;
Jason Sams14f67ed2010-05-11 14:02:43 -070017rs_allocation gSelectedIconTexture;
Jason Sams14f67ed2010-05-11 14:02:43 -070018rs_allocation gHomeButton;
Jason Sams14f67ed2010-05-11 14:02:43 -070019
20rs_program_fragment gPFTexNearest;
21rs_program_fragment gPFTexMip;
22rs_program_fragment gPFTexMipAlpha;
23rs_program_vertex gPVCurve;
24rs_program_store gPS;
25rs_mesh gSMCell;
26
27rs_allocation *gIconIDs;
28rs_allocation *gLabelIDs;
29
Jason Sams1aa4ff02010-06-15 14:59:57 -070030typedef struct VpConsts {
Alex Sakhartchouk95252b42010-09-13 20:44:01 -070031 rs_matrix4x4 Proj;
Jason Sams14f67ed2010-05-11 14:02:43 -070032 float4 Position;
33 float4 ScaleOffset;
34 float2 BendPos;
35 float2 ImgSize;
36} VpConsts_t;
37VpConsts_t *vpConstants;
38
39
Jason Sams60a55bb2010-06-18 15:11:19 -070040#pragma rs export_func(move, moveTo, setZoom, fling)
Jason Sams14f67ed2010-05-11 14:02:43 -070041
Jason Sams0f505e52009-10-13 17:18:35 -070042
43// Attraction to center values from page edge to page center.
Jason Samsad1bdf02010-05-14 17:54:50 -070044static float g_AttractionTable[9] = {20.f, 20.f, 20.f, 10.f, -10.f, -20.f, -20.f, -20.f, -20.f};
45static float g_FrictionTable[9] = {10.f, 10.f, 11.f, 15.f, 15.f, 11.f, 10.f, 10.f, 10.f};
46static float g_PhysicsTableSize = 7;
Jason Sams0f505e52009-10-13 17:18:35 -070047
Jason Sams60a55bb2010-06-18 15:11:19 -070048static float gZoomTarget;
Stephen Hinesb02af382010-10-08 15:52:00 -070049float gTargetPos;
Jason Samsad1bdf02010-05-14 17:54:50 -070050static float g_PosPage = 0.f;
51static float g_PosVelocity = 0.f;
52static float g_LastPositionX = 0.f;
Jason Sams60a55bb2010-06-18 15:11:19 -070053static bool g_LastTouchDown = false;
Jason Sams14f67ed2010-05-11 14:02:43 -070054static float g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -070055static int g_PosMax;
Jason Samsad1bdf02010-05-14 17:54:50 -070056static float g_Zoom = 0.f;
57static float g_Animation = 1.f;
Jason Sams14f67ed2010-05-11 14:02:43 -070058static float g_OldPosPage;
59static float g_OldPosVelocity;
60static float g_OldZoom;
Jason Samsad1bdf02010-05-14 17:54:50 -070061static float g_MoveToTotalTime = 0.2f;
62static float g_MoveToTime = 0.f;
63static float g_MoveToOldPos = 0.f;
Jason Samsc1c521e2009-10-19 14:45:45 -070064
Jason Sams14f67ed2010-05-11 14:02:43 -070065static int g_Cols;
66static int g_Rows;
Jason Sams0f505e52009-10-13 17:18:35 -070067
Alex Sakhartchouk95252b42010-09-13 20:44:01 -070068rs_allocation g_VPConstAlloc;
69
Jason Sams0f505e52009-10-13 17:18:35 -070070// Drawing constants, should be parameters ======
71#define VIEW_ANGLE 1.28700222f
72
Jason Sams0f505e52009-10-13 17:18:35 -070073
Jason Sams14f67ed2010-05-11 14:02:43 -070074static void updateReadback() {
Jason Samsad1bdf02010-05-14 17:54:50 -070075 if ((g_OldPosPage != g_PosPage) ||
76 (g_OldPosVelocity != g_PosVelocity) ||
77 (g_OldZoom != g_Zoom)) {
Jason Sams0f505e52009-10-13 17:18:35 -070078
79 g_OldPosPage = g_PosPage;
80 g_OldPosVelocity = g_PosVelocity;
81 g_OldZoom = g_Zoom;
82
83 int i[3];
84 i[0] = g_PosPage * (1 << 16);
85 i[1] = g_PosVelocity * (1 << 16);
86 i[2] = g_OldZoom * (1 << 16);
Jason Sams500d36e2010-07-28 11:15:33 -070087 rsSendToClientBlocking(1, &i[0], sizeof(i));
Jason Samsad1bdf02010-05-14 17:54:50 -070088 }
Jason Sams0f505e52009-10-13 17:18:35 -070089}
90
Jason Sams0f505e52009-10-13 17:18:35 -070091void init() {
Jason Sams41b61c82009-10-15 15:40:54 -070092}
Jason Sams0f505e52009-10-13 17:18:35 -070093
Jason Sams60a55bb2010-06-18 15:11:19 -070094void move(float newPos) {
Jason Sams0f505e52009-10-13 17:18:35 -070095 if (g_LastTouchDown) {
Jason Sams60a55bb2010-06-18 15:11:19 -070096 float dx = -(newPos - g_LastPositionX);
Jason Sams0f505e52009-10-13 17:18:35 -070097 g_PosVelocity = 0;
Jason Sams6ec11bc2010-01-19 17:56:52 -080098 g_PosPage += dx * 5.2f;
Jason Sams0f505e52009-10-13 17:18:35 -070099
Jason Samsc8514792009-10-29 14:27:29 -0700100 float pmin = -0.49f;
101 float pmax = g_PosMax + 0.49f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700102 g_PosPage = clamp(g_PosPage, pmin, pmax);
Jason Sams0f505e52009-10-13 17:18:35 -0700103 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700104 g_LastTouchDown = true;
105 g_LastPositionX = newPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700106 g_MoveToTime = 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700107}
108
Jason Sams60a55bb2010-06-18 15:11:19 -0700109void moveTo(float targetPos) {
110 gTargetPos = targetPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700111 g_MoveToTime = g_MoveToTotalTime;
112 g_PosVelocity = 0;
113 g_MoveToOldPos = g_PosPage;
114}
115
Jason Sams60a55bb2010-06-18 15:11:19 -0700116void setZoom(float z, /*bool*/ int animate) {
117 gZoomTarget = z;
118 if (gZoomTarget < 0.001f) {
119 gZoomTarget = 0;
120 }
121 if (!animate) {
122 g_Zoom = gZoomTarget;
123 }
Joe Onorato3a8820b2009-11-10 15:06:42 -0800124 updateReadback();
125}
126
Jason Sams60a55bb2010-06-18 15:11:19 -0700127void fling(float newPos, float vel) {
128 move(newPos);
129
130 g_LastTouchDown = false;
131 g_PosVelocity = -vel * 4;
Jason Sams14f67ed2010-05-11 14:02:43 -0700132 float av = fabs(g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700133 float minVel = 3.5f;
134
Jason Sams13a75d52010-05-19 16:38:04 -0700135 minVel *= 1.f - (fabs(rsFrac(g_PosPage + 0.5f) - 0.5f) * 0.45f);
Jason Sams0f505e52009-10-13 17:18:35 -0700136
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) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700146 g_PosVelocity = max(0.f, g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700147 }
148 if (g_PosPage > g_PosMax) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700149 g_PosVelocity = min(0.f, g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700150 }
151}
152
Jason Sams14f67ed2010-05-11 14:02:43 -0700153// Interpolates values in the range 0..1 to a curve that eases in
154// and out.
155static float getInterpolation(float input) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700156 return (cos((input + 1) * PI) * 0.5f) + 0.5f;
Jason Sams0f505e52009-10-13 17:18:35 -0700157}
158
Mike Cleron7d5d7462009-10-20 14:06:00 -0700159
Jason Sams14f67ed2010-05-11 14:02:43 -0700160static void updatePos() {
Jason Sams0f505e52009-10-13 17:18:35 -0700161 if (g_LastTouchDown) {
162 return;
163 }
164
Jason Sams13a75d52010-05-19 16:38:04 -0700165 float tablePosNorm = rsFrac(g_PosPage + 0.5f);
Jason Sams0f505e52009-10-13 17:18:35 -0700166 float tablePosF = tablePosNorm * g_PhysicsTableSize;
167 int tablePosI = tablePosF;
168 float tablePosFrac = tablePosF - tablePosI;
Jason Sams14f67ed2010-05-11 14:02:43 -0700169 float accel = mix(g_AttractionTable[tablePosI],
Jason Sams0f505e52009-10-13 17:18:35 -0700170 g_AttractionTable[tablePosI + 1],
171 tablePosFrac) * g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -0700172 float friction = mix(g_FrictionTable[tablePosI],
Jason Sams2e19c052009-10-20 18:19:55 -0700173 g_FrictionTable[tablePosI + 1],
174 tablePosFrac) * g_DT;
Jason Sams0f505e52009-10-13 17:18:35 -0700175
Jason Samsc1c521e2009-10-19 14:45:45 -0700176 if (g_MoveToTime) {
Jason Samsc8514792009-10-29 14:27:29 -0700177 // New position is old posiition + (total distance) * (interpolated time)
Jason Sams14f67ed2010-05-11 14:02:43 -0700178 g_PosPage = g_MoveToOldPos + (gTargetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime);
Jason Samsc1c521e2009-10-19 14:45:45 -0700179 g_MoveToTime -= g_DT;
180 if (g_MoveToTime <= 0) {
181 g_MoveToTime = 0;
Jason Sams14f67ed2010-05-11 14:02:43 -0700182 g_PosPage = gTargetPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700183 }
184 return;
185 }
186
Jason Sams0f505e52009-10-13 17:18:35 -0700187 // If our velocity is low OR acceleration is opposing it, apply it.
Jason Sams14f67ed2010-05-11 14:02:43 -0700188 if (fabs(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700189 g_PosVelocity += accel;
190 }
Jason Sams13a75d52010-05-19 16:38:04 -0700191 //RS_DEBUG(g_PosPage);
192 //RS_DEBUG(g_PosVelocity);
193 //RS_DEBUG(friction);
194 //RS_DEBUG(accel);
Jason Sams0f505e52009-10-13 17:18:35 -0700195
Jason Samsc8514792009-10-29 14:27:29 -0700196 // Normal physics
197 if (g_PosVelocity > 0) {
198 g_PosVelocity -= friction;
Jason Sams14f67ed2010-05-11 14:02:43 -0700199 g_PosVelocity = max(g_PosVelocity, 0.f);
Jason Samsc8514792009-10-29 14:27:29 -0700200 } else {
201 g_PosVelocity += friction;
Jason Sams14f67ed2010-05-11 14:02:43 -0700202 g_PosVelocity = min(g_PosVelocity, 0.f);
Jason Samsc8514792009-10-29 14:27:29 -0700203 }
204
Jason Sams14f67ed2010-05-11 14:02:43 -0700205 if ((friction > fabs(g_PosVelocity)) && (friction > fabs(accel))) {
Jason Sams0f505e52009-10-13 17:18:35 -0700206 // Special get back to center and overcome friction physics.
207 float t = tablePosNorm - 0.5f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700208 if (fabs(t) < (friction * g_DT)) {
Jason Sams0f505e52009-10-13 17:18:35 -0700209 // really close, just snap
Jason Sams14f67ed2010-05-11 14:02:43 -0700210 g_PosPage = round(g_PosPage);
Jason Sams0f505e52009-10-13 17:18:35 -0700211 g_PosVelocity = 0;
212 } else {
213 if (t > 0) {
214 g_PosVelocity = -friction;
215 } else {
216 g_PosVelocity = friction;
217 }
218 }
Jason Sams0f505e52009-10-13 17:18:35 -0700219 }
Jason Sams0f505e52009-10-13 17:18:35 -0700220
221 // Check for out of boundry conditions.
222 if (g_PosPage < 0 && g_PosVelocity < 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700223 float damp = 1.0f + (g_PosPage * 4);
224 damp = clamp(damp, 0.f, 0.9f);
Jason Sams0f505e52009-10-13 17:18:35 -0700225 g_PosVelocity *= damp;
226 }
227 if (g_PosPage > g_PosMax && g_PosVelocity > 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700228 float damp = 1.0f - ((g_PosPage - g_PosMax) * 4);
229 damp = clamp(damp, 0.f, 0.9f);
Jason Sams0f505e52009-10-13 17:18:35 -0700230 g_PosVelocity *= damp;
231 }
Jason Samsc8514792009-10-29 14:27:29 -0700232
233 g_PosPage += g_PosVelocity * g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -0700234 g_PosPage = clamp(g_PosPage, -0.49f, g_PosMax + 0.49f);
Jason Sams0f505e52009-10-13 17:18:35 -0700235}
236
Jason Sams14f67ed2010-05-11 14:02:43 -0700237static void
Jason Sams0f505e52009-10-13 17:18:35 -0700238draw_home_button()
239{
Jason Sams13a75d52010-05-19 16:38:04 -0700240 rsgBindTexture(gPFTexNearest, 0, gHomeButton);
Jason Sams0f505e52009-10-13 17:18:35 -0700241
Jason Sams13a75d52010-05-19 16:38:04 -0700242 float w = rsgGetWidth();
243 float h = rsgGetHeight();
244 float tw = rsAllocationGetDimX(gHomeButton);
245 float th = rsAllocationGetDimY(gHomeButton);
Jason Sams76512482010-02-04 16:31:35 -0800246
247 float x;
248 float y;
Jason Sams13a75d52010-05-19 16:38:04 -0700249 if (w > h) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700250 x = w - (tw * (1 - g_Animation)) + 20;
251 y = (h - th) * 0.5f;
Jason Sams76512482010-02-04 16:31:35 -0800252 } else {
Jason Sams14f67ed2010-05-11 14:02:43 -0700253 x = (w - tw) / 2;
254 y = -g_Animation * th;
Jason Sams76512482010-02-04 16:31:35 -0800255 y -= 30; // move the house to the edge of the screen as it doesn't fill the texture.
256 }
257
Jason Sams13a75d52010-05-19 16:38:04 -0700258 rsgDrawSpriteScreenspace(x, y, 0, tw, th);
Jason Sams0f505e52009-10-13 17:18:35 -0700259}
260
Jason Sams14f67ed2010-05-11 14:02:43 -0700261static void drawFrontGrid(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700262{
Jason Sams13a75d52010-05-19 16:38:04 -0700263 float h = rsgGetHeight();
264 float w = rsgGetWidth();
Jason Sams0f505e52009-10-13 17:18:35 -0700265
266 int intRowOffset = rowOffset;
267 float rowFrac = rowOffset - intRowOffset;
Jason Sams13a75d52010-05-19 16:38:04 -0700268 float colWidth = 120.f;//w / 4;
Jason Sams0f505e52009-10-13 17:18:35 -0700269 float rowHeight = colWidth + 25.f;
Jason Samsb4ecab22010-01-19 16:43:26 -0800270 float yoff = 0.5f * h + 1.5f * rowHeight;
Jason Sams0f505e52009-10-13 17:18:35 -0700271
272 int row, col;
Jason Sams76512482010-02-04 16:31:35 -0800273 int colCount = 4;
274 if (w > h) {
275 colCount = 6;
276 rowHeight -= 12.f;
277 yoff = 0.47f * h + 1.0f * rowHeight;
278 }
279
280 int iconNum = (intRowOffset - 5) * colCount;
281
Jason Sams13a75d52010-05-19 16:38:04 -0700282 rsgBindProgramVertex(gPVCurve);
Jason Samsb4ecab22010-01-19 16:43:26 -0800283
Jason Sams76512482010-02-04 16:31:35 -0800284 vpConstants->Position.z = p;
Jason Samsb4ecab22010-01-19 16:43:26 -0800285
286 for (row = -5; row < 15; row++) {
Jason Sams0f505e52009-10-13 17:18:35 -0700287 float y = yoff - ((-rowFrac + row) * rowHeight);
288
Jason Sams76512482010-02-04 16:31:35 -0800289 for (col=0; col < colCount; col++) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700290 if (iconNum >= gIconCount) {
Jason Sams0f505e52009-10-13 17:18:35 -0700291 return;
292 }
293
294 if (iconNum >= 0) {
Jason Samsb4ecab22010-01-19 16:43:26 -0800295 float x = colWidth * col + (colWidth / 2);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800296 vpConstants->Position.x = x + 0.2f;
Jason Sams1a94ee32010-01-20 13:34:30 -0800297
Jason Samsf0d03e42010-08-13 12:18:01 -0700298 if (gSelectedIconIndex == iconNum && !p && rsIsObject(gSelectedIconTexture)) {
Jason Sams13a75d52010-05-19 16:38:04 -0700299 rsgBindProgramFragment(gPFTexNearest);
300 rsgBindTexture(gPFTexNearest, 0, gSelectedIconTexture);
301 vpConstants->ImgSize.x = rsAllocationGetDimX(gSelectedIconTexture);
302 vpConstants->ImgSize.y = rsAllocationGetDimY(gSelectedIconTexture);
303 vpConstants->Position.y = y - (rsAllocationGetDimY(gSelectedIconTexture)
304 - rsAllocationGetDimY(gIconIDs[iconNum])) * 0.5f;
Alex Sakhartchouk95252b42010-09-13 20:44:01 -0700305 rsAllocationMarkDirty(g_VPConstAlloc);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700306 rsgDrawMesh(gSMCell);
Jason Sams37f262d2010-01-20 11:19:51 -0800307 }
308
Jason Sams13a75d52010-05-19 16:38:04 -0700309 rsgBindProgramFragment(gPFTexMip);
310 vpConstants->ImgSize.x = rsAllocationGetDimX(gIconIDs[iconNum]);
311 vpConstants->ImgSize.y = rsAllocationGetDimY(gIconIDs[iconNum]);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800312 vpConstants->Position.y = y - 0.2f;
Alex Sakhartchouk95252b42010-09-13 20:44:01 -0700313 rsAllocationMarkDirty(g_VPConstAlloc);
Jason Sams13a75d52010-05-19 16:38:04 -0700314 rsgBindTexture(gPFTexMip, 0, gIconIDs[iconNum]);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700315 rsgDrawMesh(gSMCell);
Joe Onorato742d7fc2009-10-15 19:48:16 -0700316
Jason Sams13a75d52010-05-19 16:38:04 -0700317 rsgBindProgramFragment(gPFTexMipAlpha);
318 vpConstants->ImgSize.x = rsAllocationGetDimX(gLabelIDs[iconNum]);
319 vpConstants->ImgSize.y = rsAllocationGetDimY(gLabelIDs[iconNum]);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800320 vpConstants->Position.y = y - 64.f - 0.2f;
Alex Sakhartchouk95252b42010-09-13 20:44:01 -0700321 rsAllocationMarkDirty(g_VPConstAlloc);
Jason Sams13a75d52010-05-19 16:38:04 -0700322 rsgBindTexture(gPFTexMipAlpha, 0, gLabelIDs[iconNum]);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700323 rsgDrawMesh(gSMCell);
Jason Sams0f505e52009-10-13 17:18:35 -0700324 }
325 iconNum++;
326 }
327 }
328}
329
Jason Sams0f505e52009-10-13 17:18:35 -0700330
Jason Sams14f67ed2010-05-11 14:02:43 -0700331int root()
Jason Sams0f505e52009-10-13 17:18:35 -0700332{
333 // Compute dt in seconds.
Jason Samsb52dfa02009-10-14 20:16:14 -0700334 // physics may break if DT is large.
Jason Sams500d36e2010-07-28 11:15:33 -0700335 g_DT = min(rsGetDt(), 0.1f);
Alex Sakhartchouk95252b42010-09-13 20:44:01 -0700336 g_VPConstAlloc = rsGetAllocation(vpConstants);
Jason Sams0f505e52009-10-13 17:18:35 -0700337
Jason Sams14f67ed2010-05-11 14:02:43 -0700338 if (g_Zoom != gZoomTarget) {
Jason Sams6471c8b2010-01-20 14:15:22 -0800339 float dz = g_DT * 1.7f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700340 if (gZoomTarget < 0.5f) {
Jason Sams6471c8b2010-01-20 14:15:22 -0800341 dz = -dz;
Jason Sams0f505e52009-10-13 17:18:35 -0700342 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700343 if (fabs(g_Zoom - gZoomTarget) < fabs(dz)) {
344 g_Zoom = gZoomTarget;
Jason Sams0f505e52009-10-13 17:18:35 -0700345 } else {
346 g_Zoom += dz;
347 }
348 updateReadback();
349 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700350 g_Animation = pow(1.f - g_Zoom, 3.f);
Jason Sams0f505e52009-10-13 17:18:35 -0700351
352 // Set clear value to dim the background based on the zoom position.
Jason Samsad1bdf02010-05-14 17:54:50 -0700353 if ((g_Zoom < 0.001f) && (gZoomTarget < 0.001f)) {
Jason Sams13a75d52010-05-19 16:38:04 -0700354 rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Jason Sams0f505e52009-10-13 17:18:35 -0700355 // When we're zoomed out and not tracking motion events, reset the pos to 0.
356 if (!g_LastTouchDown) {
357 g_PosPage = 0;
358 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700359 return 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700360 } else {
Jason Sams13a75d52010-05-19 16:38:04 -0700361 rsgClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
Jason Sams0f505e52009-10-13 17:18:35 -0700362 }
363
Jason Sams13a75d52010-05-19 16:38:04 -0700364 rsgBindProgramStore(gPS);
365
Jason Sams0f505e52009-10-13 17:18:35 -0700366 // icons & labels
Jason Sams13a75d52010-05-19 16:38:04 -0700367 if (rsgGetWidth() > rsgGetHeight()) {
Jason Samsad1bdf02010-05-14 17:54:50 -0700368 g_Cols = COLUMNS_PER_PAGE_LANDSCAPE;
369 g_Rows = ROWS_PER_PAGE_LANDSCAPE;
Joe Onorato20e7a562010-03-18 17:12:52 -0700370 } else {
Jason Samsad1bdf02010-05-14 17:54:50 -0700371 g_Cols = COLUMNS_PER_PAGE_PORTRAIT;
372 g_Rows = ROWS_PER_PAGE_PORTRAIT;
Jason Samscc903492010-03-12 12:46:04 -0800373 }
Jason Samsad1bdf02010-05-14 17:54:50 -0700374
Jason Sams14f67ed2010-05-11 14:02:43 -0700375 g_PosMax = ((gIconCount + (g_Cols-1)) / g_Cols) - g_Rows;
Jason Sams0f505e52009-10-13 17:18:35 -0700376 if (g_PosMax < 0) g_PosMax = 0;
377
Jason Samscc903492010-03-12 12:46:04 -0800378 updatePos();
Jason Sams0f505e52009-10-13 17:18:35 -0700379 updateReadback();
380
Jason Sams0f505e52009-10-13 17:18:35 -0700381 // Draw the icons ========================================
Jason Sams6471c8b2010-01-20 14:15:22 -0800382 drawFrontGrid(g_PosPage, g_Animation);
Jason Samsc8514792009-10-29 14:27:29 -0700383
Jason Sams13a75d52010-05-19 16:38:04 -0700384 rsgBindProgramFragment(gPFTexNearest);
Jason Samsb52dfa02009-10-14 20:16:14 -0700385 draw_home_button();
Jason Sams60a55bb2010-06-18 15:11:19 -0700386 return (g_PosVelocity != 0) || rsFrac(g_PosPage) || g_Zoom != gZoomTarget || (g_MoveToTime != 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700387}
388
Jason Sams14f67ed2010-05-11 14:02:43 -0700389