From 5d8f96f36ae6c7bb31f8cdaed0d673a89f73812a Mon Sep 17 00:00:00 2001 From: Ryan Dwyer Date: Mon, 11 Jul 2022 23:42:04 +1000 Subject: [PATCH] Decompile bgChooseRoomsToLoad and discover more room and portal flags --- src/files/setup/setupame.c | 220 ++++++------- src/files/setup/setupark.c | 220 ++++++------- src/files/setup/setupsho.c | 6 +- src/game/bg.c | 514 +++++++++---------------------- src/game/bot.c | 10 +- src/game/camera.c | 2 +- src/game/chraction.c | 28 +- src/game/chrai.c | 4 +- src/game/chraicommands.c | 8 +- src/game/dlights.c | 12 +- src/game/explosions.c | 4 +- src/game/lv.c | 2 +- src/game/player.c | 11 +- src/game/portal.c | 48 +-- src/game/prop.c | 6 +- src/game/propobj.c | 47 +-- src/game/smoke.c | 4 +- src/game/sparks.c | 6 +- src/game/wallhit.c | 15 +- src/game/weather.c | 4 +- src/include/constants.h | 17 +- src/include/game/bg.h | 12 +- src/include/game/chraction.h | 2 +- src/include/game/chraicommands.h | 4 +- src/include/game/portal.h | 10 +- 25 files changed, 504 insertions(+), 712 deletions(-) diff --git a/src/files/setup/setupame.c b/src/files/setup/setupame.c index 52864caff..023e4ba4f 100644 --- a/src/files/setup/setupame.c +++ b/src/files/setup/setupame.c @@ -3900,116 +3900,116 @@ u8 func101f_setup_rtracker[] = { u8 func1420_setup_portals[] = { yield - set_portal_flag(0x008e, 0x08) - set_portal_flag(0x008f, 0x08) - set_portal_flag(0x0084, 0x08) - set_portal_flag(0x0090, 0x08) - set_portal_flag(0x0091, 0x08) - set_portal_flag(0x0093, 0x08) - set_portal_flag(0x0096, 0x08) - set_portal_flag(0x0095, 0x08) - set_portal_flag(0x0099, 0x08) - set_portal_flag(0x00b6, 0x08) - set_portal_flag(0x00bf, 0x08) - set_portal_flag(0x00be, 0x08) - set_portal_flag(0x00c0, 0x08) - set_portal_flag(0x00c2, 0x08) - set_portal_flag(0x00c4, 0x08) - set_portal_flag(0x00c8, 0x08) - set_portal_flag(0x00c7, 0x08) - set_portal_flag(0x00c9, 0x08) - set_portal_flag(0x00cd, 0x08) - set_portal_flag(0x00ce, 0x08) - set_portal_flag(0x00d2, 0x08) - set_portal_flag(0x00e0, 0x08) - set_portal_flag(0x00dc, 0x08) - set_portal_flag(0x00de, 0x08) - set_portal_flag(0x00e3, 0x08) - set_portal_flag(0x00e5, 0x08) - set_portal_flag(0x00e7, 0x08) - set_portal_flag(0x00fb, 0x08) - set_portal_flag(0x00fa, 0x08) - set_portal_flag(0x00fc, 0x08) - set_portal_flag(0x00ff, 0x08) - set_portal_flag(0x0100, 0x08) - set_portal_flag(0x0103, 0x08) - set_portal_flag(0x0102, 0x08) - set_portal_flag(0x0104, 0x08) - set_portal_flag(0x0109, 0x08) - set_portal_flag(0x010c, 0x08) - set_portal_flag(0x0119, 0x08) - set_portal_flag(0x0112, 0x08) - set_portal_flag(0x0117, 0x08) - set_portal_flag(0x0120, 0x08) - set_portal_flag(0x011e, 0x08) - set_portal_flag(0x011c, 0x08) - set_portal_flag(0x0108, 0x08) - set_portal_flag(0x006f, 0x08) - set_portal_flag(0x007d, 0x08) - set_portal_flag(0x0080, 0x08) - set_portal_flag(0x0081, 0x08) - set_portal_flag(0x0075, 0x08) - set_portal_flag(0x0078, 0x08) - set_portal_flag(0x0079, 0x08) - set_portal_flag(0x0006, 0x08) - set_portal_flag(0x0004, 0x08) - set_portal_flag(0x0008, 0x08) - set_portal_flag(0x000a, 0x08) - set_portal_flag(0x0001, 0x08) - set_portal_flag(0x0005, 0x08) - set_portal_flag(0x0000, 0x08) - set_portal_flag(0x0003, 0x08) - set_portal_flag(0x0007, 0x08) - set_portal_flag(0x0013, 0x08) - set_portal_flag(0x0009, 0x08) - set_portal_flag(0x00b1, 0x08) - set_portal_flag(0x00ef, 0x08) - set_portal_flag(0x00ee, 0x08) - set_portal_flag(0x0121, 0x08) - set_portal_flag(0x00e8, 0x08) - set_portal_flag(0x00e9, 0x08) - set_portal_flag(0x00ea, 0x08) - set_portal_flag(0x00ec, 0x08) - set_portal_flag(0x00eb, 0x08) - set_portal_flag(0x00ed, 0x08) - set_portal_flag(0x009d, 0x08) - set_portal_flag(0x00af, 0x08) - set_portal_flag(0x00a1, 0x08) - set_portal_flag(0x005a, 0x08) - set_portal_flag(0x005c, 0x08) - set_portal_flag(0x005d, 0x08) - set_portal_flag(0x0060, 0x08) - set_portal_flag(0x0034, 0x08) - set_portal_flag(0x0030, 0x08) - set_portal_flag(0x002e, 0x08) - set_portal_flag(0x002b, 0x08) - set_portal_flag(0x0028, 0x08) - set_portal_flag(0x0025, 0x08) - set_portal_flag(0x0036, 0x08) - set_portal_flag(0x0038, 0x08) - set_portal_flag(0x004f, 0x08) - set_portal_flag(0x0051, 0x08) - set_portal_flag(0x0052, 0x08) - set_portal_flag(0x0057, 0x08) - set_portal_flag(0x0058, 0x08) - set_portal_flag(0x0031, 0x08) - set_portal_flag(0x002f, 0x08) - set_portal_flag(0x0023, 0x08) - set_portal_flag(0x00a6, 0x08) - set_portal_flag(0x00a3, 0x08) - set_portal_flag(0x00a2, 0x08) - set_portal_flag(0x00a4, 0x08) - set_portal_flag(0x0087, 0x08) - set_portal_flag(0x00b9, 0x08) - set_portal_flag(0x00b4, 0x08) - set_portal_flag(0x00b2, 0x08) - set_portal_flag(0x00b3, 0x08) - set_portal_flag(0x00bd, 0x08) - set_portal_flag(0x00f4, 0x08) - set_portal_flag(0x00f2, 0x08) - set_portal_flag(0x00f0, 0x08) - set_portal_flag(0x00f8, 0x08) - set_portal_flag(0x00f1, 0x08) + set_portal_flag(0x008e, PORTALFLAG_SKIP) + set_portal_flag(0x008f, PORTALFLAG_SKIP) + set_portal_flag(0x0084, PORTALFLAG_SKIP) + set_portal_flag(0x0090, PORTALFLAG_SKIP) + set_portal_flag(0x0091, PORTALFLAG_SKIP) + set_portal_flag(0x0093, PORTALFLAG_SKIP) + set_portal_flag(0x0096, PORTALFLAG_SKIP) + set_portal_flag(0x0095, PORTALFLAG_SKIP) + set_portal_flag(0x0099, PORTALFLAG_SKIP) + set_portal_flag(0x00b6, PORTALFLAG_SKIP) + set_portal_flag(0x00bf, PORTALFLAG_SKIP) + set_portal_flag(0x00be, PORTALFLAG_SKIP) + set_portal_flag(0x00c0, PORTALFLAG_SKIP) + set_portal_flag(0x00c2, PORTALFLAG_SKIP) + set_portal_flag(0x00c4, PORTALFLAG_SKIP) + set_portal_flag(0x00c8, PORTALFLAG_SKIP) + set_portal_flag(0x00c7, PORTALFLAG_SKIP) + set_portal_flag(0x00c9, PORTALFLAG_SKIP) + set_portal_flag(0x00cd, PORTALFLAG_SKIP) + set_portal_flag(0x00ce, PORTALFLAG_SKIP) + set_portal_flag(0x00d2, PORTALFLAG_SKIP) + set_portal_flag(0x00e0, PORTALFLAG_SKIP) + set_portal_flag(0x00dc, PORTALFLAG_SKIP) + set_portal_flag(0x00de, PORTALFLAG_SKIP) + set_portal_flag(0x00e3, PORTALFLAG_SKIP) + set_portal_flag(0x00e5, PORTALFLAG_SKIP) + set_portal_flag(0x00e7, PORTALFLAG_SKIP) + set_portal_flag(0x00fb, PORTALFLAG_SKIP) + set_portal_flag(0x00fa, PORTALFLAG_SKIP) + set_portal_flag(0x00fc, PORTALFLAG_SKIP) + set_portal_flag(0x00ff, PORTALFLAG_SKIP) + set_portal_flag(0x0100, PORTALFLAG_SKIP) + set_portal_flag(0x0103, PORTALFLAG_SKIP) + set_portal_flag(0x0102, PORTALFLAG_SKIP) + set_portal_flag(0x0104, PORTALFLAG_SKIP) + set_portal_flag(0x0109, PORTALFLAG_SKIP) + set_portal_flag(0x010c, PORTALFLAG_SKIP) + set_portal_flag(0x0119, PORTALFLAG_SKIP) + set_portal_flag(0x0112, PORTALFLAG_SKIP) + set_portal_flag(0x0117, PORTALFLAG_SKIP) + set_portal_flag(0x0120, PORTALFLAG_SKIP) + set_portal_flag(0x011e, PORTALFLAG_SKIP) + set_portal_flag(0x011c, PORTALFLAG_SKIP) + set_portal_flag(0x0108, PORTALFLAG_SKIP) + set_portal_flag(0x006f, PORTALFLAG_SKIP) + set_portal_flag(0x007d, PORTALFLAG_SKIP) + set_portal_flag(0x0080, PORTALFLAG_SKIP) + set_portal_flag(0x0081, PORTALFLAG_SKIP) + set_portal_flag(0x0075, PORTALFLAG_SKIP) + set_portal_flag(0x0078, PORTALFLAG_SKIP) + set_portal_flag(0x0079, PORTALFLAG_SKIP) + set_portal_flag(0x0006, PORTALFLAG_SKIP) + set_portal_flag(0x0004, PORTALFLAG_SKIP) + set_portal_flag(0x0008, PORTALFLAG_SKIP) + set_portal_flag(0x000a, PORTALFLAG_SKIP) + set_portal_flag(0x0001, PORTALFLAG_SKIP) + set_portal_flag(0x0005, PORTALFLAG_SKIP) + set_portal_flag(0x0000, PORTALFLAG_SKIP) + set_portal_flag(0x0003, PORTALFLAG_SKIP) + set_portal_flag(0x0007, PORTALFLAG_SKIP) + set_portal_flag(0x0013, PORTALFLAG_SKIP) + set_portal_flag(0x0009, PORTALFLAG_SKIP) + set_portal_flag(0x00b1, PORTALFLAG_SKIP) + set_portal_flag(0x00ef, PORTALFLAG_SKIP) + set_portal_flag(0x00ee, PORTALFLAG_SKIP) + set_portal_flag(0x0121, PORTALFLAG_SKIP) + set_portal_flag(0x00e8, PORTALFLAG_SKIP) + set_portal_flag(0x00e9, PORTALFLAG_SKIP) + set_portal_flag(0x00ea, PORTALFLAG_SKIP) + set_portal_flag(0x00ec, PORTALFLAG_SKIP) + set_portal_flag(0x00eb, PORTALFLAG_SKIP) + set_portal_flag(0x00ed, PORTALFLAG_SKIP) + set_portal_flag(0x009d, PORTALFLAG_SKIP) + set_portal_flag(0x00af, PORTALFLAG_SKIP) + set_portal_flag(0x00a1, PORTALFLAG_SKIP) + set_portal_flag(0x005a, PORTALFLAG_SKIP) + set_portal_flag(0x005c, PORTALFLAG_SKIP) + set_portal_flag(0x005d, PORTALFLAG_SKIP) + set_portal_flag(0x0060, PORTALFLAG_SKIP) + set_portal_flag(0x0034, PORTALFLAG_SKIP) + set_portal_flag(0x0030, PORTALFLAG_SKIP) + set_portal_flag(0x002e, PORTALFLAG_SKIP) + set_portal_flag(0x002b, PORTALFLAG_SKIP) + set_portal_flag(0x0028, PORTALFLAG_SKIP) + set_portal_flag(0x0025, PORTALFLAG_SKIP) + set_portal_flag(0x0036, PORTALFLAG_SKIP) + set_portal_flag(0x0038, PORTALFLAG_SKIP) + set_portal_flag(0x004f, PORTALFLAG_SKIP) + set_portal_flag(0x0051, PORTALFLAG_SKIP) + set_portal_flag(0x0052, PORTALFLAG_SKIP) + set_portal_flag(0x0057, PORTALFLAG_SKIP) + set_portal_flag(0x0058, PORTALFLAG_SKIP) + set_portal_flag(0x0031, PORTALFLAG_SKIP) + set_portal_flag(0x002f, PORTALFLAG_SKIP) + set_portal_flag(0x0023, PORTALFLAG_SKIP) + set_portal_flag(0x00a6, PORTALFLAG_SKIP) + set_portal_flag(0x00a3, PORTALFLAG_SKIP) + set_portal_flag(0x00a2, PORTALFLAG_SKIP) + set_portal_flag(0x00a4, PORTALFLAG_SKIP) + set_portal_flag(0x0087, PORTALFLAG_SKIP) + set_portal_flag(0x00b9, PORTALFLAG_SKIP) + set_portal_flag(0x00b4, PORTALFLAG_SKIP) + set_portal_flag(0x00b2, PORTALFLAG_SKIP) + set_portal_flag(0x00b3, PORTALFLAG_SKIP) + set_portal_flag(0x00bd, PORTALFLAG_SKIP) + set_portal_flag(0x00f4, PORTALFLAG_SKIP) + set_portal_flag(0x00f2, PORTALFLAG_SKIP) + set_portal_flag(0x00f0, PORTALFLAG_SKIP) + set_portal_flag(0x00f8, PORTALFLAG_SKIP) + set_portal_flag(0x00f1, PORTALFLAG_SKIP) set_ailist(CHR_SELF, GAILIST_IDLE) endlist }; diff --git a/src/files/setup/setupark.c b/src/files/setup/setupark.c index 83de21362..61ce62606 100644 --- a/src/files/setup/setupark.c +++ b/src/files/setup/setupark.c @@ -3047,116 +3047,116 @@ u8 func101b_lift_door_sounds[] = { u8 func141c_setup_portals[] = { yield - set_portal_flag(0x008e, 0x08) - set_portal_flag(0x008f, 0x08) - set_portal_flag(0x0084, 0x08) - set_portal_flag(0x0090, 0x08) - set_portal_flag(0x0091, 0x08) - set_portal_flag(0x0093, 0x08) - set_portal_flag(0x0096, 0x08) - set_portal_flag(0x0095, 0x08) - set_portal_flag(0x0099, 0x08) - set_portal_flag(0x00b6, 0x08) - set_portal_flag(0x00bf, 0x08) - set_portal_flag(0x00be, 0x08) - set_portal_flag(0x00c0, 0x08) - set_portal_flag(0x00c2, 0x08) - set_portal_flag(0x00c4, 0x08) - set_portal_flag(0x00c8, 0x08) - set_portal_flag(0x00c7, 0x08) - set_portal_flag(0x00c9, 0x08) - set_portal_flag(0x00cd, 0x08) - set_portal_flag(0x00ce, 0x08) - set_portal_flag(0x00d2, 0x08) - set_portal_flag(0x00e0, 0x08) - set_portal_flag(0x00dc, 0x08) - set_portal_flag(0x00de, 0x08) - set_portal_flag(0x00e3, 0x08) - set_portal_flag(0x00e5, 0x08) - set_portal_flag(0x00e7, 0x08) - set_portal_flag(0x00fb, 0x08) - set_portal_flag(0x00fa, 0x08) - set_portal_flag(0x00fc, 0x08) - set_portal_flag(0x00ff, 0x08) - set_portal_flag(0x0100, 0x08) - set_portal_flag(0x0103, 0x08) - set_portal_flag(0x0102, 0x08) - set_portal_flag(0x0104, 0x08) - set_portal_flag(0x0109, 0x08) - set_portal_flag(0x010c, 0x08) - set_portal_flag(0x0119, 0x08) - set_portal_flag(0x0112, 0x08) - set_portal_flag(0x0117, 0x08) - set_portal_flag(0x0120, 0x08) - set_portal_flag(0x011e, 0x08) - set_portal_flag(0x011c, 0x08) - set_portal_flag(0x0108, 0x08) - set_portal_flag(0x006f, 0x08) - set_portal_flag(0x007d, 0x08) - set_portal_flag(0x0080, 0x08) - set_portal_flag(0x0081, 0x08) - set_portal_flag(0x0075, 0x08) - set_portal_flag(0x0078, 0x08) - set_portal_flag(0x0079, 0x08) - set_portal_flag(0x0006, 0x08) - set_portal_flag(0x0004, 0x08) - set_portal_flag(0x0008, 0x08) - set_portal_flag(0x000a, 0x08) - set_portal_flag(0x0001, 0x08) - set_portal_flag(0x0005, 0x08) - set_portal_flag(0x0000, 0x08) - set_portal_flag(0x0003, 0x08) - set_portal_flag(0x0007, 0x08) - set_portal_flag(0x0013, 0x08) - set_portal_flag(0x0009, 0x08) - set_portal_flag(0x00b1, 0x08) - set_portal_flag(0x00ef, 0x08) - set_portal_flag(0x00ee, 0x08) - set_portal_flag(0x0121, 0x08) - set_portal_flag(0x00e8, 0x08) - set_portal_flag(0x00e9, 0x08) - set_portal_flag(0x00ea, 0x08) - set_portal_flag(0x00ec, 0x08) - set_portal_flag(0x00eb, 0x08) - set_portal_flag(0x00ed, 0x08) - set_portal_flag(0x009d, 0x08) - set_portal_flag(0x00af, 0x08) - set_portal_flag(0x00a1, 0x08) - set_portal_flag(0x005a, 0x08) - set_portal_flag(0x005c, 0x08) - set_portal_flag(0x005d, 0x08) - set_portal_flag(0x0060, 0x08) - set_portal_flag(0x0034, 0x08) - set_portal_flag(0x0030, 0x08) - set_portal_flag(0x002e, 0x08) - set_portal_flag(0x002b, 0x08) - set_portal_flag(0x0028, 0x08) - set_portal_flag(0x0025, 0x08) - set_portal_flag(0x0036, 0x08) - set_portal_flag(0x0038, 0x08) - set_portal_flag(0x004f, 0x08) - set_portal_flag(0x0051, 0x08) - set_portal_flag(0x0052, 0x08) - set_portal_flag(0x0057, 0x08) - set_portal_flag(0x0058, 0x08) - set_portal_flag(0x0031, 0x08) - set_portal_flag(0x002f, 0x08) - set_portal_flag(0x0023, 0x08) - set_portal_flag(0x00a6, 0x08) - set_portal_flag(0x00a3, 0x08) - set_portal_flag(0x00a2, 0x08) - set_portal_flag(0x00a4, 0x08) - set_portal_flag(0x0087, 0x08) - set_portal_flag(0x00b9, 0x08) - set_portal_flag(0x00b4, 0x08) - set_portal_flag(0x00b2, 0x08) - set_portal_flag(0x00b3, 0x08) - set_portal_flag(0x00bd, 0x08) - set_portal_flag(0x00f4, 0x08) - set_portal_flag(0x00f2, 0x08) - set_portal_flag(0x00f0, 0x08) - set_portal_flag(0x00f8, 0x08) - set_portal_flag(0x00f1, 0x08) + set_portal_flag(0x008e, PORTALFLAG_SKIP) + set_portal_flag(0x008f, PORTALFLAG_SKIP) + set_portal_flag(0x0084, PORTALFLAG_SKIP) + set_portal_flag(0x0090, PORTALFLAG_SKIP) + set_portal_flag(0x0091, PORTALFLAG_SKIP) + set_portal_flag(0x0093, PORTALFLAG_SKIP) + set_portal_flag(0x0096, PORTALFLAG_SKIP) + set_portal_flag(0x0095, PORTALFLAG_SKIP) + set_portal_flag(0x0099, PORTALFLAG_SKIP) + set_portal_flag(0x00b6, PORTALFLAG_SKIP) + set_portal_flag(0x00bf, PORTALFLAG_SKIP) + set_portal_flag(0x00be, PORTALFLAG_SKIP) + set_portal_flag(0x00c0, PORTALFLAG_SKIP) + set_portal_flag(0x00c2, PORTALFLAG_SKIP) + set_portal_flag(0x00c4, PORTALFLAG_SKIP) + set_portal_flag(0x00c8, PORTALFLAG_SKIP) + set_portal_flag(0x00c7, PORTALFLAG_SKIP) + set_portal_flag(0x00c9, PORTALFLAG_SKIP) + set_portal_flag(0x00cd, PORTALFLAG_SKIP) + set_portal_flag(0x00ce, PORTALFLAG_SKIP) + set_portal_flag(0x00d2, PORTALFLAG_SKIP) + set_portal_flag(0x00e0, PORTALFLAG_SKIP) + set_portal_flag(0x00dc, PORTALFLAG_SKIP) + set_portal_flag(0x00de, PORTALFLAG_SKIP) + set_portal_flag(0x00e3, PORTALFLAG_SKIP) + set_portal_flag(0x00e5, PORTALFLAG_SKIP) + set_portal_flag(0x00e7, PORTALFLAG_SKIP) + set_portal_flag(0x00fb, PORTALFLAG_SKIP) + set_portal_flag(0x00fa, PORTALFLAG_SKIP) + set_portal_flag(0x00fc, PORTALFLAG_SKIP) + set_portal_flag(0x00ff, PORTALFLAG_SKIP) + set_portal_flag(0x0100, PORTALFLAG_SKIP) + set_portal_flag(0x0103, PORTALFLAG_SKIP) + set_portal_flag(0x0102, PORTALFLAG_SKIP) + set_portal_flag(0x0104, PORTALFLAG_SKIP) + set_portal_flag(0x0109, PORTALFLAG_SKIP) + set_portal_flag(0x010c, PORTALFLAG_SKIP) + set_portal_flag(0x0119, PORTALFLAG_SKIP) + set_portal_flag(0x0112, PORTALFLAG_SKIP) + set_portal_flag(0x0117, PORTALFLAG_SKIP) + set_portal_flag(0x0120, PORTALFLAG_SKIP) + set_portal_flag(0x011e, PORTALFLAG_SKIP) + set_portal_flag(0x011c, PORTALFLAG_SKIP) + set_portal_flag(0x0108, PORTALFLAG_SKIP) + set_portal_flag(0x006f, PORTALFLAG_SKIP) + set_portal_flag(0x007d, PORTALFLAG_SKIP) + set_portal_flag(0x0080, PORTALFLAG_SKIP) + set_portal_flag(0x0081, PORTALFLAG_SKIP) + set_portal_flag(0x0075, PORTALFLAG_SKIP) + set_portal_flag(0x0078, PORTALFLAG_SKIP) + set_portal_flag(0x0079, PORTALFLAG_SKIP) + set_portal_flag(0x0006, PORTALFLAG_SKIP) + set_portal_flag(0x0004, PORTALFLAG_SKIP) + set_portal_flag(0x0008, PORTALFLAG_SKIP) + set_portal_flag(0x000a, PORTALFLAG_SKIP) + set_portal_flag(0x0001, PORTALFLAG_SKIP) + set_portal_flag(0x0005, PORTALFLAG_SKIP) + set_portal_flag(0x0000, PORTALFLAG_SKIP) + set_portal_flag(0x0003, PORTALFLAG_SKIP) + set_portal_flag(0x0007, PORTALFLAG_SKIP) + set_portal_flag(0x0013, PORTALFLAG_SKIP) + set_portal_flag(0x0009, PORTALFLAG_SKIP) + set_portal_flag(0x00b1, PORTALFLAG_SKIP) + set_portal_flag(0x00ef, PORTALFLAG_SKIP) + set_portal_flag(0x00ee, PORTALFLAG_SKIP) + set_portal_flag(0x0121, PORTALFLAG_SKIP) + set_portal_flag(0x00e8, PORTALFLAG_SKIP) + set_portal_flag(0x00e9, PORTALFLAG_SKIP) + set_portal_flag(0x00ea, PORTALFLAG_SKIP) + set_portal_flag(0x00ec, PORTALFLAG_SKIP) + set_portal_flag(0x00eb, PORTALFLAG_SKIP) + set_portal_flag(0x00ed, PORTALFLAG_SKIP) + set_portal_flag(0x009d, PORTALFLAG_SKIP) + set_portal_flag(0x00af, PORTALFLAG_SKIP) + set_portal_flag(0x00a1, PORTALFLAG_SKIP) + set_portal_flag(0x005a, PORTALFLAG_SKIP) + set_portal_flag(0x005c, PORTALFLAG_SKIP) + set_portal_flag(0x005d, PORTALFLAG_SKIP) + set_portal_flag(0x0060, PORTALFLAG_SKIP) + set_portal_flag(0x0034, PORTALFLAG_SKIP) + set_portal_flag(0x0030, PORTALFLAG_SKIP) + set_portal_flag(0x002e, PORTALFLAG_SKIP) + set_portal_flag(0x002b, PORTALFLAG_SKIP) + set_portal_flag(0x0028, PORTALFLAG_SKIP) + set_portal_flag(0x0025, PORTALFLAG_SKIP) + set_portal_flag(0x0036, PORTALFLAG_SKIP) + set_portal_flag(0x0038, PORTALFLAG_SKIP) + set_portal_flag(0x004f, PORTALFLAG_SKIP) + set_portal_flag(0x0051, PORTALFLAG_SKIP) + set_portal_flag(0x0052, PORTALFLAG_SKIP) + set_portal_flag(0x0057, PORTALFLAG_SKIP) + set_portal_flag(0x0058, PORTALFLAG_SKIP) + set_portal_flag(0x0031, PORTALFLAG_SKIP) + set_portal_flag(0x002f, PORTALFLAG_SKIP) + set_portal_flag(0x0023, PORTALFLAG_SKIP) + set_portal_flag(0x00a6, PORTALFLAG_SKIP) + set_portal_flag(0x00a3, PORTALFLAG_SKIP) + set_portal_flag(0x00a2, PORTALFLAG_SKIP) + set_portal_flag(0x00a4, PORTALFLAG_SKIP) + set_portal_flag(0x0087, PORTALFLAG_SKIP) + set_portal_flag(0x00b9, PORTALFLAG_SKIP) + set_portal_flag(0x00b4, PORTALFLAG_SKIP) + set_portal_flag(0x00b2, PORTALFLAG_SKIP) + set_portal_flag(0x00b3, PORTALFLAG_SKIP) + set_portal_flag(0x00bd, PORTALFLAG_SKIP) + set_portal_flag(0x00f4, PORTALFLAG_SKIP) + set_portal_flag(0x00f2, PORTALFLAG_SKIP) + set_portal_flag(0x00f0, PORTALFLAG_SKIP) + set_portal_flag(0x00f8, PORTALFLAG_SKIP) + set_portal_flag(0x00f1, PORTALFLAG_SKIP) set_ailist(CHR_SELF, GAILIST_IDLE) endlist }; diff --git a/src/files/setup/setupsho.c b/src/files/setup/setupsho.c index 6b0ffef38..d23774ec4 100644 --- a/src/files/setup/setupsho.c +++ b/src/files/setup/setupsho.c @@ -3923,9 +3923,13 @@ u8 func1025_unlock_doors_for_buddy[] = { endlist }; +/** + * Unblock the portal in the explosive wall to prevent a flicker + * where the room isn't rendered on the first frame after exploding. + */ u8 func1426_setup_portals[] = { yield - set_portal_flag(0x0072, 0x04) + set_portal_flag(0x0072, PORTALFLAG_FORCEUNBLOCKED) set_ailist(CHR_SELF, GAILIST_IDLE) endlist }; diff --git a/src/game/bg.c b/src/game/bg.c index f4e0a2ea3..9edb677d2 100644 --- a/src/game/bg.c +++ b/src/game/bg.c @@ -86,7 +86,7 @@ s32 var8007fc28 = 0; s32 var8007fc2c = 0; s32 var8007fc30 = 0x00000000; s32 var8007fc34 = 0x00000000; -u32 var8007fc38 = 0x00000000; +u32 g_BgNumRoomLoadCandidates = 0x00000000; u16 var8007fc3c = 0xfffe; s32 g_NumPortalThings = 0; u32 var8007fc44 = 0xffffffff; @@ -144,12 +144,12 @@ void func0f157e94(s32 roomnum, s32 draworder, struct screenbox *box) s32 index; #if VERSION < VERSION_NTSC_1_0 - g_Rooms[roomnum].flags |= ROOMFLAG_VISIBLEBYPLAYER; + g_Rooms[roomnum].flags |= ROOMFLAG_ONSCREEN; #endif - if ((g_Rooms[roomnum].flags & ROOMFLAG_FORCEDISABLED) == 0) { + if ((g_Rooms[roomnum].flags & ROOMFLAG_DISABLEDBYSCRIPT) == 0) { #if VERSION >= VERSION_NTSC_1_0 - g_Rooms[roomnum].flags |= ROOMFLAG_VISIBLEBYPLAYER; + g_Rooms[roomnum].flags |= ROOMFLAG_ONSCREEN; #endif if (g_Rooms[roomnum].flags & ROOMFLAG_0800) { @@ -2381,7 +2381,7 @@ Gfx *bgRenderSceneInXray(Gfx *gdl) room = prop->rooms; while (*room != -1) { - if (g_Rooms[*room].flags & ROOMFLAG_VISIBLEBYPLAYER) { + if (g_Rooms[*room].flags & ROOMFLAG_ONSCREEN) { *roomnumptr = *room; break; } @@ -2580,7 +2580,8 @@ Gfx *bgRenderScene(Gfx *gdl) // Build an array of room numbers per onscreen prop. // For each onscreen prop there is exactly one entry in the roomnumsbyprop array. - roomnumptr = roomnumsbyprop; if (var8007fc2c); + roomnumptr = roomnumsbyprop; \ + if (var8007fc2c); for (ptr = g_Vars.onscreenprops; ptr < g_Vars.endonscreenprops; ptr++) { *roomnumptr = 0; @@ -2590,7 +2591,7 @@ Gfx *bgRenderScene(Gfx *gdl) room = prop->rooms; while (*room != -1) { - if (g_Rooms[*room].flags & ROOMFLAG_VISIBLEBYPLAYER) { + if (g_Rooms[*room].flags & ROOMFLAG_ONSCREEN) { *roomnumptr = *room; break; } @@ -8081,40 +8082,40 @@ void boxCopy(struct screenbox *dst, struct screenbox *src) dst->ymax = src->ymax; } -bool roomIsVisibleByAnyPlayer(s32 room) +bool roomIsOnScreen(s32 room) { if (g_Vars.mplayerisrunning) { return (g_MpRoomVisibility[room] & 0xf) != 0; } - return g_Rooms[room].flags & ROOMFLAG_VISIBLEBYPLAYER; + return g_Rooms[room].flags & ROOMFLAG_ONSCREEN; } -bool roomIsVisibleByAnyAibot(s32 room) +bool roomIsOnStandby(s32 room) { if (g_Vars.mplayerisrunning) { return (g_MpRoomVisibility[room] & 0xf0) != 0; } - return g_Rooms[room].flags & ROOMFLAG_VISIBLEBYAIBOT; + return g_Rooms[room].flags & ROOMFLAG_STANDBY; } -bool roomIsVisibleByPlayer(s32 room, u32 playernum) +bool roomIsOnPlayerScreen(s32 room, u32 playernum) { if (g_Vars.mplayerisrunning) { return (g_MpRoomVisibility[room] & (1 << playernum)) != 0; } - return g_Rooms[room].flags & ROOMFLAG_VISIBLEBYPLAYER; + return g_Rooms[room].flags & ROOMFLAG_ONSCREEN; } -bool roomIsVisibleByAibot(s32 room, u32 aibotindex) +bool roomIsOnPlayerStandby(s32 room, u32 playernum) { if (g_Vars.mplayerisrunning) { - return (g_MpRoomVisibility[room] & (0x10 << aibotindex)) != 0; + return (g_MpRoomVisibility[room] & (0x10 << playernum)) != 0; } - return g_Rooms[room].flags & ROOMFLAG_VISIBLEBYAIBOT; + return g_Rooms[room].flags & ROOMFLAG_STANDBY; } s32 portalFindNumByVertices(struct portalvertices *arg0) @@ -9819,7 +9820,7 @@ void bgTickRooms(void) g_Rooms[i].loaded240 = g_BgUnloadDelay240; } - if (g_Rooms[i].flags & ROOMFLAG_VISIBLEBYPLAYER) { + if (g_Rooms[i].flags & ROOMFLAG_ONSCREEN) { g_Rooms[i].loaded240 = 1; } @@ -14216,8 +14217,8 @@ glabel var7f1b76bc // break; // case PORTALCMD_1F: // 1f - f162858 - set visibility to same as portal X // if (execute) { -// if ((g_BgPortals[cmd[1].param].flags & PORTALFLAG_ENABLED) == 0 -// || (g_BgPortals[cmd[1].param].flags & PORTALFLAG_04)) { +// if ((g_BgPortals[cmd[1].param].flags & PORTALFLAG_BLOCKED) == 0 +// || (g_BgPortals[cmd[1].param].flags & PORTALFLAG_FORCEUNBLOCKED)) { // if (portal0f15d10c(cmd[1].param, &var800a65c8) == 0) { // g_PortalMode = PORTALMODE_HIDE; // } else if (boxGetIntersection(&var800a65c0, &var800a65c8) == 0) { @@ -14231,8 +14232,8 @@ glabel var7f1b76bc // break; // case PORTALCMD_22: // 22 - f1628d4 - make visible if portal can view room // if (execute) { -// if ((g_BgPortals[cmd[1].param].flags & PORTALFLAG_ENABLED) == 0 -// || (g_BgPortals[cmd[1].param].flags & PORTALFLAG_04)) { +// if ((g_BgPortals[cmd[1].param].flags & PORTALFLAG_BLOCKED) == 0 +// || (g_BgPortals[cmd[1].param].flags & PORTALFLAG_FORCEUNBLOCKED)) { // struct screenbox box1; // if (portal0f15d10c(cmd[1].param, &box1) && boxGetIntersection(&var800a65c0, &box1)) { // if (g_PortalMode != PORTALMODE_SHOW) { @@ -14250,8 +14251,8 @@ glabel var7f1b76bc // if (execute) { // if (g_PortalMode == PORTALMODE_SHOW) { // struct screenbox box2; -// if ((g_BgPortals[cmd[1].param].flags & PORTALFLAG_ENABLED) -// && (g_BgPortals[cmd[1].param].flags & PORTALFLAG_04) == 0) { +// if ((g_BgPortals[cmd[1].param].flags & PORTALFLAG_BLOCKED) +// && (g_BgPortals[cmd[1].param].flags & PORTALFLAG_FORCEUNBLOCKED) == 0) { // g_PortalMode = PORTALMODE_HIDE; // } else if (portal0f15d10c(cmd[1].param, &box2) == 0) { // g_PortalMode = PORTALMODE_HIDE; @@ -14275,7 +14276,7 @@ glabel var7f1b76bc // break; // case PORTALCMD_DISABLEROOM: // 24 - f162a70 // if (execute) { -// g_Rooms[cmd[1].param].flags |= ROOMFLAG_FORCEDISABLED; +// g_Rooms[cmd[1].param].flags |= ROOMFLAG_DISABLEDBYSCRIPT; // } // cmd += cmd->len; // break; @@ -14284,7 +14285,7 @@ glabel var7f1b76bc // s32 i; // // for (i = cmd[1].param; i <= cmd[2].param; i++) { -// g_Rooms[i].flags |= ROOMFLAG_FORCEDISABLED; +// g_Rooms[i].flags |= ROOMFLAG_DISABLEDBYSCRIPT; // } // } // cmd += cmd->len; @@ -14303,8 +14304,8 @@ glabel var7f1b76bc // break; // case PORTALCMD_29: // 29 - f162b58 - copy visible state (true/false) of portal X to stack // if (execute) { -// portalPushValue((g_BgPortals[cmd[1].param].flags & PORTALFLAG_ENABLED) == 0 -// || !((g_BgPortals[cmd[1].param].flags & PORTALFLAG_04) == 0)); +// portalPushValue((g_BgPortals[cmd[1].param].flags & PORTALFLAG_BLOCKED) == 0 +// || !((g_BgPortals[cmd[1].param].flags & PORTALFLAG_FORCEUNBLOCKED) == 0)); // } // cmd += cmd->len; // break; @@ -14711,7 +14712,7 @@ glabel func0f162d9c /* f163290: 1420ff60 */ bnez $at,.L0f163014 /* f163294: 2673008c */ addiu $s3,$s3,0x8c .L0f163298: -/* f163298: 0fc58e5f */ jal func0f16397c +/* f163298: 0fc58e5f */ jal bgChooseRoomsToLoad /* f16329c: 00000000 */ nop /* f1632a0: 8fbf0044 */ lw $ra,0x44($sp) /* f1632a4: d7b40018 */ ldc1 $f20,0x18($sp) @@ -14734,7 +14735,7 @@ void func0f1632d4(s16 roomnum1, s16 roomnum2, s16 draworder, struct screenbox *b s32 i; s32 j; - if (g_Rooms[roomnum2].flags & ROOMFLAG_FORCEDISABLED) { + if (g_Rooms[roomnum2].flags & ROOMFLAG_DISABLEDBYSCRIPT) { return; } @@ -14875,8 +14876,8 @@ void func0f163528(struct var800a4d00 *arg0) s6 = s0; } - if ((g_BgPortals[portalnum].flags & PORTALFLAG_ENABLED) - && (g_BgPortals[portalnum].flags & PORTALFLAG_04) == 0) { + if ((g_BgPortals[portalnum].flags & PORTALFLAG_BLOCKED) + && (g_BgPortals[portalnum].flags & PORTALFLAG_FORCEUNBLOCKED) == 0) { continue; } @@ -14939,332 +14940,114 @@ bool func0f163904(void) return true; } -GLOBAL_ASM( -glabel func0f16397c -/* f16397c: 27bdff88 */ addiu $sp,$sp,-120 -/* f163980: afb70030 */ sw $s7,0x30($sp) -/* f163984: 3c17800a */ lui $s7,%hi(g_BgPortals) -/* f163988: 26f74cc8 */ addiu $s7,$s7,%lo(g_BgPortals) -/* f16398c: afb00014 */ sw $s0,0x14($sp) -/* f163990: 8eea0000 */ lw $t2,0x0($s7) -/* f163994: 3c108008 */ lui $s0,%hi(var8007fc38) -/* f163998: 2610fc38 */ addiu $s0,$s0,%lo(var8007fc38) -/* f16399c: afbf0034 */ sw $ra,0x34($sp) -/* f1639a0: afb6002c */ sw $s6,0x2c($sp) -/* f1639a4: afb50028 */ sw $s5,0x28($sp) -/* f1639a8: afb40024 */ sw $s4,0x24($sp) -/* f1639ac: afb30020 */ sw $s3,0x20($sp) -/* f1639b0: afb2001c */ sw $s2,0x1c($sp) -/* f1639b4: afb10018 */ sw $s1,0x18($sp) -/* f1639b8: ae000000 */ sw $zero,0x0($s0) -/* f1639bc: 954e0000 */ lhu $t6,0x0($t2) -/* f1639c0: 0000a825 */ or $s5,$zero,$zero -/* f1639c4: 3c16800a */ lui $s6,%hi(g_Rooms) -/* f1639c8: 11c000d0 */ beqz $t6,.L0f163d0c -/* f1639cc: 01401825 */ or $v1,$t2,$zero -/* f1639d0: 3c14800a */ lui $s4,%hi(g_RoomPortals) -/* f1639d4: 26944ce0 */ addiu $s4,$s4,%lo(g_RoomPortals) -/* f1639d8: 26d64928 */ addiu $s6,$s6,%lo(g_Rooms) -/* f1639dc: 2411008c */ addiu $s1,$zero,0x8c -/* f1639e0: 906f0006 */ lbu $t7,0x6($v1) -.L0f1639e4: -/* f1639e4: 31f80008 */ andi $t8,$t7,0x8 -/* f1639e8: 570000c4 */ bnezl $t8,.L0f163cfc -/* f1639ec: 946e0008 */ lhu $t6,0x8($v1) -/* f1639f0: 84730002 */ lh $s3,0x2($v1) -/* f1639f4: 8ec50000 */ lw $a1,0x0($s6) -/* f1639f8: 84720004 */ lh $s2,0x4($v1) -/* f1639fc: 02710019 */ multu $s3,$s1 -/* f163a00: 00006012 */ mflo $t4 -/* f163a04: 00ac4021 */ addu $t0,$a1,$t4 -/* f163a08: 95020000 */ lhu $v0,0x0($t0) -/* f163a0c: 30440004 */ andi $a0,$v0,0x4 -/* f163a10: 1080005b */ beqz $a0,.L0f163b80 -/* f163a14: 00000000 */ nop -/* f163a18: 02510019 */ multu $s2,$s1 -/* f163a1c: 00005812 */ mflo $t3 -/* f163a20: 00ab3021 */ addu $a2,$a1,$t3 -/* f163a24: 94c70000 */ lhu $a3,0x0($a2) -/* f163a28: 30f90004 */ andi $t9,$a3,0x4 -/* f163a2c: 17200054 */ bnez $t9,.L0f163b80 -/* f163a30: 34ed0008 */ ori $t5,$a3,0x8 -/* f163a34: a4cd0000 */ sh $t5,0x0($a2) -/* f163a38: 8ece0000 */ lw $t6,0x0($s6) -/* f163a3c: 02402025 */ or $a0,$s2,$zero -/* f163a40: 24050001 */ addiu $a1,$zero,0x1 -/* f163a44: 01cb3021 */ addu $a2,$t6,$t3 -/* f163a48: 84cf0002 */ lh $t7,0x2($a2) -/* f163a4c: 15e00007 */ bnez $t7,.L0f163a6c -/* f163a50: 00000000 */ nop -/* f163a54: 94d80000 */ lhu $t8,0x0($a2) -/* f163a58: 37190020 */ ori $t9,$t8,0x20 -/* f163a5c: a4d90000 */ sh $t9,0x0($a2) -/* f163a60: 8e0d0000 */ lw $t5,0x0($s0) -/* f163a64: 25ae0001 */ addiu $t6,$t5,0x1 -/* f163a68: ae0e0000 */ sw $t6,0x0($s0) -.L0f163a6c: -/* f163a6c: 0fc55f6c */ jal roomUnpauseProps -/* f163a70: afab003c */ sw $t3,0x3c($sp) -/* f163a74: 8eea0000 */ lw $t2,0x0($s7) -/* f163a78: 8fab003c */ lw $t3,0x3c($sp) -/* f163a7c: 01551821 */ addu $v1,$t2,$s5 -/* f163a80: 90620006 */ lbu $v0,0x6($v1) -/* f163a84: 304f0001 */ andi $t7,$v0,0x1 -/* f163a88: 11e0009b */ beqz $t7,.L0f163cf8 -/* f163a8c: 30580004 */ andi $t8,$v0,0x4 -/* f163a90: 5700009a */ bnezl $t8,.L0f163cfc -/* f163a94: 946e0008 */ lhu $t6,0x8($v1) -/* f163a98: 8ec50000 */ lw $a1,0x0($s6) -/* f163a9c: 00004825 */ or $t1,$zero,$zero -/* f163aa0: 00003825 */ or $a3,$zero,$zero -/* f163aa4: 00ab3021 */ addu $a2,$a1,$t3 -/* f163aa8: 80c80005 */ lb $t0,0x5($a2) -/* f163aac: 59000093 */ blezl $t0,.L0f163cfc -/* f163ab0: 946e0008 */ lhu $t6,0x8($v1) -.L0f163ab4: -/* f163ab4: 84cd000e */ lh $t5,0xe($a2) -/* f163ab8: 8e990000 */ lw $t9,0x0($s4) -/* f163abc: 25290001 */ addiu $t1,$t1,0x1 -/* f163ac0: 000d7040 */ sll $t6,$t5,0x1 -/* f163ac4: 032e7821 */ addu $t7,$t9,$t6 -/* f163ac8: 01e7c021 */ addu $t8,$t7,$a3 -/* f163acc: 87020000 */ lh $v0,0x0($t8) -/* f163ad0: 000268c0 */ sll $t5,$v0,0x3 -/* f163ad4: 014d2021 */ addu $a0,$t2,$t5 -/* f163ad8: 84830002 */ lh $v1,0x2($a0) -/* f163adc: 16430013 */ bne $s2,$v1,.L0f163b2c -/* f163ae0: 00000000 */ nop -/* f163ae4: 84990004 */ lh $t9,0x4($a0) -/* f163ae8: 03310019 */ multu $t9,$s1 -/* f163aec: 00007012 */ mflo $t6 -/* f163af0: 00ae1021 */ addu $v0,$a1,$t6 -/* f163af4: 844f0002 */ lh $t7,0x2($v0) -/* f163af8: 55e0001d */ bnezl $t7,.L0f163b70 -/* f163afc: 0128082a */ slt $at,$t1,$t0 -/* f163b00: 94580000 */ lhu $t8,0x0($v0) -/* f163b04: 370d0020 */ ori $t5,$t8,0x20 -/* f163b08: a44d0000 */ sh $t5,0x0($v0) -/* f163b0c: 8e190000 */ lw $t9,0x0($s0) -/* f163b10: 8ec50000 */ lw $a1,0x0($s6) -/* f163b14: 8eea0000 */ lw $t2,0x0($s7) -/* f163b18: 272e0001 */ addiu $t6,$t9,0x1 -/* f163b1c: ae0e0000 */ sw $t6,0x0($s0) -/* f163b20: 00ab3021 */ addu $a2,$a1,$t3 -/* f163b24: 10000011 */ b .L0f163b6c -/* f163b28: 80c80005 */ lb $t0,0x5($a2) -.L0f163b2c: -/* f163b2c: 00710019 */ multu $v1,$s1 -/* f163b30: 00007812 */ mflo $t7 -/* f163b34: 00af1021 */ addu $v0,$a1,$t7 -/* f163b38: 84580002 */ lh $t8,0x2($v0) -/* f163b3c: 5700000c */ bnezl $t8,.L0f163b70 -/* f163b40: 0128082a */ slt $at,$t1,$t0 -/* f163b44: 944d0000 */ lhu $t5,0x0($v0) -/* f163b48: 35b90020 */ ori $t9,$t5,0x20 -/* f163b4c: a4590000 */ sh $t9,0x0($v0) -/* f163b50: 8e0e0000 */ lw $t6,0x0($s0) -/* f163b54: 8ec50000 */ lw $a1,0x0($s6) -/* f163b58: 8eea0000 */ lw $t2,0x0($s7) -/* f163b5c: 25cf0001 */ addiu $t7,$t6,0x1 -/* f163b60: ae0f0000 */ sw $t7,0x0($s0) -/* f163b64: 00ab3021 */ addu $a2,$a1,$t3 -/* f163b68: 80c80005 */ lb $t0,0x5($a2) -.L0f163b6c: -/* f163b6c: 0128082a */ slt $at,$t1,$t0 -.L0f163b70: -/* f163b70: 1420ffd0 */ bnez $at,.L0f163ab4 -/* f163b74: 24e70002 */ addiu $a3,$a3,0x2 -/* f163b78: 1000005f */ b .L0f163cf8 -/* f163b7c: 01551821 */ addu $v1,$t2,$s5 -.L0f163b80: -/* f163b80: 02510019 */ multu $s2,$s1 -/* f163b84: 0000c012 */ mflo $t8 -/* f163b88: 00b86821 */ addu $t5,$a1,$t8 -/* f163b8c: 95b90000 */ lhu $t9,0x0($t5) -/* f163b90: 332e0004 */ andi $t6,$t9,0x4 -/* f163b94: 51c00059 */ beqzl $t6,.L0f163cfc -/* f163b98: 946e0008 */ lhu $t6,0x8($v1) -/* f163b9c: 14800056 */ bnez $a0,.L0f163cf8 -/* f163ba0: 344f0008 */ ori $t7,$v0,0x8 -/* f163ba4: a50f0000 */ sh $t7,0x0($t0) -/* f163ba8: 8ed80000 */ lw $t8,0x0($s6) -/* f163bac: 02602025 */ or $a0,$s3,$zero -/* f163bb0: 24050001 */ addiu $a1,$zero,0x1 -/* f163bb4: 030c4021 */ addu $t0,$t8,$t4 -/* f163bb8: 850d0002 */ lh $t5,0x2($t0) -/* f163bbc: 15a00007 */ bnez $t5,.L0f163bdc -/* f163bc0: 00000000 */ nop -/* f163bc4: 95190000 */ lhu $t9,0x0($t0) -/* f163bc8: 372e0020 */ ori $t6,$t9,0x20 -/* f163bcc: a50e0000 */ sh $t6,0x0($t0) -/* f163bd0: 8e0f0000 */ lw $t7,0x0($s0) -/* f163bd4: 25f80001 */ addiu $t8,$t7,0x1 -/* f163bd8: ae180000 */ sw $t8,0x0($s0) -.L0f163bdc: -/* f163bdc: 0fc55f6c */ jal roomUnpauseProps -/* f163be0: afac0048 */ sw $t4,0x48($sp) -/* f163be4: 8eea0000 */ lw $t2,0x0($s7) -/* f163be8: 8fac0048 */ lw $t4,0x48($sp) -/* f163bec: 01551821 */ addu $v1,$t2,$s5 -/* f163bf0: 90620006 */ lbu $v0,0x6($v1) -/* f163bf4: 304d0001 */ andi $t5,$v0,0x1 -/* f163bf8: 11a0003f */ beqz $t5,.L0f163cf8 -/* f163bfc: 30590004 */ andi $t9,$v0,0x4 -/* f163c00: 5720003e */ bnezl $t9,.L0f163cfc -/* f163c04: 946e0008 */ lhu $t6,0x8($v1) -/* f163c08: 8ec50000 */ lw $a1,0x0($s6) -/* f163c0c: 00004825 */ or $t1,$zero,$zero -/* f163c10: 00003825 */ or $a3,$zero,$zero -/* f163c14: 00ac4021 */ addu $t0,$a1,$t4 -/* f163c18: 81060005 */ lb $a2,0x5($t0) -/* f163c1c: 58c00037 */ blezl $a2,.L0f163cfc -/* f163c20: 946e0008 */ lhu $t6,0x8($v1) -.L0f163c24: -/* f163c24: 850f000e */ lh $t7,0xe($t0) -/* f163c28: 8e8e0000 */ lw $t6,0x0($s4) -/* f163c2c: 25290001 */ addiu $t1,$t1,0x1 -/* f163c30: 000fc040 */ sll $t8,$t7,0x1 -/* f163c34: 01d86821 */ addu $t5,$t6,$t8 -/* f163c38: 01a7c821 */ addu $t9,$t5,$a3 -/* f163c3c: 87220000 */ lh $v0,0x0($t9) -/* f163c40: 000278c0 */ sll $t7,$v0,0x3 -/* f163c44: 014f2021 */ addu $a0,$t2,$t7 -/* f163c48: 84830002 */ lh $v1,0x2($a0) -/* f163c4c: 16630012 */ bne $s3,$v1,.L0f163c98 -/* f163c50: 00000000 */ nop -/* f163c54: 00710019 */ multu $v1,$s1 -/* f163c58: 00007012 */ mflo $t6 -/* f163c5c: 00ae1021 */ addu $v0,$a1,$t6 -/* f163c60: 84580002 */ lh $t8,0x2($v0) -/* f163c64: 57000021 */ bnezl $t8,.L0f163cec -/* f163c68: 0126082a */ slt $at,$t1,$a2 -/* f163c6c: 944d0000 */ lhu $t5,0x0($v0) -/* f163c70: 35b90020 */ ori $t9,$t5,0x20 -/* f163c74: a4590000 */ sh $t9,0x0($v0) -/* f163c78: 8e0f0000 */ lw $t7,0x0($s0) -/* f163c7c: 8ec50000 */ lw $a1,0x0($s6) -/* f163c80: 8eea0000 */ lw $t2,0x0($s7) -/* f163c84: 25ee0001 */ addiu $t6,$t7,0x1 -/* f163c88: ae0e0000 */ sw $t6,0x0($s0) -/* f163c8c: 00ac4021 */ addu $t0,$a1,$t4 -/* f163c90: 10000015 */ b .L0f163ce8 -/* f163c94: 81060005 */ lb $a2,0x5($t0) -.L0f163c98: -/* f163c98: 00710019 */ multu $v1,$s1 -/* f163c9c: 0000c012 */ mflo $t8 -/* f163ca0: 00b86821 */ addu $t5,$a1,$t8 -/* f163ca4: 85b90002 */ lh $t9,0x2($t5) -/* f163ca8: 57200010 */ bnezl $t9,.L0f163cec -/* f163cac: 0126082a */ slt $at,$t1,$a2 -/* f163cb0: 848f0004 */ lh $t7,0x4($a0) -/* f163cb4: 01f10019 */ multu $t7,$s1 -/* f163cb8: 00007012 */ mflo $t6 -/* f163cbc: 00ae1021 */ addu $v0,$a1,$t6 -/* f163cc0: 94580000 */ lhu $t8,0x0($v0) -/* f163cc4: 370d0020 */ ori $t5,$t8,0x20 -/* f163cc8: a44d0000 */ sh $t5,0x0($v0) -/* f163ccc: 8e190000 */ lw $t9,0x0($s0) -/* f163cd0: 8ec50000 */ lw $a1,0x0($s6) -/* f163cd4: 8eea0000 */ lw $t2,0x0($s7) -/* f163cd8: 272f0001 */ addiu $t7,$t9,0x1 -/* f163cdc: ae0f0000 */ sw $t7,0x0($s0) -/* f163ce0: 00ac4021 */ addu $t0,$a1,$t4 -/* f163ce4: 81060005 */ lb $a2,0x5($t0) -.L0f163ce8: -/* f163ce8: 0126082a */ slt $at,$t1,$a2 -.L0f163cec: -/* f163cec: 1420ffcd */ bnez $at,.L0f163c24 -/* f163cf0: 24e70002 */ addiu $a3,$a3,0x2 -/* f163cf4: 01551821 */ addu $v1,$t2,$s5 -.L0f163cf8: -/* f163cf8: 946e0008 */ lhu $t6,0x8($v1) -.L0f163cfc: -/* f163cfc: 26b50008 */ addiu $s5,$s5,0x8 -/* f163d00: 24630008 */ addiu $v1,$v1,0x8 -/* f163d04: 55c0ff37 */ bnezl $t6,.L0f1639e4 -/* f163d08: 906f0006 */ lbu $t7,0x6($v1) -.L0f163d0c: -/* f163d0c: 3c08800a */ lui $t0,%hi(g_Vars) -/* f163d10: 25089fc0 */ addiu $t0,$t0,%lo(g_Vars) -/* f163d14: 8d180314 */ lw $t8,0x314($t0) -/* f163d18: 3c16800a */ lui $s6,%hi(g_Rooms) -/* f163d1c: 26d64928 */ addiu $s6,$s6,%lo(g_Rooms) -/* f163d20: 13000039 */ beqz $t8,.L0f163e08 -/* f163d24: 240d0001 */ addiu $t5,$zero,0x1 -/* f163d28: 8d02028c */ lw $v0,0x28c($t0) -/* f163d2c: 8d1802bc */ lw $t8,0x2bc($t0) -/* f163d30: 240f0010 */ addiu $t7,$zero,0x10 -/* f163d34: 004d2804 */ sllv $a1,$t5,$v0 -/* f163d38: 004f4804 */ sllv $t1,$t7,$v0 -/* f163d3c: 30b900ff */ andi $t9,$a1,0xff -/* f163d40: 312e00ff */ andi $t6,$t1,0xff -/* f163d44: 1b000030 */ blez $t8,.L0f163e08 -/* f163d48: 00001825 */ or $v1,$zero,$zero -/* f163d4c: 3c05800a */ lui $a1,%hi(g_MpRoomVisibility) -/* f163d50: 24a5492c */ addiu $a1,$a1,%lo(g_MpRoomVisibility) -/* f163d54: 00002025 */ or $a0,$zero,$zero -/* f163d58: 03203025 */ or $a2,$t9,$zero -/* f163d5c: 01c03825 */ or $a3,$t6,$zero -/* f163d60: 8ecd0000 */ lw $t5,0x0($s6) -.L0f163d64: -/* f163d64: 01a4c821 */ addu $t9,$t5,$a0 -/* f163d68: 972f0000 */ lhu $t7,0x0($t9) -/* f163d6c: 31ee0004 */ andi $t6,$t7,0x4 -/* f163d70: 51c00008 */ beqzl $t6,.L0f163d94 -/* f163d74: 8caf0000 */ lw $t7,0x0($a1) -/* f163d78: 8cb80000 */ lw $t8,0x0($a1) -/* f163d7c: 03031021 */ addu $v0,$t8,$v1 -/* f163d80: 904d0000 */ lbu $t5,0x0($v0) -/* f163d84: 01a6c825 */ or $t9,$t5,$a2 -/* f163d88: 10000007 */ b .L0f163da8 -/* f163d8c: a0590000 */ sb $t9,0x0($v0) -/* f163d90: 8caf0000 */ lw $t7,0x0($a1) -.L0f163d94: -/* f163d94: 00c0c027 */ nor $t8,$a2,$zero -/* f163d98: 01e31021 */ addu $v0,$t7,$v1 -/* f163d9c: 904e0000 */ lbu $t6,0x0($v0) -/* f163da0: 01d86824 */ and $t5,$t6,$t8 -/* f163da4: a04d0000 */ sb $t5,0x0($v0) -.L0f163da8: -/* f163da8: 8ed90000 */ lw $t9,0x0($s6) -/* f163dac: 03247821 */ addu $t7,$t9,$a0 -/* f163db0: 95ee0000 */ lhu $t6,0x0($t7) -/* f163db4: 31d80008 */ andi $t8,$t6,0x8 -/* f163db8: 53000008 */ beqzl $t8,.L0f163ddc -/* f163dbc: 8cae0000 */ lw $t6,0x0($a1) -/* f163dc0: 8cad0000 */ lw $t5,0x0($a1) -/* f163dc4: 01a31021 */ addu $v0,$t5,$v1 -/* f163dc8: 90590000 */ lbu $t9,0x0($v0) -/* f163dcc: 03277825 */ or $t7,$t9,$a3 -/* f163dd0: 10000007 */ b .L0f163df0 -/* f163dd4: a04f0000 */ sb $t7,0x0($v0) -/* f163dd8: 8cae0000 */ lw $t6,0x0($a1) -.L0f163ddc: -/* f163ddc: 00e06827 */ nor $t5,$a3,$zero -/* f163de0: 01c31021 */ addu $v0,$t6,$v1 -/* f163de4: 90580000 */ lbu $t8,0x0($v0) -/* f163de8: 030dc824 */ and $t9,$t8,$t5 -/* f163dec: a0590000 */ sb $t9,0x0($v0) -.L0f163df0: -/* f163df0: 8d0f02bc */ lw $t7,0x2bc($t0) -/* f163df4: 24630001 */ addiu $v1,$v1,0x1 -/* f163df8: 2484008c */ addiu $a0,$a0,0x8c -/* f163dfc: 006f082a */ slt $at,$v1,$t7 -/* f163e00: 5420ffd8 */ bnezl $at,.L0f163d64 -/* f163e04: 8ecd0000 */ lw $t5,0x0($s6) -.L0f163e08: -/* f163e08: 8fbf0034 */ lw $ra,0x34($sp) -/* f163e0c: 8fb00014 */ lw $s0,0x14($sp) -/* f163e10: 8fb10018 */ lw $s1,0x18($sp) -/* f163e14: 8fb2001c */ lw $s2,0x1c($sp) -/* f163e18: 8fb30020 */ lw $s3,0x20($sp) -/* f163e1c: 8fb40024 */ lw $s4,0x24($sp) -/* f163e20: 8fb50028 */ lw $s5,0x28($sp) -/* f163e24: 8fb6002c */ lw $s6,0x2c($sp) -/* f163e28: 8fb70030 */ lw $s7,0x30($sp) -/* f163e2c: 03e00008 */ jr $ra -/* f163e30: 27bd0078 */ addiu $sp,$sp,0x78 -); +/** + * Choose which rooms should be placed on standby and which are candidates for + * loading. + * + * All offscreen neighbours of onscreen rooms are placed on standby and are + * nominated for loading. Any tinted glass in these rooms will be unpaused. + * + * If the portal between the onscreen room and the offscreen room is blocked + * (ie. a closed door or opaque glass) then nominate the neighbours of the + * offscreen room for loading too. This is necessary because opening the door or + * destroying the glass may make many rooms visible at once, and only one room + * is loaded per tick. + */ +void bgChooseRoomsToLoad(void) +{ + s32 i; + s32 j; + u32 stack; + + g_BgNumRoomLoadCandidates = 0; + + for (i = 0; g_BgPortals[i].verticesoffset != 0; i++) { + if ((g_BgPortals[i].flags & PORTALFLAG_SKIP) == 0) { + s32 roomnum1 = g_BgPortals[i].roomnum1; + s32 roomnum2 = g_BgPortals[i].roomnum2; + s32 portalnum; + + if ((g_Rooms[roomnum1].flags & ROOMFLAG_ONSCREEN) && (g_Rooms[roomnum2].flags & ROOMFLAG_ONSCREEN) == 0) { + // From room1 to room2 + g_Rooms[roomnum2].flags |= ROOMFLAG_STANDBY; + + if (g_Rooms[roomnum2].loaded240 == 0) { + g_Rooms[roomnum2].flags |= ROOMFLAG_LOADCANDIDATE; + g_BgNumRoomLoadCandidates++; + } + + roomUnpauseProps(roomnum2, true); + + if ((g_BgPortals[i].flags & PORTALFLAG_BLOCKED) && (g_BgPortals[i].flags & PORTALFLAG_FORCEUNBLOCKED) == 0) { + for (j = 0; j < g_Rooms[roomnum2].numportals; j++) { + portalnum = g_RoomPortals[g_Rooms[roomnum2].roomportallistoffset + j]; + + if (roomnum2 == g_BgPortals[portalnum].roomnum1) { + if (g_Rooms[g_BgPortals[portalnum].roomnum2].loaded240 == 0) { + g_Rooms[g_BgPortals[portalnum].roomnum2].flags |= ROOMFLAG_LOADCANDIDATE; + g_BgNumRoomLoadCandidates++; + } + } else { + if (g_Rooms[g_BgPortals[portalnum].roomnum1].loaded240 == 0) { + g_Rooms[g_BgPortals[portalnum].roomnum1].flags |= ROOMFLAG_LOADCANDIDATE; + g_BgNumRoomLoadCandidates++; + } + } + } + } + } else if ((g_Rooms[roomnum2].flags & ROOMFLAG_ONSCREEN) + && (g_Rooms[roomnum1].flags & ROOMFLAG_ONSCREEN) == 0) { + // From room2 to room1 + g_Rooms[roomnum1].flags |= ROOMFLAG_STANDBY; + + if (g_Rooms[roomnum1].loaded240 == 0) { + g_Rooms[roomnum1].flags |= ROOMFLAG_LOADCANDIDATE; + g_BgNumRoomLoadCandidates++; + } + + roomUnpauseProps(roomnum1, true); + + if ((g_BgPortals[i].flags & PORTALFLAG_BLOCKED) && (g_BgPortals[i].flags & PORTALFLAG_FORCEUNBLOCKED) == 0) { + for (j = 0; j < g_Rooms[roomnum1].numportals; j++) { + portalnum = g_RoomPortals[g_Rooms[roomnum1].roomportallistoffset + j]; + + if (roomnum1 == g_BgPortals[portalnum].roomnum1) { + if (g_Rooms[g_BgPortals[portalnum].roomnum1].loaded240 == 0) { + g_Rooms[g_BgPortals[portalnum].roomnum1].flags |= ROOMFLAG_LOADCANDIDATE; + g_BgNumRoomLoadCandidates++; + } + } else { + if (g_Rooms[g_BgPortals[portalnum].roomnum1].loaded240 == 0) { + g_Rooms[g_BgPortals[portalnum].roomnum2].flags |= ROOMFLAG_LOADCANDIDATE; + g_BgNumRoomLoadCandidates++; + } + } + } + } + } + } + } + + // Update visibility per player + if (g_Vars.mplayerisrunning) { + u8 flag1 = 0x01 << g_Vars.currentplayernum; + u8 flag2 = 0x10 << g_Vars.currentplayernum; + + for (i = 0; i < g_Vars.roomcount; i++) { + if (g_Rooms[i].flags & ROOMFLAG_ONSCREEN) { + g_MpRoomVisibility[i] |= flag1; + } else { + g_MpRoomVisibility[i] &= ~flag1; + } + + if (g_Rooms[i].flags & ROOMFLAG_STANDBY) { + g_MpRoomVisibility[i] |= flag2; + } else { + g_MpRoomVisibility[i] &= ~flag2; + } + } + } +} void bgTickPortals(void) { @@ -15284,7 +15067,7 @@ void bgTickPortals(void) var800a4cf0.zrange.far = var800a4cf0.zrange.far / g_Vars.currentplayerstats->scale_bg2gfx; for (i = 0; i < g_Vars.roomcount; i++) { - g_Rooms[i].flags &= ~(ROOMFLAG_FORCEDISABLED | ROOMFLAG_VISIBLEBYPLAYER | ROOMFLAG_VISIBLEBYAIBOT | ROOMFLAG_0020); + g_Rooms[i].flags &= ~(ROOMFLAG_DISABLEDBYSCRIPT | ROOMFLAG_ONSCREEN | ROOMFLAG_STANDBY | ROOMFLAG_LOADCANDIDATE); g_Rooms[i].portalrecursioncount = 0; g_Rooms[i].unk06 = 0; g_Rooms[i].unk07 = 1; @@ -15336,7 +15119,7 @@ void bgTickPortals(void) } } - func0f16397c(); + bgChooseRoomsToLoad(); } } @@ -15353,6 +15136,7 @@ Gfx *func0f164150(Gfx *gdl) var8007fc28 = 0; } + // Consider loading one room by finding the load candidate that is closest to the player if (var8007fc28 == 0 && var8007fc10 == 4 && g_Vars.tickmode == TICKMODE_NORMAL && IS8MB()) { struct player *player = g_Vars.currentplayer; s32 i; @@ -15362,9 +15146,9 @@ Gfx *func0f164150(Gfx *gdl) s32 bestroomnum = 0; f32 radius; - if (var8007fc38) { + if (g_BgNumRoomLoadCandidates) { for (i = 1; i < g_Vars.roomcount; i++) { - if (!g_Rooms[i].loaded240 && (g_Rooms[i].flags & ROOMFLAG_0020)) { + if (!g_Rooms[i].loaded240 && (g_Rooms[i].flags & ROOMFLAG_LOADCANDIDATE)) { dist.x = g_Vars.currentplayer->prop->pos.x - g_Rooms[i].centre.x; dist.y = g_Vars.currentplayer->prop->pos.y - g_Rooms[i].centre.y; dist.z = g_Vars.currentplayer->prop->pos.z - g_Rooms[i].centre.z; @@ -15705,9 +15489,9 @@ void room0f164c64(s32 roomnum) } } -void portalSetEnabled(s32 portal, bool enable) +void portalSetUnblocked(s32 portal, bool unblocked) { - g_BgPortals[portal].flags = (g_BgPortals[portal].flags | PORTALFLAG_ENABLED) ^ (enable != false); + g_BgPortals[portal].flags = (g_BgPortals[portal].flags | PORTALFLAG_BLOCKED) ^ (unblocked != false); } s32 func0f164e70(s32 arg0, s32 arg1, s32 arg2) @@ -15919,8 +15703,8 @@ void bgFindEnteredRooms(struct coord *bbmin, struct coord *bbmax, s16 *rooms, s3 portalnum = g_RoomPortals[g_Rooms[room].roomportallistoffset + j]; if (arg4 - && (g_BgPortals[portalnum].flags & PORTALFLAG_ENABLED) - && (g_BgPortals[portalnum].flags & PORTALFLAG_04) == 0) { + && (g_BgPortals[portalnum].flags & PORTALFLAG_BLOCKED) + && (g_BgPortals[portalnum].flags & PORTALFLAG_FORCEUNBLOCKED) == 0) { continue; } diff --git a/src/game/bot.c b/src/game/bot.c index 266177e29..31c5e5635 100644 --- a/src/game/bot.c +++ b/src/game/bot.c @@ -2090,12 +2090,12 @@ glabel var7f1b8ef0 /* f191958: 01801825 */ or $v1,$t4,$zero /* f19195c: 85840028 */ lh $a0,0x28($t4) .L0f191960: -/* f191960: 0fc575ba */ jal roomIsVisibleByAnyPlayer +/* f191960: 0fc575ba */ jal roomIsOnScreen /* f191964: afa30028 */ sw $v1,0x28($sp) /* f191968: 14400006 */ bnez $v0,.L0f191984 /* f19196c: 8fa30028 */ lw $v1,0x28($sp) /* f191970: 84640028 */ lh $a0,0x28($v1) -/* f191974: 0fc575d1 */ jal roomIsVisibleByAnyAibot +/* f191974: 0fc575d1 */ jal roomIsOnStandby /* f191978: afa30028 */ sw $v1,0x28($sp) /* f19197c: 10400005 */ beqz $v0,.L0f191994 /* f191980: 8fa30028 */ lw $v1,0x28($sp) @@ -2602,12 +2602,12 @@ glabel var7f1b8ef0 /* f191958: 01801825 */ or $v1,$t4,$zero /* f19195c: 85840028 */ lh $a0,0x28($t4) .L0f191960: -/* f191960: 0fc575ba */ jal roomIsVisibleByAnyPlayer +/* f191960: 0fc575ba */ jal roomIsOnScreen /* f191964: afa30028 */ sw $v1,0x28($sp) /* f191968: 14400006 */ bnez $v0,.L0f191984 /* f19196c: 8fa30028 */ lw $v1,0x28($sp) /* f191970: 84640028 */ lh $a0,0x28($v1) -/* f191974: 0fc575d1 */ jal roomIsVisibleByAnyAibot +/* f191974: 0fc575d1 */ jal roomIsOnStandby /* f191978: afa30028 */ sw $v1,0x28($sp) /* f19197c: 10400005 */ beqz $v0,.L0f191994 /* f191980: 8fa30028 */ lw $v1,0x28($sp) @@ -3077,7 +3077,7 @@ glabel var7f1b8ef0 // aibot->cheap = true; // // for (i = 0; prop->rooms[i] != -1; i++) { -// if (roomIsVisibleByAnyPlayer(prop->rooms[i]) || roomIsVisibleByAnyAibot(prop->rooms[i])) { +// if (roomIsOnScreen(prop->rooms[i]) || roomIsOnStandby(prop->rooms[i])) { // aibot->cheap = false; // break; // } diff --git a/src/game/camera.c b/src/game/camera.c index 5c726ca19..3b62131fd 100644 --- a/src/game/camera.c +++ b/src/game/camera.c @@ -692,7 +692,7 @@ glabel camIsPosInFovAndVisibleRoom // struct var800a4640_00 thing; // 34 // // for (i = 0, room = rooms[0]; room != -1; i++, room = rooms[i]) { -// if (g_Rooms[room].flags & ROOMFLAG_VISIBLEBYPLAYER) { +// if (g_Rooms[room].flags & ROOMFLAG_ONSCREEN) { // thisthing = func0f158140(room); // // if (hasdata == false) { diff --git a/src/game/chraction.c b/src/game/chraction.c index b76de2cae..8dc05fc17 100644 --- a/src/game/chraction.c +++ b/src/game/chraction.c @@ -5332,7 +5332,7 @@ bool chrIsRoomOffScreen(struct chrdata *chr, struct coord *waypos, s16 *wayrooms } } else { for (i = 0; sp7c[i] != -1; i++) { - if (g_Rooms[sp7c[i]].flags & ROOMFLAG_VISIBLEBYPLAYER) { + if (g_Rooms[sp7c[i]].flags & ROOMFLAG_ONSCREEN) { offscreen = false; break; } @@ -25104,25 +25104,25 @@ bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr) return false; } -bool func0f04aeb0(struct coord *pos, s16 *rooms) +bool chrIsPosOffScreen(struct coord *pos, s16 *rooms) { - bool result = true; + bool offscreen = true; s32 i; if (env0f1666f8(pos, 0)) { for (i = 0; rooms[i] != -1; i++) { - if (roomIsVisibleByAnyPlayer(rooms[i])) { + if (roomIsOnScreen(rooms[i])) { break; } } if (rooms[i] != -1) { // Room is visible by player - result = !camIsPosInScreenBox(pos, 200, func0f158140(rooms[i])); + offscreen = !camIsPosInScreenBox(pos, 200, func0f158140(rooms[i])); } } - return result; + return offscreen; } /** @@ -25135,7 +25135,7 @@ bool func0f04aeb0(struct coord *pos, s16 *rooms) * If the spawn cannot happen, the function return false. */ #if VERSION >= VERSION_NTSC_1_0 -bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, bool arg4, bool ignorebg, bool arg6) +bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, bool allowonscreen, bool ignorebg, bool arg6) { struct coord testpos; s32 i; @@ -25148,7 +25148,7 @@ bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, b if (ignorebg) { types = CDTYPE_ALL & ~CDTYPE_BG; - arg4 = true; + allowonscreen = true; } else { types = CDTYPE_ALL; } @@ -25176,7 +25176,7 @@ bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, b } if (cdTestVolume(pos, width, rooms, types, 1, ymax, ymin) != CDRESULT_COLLISION - && (arg4 || func0f04aeb0(pos, rooms))) { + && (allowonscreen || chrIsPosOffScreen(pos, rooms))) { return true; } } @@ -25198,7 +25198,7 @@ bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, b } if (cdTestVolume(&testpos, width, testrooms, CDTYPE_ALL, 1, ymax, ymin) != CDRESULT_COLLISION - && (arg4 || func0f04aeb0(&testpos, testrooms)) + && (allowonscreen || chrIsPosOffScreen(&testpos, testrooms)) && (!arg6 || ground > -100000)) { pos->x = testpos.x; pos->y = testpos.y; @@ -25222,7 +25222,7 @@ bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, b * ntsc-beta's version of this function doesn't have the arg6 argument * nor out of bounds checking, and lacks the reduction for the volume test. */ -bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, bool arg4, bool ignorebg) +bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, bool allowonscreen, bool ignorebg) { struct coord testpos; s32 i; @@ -25232,13 +25232,13 @@ bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, b if (ignorebg) { types = CDTYPE_ALL & ~CDTYPE_BG; - arg4 = true; + allowonscreen = true; } else { types = CDTYPE_ALL; } if (cdTestVolume(pos, width, rooms, types, 1, 200, -200) != CDRESULT_COLLISION - && (arg4 || func0f04aeb0(pos, rooms))) { + && (allowonscreen || chrIsPosOffScreen(pos, rooms))) { return true; } @@ -25249,7 +25249,7 @@ bool chrAdjustPosForSpawn(f32 width, struct coord *pos, s16 *rooms, f32 angle, b if (cd0002deac(pos, rooms, &testpos, testrooms, CDTYPE_BG) && cdTestVolume(&testpos, width, testrooms, CDTYPE_ALL, 1, 200, -200.0f) != CDRESULT_COLLISION - && (arg4 || func0f04aeb0(&testpos, testrooms))) { + && (allowonscreen || chrIsPosOffScreen(&testpos, testrooms))) { pos->x = testpos.x; pos->y = testpos.y; pos->z = testpos.z; diff --git a/src/game/chrai.c b/src/game/chrai.c index a4bd3428f..f8815e961 100644 --- a/src/game/chrai.c +++ b/src/game/chrai.c @@ -82,8 +82,8 @@ bool (*g_CommandPointers[])(void) = { /*0x0045*/ ai0045, /*0x0046*/ aiIfNeverBeenOnScreen, /*0x0047*/ aiIfOnScreen, - /*0x0048*/ aiIfChrInActiveRoom, - /*0x0049*/ aiIfRoomActive, + /*0x0048*/ aiIfChrInOnScreenRoom, + /*0x0049*/ aiIfRoomIsOnScreen, /*0x004a*/ ai004a, /*0x004b*/ aiIfNearMiss, /*0x004c*/ aiIfSeesSuspiciousItem, diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index 5610a79fa..959b13f0b 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -1498,7 +1498,7 @@ bool aiIfOnScreen(void) /** * @cmd 0048 */ -bool aiIfChrInActiveRoom(void) +bool aiIfChrInOnScreenRoom(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]); @@ -1507,7 +1507,7 @@ bool aiIfChrInActiveRoom(void) if (chr && chr->prop) { for (i = 0; chr->prop->rooms[i] != -1; i++) { - if (roomIsVisibleByAnyPlayer(chr->prop->rooms[i])) { + if (roomIsOnScreen(chr->prop->rooms[i])) { pass = true; } } @@ -1526,13 +1526,13 @@ bool aiIfChrInActiveRoom(void) /** * @cmd 0049 */ -bool aiIfRoomActive(void) +bool aiIfRoomIsOnScreen(void) { u8 *cmd = g_Vars.ailist + g_Vars.aioffset; u16 pad_id = cmd[3] | (cmd[2] << 8); s32 room_id = chrGetPadRoom(g_Vars.chrdata, pad_id); - if (room_id >= 0 && roomIsVisibleByAnyPlayer(room_id)) { + if (room_id >= 0 && roomIsOnScreen(room_id)) { g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); } else { g_Vars.aioffset += 5; diff --git a/src/game/dlights.c b/src/game/dlights.c index 3ba56956c..81d74ab55 100644 --- a/src/game/dlights.c +++ b/src/game/dlights.c @@ -616,7 +616,7 @@ void func0f001c0c(void) var80061420 = mempAlloc(sp68, MEMPOOL_STAGE); for (i = 0; i < g_NumPortals; i++) { - if ((g_BgPortals[i].flags & PORTALFLAG_ENABLED) && (g_BgPortals[i].flags & PORTALFLAG_04) == 0) { + if ((g_BgPortals[i].flags & PORTALFLAG_BLOCKED) && (g_BgPortals[i].flags & PORTALFLAG_FORCEUNBLOCKED) == 0) { var80061438[i] = false; } else { var80061438[i] = true; @@ -678,13 +678,13 @@ void func0f001c0c(void) } for (i = 1; i < g_Vars.roomcount; i++) { - g_Rooms[i].flags |= ROOMFLAG_VISIBLEBYPLAYER; + g_Rooms[i].flags |= ROOMFLAG_ONSCREEN; } lightingTick(); for (i = 1; i < g_Vars.roomcount; i++) { - g_Rooms[i].flags &= ~ROOMFLAG_VISIBLEBYPLAYER; + g_Rooms[i].flags &= ~ROOMFLAG_ONSCREEN; } osGetCount(); @@ -2012,7 +2012,7 @@ void func0f0037ac(void) for (i = 1; i < g_Vars.roomcount; i++) { if (i != 0) { - if ((g_Rooms[i].flags & ROOMFLAG_RENDERALWAYS) || (g_Rooms[i].flags & (ROOMFLAG_VISIBLEBYPLAYER | ROOMFLAG_VISIBLEBYAIBOT))) { + if ((g_Rooms[i].flags & ROOMFLAG_RENDERALWAYS) || (g_Rooms[i].flags & (ROOMFLAG_ONSCREEN | ROOMFLAG_STANDBY))) { if (g_Rooms[i].flags & (ROOMFLAG_0200 | ROOMFLAG_0400)) { s32 sum = 0; s32 sp90 = 0; @@ -2148,7 +2148,7 @@ void roomAdjustLighting(s32 roomnum, s32 start, s32 limit) void func0f004558(s32 roomnum, s32 increment, s32 limit) { if (roomnum) { - if (g_Rooms[roomnum].flags & ROOMFLAG_VISIBLEBYPLAYER) { + if (g_Rooms[roomnum].flags & ROOMFLAG_ONSCREEN) { if (increment > 0) { // Increasing if (g_Rooms[roomnum].unk52 < limit) { @@ -2380,7 +2380,7 @@ void func0f004c6c(void) } for (i = 0; i < g_NumPortals; i++) { - var8009cad8[i] = portal0f0b656c(i) > 0.5f; + var8009cad8[i] = portalGetXluFrac(i) > 0.5f; portalGetAvgVertexPos(i, &var80061428[i]); } diff --git a/src/game/explosions.c b/src/game/explosions.c index 5c1691853..e50d3759b 100644 --- a/src/game/explosions.c +++ b/src/game/explosions.c @@ -1277,9 +1277,7 @@ Gfx *explosionRender(struct prop *prop, Gfx *gdl, bool xlupass) roomnum = prop->rooms[j]; while (roomnum != -1) { - if (g_Rooms[roomnum].gfxdata - && g_Rooms[roomnum].loaded240 - && (g_Rooms[roomnum].flags & ROOMFLAG_VISIBLEBYPLAYER)) { + if (g_Rooms[roomnum].gfxdata && g_Rooms[roomnum].loaded240 && (g_Rooms[roomnum].flags & ROOMFLAG_ONSCREEN)) { break; } diff --git a/src/game/lv.c b/src/game/lv.c index b6dc84e1b..5620a77fd 100644 --- a/src/game/lv.c +++ b/src/game/lv.c @@ -2066,7 +2066,7 @@ void lvTick(void) for (otherplayernum = 0; otherplayernum < PLAYERCOUNT(); otherplayernum++) { if (playernum != otherplayernum && g_Vars.players[otherplayernum]->isdead == false - && roomIsVisibleByPlayer(rooms[r], otherplayernum)) { + && roomIsOnPlayerScreen(rooms[r], otherplayernum)) { foundnearbychr = true; } } diff --git a/src/game/player.c b/src/game/player.c index 0600e5a45..57575e7ba 100644 --- a/src/game/player.c +++ b/src/game/player.c @@ -264,15 +264,11 @@ f32 playerChooseSpawnLocation(f32 chrwidth, struct coord *dstpos, s16 *dstrooms, bestsqdist = sqdist; } - if (roomIsVisibleByPlayer(pad.room, i)) { + if (roomIsOnPlayerScreen(pad.room, i)) { verybadpads[p] = true; } - // @bug: The aibot check should be in the aibot loop. As it - // stands it's using the playernum iterator as the AI bot num, - // so if there's more AI bots than players then some AI bots - // will be excluded from the room visibility check. - if (verybadpads[p] || roomIsVisibleByAibot(pad.room, i)) { + if (verybadpads[p] || roomIsOnPlayerStandby(pad.room, i)) { badpads[p] = true; } } @@ -318,7 +314,8 @@ f32 playerChooseSpawnLocation(f32 chrwidth, struct coord *dstpos, s16 *dstrooms, // are at least 10m away. For each pad added, set their distance to -1 so // they don't get reused later. i = random() % numpads; - p = i; while (sllen < 4) { + p = i; \ + while (sllen < 4) { if (padsqdists[p] > 1000 * 1000 && !badpads[p]) { padUnpack(pads[p], PADFIELD_POS | PADFIELD_ROOM | PADFIELD_LOOK, &pad); diff --git a/src/game/portal.c b/src/game/portal.c index 720daa229..d9bbae897 100644 --- a/src/game/portal.c +++ b/src/game/portal.c @@ -70,59 +70,59 @@ const char var7f1ad2bc[] = "ACOUSTIC -> DGD WARNING: portalAVReset no portals!\n struct roomacousticdata *g_RoomAcousticData; u32 var8009dd74; struct var8009dd78 var8009dd78[10]; -u16 *var8009ddc8; -s32 var8009ddcc; +u16 *g_PortalXluFracs; +s32 g_NumPortalXluFracs; -void portal0f0b63b0(s32 portalnum, f32 frac) +void portalSetXluFrac2(s32 portalnum, f32 frac) { if (portalnum >= 0) { u8 value = (u32)(255 * frac); value <<= 0; - var8009ddc8[portalnum] = (var8009ddc8[portalnum] & 0xff00) | value; + g_PortalXluFracs[portalnum] = (g_PortalXluFracs[portalnum] & 0xff00) | value; } } -void portal0f0b6470(s32 portalnum, f32 frac) +void portalSetXluFrac(s32 portalnum, f32 frac) { if (portalnum >= 0) { u8 value = (u32)(15 * frac) & 0xf; - var8009ddc8[portalnum] = (var8009ddc8[portalnum] & 0xf0ff) | (value << 8); + g_PortalXluFracs[portalnum] = (g_PortalXluFracs[portalnum] & 0xf0ff) | (value << 8); } } -f32 portal0f0b6534(s32 arg0) +f32 portalGetXluFrac2(s32 arg0) { - f32 value = (var8009ddc8[arg0] & 0xff) * 0.0039215688593686f; + f32 value = (g_PortalXluFracs[arg0] & 0xff) * 0.0039215688593686f; return value; } -f32 portal0f0b656c(s32 arg0) +f32 portalGetXluFrac(s32 arg0) { - f32 value = ((var8009ddc8[arg0] & 0xf00) >> 8) * 0.06666667f; + f32 value = ((g_PortalXluFracs[arg0] & 0xf00) >> 8) * 0.06666667f; return value; } -void portal0f0b65a8(s32 arg0) +void portal0f0b65a8(s32 numportals) { - if (arg0 > 0) { - var8009ddcc = arg0; - var8009ddc8 = mempAlloc(ALIGN16(arg0 * 2), MEMPOOL_STAGE); + if (numportals > 0) { + g_NumPortalXluFracs = numportals; + g_PortalXluFracs = mempAlloc(ALIGN16(numportals * 2), MEMPOOL_STAGE); } else { - var8009ddc8 = NULL; + g_PortalXluFracs = NULL; } } void portalsReset(void) { - if (var8009ddc8) { + if (g_PortalXluFracs) { struct prop *prop; s32 i; - for (i = 0; i < var8009ddcc; i++) { - portal0f0b6470(i, 1); - portal0f0b63b0(i, 1); + for (i = 0; i < g_NumPortalXluFracs; i++) { + portalSetXluFrac(i, 1); + portalSetXluFrac2(i, 1); } prop = g_Vars.activeprops; @@ -136,13 +136,13 @@ void portalsReset(void) struct tintedglassobj *glass = (struct tintedglassobj *)obj; if (glass->portalnum >= 0) { - portal0f0b6470(glass->portalnum, 0); + portalSetXluFrac(glass->portalnum, 0); } } else if (obj->type == OBJTYPE_GLASS) { struct glassobj *glass = (struct glassobj *)obj; if (glass->portalnum >= 0) { - portal0f0b6470(glass->portalnum, 0); + portalSetXluFrac(glass->portalnum, 0); } } } @@ -151,9 +151,9 @@ void portalsReset(void) prop = prop->next; } - for (i = 0; i < var8009ddcc; i++) { - portal0f0b656c(i); - portal0f0b6534(i); + for (i = 0; i < g_NumPortalXluFracs; i++) { + portalGetXluFrac(i); + portalGetXluFrac2(i); } } } diff --git a/src/game/prop.c b/src/game/prop.c index 86efcb27e..19be72434 100644 --- a/src/game/prop.c +++ b/src/game/prop.c @@ -5752,7 +5752,7 @@ glabel propsTickPlayer // rooms = prop->rooms; // // for (i = 0; *rooms != -1; i++) { -// if (g_Rooms[*rooms].flags & ROOMFLAG_VISIBLEBYPLAYER) { +// if (g_Rooms[*rooms].flags & ROOMFLAG_ONSCREEN) { // score++; // } // rooms++; @@ -5779,7 +5779,7 @@ glabel propsTickPlayer // rooms = prop->rooms; // // for (i = 0; *rooms != -1; i++) { -// if (g_Rooms[*rooms].flags & ROOMFLAG_VISIBLEBYAIBOT) { +// if (g_Rooms[*rooms].flags & ROOMFLAG_STANDBY) { // break; // } // @@ -6150,7 +6150,7 @@ void propsTickPadEffects(void) padUnpack(effect->pad, PADFIELD_ROOM, &pad); - if (roomIsVisibleByAnyPlayer(pad.room)) { + if (roomIsOnScreen(pad.room)) { switch (effect->effect) { case PADEFFECT_SPARKS: case PADEFFECT_SPARKS2: diff --git a/src/game/propobj.c b/src/game/propobj.c index 076b08efb..031787736 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -5228,15 +5228,15 @@ void objFree(struct defaultobj *obj, bool freeprop, bool canregen) struct tintedglassobj *glass = (struct tintedglassobj *) obj; if (glass->portalnum >= 0) { - portal0f0b6470(glass->portalnum, 1); - portalSetEnabled(glass->portalnum, true); - g_BgPortals[glass->portalnum].flags |= PORTALFLAG_04; + portalSetXluFrac(glass->portalnum, 1); + portalSetUnblocked(glass->portalnum, true); + g_BgPortals[glass->portalnum].flags |= PORTALFLAG_FORCEUNBLOCKED; } } else if (obj->type == OBJTYPE_GLASS) { struct glassobj *glass = (struct glassobj *) obj; if (glass->portalnum >= 0) { - portal0f0b6470(glass->portalnum, 1); + portalSetXluFrac(glass->portalnum, 1); } } else if (obj->type == OBJTYPE_DOOR) { struct doorobj *door = (struct doorobj *) obj; @@ -5244,7 +5244,7 @@ void objFree(struct defaultobj *obj, bool freeprop, bool canregen) doorActivatePortal(door); if (door->portalnum >= 0) { - g_BgPortals[door->portalnum].flags |= PORTALFLAG_04; + g_BgPortals[door->portalnum].flags |= PORTALFLAG_FORCEUNBLOCKED; } } @@ -49705,9 +49705,9 @@ void glassUpdatePortal(struct prop *prop, s32 playercount, bool *arg2) if (glass->portalnum >= 0 && playercount == 1) { if (glass->opacity == 255) { - portalSetEnabled(glass->portalnum, false); + portalSetUnblocked(glass->portalnum, false); } else { - portalSetEnabled(glass->portalnum, true); + portalSetUnblocked(glass->portalnum, true); } } @@ -49947,15 +49947,17 @@ s32 objTickPlayer(struct prop *prop) struct tintedglassobj *glass = (struct tintedglassobj *)obj; if (glass->portalnum >= 0) { - pass = (g_BgPortals[glass->portalnum].flags & PORTALFLAG_ENABLED) && (g_BgPortals[glass->portalnum].flags & PORTALFLAG_04) == 0; - g_BgPortals[glass->portalnum].flags |= PORTALFLAG_04; + pass = (g_BgPortals[glass->portalnum].flags & PORTALFLAG_BLOCKED) + && (g_BgPortals[glass->portalnum].flags & PORTALFLAG_FORCEUNBLOCKED) == 0; + g_BgPortals[glass->portalnum].flags |= PORTALFLAG_FORCEUNBLOCKED; } } else if (obj->type == OBJTYPE_DOOR) { struct doorobj *door = (struct doorobj *)obj; if (door->portalnum >= 0) { - pass = (g_BgPortals[door->portalnum].flags & PORTALFLAG_ENABLED) && (g_BgPortals[door->portalnum].flags & PORTALFLAG_04) == 0; - g_BgPortals[door->portalnum].flags |= PORTALFLAG_04; + pass = (g_BgPortals[door->portalnum].flags & PORTALFLAG_BLOCKED) + && (g_BgPortals[door->portalnum].flags & PORTALFLAG_FORCEUNBLOCKED) == 0; + g_BgPortals[door->portalnum].flags |= PORTALFLAG_FORCEUNBLOCKED; } } @@ -54087,10 +54089,17 @@ void doorDestroyGlass(struct doorobj *door) rodata = modelGetPartRodata(model->filedata, 2); if (door->portalnum >= 0) { - bail = (g_BgPortals[door->portalnum].flags & PORTALFLAG_ENABLED) != 0 - && (g_BgPortals[door->portalnum].flags & PORTALFLAG_04) == 0; + // @bug: Firing three shots at door glass is supposed to destroy it, + // and this function is called when the third shot happens, but if it's + // shot from a long distance (such that the glass is opaque) then this + // function returns early and the glass remains in place, despite + // setting the portal as unblocked. On the fourth shot + // PORTALFLAG_FORCEUNBLOCKED is already set, so bail is false and the + // glass is destroyed. + bail = (g_BgPortals[door->portalnum].flags & PORTALFLAG_BLOCKED) + && (g_BgPortals[door->portalnum].flags & PORTALFLAG_FORCEUNBLOCKED) == 0; - g_BgPortals[door->portalnum].flags |= PORTALFLAG_04; + g_BgPortals[door->portalnum].flags |= PORTALFLAG_FORCEUNBLOCKED; if (bail) { return; @@ -61839,14 +61848,14 @@ void func0f08d460(struct doorobj *door) void doorActivatePortal(struct doorobj *door) { if (door->portalnum >= 0) { - portalSetEnabled(door->portalnum, true); + portalSetUnblocked(door->portalnum, true); } } void doorDeactivatePortal(struct doorobj *door) { if (door->portalnum >= 0) { - portalSetEnabled(door->portalnum, false); + portalSetUnblocked(door->portalnum, false); } } @@ -62461,7 +62470,7 @@ bool func0f08e8ac(struct prop *prop, struct coord *pos, f32 arg2, bool arg3) roomnum = *rooms; while (roomnum != -1) { - if (g_Rooms[roomnum].flags & ROOMFLAG_VISIBLEBYPLAYER) { + if (g_Rooms[roomnum].flags & ROOMFLAG_ONSCREEN) { if (env0f1666f8(pos, arg2) && (!arg3 || func0f08e794(pos, arg2))) { result = camIsPosInFovAndVisibleRoom(prop->rooms, pos, arg2); @@ -62833,8 +62842,8 @@ void doorsCalcFrac(struct doorobj *door) } } - portal0f0b6470(door->portalnum, frac / numsameportal); - portal0f0b63b0(door->portalnum, frac / numsameportal); + portalSetXluFrac(door->portalnum, frac / numsameportal); + portalSetXluFrac2(door->portalnum, frac / numsameportal); } } diff --git a/src/game/smoke.c b/src/game/smoke.c index ae16e88e2..eb90355e0 100644 --- a/src/game/smoke.c +++ b/src/game/smoke.c @@ -623,9 +623,7 @@ Gfx *smokeRender(struct prop *prop, Gfx *gdl, bool xlupass) roomnum = prop->rooms[i]; while (roomnum != -1) { - if (g_Rooms[roomnum].gfxdata - && g_Rooms[roomnum].loaded240 - && (g_Rooms[roomnum].flags & ROOMFLAG_VISIBLEBYPLAYER)) { + if (g_Rooms[roomnum].gfxdata && g_Rooms[roomnum].loaded240 && (g_Rooms[roomnum].flags & ROOMFLAG_ONSCREEN)) { break; } diff --git a/src/game/sparks.c b/src/game/sparks.c index 73b495fbd..ff5c8f90f 100644 --- a/src/game/sparks.c +++ b/src/game/sparks.c @@ -353,8 +353,10 @@ Gfx *sparksRender(Gfx *gdl) if ((group->prop->flags & PROPFLAG_ONTHISSCREENTHISTICK) == 0) { render = false; } - } else if ((g_Rooms[group->room].flags & ROOMFLAG_VISIBLEBYPLAYER) == 0) { - render = false; + } else { + if ((g_Rooms[group->room].flags & ROOMFLAG_ONSCREEN) == 0) { + render = false; + } } if (g_Vars.currentplayer->visionmode == VISIONMODE_XRAY) { diff --git a/src/game/wallhit.c b/src/game/wallhit.c index 8fc5432a4..eb13ab4b6 100644 --- a/src/game/wallhit.c +++ b/src/game/wallhit.c @@ -353,10 +353,9 @@ bool wallhitReapOneInRoom(s32 room) /** * Remove a single wallhit. * - * The wallhit will be removed from a room that's out of sight of both players - * and bots if possible, otherwise a room that's only out of sight of players. - * If none of those are possible then all rooms are considered, and prop hits - * too. + * The wallhit will be removed from a room that's offscreen and not in standby + * if possible, otherwise a room that's in standby. If wallhits only exist in + * onscreen rooms then all rooms are considered, and prop hits too. * * The chosen room will be the one with the most wallhits within one of those * three categories. @@ -372,14 +371,14 @@ void wallhitReapOne(void) s32 bestvalue = -1; for (room = 0; room < g_Vars.roomcount; room++) { - s32 visiblebyplayer = room == 0 ? 1 : (g_Rooms[room].flags & ROOMFLAG_VISIBLEBYPLAYER); - s32 visiblebybot = room == 0 ? 1 : (g_Rooms[room].flags & ROOMFLAG_VISIBLEBYAIBOT); + s32 onscreen = room == 0 ? 1 : (g_Rooms[room].flags & ROOMFLAG_ONSCREEN); + s32 standby = room == 0 ? 1 : (g_Rooms[room].flags & ROOMFLAG_STANDBY); bool consider; if (i == 0) { - consider = !visiblebyplayer && !visiblebybot; + consider = !onscreen && !standby; } else if (i == 1) { - consider = !visiblebyplayer; + consider = !onscreen; } else { consider = true; } diff --git a/src/game/weather.c b/src/game/weather.c index fcc088812..f164cf92d 100644 --- a/src/game/weather.c +++ b/src/game/weather.c @@ -2808,7 +2808,7 @@ u32 var8007f0fc = 22000; // for (j2 = 0; j2 < numneighbours; j2++) { // a0 = true; // -// if (g_Rooms[sp128[j2]].flags & ROOMFLAG_VISIBLEBYPLAYER) { +// if (g_Rooms[sp128[j2]].flags & ROOMFLAG_ONSCREEN) { // for (k = 0; k < s4; k++) { // if (spcb8[k] == sp128[j2]) { // a0 = false; @@ -4740,7 +4740,7 @@ u32 var8007f110 = 0xffffff7f; // for (j2 = 0; j2 < numneighbours; j2++) { // a0 = true; // -// if (g_Rooms[sp144[j2]].flags & ROOMFLAG_VISIBLEBYPLAYER) { +// if (g_Rooms[sp144[j2]].flags & ROOMFLAG_ONSCREEN) { // for (k = 0; k < sp1268; k++) { // if (sp126c[k] == sp144[j2]) { // a0 = false; diff --git a/src/include/constants.h b/src/include/constants.h index 05f65b4cc..fbd205a13 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -3351,9 +3351,10 @@ #define PORTALCMD_64 0x64 #define PORTALCMD_TRAILER 0x65 -#define PORTALFLAG_ENABLED 0x01 -#define PORTALFLAG_02 0x02 -#define PORTALFLAG_04 0x04 +#define PORTALFLAG_BLOCKED 0x01 // Due to door being closed, or player is too far from glass +#define PORTALFLAG_02 0x02 +#define PORTALFLAG_FORCEUNBLOCKED 0x04 // Glass is destroyed, or door is freed +#define PORTALFLAG_SKIP 0x08 // DD tower exterior - don't bother processing these #define PORTALMODE_SHOW 0 #define PORTALMODE_HIDE 1 @@ -3469,12 +3470,12 @@ #define RENDERPASS_XLU 1 #define RENDERPASS_OPA_POSTBG 2 -#define ROOMFLAG_FORCEDISABLED 0x0001 -#define ROOMFLAG_HASDYNTEX 0x0002 -#define ROOMFLAG_VISIBLEBYPLAYER 0x0004 -#define ROOMFLAG_VISIBLEBYAIBOT 0x0008 +#define ROOMFLAG_DISABLEDBYSCRIPT 0x0001 +#define ROOMFLAG_HASDYNTEX 0x0002 // Has dynamic textures such as water +#define ROOMFLAG_ONSCREEN 0x0004 +#define ROOMFLAG_STANDBY 0x0008 // Neighbour of an onscreen room - usually loaded as well #define ROOMFLAG_0010 0x0010 -#define ROOMFLAG_0020 0x0020 +#define ROOMFLAG_LOADCANDIDATE 0x0020 // Room is a good candidate for loading on this tick #define ROOMFLAG_0040 0x0040 #define ROOMFLAG_RENDERALWAYS 0x0080 #define ROOMFLAG_DIRTY 0x0100 diff --git a/src/include/game/bg.h b/src/include/game/bg.h index 24f716c7b..981280335 100644 --- a/src/include/game/bg.h +++ b/src/include/game/bg.h @@ -45,10 +45,10 @@ Gfx *boxRenderBorder(Gfx *gdl, s32 x1, s32 y1, s32 x2, s32 y2); bool boxGetIntersection(struct screenbox *a, struct screenbox *b); void boxExpand(struct screenbox *a, struct screenbox *b); void boxCopy(struct screenbox *dst, struct screenbox *src); -bool roomIsVisibleByAnyPlayer(s32 room); -bool roomIsVisibleByAnyAibot(s32 room); -bool roomIsVisibleByPlayer(s32 room, u32 playernum); -bool roomIsVisibleByAibot(s32 room, u32 aibotindex); +bool roomIsOnScreen(s32 room); +bool roomIsOnStandby(s32 room); +bool roomIsOnPlayerScreen(s32 room, u32 playernum); +bool roomIsOnPlayerStandby(s32 room, u32 aibotindex); s32 portalFindNumByVertices(struct portalvertices *pvertices); u32 bgInflate(u8 *src, u8 *dst, u32 len); Gfx *func0f15da00(struct roomgfxdata18 *arg0, Gfx *arg1, Gfx *arg2); @@ -86,7 +86,7 @@ u32 func0f162d9c(void); void func0f1632d4(s16 roomnum1, s16 roomnum2, s16 draworder, struct screenbox *box); void func0f163528(struct var800a4d00 *arg0); bool func0f163904(void); -u32 func0f16397c(void); +void bgChooseRoomsToLoad(void); void bgTickPortals(void); Gfx *func0f164150(Gfx *gdl); s32 roomsGetActive(s16 *rooms, s32 len); @@ -97,7 +97,7 @@ void bgExpandRoomToPortals(s32 roomnum); void portalSwapRooms(s32 portal); void func0f164ab8(s32 portalnum); void room0f164c64(s32 roomnum); -void portalSetEnabled(s32 portal, bool enable); +void portalSetUnblocked(s32 portal, bool unblocked); s32 func0f164e8c(struct coord *arg0, struct coord *arg1); bool bgIsBboxOverlapping(struct coord *arg0, struct coord *arg1, struct coord *arg2, struct coord *arg3); void portalFindBbox(s32 portalnum, struct coord *bbmin, struct coord *bbmax); diff --git a/src/include/game/chraction.h b/src/include/game/chraction.h index 8f2689cfe..7f7410fe4 100644 --- a/src/include/game/chraction.h +++ b/src/include/game/chraction.h @@ -203,7 +203,7 @@ bool chrSetPadPresetToWaypointWithinTargetQuadrant(struct chrdata *chr, u8 arg1) bool chrSetChrPresetToChrNearPad(u32 checktype, struct chrdata *chr, f32 distance, s32 padnum); bool chrSetChrPresetToChrNearPos(u8 checktype, struct chrdata *chr, f32 distance, struct coord *pos, s16 *room); bool chrSetPadPresetToPadOnRouteToTarget(struct chrdata *chr); -bool func0f04aeb0(struct coord *pos, s16 *rooms); +bool chrIsPosOffScreen(struct coord *pos, s16 *rooms); #if VERSION >= VERSION_NTSC_1_0 bool chrAdjustPosForSpawn(f32 chrwidth, struct coord *pos, s16 *rooms, f32 angle, bool arg4, bool arg5, bool arg6); diff --git a/src/include/game/chraicommands.h b/src/include/game/chraicommands.h index 8c73145ce..1bdfeb418 100644 --- a/src/include/game/chraicommands.h +++ b/src/include/game/chraicommands.h @@ -76,8 +76,8 @@ /*0x0045*/ bool ai0045(void); /*0x0046*/ bool aiIfNeverBeenOnScreen(void); /*0x0047*/ bool aiIfOnScreen(void); -/*0x0048*/ bool aiIfChrInActiveRoom(void); -/*0x0049*/ bool aiIfRoomActive(void); +/*0x0048*/ bool aiIfChrInOnScreenRoom(void); +/*0x0049*/ bool aiIfRoomIsOnScreen(void); /*0x004a*/ bool ai004a(void); /*0x004b*/ bool aiIfNearMiss(void); /*0x004c*/ bool aiIfSeesSuspiciousItem(void); diff --git a/src/include/game/portal.h b/src/include/game/portal.h index 7ad017da5..0624d076f 100644 --- a/src/include/game/portal.h +++ b/src/include/game/portal.h @@ -4,11 +4,11 @@ #include "data.h" #include "types.h" -void portal0f0b63b0(s32 portalnum, f32 frac); -void portal0f0b6470(s32 portalnum, f32 frac); -f32 portal0f0b6534(s32 arg0); -f32 portal0f0b656c(s32 arg0); -void portal0f0b65a8(s32 arg0); +void portalSetXluFrac2(s32 portalnum, f32 frac); +void portalSetXluFrac(s32 portalnum, f32 frac); +f32 portalGetXluFrac2(s32 arg0); +f32 portalGetXluFrac(s32 arg0); +void portal0f0b65a8(s32 numportals); void portalsReset(void); void acousticReset(void);