Page 1 of 2

Pseudo-3D road demo

Posted: Wed Mar 26, 2014 10:15 pm
by M-374 LX
Image

This is a tech demo for Sega Genesis that shows a pseudo-3D road featuring curves. This effect has been seen in games like OutRun, Super Hang-On, and Super Monaco GP.
Most of the information required to create this demo was obtained from Lou's Pseudo-3D Page. So, I would like to thank Louis Gorenfeld, the author of the page.

I have plans to turn this demo into a complete game. Thus, any help on improving and optimizing this demo will be appreciated.

Version 1.1 adds hills, which are not yet perfect.

Controls
D-pad left/right: move left/right*
A: brake
B: accelerate

*The left/right movement is absent in version 1.1 due to issues that appeared after adding hills.

Download
v1.1: Link
v1.0: Link

Posted: Wed Mar 26, 2014 11:53 pm
by djcouchycouch
I like it!

Posted: Thu Mar 27, 2014 12:10 am
by KanedaFr
Lou's Pseudo 3D Page is on my favorites list for so looooooooooooong ;)
Always wanted to try it on Genny !

It runs really fast !
Now, try to make hills then jumps !

Congrats !

Posted: Thu Mar 27, 2014 12:21 am
by M-374 LX
Thanks, guys.

Maybe hills can be created by changing the vertical scroll value during the horizontal interrupt, as done with the palette at present.

According to the page, this effect can be done by multiplying a value during drawing to a value in the Z map, but this causes a significant performance loss in the Genesis.

Posted: Thu Mar 27, 2014 12:30 am
by djcouchycouch
M-374 LX wrote:Thanks, guys.

Maybe hills can be created by changing the vertical scroll value during the horizontal interrupt, as done with the palette at present.

According to the page, this effect can be done by multiplying a value during drawing to a value in the Z map, but this causes a significant performance loss in the Genesis.
look up tables!

Posted: Thu Mar 27, 2014 5:06 am
by TmEE co.(TM)
Naiss !

Posted: Thu Mar 27, 2014 1:00 pm
by M-374 LX
djcouchycouch wrote:look up tables!
The variety of values to be multiplied is large. Lookup tables do not seem to be a viable idea.

Posted: Thu Mar 27, 2014 2:33 pm
by djcouchycouch
M-374 LX wrote:
djcouchycouch wrote:look up tables!
The variety of values to be multiplied is large. Lookup tables do not seem to be a viable idea.
Number fudging!

But seriously, it would be interesting to see how the Outrun port does it. Or how any of the other racing games does it.

Posted: Sat Mar 29, 2014 12:31 am
by M-374 LX
I am currently trying to add hills, but something seems to be wrong.

This is the C structure I am trying to use to store vertical scrolling and palette information for each scanline:

Code: Select all

struct
{
	ushort vscroll;
	ushort color;
} scanline_buffer[224];
And here, how I try to read it during the HBlank:

Code: Select all

	move.b	(0xC00008), %d0
	lsl.w	#2, %d0

	lea		scanline_buffer, %a0
	move.w	0(%a0,%d0.w),%d1
	move.w	2(%a0,%d0.w),%d0
The problem is that the vertical scrolling gets corrupted if I write color information to the struct, but not if I do not. I believe this problem is related to the struct alignment. Is this correct? If so, how can I fix it?

Posted: Sat Mar 29, 2014 2:00 am
by gasega68k
You can try this:

Code: Select all

   moveq   #0, %d0         ;clear d0
   move.b   (0xC00008), %d0 
   lsl.w   #2, %d0 

   lea      scanline_buffer, %a0 
   move.w   0(%a0,%d0.w),%d1 
   move.w   2(%a0,%d0.w),%d0
You could also use two "add.w %d0,%d0" instead of "lsl.w #2,%d0" because it is faster.
Good luck with this project. :)

Posted: Sat Mar 29, 2014 2:06 am
by M-374 LX
I have actually cleared D0 and D1 immediately before:

Code: Select all

	clr.l	%d0
	clr.l	%d1

   move.b   (0xC00008), %d0
   lsl.w   #2, %d0

   lea      scanline_buffer, %a0
   move.w   0(%a0,%d0.w),%d1
   move.w   2(%a0,%d0.w),%d0

Posted: Sat Mar 29, 2014 9:41 am
by Stef
I don't think read is the problem, can we see how you are writing D0 and D1 to the VDP ?

Posted: Sun Mar 30, 2014 1:43 am
by M-374 LX
I have finally found that the problem stops if I do not call the vdp_hscroll function, which copies scroll values for each line from a buffer via DMA. Perhaps it is a better idea to set the horizontal scrolling mode to full screen and change the scroll value also during the HBlank.

Posted: Sun Mar 30, 2014 9:46 am
by Stef
Normally the line H scroll is made for that. I think the problem is that you actually had some VDP access conflict: maybe the hscroll DMA method is interrupted by the HInt method and so your VDP accesses get corrupted.
Something you can do is to protect your HScroll method against HInt or just be sure they won't happen at same time.

Posted: Sun Mar 30, 2014 2:13 pm
by Eke
I was wondering why the road effect was not displayed on real hardware and Genesis Plus GX.

It turns out you accidentally set bit 2 in VDP register #0 which results in freezing the HV counter. This feature is not supported by most emulators but you might want to fix it since your code relies on HV counter :wink:

Also, it seems like the demo hangs on real hardware (controls do not respond): I suspect this is because DMA is left enabled in VDP register #1 even when not being used but I am not sure