ipatix / gba-hq-mixer

This repository contains multiple versions of my so called "HQ mixer" for GBA games which use the m4a/mp2k sound driver.
GNU General Public License v3.0
36 stars 6 forks source link

R5 is overwritten in C_channel_state_loop #6

Closed laqieer closed 3 years ago

laqieer commented 3 years ago

https://github.com/ipatix/gba-hq-mixer/blob/8084e0056077cc3d51229eda95aaad98be674fdf/m4a_hq_mixer.s#L163 https://github.com/ipatix/gba-hq-mixer/blob/8084e0056077cc3d51229eda95aaad98be674fdf/m4a_hq_mixer.s#L164 https://github.com/ipatix/gba-hq-mixer/blob/8084e0056077cc3d51229eda95aaad98be674fdf/m4a_hq_mixer.s#L165

LDRB    R5, [R3, #WAVE_TYPE]
LSL     R5, R5, #31
LDRB    R5, [R4, #CHN_MODE]
laqieer commented 3 years ago

For compressed wav data, it prvents the routine from choosing the correct branch C_channel_init_comp and causes https://github.com/ipatix/gba-hq-mixer/issues/7

ipatix commented 3 years ago

This is intentional. R5 is shifted by 31 to the left in order to set the Sign Flag which is then evaluated here: https://github.com/ipatix/gba-hq-mixer/blob/8084e0056077cc3d51229eda95aaad98be674fdf/m4a_hq_mixer.s#L166

The result of R5 is intentionally discarded and it is a common way to do this (gcc also does this) to check for single bits in a value.

ipatix commented 3 years ago

7 Is caused by the code simply not supporting compressed samples which are not aligned to 64 samples.

laqieer commented 3 years ago

Good to learn that. Thx.