Rom/Unmirrored WRAM

From TLoZ: ALTTP Hacking Resources
Jump to: navigation, search

Overworld:

  • $7E2000[0x2000] = Map16 tile data for the overworld. Supports up to 1024x1024 pixels of tiles. Note: this is handled

somewhat differently than the Map8 data in the dungeons which supports up to 512x512. 587Dungeons:

  • $7E2000[0x2000] = when loading dungeon graphics, contains the (map8) tilemap for BG1.
  • $7E4000[0x2000] = when loading dungeon graphics, contains the (map8) tilemap for BG0.

A note about these tilemap representations: These are the tilemaps but not exactly as they would linearly appear in VRAM. These maps are stored as the whole 512x512 pixel screen, line by line. The first $80 bytes contains the top line of the picture as it appears to us. The second $80 bytes represents the second line of the picture as it appears to us, etc. In VRAM, however, the tile indices are stored by quadrant of the screen. Thus, the algorithm to convert the address of a tile in this map to one in VRAM is: int B = tilemap_address; int Y = 0; // Y will be the resulting VRAM offset if(B & 0x1000) // Is this tile in the lower two quadrants? { // YES! Y += 0x1000; B ^= 0x1000; // Tells us to ignore this bit in the proceeding calculations. } if(B & 0x40) // Is this tile in a right hand quadrant? { // YES! Y += 0x800; B ^= 0x040; // The ^ symbol is XOR, in case you didn't know. } Y += (B - ((B & 0xFF80) >> 1)); Keep in mind these aren't real addresses, just offsets into respective arrays in WRAM and VRAM. e.g. X or Y registers would be the offset in WRAM and your DMA controls registers would handle the problem for DMA. WRAM -> VRAM

  • {{$|0

-> $0

  • {{$|40

-> $800

  • {{$|80

-> $40

  • {{$|C0

-> $840

  • {{$|100 -> $80
  • {{$|140 -> $880
  • {{$|180 -> $C0
  • {{$|1C0 -> $8C0
  • {{$|280-$2BF -> $140-$17F

... -> ...

  • {{$|1000 -> $1000
  • {{$|1040 -> $1800
  • {{$|1080 -> $1040
  • ${{{1}}}[{{0x|300] -
  • $7E9300[{{0x|180] -
  • $7E9480[{{0x|1C0] -
  • $7E9640[{{0x|1C0] -
  • $7E9800[{{0x|C0] -
  • $7E98C0[{{0x|100] -
  • $7E99C0[{{0x|100] -
  • $7E9AC0[{{0x|100] -
  • $7E9BC0[{{0x|380] -
  • $7E9F40[{{0x|1C0] -
  • $7EA100[{{0x|80] -
  • $7EA180[{{0x|300] -
  • $7EA480[{{0x|200] -
  • $7EA680[{{0x|400] -
  • $7EAA80[{{0x|400] -
  • $7EAE80[{{0x|400] -
  • $7EB280[{{0x|C0] -
  • $7EB340[{{0x|200] -
  • $7EB540[{{0x|400] -
  • $7EB940[{{0x|400] -
  • $7EBD40[{{0x|80] -
  • $7EBDC0[{{0x|40] -

24 Sword tiles 12 Shield tiles 14 Ice / Fire Rod tiles 14 Hammer tiles 6 Bow tiles 8 Shovel tiles 8 Tiles (Sleep 'Z's, Musical notes, two unknown tiles) 8 Hookshot tiles 28 Bug Net tiles 14 Cane tiles (Byrna and Somaria) 4 Book of Mudora tiles 24 unused tiles (free ram) 16 Push Block tiles Animated BG tiles for step 0 Animated BG tiles for step 1 Animated BG tiles for step 2 Sprite tiles for rupee animation (3 steps) Tiles for the steps that animate the barrier tiles going up and down Sprite tiles for bird and thief's chest Tagalong graphics, room for 8 16x16 sprites (32 8x8 tiles) Sprite tiles for receive item (4 8x8 tiles) Star tiles (part of animated tiles, consists of 2 8x8 tiles)

  • $7EBE00[0x200] = possibly free ram

Values related to Dungeon Headers:

  • $7EC000[{{0x|01]
  • $7EC001[{{0x|01]
  • $7EC002[{{0x|01]
  • $7EC003[{{0x|01]
  • $7EC004[0x{{{1}}}[0x01] = Mosaic "level" in screen transitions transitions.
  • $7EC013[0x02] = Rupee sprite tile animation timer? (countdown)
  • $7EC017[0x01] = ???? Linked to $045A seems to determine fixed color +/-
  • $7EC018[0x01] = free ram
  • $7EC019[0x06] = Array of palette filter settings that get temporarily stored to $7EC007 for Agahnim's sprite.
  • $7EC01F[0x06] = Array of palette filter settings that get temporarily stored to $7EC007 for Agahnim's sprite.
  • $7EC025[0xDB] = free ram
  • $7EC100[0x02] = Mirror of $040A
  • $7EC102[0x02] = Mirror of $1C
  • $7EC104[0x02] = Mirror of $E8
  • $7EC106[0x02] = Mirror of $E2
  • $7EC108[0x02] = Mirror of $20
  • $7EC10A[0x02] = Mirror of $22
  • $7EC10C[0x02] = Mirror of $8A
  • $7EC10E[0x02] = Mirror of $84
  • $7EC110[0x02] = Mirror of $0618
  • $7EC112[0x02] = Mirror of $061C
  • $7EC114[0x02] = Mirror of $0600
  • $7EC116[0x02] = Mirror of $0602
  • $7EC118[0x02] = Mirror of $0604
  • $7EC11A[0x02] = Mirror of $0606
  • $7EC11C[0x02] = Mirror of $0610
  • $7EC11E[0x02] = Mirror of $0612
  • $7EC120[0x02] = Mirror of $0614
  • $7EC122[0x02] = Mirror of $0616
  • $7EC124[{{0x|01]
  • $7EC125[{{0x|01]
  • $7EC126[{{0x|01]
  • $7EC127[0x{{{1}}}[0x01] = Mirror of $1C
  • $7EC143[0x01] = Mirror of $1D
  • $7EC144[0x02] = Mirror of $00E8, BG1 V scroll value
  • $7EC146[0x02] = Mirror of $00E2, BG1 H scroll value
  • $7EC148[0x02] = Mirror of $0020, Link's Y coordinate
  • $7EC14A[0x02] = Mirror of $0022, Link's X coordinate
  • $7EC14C[0x02] = Mirror of $008A, overworld area number
  • $7EC14E[0x02] = Mirror of $0084, ????
  • $7EC150[0x02] = Mirror of $0618, Camera's Y coordinate lower bound
  • $7EC152[0x02] = Mirror of $061C, Camera's X coordinate lower bound
  • $7EC154[0x02] = Mirror of $0600
  • $7EC156[0x02] = Mirror of $0602
  • $7EC158[0x02] = Mirror of $0604
  • $7EC15A[0x02] = Mirror of $0606
  • $7EC15C[0x02] = Mirror of $0610
  • $7EC15E[0x02] = Mirror of $0612
  • $7EC160[0x02] = Mirror of $0614
  • $7EC162[0x02] = Mirror of $0616
  • $7EC164[{{0x|01]
  • $7EC165[{{0x|01]
  • $7EC166[{{0x|01]
  • $7EC167[{{0x|01]
    • Mirror of $0AA0
    • Mirror of $0AA1 (blockset for dungeon entrance)
    • Mirror of $0AA2
    • Mirror of $0AA3
  • $7EC168[0x02] = ???? See pre dungeon mode
  • $7EC16A[0x02] = Mirror of $0624
  • $7EC16C[0x02] = Mirror of $0626
  • $7EC16E[0x02] = Mirror of $0628
  • $7EC170[0x02] = Mirror of $062A
  • $7EC172[0x02] = Orange/blue barrier state
  • $7EC174[0x02] = Mirror of $86
  • $7EC176[0x02] = Mirror of $88
  • $7EC178[0x08] = free ram?
  • $7EC180[{{0x|02]
  • $7EC182[{{0x|02]
  • $7EC184[{{0x|02]
  • $7EC186[0x{{{1}}}[0x02] = Mirror of $0618
  • $7EC19A[0x02] = Mirror of $061C
  • $7EC19C[0x02] = Mirror of $A6
  • $7EC19E[0x02] = Mirror of $A9
  • $7EC1A0[0x06] = free ram?
  • $7EC1A6[0x02] = Mirror of $2F
  • $7EC1A8[0x02] = Mirror of $0476
  • $7EC1AA[0x02] = Mirror of $A4
  • $7EC1AC[0x54] = free ram?
  • $7EC200[{{0x|02]
  • $7EC202[{{0x|02]
  • $7EC204[{{0x|02]
  • $7EC206[{{0x|02]

- Mirror of $E0 - Mirror of $E2 - Mirror of $E6 - Mirror of $E8

  • $7EC208[0x01] = Mirror of $0414
  • $7EC20A[0x01] = Mirror of $0AB6
  • $7EC20B[0x01] = Mirror of $0AB8
  • $7EC20C[0x01] = Mirror of $0AB7
  • $7EC20D[0x01] = free ram?
  • $7EC20E[0x01] = Mirror of $0AA1
  • $7EC20F[0x01] = Mirror of $0AA3
  • $7EC210[0x01] = Mirror of $0AA2
  • $7EC211[0x01] = Mirror of $1C
  • $7EC212[0x01] = Mirror of $1D
  • $7EC213[{{0x|02]
  • $7EC215[{{0x|02]
  • $7EC217[{{0x|02]
  • $7EC219[0x{{{1}}}[0xC0? (best guess)] = related to the VWF?
These are set when new graphics are loaded using $0AA2
  • $7EC2F8[0x01] = Cached value for subset 0 of secondary bg graphics
  • $7EC2F9[0x01] = Cached value for subset 1 of secondary bg graphics
  • $7EC2FA[0x01] = Cached value for subset 2 of secondary bg graphics
  • $7EC2FB[0x01] = Cached value for subset 3 of secondary bg graphics
These are set when new graphics are loaded using $0AA3
  • $7EC2FC[0x01] = Sprite Graphics Subset 0
  • $7EC2FD[0x01] = Sprite Graphics Subset 1
  • $7EC2FE[0x01] = Sprite Graphics Subset 2
  • $7EC2FF[0x01] = Sprite Graphics Subset 3
  • $7EC300[0x200] = Auxiliary palette buffer. Probably used for manipulations of the palette that would be cause

graphical glitches if applied every frame.

  • $7EC500[0x200] = Main palette buffer (512 bytes)

Palette Data that will get written to CGRAM (512 bytes) whenever $7E0015 is nonzero. The following is a list of tile types found in each palette slot. Extra Info: BP-<number> means background palette <number> SP-<number> means sprite palette <number> The "first half" indicates the first 8 colors of a 4bpp palete, and the "second half" indicates the latter 8 colors. Note: however, that the first color of the "first half" palettes are never actually displayed b/c the hardware treats them as transparent. HUD-<number>- indicates a 4 color palette used with the 2bpp heads up display graphics. <number> ranges from 0 to 7. Only the last 3 colors are displayed as the first color in each HUD palette is considered transparent. Palettes are listed in order of appearance: HUD-0 HUD-1 HUD-2 HUD-3 HUD-4 HUD-5 HUD-6 HUD-7 - Arrow icon and blank item box. - Numbers, hearts, the "Life" icon, and the Floor Indicator. - Key icon, outline of magic bar and item box, the two dashes on either side of the "Life" icon and the border of the dialogue window. - Bomb icon - ???? - Pegasus boots on menu window - Dialogue text, - Magic meter (green) and rupee icon BP-2 (first half) - Overworld: Green / Tan ground, most of the rock and related colors on Death Mountain Dungeons: Misc things in dungeons, like edges of pits, parts of doors, boundaries for doors, 593boundaries of torches BP-2 (second half) - Overworld: Houses, urns, tops of wooden gates, Dungeons: Walls / doors in dungeons, houses on overworld BP-3 (first half) - Overworld: Secondary ground color, borders of certain paths, like in desert. Dungeons: Torches in dungeons, pots, statues, orange switch blocks BP-3 (second half) - Overworld: Statues, particular parts of rocks, paths and outlines of stone paths Dungeons: Primary floor colors BP-4 (first half) - Overworld: particular parts of rocks Dungeons: doorway statue in dungeons BP-4 (second half) - Overworld: Green trees, cacti, woods seen from high above on Death Mountain Dungeons: parallax floor below in dungeons, dungeon wall border. BP-5 (first half) - Animated tiles in overworld, beds, chairs tables in indoors BP-5 (second half) - Overworld: Pathway in Kakkariko and shrub hedges, overlays using color addition (fog in forest, lava in dark world) Dungeons: Dungeon entrance floor BP-6 (first half) - Overworld: Bushes, fences, grass, and the ground bushes and grass leave behind, signs Dungeons: Chests, candles in fortune teller huts, blue switch blocks BP-6 (second half) - Overworld: Tower of Hera, some parts above doors, master sword platform, small trees, red trees, Sahasralah's house. Dungeons: Rug in smithy house, BG1 floor BP-7 (first half) - Pyramid of Power, Dark Palace, Blue House roofs, warp tiles / cloud tiles. Seems to be an important palette. Dungeon: and tiles related to chests tiles in dungeons BP-7 (second half) - Overworld: cloud tiles (some), rope bridges Dungeons: Ceilings SP-0 (first half) - Sanctuary and Hyrule Castle Mantle, old guy at the bar in Kakkariko's body, weird head looking things at the entrance to the Desert Palace, bombos and ether tablets SP-0 (second half) - heavy rocks SP-1 (first half) - apples from trees, part of master sword beam, grass around your legs, off color bushes SP-1 (second half) - red rupees, small hearts, red potion in shops, some shadows, link's bow SP-2 (first half) - numerous special objects (dash dush from boots, sparkles, death / transformation poof), warp, whirlpool SP-2 (second half) - blue rupees SP-3 (first half) - red soldiers, bees, SP-3 (second half) - usually set to all dark grey colors, but can be swapped with SP-5 (second half) SP-4 (first half) - faeries, blue soldiers, chickens, green soldier shields, crows, lumberjack saw SP-4 (second half) - green rupees, green enemy bombs, some shadows, magic decanters SP-5 (first half) - palette determined by $0AAD, so varies by area / room SP-5 (second half) - Link's Sword (first three colors) and Shield (last four colors) SP-6 (first half) - palette determined by $0AAE, so varies by area / room 594SP-6 (second half) - throwable items like bushes, pots, rocks, signs, and the pieces all of those shatter into skulls that lurk in the ground under bushes SP-7 (full) - Link's body palette, including his glove color

  • $7EC700[0x14A] = The HUD tile indices buffer. (330 bytes)
  • $7EC7F2[0x04] = floor indicator (top two tiles)
  • $7EC782[0x04] = floor indicator (bottom two tiles)
  • $7EC84A[0x1FB6] = seemingly free ram (nearly 8K!)
  • $7EE800[0x800] = it's cleared out but I don't know what it's used for
  • $7EF000[0x500] = Save Game Memory, which gets mapped to a slot in SRAM when you save your game. SRAM slots

are at $70:0000, $70:0500, $70:0A00. They are also mirrored in the next three slots. See the sram documentation for more details.

  • $7EF500[0x80] = Possibly free ram
  • $7EF580[0x280] = (dungeon) For items under pots, this keeps track of which ones have been revealed in a given room

(array probably resets on reentrance to the dungeon or mirror usage)

  • $7EF800[0x100] = Stores the overworld tilemap address for a tile that has been modified.

Seems to support up to 0x80 different tiles. At first I thought this was for knowing what to reinstate when the screen scrolls on larger overworld areas, but that doesn't seem to be the case. The index into this table is $04AC.

  • $7EF900[0x40] = free ram?
  • $7EF940[0x200] = (dungeon) moveable block data (persistent across rooms and only regenerates upon

dungeon reentry or mirror). In the original game, only 0x18C of these bytes are filled with actual block data. Each block entry consists of 2 16-bit values: The first is the room that the block exists in. The second is the tilemap address of the block. If the tilemap address is from 0x0000 to 0x1FFF, then it's on BG2 If it's from 0x2000 to 0x3FFF, the block is on BG1. This value is always anded with 0x3FFF, forcing the block to one BG or the other.

  • $7EFA00[0x200] = (overworld) Note that this clashes with the block data
  • $7EFB40[0x180] = (dungeon) torch data (persistent across rooms)

Each torch entry consists of 2 16-bit values: The first word is the room that the torch exists in. The second

  • $7EFCC0[0x80] -

Each byte is the sprite graphics set to use for each overworld area. 595$7EFD40[0x80] = Each byte is the sprite palette set to use for each overworld area.

  • $7EFDC0[0x40] = free ram?
  • $7EFE00[0x200] = CHR to Tile Attribute table. Each byte tells the game how Link interacts with the each CHR type.

After the tilemaps are created from loading objects, the game then uses this table to translate CHR values into behavior types, and creates behavior tables for BG0 and BG1. As an example, let's say the CHR value for a particular tile in the tilemap was 0x04. In this lookup table, that would be the 5th byte (since it starts at 0), and you'd find the behavior type for that CHR to be 0x02. CHR values 0x140 0x1BF are loaded with behaviors that vary depending on the current value of $0AA2, the secondary graphics index. See $7F2000 and $7F3000 for details on tile attributes in dungeons. Also see routine $0717D9 in the Banks files (if you have them) and $71659 in Zelda3_ROM.log.