5 Commits
Author SHA1 Message Date
popux dd88c8ee28 Fix mac build 2026-10-22 16:24:11 +02:00
popux aa8c2754d9 Fix corpses crash 2026-10-22 16:23:47 +02:00
popux 5787e3abbc Fix respawn 2026-10-22 16:23:41 +02:00
popux 342e825c73 Corpses 2026-10-22 13:08:39 +02:00
popux f3b74e9c7c Decal fix 2026-10-21 20:31:03 +02:00
14 changed files with 361 additions and 16 deletions

No files matched your search

+9 -7
View File
@@ -23,14 +23,15 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
# declaration (no members) and rejects base-member access. So prefer GCC.
# (GCC does hard-error on the one struct that declares a member with the same
# name as an inherited one — CCTVRecord's `pad` — see docs/internals.md.)
# An explicit -DCMAKE_C_COMPILER=... always wins.
if(NOT DEFINED CMAKE_C_COMPILER)
# An explicit -DCMAKE_C_COMPILER=... or a CC environment variable always wins.
if(NOT DEFINED CMAKE_C_COMPILER AND "$ENV{CC}" STREQUAL "")
if(CMAKE_HOST_APPLE)
# Homebrew installs real GNU GCC with a version suffix; /usr/bin/gcc is
# Apple Clang and does not support the Plan 9 struct extensions required
# by the decomp's `inherits` pattern.
# Homebrew (gcc-N) and MacPorts (gcc-mp-N) install real GNU GCC with a
# version suffix; /usr/bin/gcc is Apple Clang and does not support the
# Plan 9 struct extensions required by the decomp's `inherits` pattern.
find_program(_GE007_GCC
NAMES gcc-16 gcc-15 gcc-14 gcc-13 gcc-12 gcc-11 gcc)
NAMES gcc-16 gcc-mp-16 gcc-15 gcc-mp-15 gcc-14 gcc-mp-14 gcc-13 gcc-mp-13
gcc-12 gcc-mp-12 gcc-11 gcc-mp-11 gcc)
else()
find_program(_GE007_GCC NAMES gcc)
endif()
@@ -39,7 +40,8 @@ if(NOT DEFINED CMAKE_C_COMPILER)
get_filename_component(_GE007_GCC_DIR "${_GE007_GCC}" DIRECTORY)
if(CMAKE_HOST_APPLE)
find_program(_GE007_GXX
NAMES g++-16 g++-15 g++-14 g++-13 g++-12 g++-11 g++
NAMES g++-16 g++-mp-16 g++-15 g++-mp-15 g++-14 g++-mp-14 g++-13 g++-mp-13
g++-12 g++-mp-12 g++-11 g++-mp-11 g++
PATHS "${_GE007_GCC_DIR}" NO_DEFAULT_PATH)
else()
find_program(_GE007_GXX NAMES g++
Regular → Executable
View File
File mode changed.
+13 -1
View File
@@ -55,7 +55,19 @@ brew install cmake gcc sdl2 zlib python3
The project requires real GNU GCC for the decomp's Plan 9 struct extensions.
Apple's `/usr/bin/gcc` is Clang and is not compatible. CMake automatically
selects Homebrew's versioned `gcc-N`/`g++-N` executables.
selects Homebrew's versioned `gcc-N`/`g++-N` (or MacPorts' `gcc-mp-N`/`g++-mp-N`)
executables; set `CC`/`CXX` to pick a specific one. Delete the build directory
after switching compilers.
If GCC fails with `fatal error: _bounds.h: No such file or directory`, it was
built against a newer macOS SDK than the one CMake picked (the `xcode-select`
default). Point `SDKROOT` at the SDK GCC was built with (`gcc -v` shows it as
`--with-sysroot`), for example with MacPorts GCC 15:
```sh
SDKROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX15.sdk \
CC=/opt/local/bin/gcc-mp-15 CXX=/opt/local/bin/g++-mp-15 ./build-pc.sh ntsc-final
```
### Asset extraction (decompilation toolchain)
+169 -3
View File
@@ -38,6 +38,10 @@ struct ShaderProgram {
GLint frame_count_location;
GLint noise_scale_location;
GLint three_point_filter_locations[2];
GLint decal_mode_location;
GLint decal_scale_location;
int decal_mode;
float decal_scale;
};
struct Framebuffer {
@@ -45,6 +49,8 @@ struct Framebuffer {
bool has_depth_buffer;
uint32_t msaa_level;
bool invert_y;
bool depth_copy_checked;
bool depth_copy_failed;
GLuint fbo, clrbuf, clrbuf_msaa, rbo;
};
@@ -63,6 +69,19 @@ static int current_anisotropy_level = 4; /* B1: sane default (0 was invalid fo
static FilteringMode current_filter_mode = FILTER_LINEAR;
static MipmapFilteringMode current_mipmap_filter_mode = MIPMAP_LINEAR;
static bool current_textures_linear_filter[2] = {false, false};
static struct ShaderProgram* current_shader_program;
// N64 decal depth mode: pixels only pass when close to the stored depth, using a copy of the depth buffer
#define DECAL_DEPTH_TEXTURE_UNIT 2
// Height of the N64 frame; the RDP's depth slope tolerance is measured in N64 pixels
#define DECAL_N64_SCREEN_HEIGHT 240.0f
static bool depth_copy_supported;
static bool depth_copy_dirty = true;
static size_t depth_copy_source;
static GLuint depth_copy_fbo, depth_copy_tex;
static uint32_t depth_copy_width, depth_copy_height;
static bool current_depth_test;
static bool current_depth_decal;
static int gl_glsl_version = 130;
static char gl_glsl_version_str[16] = "130";
@@ -127,6 +146,7 @@ static void gfx_opengl_unload_shader(struct ShaderProgram* old_prg) {
static void gfx_opengl_load_shader(struct ShaderProgram* new_prg) {
// if (!new_prg) return;
current_shader_program = new_prg;
glUseProgram(new_prg->opengl_program_id);
gfx_opengl_vertex_array_set_attribs(new_prg);
gfx_opengl_set_uniforms(new_prg);
@@ -396,6 +416,9 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
append_line(fs_buf, &fs_len, "uniform int frame_count;");
append_line(fs_buf, &fs_len, "uniform float noise_scale;");
append_line(fs_buf, &fs_len, "uniform int uDecalMode;");
append_line(fs_buf, &fs_len, "uniform highp float uDecalPixelScale;");
append_line(fs_buf, &fs_len, "uniform highp sampler2D uDepthTex;");
append_line(fs_buf, &fs_len, "float random(in vec3 value) {");
append_line(fs_buf, &fs_len, " float random = dot(sin(value), vec3(12.9898, 78.233, 37.719));");
@@ -455,6 +478,16 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
}
append_line(fs_buf, &fs_len, "void main() {");
// RDP decal Z mode: pass only if |z - stored z| <= dz (the per-pixel depth slope), and never over cleared depth.
// The slope is computed before anything can discard, since derivatives are undefined after a neighbor discards.
append_line(fs_buf, &fs_len, " highp float decalSlope = fwidth(gl_FragCoord.z);");
append_line(fs_buf, &fs_len, " if (uDecalMode != 0) {");
append_line(fs_buf, &fs_len, " highp float storedZ = texelFetch(uDepthTex, ivec2(gl_FragCoord.xy), 0).r;");
append_line(fs_buf, &fs_len, " highp float dz = max(decalSlope * uDecalPixelScale, 1.0 / 262144.0);");
append_line(fs_buf, &fs_len, " if (storedZ >= 1.0 || abs(gl_FragCoord.z - storedZ) > dz) discard;");
append_line(fs_buf, &fs_len, " }");
/* D548: combiner inputs are 8-bit on the N64 (shade, prim, env), so never
* above 1.0. Under the D540 noperspective shade, GPU clipping of a big
* near-camera triangle can extrapolate them past 1.0; the CC wrap
@@ -703,6 +736,14 @@ static struct ShaderProgram* gfx_opengl_create_and_load_new_shader(uint64_t shad
prg->noise_scale_location = glGetUniformLocation(shader_program, "noise_scale");
prg->three_point_filter_locations[0] = glGetUniformLocation(shader_program, "three_point_filter0");
prg->three_point_filter_locations[1] = glGetUniformLocation(shader_program, "three_point_filter1");
prg->decal_mode_location = glGetUniformLocation(shader_program, "uDecalMode");
prg->decal_scale_location = glGetUniformLocation(shader_program, "uDecalPixelScale");
prg->decal_mode = 0;
prg->decal_scale = 0.0f;
if (prg->decal_mode_location >= 0) {
glUniform1i(prg->decal_mode_location, 0);
glUniform1i(glGetUniformLocation(shader_program, "uDepthTex"), DECAL_DEPTH_TEXTURE_UNIT);
}
gfx_opengl_load_shader(prg);
@@ -722,6 +763,7 @@ static void gfx_opengl_shader_get_info(struct ShaderProgram* prg, uint8_t* num_i
static void gfx_opengl_clear_shaders(void) {
glUseProgram(0);
current_shader_program = nullptr;
for (auto& pair : shader_program_pool) {
glDeleteProgram(pair.second.opengl_program_id);
}
@@ -830,9 +872,9 @@ static void gfx_opengl_set_sampler_parameters(int tile, bool linear_filter, uint
}
mipmaps = mipmaps && (current_mipmap_filter_mode != MIPMAP_DISABLED);
const int mip_idx = mipmaps ? current_mipmap_filter_mode : 0;
const GLint min_filter = linear_filter ? min_filters[current_filter_mode][mip_idx] : GL_NEAREST;
/* Trilinear option (playtest 2026-10-03): TRILINEAR magnifies LINEAR too. */
const GLint max_filter = linear_filter && (current_filter_mode == FILTER_LINEAR || current_filter_mode == FILTER_TRILINEAR) ? GL_LINEAR : GL_NEAREST;
const GLint min_filter = linear_filter ? min_filters[current_filter_mode][mip_idx] : GL_LINEAR;
// Point-sampled textures (e.g. HUD ammo icons) are filtered too
const GLint max_filter = GL_LINEAR;
glActiveTexture(GL_TEXTURE0 + tile);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, min_filter);
@@ -859,6 +901,9 @@ static void gfx_opengl_set_sampler_parameters(int tile, bool linear_filter, uint
}
static void gfx_opengl_set_depth_mode(bool depth_test, bool depth_update, bool depth_compare, bool depth_source_prim, uint16_t zmode) {
current_depth_test = depth_test;
current_depth_decal = depth_test && depth_compare && zmode == ZMODE_DEC;
if (depth_test) {
glEnable(GL_DEPTH_TEST);
glDepthMask(depth_update ? GL_TRUE : GL_FALSE);
@@ -928,10 +973,122 @@ static void gfx_opengl_set_use_alpha(bool use_alpha, bool modulate) {
}
}
static GLuint gfx_opengl_framebuffer_name(size_t fb_id) {
// fb 0 is the window's default framebuffer (GL name 0)
return fb_id == 0 ? 0 : framebuffers[fb_id].fbo;
}
static bool gfx_opengl_update_depth_copy(void) {
if (!depth_copy_supported) {
return false;
}
Framebuffer& fb = framebuffers[current_framebuffer];
if ((current_framebuffer != 0 && !fb.has_depth_buffer) || fb.depth_copy_failed) {
return false;
}
if (!depth_copy_dirty && depth_copy_source == current_framebuffer && depth_copy_width == fb.width &&
depth_copy_height == fb.height) {
return true;
}
if (depth_copy_tex == 0 || depth_copy_width != fb.width || depth_copy_height != fb.height) {
if (depth_copy_tex == 0) {
glGenTextures(1, &depth_copy_tex);
glGenFramebuffers(1, &depth_copy_fbo);
}
GLint active_texture;
glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture);
glActiveTexture(GL_TEXTURE0 + DECAL_DEPTH_TEXTURE_UNIT);
glBindTexture(GL_TEXTURE_2D, depth_copy_tex);
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, fb.width, fb.height, 0, GL_DEPTH_STENCIL,
GL_UNSIGNED_INT_24_8, NULL);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glActiveTexture(active_texture);
const GLenum no_draw_buffer = GL_NONE;
glBindFramebuffer(GL_FRAMEBUFFER, depth_copy_fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D, depth_copy_tex, 0);
glDrawBuffers(1, &no_draw_buffer);
glReadBuffer(GL_NONE);
glBindFramebuffer(GL_FRAMEBUFFER, gfx_opengl_framebuffer_name(current_framebuffer));
depth_copy_width = fb.width;
depth_copy_height = fb.height;
}
const bool check_errors = !fb.depth_copy_checked;
if (check_errors) {
for (int i = 0; i < 16 && glGetError() != GL_NO_ERROR; i++) {
}
}
glDisable(GL_SCISSOR_TEST);
glBindFramebuffer(GL_READ_FRAMEBUFFER, gfx_opengl_framebuffer_name(current_framebuffer));
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, depth_copy_fbo);
glBlitFramebuffer(0, 0, fb.width, fb.height, 0, 0, fb.width, fb.height, GL_DEPTH_BUFFER_BIT, GL_NEAREST);
glBindFramebuffer(GL_FRAMEBUFFER, gfx_opengl_framebuffer_name(current_framebuffer));
glEnable(GL_SCISSOR_TEST);
if (check_errors) {
fb.depth_copy_checked = true;
if (glGetError() != GL_NO_ERROR) {
fb.depth_copy_failed = true;
sysLogPrintf(LOG_WARNING, "GL: could not copy depth buffer of framebuffer %u, decal edges will not be clipped",
(unsigned)current_framebuffer);
return false;
}
}
depth_copy_dirty = false;
depth_copy_source = current_framebuffer;
return true;
}
static void gfx_opengl_set_decal_uniforms(struct ShaderProgram* prg, bool enabled) {
if (prg == nullptr || prg->decal_mode_location < 0) {
return;
}
const int mode = enabled ? 1 : 0;
if (prg->decal_mode != mode) {
glUniform1i(prg->decal_mode_location, mode);
prg->decal_mode = mode;
}
const float scale = framebuffers[current_framebuffer].height / DECAL_N64_SCREEN_HEIGHT;
if (enabled && prg->decal_scale != scale) {
glUniform1f(prg->decal_scale_location, scale);
prg->decal_scale = scale;
}
}
static void gfx_opengl_draw_triangles(float buf_vbo[], size_t buf_vbo_len, size_t buf_vbo_num_tris) {
// printf("flushing %d tris\n", buf_vbo_num_tris);
if (current_depth_decal) {
// The shader replaces the depth test like the RDP does; fall back to polygon offset if depth can't be copied
const bool decal = gfx_opengl_update_depth_copy();
glDepthFunc(decal ? GL_ALWAYS : GL_LEQUAL);
if (decal) {
glDisable(GL_POLYGON_OFFSET_FILL);
} else {
glEnable(GL_POLYGON_OFFSET_FILL);
}
gfx_opengl_set_decal_uniforms(current_shader_program, decal);
} else {
gfx_opengl_set_decal_uniforms(current_shader_program, false);
}
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * buf_vbo_len, buf_vbo, GL_STREAM_DRAW);
glDrawArrays(GL_TRIANGLES, 0, 3 * buf_vbo_num_tris);
if (current_depth_test && current_depth_mask) {
depth_copy_dirty = true;
}
}
typedef void (APIENTRY *DEBUGPROC)(GLenum source,
@@ -1122,6 +1279,11 @@ static void gfx_opengl_init(void) {
gfx_framebuffers_enabled = false;
}
depth_copy_supported = GLVersion.major >= 3 && gfx_opengl_supports_framebuffers() && glDrawBuffers && glReadBuffer;
if (!depth_copy_supported) {
sysLogPrintf(LOG_WARNING, "GL: depth buffer copies unsupported, decal edges will not be clipped");
}
if ((GLVersion.major < 4 || GLVersion.minor < 4) && !GLAD_GL_ARB_texture_mirror_clamp_to_edge) {
// GL_MIRROR_CLAMP_TO_EDGE unsupported
gl_mirror_clamp = GL_MIRRORED_REPEAT;
@@ -1455,6 +1617,7 @@ static void gfx_opengl_update_framebuffer_parameters(int fb_id, uint32_t width,
fb.has_depth_buffer = has_depth_buffer;
fb.msaa_level = msaa_level;
fb.invert_y = opengl_invert_y;
depth_copy_dirty = true;
}
bool gfx_opengl_start_draw_to_framebuffer(int fb_id, float noise_scale) {
@@ -1469,6 +1632,7 @@ bool gfx_opengl_start_draw_to_framebuffer(int fb_id, float noise_scale) {
* GL implementation like Mesa/llvmpipe). */
glBindFramebuffer(GL_FRAMEBUFFER, fb_id == 0 ? 0 : fb.fbo);
current_framebuffer = fb_id;
depth_copy_dirty = true;
return true;
} else {
return false;
@@ -1486,6 +1650,7 @@ void gfx_opengl_clear_framebuffer(bool clear_color, bool clear_depth) {
if (clear_depth) {
glDepthMask(GL_TRUE);
mask |= GL_DEPTH_BUFFER_BIT;
depth_copy_dirty = true;
}
glClear(mask);
if (clear_depth) {
@@ -1509,6 +1674,7 @@ void gfx_opengl_clear_region(bool clear_color, bool clear_depth, int x, int y, i
if (clear_depth) {
glDepthMask(GL_TRUE);
mask |= GL_DEPTH_BUFFER_BIT;
depth_copy_dirty = true;
}
glScissor(x, y, w, h);
glEnable(GL_SCISSOR_TEST);
+4
View File
@@ -112,6 +112,8 @@ s32 portSkipIntro = 0;
* hook in src/game/bondview2.c currentPlayerSetFadeColour). 0 (default) =
* original damage flash. */
s32 portNoHitFlash = 0;
s32 portDecalLimit = 100; /* Game.DecalLimit: bullet holes / blood splats kept per stage (N64: 100) */
s32 portMaxCorpses = 0; /* Game.MaxCorpses: 0 = bodies fade after dying (N64), -1 = never */
/* v0.4.0 M2 (D373/D379): in-game crosshair on/off + tint
* (gunfire.c gunDrawSight, #ifdef PORT). Default keeps the original
@@ -561,6 +563,8 @@ PD_CONSTRUCTOR static void videoConfigInit(void)
configRegisterFloat("Game.ScreenShakeIntensity", &portScreenShakeScale, 0.0f, 10.0f);
configRegisterInt("Game.SkipIntro", &portSkipIntro, 0, 1);
configRegisterInt("Game.NoHitFlash", &portNoHitFlash, 0, 1);
configRegisterInt("Game.DecalLimit", &portDecalLimit, 100, 2000);
configRegisterInt("Game.MaxCorpses", &portMaxCorpses, -1, 64); /* -1 = never fade */
configRegisterInt("Game.AIWideView", &cfgAIWideView, 0, 1); /* D468 */
configRegisterInt("Video.CrosshairHide", &portCrosshairHide, 0, 1); /* v0.4.0 M2 (D373) */
configRegisterInt("Video.CrosshairPersistent", &cfgCrosshairPersistent, 0, 1); /* D436 */
+114
View File
@@ -887,6 +887,99 @@ void chrlvActorFadeAway(ChrRecord *self)
}
#ifdef PORT
/* Game.MaxCorpses: 0 = original (every body fades once its death animation
* ends), -1 = bodies never fade unless guard slots run low (spawning needs 3
* free). Otherwise bodies stay, and the oldest starts its normal fade once
* there are more than this many. A kept body is marked by allowfade ==
* CORPSE_KEEP, and reaptimer holds its death order. */
#define CORPSE_MIN_FREE_SLOTS 4
#define CORPSE_KEEP (-2)
extern s32 portMaxCorpses;
s32 chrGetNumFree(void);
static s32 s_CorpseSeq = 0;
static void chrlvActorKeepCorpse(ChrRecord *self)
{
if (self->actiontype != ACT_DEAD)
{
chrStopFiring(self);
self->actiontype = ACT_DEAD;
self->act_dead.allowfade = CORPSE_KEEP;
self->act_dead.reaptimer = ++s_CorpseSeq;
self->sleep = 0;
/* Scripts see a removed guard once its body would have faded: level
* scripts respawn reinforcements on if_chr_does_not_exist(id), and
* spawned guards reuse that id via SetMyChrNum. Move the body to a
* fresh internal id (as chrAllocate does) so its old one frees up. */
self->chrnum = (s16)player1_guardID;
player1_guardID += 1;
}
}
static void chrlvFadeExcessCorpses(void)
{
for (;;)
{
s32 i;
s32 count = 0;
s32 fading = 0;
bool excess;
ChrRecord *oldest = NULL;
ChrRecord *oldestoffscreen = NULL;
for (i = 0; i < g_NumChrSlots; i++)
{
ChrRecord *chr = &g_ChrSlots[i];
if (chr->model == NULL || chr->prop == NULL || chr->actiontype != ACT_DEAD)
{
continue;
}
if (chr->act_dead.allowfade != CORPSE_KEEP)
{
/* already fading: its slot frees up within 1.5 s */
fading++;
continue;
}
count++;
if (oldest == NULL || chr->act_dead.reaptimer < oldest->act_dead.reaptimer)
{
oldest = chr;
}
if ((chr->prop->flags & PROPFLAG_ONSCREEN) == 0
&& (oldestoffscreen == NULL || chr->act_dead.reaptimer < oldestoffscreen->act_dead.reaptimer))
{
oldestoffscreen = chr;
}
}
if (portMaxCorpses > 0)
{
excess = count > portMaxCorpses;
}
else
{
excess = chrGetNumFree() + fading < CORPSE_MIN_FREE_SLOTS;
}
if (!excess || oldest == NULL)
{
return;
}
/* Prefer one the player can't see; chrlvTickDead starts the fade */
(oldestoffscreen ? oldestoffscreen : oldest)->act_dead.allowfade = -1;
}
}
#endif
/**
* chrStepToSide
@@ -5331,6 +5424,13 @@ void chrlvTickSurrender(ChrRecord *self)
*/
void chrlvTickDead(ChrRecord *self)
{
#ifdef PORT
if (self->act_dead.allowfade == CORPSE_KEEP)
{
return;
}
#endif
if (self->act_init.padding[0] >= 0)
{
self->act_init.padding[0] += g_ClockTimer;
@@ -5502,6 +5602,13 @@ void chrlvTickDie(ChrRecord *self)
return;
}
#ifdef PORT
if (portMaxCorpses != 0)
{
chrlvActorKeepCorpse(self);
}
else
#endif
chrlvActorFadeAway(self);
}
@@ -9618,6 +9725,13 @@ void chrlvAllChrTick(void)
chrlvActionTick(&g_ActiveChrs[i]);
}
#ifdef PORT
if (portMaxCorpses != 0)
{
chrlvFadeExcessCorpses();
}
#endif
g_SeenBondRecentlyGuardCount = 0;
for (i=0; i<max; i++)
+5
View File
@@ -76,6 +76,11 @@ void dynInitMemory(void) {
* targets, so g_VtxBuffers is left alone. */
{
s32 gfxHalf = g_GfxSizesByPlayerCount[getPlayerCount() - 1] * ((s32)sizeof(Gfx) / 8);
extern s32 portDecalLimit;
/* Game.DecalLimit: each impact above the default 100 needs a few more commands */
if (portDecalLimit > 100) {
gfxHalf += (portDecalLimit - 100) * 4 * (s32)sizeof(Gfx);
}
g_GfxBuffers[0] = mempAllocBytesInBank(gfxHalf * 2, MEMPOOL_STAGE);
g_GfxBuffers[1] = (g_GfxBuffers[0] + gfxHalf);
g_GfxBuffers[2] = (g_GfxBuffers[1] + gfxHalf);
+3
View File
@@ -74,6 +74,9 @@ struct Scorch *g_ScorchBuffer;
* cannonically wallhitlist
*/
struct BulletImpact *g_BulletImpactBuffer;
#ifdef PORT
s32 g_BulletImpactBufferLen = BULLET_IMPACT_BUFFER_LEN_DEFAULT;
#endif
// data
//D:80040170
+8 -1
View File
@@ -13,7 +13,14 @@
#define SMOKE_PARTS_LEN 10
#define SCORCH_BUFFER_LEN 20
#define IMPACT_TYPE_LEN 20
#define BULLET_IMPACT_BUFFER_LEN 100
#define BULLET_IMPACT_BUFFER_LEN_DEFAULT 100
#ifdef PORT
/* Game.DecalLimit, latched when the stage's impact buffer is allocated */
extern s32 g_BulletImpactBufferLen;
#define BULLET_IMPACT_BUFFER_LEN g_BulletImpactBufferLen
#else
#define BULLET_IMPACT_BUFFER_LEN BULLET_IMPACT_BUFFER_LEN_DEFAULT
#endif
#define MAX_FLYING_PARTICLES 200
typedef struct s_smoketype {
+6
View File
@@ -57,6 +57,12 @@ void alloc_explosion_smoke_casing_scorch_impact_buffers(void)
}
}
#ifdef PORT
{
extern s32 portDecalLimit;
g_BulletImpactBufferLen = portDecalLimit;
}
#endif
osSyncPrintf("Allocating %d bytes for wallhit data\n", BULLET_IMPACT_BUFFER_LEN * sizeof(struct BulletImpact));
g_BulletImpactBuffer = (struct BulletImpact *)mempAllocBytesInBank(BULLET_IMPACT_BUFFER_LEN * sizeof(struct BulletImpact), MEMPOOL_STAGE);
+7
View File
@@ -28,6 +28,13 @@ void alloc_init_GUARDdata_entries(s32 count)
s32 i;
g_NumChrSlots = count + 10; //special guards?
#ifdef PORT
{
/* Game.MaxCorpses: kept bodies hold their slots; keep room for spawns */
extern s32 portMaxCorpses;
g_NumChrSlots += portMaxCorpses < 0 ? 64 : portMaxCorpses;
}
#endif
g_ChrSlots = mempAllocBytesInBank(align_addr_zero(g_NumChrSlots * sizeof(ChrRecord)), MEMPOOL_STAGE);
for(i = 0; g_NumChrSlots > i; i++)
+1 -3
View File
@@ -2,13 +2,11 @@
#include "bondtypes.h"
#include "initunk_005450.h"
#define MODELHITENTRIES_LEN 600
extern struct ModelHitEntry *g_ModelHitFreeList; // canonically freedist
/**
* These are linker/BSS labels. g_ModelHitEntries is the start of a
* ModelHitEntry[600] pool. g_ModelHitEntriesPenultimate labels entry 598
* ModelHitEntry[MODELHITENTRIES_LEN] pool. g_ModelHitEntriesPenultimate labels entry 598
* inside that same pool and is kept as a raw char symbol so IDO emits the
* original relocation.
*/
+10
View File
@@ -2,6 +2,16 @@
#define _INITUNK_005450_H_
#include <ultra64.h>
/* Hit-test/draw-order entries shared by every model drawn in a frame (each
* chr takes one per drawable node, ~20-30). PC: room for many more drawn
* chrs, e.g. bodies kept by Game.MaxCorpses; exhausting the pool left later
* chrs without entries and crashed the next shot test. */
#if defined(PLATFORM_64BIT)
#define MODELHITENTRIES_LEN 8192
#else
#define MODELHITENTRIES_LEN 600
#endif
void initModelHitEntryFreeList(void);
#endif
+12 -1
View File
@@ -1,6 +1,7 @@
#include <ultra64.h>
#include <memp.h>
#include "objecthandler.h"
#include "initunk_005450.h"
#include "model.h"
// bss
@@ -11,7 +12,7 @@
// writes 600*40 bytes from g_ModelHitEntries and overruns the N64-sized placeholders
// by 12KB into adjacent .bss globals. Size the pool for the real struct on PC; keep
// the original placeholder chain verbatim on N64.
char g_ModelHitEntries[600 * sizeof(ModelHitEntry)];
char g_ModelHitEntries[MODELHITENTRIES_LEN * sizeof(ModelHitEntry)];
#else
//CODE.bss:80076A50
char g_ModelHitEntries[0xC];
@@ -1269,6 +1270,16 @@ s32 sub_GAME_7F06C010(ModelHitEntry **entryptr, coord3d *modelRayStart, coord3d
{
ModelHitEntry *entry = *entryptr;
#ifdef PORT
/* No entries (the shared pool ran out while drawing): nothing to hit */
if (entry == NULL)
{
*outModel = NULL;
*outNode = NULL;
return 0;
}
#endif
while (entry->next != NULL)
{
entry = entry->next;