mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 10:42:07 +00:00
Use inttypes for stdint types
This should help make RGBDS portable to systems with 16-bit integers, like DOS. For kicks, use the macros for 16-bit and 8-bit integers. Fix other miscellaneous things, like #include ordering and other printf-format related things. Reduce repitition in math.c while I'm there.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
* Fixedpoint math routines
|
||||
*/
|
||||
|
||||
#include <inttypes.h>
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -37,12 +38,16 @@ void math_DefinePI(void)
|
||||
*/
|
||||
void math_Print(int32_t i)
|
||||
{
|
||||
if (i >= 0)
|
||||
printf("%d.%05d", i >> 16,
|
||||
((int32_t)(fx2double(i) * 100000 + 0.5)) % 100000);
|
||||
else
|
||||
printf("-%d.%05d", (-i) >> 16,
|
||||
((int32_t)(fx2double(-i) * 100000 + 0.5)) % 100000);
|
||||
uint32_t u = i;
|
||||
const char *sign = "";
|
||||
|
||||
if (i < 0) {
|
||||
u = -u;
|
||||
sign = "-";
|
||||
}
|
||||
|
||||
printf("%s%" PRIu32 ".%05" PRIu32, sign, u >> 16,
|
||||
((uint32_t)(fx2double(u) * 100000 + 0.5)) % 100000);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user