Skip to content

Commit

Permalink
just. a lot really
Browse files Browse the repository at this point in the history
  • Loading branch information
ieee802dot11ac committed Jun 6, 2024
1 parent 14fb29f commit 105513d
Show file tree
Hide file tree
Showing 22 changed files with 226 additions and 23 deletions.
4 changes: 3 additions & 1 deletion config/SZBE69_B8/objects.json
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@
"system/rndobj/Utl.cpp": "NonMatching",
"system/rndobj/Wind.cpp": "NonMatching",

"system/rndwii/Mesh.cpp": "NonMatching",
"system/rndwii/Rnd.cpp": "NonMatching",

"system/synth/ADSR.cpp": "NonMatching",
Expand Down Expand Up @@ -518,7 +519,8 @@
"system/world/LightPresetManager.cpp": "NonMatching",
"system/world/Spotlight.cpp": "NonMatching",
"system/world/SpotlightDrawer.cpp": "NonMatching",
"system/world/SpotlightEnder.cpp": "Matching"
"system/world/SpotlightEnder.cpp": "Matching",
"system/world/World.cpp": "NonMatching"
}
},
"flex": {
Expand Down
4 changes: 4 additions & 0 deletions src/system/math/Rot.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
#include "math/Vec.h"
#include "math/Mtx.h"

#define PI 3.14159265358979323846
#define RAD2DEG 0.01745329238474369049f
#define DEG2RAD 57.2957763671875f

void Multiply(const Transform&, const Transform&, Transform&);
void MakeRotMatrix(const Vector3&, Hmx::Matrix3&, bool);
void MakeEulerScale(const Hmx::Matrix3&, Vector3&, Vector3&);
Expand Down
1 change: 1 addition & 0 deletions src/system/obj/Dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ class ObjectDir : public virtual Hmx::Object {
};

BinStream& operator>>(BinStream& bs, ObjectDir::Viewport& vp);
void PreloadSharedSubdirs(class Symbol);

extern bool gLoadingProxyFromDisk;
extern const char* kNotObjectMsg;
Expand Down
28 changes: 22 additions & 6 deletions src/system/rndobj/Cam.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
#include "rndobj/Cam.h"
#include "math/Rot.h"
#include "obj/ObjMacros.h"
#include "obj/ObjPtr_p.h"
#include "obj/Object.h"
#include "os/Debug.h"
#include "rndobj/Draw.h"
#include "rndobj/Rnd.h"
#include "rndobj/Trans.h"
#include "rndobj/Utl.h"
#include "utl/Symbols.h"
#include "utl/Symbols2.h"

RndCam* RndCam::sCurrent = 0;
int CAM_REV = 12;
Expand All @@ -18,6 +21,16 @@ void RndCam::WorldToScreen(const Vector3& w, Vector2& s) const {
s = mZRange;
}

void RndCam::Select() {
if (sCurrent && sCurrent->mTargetTex.mPtr && sCurrent != this) {
sCurrent->mTargetTex->FinishDrawTarget();
}
if (mCache->mFlags & 1) WorldXfm_Force();
sCurrent = this;
Rnd::Aspect a = TheRnd->mAspect;
if (mAspect != a) UpdateLocal();
}

void RndCam::SetTargetTex(RndTex* tex){
if(sCurrent == this && mTargetTex){
mTargetTex->FinishDrawTarget();
Expand Down Expand Up @@ -101,13 +114,14 @@ BEGIN_HANDLERS(RndCam)
END_HANDLERS

DataNode RndCam::OnSetFrustum(const DataArray* da){
float nearPlane, farPlane, yFov;
float nearPlane, farPlane, yFov, temp;
if(!da->FindData(near_plane, nearPlane, false))
nearPlane = mNearPlane;
if(!da->FindData(far_plane, farPlane, false))
farPlane = mFarPlane;
if(da->FindData(y_fov, yFov, false)) yFov *= 0.017453292f;
else yFov = mYFov;
if(da->FindData(y_fov, yFov, false)) temp = 0.017453292f * yFov;
else temp = mYFov;
yFov = temp;
SetFrustum(nearPlane, farPlane, yFov, 1.0f);
return DataNode(0);
}
Expand All @@ -132,8 +146,10 @@ DataNode RndCam::OnFarPlane(const DataArray*){
}

BEGIN_PROPSYNCS(RndCam)
//SYNC_SUPERCLASS(RndTransformable)
SYNC_PROP_MODIFY(near_plane, mNearPlane, )
SYNC_SUPERCLASS(RndTransformable)
SYNC_PROP_SET(near_plane, mNearPlane, SetFrustum(_val.Float(NULL), mFarPlane, mYFov, 1))
SYNC_PROP_SET(far_plane, mFarPlane, SetFrustum(mNearPlane, _val.Float(NULL), mYFov, 1))
SYNC_PROP_SET(y_fov, mYFov * DEG2RAD, SetFrustum(mNearPlane, mFarPlane, _val.Float(NULL) * RAD2DEG, 1))
SYNC_PROP(z_range, mZRange)
SYNC_PROP_MODIFY(screen_rect, mScreenRect, UpdateLocal())
SYNC_PROP_MODIFY_ALT(screen_rect, mScreenRect, UpdateLocal())
END_PROPSYNCS
13 changes: 7 additions & 6 deletions src/system/rndobj/Cam.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "math/Vec.h"
#include "math/Geo.h"
#include "obj/ObjPtr_p.h"
#include "rndobj/Rnd.h"
#include "rndobj/Tex.h"

class RndCam : public RndTransformable {
Expand Down Expand Up @@ -39,11 +40,11 @@ class RndCam : public RndTransformable {
REGISTER_OBJ_FACTORY(RndCam)
}

Transform mInvWorldXfm;
Transform mLocalProjectXfm;
Transform mInvLocalProjectXfm;
Transform mWorldProjectXfm;
Transform mInvWorldProjectXfm;
Transform mInvWorldXfm; // 0x90
Transform mLocalProjectXfm; // 0xC0
Transform mInvLocalProjectXfm; // 0xF0
Transform mWorldProjectXfm; // 0x120
Transform mInvWorldProjectXfm; // 0x150
Frustum mLocalFrustum; // 0x180
Frustum mWorldFrustum; // 0x1E0
float mNearPlane; // 0x240
Expand All @@ -53,7 +54,7 @@ class RndCam : public RndTransformable {
Vector2 mZRange; // 0x250
Hmx::Rect mScreenRect; // 0x258
ObjPtr<RndTex, class ObjectDir> mTargetTex; // 0x268
int asdf; // 0x274
Rnd::Aspect mAspect; // 0x274
};

#endif
45 changes: 44 additions & 1 deletion src/system/rndobj/Console.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "rndobj/Console.h"
#include "obj/ObjMacros.h"
#include "os/Debug.h"
#include "obj/Data.h"
#include "obj/DataFunc.h"
#include "os/File.h"
#include "os/System.h"
#include "rndobj/Overlay.h"
#include <string.h>
Expand Down Expand Up @@ -110,6 +112,28 @@ void RndConsole::InsertBreak(DataArray* arr, int i){
mBreakpoints.back().index = i;
}

void RndConsole::List() {
if (mDebugging) {
mOutput->Clear();
if (File* f = NewFile(mDebugging->File(), 2)) {
int i = 1;
int x = mOutput->mLines.size();
int y = mDebugging->Line();
int z = y - x / 2;
do {
char buf[4];
f->Read(buf, 1);
if (i > z) *mOutput << buf[0];
i++;
char brk = '>';
if (i == mDebugging->mLine) brk = ':';
*mOutput << MakeString("%3d%c", i, brk);
} while (i > y);

delete f;
}
} else MILO_FAIL("Can't list unless debugging");
}

// // declared/defined in DataArray.cpp
extern DataArray* gCallStack[100];
Expand All @@ -136,7 +160,7 @@ void RndConsole::Step(int i) {
mDebugging = 0;
gPreExecuteFunc = *DataBreak;

} else MILO_FAIL("can't step unless debugging");
} else MILO_FAIL("Can't step unless debugging");
}

void RndConsole::Continue() {
Expand Down Expand Up @@ -225,3 +249,22 @@ RndConsole::RndConsole() : mShowing(0), mBuffer(),
RndConsole::~RndConsole(){
TheDebug.SetReflect(0);
}

BEGIN_HANDLERS(RndConsole)
HANDLE_MESSAGE(KeyboardKeyMsg)
HANDLE_CHECK(592)
END_HANDLERS

int RndConsole::OnMsg(const KeyboardKeyMsg& msg) {
if (!mShowing) return 0;
if (msg.mData->Int(2) == 302) SetShowing(false);
else {
if (msg.mData->Int(2) == 9) {
if (mTabLen == 0) mTabLen = strlen(mInput->CurrentLine()->c_str());
}
}

mTabLen = msg.mData->Int(2) == 10 ? mCursor : -1;
if (msg.mData->Int(2) != 9) mTabLen = 0;
return 0;
}
4 changes: 3 additions & 1 deletion src/system/rndobj/Console.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
#define RNDOBJ_CONSOLE_H

#include "obj/Object.h"
#include <list>
#include "os/Keyboard.h"
#include "utl/Str.h"
#include <list>

class RndOverlay;

Expand Down Expand Up @@ -32,6 +33,7 @@ class RndConsole : public Hmx::Object { // 0x58 - 0x1c = 0x3c
void Continue();
void Help(Symbol);
void SetShowing(bool);
int OnMsg(const KeyboardKeyMsg&);

void* operator new(size_t s){
return _PoolAlloc(s, sizeof(RndConsole), FastPool);
Expand Down
2 changes: 1 addition & 1 deletion src/system/rndobj/Mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -395,4 +395,4 @@ BEGIN_PROPSYNCS(RndMesh)
SYNC_PROP(geom_owner, mOwner)


END_PROPSYNCS
END_PROPSYNCS
1 change: 1 addition & 0 deletions src/system/rndobj/Overlay.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class RndOverlay : public TextStream {
void SetTimeout(float);
void SetLines(int);
void Clear();
String* CurrentLine();
static void Init();
static void Terminate();
static void TogglePosition();
Expand Down
6 changes: 3 additions & 3 deletions src/system/rndobj/Trans.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class RndTransformable : public virtual RndHighlightable {
Transform mLocalXfm; // 0x1c
Transform mWorldXfm; // 0x4c
DirtyCache* mCache; // 0x7c
u16 mConstraint; Constraint TransConstraint() { return (Constraint) mConstraint; }
bool mPreserveScale;
ObjPtr<RndTransformable, class ObjectDir> mTarget;
u16 mConstraint; Constraint TransConstraint() { return (Constraint) mConstraint; } // 0x80
bool mPreserveScale; // 0x83
ObjPtr<RndTransformable, class ObjectDir> mTarget; // 0x84

static ushort gRev;
static ushort gAltRev;
Expand Down
49 changes: 49 additions & 0 deletions src/system/rndwii/Mesh.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include "Mesh.h"
#include "obj/Data.h"
#include "obj/Object.h"
#include "os/Debug.h"
#include "revolution/GX.h"
#include "revolution/os/OSCache.h"
#include "rndwii/Rnd.h"

bool gToggleAO = true;

static DataNode OnToggleAO(DataArray*) {
gToggleAO = !gToggleAO;
TheDebug << MakeString("Ambient Occlusion is now %s!\n", gToggleAO ? "ON" : "OFF");
return DataNode();
}

DisplayList::DisplayList() : mData(NULL), mSize(0), unk_0x8(0) {}

DisplayList::~DisplayList() { Clear(); }

void DisplayList::Init() {

}

void DisplayList::Clear() {
WiiRnd::SyncFree(mData);
mData = NULL;
mSize = 0;
unk_0x8 = 0;
}

void DisplayList::Copy(const DisplayList& d) {
Clear();
}

void DisplayList::Draw(u32 u, _GXVtxFmt f) const {
MILO_ASSERT(mData, 237);
MILO_ASSERT(mSize > 0, 238);
DCStoreRange(mData, mSize);
GXCallDisplayList(mData, mSize);
}

WiiMesh::WiiMesh() {}

BEGIN_COPYS(WiiMesh)
COPY_SUPERCLASS(RndMesh)
CREATE_COPY(WiiMesh)

END_COPYS
35 changes: 35 additions & 0 deletions src/system/rndwii/Mesh.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#ifndef RNDWII_MESH_H
#define RNDWII_MESH_H

#include "obj/ObjMacros.h"
#include "obj/Object.h"
#include "revolution/gx/GXTypes.h"
#include "rndobj/Mesh.h"

class DisplayList { // 0xC
public:
DisplayList();
~DisplayList();
void Init();
void Clear();
void Copy(const DisplayList&);
void Draw(u32, _GXVtxFmt) const;

void* mData;
int mSize;
int unk_0x8;
};

class WiiMesh : public RndMesh { // 0x198
WiiMesh();

virtual void Copy(const Hmx::Object*, CopyType);
OBJ_CLASSNAME(WiiMesh)
OBJ_SET_TYPE(WiiMesh)

NEW_OBJ(WiiMesh)

DisplayList mDisplays; // 0x158
};

#endif // RNDWII_MESH_H
2 changes: 2 additions & 0 deletions src/system/rndwii/Rnd.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ class WiiRnd : public Rnd { public:
std::vector<Rnd::PointTest> unk_0x2B4;
bool unk_0x2BC;
int mFramesBuffered; // 0x2C0

static bool mUseLockedCache, mShowParticle, mShowAssetName;
static void SyncFree(void*);
};

void RndGXBegin(_GXPrimitive prim, _GXVtxFmt fmt, unsigned short verts);
Expand Down
2 changes: 2 additions & 0 deletions src/system/world/CameraShot.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ class CamShot : public RndAnimatable {
bool mLooping : 1; // 0x120 >> 7
bool mUseDepthOfField : 1; // 0x120 >> 6 & 1
bool mPS3PerPixel : 1; // 0x120 >> 5 & 1

static void Init();
};

#endif
6 changes: 5 additions & 1 deletion src/system/world/ColorPalette.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#define WORLD_COLORPALETTE_H
#include "obj/Object.h"
#include "math/Color.h"
#include "utl/MemMgr.h"
#include <vector>

class ColorSet {
Expand All @@ -11,6 +12,7 @@ class ColorSet {
};

class ColorPalette : public Hmx::Object {
public:
ColorPalette();
virtual ~ColorPalette(){}
OBJ_CLASSNAME(ColorPalette);
Expand All @@ -21,7 +23,9 @@ class ColorPalette : public Hmx::Object {
virtual void Copy(const Hmx::Object*, Hmx::Object::CopyType);
virtual void Load(BinStream&);

DECLARE_REVS;
NEW_OVERLOAD
DECLARE_REVS
NEW_OBJ(ColorPalette)

std::vector<Hmx::Color> mColors;
};
Expand Down
1 change: 1 addition & 0 deletions src/system/world/Dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class WorldDir : public PanelDir {
virtual bool DrawShowingBudget(float);

NEW_OBJ(WorldDir)
static void Init();

ObjList<int> mPresetOverrides; // 0x1d8 - WorldDir::PresetOverride
ObjList<int> mBitmapOverrides; // 0x1e4 - WorldDir::BitmapOverride
Expand Down
Loading

0 comments on commit 105513d

Please sign in to comment.