Skip to content

Commit

Permalink
Matched a few more TUs (#291)
Browse files Browse the repository at this point in the history
* colorpalette just has stlport regswaps now

* hdcache work

* a buncha fixes

* key math attempt

* i hate inlines

* i hate inlining

* tiny tweaks

* midiinst work

* update samplezone fields

* midiinst work

* uiproxy nearly done

* add binkclip cpp, UIProxy has link issues

* binkclip work

* binkclip almost done

* match binkclip

* add binkreader TU

* sampledata work

* metamusic added

* wavefile nearly matched

* match wavefile

* wavefile and sampledata tweaks
  • Loading branch information
rjkiv authored Jul 18, 2024
1 parent 3c86233 commit 8c0b5e2
Show file tree
Hide file tree
Showing 40 changed files with 1,180 additions and 129 deletions.
11 changes: 9 additions & 2 deletions config/SZBE69_B8/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@
"system/math/FileChecksum.cpp": "Matching",
"system/math/Geo.cpp": "NonMatching",
"system/math/Interp.cpp": "Matching",
"system/math/Key.cpp": { "status": "NonMatching", "extra_cflags": [ "-fp_contract off" ] },
"system/math/Primes.cpp": "Matching",
"system/math/Rand.cpp": "Matching",
"system/math/Rand2.cpp": "Matching",
Expand Down Expand Up @@ -406,6 +407,8 @@
"system/rndwii/Rnd.cpp": "NonMatching",

"system/synth/ADSR.cpp": "NonMatching",
"system/synth/BinkClip.cpp": "Matching",
"system/synth/BinkReader.cpp": "NonMatching",
"system/synth/ByteGrinder.cpp": "NonMatching",
"system/synth/Emitter.cpp": "NonMatching",
"system/synth/Faders.cpp": "Equivalent",
Expand All @@ -421,6 +424,7 @@
"system/synth/FxSendPitchShift.cpp": "Matching",
"system/synth/FxSendSynapse.cpp": "Matching",
"system/synth/FxSendWah.cpp": "Matching",
"system/synth/MetaMusic.cpp": "NonMatching",
"system/synth/Mic.cpp": "Matching",
"system/synth/MicNull.cpp": "NonMatching",
"system/synth/MidiInstrument.cpp": "NonMatching",
Expand Down Expand Up @@ -480,7 +484,10 @@
"system/ui/UIListWidget.cpp": "NonMatching",
"system/ui/UIPanel.cpp": "Matching",
"system/ui/UIPicture.cpp": "Matching",
"system/ui/UIProxy.cpp": "NonMatching",
"system/ui/UIProxy.cpp": {
"status": "LinkIssues",
"comment": "SetType ordering in bss"
},
"system/ui/UIResource.cpp": "Matching",
"system/ui/UIScreen.cpp": {
"status": "LinkIssues",
Expand Down Expand Up @@ -553,7 +560,7 @@
"system/utl/UTF8.cpp": "NonMatching",
"system/utl/VarTimer.cpp": "NonMatching",
"system/utl/Wav.cpp": "NonMatching",
"system/utl/WaveFile.cpp": "NonMatching",
"system/utl/WaveFile.cpp": "Matching",

"system/world/CameraManager.cpp": "NonMatching",
"system/world/CameraShot.cpp": "NonMatching",
Expand Down
1 change: 0 additions & 1 deletion src/system/char/CharInterest.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef CHAR_CHARINTEREST_H
#define CHAR_CHARINTEREST_H
#include "obj/ObjMacros.h"
#include "rndobj/Trans.h"
#include "obj/ObjPtr_p.h"
#include "char/CharEyeDartRuleset.h"
Expand Down
21 changes: 6 additions & 15 deletions src/system/math/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,21 @@ namespace Hmx {
Color(int i) : alpha(1.0f) { Unpack(i); }

// copy ctor uses asm magic
Color(const register Color& color){
register Color* theCol = this;
register float temp1;
register float temp2;
ASM_BLOCK(
psq_lx temp2,0,color,0,0
psq_l temp1,8(color),0,0
psq_stx temp2,0,theCol,0,0
psq_st temp1,8(theCol),0,0
)
Color(const Color& color){
typedef struct{
__vec2x32float__ a, b;
} Color_psq;

*(Color_psq *)this = *(Color_psq *)&color;
}

void Set(float f1, float f2, float f3, float f4){
red = f1; green = f2; blue = f3; alpha = f4;
}

// all weak
// Color() {};
// Color(int);
// void operator=(const Color &);
// void Unpack(int);
// bool operator==(const Color &) const;
// bool operator!=(const Color &) const;
// void Set(float, float, float, float);

void Set(float f){ red = green = blue = alpha = f; }

Expand Down
49 changes: 49 additions & 0 deletions src/system/math/Key.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "math/Key.h"
#include "math/Vec.h"

// fn_802E33CC - SplineTangent(const Keys<Vector3, Vector3>&, int, Vector3&)
// https://decomp.me/scratch/uaX0T - retail
// https://decomp.me/scratch/g4W1K - debug (i hate inlining)
void SplineTangent(const Keys<Vector3, Vector3>& keys, int i, Vector3& vout){
int size = keys.size();
MILO_ASSERT(size > 1, 0x17);
if(size == 2){
Subtract(keys[1].value, keys[0].value, vout);
}
else if(i <= 0){
Subtract(keys[1].value, keys[0].value, vout);
Scale(vout, 1.5f, vout);
Vector3 vtmp;
Subtract(keys[2].value, keys[0].value, vtmp);
Scale(vtmp, 0.25f, vtmp);
Subtract(vout, vtmp, vout);
}
else if(i >= size - 1){
Subtract(keys[size - 1].value, keys[size - 2].value, vout);
Scale(vout, 1.5f, vout);
Vector3 vtmp;
Subtract(keys[size - 1].value, keys[size - 3].value, vtmp);
Scale(vtmp, 0.25f, vtmp);
Subtract(vout, vtmp, vout);
}
else {
Subtract(keys[i + 1].value, keys[i - 1].value, vout);
Scale(vout, 0.5f, vout);
}
}

// fn_802E35A8 - InterpTangent(const Vector3&, const Vector3&, const Vector3&, const Vector3&, float, Vector3&)
// i absolutely hate inlines
void InterpTangent(const Vector3& v1, const Vector3& v2, const Vector3& v3, const Vector3& v4, float f, Vector3& vout){
float scale = f * f;
Scale(v1, scale * 6.0f - f * 6.0f, vout);
Vector3 vtmp;
Scale(v2, -(f * 4.0f - scale * 3.0f) + 1.0f, vtmp);
Add(vout, vtmp, vout);
Scale(v3, scale * -6.0f + f * 6.0f, vtmp);
Add(vout, vtmp, vout);
Scale(v4, -(f * 2.0f - f * 3.0f), vtmp);
Add(vout, vtmp, vout);
}

// fn_802E36D4 - InterpVector(const Keys<Vector3, Vector3>&, const Key<Vector3>*, const Key<Vector3>*, float, bool, Vector3&, Vector3*)
54 changes: 54 additions & 0 deletions src/system/math/Mtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ namespace Hmx {
}
Matrix3& operator=(const Matrix3 &);
Vector3& operator[](int);

bool operator==(const Matrix3& mtx) const {
return x == mtx.x && y == mtx.y && z == mtx.z;
}

};

class Quat {
Expand Down Expand Up @@ -145,6 +150,10 @@ class Transform {
m.z.Zero();
v.Zero();
}

bool operator==(const Transform& tf) const {
return m == tf.m && v == tf.v;
}
};

inline BinStream& operator>>(BinStream& bs, Transform& tf){
Expand Down Expand Up @@ -212,5 +221,50 @@ void ScaleAddEq(Hmx::Quat&, const Hmx::Quat&, float);
void Normalize(const Hmx::Quat&, Hmx::Quat&);
void Multiply(const Hmx::Quat&, const Hmx::Quat&, Hmx::Quat&);
void FastInterp(const Hmx::Quat&, const Hmx::Quat&, float, Hmx::Quat&);
void Invert(const Hmx::Matrix3&, Hmx::Matrix3&);
void Multiply(const Hmx::Matrix3&, const Vector3&, Vector3&);

inline void Multiply(const Vector3& vin, const Hmx::Matrix3& mtx, Vector3& vout) {
register __vec2x32float__ i1, i2, m1, m2, o1, o2;

register const Vector3 *_vin = &vin;
register Vector3 *_vout = &vout;
register const Hmx::Matrix3 *_m = &mtx;

typedef Hmx::Matrix3 Matrix3;

ASM_BLOCK(
psq_l i1, Vector3.x(_vin), 0, 0
psq_l i2, Vector3.y(_vin), 0, 0

psq_l m1, Matrix3.z.x(_m), 0, 0
psq_l m2, Matrix3.z.z(_m), 1, 0

ps_muls1 o1, m1, i2
ps_muls1 o2, m2, i2

psq_l m1, Matrix3.y.x(_m), 0, 0
psq_l m2, Matrix3.y.z(_m), 1, 0

ps_madds0 o1, m1, i2, o1
ps_madds0 o2, m2, i2, o2

psq_l m1, Matrix3.x.x(_m), 0, 0
psq_l m2, Matrix3.x.z(_m), 1, 0

ps_madds0 o1, m1, i1, o1
ps_madds0 o2, m2, i1, o2

psq_st o1, Vector3.x(_vout), 0, 0
psq_st o2, Vector3.z(_vout), 1, 0
)
}

inline void Invert(const Transform& tfin, Transform& tfout){
Vector3 vtmp;
Negate(tfin.v, vtmp);
Invert(tfin.m, tfout.m);
Multiply(vtmp, tfout.m, tfout.v);
}

#endif
3 changes: 0 additions & 3 deletions src/system/math/Rot.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
#define RAD2DEG 57.2957763671875f
#define DEG2RAD 0.01745329238474369049f

void Multiply(const Hmx::Matrix3&, const Vector3&, Vector3&);
void Multiply(const Vector3&, const Hmx::Matrix3&, Vector3&);
void Multiply(const Vector3&, const Transform&, Vector3&);
void Multiply(const Transform&, const Vector3&, Vector3&);
void Multiply(const Transform&, const Transform&, Transform&);
Expand All @@ -21,7 +19,6 @@ void MakeEuler(const Hmx::Matrix3&, Vector3&);
void MakeEulerScale(const Hmx::Matrix3&, Vector3&, Vector3&);
void Normalize(const Hmx::Matrix3&, Hmx::Matrix3&);
void MakeRotMatrix(const Hmx::Quat&, Hmx::Matrix3&);
void Invert(const Transform&, Transform&);
void Interp(const Hmx::Quat&, const Hmx::Quat&, float, Hmx::Quat&);
void RotateAboutX(const Hmx::Matrix3&, float, Hmx::Matrix3&);
void MakeRotQuat(const Vector3&, const Vector3&, Hmx::Quat&);
Expand Down
22 changes: 9 additions & 13 deletions src/system/math/Vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,9 @@ class Vector3 {

const float& operator[](int i) const { return *(&x + i); }
float& operator[](int i){ return *(&x + i); }
// bool operator==(const Vector3 &) const;
bool operator==(const Vector3& v) const {
return x == v.x && y == v.y && z == v.z;
}
// bool operator!=(const Vector3 &) const;
};

Expand Down Expand Up @@ -219,13 +221,7 @@ inline float Distance(const Vector3& v1, const Vector3& v2){
}

inline void Subtract(const Vector3 &v1, const Vector3 &v2, Vector3 &dst) {
#ifdef VERSION_SZBE69_B8
dst.z = v1.z - v2.z;
dst.y = v1.y - v2.y;
dst.x = v1.x - v2.x;
#else
dst.Set(v1.x - v2.x, v1.y - v2.y, v1.z - v2.z);
#endif
}

float Length(const Vector3&);
Expand All @@ -251,6 +247,8 @@ inline float LengthSquared(const Vector3& v){
return x * x + y * y + z * z;
}

// https://decomp.me/scratch/TWZ2T
// why oh why does debug behave this way
inline float DistanceSquared(const Vector3& v1, const Vector3& v2){
#ifdef VERSION_SZBE69_B8
float zdiff = v1.z - v2.z;
Expand All @@ -267,13 +265,7 @@ inline float DistanceSquared(const Vector3& v1, const Vector3& v2){
float RecipSqrtAccurate(float);

inline void Add(const Vector3& v1, const Vector3& v2, Vector3& dst){
#ifdef VERSION_SZBE69_B8
dst.z = v1.z + v2.z;
dst.y = v1.y + v2.y;
dst.x = v1.x + v2.x;
#else
dst.Set(v1.x + v2.x, v1.y + v2.y, v1.z + v2.z);
#endif
}

inline void Interp(const Vector2& v1, const Vector2& v2, float f, Vector2& res){
Expand Down Expand Up @@ -314,4 +306,8 @@ inline float operator*(const Vector3& v1, const Vector3& v2){
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
}

inline void Negate(const Vector3& v, Vector3& vres){
vres.Set(-v.x, -v.y, -v.z);
}

#endif
1 change: 0 additions & 1 deletion src/system/meta/HeldButtonPanel.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#ifndef META_HELDBUTTONPANEL_H
#define META_HELDBUTTONPANEL_H
#include "obj/ObjMacros.h"
#include "ui/UIPanel.h"
#include "meta/ButtonHolder.h"

Expand Down
8 changes: 4 additions & 4 deletions src/system/meta/SongPreview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,10 +285,10 @@ void SongPreview::PrepareSong(Symbol s){
mStream->SetPan(i, pans[i]);
}

const TrackChannels& tracks = data->FindTrackChannel(kAudioTypeMulti);
if(&tracks != 0){
for(int i = 0; i < tracks.mChannels.size(); i++){
mStream->SetVolume(tracks.mChannels[i], -96.0f);
const TrackChannels* tracks = data->FindTrackChannel(kAudioTypeMulti);
if(tracks != 0){
for(int i = 0; i < tracks->mChannels.size(); i++){
mStream->SetVolume(tracks->mChannels[i], -96.0f);
}
}
DetachFaders();
Expand Down
3 changes: 2 additions & 1 deletion src/system/obj/Dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ template <class T> class ObjDirPtr : public ObjRef {

// IsLoaded__21ObjDirPtr<9ObjectDir>CFv
bool IsLoaded() const {
bool b;
bool ret = true;
if(!mDir){
bool b = false;
b = false;
if(mLoader && mLoader->IsLoaded()) b = true;
if(!b) ret = false;
}
Expand Down
4 changes: 2 additions & 2 deletions src/system/obj/PropSync_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
#include "utl/FilePath.h"
#include "utl/Symbol.h"
#include "os/Debug.h"
#include "obj/ObjVector.h"
#include "obj/ObjList.h"
#include "math/Geo.h"
#include <list>

Expand Down Expand Up @@ -220,6 +218,7 @@ template <class T, typename T2> bool PropSync(std::vector<T, T2>& vec, DataNode&
}
}

#include "obj/ObjVector.h"
template <class T, typename T2> bool PropSync(ObjVector<T, T2>& objVec, DataNode& node, DataArray* prop, int i, PropOp op) {
if(op == kPropUnknown0x40) return false;
else if(i == prop->Size()){
Expand Down Expand Up @@ -247,6 +246,7 @@ template <class T, typename T2> bool PropSync(ObjVector<T, T2>& objVec, DataNode
}
}

#include "obj/ObjList.h"
template <class T> bool PropSync(ObjList<T>& objList, DataNode& node, DataArray* prop, int i, PropOp op){
if(op == kPropUnknown0x40) return false;
else if(i == prop->Size()){
Expand Down
5 changes: 2 additions & 3 deletions src/system/os/CritSec.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,8 @@ class CriticalSection {
void Exit();
void Abandon();

void operator delete(void* v){
_PoolFree(sizeof(CriticalSection), FastPool, v);
}
NEW_POOL_OVERLOAD(CriticalSection)
DELETE_POOL_OVERLOAD(CriticalSection)
};

class CritSecTracker {
Expand Down
Loading

0 comments on commit 8c0b5e2

Please sign in to comment.