Cannot get sprites to display
Moderator: Moderators
Forum rules
- For making cartridges of your Super NES games, see Reproduction.
Cannot get sprites to display
I am trying to create a simple Pong game for the snes. I have got the background to appear but I cannot get the sprites to appear.
As you can see, the correct values are appearing in OAM, but the sprite preview is completely blankand they do not appear on screen. I have enabled the OAM in register $212c, what have I missed? Sorry if I have missed something dumb but I have searched the forum and the snes developer's manual and I am kind of at the end of my tether here.
As you can see, the correct values are appearing in OAM, but the sprite preview is completely blankand they do not appear on screen. I have enabled the OAM in register $212c, what have I missed? Sorry if I have missed something dumb but I have searched the forum and the snes developer's manual and I am kind of at the end of my tether here.
-
- Posts: 3140
- Joined: Wed May 19, 2010 6:12 pm
Re: Cannot get sprites to display
Maybe there's no sprite palettes. Sprites use the 2nd half of the color palette table.
Re: Cannot get sprites to display
Also note that even with the palette set, color 0 of that palette will always be transparent regardless of what value you set it to, so if the sprite pixels are all 0, it won't show up at all.
Re: Cannot get sprites to display
Are you sure the graphics data for the sprites is in the right place in VRAM, and that you've pointed the PPU at it via $2101?
Re: Cannot get sprites to display
I copied the palette entries to the second half of the table and it worked first time. I knew it would be something stupid like that. Oh well, I'll know next time.
Thank you everyone for your answers.
Edit: I have a couple more questions to ask. Now that the sprites are appearing, they seem to be vertically stretched.
The sprite on the right is supposed to be square. Is this because I'm not using a scanline filter?
The other thing I wanted to ask was about fading the screen in and out. This is my code for both
The weird thing is these routines work in snes9x but not in bsnes. I'm guessing this is because bsnes is supremely accurate and stricter about writing to the registers. Is there a more appropriate way to fade the screen in and out?
Thank you everyone for your answers.
Edit: I have a couple more questions to ask. Now that the sprites are appearing, they seem to be vertically stretched.
The sprite on the right is supposed to be square. Is this because I'm not using a scanline filter?
The other thing I wanted to ask was about fading the screen in and out. This is my code for both
Code: Select all
transitiontogame: //fadeout screen
sep #$20
lda #$80
sta $4200
dec {DISPLAY_REG} //shadow of $2100 in ram
bpl .stillfading
jmp loadgame
.stillfading:
wai
jmp transitiontogame
fadeintogame: //fade into game
sep #$20
inc {DISPLAY_REG}
lda {DISPLAY_REG}
cmp #$0f
bcc .stillfading
jmp gamelogic
.stillfading:
wai
jmp fadeintogame
//DISPLAY_REG is only copied to $2100 during vblank
Re: Cannot get sprites to display
Don't you have to enable NMI during V-Blank (or forced V-Blank) ?
https://twitter.com/Lint_
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]
Re: Cannot get sprites to display
Yes, reading $4210 once has to be done in one's NMI routine.
I don't see anything "immediately" wrong (but it's almost 0300 here) with the code in question, but I'm not sure that manipulating $2100 directly like that is ideal. inc (on a memory location or direct page) effectively does a read-write-increment-write operation (i.e. inc $2100 is actually the equivalent of lda $2100, sta $2100, inc, sta $2100). So, I would suggest keeping track of your "screen fade value" in direct page or RAM somewhere, and then reading/writing that to $2100. If you want an example of screen fading, the little demo I made as part of my SNES documentation back in the 90s included source for it.
Edit: oh, one thing I did notice: you're re-writing $80 to $4200 every fade in phase. I don't know what that's actually going to do to NMI. You should really only be doing that once. You don't need to keep doing it. Try changing your jmp to a label that does the dec. Or just go look at my old code. Honestly the screen fade stuff isn't that hard.
I don't see anything "immediately" wrong (but it's almost 0300 here) with the code in question, but I'm not sure that manipulating $2100 directly like that is ideal. inc (on a memory location or direct page) effectively does a read-write-increment-write operation (i.e. inc $2100 is actually the equivalent of lda $2100, sta $2100, inc, sta $2100). So, I would suggest keeping track of your "screen fade value" in direct page or RAM somewhere, and then reading/writing that to $2100. If you want an example of screen fading, the little demo I made as part of my SNES documentation back in the 90s included source for it.
Edit: oh, one thing I did notice: you're re-writing $80 to $4200 every fade in phase. I don't know what that's actually going to do to NMI. You should really only be doing that once. You don't need to keep doing it. Try changing your jmp to a label that does the dec. Or just go look at my old code. Honestly the screen fade stuff isn't that hard.
Re: Cannot get sprites to display
koitsu : At first i tough that myself too, then I saw the last line of the code provided : DISPLAY_REG is only copied to $2100 during vblank
My point is that I think that NMI isnt even enabled (cause it have to be done during forced V-Blank), so DISPLAY_REG value is never copied into $2100. snes9x don't care about that ... bsnes is more accurate on that one.
My point is that I think that NMI isnt even enabled (cause it have to be done during forced V-Blank), so DISPLAY_REG value is never copied into $2100. snes9x don't care about that ... bsnes is more accurate on that one.
https://twitter.com/Lint_
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]
Re: Cannot get sprites to display
You're using 4 sprites, and all of them are pointing to char #65, which appears to be a 4x8 white block, is it not?AzimuthFE wrote:The sprite on the right is supposed to be square. Is this because I'm not using a scanline filter?
Re: Cannot get sprites to display
Thank you for your replies. I should have made it clear that the NMI is already enabled when the program enters these routines. I write #$80 to this register to disable the joypad. Having said that I did move the write outside the loop. I watched the fade frame-by-frame and it does seem to be working; it's just harder to perceive in bsnes than snes9x.
I tried it in higan-performance and it works fine. It even does the fade in the same way snes9x does. However, when I open the rom in higan-accuracy this happens:
The amount that it is shifted varies each time I open the rom.
I tried it in higan-performance and it works fine. It even does the fade in the same way snes9x does. However, when I open the rom in higan-accuracy this happens:
The amount that it is shifted varies each time I open the rom.
O.O really? I am just making a complete ass of myself in this thread aren't I? I changed the character and it worked. Thanks.ccovell wrote:
You're using 4 sprites, and all of them are pointing to char #65, which appears to be a 4x8 white block, is it not?
-
- Posts: 271
- Joined: Sun Mar 27, 2011 10:49 am
- Location: Victoria, BC
Re: Cannot get sprites to display
If something changes every time, then it relies on uninitialized data i.e. you're not initializing something you need to.
Re: Cannot get sprites to display
Yup. I used a rather lazy loop to initialize the registers (a loop storing #$00 to $2100,x until x reached #$44). I added a loop that explicitly writes #$00 twice to each scroll register and it works. Thanks to everyone for the help.adam_smasher wrote:If something changes every time, then it relies on uninitialized data i.e. you're not initializing something you need to.
Re: Cannot get sprites to display
If by "initialise" you're talking about actually initialising the console itself on reset, writing $00 to all the registers is incorrect. The official documentation clearly outlines what all the values need to be (you can exclude $2104, $2118, $2119, and $2122).AzimuthFE wrote:Yup. I used a rather lazy loop to initialize the registers (a loop storing #$00 to $2100,x until x reached #$44). I added a loop that explicitly writes #$00 twice to each scroll register and it works. Thanks to everyone for the help.adam_smasher wrote:If something changes every time, then it relies on uninitialized data i.e. you're not initializing something you need to.