ref: 38cdad798dbae4a2820f4d4e61bc5b782e70ef47
parent: 2d3a94b7c4ba033bdbfa382611a18b71a68349d4
parent: 8a3c44fad3a1d3c4f6b65f34d4e17d9359969177
author: Rangi <[email protected]>
date: Thu Apr 23 12:35:47 EDT 2020
Merge pull request #714 from Rangi42/master Miscellaneous updates and corrections
--- a/audio/sfx.asm
+++ b/audio/sfx.asm
@@ -1057,7 +1057,7 @@
rest 8
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_RegisterPhoneNumber_Ch6:
toggle_sfx
@@ -1081,7 +1081,7 @@
rest 8
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_RegisterPhoneNumber_Ch7:
toggle_sfx
@@ -1102,7 +1102,7 @@
rest 8
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_RegisterPhoneNumber_Ch8:
toggle_sfx
@@ -1113,7 +1113,7 @@
rest 16
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_3rdPlace:
channel_count 3
@@ -1138,7 +1138,7 @@
note D_, 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_3rdPlace_Ch6:
toggle_sfx
@@ -1155,7 +1155,7 @@
note G_, 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_3rdPlace_Ch7:
toggle_sfx
@@ -1172,7 +1172,7 @@
note B_, 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetEgg:
channel_count 4
@@ -1211,7 +1211,7 @@
rest 9
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetEgg_Ch6:
toggle_sfx
@@ -1240,7 +1240,7 @@
rest 9
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetEgg_Ch7:
toggle_sfx
@@ -1259,7 +1259,7 @@
rest 9
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetEgg_Ch8:
toggle_sfx
@@ -1271,7 +1271,7 @@
rest 12
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_MoveDeleted:
channel_count 4
@@ -1308,7 +1308,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_MoveDeleted_Ch6:
toggle_sfx
@@ -1344,7 +1344,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_MoveDeleted_Ch7:
toggle_sfx
@@ -1371,7 +1371,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_MoveDeleted_Ch8:
toggle_sfx
@@ -1383,7 +1383,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_2ndPlace:
channel_count 4
@@ -1424,7 +1424,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_2ndPlace_Ch6:
toggle_sfx
@@ -1448,7 +1448,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_2ndPlace_Ch7:
toggle_sfx
@@ -1486,7 +1486,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_2ndPlace_Ch8:
toggle_sfx
@@ -1501,7 +1501,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_1stPlace:
channel_count 4
@@ -1549,7 +1549,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_1stPlace_Ch6:
toggle_sfx
@@ -1573,7 +1573,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_1stPlace_Ch7:
toggle_sfx
@@ -1597,7 +1597,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_1stPlace_Ch8:
toggle_sfx
@@ -1618,7 +1618,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_ChooseACard:
channel_count 4
@@ -1671,7 +1671,7 @@
rest 12
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_ChooseACard_Ch6:
toggle_sfx
@@ -1703,7 +1703,7 @@
rest 12
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_ChooseACard_Ch7:
toggle_sfx
@@ -1739,7 +1739,7 @@
rest 12
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_ChooseACard_Ch8:
toggle_sfx
@@ -1764,7 +1764,7 @@
note B_, 16
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetTm:
channel_count 4
@@ -1797,7 +1797,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetTm_Ch6:
toggle_sfx
@@ -1820,7 +1820,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetTm_Ch7:
toggle_sfx
@@ -1851,7 +1851,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetTm_Ch8:
toggle_sfx
@@ -1871,7 +1871,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetBadge:
channel_count 4
@@ -1899,7 +1899,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetBadge_branch_f11aa:
rest 5
@@ -1970,7 +1970,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetBadge_Ch7:
toggle_sfx
@@ -2009,7 +2009,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_GetBadge_Ch8:
toggle_sfx
@@ -2035,7 +2035,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_QuitSlots:
channel_count 4
@@ -2074,7 +2074,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_QuitSlots_Ch6:
toggle_sfx
@@ -2101,7 +2101,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_QuitSlots_Ch7:
toggle_sfx
@@ -2132,7 +2132,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_QuitSlots_Ch8:
toggle_sfx
@@ -2152,7 +2152,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_Protect:
channel_count 2
@@ -3042,7 +3042,7 @@
note D_, 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfareLessThan20_Ch6:
toggle_sfx
@@ -3061,7 +3061,7 @@
note F#, 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfareLessThan20_Ch7:
toggle_sfx
@@ -3089,7 +3089,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfareLessThan20_Ch8:
toggle_sfx
@@ -3100,7 +3100,7 @@
rest 12
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare140169:
channel_count 4
@@ -3136,7 +3136,7 @@
rest 8
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare140169_Ch6:
toggle_sfx
@@ -3162,7 +3162,7 @@
rest 8
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare140169_Ch7:
toggle_sfx
@@ -3196,7 +3196,7 @@
rest 4
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare140169_Ch8:
toggle_sfx
@@ -3213,7 +3213,7 @@
note D_, 8
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare170199:
channel_count 4
@@ -3249,7 +3249,7 @@
rest 4
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare170199_Ch6:
toggle_sfx
@@ -3277,7 +3277,7 @@
rest 4
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare170199_Ch7:
toggle_sfx
@@ -3305,7 +3305,7 @@
rest 4
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare170199_Ch8:
toggle_sfx
@@ -3327,7 +3327,7 @@
note B_, 16
sound_ret
- db $fd
+ db sound_loop_cmd ; unused
Sfx_DexFanfare200229:
channel_count 4
@@ -3361,7 +3361,7 @@
rest 4
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare200229_Ch6:
toggle_sfx
@@ -3384,7 +3384,7 @@
rest 4
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare200229_Ch7:
toggle_sfx
@@ -3428,7 +3428,7 @@
rest 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare200229_Ch8:
toggle_sfx
@@ -3457,7 +3457,7 @@
note B_, 12
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare230Plus:
channel_count 4
@@ -3512,7 +3512,7 @@
rest 2
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare230Plus_Ch6:
toggle_sfx
@@ -3547,7 +3547,7 @@
rest 2
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare230Plus_Ch7:
toggle_sfx
@@ -3596,7 +3596,7 @@
rest 2
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_DexFanfare230Plus_Ch8:
toggle_sfx
@@ -3632,7 +3632,7 @@
note D_, 6
sound_ret
- toggle_sfx
+ toggle_sfx ; unused
Sfx_NotVeryEffective:
channel_count 1
--- a/docs/design_flaws.md
+++ b/docs/design_flaws.md
@@ -617,7 +617,7 @@
add hl, bc
add hl, bc
+ add hl, bc
-+ b = bank
++ ; b = bank
+ ld a, BANK(PokedexDataPointerTable)
+ call GetFarByte
+ ld b, a
--- a/engine/battle/core.asm
+++ b/engine/battle/core.asm
@@ -6219,7 +6219,7 @@
; 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 @@
ld a, BANK(sLinkBattleStats)
call GetSRAMBank
- call AddLastMobileBattleToLinkRecord
+ call AddLastLinkBattleToLinkRecord
call ReadAndPrintLinkBattleRecord
call CloseSRAM
@@ -8442,6 +8442,9 @@
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 @@
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 @@
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 @@
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 @@
ld hl, wRoamMon3Species
ret
-AddLastMobileBattleToLinkRecord:
+AddLastLinkBattleToLinkRecord:
ld hl, wOTPlayerID
ld de, wStringBuffer1
ld bc, 2
@@ -8702,10 +8705,10 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
.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
--- a/macros/code.asm
+++ b/macros/code.asm
@@ -51,7 +51,7 @@
; 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
--- a/macros/wram.asm
+++ b/macros/wram.asm
@@ -238,6 +238,7 @@
\1Wins:: dw
\1Losses:: dw
\1Draws:: dw
+\1End::
ENDM
trademon: MACRO
--- a/sram.asm
+++ b/sram.asm
@@ -125,12 +125,10 @@
sBox:: box sBox
; b160
- ds $f4
+ ds $100
SECTION "Link Battle Data", SRAM
-
-sLinkBattleResults:: ds $c
sLinkBattleStats::
sLinkBattleWins:: dw ; b260
--- a/wram.asm
+++ b/wram.asm
@@ -2851,15 +2851,15 @@
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