Demo. Fzero like game on NES.

Discuss technical or other issues relating to programming the Nintendo Entertainment System, Famicom, or compatible systems.

Moderator: Moderators

User avatar
dougeff
Posts: 2816
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Demo. Fzero like game on NES.

Post by dougeff » Wed Jan 02, 2019 2:59 pm

This is my "what if F-zero or Mario Kart were made in 1985" idea. About 1 year of planning and about 2 days of actual programming.

https://youtu.be/vn7xwTau7s0

I was only able to calculate half of the road per frame... and still have enough frame left to play music and move some sprites (later). It would probably look better with a much bigger racetrack.

Edit, changed title.
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
tokumaru
Posts: 11991
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Demo. Realtime 3d processing.

Post by tokumaru » Wed Jan 02, 2019 3:37 pm

Interesting! Reminds me of this: https://youtu.be/7Nw3OL4-tw4

But the resolution is way too low... Do you think you can improve it and still have it run smoothly?

User avatar
dougeff
Posts: 2816
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Demo. Fzero like game on NES.

Post by dougeff » Wed Jan 02, 2019 4:20 pm

I was going to do a second pass over the data and do a "smoothing", and that pass could put edges as well... but I don't think I have the processing time. Currently it takes a (worse case scenario) 200 scanlines to process 1/2 of the picture.

I would have to drop down to 15 fps to do much more.


Unrelated, I could make a nice scrolling text demo, or scrolling logo / title screen with this method.
nesdoug.com -- blog/tutorial on programming for the NES

tepples
Posts: 22278
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: Demo. Fzero like game on NES.

Post by tepples » Wed Jan 02, 2019 4:27 pm

What frame rate does F-FF run at? Could someone check before I get home?

User avatar
Bregalad
Posts: 8008
Joined: Fri Nov 12, 2004 2:49 pm
Location: Chexbres, VD, Switzerland

Re: Demo. Fzero like game on NES.

Post by Bregalad » Wed Jan 02, 2019 4:31 pm

I hate to be negative when criticising, especailly after all the effort you put into this project. However this really looks awful. Rendering is inapropriate for racers as it's way too slow. Simulate a pre-rendered road by distorting it is the standard way to do it. Look at Rad Racer, it actually looks quite good and convincing. I was expecting something like that when I clicked on the link. So yeah... that's what a Mario Kart or F-Zero would have looked like on the NES.

Sure Rad Racer uses the MMC1, which is a "special chip", but actually it doesn't use much of the chip, and it uses it mainly for extra memory, so if the game was single-level it could have fitted a NROM cart easily. For a NROM racer from 1985, look at F1-Race (the road is only distorted horizontally, not vertically, as it probably wasn't understood how to do this with the NES at this date).

lidnariq
Posts: 10241
Joined: Sun Apr 13, 2008 11:12 am
Location: Seattle

Re: Demo. Fzero like game on NES.

Post by lidnariq » Wed Jan 02, 2019 4:37 pm

Yeah, but we already have seen dozens of instances of using raster effects to fake 3d.

User avatar
tokumaru
Posts: 11991
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Demo. Fzero like game on NES.

Post by tokumaru » Wed Jan 02, 2019 4:39 pm

Bregalad wrote:Simulate a pre-rendered road by distorting it is the standard way to do it.
The standard way is also the boring way. I'd rather see something unique, even if it doesn't look great.

User avatar
nesrocks
Posts: 481
Joined: Thu Aug 13, 2015 4:40 pm
Location: Rio de Janeiro - Brazil
Contact:

Re: Demo. Fzero like game on NES.

Post by nesrocks » Wed Jan 02, 2019 5:27 pm

I thought it looked great. I mean, afaik dougeff isn't an artist, I'm talking about the programming of the thing. It looks like real mode 7, at low resolution, ok.

I think one improvement that may be simple to add is to add different tiles depending on depth (screen y coordinate, really). It can be used to simulate distance.
https://twitter.com/bitinkstudios <- Follow me on twitter! Thanks!

User avatar
pubby
Posts: 558
Joined: Thu Mar 31, 2016 11:15 am

Re: Demo. Fzero like game on NES.

Post by pubby » Wed Jan 02, 2019 5:41 pm

tepples wrote:What frame rate does F-FF run at?
30 FPS for 1 player, 20 for 2 players
I think one improvement that may be simple to add is to add different tiles depending on depth (screen y coordinate, really). It can be used to simulate distance.
Oh yeah and attributes + a few palettes are trivial for this effect too.

nocash
Posts: 1318
Joined: Fri Feb 24, 2012 12:09 pm
Contact:

Re: Demo. Fzero like game on NES.

Post by nocash » Wed Jan 02, 2019 5:56 pm

dougeff wrote:This is my "what if F-zero or Mario Kart were made in 1985" idea. About 1 year of planning and about 2 days of actual programming.
https://youtu.be/vn7xwTau7s0
That looks a bit blocky.
If you are already overloading the CPU with 16x16 "pixels" then I am wondering if you are using loads of multiplications or divisions per pixel?
Essentially, a scanline should be rendered by computing the x/y source steps, and then reading the source data with that steps (ie. using only step additions for the source coordinates, no multiplications or divisions within scanlines).
For the separate lines, I think you could re-use the same x/y steps, multiplied by a scaling factor for the distance. So there isn't too much complicated maths required, the main bottleneck would be reading source pixels, merging them to bitplanes, and writing to VRAM.
When using a huge ROM you could store the source data as uncompressed bitmap with 1 byte per pixel - of course that would have been expensive in 1985, and the required bank switching could also slowdown things, so you might find a better & cheaper way.

User avatar
dougeff
Posts: 2816
Joined: Fri May 08, 2015 7:17 pm
Location: DIGDUG
Contact:

Re: Demo. Fzero like game on NES.

Post by dougeff » Wed Jan 02, 2019 6:23 pm

16x16
8x8. It just doesn't use the whole screen. The final picture is 20x20 tiles. I tried 22, but it was too slow.
loads of multiplications or divisions per pixel
Pre calculated LUT of sine and cosine for every 3° at 10 different distances. Each pixel is added to a base x,y (2 16-bit adds), and then indexed on a map.
nesdoug.com -- blog/tutorial on programming for the NES

User avatar
tokumaru
Posts: 11991
Joined: Sat Feb 12, 2005 9:43 pm
Location: Rio de Janeiro - Brazil

Re: Demo. Fzero like game on NES.

Post by tokumaru » Wed Jan 02, 2019 7:01 pm

dougeff wrote:Pre calculated LUT of sine and cosine for every 3° at 10 different distances. Each pixel is added to a base x,y (2 16-bit adds), and then indexed on a map.
I have considered doing floor casting that way in my raycaster, but combined with wall texturing that would've been insanely slow. So I settled for blocky floors instead, because instead of doing calculations for every screen pixel, I only need calculations between block boundaries in the map.

If you don't need too much detail on the floor (based on your test map it doesn't look like you do), you might be able to get away with checking only grid boundaries too. That should result in a decent speed bump, probably enough to increase the resolution.

nocash
Posts: 1318
Joined: Fri Feb 24, 2012 12:09 pm
Contact:

Re: Demo. Fzero like game on NES.

Post by nocash » Wed Jan 02, 2019 7:33 pm

No, I meant 16x16 tiles, aka 16x16 low-resolution pixels. Oh, or is it even 20x20? Excluding the sky, that would be 20x10, or 200 pixels per frame.
So you would need 400 additions, and indexing for 200 pixels and a few dozen multiplications per frame.
I think you could reach maybe around 100 frames per second at that resolution.
But the framerate would drop rapidly when increasing the resolution, unless you drop the per pixel texturing.
With filled shapes you might get similar quality as what you have now, but at much higher resolution.

Not sure about NES, but home computers did have some 3D games, like Elite, Mercenary, Driller. And I think there's also Doom for the Spectrum.
The advantage on NES is that it's about twice as fast as C64, so I am wondering if it could render some impressive graphics at not so bad framerate.

User avatar
FrankenGraphics
Formerly WheelInventor
Posts: 2033
Joined: Thu Apr 14, 2016 2:55 am
Location: Gothenburg, Sweden
Contact:

Re: Demo. Fzero like game on NES.

Post by FrankenGraphics » Thu Jan 03, 2019 2:42 am

I think this is pretty cool! Honestly, the resolution is enough for it to be playable. If you somehow can get it up or smooth the edges with diagonal boundary tiles to make it seem like it has better resolution (the smoothing doesn't need to be meticulous either as long as it doesn't lie about the position of the boundary too much), that's a bonus. But you could probably work with this.

The obvious advantage of this method is that you can create tracks very freely, including sharp turns and intersecting paths. It offers something you can't do for the game design with raster effects alone.

It could also work for maze crawlers and tank games (with seethrough walls). I mean you could simply avoid the natural ideal and go for something more TRON-y, or assume the player has a birds eye viewpoint above hedges/walls.
http://www.frankengraphics.com - personal NES blog

User avatar
koitsu
Posts: 4218
Joined: Sun Sep 19, 2004 9:28 pm
Location: A world gone mad

Re: Demo. Fzero like game on NES.

Post by koitsu » Thu Jan 03, 2019 3:15 am

Surprised not a single person here has mentioned RoadBlasters from Tengen/Beam Software. Like Rad Racer, it also uses MMC1 (in this case, 128KB PRG + 128KB CHR). I'm going off of memory so there's a large chance I'm remembering things wrong, but I think it used precisely-timed PPU writes and reads and/or certain bits in in HBlank, combined with palette cycling and a lot of CHR swapping to give the impression of road movement, plus providing a horizon. There's similarities in the implementation model to Rad Racer and Rad Racer 2, but the result is a lot more impressive given all the other stuff going on. Consider that it's an arcade port as well (and yes, the surrounding environment does have that palette cycling effect even on the arcade).

If you haven't played this game (or at least checked it our in general), I recommend doing so.

Post Reply