diff options
author | Colin Noga <Tempus@Spectrum-Song.local> | 2011-06-19 03:32:22 -0500 |
---|---|---|
committer | Colin Noga <Tempus@Spectrum-Song.local> | 2011-06-19 03:32:22 -0500 |
commit | 8b4c5e87a0a407246d5ee37684105e72283687a5 (patch) | |
tree | 687a5e9a872c23a6730b938cc43f77aac4b42e0b | |
parent | fe5ff40e8e6ab1cdc83df3263d3d16830e4ff18f (diff) | |
download | kamek-8b4c5e87a0a407246d5ee37684105e72283687a5.tar.gz kamek-8b4c5e87a0a407246d5ee37684105e72283687a5.zip |
Added all latest fixes for textures, event looper, and sprite spawner, plus some other odds and ends
-rw-r--r-- | spritespawner.yaml | 15 | ||||
-rw-r--r-- | spritetex.yaml | 172 | ||||
-rw-r--r-- | src/spritespawner.cpp | 101 | ||||
-rw-r--r-- | src/spritetex.S | 317 |
4 files changed, 593 insertions, 12 deletions
diff --git a/spritespawner.yaml b/spritespawner.yaml new file mode 100644 index 0000000..351e68e --- /dev/null +++ b/spritespawner.yaml @@ -0,0 +1,15 @@ +---
+# Replaces Ac_Lift_ObjBg_HMove_Big
+
+source_files: [../src/spritespawner.cpp]
+hooks:
+ - name: SpriteSpawner_Create
+ type: add_func_pointer
+ src_addr_pal: 0x80ADEA18
+ target_func: 'SpriteSpawner_Create(SpriteSpawner *)'
+
+ - name: SpriteSpawner_Execute
+ type: add_func_pointer
+ src_addr_pal: 0x80ADEA24
+ target_func: 'SpriteSpawner_Execute(SpriteSpawner *)'
+
\ No newline at end of file diff --git a/spritetex.yaml b/spritetex.yaml index 56a4da4..a9c107c 100644 --- a/spritetex.yaml +++ b/spritetex.yaml @@ -140,6 +140,13 @@ hooks: target_func: 'TEX_Gabon'
+ - name: TEX_Gabon_Spike
+ type: branch_insn
+ branch_type: bl
+ src_addr_pal: 0x80A00984
+ target_func: 'TEX_Gabon_Spike'
+ + - name: TEX_GabonRock
type: branch_insn
branch_type: bl
@@ -245,11 +252,18 @@ hooks: # target_func: 'TEX_CheepChomp'
-# - name: TEX_Boo
-# type: branch_insn
-# branch_type: bl
-# src_addr_pal: 0x80AAF5E0
-# target_func: 'TEX_Boo'
+# - name: TEX_BigBoo +# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80AAF5E0
+# target_func: 'TEX_BigBoo'
+# +# +# - name: TEX_Boo +# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x808F0628
+# target_func: 'TEX_Boo'
- name: TEX_Midway
@@ -294,6 +308,68 @@ hooks: # target_func: 'TEX_Platforms'
+# - name: TEX_Platform_ShifterH
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80841CBC
+# target_func: 'TEX_Platform_ShifterH'
+ +# - name: TEX_Platform_ShifterF
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x808374FC
+# target_func: 'TEX_Platform_ShifterF'
+# +# - name: TEX_Platform_ShifterL
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80839810
+# target_func: 'TEX_Platform_ShifterL'
+# +# - name: TEX_Platform_ShifterV
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80844D68
+# target_func: 'TEX_Platform_ShifterF'
+# +# - name: TEX_Platform_ShifterR
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80845B08
+# target_func: 'TEX_Platform_ShifterR'
+# +# - name: TEX_Platform_ShifterS
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80848A64
+# target_func: 'TEX_Platform_ShifterS'
+# +# - name: TEX_Platform_ShifterK
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x8084A778
+# target_func: 'TEX_Platform_ShifterK'
+# +# - name: TEX_Platform_ShifterW
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x8084F344
+# target_func: 'TEX_Platform_ShifterW'
+# +# - name: TEX_Platform_ShifterSL
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80858870
+# target_func: 'TEX_Platform_ShifterSL'
+# +# - name: TEX_Platform_ShifterWL
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x808BF040
+# target_func: 'TEX_Platform_ShifterW'
+# + + - name: TEX_PokeyA
type: branch_insn
branch_type: bl
@@ -315,3 +391,89 @@ hooks: target_func: 'TEX_PokeyC'
+ - name: TEX_PokeyNoSand
+ type: branch_insn
+ branch_type: bl
+ src_addr_pal: 0x80A9E7A8
+ target_func: 'TEX_PokeyNoSand'
+ + +# - name: TEX_PokeySnowmanPos
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80A9F7C0
+# target_func: 'TEX_PokeySnowmanPos'
+# +# - name: TEX_PokeySnowmanPosA
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80A9FEF8
+# target_func: 'TEX_PokeySnowmanPosA'
+# +# - name: TEX_PokeySnowmanPosB
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80AA002C
+# target_func: 'TEX_PokeySnowmanPosB'
+# +# +# - name: TEX_PokeySnowmanPosC
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80AA04D0
+# target_func: 'TEX_PokeySnowmanPosC'
+# +# +# - name: TEX_PokeySnowmanPosD
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80AA0644
+# target_func: 'TEX_PokeySnowmanPosD'
+# +# - name: TEX_PokeySnowmanPosE
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80AA0848
+# target_func: 'TEX_PokeySnowmanPosE'
+# +# - name: TEX_PokeySnowmanPosF
+# type: branch_insn
+# branch_type: bl
+# src_addr_pal: 0x80AA0A5C
+# target_func: 'TEX_PokeySnowmanPosF'
+# +# +# +# - name: TEX_PokeySnowmanPosZ
+# type: patch
+# data: '60000000'
+# addr_pal: 0x80A9D054
+ + + - name: TEX_PokeySnowman
+ type: branch_insn
+ branch_type: bl
+ src_addr_pal: 0x80A9F714
+ target_func: 'TEX_PokeySnowman'
+ + + - name: TEX_CloudBounce
+ type: branch_insn
+ branch_type: bl
+ src_addr_pal: 0x80A5C900
+ target_func: 'TEX_CloudBounce'
+ + + - name: TEX_SpikeBall
+ type: branch_insn
+ branch_type: bl
+ src_addr_pal: 0x809B7620
+ target_func: 'TEX_SpikeBall'
+ + + - name: TEX_SpikeBallSmall
+ type: branch_insn
+ branch_type: bl
+ src_addr_pal: 0x80AB6054
+ target_func: 'TEX_SpikeBall'
+ diff --git a/src/spritespawner.cpp b/src/spritespawner.cpp new file mode 100644 index 0000000..d9ee51a --- /dev/null +++ b/src/spritespawner.cpp @@ -0,0 +1,101 @@ +#include <common.h>
+#include <game.h>
+
+struct SpriteSpawner {
+ u32 id; // 0x00
+ u32 settings; // 0x04
+ u16 name; // 0x08
+ u8 _0A[6]; // 0x0A
+ u8 _10[0x9C]; // 0x10
+ float x; // 0xAC
+ float y; // 0xB0
+ float z; // 0xB4
+ u8 _B8[0x318]; // 0xB8
+ // Any variables you add to the class go here; starting at offset 0x3D0
+ u64 eventFlag; // 0x3D0
+ u16 type; // 0x3D4
+ u8 lastEvState; // 0x3D6
+};
+
+struct EventTable_t {
+ u64 events;
+};
+ + +struct VEC {
+ float x;
+ float y;
+ float z;
+};
+ +
+extern EventTable_t *EventTable;
+extern "C" void CreateActor(u16 classID, int settings, VEC pos, char rot, char layer); + +void SpriteSpawner_Update(SpriteSpawner *self);
+ +#define ACTIVATE 1
+#define DEACTIVATE 0
+
+ + +
+bool SpriteSpawner_Create(SpriteSpawner *self) {
+ OSReport("I exist, dammit!");
+ + char eventNum = (self->settings >> 24) & 0xFF;
+ self->eventFlag = (u64)1 << (eventNum - 1);
+
+
+ self->type = (self->settings) & 0xFFFF;
+
+ self->lastEvState = 0xFF;
+
+ SpriteSpawner_Update(self);
+
+ return true;
+}
+
+bool SpriteSpawner_Execute(SpriteSpawner *self) {
+ SpriteSpawner_Update(self);
+ return true;
+}
+
+ +void SpriteSpawner_Update(SpriteSpawner *self) {
+
+ u8 newEvState = 0;
+ if (EventTable->events & self->eventFlag)
+ newEvState = 1;
+
+ if (newEvState == self->lastEvState)
+ return;
+
+ u8 offState;
+ if (newEvState == ACTIVATE) + {
+ offState = (newEvState == 1) ? 1 : 0;
+ + // Put an action for when the event turns on here + + int spriteset = 0; + VEC pos; + pos.x = self->x; + pos.y = self->y; + pos.z = self->z; + + OSReport("Spawning Sprite: %d at %f,%f,%f\n", self->type, pos.x, pos.y, pos.z);
+ + CreateActor(self->type, spriteset, pos, 0, 0); + }
+
+ else + {
+ offState = (newEvState == 1) ? 0 : 1;
+ + // Put an action for when the event turns off here + + }
+ + self->lastEvState = newEvState;
+} diff --git a/src/spritetex.S b/src/spritetex.S index 0336a5c..bf7a02f 100644 --- a/src/spritetex.S +++ b/src/spritetex.S @@ -199,11 +199,16 @@ TEX_Gabon: srwi r5, r5, 24
andi. r5, r5, 0xF
b GetTexFilenameForR5
-
+ + +.global TEX_Gabon_Spike
+TEX_Gabon_Spike:
+ andis. r4, r4, 0xFFF0
+ blr
.global TEX_GabonRock
TEX_GabonRock:
- lwz r5, 4(r29)
+ lwz r5, 4(r28)
srwi r5, r5, 24
andi. r5, r5, 0xF
b GetTexFilenameForR5
@@ -333,13 +338,19 @@ TEX_CheepChomp: b GetTexFilenameForR5
-.global TEX_Boo
-TEX_Boo:
+.global TEX_BigBoo
+TEX_BigBoo:
lwz r5, 4(r27)
srwi r5, r5, 24
andi. r5, r5, 0xF
b GetTexFilenameForR5
+.global TEX_Boo
+TEX_Boo:
+ lwz r5, 4(r30)
+ srwi r5, r5, 24
+ andi. r5, r5, 0xF
+ b GetTexFilenameForR5
.global TEX_Midway
TEX_Midway:
@@ -382,12 +393,91 @@ TEX_Spinner: .global TEX_Platforms
-TEX_Platforms:
+TEX_Platforms: + + li r5, 1 + b GetTexFilenameForR5
+# cmpwi r0, 9 +# blt ReplacePlatforms +# +# lwzx r5, r5, r0 +# blr + + +ReplacePlatforms: + lwz r5, 4(r29)
srwi r5, r5, 4
andi. r5, r5, 0xF
b GetTexFilenameForR5
+ +.global TEX_Platform_ShifterH
+TEX_Platform_ShifterH: + + stw r5, 0x504(r30) + lwz r5, 4(r30) + stw r5, 0x3D8(r30) + blr + +.global TEX_Platform_ShifterF
+TEX_Platform_ShifterF: + + stw r4, 0x504(r30) + lwz r4, 4(r30) + stw r4, 0x3D8(r30) + blr + +.global TEX_Platform_ShifterL
+TEX_Platform_ShifterL: + + stw r5, 0x504(r28) + lwz r5, 4(r28) + stw r5, 0x3D8(r28) + blr + +.global TEX_Platform_ShifterR
+TEX_Platform_ShifterR: + + stw r4, 0x504(r31) + lwz r4, 4(r31) + stw r4, 0x3D8(r31) + blr + +.global TEX_Platform_ShifterS
+TEX_Platform_ShifterS: + + stw r30, 0x4C4(r27) + lwz r30, 4(r27) + stw r30, 0x398(r27) + blr + +.global TEX_Platform_ShifterK
+TEX_Platform_ShifterK: + + stw r4, 0x5A4(r27) + lwz r4, 4(r27) + stw r4, 0x478(r27) + blr + +.global TEX_Platform_ShifterW
+TEX_Platform_ShifterW: + + stw r0, 0x504(r29) + lwz r0, 4(r29) + stw r0, 0x3D8(r29) + blr + +.global TEX_Platform_ShifterSL
+TEX_Platform_ShifterSL: + + stw r4, 0x504(r29) + lwz r4, 4(r29) + stw r4, 0x3D8(r29) + blr + + + .global TEX_PokeyA
TEX_PokeyA:
@@ -401,16 +491,217 @@ TEX_PokeyA: TEX_PokeyB:
lwz r5, 4(r29)
srwi r5, r5, 24
- andi. r5, r5, 0xF
+ andi. r5, r5, 0xF + b GetTexFilenameForR5
+ +.global TEX_PokeySnowman +TEX_PokeySnowman: + + lwz r10, 4(r30)
+ srwi r10, r10, 24
+ andi. r10, r10, 0xF + + cmpwi r10, 0x2 + bne SnowmanPokey + + lwz r10, 4(r30) + # r10 is the current height + andi. r10, r10, 0xF + + # Find it + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f0, r11, r10 # get it from the array + + blr + + +SnowmanPokey: + + lfs f0, 0x54(r31) + blr
+ + + + +.global TEX_PokeySnowmanPosF +TEX_PokeySnowmanPosF: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f2, r11, r10 # get it from the array + + fmuls f0, f0, f2 + stfs f0, 0xB0(r30) + blr + +.global TEX_PokeySnowmanPosE +TEX_PokeySnowmanPosE: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f2, r11, r10 # get it from the array + + fmuls f31, f31, f2 + stfs f31, 0xB0(r29) + blr + +.global TEX_PokeySnowmanPosD +TEX_PokeySnowmanPosD: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f2, r11, r10 # get it from the array + + fmuls f1, f1, f2 + stfs f1, 0xB0(r30) + blr + + +.global TEX_PokeySnowmanPosC +TEX_PokeySnowmanPosC: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f2, r11, r10 # get it from the array + + fmuls f0, f0, f2 + stfs f0, 0xB0(r31) + blr + + +.global TEX_PokeySnowmanPosB +TEX_PokeySnowmanPosB: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f0, r11, r10 # get it from the array + + fmuls f1, f1, f0 + stfs f1, 0x18(r1) + blr + + + +.global TEX_PokeySnowmanPosA +TEX_PokeySnowmanPosA: + + lwz r10, 4(r31) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f0, r11, r10 # get it from the array + + fmuls f3, f3, f0 + stfs f3, 0x168(r31) + blr + + +.global TEX_PokeySnowmanPos +TEX_PokeySnowmanPos: + + mr r3, r30 + + lwz r10, 4(r30) + andi. r10, r10, 0xF + + lis r11, SnowmanTable@h + ori r11, r11, SnowmanTable@l + slwi r10, r10, 2 # size *= 4 (size of float) + lfsx f0, r11, r10 # get it from the array + + lis r5, AddAmount@h + ori r5, r5, AddAmount@l + slwi r6, r6, 2 # size *= 4 (size of float) + lfsx f3, r5, r6 # get it from the array + + lfs f2, 0xB0(r30) + fmuls f3, f3, f0 + fmuls f3, f3, f0 + fmuls f3, f3, f0 + fsubs f2, f2, f3 + stfs f2, 0xB0(r30) + + blr + +SnowmanPokeyPos: + + fsubs f0, f0, f31 + fsubs f0, f0, f31 + fsubs f1, f1, f31 + fsubs f1, f1, f31 + + + lfs f2, 8(r1) + fadds f2, f2, f31 + stfs f2, 8(r1) + blr
+ .global TEX_PokeyC
TEX_PokeyC:
+ lwz r5, 4(r30) + andis. r5, r5, 0xFFF0 or r5, r5, r31
+ or r5, r5, r0
+ + lwz r0, 0x524(r30) + slwi r0, r0, 8 + or r5, r5, r0 + blr
+ + +.global TEX_PokeyNoSand
+TEX_PokeyNoSand:
+ cmpwi r3, 0x20 + blr
+ + +.global TEX_CloudBounce
+TEX_CloudBounce:
+ lwz r5, 4(r28)
+ srwi r5, r5, 24
+ andi. r5, r5, 0xF
+ b GetTexFilenameForR5
+ + +.global TEX_SpikeBall
+TEX_SpikeBall:
+ lwz r5, 4(r30)
+ srwi r5, r5, 24
+ andi. r5, r5, 0xF
+ b GetTexFilenameForR5
+ + + .data
@@ -419,4 +710,16 @@ TexFilenameBuffer: TexFormatString:
.string "g3d/t%02d.brres"
-
+ +ConvertFloat: + .word 0x43300000,0x0,0x43300000,0x80000000 + +.align 4 + +SnowmanTable: + .float 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 4.5, 5.0, 5.5, 6.0, 6.5 + +AddAmount: + .float 32.0 +
+.align 4 |