diff options
Diffstat (limited to '')
-rw-r--r-- | src/animtiles.cpp | 122 | ||||
-rw-r--r-- | src/crowdclapper.s | 39 | ||||
-rw-r--r-- | src/eventlooper.cpp | 102 | ||||
-rw-r--r-- | src/fileload.cpp | 268 | ||||
-rw-r--r-- | src/fileload.h | 148 | ||||
-rw-r--r-- | src/gakenoko.S | 440 | ||||
-rwxr-xr-x | src/growup.s | 40 | ||||
-rw-r--r-- | src/heapbar.S | 236 | ||||
-rw-r--r-- | src/heapbar.cpp | 294 | ||||
-rw-r--r-- | src/layoutlib.S | 262 | ||||
-rw-r--r-- | src/layoutlib.h | 298 | ||||
-rw-r--r-- | src/levelinfo.cpp | 72 | ||||
-rw-r--r-- | src/levelinfo.h | 112 | ||||
-rw-r--r-- | src/levelnames.cpp | 166 | ||||
-rw-r--r-- | src/levelspecial.cpp | 174 | ||||
-rw-r--r-- | src/linegod.S | 106 | ||||
-rw-r--r-- | src/linegod.cpp | 426 | ||||
-rw-r--r-- | src/msgbox.S | 74 | ||||
-rw-r--r-- | src/msgbox.cpp | 454 | ||||
-rw-r--r-- | src/poweruphax.S | 1378 | ||||
-rw-r--r-- | src/randomcrap.S | 16 | ||||
-rw-r--r-- | src/randtiles.cpp | 44 | ||||
-rw-r--r-- | src/randtiles.h | 126 | ||||
-rwxr-xr-x | src/spritespawner.cpp | 138 | ||||
-rwxr-xr-x | src/spriteswapper.cpp | 144 | ||||
-rwxr-xr-x | src/spritetex.S | 2042 | ||||
-rw-r--r-- | src/tilegod.S | 130 | ||||
-rw-r--r-- | src/worldmap.cpp | 2128 | ||||
-rw-r--r-- | src/worldmap.h | 126 |
29 files changed, 5144 insertions, 4961 deletions
diff --git a/src/animtiles.cpp b/src/animtiles.cpp index 26cdbf8..2efba16 100644 --- a/src/animtiles.cpp +++ b/src/animtiles.cpp @@ -1,61 +1,61 @@ -#include <common.h>
-#include <game.h>
-#include "fileload.h"
-
-struct AnimDef_Header {
- u32 magic;
- u32 entryCount;
-};
-
-struct AnimDef_Entry {
- u16 texNameOffset;
- u16 frameDelayOffset;
- u16 tileNum;
- u8 tilesetNum;
- u8 reverse;
-};
-
-FileHandle fh;
-
-void DoTiles(void* self) {
- //OSReport("fucker\n");
- AnimDef_Header *header;
-
- header = (AnimDef_Header*)LoadFile(&fh, "/NewerRes/AnimTiles.bin");
-
- if (!header) {
- OSReport("anim load fail\n");
- return;
- }
-
- if (header->magic != 'NWRa') {
- OSReport("anim info incorrect\n");
- FreeFile(&fh);
- return;
- }
-
- AnimDef_Entry *entries = (AnimDef_Entry*)(header+1);
-
- OSReport("Loading animated tiles\n");
-
- for (int i = 0; i < header->entryCount; i++) {
- AnimDef_Entry *entry = &entries[i];
- char *name = (char*)fh.filePtr+entry->texNameOffset;
- char *frameDelays = (char*)fh.filePtr+entry->frameDelayOffset;
-
- char realName[0x40];
- snprintf(realName, 0x40, "BG_tex/%s", name);
-
- void *blah = BgTexMng__LoadAnimTile(self, entry->tilesetNum, entry->tileNum, realName, frameDelays, entry->reverse);
-
- OSReport("[%d] %s %08x\n", i, name, blah);
- //OSReport("Returned: %08x\n", blah);
- }
-
- OSReport("Animated tiles complete\n");
-}
-
-
-void DestroyTiles(void *self) {
- FreeFile(&fh);
-}
+#include <common.h> +#include <game.h> +#include "fileload.h" + +struct AnimDef_Header { + u32 magic; + u32 entryCount; +}; + +struct AnimDef_Entry { + u16 texNameOffset; + u16 frameDelayOffset; + u16 tileNum; + u8 tilesetNum; + u8 reverse; +}; + +FileHandle fh; + +void DoTiles(void* self) { + //OSReport("fucker\n"); + AnimDef_Header *header; + + header = (AnimDef_Header*)LoadFile(&fh, "/NewerRes/AnimTiles.bin"); + + if (!header) { + OSReport("anim load fail\n"); + return; + } + + if (header->magic != 'NWRa') { + OSReport("anim info incorrect\n"); + FreeFile(&fh); + return; + } + + AnimDef_Entry *entries = (AnimDef_Entry*)(header+1); + + OSReport("Loading animated tiles\n"); + + for (int i = 0; i < header->entryCount; i++) { + AnimDef_Entry *entry = &entries[i]; + char *name = (char*)fh.filePtr+entry->texNameOffset; + char *frameDelays = (char*)fh.filePtr+entry->frameDelayOffset; + + char realName[0x40]; + snprintf(realName, 0x40, "BG_tex/%s", name); + + void *blah = BgTexMng__LoadAnimTile(self, entry->tilesetNum, entry->tileNum, realName, frameDelays, entry->reverse); + + OSReport("[%d] %s %08x\n", i, name, blah); + //OSReport("Returned: %08x\n", blah); + } + + OSReport("Animated tiles complete\n"); +} + + +void DestroyTiles(void *self) { + FreeFile(&fh); +} diff --git a/src/crowdclapper.s b/src/crowdclapper.s new file mode 100644 index 0000000..786013f --- /dev/null +++ b/src/crowdclapper.s @@ -0,0 +1,39 @@ +.extern OneofManySoundPlayers +.extern EventTable + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f2,2; .set f3,3 +#endif + +.text +.align 4 + +.global CrowdClapperEventActivate +CrowdClapperEventActivate: + + mflr r0 + bl OneofManySoundPlayers + mtlr r0 + + lis r8, EventTable@h + ori r8, r8, EventTable@l + + lwz r11, 4(r8) + + lwz r9, 4(r31) + srwi r9, r9, 24 + + subi r9, r9, 1 + + li r10, 1 + slw r10, r10, r9 + + or r11, r11, r10 + stw r11, 0(r8) + blr
\ No newline at end of file diff --git a/src/eventlooper.cpp b/src/eventlooper.cpp index 755742d..6bc0526 100644 --- a/src/eventlooper.cpp +++ b/src/eventlooper.cpp @@ -1,37 +1,37 @@ -#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;
+#include <common.h> +#include <game.h> -void EventLooper_Update(EventLooper *self);
+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; + // ... +}; -
-bool EventLooper_Create(EventLooper *self) {
- char eventStart = (self->settings >> 24) & 0xFF;
- char eventEnd = (self->settings >> 16) & 0xFF;
+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; @@ -41,41 +41,41 @@ bool EventLooper_Create(EventLooper *self) { q = q | ((u64)1 << (i - 1)); } - self->eventFlag = q;
+ self->eventFlag = q; - self->delay = (((self->settings) & 0xFF) + 1) * 10;
- self->delayCount = 0;
+ self->delay = (((self->settings) & 0xFF) + 1) * 10; + self->delayCount = 0; - char tmpEvent= (self->settings >> 8) & 0xFF;
+ char tmpEvent= (self->settings >> 8) & 0xFF; if (tmpEvent == 0) { self->eventActive = (u64)0xFFFFFFFFFFFFFFFF; } else { - self->eventActive = (u64)1 << (tmpEvent - 1);
+ 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;
-}
-
+ EventLooper_Update(self); + + return true; +} + +bool EventLooper_Execute(EventLooper *self) { + EventLooper_Update(self); + return true; +} + -void EventLooper_Update(EventLooper *self) {
+void EventLooper_Update(EventLooper *self) { if ((EventTable->events & self->eventActive) == 0) return; @@ -83,7 +83,7 @@ void EventLooper_Update(EventLooper *self) { // Waiting for the right moment if (self->delayCount < self->delay) { -// OSReport("Delaying: %d / %d\n", self->delayCount, self->delay);
+// OSReport("Delaying: %d / %d\n", self->delayCount, self->delay); self->delayCount = self->delayCount + 1; return; @@ -93,7 +93,7 @@ void EventLooper_Update(EventLooper *self) { self->delayCount = 0; // Find which event(s) is/are on - u64 evState = EventTable->events & self->eventFlag;
+ u64 evState = EventTable->events & self->eventFlag; // Turn off the old events EventTable->events = EventTable->events & (~self->eventFlag); @@ -107,7 +107,7 @@ void EventLooper_Update(EventLooper *self) { else { - char eventStart = (self->settings >> 24) & 0xFF;
+ char eventStart = (self->settings >> 24) & 0xFF; evState = (u64)1 << (eventStart - 1); EventTable->events = EventTable->events | evState; } diff --git a/src/fileload.cpp b/src/fileload.cpp index 5f60e8c..fac7576 100644 --- a/src/fileload.cpp +++ b/src/fileload.cpp @@ -1,134 +1,134 @@ -#include "fileload.h"
-
-extern "C" void UncompressBackward(void *bottom);
-
-
-void *LoadFile(FileHandle *handle, const char *name) {
- OSReport("[LoadFile %s]\n", name);
-
- int entryNum = DVDConvertPathToEntrynum(name);
-
- DVDHandle dvdhandle;
- if (!DVDFastOpen(entryNum, &dvdhandle)) {
- OSReport("Cannot open file %s [%d]\n", name, entryNum);
- return 0;
- }
-
- handle->length = dvdhandle.length;
- handle->filePtr = EGG__Heap__alloc((handle->length+0x1F) & ~0x1F, 0x20, GetArchiveHeap());
-
- int ret = DVDReadPrio(&dvdhandle, handle->filePtr, (handle->length+0x1F) & ~0x1F, 0, 2);
-
- DVDClose(&dvdhandle);
-
- OSReport("[Success %p]\n", handle->filePtr);
-
- return handle->filePtr;
-}
-
-void *LoadCompressedFile(FileHandle *handle, const char *name) {
- OSReport("[LoadCompressedFile %s]\n", name);
-
- int entryNum = DVDConvertPathToEntrynum(name);
-
- DVDHandle dvdhandle;
- if (!DVDFastOpen(entryNum, &dvdhandle)) {
- OSReport("Cannot open file %s [%d]\n", name, entryNum);
- return 0;
- }
-
- u32 infoBlock[0x20 / sizeof(u32)] __attribute__ ((aligned(32)));
- DVDReadPrio(&dvdhandle, infoBlock, 0x20, dvdhandle.length - 8, 2);
-
- // Reverse it!
- infoBlock[1] = (infoBlock[1] >> 24) | ((infoBlock[1] >> 8) & 0xFF00) | ((infoBlock[1] & 0xFF00) << 8) | ((infoBlock[1] & 0xFF) << 24);
-
- u32 uncompSize = dvdhandle.length + infoBlock[1];
- OSReport("[Comp:%d UnComp:%d]\n", dvdhandle.length, uncompSize);
- handle->length = uncompSize;
- handle->filePtr = EGG__Heap__alloc((uncompSize+0x1F) & ~0x1F, 0x20, GetArchiveHeap());
-
- int ret = DVDReadPrio(&dvdhandle, handle->filePtr, (dvdhandle.length+0x1F) & ~0x1F, 0, 2);
-
- DVDClose(&dvdhandle);
-
- UncompressBackward((void*)((u32)handle->filePtr + dvdhandle.length));
-
- OSReport("[Success %p]\n", handle->filePtr);
-
- return handle->filePtr;
-}
-
-bool FreeFile(FileHandle *handle) {
- if (!handle) return false;
-
- if (handle->filePtr) {
- OSReport("[FreeFile %p]\n", handle->filePtr);
- EGG__Heap__free(handle->filePtr, GetArchiveHeap());
- }
-
- handle->filePtr = 0;
- handle->length = 0;
-
- return true;
-}
-
-
-
-
-File::File() {
- m_loaded = false;
-}
-
-File::~File() {
- close();
-}
-
-bool File::open(const char *filename) {
- if (m_loaded)
- close();
-
- void *ret = LoadFile(&m_handle, filename);
- if (ret != 0)
- m_loaded = true;
-
- return (ret != 0);
-}
-
-bool File::openCompressed(const char *filename) {
- if (m_loaded)
- close();
-
- void *ret = LoadCompressedFile(&m_handle, filename);
- if (ret != 0)
- m_loaded = true;
-
- return (ret != 0);
-}
-
-void File::close() {
- if (!m_loaded)
- return;
-
- m_loaded = false;
- FreeFile(&m_handle);
-}
-
-bool File::isOpen() {
- return m_loaded;
-}
-
-void *File::ptr() {
- if (m_loaded)
- return m_handle.filePtr;
- else
- return 0;
-}
-
-u32 File::length() {
- if (m_loaded)
- return m_handle.length;
- else
- return 0xFFFFFFFF;
-}
-
+#include "fileload.h" + +extern "C" void UncompressBackward(void *bottom); + + +void *LoadFile(FileHandle *handle, const char *name) { + OSReport("[LoadFile %s]\n", name); + + int entryNum = DVDConvertPathToEntrynum(name); + + DVDHandle dvdhandle; + if (!DVDFastOpen(entryNum, &dvdhandle)) { + OSReport("Cannot open file %s [%d]\n", name, entryNum); + return 0; + } + + handle->length = dvdhandle.length; + handle->filePtr = EGG__Heap__alloc((handle->length+0x1F) & ~0x1F, 0x20, GetArchiveHeap()); + + int ret = DVDReadPrio(&dvdhandle, handle->filePtr, (handle->length+0x1F) & ~0x1F, 0, 2); + + DVDClose(&dvdhandle); + + OSReport("[Success %p]\n", handle->filePtr); + + return handle->filePtr; +} + +void *LoadCompressedFile(FileHandle *handle, const char *name) { + OSReport("[LoadCompressedFile %s]\n", name); + + int entryNum = DVDConvertPathToEntrynum(name); + + DVDHandle dvdhandle; + if (!DVDFastOpen(entryNum, &dvdhandle)) { + OSReport("Cannot open file %s [%d]\n", name, entryNum); + return 0; + } + + u32 infoBlock[0x20 / sizeof(u32)] __attribute__ ((aligned(32))); + DVDReadPrio(&dvdhandle, infoBlock, 0x20, dvdhandle.length - 8, 2); + + // Reverse it! + infoBlock[1] = (infoBlock[1] >> 24) | ((infoBlock[1] >> 8) & 0xFF00) | ((infoBlock[1] & 0xFF00) << 8) | ((infoBlock[1] & 0xFF) << 24); + + u32 uncompSize = dvdhandle.length + infoBlock[1]; + OSReport("[Comp:%d UnComp:%d]\n", dvdhandle.length, uncompSize); + handle->length = uncompSize; + handle->filePtr = EGG__Heap__alloc((uncompSize+0x1F) & ~0x1F, 0x20, GetArchiveHeap()); + + int ret = DVDReadPrio(&dvdhandle, handle->filePtr, (dvdhandle.length+0x1F) & ~0x1F, 0, 2); + + DVDClose(&dvdhandle); + + UncompressBackward((void*)((u32)handle->filePtr + dvdhandle.length)); + + OSReport("[Success %p]\n", handle->filePtr); + + return handle->filePtr; +} + +bool FreeFile(FileHandle *handle) { + if (!handle) return false; + + if (handle->filePtr) { + OSReport("[FreeFile %p]\n", handle->filePtr); + EGG__Heap__free(handle->filePtr, GetArchiveHeap()); + } + + handle->filePtr = 0; + handle->length = 0; + + return true; +} + + + + +File::File() { + m_loaded = false; +} + +File::~File() { + close(); +} + +bool File::open(const char *filename) { + if (m_loaded) + close(); + + void *ret = LoadFile(&m_handle, filename); + if (ret != 0) + m_loaded = true; + + return (ret != 0); +} + +bool File::openCompressed(const char *filename) { + if (m_loaded) + close(); + + void *ret = LoadCompressedFile(&m_handle, filename); + if (ret != 0) + m_loaded = true; + + return (ret != 0); +} + +void File::close() { + if (!m_loaded) + return; + + m_loaded = false; + FreeFile(&m_handle); +} + +bool File::isOpen() { + return m_loaded; +} + +void *File::ptr() { + if (m_loaded) + return m_handle.filePtr; + else + return 0; +} + +u32 File::length() { + if (m_loaded) + return m_handle.length; + else + return 0xFFFFFFFF; +} + diff --git a/src/fileload.h b/src/fileload.h index 5dcdb2b..e5667ff 100644 --- a/src/fileload.h +++ b/src/fileload.h @@ -1,74 +1,74 @@ -#ifndef __NEWER_FILELOAD_H
-#define __NEWER_FILELOAD_H
-
-#include <common.h>
-
-struct FileHandle {
- void *filePtr;
- int length;
-};
-
-struct DVDHandle {
- int unk1; // 00
- int unk2; // 04
- int unk3; // 08
- int unk4; // 0C
- int unk5; // 10
- int unk6; // 14
- int unk7; // 18
- int unk8; // 1C
- int unk9; // 20
- int unk10; // 24
- int unk11; // 28
- int unk12; // 2C
- int address; // 30
- int length; // 34
- int unk13; // 38
-};
-
-
-int DVDConvertPathToEntrynum(const char *path);
-bool DVDFastOpen(int entrynum, DVDHandle *handle);
-int DVDReadPrio(DVDHandle *handle, void *buffer, int length, int offset, int unk);
-bool DVDClose(DVDHandle *handle);
-
-// EGG::Heap
-void *EGG__Heap__alloc(unsigned long size, int unk, void *heap);
-void EGG__Heap__free(void *ptr, void *heap);
-
-void *LoadFile(FileHandle *handle, const char *name);
-void *LoadCompressedFile(FileHandle *handle, const char *name);
-bool FreeFile(FileHandle *handle);
-
-void inline *GetArchiveHeap() {
- return ArchiveHeap;
-
-}
-
-
-// C++ interface
-class File {
-public:
- File();
- ~File();
-
- bool open(const char *filename);
- void close();
-
- bool openCompressed(const char *filename);
-
- bool isOpen();
-
- void *ptr();
- u32 length();
-
-private:
- FileHandle m_handle;
- bool m_loaded;
-};
-
-
-// Todo: input stream maybe?
-
-#endif
-
+#ifndef __NEWER_FILELOAD_H +#define __NEWER_FILELOAD_H + +#include <common.h> + +struct FileHandle { + void *filePtr; + int length; +}; + +struct DVDHandle { + int unk1; // 00 + int unk2; // 04 + int unk3; // 08 + int unk4; // 0C + int unk5; // 10 + int unk6; // 14 + int unk7; // 18 + int unk8; // 1C + int unk9; // 20 + int unk10; // 24 + int unk11; // 28 + int unk12; // 2C + int address; // 30 + int length; // 34 + int unk13; // 38 +}; + + +int DVDConvertPathToEntrynum(const char *path); +bool DVDFastOpen(int entrynum, DVDHandle *handle); +int DVDReadPrio(DVDHandle *handle, void *buffer, int length, int offset, int unk); +bool DVDClose(DVDHandle *handle); + +// EGG::Heap +void *EGG__Heap__alloc(unsigned long size, int unk, void *heap); +void EGG__Heap__free(void *ptr, void *heap); + +void *LoadFile(FileHandle *handle, const char *name); +void *LoadCompressedFile(FileHandle *handle, const char *name); +bool FreeFile(FileHandle *handle); + +void inline *GetArchiveHeap() { + return ArchiveHeap; + +} + + +// C++ interface +class File { +public: + File(); + ~File(); + + bool open(const char *filename); + void close(); + + bool openCompressed(const char *filename); + + bool isOpen(); + + void *ptr(); + u32 length(); + +private: + FileHandle m_handle; + bool m_loaded; +}; + + +// Todo: input stream maybe? + +#endif + diff --git a/src/gakenoko.S b/src/gakenoko.S index 9443ce4..3f12501 100644 --- a/src/gakenoko.S +++ b/src/gakenoko.S @@ -1,220 +1,220 @@ -# GAKE CLASS LAYOUT
-#
-# 524: SomeMHeapAllocatorSubclass
-# 540: 0 [[ResFile maybe?]]
-# 544: mdl_c
-# 584: SomeModelAnimationClass
-# 5BC: ResAnmTexPat (maybe?)
-# 5C0: Some type of animation: 80329890
-# 5C4: Set to 0 in ctor
-# 5C8: Set to 0 in ctor
-# 5CC: mAllocator_c
-# 5F4: EGG::Effect subclass 80329CA0
-#
-#
-# NET CLASS LAYOUT
-#
-# 524: 0
-# 528: SomeMHeapAllocatorSubclass
-# 544: ResFile
-# 548: mdl_c
-# 588: SomeModelAnimationClass
-# 5C0: ResAnmTexPat
-# 5C4: Some type of animation: 80329890
-# 5C8: Set to 0 in ctor
-# 5CC: Set to 0 in ctor
-# 5D0: mAllocator_c
-
-.extern mHeapAllocatorSubclass_Link
-.extern mHeapAllocatorSubclass_UnLink
-.extern RetrieveFileFromArc
-.extern GetResMdl
-.extern m3d__mdl_c__DoStuff
-.extern sub_80064BD0
-.extern GetResAnmChr
-.extern SomeModelAnimationClass_Setup
-.extern GetResAnmTexPat
-.extern sub_80166970
-.extern sub_80166D10
-.extern daEnGakeNoko_c__StateID_FoolMove
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.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 f2,2; .set f3,3
-#endif
-
-.set sp,1
-.set rtoc,2
-.set this,31
-
-.text
-
-.align 4
-.global gakenoko_create
-
-.set AnmTexPat,0x24
-.set ResMdlForTexPat,0x20
-.set AnmChr,0x1C
-.set ResMdlForChr,0x18
-.set ResMdlForScnMdl,0x14
-.set AnmTexPatAgain,0x10
-
-# Stack layout:
-# 0x34 : LR
-# 0x30 : SP
-# 0x2C : save this
-# 0x28 : save r30
-# 0x24 : AnmTexPat
-# 0x20 : ResMdlForTexPat
-# 0x1C : AnmChr
-# 0x18 : ResMdlForChr
-# 0x14 : ResMdlForScnMdl
-# 0x10 : AnmTexPatAgain
-
-# Local register vars:
-# r31 = this
-# r30 = resmdl
-
-gakenoko_create:
- stwu r1, -0x30(sp)
- mflr r0
- stw r0, 0x34(sp)
- stw this, 0x2C(sp)
- stw r30, 0x28(sp)
-
- mr this, r3
-
- # Create a heap
- addi r3, r3, 0x524 # SomeMHeapAllocatorSubclass
- li r4, -1
- lis r5, 0x8037
- lwz r5, 0x7F48(r5)
- bl mHeapAllocatorSubclass_Link
-
- # Get ResFile
- lwz r3, -0x5668(r13)
- addi r3, r3, 4
- lis r4, arcName@h
- ori r4, r4, arcName@l
- lis r5, fileName@h
- ori r5, r5, fileName@l
- bl RetrieveFileFromArc
-
- stw r3, 0x540(this)
-
- # Get model
- addi r3, this, 0x540 # ResFile
- lis r4, arcName@h
- ori r4, r4, arcName@l
- bl GetResMdl
-
- mr r30, r3
- stw r3, ResMdlForScnMdl(sp) # store resmdl
-
- # Do scnmdl stuff
- addi r3, this, 0x544 # mdl_c
- addi r4, sp, ResMdlForScnMdl
- addi r5, this, 0x524 # SomeMHeapAllocatorSubclass
- li r6, 0x7fff
- li r7, 1
- li r8, 0
- bl m3d__mdl_c__DoStuff
-
- addi r3, this, 0x544 # mdl_c
- bl sub_80064BD0
-
- # Handle anim
- addi r3, this, 0x540 # ResFile
- lis r4, animName@h
- ori r4, r4, animName@l
- bl GetResAnmChr
-
- stw r3, AnmChr(sp)
-
- # Set it up
- stw r30, ResMdlForChr(sp)
-
- addi r3, this, 0x584 # SomeModelAnimationClass
- addi r4, sp, ResMdlForChr
- addi r5, sp, AnmChr
- addi r6, this, 0x524 # SomeMHeapAllocatorSubclass
- li r7, 0
- bl SomeModelAnimationClass_Setup
-
- # Now handle the texpat anim
- addi r3, this, 0x540 # ResFile
- lis r4, arcName@h
- ori r4, r4, arcName@l
- bl GetResAnmTexPat
-
- stw r3, 0x5BC(this) # ResAnmTexPat
- stw r3, AnmTexPat(sp)
-
- # Set it up
- stw r30, ResMdlForTexPat(sp)
-
- addi r3, this, 0x5C0 # Weird Animation
- addi r4, sp, ResMdlForTexPat
- addi r5, sp, AnmTexPat
- addi r6, this, 0x524 # SomeMHeapAllocatorSubclass
- li r7, 0
- li r8, 1
- bl sub_80166970
-
-
- lwz r0, 0x5BC(this)
- stw r0, AnmTexPatAgain(sp)
-
- addi r3, this, 0x5C0 # Weird Animation
- addi r4, this, 0x544 # mdl_c
- addi r5, sp, AnmTexPatAgain
- li r6, 0
- li r7, 1
- bl sub_80166D10
-
- # Unbind the MHeapAllocatorSubclass
- addi r3, this, 0x524 # SomeMHeapAllocatorSubclass
- bl mHeapAllocatorSubclass_UnLink
-
-
- # Model's done
- # Set a state
- mr r3, this
- lis r4, daEnGakeNoko_c__StateID_FoolMove@h
- ori r4, r4, daEnGakeNoko_c__StateID_FoolMove@l
-
- lwz r12, 0x60(this)
- lwz r12, 0xD4(r12)
- mtctr r12
-
-
- li r3, 1
-
- # Clean up stack
- lwz r0, 0x34(sp)
- lwz this, 0x2C(sp)
- lwz r30, 0x28(sp)
- mtlr r0
- addi sp, sp, 0x30
-
- blr
-
-
-.data
-
-fileName:
- .string "g3d/nokonokoB.brres"
-
-arcName:
- .string "nokonokoB"
-
-animName:
- .string "net_walk2"
-
-debugString:
- .string "X> %08x\n"
+# GAKE CLASS LAYOUT +# +# 524: SomeMHeapAllocatorSubclass +# 540: 0 [[ResFile maybe?]] +# 544: mdl_c +# 584: SomeModelAnimationClass +# 5BC: ResAnmTexPat (maybe?) +# 5C0: Some type of animation: 80329890 +# 5C4: Set to 0 in ctor +# 5C8: Set to 0 in ctor +# 5CC: mAllocator_c +# 5F4: EGG::Effect subclass 80329CA0 +# +# +# NET CLASS LAYOUT +# +# 524: 0 +# 528: SomeMHeapAllocatorSubclass +# 544: ResFile +# 548: mdl_c +# 588: SomeModelAnimationClass +# 5C0: ResAnmTexPat +# 5C4: Some type of animation: 80329890 +# 5C8: Set to 0 in ctor +# 5CC: Set to 0 in ctor +# 5D0: mAllocator_c + +.extern mHeapAllocatorSubclass_Link +.extern mHeapAllocatorSubclass_UnLink +.extern RetrieveFileFromArc +.extern GetResMdl +.extern m3d__mdl_c__DoStuff +.extern sub_80064BD0 +.extern GetResAnmChr +.extern SomeModelAnimationClass_Setup +.extern GetResAnmTexPat +.extern sub_80166970 +.extern sub_80166D10 +.extern daEnGakeNoko_c__StateID_FoolMove + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f2,2; .set f3,3 +#endif + +.set sp,1 +.set rtoc,2 +.set this,31 + +.text + +.align 4 +.global gakenoko_create + +.set AnmTexPat,0x24 +.set ResMdlForTexPat,0x20 +.set AnmChr,0x1C +.set ResMdlForChr,0x18 +.set ResMdlForScnMdl,0x14 +.set AnmTexPatAgain,0x10 + +# Stack layout: +# 0x34 : LR +# 0x30 : SP +# 0x2C : save this +# 0x28 : save r30 +# 0x24 : AnmTexPat +# 0x20 : ResMdlForTexPat +# 0x1C : AnmChr +# 0x18 : ResMdlForChr +# 0x14 : ResMdlForScnMdl +# 0x10 : AnmTexPatAgain + +# Local register vars: +# r31 = this +# r30 = resmdl + +gakenoko_create: + stwu r1, -0x30(sp) + mflr r0 + stw r0, 0x34(sp) + stw this, 0x2C(sp) + stw r30, 0x28(sp) + + mr this, r3 + + # Create a heap + addi r3, r3, 0x524 # SomeMHeapAllocatorSubclass + li r4, -1 + lis r5, 0x8037 + lwz r5, 0x7F48(r5) + bl mHeapAllocatorSubclass_Link + + # Get ResFile + lwz r3, -0x5668(r13) + addi r3, r3, 4 + lis r4, arcName@h + ori r4, r4, arcName@l + lis r5, fileName@h + ori r5, r5, fileName@l + bl RetrieveFileFromArc + + stw r3, 0x540(this) + + # Get model + addi r3, this, 0x540 # ResFile + lis r4, arcName@h + ori r4, r4, arcName@l + bl GetResMdl + + mr r30, r3 + stw r3, ResMdlForScnMdl(sp) # store resmdl + + # Do scnmdl stuff + addi r3, this, 0x544 # mdl_c + addi r4, sp, ResMdlForScnMdl + addi r5, this, 0x524 # SomeMHeapAllocatorSubclass + li r6, 0x7fff + li r7, 1 + li r8, 0 + bl m3d__mdl_c__DoStuff + + addi r3, this, 0x544 # mdl_c + bl sub_80064BD0 + + # Handle anim + addi r3, this, 0x540 # ResFile + lis r4, animName@h + ori r4, r4, animName@l + bl GetResAnmChr + + stw r3, AnmChr(sp) + + # Set it up + stw r30, ResMdlForChr(sp) + + addi r3, this, 0x584 # SomeModelAnimationClass + addi r4, sp, ResMdlForChr + addi r5, sp, AnmChr + addi r6, this, 0x524 # SomeMHeapAllocatorSubclass + li r7, 0 + bl SomeModelAnimationClass_Setup + + # Now handle the texpat anim + addi r3, this, 0x540 # ResFile + lis r4, arcName@h + ori r4, r4, arcName@l + bl GetResAnmTexPat + + stw r3, 0x5BC(this) # ResAnmTexPat + stw r3, AnmTexPat(sp) + + # Set it up + stw r30, ResMdlForTexPat(sp) + + addi r3, this, 0x5C0 # Weird Animation + addi r4, sp, ResMdlForTexPat + addi r5, sp, AnmTexPat + addi r6, this, 0x524 # SomeMHeapAllocatorSubclass + li r7, 0 + li r8, 1 + bl sub_80166970 + + + lwz r0, 0x5BC(this) + stw r0, AnmTexPatAgain(sp) + + addi r3, this, 0x5C0 # Weird Animation + addi r4, this, 0x544 # mdl_c + addi r5, sp, AnmTexPatAgain + li r6, 0 + li r7, 1 + bl sub_80166D10 + + # Unbind the MHeapAllocatorSubclass + addi r3, this, 0x524 # SomeMHeapAllocatorSubclass + bl mHeapAllocatorSubclass_UnLink + + + # Model's done + # Set a state + mr r3, this + lis r4, daEnGakeNoko_c__StateID_FoolMove@h + ori r4, r4, daEnGakeNoko_c__StateID_FoolMove@l + + lwz r12, 0x60(this) + lwz r12, 0xD4(r12) + mtctr r12 + + + li r3, 1 + + # Clean up stack + lwz r0, 0x34(sp) + lwz this, 0x2C(sp) + lwz r30, 0x28(sp) + mtlr r0 + addi sp, sp, 0x30 + + blr + + +.data + +fileName: + .string "g3d/nokonokoB.brres" + +arcName: + .string "nokonokoB" + +animName: + .string "net_walk2" + +debugString: + .string "X> %08x\n" diff --git a/src/growup.s b/src/growup.s index b8d8922..11fa5b4 100755 --- a/src/growup.s +++ b/src/growup.s @@ -1,14 +1,14 @@ -#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.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
+#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f6,6; .set f8,8 -.set f31,31; .set f30,30
-#endif
+.set f31,31; .set f30,30 +#endif .text @@ -24,7 +24,7 @@ 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
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -38,7 +38,7 @@ 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
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -52,7 +52,7 @@ 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
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -66,7 +66,7 @@ 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
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -80,7 +80,7 @@ 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
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, RiderLookupTable@h @@ -94,7 +94,7 @@ 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
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, RiderLookupTable@h @@ -108,7 +108,7 @@ 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
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -122,7 +122,7 @@ 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
+ andi. r12, r12, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -531,7 +531,7 @@ ModifyStandOnTopInitA: 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
+ andi. r10, r10, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -562,7 +562,7 @@ ModifyStandOnTopInitB: 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
+ andi. r10, r10, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h @@ -618,7 +618,7 @@ ModifyStandOnTopInitD: 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
+ andi. r10, r10, 0xF # first off, get the value from the lookup table lis r11, LookupTable@h diff --git a/src/heapbar.S b/src/heapbar.S index 35d45e5..4f86fbe 100644 --- a/src/heapbar.S +++ b/src/heapbar.S @@ -1,118 +1,118 @@ -# memory debugger - fun!
-# GX stuff is implemented in C++, this just gets the lowlevel info
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.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 f2,2; .set f3,3
-#endif
-
-#define HEAP_EGGRootMEM1 1
-#define HEAP_EGGRootMEM2 2
-
-.extern cppGXStart
-.extern cppGXEnd
-.extern cppProcessHeap
-.extern MEMGetTotalFreeSizeForExpHeap
-.extern GameHeap1
-.extern GameHeap2
-
-.set sp,1
-.set rtoc,2
-.set this,31
-
-.text
-
-.align 4
-
-.global doHeapBar
-
-doHeapBar:
- blr
-
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
-
- stw this, 0xC(sp)
-
- #lis r3, EGGTSystem_Pointer@h
- #ori r3, r3, EGGTSystem_Pointer@l
- #lwz this, 0(r3)
-
- bl cppGXStart
-
- #lwz r3, 0x18(this)
- #lis r3, dSys_c__RootHeapMEM1@h
- #ori r3, r3, dSys_c__RootHeapMEM1@l
- lis r3, GameHeap1@h
- ori r3, r3, GameHeap1@l
- lwz r3, 0(r3)
- li r4, HEAP_EGGRootMEM1
- bl asmProcessHeap
-
- #lwz r3, 0x1C(this)
- #lis r3, dSys_c__RootHeapMEM2@h
- #ori r3, r3, dSys_c__RootHeapMEM2@l
- lis r3, GameHeap2@h
- ori r3, r3, GameHeap2@l
- lwz r3, 0(r3)
- li r4, HEAP_EGGRootMEM2
- bl asmProcessHeap
-
- bl cppGXEnd
-
- lwz this, 0xC(sp)
- lwz r0, 0x14(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-
-asmProcessHeap:
-
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
-
- stw r31, 0xC(sp)
- stw r30, 0x8(sp)
-
- mr r31, r3
- mr r30, r4
-
- # get all the required data from the heap
- # cppProcessHeap(u32 freeSize, u32 heapSize, int heapID, char *name)
-
- # get free size first so the function doesn't destroy our volatile regs
- # because I'm too lazy to save them >.>
- lwz r3, 0x10(r31)
- bl MEMGetTotalFreeSizeForExpHeap
-
- # get name
- lwz r6, 0x34(r31)
-
- # get heapID
- mr r5, r30
-
- # get heap size
- # this was a fucking pain to figure out -_-
- lwz r4, 0x10(r31) # get the MEMiHeapHead*
- lwz r7, 0x18(r4) # get heapStart
- lwz r8, 0x1C(r4) # get heapEnd
- sub r4, r8, r7 # heapSize = heapEnd - heapStart probably
-
- # now do it
- bl cppProcessHeap
-
- lwz r30, 0x8(sp)
- lwz r31, 0xC(sp)
- lwz r0, 0x14(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
+# memory debugger - fun! +# GX stuff is implemented in C++, this just gets the lowlevel info + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f2,2; .set f3,3 +#endif + +#define HEAP_EGGRootMEM1 1 +#define HEAP_EGGRootMEM2 2 + +.extern cppGXStart +.extern cppGXEnd +.extern cppProcessHeap +.extern MEMGetTotalFreeSizeForExpHeap +.extern GameHeap1 +.extern GameHeap2 + +.set sp,1 +.set rtoc,2 +.set this,31 + +.text + +.align 4 + +.global doHeapBar + +doHeapBar: + blr + + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + + stw this, 0xC(sp) + + #lis r3, EGGTSystem_Pointer@h + #ori r3, r3, EGGTSystem_Pointer@l + #lwz this, 0(r3) + + bl cppGXStart + + #lwz r3, 0x18(this) + #lis r3, dSys_c__RootHeapMEM1@h + #ori r3, r3, dSys_c__RootHeapMEM1@l + lis r3, GameHeap1@h + ori r3, r3, GameHeap1@l + lwz r3, 0(r3) + li r4, HEAP_EGGRootMEM1 + bl asmProcessHeap + + #lwz r3, 0x1C(this) + #lis r3, dSys_c__RootHeapMEM2@h + #ori r3, r3, dSys_c__RootHeapMEM2@l + lis r3, GameHeap2@h + ori r3, r3, GameHeap2@l + lwz r3, 0(r3) + li r4, HEAP_EGGRootMEM2 + bl asmProcessHeap + + bl cppGXEnd + + lwz this, 0xC(sp) + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + +asmProcessHeap: + + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + + stw r31, 0xC(sp) + stw r30, 0x8(sp) + + mr r31, r3 + mr r30, r4 + + # get all the required data from the heap + # cppProcessHeap(u32 freeSize, u32 heapSize, int heapID, char *name) + + # get free size first so the function doesn't destroy our volatile regs + # because I'm too lazy to save them >.> + lwz r3, 0x10(r31) + bl MEMGetTotalFreeSizeForExpHeap + + # get name + lwz r6, 0x34(r31) + + # get heapID + mr r5, r30 + + # get heap size + # this was a fucking pain to figure out -_- + lwz r4, 0x10(r31) # get the MEMiHeapHead* + lwz r7, 0x18(r4) # get heapStart + lwz r8, 0x1C(r4) # get heapEnd + sub r4, r8, r7 # heapSize = heapEnd - heapStart probably + + # now do it + bl cppProcessHeap + + lwz r30, 0x8(sp) + lwz r31, 0xC(sp) + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + blr diff --git a/src/heapbar.cpp b/src/heapbar.cpp index 3759b22..386427d 100644 --- a/src/heapbar.cpp +++ b/src/heapbar.cpp @@ -1,147 +1,147 @@ -#define GEKKO
-
-#include <common.h>
-#include "rvl/mtx.h"
-#include "rvl/GXEnum.h"
-#include "rvl/GXStruct.h"
-#include "rvl/GXTransform.h"
-#include "rvl/GXGeometry.h"
-#include "rvl/GXDispList.h"
-#include "rvl/GXLighting.h"
-#include "rvl/GXTev.h"
-#include "rvl/GXTexture.h"
-#include "rvl/GXCull.h"
-#include "rvl/GXPixel.h"
-#include "rvl/GXBump.h"
-//#include "rvl/GXVert.h"
-#include "rvl/vifuncs.h"
-
-extern u32 Global5758;
-
-#define GXPosition3f32(x,y,z) \
- *((volatile float*)0xCC008000) = (x); \
- *((volatile float*)0xCC008000) = (y); \
- *((volatile float*)0xCC008000) = (z);
-
-#define GXColor1u32(x) \
- *((volatile u32*)0xCC008000) = (x);
-
-
-extern "C" {
-
-
-void cppGXStart() {
- Mtx44 ortho;
-
- MTXOrtho(ortho, 0, 456, 0, 686, 0.0F, 1.0F);
- GXSetProjection(ortho, GX_ORTHOGRAPHIC);
-
- Mtx identity;
- MTXIdentity(identity);
-
- GXLoadPosMtxImm(identity, GX_PNMTX0);
-
- GXSetNumTevStages(1);
- GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0);
- GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR);
- GXSetTevDirect(GX_TEVSTAGE0);
-
- GXSetNumChans(1);
- GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE);
-
- GXClearVtxDesc();
- GXSetVtxDesc(GX_VA_POS, GX_DIRECT);
- GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT);
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0);
- GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBX8, 0);
-
- GXSetZMode(GX_TRUE, GX_ALWAYS, GX_TRUE);
-}
-
-void cppGXEnd() {
-}
-
-
-
-float y_positions[] = {
- -1,
- 0.0,
- 16.0
-};
-
-u32 colours[] = {
- -1,
- 0x0000ffff,
- 0xff0000ff
-};
-
-u32 col_5758[] = {
- 0x00ff00ff,
- 0xffff00ff,
- 0x00ffffff,
- 0xf0ff0fff
-};
-
-void cppProcessHeap(u32 freeSize, u32 heapSize, int heapID, char *name) {
- // get the info needed
- float y_pos = y_positions[heapID];
- u32 colour = colours[heapID];
-
- // width: 686
-
- //OSReport("%s => size %d, free %d\n", name, heapSize, freeSize);
-
- float left = 0;
- float right = ((heapSize - freeSize) * 686.0f) / heapSize;
- float top = y_pos;
- float bottom = y_pos+16;
-
- GXBegin(GX_QUADS, GX_VTXFMT0, 4);
-
- GXPosition3f32(left, top, 0.0);
- GXColor1u32(colour);
- GXPosition3f32(right, top, 0.0);
- GXColor1u32(colour);
- GXPosition3f32(right, bottom, 0.0);
- GXColor1u32(colour);
- GXPosition3f32(left, bottom, 0.0);
- GXColor1u32(colour);
-
- GXEnd();
-
-
- GXBegin(GX_QUADS, GX_VTXFMT0, 16);
-
- for (int i = 0; i < 4; i++) {
- GXPosition3f32(16*i, 32, 0.0);
- GXColor1u32(col_5758[i]);
- GXPosition3f32(16*i+16, 32, 0.0);
- GXColor1u32(col_5758[i]);
- GXPosition3f32(16*i+16, 48, 0.0);
- GXColor1u32(col_5758[i]);
- GXPosition3f32(16*i, 48, 0.0);
- GXColor1u32(col_5758[i]);
- }
-
- GXEnd();
-
- for (int i = 0; i < 4; i++) {
- if (Global5758 & (1 << i)) {
- GXBegin(GX_QUADS, GX_VTXFMT0, 4);
-
- GXPosition3f32(16*i, 48, 0.0);
- GXColor1u32(0xffffffff);
- GXPosition3f32(16*i+16, 48, 0.0);
- GXColor1u32(0xffffffff);
- GXPosition3f32(16*i+16, 56, 0.0);
- GXColor1u32(0xffffffff);
- GXPosition3f32(16*i, 56, 0.0);
- GXColor1u32(0xffffffff);
-
- GXEnd();
- }
- }
-}
-
-
-};
+#define GEKKO + +#include <common.h> +#include "rvl/mtx.h" +#include "rvl/GXEnum.h" +#include "rvl/GXStruct.h" +#include "rvl/GXTransform.h" +#include "rvl/GXGeometry.h" +#include "rvl/GXDispList.h" +#include "rvl/GXLighting.h" +#include "rvl/GXTev.h" +#include "rvl/GXTexture.h" +#include "rvl/GXCull.h" +#include "rvl/GXPixel.h" +#include "rvl/GXBump.h" +//#include "rvl/GXVert.h" +#include "rvl/vifuncs.h" + +extern u32 Global5758; + +#define GXPosition3f32(x,y,z) \ + *((volatile float*)0xCC008000) = (x); \ + *((volatile float*)0xCC008000) = (y); \ + *((volatile float*)0xCC008000) = (z); + +#define GXColor1u32(x) \ + *((volatile u32*)0xCC008000) = (x); + + +extern "C" { + + +void cppGXStart() { + Mtx44 ortho; + + MTXOrtho(ortho, 0, 456, 0, 686, 0.0F, 1.0F); + GXSetProjection(ortho, GX_ORTHOGRAPHIC); + + Mtx identity; + MTXIdentity(identity); + + GXLoadPosMtxImm(identity, GX_PNMTX0); + + GXSetNumTevStages(1); + GXSetTevOrder(GX_TEVSTAGE0, GX_TEXCOORD_NULL, GX_TEXMAP_NULL, GX_COLOR0A0); + GXSetTevOp(GX_TEVSTAGE0, GX_PASSCLR); + GXSetTevDirect(GX_TEVSTAGE0); + + GXSetNumChans(1); + GXSetChanCtrl(GX_COLOR0A0, GX_DISABLE, GX_SRC_VTX, GX_SRC_VTX, GX_LIGHT_NULL, GX_DF_NONE, GX_AF_NONE); + + GXClearVtxDesc(); + GXSetVtxDesc(GX_VA_POS, GX_DIRECT); + GXSetVtxDesc(GX_VA_CLR0, GX_DIRECT); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_POS, GX_POS_XYZ, GX_F32, 0); + GXSetVtxAttrFmt(GX_VTXFMT0, GX_VA_CLR0, GX_CLR_RGBA, GX_RGBX8, 0); + + GXSetZMode(GX_TRUE, GX_ALWAYS, GX_TRUE); +} + +void cppGXEnd() { +} + + + +float y_positions[] = { + -1, + 0.0, + 16.0 +}; + +u32 colours[] = { + -1, + 0x0000ffff, + 0xff0000ff +}; + +u32 col_5758[] = { + 0x00ff00ff, + 0xffff00ff, + 0x00ffffff, + 0xf0ff0fff +}; + +void cppProcessHeap(u32 freeSize, u32 heapSize, int heapID, char *name) { + // get the info needed + float y_pos = y_positions[heapID]; + u32 colour = colours[heapID]; + + // width: 686 + + //OSReport("%s => size %d, free %d\n", name, heapSize, freeSize); + + float left = 0; + float right = ((heapSize - freeSize) * 686.0f) / heapSize; + float top = y_pos; + float bottom = y_pos+16; + + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + + GXPosition3f32(left, top, 0.0); + GXColor1u32(colour); + GXPosition3f32(right, top, 0.0); + GXColor1u32(colour); + GXPosition3f32(right, bottom, 0.0); + GXColor1u32(colour); + GXPosition3f32(left, bottom, 0.0); + GXColor1u32(colour); + + GXEnd(); + + + GXBegin(GX_QUADS, GX_VTXFMT0, 16); + + for (int i = 0; i < 4; i++) { + GXPosition3f32(16*i, 32, 0.0); + GXColor1u32(col_5758[i]); + GXPosition3f32(16*i+16, 32, 0.0); + GXColor1u32(col_5758[i]); + GXPosition3f32(16*i+16, 48, 0.0); + GXColor1u32(col_5758[i]); + GXPosition3f32(16*i, 48, 0.0); + GXColor1u32(col_5758[i]); + } + + GXEnd(); + + for (int i = 0; i < 4; i++) { + if (Global5758 & (1 << i)) { + GXBegin(GX_QUADS, GX_VTXFMT0, 4); + + GXPosition3f32(16*i, 48, 0.0); + GXColor1u32(0xffffffff); + GXPosition3f32(16*i+16, 48, 0.0); + GXColor1u32(0xffffffff); + GXPosition3f32(16*i+16, 56, 0.0); + GXColor1u32(0xffffffff); + GXPosition3f32(16*i, 56, 0.0); + GXColor1u32(0xffffffff); + + GXEnd(); + } + } +} + + +}; diff --git a/src/layoutlib.S b/src/layoutlib.S index 2fae70a..96c69cb 100644 --- a/src/layoutlib.S +++ b/src/layoutlib.S @@ -1,131 +1,131 @@ -.extern LayoutHelper_Link
-
-#ifndef __MWERKS__
-.extern _Z8LoadFileP10FileHandlePc
-.extern _Z8FreeFileP10FileHandle
-#define LoadFileFunc _Z8LoadFileP10FileHandlePc
-#define FreeFileFunc _Z8FreeFileP10FileHandle
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.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 f2,2; .set f3,3
-#else
-.extern LoadFile__FP10FileHandlePCc
-.extern FreeFile__FP10FileHandle
-#define LoadFileFunc LoadFile__FP10FileHandlePCc
-#define FreeFileFunc FreeFile__FP10FileHandle
-#endif
-
-.text
-
-.set sp,1
-.set rtoc,2
-.set this,31
-
-
-
-
-.global EmbeddedLayout_LoadArc
-EmbeddedLayout_LoadArc:
- # stack setup
- stwu sp, -0x20(sp)
- mflr r0
- stw r0, 0x24(sp)
- stw r31, 0x1C(sp)
- stw r30, 0x18(sp)
-
- # r31 is a pointer to the LayoutHelper (must be converted)
- # r30 stores the filename
- addi r31, r3, 0xAC
- mr r30, r4
-
- # check to see if an arc has already been loaded
- lwz r0, 0xBC(r3)
- cmpwi r0, 0
- bne return_0
-
- # ok, no
- # create a FileHandle where a NSMBWFile would be
- # don't know if this will work but it's worth a try
- addi r3, r31, 0xC0
- mr r4, r30
- bl LoadFileFunc
-
- # check retval
- cmpwi r3, 0
- stw r3, 0xBC(r31)
- beq return_0
-
- # link it
- mr r4, r3
- mr r3, r31
- lis r5, arcString@h
- ori r5, r5, arcString@l
- bl LayoutHelper_Link
-
- # now add a pointer to the LayoutHelper into the Layout at offset 0x84
- # turn r3 into an EmbeddedLayout pointer
- subi r3, r31, 0xAC
- stw r31, 0x84(r3)
-
- b return_1
-
-return_0:
- li r3, 0
- b return
-
-return_1:
- li r3, 1
-
-return:
- lwz r30, 0x18(sp)
- lwz r31, 0x1C(sp)
- lwz r0, 0x24(sp)
- mtlr r0
- addi sp, sp, 0x20
- blr
-
-.align 4
-
-.global EmbeddedLayout_FreeArc
-EmbeddedLayout_FreeArc:
- # stack setup
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
- stw r31, 0xC(sp)
-
- # r31 is a pointer to the LayoutHelper (must be converted)
- addi r31, r3, 0xAC
-
- # - if an arc has been loaded, then free the NSMBWFile
- lwz r0, 0xBC(r3)
- cmpwi r0, 0
- beq xreturn_1
-
- # no, so free it
- addi r3, r31, 0xC0
- bl FreeFileFunc
-
- li r3, 0
- stw r3, 0xBC(r31)
-
-xreturn_1:
- li r3, 1
- lwz r31, 0xC(sp)
- lwz r0, 0x14(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-
-.data
-arcString:
- .string "arc"
-
-.align 4
-
+.extern LayoutHelper_Link + +#ifndef __MWERKS__ +.extern _Z8LoadFileP10FileHandlePc +.extern _Z8FreeFileP10FileHandle +#define LoadFileFunc _Z8LoadFileP10FileHandlePc +#define FreeFileFunc _Z8FreeFileP10FileHandle +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f2,2; .set f3,3 +#else +.extern LoadFile__FP10FileHandlePCc +.extern FreeFile__FP10FileHandle +#define LoadFileFunc LoadFile__FP10FileHandlePCc +#define FreeFileFunc FreeFile__FP10FileHandle +#endif + +.text + +.set sp,1 +.set rtoc,2 +.set this,31 + + + + +.global EmbeddedLayout_LoadArc +EmbeddedLayout_LoadArc: + # stack setup + stwu sp, -0x20(sp) + mflr r0 + stw r0, 0x24(sp) + stw r31, 0x1C(sp) + stw r30, 0x18(sp) + + # r31 is a pointer to the LayoutHelper (must be converted) + # r30 stores the filename + addi r31, r3, 0xAC + mr r30, r4 + + # check to see if an arc has already been loaded + lwz r0, 0xBC(r3) + cmpwi r0, 0 + bne return_0 + + # ok, no + # create a FileHandle where a NSMBWFile would be + # don't know if this will work but it's worth a try + addi r3, r31, 0xC0 + mr r4, r30 + bl LoadFileFunc + + # check retval + cmpwi r3, 0 + stw r3, 0xBC(r31) + beq return_0 + + # link it + mr r4, r3 + mr r3, r31 + lis r5, arcString@h + ori r5, r5, arcString@l + bl LayoutHelper_Link + + # now add a pointer to the LayoutHelper into the Layout at offset 0x84 + # turn r3 into an EmbeddedLayout pointer + subi r3, r31, 0xAC + stw r31, 0x84(r3) + + b return_1 + +return_0: + li r3, 0 + b return + +return_1: + li r3, 1 + +return: + lwz r30, 0x18(sp) + lwz r31, 0x1C(sp) + lwz r0, 0x24(sp) + mtlr r0 + addi sp, sp, 0x20 + blr + +.align 4 + +.global EmbeddedLayout_FreeArc +EmbeddedLayout_FreeArc: + # stack setup + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + stw r31, 0xC(sp) + + # r31 is a pointer to the LayoutHelper (must be converted) + addi r31, r3, 0xAC + + # - if an arc has been loaded, then free the NSMBWFile + lwz r0, 0xBC(r3) + cmpwi r0, 0 + beq xreturn_1 + + # no, so free it + addi r3, r31, 0xC0 + bl FreeFileFunc + + li r3, 0 + stw r3, 0xBC(r31) + +xreturn_1: + li r3, 1 + lwz r31, 0xC(sp) + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + +.data +arcString: + .string "arc" + +.align 4 + diff --git a/src/layoutlib.h b/src/layoutlib.h index 6b7d275..55a3027 100644 --- a/src/layoutlib.h +++ b/src/layoutlib.h @@ -1,149 +1,149 @@ -#ifndef __NEWER_LAYOUTLIB_H
-#define __NEWER_LAYOUTLIB_H
-
-/* Treeki's LayoutLib for New Super Mario Bros Wii */
-#include <common.h>
-
-typedef float MTX[3][4];
-
-struct nw4r__lyt__Layout {
- void *vtable;
- void *field_04;
- void *field_08;
- void *field_0C;
- void *rootPane;
- void *field_14;
- void *field_18;
- void *field_1C;
-};
-
-struct nw4r__lyt__DrawInfo {
- // 0x00
- void *vtable;
- MTX matrix;
-
- // 0x34
- float left;
- float top;
- float right;
-
- // 0x40
- float bottom;
- float scale_x;
- float scale_y;
- float opacity;
-
- // 0x50
- unsigned char widescreenFlag;
-};
-
-struct FrameCtrl_c {
-
-};
-
-struct Anm_c {
- FrameCtrl_c *fc_ptr;
- void *brlanHandler;
- void *field_08;
- char field_0C;
- char pad[3];
- FrameCtrl_c fc;
-};
-
-struct Layout {
- void *field_00;
- void *field_04;
- void *vtable;
- unsigned char drawOrder; // 0x0C
- char pad1[3];
-
- // offset 0x10
- nw4r__lyt__Layout layout; // Actually m2d::Layout_c, but the struct is the same
-
- // offset 0x30
- nw4r__lyt__DrawInfo drawInfo;
-
- // offset 0x84
- //LayoutHelper *field_84;
- void *field_84;
- float posX; // 0x88
- float posY; // 0x8C
- float clipX; // 0x90
- float clipY; // 0x94
- float clipWidth; // 0x98
- float clipHeight; // 0x9C
- unsigned char clipEnabled; // 0xA0
- char pad2[3];
- unsigned int animEnabled; // 0xA4
- void *field_A8;
-
- // offset 0xAC
- //LayoutHelper lh; // actually a m2d::ResAccLoader_c
- char lh[0xD4]; // don't feel like figuring this one out -_-
-
- // offset 0x180
- //BrlanHandler *brlanHandlers; // 0x180, points to brlan handlers
- void *brlanHandlers;
- //GrpHandler *grpHandlers; // 0x184
- void *grpHandlers;
- char *field_188; // char array, probably "anim enabled"
- int brlanCount; // 0x18C
- int grpCount; // 0x190
- int field_194; // no idea
-};
-
-
-void EmbeddedLayout_ctor(Layout *self); // 0x800C89A0
-void EmbeddedLayout_dtor(Layout *self, bool del); // 0x800C89F0
-void EmbeddedLayout_Free(Layout *self); // 0x800C9A20
-bool EmbeddedLayout_LoadArcOld(Layout *self, const char *path, bool isLangSpecific); // 0x800C8D00
-
-extern "C" {
-bool EmbeddedLayout_LoadArc(Layout *self, const char *path); // custom
-bool EmbeddedLayout_FreeArc(Layout *self); // custom
-};
-
-void EmbeddedLayout_LoadBrlans(Layout *self, const char **names, int count); // 0x800C90A0
-void EmbeddedLayout_LoadGroups(Layout *self, const char **names, int *brlanLinkIDs, int count); // 0x800C91E0
-
-void EmbeddedLayout_AddToDrawList(Layout *self); // 0x80163990
-
-void *EmbeddedLayout_FindPaneByName(Layout *self, const char *name);
-void *EmbeddedLayout_FindTextBoxByName(Layout *self, const char *name);
-void *EmbeddedLayout_FindPictureByName(Layout *self, const char *name);
-void *EmbeddedLayout_FindWindowByName(Layout *self, const char *name);
-
-void EmbeddedLayout_EnableNonLoopAnim(Layout *self, int animNum, bool pointlessShit); // 0x800C93E0
-void EmbeddedLayout_EnableLoopAnim(Layout *self, int animNum); // 0x800C9470
-void EmbeddedLayout_ResetAnimToInitialState(Layout *self, int animNum, bool isLoop_maybe); // 0x800C94C0
-void EmbeddedLayout_DisableAnim(Layout *self, int animNum); // 0x800C9580
-void EmbeddedLayout_DisableAllAnims(Layout *self); // 0x800C95F0
-void EmbeddedLayout_Process(Layout *self); // 0x800C9650
-bool EmbeddedLayout_CheckIfAnimationIsOn(Layout *self, int animNum); // 0x800C9700
-bool EmbeddedLayout_CheckIfAnyAnimationsAreOn(Layout *self); // 0x800C9730
-
-
-typedef bool (*__EmbeddedLayout_Build_type)(Layout*, const char*, void*);
-inline bool EmbeddedLayout_Build(Layout *self, const char *brlytName, void *lh) {
- VF_BEGIN(__EmbeddedLayout_Build_type, self, 5, 8)
- return VF_CALL(self, brlytName, lh);
- VF_END;
-}
-
-typedef void (*__EmbeddedLayout_UpdateMatrix_type)(Layout*);
-inline void EmbeddedLayout_UpdateMatrix(Layout *self) {
- VF_BEGIN(__EmbeddedLayout_UpdateMatrix_type, self, 4, 8)
- VF_CALL(self);
- VF_END;
-}
-
-typedef void (*__TextBox_SetString_type)(void*, unsigned short const *, unsigned short);
-inline void TextBox_SetString(void *self, unsigned short const *str, unsigned short unk) {
- VF_BEGIN(__TextBox_SetString_type, self, 31, 0)
- VF_CALL(self, str, unk);
- VF_END;
-}
-
-#define PANE_FLAGS(pane) (*((u8*)(((u32)(pane))+0xBB)))
-
-#endif
+#ifndef __NEWER_LAYOUTLIB_H +#define __NEWER_LAYOUTLIB_H + +/* Treeki's LayoutLib for New Super Mario Bros Wii */ +#include <common.h> + +typedef float MTX[3][4]; + +struct nw4r__lyt__Layout { + void *vtable; + void *field_04; + void *field_08; + void *field_0C; + void *rootPane; + void *field_14; + void *field_18; + void *field_1C; +}; + +struct nw4r__lyt__DrawInfo { + // 0x00 + void *vtable; + MTX matrix; + + // 0x34 + float left; + float top; + float right; + + // 0x40 + float bottom; + float scale_x; + float scale_y; + float opacity; + + // 0x50 + unsigned char widescreenFlag; +}; + +struct FrameCtrl_c { + +}; + +struct Anm_c { + FrameCtrl_c *fc_ptr; + void *brlanHandler; + void *field_08; + char field_0C; + char pad[3]; + FrameCtrl_c fc; +}; + +struct Layout { + void *field_00; + void *field_04; + void *vtable; + unsigned char drawOrder; // 0x0C + char pad1[3]; + + // offset 0x10 + nw4r__lyt__Layout layout; // Actually m2d::Layout_c, but the struct is the same + + // offset 0x30 + nw4r__lyt__DrawInfo drawInfo; + + // offset 0x84 + //LayoutHelper *field_84; + void *field_84; + float posX; // 0x88 + float posY; // 0x8C + float clipX; // 0x90 + float clipY; // 0x94 + float clipWidth; // 0x98 + float clipHeight; // 0x9C + unsigned char clipEnabled; // 0xA0 + char pad2[3]; + unsigned int animEnabled; // 0xA4 + void *field_A8; + + // offset 0xAC + //LayoutHelper lh; // actually a m2d::ResAccLoader_c + char lh[0xD4]; // don't feel like figuring this one out -_- + + // offset 0x180 + //BrlanHandler *brlanHandlers; // 0x180, points to brlan handlers + void *brlanHandlers; + //GrpHandler *grpHandlers; // 0x184 + void *grpHandlers; + char *field_188; // char array, probably "anim enabled" + int brlanCount; // 0x18C + int grpCount; // 0x190 + int field_194; // no idea +}; + + +void EmbeddedLayout_ctor(Layout *self); // 0x800C89A0 +void EmbeddedLayout_dtor(Layout *self, bool del); // 0x800C89F0 +void EmbeddedLayout_Free(Layout *self); // 0x800C9A20 +bool EmbeddedLayout_LoadArcOld(Layout *self, const char *path, bool isLangSpecific); // 0x800C8D00 + +extern "C" { +bool EmbeddedLayout_LoadArc(Layout *self, const char *path); // custom +bool EmbeddedLayout_FreeArc(Layout *self); // custom +}; + +void EmbeddedLayout_LoadBrlans(Layout *self, const char **names, int count); // 0x800C90A0 +void EmbeddedLayout_LoadGroups(Layout *self, const char **names, int *brlanLinkIDs, int count); // 0x800C91E0 + +void EmbeddedLayout_AddToDrawList(Layout *self); // 0x80163990 + +void *EmbeddedLayout_FindPaneByName(Layout *self, const char *name); +void *EmbeddedLayout_FindTextBoxByName(Layout *self, const char *name); +void *EmbeddedLayout_FindPictureByName(Layout *self, const char *name); +void *EmbeddedLayout_FindWindowByName(Layout *self, const char *name); + +void EmbeddedLayout_EnableNonLoopAnim(Layout *self, int animNum, bool pointlessShit); // 0x800C93E0 +void EmbeddedLayout_EnableLoopAnim(Layout *self, int animNum); // 0x800C9470 +void EmbeddedLayout_ResetAnimToInitialState(Layout *self, int animNum, bool isLoop_maybe); // 0x800C94C0 +void EmbeddedLayout_DisableAnim(Layout *self, int animNum); // 0x800C9580 +void EmbeddedLayout_DisableAllAnims(Layout *self); // 0x800C95F0 +void EmbeddedLayout_Process(Layout *self); // 0x800C9650 +bool EmbeddedLayout_CheckIfAnimationIsOn(Layout *self, int animNum); // 0x800C9700 +bool EmbeddedLayout_CheckIfAnyAnimationsAreOn(Layout *self); // 0x800C9730 + + +typedef bool (*__EmbeddedLayout_Build_type)(Layout*, const char*, void*); +inline bool EmbeddedLayout_Build(Layout *self, const char *brlytName, void *lh) { + VF_BEGIN(__EmbeddedLayout_Build_type, self, 5, 8) + return VF_CALL(self, brlytName, lh); + VF_END; +} + +typedef void (*__EmbeddedLayout_UpdateMatrix_type)(Layout*); +inline void EmbeddedLayout_UpdateMatrix(Layout *self) { + VF_BEGIN(__EmbeddedLayout_UpdateMatrix_type, self, 4, 8) + VF_CALL(self); + VF_END; +} + +typedef void (*__TextBox_SetString_type)(void*, unsigned short const *, unsigned short); +inline void TextBox_SetString(void *self, unsigned short const *str, unsigned short unk) { + VF_BEGIN(__TextBox_SetString_type, self, 31, 0) + VF_CALL(self, str, unk); + VF_END; +} + +#define PANE_FLAGS(pane) (*((u8*)(((u32)(pane))+0xBB))) + +#endif diff --git a/src/levelinfo.cpp b/src/levelinfo.cpp index 9807fc4..ec65350 100644 --- a/src/levelinfo.cpp +++ b/src/levelinfo.cpp @@ -1,36 +1,36 @@ -#include "levelinfo.h"
-
-void LevelInfo_Prepare(FileHandle *fh) {
- void *file = fh->filePtr;
-
- // decrypt all the level names
- for (int sect = 0; sect < LevelInfo_GetSectionCount(file); sect++) {
- // parse this section
- LevelInfo_Section *thisSect = LevelInfo_GetSection(file, sect);
- LevelInfo_Entry *levels = LevelInfo_GetLevels(file, thisSect);
-
- for (int lev = 0; lev < thisSect->levelCount; lev++) {
- LevelInfo_Entry *level = &levels[lev];
-
- char *name = LevelInfo_GetName(file, level);
-
- for (int i = 0; i < level->nameLength+1; i++) {
- name[i] -= 0xD0;
- }
- }
- }
-}
-
-LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level) {
- for (int i = 0; i < LevelInfo_GetSectionCount(file); i++) {
- LevelInfo_Section *sect = LevelInfo_GetSection(file, i);
-
- for (int j = 0; j < sect->levelCount; j++) {
- LevelInfo_Entry *entry = &LevelInfo_GetLevels(file, sect)[j];
- if (entry->world == world && entry->level == level)
- return entry;
- }
- }
-
- return 0;
-}
+#include "levelinfo.h" + +void LevelInfo_Prepare(FileHandle *fh) { + void *file = fh->filePtr; + + // decrypt all the level names + for (int sect = 0; sect < LevelInfo_GetSectionCount(file); sect++) { + // parse this section + LevelInfo_Section *thisSect = LevelInfo_GetSection(file, sect); + LevelInfo_Entry *levels = LevelInfo_GetLevels(file, thisSect); + + for (int lev = 0; lev < thisSect->levelCount; lev++) { + LevelInfo_Entry *level = &levels[lev]; + + char *name = LevelInfo_GetName(file, level); + + for (int i = 0; i < level->nameLength+1; i++) { + name[i] -= 0xD0; + } + } + } +} + +LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level) { + for (int i = 0; i < LevelInfo_GetSectionCount(file); i++) { + LevelInfo_Section *sect = LevelInfo_GetSection(file, i); + + for (int j = 0; j < sect->levelCount; j++) { + LevelInfo_Entry *entry = &LevelInfo_GetLevels(file, sect)[j]; + if (entry->world == world && entry->level == level) + return entry; + } + } + + return 0; +} diff --git a/src/levelinfo.h b/src/levelinfo.h index 1b75275..8e1e916 100644 --- a/src/levelinfo.h +++ b/src/levelinfo.h @@ -1,56 +1,56 @@ -#ifndef __NEWER_LEVELINFO_H
-#define __NEWER_LEVELINFO_H
-
-#include <common.h>
-#include "fileload.h"
-
-struct LevelInfo_Header {
- u32 magic;
- u32 sectionCount;
-};
-
-struct LevelInfo_Section {
- u32 levelCount;
-};
-
-struct LevelInfo_Entry {
- u8 world;
- u8 level;
- u8 reserved1;
- u8 reserved2;
- u8 nameLength;
- u8 reserved3;
- u16 flags;
- u32 nameOffset;
-};
-
-inline u32 LevelInfo_GetSectionCount(void *file) {
- return ((LevelInfo_Header*)file)->sectionCount;
-}
-
-inline u32 *LevelInfo_GetOffsets(void *file) {
- return (u32*)(((LevelInfo_Header*)file)+1);
-}
-
-inline LevelInfo_Section *LevelInfo_GetSection(void *file, int id) {
- u32 offs = LevelInfo_GetOffsets(file)[id];
- return (LevelInfo_Section*)(((char*)file)+offs);
-};
-
-inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, LevelInfo_Section *section) {
- return (LevelInfo_Entry*)(section+1);
-}
-
-inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, int sectionID) {
- return (LevelInfo_Entry*)(LevelInfo_GetSection(file, sectionID)+1);
-}
-
-inline char *LevelInfo_GetName(void *file, LevelInfo_Entry *entry) {
- return ((char*)file)+entry->nameOffset;
-}
-
-void LevelInfo_Prepare(FileHandle *fh);
-LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level);
-
-
-#endif
+#ifndef __NEWER_LEVELINFO_H +#define __NEWER_LEVELINFO_H + +#include <common.h> +#include "fileload.h" + +struct LevelInfo_Header { + u32 magic; + u32 sectionCount; +}; + +struct LevelInfo_Section { + u32 levelCount; +}; + +struct LevelInfo_Entry { + u8 world; + u8 level; + u8 reserved1; + u8 reserved2; + u8 nameLength; + u8 reserved3; + u16 flags; + u32 nameOffset; +}; + +inline u32 LevelInfo_GetSectionCount(void *file) { + return ((LevelInfo_Header*)file)->sectionCount; +} + +inline u32 *LevelInfo_GetOffsets(void *file) { + return (u32*)(((LevelInfo_Header*)file)+1); +} + +inline LevelInfo_Section *LevelInfo_GetSection(void *file, int id) { + u32 offs = LevelInfo_GetOffsets(file)[id]; + return (LevelInfo_Section*)(((char*)file)+offs); +}; + +inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, LevelInfo_Section *section) { + return (LevelInfo_Entry*)(section+1); +} + +inline LevelInfo_Entry *LevelInfo_GetLevels(void *file, int sectionID) { + return (LevelInfo_Entry*)(LevelInfo_GetSection(file, sectionID)+1); +} + +inline char *LevelInfo_GetName(void *file, LevelInfo_Entry *entry) { + return ((char*)file)+entry->nameOffset; +} + +void LevelInfo_Prepare(FileHandle *fh); +LevelInfo_Entry *LevelInfo_Search(void *file, int world, int level); + + +#endif diff --git a/src/levelnames.cpp b/src/levelnames.cpp index b6f440e..95d7e5d 100644 --- a/src/levelnames.cpp +++ b/src/levelnames.cpp @@ -1,83 +1,83 @@ -#include <common.h>
-#include <actors.h>
-#include <stage.h>
-#include "levelinfo.h"
-#include "fileload.h"
-#include "layoutlib.h"
-
-//#define DEBUG_NAMES
-
-#ifndef DEBUG_NAMES
-#define OSReport(...)
-#endif
-
-extern char CurrentLevel;
-extern char CurrentWorld;
-
-int DoNames(int state) {
- OSReport("DoNames called - State param is %d\n", state);
- int wnum = (int)CurrentWorld;
- int lnum = (int)CurrentLevel;
- OSReport("Current Level: %d-%d\n", wnum+1, lnum+1);
-
- // Skip the title screen
- // and only process the code if the State is set to 1
- // (the screen has been initialised)
- if (state == 1 && lnum != STAGE_TITLE) {
- OSReport("Processing\n");
- // grab the CRSIN object
- Actor *ptr = FindActorByType(CRSIN, 0);
- //OSReport("CRSIN actor found at : %08X\n", ptr);
-
- // FIX !!!!!
-
- if (ptr != 0) {
- void *worldObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_WorldName");
- void *levelObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_LevelName");
- //OSReport("WorldObj TextBox : %08X; LevelObj TextBox : %08X\n", worldObj, levelObj);
- if (worldObj == 0 || levelObj == 0) return state;
-
- /*char *file = RetrieveFileFromArc(ARC_TABLE, "Mario", "newer/names.bin");
- //OSReport("RetrieveFileFromArc returned : %08X\n", file);
- char *worldname = file + (wnum * 0x40);
- char *levelname = file + 0x280 + (wnum * 0xA80) + (lnum * 0x40);*/
- OSReport("Loading file...\n");
- FileHandle fh;
- void *info = LoadFile(&fh, "/NewerRes/LevelInfo.bin");
-
- LevelInfo_Prepare(&fh);
- LevelInfo_Entry *entry = LevelInfo_Search(info, wnum, lnum);
- char *worldname = LevelInfo_GetName(info, entry);
- char *levelname = "";
- OSReport("Got name : %s\n", worldname);
-
- void *vtable = *((void**)levelObj);
- void *funcaddr = *((void**)((u32)vtable+0x7C));
- int (*SetString)(void*, unsigned short*, unsigned short);
- SetString = (int(*)(void*, unsigned short*, unsigned short))funcaddr;
-
- unsigned short wbuffer[0x40], lbuffer[0x40];
- for (int i = 0; i < 0x40; i++) {
- wbuffer[i] = (unsigned short)worldname[i];
- lbuffer[i] = (unsigned short)levelname[i];
- }
-
- SetString(worldObj, wbuffer, 0);
- SetString(levelObj, lbuffer, 0);
-
- OSReport("Freeing file\n");
- FreeFile(&fh);
- OSReport("Inserted strings\n");
- }
- } else {
- OSReport("Skipped\n");
- }
-
- OSReport("Reached the end of DoNames\n");
- return state;
-}
-
-int DoNamesTest2(int state, u32 ptr) {
- OSReport("TEST 1:%08X 2:%08X\n", state, ptr);
- return DoNames(state);
-}
+#include <common.h> +#include <actors.h> +#include <stage.h> +#include "levelinfo.h" +#include "fileload.h" +#include "layoutlib.h" + +//#define DEBUG_NAMES + +#ifndef DEBUG_NAMES +#define OSReport(...) +#endif + +extern char CurrentLevel; +extern char CurrentWorld; + +int DoNames(int state) { + OSReport("DoNames called - State param is %d\n", state); + int wnum = (int)CurrentWorld; + int lnum = (int)CurrentLevel; + OSReport("Current Level: %d-%d\n", wnum+1, lnum+1); + + // Skip the title screen + // and only process the code if the State is set to 1 + // (the screen has been initialised) + if (state == 1 && lnum != STAGE_TITLE) { + OSReport("Processing\n"); + // grab the CRSIN object + Actor *ptr = FindActorByType(CRSIN, 0); + //OSReport("CRSIN actor found at : %08X\n", ptr); + + // FIX !!!!! + + if (ptr != 0) { + void *worldObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_WorldName"); + void *levelObj = EmbeddedLayout_FindTextBoxByName((Layout*)((u32)ptr+0xB0), "TXT_LevelName"); + //OSReport("WorldObj TextBox : %08X; LevelObj TextBox : %08X\n", worldObj, levelObj); + if (worldObj == 0 || levelObj == 0) return state; + + /*char *file = RetrieveFileFromArc(ARC_TABLE, "Mario", "newer/names.bin"); + //OSReport("RetrieveFileFromArc returned : %08X\n", file); + char *worldname = file + (wnum * 0x40); + char *levelname = file + 0x280 + (wnum * 0xA80) + (lnum * 0x40);*/ + OSReport("Loading file...\n"); + FileHandle fh; + void *info = LoadFile(&fh, "/NewerRes/LevelInfo.bin"); + + LevelInfo_Prepare(&fh); + LevelInfo_Entry *entry = LevelInfo_Search(info, wnum, lnum); + char *worldname = LevelInfo_GetName(info, entry); + char *levelname = ""; + OSReport("Got name : %s\n", worldname); + + void *vtable = *((void**)levelObj); + void *funcaddr = *((void**)((u32)vtable+0x7C)); + int (*SetString)(void*, unsigned short*, unsigned short); + SetString = (int(*)(void*, unsigned short*, unsigned short))funcaddr; + + unsigned short wbuffer[0x40], lbuffer[0x40]; + for (int i = 0; i < 0x40; i++) { + wbuffer[i] = (unsigned short)worldname[i]; + lbuffer[i] = (unsigned short)levelname[i]; + } + + SetString(worldObj, wbuffer, 0); + SetString(levelObj, lbuffer, 0); + + OSReport("Freeing file\n"); + FreeFile(&fh); + OSReport("Inserted strings\n"); + } + } else { + OSReport("Skipped\n"); + } + + OSReport("Reached the end of DoNames\n"); + return state; +} + +int DoNamesTest2(int state, u32 ptr) { + OSReport("TEST 1:%08X 2:%08X\n", state, ptr); + return DoNames(state); +} diff --git a/src/levelspecial.cpp b/src/levelspecial.cpp index 7ad69ff..e075773 100644 --- a/src/levelspecial.cpp +++ b/src/levelspecial.cpp @@ -1,30 +1,30 @@ -#include <common.h>
-#include <game.h>
-
-struct LevelSpecial {
- 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
- u8 type; // 0x3D4
- u8 effect; // 0x3D5
- u8 lastEvState; // 0x3D6
- u8 func; // 0x3D7
-};
-
-struct EventTable_t {
- u64 events;
- // ...
-};
- -extern EventTable_t *EventTable;
+#include <common.h> +#include <game.h> + +struct LevelSpecial { + 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 + u8 type; // 0x3D4 + u8 effect; // 0x3D5 + u8 lastEvState; // 0x3D6 + u8 func; // 0x3D7 +}; + +struct EventTable_t { + u64 events; + // ... +}; + +extern EventTable_t *EventTable; extern u16 TimeStopFlag; extern u32 TimerBranch; @@ -50,17 +50,17 @@ float GlobalRiderFloatModifications [] = {1, 0.6, 0.7, 0.9, 1, 1, 1, 1.1, 1.25, extern "C" dAc_Py_c *GetSpecificPlayerActor(int number); -void LevelSpecial_Update(LevelSpecial *self);
+void LevelSpecial_Update(LevelSpecial *self); bool ResetAfterLevel(); -#define ACTIVATE 1
-#define DEACTIVATE 0
-
-fBase_c *FindActorByID(u32 id);
+#define ACTIVATE 1 +#define DEACTIVATE 0 +fBase_c *FindActorByID(u32 id); -bool ResetAfterLevel(void) {
+ +bool ResetAfterLevel(void) { TimeStopFlag = 0; TimerBranch = 0x3403FFA4; MarioDescentRate = -4; @@ -75,50 +75,50 @@ bool ResetAfterLevel(void) { AlwaysDrawFlag = 0x9421FFF0; AlwaysDrawBranch = 0x7C0802A6; ZOrderOn = 0; - return true;
-}
-
-bool LevelSpecial_Create(LevelSpecial *self) {
- char eventNum = (self->settings >> 24) & 0xFF;
- self->eventFlag = (u64)1 << (eventNum - 1);
-
- OSReport("Special Event created @%p event %d\n", self, eventNum);
-
- OSReport("Eventnum: %d. Event flag: %08x %08x\n", eventNum, self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF);
-
- self->type = (self->settings) & 15;
- self->effect = (self->settings >> 4) & 15;
-
- self->lastEvState = 0xFF;
-
- LevelSpecial_Update(self);
-
- return true;
-}
-
-bool LevelSpecial_Execute(LevelSpecial *self) {
- LevelSpecial_Update(self);
- return true;
-}
-
- -void LevelSpecial_Update(LevelSpecial *self) {
- //OSReport("%08x%08x", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF);
-
- u8 newEvState = 0;
- if (EventTable->events & self->eventFlag)
- newEvState = 1;
-
- if (newEvState == self->lastEvState)
- return;
-
- OSReport("Event state changed from %d to %d\n", self->lastEvState, newEvState);
-
- u8 offState;
+ return true; +} + +bool LevelSpecial_Create(LevelSpecial *self) { + char eventNum = (self->settings >> 24) & 0xFF; + self->eventFlag = (u64)1 << (eventNum - 1); + + OSReport("Special Event created @%p event %d\n", self, eventNum); + + OSReport("Eventnum: %d. Event flag: %08x %08x\n", eventNum, self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF); + + self->type = (self->settings) & 15; + self->effect = (self->settings >> 4) & 15; + + self->lastEvState = 0xFF; + + LevelSpecial_Update(self); + + return true; +} + +bool LevelSpecial_Execute(LevelSpecial *self) { + LevelSpecial_Update(self); + return true; +} + + +void LevelSpecial_Update(LevelSpecial *self) { + //OSReport("%08x%08x", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF); + + u8 newEvState = 0; + if (EventTable->events & self->eventFlag) + newEvState = 1; + + if (newEvState == self->lastEvState) + return; + + OSReport("Event state changed from %d to %d\n", self->lastEvState, newEvState); + + u8 offState; if (newEvState == ACTIVATE) - {
- offState = (newEvState == 1) ? 1 : 0;
- OSReport("Activate Special Event!", offState);
+ { + offState = (newEvState == 1) ? 1 : 0; + OSReport("Activate Special Event!", offState); switch (self->type) { case 1: // Time Freeze @@ -251,12 +251,12 @@ void LevelSpecial_Update(LevelSpecial *self) { default: break; } - }
-
+ } + else - {
- offState = (newEvState == 1) ? 0 : 1;
- OSReport("Deactivate Special Event", offState);
+ { + offState = (newEvState == 1) ? 0 : 1; + OSReport("Deactivate Special Event", offState); switch (self->type) { case 1: // Time Freeze @@ -371,14 +371,14 @@ void LevelSpecial_Update(LevelSpecial *self) { default: break; } - }
- OSReport("Special Event is %d\n", offState);
+ } + OSReport("Special Event is %d\n", offState); - OSReport("Success!\n");
-
-
- self->lastEvState = newEvState;
+ OSReport("Success!\n"); + + + self->lastEvState = newEvState; } diff --git a/src/linegod.S b/src/linegod.S index ed636dd..811fa84 100644 --- a/src/linegod.S +++ b/src/linegod.S @@ -1,53 +1,53 @@ -.text
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.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 f2,2; .set f3,3
-#endif
-
-.align 4
-.extern ContinueBgActorSpawn
-.global BgActorSpawnFix
-BgActorSpawnFix:
- mr 30, 3
-
- #lis 3, TestStr@h
- #ori 3, 3, TestStr@l
- #mr 4, 30
- #crclr 4*cr1+eq
- #bl OSReport
-
- lbz 0, 7(30)
- cmpwi 0, 1
- beq JustRet
- b ContinueBgActorSpawn
-JustRet:
-
- lwz 31, 0x3C(1)
- lwz 30, 0x38(1)
- lwz 0, 0x44(1)
- mtlr 0
- addi 1, 1, 0x40
- blr
-
-
-.global BgActorSetInfoFix
-BgActorSetInfoFix:
- sth 4, 0(3)
- sth 5, 2(3)
- sth 6, 4(3)
- stb 7, 6(3)
- li 4, 0
- stb 4, 7(3)
- blr
-
-
-#.data
-#TestStr:
-# .string "Spawning actor %p\n"
-# .align 4
+.text + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f2,2; .set f3,3 +#endif + +.align 4 +.extern ContinueBgActorSpawn +.global BgActorSpawnFix +BgActorSpawnFix: + mr 30, 3 + + #lis 3, TestStr@h + #ori 3, 3, TestStr@l + #mr 4, 30 + #crclr 4*cr1+eq + #bl OSReport + + lbz 0, 7(30) + cmpwi 0, 1 + beq JustRet + b ContinueBgActorSpawn +JustRet: + + lwz 31, 0x3C(1) + lwz 30, 0x38(1) + lwz 0, 0x44(1) + mtlr 0 + addi 1, 1, 0x40 + blr + + +.global BgActorSetInfoFix +BgActorSetInfoFix: + sth 4, 0(3) + sth 5, 2(3) + sth 6, 4(3) + stb 7, 6(3) + li 4, 0 + stb 4, 7(3) + blr + + +#.data +#TestStr: +# .string "Spawning actor %p\n" +# .align 4 diff --git a/src/linegod.cpp b/src/linegod.cpp index de08fa0..dcadf59 100644 --- a/src/linegod.cpp +++ b/src/linegod.cpp @@ -1,213 +1,213 @@ -#include <common.h>
-#include <game.h>
-
-// TODO: make "No Deactivation"
-
-struct BgActor {
- u16 def_id; // 0x00
- u16 x; // 0x02
- u16 y; // 0x04
- u8 layer; // 0x06
- u8 EXTRA_off; // 0x07
- u32 actor_id; // 0x08
-};
-
-struct BgActorDef {
- u32 tilenum;
- u16 actor;
- u8 _06[2];
- float x;
- float y;
- float z;
- float another_x;
- float another_y;
- u32 extra_var;
-};
-
-struct dBgActorManager_c {
- u32 vtable; // 0x00
- u8 _04[0x34]; // 0x04
- BgActor *array; // 0x38
- u32 count; // 0x3C
- u32 type; // 0x40
-};
-
-extern dBgActorManager_c *dBgActorManager;
-
-extern BgActorDef *BgActorDefs;
-
-struct BG_GM_hax {
- u8 _00[0x8FE64];
- float _0x8FE64;
- float _0x8FE68;
- float _0x8FE6C;
- float _0x8FE70;
-};
-
-extern BG_GM_hax *BG_GM_ptr;
-
-// Regular class is 0x3D0.
-// Let's add stuff to the end just to be safe.
-// Size is now 0x400
-// 80898798 38600400
-
-#define LINEGOD_FUNC_ACTIVATE 0
-#define LINEGOD_FUNC_DEACTIVATE 1
-
-struct LineGod {
- 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
- u64 eventFlag; // 0x3D0
- u8 func; // 0x3D4
- u8 width; // 0x3D5
- u8 height; // 0x3D6
- u8 lastEvState; // 0x3D7
- BgActor *ac[8]; // 0x3D8
-};
-
-struct EventTable_t {
- u64 events;
- // ...
-};
-
-extern EventTable_t *EventTable;
-
-fBase_c *FindActorByID(u32 id);
-
-u16 *GetPointerToTile(BG_GM_hax *self, u16 x, u16 y, u16 layer, short *blockID_p, bool unused);
-
-
-
-void LineGod_BuildList(LineGod *self);
-bool LineGod_AppendToList(LineGod *self, BgActor *ac);
-void LineGod_Update(LineGod *self);
-
-
-bool LineGod_Create(LineGod *self) {
- char eventNum = (self->settings >> 24) & 0xFF;
- self->eventFlag = (u64)1 << (eventNum - 1);
-
- OSReport("LineGod created @%p event %d\n", self, eventNum);
-
- //OSReport("Eventnum: %d. Event flag: %08x %08x\n", eventNum, self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF);
-
- self->func = (self->settings) & 1;
- self->width = (self->settings >> 4) & 15;
- self->height = (self->settings >> 8) & 15;
-
- self->lastEvState = 0xFF;
-
- LineGod_BuildList(self);
- LineGod_Update(self);
-
- return true;
-}
-
-bool LineGod_Execute(LineGod *self) {
- LineGod_Update(self);
- return true;
-}
-
-void LineGod_BuildList(LineGod *self) {
- for (int clearIdx = 0; clearIdx < 8; clearIdx++) {
- self->ac[clearIdx] = 0;
- }
-
-
- u16 x1 = self->x / 16;
- u16 x2 = x1 + self->width - 1;
- u16 y1 = (-self->y) / 16;
- u16 y2 = y1 + self->height - 1;
- OSReport("Searching ... %d,%d - %d,%d\n", x1, y1, x2, y2);
-
- x1 -= (BG_GM_ptr->_0x8FE64 / 16);
- x2 -= (BG_GM_ptr->_0x8FE64 / 16);
- y1 += (BG_GM_ptr->_0x8FE6C / 16);
- y2 += (BG_GM_ptr->_0x8FE6C / 16);
- OSReport("Manipulated offsets ... %d,%d - %d,%d\n", x1, y1, x2, y2);
-
- OSReport("My array: %p\n", &self->ac[0]);
-
- for (int i = 0; i < dBgActorManager->count; i++) {
- BgActor *ac = &dBgActorManager->array[i];
- //OSReport("Actor %p: %d,%d", ac, ac->x, ac->y);
-
- if (ac->x >= x1 && ac->x <= x2 && ac->y >= y1 && ac->y <= y2)
- LineGod_AppendToList(self, ac);
- }
-}
-
-bool LineGod_AppendToList(LineGod *self, BgActor *ac) {
- OSReport("Adding %p to the list (pos: %d,%d)\n", ac, ac->x, ac->y);
-
- for (int search = 0; search < 8; search++) {
- if (self->ac[search] == 0) {
- self->ac[search] = ac;
- return true;
- }
- }
-
- return false;
-}
-
-void LineGod_Update(LineGod *self) {
- //OSReport("%08x%08x", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF);
-
- u8 newEvState = 0;
- if (EventTable->events & self->eventFlag)
- newEvState = 1;
-
- if (newEvState == self->lastEvState)
- return;
-
- u16 x_bias = (BG_GM_ptr->_0x8FE64 / 16);
- u16 y_bias = -(BG_GM_ptr->_0x8FE6C / 16);
-
- OSReport("Event state changed from %d to %d\n", self->lastEvState, newEvState);
-
- u8 offState;
- if (self->func == LINEGOD_FUNC_ACTIVATE)
- offState = (newEvState == 1) ? 1 : 0;
- else
- offState = (newEvState == 1) ? 0 : 1;
-
- //OSReport("offState is %d\n", offState);
-
- for (int i = 0; i < 8; i++) {
- if (self->ac[i] != 0) {
- BgActor *ac = self->ac[i];
-
- //OSReport("Assigning %d to %p->EXTRA_off (actor ID is %d)\n", offState, ac, ac->actor_id);
-
- ac->EXTRA_off = offState;
- if (offState == 1 && ac->actor_id != 0) {
- fBase_c *assoc_ac = FindActorByID(ac->actor_id);
- //OSReport("Got actor: %p\n", assoc_ac);
- if (assoc_ac != 0)
- assoc_ac->Delete();
- ac->actor_id = 0;
- }
-
- u16 *tile = GetPointerToTile(BG_GM_ptr, (ac->x + x_bias) * 16, (ac->y + y_bias) * 16, 0, 0, 0);
- if (offState == 1)
- *tile = 0;
- else
- *tile = BgActorDefs[ac->def_id].tilenum;
-
- //OSReport("def_id: %d; def_ptr: %p\n", ac->def_id, &(BgActorDefs[ac->def_id]));
- //OSReport("Placed tile %d at %p [%d,%d]\n", *tile, tile, ac->x+x_bias, ac->y+y_bias);
- }
- }
-
- //OSReport("Success!\n");
-
-
- self->lastEvState = newEvState;
-}
+#include <common.h> +#include <game.h> + +// TODO: make "No Deactivation" + +struct BgActor { + u16 def_id; // 0x00 + u16 x; // 0x02 + u16 y; // 0x04 + u8 layer; // 0x06 + u8 EXTRA_off; // 0x07 + u32 actor_id; // 0x08 +}; + +struct BgActorDef { + u32 tilenum; + u16 actor; + u8 _06[2]; + float x; + float y; + float z; + float another_x; + float another_y; + u32 extra_var; +}; + +struct dBgActorManager_c { + u32 vtable; // 0x00 + u8 _04[0x34]; // 0x04 + BgActor *array; // 0x38 + u32 count; // 0x3C + u32 type; // 0x40 +}; + +extern dBgActorManager_c *dBgActorManager; + +extern BgActorDef *BgActorDefs; + +struct BG_GM_hax { + u8 _00[0x8FE64]; + float _0x8FE64; + float _0x8FE68; + float _0x8FE6C; + float _0x8FE70; +}; + +extern BG_GM_hax *BG_GM_ptr; + +// Regular class is 0x3D0. +// Let's add stuff to the end just to be safe. +// Size is now 0x400 +// 80898798 38600400 + +#define LINEGOD_FUNC_ACTIVATE 0 +#define LINEGOD_FUNC_DEACTIVATE 1 + +struct LineGod { + 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 + u64 eventFlag; // 0x3D0 + u8 func; // 0x3D4 + u8 width; // 0x3D5 + u8 height; // 0x3D6 + u8 lastEvState; // 0x3D7 + BgActor *ac[8]; // 0x3D8 +}; + +struct EventTable_t { + u64 events; + // ... +}; + +extern EventTable_t *EventTable; + +fBase_c *FindActorByID(u32 id); + +u16 *GetPointerToTile(BG_GM_hax *self, u16 x, u16 y, u16 layer, short *blockID_p, bool unused); + + + +void LineGod_BuildList(LineGod *self); +bool LineGod_AppendToList(LineGod *self, BgActor *ac); +void LineGod_Update(LineGod *self); + + +bool LineGod_Create(LineGod *self) { + char eventNum = (self->settings >> 24) & 0xFF; + self->eventFlag = (u64)1 << (eventNum - 1); + + OSReport("LineGod created @%p event %d\n", self, eventNum); + + //OSReport("Eventnum: %d. Event flag: %08x %08x\n", eventNum, self->eventFlag >> 32, self->eventFlag & 0xFFFFFFFF); + + self->func = (self->settings) & 1; + self->width = (self->settings >> 4) & 15; + self->height = (self->settings >> 8) & 15; + + self->lastEvState = 0xFF; + + LineGod_BuildList(self); + LineGod_Update(self); + + return true; +} + +bool LineGod_Execute(LineGod *self) { + LineGod_Update(self); + return true; +} + +void LineGod_BuildList(LineGod *self) { + for (int clearIdx = 0; clearIdx < 8; clearIdx++) { + self->ac[clearIdx] = 0; + } + + + u16 x1 = self->x / 16; + u16 x2 = x1 + self->width - 1; + u16 y1 = (-self->y) / 16; + u16 y2 = y1 + self->height - 1; + OSReport("Searching ... %d,%d - %d,%d\n", x1, y1, x2, y2); + + x1 -= (BG_GM_ptr->_0x8FE64 / 16); + x2 -= (BG_GM_ptr->_0x8FE64 / 16); + y1 += (BG_GM_ptr->_0x8FE6C / 16); + y2 += (BG_GM_ptr->_0x8FE6C / 16); + OSReport("Manipulated offsets ... %d,%d - %d,%d\n", x1, y1, x2, y2); + + OSReport("My array: %p\n", &self->ac[0]); + + for (int i = 0; i < dBgActorManager->count; i++) { + BgActor *ac = &dBgActorManager->array[i]; + //OSReport("Actor %p: %d,%d", ac, ac->x, ac->y); + + if (ac->x >= x1 && ac->x <= x2 && ac->y >= y1 && ac->y <= y2) + LineGod_AppendToList(self, ac); + } +} + +bool LineGod_AppendToList(LineGod *self, BgActor *ac) { + OSReport("Adding %p to the list (pos: %d,%d)\n", ac, ac->x, ac->y); + + for (int search = 0; search < 8; search++) { + if (self->ac[search] == 0) { + self->ac[search] = ac; + return true; + } + } + + return false; +} + +void LineGod_Update(LineGod *self) { + //OSReport("%08x%08x", EventTable->events >> 32, EventTable->events & 0xFFFFFFFF); + + u8 newEvState = 0; + if (EventTable->events & self->eventFlag) + newEvState = 1; + + if (newEvState == self->lastEvState) + return; + + u16 x_bias = (BG_GM_ptr->_0x8FE64 / 16); + u16 y_bias = -(BG_GM_ptr->_0x8FE6C / 16); + + OSReport("Event state changed from %d to %d\n", self->lastEvState, newEvState); + + u8 offState; + if (self->func == LINEGOD_FUNC_ACTIVATE) + offState = (newEvState == 1) ? 1 : 0; + else + offState = (newEvState == 1) ? 0 : 1; + + //OSReport("offState is %d\n", offState); + + for (int i = 0; i < 8; i++) { + if (self->ac[i] != 0) { + BgActor *ac = self->ac[i]; + + //OSReport("Assigning %d to %p->EXTRA_off (actor ID is %d)\n", offState, ac, ac->actor_id); + + ac->EXTRA_off = offState; + if (offState == 1 && ac->actor_id != 0) { + fBase_c *assoc_ac = FindActorByID(ac->actor_id); + //OSReport("Got actor: %p\n", assoc_ac); + if (assoc_ac != 0) + assoc_ac->Delete(); + ac->actor_id = 0; + } + + u16 *tile = GetPointerToTile(BG_GM_ptr, (ac->x + x_bias) * 16, (ac->y + y_bias) * 16, 0, 0, 0); + if (offState == 1) + *tile = 0; + else + *tile = BgActorDefs[ac->def_id].tilenum; + + //OSReport("def_id: %d; def_ptr: %p\n", ac->def_id, &(BgActorDefs[ac->def_id])); + //OSReport("Placed tile %d at %p [%d,%d]\n", *tile, tile, ac->x+x_bias, ac->y+y_bias); + } + } + + //OSReport("Success!\n"); + + + self->lastEvState = newEvState; +} diff --git a/src/msgbox.S b/src/msgbox.S index db0021c..ac49676 100644 --- a/src/msgbox.S +++ b/src/msgbox.S @@ -1,37 +1,37 @@ -.text
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.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 f2,2; .set f3,3
-#endif
-
-.extern Global5758
-
-# -if param & 1 /and/ messagebox is on,
-# otherwise, return Global5758 & param
-
-.global Query5758Replacement
-Query5758Replacement:
- mr 5, 3 # save param
- lis 4, Global5758@h
- ori 4, 4, Global5758@l
- lwz 0, 0(4) # get 5758
- and 3, 0, 3 # AND with param
- andi. 5, 5, 1 # if param & 1 == 0..
- beqlr # then return
-
- lis 4, MessageBoxIsShowing@h
- ori 4, 4, MessageBoxIsShowing@l
- lwz 4, 0(4)
- or 3, 3, 4 # otherwise, OR with MessageBoxIsShowing
- blr # then return
-
-
-.data
-MessageBoxIsShowing:
- .long 0
+.text + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f2,2; .set f3,3 +#endif + +.extern Global5758 + +# -if param & 1 /and/ messagebox is on, +# otherwise, return Global5758 & param + +.global Query5758Replacement +Query5758Replacement: + mr 5, 3 # save param + lis 4, Global5758@h + ori 4, 4, Global5758@l + lwz 0, 0(4) # get 5758 + and 3, 0, 3 # AND with param + andi. 5, 5, 1 # if param & 1 == 0.. + beqlr # then return + + lis 4, MessageBoxIsShowing@h + ori 4, 4, MessageBoxIsShowing@l + lwz 4, 0(4) + or 3, 3, 4 # otherwise, OR with MessageBoxIsShowing + blr # then return + + +.data +MessageBoxIsShowing: + .long 0 diff --git a/src/msgbox.cpp b/src/msgbox.cpp index 63eb994..f99f73f 100644 --- a/src/msgbox.cpp +++ b/src/msgbox.cpp @@ -1,227 +1,227 @@ -#include <common.h>
-#include <game.h>
-#include "layoutlib.h"
-#include "fileload.h"
-
-
-struct MsgData_Header {
- u32 magic;
- u32 msgCount;
-};
-
-struct MsgData_Entry {
- u32 number;
- u32 titleOffset;
- u32 msgOffset;
-};
-
-
-
-struct dMsgBoxManager_c {
- // 0x00
- int ID;
- unsigned int Settings;
- short Type;
- char Unk_0A;
- char Unk_0B;
- char Unk_0C;
- char Unk_0D;
- char Unk_0E;
- char Unk_0F;
-
- // 0x10
- void *CONNECT_parent;
- void *CONNECT_child;
- void *CONNECT_prev;
- void *CONNECT_next;
-
- // 0x20
- void *CONNECT_thisObj;
- void *EXECUTE_prev;
- void *EXECUTE_next;
- void *EXECUTE_thisObj;
-
- // 0x30
- short Unk_30;
- short Unk_32;
- void *DRAW_prev;
- void *DRAW_next;
- void *DRAW_thisObj;
-
- // 0x40
- short Unk_40;
- short Unk_42;
- void *IDLookup_prev;
- void *IDLookup_next;
- void *IDLookup_thisObj;
-
- // 0x50
- void *Unk_50;
- int Unk_54;
- int Unk_58;
- void *Unk_5C;
-
- // 0x60
- void *vtable;
- int Unk_64; // dBase_c starts here
- char *weirdTypeString;
- char *actorName;
-
- // dMsgBoxManager_c starts here (offset 0x70)
- Layout *layout;
- int state;
- FileHandle msgDataFH;
-
- // 0x80
- void *msgData;
-
- // current allocated class size: 0xD0
-};
-
-
-#define STATE_NULL 0
-#define STATE_BOX_APPEAR_WAIT 1
-#define STATE_BUTTON_APPEAR_WAIT 2
-#define STATE_SHOWN 3
-#define STATE_BUTTON_DISAPPEAR_WAIT 4
-#define STATE_BOX_DISAPPEAR_WAIT 5
-
-#define animBoxAppear 0
-#define animBoxDisappear 1
-#define animButtonAppear 2
-#define animButtonDisappear 3
-
-extern int MessageBoxIsShowing;
-dMsgBoxManager_c *CurrentMsgBoxManager;
-
-const char *brlan_BoxAppear = "BoxAppear.brlan";
-const char *brlan_BoxDisappear = "BoxDisappear.brlan";
-const char *brlan_ButtonAppear = "ButtonAppear.brlan";
-const char *brlan_ButtonDisappear = "ButtonDisappear.brlan";
-
-const char *group_Box = "G_Box";
-const char *group_Button = "G_Button";
-
-bool dMsgBoxManager_c__Create(dMsgBoxManager_c *self) {
- self->layout = (Layout*)AllocFromGameHeap1(sizeof(Layout));
-
- if (!self->layout) {
- OSReport("memalloc fail\n");
- InfiniteLoop;
- }
-
- EmbeddedLayout_ctor(self->layout);
- EmbeddedLayout_LoadArc(self->layout, "NewerRes/msgbox.arc");
-
- if (!EmbeddedLayout_Build(self->layout, "MessageBox.brlyt", 0)) {
- OSReport("build fail\n");
- InfiniteLoop;
- }
-
-
- const char *anims[4] = {brlan_BoxAppear, brlan_BoxDisappear, brlan_ButtonAppear, brlan_ButtonDisappear};
- EmbeddedLayout_LoadBrlans(self->layout, anims, 4);
-
- const char *groups[4] = {group_Box, group_Box, group_Button, group_Button};
-
- int mappings[4] = {0, 1, 2, 3};
- EmbeddedLayout_LoadGroups(self->layout, groups, mappings, 4);
-
- EmbeddedLayout_DisableAllAnims(self->layout);
-
- for (int i = 0; i < 4; i++) {
- EmbeddedLayout_ResetAnimToInitialState(self->layout, i, false);
- }
-
- self->msgData = LoadFile(&self->msgDataFH, "/NewerRes/MsgData.bin");
-
- self->state = STATE_NULL;
- self->layout->drawOrder = 0xA0;
-
- CurrentMsgBoxManager = self;
-
- return true;
-}
-
-bool dMsgBoxManager_c__Execute(dMsgBoxManager_c *self) {
- if (self->state == STATE_NULL)
- return true;
-
-
- switch (self->state) {
- /**************************************************************************/
- case STATE_BOX_APPEAR_WAIT:
- if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animBoxAppear)) {
- EmbeddedLayout_EnableNonLoopAnim(self->layout, animButtonAppear, false);
- self->state = STATE_BUTTON_APPEAR_WAIT;
- }
-
- break;
-
- /**************************************************************************/
- case STATE_BUTTON_APPEAR_WAIT:
- if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animButtonAppear)) {
- self->state = STATE_SHOWN;
- }
-
- break;
-
- /**************************************************************************/
- case STATE_SHOWN:
- if (false) {
- EmbeddedLayout_EnableNonLoopAnim(self->layout, animButtonDisappear, false);
- self->state = STATE_BUTTON_DISAPPEAR_WAIT;
- }
-
- break;
-
- /**************************************************************************/
- case STATE_BUTTON_DISAPPEAR_WAIT:
- if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animButtonDisappear)) {
- EmbeddedLayout_EnableNonLoopAnim(self->layout, animBoxDisappear, false);
- self->state = STATE_BOX_DISAPPEAR_WAIT;
- }
-
- break;
-
- /**************************************************************************/
- case STATE_BOX_DISAPPEAR_WAIT:
- if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animBoxDisappear)) {
- self->state = STATE_NULL;
-
- EmbeddedLayout_DisableAllAnims(self->layout);
-
- for (int i = 0; i < 4; i++) {
- EmbeddedLayout_ResetAnimToInitialState(self->layout, i, false);
- }
- }
- break;
- }
-
-
- EmbeddedLayout_Process(self->layout);
- EmbeddedLayout_UpdateMatrix(self->layout);
-
- return true;
-}
-
-bool dMsgBoxManager_c__Draw(dMsgBoxManager_c *self) {
- if (self->state != STATE_NULL) {
- EmbeddedLayout_AddToDrawList(self->layout);
- }
-
- return true;
-}
-
-bool dMsgBoxManager_c__Delete(dMsgBoxManager_c *self) {
- EmbeddedLayout_FreeArc(self->layout);
- EmbeddedLayout_Free(self->layout);
- EmbeddedLayout_dtor(self->layout, false);
- FreeFromGameHeap1(self->layout);
-
- CurrentMsgBoxManager = 0;
-
- return true;
-}
-
-
+#include <common.h> +#include <game.h> +#include "layoutlib.h" +#include "fileload.h" + + +struct MsgData_Header { + u32 magic; + u32 msgCount; +}; + +struct MsgData_Entry { + u32 number; + u32 titleOffset; + u32 msgOffset; +}; + + + +struct dMsgBoxManager_c { + // 0x00 + int ID; + unsigned int Settings; + short Type; + char Unk_0A; + char Unk_0B; + char Unk_0C; + char Unk_0D; + char Unk_0E; + char Unk_0F; + + // 0x10 + void *CONNECT_parent; + void *CONNECT_child; + void *CONNECT_prev; + void *CONNECT_next; + + // 0x20 + void *CONNECT_thisObj; + void *EXECUTE_prev; + void *EXECUTE_next; + void *EXECUTE_thisObj; + + // 0x30 + short Unk_30; + short Unk_32; + void *DRAW_prev; + void *DRAW_next; + void *DRAW_thisObj; + + // 0x40 + short Unk_40; + short Unk_42; + void *IDLookup_prev; + void *IDLookup_next; + void *IDLookup_thisObj; + + // 0x50 + void *Unk_50; + int Unk_54; + int Unk_58; + void *Unk_5C; + + // 0x60 + void *vtable; + int Unk_64; // dBase_c starts here + char *weirdTypeString; + char *actorName; + + // dMsgBoxManager_c starts here (offset 0x70) + Layout *layout; + int state; + FileHandle msgDataFH; + + // 0x80 + void *msgData; + + // current allocated class size: 0xD0 +}; + + +#define STATE_NULL 0 +#define STATE_BOX_APPEAR_WAIT 1 +#define STATE_BUTTON_APPEAR_WAIT 2 +#define STATE_SHOWN 3 +#define STATE_BUTTON_DISAPPEAR_WAIT 4 +#define STATE_BOX_DISAPPEAR_WAIT 5 + +#define animBoxAppear 0 +#define animBoxDisappear 1 +#define animButtonAppear 2 +#define animButtonDisappear 3 + +extern int MessageBoxIsShowing; +dMsgBoxManager_c *CurrentMsgBoxManager; + +const char *brlan_BoxAppear = "BoxAppear.brlan"; +const char *brlan_BoxDisappear = "BoxDisappear.brlan"; +const char *brlan_ButtonAppear = "ButtonAppear.brlan"; +const char *brlan_ButtonDisappear = "ButtonDisappear.brlan"; + +const char *group_Box = "G_Box"; +const char *group_Button = "G_Button"; + +bool dMsgBoxManager_c__Create(dMsgBoxManager_c *self) { + self->layout = (Layout*)AllocFromGameHeap1(sizeof(Layout)); + + if (!self->layout) { + OSReport("memalloc fail\n"); + InfiniteLoop; + } + + EmbeddedLayout_ctor(self->layout); + EmbeddedLayout_LoadArc(self->layout, "NewerRes/msgbox.arc"); + + if (!EmbeddedLayout_Build(self->layout, "MessageBox.brlyt", 0)) { + OSReport("build fail\n"); + InfiniteLoop; + } + + + const char *anims[4] = {brlan_BoxAppear, brlan_BoxDisappear, brlan_ButtonAppear, brlan_ButtonDisappear}; + EmbeddedLayout_LoadBrlans(self->layout, anims, 4); + + const char *groups[4] = {group_Box, group_Box, group_Button, group_Button}; + + int mappings[4] = {0, 1, 2, 3}; + EmbeddedLayout_LoadGroups(self->layout, groups, mappings, 4); + + EmbeddedLayout_DisableAllAnims(self->layout); + + for (int i = 0; i < 4; i++) { + EmbeddedLayout_ResetAnimToInitialState(self->layout, i, false); + } + + self->msgData = LoadFile(&self->msgDataFH, "/NewerRes/MsgData.bin"); + + self->state = STATE_NULL; + self->layout->drawOrder = 0xA0; + + CurrentMsgBoxManager = self; + + return true; +} + +bool dMsgBoxManager_c__Execute(dMsgBoxManager_c *self) { + if (self->state == STATE_NULL) + return true; + + + switch (self->state) { + /**************************************************************************/ + case STATE_BOX_APPEAR_WAIT: + if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animBoxAppear)) { + EmbeddedLayout_EnableNonLoopAnim(self->layout, animButtonAppear, false); + self->state = STATE_BUTTON_APPEAR_WAIT; + } + + break; + + /**************************************************************************/ + case STATE_BUTTON_APPEAR_WAIT: + if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animButtonAppear)) { + self->state = STATE_SHOWN; + } + + break; + + /**************************************************************************/ + case STATE_SHOWN: + if (false) { + EmbeddedLayout_EnableNonLoopAnim(self->layout, animButtonDisappear, false); + self->state = STATE_BUTTON_DISAPPEAR_WAIT; + } + + break; + + /**************************************************************************/ + case STATE_BUTTON_DISAPPEAR_WAIT: + if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animButtonDisappear)) { + EmbeddedLayout_EnableNonLoopAnim(self->layout, animBoxDisappear, false); + self->state = STATE_BOX_DISAPPEAR_WAIT; + } + + break; + + /**************************************************************************/ + case STATE_BOX_DISAPPEAR_WAIT: + if (!EmbeddedLayout_CheckIfAnimationIsOn(self->layout, animBoxDisappear)) { + self->state = STATE_NULL; + + EmbeddedLayout_DisableAllAnims(self->layout); + + for (int i = 0; i < 4; i++) { + EmbeddedLayout_ResetAnimToInitialState(self->layout, i, false); + } + } + break; + } + + + EmbeddedLayout_Process(self->layout); + EmbeddedLayout_UpdateMatrix(self->layout); + + return true; +} + +bool dMsgBoxManager_c__Draw(dMsgBoxManager_c *self) { + if (self->state != STATE_NULL) { + EmbeddedLayout_AddToDrawList(self->layout); + } + + return true; +} + +bool dMsgBoxManager_c__Delete(dMsgBoxManager_c *self) { + EmbeddedLayout_FreeArc(self->layout); + EmbeddedLayout_Free(self->layout); + EmbeddedLayout_dtor(self->layout, false); + FreeFromGameHeap1(self->layout); + + CurrentMsgBoxManager = 0; + + return true; +} + + diff --git a/src/poweruphax.S b/src/poweruphax.S index bfd8c83..3db06c7 100644 --- a/src/poweruphax.S +++ b/src/poweruphax.S @@ -1,689 +1,689 @@ -.text
-.align 4
-.set sp, 1
-
-.extern returnFromGPSFASixth
-.extern daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot
-.extern dAcPy_c__ChangePowerupWithAnimation
-.extern PlayPlayerSound
-.extern CreateActor
-.extern PlayerProjectileShooting
-.extern Actor_SearchByName
-.extern SomeTable_802F5440
-.extern SomeTable_802F5580
-.extern SomeTable_802F56C0
-.extern BlahTable
-.extern continuePlumberSetPowerupTexture
-.extern doneSettingThePowerupTexture
-.extern doneSettingThePowerupTexture2
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.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 f2,2; .set f3,3
-.set f1,1; .set f30,30; .set f31,31
-#endif
-
-.global GetInfoFromDumbTable
-GetInfoFromDumbTable:
- lis r3, SomeTable@h
- ori r3, r3, SomeTable@l
-
- slwi r4, r4, 2
- slwi r0, r5, 6
-
- lwzx r3, r3, r4
- add r3, r3, r0
- blr
-
-
-
-
-.global FukidashiFix
-FukidashiFix:
- lis r7, ZeroFloat@h
- ori r7, r7, ZeroFloat@l
-
- lis r8, FukidashiTable2@h
- ori r8, r8, FukidashiTable2@l
-
- mulli r6, r4, 0x20
- slwi r0, r5, 2
- add r0, r0, r6
-
- lfs f0, 0(r7)
- lfsx f1, r8, r0
-
- stfs f0, 0x1DC(r3)
- stfs f1, 0x1E0(r3)
- stfs f0, 0x1E4(r3)
-
- blr
-
-
-
-
-.global PlayerGetHeight
-PlayerGetHeight:
- lwz r0, 0x14D4(r3)
-
- lwz r4, 0x1090(r3)
- slwi r4, r4, 3
-
- cmpwi r0, 0
- beq useNormal
- cmpwi r0, 1
- bne useDucking
-
-useNormal:
- lis r3, PlayerHeightsNormal@h
- ori r3, r3, PlayerHeightsNormal@l
- b gotOffset
-
-useDucking:
- lis r3, PlayerHeightsDucking@h
- ori r3, r3, PlayerHeightsDucking@l
-
-gotOffset:
- lfsx f1, r3, r4
- blr
-
-
-
-.global WtfEver
-WtfEver:
- lis r3, WtfEverTable@h
- ori r3, r3, WtfEverTable@l
- lfsx f0, r3, r0
- blr
-
-
-
-.global YetAnother
-YetAnother:
- lis r3, YetAnotherTable@h
- ori r3, r3, YetAnotherTable@l
- lfsx f0, r3, r0
- blr
-
-
-
-
-.global GetWeirdScaleTable
-GetWeirdScaleTable:
- lis r5, WeirdScaleTable@h
- ori r5, r5, WeirdScaleTable@l
- lfsx f1, r5, r0
- blr
-
-
-
-
-
-.global GetAsdfTable
-GetAsdfTable:
- extsb r0, r4
- cmpwi r0, -1
- bne dontGetThisOne
-
- lwz r0, 0x1090(r3)
- extsb r4, r0
-
-dontGetThisOne:
- extsb r0, r4
-
- lis r3, AsdfTable@h
- ori r3, r3, AsdfTable@l
- lbzx r3, r3, r0
-
- blr
-
-
-
-
-
-.global GetBlahTableOffset
-GetBlahTableOffset:
- lis r5, BlahTableOffsets@h
- ori r5, r5, BlahTableOffsets@l
- lwzx r30, r5, r4
- blr
-
-
-.global DealWithBlahTable
-DealWithBlahTable:
- lis r5, BlahTableOffsets@h
- ori r5, r5, BlahTableOffsets@l
-
- # points to BlahTable
- lis r4, BlahTable@h
- ori r4, r4, BlahTable@l
-
- # get blahtableoffset entry based on powerup
- lwz r0, 0x1090(r3)
- slwi r0, r0, 2
- lwzx r0, r5, r0
-
- # now get the entry from the blahtable
- slwi r0, r0, 2
- lwzx r4, r4, r0
-
- # do shit here
-
- lfs f3, 0(r4)
- stfs f3, 0x14E4(r3)
- stfs f3, 0x164(r3)
-
- lfs f1, 0x2A70(r3)
- lfs f0, 0x2A74(r3)
-
- lfs f2, 4(r4)
- fadds f1, f2, f1
- fadds f0, f0, f1
- stfs f0, 0x14E8(r3)
- stfs f0, 0x168(r3)
-
- lfs f0, 0x8(r4)
- lfs f1, 0xC(r4)
- stfs f0, 0x16C(r3)
- stfs f1, 0x170(r3)
-
- # hope I did this right
- blr
-
-
-
-
-
-.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest
-GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest:
- lis r6, PowerupScaleFloats@h
- ori r6, r6, PowerupScaleFloats@l
- add r4, r6, r0
- blr
-
-.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest
-GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest:
- lis r6, PowerupScaleFloats@h
- ori r6, r6, PowerupScaleFloats@l
- add r3, r6, r0
- blr
-
-.global GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest
-GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest:
- lis r8, PowerupScaleFloats@h
- ori r8, r8, PowerupScaleFloats@l
- add r7, r8, r0
- blr
-
-.global GetPowerupScaleFloatAddr_fixForSixth
-GetPowerupScaleFloatAddr_fixForSixth:
- lis r5, PowerupScaleFloats@h
- ori r5, r5, PowerupScaleFloats@l
- add r4, r5, r4
- b returnFromGPSFASixth
-
-
-
-.global PlumberSetPowerupFix
-PlumberSetPowerupFix:
- lbz r0, 0x152(r31) # get powerup id
-
- cmpwi r0, 2
- beq doFireTex
-
- cmpwi r0, 6
- beq doIceTex
-
- cmpwi r0, 7
- beq doHammerTex
-
- li r4, 0
- b gotTexID
-
-doFireTex:
- li r4, 1
- b gotTexID
-
-doIceTex:
- li r4, 2
- b gotTexID
-
-doHammerTex:
- li r4, 3
-
-gotTexID:
- lwz r12, 0(r31)
- mr r3, r31
- lwz r12, 0x34(r12)
- mtctr r12
- bctrl
-
- b doneSettingThePowerupTexture
-
-
-
-.global PlumberSetPowerupFix2
-PlumberSetPowerupFix2:
- cmpwi r31, 2
- beq doFireTex2
-
- cmpwi r31, 6
- beq doIceTex2
-
- cmpwi r31, 7
- beq doHammerTex2
-
- li r4, 0
- b gotTexID2
-
-doFireTex2:
- li r4, 1
- b gotTexID2
-
-doIceTex2:
- li r4, 2
- b gotTexID2
-
-doHammerTex2:
- li r4, 3
-
-gotTexID2:
- lwz r3, 0x2A64(r30)
- lwz r12, 0(r3)
- lwz r12, 0x34(r12)
- mtctr r12
- bctrl
-
- b doneSettingThePowerupTexture2
-
-
-
-
-.global PlumberSetPowerupTextureDebug
-.extern OSReport
-.extern continuePlumberSetPowerupTextureDebug
-PlumberSetPowerupTextureDebug:
- stwu sp, -0x30(sp)
- mflr r0
- stw r0, 0x34(sp)
- stw r3, 0x20(sp)
- stw r4, 0x24(sp)
-
- mr r6, r0
- mr r5, r4
- mr r4, r3
- lis r3, PowerupTexDebugStr@h
- ori r3, r3, PowerupTexDebugStr@l
- crclr 4*cr1+eq
- bl OSReport
-
- lwz r3, 0x20(sp)
- lwz r4, 0x24(sp)
- lwz r0, 0x34(sp)
- mtlr r0
- addi sp, sp, 0x30
-
- stwu sp, -0x30(sp)
-
- b continuePlumberSetPowerupTextureDebug
-
-
-
-
-
-.global PlumberSetPowerupTextureFix
-PlumberSetPowerupTextureFix:
- stb r4, 0x153(r3)
-
- lis r5, PowerupTextures@h
- ori r5, r5, PowerupTextures@l
-
- slwi r4, r4, 2
- lfsx f31, r5, r4
-
- b continuePlumberSetPowerupTexture
-
-
-
-.global SetHammerToEnItemDCA
-SetHammerToEnItemDCA:
- bl daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot
- cmpwi r3, 1
- bne DontSetHammer
-
- li r0, 5
- sth r0, 0xDCA(r31)
-
-DontSetHammer:
- lwz r0, 0x14(sp)
- lwz r31, 0xC(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-#.global EnItem_BindAnimation_Fix
-#EnItem_BindAnimation_Fix:
-# lhz r0, 0xDCA(r3)
-# cmpwi r0, 5
-# beqlr
-# stwu sp, -0x20(sp)
-# b EnItem_BindAnimation_Continued
-
-
-.global WeirdAnimLoadHack
-WeirdAnimLoadHack:
- cmplwi r4, 5 #hammersuit
- beqlr
- cmplwi r4, 6 #1up
- beqlr
- # neither of those succeeded
- crclr 4*cr0+eq
- blr
-
-
-
-.global TryToGiveMarioHammerSuit
-TryToGiveMarioHammerSuit:
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
-
- # check the obtained item number
- cmplwi r3, 5
- bne IsntGettingHammerSuit
-
- # check the current player powerup
- cmplwi r4, 7
- bne DontHaveHammerSuit
-
- li r28, 0
- li r29, 2
- b ReturnFromTTGMHS
-
-DontHaveHammerSuit:
- mr r3, r30
- li r4, 7
- bl dAcPy_c__ChangePowerupWithAnimation
-
- cmpwi r3, 0
- beq ReturnFromTTGMHS
-
- li r29, 1
-
-IsntGettingHammerSuit:
-ReturnFromTTGMHS:
- # end of function
- lwz r0, 0x14(sp)
- mtlr r0
- addi sp, sp, 0x10
-
- # leftover instruction from what we replaced to add the bl
- cmpwi r29, 0
- blr
-
-
-
-.global ThrowHammer
-ThrowHammer:
- # continues on from PlayerProjectileShooting
-
- # get powerup
- lwz r3, 0x1090(r30)
- cmplwi r3, 7
- bne ReturnFromThrowHammer
-
- mr r3, r30
- li r4, 498
- li r5, 0
- bl PlayPlayerSound
-
- li r3, 0x73 # Hammer
- li r4, 0 # Settings
- addi r5, sp, 0x2C # Position
- li r6, 0 # Rotation
- lbz r7, 0x38F(r30) # Layer
- bl CreateActor
-
- # Store player ID
- lwz r4, 0(r30)
- stw r4, 0x450(r3)
-
- # store player number, but add 0x100 to differentiate it from 0
- lbz r4, 0x38D(r30)
- addi r4, r4, 0x100
- stw r4, 0x458(r3)
-
- # Fix scale
- lis r4, OneFloat@h
- ori r4, r4, OneFloat@l
- lfs f0, 0(r4)
- stfs f0, 0xDC(r3)
- stfs f0, 0xE0(r3)
- stfs f0, 0xE4(r3)
-
- mr r4, r30
- lwz r12, 0x60(r3)
- lwz r12, 0x8C(r12)
- mtctr r12
- bctrl
-
-ReturnFromThrowHammer:
- lwz r0, 0xC4(sp)
- psq_l f31, 0xB8(sp), 1, 0
- lfd f31, 0xB0(sp)
- psq_l f30, 0xA8(sp), 1, 0
- lfd f30, 0xA0(sp)
- lwz r31, 0x9C(sp)
- lwz r30, 0x98(sp)
- mtlr r0
- addi sp, sp, 0xC0
- blr
-
-
-
-.global MoreProjectileStuff_Fix
-MoreProjectileStuff_Fix:
- lwz r3, 0x1090(r31)
- cmplwi r3, 7
- bne ReturnFromMPSFix
-
- mr r3, r31
- li r4, 1
- bl PlayerProjectileShooting
-
-ReturnFromMPSFix:
- lwz r0, 0x14(sp)
- lwz r31, 0xC(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-
-.global ProjectileShootCheck_Fix
-ProjectileShootCheck_Fix:
- lwz r3, 0x1090(r31)
- cmplwi r3, 7
- bne Return0fromPSCFix
-
- lbz r3, 0x38D(r31)
- li r4, 0
- extsb r3, r3
- bl CheckHammerLimit
-
- cmpwi r3, 0
- beq Return0fromPSCFix
-
- b Return1fromPSCFix
-
-Return0fromPSCFix:
- li r3, 0
- b ReturnFromPSCFix
-
-Return1fromPSCFix:
- li r3, 1
-
-ReturnFromPSCFix:
- lwz r0, 0x14(sp)
- lwz r31, 0xC(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-.global CheckHammerLimit
-CheckHammerLimit:
- stwu sp, -0x10(sp)
- mflr r0
- stw r0, 0x14(sp)
- stw r31, 0xC(sp)
- stw r30, 0x8(sp)
-
- # r30 = player number
- mr r30, r3
- addi r30, r30, 0x100
-
- # r31 = hammer count so far
- li r31, 0
-
- # search for every Hammer
-
- li r3, 0
- b startOrContinueLoop
-loop:
-
- lwz r4, 0x458(r3)
- cmpw r4, r30
- bne startOrContinueLoop
-
- addi r31, r31, 1
-
-startOrContinueLoop:
- mr r4, r3
- li r3, 0x73
- bl Actor_SearchByName
-
- cmpwi r3, 0
- bne loop
-
- # now if the current count is >= 2, return 0
- # otherwise return 1
- cmpwi r31, 2
- bge tooManyHammers
-
- li r3, 1
- b gotHammerStatus
-
-tooManyHammers:
- li r3, 0
-
-gotHammerStatus:
- lwz r0, 0x14(sp)
- lwz r31, 0xC(sp)
- lwz r30, 0x8(sp)
- mtlr r0
- addi sp, sp, 0x10
- blr
-
-
-
-
-
-
-.data
-
-SomeTable:
- .long SomeTable_802F5580
- .long SomeTable_802F56C0
- .long SomeTable_802F56C0
- .long SomeTable_802F5440
- .long SomeTable_802F56C0
- .long SomeTable_802F56C0
- .long SomeTable_802F56C0
- .long SomeTable_802F56C0
-
-ZeroFloat:
- .float 0.0
-
-OneFloat:
- .float 1.0
-
-FukidashiTable2:
- .float 20.0, 32.0, 32.0, 12.0, 38.0, 33.0, 32.0, 32.0
- .float 20.0, 34.0, 34.0, 12.0, 39.0, 35.0, 34.0, 34.0
- .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0
- .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0
-
-PlayerHeightsNormal:
- .float 16.0, 27.0, 27.0, 12.0, 27.0, 27.0, 27.0, 27.0
-
-PlayerHeightsDucking:
- .float 13.0, 21.0, 21.0, 9.0, 21.0, 21.0, 21.0, 21.0
-
-WtfEverTable:
- .float 4.5, 10.0, 10.0, 1.0, 10.0, 9.0, 10.0, 10.0
-
-YetAnotherTable:
- .float 0.0, -4.0, -4.0, 4.0, -6.0, -2.0, -4.0, -4.0
-
-WeirdScaleTable:
- .float 16.0, 31.0, 31.0, 6.0, 34.0, 31.0, 31.0, 31.0
-
-AsdfTable:
- .byte 1, 2, 2, 0, 2, 2, 2, 2
-
-BlahTableOffsets:
- .long 1, 2, 2, 0, 3, 2, 2, 2
-
-PowerupScaleFloats:
- .long 0xDEADBEEF, 0xDEADBEEF # padding
- .float 1.0
- .float 1.0
- .float 1.0
- .float 0.6
- .float 1.0
- .float 1.0
- .float 1.0
- .float 1.0
-
-PowerupTextures:
- .float 0.0
- .float 1.0
- .float 2.0
- .float 3.0
-
-.global BrosArcFileName
-BrosArcFileName:
- .string "bros"
-
-.global I_hammerArcFilename
-I_hammerArcFilename:
- .string "I_hammer"
-
-.global I_hammerResFile
-I_hammerResFile:
-# .string "g3d/I_hammer.brres"
- .string "g3d/I_fireflower.brres"
-
-.global I_hammerModelName
-I_hammerModelName:
-# .string "I_hammer"
- .string "I_fireflower"
-
-
-PowerupTexDebugStr:
- .string "Plumber::SetPowerupTexture() called on class %p with texnum %d lr=%p\n"
-
-#.global BrosModelFilename
-#BrosModelFilename:
-# .string "g3d/bros.brres"
-
-#.global HammerModelName
-#HammerModelName:
-# .string "bros_hammer"
+.text +.align 4 +.set sp, 1 + +.extern returnFromGPSFASixth +.extern daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot +.extern dAcPy_c__ChangePowerupWithAnimation +.extern PlayPlayerSound +.extern CreateActor +.extern PlayerProjectileShooting +.extern Actor_SearchByName +.extern SomeTable_802F5440 +.extern SomeTable_802F5580 +.extern SomeTable_802F56C0 +.extern BlahTable +.extern continuePlumberSetPowerupTexture +.extern doneSettingThePowerupTexture +.extern doneSettingThePowerupTexture2 + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f2,2; .set f3,3 +.set f1,1; .set f30,30; .set f31,31 +#endif + +.global GetInfoFromDumbTable +GetInfoFromDumbTable: + lis r3, SomeTable@h + ori r3, r3, SomeTable@l + + slwi r4, r4, 2 + slwi r0, r5, 6 + + lwzx r3, r3, r4 + add r3, r3, r0 + blr + + + + +.global FukidashiFix +FukidashiFix: + lis r7, ZeroFloat@h + ori r7, r7, ZeroFloat@l + + lis r8, FukidashiTable2@h + ori r8, r8, FukidashiTable2@l + + mulli r6, r4, 0x20 + slwi r0, r5, 2 + add r0, r0, r6 + + lfs f0, 0(r7) + lfsx f1, r8, r0 + + stfs f0, 0x1DC(r3) + stfs f1, 0x1E0(r3) + stfs f0, 0x1E4(r3) + + blr + + + + +.global PlayerGetHeight +PlayerGetHeight: + lwz r0, 0x14D4(r3) + + lwz r4, 0x1090(r3) + slwi r4, r4, 3 + + cmpwi r0, 0 + beq useNormal + cmpwi r0, 1 + bne useDucking + +useNormal: + lis r3, PlayerHeightsNormal@h + ori r3, r3, PlayerHeightsNormal@l + b gotOffset + +useDucking: + lis r3, PlayerHeightsDucking@h + ori r3, r3, PlayerHeightsDucking@l + +gotOffset: + lfsx f1, r3, r4 + blr + + + +.global WtfEver +WtfEver: + lis r3, WtfEverTable@h + ori r3, r3, WtfEverTable@l + lfsx f0, r3, r0 + blr + + + +.global YetAnother +YetAnother: + lis r3, YetAnotherTable@h + ori r3, r3, YetAnotherTable@l + lfsx f0, r3, r0 + blr + + + + +.global GetWeirdScaleTable +GetWeirdScaleTable: + lis r5, WeirdScaleTable@h + ori r5, r5, WeirdScaleTable@l + lfsx f1, r5, r0 + blr + + + + + +.global GetAsdfTable +GetAsdfTable: + extsb r0, r4 + cmpwi r0, -1 + bne dontGetThisOne + + lwz r0, 0x1090(r3) + extsb r4, r0 + +dontGetThisOne: + extsb r0, r4 + + lis r3, AsdfTable@h + ori r3, r3, AsdfTable@l + lbzx r3, r3, r0 + + blr + + + + + +.global GetBlahTableOffset +GetBlahTableOffset: + lis r5, BlahTableOffsets@h + ori r5, r5, BlahTableOffsets@l + lwzx r30, r5, r4 + blr + + +.global DealWithBlahTable +DealWithBlahTable: + lis r5, BlahTableOffsets@h + ori r5, r5, BlahTableOffsets@l + + # points to BlahTable + lis r4, BlahTable@h + ori r4, r4, BlahTable@l + + # get blahtableoffset entry based on powerup + lwz r0, 0x1090(r3) + slwi r0, r0, 2 + lwzx r0, r5, r0 + + # now get the entry from the blahtable + slwi r0, r0, 2 + lwzx r4, r4, r0 + + # do shit here + + lfs f3, 0(r4) + stfs f3, 0x14E4(r3) + stfs f3, 0x164(r3) + + lfs f1, 0x2A70(r3) + lfs f0, 0x2A74(r3) + + lfs f2, 4(r4) + fadds f1, f2, f1 + fadds f0, f0, f1 + stfs f0, 0x14E8(r3) + stfs f0, 0x168(r3) + + lfs f0, 0x8(r4) + lfs f1, 0xC(r4) + stfs f0, 0x16C(r3) + stfs f1, 0x170(r3) + + # hope I did this right + blr + + + + + +.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest +GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r4_dest: + lis r6, PowerupScaleFloats@h + ori r6, r6, PowerupScaleFloats@l + add r4, r6, r0 + blr + +.global GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest +GetPowerupScaleFloatAddr_r6_trash_r0_valshl2_r3_dest: + lis r6, PowerupScaleFloats@h + ori r6, r6, PowerupScaleFloats@l + add r3, r6, r0 + blr + +.global GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest +GetPowerupScaleFloatAddr_r8_trash_r0_valshl2_r7_dest: + lis r8, PowerupScaleFloats@h + ori r8, r8, PowerupScaleFloats@l + add r7, r8, r0 + blr + +.global GetPowerupScaleFloatAddr_fixForSixth +GetPowerupScaleFloatAddr_fixForSixth: + lis r5, PowerupScaleFloats@h + ori r5, r5, PowerupScaleFloats@l + add r4, r5, r4 + b returnFromGPSFASixth + + + +.global PlumberSetPowerupFix +PlumberSetPowerupFix: + lbz r0, 0x152(r31) # get powerup id + + cmpwi r0, 2 + beq doFireTex + + cmpwi r0, 6 + beq doIceTex + + cmpwi r0, 7 + beq doHammerTex + + li r4, 0 + b gotTexID + +doFireTex: + li r4, 1 + b gotTexID + +doIceTex: + li r4, 2 + b gotTexID + +doHammerTex: + li r4, 3 + +gotTexID: + lwz r12, 0(r31) + mr r3, r31 + lwz r12, 0x34(r12) + mtctr r12 + bctrl + + b doneSettingThePowerupTexture + + + +.global PlumberSetPowerupFix2 +PlumberSetPowerupFix2: + cmpwi r31, 2 + beq doFireTex2 + + cmpwi r31, 6 + beq doIceTex2 + + cmpwi r31, 7 + beq doHammerTex2 + + li r4, 0 + b gotTexID2 + +doFireTex2: + li r4, 1 + b gotTexID2 + +doIceTex2: + li r4, 2 + b gotTexID2 + +doHammerTex2: + li r4, 3 + +gotTexID2: + lwz r3, 0x2A64(r30) + lwz r12, 0(r3) + lwz r12, 0x34(r12) + mtctr r12 + bctrl + + b doneSettingThePowerupTexture2 + + + + +.global PlumberSetPowerupTextureDebug +.extern OSReport +.extern continuePlumberSetPowerupTextureDebug +PlumberSetPowerupTextureDebug: + stwu sp, -0x30(sp) + mflr r0 + stw r0, 0x34(sp) + stw r3, 0x20(sp) + stw r4, 0x24(sp) + + mr r6, r0 + mr r5, r4 + mr r4, r3 + lis r3, PowerupTexDebugStr@h + ori r3, r3, PowerupTexDebugStr@l + crclr 4*cr1+eq + bl OSReport + + lwz r3, 0x20(sp) + lwz r4, 0x24(sp) + lwz r0, 0x34(sp) + mtlr r0 + addi sp, sp, 0x30 + + stwu sp, -0x30(sp) + + b continuePlumberSetPowerupTextureDebug + + + + + +.global PlumberSetPowerupTextureFix +PlumberSetPowerupTextureFix: + stb r4, 0x153(r3) + + lis r5, PowerupTextures@h + ori r5, r5, PowerupTextures@l + + slwi r4, r4, 2 + lfsx f31, r5, r4 + + b continuePlumberSetPowerupTexture + + + +.global SetHammerToEnItemDCA +SetHammerToEnItemDCA: + bl daEnItem_c__GetWhetherPlayerCanGetPowerupOrNot + cmpwi r3, 1 + bne DontSetHammer + + li r0, 5 + sth r0, 0xDCA(r31) + +DontSetHammer: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + +#.global EnItem_BindAnimation_Fix +#EnItem_BindAnimation_Fix: +# lhz r0, 0xDCA(r3) +# cmpwi r0, 5 +# beqlr +# stwu sp, -0x20(sp) +# b EnItem_BindAnimation_Continued + + +.global WeirdAnimLoadHack +WeirdAnimLoadHack: + cmplwi r4, 5 #hammersuit + beqlr + cmplwi r4, 6 #1up + beqlr + # neither of those succeeded + crclr 4*cr0+eq + blr + + + +.global TryToGiveMarioHammerSuit +TryToGiveMarioHammerSuit: + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + + # check the obtained item number + cmplwi r3, 5 + bne IsntGettingHammerSuit + + # check the current player powerup + cmplwi r4, 7 + bne DontHaveHammerSuit + + li r28, 0 + li r29, 2 + b ReturnFromTTGMHS + +DontHaveHammerSuit: + mr r3, r30 + li r4, 7 + bl dAcPy_c__ChangePowerupWithAnimation + + cmpwi r3, 0 + beq ReturnFromTTGMHS + + li r29, 1 + +IsntGettingHammerSuit: +ReturnFromTTGMHS: + # end of function + lwz r0, 0x14(sp) + mtlr r0 + addi sp, sp, 0x10 + + # leftover instruction from what we replaced to add the bl + cmpwi r29, 0 + blr + + + +.global ThrowHammer +ThrowHammer: + # continues on from PlayerProjectileShooting + + # get powerup + lwz r3, 0x1090(r30) + cmplwi r3, 7 + bne ReturnFromThrowHammer + + mr r3, r30 + li r4, 498 + li r5, 0 + bl PlayPlayerSound + + li r3, 0x73 # Hammer + li r4, 0 # Settings + addi r5, sp, 0x2C # Position + li r6, 0 # Rotation + lbz r7, 0x38F(r30) # Layer + bl CreateActor + + # Store player ID + lwz r4, 0(r30) + stw r4, 0x450(r3) + + # store player number, but add 0x100 to differentiate it from 0 + lbz r4, 0x38D(r30) + addi r4, r4, 0x100 + stw r4, 0x458(r3) + + # Fix scale + lis r4, OneFloat@h + ori r4, r4, OneFloat@l + lfs f0, 0(r4) + stfs f0, 0xDC(r3) + stfs f0, 0xE0(r3) + stfs f0, 0xE4(r3) + + mr r4, r30 + lwz r12, 0x60(r3) + lwz r12, 0x8C(r12) + mtctr r12 + bctrl + +ReturnFromThrowHammer: + lwz r0, 0xC4(sp) + psq_l f31, 0xB8(sp), 1, 0 + lfd f31, 0xB0(sp) + psq_l f30, 0xA8(sp), 1, 0 + lfd f30, 0xA0(sp) + lwz r31, 0x9C(sp) + lwz r30, 0x98(sp) + mtlr r0 + addi sp, sp, 0xC0 + blr + + + +.global MoreProjectileStuff_Fix +MoreProjectileStuff_Fix: + lwz r3, 0x1090(r31) + cmplwi r3, 7 + bne ReturnFromMPSFix + + mr r3, r31 + li r4, 1 + bl PlayerProjectileShooting + +ReturnFromMPSFix: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + +.global ProjectileShootCheck_Fix +ProjectileShootCheck_Fix: + lwz r3, 0x1090(r31) + cmplwi r3, 7 + bne Return0fromPSCFix + + lbz r3, 0x38D(r31) + li r4, 0 + extsb r3, r3 + bl CheckHammerLimit + + cmpwi r3, 0 + beq Return0fromPSCFix + + b Return1fromPSCFix + +Return0fromPSCFix: + li r3, 0 + b ReturnFromPSCFix + +Return1fromPSCFix: + li r3, 1 + +ReturnFromPSCFix: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + +.global CheckHammerLimit +CheckHammerLimit: + stwu sp, -0x10(sp) + mflr r0 + stw r0, 0x14(sp) + stw r31, 0xC(sp) + stw r30, 0x8(sp) + + # r30 = player number + mr r30, r3 + addi r30, r30, 0x100 + + # r31 = hammer count so far + li r31, 0 + + # search for every Hammer + + li r3, 0 + b startOrContinueLoop +loop: + + lwz r4, 0x458(r3) + cmpw r4, r30 + bne startOrContinueLoop + + addi r31, r31, 1 + +startOrContinueLoop: + mr r4, r3 + li r3, 0x73 + bl Actor_SearchByName + + cmpwi r3, 0 + bne loop + + # now if the current count is >= 2, return 0 + # otherwise return 1 + cmpwi r31, 2 + bge tooManyHammers + + li r3, 1 + b gotHammerStatus + +tooManyHammers: + li r3, 0 + +gotHammerStatus: + lwz r0, 0x14(sp) + lwz r31, 0xC(sp) + lwz r30, 0x8(sp) + mtlr r0 + addi sp, sp, 0x10 + blr + + + + + + +.data + +SomeTable: + .long SomeTable_802F5580 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + .long SomeTable_802F5440 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + .long SomeTable_802F56C0 + +ZeroFloat: + .float 0.0 + +OneFloat: + .float 1.0 + +FukidashiTable2: + .float 20.0, 32.0, 32.0, 12.0, 38.0, 33.0, 32.0, 32.0 + .float 20.0, 34.0, 34.0, 12.0, 39.0, 35.0, 34.0, 34.0 + .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0 + .float 20.0, 29.0, 29.0, 11.0, 34.0, 29.0, 29.0, 29.0 + +PlayerHeightsNormal: + .float 16.0, 27.0, 27.0, 12.0, 27.0, 27.0, 27.0, 27.0 + +PlayerHeightsDucking: + .float 13.0, 21.0, 21.0, 9.0, 21.0, 21.0, 21.0, 21.0 + +WtfEverTable: + .float 4.5, 10.0, 10.0, 1.0, 10.0, 9.0, 10.0, 10.0 + +YetAnotherTable: + .float 0.0, -4.0, -4.0, 4.0, -6.0, -2.0, -4.0, -4.0 + +WeirdScaleTable: + .float 16.0, 31.0, 31.0, 6.0, 34.0, 31.0, 31.0, 31.0 + +AsdfTable: + .byte 1, 2, 2, 0, 2, 2, 2, 2 + +BlahTableOffsets: + .long 1, 2, 2, 0, 3, 2, 2, 2 + +PowerupScaleFloats: + .long 0xDEADBEEF, 0xDEADBEEF # padding + .float 1.0 + .float 1.0 + .float 1.0 + .float 0.6 + .float 1.0 + .float 1.0 + .float 1.0 + .float 1.0 + +PowerupTextures: + .float 0.0 + .float 1.0 + .float 2.0 + .float 3.0 + +.global BrosArcFileName +BrosArcFileName: + .string "bros" + +.global I_hammerArcFilename +I_hammerArcFilename: + .string "I_hammer" + +.global I_hammerResFile +I_hammerResFile: +# .string "g3d/I_hammer.brres" + .string "g3d/I_fireflower.brres" + +.global I_hammerModelName +I_hammerModelName: +# .string "I_hammer" + .string "I_fireflower" + + +PowerupTexDebugStr: + .string "Plumber::SetPowerupTexture() called on class %p with texnum %d lr=%p\n" + +#.global BrosModelFilename +#BrosModelFilename: +# .string "g3d/bros.brres" + +#.global HammerModelName +#HammerModelName: +# .string "bros_hammer" diff --git a/src/randomcrap.S b/src/randomcrap.S index e7b6451..808009b 100644 --- a/src/randomcrap.S +++ b/src/randomcrap.S @@ -1,8 +1,8 @@ -.text
-.global HeapChangeAttempt
-HeapChangeAttempt:
- lis 4, 0x8037
- ori 4, 4, 0x7F50
- lwz 4, 0(4)
- blr
-
+.text +.global HeapChangeAttempt +HeapChangeAttempt: + lis 4, 0x8037 + ori 4, 4, 0x7F50 + lwz 4, 0(4) + blr + diff --git a/src/randtiles.cpp b/src/randtiles.cpp index c7388dd..0bc2ede 100644 --- a/src/randtiles.cpp +++ b/src/randtiles.cpp @@ -1,22 +1,22 @@ -#include "randtiles.h"
-
-u32 djb2(u8 *str) {
- u32 hash = 5381;
- int c;
-
- while (c = *str++)
- hash = ((hash << 5) + hash) + c;
-
- return hash;
-}
-
-RandTiles_Section *RandTiles_Search(void *file, u32 nameHash) {
- for (int i = 0; i < RandTiles_GetSectionCount(file); i++) {
- RandTiles_Section *sect = RandTiles_GetSection(file, i);
-
- if (sect->nameHash == nameHash)
- return sect;
- }
-
- return 0;
-}
+#include "randtiles.h" + +u32 djb2(u8 *str) { + u32 hash = 5381; + int c; + + while (c = *str++) + hash = ((hash << 5) + hash) + c; + + return hash; +} + +RandTiles_Section *RandTiles_Search(void *file, u32 nameHash) { + for (int i = 0; i < RandTiles_GetSectionCount(file); i++) { + RandTiles_Section *sect = RandTiles_GetSection(file, i); + + if (sect->nameHash == nameHash) + return sect; + } + + return 0; +} diff --git a/src/randtiles.h b/src/randtiles.h index ab2553d..14355da 100644 --- a/src/randtiles.h +++ b/src/randtiles.h @@ -1,63 +1,63 @@ -#ifndef __NEWER_RANDTILES_H
-#define __NEWER_RANDTILES_H
-
-#include <common.h>
-#include "fileload.h"
-
-#define RAND_CHECK_HORZ
-#define RAND_CHECK_VERT
-#define RAND_CHECK_BOTH
-
-struct RandTiles_Header {
- u32 magic;
- u32 sectionCount;
-};
-
-struct RandTiles_Section {
- u32 nameHash;
- u32 entryCount;
-};
-
-struct RandTiles_Entry {
- u16 startTile;
- u16 endTile;
- u8 count;
- u8 type;
- u16 reserved;
- u32 dataOffset;
-};
-
-inline u32 RandTiles_GetSectionCount(void *file) {
- return ((RandTiles_Header*)file)->sectionCount;
-}
-
-inline u32 *RandTiles_GetOffsets(void *file) {
- return (u32*)(((RandTiles_Header*)file)+1);
-}
-
-inline RandTiles_Section *RandTiles_GetSection(void *file, int id) {
- u32 offs = RandTiles_GetOffsets(file)[id];
- return (RandTiles_Section*)(((char*)file)+offs);
-};
-
-inline RandTiles_Entry *RandTiles_GetTiles(void *file, RandTiles_Section *section) {
- return (RandTiles_Entry*)(section+1);
-}
-
-inline RandTiles_Entry *RandTiles_GetTiles(void *file, int sectionID) {
- return (RandTiles_Entry*)(RandTiles_GetSection(file, sectionID)+1);
-}
-
-inline char *RandTiles_GetName(void *file, RandTiles_Section *section) {
- return ((char*)file)+section->nameOffset;
-}
-
-inline u16 *RandTiles_GetData(void *file, RandTiles_Entry *entry) {
- return (u16*)(((char*)file)+entry->dataOffset);
-}
-
-u32 djb2(u8 *str);
-RandTiles_Section *RandTiles_Search(void *file, u32 nameHash);
-
-
-#endif
+#ifndef __NEWER_RANDTILES_H +#define __NEWER_RANDTILES_H + +#include <common.h> +#include "fileload.h" + +#define RAND_CHECK_HORZ +#define RAND_CHECK_VERT +#define RAND_CHECK_BOTH + +struct RandTiles_Header { + u32 magic; + u32 sectionCount; +}; + +struct RandTiles_Section { + u32 nameHash; + u32 entryCount; +}; + +struct RandTiles_Entry { + u16 startTile; + u16 endTile; + u8 count; + u8 type; + u16 reserved; + u32 dataOffset; +}; + +inline u32 RandTiles_GetSectionCount(void *file) { + return ((RandTiles_Header*)file)->sectionCount; +} + +inline u32 *RandTiles_GetOffsets(void *file) { + return (u32*)(((RandTiles_Header*)file)+1); +} + +inline RandTiles_Section *RandTiles_GetSection(void *file, int id) { + u32 offs = RandTiles_GetOffsets(file)[id]; + return (RandTiles_Section*)(((char*)file)+offs); +}; + +inline RandTiles_Entry *RandTiles_GetTiles(void *file, RandTiles_Section *section) { + return (RandTiles_Entry*)(section+1); +} + +inline RandTiles_Entry *RandTiles_GetTiles(void *file, int sectionID) { + return (RandTiles_Entry*)(RandTiles_GetSection(file, sectionID)+1); +} + +inline char *RandTiles_GetName(void *file, RandTiles_Section *section) { + return ((char*)file)+section->nameOffset; +} + +inline u16 *RandTiles_GetData(void *file, RandTiles_Entry *entry) { + return (u16*)(((char*)file)+entry->dataOffset); +} + +u32 djb2(u8 *str); +RandTiles_Section *RandTiles_Search(void *file, u32 nameHash); + + +#endif diff --git a/src/spritespawner.cpp b/src/spritespawner.cpp index 1d6a071..5335dfe 100755 --- a/src/spritespawner.cpp +++ b/src/spritespawner.cpp @@ -1,74 +1,74 @@ -#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
- u32 inheritSet; // 0x3D6
+#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 + u32 inheritSet; // 0x3D6 u8 lastEvState; // 0x3DA - u32 createdActor;
-};
-
-struct EventTable_t {
- u64 events;
-};
- - -struct VEC {
- float x;
- float y;
- float z;
-};
- -
-extern EventTable_t *EventTable;
+ u32 createdActor; +}; + +struct EventTable_t { + u64 events; +}; + + +struct VEC { + float x; + float y; + float z; +}; + + +extern EventTable_t *EventTable; extern "C" dStageActor_c *CreateActor(u16 classID, int settings, VEC pos, char rot, char layer); extern "C" dStageActor_c *Actor_SearchByID(u32 actorID); -void SpriteSpawner_Update(SpriteSpawner *self);
- -#define ACTIVATE 1
-#define DEACTIVATE 0
-
- - -
-bool SpriteSpawner_Create(SpriteSpawner *self) {
- OSReport("I exist, dammit!");
- - char eventNum = (self->settings >> 28) & 0xF;
- OSReport("Event to activate: %d", eventNum);
- - self->eventFlag = (u64)1 << (eventNum - 1);
- self->createdActor = 0;
- self->type = (self->settings >> 16) & 0xFFF;
-
- short tempSet = self->settings & 0xFFFF;
- self->inheritSet = (tempSet & 3) | ((tempSet & 0xC) << 2) | ((tempSet & 0x30) << 4) | ((tempSet & 0xC0) << 6) | ((tempSet & 0x300) << 8) | ((tempSet & 0xC00) << 10) | ((tempSet & 0x3000) << 12) | ((tempSet & 0xC000) << 14);
-
- SpriteSpawner_Update(self);
-
- return true;
-}
-
-bool SpriteSpawner_Execute(SpriteSpawner *self) {
- SpriteSpawner_Update(self);
- return true;
-}
-
- -void SpriteSpawner_Update(SpriteSpawner *self) {
-
+void SpriteSpawner_Update(SpriteSpawner *self); + +#define ACTIVATE 1 +#define DEACTIVATE 0 + + + + +bool SpriteSpawner_Create(SpriteSpawner *self) { + OSReport("I exist, dammit!"); + + char eventNum = (self->settings >> 28) & 0xF; + OSReport("Event to activate: %d", eventNum); + + self->eventFlag = (u64)1 << (eventNum - 1); + self->createdActor = 0; + self->type = (self->settings >> 16) & 0xFFF; + + short tempSet = self->settings & 0xFFFF; + self->inheritSet = (tempSet & 3) | ((tempSet & 0xC) << 2) | ((tempSet & 0x30) << 4) | ((tempSet & 0xC0) << 6) | ((tempSet & 0x300) << 8) | ((tempSet & 0xC00) << 10) | ((tempSet & 0x3000) << 12) | ((tempSet & 0xC000) << 14); + + SpriteSpawner_Update(self); + + return true; +} + +bool SpriteSpawner_Execute(SpriteSpawner *self) { + SpriteSpawner_Update(self); + return true; +} + + +void SpriteSpawner_Update(SpriteSpawner *self) { + if (EventTable->events & self->eventFlag) { // Put an action for when the event turns on here @@ -80,7 +80,7 @@ void SpriteSpawner_Update(SpriteSpawner *self) { 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);
+ OSReport("Spawning Sprite: %d at %f,%f,%f\n", self->type, pos.x, pos.y, pos.z); dStageActor_c *spawned = CreateActor(self->type, self->inheritSet, pos, 0, 0); self->createdActor = spawned->id; @@ -99,5 +99,5 @@ void SpriteSpawner_Update(SpriteSpawner *self) { } self->createdActor = 0; } - }
+ } } diff --git a/src/spriteswapper.cpp b/src/spriteswapper.cpp new file mode 100755 index 0000000..cbff99f --- /dev/null +++ b/src/spriteswapper.cpp @@ -0,0 +1,144 @@ +#include <common.h> +#include <game.h> + +struct SpriteSwapper { + 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 firstType; // 0x3D4 + u16 secondType; // 0x3D4 + u8 lastEvState; // 0x3DA + u32 firstActor; + u32 secondActor; +}; + +struct EventTable_t { + u64 events; +}; + + +struct VEC { + float x; + float y; + float z; +}; + + +extern EventTable_t *EventTable; +extern "C" dStageActor_c *CreateActor(u16 classID, int settings, VEC pos, char rot, char layer); +extern "C" dStageActor_c *Actor_SearchByID(u32 actorID); + +void SpriteSwapper_Update(SpriteSwapper *self); + +#define ACTIVATE 1 +#define DEACTIVATE 0 + + + + +bool SpriteSwapper_Create(SpriteSwapper *self) { + OSReport("I exist, dammit!"); + + char eventNum = (self->settings >> 28) & 0xF; + OSReport("Event to activate: %d", eventNum); + + self->eventFlag = (u64)1 << (eventNum - 1); + self->firstActor = 0; + self->secondActor = 0; + self->firstType = (self->settings >> 16) & 0xFFF; + self->secondType = self->settings & 0xFFF; + + VEC pos; + pos.x = self->x; + pos.y = self->y; + pos.z = self->z; + + OSReport("Spawning first sprite."); + + dStageActor_c *spawned = CreateActor(self->firstType, 0, pos, 0, 0); + self->firstActor = spawned->id; + + OSReport("Spawned %d.", self->firstActor); + + SpriteSwapper_Update(self); + + return true; +} + +bool SpriteSwapper_Execute(SpriteSwapper *self) { + SpriteSwapper_Update(self); + return true; +} + + +void SpriteSwapper_Update(SpriteSwapper *self) { + + if (EventTable->events & self->eventFlag) + { + // Put an action for when the event turns on here + OSReport("Event turned on."); + + if (self->firstActor != 0) + { + OSReport("Found the first sprite."); + + dStageActor_c *spawned = Actor_SearchByID(self->firstActor); + if (spawned != 0) { + OSReport("It's still alive."); + self->x = spawned->pos.x; + self->y = spawned->pos.y; + self->z = spawned->pos.z; + spawned->Delete(); + } + self->firstActor = 0; + OSReport("Now it's deleted."); + + VEC pos; + pos.x = self->x; + pos.y = self->y; + pos.z = self->z; + + OSReport("Making second sprite."); + dStageActor_c *spawner = CreateActor(self->secondType, 0, pos, 0, 0); + self->secondActor = spawner->id; + OSReport("Spawned %d.", self->secondActor); + } +// EventTable->events = EventTable->events & ~self->eventFlag; + } + else + { + OSReport("Event turned off."); + if (self->secondActor != 0) + { + OSReport("Found the second sprite."); + dStageActor_c *spawned = Actor_SearchByID(self->secondActor); + if (spawned != 0) { + OSReport("It's still alive."); + self->x = spawned->pos.x; + self->y = spawned->pos.y; + self->z = spawned->pos.z; + spawned->Delete(); + } + self->secondActor = 0; + OSReport("Now it's deleted."); + + VEC pos; + pos.x = self->x; + pos.y = self->y; + pos.z = self->z; + + OSReport("Making first sprite again."); + dStageActor_c *spawner = CreateActor(self->firstType, 0, pos, 0, 0); + self->firstActor = spawner->id; + OSReport("Spawned %d.", self->firstActor); + } + } +} diff --git a/src/spritetex.S b/src/spritetex.S index c636943..75e0256 100755 --- a/src/spritetex.S +++ b/src/spritetex.S @@ -1,869 +1,869 @@ -.extern sprintf
-.extern GenerateRandomNumber
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.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 f2,2; .set f3,3
-#endif
-
-.text
-.align 4
-.global GetTexFilenameForR5, TexFilenameBuffer, TexFormatString
-
-.set sp, 1
-
-GetTexFilenameForR5:
- # obj number should be put into r5
- # returned filename is in r5
- # this makes it easy to use with dRes_c::GetResource
-
- stwu sp, -0x20(sp)
- mflr r0
- stw r0, 0x24(sp)
- stw r3, 0x1C(sp)
- stw r4, 0x18(sp)
- stw r6, 0x14(sp)
- stw r7, 0x10(sp)
- stw r8, 0xC(sp)
- stw r9, 0x8(sp)
-
- lis r3, TexFilenameBuffer@h
- ori r3, r3, TexFilenameBuffer@l
-
- lis r4, TexFormatString@h
- ori r4, r4, TexFormatString@l
-
- crclr 4*cr1+eq
- bl sprintf
-
- lis r5, TexFilenameBuffer@h
- ori r5, r5, TexFilenameBuffer@l
-
- lwz r0, 0x24(sp)
- lwz r3, 0x1C(sp)
- lwz r4, 0x18(sp)
- lwz r6, 0x14(sp)
- lwz r7, 0x10(sp)
- lwz r8, 0xC(sp)
- lwz r9, 0x8(sp)
- mtlr r0
- addi sp, sp, 0x20
- blr
-
-
-.global TEX_YoshiEggSetColour
-TEX_YoshiEggSetColour:
-
- stwu sp, -0x30(sp)
- mflr r0
- stw r0, 0x24(sp)
- mr r9, r3
- stw r4, 0x18(sp)
- stw r5, 0x14(sp)
- stw r6, 0x10(sp)
- stw r7, 0x0C(sp)
-
- li r3, 10
- bl GenerateRandomNumber
- stw r3, 0x5F8(r9)
-
- lwz r0, 0x24(sp)
- mr r3, r9
- lwz r4, 0x18(sp)
- lwz r5, 0x14(sp)
- lwz r6, 0x10(sp)
- lwz r7, 0x0C(sp)
- mtlr r0
- addi sp, sp, 0x30
- blr
-
-
-.global TEX_YoshiEggSetBrres
-TEX_YoshiEggSetBrres:
-
- lwz r5, 0x5F8(r27)
- clrlwi r5, r5, 28
-
- cmpwi r5, 4
- blt YoshiEggOne
-
- cmpwi r5, 8
- blt YoshiEggTwo
-
- li r5, 2
- b GetTexFilenameForR5
-
-
-YoshiEggOne:
- li r5, 0
- b GetTexFilenameForR5
-
-YoshiEggTwo:
- li r5, 1
- b GetTexFilenameForR5
-
-
-
-.global TEX_YoshiEggSetFrame
-TEX_YoshiEggSetFrame:
-
- lwz r5, 0x5F8(r27)
- clrlwi r5, r5, 30
- blr
-
-
-.global TEX_YoshiEggEffect
-TEX_YoshiEggEffect:
-
- lwz r0, 0x5F8(r3)
- clrlwi r0, r0, 30
- blr
-
-
-.global TEX_YoshiSetColour
-TEX_YoshiSetColour:
-
- lwz r4, 0x5F8(r31)
- oris r4, r4, 1
- blr
-
-
-.global TEX_YoshiHack
-TEX_YoshiHack:
-
- stwu sp, -0x30(sp)
- mflr r0
- stw r0, 0x24(sp)
- stw r3, 0x1C(sp)
- stw r4, 0x18(sp)
- stw r5, 0x14(sp)
- stw r6, 0x10(sp)
- stw r7, 0x0C(sp)
- stw r8, 0x08(sp)
- stw r9, 0x04(sp)
-
- lwz r5, 0x24C(r31)
- clrlwi r5, r5, 28
-
- lis r3, TexFilenameBuffer@h
- ori r3, r3, TexFilenameBuffer@l
-
- lis r4, TexFormatString@h
- ori r4, r4, TexFormatString@l
-
- crclr 4*cr1+eq
- bl sprintf
-
- lis r5, TexFilenameBuffer@h
- ori r5, r5, TexFilenameBuffer@l
-
- lis r4, YoshiArc@h
- ori r4, r4, YoshiArc@l
-
- lwz r0, 0x24(sp)
- lwz r3, 0x1C(sp)
- lwz r6, 0x10(sp)
- lwz r7, 0x0C(sp)
- lwz r8, 0x08(sp)
- lwz r9, 0x04(sp)
- mtlr r0
- addi sp, sp, 0x30
- blr
-
-
-
-
-.global TEX_WoodBox
-TEX_WoodBox:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- b GetTexFilenameForR5
-
-
-.global TEX_Bush
-TEX_Bush:
- srwi r5, r27, 28
- b GetTexFilenameForR5
-
-
-# The below was added by Tempus
-
-
-.global TEX_Goomba
-TEX_Goomba:
- lwz r5, 4(r3)
- 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
-TEX_Barrel:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Blooper
-TEX_Blooper:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_BigBlock
-TEX_BigBlock:
- lwz r5, 4(r28)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Thwomp
-TEX_Thwomp:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_GiantBuzzy
-TEX_GiantBuzzy:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Buzzy
-TEX_Buzzy:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-.global TEX_BuzzyShell
-TEX_BuzzyShell:
- lwz r5, 4(r3)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_SpikeTop
-TEX_SpikeTop:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Spiny
-TEX_Spiny:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_SpinyShell
-TEX_SpinyShell:
- lwz r5, 4(r3)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_SpringBlock
-TEX_SpringBlock:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Coaster
-TEX_Coaster:
- lwz r5, 4(r3)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Koopa
-TEX_Koopa:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Gabon
-TEX_Gabon:
- lwz r5, 4(r29)
- 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(r28)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Podoboo
-TEX_Podoboo:
- lwz r5, 4(r31)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Switch
-TEX_Switch:
- lwz r5, 4(r29)
- srwi r5, r5, 16
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_WiggleShroom
-TEX_WiggleShroom:
- lwz r5, -0x520(r3)
- # This sprite is pretty complex
- # The register with THIS is r29
- # before the loading function,
- # it passes it into r3, and then mr's
- # it into r30. r3 is then overwritten.
- # Then, it puts r31 into r5, r30 partly
- # into r3 and partly into r4. Why?
- # So, the possibilities for THIS are
- # r30, r3, and r4, no? In the next function,
- # r30 is stored over before our getFile, as
- # are r29/r28.
-
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Bramball
-TEX_Bramball:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Monty
-TEX_Monty:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_ChainChomp
-TEX_ChainChomp:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Manta
-TEX_Manta:
- lwz r5, 4(r28)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Parabeetle
-TEX_Parabeetle:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Bomb
-TEX_Bomb:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_ParaBomb
-TEX_ParaBomb:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_CheepA
-TEX_CheepA:
- lwz r5, 4(r27)
- srwi r5, r5, 20
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_CheepB
-TEX_CheepB:
- lwz r5, 4(r28)
- srwi r5, r5, 20
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_CheepC
-TEX_CheepC:
- lwz r5, 4(r28)
- srwi r5, r5, 20
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_CheepChomp
-TEX_CheepChomp:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.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:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xFF
- b GetTexFilenameForR5
-
-
-.global TEX_Goal
-TEX_Goal:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_StretchMush
-TEX_StretchMush:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_BlockSlide
-TEX_BlockSlide:
- lwz r5, 4(r28)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_Spinner
-TEX_Spinner:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global 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:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_PokeyB
-TEX_PokeyB:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- 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
-
-
-.global TEX_Huckit
-TEX_Huckit:
- lwz r5, 4(r29)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-.global TEX_HuckitBalls
-TEX_HuckitBalls:
- lwz r5, 4(r30)
- srwi r5, r5, 24
- andi. r5, r5, 0xF
- b GetTexFilenameForR5
-
-
-
-
-
-.global HammerTime
-HammerTime:
- lwz r8, 4(r31)
+.extern sprintf +.extern GenerateRandomNumber + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f2,2; .set f3,3 +#endif + +.text +.align 4 +.global GetTexFilenameForR5, TexFilenameBuffer, TexFormatString + +.set sp, 1 + +GetTexFilenameForR5: + # obj number should be put into r5 + # returned filename is in r5 + # this makes it easy to use with dRes_c::GetResource + + stwu sp, -0x20(sp) + mflr r0 + stw r0, 0x24(sp) + stw r3, 0x1C(sp) + stw r4, 0x18(sp) + stw r6, 0x14(sp) + stw r7, 0x10(sp) + stw r8, 0xC(sp) + stw r9, 0x8(sp) + + lis r3, TexFilenameBuffer@h + ori r3, r3, TexFilenameBuffer@l + + lis r4, TexFormatString@h + ori r4, r4, TexFormatString@l + + crclr 4*cr1+eq + bl sprintf + + lis r5, TexFilenameBuffer@h + ori r5, r5, TexFilenameBuffer@l + + lwz r0, 0x24(sp) + lwz r3, 0x1C(sp) + lwz r4, 0x18(sp) + lwz r6, 0x14(sp) + lwz r7, 0x10(sp) + lwz r8, 0xC(sp) + lwz r9, 0x8(sp) + mtlr r0 + addi sp, sp, 0x20 + blr + + +.global TEX_YoshiEggSetColour +TEX_YoshiEggSetColour: + + stwu sp, -0x30(sp) + mflr r0 + stw r0, 0x24(sp) + mr r9, r3 + stw r4, 0x18(sp) + stw r5, 0x14(sp) + stw r6, 0x10(sp) + stw r7, 0x0C(sp) + + li r3, 10 + bl GenerateRandomNumber + stw r3, 0x5F8(r9) + + lwz r0, 0x24(sp) + mr r3, r9 + lwz r4, 0x18(sp) + lwz r5, 0x14(sp) + lwz r6, 0x10(sp) + lwz r7, 0x0C(sp) + mtlr r0 + addi sp, sp, 0x30 + blr + + +.global TEX_YoshiEggSetBrres +TEX_YoshiEggSetBrres: + + lwz r5, 0x5F8(r27) + clrlwi r5, r5, 28 + + cmpwi r5, 4 + blt YoshiEggOne + + cmpwi r5, 8 + blt YoshiEggTwo + + li r5, 2 + b GetTexFilenameForR5 + + +YoshiEggOne: + li r5, 0 + b GetTexFilenameForR5 + +YoshiEggTwo: + li r5, 1 + b GetTexFilenameForR5 + + + +.global TEX_YoshiEggSetFrame +TEX_YoshiEggSetFrame: + + lwz r5, 0x5F8(r27) + clrlwi r5, r5, 30 + blr + + +.global TEX_YoshiEggEffect +TEX_YoshiEggEffect: + + lwz r0, 0x5F8(r3) + clrlwi r0, r0, 30 + blr + + +.global TEX_YoshiSetColour +TEX_YoshiSetColour: + + lwz r4, 0x5F8(r31) + oris r4, r4, 1 + blr + + +.global TEX_YoshiHack +TEX_YoshiHack: + + stwu sp, -0x30(sp) + mflr r0 + stw r0, 0x24(sp) + stw r3, 0x1C(sp) + stw r4, 0x18(sp) + stw r5, 0x14(sp) + stw r6, 0x10(sp) + stw r7, 0x0C(sp) + stw r8, 0x08(sp) + stw r9, 0x04(sp) + + lwz r5, 0x24C(r31) + clrlwi r5, r5, 28 + + lis r3, TexFilenameBuffer@h + ori r3, r3, TexFilenameBuffer@l + + lis r4, TexFormatString@h + ori r4, r4, TexFormatString@l + + crclr 4*cr1+eq + bl sprintf + + lis r5, TexFilenameBuffer@h + ori r5, r5, TexFilenameBuffer@l + + lis r4, YoshiArc@h + ori r4, r4, YoshiArc@l + + lwz r0, 0x24(sp) + lwz r3, 0x1C(sp) + lwz r6, 0x10(sp) + lwz r7, 0x0C(sp) + lwz r8, 0x08(sp) + lwz r9, 0x04(sp) + mtlr r0 + addi sp, sp, 0x30 + blr + + + + +.global TEX_WoodBox +TEX_WoodBox: + lwz r5, 4(r30) + srwi r5, r5, 24 + b GetTexFilenameForR5 + + +.global TEX_Bush +TEX_Bush: + srwi r5, r27, 28 + b GetTexFilenameForR5 + + +# The below was added by Tempus + + +.global TEX_Goomba +TEX_Goomba: + lwz r5, 4(r3) + 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 +TEX_Barrel: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Blooper +TEX_Blooper: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_BigBlock +TEX_BigBlock: + lwz r5, 4(r28) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Thwomp +TEX_Thwomp: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_GiantBuzzy +TEX_GiantBuzzy: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Buzzy +TEX_Buzzy: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + +.global TEX_BuzzyShell +TEX_BuzzyShell: + lwz r5, 4(r3) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_SpikeTop +TEX_SpikeTop: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Spiny +TEX_Spiny: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_SpinyShell +TEX_SpinyShell: + lwz r5, 4(r3) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_SpringBlock +TEX_SpringBlock: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Coaster +TEX_Coaster: + lwz r5, 4(r3) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Koopa +TEX_Koopa: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Gabon +TEX_Gabon: + lwz r5, 4(r29) + 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(r28) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Podoboo +TEX_Podoboo: + lwz r5, 4(r31) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Switch +TEX_Switch: + lwz r5, 4(r29) + srwi r5, r5, 16 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_WiggleShroom +TEX_WiggleShroom: + lwz r5, -0x520(r3) + # This sprite is pretty complex + # The register with THIS is r29 + # before the loading function, + # it passes it into r3, and then mr's + # it into r30. r3 is then overwritten. + # Then, it puts r31 into r5, r30 partly + # into r3 and partly into r4. Why? + # So, the possibilities for THIS are + # r30, r3, and r4, no? In the next function, + # r30 is stored over before our getFile, as + # are r29/r28. + + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Bramball +TEX_Bramball: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Monty +TEX_Monty: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_ChainChomp +TEX_ChainChomp: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Manta +TEX_Manta: + lwz r5, 4(r28) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Parabeetle +TEX_Parabeetle: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Bomb +TEX_Bomb: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_ParaBomb +TEX_ParaBomb: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_CheepA +TEX_CheepA: + lwz r5, 4(r27) + srwi r5, r5, 20 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_CheepB +TEX_CheepB: + lwz r5, 4(r28) + srwi r5, r5, 20 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_CheepC +TEX_CheepC: + lwz r5, 4(r28) + srwi r5, r5, 20 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_CheepChomp +TEX_CheepChomp: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.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: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xFF + b GetTexFilenameForR5 + + +.global TEX_Goal +TEX_Goal: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_StretchMush +TEX_StretchMush: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_BlockSlide +TEX_BlockSlide: + lwz r5, 4(r28) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_Spinner +TEX_Spinner: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global 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: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_PokeyB +TEX_PokeyB: + lwz r5, 4(r29) + srwi r5, r5, 24 + 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 + + +.global TEX_Huckit +TEX_Huckit: + lwz r5, 4(r29) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + +.global TEX_HuckitBalls +TEX_HuckitBalls: + lwz r5, 4(r30) + srwi r5, r5, 24 + andi. r5, r5, 0xF + b GetTexFilenameForR5 + + + + + +.global HammerTime +HammerTime: + lwz r8, 4(r31) srwi r8, r8, 8 andi. r8, r8, 0xF cmpwi r8, 1 - beq ThrowBobomb
+ beq ThrowBobomb cmpwi r8, 2 - beq ThrowGoomba
+ beq ThrowGoomba cmpwi r8, 3 - beq ThrowSpiny
+ beq ThrowSpiny cmpwi r8, 4 - beq ThrowCoin
+ beq ThrowCoin cmpwi r8, 5 - beq ThrowLemmyBall
-
- blr
-
+ beq ThrowLemmyBall + + blr + ThrowBobomb: li r3, 133 @@ -883,37 +883,37 @@ ThrowSpiny: ThrowCoin: li r3, 10 - mflr r8
+ mflr r8 mr r9, r5 - bl GenerateRandomNumber
+ bl GenerateRandomNumber mr r5, r9 - mtlr r8
- cmpwi r3, 1
- beq ThrowItem
-
+ mtlr r8 + cmpwi r3, 1 + beq ThrowItem + li r3, 0x193 li r4, 0 li r6, 0 li r7, 0 blr -
-ThrowItem:
+ +ThrowItem: li r3, 6 - mflr r8
+ mflr r8 mr r9, r5 - bl GenerateRandomNumber
+ bl GenerateRandomNumber mtlr r8 mr r5, r9 - li r4, 0
+ li r4, 0 - mr r4, r3
- li r3, 0x3C
+ mr r4, r3 + li r3, 0x3C li r6, 0 li r7, 0 - blr
-
+ blr + ThrowLemmyBall: li r3, 0x232 @@ -921,156 +921,156 @@ ThrowLemmyBall: blr -
-
-.global HammerLaunch
-HammerLaunch:
- mr r3, r30
- # r31 is the new actor currently
- # r30 is self, all others are volatile
-
- lwz r5, 4(r30)
- lwz r8, 0x348(r30)
-
- srwi r5, r5, 8
- andi. r5, r5, 0xF
-
- cmpwi r5, 0
- beqlr
-
- lis r7, LaunchAngle@h
- ori r7, r7, LaunchAngle@l
-
-# lfs f0, 0(r7)
-# stfs f0, 0xDC(r31)
-# stfs f0, 0xE0(r31)
-# stfs f0, 0xE4(r31)
-
- # Nybble 11 is for y right now
- li r6, 0
- slwi r6, r6, 2 # size *= 4 (size of float)
- lfsx f0, r7, r6 # get it from the array
-
- stfs f0, 0xEC(r31)
-
- cmpwi r5, 5
- beq LemmyLaunch
-
- li r6, 1
- slwi r6, r6, 2 # size *= 4 (size of float)
-
- cmpwi r8, 0
- bne FacingLeft
-
- # Nybble 12 is for x right now
- lfsx f0, r7, r6 # get it from the array
-
- stfs f0, 0xE8(r31)
-
- blr
-
-
-FacingLeft:
-
- lis r7, LaunchAngleLeft@h
- ori r7, r7, LaunchAngleLeft@l
-
- # Nybble 12 is for x right now
- lfsx f0, r7, r6 # get it from the array
-
- stfs f0, 0xE8(r31)
- li r7, 270
- sth r7, 0x102(r31)
-
- blr
-
-
-LemmyLaunch:
-
- li r6, 2
- slwi r6, r6, 2 # size *= 4 (size of float)
-
- cmpwi r8, 0
- bne FacingLeft
-
- # Nybble 12 is for x right now
- lfsx f0, r7, r6 # get it from the array
-
- stfs f0, 0xE8(r31)
- blr
-
-
-.global HammerSpin
-HammerSpin:
-# sth r3, 0x100(r31)
- blr
-
-
-
-
-.data
-TexFilenameBuffer:
- .long 0,0,0,0
-
-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
-
-LaunchAngle:
- .float 4.0, 2.5, 1.5
-
-LaunchAngleLeft:
- .float -4.0, -2.5, -1.5
-
-
-
-.align 4
-
-YoshiArc:
- .string "Y_TexGreen"
-.align 4
-
-Y_TexGreen:
- .string "Y_TexGreen"
-.align 4
-Y_TexRed:
- .string "Y_TexRed"
-.align 4
-Y_TexYellow:
- .string "Y_TexYellow"
-.align 4
-Y_TexBlue:
- .string "Y_TexBlue"
-.align 4
-Y_TexPurple:
- .string "Y_TexPurple"
-.align 4
-Y_TexOrange:
- .string "Y_TexOrange"
-.align 4
-Y_TexSkyBlue:
- .string "Y_TexSkyBlue"
-.align 4
-Y_TexBlack:
- .string "Y_TexBlack"
-.align 4
-Y_TexWhite:
- .string "Y_TexWhite"
-.align 4
-
-YoshiStrings:
- .long Y_TexGreen, Y_TexRed, Y_TexYellow, Y_TexBlue, Y_TexPurple, Y_TexOrange, Y_TexSkyBlue, Y_TexBlack, Y_TexWhite
-
-.align 4
-
-
+ + +.global HammerLaunch +HammerLaunch: + mr r3, r30 + # r31 is the new actor currently + # r30 is self, all others are volatile + + lwz r5, 4(r30) + lwz r8, 0x348(r30) + + srwi r5, r5, 8 + andi. r5, r5, 0xF + + cmpwi r5, 0 + beqlr + + lis r7, LaunchAngle@h + ori r7, r7, LaunchAngle@l + +# lfs f0, 0(r7) +# stfs f0, 0xDC(r31) +# stfs f0, 0xE0(r31) +# stfs f0, 0xE4(r31) + + # Nybble 11 is for y right now + li r6, 0 + slwi r6, r6, 2 # size *= 4 (size of float) + lfsx f0, r7, r6 # get it from the array + + stfs f0, 0xEC(r31) + + cmpwi r5, 5 + beq LemmyLaunch + + li r6, 1 + slwi r6, r6, 2 # size *= 4 (size of float) + + cmpwi r8, 0 + bne FacingLeft + + # Nybble 12 is for x right now + lfsx f0, r7, r6 # get it from the array + + stfs f0, 0xE8(r31) + + blr + + +FacingLeft: + + lis r7, LaunchAngleLeft@h + ori r7, r7, LaunchAngleLeft@l + + # Nybble 12 is for x right now + lfsx f0, r7, r6 # get it from the array + + stfs f0, 0xE8(r31) + li r7, 270 + sth r7, 0x102(r31) + + blr + + +LemmyLaunch: + + li r6, 2 + slwi r6, r6, 2 # size *= 4 (size of float) + + cmpwi r8, 0 + bne FacingLeft + + # Nybble 12 is for x right now + lfsx f0, r7, r6 # get it from the array + + stfs f0, 0xE8(r31) + blr + + +.global HammerSpin +HammerSpin: +# sth r3, 0x100(r31) + blr + + + + +.data +TexFilenameBuffer: + .long 0,0,0,0 + +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 + +LaunchAngle: + .float 4.0, 2.5, 1.5 + +LaunchAngleLeft: + .float -4.0, -2.5, -1.5 + + + +.align 4 + +YoshiArc: + .string "Y_TexGreen" +.align 4 + +Y_TexGreen: + .string "Y_TexGreen" +.align 4 +Y_TexRed: + .string "Y_TexRed" +.align 4 +Y_TexYellow: + .string "Y_TexYellow" +.align 4 +Y_TexBlue: + .string "Y_TexBlue" +.align 4 +Y_TexPurple: + .string "Y_TexPurple" +.align 4 +Y_TexOrange: + .string "Y_TexOrange" +.align 4 +Y_TexSkyBlue: + .string "Y_TexSkyBlue" +.align 4 +Y_TexBlack: + .string "Y_TexBlack" +.align 4 +Y_TexWhite: + .string "Y_TexWhite" +.align 4 + +YoshiStrings: + .long Y_TexGreen, Y_TexRed, Y_TexYellow, Y_TexBlue, Y_TexPurple, Y_TexOrange, Y_TexSkyBlue, Y_TexBlack, Y_TexWhite + +.align 4 + + diff --git a/src/tilegod.S b/src/tilegod.S index 248b3dc..474b16c 100644 --- a/src/tilegod.S +++ b/src/tilegod.S @@ -1,65 +1,65 @@ -.text
-
-#ifndef __MWERKS__
-.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4
-.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9
-.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14
-.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19
-.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 f2,2; .set f3,3
-#endif
-
-.align 4
-.extern ExitFromTileGodHack
-.extern TileTable
-
-.global NEW_GetTileFromTileTable
-NEW_GetTileFromTileTable:
- andi. r0, r3, 0x8000
- beq UseRegular
-
- li r4, 0x7FFF
- and r3, r3, r4
- blr
-
-UseRegular:
- lis r4, TileTable@h
- ori r4, r4, TileTable@l
-
- clrlslwi r0, r3, 16, 1
- lhzx r3, r4, r0
- blr
-
-
-.global TileGodHack
-TileGodHack:
- lwz r4, 4(r3) # Load settings
- extrwi. r0, r4, 1, 16 # Get and check the "use regular tile" flag
- extrwi r4, r4, 3, 17 # Get the tile number OR tileset number
- bne Special
-
- lis r3, TileGodTiles@h
- ori r3, r3, TileGodTiles@l
- slwi r4, r4, 1
- lhzx r25, r3, r4
-
- b ExitFromTileGodHack
-
-Special:
- lwz r3, 4(r3) # Load settings
- srwi r3, r3, 20 # Get tile number
- andi. r3, r3, 0xFF # Cut off top nybble
- slwi r4, r4, 8 # Shift tileset number
- or r3, r3, r4 # Add tileset number
- ori r25, r3, 0x8000 # Add "get regular tile" flag
-
- b ExitFromTileGodHack
-
-
-
-.data
-TileGodTiles:
- .short 0x7C, 0x02, 0x0C, 0x7B, 0x0F, 0x00
-
-
+.text + +#ifndef __MWERKS__ +.set r0,0; .set r1,1; .set r2,2; .set r3,3; .set r4,4 +.set r5,5; .set r6,6; .set r7,7; .set r8,8; .set r9,9 +.set r10,10; .set r11,11; .set r12,12; .set r13,13; .set r14,14 +.set r15,15; .set r16,16; .set r17,17; .set r18,18; .set r19,19 +.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 f2,2; .set f3,3 +#endif + +.align 4 +.extern ExitFromTileGodHack +.extern TileTable + +.global NEW_GetTileFromTileTable +NEW_GetTileFromTileTable: + andi. r0, r3, 0x8000 + beq UseRegular + + li r4, 0x7FFF + and r3, r3, r4 + blr + +UseRegular: + lis r4, TileTable@h + ori r4, r4, TileTable@l + + clrlslwi r0, r3, 16, 1 + lhzx r3, r4, r0 + blr + + +.global TileGodHack +TileGodHack: + lwz r4, 4(r3) # Load settings + extrwi. r0, r4, 1, 16 # Get and check the "use regular tile" flag + extrwi r4, r4, 3, 17 # Get the tile number OR tileset number + bne Special + + lis r3, TileGodTiles@h + ori r3, r3, TileGodTiles@l + slwi r4, r4, 1 + lhzx r25, r3, r4 + + b ExitFromTileGodHack + +Special: + lwz r3, 4(r3) # Load settings + srwi r3, r3, 20 # Get tile number + andi. r3, r3, 0xFF # Cut off top nybble + slwi r4, r4, 8 # Shift tileset number + or r3, r3, r4 # Add tileset number + ori r25, r3, 0x8000 # Add "get regular tile" flag + + b ExitFromTileGodHack + + + +.data +TileGodTiles: + .short 0x7C, 0x02, 0x0C, 0x7B, 0x0F, 0x00 + + diff --git a/src/worldmap.cpp b/src/worldmap.cpp index d7f73d0..d650fce 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -1,1064 +1,1064 @@ -#include "worldmap.h"
-
-extern "C" void LoadMapScene();
-
-dScNewerWorldMap_c *dScNewerWorldMap_c::instance = 0;
-
-
-dScNewerWorldMap_c *dScNewerWorldMap_c::build() {
- // return new dScNewerWorldMap_c;
- OSReport("Creating WorldMap\n");
-
- void *buffer = AllocFromGameHeap1(sizeof(dScNewerWorldMap_c));
- dScNewerWorldMap_c *c = new(buffer) dScNewerWorldMap_c;
-
- OSReport("Created WorldMap @ %p\n", c);
-
- instance = c;
- return c;
-}
-
-
-#define SELC_SETUP_DONE(sc) (*((bool*)(((u32)(sc))+0xD38)))
-
-#define EASYP_SETUP_DONE(ep) (*((bool*)(((u32)(ep))+0x278)))
-#define EASYP_ACTIVE(ep) (*((bool*)(((u32)(ep))+0x279)))
-
-#define CSMENU_SETUP_DONE(csm) (*((bool*)(((u32)(csm))+0x270)))
-#define CSMENU_ACTIVE(csm) (*((bool*)(((u32)(csm))+0x271)))
-#define CSMENU_CHOICE_OK(csm) (*((bool*)(((u32)(csm))+0x272)))
-#define CSMENU_UNK(csm) (*((bool*)(((u32)(csm))+0x273)))
-#define CSMENU_CURRENT(csm) (*((int*)(((u32)(csm))+0x268)))
-
-#define YESNO_SETUP_DONE(ynw) (*((bool*)(((u32)(ynw))+0x294)))
-#define YESNO_VISIBLE(ynw) (*((bool*)(((u32)(ynw))+0x295)))
-#define YESNO_CLOSE(ynw) (*((bool*)(((u32)(ynw))+0x296)))
-#define YESNO_OPENING(ynw) (*((bool*)(((u32)(ynw))+0x297)))
-#define YESNO_REFUSED(ynw) (*((bool*)(((u32)(ynw))+0x298)))
-#define YESNO_CANCELLED(ynw) (*((bool*)(((u32)(ynw))+0x299)))
-#define YESNO_CANCELLED2(ynw) (*((bool*)(((u32)(ynw))+0x29A)))
-#define YESNO_CURRENT(ynw) (*((int*)(((u32)(ynw))+0x284)))
-#define YESNO_TYPE(ynw) (*((int*)(((u32)(ynw))+0x28C)))
-
-#define NPCHG_SETUP_DONE(npc) (*((bool*)(((u32)(npc))+0x67C)))
-#define NPCHG_ACTIVE(npc) (*((bool*)(((u32)(npc))+0x67E)))
-#define NPCHG_HIDE_FOR_EASYP(npc) (*((bool*)(((u32)(npc))+0x67F)))
-#define NPCHG_READY(npc) (*((bool*)(((u32)(npc))+0x680)))
-#define NPCHG_CCSB(npc,idx) (((void**)(((u32)(npc))+0x74))[(idx)])
-#define NPCHG_CCSC(npc,idx) (((void**)(((u32)(npc))+0x84))[(idx)])
-#define NPCHG_CCSA(npc,idx) (((void**)(((u32)(npc))+0x94))[(idx)])
-#define NPCHG_CCI(npc,idx) (((void**)(((u32)(npc))+0xA4))[(idx)])
-#define NPCHG_2DPLAYER(npc,idx) (((void**)(((u32)(npc))+0x64C))[(idx)])
-
-#define STKI_SETUP_DONE(si) (*((bool*)(((u32)(si))+0x310)))
-#define STKI_SHADOW(si) (*((void**)(((u32)(si))+0x310)))
-#define STKI_2DPLAYER(si,idx) (((void**)(((u32)(si))+0x2E4))[(idx)])
-#define STKI_ITEM(si,idx) (((void**)(((u32)(si))+0x2F4))[(idx)])
-#define STKI_SHOW(si) (*((bool*)(((u32)(si))+0x8DD)))
-
-#define SIS_SETUP_DONE(sis) (*((bool*)(((u32)(sis))+0x260)))
-
-#define CCSB_ACTIVE(ccsb) (*((bool*)(((u32)(ccsb))+0x29C)))
-
-#define CCSC_ACTIVE(ccsc) (*((bool*)(((u32)(ccsc))+0x2A1)))
-
-#define PLAYER2D_SHOW_EASY_PAIRING(p2d) (*((bool*)(((u32)(p2d))+0x264)))
-
-#define CONT_LIVES(cont,idx) (((int*)(((u32)(cont))+0x2B8))[(idx)])
-#define CONT_SETUP_DONE(cont) (*((bool*)(((u32)(cont))+0x2D4)))
-#define CONT_UNK1(cont) (*((bool*)(((u32)(cont))+0x2D5)))
-#define CONT_UNK2(cont) (*((bool*)(((u32)(cont))+0x2D6)))
-#define CONT_DONE(cont) (*((bool*)(((u32)(cont))+0x2D7)))
-#define CONT_UNK3(cont) (*((bool*)(((u32)(cont))+0x2E0)))
-
-inline u8 GetSwitchStatus() {
- return *((u8*)(((u32)GameMgr)+0x380));
-}
-
-inline void SetSwitchStatus(u8 stat) {
- *((u8*)(((u32)GameMgr)+0x380)) = stat;
-}
-
-#define STATE_START_DVD 0
-#define STATE_LOAD_RES 1
-#define STATE_END_DVD 2
-#define STATE_SETUP_WAIT 3
-#define STATE_LIMBO 4
-#define STATE_CONTINUE_WAIT 5
-#define STATE_NORMAL 6
-#define STATE_OPT_CHANGE_WAIT 7
-#define STATE_CSMENU 8
-#define STATE_TITLE_CONFIRM_OPEN_WAIT 9
-#define STATE_TITLE_CONFIRM_SELECT 10
-#define STATE_TITLE_CONFIRM_HIT_WAIT 11
-#define STATE_PLAYER_CHANGE_WAIT 12
-#define STATE_EASY_PAIRING_WAIT 13
-#define STATE_POWERUPS_WAIT 14
-#define STATE_SAVE_OPEN 15
-#define STATE_SAVE_SELECT 16
-#define STATE_SAVE_WINDOW_CLOSE 17
-#define STATE_SAVE_DO 18
-#define STATE_SAVE_END_WINDOW 19
-#define STATE_SAVE_END_CLOSE_WAIT 20
-#define STATE_QUICKSAVE_OPEN 21
-#define STATE_QUICKSAVE_SELECT 22
-#define STATE_QUICKSAVE_WINDOW_CLOSE 23
-#define STATE_QUICKSAVE_DO 24
-#define STATE_QUICKSAVE_END_WINDOW 25
-#define STATE_QUICKSAVE_END_CLOSE_WAIT 26
-#define STATE_SAVE_ERROR 27
-
-#define MENU_HEIGHT 15
-
-const char *anim1 = "optionActivated.brlan";
-const char *anim2 = "optionDeactivated.brlan";
-
-const char *group1 = "G_opt00";
-const char *group2 = "G_opt01";
-const char *group3 = "G_opt02";
-const char *group4 = "G_opt03";
-const char *group5 = "G_opt04";
-const char *group6 = "G_opt05";
-const char *group7 = "G_opt06";
-const char *group8 = "G_opt07";
-const char *group9 = "G_opt08";
-const char *group10 = "G_opt09";
-const char *group11 = "G_opt10";
-const char *group12 = "G_opt11";
-const char *group13 = "G_opt12";
-const char *group14 = "G_opt13";
-const char *group15 = "G_opt14";
-
-
-void dScNewerWorldMap_c::StartLevel() {
- LevelInfo_Entry *level = LevelInfo_GetLevels(this->levelInfo, this->currentPage);
- level += this->selections[this->currentPage];
- StartLevel(level);
-}
-
-void dScNewerWorldMap_c::StartLevel(LevelInfo_Entry *entry) {
- for (int i = 0; i < 4; i++) {
- bool isThere = QueryPlayerAvailability(i);
- int id = Player_ID[i];
- Player_Active[i] = isThere ? 1 : 0;
- if (!isThere) Player_Flags[i] = 0;
- }
-
- StartLevelInfo sl;
- sl.unk1 = 0;
- sl.unk2 = 0xFF;
- sl.unk3 = 0;
- sl.unk4 = 0;
- sl.purpose = 0;
-
- sl.world1 = entry->world;
- sl.world2 = entry->world;
- sl.level1 = entry->level;
- sl.level2 = entry->level;
-
- // hopefully this will fix the Star Coin issues
- SetSomeConditionShit(entry->world, entry->level, 2);
-
- ActivateWipe(WIPE_MARIO);
-
- DoStartLevel(GetGameMgr(), &sl);
-}
-
-void dScNewerWorldMap_c::SetTitle(const char *text) {
- unsigned short conv_buf[0x200];
- int length = strlen(text);
- if (length > 0x1FF)
- length = 0x1FF;
-
- for (int i = 0; i < length; i++) {
- conv_buf[i] = text[i];
- }
- conv_buf[length] = 0;
-
- void *textBox = EmbeddedLayout_FindTextBoxByName(this->layout, "ScreenTitle");
- TextBox_SetString(textBox, conv_buf, 0);
-}
-
-void dScNewerWorldMap_c::GenSBTitle() {
- char buf[0x100];
- sprintf(buf, "Switches: R:%s; G:%s; Y:%s; B:%s",
- ((GetSwitchStatus() & 1) != 0) ? "On" : "Off",
- ((GetSwitchStatus() & 2) != 0) ? "On" : "Off",
- ((GetSwitchStatus() & 4) != 0) ? "On" : "Off",
- ((GetSwitchStatus() & 8) != 0) ? "On" : "Off");
- this->SetTitle(buf);
-}
-
-void dScNewerWorldMap_c::GenText() {
- char buf[0x1FF];
- char paneNameBuf[0x20];
- char textBoxNameBuf[0x20];
- unsigned short wchars[0x1FF];
-
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
-
- LevelInfo_Section *section = LevelInfo_GetSection(this->levelInfo, this->currentPage);
- LevelInfo_Entry *levels = LevelInfo_GetLevels(this->levelInfo, section);
-
- int count = section->levelCount;
-
- for (int i = 0; i < MENU_HEIGHT; i++) {
- sprintf(paneNameBuf, "Opt%02d", i);
- sprintf(textBoxNameBuf, "OptText%02d", i);
- void *pane = EmbeddedLayout_FindPaneByName(this->layout, paneNameBuf);
- void *textBox = EmbeddedLayout_FindTextBoxByName(this->layout, textBoxNameBuf);
-
- if (i < count) {
- // valid level
- PANE_FLAGS(pane) |= 1;
-
- u32 conds = save->GetLevelCondition(levels[i].world, levels[i].level);
-
- char cond1, cond2, cond3, cond4, cond5;
- cond1 = (conds & COND_NORMAL ? 'x' : '.');
- cond2 = (conds & COND_SECRET ? 'x' : '.');
- cond3 = (conds & COND_COIN1 ? 'x' : '.');
- cond4 = (conds & COND_COIN2 ? 'x' : '.');
- cond5 = (conds & COND_COIN3 ? 'x' : '.');
-
- sprintf(buf, "%s %c%c %c%c%c", LevelInfo_GetName(this->levelInfo, &levels[i]), cond1, cond2, cond3, cond4, cond5);
-
- for (int i = 0; i < 0x1FF; i++) {
- wchars[i] = buf[i];
- if (buf[i] == 0) break;
- }
-
- TextBox_SetString(textBox, wchars, 0);
- } else {
- // invalid, hide the pane
- PANE_FLAGS(pane) &= ~1;
- }
- }
-}
-
-int dScNewerWorldMap_c::onCreate() {
- OSReport("1:Loading scene\n");
-
- LoadMapScene();
- OSReport("2:Loading scene\n");
- GameSetup__LoadScene(0); // lol, stolen from GAME_SETUP
-
- OSReport("3:Layout alloc\n");
- this->layout = (Layout*)AllocFromGameHeap1(sizeof(Layout));
- if (!this->layout) {
- OSReport("memalloc fail\n");
- InfiniteLoop;
- }
-
- OSReport("4:Layout ctor\n");
- EmbeddedLayout_ctor(this->layout);
- OSReport("5:Layout load arc\n");
- EmbeddedLayout_LoadArc(this->layout, "NewerRes/wmap.arc");
-
- OSReport("6:Layout build\n");
- if (!EmbeddedLayout_Build(this->layout, "levelSelect.brlyt", 0)) {
- OSReport("build fail\n");
- InfiniteLoop;
- }
-
-
- OSReport("7:Layout load brlan\n");
- const char *anims[2] = {anim1, anim2};
- EmbeddedLayout_LoadBrlans(this->layout, anims, 2);
-
- const char *groups[30] = {
- group1, group2, group3, group4, group5,
- group6, group7, group8, group9, group10,
- group11, group12, group13, group14, group15,
- group1, group2, group3, group4, group5,
- group6, group7, group8, group9, group10,
- group11, group12, group13, group14, group15,
- };
-
- int mappings[30] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
- OSReport("8:Layout load group\n");
- EmbeddedLayout_LoadGroups(this->layout, groups, mappings, 30);
-
- OSReport("9:Layout reset anims\n");
- EmbeddedLayout_DisableAllAnims(this->layout);
-
- for (int i = 0; i < 15; i++) {
- EmbeddedLayout_ResetAnimToInitialState(this->layout, i, false);
- }
-
-
- OSReport("10:Item 1\n");
- this->selectCursor = CreateParentedObject(SELECT_CURSOR, this, 0, 0);
- OSReport("11:Item 2\n");
- this->csMenu = CreateParentedObject(COURSE_SELECT_MENU, this, 0, 0);
- OSReport("12:Item 3\n");
- this->yesNoWindow = CreateParentedObject(YES_NO_WINDOW, this, 0, 0);
- OSReport("13:Item 4\n");
- this->numPeopleChange = CreateParentedObject(NUMBER_OF_PEOPLE_CHANGE, this, 0, 0);
-
- for (int i = 0; i < 4; i++) {
- OSReport("14:Character change select %d\n", i);
- void *ccsb = CreateParentedObject(CHARACTER_CHANGE_SELECT_BASE, this, i, 0);
- void *ccsc = CreateParentedObject(CHARACTER_CHANGE_SELECT_CONTENTS, this, i, 0);
- void *ccsa = CreateParentedObject(CHARACTER_CHANGE_SELECT_ARROW, this, i, 0);
- void *cci = CreateParentedObject(CHARACTER_CHANGE_INDICATOR, this, i, 0);
-
- NPCHG_CCSB(this->numPeopleChange, i) = ccsb;
- NPCHG_CCSC(this->numPeopleChange, i) = ccsc;
- NPCHG_CCSA(this->numPeopleChange, i) = ccsa;
- NPCHG_CCI(this->numPeopleChange, i) = cci;
- }
-
- OSReport("15:Item 5\n");
- this->continueObj = CreateParentedObject(CONTINUE, this, 0, 0);
-
- OSReport("16:Item 6\n");
- this->stockItem = CreateParentedObject(STOCK_ITEM, this, 0, 0);
- OSReport("17:Item 7\n");
- this->stockItemShadow = CreateParentedObject(STOCK_ITEM_SHADOW, this, 0, 0);
- STKI_SHADOW(this->stockItem) = this->stockItemShadow;
-
- OSReport("18:Item 8\n");
- this->easyPairing = CreateParentedObject(EASY_PAIRING, this, 0, 0);
-
- this->state = STATE_START_DVD;
-
- this->layout->drawOrder = 0;
-
- *CurrentDrawFunc = NewerMapDrawFunc;
-
- // level info
- OSReport("19:Load level info\n");
- this->levelInfo = LoadFile(&this->levelInfoFH, "/NewerRes/LevelInfo.bin");
- OSReport("20:Prepare level info\n");
- LevelInfo_Prepare(&this->levelInfoFH);
-
- // load the menu info
- OSReport("21:Load save info\n");
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
-
- this->currentPage = save->current_world;
-
- // bounds check
- if (save->current_path_node >= 15)
- save->current_path_node = 0;
-
- int sCount = LevelInfo_GetSectionCount(this->levelInfo);
- this->selections = (int*)AllocFromGameHeap1(sizeof(int) * sCount);
-
- for (int i = 0; i < sCount; i++) {
- this->selections[i] = 0;
- }
-
- this->selections[this->currentPage] = save->current_path_node;
-
- // show button anim
- OSReport("22:Enable anim\n");
- EmbeddedLayout_EnableNonLoopAnim(this->layout, save->current_path_node, false);
-
- OSReport("23:Make text\n");
- this->GenText();
- this->GenSBTitle();
-
- OSReport("24:onCreate complete\n");
- return true;
-}
-
-int dScNewerWorldMap_c::onDelete() {
- EmbeddedLayout_FreeArc(this->layout);
- EmbeddedLayout_Free(this->layout);
- EmbeddedLayout_dtor(this->layout, false);
- FreeFromGameHeap1(this->layout);
-
- FreeFromGameHeap1(this->selections);
-
- FreeFile(&this->levelInfoFH);
-
- FreeScene(0);
- FreeScene(1);
-
- DVD_FreeFile(GetDVDClass2(), "SI_kinoko");
- DVD_FreeFile(GetDVDClass2(), "SI_fireflower");
- DVD_FreeFile(GetDVDClass2(), "SI_iceflower");
- DVD_FreeFile(GetDVDClass2(), "SI_penguin");
- DVD_FreeFile(GetDVDClass2(), "SI_propeller");
- DVD_FreeFile(GetDVDClass2(), "SI_star");
-
- return true;
-}
-
-int dScNewerWorldMap_c::onExecute() {
-
- if (QueryGlobal5758(0xFFFFFFFF)) return true;
- if (CheckIfWeCantDoStuff()) return true;
-
- /**************************************************************************/
- // Read Wiimote Buttons
-
- int heldButtons = Remocon_GetButtons(GetActiveRemocon());
- int nowPressed = Remocon_GetPressed(GetActiveRemocon());
-
- /**************************************************************************/
- // State Specific
-
- switch (this->state) {
- /**********************************************************************/
- // STATE_START_DVD : Set up DVD
- case STATE_START_DVD:
-
- DVD_Start();
- this->state = STATE_LOAD_RES;
-
- break;
-
- /**********************************************************************/
- // STATE_LOAD_RES : Load extra stuff we need
- case STATE_LOAD_RES:
-
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_kinoko", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_fireflower", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_iceflower", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_penguin", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_propeller", 0);
- DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_star", 0);
- //DVD_LoadFile(GetDVDClass(), "Object", "fruits_kusa_gake", 0);
-
- this->state = STATE_END_DVD;
-
- break;
-
- /**********************************************************************/
- // STATE_END_DVD : Wait for files to load, end DVD
- case STATE_END_DVD:
-
- if (!DVD_StillLoading(GetDVDClass2())) {
- if (DVD_End()) {
- this->state = STATE_SETUP_WAIT;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SETUP_WAIT : Waiting for the world map managers to be set up
- case STATE_SETUP_WAIT: {
-
- bool success = true;
-
- success &= CSMENU_SETUP_DONE(this->csMenu);
- success &= SELC_SETUP_DONE(this->selectCursor);
- success &= NPCHG_SETUP_DONE(this->numPeopleChange);
- success &= YESNO_SETUP_DONE(this->yesNoWindow);
- success &= CONT_SETUP_DONE(this->continueObj);
- success &= STKI_SETUP_DONE(this->stockItem);
- success &= SIS_SETUP_DONE(this->stockItemShadow);
- success &= EASYP_SETUP_DONE(this->easyPairing);
-
- if (success) {
- // ok, now we can set up other required shit
-
- // first up: player models for Stocked Items
- for (int i = 0; i < 4; i++) {
- void *obj = CreateChildObject(WM_2D_PLAYER, this, i, 0, 0);
- STKI_2DPLAYER(this->stockItem,i) = obj;
- NPCHG_2DPLAYER(this->numPeopleChange,i) = obj;
- }
-
- // next: items for the Powerup screen
- for (int i = 0; i < 7; i++) {
- void *obj = CreateChildObject(WM_ITEM, this, i, 0, 0);
- STKI_ITEM(this->stockItem,i) = obj;
- }
-
- // now, check if we need to handle Continue
- if (CheckIfContinueShouldBeActivated()) {
- this->state = STATE_CONTINUE_WAIT;
- CONT_UNK1(this->continueObj) = true;
- CONT_UNK2(this->continueObj) = true;
- CONT_UNK3(this->continueObj) = false;
- } else {
- this->state = STATE_OPT_CHANGE_WAIT;
- }
- }
-
- } break;
-
- /**********************************************************************/
- // STATE_CONTINUE_WAIT : Waiting for the Continue anim to finish
- case STATE_CONTINUE_WAIT:
-
- if (CONT_DONE(this->continueObj)) {
- CONT_UNK1(this->continueObj) = 0;
- CONT_UNK2(this->continueObj) = 0;
- CONT_UNK3(this->continueObj) = 0;
-
- for (int i = 0; i < 4; i++) {
- int idx = SearchForIndexOfPlayerID(i);
- Player_Lives[Player_ID[idx]] = CONT_LIVES(this->continueObj, i);
- }
-
- this->state = STATE_OPT_CHANGE_WAIT;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_NORMAL : Nothing related to the menu is going on
- case STATE_NORMAL: {
-
- int currentPage = this->currentPage;
- int currentSelection = this->selections[currentPage];
- int newPage = currentPage;
- int newSelection = currentSelection;
-
- // Activate the menu
- if (nowPressed & WPAD_PLUS) {
- CSMENU_ACTIVE(this->csMenu) = true;
- this->state = STATE_CSMENU;
- }
-
- if (nowPressed & WPAD_B) {
- SetSwitchStatus((GetSwitchStatus() + 1) & 15);
- this->GenSBTitle();
- }
-
- // Change the current level
- if ((nowPressed & WPAD_UP) && currentSelection > 0) {
- newSelection = currentSelection - 1;
- }
-
- if ((nowPressed & WPAD_DOWN) && currentSelection < (LevelInfo_GetSection(this->levelInfo, currentPage)->levelCount - 1)) {
- newSelection = currentSelection + 1;
- }
-
- // Change the current world
- if ((nowPressed & WPAD_LEFT) && currentPage > 0) {
- newPage = currentPage - 1;
- }
-
- if ((nowPressed & WPAD_RIGHT) && currentPage < (LevelInfo_GetSectionCount(this->levelInfo) - 1)) {
- newPage = currentPage + 1;
- }
-
-
- if (newPage != currentPage) {
- this->currentPage = newPage;
- this->GenText();
-
- // do this to let the rest of the code handle animations
- newSelection = this->selections[newPage];
- }
-
- if (newSelection != currentSelection) {
- EmbeddedLayout_DisableAllAnims(this->layout);
-
- // enable On animation
- EmbeddedLayout_EnableNonLoopAnim(this->layout, newSelection, false);
-
- // enable Off animation
- EmbeddedLayout_EnableNonLoopAnim(this->layout, currentSelection+15, false);
-
- this->selections[newPage] = newSelection;
- this->state = STATE_OPT_CHANGE_WAIT;
- }
-
-
- // save the info to the file
- if (currentSelection != newSelection || currentPage != newPage) {
- SaveBlock *save = GetSaveFile()->GetBlock(-1);
- save->current_world = newPage;
- save->current_path_node = newSelection;
- }
-
-
- // Enter the current level
- if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- this->StartLevel();
- this->state = STATE_LIMBO; // just in case
- }
-
- if (nowPressed & WPAD_ONE) {
- STKI_SHOW(this->stockItem) = true;
- this->state = STATE_POWERUPS_WAIT;
- }
- } break;
-
- /**********************************************************************/
- // STATE_OPT_CHANGE_WAIT : Waiting for the option change animation to
- // finish playing
- case STATE_OPT_CHANGE_WAIT:
-
- if (!EmbeddedLayout_CheckIfAnimationIsOn(this->layout, -1)) {
- this->state = STATE_NORMAL;
- }
-
- break;
- /**********************************************************************/
- // STATE_CSMENU : The course select menu is currently being shown
- case STATE_CSMENU:
-
- // First off, check to see if it's been hidden
- if (!CSMENU_ACTIVE(this->csMenu)) {
- // That means something happened
- if (CSMENU_CHOICE_OK(this->csMenu)) {
- // Player pressed a button
-
- switch (CSMENU_CURRENT(this->csMenu)) {
- case 0:
- // Star Coins
- //OSReport("Star Coins was pressed\n");
- this->state = STATE_NORMAL;
- break;
-
- case 1:
- // Add/Drop Players
- //OSReport("Add/Drop Players was pressed\n");
- this->state = STATE_PLAYER_CHANGE_WAIT;
- NPCHG_ACTIVE(this->numPeopleChange) = true;
- WpadShit(10);
-
- break;
-
- case 2:
- // Save or Quick Save
- //OSReport("Save or Quick Save was pressed\n");
- if (GetSaveFile()->GetBlock(-1)->bitfield & 2) {
- this->state = STATE_SAVE_OPEN;
- YESNO_TYPE(this->yesNoWindow) = 1;
- YESNO_VISIBLE(this->yesNoWindow) = 1;
-
- } else {
- this->state = STATE_QUICKSAVE_OPEN;
- YESNO_TYPE(this->yesNoWindow) = 15;
- YESNO_VISIBLE(this->yesNoWindow) = 1;
-
- }
-
- break;
-
- case 3:
- // Title Screen
- //OSReport("Title Screen was pressed\n");
- this->state = STATE_TITLE_CONFIRM_OPEN_WAIT;
- YESNO_VISIBLE(this->yesNoWindow) = true;
- YESNO_TYPE(this->yesNoWindow) = 10;
- break;
- }
-
- } else {
- // Ok, change back to STATE_NORMAL
- this->state = STATE_NORMAL;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_TITLE_CONFIRM_OPEN_WAIT : Waiting for the "Go to Title Screen"
- // YesNoWindow to finish opening
- case STATE_TITLE_CONFIRM_OPEN_WAIT:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- this->state = STATE_TITLE_CONFIRM_SELECT;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_TITLE_CONFIRM_SELECT : Let the user choose an option on the
- // "Go to Title Screen" YesNoWindow.
- case STATE_TITLE_CONFIRM_SELECT:
-
- if (nowPressed & WPAD_LEFT) {
- // Select "OK!"
- YESNO_CURRENT(this->yesNoWindow) = 1;
-
- } else if (nowPressed & WPAD_RIGHT) {
- // Select "Cancel"
- YESNO_CURRENT(this->yesNoWindow) = 0;
-
- } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- // Pick the current option
- YESNO_CLOSE(this->yesNoWindow) = true;
- if (YESNO_CURRENT(this->yesNoWindow) != 1)
- YESNO_REFUSED(this->yesNoWindow) = true;
- this->state = STATE_TITLE_CONFIRM_HIT_WAIT;
-
- } else {
- // Cancel using B or 1
- if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) {
- YESNO_CANCELLED(this->yesNoWindow) = true;
- YESNO_CURRENT(this->yesNoWindow) = true;
- this->state = STATE_TITLE_CONFIRM_HIT_WAIT;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_TITLE_CONFIRM_HIT_WAIT : Process the user's chosen option on
- // the "Go to Title Screen" YesNoWindow. Also, wait for the
- // animation to be complete.
- case STATE_TITLE_CONFIRM_HIT_WAIT:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- if (YESNO_CURRENT(this->yesNoWindow) == 1) {
- this->state = STATE_NORMAL;
- } else {
- this->state = STATE_LIMBO;
- StartTitleScreenStage(false, 0);
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_PLAYER_CHANGE_WAIT : Wait for the user to do something on the
- // Add/Drop Players screen.
- case STATE_PLAYER_CHANGE_WAIT:
-
- if (NPCHG_READY(this->numPeopleChange)) {
- if (nowPressed & WPAD_PLUS) {
- // activate easy pairing. FUN !!
- NPCHG_HIDE_FOR_EASYP(this->numPeopleChange) = 1;
-
- for (int i = 0; i < 4; i++) {
- void *obj = NPCHG_2DPLAYER(this->numPeopleChange, i);
- void *ccsb = NPCHG_CCSB(this->numPeopleChange, i);
- void *ccsc = NPCHG_CCSC(this->numPeopleChange, i);
-
- PLAYER2D_SHOW_EASY_PAIRING(obj) = 1;
- CCSB_ACTIVE(ccsb) = 1;
- CCSC_ACTIVE(ccsc) = 1;
- }
-
- EASYP_ACTIVE(this->easyPairing) = 1;
- this->state = STATE_EASY_PAIRING_WAIT;
- }
- } else {
- if (!NPCHG_ACTIVE(this->numPeopleChange)) {
- this->state = STATE_NORMAL;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_EASY_PAIRING_WAIT : Wait for the user to exit Easy Pairing.
- case STATE_EASY_PAIRING_WAIT:
-
- if (!EASYP_ACTIVE(this->easyPairing)) {
- NPCHG_HIDE_FOR_EASYP(this->numPeopleChange) = 0;
-
- for (int i = 0; i < 4; i++) {
- void *obj = NPCHG_2DPLAYER(this->numPeopleChange, i);
- void *ccsb = NPCHG_CCSB(this->numPeopleChange, i);
- void *ccsc = NPCHG_CCSC(this->numPeopleChange, i);
-
- PLAYER2D_SHOW_EASY_PAIRING(obj) = 0;
- CCSB_ACTIVE(ccsb) = 0;
- CCSC_ACTIVE(ccsc) = 0;
- }
-
- this->state = STATE_PLAYER_CHANGE_WAIT;
- WpadShit(10);
- }
-
- break;
-
- /**********************************************************************/
- // STATE_POWERUPS_WAIT : Wait for the user to exit the Powerups screen.
- case STATE_POWERUPS_WAIT:
-
- if (!STKI_SHOW(this->stockItem)) {
- this->state = STATE_NORMAL;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_OPEN : Waiting for the "Save?" YesNoWindow to open
- case STATE_SAVE_OPEN:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- this->state = STATE_SAVE_SELECT;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_SELECT : Let the user choose an option on the
- // "Save?" YesNoWindow.
- case STATE_SAVE_SELECT:
-
- if (nowPressed & WPAD_LEFT) {
- // Select "OK!"
- YESNO_CURRENT(this->yesNoWindow) = 1;
-
- } else if (nowPressed & WPAD_RIGHT) {
- // Select "Cancel"
- YESNO_CURRENT(this->yesNoWindow) = 0;
-
- } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- // Pick the current option
- YESNO_CLOSE(this->yesNoWindow) = true;
-
- if (YESNO_CURRENT(this->yesNoWindow) != 1)
- YESNO_CANCELLED2(this->yesNoWindow) = true;
- this->state = STATE_SAVE_WINDOW_CLOSE;
-
- } else {
- // Cancel using B or 1
- if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) {
- YESNO_CANCELLED(this->yesNoWindow) = true;
- YESNO_CURRENT(this->yesNoWindow) = 1;
- this->state = STATE_SAVE_WINDOW_CLOSE;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_WINDOW_CLOSE : Process the user's chosen option on the
- // "Save?" YesNoWindow. Also, wait for the animation to be complete.
- case STATE_SAVE_WINDOW_CLOSE:
-
- if (!YESNO_VISIBLE(this->yesNoWindow)) {
- if (YESNO_CURRENT(this->yesNoWindow) == 1) {
- this->state = STATE_NORMAL;
- } else {
- this->state = STATE_SAVE_DO;
- SaveGame(0, false);
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_DO : Save the game.
- case STATE_SAVE_DO:
-
- if (!GetSaveFile()->CheckIfWriting()) {
- if (GetSaveHandler()->CurrentError == 0) {
- YESNO_TYPE(this->yesNoWindow) = 2;
- YESNO_VISIBLE(this->yesNoWindow) = true;
- this->state = STATE_SAVE_END_WINDOW;
- } else {
- this->state = STATE_SAVE_ERROR;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_END_WINDOW : Handle the Save End window.
- case STATE_SAVE_END_WINDOW:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- YESNO_CLOSE(this->yesNoWindow) = true;
- this->state = STATE_SAVE_END_CLOSE_WAIT;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_SAVE_END_CLOSE_WAIT : Wait for the Save End window to close.
- case STATE_SAVE_END_CLOSE_WAIT:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- this->state = STATE_NORMAL;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_OPEN : Waiting for the "Save?" YesNoWindow to open
- case STATE_QUICKSAVE_OPEN:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- this->state = STATE_QUICKSAVE_SELECT;
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_SELECT : Let the user choose an option on the
- // "Save?" YesNoWindow.
- case STATE_QUICKSAVE_SELECT:
-
- if (nowPressed & WPAD_LEFT) {
- // Select "OK!"
- YESNO_CURRENT(this->yesNoWindow) = 1;
-
- } else if (nowPressed & WPAD_RIGHT) {
- // Select "Cancel"
- YESNO_CURRENT(this->yesNoWindow) = 0;
-
- } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- // Pick the current option
- YESNO_CLOSE(this->yesNoWindow) = true;
-
- if (YESNO_CURRENT(this->yesNoWindow) != 1)
- YESNO_CANCELLED2(this->yesNoWindow) = true;
- this->state = STATE_QUICKSAVE_WINDOW_CLOSE;
-
- } else {
- // Cancel using B or 1
- if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) {
- YESNO_CANCELLED(this->yesNoWindow) = true;
- YESNO_CURRENT(this->yesNoWindow) = 1;
- this->state = STATE_QUICKSAVE_WINDOW_CLOSE;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_WINDOW_CLOSE : Process the user's chosen option on
- // the "Save?" YesNoWindow. Also, wait for the animation to be complete
- case STATE_QUICKSAVE_WINDOW_CLOSE:
-
- if (!YESNO_VISIBLE(this->yesNoWindow)) {
- if (YESNO_CURRENT(this->yesNoWindow) == 1) {
- this->state = STATE_NORMAL;
- } else {
- this->state = STATE_QUICKSAVE_DO;
- SaveGame(0, true);
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_DO : Save the game.
- case STATE_QUICKSAVE_DO:
-
- if (!GetSaveFile()->CheckIfWriting()) {
- if (GetSaveHandler()->CurrentError == 0) {
- YESNO_TYPE(this->yesNoWindow) = 16;
- YESNO_VISIBLE(this->yesNoWindow) = true;
- this->state = STATE_QUICKSAVE_END_WINDOW;
- } else {
- this->state = STATE_SAVE_ERROR;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_END_WINDOW : Handle the Save End window.
- case STATE_QUICKSAVE_END_WINDOW:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) {
- YESNO_CLOSE(this->yesNoWindow) = true;
- YESNO_REFUSED(this->yesNoWindow) = true;
- this->state = STATE_QUICKSAVE_END_CLOSE_WAIT;
- }
- }
-
- break;
-
- /**********************************************************************/
- // STATE_QUICKSAVE_END_CLOSE_WAIT : Wait for Save End window to close
- case STATE_QUICKSAVE_END_CLOSE_WAIT:
-
- if (!YESNO_OPENING(this->yesNoWindow)) {
- if (YESNO_CURRENT(this->yesNoWindow) == 1) {
- this->state = STATE_NORMAL;
- } else {
- this->state = STATE_LIMBO;
- StartTitleScreenStage(false, 0);
- }
- }
-
- break;
-
- }
-
- if (this->state >= STATE_NORMAL) {
- EmbeddedLayout_Process(this->layout);
- EmbeddedLayout_UpdateMatrix(this->layout);
- }
-
- return true;
-}
-
-int dScNewerWorldMap_c::onDraw() {
- EmbeddedLayout_AddToDrawList(this->layout);
-
- return true;
-}
-
-
-
-void NewerMapDrawFunc() {
- int keepCamera = GetCurrentCameraID();
-
- // All drawing uses scene 1, since that's the only one loaded by GAME_SETUP.
- // Todo: Newer-specific scenes?
-
- // Stage 1
- SetupLYTDrawing();
- DrawAllLayoutsBeforeX(129);
- GXDrawDone(); // is all GXDrawDone really needed..?
-
- // Stage 2
- Reset3DState();
- SetCurrentCameraID(0);
- LinkScene(0);
- SceneCalcWorld(0);
- SceneCameraStuff(0);
- ChangeAlphaUpdate(false);
- CalcMaterial();
- DrawOpa();
- DrawXlu();
- UnlinkScene(0);
- GXDrawDone();
-
- //Reset3DState();
- //T3D::DrawQueue();
-
- // Stage 3
- Reset3DState();
- SetupLYTDrawing();
- DrawAllLayoutsAfterXandBeforeY(128, 146);
- GXDrawDone();
-
- // Stage 4
- RemoveAllFromScnRoot();
- Reset3DState();
- SetCurrentCameraID(1);
-
- DoSpecialDrawing1();
- LinkScene(1);
- SceneCalcWorld(1);
- SceneCameraStuff(1);
- CalcMaterial();
- DrawOpa();
- DrawXlu();
-
- // Stage 5
- if (GAMEMGR_GET_AFC(GameMgr)) {
- for (int i = 0; i < 4; i++) {
- RenderEffects(0, 11+i);
- }
-
- for (int i = 0; i < 4; i++) {
- RenderEffects(0, 7+i);
- }
- }
-
- RenderEffects(0, 2); // need to investigate how this thing works
-
- DrawAllLayoutsAfterX(145);
- ClearLayoutDrawList(); // this is REALLY IMPORTANT!
-
- UnlinkScene(1);
-
- // End
- SetCurrentCameraID(0);
-}
-
+#include "worldmap.h" + +extern "C" void LoadMapScene(); + +dScNewerWorldMap_c *dScNewerWorldMap_c::instance = 0; + + +dScNewerWorldMap_c *dScNewerWorldMap_c::build() { + // return new dScNewerWorldMap_c; + OSReport("Creating WorldMap\n"); + + void *buffer = AllocFromGameHeap1(sizeof(dScNewerWorldMap_c)); + dScNewerWorldMap_c *c = new(buffer) dScNewerWorldMap_c; + + OSReport("Created WorldMap @ %p\n", c); + + instance = c; + return c; +} + + +#define SELC_SETUP_DONE(sc) (*((bool*)(((u32)(sc))+0xD38))) + +#define EASYP_SETUP_DONE(ep) (*((bool*)(((u32)(ep))+0x278))) +#define EASYP_ACTIVE(ep) (*((bool*)(((u32)(ep))+0x279))) + +#define CSMENU_SETUP_DONE(csm) (*((bool*)(((u32)(csm))+0x270))) +#define CSMENU_ACTIVE(csm) (*((bool*)(((u32)(csm))+0x271))) +#define CSMENU_CHOICE_OK(csm) (*((bool*)(((u32)(csm))+0x272))) +#define CSMENU_UNK(csm) (*((bool*)(((u32)(csm))+0x273))) +#define CSMENU_CURRENT(csm) (*((int*)(((u32)(csm))+0x268))) + +#define YESNO_SETUP_DONE(ynw) (*((bool*)(((u32)(ynw))+0x294))) +#define YESNO_VISIBLE(ynw) (*((bool*)(((u32)(ynw))+0x295))) +#define YESNO_CLOSE(ynw) (*((bool*)(((u32)(ynw))+0x296))) +#define YESNO_OPENING(ynw) (*((bool*)(((u32)(ynw))+0x297))) +#define YESNO_REFUSED(ynw) (*((bool*)(((u32)(ynw))+0x298))) +#define YESNO_CANCELLED(ynw) (*((bool*)(((u32)(ynw))+0x299))) +#define YESNO_CANCELLED2(ynw) (*((bool*)(((u32)(ynw))+0x29A))) +#define YESNO_CURRENT(ynw) (*((int*)(((u32)(ynw))+0x284))) +#define YESNO_TYPE(ynw) (*((int*)(((u32)(ynw))+0x28C))) + +#define NPCHG_SETUP_DONE(npc) (*((bool*)(((u32)(npc))+0x67C))) +#define NPCHG_ACTIVE(npc) (*((bool*)(((u32)(npc))+0x67E))) +#define NPCHG_HIDE_FOR_EASYP(npc) (*((bool*)(((u32)(npc))+0x67F))) +#define NPCHG_READY(npc) (*((bool*)(((u32)(npc))+0x680))) +#define NPCHG_CCSB(npc,idx) (((void**)(((u32)(npc))+0x74))[(idx)]) +#define NPCHG_CCSC(npc,idx) (((void**)(((u32)(npc))+0x84))[(idx)]) +#define NPCHG_CCSA(npc,idx) (((void**)(((u32)(npc))+0x94))[(idx)]) +#define NPCHG_CCI(npc,idx) (((void**)(((u32)(npc))+0xA4))[(idx)]) +#define NPCHG_2DPLAYER(npc,idx) (((void**)(((u32)(npc))+0x64C))[(idx)]) + +#define STKI_SETUP_DONE(si) (*((bool*)(((u32)(si))+0x310))) +#define STKI_SHADOW(si) (*((void**)(((u32)(si))+0x310))) +#define STKI_2DPLAYER(si,idx) (((void**)(((u32)(si))+0x2E4))[(idx)]) +#define STKI_ITEM(si,idx) (((void**)(((u32)(si))+0x2F4))[(idx)]) +#define STKI_SHOW(si) (*((bool*)(((u32)(si))+0x8DD))) + +#define SIS_SETUP_DONE(sis) (*((bool*)(((u32)(sis))+0x260))) + +#define CCSB_ACTIVE(ccsb) (*((bool*)(((u32)(ccsb))+0x29C))) + +#define CCSC_ACTIVE(ccsc) (*((bool*)(((u32)(ccsc))+0x2A1))) + +#define PLAYER2D_SHOW_EASY_PAIRING(p2d) (*((bool*)(((u32)(p2d))+0x264))) + +#define CONT_LIVES(cont,idx) (((int*)(((u32)(cont))+0x2B8))[(idx)]) +#define CONT_SETUP_DONE(cont) (*((bool*)(((u32)(cont))+0x2D4))) +#define CONT_UNK1(cont) (*((bool*)(((u32)(cont))+0x2D5))) +#define CONT_UNK2(cont) (*((bool*)(((u32)(cont))+0x2D6))) +#define CONT_DONE(cont) (*((bool*)(((u32)(cont))+0x2D7))) +#define CONT_UNK3(cont) (*((bool*)(((u32)(cont))+0x2E0))) + +inline u8 GetSwitchStatus() { + return *((u8*)(((u32)GameMgr)+0x380)); +} + +inline void SetSwitchStatus(u8 stat) { + *((u8*)(((u32)GameMgr)+0x380)) = stat; +} + +#define STATE_START_DVD 0 +#define STATE_LOAD_RES 1 +#define STATE_END_DVD 2 +#define STATE_SETUP_WAIT 3 +#define STATE_LIMBO 4 +#define STATE_CONTINUE_WAIT 5 +#define STATE_NORMAL 6 +#define STATE_OPT_CHANGE_WAIT 7 +#define STATE_CSMENU 8 +#define STATE_TITLE_CONFIRM_OPEN_WAIT 9 +#define STATE_TITLE_CONFIRM_SELECT 10 +#define STATE_TITLE_CONFIRM_HIT_WAIT 11 +#define STATE_PLAYER_CHANGE_WAIT 12 +#define STATE_EASY_PAIRING_WAIT 13 +#define STATE_POWERUPS_WAIT 14 +#define STATE_SAVE_OPEN 15 +#define STATE_SAVE_SELECT 16 +#define STATE_SAVE_WINDOW_CLOSE 17 +#define STATE_SAVE_DO 18 +#define STATE_SAVE_END_WINDOW 19 +#define STATE_SAVE_END_CLOSE_WAIT 20 +#define STATE_QUICKSAVE_OPEN 21 +#define STATE_QUICKSAVE_SELECT 22 +#define STATE_QUICKSAVE_WINDOW_CLOSE 23 +#define STATE_QUICKSAVE_DO 24 +#define STATE_QUICKSAVE_END_WINDOW 25 +#define STATE_QUICKSAVE_END_CLOSE_WAIT 26 +#define STATE_SAVE_ERROR 27 + +#define MENU_HEIGHT 15 + +const char *anim1 = "optionActivated.brlan"; +const char *anim2 = "optionDeactivated.brlan"; + +const char *group1 = "G_opt00"; +const char *group2 = "G_opt01"; +const char *group3 = "G_opt02"; +const char *group4 = "G_opt03"; +const char *group5 = "G_opt04"; +const char *group6 = "G_opt05"; +const char *group7 = "G_opt06"; +const char *group8 = "G_opt07"; +const char *group9 = "G_opt08"; +const char *group10 = "G_opt09"; +const char *group11 = "G_opt10"; +const char *group12 = "G_opt11"; +const char *group13 = "G_opt12"; +const char *group14 = "G_opt13"; +const char *group15 = "G_opt14"; + + +void dScNewerWorldMap_c::StartLevel() { + LevelInfo_Entry *level = LevelInfo_GetLevels(this->levelInfo, this->currentPage); + level += this->selections[this->currentPage]; + StartLevel(level); +} + +void dScNewerWorldMap_c::StartLevel(LevelInfo_Entry *entry) { + for (int i = 0; i < 4; i++) { + bool isThere = QueryPlayerAvailability(i); + int id = Player_ID[i]; + Player_Active[i] = isThere ? 1 : 0; + if (!isThere) Player_Flags[i] = 0; + } + + StartLevelInfo sl; + sl.unk1 = 0; + sl.unk2 = 0xFF; + sl.unk3 = 0; + sl.unk4 = 0; + sl.purpose = 0; + + sl.world1 = entry->world; + sl.world2 = entry->world; + sl.level1 = entry->level; + sl.level2 = entry->level; + + // hopefully this will fix the Star Coin issues + SetSomeConditionShit(entry->world, entry->level, 2); + + ActivateWipe(WIPE_MARIO); + + DoStartLevel(GetGameMgr(), &sl); +} + +void dScNewerWorldMap_c::SetTitle(const char *text) { + unsigned short conv_buf[0x200]; + int length = strlen(text); + if (length > 0x1FF) + length = 0x1FF; + + for (int i = 0; i < length; i++) { + conv_buf[i] = text[i]; + } + conv_buf[length] = 0; + + void *textBox = EmbeddedLayout_FindTextBoxByName(this->layout, "ScreenTitle"); + TextBox_SetString(textBox, conv_buf, 0); +} + +void dScNewerWorldMap_c::GenSBTitle() { + char buf[0x100]; + sprintf(buf, "Switches: R:%s; G:%s; Y:%s; B:%s", + ((GetSwitchStatus() & 1) != 0) ? "On" : "Off", + ((GetSwitchStatus() & 2) != 0) ? "On" : "Off", + ((GetSwitchStatus() & 4) != 0) ? "On" : "Off", + ((GetSwitchStatus() & 8) != 0) ? "On" : "Off"); + this->SetTitle(buf); +} + +void dScNewerWorldMap_c::GenText() { + char buf[0x1FF]; + char paneNameBuf[0x20]; + char textBoxNameBuf[0x20]; + unsigned short wchars[0x1FF]; + + SaveBlock *save = GetSaveFile()->GetBlock(-1); + + LevelInfo_Section *section = LevelInfo_GetSection(this->levelInfo, this->currentPage); + LevelInfo_Entry *levels = LevelInfo_GetLevels(this->levelInfo, section); + + int count = section->levelCount; + + for (int i = 0; i < MENU_HEIGHT; i++) { + sprintf(paneNameBuf, "Opt%02d", i); + sprintf(textBoxNameBuf, "OptText%02d", i); + void *pane = EmbeddedLayout_FindPaneByName(this->layout, paneNameBuf); + void *textBox = EmbeddedLayout_FindTextBoxByName(this->layout, textBoxNameBuf); + + if (i < count) { + // valid level + PANE_FLAGS(pane) |= 1; + + u32 conds = save->GetLevelCondition(levels[i].world, levels[i].level); + + char cond1, cond2, cond3, cond4, cond5; + cond1 = (conds & COND_NORMAL ? 'x' : '.'); + cond2 = (conds & COND_SECRET ? 'x' : '.'); + cond3 = (conds & COND_COIN1 ? 'x' : '.'); + cond4 = (conds & COND_COIN2 ? 'x' : '.'); + cond5 = (conds & COND_COIN3 ? 'x' : '.'); + + sprintf(buf, "%s %c%c %c%c%c", LevelInfo_GetName(this->levelInfo, &levels[i]), cond1, cond2, cond3, cond4, cond5); + + for (int i = 0; i < 0x1FF; i++) { + wchars[i] = buf[i]; + if (buf[i] == 0) break; + } + + TextBox_SetString(textBox, wchars, 0); + } else { + // invalid, hide the pane + PANE_FLAGS(pane) &= ~1; + } + } +} + +int dScNewerWorldMap_c::onCreate() { + OSReport("1:Loading scene\n"); + + LoadMapScene(); + OSReport("2:Loading scene\n"); + GameSetup__LoadScene(0); // lol, stolen from GAME_SETUP + + OSReport("3:Layout alloc\n"); + this->layout = (Layout*)AllocFromGameHeap1(sizeof(Layout)); + if (!this->layout) { + OSReport("memalloc fail\n"); + InfiniteLoop; + } + + OSReport("4:Layout ctor\n"); + EmbeddedLayout_ctor(this->layout); + OSReport("5:Layout load arc\n"); + EmbeddedLayout_LoadArc(this->layout, "NewerRes/wmap.arc"); + + OSReport("6:Layout build\n"); + if (!EmbeddedLayout_Build(this->layout, "levelSelect.brlyt", 0)) { + OSReport("build fail\n"); + InfiniteLoop; + } + + + OSReport("7:Layout load brlan\n"); + const char *anims[2] = {anim1, anim2}; + EmbeddedLayout_LoadBrlans(this->layout, anims, 2); + + const char *groups[30] = { + group1, group2, group3, group4, group5, + group6, group7, group8, group9, group10, + group11, group12, group13, group14, group15, + group1, group2, group3, group4, group5, + group6, group7, group8, group9, group10, + group11, group12, group13, group14, group15, + }; + + int mappings[30] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + OSReport("8:Layout load group\n"); + EmbeddedLayout_LoadGroups(this->layout, groups, mappings, 30); + + OSReport("9:Layout reset anims\n"); + EmbeddedLayout_DisableAllAnims(this->layout); + + for (int i = 0; i < 15; i++) { + EmbeddedLayout_ResetAnimToInitialState(this->layout, i, false); + } + + + OSReport("10:Item 1\n"); + this->selectCursor = CreateParentedObject(SELECT_CURSOR, this, 0, 0); + OSReport("11:Item 2\n"); + this->csMenu = CreateParentedObject(COURSE_SELECT_MENU, this, 0, 0); + OSReport("12:Item 3\n"); + this->yesNoWindow = CreateParentedObject(YES_NO_WINDOW, this, 0, 0); + OSReport("13:Item 4\n"); + this->numPeopleChange = CreateParentedObject(NUMBER_OF_PEOPLE_CHANGE, this, 0, 0); + + for (int i = 0; i < 4; i++) { + OSReport("14:Character change select %d\n", i); + void *ccsb = CreateParentedObject(CHARACTER_CHANGE_SELECT_BASE, this, i, 0); + void *ccsc = CreateParentedObject(CHARACTER_CHANGE_SELECT_CONTENTS, this, i, 0); + void *ccsa = CreateParentedObject(CHARACTER_CHANGE_SELECT_ARROW, this, i, 0); + void *cci = CreateParentedObject(CHARACTER_CHANGE_INDICATOR, this, i, 0); + + NPCHG_CCSB(this->numPeopleChange, i) = ccsb; + NPCHG_CCSC(this->numPeopleChange, i) = ccsc; + NPCHG_CCSA(this->numPeopleChange, i) = ccsa; + NPCHG_CCI(this->numPeopleChange, i) = cci; + } + + OSReport("15:Item 5\n"); + this->continueObj = CreateParentedObject(CONTINUE, this, 0, 0); + + OSReport("16:Item 6\n"); + this->stockItem = CreateParentedObject(STOCK_ITEM, this, 0, 0); + OSReport("17:Item 7\n"); + this->stockItemShadow = CreateParentedObject(STOCK_ITEM_SHADOW, this, 0, 0); + STKI_SHADOW(this->stockItem) = this->stockItemShadow; + + OSReport("18:Item 8\n"); + this->easyPairing = CreateParentedObject(EASY_PAIRING, this, 0, 0); + + this->state = STATE_START_DVD; + + this->layout->drawOrder = 0; + + *CurrentDrawFunc = NewerMapDrawFunc; + + // level info + OSReport("19:Load level info\n"); + this->levelInfo = LoadFile(&this->levelInfoFH, "/NewerRes/LevelInfo.bin"); + OSReport("20:Prepare level info\n"); + LevelInfo_Prepare(&this->levelInfoFH); + + // load the menu info + OSReport("21:Load save info\n"); + SaveBlock *save = GetSaveFile()->GetBlock(-1); + + this->currentPage = save->current_world; + + // bounds check + if (save->current_path_node >= 15) + save->current_path_node = 0; + + int sCount = LevelInfo_GetSectionCount(this->levelInfo); + this->selections = (int*)AllocFromGameHeap1(sizeof(int) * sCount); + + for (int i = 0; i < sCount; i++) { + this->selections[i] = 0; + } + + this->selections[this->currentPage] = save->current_path_node; + + // show button anim + OSReport("22:Enable anim\n"); + EmbeddedLayout_EnableNonLoopAnim(this->layout, save->current_path_node, false); + + OSReport("23:Make text\n"); + this->GenText(); + this->GenSBTitle(); + + OSReport("24:onCreate complete\n"); + return true; +} + +int dScNewerWorldMap_c::onDelete() { + EmbeddedLayout_FreeArc(this->layout); + EmbeddedLayout_Free(this->layout); + EmbeddedLayout_dtor(this->layout, false); + FreeFromGameHeap1(this->layout); + + FreeFromGameHeap1(this->selections); + + FreeFile(&this->levelInfoFH); + + FreeScene(0); + FreeScene(1); + + DVD_FreeFile(GetDVDClass2(), "SI_kinoko"); + DVD_FreeFile(GetDVDClass2(), "SI_fireflower"); + DVD_FreeFile(GetDVDClass2(), "SI_iceflower"); + DVD_FreeFile(GetDVDClass2(), "SI_penguin"); + DVD_FreeFile(GetDVDClass2(), "SI_propeller"); + DVD_FreeFile(GetDVDClass2(), "SI_star"); + + return true; +} + +int dScNewerWorldMap_c::onExecute() { + + if (QueryGlobal5758(0xFFFFFFFF)) return true; + if (CheckIfWeCantDoStuff()) return true; + + /**************************************************************************/ + // Read Wiimote Buttons + + int heldButtons = Remocon_GetButtons(GetActiveRemocon()); + int nowPressed = Remocon_GetPressed(GetActiveRemocon()); + + /**************************************************************************/ + // State Specific + + switch (this->state) { + /**********************************************************************/ + // STATE_START_DVD : Set up DVD + case STATE_START_DVD: + + DVD_Start(); + this->state = STATE_LOAD_RES; + + break; + + /**********************************************************************/ + // STATE_LOAD_RES : Load extra stuff we need + case STATE_LOAD_RES: + + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_kinoko", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_fireflower", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_iceflower", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_penguin", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_propeller", 0); + DVD_LoadFile(GetDVDClass(), "WorldMap", "SI_star", 0); + //DVD_LoadFile(GetDVDClass(), "Object", "fruits_kusa_gake", 0); + + this->state = STATE_END_DVD; + + break; + + /**********************************************************************/ + // STATE_END_DVD : Wait for files to load, end DVD + case STATE_END_DVD: + + if (!DVD_StillLoading(GetDVDClass2())) { + if (DVD_End()) { + this->state = STATE_SETUP_WAIT; + } + } + + break; + + /**********************************************************************/ + // STATE_SETUP_WAIT : Waiting for the world map managers to be set up + case STATE_SETUP_WAIT: { + + bool success = true; + + success &= CSMENU_SETUP_DONE(this->csMenu); + success &= SELC_SETUP_DONE(this->selectCursor); + success &= NPCHG_SETUP_DONE(this->numPeopleChange); + success &= YESNO_SETUP_DONE(this->yesNoWindow); + success &= CONT_SETUP_DONE(this->continueObj); + success &= STKI_SETUP_DONE(this->stockItem); + success &= SIS_SETUP_DONE(this->stockItemShadow); + success &= EASYP_SETUP_DONE(this->easyPairing); + + if (success) { + // ok, now we can set up other required shit + + // first up: player models for Stocked Items + for (int i = 0; i < 4; i++) { + void *obj = CreateChildObject(WM_2D_PLAYER, this, i, 0, 0); + STKI_2DPLAYER(this->stockItem,i) = obj; + NPCHG_2DPLAYER(this->numPeopleChange,i) = obj; + } + + // next: items for the Powerup screen + for (int i = 0; i < 7; i++) { + void *obj = CreateChildObject(WM_ITEM, this, i, 0, 0); + STKI_ITEM(this->stockItem,i) = obj; + } + + // now, check if we need to handle Continue + if (CheckIfContinueShouldBeActivated()) { + this->state = STATE_CONTINUE_WAIT; + CONT_UNK1(this->continueObj) = true; + CONT_UNK2(this->continueObj) = true; + CONT_UNK3(this->continueObj) = false; + } else { + this->state = STATE_OPT_CHANGE_WAIT; + } + } + + } break; + + /**********************************************************************/ + // STATE_CONTINUE_WAIT : Waiting for the Continue anim to finish + case STATE_CONTINUE_WAIT: + + if (CONT_DONE(this->continueObj)) { + CONT_UNK1(this->continueObj) = 0; + CONT_UNK2(this->continueObj) = 0; + CONT_UNK3(this->continueObj) = 0; + + for (int i = 0; i < 4; i++) { + int idx = SearchForIndexOfPlayerID(i); + Player_Lives[Player_ID[idx]] = CONT_LIVES(this->continueObj, i); + } + + this->state = STATE_OPT_CHANGE_WAIT; + } + + break; + + /**********************************************************************/ + // STATE_NORMAL : Nothing related to the menu is going on + case STATE_NORMAL: { + + int currentPage = this->currentPage; + int currentSelection = this->selections[currentPage]; + int newPage = currentPage; + int newSelection = currentSelection; + + // Activate the menu + if (nowPressed & WPAD_PLUS) { + CSMENU_ACTIVE(this->csMenu) = true; + this->state = STATE_CSMENU; + } + + if (nowPressed & WPAD_B) { + SetSwitchStatus((GetSwitchStatus() + 1) & 15); + this->GenSBTitle(); + } + + // Change the current level + if ((nowPressed & WPAD_UP) && currentSelection > 0) { + newSelection = currentSelection - 1; + } + + if ((nowPressed & WPAD_DOWN) && currentSelection < (LevelInfo_GetSection(this->levelInfo, currentPage)->levelCount - 1)) { + newSelection = currentSelection + 1; + } + + // Change the current world + if ((nowPressed & WPAD_LEFT) && currentPage > 0) { + newPage = currentPage - 1; + } + + if ((nowPressed & WPAD_RIGHT) && currentPage < (LevelInfo_GetSectionCount(this->levelInfo) - 1)) { + newPage = currentPage + 1; + } + + + if (newPage != currentPage) { + this->currentPage = newPage; + this->GenText(); + + // do this to let the rest of the code handle animations + newSelection = this->selections[newPage]; + } + + if (newSelection != currentSelection) { + EmbeddedLayout_DisableAllAnims(this->layout); + + // enable On animation + EmbeddedLayout_EnableNonLoopAnim(this->layout, newSelection, false); + + // enable Off animation + EmbeddedLayout_EnableNonLoopAnim(this->layout, currentSelection+15, false); + + this->selections[newPage] = newSelection; + this->state = STATE_OPT_CHANGE_WAIT; + } + + + // save the info to the file + if (currentSelection != newSelection || currentPage != newPage) { + SaveBlock *save = GetSaveFile()->GetBlock(-1); + save->current_world = newPage; + save->current_path_node = newSelection; + } + + + // Enter the current level + if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + this->StartLevel(); + this->state = STATE_LIMBO; // just in case + } + + if (nowPressed & WPAD_ONE) { + STKI_SHOW(this->stockItem) = true; + this->state = STATE_POWERUPS_WAIT; + } + } break; + + /**********************************************************************/ + // STATE_OPT_CHANGE_WAIT : Waiting for the option change animation to + // finish playing + case STATE_OPT_CHANGE_WAIT: + + if (!EmbeddedLayout_CheckIfAnimationIsOn(this->layout, -1)) { + this->state = STATE_NORMAL; + } + + break; + /**********************************************************************/ + // STATE_CSMENU : The course select menu is currently being shown + case STATE_CSMENU: + + // First off, check to see if it's been hidden + if (!CSMENU_ACTIVE(this->csMenu)) { + // That means something happened + if (CSMENU_CHOICE_OK(this->csMenu)) { + // Player pressed a button + + switch (CSMENU_CURRENT(this->csMenu)) { + case 0: + // Star Coins + //OSReport("Star Coins was pressed\n"); + this->state = STATE_NORMAL; + break; + + case 1: + // Add/Drop Players + //OSReport("Add/Drop Players was pressed\n"); + this->state = STATE_PLAYER_CHANGE_WAIT; + NPCHG_ACTIVE(this->numPeopleChange) = true; + WpadShit(10); + + break; + + case 2: + // Save or Quick Save + //OSReport("Save or Quick Save was pressed\n"); + if (GetSaveFile()->GetBlock(-1)->bitfield & 2) { + this->state = STATE_SAVE_OPEN; + YESNO_TYPE(this->yesNoWindow) = 1; + YESNO_VISIBLE(this->yesNoWindow) = 1; + + } else { + this->state = STATE_QUICKSAVE_OPEN; + YESNO_TYPE(this->yesNoWindow) = 15; + YESNO_VISIBLE(this->yesNoWindow) = 1; + + } + + break; + + case 3: + // Title Screen + //OSReport("Title Screen was pressed\n"); + this->state = STATE_TITLE_CONFIRM_OPEN_WAIT; + YESNO_VISIBLE(this->yesNoWindow) = true; + YESNO_TYPE(this->yesNoWindow) = 10; + break; + } + + } else { + // Ok, change back to STATE_NORMAL + this->state = STATE_NORMAL; + } + } + + break; + + /**********************************************************************/ + // STATE_TITLE_CONFIRM_OPEN_WAIT : Waiting for the "Go to Title Screen" + // YesNoWindow to finish opening + case STATE_TITLE_CONFIRM_OPEN_WAIT: + + if (!YESNO_OPENING(this->yesNoWindow)) { + this->state = STATE_TITLE_CONFIRM_SELECT; + } + + break; + + /**********************************************************************/ + // STATE_TITLE_CONFIRM_SELECT : Let the user choose an option on the + // "Go to Title Screen" YesNoWindow. + case STATE_TITLE_CONFIRM_SELECT: + + if (nowPressed & WPAD_LEFT) { + // Select "OK!" + YESNO_CURRENT(this->yesNoWindow) = 1; + + } else if (nowPressed & WPAD_RIGHT) { + // Select "Cancel" + YESNO_CURRENT(this->yesNoWindow) = 0; + + } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + // Pick the current option + YESNO_CLOSE(this->yesNoWindow) = true; + if (YESNO_CURRENT(this->yesNoWindow) != 1) + YESNO_REFUSED(this->yesNoWindow) = true; + this->state = STATE_TITLE_CONFIRM_HIT_WAIT; + + } else { + // Cancel using B or 1 + if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) { + YESNO_CANCELLED(this->yesNoWindow) = true; + YESNO_CURRENT(this->yesNoWindow) = true; + this->state = STATE_TITLE_CONFIRM_HIT_WAIT; + } + } + + break; + + /**********************************************************************/ + // STATE_TITLE_CONFIRM_HIT_WAIT : Process the user's chosen option on + // the "Go to Title Screen" YesNoWindow. Also, wait for the + // animation to be complete. + case STATE_TITLE_CONFIRM_HIT_WAIT: + + if (!YESNO_OPENING(this->yesNoWindow)) { + if (YESNO_CURRENT(this->yesNoWindow) == 1) { + this->state = STATE_NORMAL; + } else { + this->state = STATE_LIMBO; + StartTitleScreenStage(false, 0); + } + } + + break; + + /**********************************************************************/ + // STATE_PLAYER_CHANGE_WAIT : Wait for the user to do something on the + // Add/Drop Players screen. + case STATE_PLAYER_CHANGE_WAIT: + + if (NPCHG_READY(this->numPeopleChange)) { + if (nowPressed & WPAD_PLUS) { + // activate easy pairing. FUN !! + NPCHG_HIDE_FOR_EASYP(this->numPeopleChange) = 1; + + for (int i = 0; i < 4; i++) { + void *obj = NPCHG_2DPLAYER(this->numPeopleChange, i); + void *ccsb = NPCHG_CCSB(this->numPeopleChange, i); + void *ccsc = NPCHG_CCSC(this->numPeopleChange, i); + + PLAYER2D_SHOW_EASY_PAIRING(obj) = 1; + CCSB_ACTIVE(ccsb) = 1; + CCSC_ACTIVE(ccsc) = 1; + } + + EASYP_ACTIVE(this->easyPairing) = 1; + this->state = STATE_EASY_PAIRING_WAIT; + } + } else { + if (!NPCHG_ACTIVE(this->numPeopleChange)) { + this->state = STATE_NORMAL; + } + } + + break; + + /**********************************************************************/ + // STATE_EASY_PAIRING_WAIT : Wait for the user to exit Easy Pairing. + case STATE_EASY_PAIRING_WAIT: + + if (!EASYP_ACTIVE(this->easyPairing)) { + NPCHG_HIDE_FOR_EASYP(this->numPeopleChange) = 0; + + for (int i = 0; i < 4; i++) { + void *obj = NPCHG_2DPLAYER(this->numPeopleChange, i); + void *ccsb = NPCHG_CCSB(this->numPeopleChange, i); + void *ccsc = NPCHG_CCSC(this->numPeopleChange, i); + + PLAYER2D_SHOW_EASY_PAIRING(obj) = 0; + CCSB_ACTIVE(ccsb) = 0; + CCSC_ACTIVE(ccsc) = 0; + } + + this->state = STATE_PLAYER_CHANGE_WAIT; + WpadShit(10); + } + + break; + + /**********************************************************************/ + // STATE_POWERUPS_WAIT : Wait for the user to exit the Powerups screen. + case STATE_POWERUPS_WAIT: + + if (!STKI_SHOW(this->stockItem)) { + this->state = STATE_NORMAL; + } + + break; + + /**********************************************************************/ + // STATE_SAVE_OPEN : Waiting for the "Save?" YesNoWindow to open + case STATE_SAVE_OPEN: + + if (!YESNO_OPENING(this->yesNoWindow)) { + this->state = STATE_SAVE_SELECT; + } + + break; + + /**********************************************************************/ + // STATE_SAVE_SELECT : Let the user choose an option on the + // "Save?" YesNoWindow. + case STATE_SAVE_SELECT: + + if (nowPressed & WPAD_LEFT) { + // Select "OK!" + YESNO_CURRENT(this->yesNoWindow) = 1; + + } else if (nowPressed & WPAD_RIGHT) { + // Select "Cancel" + YESNO_CURRENT(this->yesNoWindow) = 0; + + } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + // Pick the current option + YESNO_CLOSE(this->yesNoWindow) = true; + + if (YESNO_CURRENT(this->yesNoWindow) != 1) + YESNO_CANCELLED2(this->yesNoWindow) = true; + this->state = STATE_SAVE_WINDOW_CLOSE; + + } else { + // Cancel using B or 1 + if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) { + YESNO_CANCELLED(this->yesNoWindow) = true; + YESNO_CURRENT(this->yesNoWindow) = 1; + this->state = STATE_SAVE_WINDOW_CLOSE; + } + } + + break; + + /**********************************************************************/ + // STATE_SAVE_WINDOW_CLOSE : Process the user's chosen option on the + // "Save?" YesNoWindow. Also, wait for the animation to be complete. + case STATE_SAVE_WINDOW_CLOSE: + + if (!YESNO_VISIBLE(this->yesNoWindow)) { + if (YESNO_CURRENT(this->yesNoWindow) == 1) { + this->state = STATE_NORMAL; + } else { + this->state = STATE_SAVE_DO; + SaveGame(0, false); + } + } + + break; + + /**********************************************************************/ + // STATE_SAVE_DO : Save the game. + case STATE_SAVE_DO: + + if (!GetSaveFile()->CheckIfWriting()) { + if (GetSaveHandler()->CurrentError == 0) { + YESNO_TYPE(this->yesNoWindow) = 2; + YESNO_VISIBLE(this->yesNoWindow) = true; + this->state = STATE_SAVE_END_WINDOW; + } else { + this->state = STATE_SAVE_ERROR; + } + } + + break; + + /**********************************************************************/ + // STATE_SAVE_END_WINDOW : Handle the Save End window. + case STATE_SAVE_END_WINDOW: + + if (!YESNO_OPENING(this->yesNoWindow)) { + if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + YESNO_CLOSE(this->yesNoWindow) = true; + this->state = STATE_SAVE_END_CLOSE_WAIT; + } + } + + break; + + /**********************************************************************/ + // STATE_SAVE_END_CLOSE_WAIT : Wait for the Save End window to close. + case STATE_SAVE_END_CLOSE_WAIT: + + if (!YESNO_OPENING(this->yesNoWindow)) { + this->state = STATE_NORMAL; + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_OPEN : Waiting for the "Save?" YesNoWindow to open + case STATE_QUICKSAVE_OPEN: + + if (!YESNO_OPENING(this->yesNoWindow)) { + this->state = STATE_QUICKSAVE_SELECT; + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_SELECT : Let the user choose an option on the + // "Save?" YesNoWindow. + case STATE_QUICKSAVE_SELECT: + + if (nowPressed & WPAD_LEFT) { + // Select "OK!" + YESNO_CURRENT(this->yesNoWindow) = 1; + + } else if (nowPressed & WPAD_RIGHT) { + // Select "Cancel" + YESNO_CURRENT(this->yesNoWindow) = 0; + + } else if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + // Pick the current option + YESNO_CLOSE(this->yesNoWindow) = true; + + if (YESNO_CURRENT(this->yesNoWindow) != 1) + YESNO_CANCELLED2(this->yesNoWindow) = true; + this->state = STATE_QUICKSAVE_WINDOW_CLOSE; + + } else { + // Cancel using B or 1 + if (CheckIfMenuShouldBeCancelledForSpecifiedWiimote(0)) { + YESNO_CANCELLED(this->yesNoWindow) = true; + YESNO_CURRENT(this->yesNoWindow) = 1; + this->state = STATE_QUICKSAVE_WINDOW_CLOSE; + } + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_WINDOW_CLOSE : Process the user's chosen option on + // the "Save?" YesNoWindow. Also, wait for the animation to be complete + case STATE_QUICKSAVE_WINDOW_CLOSE: + + if (!YESNO_VISIBLE(this->yesNoWindow)) { + if (YESNO_CURRENT(this->yesNoWindow) == 1) { + this->state = STATE_NORMAL; + } else { + this->state = STATE_QUICKSAVE_DO; + SaveGame(0, true); + } + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_DO : Save the game. + case STATE_QUICKSAVE_DO: + + if (!GetSaveFile()->CheckIfWriting()) { + if (GetSaveHandler()->CurrentError == 0) { + YESNO_TYPE(this->yesNoWindow) = 16; + YESNO_VISIBLE(this->yesNoWindow) = true; + this->state = STATE_QUICKSAVE_END_WINDOW; + } else { + this->state = STATE_SAVE_ERROR; + } + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_END_WINDOW : Handle the Save End window. + case STATE_QUICKSAVE_END_WINDOW: + + if (!YESNO_OPENING(this->yesNoWindow)) { + if (Wiimote_TestButtons(GetActiveWiimote(), WPAD_A | WPAD_TWO)) { + YESNO_CLOSE(this->yesNoWindow) = true; + YESNO_REFUSED(this->yesNoWindow) = true; + this->state = STATE_QUICKSAVE_END_CLOSE_WAIT; + } + } + + break; + + /**********************************************************************/ + // STATE_QUICKSAVE_END_CLOSE_WAIT : Wait for Save End window to close + case STATE_QUICKSAVE_END_CLOSE_WAIT: + + if (!YESNO_OPENING(this->yesNoWindow)) { + if (YESNO_CURRENT(this->yesNoWindow) == 1) { + this->state = STATE_NORMAL; + } else { + this->state = STATE_LIMBO; + StartTitleScreenStage(false, 0); + } + } + + break; + + } + + if (this->state >= STATE_NORMAL) { + EmbeddedLayout_Process(this->layout); + EmbeddedLayout_UpdateMatrix(this->layout); + } + + return true; +} + +int dScNewerWorldMap_c::onDraw() { + EmbeddedLayout_AddToDrawList(this->layout); + + return true; +} + + + +void NewerMapDrawFunc() { + int keepCamera = GetCurrentCameraID(); + + // All drawing uses scene 1, since that's the only one loaded by GAME_SETUP. + // Todo: Newer-specific scenes? + + // Stage 1 + SetupLYTDrawing(); + DrawAllLayoutsBeforeX(129); + GXDrawDone(); // is all GXDrawDone really needed..? + + // Stage 2 + Reset3DState(); + SetCurrentCameraID(0); + LinkScene(0); + SceneCalcWorld(0); + SceneCameraStuff(0); + ChangeAlphaUpdate(false); + CalcMaterial(); + DrawOpa(); + DrawXlu(); + UnlinkScene(0); + GXDrawDone(); + + //Reset3DState(); + //T3D::DrawQueue(); + + // Stage 3 + Reset3DState(); + SetupLYTDrawing(); + DrawAllLayoutsAfterXandBeforeY(128, 146); + GXDrawDone(); + + // Stage 4 + RemoveAllFromScnRoot(); + Reset3DState(); + SetCurrentCameraID(1); + + DoSpecialDrawing1(); + LinkScene(1); + SceneCalcWorld(1); + SceneCameraStuff(1); + CalcMaterial(); + DrawOpa(); + DrawXlu(); + + // Stage 5 + if (GAMEMGR_GET_AFC(GameMgr)) { + for (int i = 0; i < 4; i++) { + RenderEffects(0, 11+i); + } + + for (int i = 0; i < 4; i++) { + RenderEffects(0, 7+i); + } + } + + RenderEffects(0, 2); // need to investigate how this thing works + + DrawAllLayoutsAfterX(145); + ClearLayoutDrawList(); // this is REALLY IMPORTANT! + + UnlinkScene(1); + + // End + SetCurrentCameraID(0); +} + diff --git a/src/worldmap.h b/src/worldmap.h index 0cf567e..82032e6 100644 --- a/src/worldmap.h +++ b/src/worldmap.h @@ -1,63 +1,63 @@ -/*
- * Newer Super Mario Bros. Wii
- * World Maps
- *
- * Wish me luck. That's all I'm saying. --Treeki
- * Started: 03/06/2010; 11:52pm
- */
-
-// TODO: add Save Error state
-
-//#define WM_DEBUGGING
-
-#include <common.h>
-#include <game.h>
-
-#include "layoutlib.h"
-#include "fileload.h"
-#include "levelinfo.h"
-
-#ifdef WM_DEBUGGING
-#define MapReport OSReport
-#else
-inline void MapReport(const char *str, ...) { }
-#endif
-
-void NewerMapDrawFunc();
-
-
-// WORLD MAP CLASS LAYOUT
-class dScNewerWorldMap_c : public dScene_c {
-public:
- Layout *layout;
- int currentPage;
- int *selections;
- int state;
- void *csMenu;
- void *selectCursor;
- void *numPeopleChange;
- void *yesNoWindow;
- void *continueObj;
- void *stockItem;
- void *stockItemShadow;
- void *easyPairing;
-
- void *levelInfo;
- FileHandle levelInfoFH;
-
- void StartLevel(LevelInfo_Entry *entry);
-
- void StartLevel();
- void GenText();
- void GenSBTitle();
- void SetTitle(const char *text);
-
- int onCreate();
- int onDelete();
- int onExecute();
- int onDraw();
-
- static dScNewerWorldMap_c *build();
- static dScNewerWorldMap_c *instance;
-};
-
+/* + * Newer Super Mario Bros. Wii + * World Maps + * + * Wish me luck. That's all I'm saying. --Treeki + * Started: 03/06/2010; 11:52pm + */ + +// TODO: add Save Error state + +//#define WM_DEBUGGING + +#include <common.h> +#include <game.h> + +#include "layoutlib.h" +#include "fileload.h" +#include "levelinfo.h" + +#ifdef WM_DEBUGGING +#define MapReport OSReport +#else +inline void MapReport(const char *str, ...) { } +#endif + +void NewerMapDrawFunc(); + + +// WORLD MAP CLASS LAYOUT +class dScNewerWorldMap_c : public dScene_c { +public: + Layout *layout; + int currentPage; + int *selections; + int state; + void *csMenu; + void *selectCursor; + void *numPeopleChange; + void *yesNoWindow; + void *continueObj; + void *stockItem; + void *stockItemShadow; + void *easyPairing; + + void *levelInfo; + FileHandle levelInfoFH; + + void StartLevel(LevelInfo_Entry *entry); + + void StartLevel(); + void GenText(); + void GenSBTitle(); + void SetTitle(const char *text); + + int onCreate(); + int onDelete(); + int onExecute(); + int onDraw(); + + static dScNewerWorldMap_c *build(); + static dScNewerWorldMap_c *instance; +}; + |