From 0a36d49d2cd4346dc99a52155e2599917c1e6a42 Mon Sep 17 00:00:00 2001 From: aap Date: Thu, 30 May 2019 00:47:33 +0200 Subject: clean up --- src/General.h | 7 +- src/ParticleMgr.cpp | 252 --------------------------------------------- src/ParticleMgr.h | 206 ------------------------------------ src/RecordDataForChase.cpp | 5 - src/RecordDataForChase.h | 7 -- src/RecordDataForGame.cpp | 4 - src/RecordDataForGame.h | 7 -- src/Timer.cpp | 6 +- src/common.h | 81 ++++++--------- src/config.h | 7 +- src/control/Record.cpp | 6 ++ src/control/Record.h | 13 +++ src/main.cpp | 15 --- src/math/Vector.cpp | 78 -------------- src/math/Vector.h | 169 ++++++++++-------------------- src/render/Particle.cpp | 4 +- src/render/ParticleMgr.cpp | 252 +++++++++++++++++++++++++++++++++++++++++++++ src/render/ParticleMgr.h | 206 ++++++++++++++++++++++++++++++++++++ src/render/Sprite.cpp | 6 -- src/render/Sprite2d.cpp | 7 -- 20 files changed, 573 insertions(+), 765 deletions(-) delete mode 100644 src/ParticleMgr.cpp delete mode 100644 src/ParticleMgr.h delete mode 100644 src/RecordDataForChase.cpp delete mode 100644 src/RecordDataForChase.h delete mode 100644 src/RecordDataForGame.cpp delete mode 100644 src/RecordDataForGame.h create mode 100644 src/control/Record.cpp create mode 100644 src/control/Record.h delete mode 100644 src/math/Vector.cpp create mode 100644 src/render/ParticleMgr.cpp create mode 100644 src/render/ParticleMgr.h (limited to 'src') diff --git a/src/General.h b/src/General.h index d67b1ff0..aa52bf4d 100644 --- a/src/General.h +++ b/src/General.h @@ -1,5 +1,4 @@ - - +#pragma once class CGeneral { @@ -46,8 +45,8 @@ public: { return myrand() & 0xFFFF; } // Probably don't want to ever reach high static float GetRandomNumberInRange(float low, float high) - { return low + (high - low)*(GetRandomNumber()/float(MY_RAND_MAX + 1)); } + { return low + (high - low)*(GetRandomNumber()/65536.0f); } static Int32 GetRandomNumberInRange(Int32 low, Int32 high) - { return low + (high - low)*(GetRandomNumber()/float(MY_RAND_MAX + 1)); } + { return low + (high - low)*(GetRandomNumber()/65536.0f); } }; diff --git a/src/ParticleMgr.cpp b/src/ParticleMgr.cpp deleted file mode 100644 index d259c4b4..00000000 --- a/src/ParticleMgr.cpp +++ /dev/null @@ -1,252 +0,0 @@ -#include "common.h" -#include "patcher.h" -#include "FileMgr.h" -#include "ParticleMgr.h" - -_TODO("work_buff"); -UInt8 work_buff[55000]; - -cParticleSystemMgr mod_ParticleSystemManager; - -const Char *ParticleFilename = "PARTICLE.CFG"; - -//cParticleSystemMgr::cParticleSystemMgr() -void cParticleSystemMgr::ctor() -{ - memset(this, 0, sizeof(*this)); -} - -void cParticleSystemMgr::Initialise() -{ - LoadParticleData(); - - for ( Int32 i = 0; i < MAX_PARTICLES; i++ ) - m_aParticles[i].m_pParticles = NULL; -} - -void cParticleSystemMgr::LoadParticleData() -{ - CFileMgr::SetDir("DATA"); - CFileMgr::LoadFile(ParticleFilename, work_buff, ARRAY_SIZE(work_buff), "r"); - CFileMgr::SetDir(""); - - tParticleSystemData *entry = NULL; - Int32 type = PARTICLE_FIRST; - - Char *lineStart = (Char *)work_buff; - Char *lineEnd = lineStart + 1; - - Char line[500]; - Char delims[4]; - - while ( true ) - { - ASSERT(lineStart != NULL); - ASSERT(lineEnd != NULL); - - while ( *lineEnd != '\n' ) - ++lineEnd; - - Int32 lineLength = lineEnd - lineStart; - - ASSERT(lineLength < 500); - - strncpy(line, lineStart, lineLength); - - line[lineLength] = '\0'; - - if ( !strcmp(line, ";the end") ) - break; - - if ( *line != ';' ) - { - Int32 param = CFG_PARAM_FIRST; - - strcpy(delims, " \t"); - - Char *value = strtok(line, delims); - - ASSERT(value != NULL); - - do - { - switch ( param ) - { - case CFG_PARAM_PARTICLE_TYPE_NAME: - ASSERT(type < MAX_PARTICLES); - entry = &m_aParticles[type]; - ASSERT(entry != NULL); - entry->m_Type = (tParticleType)type++; - strcpy(entry->m_aName, value); - break; - - case CFG_PARAM_RENDER_COLOURING_R: - entry->m_RenderColouring.red = atoi(value); - break; - - case CFG_PARAM_RENDER_COLOURING_G: - entry->m_RenderColouring.green = atoi(value); - break; - - case CFG_PARAM_RENDER_COLOURING_B: - entry->m_RenderColouring.blue = atoi(value); - break; - - case CFG_PARAM_INITIAL_COLOR_VARIATION: - entry->m_InitialColorVariation = min(atoi(value), 100); - break; - - case CFG_PARAM_FADE_DESTINATION_COLOR_R: - entry->m_FadeDestinationColor.red = atoi(value); - break; - - case CFG_PARAM_FADE_DESTINATION_COLOR_G: - entry->m_FadeDestinationColor.green = atoi(value); - break; - - case CFG_PARAM_FADE_DESTINATION_COLOR_B: - entry->m_FadeDestinationColor.blue = atoi(value); - break; - - case CFG_PARAM_COLOR_FADE_TIME: - entry->m_ColorFadeTime = atoi(value); - break; - - case CFG_PARAM_DEFAULT_INITIAL_RADIUS: - entry->m_fDefaultInitialRadius = atof(value); - break; - - case CFG_PARAM_EXPANSION_RATE: - entry->m_fExpansionRate = atof(value); - break; - - case CFG_PARAM_INITIAL_INTENSITY: - entry->m_nFadeToBlackInitialIntensity = atoi(value); - break; - - case CFG_PARAM_FADE_TIME: - entry->m_nFadeToBlackTime = atoi(value); - break; - - case CFG_PARAM_FADE_AMOUNT: - entry->m_nFadeToBlackAmount = atoi(value); - break; - - case CFG_PARAM_INITIAL_ALPHA_INTENSITY: - entry->m_nFadeAlphaInitialIntensity = atoi(value); - break; - - case CFG_PARAM_FADE_ALPHA_TIME: - entry->m_nFadeAlphaTime = atoi(value); - break; - - case CFG_PARAM_FADE_ALPHA_AMOUNT: - entry->m_nFadeAlphaAmount = atoi(value); - break; - - case CFG_PARAM_INITIAL_ANGLE: - entry->m_nZRotationInitialAngle = atoi(value); - break; - - case CFG_PARAM_CHANGE_TIME: - entry->m_nZRotationChangeTime = atoi(value); - break; - - case CFG_PARAM_ANGLE_CHANGE_AMOUNT: - entry->m_nZRotationAngleChangeAmount = atoi(value); - break; - - case CFG_PARAM_INITIAL_Z_RADIUS: - entry->m_fInitialZRadius = atof(value); - break; - - case CFG_PARAM_Z_RADIUS_CHANGE_TIME: - entry->m_nZRadiusChangeTime = atoi(value); - break; - - case CFG_PARAM_Z_RADIUS_CHANGE_AMOUNT: - entry->m_fZRadiusChangeAmount = atof(value); - break; - - case CFG_PARAM_ANIMATION_SPEED: - entry->m_nAnimationSpeed = atoi(value); - break; - - case CFG_PARAM_START_ANIMATION_FRAME: - entry->m_nStartAnimationFrame = atoi(value); - break; - - case CFG_PARAM_FINAL_ANIMATION_FRAME: - entry->m_nFinalAnimationFrame = atoi(value); - break; - - case CFG_PARAM_ROTATION_SPEED: - entry->m_nRotationSpeed = atoi(value); - break; - - case CFG_PARAM_GRAVITATIONAL_ACCELERATION: - entry->m_fGravitationalAcceleration = atof(value); - break; - - case CFG_PARAM_FRICTION_DECCELERATION: - entry->m_nFrictionDecceleration = atoi(value); - break; - - case CFG_PARAM_LIFE_SPAN: - entry->m_nLifeSpan = atoi(value); - break; - - case CFG_PARAM_POSITION_RANDOM_ERROR: - entry->m_fPositionRandomError = atof(value); - break; - - case CFG_PARAM_VELOCITY_RANDOM_ERROR: - entry->m_fVelocityRandomError = atof(value); - break; - - case CFG_PARAM_EXPANSION_RATE_ERROR: - entry->m_fExpansionRateError = atof(value); - break; - - case CFG_PARAM_ROTATION_RATE_ERROR: - entry->m_nRotationRateError = atoi(value); - break; - - case CFG_PARAM_LIFE_SPAN_ERROR_SHAPE: - entry->m_nLifeSpanErrorShape = atoi(value); - break; - - case CFG_PARAM_TRAIL_LENGTH_MULTIPLIER: - entry->m_fTrailLengthMultiplier = atof(value); - break; - - case CFG_PARAM_PARTICLE_CREATE_RANGE: - entry->m_fCreateRange = SQR(atof(value)); - break; - - case CFG_PARAM_FLAGS: - entry->Flags = atoi(value); - break; - } - - value = strtok(NULL, delims); - - param++; - - if ( param > CFG_PARAM_LAST ) - param = CFG_PARAM_FIRST; - - } while ( value != NULL ); - } - - lineEnd++; - lineStart = lineEnd; - lineEnd++; - } -} - -STARTPATCHES - InjectHook(0x50FCB0, &cParticleSystemMgr::ctor, PATCH_JUMP); - InjectHook(0x50FCD0, &cParticleSystemMgr::Initialise, PATCH_JUMP); - InjectHook(0x50FDF0, &cParticleSystemMgr::LoadParticleData, PATCH_JUMP); -ENDPATCHES \ No newline at end of file diff --git a/src/ParticleMgr.h b/src/ParticleMgr.h deleted file mode 100644 index a2dcbdb5..00000000 --- a/src/ParticleMgr.h +++ /dev/null @@ -1,206 +0,0 @@ -#pragma once - -class CParticle; - -enum tParticleType -{ - PARTICLE_SPARK = 0, - PARTICLE_SPARK_SMALL, - PARTICLE_WHEEL_DIRT, - PARTICLE_WHEEL_WATER, - PARTICLE_BLOOD, - PARTICLE_BLOOD_SMALL, - PARTICLE_BLOOD_SPURT, - PARTICLE_DEBRIS, - PARTICLE_DEBRIS2, - PARTICLE_WATER, - PARTICLE_FLAME, - PARTICLE_FIREBALL, - PARTICLE_GUNFLASH, - PARTICLE_GUNFLASH_NOANIM, - PARTICLE_GUNSMOKE, - PARTICLE_GUNSMOKE2, - PARTICLE_SMOKE, - PARTICLE_SMOKE_SLOWMOTION, - PARTICLE_GARAGEPAINT_SPRAY, - PARTICLE_SHARD, - PARTICLE_SPLASH, - PARTICLE_CARFLAME, - PARTICLE_STEAM, - PARTICLE_STEAM2, - PARTICLE_STEAM_NY, - PARTICLE_STEAM_NY_SLOWMOTION, - PARTICLE_ENGINE_STEAM, - PARTICLE_RAINDROP, - PARTICLE_RAINDROP_SMALL, - PARTICLE_RAIN_SPLASH, - PARTICLE_RAIN_SPLASH_BIGGROW, - PARTICLE_RAIN_SPLASHUP, - PARTICLE_WATERSPRAY, - PARTICLE_EXPLOSION_MEDIUM, - PARTICLE_EXPLOSION_LARGE, - PARTICLE_EXPLOSION_MFAST, - PARTICLE_EXPLOSION_LFAST, - PARTICLE_CAR_SPLASH, - PARTICLE_BOAT_SPLASH, - PARTICLE_BOAT_THRUSTJET, - PARTICLE_BOAT_WAKE, - PARTICLE_WATER_HYDRANT, - PARTICLE_WATER_CANNON, - PARTICLE_EXTINGUISH_STEAM, - PARTICLE_PED_SPLASH, - PARTICLE_PEDFOOT_DUST, - PARTICLE_HELI_DUST, - PARTICLE_HELI_ATTACK, - PARTICLE_ENGINE_SMOKE, - PARTICLE_ENGINE_SMOKE2, - PARTICLE_CARFLAME_SMOKE, - PARTICLE_FIREBALL_SMOKE, - PARTICLE_PAINT_SMOKE, - PARTICLE_TREE_LEAVES, - PARTICLE_CARCOLLISION_DUST, - PARTICLE_CAR_DEBRIS, - PARTICLE_HELI_DEBRIS, - PARTICLE_EXHAUST_FUMES, - PARTICLE_RUBBER_SMOKE, - PARTICLE_BURNINGRUBBER_SMOKE, - PARTICLE_BULLETHIT_SMOKE, - PARTICLE_GUNSHELL_FIRST, - PARTICLE_GUNSHELL, - PARTICLE_GUNSHELL_BUMP1, - PARTICLE_GUNSHELL_BUMP2, - PARTICLE_TEST, - PARTICLE_BIRD_FRONT, - PARTICLE_RAINDROP_2D, - - MAX_PARTICLES, - PARTICLE_FIRST = PARTICLE_SPARK, - PARTICLE_LAST = PARTICLE_RAINDROP_2D -}; - -enum -{ - ZCHECK_FIRST = BIT(0), - ZCHECK_STEP = BIT(1), - DRAW_OPAQUE = BIT(2), - SCREEN_TRAIL = BIT(3), - SPEED_TRAIL = BIT(4), - RAND_VERT_V = BIT(5), - CYCLE_ANIM = BIT(6), - DRAW_DARK = BIT(7), - VERT_TRAIL = BIT(8), - _FLAG9 = BIT(9), // unused - DRAWTOP2D = BIT(10), - CLIPOUT2D = BIT(11), - ZCHECK_BUMP = BIT(12), - ZCHECK_BUMP_FIRST = BIT(13) -}; - - -struct tParticleSystemData -{ - tParticleType m_Type; - Char m_aName[20]; - Float m_fCreateRange; - Float m_fDefaultInitialRadius; - Float m_fExpansionRate; - UInt16 m_nZRotationInitialAngle; - Int16 m_nZRotationAngleChangeAmount; - UInt16 m_nZRotationChangeTime; - UInt16 m_nZRadiusChangeTime; - Float m_fInitialZRadius; - Float m_fZRadiusChangeAmount; - UInt16 m_nFadeToBlackTime; - Int16 m_nFadeToBlackAmount; - UInt8 m_nFadeToBlackInitialIntensity; - UInt8 m_nFadeAlphaInitialIntensity; - UInt16 m_nFadeAlphaTime; - Int16 m_nFadeAlphaAmount; - UInt16 m_nStartAnimationFrame; - UInt16 m_nFinalAnimationFrame; - UInt16 m_nAnimationSpeed; - UInt16 m_nRotationSpeed; - char _pad1[2]; - Float m_fGravitationalAcceleration; - Int32 m_nFrictionDecceleration; - Int32 m_nLifeSpan; - Float m_fPositionRandomError; - Float m_fVelocityRandomError; - Float m_fExpansionRateError; - Int32 m_nRotationRateError; - UInt32 m_nLifeSpanErrorShape; - Float m_fTrailLengthMultiplier; - UInt32 Flags; - RwRGBA m_RenderColouring; - UInt8 m_InitialColorVariation; - RwRGBA m_FadeDestinationColor; - char _pad2[3]; - UInt32 m_ColorFadeTime; - - RwRaster **m_ppRaster; - CParticle *m_pParticles; -}; -VALIDATE_SIZE(tParticleSystemData, 0x88); - - -class cParticleSystemMgr -{ - enum - { - CFG_PARAM_PARTICLE_TYPE_NAME = 0, - CFG_PARAM_RENDER_COLOURING_R, - CFG_PARAM_RENDER_COLOURING_G, - CFG_PARAM_RENDER_COLOURING_B, - CFG_PARAM_INITIAL_COLOR_VARIATION, - CFG_PARAM_FADE_DESTINATION_COLOR_R, - CFG_PARAM_FADE_DESTINATION_COLOR_G, - CFG_PARAM_FADE_DESTINATION_COLOR_B, - CFG_PARAM_COLOR_FADE_TIME, - CFG_PARAM_DEFAULT_INITIAL_RADIUS, - CFG_PARAM_EXPANSION_RATE, - CFG_PARAM_INITIAL_INTENSITY, - CFG_PARAM_FADE_TIME, - CFG_PARAM_FADE_AMOUNT, - CFG_PARAM_INITIAL_ALPHA_INTENSITY, - CFG_PARAM_FADE_ALPHA_TIME, - CFG_PARAM_FADE_ALPHA_AMOUNT, - CFG_PARAM_INITIAL_ANGLE, - CFG_PARAM_CHANGE_TIME, - CFG_PARAM_ANGLE_CHANGE_AMOUNT, - CFG_PARAM_INITIAL_Z_RADIUS, - CFG_PARAM_Z_RADIUS_CHANGE_TIME, - CFG_PARAM_Z_RADIUS_CHANGE_AMOUNT, - CFG_PARAM_ANIMATION_SPEED, - CFG_PARAM_START_ANIMATION_FRAME, - CFG_PARAM_FINAL_ANIMATION_FRAME, - CFG_PARAM_ROTATION_SPEED, - CFG_PARAM_GRAVITATIONAL_ACCELERATION, - CFG_PARAM_FRICTION_DECCELERATION, - CFG_PARAM_LIFE_SPAN, - CFG_PARAM_POSITION_RANDOM_ERROR, - CFG_PARAM_VELOCITY_RANDOM_ERROR, - CFG_PARAM_EXPANSION_RATE_ERROR, - CFG_PARAM_ROTATION_RATE_ERROR, - CFG_PARAM_LIFE_SPAN_ERROR_SHAPE, - CFG_PARAM_TRAIL_LENGTH_MULTIPLIER, - CFG_PARAM_PARTICLE_CREATE_RANGE, - CFG_PARAM_FLAGS, - - MAX_CFG_PARAMS, - CFG_PARAM_FIRST = CFG_PARAM_PARTICLE_TYPE_NAME, - CFG_PARAM_LAST = CFG_PARAM_FLAGS - }; - -public: - tParticleSystemData m_aParticles[MAX_PARTICLES]; - - cParticleSystemMgr() { ctor(); } void ctor(); - - void Initialise(); - void LoadParticleData(); - //void RangeCheck(tParticleSystemData *pData); -}; - -VALIDATE_SIZE(cParticleSystemMgr, 0x2420); - -extern cParticleSystemMgr mod_ParticleSystemManager; \ No newline at end of file diff --git a/src/RecordDataForChase.cpp b/src/RecordDataForChase.cpp deleted file mode 100644 index 6bff623e..00000000 --- a/src/RecordDataForChase.cpp +++ /dev/null @@ -1,5 +0,0 @@ -#include "common.h" -#include "RecordDataForChase.h" - - -UInt8 &CRecordDataForChase::Status = *(UInt8*)0x95CDCE; \ No newline at end of file diff --git a/src/RecordDataForChase.h b/src/RecordDataForChase.h deleted file mode 100644 index 0dc72bed..00000000 --- a/src/RecordDataForChase.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -class CRecordDataForChase -{ -public: - static UInt8 &Status; -}; \ No newline at end of file diff --git a/src/RecordDataForGame.cpp b/src/RecordDataForGame.cpp deleted file mode 100644 index 05b4223c..00000000 --- a/src/RecordDataForGame.cpp +++ /dev/null @@ -1,4 +0,0 @@ -#include "common.h" -#include "RecordDataForGame.h" - -UInt16 &CRecordDataForGame::RecordingState = *(UInt16 *)0x95CC24; \ No newline at end of file diff --git a/src/RecordDataForGame.h b/src/RecordDataForGame.h deleted file mode 100644 index 5d007ce5..00000000 --- a/src/RecordDataForGame.h +++ /dev/null @@ -1,7 +0,0 @@ -#pragma once - -class CRecordDataForGame -{ -public: - static UInt16 &RecordingState; -}; \ No newline at end of file diff --git a/src/Timer.cpp b/src/Timer.cpp index 02dbf55a..35e569ac 100644 --- a/src/Timer.cpp +++ b/src/Timer.cpp @@ -1,10 +1,9 @@ +#include #include "common.h" #include "patcher.h" #include "DMAudio.h" +#include "Record.h" #include "Timer.h" -#include "RecordDataForGame.h" -#include "RecordDataForChase.h" -#include uint32 &CTimer::m_snTimeInMilliseconds = *(uint32*)0x885B48; uint32 &CTimer::m_snTimeInMillisecondsPauseMode = *(uint32*)0x5F7614; @@ -229,4 +228,3 @@ STARTPATCHES InjectHook(0x4AD4A0, CTimer::EndUserPause, PATCH_JUMP); ENDPATCHES #endif - diff --git a/src/common.h b/src/common.h index 89c031fe..34214d42 100644 --- a/src/common.h +++ b/src/common.h @@ -18,32 +18,29 @@ #define rwVENDORID_ROCKSTAR 0x0253F2 -typedef uint8_t uint8; -typedef int8_t int8; -typedef uint16_t uint16; -typedef int16_t int16; -typedef uint32_t uint32; -typedef int32_t int32; +// Get rid of bullshit windows definitions, we're not running on an 8086 +#ifdef far +#undef far +#endif +#ifdef near +#undef near +#endif + +typedef uint8_t uint8, UInt8; +typedef int8_t int8, Int8; +typedef uint16_t uint16, UInt16; +typedef int16_t int16, Int16; +typedef uint32_t uint32, UInt32; +typedef int32_t int32, Int32; typedef uintptr_t uintptr; +typedef uint64_t uint64, UInt64; +typedef int64_t int64, Int64; -typedef char Int8; -typedef unsigned char UInt8; -typedef signed char SInt8; -typedef short Int16; -typedef unsigned short UInt16; -typedef signed short SInt16; -typedef int Int32; -typedef unsigned int UInt32; -typedef signed int SInt32; -typedef float Float; -typedef double Double; -typedef Int8 Bool; //typedef bool Bool; +typedef float Float; +typedef double Double; +typedef bool Bool; typedef char Char; -typedef __int64 Int64; -typedef unsigned __int64 UInt64; -typedef signed __int64 SInt64; - #define nil NULL #include "config.h" @@ -85,10 +82,10 @@ extern RsGlobalType &RsGlobal; #define DEFAULT_SCREEN_HEIGHT (448) #define SCREEN_WIDTH Float(RsGlobal.width) #define SCREEN_HEIGHT Float(RsGlobal.height) -#define SCREEN_STRETCH_X(a) Float( a * ( SCREEN_WIDTH / Float(DEFAULT_SCREEN_WIDTH) ) ) -#define SCREEN_STRETCH_Y(a) Float( a * ( SCREEN_HEIGHT / Float(DEFAULT_SCREEN_HEIGHT) ) ) -#define SCREEN_FROM_RIGHT(a) Float( SCREEN_WIDTH - SCREEN_STRETCH_X(a) ) -#define SCREEN_FROM_BOTTOM(a) Float( SCREEN_HEIGHT - SCREEN_STRETCH_Y(a) ) +#define SCREEN_STRETCH_X(a) Float((a) * (SCREEN_WIDTH / Float(DEFAULT_SCREEN_WIDTH))) +#define SCREEN_STRETCH_Y(a) Float((a) * (SCREEN_HEIGHT / Float(DEFAULT_SCREEN_HEIGHT))) +#define SCREEN_FROM_RIGHT(a) Float(SCREEN_WIDTH - SCREEN_STRETCH_X(a)) +#define SCREEN_FROM_BOTTOM(a) Float(SCREEN_HEIGHT - SCREEN_STRETCH_Y(a)) char *GetUserDirectory(void); @@ -120,41 +117,29 @@ public: CRGBA(void) { } CRGBA(uint8 r, uint8 g, uint8 b, uint8 a) : r(r), g(g), b(b), a(a) { } #ifdef RWCORE_H - operator RwRGBA &(void) - { + operator RwRGBA &(void) { return rwRGBA; } - operator RwRGBA *(void) - { + operator RwRGBA *(void) { return &rwRGBA; } - operator RwRGBA (void) const - { + operator RwRGBA (void) const { return rwRGBA; } #endif }; -// inline float clamp(float v, float min, float max){ return vmax ? max : v; } - -inline float -sq(float x) { return x*x; } +#define clamp(v, low, high) ((v)<(low) ? (low) : (v)>(high) ? (high) : (v)) -#define SQR(x) ( x * x ) +inline float sq(float x) { return x*x; } +#define SQR(x) ((x) * (x)) #define PI M_PI #define DEGTORAD(x) ((x) * PI / 180.0f) #define RADTODEG(x) ((x) * 180.0f / PI) - -#if USE_PS2_RAND == TRUE -#define MY_RAND_MAX 65535 -#else -#define MY_RAND_MAX 32767 -#endif - int myrand(void); void mysrand(unsigned int seed); @@ -167,10 +152,6 @@ void mysrand(unsigned int seed); #define VALIDATE_SIZE(struc, size) static_assert(sizeof(struc) == size, "Invalid structure size of " #struc) #define VALIDATE_OFFSET(struc, member, offset) static_assert(offsetof(struc, member) == offset, "The offset of " #member " in " #struc " is not " #offset "...") -#define clamp(v, a, b) (max(min(v, b), a)) -//#define min(a, b) ((a) < (b) ? (a) : (b)) -//#define max(a, b) ((a) > (b) ? (a) : (b)) - -#define PERCENT(x, p) ( ( Float(x) * ( Float(p) / 100.0f ) ) ) +#define PERCENT(x, p) ((Float(x) * (Float(p) / 100.0f))) #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0])) -#define BIT(num) (1<<(num)) \ No newline at end of file +#define BIT(num) (1<<(num)) diff --git a/src/config.h b/src/config.h index 8637814d..ccd81023 100644 --- a/src/config.h +++ b/src/config.h @@ -1,5 +1,4 @@ -#ifndef _CONFIG_H_ -#define _CONFIG_H_ +#pragma once enum Config { NUMCDIMAGES = 50, // was 12 @@ -52,7 +51,3 @@ enum Config { NUMWEATHERS = 4, NUMHOURS = 24, }; - -#define USE_PS2_RAND TRUE - -#endif diff --git a/src/control/Record.cpp b/src/control/Record.cpp new file mode 100644 index 00000000..8949da5e --- /dev/null +++ b/src/control/Record.cpp @@ -0,0 +1,6 @@ +#include "common.h" +#include "Record.h" + +UInt16 &CRecordDataForGame::RecordingState = *(UInt16*)0x95CC24; + +UInt8 &CRecordDataForChase::Status = *(UInt8*)0x95CDCE; diff --git a/src/control/Record.h b/src/control/Record.h new file mode 100644 index 00000000..97a9663d --- /dev/null +++ b/src/control/Record.h @@ -0,0 +1,13 @@ +#pragma once + +class CRecordDataForGame +{ +public: + static UInt16 &RecordingState; +}; + +class CRecordDataForChase +{ +public: + static UInt8 &Status; +}; diff --git a/src/main.cpp b/src/main.cpp index 853308a1..955b33ed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -24,37 +24,22 @@ void operator delete(void *ptr) noexcept { gtadelete(ptr); } unsigned __int64 myrand_seed = 1; - -int _cwrand() // original codewarrior rand -{ - return ((int (__cdecl *)())0x5A41D0)(); -} - int myps2rand(void) { - return _cwrand(); myrand_seed = 0x5851F42D4C957F2D * myrand_seed + 1; return ((myrand_seed >> 32) & 0x7FFFFFFF); } int myrand(void) { -#if USE_PS2_RAND == TRUE return myps2rand(); -#else - return _cwrand(); -#endif } void mysrand(unsigned int seed) { -#if USE_PS2_RAND == TRUE myrand_seed = seed; -#else - ; -#endif } // platform stuff diff --git a/src/math/Vector.cpp b/src/math/Vector.cpp deleted file mode 100644 index d9cc590f..00000000 --- a/src/math/Vector.cpp +++ /dev/null @@ -1,78 +0,0 @@ -#include "common.h" -#include "Vector.h" - -void CVector::Normalise() -{ - float sq = MagnitudeSqr(); - if(sq > 0.0f){ - float invsqrt = 1.0f/sqrt(sq); // CMaths::RecipSqrt - x *= invsqrt; - y *= invsqrt; - z *= invsqrt; - }else - x = 1.0f; -} - -// operator + -CVector operator + (CVector const &refLeft, CVector const &refRight) -{ - return CVector(refLeft.x + refRight.x, refLeft.y + refRight.y, refLeft.z + refRight.z); -} - -CVector operator + (CVector const &refLeft, float fRight) -{ - return CVector(refLeft.x + fRight, refLeft.y + fRight, refLeft.z + fRight); -} - -CVector operator + (float fLeft, CVector const &refRight) -{ - return CVector(fLeft + refRight.x, fLeft + refRight.y, fLeft + refRight.z); -} - -// operator - -CVector operator - (CVector const &refLeft, CVector const &refRight) -{ - return CVector(refLeft.x - refRight.x, refLeft.y - refRight.y, refLeft.z - refRight.z); -} - -CVector operator - (CVector const &refLeft, float fRight) -{ - return CVector(refLeft.x - fRight, refLeft.y - fRight, refLeft.z - fRight); -} - -CVector operator - (float fLeft, CVector const &refRight) -{ - return CVector(fLeft - refRight.x, fLeft - refRight.y, fLeft - refRight.z); -} - -// operator * -CVector operator * (CVector const &refLeft, CVector const &refRight) -{ - return CVector(refLeft.x * refRight.x, refLeft.y * refRight.y, refLeft.z * refRight.z); -} - -CVector operator * (CVector const &refLeft, float fRight) -{ - return CVector(refLeft.x * fRight, refLeft.y * fRight, refLeft.z * fRight); -} - -CVector operator * (float fLeft, CVector const &refRight) -{ - return CVector(fLeft * refRight.x, fLeft * refRight.y, fLeft * refRight.z); -} - -// operator / -CVector operator / (CVector const &refLeft, CVector const &refRight) -{ - return CVector(refLeft.x / refRight.x, refLeft.y / refRight.y, refLeft.z / refRight.z); -} - -CVector operator / (CVector const &refLeft, float fRight) -{ - return CVector(refLeft.x / fRight, refLeft.y / fRight, refLeft.z / fRight); -} - -CVector operator / (float fLeft, CVector const &refRight) -{ - return CVector(fLeft / refRight.x, fLeft / refRight.y, fLeft / refRight.z); -} \ No newline at end of file diff --git a/src/math/Vector.h b/src/math/Vector.h index e45906c8..3dba07ca 100644 --- a/src/math/Vector.h +++ b/src/math/Vector.h @@ -6,128 +6,71 @@ public: float x, y, z; CVector(void) {} CVector(float x, float y, float z) : x(x), y(y), z(z) {} -// CVector(CVector &refVector) : x(refVector.x), y(refVector.y), z(refVector.z) { } -// CVector(const CVector &refVector) : x(refVector.x), y(refVector.y), z(refVector.z) {} -// CVector(CVector2D &refVector, float _z = 0.0f) : x(refVector.x), y(refVector.y), z(_z) {} #ifdef RWCORE_H - CVector(RwV3d const &v) : x(v.x), y(v.y), z(v.z) {} + CVector(const RwV3d &v) : x(v.x), y(v.y), z(v.z) {} operator RwV3d (void) const { RwV3d vecRw = { this->x, this->y, this->z }; return vecRw; } - operator RwV3d *(void) - { - return (RwV3d *)this; + operator RwV3d *(void) { + return (RwV3d*)this; } - operator RwV3d &(void) - { - return *((RwV3d *)this); + operator RwV3d &(void) { + return *((RwV3d*)this); } #endif float Magnitude(void) const { return sqrt(x*x + y*y + z*z); } float MagnitudeSqr(void) const { return x*x + y*y + z*z; } float Magnitude2D(void) const { return sqrt(x*x + y*y); } - void Normalise(void); - - - // operator = - inline CVector const& operator = (CVector const &refRight) - { - x = refRight.x; - y = refRight.y; - z = refRight.z; - return *this; - } - - inline CVector const& operator = (float fRight) - { - x = fRight; - y = fRight; - z = fRight; - return *this; - } - - // operator += - inline CVector const& operator += (CVector const &refRight) - { - x += refRight.x; - y += refRight.y; - z += refRight.z; - return *this; - } - - inline CVector const& operator += (float fRight) - { - x += fRight; - y += fRight; - z += fRight; - return *this; - } - - // operator -= - inline CVector const& operator -= (CVector const &refRight) - { - x -= refRight.x; - y -= refRight.y; - z -= refRight.z; - return *this; + void Normalise(void) { + float sq = MagnitudeSqr(); + if(sq > 0.0f){ + float invsqrt = 1.0f/sqrt(sq); // CMaths::RecipSqrt + x *= invsqrt; + y *= invsqrt; + z *= invsqrt; + }else + x = 1.0f; } - - inline CVector const& operator -= (float fRight) - { - x -= fRight; - y -= fRight; - z -= fRight; + + inline const CVector &operator+=(CVector const &right) { + x += right.x; + y += right.y; + z += right.z; return *this; } - - // operator *= - inline CVector const& operator *= (CVector const &refRight) - { - x *= refRight.x; - y *= refRight.y; - z *= refRight.z; + + inline const CVector &operator-=(CVector const &right) { + x -= right.x; + y -= right.y; + z -= right.z; return *this; } - - inline CVector const& operator *= (float fRight) - { - x *= fRight; - y *= fRight; - z *= fRight; + + inline const CVector &operator*=(float right) { + x *= right; + y *= right; + z *= right; return *this; } - - // operator /= - inline CVector const& operator /= (CVector const &refRight) - { - x /= refRight.x; - y /= refRight.y; - z /= refRight.z; + + inline const CVector &operator/=(float right) { + x /= right; + y /= right; + z /= right; return *this; } - - inline CVector const& operator /= (float fRight) - { - x /= fRight; - y /= fRight; - z /= fRight; - return *this; + + inline CVector operator-() const { + return CVector(-x, -y, -z); } - - inline CVector operator - () const - { - return CVector(-x, -y, -z); - } - + bool IsZero(void) { return x == 0.0f && y == 0.0f && z == 0.0f; } }; -//extern CVector operator*(CMatrix const& matrix, CVector const& vector); - inline float DotProduct(const CVector &v1, const CVector &v2) { @@ -143,22 +86,22 @@ CrossProduct(const CVector &v1, const CVector &v2) v1.x*v2.y - v1.y*v2.x); } -// operator + -extern CVector operator + (CVector const &refLeft, CVector const &refRight); -extern CVector operator + (CVector const &refLeft, float fRight); -extern CVector operator + (float fLeft, CVector const &refRight); +inline CVector operator+(const CVector &left, const CVector &right) +{ + return CVector(left.x + right.x, left.y + right.y, left.z + right.z); +} + +inline CVector operator-(const CVector &left, const CVector &right) +{ + return CVector(left.x - right.x, left.y - right.y, left.z - right.z); +} -// operator - -extern CVector operator - (CVector const &refLeft, CVector const &refRight); -extern CVector operator - (CVector const &refLeft, float fRight); -extern CVector operator - (float fLeft, CVector const &refRight); - -// operator * -extern CVector operator * (CVector const &refLeft, CVector const &refRight); -extern CVector operator * (CVector const &refLeft, float fRight); -extern CVector operator * (float fLeft, CVector const &refRight); - -// operator / -extern CVector operator / (CVector const &refLeft, CVector const &refRight); -extern CVector operator / (CVector const &refLeft, float fRight); -extern CVector operator / (float fLeft, CVector const &refRight); \ No newline at end of file +inline CVector operator*(const CVector &left, float right) +{ + return CVector(left.x * right, left.y * right, left.z * right); +} + +inline CVector operator/(const CVector &left, float right) +{ + return CVector(left.x / right, left.y / right, left.z / right); +} diff --git a/src/render/Particle.cpp b/src/render/Particle.cpp index aade3578..18ea4c6c 100644 --- a/src/render/Particle.cpp +++ b/src/render/Particle.cpp @@ -1229,7 +1229,9 @@ void CParticle::Update() moveStep.z = point.point.z; if ( psystem->m_Type == PARTICLE_DEBRIS2 ) { - particle->m_vecVelocity *= CVector(0.8f, 0.8f, -0.4f); + particle->m_vecVelocity.x *= 0.8f; + particle->m_vecVelocity.y *= 0.8f; + particle->m_vecVelocity.z *= -0.4f; if ( particle->m_vecVelocity.z < 0.005f ) particle->m_vecVelocity.z = 0.0f; } diff --git a/src/render/ParticleMgr.cpp b/src/render/ParticleMgr.cpp new file mode 100644 index 00000000..d259c4b4 --- /dev/null +++ b/src/render/ParticleMgr.cpp @@ -0,0 +1,252 @@ +#include "common.h" +#include "patcher.h" +#include "FileMgr.h" +#include "ParticleMgr.h" + +_TODO("work_buff"); +UInt8 work_buff[55000]; + +cParticleSystemMgr mod_ParticleSystemManager; + +const Char *ParticleFilename = "PARTICLE.CFG"; + +//cParticleSystemMgr::cParticleSystemMgr() +void cParticleSystemMgr::ctor() +{ + memset(this, 0, sizeof(*this)); +} + +void cParticleSystemMgr::Initialise() +{ + LoadParticleData(); + + for ( Int32 i = 0; i < MAX_PARTICLES; i++ ) + m_aParticles[i].m_pParticles = NULL; +} + +void cParticleSystemMgr::LoadParticleData() +{ + CFileMgr::SetDir("DATA"); + CFileMgr::LoadFile(ParticleFilename, work_buff, ARRAY_SIZE(work_buff), "r"); + CFileMgr::SetDir(""); + + tParticleSystemData *entry = NULL; + Int32 type = PARTICLE_FIRST; + + Char *lineStart = (Char *)work_buff; + Char *lineEnd = lineStart + 1; + + Char line[500]; + Char delims[4]; + + while ( true ) + { + ASSERT(lineStart != NULL); + ASSERT(lineEnd != NULL); + + while ( *lineEnd != '\n' ) + ++lineEnd; + + Int32 lineLength = lineEnd - lineStart; + + ASSERT(lineLength < 500); + + strncpy(line, lineStart, lineLength); + + line[lineLength] = '\0'; + + if ( !strcmp(line, ";the end") ) + break; + + if ( *line != ';' ) + { + Int32 param = CFG_PARAM_FIRST; + + strcpy(delims, " \t"); + + Char *value = strtok(line, delims); + + ASSERT(value != NULL); + + do + { + switch ( param ) + { + case CFG_PARAM_PARTICLE_TYPE_NAME: + ASSERT(type < MAX_PARTICLES); + entry = &m_aParticles[type]; + ASSERT(entry != NULL); + entry->m_Type = (tParticleType)type++; + strcpy(entry->m_aName, value); + break; + + case CFG_PARAM_RENDER_COLOURING_R: + entry->m_RenderColouring.red = atoi(value); + break; + + case CFG_PARAM_RENDER_COLOURING_G: + entry->m_RenderColouring.green = atoi(value); + break; + + case CFG_PARAM_RENDER_COLOURING_B: + entry->m_RenderColouring.blue = atoi(value); + break; + + case CFG_PARAM_INITIAL_COLOR_VARIATION: + entry->m_InitialColorVariation = min(atoi(value), 100); + break; + + case CFG_PARAM_FADE_DESTINATION_COLOR_R: + entry->m_FadeDestinationColor.red = atoi(value); + break; + + case CFG_PARAM_FADE_DESTINATION_COLOR_G: + entry->m_FadeDestinationColor.green = atoi(value); + break; + + case CFG_PARAM_FADE_DESTINATION_COLOR_B: + entry->m_FadeDestinationColor.blue = atoi(value); + break; + + case CFG_PARAM_COLOR_FADE_TIME: + entry->m_ColorFadeTime = atoi(value); + break; + + case CFG_PARAM_DEFAULT_INITIAL_RADIUS: + entry->m_fDefaultInitialRadius = atof(value); + break; + + case CFG_PARAM_EXPANSION_RATE: + entry->m_fExpansionRate = atof(value); + break; + + case CFG_PARAM_INITIAL_INTENSITY: + entry->m_nFadeToBlackInitialIntensity = atoi(value); + break; + + case CFG_PARAM_FADE_TIME: + entry->m_nFadeToBlackTime = atoi(value); + break; + + case CFG_PARAM_FADE_AMOUNT: + entry->m_nFadeToBlackAmount = atoi(value); + break; + + case CFG_PARAM_INITIAL_ALPHA_INTENSITY: + entry->m_nFadeAlphaInitialIntensity = atoi(value); + break; + + case CFG_PARAM_FADE_ALPHA_TIME: + entry->m_nFadeAlphaTime = atoi(value); + break; + + case CFG_PARAM_FADE_ALPHA_AMOUNT: + entry->m_nFadeAlphaAmount = atoi(value); + break; + + case CFG_PARAM_INITIAL_ANGLE: + entry->m_nZRotationInitialAngle = atoi(value); + break; + + case CFG_PARAM_CHANGE_TIME: + entry->m_nZRotationChangeTime = atoi(value); + break; + + case CFG_PARAM_ANGLE_CHANGE_AMOUNT: + entry->m_nZRotationAngleChangeAmount = atoi(value); + break; + + case CFG_PARAM_INITIAL_Z_RADIUS: + entry->m_fInitialZRadius = atof(value); + break; + + case CFG_PARAM_Z_RADIUS_CHANGE_TIME: + entry->m_nZRadiusChangeTime = atoi(value); + break; + + case CFG_PARAM_Z_RADIUS_CHANGE_AMOUNT: + entry->m_fZRadiusChangeAmount = atof(value); + break; + + case CFG_PARAM_ANIMATION_SPEED: + entry->m_nAnimationSpeed = atoi(value); + break; + + case CFG_PARAM_START_ANIMATION_FRAME: + entry->m_nStartAnimationFrame = atoi(value); + break; + + case CFG_PARAM_FINAL_ANIMATION_FRAME: + entry->m_nFinalAnimationFrame = atoi(value); + break; + + case CFG_PARAM_ROTATION_SPEED: + entry->m_nRotationSpeed = atoi(value); + break; + + case CFG_PARAM_GRAVITATIONAL_ACCELERATION: + entry->m_fGravitationalAcceleration = atof(value); + break; + + case CFG_PARAM_FRICTION_DECCELERATION: + entry->m_nFrictionDecceleration = atoi(value); + break; + + case CFG_PARAM_LIFE_SPAN: + entry->m_nLifeSpan = atoi(value); + break; + + case CFG_PARAM_POSITION_RANDOM_ERROR: + entry->m_fPositionRandomError = atof(value); + break; + + case CFG_PARAM_VELOCITY_RANDOM_ERROR: + entry->m_fVelocityRandomError = atof(value); + break; + + case CFG_PARAM_EXPANSION_RATE_ERROR: + entry->m_fExpansionRateError = atof(value); + break; + + case CFG_PARAM_ROTATION_RATE_ERROR: + entry->m_nRotationRateError = atoi(value); + break; + + case CFG_PARAM_LIFE_SPAN_ERROR_SHAPE: + entry->m_nLifeSpanErrorShape = atoi(value); + break; + + case CFG_PARAM_TRAIL_LENGTH_MULTIPLIER: + entry->m_fTrailLengthMultiplier = atof(value); + break; + + case CFG_PARAM_PARTICLE_CREATE_RANGE: + entry->m_fCreateRange = SQR(atof(value)); + break; + + case CFG_PARAM_FLAGS: + entry->Flags = atoi(value); + break; + } + + value = strtok(NULL, delims); + + param++; + + if ( param > CFG_PARAM_LAST ) + param = CFG_PARAM_FIRST; + + } while ( value != NULL ); + } + + lineEnd++; + lineStart = lineEnd; + lineEnd++; + } +} + +STARTPATCHES + InjectHook(0x50FCB0, &cParticleSystemMgr::ctor, PATCH_JUMP); + InjectHook(0x50FCD0, &cParticleSystemMgr::Initialise, PATCH_JUMP); + InjectHook(0x50FDF0, &cParticleSystemMgr::LoadParticleData, PATCH_JUMP); +ENDPATCHES \ No newline at end of file diff --git a/src/render/ParticleMgr.h b/src/render/ParticleMgr.h new file mode 100644 index 00000000..a2dcbdb5 --- /dev/null +++ b/src/render/ParticleMgr.h @@ -0,0 +1,206 @@ +#pragma once + +class CParticle; + +enum tParticleType +{ + PARTICLE_SPARK = 0, + PARTICLE_SPARK_SMALL, + PARTICLE_WHEEL_DIRT, + PARTICLE_WHEEL_WATER, + PARTICLE_BLOOD, + PARTICLE_BLOOD_SMALL, + PARTICLE_BLOOD_SPURT, + PARTICLE_DEBRIS, + PARTICLE_DEBRIS2, + PARTICLE_WATER, + PARTICLE_FLAME, + PARTICLE_FIREBALL, + PARTICLE_GUNFLASH, + PARTICLE_GUNFLASH_NOANIM, + PARTICLE_GUNSMOKE, + PARTICLE_GUNSMOKE2, + PARTICLE_SMOKE, + PARTICLE_SMOKE_SLOWMOTION, + PARTICLE_GARAGEPAINT_SPRAY, + PARTICLE_SHARD, + PARTICLE_SPLASH, + PARTICLE_CARFLAME, + PARTICLE_STEAM, + PARTICLE_STEAM2, + PARTICLE_STEAM_NY, + PARTICLE_STEAM_NY_SLOWMOTION, + PARTICLE_ENGINE_STEAM, + PARTICLE_RAINDROP, + PARTICLE_RAINDROP_SMALL, + PARTICLE_RAIN_SPLASH, + PARTICLE_RAIN_SPLASH_BIGGROW, + PARTICLE_RAIN_SPLASHUP, + PARTICLE_WATERSPRAY, + PARTICLE_EXPLOSION_MEDIUM, + PARTICLE_EXPLOSION_LARGE, + PARTICLE_EXPLOSION_MFAST, + PARTICLE_EXPLOSION_LFAST, + PARTICLE_CAR_SPLASH, + PARTICLE_BOAT_SPLASH, + PARTICLE_BOAT_THRUSTJET, + PARTICLE_BOAT_WAKE, + PARTICLE_WATER_HYDRANT, + PARTICLE_WATER_CANNON, + PARTICLE_EXTINGUISH_STEAM, + PARTICLE_PED_SPLASH, + PARTICLE_PEDFOOT_DUST, + PARTICLE_HELI_DUST, + PARTICLE_HELI_ATTACK, + PARTICLE_ENGINE_SMOKE, + PARTICLE_ENGINE_SMOKE2, + PARTICLE_CARFLAME_SMOKE, + PARTICLE_FIREBALL_SMOKE, + PARTICLE_PAINT_SMOKE, + PARTICLE_TREE_LEAVES, + PARTICLE_CARCOLLISION_DUST, + PARTICLE_CAR_DEBRIS, + PARTICLE_HELI_DEBRIS, + PARTICLE_EXHAUST_FUMES, + PARTICLE_RUBBER_SMOKE, + PARTICLE_BURNINGRUBBER_SMOKE, + PARTICLE_BULLETHIT_SMOKE, + PARTICLE_GUNSHELL_FIRST, + PARTICLE_GUNSHELL, + PARTICLE_GUNSHELL_BUMP1, + PARTICLE_GUNSHELL_BUMP2, + PARTICLE_TEST, + PARTICLE_BIRD_FRONT, + PARTICLE_RAINDROP_2D, + + MAX_PARTICLES, + PARTICLE_FIRST = PARTICLE_SPARK, + PARTICLE_LAST = PARTICLE_RAINDROP_2D +}; + +enum +{ + ZCHECK_FIRST = BIT(0), + ZCHECK_STEP = BIT(1), + DRAW_OPAQUE = BIT(2), + SCREEN_TRAIL = BIT(3), + SPEED_TRAIL = BIT(4), + RAND_VERT_V = BIT(5), + CYCLE_ANIM = BIT(6), + DRAW_DARK = BIT(7), + VERT_TRAIL = BIT(8), + _FLAG9 = BIT(9), // unused + DRAWTOP2D = BIT(10), + CLIPOUT2D = BIT(11), + ZCHECK_BUMP = BIT(12), + ZCHECK_BUMP_FIRST = BIT(13) +}; + + +struct tParticleSystemData +{ + tParticleType m_Type; + Char m_aName[20]; + Float m_fCreateRange; + Float m_fDefaultInitialRadius; + Float m_fExpansionRate; + UInt16 m_nZRotationInitialAngle; + Int16 m_nZRotationAngleChangeAmount; + UInt16 m_nZRotationChangeTime; + UInt16 m_nZRadiusChangeTime; + Float m_fInitialZRadius; + Float m_fZRadiusChangeAmount; + UInt16 m_nFadeToBlackTime; + Int16 m_nFadeToBlackAmount; + UInt8 m_nFadeToBlackInitialIntensity; + UInt8 m_nFadeAlphaInitialIntensity; + UInt16 m_nFadeAlphaTime; + Int16 m_nFadeAlphaAmount; + UInt16 m_nStartAnimationFrame; + UInt16 m_nFinalAnimationFrame; + UInt16 m_nAnimationSpeed; + UInt16 m_nRotationSpeed; + char _pad1[2]; + Float m_fGravitationalAcceleration; + Int32 m_nFrictionDecceleration; + Int32 m_nLifeSpan; + Float m_fPositionRandomError; + Float m_fVelocityRandomError; + Float m_fExpansionRateError; + Int32 m_nRotationRateError; + UInt32 m_nLifeSpanErrorShape; + Float m_fTrailLengthMultiplier; + UInt32 Flags; + RwRGBA m_RenderColouring; + UInt8 m_InitialColorVariation; + RwRGBA m_FadeDestinationColor; + char _pad2[3]; + UInt32 m_ColorFadeTime; + + RwRaster **m_ppRaster; + CParticle *m_pParticles; +}; +VALIDATE_SIZE(tParticleSystemData, 0x88); + + +class cParticleSystemMgr +{ + enum + { + CFG_PARAM_PARTICLE_TYPE_NAME = 0, + CFG_PARAM_RENDER_COLOURING_R, + CFG_PARAM_RENDER_COLOURING_G, + CFG_PARAM_RENDER_COLOURING_B, + CFG_PARAM_INITIAL_COLOR_VARIATION, + CFG_PARAM_FADE_DESTINATION_COLOR_R, + CFG_PARAM_FADE_DESTINATION_COLOR_G, + CFG_PARAM_FADE_DESTINATION_COLOR_B, + CFG_PARAM_COLOR_FADE_TIME, + CFG_PARAM_DEFAULT_INITIAL_RADIUS, + CFG_PARAM_EXPANSION_RATE, + CFG_PARAM_INITIAL_INTENSITY, + CFG_PARAM_FADE_TIME, + CFG_PARAM_FADE_AMOUNT, + CFG_PARAM_INITIAL_ALPHA_INTENSITY, + CFG_PARAM_FADE_ALPHA_TIME, + CFG_PARAM_FADE_ALPHA_AMOUNT, + CFG_PARAM_INITIAL_ANGLE, + CFG_PARAM_CHANGE_TIME, + CFG_PARAM_ANGLE_CHANGE_AMOUNT, + CFG_PARAM_INITIAL_Z_RADIUS, + CFG_PARAM_Z_RADIUS_CHANGE_TIME, + CFG_PARAM_Z_RADIUS_CHANGE_AMOUNT, + CFG_PARAM_ANIMATION_SPEED, + CFG_PARAM_START_ANIMATION_FRAME, + CFG_PARAM_FINAL_ANIMATION_FRAME, + CFG_PARAM_ROTATION_SPEED, + CFG_PARAM_GRAVITATIONAL_ACCELERATION, + CFG_PARAM_FRICTION_DECCELERATION, + CFG_PARAM_LIFE_SPAN, + CFG_PARAM_POSITION_RANDOM_ERROR, + CFG_PARAM_VELOCITY_RANDOM_ERROR, + CFG_PARAM_EXPANSION_RATE_ERROR, + CFG_PARAM_ROTATION_RATE_ERROR, + CFG_PARAM_LIFE_SPAN_ERROR_SHAPE, + CFG_PARAM_TRAIL_LENGTH_MULTIPLIER, + CFG_PARAM_PARTICLE_CREATE_RANGE, + CFG_PARAM_FLAGS, + + MAX_CFG_PARAMS, + CFG_PARAM_FIRST = CFG_PARAM_PARTICLE_TYPE_NAME, + CFG_PARAM_LAST = CFG_PARAM_FLAGS + }; + +public: + tParticleSystemData m_aParticles[MAX_PARTICLES]; + + cParticleSystemMgr() { ctor(); } void ctor(); + + void Initialise(); + void LoadParticleData(); + //void RangeCheck(tParticleSystemData *pData); +}; + +VALIDATE_SIZE(cParticleSystemMgr, 0x2420); + +extern cParticleSystemMgr mod_ParticleSystemManager; \ No newline at end of file diff --git a/src/render/Sprite.cpp b/src/render/Sprite.cpp index 509564ac..900b4dba 100644 --- a/src/render/Sprite.cpp +++ b/src/render/Sprite.cpp @@ -4,12 +4,6 @@ #include "Camera.h" #include "Sprite.h" -// Get rid of bullshit windows definitions, we're not running on an 8086 -#ifdef far -#undef far -#undef near -#endif - float &CSprite::m_f2DNearScreenZ = *(float*)0x8F1ABC; float &CSprite::m_f2DFarScreenZ = *(float*)0x8F2C94; float &CSprite::m_fRecipNearClipPlane = *(float*)0x8F5FFC; diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index 2311a75e..ff6cd0db 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -4,12 +4,6 @@ #include "Camera.h" #include "Sprite2d.h" -// Get rid of bullshit windows definitions, we're not running on an 8086 -#ifdef far -#undef far -#undef near -#endif - RwIm2DVertex *CSprite2d::maVertices = (RwIm2DVertex*)0x6E9168; float &CSprite2d::RecipNearClip = *(float*)0x880DB4; int32 &CSprite2d::mCurrentBank = *(int32*)0x8F1AF4; @@ -18,7 +12,6 @@ int32 *CSprite2d::mCurrentSprite = (int32*)0x6F4500; int32 *CSprite2d::mBankStart = (int32*)0x774BE8; RwIm2DVertex *CSprite2d::maBankVertices = (RwIm2DVertex*)0x8429F8; - void CSprite2d::SetRecipNearClip(void) { -- cgit v1.2.3