From c59957e11f7f3a7202023356f5df3944970504ff Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Sat, 23 Jul 2022 14:38:58 +1000 Subject: [PATCH] Decompile sky0f11f6ec --- src/game/propobj.c | 8 +- src/game/sky.c | 198 +++----------------------------------------- src/include/types.h | 2 +- 3 files changed, 18 insertions(+), 190 deletions(-) diff --git a/src/game/propobj.c b/src/game/propobj.c index fdb6ff8b7..7a9ba2ab5 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -13681,11 +13681,11 @@ s32 projectileLaunch(struct defaultobj *obj, struct projectile *projectile, stru s32 projectileTick(struct defaultobj *obj, bool *embedded) { struct projectile *projectile = obj->projectile; - s32 cdresult; // 600 + s32 cdresult; struct coord sp5f4; struct coord sp5e8; struct coord sp5dc; - bool result = false; // 5d8 + bool result = false; struct prop *prop = obj->prop; struct coord sp5c8; s16 sp5b8[8]; @@ -13695,12 +13695,12 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded) struct coord sp590; f32 sp58c; bool haslimitedarea; - f32 ground; // 584 + f32 ground; Mtxf sp544; Mtxf sp504; Mtxf sp4c4; Mtxf sp484; - struct pad pad; // 430 + struct pad pad; f32 dist; f32 shield; s32 i; diff --git a/src/game/sky.c b/src/game/sky.c index 8672a6a64..aea589f35 100644 --- a/src/game/sky.c +++ b/src/game/sky.c @@ -363,191 +363,19 @@ glabel var7f1b4ff8 /* f11f6e8: 00000000 */ nop ); -GLOBAL_ASM( -glabel sky0f11f6ec -.late_rodata -glabel var7f1b4ffc -.word 0x3b808081 -.text -/* f11f6ec: 27bdffe8 */ addiu $sp,$sp,-24 -/* f11f6f0: afbf0014 */ sw $ra,0x14($sp) -/* f11f6f4: afa5001c */ sw $a1,0x1c($sp) -/* f11f6f8: 0fc595f3 */ jal envGetCurrent -/* f11f6fc: afa40018 */ sw $a0,0x18($sp) -/* f11f700: 904e0008 */ lbu $t6,0x8($v0) -/* f11f704: 3c013f80 */ lui $at,0x3f80 -/* f11f708: 44818000 */ mtc1 $at,$f16 -/* f11f70c: 448e2000 */ mtc1 $t6,$f4 -/* f11f710: 3c017f1b */ lui $at,%hi(var7f1b4ffc) -/* f11f714: c4324ffc */ lwc1 $f18,%lo(var7f1b4ffc)($at) -/* f11f718: 8fa40018 */ lw $a0,0x18($sp) -/* f11f71c: 05c10005 */ bgez $t6,.L0f11f734 -/* f11f720: 468020a0 */ cvt.s.w $f2,$f4 -/* f11f724: 3c014f80 */ lui $at,0x4f80 -/* f11f728: 44813000 */ mtc1 $at,$f6 -/* f11f72c: 00000000 */ nop -/* f11f730: 46061080 */ add.s $f2,$f2,$f6 -.L0f11f734: -/* f11f734: 904f0009 */ lbu $t7,0x9($v0) -/* f11f738: 3c014f80 */ lui $at,0x4f80 -/* f11f73c: 240d00ff */ addiu $t5,$zero,0xff -/* f11f740: 448f4000 */ mtc1 $t7,$f8 -/* f11f744: 05e10004 */ bgez $t7,.L0f11f758 -/* f11f748: 46804320 */ cvt.s.w $f12,$f8 -/* f11f74c: 44815000 */ mtc1 $at,$f10 -/* f11f750: 00000000 */ nop -/* f11f754: 460a6300 */ add.s $f12,$f12,$f10 -.L0f11f758: -/* f11f758: 9058000a */ lbu $t8,0xa($v0) -/* f11f75c: 3c014f80 */ lui $at,0x4f80 -/* f11f760: c7a8001c */ lwc1 $f8,0x1c($sp) -/* f11f764: 44982000 */ mtc1 $t8,$f4 -/* f11f768: 00000000 */ nop -/* f11f76c: 468023a0 */ cvt.s.w $f14,$f4 -/* f11f770: 46121102 */ mul.s $f4,$f2,$f18 -/* f11f774: 07030005 */ bgezl $t8,.L0f11f78c -/* f11f778: 46048181 */ sub.s $f6,$f16,$f4 -/* f11f77c: 44813000 */ mtc1 $at,$f6 -/* f11f780: 00000000 */ nop -/* f11f784: 46067380 */ add.s $f14,$f14,$f6 -/* f11f788: 46048181 */ sub.s $f6,$f16,$f4 -.L0f11f78c: -/* f11f78c: c44a0034 */ lwc1 $f10,0x34($v0) -/* f11f790: 24080001 */ addiu $t0,$zero,0x1 -/* f11f794: 46088001 */ sub.s $f0,$f16,$f8 -/* f11f798: 46065202 */ mul.s $f8,$f10,$f6 -/* f11f79c: 3c014f00 */ lui $at,0x4f00 -/* f11f7a0: 46004102 */ mul.s $f4,$f8,$f0 -/* f11f7a4: 46022280 */ add.s $f10,$f4,$f2 -/* f11f7a8: 4459f800 */ cfc1 $t9,$31 -/* f11f7ac: 44c8f800 */ ctc1 $t0,$31 -/* f11f7b0: 00000000 */ nop -/* f11f7b4: 460051a4 */ cvt.w.s $f6,$f10 -/* f11f7b8: 4448f800 */ cfc1 $t0,$31 -/* f11f7bc: 00000000 */ nop -/* f11f7c0: 31080078 */ andi $t0,$t0,0x78 -/* f11f7c4: 51000013 */ beqzl $t0,.L0f11f814 -/* f11f7c8: 44083000 */ mfc1 $t0,$f6 -/* f11f7cc: 44813000 */ mtc1 $at,$f6 -/* f11f7d0: 24080001 */ addiu $t0,$zero,0x1 -/* f11f7d4: 46065181 */ sub.s $f6,$f10,$f6 -/* f11f7d8: 44c8f800 */ ctc1 $t0,$31 -/* f11f7dc: 00000000 */ nop -/* f11f7e0: 460031a4 */ cvt.w.s $f6,$f6 -/* f11f7e4: 4448f800 */ cfc1 $t0,$31 -/* f11f7e8: 00000000 */ nop -/* f11f7ec: 31080078 */ andi $t0,$t0,0x78 -/* f11f7f0: 15000005 */ bnez $t0,.L0f11f808 -/* f11f7f4: 00000000 */ nop -/* f11f7f8: 44083000 */ mfc1 $t0,$f6 -/* f11f7fc: 3c018000 */ lui $at,0x8000 -/* f11f800: 10000007 */ b .L0f11f820 -/* f11f804: 01014025 */ or $t0,$t0,$at -.L0f11f808: -/* f11f808: 10000005 */ b .L0f11f820 -/* f11f80c: 2408ffff */ addiu $t0,$zero,-1 -/* f11f810: 44083000 */ mfc1 $t0,$f6 -.L0f11f814: -/* f11f814: 00000000 */ nop -/* f11f818: 0500fffb */ bltz $t0,.L0f11f808 -/* f11f81c: 00000000 */ nop -.L0f11f820: -/* f11f820: 44d9f800 */ ctc1 $t9,$31 -/* f11f824: a0880014 */ sb $t0,0x14($a0) -/* f11f828: c4480038 */ lwc1 $f8,0x38($v0) -/* f11f82c: 46126102 */ mul.s $f4,$f12,$f18 -/* f11f830: 240a0001 */ addiu $t2,$zero,0x1 -/* f11f834: 3c014f00 */ lui $at,0x4f00 -/* f11f838: 46048281 */ sub.s $f10,$f16,$f4 -/* f11f83c: 460a4182 */ mul.s $f6,$f8,$f10 -/* f11f840: 00000000 */ nop -/* f11f844: 46003102 */ mul.s $f4,$f6,$f0 -/* f11f848: 460c2200 */ add.s $f8,$f4,$f12 -/* f11f84c: 4449f800 */ cfc1 $t1,$31 -/* f11f850: 44caf800 */ ctc1 $t2,$31 -/* f11f854: 00000000 */ nop -/* f11f858: 460042a4 */ cvt.w.s $f10,$f8 -/* f11f85c: 444af800 */ cfc1 $t2,$31 -/* f11f860: 00000000 */ nop -/* f11f864: 314a0078 */ andi $t2,$t2,0x78 -/* f11f868: 11400012 */ beqz $t2,.L0f11f8b4 -/* f11f86c: 00000000 */ nop -/* f11f870: 44815000 */ mtc1 $at,$f10 -/* f11f874: 240a0001 */ addiu $t2,$zero,0x1 -/* f11f878: 460a4281 */ sub.s $f10,$f8,$f10 -/* f11f87c: 44caf800 */ ctc1 $t2,$31 -/* f11f880: 00000000 */ nop -/* f11f884: 460052a4 */ cvt.w.s $f10,$f10 -/* f11f888: 444af800 */ cfc1 $t2,$31 -/* f11f88c: 00000000 */ nop -/* f11f890: 314a0078 */ andi $t2,$t2,0x78 -/* f11f894: 15400005 */ bnez $t2,.L0f11f8ac -/* f11f898: 00000000 */ nop -/* f11f89c: 440a5000 */ mfc1 $t2,$f10 -/* f11f8a0: 3c018000 */ lui $at,0x8000 -/* f11f8a4: 10000007 */ b .L0f11f8c4 -/* f11f8a8: 01415025 */ or $t2,$t2,$at -.L0f11f8ac: -/* f11f8ac: 10000005 */ b .L0f11f8c4 -/* f11f8b0: 240affff */ addiu $t2,$zero,-1 -.L0f11f8b4: -/* f11f8b4: 440a5000 */ mfc1 $t2,$f10 -/* f11f8b8: 00000000 */ nop -/* f11f8bc: 0540fffb */ bltz $t2,.L0f11f8ac -/* f11f8c0: 00000000 */ nop -.L0f11f8c4: -/* f11f8c4: 44c9f800 */ ctc1 $t1,$31 -/* f11f8c8: a08a0015 */ sb $t2,0x15($a0) -/* f11f8cc: c446003c */ lwc1 $f6,0x3c($v0) -/* f11f8d0: 46127102 */ mul.s $f4,$f14,$f18 -/* f11f8d4: 240c0001 */ addiu $t4,$zero,0x1 -/* f11f8d8: 3c014f00 */ lui $at,0x4f00 -/* f11f8dc: 46048201 */ sub.s $f8,$f16,$f4 -/* f11f8e0: 46083282 */ mul.s $f10,$f6,$f8 -/* f11f8e4: 00000000 */ nop -/* f11f8e8: 46005102 */ mul.s $f4,$f10,$f0 -/* f11f8ec: 460e2180 */ add.s $f6,$f4,$f14 -/* f11f8f0: 444bf800 */ cfc1 $t3,$31 -/* f11f8f4: 44ccf800 */ ctc1 $t4,$31 -/* f11f8f8: 00000000 */ nop -/* f11f8fc: 46003224 */ cvt.w.s $f8,$f6 -/* f11f900: 444cf800 */ cfc1 $t4,$31 -/* f11f904: 00000000 */ nop -/* f11f908: 318c0078 */ andi $t4,$t4,0x78 -/* f11f90c: 11800012 */ beqz $t4,.L0f11f958 -/* f11f910: 00000000 */ nop -/* f11f914: 44814000 */ mtc1 $at,$f8 -/* f11f918: 240c0001 */ addiu $t4,$zero,0x1 -/* f11f91c: 46083201 */ sub.s $f8,$f6,$f8 -/* f11f920: 44ccf800 */ ctc1 $t4,$31 -/* f11f924: 00000000 */ nop -/* f11f928: 46004224 */ cvt.w.s $f8,$f8 -/* f11f92c: 444cf800 */ cfc1 $t4,$31 -/* f11f930: 00000000 */ nop -/* f11f934: 318c0078 */ andi $t4,$t4,0x78 -/* f11f938: 15800005 */ bnez $t4,.L0f11f950 -/* f11f93c: 00000000 */ nop -/* f11f940: 440c4000 */ mfc1 $t4,$f8 -/* f11f944: 3c018000 */ lui $at,0x8000 -/* f11f948: 10000007 */ b .L0f11f968 -/* f11f94c: 01816025 */ or $t4,$t4,$at -.L0f11f950: -/* f11f950: 10000005 */ b .L0f11f968 -/* f11f954: 240cffff */ addiu $t4,$zero,-1 -.L0f11f958: -/* f11f958: 440c4000 */ mfc1 $t4,$f8 -/* f11f95c: 00000000 */ nop -/* f11f960: 0580fffb */ bltz $t4,.L0f11f950 -/* f11f964: 00000000 */ nop -.L0f11f968: -/* f11f968: a08c0016 */ sb $t4,0x16($a0) -/* f11f96c: a08d0017 */ sb $t5,0x17($a0) -/* f11f970: 8fbf0014 */ lw $ra,0x14($sp) -/* f11f974: 44cbf800 */ ctc1 $t3,$31 -/* f11f978: 27bd0018 */ addiu $sp,$sp,0x18 -/* f11f97c: 03e00008 */ jr $ra -/* f11f980: 00000000 */ nop -); +void sky0f11f6ec(struct skything18 *arg0, f32 arg1) +{ + struct environment *env = envGetCurrent(); + f32 scale = 1.0f - arg1; + f32 r = env->sky_r; + f32 g = env->sky_g; + f32 b = env->sky_b; + + arg0->colour.r = r + env->water_r * (1.0f - r * (1.0f / 255.0f)) * scale; + arg0->colour.g = g + env->water_g * (1.0f - g * (1.0f / 255.0f)) * scale; + arg0->colour.b = b + env->water_b * (1.0f - b * (1.0f / 255.0f)) * scale; + arg0->colour.a = 0xff; +} Gfx *skyRender(Gfx *gdl) { diff --git a/src/include/types.h b/src/include/types.h index 0b1ceff56..e5586409d 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -6291,7 +6291,7 @@ struct skything18 { /*0x08*/ f32 unk08; /*0x0c*/ f32 unk0c; /*0x10*/ f32 unk10; - /*0x14*/ u32 unk14; + /*0x14*/ struct colour colour; }; struct skything38 {