| 1 |
/* |
| 2 |
* vic20sound.h - implementation of VIC20 sound code |
| 3 |
* |
| 4 |
* Written by |
| 5 |
* Teemu Rantanen <[email protected]> |
| 6 |
* |
| 7 |
* This file is part of VICE, the Versatile Commodore Emulator. |
| 8 |
* See README for copyright notice. |
| 9 |
* |
| 10 |
* This program is free software; you can redistribute it and/or modify |
| 11 |
* it under the terms of the GNU General Public License as published by |
| 12 |
* the Free Software Foundation; either version 2 of the License, or |
| 13 |
* (at your option) any later version. |
| 14 |
* |
| 15 |
* This program is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 |
* GNU General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU General Public License |
| 21 |
* along with this program; if not, write to the Free Software |
| 22 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 23 |
* 02111-1307 USA. |
| 24 |
* |
| 25 |
*/ |
| 26 |
|
| 27 |
#ifndef VICE_VIC20SOUND_H |
| 28 |
#define VICE_VIC20SOUND_H |
| 29 |
|
| 30 |
#ifdef __cplusplus |
| 31 |
extern "C" { |
| 32 |
#endif |
| 33 |
|
| 34 |
#include <stdint.h> |
| 35 |
#include <stdbool.h> |
| 36 |
|
| 37 |
struct sound_vic20_s { |
| 38 |
unsigned char div; |
| 39 |
struct { |
| 40 |
unsigned char out; |
| 41 |
unsigned char reg; |
| 42 |
unsigned char shift; |
| 43 |
signed short ctr; |
| 44 |
} ch[4]; |
| 45 |
unsigned short noisectr; |
| 46 |
unsigned char volume; |
| 47 |
int cyclecount; |
| 48 |
|
| 49 |
int accum; |
| 50 |
int accum_cycles; |
| 51 |
|
| 52 |
float cycles_per_sample; |
| 53 |
float leftover_cycles; |
| 54 |
int speed; |
| 55 |
|
| 56 |
float highpassbuf; |
| 57 |
float highpassbeta; |
| 58 |
float lowpassbuf; |
| 59 |
float lowpassbeta; |
| 60 |
bool filter_off; |
| 61 |
|
| 62 |
uint16_t noise_LFSR; |
| 63 |
uint8_t noise_LFSR0_old; |
| 64 |
}; |
| 65 |
typedef struct sound_vic20_s sound_vic20_t; |
| 66 |
|
| 67 |
int vic_sound_machine_init(sound_vic20_t *snd, int speed, int cycles_per_sec, bool filter_off); |
| 68 |
void vic_sound_machine_store(sound_vic20_t *snd, uint16_t addr, uint8_t value); |
| 69 |
int vic_sound_machine_calculate_samples(sound_vic20_t *snd, int16_t *pbuf, int nr, int soc, int scc, uint32_t delta_t); |
| 70 |
void vic_sound_clock(sound_vic20_t *snd, uint32_t cycles); |
| 71 |
|
| 72 |
#ifdef __cplusplus |
| 73 |
}; |
| 74 |
#endif |
| 75 |
#endif |