feat: implement vertical 8bpp sprites
This commit is contained in:
parent
1bf10f6d76
commit
1354c3d26d
|
@ -1081,6 +1081,282 @@ pub const vertical = struct {
|
|||
|
||||
/// 2D-Mapped Vertical Sprites
|
||||
pub const d2 = struct {
|
||||
|
||||
/// 2D-Mapped Vertical 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 Sprite8x16 = struct {
|
||||
const Self = @This();
|
||||
|
||||
const tile = [32]u32{
|
||||
0x01010102, 0x02010101, 0x01010102, 0x02010101, 0x01010201, 0x01020101, 0x01010201, 0x01020101,
|
||||
0x01020101, 0x01010201, 0x01020101, 0x01010201, 0x02010101, 0x01010101, 0x02010101, 0x01010101,
|
||||
0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01020101, 0x01010201, 0x01020101, 0x01010201,
|
||||
0x01010201, 0x01020101, 0x01010201, 0x01020101, 0x01010102, 0x02010101, 0x01010102, 0x02010101,
|
||||
};
|
||||
|
||||
pub fn getAttribute() Attribute {
|
||||
return Attribute{
|
||||
.paletteMode = .Color256,
|
||||
.doubleSizeOrVisible = false,
|
||||
.palette = 0,
|
||||
.tileIndex = 0,
|
||||
.shape = .Vertical,
|
||||
.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 = 1;
|
||||
|
||||
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);
|
||||
|
||||
loadPalette();
|
||||
}
|
||||
};
|
||||
|
||||
pub const Sprite8x32 = struct {
|
||||
const Self = @This();
|
||||
|
||||
const tile = [64]u32{
|
||||
0x01010102, 0x02010101, 0x01010102, 0x02010101, 0x01010102, 0x02010101, 0x01010102, 0x02010101,
|
||||
0x01010201, 0x01020101, 0x01010201, 0x01020101, 0x01010201, 0x01020101, 0x01010201, 0x01020101,
|
||||
0x01020101, 0x01010201, 0x01020101, 0x01010201, 0x01020101, 0x01010201, 0x01020101, 0x01010201,
|
||||
0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x02010101, 0x01010101,
|
||||
0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010102,
|
||||
0x01020101, 0x01010201, 0x01020101, 0x01010201, 0x01020101, 0x01010201, 0x01020101, 0x01010201,
|
||||
0x01010201, 0x01020101, 0x01010201, 0x01020101, 0x01010201, 0x01020101, 0x01010201, 0x01020101,
|
||||
0x01010102, 0x02010101, 0x01010102, 0x02010101, 0x01010102, 0x02010101, 0x01010102, 0x02010101,
|
||||
};
|
||||
|
||||
pub fn getAttribute() Attribute {
|
||||
return Attribute{
|
||||
.paletteMode = .Color256,
|
||||
.doubleSizeOrVisible = false,
|
||||
.palette = 0,
|
||||
.tileIndex = 0,
|
||||
.shape = .Vertical,
|
||||
.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 = 1;
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
pub const Sprite16x32 = struct {
|
||||
const Self = @This();
|
||||
|
||||
const tile = [128]u32{
|
||||
0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101,
|
||||
0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101, 0x01010101,
|
||||
0x01010101, 0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101,
|
||||
0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102,
|
||||
0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201,
|
||||
0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101,
|
||||
0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101,
|
||||
0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||
|
||||
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101,
|
||||
0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102,
|
||||
0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101,
|
||||
0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101, 0x01010101,
|
||||
0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101,
|
||||
0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01010101,
|
||||
0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201,
|
||||
0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101,
|
||||
};
|
||||
|
||||
pub fn getAttribute() Attribute {
|
||||
return Attribute{
|
||||
.paletteMode = .Color256,
|
||||
.doubleSizeOrVisible = false,
|
||||
.palette = 0,
|
||||
.tileIndex = 0,
|
||||
.shape = .Vertical,
|
||||
.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 = 2;
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
pub const Sprite32x64 = struct {
|
||||
const Self = @This();
|
||||
|
||||
const tile = [512]u32{
|
||||
0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101,
|
||||
0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101, 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, 0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101,
|
||||
0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102,
|
||||
|
||||
0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201,
|
||||
0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101,
|
||||
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,
|
||||
0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101,
|
||||
0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01010101,
|
||||
|
||||
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||
0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101,
|
||||
0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101, 0x01010101,
|
||||
0x01010101, 0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101,
|
||||
0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102,
|
||||
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, 0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201,
|
||||
0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101,
|
||||
0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101,
|
||||
0x01010201, 0x01010101, 0x01010201, 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, 0x01020101, 0x01010101, 0x01020101,
|
||||
0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102,
|
||||
0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101,
|
||||
0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101, 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,
|
||||
0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101,
|
||||
0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01010101,
|
||||
0x01010101, 0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201,
|
||||
0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101,
|
||||
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||
0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101,
|
||||
|
||||
0x01010101, 0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101,
|
||||
0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102,
|
||||
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,
|
||||
0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201, 0x01010101,
|
||||
0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101, 0x01010101,
|
||||
|
||||
0x02010101, 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101,
|
||||
0x01010201, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, 0x01010102, 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, 0x01010102, 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01010201,
|
||||
0x01010101, 0x01020101, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, 0x02010101,
|
||||
};
|
||||
|
||||
pub fn getAttribute() Attribute {
|
||||
return Attribute{
|
||||
.paletteMode = .Color256,
|
||||
.doubleSizeOrVisible = false,
|
||||
.palette = 0,
|
||||
.tileIndex = 0,
|
||||
.shape = .Vertical,
|
||||
.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 = 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 * 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);
|
||||
GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * (offset * 4), &Self.tile[tile_idx * 4], sprite_width);
|
||||
GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * (offset * 5), &Self.tile[tile_idx * 5], sprite_width);
|
||||
GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * (offset * 6), &Self.tile[tile_idx * 6], sprite_width);
|
||||
GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * (offset * 7), &Self.tile[tile_idx * 7], sprite_width);
|
||||
|
||||
loadPalette();
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
/// 2D-Mapped Vertical Sprites using 4-bit Colour
|
||||
pub const bpp4 = struct {
|
||||
pub const palette: [8]u32 = [_]u32{
|
||||
|
|
Loading…
Reference in New Issue