blob: b07e1fe8a6093c80a5d15fe4022a6f52694f1bf1 [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 {
Jason Sams14f67ed2010-05-11 14:02:43 -070031 float4 Position;
32 float4 ScaleOffset;
33 float2 BendPos;
34 float2 ImgSize;
35} VpConsts_t;
36VpConsts_t *vpConstants;
37
38
Jason Sams60a55bb2010-06-18 15:11:19 -070039#pragma rs export_var(COLUMNS_PER_PAGE_PORTRAIT, ROWS_PER_PAGE_PORTRAIT, COLUMNS_PER_PAGE_LANDSCAPE, ROWS_PER_PAGE_LANDSCAPE, gIconCount, gSelectedIconIndex, gSelectedIconTexture, gHomeButton, gTargetPos, gPFTexNearest, gPFTexMip, gPFTexMipAlpha, gPVCurve, gPS, gSMCell, gIconIDs, gLabelIDs, vpConstants)
40#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;
49static float 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
68// Drawing constants, should be parameters ======
69#define VIEW_ANGLE 1.28700222f
70
Jason Sams0f505e52009-10-13 17:18:35 -070071
Jason Sams14f67ed2010-05-11 14:02:43 -070072static void updateReadback() {
Jason Samsad1bdf02010-05-14 17:54:50 -070073 if ((g_OldPosPage != g_PosPage) ||
74 (g_OldPosVelocity != g_PosVelocity) ||
75 (g_OldZoom != g_Zoom)) {
Jason Sams0f505e52009-10-13 17:18:35 -070076
77 g_OldPosPage = g_PosPage;
78 g_OldPosVelocity = g_PosVelocity;
79 g_OldZoom = g_Zoom;
80
81 int i[3];
82 i[0] = g_PosPage * (1 << 16);
83 i[1] = g_PosVelocity * (1 << 16);
84 i[2] = g_OldZoom * (1 << 16);
Jason Sams500d36e2010-07-28 11:15:33 -070085 rsSendToClientBlocking(1, &i[0], sizeof(i));
Jason Samsad1bdf02010-05-14 17:54:50 -070086 }
Jason Sams0f505e52009-10-13 17:18:35 -070087}
88
Jason Sams0f505e52009-10-13 17:18:35 -070089void init() {
Jason Sams41b61c82009-10-15 15:40:54 -070090}
Jason Sams0f505e52009-10-13 17:18:35 -070091
Jason Sams60a55bb2010-06-18 15:11:19 -070092void move(float newPos) {
Jason Sams0f505e52009-10-13 17:18:35 -070093 if (g_LastTouchDown) {
Jason Sams60a55bb2010-06-18 15:11:19 -070094 float dx = -(newPos - g_LastPositionX);
Jason Sams0f505e52009-10-13 17:18:35 -070095 g_PosVelocity = 0;
Jason Sams6ec11bc2010-01-19 17:56:52 -080096 g_PosPage += dx * 5.2f;
Jason Sams0f505e52009-10-13 17:18:35 -070097
Jason Samsc8514792009-10-29 14:27:29 -070098 float pmin = -0.49f;
99 float pmax = g_PosMax + 0.49f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700100 g_PosPage = clamp(g_PosPage, pmin, pmax);
Jason Sams0f505e52009-10-13 17:18:35 -0700101 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700102 g_LastTouchDown = true;
103 g_LastPositionX = newPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700104 g_MoveToTime = 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700105}
106
Jason Sams60a55bb2010-06-18 15:11:19 -0700107void moveTo(float targetPos) {
108 gTargetPos = targetPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700109 g_MoveToTime = g_MoveToTotalTime;
110 g_PosVelocity = 0;
111 g_MoveToOldPos = g_PosPage;
112}
113
Jason Sams60a55bb2010-06-18 15:11:19 -0700114void setZoom(float z, /*bool*/ int animate) {
115 gZoomTarget = z;
116 if (gZoomTarget < 0.001f) {
117 gZoomTarget = 0;
118 }
119 if (!animate) {
120 g_Zoom = gZoomTarget;
121 }
Joe Onorato3a8820b2009-11-10 15:06:42 -0800122 updateReadback();
123}
124
Jason Sams60a55bb2010-06-18 15:11:19 -0700125void fling(float newPos, float vel) {
126 move(newPos);
127
128 g_LastTouchDown = false;
129 g_PosVelocity = -vel * 4;
Jason Sams14f67ed2010-05-11 14:02:43 -0700130 float av = fabs(g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700131 float minVel = 3.5f;
132
Jason Sams13a75d52010-05-19 16:38:04 -0700133 minVel *= 1.f - (fabs(rsFrac(g_PosPage + 0.5f) - 0.5f) * 0.45f);
Jason Sams0f505e52009-10-13 17:18:35 -0700134
135 if (av < minVel && av > 0.2f) {
136 if (g_PosVelocity > 0) {
137 g_PosVelocity = minVel;
138 } else {
139 g_PosVelocity = -minVel;
140 }
141 }
142
143 if (g_PosPage <= 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700144 g_PosVelocity = max(0.f, g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700145 }
146 if (g_PosPage > g_PosMax) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700147 g_PosVelocity = min(0.f, g_PosVelocity);
Jason Sams0f505e52009-10-13 17:18:35 -0700148 }
149}
150
Jason Sams14f67ed2010-05-11 14:02:43 -0700151// Interpolates values in the range 0..1 to a curve that eases in
152// and out.
153static float getInterpolation(float input) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700154 return (cos((input + 1) * PI) * 0.5f) + 0.5f;
Jason Sams0f505e52009-10-13 17:18:35 -0700155}
156
Mike Cleron7d5d7462009-10-20 14:06:00 -0700157
Jason Sams14f67ed2010-05-11 14:02:43 -0700158static void updatePos() {
Jason Sams0f505e52009-10-13 17:18:35 -0700159 if (g_LastTouchDown) {
160 return;
161 }
162
Jason Sams13a75d52010-05-19 16:38:04 -0700163 float tablePosNorm = rsFrac(g_PosPage + 0.5f);
Jason Sams0f505e52009-10-13 17:18:35 -0700164 float tablePosF = tablePosNorm * g_PhysicsTableSize;
165 int tablePosI = tablePosF;
166 float tablePosFrac = tablePosF - tablePosI;
Jason Sams14f67ed2010-05-11 14:02:43 -0700167 float accel = mix(g_AttractionTable[tablePosI],
Jason Sams0f505e52009-10-13 17:18:35 -0700168 g_AttractionTable[tablePosI + 1],
169 tablePosFrac) * g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -0700170 float friction = mix(g_FrictionTable[tablePosI],
Jason Sams2e19c052009-10-20 18:19:55 -0700171 g_FrictionTable[tablePosI + 1],
172 tablePosFrac) * g_DT;
Jason Sams0f505e52009-10-13 17:18:35 -0700173
Jason Samsc1c521e2009-10-19 14:45:45 -0700174 if (g_MoveToTime) {
Jason Samsc8514792009-10-29 14:27:29 -0700175 // New position is old posiition + (total distance) * (interpolated time)
Jason Sams14f67ed2010-05-11 14:02:43 -0700176 g_PosPage = g_MoveToOldPos + (gTargetPos - g_MoveToOldPos) * getInterpolation((g_MoveToTotalTime - g_MoveToTime) / g_MoveToTotalTime);
Jason Samsc1c521e2009-10-19 14:45:45 -0700177 g_MoveToTime -= g_DT;
178 if (g_MoveToTime <= 0) {
179 g_MoveToTime = 0;
Jason Sams14f67ed2010-05-11 14:02:43 -0700180 g_PosPage = gTargetPos;
Jason Samsc1c521e2009-10-19 14:45:45 -0700181 }
182 return;
183 }
184
Jason Sams0f505e52009-10-13 17:18:35 -0700185 // If our velocity is low OR acceleration is opposing it, apply it.
Jason Sams14f67ed2010-05-11 14:02:43 -0700186 if (fabs(g_PosVelocity) < 4.0f || (g_PosVelocity * accel) < 0) {
Jason Sams0f505e52009-10-13 17:18:35 -0700187 g_PosVelocity += accel;
188 }
Jason Sams13a75d52010-05-19 16:38:04 -0700189 //RS_DEBUG(g_PosPage);
190 //RS_DEBUG(g_PosVelocity);
191 //RS_DEBUG(friction);
192 //RS_DEBUG(accel);
Jason Sams0f505e52009-10-13 17:18:35 -0700193
Jason Samsc8514792009-10-29 14:27:29 -0700194 // Normal physics
195 if (g_PosVelocity > 0) {
196 g_PosVelocity -= friction;
Jason Sams14f67ed2010-05-11 14:02:43 -0700197 g_PosVelocity = max(g_PosVelocity, 0.f);
Jason Samsc8514792009-10-29 14:27:29 -0700198 } else {
199 g_PosVelocity += friction;
Jason Sams14f67ed2010-05-11 14:02:43 -0700200 g_PosVelocity = min(g_PosVelocity, 0.f);
Jason Samsc8514792009-10-29 14:27:29 -0700201 }
202
Jason Sams14f67ed2010-05-11 14:02:43 -0700203 if ((friction > fabs(g_PosVelocity)) && (friction > fabs(accel))) {
Jason Sams0f505e52009-10-13 17:18:35 -0700204 // Special get back to center and overcome friction physics.
205 float t = tablePosNorm - 0.5f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700206 if (fabs(t) < (friction * g_DT)) {
Jason Sams0f505e52009-10-13 17:18:35 -0700207 // really close, just snap
Jason Sams14f67ed2010-05-11 14:02:43 -0700208 g_PosPage = round(g_PosPage);
Jason Sams0f505e52009-10-13 17:18:35 -0700209 g_PosVelocity = 0;
210 } else {
211 if (t > 0) {
212 g_PosVelocity = -friction;
213 } else {
214 g_PosVelocity = friction;
215 }
216 }
Jason Sams0f505e52009-10-13 17:18:35 -0700217 }
Jason Sams0f505e52009-10-13 17:18:35 -0700218
219 // Check for out of boundry conditions.
220 if (g_PosPage < 0 && g_PosVelocity < 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700221 float damp = 1.0f + (g_PosPage * 4);
222 damp = clamp(damp, 0.f, 0.9f);
Jason Sams0f505e52009-10-13 17:18:35 -0700223 g_PosVelocity *= damp;
224 }
225 if (g_PosPage > g_PosMax && g_PosVelocity > 0) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700226 float damp = 1.0f - ((g_PosPage - g_PosMax) * 4);
227 damp = clamp(damp, 0.f, 0.9f);
Jason Sams0f505e52009-10-13 17:18:35 -0700228 g_PosVelocity *= damp;
229 }
Jason Samsc8514792009-10-29 14:27:29 -0700230
231 g_PosPage += g_PosVelocity * g_DT;
Jason Sams14f67ed2010-05-11 14:02:43 -0700232 g_PosPage = clamp(g_PosPage, -0.49f, g_PosMax + 0.49f);
Jason Sams0f505e52009-10-13 17:18:35 -0700233}
234
Jason Sams14f67ed2010-05-11 14:02:43 -0700235static void
Jason Sams0f505e52009-10-13 17:18:35 -0700236draw_home_button()
237{
Jason Sams13a75d52010-05-19 16:38:04 -0700238 rsgBindTexture(gPFTexNearest, 0, gHomeButton);
Jason Sams0f505e52009-10-13 17:18:35 -0700239
Jason Sams13a75d52010-05-19 16:38:04 -0700240 float w = rsgGetWidth();
241 float h = rsgGetHeight();
242 float tw = rsAllocationGetDimX(gHomeButton);
243 float th = rsAllocationGetDimY(gHomeButton);
Jason Sams76512482010-02-04 16:31:35 -0800244
245 float x;
246 float y;
Jason Sams13a75d52010-05-19 16:38:04 -0700247 if (w > h) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700248 x = w - (tw * (1 - g_Animation)) + 20;
249 y = (h - th) * 0.5f;
Jason Sams76512482010-02-04 16:31:35 -0800250 } else {
Jason Sams14f67ed2010-05-11 14:02:43 -0700251 x = (w - tw) / 2;
252 y = -g_Animation * th;
Jason Sams76512482010-02-04 16:31:35 -0800253 y -= 30; // move the house to the edge of the screen as it doesn't fill the texture.
254 }
255
Jason Sams13a75d52010-05-19 16:38:04 -0700256 rsgDrawSpriteScreenspace(x, y, 0, tw, th);
Jason Sams0f505e52009-10-13 17:18:35 -0700257}
258
Jason Sams14f67ed2010-05-11 14:02:43 -0700259static void drawFrontGrid(float rowOffset, float p)
Jason Sams0f505e52009-10-13 17:18:35 -0700260{
Jason Sams13a75d52010-05-19 16:38:04 -0700261 float h = rsgGetHeight();
262 float w = rsgGetWidth();
Jason Sams0f505e52009-10-13 17:18:35 -0700263
264 int intRowOffset = rowOffset;
265 float rowFrac = rowOffset - intRowOffset;
Jason Sams13a75d52010-05-19 16:38:04 -0700266 float colWidth = 120.f;//w / 4;
Jason Sams0f505e52009-10-13 17:18:35 -0700267 float rowHeight = colWidth + 25.f;
Jason Samsb4ecab22010-01-19 16:43:26 -0800268 float yoff = 0.5f * h + 1.5f * rowHeight;
Jason Sams0f505e52009-10-13 17:18:35 -0700269
270 int row, col;
Jason Sams76512482010-02-04 16:31:35 -0800271 int colCount = 4;
272 if (w > h) {
273 colCount = 6;
274 rowHeight -= 12.f;
275 yoff = 0.47f * h + 1.0f * rowHeight;
276 }
277
278 int iconNum = (intRowOffset - 5) * colCount;
279
Jason Sams13a75d52010-05-19 16:38:04 -0700280 rsgBindProgramVertex(gPVCurve);
Jason Samsb4ecab22010-01-19 16:43:26 -0800281
Jason Sams76512482010-02-04 16:31:35 -0800282 vpConstants->Position.z = p;
Jason Samsb4ecab22010-01-19 16:43:26 -0800283
284 for (row = -5; row < 15; row++) {
Jason Sams0f505e52009-10-13 17:18:35 -0700285 float y = yoff - ((-rowFrac + row) * rowHeight);
286
Jason Sams76512482010-02-04 16:31:35 -0800287 for (col=0; col < colCount; col++) {
Jason Sams14f67ed2010-05-11 14:02:43 -0700288 if (iconNum >= gIconCount) {
Jason Sams0f505e52009-10-13 17:18:35 -0700289 return;
290 }
291
292 if (iconNum >= 0) {
Jason Samsb4ecab22010-01-19 16:43:26 -0800293 float x = colWidth * col + (colWidth / 2);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800294 vpConstants->Position.x = x + 0.2f;
Jason Sams1a94ee32010-01-20 13:34:30 -0800295
Jason Samsf0d03e42010-08-13 12:18:01 -0700296 if (gSelectedIconIndex == iconNum && !p && rsIsObject(gSelectedIconTexture)) {
Jason Sams13a75d52010-05-19 16:38:04 -0700297 rsgBindProgramFragment(gPFTexNearest);
298 rsgBindTexture(gPFTexNearest, 0, gSelectedIconTexture);
299 vpConstants->ImgSize.x = rsAllocationGetDimX(gSelectedIconTexture);
300 vpConstants->ImgSize.y = rsAllocationGetDimY(gSelectedIconTexture);
301 vpConstants->Position.y = y - (rsAllocationGetDimY(gSelectedIconTexture)
302 - rsAllocationGetDimY(gIconIDs[iconNum])) * 0.5f;
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700303 rsgDrawMesh(gSMCell);
Jason Sams37f262d2010-01-20 11:19:51 -0800304 }
305
Jason Sams13a75d52010-05-19 16:38:04 -0700306 rsgBindProgramFragment(gPFTexMip);
307 vpConstants->ImgSize.x = rsAllocationGetDimX(gIconIDs[iconNum]);
308 vpConstants->ImgSize.y = rsAllocationGetDimY(gIconIDs[iconNum]);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800309 vpConstants->Position.y = y - 0.2f;
Jason Sams13a75d52010-05-19 16:38:04 -0700310 rsgBindTexture(gPFTexMip, 0, gIconIDs[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);
314 vpConstants->ImgSize.x = rsAllocationGetDimX(gLabelIDs[iconNum]);
315 vpConstants->ImgSize.y = rsAllocationGetDimY(gLabelIDs[iconNum]);
Jason Sams6b08ffe2010-02-22 15:41:30 -0800316 vpConstants->Position.y = y - 64.f - 0.2f;
Jason Sams13a75d52010-05-19 16:38:04 -0700317 rsgBindTexture(gPFTexMipAlpha, 0, gLabelIDs[iconNum]);
Alex Sakhartchouk1bdb9d32010-07-01 16:08:19 -0700318 rsgDrawMesh(gSMCell);
Jason Sams0f505e52009-10-13 17:18:35 -0700319 }
320 iconNum++;
321 }
322 }
323}
324
Jason Sams0f505e52009-10-13 17:18:35 -0700325
Jason Sams14f67ed2010-05-11 14:02:43 -0700326int root()
Jason Sams0f505e52009-10-13 17:18:35 -0700327{
328 // Compute dt in seconds.
Jason Samsb52dfa02009-10-14 20:16:14 -0700329 // physics may break if DT is large.
Jason Sams500d36e2010-07-28 11:15:33 -0700330 g_DT = min(rsGetDt(), 0.1f);
Jason Sams0f505e52009-10-13 17:18:35 -0700331
Jason Sams14f67ed2010-05-11 14:02:43 -0700332 if (g_Zoom != gZoomTarget) {
Jason Sams6471c8b2010-01-20 14:15:22 -0800333 float dz = g_DT * 1.7f;
Jason Sams14f67ed2010-05-11 14:02:43 -0700334 if (gZoomTarget < 0.5f) {
Jason Sams6471c8b2010-01-20 14:15:22 -0800335 dz = -dz;
Jason Sams0f505e52009-10-13 17:18:35 -0700336 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700337 if (fabs(g_Zoom - gZoomTarget) < fabs(dz)) {
338 g_Zoom = gZoomTarget;
Jason Sams0f505e52009-10-13 17:18:35 -0700339 } else {
340 g_Zoom += dz;
341 }
342 updateReadback();
343 }
Jason Sams14f67ed2010-05-11 14:02:43 -0700344 g_Animation = pow(1.f - g_Zoom, 3.f);
Jason Sams0f505e52009-10-13 17:18:35 -0700345
346 // Set clear value to dim the background based on the zoom position.
Jason Samsad1bdf02010-05-14 17:54:50 -0700347 if ((g_Zoom < 0.001f) && (gZoomTarget < 0.001f)) {
Jason Sams13a75d52010-05-19 16:38:04 -0700348 rsgClearColor(0.0f, 0.0f, 0.0f, 0.0f);
Jason Sams0f505e52009-10-13 17:18:35 -0700349 // When we're zoomed out and not tracking motion events, reset the pos to 0.
350 if (!g_LastTouchDown) {
351 g_PosPage = 0;
352 }
Jason Sams60a55bb2010-06-18 15:11:19 -0700353 return 0;
Jason Sams0f505e52009-10-13 17:18:35 -0700354 } else {
Jason Sams13a75d52010-05-19 16:38:04 -0700355 rsgClearColor(0.0f, 0.0f, 0.0f, g_Zoom);
Jason Sams0f505e52009-10-13 17:18:35 -0700356 }
357
Jason Sams13a75d52010-05-19 16:38:04 -0700358 rsgBindProgramStore(gPS);
359
Jason Sams0f505e52009-10-13 17:18:35 -0700360 // icons & labels
Jason Sams13a75d52010-05-19 16:38:04 -0700361 if (rsgGetWidth() > rsgGetHeight()) {
Jason Samsad1bdf02010-05-14 17:54:50 -0700362 g_Cols = COLUMNS_PER_PAGE_LANDSCAPE;
363 g_Rows = ROWS_PER_PAGE_LANDSCAPE;
Joe Onorato20e7a562010-03-18 17:12:52 -0700364 } else {
Jason Samsad1bdf02010-05-14 17:54:50 -0700365 g_Cols = COLUMNS_PER_PAGE_PORTRAIT;
366 g_Rows = ROWS_PER_PAGE_PORTRAIT;
Jason Samscc903492010-03-12 12:46:04 -0800367 }
Jason Samsad1bdf02010-05-14 17:54:50 -0700368
Jason Sams14f67ed2010-05-11 14:02:43 -0700369 g_PosMax = ((gIconCount + (g_Cols-1)) / g_Cols) - g_Rows;
Jason Sams0f505e52009-10-13 17:18:35 -0700370 if (g_PosMax < 0) g_PosMax = 0;
371
Jason Samscc903492010-03-12 12:46:04 -0800372 updatePos();
Jason Sams0f505e52009-10-13 17:18:35 -0700373 updateReadback();
374
Jason Sams0f505e52009-10-13 17:18:35 -0700375 // Draw the icons ========================================
Jason Sams6471c8b2010-01-20 14:15:22 -0800376 drawFrontGrid(g_PosPage, g_Animation);
Jason Samsc8514792009-10-29 14:27:29 -0700377
Jason Sams13a75d52010-05-19 16:38:04 -0700378 rsgBindProgramFragment(gPFTexNearest);
Jason Samsb52dfa02009-10-14 20:16:14 -0700379 draw_home_button();
Jason Sams60a55bb2010-06-18 15:11:19 -0700380 return (g_PosVelocity != 0) || rsFrac(g_PosPage) || g_Zoom != gZoomTarget || (g_MoveToTime != 0);
Jason Sams0f505e52009-10-13 17:18:35 -0700381}
382
Jason Sams14f67ed2010-05-11 14:02:43 -0700383