Possible to load image line by line?

SGDK only sub forum

Moderator: Stef

Post Reply
POLYGAMe
Very interested
Posts: 151
Joined: Sun Apr 14, 2013 1:19 am
Location: Auckland, New Zealand
Contact:

Possible to load image line by line?

Post by POLYGAMe » Tue Jan 12, 2016 11:47 pm

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!

Stef
Very interested
Posts: 3034
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Possible to load image line by line?

Post by Stef » Wed Jan 13, 2016 9:22 am

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

POLYGAMe
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?

Post by POLYGAMe » Wed Jan 13, 2016 9:47 am

Thanks for the info. I'll have a go at it on the weekend :)

POLYGAMe
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?

Post by POLYGAMe » Sat Jan 23, 2016 12:39 am

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

Stef
Very interested
Posts: 3034
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Possible to load image line by line?

Post by Stef » Sat Jan 23, 2016 9:02 am

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

POLYGAMe
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?

Post by POLYGAMe » Sat Jan 23, 2016 9:36 am

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!!!

Stef
Very interested
Posts: 3034
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Possible to load image line by line?

Post by Stef » Sat Jan 23, 2016 2:25 pm

Note for me: add Unity engine support to SGDK :D

POLYGAMe
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?

Post by POLYGAMe » Sun Jan 24, 2016 12:16 am

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?

tryphon
Very interested
Posts: 316
Joined: Sat Aug 17, 2013 9:38 pm
Location: France

Re: Possible to load image line by line?

Post by tryphon » Sun Jan 24, 2016 12:33 am

Stef wrote:Note for me: add Unity engine support to SGDK :D
You made my day ! :D

Stef
Very interested
Posts: 3034
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Possible to load image line by line?

Post by Stef » Sun Jan 24, 2016 2:45 pm

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

POLYGAMe
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?

Post by POLYGAMe » Sun Jan 24, 2016 6:41 pm

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.

Post Reply