mirror of
https://github.com/eried/portapack-mayhem.git
synced 2025-06-25 15:20:31 -04:00
Create optimised integer functions to reduce CPU usage
(cherry picked from commit a47bfe1da7bffe9f752e4c522e11593cce6dffd0)
This commit is contained in:
parent
b549d3a4f1
commit
567fee1d98
4 changed files with 85 additions and 0 deletions
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "ui.hpp"
|
||||
#include "sine_table.hpp"
|
||||
#include "utility.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
@ -96,4 +97,10 @@ Point polar_to_point(float angle, uint32_t distance) {
|
|||
sin_f32(DEG_TO_RAD(-angle) - (pi / 2)) * distance);
|
||||
}
|
||||
|
||||
Point fast_polar_to_point(int32_t angle, uint32_t distance) {
|
||||
//polar to compass with y negated for screen drawing
|
||||
return Point((int16_sin_s4(((1<<16)*(-angle + 180))/360) * distance)/(1<<16),
|
||||
(int16_sin_s4(((1<<16)*(-angle - 90))/360) * distance)/(1<<16));
|
||||
}
|
||||
|
||||
} /* namespace ui */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue