diff src/pin8gba_sound.h @ 0:c84446dfb3f5

initial add
author paulo@localhost
date Fri, 13 Mar 2009 00:39:12 -0700
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/pin8gba_sound.h	Fri Mar 13 00:39:12 2009 -0700
     1.3 @@ -0,0 +1,117 @@
     1.4 +/*
     1.5 + * pin8gba_sound.h
     1.6 + * Header file for GBA sound registers
     1.7 + */
     1.8 +
     1.9 +
    1.10 +/* Copyright 2001-2006 Damian Yerrick
    1.11 +
    1.12 +(insert zlib license here)
    1.13 +
    1.14 +*/
    1.15 +
    1.16 +
    1.17 +/* Why the funny register names?
    1.18 +
    1.19 +The register names do not match the names in the official GBA
    1.20 +documentation.  I choose the names that seem most logical to me.
    1.21 +In addition, I do slick macro tricks with the VRAM addresses for
    1.22 +maps and the like and with registers that control timers, DMA,
    1.23 +and backgrounds.  The gba.h that comes with wintermute's libgba
    1.24 +incorporates some but not all of these tricks.  In addition,
    1.25 +the names in gba.h for the sound registers aren't descriptive
    1.26 +at all.
    1.27 +
    1.28 +*/
    1.29 +
    1.30 +#ifndef PIN8GBA_SOUND_H
    1.31 +#ifdef __cplusplus
    1.32 +extern "C" {
    1.33 +#endif
    1.34 +#define PIN8GBA_SOUND_H
    1.35 +
    1.36 +
    1.37 +#define DMGSNDCTRL         (*(volatile u16 *)0x04000080)
    1.38 +#define DMGSNDCTRL_LVOL(x) (x)
    1.39 +#define DMGSNDCTRL_RVOL(x) ((x) << 4)
    1.40 +#define DMGSNDCTRL_LSQR1   0x0100
    1.41 +#define DMGSNDCTRL_LSQR2   0x0200
    1.42 +#define DMGSNDCTRL_LTRI    0x0400
    1.43 +#define DMGSNDCTRL_LNOISE  0x0800
    1.44 +#define DMGSNDCTRL_RSQR1   0x1000
    1.45 +#define DMGSNDCTRL_RSQR2   0x2000
    1.46 +#define DMGSNDCTRL_RTRI    0x4000
    1.47 +#define DMGSNDCTRL_RNOISE  0x8000
    1.48 +
    1.49 +#define DSOUNDCTRL           (*(volatile u16 *)0x04000082)
    1.50 +#define DSOUNDCTRL_DMG25     0x0000
    1.51 +#define DSOUNDCTRL_DMG50     0x0001
    1.52 +#define DSOUNDCTRL_DMG100    0x0002
    1.53 +#define DSOUNDCTRL_A50       0x0000
    1.54 +#define DSOUNDCTRL_A100      0x0004
    1.55 +#define DSOUNDCTRL_B50       0x0000
    1.56 +#define DSOUNDCTRL_B100      0x0008
    1.57 +#define DSOUNDCTRL_AR        0x0100
    1.58 +#define DSOUNDCTRL_AL        0x0200
    1.59 +#define DSOUNDCTRL_ATIMER(x) ((x) << 10)
    1.60 +#define DSOUNDCTRL_ARESET    0x0400
    1.61 +#define DSOUNDCTRL_BR        0x1000
    1.62 +#define DSOUNDCTRL_BL        0x2000
    1.63 +#define DSOUNDCTRL_BTIMER(x) ((x) << 14)
    1.64 +#define DSOUNDCTRL_BRESET    0x8000
    1.65 +
    1.66 +#define SNDSTAT        (*(volatile u16*)0x04000084)
    1.67 +#define SNDSTAT_SQR1   0x0001
    1.68 +#define SNDSTAT_SQR2   0x0002
    1.69 +#define SNDSTAT_TRI    0x0004
    1.70 +#define SNDSTAT_NOISE  0x0008
    1.71 +#define SNDSTAT_ENABLE 0x0080
    1.72 +
    1.73 +#define SNDBIAS      (*(volatile u16 *)0x04000088)
    1.74 +#define SETSNDRES(x) SNDBIAS = (SNDBIAS & 0x3fff) | (x << 14)
    1.75 +
    1.76 +#define DSOUND_FIFOA (*(volatile u32 *)0x040000a0)
    1.77 +#define DSOUND_FIFOB (*(volatile u32 *)0x040000a4)
    1.78 +
    1.79 +
    1.80 +#define SQR1SWEEP   (*(volatile u16 *)0x04000060)
    1.81 +#define SQR1SWEEP_OFF 0x0008
    1.82 +
    1.83 +#define SQR1CTRL    (*(volatile u16 *)0x04000062)
    1.84 +#define SQR2CTRL    (*(volatile u16 *)0x04000068)
    1.85 +#define NOISECTRL   (*(volatile u16 *)0x04000078)
    1.86 +#define SQR_DUTY(n) ((n) << 6)
    1.87 +#define SQR_VOL(n)  ((n) << 12)
    1.88 +
    1.89 +#define SQR1FREQ      (*(volatile u16 *)0x04000064)
    1.90 +#define SQR2FREQ      (*(volatile u16 *)0x0400006c)
    1.91 +#define TRIFREQ       (*(volatile u16 *)0x04000074)
    1.92 +#define FREQ_HOLD  0x0000
    1.93 +#define FREQ_TIMED 0x4000
    1.94 +#define FREQ_RESET 0x8000
    1.95 +
    1.96 +#define NOISEFREQ       (*(volatile u16 *)0x0400007c)
    1.97 +#define NOISEFREQ_127   0x0008
    1.98 +#define NOISEFREQ_OCT(x) ((x) << 4)
    1.99 +
   1.100 +#define TRICTRL         (*(volatile u16 *)0x04000070)
   1.101 +#define TRICTRL_2X32    0x0000
   1.102 +#define TRICTRL_1X64    0x0020
   1.103 +#define TRICTRL_BANK(x) ((x) << 6)
   1.104 +#define TRICTRL_ENABLE  0x0080
   1.105 +
   1.106 +#define TRILENVOL        (*(volatile u16 *)0x04000072)
   1.107 +#define TRILENVOL_LEN(x) (256 - (x))
   1.108 +#define TRILENVOL_MUTE   0x0000
   1.109 +#define TRILENVOL_25     0x6000
   1.110 +#define TRILENVOL_50     0x4000
   1.111 +#define TRILENVOL_75     0x8000
   1.112 +#define TRILENVOL_100    0x2000
   1.113 +
   1.114 +#define TRIWAVERAM ((volatile u32 *)0x04000090)
   1.115 +
   1.116 +
   1.117 +#ifdef __cplusplus
   1.118 +}
   1.119 +#endif
   1.120 +#endif