#11487 - Taipan - Wed Oct 08, 2003 2:16 pm
First of all sorry for my bad english.
Can backgrounds scroll only 1 pixel at once or is it possible to scroll with more precision like 0.5 pixel and how do you do it
Ik know it's possible to scroll 5 pixel at once :-)
Taipan
#11488 - poslundc - Wed Oct 08, 2003 2:25 pm
If you want to scroll less than one pixel per frame, you have two options:
1. Use a Rotation Background. Their scroll registers include a fractional portion (the bottom eight bits of the number). Read one of the tutorials online about fixed-point math if you have difficulty understanding how this works.
2. Keep track of your background's x and y coordinates in a separate variable, and used fixed-point math the same way you did with #1. That is, let the bottom 8 bits of the coordinate specify the fractional part of the number. Then when it comes time to update the registers, just shift right by 8 bits and you'll have the correct decimal part.
Dan.
#12067 - Taipan - Tue Oct 28, 2003 7:42 pm
Can anyone give me a code example for text backgrounds.
I looked at te pern project but coudn't find a usable example
#12069 - Lord Graga - Tue Oct 28, 2003 9:57 pm
Sure:
Code: |
SET_MODE(MODE_0|BG0_ENABLE);
REG_BG0CNT = COLOR_256|BG_SCREENMEM(24)|BG_CHARMEM(0);
for(i=0;i<32*32;i++) ScreenMem24[i] = map[i];
for(i=0;i<tile_WIDTH*tile_HEIGHT/2;i++) CharMem0[i] = tileData[i];
for(i=0;i<256;i++) BGPaletteMem[i] = tilePalette[i];
while(1)
{
counter++;
if(counter==2)
{
counter = 0;
x++;
REG_BG0HOFS = x;
}
WaitForVSync();
}
|
#12073 - Taipan - Tue Oct 28, 2003 11:31 pm
thx but that wasn't what I ment.
I would like to have a example that shows how to scroll less then one pixel
#12076 - sajiimori - Wed Oct 29, 2003 12:25 am
The example makes the background scroll less than one pixel per frame by using a counter variable. What else do you want?
In reality, scrolling happens at the pixel level because the screen is divided into physical pixels. You can simulate sub-pixel scrolling however you like, and one method is to use counters. If you don't like that method, you can change the example so that x is incremented every frame, and store some fraction of x in the scroll register, such as x/2.
#12078 - tepples - Wed Oct 29, 2003 2:45 am
I know how to scroll by subpixels: put the same map in two layers and blend slowly from one layer to the same layer scrolled by one pixel.
But most GBA games don't do this; they just keep track of the scroll position down to sub-pixel precision, using fixed-point arithmetic, and then round it to the nearest pixel every frame.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#12091 - sajiimori - Wed Oct 29, 2003 7:39 am
I'd say the blending method is also only simulating sub-pixel scrolling, but at that point the debate would become rather philisophical. ;-)
#12104 - Taipan - Wed Oct 29, 2003 6:35 pm
And what about the post of poslundc
He tells something diverend. Can't the gba hardware do the pointmath stuff for me
#12105 - tepples - Wed Oct 29, 2003 6:39 pm
Taipan wrote: |
And what about the post of poslundc
He tells something diverend. |
Is "diverend" supposed to mean "different"? I don't see any difference between the second method I mentioned and the second method that poslundc mentioned.
Quote: |
Can't the gba hardware do the pointmath stuff for me |
Fixed-point arithmetic is merely an application of the integer unit of any 32-bit processor such as the GBA's ARM7TDMI processor. Google will help you.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#12111 - yaustar - Wed Oct 29, 2003 11:48 pm
float values have to be emulated in software which is extremely slow. Fixed point math is a lot easier for the GBA to handle. (At least that is what I was told when I asked the same question :P)
_________________
[Blog] [Portfolio]