resonance 1.0.1
Loading...
Searching...
No Matches
APolygon Class Reference

Convex polygon for the ACanvas polygon fills, as vertex indices into a shared point array. More...

#include <apolygon.h>

Collaboration diagram for APolygon:

Public Member Functions

void SetupEdge (APolygonEdge *pEdge, short nFrom, int nDirection) const
 Start an edge at one vertex and aim it at a neighbour.
void SetupTexturedEdge (APolygonEdge *pEdge, short nFrom, int nDirection, const ABitmap *pTexture) const
 Start an edge as SetupEdge() does and add its texture walk.

Public Attributes

union { 
   unsigned int   mColor 
   const ABitmap *   mTexture 
}; 
short mReserved04
short mVertexCount
const APoint * mPoints
unsigned char mIndices [kAPolygonMaxVertexCount]
const APoint * mTexCoords

Detailed Description

Convex polygon for the ACanvas polygon fills, as vertex indices into a shared point array.

The record is not polymorphic and has no RTTI. Its two routines sit inside the ACanvas translation unit, between the ACanvas members that call them.

The record is at least 0x18 bytes. The index array runs from 0x0c to the texture coordinate pointer at 0x14, which bounds it at eight vertices. No reader of the halfword at 0x04 was located.

The first word has two readings. ACanvas::DrawFlatConvexPolygon() passes it to ACanvas::SetColorNative(), and ACanvas::DrawTmappedConvexPolygon() passes it as the source bitmap of ACanvas::DrawTmapRow8U(). It is modelled as a union of the two.

Every position is 24.8 fixed point. A vertex position is mPoints[mIndices[i]], while a texture coordinate is mTexCoords[i] with no indirection. Each texture coordinate is a fraction of the texture extent, because APolygon::SetupTexturedEdge() multiplies it by the texture width or height.

Member Function Documentation

◆ SetupEdge()

void APolygon::SetupEdge ( APolygonEdge * pEdge,
short nFrom,
int nDirection ) const

Start an edge at one vertex and aim it at a neighbour.

The neighbour is nFrom plus nDirection, wrapped to the vertex count at either end. The previous mBottom of the edge becomes its mTop, and the new mBottom is the neighbour's row rounded to the nearest whole row with AFix::onehalf. The column step is the column difference divided by the row count, or zero for an edge of no rows.

Parameters
pEdgeThe edge to fill.
nFromThe vertex position in mIndices the edge starts at.
nDirection1 to walk forward through mIndices, -1 to walk backward.
Ghidra address:
NTSC-U/C: 0x005e97c8
Ghidra address:
PAL: 0x0062b910

◆ SetupTexturedEdge()

void APolygon::SetupTexturedEdge ( APolygonEdge * pEdge,
short nFrom,
int nDirection,
const ABitmap * pTexture ) const

Start an edge as SetupEdge() does and add its texture walk.

Scales both texture coordinates of the edge by the texture extent. The texture step is written only for an edge of one row or more, so an empty edge retains the previous step.

Parameters
pEdgeThe edge to fill.
nFromThe vertex position in mIndices the edge starts at.
nDirection1 to walk forward through mIndices, -1 to walk backward.
pTextureThe texture whose extent scales the coordinates.
Ghidra address:
NTSC-U/C: 0x005e9bd8
Ghidra address:
PAL: 0x0062bd20

Member Data Documentation

◆ mColor

unsigned int APolygon::mColor

The fill colour in the canvas pixel format. +0x00

◆ mTexture

const ABitmap* APolygon::mTexture

The texture of a textured fill. +0x00

◆ [union]

union { ... } APolygon

◆ mReserved04

short APolygon::mReserved04

No reader was located. +0x04

◆ mVertexCount

short APolygon::mVertexCount

Vertices in mIndices. +0x06

◆ mPoints

const APoint* APolygon::mPoints

The shared vertex positions. +0x08

◆ mIndices

unsigned char APolygon::mIndices[kAPolygonMaxVertexCount]

Positions into mPoints. +0x0c

◆ mTexCoords

const APoint* APolygon::mTexCoords

Texture coordinates, one per vertex. +0x14


The documentation for this class was generated from the following file: