From 2d2037667f87f4a8273333b8b09785a99bc8c7eb Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Tue, 8 Feb 2022 20:14:34 +1000 Subject: [PATCH] Attempt to decompile wallhitRenderBgHitsLayer1 --- src/game/bg.c | 4 +- src/game/chr/chr.c | 6 +- src/game/game_013550.c | 4 +- src/game/lv.c | 6 +- src/game/prop.c | 6 +- src/game/propobj.c | 26 ++--- src/game/training/training.c | 4 +- src/game/wallhit.c | 171 +++++++++++++++++++++++---------- src/include/bss.h | 4 +- src/include/game/game_0b3350.h | 2 +- src/include/game/wallhit.h | 18 ++-- src/include/types.h | 49 ++++------ 12 files changed, 179 insertions(+), 121 deletions(-) diff --git a/src/game/bg.c b/src/game/bg.c index 510894738..21c415d70 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -2742,7 +2742,7 @@ Gfx *bgRenderScene(Gfx *gdl) if (getVar80084040() && g_Vars.currentplayer->visionmode != VISIONMODE_XRAY) { for (i = 0; i < var8007fc2c; i++) { roomnum = roomnums[i]; - gdl = wallhitsRender(var800a4640.unk000[roomnum].roomnum, gdl); + gdl = wallhitRenderBgHits(var800a4640.unk000[roomnum].roomnum, gdl); } } @@ -3359,7 +3359,7 @@ glabel bgRenderScene /* f155548: 01926023 */ subu $t4,$t4,$s2 /* f15554c: 000c6080 */ sll $t4,$t4,0x2 /* f155550: 008c2021 */ addu $a0,$a0,$t4 -/* f155554: 0fc4ef16 */ jal wallhitsRender +/* f155554: 0fc4ef16 */ jal wallhitRenderBgHits /* f155558: 84848dc0 */ lh $a0,-0x7240($a0) /* f15555c: 3c0d8008 */ lui $t5,0x8008 /* f155560: 8dad2490 */ lw $t5,0x2490($t5) diff --git a/src/game/chr/chr.c b/src/game/chr/chr.c index bd3c6dd47..5842ee3af 100644 --- a/src/game/chr/chr.c +++ b/src/game/chr/chr.c @@ -8140,7 +8140,7 @@ void chrRenderAttachedObject(struct prop *prop, struct modelrenderdata *renderda // Note: OBJH2FLAG_RENDEROPAQUE << 1 is OBJH2FLAG_RENDERALPHA // so this is just checking if the appropriate flag is enabled if (obj->hidden2 & OBJH2FLAG_RENDEROPAQUE << withalpha) { - renderdata->gdl = func0f140e20(renderdata->gdl, prop, withalpha); + renderdata->gdl = wallhitRenderPropHits(renderdata->gdl, prop, withalpha); } child = prop->child; @@ -10172,7 +10172,7 @@ void chrHit(struct shotdata *shotdata, struct hit *hit) if (type->num04 > 0) { index = random() % type->num04; - func0f13f3f4( + wallhitCreate( &hit->hitthing.unk00, &hit->hitthing.unk0c, &shotdata->gunpos, @@ -10208,7 +10208,7 @@ void chrHit(struct shotdata *shotdata, struct hit *hit) index = random() % type->num04; - func0f13f3f4( + wallhitCreate( &hit->hitthing.unk00, &hit->hitthing.unk0c, &shotdata->gunpos, diff --git a/src/game/game_013550.c b/src/game/game_013550.c index bbe87cb97..935ecbed7 100644 --- a/src/game/game_013550.c +++ b/src/game/game_013550.c @@ -100,7 +100,7 @@ void func0f013550(void) u32 structssize; void *ptr; - structssize = var8009cc44 * sizeof(struct var800a41b0); + structssize = var8009cc44 * sizeof(struct wallhit); structssize += 0xf; structssize &= ~0xf; @@ -111,7 +111,7 @@ void func0f013550(void) ptr = mempAlloc(structssize + numberssize, MEMPOOL_STAGE); var8009cc40 = ptr; - var800a41b0 = (struct var800a41b0 *)((u32)ptr + numberssize); + var800a41b0 = (struct wallhit *)((u32)ptr + numberssize); var800a41b4 = NULL; var800a41b8 = 0; diff --git a/src/game/lv.c b/src/game/lv.c index 8897099c2..2d145cbdf 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -7722,7 +7722,7 @@ glabel var7f1b8ed0pf /* f16d7e0: 00000000 */ nop /* f16d7e4: 0fc0785c */ jal sparksTick /* f16d7e8: 00000000 */ nop -/* f16d7ec: 0fc4fdad */ jal func0f13eb44 +/* f16d7ec: 0fc4fdad */ jal wallhitsTick /* f16d7f0: 00000000 */ nop /* f16d7f4: 0fc52945 */ jal func0f149864 /* f16d7f8: 00000000 */ nop @@ -8118,7 +8118,7 @@ void lvTick(void) casingsTick(); shardsTick(); sparksTick(); - func0f13eb44(); + wallhitsTick(); func0f149864(); if (g_WeatherActive) { @@ -9324,7 +9324,7 @@ glabel lvTick /* f16774c: 00000000 */ sll $zero,$zero,0x0 /* f167750: 0fc0774c */ jal sparksTick /* f167754: 00000000 */ sll $zero,$zero,0x0 -/* f167758: 0fc4e591 */ jal func0f13eb44 +/* f167758: 0fc4e591 */ jal wallhitsTick /* f16775c: 00000000 */ sll $zero,$zero,0x0 /* f167760: 0fc5100d */ jal func0f149864 /* f167764: 00000000 */ sll $zero,$zero,0x0 diff --git a/src/game/prop.c b/src/game/prop.c index 720db2402..4fddc2b55 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -162,8 +162,8 @@ struct prop *propAllocate(void) prop->lastupdateframe = 0xffff; prop->propupdate240 = 0; prop->propupdate60err = 2; - prop->unk40 = 0; - prop->unk44 = 0; + prop->wallhits1 = NULL; + prop->wallhits2 = NULL; g_Vars.propstates[prop->propstateindex].propcount++; g_Vars.allocstateindex++; @@ -841,7 +841,7 @@ struct prop *shotCalculateHits(s32 handnum, bool arg1, struct coord *arg2, struc } if (uVar6) { - func0f13f3f4(&sp694.unk00, &sp694.unk0c, &shotdata.gunpos, 0, 0, uVar6, room, 0, -1, 0, g_Vars.currentplayer->prop->chr, sp694.unk2c == 2); + wallhitCreate(&sp694.unk00, &sp694.unk0c, &shotdata.gunpos, 0, 0, uVar6, room, 0, -1, 0, g_Vars.currentplayer->prop->chr, sp694.unk2c == 2); } } diff --git a/src/game/propobj.c b/src/game/propobj.c index 4ba1d3810..cdab1ef1e 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -6059,8 +6059,8 @@ void objFree(struct defaultobj *obj, bool freeprop, bool canregen) chrClearReferences(obj->prop - g_Vars.props); projectilesUnrefOwner(obj->prop); - func0f13e40c(obj->prop, 0); - func0f13e40c(obj->prop, 1); + wallhitsRemoveByProp(obj->prop, 0); + wallhitsRemoveByProp(obj->prop, 1); func0f06ac90(obj->prop); child = obj->prop->child; @@ -52063,7 +52063,7 @@ void objRenderProp(struct prop *prop, struct modelrenderdata *renderdata, bool w } if (obj->hidden2 & (OBJH2FLAG_RENDEROPAQUE << withalpha)) { - gdl = func0f140e20(gdl, prop, withalpha); + gdl = wallhitRenderPropHits(gdl, prop, withalpha); } if (sp6c) { @@ -53906,7 +53906,7 @@ glabel var7f1aa838 /* f081d70: 8fa800d0 */ lw $t0,0xd0($sp) /* f081d74: 24050001 */ addiu $a1,$zero,0x1 /* f081d78: 8d040014 */ lw $a0,0x14($t0) -/* f081d7c: 0fc4f903 */ jal func0f13e40c +/* f081d7c: 0fc4f903 */ jal wallhitsRemoveByProp /* f081d80: e7b000bc */ swc1 $f16,0xbc($sp) /* f081d84: 24090001 */ addiu $t1,$zero,0x1 /* f081d88: c7b000bc */ lwc1 $f16,0xbc($sp) @@ -54614,7 +54614,7 @@ glabel var7f1aa838 /* f0807dc: 8fa800d8 */ lw $t0,0xd8($sp) .NB0f0807e0: /* f0807e0: 24050001 */ addiu $a1,$zero,0x1 -/* f0807e4: 0fc4e3c3 */ jal func0f13e40c +/* f0807e4: 0fc4e3c3 */ jal wallhitsRemoveByProp /* f0807e8: 8d040014 */ lw $a0,0x14($t0) /* f0807ec: 24090001 */ addiu $t1,$zero,0x1 /* f0807f0: afa00088 */ sw $zero,0x88($sp) @@ -58733,8 +58733,8 @@ void glassDestroy(struct defaultobj *obj) struct prop *prop = obj->prop; struct modelrodata_bbox *bbox = objFindBboxRodata(obj); - func0f13e40c(prop, 0); - func0f13e40c(prop, 1); + wallhitsRemoveByProp(prop, 0); + wallhitsRemoveByProp(prop, 1); if (obj->modelnum == MODEL_AIVILLABOT1 || obj->modelnum == MODEL_AIVILLABOT2 @@ -58796,7 +58796,7 @@ void doorDestroyGlass(struct doorobj *door) shardsCreate((struct coord *) &matrix.m[3][0], &matrix.m[0][0], &matrix.m[1][0], &matrix.m[2][0], rodata->bbox.xmin, rodata->bbox.xmax, rodata->bbox.ymin, rodata->bbox.ymax, SHARDTYPE_GLASS, prop); - func0f13e40c(prop, 1); + wallhitsRemoveByProp(prop, 1); node = modelGetPart(model->filedata, 1); rwdata = modelGetNodeRwData(model, node); @@ -58822,7 +58822,7 @@ void func0f084f64(struct defaultobj *obj) SHARDTYPE_GLASS, prop); } - func0f13e40c(prop, 1); + wallhitsRemoveByProp(prop, 1); rwdata = modelGetNodeRwData(model, modelGetPart(model->filedata, 3)); rwdata->toggle.visible = false; } @@ -59655,7 +59655,7 @@ glabel objHit /* f0863d0: 27240010 */ addiu $a0,$t9,0x10 /* f0863d4: 2725001c */ addiu $a1,$t9,0x1c /* f0863d8: 24c6001c */ addiu $a2,$a2,0x1c -/* f0863dc: 0fc4fcfd */ jal func0f13f3f4 +/* f0863dc: 0fc4fcfd */ jal wallhitCreate /* f0863e0: afad0028 */ sw $t5,0x28($sp) /* f0863e4: 10000078 */ b .L0f0865c8 /* f0863e8: 8fa80124 */ lw $t0,0x124($sp) @@ -59787,7 +59787,7 @@ glabel objHit /* f0865b0: 2585001c */ addiu $a1,$t4,0x1c /* f0865b4: afad002c */ sw $t5,0x2c($sp) /* f0865b8: 24c6001c */ addiu $a2,$a2,0x1c -/* f0865bc: 0fc4fcfd */ jal func0f13f3f4 +/* f0865bc: 0fc4fcfd */ jal wallhitCreate /* f0865c0: afb90028 */ sw $t9,0x28($sp) /* f0865c4: 8fa80124 */ lw $t0,0x124($sp) .L0f0865c8: @@ -60384,7 +60384,7 @@ glabel objHit /* f084c2c: 25e40010 */ addiu $a0,$t7,0x10 /* f084c30: 25e5001c */ addiu $a1,$t7,0x1c /* f084c34: 24c6001c */ addiu $a2,$a2,0x1c -/* f084c38: 0fc4e7bd */ jal func0f13f3f4 +/* f084c38: 0fc4e7bd */ jal wallhitCreate /* f084c3c: afad0028 */ sw $t5,0x28($sp) /* f084c40: 10000078 */ beqz $zero,.NB0f084e24 /* f084c44: 8fa80124 */ lw $t0,0x124($sp) @@ -60516,7 +60516,7 @@ glabel objHit /* f084e0c: 25c5001c */ addiu $a1,$t6,0x1c /* f084e10: afad002c */ sw $t5,0x2c($sp) /* f084e14: 24c6001c */ addiu $a2,$a2,0x1c -/* f084e18: 0fc4e7bd */ jal func0f13f3f4 +/* f084e18: 0fc4e7bd */ jal wallhitCreate /* f084e1c: afaf0028 */ sw $t7,0x28($sp) /* f084e20: 8fa80124 */ lw $t0,0x124($sp) .NB0f084e24: diff --git a/src/game/training/training.c b/src/game/training/training.c index 07f8a4f57..fee1eef21 100644 --- a/src/game/training/training.c +++ b/src/game/training/training.c @@ -533,8 +533,8 @@ void frInitDefaults(void) g_FrData.targets[i].invincibletimer = 0; g_FrData.targets[i].frpadnum = -1; - func0f13e40c(g_FrData.targets[i].prop, false); - func0f13e40c(g_FrData.targets[i].prop, true); + wallhitsRemoveByProp(g_FrData.targets[i].prop, 0); + wallhitsRemoveByProp(g_FrData.targets[i].prop, 1); } g_FrData.timetaken = PALDOWN(-240); diff --git a/src/game/wallhit.c b/src/game/wallhit.c index 995f93583..cbeb66040 100644 --- a/src/game/wallhit.c +++ b/src/game/wallhit.c @@ -6,6 +6,7 @@ #include "game/game_0b3350.h" #include "game/game_127910.h" #include "game/game_1668e0.h" +#include "game/gfxmemory.h" #include "game/file.h" #include "game/options.h" #include "game/utils.h" @@ -59,8 +60,8 @@ const char var7f1b5cc8[] = ""; const char var7f1b5ccc[] = ""; const char var7f1b5cd0[] = "Wallhit colour %d not implemented, substituting black\n"; -struct var800a41b0 *var800a41b0; -struct var800a41b0 *var800a41b4; +struct wallhit *var800a41b0; +struct wallhit *var800a41b4; u32 var800a41b8; u32 var8007f740 = 0x00000000; @@ -122,7 +123,7 @@ s16 func0f13e0e0(f32 value) } GLOBAL_ASM( -glabel func0f13e1b0 +glabel wallhitRemove /* f13e1b0: 908e006f */ lbu $t6,0x6f($a0) /* f13e1b4: 3c03800a */ lui $v1,%hi(var800a41b8) /* f13e1b8: 246341b8 */ addiu $v1,$v1,%lo(var800a41b8) @@ -301,19 +302,19 @@ glabel func0f13e1b0 /* f13e408: 00000000 */ nop ); -void func0f13e40c(struct prop *prop, s8 arg1) +void wallhitsRemoveByProp(struct prop *prop, s8 layer) { struct prop *copy = prop; - if (arg1) { - while (copy->unk44) { - func0f13e640(copy->unk44, 1); - func0f13e1b0(copy->unk44); + if (layer) { + while (copy->wallhits2) { + func0f13e640(copy->wallhits2, 1); + wallhitRemove(copy->wallhits2); } } else { - while (copy->unk40) { - func0f13e640(copy->unk40, 1); - func0f13e1b0(copy->unk40); + while (copy->wallhits1) { + func0f13e640(copy->wallhits1, 1); + wallhitRemove(copy->wallhits1); } } } @@ -348,32 +349,32 @@ void func0f13e5c8(struct prop *prop) } } -void func0f13e640(struct var800a41b0 *thing, u32 arg1) +void func0f13e640(struct wallhit *hit, u32 arg1) { - if (thing->unk6f_02 == 0) { - if (thing->unk60) { + if (hit->unk6f_02 == 0) { + if (hit->unk60) { var8009cc40[0]--; } else { - var8009cc40[thing->unk68]--; + var8009cc40[hit->unk68]--; } - if (thing->unk6d == 0) { - thing->unk6d = arg1; - thing->unk6e = arg1; + if (hit->unk6d == 0) { + hit->unk6d = arg1; + hit->unk6e = arg1; } - thing->unk6f_02 = true; + hit->unk6f_02 = true; var8009cc48--; var8009cc50++; - if (var8007f75c[thing->unk6a].unk08 == 3) { + if (var8007f75c[hit->texturenum].unk08 == 3) { var8009cc54--; } else { var8009cc58--; } - thing->unk6f_03 = false; + hit->unk6f_03 = false; } } @@ -844,7 +845,7 @@ glabel func0f13e994 ); GLOBAL_ASM( -glabel func0f13eb44 +glabel wallhitsTick .late_rodata glabel var7f1b5d08 .word 0x3f19999a @@ -1110,7 +1111,7 @@ glabel var7f1b5d18 /* f13eeec: 10000003 */ b .L0f13eefc /* f13eef0: a22c006e */ sb $t4,0x6e($s1) .L0f13eef4: -/* f13eef4: 0fc4f86c */ jal func0f13e1b0 +/* f13eef4: 0fc4f86c */ jal wallhitRemove /* f13eef8: 02202025 */ or $a0,$s1,$zero .L0f13eefc: /* f13eefc: 9222006d */ lbu $v0,0x6d($s1) @@ -1460,7 +1461,7 @@ glabel var7f1b5d18 ); GLOBAL_ASM( -glabel func0f13f3f4 +glabel wallhitCreate .late_rodata glabel var7f1b5d1c .word 0x3dcccccd @@ -5498,7 +5499,7 @@ s32 func0f140750(struct coord *coord) #if VERSION >= VERSION_NTSC_1_0 GLOBAL_ASM( -glabel func0f1408a8 +glabel wallhitRenderBgHitsLayer1 /* f1408a8: 27bdffb0 */ addiu $sp,$sp,-80 /* f1408ac: afa50054 */ sw $a1,0x54($sp) /* f1408b0: 24af0008 */ addiu $t7,$a1,0x8 @@ -5693,7 +5694,7 @@ glabel func0f1408a8 ); #else GLOBAL_ASM( -glabel func0f1408a8 +glabel wallhitRenderBgHitsLayer1 /* f13b3a4: 27bdffb0 */ addiu $sp,$sp,-80 /* f13b3a8: afa50054 */ sw $a1,0x54($sp) /* f13b3ac: 24af0008 */ addiu $t7,$a1,0x8 @@ -5881,9 +5882,73 @@ glabel func0f1408a8 ); #endif +// Mismatch: Target copies the colours using $at. +//Gfx *wallhitRenderBgHitsLayer1(s32 roomnum, Gfx *gdl) +//{ +// struct wallhit *hit; +// u32 *colours; +// s32 prevtexturenum; +// s32 prev6b; +// +// gSPClearGeometryMode(gdl++, G_CULL_BOTH); +// gSPSetGeometryMode(gdl++, G_CULL_BACK); +//#if VERSION >= VERSION_NTSC_1_0 +// gDPSetTextureDetail(gdl++, G_TD_CLAMP); +//#endif +// gDPSetColorDither(gdl++, G_CD_NOISE); +// gDPSetTextureFilter(gdl++, G_TF_BILERP); +// +// prevtexturenum = -1; +// prev6b = -1; +// +// gdl = func0f166d7c(gdl, roomnum); +// +// hit = g_Rooms[roomnum].wallhits1; +// +// while (hit) { +// if (hit->unk6f_00 && hit->unk6f_05) { +// if (hit->unk6f_04) { +// hit->unk6b = 1; +// } else { +// hit->unk6b = func0f140750(&hit->unk50); +// } +// +// if (hit->texturenum != prevtexturenum || hit->unk6b != prev6b) { +// func0f0b39c0(&gdl, &var800ab560[hit->texturenum], 2, hit->unk6b, 2, 1, NULL); +// +// prevtexturenum = hit->texturenum; +// prev6b = hit->unk6b; +// } +// +// colours = gfxAllocateColours(4); +// colours[0] = hit->colours[0]; +// colours[1] = hit->colours[1]; +// colours[2] = hit->colours[2]; +// colours[3] = hit->colours[3]; +// +// gDPSetColorArray(gdl++, osVirtualToPhysical(colours), 4); +// +// if (hit->verticesptr != NULL) { +// gDPSetVerticeArray(gdl++, hit->verticesptr, 4); +// } else { +// gDPSetVerticeArray(gdl++, osVirtualToPhysical(&hit->vertices), 4); +// } +// +// gDPTri2(gdl++, 0, 1, 2, 0, 2, 3); +// } +// +// hit = hit->next; +// } +// +// gSPClearGeometryMode(gdl++, G_CULL_BOTH); +// gDPSetColorDither(gdl++, G_CD_BAYER); +// +// return gdl; +//} + #if VERSION >= VERSION_NTSC_1_0 GLOBAL_ASM( -glabel func0f140b7c +glabel wallhitRenderBgHitsLayer2 /* f140b7c: 27bdffb0 */ addiu $sp,$sp,-80 /* f140b80: afa50054 */ sw $a1,0x54($sp) /* f140b84: 24af0008 */ addiu $t7,$a1,0x8 @@ -6063,7 +6128,7 @@ glabel func0f140b7c ); #else GLOBAL_ASM( -glabel func0f140b7c +glabel wallhitRenderBgHitsLayer2 /* f13b65c: 27bdffb0 */ addiu $sp,$sp,-80 /* f13b660: afa50054 */ sw $a1,0x54($sp) /* f13b664: 24af0008 */ addiu $t7,$a1,0x8 @@ -6238,7 +6303,7 @@ glabel func0f140b7c #if VERSION >= VERSION_NTSC_1_0 GLOBAL_ASM( -glabel func0f140e20 +glabel wallhitRenderPropHits /* f140e20: 27bdff48 */ addiu $sp,$sp,-184 /* f140e24: 3c0e800a */ lui $t6,%hi(g_Vars+0x284) /* f140e28: 8dcea244 */ lw $t6,%lo(g_Vars+0x284)($t6) @@ -6486,7 +6551,7 @@ glabel func0f140e20 ); #else GLOBAL_ASM( -glabel func0f140e20 +glabel wallhitRenderPropHits /* f13b8e4: 27bdff50 */ addiu $sp,$sp,-176 /* f13b8e8: 3c0e800a */ lui $t6,0x800a /* f13b8ec: 8dcee944 */ lw $t6,-0x16bc($t6) @@ -6727,14 +6792,14 @@ glabel func0f140e20 ); #endif -Gfx *wallhitsRender(s32 roomnum, Gfx *gdl) +Gfx *wallhitRenderBgHits(s32 roomnum, Gfx *gdl) { - if (g_Rooms[roomnum].unk84 != 0) { - gdl = func0f1408a8(roomnum, gdl); + if (g_Rooms[roomnum].wallhits1 != NULL) { + gdl = wallhitRenderBgHitsLayer1(roomnum, gdl); } - if (g_Rooms[roomnum].unk88 != 0) { - gdl = func0f140b7c(roomnum, gdl); + if (g_Rooms[roomnum].wallhits2 != NULL) { + gdl = wallhitRenderBgHitsLayer2(roomnum, gdl); } return gdl; @@ -6990,16 +7055,16 @@ void func0f14159c(struct prop *prop) s32 i; for (i = 0; i < var8009cc44; i++) { - struct var800a41b0 *thing = &var800a41b0[i]; + struct wallhit *hit = &var800a41b0[i]; - if (thing->prop - && thing->unk68 > 0 - && thing->prop == prop - && var8007f75c[thing->unk6a].unk08 == 3) { - if ((thing->unk6a >= 0xc && thing->unk6a <= 0xc) || (random() % 100) < 35) { - func0f13e640(thing, (PAL ? 100 : 120)); + if (hit->prop + && hit->unk68 > 0 + && hit->prop == prop + && var8007f75c[hit->texturenum].unk08 == 3) { + if ((hit->texturenum >= 12 && hit->texturenum <= 12) || (random() % 100) < 35) { + func0f13e640(hit, (PAL ? 100 : 120)); } else { - thing->unk70_00 = g_Vars.lvframenum; + hit->unk70_00 = g_Vars.lvframenum; } } } @@ -7015,17 +7080,17 @@ void func0f141704(struct prop *prop) s32 i; for (i = 0; i < var8009cc44; i++) { - struct var800a41b0 *thing = &var800a41b0[i]; + struct wallhit *hit = &var800a41b0[i]; - if (thing->prop - && thing->unk68 > 0 - && thing->prop == prop - && thing->unk6f_02 == 0 - && var8007f75c[thing->unk6a].unk08 == 3 - && thing->unk6a > 0xb - && thing->unk6a < 0xd - && thing->unk70_00 < bestvalue) { - bestvalue = thing->unk70_00; + if (hit->prop + && hit->unk68 > 0 + && hit->prop == prop + && hit->unk6f_02 == 0 + && var8007f75c[hit->texturenum].unk08 == 3 + && hit->texturenum >= 12 + && hit->texturenum <= 12 + && hit->unk70_00 < bestvalue) { + bestvalue = hit->unk70_00; index = i; } } diff --git a/src/include/bss.h b/src/include/bss.h index e6939a061..ed61d529d 100644 --- a/src/include/bss.h +++ b/src/include/bss.h @@ -211,8 +211,8 @@ extern u32 g_NextSparkIndex; extern struct sparkgroup g_SparkGroups[10]; extern u32 var800a4130; extern u8 *var800a41a0; -extern struct var800a41b0 *var800a41b0; -extern struct var800a41b0 *var800a41b4; +extern struct wallhit *var800a41b0; +extern struct wallhit *var800a41b4; extern u32 var800a41b8; extern s32 g_MaxShards; extern struct shard *g_Shards; diff --git a/src/include/game/game_0b3350.h b/src/include/game/game_0b3350.h index 443084e57..cca18112f 100644 --- a/src/include/game/game_0b3350.h +++ b/src/include/game/game_0b3350.h @@ -11,6 +11,6 @@ u32 func0f0b34d8(void); u32 func0f0b3548(void); u32 func0f0b35b8(void); void func0f0b3988(struct textureconfig *config); -void func0f0b39c0(Gfx **gdl, struct textureconfig *arg1, u32 arg2, u32 arg3, u32 arg4, u32 arg5, u32 *arg6); +void func0f0b39c0(Gfx **gdl, struct textureconfig *arg1, u32 arg2, u32 arg3, u32 arg4, s32 arg5, u32 *arg6); #endif diff --git a/src/include/game/wallhit.h b/src/include/game/wallhit.h index 707533fcc..b674320c5 100644 --- a/src/include/game/wallhit.h +++ b/src/include/game/wallhit.h @@ -5,21 +5,21 @@ #include "types.h" s16 func0f13e0e0(f32 arg0); -void func0f13e1b0(struct var800a41b0 *arg0); -void func0f13e40c(struct prop *prop, s8 arg1); +void wallhitRemove(struct wallhit *wallhit); +void wallhitsRemoveByProp(struct prop *prop, s8 layer); bool chrIsUsingPaintball(struct chrdata *chr); void func0f13e5c8(struct prop *prop); -void func0f13e640(struct var800a41b0 *thing, u32 arg1); +void func0f13e640(struct wallhit *wallhit, u32 arg1); u32 func0f13e744(void); u32 func0f13e994(void); -void func0f13eb44(void); -void func0f13f3f4(struct coord *arg0, struct coord *arg1, struct coord *arg2, u32 arg3, u32 arg4, u32 arg5, s32 room, struct prop *arg7, s32 arg8, u32 arg9, struct chrdata *chr, bool arg11); +void wallhitsTick(void); +void wallhitCreate(struct coord *arg0, struct coord *arg1, struct coord *arg2, u32 arg3, u32 arg4, u32 arg5, s32 room, struct prop *arg7, s32 arg8, u32 arg9, struct chrdata *chr, bool arg11); u32 func0f13f504(void); s32 func0f140750(struct coord *coord); -Gfx *func0f1408a8(s32 roomnum, Gfx *gdl); -Gfx *func0f140b7c(s32 roomnum, Gfx *gdl); -Gfx *func0f140e20(Gfx *gdl, struct prop *prop, bool withalpha); -Gfx *wallhitsRender(s32 roomnum, Gfx *gdl); +Gfx *wallhitRenderBgHitsLayer1(s32 roomnum, Gfx *gdl); +Gfx *wallhitRenderBgHitsLayer2(s32 roomnum, Gfx *gdl); +Gfx *wallhitRenderPropHits(Gfx *gdl, struct prop *prop, bool withalpha); +Gfx *wallhitRenderBgHits(s32 roomnum, Gfx *gdl); void func0f141234(void); void func0f14159c(struct prop *prop); void func0f141704(struct prop *prop); diff --git a/src/include/types.h b/src/include/types.h index 3acef562c..fe52b8267 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -433,8 +433,8 @@ struct prop { /*0x3f*/ u8 backgrounded : 1; /*0x3f*/ u8 forcetick : 1; /*0x3f*/ u8 active : 1; - /*0x40*/ struct var800a41b0 *unk40; - /*0x44*/ struct var800a41b0 *unk44; + /*0x40*/ struct wallhit *wallhits1; + /*0x44*/ struct wallhit *wallhits2; }; struct packedpad { @@ -3752,8 +3752,8 @@ struct room { /*0x78*/ u32 unk78; /*0x7c*/ u32 unk7c; /*0x80*/ s32 gfxdatalen; // when inflated - /*0x84*/ u32 unk84; - /*0x88*/ u32 unk88; + /*0x84*/ struct wallhit *wallhits1; + /*0x88*/ struct wallhit *wallhits2; }; struct fireslotthing { @@ -6113,35 +6113,26 @@ struct stageheadlimit { u8 maxheads; }; -struct var800a41b0 { - /*0x00*/ u32 unk00; - /*0x04*/ u32 unk04; - /*0x08*/ u32 unk08; - /*0x0c*/ u32 unk0c; - /*0x10*/ u32 unk10; - /*0x14*/ u32 unk14; - /*0x18*/ u32 unk18; - /*0x1c*/ u32 unk1c; - /*0x20*/ u32 unk20; - /*0x24*/ u32 unk24; - /*0x28*/ u32 unk28; - /*0x2c*/ u32 unk2c; +struct fourcolours { + u32 colour1; + u32 colour2; + u32 colour3; + u32 colour4; +}; + +struct wallhit { + /*0x00*/ struct gfxvtx vertices[4]; /*0x30*/ u32 unk30; /*0x34*/ u32 unk34; /*0x38*/ u32 unk38; /*0x3c*/ u32 unk3c; - /*0x40*/ u32 unk40; - /*0x44*/ u32 unk44; - /*0x48*/ u32 unk48; - /*0x4c*/ u32 unk4c; - /*0x50*/ u32 unk50; - /*0x54*/ u32 unk54; - /*0x58*/ u32 unk58; + /*0x40*/ u32 colours[4]; + /*0x50*/ struct coord unk50; /*0x5c*/ struct prop *prop; /*0x60*/ u32 unk60; - /*0x64*/ u32 unk64; + /*0x64*/ struct gfxvtx *verticesptr; /*0x68*/ s16 unk68; - /*0x6a*/ u8 unk6a; + /*0x6a*/ u8 texturenum; /*0x6b*/ u8 unk6b; /*0x6c*/ u8 unk6c; /*0x6d*/ u8 unk6d; @@ -6150,10 +6141,12 @@ struct var800a41b0 { /*0x6f*/ u8 unk6f_01 : 1; /*0x6f*/ u8 unk6f_02 : 1; /*0x6f*/ u8 unk6f_03 : 1; + /*0x6f*/ u8 unk6f_04 : 1; + /*0x6f*/ u8 unk6f_05 : 1; /*0x70*/ u32 unk70_00 : 28; /*0x70*/ u32 unk70_28 : 4; - /*0x74*/ struct var800a41b0 *prev; - /*0x78*/ u32 unk78; + /*0x74*/ struct wallhit *prev; + /*0x78*/ struct wallhit *next; }; /**