.sinLo FOR I%, 0, 256 N = SIN((I% / 256) * (PI / 2)) IF N >= 1 B% = 255 ELSE B% = LO(INT(N * 65536)) ENDIF EQUB B% NEXTName: sinLo [Show more] Type: Variable Category: Maths Summary: Low byte of the sine lookup table Deep dive: TrigonometryContext: See this variable in context in the source code References: This variable is used as follows: * Sine16Bit uses sinLo
This table contains sine values for a quarter of a circle, i.e. for the range 0 to 90 degrees, or 0 to PI/2 radians. The table contains values for indexes 0 to 256, which cover the quarter from 0 to PI/2 radians. Entry X in the table is therefore (X / 256) * (PI / 2) radians of the way round the quarter circle, so the table at index X contains the sine of this value. The value of sine across the quarter circle ranges from 0 to 1: sin(0) = 0 sin(90) = sin(PI/2) = 1 but assembly language doesn't support fractions, so instead we store the sine in a 16-bit number that contains the sine multiplied by 65536, so the range of (sinHi sinLo) over the course of the quarter circle is 0 to 65536. It might help to think of sinHi as an integer ranging from 0 to 256 across the quarter circle, with sinLo as the fractional part ranging from 0 to 255; this is the approach taken in the Sine16Bit routine. In other words, entry X in this table contains sin(X) * 65536, where X ranges from 0 to 256 over the course of a quarter circle.