gbemu/include/audio.h

109 lines
2.1 KiB
C
Raw Normal View History

2025-02-01 23:58:55 -07:00
#pragma once
#include <common.h>
2025-02-03 16:25:18 -07:00
#include <pa_ringbuffer.h>
2025-02-01 23:58:55 -07:00
typedef struct {
2025-02-02 20:36:32 -07:00
bool audio_enabled;
bool ch1_left;
bool ch1_right;
bool ch2_left;
bool ch2_right;
bool ch3_left;
bool ch3_right;
bool ch4_left;
bool ch4_right;
2025-02-03 23:09:12 -07:00
bool ch1_dac;
bool ch2_dac;
bool ch4_dac;
2025-02-04 19:10:57 -07:00
bool ch1_len_fz;
2025-02-05 15:49:53 -07:00
bool ch2_len_fz;
bool ch3_len_fz;
bool ch4_len_fz;
2025-02-04 19:10:57 -07:00
2025-02-02 20:36:32 -07:00
u8 volume_left;
u8 volume_right;
2025-02-03 22:59:24 -07:00
bool vin_left;
bool vin_right;
2025-02-02 20:36:32 -07:00
u8 sq1_duty;
u8 sq1_volume;
u8 sq1_sample;
u16 sq1_period_reset;
u16 sq1_period_timer;
bool sq1_enable;
bool sq1_len_enable;
u8 sq1_sweep_pace;
bool sq1_sweep_direction;
u8 sq1_initial_len;
u8 sq1_len;
u8 sq1_initial_volume;
bool sq1_env_direction;
2025-02-03 16:25:18 -07:00
bool sq1_env_direction_buffer;
2025-02-02 20:36:32 -07:00
u8 sq1_env_pace;
2025-02-03 16:25:18 -07:00
u8 sq1_env_pace_buffer;
2025-02-02 20:36:32 -07:00
u8 sq1_env_timer;
u8 sq1_sweep_step;
2025-02-03 16:25:18 -07:00
u8 sq1_sweep_timer;
bool sq1_sweep_enabled;
u16 sq1_sweep_period;
u16 sq1_calc_period;
u8 sq2_duty;
u8 sq2_volume;
2025-02-02 20:36:32 -07:00
u8 sq2_sample;
u16 sq2_period_reset;
u16 sq2_period_timer;
bool sq2_enable;
bool sq2_len_enable;
u8 sq2_initial_len;
u8 sq2_len;
u8 sq2_initial_volume;
bool sq2_env_direction;
2025-02-03 16:25:18 -07:00
bool sq2_env_direction_buffer;
2025-02-02 20:36:32 -07:00
u8 sq2_env_pace;
2025-02-03 16:25:18 -07:00
u8 sq2_env_pace_buffer;
2025-02-02 20:36:32 -07:00
u8 sq2_env_timer;
2025-02-03 16:25:18 -07:00
bool ch3_enable;
2025-02-03 22:59:24 -07:00
bool ch3_dac;
2025-02-03 16:25:18 -07:00
u8 ch3_initial_len;
u8 ch3_len;
u8 ch3_volume;
u8 ch3_initial_volume;
u16 ch3_period_timer;
u16 ch3_period_reset;
bool ch3_len_enable;
u8 ch3_last_sample;
u8 ch3_sample;
bool ch4_enable;
u8 ch4_initial_len;
u8 ch4_len;
u8 ch4_initial_volume;
u8 ch4_volume;
u8 ch4_env_pace;
u8 ch4_env_pace_buffer;
u8 ch4_env_timer;
bool ch4_env_direction;
bool ch4_env_direction_buffer;
u8 ch4_clock_shift;
bool ch4_lfsr_width;
u8 ch4_clock_divider;
bool ch4_len_enable;
u16 ch4_lfsr;
u8 wave_ram[16];
2025-02-02 20:36:32 -07:00
2025-02-01 23:58:55 -07:00
} audio_context;
2025-02-02 12:35:53 -07:00
void audio_init();
2025-02-02 20:36:32 -07:00
void audio_tick();
void audio_period_tick();
u8 audio_read(u16 address);
void audio_write(u16 address, u8 value);