weather.c moment (#450)

* strings

* fix ub

* first pass

* pass 2

* pass 3

* pass 4

* pass 5

* pass 6

* pass 7

* pass 8

* pass 9

* pass 10

* pass 11

* pass 11

* pass 12

* pass 13

* pass 13

* pass 14

* pass 15

* pass 16

* pass 17

* oh my giddy aunt I see the light

* h

* fix my life choices

* fix game breaking typo

* :)

* weather.c pain

* Update src/menu.c

Co-authored-by: Ryan Myers <ryan.p.myers@gmail.com>

* Update src/menu.c

Co-authored-by: Ryan Myers <ryan.p.myers@gmail.com>

* Update menu.c

---------

Co-authored-by: Ryan Myers <ryan.p.myers@gmail.com>
This commit is contained in:
Fazana
2024-07-05 14:02:23 +01:00
committed by GitHub
co-authored by Ryan Myers
parent 188630883e
commit 71181a801b
11 changed files with 664 additions and 622 deletions
+10 -10
View File
@@ -57,8 +57,8 @@ glabel render_rain_overlay
/* 0AE998 800ADD98 03196824 */ and $t5, $t8, $t9
/* 0AE99C 800ADD9C 86180006 */ lh $t8, 6($s0)
/* 0AE9A0 800ADDA0 A60D0002 */ sh $t5, 2($s0)
/* 0AE9A4 800ADDA4 3C0D800E */ lui $t5, %hi(D_800E2C6C) # $t5, 0x800e
/* 0AE9A8 800ADDA8 8DAD2C6C */ lw $t5, %lo(D_800E2C6C)($t5)
/* 0AE9A4 800ADDA4 3C0D800E */ lui $t5, %hi(gRainOpacity) # $t5, 0x800e
/* 0AE9A8 800ADDA8 8DAD2C6C */ lw $t5, %lo(gRainOpacity)($t5)
/* 0AE9AC 800ADDAC 3C028012 */ lui $v0, %hi(gWeatherCamera) # $v0, 0x8012
/* 0AE9B0 800ADDB0 000D7083 */ sra $t6, $t5, 2
/* 0AE9B4 800ADDB4 00008812 */ mflo $s1
@@ -125,18 +125,18 @@ glabel render_rain_overlay
/* 0AEAA8 800ADEA8 35C10003 */ ori $at, $t6, 3
/* 0AEAAC 800ADEAC 38210002 */ xori $at, $at, 2
/* 0AEAB0 800ADEB0 44C1F800 */ ctc1 $at, $31
/* 0AEAB4 800ADEB4 3C09800E */ lui $t1, %hi(D_800E2C90) # $t1, 0x800e
/* 0AEAB4 800ADEB4 3C09800E */ lui $t1, %hi(gRainVertexFlip) # $t1, 0x800e
/* 0AEAB8 800ADEB8 460042A4 */ cvt.w.s $f10, $f8
/* 0AEABC 800ADEBC 25292C90 */ addiu $t1, %lo(D_800E2C90) # addiu $t1, $t1, 0x2c90
/* 0AEABC 800ADEBC 25292C90 */ addiu $t1, %lo(gRainVertexFlip) # addiu $t1, $t1, 0x2c90
/* 0AEAC0 800ADEC0 44CEF800 */ ctc1 $t6, $31
/* 0AEAC4 800ADEC4 440F5000 */ mfc1 $t7, $f10
/* 0AEAC8 800ADEC8 46026102 */ mul.s $f4, $f12, $f2
/* 0AEACC 800ADECC 8D2D0000 */ lw $t5, ($t1)
/* 0AEAD0 800ADED0 3C0B800E */ lui $t3, %hi(D_800E2AAC) # $t3, 0x800e
/* 0AEAD0 800ADED0 3C0B800E */ lui $t3, %hi(gRainVertices) # $t3, 0x800e
/* 0AEAD4 800ADED4 000DC880 */ sll $t9, $t5, 2
/* 0AEAD8 800ADED8 46007182 */ mul.s $f6, $f14, $f0
/* 0AEADC 800ADEDC 032DC821 */ addu $t9, $t9, $t5
/* 0AEAE0 800ADEE0 256B2AAC */ addiu $t3, %lo(D_800E2AAC) # addiu $t3, $t3, 0x2aac
/* 0AEAE0 800ADEE0 256B2AAC */ addiu $t3, %lo(gRainVertices) # addiu $t3, $t3, 0x2aac
/* 0AEAE4 800ADEE4 0019C840 */ sll $t9, $t9, 1
/* 0AEAE8 800ADEE8 46062200 */ add.s $f8, $f4, $f6
/* 0AEAEC 800ADEEC 01791021 */ addu $v0, $t3, $t9
@@ -291,16 +291,16 @@ glabel render_rain_overlay
/* 0AED40 800AE140 AC780000 */ sw $t8, ($v1)
/* 0AED44 800AE144 8E6E000C */ lw $t6, 0xc($s3)
/* 0AED48 800AE148 3C088000 */ lui $t0, 0x8000
/* 0AED4C 800AE14C 3C09800E */ lui $t1, %hi(D_800E2C90) # $t1, 0x800e
/* 0AED4C 800AE14C 3C09800E */ lui $t1, %hi(gRainVertexFlip) # $t1, 0x800e
/* 0AED50 800AE150 01C8C821 */ addu $t9, $t6, $t0
/* 0AED54 800AE154 25292C90 */ addiu $t1, %lo(D_800E2C90) # addiu $t1, $t1, 0x2c90
/* 0AED54 800AE154 25292C90 */ addiu $t1, %lo(gRainVertexFlip) # addiu $t1, $t1, 0x2c90
/* 0AED58 800AE158 AC790004 */ sw $t9, 4($v1)
/* 0AED5C 800AE15C 8D380000 */ lw $t8, ($t1)
/* 0AED60 800AE160 240A000A */ li $t2, 10
/* 0AED64 800AE164 030A0019 */ multu $t8, $t2
/* 0AED68 800AE168 8FA50068 */ lw $a1, 0x68($sp)
/* 0AED6C 800AE16C 3C0B800E */ lui $t3, %hi(D_800E2AAC) # $t3, 0x800e
/* 0AED70 800AE170 256B2AAC */ addiu $t3, %lo(D_800E2AAC) # addiu $t3, $t3, 0x2aac
/* 0AED6C 800AE16C 3C0B800E */ lui $t3, %hi(gRainVertices) # $t3, 0x800e
/* 0AED70 800AE170 256B2AAC */ addiu $t3, %lo(gRainVertices) # addiu $t3, $t3, 0x2aac
/* 0AED74 800AE174 24AF0008 */ addiu $t7, $a1, 8
/* 0AED78 800AE178 AFAF0068 */ sw $t7, 0x68($sp)
/* 0AED7C 800AE17C 3C010400 */ lui $at, 0x400
+1 -1
View File
@@ -452,7 +452,7 @@ typedef struct LevelHeader {
/* 0x74 */ LevelHeader_70 *unk74[7];
// Weather related?
/* 0x90 */ s16 weatherEnable;
/* 0x90 */ s16 weatherEnable; // This affects snow density, but for rain, it simply needs to be nonzero.
/* 0x92 */ s16 weatherType;
/* 0x94 */ u8 weatherIntensity;
/* 0x95 */ u8 weatherOpacity;
+3 -3
View File
@@ -591,11 +591,11 @@ void load_level(s32 levelId, s32 numberOfPlayers, s32 entranceId, Vehicle vehicl
}
settings->courseId = levelId;
if (gCurrentLevelHeader->weatherEnable > 0) {
func_800AB4A8(gCurrentLevelHeader->weatherType, gCurrentLevelHeader->weatherEnable,
weather_reset(gCurrentLevelHeader->weatherType, gCurrentLevelHeader->weatherEnable,
gCurrentLevelHeader->weatherVelX << 8, gCurrentLevelHeader->weatherVelY << 8,
gCurrentLevelHeader->weatherVelZ << 8, gCurrentLevelHeader->weatherIntensity * 257,
gCurrentLevelHeader->weatherOpacity * 257);
set_weather_limits(-1, -512);
weather_clip_planes(-1, -512);
}
if (gCurrentLevelHeader->skyDome == -1) {
gCurrentLevelHeader->unkA4 = load_texture((s32) gCurrentLevelHeader->unkA4);
@@ -709,7 +709,7 @@ void clear_audio_and_track(void) {
func_80008174();
sound_volume_change(VOLUME_NORMAL);
if (gCurrentLevelHeader->weatherEnable > 0) {
free_weather_memory();
weather_free();
}
//! @bug this will never be true because skyDome is signed.
if (gCurrentLevelHeader->skyDome == 0xFF) {
+183 -179
View File
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -390,7 +390,7 @@ typedef struct MenuColour {
// Unknown Size
typedef struct unk80126A80 {
u8 pad0[0x13];
s8 unk13;
s8 highlight;
} unk80126A80;
/* Size: 0x10 bytes */
@@ -635,7 +635,7 @@ void menu_element_render(s32 elementID);
void menu_input(void);
SIDeviceStatus savemenu_load_sources(void);
void menu_asset_load(s32 arg0);
s32 func_80087734(s32 buttonsPressed, s32 yAxis);
s32 savemenu_input_message(s32 buttonsPressed, s32 yAxis);
void savemenu_render_element(SaveFileData *arg0, s32 x, s32 y);
void trackmenu_render_2D(s32 x, s32 y, char *hubName, char *trackName, s32 rectOpacity, s32 imageId, s32 copyViewPort, DrawTexture *arg7, s32 arg8);
void pausemenu_render(UNUSED s32 updateRate);
+2 -2
View File
@@ -5621,8 +5621,8 @@ void obj_loop_weather(Object *obj, UNUSED s32 updateRate) {
if ((diffX * diffX) + (diffZ * diffZ) <= dist) {
if (((!obj->segment.level_entry) && (!obj->segment.level_entry)) && (!obj->segment.level_entry)) {
} // Fakematch
changeWeather(entry->unkA * 256, entry->unkC * 256, entry->unkE * 256, entry->unk10 * 257,
entry->unk11 * 257, entry->unk12);
weather_set(entry->unkA * 256, entry->unkC * 256, entry->unkE * 256, entry->unk10 * 257, entry->unk11 * 257,
entry->unk12);
}
}
}
+1 -1
View File
@@ -210,7 +210,7 @@ void init_game(void) {
debug_text_init();
allocate_ghost_data();
init_particle_assets();
init_weather();
weather_init();
calc_and_alloc_heap_for_settings();
default_alloc_displaylist_heap();
load_fonts();
+5 -5
View File
@@ -344,7 +344,7 @@ void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, TriangleList **tris,
gDPSetBlendColor(gSceneCurrDisplayList++, 0, 0, 0, 0x64);
gDPSetPrimColor(gSceneCurrDisplayList++, 0, 0, 255, 255, 255, 255);
gDPSetEnvColor(gSceneCurrDisplayList++, 255, 255, 255, 0);
func_800AD40C();
rain_fog();
update_fog(numViewports, tempUpdateRate);
func_800AF404(tempUpdateRate);
if (gCurrentLevelModel->numberOfAnimatedTextures > 0) {
@@ -381,11 +381,11 @@ void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, TriangleList **tris,
}
gDPPipeSync(gSceneCurrDisplayList++);
initialise_player_viewport_vars(updateRate);
set_weather_limits(-1, -512);
weather_clip_planes(-1, -512);
// Show weather effects in single player.
if (gCurrentLevelHeader2->weatherEnable > 0 && numViewports < 2) {
process_weather(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, &gSceneCurrTriList,
tempUpdateRate);
weather_update(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, &gSceneCurrTriList,
tempUpdateRate);
}
lensflare_override(get_active_camera_segment());
lensflare_render(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList, get_active_camera_segment());
@@ -413,7 +413,7 @@ void render_scene(Gfx **dList, MatrixS **mtx, Vertex **vtx, TriangleList **tris,
matrix_world_origin(&gSceneCurrDisplayList, &gSceneCurrMatrix);
gDPPipeSync(gSceneCurrDisplayList++);
initialise_player_viewport_vars(updateRate);
set_weather_limits(-1, -512);
weather_clip_planes(-1, -512);
lensflare_override(get_active_camera_segment());
lensflare_render(&gSceneCurrDisplayList, &gSceneCurrMatrix, &gSceneCurrVertexList,
get_active_camera_segment());
+384 -334
View File
File diff suppressed because it is too large Load Diff
+72 -84
View File
@@ -7,32 +7,25 @@
typedef enum WeatherType {
WEATHER_SNOW,
WEATHER_RAIN,
WEATHER_UNK2
WEATHER_RAIN
} WeatherType;
typedef struct unk800E2850_unk0 {
s32 unk0;
s32 unk4;
s32 unk8;
} unk800E2850_unk0;
/* Size: 0x2C Bytes */
typedef struct unk800E2850 {
unk800E2850_unk0 *unk0;
s32 unk4;
TextureHeader *unk8;
s32 unkC;
s32 unk10;
s32 unk14;
s32 unk18;
s32 unk1C;
s32 unk20;
s16 unk24;
s16 unk26;
s16 unk28;
s16 unk2A;
} unk800E2850;
typedef struct SnowGfxData {
Vec3i *pos;
s32 size;
TextureHeader *texture;
s32 offsetX;
s32 offsetY;
s32 offsetZ;
s32 radiusX;
s32 radiusY;
s32 radiusZ;
s16 vertOffsetW;
s16 vertOffsetH;
s16 vertWidth;
s16 vertHeight;
} SnowGfxData;
/* Size: 0x10 Bytes */
typedef struct LensFlareData {
@@ -43,14 +36,14 @@ typedef struct LensFlareData {
} LensFlareData;
/* Size: 0x1C Bytes */
typedef struct ObjectSegment2 {
typedef struct RainPosData {
ObjectTransform trans;
s16 animFrame;
s16 unk1A;
} ObjectSegment2;
s16 opacity;
} RainPosData;
/* Size: 0x18 Bytes */
typedef struct unk800E2C2C {
typedef struct RainGfxData {
s16 unk0; //tri - u?
s16 unk2; //tri - v?
s16 unk4;
@@ -64,73 +57,68 @@ typedef struct unk800E2C2C {
u8 environmentRed;
u8 environmentGreen;
u8 environmentBlue;
u8 unk16;
u8 unk17;
} unk800E2C2C;
u8 opacity;
// pad
} RainGfxData;
typedef struct {
s16 unk0;
s16 unk2;
//s16 unk4;
s32 unk4;
} unk80127BF8;
s16 near;
s16 far;
s32 current;
} SnowLimits;
typedef struct unk800E28D4 {
s32 unk0;
s32 unk4;
s32 unk8;
u8 unkC;
u8 unkD;
u8 unkE;
u8 unkF;
} unk800E28D4;
typedef struct SnowPosData {
s32 x_position;
s32 y_position;
s32 z_position;
u8 unused_C;
u8 unused_D;
u8 unused_E;
u8 index;
} SnowPosData;
typedef struct RainData {
s32 unk0;
s32 unk4;
s32 unk8;
s32 unkC;
s32 unk10;
s32 unk14;
s32 unk18;
s32 unk1C;
s32 unk20;
s32 unk24;
s32 unk28;
s32 unk2C;
s32 unk30;
s32 unk34;
s32 unk38;
s32 unk3C;
} RainData;
typedef struct WeatherData {
s32 intensity;
s32 intensityStep;
s32 intensityTarget;
s32 velX;
s32 velXStep;
s32 velXTarget;
s32 velY;
s32 velYStep;
s32 velYTarget;
s32 velZ;
s32 velZStep;
s32 velZTarget;
s32 opacity;
s32 opacityStep;
s32 opacityTarget;
s32 shiftTime;
} WeatherData;
void set_weather_limits(s16 arg0, s16 arg1);
void weather_clip_planes(s16 arg0, s16 arg1);
void lensflare_remove(Object *obj);
void lensflare_override_add(Object *obj);
void free_rain_memory(void);
void func_800AD2C4(s32 arg0, s32 arg1, f32 arg2);
void func_800AD40C(void);
void handle_weather_rain(s32 updateRate);
void handle_rain_sound(s32 updateRate);
void render_rain_splashes(s32 updateRate);
void handle_rain_lightning(s32 updateRate);
void render_rain_overlay(unk800E2C2C*, s32);
void process_weather(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, TriangleList **currHudTris, s32 updateRate);
void render_falling_snow(void);
void free_weather_memory(void);
void changeWeather(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5);
void rain_set(s32 arg0, s32 arg1, f32 arg2);
void rain_fog(void);
void rain_update(s32 updateRate);
void rain_sound(s32 updateRate);
void rain_render_splashes(s32 updateRate);
void rain_lightning(s32 updateRate);
void render_rain_overlay(RainGfxData*, s32);
void weather_update(Gfx **currDisplayList, MatrixS **currHudMat, Vertex **currHudVerts, TriangleList **currHudTris, s32 updateRate);
void snow_render(void);
void weather_free(void);
void weather_set(s32 arg0, s32 arg1, s32 arg2, s32 arg3, s32 arg4, s32 arg5);
void lensflare_override(ObjectSegment *cameraSegment);
void func_800AC0C8(s32 updateRate);
void func_800ABB34(void);
void func_800AD144(s32 arg0, s32 arg1);
s32 coss(s16);
s32 sins(s16);
void init_weather(void);
void f32_matrix_dot(Matrix *arg0, Matrix *arg1, Matrix *arg2);
void func_800AC21C(void);
void snow_update(s32 updateRate);
void snow_init(void);
void rain_init(s32 arg0, s32 arg1);
void weather_init(void);
void snow_vertices(void);
void lensflare_init(Object *);
void lensflare_render(Gfx**, MatrixS**, Vertex**, ObjectSegment*);
void func_800AB4A8(s32 weatherType, s32 weatherEnable, s32 velX, s32 velY, s32 velZ, s32 intensity, s32 opacity);
void weather_reset(s32 weatherType, s32 weatherEnable, s32 velX, s32 velY, s32 velZ, s32 intensity, s32 opacity);
#endif