diff options
author | Ben Bridle <ben@derelict.engineering> | 2025-09-19 13:17:14 +1200 |
---|---|---|
committer | Ben Bridle <ben@derelict.engineering> | 2025-09-19 13:32:32 +1200 |
commit | bb1aa5958d1b67707dcf0f6b08bfaf0b408bd46e (patch) | |
tree | b26d07ed58aaf7a5230fc3e28c103d616abfa9b8 /arm9/source/devices/math.h | |
parent | 9612c307f00c4313d73fe0c3a86c05c8d8cd514e (diff) | |
download | bedrock-nds-bb1aa5958d1b67707dcf0f6b08bfaf0b408bd46e.zip |
Massive rewrite
This commit rewrites the emulator halfway from scratch to make it
easier to change and maintain in the future. The emulator core was
rewritten to adhere to the released Bedrock specification (earlier
versions implemented an older prototype specification, which is no
longer relevant).
This commit also adds proper support for running multiple concurrent
Bedrock instances. This was previously supported in a limited manner
for the on-screen keyboard, but now works for any regular program as
well, with switching being performed by pressing the L or R bumper
buttons. This is disabled by default, as programs will still need to
be baked into the emulator and hand-loaded.
Diffstat (limited to 'arm9/source/devices/math.h')
-rw-r--r-- | arm9/source/devices/math.h | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/arm9/source/devices/math.h b/arm9/source/devices/math.h index ae52a10..6b173b6 100644 --- a/arm9/source/devices/math.h +++ b/arm9/source/devices/math.h @@ -1,19 +1,33 @@ #ifndef MATH_H_ #define MATH_H_ + #include <math.h> + #include "../bang.h" + + + // Bedrock math device. typedef struct { - u16 op1, op2; - u16 sqrt, atan; u32 prod; u16 quot, rem; // read - bool sqrt_rc, atan_rc, prod_rc, quot_rc, rem_rc; // read cached - } MathDevice ; + s16 x, y; // Cartesian write + u16 r, t; // Polar write + s16 x_read, y_read; // Cartesian read + bool x_cached, y_cached; // Cartesian cached + u16 r_read, t_read; // Polar read + bool r_cached, t_cached; // Polar cached + u32 prod_read; // Multiplication read + bool prod_cached; // Multiplication cached + u16 quot_read, rem_read; // Division read + bool quot_cached, rem_cached; // Division cached + } MathDevice; - void set_op1_high(MathDevice *math, u8 high); - void set_op1_low(MathDevice *math, u8 low); - void set_op2_high(MathDevice *math, u8 high); - void set_op2_low(MathDevice *math, u8 low); - u16 get_sqrt(MathDevice *math); - u16 get_atan(MathDevice *math); - u32 get_prod(MathDevice *math); - u16 get_quot(MathDevice *math); - u16 get_rem(MathDevice *math); + // Methods. + void math_reset(MathDevice *math); + void math_clear_cartesian(MathDevice *math); + void math_clear_polar(MathDevice *math); + s16 math_get_x(MathDevice *math); + s16 math_get_y(MathDevice *math); + u16 math_get_r(MathDevice *math); + u16 math_get_t(MathDevice *math); + u32 math_get_prod(MathDevice *math); + u16 math_get_quot(MathDevice *math); + u16 math_get_rem(MathDevice *math); #endif |