From d522badb6098cfd85dca128c71196431175b0337 Mon Sep 17 00:00:00 2001 From: ElectroDeoxys Date: Wed, 28 Dec 2022 13:38:37 +0000 Subject: [PATCH] Split home into separate object file --- Makefile | 1 + src/data/cards.asm | 2 +- src/data/deck_ai_pointers.asm | 2 +- src/data/decks.asm | 2 +- src/data/map_scripts.asm | 2 +- src/data/script_table.asm | 2 +- src/engine/bank07.asm | 4 +- src/engine/bank20.asm | 4 +- src/engine/challenge_machine.asm | 2 +- src/engine/copy_card_name.asm | 2 +- src/engine/credits.asm | 2 +- src/engine/duel/animations/core.asm | 10 +- src/engine/duel/core.asm | 44 ++--- src/engine/duel/effect_commands.asm | 2 +- src/engine/game_loop.asm | 4 +- src/engine/gfx/sprite_animations.asm | 4 +- src/engine/menus/common.asm | 2 +- src/engine/menus/deck_machine.asm | 2 +- src/engine/menus/duel.asm | 14 +- src/engine/menus/main_menu.asm | 2 +- src/engine/menus/play_area.asm | 2 +- src/engine/overworld/npcs.asm | 2 +- src/engine/overworld/overworld.asm | 8 +- src/engine/overworld/scripting.asm | 8 +- src/engine/save.asm | 10 +- src/engine/scenes.asm | 4 +- src/{engine => }/home.asm | 3 + src/home/ai.asm | 16 +- src/home/audio_callback.asm | 2 +- src/home/bg_map.asm | 18 +- src/home/call_regs.asm | 4 +- src/home/card_collection.asm | 16 +- src/home/card_color.asm | 20 +-- src/home/card_data.asm | 24 +-- src/home/clear_sram.asm | 6 +- src/home/coin_toss.asm | 10 +- src/home/copy.asm | 6 +- src/home/damage.asm | 4 +- src/home/decompress.asm | 12 +- src/home/division.asm | 2 +- src/home/dma.asm | 4 +- src/home/double_speed.asm | 6 +- src/home/duel.asm | 240 +++++++++++++-------------- src/home/duel_menus.asm | 18 +- src/home/effect_commands.asm | 10 +- src/home/empty_screen.asm | 6 +- src/home/farcall.asm | 8 +- src/home/frames.asm | 6 +- src/home/hblank.asm | 4 +- src/home/input.asm | 10 +- src/home/interrupt.asm | 8 +- src/home/jumptable.asm | 6 +- src/home/lcd.asm | 18 +- src/home/lcd_enable_frame.asm | 2 +- src/home/list.asm | 8 +- src/home/load_animation.asm | 30 ++-- src/home/load_deck.asm | 2 +- src/home/map.asm | 54 +++--- src/home/math.asm | 6 +- src/home/memory.asm | 14 +- src/home/menus.asm | 118 ++++++------- src/home/objects.asm | 6 +- src/home/palettes.asm | 20 +-- src/home/play_animation.asm | 14 +- src/home/play_song.asm | 6 +- src/home/print_text.asm | 72 ++++---- src/home/printer.asm | 30 ++-- src/home/process_text.asm | 82 ++++----- src/home/random.asm | 6 +- src/home/save.asm | 10 +- src/home/script.asm | 14 +- src/home/scroll.asm | 12 +- src/home/serial.asm | 48 +++--- src/home/setup.asm | 16 +- src/home/sgb.asm | 40 ++--- src/home/sound.asm | 26 +-- src/home/sram.asm | 6 +- src/home/start.asm | 2 +- src/home/substatus.asm | 70 ++++---- src/home/switch_rom.asm | 8 +- src/home/text_box.asm | 34 ++-- src/home/tiles.asm | 52 +++--- src/home/time.asm | 8 +- src/home/unsafe_bg_map.asm | 6 +- src/home/vblank.asm | 2 +- src/home/vram.asm | 6 +- src/home/write_number.asm | 16 +- src/main.asm | 2 - 88 files changed, 740 insertions(+), 738 deletions(-) rename src/{engine => }/home.asm (98%) diff --git a/Makefile b/Makefile index abe11af2..6664296f 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,7 @@ rom := poketcg.gbc rom_obj := \ src/main.o \ + src/home.o \ src/gfx.o \ src/text.o \ src/audio.o \ diff --git a/src/data/cards.asm b/src/data/cards.asm index 9c68fb77..910932f9 100644 --- a/src/data/cards.asm +++ b/src/data/cards.asm @@ -1,7 +1,7 @@ ; TODO: Make card data structures more compact and rearrange the fields for ; convenience once the meaning of all fields is figured out. -CardPointers: +CardPointers:: table_width 2, CardPointers dw NULL dw GrassEnergyCard diff --git a/src/data/deck_ai_pointers.asm b/src/data/deck_ai_pointers.asm index 3798f22e..120bdf56 100644 --- a/src/data/deck_ai_pointers.asm +++ b/src/data/deck_ai_pointers.asm @@ -1,4 +1,4 @@ -DeckAIPointerTable: +DeckAIPointerTable:: table_width 2, DeckAIPointerTable dw AIActionTable_SamPractice ; SAMS_PRACTICE_DECK dw AIActionTable_GeneralDecks ; PRACTICE_PLAYER_DECK diff --git a/src/data/decks.asm b/src/data/decks.asm index ea734115..e73161ee 100644 --- a/src/data/decks.asm +++ b/src/data/decks.asm @@ -1,4 +1,4 @@ -DeckPointers: +DeckPointers:: table_width 2, DeckPointers dw UnnamedDeck dw UnnamedDeck2 diff --git a/src/data/map_scripts.asm b/src/data/map_scripts.asm index 3db6972c..e98082ae 100644 --- a/src/data/map_scripts.asm +++ b/src/data/map_scripts.asm @@ -11,7 +11,7 @@ ; c: moved player ; e: load map/closed text box -MapScripts: +MapScripts:: table_width NUM_MAP_SCRIPTS * 2, MapScripts ; OVERWORLD_MAP diff --git a/src/data/script_table.asm b/src/data/script_table.asm index 1c8c5a4d..07e2ef71 100644 --- a/src/data/script_table.asm +++ b/src/data/script_table.asm @@ -1,4 +1,4 @@ -OverworldScriptTable: +OverworldScriptTable:: table_width 2, OverworldScriptTable dw ScriptCommand_EndScript dw ScriptCommand_CloseAdvancedTextBox diff --git a/src/engine/bank07.asm b/src/engine/bank07.asm index cf9da136..d6f4e31e 100644 --- a/src/engine/bank07.asm +++ b/src/engine/bank07.asm @@ -49,7 +49,7 @@ Func_1c003: ; unreferenced call SetWindowOn ret -Func_1c056: +Func_1c056:: push hl push bc push de @@ -466,7 +466,7 @@ SetNPCDirection: pop hl ret -HandleAllNPCMovement: +HandleAllNPCMovement:: push hl push bc push de diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index c2609b42..b1acd83d 100644 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -919,7 +919,7 @@ ProcessOWFrameset: ; for each of the loaded frameset subgroups ; load their tiles and advance their durations -DoLoadedFramesetSubgroupsFrame: +DoLoadedFramesetSubgroupsFrame:: ld a, [wNumLoadedFramesetSubgroups] or a ret z @@ -1556,7 +1556,7 @@ Func_80cd7: db SPRITE_OW_GRANNY, SPRITE_ANIM_LIGHT_NPC_UP, SPRITE_ANIM_YELLOW_NPC_UP ; $2b db SPRITE_OW_AMY, SPRITE_ANIM_SGB_AMY_LAYING, SPRITE_ANIM_CGB_AMY_LAYING ; $2c -SpriteNullAnimationPointer: +SpriteNullAnimationPointer:: dw SpriteNullAnimationFrame SpriteNullAnimationFrame: diff --git a/src/engine/challenge_machine.asm b/src/engine/challenge_machine.asm index 52e3a3dc..8b54a367 100644 --- a/src/engine/challenge_machine.asm +++ b/src/engine/challenge_machine.asm @@ -14,7 +14,7 @@ ChallengeMachine_Reset: ; if a challenge is already in progress, then resume ; otherwise, start a new 5 round challenge -ChallengeMachine_Start: +ChallengeMachine_Start:: ld a, 0 ld [wLineSeparation], a call Func_10a9b diff --git a/src/engine/copy_card_name.asm b/src/engine/copy_card_name.asm index feb33ca5..5555d8e7 100644 --- a/src/engine/copy_card_name.asm +++ b/src/engine/copy_card_name.asm @@ -1,6 +1,6 @@ ; copy the name and level of the card at wLoadedCard1 to wDefaultText ; a = length in number of tiles (the resulting string will be padded with spaces to match it) -_CopyCardNameAndLevel: +_CopyCardNameAndLevel:: push bc push de ld [wCardNameLength], a diff --git a/src/engine/credits.asm b/src/engine/credits.asm index 088667a0..1625c86e 100644 --- a/src/engine/credits.asm +++ b/src/engine/credits.asm @@ -1,4 +1,4 @@ -PlayCreditsSequence: +PlayCreditsSequence:: ld a, MUSIC_STOP call PlaySong call Func_1d705 diff --git a/src/engine/duel/animations/core.asm b/src/engine/duel/animations/core.asm index e6da0926..2b77c0d6 100644 --- a/src/engine/duel/animations/core.asm +++ b/src/engine/duel/animations/core.asm @@ -1,4 +1,4 @@ -Func_1c8bc: +Func_1c8bc:: push hl push bc call Set_OBJ_8x8 @@ -25,7 +25,7 @@ Func_1c8bc: pop hl ret -PlayLoadedDuelAnimation: +PlayLoadedDuelAnimation:: ld a, [wDoFrameFunction + 0] cp LOW(Func_3ba2) jr nz, .error @@ -274,7 +274,7 @@ AnimationCoordinates: ; appends to end of wDuelAnimBuffer ; the current duel animation -LoadDuelAnimationToBuffer: +LoadDuelAnimationToBuffer:: push hl push bc ld a, [wDuelAnimBufferCurPos] @@ -376,7 +376,7 @@ GetAnimationData: pop bc ret -Func_1cac5: +Func_1cac5:: ld a, [wd42a] cp $ff jr nz, .asm_1cb03 @@ -431,7 +431,7 @@ Func_1cac5: ld [wd4c0], a jr .asm_1cafb -Func_1cb18: +Func_1cb18:: push hl push bc push de diff --git a/src/engine/duel/core.asm b/src/engine/duel/core.asm index a8d599bc..84ba4464 100644 --- a/src/engine/duel/core.asm +++ b/src/engine/duel/core.asm @@ -1,12 +1,12 @@ ; try to resume a saved duel from the main menu -TryContinueDuel: +TryContinueDuel:: call SetupDuel call LoadAndValidateDuelSaveData ldtx hl, BackUpIsBrokenText jr c, HandleFailedToContinueDuel ; fallthrough -_ContinueDuel: +_ContinueDuel:: ld hl, sp+$00 ld a, l ld [wDuelReturnAddress], a @@ -28,7 +28,7 @@ HandleFailedToContinueDuel: ; this function begins the duel after the opponent's graphics, name and deck have been introduced ; loads both player's decks and sets up the variables and resources required to begin a duel. -StartDuel_VSAIOpp: +StartDuel_VSAIOpp:: ld a, PLAYER_TURN ldh [hWhoseTurn], a ld a, DUELIST_TYPE_PLAYER @@ -2327,7 +2327,7 @@ Func_4f2d: ; draw the main scene during a duel, except the contents of the bottom text box, ; which depend on the type of duelist holding the turn. ; includes the background, both arena Pokemon, and both HUDs. -DrawDuelMainScene: +DrawDuelMainScene:: ld a, DUELVARS_DUELIST_TYPE call GetTurnDuelistVariable cp DUELIST_TYPE_PLAYER @@ -2399,7 +2399,7 @@ DrawDuelMainScene: ; draws the main elements of the main duel interface, including HUDs, HPs, card names ; and color symbols, attached cards, and other information, of both duelists. -DrawDuelHUDs: +DrawDuelHUDs:: ld a, DUELVARS_DUELIST_TYPE call GetTurnDuelistVariable cp DUELIST_TYPE_PLAYER @@ -5725,7 +5725,7 @@ Func_64fc: ; Pokemon Power. Includes the card's information above, and the Pokemon Power's ; description below. ; input: hTempPlayAreaLocation_ff9d -DisplayUsePokemonPowerScreen: +DisplayUsePokemonPowerScreen:: ldh a, [hTempPlayAreaLocation_ff9d] ld [wCurPlayAreaSlot], a xor a @@ -5953,7 +5953,7 @@ DisplayOpponentUsedAttackScreen: ; display card detail when a trainer card is used, and print "Used xxx" ; hTempCardIndex_ff9f contains the card's deck index -DisplayUsedTrainerCardDetailScreen: +DisplayUsedTrainerCardDetailScreen:: ldh a, [hTempCardIndex_ff9f] ldtx hl, UsedText call DisplayCardDetailScreen @@ -5982,7 +5982,7 @@ PrintUsedTrainerCardDescription: ; save data of the current duel to sCurrentDuel ; byte 0 is $01, bytes 1 and 2 are the checksum, byte 3 is [wDuelType] ; next $33a bytes come from DuelDataToSave -SaveDuelData: +SaveDuelData:: farcall StubbedUnusedSaveDataValidation ld de, sCurrentDuel ; fallthrough @@ -5990,7 +5990,7 @@ SaveDuelData: ; save data of the current duel to de (in SRAM) ; byte 0 is $01, bytes 1 and 2 are the checksum, byte 3 is [wDuelType] ; next $33a bytes come from DuelDataToSave -SaveDuelDataToDE: +SaveDuelDataToDE:: call EnableSRAM push de inc de @@ -7092,7 +7092,7 @@ HandlePoisonDamage: ; and a pointer in hl to the wLoadedCard* buffer where the card data is loaded, ; check if the card is Clefairy Doll or Mysterious Fossil, and, if so, convert it ; to a Pokemon card in the wLoadedCard* buffer, using .trainer_to_pkmn_data. -ConvertSpecialTrainerCardToPokemon: +ConvertSpecialTrainerCardToPokemon:: ld c, a ld a, [hl] cp TYPE_TRAINER @@ -7148,7 +7148,7 @@ ConvertSpecialTrainerCardToPokemon: ; this function applies status conditions to the defending Pokemon, ; returned by the effect functions in wEffectFunctionsFeedback -Func_6df1: +Func_6df1:: xor a ld [wPlayerArenaCardLastTurnStatus], a ld [wOpponentArenaCardLastTurnStatus], a @@ -7215,7 +7215,7 @@ ApplyStatusConditionToArenaPokemon: ld [de], a ret -Func_6e49: +Func_6e49:: call HandleDestinyBondSubstatus ; fallthrough @@ -7491,7 +7491,7 @@ Func_6ff7: ; print one of the "There was no effect from" texts depending ; on the value at wNoEffectFromWhichStatus (NO_STATUS or a status condition constant) -PrintThereWasNoEffectFromStatusText: +PrintThereWasNoEffectFromStatusText:: ld a, [wNoEffectFromWhichStatus] or a jr nz, .status @@ -7762,7 +7762,7 @@ TakeAPrizes: ; clear the non-turn holder's duelvars starting at DUELVARS_ARENA_CARD_DISABLED_ATTACK_INDEX ; these duelvars only last a two-player turn at most. -ClearNonTurnTemporaryDuelvars: +ClearNonTurnTemporaryDuelvars:: ld a, DUELVARS_ARENA_CARD_DISABLED_ATTACK_INDEX call GetNonTurnDuelistVariable xor a @@ -7778,7 +7778,7 @@ ClearNonTurnTemporaryDuelvars: ; same as ClearNonTurnTemporaryDuelvars, except the non-turn holder's arena ; Pokemon status condition is copied to wccc5 -ClearNonTurnTemporaryDuelvars_CopyStatus: +ClearNonTurnTemporaryDuelvars_CopyStatus:: ld a, DUELVARS_ARENA_CARD_STATUS call GetNonTurnDuelistVariable ld [wccc5], a @@ -7788,7 +7788,7 @@ ClearNonTurnTemporaryDuelvars_CopyStatus: ; update non-turn holder's DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE ; if wccef == 0: set to [wDealtDamage] ; if wceef != 0: set to 0 -Func_7195: +Func_7195:: ld a, DUELVARS_ARENA_CARD_LAST_TURN_DAMAGE call GetNonTurnDuelistVariable ld a, [wccef] @@ -7805,7 +7805,7 @@ Func_7195: ld [hl], a ret -_TossCoin: +_TossCoin:: ld [wCoinTossTotalNum], a ld a, [wDuelDisplayedScreen] cp COIN_TOSS @@ -8195,12 +8195,12 @@ SelectComputerOpponentData: textitem 3, 14, SelectComputerOpponentText db $ff -Func_7415: +Func_7415:: xor a ld [wce7e], a ret -Func_741a: +Func_741a:: ld hl, wEffectFunctionsFeedbackIndex ld a, [hl] or a @@ -8252,7 +8252,7 @@ Func_741a: ; this is a simple version of PlayAttackAnimation_DealAttackDamage that doesn't ; take into account status conditions, damage modifiers, etc, for damage calculation. ; used for confusion damage to self and for damage to benched Pokemon, for example -PlayAttackAnimation_DealAttackDamageSimple: +PlayAttackAnimation_DealAttackDamageSimple:: push hl push de call PlayAttackAnimation @@ -8271,7 +8271,7 @@ PlayAttackAnimation_DealAttackDamageSimple: ret ; if [wLoadedAttackAnimation] != 0, wait until the animation is over -WaitAttackAnimation: +WaitAttackAnimation:: ld a, [wLoadedAttackAnimation] or a ret z @@ -8288,7 +8288,7 @@ WaitAttackAnimation: ; - [wLoadedAttackAnimation]: animation to play ; - de: damage dealt by the attack (to display the animation with the number) ; - c: a wDamageEffectiveness constant (to print WEAK or RESIST if necessary) -PlayAttackAnimation: +PlayAttackAnimation:: ldh a, [hWhoseTurn] push af push hl diff --git a/src/engine/duel/effect_commands.asm b/src/engine/duel/effect_commands.asm index 7f08a0eb..2a3d3bb1 100644 --- a/src/engine/duel/effect_commands.asm +++ b/src/engine/duel/effect_commands.asm @@ -1,4 +1,4 @@ -EffectCommands: ; 186f7 (6:46f7) +EffectCommands:: ; Each attack has a two-byte effect pointer (attack's 7th param) that points to one of these structures. ; Similarly, trainer cards have a two-byte pointer (7th param) to one of these structures, which determines the card's function. ; Energy cards also point to one of these, but their data is just $00. diff --git a/src/engine/game_loop.asm b/src/engine/game_loop.asm index fc7def7c..93316e44 100644 --- a/src/engine/game_loop.asm +++ b/src/engine/game_loop.asm @@ -1,6 +1,6 @@ ; continuation of Bank0 Start ; meant as the main loop, but the game never returns from _GameLoop anyway -GameLoop: +GameLoop:: di ld sp, $e000 call ResetSerial @@ -35,7 +35,7 @@ GameLoop: .reset_game jp Reset -InitSaveDataAndSetUppercase: +InitSaveDataAndSetUppercase:: farcall InitSaveData ld a, 1 ld [wUppercaseHalfWidthLetters], a diff --git a/src/engine/gfx/sprite_animations.asm b/src/engine/gfx/sprite_animations.asm index 51e2a3a9..4ea2e587 100644 --- a/src/engine/gfx/sprite_animations.asm +++ b/src/engine/gfx/sprite_animations.asm @@ -1,6 +1,6 @@ ; disables all sprite animations ; and clears memory related to sprites -Func_1296e: +Func_1296e:: push af ld a, [wd5d7] or a @@ -137,7 +137,7 @@ GetSpriteAnimCounter: pop hl ret -_HandleAllSpriteAnimations: +_HandleAllSpriteAnimations:: push af ld a, [wd5d7] ; skip animating this frame if enabled or a diff --git a/src/engine/menus/common.asm b/src/engine/menus/common.asm index 60ad0a99..54eb351e 100644 --- a/src/engine/menus/common.asm +++ b/src/engine/menus/common.asm @@ -39,7 +39,7 @@ Func_758a: farcall Func_19eb4 ret -SetUpAndStartLinkDuel: +SetUpAndStartLinkDuel:: farcall _SetUpAndStartLinkDuel ret diff --git a/src/engine/menus/deck_machine.asm b/src/engine/menus/deck_machine.asm index 567bcb00..5d02e1b5 100644 --- a/src/engine/menus/deck_machine.asm +++ b/src/engine/menus/deck_machine.asm @@ -481,7 +481,7 @@ EmptyScreenAndDrawTextBox: call DrawRegularTextBox ret -Func_b177: +Func_b177:: ld a, [wd10e] and $03 ld hl, .FunctionTable diff --git a/src/engine/menus/duel.asm b/src/engine/menus/duel.asm index 887d6b66..96a49aca 100644 --- a/src/engine/menus/duel.asm +++ b/src/engine/menus/duel.asm @@ -1,4 +1,4 @@ -_OpenDuelCheckMenu: +_OpenDuelCheckMenu:: call ResetCheckMenuCursorPositionAndBlink xor a ld [wce5e], a @@ -397,7 +397,7 @@ DrawYourOrOppPlayAreaScreen: ; loads tiles and icons to display Your Play Area / Opp. Play Area screen, ; and draws the screen according to the turn player ; input: [wCheckMenuPlayAreaWhichDuelist] and [wCheckMenuPlayAreaWhichLayout] -_DrawYourOrOppPlayAreaScreen: +_DrawYourOrOppPlayAreaScreen:: xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -562,7 +562,7 @@ DrawInPlayAreaScreen: ret ; draws players prize cards and bench cards -_DrawPlayersPrizeAndBenchCards: +_DrawPlayersPrizeAndBenchCards:: xor a ld [wTileMapFill], a call ZeroObjectPositions @@ -1373,7 +1373,7 @@ DisplayCheckMenuCursor_YourOrOppPlayArea: jr DrawCheckMenuCursor_YourOrOppPlayArea ; handles Peek Pkmn Power selection menus -_HandlePeekSelection: +_HandlePeekSelection:: call Set_OBJ_8x8 call LoadCursorTile ; reset wce5c and wIsSwapTurnPending @@ -1622,7 +1622,7 @@ PeekOppPlayAreaTransitionTable: cursor_transition $08, $38, $00, $07, $07, $05, $04 cursor_transition $08, $60, $00, $06, $06, $01, $00 -_DrawAIPeekScreen: +_DrawAIPeekScreen:: push bc call Set_OBJ_8x8 call LoadCursorTile @@ -1897,7 +1897,7 @@ ZeroObjectPositionsWithCopyToggleOn: ret ; handles the screen for Player to select prize card(s) -_SelectPrizeCards: +_SelectPrizeCards:: xor a call GetFirstSetPrizeCard ld [wYourOrOppPlayAreaCurPosition], a @@ -2015,7 +2015,7 @@ _SelectPrizeCards: cursor_transition $08, $48, $00, $02, $00, $05, $05 cursor_transition $30, $48, $20, $03, $01, $04, $04 -_DrawPlayAreaToPlacePrizeCards: +_DrawPlayAreaToPlacePrizeCards:: xor a ld [wTileMapFill], a call ZeroObjectPositions diff --git a/src/engine/menus/main_menu.asm b/src/engine/menus/main_menu.asm index 005c266f..45bb3873 100644 --- a/src/engine/menus/main_menu.asm +++ b/src/engine/menus/main_menu.asm @@ -1,7 +1,7 @@ ; usually, the game doesn't loop here at all, since as soon as a main menu option ; is selected, there is no need to come back to the menu. ; the only exception is after returning from Card Pop! -_GameLoop: +_GameLoop:: call ZeroObjectPositions ld hl, wVBlankOAMCopyToggle inc [hl] diff --git a/src/engine/menus/play_area.asm b/src/engine/menus/play_area.asm index 19ea02fc..2c4a4d9e 100644 --- a/src/engine/menus/play_area.asm +++ b/src/engine/menus/play_area.asm @@ -1,7 +1,7 @@ ; this function is called when the player is shown the "In Play Area" screen. ; it can be called with either the select button (DuelMenuShortcut_BothActivePokemon), ; or via the "In Play Area" item of the Check menu (DuelCheckMenu_InPlayArea) -OpenInPlayAreaScreen: +OpenInPlayAreaScreen:: ld a, INPLAYAREA_PLAYER_ACTIVE ld [wInPlayAreaCurPosition], a .start diff --git a/src/engine/overworld/npcs.asm b/src/engine/overworld/npcs.asm index 65287145..2e237d48 100644 --- a/src/engine/overworld/npcs.asm +++ b/src/engine/overworld/npcs.asm @@ -126,7 +126,7 @@ SetNPCMatchStartTheme: INCLUDE "data/npcs.asm" -_GetNPCDuelConfigurations: +_GetNPCDuelConfigurations:: push hl push bc push de diff --git a/src/engine/overworld/overworld.asm b/src/engine/overworld/overworld.asm index a3c6ec8a..3fffdd39 100644 --- a/src/engine/overworld/overworld.asm +++ b/src/engine/overworld/overworld.asm @@ -1,4 +1,4 @@ -LoadMap: +LoadMap:: call DisableLCD call EnableSRAM bank1call DiscardSavedDuelData @@ -665,7 +665,7 @@ Func_c469: ld [wd234], a ret -SetScreenScrollWram: +SetScreenScrollWram:: ld a, [wSCXBuffer] ld [wSCX], a ld a, [wSCYBuffer] @@ -775,7 +775,7 @@ Func_c53d: call nz, Func_c6dc ret -Func_c554: +Func_c554:: ld a, [wPlayerSpriteIndex] ld [wWhichSprite], a ld a, [wCurMap] @@ -938,7 +938,7 @@ AttemptPlayerMovement: pop hl ret -FindPlayerMovementFromDirection: +FindPlayerMovementFromDirection:: ld a, [wPlayerDirection] FindPlayerMovementWithOffset: diff --git a/src/engine/overworld/scripting.asm b/src/engine/overworld/scripting.asm index 2bd7139a..92876058 100644 --- a/src/engine/overworld/scripting.asm +++ b/src/engine/overworld/scripting.asm @@ -95,7 +95,7 @@ Func_c9bc: Func_c9c0: ld l, MAP_SCRIPT_MOVED_PLAYER -CallMapScriptPointerIfExists: +CallMapScriptPointerIfExists:: call GetMapScriptPointer ret nc jp hl @@ -210,7 +210,7 @@ GetStackEventValue: ; returns the event var's value in a ; also ors it with itself before returning -GetEventValue: +GetEventValue:: push hl push bc call GetEventVar @@ -546,7 +546,7 @@ Script_LegendaryCardRightSpark: ; Enters into the script loop, continuing until wBreakScriptLoop > 0 ; When the loop is broken, it resumes normal code execution where script ended ; Note: Some scripts "double return" and skip this. -RST20: +RST20:: pop hl ld a, l ld [wScriptPointer], a @@ -877,7 +877,7 @@ ScriptCommand_MoveActiveNPCByDirection: ; Moves an NPC given the list of directions pointed to by bc ; set bit 7 to only rotate the NPC -ExecuteNPCMovement: +ExecuteNPCMovement:: farcall StartNPCMovement .loop call DoFrameIfLCDEnabled diff --git a/src/engine/save.asm b/src/engine/save.asm index 44221b60..9181059d 100644 --- a/src/engine/save.asm +++ b/src/engine/save.asm @@ -38,7 +38,7 @@ SaveAndBackupData: pop de ret -_SaveGeneralSaveData: +_SaveGeneralSaveData:: push de call GetReceivedLegendaryCards ld de, sGeneralSaveData @@ -200,7 +200,7 @@ ValidateBackupGeneralSaveData: ; returns carry if no error ; is found in sGeneralSaveData -_ValidateGeneralSaveData: +_ValidateGeneralSaveData:: push de call EnableSRAM ld de, sGeneralSaveData @@ -369,7 +369,7 @@ LoadBackupSaveData: pop hl ret -_LoadGeneralSaveData: +_LoadGeneralSaveData:: push de ld de, sGeneralSaveData call LoadGeneralSaveDataFromDE @@ -503,7 +503,7 @@ WRAMToSRAMMapper: ; save the game ; if c is 0, save the player at their current position ; otherwise, save the player in Mason's lab -_SaveGame: +_SaveGame:: ld a, c or a jr nz, .force_mason_lab @@ -526,7 +526,7 @@ _SaveGame: call SaveAndBackupData ret -_AddCardToCollectionAndUpdateAlbumProgress: +_AddCardToCollectionAndUpdateAlbumProgress:: ld [wCardToAddToCollection], a push hl push bc diff --git a/src/engine/scenes.asm b/src/engine/scenes.asm index e08c5fac..19435aec 100644 --- a/src/engine/scenes.asm +++ b/src/engine/scenes.asm @@ -2,7 +2,7 @@ ; a = scene ID (SCENE_* constant) ; b = base X position of scene in tiles ; c = base Y position of scene in tiles -_LoadScene: +_LoadScene:: push hl push bc push de @@ -243,7 +243,7 @@ SGBPacket_CardPop: ds 6 ; data set 2 ds 2 ; data set 3 -Func_12fc6: +Func_12fc6:: ld a, [wd291] push af push de diff --git a/src/engine/home.asm b/src/home.asm similarity index 98% rename from src/engine/home.asm rename to src/home.asm index 6b886a45..be681af1 100644 --- a/src/engine/home.asm +++ b/src/home.asm @@ -1,3 +1,6 @@ +INCLUDE "macros.asm" +INCLUDE "constants.asm" + ; rst vectors SECTION "rst00", ROM0 ret diff --git a/src/home/ai.asm b/src/home/ai.asm index 3806b20c..271527de 100644 --- a/src/home/ai.asm +++ b/src/home/ai.asm @@ -1,7 +1,7 @@ ; loads opponent deck at wOpponentDeckID to wOpponentDeck, and initializes wPlayerDuelistType. ; on a duel against Sam, also loads PRACTICE_PLAYER_DECK to wPlayerDeck. ; also, sets wRNG1, wRNG2, and wRNGCounter to $57. -LoadOpponentDeck: +LoadOpponentDeck:: xor a ld [wIsPracticeDuel], a ld a, [wOpponentDeckID] @@ -45,35 +45,35 @@ LoadOpponentDeck: ld [hl], a ret -AIDoAction_Turn: +AIDoAction_Turn:: ld a, AIACTION_DO_TURN jr AIDoAction -AIDoAction_StartDuel: +AIDoAction_StartDuel:: ld a, AIACTION_START_DUEL jr AIDoAction -AIDoAction_ForcedSwitch: +AIDoAction_ForcedSwitch:: ld a, AIACTION_FORCED_SWITCH call AIDoAction ldh [hTempPlayAreaLocation_ff9d], a ret -AIDoAction_KOSwitch: +AIDoAction_KOSwitch:: ld a, AIACTION_KO_SWITCH call AIDoAction ldh [hTemp_ffa0], a ret -AIDoAction_TakePrize: +AIDoAction_TakePrize:: ld a, AIACTION_TAKE_PRIZE jr AIDoAction ; this line is not needed ; calls the appropriate AI routine to handle action, ; depending on the deck ID (see engine/duel/ai/deck_ai.asm) -; input: +; input:: ; - a = AIACTION_* constant -AIDoAction: +AIDoAction:: ld c, a ; load bank for Opponent Deck pointer table diff --git a/src/home/audio_callback.asm b/src/home/audio_callback.asm index a14cffcb..a0c52d6d 100644 --- a/src/home/audio_callback.asm +++ b/src/home/audio_callback.asm @@ -1,6 +1,6 @@ SECTION "Audio Callback", ROM0 -; jumps to 3f:hl, then switches to bank 3d +; jumps to 3f::hl, then switches to bank 3d Bankswitch3dTo3f:: push af ld a, $3f diff --git a/src/home/bg_map.asm b/src/home/bg_map.asm index c88d5de8..16a7be58 100644 --- a/src/home/bg_map.asm +++ b/src/home/bg_map.asm @@ -1,19 +1,19 @@ -; reads structs: +; reads structs:: ; x (1 byte), y (1 byte), data (n bytes), $00 ; x (1 byte), y (1 byte), data (n bytes), $00 ; ... ; $ff ; for each struct, writes data to BGMap0-translated x,y -WriteDataBlocksToBGMap0: +WriteDataBlocksToBGMap0:: call WriteDataBlockToBGMap0 bit 7, [hl] ; check for $ff jr z, WriteDataBlocksToBGMap0 ret -; reads struct: +; reads struct:: ; x (1 byte), y (1 byte), data (n bytes), $00 ; writes data to BGMap0-translated x,y -WriteDataBlockToBGMap0: +WriteDataBlockToBGMap0:: ld b, [hl] inc hl ld c, [hl] @@ -49,7 +49,7 @@ WriteDataBlockToBGMap0: ret ; writes a to [v*BGMap0 + BG_MAP_WIDTH * c + b] -WriteByteToBGMap0: +WriteByteToBGMap0:: push af ld a, [wLCDC] rla @@ -71,7 +71,7 @@ WriteByteToBGMap0: ; fallthrough ; writes a to [v*BGMap0 + BG_MAP_WIDTH * c + b] during hblank -HblankWriteByteToBGMap0: +HblankWriteByteToBGMap0:: push hl push de push bc @@ -88,7 +88,7 @@ HblankWriteByteToBGMap0: ret ; copy a bytes of data from hl to vBGMap0 address pointed to by coord at bc -CopyDataToBGMap0: +CopyDataToBGMap0:: push bc push hl push af @@ -102,7 +102,7 @@ CopyDataToBGMap0: ; copy b bytes of data from hl to de ; if LCD on, copy during h-blank only -SafeCopyDataHLtoDE: ; 6fc (0:6fc) +SafeCopyDataHLtoDE:: ; 6fc (0::6fc) ld a, [wLCDC] rla jr c, JPHblankCopyDataHLtoDE @@ -113,5 +113,5 @@ SafeCopyDataHLtoDE: ; 6fc (0:6fc) dec b jr nz, .lcd_off_loop ret -JPHblankCopyDataHLtoDE: +JPHblankCopyDataHLtoDE:: jp HblankCopyDataHLtoDE diff --git a/src/home/call_regs.asm b/src/home/call_regs.asm index 2f806897..76c87ba5 100644 --- a/src/home/call_regs.asm +++ b/src/home/call_regs.asm @@ -1,5 +1,5 @@ -CallHL2: +CallHL2:: jp hl -CallBC: +CallBC:: retbc diff --git a/src/home/card_collection.asm b/src/home/card_collection.asm index a53b9d49..fe05fc79 100644 --- a/src/home/card_collection.asm +++ b/src/home/card_collection.asm @@ -1,5 +1,5 @@ ; return, in hl, the total amount of cards owned anywhere, including duplicates -GetAmountOfCardsOwned: +GetAmountOfCardsOwned:: push de push bc call EnableSRAM @@ -43,7 +43,7 @@ GetAmountOfCardsOwned: ; return carry if the count in sCardCollection plus the count in each deck (sDeck*) ; of the card with id given in a is 0 (if card not owned). ; also return the count (total owned amount) in a. -GetCardCountInCollectionAndDecks: +GetCardCountInCollectionAndDecks:: push hl push de push bc @@ -94,7 +94,7 @@ GetCardCountInCollectionAndDecks: ; return carry if the count in sCardCollection of the card with id given in a is 0. ; also return the count (amount owned outside of decks) in a. -GetCardCountInCollection: +GetCardCountInCollection:: push hl call EnableSRAM ld h, HIGH(sCardCollection) @@ -108,7 +108,7 @@ GetCardCountInCollection: ret ; creates a list at wTempCardCollection of every card the player owns and how many -CreateTempCardCollection: +CreateTempCardCollection:: call EnableSRAM ld hl, sCardCollection ld de, wTempCardCollection @@ -126,7 +126,7 @@ CreateTempCardCollection: ret ; adds the cards from a deck to wTempCardCollection given de = sDeck*Name -AddDeckCardsToTempCardCollection: +AddDeckCardsToTempCardCollection:: ld a, [de] or a ret z ; return if empty name (empty deck) @@ -147,7 +147,7 @@ AddDeckCardsToTempCardCollection: ; add card with id given in a to sCardCollection, provided that ; the player has less than MAX_AMOUNT_OF_CARD (99) of them -AddCardToCollection: +AddCardToCollection:: push hl push de push bc @@ -174,7 +174,7 @@ AddCardToCollection: ret ; remove a card with id given in a from sCardCollection (decrement its count if non-0) -RemoveCardFromCollection: +RemoveCardFromCollection:: push hl call EnableSRAM ld h, HIGH(sCardCollection) @@ -191,7 +191,7 @@ RemoveCardFromCollection: ; return the amount of different cards that the player has collected in d ; return NUM_CARDS in e, minus 1 if VENUSAUR_LV64 or MEW_LV15 has not been collected (minus 2 if neither) -GetCardAlbumProgress: +GetCardAlbumProgress:: push hl call EnableSRAM ld e, NUM_CARDS diff --git a/src/home/card_color.asm b/src/home/card_color.asm index 052a64c3..4ed5cc1e 100644 --- a/src/home/card_color.asm +++ b/src/home/card_color.asm @@ -1,11 +1,11 @@ ; return the turn holder's arena card's color in a, accounting for Venomoth's Shift Pokemon Power if active -GetArenaCardColor: +GetArenaCardColor:: xor a ; fallthrough -; input: a = play area location offset (PLAY_AREA_*) of the desired card +; input:: a = play area location offset (PLAY_AREA_*) of the desired card ; return the turn holder's card's color in a, accounting for Venomoth's Shift Pokemon Power if active -GetPlayAreaCardColor: +GetPlayAreaCardColor:: push hl push de ld e, a @@ -41,7 +41,7 @@ GetPlayAreaCardColor: ; return in a the weakness of the turn holder's arena or benchx Pokemon given the PLAY_AREA_* value in a ; if a == 0 and [DUELVARS_ARENA_CARD_CHANGED_WEAKNESS] != 0, ; return [DUELVARS_ARENA_CARD_CHANGED_WEAKNESS] instead -GetPlayAreaCardWeakness: +GetPlayAreaCardWeakness:: or a jr z, GetArenaCardWeakness add DUELVARS_ARENA_CARD @@ -49,7 +49,7 @@ GetPlayAreaCardWeakness: ; return in a the weakness of the turn holder's arena Pokemon ; if [DUELVARS_ARENA_CARD_CHANGED_WEAKNESS] != 0, return it instead -GetArenaCardWeakness: +GetArenaCardWeakness:: ld a, DUELVARS_ARENA_CARD_CHANGED_WEAKNESS call GetTurnDuelistVariable or a @@ -57,7 +57,7 @@ GetArenaCardWeakness: ld a, DUELVARS_ARENA_CARD ; fallthrough -GetCardWeakness: +GetCardWeakness:: call GetTurnDuelistVariable call LoadCardDataToBuffer2_FromDeckIndex ld a, [wLoadedCard2Weakness] @@ -66,7 +66,7 @@ GetCardWeakness: ; return in a the resistance of the turn holder's arena or benchx Pokemon given the PLAY_AREA_* value in a ; if a == 0 and [DUELVARS_ARENA_CARD_CHANGED_RESISTANCE] != 0, ; return [DUELVARS_ARENA_CARD_CHANGED_RESISTANCE] instead -GetPlayAreaCardResistance: +GetPlayAreaCardResistance:: or a jr z, GetArenaCardResistance add DUELVARS_ARENA_CARD @@ -74,7 +74,7 @@ GetPlayAreaCardResistance: ; return in a the resistance of the arena Pokemon ; if [DUELVARS_ARENA_CARD_CHANGED_RESISTANCE] != 0, return it instead -GetArenaCardResistance: +GetArenaCardResistance:: ld a, DUELVARS_ARENA_CARD_CHANGED_RESISTANCE call GetTurnDuelistVariable or a @@ -82,7 +82,7 @@ GetArenaCardResistance: ld a, DUELVARS_ARENA_CARD ; fallthrough -GetCardResistance: +GetCardResistance:: call GetTurnDuelistVariable call LoadCardDataToBuffer2_FromDeckIndex ld a, [wLoadedCard2Resistance] @@ -90,7 +90,7 @@ GetCardResistance: ; this function checks if turn holder's CHARIZARD energy burn is active, and if so, turns ; all energies at wAttachedEnergies except double colorless energies into fire energies -HandleEnergyBurn: +HandleEnergyBurn:: ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable call GetCardIDFromDeckIndex diff --git a/src/home/card_data.asm b/src/home/card_data.asm index 9fd78ae7..66f422c0 100644 --- a/src/home/card_data.asm +++ b/src/home/card_data.asm @@ -1,5 +1,5 @@ ; load data of card with text id of name at de to wLoadedCard1 -LoadCardDataToBuffer1_FromName: +LoadCardDataToBuffer1_FromName:: ld hl, CardPointers + 2 ; skip first NULL pointer ld a, BANK(CardPointers) call BankpushROM2 @@ -45,18 +45,18 @@ LoadCardDataToBuffer1_FromName: ret ; load data of card with id at e to wLoadedCard2 -LoadCardDataToBuffer2_FromCardID: +LoadCardDataToBuffer2_FromCardID:: push hl ld hl, wLoadedCard2 jr LoadCardDataToHL_FromCardID ; load data of card with id at e to wLoadedCard1 -LoadCardDataToBuffer1_FromCardID: +LoadCardDataToBuffer1_FromCardID:: push hl ld hl, wLoadedCard1 ; fallthrough -LoadCardDataToHL_FromCardID: +LoadCardDataToHL_FromCardID:: push de push bc push hl @@ -81,7 +81,7 @@ LoadCardDataToHL_FromCardID: ret ; return in a the type (TYPE_* constant) of the card with id at e -GetCardType: +GetCardType:: push hl call GetCardPointer jr c, .done @@ -96,7 +96,7 @@ GetCardType: ret ; return in de the 2-byte text id of the name of the card with id at e -GetCardName: +GetCardName:: push hl call GetCardPointer jr c, .done @@ -114,7 +114,7 @@ GetCardName: ret ; from the card id in a, returns type into a, rarity into b, and set into c -GetCardTypeRarityAndSet: +GetCardTypeRarityAndSet:: push hl push de ld d, 0 @@ -139,7 +139,7 @@ GetCardTypeRarityAndSet: ; return at hl the pointer to the data of the card with id at e ; return carry if e was out of bounds, so no pointer was returned -GetCardPointer: +GetCardPointer:: push de push bc ld l, e @@ -167,13 +167,13 @@ GetCardPointer: pop de ret -; input: +; input:: ; hl = card_gfx_index ; de = where to load the card gfx to ; bc are supposed to be $30 (number of tiles of a card gfx) and TILE_SIZE respectively ; card_gfx_index = (CardGfx - CardGraphics) / 8 (using absolute ROM addresses) ; also copies the card's palette to wCardPalette -LoadCardGfx: +LoadCardGfx:: ldh a, [hBankROM] push af push hl @@ -185,7 +185,7 @@ LoadCardGfx: add h call BankswitchROM pop hl - ; once we have the bank, get the pointer: multiply by 8 and discard the bank offset + ; once we have the bank, get the pointer:: multiply by 8 and discard the bank offset add hl, hl add hl, hl add hl, hl @@ -205,7 +205,7 @@ LoadCardGfx: ret ; identical to CopyFontsOrDuelGraphicsTiles -CopyFontsOrDuelGraphicsTiles2: +CopyFontsOrDuelGraphicsTiles2:: ld a, BANK(Fonts) ; BANK(DuelGraphics) call BankpushROM ld c, TILE_SIZE diff --git a/src/home/clear_sram.asm b/src/home/clear_sram.asm index 63aac1a2..af46aef3 100644 --- a/src/home/clear_sram.asm +++ b/src/home/clear_sram.asm @@ -1,6 +1,6 @@ ; validate the saved data in SRAM ; it must contain with the sequence $04, $21, $05 at s0a000 -ValidateSRAM: +ValidateSRAM:: xor a call BankswitchSRAM ld hl, $a000 @@ -41,7 +41,7 @@ ValidateSRAM: ret ; zero all SRAM banks and set s0a000 to $04, $21, $05 -RestartSRAM: +RestartSRAM:: ld a, 3 .clear_loop call ClearSRAMBank @@ -57,7 +57,7 @@ RestartSRAM: ret ; zero the loaded SRAM bank -ClearSRAMBank: +ClearSRAMBank:: push af call BankswitchSRAM call EnableSRAM diff --git a/src/home/coin_toss.asm b/src/home/coin_toss.asm index 726fde0c..59be4eb9 100644 --- a/src/home/coin_toss.asm +++ b/src/home/coin_toss.asm @@ -1,8 +1,8 @@ ; function that executes one or more consecutive coin tosses during a duel (a = number of coin tosses), ; displaying each result ([O] or [X]) starting from the top left corner of the screen. ; text at de is printed in a text box during the coin toss. -; returns: the number of heads in a and in wCoinTossNumHeads, and carry if at least one heads -TossCoinATimes: +; returns:: the number of heads in a and in wCoinTossNumHeads, and carry if at least one heads +TossCoinATimes:: push hl ld hl, wCoinTossScreenTextID ld [hl], e @@ -14,9 +14,9 @@ TossCoinATimes: ; function that executes a single coin toss during a duel. ; text at de is printed in a text box during the coin toss. -; returns: - carry, and 1 in a and in wCoinTossNumHeads if heads +; returns:: - carry, and 1 in a and in wCoinTossNumHeads if heads ; - nc, and 0 in a and in wCoinTossNumHeads if tails -TossCoin: +TossCoin:: push hl ld hl, wCoinTossScreenTextID ld [hl], e @@ -30,7 +30,7 @@ TossCoin: ret ; cp de, bc -CompareDEtoBC: +CompareDEtoBC:: ld a, d cp b ret nz diff --git a/src/home/copy.asm b/src/home/copy.asm index 8b21f909..055e33cc 100644 --- a/src/home/copy.asm +++ b/src/home/copy.asm @@ -1,6 +1,6 @@ ; copy c bytes of data from hl to de, b times. ; used to copy gfx data with c = TILE_SIZE -CopyGfxData: +CopyGfxData:: ld a, [wLCDC] rla jr nc, .next_tile @@ -35,7 +35,7 @@ CopyGfxData: ret ; copy bc bytes from hl to de. preserves all registers except af -CopyDataHLtoDE_SaveRegisters: +CopyDataHLtoDE_SaveRegisters:: push hl push de push bc @@ -46,7 +46,7 @@ CopyDataHLtoDE_SaveRegisters: ret ; copy bc bytes from hl to de -CopyDataHLtoDE: +CopyDataHLtoDE:: ld a, [hli] ld [de], a inc de diff --git a/src/home/damage.asm b/src/home/damage.asm index 996ea5e5..42293b12 100644 --- a/src/home/damage.asm +++ b/src/home/damage.asm @@ -1,5 +1,5 @@ ; [wDamage] += a -AddToDamage: +AddToDamage:: push hl ld hl, wDamage add [hl] @@ -11,7 +11,7 @@ AddToDamage: ret ; [wDamage] -= a -SubtractFromDamage: +SubtractFromDamage:: push de push hl ld e, a diff --git a/src/home/decompress.asm b/src/home/decompress.asm index b8952cce..963ef051 100644 --- a/src/home/decompress.asm +++ b/src/home/decompress.asm @@ -2,7 +2,7 @@ ; de = source of compressed data ; b = HIGH byte of secondary buffer ($100 bytes of buffer space) ; also clears this $100 byte space -InitDataDecompression: +InitDataDecompression:: ld hl, wDecompSourcePosPtr ld [hl], e inc hl @@ -33,10 +33,10 @@ InitDataDecompression: ; decompresses data ; uses values initialized by InitDataDecompression ; wDecompSourcePosPtr holds the pointer for compressed source -; input: +; input:: ; bc = row width ; de = buffer to place decompressed data -DecompressData: +DecompressData:: push hl push de .loop @@ -53,7 +53,7 @@ DecompressData: pop hl ret -; decompression works as follows: +; decompression works as follows:: ; first a command byte is read that will dictate how the ; following bytes will be copied ; the position will then move to the next byte (0xXY), and @@ -63,13 +63,13 @@ DecompressData: ; which means it stores 0xXY in memory as number of bytes to repeat ; from a given offset. This offset is in the next byte in the data, ; 0xZZ, which tells the offset to start repeating. A toggle is switched -; each time the algorithm hits "repeat mode": +; each time the algorithm hits "repeat mode":: ; - if off -> on it reads 0xXY and stores it, ; then repeats (0x0X + 2) bytes from the offset starting at 0xZZ; ; - if on -> off, then the data only provides the offset, ; and the previous byte read for number of bytes to repeat, 0xXY, is reused ; in which case (0x0Y + 2) bytes are repeated starting from the offset. -.Decompress: +.Decompress:: ld hl, wDecompNumBytesToRepeat ld a, [hl] or a diff --git a/src/home/division.asm b/src/home/division.asm index 56bc651a..89f703ef 100644 --- a/src/home/division.asm +++ b/src/home/division.asm @@ -1,5 +1,5 @@ ; divides BC by DE. Stores result in BC and stores remainder in HL -DivideBCbyDE: +DivideBCbyDE:: ld hl, $0000 rl c rl b diff --git a/src/home/dma.asm b/src/home/dma.asm index bcba9630..f38c70ad 100644 --- a/src/home/dma.asm +++ b/src/home/dma.asm @@ -1,5 +1,5 @@ ; copy DMA to hDMAFunction -CopyDMAFunction: +CopyDMAFunction:: ld c, LOW(hDMAFunction) ld b, JumpToFunctionInTable - DMA ld hl, DMA @@ -12,7 +12,7 @@ CopyDMAFunction: ret ; CopyDMAFunction copies this function to hDMAFunction ($ff83) -DMA: +DMA:: ld a, HIGH(wOAM) ldh [rDMA], a ld a, $28 diff --git a/src/home/double_speed.asm b/src/home/double_speed.asm index f3aa682a..23fe5f33 100644 --- a/src/home/double_speed.asm +++ b/src/home/double_speed.asm @@ -1,5 +1,5 @@ ; switch to CGB Normal Speed Mode if playing on CGB and current mode is Double Speed Mode -SwitchToCGBNormalSpeed: ; 7db (0:7db) +SwitchToCGBNormalSpeed:: ; 7db (0::7db) call CheckForCGB ret c ld hl, rKEY1 @@ -8,7 +8,7 @@ SwitchToCGBNormalSpeed: ; 7db (0:7db) jr CGBSpeedSwitch ; switch to CGB Double Speed Mode if playing on CGB and current mode is Normal Speed Mode -SwitchToCGBDoubleSpeed: +SwitchToCGBDoubleSpeed:: call CheckForCGB ret c ld hl, rKEY1 @@ -17,7 +17,7 @@ SwitchToCGBDoubleSpeed: ; fallthrough ; switch between CGB Double Speed Mode and Normal Speed Mode -CGBSpeedSwitch: +CGBSpeedSwitch:: ldh a, [rIE] push af xor a diff --git a/src/home/duel.asm b/src/home/duel.asm index a9bc99b7..777c7641 100644 --- a/src/home/duel.asm +++ b/src/home/duel.asm @@ -1,6 +1,6 @@ ; save duel state to SRAM ; called between each two-player turn, just after player draws card (ROM bank 1 loaded) -SaveDuelStateToSRAM: +SaveDuelStateToSRAM:: ld a, $2 call BankswitchSRAM ; save duel data to sCurrentDuel @@ -12,7 +12,7 @@ SaveDuelStateToSRAM: ld a, [hl] inc [hl] call DisableSRAM - ; select hl = SRAM3:(a000 + $400 * [s0a008] & $3) + ; select hl = SRAM3::(a000 + $400 * [s0a008] & $3) ; save wDuelTurns, non-turn holder's arena card ID, turn holder's arena card ID and $3 add HIGH($a000) / 4 @@ -44,7 +44,7 @@ SaveDuelStateToSRAM: ld [hli], a ld a, [wTempTurnDuelistCardID] ld [hli], a - ; save duel data to SRAM3:(a000 + $400 * [s0a008] & $3) + $0010 + ; save duel data to SRAM3::(a000 + $400 * [s0a008] & $3) + $0010 pop hl ld de, $0010 add hl, de @@ -57,7 +57,7 @@ SaveDuelStateToSRAM: ret ; copies the deck pointed to by de to wPlayerDeck or wOpponentDeck (depending on whose turn it is) -CopyDeckData: +CopyDeckData:: ld hl, wPlayerDeck ldh a, [hWhoseTurn] cp PLAYER_TURN @@ -104,7 +104,7 @@ CopyDeckData: ret ; return, in register a, the amount of prizes that the turn holder has not yet drawn -CountPrizes: +CountPrizes:: push hl ld a, DUELVARS_PRIZES call GetTurnDuelistVariable @@ -121,7 +121,7 @@ CountPrizes: ; shuffles the turn holder's deck ; if less than 60 cards remain in the deck, it makes sure that the rest are ignored -ShuffleDeck: +ShuffleDeck:: ldh a, [hWhoseTurn] ld h, a ld d, a @@ -139,7 +139,7 @@ ShuffleDeck: ; draw a card from the turn holder's deck, saving its location as CARD_LOCATION_JUST_DRAWN. ; returns carry if deck is empty, nc if a card was successfully drawn. ; AddCardToHand is meant to be called next (unless this function returned carry). -DrawCardFromDeck: +DrawCardFromDeck:: push hl ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK call GetTurnDuelistVariable @@ -162,7 +162,7 @@ DrawCardFromDeck: ; add a card to the top of the turn holder's deck ; the card is identified by register a, which contains the deck index (0-59) of the card -ReturnCardToDeck: +ReturnCardToDeck:: push hl push af ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK @@ -182,7 +182,7 @@ ReturnCardToDeck: ; search a card in the turn holder's deck, extract it, and set its location to ; CARD_LOCATION_JUST_DRAWN. AddCardToHand is meant to be called next. ; the card is identified by register a, which contains the deck index (0-59) of the card. -SearchCardInDeckAndAddToHand: +SearchCardInDeckAndAddToHand:: push af push hl push de @@ -218,7 +218,7 @@ SearchCardInDeckAndAddToHand: ; adds a card to the turn holder's hand and increments the number of cards in the hand ; the card is identified by register a, which contains the deck index (0-59) of the card -AddCardToHand: +AddCardToHand:: push af push hl push de @@ -243,7 +243,7 @@ AddCardToHand: ; removes a card from the turn holder's hand and decrements the number of cards in the hand ; the card is identified by register a, which contains the deck index (0-59) of the card -RemoveCardFromHand: +RemoveCardFromHand:: push af push hl push bc @@ -281,7 +281,7 @@ RemoveCardFromHand: ; moves a card to the turn holder's discard pile, as long as it is in the hand ; the card is identified by register a, which contains the deck index (0-59) of the card -MoveHandCardToDiscardPile: +MoveHandCardToDiscardPile:: call GetTurnDuelistVariable ld a, [hl] and $ff ^ CARD_LOCATION_JUST_DRAWN @@ -292,7 +292,7 @@ MoveHandCardToDiscardPile: ; fallthrough ; puts the turn holder's card with the deck index (0-59) given in a into the discard pile -PutCardInDiscardPile: +PutCardInDiscardPile:: push af push hl push de @@ -313,7 +313,7 @@ PutCardInDiscardPile: ; search a card in the turn holder's discard pile, extract it, and set its location to ; CARD_LOCATION_JUST_DRAWN. AddCardToHand is meant to be called next. ; the card is identified by register a, which contains the deck index (0-59) of the card -MoveDiscardPileCardToHand: +MoveDiscardPileCardToHand:: push hl push de push bc @@ -346,8 +346,8 @@ MoveDiscardPileCardToHand: ret ; return in the z flag whether turn holder's prize a (0-7) has been drawn or not -; z: drawn, nz: not drawn -CheckPrizeTaken: +; z:: drawn, nz:: not drawn +CheckPrizeTaken:: ld e, a ld d, 0 ld hl, PowersOf2 @@ -361,12 +361,12 @@ CheckPrizeTaken: and e ret -PowersOf2: +PowersOf2:: db $01, $02, $04, $08, $10, $20, $40, $80 ; fill wDuelTempList with the turn holder's discard pile cards (their 0-59 deck indexes) ; return carry if the turn holder has no cards in the discard pile -CreateDiscardPileCardList: +CreateDiscardPileCardList:: ldh a, [hWhoseTurn] ld h, a ld l, DUELVARS_NUMBER_OF_CARDS_IN_DISCARD_PILE @@ -395,7 +395,7 @@ CreateDiscardPileCardList: ; fill wDuelTempList with the turn holder's remaining deck cards (their 0-59 deck indexes) ; return carry if the turn holder has no cards left in the deck -CreateDeckCardList: +CreateDeckCardList:: ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK call GetTurnDuelistVariable cp DECK_SIZE @@ -430,10 +430,10 @@ CreateDeckCardList: ; fill wDuelTempList with the turn holder's energy cards ; in the arena or in a bench slot (their 0-59 deck indexes). -; if a == 0: search in CARD_LOCATION_ARENA -; if a != 0: search in CARD_LOCATION_BENCH_[A] +; if a == 0:: search in CARD_LOCATION_ARENA +; if a != 0:: search in CARD_LOCATION_BENCH_[A] ; return carry if no energy cards were found -CreateArenaOrBenchEnergyCardList: +CreateArenaOrBenchEnergyCardList:: or CARD_LOCATION_PLAY_AREA ld c, a ld de, wDuelTempList @@ -471,7 +471,7 @@ CreateArenaOrBenchEnergyCardList: ; fill wDuelTempList with the turn holder's hand cards (their 0-59 deck indexes) ; return carry if the turn holder has no cards in hand ; and outputs in a number of cards. -CreateHandCardList: +CreateHandCardList:: call FindLastCardInHand inc b jr .skip_card @@ -500,7 +500,7 @@ CreateHandCardList: ; sort the turn holder's hand cards by ID (highest to lowest ID) ; makes use of wDuelTempList -SortHandCardsByID: +SortHandCardsByID:: call FindLastCardInHand .loop ld a, [hld] @@ -520,11 +520,11 @@ SortHandCardsByID: jr nz, .loop2 ret -; returns: +; returns:: ; b = turn holder's number of cards in hand (DUELVARS_NUMBER_OF_CARDS_IN_HAND) ; hl = pointer to turn holder's last (newest) card in DUELVARS_HAND ; de = wDuelTempList -FindLastCardInHand: +FindLastCardInHand:: ldh a, [hWhoseTurn] ld h, a ld l, DUELVARS_NUMBER_OF_CARDS_IN_HAND @@ -536,10 +536,10 @@ FindLastCardInHand: ret ; shuffles the deck by swapping the position of each card with the position of another random card -; input: +; input:: ; a = how many cards to shuffle ; hl = DUELVARS_DECK_CARDS + [DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK] -ShuffleCards: +ShuffleCards:: or a ret z ; return if deck is empty push hl @@ -576,7 +576,7 @@ ShuffleCards: ; sort a $ff-terminated list of deck index cards by ID (lowest to highest ID). ; the list is wDuelTempList. -SortCardsInDuelTempListByID: +SortCardsInDuelTempListByID:: ld hl, hTempListPtr_ff99 ld [hl], LOW(wDuelTempList) inc hl @@ -587,7 +587,7 @@ SortCardsInDuelTempListByID: ; the pointer to the list is given in hTempListPtr_ff99. ; sorting by ID rather than deck index means that the order of equal (same ID) cards does not matter, ; even if they have a different deck index. -SortCardsInListByID: +SortCardsInListByID:: ; load [hTempListPtr_ff99] into hl and de ld hl, hTempListPtr_ff99 ld a, [hli] @@ -648,7 +648,7 @@ SortCardsInListByID: inc [hl] ; fallthrough -SortCardsInListByID_CheckForListTerminator: +SortCardsInListByID_CheckForListTerminator:: ld hl, hTempListPtr_ff99 ld a, [hli] ld h, [hl] @@ -659,7 +659,7 @@ SortCardsInListByID_CheckForListTerminator: ; returns, in register bc, the id of the card with the deck index specified in register a ; preserves hl -GetCardIDFromDeckIndex_bc: +GetCardIDFromDeckIndex_bc:: push hl call _GetCardIDFromDeckIndex ld c, a @@ -668,7 +668,7 @@ GetCardIDFromDeckIndex_bc: ret ; return [wDuelTempList + a] in a and in hTempCardIndex_ff98 -GetCardInDuelTempList_OnlyDeckIndex: +GetCardInDuelTempList_OnlyDeckIndex:: push hl push de ld e, a @@ -681,10 +681,10 @@ GetCardInDuelTempList_OnlyDeckIndex: pop hl ret -; given the deck index (0-59) of a card in [wDuelTempList + a], return: +; given the deck index (0-59) of a card in [wDuelTempList + a], return:: ; - the id of the card with that deck index in register de ; - [wDuelTempList + a] in hTempCardIndex_ff98 and in register a -GetCardInDuelTempList: +GetCardInDuelTempList:: push hl ld e, a ld d, $0 @@ -699,7 +699,7 @@ GetCardInDuelTempList: ; returns, in register de, the id of the card with the deck index (0-59) specified by register a ; preserves af and hl -GetCardIDFromDeckIndex: +GetCardIDFromDeckIndex:: push af push hl call _GetCardIDFromDeckIndex @@ -711,7 +711,7 @@ GetCardIDFromDeckIndex: ; remove card c from wDuelTempList (it contains a $ff-terminated list of deck indexes) ; returns carry if no matches were found. -RemoveCardFromDuelTempList: +RemoveCardFromDuelTempList:: push hl push de push bc @@ -744,7 +744,7 @@ RemoveCardFromDuelTempList: ret ; return the number of cards in wDuelTempList in a -CountCardsInDuelTempList: +CountCardsInDuelTempList:: push hl push bc ld hl, wDuelTempList @@ -760,7 +760,7 @@ CountCardsInDuelTempList: ret ; returns, in register a, the id of the card with the deck index (0-59) specified in register a -_GetCardIDFromDeckIndex: +_GetCardIDFromDeckIndex:: push de ld e, a ld d, $0 @@ -776,7 +776,7 @@ _GetCardIDFromDeckIndex: ret ; load data of card with deck index a (0-59) to wLoadedCard1 -LoadCardDataToBuffer1_FromDeckIndex: +LoadCardDataToBuffer1_FromDeckIndex:: push hl push de push bc @@ -793,7 +793,7 @@ LoadCardDataToBuffer1_FromDeckIndex: ret ; load data of card with deck index a (0-59) to wLoadedCard2 -LoadCardDataToBuffer2_FromDeckIndex: +LoadCardDataToBuffer2_FromDeckIndex:: push hl push de push bc @@ -812,7 +812,7 @@ LoadCardDataToBuffer2_FromDeckIndex: ; evolve a turn holder's Pokemon card in the play area slot determined by hTempPlayAreaLocation_ff9d ; into another turn holder's Pokemon card identifier by its deck index (0-59) in hTempCardIndex_ff98. ; return nc if evolution was successful. -EvolvePokemonCardIfPossible: +EvolvePokemonCardIfPossible:: ; first make sure the attempted evolution is viable ldh a, [hTempCardIndex_ff98] ld d, a @@ -824,7 +824,7 @@ EvolvePokemonCardIfPossible: ; evolve a turn holder's Pokemon card in the play area slot determined by hTempPlayAreaLocation_ff9d ; into another turn holder's Pokemon card identifier by its deck index (0-59) in hTempCardIndex_ff98. -EvolvePokemonCard: +EvolvePokemonCard:: ; place the evolved Pokemon card in the play area location of the pre-evolved Pokemon card ldh a, [hTempPlayAreaLocation_ff9d] ld e, a @@ -877,7 +877,7 @@ EvolvePokemonCard: ; e is the play area location offset (PLAY_AREA_*) of the Pokemon trying to evolve. ; d is the deck index (0-59) of the Pokemon card that was selected to be the evolution target. ; return carry if can't evolve, plus nz if the reason for it is the card was played this turn. -CheckIfCanEvolveInto: +CheckIfCanEvolveInto:: push de ld a, e add DUELVARS_ARENA_CARD @@ -920,7 +920,7 @@ CheckIfCanEvolveInto: ; e is the play area location offset (PLAY_AREA_*) of the Pokemon trying to evolve. ; d is the deck index (0-59) of the Pokemon card that was selected to be the evolution target. ; return carry if not basic to stage 2 evolution, or if evolution not possible this turn. -CheckIfCanEvolveInto_BasicToStage2: +CheckIfCanEvolveInto_BasicToStage2:: ld a, e add DUELVARS_ARENA_CARD_FLAGS call GetTurnDuelistVariable @@ -960,7 +960,7 @@ CheckIfCanEvolveInto_BasicToStage2: ; clear the status, all substatuses, and temporary duelvars of the turn holder's ; arena Pokemon. called when sending a new Pokemon into the arena. ; does not reset Headache, since it targets a player rather than a Pokemon. -ClearAllStatusConditions: +ClearAllStatusConditions:: push hl ldh a, [hWhoseTurn] ld h, a @@ -991,10 +991,10 @@ ClearAllStatusConditions: ; Removes a Pokemon card from the hand and places it in the arena or first available bench slot. ; If the Pokemon is placed in the arena, the status conditions of the player's arena card are zeroed. -; input: +; input:: ; a = deck index of the card ; return carry if there is no room for more Pokemon -PutHandPokemonCardInPlayArea: +PutHandPokemonCardInPlayArea:: push af ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA call GetTurnDuelistVariable @@ -1051,12 +1051,12 @@ PutHandPokemonCardInPlayArea: ; Removes a card from the hand and changes its location to arena or bench. Given that ; DUELVARS_ARENA_CARD or DUELVARS_BENCH aren't affected, this function is meant for energy and trainer cards. -; input: +; input:: ; a = deck index of the card ; e = play area location offset (PLAY_AREA_*) -; returns: +; returns:: ; a = CARD_LOCATION_PLAY_AREA + e -PutHandCardInPlayArea: +PutHandCardInPlayArea:: call RemoveCardFromHand call GetTurnDuelistVariable ld a, e @@ -1066,7 +1066,7 @@ PutHandCardInPlayArea: ; move the Pokemon card of the turn holder in the ; PLAY_AREA_* location given in e to the discard pile -MovePlayAreaCardToDiscardPile: +MovePlayAreaCardToDiscardPile:: call EmptyPlayAreaSlot ld l, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY_AREA dec [hl] @@ -1089,7 +1089,7 @@ MovePlayAreaCardToDiscardPile: ; init a turn holder's play area slot to empty ; which slot (arena or benchx) is determined by the play area location offset (PLAY_AREA_*) in e -EmptyPlayAreaSlot: +EmptyPlayAreaSlot:: ldh a, [hWhoseTurn] ld h, a ld d, -1 @@ -1112,7 +1112,7 @@ EmptyPlayAreaSlot: ret ; shift play area Pokemon of both players to the first available play area (arena + benchx) slots -ShiftAllPokemonToFirstPlayAreaSlots: +ShiftAllPokemonToFirstPlayAreaSlots:: call ShiftTurnPokemonToFirstPlayAreaSlots call SwapTurn call ShiftTurnPokemonToFirstPlayAreaSlots @@ -1120,7 +1120,7 @@ ShiftAllPokemonToFirstPlayAreaSlots: ret ; shift play area Pokemon of the turn holder to the first available play area (arena + benchx) slots -ShiftTurnPokemonToFirstPlayAreaSlots: +ShiftTurnPokemonToFirstPlayAreaSlots:: ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable lb de, PLAY_AREA_ARENA, PLAY_AREA_ARENA @@ -1141,7 +1141,7 @@ ShiftTurnPokemonToFirstPlayAreaSlots: ; data of the turn holder's Pokemon card in play area e. ; reset the status and all substatuses of the arena Pokemon before swapping. ; e is the play area location offset of the bench Pokemon (PLAY_AREA_*). -SwapArenaWithBenchPokemon: +SwapArenaWithBenchPokemon:: call ClearAllStatusConditions ld d, PLAY_AREA_ARENA ; fallthrough @@ -1149,7 +1149,7 @@ SwapArenaWithBenchPokemon: ; swap the data of the turn holder's Pokemon card in play area d with the ; data of the turn holder's Pokemon card in play area e. ; d and e are play area location offsets (PLAY_AREA_*). -SwapPlayAreaPokemon: +SwapPlayAreaPokemon:: push bc push de push hl @@ -1217,9 +1217,9 @@ SwapPlayAreaPokemon: ; Find which and how many energy cards are attached to the turn holder's Pokemon card in the arena, ; or a Pokemon card in the bench, depending on the value of register e. -; input: e = location to check, i.e. PLAY_AREA_* +; input:: e = location to check, i.e. PLAY_AREA_* ; Feedback is returned in wAttachedEnergies and wTotalAttachedEnergies. -GetPlayAreaCardAttachedEnergies: +GetPlayAreaCardAttachedEnergies:: push hl push de push bc @@ -1288,7 +1288,7 @@ GetPlayAreaCardAttachedEnergies: ; e = card id to search ; b = location to consider (CARD_LOCATION_*) ; h = PLAYER_TURN or OPPONENT_TURN -CountCardIDInLocation: +CountCardIDInLocation:: push bc ld l, DUELVARS_CARD_LOCATIONS ld c, $0 @@ -1314,7 +1314,7 @@ CountCardIDInLocation: ; returns [[hWhoseTurn] << 8 + a] in a and in [hl] ; i.e. duelvar a of the player whose turn it is -GetTurnDuelistVariable: +GetTurnDuelistVariable:: ld l, a ldh a, [hWhoseTurn] ld h, a @@ -1323,7 +1323,7 @@ GetTurnDuelistVariable: ; returns [([hWhoseTurn] ^ $1) << 8 + a] in a and in [hl] ; i.e. duelvar a of the player whose turn it is not -GetNonTurnDuelistVariable: +GetNonTurnDuelistVariable:: ld l, a ldh a, [hWhoseTurn] ld h, OPPONENT_TURN @@ -1337,7 +1337,7 @@ GetNonTurnDuelistVariable: ; when playing a Pokemon card, initializes some variables according to the ; card played, and checks if the played card has Pokemon Power to show it to ; the player, and possibly to use it if it triggers when the card is played. -Func_161e: +Func_161e:: ldh a, [hTempCardIndex_ff98] call ClearChangedTypesIfMuk ldh a, [hTempCardIndex_ff98] @@ -1408,12 +1408,12 @@ Func_161e: call TryExecuteEffectCommandFunction ret -; copies, given a card identified by register a (card ID): +; copies, given a card identified by register a (card ID):: ; - e into wSelectedAttack and d into hTempCardIndex_ff9f ; - Attack1 (if e == 0) or Attack2 (if e == 1) data into wLoadedAttack ; - Also from that attack, its Damage field into wDamage ; finally, clears wNoDamageOrEffect and wDealtDamage -CopyAttackDataAndDamage_FromCardID: +CopyAttackDataAndDamage_FromCardID:: push de push af ld a, e @@ -1427,12 +1427,12 @@ CopyAttackDataAndDamage_FromCardID: pop de jr CopyAttackDataAndDamage -; copies, given a card identified by register d (0-59 deck index): +; copies, given a card identified by register d (0-59 deck index):: ; - e into wSelectedAttack and d into hTempCardIndex_ff9f ; - Attack1 (if e == 0) or Attack2 (if e == 1) data into wLoadedAttack ; - Also from that attack, its Damage field into wDamage ; finally, clears wNoDamageOrEffect and wDealtDamage -CopyAttackDataAndDamage_FromDeckIndex: +CopyAttackDataAndDamage_FromDeckIndex:: ld a, e ld [wSelectedAttack], a ld a, d @@ -1440,7 +1440,7 @@ CopyAttackDataAndDamage_FromDeckIndex: call LoadCardDataToBuffer1_FromDeckIndex ; fallthrough -CopyAttackDataAndDamage: +CopyAttackDataAndDamage:: ld a, [wLoadedCard1ID] ld [wTempCardID_ccc2], a ld hl, wLoadedCard1Atk1 @@ -1471,7 +1471,7 @@ CopyAttackDataAndDamage: ; wTempNonTurnDuelistCardID to the non-turn holder's arena card, and zeroes other temp ; variables that only last between each two-player turn. ; this is called when a Pokemon card is played or when an attack is used -Func_16f6: +Func_16f6:: ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable ldh [hTempCardIndex_ff9f], a @@ -1497,7 +1497,7 @@ Func_16f6: ret ; Use an attack (from DuelMenu_Attack) or a Pokemon Power (from DuelMenu_PkmnPower) -UseAttackOrPokemonPower: +UseAttackOrPokemonPower:: ld a, [wSelectedAttack] ld [wPlayerAttackingAttackIndex], a ldh a, [hTempCardIndex_ff9f] @@ -1541,7 +1541,7 @@ UseAttackOrPokemonPower: call SetOppAction_SerialSendDuelData ; fallthrough -PlayAttackAnimation_DealAttackDamage: +PlayAttackAnimation_DealAttackDamage:: call Func_7415 ld a, [wLoadedAttackCategory] and RESIDUAL @@ -1583,7 +1583,7 @@ PlayAttackAnimation_DealAttackDamage: call PrintKnockedOutIfHLZero jr Func_17fb -Func_17ed: +Func_17ed:: call DrawWideTextBox_WaitForInput xor a ld hl, wDamage @@ -1593,7 +1593,7 @@ Func_17ed: ld [wNoDamageOrEffect], a ; fallthrough -Func_17fb: +Func_17fb:: ld a, [wTempNonTurnDuelistCardID] push af ld a, EFFECTCMDTYPE_AFTER_DAMAGE @@ -1608,28 +1608,28 @@ Func_17fb: or a ret -DisplayUsePokemonPowerScreen_WaitForInput: +DisplayUsePokemonPowerScreen_WaitForInput:: push hl call DisplayUsePokemonPowerScreen pop hl ; fallthrough -DrawWideTextBox_WaitForInput_ReturnCarry: +DrawWideTextBox_WaitForInput_ReturnCarry:: call DrawWideTextBox_WaitForInput ; fallthrough -ReturnCarry: +ReturnCarry:: scf ret -ClearNonTurnTemporaryDuelvars_ResetCarry: +ClearNonTurnTemporaryDuelvars_ResetCarry:: bank1call ClearNonTurnTemporaryDuelvars or a ret ; called when attacker deals damage to itself due to confusion ; display the corresponding animation and deal 20 damage to self -HandleConfusionDamageToSelf: +HandleConfusionDamageToSelf:: bank1call DrawDuelMainScene ld a, 1 ld [wIsDamageToSelf], a @@ -1646,7 +1646,7 @@ HandleConfusionDamageToSelf: ret ; use Pokemon Power -UsePokemonPower: +UsePokemonPower:: call Func_7415 ld a, EFFECTCMDTYPE_INITIAL_EFFECT_2 call TryExecuteEffectCommandFunction @@ -1668,7 +1668,7 @@ UsePokemonPower: ; called by UseAttackOrPokemonPower (on an attack only) ; in a link duel, it's used to send the other game data about the ; attack being in use, triggering a call to OppAction_BeginUseAttack in the receiver -SendAttackDataToLinkOpponent: +SendAttackDataToLinkOpponent:: ld a, [wccec] or a ret nz @@ -1691,7 +1691,7 @@ SendAttackDataToLinkOpponent: ldh [hTemp_ffa0], a ret -Func_189d: +Func_189d:: ld a, [wLoadedAttackCategory] bit RESIDUAL_F, a ret nz @@ -1725,7 +1725,7 @@ Func_189d: ret ; return carry and 1 into wGotHeadsFromConfusionCheck if damage will be dealt to oneself due to confusion -CheckSelfConfusionDamage: +CheckSelfConfusionDamage:: xor a ld [wGotHeadsFromConfusionCheck], a ld a, DUELVARS_ARENA_CARD_STATUS @@ -1750,7 +1750,7 @@ CheckSelfConfusionDamage: ; play the trainer card with deck index at hTempCardIndex_ff98. ; a trainer card is like an attack effect, with its own effect commands. ; return nc if the card was played, carry if it wasn't. -PlayTrainerCard: +PlayTrainerCard:: call CheckCantUseTrainerDueToHeadache jr c, .cant_use ldh a, [hWhoseTurn] @@ -1790,7 +1790,7 @@ PlayTrainerCard: ; loads the effect commands of a (trainer or energy) card with deck index (0-59) at hTempCardIndex_ff9f ; into wLoadedAttackEffectCommands. in practice, only used for trainer cards -LoadNonPokemonCardEffectCommands: +LoadNonPokemonCardEffectCommands:: ldh a, [hTempCardIndex_ff9f] call LoadCardDataToBuffer1_FromDeckIndex ld hl, wLoadedCard1EffectCommands @@ -1804,7 +1804,7 @@ LoadNonPokemonCardEffectCommands: ; Make turn holder deal A damage to self due to recoil (e.g. Thrash, Selfdestruct) ; display recoil animation -DealRecoilDamageToSelf: +DealRecoilDamageToSelf:: push af ld a, ATK_ANIM_RECOIL_HIT ld [wLoadedAttackAnimation], a @@ -1813,7 +1813,7 @@ DealRecoilDamageToSelf: ; Make turn holder deal A damage to self due to confusion ; display animation at wLoadedAttackAnimation -DealConfusionDamageToSelf: +DealConfusionDamageToSelf:: ld hl, wDamage ld [hli], a ld [hl], 0 @@ -1840,12 +1840,12 @@ DealConfusionDamageToSelf: ld [wNoDamageOrEffect], a ret -; given a damage value at wDamage: -; - if the non-turn holder's arena card is weak to the turn holder's arena card color: double damage -; - if the non-turn holder's arena card resists the turn holder's arena card color: reduce damage by 30 +; given a damage value at wDamage:: +; - if the non-turn holder's arena card is weak to the turn holder's arena card color:: double damage +; - if the non-turn holder's arena card resists the turn holder's arena card color:: reduce damage by 30 ; - also apply Pluspower, Defender, and other kinds of damage reduction accordingly ; return resulting damage in de -ApplyDamageModifiers_DamageToTarget: +ApplyDamageModifiers_DamageToTarget:: xor a ld [wDamageEffectiveness], a ld hl, wDamage @@ -1912,7 +1912,7 @@ ApplyDamageModifiers_DamageToTarget: ret ; convert a color to its equivalent WR_* (weakness/resistance) value -TranslateColorToWR: +TranslateColorToWR:: push hl add LOW(InvertedPowersOf2) ld l, a @@ -1923,14 +1923,14 @@ TranslateColorToWR: pop hl ret -InvertedPowersOf2: +InvertedPowersOf2:: db $80, $40, $20, $10, $08, $04, $02, $01 -; given a damage value at wDamage: -; - if the turn holder's arena card is weak to its own color: double damage -; - if the turn holder's arena card resists its own color: reduce damage by 30 +; given a damage value at wDamage:: +; - if the turn holder's arena card is weak to its own color:: double damage +; - if the turn holder's arena card resists its own color:: reduce damage by 30 ; return resulting damage in de -ApplyDamageModifiers_DamageToSelf: +ApplyDamageModifiers_DamageToSelf:: xor a ld [wDamageEffectiveness], a ld hl, wDamage @@ -1973,7 +1973,7 @@ ApplyDamageModifiers_DamageToSelf: ret ; increases de by 10 points for each Pluspower found in location b -ApplyAttachedPluspower: +ApplyAttachedPluspower:: push de call GetTurnDuelistVariable ld de, PLUSPOWER @@ -1988,7 +1988,7 @@ ApplyAttachedPluspower: ret ; reduces de by 20 points for each Defender found in location b -ApplyAttachedDefender: +ApplyAttachedDefender:: push de call GetTurnDuelistVariable ld de, DEFENDER @@ -2005,10 +2005,10 @@ ApplyAttachedDefender: ld d, a ret -; hl: address to subtract HP from -; de: how much HP to subtract (damage to deal) +; hl:: address to subtract HP from +; de:: how much HP to subtract (damage to deal) ; returns carry if the HP does not become 0 as a result -SubtractHP: +SubtractHP:: push hl push de ld a, [hl] @@ -2031,7 +2031,7 @@ SubtractHP: ; given a play area location offset in a, check if the turn holder's Pokemon card in ; that location has no HP left, and, if so, print that it was knocked out. -PrintPlayAreaCardKnockedOutIfNoHP: +PrintPlayAreaCardKnockedOutIfNoHP:: ld e, a add DUELVARS_ARENA_CARD_HP call GetTurnDuelistVariable @@ -2051,7 +2051,7 @@ PrintPlayAreaCardKnockedOutIfNoHP: scf ret -PrintKnockedOutIfHLZero: +PrintKnockedOutIfHLZero:: ld a, [hl] ; this is supposed to point to a remaining HP value after some form of damage calculation or a ret nz @@ -2059,7 +2059,7 @@ PrintKnockedOutIfHLZero: ; print in a text box that the Pokemon card at wTempNonTurnDuelistCardID ; was knocked out and wait 40 frames -PrintKnockedOut: +PrintKnockedOut:: ld a, [wTempNonTurnDuelistCardID] ld e, a call LoadCardDataToBuffer1_FromCardID @@ -2082,7 +2082,7 @@ PrintKnockedOut: ; damage to deal is given in de. ; shows the defending player's play area screen when dealing the damage ; instead of the main duel interface with regular attack animation. -DealDamageToPlayAreaPokemon_RegularAnim: +DealDamageToPlayAreaPokemon_RegularAnim:: ld a, ATK_ANIM_BENCH_HIT ld [wLoadedAttackAnimation], a ; fallthrough @@ -2092,7 +2092,7 @@ DealDamageToPlayAreaPokemon_RegularAnim: ; shows the defending player's play area screen when dealing the damage ; instead of the main duel interface. ; plays animation that is loaded in wLoadedAttackAnimation. -DealDamageToPlayAreaPokemon: +DealDamageToPlayAreaPokemon:: ld a, b ld [wTempPlayAreaLocation_cceb], a or a ; cp PLAY_AREA_ARENA @@ -2184,14 +2184,14 @@ DealDamageToPlayAreaPokemon: ; draw duel main scene, then print the "'s " text ; The Pokemon's name is the turn holder's arena Pokemon, and the ; attack's name is taken from wLoadedAttackName. -DrawDuelMainScene_PrintPokemonsAttackText: +DrawDuelMainScene_PrintPokemonsAttackText:: bank1call DrawDuelMainScene ; fallthrough ; print the "'s " text ; The Pokemon's name is the turn holder's arena Pokemon, and the ; attack's name is taken from wLoadedAttackName. -PrintPokemonsAttackText: +PrintPokemonsAttackText:: ld a, DUELVARS_ARENA_CARD call GetTurnDuelistVariable call LoadCardDataToBuffer1_FromDeckIndex @@ -2211,7 +2211,7 @@ PrintPokemonsAttackText: call DrawWideTextBox_PrintText ret -Func_1bb4: +Func_1bb4:: call Func_3b31 bank1call DrawDuelMainScene call DrawDuelHUDs @@ -2224,7 +2224,7 @@ Func_1bb4: ; prints one of the ThereWasNoEffectFrom*Text if wEffectFailed contains EFFECT_FAILED_NO_EFFECT, ; and prints WasUnsuccessfulText if wEffectFailed contains EFFECT_FAILED_UNSUCCESSFUL -Func_1bca: +Func_1bca:: ld a, [wEffectFailed] or a ret z @@ -2259,7 +2259,7 @@ Func_1bca: ; return in a the retreat cost of the turn holder's arena or bench Pokemon ; given the PLAY_AREA_* value in hTempPlayAreaLocation_ff9d -GetPlayAreaCardRetreatCost: +GetPlayAreaCardRetreatCost:: ldh a, [hTempPlayAreaLocation_ff9d] add DUELVARS_ARENA_CARD call GetTurnDuelistVariable @@ -2269,7 +2269,7 @@ GetPlayAreaCardRetreatCost: ; move the turn holder's card with ID at de to the discard pile ; if it's currently in the arena. -MoveCardToDiscardPileIfInArena: +MoveCardToDiscardPileIfInArena:: ld c, e ld b, d ld l, DUELVARS_CARD_LOCATIONS @@ -2297,12 +2297,12 @@ MoveCardToDiscardPileIfInArena: ret ; calculate damage and max HP of card at PLAY_AREA_* in e. -; input: +; input:: ; e = PLAY_AREA_* of card; -; output: +; output:: ; a = damage; ; c = max HP. -GetCardDamageAndMaxHP: +GetCardDamageAndMaxHP:: push hl push de ld a, DUELVARS_ARENA_CARD @@ -2322,12 +2322,12 @@ GetCardDamageAndMaxHP: ret ; check if a flag of wLoadedAttack is set -; input: +; input:: ; a = %fffffbbb, where ; fffff = flag address counting from wLoadedAttackFlag1 ; bbb = flag bit ; return carry if the flag is set -CheckLoadedAttackFlag: +CheckLoadedAttackFlag:: push hl push de push bc @@ -2360,7 +2360,7 @@ CheckLoadedAttackFlag: ; As a side effect, this also returns a duelist variable in a similar manner to ; GetNonTurnDuelistVariable, but this function appears to be ; only called to swap the turn value. -SwapTurn: +SwapTurn:: push af push hl call GetNonTurnDuelistVariable @@ -2371,7 +2371,7 @@ SwapTurn: ret ; copy the TX_END-terminated player's name from sPlayerName to de -CopyPlayerName: +CopyPlayerName:: call EnableSRAM ld hl, sPlayerName .loop @@ -2388,7 +2388,7 @@ CopyPlayerName: ; if text ID at wOpponentName is non-0, copy it from there ; else, if text at wc500 is non-0, copy if from there ; else, copy Player2Text -CopyOpponentName: +CopyOpponentName:: ld hl, wOpponentName ld a, [hli] or [hl] diff --git a/src/home/duel_menus.asm b/src/home/duel_menus.asm index 62f1ad15..194b6fa7 100644 --- a/src/home/duel_menus.asm +++ b/src/home/duel_menus.asm @@ -1,4 +1,4 @@ -OpenDuelCheckMenu: +OpenDuelCheckMenu:: ldh a, [hBankROM] push af ld a, BANK(_OpenDuelCheckMenu) @@ -8,7 +8,7 @@ OpenDuelCheckMenu: call BankswitchROM ret -OpenInPlayAreaScreen_FromSelectButton: +OpenInPlayAreaScreen_FromSelectButton:: ldh a, [hBankROM] push af ld a, BANK(OpenInPlayAreaScreen) @@ -23,11 +23,11 @@ OpenInPlayAreaScreen_FromSelectButton: ; loads tiles and icons to display Your Play Area / Opp. Play Area screen, ; and draws the screen according to the turn player -; input: h -> [wCheckMenuPlayAreaWhichDuelist] and l -> [wCheckMenuPlayAreaWhichLayout] +; input:: h -> [wCheckMenuPlayAreaWhichDuelist] and l -> [wCheckMenuPlayAreaWhichLayout] ; similar to DrawYourOrOppPlayArea (bank 2) except it also draws a wide text box. ; this is because bank 2's DrawYourOrOppPlayArea is supposed to come from the Check Menu, ; so the text box is always already there. -DrawYourOrOppPlayAreaScreen_Bank0: +DrawYourOrOppPlayAreaScreen_Bank0:: ld a, h ld [wCheckMenuPlayAreaWhichDuelist], a ld a, l @@ -42,7 +42,7 @@ DrawYourOrOppPlayAreaScreen_Bank0: call BankswitchROM ret -DrawPlayersPrizeAndBenchCards: +DrawPlayersPrizeAndBenchCards:: ldh a, [hBankROM] push af ld a, BANK(_DrawPlayersPrizeAndBenchCards) @@ -52,7 +52,7 @@ DrawPlayersPrizeAndBenchCards: call BankswitchROM ret -HandlePeekSelection: +HandlePeekSelection:: ldh a, [hBankROM] push af ld a, BANK(_HandlePeekSelection) @@ -64,7 +64,7 @@ HandlePeekSelection: ld a, b ret -DrawAIPeekScreen: +DrawAIPeekScreen:: ld b, a ldh a, [hBankROM] push af @@ -76,7 +76,7 @@ DrawAIPeekScreen: ret ; a = number of prize cards for player to select to take -SelectPrizeCards: +SelectPrizeCards:: ld [wNumberOfPrizeCardsToSelect], a ldh a, [hBankROM] push af @@ -87,7 +87,7 @@ SelectPrizeCards: call BankswitchROM ret -DrawPlayAreaToPlacePrizeCards: +DrawPlayAreaToPlacePrizeCards:: ldh a, [hBankROM] push af ld a, BANK(_DrawPlayAreaToPlacePrizeCards) diff --git a/src/home/effect_commands.asm b/src/home/effect_commands.asm index 9446d33b..ace8fc0e 100644 --- a/src/home/effect_commands.asm +++ b/src/home/effect_commands.asm @@ -1,9 +1,9 @@ ; Checks if the command type at a is one of the commands of the attack or ; card effect currently in use, and executes its associated function if so. -; input: +; input:: ; a = command type to check ; [wLoadedAttackEffectCommands] = pointer to list of commands of current attack or trainer card -TryExecuteEffectCommandFunction: +TryExecuteEffectCommandFunction:: push af ; grab pointer to command list from wLoadedAttackEffectCommands ld hl, wLoadedAttackEffectCommands @@ -18,7 +18,7 @@ TryExecuteEffectCommandFunction: ret .execute_function - ; execute the function at [wEffectFunctionsBank]:hl + ; execute the function at [wEffectFunctionsBank]::hl ldh a, [hBankROM] push af ld a, [wEffectFunctionsBank] @@ -34,11 +34,11 @@ TryExecuteEffectCommandFunction: pop af ret -; input: +; input:: ; a = command type to check ; hl = list of commands of current attack or trainer card ; return nc if command type matching a is found, carry otherwise -CheckMatchingCommand: +CheckMatchingCommand:: ld c, a ld a, l or h diff --git a/src/home/empty_screen.asm b/src/home/empty_screen.asm index 6eeea50f..5da058ee 100644 --- a/src/home/empty_screen.asm +++ b/src/home/empty_screen.asm @@ -1,5 +1,5 @@ ; initialize the screen by emptying the tilemap. used during screen transitions -EmptyScreen: +EmptyScreen:: call DisableLCD call FillTileMap xor a @@ -13,7 +13,7 @@ EmptyScreen: call DisableLCD ret -AttrBlkPacket_EmptyScreen: +AttrBlkPacket_EmptyScreen:: sgb ATTR_BLK, 1 ; sgb_command, length db 1 ; number of data sets ; Control Code, Color Palette Designation, X1, Y1, X2, Y2 @@ -23,7 +23,7 @@ AttrBlkPacket_EmptyScreen: ; returns v*BGMap0 + BG_MAP_WIDTH * c + b in de. ; used to map coordinates at bc to a BGMap0 address. -BCCoordToBGMap0Address: +BCCoordToBGMap0Address:: ld l, c ld h, $0 add hl, hl diff --git a/src/home/farcall.asm b/src/home/farcall.asm index 1fc4ee88..d28197d7 100644 --- a/src/home/farcall.asm +++ b/src/home/farcall.asm @@ -1,7 +1,7 @@ ; RST18 ; this function affects the stack so that it returns to the pointer following ; the rst call. similar to rst 28, except this always loads bank 1 -Bank1Call: +Bank1Call:: push hl push hl push hl @@ -30,7 +30,7 @@ Bank1Call: ld a, $1 ; fallthrough -Bank1Call_FarCall_Common: +Bank1Call_FarCall_Common:: call BankswitchROM ld hl, sp+$d inc de @@ -44,7 +44,7 @@ Bank1Call_FarCall_Common: ret ; switch to the ROM bank at sp+4 -SwitchToBankAtSP: ; 9dc (0:9dc) +SwitchToBankAtSP:: ; 9dc (0::9dc) push af push hl ld hl, sp+$04 @@ -59,7 +59,7 @@ SwitchToBankAtSP: ; 9dc (0:9dc) ; RST28 ; this function affects the stack so that it returns ; to the three byte pointer following the rst call -FarCall: +FarCall:: push hl push hl push hl diff --git a/src/home/frames.asm b/src/home/frames.asm index c32053d9..4bb06295 100644 --- a/src/home/frames.asm +++ b/src/home/frames.asm @@ -1,5 +1,5 @@ ; calls DoFrame a times -DoAFrames: +DoAFrames:: .loop push af call DoFrame @@ -10,7 +10,7 @@ DoAFrames: ; updates background, sprites and other game variables, halts until vblank, and reads user input ; if wDebugPauseAllowed is not 0, the game can be paused (and resumed) by pressing the SELECT button -DoFrame: +DoFrame:: push af push hl push de @@ -42,7 +42,7 @@ DoFrame: ; handle D-pad repeat counter ; used to quickly scroll through menus when a relevant D-pad key is held -HandleDPadRepeat: +HandleDPadRepeat:: ldh a, [hKeysHeld] ldh [hDPadHeld], a and D_PAD diff --git a/src/home/hblank.asm b/src/home/hblank.asm index acf2eaa1..2f38734e 100644 --- a/src/home/hblank.asm +++ b/src/home/hblank.asm @@ -1,5 +1,5 @@ ; copy b bytes of data from hl to de, but only during hblank -HblankCopyDataHLtoDE: +HblankCopyDataHLtoDE:: push bc .loop ei @@ -21,7 +21,7 @@ HblankCopyDataHLtoDE: ret ; copy c bytes of data from de to hl, but only during hblank -HblankCopyDataDEtoHL: +HblankCopyDataDEtoHL:: push bc .loop ei diff --git a/src/home/input.asm b/src/home/input.asm index 28e2e713..851369ea 100644 --- a/src/home/input.asm +++ b/src/home/input.asm @@ -1,6 +1,6 @@ ; read joypad data to refresh hKeysHeld, hKeysPressed, and hKeysReleased ; the A + B + Start + Select combination resets the game -ReadJoypad: +ReadJoypad:: ld a, JOY_BTNS_SELECT ldh [rJOYP], a ldh a, [rJOYP] @@ -36,16 +36,16 @@ ReadJoypad: and BUTTONS cp BUTTONS jr nz, SaveButtonsHeld - ; A + B + Start + Select: reset game + ; A + B + Start + Select:: reset game call ResetSerial ; fallthrough -Reset: +Reset:: ld a, [wInitialA] di jp Start -SaveButtonsHeld: +SaveButtonsHeld:: ld a, c ldh [hKeysHeld], a ld a, JOY_BTNS_SELECT | JOY_DPAD_SELECT @@ -53,7 +53,7 @@ SaveButtonsHeld: ret ; clear joypad hmem data -ClearJoypad: +ClearJoypad:: push hl ld hl, hDPadRepeat xor a diff --git a/src/home/interrupt.asm b/src/home/interrupt.asm index 19709c6a..34f80855 100644 --- a/src/home/interrupt.asm +++ b/src/home/interrupt.asm @@ -1,19 +1,19 @@ ; enable timer interrupt -EnableInt_Timer: +EnableInt_Timer:: ldh a, [rIE] or 1 << INT_TIMER ldh [rIE], a ret ; enable vblank interrupt -EnableInt_VBlank: +EnableInt_VBlank:: ldh a, [rIE] or 1 << INT_VBLANK ldh [rIE], a ret ; enable lcdc interrupt on hblank mode -EnableInt_HBlank: +EnableInt_HBlank:: ldh a, [rSTAT] or 1 << STAT_MODE_HBLANK ldh [rSTAT], a @@ -25,7 +25,7 @@ EnableInt_HBlank: ret ; disable lcdc interrupt and the hblank mode trigger -DisableInt_HBlank: +DisableInt_HBlank:: ldh a, [rSTAT] and ~(1 << STAT_MODE_HBLANK) ldh [rSTAT], a diff --git a/src/home/jumptable.asm b/src/home/jumptable.asm index c5df987c..3140fcdf 100644 --- a/src/home/jumptable.asm +++ b/src/home/jumptable.asm @@ -1,5 +1,5 @@ ; jumps to index a in pointer table hl -JumpToFunctionInTable: +JumpToFunctionInTable:: add a add l ld l, a @@ -12,7 +12,7 @@ JumpToFunctionInTable: jp hl ; call function at [hl] if non-NULL -CallIndirect: +CallIndirect:: push af ld a, [hli] or [hl] @@ -26,5 +26,5 @@ CallIndirect: pop af ; fallthrough -CallHL: +CallHL:: jp hl diff --git a/src/home/lcd.asm b/src/home/lcd.asm index 415aea05..74dc7a73 100644 --- a/src/home/lcd.asm +++ b/src/home/lcd.asm @@ -1,5 +1,5 @@ ; wait for VBlankHandler to finish unless lcd is off -WaitForVBlank: +WaitForVBlank:: push hl ld a, [wLCDC] bit LCDC_ENABLE_F, a @@ -16,7 +16,7 @@ WaitForVBlank: ret ; turn LCD on -EnableLCD: +EnableLCD:: ld a, [wLCDC] ; bit LCDC_ENABLE_F, a ; ret nz ; assert that LCD is off @@ -28,7 +28,7 @@ EnableLCD: ret ; wait for vblank, then turn LCD off -DisableLCD: +DisableLCD:: ldh a, [rLCDC] ; bit LCDC_ENABLE_F, a ; ret z ; assert that LCD is on @@ -54,29 +54,29 @@ DisableLCD: ldh [rIE], a ret -; set OBJ size: 8x8 -Set_OBJ_8x8: +; set OBJ size:: 8x8 +Set_OBJ_8x8:: ld a, [wLCDC] and LCDC_OBJ8 ld [wLCDC], a ret -; set OBJ size: 8x16 -Set_OBJ_8x16: +; set OBJ size:: 8x16 +Set_OBJ_8x16:: ld a, [wLCDC] or LCDC_OBJ16 ld [wLCDC], a ret ; set Window Display on -SetWindowOn: +SetWindowOn:: ld a, [wLCDC] or LCDC_WINON ld [wLCDC], a ret ; set Window Display off -SetWindowOff: +SetWindowOff:: ld a, [wLCDC] and LCDC_WINOFF ld [wLCDC], a diff --git a/src/home/lcd_enable_frame.asm b/src/home/lcd_enable_frame.asm index 01274957..7b6b47e2 100644 --- a/src/home/lcd_enable_frame.asm +++ b/src/home/lcd_enable_frame.asm @@ -1,4 +1,4 @@ -DoFrameIfLCDEnabled: +DoFrameIfLCDEnabled:: push af ldh a, [rLCDC] bit LCDC_ENABLE_F, a diff --git a/src/home/list.asm b/src/home/list.asm index 70bf11f6..d42d6bb8 100644 --- a/src/home/list.asm +++ b/src/home/list.asm @@ -1,5 +1,5 @@ ; Save a pointer to a list, given at de, to wListPointer -SetListPointer: +SetListPointer:: push hl ld hl, wListPointer ld [hl], e @@ -10,7 +10,7 @@ SetListPointer: ; Return the current element of the list at wListPointer, ; and advance the list to the next element -GetNextElementOfList: +GetNextElementOfList:: push hl push de ld hl, wListPointer @@ -21,7 +21,7 @@ GetNextElementOfList: inc de ; fallthrough -SetListToNextPosition: +SetListToNextPosition:: ld [hl], d dec hl ld [hl], e @@ -31,7 +31,7 @@ SetListToNextPosition: ; Set the current element of the list at wListPointer to a, ; and advance the list to the next element -SetNextElementOfList: +SetNextElementOfList:: push hl push de ld hl, wListPointer diff --git a/src/home/load_animation.asm b/src/home/load_animation.asm index 777fc3f2..f5231b01 100644 --- a/src/home/load_animation.asm +++ b/src/home/load_animation.asm @@ -1,10 +1,10 @@ ; clear [SOMETHING] - something relating to animations -Func_3ca0: +Func_3ca0:: xor a ld [wd5d7], a ; fallthrough -Func_3ca4: +Func_3ca4:: ldh a, [hBankROM] push af ld a, BANK(Func_1296e) @@ -14,7 +14,7 @@ Func_3ca4: call BankswitchROM ret -HandleAllSpriteAnimations: +HandleAllSpriteAnimations:: ldh a, [hBankROM] push af ld a, BANK(_HandleAllSpriteAnimations) @@ -26,7 +26,7 @@ HandleAllSpriteAnimations: ; hl - pointer to animation frame ; wd5d6 - bank of animation frame -DrawSpriteAnimationFrame: +DrawSpriteAnimationFrame:: ldh a, [hBankROM] push af ld a, [wd5d6] @@ -143,7 +143,7 @@ DrawSpriteAnimationFrame: ; the current frame's offset ; [wd4ca] - current frame offset ; wTempPointer* - Pointer to current Animation -GetAnimationFramePointer: +GetAnimationFramePointer:: ldh a, [hBankROM] push af push hl @@ -194,7 +194,7 @@ GetAnimationFramePointer: ; return hl pointing to the start of a sprite in wSpriteAnimBuffer. ; the sprite is identified by its index in wWhichSprite. -GetFirstSpriteAnimBufferProperty: +GetFirstSpriteAnimBufferProperty:: push bc ld c, SPRITE_ANIM_ENABLED call GetSpriteAnimBufferProperty @@ -203,11 +203,11 @@ GetFirstSpriteAnimBufferProperty: ; return hl pointing to the property (byte) c of a sprite in wSpriteAnimBuffer. ; the sprite is identified by its index in wWhichSprite. -GetSpriteAnimBufferProperty: +GetSpriteAnimBufferProperty:: ld a, [wWhichSprite] ; fallthrough -GetSpriteAnimBufferProperty_SpriteInA: +GetSpriteAnimBufferProperty_SpriteInA:: cp SPRITE_ANIM_BUFFER_CAPACITY jr c, .got_sprite debug_nop @@ -227,7 +227,7 @@ GetSpriteAnimBufferProperty_SpriteInA: pop bc ret -Func_3ddb: +Func_3ddb:: push hl push bc ld c, SPRITE_ANIM_FLAGS @@ -237,7 +237,7 @@ Func_3ddb: pop hl ret -Func_3de7: +Func_3de7:: push hl push bc ld c, SPRITE_ANIM_FLAGS @@ -247,7 +247,7 @@ Func_3de7: pop hl ret -LoadScene: +LoadScene:: push af ldh a, [hBankROM] push af @@ -266,13 +266,13 @@ LoadScene: ret ; draws player's portrait at b,c -DrawPlayerPortrait: +DrawPlayerPortrait:: ld a, $1 ld [wd61e], a ld a, TILEMAP_PLAYER ; fallthrough -DrawPortrait: +DrawPortrait:: ld [wCurTilemap], a ldh a, [hBankROM] push af @@ -284,12 +284,12 @@ DrawPortrait: ret ; draws opponent's portrait given in a at b,c -DrawOpponentPortrait: +DrawOpponentPortrait:: ld [wd61e], a ld a, TILEMAP_OPPONENT jr DrawPortrait -Func_3e31: +Func_3e31:: ldh a, [hBankROM] push af call HandleAllSpriteAnimations diff --git a/src/home/load_deck.asm b/src/home/load_deck.asm index b1c7f74a..b35a3f1e 100644 --- a/src/home/load_deck.asm +++ b/src/home/load_deck.asm @@ -1,7 +1,7 @@ ; loads the deck id in a from DeckPointers and copies it to wPlayerDeck or to ; wOpponentDeck, depending on whose turn it is. ; sets carry flag if an invalid deck id is used. -LoadDeck: +LoadDeck:: push hl ld l, a ld h, $0 diff --git a/src/home/map.asm b/src/home/map.asm index 0fd543f0..44e81e01 100644 --- a/src/home/map.asm +++ b/src/home/map.asm @@ -1,5 +1,5 @@ -OverworldDoFrameFunction: +OverworldDoFrameFunction:: ld a, [wOverworldNPCFlags] bit HIDE_ALL_NPC_SPRITES, a ret nz @@ -23,7 +23,7 @@ OverworldDoFrameFunction: ; enable the play time counter and execute the game event at [wGameEvent]. ; then return to the overworld, or restart the game (only after Credits). -ExecuteGameEvent: +ExecuteGameEvent:: ld a, 1 ld [wPlayTimeCounterEnable], a ldh a, [hBankROM] @@ -39,7 +39,7 @@ ExecuteGameEvent: ret ; execute a game event at [wGameEvent] from GameEventPointerTable -_ExecuteGameEvent: +_ExecuteGameEvent:: ld a, [wGameEvent] cp NUM_GAME_EVENTS jr c, .got_game_event @@ -48,7 +48,7 @@ _ExecuteGameEvent: ld hl, GameEventPointerTable jp JumpToFunctionInTable -GameEventPointerTable: +GameEventPointerTable:: dw GameEvent_Overworld dw GameEvent_Duel dw GameEvent_BattleCenter @@ -58,11 +58,11 @@ GameEventPointerTable: dw GameEvent_ChallengeMachine dw GameEvent_Overworld -GameEvent_Overworld: +GameEvent_Overworld:: scf ret -GameEvent_GiftCenter: +GameEvent_GiftCenter:: ldh a, [hBankROM] push af call PauseSong @@ -83,7 +83,7 @@ GameEvent_GiftCenter: scf ret -GameEvent_BattleCenter: +GameEvent_BattleCenter:: ld a, GAME_EVENT_BATTLE_CENTER ld [wActiveGameEvent], a xor a @@ -98,7 +98,7 @@ GameEvent_BattleCenter: scf ret -GameEvent_Duel: +GameEvent_Duel:: ld a, GAME_EVENT_DUEL ld [wActiveGameEvent], a xor a @@ -112,7 +112,7 @@ GameEvent_Duel: scf ret -GameEvent_ChallengeMachine: +GameEvent_ChallengeMachine:: ld a, MUSIC_PC_MAIN_MENU ld [wDefaultSong], a call PlayDefaultSong @@ -128,7 +128,7 @@ GameEvent_ChallengeMachine: scf ret -GameEvent_ContinueDuel: +GameEvent_ContinueDuel:: xor a ld [wSongOverride], a bank1call TryContinueDuel @@ -140,12 +140,12 @@ GameEvent_ContinueDuel: scf ret -GameEvent_Credits: +GameEvent_Credits:: farcall PlayCreditsSequence or a ret -GetReceivedLegendaryCards: +GetReceivedLegendaryCards:: ld a, EVENT_RECEIVED_LEGENDARY_CARDS farcall GetEventValue call EnableSRAM @@ -154,7 +154,7 @@ GetReceivedLegendaryCards: ret ; return in a the permission byte corresponding to the current map's x,y coordinates at bc -GetPermissionOfMapPosition: +GetPermissionOfMapPosition:: push hl call GetPermissionByteOfMapPosition ld a, [hl] @@ -162,7 +162,7 @@ GetPermissionOfMapPosition: ret ; set to a the permission byte corresponding to the current map's x,y coordinates at bc -SetPermissionOfMapPosition: +SetPermissionOfMapPosition:: push hl push af call GetPermissionByteOfMapPosition @@ -173,7 +173,7 @@ SetPermissionOfMapPosition: ; set the permission byte corresponding to the current map's x,y coordinates at bc ; to the value of register a anded by its current value -UpdatePermissionOfMapPosition: +UpdatePermissionOfMapPosition:: push hl push bc push de @@ -190,7 +190,7 @@ UpdatePermissionOfMapPosition: ; returns in hl the address within wPermissionMap that corresponds to ; the current map's x,y coordinates at bc -GetPermissionByteOfMapPosition: +GetPermissionByteOfMapPosition:: push bc srl b srl c @@ -206,7 +206,7 @@ GetPermissionByteOfMapPosition: ret ; copy c bytes of data from hl in bank wTempPointerBank to de, b times. -CopyGfxDataFromTempBank: +CopyGfxDataFromTempBank:: ldh a, [hBankROM] push af ld a, [wTempPointerBank] @@ -217,20 +217,20 @@ CopyGfxDataFromTempBank: ret ; Movement offsets for player movements -PlayerMovementOffsetTable: +PlayerMovementOffsetTable:: db 0, -1 ; NORTH db 1, 0 ; EAST db 0, 1 ; SOUTH db -1, 0 ; WEST ; Movement offsets for player movements, in tiles -PlayerMovementOffsetTable_Tiles: +PlayerMovementOffsetTable_Tiles:: db 0, -2 ; NORTH db 2, 0 ; EAST db 0, 2 ; SOUTH db -2, 0 ; WEST -OverworldMapNames: +OverworldMapNames:: table_width 2, OverworldMapNames tx OverworldMapMasonLaboratoryText tx OverworldMapMasonLaboratoryText @@ -248,7 +248,7 @@ OverworldMapNames: tx OverworldMapMysteryHouseText assert_table_length NUM_OWMAP_NAMES -Func_3997: +Func_3997:: ldh a, [hBankROM] push af ld a, BANK(Func_1c056) @@ -259,13 +259,13 @@ Func_3997: ret ; returns in hl a pointer to the first element for the a'th NPC -GetLoadedNPCID: +GetLoadedNPCID:: ld l, LOADED_NPC_ID call GetItemInLoadedNPCIndex ret ; return in hl a pointer to the a'th items element l -GetItemInLoadedNPCIndex: +GetItemInLoadedNPCIndex:: push bc cp LOADED_NPC_MAX jr c, .asm_39b4 @@ -288,7 +288,7 @@ GetItemInLoadedNPCIndex: ; Finds the index on wLoadedNPCs table of the npc in wTempNPC ; returns it in a and puts it into wLoadedNPCTempIndex ; c flag set if no npc found -FindLoadedNPC: +FindLoadedNPC:: push hl push bc push de @@ -318,7 +318,7 @@ FindLoadedNPC: pop hl ret -GetNextNPCMovementByte: +GetNextNPCMovementByte:: push bc ldh a, [hBankROM] push af @@ -332,7 +332,7 @@ GetNextNPCMovementByte: pop bc ret -PlayDefaultSong: +PlayDefaultSong:: push hl push bc call AssertSongFinished @@ -358,7 +358,7 @@ PlayDefaultSong: ret ; returns [wDefaultSong] or MUSIC_RONALD in a -GetDefaultSong: +GetDefaultSong:: ld a, [wRonaldIsInMap] or a jr z, .default_song diff --git a/src/home/math.asm b/src/home/math.asm index 8e54cb80..f2939297 100644 --- a/src/home/math.asm +++ b/src/home/math.asm @@ -1,5 +1,5 @@ ; returns a *= 10 -ATimes10: +ATimes10:: push de ld e, a add a @@ -10,7 +10,7 @@ ATimes10: ret ; returns hl *= 10 -HLTimes10: +HLTimes10:: push de ld l, a ld e, a @@ -25,7 +25,7 @@ HLTimes10: ; returns a /= 10 ; returns carry if a % 10 >= 5 -ADividedBy10: +ADividedBy10:: push de ld e, -1 .asm_c62 diff --git a/src/home/memory.asm b/src/home/memory.asm index c5c33176..2814018d 100644 --- a/src/home/memory.asm +++ b/src/home/memory.asm @@ -1,9 +1,9 @@ ; decompresses data from a given bank ; uses values initialized by InitDataDecompression -; input: +; input:: ; bc = row width ; de = buffer to place decompressed data -DecompressDataFromBank: +DecompressDataFromBank:: ldh a, [hBankROM] push af ld a, [wTempPointerBank] @@ -14,7 +14,7 @@ DecompressDataFromBank: ret ; Copies bc bytes from [wTempPointer] to de -CopyBankedDataToDE: +CopyBankedDataToDE:: ldh a, [hBankROM] push af push hl @@ -31,7 +31,7 @@ CopyBankedDataToDE: ret ; fill bc bytes of data at hl with a -FillMemoryWithA: +FillMemoryWithA:: push hl push de push bc @@ -49,7 +49,7 @@ FillMemoryWithA: ret ; fill 2*bc bytes of data at hl with d,e -FillMemoryWithDE: +FillMemoryWithDE:: push hl push bc .loop @@ -65,8 +65,8 @@ FillMemoryWithDE: pop hl ret -; gets far byte a:hl, outputs value in a -GetFarByte: +; gets far byte a::hl, outputs value in a +GetFarByte:: push hl push af ldh a, [hBankROM] diff --git a/src/home/menus.asm b/src/home/menus.asm index 9c1f2748..49b92f95 100644 --- a/src/home/menus.asm +++ b/src/home/menus.asm @@ -1,9 +1,9 @@ ; initializes parameters for a card list (e.g. list of hand cards in a duel, or booster pack cards) -; input: +; input:: ; a = list length ; de = initial page scroll offset, initial item (in the visible page) - ; hl: 9 bytes with the rest of the parameters -InitializeCardListParameters: + ; hl:: 9 bytes with the rest of the parameters +InitializeCardListParameters:: ld [wNumListItems], a ld a, d ld [wListScrollOffset], a @@ -39,7 +39,7 @@ InitializeCardListParameters: ; state of the list in a, d, and e if A or B were pressed. also returns carry ; if A or B were pressed, nc otherwise. returns -1 in a if B was pressed. ; used for example in the Hand card list and Discard Pile card list screens. -HandleCardListInput: +HandleCardListInput:: call HandleMenuInput ret nc ld a, [wListScrollOffset] @@ -51,11 +51,11 @@ HandleCardListInput: ret ; initializes parameters for a menu, given the 8 bytes starting at hl, -; which are loaded to the following addresses: +; which are loaded to the following addresses:: ; wCursorXPosition, wCursorYPosition, wYDisplacementBetweenMenuItems, wNumMenuItems, ; wCursorTile, wTileBehindCursor, wMenuFunctionPointer. ; also sets the current menu item (wCurMenuItem) to the one specified in register a. -InitializeMenuParameters: +InitializeMenuParameters:: ld [wCurMenuItem], a ldh [hCurMenuItem], a ld de, wCursorXPosition @@ -72,8 +72,8 @@ InitializeMenuParameters: ; returns with the carry flag set if A or B were pressed ; returns a = 0 if A was pressed, a = -1 if B was pressed -; note: return values still subject to those of the function at [wMenuFunctionPointer] if any -HandleMenuInput: +; note:: return values still subject to those of the function at [wMenuFunctionPointer] if any +HandleMenuInput:: xor a ld [wRefreshMenuCursorSFX], a ldh a, [hDPadHeld] @@ -146,7 +146,7 @@ HandleMenuInput: ; plays an "open screen" sound (SFX_02) if [hCurMenuItem] != 0xff ; plays an "exit screen" sound (SFX_03) if [hCurMenuItem] == 0xff -PlayOpenOrExitScreenSFX: +PlayOpenOrExitScreenSFX:: push af ldh a, [hCurMenuItem] inc a @@ -163,14 +163,14 @@ PlayOpenOrExitScreenSFX: ; called once per frame when a menu is open ; play the sound effect at wRefreshMenuCursorSFX if non-0 and blink the ; cursor when wCursorBlinkCounter hits 16 (i.e. every 16 frames) -RefreshMenuCursor_CheckPlaySFX: +RefreshMenuCursor_CheckPlaySFX:: ld a, [wRefreshMenuCursorSFX] or a jr z, RefreshMenuCursor call PlaySFX ; fallthrough -RefreshMenuCursor: +RefreshMenuCursor:: ld hl, wCursorBlinkCounter ld a, [hl] inc [hl] @@ -183,12 +183,12 @@ RefreshMenuCursor: ; fallthrough ; set the tile at [wCursorXPosition],[wCursorYPosition] to [wTileBehindCursor] -EraseCursor: +EraseCursor:: ld a, [wTileBehindCursor] ; fallthrough ; set the tile at [wCursorXPosition],[wCursorYPosition] to a -DrawCursor: +DrawCursor:: ld c, a ld a, [wYDisplacementBetweenMenuItems] ld l, a @@ -210,12 +210,12 @@ DrawCursor: ret ; set the tile at [wCursorXPosition],[wCursorYPosition] to [wCursorTile] -DrawCursor2: +DrawCursor2:: ld a, [wCursorTile] jr DrawCursor ; set wCurMenuItem, and hCurMenuItem to a, and zero wCursorBlinkCounter -SetMenuItem: +SetMenuItem:: ld [wCurMenuItem], a ldh [hCurMenuItem], a xor a @@ -226,7 +226,7 @@ SetMenuItem: ; only handles input not involving the B, START, or SELECT buttons, that is, ; navigating through the menu or selecting an item with the A button. ; other input in handled by PrintDuelMenuAndHandleInput.handle_input -HandleDuelMenuInput: +HandleDuelMenuInput:: ldh a, [hDPadHeld] or a jr z, .blink_cursor @@ -301,7 +301,7 @@ HandleDuelMenuInput: or a ret -DuelMenuCursorCoords: +DuelMenuCursorCoords:: db 2, 14 ; Hand db 2, 16 ; Attack db 8, 14 ; Check @@ -310,12 +310,12 @@ DuelMenuCursorCoords: db 14, 16 ; Done ; print the items of a list of cards (hand cards in a duel, cards from a booster pack...) -; and initialize the parameters of the list given: +; and initialize the parameters of the list given:: ; wDuelTempList = card list source ; a = list length ; de = initial page scroll offset, initial item (in the visible page) - ; hl: 9 bytes with the rest of the parameters -PrintCardListItems: + ; hl:: 9 bytes with the rest of the parameters +PrintCardListItems:: call InitializeCardListParameters ld hl, wMenuFunctionPointer ld a, LOW(CardListMenuFunction) @@ -330,7 +330,7 @@ PrintCardListItems: ; like PrintCardListItems, except more parameters are already initialized ; called instead of PrintCardListItems to reload the list after moving up or down -ReloadCardListItems: +ReloadCardListItems:: ld e, SYM_SPACE ld a, [wListScrollOffset] or a @@ -402,7 +402,7 @@ ReloadCardListItems: ret ; reload a list of cards, except don't print their names -Func_2827: +Func_2827:: ld a, $01 ldh [hffb0], a call ReloadCardListItems @@ -412,7 +412,7 @@ Func_2827: ; convert the number at a to TX_SYMBOL text format and write it to wDefaultText ; if the first digit is a 0, delete it and shift the number one tile to the left -OneByteNumberToTxSymbol_TrimLeadingZerosAndAlign: +OneByteNumberToTxSymbol_TrimLeadingZerosAndAlign:: call OneByteNumberToTxSymbol ld a, [hli] cp SYM_0 @@ -426,7 +426,7 @@ OneByteNumberToTxSymbol_TrimLeadingZerosAndAlign: ; this function is always loaded to wMenuFunctionPointer by PrintCardListItems ; takes care of things like handling page scrolling and calling the function at wListFunctionPointer -CardListMenuFunction: +CardListMenuFunction:: ldh a, [hDPadHeld] ld b, a ld a, [wNumMenuItems] @@ -595,7 +595,7 @@ CardListMenuFunction: ; convert the number at a to TX_SYMBOL text format and write it to wDefaultText ; replace leading zeros with SYM_SPACE -OneByteNumberToTxSymbol_TrimLeadingZeros: +OneByteNumberToTxSymbol_TrimLeadingZeros:: call OneByteNumberToTxSymbol ld a, [hl] cp SYM_0 @@ -604,7 +604,7 @@ OneByteNumberToTxSymbol_TrimLeadingZeros: ret ; convert the number at a to TX_SYMBOL text format and write it to wDefaultText -OneByteNumberToTxSymbol: +OneByteNumberToTxSymbol:: ld hl, wDefaultText push hl ld e, SYM_0 - 1 @@ -621,7 +621,7 @@ OneByteNumberToTxSymbol: ret ; translate the TYPE_* constant in wLoadedCard1Type to an index for CardSymbolTable -CardTypeToSymbolID: +CardTypeToSymbolID:: ld a, [wLoadedCard1Type] cp TYPE_TRAINER jr nc, .trainer_card @@ -640,7 +640,7 @@ CardTypeToSymbolID: ; return the entry in CardSymbolTable of the TYPE_* constant in wLoadedCard1Type ; also return the first byte of said entry (starting tile number) in a -GetCardSymbolData: +GetCardSymbolData:: call CardTypeToSymbolID add a ld c, a @@ -651,7 +651,7 @@ GetCardSymbolData: ret ; draw, at de, the 2x2 tile card symbol associated to the TYPE_* constant in wLoadedCard1Type -DrawCardSymbol: +DrawCardSymbol:: push hl push de push bc @@ -682,7 +682,7 @@ DrawCardSymbol: pop hl ret -CardSymbolTable: +CardSymbolTable:: ; starting tile number, cgb palette (grey, yellow/red, green/blue, pink/orange) db $e0, $01 ; TYPE_ENERGY_FIRE db $e4, $02 ; TYPE_ENERGY_GRASS @@ -699,21 +699,21 @@ CardSymbolTable: ; copy the name and level of the card at wLoadedCard1 to wDefaultText ; a = length in number of tiles (the resulting string will be padded with spaces to match it) -CopyCardNameAndLevel: +CopyCardNameAndLevel:: farcall _CopyCardNameAndLevel ret ; sets cursor parameters for navigating in a text box, but using ; default values for the cursor tile (SYM_CURSOR_R) and the tile behind it (SYM_SPACE). -; d,e: coordinates of the cursor -SetCursorParametersForTextBox_Default: +; d,e:: coordinates of the cursor +SetCursorParametersForTextBox_Default:: lb bc, SYM_CURSOR_R, SYM_SPACE ; cursor tile, tile behind cursor call SetCursorParametersForTextBox ; fallthrough ; wait until A or B is pressed. ; return carry if A is pressed, nc if B is pressed. erase the cursor either way -WaitForButtonAorB: +WaitForButtonAorB:: call DoFrame call RefreshMenuCursor ldh a, [hKeysPressed] @@ -730,9 +730,9 @@ WaitForButtonAorB: ret ; sets cursor parameters for navigating in a text box -; d,e: coordinates of the cursor -; b,c: tile numbers of the cursor and of the tile behind it -SetCursorParametersForTextBox: +; d,e:: coordinates of the cursor +; b,c:: tile numbers of the cursor and of the tile behind it +SetCursorParametersForTextBox:: xor a ld hl, wCurMenuItem ld [hli], a @@ -752,13 +752,13 @@ SetCursorParametersForTextBox: ; draw a 20x6 text box aligned to the bottom of the screen, ; print the text at hl without letter delay, and wait for A or B pressed -DrawWideTextBox_PrintTextNoDelay_Wait: +DrawWideTextBox_PrintTextNoDelay_Wait:: call DrawWideTextBox_PrintTextNoDelay jp WaitForWideTextBoxInput ; draw a 20x6 text box aligned to the bottom of the screen ; and print the text at hl without letter delay -DrawWideTextBox_PrintTextNoDelay: +DrawWideTextBox_PrintTextNoDelay:: push hl call DrawWideTextBox ld a, 19 @@ -766,13 +766,13 @@ DrawWideTextBox_PrintTextNoDelay: ; draw a 12x6 text box aligned to the bottom left of the screen ; and print the text at hl without letter delay -DrawNarrowTextBox_PrintTextNoDelay: +DrawNarrowTextBox_PrintTextNoDelay:: push hl call DrawNarrowTextBox ld a, 11 ; fallthrough -DrawTextBox_PrintTextNoDelay: +DrawTextBox_PrintTextNoDelay:: lb de, 1, 14 call AdjustCoordinatesForBGScroll call InitTextPrintingInTextbox @@ -785,7 +785,7 @@ DrawTextBox_PrintTextNoDelay: ; draw a 20x6 text box aligned to the bottom of the screen ; and print the text at hl with letter delay -DrawWideTextBox_PrintText: +DrawWideTextBox_PrintText:: push hl call DrawWideTextBox ld a, 19 @@ -797,7 +797,7 @@ DrawWideTextBox_PrintText: jp PrintText ; draw a 12x6 text box aligned to the bottom left of the screen -DrawNarrowTextBox: +DrawNarrowTextBox:: lb de, 0, 12 lb bc, 12, 6 call AdjustCoordinatesForBGScroll @@ -806,7 +806,7 @@ DrawNarrowTextBox: ; draw a 12x6 text box aligned to the bottom left of the screen, ; print the text at hl without letter delay, and wait for A or B pressed -DrawNarrowTextBox_WaitForInput: +DrawNarrowTextBox_WaitForInput:: call DrawNarrowTextBox_PrintTextNoDelay xor a ld hl, NarrowTextBoxMenuParameters @@ -820,7 +820,7 @@ DrawNarrowTextBox_WaitForInput: jr z, .wait_A_or_B_loop ret -NarrowTextBoxMenuParameters: +NarrowTextBoxMenuParameters:: db 10, 17 ; cursor x, cursor y db 1 ; y displacement between items db 1 ; number of items @@ -829,7 +829,7 @@ NarrowTextBoxMenuParameters: dw NULL ; function pointer if non-0 ; draw a 20x6 text box aligned to the bottom of the screen -DrawWideTextBox: +DrawWideTextBox:: lb de, 0, 12 lb bc, 20, 6 call AdjustCoordinatesForBGScroll @@ -838,12 +838,12 @@ DrawWideTextBox: ; draw a 20x6 text box aligned to the bottom of the screen, ; print the text at hl with letter delay, and wait for A or B pressed -DrawWideTextBox_WaitForInput: +DrawWideTextBox_WaitForInput:: call DrawWideTextBox_PrintText ; fallthrough ; wait for A or B to be pressed on a wide (20x6) text box -WaitForWideTextBoxInput: +WaitForWideTextBoxInput:: xor a ld hl, WideTextBoxMenuParameters call InitializeMenuParameters @@ -857,7 +857,7 @@ WaitForWideTextBoxInput: call EraseCursor ret -WideTextBoxMenuParameters: +WideTextBoxMenuParameters:: db 18, 17 ; cursor x, cursor y db 1 ; y displacement between items db 1 ; number of items @@ -866,7 +866,7 @@ WideTextBoxMenuParameters: dw NULL ; function pointer if non-0 ; display a two-item horizontal menu with custom text provided in hl and handle input -TwoItemHorizontalMenu: +TwoItemHorizontalMenu:: call DrawWideTextBox_PrintText lb de, 6, 16 ; x, y ld a, d @@ -878,7 +878,7 @@ TwoItemHorizontalMenu: call EnableLCD jp HandleYesOrNoMenu.refresh_menu -YesOrNoMenuWithText_SetCursorToYes: +YesOrNoMenuWithText_SetCursorToYes:: ld a, $01 ld [wDefaultYesOrNo], a ; fallthrough @@ -886,28 +886,28 @@ YesOrNoMenuWithText_SetCursorToYes: ; display a yes / no menu in a 20x8 textbox with custom text provided in hl and handle input ; wDefaultYesOrNo determines whether the cursor initially points to YES or to NO ; returns carry if "no" selected -YesOrNoMenuWithText: +YesOrNoMenuWithText:: call DrawWideTextBox_PrintText ; fallthrough ; prints the YES / NO menu items at coordinates x,y = 7,16 and handles input -; input: wDefaultYesOrNo. returns carry if "no" selected -YesOrNoMenu: +; input:: wDefaultYesOrNo. returns carry if "no" selected +YesOrNoMenu:: lb de, 7, 16 ; x, y call PrintYesOrNoItems lb de, 6, 16 ; x, y jr HandleYesOrNoMenu ; prints the YES / NO menu items at coordinates x,y = 3,16 and handles input -; input: wDefaultYesOrNo. returns carry if "no" selected -YesOrNoMenuWithText_LeftAligned: +; input:: wDefaultYesOrNo. returns carry if "no" selected +YesOrNoMenuWithText_LeftAligned:: call DrawNarrowTextBox_PrintTextNoDelay lb de, 3, 16 ; x, y call PrintYesOrNoItems lb de, 2, 16 ; x, y ; fallthrough -HandleYesOrNoMenu: +HandleYesOrNoMenu:: ld a, d ld [wLeftmostItemCursorX], a lb bc, SYM_CURSOR_R, SYM_SPACE ; cursor tile, tile behind cursor @@ -962,13 +962,13 @@ HandleYesOrNoMenu: ret ; prints "YES NO" at de -PrintYesOrNoItems: +PrintYesOrNoItems:: call AdjustCoordinatesForBGScroll ldtx hl, YesOrNoText call InitTextPrinting_ProcessTextFromID ret -ContinueDuel: +ContinueDuel:: ld a, BANK(_ContinueDuel) call BankswitchROM jp _ContinueDuel diff --git a/src/home/objects.asm b/src/home/objects.asm index c9a98855..de6122d7 100644 --- a/src/home/objects.asm +++ b/src/home/objects.asm @@ -1,6 +1,6 @@ ; set attributes for [hl] sprites starting from wOAM + [wOAMOffset] / 4 ; return carry if reached end of wOAM before finishing -SetManyObjectsAttributes: ; 950 (0:950) +SetManyObjectsAttributes:: ; 950 (0::950) push hl ld a, [wOAMOffset] ld c, a @@ -43,7 +43,7 @@ SetManyObjectsAttributes: ; 950 (0:950) ; for the sprite at wOAM + [wOAMOffset] / 4, set its attributes from registers e, d, c, b ; return carry if [wOAMOffset] > 40 * 4 (beyond the end of wOAM) -SetOneObjectAttributes: +SetOneObjectAttributes:: push hl ld a, [wOAMOffset] ld l, a @@ -69,7 +69,7 @@ SetOneObjectAttributes: ret ; set the Y Position and X Position of all sprites in wOAM to $00 -ZeroObjectPositions: +ZeroObjectPositions:: xor a ld [wOAMOffset], a ld hl, wOAM diff --git a/src/home/palettes.asm b/src/home/palettes.asm index 55f19789..c94938dc 100644 --- a/src/home/palettes.asm +++ b/src/home/palettes.asm @@ -1,25 +1,25 @@ ; Flush all non-CGB and CGB palettes -FlushAllPalettes: +FlushAllPalettes:: ld a, FLUSH_ALL_PALS jr FlushPalettes ; Flush non-CGB palettes and a single CGB palette, ; provided in a as an index between 0-7 (BGP) or 8-15 (OBP) -FlushPalette: +FlushPalette:: or FLUSH_ONE_PAL jr FlushPalettes ; Set wBGP to the specified value, flush non-CGB palettes, and the first CGB palette. -SetBGP: +SetBGP:: ld [wBGP], a ; fallthrough ; Flush non-CGB palettes and the first CGB palette -FlushPalette0: +FlushPalette0:: ld a, FLUSH_ONE_PAL ; fallthrough -FlushPalettes: +FlushPalettes:: ld [wFlushPaletteFlags], a ld a, [wLCDC] rla @@ -34,12 +34,12 @@ FlushPalettes: ret ; Set wOBP0 to the specified value, flush non-CGB palettes, and the first CGB palette. -SetOBP0: +SetOBP0:: ld [wOBP0], a jr FlushPalette0 ; Set wOBP1 to the specified value, flush non-CGB palettes, and the first CGB palette. -SetOBP1: +SetOBP1:: ld [wOBP1], a jr FlushPalette0 @@ -48,7 +48,7 @@ SetOBP1: ; and [wObjectPalettesCGB+$00..wObjectPalettesCGB+$3f] (sprite palette). ; Only flushes if [wFlushPaletteFlags] is nonzero, and only flushes ; a single CGB palette if bit6 of that location is reset. -FlushPalettesIfRequested: +FlushPalettesIfRequested:: ld a, [wFlushPaletteFlags] or a ret z @@ -77,7 +77,7 @@ FlushPalettesIfRequested: call CopyCGBPalettes jr .done -FlushAllCGBPalettes: +FlushAllCGBPalettes:: ; flush 8 BGP palettes xor a ld b, 8 palettes @@ -90,7 +90,7 @@ FlushAllCGBPalettes: ; copy b bytes of CGB palette data starting at ; (wBackgroundPalettesCGB + a palettes) into rBGPD or rOBPD. -CopyCGBPalettes: +CopyCGBPalettes:: add a add a add a diff --git a/src/home/play_animation.asm b/src/home/play_animation.asm index b8178628..bc1aba99 100644 --- a/src/home/play_animation.asm +++ b/src/home/play_animation.asm @@ -1,6 +1,6 @@ ; return nc if wd42a, wd4c0, and wAnimationQueue[] are all equal to $ff ; nc means no animation is playing (or animation(s) has/have ended) -CheckAnyAnimationPlaying: +CheckAnyAnimationPlaying:: push hl push bc ld a, [wd42a] @@ -21,9 +21,9 @@ CheckAnyAnimationPlaying: ; plays duel animation ; the animations are loaded to a buffer ; and played in order, so they can be stacked -; input: +; input:: ; - a = animation index -PlayDuelAnimation: +PlayDuelAnimation:: ld [wTempAnimation], a ; hold an animation temporarily ldh a, [hBankROM] push af @@ -61,7 +61,7 @@ PlayDuelAnimation: call BankswitchROM ret -Func_3ba2: +Func_3ba2:: ldh a, [hBankROM] push af ld a, BANK(Func_1cac5) @@ -72,7 +72,7 @@ Func_3ba2: call BankswitchROM ret -Func_3bb5: +Func_3bb5:: xor a ld [wd4c0], a ldh a, [hBankROM] @@ -88,14 +88,14 @@ Func_3bb5: ret ; writes from hl the pointer to the function to be called by DoFrame -SetDoFrameFunction: +SetDoFrameFunction:: ld a, l ld [wDoFrameFunction], a ld a, h ld [wDoFrameFunction + 1], a ret -ResetDoFrameFunction: +ResetDoFrameFunction:: push hl ld hl, NULL call SetDoFrameFunction diff --git a/src/home/play_song.asm b/src/home/play_song.asm index a29eacf2..17b33ab2 100644 --- a/src/home/play_song.asm +++ b/src/home/play_song.asm @@ -1,8 +1,8 @@ -ScriptPlaySong: +ScriptPlaySong:: call PlaySong ret -Func_3c87: +Func_3c87:: push af call PauseSong pop af @@ -11,7 +11,7 @@ Func_3c87: call ResumeSong ret -WaitForSongToFinish: +WaitForSongToFinish:: call DoFrameIfLCDEnabled call AssertSongFinished or a diff --git a/src/home/print_text.asm b/src/home/print_text.asm index 455b03bf..35844946 100644 --- a/src/home/print_text.asm +++ b/src/home/print_text.asm @@ -1,7 +1,7 @@ -; writes n items of text each given in the following format in hl: +; writes n items of text each given in the following format in hl:: ; x coord, y coord, text id ; $ff-terminated -PlaceTextItems: +PlaceTextItems:: ld d, [hl] ; x coord inc hl bit 7, d @@ -17,18 +17,18 @@ PlaceTextItems: jr PlaceTextItems ; do next item ; like ProcessTextFromID, except it calls InitTextPrinting first -InitTextPrinting_ProcessTextFromID: +InitTextPrinting_ProcessTextFromID:: call InitTextPrinting jr ProcessTextFromID ; like ProcessTextFromPointerToID, except it calls InitTextPrinting first -InitTextPrinting_ProcessTextFromPointerToID: +InitTextPrinting_ProcessTextFromPointerToID:: call InitTextPrinting ; fallthrough ; like ProcessTextFromID below, except a memory address containing a text ID is ; provided in hl rather than the text ID directly. -ProcessTextFromPointerToID: +ProcessTextFromPointerToID:: ld a, [hli] or [hl] ret z @@ -40,7 +40,7 @@ ProcessTextFromPointerToID: ; given the ID of a text in hl, reads the characters from it processes them. ; loops until TX_END is found. ignores TX_RAM1, TX_RAM2, and TX_RAM3 characters. ; restores original ROM bank before returning. -ProcessTextFromID: +ProcessTextFromID:: ldh a, [hBankROM] push af call GetTextOffsetFromTextID @@ -51,7 +51,7 @@ ProcessTextFromID: ; return, in a, the number of lines of the text given in hl as an ID ; this is calculated by counting the amount of '\n' characters and adding 1 to the result -CountLinesOfTextFromID: +CountLinesOfTextFromID:: push hl push de push bc @@ -86,11 +86,11 @@ CountLinesOfTextFromID: ; call PrintScrollableText with text box label, then wait for the ; player to press A or B to advance the printed text -PrintScrollableText_WithTextBoxLabel: +PrintScrollableText_WithTextBoxLabel:: call PrintScrollableText_WithTextBoxLabel_NoWait jr WaitForPlayerToAdvanceText -PrintScrollableText_WithTextBoxLabel_NoWait: +PrintScrollableText_WithTextBoxLabel_NoWait:: push hl ld hl, wTextBoxLabel ld [hl], e @@ -102,14 +102,14 @@ PrintScrollableText_WithTextBoxLabel_NoWait: ; call PrintScrollableText with no text box label, then wait for the ; player to press A or B to advance the printed text -PrintScrollableText_NoTextBoxLabel: +PrintScrollableText_NoTextBoxLabel:: xor a call PrintScrollableText ; fallthrough ; when a text box is full or the text is over, prompt the player to ; press A or B in order to clear the text and print the next lines. -WaitForPlayerToAdvanceText: +WaitForPlayerToAdvanceText:: lb bc, SYM_CURSOR_D, SYM_BOX_BOTTOM ; cursor tile, tile behind cursor lb de, 18, 17 ; x, y call SetCursorParametersForTextBox @@ -121,7 +121,7 @@ WaitForPlayerToAdvanceText: ; to advance the page or close the text. register a determines whether the textbox is ; labeled or not. if labeled, the text id of the label is provided in wTextBoxLabel. ; PrintScrollableText is used mostly for overworld NPC text. -PrintScrollableText: +PrintScrollableText:: ld [wIsTextBoxLabeled], a ldh a, [hBankROM] push af @@ -165,7 +165,7 @@ PrintScrollableText: ; zero wWhichTextHeader, wWhichTxRam2 and wWhichTxRam3, and set hJapaneseSyllabary to TX_KATAKANA ; fill wTextHeader1 with TX_KATAKANA, wFontWidth, hBankROM, and register bc for the text's pointer. -ResetTxRam_WriteToTextHeader: +ResetTxRam_WriteToTextHeader:: xor a ld [wWhichTextHeader], a ld [wWhichTxRam2], a @@ -176,7 +176,7 @@ ResetTxRam_WriteToTextHeader: ; fill the wTextHeader specified in wWhichTextHeader (0-3) with hJapaneseSyllabary, ; wFontWidth, hBankROM, and register bc for the text's pointer. -WriteToTextHeader: +WriteToTextHeader:: push hl call GetPointerToTextHeader pop bc @@ -194,7 +194,7 @@ WriteToTextHeader: ; same as WriteToTextHeader, except it then increases wWhichTextHeader to ; set the next text header to the current one (usually, because ; it will soon be written to due to a TX_RAM command). -WriteToTextHeader_MoveToNext: +WriteToTextHeader_MoveToNext:: call WriteToTextHeader ld hl, wWhichTextHeader inc [hl] @@ -203,7 +203,7 @@ WriteToTextHeader_MoveToNext: ; read the wTextHeader specified in wWhichTextHeader (0-3) and use the data to ; populate the corresponding memory addresses. also switch to the text's rombank ; and return the address of the next character in hl. -ReadTextHeader: +ReadTextHeader:: call GetPointerToTextHeader ld a, [hli] ld [hJapaneseSyllabary], a @@ -217,7 +217,7 @@ ReadTextHeader: ret ; return in hl, the address of the wTextHeader specified in wWhichTextHeader (0-3) -GetPointerToTextHeader: +GetPointerToTextHeader:: ld a, [wWhichTextHeader] ld e, a add a @@ -232,7 +232,7 @@ GetPointerToTextHeader: ; draws a wide text box with or without label depending on wIsTextBoxLabeled ; if labeled, the label's text ID is provided in wTextBoxLabel ; calls InitTextPrintingInTextbox after drawing the text box -DrawTextReadyLabeledOrRegularTextBox: +DrawTextReadyLabeledOrRegularTextBox:: push hl lb de, 0, 12 lb bc, 20, 6 @@ -261,7 +261,7 @@ DrawTextReadyLabeledOrRegularTextBox: ; then updates the current wTextHeader to point to the next character. ; a TX_RAM command causes a switch to a wTextHeader in the level below, and a TX_END ; command terminates the text unless there is a pending wTextHeader in the above level. -ProcessTextHeader: +ProcessTextHeader:: call ReadTextHeader ld a, [hli] or a ; TX_END @@ -344,12 +344,12 @@ ProcessTextHeader: call WriteToTextHeader jp ProcessTextHeader -; input: - ; de: wTxRam2 or wTxRam3 - ; hl: wWhichTxRam2 or wWhichTxRam3 +; input:: + ; de:: wTxRam2 or wTxRam3 + ; hl:: wWhichTxRam2 or wWhichTxRam3 ; return, in hl, the contents of the contents of the ; wTxRam* buffer's current entry, and increment wWhichTxRam*. -HandleTxRam2Or3: +HandleTxRam2Or3:: push de ld a, [hl] inc [hl] @@ -365,7 +365,7 @@ HandleTxRam2Or3: ; uses the two byte text id in hl to read the three byte text offset ; loads the correct bank for the specific text and returns the pointer in hl -GetTextOffsetFromTextID: +GetTextOffsetFromTextID:: push de ld e, l ld d, h @@ -393,13 +393,13 @@ GetTextOffsetFromTextID: pop de ret -; if [wFontWidth] == HALF_WIDTH: +; if [wFontWidth] == HALF_WIDTH:: ; convert the number at hl to text (ascii) format and write it to wStringBuffer ; return c = 4 - leading_zeros -; if [wFontWidth] == FULL_WIDTH: +; if [wFontWidth] == FULL_WIDTH:: ; convert the number at hl to TX_SYMBOL text format and write it to wStringBuffer ; replace leading zeros with SYM_SPACE -TwoByteNumberToText_CountLeadingZeros: +TwoByteNumberToText_CountLeadingZeros:: ld a, [wFontWidth] or a ; FULL_WIDTH jp z, TwoByteNumberToTxSymbol_TrimLeadingZeros @@ -417,9 +417,9 @@ TwoByteNumberToText_CountLeadingZeros: jr nz, .digit_loop ret -; in the overworld: copy the player's name to wStringBuffer -; in a duel: copy the name of the duelist whose turn it is to wStringBuffer -CopyPlayerNameOrTurnDuelistName: +; in the overworld:: copy the player's name to wStringBuffer +; in a duel:: copy the name of the duelist whose turn it is to wStringBuffer +CopyPlayerNameOrTurnDuelistName:: ld de, wStringBuffer push de ldh a, [hWhoseTurn] @@ -435,7 +435,7 @@ CopyPlayerNameOrTurnDuelistName: ; prints text with id at hl, with letter delay, in a textbox area. ; the text must fit in the textbox; PrintScrollableText should be used instead. -PrintText: +PrintText:: ld a, l or h jr z, .from_ram @@ -474,7 +474,7 @@ PrintText: ; prints text with id at hl, without letter delay, in a textbox area. ; the text must fit in the textbox; PrintScrollableText should be used instead. -PrintTextNoDelay: +PrintTextNoDelay:: ldh a, [hBankROM] push af call GetTextOffsetFromTextID @@ -488,7 +488,7 @@ PrintTextNoDelay: ; copies a text given its id at hl, to de ; if hl is 0, the name of the turn duelist is copied instead -CopyText: +CopyText:: ld a, l or h jr z, .special @@ -515,7 +515,7 @@ CopyText: ; then terminate the text with TX_END if it doesn't contain it already. ; fill any remaining bytes with spaces plus TX_END to match the length specified in a. ; return the text's actual length in characters (i.e. before the first TX_END) in e. -CopyTextData_FromTextID: +CopyTextData_FromTextID:: ldh [hff96], a ldh a, [hBankROM] push af @@ -527,7 +527,7 @@ CopyTextData_FromTextID: ret ; text id (usually of a card name) for TX_RAM2 -LoadTxRam2: +LoadTxRam2:: ld a, l ld [wTxRam2], a ld a, h @@ -535,7 +535,7 @@ LoadTxRam2: ret ; a number between 0 and 65535 for TX_RAM3 -LoadTxRam3: +LoadTxRam3:: ld a, l ld [wTxRam3], a ld a, h diff --git a/src/home/printer.asm b/src/home/printer.asm index 9b4ce596..45ad269f 100644 --- a/src/home/printer.asm +++ b/src/home/printer.asm @@ -1,5 +1,5 @@ ; serial transfer-related -SendPrinterPacket: +SendPrinterPacket:: push hl ld hl, wce64 ; Preamble @@ -66,12 +66,12 @@ SendPrinterPacket: scf ret -Func_3189: +Func_3189:: ld hl, PointerTable_3190 dec a jp JumpToFunctionInTable -PointerTable_3190: +PointerTable_3190:: dw Func_31a8 dw Func_31a8 dw Func_31a8 @@ -85,14 +85,14 @@ PointerTable_3190: dw Func_31ea dw Func_31f2 -Func_31a8: +Func_31a8:: call Func_31fc -Func_31ab: +Func_31ab:: ld hl, wce63 inc [hl] ret -Func_31b0: +Func_31b0:: call Func_31ab ld hl, wce68 ld a, [hli] @@ -111,7 +111,7 @@ Func_31b0: ld [de], a ; fallthrough -Func_31ca: +Func_31ca:: call Func_31fc ld hl, wce68 ld a, [hl] @@ -127,31 +127,31 @@ Func_31ca: jr z, Func_31ab ret -Func_31dd: +Func_31dd:: ld a, [wce6c] -Func_31e0: +Func_31e0:: call Func_3212 jr Func_31ab -Func_31e5: +Func_31e5:: ld a, [wce6d] jr Func_31e0 -Func_31ea: +Func_31ea:: ldh a, [rSB] ld [wce6e], a -Func_31ef: +Func_31ef:: xor a jr Func_31e0 -Func_31f2: +Func_31f2:: ldh a, [rSB] ld [wPrinterStatus], a xor a ld [wce63], a ret -Func_31fc: +Func_31fc:: ld hl, wSerialDataPtr ld e, [hl] inc hl @@ -172,7 +172,7 @@ Func_31fc: ld a, e ; fallthrough -Func_3212: +Func_3212:: ldh [rSB], a ld a, SC_INTERNAL ldh [rSC], a diff --git a/src/home/process_text.asm b/src/home/process_text.asm index 515c9410..8bdfa8fb 100644 --- a/src/home/process_text.asm +++ b/src/home/process_text.asm @@ -1,7 +1,7 @@ ; similar to ProcessText except it calls InitTextPrinting first ; with the first two bytes of hl being used to set hTextBGMap0Address. ; (the caller to ProcessText usually calls InitTextPrinting first) -InitTextPrinting_ProcessText: +InitTextPrinting_ProcessText:: push de push bc ld d, [hl] @@ -13,7 +13,7 @@ InitTextPrinting_ProcessText: ; reads the characters from the text at hl processes them. loops until ; TX_END is found. ignores TX_RAM1, TX_RAM2, and TX_RAM3 characters. -ProcessText: +ProcessText:: push de push bc call InitTextFormat @@ -48,7 +48,7 @@ ProcessText: ; processes the text character provided in a checking for specific control characters. ; hl points to the text character coming right after the one loaded into a. ; returns carry if the character was not processed by this function. -ProcessSpecialTextCharacter: +ProcessSpecialTextCharacter:: or a ; TX_END jr z, .tx_end cp TX_HIRAGANA @@ -136,7 +136,7 @@ ProcessSpecialTextCharacter: ; calls InitTextFormat, selects tiles at $8800-$97FF for text, and clears the wc600. ; selects the first and last tile to be reserved for constructing text tiles in VRAM ; based on the values given in d and e respectively. -SetupText: +SetupText:: ld a, d dec a ld [wcd04], a @@ -162,7 +162,7 @@ SetupText: ; hTextLineCurPos <- 0 ; wHalfWidthPrintState <- 0 ; hJapaneseSyllabary <- TX_KATAKANA -InitTextFormat: +InitTextFormat:: xor a ; FULL_WIDTH ld [wFontWidth], a ldh [hTextLineCurPos], a @@ -173,7 +173,7 @@ InitTextFormat: ; call InitTextPrinting ; hTextLineLength <- a -InitTextPrintingInTextbox: +InitTextPrintingInTextbox:: push af call InitTextPrinting pop af @@ -185,7 +185,7 @@ InitTextPrintingInTextbox: ; wCurTextLine <- 0 ; write BGMap0-translated DE to hTextBGMap0Address ; call InitTextFormat -InitTextPrinting: +InitTextPrinting:: push hl ld a, d ldh [hTextHorizontalAlign], a @@ -204,11 +204,11 @@ InitTextPrinting: ret ; requests a text tile to be generated and prints it in the screen -; different modes depending on hffb0: - ; hffb0 == $0: generate and place text tile - ; hffb0 == $2 (bit 1 set): only generate text tile? - ; hffb0 == $1 (bit 0 set): not even generate it, but just update text buffers? -Func_22ca: +; different modes depending on hffb0:: + ; hffb0 == $0:: generate and place text tile + ; hffb0 == $2 (bit 1 set):: only generate text tile? + ; hffb0 == $1 (bit 0 set):: not even generate it, but just update text buffers? +Func_22ca:: push hl push de push bc @@ -237,7 +237,7 @@ Func_22ca: ; writes a to wCurTextTile and to the tile pointed to by hTextBGMap0Address, ; then increments hTextBGMap0Address and hTextLineCurPos -PlaceNextTextTile: +PlaceNextTextTile:: ld [wCurTextTile], a ld hl, hTextBGMap0Address ld e, [hl] @@ -260,7 +260,7 @@ PlaceNextTextTile: ; when terminating half-width text with "\n" or TX_END, or switching to full-width ; with TX_HALF2FULL or to symbols with TX_SYMBOL, check if it's necessary to append ; a half-width space to finish an incomplete character pair. -TerminateHalfWidthText: +TerminateHalfWidthText:: ld a, [wFontWidth] or a ; FULL_WIDTH ret z @@ -277,7 +277,7 @@ TerminateHalfWidthText: pop hl ret -Func_2325: +Func_2325:: call Func_235e ret c or a @@ -324,7 +324,7 @@ Func_2325: ; search linked-list for text characters e/d (registers), if found hoist ; the result to head of list and return it. carry flag denotes success. -Func_235e: +Func_235e:: ld a, [wFontWidth] or a jr z, .print @@ -356,7 +356,7 @@ Func_235e: jr nz, .asm_238a ; ; linked list inc h ; $c7 ; ; ld a, [hl] ; if key1[l] == e and ; - cp d ; key2[l] == d: ; + cp d ; key2[l] == d:: ; jr z, .asm_238f ; break ; .asm_238a ld h, $c8 ; ; @@ -383,7 +383,7 @@ Func_235e: ld h, $c9 inc c dec c - jr z, .asm_23af ; if next[i] != NULL: + jr z, .asm_23af ; if next[i] != NULL:: ld l, c ; l ← next[i] ld [hl], b ; prev[next[i]] ← prev[i] .asm_23af @@ -391,7 +391,7 @@ Func_235e: ret ; (return new linked-list head in a) ; uppercases e if [wUppercaseHalfWidthLetters] is nonzero -CaseHalfWidthLetter: +CaseHalfWidthLetter:: ld a, [wUppercaseHalfWidthLetters] or a ret z @@ -406,11 +406,11 @@ CaseHalfWidthLetter: ; iterates over text at hl until TX_END is found, and sets wFontWidth to ; FULL_WIDTH if the first character is TX_HALFWIDTH -; returns: +; returns:: ; b = length of text in tiles ; c = length of text in bytes ; a = -b -GetTextLengthInTiles: +GetTextLengthInTiles:: ld a, [hl] cp TX_HALFWIDTH jr nz, .full_width @@ -427,11 +427,11 @@ GetTextLengthInTiles: ; fallthrough ; iterates over text at hl until TX_END is found -; returns: +; returns:: ; b = length of text in half-tiles ; c = length of text in bytes ; a = -b -GetTextLengthInHalfTiles: +GetTextLengthInHalfTiles:: push hl push de lb bc, $00, $00 @@ -439,8 +439,8 @@ GetTextLengthInHalfTiles: ld a, [hli] or a ; TX_END jr z, .tx_end - inc c ; any char except TX_END: c ++ - ; TX_FULLWIDTH, TX_SYMBOL, or > TX_CTRL_END : b ++ + inc c ; any char except TX_END:: c ++ + ; TX_FULLWIDTH, TX_SYMBOL, or > TX_CTRL_END :: b ++ cp TX_CTRL_START jr c, .character_pair cp TX_CTRL_END @@ -457,7 +457,7 @@ GetTextLengthInHalfTiles: jr nc, .char_loop ; TX_FULLWIDTH .next - inc c ; TX_FULLWIDTH or TX_SYMBOL: c ++ + inc c ; TX_FULLWIDTH or TX_SYMBOL:: c ++ inc hl jr .char_loop .tx_end @@ -472,7 +472,7 @@ GetTextLengthInHalfTiles: ; the text with TX_END if it doesn't contain it already. ; fill any remaining bytes with spaces plus TX_END to match the length specified in a. ; return the text's actual length in characters (i.e. before the first TX_END) in e. -CopyTextData: +CopyTextData:: ld [wTextMaxLength], a ld a, [hl] cp TX_HALFWIDTH @@ -552,7 +552,7 @@ CopyTextData: ; convert the number at hl to TX_SYMBOL text format and write it to wStringBuffer ; replace leading zeros with SYM_SPACE -TwoByteNumberToTxSymbol_TrimLeadingZeros: +TwoByteNumberToTxSymbol_TrimLeadingZeros:: push de push bc ld de, wStringBuffer @@ -614,7 +614,7 @@ TwoByteNumberToTxSymbol_TrimLeadingZeros: ; d = half-width character 1 (left) ; e = half-width character 2 (right) ; b = destination VRAM tile number -GenerateTextTile: +GenerateTextTile:: push hl push de push bc @@ -637,7 +637,7 @@ GenerateTextTile: ; create, at wTextTileBuffer, a half-width font tile ; made from the ascii characters given in d and e -CreateHalfWidthFontTile: +CreateHalfWidthFontTile:: push bc ldh a, [hBankROM] push af @@ -673,7 +673,7 @@ CreateHalfWidthFontTile: ; copies a 1bpp tile corresponding to a half-width font character to de. ; the ascii value of the character to copy is provided in a. ; assumes BANK(HalfWidthFont) is already loaded. -CopyHalfWidthCharacterToDE: +CopyHalfWidthCharacterToDE:: sub $20 ; HalfWidthFont begins at ascii $20 ld l, a ld h, $0 @@ -695,7 +695,7 @@ CopyHalfWidthCharacterToDE: ; create, at wTextTileBuffer, a full-width font tile given its tile ; number within the full-width font graphics (FullWidthFonts) in de. ; return its v*Tiles address in hl, and return c = TILE_SIZE. -CreateFullWidthFontTile_ConvertToTileDataAddress: +CreateFullWidthFontTile_ConvertToTileDataAddress:: push bc call GetFullWidthFontTileOffset call CreateFullWidthFontTile @@ -703,10 +703,10 @@ CreateFullWidthFontTile_ConvertToTileDataAddress: ; fallthrough ; given a tile number in b, return its v*Tiles address in hl, and return c = TILE_SIZE -; wTilePatternSelector and wTilePatternSelectorCorrection are used to select the source: +; wTilePatternSelector and wTilePatternSelectorCorrection are used to select the source:: ; - if wTilePatternSelector == $80 and wTilePatternSelectorCorrection == $00 -> $8000-$8FFF ; - if wTilePatternSelector == $88 and wTilePatternSelectorCorrection == $80 -> $8800-$97FF -ConvertTileNumberToTileDataAddress: +ConvertTileNumberToTileDataAddress:: ld hl, wTilePatternSelectorCorrection ld a, b xor [hl] @@ -725,7 +725,7 @@ ConvertTileNumberToTileDataAddress: ; create, at wTextTileBuffer, a full-width font tile given its ; within the full-width font graphics (FullWidthFonts) in hl -CreateFullWidthFontTile: +CreateFullWidthFontTile:: ld a, BANK(Fonts) ; BANK(DuelGraphics) call BankpushROM ld de, wTextTileBuffer @@ -746,7 +746,7 @@ CreateFullWidthFontTile: ; given two text characters at de, use the char at e (first one) ; to determine which type of text this pair of characters belongs to. ; return carry if TX_FULLWIDTH1 to TX_FULLWIDTH4. -ClassifyTextCharacterPair: +ClassifyTextCharacterPair:: ld a, [wFontWidth] or a ; FULL_WIDTH jr nz, .half_width @@ -783,10 +783,10 @@ ClassifyTextCharacterPair: ; convert the full-width font tile number at de to the ; equivalent offset within the full-width font tile graphics. -; if d == TX_KATAKANA: get tile from the 0_0_katakana.1bpp font. -; if d == TX_HIRAGANA or d == $0: get tile from the 0_1_hiragana.1bpp or 0_2_digits_kanji1.1bpp font. -; if d >= TX_FULLWIDTH1 and d <= TX_FULLWIDTH4: get tile from one of the other full-width fonts. -GetFullWidthFontTileOffset: +; if d == TX_KATAKANA:: get tile from the 0_0_katakana.1bpp font. +; if d == TX_HIRAGANA or d == $0:: get tile from the 0_1_hiragana.1bpp or 0_2_digits_kanji1.1bpp font. +; if d >= TX_FULLWIDTH1 and d <= TX_FULLWIDTH4:: get tile from one of the other full-width fonts. +GetFullWidthFontTileOffset:: ld bc, $50 tiles_1bpp ld a, d cp TX_HIRAGANA @@ -810,7 +810,7 @@ GetFullWidthFontTileOffset: ; pointers to VRAM? ; unreferenced -Unknown_2589: +Unknown_2589:: db $18 dw $8140 dw $817e diff --git a/src/home/random.asm b/src/home/random.asm index d731b127..b1183fd2 100644 --- a/src/home/random.asm +++ b/src/home/random.asm @@ -1,5 +1,5 @@ ; returns h * l in hl -HtimesL: +HtimesL:: push de ld a, h ld e, l @@ -20,7 +20,7 @@ HtimesL: ret ; return a random number between 0 and a (exclusive) in a -Random: +Random:: push hl ld h, a call UpdateRNGSources @@ -31,7 +31,7 @@ Random: ret ; get the next random numbers of the wRNG1 and wRNG2 sequences -UpdateRNGSources: +UpdateRNGSources:: push hl push de ld hl, wRNG1 diff --git a/src/home/save.asm b/src/home/save.asm index 58a07ce5..ab6973b6 100644 --- a/src/home/save.asm +++ b/src/home/save.asm @@ -1,22 +1,22 @@ -SaveGeneralSaveData: +SaveGeneralSaveData:: farcall _SaveGeneralSaveData ret -LoadGeneralSaveData: +LoadGeneralSaveData:: farcall _LoadGeneralSaveData ret -ValidateGeneralSaveData: +ValidateGeneralSaveData:: farcall _ValidateGeneralSaveData ret ; adds card with card ID in register a to collection ; and updates album progress in RAM -AddCardToCollectionAndUpdateAlbumProgress: +AddCardToCollectionAndUpdateAlbumProgress:: farcall _AddCardToCollectionAndUpdateAlbumProgress ret -SaveGame: +SaveGame:: push af push bc push de diff --git a/src/home/script.asm b/src/home/script.asm index aee96ff0..ad8e67da 100644 --- a/src/home/script.asm +++ b/src/home/script.asm @@ -1,4 +1,4 @@ -HandleMoveModeAPress: +HandleMoveModeAPress:: ldh a, [hBankROM] push af ld l, MAP_SCRIPT_OBJECTS @@ -59,7 +59,7 @@ HandleMoveModeAPress: ; returns a map script pointer in hl given ; current map in wCurMap and which sub-script in l ; sets c if pointer is found -GetMapScriptPointer: +GetMapScriptPointer:: push bc push hl ld a, [wCurMap] @@ -100,12 +100,12 @@ GetMapScriptPointer: ; are stored in the script-related NPC data for normal gameplay ; returns carry if a duel configuration was found ; for the given NPC deck ID -GetNPCDuelConfigurations: +GetNPCDuelConfigurations:: farcall _GetNPCDuelConfigurations ret ; finds a Script from the first byte and puts the next two bytes (usually arguments?) into cb -RunOverworldScript: +RunOverworldScript:: ld hl, wScriptPointer ld a, [hli] ld h, [hl] @@ -132,7 +132,7 @@ RunOverworldScript: pop bc jp hl -Func_3b11: +Func_3b11:: ldh a, [hBankROM] push af ld a, BANK(_GameLoop) @@ -142,7 +142,7 @@ Func_3b11: call BankswitchROM ret -Func_3b21: +Func_3b21:: ldh a, [hBankROM] push af ld a, BANK(Func_1c8bc) @@ -152,7 +152,7 @@ Func_3b21: call BankswitchROM ret -Func_3b31: +Func_3b31:: ldh a, [hBankROM] push af ld a, BANK(Func_1cb18) diff --git a/src/home/scroll.asm b/src/home/scroll.asm index bb0cdb6b..514fa215 100644 --- a/src/home/scroll.asm +++ b/src/home/scroll.asm @@ -1,5 +1,5 @@ ; something window scroll -Func_3e44: +Func_3e44:: push af push hl push bc @@ -57,7 +57,7 @@ Func_3e44: ; apply background scroll for lines 0 to 96 using the values at BGScrollData ; skip if wApplyBGScroll is non-0 -ApplyBackgroundScroll: +ApplyBackgroundScroll:: push af push hl call DisableInt_LYCoincidence @@ -109,7 +109,7 @@ ApplyBackgroundScroll: pop af ret -BGScrollData: +BGScrollData:: db 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3 db 4, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 1, 1, 1, 0, 0 db 0, -1, -1, -1, -2, -2, -2, -3, -3, -3, -4, -4, -4, -4, -4, -4 @@ -117,7 +117,7 @@ BGScrollData: ; x = BGScrollData[(wVBlankCounter + a) & $3f] ; return, in register a, x rotated right [wBGScrollMod]-1 times (max 3 times) -GetNextBackgroundScroll: +GetNextBackgroundScroll:: ld hl, wVBlankCounter add [hl] and $3f @@ -144,7 +144,7 @@ GetNextBackgroundScroll: ret ; enable lcdc interrupt on LYC=LC coincidence -EnableInt_LYCoincidence: +EnableInt_LYCoincidence:: push hl ld hl, rSTAT set STAT_LYC, [hl] @@ -155,7 +155,7 @@ EnableInt_LYCoincidence: ret ; disable lcdc interrupt and the LYC=LC coincidence trigger -DisableInt_LYCoincidence: +DisableInt_LYCoincidence:: push hl ld hl, rSTAT res STAT_LYC, [hl] diff --git a/src/home/serial.asm b/src/home/serial.asm index 51de4f9f..f94f6d7f 100644 --- a/src/home/serial.asm +++ b/src/home/serial.asm @@ -1,5 +1,5 @@ ; called at roughly 240Hz by TimerHandler -SerialTimerHandler: +SerialTimerHandler:: ld a, [wSerialOp] cp $29 jr z, .begin_transfer @@ -35,7 +35,7 @@ SerialTimerHandler: ld [hl], $0 ret -Func_0cc5: +Func_0cc5:: ld hl, wSerialRecvCounter or a jr nz, .asm_cdc @@ -94,14 +94,14 @@ Func_0cc5: scf ret -SerialHandler: +SerialHandler:: push af push hl push de push bc ld a, [wce63] ; or a ; - jr z, .asm_d35 ; if [wce63] nonzero: + jr z, .asm_d35 ; if [wce63] nonzero:: call Func_3189 ; ? jr .done ; return .asm_d35 @@ -148,7 +148,7 @@ SerialHandler: ; handles a byte read from serial transfer by decoding it and storing it into ; the receive buffer -SerialHandleRecv: +SerialHandleRecv:: ld hl, wSerialLastReadCA ld e, [hl] dec e @@ -210,7 +210,7 @@ SerialHandleRecv: ; prepares a byte to send over serial transfer, either from the send-save byte ; slot or the send buffer -SerialHandleSend: +SerialHandleSend:: ld hl, wSerialSendSave ld a, [hl] or a @@ -260,7 +260,7 @@ SerialHandleSend: ret ; store byte at a in wSerialSendBuf for sending -SerialSendByte: +SerialSendByte:: push hl push de push bc @@ -290,7 +290,7 @@ SerialSendByte: ret ; sets carry if [wSerialRecvCounter] nonzero -Func_0e32: +Func_0e32:: ld a, [wSerialRecvCounter] or a ret z @@ -298,7 +298,7 @@ Func_0e32: ret ; receive byte in wSerialRecvBuf -SerialRecvByte: +SerialRecvByte:: push hl ld hl, wSerialRecvCounter ld a, [hl] @@ -331,7 +331,7 @@ SerialRecvByte: ret ; exchange c bytes. send bytes at hl and store received bytes in de -SerialExchangeBytes: +SerialExchangeBytes:: ld b, c .asm_e64 ld a, b @@ -368,7 +368,7 @@ SerialExchangeBytes: ret ; go into slave mode (external clock) for serial transfer? -Func_0e8e: +Func_0e8e:: call ClearSerialData ld a, $12 ldh [rSB], a ; send $12 @@ -383,7 +383,7 @@ Func_0e8e: ret ; disable serial interrupt, and clear rSB, rSC, and serial registers in WRAM -ResetSerial: +ResetSerial:: ldh a, [rIE] and ~(1 << INT_SERIAL) ldh [rIE], a @@ -393,7 +393,7 @@ ResetSerial: ; fallthrough ; zero serial registers in WRAM -ClearSerialData: +ClearSerialData:: ld hl, wSerialOp ld bc, wSerialEnd - wSerialOp .loop @@ -406,7 +406,7 @@ ClearSerialData: ret ; store bc bytes from hl in wSerialSendBuf for sending -SerialSendBytes: +SerialSendBytes:: push bc .send_loop ld a, [hli] @@ -427,7 +427,7 @@ SerialSendBytes: ret ; receive bc bytes in wSerialRecvBuf and save them to hl -SerialRecvBytes: +SerialRecvBytes:: push bc .recv_loop call SerialRecvByte @@ -452,7 +452,7 @@ SerialRecvBytes: scf ret -Func_0ef1: +Func_0ef1:: ld de, wcb79 ld hl, sp+$fe ld a, l @@ -471,7 +471,7 @@ Func_0ef1: or a ret -Func_0f05: +Func_0f05:: push hl ld hl, wcb7b ld a, [hli] @@ -491,7 +491,7 @@ Func_0f05: scf ret -Func_0f1d: +Func_0f1d:: ld a, [wSerialFlags] or a jr nz, .asm_f27 @@ -510,7 +510,7 @@ Func_0f1d: ; load the number at wSerialFlags (error code?) to TxRam3, print ; TransmissionErrorText, exit the duel, and reset serial registers. -DuelTransmissionError: +DuelTransmissionError:: ld a, [wSerialFlags] ld l, a ld h, 0 @@ -530,7 +530,7 @@ DuelTransmissionError: ret ; exchange RNG during a link duel between both games -ExchangeRNG: +ExchangeRNG:: ld a, [wDuelType] cp DUELTYPE_LINK jr z, .link_duel @@ -559,7 +559,7 @@ ExchangeRNG: ; finally exchange RNG data. ; the receiving side will use this data to read the OPPACTION_* value in ; [hOppActionTableIndex] and match it by calling the corresponding OppAction* function -SetOppAction_SerialSendDuelData: +SetOppAction_SerialSendDuelData:: push hl push bc ldh [hOppActionTableIndex], a @@ -579,7 +579,7 @@ SetOppAction_SerialSendDuelData: ; receive 10 bytes of data from wSerialRecvBuf and store them into hOppActionTableIndex, ; hTempCardIndex_ff9f, hTemp_ffa0, and hTempPlayAreaLocation_ffa1, ; and hTempRetreatCostCards. also exchange RNG data. -SerialRecvDuelData: +SerialRecvDuelData:: push hl push bc ld hl, hOppActionTableIndex @@ -592,7 +592,7 @@ SerialRecvDuelData: ; serial send 8 bytes at f, a, l, h, e, d, c, b ; only during a duel against a link opponent -SerialSend8Bytes: +SerialSend8Bytes:: push hl push af ld a, DUELVARS_DUELIST_TYPE @@ -643,7 +643,7 @@ SerialSend8Bytes: ret ; serial recv 8 bytes to f, a, l, h, e, d, c, b -SerialRecv8Bytes: +SerialRecv8Bytes:: ld hl, wTempSerialBuf ld bc, 8 push hl diff --git a/src/home/setup.asm b/src/home/setup.asm index 10ecc70f..fb4e76b3 100644 --- a/src/home/setup.asm +++ b/src/home/setup.asm @@ -1,6 +1,6 @@ ; initialize scroll, window, and lcdc registers, set trampoline functions ; for the lcdc and vblank interrupts, latch clock data, and enable SRAM/RTC -SetupRegisters: +SetupRegisters:: xor a ldh [rSCY], a ldh [rSCX], a @@ -28,11 +28,11 @@ SetupRegisters: ld [MBC3LatchClock], a ld a, SRAM_ENABLE ld [MBC3SRamEnable], a -NoOp: +NoOp:: ret ; sets wConsole and, if CGB, selects WRAM bank 1 and switches to double speed mode -DetectConsole: +DetectConsole:: ld b, CONSOLE_CGB cp GBC jr z, .got_console @@ -52,7 +52,7 @@ DetectConsole: ret ; initialize the palettes (both monochrome and color) -SetupPalettes: +SetupPalettes:: ld hl, wBGP ld a, %11100100 ldh [rBGP], a @@ -82,14 +82,14 @@ SetupPalettes: call FlushAllCGBPalettes ret -InitialPalette: +InitialPalette:: rgb 28, 28, 24 rgb 21, 21, 16 rgb 10, 10, 08 rgb 00, 00, 00 ; clear VRAM tile data ([wTileMapFill] should be an empty tile) -SetupVRAM: +SetupVRAM:: call FillTileMap call CheckForCGB jr c, .vram0 @@ -109,7 +109,7 @@ SetupVRAM: ret ; fill VRAM0 BG map 0 with [wTileMapFill] and VRAM1 BG map 0 with $00 -FillTileMap: +FillTileMap:: call BankswitchVRAM0 ld hl, v0BGMap0 ld bc, v0BGMap1 - v0BGMap0 @@ -137,7 +137,7 @@ FillTileMap: ret ; zero work RAM, stack area, and high RAM ($C000-$DFFF, $FF80-$FFEF) -ZeroRAM: +ZeroRAM:: ld hl, $c000 ld bc, $e000 - $c000 .zero_wram_loop diff --git a/src/home/sgb.asm b/src/home/sgb.asm index 6df9095a..c2e5161b 100644 --- a/src/home/sgb.asm +++ b/src/home/sgb.asm @@ -1,5 +1,5 @@ ; setup SNES memory $810-$867 and palette -InitSGB: +InitSGB:: ld hl, MaskEnPacket_Freeze call SendSGB ld hl, DataSndPacket1 @@ -24,65 +24,65 @@ InitSGB: call SendSGB ret -DataSndPacket1: +DataSndPacket1:: sgb DATA_SND, 1 ; sgb_command, length dwb $085d, $00 ; destination address, bank db $0b ; number of bytes to write db $8c, $d0, $f4, $60, $00, $00, $00, $00, $00, $00, $00 ; data bytes -DataSndPacket2: +DataSndPacket2:: sgb DATA_SND, 1 ; sgb_command, length dwb $0852, $00 ; destination address, bank db $0b ; number of bytes to write db $a9, $e7, $9f, $01, $c0, $7e, $e8, $e8, $e8, $e8, $e0 ; data bytes -DataSndPacket3: +DataSndPacket3:: sgb DATA_SND, 1 ; sgb_command, length dwb $0847, $00 ; destination address, bank db $0b ; number of bytes to write db $c4, $d0, $16, $a5, $cb, $c9, $05, $d0, $10, $a2, $28 ; data bytes -DataSndPacket4: +DataSndPacket4:: sgb DATA_SND, 1 ; sgb_command, length dwb $083c, $00 ; destination address, bank db $0b ; number of bytes to write db $f0, $12, $a5, $c9, $c9, $c8, $d0, $1c, $a5, $ca, $c9 ; data bytes -DataSndPacket5: +DataSndPacket5:: sgb DATA_SND, 1 ; sgb_command, length dwb $0831, $00 ; destination address, bank db $0b ; number of bytes to write db $0c, $a5, $ca, $c9, $7e, $d0, $06, $a5, $cb, $c9, $7e ; data bytes -DataSndPacket6: +DataSndPacket6:: sgb DATA_SND, 1 ; sgb_command, length dwb $0826, $00 ; destination address, bank db $0b ; number of bytes to write db $39, $cd, $48, $0c, $d0, $34, $a5, $c9, $c9, $80, $d0 ; data bytes -DataSndPacket7: +DataSndPacket7:: sgb DATA_SND, 1 ; sgb_command, length dwb $081b, $00 ; destination address, bank db $0b ; number of bytes to write db $ea, $ea, $ea, $ea, $ea, $a9, $01, $cd, $4f, $0c, $d0 ; data bytes -DataSndPacket8: +DataSndPacket8:: sgb DATA_SND, 1 ; sgb_command, length dwb $0810, $00 ; destination address, bank db $0b ; number of bytes to write db $4c, $20, $08, $ea, $ea, $ea, $ea, $ea, $60, $ea, $ea ; data bytes -MaskEnPacket_Freeze: +MaskEnPacket_Freeze:: sgb MASK_EN, 1 ; sgb_command, length db MASK_EN_FREEZE_SCREEN ds $0e -MaskEnPacket_Cancel: +MaskEnPacket_Cancel:: sgb MASK_EN, 1 ; sgb_command, length db MASK_EN_CANCEL_MASK ds $0e -Pal01Packet_InitSGB: +Pal01Packet_InitSGB:: sgb PAL01, 1 ; sgb_command, length rgb 28, 28, 24 rgb 20, 20, 16 @@ -93,7 +93,7 @@ Pal01Packet_InitSGB: rgb 7, 0, 0 db $00 -Pal23Packet_0b00: +Pal23Packet_0b00:: sgb PAL23, 1 ; sgb_command, length rgb 0, 31, 0 rgb 0, 15, 0 @@ -104,7 +104,7 @@ Pal23Packet_0b00: rgb 0, 0, 7 db $00 -AttrBlkPacket_0b10: +AttrBlkPacket_0b10:: sgb ATTR_BLK, 1 ; sgb_command, length db 1 ; number of data sets ; Control Code, Color Palette Designation, X1, Y1, X2, Y2 @@ -113,7 +113,7 @@ AttrBlkPacket_0b10: ds 2 ; data set 3 ; send SGB packet at hl (or packets, if length > 1) -SendSGB: +SendSGB:: ld a, [hl] and $7 ret z ; return if packet length is 0 @@ -157,7 +157,7 @@ SendSGB: ; SGB hardware detection ; return carry if SGB detected and disable multi-controller mode before returning -DetectSGB: +DetectSGB:: ld bc, 60 call Wait ld hl, MltReq2Packet @@ -199,12 +199,12 @@ DetectSGB: scf ret -MltReq1Packet: +MltReq1Packet:: sgb MLT_REQ, 1 ; sgb_command, length db MLT_REQ_1_PLAYER ds $0e -MltReq2Packet: +MltReq2Packet:: sgb MLT_REQ, 1 ; sgb_command, length db MLT_REQ_2_PLAYERS ds $0e @@ -212,7 +212,7 @@ MltReq2Packet: ; fill v*Tiles1 and v*Tiles2 with data at hl ; write $0d sequences of $80,$81,$82,...,$94 separated each by $0c bytes to v*BGMap0 ; send the SGB packet at de -Func_0bcb: +Func_0bcb:: di push de .wait_vblank @@ -255,7 +255,7 @@ Func_0bcb: ret ; loops 63000 * bc cycles (~15 * bc ms) -Wait: +Wait:: ld de, 1750 .loop nop diff --git a/src/home/sound.asm b/src/home/sound.asm index 67427582..20beae19 100644 --- a/src/home/sound.asm +++ b/src/home/sound.asm @@ -1,38 +1,38 @@ -SetupSound: +SetupSound:: farcall _SetupSound ret -StopMusic: +StopMusic:: xor a ; MUSIC_STOP -PlaySong: +PlaySong:: farcall _PlaySong ret -; return a = 0: song finished, a = 1: song not finished -AssertSongFinished: +; return a = 0:: song finished, a = 1:: song not finished +AssertSongFinished:: farcall _AssertSongFinished ret -; return a = 0: SFX finished, a = 1: SFX not finished -AssertSFXFinished: +; return a = 0:: SFX finished, a = 1:: SFX not finished +AssertSFXFinished:: farcall _AssertSFXFinished ret -Func_3794: +Func_3794:: ld a, $04 -PlaySFX: +PlaySFX:: farcall _PlaySFX ret -PauseSong: +PauseSong:: farcall _PauseSong ret -ResumeSong: +ResumeSong:: farcall _ResumeSong ret -Func_37a5: +Func_37a5:: ldh a, [hBankROM] push af push hl @@ -53,7 +53,7 @@ Func_37a5: call BankswitchROM ret -Func_37c5: +Func_37c5:: ld c, $08 .asm_37c7 ld b, $06 diff --git a/src/home/sram.asm b/src/home/sram.asm index b10ac3da..2280ae8f 100644 --- a/src/home/sram.asm +++ b/src/home/sram.asm @@ -1,5 +1,5 @@ ; switch SRAM bank to a -BankswitchSRAM: +BankswitchSRAM:: push af ldh [hBankSRAM], a ld [MBC3SRamBank], a @@ -9,7 +9,7 @@ BankswitchSRAM: ret ; enable external RAM (SRAM) -EnableSRAM: +EnableSRAM:: push af ld a, SRAM_ENABLE ld [MBC3SRamEnable], a @@ -17,7 +17,7 @@ EnableSRAM: ret ; disable external RAM (SRAM) -DisableSRAM: +DisableSRAM:: push af xor a ; SRAM_DISABLE ld [MBC3SRamEnable], a diff --git a/src/home/start.asm b/src/home/start.asm index 6a026601..89683ceb 100644 --- a/src/home/start.asm +++ b/src/home/start.asm @@ -1,5 +1,5 @@ SECTION "start", ROM0 -Start: +Start:: di ld sp, $fffe push af diff --git a/src/home/substatus.asm b/src/home/substatus.asm index bc93422c..bd2b3907 100644 --- a/src/home/substatus.asm +++ b/src/home/substatus.asm @@ -1,6 +1,6 @@ ; doubles the damage at de if swords dance or focus energy was used ; in the last turn by the turn holder's arena Pokemon -HandleDoubleDamageSubstatus: +HandleDoubleDamageSubstatus:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS3 call GetTurnDuelistVariable bit SUBSTATUS3_THIS_TURN_DOUBLE_DAMAGE, [hl] @@ -31,7 +31,7 @@ HandleDoubleDamageSubstatus: ; check if the defending card (turn holder's arena card) has any substatus that ; reduces the damage dealt to it this turn (SUBSTATUS1 or Pkmn Powers). ; damage is given in de as input and the possibly updated damage is also returned in de. -HandleDamageReduction: +HandleDamageReduction:: call HandleDamageReductionExceptSubstatus2 ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetNonTurnDuelistVariable @@ -60,7 +60,7 @@ HandleDamageReduction: ; check if the defending card (turn holder's arena card) has any substatus that ; reduces the damage dealt to it this turn. (SUBSTATUS1 or Pkmn Powers) ; damage is given in de as input and the possibly updated damage is also returned in de. -HandleDamageReductionExceptSubstatus2: +HandleDamageReductionExceptSubstatus2:: ld a, [wNoDamageOrEffect] or a jr nz, .no_damage @@ -150,7 +150,7 @@ HandleDamageReductionExceptSubstatus2: ; check for Invisible Wall, Kabuto Armor, NShield, or Transparency, in order to ; possibly reduce or make zero the damage at de. -HandleDamageReductionOrNoDamageFromPkmnPowerEffects: +HandleDamageReductionOrNoDamageFromPkmnPowerEffects:: ld a, [wLoadedAttackCategory] cp POKEMON_POWER ret z @@ -173,7 +173,7 @@ HandleDamageReductionOrNoDamageFromPkmnPowerEffects: ; attacking Pokemon (turn holder's arena Pokemon) takes 10 damage. ; ignore if damage taken at de is 0. ; used to bounce back a damaging attack. -HandleStrikesBack_AgainstDamagingAttack: +HandleStrikesBack_AgainstDamagingAttack:: ld a, e or d ret z @@ -233,7 +233,7 @@ HandleStrikesBack_AgainstDamagingAttack: ; return carry if NShield or Transparency activate (if MEW_LV8 or HAUNTER_LV17 is ; the turn holder's arena Pokemon), and print their corresponding text if so -HandleNShieldAndTransparency: +HandleNShieldAndTransparency:: push de ld a, DUELVARS_ARENA_CARD add e @@ -274,7 +274,7 @@ HandleNShieldAndTransparency: ; return carry if the turn holder's arena Pokemon is under a condition that makes ; it unable to attack. also return in hl the text id to be displayed -HandleCantAttackSubstatus: +HandleCantAttackSubstatus:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetTurnDuelistVariable or a @@ -296,7 +296,7 @@ HandleCantAttackSubstatus: ; return carry if the turn holder's arena Pokemon cannot use ; selected attack at wSelectedAttack due to amnesia -HandleAmnesiaSubstatus: +HandleAmnesiaSubstatus:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetTurnDuelistVariable or a @@ -319,7 +319,7 @@ HandleAmnesiaSubstatus: ret ; return carry if the turn holder's attack was unsuccessful due to sand attack or smokescreen effect -HandleSandAttackOrSmokescreenSubstatus: +HandleSandAttackOrSmokescreenSubstatus:: call CheckSandAttackOrSmokescreenSubstatus ret nc call TossCoin @@ -332,7 +332,7 @@ HandleSandAttackOrSmokescreenSubstatus: ret ; return carry if the turn holder's arena card is under the effects of sand attack or smokescreen -CheckSandAttackOrSmokescreenSubstatus: +CheckSandAttackOrSmokescreenSubstatus:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetTurnDuelistVariable or a @@ -355,7 +355,7 @@ CheckSandAttackOrSmokescreenSubstatus: ; return carry if the defending card (turn holder's arena card) is under a substatus ; that prevents any damage or effect dealt to it for a turn. ; also return the cause of the substatus in wNoDamageOrEffect -HandleNoDamageOrEffectSubstatus: +HandleNoDamageOrEffectSubstatus:: xor a ld [wNoDamageOrEffect], a ld a, [wLoadedAttackCategory] @@ -408,7 +408,7 @@ HandleNoDamageOrEffectSubstatus: ; if the Pokemon being attacked is HAUNTER_LV17, and its Transparency is active, ; there is a 50% chance that any damage or effect is prevented ; return carry if damage is prevented -HandleTransparency: +HandleTransparency:: ld a, [wTempNonTurnDuelistCardID] cp HAUNTER_LV17 jr z, .transparency @@ -435,8 +435,8 @@ HandleTransparency: ; return carry and return the appropriate text id in hl if the target has an ; special status or power that prevents any damage or effect done to it this turn -; input: a = NO_DAMAGE_OR_EFFECT_* -CheckNoDamageOrEffect: +; input:: a = NO_DAMAGE_OR_EFFECT_* +CheckNoDamageOrEffect:: ld a, [wNoDamageOrEffect] or a ret z @@ -461,7 +461,7 @@ CheckNoDamageOrEffect: scf ret -NoDamageOrEffectTextIDTable: +NoDamageOrEffectTextIDTable:: tx NoDamageOrEffectDueToAgilityText ; NO_DAMAGE_OR_EFFECT_AGILITY tx NoDamageOrEffectDueToBarrierText ; NO_DAMAGE_OR_EFFECT_BARRIER tx NoDamageOrEffectDueToFlyText ; NO_DAMAGE_OR_EFFECT_FLY @@ -469,7 +469,7 @@ NoDamageOrEffectTextIDTable: tx NoDamageOrEffectDueToNShieldText ; NO_DAMAGE_OR_EFFECT_NSHIELD ; return carry if turn holder has Omanyte and its Clairvoyance Pkmn Power is active -IsClairvoyanceActive: +IsClairvoyanceActive:: ld a, MUK call CountPokemonIDInBothPlayAreas ccf @@ -480,11 +480,11 @@ IsClairvoyanceActive: ; returns carry if turn holder's arena card is paralyzed, asleep, confused, ; and/or toxic gas in play, meaning that attack and/or pkmn power cannot be used -CheckCannotUseDueToStatus: +CheckCannotUseDueToStatus:: xor a ; same as above, but if a is non-0, only toxic gas is checked -CheckCannotUseDueToStatus_OnlyToxicGasIfANon0: +CheckCannotUseDueToStatus_OnlyToxicGasIfANon0:: or a jr nz, .check_toxic_gas ld a, DUELVARS_ARENA_CARD_STATUS @@ -503,8 +503,8 @@ CheckCannotUseDueToStatus_OnlyToxicGasIfANon0: ; return, in a, the amount of times that the Pokemon card with a given ID is found in the ; play area of both duelists. Also return carry if the Pokemon card is at least found once. ; if the arena Pokemon is asleep, confused, or paralyzed (Pkmn Power-incapable), it doesn't count. -; input: a = Pokemon card ID to search -CountPokemonIDInBothPlayAreas: +; input:: a = Pokemon card ID to search +CountPokemonIDInBothPlayAreas:: push bc ld [wTempPokemonID_ce7c], a call CountPokemonIDInPlayArea @@ -525,8 +525,8 @@ CountPokemonIDInBothPlayAreas: ; return, in a, the amount of times that the Pokemon card with a given ID is found in the ; turn holder's play area. Also return carry if the Pokemon card is at least found once. ; if the arena Pokemon is asleep, confused, or paralyzed (Pkmn Power-incapable), it doesn't count. -; input: a = Pokemon card ID to search -CountPokemonIDInPlayArea: +; input:: a = Pokemon card ID to search +CountPokemonIDInPlayArea:: push hl push de push bc @@ -574,7 +574,7 @@ CountPokemonIDInPlayArea: ; return, in a, the retreat cost of the card in wLoadedCard1, ; adjusting for any Dodrio's Retreat Aid Pkmn Power that is active. -GetLoadedCard1RetreatCost: +GetLoadedCard1RetreatCost:: ld c, 0 ld a, DUELVARS_BENCH call GetTurnDuelistVariable @@ -607,7 +607,7 @@ GetLoadedCard1RetreatCost: ret ; return carry if the turn holder's arena Pokemon is affected by Acid and can't retreat -CheckCantRetreatDueToAcid: +CheckCantRetreatDueToAcid:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetTurnDuelistVariable or a @@ -622,7 +622,7 @@ CheckCantRetreatDueToAcid: ret ; return carry if the turn holder is affected by Headache and trainer cards can't be used -CheckCantUseTrainerDueToHeadache: +CheckCantUseTrainerDueToHeadache:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS3 call GetTurnDuelistVariable or a @@ -633,7 +633,7 @@ CheckCantUseTrainerDueToHeadache: ret ; return carry if any duelist has Aerodactyl and its Prehistoric Power Pkmn Power is active -IsPrehistoricPowerActive: +IsPrehistoricPowerActive:: ld a, AERODACTYL call CountPokemonIDInBothPlayAreas ret nc @@ -646,7 +646,7 @@ IsPrehistoricPowerActive: ; clears some SUBSTATUS2 conditions from the turn holder's active Pokemon. ; more specifically, those conditions that reduce the damage from an attack ; or prevent the opposing Pokemon from attacking the substatus condition inducer. -ClearDamageReductionSubstatus2: +ClearDamageReductionSubstatus2:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetTurnDuelistVariable or a @@ -667,7 +667,7 @@ ClearDamageReductionSubstatus2: ret ; clears the SUBSTATUS1 and updates the double damage condition of the player about to start his turn -UpdateSubstatusConditions_StartOfTurn: +UpdateSubstatusConditions_StartOfTurn:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS1 call GetTurnDuelistVariable ld [hl], $0 @@ -681,7 +681,7 @@ UpdateSubstatusConditions_StartOfTurn: ret ; clears the SUBSTATUS2, Headache, and updates the double damage condition of the player ending his turn -UpdateSubstatusConditions_EndOfTurn: +UpdateSubstatusConditions_EndOfTurn:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS3 call GetTurnDuelistVariable res SUBSTATUS3_HEADACHE, [hl] @@ -699,7 +699,7 @@ UpdateSubstatusConditions_EndOfTurn: ret ; return carry if turn holder has Blastoise and its Rain Dance Pkmn Power is active -IsRainDanceActive: +IsRainDanceActive:: ld a, BLASTOISE call CountPokemonIDInPlayArea ret nc ; return if no Pkmn Power-capable Blastoise found in turn holder's play area @@ -710,7 +710,7 @@ IsRainDanceActive: ; return carry if card at [hTempCardIndex_ff98] is a water energy card AND ; if card at [hTempPlayAreaLocation_ff9d] is a water Pokemon card. -CheckRainDanceScenario: +CheckRainDanceScenario:: ldh a, [hTempCardIndex_ff98] call GetCardIDFromDeckIndex call GetCardType @@ -728,7 +728,7 @@ CheckRainDanceScenario: ; if the defending (non-turn) card's HP is 0 and the attacking (turn) card's HP ; is not, the attacking card faints if it was affected by destiny bond -HandleDestinyBondSubstatus: +HandleDestinyBondSubstatus:: ld a, DUELVARS_ARENA_CARD_SUBSTATUS1 call GetNonTurnDuelistVariable cp SUBSTATUS1_DESTINY_BOND @@ -768,7 +768,7 @@ HandleDestinyBondSubstatus: ; when MACHAMP is damaged, if its Strikes Back is active, the ; attacking Pokemon (turn holder's arena Pokemon) takes 10 damage. ; used to bounce back an attack of the RESIDUAL category -HandleStrikesBack_AgainstResidualAttack: +HandleStrikesBack_AgainstResidualAttack:: ld a, [wTempNonTurnDuelistCardID] cp MACHAMP jr z, .strikes_back @@ -789,7 +789,7 @@ HandleStrikesBack_AgainstResidualAttack: call nc, WaitForWideTextBoxInput ret -ApplyStrikesBack_AgainstResidualAttack: +ApplyStrikesBack_AgainstResidualAttack:: push hl call LoadTxRam3 ld a, [wTempTurnDuelistCardID] @@ -822,7 +822,7 @@ ApplyStrikesBack_AgainstResidualAttack: ; if the id of the card provided in register a as a deck index is MUK, ; clear the changed type of all arena and bench Pokemon -ClearChangedTypesIfMuk: +ClearChangedTypesIfMuk:: call GetCardIDFromDeckIndex ld a, e cp MUK diff --git a/src/home/switch_rom.asm b/src/home/switch_rom.asm index ab0736f8..38951cd3 100644 --- a/src/home/switch_rom.asm +++ b/src/home/switch_rom.asm @@ -1,7 +1,7 @@ ; switch to rombank (a + top2 of h shifted down), ; set top2 of h to 01 (switchable ROM bank area), ; return old rombank id on top-of-stack -BankpushROM: +BankpushROM:: push hl push bc push af @@ -38,7 +38,7 @@ BankpushROM: ; switch to rombank a, ; return old rombank id on top-of-stack -BankpushROM2: +BankpushROM2:: push hl push bc push af @@ -66,7 +66,7 @@ BankpushROM2: ret ; restore rombank from top-of-stack -BankpopROM: +BankpopROM:: push hl push de ld hl, sp+$7 @@ -87,7 +87,7 @@ BankpopROM: ret ; switch ROM bank to a -BankswitchROM: +BankswitchROM:: ldh [hBankROM], a ld [MBC3RomBank], a ret diff --git a/src/home/text_box.asm b/src/home/text_box.asm index 209a8a35..777cfe0c 100644 --- a/src/home/text_box.asm +++ b/src/home/text_box.asm @@ -1,7 +1,7 @@ ; copy c bytes of data from de to hl ; if LCD on, copy during h-blank only -SafeCopyDataDEtoHL: +SafeCopyDataDEtoHL:: ld a, [wLCDC] ; bit LCDC_ENABLE_F, a ; jr nz, .lcd_on ; assert that LCD is on @@ -17,7 +17,7 @@ SafeCopyDataDEtoHL: ; returns v*BGMap0 + BG_MAP_WIDTH * e + d in hl. ; used to map coordinates at de to a BGMap0 address. -DECoordToBGMap0Address: +DECoordToBGMap0Address:: ld l, e ld h, $0 add hl, hl @@ -34,7 +34,7 @@ DECoordToBGMap0Address: ret ; Apply SCX and SCY correction to xy coordinates at de -AdjustCoordinatesForBGScroll: +AdjustCoordinatesForBGScroll:: push af ldh a, [hSCX] rra @@ -56,7 +56,7 @@ AdjustCoordinatesForBGScroll: ; Draws a bxc text box at de printing a name in the left side of the top border. ; The name's text id must be at hl when this function is called. ; Mostly used to print text boxes for talked-to NPCs, but occasionally used in duels as well. -DrawLabeledTextBox: +DrawLabeledTextBox:: ld a, [wConsole] cp CONSOLE_SGB jr nz, .draw_textbox @@ -150,7 +150,7 @@ DrawLabeledTextBox: ; Draws a bxc text box at de to print menu data in the overworld. ; Also used to print a text box during a duel. ; When talking to NPCs, DrawLabeledTextBox is used instead. -DrawRegularTextBox: +DrawRegularTextBox:: ld a, [wConsole] cp CONSOLE_CGB jr z, DrawRegularTextBoxCGB @@ -158,7 +158,7 @@ DrawRegularTextBox: jp z, DrawRegularTextBoxSGB ; fallthrough -DrawRegularTextBoxDMG: +DrawRegularTextBoxDMG:: call DECoordToBGMap0Address ; top line (border) of the text box ld a, SYM_BOX_TOP @@ -166,9 +166,9 @@ DrawRegularTextBoxDMG: call CopyLine ; fallthrough -; continue drawing a labeled or regular textbox on DMG or SGB: +; continue drawing a labeled or regular textbox on DMG or SGB:: ; body and bottom line of either type of textbox -ContinueDrawingTextBoxDMGorSGB: +ContinueDrawingTextBoxDMGorSGB:: dec c dec c .draw_text_box_body_loop @@ -187,7 +187,7 @@ ContinueDrawingTextBoxDMGorSGB: ; e = value of byte b ; a = value of bytes [1, b-1] ; b is supposed to be BG_MAP_WIDTH or smaller, else the stack would get corrupted -CopyLine: +CopyLine:: add sp, -BG_MAP_WIDTH push hl push bc @@ -219,7 +219,7 @@ CopyLine: ret ; DrawRegularTextBox branches here on CGB console -DrawRegularTextBoxCGB: +DrawRegularTextBoxCGB:: call DECoordToBGMap0Address ; top line (border) of the text box ld a, SYM_BOX_TOP @@ -227,9 +227,9 @@ DrawRegularTextBoxCGB: call CopyCurrentLineTilesAndAttrCGB ; fallthrough -; continue drawing a labeled or regular textbox on CGB: +; continue drawing a labeled or regular textbox on CGB:: ; body and bottom line of either type of textbox -ContinueDrawingTextBoxCGB: +ContinueDrawingTextBoxCGB:: dec c dec c .draw_text_box_body_loop @@ -257,13 +257,13 @@ ContinueDrawingTextBoxCGB: ; e = id of top right tile ; a = id of rest of tiles ; Assumes b = SCREEN_WIDTH and that VRAM bank 0 is loaded -CopyCurrentLineTilesAndAttrCGB: +CopyCurrentLineTilesAndAttrCGB:: push hl call CopyLine pop hl ; fallthrough -CopyCurrentLineAttrCGB: +CopyCurrentLineAttrCGB:: call BankswitchVRAM1 ld a, [wTextBoxFrameType] ; on CGB, wTextBoxFrameType determines the palette and the other attributes ld e, a @@ -273,7 +273,7 @@ CopyCurrentLineAttrCGB: ret ; DrawRegularTextBox branches here on SGB console -DrawRegularTextBoxSGB: +DrawRegularTextBoxSGB:: push bc push de call DrawRegularTextBoxDMG @@ -284,7 +284,7 @@ DrawRegularTextBoxSGB: ret z ; fallthrough -ColorizeTextBoxSGB: +ColorizeTextBoxSGB:: push bc push de ld hl, wTempSGBPacket @@ -326,7 +326,7 @@ ColorizeTextBoxSGB: call SendSGB ret -AttrBlkPacket_TextBox: +AttrBlkPacket_TextBox:: sgb ATTR_BLK, 1 ; sgb_command, length db 1 ; number of data sets ; Control Code, Color Palette Designation, X1, Y1, X2, Y2 diff --git a/src/home/tiles.asm b/src/home/tiles.asm index 2ebf3e7d..dce33cb7 100644 --- a/src/home/tiles.asm +++ b/src/home/tiles.asm @@ -1,9 +1,9 @@ ; Fill a bxc rectangle at de and at sp-$26, -; using tile a and the subsequent ones in the following pattern: +; using tile a and the subsequent ones in the following pattern:: ; | a+0*l+0*h | a+0*l+1*h | a+0*l+2*h | ; | a+1*l+0*h | a+1*l+1*h | a+1*l+2*h | ; | a+2*l+0*h | a+2*l+1*h | a+2*l+2*h | -FillRectangle: +FillRectangle:: push de push af push hl @@ -46,7 +46,7 @@ FillRectangle: pop de ret -Func_1f96: +Func_1f96:: add sp, -10 ld hl, sp+0 ld [hli], a ; sp-10 <- a @@ -179,7 +179,7 @@ Func_1f96: scf ret -Func_2046: +Func_2046:: ld hl, sp+3 ld a, [hl] inc [hl] @@ -189,15 +189,15 @@ Func_2046: jr z, Func_2055 ; fallthrough -Func_2051: +Func_2051:: ld hl, sp+9 jr Func_2057 -Func_2055: +Func_2055:: ld hl, sp+8 ; fallthrough -Func_2057: +Func_2057:: ld e, [hl] ld hl, sp+2 ld a, [hl] @@ -212,7 +212,7 @@ Func_2057: ; loads the four tiles of the card set 2 icon constant provided in register a ; returns carry if the specified set does not have an icon -LoadCardSet2Tiles: +LoadCardSet2Tiles:: and $7 ; mask out PRO ld e, a ld d, 0 @@ -237,7 +237,7 @@ LoadCardSet2Tiles: db -1, $0 tiles, $4 tiles, -1, -1, -1, -1, $8 tiles ; loads the Deck and Hand icons for the "Draw X card(s) from the deck." screen -LoadDuelDrawCardsScreenTiles: +LoadDuelDrawCardsScreenTiles:: ld hl, DuelOtherGraphics + $29 tiles ld de, v0Tiles1 + $74 tiles ld b, $08 @@ -245,7 +245,7 @@ LoadDuelDrawCardsScreenTiles: ; loads the 8 tiles that make up the border of the main duel menu as well as the border ; of a large card picture (displayed after drawing the card or placing it in the arena). -LoadCardOrDuelMenuBorderTiles: +LoadCardOrDuelMenuBorderTiles:: ld hl, DuelOtherGraphics + $15 tiles ld de, v0Tiles1 + $50 tiles ld b, $08 @@ -253,7 +253,7 @@ LoadCardOrDuelMenuBorderTiles: ; loads the graphics of a card type header, used to display a picture of a card after drawing it ; or placing it in the arena. register e determines which header (TRAINER, ENERGY, PoKéMoN) -LoadCardTypeHeaderTiles: +LoadCardTypeHeaderTiles:: ld d, a ld e, 0 ld hl, DuelCardHeaderGraphics - $4000 @@ -263,7 +263,7 @@ LoadCardTypeHeaderTiles: jr CopyFontsOrDuelGraphicsTiles ; loads the symbols that are displayed near the names of a list of cards in the hand or discard pile -LoadDuelCardSymbolTiles: +LoadDuelCardSymbolTiles:: ld hl, DuelDmgSgbSymbolGraphics - $4000 ld a, [wConsole] cp CONSOLE_CGB @@ -276,7 +276,7 @@ LoadDuelCardSymbolTiles: ; loads the symbols for Stage 1 Pkmn card, Stage 2 Pkmn card, and Trainer card. ; unlike LoadDuelCardSymbolTiles excludes the symbols for Basic Pkmn and all energies. -LoadDuelCardSymbolTiles2: +LoadDuelCardSymbolTiles2:: ld hl, DuelDmgSgbSymbolGraphics + $4 tiles - $4000 ld a, [wConsole] cp CONSOLE_CGB @@ -288,12 +288,12 @@ LoadDuelCardSymbolTiles2: jr CopyFontsOrDuelGraphicsTiles ; load the face down basic / stage1 / stage2 card images shown in the check Pokemon screens -LoadDuelFaceDownCardTiles: +LoadDuelFaceDownCardTiles:: ld b, $10 jr LoadDuelCheckPokemonScreenTiles.got_num_tiles ; same as LoadDuelFaceDownCardTiles, plus also load the ACT / BPx tiles -LoadDuelCheckPokemonScreenTiles: +LoadDuelCheckPokemonScreenTiles:: ld b, $24 .got_num_tiles ld hl, DuelDmgSgbSymbolGraphics + $30 tiles - $4000 @@ -306,7 +306,7 @@ LoadDuelCheckPokemonScreenTiles: jr CopyFontsOrDuelGraphicsTiles ; load the tiles for the "Placing the prizes..." screen -LoadPlacingThePrizesScreenTiles: +LoadPlacingThePrizesScreenTiles:: ; load the Pokeball field tiles ld hl, DuelOtherGraphics ld de, v0Tiles1 + $20 tiles @@ -315,7 +315,7 @@ LoadPlacingThePrizesScreenTiles: ; fallthrough ; load the Deck and the Discard Pile icons -LoadDeckAndDiscardPileIcons: +LoadDeckAndDiscardPileIcons:: ld hl, DuelDmgSgbSymbolGraphics + $54 tiles - $4000 ld a, [wConsole] cp CONSOLE_CGB @@ -327,24 +327,24 @@ LoadDeckAndDiscardPileIcons: jr CopyFontsOrDuelGraphicsTiles ; load the tiles for the [O] and [X] symbols used to display the results of a coin toss -LoadDuelCoinTossResultTiles: +LoadDuelCoinTossResultTiles:: ld hl, DuelOtherGraphics + $d tiles ld de, v0Tiles2 + $30 tiles ld b, $8 jr CopyFontsOrDuelGraphicsTiles ; load the tiles of the text characters used with TX_SYMBOL -LoadSymbolsFont: +LoadSymbolsFont:: ld hl, SymbolsFont - $4000 ld de, v0Tiles2 ; destination ld b, (DuelCardHeaderGraphics - SymbolsFont) / TILE_SIZE ; number of tiles ; fallthrough ; if hl ≤ $3fff -; copy b tiles from Gfx1:(hl+$4000) to de +; copy b tiles from Gfx1::(hl+$4000) to de ; if $4000 ≤ hl ≤ $7fff -; copy b tiles from Gfx2:hl to de -CopyFontsOrDuelGraphicsTiles: +; copy b tiles from Gfx2::hl to de +CopyFontsOrDuelGraphicsTiles:: ld a, BANK(Fonts) ; BANK(DuelGraphics) call BankpushROM ld c, TILE_SIZE @@ -353,7 +353,7 @@ CopyFontsOrDuelGraphicsTiles: ret ; this function copies gfx data into sram -Func_212f: +Func_212f:: ; loads symbols fonts to sGfxBuffer1 ld hl, SymbolsFont - $4000 ld de, sGfxBuffer1 @@ -383,7 +383,7 @@ Func_212f: jr CopyFontsOrDuelGraphicsTiles ; load the graphics and draw the duel box message given a BOXMSG_* constant in a -DrawDuelBoxMessage: +DrawDuelBoxMessage:: ld l, a ld h, 40 tiles / 4 ; boxes are 10x4 tiles call HtimesL @@ -403,7 +403,7 @@ DrawDuelBoxMessage: ; load the tiles for the latin, katakana, and hiragana fonts into VRAM ; from gfx/fonts/full_width/3.1bpp and gfx/fonts/full_width/4.1bpp -LoadFullWidthFontTiles: +LoadFullWidthFontTiles:: ld hl, FullWidthFonts + $3cc tiles_1bpp - $4000 ld a, BANK(Fonts) ; BANK(DuelGraphics) call BankpushROM @@ -421,7 +421,7 @@ LoadFullWidthFontTiles: ret ; copy 128 1bpp tiles from de to hl as 2bpp -Copy1bppTiles: +Copy1bppTiles:: ld b, $80 .tile_loop ld c, TILE_SIZE_1BPP diff --git a/src/home/time.asm b/src/home/time.asm index 8b8cda20..f3c76440 100644 --- a/src/home/time.asm +++ b/src/home/time.asm @@ -1,5 +1,5 @@ ; timer interrupt handler -TimerHandler: +TimerHandler:: push af push hl push de @@ -37,7 +37,7 @@ TimerHandler: reti ; increment play time counter by a tick -IncrementPlayTimeCounter: +IncrementPlayTimeCounter:: ld a, [wPlayTimeCounterEnable] or a ret z @@ -67,7 +67,7 @@ IncrementPlayTimeCounter: ret ; setup timer to 16384/68 ≈ 240.94 Hz -SetupTimer: +SetupTimer:: ld b, -68 ; Value for Normal Speed call CheckForCGB jr c, .set_timer @@ -85,7 +85,7 @@ SetupTimer: ret ; return carry if not CGB -CheckForCGB: +CheckForCGB:: ld a, [wConsole] cp CONSOLE_CGB ret z diff --git a/src/home/unsafe_bg_map.asm b/src/home/unsafe_bg_map.asm index fb45c0ef..66967b56 100644 --- a/src/home/unsafe_bg_map.asm +++ b/src/home/unsafe_bg_map.asm @@ -1,8 +1,8 @@ -; reads struct: +; reads struct:: ; x (1 byte), y (1 byte), data (n bytes), $00 ; writes data to BGMap0-translated x,y -; important: make sure VRAM can be accessed first, else use WriteDataBlockToBGMap0 -UnsafeWriteDataBlockToBGMap0: +; important:: make sure VRAM can be accessed first, else use WriteDataBlockToBGMap0 +UnsafeWriteDataBlockToBGMap0:: ld a, [hli] ld b, a ld a, [hli] diff --git a/src/home/vblank.asm b/src/home/vblank.asm index 509d32ff..56d37be0 100644 --- a/src/home/vblank.asm +++ b/src/home/vblank.asm @@ -1,5 +1,5 @@ ; vblank interrupt handler -VBlankHandler: +VBlankHandler:: push af push bc push de diff --git a/src/home/vram.asm b/src/home/vram.asm index 49fc0dea..4666495d 100644 --- a/src/home/vram.asm +++ b/src/home/vram.asm @@ -1,5 +1,5 @@ ; set current dest VRAM bank to 0 -BankswitchVRAM0: +BankswitchVRAM0:: push af xor a ldh [hBankVRAM], a @@ -8,7 +8,7 @@ BankswitchVRAM0: ret ; set current dest VRAM bank to 1 -BankswitchVRAM1: +BankswitchVRAM1:: push af ld a, $1 ldh [hBankVRAM], a @@ -17,7 +17,7 @@ BankswitchVRAM1: ret ; set current dest VRAM bank to a -BankswitchVRAM: +BankswitchVRAM:: ldh [hBankVRAM], a ldh [rVBK], a ret diff --git a/src/home/write_number.asm b/src/home/write_number.asm index d480e27e..1b64eafe 100644 --- a/src/home/write_number.asm +++ b/src/home/write_number.asm @@ -1,6 +1,6 @@ ; converts the two-digit BCD number provided in a to text (ascii) format, ; writes them to [wStringBuffer] and [wStringBuffer + 1], and to the BGMap0 address at bc -WriteTwoDigitBCDNumber: +WriteTwoDigitBCDNumber:: push hl push bc push de @@ -20,7 +20,7 @@ WriteTwoDigitBCDNumber: ; converts the one-digit BCD number provided in the lower nybble of a to text ; (ascii) format, and writes it to [wStringBuffer] and to the BGMap0 address at bc -WriteOneDigitBCDNumber: +WriteOneDigitBCDNumber:: push hl push bc push de @@ -40,7 +40,7 @@ WriteOneDigitBCDNumber: ; converts the four-digit BCD number provided in h and l to text (ascii) format, ; writes them to [wStringBuffer] through [wStringBuffer + 3], and to the BGMap0 address at bc -WriteFourDigitBCDNumber: +WriteFourDigitBCDNumber:: push hl push bc push de @@ -66,7 +66,7 @@ WriteFourDigitBCDNumber: ; given two BCD digits in the two nybbles of register a, ; write them in text (ascii) format to hl (most significant nybble first). ; numbers above 9 end up converted to half-width font tiles. -WriteBCDNumberInTextFormat: +WriteBCDNumberInTextFormat:: push af swap a call WriteBCDDigitInTextFormat @@ -75,7 +75,7 @@ WriteBCDNumberInTextFormat: ; given a BCD digit in the (lower nybble) of register a, write it in text (ascii) ; format to hl. numbers above 9 end up converted to half-width font tiles. -WriteBCDDigitInTextFormat: +WriteBCDDigitInTextFormat:: and $0f add "0" cp "9" + 1 @@ -87,7 +87,7 @@ WriteBCDDigitInTextFormat: ; converts the one-byte number at a to text (ascii) format, ; and writes it to [wStringBuffer] and the BGMap0 address at bc -WriteOneByteNumber: +WriteOneByteNumber:: push bc push hl ld l, a @@ -112,7 +112,7 @@ WriteOneByteNumber: ; converts the two-byte number at hl to text (ascii) format, ; and writes it to [wStringBuffer] and the BGMap0 address at bc -WriteTwoByteNumber: +WriteTwoByteNumber:: push bc ld de, wStringBuffer push de @@ -125,7 +125,7 @@ WriteTwoByteNumber: ret ; convert the number at hl to text (ascii) format and write it to de -TwoByteNumberToText: +TwoByteNumberToText:: push bc ld bc, -10000 call .get_digit diff --git a/src/main.asm b/src/main.asm index 587918c0..c27c3e5f 100644 --- a/src/main.asm +++ b/src/main.asm @@ -1,8 +1,6 @@ INCLUDE "macros.asm" INCLUDE "constants.asm" -INCLUDE "engine/home.asm" - SECTION "Game Loop", ROMX INCLUDE "engine/game_loop.asm"