diff options
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/brickmania.c | 88 |
1 files changed, 47 insertions, 41 deletions
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index b6eeeac398..3b2f00064b 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c | |||
@@ -942,13 +942,15 @@ static void brickmania_sleep(int secs) | |||
942 | int count=0; | 942 | int count=0; |
943 | int sw, w; | 943 | int sw, w; |
944 | 944 | ||
945 | while (!done) { | 945 | while (!done) |
946 | if (vscore == score) { | 946 | { |
947 | if (count==0) | 947 | if (count == 0) |
948 | count=*rb->current_tick+HZ*secs; | 948 | count = *rb->current_tick + HZ*secs; |
949 | if (*rb->current_tick>=count) | 949 | if ( (*rb->current_tick >= count) && (vscore == score) ) |
950 | done=true; | 950 | done = true; |
951 | } else { | 951 | |
952 | if(vscore != score) | ||
953 | { | ||
952 | if (vscore<score) | 954 | if (vscore<score) |
953 | vscore++; | 955 | vscore++; |
954 | if (vscore>score) | 956 | if (vscore>score) |
@@ -1272,9 +1274,9 @@ static int brickmania_game_loop(void) | |||
1272 | pad_line.p2.y = PAD_POS_Y; | 1274 | pad_line.p2.y = PAD_POS_Y; |
1273 | 1275 | ||
1274 | /* handle all of the bricks */ | 1276 | /* handle all of the bricks */ |
1275 | for (i=0;i<=7;i++) | 1277 | for (i=0; i<=7; i++) |
1276 | { | 1278 | { |
1277 | for (j=0;j<=9;j++) | 1279 | for (j=0; j<=9 ;j++) |
1278 | { | 1280 | { |
1279 | int brickx; | 1281 | int brickx; |
1280 | int bnum = i*10+j; | 1282 | int bnum = i*10+j; |
@@ -1628,6 +1630,7 @@ static int brickmania_game_loop(void) | |||
1628 | /* No lives left reset game */ | 1630 | /* No lives left reset game */ |
1629 | brickmania_init_game(false); | 1631 | brickmania_init_game(false); |
1630 | brickmania_sleep(2); | 1632 | brickmania_sleep(2); |
1633 | rb->button_clear_queue(); | ||
1631 | } | 1634 | } |
1632 | } | 1635 | } |
1633 | } | 1636 | } |
@@ -1769,6 +1772,7 @@ static int brickmania_game_loop(void) | |||
1769 | score+=100; | 1772 | score+=100; |
1770 | brickmania_init_game(true); | 1773 | brickmania_init_game(true); |
1771 | brickmania_sleep(2); | 1774 | brickmania_sleep(2); |
1775 | rb->button_clear_queue(); | ||
1772 | } | 1776 | } |
1773 | else | 1777 | else |
1774 | { | 1778 | { |
@@ -1792,9 +1796,8 @@ static int brickmania_game_loop(void) | |||
1792 | } | 1796 | } |
1793 | } | 1797 | } |
1794 | 1798 | ||
1795 | int move_button,button; | 1799 | int button=rb->button_get(false); |
1796 | int button_right,button_left; | 1800 | int move_button = rb->button_status(); |
1797 | button=rb->button_get(false); | ||
1798 | 1801 | ||
1799 | #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN) | 1802 | #if defined(HAS_BUTTON_HOLD) && !defined(HAVE_REMOTE_LCD_AS_MAIN) |
1800 | /* FIXME: Should probably check remote hold here */ | 1803 | /* FIXME: Should probably check remote hold here */ |
@@ -1803,11 +1806,13 @@ static int brickmania_game_loop(void) | |||
1803 | #endif | 1806 | #endif |
1804 | 1807 | ||
1805 | #ifdef HAVE_TOUCHSCREEN | 1808 | #ifdef HAVE_TOUCHSCREEN |
1806 | if(button & BUTTON_TOUCHSCREEN) | 1809 | if( move_button & BUTTON_TOUCHSCREEN) |
1807 | { | 1810 | { |
1811 | int data; | ||
1808 | short touch_x, touch_y; | 1812 | short touch_x, touch_y; |
1809 | touch_x = FIXED3(rb->button_get_data() >> 16); | 1813 | rb->button_status_wdata(&data); |
1810 | touch_y = FIXED3(rb->button_get_data() & 0xffff); | 1814 | touch_x = FIXED3(data >> 16); |
1815 | touch_y = FIXED3(data & 0xffff); | ||
1811 | 1816 | ||
1812 | if(flip_sides) | 1817 | if(flip_sides) |
1813 | { | 1818 | { |
@@ -1820,31 +1825,27 @@ static int brickmania_game_loop(void) | |||
1820 | 1825 | ||
1821 | if(pad_pos_x < 0) | 1826 | if(pad_pos_x < 0) |
1822 | pad_pos_x = 0; | 1827 | pad_pos_x = 0; |
1823 | else if(pad_pos_x+pad_width > GAMESCREEN_WIDTH) | 1828 | else if(pad_pos_x + pad_width > GAMESCREEN_WIDTH) |
1824 | pad_pos_x = GAMESCREEN_WIDTH-pad_width; | 1829 | pad_pos_x = GAMESCREEN_WIDTH-pad_width; |
1825 | for(k=0;k<used_balls;k++) | 1830 | for(k=0; k<used_balls; k++) |
1826 | if (game_state==ST_READY || ball[k].glue) | 1831 | if (game_state==ST_READY || ball[k].glue) |
1827 | ball[k].pos_x = pad_pos_x+pad_width/2; | 1832 | ball[k].pos_x = pad_pos_x + pad_width/2 - HALFBALL; |
1828 | |||
1829 | if(button & BUTTON_REL) | ||
1830 | button = SELECT; | ||
1831 | } | 1833 | } |
1832 | else | 1834 | else |
1833 | { | ||
1834 | #endif | 1835 | #endif |
1835 | move_button=rb->button_status(); | 1836 | { |
1837 | int button_right, button_left; | ||
1836 | #ifdef ALTRIGHT | 1838 | #ifdef ALTRIGHT |
1837 | button_right=( (move_button & RIGHT) || | 1839 | button_right = move_button & (RIGHT | ALTRIGHT); |
1838 | (move_button & ALTRIGHT)); | 1840 | button_left = move_button & (LEFT | ALTLEFT); |
1839 | button_left=((move_button & LEFT) || (move_button & ALTLEFT)); | ||
1840 | #else | 1841 | #else |
1841 | button_right=((move_button & RIGHT) || (SCROLL_FWD(button))); | 1842 | button_right =((move_button & RIGHT)|| SCROLL_FWD(move_button)); |
1842 | button_left=((move_button & LEFT) || (SCROLL_BACK(button))); | 1843 | button_left =((move_button & LEFT) ||SCROLL_BACK(move_button)); |
1843 | #endif | 1844 | #endif |
1844 | if ((game_state==ST_PAUSE) && (button_right || button_left)) | 1845 | if ((game_state==ST_PAUSE) && (button_right || button_left)) |
1845 | continue; | 1846 | continue; |
1846 | if ((button_right && flip_sides==false) || | 1847 | if ((button_right && !flip_sides) || |
1847 | (button_left && flip_sides==true)) | 1848 | (button_left && flip_sides)) |
1848 | { | 1849 | { |
1849 | if (pad_pos_x+SPEED_PAD+pad_width > GAMESCREEN_WIDTH) | 1850 | if (pad_pos_x+SPEED_PAD+pad_width > GAMESCREEN_WIDTH) |
1850 | { | 1851 | { |
@@ -1861,8 +1862,8 @@ static int brickmania_game_loop(void) | |||
1861 | pad_pos_x+=SPEED_PAD; | 1862 | pad_pos_x+=SPEED_PAD; |
1862 | } | 1863 | } |
1863 | } | 1864 | } |
1864 | else if ((button_left && flip_sides==false) || | 1865 | else if ((button_left && !flip_sides) || |
1865 | (button_right && flip_sides==true)) | 1866 | (button_right && flip_sides)) |
1866 | { | 1867 | { |
1867 | if (pad_pos_x-SPEED_PAD < 0) | 1868 | if (pad_pos_x-SPEED_PAD < 0) |
1868 | { | 1869 | { |
@@ -1879,17 +1880,20 @@ static int brickmania_game_loop(void) | |||
1879 | pad_pos_x-=SPEED_PAD; | 1880 | pad_pos_x-=SPEED_PAD; |
1880 | } | 1881 | } |
1881 | } | 1882 | } |
1882 | #ifdef HAVE_TOUCHSCREEN | ||
1883 | } | 1883 | } |
1884 | |||
1885 | switch(button) | ||
1886 | { | ||
1887 | #if defined(HAVE_TOUCHSCREEN) | ||
1888 | case (BUTTON_REL | BUTTON_TOUCHSCREEN): | ||
1884 | #endif | 1889 | #endif |
1885 | |||
1886 | |||
1887 | switch(button) { | ||
1888 | case UP: | 1890 | case UP: |
1889 | case SELECT: | 1891 | case SELECT: |
1890 | if (game_state==ST_READY) { | 1892 | if (game_state==ST_READY) |
1893 | { | ||
1891 | /* Initialize used balls starting speed */ | 1894 | /* Initialize used balls starting speed */ |
1892 | for(k=0 ; k < used_balls ; k++) { | 1895 | for(k=0 ; k < used_balls ; k++) |
1896 | { | ||
1893 | ball[k].speedy = SPEED_4Q_Y; | 1897 | ball[k].speedy = SPEED_4Q_Y; |
1894 | if(pad_pos_x + (pad_width/2) >= GAMESCREEN_WIDTH/2) | 1898 | if(pad_pos_x + (pad_width/2) >= GAMESCREEN_WIDTH/2) |
1895 | { | 1899 | { |
@@ -1955,15 +1959,17 @@ static int brickmania_game_loop(void) | |||
1955 | INT3(GAMESCREEN_HEIGHT - GAMEOVER_HEIGHT)/2, | 1959 | INT3(GAMESCREEN_HEIGHT - GAMEOVER_HEIGHT)/2, |
1956 | INT3(GAMEOVER_WIDTH),INT3(GAMEOVER_HEIGHT) ); | 1960 | INT3(GAMEOVER_WIDTH),INT3(GAMEOVER_HEIGHT) ); |
1957 | #endif | 1961 | #endif |
1958 | rb->splash(HZ*2, s); | ||
1959 | rb->lcd_update(); | 1962 | rb->lcd_update(); |
1960 | brickmania_sleep(2); | 1963 | brickmania_sleep(2); |
1961 | return 0; | 1964 | return 0; |
1962 | } | 1965 | } |
1966 | |||
1967 | /* Game always needs to yield for other threads */ | ||
1968 | rb->yield(); | ||
1969 | |||
1970 | /* Sleep for a bit if there is time to spare */ | ||
1963 | if (end > *rb->current_tick) | 1971 | if (end > *rb->current_tick) |
1964 | rb->sleep(end-*rb->current_tick); | 1972 | rb->sleep(end-*rb->current_tick); |
1965 | else | ||
1966 | rb->yield(); | ||
1967 | } | 1973 | } |
1968 | return 0; | 1974 | return 0; |
1969 | } | 1975 | } |