Document dlights.c

This commit is contained in:
Ryan Dwyer 2024-09-14 19:43:05 +10:00
parent d2c719284e
commit 5d3d1696e1
20 changed files with 401 additions and 335 deletions

View File

@ -2036,8 +2036,8 @@ void bg_build_tables(s32 stagenum)
var8007fc10 = 200;
wallhit_reset();
func0f002a98();
func0f001c0c();
lights_reset_1();
lights_reset_2();
#if VERSION < VERSION_NTSC_1_0
bg_build_reference_light_sums();

View File

@ -8272,10 +8272,10 @@ void bgun_render(Gfx **gdlptr)
renderdata.envcolour = (shade << 24 | shade << 16 | shade << 8) + col[3];
if (USINGDEVICE(DEVICE_NIGHTVISION)) {
spb0[0] = var8009caef;
spb0[1] = var8009caef;
spb0[2] = var8009caef;
spb0[3] = var8009caf0;
spb0[0] = g_GogglesChrColourIntensity;
spb0[1] = g_GogglesChrColourIntensity;
spb0[2] = g_GogglesChrColourIntensity;
spb0[3] = g_GogglesChrColourAlpha;
colour = (spb0[0] << 24 | spb0[1] << 16 | spb0[2] << 8) + spb0[3];
} else if (USINGDEVICE(DEVICE_IRSCANNER)) {

View File

@ -1911,11 +1911,11 @@ Gfx *bview_draw_nv_lens(Gfx *gdl)
strcpy(var800a41c0, "Fullscreen_DrawFaultScope");
var8009caec = 0xbc;
var8009caef = 0xbe;
var8009caf0 = 0xde;
var8009caed = 0x50;
var8009caee = 0xc0;
g_GooglesRoomBrightness = 0xbc;
g_GogglesChrColourIntensity = 0xbe;
g_GogglesChrColourAlpha = 0xde;
g_GogglesObjColourIntensity = 0x50;
g_GogglesObjColourAlpha = 0xc0;
brightness = room_get_final_brightness(g_Vars.currentplayer->prop->rooms[0]);
@ -2083,9 +2083,9 @@ Gfx *bview_draw_ir_lens(Gfx *gdl)
}
#endif
var8009caec = 0xff;
var8009caef = 0xde;
var8009caf0 = 0xde;
g_GooglesRoomBrightness = 0xff;
g_GogglesChrColourIntensity = 0xde;
g_GogglesChrColourAlpha = 0xde;
gDPPipeSync(gdl++);

View File

@ -3494,10 +3494,10 @@ Gfx *chr_render(struct prop *prop, Gfx *gdl, bool xlupass)
// Configure colours for night vision if in use
if (USINGDEVICE(DEVICE_NIGHTVISION)) {
colour[0] = var8009caef;
colour[1] = var8009caef;
colour[2] = var8009caef;
colour[3] = var8009caf0;
colour[0] = g_GogglesChrColourIntensity;
colour[1] = g_GogglesChrColourIntensity;
colour[2] = g_GogglesChrColourIntensity;
colour[3] = g_GogglesChrColourAlpha;
}
// Configure colours for xray if in use

View File

@ -437,7 +437,7 @@ bool (*g_CommandPointers[])(void) = {
/*0x01a7*/ ai_if_chr_not_talking,
/*0x01a8*/ NULL,
/*0x01a9*/ NULL,
/*0x01aa*/ ai01aa,
/*0x01aa*/ ai_if_dist_to_player_through_portals_lt_30m,
/*0x01ab*/ ai_if_num_knocked_out_chrs,
/*0x01ac*/ NULL,
/*0x01ad*/ ai_release_object,

View File

@ -8853,19 +8853,19 @@ bool ai_if_target_y_difference_less_than(void)
/**
* @cmd 01aa
*/
bool ai01aa(void)
bool ai_if_dist_to_player_through_portals_lt_30m(void)
{
u8 *cmd = g_Vars.ailist + g_Vars.aioffset;
f32 a = 3000;
f32 dist = 3000;
func0f0056f4(
lights_find_distance_through_rooms_with_limit(
g_Vars.currentplayer->prop->rooms[0],
&g_Vars.currentplayer->prop->pos,
g_Vars.chrdata->prop->rooms[0],
&g_Vars.chrdata->prop->pos,
0, &a, 0);
0, &dist, 0);
if (a < 3000) {
if (dist < 3000) {
g_Vars.aioffset = chrai_go_to_label(g_Vars.ailist, g_Vars.aioffset, cmd[2]);
} else {
g_Vars.aioffset += 3;

File diff suppressed because it is too large Load Diff

View File

@ -440,7 +440,7 @@ void lv_reset(s32 stagenum)
acoustic_reset();
portals_reset();
lights_reset();
lights_reset_3();
set_current_player_num(0);
}

View File

@ -108,7 +108,7 @@ void portal0f0b65a8(s32 numportals)
{
if (numportals > 0) {
g_NumPortalXluFracs = numportals;
g_PortalXluFracs = memp_alloc(ALIGN16(numportals * 2), MEMPOOL_STAGE);
g_PortalXluFracs = memp_alloc(ALIGN16(numportals * sizeof(g_PortalXluFracs[0])), MEMPOOL_STAGE);
} else {
g_PortalXluFracs = NULL;
}

View File

@ -13790,10 +13790,10 @@ Gfx *obj_render(struct prop *prop, Gfx *gdl, bool xlupass)
if (USINGDEVICE(DEVICE_NIGHTVISION)) {
if ((obj->flags & OBJFLAG_PATHBLOCKER) == 0) {
colour[0] = var8009caed;
colour[1] = var8009caed;
colour[2] = var8009caed;
colour[3] = var8009caee;
colour[0] = g_GogglesObjColourIntensity;
colour[1] = g_GogglesObjColourIntensity;
colour[2] = g_GogglesObjColourIntensity;
colour[3] = g_GogglesObjColourAlpha;
}
} else if (USINGDEVICE(DEVICE_IRSCANNER)) {
if ((obj->hidden & OBJHFLAG_CONDITIONALSCENERY) || (obj->flags3 & OBJFLAG3_INFRARED)) {

View File

@ -1185,7 +1185,7 @@ s32 ps_calculate_vol(struct coord *pos, f32 dist1, f32 dist2, f32 dist3, RoomNum
camroom = -1;
}
func0f0056f4(camroom, &player->cam_pos, roomnum, pos, 0, &playerdist, s0);
lights_find_distance_through_rooms_with_limit(camroom, &player->cam_pos, roomnum, pos, 0, &playerdist, s0);
}
if (playerdistptr != NULL) {

View File

@ -451,46 +451,46 @@ void func0f177a38(u32 arg0, u32 arg1, u32 arg2, u32 arg3)
}
}
s32 func0f177a54(u8 *arg0, s32 arg1, u8 *arg2, s32 arg3)
s32 func0f177a54(u8 *src, s32 count, u8 *dst, s32 stepsize)
{
s32 i = 0;
s32 v1 = 0;
s32 t0 = 0;
s32 dstlen = 0;
s32 accum = 0;
for (; i < arg1; i++) {
s32 index = i * arg3;
for (; i < count; i++) {
s32 index = i * stepsize;
if (arg0[index] != 0) {
u8 *ptr = &arg0[index];
if (src[index] != 0) {
u8 *srcptr = &src[index];
if (i != 0 && ptr[-arg3] == 0) {
arg2[v1++] = 0;
if (i != 0 && srcptr[-stepsize] == 0) {
dst[dstlen++] = 0;
if (t0 == 255) {
arg2[v1++] = 200;
arg2[v1++] = 0;
t0 -= 200;
if (accum == 255) {
dst[dstlen++] = 200;
dst[dstlen++] = 0;
accum -= 200;
} else {
while (t0 > 255) {
arg2[v1++] = 255;
t0 -= 255;
while (accum > 255) {
dst[dstlen++] = 255;
accum -= 255;
}
}
arg2[v1++] = t0;
t0 = 0;
dst[dstlen++] = accum;
accum = 0;
}
arg2[v1++] = arg0[index];
dst[dstlen++] = src[index];
} else {
t0++;
accum++;
}
}
arg2[v1++] = 0;
arg2[v1++] = 0;
dst[dstlen++] = 0;
dst[dstlen++] = 0;
return v1;
return dstlen;
}
u8 func0f177b44(u8 *arg0, s32 *arg1)

View File

@ -62,11 +62,11 @@ extern OSMesgQueue __osEepromTimerQ;
extern OSMesg __osEepromTimerMsg;
extern u32 var8009ca84;
extern u16 *g_FrameBuffers[NUM_FRAMEBUFFERS];
extern u8 var8009caec;
extern u8 var8009caed;
extern u8 var8009caee;
extern u8 var8009caef;
extern u8 var8009caf0;
extern u8 g_GooglesRoomBrightness;
extern u8 g_GogglesObjColourIntensity;
extern u8 g_GogglesObjColourAlpha;
extern u8 g_GogglesChrColourIntensity;
extern u8 g_GogglesChrColourAlpha;
extern struct prop *g_DangerousProps[12];
extern u16 *g_WallhitCountsPerRoom;
extern s32 g_WallhitsMax;

View File

@ -3801,7 +3801,11 @@
chr, \
label,
#define cmd01aa(label) \
/**
* Checks if the current chr is within 30 metres of the player,
* routing through portals rather than straight through walls.
*/
#define if_dist_to_player_through_portals_lt_30m(label) \
mkshort(0x01aa), \
label,

View File

@ -23,6 +23,7 @@
#define MAX_MPCHRS (MAX_PLAYERS + MAX_BOTS)
#define MAX_MPPLAYERCONFIGS (MAX_PLAYERS + 2)
#define MAX_OBJECTIVES 10
#define MAX_PORTALS 2048
#define MAX_PLAYERS 4
#define MAX_PROPSPERROOMCHUNK 7
#define MAX_ROOMPROPLISTCHUNKS 256

View File

@ -392,7 +392,7 @@
/*0x01a5*/ bool ai_if_using_lift(void);
/*0x01a6*/ bool ai_if_target_y_difference_less_than(void);
/*0x01a7*/ bool ai_if_chr_not_talking(void);
/*0x01aa*/ bool ai01aa(void);
/*0x01aa*/ bool ai_if_dist_to_player_through_portals_lt_30m(void);
/*0x01ab*/ bool ai_if_num_knocked_out_chrs(void);
/*0x01ad*/ bool ai_release_object(void);
/*0x01ae*/ bool ai_clear_inventory(void);

View File

@ -22,9 +22,9 @@ void room_init_lights(s32 roomnum);
bool lights_handle_hit(struct coord *gunpos, struct coord *hitpos, s32 roomnum);
void room_set_lights_faulty(s32 roomnum, s32 chance);
void room_set_light_broken(s32 roomnum, s32 lightnum);
void lights_reset(void);
void func0f001c0c(void);
void func0f002a98(void);
void lights_reset_3(void);
void lights_reset_2(void);
void lights_reset_1(void);
void room_set_lights_on(s32 roomnum, s32 enable);
void room_set_light_op(s32 roomnum, s32 operation, u8 br_to, u8 br_from, u8 duration60);
bool light_tick_broken(s32 roomnum, s32 lightnum);
@ -32,6 +32,6 @@ void lighting_tick(void);
void lights_tick(void);
void room_flash_lighting(s32 roomnum, s32 start, s32 limit);
void room_highlight(s32 roomnum);
void func0f0056f4(s32 room1, struct coord *coord1, s32 room2, struct coord *coord2, s32 arg4, f32 *arg5, s32 arg6);
void lights_find_distance_through_rooms_with_limit(s32 room1, struct coord *coord1, s32 room2, struct coord *coord2, s32 arg4, f32 *arg5, s32 arg6);
#endif

View File

@ -8,7 +8,7 @@
#define PORTALINTERSECTION_BEHINDTOFRONT 1
#define PORTALINTERSECTION_FRONTTOBEHIND 2
void portal_get_avg_vertex_pos(s32 portalnum, struct coord *avg);
void portal_get_centre(s32 portalnum, struct coord *avg);
s32 portal_calculate_intersection(s32 portalnum, struct coord *pos1, struct coord *pos2);
void portal_find_rooms(struct coord *frompos, struct coord *topos, RoomNum *fromrooms, RoomNum *finalrooms, RoomNum *intersecting, s32 maxintersecting);

View File

@ -5206,9 +5206,9 @@ struct light {
/*0x0a*/ struct vec3s16 bbox[4];
};
struct var80061420 {
u8 *unk00;
u8 *unk04;
struct transfertableentry {
u8 *horizontal;
u8 *vertical;
};
struct menurendercontext {

View File

@ -12,7 +12,7 @@ u8 var8005ef20 = 254;
u8 var8009a4e0[456][2];
void portal_get_avg_vertex_pos(s32 portalnum, struct coord *avg)
void portal_get_centre(s32 portalnum, struct coord *avg)
{
struct portalvertices *pvertices = (struct portalvertices *)((uintptr_t)g_BgPortals + g_BgPortals[portalnum].verticesoffset);
f32 f0;