coastline 0.0.4
Loading...
Searching...
No Matches
sprite.h File Reference

The sprites of the menus: pictures loaded from the cartridge and drawn in strips, and the rectangles of solid colour drawn with them. More...

#include <PR/ultratypes.h>
Include dependency graph for sprite.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  Sprite
 A picture of the menus. More...

Macros

#define SPRITE_STYLE_TINTED   99
 The style of an 8-bit sprite that draws it in the primitive colour times its texels.
#define WITH_PALETTE(value, palette)
 An argument followed by a palette, in the releases whose sprite routines take one.

Functions

void LoadTextureFromRom (Sprite *sprite)
 Allocate memory for a sprite and decompress it there from the cartridge.
void DrawSpriteAtOrigin (Sprite *sprite, u16 *palette)
 Draw a sprite at its origin, at its size on the screen.
void DrawTexturedSprite (Sprite *sprite, s32 x, s32 y)
 Draw a sprite at a position.
void DrawSpriteTinted (Sprite *sprite, u8 red, u8 green, u8 blue)
 Draw a sprite at its origin in a colour.
void DrawSpriteRegion (Sprite *sprite, s32 x, s32 y, s32 width, s32 height, u8 red, u8 green, u8 blue)
 Draw a sprite stretched over a rectangle in a colour.
void DrawSpriteStrip (Sprite *sprite, u8 *pixels, u16 *palette, s32 width, s32 height, s32 x, s32 y, s32 drawWidth, s32 drawHeight, u8 red, u8 green, u8 blue)
 Draw one strip of a sprite stretched over a rectangle, upside down to match the bottom-up rows.
void DrawScaledTexturedRect (Sprite *sprite, s32 srcX, s32 srcY, s32 srcWidth, s32 srcHeight, s32 x, s32 y, s32 width, s32 height, u8 red, u8 green, u8 blue)
 Draw a rectangle of the texels of a 4-bit sprite stretched over a rectangle of the screen in a colour, upside down.
void DrawPixel (s32 x, s32 y, u8 shade)
 Fill one pixel in a grey.
void DrawRectOutline (s32 x, s32 y, s32 width, s32 height, s32 thickness, u8 red, u8 green, u8 blue)
 Draw the outline of a rectangle in a colour, inside its edges.
void DrawFilledRectHiRes (s32 x, s32 y, s32 width, s32 height, u8 red, u8 green, u8 blue)
 Fill a rectangle in a colour.
void DrawRectBorder (s32 x, s32 y, s32 width, s32 height, s32 border, u8 transparent, u8 sunken, u8 red, u8 green, u8 blue)
 Draw a box with a bevelled border outside its edges, light at the top and the left and dark at the bottom and the right, or the other way round when sunken.

Detailed Description

The sprites of the menus: pictures loaded from the cartridge and drawn in strips, and the rectangles of solid colour drawn with them.

Macro Definition Documentation

◆ SPRITE_STYLE_TINTED

#define SPRITE_STYLE_TINTED   99

The style of an 8-bit sprite that draws it in the primitive colour times its texels.

◆ WITH_PALETTE

#define WITH_PALETTE ( value,
palette )
Value:
(value), (palette)

An argument followed by a palette, in the releases whose sprite routines take one.

Function Documentation

◆ LoadTextureFromRom()

void LoadTextureFromRom ( Sprite * sprite)

Allocate memory for a sprite and decompress it there from the cartridge.

A picture whose size does not match its dimensions is reported on the debug output, and the game then halts.

Parameters
spriteThe sprite to load.
Ghidra address:
USA: 0x80242b10
Ghidra address:
Asia: 0x80242660
Ghidra address:
EUR: 0x80244020
Ghidra address:
JPN: 0x80243b20

◆ DrawSpriteAtOrigin()

void DrawSpriteAtOrigin ( Sprite * sprite,
u16 * palette )

Draw a sprite at its origin, at its size on the screen.

Parameters
spriteThe sprite to draw. European and Japanese releases also take the palette of the texels, or NULL.
Ghidra address:
USA: 0x80245470
Ghidra address:
Asia: 0x80244FC0
Ghidra address:
EUR: 0x80246994
Ghidra address:
JPN: 0x802464cc
Parameters
paletteThe palette of the texels, or NULL.

◆ DrawTexturedSprite()

void DrawTexturedSprite ( Sprite * sprite,
s32 x,
s32 y )

Draw a sprite at a position.

Parameters
spriteThe sprite to draw.
xThe X coordinate on the screen.
yThe Y coordinate on the screen.
Ghidra address:
USA: 0x80245604
Ghidra address:
Asia: 0x80245154
Ghidra address:
EUR: 0x80246b3c
Ghidra address:
JPN: 0x80246674

◆ DrawSpriteTinted()

void DrawSpriteTinted ( Sprite * sprite,
u8 red,
u8 green,
u8 blue )

Draw a sprite at its origin in a colour.

Only a 4-bit sprite and a tinted 8-bit sprite take the colour.

Parameters
spriteThe sprite to draw.
redThe red component of the colour.
greenThe green component of the colour.
blueThe blue component of the colour.
Ghidra address:
USA: 0x80245798
Ghidra address:
Asia: 0x802452E8
Ghidra address:
EUR: 0x80246cd8
Ghidra address:
JPN: 0x80246810

◆ DrawSpriteRegion()

void DrawSpriteRegion ( Sprite * sprite,
s32 x,
s32 y,
s32 width,
s32 height,
u8 red,
u8 green,
u8 blue )

Draw a sprite stretched over a rectangle in a colour.

Parameters
spriteThe sprite to draw.
xThe left edge of the rectangle on the screen.
yThe top edge of the rectangle on the screen.
widthThe width of the rectangle.
heightThe height of the rectangle.
redThe red component of the colour.
greenThe green component of the colour.
blueThe blue component of the colour.
Ghidra address:
USA: 0x8024594c
Ghidra address:
Asia: 0x8024549C
Ghidra address:
EUR: 0x80246e94
Ghidra address:
JPN: 0x802469cc

◆ DrawSpriteStrip()

void DrawSpriteStrip ( Sprite * sprite,
u8 * pixels,
u16 * palette,
s32 width,
s32 height,
s32 x,
s32 y,
s32 drawWidth,
s32 drawHeight,
u8 red,
u8 green,
u8 blue )

Draw one strip of a sprite stretched over a rectangle, upside down to match the bottom-up rows.

The depth of the sprite picks the format and the combiner. A depth other than 4, 8, or 16 loads nothing and draws the rectangle with the texture memory as it is.

Parameters
spriteThe sprite the strip belongs to.
pixelsThe texels of the strip. European and Japanese releases also take the palette of a 4-bit strip of colour indices, or NULL for an intensity strip.
widthThe width of the strip in texels.
heightThe height of the strip in texels.
xThe left edge on the screen.
yThe top edge on the screen.
drawWidthThe width on the screen, negative to mirror the strip.
drawHeightThe height on the screen.
redThe red component of the primitive colour.
greenThe green component of the primitive colour.
blueThe blue component of the primitive colour.
Ghidra address:
USA: 0x80245b00
Ghidra address:
Asia: 0x80245650
Ghidra address:
EUR: 0x80247050
Ghidra address:
JPN: 0x80246b88
Parameters
paletteThe palette of a 4-bit strip of colour indices, or NULL for intensity.

◆ DrawScaledTexturedRect()

void DrawScaledTexturedRect ( Sprite * sprite,
s32 srcX,
s32 srcY,
s32 srcWidth,
s32 srcHeight,
s32 x,
s32 y,
s32 width,
s32 height,
u8 red,
u8 green,
u8 blue )

Draw a rectangle of the texels of a 4-bit sprite stretched over a rectangle of the screen in a colour, upside down.

The texels loaded extend one column and one row past the source rectangle.

Parameters
spriteThe sprite to draw from.
srcXThe left edge of the source rectangle in texels.
srcYThe top edge of the source rectangle in texels.
srcWidthThe width of the source rectangle in texels.
srcHeightThe height of the source rectangle in texels.
xThe left edge on the screen.
yThe top edge on the screen.
widthThe width on the screen.
heightThe height on the screen.
redThe red component of the colour.
greenThe green component of the colour.
blueThe blue component of the colour.
Ghidra address:
USA: 0x802465f0
Ghidra address:
Asia: 0x80246140
Ghidra address:
EUR: 0x80247ca0
Ghidra address:
JPN: 0x802477d8

◆ DrawPixel()

void DrawPixel ( s32 x,
s32 y,
u8 shade )

Fill one pixel in a grey.

Parameters
xThe X coordinate on the screen.
yThe Y coordinate on the screen.
shadeThe level of the grey.
Ghidra address:
USA: 0x80246a80
Ghidra address:
Asia: 0x802465D0
Ghidra address:
EUR: 0x80248130
Ghidra address:
JPN: 0x80247c68

◆ DrawRectOutline()

void DrawRectOutline ( s32 x,
s32 y,
s32 width,
s32 height,
s32 thickness,
u8 red,
u8 green,
u8 blue )

Draw the outline of a rectangle in a colour, inside its edges.

Parameters
xThe left edge on the screen.
yThe top edge on the screen.
widthThe width.
heightThe height.
thicknessThe thickness of the outline, at least 1 once the screen scale applies.
redThe red component of the colour.
greenThe green component of the colour.
blueThe blue component of the colour.
Ghidra address:
USA: 0x80246bcc
Ghidra address:
Asia: 0x8024671C
Ghidra address:
EUR: 0x8024827c
Ghidra address:
JPN: 0x80247db4

◆ DrawFilledRectHiRes()

void DrawFilledRectHiRes ( s32 x,
s32 y,
s32 width,
s32 height,
u8 red,
u8 green,
u8 blue )

Fill a rectangle in a colour.

A width or height under 1 once the screen scale applies is 1.

Parameters
xThe left edge on the screen.
yThe top edge on the screen.
widthThe width.
heightThe height.
redThe red component of the colour.
greenThe green component of the colour.
blueThe blue component of the colour.
Ghidra address:
USA: 0x80246e10
Ghidra address:
Asia: 0x80246960
Ghidra address:
EUR: 0x802484c0
Ghidra address:
JPN: 0x80247ff8

◆ DrawRectBorder()

void DrawRectBorder ( s32 x,
s32 y,
s32 width,
s32 height,
s32 border,
u8 transparent,
u8 sunken,
u8 red,
u8 green,
u8 blue )

Draw a box with a bevelled border outside its edges, light at the top and the left and dark at the bottom and the right, or the other way round when sunken.

Parameters
xThe left edge of the box.
yThe top edge of the box.
widthThe width of the box.
heightThe height of the box.
borderThe width of the border, at least 1 once the screen scale applies.
transparentWhether the inside of the box is not filled.
sunken1 to swap the light and the dark shades of the border.
redThe red component of the colour inside the box.
greenThe green component of the colour inside the box.
blueThe blue component of the colour inside the box.
Ghidra address:
USA: 0x80246f90
Ghidra address:
Asia: 0x80246AE0
Ghidra address:
EUR: 0x80248640
Ghidra address:
JPN: 0x80248178