diff options
Diffstat (limited to 'engine/overworld')
-rwxr-xr-x | engine/overworld/map_sprites.asm | 416 | ||||
-rwxr-xr-x | engine/overworld/pokemart.asm | 228 | ||||
-rw-r--r-- | engine/overworld/wild_mons.asm | 40 |
3 files changed, 342 insertions, 342 deletions
diff --git a/engine/overworld/map_sprites.asm b/engine/overworld/map_sprites.asm index 2a221c7e..8a6057a0 100755 --- a/engine/overworld/map_sprites.asm +++ b/engine/overworld/map_sprites.asm @@ -12,113 +12,113 @@ InitMapSprites: call InitOutsideMapSprites ret c ; return if the map is an outside map (already handled by above call) ; if the map is an inside map (i.e. mapID >= $25) - ld hl,wSpriteStateData1 - ld de,wSpriteStateData2 + $0d + ld hl, wSpriteStateData1 + ld de, wSpriteStateData2 + $0d ; Loop to copy picture ID's from $C1X0 to $C2XD for LoadMapSpriteTilePatterns. .copyPictureIDLoop - ld a,[hl] ; $C1X0 (picture ID) - ld [de],a ; $C2XD - ld a,$10 + ld a, [hl] ; $C1X0 (picture ID) + ld [de], a ; $C2XD + ld a, $10 add e - ld e,a - ld a,$10 + ld e, a + ld a, $10 add l - ld l,a - jr nz,.copyPictureIDLoop + ld l, a + jr nz, .copyPictureIDLoop ; This is used for both inside and outside maps, since it is called by ; InitOutsideMapSprites. ; Loads tile pattern data for sprites into VRAM. LoadMapSpriteTilePatterns: - ld a,[wNumSprites] + ld a, [wNumSprites] and a ; are there any sprites? - jr nz,.spritesExist + jr nz, .spritesExist ret .spritesExist - ld c,a ; c = [wNumSprites] - ld b,$10 ; number of sprite slots - ld hl,wSpriteStateData2 + $0d + ld c, a ; c = [wNumSprites] + ld b, $10 ; number of sprite slots + ld hl, wSpriteStateData2 + $0d xor a - ld [hFourTileSpriteCount],a + ld [hFourTileSpriteCount], a .copyPictureIDLoop ; loop to copy picture ID from $C2XD to $C2XE - ld a,[hli] ; $C2XD (sprite picture ID) - ld [hld],a ; $C2XE - ld a,l - add a,$10 - ld l,a + ld a, [hli] ; $C2XD (sprite picture ID) + ld [hld], a ; $C2XE + ld a, l + add $10 + ld l, a dec b - jr nz,.copyPictureIDLoop - ld hl,wSpriteStateData2 + $1e + jr nz, .copyPictureIDLoop + ld hl, wSpriteStateData2 + $1e .loadTilePatternLoop - ld de,wSpriteStateData2 + $1d + ld de, wSpriteStateData2 + $1d ; Check if the current picture ID has already had its tile patterns loaded. ; This done by looping through the previous sprite slots and seeing if any of ; their picture ID's match that of the current sprite slot. .checkIfAlreadyLoadedLoop - ld a,e - and a,$f0 - ld b,a ; b = offset of the wSpriteStateData2 sprite slot being checked against - ld a,l - and a,$f0 ; a = offset of current wSpriteStateData2 sprite slot + ld a, e + and $f0 + ld b, a ; b = offset of the wSpriteStateData2 sprite slot being checked against + ld a, l + and $f0 ; a = offset of current wSpriteStateData2 sprite slot cp b ; done checking all previous sprite slots? - jr z,.notAlreadyLoaded - ld a,[de] ; picture ID of the wSpriteStateData2 sprite slot being checked against + jr z, .notAlreadyLoaded + ld a, [de] ; picture ID of the wSpriteStateData2 sprite slot being checked against cp [hl] ; do the picture ID's match? - jp z,.alreadyLoaded - ld a,e - add a,$10 - ld e,a + jp z, .alreadyLoaded + ld a, e + add $10 + ld e, a jr .checkIfAlreadyLoadedLoop .notAlreadyLoaded - ld de,wSpriteStateData2 + $0e - ld b,$01 + ld de, wSpriteStateData2 + $0e + ld b, $01 ; loop to find the highest tile pattern VRAM slot (among the first 10 slots) used by a previous sprite slot ; this is done in order to find the first free VRAM slot available .findNextVRAMSlotLoop - ld a,e - add a,$10 - ld e,a - ld a,l + ld a, e + add $10 + ld e, a + ld a, l cp e ; reached current slot? - jr z,.foundNextVRAMSlot - ld a,[de] ; $C2YE (VRAM slot) - cp a,11 ; is it one of the first 10 slots? - jr nc,.findNextVRAMSlotLoop + jr z, .foundNextVRAMSlot + ld a, [de] ; $C2YE (VRAM slot) + cp 11 ; is it one of the first 10 slots? + jr nc, .findNextVRAMSlotLoop cp b ; compare the slot being checked to the current max - jr c,.findNextVRAMSlotLoop ; if the slot being checked is less than the current max + jr c, .findNextVRAMSlotLoop ; if the slot being checked is less than the current max ; if the slot being checked is greater than or equal to the current max - ld b,a ; store new max VRAM slot + ld b, a ; store new max VRAM slot jr .findNextVRAMSlotLoop .foundNextVRAMSlot inc b ; increment previous max value to get next VRAM tile pattern slot - ld a,b ; a = next VRAM tile pattern slot + ld a, b ; a = next VRAM tile pattern slot push af - ld a,[hl] ; $C2XE (sprite picture ID) - ld b,a ; b = current sprite picture ID - cp a,SPRITE_BALL ; is it a 4-tile sprite? - jr c,.notFourTileSprite + ld a, [hl] ; $C2XE (sprite picture ID) + ld b, a ; b = current sprite picture ID + cp SPRITE_BALL ; is it a 4-tile sprite? + jr c, .notFourTileSprite pop af - ld a,[hFourTileSpriteCount] - add a,11 + ld a, [hFourTileSpriteCount] + add 11 jr .storeVRAMSlot .notFourTileSprite pop af .storeVRAMSlot - ld [hl],a ; store VRAM slot at $C2XE - ld [hVRAMSlot],a ; used to determine if it's 4-tile sprite later - ld a,b ; a = current sprite picture ID + ld [hl], a ; store VRAM slot at $C2XE + ld [hVRAMSlot], a ; used to determine if it's 4-tile sprite later + ld a, b ; a = current sprite picture ID dec a add a add a push bc push hl - ld hl,SpriteSheetPointerTable - jr nc,.noCarry + ld hl, SpriteSheetPointerTable + jr nc, .noCarry inc h .noCarry add l - ld l,a - jr nc,.noCarry2 + ld l, a + jr nc, .noCarry2 inc h .noCarry2 push hl @@ -126,69 +126,69 @@ LoadMapSpriteTilePatterns: push af push de push bc - ld hl,vNPCSprites ; VRAM base address - ld bc,$c0 ; number of bytes per VRAM slot - ld a,[hVRAMSlot] - cp a,11 ; is it a 4-tile sprite? - jr nc,.fourTileSpriteVRAMAddr - ld d,a + ld hl, vNPCSprites ; VRAM base address + ld bc, $c0 ; number of bytes per VRAM slot + ld a, [hVRAMSlot] + cp 11 ; is it a 4-tile sprite? + jr nc, .fourTileSpriteVRAMAddr + ld d, a dec d ; Equivalent to multiplying $C0 (number of bytes in 12 tiles) times the VRAM ; slot and adding the result to $8000 (the VRAM base address). .calculateVRAMAddrLoop - add hl,bc + add hl, bc dec d - jr nz,.calculateVRAMAddrLoop + jr nz, .calculateVRAMAddrLoop jr .loadStillTilePattern .fourTileSpriteVRAMAddr - ld hl,vSprites + $7c0 ; address for second 4-tile sprite - ld a,[hFourTileSpriteCount] + ld hl, vSprites + $7c0 ; address for second 4-tile sprite + ld a, [hFourTileSpriteCount] and a - jr nz,.loadStillTilePattern + jr nz, .loadStillTilePattern ; if it's the first 4-tile sprite - ld hl,vSprites + $780 ; address for first 4-tile sprite + ld hl, vSprites + $780 ; address for first 4-tile sprite inc a - ld [hFourTileSpriteCount],a + ld [hFourTileSpriteCount], a .loadStillTilePattern pop bc pop de pop af push hl push hl - ld h,d - ld l,e + ld h, d + ld l, e pop de - ld b,a - ld a,[wFontLoaded] - bit 0,a ; reloading upper half of tile patterns after displaying text? - jr nz,.skipFirstLoad ; if so, skip loading data into the lower half - ld a,b - ld b,0 + ld b, a + ld a, [wFontLoaded] + bit 0, a ; reloading upper half of tile patterns after displaying text? + jr nz, .skipFirstLoad ; if so, skip loading data into the lower half + ld a, b + ld b, 0 call FarCopyData2 ; load tile pattern data for sprite when standing still .skipFirstLoad pop de pop hl - ld a,[hVRAMSlot] - cp a,11 ; is it a 4-tile sprite? - jr nc,.skipSecondLoad ; if so, there is no second block + ld a, [hVRAMSlot] + cp 11 ; is it a 4-tile sprite? + jr nc, .skipSecondLoad ; if so, there is no second block push de call ReadSpriteSheetData push af - ld a,$c0 + ld a, $c0 add e - ld e,a - jr nc,.noCarry3 + ld e, a + jr nc, .noCarry3 inc d .noCarry3 - ld a,[wFontLoaded] - bit 0,a ; reloading upper half of tile patterns after displaying text? - jr nz,.loadWhileLCDOn + ld a, [wFontLoaded] + bit 0, a ; reloading upper half of tile patterns after displaying text? + jr nz, .loadWhileLCDOn pop af pop hl - set 3,h ; add $800 to hl + set 3, h ; add $800 to hl push hl - ld h,d - ld l,e + ld h, d + ld l, e pop de call FarCopyData2 ; load tile pattern data for sprite when walking jr .skipSecondLoad @@ -198,8 +198,8 @@ LoadMapSpriteTilePatterns: .loadWhileLCDOn pop af pop hl - set 3,h ; add $800 to hl - ld b,a + set 3, h ; add $800 to hl + ld b, a swap c call CopyVideoData ; load tile pattern data for sprite when walking .skipSecondLoad @@ -208,25 +208,25 @@ LoadMapSpriteTilePatterns: jr .nextSpriteSlot .alreadyLoaded ; if the current picture ID has already had its tile patterns loaded inc de - ld a,[de] ; a = VRAM slot for the current picture ID (from $C2YE) - ld [hl],a ; store VRAM slot in current wSpriteStateData2 sprite slot (at $C2XE) + ld a, [de] ; a = VRAM slot for the current picture ID (from $C2YE) + ld [hl], a ; store VRAM slot in current wSpriteStateData2 sprite slot (at $C2XE) .nextSpriteSlot - ld a,l - add a,$10 - ld l,a + ld a, l + add $10 + ld l, a dec c - jp nz,.loadTilePatternLoop - ld hl,wSpriteStateData2 + $0d - ld b,$10 + jp nz, .loadTilePatternLoop + ld hl, wSpriteStateData2 + $0d + ld b, $10 ; the pictures ID's stored at $C2XD are no longer needed, so zero them .zeroStoredPictureIDLoop xor a - ld [hl],a ; $C2XD - ld a,$10 + ld [hl], a ; $C2XD + ld a, $10 add l - ld l,a + ld l, a dec b - jr nz,.zeroStoredPictureIDLoop + jr nz, .zeroStoredPictureIDLoop ret ; reads data from SpriteSheetPointerTable @@ -237,108 +237,108 @@ LoadMapSpriteTilePatterns: ; bc = length in bytes ; a = ROM bank ReadSpriteSheetData: - ld a,[hli] - ld e,a - ld a,[hli] - ld d,a - ld a,[hli] - ld c,a + ld a, [hli] + ld e, a + ld a, [hli] + ld d, a + ld a, [hli] + ld c, a xor a - ld b,a - ld a,[hli] + ld b, a + ld a, [hli] ret ; Loads sprite set for outside maps (cities and routes) and sets VRAM slots. ; sets carry if the map is a city or route, unsets carry if not InitOutsideMapSprites: - ld a,[wCurMap] - cp a,REDS_HOUSE_1F ; is the map a city or a route (map ID less than $25)? + ld a, [wCurMap] + cp REDS_HOUSE_1F ; is the map a city or a route (map ID less than $25)? ret nc ; if not, return - ld hl,MapSpriteSets + ld hl, MapSpriteSets add l - ld l,a - jr nc,.noCarry + ld l, a + jr nc, .noCarry inc h .noCarry - ld a,[hl] ; a = spriteSetID - cp a,$f0 ; does the map have 2 sprite sets? - call nc,GetSplitMapSpriteSetID ; if so, choose the appropriate one - ld b,a ; b = spriteSetID - ld a,[wFontLoaded] - bit 0,a ; reloading upper half of tile patterns after displaying text? - jr nz,.loadSpriteSet ; if so, forcibly reload the sprite set - ld a,[wSpriteSetID] + ld a, [hl] ; a = spriteSetID + cp $f0 ; does the map have 2 sprite sets? + call nc, GetSplitMapSpriteSetID ; if so, choose the appropriate one + ld b, a ; b = spriteSetID + ld a, [wFontLoaded] + bit 0, a ; reloading upper half of tile patterns after displaying text? + jr nz, .loadSpriteSet ; if so, forcibly reload the sprite set + ld a, [wSpriteSetID] cp b ; has the sprite set ID changed? - jr z,.skipLoadingSpriteSet ; if not, don't load it again + jr z, .skipLoadingSpriteSet ; if not, don't load it again .loadSpriteSet - ld a,b - ld [wSpriteSetID],a + ld a, b + ld [wSpriteSetID], a dec a - ld b,a + ld b, a sla a - ld c,a + ld c, a sla a sla a add c add b ; a = (spriteSetID - 1) * 11 - ld de,SpriteSets + ld de, SpriteSets ; add a to de to get offset of sprite set add e - ld e,a - jr nc,.noCarry2 + ld e, a + jr nc, .noCarry2 inc d .noCarry2 - ld hl,wSpriteStateData2 + $0d - ld a,SPRITE_RED - ld [hl],a - ld bc,wSpriteSet + ld hl, wSpriteStateData2 + $0d + ld a, SPRITE_RED + ld [hl], a + ld bc, wSpriteSet ; Load the sprite set into RAM. ; This loop also fills $C2XD (sprite picture ID) where X is from $0 to $A ; with picture ID's. This is done so that LoadMapSpriteTilePatterns will ; load tile patterns for all sprite pictures in the sprite set. .loadSpriteSetLoop - ld a,$10 + ld a, $10 add l - ld l,a - ld a,[de] ; sprite picture ID from sprite set - ld [hl],a ; $C2XD (sprite picture ID) - ld [bc],a + ld l, a + ld a, [de] ; sprite picture ID from sprite set + ld [hl], a ; $C2XD (sprite picture ID) + ld [bc], a inc de inc bc - ld a,l - cp a,$bd ; reached 11th sprite slot? - jr nz,.loadSpriteSetLoop - ld b,4 ; 4 remaining sprite slots + ld a, l + cp $bd ; reached 11th sprite slot? + jr nz, .loadSpriteSetLoop + ld b, 4 ; 4 remaining sprite slots .zeroRemainingSlotsLoop ; loop to zero the picture ID's of the remaining sprite slots - ld a,$10 + ld a, $10 add l - ld l,a + ld l, a xor a - ld [hl],a ; $C2XD (sprite picture ID) + ld [hl], a ; $C2XD (sprite picture ID) dec b - jr nz,.zeroRemainingSlotsLoop - ld a,[wNumSprites] + jr nz, .zeroRemainingSlotsLoop + ld a, [wNumSprites] push af ; save number of sprites - ld a,11 ; 11 sprites in sprite set - ld [wNumSprites],a + ld a, 11 ; 11 sprites in sprite set + ld [wNumSprites], a call LoadMapSpriteTilePatterns pop af - ld [wNumSprites],a ; restore number of sprites - ld hl,wSpriteStateData2 + $1e - ld b,$0f + ld [wNumSprites], a ; restore number of sprites + ld hl, wSpriteStateData2 + $1e + ld b, $0f ; The VRAM tile pattern slots that LoadMapSpriteTilePatterns set are in the ; order of the map's sprite set, not the order of the actual sprites loaded ; for the current map. So, they are not needed and are zeroed by this loop. .zeroVRAMSlotsLoop xor a - ld [hl],a ; $C2XE (VRAM slot) - ld a,$10 + ld [hl], a ; $C2XE (VRAM slot) + ld a, $10 add l - ld l,a + ld l, a dec b - jr nz,.zeroVRAMSlotsLoop + jr nz, .zeroVRAMSlotsLoop .skipLoadingSpriteSet - ld hl,wSpriteStateData1 + $10 + ld hl, wSpriteStateData1 + $10 ; This loop stores the correct VRAM tile pattern slots according the sprite ; data from the map's header. Since the VRAM tile pattern slots are filled in ; the order of the sprite set, in order to find the VRAM tile pattern slot @@ -347,94 +347,94 @@ InitOutsideMapSprites: ; (since the Red sprite always has the first VRAM tile pattern slot) is the ; VRAM tile pattern slot. .storeVRAMSlotsLoop - ld c,0 - ld a,[hl] ; $C1X0 (picture ID) (zero if sprite slot is not used) + ld c, 0 + ld a, [hl] ; $C1X0 (picture ID) (zero if sprite slot is not used) and a ; is the sprite slot used? - jr z,.skipGettingPictureIndex ; if the sprite slot is not used - ld b,a ; b = picture ID - ld de,wSpriteSet + jr z, .skipGettingPictureIndex ; if the sprite slot is not used + ld b, a ; b = picture ID + ld de, wSpriteSet ; Loop to find the index of the sprite's picture ID within the sprite set. .getPictureIndexLoop inc c - ld a,[de] + ld a, [de] inc de cp b ; does the picture ID match? - jr nz,.getPictureIndexLoop + jr nz, .getPictureIndexLoop inc c .skipGettingPictureIndex push hl inc h - ld a,$0e + ld a, $0e add l - ld l,a - ld a,c ; a = VRAM slot (zero if sprite slot is not used) - ld [hl],a ; $C2XE (VRAM slot) + ld l, a + ld a, c ; a = VRAM slot (zero if sprite slot is not used) + ld [hl], a ; $C2XE (VRAM slot) pop hl - ld a,$10 + ld a, $10 add l - ld l,a + ld l, a and a - jr nz,.storeVRAMSlotsLoop + jr nz, .storeVRAMSlotsLoop scf ret ; Chooses the correct sprite set ID depending on the player's position within ; the map for maps with two sprite sets. GetSplitMapSpriteSetID: - cp a,$f8 - jr z,.route20 - ld hl,SplitMapSpriteSets - and a,$0f + cp $f8 + jr z, .route20 + ld hl, SplitMapSpriteSets + and $0f dec a sla a sla a add l - ld l,a - jr nc,.noCarry + ld l, a + jr nc, .noCarry inc h .noCarry - ld a,[hli] ; determines whether the map is split East/West or North/South - cp a,$01 - ld a,[hli] ; position of dividing line - ld b,a - jr z,.eastWestDivide + ld a, [hli] ; determines whether the map is split East/West or North/South + cp $01 + ld a, [hli] ; position of dividing line + ld b, a + jr z, .eastWestDivide .northSouthDivide - ld a,[wYCoord] + ld a, [wYCoord] jr .compareCoord .eastWestDivide - ld a,[wXCoord] + ld a, [wXCoord] .compareCoord cp b - jr c,.loadSpriteSetID + jr c, .loadSpriteSetID ; if in the East side or South side inc hl .loadSpriteSetID - ld a,[hl] + ld a, [hl] ret ; Uses sprite set $01 for West side and $0A for East side. ; Route 20 is a special case because the two map sections have a more complex ; shape instead of the map simply being split horizontally or vertically. .route20 - ld hl,wXCoord - ld a,[hl] - cp a,$2b - ld a,$01 + ld hl, wXCoord + ld a, [hl] + cp $2b + ld a, $01 ret c - ld a,[hl] - cp a,$3e - ld a,$0a + ld a, [hl] + cp $3e + ld a, $0a ret nc - ld a,[hl] - cp a,$37 - ld b,$08 - jr nc,.next - ld b,$0d + ld a, [hl] + cp $37 + ld b, $08 + jr nc, .next + ld b, $0d .next - ld a,[wYCoord] + ld a, [wYCoord] cp b - ld a,$0a + ld a, $0a ret c - ld a,$01 + ld a, $01 ret INCLUDE "data/sprite_sets.asm" diff --git a/engine/overworld/pokemart.asm b/engine/overworld/pokemart.asm index 823939b1..dc5b29b5 100755 --- a/engine/overworld/pokemart.asm +++ b/engine/overworld/pokemart.asm @@ -1,230 +1,230 @@ DisplayPokemartDialogue_: - ld a,[wListScrollOffset] - ld [wSavedListScrollOffset],a + ld a, [wListScrollOffset] + ld [wSavedListScrollOffset], a call UpdateSprites xor a - ld [wBoughtOrSoldItemInMart],a + ld [wBoughtOrSoldItemInMart], a .loop xor a - ld [wListScrollOffset],a - ld [wCurrentMenuItem],a - ld [wPlayerMonNumber],a + ld [wListScrollOffset], a + ld [wCurrentMenuItem], a + ld [wPlayerMonNumber], a inc a - ld [wPrintItemPrices],a - ld a,MONEY_BOX - ld [wTextBoxID],a + ld [wPrintItemPrices], a + ld a, MONEY_BOX + ld [wTextBoxID], a call DisplayTextBoxID - ld a,BUY_SELL_QUIT_MENU - ld [wTextBoxID],a + ld a, BUY_SELL_QUIT_MENU + ld [wTextBoxID], a call DisplayTextBoxID ; This code is useless. It copies the address of the pokemart's inventory to hl, ; but the address is never used. - ld hl,wItemListPointer - ld a,[hli] - ld l,[hl] - ld h,a + ld hl, wItemListPointer + ld a, [hli] + ld l, [hl] + ld h, a - ld a,[wMenuExitMethod] - cp a,CANCELLED_MENU - jp z,.done - ld a,[wChosenMenuItem] + ld a, [wMenuExitMethod] + cp CANCELLED_MENU + jp z, .done + ld a, [wChosenMenuItem] and a ; buying? - jp z,.buyMenu + jp z, .buyMenu dec a ; selling? - jp z,.sellMenu + jp z, .sellMenu dec a ; quitting? - jp z,.done + jp z, .done .sellMenu ; the same variables are set again below, so this code has no effect xor a - ld [wPrintItemPrices],a - ld a,INIT_BAG_ITEM_LIST - ld [wInitListType],a + ld [wPrintItemPrices], a + ld a, INIT_BAG_ITEM_LIST + ld [wInitListType], a callab InitList - ld a,[wNumBagItems] + ld a, [wNumBagItems] and a - jp z,.bagEmpty - ld hl,PokemonSellingGreetingText + jp z, .bagEmpty + ld hl, PokemonSellingGreetingText call PrintText call SaveScreenTilesToBuffer1 ; save screen .sellMenuLoop call LoadScreenTilesFromBuffer1 ; restore saved screen - ld a,MONEY_BOX - ld [wTextBoxID],a + ld a, MONEY_BOX + ld [wTextBoxID], a call DisplayTextBoxID ; draw money text box - ld hl,wNumBagItems - ld a,l - ld [wListPointer],a - ld a,h - ld [wListPointer + 1],a + ld hl, wNumBagItems + ld a, l + ld [wListPointer], a + ld a, h + ld [wListPointer + 1], a xor a - ld [wPrintItemPrices],a - ld [wCurrentMenuItem],a - ld a,ITEMLISTMENU - ld [wListMenuID],a + ld [wPrintItemPrices], a + ld [wCurrentMenuItem], a + ld a, ITEMLISTMENU + ld [wListMenuID], a call DisplayListMenuID - jp c,.returnToMainPokemartMenu ; if the player closed the menu + jp c, .returnToMainPokemartMenu ; if the player closed the menu .confirmItemSale ; if the player is trying to sell a specific item call IsKeyItem - ld a,[wIsKeyItem] + ld a, [wIsKeyItem] and a - jr nz,.unsellableItem - ld a,[wcf91] + jr nz, .unsellableItem + ld a, [wcf91] call IsItemHM - jr c,.unsellableItem - ld a,PRICEDITEMLISTMENU - ld [wListMenuID],a - ld [hHalveItemPrices],a ; halve prices when selling + jr c, .unsellableItem + ld a, PRICEDITEMLISTMENU + ld [wListMenuID], a + ld [hHalveItemPrices], a ; halve prices when selling call DisplayChooseQuantityMenu inc a - jr z,.sellMenuLoop ; if the player closed the choose quantity menu with the B button - ld hl,PokemartTellSellPriceText + jr z, .sellMenuLoop ; if the player closed the choose quantity menu with the B button + ld hl, PokemartTellSellPriceText lb bc, 14, 1 ; location that PrintText always prints to, this is useless call PrintText coord hl, 14, 7 lb bc, 8, 15 - ld a,TWO_OPTION_MENU - ld [wTextBoxID],a + ld a, TWO_OPTION_MENU + ld [wTextBoxID], a call DisplayTextBoxID ; yes/no menu - ld a,[wMenuExitMethod] - cp a,CHOSE_SECOND_ITEM - jr z,.sellMenuLoop ; if the player chose No or pressed the B button + ld a, [wMenuExitMethod] + cp CHOSE_SECOND_ITEM + jr z, .sellMenuLoop ; if the player chose No or pressed the B button ; The following code is supposed to check if the player chose No, but the above ; check already catches it. - ld a,[wChosenMenuItem] + ld a, [wChosenMenuItem] dec a - jr z,.sellMenuLoop + jr z, .sellMenuLoop .sellItem - ld a,[wBoughtOrSoldItemInMart] + ld a, [wBoughtOrSoldItemInMart] and a - jr nz,.skipSettingFlag1 + jr nz, .skipSettingFlag1 inc a - ld [wBoughtOrSoldItemInMart],a + ld [wBoughtOrSoldItemInMart], a .skipSettingFlag1 call AddAmountSoldToMoney - ld hl,wNumBagItems + ld hl, wNumBagItems call RemoveItemFromInventory jp .sellMenuLoop .unsellableItem - ld hl,PokemartUnsellableItemText + ld hl, PokemartUnsellableItemText call PrintText jp .returnToMainPokemartMenu .bagEmpty - ld hl,PokemartItemBagEmptyText + ld hl, PokemartItemBagEmptyText call PrintText call SaveScreenTilesToBuffer1 jp .returnToMainPokemartMenu .buyMenu ; the same variables are set again below, so this code has no effect - ld a,1 - ld [wPrintItemPrices],a - ld a,INIT_OTHER_ITEM_LIST - ld [wInitListType],a + ld a, 1 + ld [wPrintItemPrices], a + ld a, INIT_OTHER_ITEM_LIST + ld [wInitListType], a callab InitList - ld hl,PokemartBuyingGreetingText + ld hl, PokemartBuyingGreetingText call PrintText call SaveScreenTilesToBuffer1 .buyMenuLoop call LoadScreenTilesFromBuffer1 - ld a,MONEY_BOX - ld [wTextBoxID],a + ld a, MONEY_BOX + ld [wTextBoxID], a call DisplayTextBoxID - ld hl,wItemList - ld a,l - ld [wListPointer],a - ld a,h - ld [wListPointer + 1],a + ld hl, wItemList + ld a, l + ld [wListPointer], a + ld a, h + ld [wListPointer + 1], a xor a - ld [wCurrentMenuItem],a + ld [wCurrentMenuItem], a inc a - ld [wPrintItemPrices],a + ld [wPrintItemPrices], a inc a ; a = 2 (PRICEDITEMLISTMENU) - ld [wListMenuID],a + ld [wListMenuID], a call DisplayListMenuID - jr c,.returnToMainPokemartMenu ; if the player closed the menu - ld a,99 - ld [wMaxItemQuantity],a + jr c, .returnToMainPokemartMenu ; if the player closed the menu + ld a, 99 + ld [wMaxItemQuantity], a xor a - ld [hHalveItemPrices],a ; don't halve item prices when buying + ld [hHalveItemPrices], a ; don't halve item prices when buying call DisplayChooseQuantityMenu inc a - jr z,.buyMenuLoop ; if the player closed the choose quantity menu with the B button - ld a,[wcf91] ; item ID - ld [wd11e],a ; store item ID for GetItemName + jr z, .buyMenuLoop ; if the player closed the choose quantity menu with the B button + ld a, [wcf91] ; item ID + ld [wd11e], a ; store item ID for GetItemName call GetItemName call CopyStringToCF4B ; copy name to wcf4b - ld hl,PokemartTellBuyPriceText + ld hl, PokemartTellBuyPriceText call PrintText coord hl, 14, 7 lb bc, 8, 15 - ld a,TWO_OPTION_MENU - ld [wTextBoxID],a + ld a, TWO_OPTION_MENU + ld [wTextBoxID], a call DisplayTextBoxID ; yes/no menu - ld a,[wMenuExitMethod] - cp a,CHOSE_SECOND_ITEM - jp z,.buyMenuLoop ; if the player chose No or pressed the B button + ld a, [wMenuExitMethod] + cp CHOSE_SECOND_ITEM + jp z, .buyMenuLoop ; if the player chose No or pressed the B button ; The following code is supposed to check if the player chose No, but the above ; check already catches it. - ld a,[wChosenMenuItem] + ld a, [wChosenMenuItem] dec a - jr z,.buyMenuLoop + jr z, .buyMenuLoop .buyItem call .isThereEnoughMoney - jr c,.notEnoughMoney - ld hl,wNumBagItems + jr c, .notEnoughMoney + ld hl, wNumBagItems call AddItemToInventory - jr nc,.bagFull + jr nc, .bagFull call SubtractAmountPaidFromMoney - ld a,[wBoughtOrSoldItemInMart] + ld a, [wBoughtOrSoldItemInMart] and a - jr nz,.skipSettingFlag2 - ld a,1 - ld [wBoughtOrSoldItemInMart],a + jr nz, .skipSettingFlag2 + ld a, 1 + ld [wBoughtOrSoldItemInMart], a .skipSettingFlag2 - ld a,SFX_PURCHASE + ld a, SFX_PURCHASE call PlaySoundWaitForCurrent call WaitForSoundToFinish - ld hl,PokemartBoughtItemText + ld hl, PokemartBoughtItemText call PrintText jp .buyMenuLoop .returnToMainPokemartMenu call LoadScreenTilesFromBuffer1 - ld a,MONEY_BOX - ld [wTextBoxID],a + ld a, MONEY_BOX + ld [wTextBoxID], a call DisplayTextBoxID - ld hl,PokemartAnythingElseText + ld hl, PokemartAnythingElseText call PrintText jp .loop .isThereEnoughMoney - ld de,wPlayerMoney - ld hl,hMoney - ld c,3 ; length of money in bytes + ld de, wPlayerMoney + ld hl, hMoney + ld c, 3 ; length of money in bytes jp StringCmp .notEnoughMoney - ld hl,PokemartNotEnoughMoneyText + ld hl, PokemartNotEnoughMoneyText call PrintText jr .returnToMainPokemartMenu .bagFull - ld hl,PokemartItemBagFullText + ld hl, PokemartItemBagFullText call PrintText jr .returnToMainPokemartMenu .done - ld hl,PokemartThankYouText + ld hl, PokemartThankYouText call PrintText - ld a,1 - ld [wUpdateSpritesEnabled],a + ld a, 1 + ld [wUpdateSpritesEnabled], a call UpdateSprites - ld a,[wSavedListScrollOffset] - ld [wListScrollOffset],a + ld a, [wSavedListScrollOffset] + ld [wListScrollOffset], a ret PokemartBuyingGreetingText: diff --git a/engine/overworld/wild_mons.asm b/engine/overworld/wild_mons.asm index 6444ab7e..dae57f23 100644 --- a/engine/overworld/wild_mons.asm +++ b/engine/overworld/wild_mons.asm @@ -1,33 +1,33 @@ LoadWildData: - ld hl,WildDataPointers - ld a,[wCurMap] + ld hl, WildDataPointers + ld a, [wCurMap] ; get wild data for current map - ld c,a - ld b,0 - add hl,bc - add hl,bc - ld a,[hli] - ld h,[hl] - ld l,a ; hl now points to wild data for current map - ld a,[hli] - ld [wGrassRate],a + ld c, a + ld b, 0 + add hl, bc + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a ; hl now points to wild data for current map + ld a, [hli] + ld [wGrassRate], a and a - jr z,.NoGrassData ; if no grass data, skip to surfing data + jr z, .NoGrassData ; if no grass data, skip to surfing data push hl - ld de,wGrassMons ; otherwise, load grass data - ld bc,$0014 + ld de, wGrassMons ; otherwise, load grass data + ld bc, $0014 call CopyData pop hl - ld bc,$0014 - add hl,bc + ld bc, $0014 + add hl, bc .NoGrassData - ld a,[hli] - ld [wWaterRate],a + ld a, [hli] + ld [wWaterRate], a and a ret z ; if no water data, we're done - ld de,wWaterMons ; otherwise, load surfing data - ld bc,$0014 + ld de, wWaterMons ; otherwise, load surfing data + ld bc, $0014 jp CopyData INCLUDE "data/wild_mons.asm" |