Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2017-05-17 07:34:13

Adam
Member
Registered: 2016-05-07
Post 76/93

Reusable TMs

I´m surprised that this hasn´t been asked yet, but how do you make TMs reusable? I know Rangi has made them reusable in his hack, so it seems to be possible.

I´m NOT using the disassembly, focussing instead on stuff like Hex and Wargrave´s [fantastic] tools.

Any help on that would be great!

Thanks!

Offline

#2 2017-05-17 08:05:46

Rangi
Member
Registered: 2016-05-09
Post 680/870

Re: Reusable TMs

I know I've answered this before, but turns out that was on /vp/ and in PMs. Edit: and also in the Patched Crystal hack thread. So, here's an explanation of this assembly update to make TMs reusable.

Wargrave's tools are great for editing the static tables of data, but if you plan to add whole new features (reusable TMs, Running Shoes, physical/special split, Fairy type, that kind of thing) you should really use assembly. You won't have to jump in and out of routines to insert code in the middle of things, there are no pointer or bank issues, and it's easier to debug.


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#3 2017-05-17 12:27:01

Adam
Member
Registered: 2016-05-07
Post 77/93

Re: Reusable TMs

Thanks for the reply. The only issue is that my hack is pretty much done. Barring a bunch of sprites and some other tweaks, there´s nothing much else. So Assembly isn´t really an option, as it´s too late. That´s why I was after an alternative.

I´m also pretty sure that reusable TMs are the only thing tha I need to do where Assembly would be the best way to do it.

If a non assembly method isn´t possible, I may just have to make the main ones available in later Pokemarts or something as an alternative. Not ideal though!

Offline

#4 2017-05-17 12:59:50

Rangi
Member
Registered: 2016-05-09
Post 681/870

Re: Reusable TMs

For a mostly complete feature, you can just nop out the ConsumeTM call and the quantity display code, and edit the item attribute table to add CANT_TOSS. If you're good enough with hex-editing I'm sure you could adapt the Game Corner and Mart code to prevent selling duplicates; if not, either give the TMs another way (like a new NPC script with a one-time money-for-TM deal), or just trust the player not to waste their money on extras. (Oh yeah, and change the Return TM lady so she won't give duplicates too.)

Edit: it looks like the new Mart code would be relatively simple to port. I added a check at the very beginning of MartAskPurchaseQuantity which jumps to a whole new code block if the item sold is a TM; and MartAskPurchaseQuantity is only called in one place in engine/mart.asm. So replace the call to it with a call to this ShimRoutine:

ShimRoutine:
; this is the check I added at the beginning of MartAskPurchaseQuantity
    ld a, [CurItem]
    cp TM01
    jp c, MartAskPurchaseQuantity ; go to the original routine
; now copy the .PurchaseQuantityOfTM code here
    push de
    ld hl, NumItems
    call CheckItem
    pop de
    ... ; et cetera

That's a single contiguous chunk of new code. You'd just need to find or make enough free space in the same bank as engine/mart.asm and put it in there. Then replace the "call MartAskPurchaseQuantity" with "call ShimRoutine". If you've been hex editing Z80 code, you've probably already had to do that sort of thing.

(Even if you're stuck developing your hack via hex editing, you can check out pokecrystal and use it to write new code, then compile it and copy the raw hex code into your ROM.)

That leaves the Game Corner code. Again, I added TM checks to the very beginning of certain code blocks (.doubleteam, .psychic, .hyperbeam, .Thunder, .Blizzard, .FireBlast), so replace any jumps or calls to those labels with calls to new shims that do the TM check, jump to the original label if false, and continue with the GoldenrodGameCornerPrizeVendor_AlreadyHaveTMScript/CeladonPrizeRoom_alreadyhavetm code if true.

Last edited by Rangi (2017-05-17 13:11:22)


Pokémon Polished Crystal (GitHub) — version 2.2.0 released
Pokémon Red★ and Blue★: Space World Edition (GitHub) — updated August 19!
Polished Map: pokered+pokecrystal map, tileset, and palette editor — version 3.5.1 released!

Offline

#5 2017-05-17 13:31:31

Adam
Member
Registered: 2016-05-07
Post 78/93

Re: Reusable TMs

That could be a good solution. I´ll give it a shot. Thanks!

Offline

Board footer

Powered by FluxBB