Arcana/ROM map

From Data Crystal
< Arcana
Revision as of 22:07, 2 August 2024 by Sarah Shinespark (talk | contribs) (Added to bank 00, lots more event opcodes including the ones with little documentation.)
Jump to navigation Jump to search

Chip tiny.png The following article is a ROM map for Arcana.

(Back to Main page)

Bank $00: Common functions; Event handling


$00/8153	Sub: NMI disable
$00/8167	Sub: NMI enable
$00/817B	Sub: Display Force Blanking
$00/818F	Sub: Set Display
$00/81BF	Sub: Set BG mode (1 byte parameter)
$00/81D8	Sub: Set OBJ Address (1 byte parameter)
$00/8208	Sub: Set OBJ Size (1 byte parameter)
$00/826E	Sub: Graphics dungeon stuff
$00/8327	Sub: Update screen
$00/8400	Sub: Update background scroll
$00/8465	Sub: Video stuff
$00/84B9	Table: DMA Control
$00/84D0	Table: DMA Destination
$00/84E7	Table: Videoport Control
$00/84FE	Sub: RAM Decomp80 (1 byte)
$00/8521	Sub: Decomp80 setup - Decompressor helper function. Reads a data entry that looks like "80 00 xx [xx/xxxx] xx xx" and passes the pointer to the decompressor.
$00/8766	Sub: Decompression. Similar to Run Length Encoding.
$00/88E2	Sub: Wait for VBLANK
$00/89F1	Sub: RNG (1 byte parameter) - can take a value ("5") and roll a range ("0-4"), or can provide a random 2 byte number through $1E0A.
$00/8A3D	Sub: Multiply to $1E00
$00/8B11	Sub: Set Mode7
$00/8BE4	Table: Bitwise1
$00/8BF4	Table: Bitwise2
$00/8C04	Table: HDMA channels (an AND table where all but 1 bit is set)
$00/8C34	Table: Bit flags
$00/9008	Sub: Main loop, pointer setup
$00/902B	Sub: Read Event Code. Reads the event opcode from program counter $1E10. (Very important line! Uses a jump table to run opcodes as code.)

Events: These opcodes run over half of the game. Most commonly you'll find code 07 for long calling a subroutine.
$00/90E7	Event Opcode 00 - This one is complicated, it's similar to a return
$00/90FA	Event Opcode 01 - Loops a number of times (1 byte input)
$00/911E	Event Opcode 02 - Loop end: jumps back to opcode 01
$00/9140	Event Opcode 1A - Jump always (2 bytes)
$00/9148	Event Opcode 03 - Jump long   (3 bytes)
$00/915A	Event Opcode 1B - Call subroutine (2 bytes)
$00/9177	Event Opcode 1C - Return from short subroutine/1B
$00/918D	Event Opcode 04 - Call subroutine (3 bytes)
$00/91BB	Event Opcode 05 - Return from long subroutine/04
$00/91DA	Event Opcode 06 - Delay x frames (1 byte)
$00/91EA	Animation Opcodes 30-37 (1 byte) - Sets or zeros the animation ID $0A7B,x
$00/9202	Animation Opcodes 38-3F (2 bytes) - Sets the cursor X position
$00/9250	Animation Opcodes 40-47 (2 bytes) - Sets the cursor Y position
$00/929E	Animation Opcodes E0-E7 (2 bytes)
$00/92D7	Animation Opcodes 58-5F (2 bytes)
$00/92F8	Animation Opcodes 60-67 (2 bytes)
$00/9319	Animation Opcodes F0-F7 (2 bytes)
$00/933A	Animation Opcodes 68-6F (2 bytes)
$00/9362	Animation Opcodes 70-77 (2 bytes)
$00/938A	Animation Opcodes F8-FF (2 bytes)
$00/93B2	Animation Opcodes 78-7F (3 bytes) - Reads an x offset, then stores 2bytes in $0FEF,x and zeros $0FFF,x (?)
$00/93CA	Animation Opcodes 80-87 (3 bytes)
$00/93E2	Animation Opcodes 88-8F (3 bytes)
$00/9409	Animation Opcodes 90-97 (3 bytes)
$00/9430	Animation Opcodes 98-9F (3 bytes)
$00/945E	Animation Opcodes A0-A7 (3 bytes)
$00/948C	Animation Opcodes 48-4F (2 bytes) - Adds to a total at $0937,x
$00/949F	Animation Opcodes 50-57 (2 bytes) - Adds to a total at $095B,x
$00/94B2	Animation Opcodes E8-EF (2 bytes) - Adds to a total at $097F,x
$00/94C5	Animation Opcodes C0-C7 (3 bytes)
$00/94F7	Animation Opcodes D0-D7 (0 bytes) - Zeros some stuff
$00/950F	Animation Opcodes D8-DF (1 byte)  - Takes an offset and zeros some stuff
$00/9527	Event Opcode 07 (3 bytes) - Call a subroutine. (Runs code, returns with RTL)
$00/954D	Event Opcode 0B (2 bytes) - Jump if false
$00/9562	Event Opcode 0C (2 bytes) - Jump if true
$00/9577	Event Opcode 11 (? bytes) - Switch-case: jump based on return value. Takes 1 byte (# of entries) plus 2 bytes per entry for the jump pointers.
$00/959D	Event Opcode 12 (? bytes) - Similar to 11, a switch-case
$00/95C7	Event Opcode 0D (0 bytes) - Similar to 00, some kind of return.
$00/95DF	Event Opcode 08 (2 bytes) - Similar to 1B, some kind of branch to a 2 byte pointer. Clears the animation loop.
$00/960C	Event Opcode 14 (1 byte)
$00/963F	Event Opcode 09 (3 bytes) - Similar to 04, some kind of long pointer jump.
$00/9655	Event Opcode 0A (0 bytes) - Clears the current animation loop.
$00/965F	Animation Opcodes A8-AF (0 bytes) - Increment animation ID (A8 = high speed, AF = low speed)
$00/9668	Animation Opcodes B0-B7 (0 bytes) - Decrement animation ID
$00/9671	Animation Opcodes B8-BF (1 byte)  - Adds (amount) to the animation ID
$00/968D	Event Opcode 19 (5 bytes?)- Similar to 0E, compares values
$00/96B8	Event Opcode 15 (4 bytes) - Compares an actor ID with a value.
$00/96CD	Event Opcode 0E (5 bytes) - Compares RAM to a value using a comparator (RAM Operations table)
$00/96F2	Table: RAM Operations (has pointers to functions for AND, OR, add, and XOR)
$00/9717	Event Opcode 0F (3 bytes) - Set actor (1 byte) to value (2 bytes). See Actor Arrays table.
$00/9739	Table: Actor Arrays - Pointers to RAM 09A3, 09C7, 09EB, 0A0F. These are used with an X offset to track various information. AKA var0, var1, var2, var3.
$00/9741	Event Opcode 10
$00/974A	Event Opcode 13 (3 bytes) - Set RAM address (2 bytes) to value (1 byte)
$00/975F	Event Opcode 16 (4 bytes) - Set RAM address (2 bytes) to value (2 bytes)
$00/9772	Event Opcode 17
$00/9791	Event Opcode 18
$00/97A0	Event Opcode 1D (3 bytes) - Stores a 2 byte pointer to $0A9F,x and the bank to $0AC3,x
$00/97B6	Event Opcode 1E (2 bytes) - Load value
$00/97C5	Event Opcode 1F (2 bytes) - Load value at address
$00/97D8	Event Opcode 20
$00/97F5	Event Opcode 21
$00/9814	Event Opcode 22
$00/982A	Event Opcode 23
$00/9847	Event Opcode 24 (1 byte)  - Load a value from 1 of 4 arrays
$00/9864	Event Opcode 25 (1 byte)  - Similar to 24 but sets the loop variable $0B9F,y
$00/9AF0	Sub: Get Event Code (1 byte) - Reads the next event opcode from the program counter $1E10
$00/9B00	Sub: Get Event Code (2 bytes)

$00/9C3C	Sub: Set/Get Music (1 byte)
$00/9C44	Sub: Set/Get SFX (1 byte)
$00/9B07	Sub: Main event handler
$00/A00F	Sub: Check $31 for button press (2 bytes: button)
$00/A022	Sub: Check $21 for button press (2 bytes: button)
$00/A0AC	Sub: Load text to be read (3 byte location)
$00/A0BD	Sub: Call RNG (1 byte), something with screen
$00/A0CB	Sub: Unfade from black
$00/A0DB	Sub: Fade to black

Text opcodes: These control formatting in-between the plaintext before it's written to RAM.
$00/A858	Text Opcode 00 - Null terminator/stop reading
$00/A881	Text Opcode 01 - Move cursor to X,Y position
$00/A898	Text Opcode 02 - Used drawing the menus
$00/A8A8	Text Opcode 03 - Sets vertical spacing (03 0E = default)
$00/A8C2	Text Opcode 05 - Text delay?
$00/A8DE	Text Opcode 06 - Sets text color (white/gray or white/yellow depending on context)
$00/A902	Text Opcode 0D - Newline
$00/A919	Text Opcode 14 - Writes text in RAM to the screen(2 byte address)
$00/A943	Text Opcode 10 - Writes text in RAM/ROM to the screen(3 byte address)
$00/A969	Text Opcode 11 - Converts number to text(3 byte address)
$00/A9A8	Text Opcode 1C - Sets text scroll speed
$00/A9BD	Text Opcode 1D - Sets text scroll speed (1 line at a time)
$00/A9C5	Text Opcode 1E - Sets text scroll speed (fast)
$00/A9CD	Text Opcode 7F - Wait for A press
$00/AA04	Text Opcode 08 - Move cursor to X position
$00/A9A8	Text Opcode 1C - Sets text scroll speed
$00/A9E1	Text Opcode 1B - Draws dialogue portraits

$00/BE07	Sub: Clears the screen of text
$00/C055	Sub: Hit calculation start
$00/C07C	Sub: Get row bonus
$00/C0B9	Sub: Miss check/crit check
$00/C132	Sub: No-element handling
$00/C2D4	Sub: Check if damage is over 999
$00/C30C	Sub: Load attacking Element
$00/C3CA	Sub: More element handling
$00/C431	Sub: Attack vs. Defense
$00/C585	Sub: Load stat boost modifier
$00/C5B1	Sub: Check for dead/removed actors, more
$00/C658	Sub: Load Strength modifier
$00/C66A	Sub: Load Endurance modifier
$00/C676	Sub: Load Alertness modifier
$00/C68A	Sub: Load Intelligence
$00/C6A7	Sub: Load Intelligence
$00/C6C4	Sub: Load Intelligence
$00/C6DC	Sub: Lots of branching. Returns crit chance or other variables
$00/C781	Sub: Load Armor defense
$00/C856	Sub: Loads spell power/element
$00/C88B	Sub: Multiplication (A * X)
$00/C8A1	Sub: Multiplication (AA * X)
$00/C8C2	Sub: Division (Returns A remainder, X result)
$00/D137	Sub: Checks if loaded music is $33 (must be SPC commands)
$00/D1AA	Sub: Loads HAL Logo theme

Bank $01: Game setup, gameplay, ending

$01/8001	Game start
$01/8053	A bunch of initialization/zeroing functions
$01/8913	Game over
$01/8C85	Event: Handle dungeon movement
$01/9584	Event: Item handling outside of battle
$01/9BB6	Pointer: Draw status screen ($08/C93E)

Bank $02: Battles

$02/8CF3	Event: Status handling
$02/8FC9	Tbl: Boss animations
$02/913D	Sub: Initializes a character/monster's stats from ROM at battle start

Bank $03: Event handling, towns

$03/A457	Sub: Load current tile's encounter value
$03/A499	Sub: Update dungeon progress?
$03/A52A	Dungeon BGM (See Music tab for ID list)
$03/D5BF	Item inventory limit (shops). Default $60 = $30 slots (48 items @ 8 per page) (see $07/AA28)
$03/DDD6	Item slots -1 x2, used after selling an item in town to check when to stop rearranging. (see $07/AA28)(should be $5E?)
$03/DF27	Bar prices (you know, the Alchemist guy)
		(NOTE: His prices are also plaintext in his dialogue and need to be edited separately)
$03/DFA2	Bar option 2 HP gain
$03/DFA4	Bar option 3 HP gain
$03/DFA6	Bar option 4 HP gain
$03/DFA8	Bar option 2 MP gain
$03/DFAA	Bar option 3 MP gain
$03/DFAC	Bar option 4 MP gain
$03/E052	Card prices (see Inventory)
$03/E2A8	Set up dialogue cursor

Bank $04: Graphics

Bank $05: Battles

$05/9F7B	Names, Characters ($0A bytes per entry + 00 delimeter)
$05/9FE9	Names, Enemies ($10 bytes per entry + 00 delimeter)
$05/A539	Enemy postfixes A-H (I forget what 81 40 means though)
$05/A554	Classes, Characters ($10 bytes per entry + 00 delimeter) NOTE: Using too long a name will result in a blank line.
$05/A5FE	Names, Areas ($10 bytes per entry + 00 delimeter)
$05/A895	Names, Elements ($06 bytes per entry + 00 delimeter)
$05/A8BF	Names, Status effects ($0C bytes per entry + 00 delimeter)
$05/A91A	EXP to next level, Rooks?
$05/A992	EXP to next level, Sylph?
$05/AA0A	EXP to next level, Dao?
$05/AA82	EXP to next level, Marid?
$05/AAFA	EXP to next level, Efrite?
$05/AB72	EXP to next level, Teefa
$05/ABEA	EXP to next level, Salah?
$05/AC62	EXP to next level, Darwin?
$05/ACDA	EXP to next level, Axs? (60 entries x 2 bytes)
$05/AD6A	Level-up stats, Rooks (HP, MP, Str, End, Int, Alt) (2 bytes per entry)
$05/B03A	Level-up stats, Sylph
$05/B2FD	Level-up stats, Dao
$05/B5CE	Level-up stats, Marid
$05/B89E	Level-up stats, Efrite
$05/BB7A	Level-up stats, Teefa
$05/BE4A	Level-up stats, Salah
$05/C11A	Level-up stats, Darwin
$05/C3EA	Level-up stats, Axs
$05/C6A3	A bunch of 0's and 1's
$05/C8D4	Level-up spells, Rooks
$05/C8E2	Level-up spells, Sylph
$05/C8F2	Level-up spells, Dao
$05/C8F2	Level-up spells, Marid
$05/C8FB	Level-up spells, Efrite
$05/C904	Level-up spells, Teefa
$05/C911	Level-up spells, Salah
$05/C91F	Level-up spells, Darwin
$05/C929	Level-up spells, Axs
$05/C92D	Monster race/element (2 bytes per entry) (ends at 2C9CB)
$05/C9CD	Monster Equipment stats, several unknown (start)
$05/CE54	Monster Equipment stats (end)
$05/CE55	Monster HP
$05/CEF5	Monster EXP
$05/CF95	Monster GP
$05/D035	Monster Lvl
$05/D0D5	Monster ?? stat - $20 entries of 00 through 05. No idea what this is.
$05/D195	Monster boss music (00 none, 01 Boss1, 03 Boss2, 02 Rimsala)
$05/D1E5	Monster boss flag (00-0F are bosses, FF are not bosses)
$05/D235	Monster spell. (If nonzero, there's a random chance they'll use that spell instead of attacking.) (see Spells page)
$05/D285	Monster ?? stat
$05/D405	Monster Armor Def table (bugged?): offset = Armor * 2
$05/D445	Monster Accessory Def table: offset = Accessory * 2
$05/D4A5	Possible monster stat
$05/D565	Possible monster stat
$05/DE88	Equipment prices (see Equipment tab)
$05/DF79	Equipment "can be equipped by" data (see Equipment tab)
$05/DFF3	Equipment power/defense
$05/E0E3	Equipment race bonus/element (2 bytes per item)
$05/E1D5	Equipment: weapon crit rate
$05/E226	Equipment: shield mag def ($05/E1D5)
$05/E24E	Equipment: weapon damage penalty
$05/E2C8	Equipment - spell cast in battle
$05/E356	Spells' names
$05/EA4D	Spells’ “battle only flag” (01: out of battle only, 02: battle only, 03: either)
$05/EA9F	Spells’ “single/multi target flag” (00: single, 01: multi); Change Attribute is broken as ST
$05/EAF1	Spells’ accuracy
$05/EB4D	Spells' power
$05/EC04	Spells' element (paired with an unknown byte, so skip a byte for each entry) (see Magic tab)
$05/ECA6	Spells' MP cost
$05/ECF8	Spells' color palette (see Magic tab)
$05/ED57	Spells’ sfx
$05/EE9A	Item names (look for LDA $05/EE9A,x or "BF 9A EE 05")
$05/F038	Card names (look for LDA $05/F038,x or "BF 38 F0 05")
$05/F17E	Sleeping Bag HP heal amount (200 HP) (Heals everyone but the spirits)
$05/F180	Sleeping Bag MP heal amount (25 MP)
$05/F194	Tent HP heal amount (999 MP) (Heals everyone but the spirits)
$05/F196	Tent MP heal amount (999 MP)
$05/F20A	Herbs heal amount (70 HP)
$05/F21F	Medicine heal amount (200 HP)
$05/F234	Silver Flask heal amount (15 MP)
$05/F249	Gold Flask heal amount (40 MP)

Bank $06: Stage select

$06/DDBD	Stage select: Chapter 2 (These are essentially pre-made save files)
$06/E2BD	Stage select: Chapter 3
$06/E7BD	Stage select: Chapter 4
$06/ECBD	Stage select: Chapter 5

Bank $07: Dungeons and gameplay

$07/8001	Sub: Fighting final boss?
$07/80F2	Tbl: Levelup spells
$07/8CC4	Sub: Deducts HP from target
$07/8EDF	FINIS (tile bytes) (appears 2x for some reason)
$07/8F6E	SLEEP (appears 3x for some reason)
$07/8FEC	ROOKS
$07/9020	EFRITE
$07/903A	SALAH
$07/906A	End of names' sprite values
$07/A83D	Sub: Branches based on treasure chest contents
$07/A866	Sub: Card treasure type
$07/A932	Sub: Loads a card name from ROM
$07/A9D4	Sub: Adds a card to the inventory
$07/A872	Sub: Item treasure type
$07/A95C	Sub: Loads an item name from ROM
$07/AA18	Sub: Adds an item to the inventory
$07/AA27	Item inventory limit (chests). Default $60 = $30 slots (48 items @ 8 per page)
$07/A87E	Sub: Equipment treasure type
$07/A986	Sub: Loads an equipment name from ROM
$07/AA3D	Sub: Adds a weapon to the inventory
$07/AA4D	Equipment inventory limit (chests). Default $40 = $20 slots (32 items @ 8 per page)
$07/A88A	Sub: GP treasure type
$07/A896	Sub: Monster treasure type (unused)
$07/A8AF	Sub: FFFF treasure type (unused???) (returns failure)
$07/A8BB	Sub: Empty treasure type (returns failure)
$07/AA65	Sub: Adds GP to total
$07/AA6B	Max GP (FFFF)
$07/B234	Sub: Levelup check
$07/B2DB	Sub: When Teefa/Axs join, assigns them Rooks' LV
$07/B2E2	Sub: When Salah joins, assigns her Rooks' LV-3
$07/B2F5	Sub: When Darwin joins, assigns him Rooks' LV+3
$07/BBEA	Pointer table for character stats in RAM
$07/BBF6	Honey stat boost amounts (Str, Int, End, Alt, HP, MP)
$07/BC7C	Sub: Recovers MP, sets to full MP if more than max
$07/BCF1	Sub: Loop for full party healing; ends when X=08
$07/BF3A	Sub: Related to running
$07/BF54	Sub: Deducts MP from a spell
$07/C355	Pointer table for spell effects
$07/C8DE	SFX for Healing (See Music tab for values)
$07/C8E5	SFX for Change Attribute
$07/C8E4	SFX for Buffs

Bank $08: Small scripts

$08/8000	Script, Battle/Towns/Items/Magic
$08/9650	Spell descriptions
$08/C93E	Status screen (184 bytes)
$08/C9F6	Status screen, current spirit (161 bytes)
$08/D3C3	Alchemist conversations

Bank $0C: Main script

(Text is in plaintext, so it's easy to search for in the ROM.)
$0C/A010	Script 000: Rooks' introduction
$0C/F703	Script 117: Prelude to the final battle

Bank $0D: Compressed data

$0D/9590	Weapons menu

Bank $0E: Compressed gfx

$0E/92F9	Rooks gfx
$0E/95A3	Sylph gfx
$0E/A12C	Marid gfx
$0E/AC91	Dao gfx
$0E/B715	Efrite gfx
$0E/C292	Teefa gfx
$0E/D25E	Salah gfx

Bank $0F: Battle animations?

$0F/817A	Really long pointer table

Bank $10: Compressed gfx

$10/8001	Balnea Temple/Reused brick gfx
$10/C58D	Balnea Temple gfx end

Bank $11: Compressed gfx

$11/8A91	Forest of Doubt gfx
$11/FBA7	Forest of Doubt gfx end

Bank $12: Compressed gfx

$12/8571	Bintel Castle gfx
$12/E35E	Bintel Castle gfx end

Bank $13: Graphics and Maps

$13/8001	Draven Pass gfx
$13/DACA	Draven Pass gfx end
$13/EBF7	Balnea Temple 1F map (These are all preceded by FF E4. Read break on $7FFC42 or similar and follow the DMA address given.)
$13/ECFF	Balnea Temple 2F map
$13/F764	Bintel Castle map

Bank $15: Compressed sprites

$15/B4F1	The Seven McGuffins gfx (ends at B87A)

Bank $16: Compressed sprites

$16/B8EC	Final fight gfx

Bank $17: Initialization

$17/8130	Intro script ("This is an historic land")
$17/833F	Sub: Stage Select (logs your inputs and compares them to the right codes)
$17/840E	Sound test
$17/9285	HAL logo gfx header

Bank $18: Treasures, encounters, events

$18/802E	Sub: Random encounter logic
$18/8044	Encounter rate (higher = fewer encounters) (Default $0C)
$18/8056	Sub: Random encounter
$18/80DB	Sub: Normal (returns 3)/back attack (returns 2)?
$18/8210	Sub: Formations
$18/826A	Snip: Loads the proper battle music ID
$18/82B6	Snip: Loads monster ID from formation
$18/82E2	Table: Battle music IDs (normal, boss, goddess, final)
$18/85AB	Sub: Returns treasure data (A: item type, X: value)
$18/85D2	Sub: Updates treasure tracker ($18E3) after opening a chest
$18/8A99	Table: Pointers for chapter treasures tables
$18/8AA3	Table: Treasure data Ch1 (12 bytes per entry)
$18/8B1D	Table: Treasure data Ch2 (12 bytes per entry)
$18/8CB7	Table: Treasure data Ch3 (12 bytes per entry)
$18/8EBD	Table: Treasure data Ch4 (12 bytes per entry)
$18/8FEB	Table: Treasure data Ch5 (12 bytes per entry)
Ch5 examples:
$18/9001	Location of Robe of Valor in Bintel Castle first room
$18/900D	Location of Gold Flask in Bintel Castle first room ^_^
$18/9079	Location of Grand Shield
$18/9023	Desiree data (02 0C = Equipment id 0C)
$18/9047	Return Ring data in "A Tunnel".
$18/9101	Table: Pointers to boss locations by chapter (Ch1: +0, Ch2: +2 etc)
$18/910B	Table: Ch1 boss fights (8 bytes/entry): 00 01-> Map 00 Balnea 1F; 0F00 0600 -> (0F, 06); 0600 -> Encounter #6)
$18/911D	Table: Ch2 boss fights (8 bytes/entry)
$18/912F	Table: Ch3 boss fights (8 bytes/entry)
$18/9139	Table: Ch4 boss fights (8 bytes/entry) empty, needs research
$18/913B	Table: Ch5 boss fights (8 bytes/entry) empty, needs research
$18/913D	Table: Pointers to encounters by chapter (Ch1: +2, Ch2: +4 etc)
$18/9147	Table: Ch1 encounters
$18/9177	Table: Ch2 encounters
$18/91AA	Table: Ch3 encounters
Ch3 example:
$18/91B3	Encounter data (1C 1D 1E 1A 1B -> 5 monsters in Ice Cave)
$18/91DD	Table: Ch4 encounters
$18/9229	Table: Ch5 encounters
$18/9270	Table: Pointers to RNG seeds
$18/947C	RNG seed "10" from offset 0A
$18/947D	Entry size
$18/94D9	RNG seed "01" from offset 0B (Chapter 2?)
$18/C551	Red and Blue Guardian event
$18/C6D1	Tiamat event
$18/D019	Epilogue text setup

Bank $19-1D: Unknown or compressed data

Bank $1E, 1F: Sound and Music