2021-04-13 09:47:52 +02:00
|
|
|
#include "common.h"
|
2021-12-30 06:14:55 +01:00
|
|
|
#include "sprite.h"
|
2022-07-08 14:57:08 +02:00
|
|
|
#include "nu/nusys.h"
|
|
|
|
|
|
|
|
// TODO generate this somehow, or prevent it from shifting. must be resolved at compile time
|
|
|
|
#define SPRITE_ROM_START 0x1943000 + 0x10
|
2021-12-30 06:14:55 +01:00
|
|
|
|
2022-08-10 15:36:38 +02:00
|
|
|
extern s32 PlayerRasterSetsLoaded;
|
|
|
|
extern s32 PlayerRasterBufferSetOffsets[13];
|
|
|
|
extern s32 PlayerRasterHeader;
|
2022-07-08 14:57:08 +02:00
|
|
|
extern s32 D_802E0C20[];
|
2022-08-10 15:36:38 +02:00
|
|
|
extern s32 PlayerRasterCacheSize;
|
|
|
|
extern s32 PlayerRasterMaxSize;
|
|
|
|
extern s32 SpriteDataHeader[];
|
|
|
|
extern PlayerSpriteCacheEntry PlayerRasterCache[18];
|
2021-12-13 10:27:28 +01:00
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
INCLUDE_ASM(s32, "101b90_len_8f0", spr_swizzle_anim_offsets);
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
INCLUDE_ASM(s32, "101b90_len_8f0", spr_load_sprite);
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2022-07-08 14:57:08 +02:00
|
|
|
void spr_init_player_raster_cache(s32 cacheSize, s32 maxRasterSize) {
|
2022-08-10 15:36:38 +02:00
|
|
|
void* raster;
|
2022-07-08 14:57:08 +02:00
|
|
|
s32 i;
|
|
|
|
|
2022-08-10 15:36:38 +02:00
|
|
|
nuPiReadRom(SPRITE_ROM_START, &SpriteDataHeader, 0xC);
|
|
|
|
PlayerRasterCacheSize = cacheSize;
|
|
|
|
PlayerRasterMaxSize = maxRasterSize;
|
|
|
|
SpriteDataHeader[0] += SPRITE_ROM_START;
|
|
|
|
SpriteDataHeader[1] += SPRITE_ROM_START;
|
|
|
|
SpriteDataHeader[2] += SPRITE_ROM_START;
|
|
|
|
raster = _heap_malloc(&gSpriteHeapPtr, maxRasterSize * cacheSize);
|
2022-07-08 14:57:08 +02:00
|
|
|
|
2022-08-10 15:36:38 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(PlayerRasterCache); i++) {
|
|
|
|
PlayerRasterCache[i].raster = raster;
|
|
|
|
raster += PlayerRasterMaxSize;
|
|
|
|
PlayerRasterCache[i].lazyDeleteTime = 0;
|
|
|
|
PlayerRasterCache[i].rasterIndex = 0;
|
|
|
|
PlayerRasterCache[i].spriteIndex = 0xFF;
|
2022-07-08 14:57:08 +02:00
|
|
|
}
|
|
|
|
|
2022-08-10 15:36:38 +02:00
|
|
|
for (i = 0; i < ARRAY_COUNT(PlayerRasterBufferSetOffsets); i++) {
|
|
|
|
PlayerRasterBufferSetOffsets[i] = 0;
|
2022-07-08 14:57:08 +02:00
|
|
|
}
|
2022-08-10 15:36:38 +02:00
|
|
|
PlayerRasterSetsLoaded = 0;
|
|
|
|
nuPiReadRom(SpriteDataHeader[0], &PlayerRasterHeader, 0xC);
|
|
|
|
nuPiReadRom(SpriteDataHeader[0] + PlayerRasterHeader, D_802E0C20, 0x38);
|
2022-07-08 14:57:08 +02:00
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
INCLUDE_ASM(s32, "101b90_len_8f0", spr_get_player_raster);
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2021-12-13 10:27:28 +01:00
|
|
|
void spr_update_player_raster_cache(void) {
|
|
|
|
s32 i;
|
|
|
|
|
|
|
|
func_8013A4D0();
|
|
|
|
|
2022-08-10 15:36:38 +02:00
|
|
|
for (i = 0; i < PlayerRasterCacheSize; i++) {
|
|
|
|
if (PlayerRasterCache[i].lazyDeleteTime != 0) {
|
|
|
|
PlayerRasterCache[i].lazyDeleteTime--;
|
2021-12-13 10:27:28 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
INCLUDE_ASM(s32, "101b90_len_8f0", spr_load_npc_extra_anims);
|
2021-04-13 09:47:52 +02:00
|
|
|
|
2021-06-30 04:27:12 +02:00
|
|
|
INCLUDE_ASM(s32, "101b90_len_8f0", spr_allocate_components);
|