Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2014-08-15 15:16:45

frz hax
Member
Registered: 2014-08-06
Post 7/43

Rock smash

I'm confused about the rock smash script. In PKSV they all say jumpstd 0xF which in a hex editor is 0C 0F. So where is it that you can change the pokemon found in these rocks because the hex numbers of krabby and shuckle aren't there?

Thank You

Offline

#2 2014-08-16 07:25:05

Miksy91
Member
Registered: 2010-10-16
Post 2,129/2,317

Re: Rock smash

Those 0C script codes are used to call scripts through a 3-byte pointer table starting at 0x100000.
For example for code 0C 0F 00, the script called is at 0x100158 because we have bytes "40 58 41" at address 0x10002D, and
0x100000 + 0xF * 0x3 = 0x10002D.

The script (starting at 0x100158) itself contains this part;

#org 0xCF33
'-----------------------------------
3callasm 0x474903
2writetext 0x4F59 ' 0xCF59
loadmovesprites
special 0x3A
playsound 0x1B
earthquake 0x54
applymoveother 0x4F56 ' 0xCF56 Applies movement to last talked
disappear 0xFE
3callasm 0x63A12E
copybytetovar 0xD117 ' 0xFFFFFFFF
if false 0x4F55 ' 0xCF55
clearfight
startbattle
returnafterbattle
end

#org 0xCF55
'-----------------------------------
end

So as you can see, a battle starts only if the value in $D117 is not equal to 00. As nothing in the "script part" itself writes to that address, the only possibility of the value changing is through one of those asm routines called within the script. And it's quite likely the change of the value in that address happens during "3callasm 0x63A12E" which is right before the point when we load the value from D117 to RAM (what would be the purpose of accessing this routine now if we didn't call it to affect the value that we check next?).

So anyway, that asm routine starts at address 2E:63A1 (0x2E * 0x4000 + 0x63A1 - 0x4000). If you follow the routine, you can see that it writes 00 to D117 (because xor a,a changes the value of register a to 00) first, and eventually if it reaches "call $6529", and through that subroutine, address 2E:653C, it changes the value in address D117 again to something not equal to zero.

I couldn't figure out just by taking a close look at that routine, how the pokemon you encounter are determined, but you could follow the routine with bgb's debugger and try to find out for yourself. (Or take a look at pokecrystal disassembly in which we may have a very similar routine to this one).

Last edited by Miksy91 (2014-08-16 07:25:56)

Offline

#3 2014-09-21 11:54:12

frz hax
Member
Registered: 2014-08-06
Post 31/43

Re: Rock smash

I still don't undrstand this. ASM is new to me. It's going to be such a small change but it has taken me a very long time to figure it out. Surely there is a byte which represents krabby or shuckle's index number and then I just change it to something else?

Offline

#4 2014-09-21 12:06:18

Crystal_
Member
From: Spain
Registered: 2012-09-16
Post 212/437
Website

Re: Rock smash

There are a total of 13 tables that contain data related to the pokemon that appear in headbutt trees and in rock smash boulders. The 13th table is the one that corresponds to rock smash encounters while the other 12 are used for headbutt encounters (different maps load data from different tables, although if i remember well some are unused). Since there's only one table for rock smash encounters, every map uses it.

Gold / Silver: 0xBA47C
Crystal: 0xB82FA 

These are the addresses for the first headbutt table. You'll have to skip all of them to eventually reach rock smash encounter data:

WildRockMonTable:
db 90, KRABBY, 15 ; %, species, level
db 10, SHUCKLE, 15 ; %, species, level
db $ff ; end

Offline

#5 2014-09-21 18:30:21

frz hax
Member
Registered: 2014-08-06
Post 32/43

Re: Rock smash

xD I love you so much! Now you can finally catch fossil pokemon. xD

Offline

Board footer

Powered by FluxBB