Backbuffer Color

General area for talk about ZSNES. The best place to ask for related questions as well as troubleshooting.

Moderator: ZSNES Mods

PhoenixX_2
Rookie
Posts: 17
Joined: Tue Jul 11, 2006 4:56 pm

Backbuffer Color

Post by PhoenixX_2 »

Is there any way to change the backbuffer clear color? That is to say, is there any way to change the color of the screen when some layers are disabled? Right now, it defaults to black. But what if we wanted purple or something, as a way to grab graphics from a game, already properly rendered with the proper palette and so forth.

Any help would be appreciated.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

This should be possible... though it would decrease performance (very slightly), and code has to be added to use the color value from the config file / command line / GUI.

For few graphics you can use savestate viewers - see my sig.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
PhoenixX_2
Rookie
Posts: 17
Joined: Tue Jul 11, 2006 4:56 pm

Post by PhoenixX_2 »

I'll check that out.

But, uhm, well, the back buffer needs to be cleared to some color, no matter what. Otherwise, if you'd play the game with just the sprite layer on, you'd see really neat (but weird) effects. The amount of time it takes to clear to black is the same amount of time it would take to clear to purple. At least, when using DirectX for the Windows port.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

PhoenixX_2 wrote:But, uhm, well, the back buffer needs to be cleared to some color, no matter what. Otherwise, if you'd play the game with just the sprite layer on, you'd see really neat (but weird) effects. The amount of time it takes to clear to black is the same amount of time it would take to clear to purple. At least, when using DirectX for the Windows port.
I don't know much about DirectX, but the ZSNES code probably uses a function call like "ClearSurface(0)", ie. the compiler inserts a constant (null). The modification would replace the constant with a variable reference, which is a tiny bit slower. I don't think you'd see a difference. :wink:
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
Joe Camacho
Devil's Advocate
Posts: 2293
Joined: Mon Aug 02, 2004 7:51 pm
Location: Hmo. Son.

Post by Joe Camacho »

This has been asked a couple of times, and for some reason it hasn't been implemented.
*Sometimes I edit my posts just to correct mistakes.
PhoenixX_2
Rookie
Posts: 17
Joined: Tue Jul 11, 2006 4:56 pm

Post by PhoenixX_2 »

Hehe, yeah. Using a varibale instead of a constant is slower, slightly. But, have you been able to compile zsnes? I'm currently having trouble. But, would you be able to make me a mod, possibly ;)?

I did try the state viewer. It's good I can change the background that way. This seems to be a possible solution. But to grab an animation, I'd have to make some 5 save states :D.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

re: mod
I would; I've never written or edited a C/C++ program though. There are other reasons as well.

Maybe devs like Poobah would do it. :)
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
PhoenixX_2
Rookie
Posts: 17
Joined: Tue Jul 11, 2006 4:56 pm

Post by PhoenixX_2 »

Yeah, I use C++ all the time. But I've never did much assembler stuff.

Were you the one who made vSNES?
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

Yup.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
PhoenixX_2
Rookie
Posts: 17
Joined: Tue Jul 11, 2006 4:56 pm

Post by PhoenixX_2 »

It's really well made.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

Thanks! :)
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
Poobah
Lurker
Posts: 164
Joined: Sun Sep 25, 2005 12:59 pm

Post by Poobah »

creaothceann wrote:Maybe devs like Poobah would do it. :)
I'm not a ZSNES dev! I also don't know much about DirectX.
Nach
ZSNES Developer
ZSNES Developer
Posts: 3904
Joined: Tue Jul 27, 2004 10:54 pm
Location: Solar powered park bench
Contact:

Post by Nach »

If you use Windows and want to build ZSNES yourself, download zget. Search forums for more info.
May 9 2007 - NSRT 3.4, now with lots of hashing and even more accurate information! Go download it.
_____________
Insane Coding
PhoenixX_2
Rookie
Posts: 17
Joined: Tue Jul 11, 2006 4:56 pm

Post by PhoenixX_2 »

Since it seems I'm not the only one asking for such a feature, is it possible that you could implement such an option? You can choose the colour of the background,the windows, etc.., so it'd just be adding an option for the backbuffer.

I'll look up zget.
blackmyst
Zealot
Posts: 1161
Joined: Sun Sep 26, 2004 8:36 pm
Location: Place.

Post by blackmyst »

Reading all your posts I'm sure I'm getting something wrong, but I thought the background color was determined by the game? Running donkey kong country 2 for example, it will be different for levels, menus etc.
[size=75][b]Procrastination.[/b]
Hard Work Often Pays Off After Time, but Laziness Always Pays Off Now.[/size]
Poobah
Lurker
Posts: 164
Joined: Sun Sep 25, 2005 12:59 pm

Post by Poobah »

He's talking about the colour of what is "behind" everything the game draws to the screen.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

blackmyst is right though, games can change that backdrop color via writes to $2132. (For gfx ripping, HDMA should be disabled. I think there's a key for that.)

I was probably wrong with the "ClearSurface(0)" call - I guess ZSNES just skips the disabled layers when rendering the screen. The backdrop color would still get set, so no additional clearing is needed to erase the previous screen content.

The code modification would have to always use the user-selected color for backdrop, not the SNES value at $2132.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
PhoenixX_2
Rookie
Posts: 17
Joined: Tue Jul 11, 2006 4:56 pm

Post by PhoenixX_2 »

Oh really. That makes sense actually. Come to think of it, I remember looking at something like that when I was trying to make a GBA game :D.

But yeah, vSNES is kinda solving every problem for me. Though, I WISH someone had hacked into Soulblazer before, instead of me having to do it ;).
Deathlike2
ZSNES Developer
ZSNES Developer
Posts: 6747
Joined: Tue Dec 28, 2004 6:47 am

Post by Deathlike2 »

creaothceann wrote:blackmyst is right though, games can change that backdrop color via writes to $2132. (For gfx ripping, HDMA should be disabled. I think there's a key for that.)

I was probably wrong with the "ClearSurface(0)" call - I guess ZSNES just skips the disabled layers when rendering the screen. The backdrop color would still get set, so no additional clearing is needed to erase the previous screen content.

The code modification would have to always use the user-selected color for backdrop, not the SNES value at $2132.
The only thing that may be of some use would be the Palette0 option that is used in the DOS port. By default (it wasn't in earlier versions), ZSNES colors the background black when using an 8-bit rendering mode. When disabled, the background color changes to other colors... This might be something worth looking at as a start.
Continuing [url=http://slickproductions.org/forum/index.php?board=13.0]FF4[/url] Research...
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

PhoenixX_2 wrote:But yeah, vSNES is kinda solving every problem for me. Though, I WISH someone had hacked into Soulblazer before, instead of me having to do it ;).
Glad to hear that. Have you checked romhacking.net if there's something about that game? Anyway, good luck!
Deathlike2 wrote:The only thing that may be of some use would be the Palette0 option that is used in the DOS port. By default (it wasn't in earlier versions), ZSNES colors the background black when using an 8-bit rendering mode. When disabled, the background color changes to other colors... This might be something worth looking at as a start.
Yeah, the whole monitor background is filled by color 0 of the VGA palette, which ZSNES probably was setting to the SNES backdrop color. This could also be modified to support the user's selected color - but 8-bit screenshots save the palette, and for a few pics you can change color 0 in an image editor like PaintShop Pro.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
PhoenixX_2
Rookie
Posts: 17
Joined: Tue Jul 11, 2006 4:56 pm

Post by PhoenixX_2 »

Could I request a feature for vSNES ;)? Something that grabs the tiles from a specific BG and puts it into a bmp? Because right now, I will have to manually go through each palette and export the VRAM and figure out which palette was meant for each tile.

I mean, it's not a big deal, nor something I'll probably wait for, unless you can do it super quickly. But I'd imagine it'd be pretty useful for others too :P.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

That's a bit difficult since a gfx tile might be used by several layers, and each layer could use it several times with a different palette. I (almost) only do the stuff that requires no guesswork.

You can use BGMAPPER (the inspiration for vSNES); it tries to color the VRAM tiles. It'll not be perfect in every case, but maybe it saves some work.

Btw. the tiles of the current scene are visible in the SceneViewer... does that help?
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
PhoenixX_2
Rookie
Posts: 17
Joined: Tue Jul 11, 2006 4:56 pm

Post by PhoenixX_2 »

That's what I mean, it'd take a specific BG and grab the tiles with the appropriate palette. So say a specific BG had four diamonds, using the same tile (using four different palettes). It'd grab those four diamonds in each of their form, and put them into a file. So you'd have a table:

Tile | Palette

And each time you see a tile/palette tuple, you'd add it to the bitmap.

I definately do not mean have it automatically figure out each tile and how it could be used. I just mean from a specific state, it forms a tile-set based purely on the BG and how IT used it.

Just an idea.
creaothceann
Seen it all
Posts: 2302
Joined: Mon Jan 03, 2005 5:04 pm
Location: Germany
Contact:

Post by creaothceann »

Well, I won't be able to change vSNES or write a new tool, since the source and the compiler is inaccessible to me right now. :? (Not for others though.)

But anyway:

How exactly is this "grabbing" meant? Do you mean creating a text file with the tile / palette indices, or creating a new bitmap?

It would not be hard IMO to create a C/C++ program that opens a ZSNES savestate, reads VRAM, some registers (which could also be entered manually) and the palette, and iterates through the tilemaps. You could take the savestate format from vSNES' source or romhacking.net.
vSNES | Delphi 10 BPLs
bsnes launcher with recent files list
PHoNyMiKe
Retrosexual
Posts: 1011
Joined: Wed Jul 28, 2004 2:09 am
Location: Rapture

Post by PHoNyMiKe »

I was gonna say do a par code for the bg color register but it doesn't work. it pry has to be written to for it to update. in which case you could learn a little asm while you're at it, and pry put a write in the vblank. it'd be like a 2 byte rom hack.
[url=http://www.alexchiu.com/affiliates/clickthru.cgi?id=phonymike]ultimate immortality[/url]
[url=http://www.sloganizer.net/en/][img]http://www.sloganizer.net/en/image,zsnes,white,purple.png[/img][/url]
Post Reply