From b50dd57cbb8e163cd269255c8f754e5631760a03 Mon Sep 17 00:00:00 2001 From: Rangi Date: Thu, 23 Apr 2020 16:10:46 -0400 Subject: [PATCH] Miscellaneous updates and corrections --- audio/sfx.asm | 2 +- docs/design_flaws.md | 2 +- engine/battle/core.asm | 50 +++++++++++++++++++++++------------------- macros/code.asm | 2 +- macros/wram.asm | 1 + sram.asm | 4 +--- wram.asm | 12 +++++----- 7 files changed, 38 insertions(+), 35 deletions(-) diff --git a/audio/sfx.asm b/audio/sfx.asm index 32a336126..670b987a8 100644 --- a/audio/sfx.asm +++ b/audio/sfx.asm @@ -3327,7 +3327,7 @@ Sfx_DexFanfare170199_Ch8: note B_, 16 sound_ret - db $fd + db sound_loop_cmd Sfx_DexFanfare200229: channel_count 4 diff --git a/docs/design_flaws.md b/docs/design_flaws.md index 945c2ff75..620e5b8af 100644 --- a/docs/design_flaws.md +++ b/docs/design_flaws.md @@ -617,7 +617,7 @@ And edit [engine/pokegear/radio.asm](https://github.com/pret/pokecrystal/blob/ma add hl, bc add hl, bc + add hl, bc -+ b = bank ++ ; b = bank + ld a, BANK(PokedexDataPointerTable) + call GetFarByte + ld b, a diff --git a/engine/battle/core.asm b/engine/battle/core.asm index f8d99b24e..4d561c7ae 100644 --- a/engine/battle/core.asm +++ b/engine/battle/core.asm @@ -6219,7 +6219,7 @@ LoadEnemyMon: ; Fill stats ld de, wEnemyMonMaxHP ld b, FALSE - ld hl, wEnemyMonDVs - (MON_DVS - MON_STAT_EXP + 1) ; wLinkBattleRNs + 7 ; ? + ld hl, wEnemyMonDVs - (MON_DVS - MON_STAT_EXP + 1) predef CalcMonStats ; If we're in a trainer battle, @@ -8401,7 +8401,7 @@ DisplayLinkBattleResult: ld a, BANK(sLinkBattleStats) call GetSRAMBank - call AddLastMobileBattleToLinkRecord + call AddLastLinkBattleToLinkRecord call ReadAndPrintLinkBattleRecord call CloseSRAM @@ -8442,6 +8442,9 @@ IsMobileBattle2: cp LINK_MOBILE ret +LINK_BATTLE_RECORD_LENGTH EQUS "(sLinkBattleRecord1End - sLinkBattleRecord1)" ; 18 +NUM_LINK_BATTLE_RECORDS EQUS "((sLinkBattleStatsEnd - sLinkBattleRecord) / LINK_BATTLE_RECORD_LENGTH)" ; 5 + _DisplayLinkRecord: ld a, BANK(sLinkBattleStats) call GetSRAMBank @@ -8467,7 +8470,7 @@ ReadAndPrintLinkBattleRecord: call ClearSprites call .PrintBattleRecord hlcoord 0, 8 - ld b, 5 + ld b, NUM_LINK_BATTLE_RECORDS ld de, sLinkBattleRecord + 2 .loop push bc @@ -8484,7 +8487,7 @@ ReadAndPrintLinkBattleRecord: ld h, d ld l, e ld de, wd002 - ld bc, 10 + ld bc, NAME_LENGTH - 1 call CopyBytes ld a, "@" ld [de], a @@ -8521,7 +8524,7 @@ ReadAndPrintLinkBattleRecord: call PlaceString .next pop hl - ld bc, 18 + ld bc, LINK_BATTLE_RECORD_LENGTH add hl, bc ld d, h ld e, l @@ -8694,7 +8697,7 @@ GetRoamMonSpecies: ld hl, wRoamMon3Species ret -AddLastMobileBattleToLinkRecord: +AddLastLinkBattleToLinkRecord: ld hl, wOTPlayerID ld de, wStringBuffer1 ld bc, 2 @@ -8702,10 +8705,10 @@ AddLastMobileBattleToLinkRecord: ld hl, wOTPlayerName ld bc, NAME_LENGTH - 1 call CopyBytes - ld hl, sLinkBattleResults + ld hl, sLinkBattleStats - (LINK_BATTLE_RECORD_LENGTH - 6) call .StoreResult ld hl, sLinkBattleRecord - ld d, 5 + ld d, NUM_LINK_BATTLE_RECORDS .loop push hl inc hl @@ -8716,17 +8719,17 @@ AddLastMobileBattleToLinkRecord: and a jr z, .copy push de - ld bc, 12 + ld bc, LINK_BATTLE_RECORD_LENGTH - 6 ld de, wStringBuffer1 call CompareBytesLong pop de pop hl jr c, .done - ld bc, 18 + ld bc, LINK_BATTLE_RECORD_LENGTH add hl, bc dec d jr nz, .loop - ld bc, -18 + ld bc, -LINK_BATTLE_RECORD_LENGTH add hl, bc push hl @@ -8734,7 +8737,7 @@ AddLastMobileBattleToLinkRecord: ld d, h ld e, l ld hl, wStringBuffer1 - ld bc, 12 + ld bc, LINK_BATTLE_RECORD_LENGTH - 6 call CopyBytes ld b, 6 xor a @@ -8749,16 +8752,17 @@ AddLastMobileBattleToLinkRecord: call .StoreResult call .FindOpponentAndAppendRecord ret + .StoreResult: ld a, [wBattleResult] and $f cp LOSE - ld bc, sLinkBattleWins + 1 - sLinkBattleResults + ld bc, (sLinkBattleRecord1Wins - sLinkBattleRecord1) + 1 jr c, .okay ; WIN - ld bc, sLinkBattleLosses + 1 - sLinkBattleResults + ld bc, (sLinkBattleRecord1Losses - sLinkBattleRecord1) + 1 jr z, .okay ; LOSE ; DRAW - ld bc, sLinkBattleDraws + 1 - sLinkBattleResults + ld bc, (sLinkBattleRecord1Draws - sLinkBattleRecord1) + 1 .okay add hl, bc call .CheckOverflow @@ -8780,8 +8784,8 @@ AddLastMobileBattleToLinkRecord: ret .FindOpponentAndAppendRecord: - ld b, 5 - ld hl, sLinkBattleRecord + 17 + ld b, NUM_LINK_BATTLE_RECORDS + ld hl, sLinkBattleRecord1End - 1 ld de, wd002 .loop3 push bc @@ -8799,7 +8803,7 @@ AddLastMobileBattleToLinkRecord: ld a, c ld [de], a inc de - ld bc, 18 + ld bc, LINK_BATTLE_RECORD_LENGTH add hl, bc pop bc dec b @@ -8848,26 +8852,26 @@ AddLastMobileBattleToLinkRecord: .done2 push bc ld a, b - ld bc, 18 + ld bc, LINK_BATTLE_RECORD_LENGTH ld hl, sLinkBattleRecord call AddNTimes push hl ld de, wd002 - ld bc, 18 + ld bc, LINK_BATTLE_RECORD_LENGTH call CopyBytes pop hl pop bc push hl ld a, c - ld bc, 18 + ld bc, LINK_BATTLE_RECORD_LENGTH ld hl, sLinkBattleRecord call AddNTimes pop de push hl - ld bc, 18 + ld bc, LINK_BATTLE_RECORD_LENGTH call CopyBytes ld hl, wd002 - ld bc, 18 + ld bc, LINK_BATTLE_RECORD_LENGTH pop de call CopyBytes ret diff --git a/macros/code.asm b/macros/code.asm index 58d39aa00..c92e7132f 100644 --- a/macros/code.asm +++ b/macros/code.asm @@ -51,7 +51,7 @@ calc_sine_wave: MACRO ; input: a = a signed 6-bit value ; output: a = d * sin(a * pi/32) and %111111 - cp %100000 + cp %100000 jr nc, .negative\@ call .apply\@ ld a, h diff --git a/macros/wram.asm b/macros/wram.asm index abc7df48e..abaa7daaf 100644 --- a/macros/wram.asm +++ b/macros/wram.asm @@ -238,6 +238,7 @@ link_battle_record: MACRO \1Wins:: dw \1Losses:: dw \1Draws:: dw +\1End:: ENDM trademon: MACRO diff --git a/sram.asm b/sram.asm index d7c1ece75..0cffb005b 100644 --- a/sram.asm +++ b/sram.asm @@ -125,13 +125,11 @@ SECTION "Active Box", SRAM sBox:: box sBox ; b160 - ds $f4 + ds $100 SECTION "Link Battle Data", SRAM -sLinkBattleResults:: ds $c - sLinkBattleStats:: sLinkBattleWins:: dw ; b260 sLinkBattleLosses:: dw ; b262 diff --git a/wram.asm b/wram.asm index 6274cb02d..022b06353 100644 --- a/wram.asm +++ b/wram.asm @@ -2851,15 +2851,15 @@ wCurMapData:: wVisitedSpawns:: flag_array NUM_SPAWNS ; dca5 -wDigWarpNumber:: db ; dcaa -wDigMapGroup:: db ; dcab -wDigMapNumber:: db ; dcac +wDigWarpNumber:: db ; dca9 +wDigMapGroup:: db ; dcaa +wDigMapNumber:: db ; dcab ; used on maps like second floor pokécenter, which are reused, so we know which ; map to return to -wBackupWarpNumber:: db ; dcad -wBackupMapGroup:: db ; dcae -wBackupMapNumber:: db ; dcaf +wBackupWarpNumber:: db ; dcac +wBackupMapGroup:: db ; dcad +wBackupMapNumber:: db ; dcae ds 3