8#define VISIBLE_SCANLINES 160
101 s32 targetDeltaX = target->
x;
102 s32 targetZ = target->
z;
106 depth = targetZ - eyeZ;
107 targetDeltaX -= eyeX;
112 originX =
MulQ16(target->
x, 0x8000);
113 originZ =
MulQ16(target->
z, 0x8000);
119 negativeSinYaw = -sinYaw;
121 s32 widthScale = line->
x;
123 s32 horizontalOffset;
129 affinePa = -(
MulQ16(widthScale, cosYaw) / 256);
130 horizontalOffset = (
s16)affinePa;
132 affine->
pa = affinePa;
133 affinePc =
MulQ16(widthScale, sinYaw) / 256;
135 affine->
pc = affinePc;
143 horizontalOffset = (horizontalOffset * 256) * centerX;
144 depthOffset = ((
s16)affinePc * 256) * -centerX;
146 horizontalOffset = (horizontalOffset << 8) * centerX;
147 depthOffset = ((
s16)affinePc << 8) * -centerX;
149 line->
dx = -(horizontalOffset +
MulQ16(negativeSinYaw, depth));
150 line->
dz = depthOffset +
MulQ16(cosYaw, depth);
151 affine->
x = (originX + line->
dx) >> 8;
152 affine->
y = (originZ + line->
dz) >> 8;
153 affine[1] = affine[0];
169 sampleOffset = ((originX + line->
dx) >> 8) + line->
v / 4 + line->
u / 2;
170 affine->
x = sampleOffset;
171 sampleOffset = line->
u;
173 ((originZ + line->
dz) >> 8) + sampleOffset / 4 + line->
v / 2;
175 affine->
x = (originX + line->
dx) >> 8;
176 affine->
y = (originZ + line->
dz) >> 8;
178 affine->
pa = line->
u;
179 affine->
pc = line->
v;
180 affine[1] = affine[0];
The frame loop's globals: lag counts, the CPU load display and the VBlank flags.
volatile u32 gFrameCount
Frames WaitFrames has finished.
MulQ16, the 16.16 fixed-point multiply.
static __inline__ s32 MulQ16(s32 left, s32 right)
Multiplies 16.16 fixed-point values, returning the middle 32 product bits.
struct Projection gProjection
STATIC_ASSERT, a compile-time check that emits nothing.
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
One background's affine registers, BG2PA to BG2Y.
s16 pb
not written by this routine
s16 pd
not written by this routine
The camera's eye or target point, as this routine reads it.
A runtime table entry whose two-argument target this routine calls, the arctangent.
s32(*) target(s32 x, s32 y)
The runtime table's prefix through Trig_Cos, in its assembly order.
struct RuntimeMathUnaryEntry cos
struct RuntimeMathBinaryEntry atan2
struct RuntimeUnusedEntry preceding[8]
struct RuntimeUnusedEntry squareRoots[2]
struct RuntimeMathUnaryEntry sin
A runtime table entry whose one-argument target this routine calls, the sine or the cosine.
An eight-byte runtime entry contains the ldr/bx instructions and a target word.
One scanline of the world map's ground plane.
s32 x
the line's width scale
s32 dz
the texture y offset from the origin, before >> 8
s32 dx
the texture x offset from the origin, before >> 8
The integer types, TRUE, UNUSED and the fixed-address macros.
const struct RuntimeMathTable FarCall_RuntimeTable
void Transform_UpdateVertices(struct Position *eye, struct Position *target, struct ScanVertex *line, struct BgAffine *affine)
Builds the world map's per-scanline affine table for one frame: the ground plane seen from eye toward...
#define VISIBLE_SCANLINES
visible scanlines