I want to create an illusion of 2 layers of background using only 1 plane. Horizontal scrolling per single line is used.
Here's my C code:
Code: Select all
volatile u16 *pw;
volatile u32 *pl;
pw = (u16 *) GFX_DATA_PORT;
pl = (u32 *) GFX_CTRL_PORT;
s16 i;
bgval[0]++;
bgval[1]+=2;
if(bgval[0]>=512) bgval[0]-=512;
if(bgval[1]>=512) bgval[1]-=512;
// when I cut the code here, no slowdown occurs
for(i=0; i<224; i+=2) {
*pl = ((0x4000 + ((HSCRL + ((i & 0xFF) * 4)+2) & 0x3FFF)) << 16) + (((HSCRL + ((i & 0xFF) * 4)+2) >> 14) | 0x00); *pw = bgval[0];
}
for(i=1; i<224; i+=2) {
*pl = ((0x4000 + ((HSCRL + ((i & 0xFF) * 4)+2) & 0x3FFF)) << 16) + (((HSCRL + ((i & 0xFF) * 4)+2) >> 14) | 0x00); *pw = bgval[1];
}
The question is: what is the fastest way to change a scroll value in C / at all? I've tried to get the needed info from Charles MacDonald's documentation, but failed miserably, I'm sure I have not enough technical knowledge yet. =P Thanks in advance.