+  RHDN Forum Archive
|-+  Romhacking
| |-+  General Romhacking
| | |-+  SNES ASM Help - Registers $4202 and $4203 (and anything related)
Pages: [1]
Author Topic: SNES ASM Help - Registers $4202 and $4203 (and anything related)  (Read 1 times)
DarknessSavior
Guest
« on: June 22, 2009, 02:26:56 pm »

I'm looking to change a font routine around in a game I've been messing with. There's an 8x8 font routine, which is pretty standard (I copied the routine down, and I understand every instruction with no hitches). But there's also a 16x16 font routine, which is used for just about everything (dialog, menus, maps, items, etc). I want to change the 16x16 font routine to replicate the 8x8 one, thus giving me about quadruple the amount of space for everything (if I hack in a double line hack, which I intend on doing).

However, when I stepped through the 16x16 font routine, it kept loading and storing things to $4202. At first, I checked RAM, but when it didn't show up there, I figured it was a special SNES register, and pulled out Anomie's Register Doc. Frankly, it makes no sense to me. XD

Can someone explain how the above registers work, in somewhat easier to understand English? I can post a snippet from the font routine if necessary, to show exactly what it's doing, but I'd probably be right in assuming this register tends to work in a single way.

Thanks in advance,

~DS
KingMike
Guest
« Reply #1 on: June 22, 2009, 02:42:46 pm »

Isn't $4202 and $4203 the multiplication register?
I hear the real SNES typically needs about 8 cycles to compute the result (as such, games will usually execute a few dummy operations before reading the result from... like $4214? $4216?).
I remember even byuu having trouble figuring out the exact timing.
Disch
Guest
« Reply #2 on: June 22, 2009, 03:07:45 pm »

KingMike is correct.  It's an 8x8->16 multiplier

You write 'A' to $4202, then 'B' to $4203 -- wait a bit, then read the result (A*B) from $4216 (low byte) and $4217 (high byte)

Quote
I remember even byuu having trouble figuring out the exact timing.

I remember hearing that reading before the SNES is ready results in you getting a partial (incomplete) product.  However it might be complete if the multiplication is small enough.

In any event DarknessSavior doesn't need to worry about that.  Just make sure you wait 8 cycles before attempting to read $4216/$4217 -- 3 NOPs oughtta do (yes three NOPs is only 6 cycles, but the cycles in the LDA will bump it up to over 8)

edited to remove smileys
« Last Edit: June 22, 2009, 05:44:32 pm by Disch »
MathOnNapkins
Guest
« Reply #3 on: June 22, 2009, 04:47:40 pm »

Quote from: Disch on June 22, 2009, 03:07:45 pm
(yes three NOPs is only 6 cycles, but the cycles in the LDA will bump it up to over Cool

You crazy, living-on-the-edge rebel.  Shocked
DarknessSavior
Guest
« Reply #4 on: June 23, 2009, 02:43:26 pm »

Hmm. That doesn't sound too terrible. I'll give the code another look when I get home and see if your explanation helped it make sense.

Thanks! ^^;

~DS
Pages: [1]  


Powered by SMF 1.1.4 | SMF © 2006-2007, Simple Machines LLC