Fix some UB behaviour

This commit is contained in:
David Guillen Fandos 2021-06-30 00:29:21 +02:00
parent 48f1a71fb7
commit 836e51b694
2 changed files with 4 additions and 4 deletions

2
cpu.c
View File

@ -266,7 +266,7 @@ void print_register_usage(void)
using_register_list(arm, reg_list, 16) \
#define arm_decode_branch() \
s32 offset = ((s32)(opcode & 0xFFFFFF) << 8) >> 6 \
s32 offset = ((s32)((u32)(opcode << 8))) >> 6 \
#define thumb_decode_shift() \

View File

@ -85,9 +85,9 @@ void sound_timer(fixed8_24 frequency_step, u32 channel)
u32 buffer_index = ds->buffer_index;
s16 current_sample, next_sample;
current_sample = ds->fifo[ds->fifo_base] << 4;
current_sample = ds->fifo[ds->fifo_base] * 16;
ds->fifo_base = (ds->fifo_base + 1) % 32;
next_sample = ds->fifo[ds->fifo_base] << 4;
next_sample = ds->fifo[ds->fifo_base] * 16;
if(sound_on == 1)
{
@ -655,7 +655,7 @@ void render_audio(void)
current_sample = 2047;
if(current_sample < -2048)
current_sample = -2048;
stream_base[i] = current_sample << 4;
stream_base[i] = current_sample * 16;
source[i] = 0;
}
audio_batch_cb(stream_base, 256);