diff options
Diffstat (limited to 'home.asm')
-rw-r--r-- | home.asm | 1928 |
1 files changed, 964 insertions, 964 deletions
@@ -148,24 +148,24 @@ CheckForUserInterruption:: ; INPUT: ; a = ID of destination warp within destination map LoadDestinationWarpPosition:: - ld b,a - ld a,[H_LOADEDROMBANK] + ld b, a + ld a, [H_LOADEDROMBANK] push af - ld a,[wPredefParentBank] - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a - ld a,b + ld a, [wPredefParentBank] + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a + ld a, b add a add a - ld c,a - ld b,0 - add hl,bc - ld bc,4 - ld de,wCurrentTileBlockMapViewPointer + ld c, a + ld b, 0 + add hl, bc + ld bc, 4 + ld de, wCurrentTileBlockMapViewPointer call CopyData pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret @@ -189,18 +189,18 @@ DrawHPBar:: ; Middle ld a, $63 ; empty .draw - ld [hli],a + ld [hli], a dec d jr nz, .draw ; Right - ld a,[wHPBarType] + ld a, [wHPBarType] dec a ld a, $6d ; status screen and battle jr z, .ok dec a ; pokemon menu .ok - ld [hl],a + ld [hl], a pop hl @@ -346,10 +346,10 @@ GetCryData:: ret DisplayPartyMenu:: - ld a,[hTilesetType] + ld a, [hTilesetType] push af xor a - ld [hTilesetType],a + ld [hTilesetType], a call GBPalWhiteOutWithDelay3 call ClearSprites call PartyMenuInit @@ -357,10 +357,10 @@ DisplayPartyMenu:: jp HandlePartyMenuInput GoBackToPartyMenu:: - ld a,[hTilesetType] + ld a, [hTilesetType] push af xor a - ld [hTilesetType],a + ld [hTilesetType], a call PartyMenuInit call RedrawPartyMenu jp HandlePartyMenuInput @@ -405,38 +405,38 @@ PartyMenuInit:: ret HandlePartyMenuInput:: - ld a,1 - ld [wMenuWrappingEnabled],a - ld a,$40 - ld [wPartyMenuAnimMonEnabled],a + ld a, 1 + ld [wMenuWrappingEnabled], a + ld a, $40 + ld [wPartyMenuAnimMonEnabled], a call HandleMenuInput_ call PlaceUnfilledArrowMenuCursor - ld b,a + ld b, a xor a - ld [wPartyMenuAnimMonEnabled],a - ld a,[wCurrentMenuItem] - ld [wPartyAndBillsPCSavedMenuItem],a - ld hl,wd730 - res 6,[hl] ; turn on letter printing delay - ld a,[wMenuItemToSwap] + ld [wPartyMenuAnimMonEnabled], a + ld a, [wCurrentMenuItem] + ld [wPartyAndBillsPCSavedMenuItem], a + ld hl, wd730 + res 6, [hl] ; turn on letter printing delay + ld a, [wMenuItemToSwap] and a - jp nz,.swappingPokemon + jp nz, .swappingPokemon pop af - ld [hTilesetType],a - bit 1,b - jr nz,.noPokemonChosen - ld a,[wPartyCount] + ld [hTilesetType], a + bit 1, b + jr nz, .noPokemonChosen + ld a, [wPartyCount] and a - jr z,.noPokemonChosen - ld a,[wCurrentMenuItem] - ld [wWhichPokemon],a - ld hl,wPartySpecies - ld b,0 - ld c,a - add hl,bc - ld a,[hl] - ld [wcf91],a - ld [wBattleMonSpecies2],a + jr z, .noPokemonChosen + ld a, [wCurrentMenuItem] + ld [wWhichPokemon], a + ld hl, wPartySpecies + ld b, 0 + ld c, a + add hl, bc + ld a, [hl] + ld [wcf91], a + ld [wBattleMonSpecies2], a call BankswitchBack and a ret @@ -445,18 +445,18 @@ HandlePartyMenuInput:: scf ret .swappingPokemon - bit 1,b ; was the B button pressed? - jr z,.handleSwap ; if not, handle swapping the pokemon + bit 1, b ; was the B button pressed? + jr z, .handleSwap ; if not, handle swapping the pokemon .cancelSwap ; if the B button was pressed callba ErasePartyMenuCursors xor a - ld [wMenuItemToSwap],a - ld [wPartyMenuTypeOrMessageID],a + ld [wMenuItemToSwap], a + ld [wPartyMenuTypeOrMessageID], a call RedrawPartyMenu jr HandlePartyMenuInput .handleSwap - ld a,[wCurrentMenuItem] - ld [wWhichPokemon],a + ld a, [wCurrentMenuItem] + ld [wWhichPokemon], a callba SwitchPartyMon jr HandlePartyMenuInput @@ -479,33 +479,33 @@ PrintStatusCondition:: push de dec de dec de ; de = address of current HP - ld a,[de] - ld b,a + ld a, [de] + ld b, a dec de - ld a,[de] + ld a, [de] or b ; is the pokemon's HP zero? pop de - jr nz,PrintStatusConditionNotFainted + jr nz, PrintStatusConditionNotFainted ; if the pokemon's HP is 0, print "FNT" - ld a,"F" - ld [hli],a - ld a,"N" - ld [hli],a - ld [hl],"T" + ld a, "F" + ld [hli], a + ld a, "N" + ld [hli], a + ld [hl], "T" and a ret PrintStatusConditionNotFainted: - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,BANK(PrintStatusAilment) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, BANK(PrintStatusAilment) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a call PrintStatusAilment ; print status condition pop bc - ld a,b - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, b + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret ; function to print pokemon level, leaving off the ":L" if the level is at least 100 @@ -513,12 +513,12 @@ PrintStatusConditionNotFainted: ; hl = destination address ; [wLoadedMonLevel] = level PrintLevel:: - ld a,$6e ; ":L" tile ID - ld [hli],a - ld c,2 ; number of digits - ld a,[wLoadedMonLevel] ; level + ld a, $6e ; ":L" tile ID + ld [hli], a + ld c, 2 ; number of digits + ld a, [wLoadedMonLevel] ; level cp 100 - jr c,PrintLevelCommon + jr c, PrintLevelCommon ; if level at least 100, write over the ":L" tile dec hl inc c ; increment number of digits to 3 @@ -529,105 +529,105 @@ PrintLevel:: ; hl = destination address ; [wLoadedMonLevel] = level PrintLevelFull:: - ld a,$6e ; ":L" tile ID - ld [hli],a - ld c,3 ; number of digits - ld a,[wLoadedMonLevel] ; level + ld a, $6e ; ":L" tile ID + ld [hli], a + ld c, 3 ; number of digits + ld a, [wLoadedMonLevel] ; level PrintLevelCommon:: - ld [wd11e],a - ld de,wd11e - ld b,LEFT_ALIGN | 1 ; 1 byte + ld [wd11e], a + ld de, wd11e + ld b, LEFT_ALIGN | 1 ; 1 byte jp PrintNumber GetwMoves:: ; Unused. Returns the move at index a from wMoves in a - ld hl,wMoves - ld c,a - ld b,0 - add hl,bc - ld a,[hl] + ld hl, wMoves + ld c, a + ld b, 0 + add hl, bc + ld a, [hl] ret ; copies the base stat data of a pokemon to wMonHeader ; INPUT: ; [wd0b5] = pokemon ID GetMonHeader:: - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,BANK(BaseStats) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, BANK(BaseStats) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a push bc push de push hl - ld a,[wd11e] + ld a, [wd11e] push af - ld a,[wd0b5] - ld [wd11e],a - ld de,FossilKabutopsPic - ld b,$66 ; size of Kabutops fossil and Ghost sprites + ld a, [wd0b5] + ld [wd11e], a + ld de, FossilKabutopsPic + ld b, $66 ; size of Kabutops fossil and Ghost sprites cp FOSSIL_KABUTOPS ; Kabutops fossil - jr z,.specialID - ld de,GhostPic + jr z, .specialID + ld de, GhostPic cp MON_GHOST ; Ghost - jr z,.specialID - ld de,FossilAerodactylPic - ld b,$77 ; size of Aerodactyl fossil sprite + jr z, .specialID + ld de, FossilAerodactylPic + ld b, $77 ; size of Aerodactyl fossil sprite cp FOSSIL_AERODACTYL ; Aerodactyl fossil - jr z,.specialID - cp a,MEW - jr z,.mew + jr z, .specialID + cp MEW + jr z, .mew predef IndexToPokedex ; convert pokemon ID in [wd11e] to pokedex number - ld a,[wd11e] + ld a, [wd11e] dec a ld bc, MonBaseStatsEnd - MonBaseStats - ld hl,BaseStats + ld hl, BaseStats call AddNTimes - ld de,wMonHeader + ld de, wMonHeader ld bc, MonBaseStatsEnd - MonBaseStats call CopyData jr .done .specialID - ld hl,wMonHSpriteDim - ld [hl],b ; write sprite dimensions + ld hl, wMonHSpriteDim + ld [hl], b ; write sprite dimensions inc hl - ld [hl],e ; write front sprite pointer + ld [hl], e ; write front sprite pointer inc hl - ld [hl],d + ld [hl], d jr .done .mew - ld hl,MewBaseStats - ld de,wMonHeader - ld bc,MonBaseStatsEnd - MonBaseStats - ld a,BANK(MewBaseStats) + ld hl, MewBaseStats + ld de, wMonHeader + ld bc, MonBaseStatsEnd - MonBaseStats + ld a, BANK(MewBaseStats) call FarCopyData .done - ld a,[wd0b5] - ld [wMonHIndex],a + ld a, [wd0b5] + ld [wMonHIndex], a pop af - ld [wd11e],a + ld [wd11e], a pop hl pop de pop bc pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret ; copy party pokemon's name to wcd6d GetPartyMonName2:: - ld a,[wWhichPokemon] ; index within party - ld hl,wPartyMonNicks + ld a, [wWhichPokemon] ; index within party + ld hl, wPartyMonNicks ; this is called more often GetPartyMonName:: push hl push bc call SkipFixedLengthTextEntries ; add NAME_LENGTH to hl, a times - ld de,wcd6d + ld de, wcd6d push de - ld bc,NAME_LENGTH + ld bc, NAME_LENGTH call CopyData pop de pop bc @@ -648,38 +648,38 @@ GetPartyMonName:: ; Note that bits 5 and 7 are modified during execution. The above reflects ; their meaning at the beginning of the functions's execution. PrintBCDNumber:: - ld b,c ; save flags in b - res 7,c - res 6,c - res 5,c ; c now holds the length - bit 5,b - jr z,.loop - bit 7,b - jr nz,.loop - ld [hl],"¥" + ld b, c ; save flags in b + res 7, c + res 6, c + res 5, c ; c now holds the length + bit 5, b + jr z, .loop + bit 7, b + jr nz, .loop + ld [hl], "¥" inc hl .loop - ld a,[de] + ld a, [de] swap a call PrintBCDDigit ; print upper digit - ld a,[de] + ld a, [de] call PrintBCDDigit ; print lower digit inc de dec c - jr nz,.loop - bit 7,b ; were any non-zero digits printed? - jr z,.done ; if so, we are done + jr nz, .loop + bit 7, b ; were any non-zero digits printed? + jr z, .done ; if so, we are done .numberEqualsZero ; if every digit of the BCD number is zero - bit 6,b ; left or right alignment? - jr nz,.skipRightAlignmentAdjustment + bit 6, b ; left or right alignment? + jr nz, .skipRightAlignmentAdjustment dec hl ; if the string is right-aligned, it needs to be moved back one space .skipRightAlignmentAdjustment - bit 5,b - jr z,.skipCurrencySymbol - ld [hl],"¥" + bit 5, b + jr z, .skipCurrencySymbol + ld [hl], "¥" inc hl .skipCurrencySymbol - ld [hl],"0" + ld [hl], "0" call PrintLetterDelay inc hl .done @@ -688,26 +688,26 @@ PrintBCDNumber:: PrintBCDDigit:: and $f and a - jr z,.zeroDigit + jr z, .zeroDigit .nonzeroDigit - bit 7,b ; have any non-space characters been printed? - jr z,.outputDigit + bit 7, b ; have any non-space characters been printed? + jr z, .outputDigit ; if bit 7 is set, then no numbers have been printed yet - bit 5,b ; print the currency symbol? - jr z,.skipCurrencySymbol - ld [hl],"¥" + bit 5, b ; print the currency symbol? + jr z, .skipCurrencySymbol + ld [hl], "¥" inc hl - res 5,b + res 5, b .skipCurrencySymbol - res 7,b ; unset 7 to indicate that a nonzero digit has been reached + res 7, b ; unset 7 to indicate that a nonzero digit has been reached .outputDigit add "0" - ld [hli],a + ld [hli], a jp PrintLetterDelay .zeroDigit - bit 7,b ; either printing leading zeroes or already reached a nonzero digit? - jr z,.outputDigit ; if so, print a zero digit - bit 6,b ; left or right alignment? + bit 7, b ; either printing leading zeroes or already reached a nonzero digit? + jr z, .outputDigit ; if so, print a zero digit + bit 6, b ; left or right alignment? ret nz inc hl ; if right-aligned, "print" a space by advancing the pointer ret @@ -716,12 +716,12 @@ PrintBCDDigit:: ; assumes the corresponding mon header is already loaded ; hl contains offset to sprite pointer ($b for front or $d for back) UncompressMonSprite:: - ld bc,wMonHeader - add hl,bc - ld a,[hli] - ld [wSpriteInputPtr],a ; fetch sprite input pointer - ld a,[hl] - ld [wSpriteInputPtr+1],a + ld bc, wMonHeader + add hl, bc + ld a, [hli] + ld [wSpriteInputPtr], a ; fetch sprite input pointer + ld a, [hl] + ld [wSpriteInputPtr+1], a ; define (by index number) the bank that a pokemon's image is in ; index = Mew, bank 1 ; index = Kabutops fossil, bank $B @@ -730,32 +730,32 @@ UncompressMonSprite:: ; $4A ≤ index < $74, bank $B ; $74 ≤ index < $99, bank $C ; $99 ≤ index, bank $D - ld a,[wcf91] ; XXX name for this ram location - ld b,a + ld a, [wcf91] ; XXX name for this ram location + ld b, a cp MEW - ld a,BANK(MewPicFront) - jr z,.GotBank - ld a,b + ld a, BANK(MewPicFront) + jr z, .GotBank + ld a, b cp FOSSIL_KABUTOPS - ld a,BANK(FossilKabutopsPic) - jr z,.GotBank - ld a,b + ld a, BANK(FossilKabutopsPic) + jr z, .GotBank + ld a, b cp TANGELA + 1 - ld a,BANK(TangelaPicFront) - jr c,.GotBank - ld a,b + ld a, BANK(TangelaPicFront) + jr c, .GotBank + ld a, b cp MOLTRES + 1 - ld a,BANK(MoltresPicFront) - jr c,.GotBank - ld a,b + ld a, BANK(MoltresPicFront) + jr c, .GotBank + ld a, b cp BEEDRILL + 2 - ld a,BANK(BeedrillPicFront) - jr c,.GotBank - ld a,b + ld a, BANK(BeedrillPicFront) + jr c, .GotBank + ld a, b cp STARMIE + 1 - ld a,BANK(StarmiePicFront) - jr c,.GotBank - ld a,BANK(VictreebelPicFront) + ld a, BANK(StarmiePicFront) + jr c, .GotBank + ld a, BANK(VictreebelPicFront) .GotBank jp UncompressSpriteData @@ -942,7 +942,7 @@ INCLUDE "data/mart_inventories.asm" TextScriptEndingChar:: db "@" TextScriptEnd:: - ld hl,TextScriptEndingChar + ld hl, TextScriptEndingChar ret ExclamationText:: @@ -1047,41 +1047,41 @@ FadeOutAudio:: ; this function is used to display sign messages, sprite dialog, etc. ; INPUT: [hSpriteIndexOrTextID] = sprite ID or text ID DisplayTextID:: - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af callba DisplayTextIDInit ; initialization - ld hl,wTextPredefFlag - bit 0,[hl] - res 0,[hl] - jr nz,.skipSwitchToMapBank - ld a,[wCurMap] + ld hl, wTextPredefFlag + bit 0, [hl] + res 0, [hl] + jr nz, .skipSwitchToMapBank + ld a, [wCurMap] call SwitchToMapRomBank .skipSwitchToMapBank - ld a,30 ; half a second - ld [H_FRAMECOUNTER],a ; used as joypad poll timer - ld hl,wMapTextPtr - ld a,[hli] - ld h,[hl] - ld l,a ; hl = map text pointer - ld d,$00 - ld a,[hSpriteIndexOrTextID] ; text ID - ld [wSpriteIndex],a + ld a, 30 ; half a second + ld [H_FRAMECOUNTER], a ; used as joypad poll timer + ld hl, wMapTextPtr + ld a, [hli] + ld h, [hl] + ld l, a ; hl = map text pointer + ld d, $00 + ld a, [hSpriteIndexOrTextID] ; text ID + ld [wSpriteIndex], a and a - jp z,DisplayStartMenu + jp z, DisplayStartMenu cp TEXT_SAFARI_GAME_OVER - jp z,DisplaySafariGameOverText + jp z, DisplaySafariGameOverText cp TEXT_MON_FAINTED - jp z,DisplayPokemonFaintedText + jp z, DisplayPokemonFaintedText cp TEXT_BLACKED_OUT - jp z,DisplayPlayerBlackedOutText + jp z, DisplayPlayerBlackedOutText cp TEXT_REPEL_WORE_OFF - jp z,DisplayRepelWoreOffText - ld a,[wNumSprites] - ld e,a - ld a,[hSpriteIndexOrTextID] ; sprite ID + jp z, DisplayRepelWoreOffText + ld a, [wNumSprites] + ld e, a + ld a, [hSpriteIndexOrTextID] ; sprite ID cp e - jr z,.spriteHandling - jr nc,.skipSpriteHandling + jr z, .spriteHandling + jr nc, .skipSpriteHandling .spriteHandling ; get the text ID of the sprite push hl @@ -1090,123 +1090,123 @@ DisplayTextID:: callba UpdateSpriteFacingOffsetAndDelayMovement ; update the graphics of the sprite the player is talking to (to face the right direction) pop bc pop de - ld hl,wMapSpriteData ; NPC text entries - ld a,[hSpriteIndexOrTextID] + ld hl, wMapSpriteData ; NPC text entries + ld a, [hSpriteIndexOrTextID] dec a add a add l - ld l,a - jr nc,.noCarry + ld l, a + jr nc, .noCarry inc h .noCarry inc hl - ld a,[hl] ; a = text ID of the sprite + ld a, [hl] ; a = text ID of the sprite pop hl .skipSpriteHandling ; look up the address of the text in the map's text entries dec a - ld e,a + ld e, a sla e - add hl,de - ld a,[hli] - ld h,[hl] - ld l,a ; hl = address of the text - ld a,[hl] ; a = first byte of text + add hl, de + ld a, [hli] + ld h, [hl] + ld l, a ; hl = address of the text + ld a, [hl] ; a = first byte of text ; check first byte of text for special cases cp $fe ; Pokemart NPC - jp z,DisplayPokemartDialogue + jp z, DisplayPokemartDialogue cp $ff ; Pokemon Center NPC - jp z,DisplayPokemonCenterDialogue + jp z, DisplayPokemonCenterDialogue cp $fc ; Item Storage PC - jp z,FuncTX_ItemStoragePC + jp z, FuncTX_ItemStoragePC cp $fd ; Bill's PC - jp z,FuncTX_BillsPC + jp z, FuncTX_BillsPC cp $f9 ; Pokemon Center PC - jp z,FuncTX_PokemonCenterPC + jp z, FuncTX_PokemonCenterPC cp $f5 ; Vending Machine - jr nz,.notVendingMachine + jr nz, .notVendingMachine callba VendingMachineMenu ; jump banks to vending machine routine jr AfterDisplayingTextID .notVendingMachine cp $f7 ; prize menu jp z, FuncTX_GameCornerPrizeMenu cp $f6 ; cable connection NPC in Pokemon Center - jr nz,.notSpecialCase + jr nz, .notSpecialCase callab CableClubNPC jr AfterDisplayingTextID .notSpecialCase call PrintText_NoCreatingTextBox ; display the text - ld a,[wDoNotWaitForButtonPressAfterDisplayingText] + ld a, [wDoNotWaitForButtonPressAfterDisplayingText] and a - jr nz,HoldTextDisplayOpen + jr nz, HoldTextDisplayOpen AfterDisplayingTextID:: - ld a,[wEnteringCableClub] + ld a, [wEnteringCableClub] and a - jr nz,HoldTextDisplayOpen + jr nz, HoldTextDisplayOpen call WaitForTextScrollButtonPress ; wait for a button press after displaying all the text ; loop to hold the dialogue box open as long as the player keeps holding down the A button HoldTextDisplayOpen:: call Joypad - ld a,[hJoyHeld] - bit 0,a ; is the A button being pressed? - jr nz,HoldTextDisplayOpen + ld a, [hJoyHeld] + bit 0, a ; is the A button being pressed? + jr nz, HoldTextDisplayOpen CloseTextDisplay:: - ld a,[wCurMap] + ld a, [wCurMap] call SwitchToMapRomBank - ld a,$90 - ld [hWY],a ; move the window off the screen + ld a, $90 + ld [hWY], a ; move the window off the screen call DelayFrame call LoadGBPal xor a - ld [H_AUTOBGTRANSFERENABLED],a ; disable continuous WRAM to VRAM transfer each V-blank + ld [H_AUTOBGTRANSFERENABLED], a ; disable continuous WRAM to VRAM transfer each V-blank ; loop to make sprites face the directions they originally faced before the dialogue - ld hl,wSpriteStateData2 + $19 - ld c,$0f - ld de,$0010 + ld hl, wSpriteStateData2 + $19 + ld c, $0f + ld de, $0010 .restoreSpriteFacingDirectionLoop - ld a,[hl] + ld a, [hl] dec h - ld [hl],a + ld [hl], a inc h - add hl,de + add hl, de dec c - jr nz,.restoreSpriteFacingDirectionLoop - ld a,BANK(InitMapSprites) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + jr nz, .restoreSpriteFacingDirectionLoop + ld a, BANK(InitMapSprites) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a call InitMapSprites ; reload sprite tile pattern data (since it was partially overwritten by text tile patterns) - ld hl,wFontLoaded - res 0,[hl] - ld a,[wd732] - bit 3,a ; used fly warp - call z,LoadPlayerSpriteGraphics + ld hl, wFontLoaded + res 0, [hl] + ld a, [wd732] + bit 3, a ; used fly warp + call z, LoadPlayerSpriteGraphics call LoadCurrentMapView pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a jp UpdateSprites DisplayPokemartDialogue:: push hl - ld hl,PokemartGreetingText + ld hl, PokemartGreetingText call PrintText pop hl inc hl call LoadItemList - ld a,PRICEDITEMLISTMENU - ld [wListMenuID],a - ld a,[H_LOADEDROMBANK] + ld a, PRICEDITEMLISTMENU + ld [wListMenuID], a + ld a, [H_LOADEDROMBANK] push af - ld a,Bank(DisplayPokemartDialogue_) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, Bank(DisplayPokemartDialogue_) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a call DisplayPokemartDialogue_ pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a jp AfterDisplayingTextID PokemartGreetingText:: @@ -1214,38 +1214,38 @@ PokemartGreetingText:: db "@" LoadItemList:: - ld a,1 - ld [wUpdateSpritesEnabled],a - ld a,h - ld [wItemListPointer],a - ld a,l - ld [wItemListPointer + 1],a - ld de,wItemList + ld a, 1 + ld [wUpdateSpritesEnabled], a + ld a, h + ld [wItemListPointer], a + ld a, l + ld [wItemListPointer + 1], a + ld de, wItemList .loop - ld a,[hli] - ld [de],a + ld a, [hli] + ld [de], a inc de cp $ff - jr nz,.loop + jr nz, .loop ret DisplayPokemonCenterDialogue:: ; zeroing these doesn't appear to serve any purpose xor a - ld [$ff8b],a - ld [$ff8c],a - ld [$ff8d],a + ld [$ff8b], a + ld [$ff8c], a + ld [$ff8d], a inc hl - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,Bank(DisplayPokemonCenterDialogue_) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, Bank(DisplayPokemonCenterDialogue_) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a call DisplayPokemonCenterDialogue_ pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a jp AfterDisplayingTextID DisplaySafariGameOverText:: @@ -1253,7 +1253,7 @@ DisplaySafariGameOverText:: jp AfterDisplayingTextID DisplayPokemonFaintedText:: - ld hl,PokemonFaintedText + ld hl, PokemonFaintedText call PrintText jp AfterDisplayingTextID @@ -1262,11 +1262,11 @@ PokemonFaintedText:: db "@" DisplayPlayerBlackedOutText:: - ld hl,PlayerBlackedOutText + ld hl, PlayerBlackedOutText call PrintText - ld a,[wd732] - res 5,a ; reset forced to use bike bit - ld [wd732],a + ld a, [wd732] + res 5, a ; reset forced to use bike bit + ld [wd732], a jp HoldTextDisplayOpen PlayerBlackedOutText:: @@ -1274,7 +1274,7 @@ PlayerBlackedOutText:: db "@" DisplayRepelWoreOffText:: - ld hl,RepelWoreOffText + ld hl, RepelWoreOffText call PrintText jp AfterDisplayingTextID @@ -1291,22 +1291,22 @@ INCLUDE "engine/menu/start_menu.asm" ; OUTPUT: ; [wNumSetBits] = number of set bits CountSetBits:: - ld c,0 + ld c, 0 .loop - ld a,[hli] - ld e,a - ld d,8 + ld a, [hli] + ld e, a + ld d, 8 .innerLoop ; count how many bits are set in the current byte srl e - ld a,0 + ld a, 0 adc c - ld c,a + ld c, a dec d - jr nz,.innerLoop + jr nz, .innerLoop dec b - jr nz,.loop - ld a,c - ld [wNumSetBits],a + jr nz, .loop + ld a, c + ld [wNumSetBits], a ret ; subtracts the amount the player paid from their money @@ -1316,12 +1316,12 @@ SubtractAmountPaidFromMoney:: ; adds the amount the player sold to their money AddAmountSoldToMoney:: - ld de,wPlayerMoney + 2 - ld hl,$ffa1 ; total price of items - ld c,3 ; length of money in bytes + ld de, wPlayerMoney + 2 + ld hl, $ffa1 ; total price of items + ld c, 3 ; length of money in bytes predef AddBCDPredef ; add total price to money - ld a,MONEY_BOX - ld [wTextBoxID],a + ld a, MONEY_BOX + ld [wTextBoxID], a call DisplayTextBoxID ; redraw money text box ld a, SFX_PURCHASE call PlaySoundWaitForCurrent @@ -1333,15 +1333,15 @@ AddAmountSoldToMoney:: ; [wWhichPokemon] = index (within the inventory) of the item to remove ; [wItemQuantity] = quantity to remove RemoveItemFromInventory:: - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,BANK(RemoveItemFromInventory_) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, BANK(RemoveItemFromInventory_) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a call RemoveItemFromInventory_ pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret ; function to add an item (in varying quantities) to the player's bag or PC box @@ -1352,16 +1352,16 @@ RemoveItemFromInventory:: ; sets carry flag if successful, unsets carry flag if unsuccessful AddItemToInventory:: push bc - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,BANK(AddItemToInventory_) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, BANK(AddItemToInventory_) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a call AddItemToInventory_ pop bc - ld a,b - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, b + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a pop bc ret @@ -1370,80 +1370,80 @@ AddItemToInventory:: ; [wListPointer] = address of the list (2 bytes) DisplayListMenuID:: xor a - ld [H_AUTOBGTRANSFERENABLED],a ; disable auto-transfer - ld a,1 - ld [hJoy7],a ; joypad state update flag - ld a,[wBattleType] + ld [H_AUTOBGTRANSFERENABLED], a ; disable auto-transfer + ld a, 1 + ld [hJoy7], a ; joypad state update flag + ld a, [wBattleType] and a ; is it the Old Man battle? - jr nz,.specialBattleType - ld a,$01 ; hardcoded bank + jr nz, .specialBattleType + ld a, $01 ; hardcoded bank jr .bankswitch .specialBattleType ; Old Man battle ld a, BANK(DisplayBattleMenu) .bankswitch call BankswitchHome - ld hl,wd730 - set 6,[hl] ; turn off letter printing delay + ld hl, wd730 + set 6, [hl] ; turn off letter printing delay xor a - ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped - ld [wListCount],a - ld a,[wListPointer] - ld l,a - ld a,[wListPointer + 1] - ld h,a ; hl = address of the list - ld a,[hl] ; the first byte is the number of entries in the list - ld [wListCount],a - ld a,LIST_MENU_BOX - ld [wTextBoxID],a + ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped + ld [wListCount], a + ld a, [wListPointer] + ld l, a + ld a, [wListPointer + 1] + ld h, a ; hl = address of the list + ld a, [hl] ; the first byte is the number of entries in the list + ld [wListCount], a + ld a, LIST_MENU_BOX + ld [wTextBoxID], a call DisplayTextBoxID ; draw the menu text box call UpdateSprites ; disable sprites behind the text box ; the code up to .skipMovingSprites appears to be useless coord hl, 4, 2 ; coordinates of upper left corner of menu text box lb de, 9, 14 ; height and width of menu text box - ld a,[wListMenuID] + ld a, [wListMenuID] and a ; is it a PC pokemon list? - jr nz,.skipMovingSprites + jr nz, .skipMovingSprites call UpdateSprites .skipMovingSprites - ld a,1 ; max menu item ID is 1 if the list has less than 2 entries - ld [wMenuWatchMovingOutOfBounds],a - ld a,[wListCount] + ld a, 1 ; max menu item ID is 1 if the list has less than 2 entries + ld [wMenuWatchMovingOutOfBounds], a + ld a, [wListCount] cp 2 ; does the list have less than 2 entries? - jr c,.setMenuVariables - ld a,2 ; max menu item ID is 2 if the list has at least 2 entries + jr c, .setMenuVariables + ld a, 2 ; max menu item ID is 2 if the list has at least 2 entries .setMenuVariables - ld [wMaxMenuItem],a - ld a,4 - ld [wTopMenuItemY],a - ld a,5 - ld [wTopMenuItemX],a - ld a,A_BUTTON | B_BUTTON | SELECT - ld [wMenuWatchedKeys],a - ld c,10 + ld [wMaxMenuItem], a + ld a, 4 + ld [wTopMenuItemY], a + ld a, 5 + ld [wTopMenuItemX], a + ld a, A_BUTTON | B_BUTTON | SELECT + ld [wMenuWatchedKeys], a + ld c, 10 call DelayFrames DisplayListMenuIDLoop:: xor a - ld [H_AUTOBGTRANSFERENABLED],a ; disable transfer + ld [H_AUTOBGTRANSFERENABLED], a ; disable transfer call PrintListMenuEntries - ld a,1 - ld [H_AUTOBGTRANSFERENABLED],a ; enable transfer + ld a, 1 + ld [H_AUTOBGTRANSFERENABLED], a ; enable transfer call Delay3 - ld a,[wBattleType] + ld a, [wBattleType] and a ; is it the Old Man battle? - jr z,.notOldManBattle + jr z, .notOldManBattle .oldManBattle - ld a,"▶" + ld a, "▶" Coorda 5, 4 ; place menu cursor in front of first menu entry - ld c,80 + ld c, 80 call DelayFrames xor a - ld [wCurrentMenuItem],a + ld [wCurrentMenuItem], a coord hl, 5, 4 - ld a,l - ld [wMenuCursorLocation],a - ld a,h - ld [wMenuCursorLocation + 1],a + ld a, l + ld [wMenuCursorLocation], a + ld a, h + ld [wMenuCursorLocation + 1], a jr .buttonAPressed .notOldManBattle call LoadGBPal @@ -1451,231 +1451,231 @@ DisplayListMenuIDLoop:: push af call PlaceMenuCursor pop af - bit 0,a ; was the A button pressed? - jp z,.checkOtherKeys + bit 0, a ; was the A button pressed? + jp z, .checkOtherKeys .buttonAPressed - ld a,[wCurrentMenuItem] + ld a, [wCurrentMenuItem] call PlaceUnfilledArrowMenuCursor ; pointless because both values are overwritten before they are read - ld a,$01 - ld [wMenuExitMethod],a - ld [wChosenMenuItem],a + ld a, $01 + ld [wMenuExitMethod], a + ld [wChosenMenuItem], a xor a - ld [wMenuWatchMovingOutOfBounds],a - ld a,[wCurrentMenuItem] - ld c,a - ld a,[wListScrollOffset] + ld [wMenuWatchMovingOutOfBounds], a + ld a, [wCurrentMenuItem] + ld c, a + ld a, [wListScrollOffset] add c - ld c,a - ld a,[wListCount] + ld c, a + ld a, [wListCount] and a ; is the list empty? - jp z,ExitListMenu ; if so, exit the menu + jp z, ExitListMenu ; if so, exit the menu dec a cp c ; did the player select Cancel? - jp c,ExitListMenu ; if so, exit the menu - ld a,c - ld [wWhichPokemon],a - ld a,[wListMenuID] + jp c, ExitListMenu ; if so, exit the menu + ld a, c + ld [wWhichPokemon], a + ld a, [wListMenuID] cp ITEMLISTMENU - jr nz,.skipMultiplying + jr nz, .skipMultiplying ; if it's an item menu sla c ; item entries are 2 bytes long, so multiply by 2 .skipMultiplying - ld a,[wListPointer] - ld l,a - ld a,[wListPointer + 1] - ld h,a + ld a, [wListPointer] + ld l, a + ld a, [wListPointer + 1] + ld h, a inc hl ; hl = beginning of list entries - ld b,0 - add hl,bc - ld a,[hl] - ld [wcf91],a - ld a,[wListMenuID] + ld b, 0 + add hl, bc + ld a, [hl] + ld [wcf91], a + ld a, [wListMenuID] and a ; is it a PC pokemon list? - jr z,.pokemonList + jr z, .pokemonList push hl call GetItemPrice pop hl - ld a,[wListMenuID] + ld a, [wListMenuID] cp ITEMLISTMENU - jr nz,.skipGettingQuantity + jr nz, .skipGettingQuantity ; if it's an item menu inc hl - ld a,[hl] ; a = item quantity - ld [wMaxItemQuantity],a + ld a, [hl] ; a = item quantity + ld [wMaxItemQuantity], a .skipGettingQuantity - ld a,[wcf91] - ld [wd0b5],a - ld a,BANK(ItemNames) - ld [wPredefBank],a + ld a, [wcf91] + ld [wd0b5], a + ld a, BANK(ItemNames) + ld [wPredefBank], a call GetName jr .storeChosenEntry .pokemonList - ld hl,wPartyCount - ld a,[wListPointer] + ld hl, wPartyCount + ld a, [wListPointer] cp l ; is it a list of party pokemon or box pokemon? - ld hl,wPartyMonNicks - jr z,.getPokemonName + ld hl, wPartyMonNicks + jr z, .getPokemonName ld hl, wBoxMonNicks ; box pokemon names .getPokemonName - ld a,[wWhichPokemon] + ld a, [wWhichPokemon] call GetPartyMonName .storeChosenEntry ; store the menu entry that the player chose and return - ld de,wcd6d + ld de, wcd6d call CopyStringToCF4B ; copy name to wcf4b - ld a,CHOSE_MENU_ITEM - ld [wMenuExitMethod],a - ld a,[wCurrentMenuItem] - ld [wChosenMenuItem],a + ld a, CHOSE_MENU_ITEM + ld [wMenuExitMethod], a + ld a, [wCurrentMenuItem] + ld [wChosenMenuItem], a xor a - ld [hJoy7],a ; joypad state update flag - ld hl,wd730 - res 6,[hl] ; turn on letter printing delay + ld [hJoy7], a ; joypad state update flag + ld hl, wd730 + res 6, [hl] ; turn on letter printing delay jp BankswitchBack .checkOtherKeys ; check B, SELECT, Up, and Down keys - bit 1,a ; was the B button pressed? - jp nz,ExitListMenu ; if so, exit the menu - bit 2,a ; was the select button pressed? - jp nz,HandleItemListSwapping ; if so, allow the player to swap menu entries - ld b,a - bit 7,b ; was Down pressed? - ld hl,wListScrollOffset - jr z,.upPressed + bit 1, a ; was the B button pressed? + jp nz, ExitListMenu ; if so, exit the menu + bit 2, a ; was the select button pressed? + jp nz, HandleItemListSwapping ; if so, allow the player to swap menu entries + ld b, a + bit 7, b ; was Down pressed? + ld hl, wListScrollOffset + jr z, .upPressed .downPressed - ld a,[hl] + ld a, [hl] add 3 - ld b,a - ld a,[wListCount] + ld b, a + ld a, [wListCount] cp b ; will going down scroll past the Cancel button? - jp c,DisplayListMenuIDLoop + jp c, DisplayListMenuIDLoop inc [hl] ; if not, go down jp DisplayListMenuIDLoop .upPressed - ld a,[hl] + ld a, [hl] and a - jp z,DisplayListMenuIDLoop + jp z, DisplayListMenuIDLoop dec [hl] jp DisplayListMenuIDLoop DisplayChooseQuantityMenu:: ; text box dimensions/coordinates for just quantity coord hl, 15, 9 - ld b,1 ; height - ld c,3 ; width - ld a,[wListMenuID] + ld b, 1 ; height + ld c, 3 ; width + ld a, [wListMenuID] cp PRICEDITEMLISTMENU - jr nz,.drawTextBox + jr nz, .drawTextBox ; text box dimensions/coordinates for quantity and price coord hl, 7, 9 - ld b,1 ; height - ld c,11 ; width + ld b, 1 ; height + ld c, 11 ; width .drawTextBox call TextBoxBorder coord hl, 16, 10 - ld a,[wListMenuID] + ld a, [wListMenuID] cp PRICEDITEMLISTMENU - jr nz,.printInitialQuantity + jr nz, .printInitialQuantity coord hl, 8, 10 .printInitialQuantity - ld de,InitialQuantityText + ld de, InitialQuantityText call PlaceString xor a - ld [wItemQuantity],a ; initialize current quantity to 0 + ld [wItemQuantity], a ; initialize current quantity to 0 jp .incrementQuantity .waitForKeyPressLoop call JoypadLowSensitivity - ld a,[hJoyPressed] ; newly pressed buttons - bit 0,a ; was the A button pressed? - jp nz,.buttonAPressed - bit 1,a ; was the B button pressed? - jp nz,.buttonBPressed - bit 6,a ; was Up pressed? - jr nz,.incrementQuantity - bit 7,a ; was Down pressed? - jr nz,.decrementQuantity + ld a, [hJoyPressed] ; newly pressed buttons + bit 0, a ; was the A button pressed? + jp nz, .buttonAPressed + bit 1, a ; was the B button pressed? + jp nz, .buttonBPressed + bit 6, a ; was Up pressed? + jr nz, .incrementQuantity + bit 7, a ; was Down pressed? + jr nz, .decrementQuantity jr .waitForKeyPressLoop .incrementQuantity - ld a,[wMaxItemQuantity] + ld a, [wMaxItemQuantity] inc a - ld b,a - ld hl,wItemQuantity ; current quantity + ld b, a + ld hl, wItemQuantity ; current quantity inc [hl] - ld a,[hl] + ld a, [hl] cp b - jr nz,.handleNewQuantity + jr nz, .handleNewQuantity ; wrap to 1 if the player goes above the max quantity - ld a,1 - ld [hl],a + ld a, 1 + ld [hl], a jr .handleNewQuantity .decrementQuantity - ld hl,wItemQuantity ; current quantity + ld hl, wItemQuantity ; current quantity dec [hl] - jr nz,.handleNewQuantity + jr nz, .handleNewQuantity ; wrap to the max quantity if the player goes below 1 - ld a,[wMaxItemQuantity] - ld [hl],a + ld a, [wMaxItemQuantity] + ld [hl], a .handleNewQuantity coord hl, 17, 10 - ld a,[wListMenuID] + ld a, [wListMenuID] cp PRICEDITEMLISTMENU - jr nz,.printQuantity + jr nz, .printQuantity .printPrice - ld c,$03 - ld a,[wItemQuantity] - ld b,a - ld hl,hMoney ; total price + ld c, $03 + ld a, [wItemQuantity] + ld b, a + ld hl, hMoney ; total price ; initialize total price to 0 xor a - ld [hli],a - ld [hli],a - ld [hl],a + ld [hli], a + ld [hli], a + ld [hl], a .addLoop ; loop to multiply the individual price by the quantity to get the total price - ld de,hMoney + 2 - ld hl,hItemPrice + 2 + ld de, hMoney + 2 + ld hl, hItemPrice + 2 push bc predef AddBCDPredef ; add the individual price to the current sum pop bc dec b - jr nz,.addLoop - ld a,[hHalveItemPrices] + jr nz, .addLoop + ld a, [hHalveItemPrices] and a ; should the price be halved (for selling items)? - jr z,.skipHalvingPrice + jr z, .skipHalvingPrice xor a - ld [hDivideBCDDivisor],a - ld [hDivideBCDDivisor + 1],a - ld a,$02 - ld [hDivideBCDDivisor + 2],a + ld [hDivideBCDDivisor], a + ld [hDivideBCDDivisor + 1], a + ld a, $02 + ld [hDivideBCDDivisor + 2], a predef DivideBCDPredef3 ; halves the price ; store the halved price - ld a,[hDivideBCDQuotient] - ld [hMoney],a - ld a,[hDivideBCDQuotient + 1] - ld [hMoney + 1],a - ld a,[hDivideBCDQuotient + 2] - ld [hMoney + 2],a + ld a, [hDivideBCDQuotient] + ld [hMoney], a + ld a, [hDivideBCDQuotient + 1] + ld [hMoney + 1], a + ld a, [hDivideBCDQuotient + 2] + ld [hMoney + 2], a .skipHalvingPrice coord hl, 12, 10 - ld de,SpacesBetweenQuantityAndPriceText + ld de, SpacesBetweenQuantityAndPriceText call PlaceString - ld de,hMoney ; total price - ld c,$a3 + ld de, hMoney ; total price + ld c, $a3 call PrintBCDNumber coord hl, 9, 10 .printQuantity - ld de,wItemQuantity ; current quantity + ld de, wItemQuantity ; current quantity lb bc, LEADING_ZEROES | 1, 2 ; 1 byte, 2 digits call PrintNumber jp .waitForKeyPressLoop .buttonAPressed ; the player chose to make the transaction xor a - ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped + ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped ret .buttonBPressed ; the player chose to cancel the transaction xor a - ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped - ld a,$ff + ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped + ld a, $ff ret InitialQuantityText:: @@ -1685,84 +1685,84 @@ SpacesBetweenQuantityAndPriceText:: db " @" ExitListMenu:: - ld a,[wCurrentMenuItem] - ld [wChosenMenuItem],a - ld a,CANCELLED_MENU - ld [wMenuExitMethod],a - ld [wMenuWatchMovingOutOfBounds],a + ld a, [wCurrentMenuItem] + ld [wChosenMenuItem], a + ld a, CANCELLED_MENU + ld [wMenuExitMethod], a + ld [wMenuWatchMovingOutOfBounds], a xor a - ld [hJoy7],a - ld hl,wd730 - res 6,[hl] + ld [hJoy7], a + ld hl, wd730 + res 6, [hl] call BankswitchBack xor a - ld [wMenuItemToSwap],a ; 0 means no item is currently being swapped + ld [wMenuItemToSwap], a ; 0 means no item is currently being swapped scf ret PrintListMenuEntries:: coord hl, 5, 3 - ld b,9 - ld c,14 + ld b, 9 + ld c, 14 call ClearScreenArea - ld a,[wListPointer] - ld e,a - ld a,[wListPointer + 1] - ld d,a + ld a, [wListPointer] + ld e, a + ld a, [wListPointer + 1] + ld d, a inc de ; de = beginning of list entries - ld a,[wListScrollOffset] - ld c,a - ld a,[wListMenuID] + ld a, [wListScrollOffset] + ld c, a + ld a, [wListMenuID] cp ITEMLISTMENU - ld a,c - jr nz,.skipMultiplying + ld a, c + jr nz, .skipMultiplying ; if it's an item menu ; item entries are 2 bytes long, so multiply by 2 sla a sla c .skipMultiplying add e - ld e,a - jr nc,.noCarry + ld e, a + jr nc, .noCarry inc d .noCarry coord hl, 6, 4 ; coordinates of first list entry name - ld b,4 ; print 4 names + ld b, 4 ; print 4 names .loop - ld a,b - ld [wWhichPokemon],a - ld a,[de] - ld [wd11e],a + ld a, b + ld [wWhichPokemon], a + ld a, [de] + ld [wd11e], a cp $ff - jp z,.printCancelMenuItem + jp z, .printCancelMenuItem push bc push de push hl push hl push de - ld a,[wListMenuID] + ld a, [wListMenuID] and a - jr z,.pokemonPCMenu + jr z, .pokemonPCMenu cp MOVESLISTMENU - jr z,.movesMenu + jr z, .movesMenu .itemMenu call GetItemName jr .placeNameString .pokemonPCMenu push hl - ld hl,wPartyCount - ld a,[wListPointer] + ld hl, wPartyCount + ld a, [wListPointer] cp l ; is it a list of party pokemon or box pokemon? - ld hl,wPartyMonNicks - jr z,.getPokemonName + ld hl, wPartyMonNicks + jr z, .getPokemonName ld hl, wBoxMonNicks ; box pokemon names .getPokemonName - ld a,[wWhichPokemon] - ld b,a - ld a,4 + ld a, [wWhichPokemon] + ld b, a + ld a, 4 sub b - ld b,a - ld a,[wListScrollOffset] + ld b, a + ld a, [wListScrollOffset] add b call GetPartyMonName pop hl @@ -1773,90 +1773,90 @@ PrintListMenuEntries:: call PlaceString pop de pop hl - ld a,[wPrintItemPrices] + ld a, [wPrintItemPrices] and a ; should prices be printed? - jr z,.skipPrintingItemPrice + jr z, .skipPrintingItemPrice .printItemPrice push hl - ld a,[de] - ld de,ItemPrices - ld [wcf91],a + ld a, [de] + ld de, ItemPrices + ld [wcf91], a call GetItemPrice ; get price pop hl ld bc, SCREEN_WIDTH + 5 ; 1 row down and 5 columns right - add hl,bc - ld c,$a3 ; no leading zeroes, right-aligned, print currency symbol, 3 bytes + add hl, bc + ld c, $a3 ; no leading zeroes, right-aligned, print currency symbol, 3 bytes call PrintBCDNumber .skipPrintingItemPrice - ld a,[wListMenuID] + ld a, [wListMenuID] and a - jr nz,.skipPrintingPokemonLevel + jr nz, .skipPrintingPokemonLevel .printPokemonLevel - ld a,[wd11e] + ld a, [wd11e] push af push hl - ld hl,wPartyCount - ld a,[wListPointer] + ld hl, wPartyCount + ld a, [wListPointer] cp l ; is it a list of party pokemon or box pokemon? - ld a,PLAYER_PARTY_DATA - jr z,.next - ld a,BOX_DATA + ld a, PLAYER_PARTY_DATA + jr z, .next + ld a, BOX_DATA .next - ld [wMonDataLocation],a - ld hl,wWhichPokemon - ld a,[hl] - ld b,a - ld a,$04 + ld [wMonDataLocation], a + ld hl, wWhichPokemon + ld a, [hl] + ld b, a + ld a, $04 sub b - ld b,a - ld a,[wListScrollOffset] + ld b, a + ld a, [wListScrollOffset] add b - ld [hl],a + ld [hl], a call LoadMonData - ld a,[wMonDataLocation] + ld a, [wMonDataLocation] and a ; is it a list of party pokemon or box pokemon? - jr z,.skipCopyingLevel + jr z, .skipCopyingLevel .copyLevel - ld a,[wLoadedMonBoxLevel] - ld [wLoadedMonLevel],a + ld a, [wLoadedMonBoxLevel] + ld [wLoadedMonLevel], a .skipCopyingLevel pop hl - ld bc,$001c - add hl,bc + ld bc, $001c + add hl, bc call PrintLevel pop af - ld [wd11e],a + ld [wd11e], a .skipPrintingPokemonLevel pop hl pop de inc de - ld a,[wListMenuID] + ld a, [wListMenuID] cp ITEMLISTMENU - jr nz,.nextListEntry + jr nz, .nextListEntry .printItemQuantity - ld a,[wd11e] - ld [wcf91],a + ld a, [wd11e] + ld [wcf91], a call IsKeyItem ; check if item is unsellable - ld a,[wIsKeyItem] + ld a, [wIsKeyItem] and a ; is the item unsellable? - jr nz,.skipPrintingItemQuantity ; if so, don't print the quantity + jr nz, .skipPrintingItemQuantity ; if so, don't print the quantity push hl ld bc, SCREEN_WIDTH + 8 ; 1 row down and 8 columns right - add hl,bc - ld a,"×" - ld [hli],a - ld a,[wd11e] + add hl, bc + ld a, "×" + ld [hli], a + ld a, [wd11e] push af - ld a,[de] - ld [wMaxItemQuantity],a + ld a, [de] + ld [wMaxItemQuantity], a push de - ld de,wd11e - ld [de],a + ld de, wd11e + ld [de], a lb bc, 1, 2 call PrintNumber pop de pop af - ld [wd11e],a + ld [wd11e], a pop hl .skipPrintingItemQuantity inc de @@ -1864,29 +1864,29 @@ PrintListMenuEntries:: inc c push bc inc c - ld a,[wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1) + ld a, [wMenuItemToSwap] ; ID of item chosen for swapping (counts from 1) and a ; is an item being swapped? - jr z,.nextListEntry + jr z, .nextListEntry sla a cp c ; is it this item? - jr nz,.nextListEntry + jr nz, .nextListEntry dec hl - ld a,$ec ; unfilled right arrow menu cursor to indicate an item being swapped - ld [hli],a + ld a, $ec ; unfilled right arrow menu cursor to indicate an item being swapped + ld [hli], a .nextListEntry - ld bc,2 * SCREEN_WIDTH ; 2 rows - add hl,bc + ld bc, 2 * SCREEN_WIDTH ; 2 rows + add hl, bc pop bc inc c dec b - jp nz,.loop - ld bc,-8 - add hl,bc - ld a,"▼" - ld [hl],a + jp nz, .loop + ld bc, -8 + add hl, bc + ld a, "▼" + ld [hl], a ret .printCancelMenuItem - ld de,ListMenuCancelText + ld de, ListMenuCancelText jp PlaceString ListMenuCancelText:: @@ -1894,27 +1894,27 @@ ListMenuCancelText:: GetMonName:: push hl - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,BANK(MonsterNames) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a - ld a,[wd11e] + ld a, BANK(MonsterNames) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a + ld a, [wd11e] dec a - ld hl,MonsterNames - ld c,10 - ld b,0 + ld hl, MonsterNames + ld c, 10 + ld b, 0 call AddNTimes - ld de,wcd6d + ld de, wcd6d push de - ld bc,10 + ld bc, 10 call CopyData - ld hl,wcd6d + 10 + ld hl, wcd6d + 10 ld [hl], "@" pop de pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a pop hl ret @@ -1923,22 +1923,22 @@ GetItemName:: ; starting at wcd6d push hl push bc - ld a,[wd11e] + ld a, [wd11e] cp HM_01 ; is this a TM/HM? - jr nc,.Machine + jr nc, .Machine - ld [wd0b5],a - ld a,ITEM_NAME - ld [wNameListType],a - ld a,BANK(ItemNames) - ld [wPredefBank],a + ld [wd0b5], a + ld a, ITEM_NAME + ld [wNameListType], a + ld a, BANK(ItemNames) + ld [wPredefBank], a call GetName jr .Finish .Machine call GetMachineName .Finish - ld de,wcd6d ; pointer to where item name is stored in RAM + ld de, wcd6d ; pointer to where item name is stored in RAM pop bc pop hl ret @@ -1948,48 +1948,48 @@ GetMachineName:: push hl push de push bc - ld a,[wd11e] + ld a, [wd11e] push af cp TM_01 ; is this a TM? [not HM] - jr nc,.WriteTM + jr nc, .WriteTM ; if HM, then write "HM" and add 5 to the item ID, so we can reuse the ; TM printing code add 5 - ld [wd11e],a - ld hl,HiddenPrefix ; points to "HM" - ld bc,2 + ld [wd11e], a + ld hl, HiddenPrefix ; points to "HM" + ld bc, 2 jr .WriteMachinePrefix .WriteTM - ld hl,TechnicalPrefix ; points to "TM" - ld bc,2 + ld hl, TechnicalPrefix ; points to "TM" + ld bc, 2 .WriteMachinePrefix - ld de,wcd6d + ld de, wcd6d call CopyData ; now get the machine number and convert it to text - ld a,[wd11e] + ld a, [wd11e] sub TM_01 - 1 ld b, "0" .FirstDigit sub 10 - jr c,.SecondDigit + jr c, .SecondDigit inc b jr .FirstDigit .SecondDigit add 10 push af - ld a,b - ld [de],a + ld a, b + ld [de], a inc de pop af ld b, "0" add b - ld [de],a + ld [de], a inc de - ld a,"@" - ld [de],a + ld a, "@" + ld [de], a pop af - ld [wd11e],a + ld [wd11e], a pop bc pop de pop hl @@ -2004,7 +2004,7 @@ HiddenPrefix:: ; Input: a = item ID IsItemHM:: cp HM_01 - jr c,.notHM + jr c, .notHM cp TM_01 ret .notHM @@ -2014,8 +2014,8 @@ IsItemHM:: ; sets carry if move is an HM, clears carry if move is not an HM ; Input: a = move ID IsMoveHM:: - ld hl,HMMoves - ld de,1 + ld hl, HMMoves + ld de, 1 jp IsInArray HMMoves:: @@ -2024,22 +2024,22 @@ HMMoves:: GetMoveName:: push hl - ld a,MOVE_NAME - ld [wNameListType],a - ld a,[wd11e] - ld [wd0b5],a - ld a,BANK(MoveNames) - ld [wPredefBank],a + ld a, MOVE_NAME + ld [wNameListType], a + ld a, [wd11e] + ld [wd0b5], a + ld a, BANK(MoveNames) + ld [wPredefBank], a call GetName - ld de,wcd6d ; pointer to where move name is stored in RAM + ld de, wcd6d ; pointer to where move name is stored in RAM pop hl ret ; reloads text box tile patterns, current map view, and tileset tile patterns ReloadMapData:: - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,[wCurMap] + ld a, [wCurMap] call SwitchToMapRomBank call DisableLCD call LoadTextBoxTilePatterns @@ -2047,34 +2047,34 @@ ReloadMapData:: call LoadTilesetTilePatternData call EnableLCD pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret ; reloads tileset tile patterns ReloadTilesetTilePatterns:: - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,[wCurMap] + ld a, [wCurMap] call SwitchToMapRomBank call DisableLCD call LoadTilesetTilePatternData call EnableLCD pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret ; shows the town map and lets the player choose a destination to fly to ChooseFlyDestination:: - ld hl,wd72e - res 4,[hl] + ld hl, wd72e + res 4, [hl] jpba LoadTownMap_Fly ; causes the text box to close without waiting for a button press after displaying text DisableWaitingAfterTextDisplay:: - ld a,$01 - ld [wDoNotWaitForButtonPressAfterDisplayingText],a + ld a, $01 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ret ; uses an item @@ -2098,16 +2098,16 @@ UseItem:: ; OUTPUT: ; clears carry flag if the item is tossed, sets carry flag if not TossItem:: - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,BANK(TossItem_) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, BANK(TossItem_) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a call TossItem_ pop de - ld a,d - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, d + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret ; checks if an item is a key item @@ -2132,16 +2132,16 @@ IsKeyItem:: ; [wTextBoxID] = text box ID ; b, c = y, x cursor position (TWO_OPTION_MENU only) DisplayTextBoxID:: - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,BANK(DisplayTextBoxID_) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, BANK(DisplayTextBoxID_) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a call DisplayTextBoxID_ pop bc - ld a,b - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, b + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret ; not zero if an NPC movement script is running, the player character is @@ -2679,8 +2679,8 @@ FuncTX_BillsPC:: FuncTX_GameCornerPrizeMenu:: ; XXX find a better name for this function ; special_F7 - ld b,BANK(CeladonPrizeMenu) - ld hl,CeladonPrizeMenu + ld b, BANK(CeladonPrizeMenu) + ld hl, CeladonPrizeMenu bankswitchAndContinue:: call Bankswitch jp HoldTextDisplayOpen ; continue to main text-engine function @@ -2704,7 +2704,7 @@ IsItemInBag:: ; else reset zero flag ; related to Pokémon Tower and ghosts predef GetQuantityOfItemInBag - ld a,b + ld a, b and a ret @@ -2738,32 +2738,32 @@ SetSpriteImageIndexAfterSettingFacingDirection:: ; [wCoordIndex] = if there is match, the matching array index ; sets carry if the coordinates are in the array, clears carry if not ArePlayerCoordsInArray:: - ld a,[wYCoord] - ld b,a - ld a,[wXCoord] - ld c,a + ld a, [wYCoord] + ld b, a + ld a, [wXCoord] + ld c, a ; fallthrough CheckCoords:: xor a - ld [wCoordIndex],a + ld [wCoordIndex], a .loop - ld a,[hli] + ld a, [hli] cp $ff ; reached terminator? - jr z,.notInArray + jr z, .notInArray push hl - ld hl,wCoordIndex + ld hl, wCoordIndex inc [hl] pop hl .compareYCoord cp b - jr z,.compareXCoord + jr z, .compareXCoord inc hl jr .loop .compareXCoord - ld a,[hli] + ld a, [hli] cp c - jr nz,.loop + jr nz, .loop .inArray scf ret @@ -2857,31 +2857,31 @@ SetSpriteMovementBytesToFE:: SetSpriteMovementBytesToFF:: push hl call GetSpriteMovementByte1Pointer - ld [hl],$FF + ld [hl], $FF call GetSpriteMovementByte2Pointer - ld [hl],$FF ; prevent person from walking? + ld [hl], $FF ; prevent person from walking? pop hl ret ; returns the sprite movement byte 1 pointer for sprite [H_SPRITEINDEX] in hl GetSpriteMovementByte1Pointer:: - ld h,$C2 - ld a,[H_SPRITEINDEX] + ld h, $C2 + ld a, [H_SPRITEINDEX] swap a add 6 - ld l,a + ld l, a ret ; returns the sprite movement byte 2 pointer for sprite [H_SPRITEINDEX] in hl GetSpriteMovementByte2Pointer:: push de - ld hl,wMapSpriteData - ld a,[H_SPRITEINDEX] + ld hl, wMapSpriteData + ld a, [H_SPRITEINDEX] dec a add a - ld d,0 - ld e,a - add hl,de + ld d, 0 + ld e, a + add hl, de pop de ret @@ -2941,37 +2941,37 @@ HasEnoughCoins:: BankswitchHome:: ; switches to bank # in a ; Only use this when in the home bank! - ld [wBankswitchHomeTemp],a - ld a,[H_LOADEDROMBANK] - ld [wBankswitchHomeSavedROMBank],a - ld a,[wBankswitchHomeTemp] - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [wBankswitchHomeTemp], a + ld a, [H_LOADEDROMBANK] + ld [wBankswitchHomeSavedROMBank], a + ld a, [wBankswitchHomeTemp] + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret BankswitchBack:: ; returns from BankswitchHome - ld a,[wBankswitchHomeSavedROMBank] - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, [wBankswitchHomeSavedROMBank] + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret Bankswitch:: ; self-contained bankswitch, use this when not in the home bank ; switches to the bank in b - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,b - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a - ld bc,.Return + ld a, b + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a + ld bc, .Return push bc jp hl .Return pop bc - ld a,b - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, b + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret ; displays yes/no choice @@ -3033,31 +3033,31 @@ MoveSprite_:: push bc call GetSpriteMovementByte1Pointer xor a - ld [hl],a - ld hl,wNPCMovementDirections - ld c,0 + ld [hl], a + ld hl, wNPCMovementDirections + ld c, 0 .loop - ld a,[de] - ld [hli],a + ld a, [de] + ld [hli], a inc de inc c cp $FF ; have we reached the end of the movement data? - jr nz,.loop + jr nz, .loop - ld a,c - ld [wNPCNumScriptedSteps],a ; number of steps taken + ld a, c + ld [wNPCNumScriptedSteps], a ; number of steps taken pop bc - ld hl,wd730 - set 0,[hl] + ld hl, wd730 + set 0, [hl] pop hl xor a - ld [wOverrideSimulatedJoypadStatesMask],a - ld [wSimulatedJoypadStatesEnd],a + ld [wOverrideSimulatedJoypadStatesMask], a + ld [wSimulatedJoypadStatesEnd], a dec a - ld [wJoyIgnore],a - ld [wWastedByteCD3A],a + ld [wJoyIgnore], a + ld [wWastedByteCD3A], a ret ; divides [hDividend2] by [hDivisor2] and stores the quotient in [hQuotient2] @@ -3198,7 +3198,7 @@ DelayFrames:: ; wait c frames call DelayFrame dec c - jr nz,DelayFrames + jr nz, DelayFrames ret PlaySoundWaitForCurrent:: @@ -3242,82 +3242,82 @@ GetName:: ; [wPredefBank] = bank of list ; ; returns pointer to name in de - ld a,[wd0b5] - ld [wd11e],a + ld a, [wd0b5] + ld [wd11e], a ; TM names are separate from item names. ; BUG: This applies to all names instead of just items. cp HM_01 jp nc, GetMachineName - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af push hl push bc push de - ld a,[wNameListType] ;List3759_entrySelector + ld a, [wNameListType] ;List3759_entrySelector dec a - jr nz,.otherEntries + jr nz, .otherEntries ;1 = MON_NAMES call GetMonName - ld hl,NAME_LENGTH - add hl,de - ld e,l - ld d,h + ld hl, NAME_LENGTH + add hl, de + ld e, l + ld d, h jr .gotPtr .otherEntries ;2-7 = OTHER ENTRIES - ld a,[wPredefBank] - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a - ld a,[wNameListType] ;VariousNames' entryID + ld a, [wPredefBank] + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a + ld a, [wNameListType] ;VariousNames' entryID dec a add a - ld d,0 - ld e,a - jr nc,.skip + ld d, 0 + ld e, a + jr nc, .skip inc d .skip - ld hl,NamePointers - add hl,de - ld a,[hli] - ld [$ff96],a - ld a,[hl] - ld [$ff95],a - ld a,[$ff95] - ld h,a - ld a,[$ff96] - ld l,a - ld a,[wd0b5] - ld b,a - ld c,0 + ld hl, NamePointers + add hl, de + ld a, [hli] + ld [$ff96], a + ld a, [hl] + ld [$ff95], a + ld a, [$ff95] + ld h, a + ld a, [$ff96] + ld l, a + ld a, [wd0b5] + ld b, a + ld c, 0 .nextName - ld d,h - ld e,l + ld d, h + ld e, l .nextChar - ld a,[hli] + ld a, [hli] cp "@" - jr nz,.nextChar + jr nz, .nextChar inc c ;entry counter - ld a,b ;wanted entry + ld a, b ;wanted entry cp c - jr nz,.nextName - ld h,d - ld l,e - ld de,wcd6d - ld bc,$0014 + jr nz, .nextName + ld h, d + ld l, e + ld de, wcd6d + ld bc, $0014 call CopyData .gotPtr - ld a,e - ld [wUnusedCF8D],a - ld a,d - ld [wUnusedCF8D + 1],a + ld a, e + ld [wUnusedCF8D], a + ld a, d + ld [wUnusedCF8D + 1], a pop de pop bc pop hl pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a ret GetItemPrice:: @@ -3396,41 +3396,41 @@ CopyString:: ; ([hJoy7] == 1, [hJoy6] == 0) JoypadLowSensitivity:: call Joypad - ld a,[hJoy7] ; flag + ld a, [hJoy7] ; flag and a ; get all currently pressed buttons or only newly pressed buttons? - ld a,[hJoyPressed] ; newly pressed buttons - jr z,.storeButtonState - ld a,[hJoyHeld] ; all currently pressed buttons + ld a, [hJoyPressed] ; newly pressed buttons + jr z, .storeButtonState + ld a, [hJoyHeld] ; all currently pressed buttons .storeButtonState - ld [hJoy5],a - ld a,[hJoyPressed] ; newly pressed buttons + ld [hJoy5], a + ld a, [hJoyPressed] ; newly pressed buttons and a ; have any buttons been newly pressed since last check? - jr z,.noNewlyPressedButtons + jr z, .noNewlyPressedButtons .newlyPressedButtons - ld a,30 ; half a second delay - ld [H_FRAMECOUNTER],a + ld a, 30 ; half a second delay + ld [H_FRAMECOUNTER], a ret .noNewlyPressedButtons - ld a,[H_FRAMECOUNTER] + ld a, [H_FRAMECOUNTER] and a ; is the delay over? - jr z,.delayOver + jr z, .delayOver .delayNotOver xor a - ld [hJoy5],a ; report no buttons as pressed + ld [hJoy5], a ; report no buttons as pressed ret .delayOver ; if [hJoy6] = 0 and A or B is pressed, report no buttons as pressed - ld a,[hJoyHeld] + ld a, [hJoyHeld] and A_BUTTON | B_BUTTON - jr z,.setShortDelay - ld a,[hJoy6] ; flag + jr z, .setShortDelay + ld a, [hJoy6] ; flag and a - jr nz,.setShortDelay + jr nz, .setShortDelay xor a - ld [hJoy5],a + ld [hJoy5], a .setShortDelay - ld a,5 ; 1/12 of a second delay - ld [H_FRAMECOUNTER],a + ld a, 5 ; 1/12 of a second delay + ld [H_FRAMECOUNTER], a ret WaitForTextScrollButtonPress:: @@ -3503,15 +3503,15 @@ Divide:: push hl push de push bc - ld a,[H_LOADEDROMBANK] + ld a, [H_LOADEDROMBANK] push af - ld a,Bank(_Divide) - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld a, Bank(_Divide) + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a call _Divide pop af - ld [H_LOADEDROMBANK],a - ld [MBC1RomBank],a + ld [H_LOADEDROMBANK], a + ld [MBC1RomBank], a pop bc pop de pop hl @@ -3521,42 +3521,42 @@ Divide:: ; screen unless the player presses the A/B button or the delay is turned off ; through the [wd730] or [wLetterPrintingDelayFlags] flags. PrintLetterDelay:: - ld a,[wd730] - bit 6,a + ld a, [wd730] + bit 6, a ret nz - ld a,[wLetterPrintingDelayFlags] - bit 1,a + ld a, [wLetterPrintingDelayFlags] + bit 1, a ret z push hl push de push bc - ld a,[wLetterPrintingDelayFlags] - bit 0,a - jr z,.waitOneFrame - ld a,[wOptions] + ld a, [wLetterPrintingDelayFlags] + bit 0, a + jr z, .waitOneFrame + ld a, [wOptions] and $f - ld [H_FRAMECOUNTER],a + ld [H_FRAMECOUNTER], a jr .checkButtons .waitOneFrame - ld a,1 - ld [H_FRAMECOUNTER],a + ld a, 1 + ld [H_FRAMECOUNTER], a .checkButtons call Joypad - ld a,[hJoyHeld] + ld a, [hJoyHeld] .checkAButton - bit 0,a ; is the A button pressed? - jr z,.checkBButton + bit 0, a ; is the A button pressed? + jr z, .checkBButton jr .endWait .checkBButton - bit 1,a ; is the B button pressed? - jr z,.buttonsNotPressed + bit 1, a ; is the B button pressed? + jr z, .buttonsNotPressed .endWait call DelayFrame jr .done .buttonsNotPressed ; if neither A nor B is pressed - ld a,[H_FRAMECOUNTER] + ld a, [H_FRAMECOUNTER] and a - jr nz,.checkButtons + jr nz, .checkButtons .done pop bc pop de @@ -3567,15 +3567,15 @@ PrintLetterDelay:: ; In other words, the source data is from hl up to but not including bc, ; and the destination is de. CopyDataUntil:: - ld a,[hli] - ld [de],a + ld a, [hli] + ld [de], a inc de - ld a,h + ld a, h cp b - jr nz,CopyDataUntil - ld a,l + jr nz, CopyDataUntil + ld a, l cp c - jr nz,CopyDataUntil + jr nz, CopyDataUntil ret ; Function to remove a pokemon from the party or the current box. @@ -3838,21 +3838,21 @@ AddNTimes:: and a ret z .loop - add hl,bc + add hl, bc dec a - jr nz,.loop + jr nz, .loop ret ; Compare strings, c bytes in length, at de and hl. ; Often used to compare big endian numbers in battle calculations. StringCmp:: - ld a,[de] + ld a, [de] cp [hl] ret nz inc de inc hl dec c - jr nz,StringCmp + jr nz, StringCmp ret ; INPUT: @@ -3861,228 +3861,228 @@ StringCmp:: ; c = X coordinate of upper left corner of sprite ; de = base address of 4 tile number and attribute pairs WriteOAMBlock:: - ld h,wOAMBuffer / $100 + ld h, wOAMBuffer / $100 swap a ; multiply by 16 - ld l,a + ld l, a call .writeOneEntry ; upper left push bc - ld a,8 + ld a, 8 add c - ld c,a + ld c, a call .writeOneEntry ; upper right pop bc - ld a,8 + ld a, 8 add b - ld b,a + ld b, a call .writeOneEntry ; lower left - ld a,8 + ld a, 8 add c - ld c,a + ld c, a ; lower right .writeOneEntry - ld [hl],b ; Y coordinate + ld [hl], b ; Y coordinate inc hl - ld [hl],c ; X coordinate + ld [hl], c ; X coordinate inc hl - ld a,[de] ; tile number + ld a, [de] ; tile number inc de - ld [hli],a - ld a,[de] ; attribute + ld [hli], a + ld a, [de] ; attribute inc de - ld [hli],a + ld [hli], a ret HandleMenuInput:: xor a - ld [wPartyMenuAnimMonEnabled],a + ld [wPartyMenuAnimMonEnabled], a HandleMenuInput_:: - ld a,[H_DOWNARROWBLINKCNT1] + ld a, [H_DOWNARROWBLINKCNT1] push af - ld a,[H_DOWNARROWBLINKCNT2] + ld a, [H_DOWNARROWBLINKCNT2] push af ; save existing values on stack xor a - ld [H_DOWNARROWBLINKCNT1],a ; blinking down arrow timing value 1 - ld a,6 - ld [H_DOWNARROWBLINKCNT2],a ; blinking down arrow timing value 2 + ld [H_DOWNARROWBLINKCNT1], a ; blinking down arrow timing value 1 + ld a, 6 + ld [H_DOWNARROWBLINKCNT2], a ; blinking down arrow timing value 2 .loop1 xor a - ld [wAnimCounter],a ; counter for pokemon shaking animation + ld [wAnimCounter], a ; counter for pokemon shaking animation call PlaceMenuCursor call Delay3 .loop2 push hl - ld a,[wPartyMenuAnimMonEnabled] + ld a, [wPartyMenuAnimMonEnabled] and a ; is it a pokemon selection menu? - jr z,.getJoypadState + jr z, .getJoypadState callba AnimatePartyMon ; shake mini sprite of selected pokemon .getJoypadState pop hl call JoypadLowSensitivity - ld a,[hJoy5] + ld a, [hJoy5] and a ; was a key pressed? - jr nz,.keyPressed + jr nz, .keyPressed push hl coord hl, 18, 11 ; coordinates of blinking down arrow in some menus call HandleDownArrowBlinkTiming ; blink down arrow (if any) pop hl - ld a,[wMenuJoypadPollCount] + ld a, [wMenuJoypadPollCount] dec a - jr z,.giveUpWaiting + jr z, .giveUpWaiting jr .loop2 .giveUpWaiting ; if a key wasn't pressed within the specified number of checks pop af - ld [H_DOWNARROWBLINKCNT2],a + ld [H_DOWNARROWBLINKCNT2], a pop af - ld [H_DOWNARROWBLINKCNT1],a ; restore previous values + ld [H_DOWNARROWBLINKCNT1], a ; restore previous values xor a - ld [wMenuWrappingEnabled],a ; disable menu wrapping + ld [wMenuWrappingEnabled], a ; disable menu wrapping ret .keyPressed xor a - ld [wCheckFor180DegreeTurn],a - ld a,[hJoy5] - ld b,a - bit 6,a ; pressed Up key? - jr z,.checkIfDownPressed + ld [wCheckFor180DegreeTurn], a + ld a, [hJoy5] + ld b, a + bit 6, a ; pressed Up key? + jr z, .checkIfDownPressed .upPressed - ld a,[wCurrentMenuItem] ; selected menu item + ld a, [wCurrentMenuItem] ; selected menu item and a ; already at the top of the menu? - jr z,.alreadyAtTop + jr z, .alreadyAtTop .notAtTop dec a - ld [wCurrentMenuItem],a ; move selected menu item up one space + ld [wCurrentMenuItem], a ; move selected menu item up one space jr .checkOtherKeys .alreadyAtTop - ld a,[wMenuWrappingEnabled] + ld a, [wMenuWrappingEnabled] and a ; is wrapping around enabled? - jr z,.noWrappingAround - ld a,[wMaxMenuItem] - ld [wCurrentMenuItem],a ; wrap to the bottom of the menu + jr z, .noWrappingAround + ld a, [wMaxMenuItem] + ld [wCurrentMenuItem], a ; wrap to the bottom of the menu jr .checkOtherKeys .checkIfDownPressed - bit 7,a - jr z,.checkOtherKeys + bit 7, a + jr z, .checkOtherKeys .downPressed - ld a,[wCurrentMenuItem] + ld a, [wCurrentMenuItem] inc a - ld c,a - ld a,[wMaxMenuItem] + ld c, a + ld a, [wMaxMenuItem] cp c - jr nc,.notAtBottom + jr nc, .notAtBottom .alreadyAtBottom - ld a,[wMenuWrappingEnabled] + ld a, [wMenuWrappingEnabled] and a ; is wrapping around enabled? - jr z,.noWrappingAround - ld c,$00 ; wrap from bottom to top + jr z, .noWrappingAround + ld c, $00 ; wrap from bottom to top .notAtBottom - ld a,c - ld [wCurrentMenuItem],a + ld a, c + ld [wCurrentMenuItem], a .checkOtherKeys - ld a,[wMenuWatchedKeys] + ld a, [wMenuWatchedKeys] and b ; does the menu care about any of the pressed keys? - jp z,.loop1 + jp z, .loop1 .checkIfAButtonOrBButtonPressed - ld a,[hJoy5] + ld a, [hJoy5] and A_BUTTON | B_BUTTON - jr z,.skipPlayingSound + jr z, .skipPlayingSound .AButtonOrBButtonPressed push hl - ld hl,wFlags_0xcd60 - bit 5,[hl] + ld hl, wFlags_0xcd60 + bit 5, [hl] pop hl - jr nz,.skipPlayingSound - ld a,SFX_PRESS_AB + jr nz, .skipPlayingSound + ld a, SFX_PRESS_AB call PlaySound .skipPlayingSound pop af - ld [H_DOWNARROWBLINKCNT2],a + ld [H_DOWNARROWBLINKCNT2], a pop af - ld [H_DOWNARROWBLINKCNT1],a ; restore previous values + ld [H_DOWNARROWBLINKCNT1], a ; restore previous values xor a - ld [wMenuWrappingEnabled],a ; disable menu wrapping - ld a,[hJoy5] + ld [wMenuWrappingEnabled], a ; disable menu wrapping + ld a, [hJoy5] ret .noWrappingAround - ld a,[wMenuWatchMovingOutOfBounds] + ld a, [wMenuWatchMovingOutOfBounds] and a ; should we return if the user tried to go past the top or bottom? - jr z,.checkOtherKeys + jr z, .checkOtherKeys jr .checkIfAButtonOrBButtonPressed PlaceMenuCursor:: - ld a,[wTopMenuItemY] + ld a, [wTopMenuItemY] and a ; is the y coordinate 0? - jr z,.adjustForXCoord + jr z, .adjustForXCoord coord hl, 0, 0 - ld bc,SCREEN_WIDTH + ld bc, SCREEN_WIDTH .topMenuItemLoop - add hl,bc + add hl, bc dec a - jr nz,.topMenuItemLoop + jr nz, .topMenuItemLoop .adjustForXCoord - ld a,[wTopMenuItemX] - ld b,0 - ld c,a - add hl,bc + ld a, [wTopMenuItemX] + ld b, 0 + ld c, a + add hl, bc push hl - ld a,[wLastMenuItem] + ld a, [wLastMenuItem] and a ; was the previous menu id 0? - jr z,.checkForArrow1 + jr z, .checkForArrow1 push af - ld a,[hFlags_0xFFF6] - bit 1,a ; is the menu double spaced? - jr z,.doubleSpaced1 - ld bc,20 + ld a, [hFlags_0xFFF6] + bit 1, a ; is the menu double spaced? + jr z, .doubleSpaced1 + ld bc, 20 jr .getOldMenuItemScreenPosition .doubleSpaced1 - ld bc,40 + ld bc, 40 .getOldMenuItemScreenPosition pop af .oldMenuItemLoop - add hl,bc + add hl, bc dec a - jr nz,.oldMenuItemLoop + jr nz, .oldMenuItemLoop .checkForArrow1 - ld a,[hl] - cp a,"▶" ; was an arrow next to the previously selected menu item? - jr nz,.skipClearingArrow + ld a, [hl] + cp "▶" ; was an arrow next to the previously selected menu item? + jr nz, .skipClearingArrow .clearArrow - ld a,[wTileBehindCursor] - ld [hl],a + ld a, [wTileBehindCursor] + ld [hl], a .skipClearingArrow pop hl - ld a,[wCurrentMenuItem] + ld a, [wCurrentMenuItem] and a - jr z,.checkForArrow2 + jr z, .checkForArrow2 push af - ld a,[hFlags_0xFFF6] - bit 1,a ; is the menu double spaced? - jr z,.doubleSpaced2 - ld bc,20 + ld a, [hFlags_0xFFF6] + bit 1, a ; is the menu double spaced? + jr z, .doubleSpaced2 + ld bc, 20 jr .getCurrentMenuItemScreenPosition .doubleSpaced2 - ld bc,40 + ld bc, 40 .getCurrentMenuItemScreenPosition pop af .currentMenuItemLoop - add hl,bc + add hl, bc dec a - jr nz,.currentMenuItemLoop + jr nz, .currentMenuItemLoop .checkForArrow2 - ld a,[hl] + ld a, [hl] cp "▶" ; has the right arrow already been placed? - jr z,.skipSavingTile ; if so, don't lose the saved tile - ld [wTileBehindCursor],a ; save tile before overwriting with right arrow + jr z, .skipSavingTile ; if so, don't lose the saved tile + ld [wTileBehindCursor], a ; save tile before overwriting with right arrow .skipSavingTile - ld a,"▶" ; place right arrow - ld [hl],a - ld a,l - ld [wMenuCursorLocation],a - ld a,h - ld [wMenuCursorLocation + 1],a - ld a,[wCurrentMenuItem] - ld [wLastMenuItem],a + ld a, "▶" ; place right arrow + ld [hl], a + ld a, l + ld [wMenuCursorLocation], a + ld a, h + ld [wMenuCursorLocation + 1], a + ld a, [wCurrentMenuItem] + ld [wLastMenuItem], a ret ; This is used to mark a menu cursor other than the one currently being @@ -4090,22 +4090,22 @@ PlaceMenuCursor:: ; the menu cursor in the parent menu. In the case of swapping items in list, ; this is used to mark the item that was first chosen to be swapped. PlaceUnfilledArrowMenuCursor:: - ld b,a - ld a,[wMenuCursorLocation] - ld l,a - ld a,[wMenuCursorLocation + 1] - ld h,a - ld [hl],$ec ; outline of right arrow - ld a,b + ld b, a + ld a, [wMenuCursorLocation] + ld l, a + ld a, [wMenuCursorLocation + 1] + ld h, a + ld [hl], $ec ; outline of right arrow + ld a, b ret ; Replaces the menu cursor with a blank space. EraseMenuCursor:: - ld a,[wMenuCursorLocation] - ld l,a - ld a,[wMenuCursorLocation + 1] - ld h,a - ld [hl]," " + ld a, [wMenuCursorLocation] + ld l, a + ld a, [wMenuCursorLocation + 1] + ld h, a + ld [hl], " " ret ; This toggles a blinking down arrow at hl on and off after a delay has passed. @@ -4117,44 +4117,44 @@ EraseMenuCursor:: ; That allows this to be called without worrying about if a down arrow should ; be blinking. HandleDownArrowBlinkTiming:: - ld a,[hl] - ld b,a - ld a,"▼" + ld a, [hl] + ld b, a + ld a, "▼" cp b - jr nz,.downArrowOff + jr nz, .downArrowOff .downArrowOn - ld a,[H_DOWNARROWBLINKCNT1] + ld a, [H_DOWNARROWBLINKCNT1] dec a - ld [H_DOWNARROWBLINKCNT1],a + ld [H_DOWNARROWBLINKCNT1], a ret nz - ld a,[H_DOWNARROWBLINKCNT2] + ld a, [H_DOWNARROWBLINKCNT2] dec a - ld [H_DOWNARROWBLINKCNT2],a + ld [H_DOWNARROWBLINKCNT2], a ret nz - ld a," " - ld [hl],a - ld a,$ff - ld [H_DOWNARROWBLINKCNT1],a - ld a,$06 - ld [H_DOWNARROWBLINKCNT2],a + ld a, " " + ld [hl], a + ld a, $ff + ld [H_DOWNARROWBLINKCNT1], a + ld a, $06 + ld [H_DOWNARROWBLINKCNT2], a ret .downArrowOff - ld a,[H_DOWNARROWBLINKCNT1] + ld a, [H_DOWNARROWBLINKCNT1] and a ret z dec a - ld [H_DOWNARROWBLINKCNT1],a + ld [H_DOWNARROWBLINKCNT1], a ret nz dec a - ld [H_DOWNARROWBLINKCNT1],a - ld a,[H_DOWNARROWBLINKCNT2] + ld [H_DOWNARROWBLINKCNT1], a + ld a, [H_DOWNARROWBLINKCNT2] dec a - ld [H_DOWNARROWBLINKCNT2],a + ld [H_DOWNARROWBLINKCNT2], a ret nz - ld a,$06 - ld [H_DOWNARROWBLINKCNT2],a - ld a,"▼" - ld [hl],a + ld a, $06 + ld [H_DOWNARROWBLINKCNT2], a + ld a, "▼" + ld [hl], a ret ; The following code either enables or disables the automatic drawing of @@ -4166,19 +4166,19 @@ EnableAutoTextBoxDrawing:: jr AutoTextBoxDrawingCommon DisableAutoTextBoxDrawing:: - ld a,$01 + ld a, $01 AutoTextBoxDrawingCommon:: - ld [wAutoTextBoxDrawingControl],a + ld [wAutoTextBoxDrawingControl], a xor a - ld [wDoNotWaitForButtonPressAfterDisplayingText],a ; make DisplayTextID wait for button press + ld [wDoNotWaitForButtonPressAfterDisplayingText], a ; make DisplayTextID wait for button press ret PrintText:: ; Print text hl at (1, 14). push hl - ld a,MESSAGE_BOX - ld [wTextBoxID],a + ld a, MESSAGE_BOX + ld [wTextBoxID], a call DisplayTextBoxID call UpdateSprites call Delay3 @@ -4488,16 +4488,16 @@ GBPalNormal:: GBPalWhiteOut:: ; White out all palettes. xor a - ld [rBGP],a - ld [rOBP0],a - ld [rOBP1],a + ld [rBGP], a + ld [rOBP0], a + ld [rOBP1], a ret RunDefaultPaletteCommand:: - ld b,$ff + ld b, $ff RunPaletteCommand:: - ld a,[wOnSGB] + ld a, [wOnSGB] and a ret z predef_jump _RunPaletteCommand @@ -4547,7 +4547,7 @@ GiveItem:: ld [wcf91], a ld a, c ld [wItemQuantity], a - ld hl,wNumBagItems + ld hl, wNumBagItems call AddItemToInventory ret nc call GetItemName |