"John Q. Pretentious" <johnisaheadcase@y...> wrote:
> > > ScanlineCounter = (volatile u16*)0x4000006; //this is the
> > > scan line counter
> >
> > you should declare ScanlineCounter a vu16* (volatile).
>
> Er. Maybe I'm misunderstanding. Can't you get away with it during
> declaration like he did there? Like, I thought a typedef was
> really a special form of a macro?
C typedefs aren't true macros, but they act the same way.
(volatile u16 *) does work on hardware, even at GCC optimization
level 3. Here's an excerpt from the pin8gba.h that my demos use:
typedef unsigned char u8;
typedef unsigned short u16;
typedef unsigned int u32;
/* ... */
#define LCD_Y (*(volatile u16 *)0x04000006)
/* ... */
/* an array of four 16-bit registers */
#define BGCTRL ((volatile u16 *)0x04000008)
It goes on to set up other cute tricks such as defining the
background scroll registers and DMA registers as arrays of
structs, letting me write code that looks like this:
BGSCROLL[0].x = x;
BGSCROLL[0].y = y;
--
Damian Yerrick