Possible to load image line by line?
Moderator: Stef
-
- Very interested
- Posts: 151
- Joined: Sun Apr 14, 2013 1:19 am
- Location: Auckland, New Zealand
- Contact:
Possible to load image line by line?
I'm wanting to load in an image that is taller than what I want to display but I only want to load every 20th line of the image or so, so I can 'scroll' between lines.
Basically I want to use a tall image of a road but loading it this way (using every 20th line or so) the road will only take up half of the screen. Then I can 'scroll' through the lines in the bitmap and create the appearance of an Outrun style 2.5D road but textured!
Is this possible? I understand that the VDP generally displays bitmaps per tile, not per line. If it's not possible I'll use palette swapping for the road's 'movement'.
Cheers!
Basically I want to use a tall image of a road but loading it this way (using every 20th line or so) the road will only take up half of the screen. Then I can 'scroll' through the lines in the bitmap and create the appearance of an Outrun style 2.5D road but textured!
Is this possible? I understand that the VDP generally displays bitmaps per tile, not per line. If it's not possible I'll use palette swapping for the road's 'movement'.
Cheers!
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Possible to load image line by line?
Hi,POLYGAMe wrote:I'm wanting to load in an image that is taller than what I want to display but I only want to load every 20th line of the image or so, so I can 'scroll' between lines.
Basically I want to use a tall image of a road but loading it this way (using every 20th line or so) the road will only take up half of the screen. Then I can 'scroll' through the lines in the bitmap and create the appearance of an Outrun style 2.5D road but textured!
Is this possible? I understand that the VDP generally displays bitmaps per tile, not per line. If it's not possible I'll use palette swapping for the road's 'movement'.
Cheers!
Many games uses simple palette reprogramming, another trick is to use a tall image as you said but simpler:
In H40 mode by default your plan size is set to 64x64 allowing an image up to 512x512 so if your road is 128 pixels tall (4*128=512) then yo can define 4 frames for your road where:
line 0-127 = 1st frame
line 128-255 = 2nd frame
line 256-383 = 3th frame
line 384-511 = 4th and last frame
So you just need to change the vertical scroll value at each frame for the plan displaying the road and render other part of the screen with the second plan.
Another method but more tricky is to use the Horizontal interrupt and modify the vertical scroll value at each scanline, so you can do that for instance :
Line 100: vscroll = 0
Line 101: vscroll = 8
Line 102: vscroll = 16
Line 103: vscroll = 24
Line 104: vscroll = 32
...
But your maximum vertical image is still limited to 512 pixels, still using the horizontal interrupt to change vertical scroll at each line can create very neat effect for road rendering (simulate relief for instance, apply texturing...)
-
- Very interested
- Posts: 151
- Joined: Sun Apr 14, 2013 1:19 am
- Location: Auckland, New Zealand
- Contact:
Re: Possible to load image line by line?
Thanks for the info. I'll have a go at it on the weekend
-
- Very interested
- Posts: 151
- Joined: Sun Apr 14, 2013 1:19 am
- Location: Auckland, New Zealand
- Contact:
Re: Possible to load image line by line?
Okay, I'm getting somewhere but it's really slow. What's the fastest way to change images? I have a 512x512 image with four roads on it, one for each frame (each road is 128x512). What's the best way to display a road, clear it and then display the next one and so on so that it appears the road is moving? Not sure which functions I should be using for drawing in this case...
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Possible to load image line by line?
I guess you mean your road is 512x128 (WxH) and not the opposite ?
What you need to do is to load the whole 512x512 image at the beginning in whatever plan (default scroll plan size is set to 64x64 tiles so it's ok) then just use the Vertical scroll value to change the displayed image as i told you here :
What you need to do is to load the whole 512x512 image at the beginning in whatever plan (default scroll plan size is set to 64x64 tiles so it's ok) then just use the Vertical scroll value to change the displayed image as i told you here :
For that you can use this method:So you just need to change the vertical scroll value at each frame for the plan displaying the road and render other part of the screen with the second plan.
Code: Select all
VDP_setVerticalScroll(VDPPlan plan, s16 value);
-
- Very interested
- Posts: 151
- Joined: Sun Apr 14, 2013 1:19 am
- Location: Auckland, New Zealand
- Contact:
Re: Possible to load image line by line?
Hi Stef,
Yeah I worked that bit out but now I'm having other issues. lol. This is much harder (and more fun) than using Unity!!!
Yeah I worked that bit out but now I'm having other issues. lol. This is much harder (and more fun) than using Unity!!!
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Possible to load image line by line?
Note for me: add Unity engine support to SGDK
-
- Very interested
- Posts: 151
- Joined: Sun Apr 14, 2013 1:19 am
- Location: Auckland, New Zealand
- Contact:
Re: Possible to load image line by line?
Hey Stef, I have been getting the required effect by using SetMapEX and it works great but would doing it this way be slower than just adjusting the image's position?
Re: Possible to load image line by line?
You made my day !Stef wrote:Note for me: add Unity engine support to SGDK
-
- Very interested
- Posts: 3131
- Joined: Thu Nov 30, 2006 9:46 pm
- Location: France - Sevres
- Contact:
Re: Possible to load image line by line?
Definitely slower than just changing the scroll position as here you reload the whole tilemap data (but already better then reloading all tiles as well).POLYGAMe wrote:Hey Stef, I have been getting the required effect by using SetMapEX and it works great but would doing it this way be slower than just adjusting the image's position?
-
- Very interested
- Posts: 151
- Joined: Sun Apr 14, 2013 1:19 am
- Location: Auckland, New Zealand
- Contact:
Re: Possible to load image line by line?
I thought that might be the case. Damn. I need the road on the front plane so I can do hills. But if I have to load the whole image I'll have to put it in the back. I might be able to work it out with scrolling tricks but I'll need to investigate what an interrupt is. Hehe. In other news, I've started using pointers. I did two yesterday all by myself. Yay me! Haha.