You are not logged in.
Pages: 1
Hello! In my hack using pokered, I decided that similar to how Yellow and GSC does it, I wanted to make it so that using Surf with Pikachu gives you a different surfing sprite than the traditional Seel (as I have included a surfing Pikachu) ... additionally, I thought it would be cool to make it so surfing on a Lapras would give you the sprite from GSC as well.
So far, I started by copying code wholesale from yellow in the following places. In start_sub_menus.asm, I replaced the surf routine with the following code (Ignore the badge flag bit, I changed it to react to the boulder badge so I could just test early on)
.surf
bit 0,a ; 6 does the player have the Soul Badge?
jp z,.newBadgeRequired
callba CheckForForcedBikeSurf
ld hl,wd728
bit 1,[hl]
res 1,[hl]
jp z,.loop
ld a, [wcf91]
cp PIKACHU ; is this surfing pikachu?
jr z, .surfingPikachu
ld a, $1
jr .continue
.surfingPikachu
ld a, $2
.continue
ld [wd473], a
ld a,SURFBOARD
ld [wcf91],a
ld [wd152],a
call UseItem
ld a,[wcd6a]
and a
jr z,.reloadNormalSprite
call GBPalWhiteOutWithDelay3
jp .goBackToMap
.reloadNormalSprite
xor a
ld [wd473], a
jp .loop
Additionally, I had to make some updates to overworld.asm, starting by changing the "jp z, LoadSurfingPlayerSpriteGraphics" under .determineGraphics to "jp z, LoadSurfingPlayerSpriteGraphics2"
I then copied the following code over from Yellow:
LoadWalkingPlayerSpriteGraphics:: ; 0d5e (0:0d5e)
; new sprite copy stuff
xor a
ld [wd473],a
ld b,BANK(RedSprite)
ld de,RedSprite ; $4180
jr LoadPlayerSpriteGraphicsCommon
LoadSurfingPlayerSpriteGraphics2:: ; 0d69 (0:0d69)
ld a,[wd473]
and a
jr z,.asm_0d75
dec a
jr z,LoadSurfingPlayerSpriteGraphics
dec a
jr z,.asm_0d7c
.asm_0d75
ld a,[wd472]
bit 6,a
jr z,LoadSurfingPlayerSpriteGraphics
.asm_0d7c
ld b,BANK(SurfingPikachuSprite)
ld de,SurfingPikachuSprite ; 3f:6def
jr LoadPlayerSpriteGraphicsCommon
LoadSurfingPlayerSpriteGraphics:: ; 0d83 (0:0d83)
ld b,BANK(RedSprite) ; not sure, but probably same bank (5)
ld de,SeelSprite
jr LoadPlayerSpriteGraphicsCommon
LoadBikePlayerSpriteGraphics:: ; 0d8a (0:0d8a)
ld b,BANK(RedCyclingSprite)
ld de,RedCyclingSprite
LoadPlayerSpriteGraphicsCommon:: ; 0d8f (0:0d8f)
ld hl,vNPCSprites
push de
push hl
push bc
ld c, $c
call CopyVideoData
pop bc
pop hl
pop de
ld a,$c0
add e
ld e,a
jr nc,.noCarry
inc d
.noCarry
set 3,h
ld c,$c
jp CopyVideoData
Now, on its own, this all works perfect! Pikachu functions with its own surfing sprite, and that part of the hack has been satisfied. You could even do this yourself if you wanted to have similar functionality! However, I wish to add in the code for Lapras as well, and that part is where I am stumped. In theory it seems very simple, but I am realizing that I don't entirely understand how these routines work 100%
Now, obviously a sensible starting point would be to modify the .surf routine which checks for Pikachu and jumps to a routine which does ld a, $2 ... if the Pokemon is NOT Pikachu, it continues with the normal routine and sets ld a, $1
Okay, seems simple. so I would change this bit, probably, from:
cp PIKACHU ; is this surfing pikachu?
jr z, .surfingPikachu
ld a, $1
jr .continue
.surfingPikachu
ld a, $2
....into an updated routine:
cp PIKACHU ; is this surfing pikachu?
jr z, .surfingPikachu
cp LAPRAS
jr z, .surfingLapras
ld a, $1
jr .continue
.surfingPikachu
ld a, $2
.surfingLapras
ld a, $3
I assume setting it to $3 is the natural thing to do, but this is about as far as my understanding goes. I'm not actually sure where these values are being passed and what affect they have on the other routines, other than presuming it directly connects to the LoadSurfingPlayerSpriteGraphics2 routine I added in overworld.asm .... that is the part that loses me. Surely from here, it would just require adding an additional routine to that bit to say "show Lapras graphics too!" but I'm realizing I have no actual understanding of how the LoadSurfingPlayerSpriteGraphics2 in overworld.asm is actually working or how it connects to the .surf routine...I can presume a little, but my ASM is still very rudimentary, so you'll have to be patient with me :( I'm not grasping it 100%
if anyone could possibly help explain to me what this routine is doing and what I should be modifying to add the functionality I want, that would really help me a lot! Also, I haven't fully tested out this hack yet, so I have no idea if things like the currents for Seafoam cause any issues yet....I noticed that Yellow has a code to check for Pikachu in this case, would this present issues in my hack for not copying this as well? Thanks!
Last edited by KeiTaRo (2016-05-02 06:18:27)
Offline
First thing, your last code snippet needs some adjustments.
cp PIKACHU ; is this surfing pikachu?
jr z, .surfingPikachu
cp LAPRAS
jr z, .surfingLapras
ld a, $1
jr .continue
.surfingPikachu
ld a, $2
.surfingLapras
ld a, $3
should instead be something like
cp PIKACHU ; is this surfing pikachu?
jr z, .surfingPikachu
cp LAPRAS
jr z, .surfingLapras
ld a, $1
jr .continue
.surfingPikachu
ld a, $2
jr .continue
.surfingLapras
ld a, $3
Notice that once 2 is loaded into a to signify that the Pikachu sprite needs to be loaded, your old code immediately put 3 into a because you didn't write the code to skip ahead.
Secondly, I think I can help explain LoadSurfingPlayerSpriteGraphics2.
LoadSurfingPlayerSpriteGraphics2:: ; 0d69 (0:0d69)
ld a,[wd473] ;;; "surfing sprite id"
and a ;;; this will set the zero flag if a is 0
jr z,.asm_0d75
dec a ;;; this will set the zero flag if a was 1
jr z,LoadSurfingPlayerSpriteGraphics
dec a ;;; if a was originally 2, this second 'dec a' will make it 0 and set the zero flag
jr z,.asm_0d7c ;;; jump to loading the Pikachu sprite
.asm_0d75
ld a,[wd472]
bit 6,a
jr z,LoadSurfingPlayerSpriteGraphics
.asm_0d7c
ld b,BANK(SurfingPikachuSprite)
ld de,SurfingPikachuSprite ; 3f:6def
jr LoadPlayerSpriteGraphicsCommon
You could modify this slightly to account for 3 representing Lapras:
LoadSurfingPlayerSpriteGraphics2:: ; 0d69 (0:0d69)
ld a,[wd473] ;;; "surfing sprite id"
and a ;;; this will set the zero flag if a is 0
jr z,.asm_0d75
dec a ;;; this will set the zero flag if a was 1
jr z,LoadSurfingPlayerSpriteGraphics
dec a ;;; if a was originally 3, this third 'dec a' will make it 0 and set the zero flag
jr z,.asm_0d7c ;;; jump to loading the Pikachu sprite
dec a ;;; dec a one more time
jr z, .loadLaprasSurfingSprite ;;; if the zero flag is set, a must have originally been 3
.asm_0d75
ld a,[wd472]
bit 6,a
jr z,LoadSurfingPlayerSpriteGraphics
.asm_0d7c
ld b,BANK(SurfingPikachuSprite)
ld de,SurfingPikachuSprite ; 3f:6def
jr LoadPlayerSpriteGraphicsCommon
Then .loadLaprasSurfingSprite could be written similarly to how the other sprites are loaded.
Offline
Finally got a chance to try this out. Your explanation of the code was excellent, I completely see where I was heading in the wrong direction. Anyway, your code suggestion worked perfectly, and even better is that I understand why it did, so small victories I guess :D thanks for your help as usual!
Offline
No problem! Yeah, it always feels good to start getting a real grasp on assembly. Feel free to let me know anything else you could use some help with!
Offline
Pages: 1