Name and comment the trainer party reader.

Reads the contents of trainers/trainers.asm.
This commit is contained in:
yenatch 2014-06-14 22:33:23 -07:00
parent e6271ca450
commit db27602679
4 changed files with 181 additions and 141 deletions

View File

@ -8485,14 +8485,15 @@ Function3f594: ; 3f594
xor a
ld [TempEnemyMonSpecies], a
callab Function3957b
callab Function39771
callab ReadTrainerParty
ld a, [TrainerClass]
cp $9
jr nz, .asm_3f5b8
cp RIVAL1
jr nz, .ok
xor a
ld [OTPartyMon1Item], a
.ok
.asm_3f5b8
ld de, VTiles2
callab Function5120d
xor a
@ -8500,13 +8501,14 @@ Function3f594: ; 3f594
dec a
ld [$c6e6], a
hlcoord 12, 0
ld bc, $0707
ld a, $13
lb bc, 7, 7
ld a, PREDEF_FILL_BOX
call Predef
ld a, $ff
ld [CurOTMon], a
ld a, $2
ld a, TRAINER_BATTLE
ld [IsInBattle], a
call IsJohtoGymLeader
jr nc, .asm_3f606
xor a
@ -8515,14 +8517,13 @@ Function3f594: ; 3f594
ld b, a
.asm_3f5ea
push bc
ld a, $22
ld a, PartyMon1HP - PartyMon1
call GetPartyParamLocation
ld a, [hli]
or [hl]
jr z, .asm_3f5fc
ld c, $4
callab ChangeHappiness
.asm_3f5fc
pop bc
dec b
@ -8530,7 +8531,6 @@ Function3f594: ; 3f594
ld hl, CurPartyMon
inc [hl]
jr .asm_3f5ea
.asm_3f606
ret
; 3f607
@ -8568,8 +8568,8 @@ Function3f607: ; 3f607
ld [TrainerClass], a
ld [$ffad], a
hlcoord 12, 0
ld bc, $0707
ld a, $13
lb bc, 7, 7
ld a, PREDEF_FILL_BOX
call Predef
ret
; 3f662

294
main.asm
View File

@ -36688,7 +36688,7 @@ Function28177: ; 28177
or $3
ld [hl], a
ld hl, $d26b
ld de, $c656
ld de, OTName
ld bc, $000b
call CopyBytes
call Function222a
@ -43539,19 +43539,20 @@ INCLUDE "battle/ai/scoring.asm"
Function3952d: ; 3952d
ld hl, RivalName
ld a, c
cp $9
jr z, .asm_39544
cp RIVAL1
jr z, .rival
ld [CurSpecies], a
ld a, $7
ld a, TRAINER_NAME
ld [$cf61], a
call GetName
ld de, StringBuffer1
ret
.asm_39544
.rival
ld de, StringBuffer1
push de
ld bc, $000b
ld bc, NAME_LENGTH
call CopyBytes
pop de
ret
@ -43561,20 +43562,22 @@ Function39550: ; 39550
ld hl, $d26b
ld a, [InLinkBattle]
and a
jr nz, .asm_3956f
jr nz, .ok
ld hl, RivalName
ld a, c
cp $9
jr z, .asm_3956f
cp RIVAL1
jr z, .ok
ld [CurSpecies], a
ld a, $7
ld a, TRAINER_NAME
ld [$cf61], a
call GetName
ld hl, StringBuffer1
.asm_3956f
.ok
ld bc, $000d
ld de, $c656
ld de, OTName
push de
call CopyBytes
pop de
@ -43604,122 +43607,134 @@ Function3957b: ; 3957b
INCLUDE "trainers/attributes.asm"
Function39771: ; 39771
ReadTrainerParty: ; 39771
ld a, [$cfc0]
bit 0, a
ret nz
ld a, [InLinkBattle]
and a
ret nz
ld hl, OTPartyCount
xor a
ld [hli], a
dec a
ld [hl], a
ld hl, OTPartyMon1Species
ld bc, $0120
ld hl, OTPartyMons
ld bc, OTPartyMonsEnd - OTPartyMons
xor a
call ByteFill
ld a, [OtherTrainerClass]
cp $c
jr nz, .asm_3979e
ld a, [OtherTrainerID]
cp $2
jr z, .asm_397d3
ld a, [OtherTrainerClass]
.asm_3979e
ld a, [OtherTrainerClass]
cp CAL
jr nz, .not_cal2
ld a, [OtherTrainerID]
cp CAL2
jr z, .cal2
ld a, [OtherTrainerClass]
.not_cal2
dec a
ld c, a
ld b, $0
ld b, 0
ld hl, TrainerGroups
add hl, bc
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [OtherTrainerID]
ld b, a
.asm_397ae
.skip_trainer
dec b
jr z, .asm_397b8
.asm_397b1
jr z, .got_trainer
.next
ld a, [hli]
cp $ff
jr nz, .asm_397b1
jr .asm_397ae
jr nz, .next
jr .skip_trainer
.got_trainer
.asm_397b8
.skip_name
ld a, [hli]
cp $50
jr nz, .asm_397b8
cp "@"
jr nz, .skip_name
ld a, [hli]
ld c, a
ld b, $0
ld b, 0
ld d, h
ld e, l
ld hl, Jumptable_397e3
ld hl, TrainerTypes
add hl, bc
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld bc, .asm_397d0
ld bc, .done
push bc
jp [hl]
.asm_397d0
.done
jp Function3991b
.asm_397d3
.cal2
ld a, $0
call GetSRAMBank
ld de, $ac0a
call Function39806
call TrainerType2
call CloseSRAM
jr .asm_397d0
jr .done
; 397e3
Jumptable_397e3: ; 397e3
dw Function397eb
dw Function39806
dw Function39871
dw Function3989d
TrainerTypes: ; 397e3
dw TrainerType1 ; level, species
dw TrainerType2 ; level, species, moves
dw TrainerType3 ; level, species, item
dw TrainerType4 ; level, species, item, moves
; 397eb
Function397eb: ; 397eb
TrainerType1: ; 397eb
; normal (level, species)
ld h, d
ld l, e
.asm_397ed
.loop
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a ; $d143
ld a, [hli]
ld [CurPartySpecies], a ; $d108
ld a, $1
ld [MonType], a ; $cf5f
push hl
ld a, $6
call Predef
pop hl
jr .asm_397ed
; 39806
Function39806: ; 39806
ld h, d
ld l, e
.asm_39808
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a
ld a, [hli]
ld [CurPartySpecies], a
ld a, OTPARTYMON
ld [MonType], a
push hl
ld a, $6
ld a, PREDEF_ADDPARTYMON
call Predef
pop hl
jr .loop
; 39806
TrainerType2: ; 39806
; moves
ld h, d
ld l, e
.loop
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a
ld a, [hli]
ld [CurPartySpecies], a
ld a, OTPARTYMON
ld [MonType], a
push hl
ld a, PREDEF_ADDPARTYMON
call Predef
ld a, [OTPartyCount]
dec a
@ -43729,14 +43744,17 @@ Function39806: ; 39806
ld d, h
ld e, l
pop hl
ld b, NUM_MOVES
.asm_39830
.copy_moves
ld a, [hli]
ld [de], a
inc de
dec b
jr nz, .asm_39830
jr nz, .copy_moves
push hl
ld a, [OTPartyCount]
dec a
ld hl, OTPartyMon1Species
@ -43744,17 +43762,19 @@ Function39806: ; 39806
call AddNTimes
ld d, h
ld e, l
ld hl, $0017
ld hl, OTPartyMon1PP - OTPartyMon1
add hl, de
push hl
ld hl, $0002
ld hl, OTPartyMon1Moves - OTPartyMon1
add hl, de
pop de
ld b, $4
.asm_39852
ld b, NUM_MOVES
.copy_pp
ld a, [hli]
and a
jr z, .asm_3986e
jr z, .copied_pp
push hl
push bc
dec a
@ -43765,104 +43785,119 @@ Function39806: ; 39806
call GetFarByte
pop bc
pop hl
ld [de], a
inc de
dec b
jr nz, .asm_39852
jr nz, .copy_pp
.copied_pp
.asm_3986e
pop hl
jr .asm_39808
jr .loop
; 39871
Function39871: ; 39871
TrainerType3: ; 39871
; item
ld h, d
ld l, e
.asm_39873
.loop
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a ; $d143
ld a, [hli]
ld [CurPartySpecies], a ; $d108
ld a, $1
ld [MonType], a ; $cf5f
push hl
ld a, $6
call Predef
ld a, [OTPartyCount] ; $d280
dec a
ld hl, OTPartyMon1Item ; $d289
ld bc, $30
call AddNTimes
ld d, h
ld e, l
pop hl
ld a, [hli]
ld [de], a
jr .asm_39873
; 3989d (e:589d)
Function3989d: ; 3989d
ld h, d
ld l, e
.asm_3989f
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a
ld a, [hli]
ld [CurPartySpecies], a
ld a, $1
ld a, OTPARTYMON
ld [MonType], a
push hl
ld a, $6
ld a, PREDEF_ADDPARTYMON
call Predef
ld a, [OTPartyCount]
dec a
ld hl, $d289
ld bc, PartyMon2 - PartyMon1
ld hl, OTPartyMon1Item
ld bc, OTPartyMon2 - OTPartyMon1
call AddNTimes
ld d, h
ld e, l
pop hl
ld a, [hli]
ld [de], a
jr .loop
; 3989d (e:589d)
TrainerType4: ; 3989d
; item + moves
ld h, d
ld l, e
.loop
ld a, [hli]
cp $ff
ret z
ld [CurPartyLevel], a
ld a, [hli]
ld [CurPartySpecies], a
ld a, OTPARTYMON
ld [MonType], a
push hl
ld a, PREDEF_ADDPARTYMON
call Predef
ld a, [OTPartyCount]
dec a
ld hl, $d28a
ld bc, PartyMon2 - PartyMon1
ld hl, OTPartyMon1Item
ld bc, OTPartyMon2 - OTPartyMon1
call AddNTimes
ld d, h
ld e, l
pop hl
ld b, $4
.asm_398da
ld a, [hli]
ld [de], a
push hl
ld a, [OTPartyCount]
dec a
ld hl, OTPartyMon1Moves
ld bc, OTPartyMon2 - OTPartyMon1
call AddNTimes
ld d, h
ld e, l
pop hl
ld b, NUM_MOVES
.copy_moves
ld a, [hli]
ld [de], a
inc de
dec b
jr nz, .asm_398da
jr nz, .copy_moves
push hl
ld a, [OTPartyCount]
dec a
ld hl, OTPartyMon1
ld bc, PartyMon2 - PartyMon1
ld bc, OTPartyMon2 - OTPartyMon1
call AddNTimes
ld d, h
ld e, l
ld hl, $0017
ld hl, OTPartyMon1PP - OTPartyMon1
add hl, de
push hl
ld hl, $0002
ld hl, OTPartyMon1Moves - OTPartyMon1
add hl, de
pop de
ld b, $4
.asm_398fc
ld b, NUM_MOVES
.copy_pp
ld a, [hli]
and a
jr z, .asm_39918
jr z, .copied_pp
push hl
push bc
dec a
@ -43873,34 +43908,34 @@ Function3989d: ; 3989d
call GetFarByte
pop bc
pop hl
ld [de], a
inc de
dec b
jr nz, .asm_398fc
jr nz, .copy_pp
.copied_pp
.asm_39918
pop hl
jr .asm_3989f
jr .loop
; 3991b
; known jump sources: 397d0 (e:57d0)
Function3991b: ; 3991b (e:591b)
ld hl, $ffb3
xor a
ld [hli], a
ld [hli], a
ld [hli], a
ld a, [$c652]
ld a, [$c652] ; base reward
ld [hli], a
ld a, [CurPartyLevel] ; $d143
ld a, [CurPartyLevel]
ld [hl], a
call Multiply
ld hl, $c686
xor a
ld [hli], a
ld a, [$FF00+$b5]
ld a, [$ffb5]
ld [hli], a
ld a, [$FF00+$b6]
ld a, [$ffb6]
ld [hl], a
ret
@ -43918,14 +43953,16 @@ Function39939:: ; 39939
Function3994c:: ; 3994c
ld a, c
cp $c
cp CAL
jr nz, .asm_3996d
ld a, $0
call GetSRAMBank
ld a, [$abfd]
and a
call CloseSRAM
jr z, .asm_3996d
ld a, $0
call GetSRAMBank
ld hl, $abfe
@ -43947,6 +43984,7 @@ Function3994c:: ; 3994c
.asm_3997a
dec b
jr z, Function39984
.asm_3997d
ld a, [hli]
cp $ff

View File

@ -5,7 +5,7 @@
; Type
; 0: Level, species
; 1: Level, species, moves
; 2: Level, sepcies, item
; 2: Level, species, item
; 3: Level, species, item, moves
; Party
; Up to six monsters following the data type

View File

@ -1170,12 +1170,14 @@ OTPartyCount:: ds 1 ; d280
OTPartySpecies:: ds PARTY_LENGTH ; d281
OTPartyEnd:: ds 1
OTPartyMons::
OTPartyMon1:: party_struct OTPartyMon1 ; d288
OTPartyMon2:: party_struct OTPartyMon2 ; d2b8
OTPartyMon3:: party_struct OTPartyMon3 ; d2e8
OTPartyMon4:: party_struct OTPartyMon4 ; d318
OTPartyMon5:: party_struct OTPartyMon5 ; d348
OTPartyMon6:: party_struct OTPartyMon6 ; d378
OTPartyMonsEnd::
OTPartyMonOT:: ds NAME_LENGTH * PARTY_LENGTH ; d3a8
OTPartyMonNicknames:: ds PKMN_NAME_LENGTH * PARTY_LENGTH ; d3ea