added apex audio system
[gbajam21] / libs / aas / AAS_Shared.h
1 /* Copyright (c) 2003-2021 James Daniels */
2 /* Distributed under the MIT License */
3 /* license terms: see LICENSE file in root or http://opensource.org/licenses/MIT */
4
5 #ifndef __AAS_SHARED__
6 #define __AAS_SHARED__
7
8 #include "AAS.h"
9 #include "AAS_Mixer.h"
10
11 #define AAS_MAX_CHANNELS 16
12
13 #define REG_SOUNDCNT_L (*(volatile AAS_u16 *)0x4000080)
14 #define REG_SOUNDCNT_H (*(volatile AAS_u16 *)0x4000082)
15 #define REG_SOUNDCNT_X (*(volatile AAS_u16 *)0x4000084)
16
17 #define REG_DMA1SAD    (*(volatile AAS_u32 *)0x40000BC)
18 #define REG_DMA1DAD    (*(volatile AAS_u32 *)0x40000C0)
19 #define REG_DMA1CNT_H  (*(volatile AAS_u16 *)0x40000C6)
20 #define REG_DMA1CNT    (*(volatile AAS_u32 *)0x40000C4)
21
22 #define REG_DMA2SAD    (*(volatile AAS_u32 *)0x40000C8)
23 #define REG_DMA2DAD    (*(volatile AAS_u32 *)0x40000CC)
24 #define REG_DMA2CNT_H  (*(volatile AAS_u16 *)0x40000D2)
25 #define REG_DMA2CNT    (*(volatile AAS_u32 *)0x40000d0)
26
27 #define REG_TM0CNT     (*(volatile AAS_u16 *)0x4000102)
28 #define REG_TM0D       (*(volatile AAS_u16 *)0x4000100)
29
30 #define REG_TM1CNT     (*(volatile AAS_u16 *)0x4000106)
31 #define REG_TM1D       (*(volatile AAS_u16 *)0x4000104)
32
33 #define REG_IE         (*(volatile AAS_u16 *)0x4000200)
34 #define REG_IME        (*(volatile AAS_u16 *)0x4000208)
35 #define REG_IF         (*(volatile AAS_u16 *)0x4000202)
36
37 #define DISPCNT              (*(volatile AAS_u16 *)0x4000000)
38 #define REG_VCOUNT     (*(volatile AAS_u16 *)0x4000006)
39
40 struct AAS_ModSample
41 {
42         AAS_u32 data; /* offset in bytes */
43         AAS_u16 repeat; /* in halfwords */
44         AAS_u16 length; /* in halfwords */
45         AAS_u8 finetune;
46         AAS_u8 volume;
47         AAS_u16 padding;
48 };
49
50 extern const AAS_u16 AAS_DATA_NUM_MODS;
51 extern const struct AAS_ModSample AAS_ModSamples[][31];
52 extern const AAS_s16 AAS_Sequence[][128][16];
53 extern const AAS_u8 AAS_NumChans[];
54 extern const AAS_u8 AAS_RestartPos[];
55 extern const AAS_u8 AAS_PatternData[];
56 extern const AAS_s8 AAS_SampleData[];
57
58 extern const AAS_u16 AAS_DivTable[8192];
59 extern const AAS_u16 AAS_MOD_period_conv_table[2048];
60 extern const AAS_u16 AAS_period_table[16][60];
61
62 extern const AAS_u16 AAS_tick_rate[41];
63
64 extern const AAS_s8 AAS_sin[64];
65
66 extern AAS_s16 AAS_mod_num AAS_IN_EWRAM;
67 extern AAS_BOOL AAS_initialised AAS_IN_EWRAM;
68 extern AAS_u8 AAS_volscale AAS_IN_EWRAM;
69 extern AAS_u8 AAS_mod_num_chans AAS_IN_EWRAM;
70 extern AAS_u16 AAS_mix_scale AAS_IN_EWRAM;
71 extern AAS_BOOL AAS_changed[2] AAS_IN_IWRAM;
72
73 extern AAS_u8 AAS_chan_rearrange[AAS_MAX_CHANNELS] AAS_IN_EWRAM;
74
75 __inline static int AAS_Min( int a, int b )
76 {
77   if ( a < b )
78       return a;
79   else
80       return b;
81 }
82
83 #endif