Decompiled all known swdrv functions

This commit is contained in:
Seeky 2020-12-22 14:15:39 +00:00
parent c2231104f7
commit 847868c099
4 changed files with 83 additions and 14 deletions

View File

@ -1,3 +1,7 @@
/*
Functions to execute interpreted evt script code and handle evt variables
*/
#ifndef EVTMGR_CMD_H
#define EVTMGR_CMD_H

View File

@ -8,10 +8,10 @@ typedef struct {
s64 time;
u8 unknown_0x100[0x140 - 0x100];
s32 gsw0;
u32 gswf[256];
u8 gsw[2048];
s32 lswf[16];
u8 lsw[1024];
u32 gswf[256]; // 8192 flags
s8 gsw[2048];
u32 lswf[16]; // 512 flags
s8 lsw[1024];
u8 unknown_0x1184[0x900]; // coin related?
u8 unknown_0x1a84[0x1ab0 - 0x1a84];
} SpmarioGlobals;

View File

@ -1,3 +1,11 @@
/*
Functions handling "Saved Work", which are variables used in evt
scripts that are saved when closing the game
Set, Get & Clear functions handle bools
ByteGet and ByteSet functions handle s8 (or s32 for gsw0)
LSW(F) functions are prefixed by an underscore, the rest are GSW(F)
*/
#ifndef SWDRV_H
#define SWDRV_H
@ -33,22 +41,53 @@ void swClear(s32 num); // 80038034
/*
Sets a global saved work value
Value cast to s8 unless setting GSW 0
Value cast to u8 unless setting GSW 0
*/
void swByteSet(s32 num, s32 value);
void swByteSet(s32 num, s32 value); // 80038074
/*
Gets a global saved work value
Return is s8 unless getting GSW 0
Return is u8 unless getting GSW 0
*/
s32 swByteGet(s32 num);
s32 swByteGet(s32 num); // 800380f8
/*
Turns on a local saved work flag
*/
void _swSet(s32 num); // 8003811c
/*
Returns the value of a local saved work flag
*/
bool _swGet(s32 num); // 8003815c
/*
Turns off a local saved work flag
*/
void _swClear(s32 num); // 800381a4
// _swSet
s32 _swGet(s32 num);
// _swClear
// TTYD symbol map shows there's an _swToggle but it went unused in both games
// _swToggle
// _swByteSet
/*
Sets a local saved work value
*/
void _swByteSet(s32 num, s8 value);
/*
Returns a local saved work value
Note: return is technically just s8 but calls used wrong casts when it was set to that
*/
s32 _swByteGet(s32 num);
// New to SPM so no symbols:
// 80038204
// 800383a0
// 80038478
// 80038550
// 8003863c
// 8003864c
// 8003865c
// 8003875c
// 800387d8
#endif

View File

@ -1,3 +1,7 @@
/*
80037eac-800388b3
*/
#include <common.h>
#include <evtmgr_cmd.h>
#include <somewhere.h>
@ -45,7 +49,7 @@ void swByteSet(s32 num, s32 value) {
else {
// "The value is strange"
assertf(num < 256, "値がおかしい sw_byte[%d] = %d", num + EVTDAT_LSW_BASE, value);
gp->gsw[num] = (u8) value;
gp->gsw[num] = (s8) value;
}
}
@ -54,5 +58,27 @@ s32 swByteGet(s32 num) {
else return gp->gsw[num];
}
void _swSet(s32 num) {
gp->lswf[num / 32] |= 1U << (num % 32);
}
bool _swGet(s32 num) {
u32 mask = 1U << (num % 32);
u32 dat = gp->lswf[num / 32];
return (bool) (mask & dat);
}
void _swClear(s32 num) {
gp->lswf[num / 32] &= ~(1U << (num % 32));
}
void _swByteSet(s32 num, s8 value) {
gp->lsw[num] = (s8) value;
}
s32 _swByteGet(s32 num) {
return gp->gsw[num];
}
// a lot