diff options
| author | Daniel Harding <33dannye@gmail.com> | 2018-02-10 15:52:58 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-02-10 15:52:58 -0600 |
| commit | 24f40989d472407dc51653f2a671348126c6e816 (patch) | |
| tree | 3aa0db9181a57a8dd5456955f7957a1950fe1400 /src/engine | |
| parent | 9b373dbff462614e484c0a5584e089e668bfd469 (diff) | |
| parent | f541f5e03adadf0b9315cc642da9a5b377b52c12 (diff) | |
Merge pull request #34 from xCrystal/master
Some Home disasm ; Misc style fixes, constants and labeling ; Split macros ; Create linkerscript and arrange Sections ; Bump extras
Diffstat (limited to 'src/engine')
| -rwxr-xr-x | src/engine/bank1.asm | 167 | ||||
| -rwxr-xr-x | src/engine/bank1c.asm | 28 | ||||
| -rwxr-xr-x | src/engine/bank2.asm | 66 | ||||
| -rwxr-xr-x | src/engine/bank20.asm | 38 | ||||
| -rwxr-xr-x | src/engine/bank3.asm | 110 | ||||
| -rwxr-xr-x | src/engine/bank4.asm | 114 | ||||
| -rwxr-xr-x | src/engine/bank5.asm | 646 | ||||
| -rwxr-xr-x | src/engine/bank6.asm | 22 | ||||
| -rwxr-xr-x | src/engine/bank7.asm | 48 | ||||
| -rwxr-xr-x | src/engine/bank8.asm | 264 | ||||
| -rw-r--r-- | src/engine/booster_packs.asm | 566 | ||||
| -rwxr-xr-x | src/engine/boosters.asm | 993 | ||||
| -rw-r--r-- | src/engine/effect_functions.asm | 32 | ||||
| -rwxr-xr-x | src/engine/home.asm | 1370 |
14 files changed, 2194 insertions, 2270 deletions
diff --git a/src/engine/bank1.asm b/src/engine/bank1.asm index 1008822..b5894d2 100755 --- a/src/engine/bank1.asm +++ b/src/engine/bank1.asm @@ -16,20 +16,21 @@ Func_4000: ; 4000 (1:4000) farcall Func_1a6cc ldh a, [hButtonsHeld] cp A_BUTTON | B_BUTTON - jr z, .asm_4035 + jr z, .ask_erase_backup_ram farcall Func_126d1 jr Func_4000 -.asm_4035 +.ask_erase_backup_ram call Func_405a call Func_04a2 - text_hl ResetBackUpRamText - call Func_2af0 - jr c, .asm_404d + ldtx hl, ResetBackUpRamText + call YesOrNoMenuWithText + jr c, .reset_game +; erase sram call EnableExtRAM xor a ld [$a000], a call DisableExtRAM -.asm_404d +.reset_game jp Reset Func_4050: ; 4050 (1:4050) @@ -39,10 +40,10 @@ Func_4050: ; 4050 (1:4050) ret Func_405a: ; 405a (1:405a) -INCBIN "baserom.gbc",$405a,$406f - $405a + INCROM $405a, $406f Func_406f: ; 406f (1:406f) -INCBIN "baserom.gbc",$406f,$409f - $406f + INCROM $406f, $409f ; this function begins the duel after the opponent's ; graphics, name and deck have been introduced @@ -128,7 +129,7 @@ StartDuel: ; 409f (1:409f) call Func_04a2 ld a, $3 call Func_2167 - text_hl DecisionText + ldtx hl, DecisionText call DrawWideTextBox_WaitForInput call Func_04a2 ldh a, [hWhoseTurn] @@ -147,7 +148,7 @@ StartDuel: ; 409f (1:409f) jr z, .activeDuelistLostBattle ld a, $5f ld c, MUSIC_DARKDIDDLY - text_hl DuelWasDrawText + ldtx hl, DuelWasDrawText jr .handleDuelFinished .activeDuelistWonBattle @@ -159,7 +160,7 @@ StartDuel: ; 409f (1:409f) ld [wd0c3], a ld a, $5d ld c, MUSIC_MATCHVICTORY - text_hl WonDuelText + ldtx hl, WonDuelText jr .handleDuelFinished .activeDuelistLostBattle @@ -171,7 +172,7 @@ StartDuel: ; 409f (1:409f) ld [wd0c3], a ld a, $5e ld c, MUSIC_MATCHLOSS - text_hl LostDuelText + ldtx hl, LostDuelText .handleDuelFinished call Func_3b6a @@ -202,7 +203,7 @@ StartDuel: ; 409f (1:409f) call Func_3b31 ld a, [wDuelTheme] call PlaySong - text_hl StartSuddenDeathMatchText + ldtx hl, StartSuddenDeathMatchText call DrawWideTextBox_WaitForInput ld a, $1 ld [wcc08], a @@ -231,7 +232,7 @@ StartDuel: ; 409f (1:409f) ret ; 0x420b -INCBIN "baserom.gbc",$420b,$4225 - $420b + INCROM $420b, $4225 HandleTurn: ; 4225 (1:4225) ld a, DUELVARS_DUELIST_TYPE @@ -245,7 +246,7 @@ HandleTurn: ; 4225 (1:4225) .asm_4237 call $70e6 call $4933 - call _DrawCardFromDeck + call DrawCardFromDeck jr nc, .deckNotEmpty ld a, DUEL_LOST ld [wDuelFinished], a @@ -282,8 +283,8 @@ Func_426d: xor a ld [wVBlankCtr], a ld [wcbf9], a - text_hl DuelistIsThinkingText - call Func_2a36 + ldtx hl, DuelistIsThinkingText + call DrawWideTextBox_PrintTextNoDelay call Func_2bbf ld a, $ff ld [wcc11], a @@ -299,7 +300,7 @@ PrintDuelMenu: or a ret nz ld a, [wCurrentDuelMenuItem] - call Func_2710 + call SetMenuItem Func_42ac: call DoFrame @@ -333,18 +334,18 @@ Func_42ac: ld [wCurrentDuelMenuItem], a jr nc, Func_42ac ldh a, [hCurrentMenuItem] - ld hl, BattleMenuFunctionTable + ld hl, DuelMenuFunctionTable jp JumpToFunctionInTable -BattleMenuFunctionTable: ; 42f1 (1:42f1) - dw OpenHandMenu - dw OpenBattleAttackMenu - dw OpenBattleCheckMenu - dw OpenPokemonPowerMenu - dw PlayerRetreat - dw PlayerEndTurn +DuelMenuFunctionTable: ; 42f1 (1:42f1) + dw DuelMenu_Hand + dw DuelMenu_Attack + dw DuelMenu_Check + dw DuelMenu_PkmnPower + dw DuelMenu_Retreat + dw DuelMenu_Done -INCBIN "baserom.gbc",$42fd, $430b - $42fd + INCROM $42fd, $430b Func_430b: ; 430b (1:430b) call Func_4329 @@ -382,15 +383,15 @@ Func_4339: ; 4339 (1:4339) Func_4342: ; 4342 (1:4342) jp $5550 -INCBIN "baserom.gbc",$4345, $438e - $4345 + INCROM $4345, $438e -OpenPokemonPowerMenu: ; 438e (1:438e) +DuelMenu_PkmnPower: ; 438e (1:438e) call $6431 jp c, Func_426d call Func_1730 jp Func_426d -PlayerEndTurn: ; 439a (1:439a) +DuelMenu_Done: ; 439a (1:439a) ld a, $08 call $51e7 jp c, Func_4268 @@ -399,7 +400,7 @@ PlayerEndTurn: ; 439a (1:439a) call $717a ret -PlayerRetreat: ; 43ab (1:43ab) +DuelMenu_Retreat: ; 43ab (1:43ab) ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable and a,PASSIVE_STATUS_MASK @@ -413,7 +414,7 @@ PlayerRetreat: ; 43ab (1:43ab) jr c, Func_441f call $4611 jr c, Func_441c - text_hl SelectMonOnBenchToSwitchWithActiveText + ldtx hl, SelectMonOnBenchToSwitchWithActiveText call DrawWideTextBox_WaitForInput call $600c jr c, Func_441c @@ -427,7 +428,7 @@ PlayerRetreat: ; 43ab (1:43ab) call $4f9d Func_43e8: ; 43e8 - text_hl UnableToRetreatText + ldtx hl, UnableToRetreatText call DrawWideTextBox_WaitForInput jp PrintDuelMenu @@ -437,7 +438,7 @@ Func_43f1: ; 43f1 (1:43f1) call $4611 jr c, Func_441c call $6558 - text_hl SelectMonOnBenchToSwitchWithActiveText + ldtx hl, SelectMonOnBenchToSwitchWithActiveText call DrawWideTextBox_WaitForInput call $600c ld [wBenchSelectedPokemon], a @@ -457,22 +458,22 @@ Func_441f: ; 441f (1:441f) call DrawWideTextBox_WaitForInput jp PrintDuelMenu -OpenHandMenu: ; 4425 (1:4425) +DuelMenu_Hand: ; 4425 (1:4425) ld a, DUELVARS_NUMBER_OF_CARDS_IN_HAND call GetTurnDuelistVariable or a jr nz, Func_4436 - text_hl NoCardsInHandText + ldtx hl, NoCardsInHandText call DrawWideTextBox_WaitForInput jp PrintDuelMenu Func_4436: ; 4436 (1:4436) -INCBIN "baserom.gbc",$4436, $4477 - $4436 + INCROM $4436, $4477 -; c contains the energy card being played +; c contains the type of energy card being played PlayerUseEnergyCard: ; 4477 (1:4477) ld a, c - cp WATER_ENERGY_CARD ; XXX why treat water energy card differently? + cp TYPE_ENERGY_WATER ; XXX why treat water energy card differently? jr nz, .notWaterEnergy call $3615 jr c, .waterEnergy @@ -509,28 +510,28 @@ PlayerUseEnergyCard: ; 4477 (1:4477) ld a, [wAlreadyPlayedEnergy] or a jr z, .asm_4490 - text_hl OnlyOneEnergyCardText + ldtx hl, OnlyOneEnergyCardText call DrawWideTextBox_WaitForInput jp Func_4436 .alreadyPlayedEnergy - text_hl OnlyOneEnergyCardText + ldtx hl, OnlyOneEnergyCardText call DrawWideTextBox_WaitForInput - call $123b + call CreateHandCardBuffer call $55be jp $4447 ; 0x44db -INCBIN "baserom.gbc",$44db, $4585 - $44db + INCROM $44db, $4585 -OpenBattleCheckMenu: ; 4585 (1:4585) +DuelMenu_Check: ; 4585 (1:4585) call Func_3b31 call Func_3096 jp Func_426d -INCBIN "baserom.gbc",$458e, $46fc - $458e + INCROM $458e, $46fc -OpenBattleAttackMenu: ; 46fc (1:46fc) +DuelMenu_Attack: ; 46fc (1:46fc) call HandleCantAttackSubstatus jr c, .alertCantAttackAndCancelMenu call CheckIfActiveCardParalyzedOrAsleep @@ -548,7 +549,7 @@ OpenBattleAttackMenu: ; 46fc (1:46fc) call LoadPokemonMovesToDuelCardOrAttackList or a jr nz, .openAttackMenu - text_hl NoSelectableAttackText + ldtx hl, NoSelectableAttackText call DrawWideTextBox_WaitForInput jp PrintDuelMenu @@ -570,14 +571,14 @@ OpenBattleAttackMenu: ; 46fc (1:46fc) ldh a, [hButtonsPressed] and START jr nz, .displaySelectedMoveInfo - call MenuCursorAcceptInput + call HandleMenuInput jr nc, .waitForInput cp $ff ; was B pressed? jp z, PrintDuelMenu ld [wSelectedDuelSubMenuItem], a call CheckIfEnoughEnergies jr nc, .enoughEnergy - text_hl NotEnoughEnergyCardsText + ldtx hl, NotEnoughEnergyCardsText call DrawWideTextBox_WaitForInput jr .tryOpenAttackMenu @@ -660,14 +661,12 @@ Func_478b: ; 478b (1:478b) ret AttackMenuCursorData: - db $01 - db $0d - db $02 - db $02 - db $0f - db $00 - db $00 - db $00 + db 1, 13 ; x, y + db 2 ; y displacement between items + db 2 ; number of items + db $0f ; cursor tile number + db $00 ; tile behind cursor + dw $0000 ; unknown function pointer if non-0 Func_47ec: ; $47ec (1:47ec) ld a, [wcc04] @@ -919,17 +918,17 @@ CheckIfActiveCardParalyzedOrAsleep: ; 4918 (1:4918) ret .paralyzed - text_hl UnableDueToParalysisText + ldtx hl, UnableDueToParalysisText jr .returnWithStatusCondition .asleep - text_hl UnableDueToSleepText + ldtx hl, UnableDueToSleepText .returnWithStatusCondition: scf ret -INCBIN "baserom.gbc",$4933, $4b60 - $4933 + INCROM $4933, $4b60 Func_4b60: ; 4b60 (1:4b60) call $7107 @@ -994,7 +993,7 @@ Func_4b60: ; 4b60 (1:4b60) call Func_4cd5 call SwapTurn jp c, $4c77 - call $311d + call Func_311d ld hl, $0072 call DrawWideTextBox_WaitForInput call Func_0f58 @@ -1058,7 +1057,7 @@ Func_4b60: ; 4b60 (1:4b60) ; 0x4c77 -INCBIN "baserom.gbc",$4c77, $4cd5 - $4c77 + INCROM $4c77, $4cd5 ; Select Basic Pokemon From Hand Func_4cd5: ; 4cd5 (1:4cd5) @@ -1117,7 +1116,7 @@ Func_4cd5: ; 4cd5 (1:4cd5) call $51e7 jr c, .asm_4d28 ld a, [$ff98] - call $1485 + call Func_1485 ld a, [$ff98] ld hl, $0062 call $4b31 @@ -1141,7 +1140,7 @@ Func_4cd5: ; 4cd5 (1:4cd5) cp $6 jr nc, .asm_4d86 ld a, [$ff98] - call $1485 + call Func_1485 ld a, [$ff98] ld hl, $0061 call $4b31 @@ -1163,13 +1162,13 @@ Func_4cd5: ; 4cd5 (1:4cd5) ; 0x4d97 -INCBIN "baserom.gbc",$4d97, $5aeb - $4d97 + INCROM $4d97, $5aeb Func_5aeb: ; 5aeb (1:5aeb) -INCBIN "baserom.gbc",$5aeb,$6785 - $5aeb + INCROM $5aeb, $6785 Func_6785: ; 6785 (1:6785) -INCBIN "baserom.gbc",$6785,$6793 - $6785 + INCROM $6785, $6793 ; loads player deck from SRAM to wPlayerDeck LoadPlayerDeck: ; 6793 (1:6793) @@ -1192,7 +1191,7 @@ LoadPlayerDeck: ; 6793 (1:6793) ret ; 0x67b2 -INCBIN "baserom.gbc",$67b2,$67be - $67b2 + INCROM $67b2, $67be ; related to ai taking their turn in a duel ; called multiple times during one ai turn @@ -1224,7 +1223,7 @@ AIMakeDecision: ; 67be (1:67be) ret nz ld [wVBlankCtr], a ld hl, $0088 - call Func_2a36 + call DrawWideTextBox_PrintTextNoDelay or a ret @@ -1233,7 +1232,7 @@ AIMakeDecision: ; 67be (1:67be) ret ; 0x67fb -INCBIN "baserom.gbc",$67fb,$695e - $67fb + INCROM $67fb, $695e AIMoveTable: ; 695e (1:695e) dw Func_0f35 @@ -1260,7 +1259,7 @@ AIMoveTable: ; 695e (1:695e) dw $6b15 dw $6b20 -INCBIN "baserom.gbc",$698c,$69a5 - $698c + INCROM $698c, $69a5 AIUseEnergyCard: ; 69a5 (1:69a5) ld a, [$ffa1] @@ -1279,20 +1278,20 @@ AIUseEnergyCard: ; 69a5 (1:69a5) ret ; 0x69c5 -INCBIN "baserom.gbc",$69c5,$6d84 - $69c5 + INCROM $69c5, $6d84 ; converts clefairy doll/mysterious fossil at specified wLoadedCard to pokemon card ConvertTrainerCardToPokemon: ld c, a ld a, [hl] - cp TRAINER_CARD + cp TYPE_TRAINER ret nz push hl ldh a, [hWhoseTurn] ld h, a ld l, c ld a, [hl] - and TRAINER_CARD + and TYPE_TRAINER pop hl ret z ld a, e @@ -1336,7 +1335,7 @@ ConvertTrainerCardToPokemon: db UNABLE_RETREAT ; retreat cost ds $0d ; PKMN_CARD_DATA_LENGTH - (wLoadedCard1RetreatCost + 1 - wLoadedCard1) -INCBIN "baserom.gbc",$6df1,$7107 - $6df1 + INCROM $6df1, $7107 ; initializes duel variables such as cards in deck and in hand, or Pokemon in play area ; player turn: [c200, c2ff] @@ -1381,7 +1380,7 @@ InitializeDuelVariables: ; 7107 (1:7107) ret ; 0x7133 -INCBIN "baserom.gbc",$7133,$71ad - $7133 + INCROM $7133, $71ad _TossCoin: ; 71ad (1:71ad) ld [wcd9c], a @@ -1391,7 +1390,7 @@ _TossCoin: ; 71ad (1:71ad) xor a ld [wcd9f], a call Func_04a2 - call $210f + call Func_210f .asm_71c1 ld a, [wcd9f] @@ -1515,7 +1514,7 @@ _TossCoin: ; 71ad (1:71ad) .asm_7292 ld a, d - call Func_3796 + call PlaySFX ld a, [wcd9c] dec a jr z, .asm_72b9 @@ -1577,29 +1576,29 @@ _TossCoin: ; 71ad (1:71ad) ret ; 0x72ff -INCBIN "baserom.gbc",$72ff,$7354 - $72ff + INCROM $72ff, $7354 BuildVersion: ; 7354 (1:7354) db "VER 12/20 09:36",TX_END -INCBIN "baserom.gbc",$7364,$7571 - $7364 + INCROM $7364, $7571 Func_7571: ; 7571 (1:7571) -INCBIN "baserom.gbc",$7571,$7576 - $7571 + INCROM $7571, $7576 Func_7576: ; 7576 (1:7576) farcallx $6, $591f ret ; 0x757b -INCBIN "baserom.gbc",$757b,$758f - $757b + INCROM $757b, $758f Func_758f: ; 758f (1:758f) -INCBIN "baserom.gbc",$758f,$7594 - $758f + INCROM $758f, $7594 Func_7594: ; 7594 (1:7594) farcallx $6, $661f ret ; 0x7599 -INCBIN "baserom.gbc",$7599,$8000 - $7599
\ No newline at end of file + INCROM $7599, $8000
\ No newline at end of file diff --git a/src/engine/bank1c.asm b/src/engine/bank1c.asm index 9abadde..c7ae122 100755 --- a/src/engine/bank1c.asm +++ b/src/engine/bank1c.asm @@ -22,7 +22,7 @@ Func_70018: ; 70018 (1c:4018) ret ; 0x70024 -INCBIN "baserom.gbc",$70024,$70044 - $70024 + INCROM $70024, $70044 Func_70044: ; 70044 (1c:4044) push hl @@ -41,7 +41,7 @@ Func_70044: ; 70044 (1c:4044) ret Unknown_70057: ; 70057 (1c:4057) -INCBIN "baserom.gbc",$70057,$70082 - $70057 + INCROM $70057, $70082 Func_70082: ; 70082 (1c:4082) ld a, [wConsole] @@ -80,7 +80,7 @@ Func_700a3: ; 700a3 (1c:40a3) ld a, [hli] ld h, [hl] ld l, a - ld de, $8800 + ld de, vTiles1 call Func_701e9 call Func_701fe ld hl, SGB_700de @@ -96,7 +96,7 @@ Func_700a3: ; 700a3 (1c:40a3) jr z, .asm_700da call Func_70136 dec hl - ld de, $8800 + ld de, vTiles1 call Func_701e9 ld hl, SGB_700ee call Func_70177 @@ -108,11 +108,11 @@ Func_700a3: ; 700a3 (1c:40a3) ; CHR_TRN: tiles $00-$7F, BG (border) tiles (from SNES $000-$FFF) SGB_700de: ; 700de (1c:40de) -INCBIN "baserom.gbc",$700de,$700ee - $700de + INCROM $700de, $700ee ; CHR_TRN: tiles $80-$FF, BG (border) tiles (from SNES $000-$FFF) SGB_700ee: ; 700ee (1c:40ee) -INCBIN "baserom.gbc",$700ee,$700fe - $700ee + INCROM $700ee, $700fe Func_700fe: ; 700fe (1c:40fe) push hl @@ -123,10 +123,10 @@ Func_700fe: ; 700fe (1c:40fe) push hl call Func_70136 pop hl - ld de, $8800 + ld de, vTiles1 call Func_701e9 pop hl - ld de, $9000 + ld de, vTiles2 call Func_701e9 call Func_701fe pop hl @@ -140,7 +140,7 @@ Func_700fe: ; 700fe (1c:40fe) ; PCT_TRN: read tile map & palette data into VRAM (from SNES $000-$87F) SGB_70126: ; 70126 (1c:4126) -INCBIN "baserom.gbc",$70126,$70136 - $70126 + INCROM $70126, $70136 Func_70136: ; 70136 (1c:4136) push hl @@ -200,11 +200,11 @@ Func_70177: ; 70177 (1c:4177) ; MASK_EN on SGB_MASK_EN_ON_701a0: ; 701a0 (1c:41a0) -INCBIN "baserom.gbc",$701a0,$701b0 - $701a0 + INCROM $701a0, $701b0 ; MASK_EN off SGB_MASK_EN_OFF_701b0: ; 701b0 (1c:41b0) -INCBIN "baserom.gbc",$701b0,$701c0 - $701b0 + INCROM $701b0, $701c0 Func_701c0: ; 701c0 (1c:41c0) push hl @@ -212,7 +212,7 @@ Func_701c0: ; 701c0 (1c:41c0) call DisableLCD xor a ld c, $10 - ld hl, $9000 + ld hl, vTiles2 .asm_701cb ld [hli], a dec c @@ -251,7 +251,7 @@ Func_701e9: ; 701e9 (1c:41e9) ret Func_701fe: ; 701fe (1c:41fe) - ld hl, $9800 + ld hl, vBGMapTiles ld de, $000c ld a, $80 ld c, $d @@ -311,4 +311,4 @@ Func_70214: ; 70214 (1c:4214) ret Unknown_7024a: ; 7024a (1c:424a) -INCBIN "baserom.gbc",$7024a,$74000 - $7024a + INCROM $7024a, $74000 diff --git a/src/engine/bank2.asm b/src/engine/bank2.asm index a721a74..fea3d9b 100755 --- a/src/engine/bank2.asm +++ b/src/engine/bank2.asm @@ -1,4 +1,4 @@ -INCBIN "baserom.gbc",$8000,$8cd4 - $8000 + INCROM $8000, $8cd4 Func_8cd4: ; 8cd4 (2:4cd4) push bc @@ -17,7 +17,7 @@ Func_8cd4: ; 8cd4 (2:4cd4) ret ; 0x8ce7 -INCBIN "baserom.gbc",$8ce7,$8cf9 - $8ce7 + INCROM $8ce7, $8cf9 Func_8cf9: ; 8cf9 (2:4cf9) call EnableExtRAM @@ -37,7 +37,7 @@ Func_8d0b: ; 8d0b (2:4d0b) ret Unknown_8d15: ; 8d15 (2:4d15) -INCBIN "baserom.gbc",$8d15,$8d56 - $8d15 + INCROM $8d15, $8d56 Func_8d56: ; 8d56 (2:4d56) xor a @@ -55,7 +55,7 @@ Func_8d56: ; 8d56 (2:4d56) ret ; 0x8d78 -INCBIN "baserom.gbc",$8d78,$8d9d - $8d78 + INCROM $8d78, $8d9d Func_8d9d: ; 8d9d (2:4d9d) ld de, $cfd1 @@ -69,7 +69,7 @@ Func_8d9d: ; 8d9d (2:4d9d) ret Unknown_8da9: ; 8da9 (2:4da9) -INCBIN "baserom.gbc",$8da9,$8db0 - $8da9 + INCROM $8da9, $8db0 Func_8db0: ; 8db0 (2:4db0) ld hl, Unknown_8da9 @@ -81,14 +81,14 @@ Func_8db0: ; 8db0 (2:4db0) Func_8dbc: ; 8dbc (2:4dbc) ld hl, Unknown_8de2 call InitializeCursorParameters - text_hl PleaseSelectDeckText + ldtx hl, PleaseSelectDeckText call DrawWideTextBox_PrintText .asm_8dc8 call DoFrame jr c, Func_8dbc call Func_8dea jr c, Func_8dbc - call MenuCursorAcceptInput + call HandleMenuInput jr nc, .asm_8dc8 ldh a, [hCurrentMenuItem] cp $ff @@ -97,7 +97,7 @@ Func_8dbc: ; 8dbc (2:4dbc) jp Func_8e42 Unknown_8de2: ; 8de2 (2:4de2) -INCBIN "baserom.gbc",$8de2,$8dea - $8de2 + INCROM $8de2, $8dea Func_8dea: ; 8dea (2:4dea) ldh a, [hButtonsPressed2] @@ -348,13 +348,13 @@ Func_8f9d: ; 8f9d (2:4f9d) xor a ld [wce3f], a ld [wce40], a - text_hl ChosenAsDuelingDeckText + ldtx hl, ChosenAsDuelingDeckText call DrawWideTextBox_WaitForInput ld a, [wceb1] jp Func_8dbc Func_8fe8: ; 8fe8 (2:4fe8) - text_hl ThereIsNoDeckHereText + ldtx hl, ThereIsNoDeckHereText call DrawWideTextBox_WaitForInput ld a, [wceb1] ret @@ -372,13 +372,13 @@ Func_8ff2: ; 8ff2 (2:4ff2) ret ; 0x9001 -INCBIN "baserom.gbc",$9001,$9026 - $9001 + INCROM $9001, $9026 Func_9026: ; 9026 (2:5026) ret Unknown_9027: ; 9027 (2:5027) -INCBIN "baserom.gbc",$9027,$9038 - $9027 + INCROM $9027, $9038 Func_9038: ; 9038 (2:5038) ld a, [wceb1] @@ -471,7 +471,7 @@ Func_9065: ; 9065 (2:5065) ld a, [wcfe3] or a jr z, .asm_90ca - call Func_3796 + call PlaySFX .asm_90ca ld hl, $cea3 ld a, [hl] @@ -515,7 +515,7 @@ Func_90fb: ; 90fb (2:50fb) .asm_9103 ld a, $3 .asm_9105 - call Func_3796 + call PlaySFX pop af ret @@ -540,7 +540,7 @@ Func_910a: ; 910a (2:510a) ret ; 0x9120 -INCBIN "baserom.gbc",$9120,$9152 - $9120 + INCROM $9120, $9152 Func_9152: ; 9152 (2:5152) push hl @@ -662,7 +662,7 @@ Func_9168: ; 9168 (2:5168) ret Unknown_9242: ; 9242 (2:5242) -INCBIN "baserom.gbc",$9242,$9253 - $9242 + INCROM $9242, $9253 Func_9253: ; 9253 (2:5253) ld de, wc590 @@ -703,13 +703,13 @@ Func_926e: ; 926e (2:526e) ret .asm_929c call Func_22ae - text_hl NewDeckText + ldtx hl, NewDeckText call Func_2c29 scf ret Unknown_92a7: ; 92a7 (2:52a7) -INCBIN "baserom.gbc",$92a7,$92ad - $92a7 + INCROM $92a7, $92ad Func_92ad: ; 92ad (2:52ad) ld a, [hli] @@ -726,7 +726,7 @@ Func_92b4: ; 92b4 (2:52b4) ret ; 0x92be -INCBIN "baserom.gbc",$92be,$9314 - $92be + INCROM $92be, $9314 Func_9314: ; 9314 (2:5314) ld bc, $0018 @@ -759,31 +759,31 @@ Func_9326: ; 9326 (2:5326) ret Func_9345: ; 9345 (2:5345) -INCBIN "baserom.gbc",$9345,$9843 - $9345 + INCROM $9345, $9843 Func_9843: ; 9843 (2:5843) -INCBIN "baserom.gbc",$9843,$9e41 - $9843 + INCROM $9843, $9e41 Func_9e41: ; 9e41 (2:5e41) -INCBIN "baserom.gbc",$9e41,$a288 - $9e41 + INCROM $9e41, $a288 Func_a288: ; a288 (2:6288) -INCBIN "baserom.gbc",$a288,$a763 - $a288 + INCROM $a288, $a763 Unknown_a763: ; a763 (2:6763) -INCBIN "baserom.gbc",$a763,$a76c - $a763 + INCROM $a763, $a76c Unknown_a76c: ; a76c (2:676c) -INCBIN "baserom.gbc",$a76c,$a775 - $a76c + INCROM $a76c, $a775 Unknown_a775: ; a775 (2:6775) -INCBIN "baserom.gbc",$a775,$a77e - $a775 + INCROM $a775, $a77e Unknown_a77e: ; a77e (2:677e) -INCBIN "baserom.gbc",$a77e,$b177 - $a77e + INCROM $a77e, $b177 Func_b177: ; b177 (2:7177) -INCBIN "baserom.gbc",$b177,$b19d - $b177 + INCROM $b177, $b19d Func_b19d: ; b19d (2:719d) xor a @@ -842,7 +842,7 @@ Func_b19d: ; b19d (2:719d) .asm_b216 ld hl, $0272 - call Func_2af0 + call YesOrNoMenuWithText ld a, [$d086] jr c, .asm_b1b3 call $7592 @@ -888,7 +888,7 @@ Func_b19d: ; b19d (2:719d) ret ; 0xb274 -INCBIN "baserom.gbc",$b274,$ba04 - $b274 + INCROM $b274, $ba04 Func_ba04: ; ba04 (2:7a04) ld a, [wd0a9] @@ -923,7 +923,7 @@ Func_ba04: ; ba04 (2:7a04) ld [hl], d .asm_ba40 call DoFrame - call MenuCursorAcceptInput + call HandleMenuInput jr c, .asm_baa3 ld a, [$ff8f] and $c0 @@ -973,7 +973,7 @@ Func_ba04: ; ba04 (2:7a04) jp $7a25 .asm_baa3 - call Func_270b + call DrawCursor2 ld a, [$cea1] ld [$d087], a ld a, [wCurMenuItem] @@ -1071,4 +1071,4 @@ Func_ba04: ; ba04 (2:7a04) jp $7a25 ; 0xbb6e -INCBIN "baserom.gbc",$bb6e,$c000 - $bb6e + INCROM $bb6e, $c000 diff --git a/src/engine/bank20.asm b/src/engine/bank20.asm index 0142e93..b551e73 100755 --- a/src/engine/bank20.asm +++ b/src/engine/bank20.asm @@ -1,5 +1,5 @@ Func_80000: ; 80000 (20:4000) -INCBIN "baserom.gbc",$80000,$80028 - $80000 + INCROM $80000, $80028 Func_80028: ; 80028 (20:4028) call Func_801f1 @@ -11,7 +11,7 @@ Func_80028: ; 80028 (20:4028) ret ; 0x8003d -INCBIN "baserom.gbc",$8003d,$80077 - $8003d + INCROM $8003d, $80077 Func_80077: ; 80077 (20:4077) ld a, $1 @@ -25,7 +25,7 @@ Func_80077: ; 80077 (20:4077) push hl push bc push de - call Func_04cf + call BCCoordToBGMap0Address ld hl, wd4c2 ld [hl], e inc hl @@ -55,7 +55,7 @@ Func_80077: ; 80077 (20:4077) ret ; 0x800bd -INCBIN "baserom.gbc",$800bd,$801a1 - $800bd + INCROM $800bd, $801a1 Func_801a1: ; 801a1 (20:41a1) push hl @@ -65,17 +65,17 @@ Func_801a1: ; 801a1 (20:41a1) push af ld a, $1 call BankswitchRAM - ld hl, $a000 - ld de, $9800 + ld hl, vEnd + ld de, vBGMapTiles ld c, $20 .asm_801b4 push bc push hl push de ld b, $20 - call $06fc + call SafeCopyDataHLtoDE ld a, [wConsole] - cp $2 + cp CONSOLE_CGB jr nz, .asm_801d6 pop de pop hl @@ -85,7 +85,7 @@ Func_801a1: ; 801a1 (20:41a1) add hl, bc call BankswitchVRAM_1 ld b, $20 - call $06fc + call SafeCopyDataHLtoDE call BankswitchVRAM_0 .asm_801d6 @@ -157,7 +157,7 @@ Func_80229: ; 80229 (20:4229) ret ; 0x80238 -INCBIN "baserom.gbc",$80238,$8025b - $80238 + INCROM $80238, $8025b Func_8025b: ; 8025b (20:425b) push hl @@ -234,19 +234,19 @@ Func_802bb: ; 802bb (20:42bb) ret ; 0x802d4 -INCBIN "baserom.gbc",$802d4,$80418 - $802d4 + INCROM $802d4, $80418 Func_80418: ; 80418 (20:4418) -INCBIN "baserom.gbc",$80418,$80480 - $80418 + INCROM $80418, $80480 Func_80480: ; 80480 (20:4480) -INCBIN "baserom.gbc",$80480,$804d8 - $80480 + INCROM $80480, $804d8 Func_804d8: ; 804d8 (20:44d8) -INCBIN "baserom.gbc",$804d8,$80b7a - $804d8 + INCROM $804d8, $80b7a Func_80b7a: ; 80b7a (20:4b7a) -INCBIN "baserom.gbc",$80b7a,$80ba4 - $80b7a + INCROM $80b7a, $80ba4 Func_80ba4: ; 80ba4 (20:4ba4) push af @@ -288,7 +288,7 @@ Func_80ba4: ; 80ba4 (20:4ba4) ld c, [hl] inc hl ld a, [wConsole] - cp $2 + cp CONSOLE_CGB jr nz, .asm_80be7 inc hl @@ -327,10 +327,10 @@ Func_80ba4: ; 80ba4 (20:4ba4) ret ; 0x80c21 -INCBIN "baserom.gbc",$80c21,$80e5a - $80c21 + INCROM $80c21, $80e5a Unknown_80e5a: ; 80e5a (20:4e5a) -INCBIN "baserom.gbc",$80e5a,$80e5d - $80e5a + INCROM $80e5a, $80e5d MapDataPointers: ; 80e5d (20:4e5d) -INCBIN "baserom.gbc",$80e5d,$84000 - $80e5d + INCROM $80e5d, $84000 diff --git a/src/engine/bank3.asm b/src/engine/bank3.asm index 6fb124e..563a667 100755 --- a/src/engine/bank3.asm +++ b/src/engine/bank3.asm @@ -65,7 +65,7 @@ LoadMap: ; c000 (3:4000) bit 4, [hl] jr z, .asm_c0b6 ld a, $c - call Func_3796 + call PlaySFX jp .asm_c037 .asm_c0b6 farcall Func_10ab4 @@ -336,7 +336,7 @@ Func_c268: ; c268 (3:4268) ret Unknown_c27c: ; c27c (3:427c) -INCBIN "baserom.gbc",$c27c,$c280 - $c27c + INCROM $c27c, $c280 Func_c280: ; c280 (3:4280) call Func_c228 @@ -440,7 +440,7 @@ Func_c335: ; c335 (3:4335) ld hl, $cb30 ld de, $d0cc ld bc, $0040 - call CopyData_SaveRegisters + call CopyDataHLtoDE_SaveRegisters ret Func_c34e: ; c34e (3:434e) @@ -451,7 +451,7 @@ Func_c34e: ; c34e (3:434e) ld hl, $d0cc ld de, $cb30 ld bc, $0040 - call CopyData_SaveRegisters + call CopyDataHLtoDE_SaveRegisters call Func_0404 ret @@ -467,7 +467,7 @@ Func_c36a: ; c36a (3:436a) ret ; 0xc37a -INCBIN "baserom.gbc",$c37a,$c41c - $c37a + INCROM $c37a, $c41c Func_c41c: ; c41c (3:441c) ld a, [wd332] @@ -986,7 +986,7 @@ MainMenu_c75a: ; c75a (3:475a) call Func_c29b .asm_c76a call DoFrameIfLCDEnabled - call MenuCursorAcceptInput + call HandleMenuInput jr nc, .asm_c76a ld a, e ld [wd0b8], a @@ -1062,7 +1062,7 @@ PC_c7ea: ; c7ea (3:47ea) call Func_c241 call $4915 call DoFrameIfLCDEnabled - text_hl TurnedPCOnText + ldtx hl, TurnedPCOnText call Func_2c73 call $484e .asm_c801 @@ -1070,7 +1070,7 @@ PC_c7ea: ; c7ea (3:47ea) call Func_c29b .asm_c806 call DoFrameIfLCDEnabled - call MenuCursorAcceptInput + call HandleMenuInput jr nc, .asm_c806 ld a, e ld [wd0b9], a @@ -1089,7 +1089,7 @@ PC_c7ea: ; c7ea (3:47ea) .asm_c82f call Func_c135 call DoFrameIfLCDEnabled - text_hl TurnedPCOffText + ldtx hl, TurnedPCOffText call Func_c891 call CloseDialogueBox xor a @@ -1098,7 +1098,7 @@ PC_c7ea: ; c7ea (3:47ea) ret ; 0xc846 -INCBIN "baserom.gbc",$c846,$c891 - $c846 + INCROM $c846, $c891 Func_c891: ; c891 (3:4891) push hl @@ -1177,11 +1177,11 @@ Func_c8ed: ; c8ed (3:c8ed) ld [hli], a ld [hl], a pop hl - call Func_2af0 + call YesOrNoMenuWithText jr .asm_c911 .asm_c90e - call $2af3 + call YesOrNoMenu .asm_c911 pop de @@ -1351,7 +1351,7 @@ Func_c9e8: ; c9e8 (3:49e8) ret Unknown_ca0a: ; ca0a (3:4a04) -INCBIN "baserom.gbc",$ca0a,$ca0e - $ca0a + INCROM $ca0a, $ca0e Func_ca0e: ; ca0e (3:4a0e) ld a, [wd32e] @@ -1430,7 +1430,7 @@ CheckIfEventFlagSet: ; ca6c (3:4a6c) ret ; 0xca84 -INCBIN "baserom.gbc",$ca84,$ca8f - $ca84 + INCROM $ca84, $ca8f Func_ca8f: ; ca8f (3:4a8f) call Func_cab3 @@ -1477,7 +1477,7 @@ Func_cab3: ; cab3 (3:4ab3) ret ; 0xcac2 -INCBIN "baserom.gbc",$cac2,$cac5 - $cac2 + INCROM $cac2, $cac5 SetEventFlags: ; cac5 (3:4ac5) push bc @@ -1487,7 +1487,7 @@ SetEventFlags: ; cac5 (3:4ac5) ret ; 0xcacd -INCBIN "baserom.gbc",$cacd,$cad0 - $cacd + INCROM $cacd, $cad0 Func_cad0: ; cad0 (3:4ad0) push bc @@ -1541,7 +1541,7 @@ Func_cad8: ; cad8 (3:4ad8) ret ; 0xcb15 -INCBIN "baserom.gbc",$cb15,$cb1d - $cb15 + INCROM $cb15, $cb1d GetEventFlagMod: ; cb1d (3:4b1d) push bc @@ -1563,7 +1563,7 @@ GetEventFlagMod: ; cb1d (3:4b1d) ; offset - bytes to set or reset EventFlagMods: ; cb37 (3:4b37) -INCBIN "baserom.gbc",$cb37,$cc32 - $cb37 + INCROM $cb37, $cc32 Func_cc32: ; cc32 (3:4c32) push hl @@ -1576,7 +1576,7 @@ Func_cc32: ; cc32 (3:4c32) ret ; 0xcc3e -INCBIN "baserom.gbc",$cc3e,$cc42 - $cc3e + INCROM $cc3e, $cc42 ; called when pressing a in front of an object. creates a pointer to the data right after an RST20 ; was called, then runs RunOverworldScript to handle that data @@ -1590,7 +1590,7 @@ RST20: ; cc42 (3:4c42) ld [wBreakOWScriptLoop], a .asm_cc4f call RunOverworldScript - ld a, [wBreakOWScriptLoop] ; if you break out, it jumps + ld a, [wBreakOWScriptLoop] ; if you break out, it jumps or a jr z, .asm_cc4f ld hl, wOWScriptPointer @@ -1639,7 +1639,7 @@ SetOWScriptPointer: ; cc8b (3:4c8b) ret ; 0xcc92 -INCBIN "baserom.gbc",$cc92,$cc96 - $cc92 + INCROM $cc92, $cc96 GetOWSArgs1AfterPointer: ; cc96 (3:4c96) ld a, $1 @@ -1701,7 +1701,7 @@ OWScript_EndScriptCloseText: ; cccc (3:4ccc) pop hl ret -;args: 2-Text String Index +; args: 2-Text String Index OWScript_PrintTextString: ; ccd4 (3:4cd4) ld l, c ld h, b @@ -1781,7 +1781,7 @@ Func_cd4f: ; cd4f (3:4d4f) jr asm_cd2f Unknown_dd63: ; cd4f (3:4d4f) -INCBIN "baserom.gbc",$cd63,$cd66 - $cd63 + INCROM $cd63, $cd66 Func_cd66: ; cd66 (3:4d66) ld a, c @@ -1999,7 +1999,7 @@ Func_ceba: ; ceba (3:4eba) jp IncreaseOWScriptPointerBy1 ; 0xcedd -INCBIN "baserom.gbc",$cedd,$cee2 - $cedd + INCROM $cedd, $cee2 Func_cee2: ; cee2 (3:4ee2) call Func_c2a3 @@ -2032,7 +2032,7 @@ Func_cf0c: ; cf0c (3:4f0c) Func_cf12: ; cf12 (3:4f12) ld a, c - call $1d1d + call Func_1d1d asm_cf16 or a @@ -2207,7 +2207,7 @@ Func_cfd4: ; cfd4 (3:4fd4) dec hl jp IncreaseOWScriptPointerBy1 -INCBIN "baserom.gbc",$d006,$d00b - $d006 + INCROM $d006, $d00b Func_d00b: ; d00b (3:500b) sla c @@ -2236,7 +2236,7 @@ Func_d025: ; d025 (3:5025) Func_d032: ; d032 (3:5032) call Func_ca69 dec hl - call $1d1d + call Func_1d1d jp c, Func_cf67 jp Func_cf6d @@ -2405,7 +2405,7 @@ Func_d135: ; d135 (3:5135) ld [hl], d jp IncreaseOWScriptPointerBy2 -INCBIN "baserom.gbc",$d153,$d16b - $d153 + INCROM $d153, $d16b Func_d16b: ; d16b (3:516b) ld hl, wd0c8 @@ -2477,7 +2477,7 @@ asm_d1c6 ld [wce40], a jp IncreaseOWScriptPointerBy1 -INCBIN "baserom.gbc",$d1dc,$d209 - $d1dc + INCROM $d1dc, $d209 Func_d209: ; d209 (3:5209) call Func_ca69 @@ -2510,7 +2510,7 @@ Func_d209: ; d209 (3:5209) ld a, c jr asm_d1c6 -INCBIN "baserom.gbc",$d234,$d244 - $d234 + INCROM $d234, $d244 Func_d244: ; d244 (3:5244) ld a, c @@ -2527,7 +2527,7 @@ Func_d24c: ; d24c (3:524c) halt jp IncreaseOWScriptPointerBy1 -INCBIN "baserom.gbc",$d25e,$d271 - $d25e + INCROM $d25e, $d271 Func_d271: ; d271 (3:5271) ld hl, $527b @@ -2536,7 +2536,7 @@ Func_d271: ; d271 (3:5271) jp IncreaseOWScriptPointerBy1 ; 0xd27b -INCBIN "baserom.gbc",$d27b,$d28c - $d27b + INCROM $d27b, $d28c Func_d28c: ; d28c (3:528c) ld [$d416], a @@ -2576,7 +2576,7 @@ Func_d28c: ; d28c (3:528c) .asm_d2c1 call DoFrameIfLCDEnabled - call MenuCursorAcceptInput + call HandleMenuInput jr nc, .asm_d2c1 ld a, [hCurrentMenuItem] cp e @@ -2627,7 +2627,7 @@ Func_d2f6: ; d2f6 (3:52f6) jp IncreaseOWScriptPointerBy1 ; 0xd30c -INCBIN "baserom.gbc",$d30c,$d317 - $d30c + INCROM $d30c, $d317 Func_d317: ; d317 (3:5317) ld hl, $532b @@ -2640,7 +2640,7 @@ Func_d317: ; d317 (3:5317) jp IncreaseOWScriptPointerBy1 -INCBIN "baserom.gbc",$d32b,$d336 - $d32b + INCROM $d32b, $d336 DeckMachine_d336: ; d336 (3:5336) push bc @@ -2736,7 +2736,7 @@ Func_d3d4: ; d3d4 (3:53d4) bank1call Func_7576 jp IncreaseOWScriptPointerBy1 -INCBIN "baserom.gbc",$d3dd,$d3e0 - $d3dd + INCROM $d3dd, $d3e0 Func_d3e0: ; d3e0 (3:53e0) ld a, $1 @@ -2769,7 +2769,7 @@ Func_d40f: ; d40f (3:540f) Func_d416: ; d416 (3:5416) ld a, c - call Func_3796 + call PlaySFX jp IncreaseOWScriptPointerBy2 Func_d41d: ; d41d (3:541d) @@ -2876,7 +2876,7 @@ Func_d4ae: ; d4ae (3:54ae) cp c jr c, Func_d490 ; 0xd4b2 $dc jr Func_d48a ; 0xd4b4 $d4 - + Func_d4b6: ; d4b6 (3:54b6) ld a, c ld c, b @@ -2916,7 +2916,7 @@ asm_d4e6 jp IncreaseOWScriptPointerBy4 ; 0xd4ec -INCBIN "baserom.gbc",$d4ec,$d753 - $d4ec + INCROM $d4ec, $d753 OWSequence_d753: ; d753 (3:5753) start_script @@ -2962,10 +2962,10 @@ OWSequence_d753: ; d753 (3:5753) db $80 db $58 db $02 - + ; there's more to this script but it hasn't been disassembled yet -INCBIN "baserom.gbc",$d77e,$e13f - $d77e + INCROM $d77e, $e13f WaterClubMovePlayer: ; e13f (3:613f) ld a, [wPlayerYCoord] @@ -3029,8 +3029,8 @@ OWSequence_BeatSara: ; e18c (3:618c) run_script OWScript_PrintTextString tx Text0430 run_script OWScript_GiveBoosterPacks - db BOOSTER_ColoWater - db BOOSTER_ColoWater + db BOOSTER_COLOSSEUM_WATER + db BOOSTER_COLOSSEUM_WATER db NO_BOOSTER run_script OWScript_PrintTextString tx Text0431 @@ -3067,8 +3067,8 @@ OWSequence_BeatAmanda: ; e1b3 (03:61b3) run_script OWScript_PrintTextString tx Text0437 run_script OWScript_GiveBoosterPacks - db BOOSTER_LightningColorless - db BOOSTER_LightningColorless + db BOOSTER_MYSTERY_LIGHTNING_COLORLESS + db BOOSTER_MYSTERY_LIGHTNING_COLORLESS db NO_BOOSTER run_script OWScript_PrintTextString tx Text0438 @@ -3080,7 +3080,7 @@ OWSequence_LostToAmanda: ; e1c1 (03:61c1) tx Text0439 OWSequence_NotReadyToSeeAmy: -INCBIN "baserom.gbc",$e1c5,$e21c - $e1c5 + INCROM $e1c5, $e21c OWSequence_Joshua: start_script @@ -3113,8 +3113,8 @@ OWSequence_Joshua: run_script Func_d484 db $33 db $01 - -INCBIN "baserom.gbc",$e23f,$e52c - $e23f + + INCROM $e23f, $e52c FindEndOfBattleScript: ; e52c (3:652c) ld c, $0 @@ -3147,7 +3147,7 @@ FindEndOfBattleScript: ; e52c (3:652c) jp Func_c926 ; 0xe553 -INCBIN "baserom.gbc",$e553,$f580 - $e553 + INCROM $e553, $f580 Func_f580: ; f580 (3:7580) call Func_ca69 @@ -3183,7 +3183,7 @@ Func_f580: ; f580 (3:7580) ret ; 0xf5b3 -INCBIN "baserom.gbc",$f5b3,$fc2b - $f5b3 + INCROM $f5b3, $fc2b Func_fc2b: ; fc2b (3:7c2b) ld a, [wd0c3] @@ -3210,16 +3210,16 @@ PointerTable_fc4c: ; fc4c (3:7c4c) dw Unknown_fc68 dw Unknown_fc60 -INCBIN "baserom.gbc",$fc52,$fc60 - $fc52 + INCROM $fc52, $fc60 Unknown_fc60: ; fc60 (3:7c60) -INCBIN "baserom.gbc",$fc60,$fc64 - $fc60 + INCROM $fc60, $fc64 Unknown_fc64: ; fc64 (3:7c64) -INCBIN "baserom.gbc",$fc64,$fc68 - $fc64 + INCROM $fc64, $fc68 Unknown_fc68: ; fc68 (3:7c68) -INCBIN "baserom.gbc",$fc68,$fcad - $fc68 + INCROM $fc68, $fcad Func_fcad: ; fcad (3:7cad) -INCBIN "baserom.gbc",$fcad,$10000 - $fcad + INCROM $fcad, $10000 diff --git a/src/engine/bank4.asm b/src/engine/bank4.asm index 394804f..29d96fc 100755 --- a/src/engine/bank4.asm +++ b/src/engine/bank4.asm @@ -42,10 +42,10 @@ Func_10031: ; 10031 (4:4031) ret Func_10059: ; 10059 (4:4059) -INCBIN "baserom.gbc",$10059,$100a2 - $10059 + INCROM $10059, $100a2 Func_100a2: ; 100a2 (4:40a2) -INCBIN "baserom.gbc",$100a2,$1029e - $100a2 + INCROM $100a2, $1029e Medal_1029e: ; 1029e (4:429e) sub $8 @@ -90,7 +90,7 @@ Medal_1029e: ; 1029e (4:429e) ld a, [wd116] cp $e0 jr nz, .asm_102e2 - text_hl WonTheMedalText + ldtx hl, WonTheMedalText call Func_2c73 call Func_3c96 call Func_37a0 @@ -99,7 +99,7 @@ Medal_1029e: ; 1029e (4:429e) ret Unknown_1030b: ; 1030b (4:430b) -INCBIN "baserom.gbc",$1030b,$1031b - $1030b + INCROM $1030b, $1031b BoosterPack_1031b: ; 1031b (4:431b) ld c, a @@ -142,16 +142,16 @@ BoosterPack_1031b: ; 1031b (4:431b) pop bc ld a, c farcall GenerateBoosterPack - text_hl ReceivedBoosterPackText + ldtx hl, ReceivedBoosterPackText ld a, [wd117] cp $1 jr nz, .asm_10373 - text_hl AndAnotherBoosterPackText + ldtx hl, AndAnotherBoosterPackText .asm_10373 call Func_2c73 call Func_3c96 call Func_37a0 - text_hl CheckedCardsInBoosterPackText + ldtx hl, CheckedCardsInBoosterPackText call Func_2c73 call DisableLCD call Func_1288c @@ -168,10 +168,10 @@ BoosterPack_1031b: ; 1031b (4:431b) ret ; 0x103a5 -INCBIN "baserom.gbc",$103a5,$103d2 - $103a5 + INCROM $103a5, $103d2 Func_103d2: ; 103d2 (4:43d2) -INCBIN "baserom.gbc",$103d2,$103d3 - $103d2 + INCROM $103d2, $103d3 Duel_Init: ; 103d3 (4:43d3) ld a, [wd291] @@ -220,10 +220,10 @@ Duel_Init: ; 103d3 (4:43d3) call PlaySong call $4031 call DoFrameIfLCDEnabled - ld bc, $2f1d - ld de, $1211 - call Func_2a1a - call Func_2a00 ; wait for the user to press a or b + lb bc, $2f, $1d ; cursor tile, tile behind cursor + lb de, 18, 17 ; x, y + call SetCursorParametersForTextBox + call WaitForButtonAorB ; wait for the user to press a or b call Func_3c96 call Func_10ab4 ; fade out pop af @@ -231,13 +231,13 @@ Duel_Init: ; 103d3 (4:43d3) ret ; 0x10451 -INCBIN "baserom.gbc",$10451,$10548 - $10451 + INCROM $10451, $10548 Func_10548: ; 10548 (4:4548) -INCBIN "baserom.gbc",$10548,$10756 - $10548 + INCROM $10548, $10756 Func_10756: ; 10756 (4:4756) -INCBIN "baserom.gbc",$10756,$10a70 - $10756 + INCROM $10756, $10a70 Func_10a70: ; 10a70 (4:4a70) push hl @@ -277,13 +277,13 @@ Func_10a70: ; 10a70 (4:4a70) ret Func_10a9b: ; 10a9b (4:4a9b) -INCBIN "baserom.gbc",$10a9b,$10ab4 - $10a9b + INCROM $10a9b, $10ab4 Func_10ab4: ; 10ab4 (4:4ab4) -INCBIN "baserom.gbc",$10ab4,$10af9 - $10ab4 + INCROM $10ab4, $10af9 Func_10af9: ; 10af9 (4:4af9) -INCBIN "baserom.gbc",$10af9,$10c96 - $10af9 + INCROM $10af9, $10c96 Func_10c96: ; 10c96 (4:4c96) ld a, [$ff81] @@ -308,7 +308,7 @@ Func_10c96: ; 10c96 (4:4c96) ret ; 0x10cbb -INCBIN "baserom.gbc",$10cbb,$10dba - $10cbb + INCROM $10cbb, $10dba Func_10dba: ; 10dba (4:4dba) ld a, $1 @@ -318,7 +318,7 @@ Func_10dba: ; 10dba (4:4dba) farcall Func_111e9 .asm_10dca call DoFrameIfLCDEnabled - call MenuCursorAcceptInput + call HandleMenuInput jr nc, .asm_10dca ld a, e ld [wd0ba], a @@ -338,10 +338,10 @@ Func_10dba: ; 10dba (4:4dba) ret ; 0x10df0 -INCBIN "baserom.gbc",$10df0,$10e28 - $10df0 + INCROM $10df0, $10e28 Func_10e28: ; 10e28 (4:4e28) -INCBIN "baserom.gbc",$10e28,$10e55 - $10e28 + INCROM $10e28, $10e55 Func_10e55: ; 10e55 (4:4e55) ld a, [wd336] @@ -373,7 +373,7 @@ Func_10e71: ; 10e71 (4:4e71) and A_BUTTON jr z, .asm_10e96 ld a, $2 - call Func_3796 + call PlaySFX call Func_11016 call Func_11024 jr .asm_10e96 @@ -399,14 +399,14 @@ Func_10e97: ; 10e97 (4:4e97) ld [wd32e], a call Func_10f2e ld a, $1 - call Func_3796 + call PlaySFX .asm_10eb9 pop bc pop hl ret Unknown_10ebc: ; 10ebc (4:4ebc) -INCBIN "baserom.gbc",$10ebc,$10efd - $10ebc + INCROM $10ebc, $10efd Func_10efd: ; 10efd (4:4efd) push hl @@ -429,7 +429,7 @@ Func_10efd: ; 10efd (4:4efd) ret Unknown_10f14: ; 10f14 (4:4f14) -INCBIN "baserom.gbc",$10f14,$10f2e - $10f14 + INCROM $10f14, $10f2e Func_10f2e: ; 10f2e (4:4f2e) push hl @@ -549,7 +549,7 @@ Func_11016: ; 11016 (4:5016) Func_11024: ; 11024 (4:5024) ld a, $57 - call Func_3796 + call PlaySFX ld a, [wd336] ld [wd4cf], a ld c, $f @@ -789,22 +789,22 @@ Func_11184: ; 11184 (4:5184) ret ; 0x111b3 -INCBIN "baserom.gbc",$111b3,$111e9 - $111b3 + INCROM $111b3, $111e9 Func_111e9: ; 111e9 (4:51e9) -INCBIN "baserom.gbc",$111e9,$1124d - $111e9 + INCROM $111e9, $1124d Func_1124d: ; 1124d (4:524d) -INCBIN "baserom.gbc",$1124d,$11320 - $1124d + INCROM $1124d, $11320 Func_11320: ; 11320 (4:5320) -INCBIN "baserom.gbc",$11320,$11416 - $11320 + INCROM $11320, $11416 Func_11416: ; 11416 (4:5416) -INCBIN "baserom.gbc",$11416,$11430 - $11416 + INCROM $11416, $11430 Func_11430: ; 11430 (4:5430) -INCBIN "baserom.gbc",$11430,$1157c - $11430 + INCROM $11430, $1157c Func_1157c: ; 1157c (4:557c) ld a, c @@ -831,7 +831,7 @@ Func_1157c: ; 1157c (4:557c) ; 0x115a3 -INCBIN "baserom.gbc",$115a3,$1162a - $115a3 + INCROM $115a3, $1162a INCLUDE "data/map_scripts.asm" @@ -958,9 +958,9 @@ Func_118d3: ; 118d3 (4:58d3) pop hl ret -INCLUDE "data/unknownNPCData.asm" +INCLUDE "data/npcs.asm" -INCBIN "baserom.gbc",$11f4e,$1217b - $11f4e + INCROM $11f4e, $1217b OverworldScriptTable: ; 1217b (4:617b) dw OWScript_EndScriptLoop1 @@ -1068,10 +1068,10 @@ OverworldScriptTable: ; 1217b (4:617b) dw OWScript_EndScriptLoop9 dw OWScript_EndScriptLoop10 -INCBIN "baserom.gbc",$1224b,$1229f - $1224b + INCROM $1224b, $1229f Unknown_1229f: ; 1229f (4:629f) -INCBIN "baserom.gbc",$1229f,$126d1 - $1229f + INCROM $1229f, $126d1 Func_126d1: ; 126d1 (4:66d1) call Func_099c @@ -1164,19 +1164,19 @@ Func_1277e: ; 1277e (4:677e) ret ; 0x1279a -INCBIN "baserom.gbc",$1279a,$12871 - $1279a + INCROM $1279a, $12871 Func_12871: ; 12871 (4:6871) -INCBIN "baserom.gbc",$12871,$1288c - $12871 + INCROM $12871, $1288c Func_1288c: ; 1288c (4:688c) -INCBIN "baserom.gbc",$1288c,$128a9 - $1288c + INCROM $1288c, $128a9 Func_128a9: ; 128a9 (4:68a9) -INCBIN "baserom.gbc",$128a9,$1296e - $128a9 + INCROM $128a9, $1296e Func_1296e: ; 1296e (4:696e) -INCBIN "baserom.gbc",$1296e,$1299f - $1296e + INCROM $1296e, $1299f Func_1299f: ; 1299f (4:699f) push af @@ -1245,10 +1245,10 @@ Func_129d9: ; 129d9 (4:69d9) ret ; 0x129fa -INCBIN "baserom.gbc",$129fa,$12a21 - $129fa + INCROM $129fa, $12a21 Func_12a21: ; 12a21 (4:6a21) -INCBIN "baserom.gbc",$12a21,$12ab5 - $12a21 + INCROM $12a21, $12ab5 Func_12ab5: ; 12ab5 (4:6ab5) push hl @@ -1266,7 +1266,7 @@ Func_12ab5: ; 12ab5 (4:6ab5) ret ; 0x12ac9 -INCBIN "baserom.gbc",$12ac9,$12ae2 - $12ac9 + INCROM $12ac9, $12ae2 Func_12ae2: ; 12ae2 (4:6ae2) push bc @@ -1409,10 +1409,10 @@ Func_12b89: ; 12b89 (4:6b89) ret Func_12ba7: ; 12ba7 (4:6ba7) -INCBIN "baserom.gbc",$12ba7,$12bcd - $12ba7 + INCROM $12ba7, $12bcd Func_12bcd: ; 12bcd (4:6bcd) -INCBIN "baserom.gbc",$12bcd,$12c05 - $12bcd + INCROM $12bcd, $12c05 Func_12c05: ; 12c05 (4:6c05) push hl @@ -1487,29 +1487,29 @@ Func_12c4f: ; 12c4f (4:6c4f) ret Func_12c5e: ; 12c5e (4:6c5e) -INCBIN "baserom.gbc",$12c5e,$12c7f - $12c5e + INCROM $12c5e, $12c7f Func_12c7f: ; 12c7f (4:6c7f) -INCBIN "baserom.gbc",$12c7f,$131b3 - $12c7f + INCROM $12c7f, $131b3 Func_131b3: ; 131b3 (4:71b3) -INCBIN "baserom.gbc",$131b3,$131d3 - $131b3 + INCROM $131b3, $131d3 Func_131d3: ; 131d3 (4:71d3) -INCBIN "baserom.gbc",$131d3,$1344d - $131d3 + INCROM $131d3, $1344d Func_1344d: ; 1344d (4:744d) call Func_379b ld a, MUSIC_MEDAL call PlaySong - text_hl DefeatedFiveOpponentsText + ldtx hl, DefeatedFiveOpponentsText call Func_2c73 call Func_3c96 call Func_37a0 ret ; 0x13462 -INCBIN "baserom.gbc",$13462,$13485 - $13462 + INCROM $13462, $13485 Func_13485: ; 13485 (4:7485) call EnableExtRAM @@ -1524,11 +1524,11 @@ Func_13485: ; 13485 (4:7485) call Func_379b ld a, MUSIC_MEDAL call PlaySong - text_hl ConsecutiveWinRecordIncreasedText + ldtx hl, ConsecutiveWinRecordIncreasedText call Func_2c73 call Func_3c96 call Func_37a0 ret ; 0x134b1 -INCBIN "baserom.gbc",$134b1,$14000 - $134b1 + INCROM $134b1, $14000 diff --git a/src/engine/bank5.asm b/src/engine/bank5.asm index d65c21b..3f0e5a2 100755 --- a/src/engine/bank5.asm +++ b/src/engine/bank5.asm @@ -1,323 +1,323 @@ -PointerTable_14000: ; 14000 (05:4000)
- dw $47bd ; SAMS_PRACTICE_DECK
- dw PointerTable_14668 ; PRACTICE_PLAYER_DECK
- dw PointerTable_14668 ; SAMS_NORMAL_DECK
- dw PointerTable_14668 ; CHARMANDER_AND_FRIENDS_DECK
- dw PointerTable_14668 ; CHARMANDER_EXTRA_DECK
- dw PointerTable_14668 ; SQUIRTLE_AND_FRIENDS_DECK
- dw PointerTable_14668 ; SQUIRTLE_EXTRA_DECK
- dw PointerTable_14668 ; BULBASAUR_AND_FRIENDS_DECK
- dw PointerTable_14668 ; BULBASAUR_EXTRA_DECK
- dw PointerTable_14668 ; LIGHTNING_AND_FIRE_DECK
- dw PointerTable_14668 ; WATER_AND_FIGHTING_DECK
- dw PointerTable_14668 ; GRASS_AND_PSYCHIC_DECK
- dw $49e8 ; LEGENDARY_MOLTRES_DECK
- dw $4b0f ; LEGENDARY_ZAPDOS_DECK
- dw $4c0b ; LEGENDARY_ARTICUNO_DECK
- dw $4d60 ; LEGENDARY_DRAGONITE_DECK
- dw $4e89 ; FIRST_STRIKE_DECK
- dw $4f0e ; ROCK_CRUSHER_DECK
- dw $4f8f ; GO_GO_RAIN_DANCE_DECK
- dw $5019 ; ZAPPING_SELFDESTRUCT_DECK
- dw $509b ; FLOWER_POWER_DECK
- dw $5122 ; STRANGE_PSYSHOCK_DECK
- dw $51ad ; WONDERS_OF_SCIENCE_DECK
- dw $5232 ; FIRE_CHARGE_DECK
- dw $52bd ; IM_RONALD_DECK
- dw $534b ; POWERFUL_RONALD_DECK
- dw $53e8 ; INVINCIBLE_RONALD_DECK
- dw $546f ; LEGENDARY_RONALD_DECK
- dw $48dc ; MUSCLES_FOR_BRAINS_DECK
- dw PointerTable_14668 ; HEATED_BATTLE_DECK
- dw PointerTable_14668 ; LOVE_TO_BATTLE_DECK
- dw PointerTable_14668 ; EXCAVATION_DECK
- dw PointerTable_14668 ; BLISTERING_POKEMON_DECK
- dw PointerTable_14668 ; HARD_POKEMON_DECK
- dw PointerTable_14668 ; WATERFRONT_POKEMON_DECK
- dw PointerTable_14668 ; LONELY_FRIENDS_DECK
- dw PointerTable_14668 ; SOUND_OF_THE_WAVES_DECK
- dw PointerTable_14668 ; PIKACHU_DECK
- dw PointerTable_14668 ; BOOM_BOOM_SELFDESTRUCT_DECK
- dw PointerTable_14668 ; POWER_GENERATOR_DECK
- dw PointerTable_14668 ; ETCETERA_DECK
- dw PointerTable_14668 ; FLOWER_GARDEN_DECK
- dw PointerTable_14668 ; KALEIDOSCOPE_DECK
- dw PointerTable_14668 ; GHOST_DECK
- dw PointerTable_14668 ; NAP_TIME_DECK
- dw PointerTable_14668 ; STRANGE_POWER_DECK
- dw PointerTable_14668 ; FLYIN_POKEMON_DECK
- dw PointerTable_14668 ; LOVELY_NIDORAN_DECK
- dw PointerTable_14668 ; POISON_DECK
- dw PointerTable_14668 ; ANGER_DECK
- dw PointerTable_14668 ; FLAMETHROWER_DECK
- dw PointerTable_14668 ; RESHUFFLE_DECK
- dw $48dc ; IMAKUNI_DECK
-; 1406a
-
-INCBIN "baserom.gbc",$1406a,$14226 - $1406a
-
-Func_14226: ; 14226 (5:4226)
- call CreateHandCardBuffer
- ld hl, wDuelCardOrAttackList
-.checkForNextPokemon
- ld a, [hli]
- ld [$ff98], a
- cp $ff
- ret z
- call LoadDeckCardToBuffer1
- ld a, [wLoadedCard1Type]
- cp FIRE_ENERGY_CARD
- jr nc, .checkForNextPokemon
- ld a, [wLoadedCard1Stage]
- or a
- jr nz, .checkForNextPokemon
- push hl
- ld a, [$ff98]
- call $1485
- pop hl
- jr .checkForNextPokemon
-; 0x1424b
-
-INCBIN "baserom.gbc",$1424b,$14663 - $1424b
-
-Func_14663: ; 14663 (5:4663)
- farcall Func_200e5
- ret
-
-; GENERAL DECK POINTER LIST - Not sure on all of these.
-; This is an example of an AI pointer table, there's one for each AI type.
-PointerTable_14668: ; 14668 (05:4668)
- dw Func_14674 ; not used
- dw Func_14674 ; general AI for battles
- dw Func_14678 ; basic pokemon placement / cheater shuffling on better AI
- dw Func_1467f
- dw Func_14683
- dw Func_14687
-
-; when battle AI gets called
-Func_14674: ; 14674 (5:4674)
- call Func_1468b
- ret
-
-Func_14678: ; 14678 (5:4678)
- call Func_15636
- call $4226
- ret
-
-Func_1467f: ; 1467f (5:467f)
- call $5b72
- ret
-
-Func_14683: ; 14683 (5:4683)
- call $5b72
- ret
-
-Func_14687: ; 14687 (5:4687)
- call $41e5
- ret
-
-; AI for general decks i think
-Func_1468b: ; 1468b (5:468b)
- call Func_15649
- ld a, $1
- call Func_14663
- farcallx $8, $67d3
- jp nc, $4776
- farcallx $8, $6790
- farcallx $8, $66a3
- farcallx $8, $637f
- ret c
- farcallx $8, $662d
- ld a, $2
- call Func_14663
- ld a, $3
- call Func_14663
- ld a, $4
- call Func_14663
- call $5eae
- ret c
- ld a, $5
- call Func_14663
- ld a, $6
- call Func_14663
- ld a, $7
- call Func_14663
- ld a, $8
- call Func_14663
- call $4786
- ld a, $a
- call Func_14663
- ld a, $b
- call Func_14663
- ld a, $c
- call Func_14663
- ld a, [wAlreadyPlayedEnergy]
- or a
- jr nz, .asm_146ed
- call $64e8
-
-.asm_146ed
- call $5eae
- farcallx $8, $66a3
- farcallx $8, $637f
- ret c
- farcallx $8, $6790
- ld a, $d
- farcallx $8, $619b
- ld a, $d
- call Func_14663
- ld a, $f
- call Func_14663
- ld a, [$ce20]
- and $4
- jr z, .asm_14776
- ld a, $1
- call Func_14663
- ld a, $2
- call Func_14663
- ld a, $3
- call Func_14663
- ld a, $4
- call Func_14663
- call $5eae
- ret c
- ld a, $5
- call Func_14663
- ld a, $6
- call Func_14663
- ld a, $7
- call Func_14663
- ld a, $8
- call Func_14663
- call $4786
- ld a, $a
- call Func_14663
- ld a, $b
- call Func_14663
- ld a, $c
- call Func_14663
- ld a, [wAlreadyPlayedEnergy]
- or a
- jr nz, .asm_1475b
- call $64e8
-
-.asm_1475b
- call $5eae
- farcallx $8, $66a3
- farcallx $8, $637f
- ret c
- farcallx $8, $6790
- ld a, $d
- farcallx $8, $619b
- ld a, $d
- call Func_14663
-
-.asm_14776
- ld a, $e
- farcallx $8, $619b
- call $69f8
- ret c
- ld a, $5
- bank1call $67be
- ret
-; 0x14786
-
-
-INCBIN "baserom.gbc",$14786,$15636 - $14786
-Func_15636: ; 15636 (5:5636)
- ld a, $10
- ld hl, $cda5
- call ZeroData
- ld a, $5
- ld [$cda6], a
- ld a, $ff
- ld [$cda5], a
- ret
-
-Func_15649: ; 15649 (5:5649)
- ld a, [$cda6]
- inc a
- ld [$cda6], a
- xor a
- ld [$ce20], a
- ld [$cddb], a
- ld [$cddc], a
- ld [$ce03], a
- ld a, [wcc10]
- cp $ff
- jr z, .asm_156b1
- or a
- jr z, .asm_156b1
- ld a, [wcc11]
- cp $ff
- jr z, .asm_156b1
- call SwapTurn
- call GetCardInDeckPosition
- call SwapTurn
- ld a, e
- cp MEWTWO1 ; I believe this is a check for Mewtwo1's Barrier move
- jr nz, .asm_156b1
- ld a, [$cda7]
- bit 7, a
- jr nz, .asm_156aa
- inc a
- ld [$cda7], a
- cp $3
- jr c, .asm_156c2
- ld a, (wPlayerArenaCard & $FF)
- call GetNonTurnDuelistVariable
- call SwapTurn
- call GetCardInDeckPosition
- call SwapTurn
- ld a, e
- cp MEWTWO1
- jr nz, .asm_156a4
- farcallx $8, $67a9
- jr nc, .asm_156aa
-
-.asm_156a4
- xor a
- ld [$cda7], a
- jr .asm_156c2
-
-.asm_156aa
- ld a, $80
- ld [$cda7], a
- jr .asm_156c2
-
-.asm_156b1
- ld a, [$cda7]
- bit 7, a
- jr z, .asm_156be
- inc a
- ld [$cda7], a
- jr .asm_156c2
-
-.asm_156be
- xor a
- ld [$cda7], a
-
-.asm_156c2
- ret
-; 0x156c3
-
-INCBIN "baserom.gbc",$156c3,$1575e - $156c3
-
-; zeroes a bytes starting at hl
-ZeroData: ; 1575e (5:575e)
- push af
- push bc
- push hl
- ld b, a
- xor a
-.clearLoop
- ld [hli], a
- dec b
- jr nz, .clearLoop
- pop hl
- pop bc
- pop af
- ret
-; 0x1576b
-
-INCBIN "baserom.gbc",$1576b,$18000 - $1576b
+PointerTable_14000: ; 14000 (05:4000) + dw $47bd ; SAMS_PRACTICE_DECK + dw PointerTable_14668 ; PRACTICE_PLAYER_DECK + dw PointerTable_14668 ; SAMS_NORMAL_DECK + dw PointerTable_14668 ; CHARMANDER_AND_FRIENDS_DECK + dw PointerTable_14668 ; CHARMANDER_EXTRA_DECK + dw PointerTable_14668 ; SQUIRTLE_AND_FRIENDS_DECK + dw PointerTable_14668 ; SQUIRTLE_EXTRA_DECK + dw PointerTable_14668 ; BULBASAUR_AND_FRIENDS_DECK + dw PointerTable_14668 ; BULBASAUR_EXTRA_DECK + dw PointerTable_14668 ; LIGHTNING_AND_FIRE_DECK + dw PointerTable_14668 ; WATER_AND_FIGHTING_DECK + dw PointerTable_14668 ; GRASS_AND_PSYCHIC_DECK + dw $49e8 ; LEGENDARY_MOLTRES_DECK + dw $4b0f ; LEGENDARY_ZAPDOS_DECK + dw $4c0b ; LEGENDARY_ARTICUNO_DECK + dw $4d60 ; LEGENDARY_DRAGONITE_DECK + dw $4e89 ; FIRST_STRIKE_DECK + dw $4f0e ; ROCK_CRUSHER_DECK + dw $4f8f ; GO_GO_RAIN_DANCE_DECK + dw $5019 ; ZAPPING_SELFDESTRUCT_DECK + dw $509b ; FLOWER_POWER_DECK + dw $5122 ; STRANGE_PSYSHOCK_DECK + dw $51ad ; WONDERS_OF_SCIENCE_DECK + dw $5232 ; FIRE_CHARGE_DECK + dw $52bd ; IM_RONALD_DECK + dw $534b ; POWERFUL_RONALD_DECK + dw $53e8 ; INVINCIBLE_RONALD_DECK + dw $546f ; LEGENDARY_RONALD_DECK + dw $48dc ; MUSCLES_FOR_BRAINS_DECK + dw PointerTable_14668 ; HEATED_BATTLE_DECK + dw PointerTable_14668 ; LOVE_TO_BATTLE_DECK + dw PointerTable_14668 ; EXCAVATION_DECK + dw PointerTable_14668 ; BLISTERING_POKEMON_DECK + dw PointerTable_14668 ; HARD_POKEMON_DECK + dw PointerTable_14668 ; WATERFRONT_POKEMON_DECK + dw PointerTable_14668 ; LONELY_FRIENDS_DECK + dw PointerTable_14668 ; SOUND_OF_THE_WAVES_DECK + dw PointerTable_14668 ; PIKACHU_DECK + dw PointerTable_14668 ; BOOM_BOOM_SELFDESTRUCT_DECK + dw PointerTable_14668 ; POWER_GENERATOR_DECK + dw PointerTable_14668 ; ETCETERA_DECK + dw PointerTable_14668 ; FLOWER_GARDEN_DECK + dw PointerTable_14668 ; KALEIDOSCOPE_DECK + dw PointerTable_14668 ; GHOST_DECK + dw PointerTable_14668 ; NAP_TIME_DECK + dw PointerTable_14668 ; STRANGE_POWER_DECK + dw PointerTable_14668 ; FLYIN_POKEMON_DECK + dw PointerTable_14668 ; LOVELY_NIDORAN_DECK + dw PointerTable_14668 ; POISON_DECK + dw PointerTable_14668 ; ANGER_DECK + dw PointerTable_14668 ; FLAMETHROWER_DECK + dw PointerTable_14668 ; RESHUFFLE_DECK + dw $48dc ; IMAKUNI_DECK +; 1406a + + INCROM $1406a, $14226 + +Func_14226: ; 14226 (5:4226) + call CreateHandCardBuffer + ld hl, wDuelCardOrAttackList +.checkForNextPokemon + ld a, [hli] + ld [$ff98], a + cp $ff + ret z + call LoadDeckCardToBuffer1 + ld a, [wLoadedCard1Type] + cp TYPE_ENERGY_FIRE + jr nc, .checkForNextPokemon + ld a, [wLoadedCard1Stage] + or a + jr nz, .checkForNextPokemon + push hl + ld a, [$ff98] + call Func_1485 + pop hl + jr .checkForNextPokemon +; 0x1424b + + INCROM $1424b, $14663 + +Func_14663: ; 14663 (5:4663) + farcall Func_200e5 + ret + +; GENERAL DECK POINTER LIST - Not sure on all of these. +; This is an example of an AI pointer table, there's one for each AI type. +PointerTable_14668: ; 14668 (05:4668) + dw Func_14674 ; not used + dw Func_14674 ; general AI for battles + dw Func_14678 ; basic pokemon placement / cheater shuffling on better AI + dw Func_1467f + dw Func_14683 + dw Func_14687 + +; when battle AI gets called +Func_14674: ; 14674 (5:4674) + call Func_1468b + ret + +Func_14678: ; 14678 (5:4678) + call Func_15636 + call $4226 + ret + +Func_1467f: ; 1467f (5:467f) + call $5b72 + ret + +Func_14683: ; 14683 (5:4683) + call $5b72 + ret + +Func_14687: ; 14687 (5:4687) + call $41e5 + ret + +; AI for general decks i think +Func_1468b: ; 1468b (5:468b) + call Func_15649 + ld a, $1 + call Func_14663 + farcallx $8, $67d3 + jp nc, $4776 + farcallx $8, $6790 + farcallx $8, $66a3 + farcallx $8, $637f + ret c + farcallx $8, $662d + ld a, $2 + call Func_14663 + ld a, $3 + call Func_14663 + ld a, $4 + call Func_14663 + call $5eae + ret c + ld a, $5 + call Func_14663 + ld a, $6 + call Func_14663 + ld a, $7 + call Func_14663 + ld a, $8 + call Func_14663 + call $4786 + ld a, $a + call Func_14663 + ld a, $b + call Func_14663 + ld a, $c + call Func_14663 + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_146ed + call $64e8 + +.asm_146ed + call $5eae + farcallx $8, $66a3 + farcallx $8, $637f + ret c + farcallx $8, $6790 + ld a, $d + farcallx $8, $619b + ld a, $d + call Func_14663 + ld a, $f + call Func_14663 + ld a, [$ce20] + and $4 + jr z, .asm_14776 + ld a, $1 + call Func_14663 + ld a, $2 + call Func_14663 + ld a, $3 + call Func_14663 + ld a, $4 + call Func_14663 + call $5eae + ret c + ld a, $5 + call Func_14663 + ld a, $6 + call Func_14663 + ld a, $7 + call Func_14663 + ld a, $8 + call Func_14663 + call $4786 + ld a, $a + call Func_14663 + ld a, $b + call Func_14663 + ld a, $c + call Func_14663 + ld a, [wAlreadyPlayedEnergy] + or a + jr nz, .asm_1475b + call $64e8 + +.asm_1475b + call $5eae + farcallx $8, $66a3 + farcallx $8, $637f + ret c + farcallx $8, $6790 + ld a, $d + farcallx $8, $619b + ld a, $d + call Func_14663 + +.asm_14776 + ld a, $e + farcallx $8, $619b + call $69f8 + ret c + ld a, $5 + bank1call $67be + ret +; 0x14786 + + + INCROM $14786, $15636 +Func_15636: ; 15636 (5:5636) + ld a, $10 + ld hl, $cda5 + call ZeroData + ld a, $5 + ld [$cda6], a + ld a, $ff + ld [$cda5], a + ret + +Func_15649: ; 15649 (5:5649) + ld a, [$cda6] + inc a + ld [$cda6], a + xor a + ld [$ce20], a + ld [$cddb], a + ld [$cddc], a + ld [$ce03], a + ld a, [wcc10] + cp $ff + jr z, .asm_156b1 + or a + jr z, .asm_156b1 + ld a, [wcc11] + cp $ff + jr z, .asm_156b1 + call SwapTurn + call GetCardInDeckPosition + call SwapTurn + ld a, e + cp MEWTWO1 ; I believe this is a check for Mewtwo1's Barrier move + jr nz, .asm_156b1 + ld a, [$cda7] + bit 7, a + jr nz, .asm_156aa + inc a + ld [$cda7], a + cp $3 + jr c, .asm_156c2 + ld a, (wPlayerArenaCard & $FF) + call GetNonTurnDuelistVariable + call SwapTurn + call GetCardInDeckPosition + call SwapTurn + ld a, e + cp MEWTWO1 + jr nz, .asm_156a4 + farcallx $8, $67a9 + jr nc, .asm_156aa + +.asm_156a4 + xor a + ld [$cda7], a + jr .asm_156c2 + +.asm_156aa + ld a, $80 + ld [$cda7], a + jr .asm_156c2 + +.asm_156b1 + ld a, [$cda7] + bit 7, a + jr z, .asm_156be + inc a + ld [$cda7], a + jr .asm_156c2 + +.asm_156be + xor a + ld [$cda7], a + +.asm_156c2 + ret +; 0x156c3 + + INCROM $156c3, $1575e + +; zeroes a bytes starting at hl +ZeroData: ; 1575e (5:575e) + push af + push bc + push hl + ld b, a + xor a +.clearLoop + ld [hli], a + dec b + jr nz, .clearLoop + pop hl + pop bc + pop af + ret +; 0x1576b + + INCROM $1576b, $18000 diff --git a/src/engine/bank6.asm b/src/engine/bank6.asm index c66e669..6428c3f 100755 --- a/src/engine/bank6.asm +++ b/src/engine/bank6.asm @@ -1,8 +1,8 @@ -INCBIN "baserom.gbc",$18000,$186f7 - $18000 + INCROM $18000, $186f7 INCLUDE "data/effect_commands.asm" -INCBIN "baserom.gbc",$18f9c,$1996e - $18f9c + INCROM $18f9c, $1996e Func_1996e: ; 1996e (6:596e) call EnableExtRAM @@ -108,7 +108,7 @@ Func_19a12: ; 19a12 (6:5a12) ret ; 0x19a1f -INCBIN "baserom.gbc",$19a1f,$1a61f - $19a1f + INCROM $19a1f, $1a61f Func_1a61f: ; 1a61f (6:661f) push af @@ -124,23 +124,23 @@ Func_1a61f: ; 1a61f (6:661f) ld a, $76 call $663b ld a, $c1 - text_hl ReceivedLegendaryCardText + ldtx hl, ReceivedLegendaryCardText jr .asm_1a660 .asm_1a640 - text_hl ReceivedCardText + ldtx hl, ReceivedCardText cp $1e jr z, .asm_1a660 cp $43 jr z, .asm_1a660 - text_hl ReceivedPromotionalFlyingPikachuText + ldtx hl, ReceivedPromotionalFlyingPikachuText cp $64 jr z, .asm_1a660 - text_hl ReceivedPromotionalSurfingPikachuText + ldtx hl, ReceivedPromotionalSurfingPikachuText cp $65 jr z, .asm_1a660 cp $66 jr z, .asm_1a660 - text_hl ReceivedPromotionalCardText + ldtx hl, ReceivedPromotionalCardText .asm_1a660 push hl ld e, a @@ -167,13 +167,13 @@ Func_1a61f: ; 1a61f (6:661f) ret ; 0x1a68d -INCBIN "baserom.gbc",$1a68d,$1a6cc - $1a68d + INCROM $1a68d, $1a6cc Func_1a6cc: ; 1a6cc (6:66cc) ret ; 0x1a6cd -INCBIN "baserom.gbc",$1a6cd,$1ad89 - $1a6cd + INCROM $1a6cd, $1ad89 Func_1ad89: ; 1ad89 (6:6d89) -INCBIN "baserom.gbc",$1ad89,$1c000 - $1ad89 + INCROM $1ad89, $1c000 diff --git a/src/engine/bank7.asm b/src/engine/bank7.asm index 160092d..9d2d603 100755 --- a/src/engine/bank7.asm +++ b/src/engine/bank7.asm @@ -1,4 +1,4 @@ -INCBIN "baserom.gbc",$1c000,$1c056 - $1c000 + INCROM $1c000, $1c056 Func_1c056: ; 1c056 (7:4056) push hl @@ -48,7 +48,7 @@ Func_1c056: ; 1c056 (7:4056) pop hl ret -INCLUDE "data/warp_data.asm" +INCLUDE "data/warps.asm" Func_1c33b: ; 1c33b (7:433b) push hl @@ -91,7 +91,7 @@ Func_1c33b: ; 1c33b (7:433b) INCLUDE "data/map_songs.asm" Func_1c440: ; 1c440 (7:4440) -INCBIN "baserom.gbc",$1c440,$1c455 - $1c440 + INCROM $1c440, $1c455 Func_1c455: ; 1c455 (7:4455) push hl @@ -129,13 +129,13 @@ Func_1c477: ; 1c477 (7:4477) ret Func_1c485: ; 1c485 (7:4485) -INCBIN "baserom.gbc",$1c485,$1c50a - $1c485 + INCROM $1c485, $1c50a Func_1c50a: ; 1c50a (7:450a) push hl call Func_1c719 ld a, [wd3aa] - call $39a7 + call Func_39a7 ld a, [hl] or a jr z, .asm_1c52c @@ -224,16 +224,16 @@ Func_1c57b: ; 1c57b (7:457b) ret Func_1c58e: ; 1c58e (7:458e) -INCBIN "baserom.gbc",$1c58e,$1c5e9 - $1c58e + INCROM $1c58e, $1c5e9 Func_1c5e9: ; 1c5e9 (7:45e9) -INCBIN "baserom.gbc",$1c5e9,$1c610 - $1c5e9 + INCROM $1c5e9, $1c610 Func_1c610: ; 1c610 (7:4610) -INCBIN "baserom.gbc",$1c610,$1c6f8 - $1c610 + INCROM $1c610, $1c6f8 Func_1c6f8: ; 1c6f8 (7:46f8) -INCBIN "baserom.gbc",$1c6f8,$1c719 - $1c6f8 + INCROM $1c6f8, $1c719 Func_1c719: ; 1c719 (7:4719) push hl @@ -251,7 +251,7 @@ Func_1c719: ; 1c719 (7:4719) ret Func_1c72e: ; 1c72e (7:472e) -INCBIN "baserom.gbc",$1c72e,$1c768 - $1c72e + INCROM $1c72e, $1c768 Func_1c768: ; 1c768 (7:4768) push hl @@ -265,7 +265,7 @@ Func_1c768: ; 1c768 (7:4768) ld a, $02 farcall Func_c29b ld a, [wd3aa] - call $39a7 + call Func_39a7 ld a, [hl] farcall Func_1187d pop hl @@ -334,10 +334,10 @@ Func_1c7de: ; 1c7de (7:47de) ret ; 0x1c7e4 -INCBIN "baserom.gbc",$1c7e4,$1c82e - $1c7e4 + INCROM $1c7e4, $1c82e Func_1c82e: ; 1c82e (7:482e) -INCBIN "baserom.gbc",$1c82e,$1c83d - $1c82e + INCROM $1c82e, $1c83d Func_1c83d: ; 1c83d (7:483d) push hl @@ -367,7 +367,7 @@ Func_1c83d: ; 1c83d (7:483d) ret ; 0x1c858 -INCBIN "baserom.gbc",$1c858,$1d078 - $1c858 + INCROM $1c858, $1d078 Func_1d078: ; 1d078 (7:5078) ld a, [wd627] @@ -406,7 +406,7 @@ Func_1d078: ; 1d078 (7:5078) and A_BUTTON | START jr z, .asm_1d095 ld a, $2 - call Func_3796 + call PlaySFX farcall Func_10ab4 .asm_1d0c7 @@ -436,7 +436,7 @@ Func_1d078: ; 1d078 (7:5078) ret ; 0x1d0fa -INCBIN "baserom.gbc",$1d0fa,$1d11c - $1d0fa + INCROM $1d0fa, $1d11c Func_1d11c: ; 1d11c (7:511c) ld a, MUSIC_PCMAINMENU @@ -466,7 +466,7 @@ Func_1d11c: ; 1d11c (7:511c) .asm_1d15a call DoFrameIfLCDEnabled call UpdateRNGSources - call MenuCursorAcceptInput + call HandleMenuInput push af call $51e9 pop af @@ -486,10 +486,10 @@ Func_1d11c: ; 1d11c (7:511c) ret ; 0x1d17f -INCBIN "baserom.gbc",$1d17f,$1d306 - $1d17f + INCROM $1d17f, $1d306 Func_1d306: ; 1d306 (7:5306) -INCBIN "baserom.gbc",$1d306,$1d386 - $1d306 + INCROM $1d306, $1d386 Titlescreen_1d386: ; 1d386 (7:5386) call Func_378a @@ -509,10 +509,10 @@ Titlescreen_1d386: ; 1d386 (7:5386) ret Func_1d3a9: ; 1d3a9 (7:53a9) -INCBIN "baserom.gbc",$1d3a9,$1d42e - $1d3a9 + INCROM $1d3a9, $1d42e Func_1d42e: ; 1d42e (7:542e) -INCBIN "baserom.gbc",$1d42e,$1d519 - $1d42e + INCROM $1d42e, $1d519 Titlescreen_1d519: ; 1d519 (7:5519) ld a, MUSIC_TITLESCREEN @@ -522,10 +522,10 @@ Titlescreen_1d519: ; 1d519 (7:5519) ret ; 0x1d523 -INCBIN "baserom.gbc",$1d523,$1d59c - $1d523 + INCROM $1d523, $1d59c Func_1d59c: ; 1d59c (7:559c) -INCBIN "baserom.gbc",$1d59c,$1d6ad - $1d59c + INCROM $1d59c, $1d6ad Credits_1d6ad: ; 1d6ad (7:56ad) ld a, MUSIC_STOP @@ -563,4 +563,4 @@ Credits_1d6ad: ; 1d6ad (7:56ad) ret ; 0x1d705 -INCBIN "baserom.gbc",$1d705,$1e1c4 - $1d705 + INCROM $1d705, $1e1c4 diff --git a/src/engine/bank8.asm b/src/engine/bank8.asm index fca29ba..aa47756 100755 --- a/src/engine/bank8.asm +++ b/src/engine/bank8.asm @@ -1,132 +1,132 @@ -INCBIN "baserom.gbc",$20000,$200e5 - $20000
-
-; 0 - e4 is a big set of data, seems to be one entry for each card
-
-Func_200e5: ; 200e5 (8:40e5)
- ld [$ce18], a
- call CreateHandCardBuffer
- ld hl, wDuelCardOrAttackList
- ld de, wHandCardBuffer
- call CopyBuffer
- ld hl, wHandCardBuffer
- ld a, [hli]
- ld [$ce16], a
- cp $ff
- ret z
- push hl
- ld a, [$ce18]
- ld d, a
- ld hl, $4000
-.asm_4106
- xor a
- ld [$ce21], a
- ld a, [hli]
- cp $ff
- jp z, $41b1
- cp d
- jp nz, .incHL5
- ld a, [hli]
- ld [$ce17], a
- ld a, [$ce16]
- call LoadDeckCardToBuffer1
- cp $d2
- jr nz, .asm_2012b
- ld b, a
- ld a, [$ce20]
- and $2
- jr nz, .incHL4
- ld a, b
-
-.asm_2012b
- ld b, a
- ld a, [$ce17]
- cp b
- jr nz, .incHL4
- push hl
- push de
- ld a, [$ce16]
- ld [$ff9f], a
- bank1call $35a9
- jp c, $41a8
- call $1944
- ld a, $1
- call TryExecuteEffectCommandFunction
- jp c, $41a8
- farcallx $5, $743b
- jr c, .asm_201a8
- pop de
- pop hl
- push hl
- call CallIndirect
- pop hl
- jr nc, .incHL4
- inc hl
- inc hl
- ld [$ce19], a
- push de
- push hl
- ld a, [$ce16]
- ld [$ff9f], a
- ld a, $6
- bank1call $67be
- pop hl
- pop de
- jr c, .incHL2
- push hl
- call CallIndirect
- pop hl
- inc hl
- inc hl
- ld a, [$ce20]
- ld b, a
- ld a, [$ce21]
- or b
- ld [$ce20], a
- pop hl
- and $8
- jp z, $40f7
- call $123b
- ld hl, wDuelCardOrAttackList
- ld de, $cf68
- call $697b
- ld hl, $cf68
- ld a, [$ce20]
- and $f7
- ld [$ce20], a
- jp $40f7
-
-.incHL5
- inc hl
-
-.incHL4
- inc hl
- inc hl
-
-.incHL2
- inc hl
- inc hl
- jp .asm_4106
-
-.asm_201a8
- pop de
- pop hl
- inc hl
- inc hl
- inc hl
- inc hl
- jp .asm_4106
-; 0x201b1
-
-INCBIN "baserom.gbc",$201b1,$2297b - $201b1
-
-; copies $ff terminated buffer from hl to de
-CopyBuffer: ; 2297b (8:697b)
- ld a, [hli]
- ld [de], a
- cp $ff
- ret z
- inc de
- jr CopyBuffer
-; 0x22983
-
-INCBIN "baserom.gbc",$22983,$24000 - $22983
+ INCROM $20000, $200e5 + +; 0 - e4 is a big set of data, seems to be one entry for each card + +Func_200e5: ; 200e5 (8:40e5) + ld [$ce18], a + call CreateHandCardBuffer + ld hl, wDuelCardOrAttackList + ld de, wHandCardBuffer + call CopyBuffer + ld hl, wHandCardBuffer + ld a, [hli] + ld [$ce16], a + cp $ff + ret z + push hl + ld a, [$ce18] + ld d, a + ld hl, $4000 +.asm_4106 + xor a + ld [$ce21], a + ld a, [hli] + cp $ff + jp z, $41b1 + cp d + jp nz, .incHL5 + ld a, [hli] + ld [$ce17], a + ld a, [$ce16] + call LoadDeckCardToBuffer1 + cp $d2 + jr nz, .asm_2012b + ld b, a + ld a, [$ce20] + and $2 + jr nz, .incHL4 + ld a, b + +.asm_2012b + ld b, a + ld a, [$ce17] + cp b + jr nz, .incHL4 + push hl + push de + ld a, [$ce16] + ld [$ff9f], a + bank1call $35a9 + jp c, $41a8 + call Func_1944 + ld a, $1 + call TryExecuteEffectCommandFunction + jp c, $41a8 + farcallx $5, $743b + jr c, .asm_201a8 + pop de + pop hl + push hl + call CallIndirect + pop hl + jr nc, .incHL4 + inc hl + inc hl + ld [$ce19], a + push de + push hl + ld a, [$ce16] + ld [$ff9f], a + ld a, $6 + bank1call $67be + pop hl + pop de + jr c, .incHL2 + push hl + call CallIndirect + pop hl + inc hl + inc hl + ld a, [$ce20] + ld b, a + ld a, [$ce21] + or b + ld [$ce20], a + pop hl + and $8 + jp z, $40f7 + call CreateHandCardBuffer + ld hl, wDuelCardOrAttackList + ld de, $cf68 + call $697b + ld hl, $cf68 + ld a, [$ce20] + and $f7 + ld [$ce20], a + jp $40f7 + +.incHL5 + inc hl + +.incHL4 + inc hl + inc hl + +.incHL2 + inc hl + inc hl + jp .asm_4106 + +.asm_201a8 + pop de + pop hl + inc hl + inc hl + inc hl + inc hl + jp .asm_4106 +; 0x201b1 + + INCROM $201b1, $2297b + +; copies $ff terminated buffer from hl to de +CopyBuffer: ; 2297b (8:697b) + ld a, [hli] + ld [de], a + cp $ff + ret z + inc de + jr CopyBuffer +; 0x22983 + + INCROM $22983, $24000 diff --git a/src/engine/booster_packs.asm b/src/engine/booster_packs.asm new file mode 100644 index 0000000..e3180fe --- /dev/null +++ b/src/engine/booster_packs.asm @@ -0,0 +1,566 @@ +GenerateBoosterPack: ; 1e1c4 (7:61c4) + push hl + push bc + push de + ld [wBoosterIndex], a +.noCardsFoundLoop + call InitBoosterData + call GenerateBoosterEnergies + call GenerateBoosterNonEnergies + jr c, .noCardsFoundLoop + call PutEnergiesAndNonEnergiesTogether + call AddBoosterCardsToCollection + pop de + pop bc + pop hl + ret + +; generate all Pokemon or Trainer cards (if any) for the current booster pack +GenerateBoosterNonEnergies: ; 1e1df (7:61df) + ld a, STAR + ld [wBoosterCurRarity], a +.generateCardLoop + call FindCurRarityChance + ld a, [hl] + or a + jr z, .noMoreOfCurrentRarity + call FindCardsInSetAndRarity + call FindTotalTypeChances + or a + jr z, .noValidCards + call Random + call DetermineBoosterCardType + call FindBoosterCard + call UpdateBoosterCardTypesChanceByte + call AddBoosterCardToDrawnNonEnergies + call FindCurRarityChance + dec [hl] + jr .generateCardLoop +.noMoreOfCurrentRarity + ld a, [wBoosterCurRarity] + dec a + ld [wBoosterCurRarity], a + bit 7, a ; any rarity left to check? + jr z, .generateCardLoop + or a + ret +.noValidCards + rst $38 + scf + ret + +; return hl pointing to wBoosterData<Rarity>Amount[wBoosterCurRarity] +FindCurRarityChance: ; 1e219 (7:6219) + push bc + ld hl, wBoosterDataCommonAmount + ld a, [wBoosterCurRarity] + ld c, a + ld b, $0 + add hl, bc + pop bc + ret + +FindCardsInSetAndRarity: ; 1e226 (7:6226) + ld c, NUM_BOOSTER_CARD_TYPES + ld hl, wBoosterAmountOfCardTypeTable + xor a +.deleteTypeTableLoop + ld [hli], a + dec c + jr nz, .deleteTypeTableLoop + xor a + ld hl, wBoosterViableCardList + ld [hl], a + ld de, $1 +.checkCardViableLoop + push de + ld a, e + ld [wBoosterTempCard], a + call IsByteInTempCardCollectionZero + jr c, .finishedWithCurrentCard + call CheckCardViable + jr c, .finishedWithCurrentCard + ld a, [wBoosterCurrentCardType] + call GetCardType + push af + push hl + ld c, a + ld b, $00 + ld hl, wBoosterAmountOfCardTypeTable + add hl, bc + inc [hl] + pop hl + ld a, [wBoosterTempCard] + ld [hli], a + pop af + ld [hli], a + xor a + ld [hl], a +.finishedWithCurrentCard + pop de + inc e + ld a, e + cp NUM_CARDS + 1 + jr c, .checkCardViableLoop + ret + +CheckCardViable: ; 1e268 (7:6268) + push bc + ld a, e + call GetCardHeader + ld [wBoosterCurrentCardType], a + ld a, b + ld [wBoosterCurrentCardRarity], a + ld a, c + ld [wBoosterCurrentCardSet], a + ld a, [wBoosterCurrentCardRarity] + ld c, a + ld a, [wBoosterCurRarity] + cp c + jr nz, .invalidCard + ld a, [wBoosterCurrentCardType] + call GetCardType + cp BOOSTER_CARD_TYPE_ENERGY + jr z, .returnValidCard + ld a, [wBoosterCurrentCardSet] + swap a + and $0f + ld c, a + ld a, [wBoosterDataSet] + cp c + jr nz, .invalidCard +.returnValidCard + or a + jr .return +.invalidCard + scf +.return + pop bc + ret + +; Map a card's TYPE_* constant given in a to its BOOSTER_CARD_TYPE_* constant +GetCardType: ; 1e2a0 (7:62a0) + push hl + push bc + ld hl, CardTypeTable + cp NUM_CARD_TYPES + jr nc, .loadType + ld c, a + ld b, $00 + add hl, bc +.loadType + ld a, [hl] + pop bc + pop hl + ret + +CardTypeTable: ; 1e2b1 (7:62b1) + db BOOSTER_CARD_TYPE_FIRE ; TYPE_PKMN_FIRE + db BOOSTER_CARD_TYPE_GRASS ; TYPE_PKMN_GRASS + db BOOSTER_CARD_TYPE_LIGHTNING ; TYPE_PKMN_LIGHTNING + db BOOSTER_CARD_TYPE_WATER ; TYPE_PKMN_WATER + db BOOSTER_CARD_TYPE_FIGHTING ; TYPE_PKMN_FIGHTING + db BOOSTER_CARD_TYPE_PSYCHIC ; TYPE_PKMN_PSYCHIC + db BOOSTER_CARD_TYPE_COLORLESS ; TYPE_PKMN_COLORLESS + db BOOSTER_CARD_TYPE_TRAINER ; TYPE_PKMN_UNUSED + db BOOSTER_CARD_TYPE_ENERGY ; TYPE_ENERGY_FIRE + db BOOSTER_CARD_TYPE_ENERGY ; TYPE_ENERGY_GRASS + db BOOSTER_CARD_TYPE_ENERGY ; TYPE_ENERGY_LIGHTNING + db BOOSTER_CARD_TYPE_ENERGY ; TYPE_ENERGY_WATER + db BOOSTER_CARD_TYPE_ENERGY ; TYPE_ENERGY_FIGHTING + db BOOSTER_CARD_TYPE_ENERGY ; TYPE_ENERGY_PSYCHIC + db BOOSTER_CARD_TYPE_ENERGY ; TYPE_ENERGY_COLORLESS + db BOOSTER_CARD_TYPE_TRAINER ; TYPE_ENERGY_UNUSED + db BOOSTER_CARD_TYPE_TRAINER ; TYPE_TRAINER + +FindTotalTypeChances: ; 1e2c2 (7:62c2) + ld c, NUM_BOOSTER_CARD_TYPES + xor a + ld hl, wBoosterTempTypeChanceTable +.deleteTempTypeChanceTableLoop + ld [hli], a + dec c + jr nz, .deleteTempTypeChanceTableLoop + ld [wd4ca], a + ld bc, $00 +.checkIfTypeIsValid + push bc + ld hl, wBoosterAmountOfCardTypeTable + add hl, bc + ld a, [hl] + or a + jr z, .amountOfTypeOrChanceZero + ld hl, wBoosterDataTypeChances + add hl, bc + ld a, [hl] + or a + jr z, .amountOfTypeOrChanceZero + ld hl, wBoosterTempTypeChanceTable + add hl, bc + ld [hl], a + ld a, [wd4ca] + add [hl] + ld [wd4ca], a +.amountOfTypeOrChanceZero + pop bc + inc c + ld a, c + cp NUM_BOOSTER_CARD_TYPES + jr c, .checkIfTypeIsValid + ld a, [wd4ca] + ret + +DetermineBoosterCardType: ; 1e2fa (7:62fa) + ld [wd4ca], a + ld c, $00 + ld hl, wBoosterTempTypeChanceTable +.loopThroughCardTypes + ld a, [hl] + or a + jr z, .skipNoChanceType + ld a, [wd4ca] + sub [hl] + ld [wd4ca], a + jr c, .foundCardType +.skipNoChanceType + inc hl + inc c + ld a, c + cp a, NUM_BOOSTER_CARD_TYPES + jr c, .loopThroughCardTypes + ld a, BOOSTER_CARD_TYPE_ENERGY +.foundCardType + ld a, c + ld [wBoosterSelectedCardType], a + ret + +FindBoosterCard: ; 1e31d (7:631d) + ld a, [wBoosterSelectedCardType] + ld c, a + ld b, $00 + ld hl, wBoosterAmountOfCardTypeTable + add hl, bc + ld a, [hl] + call Random + ld [wd4ca], a + ld hl, wBoosterViableCardList +.findMatchingCardLoop + ld a, [hli] + or a + jr z, .noValidCardFound + ld [wBoosterTempCard], a + ld a, [wBoosterSelectedCardType] + cp [hl] + jr nz, .cardIncorrectType + ld a, [wd4ca] + or a + jr z, .returnWithCurrentCard + dec a + ld [wd4ca], a +.cardIncorrectType + inc hl + jr .findMatchingCardLoop +.returnWithCurrentCard + or a + ret +.noValidCardFound + rst $38 + scf + ret + +; lowers the chance of getting the same type multiple times. +; more specifically, when a card of type T is drawn, T's new chances become +; min (1, wBoosterDataTypeChances[T] - wBoosterAveragedTypeChances). +UpdateBoosterCardTypesChanceByte: ; 1e350 (7:6350) + push hl + push bc + ld a, [wBoosterSelectedCardType] + ld c, a + ld b, $00 + ld hl, wBoosterDataTypeChances + add hl, bc + ld a,[wBoosterAveragedTypeChances] + ld c, a + ld a, [hl] + sub c + ld [hl], a + jr z, .chanceLessThanOne + jr nc, .stillSomeChanceLeft +.chanceLessThanOne + ld a, $01 + ld [hl], a +.stillSomeChanceLeft + pop bc + pop hl + ret + +; generates between 0 and 10 energy cards for the current booster. +; the amount of energies and their probabilities vary with each booster. +GenerateBoosterEnergies: ; 1e3db (7:63db) + ld hl, wBoosterDataEnergyFunctionPointer + 1 + ld a, [hld] + or a + jr z, .noFunctionPointer + ld l, [hl] + ld h, a + jp hl +.noFunctionPointer + ld a, [hl] + or a + ret z ; return if no hardcoded energy either + push af + call AddBoosterEnergyToDrawnEnergies + pop af + ret + +AddBoosterEnergyToDrawnEnergies: ; 1e380 (7:6380) + ld [wBoosterTempCard], a + call AddBoosterCardToDrawnEnergies + ret + +; generates a random energy card +GenerateEndingEnergy: ; 1e387 (7:6387) + ld a, COLORLESS - FIRE + call Random + add a, $01 + jr AddBoosterEnergyToDrawnEnergies + +; generates a booster with 10 random energies +GenerateRandomEnergyBooster: ; 1e390 (7:6390) + ld a, NUM_CARDS_IN_BOOSTER +.generateEnergyLoop + push af + call GenerateEndingEnergy + pop af + dec a + jr nz, .generateEnergyLoop + jr ZeroBoosterRarityData + +GenerateEnergyBoosterLightningFire: ; 1e39c (7:639c) + ld hl, EnergyBoosterLightningFireData + jr GenerateTwoTypesEnergyBooster + +GenerateEnergyBoosterWaterFighting: ; 1e3a1 (7:63a1) + ld hl, EnergyBoosterWaterFightingData + jr GenerateTwoTypesEnergyBooster + +GenerateEnergyBoosterGrassPsychic: ; 1e3a6 (7:63a6) + ld hl, EnergyBoosterGrassPsychicData + jr GenerateTwoTypesEnergyBooster + +; generates a booster with 5 energies of 2 different types each +GenerateTwoTypesEnergyBooster: ; 1e3ab (7:63ab) + ld b, $02 +.addTwoEnergiesToBoosterLoop + ld c, NUM_CARDS_IN_BOOSTER / 2 +.addEnergyToBoosterLoop + push hl + push bc + ld a, [hl] + call AddBoosterEnergyToDrawnEnergies + pop bc + pop hl + dec c + jr nz, .addEnergyToBoosterLoop + inc hl + dec b + jr nz, .addTwoEnergiesToBoosterLoop +ZeroBoosterRarityData: + xor a + ld [wBoosterDataCommonAmount], a + ld [wBoosterDataUncommonAmount], a + ld [wBoosterDataRareAmount], a + ret + +EnergyBoosterLightningFireData: + db LIGHTNING_ENERGY, FIRE_ENERGY +EnergyBoosterWaterFightingData: + db WATER_ENERGY, FIGHTING_ENERGY +EnergyBoosterGrassPsychicData: + db GRASS_ENERGY, PSYCHIC_ENERGY + +AddBoosterCardToDrawnEnergies: ; 1e3cf (7:63cf) + push hl + ld hl, wBoosterTempEnergiesDrawn + call CopyToFirstEmptyByte + call AddBoosterCardToTempCardCollection + pop hl + ret + +AddBoosterCardToDrawnNonEnergies: ; 1e3db (7:63db) + push hl + ld hl, wBoosterTempNonEnergiesDrawn + call CopyToFirstEmptyByte + call AddBoosterCardToTempCardCollection + pop hl + ret + +CopyToFirstEmptyByte: ; 1e3e7 (7:63e7) + ld a, [hli] + or a + jr nz, CopyToFirstEmptyByte + dec hl + ld a, [wBoosterTempCard] + ld [hli], a + xor a + ld [hl], a + ret + +; trim empty slots in wBoosterCardsDrawn between regular cards and energies +PutEnergiesAndNonEnergiesTogether: ; 1e3f3 (7:63f3) + push hl + ld hl, wBoosterTempEnergiesDrawn +.loopThroughExtraCards + ld a, [hli] + or a + jr z, .endOfCards + ld [wBoosterTempCard], a + push hl + ld hl, wBoosterTempNonEnergiesDrawn + call CopyToFirstEmptyByte + pop hl + jr .loopThroughExtraCards +.endOfCards + pop hl + ret + +AddBoosterCardsToCollection:; 1e40a (7:640a) + push hl + ld hl, wBoosterCardsDrawn +.addCardsLoop + ld a, [hli] + or a + jr z, .noCardsLeft + call AddCardToCollection + jr .addCardsLoop +.noCardsLeft + pop hl + ret + +AddBoosterCardToTempCardCollection: ; 1e419 (7:6419) + push hl + ld h, wTempCardCollection >> 8 + ld a, [wBoosterTempCard] + ld l, a + inc [hl] + pop hl + ret + +IsByteInTempCardCollectionZero: ; 1e423 (7:6423) + push hl + ld h, wTempCardCollection >> 8 + ld a, [wBoosterTempCard] + ld l, a + ld a, [hl] + pop hl + cp $01 + ccf + ret + +; clears wBoosterCardsDrawn and wTempCardCollection +; copies booster data to wBoosterData* *CurSet, *EnergyFunctionPointer, and *TypeChances +; copies rarity amounts to wBoosterData*Amount and averages them into wBoosterAveragedTypeChances +InitBoosterData: ; 1e430 (7:6430) + ld c, wBoosterCardsDrawnEnd - wBoosterCardsDrawn + ld hl, wBoosterCardsDrawn + xor a +.clearPlayerDeckLoop + ld [hli], a + dec c + jr nz, .clearPlayerDeckLoop + ld c, $00 ; $100 + ld hl, wTempCardCollection + xor a +.clearTempCardCollectionLoop + ld [hli], a + dec c + jr nz, .clearTempCardCollectionLoop + call FindBoosterDataPointer + ld de, wBoosterDataSet + ld bc, wBoosterDataTypeChances - wBoosterDataSet + NUM_BOOSTER_CARD_TYPES ; Pack2 - Pack1 + call CopyDataHLtoDE ; load booster pack data to wram + call LoadRarityAmountsToWram + ld bc, $0 + ld d, NUM_BOOSTER_CARD_TYPES + ld e, $0 + ld hl, wBoosterDataTypeChances +.addChanceBytesLoop + ld a, [hli] + or a + jr z, .skipChanceByte + add c + ld c, a + inc e +.skipChanceByte + dec d + jr nz, .addChanceBytesLoop + call DivideBCbyDE + ld a, c + ld [wBoosterAveragedTypeChances], a + ret + +FindBoosterDataPointer: ; 1e46f (7:646f) + push bc + ld a, [wBoosterIndex] + add a + ld c, a + ld b, $0 + ld hl, BoosterDataJumptable + add hl, bc + ld a, [hli] + ld h, [hl] + ld l, a + pop bc + ret + +BoosterDataJumptable: ; 1e480 (7:6480) + dw PackColosseumNeutral + dw PackColosseumGrass + dw PackColosseumFire + dw PackColosseumWater + dw PackColosseumLightning + dw PackColosseumFighting + dw PackColosseumTrainer + dw PackEvolutionNeutral + dw PackEvolutionGrass + dw PackEvolutionNeutralFireEnergy + dw PackEvolutionWater + dw PackEvolutionFighting + dw PackEvolutionPsychic + dw PackEvolutionTrainer + dw PackMysteryNeutral + dw PackMysteryGrassColorless + dw PackMysteryWaterColorless + dw PackMysteryLightningColorless + dw PackMysteryFightingColorless + dw PackMysteryTrainerColorless + dw PackLaboratoryMostlyNeutral + dw PackLaboratoryGrass + dw PackLaboratoryWater + dw PackLaboratoryPsychic + dw PackLaboratoryTrainer + dw PackEnergyLightningFire + dw PackEnergyWaterFighting + dw PackEnergyGrassPsychic + dw PackRandomEnergies + +LoadRarityAmountsToWram: ; 1e4ba (7:64ba) + ld a, [wBoosterDataSet] + add a + add a + ld c, a + ld b, $00 + ld hl, BoosterSetRarityAmountTable + add hl, bc + inc hl + ld a, [hli] + ld [wBoosterDataCommonAmount], a + ld a, [hli] + ld [wBoosterDataUncommonAmount], a + ld a, [hli] + ld [wBoosterDataRareAmount], a + ret + +INCLUDE "data/booster_packs.asm" + + INCROM $1e640, $20000
\ No newline at end of file diff --git a/src/engine/boosters.asm b/src/engine/boosters.asm deleted file mode 100755 index 7537897..0000000 --- a/src/engine/boosters.asm +++ /dev/null @@ -1,993 +0,0 @@ -GenerateBoosterPack: ; 1e1c4 (7:61c4) - push hl - push bc - push de - ld [wBoosterDataIndex], a -.noCardsFoundLoop - call InitBoosterData - call GenerateBoosterEnergy - call GenerateBoosterCard - jr c, .noCardsFoundLoop - call CopyBoosterEnergiesToBooster - call AddBoosterCardsToCollection - pop de - pop bc - pop hl - ret - -GenerateBoosterCard: ; 1e1df (7:61df) - ld a, STAR - ld [wBoosterCurrRarity], a -.generateCardLoop - call FindCurrRarityChance - ld a, [hl] - or a - jr z, .noMoreOfCurrentRarity - call FindCardsInSetAndRarity - call FindTotalTypeChances - or a - jr z, .noValidCards - call Random - call DetermineBoosterCardType - call FindBoosterCard - call UpdateBoosterCardTypesChanceByte - call AddCardToBoosterList - call FindCurrRarityChance - dec [hl] - jr .generateCardLoop -.noMoreOfCurrentRarity - ld a, [wBoosterCurrRarity] - dec a - ld [wBoosterCurrRarity], a - bit 7, a - jr z, .generateCardLoop - or a - ret -.noValidCards - rst $38 - scf - ret - -FindCurrRarityChance: ; 1e219 (7:6219) - push bc - ld hl, wBoosterDataCommonAmount - ld a, [wBoosterCurrRarity] - ld c, a - ld b, $0 - add hl, bc - pop bc - ret - -FindCardsInSetAndRarity: ; 1e226 (7:6226) - ld c, BOOSTER_CARD_TYPE_AMOUNT - ld hl, wBoosterAmountOfCardTypeTable - xor a -.deleteTypeTableLoop - ld [hli], a - dec c - jr nz, .deleteTypeTableLoop - xor a - ld hl, wBoosterViableCardList - ld [hl], a - ld de, $1 -.checkCardViableLoop - push de - ld a, e - ld [wBoosterTempData], a - call CheckByteInWramZeroed - jr c, .finishedWithCurrentCard - call CheckCardViable - jr c, .finishedWithCurrentCard - ld a, [wBoosterCurrentCardType] - call GetCardType - push af - push hl - ld c, a - ld b, $00 - ld hl, wBoosterAmountOfCardTypeTable - add hl, bc - inc [hl] - pop hl - ld a, [wBoosterTempData] - ld [hli], a - pop af - ld [hli], a - xor a - ld [hl], a -.finishedWithCurrentCard - pop de - inc e - ld a, e - cp NUM_CARDS + 1 - jr c, .checkCardViableLoop - ret - -CheckCardViable: ; 1e268 (7:6268) - push bc - ld a, e - call GetCardHeader - ld [wBoosterCurrentCardType], a - ld a, b - ld [wBoosterCurrentCardRarity], a - ld a, c - ld [wBoosterCurrentCardSet], a - ld a, [wBoosterCurrentCardRarity] - ld c, a - ld a, [wBoosterCurrRarity] - cp c - jr nz, .invalidCard - ld a, [wBoosterCurrentCardType] - call GetCardType - cp BOOSTER_CARD_TYPE_ENERGY - jr z, .returnValidCard - ld a, [wBoosterCurrentCardSet] - swap a - and $0f - ld c, a - ld a, [wBoosterDataCurrSet] - cp c - jr nz, .invalidCard -.returnValidCard - or a - jr .return -.invalidCard - scf -.return - pop bc - ret - -GetCardType: ; 1e2a0 (7:62a0) - push hl - push bc - ld hl, CardTypeTable - cp $11 - jr nc, .skipToTypeLoad - ld c, a - ld b, $00 - add hl, bc -.skipToTypeLoad - ld a, [hl] - pop bc - pop hl - ret - -CardTypeTable: ; 1e2b1 (7:62b1) - db BOOSTER_CARD_TYPE_FIRE - db BOOSTER_CARD_TYPE_GRASS - db BOOSTER_CARD_TYPE_LIGHTNING - db BOOSTER_CARD_TYPE_WATER - db BOOSTER_CARD_TYPE_FIGHTING - db BOOSTER_CARD_TYPE_PSYCHIC - db BOOSTER_CARD_TYPE_COLORLESS - db BOOSTER_CARD_TYPE_TRAINER - db BOOSTER_CARD_TYPE_ENERGY - db BOOSTER_CARD_TYPE_ENERGY - db BOOSTER_CARD_TYPE_ENERGY - db BOOSTER_CARD_TYPE_ENERGY - db BOOSTER_CARD_TYPE_ENERGY - db BOOSTER_CARD_TYPE_ENERGY - db BOOSTER_CARD_TYPE_ENERGY - db BOOSTER_CARD_TYPE_TRAINER - db BOOSTER_CARD_TYPE_TRAINER - -FindTotalTypeChances: ; 1e2c2 (7:62c2) - ld c, BOOSTER_CARD_TYPE_AMOUNT - xor a - ld hl, wBoosterTempTypeChanceTable -.deleteTempTypeChanceTableLoop - ld [hli], a - dec c - jr nz, .deleteTempTypeChanceTableLoop - ld [wd4ca], a - ld bc, $00 -.checkIfTypeIsValid - push bc - ld hl, wBoosterAmountOfCardTypeTable - add hl, bc - ld a, [hl] - or a - jr z, .amountOfTypeOrChanceZero - ld hl, wBoosterDataTypeChanceData - add hl, bc - ld a, [hl] - or a - jr z, .amountOfTypeOrChanceZero - ld hl, wBoosterTempTypeChanceTable - add hl, bc - ld [hl], a - ld a, [wd4ca] - add [hl] - ld [wd4ca], a -.amountOfTypeOrChanceZero - pop bc - inc c - ld a, c - cp $09 - jr c, .checkIfTypeIsValid - ld a, [wd4ca] - ret - -DetermineBoosterCardType: ; 1e2fa (7:62fa) - ld [wd4ca], a - ld c, $00 - ld hl, wBoosterTempTypeChanceTable -.loopThroughCardTypes - ld a, [hl] - or a - jr z, .skipNoChanceType - ld a, [wd4ca] - sub [hl] - ld [wd4ca], a - jr c, .foundCardType -.skipNoChanceType - inc hl - inc c - ld a, c - cp a, BOOSTER_CARD_TYPE_AMOUNT - jr c, .loopThroughCardTypes - ld a, $08 -.foundCardType - ld a, c - ld [wBoosterSelectedCardType], a - ret - -FindBoosterCard: ; 1e31d (7:631d) - ld a, [wBoosterSelectedCardType] - ld c, a - ld b, $00 - ld hl, wBoosterAmountOfCardTypeTable - add hl, bc - ld a, [hl] - call Random - ld [wd4ca], a - ld hl, wBoosterViableCardList -.findMatchingCardLoop - ld a, [hli] - or a - jr z, .noValidCardFound - ld [wBoosterTempData], a - ld a, [wBoosterSelectedCardType] - cp [hl] - jr nz, .cardIncorrectType - ld a, [wd4ca] - or a - jr z, .returnWithCurrentCard - dec a - ld [wd4ca], a -.cardIncorrectType - inc hl - jr .findMatchingCardLoop -.returnWithCurrentCard - or a - ret -.noValidCardFound - rst $38 - scf - ret - -;lowers the chance of getting the same type multiple times -UpdateBoosterCardTypesChanceByte: ; 1e350 (7:6350) - push hl - push bc - ld a, [wBoosterSelectedCardType] - ld c, a - ld b, $00 - ld hl, wBoosterDataTypeChanceData - add hl, bc - ld a,[wBoosterDataAveragedChance] - ld c, a - ld a, [hl] - sub c - ld [hl], a - jr z, .chanceLessThanOne - jr nc, .stillSomeChanceLeft -.chanceLessThanOne - ld a, $01 - ld [hl], a -.stillSomeChanceLeft - pop bc - pop hl - ret - -GenerateBoosterEnergy: ; 1e3db (7:63db) - ld hl, wBoosterDataEnergyFunctionPointer + 1 - ld a, [hld] - or a - jr z, .noFunctionPointer - ld l, [hl] - ld h, a - jp hl -.noFunctionPointer - ld a, [hl] - or a - ret z - push af - call AddBoosterEnergyToWram - pop af - ret - -AddBoosterEnergyToWram: ; 1e380 (7:6380) - ld [wBoosterTempData], a - call AddCardToBoosterEnergies - ret - -GenerateEndingEnergy: ; 1e387 (7:6387) - ld a, $06 - call Random - add a, $01 - jr AddBoosterEnergyToWram - -GenerateRandomEnergyBoosterPack: ; 1e390 (7:6390) - ld a, $0a -.generateEnergyLoop - push af - call GenerateEndingEnergy - pop af - dec a - jr nz, .generateEnergyLoop - jr ZeroBoosterRarityData - -GenerateEnergyBoosterLightningFire: ; 1e39c (7:639c) - ld hl, EnergyBoosterLightningFireData - jr CreateEnergyBooster - -GenerateEnergyBoosterWaterFighting: ; 1e3a1 (7:63a1) - ld hl, EnergyBoosterWaterFightingData - jr CreateEnergyBooster - -GenerateEnergyBoosterGrassPsychic: ; 1e3a6 (7:63a6) - ld hl, EnergyBoosterGrassPsychicData - jr CreateEnergyBooster - -CreateEnergyBooster: ; 1e3ab (7:63ab) - ld b, $02 -.addTwoEnergiesToBoosterLoop - ld c, $05 -.addEnergyToBoosterLoop - push hl - push bc - ld a, [hl] - call AddBoosterEnergyToWram - pop bc - pop hl - dec c - jr nz, .addEnergyToBoosterLoop - inc hl - dec b - jr nz, .addTwoEnergiesToBoosterLoop -ZeroBoosterRarityData: - xor a - ld [wBoosterDataCommonAmount], a - ld [wBoosterDataUncommonAmount], a - ld [wBoosterDataRareAmount], a - ret - -EnergyBoosterLightningFireData: - db LIGHTNING_ENERGY, FIRE_ENERGY -EnergyBoosterWaterFightingData: - db WATER_ENERGY, FIGHTING_ENERGY -EnergyBoosterGrassPsychicData: - db GRASS_ENERGY, PSYCHIC_ENERGY - -AddCardToBoosterEnergies: ; 1e3cf (7:63cf) - push hl - ld hl, wPlayerDeck + $b - call CopyToFirstEmptyByte - call AddBoosterCardToTempCardCollection - pop hl - ret - -AddCardToBoosterList: ; 1e3db (7:63db) - push hl - ld hl, wPlayerDeck - call CopyToFirstEmptyByte - call AddBoosterCardToTempCardCollection - pop hl - ret - -CopyToFirstEmptyByte: ; 1e3e7 (7:63e7) - ld a, [hli] - or a - jr nz, CopyToFirstEmptyByte - dec hl - ld a, [wBoosterTempData] - ld [hli], a - xor a - ld [hl], a - ret - -CopyBoosterEnergiesToBooster: ; 1e3f3 (7:63f3) - push hl - ld hl, wPlayerDeck + $b -.loopThroughExtraCards - ld a, [hli] - or a - jr z, .endOfCards - ld [wBoosterTempData], a - push hl - ld hl, wPlayerDeck - call CopyToFirstEmptyByte - pop hl - jr .loopThroughExtraCards -.endOfCards - pop hl - ret - -AddBoosterCardsToCollection:; 1e40a (7:640a) - push hl - ld hl, wPlayerDeck -.addCardsLoop - ld a, [hli] - or a - jr z, .noCardsLeft - call AddCardToCollection - jr .addCardsLoop -.noCardsLeft - pop hl - ret - -AddBoosterCardToTempCardCollection: ; 1e419 (7:6419) - push hl - ld h, wTempCardCollection >> 8 - ld a, [wBoosterTempData] - ld l, a - inc [hl] - pop hl - ret - -CheckByteInWramZeroed: ; 1e423 (7:6423) - push hl - ld h, wTempCardCollection >> 8 - ld a, [wBoosterTempData] - ld l, a - ld a, [hl] - pop hl - cp $01 - ccf - ret - -;clears wPlayerDeck and wTempCardCollection -;copies rarity amounts to ram and averages them into wBoosterDataAveragedChance -InitBoosterData: ; 1e430 (7:6430) - ld c, $16 - ld hl, wPlayerDeck - xor a -.clearPlayerDeckLoop - ld [hli], a - dec c - jr nz, .clearPlayerDeckLoop - ld c, $00 - ld hl, wTempCardCollection - xor a -.clearTempCardCollectionLoop - ld [hli], a - dec c - jr nz, .clearTempCardCollectionLoop - call FindBoosterDataPointer - ld de, wBoosterDataCurrSet - ld bc, $c - call CopyData - call LoadRarityAmountsToWram - ld bc, $0 - ld d, BOOSTER_CARD_TYPE_AMOUNT - ld e, $0 - ld hl, wBoosterDataTypeChanceData -.addChanceBytesLoop - ld a, [hli] - or a - jr z, .skipChanceByte - add c - ld c, a - inc e -.skipChanceByte - dec d - jr nz, .addChanceBytesLoop - call DivideBCbyDE - ld a, c - ld [wBoosterDataAveragedChance], a - ret - -FindBoosterDataPointer: ; 1e46f (7:646f) - push bc - ld a, [wBoosterDataIndex] - add a - ld c, a - ld b, $0 - ld hl, BoosterData_PtrTbl - add hl, bc - ld a, [hli] - ld h, [hl] - ld l, a - pop bc - ret - -BoosterData_PtrTbl: ; 1e480 (7:6480) - dw PackColoNeutral - dw PackColoGrass - dw PackColoFire - dw PackColoWater - dw PackColoLightning - dw PackColoFighting - dw PackColoTrainer - dw PackEvoNeutral - dw PackEvoGrass - dw PackEvoNeutralFireEnergy - dw PackEvoWater - dw PackEvoFighting - dw PackEvoPsychic - dw PackEvoTrainer - dw PackMysteryNeutral - dw PackMysteryGrassColorless - dw PackMysteryWaterColorless - dw PackLightningColorless - dw PackMysteryFightingColorless - dw PackMysteryTrainerColorless - dw PackLabTrainerLessFighting - dw PackLabGrass - dw PackLabWater - dw PackLabPsychic - dw PackLabTrainer - dw PackEnergyLightningFire - dw PackEnergyWaterFighting - dw PackEnergyGrassPsychic - dw PackRandomEnergies - -LoadRarityAmountsToWram: ; 1e4ba (7:64ba) - ld a, [wBoosterDataCurrSet] - add a - add a - ld c, a - ld b, $00 - ld hl, BoosterSetRarityAmountTable - add hl, bc - inc hl - ld a, [hli] - ld [wBoosterDataCommonAmount], a - ld a, [hli] - ld [wBoosterDataUncommonAmount], a - ld a, [hli] - ld [wBoosterDataRareAmount], a - ret - -BoosterSetRarityAmountTable: ; 1e4d4 (7::64d4) - db $01, $05, $03, $01 ; other, commons, uncommons, rares - db $01, $05, $03, $01 ; other, commons, uncommons, rares - db $00, $06, $03, $01 ; other, commons, uncommons, rares - db $00, $06, $03, $01 ; other, commons, uncommons, rares - -PackColoNeutral:: ; 1e4e4 (7:64e4) - db COLOSSEUM >> 4 ; booster pack set - dw GenerateEndingEnergy ; energy or energy generation function - -; Card Type Chances - db $14 ; Grass Type Chance - db $14 ; Fire Type Chance - db $14 ; Water Type Chance - db $14 ; Lightning Type Chance - db $14 ; Fighting Type Chance - db $14 ; Psychic Type Chance - db $14 ; Colorless Type Chance - db $14 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackColoGrass:: ; 1e4f0 (7:64f0) - db COLOSSEUM >> 4 ; booster pack set - dw GRASS_ENERGY ; energy or energy generation function - -; Card Type Chances - db $30 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackColoFire:: ; 1e4fc (7:64fc) - db COLOSSEUM >> 4 ; booster pack set - dw FIRE_ENERGY ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $30 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackColoWater:: ; 1e508 (7:6508) - db COLOSSEUM >> 4 ; booster pack set - dw WATER_ENERGY ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $30 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackColoLightning:: ; 1e514 (7:6514) - db COLOSSEUM >> 4 ; booster pack set - dw LIGHTNING_ENERGY ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $30 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackColoFighting:: ; 1e520 (7:6520) - db COLOSSEUM >> 4 ; booster pack set - dw FIGHTING_ENERGY ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $30 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackColoTrainer:: ; 1e52c (7:652c) - db COLOSSEUM >> 4 ; booster pack set - dw GenerateEndingEnergy ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $30 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEvoNeutral:: ; 1e538 (7:6538) - db EVOLUTION >> 4 ; booster pack set - dw GenerateEndingEnergy ; energy or energy generation function - -; Card Type Chances - db $14 ; Grass Type Chance - db $14 ; Fire Type Chance - db $14 ; Water Type Chance - db $14 ; Lightning Type Chance - db $14 ; Fighting Type Chance - db $14 ; Psychic Type Chance - db $14 ; Colorless Type Chance - db $14 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEvoGrass:: ; 1e544 (7:6544) - db EVOLUTION >> 4 ; booster pack set - dw GRASS_ENERGY ; energy or energy generation function - -; Card Type Chances - db $30 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEvoNeutralFireEnergy:: ; 1e550 (7:6550) - db EVOLUTION >> 4 ; booster pack set - dw FIRE_ENERGY ; energy or energy generation function - -; Card Type Chances - db $14 ; Grass Type Chance - db $14 ; Fire Type Chance - db $14 ; Water Type Chance - db $14 ; Lightning Type Chance - db $14 ; Fighting Type Chance - db $14 ; Psychic Type Chance - db $14 ; Colorless Type Chance - db $14 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEvoWater:: ; 1e55c (7:655c) - db EVOLUTION >> 4 ; booster pack set - dw WATER_ENERGY ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $30 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEvoFighting:: ; 1e568 (7:6568) - db EVOLUTION >> 4 ; booster pack set - dw FIGHTING_ENERGY ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $30 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEvoPsychic:: ; 1e574 (7:6574) - db EVOLUTION >> 4 ; booster pack set - dw PSYCHIC_ENERGY ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $30 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEvoTrainer:: ; 1e580 (7:6580) - db EVOLUTION >> 4 ; booster pack set - dw GenerateEndingEnergy ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $30 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackMysteryNeutral:: ; 1e58c (7:658c) - db MYSTERY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $11 ; Grass Type Chance - db $11 ; Fire Type Chance - db $11 ; Water Type Chance - db $11 ; Lightning Type Chance - db $11 ; Fighting Type Chance - db $11 ; Psychic Type Chance - db $11 ; Colorless Type Chance - db $11 ; Trainer Card Chance - db $11 ; Energy Card Chance - -PackMysteryGrassColorless:: ; 1e598 (7:6598) - db MYSTERY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $30 ; Grass Type Chance - db $0C ; Fire Type Chance - db $0C ; Water Type Chance - db $0C ; Lightning Type Chance - db $0C ; Fighting Type Chance - db $0C ; Psychic Type Chance - db $16 ; Colorless Type Chance - db $0C ; Trainer Card Chance - db $0C ; Energy Card Chance - -PackMysteryWaterColorless:: ; 1e5a4 (7:65a4) - db MYSTERY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $0C ; Grass Type Chance - db $0C ; Fire Type Chance - db $30 ; Water Type Chance - db $0C ; Lightning Type Chance - db $0C ; Fighting Type Chance - db $0C ; Psychic Type Chance - db $16 ; Colorless Type Chance - db $0C ; Trainer Card Chance - db $0C ; Energy Card Chance - -PackLightningColorless:: ; 1e5b0 (7:65b0) - db MYSTERY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $0C ; Grass Type Chance - db $0C ; Fire Type Chance - db $0C ; Water Type Chance - db $30 ; Lightning Type Chance - db $0C ; Fighting Type Chance - db $0C ; Psychic Type Chance - db $16 ; Colorless Type Chance - db $0C ; Trainer Card Chance - db $0C ; Energy Card Chance - -PackMysteryFightingColorless:: ; 1e5bc (7:65bc) - db MYSTERY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $0C ; Grass Type Chance - db $0C ; Fire Type Chance - db $0C ; Water Type Chance - db $0C ; Lightning Type Chance - db $30 ; Fighting Type Chance - db $0C ; Psychic Type Chance - db $16 ; Colorless Type Chance - db $0C ; Trainer Card Chance - db $0C ; Energy Card Chance - -PackMysteryTrainerColorless:: ; 1e5c8 (7:65c8) - db MYSTERY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $0C ; Grass Type Chance - db $0C ; Fire Type Chance - db $0C ; Water Type Chance - db $0C ; Lightning Type Chance - db $0C ; Fighting Type Chance - db $0C ; Psychic Type Chance - db $16 ; Colorless Type Chance - db $30 ; Trainer Card Chance - db $0C ; Energy Card Chance - -PackLabTrainerLessFighting:: ; 1e5d4 (7:65d4) - db LABORATORY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $14 ; Grass Type Chance - db $14 ; Fire Type Chance - db $14 ; Water Type Chance - db $14 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $14 ; Psychic Type Chance - db $14 ; Colorless Type Chance - db $18 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackLabGrass:: ; 1e5e0 (7:65e0) - db LABORATORY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $30 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackLabWater:: ; 1e5ec (7:65ec) - db LABORATORY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $30 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackLabPsychic:: ; 1e5f8 (7:65f8) - db LABORATORY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $30 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $10 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackLabTrainer:: ; 1e604 (7:6604) - db LABORATORY >> 4 ; booster pack set - dw $0000 ; energy or energy generation function - -; Card Type Chances - db $10 ; Grass Type Chance - db $10 ; Fire Type Chance - db $10 ; Water Type Chance - db $10 ; Lightning Type Chance - db $10 ; Fighting Type Chance - db $10 ; Psychic Type Chance - db $10 ; Colorless Type Chance - db $30 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEnergyLightningFire:: ; 1e610 (7:6610) - db COLOSSEUM >> 4 ; booster pack set - dw GenerateEnergyBoosterLightningFire ; energy or energy generation function - -; Card Type Chances - db $00 ; Grass Type Chance - db $00 ; Fire Type Chance - db $00 ; Water Type Chance - db $00 ; Lightning Type Chance - db $00 ; Fighting Type Chance - db $00 ; Psychic Type Chance - db $00 ; Colorless Type Chance - db $00 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEnergyWaterFighting:: ; 1e61c (7:661c) - db COLOSSEUM >> 4 ; booster pack set - dw GenerateEnergyBoosterWaterFighting ; energy or energy generation function - -; Card Type Chances - db $00 ; Grass Type Chance - db $00 ; Fire Type Chance - db $00 ; Water Type Chance - db $00 ; Lightning Type Chance - db $00 ; Fighting Type Chance - db $00 ; Psychic Type Chance - db $00 ; Colorless Type Chance - db $00 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackEnergyGrassPsychic:: ; 1e628 (7:6628) - db COLOSSEUM >> 4 ; booster pack set - dw GenerateEnergyBoosterGrassPsychic ; energy or energy generation function - -; Card Type Chances - db $00 ; Grass Type Chance - db $00 ; Fire Type Chance - db $00 ; Water Type Chance - db $00 ; Lightning Type Chance - db $00 ; Fighting Type Chance - db $00 ; Psychic Type Chance - db $00 ; Colorless Type Chance - db $00 ; Trainer Card Chance - db $00 ; Energy Card Chance - -PackRandomEnergies:: ; 1e634 (7:6634) - db COLOSSEUM >> 4 ; booster pack set - dw GenerateRandomEnergyBoosterPack ; energy or energy generation function - -; Card Type Chances - db $00 ; Grass Type Chance - db $00 ; Fire Type Chance - db $00 ; Water Type Chance - db $00 ; Lightning Type Chance - db $00 ; Fighting Type Chance - db $00 ; Psychic Type Chance - db $00 ; Colorless Type Chance - db $00 ; Trainer Card Chance - db $00 ; Energy Card Chance - -INCBIN "baserom.gbc",$1e640,$20000 - $1e640 diff --git a/src/engine/effect_functions.asm b/src/engine/effect_functions.asm index 9a4b63e..dc05043 100644 --- a/src/engine/effect_functions.asm +++ b/src/engine/effect_functions.asm @@ -1,5 +1,5 @@ Poison50PercentEffect: ; 2c000 (b:4000) - text_de PoisonCheckText + ldtx de, PoisonCheckText call TossCoin_BankB ret nc @@ -11,14 +11,14 @@ PoisonEffect: ; 2c007 (b:4007) jr applyEffect Paralysis50PercentEffect: ; 2c011 (b:4011) - text_de ParalysisCheckText + ldtx de, ParalysisCheckText call TossCoin_BankB ret nc lb bc, $f0, PARALYZED jr applyEffect Confusion50PercentEffect: ; 2c01d (b:401d) - text_de ConfusionCheckText + ldtx de, ConfusionCheckText call TossCoin_BankB ret nc @@ -26,7 +26,7 @@ ConfusionEffect: ; 2c024 (b:4024) lb bc, $f0, CONFUSED jr applyEffect - text_de SleepCheckText + ldtx de, SleepCheckText call TossCoin_BankB ret nc @@ -128,7 +128,7 @@ Func_2c0a2: ; 2c0a2 (b:40a2) ret ; 0x2c0a8 -INCBIN "baserom.gbc",$2c0a8,$2c0d4 - $2c0a8 + INCROM $2c0a8, $2c0d4 ; Sets some flags for AI use ; if target double poisoned @@ -181,7 +181,7 @@ Func_2c0fb: ; 2c0fb (b:40fb) ret ; 0x2c10b -INCBIN "baserom.gbc",$2c10b,$2c140 - $2c10b + INCROM $2c10b, $2c140 ; apply a status condition of type 1 identified by register a to the target ApplySubstatus1ToDefendingCard: ; 2c140 (b:4140) @@ -218,7 +218,7 @@ ApplySubstatus2ToDefendingCard: ; 2c149 (b:4149) ret ; 0x2c166 -INCBIN "baserom.gbc",$2c166,$2c6f0 - $2c166 + INCROM $2c166, $2c6f0 SpitPoison_AIEffect: ; 2c6f0 (b:46f0) ld a, $5 @@ -227,7 +227,7 @@ SpitPoison_AIEffect: ; 2c6f0 (b:46f0) ; 0x2c6f8 SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8) - text_de PoisonCheckText + ldtx de, PoisonCheckText call TossCoin_BankB jp c, PoisonEffect ld a, $8c @@ -236,7 +236,7 @@ SpitPoison_Poison50PercentEffect: ; 2c6f8 (b:46f8) ret ; 0x2c70a -INCBIN "baserom.gbc",$2c70a,$2c730 - $2c70a + INCROM $2c70a, $2c730 PoisonFang_AIEffect: ; 2c730 (b:4730) ld a, $a @@ -250,10 +250,10 @@ WeepinbellPoisonPowder_AIEffect: ; 2c738 (b:4738) jp Func_2c0d4 ; 0x2c740 -INCBIN "baserom.gbc",$2c740,$2c77e - $2c740 + INCROM $2c740, $2c77e AcidEffect: ; 2c77e (b:477e) - text_de AcidCheckText + ldtx de, AcidCheckText call TossCoin_BankB ret nc ld a, SUBSTATUS2_UNABLE_RETREAT @@ -277,7 +277,7 @@ FoulOdorEffect: ; 2c793 (b:4793) ; 0x2c7a0 KakunaStiffenEffect: ; 2c7a0 (b:47a0) - text_de IfHeadsNoDamageNextTurnText + ldtx de, IfHeadsNoDamageNextTurnText call TossCoin_BankB jp nc, Func_2c0a2 ld a, $4f @@ -293,7 +293,7 @@ KakunaPoisonPowder_AIEffect: ; 2c7b4 (b:47b4) jp Func_2c0d4 ; 0x2c7bc -INCBIN "baserom.gbc",$2c7bc,$2c7d0 - $2c7bc + INCROM $2c7bc, $2c7d0 SwordsDanceEffect: ; 2c7d0 (b:47d0) ld a, [wTempTurnDuelistCardId] @@ -310,11 +310,11 @@ ZubatSupersonicEffect: ; 2c7dc (b:47dc) ret ; 0x2c7e3 -INCBIN "baserom.gbc",$2c7e3,$2c836 - $2c7e3 + INCROM $2c7e3, $2c836 ; an exact copy of KakunaStiffenEffect MetapodStiffenEffect: ; 2c836 (b:4836) - text_de IfHeadsNoDamageNextTurnText + ldtx de, IfHeadsNoDamageNextTurnText call TossCoin_BankB jp nc, Func_2c0a2 ld a, $4f @@ -324,4 +324,4 @@ MetapodStiffenEffect: ; 2c836 (b:4836) ret ; 0x2c84a -INCBIN "baserom.gbc",$2c84a,$30000 - $2c84a + INCROM $2c84a, $30000 diff --git a/src/engine/home.asm b/src/engine/home.asm index c47a7a2..2f57dce 100755 --- a/src/engine/home.asm +++ b/src/engine/home.asm @@ -1,42 +1,39 @@ -GLOBAL CardGraphics -GLOBAL TextOffsets - ; rst vectors -SECTION "rst00",ROM0[0] +SECTION "rst00", ROM0 ret -SECTION "rst08",ROM0[8] +SECTION "rst08", ROM0 ret -SECTION "rst10",ROM0[$10] +SECTION "rst10", ROM0 ret -SECTION "rst18",ROM0[$18] +SECTION "rst18", ROM0 jp RST18 -SECTION "rst20",ROM0[$20] +SECTION "rst20", ROM0 jp RST20 -SECTION "rst28",ROM0[$28] +SECTION "rst28", ROM0 jp RST28 -SECTION "rst30",ROM0[$30] +SECTION "rst30", ROM0 ret -SECTION "rst38",ROM0[$38] +SECTION "rst38", ROM0 ret ; interrupts -SECTION "vblank",ROM0[$40] +SECTION "vblank", ROM0 jp VBlankHandler -SECTION "lcdc",ROM0[$48] +SECTION "lcdc", ROM0 call wLCDCFunctiontrampoline reti -SECTION "timer",ROM0[$50] +SECTION "timer", ROM0 jp TimerHandler -SECTION "serial",ROM0[$58] +SECTION "serial", ROM0 jp SerialHandler -SECTION "joypad",ROM0[$60] +SECTION "joypad", ROM0 reti -SECTION "romheader",ROM0[$100] +SECTION "romheader", ROM0 nop jp Start -SECTION "start",ROM0[$150] +SECTION "start", ROM0 Start: ; 0150 (0:0150) di ld sp, $fffe @@ -59,7 +56,7 @@ Start: ; 0150 (0:0150) call SetupVRAM call SetupLCD call SetupPalettes - call SetupSound_T + call SetupSound call SetupTimer call ResetSerial call CopyDMAFunction @@ -137,9 +134,9 @@ TimerHandler: ; 01e6 (0:01e6) set 1, [hl] ldh a, [hBankROM] push af - ld a, BANK(SoundTimerHandler_Ext) + ld a, BANK(SoundTimerHandler) call BankswitchHome - call SoundTimerHandler_Ext + call SoundTimerHandler pop af call BankswitchHome ; clear in-timer flag @@ -213,7 +210,7 @@ CheckForCGB: ; 025c (0:025c) WaitForVBlank: ; 0264 (0:0264) push hl ld a, [wLCDC] - bit 7, a + bit rLCDC_ENABLE, a jr z, .asm_275 ld hl, wVBlankCtr ld a, [hl] @@ -229,19 +226,19 @@ WaitForVBlank: ; 0264 (0:0264) ; turn LCD on EnableLCD: ; 0277 (0:0277) ld a, [wLCDC] ; - bit 7, a ; + bit rLCDC_ENABLE, a ; ret nz ; assert that LCD is off - or $80 ; + or rLCDC_ENABLE_MASK ; ld [wLCDC], a ; ld [rLCDC], a ; turn LCD on - ld a, $c0 + ld a, %11000000 ld [wFlushPaletteFlags], a ret ; wait for vblank, then turn LCD off DisableLCD: ; 028a (0:028a) ld a, [rLCDC] ; - bit 7, a ; + bit rLCDC_ENABLE, a ; ret z ; assert that LCD is on ld a, [rIE] ld [wIE], a @@ -249,7 +246,7 @@ DisableLCD: ; 028a (0:028a) ld [rIE], a ; disable vblank interrupt .asm_298 ld a, [rLY] ; - cp $91 ; + cp LY_VBLANK ; jr nz, .asm_298 ; wait for vblank ld a, [rLCDC] ; and $7f ; @@ -353,7 +350,7 @@ SetupLCD: ; 030b (0:030b) ld [wLCDC], a ld a, $1 ld [MBC3LatchClock], a - ld a, $a + ld a, SRAM_ENABLE ld [MBC3SRamEnable], a NopF: ; 0348 (0:0348) ret @@ -374,13 +371,13 @@ DetectConsole: ; 0349 (0:0349) ret nz ld a, CONSOLE_SGB ld [rSVBK], a - call Func_07e7 + call SwitchToCGBDoubleSpeed ret ; initialize the palettes (both monochrome and color) SetupPalettes: ; 036a (0:036a) ld hl, wBGP - ld a, $e4 + ld a, %11100100 ld [rBGP], a ld [hli], a ld [rOBP0], a @@ -422,8 +419,8 @@ SetupVRAM: ; 03a1 (0:03a1) call .asm_3b2 call BankswitchVRAM_0 .asm_3b2 - ld hl, $8000 - ld bc, $1800 + ld hl, vTiles0 + ld bc, vBGMapTiles - vTiles0 .asm_3b8 xor a ld [hli], a @@ -436,8 +433,8 @@ SetupVRAM: ; 03a1 (0:03a1) ; fill VARM tile map banks with [wTileMapFill] FillTileMap: ; 03c0 (0:03c0) call BankswitchVRAM_0 - ld hl, $9800 - ld bc, $0400 + ld hl, vBGMapTiles + ld bc, vBGMapAttrs - vBGMapTiles .asm_3c9 ld a, [wTileMapFill] ld [hli], a @@ -449,8 +446,8 @@ FillTileMap: ; 03c0 (0:03c0) cp CONSOLE_CGB ret nz call BankswitchVRAM_1 - ld hl, $9800 - ld bc, $0400 + ld hl, vBGMapTiles + ld bc, vBGMapAttrs - vBGMapTiles .asm_3e1 xor a ld [hli], a @@ -463,23 +460,23 @@ FillTileMap: ; 03c0 (0:03c0) ; zero work RAM, stack area & high RAM ($C000-$DFFF, $FF80-$FFEF) ZeroRAM: ; 03ec (0:03ec) - ld hl, wTempCardCollection - ld bc, $2000 -.asm_3f2 + ld hl, $c000 + ld bc, $e000 - $c000 +.zero_wram_loop xor a ld [hli], a dec bc ld a, c or b - jr nz, .asm_3f2 - ld c, $80 - ld b, $70 + jr nz, .zero_wram_loop + ld c, LOW($ff80) + ld b, $fff0 - $ff80 xor a -.asm_3fe +.zero_hram_loop ld [$ff00+c], a inc c dec b - jr nz, .asm_3fe + jr nz, .zero_hram_loop ret Func_0404: ; 0404 (0:0404) @@ -601,7 +598,7 @@ Func_0492: ; 0492 (0:0492) ld b, a ld a, [hli] ld c, a - call Func_04cf + call BCCoordToBGMap0Address jr .asm_49d .asm_49b ld [de], a @@ -630,7 +627,9 @@ SGB_ATTR_BLK_04bf: ; 04bf (0:04bf) sgb ATTR_BLK, 1 ; sgb_command, length db $01,$03,$00,$00,$00,$13,$11,$00,$00,$00,$00,$00,$00,$00,$00 -Func_04cf: ; 04cf (0:04cf) +; returns vBGMapTiles + BG_MAP_WIDTH * c + b in de. +; used to map coordinates at bc to a BGMap0 address. +BCCoordToBGMap0Address: ; 04cf (0:04cf) ld l, c ld h, $0 add hl, hl @@ -639,7 +638,7 @@ Func_04cf: ; 04cf (0:04cf) add hl, hl add hl, hl ld c, b - ld b, $98 + ld b, HIGH(vBGMapTiles) add hl, bc ld e, l ld d, h @@ -735,13 +734,13 @@ DoFrame: ; 053f (0:053f) ldh a, [hButtonsPressed] and SELECT jr z, .done -.gamePausedLoop +.game_paused_loop call WaitForVBlank call ReadJoypad call HandleDPadRepeat ldh a, [hButtonsPressed] and SELECT - jr z, .gamePausedLoop + jr z, .game_paused_loop .done pop bc pop de @@ -825,7 +824,85 @@ CallHL: ; 05c1 (0:05c1) jp hl ; 0x5c2 -INCBIN "baserom.gbc",$05c2,$0663 - $05c2 +Func_05c2: ; 5c2 (0:5c2) + push hl + push bc + push de + ld hl, wcaa0 + push hl + push bc + call Func_0614 + pop bc + call BCCoordToBGMap0Address + pop hl + ld b, $02 + call JumpToHblankCopyDataHLtoDE + pop de + pop bc + pop hl + ret +; 0x5db + +Func_05db: ; 5db (0:5db) + push hl + push bc + push de + ld hl, wcaa0 + push hl + push bc + call Func_061b + pop bc + call BCCoordToBGMap0Address + pop hl + ld b, $01 + call JumpToHblankCopyDataHLtoDE + pop de + pop bc + pop hl + ret +; 0x5f4 + +Func_05f4: ; 5f4 (0:5f4) + push hl + push bc + push de + ld e, l + ld d, h + ld hl, wcaa0 + push hl + push bc + ld a, d + call Func_0614 + ld a, e + call Func_0614 + pop bc + call BCCoordToBGMap0Address + pop hl + ld b, $04 + call JumpToHblankCopyDataHLtoDE + pop de + pop bc + pop hl + ret +; 0x614 + +Func_0614: ; 614 (0:614) + push af + swap a + call Func_061b + pop af +Func_061b: + and $0f + add $30 + cp $3a + jr c, .asm_625 + add $07 +.asm_625 + ld [hli], a + ret +; 0x627 + + INCROM $0627, $0663 Func_0663: ; 0663 (0:0663) push bc @@ -861,47 +938,114 @@ Func_0686: ; 0686 (0:0686) ret ; 0x695 -INCBIN "baserom.gbc",$0695,$06c3 - $0695 +Func_0695: ; 0695 (0:0695) + call Func_069d + bit 7, [hl] + jr z, Func_0695 + ret +; 0x69d + +Func_069d: ; 069d (0:069d) + ld b, [hl] + inc hl + ld c, [hl] + inc hl + push hl + push bc + ld b, $ff +.asm_6a5 + inc b + ld a, [hli] + or a + jr nz, .asm_6a5 + ld a, b + pop bc + push af + call BCCoordToBGMap0Address + pop af + ld b, a + pop hl + or a + jr z, .asm_6bd + push bc + push hl + call SafeCopyDataHLtoDE + pop hl + pop bc + +.asm_6bd + inc b + ld c, b + ld b, $0 + add hl, bc + ret +; 0x6c3 Func_06c3: ; 06c3 (0:06c3) push af ld a, [wLCDC] rla - jr c, .asm_6d8 + jr c, .lcd_on pop af push hl push de push bc push af - call Func_04cf + call BCCoordToBGMap0Address pop af ld [de], a pop bc pop de pop hl ret -.asm_6d8 +.lcd_on pop af push hl push de push bc - ld hl, $cac1 + ld hl, wcac1 push hl ld [hl], a - call Func_04cf + call BCCoordToBGMap0Address pop hl ld b, $1 - call MemcpyHLDE_hblank + call HblankCopyDataHLtoDE pop bc pop de pop hl ret ; 0x6ee -INCBIN "baserom.gbc",$06ee,$0709 - $06ee +; copy a bytes of data from hl to vBGMap0 address pointed to by coord at bc +Func_06ee: ; 06ee (0:06ee) + push bc + push hl + push af + call BCCoordToBGMap0Address + pop af + ld b, a + pop hl + call SafeCopyDataHLtoDE + pop bc + ret +; 0x6fc -Func_0709: ; 0709 (0:0709) - jp MemcpyHLDE_hblank +; memcpy(DE, HL, B) +; if LCD on, copy during h-blank only +SafeCopyDataHLtoDE: ; 6fc (0:6fc) + ld a, [wLCDC] + rla + jr c, JumpToHblankCopyDataHLtoDE +.lcd_off_loop + ld a, [hli] + ld [de], a + inc de + dec b + jr nz, .lcd_off_loop + ret +JumpToHblankCopyDataHLtoDE: ; 0709 (0:0709) + jp HblankCopyDataHLtoDE +; 0x70c CopyGfxData: ; 070c (0:070c) ld a, [wLCDC] @@ -912,7 +1056,7 @@ CopyGfxData: ; 070c (0:070c) push hl push de ld b, c - call Func_0709 + call JumpToHblankCopyDataHLtoDE ld b, $0 pop hl add hl, bc @@ -937,25 +1081,25 @@ CopyGfxData: ; 070c (0:070c) jr nz, .asm_726 ret -CopyData_SaveRegisters: ; 0732 (0:0732) +CopyDataHLtoDE_SaveRegisters: ; 0732 (0:0732) push hl push de push bc - call CopyData + call CopyDataHLtoDE pop bc pop de pop hl ret ; copies bc bytes from hl to de -CopyData: ; 073c (0:073c) +CopyDataHLtoDE: ; 073c (0:073c) ld a, [hli] ld [de], a inc de dec bc ld a, c or b - jr nz, CopyData + jr nz, CopyDataHLtoDE ret ; switch to rombank (A + top2 of H shifted down), @@ -1059,7 +1203,7 @@ BankswitchRAM: ; 07a9 (0:07a9) push af ldh [hBankRAM], a ld [MBC3SRamBank], a - ld a, $a + ld a, SRAM_ENABLE ld [MBC3SRamEnable], a pop af ret @@ -1067,7 +1211,7 @@ BankswitchRAM: ; 07a9 (0:07a9) ; enable external RAM EnableExtRAM: ; 07b6 (0:07b6) push af - ld a, $a + ld a, SRAM_ENABLE ld [MBC3SRamEnable], a pop af ret @@ -1075,7 +1219,7 @@ EnableExtRAM: ; 07b6 (0:07b6) ; disable external RAM DisableExtRAM: ; 07be (0:07be) push af - xor a + xor a ; SRAM_DISABLE ld [MBC3SRamEnable], a pop af ret @@ -1106,14 +1250,22 @@ BankswitchVRAM: ; 07d6 (0:07d6) ret ; 0x7db -INCBIN "baserom.gbc",$07db,$07e7 - $07db +SwitchToCGBNormalSpeed: ; 7db (0:7db) + call CheckForCGB + ret c + ld hl, rKEY1 + bit 7, [hl] + ret z + jr CGBSpeedSwitch -Func_07e7: ; 07e7 (0:07e7) +SwitchToCGBDoubleSpeed: ; 07e7 (0:07e7) call CheckForCGB ret c ld hl, rKEY1 bit 7, [hl] ret nz +; fallthrough +CGBSpeedSwitch: ; 07f1 (0:07f1) ld a, [rIE] push af xor a @@ -1223,7 +1375,7 @@ HtimesL: ; 0879 (0:0879) ret ; 0x88f -; return a random number between 0 and a in a +; return a random number between 0 and a (exclusive) in a Random: ; 088f (0:088f) push hl ld h, a @@ -1391,7 +1543,7 @@ Func_08ef: ; 08ef (0:08ef) jr .asm_93c ; 0x950 -INCBIN "baserom.gbc",$0950,$099c - $0950 + INCROM $0950, $099c Func_099c: ; 099c (0:099c) xor a @@ -1453,7 +1605,18 @@ Func_09ce: ; 09ce (0:09ce) ret ; 0x9dc -INCBIN "baserom.gbc",$09dc,$09e9 - $09dc +SwitchToBankAtSP: ; 9dc (0:9dc) + push af + push hl + ld hl, sp+$04 + ld a, [hl] + call BankswitchHome + pop hl + pop af + inc sp + inc sp + ret +; 0x9e9 ; this function affects the stack so that it returns ; to the three byte pointer following the rst call @@ -1660,7 +1823,48 @@ SGB_MLT_REQ_2: ; 0bbb (0:0bbb) sgb MLT_REQ, 1 ; sgb_command, length db $01,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00,$00 -INCBIN "baserom.gbc",$0bcb,$0c08 - $0bcb +Func_0bcb: ; 0bcb (0:0bcb) + di + push de +.wait_vbalnk + ld a, [rLY] + cp LY_VBLANK + 3 + jr nz, .wait_vbalnk + ld a, $43 + ld [rLCDC], a + ld a, %11100100 + ld [rBGP], a + ld de, vTiles1 + ld bc, vBGMapTiles - vTiles1 +.loop + ld a, [hli] + ld [de], a + inc de + dec bc + ld a, b + or c + jr nz, .loop + ld hl, vBGMapTiles + ld de, $000c + ld a, $80 + ld c, $d +.asm_bf3 + ld b, $14 +.asm_bf5 + ld [hli], a + inc a + dec b + jr nz, .asm_bf5 + add hl, de + dec c + jr nz, .asm_bf3 + ld a, $c3 + ld [rLCDC], a + pop hl + call SendSGB + ei + ret +; 0xc08 ; loops 63000 * bc cycles (~15 * bc ms) Wait: ; 0c08 (0:0c08) @@ -1680,7 +1884,7 @@ Wait: ; 0c08 (0:0c08) ret ; memcpy(DE, HL, B), but only during hblank -MemcpyHLDE_hblank: ; 0c19 (0:0c19) +HblankCopyDataHLtoDE: ; 0c19 (0:0c19) push bc .loop ei @@ -1701,30 +1905,30 @@ MemcpyHLDE_hblank: ; 0c19 (0:0c19) pop bc ret -; memcpy(HL, DE, B), but only during hblank -MemcpyDEHL_hblank: ; 0c32 (0:0c32) +; memcpy(HL, DE, C), but only during hblank +HblankCopyDataDEtoHL: ; 0c32 (0:0c32) push bc -.asm_c33 +.loop ei di ld a, [rSTAT] and $3 - jr nz, .asm_c33 + jr nz, .loop ld a, [de] ld [hl], a ld a, [rSTAT] and $3 - jr nz, .asm_c33 + jr nz, .loop ei inc hl inc de dec c - jr nz, .asm_c33 + jr nz, .loop pop bc ret ; 0xc4b -INCBIN "baserom.gbc",$0c4b,$0c91 - $0c4b + INCROM $0c4b, $0c91 ; called at roughly 240Hz by TimerHandler SerialTimerHandler: ; 0c91 (0:0c91) @@ -1764,7 +1968,7 @@ SerialTimerHandler: ; 0c91 (0:0c91) ret ; 0xcc5 -INCBIN "baserom.gbc",$0cc5,$0d26 - $0cc5 + INCROM $0cc5, $0d26 SerialHandler: ; 0d26 (0:0d26) push af @@ -2093,14 +2297,40 @@ Func_0ebf: ; 0ebf (0:0ebf) ret ; 0xed5 -INCBIN "baserom.gbc",$0ed5,$0f35 - $0ed5 +Func_0ed5: ; 0ed5 (0:0ed5) + push bc +.asm_ed6 + call Func_0e39 + jr nc, .asm_edf + halt + nop + jr .asm_ed6 +.asm_edf + ld [hli], a + ld a, [wSerialFlags] + or a + jr nz, .asm_eee + dec bc + ld a, c + or b + jr nz, .asm_ed6 + pop bc + or a + ret +.asm_eee + pop bc + scf + ret +; 0xef1 + + INCROM $0ef1, $0f35 Func_0f35: ; 0f35 (0:0f35) ld a, [wSerialFlags] ld l, a ld h, $0 call Func_2ec4 - text_hl TransmissionErrorText + ldtx hl, TransmissionErrorText call DrawWideTextBox_WaitForInput ld a, $ff ld [wd0c3], a @@ -2143,18 +2373,28 @@ Func_0f7f: ; 0f7f (0:0f7f) ld a, DUELVARS_DUELIST_TYPE call GetNonTurnDuelistVariable cp DUELIST_TYPE_LINK_OPP - jr nz, .notLink + jr nz, .not_link ld hl, $ff9e ld bc, $000a call Func_0ebf call Func_0f58 -.notLink +.not_link pop bc pop hl ret ; 0xf9b -INCBIN "baserom.gbc",$0f9b,$0fac - $0f9b +Func_0f9b: ; 0f9b (0:0f9b) + push hl + push bc + ld hl, $ff9e + ld bc, $000a + call Func_0ed5 + call Func_0f58 + pop bc + pop hl + ret +; 0xfac Func_0fac: ; 0fac (0:0fac) push hl @@ -2177,7 +2417,7 @@ Func_0fac: ; 0fac (0:0fac) push de push hl push af - ld hl, $cbed + ld hl, wcbed pop de ld [hl], e inc hl @@ -2196,7 +2436,7 @@ Func_0fac: ; 0fac (0:0fac) ld [hl], c inc hl ld [hl], b - ld hl, $cbed + ld hl, wcbed ld bc, $0008 call Func_0ebf jp c, Func_0f35 @@ -2207,7 +2447,34 @@ Func_0fac: ; 0fac (0:0fac) ret ; 0xfe9 -INCBIN "baserom.gbc",$0fe9,$100b - $0fe9 +Func_0fe9: ; 0fe9 (0:0fe9) + ld hl, wcbed + ld bc, $0008 + push hl + call Func_0ed5 + jp c, Func_0f35 + pop hl + ld e, [hl] + inc hl + ld d, [hl] + inc hl + push de + ld e, [hl] + inc hl + ld d, [hl] + inc hl + push de + ld e, [hl] + inc hl + ld d, [hl] + inc hl + ld c, [hl] + inc hl + ld b, [hl] + pop hl + pop af + ret +; 0x100b Func_100b: ; 100b (0:100b) ld a, $2 @@ -2266,9 +2533,9 @@ CopyDeckData: ; 1072 (0:1072) ld hl, wPlayerDeck ldh a, [hWhoseTurn] cp PLAYER_TURN - jr z, .copyDeckData + jr z, .copy_deck_data ld hl, wOpponentDeck -.copyDeckData +.copy_deck_data ; start by putting a terminator at the end of the deck push hl ld bc, DECK_SIZE - 1 @@ -2276,7 +2543,7 @@ CopyDeckData: ; 1072 (0:1072) ld [hl], $0 pop hl push hl -.nextCard +.next_card ld a, [de] inc de ld b, a @@ -2285,12 +2552,12 @@ CopyDeckData: ; 1072 (0:1072) ld a, [de] inc de ld c, a -.cardQuantityLoop +.card_quantity_loop ld [hl], c inc hl dec b - jr nz, .cardQuantityLoop - jr .nextCard + jr nz, .card_quantity_loop + jr .next_card .done ld hl, $cce9 ld a, [de] @@ -2309,7 +2576,21 @@ CopyDeckData: ; 1072 (0:1072) ret ; 0x10aa -INCBIN "baserom.gbc",$10aa,$10bc - $10aa +Func_10aa: ; 10aa (0:10aa) + push hl + ld a, DUELVARS_PRIZES + call GetTurnDuelistVariable + ld l, a + xor a +.asm_10b2 + rr l + adc $00 + inc l + dec l + jr nz, .asm_10b2 + pop hl + ret +; 0x10bc ; shuffles the deck specified by hWhoseTurn ; if less than 60 cards remain in the deck, make sure the rest are ignored @@ -2323,38 +2604,37 @@ ShuffleDeck: ; 10bc (0:10bc) ld b, a ld a, DUELVARS_DECK_CARDS add [hl] - ld l, a ; hl = position in the wPlayerDeckCards or wOpponentDeckCards array - ; of the first (top) card in the deck + ld l, a ; hl = position of the first (top) deck card in the wPlayerDeckCards or wOpponentDeckCards array ld a, b ; a = number of cards in the deck call ShuffleCards ret -; draw a card from the deck, saving its location as $40 +; draw a card from the deck, saving its location as CARD_LOCATION_JUST_DRAWN ; returns c if deck is empty, nc if a card was succesfully drawn -_DrawCardFromDeck: ; 10cf (0:10cf) +DrawCardFromDeck: ; 10cf (0:10cf) push hl ld a, DUELVARS_NUMBER_OF_CARDS_NOT_IN_DECK call GetTurnDuelistVariable cp DECK_SIZE - jr nc, .emptyDeck + jr nc, .empty_deck inc a ld [hl], a ; increment number of cards not in deck add DUELVARS_DECK_CARDS - 1 ; point to top card in the deck ld l, a ld a, [hl] ; grab card number (0-59) from wPlayerDeckCards or wOpponentDeckCards array ld l, a - ld [hl], $40 ; temporarily write $40 to corresponding card location variable + ld [hl], CARD_LOCATION_JUST_DRAWN ; temporarily write to corresponding card location variable pop hl or a ret -.emptyDeck +.empty_deck pop hl scf ret ; 0x10e8 -INCBIN "baserom.gbc",$10e8,$1123 - $10e8 + INCROM $10e8, $1123 ; adds a card to the hand and increments the number of cards in the hand ; the card is identified by register a, which contains the card number within the deck (0-59) @@ -2366,8 +2646,8 @@ AddCardToHand: ; 1123 (0:1123) ld l, a ldh a, [hWhoseTurn] ld h, a - ; write $1 (hand) into the location of this card - ld [hl], $1 + ; write $1 (CARD_LOCATION_HAND) into the location of this card + ld [hl], CARD_LOCATION_HAND ; increment number of cards in hand ld l, DUELVARS_NUMBER_OF_CARDS_IN_HAND inc [hl] @@ -2382,26 +2662,26 @@ AddCardToHand: ; 1123 (0:1123) ret ; 0x1139 -INCBIN "baserom.gbc",$1139,$123b - $1139 + INCROM $1139, $123b CreateHandCardBuffer: ; 123b (0:123b) call FindLastCardInHand inc b - jr .skipCard + jr .skip_card -.checkNextCardLoop +.check_next_card_loop ld a, [hld] push hl ld l, a bit 6, [hl] pop hl - jr nz, .skipCard + jr nz, .skip_card ld [de], a inc de -.skipCard +.skip_card dec b - jr nz, .checkNextCardLoop + jr nz, .check_next_card_loop ld a, $ff ld [de], a ld l, (wPlayerNumberOfCardsInHand & $ff) @@ -2412,7 +2692,7 @@ CreateHandCardBuffer: ; 123b (0:123b) ret ; 0x1258 -INCBIN "baserom.gbc",$1258,$1271 - $1258 + INCROM $1258, $1271 ; puts an index to the last (newest) card in current player's hand into hl. FindLastCardInHand: ; 1271 (0:1271) @@ -2440,7 +2720,7 @@ ShuffleCards: ; 127f (0:127f) ld b, a ld e, l ld d, h -.shuffleNextCardLoop +.shuffle_next_card_loop push bc push de ld a, c @@ -2459,14 +2739,14 @@ ShuffleCards: ; 127f (0:127f) pop bc inc hl dec b - jr nz, .shuffleNextCardLoop + jr nz, .shuffle_next_card_loop pop bc pop de pop hl ret ; 0x12a3 -INCBIN "baserom.gbc",$12a3,$1312 - $12a3 + INCROM $12a3, $1312 ; given a position in wDuelCardOrAttackList (c510), return: @@ -2499,7 +2779,7 @@ GetCardInDeckPosition: ; 1324 (0:1324) ret ; 0x132f -INCBIN "baserom.gbc",$132f,$1362 - $132f + INCROM $132f, $1362 ; returns, in register a, the id of the card in the deck position specified in register a _GetCardInDeckPosition: ; 1362 (0:1362) @@ -2509,14 +2789,15 @@ _GetCardInDeckPosition: ; 1362 (0:1362) ld hl, wPlayerDeck ldh a, [hWhoseTurn] cp PLAYER_TURN - jr z, .loadCardFromDeck + jr z, .load_card_from_deck ld hl, wOpponentDeck -.loadCardFromDeck +.load_card_from_deck add hl, de ld a, [hl] pop de ret +; load data of card in position a to wLoadedCard1 LoadDeckCardToBuffer1: ; 1376 (0:1376) push hl push de @@ -2533,6 +2814,7 @@ LoadDeckCardToBuffer1: ; 1376 (0:1376) pop hl ret +; load data of card in position a to wLoadedCard2 LoadDeckCardToBuffer2: ; 138c (0:138c) push hl push de @@ -2550,14 +2832,14 @@ LoadDeckCardToBuffer2: ; 138c (0:138c) ret ; 0x13a2 -INCBIN "baserom.gbc",$13a2,$1485 - $13a2 + INCROM $13a2, $1485 Func_1485: ; 1485 (0:1485) push af ld a, DUELVARS_NUMBER_OF_POKEMON_IN_PLAY call GetTurnDuelistVariable cp MAX_POKEMON_IN_PLAY - jr nc, .tooManyPokemonInPlay + jr nc, .too_many_pokemon_in_play inc [hl] ld e, a pop af @@ -2602,13 +2884,13 @@ Func_1485: ; 1485 (0:1485) or a ret -.tooManyPokemonInPlay +.too_many_pokemon_in_play pop af scf ret ; 0x14d2 -INCBIN "baserom.gbc",$14d2,$159f - $14d2 + INCROM $14d2, $159f ; This function iterates through the card locations array to find out which and how many ; energy cards are in arena (i.e. attached to the active pokemon). @@ -2622,10 +2904,10 @@ GetAttachedEnergies: ; 159f (0:159f) xor a ld c, NUM_TYPES ld hl, wAttachedEnergies -.zeroEnergiesLoop +.zero_energies_loop ld [hli], a dec c - jr nz, .zeroEnergiesLoop + jr nz, .zero_energies_loop ld a, CARD_LOCATION_ARENA or e ; if e is non-0, arena is not the only location that counts ld e, a @@ -2633,10 +2915,10 @@ GetAttachedEnergies: ; 159f (0:159f) ld h, a ld l, DUELVARS_CARD_LOCATIONS ld c, DECK_SIZE -.nextCard +.next_card ld a, [hl] cp e - jr nz, .notInRequestedLocation + jr nz, .not_in_requested_location push hl push de @@ -2644,8 +2926,8 @@ GetAttachedEnergies: ; 159f (0:159f) ld a, l call LoadDeckCardToBuffer2 ld a, [wLoadedCard2Type] - bit ENERGY_CARD_F, a - jr z, .notAnEnergyCard + bit TYPE_ENERGY_F, a + jr z, .not_an_energy_card and $7 ; zero bit 3 to extract the type ld e, a ld d, $0 @@ -2653,18 +2935,18 @@ GetAttachedEnergies: ; 159f (0:159f) add hl, de inc [hl] ; increment the number of energy cards of this type cp COLORLESS - jr nz, .notColorless + jr nz, .not_colorless inc [hl] ; each colorless energy counts as two -.notAnEnergyCard -.notColorless +.not_an_energy_card +.not_colorless pop bc pop de pop hl -.notInRequestedLocation +.not_in_requested_location inc l dec c - jr nz, .nextCard + jr nz, .next_card ; all 60 cards checked ld hl, wAttachedEnergies ld c, NUM_TYPES @@ -2689,22 +2971,22 @@ CountCardIDInLocation: ; 15ef (0:15ef) push bc ld l, $0 ld c, $0 -.nextCard +.next_card ld a, [hl] cp b - jr nz, .unmatchingCardLocationOrID + jr nz, .unmatching_card_location_orID ld a, l push hl call _GetCardInDeckPosition cp e pop hl - jr nz, .unmatchingCardLocationOrID + jr nz, .unmatching_card_location_orID inc c -.unmatchingCardLocationOrID +.unmatching_card_location_orID inc l ld a, l cp DECK_SIZE - jr c, .nextCard + jr c, .next_card ld a, c pop bc ret @@ -2732,7 +3014,7 @@ GetNonTurnDuelistVariable: ; 1611 (0:1611) ret ; 0x161e -INCBIN "baserom.gbc",$161e,$16c0 - $161e + INCROM $161e, $16c0 CopyMoveDataAndDamageToBuffer: ; 16c0 (0:16c0) ld a, e @@ -2744,17 +3026,17 @@ CopyMoveDataAndDamageToBuffer: ; 16c0 (0:16c0) ld [wTempCardId], a ld hl, wLoadedCard1Move1 dec e - jr nz, .gotMove + jr nz, .got_move ld hl, wLoadedCard1Move2 -.gotMove +.got_move ld de, wLoadedMove ld c, wLoadedCard1Move2 - wLoadedCard1Move1 -.copyLoop +.copy_loop ld a, [hli] ld [de], a inc de dec c - jr nz, .copyLoop + jr nz, .copy_loop ld a, [wLoadedMoveDamage] ld hl, wDamage ld [hli], a @@ -2918,7 +3200,7 @@ DealConfusionDamageToSelf: ; 1828 (0:1828) bank1call $4f9d ld a, $1 ld [wcce6], a - text_hl DamageToSelfDueToConfusionText + ldtx hl, DamageToSelfDueToConfusionText call DrawWideTextBox_PrintText ld a, $75 ld [wLoadedMoveAnimation], a @@ -3017,20 +3299,39 @@ CheckSelfConfusionDamage: ; 18d7 (0:18d7) or a ret .confused - text_de ConfusionCheckDamageText + ldtx de, ConfusionCheckDamageText call TossCoin - jr c, .noConfusionDamage + jr c, .no_confusion_damage ld a, $1 ld [wccc9], a scf ret -.noConfusionDamage +.no_confusion_damage or a ret ; 0x18f9 -INCBIN "baserom.gbc",$18f9,$195c - $18f9 + INCROM $18f9, $1944 +; this loads HP and Stage (1 byte each) of card with id at $ff9f into wLoadedMoveEffectCommands +Func_1944: ; 1944 (0:1944) + ld a, [$ff9f] + call LoadDeckCardToBuffer1 + ld hl, wLoadedCard1HP + ld de, wLoadedMoveEffectCommands + ld a, [hli] + ld [de], a + inc de + ld a, [hl] + ld [de], a + ret +; 0x1955 + +Func_1955: ; 1955 (0:1955) + push af + ld a, $7a + ld [wLoadedMoveAnimation], a + pop af ; this function appears to apply several damage modifiers Func_195c: ; 195c (0:195c) ld hl, wDamage @@ -3065,10 +3366,10 @@ Func_1994: ; 1994 (0:1994) ld hl, wDamage ld a, [hli] or [hl] - jr nz, .nonZeroDamage + jr nz, .non_zero_damage ld de, $0000 ret -.nonZeroDamage +.non_zero_damage xor a ld [$ff9d], a ld d, [hl] @@ -3080,7 +3381,7 @@ Func_1994: ; 1994 (0:1994) xor a ld [wccc1], a call HandleDoubleDamageSubstatus - jr .checkPluspowerAndDefender + jr .check_pluspower_and_defender .safe call HandleDoubleDamageSubstatus ld a, e @@ -3104,14 +3405,14 @@ Func_1994: ; 1994 (0:1994) call Func_374a call SwapTurn and b - jr z, .checkPluspowerAndDefender + jr z, .check_pluspower_and_defender ld hl, $ffe2 add hl, de ld e, l ld d, h ld hl, $ccc1 set 2, [hl] -.checkPluspowerAndDefender +.check_pluspower_and_defender ld b, CARD_LOCATION_ARENA call ApplyAttachedPluspower call SwapTurn @@ -3119,9 +3420,9 @@ Func_1994: ; 1994 (0:1994) call ApplyAttachedDefender call HandleDamageReduction bit 7, d - jr z, .noUnderflow + jr z, .no_underflow ld de, $0000 -.noUnderflow +.no_underflow call SwapTurn ret @@ -3137,7 +3438,7 @@ Func_1a0e: ; 1a0e (0:1a0e) ret ; 0x1a1a -INCBIN "baserom.gbc",$1a1a,$1a22 - $1a1a + INCROM $1a1a, $1a22 Func_1a22: ; 1a22 (0:1a22) xor a @@ -3146,7 +3447,7 @@ Func_1a22: ; 1a22 (0:1a22) ld a, [hli] or [hl] or a - jr z, .noDamage + jr z, .no_damage ld d, [hl] dec hl ld e, [hl] @@ -3177,7 +3478,7 @@ Func_1a22: ; 1a22 (0:1a22) call ApplyAttachedDefender bit 7, d ; test for underflow ret z -.noDamage +.no_damage ld de, $0000 ret @@ -3226,9 +3527,9 @@ SubstractHP: ; 1a96 (0:1a96) ld a, $0 sbc d and $80 - jr z, .noUnderflow + jr z, .no_underflow ld [hl], $0 -.noUnderflow +.no_underflow ld a, [hl] or a jr z, .zero @@ -3271,7 +3572,7 @@ Func_1ad3: ; 1ad3 (0:1ad3) ld h, [hl] ld l, a call Func_2ebb - text_hl WasKnockedOutText + ldtx hl, WasKnockedOutText call DrawWideTextBox_PrintText ld a, $28 .asm_1aeb @@ -3282,7 +3583,7 @@ Func_1ad3: ; 1ad3 (0:1ad3) ret ; 0x1af3 -INCBIN "baserom.gbc",$1af3,$1b8d - $1af3 + INCROM $1af3, $1b8d Func_1b8d: ; 1b8d (0:1b8d) bank1call $4f9d @@ -3300,7 +3601,7 @@ Func_1b8d: ; 1b8d (0:1b8d) ld [hli], a ld a, [wLoadedMoveName + 1] ld [hli], a - text_hl PokemonsAttackText ; text when using an attack + ldtx hl, PokemonsAttackText ; text when using an attack call DrawWideTextBox_PrintText ret @@ -3337,7 +3638,7 @@ Func_1bca: ; 1bca (0:1bca) inc de ld a, [hli] ld [de], a - text_hl WasUnsuccessfulText + ldtx hl, WasUnsuccessfulText call DrawWideTextBox_PrintText scf ret @@ -3348,7 +3649,7 @@ Func_1bca: ; 1bca (0:1bca) ret ; 0x1c05 -INCBIN "baserom.gbc",$1c05,$1c72 - $1c05 + INCROM $1c05, $1c72 ; returns [hWhoseTurn] <-- ([hWhoseTurn] ^ $1) ; As a side effect, this also returns a duelist variable in a similar manner to @@ -3381,19 +3682,19 @@ PrintOpponentName: ; 1c8e (0:1c8e) ld hl, $cc16 ld a, [hli] or [hl] - jr z, .specialName + jr z, .special_name ld a, [hld] ld l, [hl] ld h, a jp PrintTextBoxBorderLabel -.specialName +.special_name ld hl, $c500 ld a, [hl] or a - jr z, .printPlayer2 + jr z, .print_player2 jr printNameLoop -.printPlayer2 - text_hl Player2 +.print_player2 + ldtx hl, Player2Text jp PrintTextBoxBorderLabel Func_1caa: ; 1caa (0:1caa) @@ -3502,13 +3803,13 @@ Func_1d1d: ; 1d1d (0:1d1d) scf ret -;creates a list at $c000 of every card the player owns and how many +; creates a list at $c000 of every card the player owns and how many CreateTempCardCollection: ; 1d2e (0:1d2e) call EnableExtRAM ld hl, sCardCollection ld de, wTempCardCollection ld bc, CARD_COLLECTION_SIZE - call CopyData + call CopyDataHLtoDE ld de, sDeck1Name call AddDeckCardsToTempCardCollection ld de, sDeck2Name @@ -3539,7 +3840,7 @@ AddDeckCardsToTempCardCollection: ; 1d59 (0:1d59) jr nz, .asm_1d66 ret -;adds card a to collection, provided the player has less than 99 of them +; adds card a to collection, provided the player has less than 99 of them AddCardToCollection: ; 1d6e (0:1d6e) push hl push de @@ -3583,26 +3884,27 @@ Func_1d91: ; 1d91 (0:1d91) ret ; 0x1da4 -INCBIN "baserom.gbc",$1da4,$1dca - $1da4 + INCROM $1da4, $1dca ; memcpy(HL, DE, C) -Memcpy: ; 1dca (0:1dca) +; if LCD on, copy during h-blank only +SafeCopyDataDEtoHL: ; 1dca (0:1dca) ld a, [wLCDC] ; - bit 7, a ; - jr nz, .asm_1dd8 ; assert that LCD is on -.asm_1dd1 + bit rLCDC_ENABLE, a ; + jr nz, .lcd_on ; assert that LCD is on +.lcd_off_loop ld a, [de] inc de ld [hli], a dec c - jr nz, .asm_1dd1 + jr nz, .lcd_off_loop ret -.asm_1dd8 - jp MemcpyDEHL_hblank +.lcd_on + jp HblankCopyDataDEtoHL -; calculates $9800 + SCREEN_WIDTH * e + d to map the screen coordinates at de -; to the corresponding BG Map 0 address in VRAM. -CalculateBGMap0Address: ; 1ddb (0:1ddb) +; returns vBGMapTiles + BG_MAP_WIDTH * e + d in hl. +; used to map coordinates at de to a BGMap0 address. +DECoordToBGMap0Address: ; 1ddb (0:1ddb) ld l, e ld h, $0 add hl, hl @@ -3614,7 +3916,7 @@ CalculateBGMap0Address: ; 1ddb (0:1ddb) add d ld l, a ld a, h - adc $98 + adc HIGH(vBGMapTiles) ld h, a ret @@ -3644,20 +3946,20 @@ AdjustCoordinatesForWindow: ; 1deb (0:1deb) DrawLabeledTextBox: ; 1e00 (0:1e00) ld a, [wConsole] cp CONSOLE_SGB - jr nz, .drawTopBorder + jr nz, .draw_top_border ld a, [wFrameType] or a - jr z, .drawTopBorder + jr z, .draw_top_border ; Console is SGB and frame type is != 0. ; The text box will be colorized so a SGB command needs to be transferred push de push bc - call .drawTopBorder ; this falls through to drawing the whole box + call .draw_top_border ; this falls through to drawing the whole box pop bc pop de jp ColorizeTextBoxSGB -.drawTopBorder +.draw_top_border push de push bc push hl @@ -3688,17 +3990,17 @@ DrawLabeledTextBox: ; 1e00 (0:1e00) ld a, d sub b sub $4 - jr z, .drawTopBorderRightTile + jr z, .draw_top_border_right_tile ld b, a -.drawTopBorderLineLoop +.draw_top_border_line_loop ld a, $5 ld [hli], a ld a, $1c ld [hli], a dec b - jr nz, .drawTopBorderLineLoop + jr nz, .draw_top_border_line_loop -.drawTopBorderRightTile +.draw_top_border_right_tile ld a, $5 ld [hli], a ld a, $19 @@ -3718,12 +4020,12 @@ DrawLabeledTextBox: ; 1e00 (0:1e00) jr z, .cgb ; DMG or SGB inc e - call CalculateBGMap0Address + call DECoordToBGMap0Address ; top border done, draw the rest of the text box jr ContinueDrawingTextBoxDMGorSGB .cgb - call CalculateBGMap0Address + call DECoordToBGMap0Address push de call CopyCurrentLineAttrCGB ; BG Map attributes for current line, which is the top border pop de @@ -3742,32 +4044,32 @@ DrawRegularTextBox: ; 1e7c (0:1e7c) jp z, DrawRegularTextBoxSGB ; fallthrough DrawRegularTextBoxDMG: ; 1e88 (0:1e88) - call CalculateBGMap0Address + call DECoordToBGMap0Address ; top line (border) of the text box ld a, $1c - ld de, $1819 + lb de, $18, $19 call CopyLine ContinueDrawingTextBoxDMGorSGB dec c dec c -.drawTextBoxBodyLoop +.draw_text_box_body_loop ld a, $0 - ld de, $1e1f + lb de, $1e, $1f call CopyLine dec c - jr nz, .drawTextBoxBodyLoop + jr nz, .draw_text_box_body_loop ; bottom line (border) of the text box ld a, $1d - ld de, $1a1b + lb de, $1a, $1b ; fallthrough -; copies b bytes of data to sp+$1c and to hl, and returns hl += SCREEN_WIDTH +; copies b bytes of data to sp+$1c and to hl, and returns hl += BG_MAP_WIDTH ; d = value of byte 0 ; e = value of byte b ; a = value of bytes [1, b-1] -; b is supposed to be SCREEN_WIDTH or smaller, else the stack would get corrupted +; b is supposed to be BG_MAP_WIDTH or smaller, else the stack would get corrupted CopyLine: ; 1ea5 (0:1ea5) - add sp, -$20 + add sp, -BG_MAP_WIDTH push hl push bc ld hl, sp+$4 @@ -3788,27 +4090,27 @@ CopyLine: ; 1ea5 (0:1ea5) push bc ld c, b ld b, $0 - call Memcpy + call SafeCopyDataDEtoHL pop bc pop de - ; advance pointer SCREEN_WIDTH positions and restore stack pointer - ld hl, $0020 + ; advance pointer BG_MAP_WIDTH positions and restore stack pointer + ld hl, BG_MAP_WIDTH add hl, de - add sp, $20 + add sp, BG_MAP_WIDTH ret DrawRegularTextBoxCGB: - call CalculateBGMap0Address + call DECoordToBGMap0Address ; top line (border) of the text box ld a, $1c - ld de, $1819 + lb de, $18, $19 call CopyCurrentLineTilesAndAttrCGB ContinueDrawingTextBoxCGB dec c dec c -.drawTextBoxBodyLoop +.draw_text_box_body_loop ld a, $0 - ld de, $1e1f + lb de, $1e, $1f push hl call CopyLine pop hl @@ -3820,10 +4122,10 @@ ContinueDrawingTextBoxCGB call CopyLine call BankswitchVRAM_0 dec c - jr nz, .drawTextBoxBodyLoop + jr nz, .draw_text_box_body_loop ; bottom line (border) of the text box ld a, $1d - ld de, $1a1b + lb de, $1a, $1b call CopyCurrentLineTilesAndAttrCGB ret @@ -3859,12 +4161,12 @@ ColorizeTextBoxSGB ld hl, $cae0 ld de, SGB_ATTR_BLK_1f4f ld c, $10 -.copySGBCommandLoop +.copy_sgb_command_loop ld a, [de] inc de ld [hli], a dec c - jr nz, .copySGBCommandLoop + jr nz, .copy_sgb_command_loop pop de pop bc ld hl, $cae4 @@ -3899,7 +4201,7 @@ Func_1f5f: ; 1f5f (0:1f5f) push af push hl add sp, $e0 - call CalculateBGMap0Address + call DECoordToBGMap0Address .asm_1f67 push hl push bc @@ -3921,7 +4223,7 @@ Func_1f5f: ; 1f5f (0:1f5f) push bc ld c, b ld b, $0 - call Memcpy + call SafeCopyDataDEtoHL ld hl, sp+$24 ld a, [hl] ld hl, sp+$27 @@ -3938,7 +4240,7 @@ Func_1f5f: ; 1f5f (0:1f5f) ret ; 0x1f96 -INCBIN "baserom.gbc",$1f96,$20b0 - $1f96 + INCROM $1f96, $20b0 Func_20b0: ; 20b0 (0:20b0) ld hl, $2fe8 @@ -3947,7 +4249,7 @@ Func_20b0: ; 20b0 (0:20b0) jr nz, .asm_20bd ld hl, $37f8 .asm_20bd - ld de, $8d00 + ld de, vTiles1 + $500 ld b, $30 jr asm_2121 @@ -3958,7 +4260,7 @@ Func_20c4: ; 20c4 (0:20c4) jr nz, .asm_20d1 ld hl, $3838 .asm_20d1 - ld de, $8d40 + ld de, vTiles1 + $540 ld b, $c jr asm_2121 @@ -3975,12 +4277,12 @@ asm_20de jr nz, .asm_20eb ld hl, $3af8 .asm_20eb - ld de, $8d00 + ld de, vTiles1 + $500 jr asm_2121 Func_20f0: ; 20f0 (0:20f0) ld hl, $4008 - ld de, $8a00 + ld de, vTiles1 + $200 ld b, $d call asm_2121 ld hl, $3528 @@ -3989,19 +4291,19 @@ Func_20f0: ; 20f0 (0:20f0) jr nz, .asm_2108 ld hl, $3d38 .asm_2108 - ld de, $8d00 + ld de, vTiles1 + $500 ld b, $30 jr asm_2121 Func_210f: ; 210f (0:210f) ld hl, $40d8 - ld de, $9300 + ld de, vTiles2 + $300 ld b, $8 jr asm_2121 Func_2119: ; 2119 (0:2119) ld hl, DuelGraphics - Fonts - ld de, $9000 ; destination + ld de, vTiles2 ; destination ld b, $38 ; number of tiles asm_2121 ld a, BANK(Fonts) @@ -4012,7 +4314,7 @@ asm_2121 ret ; 0x212f -INCBIN "baserom.gbc",$212f,$2167 - $212f + INCROM $212f, $2167 Func_2167: ; 2167 (0:2167) ld l, a @@ -4032,7 +4334,7 @@ Func_2167: ; 2167 (0:2167) jp Func_1f5f ; 0x2189 -INCBIN "baserom.gbc",$2189,$21c5 - $2189 + INCROM $2189, $21c5 Func_21c5: ; 21c5 (0:21c5) push de @@ -4193,7 +4495,7 @@ Func_22ae: ; 22ae (0:22ae) xor a ldh [$ffae], a ld [wcd09], a - call CalculateBGMap0Address + call DECoordToBGMap0Address ld a, l ldh [$ffaa], a ld a, h @@ -4246,7 +4548,7 @@ Func_22f2: ; 22f2 (0:22f2) ld h, d ld de, $cd05 ld c, $1 - call Memcpy + call SafeCopyDataDEtoHL ld hl, $ffac inc [hl] ret @@ -4439,12 +4741,12 @@ Func_23d3: ; 23d3 (0:23d3) ret ; 0x23fd -INCBIN "baserom.gbc",$23fd,$245d - $23fd + INCROM $23fd, $245d Func_245d: ; 245d (0:245d) push de push bc - ld de, $caa0 + ld de, wcaa0 push de ld bc, $d8f0 call Func_2499 @@ -4504,7 +4806,7 @@ Func_24ac: ; 24ac (0:24ac) or a jr nz, .asm_24bf call Func_2510 - call Memcpy + call SafeCopyDataDEtoHL .asm_24bb pop bc pop de @@ -4513,7 +4815,7 @@ Func_24ac: ; 24ac (0:24ac) .asm_24bf call Func_24ca call Func_2518 - call Memcpy + call SafeCopyDataDEtoHL jr .asm_24bb Func_24ca: ; 24ca (0:24ca) @@ -4659,121 +4961,124 @@ Func_256d: ; 256d (0:256d) ret ; 0x2589 -INCBIN "baserom.gbc",$2589,$2636 - $2589 + INCROM $2589, $2636 ; initializes cursor parameters given the 8 bytes starting at hl, ; which represent the following: ; x position, y position, y displacement between items, number of items, -; cursor tile number, tile behind cursor, ??, ?? +; cursor tile number, tile behind cursor, ???? (unknown function pointer if non-0) +; also sets the current menu item to the one specified in register a InitializeCursorParameters: ; 2636 (0:2636) ld [wCurMenuItem], a ldh [hCurrentMenuItem], a ld de, wCursorXPosition ld b, $8 -.asm_2640 +.loop ld a, [hli] ld [de], a inc de dec b - jr nz, .asm_2640 + jr nz, .loop xor a ld [wCursorBlinkCounter], a ret ; 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 -MenuCursorAcceptInput: ; 264b (0:264b) +HandleMenuInput: ; 264b (0:264b) xor a - ld [wcd99], a + ld [wRefreshMenuCursorSFX], a ldh a, [hButtonsPressed2] or a - jr z, .asm_2685 + jr z, .up_down_done ld b, a ld a, [wNumMenuItems] ld c, a ld a, [wCurMenuItem] bit D_UP_F, b - jr z, .asm_266b + jr z, .not_up dec a bit 7, a - jr z, .asm_2674 + jr z, .handle_up_or_down ld a, [wNumMenuItems] - dec a - jr .asm_2674 -.asm_266b + dec a ; wrapping around, so load the bottommost item + jr .handle_up_or_down +.not_up bit D_DOWN_F, b - jr z, .asm_2685 + jr z, .up_down_done inc a cp c - jr c, .asm_2674 - xor a -.asm_2674 + jr c, .handle_up_or_down + xor a ; wrapping around, so load the topmost item +.handle_up_or_down push af ld a, $1 - ld [wcd99], a + ld [wRefreshMenuCursorSFX], a ; buffer sound for up/down call EraseCursor pop af ld [wCurMenuItem], a xor a ld [wCursorBlinkCounter], a -.asm_2685 +.up_down_done ld a, [wCurMenuItem] ldh [hCurrentMenuItem], a - ld hl, $cd17 + ld hl, wcd17 ld a, [hli] or [hl] - jr z, asm_26a9 + jr z, .check_A_or_B ld a, [hld] ld l, [hl] ld h, a ldh a, [hCurrentMenuItem] call CallHL - jr nc, HandleMenuInput -asm_269b: - call Func_270b - -Func_269e: ; 269e (0:269e) - call Func_26c0 + jr nc, RefreshMenuCursor_CheckPlaySFX +.A_pressed_draw_cursor + call DrawCursor2 +.A_pressed + call PlayOpenOrExitScreenSFX ld a, [wCurMenuItem] ld e, a ldh a, [hCurrentMenuItem] scf ret -asm_26a9: +.check_A_or_B ldh a, [hButtonsPressed] and A_BUTTON | B_BUTTON - jr z, HandleMenuInput + jr z, RefreshMenuCursor_CheckPlaySFX and A_BUTTON - jr nz, asm_269b + jr nz, HandleMenuInput.A_pressed_draw_cursor + ; b button pressed ld a, [wCurMenuItem] ld e, a ld a, $ff ldh [hCurrentMenuItem], a - call Func_26c0 + call PlayOpenOrExitScreenSFX scf ret -Func_26c0: ; 26c0 (0:26c0) +; plays an "open screen" sound if [hCurrentMenuItem] != 0xff +; plays a "exit screen" sound if [hCurrentMenuItem] == 0xff +PlayOpenOrExitScreenSFX: ; 26c0 (0:26c0) push af ldh a, [hCurrentMenuItem] inc a - jr z, .asm_26ca + jr z, .play_exit_sfx ld a, $2 - jr .asm_26cc -.asm_26ca + jr .play_sfx +.play_exit_sfx ld a, $3 -.asm_26cc - call Func_3796 +.play_sfx + call PlaySFX pop af ret -HandleMenuInput: ; 26d1 (0:26d1) - ld a, [wcd99] +RefreshMenuCursor_CheckPlaySFX: ; 26d1 (0:26d1) + ld a, [wRefreshMenuCursorSFX] or a - jr z, HandleTextBoxInput - call Func_3796 + jr z, RefreshMenuCursor + call PlaySFX ; fallthrough -HandleTextBoxInput: ; 26da (0:26da) +RefreshMenuCursor: ; 26da (0:26da) ld hl, wCursorBlinkCounter ld a, [hl] inc [hl] @@ -4806,11 +5111,12 @@ DrawCursor: or a ret -Func_270b: ; 270b (0:270b) +; unlike DrawCursor, read cursor tile from wCursorTileNumber instead of register a +DrawCursor2: ; 270b (0:270b) ld a, [wCursorTileNumber] jr DrawCursor -Func_2710: ; 2710 (0:2710) +SetMenuItem: ; 2710 (0:2710) ld [wCurMenuItem], a ldh [hCurrentMenuItem], a xor a @@ -4829,7 +5135,7 @@ Func_271a: ; 271a (0:271a) xor $1 jr .asm_2748 .asm_272c - bit 5, b + bit D_LEFT_F, b jr z, .asm_273b ld a, [hl] sub $2 @@ -4838,7 +5144,7 @@ Func_271a: ; 271a (0:271a) add $4 jr .asm_2748 .asm_273b - bit 4, b + bit D_RIGHT_F, b jr z, .asm_275d ld a, [hl] add $2 @@ -4848,7 +5154,7 @@ Func_271a: ; 271a (0:271a) .asm_2748 push af ld a, $1 - call Func_3796 + call PlaySFX call .asm_2772 pop af ld [wCurMenuItem], a @@ -4859,7 +5165,7 @@ Func_271a: ; 271a (0:271a) .asm_275d ldh a, [hButtonsPressed2] and A_BUTTON - jp nz, Func_269e + jp nz, HandleMenuInput.A_pressed .asm_2764 ld hl, wCursorBlinkCounter ld a, [hl] @@ -4890,64 +5196,70 @@ Func_271a: ; 271a (0:271a) ret ; 0x278d -INCBIN "baserom.gbc",$278d,$29f5 - $278d + INCROM $278d, $29f5 Func_29f5: ; 29f5 (0:29f5) farcallx $6, $4000 ret ; 0x29fa -INCBIN "baserom.gbc",$29fa,$2a00 - $29fa - -Func_2a00: ; 2a00 (0:2a00) +Func_29fa: ; 29fa (0:29fa) + lb bc, $0f, $00 ; cursor tile, tile behind cursor + call SetCursorParametersForTextBox +WaitForButtonAorB: ; 2a00 (0:2a00) call DoFrame - call HandleTextBoxInput + call RefreshMenuCursor ldh a, [hButtonsPressed] bit A_BUTTON_F, a - jr nz, .asm_2a15 + jr nz, .a_pressed bit B_BUTTON_F, a - jr z, Func_2a00 + jr z, WaitForButtonAorB call EraseCursor scf ret -.asm_2a15 +.a_pressed call EraseCursor or a ret -Func_2a1a: ; 2a1a (0:2a1a) +SetCursorParametersForTextBox: ; 2a1a (0:2a1a) xor a ld hl, wCurMenuItem ld [hli], a - ld [hl], d + ld [hl], d ; wCursorXPosition inc hl - ld [hl], e + ld [hl], e ; wCursorYPosition inc hl - ld [hl], $0 + ld [hl], 0 ; wYDisplacementBetweenMenuItems inc hl - ld [hl], $1 + ld [hl], 1 ; wNumMenuItems inc hl - ld [hl], b + ld [hl], b ; wCursorTileNumber inc hl - ld [hl], c + ld [hl], c ; wTileBehindCursor ld [wCursorBlinkCounter], a ret ; 0x2a30 -INCBIN "baserom.gbc",$2a30,$2a36 - $2a30 +Func_2a30: ; 2a30 (0:2a30) + call DrawWideTextBox_PrintTextNoDelay + jp WaitForWideTextBoxInput +; 0x2a36 -Func_2a36: ; 2a36 (0:2a36) +DrawWideTextBox_PrintTextNoDelay: ; 2a36 (0:2a36) push hl call DrawWideTextBox ld a, $13 jr Func_2a44 -DrawNarrowTextBox_PrintText: ; 2a3e (0:2a3e) +DrawNarrowTextBox_PrintTextNoDelay: ; 2a3e (0:2a3e) push hl call DrawNarrowTextBox ld a, $b +; fallthrough + Func_2a44: ; 2a44 (0:2a44) - ld de, $010e + lb de, 1, 14 call AdjustCoordinatesForWindow call Func_22a6 pop hl @@ -4961,7 +5273,7 @@ DrawWideTextBox_PrintText: ; 2a59 (0:2a59) push hl call DrawWideTextBox ld a, $13 - ld de, $010e + lb de, 1, 14 call AdjustCoordinatesForWindow call Func_22a6 call EnableLCD @@ -4970,33 +5282,38 @@ DrawWideTextBox_PrintText: ; 2a59 (0:2a59) ; draws a 12x6 text box aligned to the bottom left of the screen DrawNarrowTextBox: ; 2a6f (0:2a6f) - ld de, $000c - ld bc, $0c06 + lb de, 0, 12 + lb bc, 12, 6 call AdjustCoordinatesForWindow call DrawRegularTextBox ret DrawNarrowTextBox_WaitForInput: ; 2a7c (0:2a7c) - call DrawNarrowTextBox_PrintText + call DrawNarrowTextBox_PrintTextNoDelay xor a ld hl, NarrowTextBoxPromptCursorData call InitializeCursorParameters call EnableLCD -.waitAorBLoop +.wait_A_or_B_loop call DoFrame - call HandleTextBoxInput + call RefreshMenuCursor ldh a, [hButtonsPressed] and A_BUTTON | B_BUTTON - jr z, .waitAorBLoop + jr z, .wait_A_or_B_loop ret NarrowTextBoxPromptCursorData: ; 2a96 (0:2a96) - db $a, $11, $1, $1, $2f, $1d, $0, $0 + db 10, 17 ; x, y + db 1 ; y displacement between items + db 1 ; number of items + db $2f ; cursor tile number + db $1d ; tile behind cursor + dw $0000 ; unknown function pointer if non-0 ; draws a 20x6 text box aligned to the bottom of the screen DrawWideTextBox: ; 2a9e (0:2a9e) - ld de, $000c - ld bc, $1406 + lb de, 0, 12 + lb bc, 20, 6 call AdjustCoordinatesForWindow call DrawRegularTextBox ret @@ -5009,88 +5326,121 @@ WaitForWideTextBoxInput: ; 2aae (0:2aae) ld hl, WideTextBoxPromptCursorData call InitializeCursorParameters call EnableLCD -.waitAorBLoop +.wait_A_or_B_loop call DoFrame - call HandleTextBoxInput + call RefreshMenuCursor ldh a, [hButtonsPressed] and A_BUTTON | B_BUTTON - jr z, .waitAorBLoop + jr z, .wait_A_or_B_loop call EraseCursor ret WideTextBoxPromptCursorData: ; 2ac8 (0:2ac8) - db $12, $11, $1, $1, $2f, $1d, $0, $0 + db 18, 17 ; x, y + db 1 ; y displacement between items + db 1 ; number of items + db $2f ; cursor tile number + db $1d ; tile behind cursor + dw $0000 ; unknown function pointer if non-0 + +TwoItemHorizontalMenu: ; 2ad0 (0:2ad0) + call DrawWideTextBox_PrintText + lb de, 6, 16 ; x, y + ld a, d + ld [wLeftmostItemCursorX], a + lb bc, $0f, $00 ; cursor tile, tile behind cursor + call SetCursorParametersForTextBox + ld a, 1 + ld [wCurMenuItem], a + call EnableLCD + jp HandleYesOrNoMenu.refresh_menu +; 0x2aeb -INCBIN "baserom.gbc",$2ad0,$2af0 - $2ad0 +Func_2aeb: ; 2aeb (0:2aeb) + ld a, $01 + ld [wcd9a], a +; fallthrough -Func_2af0: ; 2af0 (0:2af0) +; handle a yes / no menu with custom text provided in hl +; returns carry if "no" selected +YesOrNoMenuWithText: ; 2af0 (0:2af0) call DrawWideTextBox_PrintText - ld de, $0710 - call Func_2b66 - ld de, $0610 - jr .asm_2b0a - call DrawNarrowTextBox_PrintText - ld de, $0310 - call Func_2b66 - ld de, $0210 -.asm_2b0a +; fallthrough +YesOrNoMenu: ; 2af3 (0:2af3) + lb de, 7, 16 ; x, y + call PrintYesOrNoItems + lb de, 6, 16 ; x, y + jr HandleYesOrNoMenu + +YesOrNoMenuWithText_LeftAligned: ; 2afe (0:2afe) + call DrawNarrowTextBox_PrintTextNoDelay + lb de, 3, 16 ; x, y + call PrintYesOrNoItems + lb de, 2, 16 ; x, y +; fallthrough +HandleYesOrNoMenu: ld a, d - ld [wcd98], a - ld bc, $0f00 - call Func_2a1a + ld [wLeftmostItemCursorX], a + lb bc, $0f, $00 ; cursor tile, tile behind cursor + call SetCursorParametersForTextBox ld a, [wcd9a] ld [wCurMenuItem], a call EnableLCD - jr .asm_2b39 -.asm_2b1f + jr .refresh_menu +.wait_button_loop call DoFrame - call HandleTextBoxInput + call RefreshMenuCursor ldh a, [hButtonsPressed] bit A_BUTTON_F, a - jr nz, .asm_2b50 + jr nz, .a_pressed ldh a, [hButtonsPressed2] and D_RIGHT | D_LEFT - jr z, .asm_2b1f + jr z, .wait_button_loop + ; left or right pressed, so switch to the other menu item ld a, $1 - call Func_3796 + call PlaySFX call EraseCursor -.asm_2b39 - ld a, [wcd98] +.refresh_menu + ld a, [wLeftmostItemCursorX] ld c, a + ; default to the second option (NO) ld hl, wCurMenuItem ld a, [hl] xor $1 ld [hl], a + ; x separation between left and right items is 4 tiles add a add a add c ld [wCursorXPosition], a xor a ld [wCursorBlinkCounter], a - jr .asm_2b1f -.asm_2b50 + jr .wait_button_loop +.a_pressed ld a, [wCurMenuItem] ldh [hCurrentMenuItem], a or a - jr nz, .asm_2b5c - ld [wcd9a], a + jr nz, .no +;.yes + ld [wcd9a], a ; 0 ret -.asm_2b5c +.no xor a - ld [wcd9a], a + ld [wcd9a], a ; 0 ld a, $1 ldh [hCurrentMenuItem], a scf ret -Func_2b66: ; 2b66 (0:2b66) +; prints YES NO at de +PrintYesOrNoItems: ; 2b66 (0:2b66) call AdjustCoordinatesForWindow - text_hl YesOrNoText + ldtx hl, YesOrNoText call Func_2c1b ret ; 0x2b70 -INCBIN "baserom.gbc",$2b70,$2b78 - $2b70 + INCROM $2b70, $2b78 ; loads opponent deck to wOpponentDeck LoadOpponentDeck: ; 2b78 (0:2b78) @@ -5098,17 +5448,17 @@ LoadOpponentDeck: ; 2b78 (0:2b78) ld [wIsPracticeDuel], a ld a, [wOpponentDeckId] cp SAMS_NORMAL_DECK - 2 - jr z, .normalSamDuel + jr z, .normal_sam_duel or a ; cp SAMS_PRACTICE_DECK - 2 - jr nz, .notPracticeDuel + jr nz, .not_practice_duel ; only practice duels will display help messages, but ; any duel with Sam will force the PRACTICE_PLAYER_DECK -;.practiceSamDuel +;.practice_sam_duel inc a ld [wIsPracticeDuel], a -.normalSamDuel +.normal_sam_duel xor a ld [wOpponentDeckId], a call SwapTurn @@ -5122,17 +5472,17 @@ LoadOpponentDeck: ; 2b78 (0:2b78) ld [hl], a xor a -.notPracticeDuel +.not_practice_duel inc a inc a call LoadDeck ld a, [wOpponentDeckId] - cp NUMBER_OF_DECKS - jr c, .validDeck + cp DECKS_END + jr c, .valid_deck ld a, PRACTICE_PLAYER_DECK - 2 ld [wOpponentDeckId], a -.validDeck +.valid_deck ; set opponent as controlled by AI ld a, DUELVARS_DUELIST_TYPE call GetTurnDuelistVariable @@ -5235,17 +5585,17 @@ Func_2c29: ; 2c29 (0:2c29) ret ; 0x2c37 -INCBIN "baserom.gbc",$2c37,$2c73 - $2c37 + INCROM $2c37, $2c73 Func_2c73: ; 2c73 (0:2c73) xor a call Func_2c84 Func_2c77: ; 2c77 (0:2c77) - ld bc, $2f1d - ld de, $1211 - call Func_2a1a - call Func_2a00 + lb bc, $2f, $1d ; cursor tile, tile behind cursor + lb de, 18, 17 ; x, y + call SetCursorParametersForTextBox + call WaitForButtonAorB ret Func_2c84: ; 2c84 (0:2c84) @@ -5343,8 +5693,8 @@ Func_2d06: ; 2d06 (0:2d06) Func_2d15: ; 2d15 (0:2d15) push hl - ld de, $000c - ld bc, $1406 + lb de, 0, 12 + lb bc, 20, 6 call AdjustCoordinatesForWindow ld a, [wce4b] or a @@ -5359,7 +5709,7 @@ Func_2d15: ; 2d15 (0:2d15) ld l, a call DrawLabeledTextBox .asm_2d36 - ld de, $010e + lb de, 1, 14 call AdjustCoordinatesForWindow ld a, $13 call Func_22a6 @@ -5496,7 +5846,7 @@ Func_2e12: ; 2e12 (0:2e12) ld a, [wcd0a] or a jp z, Func_245d - ld de, $caa0 + ld de, wcaa0 push de call Func_0663 pop hl @@ -5511,15 +5861,15 @@ Func_2e12: ; 2e12 (0:2e12) ret Func_2e2c: ; 2e2c (0:2e2c) - ld de, $caa0 + ld de, wcaa0 push de ldh a, [hWhoseTurn] cp OPPONENT_TURN - jp z, .opponentTurn + jp z, .opponent_turn call PrintPlayerName pop hl ret -.opponentTurn +.opponent_turn call PrintOpponentName pop hl ret @@ -5528,38 +5878,38 @@ Func_2e2c: ; 2e2c (0:2e2c) PrintText: ; 2e41 (0:2e41) ld a, l or h - jr z, .fromRAM + jr z, .from_ram ldh a, [hBankROM] push af call ReadTextOffset - call .printText + call .print_text pop af call BankswitchHome ret -.fromRAM +.from_ram ld hl, wc590 -.printText +.print_text call Func_2cc8 -.nextTileLoop +.next_tile_loop ldh a, [hButtonsHeld] ld b, a ld a, [wTextSpeed] inc a cp $3 - jr nc, .applyDelay + jr nc, .apply_delay ; if text speed is 1, pressing b ignores it bit B_BUTTON_F, b - jr nz, .skipDelay - jr .applyDelay -.textDelayLoop + jr nz, .skip_delay + jr .apply_delay +.text_delay_loop ; wait a number of frames equal to wTextSpeed between printing each text tile call DoFrame -.applyDelay +.apply_delay dec a - jr nz, .textDelayLoop -.skipDelay + jr nz, .text_delay_loop +.skip_delay call Func_2d43 - jr nc, .nextTileLoop + jr nc, .next_tile_loop ret ; prints text with id at hl without letter delay in a textbox area @@ -5568,9 +5918,9 @@ PrintTextNoDelay: ; 2e76 (0:2e76) push af call ReadTextOffset call Func_2cc8 -.nextTileLoop +.next_tile_loop call Func_2d43 - jr nc, .nextTileLoop + jr nc, .next_tile_loop pop af call BankswitchHome ret @@ -5586,12 +5936,12 @@ PrintTextBoxBorderLabel: ; 2e89 (0:2e89) ldh a, [hBankROM] push af call ReadTextOffset -.nextTileLoop +.next_tile_loop ld a, [hli] ld [de], a inc de or a - jr nz, .nextTileLoop + jr nz, .next_tile_loop pop af call BankswitchHome dec de @@ -5603,7 +5953,7 @@ PrintTextBoxBorderLabel: ; 2e89 (0:2e89) jp PrintPlayerName ; 0x2ea9 -INCBIN "baserom.gbc",$2ea9,$2ebb - $2ea9 + INCROM $2ea9, $2ebb Func_2ebb: ; 2ebb (0:2ebb) ld a, l @@ -5620,7 +5970,7 @@ Func_2ec4: ; 2ec4 (0:2ec4) ret ; 0x2ecd -INCBIN "baserom.gbc",$2ecd,$2f0a - $2ecd + INCROM $2ecd, $2f0a ; load data of card with id at e to wLoadedCard1 or wLoadedCard2 LoadCardDataToBuffer2: ; 2f0a (0:2f0a) @@ -5642,12 +5992,12 @@ LoadCardDataToRAM: ; 2f14 (0:2f14) ld a, BANK(CardPointers) call BankpushHome2 ld b, PKMN_CARD_DATA_LENGTH -.copyCardDataLoop +.copy_card_data_loop ld a, [hli] ld [de], a inc de dec b - jr nz, .copyCardDataLoop + jr nz, .copy_card_data_loop call BankpopHome or a @@ -5696,7 +6046,7 @@ GetCardHeader: ; 2f5d (0:2f5d) ld d, $00 ld e, a call GetCardPointer - jr c, .cardNotFound + jr c, .card_not_found ld a, $0c call BankpushHome2 ld e, [hl] @@ -5708,7 +6058,7 @@ GetCardHeader: ; 2f5d (0:2f5d) call BankpopHome ld a, e or a -.cardNotFound +.card_not_found pop de pop hl ret @@ -5730,7 +6080,7 @@ GetCardPointer: ; 2f7c (0:2f7c) cp a, (CardPointers + 2 + (2 * NUM_CARDS)) % $100 .nz ccf - jr c, .outOfBounds + jr c, .out_of_bounds ld a, BANK(CardPointers) call BankpushHome2 ld a, [hli] @@ -5738,7 +6088,7 @@ GetCardPointer: ; 2f7c (0:2f7c) ld l,a call BankpopHome or a -.outOfBounds +.out_of_bounds pop bc pop de ret @@ -5762,12 +6112,12 @@ LoadCardGfx: ; 2fa0 (0:2fa0) call CopyGfxData ld b, $8 ; length of palette ld de, $ce23 -.copyCardPalette +.copy_card_palette ld a, [hli] ld [de], a inc de dec b - jr nz, .copyCardPalette + jr nz, .copy_card_palette pop af call BankswitchHome ret @@ -5794,12 +6144,12 @@ TryExecuteEffectCommandFunction: ; 2fd9 (0:2fd9) ld l, a pop af call CheckMatchingCommand - jr nc, .executeFunction + jr nc, .execute_function ; return if no matching command was found or a ret -.executeFunction +.execute_function ; executes the function at [wce22]:hl ldh a, [hBankROM] push af @@ -5824,12 +6174,12 @@ CheckMatchingCommand: ; 2ffe (0:2ffe) ld c, a ld a, l or h - jr nz, .notNullPointer + jr nz, .not_null_pointer ; return c if pointer is $0000 scf ret -.notNullPointer +.not_null_pointer ldh a, [hBankROM] push af ld a, BANK(EffectCommands) @@ -5837,18 +6187,18 @@ CheckMatchingCommand: ; 2ffe (0:2ffe) ; store the bank number of command functions ($b) in wce22 ld a, $b ld [wce22],a -.checkCommandLoop +.check_command_loop ld a, [hli] or a - jr z, .noMoreCommands + jr z, .no_more_commands cp c - jr z, .matchingCommandFound + jr z, .matching_command_found ; skip function pointer for this command and move to the next one inc hl inc hl - jr .checkCommandLoop + jr .check_command_loop -.matchingCommandFound +.matching_command_found ; load function pointer for this command ld a, [hli] ld h, [hl] @@ -5859,7 +6209,7 @@ CheckMatchingCommand: ; 2ffe (0:2ffe) or a ret ; restore bank and return c -.noMoreCommands +.no_more_commands pop af call BankswitchHome scf @@ -5883,14 +6233,14 @@ LoadDeck: ; 302c (0:302c) ld d, [hl] ld a, d or e - jr z, .nullPointer + jr z, .null_pointer call CopyDeckData pop af call BankswitchHome pop hl or a ret -.nullPointer +.null_pointer pop af call BankswitchHome pop hl @@ -6262,19 +6612,19 @@ HandleDamageReduction: ; 3244 (0:3244) or a ret z cp SUBSTATUS2_REDUCE_BY_20 - jr z, .reduceDamageBy20 + jr z, .reduce_damage_by_20 cp SUBSTATUS2_POUNCE - jr z, .reduceDamageBy10 + jr z, .reduce_damage_by_10 cp SUBSTATUS2_GROWL - jr z, .reduceDamageBy10 + jr z, .reduce_damage_by_10 ret -.reduceDamageBy20 +.reduce_damage_by_20 ld hl, -20 add hl, de ld e, l ld d, h ret -.reduceDamageBy10 +.reduce_damage_by_10 ld hl, -10 add hl, de ld e, l @@ -6284,28 +6634,28 @@ HandleDamageReduction: ; 3244 (0:3244) HandleDamageReductionExceptSubstatus2: ; 3269 (0:3269) ld a, [wNoDamageOrEffect] or a - jr nz, .noDamage + jr nz, .no_damage ld a, DUELVARS_ARENA_CARD_SUBSTATUS1 call GetTurnDuelistVariable or a - jr z, .notAffectedBySubstatus1 + jr z, .not_affected_by_substatus1 cp SUBSTATUS1_NO_DAMAGE_STIFFEN - jr z, .noDamage + jr z, .no_damage cp SUBSTATUS1_NO_DAMAGE_10 - jr z, .noDamage + jr z, .no_damage cp SUBSTATUS1_NO_DAMAGE_11 - jr z, .noDamage + jr z, .no_damage cp SUBSTATUS1_NO_DAMAGE_17 - jr z, .noDamage + jr z, .no_damage cp SUBSTATUS1_REDUCE_BY_10 - jr z, .reduceDamageBy10 + jr z, .reduce_damage_by_10 cp SUBSTATUS1_REDUCE_BY_20 - jr z, .reduceDamageBy20 + jr z, .reduce_damage_by_20 cp SUBSTATUS1_HARDEN - jr z, .preventLessThan40Damage + jr z, .prevent_less_than_40_damage cp SUBSTATUS1_HALVE_DAMAGE - jr z, .halveDamage -.notAffectedBySubstatus1 + jr z, .halve_damage +.not_affected_by_substatus1 call CheckIfUnderAnyCannotUseStatus ret c ld a, [wLoadedMoveCategory] @@ -6313,32 +6663,32 @@ HandleDamageReductionExceptSubstatus2: ; 3269 (0:3269) ret z ld a, [wTempNonTurnDuelistCardId] cp MR_MIME - jr z, .preventLessThan30Damage ; invisible wall + jr z, .prevent_less_than_30_damage ; invisible wall cp KABUTO - jr z, .halveDamage2 ; kabuto armor + jr z, .halve_damage2 ; kabuto armor ret -.noDamage +.no_damage ld de, 0 ret -.reduceDamageBy10 +.reduce_damage_by_10 ld hl, -10 add hl, de ld e, l ld d, h ret -.reduceDamageBy20 +.reduce_damage_by_20 ld hl, -20 add hl, de ld e, l ld d, h ret -.preventLessThan40Damage +.prevent_less_than_40_damage ld bc, 40 call CompareDEtoBC ret nc ld de, 0 ret -.halveDamage +.halve_damage sla d rr e bit 0, e @@ -6348,7 +6698,7 @@ HandleDamageReductionExceptSubstatus2: ; 3269 (0:3269) ld e, l ld d, h ret -.preventLessThan30Damage +.prevent_less_than_30_damage ld a, [wLoadedMoveCategory] cp POKEMON_POWER ret z @@ -6357,7 +6707,7 @@ HandleDamageReductionExceptSubstatus2: ; 3269 (0:3269) ret c ld de, 0 ret -.halveDamage2 +.halve_damage2 sla d rr e bit 0, e @@ -6369,7 +6719,7 @@ HandleDamageReductionExceptSubstatus2: ; 3269 (0:3269) ret ; 0x32f7 -INCBIN "baserom.gbc",$32f7,$33c1 - $32f7 + INCROM $32f7, $33c1 ; return carry if card is under a condition that makes it unable to attack ; also return in hl the text id to be displayed @@ -6378,18 +6728,18 @@ HandleCantAttackSubstatus: ; 33c1 (0:33c1) call GetTurnDuelistVariable or a ret z - text_hl UnableToAttackDueToTailWagText + ldtx hl, UnableToAttackDueToTailWagText cp SUBSTATUS2_TAIL_WAG - jr z, .returnWithCantAttack - text_hl UnableToAttackDueToLeerText + jr z, .return_with_cant_attack + ldtx hl, UnableToAttackDueToLeerText cp SUBSTATUS2_LEER - jr z, .returnWithCantAttack - text_hl UnableToAttackDueToBoneAttackText + jr z, .return_with_cant_attack + ldtx hl, UnableToAttackDueToBoneAttackText cp SUBSTATUS2_BONE_ATTACK - jr z, .returnWithCantAttack + jr z, .return_with_cant_attack or a ret -.returnWithCantAttack +.return_with_cant_attack scf ret @@ -6398,12 +6748,12 @@ HandleAmnesiaSubstatus: ; 33e1 (0:33e1) ld a, DUELVARS_ARENA_CARD_SUBSTATUS2 call GetTurnDuelistVariable or a - jr nz, .checkAmnesia + jr nz, .check_amnesia ret -.checkAmnesia +.check_amnesia cp SUBSTATUS2_AMNESIA jr z, .affectedByAmnesia -.notTheMoveDisabledByAmnesia +.not_the_disabled_move or a ret .affectedByAmnesia @@ -6411,8 +6761,8 @@ HandleAmnesiaSubstatus: ; 33e1 (0:33e1) call GetTurnDuelistVariable ld a, [wSelectedMoveIndex] cp [hl] - jr nz, .notTheMoveDisabledByAmnesia - text_hl UnableToUseAttackDueToAmnesiaText + jr nz, .not_the_disabled_move + ldtx hl, UnableToUseAttackDueToAmnesiaText scf ret @@ -6424,7 +6774,7 @@ HandleSandAttackOrSmokescreenSubstatus: ; 3400 (0:3400) ld [wcc0a], a ccf ret nc - text_hl AttackUnsuccessfulText + ldtx hl, AttackUnsuccessfulText call DrawWideTextBox_WaitForInput scf ret @@ -6435,15 +6785,15 @@ CheckSandAttackOrSmokescreenSubstatus: ; 3414 (0:3414) call GetTurnDuelistVariable or a ret z - text_de SandAttackCheckText + ldtx de, SandAttackCheckText cp SUBSTATUS2_SAND_ATTACK - jr z, .cardIsAffected - text_de SmokescreenCheckText + jr z, .card_is_affected + ldtx de, SmokescreenCheckText cp SUBSTATUS2_SMOKESCREEN - jr z, .cardIsAffected + jr z, .card_is_affected or a ret -.cardIsAffected +.card_is_affected ld a, [wcc0a] or a ret nz @@ -6462,31 +6812,31 @@ HandleNoDamageOrEffectSubstatus: ; 3432 (0:3432) ld a, DUELVARS_ARENA_CARD_SUBSTATUS1 call GetTurnDuelistVariable ld e, NO_DAMAGE_OR_EFFECT_FLY - text_hl NoDamageOrEffectDueToFlyText + ldtx hl, NoDamageOrEffectDueToFlyText cp SUBSTATUS1_FLY - jr z, .noDamageOrEffect + jr z, .no_damage_or_effect ld e, NO_DAMAGE_OR_EFFECT_BARRIER - text_hl NoDamageOrEffectDueToBarrierText + ldtx hl, NoDamageOrEffectDueToBarrierText cp SUBSTATUS1_BARRIER - jr z, .noDamageOrEffect + jr z, .no_damage_or_effect ld e, NO_DAMAGE_OR_EFFECT_AGILITY - text_hl NoDamageOrEffectDueToAgilityText + ldtx hl, NoDamageOrEffectDueToAgilityText cp SUBSTATUS1_AGILITY - jr z, .noDamageOrEffect + jr z, .no_damage_or_effect call CheckIfUnderAnyCannotUseStatus ccf ret nc ld a, [wTempNonTurnDuelistCardId] cp MEW1 - jr z, .neutralizingShield + jr z, .neutralizing_shield or a ret -.noDamageOrEffect +.no_damage_or_effect ld a, e ld [wNoDamageOrEffect], a scf ret -.neutralizingShield +.neutralizing_shield ld a, [wcce6] or a ret nz @@ -6498,8 +6848,8 @@ HandleNoDamageOrEffectSubstatus: ; 3432 (0:3432) or a ret z ld e, NO_DAMAGE_OR_EFFECT_NSHIELD - text_hl NoDamageOrEffectDueToNShieldText - jr .noDamageOrEffect + ldtx hl, NoDamageOrEffectDueToNShieldText + jr .no_damage_or_effect ; if the Pokemon being attacked is Haunter1, and its Transparency is active, ; there is a 50% chance that any damage or effect is prevented @@ -6519,12 +6869,12 @@ HandleTransparency: ; 348a (0:348a) jr c, .asm_3491 xor a ld [wcac2], a - text_de TransparencyCheckText + ldtx de, TransparencyCheckText call TossCoin ret nc ld a, NO_DAMAGE_OR_EFFECT_TRANSPARENCY ld [wNoDamageOrEffect], a - text_hl NoDamageOrEffectDueToTransparencyText + ldtx hl, NoDamageOrEffectDueToTransparencyText scf ret ; 0x34b7 @@ -6536,7 +6886,7 @@ CheckNoDamageOrEffect: ; 34b7 (0:34b7) or a ret z bit 7, a - jr nz, .dontPrintText ; already been here so don't repeat the text + jr nz, .dont_print_text ; already been here so don't repeat the text ld hl, wNoDamageOrEffect set 7, [hl] dec a @@ -6551,7 +6901,7 @@ CheckNoDamageOrEffect: ; 34b7 (0:34b7) scf ret -.dontPrintText +.dont_print_text ld hl, $0000 scf ret @@ -6582,17 +6932,17 @@ CheckIfUnderAnyCannotUseStatus: ; 34ef (0:34ef) ; same as above, but if a is non-0, only toxic gas is checked CheckIfUnderAnyCannotUseStatus2: ; 34f0 (0:34f0) or a - jr nz, .checkToxicGas + jr nz, .check_toxic_gas ld a, DUELVARS_ARENA_CARD_STATUS call GetTurnDuelistVariable and PASSIVE_STATUS_MASK - text_hl CannotUseDueToStatusText + ldtx hl, CannotUseDueToStatusText scf jr nz, .done ; return carry -.checkToxicGas +.check_toxic_gas ld a, MUK call Func_3509 - text_hl UnableDueToToxicGasText + ldtx hl, UnableDueToToxicGasText .done ret @@ -6661,7 +7011,7 @@ Func_3525: ; 3525 (0:3525) ret ; 0x356a -INCBIN "baserom.gbc",$356a,$35e6 - $356a + INCROM $356a, $35e6 ; if swords dance or focus energy was used this turn, ; mark that the base power of the next turn's attack has to be doubled @@ -6697,7 +7047,7 @@ UpdateSubstatusConditions: ; 35fa (0:35fa) ret ; 0x3615 -INCBIN "baserom.gbc",$3615,$363b - $3615 + INCROM $3615, $363b ; if the target card's HP is 0 and the attacking card's HP is not, ; the attacking card faints if it was affected by destiny bond @@ -6705,10 +7055,10 @@ HandleDestinyBondSubstatus: ; 363b (0:363b) ld a, DUELVARS_ARENA_CARD_SUBSTATUS1 call GetNonTurnDuelistVariable cp SUBSTATUS1_DESTINY_BOND - jr z, .checkHP + jr z, .check_hp ret -.checkHP +.check_hp ld a, DUELVARS_ARENA_CARD call GetNonTurnDuelistVariable cp $ff @@ -6734,7 +7084,7 @@ HandleDestinyBondSubstatus: ; 363b (0:363b) ld h, [hl] ld l, a call Func_2ebb - text_hl KnockedOutDueToDestinyBondText + ldtx hl, KnockedOutDueToDestinyBondText call DrawWideTextBox_WaitForInput ret ; 0x367b @@ -6744,9 +7094,9 @@ HandleDestinyBondSubstatus: ; 363b (0:363b) HandleStrikesBack: ; 367b (0:367b) ld a, [wTempNonTurnDuelistCardId] cp MACHAMP - jr z, .strikesBack + jr z, .strikes_back ret -.strikesBack +.strikes_back ld a, [wLoadedMoveCategory] and RESIDUAL ret nz @@ -6780,7 +7130,7 @@ ApplyStrikesBack: ; 36a2 (0:36a2) push af push hl call SubstractHP - text_hl ReceivesDamageDueToStrikesBackText + ldtx hl, ReceivesDamageDueToStrikesBackText call DrawWideTextBox_PrintText pop hl pop af @@ -6794,7 +7144,7 @@ ApplyStrikesBack: ; 36a2 (0:36a2) ret ; 0x36d9 -INCBIN "baserom.gbc",$36d9,$36f6 - $36d9 + INCROM $36d9, $36f6 Func_36f6: ; 36f6 (0:36f6) xor a @@ -6833,7 +7183,7 @@ Func_36f7: ; 36f7 (0:36f7) ret ; 0x3729 -INCBIN "baserom.gbc",$3729,$3730 - $3729 + INCROM $3729, $3730 Func_3730: ; 3730 (0:3730) ld a, DUELVARS_ARENA_CARD_SUBSTATUS3 @@ -6847,7 +7197,7 @@ Func_3730: ; 3730 (0:3730) ret ; 0x3743 -INCBIN "baserom.gbc",$3743,$374a - $3743 + INCROM $3743, $374a Func_374a: ; 374a (0:374a) ld a, DUELVARS_ARENA_CARD_SUBSTATUS4 @@ -6876,23 +7226,23 @@ HandleEnergyBurn: ; 375d (0:375d) ld hl, wAttachedEnergies ld c, COLORLESS - FIRE xor a -.zeroNextEnergy +.zero_next_energy ld [hli], a dec c - jr nz, .zeroNextEnergy + jr nz, .zero_next_energy ld a, [wTotalAttachedEnergies] ld [wAttachedEnergies], a ret ; 0x377f -SetupSound_T: ; 377f (0:377f) - farcall SetupSound_Ext +SetupSound: ; 377f (0:377f) + farcall _SetupSound ret Func_3784: ; 3784 (0:3784) xor a PlaySong: ; 3785 (0:3785) - farcall Func_f4006 + farcall _PlaySong ret Func_378a: ; 378a (0:378a) @@ -6905,8 +7255,8 @@ Func_378f: ; 378f (0:378f) Func_3794: ; 3794 (0:3794) ld a, $04 -Func_3796: ; 3796 (0:3796) - farcall Func_f4009 +PlaySFX: ; 3796 (0:3796) + farcall _PlaySFX ret Func_379b: ; 379b (0:379b) @@ -6918,7 +7268,7 @@ Func_37a0: ; 37a0 (0:37a0) ret ; 0x37a5 -INCBIN "baserom.gbc",$37a5,$380e - $37a5 + INCROM $37a5, $380e Func_380e: ; 380e (0:380e) ld a, [wd0c1] @@ -7079,7 +7429,7 @@ GetFloorObjectFromPos: ; 3927 (0:3927) ret ; 0x392e -INCBIN "baserom.gbc",$392e,$3946 - $392e + INCROM $392e, $3946 ; puts a floor tile in hc given coords in bc (x,y. measured in tiles) FindFloorTileFromPos: ; 3946 (0:3946) @@ -7108,7 +7458,7 @@ Func_395a: ; 395a (0:395a) ret Unknown_396b: ; 396b (0:396b) -INCBIN "baserom.gbc",$396b,$3973 - $396b + INCROM $396b, $3973 ; Movement offsets for scripted movements ScriptedMovementOffsetTable: ; 3973 (0:3973) @@ -7118,7 +7468,7 @@ ScriptedMovementOffsetTable: ; 3973 (0:3973) db -$02, $00 ; move 2 tiles left Unknown_397b: ; 397b (0:397b) -INCBIN "baserom.gbc",$397b,$3997 - $397b + INCROM $397b, $3997 Func_3997: ; 3997 (0:3997) ldh a, [hBankROM] @@ -7186,7 +7536,7 @@ Func_39c3: ; 39c3 (0:39c3) ret ; 0x39ea -INCBIN "baserom.gbc",$39ea,$39fc - $39ea + INCROM $39ea, $39fc Func_39fc: ; 39fc (0:39fc) push hl @@ -7239,7 +7589,7 @@ Func_3a40: ; 3a40 (0:3a40) ret ; 0x3a45 -INCBIN "baserom.gbc",$3a45,$3a5e - $3a45 + INCROM $3a45, $3a5e Func_3a5e: ; 3a5e (0:3a5e) ldh a, [hBankROM] @@ -7333,7 +7683,7 @@ Func_3abd: ; 3abd (0:3abd) ret ; 0x3ae8 -INCBIN "baserom.gbc",$3ae8,$3aed - $3ae8 + INCROM $3ae8, $3aed ; finds an OWScript from the first byte and puts the next two bytes (usually arguments?) into cb RunOverworldScript: ; 3aed (0:3aed) @@ -7364,7 +7714,7 @@ RunOverworldScript: ; 3aed (0:3aed) jp hl ; 0x3b11 -INCBIN "baserom.gbc",$3b11,$3b21 - $3b11 + INCROM $3b11, $3b21 Func_3b21: ; 3b21 (0:3b21) ldh a, [hBankROM] @@ -7446,7 +7796,7 @@ Func_3b6a: ; 3b6a (0:3b6a) ret ; 0x3ba2 -INCBIN "baserom.gbc",$3ba2,$3bd2 - $3ba2 + INCROM $3ba2, $3bd2 ; writes from hl the pointer to the function to be called by DoFrame SetDoFrameFunction: ; 3bd2 (0:3bd2) @@ -7464,7 +7814,7 @@ ResetDoFrameFunction: ; 3bdb (0:3bdb) ret ; 0x3be4 -INCBIN "baserom.gbc",$3be4,$3bf5 - $3be4 + INCROM $3be4, $3bf5 Func_3bf5: ; 3bf5 (0:3bf5) ldh a, [hBankROM] @@ -7476,25 +7826,25 @@ Func_3bf5: ; 3bf5 (0:3bf5) ld l, a ld a, [wd4c5] ld h, a - call CopyData_SaveRegisters + call CopyDataHLtoDE_SaveRegisters pop hl pop af call BankswitchHome ret ; 0x3c10 -INCBIN "baserom.gbc",$3c10,$3c45 - $3c10 + INCROM $3c10, $3c45 Func_3c45: ; 3c45 (0:3c45) jp hl ; 0x3c46 -INCBIN "baserom.gbc",$3c46,$3c48 - $3c46 + INCROM $3c46, $3c48 DoFrameIfLCDEnabled: ; 3c48 (0:3c48) push af ld a, [rLCDC] - bit 7, a + bit rLCDC_ENABLE, a jr z, .done push bc push de @@ -7544,7 +7894,7 @@ Func_3c83: ; 3c83 (0:3c83) ret ; 0x3c87 -INCBIN "baserom.gbc",$3c87,$3c96 - $3c87 + INCROM $3c87, $3c96 Func_3c96: ; 3c96 (0:3c96) call DoFrameIfLCDEnabled @@ -7578,7 +7928,7 @@ Func_3cb4: ; 3cb4 (0:3cb4) ret ; 0x3cc4 -INCBIN "baserom.gbc",$3cc4,$3d72 - $3cc4 + INCROM $3cc4, $3d72 Func_3d72: ; 3d72 (0:3d72) ldh a, [hBankROM] @@ -7657,7 +8007,7 @@ ModifyUnknownOAMBufferProperty: ; 3dbf (0:3dbf) ret ; 0x3ddb -INCBIN "baserom.gbc",$3ddb,$3df3 - $3ddb + INCROM $3ddb, $3df3 Func_3df3: ; 3df3 (0:3df3) push af @@ -7678,8 +8028,10 @@ Func_3df3: ; 3df3 (0:3df3) ret ; 0x3e10 -INCBIN "baserom.gbc",$3e10,$3e17 - $3e10 - +Func_3e10: ; 3e10 (0:3e10) + ld a, $1 + ld [wd61e], a + ld a, $62 Func_3e17: ; 3e17 (0:3e17) ld [wd131], a ldh a, [hBankROM] @@ -7697,7 +8049,7 @@ Func_3e2a: ; 3e2a (0:3e2a) jr Func_3e17 ; 0x3e31 -INCBIN "baserom.gbc",$3e31,$3fe0 - $3e31 + INCROM $3e31, $3fe0 ; jumps to 3f:hl Bankswitch3dTo3f:: ; 3fe0 (0:3fe0) @@ -7717,5 +8069,5 @@ Bankswitch3d: ; 3fe0 (0:3fe0) ret rept $a -db $ff + db $ff endr |
