From 0dabea30d98d175e5d7e0655c10757db99ac8295 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 15 Jan 2012 21:27:19 +0100 Subject: Cleanups in the include files and other stuff --- include/g3dhax.h | 26 +++++++---- include/game.h | 130 +++++++++++++++++++++++++++++++++++++++++++++++++-- include/rvl/GXVert.h | 38 ++++++++++----- 3 files changed, 169 insertions(+), 25 deletions(-) (limited to 'include') diff --git a/include/g3dhax.h b/include/g3dhax.h index b016e55..d358436 100644 --- a/include/g3dhax.h +++ b/include/g3dhax.h @@ -161,6 +161,8 @@ class mAllocator_c : public EGG::Allocator { mAllocator_c(); ~mAllocator_c(); + bool setup(/*EGG::Heap*/void *heap, s32 align); + void *alloc(u32 size); void free(void *block); }; @@ -182,19 +184,15 @@ namespace m3d { void DisableIndirectTexturing(); void InitTexObjWithResTex(GXTexObj *obj, /* ResTex */ void *resTex, GXTexWrapMode wrapS, GXTexWrapMode wrapT, GXTexFilter minFilt, GXTexFilter magFilt); - // I need to do scnLeaf_c some time... - class proc_c { + class scnLeaf_c { public: - proc_c(); - virtual ~proc_c(); + scnLeaf_c(); + virtual ~scnLeaf_c(); - void setup(void *allocator = 0, u32 *size = 0); virtual int returnUnknown(); virtual void free(); virtual bool scheduleForDrawing(); - virtual void drawOpa(); - virtual void drawXlu(); void setScnObjOption(ulong, ulong); bool getScnObjOption(ulong, ulong*); @@ -214,8 +212,20 @@ namespace m3d { void *scnObj; }; - class banm_c; + class proc_c : public scnLeaf_c { + public: + bool setup(void *allocator = 0, u32 *size = 0); + + int returnUnknown() { return 2; } + virtual void drawOpa() = 0; + virtual void drawXlu() = 0; + }; + + + + // TODO: bmdl_c/smdl_c + class banm_c; class mdl_c { public: mdl_c(); diff --git a/include/game.h b/include/game.h index 8e7d86a..0871eb1 100755 --- a/include/game.h +++ b/include/game.h @@ -11,8 +11,17 @@ #define offsetof(type, member) ((u32) &(((type *) 0)->member)) +template +inline T min(T one, T two) { return (one < two) ? one : two; } +template +inline T max(T one, T two) { return (one > two) ? one : two; } +template +inline T clamp(T value, T one, T two) { return (value < one) ? one : ((value > two) ? two : value); } + + extern "C" { int strlen(const char *str); +char *strcpy(char *dest, const char *src); float atan(float x); float atan2(float y, float x); @@ -761,8 +770,15 @@ namespace G3DState { } +VEC2 GetSomeSizeRelatedBULLSHIT(); +Vec CalculateSomethingAboutRatio(float, float, float, float); +float CalculateSomethingElseAboutRatio(); + nw4r::g3d::CameraData *GetCameraByID(int id); +namespace EGG { class Screen; }; +void DoSomethingCameraRelatedWithEGGScreen(int id, EGG::Screen *screen); + int GetCurrentCameraID(); // 80164C80 void SetCurrentCameraID(int id); // 80164C90 @@ -777,6 +793,7 @@ void DrawOpa(); // 80164F70 void DrawXlu(); // 80164F80 bool ChangeAlphaUpdate(bool enable); // 802D3270 +bool ChangeColorUpdate(bool enable); // 802D3210 void DoSpecialDrawing1(); // 8006CAE0 void DoSpecialDrawing2(); // 8006CB40 @@ -784,6 +801,7 @@ void DoSpecialDrawing2(); // 8006CB40 void SetupLYTDrawing(); // 80163360 void ClearLayoutDrawList(); // 801632B0 +void RenderAllLayouts(); // 800067A0 void DrawAllLayoutsBeforeX(int x); // 80163440 void DrawAllLayoutsAfterX(int x); // 801634D0 void DrawAllLayoutsAfterXandBeforeY(int x, int y); // 80163560 @@ -837,7 +855,7 @@ namespace m2d { namespace EGG { class Frustum { public: - GXProjectionType projType; + int projType; // 0 = ortho, 1 = perspective.. who needs GXEnum.h anyway int isCentered; float width; float height; @@ -847,8 +865,8 @@ namespace EGG { float far; float center_x_maybe; float center_y_maybe; - float x_direction; - float unk2; + float horizontalMultiplier; + float verticalMultiplier; float unk3; short some_flag_bit; @@ -876,8 +894,8 @@ namespace EGG { void copyAllFields(Frustum &f); // 802C6EE0 - void saveSomething(float f1, float f2, float f3, float f4); // 802C70C0 - void loadSomething(float *f1, float *f2, float *f3, float *f4); // 802C70E0 + static void saveSomething(float f1, float f2, float f3, float f4); // 802C70C0 + static void restoreSomething(float *f1, float *f2, float *f3, float *f4); // 802C70E0 void loadPerspective(); // 802C7110 void loadOrtho(); // 802C7140 @@ -891,6 +909,97 @@ namespace EGG { void getOrthoVars(float *top, float *bottom, float *left, float *right); // 802C7480 }; + + + class Screen : public Frustum { + public: + struct Info { + float viewportX, viewportY, viewportWidth, viewportHeight; + float viewportNearZ, viewportFarZ; + + int scissorX, scissorY, scissorWidth, scissorHeight; + int scissorOffsetX, scissorOffsetY; + }; + + Screen(); // 802D0FB0; creates perspective screen with basic settings + Screen(Screen *pParent, bool isCentered, float m40, float m44, float width, float height); // 802D1080 + Screen(Screen &s); // 802D1140 + + ~Screen(); // not called by the retail game.. dunno how to make CodeWarrior do this, who gives a fuck + + void loadDirectly(); + void loadIntoCamera(nw4r::g3d::Camera cam); + + void setSomeVars(bool isCentered, float m40, float m44, float width, float height); // 802D1500 + + Info *getStructContainingInfo(); // 802D1AB0 + + void doSomethingWithAPassedMatrix(Mtx m, float f1, float f2, float f3, float f4); // 802D1B40 + + //protected: + void copyAllFields(Screen &s); // 802D1430 + void setParent(Screen *pParent = 0); // 802D1540 + + void useScreenWidth640(); // 802D15A0 + void calculateCrap(); // 802D15D0 + + bool checkIfFlag1IsSet(); // 802D1B10 + + + Screen *parent; // I think it's the parent screen, anyway ... + float _40, _44, _48, _4C, _50, _54; + Info info; + }; + + + class LookAtCamera /* : public BaseCamera */ { + public: + virtual Mtx *getMatrix(); + virtual Mtx *getMatrixAgain(); + virtual void callCalculateMatrix(); + virtual void calculateMatrix(); + virtual void loadMatricesIntoGX(); + virtual void _vf1C(); // null + virtual Vec getCamPos(); + virtual void doStuffInvolvingVfsAndOtherObject(void *unkType); + virtual void _vf28(); // null + virtual Mtx *getPreviousMatrix(); + + void assignToNW4RCamera(nw4r::g3d::Camera &cam); // 802BEB70 + Vec getStuffFromMatrix(); // 802BEBC0 + Vec getMoreStuffFromMatrix(); // 802BEC20 + Vec getEvenMoreStuffFromMatrix(); // 802BEC80 + + private: + Mtx matrix; + Mtx previousMatrix; + + public: + Vec camPos, target, camUp; + }; + + class ProjectOrtho /* : public something? */ { + public: + virtual GXProjectionType getProjectionType(); + virtual void setGXProjection(); + virtual void _vf10(); // null + virtual VEC2 _vf14(VEC2 *something); + virtual Vec _vf18(float something, /*BaseCamera?*/ LookAtCamera *camera); + virtual Vec _vf1C(float something, /*BaseCamera?*/ LookAtCamera *camera); + virtual Vec _vf20(VEC2 *something); + virtual void _vf24(); + virtual void setOrthoOntoCamera(nw4r::g3d::Camera &cam); + virtual void _vf2C(); // null + virtual void setGXProjectionUnscaled(); // does not take aspect ratio into account + + ProjectOrtho(); // 802BF6C0 + void setVolume(float top, float bottom, float left, float right); // 802BF710 + void setDefaults(); // I think? 802BF830 + + Mtx44 matrix; // unused? dunno + void *_44; // dunno type + float near, far, top, bottom, left, right; + }; } @@ -2337,5 +2446,16 @@ inline u8 *getResource(const char *arcName, const char *fileName) { inline void scaleDown(Vec* scale, float amt) { scale->x -= amt; scale->y -= amt; scale->z -= amt; } inline void scaleUp(Vec* scale, float amt) { scale->x -= amt; scale->y -= amt; scale->z -= amt; } + + + + +struct SSM { short width, height; float xScale, yScale; }; +extern SSM ScreenSizesAndMultipliers[3]; +extern int currentScreenSizeID; + +extern float GlobalScreenWidth, GlobalScreenHeight; + + #endif diff --git a/include/rvl/GXVert.h b/include/rvl/GXVert.h index 8564563..41587c5 100755 --- a/include/rvl/GXVert.h +++ b/include/rvl/GXVert.h @@ -24,10 +24,24 @@ extern "C" { #else // MINNOW #define GXFIFO_ADDR 0x1C008000 #endif// MINNOW +typedef union uPPCWGPipe +{ + u8 u8; + u16 u16; + u32 u32; + u64 u64; + s8 s8; + s16 s16; + s32 s32; + s64 s64; + f32 f32; + f64 f64; +} PPCWGPipe; + // SN-Phil: removed 'extern', added AT_ADDRESS -//volatile PPCWGPipe GXWGFifo AT_ADDRESS(GXFIFO_ADDR) ; -extern volatile PPCWGPipe GXWGFifo; +volatile PPCWGPipe GXWGFifo : (GXFIFO_ADDR) ; +//extern volatile PPCWGPipe GXWGFifo; #endif // !EMU /*---------------------------------------------------------------------------*/ @@ -76,7 +90,7 @@ extern volatile PPCWGPipe GXWGFifo; #define __GXCDEF1(func,ts,td) \ static inline void func(const ts x) \ { \ - GXWGFifo._##td = (td) x; \ + GXWGFifo.td = (td) x; \ return; \ } @@ -84,8 +98,8 @@ extern volatile PPCWGPipe GXWGFifo; #define __GXCDEF2(func,ts,td) \ static inline void func(const ts x, const ts y) \ { \ - GXWGFifo._##td = (td) x; \ - GXWGFifo._##td = (td) y; \ + GXWGFifo.td = (td) x; \ + GXWGFifo.td = (td) y; \ return; \ } @@ -93,9 +107,9 @@ extern volatile PPCWGPipe GXWGFifo; #define __GXCDEF3(func,ts,td) \ static inline void func(const ts x, const ts y, const ts z) \ { \ - GXWGFifo._##td = (td) x; \ - GXWGFifo._##td = (td) y; \ - GXWGFifo._##td = (td) z; \ + GXWGFifo.td = (td) x; \ + GXWGFifo.td = (td) y; \ + GXWGFifo.td = (td) z; \ return; \ } @@ -103,10 +117,10 @@ extern volatile PPCWGPipe GXWGFifo; #define __GXCDEF4(func,ts,td) \ static inline void func(const ts x, const ts y, const ts z, const ts w) \ { \ - GXWGFifo._##td = (td) x; \ - GXWGFifo._##td = (td) y; \ - GXWGFifo._##td = (td) z; \ - GXWGFifo._##td = (td) w; \ + GXWGFifo.td = (td) x; \ + GXWGFifo.td = (td) y; \ + GXWGFifo.td = (td) z; \ + GXWGFifo.td = (td) w; \ return; \ } -- cgit v1.2.3