Miscellaneous updates and corrections

This commit is contained in:
Rangi 2020-04-23 16:10:46 -04:00
parent 2d3a94b7c4
commit b50dd57cbb
7 changed files with 38 additions and 35 deletions

View File

@ -3327,7 +3327,7 @@ Sfx_DexFanfare170199_Ch8:
note B_, 16
sound_ret
db $fd
db sound_loop_cmd
Sfx_DexFanfare200229:
channel_count 4

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -238,6 +238,7 @@ link_battle_record: MACRO
\1Wins:: dw
\1Losses:: dw
\1Draws:: dw
\1End::
ENDM
trademon: MACRO

View File

@ -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

View File

@ -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