-
Notifications
You must be signed in to change notification settings - Fork 2k
/
event.inc
1794 lines (1525 loc) · 46.7 KB
/
event.inc
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
@ Does nothing.
.macro nop
.byte 0x00
.endm
@ Does nothing.
.macro nop1
.byte 0x01
.endm
@ Terminates script execution.
.macro end
.byte 0x02
.endm
@ Jumps back to after the last-executed call statement, and continues script execution from there.
.macro return
.byte 0x03
.endm
@ Jumps to destination and continues script execution from there. The location of the calling script is remembered and can be returned to later.
.macro call destination:req
.byte 0x04
.4byte \destination
.endm
@ Jumps to destination and continues script execution from there.
.macro goto destination:req
.byte 0x05
.4byte \destination
.endm
@ If the result of the last comparison matches condition (see Comparison operators), jumps to destination and continues script execution from there.
.macro goto_if condition:req, destination:req
.byte 0x06
.byte \condition
.4byte \destination
.endm
@ If the result of the last comparison matches condition (see Comparison operators), calls destination.
.macro call_if condition:req, destination:req
.byte 0x07
.byte \condition
.4byte \destination
.endm
@ Jumps to the standard function at index function.
.macro gotostd function:req
.byte 0x08
.byte \function
.endm
@ callstd function names
STD_OBTAIN_ITEM = 0
STD_FIND_ITEM = 1
STD_OBTAIN_DECORATION = 7
STD_REGISTER_MATCH_CALL = 8
@ Calls the standard function at index function.
.macro callstd function:req
.byte 0x09
.byte \function
.endm
@ If the result of the last comparison matches condition (see Comparison operators), jumps to the standard function at index function.
.macro gotostd_if condition:req, function:req
.byte 0x0a
.byte \condition
.byte \function
.endm
@ If the result of the last comparison matches condition (see Comparison operators), calls the standard function at index function.
.macro callstd_if condition:req, function:req
.byte 0x0b
.byte \condition
.byte \function
.endm
@ Executes a script stored in a default RAM location.
.macro returnram
.byte 0x0c
.endm
@ Terminates script execution and "resets the script RAM".
.macro killscript
.byte 0x0d
.endm
@ Sets some status related to Mystery Event.
.macro setmysteryeventstatus value:req
.byte 0x0e
.byte \value
.endm
@ Sets the specified script bank to value.
.macro loadword destination:req, value:req
.byte 0x0f
.byte \destination
.4byte \value
.endm
@ Sets the specified script bank to value.
.macro loadbyte destination:req, value:req
.byte 0x10
.byte \destination
.byte \value
.endm
@ Sets the byte at offset to value.
.macro writebytetoaddr value:req, offset:req
.byte 0x11
.byte \value
.4byte \offset
.endm
@ Copies the byte value at source into the specified script bank.
.macro loadbytefromaddr destination:req, source:req
.byte 0x12
.byte \destination
.4byte \source
.endm
@ Not sure. Judging from XSE's description I think it takes the least-significant byte in bank source and writes it to destination.
.macro setptrbyte source:req, destination:req
.byte 0x13
.byte \source
.4byte \destination
.endm
@ Copies the contents of bank source into bank destination.
.macro copylocal destination:req, source:req
.byte 0x14
.byte \destination
.byte \source
.endm
@ Copies the byte at source to destination, replacing whatever byte was previously there.
.macro copybyte destination:req, source:req
.byte 0x15
.4byte \destination
.4byte \source
.endm
@ Changes the value of destination to value.
.macro setvar destination:req, value:req
.byte 0x16
.2byte \destination
.2byte \value
.endm
@ Changes the value of destination by adding value to it. Overflow is not prevented (0xFFFF + 1 = 0x0000).
.macro addvar destination:req, value:req
.byte 0x17
.2byte \destination
.2byte \value
.endm
@ Changes the value of destination by subtracting value to it. Overflow is not prevented (0x0000 - 1 = 0xFFFF).
.macro subvar destination:req, value:req
.byte 0x18
.2byte \destination
.2byte \value
.endm
@ Copies the value of source into destination.
.macro copyvar destination:req, source:req
.byte 0x19
.2byte \destination
.2byte \source
.endm
@ If source is not a variable, then this function acts like setvar. Otherwise, it acts like copyvar.
.macro setorcopyvar destination:req, source:req
.byte 0x1a
.2byte \destination
.2byte \source
.endm
@ Compares the values of script banks a and b, after forcing the values to bytes.
.macro compare_local_to_local byte1:req, byte2:req
.byte 0x1b
.byte \byte1
.byte \byte2
.endm
@ Compares the least-significant byte of the value of script bank a to a fixed byte value (b).
.macro compare_local_to_value a:req, b:req
.byte 0x1c
.byte \a
.byte \b
.endm
@ Compares the least-significant byte of the value of script bank a to the byte located at offset b.
.macro compare_local_to_addr a:req, b:req
.byte 0x1d
.byte \a
.4byte \b
.endm
@ Compares the byte located at offset a to the least-significant byte of the value of script bank b.
.macro compare_addr_to_local a:req, b:req
.byte 0x1e
.4byte \a
.byte \b
.endm
@ Compares the byte located at offset a to a fixed byte value (b).
.macro compare_addr_to_value a:req, b:req
.byte 0x1f
.4byte \a
.byte \b
.endm
@ Compares the byte located at offset a to the byte located at offset b.
.macro compare_addr_to_addr a:req, b:req
.byte 0x20
.4byte \a
.4byte \b
.endm
@ Compares the value of `var` to a fixed word value (b).
.macro compare_var_to_value var:req, value:req
.byte 0x21
.2byte \var
.2byte \value
.endm
@ Compares the value of `var1` to the value of `var2`.
.macro compare_var_to_var var1:req, var2:req
.byte 0x22
.2byte \var1
.2byte \var2
.endm
@ Generic compare macro which attempts to deduce argument types based on their values
@ Any values between 0x4000 to 0x40FF and 0x8000 to 0x8015 are considered event variable identifiers
.macro compare var:req, arg:req
.if ((\arg >= VARS_START && \arg <= VARS_END) || (\arg >= SPECIAL_VARS_START && \arg <= SPECIAL_VARS_END))
compare_var_to_var \var, \arg
.else
compare_var_to_value \var, \arg
.endif
.endm
@ Calls the native C function stored at `func`.
.macro callnative func:req
.byte 0x23
.4byte \func
.endm
@ Replaces the script with the function stored at `func`. Execution returns to the bytecode script when func returns TRUE.
.macro gotonative func:req
.byte 0x24
.4byte \func
.endm
@ Calls a special function; that is, a function designed for use by scripts and listed in a table of pointers.
.macro special function:req
.byte 0x25
.2byte SPECIAL_\function
.endm
@ Calls a special function. That function's output (if any) will be written to the variable you specify.
.macro specialvar output:req, function:req
.byte 0x26
.2byte \output
.2byte SPECIAL_\function
.endm
@ temporary solution
.macro specialvar_ output:req, functionId:req
.byte 0x26
.2byte \output
.2byte \functionId
.endm
@ Blocks script execution until a command or ASM code manually unblocks it. Generally used with specific
@ commands and specials. If this command runs, and a subsequent command or piece of ASM does not unblock
@ state, the script will remain blocked indefinitely (essentially a hang).
.macro waitstate
.byte 0x27
.endm
@ Blocks script execution for frames. (Pokemon Emerald runs at just shy of 60 frames per second.)
.macro delay frames:req
.byte 0x28
.2byte \frames
.endm
@ Sets a to 1.
.macro setflag a:req
.byte 0x29
.2byte \a
.endm
@ Sets a to 0.
.macro clearflag a:req
.byte 0x2a
.2byte \a
.endm
@ Compares a to 1.
.macro checkflag a:req
.byte 0x2b
.2byte \a
.endm
@ Initializes the RTC`s local time offset to the given hour and minute. In FireRed, this command is a nop.
.macro initclock hour:req, minute:req
.byte 0x2c
.2byte \hour
.2byte \minute
.endm
@ Runs time based events. In FireRed, this command is a nop.
.macro dotimebasedevents
.byte 0x2d
.endm
@ Sets the values of variables 0x8000, 0x8001, and 0x8002 to the current hour, minute, and second. In FRLG,
@ this command sets those variables to zero.
.macro gettime
.byte 0x2e
.endm
@ Plays the specified (sound_number) sound. Only one sound may play at a time, with newer ones interrupting older ones.
.macro playse sound_number:req
.byte 0x2f
.2byte \sound_number
.endm
@ Blocks script execution until the currently-playing sound (triggered by playse) finishes playing.
.macro waitse
.byte 0x30
.endm
@ Plays the specified (fanfare_number) fanfare.
.macro playfanfare fanfare_number:req
.byte 0x31
.2byte \fanfare_number
.endm
@ Blocks script execution until all currently-playing fanfares finish.
.macro waitfanfare
.byte 0x32
.endm
@ Plays the specified (song_number) song. If save_song is TRUE, the
@ specified (song_number) will be saved as if savebgm was called with it.
.macro playbgm song_number:req, save_song:req
.byte 0x33
.2byte \song_number
.byte \save_song
.endm
@ Saves the specified (song_number) song to be played later.
.macro savebgm song_number:req
.byte 0x34
.2byte \song_number
.endm
@ Crossfades the currently-playing song into the map's default song.
.macro fadedefaultbgm
.byte 0x35
.endm
@ Crossfades the currently-playng song into the specified (song_number) song.
.macro fadenewbgm song_number:req
.byte 0x36
.2byte \song_number
.endm
@ Fades out the currently-playing song.
.macro fadeoutbgm speed:req
.byte 0x37
.byte \speed
.endm
@ Fades the previously-playing song back in.
.macro fadeinbgm speed:req
.byte 0x38
.byte \speed
.endm
@ Sends the player to Warp warp on Map bank.map. If the specified warp is 0xFF,
@ then the player will instead be sent to (X, Y) on the map.
.macro warp map:req, warp:req, X:req, Y:req
.byte 0x39
map \map
.byte \warp
.2byte \X
.2byte \Y
.endm
@ Clone of warp that does not play a sound effect.
.macro warpsilent map:req, warp:req, X:req, Y:req
.byte 0x3a
map \map
.byte \warp
.2byte \X
.2byte \Y
.endm
@ Clone of warp that plays a door opening animation before stepping upwards into it.
.macro warpdoor map:req, warp:req, X:req, Y:req
.byte 0x3b
map \map
.byte \warp
.2byte \X
.2byte \Y
.endm
@ Warps the player to another map using a hole animation.
.macro warphole map:req
.byte 0x3c
map \map
.endm
@ Clone of warp that uses a teleport effect. It is apparently only used in R/S/E.
.macro warpteleport map:req, warp:req, X:req, Y:req
.byte 0x3d
map \map
.byte \warp
.2byte \X
.2byte \Y
.endm
@ Sets the warp destination to be used later.
.macro setwarp map:req, warp:req, X:req, Y:req
.byte 0x3e
map \map
.byte \warp
.2byte \X
.2byte \Y
.endm
@ Sets the warp destination that a warp to Warp 127 on Map 127.127 will connect to.
@ Useful when a map has warps that need to go to script-controlled locations (i.e. elevators).
.macro setdynamicwarp map:req, warp:req, X:req, Y:req
.byte 0x3f
map \map
.byte \warp
.2byte \X
.2byte \Y
.endm
@ Sets the destination that diving or emerging from a dive will take the player to.
.macro setdivewarp map:req, warp:req, X:req, Y:req
.byte 0x40
map \map
.byte \warp
.2byte \X
.2byte \Y
.endm
@ Sets the destination that falling into a hole will take the player to.
.macro setholewarp map:req, warp:req, X:req, Y:req
.byte 0x41
map \map
.byte \warp
.2byte \X
.2byte \Y
.endm
@ Retrieves the player's zero-indexed X- and Y-coordinates in the map, and stores them in the specified variables.
.macro getplayerxy X:req, Y:req
.byte 0x42
.2byte \X
.2byte \Y
.endm
@ Retrieves the number of Pokemon in the player's party, and stores that number in VAR_RESULT.
.macro getpartysize
.byte 0x43
.endm
@ Attempts to add quantity of item index to the player's Bag. If the player has enough room, the item will be added and
@ VAR_RESULT will be set to TRUE; otherwise, VAR_RESULT is set to FALSE.
.macro additem index:req, quantity=1
.byte 0x44
.2byte \index
.2byte \quantity
.endm
@ Removes quantity of item index from the player's Bag.
.macro removeitem index:req, quantity=1
.byte 0x45
.2byte \index
.2byte \quantity
.endm
@ Checks if the player has enough space in their Bag to hold quantity more of item index. Sets VAR_RESULT to
@ TRUE if there is room, or FALSE is there is no room.
.macro checkitemspace index:req, quantity:req
.byte 0x46
.2byte \index
.2byte \quantity
.endm
@ Checks if the player has quantity or more of item index in their Bag. Sets VAR_RESULT to TRUE if the player has
@ enough of the item, or FALSE if they have fewer than quantity of the item.
.macro checkitem index:req, quantity:req
.byte 0x47
.2byte \index
.2byte \quantity
.endm
@ Checks which Bag pocket the specified item belongs in, and writes the pocket value (POCKET_*) to VAR_RESULT.
@ This script is used to show the name of the proper Bag pocket when the player receives an item via callstd (simplified to giveitem in XSE).
.macro checkitemtype index:req
.byte 0x48
.2byte \index
.endm
@ Adds a quantity amount of item index to the player's PC. Both arguments can be variables.
.macro addpcitem index:req, quantity:req
.byte 0x49
.2byte \index
.2byte \quantity
.endm
@ Checks for quantity amount of item index in the player's PC. Both arguments can be variables.
.macro checkpcitem index:req, quantity:req
.byte 0x4a
.2byte \index
.2byte \quantity
.endm
@ Adds decoration to the player's PC. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
.macro adddecoration decoration:req
.byte 0x4b
.2byte \decoration
.endm
@ Removes a decoration from the player's PC. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
.macro removedecoration decoration:req
.byte 0x4c
.2byte \decoration
.endm
@ Checks for decoration in the player's PC. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
.macro checkdecor decoration:req
.byte 0x4d
.2byte \decoration
.endm
@ Checks if the player has enough space in their PC to hold decoration. Sets VAR_RESULT to TRUE if there is room, or
@ FALSE is there is no room. In FireRed, this command is a nop. (The argument is read, but not used for anything.)
.macro checkdecorspace decoration:req
.byte 0x4e
.2byte \decoration
.endm
@ Applies the movement data at movements to the specified (index) Object. Also closes any standard message boxes that are still open.
@ If no map is specified, then the current map is used.
.macro applymovement index:req, movements:req, map
.ifb \map
.byte 0x4f
.2byte \index
.4byte \movements
.else
@ Really only useful if the object has followed from one map to another (e.g. Wally during the catching event).
.byte 0x50
.2byte \index
.4byte \movements
map \map
.endif
.endm
@ Blocks script execution until the movements being applied to the specified (index) Object finish.
@ If the specified Object is 0x0000, then the command will block script execution until all Objects
@ affected by applymovement finish their movements. If the specified Object is not currently being
@ manipulated with applymovement, then this command does nothing.
@ If no map is specified, then the current map is used.
.macro waitmovement index:req, map
.ifb \map
.byte 0x51
.2byte \index
.else
.byte 0x52
.2byte \index
map \map
.endif
.endm
@ Attempts to hide the specified (index) Object on the specified (map_group, map_num) map,
@ by setting its visibility flag if it has a valid one. If the Object does not have a valid
@ visibility flag, this command does nothing.
@ If no map is specified, then the current map is used.
.macro removeobject index:req, map
.ifb \map
.byte 0x53
.2byte \index
.else
.byte 0x54
.2byte \index
map \map
.endif
.endm
@ Unsets the specified (index) Object's visibility flag on the specified (map_group, map_num) map if it has a valid one.
@ If the Object does not have a valid visibility flag, this command does nothing.
@ If no map is specified, then the current map is used.
.macro addobject index:req, map
.ifb \map
.byte 0x55
.2byte \index
.else
.byte 0x56
.2byte \index
map \map
.endif
.endm
@ Sets the specified (index) Object's position on the current map.
.macro setobjectxy index:req, x:req, y:req
.byte 0x57
.2byte \index
.2byte \x
.2byte \y
.endm
.macro showobjectat index:req, map:req
.byte 0x58
.2byte \index
map \map
.endm
.macro hideobjectat index:req, map:req
.byte 0x59
.2byte \index
map \map
.endm
@ If the script was called by an Object, then that Object will turn to face toward the metatile that the player is standing on.
.macro faceplayer
.byte 0x5a
.endm
.macro turnobject index:req, direction:req
.byte 0x5b
.2byte \index
.byte \direction
.endm
@ If the Trainer flag for Trainer index is not set, this command does absolutely nothing.
.macro trainerbattle type:req, trainer:req, local_id:req, pointer1:req, pointer2, pointer3, pointer4
.byte 0x5c
.byte \type
.2byte \trainer
.2byte \local_id
.if \type == TRAINER_BATTLE_SINGLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ event script
.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ event script
.elseif \type == TRAINER_BATTLE_SINGLE_NO_INTRO_TEXT
.4byte \pointer1 @ text
.elseif \type == TRAINER_BATTLE_DOUBLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.elseif \type == TRAINER_BATTLE_REMATCH
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.4byte \pointer4 @ event script
.elseif \type == TRAINER_BATTLE_REMATCH_DOUBLE
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.elseif \type == TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.4byte \pointer3 @ text
.4byte \pointer4 @ event script
.elseif \type == TRAINER_BATTLE_PYRAMID
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_SET_TRAINER_A
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_SET_TRAINER_B
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.elseif \type == TRAINER_BATTLE_HILL
.4byte \pointer1 @ text
.4byte \pointer2 @ text
.endif
.endm
NO_MUSIC = FALSE
@ Starts a single trainer battle, takes a trainer, intro text, loss text, and an optional event script
@ when used with an event script, you can also pass in an optional flag to disable music
.macro trainerbattle_single trainer:req, intro_text:req, lose_text:req, event_script=FALSE, music=TRUE
.if \event_script == FALSE
trainerbattle TRAINER_BATTLE_SINGLE, \trainer, 0, \intro_text, \lose_text
.elseif \music == TRUE
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT, \trainer, 0, \intro_text, \lose_text, \event_script
.else
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT_NO_MUSIC, \trainer, 0, \intro_text, \lose_text, \event_script
.endif
.endm
@ Starts a double trainer battle, takes a trainer, intro text, loss text, text for when you have too few pokemon
@ and an optional event script, when used with an event script you can pass in an optional flag to disable music
.macro trainerbattle_double trainer:req, intro_text:req, lose_text:req, not_enough_pkmn_text:req, event_script=FALSE, music=TRUE
.if \event_script == FALSE
trainerbattle TRAINER_BATTLE_DOUBLE, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text
.elseif \music == TRUE
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text, \event_script
.else
trainerbattle TRAINER_BATTLE_CONTINUE_SCRIPT_DOUBLE_NO_MUSIC, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text, \event_script
.endif
.endm
@ Starts a rematch battle, takes a trainer, intro text and loss text
.macro trainerbattle_rematch trainer:req, intro_text:req, lose_text:req
trainerbattle TRAINER_BATTLE_REMATCH, \trainer, 0, \intro_text, \lose_text
.endm
@ Starts a rematch double battle, takes a trainer, intro text, loss text, and text for when you have too few pokemon
.macro trainerbattle_rematch_double trainer:req, intro_text:req, lose_text:req, not_enough_pkmn_text:req
trainerbattle TRAINER_BATTLE_REMATCH_DOUBLE, \trainer, 0, \intro_text, \lose_text, \not_enough_pkmn_text
.endm
@ Starts a trainer battle, skipping intro text, takes a trainer and loss text
.macro trainerbattle_no_intro trainer:req, lose_text:req
trainerbattle TRAINER_BATTLE_SINGLE_NO_INTRO_TEXT, \trainer, 0, \lose_text
.endm
@ Starts a trainer battle using the battle information stored in RAM (usually by trainerbattle, which actually calls this
@ command behind-the-scenes), and blocks script execution until the battle finishes.
.macro trainerbattlebegin
.byte 0x5d
.endm
@ Goes to address after the trainerbattle command (called by the battle functions, see battle_setup.c)
.macro gotopostbattlescript
.byte 0x5e
.endm
@ Goes to address specified in the trainerbattle command (called by the battle functions, see battle_setup.c)
.macro gotobeatenscript
.byte 0x5f
.endm
@ Compares Flag (trainer + 0x500) to 1. (If the flag is set, then the trainer has been defeated by the player.)
.macro checktrainerflag trainer:req
.byte 0x60
.2byte \trainer
.endm
@ Sets Flag (trainer + 0x500).
.macro settrainerflag trainer:req
.byte 0x61
.2byte \trainer
.endm
@ Clears Flag (trainer + 0x500).
.macro cleartrainerflag trainer:req
.byte 0x62
.2byte \trainer
.endm
.macro setobjectxyperm index:req, x:req, y:req
.byte 0x63
.2byte \index
.2byte \x
.2byte \y
.endm
@ Copies a live object event's xy position to its template, so that if the sprite goes off screen,
@ it'll still be there when it comes back on screen.
.macro copyobjectxytoperm index:req
.byte 0x64
.2byte \index
.endm
.macro setobjectmovementtype word:req, byte:req
.byte 0x65
.2byte \word
.byte \byte
.endm
@ If a standard message box (or its text) is being drawn on-screen, this command blocks script execution until the
@ box and its text have been fully drawn.
.macro waitmessage
.byte 0x66
.endm
@ Starts displaying a standard message box containing the specified text. If text is a pointer, then the string at
@ that offset will be loaded and used. If text is script bank 0, then the value of script bank 0 will be treated as
@ a pointer to the text. (You can use loadpointer to place a string pointer in a script bank.)
.macro message text:req
.byte 0x67
.4byte \text
.endm
@ Closes the current message box.
.macro closemessage
.byte 0x68
.endm
@ Freezes all objects immediately except the player. The player is frozen once their movement is finished.
.macro lockall
.byte 0x69
.endm
@ Freezes all objects immediately except the player and the selected object. The player and selected object are frozen once their movement is finished.
.macro lock
.byte 0x6a
.endm
@ Resumes normal movement for all Objects on-screen, and closes any standard message boxes that are still open.
.macro releaseall
.byte 0x6b
.endm
@ If the script was called by an Object, then that Object's movement will resume. This command also closes any standard message boxes that are still open.
.macro release
.byte 0x6c
.endm
@ Blocks script execution until the player presses any key.
.macro waitbuttonpress
.byte 0x6d
.endm
@ Displays a YES/NO multichoice box at the specified coordinates, and blocks script execution until the user makes a selection.
@ Their selection is stored in VAR_RESULT as NO (0) or YES (1). Pressing B is equivalent to answering NO
.macro yesnobox x:req, y:req
.byte 0x6e
.byte \x
.byte \y
.endm
@ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made.
@ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with multichoiceId.
@ If ignoreBPress is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
.macro multichoice x:req, y:req, multichoiceId:req, ignoreBPress:req
.byte 0x6f
.byte \x
.byte \y
.byte \multichoiceId
.byte \ignoreBPress
.endm
@ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made.
@ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with multichoiceId.
@ The default argument determines the initial position of the cursor when the box is first opened; it is zero-indexed, and if it is too large, it is treated as 0x00.
@ If ignoreBPress is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
.macro multichoicedefault x:req, y:req, multichoiceId:req, default:req, ignoreBPress:req
.byte 0x70
.byte \x
.byte \y
.byte \multichoiceId
.byte \default
.byte \ignoreBPress
.endm
@ Displays a multichoice box from which the user can choose a selection, and blocks script execution until a selection is made.
@ Lists of options are predefined (sMultichoiceLists) and the one to be used is specified with multichoiceId.
@ The per_row argument determines how many list items will be shown on a single row of the box.
@ If ignoreBPress is set to a non-zero value, then the user will not be allowed to back out of the multichoice with the B button.
.macro multichoicegrid x:req, y:req, multichoiceId:req, per_row:req, ignoreBPress:req
.byte 0x71
.byte \x
.byte \y
.byte \multichoiceId
.byte \per_row
.byte \ignoreBPress
.endm
@ Nopped in Emerald.
.macro drawbox
.byte 0x72
.endm
@ Nopped in Emerald, but still consumes parameters.
.macro erasebox left:req, top:req, right:req, bottom:req
.byte 0x73
.byte \left
.byte \top
.byte \right
.byte \bottom
.endm
@ Nopped in Emerald, but still consumes parameters.
.macro drawboxtext left:req, top:req, multichoiceId:req, ignoreBPress:req
.byte 0x74
.byte \left
.byte \top
.byte \multichoiceId
.byte \ignoreBPress
.endm
@ Displays a box containing the front sprite for the specified (species) Pokemon species.
.macro showmonpic species:req, x:req, y:req
.byte 0x75
.2byte \species
.byte \x
.byte \y
.endm
@ Hides all boxes displayed with showmonpic.
.macro hidemonpic
.byte 0x76
.endm
@ Draws an image of the winner of the contest. winnerId is any CONTEST_WINNER_* constant.
.macro showcontestpainting winnerId:req
.byte 0x77
.byte \winnerId
.endm
@ Displays the string at pointer as braille text in a standard message box. The string must be formatted to use braille
@ characters and needs to provide six extra starting characters that are skipped (in RS, these characters determined the
@ box's size and position, but in Emerald these are calculated automatically).
.macro braillemessage text:req
.byte 0x78
.4byte \text
.endm
@ Formatting for the braille window, to be put at the start of a pointer used by braillemessage.
@ These are from RS and are ignored in Emerald (see ScrCmd_braillemessage, and comment above)
.macro brailleformat winLeft:req, winTop:req, winRight:req, winBottom:req, textLeft:req, textTop:req
.byte \winLeft
.byte \winTop
.byte \winRight
.byte \winBottom
.byte \textLeft
.byte \textTop
.endm
@ Gives the player one of the specified (species) Pokemon at level level holding item. The trailing 0s are unused parameters
.macro givemon species:req, level:req, item:req
.byte 0x79
.2byte \species
.byte \level
.2byte \item
.4byte 0x0
.4byte 0x0
.byte 0
.endm
.macro giveegg species:req
.byte 0x7a
.2byte \species
.endm
.macro setmonmove index:req, slot:req, move:req
.byte 0x7b
.byte \index
.byte \slot
.2byte \move
.endm
@ Checks if at least one Pokemon in the player's party knows the specified (index) attack. If so, VAR_RESULT is set to the
@ (zero-indexed) slot number of the first Pokemon that knows the move. If not, VAR_RESULT is set to PARTY_SIZE.
@ VAR_0x8004 is also set to this Pokemon's species.
.macro checkpartymove index:req
.byte 0x7c
.2byte \index
.endm
@ Writes the name of the Pokemon at index species to the specified buffer.
.macro bufferspeciesname out:req, species:req
.byte 0x7d
.byte \out
.2byte \species
.endm
@ Writes the name of the species of the first Pokemon in the player's party to the specified buffer.
.macro bufferleadmonspeciesname out:req
.byte 0x7e
.byte \out
.endm
@ Writes the nickname of the Pokemon in slot slot (zero-indexed) of the player's party to the specified buffer.
@ If an empty or invalid slot is specified, ten spaces ("") are written to the buffer.
.macro bufferpartymonnick out:req, slot:req
.byte 0x7f
.byte \out
.2byte \slot
.endm
@ Writes the name of the item at index item to the specified buffer. If the specified index is larger than
@ the number of items in the game (0x176), the name of item 0 ("????????") is buffered instead.