Registrarse

[Rutina] [ASM] The implementation of ROCK CLIMB in BPRE

jiangzhengwenjz

Usuario mítico
This post will only deal with the "rock climb" selected by the player in the pokemon selection scene, so please do the script on your own if you want to use rock climb by talking to a rock.
This hack can judge the "playerfacing" and the number of the blocks you will climb.
1. Firstly we will repoint and expand the RAM location for TMs: (found from Development: More TMs/HMs - The PokéCommunity Forums Credit goes to Taの境界)
at 0x99E6A:
Código:
01 48 00 47 00 00 FF FF FF 08
FF FF FF 08 is the pointer to ram.asm (thumb mode +1):
ram.asm:
Código:
.text
.align 2
.thumb
.thumb_func
.global tm_slots_hack

main:
ldr r0, ram
str r0, [r1, #0x18]
mov r0, #0x3B
strb r0, [r1, #0x1c]
ldr r0, return
bx r0

.align
ram:.word 0x0203c000
return:.word 0x08099e74+1
0x203c000 is the free ram location.

2. Use JPAN's save_block_hack to save properly.
link: The PokéCommunity Forums - View Single Post - Research: FireRed Pokédex Hacking
Or use the patch instead: JPAN's Save Block Patch for FR » Romhack.me - ROM Hacking Community

3. tables and codes
1)repoint the table at 0x45A76E, replace 0c 00 with the move id of rock climb (swapped), and put 0c 00 after it as the end. (special move table)
2)repoint the table at 0x45A80C, add the move id (swapped). (TM table)
3)repoint the table at 0x45A37C and add an pointer to the description text. Please make it short like other texts in this table. (description text pointer table)
4)repoint the table at 0x45A618 and add [pointer to move name] A5 45 12 08 at the end of the table. (name_table)
5)copy these data to 0x3D4D6C as item picture and palette data.
Código:
C8 1C E9 08 64 1E E9 08
(in item picture & palette table)
6)copy these data to 0x3DEBCC as item data. (in item table)
Código:
C2 C7 A1 AA FF 00 00 00 00 00 00 00 00 00 5B 01 00 00 00 00 E5 75 48 08 01 00 04 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Please edit the description pointer to your new description!
7)edit the table at 0x252BC8 to enable some pokemon to learn the HM. This table is made up with bitfield, which means that you should convert it into binary to see the real data. 1 = learnable 0 = can't learn(TM learnable table)
For example, data for bulbasaur is "20 07 35 84 08 1E E4 00"
We divide it into 2 parts: "20 07 35 84" and "08 1E E4 00"
Then swap them, so we get "84350720" and "00E41E08"
Convert them into binary: "10000100001101010000011100100000" and "111001000001111000001000"
get them together in the reversed order:
"11100100000111100000100010000100001101010000011100100000"
It's in the order of "HM08, HM07,.........,TM01"
So if we want bulbusaur to learn HM09 we edit the higher part "111001000001111000001000"
We change it into "100111001000001111000001000"
Then we convert it into hexadecimal: "4E41E08"
swap it to get "08 1E E4 04" and we absolutely use it to replace "08 1E E4 00".
So you can see that we will always only deal with the higher part, I convert the lower part to just make things clearer

8)repoint the table at 0x45A788 and add [XX XX XX 08 0D 00 00 00] to the end of it. (function table)
XX XX XX 08 is the pointer to the following function: (thumb mode +1)
check.asm: (main ROCK CLIMB function)
Código:
.thumb
.align 2
push {r4, lr}
sub sp, sp, #4
mov r4, sp
add r4, #2
mov r0, sp
mov r1, r4
ldr r3, =0x0805C4F5
bl call_via_r3
mov r0, sp
mov r1, #0
ldrsh r0, [r0, r1]
mov r2, #0
ldrsh r1, [r4, r2]
ldr r2, =0x08058F79
bl call_via_r2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
cmp r0, #0x80 @behavior_byte
bne back
ldr r1, =0x03005024
ldr r0, =0x081248B1
str r0, [r1]
ldr r1, =0x0203B0C4
ldr r0, =0x08RRRRRR
str r0, [r1]
mov r0, #1
b real_back

back:
mov r0, #0

real_back:
add sp, sp, #4
pop {r4}
pop {r1}
bx r1

call_via_r3:
bx r3

call_via_r2:
bx r2
change 0x8RRRRRR to the offset+1 of the following function:(script_run function)
Código:
.thumb
.align 2
run_scr:
push {lr}
ldr r0, =0x0203B0A0
ldrb r0, [r0, #9]
ldr r1, =0x020386E0
lsl r0, r0, #0x18
lsr r0, r0, #0x18
str r0, [r1]
ldr r0, =0x08SSSSSS
ldr r1, =0x08069AE5
bl call_via_r1
pop {r0}
bx r0


call_via_r1:
bx r1
change 0x8SSSSSS to the offset of the following script:(ROCK CLIMB script)
Código:
#org @start
lockall
doanimation 0x25
waitstate
callasm 0x8kkkkkk //offset of code1+1
compare 0x800c 1
if1 1 @down
compare 0x800c 2
if1 1 @up
compare 0x800c 3
if1 1 @left
goto @right

#org @down
applymovement 0xff @movedown
waitmovement 0xff
callasm 0x8jjjjjj //offset of code2+1
compare 0x8004 0
if1 1 @downeventual
goto @down

#org @up
applymovement 0xff @moveup
waitmovement 0xff
callasm 0x8jjjjjj //offset of code2+1
compare 0x8004 0
if1 1 @upeventual
goto @up

#org @left
applymovement 0xff @moveleft
waitmovement 0xff
callasm 0x8jjjjjj //offset of code2+1
compare 0x8004 0
if1 1 @lefteventual
goto @left

#org @right
applymovement 0xff @moveright
waitmovement 0xff
callasm 0x8jjjjjj //offset of code2+1
compare 0x8004 0
if1 1 @righteventual
goto @right

#org @downeventual
applymovement 0xff @movedown
waitmovement 0xff
releaseall
end

#org @upeventual
applymovement 0xff @moveup
waitmovement 0xff
releaseall
end

#org @lefteventual
applymovement 0xff @moveleft
waitmovement 0xff
releaseall
end

#org @righteventual
applymovement 0xff @moveright
waitmovement 0xff
releaseall
end

#org @movedown
#raw 0x1D 0xfe

#org @moveup
#raw 0x1e 0xfe

#org @moveleft
#raw 0x1f 0xfe

#org @moveright
#raw 0x20 0xfe
change the 0x8kkkkkk & 0x8jjjjjj to the offset+1 of the following routines.

code1:(get "playerfacing" in var_0x800C)
Código:
.thumb
.align 2
push {lr}
ldr r0, =0x0805C6C5
bl linker
ldr r1, =0x020370D4
strh r0, [r1]
pop {pc}

linker:
bx r0
code2:(get the tile behavior byte)
Código:
.thumb
.align 2
push {r4, lr}
sub sp, sp, #4
mov r4, sp
add r4, #2
mov r0, sp
mov r1, r4
ldr r3, =0x0805C4F5
bl call_via_r3
mov r0, sp
mov r1, #0
ldrsh r0, [r0, r1]
mov r2, #0
ldrsh r1, [r4, r2]
ldr r2, =0x08058F79
bl call_via_r2
lsl r0, r0, #0x18
lsr r0, r0, #0x18
ldr r1, =0x020370C0
cmp r0, #0x80 @behavior_byte
bne back
mov r0, #1
b realback

back:
mov r0, #0

realback:
strh r0, [r1]
add sp, sp, #4
pop {r4, pc}

call_via_r2:
bx r2


call_via_r3:
bx r3
change the "0x80" in code2 and check.asm to the behavior byte you selected for the "rock climb" tile block.

4. fix the badge check routine so that it will check the 8th badge for the HM09 you added: (untested)
place this at 0x12461C:
Código:
00 48 00 47 MM MM MM 08
MM MM MM 08 is the pointer to the following routine: (thumb mode +1)
Código:
.thumb
.align 2
add r0, r4, #0
cmp r4, #7
blt checkbadge
mov r0, #7
cmp r4, #0xc
beq checkbadge
ldr r1, =0x8124627
add r1, #0x32
bx r1

checkbadge:
mov r1, #0x82
lsl r1, r1, #0x4
add r0, r0, r1
ldr r1, =0x8124627
bx r1
5. An example: (Haven't edited the text and name yet)


At last, I have to say that i haven't tried to teach the HM to a pokemon, so if there's any problem, simply follow a reply in Development: More TMs/HMs - The PokéCommunity Forums to delete the animation of learning TMs, but I think there's no problem)

As you can see, I have done the main part, but I can't ensure there's no glitch in this hack. So please contribute to it! I'm so tired with it so i won't touch it recently...

Edit: Here is a simple looping script to get all of the TMs and HMs as the cheats for the game won't work:
Código:
#org @start
lock
faceplayer
setvar 0x8004 0x121
goto @snippet2

//---------------
#org @snippet1
release
end

//---------------
#org @snippet2
additem 0x8004 0x1
addvar 0x8004 0x1
compare 0x8004 0x15C
if 0x1 goto @snippet1
goto @snippet2
 
Última edición:

Naren Jr.

Puto amo
Usuario de Platino
Wow es genial lo que acabas de conseguir!

Se que hablas ingles pero te comento español, realmente con esto nos da la posibilidad para hacer mas cosas o quizás usar nuestra imaginación para crear mejores movimientos

Gracias por el aporte!
 

Rata

Veterano en Gráficos
No entiendo mucho de scripts, por que no es mi área. Pero por lo que veo, como dice arriba @Naren Jr. , tal vez la rutina ASM que has posteado pueda usarse para usar más la imaginación en los movimientos del protagonista y darle un toque más "realista" al juego.

Saludos! (I hope u understand my message)
 

jiangzhengwenjz

Usuario mítico
Re: Respuesta: [ASM] The implementation of ROCK CLIMB in BPRE

No entiendo mucho de scripts, por que no es mi área. Pero por lo que veo, como dice arriba @Naren Jr. , tal vez la rutina ASM que has posteado pueda usarse para usar más la imaginación en los movimientos del protagonista y darle un toque más "realista" al juego.

Saludos! (I hope u understand my message)
Oops, I don't get some of your words because I use google translation xD

If you're speaking of the ROCK CLIMB triggered by talking to the rock, I can say that an ASM function created in the main thread can automatically check the behavior byte of the tile block the player is facing.
Therefore, everyone could create a "universal" ROCK CLIMB script by using this function, but I'm just too lazy to do it. :D

If you're speaking of the terrible movement, feel free to change the movement data. You can even use "overworld swapping" in it, which is included in JPAN's hacked engine and Jota's tutorial. The script I wrote is just an example, which is mostly for test.

I hope that you can understand my words, as the language difference is very annoying and google translate is always not satisfactory.

Saludos!
 
Última edición:

Laquin

Usuario mítico
Respuesta: Re: Respuesta: [ASM] The implementation of ROCK CLIMB in BPRE

Oops, I don't get some of your words because I use google translation xD

If you're speaking of the ROCK CLIMB triggered by talking to the rock, I can say that an ASM function created in the main thread can automatically check the behavior byte of the tile block the player is facing.
Therefore, everyone could create a "universal" ROCK CLIMB script by using this function, but I'm just too lazy to do it. :D

If you're speaking of the terrible movement, feel free to change the movement data. You can even use "overworld swapping" in it, which is included in JPAN's hacked engine and Jota's tutorial. The script I wrote is just an example, which is mostly for test.

I hope that you can understand my words, as the language difference is very annoying and google translate is always not satisfactory.

Saludos!
He says that with that ASM rutine, you can add lots of other HM's.

Fine work, jianzhen... ! I don't know if I'm gonna use it, but I'm sure there are people who are going to. Congrats :D

Sorry for my bad english :c
 
Última edición:

jiangzhengwenjz

Usuario mítico
Re: Respuesta: Re: Respuesta: [ASM] The implementation of ROCK CLIMB in BPRE

He says that with that ASM rutine, you can add lots of other MO's.

Fine work, jianzhen... ! I don't know if I'm gonna use it, but I'm sure there are people who are going to. Congrats :D

Sorry for my bad english :c
What is "MO"? Does it stand for "movements"?
If that's true, I have said something about it in the previous reply to Rata :)
 
Arriba