mirror of
https://github.com/pmret/papermario.git
synced 2024-11-09 12:32:38 +01:00
Decompiled some functions in world.c (#223)
This commit is contained in:
parent
f36df5fcf7
commit
1b2e728e4d
@ -2,8 +2,23 @@
|
||||
#include "ld_addrs.h"
|
||||
#include "map.h"
|
||||
|
||||
#define ASSET_TABLE_ROM_START 0x1E40000
|
||||
#define ASSET_TABLE_HEADER_SIZE 0x20
|
||||
#define ASSET_TABLE_FIRST_ENTRY (ASSET_TABLE_ROM_START + ASSET_TABLE_HEADER_SIZE)
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ char name[16];
|
||||
/* 0x10 */ u32 offset;
|
||||
/* 0x14 */ u32 compressedLength;
|
||||
/* 0x18 */ u32 decompressedLength;
|
||||
} AssetHeader; // size = 0x1C
|
||||
|
||||
// bss
|
||||
extern MapConfig D_800A41E8; // gMapHeader?
|
||||
extern s32 D_800A41E0; // gMapConfig?
|
||||
|
||||
void load_world_script_api(void) {
|
||||
dma_copy(&world_script_api_ROM_START, &world_script_api_ROM_END, &world_script_api_VRAM);
|
||||
dma_copy((s32)&world_script_api_ROM_START, (s32)&world_script_api_ROM_END, &world_script_api_VRAM);
|
||||
}
|
||||
|
||||
// TODO
|
||||
@ -24,15 +39,54 @@ static const s32 rodata_73DA0[] = {
|
||||
|
||||
INCLUDE_ASM(s32, "world/world", load_map_by_IDs);
|
||||
|
||||
INCLUDE_ASM(s32, "world/world", get_current_map_config);
|
||||
s32 get_current_map_config() {
|
||||
return D_800A41E0;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(MapConfig*, "world/world", get_current_map_header);
|
||||
MapConfig* get_current_map_header() {
|
||||
return &D_800A41E8;
|
||||
}
|
||||
|
||||
INCLUDE_ASM(s32, "world/world", get_map_IDs_by_name);
|
||||
|
||||
INCLUDE_ASM(void*, "world/world", load_asset_by_name, char* name, s32* decompressedSize);
|
||||
void* load_asset_by_name(char* assetName, s32* decompressedSize) {
|
||||
AssetHeader firstHeader;
|
||||
AssetHeader* assetTableBuffer;
|
||||
AssetHeader* curAsset;
|
||||
void* ret;
|
||||
|
||||
INCLUDE_ASM(s32, "world/world", get_asset_offset);
|
||||
dma_copy(ASSET_TABLE_FIRST_ENTRY, ASSET_TABLE_FIRST_ENTRY + sizeof(AssetHeader), &firstHeader);
|
||||
assetTableBuffer = heap_malloc(firstHeader.offset);
|
||||
curAsset = &assetTableBuffer[0];
|
||||
dma_copy(ASSET_TABLE_FIRST_ENTRY, ASSET_TABLE_FIRST_ENTRY + firstHeader.offset, assetTableBuffer);
|
||||
while (strcmp(curAsset->name, assetName) != 0) {
|
||||
curAsset++;
|
||||
}
|
||||
*decompressedSize = curAsset->decompressedLength;
|
||||
ret = general_heap_malloc(curAsset->compressedLength);
|
||||
dma_copy(ASSET_TABLE_FIRST_ENTRY + curAsset->offset, ASSET_TABLE_FIRST_ENTRY + curAsset->offset + curAsset->compressedLength, ret);
|
||||
heap_free(assetTableBuffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
s32 get_asset_offset(char* assetName, s32* compressedSize) {
|
||||
AssetHeader firstHeader;
|
||||
AssetHeader* assetTableBuffer;
|
||||
AssetHeader* curAsset;
|
||||
s32 ret;
|
||||
|
||||
dma_copy(ASSET_TABLE_FIRST_ENTRY, ASSET_TABLE_FIRST_ENTRY + sizeof(AssetHeader), &firstHeader);
|
||||
assetTableBuffer = heap_malloc(firstHeader.offset);
|
||||
curAsset = &assetTableBuffer[0];
|
||||
dma_copy(ASSET_TABLE_FIRST_ENTRY, ASSET_TABLE_FIRST_ENTRY + firstHeader.offset, assetTableBuffer);
|
||||
while (strcmp(curAsset->name, assetName) != 0) {
|
||||
curAsset++;
|
||||
}
|
||||
*compressedSize = curAsset->compressedLength;
|
||||
ret = ASSET_TABLE_FIRST_ENTRY + curAsset->offset;
|
||||
heap_free(assetTableBuffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define AREA(area, jp_name) { ARRAY_COUNT(area##_maps), area##_maps, "area_" #area, jp_name }
|
||||
|
||||
|
@ -1,58 +0,0 @@
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
|
||||
glabel get_asset_offset
|
||||
/* 361D0 8005ADD0 27BDFFB8 */ addiu $sp, $sp, -0x48
|
||||
/* 361D4 8005ADD4 AFB20038 */ sw $s2, 0x38($sp)
|
||||
/* 361D8 8005ADD8 0080902D */ daddu $s2, $a0, $zero
|
||||
/* 361DC 8005ADDC AFB3003C */ sw $s3, 0x3c($sp)
|
||||
/* 361E0 8005ADE0 00A0982D */ daddu $s3, $a1, $zero
|
||||
/* 361E4 8005ADE4 3C0401E4 */ lui $a0, 0x1e4
|
||||
/* 361E8 8005ADE8 34840020 */ ori $a0, $a0, 0x20
|
||||
/* 361EC 8005ADEC 3C0501E4 */ lui $a1, 0x1e4
|
||||
/* 361F0 8005ADF0 34A5003C */ ori $a1, $a1, 0x3c
|
||||
/* 361F4 8005ADF4 27A60010 */ addiu $a2, $sp, 0x10
|
||||
/* 361F8 8005ADF8 AFBF0040 */ sw $ra, 0x40($sp)
|
||||
/* 361FC 8005ADFC AFB10034 */ sw $s1, 0x34($sp)
|
||||
/* 36200 8005AE00 0C00A5CF */ jal dma_copy
|
||||
/* 36204 8005AE04 AFB00030 */ sw $s0, 0x30($sp)
|
||||
/* 36208 8005AE08 8FA40020 */ lw $a0, 0x20($sp)
|
||||
/* 3620C 8005AE0C 0C00AB39 */ jal heap_malloc
|
||||
/* 36210 8005AE10 00000000 */ nop
|
||||
/* 36214 8005AE14 0040882D */ daddu $s1, $v0, $zero
|
||||
/* 36218 8005AE18 0220802D */ daddu $s0, $s1, $zero
|
||||
/* 3621C 8005AE1C 3C0201E4 */ lui $v0, 0x1e4
|
||||
/* 36220 8005AE20 34420020 */ ori $v0, $v0, 0x20
|
||||
/* 36224 8005AE24 3C0401E4 */ lui $a0, 0x1e4
|
||||
/* 36228 8005AE28 34840020 */ ori $a0, $a0, 0x20
|
||||
/* 3622C 8005AE2C 8FA50020 */ lw $a1, 0x20($sp)
|
||||
/* 36230 8005AE30 0220302D */ daddu $a2, $s1, $zero
|
||||
/* 36234 8005AE34 0C00A5CF */ jal dma_copy
|
||||
/* 36238 8005AE38 00A22821 */ addu $a1, $a1, $v0
|
||||
.L8005AE3C:
|
||||
/* 3623C 8005AE3C 0200202D */ daddu $a0, $s0, $zero
|
||||
/* 36240 8005AE40 0C01BB5C */ jal strcmp
|
||||
/* 36244 8005AE44 0240282D */ daddu $a1, $s2, $zero
|
||||
/* 36248 8005AE48 10400003 */ beqz $v0, .L8005AE58
|
||||
/* 3624C 8005AE4C 3C0301E4 */ lui $v1, 0x1e4
|
||||
/* 36250 8005AE50 08016B8F */ j .L8005AE3C
|
||||
/* 36254 8005AE54 2610001C */ addiu $s0, $s0, 0x1c
|
||||
.L8005AE58:
|
||||
/* 36258 8005AE58 8E020014 */ lw $v0, 0x14($s0)
|
||||
/* 3625C 8005AE5C 34630020 */ ori $v1, $v1, 0x20
|
||||
/* 36260 8005AE60 AE620000 */ sw $v0, ($s3)
|
||||
/* 36264 8005AE64 8E100010 */ lw $s0, 0x10($s0)
|
||||
/* 36268 8005AE68 0220202D */ daddu $a0, $s1, $zero
|
||||
/* 3626C 8005AE6C 0C00AB4B */ jal heap_free
|
||||
/* 36270 8005AE70 02038021 */ addu $s0, $s0, $v1
|
||||
/* 36274 8005AE74 0200102D */ daddu $v0, $s0, $zero
|
||||
/* 36278 8005AE78 8FBF0040 */ lw $ra, 0x40($sp)
|
||||
/* 3627C 8005AE7C 8FB3003C */ lw $s3, 0x3c($sp)
|
||||
/* 36280 8005AE80 8FB20038 */ lw $s2, 0x38($sp)
|
||||
/* 36284 8005AE84 8FB10034 */ lw $s1, 0x34($sp)
|
||||
/* 36288 8005AE88 8FB00030 */ lw $s0, 0x30($sp)
|
||||
/* 3628C 8005AE8C 03E00008 */ jr $ra
|
||||
/* 36290 8005AE90 27BD0048 */ addiu $sp, $sp, 0x48
|
||||
/* 36294 8005AE94 00000000 */ nop
|
||||
/* 36298 8005AE98 00000000 */ nop
|
||||
/* 3629C 8005AE9C 00000000 */ nop
|
@ -1,8 +0,0 @@
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
|
||||
glabel get_current_map_config
|
||||
/* 35FD8 8005ABD8 3C02800A */ lui $v0, %hi(D_800A41E0)
|
||||
/* 35FDC 8005ABDC 8C4241E0 */ lw $v0, %lo(D_800A41E0)($v0)
|
||||
/* 35FE0 8005ABE0 03E00008 */ jr $ra
|
||||
/* 35FE4 8005ABE4 00000000 */ nop
|
@ -1,8 +0,0 @@
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
|
||||
glabel get_current_map_header
|
||||
/* 35FE8 8005ABE8 3C02800A */ lui $v0, %hi(D_800A41E8)
|
||||
/* 35FEC 8005ABEC 244241E8 */ addiu $v0, $v0, %lo(D_800A41E8)
|
||||
/* 35FF0 8005ABF0 03E00008 */ jr $ra
|
||||
/* 35FF4 8005ABF4 00000000 */ nop
|
@ -1,64 +0,0 @@
|
||||
.set noat # allow manual use of $at
|
||||
.set noreorder # don't insert nops after branches
|
||||
|
||||
glabel load_asset_by_name
|
||||
/* 360E8 8005ACE8 27BDFFB8 */ addiu $sp, $sp, -0x48
|
||||
/* 360EC 8005ACEC AFB00030 */ sw $s0, 0x30($sp)
|
||||
/* 360F0 8005ACF0 0080802D */ daddu $s0, $a0, $zero
|
||||
/* 360F4 8005ACF4 AFB3003C */ sw $s3, 0x3c($sp)
|
||||
/* 360F8 8005ACF8 00A0982D */ daddu $s3, $a1, $zero
|
||||
/* 360FC 8005ACFC 3C0401E4 */ lui $a0, 0x1e4
|
||||
/* 36100 8005AD00 34840020 */ ori $a0, $a0, 0x20
|
||||
/* 36104 8005AD04 3C0501E4 */ lui $a1, 0x1e4
|
||||
/* 36108 8005AD08 34A5003C */ ori $a1, $a1, 0x3c
|
||||
/* 3610C 8005AD0C 27A60010 */ addiu $a2, $sp, 0x10
|
||||
/* 36110 8005AD10 AFBF0040 */ sw $ra, 0x40($sp)
|
||||
/* 36114 8005AD14 AFB20038 */ sw $s2, 0x38($sp)
|
||||
/* 36118 8005AD18 0C00A5CF */ jal dma_copy
|
||||
/* 3611C 8005AD1C AFB10034 */ sw $s1, 0x34($sp)
|
||||
/* 36120 8005AD20 8FA40020 */ lw $a0, 0x20($sp)
|
||||
/* 36124 8005AD24 0C00AB39 */ jal heap_malloc
|
||||
/* 36128 8005AD28 00000000 */ nop
|
||||
/* 3612C 8005AD2C 0040902D */ daddu $s2, $v0, $zero
|
||||
/* 36130 8005AD30 0240882D */ daddu $s1, $s2, $zero
|
||||
/* 36134 8005AD34 3C0201E4 */ lui $v0, 0x1e4
|
||||
/* 36138 8005AD38 34420020 */ ori $v0, $v0, 0x20
|
||||
/* 3613C 8005AD3C 3C0401E4 */ lui $a0, 0x1e4
|
||||
/* 36140 8005AD40 34840020 */ ori $a0, $a0, 0x20
|
||||
/* 36144 8005AD44 8FA50020 */ lw $a1, 0x20($sp)
|
||||
/* 36148 8005AD48 0240302D */ daddu $a2, $s2, $zero
|
||||
/* 3614C 8005AD4C 0C00A5CF */ jal dma_copy
|
||||
/* 36150 8005AD50 00A22821 */ addu $a1, $a1, $v0
|
||||
.L8005AD54:
|
||||
/* 36154 8005AD54 0220202D */ daddu $a0, $s1, $zero
|
||||
/* 36158 8005AD58 0C01BB5C */ jal strcmp
|
||||
/* 3615C 8005AD5C 0200282D */ daddu $a1, $s0, $zero
|
||||
/* 36160 8005AD60 10400003 */ beqz $v0, .L8005AD70
|
||||
/* 36164 8005AD64 00000000 */ nop
|
||||
/* 36168 8005AD68 08016B55 */ j .L8005AD54
|
||||
/* 3616C 8005AD6C 2631001C */ addiu $s1, $s1, 0x1c
|
||||
.L8005AD70:
|
||||
/* 36170 8005AD70 8E220018 */ lw $v0, 0x18($s1)
|
||||
/* 36174 8005AD74 AE620000 */ sw $v0, ($s3)
|
||||
/* 36178 8005AD78 0C00AB0A */ jal general_heap_malloc
|
||||
/* 3617C 8005AD7C 8E240014 */ lw $a0, 0x14($s1)
|
||||
/* 36180 8005AD80 3C0301E4 */ lui $v1, 0x1e4
|
||||
/* 36184 8005AD84 34630020 */ ori $v1, $v1, 0x20
|
||||
/* 36188 8005AD88 0040802D */ daddu $s0, $v0, $zero
|
||||
/* 3618C 8005AD8C 0040302D */ daddu $a2, $v0, $zero
|
||||
/* 36190 8005AD90 8E220010 */ lw $v0, 0x10($s1)
|
||||
/* 36194 8005AD94 8E250014 */ lw $a1, 0x14($s1)
|
||||
/* 36198 8005AD98 00432021 */ addu $a0, $v0, $v1
|
||||
/* 3619C 8005AD9C 00A32821 */ addu $a1, $a1, $v1
|
||||
/* 361A0 8005ADA0 0C00A5CF */ jal dma_copy
|
||||
/* 361A4 8005ADA4 00452821 */ addu $a1, $v0, $a1
|
||||
/* 361A8 8005ADA8 0C00AB4B */ jal heap_free
|
||||
/* 361AC 8005ADAC 0240202D */ daddu $a0, $s2, $zero
|
||||
/* 361B0 8005ADB0 0200102D */ daddu $v0, $s0, $zero
|
||||
/* 361B4 8005ADB4 8FBF0040 */ lw $ra, 0x40($sp)
|
||||
/* 361B8 8005ADB8 8FB3003C */ lw $s3, 0x3c($sp)
|
||||
/* 361BC 8005ADBC 8FB20038 */ lw $s2, 0x38($sp)
|
||||
/* 361C0 8005ADC0 8FB10034 */ lw $s1, 0x34($sp)
|
||||
/* 361C4 8005ADC4 8FB00030 */ lw $s0, 0x30($sp)
|
||||
/* 361C8 8005ADC8 03E00008 */ jr $ra
|
||||
/* 361CC 8005ADCC 27BD0048 */ addiu $sp, $sp, 0x48
|
Loading…
Reference in New Issue
Block a user