Starfall321
OnePunchStarfall
- 36
- Posts
- 8
- Years
- Seen Aug 3, 2016
Before anyone asking about doing this Kanto , pls take a look on this post
Although he don't really give us much explanation, his post definitely useful for further development.
The purpose of this thread is to port and fix the routine to Emerald. I cant do this alone, so any help is appreciated.
Let this picture speak everything
Done
In progress/Need help!!!
Things we need to do:
0. Expand the TM/HM move table
TMData=616040
Repoint the old table, quite easy to do so.
1.Expand the item number.(alternative)
2.Expand the pocket slot.
.text
.align 2
.thumb
.thumb_func
.global emerald_tm_slots_hack
main:
ldr r0, ram
str r0, [r1, #0x10]
mov r0, #0x80 @128 slot
strb r0, [r1, #0x14]
ldr r0, return
bx r0
.align
ram: .word 0x0203d900 @you will need 4x128= 512bytes
return: .word 0x080D6628+1
@Goto 0xD6620 :00 48 00 47 [reverse routine pointer+1]
2.5.Fix Bag maximum size
@credit to azurile13
.org 0x00000B38
malloc:
push {lr}
mov r1, r0
.org 0x001AB218
main:
push {r4, lr}
ldr r4, =0x0203CE74
mov r0, #0x81 @(maximum pocket size+1)
lsl r0, r0, #0x3
bl malloc
str r0, [r4, #0]
ldr r0, =0xC18 @(maximum pocket size+1)*24
bl malloc
str r0, [r4, #4]
pop {r4}
pop {r0}
bx r0
3.Fix TM/HM index routine.
.align 2
ldr r1, =0x17B @new TM01 index
sub r0, r0 ,r1
lsl r0, r0, #0x1
ldr r1, =0x08XXXXXX @TM/HM move table offset
add r0, r0, r1
ldrh r0, [r0]
bx lr
@Go to 0x1B6CFC: 00 00 00 00 00 49 08 47 CC BB AA 08, replace CC BB AA 08 to your asm offset+1 in reverse pointer.
4.Fix No.? thing
.align 2
ldr r0, =0x1F2 @HM01_INDEX-1
cmp r5, r0
bls isTM
sub r1, r5, r0
ldr r0, =0x02021CC4
ldr r2, =0x081AB3E8+1 @return_place1
bx r2
isTM:
ldr r0, =0x17A @TM01_INDEX-1
sub r1, r5, r0
ldr r0, =0x02021CC4
ldr r2, =0x081AB408+1 @return_place2
bx r2
@Go to 0x1AB3DA: 00 00 00 48 00 47 CC BB AA 08, replace CC BB AA 08 to your asm offset+1 in reverse pointer.
4.5.Fix 3 digit number not showing properly
@Fix 3 digit number not showing properly, thx azurile13 for hint
.align 2
cmp r1, #100
blt two_digit
mov r3, #3
b exit
two_digit:
mov r3, #2
exit:
ldr r2, =0x081ab410+1
bx r2
@Go to 0x1AB408: 00 4A 10 47 CC BB AA 08, replace CC BB AA 08 to your asm offset+1 in reverse pointer.
@Go to 0x1AB3EA: 02 23, to fix HM 2 digit not showing properly.
5.Fix HM icon thing
6.Fix TM/HM compatibility table
@again credit to azurile13, his routine for fire red seems more efficient than mine, so I choose to port it to emerald
.org 0x0006E02E
lsl r1, r1, #4 @or a mul for bytes not a power of 2(modify this line if you want more TM)
ldr r0, TMHM_compatibility @new TMHM compatibility table
add r0, r1
ldr r4, get_tm01
sub r4, r7, r4
lsr r1, r4, #0x3 @div 8, round down
ldrb r0, [r0, r1]
lsl r1, r4, #0x1D
lsr r1, r1, #0x1D
lsr r0, r1
lsl r0, r0, #0x1F
lsr r0, r0, #0x1F
pop {r4-r5}
pop {r1}
bx r1
.align
get_tm01: .word 0x17B
TMHM_compatibility: .word 0x0F00000
7. Fix "Booted up an HM."
I move the bunch of TM item data to expanded slot and move HM data backward so I could have extra 78 TM between them.
You can actually use alternative way to do this(without moving original item data), but you need to modify the routines above and the item arrangement routine yourself, so I suggest to use my way.
Although he don't really give us much explanation, his post definitely useful for further development.
The purpose of this thread is to port and fix the routine to Emerald. I cant do this alone, so any help is appreciated.
Let this picture speak everything
![[PokeCommunity.com] Porting TM/HM expansion to Emerald UPDATED!!! [PokeCommunity.com] Porting TM/HM expansion to Emerald UPDATED!!!](https://media.giphy.com/media/l41Yh936jNbbZhvyw/giphy.gif)
Done
In progress/Need help!!!
Things we need to do:
0. Expand the TM/HM move table
Spoiler:
TMData=616040
Repoint the old table, quite easy to do so.
1.Expand the item number.(alternative)
2.Expand the pocket slot.
Spoiler:
.text
.align 2
.thumb
.thumb_func
.global emerald_tm_slots_hack
main:
ldr r0, ram
str r0, [r1, #0x10]
mov r0, #0x80 @128 slot
strb r0, [r1, #0x14]
ldr r0, return
bx r0
.align
ram: .word 0x0203d900 @you will need 4x128= 512bytes
return: .word 0x080D6628+1
@Goto 0xD6620 :00 48 00 47 [reverse routine pointer+1]
2.5.Fix Bag maximum size
Spoiler:
@credit to azurile13
.org 0x00000B38
malloc:
push {lr}
mov r1, r0
.org 0x001AB218
main:
push {r4, lr}
ldr r4, =0x0203CE74
mov r0, #0x81 @(maximum pocket size+1)
lsl r0, r0, #0x3
bl malloc
str r0, [r4, #0]
ldr r0, =0xC18 @(maximum pocket size+1)*24
bl malloc
str r0, [r4, #4]
pop {r4}
pop {r0}
bx r0
3.Fix TM/HM index routine.
Spoiler:
.align 2
ldr r1, =0x17B @new TM01 index
sub r0, r0 ,r1
lsl r0, r0, #0x1
ldr r1, =0x08XXXXXX @TM/HM move table offset
add r0, r0, r1
ldrh r0, [r0]
bx lr
@Go to 0x1B6CFC: 00 00 00 00 00 49 08 47 CC BB AA 08, replace CC BB AA 08 to your asm offset+1 in reverse pointer.
4.Fix No.? thing
Spoiler:
.align 2
ldr r0, =0x1F2 @HM01_INDEX-1
cmp r5, r0
bls isTM
sub r1, r5, r0
ldr r0, =0x02021CC4
ldr r2, =0x081AB3E8+1 @return_place1
bx r2
isTM:
ldr r0, =0x17A @TM01_INDEX-1
sub r1, r5, r0
ldr r0, =0x02021CC4
ldr r2, =0x081AB408+1 @return_place2
bx r2
@Go to 0x1AB3DA: 00 00 00 48 00 47 CC BB AA 08, replace CC BB AA 08 to your asm offset+1 in reverse pointer.
4.5.Fix 3 digit number not showing properly
Spoiler:
@Fix 3 digit number not showing properly, thx azurile13 for hint
.align 2
cmp r1, #100
blt two_digit
mov r3, #3
b exit
two_digit:
mov r3, #2
exit:
ldr r2, =0x081ab410+1
bx r2
@Go to 0x1AB408: 00 4A 10 47 CC BB AA 08, replace CC BB AA 08 to your asm offset+1 in reverse pointer.
@Go to 0x1AB3EA: 02 23, to fix HM 2 digit not showing properly.
5.Fix HM icon thing
Spoiler:
.org 0x1AB5FC
.word -0x17B-120 @-new TM01 index-120
.word -0x17B-120 @-new TM01 index-120
6.Fix TM/HM compatibility table
Spoiler:
@again credit to azurile13, his routine for fire red seems more efficient than mine, so I choose to port it to emerald
.org 0x0006E02E
lsl r1, r1, #4 @or a mul for bytes not a power of 2(modify this line if you want more TM)
ldr r0, TMHM_compatibility @new TMHM compatibility table
add r0, r1
ldr r4, get_tm01
sub r4, r7, r4
lsr r1, r4, #0x3 @div 8, round down
ldrb r0, [r0, r1]
lsl r1, r4, #0x1D
lsr r1, r1, #0x1D
lsr r0, r1
lsl r0, r0, #0x1F
lsr r0, r0, #0x1F
pop {r4-r5}
pop {r1}
bx r1
.align
get_tm01: .word 0x17B
TMHM_compatibility: .word 0x0F00000
7. Fix "Booted up an HM."
Spoiler:
@Fix "Booted up an HM."
.align 2
ldrh r1, [r0]
ldr r0, HM01_index
cmp r1, r0
bls TMstring
ldr r2, HMstring_return
bx r2
TMstring:
ldr r2, TMstring_return
bx r2
.align
HM01_index: .word 0x1F2
HMstring_return: .word 0x080FDF5A+1
TMstring_return: .word 0x080FDF74+1
@Go to 0xFDF50: 00 4A 10 47 CC BB AA 08, replace CC BB AA 08 to your asm offset+1 in reverse pointer.
.align 2
ldrh r1, [r0]
ldr r0, HM01_index
cmp r1, r0
bls TMstring
ldr r2, HMstring_return
bx r2
TMstring:
ldr r2, TMstring_return
bx r2
.align
HM01_index: .word 0x1F2
HMstring_return: .word 0x080FDF5A+1
TMstring_return: .word 0x080FDF74+1
@Go to 0xFDF50: 00 4A 10 47 CC BB AA 08, replace CC BB AA 08 to your asm offset+1 in reverse pointer.
I move the bunch of TM item data to expanded slot and move HM data backward so I could have extra 78 TM between them.
You can actually use alternative way to do this(without moving original item data), but you need to modify the routines above and the item arrangement routine yourself, so I suggest to use my way.
Last edited: