Difference between revisions of "Metaroom Quadrants"

From TLoZ: ALTTP Hacking Resources
Jump to: navigation, search
 
Line 1: Line 1:
 
''See also: [[Standard Notation]]''
 
''See also: [[Standard Notation]]''
  
''See also: [[Metaroom]]''
+
''See also: [[Metarooms]]''
  
 
The game keeps track of which quadrants of which metarooms the player has visited, primarily for the purpose of illuminating visited rooms in dungeon maps. The game maintains several variables in memory pertaining to the current interior room, and uses these to update the working save file when the player enters and exits new interiors.
 
The game keeps track of which quadrants of which metarooms the player has visited, primarily for the purpose of illuminating visited rooms in dungeon maps. The game maintains several variables in memory pertaining to the current interior room, and uses these to update the working save file when the player enters and exits new interiors.
Line 25: Line 25:
 
  <nowiki>( H << 2 ) | ( W << 1 ) | Y | X</nowiki>
 
  <nowiki>( H << 2 ) | ( W << 1 ) | Y | X</nowiki>
  
So, within this new value, bit 0 indicates whether the player is on the left or right half of the metaroom, bit 1 indicates whether the player is on the top or bottom half of the metaroom, bit 2 indicates whether or not the room is wide, and bit 3 indicates whether or not the room is tall. (Note: The values of X and Y can be inaccurate when inside non-dungeon rooms, such as houses in Kakariko Village.)
+
So, within this new value, bit 0 indicates whether the player is on the left or right half of the metaroom, bit 1 indicates whether the player is on the top or bottom half of the metaroom, bit 2 indicates whether or not the room is wide, and bit 3 indicates whether or not the room is tall.
  
 
This value is then used as an index into a lookup table to retrieve a new 4-bit value which has bits set representing which quadrants of the metaroom have been visited by entering the room. The table's values are configured such that bit 0 indicates the bottom-right quadrant, bit 1 indicates the bottom-left quadrant, bit 2 indicates the top-right quadrant, and bit 3 indicates the top-left quadrant.
 
This value is then used as an index into a lookup table to retrieve a new 4-bit value which has bits set representing which quadrants of the metaroom have been visited by entering the room. The table's values are configured such that bit 0 indicates the bottom-right quadrant, bit 1 indicates the bottom-left quadrant, bit 2 indicates the top-right quadrant, and bit 3 indicates the top-left quadrant.
 +
 +
== Non-Dungeon Rooms ==
 +
 +
''See also: [[Player Position]]''
 +
 +
Note: The values of X and Y do not always reflect the actual portion of the metaroom the player is on when inside non-dungeon rooms, such as houses in Kakariko Village, because the game does not provide maps for these interiors and so does not worry about tracking them accurately. The player's X and Y pixel coordinates can be used instead to identify the currently-occupied quadrant. Let (Xp,Yp) be the player's pixel coordinates, N be the current interior metaroom's index, and (Qx,Qy) be the quadrant coordinates with (0,0) being the top-left corner and (1,1) being the bottom-right corner.
 +
 +
<nowiki>Qx = ( Xp - ( N % 16 ) * 512 ) / 256
 +
Qy = ( Yp - ( N / 16 ) * 512 ) / 256</nowiki>
  
 
== Table Values ==
 
== Table Values ==

Latest revision as of 12:51, 14 November 2016

See also: Standard Notation

See also: Metarooms

The game keeps track of which quadrants of which metarooms the player has visited, primarily for the purpose of illuminating visited rooms in dungeon maps. The game maintains several variables in memory pertaining to the current interior room, and uses these to update the working save file when the player enters and exits new interiors.

$7E00A6[$1]
0 if the room has normal width (half of a metaroom)
2 if the room is wide (the full width of a metaroom)
$7E00A7[$1]
0 if the room has normal height (half of a metaroom)
2 if the room is tall (the full height of a metaroom)
$7E00A9[$1]
0 if the player is in the left half of the metaroom
1 if the player is in the right half of the metaroom
$7E00AA[$1]
0 if the player is in the top half of the metaroom
2 if the player is in the bottom half of the metaroom

Let us label these four values W , H , X , and Y. When updating the working save file, the game combines the four values into a single 4-bit value as follows.

( H << 2 ) | ( W << 1 ) | Y | X

So, within this new value, bit 0 indicates whether the player is on the left or right half of the metaroom, bit 1 indicates whether the player is on the top or bottom half of the metaroom, bit 2 indicates whether or not the room is wide, and bit 3 indicates whether or not the room is tall.

This value is then used as an index into a lookup table to retrieve a new 4-bit value which has bits set representing which quadrants of the metaroom have been visited by entering the room. The table's values are configured such that bit 0 indicates the bottom-right quadrant, bit 1 indicates the bottom-left quadrant, bit 2 indicates the top-right quadrant, and bit 3 indicates the top-left quadrant.

Non-Dungeon Rooms

See also: Player Position

Note: The values of X and Y do not always reflect the actual portion of the metaroom the player is on when inside non-dungeon rooms, such as houses in Kakariko Village, because the game does not provide maps for these interiors and so does not worry about tracking them accurately. The player's X and Y pixel coordinates can be used instead to identify the currently-occupied quadrant. Let (Xp,Yp) be the player's pixel coordinates, N be the current interior metaroom's index, and (Qx,Qy) be the quadrant coordinates with (0,0) being the top-left corner and (1,1) being the bottom-right corner.

Qx = ( Xp - ( N % 16 ) * 512 ) / 256
Qy = ( Yp - ( N / 16 ) * 512 ) / 256

Table Values

Index Value
$00 $08
$01 $04
$02 $02
$03 $01
$04 $0C
$05 $0C
$06 $03
$07 $03
$08 $0A
$09 $05
$0A $0A
$0B $05
$0C $0F
$0D $0F
$0E $0F
$0F $0F

Table Offsets

(USA)
$135CC[$10]
(J10)
$13504[$10]
(J11)
$13514[$10]
(J12)
$1351B[$10]
(CAN)
$13688[$10]
(FRA)
$135F1[$10]
(EUR) and (GER)
$135D9[$10]