This page is a mirror of Tepples' nesdev forum mirror (URL TBD).
Last updated on Oct-18-2019 Download

Flowing palette demo

Flowing palette demo
by on (#63014)
After days of non-stop work on this, I think it's ready for some exposure (no source yet, as it's still not cleaned up as much as I'd like). NTSC only:

flowing_palette.zip

It works beautifully on my NTSC front-loader NES. I'm not sure it'll work on emulators; if someone has a PowerPak and can verify that an emulator matches what you see on your NES, please post which emulator you used.

All graphics are generated by manually setting $2006 and $2007. After initialization, all code is cycle-timed, as this is the only way to get a stable image with this technique. I had been working so many days non-stop on this that I wanted to go ahead and release it, before I got the new PPU timing technique working that will eliminate the need for cycle timing everything, since that will require a big rewrite.

by on (#63015)
MAN THIS IS AMAZING !!

by on (#63020)
Really incredible, blargg, thanks for sharing. I haven't checked on real hardware yet, but it looks great in Nestopia (OSX).

by on (#63022)
I will test it now on my PowerPak and use FCEU (0.98.12-3 from the debian testing repos).

by on (#63023)
Could only test it on nestopia. Interesting effect. Hope I can see it on the real thing someday. good work.

by on (#63024)
Bad news. Looks like interference(let me dig some batteries up and take a picture). Is this what it is suppose to look like?

Image

by on (#63027)
Sorry about excellent photography and my CRT(why the black bar is there). If the screenshot of FCEU looks a little off it is because I could not be bothered finding out how to take screenshots(do not bother with emulators any more).

Image

I will take my NES to the lounge TV (LCD) for a much better picture.

by on (#63029)
Took another picture and here it is.

Image

http://www.megaupload.com/?d=4Y46H370[/img]

by on (#63032)
Argh, I found a minor bug that caused the scrolling to sometimes stop when changing directions. Fixed now. Apparently I did need those three CLCs :)

Screenshots don't really do any justice to this, as it's so dynamic. Apparently some emulators don't either. It also won't work on non-NTSC NES, so it's not worth trying. If someone wants to do a video capture from an NTSC NES and put on YouTube, that would be great. Until someone has verified that any emulators reproduce how it looks on a NES, it's best to assume thatthey don't emulate it correctly (if all you have is an emulator, you can't really tell whether it's emulating correctly).

danntor, are you using an NTSC NES?

by on (#63033)
Would have been nice if you said NTSC only. Still very good when I could see it actually work.

by on (#63034)
Looks great on Nestopia and Nintendulator.

by on (#63037)
danntor wrote:
Bad news. Looks like interference(let me dig some batteries up and take a picture). Is this what it is suppose to look like?

Image

FCEU doesn't emulate properly the behavior blargg is using here (the PPU rendering the color pointed by PPUADDR when rendering is turned off).

Interesting demo. Must have been pretty tough to code... Is it supposed to flicker horizontally before the vertical distortion starts? Maybe you did that so that the colors would blend better? I haven't seen it on the NES yet, but on my PC this looks a bit strange.

by on (#63038)
Damn, this looks like something off the Amiga (raster-effect-like stuff).

by on (#63041)
Cool! I was gonna say, the previous version you posted of this was the coolest NES palette demo ever (before it disappeared), but it's even better now.

by on (#63044)
blargg wrote:
If someone wants to do a video capture from an NTSC NES and put on YouTube, that would be great.

Done.

by on (#63045)
That is truly awesome Blargg!

What's up with the annoying sound? Isn't there enough time during vblank to drive a music engine?

by on (#63046)
I think it's supposed to sound like a NES game rendering ocean waves or something.

by on (#63047)
Anders_A wrote:
What's up with the annoying sound? Isn't there enough time during vblank to drive a music engine?

I don't think so... his whole code is cycle timed and he doesn't even use any interrupts !!
So basically had to write all his code so that it will take a constant # of cycles no matter of what it's doing, so basically it means no branches, etc... or if you use any assembly equivalent of if/else statement it's a headache to make both flows join again at the same timing.

Since I don't know any music engine that execute in a constant # of cycles, no playing music just isn't possible here.

by on (#63049)
A music engine which always uses the same number of cycles would make a pretty cool addition to this though :). I'm guessing there is alot of free time during vblank, so it wouldn't even have to be very optimized aslong as it always use the same number of cycles.

by on (#63052)
koitsu wrote:
Damn, this looks like something off the Amiga (raster-effect-like stuff).


Time to start some demo compo thingy? ;) That what it reminded me when I saw it, demos.

by on (#63053)
But this is NTSC only. I thought the demoscene was something that happened only in Europe.

by on (#63055)
Dwedit wrote:
Looks great on Nestopia and Nintendulator.


Looks great on NESICIDE. Awesome demo!

Back to debugging my DMC...

This demo actually helped me find a bug in my PPU. Turns out I wasn't masking the palette RAM with $3F on reads, which caused some pretty ghastly colors to appear [invalid memory...off of the end of my allocated palette RAM] in the bottom third of the screen.

by on (#63057)
- Seems to work fine with RockNES, except by a minor horizontal flickering. The rest is fantastic. ^_^;;

by on (#63058)
Yeah, I wanted to put a music engine in. This thing is using almost all time, though, because it has to recalculate a 200+ entry table every frame. I'm spending very little time delaying, maybe 200 cycles or so each frame. The graphics engine in this is very flexible. There is plenty I haven't done with it. All the tables are in RAM, and it does a lot of lookup during rendering, so you can quickly change things without having to rewrite a lot of tables.

I do script some things, like the simplistic palette at the beginning dividing into twice as many colors, so you can see that effect from the start, then that palette having a wave transform it into a smoother one. I would have loved to have it start out all dorky simple looking, then some techno soundtrack start pumping while it went all crazy. If someone else wanted to work on a sequel with music and various events, I'm interested.

I actually can do branches in the code. I had to develop some techniques to make it bearable. Many branch sequences clamp a value to a range. For example, to subtract 12 from A if it's >= 12:
Code:
        cmp #12
        bcc next
next:   bcc skip
        sbc #12         ; carry already set
skip:

This takes 8 cycles either way, not that much more than the 5/6 it would when coded normally.

Now that I'm getting that new PPU synchronization technique to work, I could eliminate almost all the cycle-timing, and put a normal non-cycle-timed music engine in. One of the cool timing-related things inside this is the horizontal scrolling engine. This supports fine horizontal scrolling on a frame-by-frame basis, doing proper timing between frames to avoid drift. Of course with this new PPU synch technique it's trivial to implement, but I hadn't come up with the idea yet with this. :)

tepples, thanks for posting a video. I was hoping you'd do so, as I know you've got a video digitizer.
Re: Flowing palette demo
by on (#141024)
Made an RGB capture of a system with NESRGB running it. Interesting effect, but definitely not correct...
https://www.youtube.com/watch?v=K4S5N2B ... e=youtu.be
Once it's done processing you should be able to view it at 60fps.

EDIT: Didn't realize I'd bumped something so old, but it may be interesting nonetheless.
Re: Flowing palette demo
by on (#141086)
Nice. I, too, had been wondering whether NESRGB implemented those.
Re: Flowing palette demo
by on (#141093)
Would this impact any games? Has it been brought up to the NESRGB Dev?
Re: Flowing palette demo
by on (#141094)
Most games keep their palette updates inside the vertical blanking period in order to avoid the rainbow artifacts that this demo exploits. If I had to name a commercial game that it affects, that'd probably be Micro Machines. Does the NESRGB team own a copy of that game?
Re: Flowing palette demo
by on (#141096)
tepples wrote:
Most games keep their palette updates inside the vertical blanking period in order to avoid the rainbow artifacts that this demo exploits. If I had to name a commercial game that it affects, that'd probably be Micro Machines. Does the NESRGB team own a copy of that game?


That's what I was thinking. I always thought micro machines was one of those games that is a default test game to make sure everything is running properly. It would be good to see if someone has tested it.
Re: Flowing palette demo
by on (#141098)
I asked Tim about it. From his email,

Quote:
Yes, I know about that one. There's a feature of the PPU that the Nesdev Wiki calls The background palette hack. I decided not to implement it because it would take significant resources in the PLD. It didn't seem like a useful feature to me and I don't think a single game uses it.


That sounds fair to me - does Micro Machines specifically utilize this technique of modifying the background color? I can try Micro Machines if I know what I'm looking for.

EDIT: It seems I can not test Micro Machines as the Everdrive N8 I own will not run it.
Re: Flowing palette demo
by on (#141102)
Seems like that design choice should be put in a FAQ or clearly/bolded labelled as a non-implemented "feature" on the NESRGB site. The lack of disclosure of things like this up front from the get-go is unacceptable; transparency is good. That said, having a list of games and demos which get impacted by this decision is good too, that way Tim can say "this PPU feature isn't implemented, and to date that feature is only known to affect the following games/demos". It's a win-win for everyone.
Re: Flowing palette demo
by on (#141305)
mikejmoffitt wrote:
I asked Tim about it. From his email,

Quote:
Yes, I know about that one. There's a feature of the PPU that the Nesdev Wiki calls The background palette hack. I decided not to implement it because it would take significant resources in the PLD. It didn't seem like a useful feature to me and I don't think a single game uses it.


That sounds fair to me - does Micro Machines specifically utilize this technique of modifying the background color? I can try Micro Machines if I know what I'm looking for.

EDIT: It seems I can not test Micro Machines as the Everdrive N8 I own will not run it.


There was a big rom hack that didn't work on this RGB thingy. It had to with the way RGB device wasn't handling the mirroring of.. I think it was palette ram? It was a mirror of something in the PPU address, that the hacker left in the upper bits of the address, because it saved a couple of bytes and cycles (and worked on the real hardware). I forget what the hack was (popular megaman one?).
Re: Flowing palette demo
by on (#141332)
Haven't heard about palette mirroring being a problem, sure it's not just use of the color emphasis bits?
Re: Flowing palette demo
by on (#141339)
Probably that "Rockman Minus 4 Turbo Infinity Extreme Remix Ultra" one or whatever. It uses emphasis bits, but NESRGB is supposed to support those.
Re: Flowing palette demo
by on (#141409)
mikejmoffitt wrote:
Probably that "Rockman Minus 4 Turbo Infinity Extreme Remix Ultra" one or whatever. It uses emphasis bits, but NESRGB is supposed to support those.

Maybe, but a quick search turned up Castlevania II as having issues (bisquit's retranslation) - so that might be what I had remembered. Anyway, the problem was specifically PPU upper bits of the address to read/write, act as if they don't do anything (the upper 2 bits, maybe? Thus a mirroring effect, whatever you want to call it). But I think a newer revision of this RGBNES fixes that (ver 1.7 ???).
Re: Flowing palette demo
by on (#149799)
mikejmoffitt wrote:
I asked Tim about it. From his email,

Quote:
Yes, I know about that one. There's a feature of the PPU that the Nesdev Wiki calls The background palette hack. I decided not to implement it because it would take significant resources in the PLD. It didn't seem like a useful feature to me and I don't think a single game uses it.


That sounds fair to me - does Micro Machines specifically utilize this technique of modifying the background color? I can try Micro Machines if I know what I'm looking for.

EDIT: It seems I can not test Micro Machines as the Everdrive N8 I own will not run it.


Micro Machines runs fine in an Everdrive N8 if you change the mapper from 71 to 2. I would be really interested to see what a v1.7 NESRGB does with that game.