summaryrefslogtreecommitdiff
path: root/lib/rbcodec/codecs/libgme/kss_scc_apu.h
blob: a6962469ac42864223c0bbd2cb4b96c8263ea463 (plain)
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
// Konami SCC sound chip emulator

// Game_Music_Emu 0.6-pre
#ifndef KSS_SCC_APU_H
#define KSS_SCC_APU_H

#include "blargg_common.h"
#include "blip_buffer.h"

enum { scc_reg_count = 0xB0 }; // 0 <= reg < reg_count
enum { scc_osc_count = 5 };
enum { scc_amp_range = 0x8000 };

struct scc_osc_t
{
	int delay;
	int phase;
	int last_amp;
	struct Blip_Buffer* output;
};

struct Scc_Apu {
	struct scc_osc_t oscs [scc_osc_count];
	blip_time_t last_time;
	unsigned char regs [scc_reg_count];

	struct Blip_Synth synth;
};

void Scc_init( struct Scc_Apu* this );

// Resets sound chip
void Scc_reset( struct Scc_Apu* this );

// Set overall volume, where 1.0 is normal
void Scc_volume( struct Scc_Apu* this, int v );

static inline void Scc_set_output( struct Scc_Apu* this, int index, struct Blip_Buffer* b )
{
	assert( (unsigned) index < scc_osc_count );
	this->oscs [index].output = b;
}

// Emulates to time t, then writes data to reg
void Scc_write( struct Scc_Apu* this, blip_time_t time, int addr, int data );

// Emulates to time t, then subtracts t from the current time.
// OK if previous write call had time slightly after t.
void Scc_end_frame( struct Scc_Apu* this, blip_time_t end_time );

#endif