forked from UsernameFodder/pmdsky-debug
-
Notifications
You must be signed in to change notification settings - Fork 0
/
overlay29.yml
6608 lines (5913 loc) · 229 KB
/
overlay29.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
overlay29:
versions:
- EU
- NA
- JP
address:
EU: 0x22DCB80
NA: 0x22DC240
JP: 0x22DD8E0
length:
EU: 0x77900
NA: 0x77620
JP: 0x77200
description: |-
The dungeon engine.
This is the "main" overlay of dungeon mode. It controls most things that happen in a Mystery Dungeon, such as dungeon layout generation, dungeon menus, enemy AI, and generally just running each turn while within a dungeon.
subregions:
- move_effects.yml
functions:
- name: DungeonAlloc
address:
EU: 0x22DF39C
NA: 0x22DEA5C
JP: 0x22E00FC
description: |-
Allocates a new dungeon struct.
This updates the master dungeon pointer and returns a copy of that pointer.
return: pointer to a newly allocated dungeon struct
- name: GetDungeonPtrMaster
address:
EU: 0x22DF3C0
NA: 0x22DEA80
description: |-
Returns the master dungeon pointer (a global, see DUNGEON_PTR_MASTER).
return: pointer to a newly allocated dungeon struct
- name: DungeonZInit
address:
EU: 0x22DF3D0
NA: 0x22DEA90
JP: 0x22E0130
description: |-
Zero-initializes the dungeon struct pointed to by the master dungeon pointer.
No params.
- name: DungeonFree
address:
EU: 0x22DF3F0
NA: 0x22DEAB0
description: |-
Frees the dungeons struct pointer to by the master dungeon pointer, and nullifies the pointer.
No params.
- name: RunDungeon
address:
EU: 0x22DF878
NA: 0x22DEF38
JP: 0x22E05D8
description: |-
Called at the start of a dungeon. Initializes the dungeon struct from specified dungeon data. Includes a loop that does not break until the dungeon is cleared, and another one inside it that runs until the current floor ends.
r0: Pointer to the struct containing info used to initialize the dungeon. See type dungeon_init for details.
r1: Pointer to the dungeon data struct that will be used during the dungeon.
- name: EntityIsValid
address:
EU:
- 0x22E0C94
- 0x22E235C
- 0x22E2947
- 0x22E3C98
- 0x22E4168
- 0x22E9FA4
- 0x22ECFB8
- 0x22ED770
- 0x22EECF8
- 0x22F0154
- 0x22F0F44
- 0x22F5C48
- 0x22F6C60
- 0x22F7D1C
- 0x22FD398
- 0x22FEEB8
- 0x2300B10
- 0x2303464
- 0x23051E4
- 0x2305FB8
- 0x2306630
- 0x2308924
- 0x23099E8
- 0x230F364
- 0x230FA7C
- 0x2311A70
- 0x2312314
- 0x2315B78
- 0x2319794
- 0x23198AC
- 0x231A9EC
- 0x231BBF4
- 0x231D630
- 0x231F840
- 0x231FFD8
- 0x2320664
- 0x2320BE4
- 0x23211CC
- 0x2321EA0
- 0x2326088
- 0x232F280
- 0x23349EC
- 0x2335B18
- 0x2338878
- 0x23456DC
- 0x2346284
- 0x23487A4
- 0x234A47C
- 0x234E9D0
- 0x234F820
NA:
- 0x22E0354
- 0x22E1A1C
- 0x22E32E8
- 0x22E37B8
- 0x22E95F4
- 0x22EC608
- 0x22ECDC0
- 0x22EE348
- 0x22EF7A0
- 0x22F0590
- 0x22F528C
- 0x22F62A8
- 0x22F7364
- 0x22FC99C
- 0x22FED98
- 0x23000E4
- 0x2302A38
- 0x23047B8
- 0x230558C
- 0x2305C04
- 0x2307EF8
- 0x230827C
- 0x2308FBC
- 0x230E8F0
- 0x230F008
- 0x2311010
- 0x23118B4
- 0x2315118
- 0x2318D34
- 0x2318E4C
- 0x2319F8C
- 0x231B194
- 0x231CBC8
- 0x231EDD8
- 0x231F570
- 0x231FBFC
- 0x232017C
- 0x2320764
- 0x2321438
- 0x2325620
- 0x232E840
- 0x2333FAC
- 0x23350D8
- 0x2337CA8
- 0x2344AF8
- 0x2345698
- 0x2347BA4
- 0x234987C
- 0x234DDD0
- 0x234EC14
JP:
- 0x2312538
- 0x2312DCC
- 0x23165F0
- 0x23364C4
description: |-
Checks if an entity pointer points to a valid entity (not entity type 0, which represents no entity).
r0: entity pointer
return: bool
- name: GetFloorType
address:
EU: 0x22E0CF0
NA: 0x22E03B0
JP: 0x22E1A48
description: |-
Get the current floor type.
Floor types:
0 appears to mean the current floor is "normal"
1 appears to mean the current floor is a fixed floor
2 means the current floor has a rescue point
return: floor type
- name: TryForcedLoss
address:
EU: 0x22E0F60
NA: 0x22E0620
JP: 0x22E1CAC
description: |-
Attempts to trigger a forced loss of the type specified in dungeon::forced_loss_reason.
r0: if true, the function will not check for the end of the floor condition and will skip other (unknown) actions in case of forced loss.
return: true if the forced loss happens, false otherwise
- name: IsBossFight
address:
EU: 0x22E11A4
NA: 0x22E0864
JP: 0x22E1EF4
description: |-
Note: unverified, ported from Irdkwia's notes
r0: fixed_room_id
return: bool
- name: IsCurrentFixedRoomBossFight
address:
EU: 0x22E11C0
NA: 0x22E0880
JP: 0x22E1F10
description: |-
Note: unverified, ported from Irdkwia's notes
return: bool
- name: IsMarowakTrainingMaze
address:
EU: 0x22E11E0
NA: 0x22E08A0
JP: 0x22E1F30
description: |-
Check if the current dungeon is one of the training mazes in Marowak Dojo (this excludes Final Maze).
return: bool
- name: FixedRoomIsSubstituteRoom
address:
EU: 0x22E120C
NA: 0x22E08CC
description: |-
Checks if the current fixed room is the "substitute room" (ID 0x6E).
return: bool
- name: StoryRestrictionsEnabled
address:
EU: 0x22E1268
NA: 0x22E0928
JP: 0x22E1FB8
description: |-
Returns true if certain special restrictions are enabled.
If true, you will get kicked out of the dungeon if a team member that passes the arm9::JoinedAtRangeCheck2 check faints.
return: !dungeon::nonstory_flag || dungeon::hidden_land_flag
- name: GetScenarioBalanceVeneer
address:
EU: 0x22E129C
NA: 0x22E095C
description: |-
Likely a linker-generated veneer for GetScenarioBalance.
See https://developer.arm.com/documentation/dui0474/k/image-structure-and-generation/linker-generated-veneers/what-is-a-veneer-
- name: FadeToBlack
address:
EU: 0x22E12A8
NA: 0x22E0968
JP: 0x22E1FF8
description: |-
Fades the screen to black across several frames.
No params.
- name: GetTileAtEntity
address:
EU: 0x22E1F68
NA: 0x22E1628
JP: 0x22E2CB8
description: |-
Returns a pointer to the tile where an entity is located.
r0: pointer to entity
returns: pointer to tile
- name: SpawnTrap
address:
EU: 0x22E2BA0
NA: 0x22E2260
JP: 0x22E38F0
description: |-
Spawns a trap on the floor. Fails if there are more than 64 traps already on the floor.
This modifies the appropriate fields on the dungeon struct, initializing new entries in the entity table and the trap info list.
r0: trap ID
r1: position
r2: team (see struct trap::team)
r3: flags (see struct trap::team)
return: entity pointer for the newly added trap, or null on failure
- name: SpawnItemEntity
address:
EU: 0x22E2C54
NA: 0x22E2314
description: |-
Spawns a blank item entity on the floor. Fails if there are more than 64 items already on the floor.
This initializes a new entry in the entity table and points it to the corresponding slot in the item info list.
r0: position
return: entity pointer for the newly added item, or null on failure
- name: ShouldDisplayEntityMessages
address:
EU: 0x22E2EB4
NA: 0x22E2574
description: |-
Checks if messages that involve a certain entity should be displayed or suppressed.
For example, it returns false if the entity is an invisible enemy.
r0: Entity pointer
r1: ?
return: True if messages involving the entity should be displayed, false if they should be suppressed.
- name: ShouldDisplayEntityMessagesWrapper
address:
EU: 0x22E306C
NA: 0x22E272C
description: |-
Calls ShouldDisplayEntityMessages with r1 = 0
r0: Entity pointer
return: True if messages involving the entity should be displayed, false if they should be suppressed.
- name: CanSeeTarget
address:
EU: 0x22E308C
NA: 0x22E274C
JP: 0x22E3DE0
description: |-
Checks if a given monster can see another monster.
Calls IsPositionActuallyInSight. Also checks if the user is blinded, if the target is invisible, etc.
This function is almost the same as CanTargetEntity, the only difference is that the latter calls IsPositionInSight instead.
r0: User entity pointer
r1: Target entity pointer
return: True if the user can see the target, false otherwise
- name: CanTargetEntity
address:
EU: 0x22E3150
NA: 0x22E2810
JP: 0x22E3EA4
description: |-
Checks if a monster can target another entity when controlled by the AI.
More specifically, it checks if the target is invisible, if the user can see invisible monsters, if the user is blinded and if the target position is in sight from the position of the user (this last check is done by calling IsPositionInSight with the user's and the target's position).
This function is almost the same as CanSeeTarget, the only difference is that the latter calls IsPositionActuallyInSight instead.
r0: User entity pointer
r1: Target entity pointer
return: True if the user can target the target, false otherwise
- name: CanTargetPosition
address:
EU: 0x22E3294
NA: 0x22E2954
JP: 0x22E3FE8
description: |-
Checks if a monster can target a position. This function just calls IsPositionInSight using the position of the user as the origin.
r0: Entity pointer
r1: Target position
return: True if the specified monster can target the target position, false otherwise.
- name: GetTeamMemberIndex
address:
EU: 0x22E3378
NA: 0x22E2A38
JP: 0x22E40CC
description: |-
Given a pointer to an entity, returns its index on the entity list, or null if the entity can't be found on the first 4 slots of the list.
r0: Pointer to the entity to find
return: Index of the specified entity on the entity list, or null if it's not on the first 4 slots.
- name: SubstitutePlaceholderStringTags
address:
EU: 0x22E3418
NA: 0x22E2AD8
JP: 0x22E416C
description: |-
Replaces instances of a given placeholder tag by the string representation of the given entity.
From the eos-move-effects docs (which are somewhat nebulous): "Replaces the string at StringID [r0] by the string representation of the target [r1] (aka its name). Any message with the string manipulator '[string:StringID]' will use that string".
The game uses various placeholder tags in its strings, which you can read about here: https://textbox.skytemple.org/.
r0: string ID (unclear what this means)
r1: entity pointer
r2: ?
- name: UpdateMapSurveyorFlag
address:
EU: 0x22E375C
NA: 0x22E2DD8
description: |-
Sets the Map Surveyor flag in the dungeon struct to true if a team member has Map Surveyor, sets it to false otherwise.
This function has two variants: in the EU ROM, it will return true if the flag was changed. The NA version will return the new value of the flag instead.
return: bool
- name: PointCameraToMonster
address:
EU: 0x22E3804
NA: 0x22E2E54
JP: 0x22E44C4
description: |-
Points the camera to the specified monster.
r0: Entity pointer
r1: ?
- name: UpdateCamera
address:
EU: 0x22E3874
NA: 0x22E2EC4
JP: 0x22E4534
description: |-
Called every frame. Sets the camera to the right coordinates depending on the monster it points to.
It also takes care of updating the minimap, checking which elements should be shown on it, as well as whether the screen should be black due to the blinker status.
r0: ?
- name: ItemIsActive
address:
EU:
- 0x22E3CBC
- 0x22EECC8
- 0x22F6350
- 0x23002C4
- 0x23030F8
- 0x2308948
- 0x230B450
- 0x230EFEC
- 0x2310284
- 0x2311A94
- 0x2312658
- 0x2315B9C
- 0x2348750
NA:
- 0x22E330C
- 0x22EE318
- 0x22F5994
- 0x22FF898
- 0x23026CC
- 0x2307F1C
- 0x230A9DC
- 0x230E578
- 0x230F810
- 0x2311034
- 0x2311BF8
- 0x231513C
- 0x2347B50
JP:
- 0x2300CA8
- 0x2316614
description: |-
Checks if a monster is holding a certain item that isn't disabled by Klutz.
r0: entity pointer
r1: item ID
return: bool
- name: GetVisibilityRange
address:
EU: 0x22E3CEC
NA: 0x22E333C
description: |-
Returns dungeon::display_data::visibility_range. If the visibility range is 0, returns 2 instead.
return: Visibility range of the current floor, or 2 if the visibility is 0.
- name: PlayEffectAnimation
address:
EU: 0x22E3F94
NA: 0x22E35E4
JP: 0x22E4C54
description: |-
Just a guess. This appears to be paired often with GetEffectAnimationField0x19, and also has calls AnimationHasMoreFrames in a loop alongside AdvanceFrame(66) calls.
The third parameter skips the loop entirely. It seems like in this case the function might just preload some animation frames for later use??
r0: entity pointer
r1: ?
r2: appears to be a flag for actually running the animation now? If this is 0, the AdvanceFrame loop is skipped entirely.
others: ?
return: status code, or maybe the number of frames or something? Either way, -1 seems to indicate the animation being finished or something?
- name: UpdateStatusIconFlags
address:
EU: 0x22E4464
NA: 0x22E3AB4
JP: 0x22E5124
description: |-
Sets a monster's status_icon_flags bitfield according to its current status effects. Does not affect a Sudowoodo in the "permanent sleep" state (statuses::sleep == 0x7F).
Some of the status effect in monster::statuses are used as an index to access an array, where every group of 8 bytes represents a bitmask. All masks are added in a bitwise OR and then stored in monster::status_icon.
Also sets icon flags for statuses::exposed, statuses::grudge, critical HP and lowered stats with explicit checks, and applies the effect of the Identifier Orb (see dungeon::identify_orb_flag).
r0: entity pointer
- name: PlayEffectAnimation0x171Full
address:
EU: 0x22E49C8
NA: 0x22E4018
JP: 0x22E5688
description: |-
Just a guess. Calls PlayEffectAnimation with data from animation ID 0x171, with the third parameter of PlayEffectAnimation set to true.
r0: entity pointer
- name: PlayEffectAnimation0x171
address:
EU: 0x22E4A1C
NA: 0x22E406C
JP: 0x22E56DC
description: |-
Just a guess. Calls PlayEffectAnimation with data from animation ID 0x171.
r0: entity pointer
- name: ShowPpRestoreEffect
address:
EU: 0x22E5314
NA: 0x22E4964
JP: 0x22E5FD4
description: |-
Displays the graphical effect on a monster that just recovered PP.
r0: entity pointer
- name: PlayEffectAnimation0x1A9
address:
NA:
- 0x22E6130
- 0x22E617C
- 0x22E61C8
- 0x22E6214
- 0x22E64C4
- 0x22E6510
description: |-
Just a guess. Calls PlayEffectAnimation with data from animation ID 0x1A9.
r0: entity pointer
- name: PlayEffectAnimation0x18E
address:
EU: 0x22E6D88
NA: 0x22E63D8
JP: 0x22E7A48
description: |-
Just a guess. Calls PlayEffectAnimation with data from animation ID 0x18E.
r0: entity pointer
- name: LoadMappaFileAttributes
address:
EU: 0x22E796C
NA: 0x22E6FBC
JP: 0x22E862C
description: |-
Note: unverified, ported from Irdkwia's notes
This function processes the spawn list of the current floor, checking which species can spawn, capping the amount of spawnable species on the floor to 14, randomly choosing which 14 species will spawn and ensuring that the sprite size of all the species combined does not exceed the maximum of 0x58000 bytes (352 KB). Kecleon and the Decoy are always included in the random selection.
r0: quick_saved
r1: ???
r2: special_process
- name: MonsterSpawnListPartialCopy
address:
EU: 0x22E8610
NA: 0x22E7C60
description: |-
Copies all entries in the floor's monster spawn list that have a sprite size >= 6 to the specified buffer.
The parameter in r1 can be used to specify how many entries are already present in the buffer. Entries added by this function will be placed after those, and the total returned in r1 will account for existing entries as well.
r0: (output) Buffer where the result will be stored
r1: Current amount of entries in the buffer
return: New amount of entries in the buffer
- name: IsOnMonsterSpawnList
address:
EU: 0x22E86FC
NA: 0x22E7D4C
JP: 0x22E93B4
description: |-
Returns true if the specified monster is included in the floor's monster spawn list (the modified list after a maximum of 14 different species were chosen, not the raw list read from the mappa file).
r0: Monster ID
return: bool
- name: GetMonsterIdToSpawn
address:
EU: 0x22E8750
NA: 0x22E7DA0
JP: 0x22E9408
description: |-
Get the id of the monster to be randomly spawned.
r0: the spawn weight to use (0 for normal, 1 for monster house)
return: monster ID
- name: GetMonsterLevelToSpawn
address:
EU: 0x22E8808
NA: 0x22E7E58
JP: 0x22E94C0
description: |-
Get the level of the monster to be spawned, given its id.
r0: monster ID
return: Level of the monster to be spawned, or 1 if the specified ID can't be found on the floor's spawn table.
- name: GetDirectionTowardsPosition
address:
EU: 0x22E99D0
NA: 0x22E9020
JP: 0x22EA688
description: |-
Gets the direction in which a monster should move to go from the origin position to the target position
r0: Origin position
r1: Target position
return: Direction in which to move to reach the target position from the origin position
- name: GetChebyshevDistance
address:
EU: 0x22E9A3C
NA: 0x22E908C
JP: 0x22EA6F4
description: |-
Returns the Chebyshev distance between two positions. Calculated as max(abs(x0-x1), abs(y0-y1)).
r0: Position A
r1: Position B
return: Chebyshev Distance between position A and position B
- name: IsPositionActuallyInSight
address:
EU: 0x22E9A7C
NA: 0x22E90CC
JP: 0x22EA734
description: |-
Checks if a given target position is in sight from a given origin position.
If the origin position is on a hallway or r2 is true, checks if both positions are within <dungeon::display_data::visibility_range> tiles of each other.
If the origin position is on a room, checks that the target position is within the boundaries of said room.
r0: Origin position
r1: Target position
r2: True to assume the entity standing on the origin position has the dropeye status
return: True if the target position is in sight from the origin position
- name: IsPositionInSight
address:
EU: 0x22E9B54
NA: 0x22E91A4
JP: 0x22EA80C
description: |-
Checks if a given target position is in sight from a given origin position.
There's multiple factors that affect this check, but generally, it's true if both positions are in the same room (by checking if the target position is within the boundaries of the room where the origin position is) or within 2 tiles of each other.
r0: Origin position
r1: Target position
r2: True to assume the entity standing on the origin position has the dropeye status
return: True if the target position is in sight from the origin position
- name: GetLeader
address:
EU: 0x22E9F30
NA: 0x22E9580
JP: 0x22EABE8
description: |-
Gets the pointer to the entity that is currently leading the team, or null if none of the first 4 entities is a valid monster with its is_team_leader flag set. It also sets LEADER_PTR to the result before returning it.
return: Pointer to the current leader of the team or null if there's no valid leader.
- name: GetLeaderMonster
address:
EU: 0x22E9FC8
NA: 0x22E9618
JP: 0x22EAC80
description: |-
Returns a pointer to the monster data of the current leader.
No params.
- name: FindNearbyUnoccupiedTile
address:
EU: 0x22EA1F4
NA: 0x22E9844
JP: 0x22EAEAC
description: |-
Searches for an unoccupied tile near some origin.
A tile is considered "unoccupied" if it's not a key door, and has no object or monster on it. In "random room" mode, the tile must also not be in a hallway, and must not have the stairs.
The first unoccupied tile found is returned. The search order is randomized in "random room" mode, otherwise the search order is fixed based on the input displacement array.
r0: [output] position
r1: origin position
r2: array of displacements from the origin position to consider
r3: number of elements in displacements array
stack[0]: random room mode flag
return: whether a tile was successfully found
- name: FindClosestUnoccupiedTileWithin2
address:
NA: 0x22E99F0
description: |-
Searches for the closest unoccupied tile within 2 steps of the given origin.
Calls FindNearbyUnoccupiedTile with DISPLACEMENTS_WITHIN_2_SMALLEST_FIRST.
r0: [output] position
r1: origin position
r2: random room mode flag
return: whether a tile was successfully found
- name: FindFarthestUnoccupiedTileWithin2
address:
NA: 0x22E9A0C
description: |-
Searches for the farthest unoccupied tile within 2 steps of the given origin.
Calls FindNearbyUnoccupiedTile with DISPLACEMENTS_WITHIN_2_LARGEST_FIRST.
r0: [output] position
r1: origin position
r2: random room mode flag
return: whether a tile was successfully found
- name: FindUnoccupiedTileWithin3
address:
EU: 0x22EA3D8
NA: 0x22E9A28
JP: 0x22EB090
description: |-
Searches for an unoccupied tile within 3 steps of the given origin.
Calls FindNearbyUnoccupiedTile with DISPLACEMENTS_WITHIN_3.
r0: [output] position
r1: origin position
r2: random room mode flag
return: whether a tile was successfully found
- name: TickStatusTurnCounter
address:
EU: 0x22EA3F4
NA: 0x22E9A44
JP: 0x22EB0AC
description: |-
Ticks down a turn counter for a status condition. If the counter equals 0x7F, it will not be decreased.
r0: pointer to the status turn counter
return: new counter value
- name: AdvanceFrame
address:
EU: 0x22EA990
NA: 0x22E9FE0
JP: 0x22EB648
description: |-
Advances one frame. Does not return until the next frame starts.
r0: ? - Unused by the function
- name: SetDungeonRngPreseed23Bit
address:
EU: 0x22EB318
NA: 0x22EA968
JP: 0x22EBFD0
description: |-
Sets the preseed in the global dungeon PRNG state, using 23 bits from the input. See GenerateDungeonRngSeed for more information.
Given the input preseed23, the actual global preseed is set to (preseed23 & 0xFFFFFF | 1), so only bits 1-23 of the input are used.
r0: preseed23
- name: GenerateDungeonRngSeed
address:
EU: 0x22EB330
NA: 0x22EA980
JP: 0x22EBFE8
description: |-
Generates a seed with which to initialize the dungeon PRNG.
The seed is calculated by starting with a different seed, the "preseed" x0 (defaults to 1, but can be set by other functions). The preseed is iterated twice with the same recurrence relation used in the primary LCG to generate two pseudorandom 32-bit numbers x1 and x2. The output seed is then computed as
seed = (x1 & 0xFF0000) | (x2 >> 0x10) | 1
The value x1 is then saved as the new preseed.
This method of seeding the dungeon PRNG appears to be used only sometimes, depending on certain flags in the data for a given dungeon.
return: RNG seed
- name: GetDungeonRngPreseed
address:
EU: 0x22EB37C
NA: 0x22EA9CC
JP: 0x22EC034
description: |-
Gets the current preseed stored in the global dungeon PRNG state. See GenerateDungeonRngSeed for more information.
return: current dungeon RNG preseed
- name: SetDungeonRngPreseed
address:
EU: 0x22EB38C
NA: 0x22EA9DC
JP: 0x22EC044
description: |-
Sets the preseed in the global dungeon PRNG state. See GenerateDungeonRngSeed for more information.
r0: preseed
- name: InitDungeonRng
address:
EU: 0x22EB39C
NA: 0x22EA9EC
JP: 0x22EC054
description: |-
Initialize (or reinitialize) the dungeon PRNG with a given seed. The primary LCG and the five secondary LCGs are initialized jointly, and with the same seed.
r0: seed
- name: DungeonRand16Bit
address:
EU: 0x22EB3D0
NA: 0x22EAA20
JP: 0x22EC088
description: |-
Computes a pseudorandom 16-bit integer using the dungeon PRNG.
Note that the dungeon PRNG is only used in dungeon mode (as evidenced by these functions being in overlay 29). The game uses another lower-quality PRNG (see arm9.yml) for other needs.
Random numbers are generated with a linear congruential generator (LCG). The game actually maintains 6 separate sequences that can be used for generation: a primary LCG and 5 secondary LCGs. The generator used depends on parameters set on the global PRNG state.
All dungeon LCGs have a modulus of 2^32 and a multiplier of 1566083941 (see DUNGEON_PRNG_LCG_MULTIPLIER). The primary LCG uses an increment of 1, while the secondary LCGs use an increment of 2531011 (see DUNGEON_PRNG_LCG_INCREMENT_SECONDARY). So, for example, the primary LCG uses the recurrence relation:
x = (1566083941*x_prev + 1) % 2^32
Since the dungeon LCGs generate 32-bit integers rather than 16-bit, the primary LCG yields 16-bit values by taking the upper 16 bits of the computed 32-bit value. The secondary LCGs yield 16-bit values by taking the lower 16 bits of the computed 32-bit value.
All of the dungeon LCGs have a hard-coded default seed of 1, but in practice the seed is set with a call to InitDungeonRng during dungeon initialization.
return: pseudorandom int on the interval [0, 65535]
- name: DungeonRandInt
address:
EU: 0x22EB448
NA: 0x22EAA98
JP: 0x22EC100
description: |-
Compute a pseudorandom integer under a given maximum value using the dungeon PRNG.
r0: high
return: pseudorandom integer on the interval [0, high - 1]
- name: DungeonRandRange
address:
EU: 0x22EB470
NA: 0x22EAAC0
JP: 0x22EC128
description: |-
Compute a pseudorandom value between two integers using the dungeon PRNG.
r0: x
r1: y
return: pseudorandom integer on the interval [min(x, y), max(x, y) - 1]
- name: DungeonRandOutcome
address:
EU:
- 0x22EB4D0
- 0x22EB500
NA:
- 0x22EAB20
- 0x22EAB50
JP:
- 0x22EC188
- 0x22EC1B8
description: |-
Returns the result of a possibly biased coin flip (a Bernoulli random variable) with some success probability p, using the dungeon PRNG.
r0: success percentage (100*p)
return: true with probability p, false with probability (1-p)
- name: CalcStatusDuration
address:
EU: 0x22EB530
NA: 0x22EAB80
JP: 0x22EC1E8
description: |-
Seems to calculate the duration of a volatile status on a monster.
r0: entity pointer
r1: pointer to a turn range (an array of two shorts {lower, higher})
r2: flag for whether or not to factor in the Self Curer IQ skill and the Natural Cure ability
return: number of turns for the status condition
- name: DungeonRngUnsetSecondary
address:
EU: 0x22EB5E4
NA: 0x22EAC34
JP: 0x22EC29C
description: |-
Sets the dungeon PRNG to use the primary LCG for subsequent random number generation, and also resets the secondary LCG index back to 0.
Similar to DungeonRngSetPrimary, but DungeonRngSetPrimary doesn't modify the secondary LCG index if it was already set to something other than 0.
No params.
- name: DungeonRngSetSecondary
address:
EU: 0x22EB5FC
NA: 0x22EAC4C
JP: 0x22EC2B4
description: |-
Sets the dungeon PRNG to use one of the 5 secondary LCGs for subsequent random number generation.
r0: secondary LCG index
- name: DungeonRngSetPrimary
address:
EU: 0x22EB614
NA: 0x22EAC64
description: |-
Sets the dungeon PRNG to use the primary LCG for subsequent random number generation.
No params.
- name: ChangeDungeonMusic
address:
EU: 0x22EB7C4
NA: 0x22EAE14
JP: 0x22EC47C
description: |-
Note: unverified, ported from Irdkwia's notes
r0: music ID
- name: TrySwitchPlace
address:
EU: 0x22EBB28
NA: 0x22EB178
JP: 0x22EC7E0
description: |-
The user entity attempts to switch places with the target entity (i.e. by the effect of the Switcher Orb).
The function checks for the Suction Cups ability for both the user and the target, and for the Mold Breaker ability on the user.
r0: pointer to user entity
r1: pointer to target entity
- name: ClearMonsterActionFields
address:
EU: 0x22EBDA4
NA: 0x22EB3F4
JP: 0x22ECA5C
description: |-
Clears the fields related to AI in the monster's data struct, setting them all to 0.
Specifically, monster::action::action_id, monster::action::action_use_idx and monster::action::field_0xA are cleared.
r0: Pointer to the monster's action field
- name: SetMonsterActionFields
address:
EU: 0x22EBDB8
NA: 0x22EB408
JP: 0x22ECA70
description: |-
Sets some the fields related to AI in the monster's data struct.
Specifically, monster::action::action_id, monster::action::action_use_idx and monster::action::field_0xA. The last 2 are always set to 0.
r0: Pointer to the monster's action field
r1: Value to set monster::action::action_id to.
- name: SetActionPassTurnOrWalk
address:
EU: 0x22EBDCC
NA: 0x22EB41C
JP: 0x22ECA84
description: |-
Sets a monster's action to action::ACTION_PASS_TURN or action::ACTION_WALK, depending on the result of GetCanMoveFlag for the monster's ID.
r0: Pointer to the monster's action field
r1: Monster ID
- name: GetItemAction
address:
EU: 0x22EBF88
NA: 0x22EB5D8
JP: 0x22ECC40
description: |-
Returns the action ID that corresponds to an item given its ID.
The action is based on the category of the item (see ITEM_CATEGORY_ACTIONS), unless the specified ID is 0x16B, in which case ACTION_UNK_35 is returned.
Some items can have unexpected actions, such as thrown items, which have ACTION_NOTHING. This is done to prevent duplicate actions from being listed in the menu (since items always have a "throw" option), since a return value of ACTION_NOTHING prevents the option from showing up in the menu.
r0: Item ID
return: Action ID associated with the specified item
- name: AddDungeonSubMenuOption
address:
EU: 0x22EC1CC
NA: 0x22EB81C
JP: 0x22ECE84
description: |-
Adds an option to the list of actions that can be taken on a pokémon, item or move to the currently active sub-menu on dungeon mode (team, moves, items, etc.).
r0: Action ID
r1: True if the option should be enabled, false otherwise
- name: DisableDungeonSubMenuOption
address:
EU: 0x22EC2A4
NA: 0x22EB8F4
JP: 0x22ECF5C
description: |-
Disables an option that was addeed to a dungeon sub-menu.
r0: Action ID of the option that should be disabled
- name: SetActionRegularAttack
address:
EU: 0x22EC600
NA: 0x22EBC50
JP: 0x22ED2B8
description: |-
Sets a monster's action to action::ACTION_REGULAR_ATTACK, with a specified direction.
r0: Pointer to the monster's action field
r1: Direction in which to use the move. Gets stored in monster::action::direction.
- name: SetActionUseMoveAi
address:
EU: 0x22EC66C
NA: 0x22EBCBC
JP: 0x22ED324
description: |-
Sets a monster's action to action::ACTION_USE_MOVE_AI, with a specified direction and move index.
r0: Pointer to the monster's action field
r1: Index of the move to use (0-3). Gets stored in monster::action::action_use_idx.
r2: Direction in which to use the move. Gets stored in monster::action::direction.
- name: RunFractionalTurn
address:
EU: 0x22EC6B8
NA: 0x22EBD08
JP: 0x22ED370