Monday, November 9, 2009

Sprite Field Coordinates

Since the Super Nintendo's OAM (object attribute memory) uses a 9-bit x and an 8-bit y screen coordinate, and the screen is 256x224 pixels big, you may think 16-bit field coordinates is the best approach since the top 8 bits will be what screen, and the bottom 8 bits will be what pixel of the screen, but there is a catch. You'd only be able to increment using whole numbers like 1 and 2 pixels per frame. If you need something inbetween like 1.5 pixels per frame you need decimal bits. If you do 16-bit whole numbers and 16-bit decimals such as this:

ssssssssttttpppp dddddddddddddddd
s: screen
t: tile
p: pixel
d: decimal

it will require 32-bit math which the 65816 isn't very good at. Thankfully there is a better way of doing this:

ssssttttppppdddd
s: screen
t: tile
p: pixel
d: decimal

This is not just optimistic because it uses 16-bit math which the 65816 IS good at. It also makes sprite-tile collision way easier. All you need to do is combine both top bytes of both x and y coordinates to calculate the correct tile number the sprite is overlapping.

Sunday, November 1, 2009

Why your Super Nintendo codes don't work sometimes

Beleive it or not you could be the best Super Nintendo programmer in history and not even know it. What makes a good Super Nintendo programmer is the ability to come up with ways around limitations. The only issue is there is bad documentation on issues such as interrupts and stacks which seem unimportant but can really glitch up your code if you don't set them up the correct way.

For the last few months I've been working on a MegaMan-like action game, but I've ran into a problem early on that took me a long time to fix. I was trying to program the AI/physics of the player sprite, but everything I did glitched out. I asked other people to tell me what I'm doing wrong, they asked me for my source code and I gave it to them. This was 3 weeks ago and they still never answered me. I've got it to work correctly before they were even able to answer me.

To solve the problem I had to keep tinkering with the interrupts and stack until I finally got it right. I doubt the people who are taking me so long to answer this problem actually know themselves, simply because you can search all you want but there isn't any good documents that deal with interrupts and stack enough for anyone to completely understand it.

Wednesday, September 9, 2009

Rotating 2 Backgrounds at One Time

Most people don't know this but you can actually rotate 2 backgrounds at one time on the Snes. How? It's really simple. There is a Mode named Mode-2; it has 2 backgrounds with 16 colors per tile. However instead of all the tiles being scrolled together, each vertical column is scrolled seperately. The offsets of the tiles for bg1 are stored in the bg3 tile map, on the 2nd row of tiles with a byte value of #$20 stored inbetween each offset. (I don't know why it is this way)

If offset the first collumn by zero; second by one, third by two, etc, the screen looks screw like a parallelegram. Then you can use the H-DMA to controll the horizontal bg scroll and decrement it every 8 lines, and it appears as if the screen was rotated 30 degrees. Then you can do it with every other tile instead, and decrement the horizontal bg scroll every 16 lines instead. Now it looks like it was scrolled 15 degrees.

I have a demo to show you, but I don't think this website has anyway of uploading it.

Tuesday, September 8, 2009

Who am I and what are my goals?

I am a Super Nintendo homebrew developer as you can clearly see, but unlike other homebrewers my goals are much much bigger. Other homebrewers' goals are to try to emulate what the best programmers did back in the day, my goal is to surpass them. You simply can't get any progress done trying to emulate what others already did, especially stuff they did long long ago. You need to do things that people never did before, or else there is no fun in homebrewing at all. You may think the Super Nintendo homebrew development scene is great and making progress, I beg to differ. I beleive that it will never get passed it's infancy until people start trying to do new things. You never know what you can do unless you try, so never assume something can't be done before you even tried to do it in the first place.