Tactics Ogre:ROM map

From Data Crystal
Revision as of 03:42, 4 May 2016 by Lytron (talk | contribs)
Jump to: navigation, search

ROM offsets

These are ROM offsets for the starting points of each section (all in hex), pretty sure it's headerless (latest ROM revision, has Lakmir's translation patch applied to it):

40c33 - Spell Areas
40cc9 - Spell Function Bytes
40fb7 - Spell Accuracy Types (Auto-Hit, Dex-Based, etc.)
4104d - Spell Cost Type (Whether it eats HP or MP, how much, etc.)
41179 - Spell Formula Table
4133B - Spell Elements (Fire, Air, Virtue, etc.)
42703 - Character Sprite pointers
429e3 - Character Name pointers
42ad2 - Job IDs
42bc2 - Starting Elements
42cb0 - Starting Alignments
42dbf - Number of Magic Slots
42ead - Starting Level
42f9b - Starting HP
430bb - HP Growth
4314b - Starting MP
4326b - MP Growth
432fb - Starting Strength
4338b - Strength Growth
4341b - Starting Vitality
434ab - Vitality Growth
4353b - Starting Intelligence
435cb - Intelligence Growth
4365b - Starting Mentality
436eb - Mentality Growth
4377b - Starting Agility
4380b - Agility Growth
4389b - Starting Dexterity
4392b - Dexterity Growth
43a4c - Class Weight Penalties
43add - Physical Resistance
43b6e - Air Resistance
43bff - Fire Resistance
43c90 - Earth Resistance
43d21 - Water Resistance
43db2 - Virtue Resistance
43e43 - Bane Resistance
43ef4 - Attack+ Capability
440b1 - Species Table
441a1 - Basic Indirect Attack Type
442b0 - Magic Set that can be equipped
443a0 - Class Special Attacks (Slot 1)
4448f - Class Special Attacks (Slot 2)
4457e - Class Special Attacks (Slot 3)
4466d - Class Special Attacks (Slot 4)
4475b - Movement Types
44849 - Movement Rates
44937 - Starting Loyalties
44a26 - Weather Tolerance
451da - Item Types
452ca - Item Elements
453ba - Weapon Handedness
454aa - Item Equip Slot Locations (Finger, Head, etc.)
45655 - Item Weights
4572e - Item Strength Modifiers (Atk. Power)
4580e - Item Intelligence Modifiers
458ee - Item Agility Modifiers
459ce - Item Dexterity Modifiers
45aae - Item Vitality Modifiers
45b8e - Item Mentality Modifiers
45c6e - Item Luck Modifiers
45d4e - Item Physical Resistance (Def. Power) (signed)
45e2e - Item Air Resistance (signed)
45f0e - Item Fire Resistance (signed)
45fee - Item Earth Resistance (signed)
460ce - Item Water Resistance (signed)
461ae - Item Virtue Resistance (signed)
4628e - Item Bane Resistance (signed)
4646f - Item Prices (multiplied by 10 in-game)
46612 - Item Strength Raise at Level Up
466e4 - Item Intelligence Raise at Level Up
467b4 - Item Agility Raise at Level Up
46884 - Item Dexterity Raise at Level Up
46956 - Item Vitality Raise at Level Up
46a26 - Item Mentality Raise at Level Up
46af6 - Item Luck Raise at Level Up
46bc6 - Item Special Effects (Stuns on hit, Anti-Dragon, etc.)
46cb6 - Item Special Skills (used in the Item menu)
46d86 - Item Status Guards (immunity to petrification, etc.)
46e76 - Item Passive Effects (wearer can fly, HP regen, etc.)
47047 - Spell MP cost/Targeting Information
47172 - Spell Schools (Hahnela, Ishtar, DragonGod, etc.)
47208 - Spell Ranges
4729e - Special Spell Conditions #1 (Summons, Line-of-sight spells, whether equipment is needed, etc.)
4732f - Spell Prices (multiplied by 10 in-game)
47431 - Spell Set Modifiers
474a1 - How the caster behaves when using the spell/skill. NOTE: Each half of the bytes here specifies one skill.
474f1 - Special Spell Conditions #2 (If equipment is needed, this specifies the type (swords, spears, etc.) NOTE: Each half of the bytes here specifies one skill.
ea0dc - Class Grids (determines what you can change into)
ebba7 - Denim's Base Class
ebca1 - Denim's Initial Equipment (Slot 1)
ebcac - Denim's Initial Equipment (Slot 2)
ebcb7 - Denim's Initial Equipment (Slot 3)
ebcc2 - Denim's Initial Equipment (Slot 4)
ebc94 - Denim's Initial Spells (doesn't insert into Magic menu, need to use a JMP routine to get anything out of it)
ed61e - Item Shop pointers/data
ed6d9 - Magic Shop pointers/data
f3195 - Job Stat Requirements (what's needed to change into that job stat-wise, might also cover alignment but I couldn't tell from a glance).

Code

This is all taken from the Japanese V1.0 version

$80/8000 ROM Start

$00/8000 18          CLC           ; Switch to Native Mode
$00/8001 FB          XCE
$00/8002 78          SEI           ; Disable Interrupts
$00/8003 D8          CLD           ; Deactivate Decimal Mode (if accidentally turned on)
$00/8004 4B          PHK           ; Push Bank Register
$00/8005 AB          PLB           ; Pull Data Bank Register
$00/8006 E2 20       SEP #$20
$00/8008 C2 10       REP #$10
$00/800A A2 FF 1F    LDX #$1FFF    ; Set Stack to $7E:1FFF
$00/800D 9A          TXS
$00/800E F4 00 00    PEA $0000     ; Direct Page Register = #$0000
$00/8011 2B          PLD
$00/8012 9C 00 42    STZ $4200     ; Deactivate NMI / Auto-Joypad
$00/8015 9C AF 05    STZ $05AF     ; Backup for $4200?
$00/8018 20 6A 80    JSR $806A     ; De-activate HDMAs, FBLANK, Clear Screen Destination Registers

Clear $7E:2000 to $7E:FFFF

$00/801B A0 00 E0    LDY #$E000    ; DMA Size: #$E000
$00/801E 8C 05 43    STY $4305
$00/8021 A0 00 20    LDY #$2000    ; WRAM Destination: $(7E)2000
$00/8024 18          CLC           ; WRAM-Destination: Bank $7E
$00/8025 A2 69 80    LDX #$8069    ; DMA Source Address: $00/8069 (ROM: $0000.0069
$00/8028 A9 00       LDA #$00
$00/802A 22 A7 9D 80 JSL $809DA7   ; Long Branch to the DMA setup and activation


$00/802E A9 01       LDA #$01      ; Activate Fast ROM
$00/8030 8D 0D 42    STA $420D
$00/8033 22 00 80 8F JSL $8F8000   ; Jump to ??? (Sound Setup?)

$00/8037 64 59       STZ $59       ; ???
$00/8039 64 EA       STZ $EA
$00/803B C6 EA       DEC $EA       ; ??? ($EA = #$FF)
$00/803D A9 01       LDA #$01
$00/803F 85 51       STA $51       ; ??? ($51 = #$01)
$00/8041 78          SEI           ; Disable Interrupts (again)
$00/8042 D8          CLD           ; Deactivate Decimal Mode (again)
$00/8043 4B          PHK           ; Push Bank Register
$00/8044 AB          PLB           ; Pull Data Bank Register
$00/8045 E2 20       SEP #$20
$00/8047 C2 10       REP #$10
$00/8049 A2 00 02    LDX #$0200
$00/804C 8E 5F 05    STX $055F     ; ???
$00/804F 9C 00 42    STZ $4200     ; Deactivate NMI / Auto-Joypad (again)
$00/8052 9C AF 05    STZ $05AF     ; Backup for $4200?
$00/8055 20 6A 80    JSR $806A     ; De-activate HDMAs, FBLANK, Clear Screen Destination Registers 

$00/8058 A9 01       LDA #$01      ; Activate Fast ROM (again)
$00/805A 8D 0D 42    STA $420D
$00/805D AF F0 FF 00 LDA $00FFF0   ; = #$FF
$00/8061 8F F3 00 00 STA $0000F3   ; ???
$00/8065 5C 91 80 80 JMP $808091   ; Jump to ???

$80/8069 Clear Byte

$00/8069 00                        ; Clear Byte for $80/801B

$80/806A De-activate HDMAs, FBLANK, Clear Screen Destination Registers

$00/806A 9C 0C 42    STZ $420C     ; De-activate HDMAs
$00/806D 9C B0 05    STZ $05B0     ; Backup for $420C?
$00/8070 9C 86 05    STZ $0586     ; Backup for $420C?
$00/8073 A9 80       LDA #$80
$00/8075 8D 00 21    STA $2100     ; FBLANK
$00/8078 8D 87 05    STA $0587     ; Backup for $2100
$00/807B 8D 6A 05    STA $056A     ; Backup for $2100
$00/807E 9C 2C 21    STZ $212C     ; Clear Main Screen Destinations
$00/8081 9C 2D 21    STZ $212D     ; Clear Subscreen Destinations
$00/8084 60          RTS

$80/8091 ???

$80/8091 22 4A A1 80 JSL $80A14A   ; Long-Jump to Deactivation of NMI, Auto-Joypad & HDMAs
$80/8095 A2 FF 1F    LDX #$1FFF    ; Set Stack to $7E:1FFF
$80/8098 9A          TXS
$80/8099 F4 00 00    PEA $0000     ; Direct Page Register = #$0000
$80/809C 2B          PLD
$80/809D 4B          PHK           ; Push Bank Register
$80/809E AB          PLB           ; Pull Data Bank Register
$80/809F 22 B6 A1 80 JSL $80A1B6   ; Jump to ???

$80/9D89 VRAM Clear

$80/9D89 8D 04 43    STA $4304     ; A: Source Bank (8 bit)
$80/9D8C 8E 02 43    STX $4302     ; X: Source Address (16 bit)
$80/9D8F 8C 16 21    STY $2116     ; Y: Destination VRAM Address (16 bit)
$80/9D92 A9 80       LDA #$80      ; Increment after writing $2119
$80/9D94 8D 15 21    STA $2115
$80/9D97 A9 09       LDA #$09      ; FIXED TRANSFER, 16 bit Transfer
$80/9D99 8D 00 43    STA $4300
$80/9D9C A9 18       LDA #$18      ; DMA Destination: $2118, VRAM
$80/9D9E 8D 01 43    STA $4301
$80/9DA1 A9 01       LDA #$01      ; Activate DMA
$80/9DA3 8D 0B 42    STA $420B
$80/9DA6 60          RTS

$80/9DA7 Long Jump to the WRAM-Clear-DMA

$80/9DA7 20 AB 9D    JSR $9DAB     ; Setup of the rest of the DMA and activation
$80/9DAA 6B          RTL

$80/9DAB WRAM-Clear-DMA

This Subroutine is half a setup for a DMA and starts the DMA. The first half of the setup has to be done before this Subroutine gets called. A call can be found at $80/801B. This is a fixed Transfer, so it's used for Clear Up DMAs. Furthermore, due to it's construction it is fixed to WRAM addresses. Before this subroutine is called, there are additional values that are loaded into certain registers:

A: Source Bank (8 bit)

X: Source Address (16 bit)

Y: Destination WRAM Address (16 bit)

Carry Bit Set: WRAM Bank $7F / Carry Bit Clear: WRAM Bank $7E

$80/9DAB 8D 04 43    STA $4304     ; A: Source Bank (8 bit)
$80/9DAE 8E 02 43    STX $4302     ; X: Source Address (16 bit)
$80/9DB1 8C 81 21    STY $2181     ; Y: Destination WRAM Address (16 bit)
$80/9DB4 2A          ROL A         ; Roll Carry-Bit in A
$80/9DB5 8D 83 21    STA $2183     ; If carry bit was set: Bank $7F, if clear: $7E
$80/9DB8 A9 08       LDA #$08      ; FIXED TRANSFER
$80/9DBA 8D 00 43    STA $4300
$80/9DBD A9 80       LDA #$80      ; DMA to Register $2180 --> to the WRAM address previously set up
$80/9DBF 8D 01 43    STA $4301
$80/9DC2 A9 01       LDA #$01      ; Activate DMA
$80/9DC4 8D 0B 42    STA $420B
$80/9DC7 60          RTS

$80/A14A Long Jump to Deactivate NMI, Auto-Joypad and HDMAs

$80/A14A 8B          PHB           ; Buffer Data Bank Register on Stack
$80/A14B 4B          PHK           ; Set Bank Register as Data Bank Register
$80/A14C AB          PLB
$80/A14D 20 52 A1    JSR $A152     ; Jump to Deactivation of NMI, Auto-Joypad & HDMAs
$80/A150 AB          PLB           ; Pull Original Data Bank Register
$80/A151 6B          RTL

$80/A152 Deactivate NMI, Auto-Joypad and HDMAs

$80/A152 9C 00 42    STZ $4200     ; Deactivate NMI / Auto-Joypad
$80/A155 9C AF 05    STZ $05AF     ; Backup for $4200?
$80/A158 9C 0C 42    STZ $420C     ; De-activate HDMAs
$80/A15B 9C B0 05    STZ $05B0     ; Backup for $420C?
$80/A15E 9C 86 05    STZ $0586     ; Backup for $420C?
$80/A161 60          RTS

$80/B26D Update Graphic Setup Registers

$80/B26D AD 6B 05    LDA $056B     ; BG Mode
$80/B270 8D 05 21    STA $2105
$80/B273 AD 6C 05    LDA $056C     ; Sprite sizes
$80/B276 8D 01 21    STA $2101
$80/B279 AE A6 05    LDX $05A6     ; Main Screen/Subscreen Destination (16 bit!)
$80/B27C 8E 2C 21    STX $212C
$80/B27F AE 8F 05    LDX $058F     ; BG1-4 Tileset Addresses (16 bit!)
$80/B282 8E 0B 21    STX $210B
$80/B285 AE 6D 05    LDX $056D     ; BG1/2 Tilemap Address
$80/B288 8E 07 21    STX $2107
$80/B28B AE 6F 05    LDX $056F     ; BG3/4 Tilemap Address
$80/B28E 8E 09 21    STX $2109
$80/B291 AE 81 05    LDX $0581     ; Color Addition Select
$80/B294 8E 30 21    STX $2130
$80/B297 AD 85 05    LDA $0585     ; Fixed Color Data
$80/B29A 8D 32 21    STA $2132
$80/B29D AD 84 05    LDA $0584     ; Fixed Color Data
$80/B2A0 8D 32 21    STA $2132
$80/B2A3 AD 83 05    LDA $0583     ; Fixed Color Data
$80/B2A6 8D 32 21    STA $2132
$80/B2A9 A0 00 00    LDY #$0000    ; Update the BG Scroll registers
$80/B2AC A2 71 05    LDX #$0571
$80/B2AF B5 00       LDA $00,x
$80/B2B1 99 0D 21    STA $210D,y
$80/B2B4 B5 01       LDA $01,x
$80/B2B6 99 0D 21    STA $210D,y
$80/B2B9 E8          INX
$80/B2BA E8          INX
$80/B2BB C8          INY
$80/B2BC C0 08 00    CPY #$0008
$80/B2BF D0 EE       BNE $EE       ; [$B2AF]
$80/B2C1 60          RTS

$80/B54D Clear Graphic Setup Registers

$80/B54D 9C 33 21    STZ $2133
$80/B550 A9 02       LDA #$02      ; 8x8 and 32x32 sprites
$80/B552 8D 01 21    STA $2101
$80/B555 8D 88 05    STA $0588
$80/B558 A9 09       LDA #$09      ; Mode 1, Priority Bit
$80/B55A 8D 05 21    STA $2105
$80/B55D 8D 89 05    STA $0589
$80/B560 A9 71       LDA #$71      ; BG1 Tilemap at $7000 in VRAM, h mirroring
$80/B562 8D 07 21    STA $2107
$80/B565 8D 8B 05    STA $058B
$80/B568 A9 79       LDA #$79      ; BG2 Tilemap at $7000 in VRAM, h/v mirroring
$80/B56A 8D 08 21    STA $2108
$80/B56D 8D 8C 05    STA $058C
$80/B570 A9 3C       LDA #$3C      ; BG3 Tilemap at $3C00 in VRAM
$80/B572 8D 09 21    STA $2109
$80/B575 8D 8D 05    STA $058D
$80/B578 A9 3C       LDA #$3C      ; BG3 Tilemap at $3C00 in VRAM
$80/B57A 8D 0A 21    STA $210A
$80/B57D 8D 8E 05    STA $058E
$80/B580 A9 00       LDA #$00      ; BG1/2 Tiles at $0000 in VRAM
$80/B582 8D 0B 21    STA $210B
$80/B585 8D 8F 05    STA $058F
$80/B588 A9 55       LDA #$55      ; BG3/4 Tiles at $5000 in VRAM
$80/B58A 8D 0C 21    STA $210C
$80/B58D 8D 90 05    STA $0590
$80/B590 A9 17       LDA #$17      ; BG1-3 and Sprites for Main Screen
$80/B592 8D 2C 21    STA $212C
$80/B595 8D A6 05    STA $05A6
$80/B598 A9 04       LDA #$04      ; BG4 for Subscreen
$80/B59A 8D 2D 21    STA $212D
$80/B59D 8D A7 05    STA $05A7
$80/B5A0 9C A8 05    STZ $05A8     ; Window Mask Registers
$80/B5A3 9C 2E 21    STZ $212E
$80/B5A6 9C A9 05    STZ $05A9
$80/B5A9 9C 2F 21    STZ $212F
$80/B5AC A9 02       LDA #$02
$80/B5AE 8D AA 05    STA $05AA     ; ???
$80/B5B1 A9 23       LDA #$23
$80/B5B3 8D AB 05    STA $05AB     ; ???
$80/B5B6 A9 E0       LDA #$E0
$80/B5B8 8D AC 05    STA $05AC     ; ???
$80/B5BB 8D AD 05    STA $05AD     ; ???
$80/B5BE 8D AE 05    STA $05AE     ; ???
$80/B5C1 9C 8A 05    STZ $058A     ; ???
$80/B5C4 60          RTS

$80/B673 Clear Registers, clear WRAM Bank $7F

$80/B673 A2 02 42    LDX #$4202    ; Clear $4202 to $420C
$80/B676 A9 0B       LDA #$0B
$80/B678 74 00       STZ $00,x
$80/B67A E8          INX
$80/B67B 3A          DEC A
$80/B67C D0 FA       BNE $FA    [$B678]
$80/B67E A9 FF       LDA #$FF      ; "Programmable I/O Port"
$80/B680 8D 01 42    STA $4201
$80/B683 A2 06 21    LDX #$2106    ; Clear $2106 to $2114
$80/B686 A9 0F       LDA #$0F
$80/B688 74 00       STZ $00,x
$80/B68A 74 00       STZ $00,x
$80/B68C E8          INX
$80/B68D 3A          DEC A
$80/B68E D0 F8       BNE $F8
$80/B690 A9 80       LDA #$80
$80/B692 95 00       STA $00,x  [$00:2115]
$80/B694 A9 01       LDA #$01
$80/B696 A2 1A 21    LDX #$211A    ; Mode 7 Settings
$80/B699 74 00       STZ $00,x     ; Clear a lot of Mode 7 Registers
$80/B69B 74 01       STZ $01,x
$80/B69D 95 01       STA $01,x
$80/B69F 74 02       STZ $02,x
$80/B6A1 74 02       STZ $02,x
$80/B6A3 74 03       STZ $03,x
$80/B6A5 74 03       STZ $03,x
$80/B6A7 74 04       STZ $04,x
$80/B6A9 95 04       STA $04,x
$80/B6AB 74 05       STZ $05,x
$80/B6AD 74 05       STZ $05,x
$80/B6AF 74 06       STZ $06,x
$80/B6B1 74 06       STZ $06,x
$80/B6B3 A2 23 21    LDX #$2123    ; Clear $2123 to $212E
$80/B6B6 A9 0C       LDA #$0C
$80/B6B8 74 00       STZ $00,x
$80/B6BA E8          INX
$80/B6BB 3A          DEC A
$80/B6BC D0 FA       BNE $FA    [$B6B8]
$80/B6BE A2 30 21    LDX #$2130
$80/B6C1 A9 30       LDA #$30
$80/B6C3 95 00       STA $00,x     ; $2130 - Color Addition
$80/B6C5 74 01       STZ $01,x     ; $2131 - Color Subtraction
$80/B6C7 A9 E0       LDA #$E0
$80/B6C9 95 02       STA $02,x     ; $2132 - Fixed Color DAta
$80/B6CB 74 03       STZ $03,x     ; $2133 - Screen Mode/Video Select

And then proceeds on the next part

$80/B6CD Set up $7F Clear DMA

$80/B6CD A0 00 00    LDY #$0000    ; Transfer $10000 Byte
$80/B6D0 8C 05 43    STY $4305
$80/B6D3 A0 00 00    LDY #$0000    ; Destination: #$7F:0000
$80/B6D6 38          SEC
$80/B6D7 A2 F1 B6    LDX #$B6F1    ; Position of the Clear Byte: $80/B6F1
$80/B6DA A9 80       LDA #$80
$80/B6DC 20 AB 9D    JSR $9DAB     ; Fixed WRAM Clear DMA

$80/B6DF Set up VRAM Clear DMA

$80/B6DF A0 00 00    LDY #$0000    ; Transfer $10000 Byte
$80/B6E2 8C 05 43    STY $4305
$80/B6E5 A0 00 00    LDY #$0000    ; (VRAM-)Destination: #0000
$80/B6E8 A2 F1 B6    LDX #$B6F1    ; Position of the Clear Byte: $80/B6F1
$80/B6EB A9 80       LDA #$80
$80/B6ED 20 89 9D    JSR $9D89     ; Fixed VRAM Clear DMA

$8F/83DB Sound-related stuff

$8F/83DB C5 FA       CMP $FA       ; ???
$8F/83DD D0 2B       BNE $2B    [$840A]
$8F/83DF A5 F5       LDA $F5
$8F/83E1 05 F6       ORA $F6
$8F/83E3 05 F7       ORA $F7
$8F/83E5 F0 21       BEQ $21       ; If $F5/$F6/$F7 are empty, exit
$8F/83E7 A5 F5       LDA $F5       ; Transfer buffer to $2140
$8F/83E9 8D 40 21    STA $2140
$8F/83EC A5 F6       LDA $F6       ; Transfer buffer to $2141
$8F/83EE 8D 41 21    STA $2141
$8F/83F1 A5 F7       LDA $F7       ; Transfer buffer to $2142
$8F/83F3 8D 42 21    STA $2142
$8F/83F6 64 F5       STZ $F5       ; Clear buffers $F5, $F6 and $F7
$8F/83F8 64 F6       STZ $F6
$8F/83FA 64 F7       STZ $F7
$8F/83FC A5 FA       LDA $FA       ; Transfer buffer to $2143
$8F/83FE 8D 43 21    STA $2143
$8F/8401 1A          INC A         ; Increment $FA value
$8F/8402 29 7F       AND #$7F      ; If it turned #$80 ==> #$00
$8F/8404 F0 FB       BEQ $FB       ; If #$00 ==> Increment again
$8F/8406 85 FA       STA $FA       ; Store back in $FA
$8F/8408 18          CLC           ; ???
$8F/8409 6B          RTL