Pseudo-3D road demo

Announce (tech) demos or games releases

Moderator: Mask of Destiny

M-374 LX
Very interested
Posts: 61
Joined: Mon Aug 11, 2008 10:15 pm
Contact:

Pseudo-3D road demo

Post by M-374 LX » Wed Mar 26, 2014 10:15 pm

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
Last edited by M-374 LX on Tue Apr 01, 2014 9:26 pm, edited 2 times in total.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Wed Mar 26, 2014 11:53 pm

I like it!

KanedaFr
Administrateur
Posts: 1139
Joined: Tue Aug 29, 2006 10:56 am
Contact:

Post by KanedaFr » Thu Mar 27, 2014 12:10 am

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 !

M-374 LX
Very interested
Posts: 61
Joined: Mon Aug 11, 2008 10:15 pm
Contact:

Post by M-374 LX » Thu Mar 27, 2014 12:21 am

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.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Thu Mar 27, 2014 12:30 am

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!

TmEE co.(TM)
Very interested
Posts: 2440
Joined: Tue Dec 05, 2006 1:37 pm
Location: Estonia, Rapla City
Contact:

Post by TmEE co.(TM) » Thu Mar 27, 2014 5:06 am

Naiss !
Mida sa loed ? Nagunii aru ei saa ;)
http://www.tmeeco.eu
Files of all broken links and images of mine are found here : http://www.tmeeco.eu/FileDen

M-374 LX
Very interested
Posts: 61
Joined: Mon Aug 11, 2008 10:15 pm
Contact:

Post by M-374 LX » Thu Mar 27, 2014 1:00 pm

djcouchycouch wrote:look up tables!
The variety of values to be multiplied is large. Lookup tables do not seem to be a viable idea.

djcouchycouch
Very interested
Posts: 710
Joined: Sat Feb 18, 2012 2:44 am

Post by djcouchycouch » Thu Mar 27, 2014 2:33 pm

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.

M-374 LX
Very interested
Posts: 61
Joined: Mon Aug 11, 2008 10:15 pm
Contact:

Post by M-374 LX » Sat Mar 29, 2014 12:31 am

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?

gasega68k
Very interested
Posts: 141
Joined: Thu Aug 22, 2013 3:47 am
Location: Venezuela - Caracas
Contact:

Post by gasega68k » Sat Mar 29, 2014 2:00 am

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

M-374 LX
Very interested
Posts: 61
Joined: Mon Aug 11, 2008 10:15 pm
Contact:

Post by M-374 LX » Sat Mar 29, 2014 2:06 am

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

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

Post by Stef » Sat Mar 29, 2014 9:41 am

I don't think read is the problem, can we see how you are writing D0 and D1 to the VDP ?

M-374 LX
Very interested
Posts: 61
Joined: Mon Aug 11, 2008 10:15 pm
Contact:

Post by M-374 LX » Sun Mar 30, 2014 1:43 am

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.

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

Post by Stef » Sun Mar 30, 2014 9:46 am

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.

Eke
Very interested
Posts: 884
Joined: Wed Feb 28, 2007 2:57 pm
Contact:

Post by Eke » Sun Mar 30, 2014 2:13 pm

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

Post Reply