summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomer Shalev <shalev.tomer@gmail.com>2010-02-19 07:36:56 +0000
committerTomer Shalev <shalev.tomer@gmail.com>2010-02-19 07:36:56 +0000
commit320eab69d3cfb692fd5dc30e875fc72e9131e843 (patch)
tree6884cedfd021cbbd790b2215bb2994951f198765
parentac9f850b7d5e37d0e42e78f4c53aa4487721f6e3 (diff)
downloadrockbox-320eab69d3cfb692fd5dc30e875fc72e9131e843.tar.gz
rockbox-320eab69d3cfb692fd5dc30e875fc72e9131e843.zip
Brickmania: Remove spaces at the end of line
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@24769 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/plugins/brickmania.c302
1 files changed, 151 insertions, 151 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c
index bc5ca34a33..cdb2545572 100644
--- a/apps/plugins/brickmania.c
+++ b/apps/plugins/brickmania.c
@@ -34,8 +34,8 @@ PLUGIN_HEADER
34/* If there are three fractional bits, the smallest screen size that will scale 34/* If there are three fractional bits, the smallest screen size that will scale
35 * properly is 28x22. If you have a smaller screen increase the fractional 35 * properly is 28x22. If you have a smaller screen increase the fractional
36 * precision. If you have a precision of 4 the smallest screen size would be 36 * precision. If you have a precision of 4 the smallest screen size would be
37 * 14x11. Note though that this will decrease the maximum resolution due to 37 * 14x11. Note though that this will decrease the maximum resolution due to
38 * the line intersection tests. These defines are used for all of the fixed 38 * the line intersection tests. These defines are used for all of the fixed
39 * point calculations/conversions. 39 * point calculations/conversions.
40 */ 40 */
41#define FIXED3(x) ((x)<<3) 41#define FIXED3(x) ((x)<<3)
@@ -328,12 +328,12 @@ CONFIG_KEYPAD == SANSA_M200_PAD
328#define SPEED_SCALE_W(x) FIXED3_DIV(GAMESCREEN_WIDTH, FIXED3(220)/(x) ) 328#define SPEED_SCALE_W(x) FIXED3_DIV(GAMESCREEN_WIDTH, FIXED3(220)/(x) )
329 329
330/* These are all used as ball speeds depending on where the ball hit the 330/* These are all used as ball speeds depending on where the ball hit the
331 * paddle. 331 * paddle.
332 * 332 *
333 * Note that all of these speeds (including pad, power, and fire) 333 * Note that all of these speeds (including pad, power, and fire)
334 * could be made variable and could be raised to be much higher to add 334 * could be made variable and could be raised to be much higher to add
335 * additional difficulty to the game. The line intersection tests allow this 335 * additional difficulty to the game. The line intersection tests allow this
336 * to be drastically increased without the collision detection failing 336 * to be drastically increased without the collision detection failing
337 * (ideally). 337 * (ideally).
338 */ 338 */
339#define SPEED_1Q_X SPEED_SCALE_W( 6) 339#define SPEED_1Q_X SPEED_SCALE_W( 6)
@@ -809,7 +809,7 @@ int flip_sides_delay;
809bool resume = false; 809bool resume = false;
810bool resume_file = false; 810bool resume_file = false;
811 811
812typedef struct cube 812typedef struct cube
813{ 813{
814 int powertop; /* Stores the powerup Y top pos, it is a fixed point num */ 814 int powertop; /* Stores the powerup Y top pos, it is a fixed point num */
815 int power; /* What powerup is in the brick? */ 815 int power; /* What powerup is in the brick? */
@@ -821,7 +821,7 @@ typedef struct cube
821} cube; 821} cube;
822cube brick[NUM_BRICKS_ROWS * NUM_BRICKS_COLS]; 822cube brick[NUM_BRICKS_ROWS * NUM_BRICKS_COLS];
823 823
824typedef struct balls 824typedef struct balls
825{ 825{
826 /* pos_x and y store the current center position of the ball */ 826 /* pos_x and y store the current center position of the ball */
827 int pos_x; 827 int pos_x;
@@ -856,41 +856,41 @@ static struct configdata config[] = {
856 856
857struct highscore highest[NUM_SCORES]; 857struct highscore highest[NUM_SCORES];
858 858
859typedef struct point 859typedef struct point
860{ 860{
861 int x; 861 int x;
862 int y; 862 int y;
863} point; 863} point;
864 864
865typedef struct line 865typedef struct line
866{ 866{
867 point p1; 867 point p1;
868 point p2; 868 point p2;
869} line; 869} line;
870 870
871/* 871/*
872 * check_lines: 872 * check_lines:
873 * This is based off an explanation and expanded math presented by Paul Bourke: 873 * This is based off an explanation and expanded math presented by Paul Bourke:
874 * http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/ 874 * http://local.wasp.uwa.edu.au/~pbourke/geometry/lineline2d/
875 * 875 *
876 * It takes two lines as inputs and returns 1 if they intersect, 0 if they do 876 * It takes two lines as inputs and returns 1 if they intersect, 0 if they do
877 * not. hitp returns the point where the two lines intersected. 877 * not. hitp returns the point where the two lines intersected.
878 * 878 *
879 * This function expects fixed point inputs with a precision of 3. When a 879 * This function expects fixed point inputs with a precision of 3. When a
880 * collision occurs hitp is updated with a fixed point location (precision 3) 880 * collision occurs hitp is updated with a fixed point location (precision 3)
881 * where the collision happened. The internal calculations are fixed 881 * where the collision happened. The internal calculations are fixed
882 * point with a 7 bit fractional precision. 882 * point with a 7 bit fractional precision.
883 * 883 *
884 * If you choose 10 bits of precision a screen size of about 640x480 is the 884 * If you choose 10 bits of precision a screen size of about 640x480 is the
885 * largest this can go. 7 bits allows for an accurate intersection calculation 885 * largest this can go. 7 bits allows for an accurate intersection calculation
886 * with a line length of about 64 and a rougher line lenght of 128 which is 886 * with a line length of about 64 and a rougher line lenght of 128 which is
887 * larger than any target currently needs (the pad is the longest line and it 887 * larger than any target currently needs (the pad is the longest line and it
888 * only needs an accuracy of 2^4 at most to figure out which section of the pad 888 * only needs an accuracy of 2^4 at most to figure out which section of the pad
889 * the ball hit). A precision of 7 gives breathing room for larger screens. 889 * the ball hit). A precision of 7 gives breathing room for larger screens.
890 * Longer line sizes that need accurate intersection points will need more 890 * Longer line sizes that need accurate intersection points will need more
891 * precision, but will decrease the maximum screen resolution. 891 * precision, but will decrease the maximum screen resolution.
892 */ 892 */
893 893
894#define LINE_PREC 7 894#define LINE_PREC 7
895int check_lines(line *line1, line *line2, point *hitp) 895int check_lines(line *line1, line *line2, point *hitp)
896{ 896{
@@ -906,13 +906,13 @@ int check_lines(line *line1, line *line2, point *hitp)
906 * triangle formed by each line to find a point on the line. 906 * triangle formed by each line to find a point on the line.
907 * 907 *
908 * The two equations can be expanded to their x/y components: 908 * The two equations can be expanded to their x/y components:
909 * Pa.x = p1.x + ua(p2.x - p1.x) 909 * Pa.x = p1.x + ua(p2.x - p1.x)
910 * Pa.y = p1.y + ua(p2.y - p1.y) 910 * Pa.y = p1.y + ua(p2.y - p1.y)
911 * 911 *
912 * Pb.x = p3.x + ub(p4.x - p3.x) 912 * Pb.x = p3.x + ub(p4.x - p3.x)
913 * Pb.y = p3.y + ub(p4.y - p3.y) 913 * Pb.y = p3.y + ub(p4.y - p3.y)
914 * 914 *
915 * When Pa.x == Pb.x and Pa.y == Pb.y the lines intersect so you can come 915 * When Pa.x == Pb.x and Pa.y == Pb.y the lines intersect so you can come
916 * up with two equations (one for x and one for y): 916 * up with two equations (one for x and one for y):
917 * 917 *
918 * p1.x + ua(p2.x - p1.x) = p3.x + ub(p4.x - p3.x) 918 * p1.x + ua(p2.x - p1.x) = p3.x + ub(p4.x - p3.x)
@@ -925,30 +925,30 @@ int check_lines(line *line1, line *line2, point *hitp)
925 /* Denominator for ua and ub are the same so store this calculation */ 925 /* Denominator for ua and ub are the same so store this calculation */
926 int d = FIXED3_MUL((line2->p2.y - line2->p1.y),(line1->p2.x-line1->p1.x)) 926 int d = FIXED3_MUL((line2->p2.y - line2->p1.y),(line1->p2.x-line1->p1.x))
927 -FIXED3_MUL((line2->p2.x - line2->p1.x),(line1->p2.y-line1->p1.y)); 927 -FIXED3_MUL((line2->p2.x - line2->p1.x),(line1->p2.y-line1->p1.y));
928 928
929 /* n_a and n_b are calculated as seperate values for readability */ 929 /* n_a and n_b are calculated as seperate values for readability */
930 int n_a = FIXED3_MUL((line2->p2.x - line2->p1.x),(line1->p1.y-line2->p1.y)) 930 int n_a = FIXED3_MUL((line2->p2.x - line2->p1.x),(line1->p1.y-line2->p1.y))
931 -FIXED3_MUL((line2->p2.y - line2->p1.y),(line1->p1.x-line2->p1.x)); 931 -FIXED3_MUL((line2->p2.y - line2->p1.y),(line1->p1.x-line2->p1.x));
932 932
933 int n_b = FIXED3_MUL((line1->p2.x - line1->p1.x),(line1->p1.y-line2->p1.y)) 933 int n_b = FIXED3_MUL((line1->p2.x - line1->p1.x),(line1->p1.y-line2->p1.y))
934 -FIXED3_MUL((line1->p2.y - line1->p1.y),(line1->p1.x-line2->p1.x)); 934 -FIXED3_MUL((line1->p2.y - line1->p1.y),(line1->p1.x-line2->p1.x));
935 935
936 /* Make sure there is not a division by zero - this also indicates that 936 /* Make sure there is not a division by zero - this also indicates that
937 * the lines are parallel. 937 * the lines are parallel.
938 * 938 *
939 * If n_a and n_b were both equal to zero the lines would be on top of each 939 * If n_a and n_b were both equal to zero the lines would be on top of each
940 * other (coincidental). This check is not done because it is not 940 * other (coincidental). This check is not done because it is not
941 * necessary for this implementation (the parallel check accounts for this). 941 * necessary for this implementation (the parallel check accounts for this).
942 */ 942 */
943 if(d == 0) 943 if(d == 0)
944 return 0; 944 return 0;
945 945
946 /* Calculate the intermediate fractional point that the lines potentially 946 /* Calculate the intermediate fractional point that the lines potentially
947 * intersect. 947 * intersect.
948 */ 948 */
949 int ua = (n_a << LINE_PREC)/d; 949 int ua = (n_a << LINE_PREC)/d;
950 int ub = (n_b << LINE_PREC)/d; 950 int ub = (n_b << LINE_PREC)/d;
951 951
952 /* The fractional point will be between 0 and 1 inclusive if the lines 952 /* The fractional point will be between 0 and 1 inclusive if the lines
953 * intersect. If the fractional calculation is larger than 1 or smaller 953 * intersect. If the fractional calculation is larger than 1 or smaller
954 * than 0 the lines would need to be longer to intersect. 954 * than 0 the lines would need to be longer to intersect.
@@ -968,7 +968,7 @@ static void brickmania_init_game(bool new_game)
968 968
969 pad_pos_x = GAMESCREEN_WIDTH/2 - PAD_WIDTH/2; 969 pad_pos_x = GAMESCREEN_WIDTH/2 - PAD_WIDTH/2;
970 970
971 for(i=0;i<MAX_BALLS;i++) 971 for(i=0;i<MAX_BALLS;i++)
972 { 972 {
973 ball[i].speedx = 0; 973 ball[i].speedx = 0;
974 ball[i].speedy = 0; 974 ball[i].speedy = 0;
@@ -994,12 +994,12 @@ static void brickmania_init_game(bool new_game)
994 life++; 994 life++;
995 } 995 }
996 } 996 }
997 997
998 for(i=0;i<MAX_FIRES;i++) { 998 for(i=0;i<MAX_FIRES;i++) {
999 /* No fire should be active */ 999 /* No fire should be active */
1000 fire[i].top=-1; 1000 fire[i].top=-1;
1001 } 1001 }
1002 1002
1003 for(i=0;i<NUM_BRICKS_ROWS;i++) { 1003 for(i=0;i<NUM_BRICKS_ROWS;i++) {
1004 for(j=0;j<NUM_BRICKS_COLS;j++) { 1004 for(j=0;j<NUM_BRICKS_COLS;j++) {
1005 int bnum = i*NUM_BRICKS_COLS+j; 1005 int bnum = i*NUM_BRICKS_COLS+j;
@@ -1102,7 +1102,7 @@ static void brickmania_sleep(int secs)
1102 int count=0; 1102 int count=0;
1103 int sw, w; 1103 int sw, w;
1104 1104
1105 while (!done) 1105 while (!done)
1106 { 1106 {
1107 if (count == 0) 1107 if (count == 0)
1108 count = *rb->current_tick + HZ*secs; 1108 count = *rb->current_tick + HZ*secs;
@@ -1262,7 +1262,7 @@ static int brickmania_menu(void)
1262 brickmania_init_game(true); 1262 brickmania_init_game(true);
1263 return 0; 1263 return 0;
1264 case 2: 1264 case 2:
1265 rb->set_option("Difficulty", &difficulty, INT, 1265 rb->set_option("Difficulty", &difficulty, INT,
1266 options, 2, NULL); 1266 options, 2, NULL);
1267 break; 1267 break;
1268 case 3: 1268 case 3:
@@ -1338,12 +1338,12 @@ static int brickmania_game_loop(void)
1338 char s[30]; 1338 char s[30];
1339 int sec_count=0; 1339 int sec_count=0;
1340 int end; 1340 int end;
1341 1341
1342 /* pad_line used for powerup/ball checks */ 1342 /* pad_line used for powerup/ball checks */
1343 line pad_line; 1343 line pad_line;
1344 /* This is used for various lines that are checked (ball and powerup) */ 1344 /* This is used for various lines that are checked (ball and powerup) */
1345 line misc_line; 1345 line misc_line;
1346 1346
1347 /* This stores the point that the two lines intersected in a test */ 1347 /* This stores the point that the two lines intersected in a test */
1348 point pt_hit; 1348 point pt_hit;
1349 1349
@@ -1352,7 +1352,7 @@ static int brickmania_game_loop(void)
1352 } 1352 }
1353 resume = false; 1353 resume = false;
1354 resume_file = false; 1354 resume_file = false;
1355 1355
1356#ifdef HAVE_LCD_COLOR 1356#ifdef HAVE_LCD_COLOR
1357 rb->lcd_set_background(LCD_BLACK); 1357 rb->lcd_set_background(LCD_BLACK);
1358 rb->lcd_set_foreground(LCD_WHITE); 1358 rb->lcd_set_foreground(LCD_WHITE);
@@ -1367,7 +1367,7 @@ static int brickmania_game_loop(void)
1367 if (life >= 0) { 1367 if (life >= 0) {
1368 rb->lcd_clear_display(); 1368 rb->lcd_clear_display();
1369 1369
1370 if (flip_sides) 1370 if (flip_sides)
1371 { 1371 {
1372 if (TIME_AFTER(*rb->current_tick, sec_count)) 1372 if (TIME_AFTER(*rb->current_tick, sec_count))
1373 { 1373 {
@@ -1405,7 +1405,7 @@ static int brickmania_game_loop(void)
1405 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s); 1405 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, 0, s);
1406 1406
1407 /* continue game */ 1407 /* continue game */
1408 if (game_state == ST_PAUSE) 1408 if (game_state == ST_PAUSE)
1409 { 1409 {
1410 rb->snprintf(s, sizeof(s), CONTINUE_TEXT); 1410 rb->snprintf(s, sizeof(s), CONTINUE_TEXT);
1411 rb->lcd_getstringsize(s, &sw, NULL); 1411 rb->lcd_getstringsize(s, &sw, NULL);
@@ -1416,43 +1416,43 @@ static int brickmania_game_loop(void)
1416 1416
1417 /* draw the ball */ 1417 /* draw the ball */
1418 for(i=0;i<used_balls;i++) 1418 for(i=0;i<used_balls;i++)
1419 rb->lcd_bitmap(brickmania_ball, 1419 rb->lcd_bitmap(brickmania_ball,
1420 INT3(ball[i].pos_x - HALFBALL), 1420 INT3(ball[i].pos_x - HALFBALL),
1421 INT3(ball[i].pos_y - HALFBALL), 1421 INT3(ball[i].pos_y - HALFBALL),
1422 INT3(BALL), INT3(BALL)); 1422 INT3(BALL), INT3(BALL));
1423 1423
1424 if (brick_on_board==0) 1424 if (brick_on_board==0)
1425 brick_on_board--; 1425 brick_on_board--;
1426 1426
1427 /* if the pad is fire */ 1427 /* if the pad is fire */
1428 for(i=0; i<MAX_FIRES; i++) 1428 for(i=0; i<MAX_FIRES; i++)
1429 { 1429 {
1430 /* If the projectile is active (>0 inactive) */ 1430 /* If the projectile is active (>0 inactive) */
1431 if (fire[i].top >= 0) 1431 if (fire[i].top >= 0)
1432 { 1432 {
1433 if (game_state!=ST_PAUSE) 1433 if (game_state!=ST_PAUSE)
1434 fire[i].top -= SPEED_FIRE; 1434 fire[i].top -= SPEED_FIRE;
1435 /* Draw the projectile */ 1435 /* Draw the projectile */
1436 rb->lcd_vline( INT3(fire[i].x_pos), INT3(fire[i].top), 1436 rb->lcd_vline( INT3(fire[i].x_pos), INT3(fire[i].top),
1437 INT3(fire[i].top + FIRE_LENGTH)); 1437 INT3(fire[i].top + FIRE_LENGTH));
1438 } 1438 }
1439 } 1439 }
1440 1440
1441 /* Setup the pad line-later used in intersection test */ 1441 /* Setup the pad line-later used in intersection test */
1442 pad_line.p1.x = pad_pos_x; 1442 pad_line.p1.x = pad_pos_x;
1443 pad_line.p1.y = PAD_POS_Y; 1443 pad_line.p1.y = PAD_POS_Y;
1444 1444
1445 pad_line.p2.x = pad_pos_x + pad_width; 1445 pad_line.p2.x = pad_pos_x + pad_width;
1446 pad_line.p2.y = PAD_POS_Y; 1446 pad_line.p2.y = PAD_POS_Y;
1447 1447
1448 /* handle all of the bricks/powerups */ 1448 /* handle all of the bricks/powerups */
1449 for (i=0; i<NUM_BRICKS_ROWS; i++) 1449 for (i=0; i<NUM_BRICKS_ROWS; i++)
1450 { 1450 {
1451 for (j=0; j<NUM_BRICKS_COLS ;j++) 1451 for (j=0; j<NUM_BRICKS_COLS ;j++)
1452 { 1452 {
1453 int brickx; 1453 int brickx;
1454 int bnum = i*NUM_BRICKS_COLS+j; 1454 int bnum = i*NUM_BRICKS_COLS+j;
1455 1455
1456 /* This brick is not really a brick, it is a powerup if 1456 /* This brick is not really a brick, it is a powerup if
1457 * poweruse is set. Perform appropriate powerup checks. 1457 * poweruse is set. Perform appropriate powerup checks.
1458 */ 1458 */
@@ -1460,7 +1460,7 @@ static int brickmania_game_loop(void)
1460 { 1460 {
1461 brickx = LEFTMARGIN + j*BRICK_WIDTH + 1461 brickx = LEFTMARGIN + j*BRICK_WIDTH +
1462 (BRICK_WIDTH - POWERUP_WIDTH) / 2; 1462 (BRICK_WIDTH - POWERUP_WIDTH) / 2;
1463 1463
1464 /* Update powertop if the game is not paused */ 1464 /* Update powertop if the game is not paused */
1465 if (game_state!=ST_PAUSE) 1465 if (game_state!=ST_PAUSE)
1466 brick[bnum].powertop+=SPEED_POWER; 1466 brick[bnum].powertop+=SPEED_POWER;
@@ -1468,26 +1468,26 @@ static int brickmania_game_loop(void)
1468 /* Draw the powerup */ 1468 /* Draw the powerup */
1469 rb->lcd_bitmap_part(brickmania_powerups,0, 1469 rb->lcd_bitmap_part(brickmania_powerups,0,
1470 INT3(POWERUP_HEIGHT)*brick[bnum].power, 1470 INT3(POWERUP_HEIGHT)*brick[bnum].power,
1471 STRIDE( SCREEN_MAIN, 1471 STRIDE( SCREEN_MAIN,
1472 BMPWIDTH_brickmania_powerups, 1472 BMPWIDTH_brickmania_powerups,
1473 BMPHEIGHT_brickmania_powerups), 1473 BMPHEIGHT_brickmania_powerups),
1474 INT3(brickx), 1474 INT3(brickx),
1475 INT3(brick[bnum].powertop), 1475 INT3(brick[bnum].powertop),
1476 INT3(POWERUP_WIDTH), 1476 INT3(POWERUP_WIDTH),
1477 INT3(POWERUP_HEIGHT) ); 1477 INT3(POWERUP_HEIGHT) );
1478 1478
1479 /* Use misc_line to check if the center of the powerup 1479 /* Use misc_line to check if the center of the powerup
1480 * hit the paddle. 1480 * hit the paddle.
1481 */ 1481 */
1482 misc_line.p1.x = brickx + (POWERUP_WIDTH >> 1); 1482 misc_line.p1.x = brickx + (POWERUP_WIDTH >> 1);
1483 misc_line.p1.y = brick[bnum].powertop + POWERUP_HEIGHT; 1483 misc_line.p1.y = brick[bnum].powertop + POWERUP_HEIGHT;
1484 1484
1485 misc_line.p2.x = brickx + (POWERUP_WIDTH >> 1); 1485 misc_line.p2.x = brickx + (POWERUP_WIDTH >> 1);
1486 misc_line.p2.y = SPEED_POWER + brick[bnum].powertop + 1486 misc_line.p2.y = SPEED_POWER + brick[bnum].powertop +
1487 POWERUP_HEIGHT; 1487 POWERUP_HEIGHT;
1488 1488
1489 /* Check if the powerup will hit the paddle */ 1489 /* Check if the powerup will hit the paddle */
1490 if ( check_lines(&misc_line, &pad_line, &pt_hit) ) 1490 if ( check_lines(&misc_line, &pad_line, &pt_hit) )
1491 { 1491 {
1492 switch(brick[bnum].power) { 1492 switch(brick[bnum].power) {
1493 case 0: /* Extra Life */ 1493 case 0: /* Extra Life */
@@ -1496,7 +1496,7 @@ static int brickmania_game_loop(void)
1496 break; 1496 break;
1497 case 1: /* Loose a life */ 1497 case 1: /* Loose a life */
1498 life--; 1498 life--;
1499 if (life>=0) 1499 if (life>=0)
1500 { 1500 {
1501 brickmania_init_game(false); 1501 brickmania_init_game(false);
1502 brickmania_sleep(2); 1502 brickmania_sleep(2);
@@ -1530,16 +1530,16 @@ static int brickmania_game_loop(void)
1530 break; 1530 break;
1531 case 6: /* Extra Ball */ 1531 case 6: /* Extra Ball */
1532 score += 23; 1532 score += 23;
1533 if(used_balls<MAX_BALLS) 1533 if(used_balls<MAX_BALLS)
1534 { 1534 {
1535 /* Set the speed */ 1535 /* Set the speed */
1536 if(rb->rand()%2 == 0) 1536 if(rb->rand()%2 == 0)
1537 ball[used_balls].speedx=-SPEED_4Q_X; 1537 ball[used_balls].speedx=-SPEED_4Q_X;
1538 else 1538 else
1539 ball[used_balls].speedx= SPEED_4Q_X; 1539 ball[used_balls].speedx= SPEED_4Q_X;
1540 1540
1541 ball[used_balls].speedy= SPEED_4Q_Y; 1541 ball[used_balls].speedy= SPEED_4Q_Y;
1542 1542
1543 /* Ball is not glued */ 1543 /* Ball is not glued */
1544 ball[used_balls].glue= false; 1544 ball[used_balls].glue= false;
1545 used_balls++; 1545 used_balls++;
@@ -1547,33 +1547,33 @@ static int brickmania_game_loop(void)
1547 break; 1547 break;
1548 case 7: /* Long paddle */ 1548 case 7: /* Long paddle */
1549 score+=23; 1549 score+=23;
1550 if (pad_width==PAD_WIDTH) 1550 if (pad_width==PAD_WIDTH)
1551 { 1551 {
1552 pad_width = LONG_PAD_WIDTH; 1552 pad_width = LONG_PAD_WIDTH;
1553 pad_pos_x -= (LONG_PAD_WIDTH - 1553 pad_pos_x -= (LONG_PAD_WIDTH -
1554 PAD_WIDTH)/2; 1554 PAD_WIDTH)/2;
1555 } 1555 }
1556 else if (pad_width==SHORT_PAD_WIDTH) 1556 else if (pad_width==SHORT_PAD_WIDTH)
1557 { 1557 {
1558 pad_width = PAD_WIDTH; 1558 pad_width = PAD_WIDTH;
1559 pad_pos_x-=(PAD_WIDTH- 1559 pad_pos_x-=(PAD_WIDTH-
1560 SHORT_PAD_WIDTH)/2; 1560 SHORT_PAD_WIDTH)/2;
1561 } 1561 }
1562 1562
1563 if (pad_pos_x < 0) 1563 if (pad_pos_x < 0)
1564 pad_pos_x = 0; 1564 pad_pos_x = 0;
1565 else if(pad_pos_x + pad_width > 1565 else if(pad_pos_x + pad_width >
1566 GAMESCREEN_WIDTH) 1566 GAMESCREEN_WIDTH)
1567 pad_pos_x = GAMESCREEN_WIDTH-pad_width; 1567 pad_pos_x = GAMESCREEN_WIDTH-pad_width;
1568 break; 1568 break;
1569 case 8: /* Short Paddle */ 1569 case 8: /* Short Paddle */
1570 if (pad_width==PAD_WIDTH) 1570 if (pad_width==PAD_WIDTH)
1571 { 1571 {
1572 pad_width=SHORT_PAD_WIDTH; 1572 pad_width=SHORT_PAD_WIDTH;
1573 pad_pos_x+=(PAD_WIDTH- 1573 pad_pos_x+=(PAD_WIDTH-
1574 SHORT_PAD_WIDTH)/2; 1574 SHORT_PAD_WIDTH)/2;
1575 } 1575 }
1576 else if (pad_width==LONG_PAD_WIDTH) 1576 else if (pad_width==LONG_PAD_WIDTH)
1577 { 1577 {
1578 pad_width=PAD_WIDTH; 1578 pad_width=PAD_WIDTH;
1579 pad_pos_x+=(LONG_PAD_WIDTH-PAD_WIDTH)/2; 1579 pad_pos_x+=(LONG_PAD_WIDTH-PAD_WIDTH)/2;
@@ -1584,7 +1584,7 @@ static int brickmania_game_loop(void)
1584 brick[bnum].poweruse = false; 1584 brick[bnum].poweruse = false;
1585 } 1585 }
1586 1586
1587 if (brick[bnum].powertop>PAD_POS_Y) 1587 if (brick[bnum].powertop>PAD_POS_Y)
1588 { 1588 {
1589 /* Disable the powerup (it was missed) */ 1589 /* Disable the powerup (it was missed) */
1590 brick[bnum].poweruse = false; 1590 brick[bnum].poweruse = false;
@@ -1596,51 +1596,51 @@ static int brickmania_game_loop(void)
1596 /* these lines are used to describe the brick */ 1596 /* these lines are used to describe the brick */
1597 line bot_brick, top_brick, left_brick, rght_brick; 1597 line bot_brick, top_brick, left_brick, rght_brick;
1598 brickx = LEFTMARGIN + j*BRICK_WIDTH; 1598 brickx = LEFTMARGIN + j*BRICK_WIDTH;
1599 1599
1600 /* Describe the brick for later collision checks */ 1600 /* Describe the brick for later collision checks */
1601 /* Setup the bottom of the brick */ 1601 /* Setup the bottom of the brick */
1602 bot_brick.p1.x = brickx; 1602 bot_brick.p1.x = brickx;
1603 bot_brick.p1.y = brick[bnum].powertop + BRICK_HEIGHT; 1603 bot_brick.p1.y = brick[bnum].powertop + BRICK_HEIGHT;
1604 1604
1605 bot_brick.p2.x = brickx + BRICK_WIDTH; 1605 bot_brick.p2.x = brickx + BRICK_WIDTH;
1606 bot_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT; 1606 bot_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT;
1607 1607
1608 /* Setup the top of the brick */ 1608 /* Setup the top of the brick */
1609 top_brick.p1.x = brickx; 1609 top_brick.p1.x = brickx;
1610 top_brick.p1.y = brick[bnum].powertop; 1610 top_brick.p1.y = brick[bnum].powertop;
1611 1611
1612 top_brick.p2.x = brickx + BRICK_WIDTH; 1612 top_brick.p2.x = brickx + BRICK_WIDTH;
1613 top_brick.p2.y = brick[bnum].powertop; 1613 top_brick.p2.y = brick[bnum].powertop;
1614 1614
1615 /* Setup the left of the brick */ 1615 /* Setup the left of the brick */
1616 left_brick.p1.x = brickx; 1616 left_brick.p1.x = brickx;
1617 left_brick.p1.y = brick[bnum].powertop; 1617 left_brick.p1.y = brick[bnum].powertop;
1618 1618
1619 left_brick.p2.x = brickx; 1619 left_brick.p2.x = brickx;
1620 left_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT; 1620 left_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT;
1621 1621
1622 /* Setup the right of the brick */ 1622 /* Setup the right of the brick */
1623 rght_brick.p1.x = brickx + BRICK_WIDTH; 1623 rght_brick.p1.x = brickx + BRICK_WIDTH;
1624 rght_brick.p1.y = brick[bnum].powertop; 1624 rght_brick.p1.y = brick[bnum].powertop;
1625 1625
1626 rght_brick.p2.x = brickx + BRICK_WIDTH; 1626 rght_brick.p2.x = brickx + BRICK_WIDTH;
1627 rght_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT; 1627 rght_brick.p2.y = brick[bnum].powertop + BRICK_HEIGHT;
1628 1628
1629 /* Check if any of the active fires hit a brick */ 1629 /* Check if any of the active fires hit a brick */
1630 for (k=0;k<MAX_FIRES;k++) 1630 for (k=0;k<MAX_FIRES;k++)
1631 { 1631 {
1632 if(fire[k].top > 0) 1632 if(fire[k].top > 0)
1633 { 1633 {
1634 /* Use misc_line to check if fire hit brick */ 1634 /* Use misc_line to check if fire hit brick */
1635 misc_line.p1.x = fire[k].x_pos; 1635 misc_line.p1.x = fire[k].x_pos;
1636 misc_line.p1.y = fire[k].top; 1636 misc_line.p1.y = fire[k].top;
1637 1637
1638 misc_line.p2.x = fire[k].x_pos; 1638 misc_line.p2.x = fire[k].x_pos;
1639 misc_line.p2.y = fire[k].top + SPEED_FIRE; 1639 misc_line.p2.y = fire[k].top + SPEED_FIRE;
1640 1640
1641 /* If the fire hit the brick take care of it */ 1641 /* If the fire hit the brick take care of it */
1642 if (check_lines(&misc_line, &bot_brick, 1642 if (check_lines(&misc_line, &bot_brick,
1643 &pt_hit)) 1643 &pt_hit))
1644 { 1644 {
1645 score+=13; 1645 score+=13;
1646 /* De-activate the fire */ 1646 /* De-activate the fire */
@@ -1649,23 +1649,23 @@ static int brickmania_game_loop(void)
1649 } 1649 }
1650 } 1650 }
1651 } 1651 }
1652 1652
1653 /* Draw the brick */ 1653 /* Draw the brick */
1654 rb->lcd_bitmap_part(brickmania_bricks,0, 1654 rb->lcd_bitmap_part(brickmania_bricks,0,
1655 INT3(BRICK_HEIGHT)*brick[bnum].color, 1655 INT3(BRICK_HEIGHT)*brick[bnum].color,
1656 STRIDE( SCREEN_MAIN, 1656 STRIDE( SCREEN_MAIN,
1657 BMPWIDTH_brickmania_bricks, 1657 BMPWIDTH_brickmania_bricks,
1658 BMPHEIGHT_brickmania_bricks), 1658 BMPHEIGHT_brickmania_bricks),
1659 INT3(brickx), 1659 INT3(brickx),
1660 INT3(brick[bnum].powertop), 1660 INT3(brick[bnum].powertop),
1661 INT3(BRICK_WIDTH), INT3(BRICK_HEIGHT) ); 1661 INT3(BRICK_WIDTH), INT3(BRICK_HEIGHT) );
1662 1662
1663#ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */ 1663#ifdef HAVE_LCD_COLOR /* No transparent effect for greyscale lcds for now */
1664 if (brick[bnum].hiteffect > 0) 1664 if (brick[bnum].hiteffect > 0)
1665 rb->lcd_bitmap_transparent_part(brickmania_break,0, 1665 rb->lcd_bitmap_transparent_part(brickmania_break,0,
1666 INT3(BRICK_HEIGHT)*brick[bnum].hiteffect, 1666 INT3(BRICK_HEIGHT)*brick[bnum].hiteffect,
1667 STRIDE( SCREEN_MAIN, 1667 STRIDE( SCREEN_MAIN,
1668 BMPWIDTH_brickmania_break, 1668 BMPWIDTH_brickmania_break,
1669 BMPHEIGHT_brickmania_break), 1669 BMPHEIGHT_brickmania_break),
1670 INT3(brickx), 1670 INT3(brickx),
1671 INT3(brick[bnum].powertop), 1671 INT3(brick[bnum].powertop),
@@ -1673,28 +1673,28 @@ static int brickmania_game_loop(void)
1673#endif 1673#endif
1674 1674
1675 /* Check if any balls collided with the brick */ 1675 /* Check if any balls collided with the brick */
1676 for(k=0; k<used_balls; k++) 1676 for(k=0; k<used_balls; k++)
1677 { 1677 {
1678 /* Setup the ball path to describe the current ball 1678 /* Setup the ball path to describe the current ball
1679 * position and the line it makes to its next 1679 * position and the line it makes to its next
1680 * position. 1680 * position.
1681 */ 1681 */
1682 misc_line.p1.x = ball[k].pos_x; 1682 misc_line.p1.x = ball[k].pos_x;
1683 misc_line.p1.y = ball[k].pos_y; 1683 misc_line.p1.y = ball[k].pos_y;
1684 1684
1685 misc_line.p2.x = ball[k].pos_x + ball[k].speedx; 1685 misc_line.p2.x = ball[k].pos_x + ball[k].speedx;
1686 misc_line.p2.y = ball[k].pos_y + ball[k].speedy; 1686 misc_line.p2.y = ball[k].pos_y + ball[k].speedy;
1687 1687
1688 /* Check to see if the ball and the bottom hit. If 1688 /* Check to see if the ball and the bottom hit. If
1689 * the ball is moving down we don't want to 1689 * the ball is moving down we don't want to
1690 * include the bottom line intersection. 1690 * include the bottom line intersection.
1691 * 1691 *
1692 * The order that the sides are checked matters. 1692 * The order that the sides are checked matters.
1693 * 1693 *
1694 * Note that tempx/tempy store the next position 1694 * Note that tempx/tempy store the next position
1695 * that the ball should be drawn. 1695 * that the ball should be drawn.
1696 */ 1696 */
1697 if(ball[k].speedy <= 0 && 1697 if(ball[k].speedy <= 0 &&
1698 check_lines(&misc_line, &bot_brick, &pt_hit)) 1698 check_lines(&misc_line, &bot_brick, &pt_hit))
1699 { 1699 {
1700 ball[k].speedy = -ball[k].speedy; 1700 ball[k].speedy = -ball[k].speedy;
@@ -1705,7 +1705,7 @@ static int brickmania_game_loop(void)
1705 /* Check the top, if the ball is moving up dont 1705 /* Check the top, if the ball is moving up dont
1706 * count it as a hit. 1706 * count it as a hit.
1707 */ 1707 */
1708 else if(ball[k].speedy > 0 && 1708 else if(ball[k].speedy > 0 &&
1709 check_lines(&misc_line, &top_brick, &pt_hit)) 1709 check_lines(&misc_line, &top_brick, &pt_hit))
1710 { 1710 {
1711 ball[k].speedy = -ball[k].speedy; 1711 ball[k].speedy = -ball[k].speedy;
@@ -1733,7 +1733,7 @@ static int brickmania_game_loop(void)
1733 } 1733 }
1734 } /* for k */ 1734 } /* for k */
1735 } /* if(used) */ 1735 } /* if(used) */
1736 1736
1737 } /* for j */ 1737 } /* for j */
1738 } /* for i */ 1738 } /* for i */
1739 1739
@@ -1743,9 +1743,9 @@ static int brickmania_game_loop(void)
1743 rb->lcd_bitmap_part( 1743 rb->lcd_bitmap_part(
1744 brickmania_pads, 1744 brickmania_pads,
1745 0, pad_type*INT3(PAD_HEIGHT), 1745 0, pad_type*INT3(PAD_HEIGHT),
1746 STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_pads, 1746 STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_pads,
1747 BMPHEIGHT_brickmania_pads), 1747 BMPHEIGHT_brickmania_pads),
1748 INT3(pad_pos_x), INT3(PAD_POS_Y), 1748 INT3(pad_pos_x), INT3(PAD_POS_Y),
1749 INT3(pad_width), INT3(PAD_HEIGHT) ); 1749 INT3(pad_width), INT3(PAD_HEIGHT) );
1750 } 1750 }
1751 else if( pad_width == LONG_PAD_WIDTH ) /* Long Pad */ 1751 else if( pad_width == LONG_PAD_WIDTH ) /* Long Pad */
@@ -1753,9 +1753,9 @@ static int brickmania_game_loop(void)
1753 rb->lcd_bitmap_part( 1753 rb->lcd_bitmap_part(
1754 brickmania_long_pads, 1754 brickmania_long_pads,
1755 0,pad_type*INT3(PAD_HEIGHT), 1755 0,pad_type*INT3(PAD_HEIGHT),
1756 STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_long_pads, 1756 STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_long_pads,
1757 BMPHEIGHT_brickmania_long_pads), 1757 BMPHEIGHT_brickmania_long_pads),
1758 INT3(pad_pos_x), INT3(PAD_POS_Y), 1758 INT3(pad_pos_x), INT3(PAD_POS_Y),
1759 INT3(pad_width), INT3(PAD_HEIGHT) ); 1759 INT3(pad_width), INT3(PAD_HEIGHT) );
1760 } 1760 }
1761 else /* Short pad */ 1761 else /* Short pad */
@@ -1763,9 +1763,9 @@ static int brickmania_game_loop(void)
1763 rb->lcd_bitmap_part( 1763 rb->lcd_bitmap_part(
1764 brickmania_short_pads, 1764 brickmania_short_pads,
1765 0,pad_type*INT3(PAD_HEIGHT), 1765 0,pad_type*INT3(PAD_HEIGHT),
1766 STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_short_pads, 1766 STRIDE( SCREEN_MAIN, BMPWIDTH_brickmania_short_pads,
1767 BMPHEIGHT_brickmania_short_pads), 1767 BMPHEIGHT_brickmania_short_pads),
1768 INT3(pad_pos_x), INT3(PAD_POS_Y), 1768 INT3(pad_pos_x), INT3(PAD_POS_Y),
1769 INT3(pad_width), INT3(PAD_HEIGHT) ); 1769 INT3(pad_width), INT3(PAD_HEIGHT) );
1770 } 1770 }
1771 1771
@@ -1773,21 +1773,21 @@ static int brickmania_game_loop(void)
1773 if (game_state!=ST_PAUSE) 1773 if (game_state!=ST_PAUSE)
1774 { 1774 {
1775 /* Loop through all of the balls in play */ 1775 /* Loop through all of the balls in play */
1776 for(k=0;k<used_balls;k++) 1776 for(k=0;k<used_balls;k++)
1777 { 1777 {
1778 line screen_edge; 1778 line screen_edge;
1779 1779
1780 /* Describe the ball movement for the edge collision detection */ 1780 /* Describe the ball movement for the edge collision detection */
1781 misc_line.p1.x = ball[k].pos_x; 1781 misc_line.p1.x = ball[k].pos_x;
1782 misc_line.p1.y = ball[k].pos_y; 1782 misc_line.p1.y = ball[k].pos_y;
1783 1783
1784 misc_line.p2.x = ball[k].pos_x + ball[k].speedx; 1784 misc_line.p2.x = ball[k].pos_x + ball[k].speedx;
1785 misc_line.p2.y = ball[k].pos_y + ball[k].speedy; 1785 misc_line.p2.y = ball[k].pos_y + ball[k].speedy;
1786 1786
1787 /* Did the Ball hit the top of the screen? */ 1787 /* Did the Ball hit the top of the screen? */
1788 screen_edge.p1.x = 0; 1788 screen_edge.p1.x = 0;
1789 screen_edge.p1.y = 0; 1789 screen_edge.p1.y = 0;
1790 1790
1791 screen_edge.p2.x = FIXED3(LCD_WIDTH); 1791 screen_edge.p2.x = FIXED3(LCD_WIDTH);
1792 screen_edge.p2.y = 0; 1792 screen_edge.p2.y = 0;
1793 /* the test for pos_y prevents the ball from bouncing back 1793 /* the test for pos_y prevents the ball from bouncing back
@@ -1802,10 +1802,10 @@ static int brickmania_game_loop(void)
1802 } 1802 }
1803 1803
1804 /* Player missed the ball and hit bottom of screen */ 1804 /* Player missed the ball and hit bottom of screen */
1805 if (ball[k].pos_y >= GAMESCREEN_HEIGHT) 1805 if (ball[k].pos_y >= GAMESCREEN_HEIGHT)
1806 { 1806 {
1807 /* Player had balls to spare, so handle the removal */ 1807 /* Player had balls to spare, so handle the removal */
1808 if (used_balls>1) 1808 if (used_balls>1)
1809 { 1809 {
1810 /* decrease number of balls in play */ 1810 /* decrease number of balls in play */
1811 used_balls--; 1811 used_balls--;
@@ -1829,11 +1829,11 @@ static int brickmania_game_loop(void)
1829 k--; 1829 k--;
1830 continue; 1830 continue;
1831 } 1831 }
1832 else 1832 else
1833 { 1833 {
1834 /* Player lost a life */ 1834 /* Player lost a life */
1835 life--; 1835 life--;
1836 if (life>=0) 1836 if (life>=0)
1837 { 1837 {
1838 /* No lives left reset game */ 1838 /* No lives left reset game */
1839 brickmania_init_game(false); 1839 brickmania_init_game(false);
@@ -1846,7 +1846,7 @@ static int brickmania_game_loop(void)
1846 /* Check if the ball hit the left side */ 1846 /* Check if the ball hit the left side */
1847 screen_edge.p1.x = 0; 1847 screen_edge.p1.x = 0;
1848 screen_edge.p1.y = 0; 1848 screen_edge.p1.y = 0;
1849 1849
1850 screen_edge.p2.x = 0; 1850 screen_edge.p2.x = 0;
1851 screen_edge.p2.y = FIXED3(LCD_HEIGHT); 1851 screen_edge.p2.y = FIXED3(LCD_HEIGHT);
1852 if ( !ball[k].glue && 1852 if ( !ball[k].glue &&
@@ -1863,7 +1863,7 @@ static int brickmania_game_loop(void)
1863 /* Check if the ball hit the right side */ 1863 /* Check if the ball hit the right side */
1864 screen_edge.p1.x = FIXED3(LCD_WIDTH); 1864 screen_edge.p1.x = FIXED3(LCD_WIDTH);
1865 screen_edge.p1.y = 0; 1865 screen_edge.p1.y = 0;
1866 1866
1867 screen_edge.p2.x = FIXED3(LCD_WIDTH); 1867 screen_edge.p2.x = FIXED3(LCD_WIDTH);
1868 screen_edge.p2.y = FIXED3(LCD_HEIGHT); 1868 screen_edge.p2.y = FIXED3(LCD_HEIGHT);
1869 if ( !ball[k].glue && 1869 if ( !ball[k].glue &&
@@ -1881,7 +1881,7 @@ static int brickmania_game_loop(void)
1881 * Hit set the x/y speed appropriately. 1881 * Hit set the x/y speed appropriately.
1882 */ 1882 */
1883 if( game_state!=ST_READY && !ball[k].glue && 1883 if( game_state!=ST_READY && !ball[k].glue &&
1884 check_lines(&misc_line, &pad_line, &pt_hit) ) 1884 check_lines(&misc_line, &pad_line, &pt_hit) )
1885 { 1885 {
1886 /* Re-position ball based on collision */ 1886 /* Re-position ball based on collision */
1887 ball[k].tempy = ON_PAD_POS_Y; 1887 ball[k].tempy = ON_PAD_POS_Y;
@@ -1894,7 +1894,7 @@ static int brickmania_game_loop(void)
1894 * should be negative. 1894 * should be negative.
1895 */ 1895 */
1896 int x_direction = -1; 1896 int x_direction = -1;
1897 1897
1898 /* Comparisons are done with respect to 1/2 pad_width */ 1898 /* Comparisons are done with respect to 1/2 pad_width */
1899 if(ball_repos > pad_width/2) 1899 if(ball_repos > pad_width/2)
1900 { 1900 {
@@ -1905,12 +1905,12 @@ static int brickmania_game_loop(void)
1905 */ 1905 */
1906 x_direction = 1; 1906 x_direction = 1;
1907 } 1907 }
1908 1908
1909 /* Figure out where the ball hit relative to 1/2 pad 1909 /* Figure out where the ball hit relative to 1/2 pad
1910 * and in divisions of 4. 1910 * and in divisions of 4.
1911 */ 1911 */
1912 ball_repos = ball_repos / (pad_width/2/4); 1912 ball_repos = ball_repos / (pad_width/2/4);
1913 1913
1914 switch(ball_repos) 1914 switch(ball_repos)
1915 { 1915 {
1916 /* Ball hit the outer edge of the paddle */ 1916 /* Ball hit the outer edge of the paddle */
@@ -1953,8 +1953,8 @@ static int brickmania_game_loop(void)
1953 ball[k].speedy = SPEED_4Q_Y; 1953 ball[k].speedy = SPEED_4Q_Y;
1954 break; 1954 break;
1955 } 1955 }
1956 1956
1957 if(pad_type == STICKY) 1957 if(pad_type == STICKY)
1958 { 1958 {
1959 ball[k].speedy = -ball[k].speedy; 1959 ball[k].speedy = -ball[k].speedy;
1960 ball[k].glue=true; 1960 ball[k].glue=true;
@@ -1974,7 +1974,7 @@ static int brickmania_game_loop(void)
1974 ball[k].pos_x = ball[k].tempx; 1974 ball[k].pos_x = ball[k].tempx;
1975 else 1975 else
1976 ball[k].pos_x += ball[k].speedx; 1976 ball[k].pos_x += ball[k].speedx;
1977 1977
1978 if(ball[k].tempy) 1978 if(ball[k].tempy)
1979 ball[k].pos_y = ball[k].tempy; 1979 ball[k].pos_y = ball[k].tempy;
1980 else 1980 else
@@ -1988,9 +1988,9 @@ static int brickmania_game_loop(void)
1988 1988
1989 rb->lcd_update(); 1989 rb->lcd_update();
1990 1990
1991 if (brick_on_board < 0) 1991 if (brick_on_board < 0)
1992 { 1992 {
1993 if (level+1<NUM_LEVELS) 1993 if (level+1<NUM_LEVELS)
1994 { 1994 {
1995 level++; 1995 level++;
1996 if (difficulty==NORMAL) 1996 if (difficulty==NORMAL)
@@ -1999,7 +1999,7 @@ static int brickmania_game_loop(void)
1999 brickmania_sleep(2); 1999 brickmania_sleep(2);
2000 rb->button_clear_queue(); 2000 rb->button_clear_queue();
2001 } 2001 }
2002 else 2002 else
2003 { 2003 {
2004 rb->lcd_getstringsize("Congratulations!", &sw, NULL); 2004 rb->lcd_getstringsize("Congratulations!", &sw, NULL);
2005 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, INT3(STRINGPOS_CONGRATS), 2005 rb->lcd_putsxy(LCD_WIDTH/2-sw/2, INT3(STRINGPOS_CONGRATS),
@@ -2038,7 +2038,7 @@ static int brickmania_game_loop(void)
2038 rb->button_status_wdata(&data); 2038 rb->button_status_wdata(&data);
2039 touch_x = FIXED3(data >> 16); 2039 touch_x = FIXED3(data >> 16);
2040 touch_y = FIXED3(data & 0xffff); 2040 touch_y = FIXED3(data & 0xffff);
2041 2041
2042 if(flip_sides) 2042 if(flip_sides)
2043 { 2043 {
2044 pad_pos_x = GAMESCREEN_WIDTH - (touch_x + pad_width/2); 2044 pad_pos_x = GAMESCREEN_WIDTH - (touch_x + pad_width/2);
@@ -2070,9 +2070,9 @@ static int brickmania_game_loop(void)
2070 if ((game_state==ST_PAUSE) && (button_right || button_left)) 2070 if ((game_state==ST_PAUSE) && (button_right || button_left))
2071 continue; 2071 continue;
2072 if ((button_right && !flip_sides) || 2072 if ((button_right && !flip_sides) ||
2073 (button_left && flip_sides)) 2073 (button_left && flip_sides))
2074 { 2074 {
2075 if (pad_pos_x+SPEED_PAD+pad_width > GAMESCREEN_WIDTH) 2075 if (pad_pos_x+SPEED_PAD+pad_width > GAMESCREEN_WIDTH)
2076 { 2076 {
2077 for(k=0;k<used_balls;k++) 2077 for(k=0;k<used_balls;k++)
2078 if (game_state==ST_READY || ball[k].glue) 2078 if (game_state==ST_READY || ball[k].glue)
@@ -2088,16 +2088,16 @@ static int brickmania_game_loop(void)
2088 } 2088 }
2089 } 2089 }
2090 else if ((button_left && !flip_sides) || 2090 else if ((button_left && !flip_sides) ||
2091 (button_right && flip_sides)) 2091 (button_right && flip_sides))
2092 { 2092 {
2093 if (pad_pos_x-SPEED_PAD < 0) 2093 if (pad_pos_x-SPEED_PAD < 0)
2094 { 2094 {
2095 for(k=0;k<used_balls;k++) 2095 for(k=0;k<used_balls;k++)
2096 if (game_state==ST_READY || ball[k].glue) 2096 if (game_state==ST_READY || ball[k].glue)
2097 ball[k].pos_x-=pad_pos_x; 2097 ball[k].pos_x-=pad_pos_x;
2098 pad_pos_x -= pad_pos_x; 2098 pad_pos_x -= pad_pos_x;
2099 } 2099 }
2100 else 2100 else
2101 { 2101 {
2102 for(k=0;k<used_balls;k++) 2102 for(k=0;k<used_balls;k++)
2103 if (game_state==ST_READY || ball[k].glue) 2103 if (game_state==ST_READY || ball[k].glue)
@@ -2106,8 +2106,8 @@ static int brickmania_game_loop(void)
2106 } 2106 }
2107 } 2107 }
2108 } 2108 }
2109 2109
2110 switch(button) 2110 switch(button)
2111 { 2111 {
2112#if defined(HAVE_TOUCHSCREEN) 2112#if defined(HAVE_TOUCHSCREEN)
2113 case (BUTTON_REL | BUTTON_TOUCHSCREEN): 2113 case (BUTTON_REL | BUTTON_TOUCHSCREEN):
@@ -2117,16 +2117,16 @@ static int brickmania_game_loop(void)
2117#ifdef ALTSELECT 2117#ifdef ALTSELECT
2118 case ALTSELECT: 2118 case ALTSELECT:
2119#endif 2119#endif
2120 if (game_state==ST_READY) 2120 if (game_state==ST_READY)
2121 { 2121 {
2122 /* Initialize used balls starting speed */ 2122 /* Initialize used balls starting speed */
2123 for(k=0 ; k < used_balls ; k++) 2123 for(k=0 ; k < used_balls ; k++)
2124 { 2124 {
2125 ball[k].speedy = SPEED_4Q_Y; 2125 ball[k].speedy = SPEED_4Q_Y;
2126 if(pad_pos_x + (pad_width/2) >= GAMESCREEN_WIDTH/2) 2126 if(pad_pos_x + (pad_width/2) >= GAMESCREEN_WIDTH/2)
2127 { 2127 {
2128 ball[k].speedx = SPEED_4Q_X; 2128 ball[k].speedx = SPEED_4Q_X;
2129 } 2129 }
2130 else 2130 else
2131 { 2131 {
2132 ball[k].speedx = -SPEED_4Q_X; 2132 ball[k].speedx = -SPEED_4Q_X;
@@ -2134,13 +2134,13 @@ static int brickmania_game_loop(void)
2134 } 2134 }
2135 game_state=ST_START; 2135 game_state=ST_START;
2136 } 2136 }
2137 else if (game_state==ST_PAUSE) 2137 else if (game_state==ST_PAUSE)
2138 { 2138 {
2139 game_state=ST_START; 2139 game_state=ST_START;
2140 } 2140 }
2141 else if (pad_type == STICKY) 2141 else if (pad_type == STICKY)
2142 { 2142 {
2143 for(k=0;k<used_balls;k++) 2143 for(k=0;k<used_balls;k++)
2144 { 2144 {
2145 if (ball[k].glue) 2145 if (ball[k].glue)
2146 { 2146 {
@@ -2149,12 +2149,12 @@ static int brickmania_game_loop(void)
2149 } 2149 }
2150 } 2150 }
2151 } 2151 }
2152 else if (pad_type == SHOOTER) 2152 else if (pad_type == SHOOTER)
2153 { 2153 {
2154 k=brickmania_find_empty_fire(); 2154 k=brickmania_find_empty_fire();
2155 fire[k].top=PAD_POS_Y - FIRE_LENGTH; 2155 fire[k].top=PAD_POS_Y - FIRE_LENGTH;
2156 fire[k].x_pos = pad_pos_x + 1; /* Add 1 for edge */ 2156 fire[k].x_pos = pad_pos_x + 1; /* Add 1 for edge */
2157 2157
2158 k=brickmania_find_empty_fire(); 2158 k=brickmania_find_empty_fire();
2159 fire[k].top=PAD_POS_Y - FIRE_LENGTH; 2159 fire[k].top=PAD_POS_Y - FIRE_LENGTH;
2160 fire[k].x_pos = pad_pos_x + pad_width -1; /* Sub1 edge*/ 2160 fire[k].x_pos = pad_pos_x + pad_width -1; /* Sub1 edge*/
@@ -2174,7 +2174,7 @@ static int brickmania_game_loop(void)
2174 break; 2174 break;
2175 } 2175 }
2176 } 2176 }
2177 else 2177 else
2178 { 2178 {
2179#ifdef HAVE_LCD_COLOR 2179#ifdef HAVE_LCD_COLOR
2180 rb->lcd_bitmap_transparent(brickmania_gameover, 2180 rb->lcd_bitmap_transparent(brickmania_gameover,
@@ -2191,10 +2191,10 @@ static int brickmania_game_loop(void)
2191 brickmania_sleep(2); 2191 brickmania_sleep(2);
2192 return 0; 2192 return 0;
2193 } 2193 }
2194 2194
2195 /* Game always needs to yield for other threads */ 2195 /* Game always needs to yield for other threads */
2196 rb->yield(); 2196 rb->yield();
2197 2197
2198 /* Sleep for a bit if there is time to spare */ 2198 /* Sleep for a bit if there is time to spare */
2199 if (TIME_BEFORE(*rb->current_tick, end)) 2199 if (TIME_BEFORE(*rb->current_tick, end))
2200 rb->sleep(end-*rb->current_tick); 2200 rb->sleep(end-*rb->current_tick);
@@ -2211,7 +2211,7 @@ enum plugin_status plugin_start(const void* parameter)
2211 highscore_load(HIGH_SCORE,highest,NUM_SCORES); 2211 highscore_load(HIGH_SCORE,highest,NUM_SCORES);
2212 configfile_load(CONFIG_FILE_NAME,config,1,0); 2212 configfile_load(CONFIG_FILE_NAME,config,1,0);
2213 last_difficulty = difficulty; 2213 last_difficulty = difficulty;
2214 2214
2215#ifdef HAVE_TOUCHSCREEN 2215#ifdef HAVE_TOUCHSCREEN
2216 rb->touchscreen_set_mode(TOUCHSCREEN_POINT); 2216 rb->touchscreen_set_mode(TOUCHSCREEN_POINT);
2217#endif 2217#endif
@@ -2231,18 +2231,18 @@ enum plugin_status plugin_start(const void* parameter)
2231 { 2231 {
2232 if(!resume) 2232 if(!resume)
2233 { 2233 {
2234 int position = highscore_update(score, level+1, "", highest, 2234 int position = highscore_update(score, level+1, "", highest,
2235 NUM_SCORES); 2235 NUM_SCORES);
2236 if (position == 0) 2236 if (position == 0)
2237 { 2237 {
2238 rb->splash(HZ*2, "New High Score"); 2238 rb->splash(HZ*2, "New High Score");
2239 } 2239 }
2240 2240
2241 if (position != -1) 2241 if (position != -1)
2242 { 2242 {
2243 highscore_show(position, highest, NUM_SCORES, true); 2243 highscore_show(position, highest, NUM_SCORES, true);
2244 } 2244 }
2245 else 2245 else
2246 { 2246 {
2247 brickmania_sleep(3); 2247 brickmania_sleep(3);
2248 } 2248 }