2017-12-16 02:22:26 +00:00
|
|
|
_SwitchPartyMons:
|
2018-07-29 05:27:33 +00:00
|
|
|
ld a, [wSwitchMon]
|
2017-12-16 02:22:26 +00:00
|
|
|
dec a
|
2020-11-04 00:53:07 +00:00
|
|
|
ld [wSwitchMonFrom], a
|
2017-12-16 02:22:26 +00:00
|
|
|
ld b, a
|
|
|
|
ld a, [wMenuCursorY]
|
|
|
|
dec a
|
2020-11-04 00:53:07 +00:00
|
|
|
ld [wSwitchMonTo], a
|
2017-12-16 02:22:26 +00:00
|
|
|
cp b
|
|
|
|
jr z, .skip
|
|
|
|
call .SwapMonAndMail
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonFrom]
|
2017-12-16 02:22:26 +00:00
|
|
|
call .ClearSprite
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonTo]
|
2017-12-16 02:22:26 +00:00
|
|
|
call .ClearSprite
|
|
|
|
.skip
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.ClearSprite:
|
2017-12-16 02:22:26 +00:00
|
|
|
push af
|
|
|
|
hlcoord 0, 1
|
|
|
|
ld bc, 2 * SCREEN_WIDTH
|
|
|
|
call AddNTimes
|
|
|
|
ld bc, 2 * SCREEN_WIDTH
|
|
|
|
ld a, " "
|
|
|
|
call ByteFill
|
|
|
|
pop af
|
2018-01-30 19:52:46 +00:00
|
|
|
ld hl, wVirtualOAMSprite00
|
2018-01-10 18:47:57 +00:00
|
|
|
ld bc, 4 * SPRITEOAMSTRUCT_LENGTH
|
2017-12-16 02:22:26 +00:00
|
|
|
call AddNTimes
|
2018-01-10 18:47:57 +00:00
|
|
|
ld de, SPRITEOAMSTRUCT_LENGTH
|
|
|
|
ld c, 4
|
2017-12-16 02:22:26 +00:00
|
|
|
.gfx_loop
|
2018-01-10 18:47:57 +00:00
|
|
|
ld [hl], SCREEN_WIDTH_PX ; y (off-screen)
|
2017-12-16 02:22:26 +00:00
|
|
|
add hl, de
|
|
|
|
dec c
|
|
|
|
jr nz, .gfx_loop
|
|
|
|
ld de, SFX_SWITCH_POKEMON
|
|
|
|
call WaitPlaySFX
|
|
|
|
ret
|
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.SwapMonAndMail:
|
2017-12-16 02:22:26 +00:00
|
|
|
push hl
|
|
|
|
push de
|
|
|
|
push bc
|
2018-01-23 22:39:09 +00:00
|
|
|
ld bc, wPartySpecies
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonTo]
|
2017-12-16 02:22:26 +00:00
|
|
|
ld l, a
|
2020-11-09 20:17:03 +00:00
|
|
|
ld h, 0
|
2017-12-16 02:22:26 +00:00
|
|
|
add hl, bc
|
|
|
|
ld d, h
|
|
|
|
ld e, l
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonFrom]
|
2017-12-16 02:22:26 +00:00
|
|
|
ld l, a
|
2020-11-09 20:17:03 +00:00
|
|
|
ld h, 0
|
2017-12-16 02:22:26 +00:00
|
|
|
add hl, bc
|
|
|
|
ld a, [hl]
|
|
|
|
push af
|
|
|
|
ld a, [de]
|
|
|
|
ld [hl], a
|
|
|
|
pop af
|
|
|
|
ld [de], a
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonTo]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMon1Species
|
2017-12-16 02:22:26 +00:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
2020-10-29 18:45:40 +00:00
|
|
|
ld de, wSwitchMonBuffer
|
2017-12-16 02:22:26 +00:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonFrom]
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMon1
|
2017-12-16 02:22:26 +00:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
pop de
|
|
|
|
push hl
|
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
pop de
|
2020-10-29 18:45:40 +00:00
|
|
|
ld hl, wSwitchMonBuffer
|
2017-12-16 02:22:26 +00:00
|
|
|
ld bc, PARTYMON_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonTo]
|
2021-03-17 20:16:02 +00:00
|
|
|
ld hl, wPartyMonOTs
|
2017-12-16 02:22:26 +00:00
|
|
|
call SkipNames
|
|
|
|
push hl
|
2020-10-29 18:45:40 +00:00
|
|
|
call .CopyNameToSwitchMonBuffer
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonFrom]
|
2021-03-17 20:16:02 +00:00
|
|
|
ld hl, wPartyMonOTs
|
2017-12-16 02:22:26 +00:00
|
|
|
call SkipNames
|
|
|
|
pop de
|
|
|
|
push hl
|
|
|
|
call .CopyName
|
|
|
|
pop de
|
2020-10-29 18:45:40 +00:00
|
|
|
ld hl, wSwitchMonBuffer
|
2017-12-16 02:22:26 +00:00
|
|
|
call .CopyName
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMonNicknames
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonTo]
|
2017-12-16 02:22:26 +00:00
|
|
|
call SkipNames
|
|
|
|
push hl
|
2020-10-29 18:45:40 +00:00
|
|
|
call .CopyNameToSwitchMonBuffer
|
2018-01-23 22:39:09 +00:00
|
|
|
ld hl, wPartyMonNicknames
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonFrom]
|
2017-12-16 02:22:26 +00:00
|
|
|
call SkipNames
|
|
|
|
pop de
|
|
|
|
push hl
|
|
|
|
call .CopyName
|
|
|
|
pop de
|
2020-10-29 18:45:40 +00:00
|
|
|
ld hl, wSwitchMonBuffer
|
2017-12-16 02:22:26 +00:00
|
|
|
call .CopyName
|
|
|
|
ld hl, sPartyMail
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonTo]
|
2017-12-16 02:22:26 +00:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
push hl
|
2020-10-29 18:45:40 +00:00
|
|
|
ld de, wSwitchMonBuffer
|
2017-12-16 02:22:26 +00:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
ld a, BANK(sPartyMail)
|
2020-06-17 21:03:38 +00:00
|
|
|
call OpenSRAM
|
2017-12-16 02:22:26 +00:00
|
|
|
call CopyBytes
|
|
|
|
ld hl, sPartyMail
|
2020-11-04 00:53:07 +00:00
|
|
|
ld a, [wSwitchMonFrom]
|
2017-12-16 02:22:26 +00:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call AddNTimes
|
|
|
|
pop de
|
|
|
|
push hl
|
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
pop de
|
2020-10-29 18:45:40 +00:00
|
|
|
ld hl, wSwitchMonBuffer
|
2017-12-16 02:22:26 +00:00
|
|
|
ld bc, MAIL_STRUCT_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
call CloseSRAM
|
|
|
|
pop bc
|
|
|
|
pop de
|
|
|
|
pop hl
|
|
|
|
ret
|
|
|
|
|
2020-10-29 18:45:40 +00:00
|
|
|
.CopyNameToSwitchMonBuffer:
|
|
|
|
ld de, wSwitchMonBuffer
|
2017-12-16 02:22:26 +00:00
|
|
|
|
2018-06-24 14:09:41 +00:00
|
|
|
.CopyName:
|
2017-12-16 02:22:26 +00:00
|
|
|
ld bc, NAME_LENGTH
|
|
|
|
call CopyBytes
|
|
|
|
ret
|