| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
#pragma once |
| 6 |
|
| 7 |
#include <stdint.h> |
| 8 |
#include <stdbool.h> |
| 9 |
|
| 10 |
#ifdef __cplusplus |
| 11 |
extern "C" { |
| 12 |
#endif |
| 13 |
|
| 14 |
void psg_reset(void); |
| 15 |
void psg_writereg(uint8_t reg, uint8_t val); |
| 16 |
void psg_render(int16_t *buf, unsigned num_samples); |
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
#define PSG_NUM_CHANNELS 16 |
| 25 |
#define PSG_NUM_REGS (PSG_NUM_CHANNELS * 4) |
| 26 |
|
| 27 |
|
| 28 |
enum psg_waveform { |
| 29 |
PSG_WF_PULSE = 0, |
| 30 |
PSG_WF_SAWTOOTH, |
| 31 |
PSG_WF_TRIANGLE, |
| 32 |
PSG_WF_NOISE, |
| 33 |
}; |
| 34 |
|
| 35 |
struct psg_debug_channel { |
| 36 |
uint16_t freq; |
| 37 |
uint8_t vol_raw; |
| 38 |
uint16_t vol_lut; |
| 39 |
bool left, right; |
| 40 |
uint8_t pw; |
| 41 |
uint8_t waveform; |
| 42 |
uint32_t phase; |
| 43 |
uint16_t noiseval; |
| 44 |
int16_t last_sample; |
| 45 |
uint16_t peak; |
| 46 |
}; |
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
bool psg_debug_get_channel(int ch, struct psg_debug_channel *out); |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
uint8_t psg_debug_get_reg(uint8_t reg); |
| 56 |
|
| 57 |
|
| 58 |
uint16_t psg_debug_get_noise_state(void); |
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
#define PSG_SCOPE_SAMPLES 2048 |
| 68 |
#define PSG_SCOPE_MIX_L PSG_NUM_CHANNELS |
| 69 |
#define PSG_SCOPE_MIX_R (PSG_NUM_CHANNELS + 1) |
| 70 |
#define PSG_SCOPE_STREAMS (PSG_NUM_CHANNELS + 2) |
| 71 |
|
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
unsigned psg_debug_scope_read(int ch, int16_t *dest, unsigned max_samples); |
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
unsigned psg_debug_scope_predict(int16_t (*dest)[PSG_SCOPE_SAMPLES], unsigned num_samples); |
| 99 |
|
| 100 |
#ifdef __cplusplus |
| 101 |
} |
| 102 |
#endif |