Table of Contents

Struct SpriteTable

Namespace
GB
Assembly
GBSharp.Framework.dll

Indexed access to OAM. Holds no state and occupies no memory.

public struct SpriteTable
Inherited Members

Fields

Count

The number of hardware sprites. Indices beyond this do nothing.

public const byte Count = 40

Field Value

byte

Properties

this[byte]

A typed view of one sprite. Costs nothing: this lowers to index itself.

public ref SpriteRef this[byte index] { get; }

Parameters

index byte

Property Value

SpriteRef

Methods

Hide(byte)

Moves a sprite off screen.

[Native("gbs_sprite_hide")]
public void Hide(byte id)

Parameters

id byte

HideAll()

Moves every sprite off screen.

[Native("gbs_sprites_hide_all")]
public void HideAll()

Remarks

This is a loop over all 40, not a single register write. Worth doing once at startup; not worth doing every frame.

Load(SpriteAsset)

Loads a converted sprite sheet: its tiles, and on Game Boy Color its palettes.

[Native("gbs_sprite_load")]
public void Load(SpriteAsset sheet)

Parameters

sheet SpriteAsset

LoadTiles(byte, byte, byte[])

Copies sprite tile data into VRAM. 16 bytes per tile.

[Native("gbs_sprite_load_tiles")]
public void LoadTiles(byte firstTile, byte count, byte[] data)

Parameters

firstTile byte
count byte
data byte[]

Move(byte, byte, byte)

Sets a sprite's position in one call.

[Native("gbs_sprite_move")]
public void Move(byte id, byte x, byte y)

Parameters

id byte
x byte
y byte

Remarks

Cheaper than assigning X and Y separately, which costs two OAM writes.

Scroll(byte, sbyte, sbyte)

Moves a sprite by a relative amount.

[Native("scroll_sprite")]
public void Scroll(byte id, sbyte dx, sbyte dy)

Parameters

id byte
dx sbyte
dy sbyte

SetFlags(byte, SpriteFlags)

Sets all of a sprite's attribute bits at once.

[Native("set_sprite_prop")]
public void SetFlags(byte id, SpriteFlags flags)

Parameters

id byte
flags SpriteFlags

SetTile(byte, byte)

Sets which tile a sprite draws.

[Native("gbs_sprite_set_tile")]
public void SetTile(byte id, byte tile)

Parameters

id byte
tile byte