-
Notifications
You must be signed in to change notification settings - Fork 16
/
apu.h
81 lines (72 loc) · 2.06 KB
/
apu.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/*
* Copyright (C) 2017 - 2018 FIX94
*
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
#ifndef _apu_h_
#define _apu_h_
#include "common.h"
#define NUM_BUFFERS 4
#define EXP_VRC6 (1<<0)
#define EXP_VRC7 (1<<1)
#define EXP_FDS (1<<2)
#define EXP_MMC5 (1<<3)
#define EXP_N163 (1<<4)
#define EXP_S5B (1<<5)
void apuInitBufs();
void apuDeinitBufs();
void apuInit();
FIXNES_ALWAYSINLINE void apuCycle();
void apuWriteDMCBuf(uint8_t val);
uint8_t *apuGetBuf();
uint32_t apuGetBufSize();
uint32_t apuGetFrequency();
void apuSetReg00(uint16_t addr, uint8_t val);
void apuSetReg01(uint16_t addr, uint8_t val);
void apuSetReg02(uint16_t addr, uint8_t val);
void apuSetReg03(uint16_t addr, uint8_t val);
void apuSetReg04(uint16_t addr, uint8_t val);
void apuSetReg05(uint16_t addr, uint8_t val);
void apuSetReg06(uint16_t addr, uint8_t val);
void apuSetReg07(uint16_t addr, uint8_t val);
void apuSetReg08(uint16_t addr, uint8_t val);
void apuSetReg0A(uint16_t addr, uint8_t val);
void apuSetReg0B(uint16_t addr, uint8_t val);
void apuSetReg0C(uint16_t addr, uint8_t val);
void apuSetReg0E(uint16_t addr, uint8_t val);
void apuSetReg0F(uint16_t addr, uint8_t val);
void apuSetReg10(uint16_t addr, uint8_t val);
void apuSetReg11(uint16_t addr, uint8_t val);
void apuSetReg12(uint16_t addr, uint8_t val);
void apuSetReg13(uint16_t addr, uint8_t val);
void apuSetReg15(uint16_t addr, uint8_t val);
void apuSetReg17(uint16_t addr, uint8_t val);
uint8_t apuGetReg15(uint16_t addr);
bool apuUpdate();
void apuBoot();
void apuReset();
typedef struct _envelope_t {
bool start;
bool constant;
bool loop;
uint8_t vol;
//uint8_t envelope;
uint8_t divider;
uint8_t decay;
} envelope_t;
typedef struct _sweep_t {
bool enabled;
bool start;
bool negative;
bool mute;
bool chan1;
uint8_t period;
uint8_t divider;
uint8_t shift;
//specifically signed for pulse 1 as a shift value of 0 and negative
//flag enabled would cause an overflow and a mute otherwise
int16_t targetFreq;
} sweep_t;
void doEnvelopeLogic(envelope_t *env);
#endif