News:

Don't forget to visit the main site! There's lots of helpful docs, patches, and more!

Main Menu

[SM] Usage of RAM $7E:4200..4218

Started by JAM, November 05, 2010, 09:26:40 PM

Previous topic - Next topic

JAM

Can anyone explain this? I saw these addresses in code multiple times but I don't understand what are stored there

Scyzer

2000+ are hardware registers. They aren't viewable in the RAM or rom, but are used for stuff within the snes emulation itself. They take care of whether the game is displaying mode0 or mode7, how many palettes are used, color math for FX, multiplying and dividing values, etc. It's not really something to worry about.

DSO

On the contrary, knowing about the registers and how to use them comes in handy very much when you're trying to figure out what certain routines are doing or when you wanna create your own cool special effects such as what Jathys did for Eris' Phantoon.

This doc explains about SNES registers and how they're used.

JAM

Sadiztyk Fish
But the mentioned addresses (4202..4218) are used in many cases, such as counting reserve tank amount in the menu, via door transfer to change liquid level, when operating with scrolls etc. It's hard to say how this works if you don't know the usage of 4202..4218.

DSO
Thanks, it's helped a lot

Scyzer

well, 4202+ are used in math operations (division, multiplication, etc). It can be used to calculate decimal values out of hexidecimal, set up the ending percentages, a ton of stuff really =)
Pretty much you just store 2 values to the hardware registers at 420X and 420Y (depending what operation you want to do), then read the value from 421Z (dependant on the operation) after 7 or 8 cycles

JAM

Ah, that's why there are a lot of NOP's in the code around RAM 4202..4218. I thought there was replacement of unneeded code but now it make sence.

Scyzer

Yep, NOP is mostly used in SM as a cycle waster for stuff like that. 2 cycles for a single byte is efficient for it's purpose.

JAM

#7
I saw slightly different code for wasting cycles in bank $80:

PHA
PLA
PHA
PLA


Same 14 cycles in result (PHA takes 3 while PLA takes 4), but this code uses less space