diff options
author | Bertrik Sikken <bertrik@sikken.nl> | 2009-10-18 15:50:30 +0000 |
---|---|---|
committer | Bertrik Sikken <bertrik@sikken.nl> | 2009-10-18 15:50:30 +0000 |
commit | d24d885aa42b5087d89f12dabad13895051da4e2 (patch) | |
tree | 61584fe54660aab9a57bcb67c5a65cb888f4a38b /apps | |
parent | 1c64a4d3e0a4ae2f4eb537f00c7dc4372ca5df88 (diff) | |
download | rockbox-d24d885aa42b5087d89f12dabad13895051da4e2.tar.gz rockbox-d24d885aa42b5087d89f12dabad13895051da4e2.zip |
Use wrap-safe TIME_BEFORE/TIME_AFTER macros to compare times with current_time, instead of comparing them directly.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@23246 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/gui/list.c | 3 | ||||
-rw-r--r-- | apps/plugins/brickmania.c | 6 | ||||
-rw-r--r-- | apps/plugins/clix.c | 4 | ||||
-rw-r--r-- | apps/plugins/invadrox.c | 2 | ||||
-rw-r--r-- | apps/plugins/mandelbrot.c | 4 | ||||
-rw-r--r-- | apps/plugins/pong.c | 24 | ||||
-rw-r--r-- | apps/plugins/rockblox1d.c | 2 | ||||
-rw-r--r-- | apps/plugins/spacerocks.c | 2 | ||||
-rw-r--r-- | apps/plugins/xobox.c | 2 | ||||
-rw-r--r-- | apps/tagcache.c | 2 |
10 files changed, 25 insertions, 26 deletions
diff --git a/apps/gui/list.c b/apps/gui/list.c index d7ecdccd30..a9d8ff6d9b 100644 --- a/apps/gui/list.c +++ b/apps/gui/list.c | |||
@@ -599,8 +599,7 @@ bool gui_synclist_do_button(struct gui_synclist * lists, | |||
599 | { | 599 | { |
600 | if (!last_accel_tick) | 600 | if (!last_accel_tick) |
601 | last_accel_tick = current_tick + start_delay; | 601 | last_accel_tick = current_tick + start_delay; |
602 | else if (current_tick >= | 602 | else if (TIME_AFTER(current_tick, last_accel_tick + accel_wait)) |
603 | last_accel_tick + accel_wait) | ||
604 | { | 603 | { |
605 | last_accel_tick = current_tick; | 604 | last_accel_tick = current_tick; |
606 | next_item_modifier++; | 605 | next_item_modifier++; |
diff --git a/apps/plugins/brickmania.c b/apps/plugins/brickmania.c index 3f79f7c7d6..9bf4cf2b06 100644 --- a/apps/plugins/brickmania.c +++ b/apps/plugins/brickmania.c | |||
@@ -1067,7 +1067,7 @@ static void brickmania_sleep(int secs) | |||
1067 | { | 1067 | { |
1068 | if (count == 0) | 1068 | if (count == 0) |
1069 | count = *rb->current_tick + HZ*secs; | 1069 | count = *rb->current_tick + HZ*secs; |
1070 | if ( (*rb->current_tick >= count) && (vscore == score) ) | 1070 | if ( (TIME_AFTER(*rb->current_tick, count)) && (vscore == score) ) |
1071 | done = true; | 1071 | done = true; |
1072 | 1072 | ||
1073 | if(vscore != score) | 1073 | if(vscore != score) |
@@ -1323,7 +1323,7 @@ static int brickmania_game_loop(void) | |||
1323 | 1323 | ||
1324 | if (flip_sides) | 1324 | if (flip_sides) |
1325 | { | 1325 | { |
1326 | if (*rb->current_tick>=sec_count) | 1326 | if (TIME_AFTER(*rb->current_tick, sec_count)) |
1327 | { | 1327 | { |
1328 | sec_count=*rb->current_tick+HZ; | 1328 | sec_count=*rb->current_tick+HZ; |
1329 | if (num_count!=0) | 1329 | if (num_count!=0) |
@@ -2111,7 +2111,7 @@ static int brickmania_game_loop(void) | |||
2111 | rb->yield(); | 2111 | rb->yield(); |
2112 | 2112 | ||
2113 | /* Sleep for a bit if there is time to spare */ | 2113 | /* Sleep for a bit if there is time to spare */ |
2114 | if (end > *rb->current_tick) | 2114 | if (TIME_BEFORE(*rb->current_tick, end)) |
2115 | rb->sleep(end-*rb->current_tick); | 2115 | rb->sleep(end-*rb->current_tick); |
2116 | } | 2116 | } |
2117 | return 0; | 2117 | return 0; |
diff --git a/apps/plugins/clix.c b/apps/plugins/clix.c index 9c53bdab70..68c56ec1d5 100644 --- a/apps/plugins/clix.c +++ b/apps/plugins/clix.c | |||
@@ -684,7 +684,7 @@ static int clix_handle_game(struct clix_game_state_t* state) | |||
684 | 684 | ||
685 | while(true) | 685 | while(true) |
686 | { | 686 | { |
687 | if (blink_tick < *rb->current_tick) { | 687 | if (TIME_AFTER(*rb->current_tick, blink_tick)) { |
688 | state->blink = state->blink ? false : true; | 688 | state->blink = state->blink ? false : true; |
689 | blink_tick = *rb->current_tick + BLINK_TICKCOUNT; | 689 | blink_tick = *rb->current_tick + BLINK_TICKCOUNT; |
690 | } | 690 | } |
@@ -692,7 +692,7 @@ static int clix_handle_game(struct clix_game_state_t* state) | |||
692 | time = 6; /* number of ticks this function will loop reading keys */ | 692 | time = 6; /* number of ticks this function will loop reading keys */ |
693 | start = *rb->current_tick; | 693 | start = *rb->current_tick; |
694 | end = start + time; | 694 | end = start + time; |
695 | while(end > *rb->current_tick) | 695 | while(TIME_BEFORE(*rb->current_tick, end)) |
696 | { | 696 | { |
697 | oldx = state->x; | 697 | oldx = state->x; |
698 | oldy = state->y; | 698 | oldy = state->y; |
diff --git a/apps/plugins/invadrox.c b/apps/plugins/invadrox.c index 1886ed4b49..b3e5d164c6 100644 --- a/apps/plugins/invadrox.c +++ b/apps/plugins/invadrox.c | |||
@@ -1751,7 +1751,7 @@ void game_loop(void) | |||
1751 | 1751 | ||
1752 | /* Wait until next frame */ | 1752 | /* Wait until next frame */ |
1753 | DBG("%ld (%d)\n", end - *rb->current_tick, (CYCLETIME * HZ) / 1000); | 1753 | DBG("%ld (%d)\n", end - *rb->current_tick, (CYCLETIME * HZ) / 1000); |
1754 | if (end > *rb->current_tick) { | 1754 | if (TIME_BEFORE(*rb->current_tick, end)) { |
1755 | rb->sleep(end - *rb->current_tick); | 1755 | rb->sleep(end - *rb->current_tick); |
1756 | } else { | 1756 | } else { |
1757 | rb->yield(); | 1757 | rb->yield(); |
diff --git a/apps/plugins/mandelbrot.c b/apps/plugins/mandelbrot.c index 00542cbb14..dbab55579d 100644 --- a/apps/plugins/mandelbrot.c +++ b/apps/plugins/mandelbrot.c | |||
@@ -643,7 +643,7 @@ void calc_mandelbrot_low_prec(void) | |||
643 | 643 | ||
644 | /* be nice to other threads: | 644 | /* be nice to other threads: |
645 | * if at least one tick has passed, yield */ | 645 | * if at least one tick has passed, yield */ |
646 | if (*rb->current_tick > last_yield) { | 646 | if (TIME_AFTER(*rb->current_tick, last_yield)) { |
647 | rb->yield(); | 647 | rb->yield(); |
648 | last_yield = *rb->current_tick; | 648 | last_yield = *rb->current_tick; |
649 | } | 649 | } |
@@ -706,7 +706,7 @@ void calc_mandelbrot_high_prec(void) | |||
706 | 706 | ||
707 | /* be nice to other threads: | 707 | /* be nice to other threads: |
708 | * if at least one tick has passed, yield */ | 708 | * if at least one tick has passed, yield */ |
709 | if (*rb->current_tick > last_yield) { | 709 | if (TIME_AFTER(*rb->current_tick, last_yield)) { |
710 | rb->yield(); | 710 | rb->yield(); |
711 | last_yield = *rb->current_tick; | 711 | last_yield = *rb->current_tick; |
712 | } | 712 | } |
diff --git a/apps/plugins/pong.c b/apps/plugins/pong.c index a6144d9664..1c6f02eb0d 100644 --- a/apps/plugins/pong.c +++ b/apps/plugins/pong.c | |||
@@ -450,21 +450,21 @@ int keys(struct pong *p) | |||
450 | int start = *rb->current_tick; | 450 | int start = *rb->current_tick; |
451 | int end = start + time; | 451 | int end = start + time; |
452 | 452 | ||
453 | while(end > *rb->current_tick) { | 453 | while(TIME_BEFORE(*rb->current_tick, end)) { |
454 | key = rb->button_get_w_tmo(end - *rb->current_tick); | 454 | key = rb->button_get_w_tmo(end - *rb->current_tick); |
455 | 455 | ||
456 | #ifdef HAVE_TOUCHSCREEN | 456 | #ifdef HAVE_TOUCHSCREEN |
457 | short touch_x, touch_y; | 457 | short touch_x, touch_y; |
458 | if(key & BUTTON_TOUCHSCREEN) | 458 | if(key & BUTTON_TOUCHSCREEN) |
459 | { | 459 | { |
460 | touch_x = rb->button_get_data() >> 16; | 460 | touch_x = rb->button_get_data() >> 16; |
461 | touch_y = rb->button_get_data() & 0xFFFF; | 461 | touch_y = rb->button_get_data() & 0xFFFF; |
462 | if(touch_x >= xpos[0] && touch_x <= xpos[0]+(PAD_WIDTH*4)) | 462 | if(touch_x >= xpos[0] && touch_x <= xpos[0]+(PAD_WIDTH*4)) |
463 | padmove(&p->w_pad[0], touch_y-(p->e_pad[0]*2+PAD_HEIGHT)/2); | 463 | padmove(&p->w_pad[0], touch_y-(p->e_pad[0]*2+PAD_HEIGHT)/2); |
464 | 464 | ||
465 | if(touch_x >= xpos[1]-(PAD_WIDTH*4) && touch_x <= xpos[1]) | 465 | if(touch_x >= xpos[1]-(PAD_WIDTH*4) && touch_x <= xpos[1]) |
466 | padmove(&p->w_pad[1], touch_y-(p->e_pad[1]*2+PAD_HEIGHT)/2); | 466 | padmove(&p->w_pad[1], touch_y-(p->e_pad[1]*2+PAD_HEIGHT)/2); |
467 | } | 467 | } |
468 | #endif | 468 | #endif |
469 | 469 | ||
470 | #ifdef HAS_BUTTON_HOLD | 470 | #ifdef HAS_BUTTON_HOLD |
diff --git a/apps/plugins/rockblox1d.c b/apps/plugins/rockblox1d.c index 12f05bb639..441615845d 100644 --- a/apps/plugins/rockblox1d.c +++ b/apps/plugins/rockblox1d.c | |||
@@ -302,7 +302,7 @@ enum plugin_status plugin_start(const void* parameter) | |||
302 | ++pos_cur_brick; | 302 | ++pos_cur_brick; |
303 | } | 303 | } |
304 | 304 | ||
305 | if (end > *rb->current_tick) | 305 | if (TIME_BEFORE(*rb->current_tick, end)) |
306 | rb->sleep(end-*rb->current_tick); | 306 | rb->sleep(end-*rb->current_tick); |
307 | else | 307 | else |
308 | rb->yield(); | 308 | rb->yield(); |
diff --git a/apps/plugins/spacerocks.c b/apps/plugins/spacerocks.c index ded3900b05..0061967f8b 100644 --- a/apps/plugins/spacerocks.c +++ b/apps/plugins/spacerocks.c | |||
@@ -2059,7 +2059,7 @@ static int spacerocks_game_loop(void) | |||
2059 | if(next_thrust_count) | 2059 | if(next_thrust_count) |
2060 | next_thrust_count--; | 2060 | next_thrust_count--; |
2061 | 2061 | ||
2062 | if (end > *rb->current_tick) | 2062 | if (TIME_BEFORE(*rb->current_tick, end)) |
2063 | rb->sleep(end-*rb->current_tick); | 2063 | rb->sleep(end-*rb->current_tick); |
2064 | else | 2064 | else |
2065 | rb->yield(); | 2065 | rb->yield(); |
diff --git a/apps/plugins/xobox.c b/apps/plugins/xobox.c index 3b7ada31f4..423322098a 100644 --- a/apps/plugins/xobox.c +++ b/apps/plugins/xobox.c | |||
@@ -1045,7 +1045,7 @@ static int xobox_loop (void) | |||
1045 | } | 1045 | } |
1046 | } | 1046 | } |
1047 | 1047 | ||
1048 | if (end > *rb->current_tick) | 1048 | if (TIME_BEFORE(*rb->current_tick, end)) |
1049 | rb->sleep (end - *rb->current_tick); | 1049 | rb->sleep (end - *rb->current_tick); |
1050 | else | 1050 | else |
1051 | rb->yield (); | 1051 | rb->yield (); |
diff --git a/apps/tagcache.c b/apps/tagcache.c index 4d4935a6b6..a5df2f0ad1 100644 --- a/apps/tagcache.c +++ b/apps/tagcache.c | |||
@@ -352,7 +352,7 @@ static bool do_timed_yield(void) | |||
352 | { | 352 | { |
353 | /* Sorting can lock up for quite a while, so yield occasionally */ | 353 | /* Sorting can lock up for quite a while, so yield occasionally */ |
354 | static long wakeup_tick = 0; | 354 | static long wakeup_tick = 0; |
355 | if (current_tick >= wakeup_tick) | 355 | if (TIME_AFTER(current_tick, wakeup_tick)) |
356 | { | 356 | { |
357 | wakeup_tick = current_tick + (HZ/4); | 357 | wakeup_tick = current_tick + (HZ/4); |
358 | yield(); | 358 | yield(); |