diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/eventlooper.cpp | 116 | ||||
-rw-r--r-- | src/growup.s | 877 | ||||
-rw-r--r-- | src/levelspecial.cpp | 69 | ||||
-rw-r--r-- | src/spritetex.S | 17 |
4 files changed, 942 insertions, 137 deletions
diff --git a/src/eventlooper.cpp b/src/eventlooper.cpp new file mode 100644 index 0000000..755742d --- /dev/null +++ b/src/eventlooper.cpp @@ -0,0 +1,116 @@ +#include <common.h>
+#include <game.h>
+
+struct EventLooper {
+ 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
+ u64 eventActive; // 0x3D0
+ u8 delay; // 0x3D4
+ u8 delayCount; // 0x3D7
+};
+
+struct EventTable_t {
+ u64 events;
+ // ...
+};
+
+extern EventTable_t *EventTable;
+ +void EventLooper_Update(EventLooper *self);
+ + +
+bool EventLooper_Create(EventLooper *self) {
+ char eventStart = (self->settings >> 24) & 0xFF;
+ char eventEnd = (self->settings >> 16) & 0xFF;
+ + // Putting all the events into the flag + int i; + u64 q = (u64)0; + for(i=eventStart;i<(eventEnd+1);i++) + { + q = q | ((u64)1 << (i - 1)); + } + + self->eventFlag = q;
+ + self->delay = (((self->settings) & 0xFF) + 1) * 10;
+ self->delayCount = 0;
+ + char tmpEvent= (self->settings >> 8) & 0xFF;
+ if (tmpEvent == 0) + { + self->eventActive = (u64)0xFFFFFFFFFFFFFFFF; + } + else + { + self->eventActive = (u64)1 << (tmpEvent - 1);
+ + } + + + if (EventTable->events & self->eventActive) + {
+ u64 evState = (u64)1 << (eventStart - 1); + EventTable->events = EventTable->events | evState; + } + + EventLooper_Update(self);
+
+ return true;
+}
+
+bool EventLooper_Execute(EventLooper *self) {
+ EventLooper_Update(self);
+ return true;
+}
+
+ +void EventLooper_Update(EventLooper *self) {
+ + if ((EventTable->events & self->eventActive) == 0) + return; + + // Waiting for the right moment + if (self->delayCount < self->delay) + { +// OSReport("Delaying: %d / %d\n", self->delayCount, self->delay);
+ + self->delayCount = self->delayCount + 1; + return; + } + + // Reset the delay + self->delayCount = 0; + + // Find which event(s) is/are on + u64 evState = EventTable->events & self->eventFlag;
+ + // Turn off the old events + EventTable->events = EventTable->events & (~self->eventFlag); + + // Shift them right if they can, if not, reset! + evState = evState << 1; + if (evState < self->eventFlag) + { + EventTable->events = EventTable->events | evState; + } + + else + { + char eventStart = (self->settings >> 24) & 0xFF;
+ evState = (u64)1 << (eventStart - 1); + EventTable->events = EventTable->events | evState; + } + + +} diff --git a/src/growup.s b/src/growup.s index 903b766..f1cff50 100644 --- a/src/growup.s +++ b/src/growup.s @@ -6,7 +6,8 @@ .set r20,20; .set r21,21; .set r22,22; .set r23,23; .set r24,24
.set r25,25; .set r26,26; .set r27,27; .set r28,28; .set r29,29
.set r30,30; .set r31,31; .set f0,0; .set f1,1; .set f2,2 -.set f3,3; .set f4,4; .set f5,5; .set f8,8;
+.set f3,3; .set f4,4; .set f5,5; .set f6,6; .set f8,8 +.set f31,31; .set f30,30
#endif
@@ -18,94 +19,468 @@ .align 4 -.global ModifyGlobalSizes -ModifyGlobalSizes: -# lhz r10, 8(r3) -# cmpwi r10, 60 -# beq dontDoAnything +LoadFromSettingsS: + # we can trash r12 for now, it's not supposed to be guaranteed anyway + lwz r12, 4(r3) # get the sprite settings + srwi r12, r12, 20 # get the highest nybble as r10 (maps to Nyb7 in Reggie) + andi. r12, r12, 0xF
- # we can trash r10 for now, it's not supposed to be guaranteed anyway - lwz r10, 4(r3) # get the sprite settings - srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) - andi. r10, r10, 0xF
+ # first off, get the value from the lookup table + lis r11, LookupTable@h + ori r11, r11, LookupTable@l + slwi r12, r12, 2 # size *= 4 (size of float) + lfsx f8, r11, r12 # get it from the array + blr + + +LoadFromSettingsSF: + # we can trash r12 for now, it's not supposed to be guaranteed anyway + lwz r12, 4(r3) # get the sprite settings + srwi r12, r12, 28 # get the highest nybble as r12 (maps to Nyb5 in Reggie) + andi. r12, r12, 0xF
# first off, get the value from the lookup table lis r11, LookupTable@h ori r11, r11, LookupTable@l - slwi r10, r10, 2 # size *= 4 (size of float) - lfsx f5, r11, r10 # get it from the array + slwi r12, r12, 2 # size *= 4 (size of float) + lfsx f8, r11, r12 # get it from the array + blr + + +LoadFromSettingsC: + # we can trash r12 for now, it's not supposed to be guaranteed anyway + lwz r12, 4(r4) # get the sprite settings + srwi r12, r12, 20 # get the highest nybble as r12 (maps to Nyb7 in Reggie) + andi. r12, r12, 0xF
+ + # first off, get the value from the lookup table + lis r11, LookupTable@h + ori r11, r11, LookupTable@l + slwi r12, r12, 2 # size *= 4 (size of float) + lfsx f8, r11, r12 # get it from the array + blr + + +LoadFromSettingsCF: + # we can trash r12 for now, it's not supposed to be guaranteed anyway + lwz r12, 4(r4) # get the sprite settings + srwi r12, r12, 28 # get the highest nybble as r12 (maps to Nyb5 in Reggie) + andi. r12, r12, 0xF
+ + # first off, get the value from the lookup table + lis r11, LookupTable@h + ori r11, r11, LookupTable@l + slwi r12, r12, 2 # size *= 4 (size of float) + lfsx f8, r11, r12 # get it from the array + blr + + +LoadFromSettingsH: + # we can trash r12 for now, it's not supposed to be guaranteed anyway + lwz r12, 4(r30) # get the sprite settings + srwi r12, r12, 20 # get the highest nybble as r12 (maps to Nyb7 in Reggie) + andi. r12, r12, 0xF
+ + # first off, get the value from the lookup table + lis r11, RiderLookupTable@h + ori r11, r11, RiderLookupTable@l + slwi r12, r12, 2 # size *= 4 (size of float) + lfsx f8, r11, r12 # get it from the array + blr + + +LoadFromSettingsHF: + # we can trash r12 for now, it's not supposed to be guaranteed anyway + lwz r12, 4(r30) # get the sprite settings + srwi r12, r12, 28 # get the highest nybble as r12 (maps to Nyb5 in Reggie) + andi. r12, r12, 0xF
+ + # first off, get the value from the lookup table + lis r11, RiderLookupTable@h + ori r11, r11, RiderLookupTable@l + slwi r12, r12, 2 # size *= 4 (size of float) + lfsx f8, r11, r12 # get it from the array + blr + + +LoadFromSettingsL: + # we can trash r12 for now, it's not supposed to be guaranteed anyway + lwz r12, 8(r30) # get the sprite settings + srwi r12, r12, 20 # get the highest nybble as r12 (maps to Nyb7 in Reggie) + andi. r12, r12, 0xF
+ + # first off, get the value from the lookup table + lis r11, LookupTable@h + ori r11, r11, LookupTable@l + slwi r12, r12, 2 # size *= 4 (size of float) + lfsx f8, r11, r12 # get it from the array + blr + + +LoadFromSettingsLF: + # we can trash r12 for now, it's not supposed to be guaranteed anyway + lwz r12, 8(r30) # get the sprite settings + srwi r12, r12, 28 # get the highest nybble as r12 (maps to Nyb5 in Reggie) + andi. r12, r12, 0xF
+ + # first off, get the value from the lookup table + lis r11, LookupTable@h + ori r11, r11, LookupTable@l + slwi r12, r12, 2 # size *= 4 (size of float) + lfsx f8, r11, r12 # get it from the array + blr + + + +ModelNoChanges: + lwz r4, 0x47C(r3) + lfs f0, 0xDC(r4) + stfs f0, 0x464(r3) + lfs f0, 0xE0(r4) + stfs f0, 0x468(r3) + lfs f0, 0xE4(r4) + stfs f0, 0x46C(r3) + blr + + +.global ModifyGlobalSizes +ModifyGlobalSizes: + + # Go back if SizerOn is 0 (off) + lis r10, SizerOn@h + ori r10, r10, SizerOn@l + lbz r10, 0(r10) + cmpwi r10, 0 + beq ModelNoChanges + + # Else, use Global + lis r11, GlobalSpriteSize@h + ori r11, r11, GlobalSpriteSize@l + lfs f8, 0(r11) + + mflr r9 + + # Load from Nyb5 Settings if SizerOn is 1 + cmpwi r10, 1 + beql LoadFromSettingsSF + + # Load from Nyb7 Settings if SizerOn is 2 + cmpwi r10, 2 + beql LoadFromSettingsS + + mtlr r9 # Modify the actor lwz r4, 0x47C(r3) lfs f0, 0xDC(r4) - fmuls f0, f0, f5 + fmuls f0, f0, f8 stfs f0, 0xDC(r3) - stfs f0, 0x464(r4) + stfs f0, 0x464(r3) lfs f0, 0xE0(r4) - fmuls f0, f0, f5 + fmuls f0, f0, f8 stfs f0, 0xE0(r3) - stfs f0, 0x468(r4) + stfs f0, 0x468(r3) lfs f0, 0xE4(r4) - fmuls f0, f0, f5 + fmuls f0, f0, f8 stfs f0, 0xE4(r3) - stfs f0, 0x46C(r4) + stfs f0, 0x46C(r3) + + blr + + +# Another one to try at 80095750 +SpeedUpdatesNoChangesB: + lfs f3, 0xC(r1) + lfs f1, 0x440(r30) + lfs f2, 0x10(r1) + fadds f6, f3, f1 + lfs f0, 0x444(r30) + lfs f4, 0x14(r1) + fadds f5, f2, f0 + lfs f3, 0x448(r30) + lfs f1, 0xAC(r30) #Actor.x_pos + fadds f3, f4, f3 + lfs f0, 0xB0(r30) #Actor.y_pos + fadds f2, f1, f6 + fadds f1, f0, f5 + lfs f0, 0xB4(r30) #Actor.z_pos + stfs f2, 0xAC(r30) #Actor.x_pos + fadds f0, f0, f3 + stfs f1, 0xB0(r30) #Actor.y_pos + stfs f0, 0xB4(r30) #Actor.z_pos + psq_l f31, 0x38(r1), 1, 0 + lfd f31, 0x30(r1) + psq_l f30, 0x28(r1), 1, 0 + lfd f30, 0x20(r1) + lwz r31, 0x1C(r1) + lwz r30, 0x18(r1) + lwz r0, 0x44(r1) + stfs f6, 0xC(r1) + stfs f5, 0x10(r1) + stfs f3, 0x14(r1) + mtlr r0 + addi r1, r1, 0x40 + blr + + +.global ModifySpeedUpdatesB +ModifySpeedUpdatesB: + + # Go back if Type is a Player, Yoshi, or World Map Shit + lhz r10, 8(r30) + cmpwi r10, 0x12 + blt SpeedUpdatesNoChangesB + + # Go back if SizerOn is 0 (off) + lis r10, SizerOn@h + ori r10, r10, SizerOn@l + lbz r10, 0(r10) + cmpwi r10, 0 + beq SpeedUpdatesNoChangesB + + # Else, use Global + lis r11, GlobalSpriteSpeed@h + ori r11, r11, GlobalSpriteSpeed@l + lfs f8, 0(r11) + + mflr r9 + + # Load from Nyb5 Settings if SizerOn is 1 + cmpwi r10, 1 + beql LoadFromSettingsHF + + # Load from Nyb7 Settings if SizerOn is 2 + cmpwi r10, 2 + beql LoadFromSettingsH + + mtlr r9 + + + lfs f3, 0xC(r1) + lfs f1, 0x440(r30) + lfs f2, 0x10(r1) + fadds f6, f3, f1 + lfs f0, 0x444(r30) + lfs f4, 0x14(r1) + fadds f5, f2, f0 + lfs f3, 0x448(r30) + lfs f1, 0xAC(r30) #Actor.x_pos + fadds f3, f4, f3 + lfs f0, 0xB0(r30) #Actor.y_pos + fmuls f6, f8, f6 + fadds f2, f1, f6 + fmuls f5, f8, f5 + fadds f1, f0, f5 + lfs f0, 0xB4(r30) #Actor.z_pos + stfs f2, 0xAC(r30) #Actor.x_pos + fmuls f3, f8, f3 + fadds f0, f0, f3 + stfs f1, 0xB0(r30) #Actor.y_pos + stfs f0, 0xB4(r30) #Actor.z_pos + psq_l f31, 0x38(r1), 1, 0 + lfd f31, 0x30(r1) + psq_l f30, 0x28(r1), 1, 0 + lfd f30, 0x20(r1) + lwz r31, 0x1C(r1) + lwz r30, 0x18(r1) + lwz r0, 0x44(r1) + stfs f6, 0xC(r1) + stfs f5, 0x10(r1) + stfs f3, 0x14(r1) + mtlr r0 + addi r1, r1, 0x40 + blr + + + +# dStageActor_positionRelated: 80065620 +SpeedUpdatesNoChangesA: + lfs f3, 0xB0(r4) + lfs f2, 0xD4(r4) + lfs f1, 0xAC(r4) + lfs f0, 0xD0(r4) + fadds f2, f3, f2 + fadds f0, f1, f0 + stfs f2, 4(r3) + stfs f0, 0(r3) + blr + + +.global ModifySpeedUpdatesA +ModifySpeedUpdatesA: + + # Go back if Type is a Player, Yoshi, or World Map Shit + lhz r10, 8(r4) + cmpwi r10, 0x12 + blt SpeedUpdatesNoChangesA + + # Go back if SizerOn is 0 (off) + lis r10, SizerOn@h + ori r10, r10, SizerOn@l + lbz r10, 0(r10) + cmpwi r10, 0 + beq SpeedUpdatesNoChangesA + + # Else, use Global + lis r11, GlobalSpriteSize@h + ori r11, r11, GlobalSpriteSize@l + lfs f8, 0(r11) + + mflr r9 + + # Load from Nyb5 Settings if SizerOn is 1 + cmpwi r10, 1 + beql LoadFromSettingsCF + + # Load from Nyb7 Settings if SizerOn is 2 + cmpwi r10, 2 + beql LoadFromSettingsC + + mtlr r9 + + lfs f3, 0xB0(r4) + lfs f2, 0xD4(r4) + lfs f1, 0xAC(r4) + lfs f0, 0xD0(r4) + fmuls f2, f8, f2 + fadds f2, f3, f2 + fmuls f0, f8, f0 + fadds f0, f1, f0 + stfs f2, 4(r3) + stfs f0, 0(r3) + blr - # Modify the initial actor speeds -# lfs f0, 0xD0(r3) -# fmuls f0, f0, f5 -# stfs f0, 0xD0(r3) + +#SpeedUpdatesNoChanges: +# # Xpos +# lfs f1, 0xAC(r3) +# lfs f0, 0(r4) +# fadds f0, f1, f0 +# stfs f0, 0xAC(r3) +# # Ypos +# lfs f1, 0xB0(r3) +# lfs f0, 4(r4) +# fadds f0, f1, f0 +# stfs f0, 0xB0(r3) +# # Zpos +# lfs f1, 0xB4(r3) +# lfs f0, 8(r4) +# fadds f0, f1, f0 +# stfs f0, 0xB4(r3) +# blr +# # -# lfs f0, 0xE8(r3) -# fmuls f0, f0, f5 -# stfs f0, 0xE8(r3) +#.global ModifySpeedUpdates +#ModifySpeedUpdates: # -# lfs f0, 0xC4(r3) -# fmuls f0, f0, f5 -# stfs f0, 0xC4(r3) +# # Go back if Type is a Player, Yoshi, or World Map Shit +# lhz r10, 8(r3) +# cmpwi r10, 0x12 +# blt SpeedUpdatesNoChanges # -# lfs f0, 0x110(r3) -# fmuls f0, f0, f5 -# stfs f0, 0x110(r3) +# # Go back if SizerOn is 0 (off) +# lis r10, SizerOn@h +# ori r10, r10, SizerOn@l +# lbz r10, 0(r10) +# cmpwi r10, 0 +# beq SpeedUpdatesNoChanges # -# lfs f0, 0xF4(r3) -# fmuls f0, f0, f5 -# stfs f0, 0xF4(r3) -# -# lfs f0, 0x11C(r3) -# fmuls f0, f0, f5 -# stfs f0, 0x11C(r3) +# # Else, use Global +# lis r11, GlobalSpriteSize@h +# ori r11, r11, GlobalSpriteSize@l +# lfs f8, 0(r11) +# +# mflr r9 +# +# # Load from Nyb5 Settings if SizerOn is 1 +# cmpwi r10, 1 +# beql LoadFromSettingsSF +# +# # Load from Nyb7 Settings if SizerOn is 2 +# cmpwi r10, 2 +# beql LoadFromSettingsS +# +# mtlr r9 # -# lfs f0, 0x108(r3) -# fmuls f0, f0, f5 -# stfs f0, 0x108(r3) +# # Xpos +# lfs f1, 0xAC(r3) +# lfs f0, 0(r4) +# fmuls f0, f8, f0 +# fadds f0, f1, f0 +# stfs f0, 0xAC(r3) +# # Ypos +# lfs f1, 0xB0(r3) +# lfs f0, 4(r4) +# fmuls f0, f8, f0 +# fadds f0, f1, f0 +# stfs f0, 0xB0(r3) +# # Zpos +# lfs f1, 0xB4(r3) +# lfs f0, 8(r4) +# fmuls f0, f8, f0 +# fadds f0, f1, f0 +# stfs f0, 0xB4(r3) +# blr - blr +CollisionNoChanges: + stw r4, 4(r3) + li r0, 0 + lfs f0, 0(r5) + stfs f0, 0x1C(r3) + lfs f0, 4(r5) + stfs f0, 0x20(r3) + lfs f0, 8(r5) + stfs f0, 0x24(r3) + lfs f0, 0xC(r5) + stfs f0, 0x28(r3) + lbz r4, 0x10(r5) + stb r4, 0x2C(r3) + lbz r4, 0x11(r5) + stb r4, 0x2D(r3) + lwz r4, 0x14(r5) + stw r4, 0x30(r3) + lwz r4, 0x18(r5) + stw r4, 0x34(r3) + lhz r4, 0x1C(r5) + sth r4, 0x38(r3) + lwz r4, 0x20(r5) + stw r4, 0x3C(r3) + stb r0, 0xA1(r3) + blr -#dontDoAnything: -# blr +.global ModifyCollision +ModifyCollision: + # Go back if SizerOn is 0 (off) + lis r10, SizerOn@h + ori r10, r10, SizerOn@l + lbz r10, 0(r10) + cmpwi r10, 0 + beq CollisionNoChanges + # Else, use Global + lis r11, GlobalSpriteSize@h + ori r11, r11, GlobalSpriteSize@l + lfs f8, 0(r11) -.global ModifyCollision -ModifyCollision: + mflr r9 - # we can trash r10 for now, it's not supposed to be guaranteed anyway - lwz r10, 4(r4) # get the sprite settings - srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) - andi. r10, r10, 0xF
+ # Load from Nyb5 Settings if SizerOn is 1 + cmpwi r10, 1 + beql LoadFromSettingsCF - # first off, get the value from the lookup table - lis r11, LookupTable@h - ori r11, r11, LookupTable@l - slwi r10, r10, 2 # size *= 4 (size of float) - lfsx f8, r11, r10 # get it from the array + # Load from Nyb7 Settings if SizerOn is 2 + cmpwi r10, 2 + beql LoadFromSettingsC + + mtlr r9 #This is the old ActivePhysics_InitWithStruct function. stw r4, 4(r3) @@ -153,7 +528,8 @@ ModifyCollision: ModifyStandOnTopInitA: # we can trash r10 for now, it's not supposed to be guaranteed anyway - lwz r10, 4(r4) # get the sprite settings + lwz r10, 4(r3) + lwz r10, 4(r10) # get the sprite settings srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) andi. r10, r10, 0xF
@@ -183,7 +559,8 @@ ModifyStandOnTopInitA: ModifyStandOnTopInitB: # we can trash r10 for now, it's not supposed to be guaranteed anyway - lwz r10, 4(r4) # get the sprite settings + lwz r10, 4(r3) + lwz r10, 4(r10) # get the sprite settings srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) andi. r10, r10, 0xF
@@ -238,7 +615,8 @@ ModifyStandOnTopInitD: # we can trash r10 for now, it's not supposed to be guaranteed anyway - lwz r10, 4(r4) # get the sprite settings + lwz r10, 4(r3) + lwz r10, 4(r10) # get the sprite settings srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) andi. r10, r10, 0xF
@@ -278,20 +656,43 @@ ModifyStandOnTopInitD: blr # Off we go! +RiderInitANoChanges: + lfs f0, 0(r4) + stfs f0, 0x4C(r3) + lfs f0, 4(r4) + stfs f0, 0x50(r3) + lfs f0, 0(r5) + stfs f0, 0x54(r3) + lfs f0, 4(r5) + stfs f0, 0x58(r3) + blr .global ModifyRiderInitA ModifyRiderInitA: - # we can trash r10 for now, it's not supposed to be guaranteed anyway - lwz r10, 4(r4) # get the sprite settings - srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) - andi. r10, r10, 0xF
+ # Go back if SizerOn is 0 (off) + lis r10, SizerOn@h + ori r10, r10, SizerOn@l + lbz r10, 0(r10) + cmpwi r10, 0 + beq RiderInitANoChanges - # first off, get the value from the lookup table - lis r11, RiderLookupTable@h - ori r11, r11, RiderLookupTable@l - slwi r10, r10, 2 # size *= 4 (size of float) - lfsx f8, r11, r10 # get it from the array + # Else, use Global + lis r11, GlobalSpriteSize@h + ori r11, r11, GlobalSpriteSize@l + lfs f8, 0(r11) + + mflr r9 + + # Load from Nyb5 Settings if SizerOn is 1 + cmpwi r10, 1 + beql LoadFromSettingsSF + + # Load from Nyb7 Settings if SizerOn is 2 + cmpwi r10, 2 + beql LoadFromSettingsS + + mtlr r9 lfs f0, 0(r4) fmuls f0, f0, f8 @@ -312,19 +713,44 @@ ModifyRiderInitA: blr # Off we go! +RiderInitBNoChanges: + lfs f0, 0(r5) + stfs f0, 0x4C(r3) + lfs f0, 4(r5) + stfs f0, 0x50(r3) + lfs f0, 0(r4) + stfs f0, 0x54(r3) + lfs f0, 4(r4) + stfs f0, 0x58(r3) + blr + + .global ModifyRiderInitB ModifyRiderInitB: - # we can trash r10 for now, it's not supposed to be guaranteed anyway - lwz r10, 4(r4) # get the sprite settings - srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) - andi. r10, r10, 0xF
+ # Go back if SizerOn is 0 (off) + lis r10, SizerOn@h + ori r10, r10, SizerOn@l + lbz r10, 0(r10) + cmpwi r10, 0 + beq RiderInitBNoChanges - # first off, get the value from the lookup table - lis r11, RiderLookupTable@h - ori r11, r11, RiderLookupTable@l - slwi r10, r10, 2 # size *= 4 (size of float) - lfsx f8, r11, r10 # get it from the array + # Else, use Global + lis r11, GlobalSpriteSize@h + ori r11, r11, GlobalSpriteSize@l + lfs f8, 0(r11) + + mflr r9 + + # Load from Nyb5 Settings if SizerOn is 1 + cmpwi r10, 1 + beql LoadFromSettingsSF + + # Load from Nyb7 Settings if SizerOn is 2 + cmpwi r10, 2 + beql LoadFromSettingsS + + mtlr r9 lfs f0, 0(r5) fmuls f0, f0, f8 @@ -346,19 +772,39 @@ ModifyRiderInitB: +RiderInitCNoChanges: + stfs f1, 0x4C(r3) + stfs f2, 0x50(r3) + stfs f3, 0x54(r3) + stfs f4, 0x58(r3) + blr + .global ModifyRiderInitC ModifyRiderInitC: - # we can trash r10 for now, it's not supposed to be guaranteed anyway - lwz r10, 4(r4) # get the sprite settings - srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) - andi. r10, r10, 0xF
+ # Go back if SizerOn is 0 (off) + lis r10, SizerOn@h + ori r10, r10, SizerOn@l + lbz r10, 0(r10) + cmpwi r10, 0 + beq RiderInitCNoChanges - # first off, get the value from the lookup table - lis r11, RiderLookupTable@h - ori r11, r11, RiderLookupTable@l - slwi r10, r10, 2 # size *= 4 (size of float) - lfsx f8, r11, r10 # get it from the array + # Else, use Global + lis r11, GlobalSpriteSize@h + ori r11, r11, GlobalSpriteSize@l + lfs f8, 0(r11) + + mflr r9 + + # Load from Nyb5 Settings if SizerOn is 1 + cmpwi r10, 1 + beql LoadFromSettingsSF + + # Load from Nyb7 Settings if SizerOn is 2 + cmpwi r10, 2 + beql LoadFromSettingsS + + mtlr r9 fmuls f1, f1, f8 fmuls f2, f2, f8 @@ -373,19 +819,41 @@ ModifyRiderInitC: blr # Off we go! + +RiderInitDNoChanges: + stfs f3, 0x4C(r3) + stfs f4, 0x50(r3) + stfs f1, 0x54(r3) + stfs f2, 0x58(r3) + blr + + .global ModifyRiderInitD ModifyRiderInitD: - # we can trash r10 for now, it's not supposed to be guaranteed anyway - lwz r10, 4(r4) # get the sprite settings - srwi r10, r10, 20 # get the highest nybble as r10 (maps to Nyb5 in Reggie) - andi. r10, r10, 0xF
+ # Go back if SizerOn is 0 (off) + lis r10, SizerOn@h + ori r10, r10, SizerOn@l + lbz r10, 0(r10) + cmpwi r10, 0 + beq RiderInitDNoChanges - # first off, get the value from the lookup table - lis r11, RiderLookupTable@h - ori r11, r11, RiderLookupTable@l - slwi r10, r10, 2 # size *= 4 (size of float) - lfsx f8, r11, r10 # get it from the array + # Else, use Global + lis r11, GlobalSpriteSize@h + ori r11, r11, GlobalSpriteSize@l + lfs f8, 0(r11) + + mflr r9 + + # Load from Nyb5 Settings if SizerOn is 1 + cmpwi r10, 1 + beql LoadFromSettingsSF + + # Load from Nyb7 Settings if SizerOn is 2 + cmpwi r10, 2 + beql LoadFromSettingsS + + mtlr r9 fmuls f1, f1, f8 fmuls f2, f2, f8 @@ -401,73 +869,199 @@ ModifyRiderInitD: -.global InheritSettings_A -InheritSettings_A: +.global InheritSettings +InheritSettings: - li r4, 0 + lwz r4, 4(r3) + andis. r4, r4, 0xFFF0 blr - lwz r4, 4(r0) - - li r10, 0 - stw r10, 8(r4) - - blr - .global InheritSettings_B InheritSettings_B: - li r4, 0 - blr - - or r4, r31, r0 - lwz r10, 4(r28) - or r4, r10, r4 - + lwz r5, 4(r3) blr .global InheritSettings_C InheritSettings_C: - li r4, 0 - blr - - or r4, r8, r18 - lwz r10, 4(r27) - or r4, r10, r4 - + lwz r4, 4(r3) + andis. r4, r4, 0xFFF0 blr - .global InheritSettings_D InheritSettings_D: - li r4, 0 + ori r4, r4, 0x2 blr - lwz r4, 4(r3) - li r10, 0 - stw r10, 8(r4) - mr r11, r4 - + + +.global AlwaysVisible +AlwaysVisible: + + li r3, 1 blr -.global InheritSettings_E -InheritSettings_E: - li r4, 0 + + +ModifyLoadSizeNoChanges: + lhz r0, 0(r30) + cmpwi r17, 0 + lhz r3, 2(r30) + li r28, 0 + mulli r4, r0, 0x28 + lwz r0, 0x24(r1) + lhz r7, 4(r30) + add r31, r0, r4 + lwz r0, 0xC(r31) + lwz r6, 0x14(r31) + li r6, 12800 + add r3, r3, r0 + lwz r8, 0x10(r31) + subf r0, r6, r3 + lhz r4, 0x20(r31) + li r4, 12800 + add r3, r3, r6 + lhz r5, 0x22(r31) + li r5, 12800 + subf r6, r4, r0 + lwz r9, 0x18(r31) + subf r7, r8, r7 + add r5, r5, r3 + srawi r26, r6, 4 + lhz r4, 0x1C(r31) + subf r0, r9, r7 + srawi r25, r5, 4 + subf r4, r4, r0 + lhz r3, 0x1E(r31) + add r0, r7, r9 + mr r27, r25 + srawi r23, r4, 4 + add r0, r3, r0 + srawi r22, r0, 4 blr - mr r4, r11 +.global ModifyLoadSize +ModifyLoadSize: + + mflr r9 + # Go back if SizerOn is 0 (off) + lis r10, SizerOn@ha + lbz r10, SizerOn@l(r10) + cmpwi r10, 0 + b ModifyLoadSizeNoChanges + + # Else, use Global + lis r11, GlobalSpriteSize@h + ori r11, r11, GlobalSpriteSize@l + lfs f8, 0(r11) + + # Load from Nyb5 Settings if SizerOn is 1 + cmpwi r10, 1 + beql LoadFromSettingsLF + + # Load from Nyb7 Settings if SizerOn is 2 + cmpwi r10, 2 + beql LoadFromSettingsL + + lhz r0, 0(r30) + cmpwi r17, 0 + lhz r3, 2(r30) + li r28, 0 + mulli r4, r0, 0x28 + lwz r0, 0x24(r1) + lhz r7, 4(r30) + add r31, r0, r4 + + lwz r12, 0xC(r31) + bl ConverterFunc + mr r0, r12 + li r0, 12800 + + lwz r12, 0x14(r31) + bl ConverterFunc + mr r6, r12 + li r6, 12800 + + add r3, r3, r0 + + lwz r12, 0x10(r31) + bl ConverterFunc + mr r8, r12 + li r8, 12800 + + subf r0, r6, r3 + + lhz r12, 0x20(r31) + bl ConverterFunc + mr r4, r12 + li r4, 12800 + + add r3, r3, r6 + + lhz r12, 0x22(r31) + bl ConverterFunc + mr r5, r12 + li r5, 12800 + + subf r6, r4, r0 + + lwz r12, 0x18(r31) + bl ConverterFunc + mr r9, r12 + li r9, 12800 + + subf r7, r8, r7 + add r5, r5, r3 + srawi r26, r6, 4 + + lhz r12, 0x1C(r31) + bl ConverterFunc + mr r4, r12 + li r4, 12800 + + subf r0, r9, r7 + srawi r25, r5, 4 + subf r4, r4, r0 + + lhz r12, 0x1E(r31) + bl ConverterFunc + mr r3, r12 + li r3, 12800 + + add r0, r7, r9 + mr r27, r25 + srawi r23, r4, 4 + add r0, r3, r0 + srawi r22, r0, 4 + + mtlr r9 blr +ConverterFunc: + # Converts an int to a float + lis r10, ConvertFloat@h + ori r10, r10, ConvertFloat@l + xoris r12,r12,0x8000 + stw r12, 4(r10) + lfd f0, 0(r10) + lfd f1, 8(r10) + fsub f0, f0, f1 + fmuls f0, f0, f8 + # Converts a float to an int + fctiw f0, f1 + stfd f0, 0(r12) + lwz r12, 4(r12) + blr @@ -500,6 +1094,7 @@ PiranhaFirePos: + .global PipeGeneratorSpawn PipeGeneratorSpawn: @@ -520,6 +1115,25 @@ LakituBomb: .data + +.global GlobalSpriteSize +GlobalSpriteSize: + .float 1.0 + +.global GlobalSpriteSpeed +GlobalSpriteSpeed: + .float 1.0 + +.global GlobalRiderSize +GlobalRiderSize: + .float 1.0 + +.global SizerOn +SizerOn: + .byte 0 + +.align 4 + LookupTable: .float 1, 1, 1, 1, 0.25, 0.5, 0.75, 1.25, 1.5, 2, 2.5, 3, 4, 5, 8, 10 @@ -529,7 +1143,10 @@ RiderLookupTable: PiranhaPosF: .float 4.0 - +ConvertFloat: + .word 0x43300000,0x0,0x43300000,0x80000000 + + Stupid: .string "Fucking Sprite was enlarged by %f times\n" .align 4 diff --git a/src/levelspecial.cpp b/src/levelspecial.cpp index 245dc87..5fd900d 100644 --- a/src/levelspecial.cpp +++ b/src/levelspecial.cpp @@ -28,6 +28,8 @@ extern EventTable_t *EventTable; extern u16 TimeStopFlag; extern u32 TimerBranch; +extern u32 AlwaysDrawFlag; +extern u32 AlwaysDrawBranch; extern float MarioDescentRate; extern float MarioJumpMax; @@ -35,6 +37,16 @@ extern float MarioJumpArc; extern float MiniMarioJumpArc; extern float MarioSize; +extern float GlobalSpriteSize; +extern float GlobalSpriteSpeed; +extern float GlobalRiderSize; +extern char SizerOn; + + +float GlobalSizeFloatModifications [] = {1, 0.25, 0.5, 0.75, 1.25, 1.5, 1.75, 2, 2.5, 3, 4, 5, 6, 7, 8, 10 }; +float GlobalRiderFloatModifications [] = {1, 0.6, 0.7, 0.9, 1, 1, 1, 1.1, 1.25, 1.5, 2, 2.5, 3, 3.5, 4, 5}; + + extern "C" void GetSpecificPlayerActor(int number); void LevelSpecial_Update(LevelSpecial *self);
@@ -55,6 +67,12 @@ bool ResetAfterLevel(void) { MarioJumpArc = 2.5; MiniMarioJumpArc = 2.5; MarioSize = 1.0; + GlobalSpriteSize = 1.0; + GlobalSpriteSpeed = 1.0; + GlobalRiderSize = 1.0; + SizerOn = 0; + AlwaysDrawFlag = 0x9421FFF0; + AlwaysDrawBranch = 0x7C0802A6; return true;
}
@@ -133,6 +151,33 @@ void LevelSpecial_Update(LevelSpecial *self) { else //Half-Pint MarioSize = 0.25; break; + + + case 5: // Global Enemy Size + SizerOn = 3; + + GlobalSpriteSize = GlobalSizeFloatModifications[self->effect]; + GlobalRiderSize = GlobalRiderFloatModifications[self->effect]; + GlobalSpriteSpeed = GlobalRiderFloatModifications[self->effect]; + + AlwaysDrawFlag = 0x38600001; + AlwaysDrawBranch = 0x4E800020; + break; + + case 6: // Individual Enemy Size + AlwaysDrawFlag = 0x38600001; + AlwaysDrawBranch = 0x4E800020; + + if (self->effect == 0) + { + SizerOn = 1; // Nyb 5 + } + else + { + SizerOn = 2; // Nyb 7 + } + break; + default: break; @@ -165,6 +210,24 @@ void LevelSpecial_Update(LevelSpecial *self) { MarioSize = 1.0; break; + case 5: // Global Enemy Size + SizerOn = 0; + + GlobalSpriteSize = 1.0; + GlobalRiderSize = 1.0; + GlobalSpriteSpeed = 1.0; + + AlwaysDrawFlag = 0x9421FFF0; + AlwaysDrawBranch = 0x7C0802A6; + break; + + case 6: // Individual Enemy Size + SizerOn = 0; + + AlwaysDrawFlag = 0x9421FFF0; + AlwaysDrawBranch = 0x7C0802A6; + break; + default: break; } @@ -178,8 +241,4 @@ void LevelSpecial_Update(LevelSpecial *self) { self->lastEvState = newEvState;
-}
- -
- - +} diff --git a/src/spritetex.S b/src/spritetex.S index 0f89cd5..0336a5c 100644 --- a/src/spritetex.S +++ b/src/spritetex.S @@ -80,6 +80,14 @@ TEX_Goomba: srwi r5, r5, 24
andi. r5, r5, 0xF
b GetTexFilenameForR5
+ + +.global TEX_BigGoomba
+TEX_BigGoomba:
+ lwz r5, 4(r30)
+ srwi r5, r5, 24
+ andi. r5, r5, 0xF
+ b GetTexFilenameForR5
.global TEX_Barrel
@@ -171,7 +179,7 @@ TEX_SpringBlock: .global TEX_Coaster
TEX_Coaster:
- lwz r5, 4(r31)
+ lwz r5, 4(r3)
srwi r5, r5, 24
andi. r5, r5, 0xF
b GetTexFilenameForR5
@@ -395,8 +403,13 @@ TEX_PokeyB: srwi r5, r5, 24
andi. r5, r5, 0xF
b GetTexFilenameForR5
+ -
+.global TEX_PokeyC
+TEX_PokeyC:
+ lwz r5, 4(r30) + or r5, r5, r31
+ blr
|