Glitch City Laboratories Archives

Glitch City Laboratories closed on 1 September 2020 (announcement). This is an archived copy of a thread from Glitch City Laboratories Forums.

You can join Glitch City Research Institute to ask questions or discuss current developments.

You may also download the archive of this forum in .tar.gz, .sql.gz, or .sqlite.gz formats.

Emulation & ROM Hacking

Link via script to the Shuckle.asm? - Page 1

Link via script to the Shuckle.asm?

Posted by: Halfshadow
Date: 2019-07-10 08:05:41
Hi. I want to link to an asm part via script. Should be possible, after a givepokemon script command I want to link to these ASM:
https://github.com/pret/pokecrystal/blob/0ae5e9b3986dbbe64870dc1ad29a63b65b96200e/engine/events/shuckle.asm

starting from the "ld bc, PARTYMON_STRUCT_LENGTH" line, I know the binary address in the rom of that line.

If linked correctly should as example give the Berry to the obtained pokémon and the Mania OT and ID and the nickname.

There is a way to link to that line?

I want to write a similar ASM with a different ID and trainer name, but I don't want to write a new special command, only add the routine to set the ID and the trainer name, is possible?

My target is of give a legit GF Mew that could pass trough the pokétransfer, I need only of own the link to the asm. :)

Re: Link via script to the Shuckle.asm?

Posted by: Sherkel
Date: 2019-07-10 12:59:08
That's a good idea, given your recent question about the VC… :D

Anyway, much as I'm not a ROM hacker I feel obliged to give some sort of answer, so while it might not be the best one, I would probably write over ManiasHouse.asm with your new text, change the constants directly, and put the warp event to it in whatever map you want the "Mew House" to be in…there's definitely a way to do it without removing the Shuckle event if you're determined to have both, but not that I know offhand.

Re: Link via script to the Shuckle.asm?

Posted by: Torchickens
Date: 2019-07-10 15:00:25
In a nutshell: I'm unsure if linking to the script would be best sorry. It's certainly possible but takes space. as a lot of the registers are set in certain ways; i.e. if you skipped the level 15 Shuckle part it would have the Mania OT and ID or predef TryAddMonToParty may never run so you'd get nothing. If you skipped the Mania OT/ID you'd also have to skip the level 15 Shuckle part.

1. (closer to Shuckle script)
If you want to use the base Shuckle script; maybe you could use the far copy bytes to dump it into RAM where then you could simulate ROM patches by modifying the code in that copy.


2.
You may set your own parameters for TryAddMonToParty predef or directly modify RAM many times etc.

For customization/user friendliness, ACE can be used to fill the TM/HM pockets with x255 (in the competitive Coin Case thread somewhere, this may need to be modified for other methods e.g. wrong pocket TM. Due to the structure being quantity only and reasonably allowing 0-255, you can use the shortest possible codes you can program; with no playing around with dummy opcodes/operands. The operands here will be identifiable by a TM (e.g. Mew is TMX's quantity, ID is TMY (high) and TMZ (low) bytes.

As for the OT, in my name your mum with Coin Case video I set a custom destination; maybe you can adjust that to party pokemon 1's OT so when you finish input on the "x's name" menu it will apply changes there.

ld a,bank ld hl,address rst $08 allows you to call anywhere, like farbankswitch in RB(?? forgot its exact name).

Hope this helps. :)

Re: Link via script to the Shuckle.asm?

Posted by: Halfshadow
Date: 2019-07-11 18:08:10
I added a new routine to add a party pokémon from the Shuckle ASM and I found the script command to use it that is 3callasm.

I have only an issue, I reached to add GF OT name and ID and the all 15 DVS but when obtained the stats are wrong 'til I put it in the PC and come back. However the PkHex mark it as legit GF Mew, I have only the issue that the current stats are wrong when just obtained.

The ASM code I wrote is this:


GiveMew:
; Adding to the party.
xor a
ld [wMonType], a

; Level 5 Mew.
ld a, MEW
ld [wCurPartySpecies], a
ld a, 5
ld [wCurPartyLevel], a

predef TryAddMonToParty
jr nc, .NotGiven

; Caught data.
ld b, 0
farcall SetGiftPartyMonCaughtData

; SetDVs.
ld bc, PARTYMON_STRUCT_LENGTH
ld a, [wPartyCount]
dec a
push af
push bc
ld hl, wPartyMon1DVs
call AddNTimes
ld [hl], HIGH(DV_MAX_)
ld [hli], a
ld [hl], LOW(DV_MAX)
pop bc
pop af

; OT ID.
ld hl, wPartyMon1ID
call AddNTimes
ld a, HIGH(GF_OT_ID)
ld [hli], a
ld [hl], LOW(GF_OT_ID)

; Nickname.
ld a, [wPartyCount]
dec a
ld hl, wPartyMonNicknames
call SkipNames
ld de, SpecialMewNick
call CopyName2

; OT.
ld a, [wPartyCount]
dec a
ld hl, wPartyMonOT
call SkipNames
ld de, SpecialMewOT
call CopyName2
        ret

.NotGiven:
xor a
ld [wScriptVar], a
ret

SpecialMewOT:
db "GF@"

SpecialMewNick:
db "MEW@"


The code is however wrote in binary mode.

To add the DVs I added two FF bytes in the right position and if I save also according to PkHex the DVs are all 15. But seems that when just obtained the current stats aren't updated.

Can I add some code to fix it?

Re: Link via script to the Shuckle.asm?

Posted by: Sherkel
Date: 2019-07-12 00:06:08
If it's like RBY, it could just be that the DVs are correct (FF'd) but the stats when viewing it before putting it in the PC haven't been recalculated to reflect the change that happens after it's already in the party. I doubt anyone playing would notice, especially if it's at level 15.

Re: Link via script to the Shuckle.asm?

Posted by: Halfshadow
Date: 2019-07-12 09:06:08
Simply if the Mew DVs aren't updated you can see that it have 25 HP instead of 26 and stats like 15 instead of 16… And this is wrong… there isn't nothing to update immediately the visible stats?

Re: Link via script to the Shuckle.asm?

Posted by: Halfshadow
Date: 2019-07-16 11:03:50
UP nobody know how update the party pokémon stats after the change?

Re: Link via script to the Shuckle.asm?

Posted by: Sherkel
Date: 2019-07-16 11:39:16
Wouldn't calling or copying the bit that runs when putting something in the PC or Daycare work?

Re: Link via script to the Shuckle.asm?

Posted by: Halfshadow
Date: 2019-07-17 14:38:53
Nope, didn't work unfortunately… :(

Re: Link via script to the Shuckle.asm?

Posted by: Halfshadow
Date: 2019-07-17 16:00:23
Ok, I did it, I linked via script to the asm in move_mon.asm, after .room_in_party there is a .okay part, I linked to half sub routine when the 3 calls have to start, "call CopyBytes
call GetBaseData
call GetLastPartyMon" and then worked finally.

Re: Link via script to the Shuckle.asm?

Posted by: Sherkel
Date: 2019-07-17 17:13:19
Great! :) It was a bit hard to tell when looking at it which part specifically recalculated the stats.

Re: Link via script to the Shuckle.asm?

Posted by: Halfshadow
Date: 2019-07-17 17:15:35
Yep… But thank you, your idea of look at the daycare was helpful. Now I have to made the same also in G/S. I made a Mew legit event that you can transfer with the bank! :D