It is currently Sun Oct 22, 2017 7:50 pm

All times are UTC - 7 hours



Forum rules


Related:



Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Thu Jun 09, 2016 5:03 pm 
Offline

Joined: Thu Jun 09, 2016 4:46 pm
Posts: 14
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.

Attachment:
pongoam.png
pongoam.png [ 22.03 KiB | Viewed 1594 times ]


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.


Top
 Profile  
 
PostPosted: Thu Jun 09, 2016 5:18 pm 
Offline

Joined: Wed May 19, 2010 6:12 pm
Posts: 2295
Maybe there's no sprite palettes. Sprites use the 2nd half of the color palette table.


Top
 Profile  
 
PostPosted: Thu Jun 09, 2016 6:28 pm 
Offline

Joined: Sun Mar 27, 2016 7:56 pm
Posts: 137
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.


Top
 Profile  
 
PostPosted: Thu Jun 09, 2016 7:51 pm 
Offline

Joined: Fri Jul 04, 2014 9:31 pm
Posts: 788
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?


Top
 Profile  
 
PostPosted: Thu Jun 09, 2016 11:10 pm 
Offline

Joined: Thu Jun 09, 2016 4:46 pm
Posts: 14
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. :oops: 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.

Attachment:
fsnes000.png
fsnes000.png [ 556 Bytes | Viewed 1515 times ]


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


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?


Top
 Profile  
 
PostPosted: Fri Jun 10, 2016 1:49 am 
Offline

Joined: Thu May 15, 2008 4:05 am
Posts: 25
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]


Top
 Profile  
 
PostPosted: Fri Jun 10, 2016 3:01 am 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
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.


Top
 Profile  
 
PostPosted: Fri Jun 10, 2016 3:08 am 
Offline

Joined: Thu May 15, 2008 4:05 am
Posts: 25
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.

_________________
https://twitter.com/Lint_
http://snesdev.antihero.org/ [depecated blog, new one coming one of these days]


Top
 Profile  
 
PostPosted: Fri Jun 10, 2016 7:06 am 
Offline

Joined: Sun Mar 19, 2006 9:44 pm
Posts: 916
Location: Japan
AzimuthFE wrote:
The sprite on the right is supposed to be square. Is this because I'm not using a scanline filter?


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?

_________________
http://www.chrismcovell.com


Top
 Profile  
 
PostPosted: Fri Jun 10, 2016 9:13 am 
Offline

Joined: Thu Jun 09, 2016 4:46 pm
Posts: 14
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:

Attachment:
higanmessedup.png
higanmessedup.png [ 43.43 KiB | Viewed 1452 times ]


The amount that it is shifted varies each time I open the rom.

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?


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.


Top
 Profile  
 
PostPosted: Fri Jun 10, 2016 11:46 am 
Offline

Joined: Sun Mar 27, 2011 10:49 am
Posts: 192
If something changes every time, then it relies on uninitialized data i.e. you're not initializing something you need to.


Top
 Profile  
 
PostPosted: Sat Jun 11, 2016 7:20 am 
Offline

Joined: Thu Jun 09, 2016 4:46 pm
Posts: 14
adam_smasher wrote:
If something changes every time, then it relies on uninitialized data i.e. you're not initializing something you need to.


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.


Top
 Profile  
 
PostPosted: Sat Jun 11, 2016 12:07 pm 
Offline
User avatar

Joined: Sun Sep 19, 2004 9:28 pm
Posts: 3192
Location: Mountain View, CA, USA
AzimuthFE wrote:
adam_smasher wrote:
If something changes every time, then it relies on uninitialized data i.e. you're not initializing something you need to.


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.

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


Attachments:
Capture.PNG
Capture.PNG [ 68.62 KiB | Viewed 1351 times ]
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: AWJ, Google Adsense [Bot] and 5 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