summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Noga <Tempus@chronometry.ca>2013-06-05 12:31:53 -0500
committerColin Noga <Tempus@chronometry.ca>2013-06-05 12:31:53 -0500
commit4f8866bed88d7e8e184a285dc855590bc618230e (patch)
tree15103dca2d355dc8c8d8e7738e121a9b1184f29e
parentd8d037539f1e648e34137e6bb96cff47c7861c8d (diff)
parent53b4cabb097291545b95115a4e430105e9295613 (diff)
downloadkamek-4f8866bed88d7e8e184a285dc855590bc618230e.tar.gz
kamek-4f8866bed88d7e8e184a285dc855590bc618230e.zip
Merge branch 'level-select' of ssh://treeki.rustedlogic.net:30000/Kamek into level-select
-rw-r--r--bugfixes.yaml31
-rw-r--r--include/common.h4
-rw-r--r--kamek_pal.x10
-rw-r--r--src/anmconstruct.S253
-rw-r--r--src/newer.cpp36
-rw-r--r--src/randomcrap.S3
6 files changed, 336 insertions, 1 deletions
diff --git a/bugfixes.yaml b/bugfixes.yaml
index 2180953..023fb41 100644
--- a/bugfixes.yaml
+++ b/bugfixes.yaml
@@ -1,7 +1,7 @@
---
# This has kind of turned into the "random stuff that we don't want to make a yaml for"
# yaml, hasn't it...
-source_files: [../src/randomcrap.S, ../src/music.cpp, ../src/fix38.S, ../src/nullsub.S, ../src/newer.cpp]
+source_files: [../src/randomcrap.S, ../src/music.cpp, ../src/fix38.S, ../src/nullsub.S, ../src/newer.cpp]#, ../src/anmconstruct.S]
hooks:
- name: ReplaceExceptionOccurred
type: branch_insn
@@ -327,3 +327,32 @@ hooks:
- name: ThwompNeverDieOutOfZone
type: nop_insn
area_pal: 0x809F5E40
+
+ - name: FixRunAnimTypo
+ type: add_func_pointer
+ src_addr_pal: 0x802F2A4C
+ target_func: 'Rrun'
+
+ # - name: FuckUpYoshi
+ # type: branch_insn
+ # branch_type: b
+ # src_addr_pal: 0x809FEFBC
+ # target_func: 'FuckUpYoshi'
+ # - name: FuckUpYoshi2
+ # type: branch_insn
+ # branch_type: b
+ # src_addr_pal: 0x800A7638
+ # target_func: 'FuckUpYoshi2'
+ # - name: YoshiStartAnimWrapper
+ # type: add_func_pointer
+ # src_addr_pal: 0x8031C5F4
+ # target_func: 'YoshiStartAnimWrapper'
+ # - name: YoshiStateWrapper
+ # type: add_func_pointer
+ # src_addr_pal: 0x80326D70
+ # target_func: 'YoshiStateWrapper'
+ # - name: AnmChrConstructWrapper
+ # type: branch_insn
+ # branch_type: b
+ # src_addr_pal: 0x80248AD0
+ # target_func: 'AnmChrConstructWrapper' \ No newline at end of file
diff --git a/include/common.h b/include/common.h
index e45f733..b002dca 100644
--- a/include/common.h
+++ b/include/common.h
@@ -161,5 +161,9 @@ static inline BOOL CXIsFinishedUncompLH( const CXUncompContextLH *context )
return (context->destCount > 0 || context->headerSize > 0)? FALSE : TRUE;
}
+namespace nw4r { namespace db {
+ void Exception_Printf_(const char *msg, ...);
+}}
+
#endif
diff --git a/kamek_pal.x b/kamek_pal.x
index 94a9eb5..49d6c41 100644
--- a/kamek_pal.x
+++ b/kamek_pal.x
@@ -1,4 +1,14 @@
SECTIONS {
+ GetResNodeNumEntries__Q34nw4r3g3d6ResMdlCFv = 0x8023B4A0;
+ MEMAllocFromAllocator = 0x801D5680;
+ __vt__Q34nw4r3g3d9AnmObjChr = 0x8034E9D0;
+ __vt__Q34nw4r3g3d12AnmObjChrRes = 0x8034E8C8;
+ GetAnmResult__Q34nw4r3g3d9ResAnmChrCFPQ34nw4r3g3d12ChrAnmResultUlf = 0x802417D0;
+
+ StartAnimOrig = 0x800D5EC0;
+ YoshiStateOrig = 0x8014BA60;
+ Exception_Printf___Q24nw4r2dbFPCce = 0x80234BC0;
+
ContinueFromFuckLineLiftActivation = 0x80839B04;
GabonRock_DropOutState = 0x80998CF0;
diff --git a/src/anmconstruct.S b/src/anmconstruct.S
new file mode 100644
index 0000000..ca73fdc
--- /dev/null
+++ b/src/anmconstruct.S
@@ -0,0 +1,253 @@
+.text
+.align 4
+.set var_38, -0x38
+.set var_10, -0x10
+.set arg_4, 4
+#define pHeap r29
+#define pSize r25
+#define resAnm r30
+#define bHasCache r27
+.global AnmChrConstructWrapper
+.extern Exception_Printf___Q24nw4r2dbFPCce
+AnmChrConstructWrapper:
+ stwu r1, -0x40(r1)
+ mflr r0
+ stw r0, 0x40+arg_4(r1)
+ addi r11, r1, 0x40+var_10
+ stfd f31, 0x40+var_10(r1)
+ psq_st f31, 0x38(r1), 1, 0
+ .extern _savegpr_25
+ bl _savegpr_25
+ lwz r8, 0(r5)
+ mr pHeap, r3
+ mr pSize, r4
+ mr resAnm, r5
+ cmpwi r8, 0
+ mr bHasCache, r7
+ beq resAnmInvalid
+
+ lwz r0, 0(r6)
+ cmpwi r0, 0
+ bne resMdlValid
+
+
+resAnmInvalid: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+34j
+ mr r7, r6 # resMdl
+ mr r8, resAnm
+ lwz r9, 0(r7)
+ lwz r10, 0(r8)
+ mr r6, bHasCache
+ mr r5, r4
+ mr r4, r3
+ lis r3, resInvalid@h
+ ori r3, r3, resInvalid@l
+ crclr 4*cr1+eq
+ bl Exception_Printf___Q24nw4r2dbFPCce
+ li r3, 0
+ b return
+
+# ---------------------------------------------------------------------------
+
+resMdlValid: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+40j
+ lhz r31, 0x22(r8)
+ mr r3, r6
+ .extern GetResNodeNumEntries__Q34nw4r3g3d6ResMdlCFv
+ bl GetResNodeNumEntries__Q34nw4r3g3d6ResMdlCFv
+
+ neg r0, bHasCache
+ mr r28, r3
+ or r4, r0, bHasCache
+ cmpwi pSize, 0
+ srawi r4, r4, 0x1F
+ slwi r0, r3, 1
+ and r3, r31, r4
+ mulli r26, r3, 0x4C
+ add r3, r26, r0
+ addi r4, r3, 0x34
+ beq loc_80248B58
+
+ stw r4, 0(pSize)
+
+
+loc_80248B58: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+80j
+ cmpwi pHeap, 0
+ bne loc_80248B68
+
+ mr r7, resAnm
+ lwz r8, 0(r7)
+ mr r6, bHasCache
+ mr r5, pSize
+ mr r4, pHeap
+ lis r3, noHeap@h
+ ori r3, r3, noHeap@l
+ crclr 4*cr1+eq
+ bl Exception_Printf___Q24nw4r2dbFPCce
+
+ li r3, 0
+ b return
+
+# ---------------------------------------------------------------------------
+
+loc_80248B68: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+8Cj
+ mr r3, pHeap
+ .extern MEMAllocFromAllocator
+ bl MEMAllocFromAllocator
+
+ cmpwi r3, 0
+ mr r31, r3
+ bne loc_80248B84
+
+ mr r7, resAnm
+ lwz r8, 0(r7)
+ mr r6, bHasCache
+ mr r5, pSize
+ mr r4, pHeap
+ lis r3, allocFail@h
+ ori r3, r3, allocFail@l
+ crclr 4*cr1+eq
+ bl Exception_Printf___Q24nw4r2dbFPCce
+ li r3, 0
+ b return
+
+# ---------------------------------------------------------------------------
+
+loc_80248B84: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+A8j
+ cmpwi bHasCache, 0
+ beq loc_80248B94
+
+ addi bHasCache, r3, 0x34
+ b loc_80248B98
+
+# ---------------------------------------------------------------------------
+
+loc_80248B94: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+B8j
+ li bHasCache, 0
+
+
+loc_80248B98: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+C0j
+ cmpwi r3, 0
+ add r4, r3, r26
+ addi r5, r4, 0x34
+ beq return_r31
+
+ lwz resAnm, 0(resAnm)
+ li r0, 0
+ .extern __vt__Q34nw4r3g3d9AnmObjChr
+ lis r4, __vt__Q34nw4r3g3d9AnmObjChr@h
+ ori r4, r4, __vt__Q34nw4r3g3d9AnmObjChr@l
+ stw r0, 4(r3)
+ stw pHeap, 8(r3)
+ stw r0, 0xC(r3)
+ stw r4, 0(r3)
+ stw r28, 0x10(r3)
+ stw r5, 0x14(r3)
+ mr r3, r31
+ lwz r12, 0(r31)
+ lwz r12, 0x34(r12)
+ mtctr r12
+ bctrl
+
+ lis r9, BLAH@h
+ ori r9, r9, BLAH@l
+ lwz r5, 0x24(resAnm)
+ lis r0, 0x4330
+ lhz r4, 0x20(resAnm)
+ .extern __vt__Q34nw4r3g3d12AnmObjChrRes
+ lis r3, __vt__Q34nw4r3g3d12AnmObjChrRes@h
+ slwi r6, r5, 2
+ subi r5, r13, 0x5C88
+ lwzx r5, r5, r6
+ xoris r4, r4, 0x8000
+ lfs f1, 0(r9)
+ ori r3, r3, __vt__Q34nw4r3g3d12AnmObjChrRes@l
+ stw r4, 0x40+var_38+4(r1)
+ cmpwi bHasCache, 0
+ lfs f0, 4(r9)
+ stw r0, 0x40+var_38(r1)
+ lfd f3, 8(r9)
+ stfs f1, 0x18(r31)
+ lfd f2, 0x40+var_38(r1)
+ stfs f0, 0x1C(r31)
+ fsubs f0, f2, f3
+ stfs f1, 0x20(r31)
+ stfs f0, 0x24(r31)
+ stw r5, 0x28(r31)
+ stw r3, 0(r31)
+ stw resAnm, 0x2C(r31)
+ stw bHasCache, 0x30(r31)
+ beq return_r31
+
+ lfs f31, 0x18(r31)
+ li r28, 0
+ li bHasCache, 0
+ b loc_80248C90
+
+# ---------------------------------------------------------------------------
+
+loc_80248C5C: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+1C8j
+ lwz r3, 0x14(r31)
+ lhzx r3, r3, bHasCache
+ rlwinm. r0, r3, 0,16,16
+ bne loc_80248C88
+
+ clrlwi r5, r3, 18
+ fmr f1, f31
+ mulli r0, r5, 0x4C
+ lwz r4, 0x30(r31)
+ addi r3, r31, 0x2C
+ add r4, r4, r0
+ .extern GetAnmResult__Q34nw4r3g3d9ResAnmChrCFPQ34nw4r3g3d12ChrAnmResultUlf
+ bl GetAnmResult__Q34nw4r3g3d9ResAnmChrCFPQ34nw4r3g3d12ChrAnmResultUlf
+
+
+loc_80248C88: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+198j
+ addi bHasCache, bHasCache, 2
+ addi r28, r28, 1
+
+
+loc_80248C90: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+188j
+ lwz r0, 0x10(r31)
+ cmplw r28, r0
+ blt loc_80248C5C
+
+
+return_r31: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+D4j
+ # nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+178j
+ mr r9, r31
+ mr r7, resAnm
+ lwz r8, 0(r7)
+ mr r6, bHasCache
+ mr r5, pSize
+ mr r4, pHeap
+ lis r3, final@h
+ ori r3, r3, final@l
+ crclr 4*cr1+eq
+ bl Exception_Printf___Q24nw4r2dbFPCce
+ mr r3, r31
+
+
+return: # CODE XREF: nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+48j
+ # nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+94j
+ # nw4r::g3d::AnmObjChrRes::Construct((MEMAllocator *,ulong *,nw4r::g3d::ResAnmChr,nw4r::g3d::ResMdl,bool))+B0j
+ addi r11, r1, 0x40+var_10
+ psq_l f31, 0x38(r1), 1, 0
+ lfd f31, 0x40+var_10(r1)
+ .extern _restgpr_25
+ bl _restgpr_25
+
+ lwz r0, 0x40+arg_4(r1)
+ mtlr r0
+ addi r1, r1, 0x40
+ blr
+
+
+.data
+resInvalid: .string "RES INVALID:h=%p s=%p c=%d m=%p\na=%p mV=%p aV=%p\n"
+noHeap: .string "NO HEAP:pHeap=%p pSize=%p bHasCache=%d\nresAnm=%p anmVal=%p\n"
+allocFail: .string "NO HEAP:pHeap=%p pSize=%p bHasCache=%d\nresAnm=%p anmVal=%p\n"
+final: .string "DONE:pHeap=%p pSize=%p bHasCache=%d resAnm=%p anmVal=%p output=%p\n"
+.align 8
+BLAH:
+.float 0.0, 1.0
+.long 0x43300000
+.long 0x80000000
diff --git a/src/newer.cpp b/src/newer.cpp
index edbbf3b..f1da7fc 100644
--- a/src/newer.cpp
+++ b/src/newer.cpp
@@ -10,6 +10,42 @@ int lastLevelIDs[] = {
};
+/*
+extern "C" void FuckUpYoshi(void *_this) {
+ dEn_c *koopa = (dEn_c*)fBase_c::search(EN_NOKONOKO, 0);
+ static int thing = 0;
+ thing++;
+ nw4r::db::Exception_Printf_("Fruit eaten: %d\n", thing);
+ if (thing == 5) {
+ nw4r::db::Exception_Printf_("5th fruit eaten\n");
+ nw4r::db::Exception_Printf_("Let's try fucking up Yoshi!\n");
+ daPlBase_c *yoshi = (daPlBase_c*)fBase_c::search(YOSHI, 0);
+ nw4r::db::Exception_Printf_("Fruit: %p ; Koopa: %p ; Yoshi: %p\n", _this, koopa, yoshi);
+ koopa->_vf220(yoshi);
+ nw4r::db::Exception_Printf_("Yoshi fucked up. Yay.\n");
+ thing = 0;
+ }
+}
+
+extern "C" void FuckUpYoshi2() {
+ dEn_c *koopa = (dEn_c*)fBase_c::search(EN_NOKONOKO, 0);
+ nw4r::db::Exception_Printf_("Let's try fucking up Yoshi!\n");
+ daPlBase_c *yoshi = (daPlBase_c*)fBase_c::search(YOSHI, 0);
+ koopa->_vf220(yoshi);
+ nw4r::db::Exception_Printf_("Yoshi fucked up. Yay.\n");
+}
+
+extern "C" void StartAnimOrig(dPlayerModelBase_c *_this, int id, float updateRate, float unk, float frame);
+extern "C" void YoshiStartAnimWrapper(dPlayerModelBase_c *_this, int id, float updateRate, float unk, float frame) {
+ nw4r::db::Exception_Printf_("[%d] anim %d (%f, %f, %f)\n", GlobalTickCount, id, updateRate, unk, frame);
+ StartAnimOrig(_this, id, updateRate, unk, frame);
+}
+extern "C" void YoshiStateOrig(daPlBase_c *_this, dStateBase_c *state, void *param);
+extern "C" void YoshiStateWrapper(daPlBase_c *_this, dStateBase_c *state, void *param) {
+ nw4r::db::Exception_Printf_("[%d] %s,%p\n", GlobalTickCount, state->getName(), param);
+ YoshiStateOrig(_this, state, param);
+}
+*/
void WriteAsciiToTextBox(nw4r::lyt::TextBox *tb, const char *source) {
diff --git a/src/randomcrap.S b/src/randomcrap.S
index 3e5909e..6d347d5 100644
--- a/src/randomcrap.S
+++ b/src/randomcrap.S
@@ -589,6 +589,9 @@ UniLogStr: .string "[ULog] returning %8x to: %x > %x > %x > %x > %x > %x\n"
SCMs: .string "Setting music to %d\n"
+.global Rrun
+Rrun: .string "Rrun"
+
.global enableHardMode
enableHardMode:
.byte 0