chore: cleanup 2d-mapping code for 4bpp vertical sprites
This commit is contained in:
parent
1354c3d26d
commit
06188d3d2b
|
@ -1390,10 +1390,16 @@ pub const vertical = struct {
|
||||||
// In Memory, Tile Map is laid out like: 1
|
// In Memory, Tile Map is laid out like: 1
|
||||||
// 2
|
// 2
|
||||||
|
|
||||||
const sprite_len = 8;
|
const tile_width = 8 * 4;
|
||||||
|
const tiles_per_row = 1;
|
||||||
|
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], sprite_len * @sizeOf(u32));
|
const sprite_width = tile_width * tiles_per_row;
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM + (sprite_len * 0x40), &Self.tile[sprite_len], sprite_len * @sizeOf(u32));
|
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 * 1], sprite_width);
|
||||||
|
|
||||||
loadPalette();
|
loadPalette();
|
||||||
}
|
}
|
||||||
|
@ -1426,14 +1432,18 @@ pub const vertical = struct {
|
||||||
// 3
|
// 3
|
||||||
// 4
|
// 4
|
||||||
|
|
||||||
const px_width = 8;
|
const tile_width = 8 * 4;
|
||||||
const offset = 0x40;
|
const tiles_per_row = 1;
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
@ -1470,14 +1480,18 @@ pub const vertical = struct {
|
||||||
// 5 6
|
// 5 6
|
||||||
// 7 8
|
// 7 8
|
||||||
|
|
||||||
const px_width = 8 * 2;
|
const tile_width = 8 * 4;
|
||||||
const offset = 0x40 / 2;
|
const tiles_per_row = 2;
|
||||||
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();
|
||||||
}
|
}
|
||||||
|
@ -1545,18 +1559,22 @@ pub const vertical = struct {
|
||||||
// 25 26 27 28
|
// 25 26 27 28
|
||||||
// 29 30 31 32
|
// 29 30 31 32
|
||||||
|
|
||||||
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;
|
||||||
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 + (px_width * (offset * 4)), &Self.tile[px_width * 4], len);
|
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 5)), &Self.tile[px_width * 5], len);
|
GBA.memcpy32(GBA.SPRITE_VRAM, &Self.tile[0], sprite_width);
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 6)), &Self.tile[px_width * 6], len);
|
GBA.memcpy32(GBA.SPRITE_VRAM + sprite_width * (offset * 1), &Self.tile[tile_idx * 1], sprite_width);
|
||||||
GBA.memcpy32(GBA.SPRITE_VRAM + (px_width * (offset * 7)), &Self.tile[px_width * 7], len);
|
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();
|
loadPalette();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue