Page 1 of 1

Possible to load image line by line?

Posted: Tue Jan 12, 2016 11:47 pm
by POLYGAMe
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!

Re: Possible to load image line by line?

Posted: Wed Jan 13, 2016 9:22 am
by Stef
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!
Hi,

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...)

Re: Possible to load image line by line?

Posted: Wed Jan 13, 2016 9:47 am
by POLYGAMe
Thanks for the info. I'll have a go at it on the weekend :)

Re: Possible to load image line by line?

Posted: Sat Jan 23, 2016 12:39 am
by POLYGAMe
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...

Re: Possible to load image line by line?

Posted: Sat Jan 23, 2016 9:02 am
by Stef
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 :
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.
For that you can use this method:

Code: Select all

VDP_setVerticalScroll(VDPPlan plan, s16 value);

Re: Possible to load image line by line?

Posted: Sat Jan 23, 2016 9:36 am
by POLYGAMe
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!!!

Re: Possible to load image line by line?

Posted: Sat Jan 23, 2016 2:25 pm
by Stef
Note for me: add Unity engine support to SGDK :D

Re: Possible to load image line by line?

Posted: Sun Jan 24, 2016 12:16 am
by POLYGAMe
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?

Posted: Sun Jan 24, 2016 12:33 am
by tryphon
Stef wrote:Note for me: add Unity engine support to SGDK :D
You made my day ! :D

Re: Possible to load image line by line?

Posted: Sun Jan 24, 2016 2:45 pm
by Stef
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?
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).

Re: Possible to load image line by line?

Posted: Sun Jan 24, 2016 6:41 pm
by POLYGAMe
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.