Skip to content

Commit ada7400

Browse files
committed
Compile SGU1 as C code
1 parent c4d058d commit ada7400

File tree

4 files changed

+10
-11
lines changed

4 files changed

+10
-11
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ add_executable(emu
3535
src/chips/pwm.c
3636
src/chips/cgia.c
3737
src/chips/ria816.c
38-
src/chips/sgu1.cc
38+
src/chips/sgu1.c
3939
src/chips/tca6416a.c
4040
src/systems/x65.c
4141
src/x65.c

ext/CMakeLists.txt

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
include_directories(imgui)
22

33
add_library(imgui-docking STATIC
4-
imgui/imgui.cpp
5-
imgui/imgui.h
6-
imgui/imstb_rectpack.h
7-
imgui/imstb_textedit.h
8-
imgui/imstb_truetype.h
4+
imgui/imgui.cpp
5+
imgui/imgui.h
6+
imgui/imstb_rectpack.h
7+
imgui/imstb_textedit.h
8+
imgui/imstb_truetype.h
99
imgui/imgui_demo.cpp
1010
imgui/imgui_draw.cpp
1111
imgui/imgui_internal.h
@@ -14,7 +14,7 @@ add_library(imgui-docking STATIC
1414
)
1515

1616
add_library(imgui-toggle STATIC
17-
imgui_toggle/imgui_offset_rect.h
17+
imgui_toggle/imgui_offset_rect.h
1818
imgui_toggle/imgui_toggle.cpp
1919
imgui_toggle/imgui_toggle.h
2020
imgui_toggle/imgui_toggle_math.h
@@ -27,7 +27,7 @@ add_library(imgui-toggle STATIC
2727
)
2828

2929
add_library(speex-resampler STATIC
30-
speexdsp/libspeexdsp/resample.c
30+
speexdsp/libspeexdsp/resample.c
3131
)
3232
target_include_directories(speex-resampler PUBLIC
3333
speexdsp/include
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ void sgu1_init(sgu1_t* sgu, const sgu1_desc_t* desc) {
3333
sgu->sample_period = (desc->tick_hz * SGU1_FIXEDPOINT_SCALE) / desc->sound_hz;
3434
sgu->sample_counter = sgu->sample_period;
3535
sgu->sample_mag = desc->magnitude;
36-
// sgu->sample_accum_count[0] = sgu->sample_accum_count[1] = 1.0f;
3736
sgu->tick_period = (desc->tick_hz * SGU1_FIXEDPOINT_SCALE) / (CHIP_CLOCK / CHIP_DIVIDER);
3837
sgu->tick_counter = sgu->tick_period;
3938
SoundUnit_Init(&sgu->su, 65536, false);
@@ -65,7 +64,7 @@ static uint64_t _sgu1_tick(sgu1_t* sgu, uint64_t pins) {
6564
speex_resampler_process_interleaved_float(sgu->resampler, in, &in_len, sgu->sample, &out_len);
6665

6766
for (int i = 0; i < SGU1_NUM_CHANNELS; i++) {
68-
sgu->voice[i].sample_buffer[sgu->voice[i].sample_pos++] = (float)SoundUnit_GetSample(&sgu->su, i);
67+
sgu->voice[i].sample_buffer[sgu->voice[i].sample_pos++] = (float)(SoundUnit_GetSample(&sgu->su, i));
6968
if (sgu->voice[i].sample_pos >= SGU1_AUDIO_SAMPLES) {
7069
sgu->voice[i].sample_pos = 0;
7170
}

src/chips/su/su.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ void SoundUnit_Init(SoundUnit* su, size_t sampleMemSize, bool dsOutMode);
106106
void SoundUnit_Reset(SoundUnit* su);
107107
void SoundUnit_Write(SoundUnit* su, uint8_t addr, uint8_t data);
108108
void SoundUnit_NextSample(SoundUnit* su, int16_t* l, int16_t* r);
109-
inline int32_t SoundUnit_GetSample(SoundUnit* su, int32_t ch) {
109+
static inline int32_t SoundUnit_GetSample(SoundUnit* su, int32_t ch) {
110110
int32_t ret = (su->nsL[ch] + su->nsR[ch]) >> 1;
111111
if (ret < -32768) ret = -32768;
112112
if (ret > 32767) ret = 32767;

0 commit comments

Comments
 (0)