| 1 |
/* |
| 2 |
* ted-sound.h |
| 3 |
* |
| 4 |
* Written by |
| 5 |
* Andreas Boose <[email protected]> |
| 6 |
* Marco van den Heuvel <[email protected]> |
| 7 |
* |
| 8 |
* This file is part of VICE, the Versatile Commodore Emulator. |
| 9 |
* See README for copyright notice. |
| 10 |
* |
| 11 |
* This program is free software; you can redistribute it and/or modify |
| 12 |
* it under the terms of the GNU General Public License as published by |
| 13 |
* the Free Software Foundation; either version 2 of the License, or |
| 14 |
* (at your option) any later version. |
| 15 |
* |
| 16 |
* This program is distributed in the hope that it will be useful, |
| 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 |
* GNU General Public License for more details. |
| 20 |
* |
| 21 |
* You should have received a copy of the GNU General Public License |
| 22 |
* along with this program; if not, write to the Free Software |
| 23 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
| 24 |
* 02111-1307 USA. |
| 25 |
* |
| 26 |
*/ |
| 27 |
|
| 28 |
#ifndef VICE_TEDSOUND_H |
| 29 |
#define VICE_TEDSOUND_H |
| 30 |
|
| 31 |
#ifdef __cplusplus |
| 32 |
extern "C" { |
| 33 |
#endif |
| 34 |
|
| 35 |
#include <stdint.h> |
| 36 |
|
| 37 |
struct plus4_sound_s { |
| 38 |
/* Voice 0 collect number of cycles elapsed */ |
| 39 |
uint32_t voice0_accu; |
| 40 |
/* Voice 0 toggle sign and reload accu if accu reached 0 */ |
| 41 |
uint32_t voice0_reload; |
| 42 |
/* Voice 0 sign of the square wave */ |
| 43 |
int16_t voice0_sign; |
| 44 |
uint8_t voice0_output_enabled; |
| 45 |
|
| 46 |
/* Voice 1 collect number of cycles elapsed */ |
| 47 |
uint32_t voice1_accu; |
| 48 |
/* Voice 1 toggle sign and reload accu if accu reached 0 */ |
| 49 |
uint32_t voice1_reload; |
| 50 |
/* Voice 1 sign of the square wave */ |
| 51 |
int16_t voice1_sign; |
| 52 |
uint8_t voice1_output_enabled; |
| 53 |
|
| 54 |
/* Volume multiplier */ |
| 55 |
int16_t volume; |
| 56 |
/* 8 cycles units per sample */ |
| 57 |
uint32_t speed; |
| 58 |
uint32_t sample_position_integer; |
| 59 |
uint32_t sample_position_remainder; |
| 60 |
uint32_t sample_length_integer; |
| 61 |
uint32_t sample_length_remainder; |
| 62 |
/* Digital output? */ |
| 63 |
uint8_t digital; |
| 64 |
/* Noise generator active? */ |
| 65 |
uint8_t noise; |
| 66 |
uint8_t noise_shift_register; |
| 67 |
|
| 68 |
/* Registers */ |
| 69 |
uint8_t plus4_sound_data[5]; |
| 70 |
}; |
| 71 |
|
| 72 |
int ted_sound_machine_init(struct plus4_sound_s* snd, int speed, int cycles_per_sec); |
| 73 |
int ted_sound_machine_calculate_samples(struct plus4_sound_s* snd, int16_t *pbuf, int nr, int sound_chip_channels); |
| 74 |
void ted_sound_machine_store(struct plus4_sound_s* snd, uint16_t addr, uint8_t val); |
| 75 |
uint8_t ted_sound_machine_read(struct plus4_sound_s* snd, uint16_t addr); |
| 76 |
void ted_sound_reset(struct plus4_sound_s* snd); |
| 77 |
|
| 78 |
#ifdef __cplusplus |
| 79 |
}; |
| 80 |
#endif |
| 81 |
#endif |