Decompile Bg_Ikana_Ray

This commit is contained in:
rozlette 2019-12-28 02:23:17 -06:00
parent 6a74885a38
commit 7692d06fcd
7 changed files with 116 additions and 173 deletions

View File

@ -54,7 +54,8 @@ C_FILES := $(wildcard src/libultra/*) \
$(wildcard src/code/*) \
$(wildcard src/boot_O2_g3/*) \
$(wildcard src/boot_O1/*) \
$(wildcard src/actors/Bg_Fu_Kaiten/*)
$(wildcard src/actors/Bg_Fu_Kaiten/*) \
$(wildcard src/actors/Bg_Ikana_Ray/*)
C_O_FILES = $(C_FILES:src/%.c=build/src/%.o)
ROM_FILES := $(shell cat ./tables/makerom_files.txt)
@ -80,6 +81,7 @@ $(shell mkdir -p $(BUILD_DIR)/src/code)
$(shell mkdir -p $(BUILD_DIR)/src/boot_O2_g3)
$(shell mkdir -p $(BUILD_DIR)/src/boot_O1)
$(shell mkdir -p $(BUILD_DIR)/src/actors/Bg_Fu_Kaiten)
$(shell mkdir -p $(BUILD_DIR)/src/actors/Bg_Ikana_Ray)
check: $(ROM)
@md5sum -c checksum.md5
@ -87,29 +89,11 @@ check: $(ROM)
$(ROM): $(ROM_FILES)
@./tools/makerom.py ./tables/dmadata_table.py $@
build/boot_pre_dmadata.bin: build/code_pre_dmadata.elf
$(MIPS_BINUTILS)objcopy --dump-section boot=$@ $<
build/%_pre_dmadata.bin: build/code_pre_dmadata.elf
$(MIPS_BINUTILS)objcopy --dump-section $*=$@ $<
build/code_pre_dmadata.bin: build/code_pre_dmadata.elf
$(MIPS_BINUTILS)objcopy --dump-section code=$@ $<
build/ovl_title_pre_dmadata.bin: build/code_pre_dmadata.elf
$(MIPS_BINUTILS)objcopy --dump-section ovl_title=$@ $<
build/ovl_Bg_Fu_Kaiten_pre_dmadata.bin: build/code_pre_dmadata.elf
$(MIPS_BINUTILS)objcopy --dump-section ovl_Bg_Fu_Kaiten=$@ $<
build/boot.bin: build/code.elf
$(MIPS_BINUTILS)objcopy --dump-section boot=$@ $<
build/code.bin: build/code.elf
$(MIPS_BINUTILS)objcopy --dump-section code=$@ $<
build/ovl_title.bin: build/code.elf
$(MIPS_BINUTILS)objcopy --dump-section ovl_title=$@ $<
build/ovl_Bg_Fu_Kaiten.bin: build/code.elf
$(MIPS_BINUTILS)objcopy --dump-section ovl_Bg_Fu_Kaiten=$@ $<
build/%.bin: build/code.elf
$(MIPS_BINUTILS)objcopy --dump-section $*=$@ $<
build/code_pre_dmadata.elf: $(S_O_FILES) $(C_O_FILES) linker_scripts/code_script.txt undef.txt linker_scripts/object_script.txt
$(LD) -r -T linker_scripts/code_script.txt -T undef.txt -T linker_scripts/object_script.txt --no-check-sections --accept-unknown-input-arch -o $@
@ -150,6 +134,9 @@ build/decomp/ovl_title: build/ovl_title.bin
build/decomp/ovl_Bg_Fu_Kaiten: build/ovl_Bg_Fu_Kaiten.bin
cp $< $@
build/decomp/ovl_Bg_Ikana_Ray: build/ovl_Bg_Ikana_Ray.bin
cp $< $@
build/baserom_pre_dmadata/boot: build/boot_pre_dmadata.bin
cp $< $@
@ -162,10 +149,9 @@ build/decomp_pre_dmadata/ovl_title: build/ovl_title_pre_dmadata.bin
build/decomp_pre_dmadata/ovl_Bg_Fu_Kaiten: build/ovl_Bg_Fu_Kaiten_pre_dmadata.bin
cp $< $@
build/src/actors/Bg_Fu_Kaiten/z_bg_fu_kaiten.o: src/actors/Bg_Fu_Kaiten/z_bg_fu_kaiten.c include/*
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTIMIZATION) -Iinclude -o $@ $<
./tools/overlay.py build/src/actors/Bg_Fu_Kaiten/z_bg_fu_kaiten.o build/src/actors/Bg_Fu_Kaiten/overlay.s
$(AS) $(ASFLAGS )build/src/actors/Bg_Fu_Kaiten/overlay.s -o build/src/actors/Bg_Fu_Kaiten/overlay.o
build/decomp_pre_dmadata/ovl_Bg_Ikana_Ray: build/ovl_Bg_Ikana_Ray_pre_dmadata.bin
cp $< $@
disasm:
@./tools/disasm.py -d ./asm -e ./include -u . -l ./tables/files.py -f ./tables/functions.py -o ./tables/objects.py -v ./tables/variables.py -v ./tables/vrom_variables.py -v ./tables/pre_boot_variables.py
@ -184,6 +170,11 @@ build/baserom_pre_dmadata/%: baserom/%
build/asm/%.o: asm/%.asm
$(AS) $(ASFLAGS) $^ -o $@
build/src/actors/%.o: src/actors/%.c include/*
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTIMIZATION) -Iinclude -o $@ $<
./tools/overlay.py $@ build/src/actors/$*_overlay.s
$(AS) $(ASFLAGS) build/src/actors/$*_overlay.s -o build/src/actors/$*_overlay.o
build/src/%.o: src/%.c include/*
$(CC) -c $(CFLAGS) $(MIPS_VERSION) $(OPTIMIZATION) -Iinclude -o $@ $<

View File

@ -5,8 +5,9 @@
extern UNK_TYPE D_04029CB0; // D_04029CB0
extern UNK_TYPE D_04029CF0; // D_04029CF0
extern UNK_TYPE D_06001100; // D_06001100
extern UNK_TYPE D_06001228; // D_06001228
extern Gfx object_ikana_obj_001100[];
extern AnimatedTexture object_ikana_obj_001228[];
extern Gfx object_fu_kaiten_0005D0[];
extern BgMeshHeader object_fu_kaiten_002D30;

View File

@ -2059,7 +2059,7 @@ typedef struct {
typedef struct {
/* 0x000 */ Actor base;
/* 0x144 */ ColCylinder cylinder;
/* 0x144 */ ColCylinder collision;
/* 0x190 */ AnimatedTexture* animatedTextures;
/* 0x194 */ actor_func update;
} ActorBgIkanaRay;

View File

@ -2700,7 +2700,7 @@ SECTIONS
build/src/actors/Bg_Fu_Kaiten/z_bg_fu_kaiten.o(.text)
build/src/actors/Bg_Fu_Kaiten/z_bg_fu_kaiten.o(.data)
build/src/actors/Bg_Fu_Kaiten/z_bg_fu_kaiten.o(.rodata)
build/src/actors/Bg_Fu_Kaiten/overlay.o(.ovl)
build/src/actors/Bg_Fu_Kaiten/z_bg_fu_kaiten_overlay.o(.ovl)
}
ovl_Obj_Aqua :
@ -3703,8 +3703,10 @@ SECTIONS
ovl_Bg_Ikana_Ray :
{
build/asm/ovl_Bg_Ikana_Ray_0x80BD53C0.o(.text)
build/asm/ovl_Bg_Ikana_Ray_data.o(.text)
build/src/actors/Bg_Ikana_Ray/z_bg_ikana_ray.o(.text)
build/src/actors/Bg_Ikana_Ray/z_bg_ikana_ray.o(.data)
build/src/actors/Bg_Ikana_Ray/z_bg_ikana_ray.o(.rodata)
build/src/actors/Bg_Ikana_Ray/z_bg_ikana_ray_overlay.o(.ovl)
}
ovl_Bg_Ikana_Shutter :

View File

@ -1,7 +1,8 @@
D_04029CB0 = 0x04029CB0;
D_04029CF0 = 0x04029CF0;
D_06001100 = 0x06001100;
D_06001228 = 0x06001228;
object_ikana_obj_001100 = 0x06001100;
object_ikana_obj_001228 = 0x06001228;
object_fu_kaiten_0005D0 = 0x060005D0;
object_fu_kaiten_002D30 = 0x06002D30;

View File

@ -0,0 +1,86 @@
#include <ultra64.h>
#include <global.h>
ActorInitData bgIkanaRayInitData = {
0x0256,
6,
0,
0,
0x0203,
0, 0,
sizeof(ActorBgIkanaRay),
(actor_func)BgIkanaRay_Init,
(actor_func)BgIkanaRay_Fini,
(actor_func)BgIkanaRay_Main,
(actor_func)BgIkanaRay_Draw
};
// TODO better formatting
ColCylinderInit bgIkanaRayCylinderInit = {
{ 10, 33, 0, 0, 0, 1 },
{ 0, { 0x00200000, 0, 0 }, { 0, 0, 0 }, 25, 0, 1 },
{ 90, 420, 65116}
};
// TODO macro
ActorInitVar bgIkanaRayCompInit[] = {
{1, 6, 0x0FC, 4000},
{1, 6, 0x100, 1000},
{1, 6, 0x104, 1000},
{0, 9, 0x058, 100}
};
void BgIkanaRay_Init(ActorBgIkanaRay* this, GlobalContext* ctxt) {
ColCylinder* collision = &this->collision;
u32 pad;
Lib_ApplyActorInitVars((Actor*)this, bgIkanaRayCompInit);
Collision_InitCylinderDefault(ctxt, collision);
Collision_InitCylinderWithData(ctxt, collision, (Actor*)this, &bgIkanaRayCylinderInit);
Collision_CylinderMoveToActor((Actor*)this, &this->collision);
this->animatedTextures = (AnimatedTexture*)Lib_PtrSegToVirt((u32)object_ikana_obj_001228);
if (Actor_GetSwitchFlag(ctxt, this->base.variable & 0x7F) != 0) {
BgIkanaRay_SetActivated(this);
} else {
BgIkanaRay_SetDeactivated(this);
}
}
void BgIkanaRay_Fini(ActorBgIkanaRay* this, GlobalContext* ctxt) {
ColCylinder* collision = &this->collision;
Collision_FiniCylinder(ctxt, collision);
}
void BgIkanaRay_SetDeactivated(ActorBgIkanaRay* this) {
this->base.draw = NULL;
this->base.flags |= 0x10;
this->update = (actor_func)BgIkanaRay_UpdateCheckForActivation;
}
void BgIkanaRay_UpdateCheckForActivation(ActorBgIkanaRay* this, GlobalContext* ctxt) {
if (Actor_GetSwitchFlag(ctxt, this->base.variable & 0x7F) != 0) {
BgIkanaRay_SetActivated(this);
}
}
void BgIkanaRay_SetActivated(ActorBgIkanaRay* this) {
this->base.draw = (actor_func)BgIkanaRay_Draw;
this->base.flags &= 0xFFFFFFEF;
this->update = (actor_func)BgIkanaRay_UpdateActivated;
}
void BgIkanaRay_UpdateActivated(ActorBgIkanaRay* this, GlobalContext* ctxt) {
Collision_AddAT(ctxt, &ctxt->collisionContext, &this->collision.base);
}
void BgIkanaRay_Main(ActorBgIkanaRay* this, GlobalContext* ctxt) {
this->update((Actor*)this, ctxt);
}
void BgIkanaRay_Draw(ActorBgIkanaRay* this, GlobalContext* ctxt) {
SceneProc_DrawAllSceneAnimatedTextures(ctxt, this->animatedTextures);
func_800BE03C(ctxt, object_ikana_obj_001100);
}

View File

@ -1,138 +0,0 @@
#include <ultra64.h>
#include <global.h>
typedef struct z_ActorBgIkanaRay_s {
/* 0x000 */ Actor baseActor;
/* 0x144 */ UNK_TYPE unk144;
/* 0x148 */ u8 pad5[0x48];
/* 0x190 */ UNK_TYPE unk190;
/* 0x194 */ void(*unk404)(struct z_ActorBgIkanaRay_s*, GlobalContext*);
} z_ActorBgIkanaRay;
void z_bg_ikana_ray_init(z_ActorBgIkanaRay* this, GlobalContext* ctxt);
void z_bg_ikana_ray_fini(z_ActorBgIkanaRay* this, GlobalContext* ctxt);
void z_bg_ikana_ray_main(z_ActorBgIkanaRay* this, GlobalContext* ctxt);
void z_bg_ikana_ray_draw(z_ActorBgIkanaRay* this, GlobalContext* ctxt);
void func_80BD5498(z_ActorBgIkanaRay* this);
void func_80BD54BC(z_ActorBgIkanaRay* this, GlobalContext* ctxt);
void func_80BD5500(z_ActorBgIkanaRay* this);
void func_80BD5530(z_ActorBgIkanaRay* this, GlobalContext* ctxt);
ActorInitData bgIkanaRayInitVar = {
0x0256,
6,
0,
0,
0x0203,
sizeof(z_ActorBgIkanaRay),
(actor_func)z_bg_ikana_ray_init,
(actor_func)z_bg_ikana_ray_fini,
(actor_func)z_bg_ikana_ray_main,
(actor_func)z_bg_ikana_ray_draw
};
GLOBAL_ASM(
.data
glabel D_80BD55F0
/* 000140 0x80BD55F0 */ .word 0x0A210000
/* 000141 0x80BD55F4 */ .word 0x00010000
/* 000142 0x80BD55F8 */ .word 0x00000000
/* 000143 0x80BD55FC */ .word 0x00200000
/* 000144 0x80BD5600 */ .word 0x00000000
/* 000145 0x80BD5604 */ .word 0x00000000
/* 000146 0x80BD5608 */ .word 0x00000000
/* 000147 0x80BD560C */ .word 0x19000100
/* 000148 0x80BD5610 */ .word 0x005A01A4
/* 000149 0x80BD5614 */ .word 0xFE5C0000
/* 000150 0x80BD5618 */ .word 0x00000000
)
// TODO macro
ActorInitVar bgIkanaRayCompInit[] = {
{1, 6, 0x0FC, 4000},
{1, 6, 0x100, 1000},
{1, 6, 0x104, 1000},
{0, 9, 0x058, 100}
};
// Overlay info
GLOBAL_ASM(
.data
glabel D_80BD562C
/* 000155 0x80BD562C */ .word 0x00000000
/* 000156 0x80BD5630 */ .word 0x00000210
/* 000157 0x80BD5634 */ .word 0x00000060
/* 000158 0x80BD5638 */ .word 0x00000000
/* 000159 0x80BD563C */ .word 0x00000000
/* 000160 0x80BD5640 */ .word 0x00000011
/* 000161 0x80BD5644 */ .word 0x45000014
/* 000162 0x80BD5648 */ .word 0x46000018
/* 000163 0x80BD564C */ .word 0x45000034
/* 000164 0x80BD5650 */ .word 0x46000038
/* 000165 0x80BD5654 */ .word 0x44000080
/* 000166 0x80BD5658 */ .word 0x44000090
/* 000167 0x80BD565C */ .word 0x450000DC
/* 000168 0x80BD5660 */ .word 0x460000E0
/* 000169 0x80BD5664 */ .word 0x44000128
/* 000170 0x80BD5668 */ .word 0x45000144
/* 000171 0x80BD566C */ .word 0x46000150
/* 000172 0x80BD5670 */ .word 0x4500014C
/* 000173 0x80BD5674 */ .word 0x46000154
/* 000174 0x80BD5678 */ .word 0x82000010
/* 000175 0x80BD567C */ .word 0x82000014
/* 000176 0x80BD5680 */ .word 0x82000018
/* 000177 0x80BD5684 */ .word 0x8200001C
)
void z_bg_ikana_ray_init(z_ActorBgIkanaRay* this, GlobalContext* ctxt) {
UNK_TYPE* sp24 = &this->unk144;
u32 pad;
func_800FFADC((Actor*)this, bgIkanaRayCompInit);
func_800E119C(ctxt, sp24);
func_800E130C(ctxt, sp24, (Actor*)this, &D_80BD55F0);
func_800E7DF8((Actor*)this, &this->unk144);
this->unk190 = func_80100504((UNK_TYPE)&D_06001228); // XXX: D_06001228 is probably a constant
if (func_800B5BB0(ctxt, this->baseActor.unk1C & 0x7F) != 0) {
func_80BD5500(this);
} else {
func_80BD5498(this);
}
}
void z_bg_ikana_ray_fini(z_ActorBgIkanaRay* this, GlobalContext* ctxt) {
UNK_TYPE* a1 = &this->unk144;
func_800E11EC(ctxt, a1);
}
void func_80BD5498(z_ActorBgIkanaRay* this) {
this->baseActor.drawFunc = NULL;
this->baseActor.unk4 |= 0x10;
this->unk404 = func_80BD54BC;
}
void func_80BD54BC(z_ActorBgIkanaRay* this, GlobalContext* ctxt) {
if (func_800B5BB0(ctxt, this->baseActor.unk1C & 0x7F) != 0) {
func_80BD5500(this);
}
}
void func_80BD5500(z_ActorBgIkanaRay* this) {
this->baseActor.drawFunc = (actor_func)z_bg_ikana_ray_draw;
this->baseActor.unk4 &= 0xFFFFFFEF;
this->unk404 = func_80BD5530;
}
void func_80BD5530(z_ActorBgIkanaRay* this, GlobalContext* ctxt) {
func_800E2558(ctxt, &ctxt->unk18884, &this->unk144);
}
void z_bg_ikana_ray_main(z_ActorBgIkanaRay* this, GlobalContext* ctxt) {
this->unk404(this, ctxt);
}
void z_bg_ikana_ray_draw(z_ActorBgIkanaRay* this, GlobalContext* ctxt) {
func_80131758(ctxt, this->unk190);
func_800BE03C(ctxt, (UNK_TYPE)&D_06001100); // XXX: D_06001100 is probably a constant
}