chore: cleanup 2d-mapping code for 4bpp horizontal sprites
This commit is contained in:
parent
f689f63eda
commit
1bf10f6d76
|
@ -908,10 +908,11 @@ pub const horizontal = struct {
|
||||||
pub fn load() void {
|
pub fn load() void {
|
||||||
// In Memory, Tile Map is laid out like: 1 2
|
// In Memory, Tile Map is laid out like: 1 2
|
||||||
|
|
||||||
const px_width = 8 * 2;
|
const tile_width = 8 * 4;
|
||||||
const len = px_width * @sizeOf(u32);
|
const tiles_per_row = 2;
|
||||||
|
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], len);
|
const sprite_width = tile_width * tiles_per_row;
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], sprite_width);
|
||||||
|
|
||||||
loadPalette();
|
loadPalette();
|
||||||
}
|
}
|
||||||
|
@ -941,10 +942,11 @@ pub const horizontal = struct {
|
||||||
pub fn load() void {
|
pub fn load() void {
|
||||||
// In Memory, Tile Map is laid out like: 1 2 3 4
|
// In Memory, Tile Map is laid out like: 1 2 3 4
|
||||||
|
|
||||||
const px_width = 8 * 4;
|
const tile_width = 8 * 4;
|
||||||
const len = px_width * @sizeOf(u32);
|
const tiles_per_row = 4;
|
||||||
|
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], len);
|
const sprite_width = tile_width * tiles_per_row;
|
||||||
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], sprite_width);
|
||||||
|
|
||||||
loadPalette();
|
loadPalette();
|
||||||
}
|
}
|
||||||
|
@ -979,12 +981,16 @@ pub const horizontal = struct {
|
||||||
// In Memory, Tile Map is laid out like: 1 2 3 4
|
// In Memory, Tile Map is laid out like: 1 2 3 4
|
||||||
// 5 6 7 8
|
// 5 6 7 8
|
||||||
|
|
||||||
const px_width = 8 * 4;
|
const tile_width = 8 * 4;
|
||||||
const offset = 0x40 / 4;
|
const tiles_per_row = 4;
|
||||||
const len = px_width * @sizeOf(u32);
|
|
||||||
|
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], len);
|
const sprite_width = tile_width * tiles_per_row;
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * offset), &Self.tile[px_width], len);
|
const offset = 0x10 / 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();
|
loadPalette();
|
||||||
}
|
}
|
||||||
|
@ -1048,14 +1054,18 @@ pub const horizontal = struct {
|
||||||
// 17 18 19 20 21 22 23 24
|
// 17 18 19 20 21 22 23 24
|
||||||
// 25 26 27 28 29 30 31 32
|
// 25 26 27 28 29 30 31 32
|
||||||
|
|
||||||
const px_width = 8 * 8;
|
const tile_width = 8 * 4;
|
||||||
const offset = 0x40 / 8;
|
const tiles_per_row = 8;
|
||||||
const len = px_width * @sizeOf(u32);
|
|
||||||
|
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], len);
|
const sprite_width = tile_width * tiles_per_row;
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * offset), &Self.tile[px_width], len);
|
const offset = 0x10 / tiles_per_row;
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 2)), &Self.tile[px_width * 2], len);
|
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 3)), &Self.tile[px_width * 3], len);
|
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();
|
loadPalette();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue