About The Mode 7 Registers...

Strictly for discussing ZSNES development and for submitting code. You can also join us on IRC at irc.libera.chat in #zsnes.
Please, no requests here.

Moderator: ZSNES Mods

Post Reply
undisbeliever
Rookie
Posts: 35
Joined: Sat Aug 21, 2004 2:31 am
Location: is an eight lettered word

About The Mode 7 Registers...

Post by undisbeliever »

I am currentally wondering about some more detailed information about the mode 7 registers. Teh only information I can find is on y0shi's document.
| w |$211B |COS (COSINE) rotate angle / X Expansion [M7A] |
| w |$211C |SIN (SIN) rotate angle / X Expansion [M7B] |
| w |$211D |SIN (SIN) rotate angle / Y Expansion [M7C] |
| w |$211E |COS (COSINE) rotate angle / Y Expansion [M7D] |
| wd |$211F |Center position X (13-bit data only) [M7X] |
| wd |$2120 |Center position Y (13-bit data only) [M7Y] |
| | | |
| | |MODE 7 formulae for rotation/enlargement/reduction: |
| | | |
| | |X2 = AB * X1-X0 + X0 |
| | |Y2 = CD * Y1-Y0 + Y0 |
| | | |
| | |A = COS(GAMMA)*(1/ALPHA) B = SIN(GAMMA)*(1/ALPHA) |
| | |C = SIN(GAMMA)*(1/BETA) D = COS(GAMMA)*(1/BETA) |
| | | |
| | | GAMMA: Rotation angle. |
| | | ALPHA: Reduction rates for X (horizontal). |
| | | BETA: Reduction rates for Y (vertical). |
| | |X0 & Y0: Center coordinate. |
| | |X1 & Y1: Display coordinate. |
| | |X2 & Y2: Coordinate before calculation. |
Th eonly decent demo (with source) that uses mode 7 rotation is the tricks dassembler demo (but that is confusing)

Since the ZSNES crew have sorted this out and have MODE7 working in their emulator I'm going to ask a few questions:

1) what type of data is stored in the registers. IE is the answer multiplied by 128 or somethign (cause it can't be a decimal)
2) how large/small can ALPHA/BETA become
3) any other information I sould know about mode7 before attempting to program with it.


/offtopic
This mode7 code is for the credits in the game (When EVERYTHING else is programmed). I just hope to get this information so that can look awesome when it's done.
/offtipic
byuu

Post by byuu »

1) what type of data is stored in the registers. IE is the answer multiplied by 128 or somethign (cause it can't be a decimal)
Yes it can. The low byte is the decimal, the high byte is the whole number.
Think about it like this: A=low byte, B=high byte, R=result
R = (B) + (A / 256)
So 1.5 would be 0x0180, or (1) + (128 / 256), or 1 + 0.5

Here is an implementation of mode7 in c, part of the code is from snes9x:
http://setsuna.the2d.com/files/mode7.cpp
Here is a demo program that uses that implementation.
http://setsuna.the2d.com/files/mode7c.zip

You can play with the latter to figure out how the registers work and affect the display. Be sure to read the controls.txt file before using it.
Post Reply