Banner
Views: 802,432,942
Time:
11 users online: codfish1002, Darolac, fsvgm777, Infinity,  KevinM,  Linkdeadx2, Osaka_OSK, Pat, Romano338, Samantha, sss cs - Guests: 19 - Bots: 51 Users: 41,953 (1,755 active)
Latest: lautaroalfonso52
Tip: This thread contains data you might find helpful when coding.Not logged in.
GradientTool - Latest Version: v0.8.2.1 (July 7, ‘15)
Forum Index - SMW Hacking - Resource & Tool Releases - GradientTool - Latest Version: v0.8.2.1 (July 7, ‘15)
Pages: « 1 2 »
Because it deserves its own thread.

As it's name may suggest, GradientTool is a tool that generates HDMA gradients. From scratch. Just add a few gradient stops, and voila! you've got a nice HDMA gradient.


With GradientTool, making HDMA gradients is a breeze!

Current version: v0.8.2.1

New feature:
  • Gamma corrected RGB gradients, i.e. RGB gradients with uniform brightness
Changes:
  • Value-corrected RGB gradients are now the default.
  • The default gradient has been changed to red → cyan to demonstrate RGB value correction.
  • The tab pages in the HDMA configuration dialog can now be used without HDMA code generation.
See the change log in the Readme for changes in previous versions.

Todo List:
  • Add some useful stuff to the generated code; particularly colour math-related stuff.
  • Clean up the code a bit
Wishlist:
  • Multisampling (better quality when gradient points are close together)
  • Hue, Saturation, Luminance (read: Luminance/Luma, not Lightness)
  • Compress all 3 RGB channels into one Transfer Mode 2 HDMA channel.

Download (v0.8.2.1, July 7, 2015)
Requires Microsoft .NET Framework 4.0 or 3.5

Any bugs, suggestions, etc., just post them here.

--------------------
That's pretty cool. I remember seeing your tool in the moderation queue and thinking how useful it sounded. Just one thing, though...it can handle gradients taller than one screen, right? Do you ever plan to make it support the format that I use for scrollable gradients, as seen here?
Originally posted by imamelia
...it can handle gradients taller than one screen, right?

Currently it generates a one-screen gradient; but with a little work, I could tweak it to handle longer gradients.

Originally posted by imamelia
Do you ever plan to make it support the format that I use for scrollable gradients?

Yes. One question though; does continuous mode work with scrollable gradients?


Anyway, I've added these to the To Do list.

--------------------
Continuous mode? The tables I use for scrollable gradients actually aren't in any kind of HDMA-related format. It's just four bytes per stripe: number of scanlines, red, blue, green. (00 is the terminator byte.) For instance, 0x10 white scanlines (maximum red, green and blue) followed by 8 black (minimum) would look like this:
Code
db $10,$3F,$5F,$9F
db $08,$20,$40,$80
I have released a new version of GradientTool. See the link at the end of the first post of this thread.

New Features:
  • Brightness gradients can now be generated.
  • Number of scanlines can be modified.
  • Generate HDMA initialization code.
  • Cubic interpolated gradients.
  • Zooming.
Changes:
  • Moved gradient name text box to HDMA Configuration menu.
  • Increased the framerate of the eyedropper magnifier to 1,000 fps.
  • HDMA table labels are no longer prefixed with '.'
  • When re-generating HDMA tables, the caret will retain its old position, if possible.
  • Exported bitmap is now 24 pixels wide for your viewing pleasure.
Bugfixes:
  • When using the eyedropper, the magnification window will stay focused when using Alt+Tab.
  • Fixed a bug where when adding a gradient stop, the wrong part of the control was redrawn.


--------------------
Something about this disturbes me. Shouldn't an HDMA gradient use one channel?

--------------------
Putting my YI hack on hold.
Color gradients require at least 2 channels to be accurate (Roy managed to do it with one channel somehow, but he cheated).

Now, while the tool looks great, I still wish you'd support the 4-byte format. Copying the data a byte at a time is quite tedious. Compressing it to 2 channels for fixed gradients would be nice as well. Also, you made a typo: it says "Uses HMDA channels 3, 4, and 5" instead of "Uses HDMA channels 3, 4, and 5".
Yea, what imamelia said is true. That typo exists. It's no big deal. The tool works great. My one other question is what part of the code should I put in Maincode in LevelASM or {MainCodeLabel} in edit's version?

--------------------
Putting my YI hack on hold.
Originally posted by imamelia
I still wish you'd support the 4-byte format. Copying the data a byte at a time is quite tedious. Compressing it to 2 channels for fixed gradients would be nice as well.

Those two features are the next thing I plan on implementing.

Protip: You can export a bitmap from GradientTool and use Ersanio's H-DMA Gradient Ripper to make Mode 2 HDMA tables from it.

Originally posted by imamelia
It says "Uses HMDA channels 3, 4, and 5" instead of "Uses HDMA channels 3, 4, and 5".

Thanks for pointing that out; I didn't even notice.
Actually, that typo only occurs in the pseudo-syntax-highlighted text box. If you export the text to an ASM file, it (the .asm file) says "Uses HDMA channels ...".

Originally posted by Ripperon-X
What part of the code should I put in Maincode in LevelASM or {MainCodeLabel} in edit's version?

It goes in LevelInitASM. Also, if you're using LevelASMTool, you'll need to change RTS to RTL.



Also, about this:

Originally posted by imamelia
Color gradients require at least 2 channels to be accurate (Roy managed to do it with one channel somehow, but he cheated)

By cheating, do you mean doing something along the lines of this:

Code
db $20,$3F ; Set Red to   100%
db $20,$5F ; Set Green to 100%
db $20,$20 ; Set Red to   0%
db $20,$9F ; Set Blue to  100%
db $20,$40 ; Set Green to 0%
db $20,$3F ; Set Red to   100%
db $20,$80 ; Set Blue to  0%
db $00

to achieve something like this:
?

While this optimization may work for some gradients, it won't work for others. Particularly if the channels are in sync.
This level of optimization is better done by hand than by machine. So yeah, I don't think I'll be implementing it.
Though it does seem like a good way to drop the size of HDMA tables.

--------------------
I kinda wish they would've made one of the last two HDMA write modes (the redundant ones) be a "one register write 4 times." Sure it'd be useless for everything but color modification, and one of the writes would be pointless, but still! I doubt it would've been hard.
Not sure, if there's another typo, but shouldn't these gradients be the Mode 1 type? I mean Mode 0 has all four layers like layer 3.
Also, would these HDMA gradients work, if Mode 3 was enabled in a certain level?

--------------------
Putting my YI hack on hold.
Originally posted by Ripperon-X
Not sure, if there's another typo, but shouldn't these gradients be the Mode 1 type? I mean Mode 0 has all four layers like layer 3.
Also, would these HDMA gradients work, if Mode 3 was enabled in a certain level?

(H)DMA transfer mode has nothing to do with the PPU mode.
No, it shouldn't be mode 1. Yes, it should work fine if PPU mode is 3.

--------------------
<blm> zsnes users are the flatearthers of emulation
New update.

GradientTool Version 0.8.0.1

New Features:
  • Support for Transfer Mode 2
  • Support for scrollable gradients
  • Support for writing to CGRAM
  • The title bar will contain an asterisk (*) if the gradient has been modified since the last time HDMA code was generated.
  • If the gradient has been modified, then when saving an ASM file, you will be asked if you want to re-generate the HDMA code.
Changes:
  • Can run on both .NET Framework 3.5 Client Profile and .NET Framework 4 Client Profile.
  • Added info about exporting bitmaps to the code box's initial text.
  • Removed the unimplemented "Ready" label from the status bar.
  • When adding gradient stops, the colour dialog's title changes to "Add Gradient Stop".
  • Double-click the track to insert a gradient stop, rather than single-clicking it.
  • By default, HDMA initialization code will not be generated.
  • Made a new HDMA configuration dialog.
Bugfixes:
  • Fixed a potential bug where the application could crash when setting the scanline count too high on a computer with insufficient memory, or not enough continuous memory.
  • There was a wierd issue where changing the zoom to anything but Fit to Window would cause the gradient editor to disappear off the top of the window. Fixed, I think.


--------------------
These are features that people have been waiting for, mainly the scrolling gradient. I can't seem to enable Transfer Mode 2, because the tool doesn't let me. What can I do to enable it? And also, what's the difference between Transfer Mode 2 and Transfer Mode 0? I know, I stink at ASM.
Also, when I press generate code, when HDMA scrolling option is enabled, shouldn't there be some other code generated than this:
Code
Gradient1_Table:
db $05,$20,$40,$80
db $09,$20,$40,$81
db $08,$20,$40,$82
db $09,$20,$40,$83
db $09,$20,$40,$84
db $09,$20,$40,$85
db $08,$20,$40,$86
db $09,$20,$40,$87
db $09,$20,$40,$88
db $08,$20,$40,$89
db $09,$20,$40,$8A
db $09,$20,$40,$8B
db $09,$20,$40,$8C
db $08,$20,$40,$8D
db $09,$20,$40,$8E
db $09,$20,$40,$8F
db $09,$20,$40,$90
db $08,$20,$40,$91
db $09,$20,$40,$92
db $09,$20,$40,$93
db $08,$20,$40,$94
db $09,$20,$40,$95
db $09,$20,$40,$96
db $09,$20,$40,$97
db $08,$20,$40,$98
db $09,$20,$40,$99
db $01,$20,$40,$9A
db $00


Edit2: I tried a simple blue gradient. I pasted the generated code in LevelASM. But instead of getting the correct blue to black gradient, I get instead a greenish yellow to white gradient. I tested a brightness gradient and inserted the generated code in LevelASMTool. What I got instead was soem kind of a sepia gradient that immediately was some kind of whiteish yellow to black transition. Am I doing something wrong?

--------------------
Putting my YI hack on hold.
Originally posted by Ripperon-X
I can't seem to enable Transfer Mode 2, because the tool doesn't let me. What can I do to enable it?

Under Gradient Channels, make sure the selected option has at least two colour channels.


Originally posted by Ripperon-X
And also, what's the difference between Transfer Mode 2 and Transfer Mode 0?

Transfer Mode 2 writes 2 bytes to one register, while Transfer Mode 0 writes once.
See Kaijyuu's Comprehensive HDMA guide if you want to know what other transfer modes mean.


Originally posted by Ripperon-X
Also, when I press generate code, when HDMA scrolling option is enabled, shouldn't there be some other code generated?

The code for scrolling gradients is fairly large compared to normal HDMA; it shouldn't be copy-pasted, as it will bloat your ROM if you use them a lot.
I may include a sample ASM file in a future release.


Originally posted by Ripperon-X
I tried a simple blue gradient. I pasted the generated code in LevelASM. But instead of getting the correct blue to black gradient, I get instead a greenish yellow to white gradient.

Sounds like your level's Back Area Colour isn't black, when your gradient only has a blue channel.
If you want such a gradient to look exactly how it looks in GradientTool regardless of the level's BG colour, than use this:

Code
STZ $0701
STZ $0702 ; Assumes A is in 8-bit mode


Originally posted by Ripperon-X
I tested a brightness gradient and inserted the generated code in LevelASMTool. What I got instead was soem kind of a sepia gradient that immediately was some kind of whiteish yellow to black transition. Am I doing something wrong?

I'm not sure what happened.
Does the banner above all of the code say "Mode 0 INIDISP Gradient"?
Does the generated code STZ $43x0 (where x is an HDMA channel)?

--------------------
I figured that the background color isn't black. Now it's better. And same thing for the brightness gradient. Can I use imamelia's HDMA scrolling code, in combination with the generated HDMA scrolling code?
Will the editor have the option to create certain HDMA gradients like lava, water or desert types? Those are kind of like the brightness gradient, but with a different color, instead of black.

--------------------
Putting my YI hack on hold.
Originally posted by Ripperon-X
Can I use imamelia's HDMA scrolling code, in combination with the generated HDMA scrolling code?

It should. I've never really used scrolling HDMA, though.


Originally posted by Ripperon-X
Will the editor have the option to create certain HDMA gradients like lava, water or desert types? Those are kind of like the brightness gradient, but with a different color, instead of black.

Most glowing effects are actually a normal HDMA gradient.
To make it brighten the screen, you enable colour math, like so:

Code
LDA #$17	;\ Everything
STA $212C	;| is on main screen
LDA #$00 	;| Nothing
STA $212D	;| is on sub screen
LDA #$27	;| Affect layer 1,2,3
STA $40		;/ and back enable


There are other ways of doing colour math, however.
For example, you can use a palette gradient that writes to CGRAM address $00. It will effect all layers on the subscreen. Note that this way is incompatible with stuff like BG lightning.

--------------------
Originally posted by ShadowFan-X
By cheating, do you mean doing something along the lines of this:

Code
db $20,$3F ; Set Red to   100%
db $20,$5F ; Set Green to 100%
db $20,$20 ; Set Red to   0%
db $20,$9F ; Set Blue to  100%
db $20,$40 ; Set Green to 0%
db $20,$3F ; Set Red to   100%
db $20,$80 ; Set Blue to  0%
db $00

to achieve something like this:

pic


Nah. What I did to generate a full-colour gradient with $2132, using only one channel, was this. It's not a perfect solution, but the best solution thinkable and honestly, it's hardly visible.

Code
HDMARGB:
db $01,$20,$40 ; First, black out red and green.
db $07,$20,$80 ; Then black out blue (and red again).
; May be wise to keep the blue colour to start with the same as the blue part of the background colour selected in Lunar Magic.
; I initially forgot to do this, actually - that would mean the first scanline of the gradient is blue, not black.
db $01,$22,$41 ; Now, after 8 scanline, add some red and green.
db $38,$22,$81 ; Directly after, add some blue too. Together, this lasts for $39 scanlines in total.
db $01,$23,$43 ; Add some more red and green.
db $03,$23,$83 ; And some blue. 4 scanlines in total.
db $01,$24,$44 ; etc
db $03,$24,$85
db $01,$26,$45
;etc. the entire table is pretty big so I'm not pasting all of it
db $01,$3F,$5F
db $03,$3F,$8D
db $01,$20,$80 ; Black out red and blue first.
db $01,$20,$40 ; Then green.
db $00


I actually did use this gradient, in Norveg's beta boss room (still working on it):



Maybe you recognize the gradient. It should resemble the gradient used in Yoshi's Island's last room, the fight between Yoshi and the huge Baby Bowser. I think you can hardly find a difference really.

Downside to this method is that the very last line of the gradient became discoloured abruptly. This is not the case with all gradients, but since my gradient jumped from yellow to black directly, which was one jump too big to make in one single scanline, there was a bright green scanline visible right at the end of the gradient.
Of course, one can mask that up - and so I did. Layer 1 is now right above that very scanline, so it can't be seen.

So yeah - this is a way to do it. Not perfect, but when in dire need of HDMA channels, this is definitely the best way to tackle your problem.

--------------------
--------> Don't follow "Find Roy's Dignity", my hack. Because it's pretty outdated. <--------
Originally posted by Roy
db $01,$20,$80 ; Black out red and blue first.
db $01,$20,$40 ; Then green.
db $00

Since the bottom scanline seems to be hidden by layer 1, why not make it the color you want on the first scanline, and/or set $0701 to the desired color?

And yeah, while I don't have any major trouble seeing that there is some inequalities there, I couldn't see them if I don't know they're there, and with an angry rat with a jetpack nearby, everyone will have other stuff to concentrate on.

...oh, and...
Quote
db $01,$23,$43 ; Add some more red and green.
db $03,$23,$83 ; And some blue. 4 scanlines in total.

Can be compressed to db $04,$63,$83, or even db $04,$E3,$00. $2132 has no problems with setting multiple colors at once.

--------------------
<blm> zsnes users are the flatearthers of emulation
About the HDMA scrolling code, I hope the sample doesn't look like the one from this link:
http://dl.dropbox.com/u/9110994/scrollgradient.txt
While it looks like it works with LevelASM, this code doesn't work at all with LevelASMTool. I tried re-organising it, by moving the 1st long part of the code to InitCode_Label and the rest to MainCode_Label. I changed the only RTS to RTL. And tried the code and the level crashed. I hope this code does get optimised a lot. Also, would Roy's method of inserting HDMA gradients using only one channel be considered a future feature in your tool, along with the special gradients (e.g. lava, desert, etc)?

--------------------
Putting my YI hack on hold.
Pages: « 1 2 »
Forum Index - SMW Hacking - Resource & Tool Releases - GradientTool - Latest Version: v0.8.2.1 (July 7, ‘15)

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2020 - SMW Central
Legal Information - Privacy Policy - Link To Us


Total queries: 7

Menu

Follow Us On

  • YouTube
  • Twitch
  • Twitter

Affiliates

  • SMBX Community
  • ROMhacking.net
  • MFGG