Can someone explain palettes more in-depth to me?
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
Can someone explain palettes more in-depth to me?
Hey, Rai here. Recently, I've been trying to code the asm to display a sprite on the screen.
I've mostly been going off the walker.asm example in the snes starter kit.
Now, I've gotten the sprite to display, but unless I put the palette at 100 bytes after the DMA address; the palette will be weird.
In this case, the palette is at 81A000 and that's the address I DMA to CGRAM. But unless I put the palette at 81A100, it won't send the correct palette.
This is weird because I did store 0 to the color register, so I thought that meant that the game should use the first palette?
You can download the asm file for the sprite routine here:
http://www.mediafire.com/download.php?sb9bmmpnozdl1jc
I've mostly been going off the walker.asm example in the snes starter kit.
Now, I've gotten the sprite to display, but unless I put the palette at 100 bytes after the DMA address; the palette will be weird.
In this case, the palette is at 81A000 and that's the address I DMA to CGRAM. But unless I put the palette at 81A100, it won't send the correct palette.
This is weird because I did store 0 to the color register, so I thought that meant that the game should use the first palette?
You can download the asm file for the sprite routine here:
http://www.mediafire.com/download.php?sb9bmmpnozdl1jc
Re: Can someone explain palettes more in-depth to me?
Hey, Rai,
great, welcome to the coding club! I'm still a newbie too. But I just took a look at your code nonetheless.
Then there's this small, mysterious loop:
Remember that writing to $2122 auto-increments the address! So it's likely possible that by simply removing that Loopingtwo thingy (which is probably useless anyway), you'll solve your problem.
great, welcome to the coding club! I'm still a newbie too. But I just took a look at your code nonetheless.
Beware of hex numbers -- $100 = 256 bytes!Rai wrote:Now, I've gotten the sprite to display, but unless I put the palette at 100 bytes after the DMA address; the palette will be weird.
In this case, the palette is at 81A000 and that's the address I DMA to CGRAM. But unless I put the palette at 81A100, it won't send the correct palette.
Then there's this small, mysterious loop:
Code: Select all
LDX #$0100
Loopingtwo:
STZ $2122
DEX
BNE Loopingtwo
Some of my projects:
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)
Re: Can someone explain palettes more in-depth to me?
Hmm... well after doing some research, I think this may just be something to do with CGRAM.Ramsis wrote:Hey, Rai,
great, welcome to the coding club! I'm still a newbie too. But I just took a look at your code nonetheless.
Beware of hex numbers -- $100 = 256 bytes!Rai wrote:Now, I've gotten the sprite to display, but unless I put the palette at 100 bytes after the DMA address; the palette will be weird.
In this case, the palette is at 81A000 and that's the address I DMA to CGRAM. But unless I put the palette at 81A100, it won't send the correct palette.
Then there's this small, mysterious loop:Remember that writing to $2122 auto-increments the address! So it's likely possible that by simply removing that Loopingtwo thingy (which is probably useless anyway), you'll solve your problem.Code: Select all
LDX #$0100 Loopingtwo: STZ $2122 DEX BNE Loopingtwo
I've looked at another game and it only uses the first 256 bytes of CGRAM for backgrounds. It uses the latter 256 bytes for sprites. But is this is true or just a coindence?
Infact yeah, I think that's it. It's because color 128 starts at $100 in cgram and sprites can only use the latter 128 colors.
I only found one document clarifying this though...
The background can use the first 128 colors in BG modes 0,1,2,5,6, and all
256 colors in BG modes 3,4,7 when not in direct color mode. Sprites always
use the latter 128 colors. Specific details about palette use and selection
for each mode will be described later.
Re: Can someone explain palettes more in-depth to me?
Well, nocash's in-depth fullsnes documentation gives you an overview of palette indices. Looks like your assumption is right (and I was wrong).
Some of my projects:
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)
Re: Can someone explain palettes more in-depth to me?
Thanks for that.Ramsis wrote:Well, nocash's in-depth fullsnes documentation gives you an overview of palette indices. Looks like your assumption is right (and I was wrong).
Unfortunately, I'm beginning to realize why there's not much SNES homebrew out there. There's a lack of asm examples on how to do things and the examples out there, make things too confusing.
Even with all the docs, you still mostly have to figure out everything yourself.
For instance, I've been trying to understand how simply move a sprite up and searching on google hasn't brung up anything good. I feel as though the only way I can figure it out is to figure out how a commercial snes game does it.
Last edited by Rai on Mon Mar 04, 2013 12:27 pm, edited 1 time in total.
Re: Can someone explain palettes more in-depth to me?
Yeah, but that's part of the fun.Rai wrote:Even with all the docs, you still mostly have to figure out everything yourself.
Some of my projects:
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)
Re: Can someone explain palettes more in-depth to me?
Perhaps, but sometimes the only way to figure out clearly how to do a simple thing, is going into a commercial game and figuring it out.Ramsis wrote:Yeah, but that's part of the fun.Rai wrote:Even with all the docs, you still mostly have to figure out everything yourself.
Even doing something as simple reading joypad input is confusing with the current documents out there.
I might make my own SNES homebrew tutorial one day with ASM examples that are clear and have detailed comments.
Heck, I'm an experienced ASM hacker and still have trouble figuring out simple things even with all the docs out there. Imagine how hard it would be for a completely newbie.
Or maybe I'm just looking in the wrong places.
Re: Can someone explain palettes more in-depth to me?
There's another approach: Make changes in an example like walker.asm, recompile it, and see what happens. This helped me a lot in the beginning anyway.Rai wrote:sometimes the only way to figure out clearly how to do a simple thing, is going into a commercial game and figuring it out.
Yes, please do!Rai wrote:I might make my own SNES homebrew tutorial one day with ASM examples that are clear and have detailed comments.
True. And still, I think if you really want to do it, and learn to make good use of the docs that are out there, and study a lot of existing sourcecode -- then I think that even against all odds, you can get really far.Rai wrote:Heck, I'm an experienced ASM hacker and still have trouble figuring out simple things even with all the docs out there. Imagine how hard it would be for a completely newbie.
Some of my projects:
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)
Re: Can someone explain palettes more in-depth to me?
Well do you know any good examples of using the joypad?Ramsis wrote:There's another approach: Make changes in an example like walker.asm, recompile it, and see what happens. This helped me a lot in the beginning anyway.Rai wrote:sometimes the only way to figure out clearly how to do a simple thing, is going into a commercial game and figuring it out.
Yes, please do!Rai wrote:I might make my own SNES homebrew tutorial one day with ASM examples that are clear and have detailed comments.
True. And still, I think if you really want to do it, and learn to make good use of the docs that are out there, and study a lot of existing sourcecode -- then I think that even against all odds, you can get really far.Rai wrote:Heck, I'm an experienced ASM hacker and still have trouble figuring out simple things even with all the docs out there. Imagine how hard it would be for a completely newbie.
I've looked and looked and looked and none of the examples have worked.
Re: Can someone explain palettes more in-depth to me?
Have you tried programming the NES first? Following an NES tutorial just might twist your brain into the right state to become able to generalize the knowledge to the Super NES.
-
- Posts: 3140
- Joined: Wed May 19, 2010 6:12 pm
Re: Can someone explain palettes more in-depth to me?
Is that supposed to be your reset routine (routine that runs at bootup), or your nmi routine (routine that runs every frame)? This is how roughly your code should look like:Rai wrote:
You can download the asm file for the sprite routine here:
http://www.mediafire.com/download.php?sb9bmmpnozdl1jc
Code: Select all
reset:
jsr initialization
wai
nmi
jsr vblank
jsr gameplay
wai
org $00ffe0
interrupt_vectors:
dw 0,0,0,0,0,nmi,reset,0
dw 0,0,0,0,0,nmi,reset,0
Re: Can someone explain palettes more in-depth to me?
It's nothing to do with the SNES, but more a lack of clear ASM samples on how to do anything.tepples wrote:Have you tried programming the NES first? Following an NES tutorial just might twist your brain into the right state to become able to generalize the knowledge to the Super NES.
I mean I've made several ASM hacks to SNES games, such as adding compression to text and even adding advance hacks like VWF's.
It's not that I don't understand ASM, it's not understanding one part of a particular code. Myself, I've done everything the examples have said, initialized all the joypad registers and the joypad register still loads zero.
But I certainly will write a homebrew document. If only so novice ASM guys can understand how to do simple things.
Re: Can someone explain palettes more in-depth to me?
I have been trying to wrap my head around SNES programming lately, have you had a look at these pages?
http://wiki.superfamicom.org/snes/show/HomePage
http://en.wikibooks.org/wiki/Super_NES_Programming
Also, this example file is nice. http://filebin.ca/T4jRsOzndk0
http://wiki.superfamicom.org/snes/show/HomePage
http://en.wikibooks.org/wiki/Super_NES_Programming
Also, this example file is nice. http://filebin.ca/T4jRsOzndk0
-
- Posts: 3140
- Joined: Wed May 19, 2010 6:12 pm
Re: Can someone explain palettes more in-depth to me?
Code: Select all
fetch_joypad:
lda #$01
sta $4200
wait_for_joypad:
lda $4212
and #$01
bne wait_for_joypad
lda $4218
sta !joypad1
lda $4219
sta !joypad1hi
lda $421a
sta !joypad2
lda $421b
sta !joypad2hi
rts
Re: Can someone explain palettes more in-depth to me?
My VGM player for the SNES uses a lot of stuff that a typical game would include: joypad input, audio playback, hdma effects, sprites, etc. The full (assembly) source code is available here.
To find the subroutine responsible for updating the OAM (sprites), search for UpdateOAM in t700c.asm.
To find the subroutine responsible for updating the OAM (sprites), search for UpdateOAM in t700c.asm.