diff --git a/src/doom/s_sound.c b/src/doom/s_sound.c index e413e589..5ffee9b0 100644 --- a/src/doom/s_sound.c +++ b/src/doom/s_sound.c @@ -90,11 +90,11 @@ static channel_t *channels; // Maximum volume of a sound effect. // Internal default is max out of 0-15. -int sfxVolume = 6; +int sfxVolume = 11; // Maximum volume of music. -int musicVolume = 6; +int musicVolume = 11; // Internal volume level, ranging from 0-127 diff --git a/src/pico/i_input.c b/src/pico/i_input.c index bab0be3e..05440cb8 100644 --- a/src/pico/i_input.c +++ b/src/pico/i_input.c @@ -571,6 +571,7 @@ void I_GetEvent() { #endif #endif +#ifdef DEFCON32_BADGE static const uint8_t bdef[] = { DEFCON32_BADGE_SW_FN_PIN, 0, 0, DEFCON32_BADGE_SW_START_PIN, SDL_SCANCODE_ESCAPE, SDL_SCANCODE_ESCAPE, @@ -585,7 +586,10 @@ static const uint8_t bdef[] = { static uint8_t buttons[count_of(bdef)/3]; static uint8_t keycodex[count_of(bdef)/3]; #include "hardware/gpio.h" +#endif + void I_GetEventTimeout(int key_timeout) { +#ifdef DEFCON32_BADGE static int mods; // this is a bit hacky, but just track the state // of each of the keys we care about, and select a different function @@ -618,6 +622,7 @@ void I_GetEventTimeout(int key_timeout) { } extern boolean show_fps; show_fps = buttons[0]; +#endif #if PICO_ON_DEVICE && !NO_USE_UART if (uart_is_readable(uart_default)) { char c = uart_getc(uart_default); diff --git a/src/pico/i_picosound.c b/src/pico/i_picosound.c index ad35139a..46c74b31 100644 --- a/src/pico/i_picosound.c +++ b/src/pico/i_picosound.c @@ -405,8 +405,19 @@ static void I_Pico_UpdateSound(void) // let's collapse stereo to mono... int16_t *samples = (int16_t *)buffer->buffer->bytes; for(int i=0;isample_count * 2; i += 2) { - // ... and divide by 4 not 2 because the speaker is real bad - samples[i] = samples[i+1] = (samples[i] + samples[i+1])/4; + // hacky: we take 270Mhz / 5431 to be close to our sample rate of 49716 Hz which is a pain + // to change as that is the OPL2 freq + uint x = samples[i] + samples[i+1]; +#ifdef DEFCON32_BADGE + // note 2x because the volume is so quiet - thus the need to saturate + pico_default_asm( + "ssat %0, #16, %0" + : "+r" (x)); + x = 2715 + x * 2715 / 32768; +#else + x = 2715 + x * 2715 / 65536; +#endif + samples[i] = samples[i+1] = x; } give_audio_buffer(producer_pool, buffer); } diff --git a/src/pico/pico_audio_pwm8/audio_pwm8.c b/src/pico/pico_audio_pwm8/audio_pwm8.c index 51ee7a63..c8831b55 100644 --- a/src/pico/pico_audio_pwm8/audio_pwm8.c +++ b/src/pico/pico_audio_pwm8/audio_pwm8.c @@ -65,16 +65,16 @@ const audio_format_t *audio_pwm8_setup(const audio_format_t *intended_audio_form dma_channel_config dma_config = dma_channel_get_default_config(dma_channel); + shared_state.slice_num = pwm_gpio_to_slice_num(config->pins[0]); channel_config_set_dreq(&dma_config, - DREQ_DMA_TIMER0 + PWM_DREQ_NUM(shared_state.slice_num) ); // todo only true for stereo channel_config_set_transfer_data_size(&dma_config, DMA_SIZE_32); // todo only true for same pin - shared_state.slice_num = pwm_gpio_to_slice_num(config->pins[0]); pwm_config pc = pwm_get_default_config(); - pwm_config_set_wrap(&pc, 255); + pwm_config_set_wrap(&pc, 5431); // 270000000 / 49716 ish pwm_init(shared_state.slice_num, &pc, true); dma_channel_configure(dma_channel, &dma_config, diff --git a/src/pico/pico_audio_pwm8/sample_encoding.cpp b/src/pico/pico_audio_pwm8/sample_encoding.cpp index 4b46c702..19526bee 100644 --- a/src/pico/pico_audio_pwm8/sample_encoding.cpp +++ b/src/pico/pico_audio_pwm8/sample_encoding.cpp @@ -32,6 +32,7 @@ audio_buffer_t *audio_pwm8_mono_to_stereo_consumer_take_s16(audio_connection_t * } audio_buffer_t *audio_pwm8_stereo_to_stereo_consumer_take_s16(audio_connection_t *connection, bool block) { - return consumer_pool_take, Stereo>(connection, block); + // buffer conversion is done in i_picosound now, so just do a pass thru copy for now + return consumer_pool_take, Stereo>(connection, block); }