diff options
author | Remy Oukaour <remy.oukaour@gmail.com> | 2017-12-24 19:35:35 -0500 |
---|---|---|
committer | Remy Oukaour <remy.oukaour@gmail.com> | 2017-12-24 19:35:35 -0500 |
commit | 7d4486e6a34a5163575400f21e806471be496e3d (patch) | |
tree | c0cc5f242b92420325d12a9cdedd6c1a3bcc3a4f /engine/routines/switchpartymons.asm | |
parent | 15f1fc7c6ce0444ebfd87b1edc22da0ffd61c667 (diff) |
Remove all code from main.asm (some labeled INCBINs, like out-of-context graphics, are still present)
engine/routines/ stores isolated out-of-context routines as individual files. It might be preferable later to append them to their related engine/ files in unique little SECTIONs, relying on the linkerscript to place them appropriately; or some other organization method. In the meantime, they're now easily findable apart from main.asm's other content.
Diffstat (limited to 'engine/routines/switchpartymons.asm')
-rw-r--r-- | engine/routines/switchpartymons.asm | 145 |
1 files changed, 145 insertions, 0 deletions
diff --git a/engine/routines/switchpartymons.asm b/engine/routines/switchpartymons.asm new file mode 100644 index 000000000..cde9c82b2 --- /dev/null +++ b/engine/routines/switchpartymons.asm @@ -0,0 +1,145 @@ +_SwitchPartyMons: + ld a, [wd0e3] + dec a + ld [Buffer3], a + ld b, a + ld a, [wMenuCursorY] + dec a + ld [Buffer2], a + cp b + jr z, .skip + call .SwapMonAndMail + ld a, [Buffer3] + call .ClearSprite + ld a, [Buffer2] + call .ClearSprite +.skip + ret + +.ClearSprite: ; 50f34 (14:4f34) + push af + hlcoord 0, 1 + ld bc, 2 * SCREEN_WIDTH + call AddNTimes + ld bc, 2 * SCREEN_WIDTH + ld a, " " + call ByteFill + pop af + ld hl, Sprites + ld bc, $10 + call AddNTimes + ld de, $4 + ld c, $4 +.gfx_loop + ld [hl], $a0 + add hl, de + dec c + jr nz, .gfx_loop + ld de, SFX_SWITCH_POKEMON + call WaitPlaySFX + ret + +.SwapMonAndMail: ; 50f62 (14:4f62) + push hl + push de + push bc + ld bc, PartySpecies + ld a, [Buffer2] + ld l, a + ld h, $0 + add hl, bc + ld d, h + ld e, l + ld a, [Buffer3] + ld l, a + ld h, $0 + add hl, bc + ld a, [hl] + push af + ld a, [de] + ld [hl], a + pop af + ld [de], a + ld a, [Buffer2] + ld hl, PartyMon1Species + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + push hl + ld de, wd002 + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + ld a, [Buffer3] + ld hl, PartyMon1 + ld bc, PARTYMON_STRUCT_LENGTH + call AddNTimes + pop de + push hl + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + pop de + ld hl, wd002 + ld bc, PARTYMON_STRUCT_LENGTH + call CopyBytes + ld a, [Buffer2] + ld hl, PartyMonOT + call SkipNames + push hl + call .CopyNameTowd002 + ld a, [Buffer3] + ld hl, PartyMonOT + call SkipNames + pop de + push hl + call .CopyName + pop de + ld hl, wd002 + call .CopyName + ld hl, PartyMonNicknames + ld a, [Buffer2] + call SkipNames + push hl + call .CopyNameTowd002 + ld hl, PartyMonNicknames + ld a, [Buffer3] + call SkipNames + pop de + push hl + call .CopyName + pop de + ld hl, wd002 + call .CopyName + ld hl, sPartyMail + ld a, [Buffer2] + ld bc, MAIL_STRUCT_LENGTH + call AddNTimes + push hl + ld de, wd002 + ld bc, MAIL_STRUCT_LENGTH + ld a, BANK(sPartyMail) + call GetSRAMBank + call CopyBytes + ld hl, sPartyMail + ld a, [Buffer3] + ld bc, MAIL_STRUCT_LENGTH + call AddNTimes + pop de + push hl + ld bc, MAIL_STRUCT_LENGTH + call CopyBytes + pop de + ld hl, wd002 + ld bc, MAIL_STRUCT_LENGTH + call CopyBytes + call CloseSRAM + pop bc + pop de + pop hl + ret + +.CopyNameTowd002: ; 51036 (14:5036) + ld de, wd002 + +.CopyName: ; 51039 (14:5039) + ld bc, NAME_LENGTH + call CopyBytes + ret |