-
Notifications
You must be signed in to change notification settings - Fork 13
/
FastDigitalRenderer.h
67 lines (52 loc) · 1.97 KB
/
FastDigitalRenderer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/*
Frodo, Commodore 64 emulator for the iPhone
Copyright (C) 1994-1997,2002 Christian Bauer
See gpl.txt for license information.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#import "SIDRenderer.h"
#import "sysdeps.h"
#include "Display.h"
class CAudioQueueManager;
const uint32 SAMPLE_FREQ = 22050; // Sample output frequency in Hz
const uint32 SID_FREQ = 985248; // SID frequency in Hz
const uint32 CALC_FREQ = 50; // Frequency at which calc_buffer is called in Hz (should be 50Hz)
const uint32 SID_CYCLES = SID_FREQ/SAMPLE_FREQ; // # of SID clocks per sample frame
const int SAMPLE_BUF_SIZE = 0x138*2;// Size of buffer for sampled voice (double buffered)
const int FRAGMENT_SIZE = SAMPLE_FREQ / CALC_FREQ;
typedef struct sound_s sound_t;
// Renderer class
class FastDigitalRenderer {
public:
FastDigitalRenderer();
~FastDigitalRenderer();
void Reset(void);
inline void EmulateLine(void) {
sample_buf[sample_in_ptr] = volume;
sample_in_ptr++;
if (sample_in_ptr == SAMPLE_BUF_SIZE)
sample_in_ptr = 0;
}
void VBlank(void);
void WriteRegister(uint16 adr, uint8 byte);
void NewPrefs(Prefs *prefs);
void Pause(void);
void Resume(void);
private:
void init_sound();
CAudioQueueManager *_audioQueue;
sound_t *_fastSID;
bool ready;
uint8 sample_buf[SAMPLE_BUF_SIZE]; // Buffer for sampled voice
int sample_in_ptr; // Index in sample_buf for writing
uint8 volume;
};