Merge pull request #94 from davidgfnet/master

Small fixes to division by zero
This commit is contained in:
Autechre 2021-02-24 03:58:08 +01:00 committed by GitHub
commit 28aa08de99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -199,7 +199,7 @@ static void sound_control_x(u32 value)
#define sound_update_frequency_step(timer_number) \
timer[timer_number].frequency_step = \
float_to_fp8_24(GBC_BASE_RATE / (timer_reload * sound_frequency)) \
float_to_fp8_24((GBC_BASE_RATE / sound_frequency) / (timer_reload)) \
/* Main */
extern timer_type timer[4];

View File

@ -273,8 +273,11 @@ u32 gbc_sound_master_volume;
else \
rate = rate + (rate >> gs->sweep_shift); \
\
if(rate > 2048) \
rate = 2048; \
if(rate > 2047) { \
rate = 2047; \
gs->active_flag = 0; \
break; \
} \
\
frequency_step = float_to_fp16_16(((131072.0f / (2048 - rate)) * 8.0f) \
/ sound_frequency); \