summaryrefslogtreecommitdiff
path: root/apps/plugins/chopper.c
diff options
context:
space:
mode:
authorDave Chapman <dave@dchapman.com>2007-02-20 00:40:21 +0000
committerDave Chapman <dave@dchapman.com>2007-02-20 00:40:21 +0000
commit329b4bda82806219434a0e7127c3188eb068b5d3 (patch)
tree3fbb257aa04f81a12dfb0891164658d9aaef065a /apps/plugins/chopper.c
parente423c0b85a3e6778229571c632ffb60716d2a17d (diff)
downloadrockbox-329b4bda82806219434a0e7127c3188eb068b5d3.tar.gz
rockbox-329b4bda82806219434a0e7127c3188eb068b5d3.zip
Scale to 50% size on the Archos devices (LCD_WIDTH <= 112) and slow it down, with some tweaks from Marianne Arnold. Plus replace a few floating point operations with integers.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12406 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps/plugins/chopper.c')
-rw-r--r--apps/plugins/chopper.c75
1 files changed, 50 insertions, 25 deletions
diff --git a/apps/plugins/chopper.c b/apps/plugins/chopper.c
index 1fec7bb1ab..941f139414 100644
--- a/apps/plugins/chopper.c
+++ b/apps/plugins/chopper.c
@@ -92,7 +92,15 @@ static struct plugin_api* rb;
92#define LEVEL_MODE_NORMAL 0 92#define LEVEL_MODE_NORMAL 0
93#define LEVEL_MODE_STEEP 1 93#define LEVEL_MODE_STEEP 1
94 94
95#if LCD_WIDTH <= 112
96#define CYCLETIME 100
97#define SCALE(x) ((x)==1 ? (x) : ((x) >> 1))
98#define SIZE 2
99#else
95#define CYCLETIME 60 100#define CYCLETIME 60
101#define SCALE(x) (x)
102#define SIZE 1
103#endif
96 104
97/*Chopper's local variables to track the terrain position etc*/ 105/*Chopper's local variables to track the terrain position etc*/
98static int chopCounter; 106static int chopCounter;
@@ -175,30 +183,30 @@ static void chopDrawPlayer(int x,int y) /* These are SCREEN coords, not world! *
175#elif LCD_DEPTH == 2 183#elif LCD_DEPTH == 2
176 rb->lcd_set_foreground(LCD_DARKGRAY); 184 rb->lcd_set_foreground(LCD_DARKGRAY);
177#endif 185#endif
178 rb->lcd_fillrect(x+6, y+2, 12, 9); 186 rb->lcd_fillrect(SCALE(x+6), SCALE(y+2), SCALE(12), SCALE(9));
179 rb->lcd_fillrect(x-3, y+6, 20, 3); 187 rb->lcd_fillrect(SCALE(x-3), SCALE(y+6), SCALE(20), SCALE(3));
180 188
181#if LCD_DEPTH > 2 189#if LCD_DEPTH > 2
182 rb->lcd_set_foreground(LCD_RGBPACK(50,50,50)); 190 rb->lcd_set_foreground(LCD_RGBPACK(50,50,50));
183#elif LCD_DEPTH == 2 191#elif LCD_DEPTH == 2
184 rb->lcd_set_foreground(LCD_DARKGRAY); 192 rb->lcd_set_foreground(LCD_DARKGRAY);
185#endif 193#endif
186 rb->lcd_fillrect(x+10, y, 2, 3); 194 rb->lcd_fillrect(SCALE(x+10), SCALE(y), SCALE(2), SCALE(3));
187 rb->lcd_fillrect(x+10, y, 1, 3); 195 rb->lcd_fillrect(SCALE(x+10), SCALE(y), SCALE(1), SCALE(3));
188 196
189#if LCD_DEPTH > 2 197#if LCD_DEPTH > 2
190 rb->lcd_set_foreground(LCD_RGBPACK(40,40,100)); 198 rb->lcd_set_foreground(LCD_RGBPACK(40,40,100));
191#elif LCD_DEPTH == 2 199#elif LCD_DEPTH == 2
192 rb->lcd_set_foreground(LCD_BLACK); 200 rb->lcd_set_foreground(LCD_BLACK);
193#endif 201#endif
194 rb->lcd_drawline(x, y+iRotorOffset, x+20, y-iRotorOffset); 202 rb->lcd_drawline(SCALE(x), SCALE(y+iRotorOffset), SCALE(x+20), SCALE(y-iRotorOffset));
195 203
196#if LCD_DEPTH > 2 204#if LCD_DEPTH > 2
197 rb->lcd_set_foreground(LCD_RGBPACK(20,20,50)); 205 rb->lcd_set_foreground(LCD_RGBPACK(20,20,50));
198#elif LCD_DEPTH == 2 206#elif LCD_DEPTH == 2
199 rb->lcd_set_foreground(LCD_BLACK); 207 rb->lcd_set_foreground(LCD_BLACK);
200#endif 208#endif
201 rb->lcd_fillrect(x - 2, y + 5, 2, 5); 209 rb->lcd_fillrect(SCALE(x - 2), SCALE(y + 5), SCALE(2), SCALE(5));
202 210
203} 211}
204 212
@@ -564,7 +572,7 @@ static void chopDrawParticle(struct CParticle *mParticle)
564#elif LCD_DEPTH == 2 572#elif LCD_DEPTH == 2
565 rb->lcd_set_foreground(LCD_LIGHTGRAY); 573 rb->lcd_set_foreground(LCD_LIGHTGRAY);
566#endif 574#endif
567 rb->lcd_fillrect(iPosX, iPosY, 3, 3); 575 rb->lcd_fillrect(SCALE(iPosX), SCALE(iPosY), SCALE(3), SCALE(3));
568 576
569} 577}
570 578
@@ -583,17 +591,32 @@ static void chopDrawScene(void)
583 chopDrawPlayer(iPlayerPosX - iCameraPosX, iPlayerPosY); 591 chopDrawPlayer(iPlayerPosX - iCameraPosX, iPlayerPosY);
584 592
585 score = -20 + iPlayerPosX/3; 593 score = -20 + iPlayerPosX/3;
594
595#if LCD_DEPTH == 1
596 rb->lcd_set_drawmode(DRMODE_COMPLEMENT);
597#else
586 rb->lcd_set_drawmode(DRMODE_FG); 598 rb->lcd_set_drawmode(DRMODE_FG);
599#endif
600
587#if LCD_DEPTH > 2 601#if LCD_DEPTH > 2
588 rb->lcd_set_foreground(LCD_BLACK); 602 rb->lcd_set_foreground(LCD_BLACK);
589#elif LCD_DEPTH == 2 603#elif LCD_DEPTH == 2
590 rb->lcd_set_foreground(LCD_WHITE); 604 rb->lcd_set_foreground(LCD_WHITE);
591#endif 605#endif
606
607#if LCD_WIDTH <= 128
608 rb->snprintf(s, sizeof(s), "Dist: %d", score);
609 rb->lcd_putsxy(1, 1, s);
610 rb->snprintf(s, sizeof(s), "Hi: %d", highscore);
611 rb->lcd_getstringsize(s, &w, NULL);
612 rb->lcd_putsxy(LCD_WIDTH - 1 - w, 1, s);
613#else
592 rb->snprintf(s, sizeof(s), "Distance: %d", score); 614 rb->snprintf(s, sizeof(s), "Distance: %d", score);
593 rb->lcd_putsxy(2, 2, s); 615 rb->lcd_putsxy(2, 2, s);
594 rb->snprintf(s, sizeof(s), "Best: %d", highscore); 616 rb->snprintf(s, sizeof(s), "Best: %d", highscore);
595 rb->lcd_getstringsize(s, &w, NULL); 617 rb->lcd_getstringsize(s, &w, NULL);
596 rb->lcd_putsxy(LCD_WIDTH - 2 - w, 2, s); 618 rb->lcd_putsxy(LCD_WIDTH - 2 - w, 2, s);
619#endif
597 rb->lcd_set_drawmode(DRMODE_SOLID); 620 rb->lcd_set_drawmode(DRMODE_SOLID);
598 621
599 rb->lcd_update(); 622 rb->lcd_update();
@@ -674,7 +697,7 @@ static int chopGameLoop(void)
674 697
675 if (chopUpdateTerrainRecycling(&mGround) == 1) 698 if (chopUpdateTerrainRecycling(&mGround) == 1)
676 /* mirror the sky if we've changed the ground */ 699 /* mirror the sky if we've changed the ground */
677 chopCopyTerrain(&mGround, &mRoof, 0, -( iScreenY * 0.75)); 700 chopCopyTerrain(&mGround, &mRoof, 0, - ( (iScreenY * 3) / 4));
678 701
679 ret = chopMenu(0); 702 ret = chopMenu(0);
680 if (ret != -1) 703 if (ret != -1)
@@ -688,7 +711,7 @@ static int chopGameLoop(void)
688 711
689 if(chopUpdateTerrainRecycling(&mGround) == 1) 712 if(chopUpdateTerrainRecycling(&mGround) == 1)
690 /* mirror the sky if we've changed the ground */ 713 /* mirror the sky if we've changed the ground */
691 chopCopyTerrain(&mGround, &mRoof, 0, -( iScreenY * 0.75)); 714 chopCopyTerrain(&mGround, &mRoof, 0, - ( (iScreenY * 3) / 4));
692 715
693 iRotorOffset = iR(-1,1); 716 iRotorOffset = iR(-1,1);
694 717
@@ -816,8 +839,8 @@ static void chopDrawBlock(struct CBlock *mBlock)
816#elif LCD_DEPTH == 2 839#elif LCD_DEPTH == 2
817 rb->lcd_set_foreground(LCD_BLACK); 840 rb->lcd_set_foreground(LCD_BLACK);
818#endif 841#endif
819 rb->lcd_fillrect(iPosX, iPosY, mBlock->iSizeX, 842 rb->lcd_fillrect(SCALE(iPosX), SCALE(iPosY), SCALE(mBlock->iSizeX),
820 mBlock->iSizeY); 843 SCALE(mBlock->iSizeY));
821} 844}
822 845
823 846
@@ -829,12 +852,12 @@ static void chopRenderTerrain(struct CTerrain *ter)
829 int oldx=0; 852 int oldx=0;
830 853
831 int ay=0; 854 int ay=0;
832 if(ter->mNodes[0].y < LCD_HEIGHT/2) 855 if(ter->mNodes[0].y < (LCD_HEIGHT*SIZE)/2)
833 ay=0; 856 ay=0;
834 else 857 else
835 ay=LCD_HEIGHT; 858 ay=(LCD_HEIGHT*SIZE);
836 859
837 while(i < ter->iNodesCount && oldx < LCD_WIDTH) 860 while(i < ter->iNodesCount && oldx < iScreenX)
838 { 861 {
839 862
840 int x = ter->mNodes[i-1].x - iCameraPosX; 863 int x = ter->mNodes[i-1].x - iCameraPosX;
@@ -848,13 +871,15 @@ static void chopRenderTerrain(struct CTerrain *ter)
848 rb->lcd_set_foreground(LCD_DARKGRAY); 871 rb->lcd_set_foreground(LCD_DARKGRAY);
849#endif 872#endif
850 873
851 rb->lcd_drawline(x, y, x2, y2); 874 rb->lcd_drawline(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2));
852 xlcd_filltriangle(x, y, x2, y2, x2, ay); 875
853 xlcd_filltriangle(x, ay, x2, y2, x2, ay); 876 xlcd_filltriangle(SCALE(x), SCALE(y), SCALE(x2), SCALE(y2), SCALE(x2), SCALE(ay));
877 xlcd_filltriangle(SCALE(x), SCALE(ay), SCALE(x2), SCALE(y2), SCALE(x2), SCALE(ay));
878
854 if (ay == 0) 879 if (ay == 0)
855 xlcd_filltriangle(x, ay, x, y, x2, y2 / 2); 880 xlcd_filltriangle(SCALE(x), SCALE(ay), SCALE(x), SCALE(y), SCALE(x2), SCALE(y2 / 2));
856 else 881 else
857 xlcd_filltriangle(x, ay, x, y, x2, LCD_HEIGHT - (LCD_HEIGHT - y2) / 2); 882 xlcd_filltriangle(SCALE(x), SCALE(ay), SCALE(x), SCALE(y), SCALE(x2), SCALE((LCD_HEIGHT*SIZE) - ((LCD_HEIGHT*SIZE) - y2) / 2));
858 883
859 oldx = x; 884 oldx = x;
860 i++; 885 i++;
@@ -870,16 +895,16 @@ void chopper_load(bool newgame)
870 int g; 895 int g;
871 896
872 if (newgame) { 897 if (newgame) {
873 iScreenX = LCD_WIDTH; 898 iScreenX = LCD_WIDTH * SIZE;
874 iScreenY = LCD_HEIGHT; 899 iScreenY = LCD_HEIGHT * SIZE;
875 blockh = 0.2*iScreenY; 900 blockh = iScreenY / 5;
876 blockw = 0.04*iScreenX; 901 blockw = iScreenX / 20;
877 iPlayerAlive = 1; 902 iPlayerAlive = 1;
878 score = 0; 903 score = 0;
879 } 904 }
880 iRotorOffset = 0; 905 iRotorOffset = 0;
881 iPlayerPosX = 60; 906 iPlayerPosX = 60;
882 iPlayerPosY = iScreenY * 0.4; 907 iPlayerPosY = (iScreenY * 4) / 10;
883 iLastBlockPlacedPosX = 0; 908 iLastBlockPlacedPosX = 0;
884 iGravityTimerCountdown = 2; 909 iGravityTimerCountdown = 2;
885 chopCounter = 0; 910 chopCounter = 0;
@@ -901,7 +926,7 @@ void chopper_load(bool newgame)
901 926
902 if (chopUpdateTerrainRecycling(&mGround) == 1) 927 if (chopUpdateTerrainRecycling(&mGround) == 1)
903 /* mirror the sky if we've changed the ground */ 928 /* mirror the sky if we've changed the ground */
904 chopCopyTerrain(&mGround, &mRoof, 0, -( iScreenY * 0.75)); 929 chopCopyTerrain(&mGround, &mRoof, 0, - ( (iScreenY * 3) / 4));
905 930
906 iLevelMode = LEVEL_MODE_NORMAL; 931 iLevelMode = LEVEL_MODE_NORMAL;
907 if (iLevelMode == LEVEL_MODE_NORMAL) 932 if (iLevelMode == LEVEL_MODE_NORMAL)