Skip to content

Commit

Permalink
Merge pull request #16 from robojumper/sLib_math
Browse files Browse the repository at this point in the history
A bit of sLib math
  • Loading branch information
elijah-thomas774 authored Aug 27, 2024
2 parents 25015d8 + 3740623 commit 7e5c3b5
Show file tree
Hide file tree
Showing 14 changed files with 587 additions and 63 deletions.
7 changes: 7 additions & 0 deletions config/SOUE01/splits.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,13 @@ s/s_StateMethod.cpp:
s/s_StateMethodUsr_FI.cpp:
.text start:0x802DE540 end:0x802DE6EC

s/s_Crc.cpp:
.text start:0x802DE6F0 end:0x802DE6F4

s/s_Math.cpp:
.text start:0x802DE740 end:0x802DEEB0
.sdata2 start:0x8057CC38 end:0x8057CC40

s/s_Phase.cpp:
.text start:0x802DEEB0 end:0x802DEF74

Expand Down
41 changes: 21 additions & 20 deletions config/SOUE01/symbols.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17198,28 +17198,29 @@ initializeStateLocalMethod__20sStateMethodUsr_FI_cFv = .text:0x802DE580; // type
executeStateLocalMethod__20sStateMethodUsr_FI_cFv = .text:0x802DE5F0; // type:function size:0x4C
finalizeStateLocalMethod__20sStateMethodUsr_FI_cFv = .text:0x802DE640; // type:function size:0x54
changeStateLocalMethod__20sStateMethodUsr_FI_cFRC12sStateIDIf_c = .text:0x802DE6A0; // type:function size:0x4C
fn_802DE6F0 = .text:0x802DE6F0; // type:function size:0x4
calcCRC__4sCrcFPCvUl = .text:0x802DE6F0; // type:function size:0x4
fn_802DE700 = .text:0x802DE700; // type:function size:0x8
fn_802DE710 = .text:0x802DE710; // type:function size:0x2C
fn_802DE740 = .text:0x802DE740; // type:function size:0x24
fn_802DE770 = .text:0x802DE770; // type:function size:0xC0
fn_802DE830 = .text:0x802DE830; // type:function size:0x44
fn_802DE880 = .text:0x802DE880; // type:function size:0x38
fn_802DE8C0 = .text:0x802DE8C0; // type:function size:0xC
fn_802DE8D0 = .text:0x802DE8D0; // type:function size:0x14
fn_802DE8F0 = .text:0x802DE8F0; // type:function size:0xB4
fn_802DE9B0 = .text:0x802DE9B0; // type:function size:0x5C
extrapolate__4sLibFfff = .text:0x802DE740; // type:function size:0x24
addCalc__4sLibFPfffff = .text:0x802DE770; // type:function size:0xC0
addCalcScaledDiff__4sLibFPffff = .text:0x802DE830; // type:function size:0x44
addCalcScaled__4sLibFPfff = .text:0x802DE880; // type:function size:0x38
absDiff__4sLibFss = .text:0x802DE8C0; // type:function size:0xC
addCalcAngle__4sLibFPsssss = .text:0x802DE8D0; // type:function size:0x14
addCalcAngleT<s>__4sLibFPsssss_s = .text:0x802DE8F0; // type:function size:0xB4
addCalcAngle__4sLibFPssss = .text:0x802DE9B0; // type:function size:0x10
addCalcAngleT<s>__4sLibFPssss_v = .text:0x802DE9C0; // type:function size:0x4C
fn_802DEA10 = .text:0x802DEA10; // type:function size:0x164
fn_802DEB80 = .text:0x802DEB80; // type:function size:0x6C
fn_802DEBF0 = .text:0x802DEBF0; // type:function size:0xC
fn_802DEC00 = .text:0x802DEC00; // type:function size:0x58
fn_802DEC60 = .text:0x802DEC60; // type:function size:0x4
fn_802DEC70 = .text:0x802DEC70; // type:function size:0x50
fn_802DECC0 = .text:0x802DECC0; // type:function size:0x4
fn_802DECD0 = .text:0x802DECD0; // type:function size:0x64
fn_802DED40 = .text:0x802DED40; // type:function size:0x4
fn_802DED50 = .text:0x802DED50; // type:function size:0x50
fn_802DEDA0 = .text:0x802DEDA0; // type:function size:0x64
chaseUC__4sLibFPUcUcUc = .text:0x802DEB80; // type:function size:0x6C
chase__4sLibFPsss = .text:0x802DEBF0; // type:function size:0xC
chaseT<s>__4sLibFPsss_i = .text:0x802DEC00; // type:function size:0x58
chase__4sLibFPiii = .text:0x802DEC60; // type:function size:0x4
chaseT<i>__4sLibFPiii_i = .text:0x802DEC70; // type:function size:0x50
chase__4sLibFPfff = .text:0x802DECC0; // type:function size:0x4
chaseT<f>__4sLibFPfff_i = .text:0x802DECD0; // type:function size:0x64
isInRange__4sLibFfff = .text:0x802DED40; // type:function size:0x4
isInRangeT<f>__4sLibFfff_i = .text:0x802DED50; // type:function size:0x50
chaseAngle__4sLibFPsss = .text:0x802DEDA0; // type:function size:0x64
fn_802DEE10 = .text:0x802DEE10; // type:function size:0x98
__ct__8sPhase_cFPPFPv_Q28sPhase_c15METHOD_RESULT_ei = .text:0x802DEEB0; // type:function size:0x14
callMethod__8sPhase_cFPv = .text:0x802DEED0; // type:function size:0xA4
Expand Down Expand Up @@ -22102,7 +22103,7 @@ fn_803AFCD0 = .text:0x803AFCD0; // type:function size:0xEC
__OSPlayTimeAlarmExpired = .text:0x803AFDC0; // type:function size:0xA0 scope:local
__OSGetPlayTime = .text:0x803AFE60; // type:function size:0x1CC scope:global
__OSInitPlayTime = .text:0x803B0030; // type:function size:0x158 scope:global
fn_803B0190 = .text:0x803B0190; // type:function size:0x134
OSCalcCRC32 = .text:0x803B0190; // type:function size:0x134
fn_803B02D0 = .text:0x803B02D0; // type:function size:0x204
__init_user = .text:0x803B04E0; // type:function size:0x20 scope:global
__init_cpp = .text:0x803B0500; // type:function size:0x48 scope:local
Expand Down
49 changes: 35 additions & 14 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,6 @@
action="store_true",
help="generate map file(s)",
)
parser.add_argument(
"--no-asm",
action="store_true",
help="don't incorporate .s files from asm directory",
)
parser.add_argument(
"--debug",
action="store_true",
Expand All @@ -94,6 +89,12 @@
type=Path,
help="path to decomp-toolkit binary or source (optional)",
)
parser.add_argument(
"--objdiff",
metavar="BINARY | DIR",
type=Path,
help="path to objdiff-cli binary or source (optional)",
)
parser.add_argument(
"--sjiswrap",
metavar="EXE",
Expand Down Expand Up @@ -128,15 +129,16 @@
config.sjiswrap_path = args.sjiswrap
if not is_windows():
config.wrapper = args.wrapper
if args.no_asm:
if not config.non_matching:
config.asm_dir = None

# Tool versions
config.binutils_tag = "2.42-1"
config.compilers_tag = "20231018"
config.dtk_tag = "v0.9.0"
config.compilers_tag = "20240706"
config.dtk_tag = "v0.9.4"
config.objdiff_tag = "v2.0.0-beta.3"
config.sjiswrap_tag = "v1.1.1"
config.wibo_tag = "0.6.14"
config.wibo_tag = "0.6.11"

# Project
config.config_path = Path("config") / config.version / "config.yml"
Expand Down Expand Up @@ -286,9 +288,10 @@ def nw4rLib(lib_name, objects, extra_cflags=[]):

Matching = True
NonMatching = False
Equivalent = config.non_matching # Object should be linked when configured with --non-matching

config.warn_missing_config = False
config.warn_missing_source = False # TODO
config.warn_missing_config = False
config.warn_missing_source = False
config.libs = [
{
"lib": "framework",
Expand Down Expand Up @@ -335,6 +338,17 @@ def nw4rLib(lib_name, objects, extra_cflags=[]):
Object(NonMatching, "f/f_base.cpp"),
Object(Matching, "f/f_list.cpp"),
Object(Matching, "f/f_manager.cpp"),
Object(Matching, "DynamicLink.cpp"),
# framework (f_name)
# d stuff (d_name)
],
},
{
"lib": "mlib",
"mw_version": "Wii/1.5",
"cflags": cflags_framework,
"host": False,
"objects": [
Object(Matching, "m/m_allocator.cpp"),
Object(Matching, "m/m_angle.cpp"),
Object(Matching, "m/m_color_fader.cpp"),
Expand All @@ -344,13 +358,20 @@ def nw4rLib(lib_name, objects, extra_cflags=[]):
Object(Matching, "m/m_heap.cpp"),
Object(NonMatching, "m/m_mtx.cpp"),
Object(Matching, "m/m_pad.cpp"),
],
},
{
"lib": "slib",
"mw_version": "Wii/1.5",
"cflags": cflags_framework,
"host": False,
"objects": [
Object(Matching, "s/s_Crc.cpp"),
Object(NonMatching, "s/s_Math.cpp"),
Object(Matching, "s/s_StateId.cpp"),
Object(Matching, "s/s_StateMethod.cpp"),
Object(Matching, "s/s_StateMethodUsr_FI.cpp"),
Object(Matching, "s/s_Phase.cpp"),
Object(Matching, "DynamicLink.cpp"),
# framework (f_name)
# d stuff (d_name)
],
},
# DolphinLib(
Expand Down
1 change: 1 addition & 0 deletions include/rvl/OS.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ extern "C" {
#include "rvl/OS/OSAudioSystem.h"
#include "rvl/OS/OSCache.h"
#include "rvl/OS/OSContext.h"
#include "rvl/OS/OSCrc.h"
#include "rvl/OS/OSError.h"
#include "rvl/OS/OSExec.h"
#include "rvl/OS/OSFastCast.h"
Expand Down
13 changes: 13 additions & 0 deletions include/rvl/OS/OSCrc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef RVL_SDK_OS_CRC_H
#define RVL_SDK_OS_CRC_H
#include <common.h>
#ifdef __cplusplus
extern "C" {
#endif

u32 OSCalcCRC32(const void *, u32);

#ifdef __cplusplus
}
#endif
#endif
2 changes: 1 addition & 1 deletion include/s/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
This library was ported from https://github.com/NSMBW-Community/NSMBW-Decomp/tree/master/include/dol/sLib
The state system in this library was ported from https://github.com/NSMBW-Community/NSMBW-Decomp/tree/master/include/dol/sLib
with differences/modifications outlined below:

## No inline destructors
Expand Down
12 changes: 12 additions & 0 deletions include/s/s_Crc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef S_CRC_H
#define S_CRC_H

#include <common.h>

namespace sCrc {

u32 calcCRC(const void *ptr, u32 size);

} // namespace sCrc

#endif
26 changes: 26 additions & 0 deletions include/s/s_Math.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#ifndef S_MATH_H
#define S_MATH_H

#include <common.h>

namespace sLib {

// Names from NSMBW
float addCalc(float *value, float target, float ratio, float maxStepSize, float minStepSize);
short addCalcAngle(short *value, short target, short ratio, short maxStepSize, short minStepSize);
BOOL chase(short *value, short target, short stepSize);
BOOL chase(int *value, int target, int stepSize);
BOOL chase(float *value, float target, float stepSize);
BOOL chaseAngle(short *value, short target, short stepSize);

// Inofficial names
float extrapolate(float start, float end, float scale);
BOOL isInRange(float val, float min, float max);
void addCalcScaledDiff(float *value, float target, float ratio, float maxStepSize);
void addCalcScaled(float *value, float stepSize, float maxStep);
int absDiff(short a1, short a2);
BOOL chaseUC(u8 *value, u8 target, u8 stepSize);

} // namespace sLib

#endif
10 changes: 10 additions & 0 deletions src/s/s_Crc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#include <s/s_Crc.h>
#include <rvl/OS.h>

namespace sCrc {

u32 calcCRC(const void *ptr, u32 size) {
return OSCalcCRC32(ptr, size);
}

} // namespace sCrc
Loading

0 comments on commit 7e5c3b5

Please sign in to comment.