summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorColin Noga <Tempus@Spectrum-Song.local>2011-06-19 03:32:22 -0500
committerColin Noga <Tempus@Spectrum-Song.local>2011-06-19 03:32:22 -0500
commit8b4c5e87a0a407246d5ee37684105e72283687a5 (patch)
tree687a5e9a872c23a6730b938cc43f77aac4b42e0b /src
parentfe5ff40e8e6ab1cdc83df3263d3d16830e4ff18f (diff)
downloadkamek-8b4c5e87a0a407246d5ee37684105e72283687a5.tar.gz
kamek-8b4c5e87a0a407246d5ee37684105e72283687a5.zip
Added all latest fixes for textures, event looper, and sprite spawner, plus some other odds and ends
Diffstat (limited to 'src')
-rw-r--r--src/spritespawner.cpp101
-rw-r--r--src/spritetex.S317
2 files changed, 411 insertions, 7 deletions
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