My scrolling routine is bad
Posted: Tue Aug 03, 2010 7:40 pm
I've got another problem I'm trying to solve without good results.
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:
As you can see, I want to change 224 values of scrolling at once. That's a lot, and in later progress I'll probably need whole 512. Using many subroutines is too slow, so I try to minimalize the amount of them. Basically, this is modified code of VDP_setHorizontalScroll script from Stef's devkit. While this works fine for a menu, where practically no other code is executed, it slows the game down.
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.
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.