> > > 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?
That wasn't declaration, it was assignment. He cast 0x40000006 as a volatile
u16* value, then assigned it to a non-volatile u16* variable. Since
ScanlineCounter wasn't declared volatile u16* (or the equivalent vu16*), the
compiler was free to cache *ScanlineCounter in a register for the duration
of the while loop.
(Of course, that doesn't explain his observations. If the compiler had
optimized away the memory access, then you'd expect an infinite loop when
the V counter was less than 160, rather than no delay at all.)
- Mike