diff --git a/src/sprite2d/main.zig b/src/sprite2d/main.zig index b453bca..d80bccb 100644 --- a/src/sprite2d/main.zig +++ b/src/sprite2d/main.zig @@ -65,8 +65,8 @@ pub fn main() noreturn { for (oam_slice) |*attr| attr.* |= 0x0200; // Grab Default Sprite (Square 64x64 4bpp) - var sprite = sprite_attrs[3]; - sprite_load_fns[3](); + var sprite = sprite_attrs[0]; + sprite_load_fns[0](); var x: i32 = 96; var y: i32 = 32; diff --git a/src/sprite2d/sprites.zig b/src/sprite2d/sprites.zig index 885d9c4..af0a1bc 100644 --- a/src/sprite2d/sprites.zig +++ b/src/sprite2d/sprites.zig @@ -255,7 +255,355 @@ pub const square = struct { }; /// 2D-Mapped Square Sprites using 8-bit Colour - const bpp8 = struct {}; + pub const bpp8 = struct { + pub const palette: [8]u32 = [_]u32{ + 0x3DEF0000, 0x00005EF7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, + }; + + fn loadPalette() void { + GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &palette, palette.len * @sizeOf(u32)); + } + + pub const Sprite8x8 = struct { + const Self = @This(); + + const tile = [16]u32{ + 0x01010102, 0x02010101, 0x01010201, 0x01020101, 0x01020101, 0x01010201, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01020101, 0x01010201, 0x01010201, 0x01020101, 0x01010102, 0x02010101, + }; + + pub fn getAttribute() Attribute { + return Attribute{ + .paletteMode = .Color256, + .doubleSizeOrVisible = false, + .palette = 0, + .tileIndex = 0, + .shape = .Square, + .size = 0, + }; + } + + pub fn load() void { + // 8x8 Sprites don't differ in any meaningful way between 1D and 2D mapping + + const tile_width = 8 * 8; + const tiles_per_row = 1; + + const sprite_width = tile_width * tiles_per_row; + GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], sprite_width); + + loadPalette(); + } + }; + + pub const Sprite16x16 = struct { + const Self = @This(); + + const tile = [64]u32{ + 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, + 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, + 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, + }; + + pub fn getAttribute() Attribute { + return Attribute{ + .paletteMode = .Color256, + .doubleSizeOrVisible = false, + .palette = 0, + .tileIndex = 0, + .shape = .Square, + .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 = 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], sprite_width); + + loadPalette(); + } + }; + + pub const Sprite32x32 = struct { + const Self = @This(); + + const tile = [256]u32{ + 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 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, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, + + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, + 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 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, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, + 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + + 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 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, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, + }; + + pub fn getAttribute() Attribute { + return Attribute{ + .paletteMode = .Color256, + .doubleSizeOrVisible = false, + .palette = 0, + .tileIndex = 0, + .shape = .Square, + .size = 2, + }; + } + + 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 + + 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); + 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 Sprite64x64 = struct { + const Self = @This(); + + const tile = [1024]u32{ + 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 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, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 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, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, + + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 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, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 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, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 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, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 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, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 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, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 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, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, + + 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 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, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 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, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, 0x01010101, + + 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 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, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 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, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 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, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 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, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 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, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 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, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + + 0x01010101, 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 0x01010101, 0x01010102, + 0x02010101, 0x01010101, 0x01020101, 0x01010101, 0x01010201, 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, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, 0x01010101, + 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, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, 0x01010101, + 0x01010101, 0x01010102, 0x01010101, 0x01010201, 0x01010101, 0x01020101, 0x01010101, 0x02010101, + }; + + pub fn getAttribute() Attribute { + return Attribute{ + .paletteMode = .Color256, + .doubleSizeOrVisible = false, + .palette = 0, + .tileIndex = 0, + .shape = .Square, + .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 + // 33 34 35 36 37 38 39 40 + // 41 42 43 44 45 46 47 48 + // 49 50 51 52 53 54 55 56 + // 57 58 59 60 61 62 63 64 + + const tile_width = 8 * 8; + const tiles_per_row = 8; + + const sprite_width = tile_width * 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 * 1, &Self.tile[tile_idx * 1], sprite_width); + GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * 2, &Self.tile[tile_idx * 2], sprite_width); + GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * 3, &Self.tile[tile_idx * 3], sprite_width); + GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * 4, &Self.tile[tile_idx * 4], sprite_width); + GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * 5, &Self.tile[tile_idx * 5], sprite_width); + GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * 6, &Self.tile[tile_idx * 6], sprite_width); + GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * 7, &Self.tile[tile_idx * 7], sprite_width); + + loadPalette(); + } + }; + }; }; };