From 6fe56af2cd63abaf30040cc5031e3db5358cf638 Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 5 Nov 2020 10:51:02 -0500 Subject: Organize home and macro code --- home/cgb_palettes.asm | 8 ++++++-- home/hidden_objects.asm | 4 +++- home/item_price.asm | 4 +++- home/joypad.asm | 4 ++-- home/overworld.asm | 29 ++++++++++++++++------------- home/pics.asm | 4 ---- home/pikachu.asm | 4 +++- home/pokemon.asm | 12 +++++------- home/printer.asm | 34 ++++++++++++++++++++++++++++++++++ home/reload_tiles.asm | 34 ---------------------------------- home/start.asm | 2 +- home/start_menu.asm | 3 ++- home/text.asm | 4 ++-- home/text_script.asm | 9 ++------- home/update_sprites.asm | 3 ++- home/vblank.asm | 8 ++++++-- 16 files changed, 87 insertions(+), 79 deletions(-) create mode 100644 home/printer.asm (limited to 'home') diff --git a/home/cgb_palettes.asm b/home/cgb_palettes.asm index 24738ae2..b8cc92c6 100644 --- a/home/cgb_palettes.asm +++ b/home/cgb_palettes.asm @@ -74,8 +74,12 @@ Func_3082:: ldh a, [hLoadedROMBank] push af call FadeOutAudio - callbs Music_DoLowHealthAlarm - callbs Audio1_UpdateMusic + ld a, BANK(Music_DoLowHealthAlarm) + call BankswitchCommon + call Music_DoLowHealthAlarm + ld a, BANK(Audio1_UpdateMusic) + call BankswitchCommon + call Audio1_UpdateMusic pop af call BankswitchCommon ret diff --git a/home/hidden_objects.asm b/home/hidden_objects.asm index 40c49c3e..0003022b 100644 --- a/home/hidden_objects.asm +++ b/home/hidden_objects.asm @@ -9,7 +9,9 @@ CheckForHiddenObjectOrBookshelfOrCardKeyDoor:: bit 0, a ; A button jr z, .nothingFound ; A button is pressed - callbs CheckForHiddenObject + ld a, BANK(CheckForHiddenObject) + call BankswitchCommon + call CheckForHiddenObject ldh a, [hDidntFindAnyHiddenObject] and a jr nz, .hiddenObjectNotFound diff --git a/home/item_price.asm b/home/item_price.asm index d8c2068e..39749ee9 100644 --- a/home/item_price.asm +++ b/home/item_price.asm @@ -31,7 +31,9 @@ GetItemPrice:: ldh [hItemPrice], a jr .done .getTMPrice - callbs GetMachinePrice + ld a, BANK(GetMachinePrice) + call BankswitchCommon + call GetMachinePrice .done ld de, hItemPrice pop af diff --git a/home/joypad.asm b/home/joypad.asm index 15f10fe2..5eb2962f 100644 --- a/home/joypad.asm +++ b/home/joypad.asm @@ -1,5 +1,5 @@ Joypad:: - homecall_jump _Joypad + homejp _Joypad ReadJoypad:: - homecall_jump ReadJoypad_ + homejp ReadJoypad_ diff --git a/home/overworld.asm b/home/overworld.asm index 2909b01e..68d50695 100644 --- a/home/overworld.asm +++ b/home/overworld.asm @@ -743,7 +743,8 @@ HandleBlackOut:: call StopMusic ld hl, wd72e res 5, [hl] - switchbank SpecialWarpIn ; also Bank(SpecialEnterMap) + ld a, BANK(SpecialWarpIn) ; also BANK(SpecialEnterMap) + call BankswitchCommon callfar ResetStatusAndHalveMoneyOnBlackout call SpecialWarpIn call PlayDefaultMusicFadeOutCurrent @@ -770,7 +771,9 @@ HandleFlyWarpOrDungeonWarp:: res 5, [hl] ; forced to ride bike call LeaveMapAnim call Func_07c4 - callbs SpecialWarpIn + ld a, BANK(SpecialWarpIn) + call BankswitchCommon + call SpecialWarpIn jp SpecialEnterMap LeaveMapAnim:: @@ -1439,9 +1442,7 @@ AdvancePlayerSprite:: push af ld a, $FF ld [wUpdateSpritesEnabled], a - ld hl, _AdvancePlayerSprite - ld b, BANK(_AdvancePlayerSprite) - call Bankswitch + callfar _AdvancePlayerSprite pop af ld [wUpdateSpritesEnabled], a ret @@ -1914,7 +1915,8 @@ asm_0dbd: ld b, $00 ldh a, [hLoadedROMBank] push af - switchbank MapSongBanks + ld a, BANK(MapSongBanks) + call BankswitchCommon ld hl, MapSongBanks add hl, bc add hl, bc @@ -2041,16 +2043,16 @@ CopyMapViewToVRAM:: ld de, vBGMap0 CopyMapViewToVRAM2: ld hl, wTileMap - ld b, 18 + ld b, SCREEN_HEIGHT .vramCopyLoop - ld c, 20 + ld c, SCREEN_WIDTH .vramCopyInnerLoop ld a, [hli] ld [de], a inc e dec c jr nz, .vramCopyInnerLoop - ld a, 32 - 20 ; total vram map width in tiles - screen width in tiles + ld a, BG_MAP_WIDTH - SCREEN_WIDTH add e ld e, a jr nc, .noCarry @@ -2068,11 +2070,11 @@ SwitchToMapRomBank:: ld c, a ld b, $00 ld a, BANK(MapHeaderBanks) - call BankswitchHome ; switch to ROM bank 3F + call BankswitchHome ld hl, MapHeaderBanks add hl, bc ld a, [hl] - ldh [hMapROMBank], a ; save map ROM bank + ldh [hMapROMBank], a call BankswitchBack ldh a, [hMapROMBank] call BankswitchCommon @@ -2083,7 +2085,8 @@ SwitchToMapRomBank:: GetMapHeaderPointer:: ldh a, [hLoadedROMBank] push af - switchbank MapHeaderPointers + ld a, BANK(MapHeaderPointers) + call BankswitchCommon push de ld a, [wCurMap] ld e, a @@ -2114,7 +2117,7 @@ ResetUsingStrengthOutOfBattleBit: ForceBikeOrSurf:: ld b, BANK(RedSprite) - ld hl, LoadPlayerSpriteGraphics + ld hl, LoadPlayerSpriteGraphics ; in bank 0 call Bankswitch jp PlayDefaultMusic ; update map/player state? diff --git a/home/pics.asm b/home/pics.asm index f3b3f1b5..8fd9a26a 100644 --- a/home/pics.asm +++ b/home/pics.asm @@ -18,10 +18,6 @@ UncompressMonSprite:: ; $99 ≤ index, bank $D ld a, [wcf91] ; XXX name for this ram location ld b, a - ;cp MEW - ;ld a, BANK(MewPicFront) - ;jr z, .GotBank - ;ld a, b cp FOSSIL_KABUTOPS ld a, BANK(FossilKabutopsPic) jr z, .GotBank diff --git a/home/pikachu.asm b/home/pikachu.asm index c9c94635..ae6acfe3 100755 --- a/home/pikachu.asm +++ b/home/pikachu.asm @@ -108,7 +108,9 @@ ApplyPikachuMovementData:: ldh a, [hLoadedROMBank] ld b, a push af - callbs ApplyPikachuMovementData_ + ld a, BANK(ApplyPikachuMovementData_) + call BankswitchCommon + call ApplyPikachuMovementData_ pop af call BankswitchCommon ret diff --git a/home/pokemon.asm b/home/pokemon.asm index 3e08906f..8e304fd3 100644 --- a/home/pokemon.asm +++ b/home/pokemon.asm @@ -5,7 +5,6 @@ DrawHPBar:: push hl push de - ;push bc ; Left ld a, $71 ; "HP:" @@ -61,7 +60,6 @@ DrawHPBar:: add e ld [hl], a .done - ;pop bc pop de pop hl ret @@ -124,7 +122,8 @@ LoadFrontSpriteByMonIndex:: pop hl ldh a, [hLoadedROMBank] push af - switchbank CopyUncompressedPicToHL + ld a, BANK(CopyUncompressedPicToHL) + call BankswitchCommon xor a ldh [hStartTileID], a call CopyUncompressedPicToHL @@ -355,7 +354,7 @@ PrintStatusCondition:: ret PrintStatusConditionNotFainted:: - homecall_jump_sf PrintStatusAilment + homejp_sf PrintStatusAilment ; function to print pokemon level, leaving off the ":L" if the level is at least 100 ; INPUT: @@ -404,7 +403,8 @@ GetwMoves:: GetMonHeader:: ldh a, [hLoadedROMBank] push af - switchbank BaseStats + ld a, BANK(BaseStats) + call BankswitchCommon push bc push de push hl @@ -423,8 +423,6 @@ GetMonHeader:: ld b, $77 ; size of Aerodactyl fossil sprite cp FOSSIL_AERODACTYL ; Aerodactyl fossil jr z, .specialID - ;cp MEW - ;jr z, .mew predef IndexToPokedex ; convert pokemon ID in [wd11e] to pokedex number ld a, [wd11e] dec a diff --git a/home/printer.asm b/home/printer.asm new file mode 100644 index 00000000..6d9f145c --- /dev/null +++ b/home/printer.asm @@ -0,0 +1,34 @@ + +PrinterSerial:: + homecall PrinterSerial_ + ret + +SerialFunction:: + ld a, [wPrinterConnectionOpen] + bit 0, a + ret z + ld a, [wPrinterOpcode] + and a + ret nz + ld hl, wOverworldMap + 650 + inc [hl] + ld a, [hl] + cp $6 + ret c + xor a + ld [hl], a + ld a, $0c + ld [wPrinterOpcode], a + ld a, $88 + ldh [rSB], a + ld a, $1 + ldh [rSC], a + ld a, START_TRANSFER_INTERNAL_CLOCK + ldh [rSC], a + ret + +; causes the text box to close without waiting for a button press after displaying text +DisableWaitingAfterTextDisplay:: + ld a, $01 + ld [wDoNotWaitForButtonPressAfterDisplayingText], a + ret diff --git a/home/reload_tiles.asm b/home/reload_tiles.asm index ae9f6544..b596263a 100644 --- a/home/reload_tiles.asm +++ b/home/reload_tiles.asm @@ -31,37 +31,3 @@ ChooseFlyDestination:: ld hl, wd72e res 4, [hl] farjp LoadTownMap_Fly - -PrinterSerial:: - homecall PrinterSerial_ - ret - -SerialFunction:: - ld a, [wPrinterConnectionOpen] - bit 0, a - ret z - ld a, [wPrinterOpcode] - and a - ret nz - ld hl, wOverworldMap + 650 - inc [hl] - ld a, [hl] - cp $6 - ret c - xor a - ld [hl], a - ld a, $0c - ld [wPrinterOpcode], a - ld a, $88 - ldh [rSB], a - ld a, $1 - ldh [rSC], a - ld a, START_TRANSFER_INTERNAL_CLOCK - ldh [rSC], a - ret - -; causes the text box to close without waiting for a button press after displaying text -DisableWaitingAfterTextDisplay:: - ld a, $01 - ld [wDoNotWaitForButtonPressAfterDisplayingText], a - ret diff --git a/home/start.asm b/home/start.asm index 379436ae..366806e9 100644 --- a/home/start.asm +++ b/home/start.asm @@ -4,7 +4,7 @@ _Start:: xor a jr .ok .gbc - ld a, 1 + ld a, TRUE .ok ldh [hGBC], a jp Init diff --git a/home/start_menu.asm b/home/start_menu.asm index bd1b24bf..8edccfe2 100755 --- a/home/start_menu.asm +++ b/home/start_menu.asm @@ -1,5 +1,6 @@ DisplayStartMenu:: - switchbank StartMenu_Pokedex ; also bank for other functions + ld a, BANK(StartMenu_Pokedex) ; also bank for other functions + call BankswitchCommon ld a, [wWalkBikeSurfState] ; walking/biking/surfing ld [wWalkBikeSurfStateCopy], a ld a, SFX_START_MENU diff --git a/home/text.asm b/home/text.asm index 78d69138..adb81425 100644 --- a/home/text.asm +++ b/home/text.asm @@ -554,8 +554,8 @@ TextCommandSounds:: db TX_SOUND_GET_KEY_ITEM, SFX_GET_KEY_ITEM db TX_SOUND_DEX_PAGE_ADDED, SFX_DEX_PAGE_ADDED db TX_SOUND_CRY_PIKACHU, PIKACHU ; used in OakSpeech - db TX_SOUND_CRY_PIDGEOT, PIDGEOT ; used in SaffronCityText12 - db TX_SOUND_CRY_DEWGONG, DEWGONG ; unused + db TX_SOUND_CRY_PIDGEOT, PIDGEOT ; used in SaffronCityText12 + db TX_SOUND_CRY_DEWGONG, DEWGONG ; unused TextCommand_DOTS:: ; wait for button press or 30 frames while printing "…"s diff --git a/home/text_script.asm b/home/text_script.asm index 20cfb71d..fe81cb51 100644 --- a/home/text_script.asm +++ b/home/text_script.asm @@ -41,17 +41,12 @@ DisplayTextID:: .spriteHandling ; get the text ID of the sprite push hl - ;push de - ;push bc - ;farcall 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 ldh a, [hSpriteIndexOrTextID] dec a add a ld e, a - ld d, $0 + ld d, 0 add hl, de inc hl ld a, [hl] ; a = text ID of the sprite @@ -60,7 +55,7 @@ DisplayTextID:: ; look up the address of the text in the map's text entries dec a ld e, a - ld d, $0 + ld d, 0 add hl, de add hl, de ld a, [hli] diff --git a/home/update_sprites.asm b/home/update_sprites.asm index 0c32dad8..5bb9ee12 100644 --- a/home/update_sprites.asm +++ b/home/update_sprites.asm @@ -4,7 +4,8 @@ UpdateSprites:: ret nz ldh a, [hLoadedROMBank] push af - switchbank _UpdateSprites + ld a, BANK(_UpdateSprites) + call BankswitchCommon ld a, $ff ld [wUpdateSpritesEnabled], a call _UpdateSprites diff --git a/home/vblank.asm b/home/vblank.asm index ed39714f..3957639a 100644 --- a/home/vblank.asm +++ b/home/vblank.asm @@ -59,8 +59,12 @@ VBlank:: .skipDec call FadeOutAudio - callbs Music_DoLowHealthAlarm - callbs Audio1_UpdateMusic + ld a, BANK(Music_DoLowHealthAlarm) + call BankswitchCommon + call Music_DoLowHealthAlarm + ld a, BANK(Audio1_UpdateMusic) + call BankswitchCommon + call Audio1_UpdateMusic call SerialFunction -- cgit v1.3.1-sl0p From 3de7ab601d465581accfe3ff171aeed2808c9647 Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 5 Nov 2020 16:55:42 -0500 Subject: Sync more with pokered --- engine/battle/animations.asm | 2 +- engine/battle/battle_transitions.asm | 4 +- engine/battle/core.asm | 50 +++++---- engine/battle/effects.asm | 3 +- engine/battle/experience.asm | 14 +-- engine/battle/ghost_marowak_anim.asm | 2 +- engine/battle/move_effects/heal.asm | 6 +- .../battle/move_effects/reflect_light_screen.asm | 6 +- engine/battle/move_effects/transform.asm | 2 +- engine/battle/safari_zone.asm | 10 +- engine/battle/scale_sprites.asm | 10 +- engine/battle/trainer_ai.asm | 6 +- engine/events/card_key.asm | 3 +- engine/gfx/palettes.asm | 10 +- home/clear_sprites.asm | 2 +- home/uncompress.asm | 2 +- hram.asm | 4 +- wram.asm | 123 ++++++++++++++------- 18 files changed, 150 insertions(+), 109 deletions(-) (limited to 'home') diff --git a/engine/battle/animations.asm b/engine/battle/animations.asm index 64bdaa00..4110e8b6 100755 --- a/engine/battle/animations.asm +++ b/engine/battle/animations.asm @@ -160,7 +160,7 @@ DrawFrameBlock: .afterDrawingTiles ld a, [wFBMode] cp FRAMEBLOCKMODE_02 - jr z, .advanceFrameBlockDestAddr; skip delay and don't clean OAM buffer + jr z, .advanceFrameBlockDestAddr ; skip delay and don't clean OAM buffer ld a, [wSubAnimFrameDelay] ld c, a call DelayFrames diff --git a/engine/battle/battle_transitions.asm b/engine/battle/battle_transitions.asm index 82c3318c..6d3a4f9c 100644 --- a/engine/battle/battle_transitions.asm +++ b/engine/battle/battle_transitions.asm @@ -355,7 +355,7 @@ BattleTransition_FlashScreenPalettes: ; used for low level trainer dungeon battles BattleTransition_Shrink: - ld c, 9 + ld c, SCREEN_HEIGHT / 2 .loop push bc xor a @@ -389,7 +389,7 @@ BattleTransition_Shrink: ; used for high level trainer dungeon battles BattleTransition_Split: - ld c, 9 + ld c, SCREEN_HEIGHT / 2 xor a ldh [hAutoBGTransferEnabled], a .loop diff --git a/engine/battle/core.asm b/engine/battle/core.asm index ac9676ec..abb1c9b4 100755 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -1765,7 +1765,7 @@ SendOutMon: ld hl, wEnemyMonHP ld a, [hli] or [hl] ; is enemy mon HP zero? - jp z, .skipDrawingEnemyHUDAndHPBar; if HP is zero, skip drawing the HUD and HP bar + jp z, .skipDrawingEnemyHUDAndHPBar ; if HP is zero, skip drawing the HUD and HP bar call DrawEnemyHUDAndHPBar .skipDrawingEnemyHUDAndHPBar call DrawPlayerHUDAndHPBar @@ -2096,16 +2096,17 @@ DisplayBattleMenu:: jp .handleBattleMenuInput ; the following happens for the old man tutorial and prof. oak pikachu battle .doSimulatedMenuInput + ; Temporarily save the player name in wGrassRate, + ; which is supposed to get overwritten when entering a + ; map with wild Pokémon. + ; In Red/Blue, due to an oversight, the data may not get + ; overwritten (on Cinnabar and Route 21) and the infamous + ; Missingno. glitch can show up. + ; However, this has been fixed in Yellow. ld hl, wPlayerName ld de, wGrassRate ld bc, NAME_LENGTH - call CopyData ; temporarily save the player name in unused space, - ; which is supposed to get overwritten when entering a - ; map with wild Pokémon. - ; In Red/Blue, due to an oversight, the data - ; may not get overwritten (cinnabar) and the infamous - ; Missingno. glitch can show up. However, - ; this has been fixed in yellow + call CopyData ld hl, .oldManName ld a, [wBattleType] dec a @@ -2310,9 +2311,9 @@ BagWasSelected: jr DisplayBagMenu SimulatedInputBattleItemList: - db 1 ; # of items + db 1 ; # items db POKE_BALL, 1 - db $ff + db -1 ; end DisplayPlayerBag: ; get the pointer to player's bag when in a normal battle @@ -4258,7 +4259,7 @@ CheckForDisobedience: call GetCurrentMove .canUseMove ld a, $1 - and a; clear Z flag + and a ; clear Z flag ret .cannotUseMove xor a ; set Z flag @@ -4731,7 +4732,7 @@ JumpToOHKOMoveEffect: INCLUDE "data/battle/unused_critical_hit_moves.asm" ; determines if attack is a critical hit -; azure heights claims "the fastest pokémon (who are, not coincidentally, +; Azure Heights claims "the fastest pokémon (who are, not coincidentally, ; among the most popular) tend to CH about 20 to 25% of the time." CriticalHitTest: xor a @@ -5442,26 +5443,32 @@ AdjustDamageForMoveType: .done ret +; function to tell how effective the type of an enemy attack is on the player's current pokemon +; this doesn't take into account the effects that dual types can have +; (e.g. 4x weakness / resistance, weaknesses and resistances canceling) +; the result is stored in [wTypeEffectiveness] +; ($05 is not very effective, $10 is neutral, $14 is super effective) +; as far is can tell, this is only used once in some AI code to help decide which move to use AIGetTypeEffectiveness: ld a, [wEnemyMoveType] - ld d, a ; d = type of enemy move + ld d, a ; d = type of enemy move ld hl, wBattleMonType - ld b, [hl] ; b = type 1 of player's pokemon + ld b, [hl] ; b = type 1 of player's pokemon inc hl - ld c, [hl] ; c = type 2 of player's pokemon + ld c, [hl] ; c = type 2 of player's pokemon ld a, $10 - ld [wd11e], a ; initialize [wd11e] to neutral effectiveness + ld [wTypeEffectiveness], a ; initialize to neutral effectiveness ld hl, TypeEffects .loop ld a, [hli] cp $ff ret z - cp d ; match the type of the move + cp d ; match the type of the move jr nz, .nextTypePair1 ld a, [hli] - cp b ; match with type 1 of pokemon + cp b ; match with type 1 of pokemon jr z, .done - cp c ; or match with type 2 of pokemon + cp c ; or match with type 2 of pokemon jr z, .done jr .nextTypePair2 .nextTypePair1 @@ -5469,8 +5476,8 @@ AIGetTypeEffectiveness: .nextTypePair2 inc hl jr .loop - .done + ; 40% chance for Lorelei's Dewgong to ignore type effectiveness? ld a, [wTrainerClass] cp LORELEI jr nz, .ok @@ -5481,9 +5488,8 @@ AIGetTypeEffectiveness: cp $66 ; 40 percent ret c .ok - ld a, [hl] - ld [wd11e], a ; store damage multiplier + ld [wTypeEffectiveness], a ; store damage multiplier ret INCLUDE "data/types/type_matchups.asm" diff --git a/engine/battle/effects.asm b/engine/battle/effects.asm index 9e5ee19f..7573ce8d 100644 --- a/engine/battle/effects.asm +++ b/engine/battle/effects.asm @@ -247,7 +247,7 @@ FreezeBurnParalyzeEffect: jr z, .burn1 cp FREEZE_SIDE_EFFECT jr z, .freeze1 -; .paralyze +; .paralyze1 ld a, 1 << PAR ld [wEnemyMonStatus], a call QuarterSpeedDueToParalysis ; quarter speed of affected mon @@ -309,6 +309,7 @@ FreezeBurnParalyzeEffect: jr z, .burn2 cp FREEZE_SIDE_EFFECT jr z, .freeze2 +; .paralyze2 ld a, 1 << PAR ld [wBattleMonStatus], a call QuarterSpeedDueToParalysis diff --git a/engine/battle/experience.asm b/engine/battle/experience.asm index bab804bb..61fbdfa3 100644 --- a/engine/battle/experience.asm +++ b/engine/battle/experience.asm @@ -43,7 +43,7 @@ GainExperience: inc de jr .nextBaseStat .maxStatExp ; if the upper byte also overflowed, then we have hit the max stat exp - dec a ; a is 0 from previous check + dec a ; ld a, $ff; a is 0 from previous check ld [de], a inc de ld [de], a @@ -234,15 +234,15 @@ GainExperience: xor a ; battle mon ld [wCalculateWhoseStats], a ld hl, CalculateModifiedStats - call Bankswitch15ToF + call CallBattleCore ld hl, ApplyBurnAndParalysisPenaltiesToPlayer - call Bankswitch15ToF + call CallBattleCore ld hl, ApplyBadgeStatBoosts - call Bankswitch15ToF + call CallBattleCore ld hl, DrawPlayerHUDAndHPBar - call Bankswitch15ToF + call CallBattleCore ld hl, PrintEmptyString - call Bankswitch15ToF + call CallBattleCore call SaveScreenTilesToBuffer1 .printGrewLevelText callabd_ModifyPikachuHappiness PIKAHAPPY_LEVELUP @@ -345,7 +345,7 @@ BoostExp: ldh [hQuotient + 2], a ret -Bankswitch15ToF: +CallBattleCore: ld b, BANK(BattleCore) jp Bankswitch diff --git a/engine/battle/ghost_marowak_anim.asm b/engine/battle/ghost_marowak_anim.asm index 03059022..76d89ba9 100644 --- a/engine/battle/ghost_marowak_anim.asm +++ b/engine/battle/ghost_marowak_anim.asm @@ -77,7 +77,7 @@ CopyMonPicFromBGToSpriteVRAM: ld [hli], a ld a, d ld [hli], a - ld a, $14 ; use OBP1 + ld a, OAM_OBP1 | 4 ld [hli], a inc d dec c diff --git a/engine/battle/move_effects/heal.asm b/engine/battle/move_effects/heal.asm index 80923a29..c3ffda65 100644 --- a/engine/battle/move_effects/heal.asm +++ b/engine/battle/move_effects/heal.asm @@ -86,7 +86,7 @@ HealEffect_: ld [wHPBarNewHP], a .playAnim ld hl, PlayCurrentMoveAnimation - call Bankswitch3DtoF + call EffectCallBattleCore ldh a, [hWhoseTurn] and a hlcoord 10, 9 @@ -98,14 +98,14 @@ HealEffect_: ld [wHPBarType], a predef UpdateHPBar2 ld hl, DrawHUDsAndHPBars - call Bankswitch3DtoF + call EffectCallBattleCore ld hl, RegainedHealthText jp PrintText .failed ld c, 50 call DelayFrames ld hl, PrintButItFailedText_ - jp Bankswitch3DtoF + jp EffectCallBattleCore StartedSleepingEffect: text_far _StartedSleepingEffect diff --git a/engine/battle/move_effects/reflect_light_screen.asm b/engine/battle/move_effects/reflect_light_screen.asm index c05055fa..46c299e9 100644 --- a/engine/battle/move_effects/reflect_light_screen.asm +++ b/engine/battle/move_effects/reflect_light_screen.asm @@ -23,14 +23,14 @@ ReflectLightScreenEffect_: .playAnim push hl ld hl, PlayCurrentMoveAnimation - call Bankswitch3DtoF + call EffectCallBattleCore pop hl jp PrintText .moveFailed ld c, 50 call DelayFrames ld hl, PrintButItFailedText_ - jp Bankswitch3DtoF + jp EffectCallBattleCore LightScreenProtectedText: text_far _LightScreenProtectedText @@ -40,6 +40,6 @@ ReflectGainedArmorText: text_far _ReflectGainedArmorText text_end -Bankswitch3DtoF: +EffectCallBattleCore: ld b, BANK(BattleCore) jp Bankswitch diff --git a/engine/battle/move_effects/transform.asm b/engine/battle/move_effects/transform.asm index d37bd94d..af47ae1b 100644 --- a/engine/battle/move_effects/transform.asm +++ b/engine/battle/move_effects/transform.asm @@ -134,7 +134,7 @@ TransformEffect_: .failed ld hl, PrintButItFailedText_ - jp Bankswitch3DtoF + jp EffectCallBattleCore TransformedText: text_far _TransformedText diff --git a/engine/battle/safari_zone.asm b/engine/battle/safari_zone.asm index 9362cc3a..a61f402f 100755 --- a/engine/battle/safari_zone.asm +++ b/engine/battle/safari_zone.asm @@ -2,18 +2,18 @@ PrintSafariZoneBattleText: ld hl, wSafariBaitFactor ld a, [hl] and a - jr z, .asm_411e + jr z, .no_bait dec [hl] ld hl, SafariZoneEatingText - jr .asm_4138 -.asm_411e + jr .done +.no_bait dec hl ld a, [hl] and a ret z dec [hl] ld hl, SafariZoneAngryText - jr nz, .asm_4138 + jr nz, .done push hl ld a, [wEnemyMonSpecies] ld [wd0b5], a @@ -21,7 +21,7 @@ PrintSafariZoneBattleText: ld a, [wMonHCatchRate] ld [wEnemyMonActualCatchRate], a pop hl -.asm_4138 +.done push hl call LoadScreenTilesFromBuffer1 pop hl diff --git a/engine/battle/scale_sprites.asm b/engine/battle/scale_sprites.asm index 794a65ab..38ebff21 100644 --- a/engine/battle/scale_sprites.asm +++ b/engine/battle/scale_sprites.asm @@ -4,18 +4,18 @@ ScaleSpriteByTwo: ld a, $0 call SwitchSRAMBankAndLatchClockData - call ScaleSpriteByTwo_ + call .ScaleSpriteByTwo call PrepareRTCDataAndDisableSRAM ret -ScaleSpriteByTwo_: +.ScaleSpriteByTwo: ld de, sSpriteBuffer1 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped ld hl, sSpriteBuffer0 + SPRITEBUFFERSIZE - 1 ; end of destination buffer - call ScaleLastSpriteColumnByTwo ; last tile column is special case - call ScaleFirstThreeSpriteColumnsByTwo ; scale first 3 tile columns + call ScaleLastSpriteColumnByTwo ; last tile column is special case + call ScaleFirstThreeSpriteColumnsByTwo ; scale first 3 tile columns ld de, sSpriteBuffer2 + (4*4*8) - 5 ; last byte of input data, last 4 rows already skipped ld hl, sSpriteBuffer1 + SPRITEBUFFERSIZE - 1 ; end of destination buffer - call ScaleLastSpriteColumnByTwo ; last tile column is special case + call ScaleLastSpriteColumnByTwo ; last tile column is special case ScaleFirstThreeSpriteColumnsByTwo: ld b, $3 ; 3 tile columns diff --git a/engine/battle/trainer_ai.asm b/engine/battle/trainer_ai.asm index 17e68e75..94e427a1 100644 --- a/engine/battle/trainer_ai.asm +++ b/engine/battle/trainer_ai.asm @@ -295,10 +295,10 @@ TrainerAI: cp LINK_STATE_BATTLING jr z, .done ; if in a link battle, we're done as well ld a, [wEnemyBattleStatus1] - and 1 << CHARGING_UP | 1 << THRASHING_ABOUT | 1 << STORING_ENERGY ; %10011 + and 1 << CHARGING_UP | 1 << THRASHING_ABOUT | 1 << STORING_ENERGY jr nz, .done ; don't follow trainer ai if opponent is in a locked state ld a, [wEnemyBattleStatus2] - and 1 << USING_RAGE ; %1000000 + and 1 << USING_RAGE jr nz, .done ; don't follow trainer ai if opponent is locked in rage ; note that this doesn't check for hyper beam recharge which can cause problems ld a, [wTrainerClass] ; what trainer class is this? @@ -311,7 +311,7 @@ TrainerAI: add hl, bc ld a, [wAICount] and a - jr z, .done; if no AI uses left, we're done here + jr z, .done ; if no AI uses left, we're done here inc hl inc a jr nz, .getpointer diff --git a/engine/events/card_key.asm b/engine/events/card_key.asm index de5f402e..10de5ed2 100755 --- a/engine/events/card_key.asm +++ b/engine/events/card_key.asm @@ -8,8 +8,7 @@ PrintCardKeyText: ret z cp b jr nz, .silphCoMapListLoop -; does not check for tile in front of player. This might be buggy - ;predef GetTileAndCoordsInFrontOfPlayer +; does not check for tile in front of player. This might be buggy. ld a, [wTileInFrontOfPlayer] cp $18 jr z, .cardKeyDoorInFrontOfPlayer diff --git a/engine/gfx/palettes.asm b/engine/gfx/palettes.asm index c08992d3..b480c6d0 100755 --- a/engine/gfx/palettes.asm +++ b/engine/gfx/palettes.asm @@ -19,7 +19,7 @@ _RunPaletteCommand: push de jp hl -SetPal_Black: +SetPal_BattleBlack: ld hl, PalPacket_Black ld de, BlkPacket_Battle ret @@ -30,7 +30,6 @@ SetPal_Battle: ld de, wPalPacket ld bc, $10 call CopyData - ;ld a, [wPlayerBattleStatus3] ld hl, wBattleMonSpecies ld a, [hl] and a @@ -42,7 +41,6 @@ SetPal_Battle: .asm_71ef9 call DeterminePaletteID ld b, a - ;ld a, [wEnemyBattleStatus3] ld hl, wEnemyMonSpecies2 call DeterminePaletteID ld c, a @@ -118,7 +116,7 @@ SetPal_Slots: ld de, BlkPacket_Slots ret -SetPal_Titlescreen: +SetPal_TitleScreen: ld hl, PalPacket_Titlescreen ld de, BlkPacket_Titlescreen ret @@ -267,13 +265,13 @@ SendUnknownPalPacket_72064:: SetPalFunctions: ; entries correspond to SET_PAL_* constants - dw SetPal_Black + dw SetPal_BattleBlack dw SetPal_Battle dw SetPal_TownMap dw SetPal_StatusScreen dw SetPal_Pokedex dw SetPal_Slots - dw SetPal_Titlescreen + dw SetPal_TitleScreen dw SetPal_NidorinoIntro dw SetPal_Generic dw SetPal_Overworld diff --git a/home/clear_sprites.asm b/home/clear_sprites.asm index 34f4b4ec..79cc99d6 100644 --- a/home/clear_sprites.asm +++ b/home/clear_sprites.asm @@ -1,7 +1,7 @@ ClearSprites:: xor a ld hl, wOAMBuffer - ld b, 40 * 4 + ld b, wOAMBufferEnd - wOAMBuffer .loop ld [hli], a dec b diff --git a/home/uncompress.asm b/home/uncompress.asm index 182821aa..27474f2d 100644 --- a/home/uncompress.asm +++ b/home/uncompress.asm @@ -558,7 +558,7 @@ ResetSpriteBufferPointers:: ; maps each nybble to its reverse NybbleReverseTable:: - db $0, $8, $4, $c, $2, $a, $6 ,$e, $1, $9, $5, $d, $3, $b, $7 ,$f + db $0, $8, $4, $c, $2, $a, $6, $e, $1, $9, $5, $d, $3, $b, $7, $f ; combines the two loaded chunks with xor (the chunk loaded second is the destination). Both chunks are differeintial decoded beforehand. UnpackSpriteMode2:: diff --git a/hram.asm b/hram.asm index f3ffc564..6c14f3c6 100644 --- a/hram.asm +++ b/hram.asm @@ -96,8 +96,8 @@ hTilePlayerStandingOn:: db hSpritePriority:: db UNION -;; Multiplication and division variables are meant -;; to overlap for back-to-back usage. Big endian. +; Multiplication and division variables are meant +; to overlap for back-to-back usage. Big endian. UNION ds 1 hMultiplicand:: ds 3 diff --git a/wram.asm b/wram.asm index 35b5f61f..c4038cd5 100755 --- a/wram.asm +++ b/wram.asm @@ -151,6 +151,7 @@ wc0f3:: ds 1 wc0f4:: ds 1 wc0f5:: ds 11 + SECTION "Sprite State Data", WRAM0 wSpriteDataStart:: @@ -191,7 +192,7 @@ wSprite11StateData1:: spritestatedata1 wSprite11StateData1 wSprite12StateData1:: spritestatedata1 wSprite12StateData1 wSprite13StateData1:: spritestatedata1 wSprite13StateData1 wSprite14StateData1:: spritestatedata1 wSprite14StateData1 -wSpritePikachuStateData1:: spritestatedata1 wSpritePikachuStateData1 +wSpritePikachuStateData1:: spritestatedata1 wSpritePikachuStateData1 wSpriteStateData2:: ; more data for all sprites on the current map @@ -229,7 +230,7 @@ wSprite11StateData2:: spritestatedata2 wSprite11StateData2 wSprite12StateData2:: spritestatedata2 wSprite12StateData2 wSprite13StateData2:: spritestatedata2 wSprite13StateData2 wSprite14StateData2:: spritestatedata2 wSprite14StateData2 -wSpritePikachuStateData2:: spritestatedata2 wSpritePikachuStateData2 +wSpritePikachuStateData2:: spritestatedata2 wSpritePikachuStateData2 wSpriteDataEnd:: @@ -244,16 +245,24 @@ wOAMBufferEnd:: wTileMap:: ; buffer for tiles that are visible on screen (20 columns by 18 rows) - ds SCREEN_HEIGHT * SCREEN_WIDTH - -wSerialPartyMonsPatchList:: -; list of indexes to patch with SERIAL_NO_DATA_BYTE after transfer + ds SCREEN_WIDTH * SCREEN_HEIGHT +UNION wTileMapBackup:: ; buffer for temporarily saving and restoring current screen's tiles ; (e.g. if menus are drawn on top) -; ds 20 * 18 + ds SCREEN_WIDTH * SCREEN_HEIGHT + +NEXTU +wSerialPartyMonsPatchList:: +; list of indexes to patch with SERIAL_NO_DATA_BYTE after transfer + ds 200 + +wSerialEnemyMonsPatchList:: +; list of indexes to patch with SERIAL_NO_DATA_BYTE after transfer + ds 200 +NEXTU wAnimatedObjectsData:: ; Used by functions in BANK 3E ; This looks similar to the address structure for Gen 2 OAM animations. @@ -303,10 +312,7 @@ wAnimatedObjectGlobalXOffset:: ds 1 wAnimatedObjectsDataEnd:: -wSerialEnemyMonsPatchList:: -; list of indexes to patch with SERIAL_NO_DATA_BYTE after transfer - -; Surfing Minigame +; Surfing minigame wSurfingMinigameData:: ds 1 wSurfingMinigameRoutineNumber:: @@ -356,7 +362,6 @@ wc5ee:: ds 1 wSurfingMinigameBGMapReadBuffer:: ds 16 - ds 24 wSurfingMinigameSCX:: ds 3 @@ -375,6 +380,7 @@ wSurfingMinigameRoutineDelay:: wSurfingMinigameIntroAnimationFinished:: ds 1 +; Yellow intro wYellowIntroCurrentScene:: wc634:: ds 1 @@ -384,13 +390,21 @@ wc635:: wYellowIntroAnimatedObjectStructPointer:: ds 1 wSurfingMinigameDataEnd:: +ENDU + + ds 80 - ds 177 +UNION +wOverworldMap:: + ds 1300 +wOverworldMapEnd:: +NEXTU wTempPic:: + ds 7 * 7 tiles + +NEXTU wPrinterData:: -wOverworldMap:: - ; ds 1300 wPrinterSendState:: ds 1 wPrinterRowIndex:: @@ -480,8 +494,7 @@ wcbea:: wcbec:: ds 16 - -wOverworldMapEnd:: +ENDU wRedrawRowOrColumnSrcTiles:: ; the tiles of the row or column to be redrawn by RedrawRowOrColumn @@ -617,6 +630,7 @@ wUnknownSerialCounter:: ; 2 bytes wEnteringCableClub:: +; 1 byte ds 2 wWhichTradeMonSelectionMenu:: @@ -705,16 +719,13 @@ wBoostExpByExpAll:: wAnimationType:: ; values between 0-6. Shake screen horizontally, shake screen vertically, blink Pokemon... +UNION wNPCMovementDirections:: - -wPikaPicUsedGFXCount:: ds 1 -wPikaPicUsedGFX:: wDexRatingNumMonsOwned:: ds 1 - wDexRatingText:: wTrainerCardBadgeAttributes:: ds 1 @@ -723,21 +734,42 @@ wSlotMachineSavedROMBank:: ; ROM back to return to when the player is done with the slot machine ds 1 - ds 13 -wPikaPicUsedGFXEnd:: - ds 13 + ds 26 wAnimPalette:: ds 1 ds 29 -wNPCMovementDirections2:: +NEXTU +wPikaPicUsedGFXCount:: + ds 1 -wPikaPicAnimObjectDataBufferSize:: +wPikaPicUsedGFX:: + ds 16 +wPikaPicUsedGFXEnd:: + + ds 43 +ENDU + +UNION +wNPCMovementDirections2:: + ds 10 +NEXTU wSwitchPartyMonTempBuffer:: ; temporary buffer when swapping party mon data + ds 49 + +NEXTU + ds 10 + +wNumStepsToTake:: +; used in Pallet Town scripted movement + ds 1 + +NEXTU +wPikaPicAnimObjectDataBufferSize:: ds 1 wPikaPicAnimObjectDataBuffer:: @@ -750,14 +782,11 @@ wPikaPicAnimObjectDataBuffer:: ; 5: x offset ; 6: y offset ; 7: unused - - ds 9 - -wNumStepsToTake:: -; used in Pallet Town scripted movement - ds 23 + ds 4 * 8 wPikaPicAnimObjectDataBufferEnd:: - ds 26 +ENDU + + ds 10 wRLEByteCount:: ds 1 @@ -835,7 +864,7 @@ wTotalPayDayMoney:: wSafariEscapeFactor:: ds 1 wSafariBaitFactor:: - ds 1; + ds 1 ds 1 @@ -1194,7 +1223,6 @@ wPlayerSpinWhileMovingUpOrDownAnimFrameDelay:: wHiddenObjectIndex:: wTrainerFacingDirection:: - ds 1 wHoFMonOrPlayer:: @@ -1240,8 +1268,6 @@ wHoFTeamNo:: wSlotMachineWheel1MiddleTile:: wFieldMovesLeftmostXCoord:: - -wcd42:: ds 1 wLastFieldMoveID:: @@ -1591,14 +1617,19 @@ wPalPacket:: wPartyMenuBlkPacket:: ; $30 bytes ds 9 + wPartyHPBarAttributes:: - ds 20 + ds 6 + + ds 14 wExpAmountGained:: ; 2-byte big-endian number ; the total amount of exp a mon gained -wcf4b:: ds 2 ; storage buffer for various strings +wcf4b:: +; storage buffer for various strings + ds 2 wGainBoostedExp:: ds 1 @@ -1779,7 +1810,11 @@ wEnemyMonDefense:: dw wEnemyMonSpeed:: dw wEnemyMonSpecial:: dw wEnemyMonPP:: ds 3 ; NUM_MOVES - 1 + + SECTION "WRAM Bank 1", WRAMX + +; continuing wEnemyMon from the previous section ds 1 ; NUM_MOVES - 3 wEnemyMonBaseStats:: ds 5 @@ -1931,6 +1966,7 @@ wPlayerConfusedCounter:: wPlayerToxicCounter:: ds 1 + wPlayerDisabledMove:: ; high nibble: which move is disabled (1-4) ; low nibble: disable turns left @@ -1947,6 +1983,7 @@ wEnemyConfusedCounter:: wEnemyToxicCounter:: ds 1 + wEnemyDisabledMove:: ; high nibble: which move is disabled (1-4) ; low nibble: disable turns left @@ -2247,7 +2284,7 @@ wMonHBackSprite:: ds 2 wMonHMoves:: - ds 4 + ds NUM_MOVES wMonHGrowthRate:: ds 1 @@ -2764,7 +2801,6 @@ wPikachuMovementFlags:: ds 1 UNION - wCurPikaMovementData:: wCurPikaMovementParam1:: ds 1 wCurPikaMovementFunc1:: ds 1 @@ -2782,7 +2818,6 @@ wPikachuStepSubtimer:: ds 1 wCurPikaMovementDataEnd:: NEXTU - wPikaPicAnimPointer:: dw wPikaPicAnimPointerSetupFinished:: ds 1 wPikaPicAnimCurGraphicID:: ds 1 @@ -3344,7 +3379,6 @@ wBeatLorelei:: ; the game uses this to tell when Elite 4 events need to be reset ds 1 -wd735:: ds 1 wd736:: @@ -3488,6 +3522,7 @@ wBoxMon2:: ds BOX_STRUCT_LENGTH * (MONS_PER_BOX - 1) wBoxMonOT:: ds NAME_LENGTH * MONS_PER_BOX wBoxMonNicks:: ds NAME_LENGTH * MONS_PER_BOX wBoxMonNicksEnd:: + wBoxDataEnd:: wGBCBasePalPointers:: ds NUM_ACTIVE_PALS * 2 @@ -3498,7 +3533,9 @@ wLastOBP1:: ds 1 wdef5:: ds 1 wBGPPalsBuffer:: ds NUM_ACTIVE_PALS * PALETTE_SIZE + SECTION "Stack", WRAMX + wStack:: -- cgit v1.3.1-sl0p