forked from Skeli789/Complete-Fire-Red-Upgrade
-
Notifications
You must be signed in to change notification settings - Fork 0
/
battle_script_macros.s
1698 lines (1378 loc) · 24.6 KB
/
battle_script_macros.s
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
@Useful Stuff
@Battle Scripts
@.equ FAILED, 0x81D7DF2
.equ NOEFFECT, 0x81D7E04
.equ ABSORB_REBRANCHER, 0x81D694E
.equ BS_MOVE_FAINT, 0x81D6947
.equ BS_MOVE_END, 0x81D694E
.equ BS_MAKE_MOVE_MISS, 0x81D6958
.equ BS_MOVE_MISSED, 0x81D695E
.equ BS_MOVE_MISSED_PAUSE, 0x81D6960
.equ BS_BUFF_ATK_STATS, 0x81D6B9E
.equ BS_MOVE_WEATHER_CHANGE, 0x81D7A14
.equ BS_FLUSH_MSGBOX, 0x81D96A8
.equ BS_HIT_FROM_ATTACKSTRING, 0x81D692E
.equ BS_HIT_FROM_DAMAGE_CALC, 0x81D6930
.equ BS_HIT_FROM_ATTACKANIMATION, 0x81D6934
.equ BS_STANDARD_HIT, 0x81D6926
.equ BS_FLUSH_MESSAGE_BOX, 0x81D96A8
@Banks
.equ BANK_TARGET, 0x0
.equ BANK_ATTACKER, 0x1
.equ BANK_EFFECT, 0x2
.equ BANK_FAINTED, 0x3
.equ BANK_SCRIPTING, 0xA
.equ BANK_PLAYER_1, 0xB
.equ BANK_OPPONENT_1, 0xC
.equ BANK_PLAYER_2, 0xD
.equ BANK_OPPONENT_2, 0xE
@Comparisons
.equ EQUALS, 0x0
.equ NOTEQUALS, 0x1
.equ GREATERTHAN, 0x2
.equ LESSTHAN, 0x3
.equ ANDS, 0x4
.equ NOTANDS, 0x5
@Delays
.equ DELAY_1SECOND, 0x40
.equ DELAY_HALFSECOND, 0x20
@Booleans
.equ FALSE, 0x0
.equ TRUE, 0x1
@Macros
.macro calculatedamage
critcalc
damagecalc
typecalc
adjustnormaldamage
.endm
.macro returnopponentmon1toball bank
.byte 0x76
.byte \bank
.byte 0x9
.endm
.macro returnopponentmon2toball bank
.byte 0x77
.byte \bank
.byte 0xA
.endm
.macro forfeityesnobox bank
.byte 0x77
.byte \bank
.byte 0xD
.endm
.macro jumpifmove compare, rom_address
.byte 0x2a
.byte EQUALS
.4byte CURRENT_MOVE
.2byte \compare
.4byte \rom_address
.endm
.macro jumpifnotmove compare, rom_address
.byte 0x2a
.byte NOTEQUALS
.4byte CURRENT_MOVE
.2byte \compare
.4byte \rom_address
.endm
.macro setmoveeffect effect
.byte 0x2E
.word EFFECT_BYTE
.byte \effect
.endm
.macro setstatchanger stat
.byte 0x2E
.word STAT_CHANGE_BYTE
.byte \stat
.endm
.macro jumpifmovehadnoeffect rom_address
.byte 0x29
.byte ANDS
.word OUTCOME
.byte OUTCOME_NO_EFFECT
.word \rom_address
.endm
.macro jumpifbehindsubstitute bank rom_address
.byte 0x1D
.byte \bank
.word STATUS2_SUBSTITUTE
.word \rom_address
.endm
.macro jumpifweather weather rom_address
.byte 0x2a
.byte ANDS
.word WEATHER_FLAGS
.hword \weather
.word \rom_address
.endm
.macro jumpifabilitypreventsstatloss bank rom_address
.byte 0x1E
.byte \bank
.byte ABILITY_CLEARBODY
.word \rom_address
.byte 0x1E
.byte \bank
.byte ABILITY_WHITESMOKE
.word \rom_address
.byte 0x1E
.byte \bank
.byte ABILITY_FULLMETALBODY
.word \rom_address
.endm
.macro jumpifstatcanbelowered bank stat rom_address
.byte 0xFF, 0x15
.byte \bank
.byte \stat
.byte 0x1 @ATK48_STAT_NEGATIVE
.4byte \rom_address
.endm
.macro jumpifstatcanberaised bank stat rom_address
.byte 0xFF, 0x15
.byte \bank
.byte \stat
.byte 0x0
.4byte \rom_address
.endm
.macro jumpifbattletype battle_type rom_address
.byte 0x2B
.byte ANDS
.word BATTLE_TYPE
.word \battle_type
.word \rom_address
.endm
.macro jumpifnotbattletype battle_type rom_address
.byte 0x2B
.byte NOTANDS
.word BATTLE_TYPE
.word \battle_type
.word \rom_address
.endm
.macro getifcantrunfrombattle bank
.byte 0x76
.byte \bank
.byte 0x2
.endm
.macro copybyte destination source
.byte 0x31
.4byte \destination
.4byte \source
.byte 0x1
.endm
.macro copyhword destination source
.byte 0x31
.4byte \destination
.4byte \source
.byte 0x2
.endm
.macro copyword destination source
.byte 0x31
.4byte \destination
.4byte \source
.byte 0x4
.endm
.macro attackcanceler
.byte 0x00
.endm
.macro accuracycheck rom_address, param1
.byte 0x01
.4byte \rom_address
.2byte \param1
.endm
.macro attackstring
.byte 0x02
.endm
.macro ppreduce
.byte 0x03
.endm
.macro critcalc
.byte 0x04
.endm
.macro damagecalc
.byte 0x05
.endm
.macro typecalc
.byte 0x06
.endm
.macro adjustnormaldamage
.byte 0x07
.endm
.macro adjustnormaldamage2
.byte 0x08
.endm
.macro attackanimation
.byte 0x09
.endm
.macro waitanimation
.byte 0x0a
.endm
.macro graphicalhpupdate bank
.byte 0x0b
.byte \bank
.endm
.macro datahpupdate bank
.byte 0x0c
.byte \bank
.endm
.macro critmessage
.byte 0x0d
.endm
.macro effectivenesssound
.byte 0x0e
.endm
.macro resultmessage
.byte 0x0f
.endm
.macro printstring string
.byte 0x10
.2byte \string
.endm
.macro printselectionstring string
.byte 0x11
.2byte \string
.endm
.macro waitmessage delay
.byte 0x12
.2byte \delay
.endm
.macro printfromtable table
.byte 0x13
.4byte \table
.endm
.macro printfromtable2 table
.byte 0x14
.4byte \table
.endm
.macro seteffectwithchancetarget
.byte 0x15
.endm
.macro seteffecttarget
.byte 0x16
.endm
.macro seteffectuser
.byte 0x17
.endm
.macro clearstatus bank
.byte 0x18
.byte \bank
.endm
.macro faintpokemon bank, param2, param3
.byte 0x19
.byte \bank
.byte \param2
.4byte \param3
.endm
.macro dofaintanimation param1
.byte 0x1a
.byte \param1
.endm
.macro cleareffectsonfaint bank
.byte 0x1b
.byte \bank
.endm
.macro jumpifstatus bank, status, rom_address
.byte 0x1c
.byte \bank
.4byte \status
.4byte \rom_address
.endm
.macro jumpifsecondarystatus bank, status, rom_address
.byte 0x1d
.byte \bank
.4byte \status
.4byte \rom_address
.endm
.macro jumpifability bank, ability, rom_address
.byte 0x1e
.byte \bank
.byte \ability
.4byte \rom_address
.endm
.macro jumpifsideaffecting bank, status, rom_address
.byte 0x1f
.byte \bank
.2byte \status
.4byte \rom_address
.endm
.macro jumpifstat bank, predicate, statid, quantity, rom_address
.byte 0x20
.byte \bank
.byte \predicate
.byte \statid
.byte \quantity
.4byte \rom_address
.endm
.macro jumpifspecialstatusflag bank, mask, status, rom_address
.byte 0x21
.byte \bank
.4byte \mask
.byte \status
.4byte \rom_address
.endm
.macro jumpiftype bank, type, rom_address
.byte 0x22
.byte \bank
.byte \type
.4byte \rom_address
.endm
.macro getexp bank
.byte 0x23
.byte \bank
.endm
.macro ifwildbattleend rom_address
.byte 0x24
.4byte \rom_address
.endm
.macro movevaluescleanup
.byte 0x25
.endm
.macro storeloopingcounter param1
.byte 0x26
.byte \param1
.endm
.macro decrementmultihit rom_address
.byte 0x27
.4byte \rom_address
.endm
.macro goto rom_address
.byte 0x28
.4byte \rom_address
.endm
.macro jumpifbyte predicate, checkaddr, compare, rom_address
.byte 0x29
.byte \predicate
.4byte \checkaddr
.byte \compare
.4byte \rom_address
.endm
.macro jumpifhalfword predicate, checkaddr, compare, rom_address
.byte 0x2a
.byte \predicate
.4byte \checkaddr
.2byte \compare
.4byte \rom_address
.endm
.macro jumpifword predicate, checkaddr, compare, rom_address
.byte 0x2b
.byte \predicate
.4byte \checkaddr
.4byte \compare
.4byte \rom_address
.endm
.macro jumpifarrayequal mem1, mem2, size, rom_address
.byte 0x2c
.4byte \mem1
.4byte \mem2
.byte \size
.4byte \rom_address
.endm
.macro jumpifarraynotequal mem1, mem2, size, rom_address
.byte 0x2d
.4byte \mem1
.4byte \mem2
.byte \size
.4byte \rom_address
.endm
.macro setbyte pointer, value
.byte 0x2e
.4byte \pointer
.byte \value
.endm
.macro addbyte pointer, value
.byte 0x2f
.4byte \pointer
.byte \value
.endm
.macro subtractbyte pointer, value
.byte 0x30
.4byte \pointer
.byte \value
.endm
.macro copyarray destination, source, size
.byte 0x31
.4byte \destination
.4byte \source
.byte \size
.endm
.macro copyarraywithindex destination, source, index, size
.byte 0x32
.4byte \destination
.4byte \source
.4byte \index
.byte \size
.endm
.macro orbyte pointer, value
.byte 0x33
.4byte \pointer
.byte \value
.endm
.macro orhalfword pointer, value
.byte 0x34
.4byte \pointer
.2byte \value
.endm
.macro orword pointer, value
.byte 0x35
.4byte \pointer
.4byte \value
.endm
.macro bicbyte pointer, value
.byte 0x36
.4byte \pointer
.byte \value
.endm
.macro bichalfword pointer, value
.byte 0x37
.4byte \pointer
.2byte \value
.endm
.macro bicword pointer, value
.byte 0x38
.4byte \pointer
.4byte \value
.endm
.macro pause delay
.byte 0x39
.2byte \delay
.endm
.macro waitstateatk
.byte 0x3a
.endm
.macro healthbarupdate bank
.byte 0x3b
.byte \bank
.endm
.macro return
.byte 0x3c
.endm
.macro end
.byte 0x3d
.endm
.macro end2
.byte 0x3e
.endm
.macro end3
.byte 0x3f
.endm
.macro jumpifaffectedbyprotect rom_address
.byte 0x40
.4byte \rom_address
.endm
.macro call rom_address
.byte 0x41
.4byte \rom_address
.endm
.macro jumpiftype2 bank, type, rom_address
.byte 0x42
.byte \bank
.byte \type
.4byte \rom_address
.endm
.macro jumpifabilitypresent ability, rom_address
.byte 0x43
.byte \ability
.4byte \rom_address
.endm
.macro endselectionscript
.byte 0x44
.endm
.macro playanimation bank, animation, var_address
.byte 0x45
.byte \bank
.byte \animation
.4byte \var_address
.endm
.macro playanimation2 bank, mem_address, int
.byte 0x46
.byte \bank
.4byte \mem_address
.4byte \int
.endm
.macro setgraphicalstatchangevalues
.byte 0x47
.endm
.macro playstatchangeanimation bank, color, int
.byte 0x48
.byte \bank
.byte \color
.byte \int
.endm
.macro cmd49 bank, int
.byte 0x49
.byte \bank
.byte \int
.endm
.macro typecalc2
.byte 0x4a
.endm
.macro returnatktoball
.byte 0x4b
.endm
.macro switch1 bank
.byte 0x4c
.byte \bank
.endm
.macro switch2 bank
.byte 0x4d
.byte \bank
.endm
.macro switch3 bank, int
.byte 0x4e
.byte \bank
.byte \int
.endm
.macro jumpifcannotswitch bank, rom_address
.byte 0x4f
.byte \bank
.4byte \rom_address
.endm
.macro openpartyscreen bank, rom_address
.byte 0x50
.byte \bank
.4byte \rom_address
.endm
.macro switchhandleorder bank, param2
.byte 0x51
.byte \bank
.byte \param2
.endm
.macro switchineffects bank
.byte 0x52
.byte \bank
.endm
.macro trainerslidein bank
.byte 0x53
.byte \bank
.endm
.macro playse effect
.byte 0x54
.2byte \effect
.endm
.macro fanfare int
.byte 0x55
.4byte \int
.endm
.macro pokemonfaintcry bank_or_side
.byte 0x56
.byte \bank_or_side
.endm
.macro flee
.byte 0x57
.endm
.macro returntoball bank
.byte 0x58
.byte \bank
.endm
.macro handlelearnnewmove param1, param2, bank_maybe
.byte 0x59
.4byte \param1
.4byte \param2
.byte \bank_maybe
.endm
.macro yesnoboxlearnmove rom_address
.byte 0x5a
.4byte \rom_address
.endm
.macro yesnoboxstoplearningmove rom_address
.byte 0x5b
.4byte \rom_address
.endm
.macro flash bank
.byte 0x5c
.byte \bank
.endm
.macro getmoneyreward rom_address
.byte 0x5d
.4byte \rom_address
.endm
.macro atk5e bank
.byte 0x5e
.byte \bank
.endm
.macro swapattackerwithtarget
.byte 0x5f
.endm
.macro incrementgamestat int
.byte 0x60
.byte \int
.endm
.macro drawpartystatussummary bank
.byte 0x61
.byte \bank
.endm
.macro hidepartystatussummary bank
.byte 0x62
.byte \bank
.endm
.macro jumptoattack bank
.byte 0x63
.byte \bank
.endm
.macro statusanimation bank
.byte 0x64
.byte \bank
.endm
.macro status2animation bank, status2
.byte 0x65
.byte \bank
.4byte \status2
.endm
.macro chosenstatusanimation bank_or_side, bank_or_side2, status
.byte 0x66
.byte \bank_or_side
.byte \bank_or_side2
.4byte \status
.endm
.macro yesnobox
.byte 0x67
.endm
.macro cancelallactions
.byte 0x68
.endm
.macro adjustsetdamage
.byte 0x69
.endm
.macro removeitem bank
.byte 0x6a
.byte \bank
.endm
.macro atknameinbuff1
.byte 0x6b
.endm
.macro drawlvlupbox
.byte 0x6c
.endm
.macro resetsentmonsvalue
.byte 0x6d
.endm
.macro setatktoplayer0
.byte 0x6e
.endm
.macro makevisible bank
.byte 0x6f
.byte \bank
.endm
.macro recordlastability bank
.byte 0x70
.byte \bank
.endm
.macro buffermovetolearn
.byte 0x71
.endm
.macro jumpifplayerran rom_address
.byte 0x72
.4byte \rom_address
.endm
.macro hpthresholds bank
.byte 0x73
.byte \bank
.endm
.macro hpthresholds2 bank
.byte 0x74
.byte \bank
.endm
.macro useitemonopponent
.byte 0x75
.endm
.macro various bank, int
.byte 0x76
.byte \bank
.byte \int
.endm
.macro setprotect
.byte 0x77
.endm
.macro faintifabilitynotdamp
.byte 0x78
.endm
.macro setuserhptozero
.byte 0x79
.endm
.macro jumpwhiletargetvalid rom_address
.byte 0x7a
.4byte \rom_address
.endm
.macro setdamageasrestorehalfmaxhp rom_address, int
.byte 0x7b
.4byte \rom_address
.byte \int
.endm
.macro jumptolastusedattack
.byte 0x7c
.endm
.macro setrain
.byte 0x7d
.endm
.macro setreflect
.byte 0x7e
.endm
.macro setleechseed
.byte 0x7f
.endm
.macro manipulatedamage id
.byte 0x80
.byte \id
.endm
.macro setrest rom_address
.byte 0x81
.4byte \rom_address
.endm
.macro jumpifnotfirstturn rom_address
.byte 0x82
.4byte \rom_address
.endm
.macro nop3
.byte 0x83
.endm
.macro jumpifcannotsleep rom_address
.byte 0x84
.4byte \rom_address
.endm
.macro stockpile
.byte 0x85
.endm
.macro stockpiletobasedamage rom_address
.byte 0x86
.4byte \rom_address
.endm
.macro stockpiletohprecovery rom_address
.byte 0x87
.4byte \rom_address
.endm
.macro negativedamage
.byte 0x88
.endm
.macro statbuffchange target, rom_address
.byte 0x89
.byte \target
.4byte \rom_address
.endm
.macro normalisebuffs
.byte 0x8a
.endm
.macro setbide
.byte 0x8b
.endm
.macro confuseifrepeatingattackends
.byte 0x8c
.endm
.macro setloopcounter count
.byte 0x8d
.byte \count
.endm
.macro initmultihitstring
.byte 0x8e
.endm
.macro forcerandomswitch rom_address
.byte 0x8f
.4byte \rom_address
.endm
.macro changetypestoenemyattacktype rom_address
.byte 0x90
.4byte \rom_address
.endm
.macro givepaydaymoney
.byte 0x91
.endm
.macro setlightscreen
.byte 0x92
.endm
.macro tryKO rom_address
.byte 0x93
.4byte \rom_address
.endm
.macro gethalfcurrentenemyhp
.byte 0x94
.endm
.macro setsandstorm
.byte 0x95
.endm
.macro weatherdamage
.byte 0x96
.endm
.macro tryinfatuatebank bank rom_address
.byte 0x97
.byte \bank
.4byte \rom_address
.endm
.macro refreshhpbar bank
.byte 0x98
.byte \bank
.endm
.macro setmisteffect
.byte 0x99
.endm
.macro setincreasedcriticalchance
.byte 0x9a
.endm
.macro transformdataexecution
.byte 0x9b
.endm
.macro setsubstituteeffect
.byte 0x9c
.endm
.macro copyattack rom_address
.byte 0x9d
.4byte \rom_address
.endm
.macro metronomeeffect