Skip to content

Commit 5e11832

Browse files
committed
Use SGU from firmware source
1 parent 96bf563 commit 5e11832

File tree

6 files changed

+7
-680
lines changed

6 files changed

+7
-680
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ add_subdirectory(src/common)
3131
include_directories(src/common)
3232
include_directories(ext/firmware/src/south)
3333
include_directories(ext/firmware/src/north)
34+
include_directories(ext/firmware/src/audio)
3435
add_executable(emu
3536
src/chips/pwm.c
3637
src/chips/cgia.c
@@ -49,7 +50,7 @@ add_executable(emu
4950
src/ui/ui_app_log.cc
5051
src/ui/ui_x65.cc
5152
src/util/ringbuffer.c
52-
src/chips/su/su.c
53+
ext/firmware/src/audio/snd/su.c
5354
${CMAKE_CURRENT_BINARY_DIR}/version.c
5455
)
5556
target_link_libraries(emu

src/chips/sgu1.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void sgu1_init(sgu1_t* sgu, const sgu1_desc_t* desc) {
2929
sgu->sample_mag = desc->magnitude;
3030
sgu->tick_period = (desc->tick_hz * SGU1_FIXEDPOINT_SCALE) / SGU1_CHIP_CLOCK;
3131
sgu->tick_counter = sgu->tick_period;
32-
SoundUnit_Init(&sgu->su, 65536, false);
32+
SoundUnit_Init(&sgu->su, 65536);
3333
sgu->resampler = speex_resampler_init(SGU1_AUDIO_CHANNELS, SGU1_CHIP_CLOCK, sgu->sound_hz, 10, nullptr);
3434
}
3535

@@ -50,14 +50,14 @@ static uint64_t _sgu1_tick(sgu1_t* sgu, uint64_t pins) {
5050
sgu->tick_counter -= SGU1_FIXEDPOINT_SCALE;
5151
if (sgu->tick_counter <= 0) {
5252
sgu->tick_counter += sgu->tick_period;
53-
short l, r;
53+
int32_t l, r;
5454
SoundUnit_NextSample(&sgu->su, &l, &r);
5555
float in[2] = { ((float)l / 32767.0f), ((float)r / 32767.0f) };
5656
spx_uint32_t in_len = 1; // 1 stereo frame
5757
spx_uint32_t out_len = 1; // room for 1 stereo frame
5858
speex_resampler_process_interleaved_float(sgu->resampler, in, &in_len, sgu->sample, &out_len);
5959

60-
for (int i = 0; i < SGU1_NUM_CHANNELS; i++) {
60+
for (uint8_t i = 0; i < SGU1_NUM_CHANNELS; i++) {
6161
sgu->voice[i].sample_buffer[sgu->voice[i].sample_pos++] = (float)(SoundUnit_GetSample(&sgu->su, i));
6262
if (sgu->voice[i].sample_pos >= SGU1_AUDIO_SAMPLES) {
6363
sgu->voice[i].sample_pos = 0;

src/chips/sgu1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#include <speex_resampler.h>
4646
#include <stdint.h>
4747
#include <stdbool.h>
48-
#include "./su/su.h"
48+
#include "snd/su.h"
4949

5050
#ifdef __cplusplus
5151
extern "C" {

0 commit comments

Comments
 (0)