Skip to content

Commit

Permalink
EU support
Browse files Browse the repository at this point in the history
  • Loading branch information
StraDaMa committed Jan 8, 2017
1 parent 769963f commit 4fa26cf
Show file tree
Hide file tree
Showing 19 changed files with 156 additions and 84 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ Place a copy of Legend of Zelda Spirit Tracks in the unpack folder and name it "

Compatibility
-------------
This patch has only been tested with the US release of Spirit tracks. Support for other regions hasn't been tested so it may or may not work.
This patch has only been tested with the US and EU release of Spirit tracks. Support for other regions hasn't been tested so it may or may not work.
22 changes: 11 additions & 11 deletions attack/attack_arm9_freespace.asm
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
dpad_check_attack:
stmfd r13!,r5-r7,r14
bl 0x02088834;overwritten opcode
rbl 0x02088834,0x02088854;overwritten opcode
bl util_get_keys_pressed
tst r6,GBAKEY_B
movne r4,0x02
beq @@endroutine
bl util_get_keys_held
tst r6,0xF0;any direction key
tst r6,GBAKEY_DIRECTION
movne r4,0x03
@@endroutine:
ldmfd r13!,r5-r7,r15

dpad_check_spin:
stmfd r13!,r3-r7,r14
push r0-r2
bl 0x0218321C
rbl 0x0218321C,0x0218323C
pop r0-r2
bl util_get_keys_held
ldr r7, =GBAKEY_B | DSKEY_Y
ldr r7,=GBAKEY_B | DSKEY_Y
ands r6,r6,r7
cmp r7,r6
moveq r3,0x05
streq r3, [r0,0x58];write 5 here to do spin attack
streq r3,[r0,0x58];write 5 here to do spin attack
@@endroutine:
ldmfd r13!,r3-r7,r15

dpad_check_roll:
stmfd r13!,r0-r7,r14
strh r12, [r7,0x4C];overwritten opcode
strh r12,[r7,0x4C];overwritten opcode
bl util_get_keys_held
tst r6,GBAKEY_A
beq @@endroutine
tstne r6,0xF0
orrne r12,r12,0x02
strneh r12, [r7,0x4C]
strneh r12,[r7,0x4C]
movne r0,0x00
strne r0, [r7,0x1C]
strne r0,[r7,0x1C]
@@endroutine:
ldmfd r13!,r0-r7,r15

dpad_check_blow_mic:
stmfd r13!,r1-r7,r14
ldrb r0, [r0,0x05]
ldrb r0,[r0,0x05]
cmp r0,0x00
ldrne r0, =0x020B52E0
ldrneb r0, [r0,0x28]
rldrne r0,0x020B52E0,0x020B5300
ldrneb r0,[r0,0x28]
cmp r0,0x00
bleq util_get_keys_held
andeq r6,0x01
Expand Down
4 changes: 2 additions & 2 deletions attack/attack_overlay0000.asm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
;check if B is pressed to use sword
.org 0x02088960
.rorg 0x02088960,0x02088980
bl dpad_check_attack

.org 0x02070128
.rorg 0x02070128,0x02070148
stmfd r13!,r1-r7,r14
bl dpad_check_blow_mic
ldmfd r13!,r1-r7,r15
Expand Down
6 changes: 3 additions & 3 deletions attack/attack_overlay0017.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.org 0x020BD324
.rorg 0x020BD324,0x020BD344
bl dpad_check_roll
.org 0x020bcf5C
.rorg 0x020BCF5C,0x020BCF7C
bl dpad_check_spin
;eof
;eof
45 changes: 23 additions & 22 deletions compile.asm
Original file line number Diff line number Diff line change
@@ -1,44 +1,45 @@
.nds
.relativeinclude on

;edit the ARM9
.open "arm9_original.bin","arm9_compressed.bin", 0x02004000
.include macros.asm
.include "macros.asm"

;edit the ARM9
;uncompressed sizes: 0x48DD8,0x048DF8
.ropen "arm9_original.bin","arm9_compressed.bin",0x02004000,0x02004000
;end of ARM9 freespace
.org 0x02044B00
.rorg 0x02044B00,0x02044AD0
.area 0x288
.include util.asm
.include movement/movement_arm9_freespace.asm
.include interact/interact_arm9_freespace.asm
.include attack/attack_arm9_freespace.asm
.include "util.asm"
.include "movement/movement_arm9_freespace.asm"
.include "interact/interact_arm9_freespace.asm"
.include "attack/attack_arm9_freespace.asm"
.pool
.endarea
.close

;edit the overlay0000 (contains code for sword attacks)
;uncompressed size: 0x633E0
.open "overlay_0000_original.bin","overlay_0000_compressed.bin",0x02051AC0
.include attack/attack_overlay0000.asm
;uncompressed sizes: 0x633E0,0x633E0
.ropen "overlay_0000_original.bin","overlay_0000_compressed.bin",0x02051AC0,0x02051AE0
.include "attack/attack_overlay0000.asm"
.close

;edit the overlay0017 (contains code for movement from pressing on the screen)
;uncompressed size: 0x8900
.open "overlay_0017_original.bin","overlay_0017_compressed.bin",0x020BB640
.include movement/movement_overlay0017.asm
.include interact/interact_overlay0017.asm
.include attack/attack_overlay0017.asm
;uncompressed sizes: 0x8900,0x8900
.ropen "overlay_0017_original.bin","overlay_0017_compressed.bin",0x020BB640,0x020BB660
.include "movement/movement_overlay0017.asm"
.include "interact/interact_overlay0017.asm"
.include "attack/attack_overlay0017.asm"
.close

;edit the overlay0024 (contains code for pressing directions to do UI functions during gameplay)
;uncompressed size: 0x13E20
.open "overlay_0024_original.bin","overlay_0024_compressed.bin",0x020C4820
.include movement/movement_overlay0024.asm
;uncompressed sizes: 0x13E20,0x13E20
.ropen "overlay_0024_original.bin","overlay_0024_compressed.bin",0x020C4820,0x020C4840
.include "movement/movement_overlay0024.asm"
.close

;edit the overlay0093 (contains code for pressing directions for zelda phantom)
;uncompressed size: 0x134C0
.open "overlay_0093_original.bin","overlay_0093_compressed.bin",0x02165880
.include movement/movement_overlay0093.asm
;uncompressed sizes: 0x134C0
.ropen "overlay_0093_original.bin","overlay_0093_compressed.bin",0x02165880,0x021658A0
.include "movement/movement_overlay0093.asm"
.close
;eof
7 changes: 5 additions & 2 deletions compile.bat
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ if not exist .\unpack\data (
call prepare.bat
if errorlevel 1 exit 1
)
regionchecker.exe .\unpack\header.bin
set gameregion=%errorlevel%
if %errorlevel% equ -1 exit 1

armips compile.asm -sym ".\unpack\zelda_spirit_tracks_dpad.sym"
armips compile.asm -sym ".\unpack\zelda_spirit_tracks_dpad.sym" -equ current_region %gameregion%
blz -eo arm9_compressed.bin

makearm9.exe -c "arm9_compressed.bin" "unpack\arm9.bin"
makearm9.exe -c "arm9_compressed.bin" "arm9_header.bin" "unpack\arm9.bin"

blz -eo overlay_0000_compressed.bin
copy overlay_0000_compressed.bin .\unpack\overlay\overlay_0000.bin
Expand Down
Binary file modified fixy9.exe
Binary file not shown.
8 changes: 4 additions & 4 deletions interact/interact_arm9_freespace.asm
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ mov r0,r8
add r1,r13,0x00
mov r2,r5
mov r3,r6
bl 0x01FFD43C;write x,y positions to r1
rbl 0x01FFD43C,0x01FFD43C;write x,y positions to r1
;r13 now has the x,y positions of link
ldrh r6, [r13,0x00]
ldrh r7, [r13,0x02]
ldrh r1, [r4,0x44];get angle youre facing

mov r0,r8
bl 0x02078678;gets map angle?
rbl 0x02078678,0x02078698;gets map angle?
add r1,r0,r1;add map angle to current angle

asr r1,r1,0x04
ldr r2,=0x0203E93C;trig table
rldr r2,0x0203E93C,0x0203E964;trig table
add r2, r2, r1, lsl 0x02
ldrsh r0, [r2,0x02]
ldrsh r1, [r2,0x00]
Expand All @@ -37,7 +37,7 @@ strh r7, [r4,0x10]
; strh r1, [r4,0x16]
mov r0,r4
mov r1,0x02
bl 0x02014230;seems to be required for input
rbl 0x02014230,0x02014230;seems to be required for input
@@endroutine:
add r13,r13,0x10
mov r0,r8
Expand Down
4 changes: 2 additions & 2 deletions interact/interact_overlay0017.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.org 0x020BE4E4
.rorg 0x020BE4E4,0x020BE504
bl dpad_check_interact
;eof
;eof
96 changes: 82 additions & 14 deletions macros.asm
Original file line number Diff line number Diff line change
@@ -1,15 +1,83 @@
;Regions
REGION_US equ 0
REGION_EU equ 1

;KeyPad Macros
GBAKEY_A equ 1<<0
GBAKEY_B equ 1<<1
GBAKEY_SELECT equ 1<<2
GBAKEY_START equ 1<<3
GBAKEY_RIGHT equ 1<<4
GBAKEY_LEFT equ 1<<5
GBAKEY_UP equ 1<<6
GBAKEY_DOWN equ 1<<7
GBAKEY_R equ 1<<8
GBAKEY_L equ 1<<9
DSKEY_X equ 1<<10
DSKEY_Y equ 1<<11
;eof
GBAKEY_A equ 1<<0;0x01
GBAKEY_B equ 1<<1;0x02
GBAKEY_SELECT equ 1<<2;0x04
GBAKEY_START equ 1<<3;0x08
GBAKEY_RIGHT equ 1<<4;0x10
GBAKEY_LEFT equ 1<<5;0x20
GBAKEY_UP equ 1<<6;0x40
GBAKEY_DOWN equ 1<<7;0x80
GBAKEY_DIRECTION equ 0xF0;
GBAKEY_R equ 1<<8;0x100
GBAKEY_L equ 1<<9;0x200
DSKEY_X equ 1<<10;0x400
DSKEY_Y equ 1<<11;0x800

;Sets the output pointer depending on the game region
.macro .rorg,us_offset,eu_offset
.if current_region == REGION_US
.org us_offset
.elseif current_region == REGION_EU
.org eu_offset
.endif
.endmacro

;Open depending on the game region
.macro .ropen,original_file,output_file,us_offset,eu_offset
.if current_region == REGION_US
.open original_file,output_file,us_offset
.elseif current_region == REGION_EU
.open original_file,output_file,eu_offset
.endif
.endmacro

;Branches depending on game region
.macro rbl,us_offset,eu_offset
.if current_region == REGION_US
bl us_offset
.elseif current_region == REGION_EU
bl eu_offset
.endif
.endmacro

;Branches depending on game region
.macro rbne,us_offset,eu_offset
.if current_region == REGION_US
bne us_offset
.elseif current_region == REGION_EU
bne eu_offset
.endif
.endmacro

;Branches depending on game region
.macro rbeq,us_offset,eu_offset
.if current_region == REGION_US
beq us_offset
.elseif current_region == REGION_EU
beq eu_offset
.endif
.endmacro

;loads value to register depending on game region
.macro rldr,reg,us_offset,eu_offset
.if current_region == REGION_US
ldr reg,=us_offset
.elseif current_region == REGION_EU
ldr reg,=eu_offset
.endif
.endmacro

;loads value to register depending on game region
.macro rldrne,reg,us_offset,eu_offset
.if current_region == REGION_US
ldrne reg,=us_offset
.elseif current_region == REGION_EU
ldrne reg,=eu_offset
.endif
.endmacro

;eof
Binary file modified makearm9.exe
Binary file not shown.
8 changes: 4 additions & 4 deletions movement/movement_arm9_freespace.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bl util_get_keys_held
tst r6,GBAKEY_SELECT
;If select is pressed no movement
bne @@endroutine
ands r1,r6,0xF0
ands r1,r6,GBAKEY_DIRECTION
mov r3,0x07*0x04;7 entries 2*2 bytes each
ldr r2, =@@dpad_movement_angle_pool
@@key_lookup_start:
Expand All @@ -23,7 +23,7 @@ add r3,0x02
ldrh r1, [r2,r3];get angle for direction

mov r0,r8
bl 0x02078678;gets map angle?
rbl 0x02078678,0x02078698;gets map angle?
add r1,r0,r1

strh r1, [r4,0x44]
Expand All @@ -33,7 +33,7 @@ strh r2, [r4,0x5C]
strh r1, [r4,0x46]
ldmfd r13!,r0-r7,r15
@@endroutine:
bl 0x02096AD4;opcode being overwritten
rbl 0x02096AD4,0x02096AF4;opcode being overwritten
@@end2:
ldmfd r13!,r0-r7,r15

Expand Down Expand Up @@ -68,4 +68,4 @@ ands r0,r0,r1
cmp r0,r1
mov r15,r14

;eof
;eof
4 changes: 2 additions & 2 deletions movement/movement_overlay0017.asm
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
.org 0x020BE550
.rorg 0x020BE550,0x020BE570
bl dpad_movement
;eof
;eof
12 changes: 6 additions & 6 deletions movement/movement_overlay0024.asm
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
.org 0x020C5980;replace pressing right for quick menu
.rorg 0x020C5980,0x020C59A0;replace pressing right for quick menu
ldrh r0, [r0,0x20]
bl quickmenu_check_buttons
beq 0x020C5994
rbeq 0x020C5994,0x020C59B4

.org 0x020C5A04;replace pressing down to bring map down
.rorg 0x020C5A04,0x020C5A24;replace pressing down to bring map down
ldrh r0, [r0,0x20]
bl quickmap_check_buttons
beq 0x020C5A18
rbeq 0x020C5A18,0x020C5A38

.org 0x020C5B18;replace pressing up to check status
.rorg 0x020C5B18,0x020C5B38;replace pressing up to check status
ldrh r0, [r0,0x20]
bl quickstatus_check_buttons
bne 0x020C5BC4
rbne 0x020C5BC4,0x020C5BE4
;eof
4 changes: 2 additions & 2 deletions movement/movement_overlay0093.asm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.org 0x0217600C;replace pressing left for zelda controls
.rorg 0x0217600C,0x0217602C;replace pressing left for zelda controls
ldr r0, [r0,0x00]
bl phantom_zelda_check_buttons
bne 0x0217603C
rbne 0x0217603C,0x0217605C
;eof
2 changes: 1 addition & 1 deletion prepare.bat
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ echo Preparing source files
cd unpack
ndstool.exe -x input.nds -9 arm9.bin -7 arm7.bin -y9 y9.bin -y7 y7.bin -d data -y overlay -t banner.bin -h header.bin
cd ..\
makearm9.exe -x .\unpack\arm9.bin arm9_original.bin
makearm9.exe -x .\unpack\arm9.bin arm9_original.bin arm9_header.bin
blz.exe -d arm9_original.bin
copy .\unpack\overlay\overlay_0000.bin .\overlay_0000_original.bin
copy .\unpack\overlay\overlay_0017.bin .\overlay_0017_original.bin
Expand Down
Binary file added regionchecker.exe
Binary file not shown.

0 comments on commit 4fa26cf

Please sign in to comment.