It is currently Thu Oct 19, 2017 12:20 am

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: Mon Mar 04, 2013 7:21 am 
Offline

Joined: Sun Jul 15, 2012 8:19 pm
Posts: 9
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


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 10:23 am 
Offline
User avatar

Joined: Sun Jul 01, 2012 6:44 am
Posts: 337
Location: Lion's den :3
Hey, Rai,

great, welcome to the coding club! I'm still a newbie too. :) But I just took a look at your code nonetheless.

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.

Beware of hex numbers -- $100 = 256 bytes! :wink:


Then there's this small, mysterious loop:
Code:
LDX #$0100

Loopingtwo:
STZ $2122
DEX
BNE Loopingtwo

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. :)

_________________
Some of my projects:
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 10:42 am 
Offline

Joined: Sun Jul 15, 2012 8:19 pm
Posts: 9
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.

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.

Beware of hex numbers -- $100 = 256 bytes! :wink:


Then there's this small, mysterious loop:
Code:
LDX #$0100

Loopingtwo:
STZ $2122
DEX
BNE Loopingtwo

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. :)

Hmm... well after doing some research, I think this may just be something to do with CGRAM.

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...
Quote:
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.


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 11:08 am 
Offline
User avatar

Joined: Sun Jul 01, 2012 6:44 am
Posts: 337
Location: Lion's den :3
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)


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 12:13 pm 
Offline

Joined: Sun Jul 15, 2012 8:19 pm
Posts: 9
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). :)

Thanks for that.

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.

Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 12:27 pm 
Offline
User avatar

Joined: Sun Jul 01, 2012 6:44 am
Posts: 337
Location: Lion's den :3
Rai wrote:
Even with all the docs, you still mostly have to figure out everything yourself.

Yeah, but that's part of the fun. :D

_________________
Some of my projects:
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 12:34 pm 
Offline

Joined: Sun Jul 15, 2012 8:19 pm
Posts: 9
Ramsis wrote:
Rai wrote:
Even with all the docs, you still mostly have to figure out everything yourself.

Yeah, but that's part of the fun. :D

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.

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.


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 12:55 pm 
Offline
User avatar

Joined: Sun Jul 01, 2012 6:44 am
Posts: 337
Location: Lion's den :3
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.

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:
I might make my own SNES homebrew tutorial one day with ASM examples that are clear and have detailed comments.

Yes, please do! :)

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.

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. :)

_________________
Some of my projects:
Furry RPG!
Unofficial SNES PowerPak firmware
(See my GitHub profile for more)


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 2:25 pm 
Offline

Joined: Sun Jul 15, 2012 8:19 pm
Posts: 9
Ramsis wrote:
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.

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:
I might make my own SNES homebrew tutorial one day with ASM examples that are clear and have detailed comments.

Yes, please do! :)

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.

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. :)

Well do you know any good examples of using the joypad?

I've looked and looked and looked and none of the examples have worked.


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 2:48 pm 
Offline

Joined: Sun Sep 19, 2004 11:12 pm
Posts: 19099
Location: NE Indiana, USA (NTSC)
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.


Top
 Profile  
 
PostPosted: Mon Mar 04, 2013 6:07 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2286
Rai wrote:

You can download the asm file for the sprite routine here:
http://www.mediafire.com/download.php?sb9bmmpnozdl1jc


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:


Code:
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


BTW, "org" is not really an ASM instruction. I don't know what assembler your using, but on xkas, the "org" command tells xkas what address to write code to.


Top
 Profile  
 
PostPosted: Tue Mar 05, 2013 5:27 am 
Offline

Joined: Sun Jul 15, 2012 8:19 pm
Posts: 9
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.

It's nothing to do with the SNES, but more a lack of clear ASM samples on how to do anything.

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.


Top
 Profile  
 
PostPosted: Tue Mar 05, 2013 11:51 am 
Offline

Joined: Sun Sep 30, 2012 3:44 am
Posts: 82
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


Top
 Profile  
 
PostPosted: Tue Mar 05, 2013 4:02 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2286
Code:
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


Here is the code I use.


Top
 Profile  
 
PostPosted: Wed Mar 06, 2013 8:04 am 
Offline

Joined: Thu Oct 05, 2006 6:29 am
Posts: 911
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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next

All times are UTC - 7 hours


Who is online

Users browsing this forum: lint and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group