fix: properly display static background scenes (#2669)

This commit is contained in:
briaguya 2023-04-04 03:12:09 -04:00 committed by GitHub
parent ff1d8a9e9d
commit 44906598e4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 2 deletions

View File

@ -1056,6 +1056,11 @@ extern "C" char* ResourceMgr_LoadFileFromDisk(const char* filePath) {
return data;
}
extern "C" uint8_t ResourceMgr_ResourceIsBackground(char* texPath) {
auto res = GetResourceByNameHandlingMQ(texPath);
return res->InitData->Type == Ship::ResourceType::SOH_Background;
}
extern "C" char* ResourceMgr_LoadJPEG(char* data, int dataSize)
{
static char* finalBuffer = 0;

View File

@ -63,6 +63,7 @@ char** ResourceMgr_ListFiles(const char* searchMask, int* resultSize);
char* GetResourceDataByNameHandlingMQ(const char* path);
void ResourceMgr_LoadFile(const char* resName);
char* ResourceMgr_LoadFileFromDisk(const char* filePath);
uint8_t ResourceMgr_ResourceIsBackground(char* texPath);
char* ResourceMgr_LoadJPEG(char* data, int dataSize);
uint16_t ResourceMgr_LoadTexWidthByName(char* texPath);
uint16_t ResourceMgr_LoadTexHeightByName(char* texPath);

View File

@ -220,7 +220,7 @@ void func_80095D04(PlayState* play, Room* room, u32 flags) {
#define JPEG_MARKER 0xFFD8FFE0
s32 func_80096238(void* data) {
s32 swapAndConvertJPEG(void* data) {
OSTime time;
if (BE32SWAP(*(u32*)data) == JPEG_MARKER)
@ -265,7 +265,7 @@ void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 h
s32 temp;
displayListHead = *displayList;
func_80096238(SEGMENTED_TO_VIRTUAL(source));
swapAndConvertJPEG(SEGMENTED_TO_VIRTUAL(source));
bg = (uObjBg*)(displayListHead + 1);
gSPBranchList(displayListHead, (u8*)bg + sizeof(uObjBg));
@ -282,6 +282,12 @@ void func_8009638C(Gfx** displayList, void* source, void* tlut, u16 width, u16 h
bg->b.imagePal = 0;
bg->b.imageFlip = 0;
if (ResourceMgr_ResourceIsBackground((char*) source)) {
char* blob = (char*) GetResourceDataByName((char*) source, true);
swapAndConvertJPEG(blob);
bg->b.imagePtr = (uintptr_t) blob;
}
displayListHead = (void*)(bg + 1);
if (fmt == G_IM_FMT_CI) {
gDPLoadTLUT(displayListHead++, tlutCount, 256, tlut);