SNES game programing help
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: SNES game programing help
I don't see anything wrong with the code that I wrote and you fixed, psychopathicteen, but I tried putting it with a code I'm writing and the game freaks out and the screen goes black. I'm pretty sure it has to do with the php and plp things, because they always seem to cause trouble. I also changed the code so that it works using bytes instead of words, but I will change it back when I use the 9th x bit.
Here it is: In order to assemble the file, go to the folder titled "Metasprite Demo" using the command line and type in "wla Metasprite Demo". I put in bsnes to play the file on.
Here it is: In order to assemble the file, go to the folder titled "Metasprite Demo" using the command line and type in "wla Metasprite Demo". I put in bsnes to play the file on.
Re: SNES game programing help
The problem is that your MetapriteTable was in Bank 4 but you were using DP addressing to load from it, which always uses bank 0.. I moved your table to bank 0 and it seemed to work fine after that.
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: SNES game programing help
Thank You!
I had no idea that kind of limitation existed. By the way, what do you think is the first thing I should do to expand my code? (I'm not really interested in a horizontally flipping metasprites, because I eventually plan to make a horizontal shooter and not enough enemies will turn around to make it worthwile.) I will try to implement said improvements, but I already know I will end up running back here. 
Re: SNES game programing help
Eh you should really learn to rely on yourself more.
I wouldn't consider it a limitation.. You can set the data bank byte and there are alternate addressing modes that provide 24-bit addressing. It's more like you need to learn more about the various addressing modes on the SNES. I suggest pouring over various documents including 65816info.txt (google it) and http://wiki.nesdev.com/w/images/7/76/Programmanual.pdf
Now, your BG1 background was also displaying incorrectly.. you had some errors in your VRAM upload address and background register settings. I fixed them.. I also added the background to scroll so that we can see it working when u move your sprite. You can do a "diff" on MetaspriteTest.asm, I only changed a few lines from your original.. Do you know what diff is?
here's a link to the fix: http://botb.club/~bazz/snes/MetaspriteDemo.zip
Now, one of the most important things you could do is establish an official MetaSprite format. something that transcends this forum post that a lot of people could learn and stick with. That would be most useful to everybody.
btw, what game is your avatar from?
I wouldn't consider it a limitation.. You can set the data bank byte and there are alternate addressing modes that provide 24-bit addressing. It's more like you need to learn more about the various addressing modes on the SNES. I suggest pouring over various documents including 65816info.txt (google it) and http://wiki.nesdev.com/w/images/7/76/Programmanual.pdf
Now, your BG1 background was also displaying incorrectly.. you had some errors in your VRAM upload address and background register settings. I fixed them.. I also added the background to scroll so that we can see it working when u move your sprite. You can do a "diff" on MetaspriteTest.asm, I only changed a few lines from your original.. Do you know what diff is?
here's a link to the fix: http://botb.club/~bazz/snes/MetaspriteDemo.zip
Now, one of the most important things you could do is establish an official MetaSprite format. something that transcends this forum post that a lot of people could learn and stick with. That would be most useful to everybody.
btw, what game is your avatar from?
Re: SNES game programing help
Different metasprite formats are better for different games. For example, cut scenes in Concentration Room for NES use horizontal or vertical strips of 8x8 pixel tiles with the same color set byte and tile numbers 1 apart (horizontally) or 16 apart (vertically).bazz wrote:Now, one of the most important things you could do is establish an official MetaSprite format.
Paste the URL of Espozo's avatar into Google Search, click Search, click Search by image, and the result is "Best guess for this image: metal slug boss". I put in my current avatar and I get Peppa Freaking Pig.btw, what game is your avatar from?
Re: SNES game programing help
i thought it might be metal slug. love that game.
anyways.. weird thing happens (you're right about different formats.. but he should officialize his I think for himself and those around him).
But yeah, weird thing happens on accurate emulators when his sprite is at ~Y coord 0-15 .. whatever portion of it is in that range will not display.. I can't figure out why... ie:

EDIT: solution below
anyways.. weird thing happens (you're right about different formats.. but he should officialize his I think for himself and those around him).
But yeah, weird thing happens on accurate emulators when his sprite is at ~Y coord 0-15 .. whatever portion of it is in that range will not display.. I can't figure out why... ie:

EDIT: solution below
Last edited by bazz on Sat Jan 03, 2015 1:23 am, edited 1 time in total.
- Drew Sebastino
- Formerly Espozo
- Posts: 3496
- Joined: Mon Sep 15, 2014 4:35 pm
- Location: Richmond, Virginia
Re: SNES game programing help
I have a bad tendency to take people for granted. I'm really a bit of an a**.bazz wrote:Eh you should really learn to rely on yourself more.
Thank you again! And I have no clue what "diff" means.bazz wrote:Now, your BG1 background was also displaying incorrectly.. you had some errors in your VRAM upload address and background register settings. I fixed them.. I also added the background to scroll so that we can see it working when u move your sprite. You can do a "diff" on MetaspriteTest.asm, I only changed a few lines from your original.. Do you know what diff is?
I'm a bit surprised that it has taken this long for somebody to ask. It's from the game, Gunforce 2. I am also bit surprised at the accuracy of the google picture thing, as the game is made by a team at Irem (Irem made r-type, moon patrol, kung fu, etc) that eventually formed Nazca after Irem went bankrupt in 1994. (Gunforce 2 was actually their last arcade game.) Nazca actually made Metal Slug (although I think Metal Slug is a downgrade from Gunforce 2 in many respects, but that's a different story) which would explain the similar art style. Interestingly, some sound effects and apparently a bit of programming was taken from Gunforce 2 to create Metal Slug. Even Eri's death scream that started in Metal Slug 2 (when she was first a playable character) was taken from Lei (I assume that that's 2nd player's name?) in Gunforce 2. About where specifically the picture comes from the game, it comes from the first level boss, which is probably the least thought out design for a vehicle imaginable. (It appears to be able to only fly backwards and it has a cockpit underneath metal armor.)tepples wrote:Quote:btw, what game is your avatar from?Paste the URL of Espozo's avatar into Google Search, click Search, click Search by image, and the result is "Best guess for this image: metal slug boss". I put in my current avatar and I get Peppa Freaking Pig.
About why it's not displaying, I have no idea either. It appears to be an overdraw problem though, and whenever you change the sprite sizes in $2101, it clipping area changes based on the lowest sprite size, (Edit: apparently doesn't apply with 8x8 and 16x16. I only tested 32x32 and 64x64) implying that it is just writing a bunch of invisible sprites at the top for some reason.
Also tepples, what is your profile picture? Humpty Dumpty?
Edit: The sprite glitchiness is actually found in the normal walker code, it's just that no sprites actually get that far up the screen
Last edited by Drew Sebastino on Fri Jan 02, 2015 11:16 pm, edited 4 times in total.
Re: SNES game programing help
EDIT: the real solution is belowbazz wrote:weird thing happens on accurate emulators when his sprite is at ~Y coord 0-15 .. whatever portion of it is in that range will not display.. I can't figure out why... ie:
Oddly enough, using a sprite mode where 16x16 is the "large" size.. it works fine now...
I switched from 16/32 mode to 8/16 and switched Hi-OAM to use the "large" sprites for the 2 active ones.. That fixed the problem but I have no idea why
Last edited by bazz on Sat Jan 03, 2015 1:26 am, edited 2 times in total.
Re: SNES game programing help
I found the solution:

Incase the image dies: It is prohibited to write 100h to sprite X- positions.
You need to at least write "01" to all off-screen sprites' LSB X-value when the MSb is set to avoid this bug. There may be better values than 01 in the long run.. adjust to your needs
I wrote a "non-optimized" solution, Label could use some work, you can stick it after your Sprite init:
EDIT: I updated the link to include this stuff. And I messed with the priority to have a cooler effect: http://botb.club/~bazz/snes/MetaspriteDemo.zip
Oh and I commented nothing.
I fixed the collision detection to look nicer, but it's using static size.. ideally it should look up the meta sprite's size to be dynamic. It's a baby but have fun with it I hope you develop it into something cool
Diff is a tool we programmers use to look at the differences between files.. It's useful when you have 2 versions of a file and you want to see the "diff"erences. It's a native tool I believe to all *nix systems. But if you're on Windows, good luck finding a diff tool I can't recommend. I don't use Windows that much anymore. I prefer graphic diff but command line is too readily available
Diff also has the ability to create patches for one or more files, or whole directories. It's really useful. Then you can pass a patch around so that someone else with the old version of the file(s) can apply your patch and get the new one(s) out of it.

Incase the image dies: It is prohibited to write 100h to sprite X- positions.
You need to at least write "01" to all off-screen sprites' LSB X-value when the MSb is set to avoid this bug. There may be better values than 01 in the long run.. adjust to your needs
I wrote a "non-optimized" solution, Label could use some work, you can stick it after your Sprite init:
Code: Select all
; expects 8/16 A/XY
lda #$01
ldx #0000
_derp:
sta SpriteBuf1,x
inx
inx
inx
inx
cpx #$200
bne _derpOh and I commented nothing.
I fixed the collision detection to look nicer, but it's using static size.. ideally it should look up the meta sprite's size to be dynamic. It's a baby but have fun with it I hope you develop it into something cool
Diff is a tool we programmers use to look at the differences between files.. It's useful when you have 2 versions of a file and you want to see the "diff"erences. It's a native tool I believe to all *nix systems. But if you're on Windows, good luck finding a diff tool I can't recommend. I don't use Windows that much anymore. I prefer graphic diff but command line is too readily available
- Attachments
-
- MetaspriteDemo2.zip
- bazz's corrections / modifications
- (3.95 MiB) Downloaded 73 times
Last edited by bazz on Wed Mar 25, 2015 4:07 am, edited 1 time in total.
Re: SNES game programing help
I think enough of us here can recognize the art style and know the history of IREM/Nazca that we didn't need to ask.Espozo wrote:I'm a bit surprised that it has taken this long for somebody to ask. It's from the game, Gunforce 2...
Re: SNES game programing help
I recently joined Twitter. New Twitter users have an egg as their avatar, which I take to represent a Twitter bird mascot that hasn't hatched yet. So I added a head, arms, and clothes to my egg. The head is modeled after that of a cartoon character: either Pinocchio or Tommy Himi (take your pick).Espozo wrote:Also tepples, what is your profile picture? Humpty Dumpty?
That'd probably be MSYS, which gives you GNU Diffutils along with Bash, GNU Make, and GNU Coreutils. This way, programmers comfortable with GNU/Linux can be comfortable in Windows.bazz wrote:But if you're on Windows, good luck finding a diff tool I can't recommend.
What SNES debugger do you use? I currently use NO$SNS in Wine.bazz wrote:I don't use Windows that much anymore.
-
psycopathicteen
- Posts: 3001
- Joined: Wed May 19, 2010 6:12 pm
Re: SNES game programing help
Or just place unused sprites below the screen at y=224.You need to at least write "01" to all off-screen sprites' LSB X-value when the MSb is set to avoid this bug. There may be better values than 01 in the long run.. adjust to your needs
Re: SNES game programing help
I would still avoid setting X = 0x100 simply because Nintendo's manual firmly warns against it.psycopathicteen wrote:Or just place unused sprites below the screen at y=224.You need to at least write "01" to all off-screen sprites' LSB X-value when the MSb is set to avoid this bug. There may be better values than 01 in the long run.. adjust to your needs
Re: SNES game programing help
Yes but if the OAM table never had a sprite at that X coordinate then setting it for off-screen sprites is pretty pointless.
Re: SNES game programing help
Not clear. I don't understand. At what X-coordinate.. "never had a sprite" it's just not clearSik wrote:Yes but if the OAM table never had a sprite at that X coordinate