;================================================================================ ; RAM Labels & Assertions ;-------------------------------------------------------------------------------- ; This module is primarily concerned with labeling WRAM addresses used by the ; randomizer and documenting their usage. We use a combination of base $[address] ; and WRAMLabel = $[address] here, favoring the former when we have larger blocks ; of contiguous ram labeled. In some cases the label name can be descriptive enough ; without documentation, you may want to consult more in-depth reference materials, ; or I just don't understand what they are. ; ; See the JP 1.0 disassembly for reference, specifically symbols_wram.asm ; (https://github.com/spannerisms/jpdasm/ - 19/11/2022) ;-------------------------------------------------------------------------------- pushpc org 0 ;================================================================================ ; Bank 7E ;-------------------------------------------------------------------------------- ;================================================================================ ; Direct Page ;-------------------------------------------------------------------------------- base $7E0000 Scrap: Scrap00: skip 1 ; Used as short-term scratch space. If you need some short-term Scrap01: skip 1 ; RAM, you can often use these. Double check that the next use Scrap02: skip 1 ; of the addresses you want to use is a write. Scrap03: skip 1 ; Scrap04: skip 1 ; Scrap05: skip 1 ; Scrap06: skip 1 ; Scrap07: skip 1 ; Scrap08: skip 1 ; Scrap09: skip 1 ; Scrap0A: skip 1 ; Scrap0B: skip 1 ; Scrap0C: skip 1 ; Scrap0D: skip 1 ; Scrap0E: skip 1 ; Scrap0F: skip 1 ; ; GameMode = $7E0010 ; Game mode & submode. Refer to disassembly. GameSubMode = $7E0011 ; ; FrameCounter = $7E001A ; Increments every frame that the game isn't lagging IndoorsFlag = $7E001B ; $00 = Outdoors | $01 = Indoors ; LinkPosY = $7E0020 ; Link's absolute x/y coordinates. Both are word length. LinkPosX = $7E0022 ; LinkPosZ = $7E0024 ; $FFFF when on ground ; LinkRecoilY = $7E0027 ; LinkRecoilX = $7E0028 ; LinkRecoilZ = $7E0029 ; ; LinkDirection = $7E002F ; $00 = Up | $02 = Down | $04 = Left | $06 = Right ; OAMOffsetY = $7E0044 ; OAMOffsetX = $7E0045 ; ; LinkJumping = $7E004D ; $00 = None | $01 = Bonk/damage/water | $02 = Ledge ; BunnyFlagDP = $7E0056 ; $00 = Link | $01 = Bunny ; LinkSlipping = $7E005B ; $00 = None | $01 = Near pit ; $02 = Falling | $03 = Falling "more" FallTimer = $7E005C ; Timer for falling animation LinkState = $7E005D ; Main Link state handler LinkSpeed = $7E005E ; Main Link speed handler ; OverworldIndex = $7E008A ; Overworld screen index. Word length. Dark world is OR $40 of ; light world screen in same position. Zeroed on UW entry. OverlayID = $7E008C ; Overworld overlay ID. One Byte. ; RoomIndex = $7E00A0 ; Underworld room index. Word length. High byte: $00 = EG1 | $01 = EG2 ; Not zeroed on exit to overworld. PreviousRoom = $7E00A2 ; Stores previous value of RoomIndex ; SubSubModule = $7E00B0 ; Often used as a submodule, such as for transitions ; ObjPtr = $7E00B7 ; Pointer for drawing room objects. Three bytes. ObjPtrOffset = $7E00BA ; Used as an offset for ObjPointer. Word Length. PlayerSpriteBank = $7E00BC ; ScrapBufferBD = $7E00BD ; Another scrap buffer. $23 bytes. FileSelectPosition = $7E00C8 ; PasswordCodePosition = $7E00C8 ; PasswordSelectPosition = $7E00C9 ; ; BG1H = $7E00E0 ; Background scroll registers BG2H = $7E00E2 ; For BG1 and BG2, these registers are used for calculations later for different writes to PPU. BG3HOFSQL = $7E00E4 ; For BG3, the values are written directly to the PPU during NMI BG1V = $7E00E6 ; Since BG1 and BG2 are not written directly to PPU they are given different names from BG3. BG2V = $7E00E8 ; BG3VOFSQL = $7E00EA ; ; LinkLayer = $7E00EE ; Layer that Link is on. $00 = BG2 (upper) | $02 = BG1 (lower) ; Joy1A_All = $7E00F0 ; Joypad input Joy2A_All = $7E00F1 ; All = Current & previous frame Joy1B_All = $7E00F2 ; New = Current frame Joy2B_All = $7E00F3 ; Old = Previous frame Joy1A_New = $7E00F4 ; Joy2A_New = $7E00F5 ; Joy1B_New = $7E00F6 ; Joy2B_New = $7E00F7 ; Joy1A_Old = $7E00F8 ; Joy2A_Old = $7E00F9 ; Joy1B_Old = $7E00FA ; Joy2B_Old = $7E00FB ; ;================================================================================ ; Mirrored WRAM ;-------------------------------------------------------------------------------- ; Pages 0x00–0x1F of Bank7E are mirrored to every program bank ALTTP uses. ;-------------------------------------------------------------------------------- CurrentMSUTrack = $7E010B ; GameModeCache = $7E010C ; GameSubModeCache = $7E010D ; ; MedallionFlag = $7E0112 ; Medallion cutscene flag. $01 = Cutscene active. ; BG1ShakeV = $7E011A ; Applied to BG Scroll. Word Length. BG1ShakeH = $7E011C ; ; CurrentVolume = $7E0127 ; TargetVolume = $7E0129 ; CurrentControlRequest = $7E0133 ; Last thing written to MusicControlRequest MusicControl = $7E012B ; MusicControlRequest = $7E012C ; SFX1 = $7E012D ; SFX2 = $7E012E ; SFX3 = $7E012F ; ; SubModuleInterface = $7E0200 ; Word length. High byte expected to be $00. ItemCursor = $7E0202 ; Current location of the item menu cursor. ; BottleMenuCounter = $7E0205 ; Step counter for opening bottle menu MenuFrameCounter = $7E0206 ; Incremented every menu frame. Never read. MenuBlink = $7E0207 ; Incremented every frame and masked with $10 to blink cursor ; ItemReceiptID = $7E02D8 ; ; BunnyFlag = $7E02E0 ; $00 = Link | $01 = Bunny ; CutsceneFlag = $7E02E4 ; Flags various cutscenes. All non-zero behave the same. ; ItemReceiptMethod = $7E02E9 ; ; TileActBE = $7E02EF ; Bitfield used by breakables and entrances. b b b b d d d d ; b = Breakables | d = Entrances CurrentYItem = $7E0303 ; ; ; TileActDig = $7E035B ; Bitfield used by diggable ground. Word length. High byte unused. ; ForceSwordUp = $7E03EF ; $01 = Force sword up pose. ; ItemsTaken = $7E0403 ; Items taken in a room: b k u t s e h c ; b = boss kill/item | k = key/heart piece (prevents crystals) ; u = 2nd key/heart piece | t = chest 4/rupees/swamp drain/bomb floor/mire wall ; s = chest 3/pod or dp wall | e, h, c = chest 2, 1, 0 DungeonID = $7E040C ; High byte mostly unused but sometimes read. Word length. ; OWEntranceCutscene = $7E04C6 ; ; HeartBeepTimer = $7E04CA ; ; NMIAux = $7E0632 ; Stores long address of NMI jump. Currently only used by shops. ; SkipOAM = $7E0710 ; Set to skip OAM updates. High byte written $FF with exploding walls ; BowDryFire = $7E0B9A ; If set, arrows are deleted immediately ; SaveFileIndex = $7E0B9D ; ; SpritePosYLow = $7E0D00 ; Sprite slot data. Each label has $10 bytes. SpritePosXLow = $7E0D10 ; SpritePosYHigh = $7E0D20 ; SpritePosXHigh = $7E0D30 ; SpriteVelocityY = $7E0D40 ; SpriteVelocityX = $7E0D50 ; ; SpriteUnknown = $7E0D80 ; Don't know what this is ; SpriteAuxTable = $7E0DA0 ; $20 bytes. SpriteGFXControl = $7E0DC0 ; SpriteAITable = $7E0DD0 ; AI state of sprites. $10 bytes. ; SpriteTimer = $7E0DF0 ; ; SpriteTypeTable = $7E0E20 ; Which sprite occupies this slot. $10 bytes. ; SpriteItemType = $7E0E80 ; Sprite Item Type. $10 bytes. ; SpriteDirectionTable = $7E0EB0 ; Sprite direction. $10 bytes. ; FreezeSprites = $7E0FC1 ; "Seems to freeze sprites" ; SpriteCoordCacheX = $7E0FD8 ; SpriteCoordCacheY = $7E0FDA ; ; NoMenu = $7E0FFC ; When set prevents menu, mirror, medallions ; TextID = $7E1CF0 ; Message ID and page. Word length. ; ToastBuffer = $7E1E0E ; Multiworld buffer. Word length. ; MSUResumeTime = $7E1E6B ; Mirrored MSU block MSUResumeControl = $7E1E6F ; MSUFallbackTable = $7E1E70 ; MSUDelayedCommand = $7E1E79 ; MSUPackCount = $7E1E7A ; MSUPackCurrent = $7E1E7B ; MSUPackRequest = $7E1E7C ; MSULoadedTrack = $7E1E7D ; MSUResumeTrack = $7E1E7F ; ClockHours = $7E1E90 ; Clock Hours ClockMinutes = $7E1E94 ; Clock Minutes ClockSeconds = $7E1E98 ; Clock Seconds ClockBuffer = $7E1E9C ; Clock Temporary ScratchBufferNV = $7E1EA0 ; Non-volatile scratch buffer. Must preserve values through return. ScratchBufferV = $7E1EB0 ; Volatile scratch buffer. Can clobber at will. ;================================================================================ ; UNMIRRORED WRAM ; Addresses from here on can only be accessed with long addressing ; or absolute addressing with the appropriate data bank set ;-------------------------------------------------------------------------------- TileUploadBuffer = $7EA180 ; 0x300 bytes SpriteOAM = $7EC025 ; ; $7EC700 - Tile map buffer for HUD HUDKeyIcon = $7EC726 ; HUDGoalIndicator = $7EC72A ; HUDPrizeIcon = $7EC742 ; HUDRupees = $7EC750 ; HUDBombCount = $7EC75A ; HUDArrowCount = $7EC760 ; HUDKeyDigits = $7EC764 ; BigRAM = $7EC900 ; Big buffer of free ram (0x1F00) ;================================================================================ ; Bank 7F ;-------------------------------------------------------------------------------- DecompressionBuffer = $7F0000 ; Decompression Buffer. $2000 bytes. base $7F5000 RedrawFlag: skip 1 ; skip 2 ; HexToDecDigit1: skip 1 ; Space for storing the result of hex to decimal conversion. HexToDecDigit2: skip 1 ; Digits are stored from high to low. HexToDecDigit3: skip 1 ; HexToDecDigit4: skip 1 ; HexToDecDigit5: skip 1 ; SpriteSkipEOR: skip 2 ; Used in utilities.asm to determine when to skip drawing sprites. Zero-padded skip $2B ; Unused AltTextFlag: skip 2 ; dialog.asm: Determines whether to load from vanilla decompression buffer ; or from a secondary buffer (used for things like free dungeon item text) BossKills: skip 1 ; LagTime: skip 4 ; Computed during stats preparation for display RupeesCollected: skip 2 ; Computed during stats preparation for display NonChestCounter: skip 2 ; Computed during stats preparation for display skip 2 ; Unused TileUploadOffsetOverride: skip 2 ; Offset override for loading sprite gfx skip 3 ; skip 9 ; ; Shop Block $7F5050 - $7F506F ShopId: skip 1 ; Shop ID. Used for indexing and loading inventory for custom shops ShopType: skip 1 ; Shop type. $FF = vanilla shop ; t - - - - - - - ; t = Take-any ShopInventory: skip $0D ; For three possible shop items, row major: ; [Item ID][Price low][Price High][Purchase Count] ShopState: skip 1 ; - - - - - l c r | Bitfield that determines whether to draw an item ShopCapacity: skip 1 ; Four lower bits of shop_config in ShopTable, number of items 1-3 ShopScratch: skip 1 ; Scratch byte used in shop drawing routines ShopSRAMIndex: skip 1 ; SRAM index for purchase counts ShopMerchant: skip 1 ; Loaded from ShopTable and used to jump to one of four drawing routines skip 2 ; Unused ShopPriceColumn: skip 3 ; Stores coordinates for drawing prices in shops skip 7 ; skip 2 ; Reserved for OneMind OneMindId: skip 1 ; Current OneMind player OneMindTimerRAM: skip 2 ; Frame counter for OneMind skip 9 ; Unused ClockStatus: skip 2 ; 2 bytes second always zero padding ; ---- --dn ; d - DNF mode ; n - Negative skip $10 ; Unused RNGLockIn: skip 1 ; Used for RNG item (currently unused by rando) BusyItem: skip 1 ; Flags for indicating when these things are "busy" BusyHealth: skip 1 ; e.g. doing some animation BusyMagic: skip 1 ; DialogOffsetPointer: skip 2 ; Offset and return pointer into new dialog buffer used DialogReturnPointer: skip 2 ; for e.g. free dungeon item text. skip 1 ; Unused PreviousOverworldDoor: skip 1 ; Previous overworld door is cached or initialized here skip 1 ; Reserved skip 1 ; Unused DuckMapFlag: skip 1 ; Temporary flag used and reset by flute map drawing routine StalfosBombDamage: skip 1 ; Relocated from damage table ValidKeyLoaded: skip 1 ; TextBoxDefer: skip 1 ; Flag used to defer post-item text boxes skip $10 ; Unused skip $10 ; Reserved for enemizer ; Most of these modifiers are intended to be written to by ; a 3rd party (e.g. Crowd Control.) Writer is responsible ; for zeroing. SwordModifier: skip 1 ; Adds level to current sword. Doesn't change graphics. ShieldModifier: skip 1 ; Not implemented ArmorModifier: skip 1 ; Adds level to current mail. Doesn't change graphics. MagicModifier: skip 1 ; Adds level to magic consumption (1/2, 1/4.) LightConeModifier: skip 1 ; Gives lamp cone when set to 1 CuccoStormer: skip 1 ; Non-zero write causes storm. OldManDash: skip 1 ; Unused IceModifier: skip 1 ; - - - g - - - i | Flipping either sets ice physics InfiniteArrows: skip 1 ; Setting these to $01 will give infinite ammo. Set by InfiniteBombs: skip 1 ; EscapeAssist. InfiniteMagic: skip 1 ; ControllerInverter: skip 1 ; $01 = D-pad | $02 = Buttons | $03 = Buttons and D-Pad ; >=$04 = Swap buttons and D-pad OHKOFlag: skip 1 ; Any non-zero write sets OHKO mode SpriteSwapper: skip 1 ; Loads new link sprite and glove/armor palette. No gfx or ; code currently in base ROM for this. BootsModifier: skip 1 ; $01 = Give dash ability skip 1 ; Unused ; Crypto Block ($7F50D0 - $7F51FF) KeyBase: skip $10 ; y: skip 4 ; z: skip 4 ; Sum: skip 4 ; p: skip 4 ; e: skip 2 ; CryptoScratch: skip $0E ; CryptoBuffer: ; v: skip $100 ; RNGPointers: skip $100 ; Pointers for static RNG ; Network I/O block. See servicerequest.asm. Rx and Tx channels ; also allocated 8 persistent bytes each in sram.asm. RxBuffer: skip $7F ; RxStatus: skip 1 ; TxBuffer: skip $7F ; TxStatus: skip 1 ; skip $10 ; Unused CompassTotalsWRAM: skip $10 ; skip $10 skip $40 ; Reserved for general dungeon tracking data. May have over ; allocated here. Feel free to reassign. skip $40 ; Unused skip $260 ; Unused DialogBuffer: skip $100 ; Dialog Buffer MiniGameTime = $7FFE00 ; Time spent in mini game. 32-bits. MiniGameTimeFinal = $7FFE04 ; Final mini game time. 32 bits. ;================================================================================ ; RAM Assertions ;-------------------------------------------------------------------------------- macro assertRAM(label, address) assert