Mercurial > hg > index.fcgi > lj > lj046-2players
annotate src/pin8gba_sound.h @ 2:80a2761bd3a4
change DS keys (add alt. rotate)
author | paulo@localhost |
---|---|
date | Mon, 23 Mar 2009 01:19:12 -0700 |
parents | |
children |
rev | line source |
---|---|
paulo@0 | 1 /* |
paulo@0 | 2 * pin8gba_sound.h |
paulo@0 | 3 * Header file for GBA sound registers |
paulo@0 | 4 */ |
paulo@0 | 5 |
paulo@0 | 6 |
paulo@0 | 7 /* Copyright 2001-2006 Damian Yerrick |
paulo@0 | 8 |
paulo@0 | 9 (insert zlib license here) |
paulo@0 | 10 |
paulo@0 | 11 */ |
paulo@0 | 12 |
paulo@0 | 13 |
paulo@0 | 14 /* Why the funny register names? |
paulo@0 | 15 |
paulo@0 | 16 The register names do not match the names in the official GBA |
paulo@0 | 17 documentation. I choose the names that seem most logical to me. |
paulo@0 | 18 In addition, I do slick macro tricks with the VRAM addresses for |
paulo@0 | 19 maps and the like and with registers that control timers, DMA, |
paulo@0 | 20 and backgrounds. The gba.h that comes with wintermute's libgba |
paulo@0 | 21 incorporates some but not all of these tricks. In addition, |
paulo@0 | 22 the names in gba.h for the sound registers aren't descriptive |
paulo@0 | 23 at all. |
paulo@0 | 24 |
paulo@0 | 25 */ |
paulo@0 | 26 |
paulo@0 | 27 #ifndef PIN8GBA_SOUND_H |
paulo@0 | 28 #ifdef __cplusplus |
paulo@0 | 29 extern "C" { |
paulo@0 | 30 #endif |
paulo@0 | 31 #define PIN8GBA_SOUND_H |
paulo@0 | 32 |
paulo@0 | 33 |
paulo@0 | 34 #define DMGSNDCTRL (*(volatile u16 *)0x04000080) |
paulo@0 | 35 #define DMGSNDCTRL_LVOL(x) (x) |
paulo@0 | 36 #define DMGSNDCTRL_RVOL(x) ((x) << 4) |
paulo@0 | 37 #define DMGSNDCTRL_LSQR1 0x0100 |
paulo@0 | 38 #define DMGSNDCTRL_LSQR2 0x0200 |
paulo@0 | 39 #define DMGSNDCTRL_LTRI 0x0400 |
paulo@0 | 40 #define DMGSNDCTRL_LNOISE 0x0800 |
paulo@0 | 41 #define DMGSNDCTRL_RSQR1 0x1000 |
paulo@0 | 42 #define DMGSNDCTRL_RSQR2 0x2000 |
paulo@0 | 43 #define DMGSNDCTRL_RTRI 0x4000 |
paulo@0 | 44 #define DMGSNDCTRL_RNOISE 0x8000 |
paulo@0 | 45 |
paulo@0 | 46 #define DSOUNDCTRL (*(volatile u16 *)0x04000082) |
paulo@0 | 47 #define DSOUNDCTRL_DMG25 0x0000 |
paulo@0 | 48 #define DSOUNDCTRL_DMG50 0x0001 |
paulo@0 | 49 #define DSOUNDCTRL_DMG100 0x0002 |
paulo@0 | 50 #define DSOUNDCTRL_A50 0x0000 |
paulo@0 | 51 #define DSOUNDCTRL_A100 0x0004 |
paulo@0 | 52 #define DSOUNDCTRL_B50 0x0000 |
paulo@0 | 53 #define DSOUNDCTRL_B100 0x0008 |
paulo@0 | 54 #define DSOUNDCTRL_AR 0x0100 |
paulo@0 | 55 #define DSOUNDCTRL_AL 0x0200 |
paulo@0 | 56 #define DSOUNDCTRL_ATIMER(x) ((x) << 10) |
paulo@0 | 57 #define DSOUNDCTRL_ARESET 0x0400 |
paulo@0 | 58 #define DSOUNDCTRL_BR 0x1000 |
paulo@0 | 59 #define DSOUNDCTRL_BL 0x2000 |
paulo@0 | 60 #define DSOUNDCTRL_BTIMER(x) ((x) << 14) |
paulo@0 | 61 #define DSOUNDCTRL_BRESET 0x8000 |
paulo@0 | 62 |
paulo@0 | 63 #define SNDSTAT (*(volatile u16*)0x04000084) |
paulo@0 | 64 #define SNDSTAT_SQR1 0x0001 |
paulo@0 | 65 #define SNDSTAT_SQR2 0x0002 |
paulo@0 | 66 #define SNDSTAT_TRI 0x0004 |
paulo@0 | 67 #define SNDSTAT_NOISE 0x0008 |
paulo@0 | 68 #define SNDSTAT_ENABLE 0x0080 |
paulo@0 | 69 |
paulo@0 | 70 #define SNDBIAS (*(volatile u16 *)0x04000088) |
paulo@0 | 71 #define SETSNDRES(x) SNDBIAS = (SNDBIAS & 0x3fff) | (x << 14) |
paulo@0 | 72 |
paulo@0 | 73 #define DSOUND_FIFOA (*(volatile u32 *)0x040000a0) |
paulo@0 | 74 #define DSOUND_FIFOB (*(volatile u32 *)0x040000a4) |
paulo@0 | 75 |
paulo@0 | 76 |
paulo@0 | 77 #define SQR1SWEEP (*(volatile u16 *)0x04000060) |
paulo@0 | 78 #define SQR1SWEEP_OFF 0x0008 |
paulo@0 | 79 |
paulo@0 | 80 #define SQR1CTRL (*(volatile u16 *)0x04000062) |
paulo@0 | 81 #define SQR2CTRL (*(volatile u16 *)0x04000068) |
paulo@0 | 82 #define NOISECTRL (*(volatile u16 *)0x04000078) |
paulo@0 | 83 #define SQR_DUTY(n) ((n) << 6) |
paulo@0 | 84 #define SQR_VOL(n) ((n) << 12) |
paulo@0 | 85 |
paulo@0 | 86 #define SQR1FREQ (*(volatile u16 *)0x04000064) |
paulo@0 | 87 #define SQR2FREQ (*(volatile u16 *)0x0400006c) |
paulo@0 | 88 #define TRIFREQ (*(volatile u16 *)0x04000074) |
paulo@0 | 89 #define FREQ_HOLD 0x0000 |
paulo@0 | 90 #define FREQ_TIMED 0x4000 |
paulo@0 | 91 #define FREQ_RESET 0x8000 |
paulo@0 | 92 |
paulo@0 | 93 #define NOISEFREQ (*(volatile u16 *)0x0400007c) |
paulo@0 | 94 #define NOISEFREQ_127 0x0008 |
paulo@0 | 95 #define NOISEFREQ_OCT(x) ((x) << 4) |
paulo@0 | 96 |
paulo@0 | 97 #define TRICTRL (*(volatile u16 *)0x04000070) |
paulo@0 | 98 #define TRICTRL_2X32 0x0000 |
paulo@0 | 99 #define TRICTRL_1X64 0x0020 |
paulo@0 | 100 #define TRICTRL_BANK(x) ((x) << 6) |
paulo@0 | 101 #define TRICTRL_ENABLE 0x0080 |
paulo@0 | 102 |
paulo@0 | 103 #define TRILENVOL (*(volatile u16 *)0x04000072) |
paulo@0 | 104 #define TRILENVOL_LEN(x) (256 - (x)) |
paulo@0 | 105 #define TRILENVOL_MUTE 0x0000 |
paulo@0 | 106 #define TRILENVOL_25 0x6000 |
paulo@0 | 107 #define TRILENVOL_50 0x4000 |
paulo@0 | 108 #define TRILENVOL_75 0x8000 |
paulo@0 | 109 #define TRILENVOL_100 0x2000 |
paulo@0 | 110 |
paulo@0 | 111 #define TRIWAVERAM ((volatile u32 *)0x04000090) |
paulo@0 | 112 |
paulo@0 | 113 |
paulo@0 | 114 #ifdef __cplusplus |
paulo@0 | 115 } |
paulo@0 | 116 #endif |
paulo@0 | 117 #endif |