git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit 95773b9538b5b85de95bdc06ab568b1a833386f0
parent 52ab20054486330a8757641230f55c716ea525e6
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Sun, 14 Aug 2022 01:54:28 +0300

Make things const

Diffstat:
MCore/apu.c10+++++-----
MCore/debugger.c6+++---
MCore/display.c6+++---
3 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/Core/apu.c b/Core/apu.c @@ -1292,7 +1292,7 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) gb->apu.wave_channel.pulse_length = (0x100 - value); break; case GB_IO_NR32: - gb->apu.wave_channel.shift = (uint8_t[]){4, 0, 1, 2}[(value >> 5) & 3]; + gb->apu.wave_channel.shift = (const uint8_t[]){4, 0, 1, 2}[(value >> 5) & 3]; if (gb->apu.is_active[GB_WAVE]) { update_wave_sample(gb, 0); } @@ -1407,11 +1407,11 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) if (!divisor) divisor = 2; if (gb->model > GB_MODEL_CGB_C) { gb->apu.noise_channel.counter_countdown = - divisor + (divisor == 2? 0 : (uint8_t[]){2, 1, 0, 3}[(gb->apu.noise_channel.alignment) & 3]); + divisor + (divisor == 2? 0 : (const uint8_t[]){2, 1, 0, 3}[(gb->apu.noise_channel.alignment) & 3]); } else { gb->apu.noise_channel.counter_countdown = - divisor + (divisor == 2? 0 : (uint8_t[]){2, 1, 4, 3}[(gb->apu.noise_channel.alignment) & 3]); + divisor + (divisor == 2? 0 : (const uint8_t[]){2, 1, 4, 3}[(gb->apu.noise_channel.alignment) & 3]); } gb->apu.noise_channel.delta = 0; } @@ -1455,10 +1455,10 @@ void GB_apu_write(GB_gameboy_t *gb, uint8_t reg, uint8_t value) } else { if (gb->model <= GB_MODEL_CGB_C) { - gb->apu.noise_channel.counter_countdown += (uint8_t[]){2, 1, 4, 3}[gb->apu.noise_channel.alignment & 3]; + gb->apu.noise_channel.counter_countdown += (const uint8_t[]){2, 1, 4, 3}[gb->apu.noise_channel.alignment & 3]; } else { - gb->apu.noise_channel.counter_countdown += (uint8_t[]){2, 1, 0, 3}[gb->apu.noise_channel.alignment & 3]; + gb->apu.noise_channel.counter_countdown += (const uint8_t[]){2, 1, 0, 3}[gb->apu.noise_channel.alignment & 3]; } if (((gb->apu.noise_channel.alignment + 1) & 3) < 2) { if ((gb->io_registers[GB_IO_NR43] & 0x07) == 1) { diff --git a/Core/debugger.c b/Core/debugger.c @@ -1803,8 +1803,8 @@ static bool apu(GB_gameboy_t *gb, char *arguments, char *modifiers, const debugg uint8_t duty = gb->io_registers[channel == GB_SQUARE_1? GB_IO_NR11 :GB_IO_NR21] >> 6; GB_log(gb, " Duty cycle %s%% (%s), current index %u/8%s\n", - duty > 3? "" : (const char *[]){"12.5", " 25", " 50", " 75"}[duty], - duty > 3? "" : (const char *[]){"_______-", "-______-", "-____---", "_------_"}[duty], + duty > 3? "" : (const char *const[]){"12.5", " 25", " 50", " 75"}[duty], + duty > 3? "" : (const char *const[]){"_______-", "-______-", "-____---", "_------_"}[duty], gb->apu.square_channels[channel].current_sample_index, gb->apu.square_channels[channel].sample_surpressed ? " (suppressed)" : ""); @@ -1839,7 +1839,7 @@ static bool apu(GB_gameboy_t *gb, char *arguments, char *modifiers, const debugg GB_log(gb, " Current position: %u\n", gb->apu.wave_channel.current_sample_index); GB_log(gb, " Volume %s (right-shifted %u times)\n", - gb->apu.wave_channel.shift > 4? "" : (const char *[]){"100%", "50%", "25%", "", "muted"}[gb->apu.wave_channel.shift], + gb->apu.wave_channel.shift > 4? "" : (const char *const[]){"100%", "50%", "25%", "", "muted"}[gb->apu.wave_channel.shift], gb->apu.wave_channel.shift); GB_log(gb, " Current sample length: %u APU ticks (next in %u ticks)\n", diff --git a/Core/display.c b/Core/display.c @@ -253,17 +253,17 @@ static inline uint8_t scale_channel(uint8_t x) static inline uint8_t scale_channel_with_curve(uint8_t x) { - return (uint8_t[]){0,6,12,20,28,36,45,56,66,76,88,100,113,125,137,149,161,172,182,192,202,210,218,225,232,238,243,247,250,252,254,255}[x]; + return (const uint8_t[]){0,6,12,20,28,36,45,56,66,76,88,100,113,125,137,149,161,172,182,192,202,210,218,225,232,238,243,247,250,252,254,255}[x]; } static inline uint8_t scale_channel_with_curve_agb(uint8_t x) { - return (uint8_t[]){0,3,8,14,20,26,33,40,47,54,62,70,78,86,94,103,112,120,129,138,147,157,166,176,185,195,205,215,225,235,245,255}[x]; + return (const uint8_t[]){0,3,8,14,20,26,33,40,47,54,62,70,78,86,94,103,112,120,129,138,147,157,166,176,185,195,205,215,225,235,245,255}[x]; } static inline uint8_t scale_channel_with_curve_sgb(uint8_t x) { - return (uint8_t[]){0,2,5,9,15,20,27,34,42,50,58,67,76,85,94,104,114,123,133,143,153,163,173,182,192,202,211,220,229,238,247,255}[x]; + return (const uint8_t[]){0,2,5,9,15,20,27,34,42,50,58,67,76,85,94,104,114,123,133,143,153,163,173,182,192,202,211,220,229,238,247,255}[x]; }

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.