// Fixed-point math helpers that mirror the conventions used by the // FS2 disassembly: byte angles (256 == full turn), 16-bit signed // magnitudes scaled to fit ±$7FFF. #ifndef MATH6502_H #define MATH6502_H #include void math6502Init(void); // sin(byteAngle) -> -32767..32767. Matches `SinByteAngle` in the // disassembly. int16_t math6502Sin(uint8_t byteAngle); // cos(byteAngle) -> -32767..32767. int16_t math6502Cos(uint8_t byteAngle); // (Y * X) signed, returns the 16-bit signed product. Matches // `MultiplyXY` in the disassembly. int16_t math6502SignedMul(int8_t y, int8_t x); // Integer square root of a non-negative int32. Returns 0 for negative // input. Matches the standard hardware-trick algorithm; precision is // exact when the answer fits in 16 bits. uint16_t math6502Sqrt(int32_t n); #endif