Minor refactor of some QoL fixes

This commit is contained in:
Colton Rushton 2021-02-14 21:05:14 -04:00
parent 332adb4716
commit 47e3f8b6a3
4 changed files with 33 additions and 12 deletions

View File

@ -2806,8 +2806,11 @@ void print_hud_course_complete_coins(s16 x, s16 y) {
print_hud_lut_string(HUD_LUT_GLOBAL, x + 32, y, courseCompleteCoinsStr);
gSPDisplayList(gDisplayListHead++, dl_rgba16_text_end);
#ifndef QOL_FIXES
if (gCourseCompleteCoins >= gHudDisplay.coins) {
#else
if (gCourseCompleteCoins >= (u64)gHudDisplay.coins) {
#endif
gCourseCompleteCoinsEqual = 1;
gCourseCompleteCoins = gHudDisplay.coins;
@ -2828,7 +2831,11 @@ void print_hud_course_complete_coins(s16 x, s16 y) {
}
}
#ifndef QOL_FIXES
if (gHudDisplay.coins == gCourseCompleteCoins && gGotFileCoinHiScore != 0) {
#else
if ((u64)gHudDisplay.coins == gCourseCompleteCoins && gGotFileCoinHiScore != 0) {
#endif
play_sound(SOUND_MENU_MARIO_CASTLE_WARP2, gDefaultSoundArgs);
}
}

View File

@ -896,7 +896,11 @@ void update_hud_values(void) {
gHudDisplay.flags &= ~HUD_DISPLAY_FLAG_COIN_COUNT;
}
#ifndef QOL_FIXES
if (gHudDisplay.coins < gMarioState->numCoins) {
#else
if ((u64)gHudDisplay.coins < gMarioState->numCoins) {
#endif
if (gGlobalTimer & 0x00000001) {
u32 coinSound;
if (gMarioState->action & (ACT_FLAG_SWIMMING | ACT_FLAG_METAL_WATER)) {

View File

@ -390,11 +390,13 @@ static struct ShaderProgram *gfx_opengl_create_and_load_new_shader(uint32_t shad
vs_buf[vs_len] = '\0';
fs_buf[fs_len] = '\0';
/*puts("Vertex shader:");
#ifdef DEBUG
puts("Vertex shader:");
puts(vs_buf);
puts("Fragment shader:");
puts(fs_buf);
puts("End");*/
puts("End");
#endif
const GLchar *sources[2] = { vs_buf, fs_buf };
const GLint lengths[2] = { vs_len, fs_len };
@ -522,11 +524,11 @@ static GLuint gfx_opengl_new_texture(void) {
}
static void gfx_opengl_select_texture(int tile, GLuint texture_id) {
opengl_tex[tile] = tex_cache + texture_id;
opengl_curtex = tile;
glActiveTexture(GL_TEXTURE0 + tile);
glBindTexture(GL_TEXTURE_2D, opengl_tex[tile]->gltex);
gfx_opengl_set_texture_uniforms(opengl_prg, tile);
opengl_tex[tile] = tex_cache + texture_id;
opengl_curtex = tile;
glActiveTexture(GL_TEXTURE0 + tile);
glBindTexture(GL_TEXTURE_2D, opengl_tex[tile]->gltex);
gfx_opengl_set_texture_uniforms(opengl_prg, tile);
}
static void gfx_opengl_upload_texture(uint8_t *rgba32_buf, int width, int height) {
@ -595,7 +597,9 @@ static void gfx_opengl_set_use_alpha(bool use_alpha) {
}
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);
#ifdef DEBUG
printf("flushing %d tris\n", buf_vbo_num_tris);
#endif
glBufferData(GL_ARRAY_BUFFER, sizeof(float) * buf_vbo_len, buf_vbo, GL_STREAM_DRAW);
glDrawArrays(GL_TRIANGLES, 0, 3 * buf_vbo_num_tris);
}

View File

@ -98,16 +98,22 @@ void produce_one_frame(void) {
int samples_left = audio_api->buffered();
u32 num_audio_samples = samples_left < audio_api->get_desired_buffered() ? SAMPLES_HIGH : SAMPLES_LOW;
//printf("Audio samples: %d %u\n", samples_left, num_audio_samples);
#ifdef DEBUG
printf("Audio samples: %d %u\n", samples_left, num_audio_samples);
#endif
s16 audio_buffer[SAMPLES_HIGH * 2 * 2];
for (int i = 0; i < 2; i++) {
/*if (audio_cnt-- == 0) {
#ifdef DEBUG
if (audio_cnt-- == 0) {
audio_cnt = 2;
}
u32 num_audio_samples = audio_cnt < 2 ? 528 : 544;*/
#endif
create_next_audio_buffer(audio_buffer + i * (num_audio_samples * 2), num_audio_samples);
}
//printf("Audio samples before submitting: %d\n", audio_api->buffered());
#ifdef DEBUG
printf("Audio samples before submitting: %d\n", audio_api->buffered());
#endif
audio_api->play((u8 *)audio_buffer, 2 * num_audio_samples * 4);