749 lines
35 KiB
Zig
749 lines
35 KiB
Zig
const std = @import("std");
|
|
|
|
const GBA = @import("gba").GBA;
|
|
const Mode3 = @import("gba").Mode3;
|
|
const LCD = @import("gba").LCD;
|
|
const OAM = @import("gba").OAM;
|
|
const Input = @import("gba").Input;
|
|
|
|
const sprite_mod = @import("sprites.zig");
|
|
|
|
const SquareSpriteTuple = std.meta.Tuple(&[_]type{ Sprite8x8, Sprite16x16, Sprite32x32, Sprite64x64 });
|
|
const HorizSpriteTuple = std.meta.Tuple(&[_]type{ Sprite16x8, Sprite32x8, Sprite32x16, Sprite64x32 });
|
|
const VertSpriteTuple = std.meta.Tuple(&[_]type{ Sprite8x16, Sprite8x32, Sprite16x32, Sprite32x64 });
|
|
const SpriteTupleTuple = std.meta.Tuple(&[_]type{ SquareSpriteTuple, HorizSpriteTuple, VertSpriteTuple });
|
|
const sprites = initSpriteTupleTuple();
|
|
|
|
// TODO: ZigGBA should support spaces, slashes, underscores, etc. in ROM Title
|
|
export var gameHeader linksection(".gbaheader") = GBA.Header.setup("SPRITE", "PAOD", "00", 0);
|
|
|
|
const obj_mapping = .TwoDimension;
|
|
|
|
pub fn main() noreturn {
|
|
LCD.setupDisplayControl(.{
|
|
.mode = .Mode0,
|
|
.objectLayer = .Show, // Enable Sprites
|
|
.objVramCharacterMapping = obj_mapping, // 2D Sprite Mapping
|
|
});
|
|
|
|
// Coppy Sprite Tiles to VRAM and Palette to PALRAM
|
|
sprites[0][0].load();
|
|
|
|
// FIXME: There are issues with OAM.Attribute and the ZigGBA API
|
|
// investigate what these issues are (could it just be my understanding?)
|
|
const attr_ptr = @intToPtr([*]OAM.Attribute, 0x0700_0000);
|
|
|
|
// Attr0 is in the least significant u16
|
|
const oam_slice = @intToPtr([*]u32, 0x0700_0000)[0 .. 0x400 / @sizeOf(u32)];
|
|
|
|
// Set bit 9 on all sprites, therefore disabling them all
|
|
for (oam_slice) |*attr| attr.* |= 0x0200;
|
|
|
|
var sprite = OAM.Attribute{};
|
|
sprite.paletteMode = sprites[0][0].paletteMode();
|
|
sprite.palette = 0;
|
|
sprite.doubleSizeOrVisible = false;
|
|
sprite.tileIndex = 0;
|
|
sprite.setSize(sprites[0][0].size());
|
|
|
|
var x: i32 = 96;
|
|
var y: i32 = 32;
|
|
|
|
var size_idx: u2 = 0;
|
|
var shape_idx: u2 = 0;
|
|
|
|
while (true) {
|
|
LCD.naiveVSync();
|
|
Input.readInput();
|
|
|
|
const shoulder = @truncate(u2, @bitCast(u32, Input.getShoulderJustPressed()));
|
|
|
|
if (Input.isKeyJustPressed(Input.Keys.A)) shape_idx +%= 1;
|
|
if (Input.isKeyJustPressed(Input.Keys.B)) shape_idx -%= 1;
|
|
|
|
if (shoulder != 0 or Input.isKeyJustPressed(Input.Keys.A) or Input.isKeyJustPressed(Input.Keys.B)) {
|
|
size_idx +%= shoulder;
|
|
shape_idx %= 3;
|
|
|
|
switch (shape_idx) {
|
|
0 => switch (size_idx) {
|
|
0 => loadSprite(0, 0, &sprite),
|
|
1 => loadSprite(0, 1, &sprite),
|
|
2 => loadSprite(0, 2, &sprite),
|
|
3 => loadSprite(0, 3, &sprite),
|
|
},
|
|
1 => switch (size_idx) {
|
|
0 => loadSprite(1, 0, &sprite),
|
|
1 => loadSprite(1, 1, &sprite),
|
|
2 => loadSprite(1, 2, &sprite),
|
|
3 => loadSprite(1, 3, &sprite),
|
|
},
|
|
2 => switch (size_idx) {
|
|
0 => loadSprite(2, 0, &sprite),
|
|
1 => loadSprite(2, 1, &sprite),
|
|
2 => loadSprite(2, 2, &sprite),
|
|
3 => loadSprite(2, 3, &sprite),
|
|
},
|
|
else => {},
|
|
}
|
|
}
|
|
|
|
x += Input.getHorizontal() * 2;
|
|
y += Input.getVertical() * 2;
|
|
|
|
sprite.setPosition(x, y);
|
|
|
|
attr_ptr[0] = sprite;
|
|
}
|
|
}
|
|
|
|
const Sprite8x8 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00005EF7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [8]u32{
|
|
0x21111112, 0x12111121, 0x11211211, 0x11112111, 0x11121111, 0x11211211, 0x12111121, 0x21111112,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size8x8;
|
|
}
|
|
|
|
fn load(_: Self) void {
|
|
// 8x8 Sprites don't differ in any meaningful way between 1D and 2D mapping
|
|
|
|
const sprite_width = 8; // 8x8
|
|
const len = sprite_width * @sizeOf(u32);
|
|
|
|
// Copy Tile Mapping
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
|
|
// Copy Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite16x16 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00005EF7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [32]u32{
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111111,
|
|
0x11111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size16x16;
|
|
}
|
|
|
|
fn load(_: Self) void {
|
|
// In Memory, Tile Map is laid out like: 1 2
|
|
// 3 4
|
|
|
|
const half = Self.tiles.len / 2;
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], half * @sizeOf(u32)); // Top
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (half * 0x20), &Self.tiles[half], half * @sizeOf(u32)); // Bottom
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite32x32 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00005EF7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [128]u32{
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size32x32;
|
|
}
|
|
|
|
fn load(_: Self) 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 px_width = 8 * 4;
|
|
const offset = 0x40 / 4;
|
|
const len = px_width * @sizeOf(u32);
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * offset), &Self.tiles[px_width], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 2)), &Self.tiles[px_width * 2], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 3)), &Self.tiles[px_width * 3], len);
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite64x64 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00005EF7, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [512]u32{
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x21111111, 0x12111111, 0x11211111, 0x11121111, 0x11112111, 0x11111211, 0x11111121, 0x11111112,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111121, 0x11111211, 0x11112111, 0x11121111, 0x11211111, 0x12111111, 0x21111111,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size64x64;
|
|
}
|
|
|
|
fn load(_: Self) 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 px_width = 8 * 8;
|
|
const offset = 0x40 / 8;
|
|
const len = px_width * @sizeOf(u32);
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * offset), &Self.tiles[px_width], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 2)), &Self.tiles[px_width * 2], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 3)), &Self.tiles[px_width * 3], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 4)), &Self.tiles[px_width * 4], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 5)), &Self.tiles[px_width * 5], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 6)), &Self.tiles[px_width * 6], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 7)), &Self.tiles[px_width * 7], len);
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite16x8 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00006318, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [16]u32{
|
|
0x11111122, 0x11112211, 0x11221111, 0x22111111, 0x11111111, 0x11221111, 0x11112211, 0x11111122,
|
|
0x22111111, 0x11221111, 0x11112211, 0x11111111, 0x11111122, 0x11112211, 0x11221111, 0x22111111,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size16x8;
|
|
}
|
|
|
|
fn load(_: Self) void {
|
|
// In Memory, Tile Map is laid out like: 1 2
|
|
|
|
const px_width = 8 * 2;
|
|
const len = px_width * @sizeOf(u32);
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite32x8 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00006318, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [32]u32{
|
|
0x11112222, 0x22221111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x22221111, 0x11112222,
|
|
0x11111111, 0x11111111, 0x11112222, 0x22221111, 0x11111111, 0x11112222, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x22221111, 0x11111111, 0x11112222, 0x22221111, 0x11111111, 0x11111111,
|
|
0x22221111, 0x11112222, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11112222, 0x22221111,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size32x8;
|
|
}
|
|
|
|
fn load(_: Self) void {
|
|
// In Memory, Tile Map is laid out like: 1 2 3 4
|
|
|
|
const px_width = 8 * 4;
|
|
const len = px_width * @sizeOf(u32);
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite32x16 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00006318, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [64]u32{
|
|
0x11111122, 0x11112211, 0x11221111, 0x22111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111122, 0x11112211, 0x11221111, 0x22111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x22111111, 0x11221111, 0x11112211, 0x11111111,
|
|
0x22111111, 0x11221111, 0x11112211, 0x11111122, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x22111111, 0x11221111, 0x11112211, 0x11111122,
|
|
0x11111111, 0x11221111, 0x11112211, 0x11111122, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111122, 0x11112211, 0x11221111, 0x22111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111122, 0x11112211, 0x11221111, 0x22111111,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size32x32;
|
|
}
|
|
|
|
fn load(_: Self) void {
|
|
// In Memory, Tile Map is laid out like: 1 2 3 4
|
|
// 5 6 7 8
|
|
|
|
const px_width = 8 * 4;
|
|
const offset = 0x40 / 4;
|
|
const len = px_width * @sizeOf(u32);
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * offset), &Self.tiles[px_width], len);
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite64x32 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00006318, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [256]u32{
|
|
0x11111122, 0x11112211, 0x11221111, 0x22111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111122, 0x11112211, 0x11221111, 0x22111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x22111111, 0x11221111, 0x11112211, 0x11111122,
|
|
0x22111111, 0x11221111, 0x11112211, 0x11111122, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111122, 0x11112211, 0x11221111, 0x22111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111122, 0x11112211, 0x11221111, 0x22111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x22111111, 0x11221111, 0x11112211, 0x11111111,
|
|
0x22111111, 0x11221111, 0x11112211, 0x11111122, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x22111111, 0x11221111, 0x11112211, 0x11111122,
|
|
0x11111111, 0x11221111, 0x11112211, 0x11111122, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111122, 0x11112211, 0x11221111, 0x22111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111122, 0x11112211, 0x11221111, 0x22111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x22111111, 0x11221111, 0x11112211, 0x11111122,
|
|
0x22111111, 0x11221111, 0x11112211, 0x11111122, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111122, 0x11112211, 0x11221111, 0x22111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111122, 0x11112211, 0x11221111, 0x22111111,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size64x32;
|
|
}
|
|
|
|
fn load(_: Self) 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 px_width = 8 * 8;
|
|
const offset = 0x40 / 8;
|
|
const len = px_width * @sizeOf(u32);
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * offset), &Self.tiles[px_width], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 2)), &Self.tiles[px_width * 2], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 3)), &Self.tiles[px_width * 3], len);
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite8x16 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00006318, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [16]u32{
|
|
0x21111112, 0x21111112, 0x12111121, 0x12111121, 0x11211211, 0x11211211, 0x11112111, 0x11112111,
|
|
0x11121111, 0x11121111, 0x11211211, 0x11211211, 0x12111121, 0x12111121, 0x21111112, 0x21111112,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size8x16;
|
|
}
|
|
|
|
fn load(_: Self) void {
|
|
// In Memory, Tile Map is laid out like: 1
|
|
// 2
|
|
|
|
const sprite_len = 8;
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], sprite_len * @sizeOf(u32));
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (sprite_len * 0x40), &Self.tiles[sprite_len], sprite_len * @sizeOf(u32));
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite8x32 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00006318, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [32]u32{
|
|
0x21111112, 0x21111112, 0x21111112, 0x21111112, 0x12111121, 0x12111121, 0x12111121, 0x12111121,
|
|
0x11211211, 0x11211211, 0x11211211, 0x11211211, 0x11112111, 0x11112111, 0x11112111, 0x11112111,
|
|
0x11121111, 0x11121111, 0x11121111, 0x11121111, 0x11211211, 0x11211211, 0x11211211, 0x11211211,
|
|
0x12111121, 0x12111121, 0x12111121, 0x12111121, 0x21111112, 0x21111112, 0x21111112, 0x21111112,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size8x32;
|
|
}
|
|
|
|
fn load(_: Self) void {
|
|
// In Memory, Tile Map is laid out like: 1
|
|
// 2
|
|
// 3
|
|
// 4
|
|
|
|
const px_width = 8;
|
|
const offset = 0x40;
|
|
const len = px_width * @sizeOf(u32);
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * offset), &Self.tiles[px_width], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 2)), &Self.tiles[px_width * 2], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 3)), &Self.tiles[px_width * 3], len);
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite16x32 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00006318, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [64]u32{
|
|
0x11111112, 0x11111112, 0x11111121, 0x11111121, 0x11111211, 0x11111211, 0x11112111, 0x11112111,
|
|
0x21111111, 0x21111111, 0x12111111, 0x12111111, 0x11211111, 0x11211111, 0x11121111, 0x11121111,
|
|
0x11121111, 0x11121111, 0x11211111, 0x11211111, 0x12111111, 0x12111111, 0x21111111, 0x21111111,
|
|
0x11112111, 0x11112111, 0x11111211, 0x11111211, 0x11111121, 0x11111121, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x12111111, 0x12111111, 0x11211111, 0x11211111, 0x11121111, 0x11121111,
|
|
0x11111112, 0x11111112, 0x11111121, 0x11111121, 0x11111211, 0x11111211, 0x11112111, 0x11112111,
|
|
0x11112111, 0x11112111, 0x11111211, 0x11111211, 0x11111121, 0x11111121, 0x11111112, 0x11111112,
|
|
0x11121111, 0x11121111, 0x11211111, 0x11211111, 0x12111111, 0x12111111, 0x21111111, 0x21111111,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size16x32;
|
|
}
|
|
|
|
fn load(_: Self) void {
|
|
// In Memory, Tile Map is laid out like: 1 2
|
|
// 3 4
|
|
// 5 6
|
|
// 7 8
|
|
|
|
const px_width = 8 * 2;
|
|
const offset = 0x40 / 2;
|
|
const len = px_width * @sizeOf(u32);
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * offset), &Self.tiles[px_width], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 2)), &Self.tiles[px_width * 2], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 3)), &Self.tiles[px_width * 3], len);
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
const Sprite32x64 = struct {
|
|
const Self = @This();
|
|
|
|
const pal = [8]u32{
|
|
0x3DEF0000, 0x00006318, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
|
|
};
|
|
|
|
const tiles = [256]u32{
|
|
0x11111112, 0x11111112, 0x11111121, 0x11111121, 0x11111211, 0x11111211, 0x11112111, 0x11112111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x21111111, 0x21111111, 0x12111111, 0x12111111, 0x11211111, 0x11211111, 0x11121111, 0x11121111,
|
|
0x11121111, 0x11121111, 0x11211111, 0x11211111, 0x12111111, 0x12111111, 0x21111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11112111, 0x11112111, 0x11111211, 0x11111211, 0x11111121, 0x11111121, 0x11111112, 0x11111112,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111112, 0x11111121, 0x11111121, 0x11111211, 0x11111211, 0x11112111, 0x11112111,
|
|
0x21111111, 0x21111111, 0x12111111, 0x12111111, 0x11211111, 0x11211111, 0x11121111, 0x11121111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11121111, 0x11121111, 0x11211111, 0x11211111, 0x12111111, 0x12111111, 0x21111111, 0x21111111,
|
|
0x11112111, 0x11112111, 0x11111211, 0x11111211, 0x11111121, 0x11111121, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x12111111, 0x12111111, 0x11211111, 0x11211111, 0x11121111, 0x11121111,
|
|
0x11111112, 0x11111112, 0x11111121, 0x11111121, 0x11111211, 0x11111211, 0x11112111, 0x11112111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11112111, 0x11112111, 0x11111211, 0x11111211, 0x11111121, 0x11111121, 0x11111112, 0x11111112,
|
|
0x11121111, 0x11121111, 0x11211111, 0x11211111, 0x12111111, 0x12111111, 0x21111111, 0x21111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
|
|
0x21111111, 0x21111111, 0x12111111, 0x12111111, 0x11211111, 0x11211111, 0x11121111, 0x11121111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111112, 0x11111112, 0x11111121, 0x11111121, 0x11111211, 0x11111211, 0x11112111, 0x11112111,
|
|
0x11112111, 0x11112111, 0x11111211, 0x11111211, 0x11111121, 0x11111121, 0x11111112, 0x11111112,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111, 0x11111111,
|
|
0x11121111, 0x11121111, 0x11211111, 0x11211111, 0x12111111, 0x12111111, 0x21111111, 0x21111111,
|
|
};
|
|
|
|
fn paletteMode(_: Self) GBA.PaletteMode {
|
|
return .Color16;
|
|
}
|
|
|
|
fn size(_: Self) OAM.ObjectSize {
|
|
return .Size32x64;
|
|
}
|
|
|
|
fn load(_: Self) 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 px_width = 8 * 4;
|
|
const offset = 0x40 / 4;
|
|
const len = px_width * @sizeOf(u32);
|
|
|
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tiles[0], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * offset), &Self.tiles[px_width], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 2)), &Self.tiles[px_width * 2], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 3)), &Self.tiles[px_width * 3], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 4)), &Self.tiles[px_width * 4], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 5)), &Self.tiles[px_width * 5], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 6)), &Self.tiles[px_width * 6], len);
|
|
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 7)), &Self.tiles[px_width * 7], len);
|
|
|
|
// Palette
|
|
GBA.memcpy32(GBA.OBJ_PALETTE_RAM, &Self.pal, Self.pal.len * @sizeOf(u32));
|
|
}
|
|
};
|
|
|
|
fn initSpriteTupleTuple() SpriteTupleTuple {
|
|
return .{ initSquareSpriteTuple(), initHorizSpriteTuple(), initVertSpriteTuple() };
|
|
}
|
|
|
|
fn initSquareSpriteTuple() SquareSpriteTuple {
|
|
return .{ Sprite8x8{}, Sprite16x16{}, Sprite32x32{}, Sprite64x64{} };
|
|
}
|
|
|
|
fn initHorizSpriteTuple() HorizSpriteTuple {
|
|
return .{ Sprite16x8{}, Sprite32x8{}, Sprite32x16{}, Sprite64x32{} };
|
|
}
|
|
|
|
fn initVertSpriteTuple() VertSpriteTuple {
|
|
return .{ Sprite8x16{}, Sprite8x32{}, Sprite16x32{}, Sprite32x64{} };
|
|
}
|
|
|
|
fn loadSprite(comptime kind: usize, comptime i: usize, sprite: *OAM.Attribute) void {
|
|
GBA.memset32(GBA.SPRITE_VRAM, 0, 0x8000); // Clear Sprite VRAM
|
|
|
|
sprites[kind][i].load();
|
|
sprite.setSize(sprites[kind][i].size());
|
|
}
|