Build fixes underway for QOL_FIXES

This commit is contained in:
Colton Rushton 2021-02-13 19:30:41 -04:00
parent 825aaa03ad
commit 7a00799fe9
16 changed files with 85 additions and 38 deletions

View File

@ -10,7 +10,7 @@ static const Vtx burn_smoke_seg4_vertex_040217C0[] = {
// //! Wrong texture format. Called as rgba16, which makes the burn smoke appear
// as a transparent black burn smoke. Probably meant to show up as white-ish
// burn smoke, but mistakened for being intended as black smoke.
// burn smoke, but mistaken for being intended as black smoke.
// Due to debate in the Koopa shorts PR surrounding the fix to a similar bug,
// said fix is on a compile-time variable. Use QOL_FIXES=1 at compile time
// to fix this.

View File

@ -879,6 +879,9 @@
#define KLEPTO_ANIM_STATE_HOLDING_NOTHING 0
#define KLEPTO_ANIM_STATE_HOLDING_CAP 1
#define KLEPTO_ANIM_STATE_HOLDING_STAR 2
#ifdef QOL_FIXES
#define KLEPTO_ANIM_STATE_HOLDING_TRANSPARENT_STAR 3
#endif
/* Bird */
/* oAction */

View File

@ -170,11 +170,12 @@ void *vec3f_normalize(Vec3f dest) {
//! Possible division by zero
f32 invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]);
#else
f32 invsqrt = 0.0f;
// Fix the division by zero warning by multiplying by 0 when the sqrtf equation happens to equal 0
if (sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]) != 0) {
f32 invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]);
invsqrt = 1.0f / sqrtf(dest[0] * dest[0] + dest[1] * dest[1] + dest[2] * dest[2]);
} else {
f32 invsqrt = 1.0f * 0.0f;
invsqrt = 1.0f * 0.0f;
}
#endif

View File

@ -664,20 +664,19 @@ void unused_set_camera_pitch_shake_env(s16 shake) {
*/
f32 calc_y_to_curr_floor(f32 *posOff, f32 posMul, f32 posBound, f32 *focOff, f32 focMul, f32 focBound) {
f32 floorHeight = sMarioGeometry.currFloorHeight;
#ifndef QOL_FIXES
f32 waterHeight;
#else
f32 waterHeight = sMarioGeometry.waterHeight;
#endif
UNUSED s32 filler;
if (!(sMarioCamState->action & ACT_FLAG_METAL_WATER)) {
#ifndef QOL_FIXES
//! @bug this should use sMarioGeometry.waterHeight
// the variable itself is initialized to sMarioGeometry.waterHeight in QOL_FIXES
if (floorHeight < (waterHeight = find_water_level(sMarioCamState->pos[0], sMarioCamState->pos[2]))) {
floorHeight = waterHeight;
}
#else
if (floorHeight < (sMarioGeometry.waterHeight = find_water_level(sMarioCamState->pos[0], sMarioCamState->pos[2]))) {
floorHeight = sMarioGeometry.waterHeight;
}
#endif
}
if (sMarioCamState->action & ACT_FLAG_ON_POLE) {
@ -9320,15 +9319,16 @@ BAD_RETURN(s32) cutscene_exit_bowser_succ_focus_left(UNUSED struct Camera *c) {
* Instead of focusing on the key, just start a pitch shake. Clever!
* The shake lasts 32 frames.
*/
#ifndef QOL_FIXES
BAD_RETURN(s32) cutscene_exit_bowser_key_toss_shake(struct Camera *c) {
#ifndef QOL_FIXES
//! Unnecessary check.
if (c->cutscene == CUTSCENE_EXIT_BOWSER_SUCC) {
set_camera_pitch_shake(0x800, 0x40, 0x800);
}
#else
#else
BAD_RETURN(s32) cutscene_exit_bowser_key_toss_shake(UNUSED struct Camera *c) {
set_camera_pitch_shake(0x800, 0x40, 0x800);
#endif
#endif
}
/**

View File

@ -2633,7 +2633,11 @@ void render_pause_castle_main_strings(s16 x, s16 y) {
s8 gCourseCompleteCoinsEqual = 0;
s32 gCourseDoneMenuTimer = 0;
#ifndef QOL_FIXES
s32 gCourseCompleteCoins = 0;
#else
u64 gCourseCompleteCoins = 0;
#endif
s8 gHudFlash = 0;
s16 render_pause_courses_and_castle(void) {

View File

@ -1477,7 +1477,7 @@ u32 interact_pole(struct MarioState *m, UNUSED u32 interactType, struct Object *
s32 actionId = m->action & ACT_ID_MASK;
if (actionId >= 0x080 && actionId < 0x0A0) {
if (!(m->prevAction & ACT_FLAG_ON_POLE) || m->usedObj != o) {
#ifdef VERSION_SH
#if defined(VERSION_SH) || defined(QOL_FIXES)
f32 velConv = m->forwardVel; // conserve the velocity.
struct Object *marioObj = m->marioObj;
u32 lowSpeed;
@ -1488,7 +1488,7 @@ u32 interact_pole(struct MarioState *m, UNUSED u32 interactType, struct Object *
mario_stop_riding_and_holding(m);
#ifdef VERSION_SH
#if defined(VERSION_SH) || defined(QOL_FIXES)
lowSpeed = (velConv <= 10.0f);
#endif

View File

@ -235,7 +235,11 @@ static void stub_is_textbox_active(u16 *a0) {
s32 get_star_collection_dialog(struct MarioState *m) {
s32 i;
s32 dialogID = 0;
#ifndef QOL_FIXES
s32 numStarsRequired;
#else
u64 numStarsRequired;
#endif
for (i = 0; i < 6; i++) {
numStarsRequired = sStarsNeededForDialog[i];

View File

@ -222,7 +222,11 @@ u32 main_pool_pop_state(void) {
* function blocks until completion.
*/
static void dma_read(u8 *dest, u8 *srcStart, u8 *srcEnd) {
#ifndef QOL_FIXES
u32 size = ALIGN16(srcEnd - srcStart);
#else
UNUSED u32 size = ALIGN16(srcEnd - srcStart);
#endif
memcpy(dest, srcStart, srcEnd - srcStart);
}

View File

@ -473,7 +473,11 @@ void save_file_reload(void) {
* Update the current save file after collecting a star or a key.
* If coin score is greater than the current high score, update it.
*/
#ifndef QOL_FIXES
void save_file_collect_star_or_key(s16 coinScore, s16 starIndex) {
#else
void save_file_collect_star_or_key(u64 coinScore, s16 starIndex) {
#endif
s32 fileIndex = gCurrSaveFileNum - 1;
s32 courseIndex = gCurrCourseNum - 1;

View File

@ -126,7 +126,11 @@ void save_file_erase(s32 fileIndex);
BAD_RETURN(s32) save_file_copy(s32 srcFileIndex, s32 destFileIndex);
void save_file_load_all(void);
void save_file_reload(void);
#ifndef QOL_FIXES
void save_file_collect_star_or_key(s16 coinScore, s16 starIndex);
#else
void save_file_collect_star_or_key(u64 coinScore, s16 starIndex);
#endif
s32 save_file_exists(s32 fileIndex);
u32 save_file_get_max_coin_score(s32 courseIndex);
s32 save_file_get_course_star_count(s32 fileIndex, s32 courseIndex);

View File

@ -411,7 +411,11 @@ void fatal_printf(const char *fmt, ...) {
gd_printf("%s", va_arg(vl, char *));
break;
case 'c':
#ifndef QOL_FIXES
gd_printf("%c", va_arg(vl, char));
#else
gd_printf("%c", va_arg(vl, int));
#endif
break;
case 'x':
gd_printf("%x", va_arg(vl, s32));

View File

@ -944,11 +944,11 @@ void gd_printf(const char *format, ...) {
break;
case 'c':
//! @bug formatter 'c' uses `s32` for va_arg instead of `char`
// Fixed in QOL_FIXES
// Fixed in QOL_FIXES (`int` is actually supposed to be used instead of `char`)
#ifndef QOL_FIXES
*csr = va_arg(args, s32);
#else
*csr = va_arg(args, char);
*csr = va_arg(args, int);
#endif
csr++;
*csr = '\0';

View File

@ -69,8 +69,10 @@ int run_press_start_demo_timer(s32 timer) {
}
return timer;
}
#ifndef QOL_FIXES
extern int gDemoInputListID_2;
#else
extern int gPressedStart;
int start_demo(int timer)

View File

@ -1,4 +1,5 @@
#include "audio_api.h"
#include "macros.h"
static bool audio_null_init(void) {
return true;
@ -12,7 +13,7 @@ static int audio_null_get_desired_buffered(void) {
return 0;
}
static void audio_null_play(const uint8_t *buf, size_t len) {
static void audio_null_play(UNUSED const uint8_t *buf, UNUSED size_t len) {
}
static void audio_null_shutdown(void) {

View File

@ -28,6 +28,8 @@
#include "../configfile.h"
#include "../fs/fs.h"
#include "macros.h"
#define SUPPORT_CHECK(x) assert(x)
// SCALE_M_N: upscale/downscale M-bit integer to N-bit
@ -201,15 +203,19 @@ static unsigned long get_time(void) {
static void gfx_flush(void) {
if (buf_vbo_len > 0) {
int num = buf_vbo_num_tris;
UNUSED int num = buf_vbo_num_tris;
#ifdef DEBUG
unsigned long t0 = get_time();
#endif
gfx_rapi->draw_triangles(buf_vbo, buf_vbo_len, buf_vbo_num_tris);
buf_vbo_len = 0;
buf_vbo_num_tris = 0;
#ifdef DEBUG
unsigned long t1 = get_time();
/*if (t1 - t0 > 1000) {
if (t1 - t0 > 1000) {
printf("f: %d %d\n", num, (int)(t1 - t0));
}*/
}
#endif
}
}
@ -619,7 +625,9 @@ static void import_texture(int tile) {
load_texture(texname);
#else
// the texture data is actual texture data
#ifdef DEBUG
int t0 = get_time();
#endif
if (fmt == G_IM_FMT_RGBA) {
if (siz == G_IM_SIZ_32b) {
import_texture_rgba32(tile);
@ -658,8 +666,10 @@ static void import_texture(int tile) {
} else {
sys_fatal("unsupported texture format: %u", fmt);
}
#ifdef DEBUG
int t1 = get_time();
//printf("Time diff: %d\n", t1 - t0);
printf("Time diff: %d\n", t1 - t0);
#endif
#endif
}
@ -1130,14 +1140,14 @@ static void gfx_sp_movemem(uint8_t index, uint8_t offset, const void* data) {
}
}
static void gfx_sp_moveword(uint8_t index, uint16_t offset, uint32_t data) {
static void gfx_sp_moveword(uint8_t index, UNUSED uint16_t offset, uint32_t data) {
switch (index) {
case G_MW_NUMLIGHT:
#ifdef F3DEX_GBI_2
rsp.current_num_lights = data / 24 + 1; // add ambient light
#else
// Ambient light is included
// The 31th bit is a flag that lights should be recalculated
// The 31st bit is a flag that lights should be recalculated
rsp.current_num_lights = (data - 0x80000000U) / 32;
#endif
rsp.lights_changed = 1;
@ -1149,12 +1159,12 @@ static void gfx_sp_moveword(uint8_t index, uint16_t offset, uint32_t data) {
}
}
static void gfx_sp_texture(uint16_t sc, uint16_t tc, uint8_t level, uint8_t tile, uint8_t on) {
static void gfx_sp_texture(uint16_t sc, uint16_t tc, UNUSED uint8_t level, UNUSED uint8_t tile, UNUSED uint8_t on) {
rsp.texture_scaling_factor.s = sc;
rsp.texture_scaling_factor.t = tc;
}
static void gfx_dp_set_scissor(uint32_t mode, uint32_t ulx, uint32_t uly, uint32_t lrx, uint32_t lry) {
static void gfx_dp_set_scissor(UNUSED uint32_t mode, uint32_t ulx, uint32_t uly, uint32_t lrx, uint32_t lry) {
float x = ulx / 4.0f * RATIO_X;
float y = (SCREEN_HEIGHT - lry / 4.0f) * RATIO_Y;
float width = (lrx - ulx) / 4.0f * RATIO_X;
@ -1168,12 +1178,12 @@ static void gfx_dp_set_scissor(uint32_t mode, uint32_t ulx, uint32_t uly, uint32
rdp.viewport_or_scissor_changed = true;
}
static void gfx_dp_set_texture_image(uint32_t format, uint32_t size, uint32_t width, const void* addr) {
static void gfx_dp_set_texture_image(UNUSED uint32_t format, uint32_t size, UNUSED uint32_t width, const void* addr) {
rdp.texture_to_load.addr = addr;
rdp.texture_to_load.siz = size;
}
static void gfx_dp_set_tile(uint8_t fmt, uint32_t siz, uint32_t line, uint32_t tmem, uint8_t tile, uint32_t palette, uint32_t cmt, uint32_t maskt, uint32_t shiftt, uint32_t cms, uint32_t masks, uint32_t shifts) {
static void gfx_dp_set_tile(uint8_t fmt, uint32_t siz, uint32_t line, uint32_t tmem, uint8_t tile, uint32_t palette, uint32_t cmt, UNUSED uint32_t maskt, UNUSED uint32_t shiftt, uint32_t cms, UNUSED uint32_t masks, UNUSED uint32_t shifts) {
if (tile == G_TX_RENDERTILE) {
SUPPORT_CHECK(palette == 0); // palette should set upper 4 bits of color index in 4b mode
@ -1202,13 +1212,13 @@ static void gfx_dp_set_tile_size(uint8_t tile, uint16_t uls, uint16_t ult, uint1
}
}
static void gfx_dp_load_tlut(uint8_t tile, uint32_t high_index) {
static void gfx_dp_load_tlut(uint8_t tile, UNUSED uint32_t high_index) {
SUPPORT_CHECK(tile == G_TX_LOADTILE);
SUPPORT_CHECK(rdp.texture_to_load.siz == G_IM_SIZ_16b);
rdp.palette = rdp.texture_to_load.addr;
}
static void gfx_dp_load_block(uint8_t tile, uint32_t uls, uint32_t ult, uint32_t lrs, uint32_t dxt) {
static void gfx_dp_load_block(uint8_t tile, uint32_t uls, uint32_t ult, uint32_t lrs, UNUSED uint32_t dxt) {
if (tile == 1) return;
SUPPORT_CHECK(tile == G_TX_LOADTILE);
SUPPORT_CHECK(uls == 0);
@ -1404,7 +1414,7 @@ static void gfx_draw_rectangle(int32_t ulx, int32_t uly, int32_t lrx, int32_t lr
}
}
static void gfx_dp_texture_rectangle(int32_t ulx, int32_t uly, int32_t lrx, int32_t lry, uint8_t tile, int16_t uls, int16_t ult, int16_t dsdx, int16_t dtdy, bool flip) {
static void gfx_dp_texture_rectangle(int32_t ulx, int32_t uly, int32_t lrx, int32_t lry, UNUSED uint8_t tile, int16_t uls, int16_t ult, int16_t dsdx, int16_t dtdy, bool flip) {
uint32_t saved_combine_mode = rdp.combine_mode;
if ((rdp.other_mode_h & (3U << G_MDSFT_CYCLETYPE)) == G_CYC_COPY) {
// Per RDP Command Summary Set Tile's shift s and this dsdx should be set to 4 texels
@ -1484,7 +1494,7 @@ static void gfx_dp_set_z_image(void *z_buf_address) {
rdp.z_buf_address = z_buf_address;
}
static void gfx_dp_set_color_image(uint32_t format, uint32_t size, uint32_t width, void* address) {
static void gfx_dp_set_color_image(UNUSED uint32_t format, UNUSED uint32_t size, UNUSED uint32_t width, void* address) {
rdp.color_image_address = address;
}
@ -1504,7 +1514,7 @@ static inline void *seg_addr(uintptr_t w1) {
#define C1(pos, width) ((cmd->words.w1 >> (pos)) & ((1U << width) - 1))
static void gfx_run_dl(Gfx* cmd) {
int dummy = 0;
UNUSED int dummy = 0;
for (;;) {
uint32_t opcode = cmd->words.w0 >> 24;
@ -1782,21 +1792,25 @@ void gfx_start_frame(void) {
void gfx_run(Gfx *commands) {
gfx_sp_reset();
//puts("New frame");
#ifdef DEBUG
puts("New frame");
#endif
if (!gfx_wapi->start_frame()) {
dropped_frame = true;
return;
}
dropped_frame = false;
#ifdef DEBUG
double t0 = gfx_wapi->get_time();
#endif
gfx_rapi->start_frame();
gfx_run_dl(commands);
gfx_flush();
#ifdef DEBUG
double t1 = gfx_wapi->get_time();
//printf("Process %f %f\n", t1, t1 - t0);
printf("Process %f %f\n", t1, t1 - t0);
#endif
gfx_rapi->end_frame();
gfx_wapi->swap_buffers_begin();
}

View File

@ -39,6 +39,8 @@
#include "pc/discord/discordrpc.h"
#endif
#include "macros.h"
OSMesg D_80339BEC;
OSMesgQueue gSIEventMesgQueue;
@ -64,7 +66,7 @@ void game_loop_one_iteration(void);
void dispatch_audio_sptask(struct SPTask *spTask) {
}
void set_vblank_handler(s32 index, struct VblankHandler *handler, OSMesgQueue *queue, OSMesg *msg) {
void set_vblank_handler(UNUSED s32 index, UNUSED struct VblankHandler *handler, UNUSED OSMesgQueue *queue, UNUSED OSMesg *msg) {
}
static bool inited = false;