blob: 4ea1aee3740ffa79801cdcb3c267ef74bee19c88 [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
Jason Sams4dfea092010-12-06 17:38:58 -080027rs_allocation *gIcons;
28rs_allocation *gLabels;
Jason Sams14f67ed2010-05-11 14:02:43 -070029
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
Jason Sams0f505e52009-10-13 17:18:35 -070039// Attraction to center values from page edge to page center.
Jason Samsad1bdf02010-05-14 17:54:50 -070040static float g_AttractionTable[9] = {20.f, 20.f, 20.f, 10.f, -10.f, -20.f, -20.f, -20.f, -20.f};
41static float g_FrictionTable[9] = {10.f, 10.f, 11.f, 15.f, 15.f, 11.f, 10.f, 10.f, 10.f};
42static float g_PhysicsTableSize = 7;
Jason Sams0f505e52009-10-13 17:18:35 -070043
Jason Sams60a55bb2010-06-18 15:11:19 -070044static float gZoomTarget;
Stephen Hinesb02af382010-10-08 15:52:00 -070045float gTargetPos;
Jason Samsad1bdf02010-05-14 17:54:50 -070046static float g_PosPage = 0.f;
47static float g_PosVelocity = 0.f;
48static float g_LastPositionX = 0.f;
Jason Sams60a55bb2010-06-18 15:11:19 -070049static bool g_LastTouchDown = false;
Jason Sams14f67ed2010-05-11 14:02:43 -070050static float g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -070051static int g_PosMax;
Jason Samsad1bdf02010-05-14 17:54:50 -070052static float g_Zoom = 0.f;
53static float g_Animation = 1.f;
Jason Sams14f67ed2010-05-11 14:02:43 -070054static float g_OldPosPage;
55static float g_OldPosVelocity;
56static float g_OldZoom;
Jason Samsad1bdf02010-05-14 17:54:50 -070057static float g_MoveToTotalTime = 0.2f;
58static float g_MoveToTime = 0.f;
59static float g_MoveToOldPos = 0.f;
Jason Samsc1c521e2009-10-19 14:45:45 -070060
Jason Sams14f67ed2010-05-11 14:02:43 -070061static int g_Cols;
62static int g_Rows;
Jason Sams0f505e52009-10-13 17:18:35 -070063
Alex Sakhartchouk95252b42010-09-13 20:44:01 -070064rs_allocation g_VPConstAlloc;
65
Jason Sams0f505e52009-10-13 17:18:35 -070066// Drawing constants, should be parameters ======
67#define VIEW_ANGLE 1.28700222f
68
Jason Sams0f505e52009-10-13 17:18:35 -070069
Jason Sams14f67ed2010-05-11 14:02:43 -070070static void updateReadback() {
Jason Samsad1bdf02010-05-14 17:54:50 -070071 if ((g_OldPosPage != g_PosPage) ||
72 (g_OldPosVelocity != g_PosVelocity) ||
73 (g_OldZoom != g_Zoom)) {
Jason Sams0f505e52009-10-13 17:18:35 -070074
75 g_OldPosPage = g_PosPage;
76 g_OldPosVelocity = g_PosVelocity;
77 g_OldZoom = g_Zoom;
78
79 int i[3];
80 i[0] = g_PosPage * (1 << 16);
81 i[1] = g_PosVelocity * (1 << 16);
82 i[2] = g_OldZoom * (1 << 16);
Jason Sams500d36e2010-07-28 11:15:33 -070083 rsSendToClientBlocking(1, &i[0], sizeof(i));
Jason Samsad1bdf02010-05-14 17:54:50 -070084 }
Jason Sams0f505e52009-10-13 17:18:35 -070085}
86
Jason Sams0f505e52009-10-13 17:18:35 -070087void init() {
Jason Sams41b61c82009-10-15 15:40:54 -070088}
Jason Sams0f505e52009-10-13 17:18:35 -070089
Jason Sams60a55bb2010-06-18 15:11:19 -070090void move(float newPos) {
Jason Sams0f505e52009-10-13 17:18:35 -070091 if (g_LastTouchDown) {
Jason Sams60a55bb2010-06-18 15:11:19 -070092 float dx = -(newPos - g_LastPositionX);
Jason Sams0f505e52009-10-13 17:18:35 -070093 g_PosVelocity = 0;
Jason Sams6ec11bc2010-01-19 17:56:52 -080094 g_PosPage += dx * 5.2f;
Jason Sams0f505e52009-10-13 17:18:35 -070095
Jason Samsc8514792009-10-29 14:27:29 -070096 float pmin = -0.49f;
97 float pmax = g_PosMax + 0.49f;
Jason Sams14f67ed2010-05-11 14:02:43 -070098 g_PosPage = clamp(g_PosPage, pmin, pmax);
Jason Sams0f505e52009-10-13 17:18:35 -070099 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700100 g_LastTouchDown = true;
101 g_LastPositionX = newPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700102 g_MoveToTime = 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700103}
104
Jason Sams60a55bb2010-06-18 15:11:19 -0700105void moveTo(float targetPos) {
106 gTargetPos = targetPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700107 g_MoveToTime = g_MoveToTotalTime;
108 g_PosVelocity = 0;
109 g_MoveToOldPos = g_PosPage;
110}
111
Jason Sams60a55bb2010-06-18 15:11:19 -0700112void setZoom(float z, /*bool*/ int animate) {
113 gZoomTarget = z;
114 if (gZoomTarget < 0.001f) {
115 gZoomTarget = 0;
116 }
117 if (!animate) {
118 g_Zoom = gZoomTarget;
119 }
Joe Onorato3a8820b2009-11-10 15:06:42 -0800120 updateReadback();
121}
122
Jason Sams60a55bb2010-06-18 15:11:19 -0700123void fling(float newPos, float vel) {
124 move(newPos);
125
126 g_LastTouchDown = false;
127 g_PosVelocity = -vel * 4;
Jason Sams14f67ed2010-05-11 14:02:43 -0700128 float av = fabs(g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700129 float minVel = 3.5f;
130
Jason Sams13a75d52010-05-19 16:38:04 -0700131 minVel *= 1.f - (fabs(rsFrac(g_PosPage + 0.5f) - 0.5f) * 0.45f);
Jason Sams0f505e52009-10-13 17:18:35 -0700132
133 if (av < minVel && av > 0.2f) {
134 if (g_PosVelocity > 0) {
135 g_PosVelocity = minVel;
136 } else {
137 g_PosVelocity = -minVel;
138 }
139 }
140
141 if (g_PosPage <= 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700142 g_PosVelocity = max(0.f, g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700143 }
144 if (g_PosPage > g_PosMax) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700145 g_PosVelocity = min(0.f, g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700146 }
147}
148
Jason Sams14f67ed2010-05-11 14:02:43 -0700149// Interpolates values in the range 0..1 to a curve that eases in
150// and out.
151static float getInterpolation(float input) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700152 return (cos((input + 1) * PI) * 0.5f) + 0.5f;
Jason Sams0f505e52009-10-13 17:18:35 -0700153}
154
Mike Cleron7d5d7462009-10-20 14:06:00 -0700155
Jason Sams14f67ed2010-05-11 14:02:43 -0700156static void updatePos() {
Jason Sams0f505e52009-10-13 17:18:35 -0700157 if (g_LastTouchDown) {
158 return;
159 }
160
Jason Sams13a75d52010-05-19 16:38:04 -0700161 float tablePosNorm = rsFrac(g_PosPage + 0.5f);
Jason Sams0f505e52009-10-13 17:18:35 -0700162 float tablePosF = tablePosNorm * g_PhysicsTableSize;
163 int tablePosI = tablePosF;
164 float tablePosFrac = tablePosF - tablePosI;
Jason Sams14f67ed2010-05-11 14:02:43 -0700165 float accel = mix(g_AttractionTable[tablePosI],
Jason Sams0f505e52009-10-13 17:18:35 -0700166 g_AttractionTable[tablePosI + 1],
167 tablePosFrac) * g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -0700168 float friction = mix(g_FrictionTable[tablePosI],
Jason Sams2e19c052009-10-20 18:19:55 -0700169 g_FrictionTable[tablePosI + 1],
170 tablePosFrac) * g_DT;
Jason Sams0f505e52009-10-13 17:18:35 -0700171
Jason Samsc1c521e2009-10-19 14:45:45 -0700172 if (g_MoveToTime) {
Jason Samsc8514792009-10-29 14:27:29 -0700173 // New position is old posiition + (total distance) * (interpolated time)
Jason Sams14f67ed2010-05-11 14:02:43 -0700174 g_PosPage = g_MoveToOldPos + (gTargetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime);
Jason Samsc1c521e2009-10-19 14:45:45 -0700175 g_MoveToTime -= g_DT;
176 if (g_MoveToTime <= 0) {
177 g_MoveToTime = 0;
Jason Sams14f67ed2010-05-11 14:02:43 -0700178 g_PosPage = gTargetPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700179 }
180 return;
181 }
182
Jason Sams0f505e52009-10-13 17:18:35 -0700183 // If our velocity is low OR acceleration is opposing it, apply it.
Jason Sams14f67ed2010-05-11 14:02:43 -0700184 if (fabs(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700185 g_PosVelocity += accel;
186 }
Jason Sams13a75d52010-05-19 16:38:04 -0700187 //RS_DEBUG(g_PosPage);
188 //RS_DEBUG(g_PosVelocity);
189 //RS_DEBUG(friction);
190 //RS_DEBUG(accel);
Jason Sams0f505e52009-10-13 17:18:35 -0700191
Jason Samsc8514792009-10-29 14:27:29 -0700192 // Normal physics
193 if (g_PosVelocity > 0) {
194 g_PosVelocity -= friction;
Jason Sams14f67ed2010-05-11 14:02:43 -0700195 g_PosVelocity = max(g_PosVelocity, 0.f);
Jason Samsc8514792009-10-29 14:27:29 -0700196 } else {
197 g_PosVelocity += friction;
Jason Sams14f67ed2010-05-11 14:02:43 -0700198 g_PosVelocity = min(g_PosVelocity, 0.f);
Jason Samsc8514792009-10-29 14:27:29 -0700199 }
200
Jason Sams14f67ed2010-05-11 14:02:43 -0700201 if ((friction > fabs(g_PosVelocity)) && (friction > fabs(accel))) {
Jason Sams0f505e52009-10-13 17:18:35 -0700202 // Special get back to center and overcome friction physics.
203 float t = tablePosNorm - 0.5f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700204 if (fabs(t) < (friction * g_DT)) {
Jason Sams0f505e52009-10-13 17:18:35 -0700205 // really close, just snap
Jason Sams14f67ed2010-05-11 14:02:43 -0700206 g_PosPage = round(g_PosPage);
Jason Sams0f505e52009-10-13 17:18:35 -0700207 g_PosVelocity = 0;
208 } else {
209 if (t > 0) {
210 g_PosVelocity = -friction;
211 } else {
212 g_PosVelocity = friction;
213 }
214 }
Jason Sams0f505e52009-10-13 17:18:35 -0700215 }
Jason Sams0f505e52009-10-13 17:18:35 -0700216
217 // Check for out of boundry conditions.
218 if (g_PosPage < 0 && g_PosVelocity < 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700219 float damp = 1.0f + (g_PosPage * 4);
220 damp = clamp(damp, 0.f, 0.9f);
Jason Sams0f505e52009-10-13 17:18:35 -0700221 g_PosVelocity *= damp;
222 }
223 if (g_PosPage > g_PosMax && g_PosVelocity > 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700224 float damp = 1.0f - ((g_PosPage - g_PosMax) * 4);
225 damp = clamp(damp, 0.f, 0.9f);
Jason Sams0f505e52009-10-13 17:18:35 -0700226 g_PosVelocity *= damp;
227 }
Jason Samsc8514792009-10-29 14:27:29 -0700228
229 g_PosPage += g_PosVelocity * g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -0700230 g_PosPage = clamp(g_PosPage, -0.49f, g_PosMax + 0.49f);
Jason Sams0f505e52009-10-13 17:18:35 -0700231}
232
Jason Sams14f67ed2010-05-11 14:02:43 -0700233static void
Jason Sams0f505e52009-10-13 17:18:35 -0700234draw_home_button()
235{
Jason Sams13a75d52010-05-19 16:38:04 -0700236 rsgBindTexture(gPFTexNearest, 0, gHomeButton);
Jason Sams0f505e52009-10-13 17:18:35 -0700237
Jason Sams13a75d52010-05-19 16:38:04 -0700238 float w = rsgGetWidth();
239 float h = rsgGetHeight();
240 float tw = rsAllocationGetDimX(gHomeButton);
241 float th = rsAllocationGetDimY(gHomeButton);
Jason Sams76512482010-02-04 16:31:35 -0800242
243 float x;
244 float y;
Jason Sams13a75d52010-05-19 16:38:04 -0700245 if (w > h) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700246 x = w - (tw * (1 - g_Animation)) + 20;
247 y = (h - th) * 0.5f;
Jason Sams76512482010-02-04 16:31:35 -0800248 } else {
Jason Sams14f67ed2010-05-11 14:02:43 -0700249 x = (w - tw) / 2;
250 y = -g_Animation * th;
Jason Sams76512482010-02-04 16:31:35 -0800251 y -= 30; // move the house to the edge of the screen as it doesn't fill the texture.
252 }
253
Jason Sams13a75d52010-05-19 16:38:04 -0700254 rsgDrawSpriteScreenspace(x, y, 0, tw, th);
Jason Sams0f505e52009-10-13 17:18:35 -0700255}
256
Jason Sams14f67ed2010-05-11 14:02:43 -0700257static void drawFrontGrid(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700258{
Jason Sams13a75d52010-05-19 16:38:04 -0700259 float h = rsgGetHeight();
260 float w = rsgGetWidth();
Jason Sams0f505e52009-10-13 17:18:35 -0700261
262 int intRowOffset = rowOffset;
263 float rowFrac = rowOffset - intRowOffset;
Jason Sams13a75d52010-05-19 16:38:04 -0700264 float colWidth = 120.f;//w / 4;
Jason Sams0f505e52009-10-13 17:18:35 -0700265 float rowHeight = colWidth + 25.f;
Jason Samsb4ecab22010-01-19 16:43:26 -0800266 float yoff = 0.5f * h + 1.5f * rowHeight;
Jason Sams0f505e52009-10-13 17:18:35 -0700267
268 int row, col;
Jason Sams76512482010-02-04 16:31:35 -0800269 int colCount = 4;
270 if (w > h) {
271 colCount = 6;
272 rowHeight -= 12.f;
273 yoff = 0.47f * h + 1.0f * rowHeight;
274 }
275
276 int iconNum = (intRowOffset - 5) * colCount;
277
Jason Sams13a75d52010-05-19 16:38:04 -0700278 rsgBindProgramVertex(gPVCurve);
Jason Samsb4ecab22010-01-19 16:43:26 -0800279
Jason Sams76512482010-02-04 16:31:35 -0800280 vpConstants->Position.z = p;
Jason Samsb4ecab22010-01-19 16:43:26 -0800281
282 for (row = -5; row < 15; row++) {
Jason Sams0f505e52009-10-13 17:18:35 -0700283 float y = yoff - ((-rowFrac + row) * rowHeight);
284
Jason Sams76512482010-02-04 16:31:35 -0800285 for (col=0; col < colCount; col++) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700286 if (iconNum >= gIconCount) {
Jason Sams0f505e52009-10-13 17:18:35 -0700287 return;
288 }
289
290 if (iconNum >= 0) {
Jason Samsb4ecab22010-01-19 16:43:26 -0800291 float x = colWidth * col + (colWidth / 2);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800292 vpConstants->Position.x = x + 0.2f;
Jason Sams1a94ee32010-01-20 13:34:30 -0800293
Jason Samsf0d03e42010-08-13 12:18:01 -0700294 if (gSelectedIconIndex == iconNum && !p && rsIsObject(gSelectedIconTexture)) {
Jason Sams13a75d52010-05-19 16:38:04 -0700295 rsgBindProgramFragment(gPFTexNearest);
296 rsgBindTexture(gPFTexNearest, 0, gSelectedIconTexture);
297 vpConstants->ImgSize.x = rsAllocationGetDimX(gSelectedIconTexture);
298 vpConstants->ImgSize.y = rsAllocationGetDimY(gSelectedIconTexture);
299 vpConstants->Position.y = y - (rsAllocationGetDimY(gSelectedIconTexture)
Jason Sams4dfea092010-12-06 17:38:58 -0800300 - rsAllocationGetDimY(gIcons[iconNum])) * 0.5f;
Jason Sams70467ef2011-02-03 14:17:40 -0800301 rsgAllocationSyncAll(g_VPConstAlloc);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700302 rsgDrawMesh(gSMCell);
Jason Sams37f262d2010-01-20 11:19:51 -0800303 }
304
Jason Sams13a75d52010-05-19 16:38:04 -0700305 rsgBindProgramFragment(gPFTexMip);
Jason Sams4dfea092010-12-06 17:38:58 -0800306 vpConstants->ImgSize.x = rsAllocationGetDimX(gIcons[iconNum]);
307 vpConstants->ImgSize.y = rsAllocationGetDimY(gIcons[iconNum]);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800308 vpConstants->Position.y = y - 0.2f;
Jason Sams70467ef2011-02-03 14:17:40 -0800309 rsgAllocationSyncAll(g_VPConstAlloc);
Jason Sams4dfea092010-12-06 17:38:58 -0800310 rsgBindTexture(gPFTexMip, 0, gIcons[iconNum]);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700311 rsgDrawMesh(gSMCell);
Joe Onorato742d7fc2009-10-15 19:48:16 -0700312
Jason Sams13a75d52010-05-19 16:38:04 -0700313 rsgBindProgramFragment(gPFTexMipAlpha);
Jason Sams4dfea092010-12-06 17:38:58 -0800314 vpConstants->ImgSize.x = rsAllocationGetDimX(gLabels[iconNum]);
315 vpConstants->ImgSize.y = rsAllocationGetDimY(gLabels[iconNum]);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800316 vpConstants->Position.y = y - 64.f - 0.2f;
Jason Sams70467ef2011-02-03 14:17:40 -0800317 rsgAllocationSyncAll(g_VPConstAlloc);
Jason Sams4dfea092010-12-06 17:38:58 -0800318 rsgBindTexture(gPFTexMipAlpha, 0, gLabels[iconNum]);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700319 rsgDrawMesh(gSMCell);
Jason Sams0f505e52009-10-13 17:18:35 -0700320 }
321 iconNum++;
322 }
323 }
324}
325
Jason Sams0f505e52009-10-13 17:18:35 -0700326
Jason Sams14f67ed2010-05-11 14:02:43 -0700327int root()
Jason Sams0f505e52009-10-13 17:18:35 -0700328{
329 // Compute dt in seconds.
Jason Samsb52dfa02009-10-14 20:16:14 -0700330 // physics may break if DT is large.
Jason Sams500d36e2010-07-28 11:15:33 -0700331 g_DT = min(rsGetDt(), 0.1f);
Alex Sakhartchouk95252b42010-09-13 20:44:01 -0700332 g_VPConstAlloc = rsGetAllocation(vpConstants);
Jason Sams0f505e52009-10-13 17:18:35 -0700333
Jason Sams14f67ed2010-05-11 14:02:43 -0700334 if (g_Zoom != gZoomTarget) {
Jason Sams6471c8b2010-01-20 14:15:22 -0800335 float dz = g_DT * 1.7f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700336 if (gZoomTarget < 0.5f) {
Jason Sams6471c8b2010-01-20 14:15:22 -0800337 dz = -dz;
Jason Sams0f505e52009-10-13 17:18:35 -0700338 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700339 if (fabs(g_Zoom - gZoomTarget) < fabs(dz)) {
340 g_Zoom = gZoomTarget;
Jason Sams0f505e52009-10-13 17:18:35 -0700341 } else {
342 g_Zoom += dz;
343 }
344 updateReadback();
345 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700346 g_Animation = pow(1.f - g_Zoom, 3.f);
Jason Sams0f505e52009-10-13 17:18:35 -0700347
348 // Set clear value to dim the background based on the zoom position.
Jason Samsad1bdf02010-05-14 17:54:50 -0700349 if ((g_Zoom < 0.001f) && (gZoomTarget < 0.001f)) {
Jason Sams13a75d52010-05-19 16:38:04 -0700350 rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Jason Sams0f505e52009-10-13 17:18:35 -0700351 // When we're zoomed out and not tracking motion events, reset the pos to 0.
352 if (!g_LastTouchDown) {
353 g_PosPage = 0;
354 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700355 return 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700356 } else {
Jason Sams13a75d52010-05-19 16:38:04 -0700357 rsgClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
Jason Sams0f505e52009-10-13 17:18:35 -0700358 }
359
Jason Sams13a75d52010-05-19 16:38:04 -0700360 rsgBindProgramStore(gPS);
361
Jason Sams0f505e52009-10-13 17:18:35 -0700362 // icons & labels
Jason Sams13a75d52010-05-19 16:38:04 -0700363 if (rsgGetWidth() > rsgGetHeight()) {
Jason Samsad1bdf02010-05-14 17:54:50 -0700364 g_Cols = COLUMNS_PER_PAGE_LANDSCAPE;
365 g_Rows = ROWS_PER_PAGE_LANDSCAPE;
Joe Onorato20e7a562010-03-18 17:12:52 -0700366 } else {
Jason Samsad1bdf02010-05-14 17:54:50 -0700367 g_Cols = COLUMNS_PER_PAGE_PORTRAIT;
368 g_Rows = ROWS_PER_PAGE_PORTRAIT;
Jason Samscc903492010-03-12 12:46:04 -0800369 }
Jason Samsad1bdf02010-05-14 17:54:50 -0700370
Jason Sams14f67ed2010-05-11 14:02:43 -0700371 g_PosMax = ((gIconCount + (g_Cols-1)) / g_Cols) - g_Rows;
Jason Sams0f505e52009-10-13 17:18:35 -0700372 if (g_PosMax < 0) g_PosMax = 0;
373
Jason Samscc903492010-03-12 12:46:04 -0800374 updatePos();
Jason Sams0f505e52009-10-13 17:18:35 -0700375 updateReadback();
376
Jason Sams0f505e52009-10-13 17:18:35 -0700377 // Draw the icons ========================================
Jason Sams6471c8b2010-01-20 14:15:22 -0800378 drawFrontGrid(g_PosPage, g_Animation);
Jason Samsc8514792009-10-29 14:27:29 -0700379
Jason Sams13a75d52010-05-19 16:38:04 -0700380 rsgBindProgramFragment(gPFTexNearest);
Jason Samsb52dfa02009-10-14 20:16:14 -0700381 draw_home_button();
Jason Sams60a55bb2010-06-18 15:11:19 -0700382 return (g_PosVelocity != 0) || rsFrac(g_PosPage) || g_Zoom != gZoomTarget || (g_MoveToTime != 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700383}
384
Jason Sams14f67ed2010-05-11 14:02:43 -0700385