NES Screen coordinates for Sprites
Moderator: Moderators
NES Screen coordinates for Sprites
Hello,
I've been looking around on this board for quite a while now, but I didn't really write anything yet.
Well, to get started:
I'm working on a small game similar to Arkanoid or Breakout that will include some puzzle elements.
It is actually in a VERY early stage of development and there is not much to show yet...
But for my question there is probably no real need for that anyways.
I was looking for a table with some information about the screen positions of sprites.
I know that $FE and $FF are off-screen and how to get sprites in the middle, but sometimes I want to do more complicated positions and I end up trying to guess where to put them and then moving them in little steps and looking at the results in an emulator until they're in the right position.
Well, it's a huge waste of time...
Maybe it's just me and I don't see yet how the positions are actually arranged and why $FE and $FF are off-screen.
So, I was looking for a table or graph for the screen positions, maybe with some explanations on it, but I couldn't find anything on the wiki or here on the board and Google wasn't that helpful either.(Maybe, I didn't have the right search words...I'm really not sure how one would describe such a graph in English. I'm German btw. It says Canada on my profile, because right now I'm living here as an international student)
To get back to my problem and (finally) to my question:
Is there such a graph somewhere out there and if there is, where can I find it?
Thanks,
Grums
I've been looking around on this board for quite a while now, but I didn't really write anything yet.
Well, to get started:
I'm working on a small game similar to Arkanoid or Breakout that will include some puzzle elements.
It is actually in a VERY early stage of development and there is not much to show yet...
But for my question there is probably no real need for that anyways.
I was looking for a table with some information about the screen positions of sprites.
I know that $FE and $FF are off-screen and how to get sprites in the middle, but sometimes I want to do more complicated positions and I end up trying to guess where to put them and then moving them in little steps and looking at the results in an emulator until they're in the right position.
Well, it's a huge waste of time...
Maybe it's just me and I don't see yet how the positions are actually arranged and why $FE and $FF are off-screen.
So, I was looking for a table or graph for the screen positions, maybe with some explanations on it, but I couldn't find anything on the wiki or here on the board and Google wasn't that helpful either.(Maybe, I didn't have the right search words...I'm really not sure how one would describe such a graph in English. I'm German btw. It says Canada on my profile, because right now I'm living here as an international student)
To get back to my problem and (finally) to my question:
Is there such a graph somewhere out there and if there is, where can I find it?
Thanks,
Grums
- cpow
- NESICIDE developer
- Posts: 1097
- Joined: Mon Oct 13, 2008 7:55 pm
- Location: Minneapolis, MN
- Contact:
Re: NES Screen coordinates for Sprites
People on this board love seeing early-stage stuff, regardless.Grumskiz wrote: But for my question there is probably no real need for that anyways.
Regarding the sprite position...
For horizontal, there's 256 pixels, and the sprite-width is 8 pixels, so to put a sprite at dead-center I would think:
(256*(1/2))-(8/2) or 124 decimal would do the trick. The 8/2 factor is just to get to the middle of the sprite, the other factor is to get to the middle of the screen. To get to half-way-to-center-from-left:
(256*(1/4))-(8/2) or 60.
To get to half-way-to-right-from-center:
(256*(3/4))-(8/2) or 188.
Hopefully you sense a pattern.
Vertically it's similar except there's only 240 pixels to work with. F0-FF is "offscreen", not just FE and FF as you state. However, vertically there's another factor that is the sprite height, which is either 8 or 16 pixels.
To get to half-way down for an 8x8 sprite:
(240*(1/2))-(8/2) or 116.
To get to half-way down for an 8x16 sprite:
(240*(1/2))-(16/2) or 112.
Hopefully here too you sense a pattern.
To get to 5/7ths of the way across by 2/3rds of the way down for 8x8 sprite:
across: (256*(5/7))-(8/2) or "roughly" 179.
down: (240*(2/3))-(8/2) or 156.
That's just what I'd do...but experimentation with an emulator, while tedious, is probably going to have to happen anyway.
Re: NES Screen coordinates for Sprites
I'm sure, they do :3cpow wrote: People on this board love seeing early-stage stuff, regardless.
There really just isn't much to see yet...
That makes sense to me, compared to the screen size that the NES produces.cpow wrote: For horizontal, there's 256 pixels, and the sprite-width is 8 pixels,(...)
Vertically it's similar except there's only 240 pixels to work with. F0-FF is "offscreen", not just FE and FF as you state.
Yes, I do see the pattern now! Thanks a lot for this formula.cpow wrote: (256*(1/2))-(8/2) or 124 decimal would do the trick. The 8/2 factor is just to get to the middle of the sprite, the other factor is to get to the middle of the screen. To get to half-way-to-center-from-left:
(256*(1/4))-(8/2) or 60.
To get to half-way-to-right-from-center:
(256*(3/4))-(8/2) or 188.
Hopefully you sense a pattern.
I just got confused by using Hex for programming all the time, while I always thought of the screen size in decimal numbers.(256x240 instead of $FF x $F0)
Now it is all clearer to me.
The latter would be the case if I used 8x16 Sprites, right?cpow wrote: However, vertically there's another factor that is the sprite height, which is either 8 or 16 pixels.
Again now it's a lot clearer to me here.
Thanks for the fast answer and the good explanation!
Oh no, you got me wrong there ^^'Dwedit wrote:If you don't like hex, then don't use it.
It was just about the screen resolution.
I'm used to have screen resolutions in a form somewhat like this: 1280x720
Notice the decimal numbers and the "x" instead of an "*".
That's the form I've seen since...well...as far as I can remember ^^'
I just never thought of converting that to Hex, because I'm used to see screen resolutions given in that form for forever, but as soon as I did convert it, it all made a lot more sense to me.
I'm used to using Hex for a while now. I learned it back when I made (crappy) SMW ROM hacks. I don't have a problem with it ;3
I think the proper way, or one of them, to put sprites off-screen is to set the Y value to $F0. Alternatively you could just write $F0 to all of Sprite RAM. Atleast I seem to recall alot of games doing this. I guess that $F0 and up would all hide it. You don't want to put them horizontally off screen and not also vertically since the sprites would still count torward the 8 sprite scanline limit.
His point is, you don't NEED to convert that to hex, not that you should stop NES programming, if that's the impression you got.Grumskiz wrote: I just never thought of converting that to Hex, because I'm used to see screen resolutions given in that form for forever, but as soon as I did convert it, it all made a lot more sense to me.
lda #255 is valid in most 6502 assemblers.
lda #$FF
and
lda #255 are equivalent.
lda #%11111111 for binary. They all become exactly the same thing. $7E is not a different number than 126.
I use binary for the bitwise operators, hex for most other things, and the straight number for speed values. You can use whichever one is easiest for you at any given time.
lda #241 is vertically off screen, because the screen resolution is only 240. No conversion necessary.
I realize you now know why those hex values are off screen, but hopefully this post taught you something else.
I'm aware of that and I know I can use decimal numbers for 6502 Assembly, because, as you said, they can all represent the same numbers.Kasumi wrote:His point is, you don't NEED to convert that to hex, not that you should stop NES programming, if that's the impression you got.Grumskiz wrote: I just never thought of converting that to Hex, because I'm used to see screen resolutions given in that form for forever, but as soon as I did convert it, it all made a lot more sense to me.
lda #255 is valid in most 6502 assemblers.
lda #$FF
and
lda #255 are equivalent.
lda #%11111111 for binary. They all become exactly the same thing. $7E is not a different number than 126.
I use binary for the bitwise operators, hex for most other things, and the straight number for speed values. You can use whichever one is easiest for you at any given time.
lda #241 is vertically off screen, because the screen resolution is only 240. No conversion necessary.
I realize you now know why those hex values are off screen, but hopefully this post taught you something else.
I think it's just a little misunderstanding going on.
I already use hex, binary and decimal numbers together in a way that is similar to yours! I also find Binary a lot clearer for bitwise operators than anything else. For most other things I use Hex, sometimes also decimal numbers that I usually convert to Hex at some point. I find it easier to see a connection between the program I write and the ROM that I run in FCEUX while I'm looking at the HEX Editor(to see the RAM Addresses while the game is running), if I use Hex. That way, for me, I it's easier to recognize and find things.
I think I wasn't really clear before...
I just didn't know that sprites are off screen on vertical positions bigger than 240 or $F0.
I thought it's only $FE and $FF, because that's what I read in the Nerdy Nights tutorials, I think.
I just never saw the connection between these two numbers and the screen resolution of which I thought it was absolutly independent from the Sprite positions. I saw it as something that is only based on the size of the nametables.
Some nitpicking: 239 ($EF) is also off screen, because the sprites are shifted down one scanline (that is, a sprite with y coord 0 will appear starting from the 2nd scanline).Grumskiz wrote:I just didn't know that sprites are off screen on vertical positions bigger than 240 or $F0.
I thought it's only $FE and $FF, because that's what I read in the Nerdy Nights tutorials, I think.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi