summaryrefslogtreecommitdiff
path: root/mobile/get_trainer_class.asm
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2017-12-23 13:17:46 -0500
committerGitHub <noreply@github.com>2017-12-23 13:17:46 -0500
commit878092004956418bfd77bfdb9fc9dd7f640f80d2 (patch)
tree3a97e3eb15d5c545977038e67589f92158e5bf23 /mobile/get_trainer_class.asm
parenta6656a986bf9dde51561cab090648e0117b173ad (diff)
parent3c37bfc6fa2570a0a77c1230673910257ecf32df (diff)
Merge pull request #419 from roukaour/master
More reorganization and documentation
Diffstat (limited to 'mobile/get_trainer_class.asm')
-rw-r--r--mobile/get_trainer_class.asm46
1 files changed, 46 insertions, 0 deletions
diff --git a/mobile/get_trainer_class.asm b/mobile/get_trainer_class.asm
new file mode 100644
index 000000000..37fe91c56
--- /dev/null
+++ b/mobile/get_trainer_class.asm
@@ -0,0 +1,46 @@
+GetMobileOTTrainerClass: ; mobile function
+ ld h, b
+ ld l, c
+ call .GetMobileOTTrainerClass
+ ld c, a
+ ret
+
+.GetMobileOTTrainerClass: ; 4e930
+ ld a, [hli]
+ xor [hl]
+ ld c, a
+ jr z, .skip_male_trainers
+ srl c
+ srl c
+.male_trainer_loop
+ srl c
+ ld a, c
+ cp MaleTrainersEnd - MaleTrainers - 1
+ jr nc, .male_trainer_loop
+ inc c
+
+.skip_male_trainers
+ ld a, [de]
+ cp $1
+ ld hl, MaleTrainers
+ jr nz, .finished
+
+ ld hl, FemaleTrainers
+ ld a, c
+ and a
+ jr z, .finished
+
+.female_trainer_loop
+ srl c
+ ld a, c
+ cp FemaleTrainersEnd - FemaleTrainers - 1
+ jr nc, .female_trainer_loop
+ inc c
+
+.finished
+ ld b, $0
+ add hl, bc
+ ld a, [hl]
+ ret
+
+INCLUDE "data/trainers/gendered_trainers.asm"