diff options
| author | XaviDCR92 <xavi.dcr@gmail.com> | 2017-11-05 18:00:57 +0100 |
|---|---|---|
| committer | XaviDCR92 <xavi.dcr@gmail.com> | 2017-11-05 18:00:57 +0100 |
| commit | 2d04eba931ac84e2f09d3c8391125f8a991ca7d3 (patch) | |
| tree | e4694bc9ae0072a927b25ef4bade962de822de0d /System.c | |
| parent | 8fba2176bc34aa7e507f0b9d983427bb5e522e17 (diff) | |
| download | pocketempires-2d04eba931ac84e2f09d3c8391125f8a991ca7d3.tar.gz | |
Deprecated use of sprintf() in favor of custom routine Systemitoa().
When B button is released and showActionsMenu == true, showActionsMenu = false.
Diffstat (limited to 'System.c')
| -rw-r--r-- | System.c | 58 |
1 files changed, 54 insertions, 4 deletions
@@ -104,7 +104,7 @@ void SystemRunTimers(void) void SystemCheckTimer(bool * timer, uint64_t * last_timer, uint8_t step) { - if (*timer == true) + if (*timer != false) { *timer = false; *last_timer = global_timer; @@ -215,9 +215,9 @@ void SystemUserTimersHandler(void) for (i = 0; i < SYSTEM_MAX_TIMERS; i++) { - if (timer_array[i].busy == true) + if (timer_array[i].busy != false) { - if (System1SecondTick() == true) + if (System1SecondTick() != false) { timer_array[i].time--; @@ -225,7 +225,7 @@ void SystemUserTimersHandler(void) { timer_array[i].Timeout_Callback(); - if (timer_array[i].repeat_flag == true) + if (timer_array[i].repeat_flag != false) { timer_array[i].time = timer_array[i].orig_time; } @@ -276,3 +276,53 @@ bool SystemCollisionCheck(TYPE_COLLISION_BLOCK* c1, TYPE_COLLISION_BLOCK* c2) return (bool)check_bb_collision( c1->x, c1->y, c1->w, c1->h, c2->x, c2->y, c2->w, c2->h ); } + +bool Systemitoa(char* str, size_t sz, int16_t value) +{ + if (sz != 0) + { + bool first_digit_found = false; + uint16_t i; + uint8_t j = 0; + + /* Example: 65535 */ + /* Another example: -32767 */ + + if (value & 0x8000) + { + /* Sign bit */ + str[j++] = '-'; + } + + for (i = 10000; i >= 1; i /= 10) + { + uint8_t digit = (uint8_t)(value / i); + value -= (uint16_t)(digit * i); + + if (digit != 0) + { + if (first_digit_found == false) + { + first_digit_found = true; + } + } + else if (first_digit_found == false) + { + continue; + } + + str[j++] = digit + '0'; + + if (j >= (sz - 1)) + { + return false; + } + } + + str[j] = '\0'; + + return true; + } + + return false; +} |
