feat: implement horizontal 8bpp sprites
This commit is contained in:
parent
77e2ef6103
commit
f689f63eda
|
@ -628,6 +628,254 @@ pub const horizontal = struct {
|
||||||
|
|
||||||
/// 2D-Mapped Horizontal Sprites
|
/// 2D-Mapped Horizontal Sprites
|
||||||
pub const d2 = struct {
|
pub const d2 = struct {
|
||||||
|
|
||||||
|
/// 2D-Mapped Horizontal Sprites using 8-bit Colour
|
||||||
|
pub const bpp8 = struct {
|
||||||
|
const palette: [8]u32 = [_]u32{
|
||||||
|
0x3DEF0000, 0x00006318, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
||||||
|
};
|
||||||
|
|
||||||
|
fn loadPalette() void {
|
||||||
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &palette, palette.len * @sizeOf(u32));
|
||||||
|
}
|
||||||
|
|
||||||
|
pub const Sprite16x8 = struct {
|
||||||
|
const Self = @This();
|
||||||
|
|
||||||
|
const tile = [32]u32{
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn getAttribute() Attribute {
|
||||||
|
return Attribute{
|
||||||
|
.paletteMode = .Color256,
|
||||||
|
.doubleSizeOrVisible = false,
|
||||||
|
.palette = 0,
|
||||||
|
.tileIndex = 0,
|
||||||
|
.shape = .Horizontal,
|
||||||
|
.size = 0,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load() void {
|
||||||
|
// In Memory, Tile Map is laid out like: 1 2
|
||||||
|
|
||||||
|
const tile_width = 8 * 8;
|
||||||
|
const tiles_per_row = 2;
|
||||||
|
|
||||||
|
const sprite_width = tile_width * tiles_per_row;
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], sprite_width);
|
||||||
|
|
||||||
|
loadPalette();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const Sprite32x8 = struct {
|
||||||
|
const Self = @This();
|
||||||
|
|
||||||
|
const tile = [64]u32{
|
||||||
|
0x02020202, 0x01010101, 0x01010101, 0x02020202, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x02020202, 0x02020202, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x02020202, 0x01010101, 0x01010101, 0x02020202,
|
||||||
|
0x01010101, 0x01010101, 0x02020202, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x02020202, 0x01010101, 0x01010101,
|
||||||
|
0x02020202, 0x01010101, 0x01010101, 0x02020202, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x02020202, 0x02020202, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x02020202, 0x01010101, 0x01010101, 0x02020202,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn getAttribute() Attribute {
|
||||||
|
return Attribute{
|
||||||
|
.paletteMode = .Color256,
|
||||||
|
.doubleSizeOrVisible = false,
|
||||||
|
.palette = 0,
|
||||||
|
.tileIndex = 0,
|
||||||
|
.shape = .Horizontal,
|
||||||
|
.size = 1,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load() void {
|
||||||
|
// In Memory, Tile Map is laid out like: 1 2 3 4
|
||||||
|
|
||||||
|
const tile_width = 8 * 8;
|
||||||
|
const tiles_per_row = 4;
|
||||||
|
|
||||||
|
const sprite_width = tile_width * tiles_per_row;
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], sprite_width);
|
||||||
|
|
||||||
|
loadPalette();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const Sprite32x16 = struct {
|
||||||
|
const Self = @This();
|
||||||
|
|
||||||
|
const tile = [128]u32{
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn getAttribute() Attribute {
|
||||||
|
return Attribute{
|
||||||
|
.paletteMode = .Color256,
|
||||||
|
.doubleSizeOrVisible = false,
|
||||||
|
.palette = 0,
|
||||||
|
.tileIndex = 0,
|
||||||
|
.shape = .Horizontal,
|
||||||
|
.size = 2,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load() void {
|
||||||
|
// In Memory, Tile Map is laid out like: 1 2 3 4
|
||||||
|
// 5 6 7 8
|
||||||
|
|
||||||
|
const tile_width = 8 * 8;
|
||||||
|
const tiles_per_row = 4;
|
||||||
|
|
||||||
|
const sprite_width = tile_width * tiles_per_row;
|
||||||
|
const offset = 0x8 / tiles_per_row;
|
||||||
|
|
||||||
|
const tile_idx = sprite_width / @sizeOf(u32);
|
||||||
|
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], sprite_width);
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * (offset * 1), &Self.tile[tile_idx], sprite_width);
|
||||||
|
|
||||||
|
loadPalette();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
pub const Sprite64x32 = struct {
|
||||||
|
const Self = @This();
|
||||||
|
|
||||||
|
const tile = [512]u32{
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x02020101, 0x01010101, 0x01010202, 0x02020101, 0x01010101, 0x01010202, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||||
|
0x01010202, 0x01010101, 0x02020101, 0x01010101, 0x01010101, 0x01010202, 0x01010101, 0x02020101,
|
||||||
|
};
|
||||||
|
|
||||||
|
pub fn getAttribute() Attribute {
|
||||||
|
return Attribute{
|
||||||
|
.paletteMode = .Color256,
|
||||||
|
.doubleSizeOrVisible = false,
|
||||||
|
.palette = 0,
|
||||||
|
.tileIndex = 0,
|
||||||
|
.shape = .Horizontal,
|
||||||
|
.size = 3,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn load() void {
|
||||||
|
// In Memory, Tile Map is laid out like: 1 2 3 4 5 6 7 8
|
||||||
|
// 9 10 11 12 13 14 15 16
|
||||||
|
// 17 18 19 20 21 22 23 24
|
||||||
|
// 25 26 27 28 29 30 31 32
|
||||||
|
|
||||||
|
const tile_width = 8 * 8;
|
||||||
|
const tiles_per_row = 8;
|
||||||
|
|
||||||
|
const sprite_width = tile_width * tiles_per_row;
|
||||||
|
const offset = 0x8 / tiles_per_row;
|
||||||
|
|
||||||
|
const tile_idx = sprite_width / @sizeOf(u32);
|
||||||
|
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], sprite_width);
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * (offset * 1), &Self.tile[tile_idx * 1], sprite_width);
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * (offset * 2), &Self.tile[tile_idx * 2], sprite_width);
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * (offset * 3), &Self.tile[tile_idx * 3], sprite_width);
|
||||||
|
|
||||||
|
loadPalette();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
/// 2D-Mapped Horizontal Sprites using 4-bit Colour
|
/// 2D-Mapped Horizontal Sprites using 4-bit Colour
|
||||||
pub const bpp4 = struct {
|
pub const bpp4 = struct {
|
||||||
const palette: [8]u32 = [_]u32{
|
const palette: [8]u32 = [_]u32{
|
||||||
|
|
Loading…
Reference in New Issue