We've just updated MediaWiki and its underlying software. If anything doesn't look or work quite right, please mention it to us. --RanAS

F-Zero RAM Map: Difference between revisions

From SnesLab
Jump to: navigation, search
(Created page with "Here is a RAM Map for F-Zero that aims to be fairly comprehensible. ===== Data Types ===== {| class="wikitable" |- ! Name !! Accepted Values !! Description |- | Angle16 || 0x...")
 
m (Add Table of Contents and Data Type sizes)
Line 1: Line 1:
Here is a RAM Map for F-Zero that aims to be fairly comprehensible.
Here is a RAM Map for F-Zero that aims to be fairly comprehensible.
__TOC__


===== Data Types =====
===== Data Types =====
{| class="wikitable"
{| class="wikitable"
|-
|-
! Name !! Accepted Values !! Description
! Name !! Accepted Values !! Size !! Description
|-
|-
| Angle16 || 0x0000 - 0xBFFF || An angle with extra fractional precision.<br>
| Angle16 || 0x0000 - 0xBFFF || 16-bit || An angle with extra fractional precision.<br>
0x0000 = 0 degrees<br>
0x0000 = 0 degrees<br>
0xBFFF ≃ 359.992675781 degrees<br>
0xBFFF ≃ 359.992675781 degrees<br>
Line 12: Line 14:
(Each unit increments the real angle value by about  0.00732421875 degrees)
(Each unit increments the real angle value by about  0.00732421875 degrees)
|-
|-
| Angle8 || 0x00 - 0xBF || An angle without the fractional precision.<br>
| Angle8 || 0x00 - 0xBF || 8-bit || An angle without the fractional precision.<br>
0x00 = 0 degrees<br>
0x00 = 0 degrees<br>
0xBF ≃ 358.125 degrees<br>
0xBF ≃ 358.125 degrees<br>
(Each unit increments the real angle value by about 1.875 degrees)
(Each unit increments the real angle value by about 1.875 degrees)
|-
|-
| CoordX || 0x0000 - 0x1FFF || X coordinate value.
| CoordX || 0x0000 - 0x1FFF || 16-bit || X coordinate value.
|-
|-
| CoordY || 0x0000 - 0x0FFF || Y coordinate value.
| CoordY || 0x0000 - 0x0FFF || 16-bit || Y coordinate value.
|}
|}
<br>
<br>

Revision as of 01:51, 9 July 2019

Here is a RAM Map for F-Zero that aims to be fairly comprehensible.

Data Types
Name Accepted Values Size Description
Angle16 0x0000 - 0xBFFF 16-bit An angle with extra fractional precision.

0x0000 = 0 degrees
0xBFFF ≃ 359.992675781 degrees
Only the high byte affects the gameplay, the low byte is there just for fractional precision.
(Each unit increments the real angle value by about 0.00732421875 degrees)

Angle8 0x00 - 0xBF 8-bit An angle without the fractional precision.

0x00 = 0 degrees
0xBF ≃ 358.125 degrees
(Each unit increments the real angle value by about 1.875 degrees)

CoordX 0x0000 - 0x1FFF 16-bit X coordinate value.
CoordY 0x0000 - 0x0FFF 16-bit Y coordinate value.


Zero Page (Direct Page)

The Direct Page register (DP) is fixed to #$0000 all the time.

Address Length Type Description
$7E0000 ?? bytes Misc. Scratchpad RAM. Used for various purposes, including: temporary storage, subroutine parameters, etc.
$7E0034 1 byte Sprites Used in the AI car graphics routine.

How many sprite tiles were needed to draw the AI car.
Stored to $7E11D0 when the graphics routine ends.

$7E003E 2 bytes Misc. Relevant value picked from the table at 7E:1076.
$7E0040 1 byte Flag "Frame done" flag. Set to zero at the start of the main loop.

When NMI happens, it's decremented to #$FF, unless the value was already non-zero (i.e. a lag frame occurred.)
This is used to make sure the gamestate runs once per frame.

$7E0041 2 bytes Pointer IRQ code pointer.

$8612 - Do nothing;
$8616 (V-Counter = 18) - Set transparent power bar color, then trigger next IRQ at V-Counter = 28, set IRQ code pointer $863C;
$863C (V-Counter = 28) - Set "horizon fog" color math settings, then trigger next IRQ at V-Counter = 47, set IRQ code pointer $865A;
$865A (V-Counter = 47) - Set BG mode to 7, then trigger next IRQ at V-Counter = 86, set IRQ code pointer $8673;
$8673 (V-Counter = 86) - Set player's shadow/finished rank color, then set the IRQ code pointer to $8612;
$8691 (V-Counter = $7E0043) - Set BG mode to 7, then set the IRQ code pointer to $8612.

$7E0043 2 bytes IRQ Scanline where the Mode7 BG starts. Used only for IRQ pointer $8691, on the race intro sequence.
$7E0045 1 byte Flag When the MSB is set, sound effects won't play. This is used to keep playing the "player wreckage" sounds when $7E0048 >= #$80.
$7E0046 4 bytes I/O SPC700 I/O ports. Various values can be written to play music or sound effects.
$7E004A 1 byte Misc. Number of cars currently on screen, multiplied by two. (A bit of a mystery still, but seems to be used in a loop that assigns sprite properties based on their Y position)
$7E004B 2 bytes Sprites Index to OAM Table #1 ($7E0200) for routines that print characters/strings on screen.
$7E004D 1 byte Sprites Index to OAM Table #2 ($7E0420) for routines that print characters/strings on screen.
$7E004E 1 byte Sprites Used for bit-fiddling on OAM Table #2. Used in conjunction with $7E004D.
$7E004F 1 byte Hardware mirror Mirror of SNES register $2101.
$7E0050 1 byte Flag "Is the game drawing cars" flag. Non-zero = Yes.

This is used to correctly handle OAM DMA.

$7E0051 1 byte Counter Frame counter. Always increments every frame (except lag frames), no matter what.

See also: $7E009A ("in-race" frame counter)

$7E0052 1 byte Misc. Player car type.

#$00 = Blue Falcon; #$01 = Wild Goose; #$02 = Golden Fox; #$03 = Fire Stingray.

$7E0053 1 byte Misc. Current race number.

From #$00 to #$04 in Grand Prix mode.
From #$00 to #$06 in Practice mode.

$7E0054 3 bytes Misc. Current gamestate (game mode).

The first byte is the "main" gamestate, the second byte is the "sub" gamestate and the third byte is the "sub-sub" gamestate.
This gamestate stuff is a complicated subject, which I plan to explain in more detail later.

$7E0057 1 byte Misc. Current difficulty setting.

#$00 = Beginner; #$01 = Standard; #$02 = Expert/Master (for Master, the flag at $7E0F3D is set)

$7E0058 1 byte Misc. Practice mode flag.

#$00 = Grand Prix mode; #$01 = Practice Mode

$7E0059 1 byte Misc. Number of spare machines (extra lives).
$7E005A 1 byte Misc. Used by most menus as current selected option.
$7E005B 1 byte Misc. "Is running pre-recorded race" flag.

#$00 = Player is in control; Other = Pre-recorded race is running.

$7E005C 1 byte Flag A flag related to color math effects.

When == #$00:

  • HDMA channels 1 and 3 are disabled;
  • $7E009B is stored to $2131;
  • $7E0E27 is treated as the red color intensity for color math and it should range from #$00 to #$1F. ($7E0E27 | #$20) is stored to $2132;
  • 7E:0E28 is treated as the green color intensity for color math and it should range from #$00 to #$1F. ($7E0E28 | #$40) is stored to $2132;
  • 7E:0E29 is treated as the blue color intensity for color math and it should range from #$00 to #$1F. ($7E0E29 | #$80) is stored to $2132;
  • IRQ is disabled.

When == #$01:

  • HDMA channels 1 and 3 are enabled. Channel 1 is used for Mode7 and BG1 horizon, channel 3 is used for the "horizon fog";
  • $212C is set to (#$13 ^ $7E005F);
  • $7E0E25 is stored to $2131;
  • $2132 is set to #$E0;
  • IRQ is enabled to trigger at V-Counter = 18, IRQ code pointer is set to $8616.

When > #$01:

  • HDMA channel 1 is enabled. Channel 1 is used for Mode7 and BG1 horizon;
  • HDMA channel 3 is disabled;
  • $212C is set to #$13;
  • IRQ is enabled to trigger at V-Counter = $7E0043, IRQ code pointer is set to $8691.
$7E005D 1 byte Hardware mirror Screen brightness and F-Blank flag. Mirror of SNES register $2100
$7E005E 1 byte Hardware mirror Enabled HDMA channels. Mirror of SNES register $420C
$7E005F 1 byte Flag Flags related to shown layers and HUD updating. Format: u--s4321

1 = Hide BG1; 2 = Hide BG2; 3 = Show BG3; 4 = Hide BG4 (unused, F-Zero never uses BG4); s = Hide sprites; - = Unused bit u = Stop updating HUD (rank, timer, score and speedometer)

$7E0060 1 byte Misc. Screen fade type.

#$00 = Not fading; #$01 = Fade-in; Other = Fade-out.

$7E0061 1 byte Misc. Screen fade delay. How many frames it takes to increment/decrement the screen brightness.
$7E0062 1 byte Misc. Screen fade timer. How many frames until the screen brightness is incremented/decremented.
$7E0063 1 byte I/O Controller 1 data (held buttons). Format: axlr----

a = A; x = X; l = L; r = R; - = Unused bits

$7E0064 1 byte I/O Controller 1 data (held buttons). Format: byetUDLR

b = B; y = Y; e = Select; t = Start; U = Up; D = Down; L = Left; R = Right.

$7E0065 1 byte I/O (Seems to be the exact same as $7E0063?) Used more often than $7E0063
$7E0066 1 byte I/O (Seems to be the exact same as $7E0064?) Used more often than $7E0064
$7E0067 1 byte I/O Controller 1 data (pressed buttons on current frame). Format: axlr----

a = A; x = X; l = L; r = R; - = Unused bits

$7E0068 1 byte I/O Controller 1 data (pressed buttons on current frame). Format: byetUDLR

b = B; y = Y; e = Select; t = Start; U = Up; D = Down; L = Left; R = Right.

$7E0069 1 byte I/O Controller 1 data (released buttons on current frame). Format: axlr----

a = A; x = X; l = L; r = R; - = Unused bits

$7E006A 1 byte I/O Controller 1 data (released buttons on current frame). Format: byetUDLR

b = B; y = Y; e = Select; t = Start; U = Up; D = Down; L = Left; R = Right.

$7E006B 1 byte Flag A flag related to windowing effects.

When == #$00:

  • $212E and $212F are set to #$00;
  • $7E0070 is stored to $2130;
  • HDMA channel 2 is disabled.

When == #$01:

  • HDMA channel 2 is enabled. Channel 2 is used for windowing effects, such as player's shadow and the big rank number when finishing a race;
  • $7E006C is stored to $4322 (16-bit, HDMA channel 2 table address);
  • $7E0E20 is stored to $7E0DE3;
  • $7E006E is stored to $212E;
  • $7E006F is stored to $212F;
  • $7E0070 is stored to $2130;
  • $7E0071 is stored to $2123;
  • $7E0072 is stored to $2124;
  • $7E0073 is stored to $2125.

When > #$01:

  • $7E006E is stored to $212E;
  • $7E006F is stored to $212F;
  • $7E0070 is stored to $2130;
  • $7E0071 is stored to $2123;
  • $7E0072 is stored to $2124;
  • $7E0073 is stored to $2125.
$7E006C 2 bytes Pointer Pointer to data for windowing effects (HDMA channel 2). Points to $7E0DD0 while racing, and to $7E0DF0 while showing the big rank number after finishing a race.
$7E006E 1 byte Hardware mirror Mirror of SNES register $212E.
$7E006F 1 byte Hardware mirror Mirror of SNES register $212F.
$7E0070 1 byte Hardware mirror Mirror of SNES register $2130.
$7E0071 1 byte Hardware mirror Mirror of SNES register $2123.
$7E0072 1 byte Hardware mirror Mirror of SNES register $2124.
$7E0073 1 byte Hardware mirror Mirror of SNES register $2125.
$7E0074 1 byte Misc. Index to $7E0EA0. Alternates between #$00 and #$10 every frame, to compensate for slowdowns (if it didn't alternate, the Mode7 layer would look jiterry when updating while the game was lagging).
$7E0075 2 bytes Hardware mirror BG1 horizontal scroll. Mirror of SNES register $210D.
$7E0077 2 bytes Hardware mirror BG1 vertical scroll. Mirror of SNES register $210E.
$7E0079 2 bytes Hardware mirror BG2 horizontal scroll. Mirror of SNES register $210F.
$7E007B 2 bytes Hardware mirror BG2 vertical scroll. Mirror of SNES register $2110.
$7E007D 2 bytes Hardware mirror Mode7 X center. Mirror of SNES register $211F.
$7E007F 2 bytes Hardware mirror Mode7 Y center. Mirror of SNES register $2120.
$7E0081 1 byte Misc. Mode7 rendering type.

#$00 = No Mode7; #$01 = Perspective effect; Other = Top-down view.

$7E0082 1 byte Misc. This value + #$80 is written to $4342 and $4372. Similarly, this value + #$A0 is written to $4352 and $4362. This updates the Mode 7 rotation through HDMA.

Similar to $7E0074, this address also alternates between #$00 and #$10 every frame to compensate for slowdowns.
Only used if $7E0081 == #$01.

$7E0083 1 byte Misc. Used after the "track zoom-in" on the race intro. This value is incremented every frame to raise the viewpoint pitch angle. When it reaches #$10, it stops increasing and the cars appear.
$7E0084 1 byte Hardware mirror Written to $4347. Only used if 7E:0081 == #$01.
$7E0085 1 byte Hardware mirror Written to $4357. Only used if 7E:0081 == #$01.
$7E0086 1 byte Hardware mirror Written to $4367. Only used if 7E:0081 == #$01.
$7E0087 1 byte Hardware mirror Written to $4377. Only used if 7E:0081 == #$01.
$7E0088 2 bytes Hardware mirror Mode7 matrix A and D. Mirror of SNES registers $211B and $211E
$7E008A 2 bytes Hardware mirror Mode7 matrix B. Mirror of SNES register $211C
$7E008C 2 bytes Hardware mirror Mode7 matrix C. Mirror of SNES register $211D
$7E008E 2 bytes Misc. Mode7 scaling. The Mode7 layer shrinks as this value increases. Only used if $7E0081 > #$01 (top-down view)
$7E0090 1 byte Misc. Current league.

#$00 = Knight League; #$01 = Queen League; #$02 = King League.

$7E0091 1 byte Empty Empty. Cleared on reset

This is still a work-in-progress! More will be added later.