Skeetendo

’Cause all games were better on the GBC

You are not logged in.

#1 2011-07-01 21:55:52

Sherkel
Member
From: U.S. of A.
Registered: 2011-01-08
Post 21/43

ASM help

I'm making a routine so that instead of displaying the rival's name when facing your rival, it says "Kao." To do this, I made the trainer loading routine (at 0E:5C53) jump to a new routine (at 0E:7C50) in which the game checks if the opponent is the rival. If it is, the game goes to another routine (at 0E:7BE6) in which the rival' name is stored to unused bytes in RAM and is replaced with "Kao."
0E:5C53
call $7C50

0E:7C50
ld a,[$D059] ;check what opponent is
cp a,$E1 ;rival 1
jr z, $7C5C ;where it jumps
cp a,$F2 ;rival 2
ret
jp $7BE6 ;this is $7C5C

0E:7BE6
This part here is tedious and repetitive to write out; it writes each byte of the rival name to a and stores them in $DEE2-$DEE8
ld a,$8A ;letter K
ld [$D34A],a
ld a,$A0 ;letter a
ld [$D34B],a
ld a,$AE ;letter o
ld [$D34C],a
ld a,$50 ;end of name marker
ld [$D34D],a
ret

And yes, I do have a routing for restoring the rival name as well, but my issue right now is getting it to write "Kao" to the RAM.


Formerly known as Tombstoner

Offline

#2 2011-07-01 22:24:25

Sawakita
Administrator
Registered: 2010-10-16
Post 150/364

Re: ASM help

Sorry but what is your actual question or problem?

Anyway:

0E:7C50
ld a,[$D059] ;check what opponent is
cp a,$E1 ;rival 1
jr z, $7C5C ;where it jumps
cp a,$F2 ;rival 2
jr z, $7C5C
ret
jp $7BE6 ;this is $7C5C

↑ ↑ Isn't there a part missing here (which I added in bold)? ↑ ↑

---
How about this for the copy-name routine:

;
    push hl
    push de
    push bc
    ld hl,TextKao
    ld de,$d34a
    ld bc,LengthOfName
    call $00b5     ;this is an existing routine that copy data from hl to de (bc is number of bytes)
    pop bc
    pop de
    pop hl
    ret

Replace 'TextKao' with the pointer to where you stored the word "Kao" (including the value $50) in ROM (same bank please) and replace LengthOfName with, well, the length of the name (including the last byte $50). You can remove the "pushs" and "popps" if you don't need registers to be preserved.
The same can be done for the rival:

;
    ld hl,$D34a
    ld de,$DEE2
    ld bc,$0008
    call $00b5
;   ...

Offline

#3 2011-07-01 22:26:17

Sherkel
Member
From: U.S. of A.
Registered: 2011-01-08
Post 22/43

Re: ASM help

Thanks so much dude. I'll try this right now.
What happened with the first code was that it still showed the rival's name in battle. I'll try this one soon.


Formerly known as Tombstoner

Offline

#4 2011-07-02 00:14:34

Sherkel
Member
From: U.S. of A.
Registered: 2011-01-08
Post 23/43

Re: ASM help

Hmm, still says that the rival's name wants to battle. I found with the Memory Viewer that instead of writing "Kao" to D34A it writes gibberish, but it doesn't even show the gibberish, just the rival's name.
Perhaps I should have told you it's loaded at the trainer loading routine, replacing the link battle check?


Formerly known as Tombstoner

Offline

#5 2011-07-02 00:48:27

233/701

Re: ASM help

Try going through it with a debugger.

Tombstoner wrote:

Perhaps I should have told you it's loaded at the trainer loading routine, replacing the link battle check?

For the record, I’m not 100% sure that’s a link battle check.

#6 2011-07-02 12:16:45

Sawakita
Administrator
Registered: 2010-10-16
Post 151/364

Re: ASM help

I give a rapid look at the code and it seems that the Rival's name gets copied from $D34A to $D04A before the routine you edited, because then the program will read his name from $D04A. So, you should overwrite the area $D04A instead of $D34A. I didn't test it, but I'm pretty sure it would work (it also doesn't require you to backup original rival's name, since the area $D04A works as temporary buffer).

Last edited by Sawakita (2011-07-02 12:18:22)

Offline

#7 2011-07-02 13:29:39

tekcoR
Member
From: Celadon City
Registered: 2010-10-16
Post 59/165

Re: ASM help

Question: wouldn't it be easier to edit the "Sony" name for the rival to 'Kao' and skip the naming screen?


Cya

Offline

#8 2011-07-02 13:43:47

234/701

Re: ASM help

tekcoR wrote:

Question: wouldn't it be easier to edit the "Sony" name for the rival to 'Kao' and skip the naming screen?

Yes, but since he also restores the name afterwards, I assume he’s still using the rival name for something.

#9 2011-07-02 16:15:09

Sherkel
Member
From: U.S. of A.
Registered: 2011-01-08
Post 24/43

Re: ASM help

I am indeed.
Thanks for all your help, guys. I'll change that offset right now.
EDIT: Got it to work finally by simply writing "Kao" to the RAM area you gave.

Last edited by Sherkel (2011-07-02 16:34:51)


Formerly known as Tombstoner

Offline

Board footer

Powered by FluxBB