diff options
Diffstat (limited to 'include')
29 files changed, 5586 insertions, 184 deletions
diff --git a/include/MPlayDef.s b/include/MPlayDef.s new file mode 100644 index 000000000..f5dd6484d --- /dev/null +++ b/include/MPlayDef.s @@ -0,0 +1,430 @@ + .equ W00, 0x80 @ WAIT + .equ W01, W00+1 @ + .equ W02, W00+2 @ + .equ W03, W00+3 @ + .equ W04, W00+4 @ + .equ W05, W00+5 @ + .equ W06, W00+6 @ + .equ W07, W00+7 @ + .equ W08, W00+8 @ + .equ W09, W00+9 @ + .equ W10, W00+10 @ + .equ W11, W00+11 @ + .equ W12, W00+12 @ + .equ W13, W00+13 @ + .equ W14, W00+14 @ + .equ W15, W00+15 @ + .equ W16, W00+16 @ + .equ W17, W00+17 @ + .equ W18, W00+18 @ + .equ W19, W00+19 @ + .equ W20, W00+20 @ + .equ W21, W00+21 @ + .equ W22, W00+22 @ + .equ W23, W00+23 @ + .equ W24, W00+24 @ + .equ W28, W00+25 @ + .equ W30, W00+26 @ + .equ W32, W00+27 @ + .equ W36, W00+28 @ + .equ W40, W00+29 @ + .equ W42, W00+30 @ + .equ W44, W00+31 @ + .equ W48, W00+32 @ + .equ W52, W00+33 @ + .equ W54, W00+34 @ + .equ W56, W00+35 @ + .equ W60, W00+36 @ + .equ W64, W00+37 @ + .equ W66, W00+38 @ + .equ W68, W00+39 @ + .equ W72, W00+40 @ + .equ W76, W00+41 @ + .equ W78, W00+42 @ + .equ W80, W00+43 @ + .equ W84, W00+44 @ + .equ W88, W00+45 @ + .equ W90, W00+46 @ + .equ W92, W00+47 @ + .equ W96, W00+48 @ + + .equ FINE, 0xb1 @ fine + .equ GOTO, 0xb2 @ goto + .equ PATT, 0xb3 @ pattern play + .equ PEND, 0xb4 @ pattern end + .equ REPT, 0xb5 @ repeat + .equ MEMACC, 0xb9 @ memacc op adr dat ***lib + .equ PRIO, 0xba @ priority + .equ TEMPO, 0xbb @ tempo (BPM/2) + .equ KEYSH, 0xbc @ key shift + .equ VOICE, 0xbd @ voice # + .equ VOL, 0xbe @ volume + .equ PAN, 0xbf @ panpot (c_v+??) + .equ BEND, 0xc0 @ pitch bend (c_v+??) + .equ BENDR, 0xc1 @ bend range + .equ LFOS, 0xc2 @ LFO speed + .equ LFODL, 0xc3 @ LFO delay + .equ MOD, 0xc4 @ modulation depth + .equ MODT, 0xc5 @ modulation type + .equ TUNE, 0xc8 @ micro tuning (c_v+??) + + .equ XCMD, 0xcd @ extend command ***lib + .equ xIECV, 0x08 @ imi.echo vol ***lib + .equ xIECL, 0x09 @ imi.echo len ***lib + + .equ EOT, 0xce @ End of Tie + .equ TIE, 0xcf @ + .equ N01, TIE+1 @ NOTE + .equ N02, N01+1 @ + .equ N03, N01+2 @ + .equ N04, N01+3 @ + .equ N05, N01+4 @ + .equ N06, N01+5 @ + .equ N07, N01+6 @ + .equ N08, N01+7 @ + .equ N09, N01+8 @ + .equ N10, N01+9 @ + .equ N11, N01+10 @ + .equ N12, N01+11 @ + .equ N13, N01+12 @ + .equ N14, N01+13 @ + .equ N15, N01+14 @ + .equ N16, N01+15 @ + .equ N17, N01+16 @ + .equ N18, N01+17 @ + .equ N19, N01+18 @ + .equ N20, N01+19 @ + .equ N21, N01+20 @ + .equ N22, N01+21 @ + .equ N23, N01+22 @ + .equ N24, N01+23 @ + .equ N28, N01+24 @ + .equ N30, N01+25 @ + .equ N32, N01+26 @ + .equ N36, N01+27 @ + .equ N40, N01+28 @ + .equ N42, N01+29 @ + .equ N44, N01+30 @ + .equ N48, N01+31 @ + .equ N52, N01+32 @ + .equ N54, N01+33 @ + .equ N56, N01+34 @ + .equ N60, N01+35 @ + .equ N64, N01+36 @ + .equ N66, N01+37 @ + .equ N68, N01+38 @ + .equ N72, N01+39 @ + .equ N76, N01+40 @ + .equ N78, N01+41 @ + .equ N80, N01+42 @ + .equ N84, N01+43 @ + .equ N88, N01+44 @ + .equ N90, N01+45 @ + .equ N92, N01+46 @ + .equ N96, N01+47 @ + +@ maximum value for volume + + .equ mxv, 0x7F @ + +@ center value of PAN, BEND, TUNE + + .equ c_v, 0x40 @ -64 ~ +63 + +@ note for N??, TIE, EOT + + .equ CnM2, 0 @ + .equ CsM2, 1 @ + .equ DnM2, 2 @ + .equ DsM2, 3 @ + .equ EnM2, 4 @ + .equ FnM2, 5 @ + .equ FsM2, 6 @ + .equ GnM2, 7 @ + .equ GsM2, 8 @ + .equ AnM2, 9 @ + .equ AsM2, 10 @ + .equ BnM2, 11 @ + .equ CnM1, 12 @ + .equ CsM1, 13 @ + .equ DnM1, 14 @ + .equ DsM1, 15 @ + .equ EnM1, 16 @ + .equ FnM1, 17 @ + .equ FsM1, 18 @ + .equ GnM1, 19 @ + .equ GsM1, 20 @ + .equ AnM1, 21 @ + .equ AsM1, 22 @ + .equ BnM1, 23 @ + .equ Cn0, 24 @ + .equ Cs0, 25 @ + .equ Dn0, 26 @ + .equ Ds0, 27 @ + .equ En0, 28 @ + .equ Fn0, 29 @ + .equ Fs0, 30 @ + .equ Gn0, 31 @ + .equ Gs0, 32 @ + .equ An0, 33 @ + .equ As0, 34 @ + .equ Bn0, 35 @ + .equ Cn1, 36 @ + .equ Cs1, 37 @ + .equ Dn1, 38 @ + .equ Ds1, 39 @ + .equ En1, 40 @ + .equ Fn1, 41 @ + .equ Fs1, 42 @ + .equ Gn1, 43 @ + .equ Gs1, 44 @ + .equ An1, 45 @ + .equ As1, 46 @ + .equ Bn1, 47 @ + .equ Cn2, 48 @ + .equ Cs2, 49 @ + .equ Dn2, 50 @ + .equ Ds2, 51 @ + .equ En2, 52 @ + .equ Fn2, 53 @ + .equ Fs2, 54 @ + .equ Gn2, 55 @ + .equ Gs2, 56 @ + .equ An2, 57 @ + .equ As2, 58 @ + .equ Bn2, 59 @ + .equ Cn3, 60 @ + .equ Cs3, 61 @ + .equ Dn3, 62 @ + .equ Ds3, 63 @ + .equ En3, 64 @ + .equ Fn3, 65 @ + .equ Fs3, 66 @ + .equ Gn3, 67 @ + .equ Gs3, 68 @ + .equ An3, 69 @ 440Hz + .equ As3, 70 @ + .equ Bn3, 71 @ + .equ Cn4, 72 @ + .equ Cs4, 73 @ + .equ Dn4, 74 @ + .equ Ds4, 75 @ + .equ En4, 76 @ + .equ Fn4, 77 @ + .equ Fs4, 78 @ + .equ Gn4, 79 @ + .equ Gs4, 80 @ + .equ An4, 81 @ + .equ As4, 82 @ + .equ Bn4, 83 @ + .equ Cn5, 84 @ + .equ Cs5, 85 @ + .equ Dn5, 86 @ + .equ Ds5, 87 @ + .equ En5, 88 @ + .equ Fn5, 89 @ + .equ Fs5, 90 @ + .equ Gn5, 91 @ + .equ Gs5, 92 @ + .equ An5, 93 @ + .equ As5, 94 @ + .equ Bn5, 95 @ + .equ Cn6, 96 @ + .equ Cs6, 97 @ + .equ Dn6, 98 @ + .equ Ds6, 99 @ + .equ En6, 100 @ + .equ Fn6, 101 @ + .equ Fs6, 102 @ + .equ Gn6, 103 @ + .equ Gs6, 104 @ + .equ An6, 105 @ + .equ As6, 106 @ + .equ Bn6, 107 @ + .equ Cn7, 108 @ + .equ Cs7, 109 @ + .equ Dn7, 110 @ + .equ Ds7, 111 @ + .equ En7, 112 @ + .equ Fn7, 113 @ + .equ Fs7, 114 @ + .equ Gn7, 115 @ + .equ Gs7, 116 @ + .equ An7, 117 @ + .equ As7, 118 @ + .equ Bn7, 119 @ + .equ Cn8, 120 @ + .equ Cs8, 121 @ + .equ Dn8, 122 @ + .equ Ds8, 123 @ + .equ En8, 124 @ + .equ Fn8, 125 @ + .equ Fs8, 126 @ + .equ Gn8, 127 @ + +@ velocity + + .equ v000, 0 @ + .equ v001, 1 @ + .equ v002, 2 @ + .equ v003, 3 @ + .equ v004, 4 @ + .equ v005, 5 @ + .equ v006, 6 @ + .equ v007, 7 @ + .equ v008, 8 @ + .equ v009, 9 @ + .equ v010, 10 @ + .equ v011, 11 @ + .equ v012, 12 @ + .equ v013, 13 @ + .equ v014, 14 @ + .equ v015, 15 @ + .equ v016, 16 @ + .equ v017, 17 @ + .equ v018, 18 @ + .equ v019, 19 @ + .equ v020, 20 @ + .equ v021, 21 @ + .equ v022, 22 @ + .equ v023, 23 @ + .equ v024, 24 @ + .equ v025, 25 @ + .equ v026, 26 @ + .equ v027, 27 @ + .equ v028, 28 @ + .equ v029, 29 @ + .equ v030, 30 @ + .equ v031, 31 @ + .equ v032, 32 @ + .equ v033, 33 @ + .equ v034, 34 @ + .equ v035, 35 @ + .equ v036, 36 @ + .equ v037, 37 @ + .equ v038, 38 @ + .equ v039, 39 @ + .equ v040, 40 @ + .equ v041, 41 @ + .equ v042, 42 @ + .equ v043, 43 @ + .equ v044, 44 @ + .equ v045, 45 @ + .equ v046, 46 @ + .equ v047, 47 @ + .equ v048, 48 @ + .equ v049, 49 @ + .equ v050, 50 @ + .equ v051, 51 @ + .equ v052, 52 @ + .equ v053, 53 @ + .equ v054, 54 @ + .equ v055, 55 @ + .equ v056, 56 @ + .equ v057, 57 @ + .equ v058, 58 @ + .equ v059, 59 @ + .equ v060, 60 @ + .equ v061, 61 @ + .equ v062, 62 @ + .equ v063, 63 @ + .equ v064, 64 @ + .equ v065, 65 @ + .equ v066, 66 @ + .equ v067, 67 @ + .equ v068, 68 @ + .equ v069, 79 @ + .equ v070, 70 @ + .equ v071, 71 @ + .equ v072, 72 @ + .equ v073, 73 @ + .equ v074, 74 @ + .equ v075, 75 @ + .equ v076, 76 @ + .equ v077, 77 @ + .equ v078, 78 @ + .equ v079, 79 @ + .equ v080, 80 @ + .equ v081, 81 @ + .equ v082, 82 @ + .equ v083, 83 @ + .equ v084, 84 @ + .equ v085, 85 @ + .equ v086, 86 @ + .equ v087, 87 @ + .equ v088, 88 @ + .equ v089, 89 @ + .equ v090, 90 @ + .equ v091, 91 @ + .equ v092, 92 @ + .equ v093, 93 @ + .equ v094, 94 @ + .equ v095, 95 @ + .equ v096, 96 @ + .equ v097, 97 @ + .equ v098, 98 @ + .equ v099, 99 @ + .equ v100, 100 @ + .equ v101, 101 @ + .equ v102, 102 @ + .equ v103, 103 @ + .equ v104, 104 @ + .equ v105, 105 @ + .equ v106, 106 @ + .equ v107, 107 @ + .equ v108, 108 @ + .equ v109, 109 @ + .equ v110, 110 @ + .equ v111, 111 @ + .equ v112, 112 @ + .equ v113, 113 @ + .equ v114, 114 @ + .equ v115, 115 @ + .equ v116, 116 @ + .equ v117, 117 @ + .equ v118, 118 @ + .equ v119, 119 @ + .equ v120, 120 @ + .equ v121, 121 @ + .equ v122, 122 @ + .equ v123, 123 @ + .equ v124, 124 @ + .equ v125, 125 @ + .equ v126, 126 @ + .equ v127, 127 @ + +@ exact gate time parameter for N?? + + .equ gtp1, 1 @ + .equ gtp2, 2 @ + .equ gtp3, 3 @ + +@ parameter of MODT + + .equ mod_vib,0 @ vibrate + .equ mod_tre,1 @ tremolo + .equ mod_pan,2 @ auto-panpot + +@ parameter of MEMACC + + .equ mem_set,0 @ + .equ mem_add,1 @ + .equ mem_sub,2 @ + .equ mem_mem_set,3 @ + .equ mem_mem_add,4 @ + .equ mem_mem_sub,5 @ + .equ mem_beq,6 @ + .equ mem_bne,7 @ + .equ mem_bhi,8 @ + .equ mem_bhs,9 @ + .equ mem_bls,10 @ + .equ mem_blo,11 @ + .equ mem_mem_beq,12 @ + .equ mem_mem_bne,13 @ + .equ mem_mem_bhi,14 @ + .equ mem_mem_bhs,15 @ + .equ mem_mem_bls,16 @ + .equ mem_mem_blo,17 @ + + .equ reverb_set,0x80 @ SOUND_MODE_REVERB_SET + .equ PAM, PAN @ diff --git a/include/config.h b/include/config.h index 6a77c4c74..796da359c 100644 --- a/include/config.h +++ b/include/config.h @@ -1,6 +1,28 @@ #ifndef GUARD_CONFIG_H #define GUARD_CONFIG_H +// In the Generation 3 games, Asserts were used in various debug builds. +// Ruby/Sapphire and Emerald do not have these asserts while Fire Red +// still has them in the ROM. This is because the developers forgot +// to define NDEBUG before release, however this has been changed as +// Ruby's actual debug build does not use the AGBPrint features. + +// To note, Ruby/Sapphire likely did not use AGBPrint. This is because +// the german debug ROM of Ruby did not have any uses of AGBPrint and +// the assert commands but instead a "crash" screen. This config exists +// for convenience for the user of pokeruby and NOT because it is +// authoritative. These additions are for user convenience based on +// officially recommended SDK practices for debugging and is therefore +// still in part authoritative. +#define NDEBUG + +// To enable print debugging, comment out "#define NDEBUG". This allows +// the various AGBPrint functions to be used. (See include/gba/isagbprint.h). +// Some emulators support a debug console window: uncomment NoCashGBAPrint() +// and NoCashGBAPrintf() in libisagbprn.c to use no$gba's own proprietary +// printing system. Use NoCashGBAPrint() and NoCashGBAPrintf() like you +// would normally use AGBPrint() and AGBPrintf(). + #ifndef REVISION #define REVISION 0 #endif diff --git a/include/credits.h b/include/credits.h new file mode 100644 index 000000000..dabe24048 --- /dev/null +++ b/include/credits.h @@ -0,0 +1,11 @@ +#ifndef GUARD_credits_H +#define GUARD_credits_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations +void sub_81439D0(void); + +#endif //GUARD_credits_H diff --git a/include/data2.h b/include/data2.h index 97cb4fd7a..9f6644714 100644 --- a/include/data2.h +++ b/include/data2.h @@ -3,7 +3,7 @@ #include "sprite.h" -struct UnknownTaskStruct; +struct ScanlineEffectParams; struct MonCoords { @@ -42,7 +42,7 @@ extern u8 gSpeciesNames[][11]; extern const u8 gMoveNames[][13]; extern const u8 gAbilityNames[][13]; extern const u8 gTypeNames[][7]; -extern const struct UnknownTaskStruct gUnknown_081F9674; +extern const struct ScanlineEffectParams gUnknown_081F9674; extern const u8 gUnknown_081F96C8[]; extern struct CompressedSpriteSheet gUnknown_081FAEA4; extern struct CompressedSpritePalette gUnknown_081FAEAC; diff --git a/include/gba/gba.h b/include/gba/gba.h index 42ae3cdde..349344031 100644 --- a/include/gba/gba.h +++ b/include/gba/gba.h @@ -7,5 +7,6 @@ #include "gba/multiboot.h" #include "gba/syscall.h" #include "gba/macro.h" +#include "gba/isagbprint.h" #endif // GUARD_GBA_GBA_H diff --git a/include/gba/isagbprint.h b/include/gba/isagbprint.h new file mode 100755 index 000000000..c5eb456c3 --- /dev/null +++ b/include/gba/isagbprint.h @@ -0,0 +1,50 @@ +#ifndef GUARD_GBA_ISAGBPRINT_H +#define GUARD_GBA_ISAGBPRINT_H + +#ifdef NDEBUG +#define AGBPrintInit() +#define AGBPutc(cChr) +#define AGBPrint(pBuf) +#define AGBPrintf(pBuf, ...) +#define AGBPrintFlush1Block() +#define AGBPrintFlush() +#define AGBAssert(pFile, nLine, pExpression, nStopProgram) +#else +void AGBPrintInit(void); +void AGBPutc(const char cChr); +void AGBPrint(const char *pBuf); +void AGBPrintf(const char *pBuf, ...); +void AGBPrintFlush1Block(void); +void AGBPrintFlush(void); +void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram); +#endif + +#undef AGB_ASSERT +#ifdef NDEBUG +#define AGB_ASSERT(exp) +#else +#define AGB_ASSERT(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 1); +#endif + +#undef AGB_WARNING +#ifdef NDEBUG +#define AGB_WARNING(exp) +#else +#define AGB_WARNING(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 0); +#endif + +// for matching purposes + +#ifdef NDEBUG +#define AGB_ASSERT_EX(exp, file, line) +#else +#define AGB_ASSERT_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 1); +#endif + +#ifdef NDEBUG +#define AGB_WARNING_EX(exp, file, line) +#else +#define AGB_WARNING_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 0); +#endif + +#endif // GUARD_GBA_ISAGBPRINT_H diff --git a/include/global.h b/include/global.h index eea1574b7..d0af4a4d1 100644 --- a/include/global.h +++ b/include/global.h @@ -1,8 +1,8 @@ #ifndef GUARD_GLOBAL_H #define GUARD_GLOBAL_H +#include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines. #include "gba/gba.h" -#include "config.h" // IDE support #if defined(__APPLE__) || defined(__CYGWIN__) diff --git a/include/hof_pc.h b/include/hof_pc.h new file mode 100644 index 000000000..c6df4e9a1 --- /dev/null +++ b/include/hof_pc.h @@ -0,0 +1,12 @@ +#ifndef GUARD_hof_pc_H +#define GUARD_hof_pc_H + +// Exported type declarations + +// Exported RAM declarations + +// Exported ROM declarations + +void ReturnFromHallOfFamePC(void); + +#endif //GUARD_hof_pc_H diff --git a/include/macros.inc b/include/macros.inc new file mode 100644 index 000000000..f34353079 --- /dev/null +++ b/include/macros.inc @@ -0,0 +1,149 @@ + .include "include/macros/asm.inc" + .include "include/macros/function.inc" + .include "include/macros/movement.inc" + .include "include/macros/pokemon_data.inc" + .include "include/macros/ec.inc" + .include "include/macros/map.inc" + + .macro region_map_location x, y, width, height, name + .byte \x + .byte \y + .byte \width + .byte \height + .4byte gMapName_\name + .endm + + .macro obj_tiles address, uncompressed_size, tag + .4byte \address + .2byte \uncompressed_size + .2byte \tag + .endm + + .macro null_obj_tiles + obj_tiles 0, 0, 0 + .endm + + .macro obj_pal address, tag + .4byte \address + .2byte \tag + .2byte 0 @ padding + .endm + + .macro null_obj_pal + obj_pal 0, 0 + .endm + + .macro paired_pals tag, address + .2byte \tag + .2byte 0 @ padding + .4byte \address + .endm + +@ For object animation frames. + .macro obj_frame_tiles address, uncompressed_size + .4byte \address + .2byte \uncompressed_size + .2byte 0 @ padding + .endm + + .macro spr_template tile_tag, pal_tag, oam, anims, images, affine_anims, callback + .2byte \tile_tag + .2byte \pal_tag + .4byte \oam + .4byte \anims + .4byte \images + .4byte \affine_anims + .4byte \callback + .endm + +@ Berry trees have a table defining the palette slot used for each of their 5 +@ stages. However, the first 2 stages always use the same slots regardless of +@ the type of tree and the slots of the last 3 stages always equal each other. + .macro berry_tree_palette_slot_table slot + .byte 3, 4, \slot, \slot, \slot + .endm + + .macro subsprite x, y, priority, tile_num_offset, size + .2byte \x + .2byte \y + .2byte ((\priority) << 14) | ((\tile_num_offset) << 4) | SPRITE_SIZE_\size + .2byte 0 @ padding + .endm + + .macro obj_image_anim_frame pic_id, duration, flags = 0 + .2byte \pic_id + .byte (\flags) | (\duration) + .byte 0 @ padding + .endm + + .macro obj_image_anim_loop count + .2byte 0xfffd + .byte \count + .byte 0 @ padding + .endm + + .macro obj_image_anim_jump target_index + .2byte 0xfffe + .byte \target_index + .byte 0 @ padding + .endm + + .macro obj_image_anim_end + .2byte 0xffff + .2byte 0 @ padding + .endm + + .macro obj_rot_scal_anim_frame delta_x_scale, delta_y_scale, delta_angle, duration + .2byte \delta_x_scale + .2byte \delta_y_scale + .byte \delta_angle + .byte \duration + .2byte 0 @ padding + .endm + + .macro obj_rot_scal_anim_loop count + .2byte 0x7ffd + .2byte \count + .4byte 0 @ padding + .endm + + .macro obj_rot_scal_anim_jump target_index + .2byte 0x7ffe + .2byte \target_index + .4byte 0 @ padding + .endm + + .macro obj_rot_scal_anim_end unknown=0 + .2byte 0x7fff + .2byte \unknown + .fill 4 @ padding + .endm + + .macro credits_entry number, text + .4byte \number + .4byte \text + .endm + + .macro door_anim_frame unknown, offset + .byte \unknown + .byte 0 @ padding + .2byte \offset + .endm + + .macro door_anim_gfx metatile_num, unknown, tile_addr, palette_addr + .2byte \metatile_num + .2byte \unknown + .4byte \tile_addr + .4byte \palette_addr + .endm + + .macro trainer_eye_trainer opp_1, opp_2, opp_3, opp_4, opp_5, map_name + .2byte OPPONENT_\opp_1 + .2byte OPPONENT_\opp_2 + .2byte OPPONENT_\opp_3 + .2byte OPPONENT_\opp_4 + .2byte OPPONENT_\opp_5 + .2byte GROUP_\map_name + .2byte MAP_\map_name + .space 2 + .endm diff --git a/include/macros/asm.inc b/include/macros/asm.inc new file mode 100644 index 000000000..26b2707ca --- /dev/null +++ b/include/macros/asm.inc @@ -0,0 +1,17 @@ + .ifndef GUARD_ASM_MACROS_ASM_INC + .set GUARD_ASM_MACROS_ASM_INC, 1 + + .macro inc x + .set \x, \x + 1 + .endm + + .macro enum_start x=0 + .set __enum__, \x + .endm + + .macro enum constant + .equiv \constant, __enum__ + inc __enum__ + .endm + + .endif @ GUARD_ASM_MACROS_ASM_INC diff --git a/include/macros/battle_ai_script.inc b/include/macros/battle_ai_script.inc new file mode 100644 index 000000000..679e30340 --- /dev/null +++ b/include/macros/battle_ai_script.inc @@ -0,0 +1,554 @@ + .macro if_random_less_than percent, address + .byte 0x00 + .byte \percent + .4byte \address + .endm + + @ unused + .macro if_random_greater_than percent, address + .byte 0x01 + .byte \percent + .4byte \address + .endm + + @ unused + .macro if_random_equal address + .byte 0x02 + .4byte \address + .endm + + @ unused + .macro if_random_not_equal address + .byte 0x03 + .4byte \address + .endm + + .macro score score + .byte 0x04 + .byte \score + .endm + + .macro if_hp_less_than target, percent, address + .byte 0x05 + .byte \target + .byte \percent + .4byte \address + .endm + + .macro if_hp_more_than target, percent, address + .byte 0x06 + .byte \target + .byte \percent + .4byte \address + .endm + + .macro if_hp_equal target, percent, address + .byte 0x07 + .byte \target + .byte \percent + .4byte \address + .endm + + .macro if_hp_not_equal target, percent, address + .byte 0x08 + .byte \target + .byte \percent + .4byte \address + .endm + + .macro if_status target, status, address + .byte 0x09 + .byte \target + .4byte \status + .4byte \address + .endm + + .macro if_not_status target, status, address + .byte 0x0a + .byte \target + .4byte \status + .4byte \address + .endm + + .macro if_status2 target, status, address + .byte 0x0b + .byte \target + .4byte \status + .4byte \address + .endm + + .macro if_not_status2 target, status, address + .byte 0x0c + .byte \target + .4byte \status + .4byte \address + .endm + + .macro if_status3 target, status, address + .byte 0x0d + .byte \target + .4byte \status + .4byte \address + .endm + + .macro if_not_status3 target, status, address + .byte 0x0e + .byte \target + .4byte \status + .4byte \address + .endm + + .macro if_status4 target, status, address + .byte 0x0f + .byte \target + .4byte \status + .4byte \address + .endm + + .macro if_not_status4 target, status, address + .byte 0x10 + .byte \target + .4byte \status + .4byte \address + .endm + + .macro if_less_than value, address + .byte 0x11 + .byte \value + .4byte \address + .endm + + .macro if_more_than value, address + .byte 0x12 + .byte \value + .4byte \address + .endm + + .macro if_equal value, address + .byte 0x13 + .byte \value + .4byte \address + .endm + + .macro if_not_equal value, address + .byte 0x14 + .byte \value + .4byte \address + .endm + + .macro if_less_than_32 value, address + .byte 0x15 + .4byte \value + .4byte \address + .endm + + .macro if_more_than_32 value, address + .byte 0x16 + .4byte \value + .4byte \address + .endm + + .macro if_equal_32 value, address + .byte 0x17 + .4byte \value + .4byte \address + .endm + + .macro if_not_equal_32 value, address + .byte 0x18 + .4byte \value + .4byte \address + .endm + + .macro if_move move, address + .byte 0x19 + .2byte \move + .4byte \address + .endm + + .macro if_not_move move, address + .byte 0x1a + .2byte \move + .4byte \address + .endm + + .macro if_in_bytes list, address + .byte 0x1b + .4byte \list + .4byte \address + .endm + + .macro if_not_in_bytes list, address + .byte 0x1c + .4byte \list + .4byte \address + .endm + + .macro if_in_words list, address + .byte 0x1d + .4byte \list + .4byte \address + .endm + + .macro if_not_in_words list, address + .byte 0x1e + .4byte \list + .4byte \address + .endm + + .macro if_user_can_damage address + .byte 0x1f + .4byte \address + .endm + + .macro if_user_cant_damage address + .byte 0x20 + .4byte \address + .endm + + .macro get_turn_count + .byte 0x21 + .endm + + .macro get_type byte + .byte 0x22 + .byte \byte + .endm + + @ unused + .macro get_move_power + .byte 0x23 + .endm + + .macro is_most_powerful_move + .byte 0x24 + .endm + + .macro get_move target + .byte 0x25 + .byte \target + .endm + + .macro if_arg_equal type, address + .byte 0x26 + .byte \type + .4byte \address + .endm + + @ unused + .macro if_arg_not_equal type, address + .byte 0x27 + .byte \type + .4byte \address + .endm + + .macro if_would_go_first target, address + .byte 0x28 + .byte \target + .4byte \address + .endm + + .macro if_would_not_go_first target, address + .byte 0x29 + .byte \target + .4byte \address + .endm + + @ nullsub + .macro ai_2a + .byte 0x2a + .endm + + @ nullsub + .macro ai_2b + .byte 0x2b + .endm + + .macro count_alive_pokemon target + .byte 0x2c + .byte \target + .endm + + @ unused + .macro get_considered_move + .byte 0x2d + .endm + + .macro get_effect + .byte 0x2e + .endm + + .macro get_ability target + .byte 0x2f + .byte \target + .endm + + @ unused + .macro get_highest_possible_damage + .byte 0x30 + .endm + + .macro if_damage_bonus value, address + .byte 0x31 + .byte \value + .4byte \address + .endm + + @ nullsub + .macro ai_32 + .byte 0x32 + .endm + + @ nullsub + .macro ai_33 + .byte 0x33 + .endm + + .macro if_status_in_party target, status, address + .byte 0x34 + .byte \target + .4byte \status + .4byte \address + .endm + + @ bugged + .macro if_status_not_in_party target, status, address + .byte 0x35 + .byte \target + .4byte \status + .4byte \address + .endm + + .macro get_weather + .byte 0x36 + .endm + + .macro if_effect byte, address + .byte 0x37 + .byte \byte + .4byte \address + .endm + + .macro if_not_effect byte, address + .byte 0x38 + .byte \byte + .4byte \address + .endm + + .macro if_stat_level_less_than target, stat, level, address + .byte 0x39 + .byte \target + .byte \stat + .byte \level + .4byte \address + .endm + + .macro if_stat_level_more_than target, stat, level, address + .byte 0x3a + .byte \target + .byte \stat + .byte \level + .4byte \address + .endm + + .macro if_stat_level_equal target, stat, level, address + .byte 0x3b + .byte \target + .byte \stat + .byte \level + .4byte \address + .endm + + .macro if_stat_level_not_equal target, stat, level, address + .byte 0x3c + .byte \target + .byte \stat + .byte \level + .4byte \address + .endm + + .macro if_can_faint address + .byte 0x3d + .4byte \address + .endm + + .macro if_cant_faint address + .byte 0x3e + .4byte \address + .endm + + @ unused + .macro if_has_move, target, move, address + .byte 0x3f + .byte \target + .2byte \move + .4byte \address + .endm + + @ unused + .macro if_dont_have_move, target, move, address + .byte 0x40 + .byte \target + .2byte \move + .4byte \address + .endm + + .macro if_move_effect target, effect, address + .byte 0x41 + .byte \target + .byte \effect + .4byte \address + .endm + + .macro if_not_move_effect target, effect, address + .byte 0x42 + .byte \target + .byte \effect + .4byte \address + .endm + + .macro if_last_move_did_damage target, byte, address + .byte 0x43 + .byte \target + .byte \byte + .4byte \address + .endm + + .macro if_encored target, address + .byte 0x44 + .byte \target + .4byte \address + .endm + + .macro flee + .byte 0x45 + .endm + + .macro if_random_100 address + .byte 0x46 + .4byte \address + .endm + + .macro watch + .byte 0x47 + .endm + + .macro get_hold_effect target + .byte 0x48 + .byte \target + .endm + + .macro get_gender target + .byte 0x49 + .byte \target + .endm + + .macro is_first_turn target + .byte 0x4a + .byte \target + .endm + + .macro get_stockpile_count target + .byte 0x4b + .byte \target + .endm + + .macro is_double_battle + .byte 0x4c + .endm + + .macro get_item target + .byte 0x4d + .byte \target + .endm + + .macro get_move_type_from_result + .byte 0x4e + .endm + + .macro get_move_power_from_result + .byte 0x4f + .endm + + .macro get_move_effect_from_result + .byte 0x50 + .endm + + .macro get_protect_count target + .byte 0x51 + .byte \target + .endm + + @ nullsub + .macro ai_52 + .byte 0x52 + .endm + + @ nullsub + .macro ai_53 + .byte 0x53 + .endm + + @ nullsub + .macro ai_54 + .byte 0x54 + .endm + + @ nullsub + .macro ai_55 + .byte 0x55 + .endm + + @ nullsub + .macro ai_56 + .byte 0x56 + .endm + + @ nullsub + .macro ai_57 + .byte 0x57 + .endm + + @ unused + .macro call address + .byte 0x58 + .4byte \address + .endm + + .macro jump address + .byte 0x59 + .4byte \address + .endm + + .macro end + .byte 0x5a + .endm + + .macro if_level_cond cond, address + .byte 0x5b + .byte \cond + .4byte \address + .endm + + .macro if_user_higher_level address + if_level_cond 0, \address + .endm + + .macro if_target_higher_level address + if_level_cond 1, \address + .endm + + .macro if_equal_levels address + if_level_cond 2, \address + .endm + + @ unused + .macro if_taunted address + .byte 0x5c + .4byte \address + .endm + + .macro if_not_taunted address + .byte 0x5d + .4byte \address + .endm diff --git a/include/macros/battle_anim.inc b/include/macros/battle_anim.inc new file mode 100644 index 000000000..4ff845032 --- /dev/null +++ b/include/macros/battle_anim.inc @@ -0,0 +1,266 @@ + .macro loadsprite id + .byte 0x00 + .2byte \id + .endm + + .macro unloadsprite id + .byte 0x01 + .2byte \id + .endm + + .macro sprite template, priority, argv:vararg + .byte 0x02 + .4byte \template + .byte \priority + .byte (.Lsprite_\@_2 - .Lsprite_\@_1) / 2 +.Lsprite_\@_1: + .2byte \argv +.Lsprite_\@_2: + .endm + + .macro createtask addr, priority, argv:vararg + .byte 0x03 + .4byte \addr + .byte \priority + .byte (.Lcreatetask_\@_2 - .Lcreatetask_\@_1) / 2 +.Lcreatetask_\@_1: + .2byte \argv +.Lcreatetask_\@_2: + .endm + + .macro pause delay + .byte 0x04 + .byte \delay + .endm + + .macro wait + .byte 0x05 + .endm + + .macro hang1 + .byte 0x06 + .endm + + .macro hang2 + .byte 0x07 + .endm + + .macro end + .byte 0x08 + .endm + + .macro playse id + .byte 0x09 + .2byte \id + .endm + + .macro monbg which + .byte 0x0A + .byte \which + .endm + + .macro clearmonbg which + .byte 0x0B + .byte \which + .endm + + .macro setalpha eva, evb + .byte 0x0C + .2byte ((\evb) << 8) | (\eva) + .endm + + .macro blendoff + .byte 0x0D + .endm + + .macro call addr + .byte 0x0E + .4byte \addr + .endm + + .macro ret + .byte 0x0F + .endm + + .macro setvar var_num, value + .byte 0x10 + .byte \var_num + .2byte \value + .endm + + .macro ifelse addr1, addr2 + .byte 0x11 + .4byte \addr1 + .4byte \addr2 + .endm + + .macro jumpif cond, addr + .byte 0x12 + .byte \cond + .4byte \addr + .endm + + .macro jump addr + .byte 0x13 + .4byte \addr + .endm + + .macro fadetobg id + .byte 0x14 + .byte \id + .endm + + .macro restorebg + .byte 0x15 + .endm + + .macro waitbgfadeout + .byte 0x16 + .endm + + .macro waitbgfadein + .byte 0x17 + .endm + + .macro changebg id + .byte 0x18 + .byte \id + .endm + + .macro panse_19 id, pan + .byte 0x19 + .2byte \id + .byte \pan + .endm + + .macro setpan pan + .byte 0x1A + .byte \pan + .endm + + .macro panse_1B id, pan_start, pan_end, step, delay + .byte 0x1B + .2byte \id + .byte \pan_start + .byte \pan_end + .byte \step + .byte \delay + .endm + + .macro panse_1C id, pan, delay, count + .byte 0x1C + .2byte \id + .byte \pan + .byte \delay + .byte \count + .endm + + .macro panse_1D id, pan, count + .byte 0x1D + .2byte \id + .byte \pan + .byte \count + .endm + + .macro setbldcnt bldcnt + .byte 0x1E + .2byte \bldcnt + .endm + + .macro createtask_1F addr, argv:vararg + .byte 0x1F + .4byte \addr + .byte (.Lcreatetask_1F_\@_2 - .Lcreatetask_1F_\@_1) / 2 +.Lcreatetask_1F_\@_1: + .2byte \argv +.Lcreatetask_1F_\@_2: + .endm + + .macro waitsound + .byte 0x20 + .endm + + .macro jumpvareq var_num, value, addr + .byte 0x21 + .byte \var_num + .2byte \value + .4byte \addr + .endm + + .macro monbg_22 unk + .byte 0x22 + .byte \unk + .endm + + .macro clearmonbg_23 unk + .byte 0x23 + .byte \unk + .endm + + .macro jumpunkcond addr + .byte 0x24 + .4byte \addr + .endm + + .macro fadetobg_25 a, b, c + .byte 0x25 + .byte \a + .byte \b + .byte \c + .endm + + .macro panse_26 id, pan_start, pan_end, step, delay + .byte 0x26 + .2byte \id + .byte \pan_start + .byte \pan_end + .byte \step + .byte \delay + .endm + + .macro panse_27 id, pan_start, pan_end, step, delay + .byte 0x27 + .2byte \id + .byte \pan_start + .byte \pan_end + .byte \step + .byte \delay + .endm + + .macro monbgprio_28 unk + .byte 0x28 + .byte \unk + .endm + + .macro monbgprio_29 + .byte 0x29 + .endm + + .macro monbgprio_2A unk + .byte 0x2A + .byte \unk + .endm + + .macro invisible side + .byte 0x2B + .byte \side + .endm + + .macro visible side + .byte 0x2C + .byte \side + .endm + + .macro doublebattle_2D unk + .byte 0x2D + .byte \unk + .endm + + .macro doublebattle_2E unk + .byte 0x2E + .byte \unk + .endm + + .macro stopsound + .byte 0x2F + .endm diff --git a/include/macros/battle_script.inc b/include/macros/battle_script.inc new file mode 100644 index 000000000..e4fa0c454 --- /dev/null +++ b/include/macros/battle_script.inc @@ -0,0 +1,1414 @@ +@ 0 == +@ 1 != +@ 2 < +@ 3 > +@ 4 &= + + .macro calculatedamage + critical + atk5 + atk6 + atk7 + .endm + + + .macro attackcanceler + .byte 0x00 + .endm + + .macro accuracycheck address, param1 + .byte 0x01 + .4byte \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 healthbarupdate 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 printselectionstringfromtable table + .byte 0x14 + .4byte \table + .endm + + .macro seteffectwithchance + .byte 0x15 + .endm + + .macro seteffectprimary + .byte 0x16 + .endm + + .macro seteffectsecondary + .byte 0x17 + .endm + + .macro clearstatusfromeffect bank + .byte 0x18 + .byte \bank + .endm + + .macro tryfaintmon 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, address + .byte 0x1c + .byte \bank + .4byte \status + .4byte \address + .endm + + .macro jumpifstatus2 bank, status, address + .byte 0x1d + .byte \bank + .4byte \status + .4byte \address + .endm + + .macro jumpifability bank, ability, address + .byte 0x1e + .byte \bank + .byte \ability + .4byte \address + .endm + + .macro jumpifsideaffecting bank, status, address + .byte 0x1f + .byte \bank + .2byte \status + .4byte \address + .endm + + .macro jumpifstat bank, flag, quantity, statid, address + .byte 0x20 + .byte \bank + .byte \flag + .byte \quantity + .byte \statid + .4byte \address + .endm + + .macro jumpifstatus3condition bank, mask, status, address + .byte 0x21 + .byte \bank + .4byte \mask + .byte \status + .4byte \address + .endm + + .macro jumpiftype bank, type, address + .byte 0x22 + .byte \bank + .byte \type + .4byte \address + .endm + + .macro getexp bank + .byte 0x23 + .byte \bank + .endm + + .macro atk24 address + .byte 0x24 + .4byte \address + .endm + + .macro movevaluescleanup + .byte 0x25 + .endm + + .macro setmultihit param1 + .byte 0x26 + .byte \param1 + .endm + + .macro decrementmultihit address + .byte 0x27 + .4byte \address + .endm + + .macro goto address + .byte 0x28 + .4byte \address + .endm + + .macro jumpifbyte ifflag, checkaddr, compare, address + .byte 0x29 + .byte \ifflag + .4byte \checkaddr + .byte \compare + .4byte \address + .endm + + .macro jumpifhalfword ifflag, checkaddr, compare, address + .byte 0x2a + .byte \ifflag + .4byte \checkaddr + .2byte \compare + .4byte \address + .endm + + .macro jumpifword ifflag, checkaddr, compare, address + .byte 0x2b + .byte \ifflag + .4byte \checkaddr + .4byte \compare + .4byte \address + .endm + + .macro jumpifarrayequal mem1, mem2, size, address + .byte 0x2c + .4byte \mem1 + .4byte \mem2 + .byte \size + .4byte \address + .endm + + .macro jumpifarraynotequal mem1, mem2, size, address + .byte 0x2d + .4byte \mem1 + .4byte \mem2 + .byte \size + .4byte \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 subbyte 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 param1, param2, param3, byte + .byte 0x32 + .4byte \param1 + .4byte \param2 + .4byte \param3 + .byte \byte + .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 pause_duration + .byte 0x39 + .2byte \pause_duration + .endm + + .macro waitstate + .byte 0x3a + .endm + + .macro healthbar_update 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 address + .byte 0x40 + .4byte \address + .endm + + .macro call address + .byte 0x41 + .4byte \address + .endm + + .macro jumpiftype2 bank, type, address + .byte 0x42 + .byte \bank + .byte \type + .4byte \address + .endm + + .macro jumpifabilitypresent ability, address + .byte 0x43 + .byte \ability + .4byte \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, address, int + .byte 0x46 + .byte \bank + .4byte \address + .4byte \int + .endm + + .macro setgraphicalstatchangevalues + .byte 0x47 + .endm + + .macro playstatchangeanimation bank, color, byte + .byte 0x48 + .byte \bank + .byte \color + .byte \byte + .endm + + .macro moveend byte1, byte2 + .byte 0x49 + .byte \byte1 + .byte \byte2 + .endm + + .macro typecalc2 + .byte 0x4a + .endm + + .macro returnatktoball + .byte 0x4b + .endm + + .macro getswitchedmondata bank + .byte 0x4c + .byte \bank + .endm + + .macro switchindataupdate bank + .byte 0x4d + .byte \bank + .endm + + .macro switchinanim bank, byte + .byte 0x4e + .byte \bank + .byte \byte + .endm + + .macro jumpifcantswitch bank, address + .byte 0x4f + .byte \bank + .4byte \address + .endm + + .macro openpartyscreen bank, address + .byte 0x50 + .byte \bank + .4byte \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 word + .byte 0x54 + .2byte \word + .endm + + .macro fanfare int + .byte 0x55 + .2byte \int + .endm + + .macro playfaintcry bank_or_side + .byte 0x56 + .byte \bank_or_side + .endm + + .macro atk57 + .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 address + .byte 0x5a + .4byte \address + .endm + + .macro yesnoboxstoplearningmove address + .byte 0x5b + .4byte \address + .endm + + .macro hitanimation bank + .byte 0x5c + .byte \bank + .endm + + .macro getmoneyreward + .byte 0x5d + .endm + + .macro atk5e bank + .byte 0x5e + .byte \bank + .endm + + .macro atk5f + .byte 0x5f + .endm + + .macro incrementgamestat byte + .byte 0x60 + .byte \byte + .endm + + .macro drawpartystatussummary bank_or_side + .byte 0x61 + .byte \bank_or_side + .endm + + .macro atk62 bank_or_side + .byte 0x62 + .byte \bank_or_side + .endm + + .macro jumptorandomattack bank + .byte 0x63 + .byte \bank + .endm + + .macro statusanimation bank + .byte 0x64 + .byte \bank + .endm + + .macro status2animation bank_or_side, address + .byte 0x65 + .byte \bank_or_side + .4byte \address + .endm + + .macro chosenstatusanimation bank_or_side, bank_or_side2, address + .byte 0x66 + .byte \bank_or_side + .byte \bank_or_side2 + .4byte \address + .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 address + .byte 0x72 + .4byte \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, byte + .byte 0x76 + .byte \bank + .byte \byte + .endm + + .macro setprotectlike + .byte 0x77 + .endm + + .macro faintifabilitynotdamp + .byte 0x78 + .endm + + .macro setatkhptozero + .byte 0x79 + .endm + + .macro jumpifnexttargetvalid address + .byte 0x7a + .4byte \address + .endm + + .macro tryhealhalfhealth address, byte + .byte 0x7b + .4byte \address + .byte \byte + .endm + + .macro trymirrormove + .byte 0x7c + .endm + + .macro setrain + .byte 0x7d + .endm + + .macro setreflect + .byte 0x7e + .endm + + .macro setseeded + .byte 0x7f + .endm + + .macro manipulatedamage id + .byte 0x80 + .byte \id + .endm + + .macro trysetrest address + .byte 0x81 + .4byte \address + .endm + + .macro jumpifnotfirstturn address + .byte 0x82 + .4byte \address + .endm + + .macro nop + .byte 0x83 + .endm + + .macro jumpifcantmakeasleep address + .byte 0x84 + .4byte \address + .endm + + .macro stockpile + .byte 0x85 + .endm + + .macro stockpiletobasedamage address + .byte 0x86 + .4byte \address + .endm + + .macro stockpiletohpheal address + .byte 0x87 + .4byte \address + .endm + + .macro negativedamage + .byte 0x88 + .endm + + .macro statbuffchange target, address + .byte 0x89 + .byte \target + .4byte \address + .endm + + .macro normalisebuffs + .byte 0x8a + .endm + + .macro setbide + .byte 0x8b + .endm + + .macro confuseifrepeatingattackends + .byte 0x8c + .endm + + .macro setmultihitcounter count + .byte 0x8d + .byte \count + .endm + + .macro initmultihitstring + .byte 0x8e + .endm + + .macro forcerandomswitch address + .byte 0x8f + .4byte \address + .endm + + .macro tryconversiontypechange address + .byte 0x90 + .4byte \address + .endm + + .macro givepaydaymoney + .byte 0x91 + .endm + + .macro setlightscreen + .byte 0x92 + .endm + + .macro tryKO address + .byte 0x93 + .4byte \address + .endm + + .macro damagetohalftargethp + .byte 0x94 + .endm + + .macro setsandstorm + .byte 0x95 + .endm + + .macro weatherdamage + .byte 0x96 + .endm + + .macro tryinfatuating address + .byte 0x97 + .4byte \address + .endm + + .macro updatestatusicon byte + .byte 0x98 + .byte \byte + .endm + + .macro setmist + .byte 0x99 + .endm + + .macro setfocusenergy + .byte 0x9a + .endm + + .macro transformdataexecution + .byte 0x9b + .endm + + .macro setsubstitute + .byte 0x9c + .endm + + .macro mimicattackcopy address + .byte 0x9d + .4byte \address + .endm + + .macro metronome + .byte 0x9e + .endm + + .macro dmgtolevel + .byte 0x9f + .endm + + .macro psywavedamageeffect + .byte 0xa0 + .endm + + .macro counterdamagecalculator address + .byte 0xa1 + .4byte \address + .endm + + .macro mirrorcoatdamagecalculator address + .byte 0xa2 + .4byte \address + .endm + + .macro disablelastusedattack address + .byte 0xa3 + .4byte \address + .endm + + .macro trysetencore address + .byte 0xa4 + .4byte \address + .endm + + .macro painsplitdmgcalc address + .byte 0xa5 + .4byte \address + .endm + + .macro settypetorandomresistance address + .byte 0xa6 + .4byte \address + .endm + + .macro setalwayshitflag + .byte 0xa7 + .endm + + .macro copymovepermanently address + .byte 0xa8 + .4byte \address + .endm + + .macro trychoosesleeptalkmove address + .byte 0xa9 + .4byte \address + .endm + + .macro setdestinybond + .byte 0xaa + .endm + + .macro trysetdestinybondtohappen + .byte 0xab + .endm + + .macro remaininghptopower + .byte 0xac + .endm + + .macro tryspiteppreduce address + .byte 0xad + .4byte \address + .endm + + .macro healpartystatus + .byte 0xae + .endm + + .macro cursetarget address + .byte 0xaf + .4byte \address + .endm + + .macro trysetspikes address + .byte 0xb0 + .4byte \address + .endm + + .macro setforesight + .byte 0xb1 + .endm + + .macro trysetperishsong address + .byte 0xb2 + .4byte \address + .endm + + .macro rolloutdamagecalculation + .byte 0xb3 + .endm + + .macro jumpifconfusedandstatmaxed bank, address + .byte 0xb4 + .byte \bank + .4byte \address + .endm + + .macro furycuttercalc + .byte 0xb5 + .endm + + .macro happinesstodamagecalculation + .byte 0xb6 + .endm + + .macro presentdamagecalculation + .byte 0xb7 + .endm + + .macro setsafeguard + .byte 0xb8 + .endm + + .macro magnitudedamagecalculation + .byte 0xb9 + .endm + + .macro jumpifnopursuitswitchdmg address + .byte 0xba + .4byte \address + .endm + + .macro setsunny + .byte 0xbb + .endm + + .macro maxattackhalvehp address + .byte 0xbc + .4byte \address + .endm + + .macro copyfoestats address + .byte 0xbd + .4byte \address + .endm + + .macro rapidspinfree + .byte 0xbe + .endm + + .macro setdefensecurlbit + .byte 0xbf + .endm + + .macro recoverbasedonsunlight address + .byte 0xc0 + .4byte \address + .endm + + .macro hiddenpowercalc + .byte 0xc1 + .endm + + .macro selectfirstvalidtarget + .byte 0xc2 + .endm + + .macro trysetfutureattack address + .byte 0xc3 + .4byte \address + .endm + + .macro trydobeatup address1, address2 + .byte 0xc4 + .4byte \address1 + .4byte \address2 + .endm + + .macro setsemiinvulnerablebit + .byte 0xc5 + .endm + + .macro clearsemiinvulnerablebit + .byte 0xc6 + .endm + + .macro setminimize + .byte 0xc7 + .endm + + .macro sethail + .byte 0xc8 + .endm + + .macro jumpifattackandspecialattackcannotfall address + .byte 0xc9 + .4byte \address + .endm + + .macro setforcedtarget + .byte 0xca + .endm + + .macro setcharge + .byte 0xcb + .endm + + .macro callterrainattack + .byte 0xcc + .endm + + .macro cureifburnedparalysedorpoisoned address + .byte 0xcd + .4byte \address + .endm + + .macro settorment address + .byte 0xce + .4byte \address + .endm + + .macro jumpifnodamage address + .byte 0xcf + .4byte \address + .endm + + .macro settaunt address + .byte 0xd0 + .4byte \address + .endm + + .macro trysethelpinghand address + .byte 0xd1 + .4byte \address + .endm + + .macro tryswapitems address + .byte 0xd2 + .4byte \address + .endm + + .macro trycopyability address + .byte 0xd3 + .4byte \address + .endm + + .macro trywish byte, address + .byte 0xd4 + .byte \byte + .4byte \address + .endm + + .macro trysetroots address + .byte 0xd5 + .4byte \address + .endm + + .macro doubledamagedealtifdamaged + .byte 0xd6 + .endm + + .macro setyawn address + .byte 0xd7 + .4byte \address + .endm + + .macro setdamagetohealthdifference address + .byte 0xd8 + .4byte \address + .endm + + .macro scaledamagebyhealthratio + .byte 0xd9 + .endm + + .macro tryswapabilities address + .byte 0xda + .4byte \address + .endm + + .macro tryimprision address + .byte 0xdb + .4byte \address + .endm + + .macro trysetgrudge address + .byte 0xdc + .4byte \address + .endm + + .macro weightdamagecalculation + .byte 0xdd + .endm + + .macro assistattackselect address + .byte 0xde + .4byte \address + .endm + + .macro trysetmagiccoat address + .byte 0xdf + .4byte \address + .endm + + .macro trysetsnatch address + .byte 0xe0 + .4byte \address + .endm + + .macro trygetintimidatetarget address + .byte 0xe1 + .4byte \address + .endm + + .macro switchoutabilities bank + .byte 0xe2 + .byte \bank + .endm + + .macro jumpifhasnohp bank, address + .byte 0xe3 + .byte \bank + .4byte \address + .endm + + .macro getsecretpowereffect + .byte 0xe4 + .endm + + .macro pickup + .byte 0xe5 + .endm + + .macro docastformchangeanimation + .byte 0xe6 + .endm + + .macro trycastformdatachange + .byte 0xe7 + .endm + + .macro settypebasedhalvers address + .byte 0xe8 + .4byte \address + .endm + + .macro setweatherballtype + .byte 0xe9 + .endm + + .macro tryrecycleitem address + .byte 0xea + .4byte \address + .endm + + .macro settypetoterrain address + .byte 0xeb + .4byte \address + .endm + + .macro pursuitrelated address + .byte 0xec + .4byte \address + .endm + + .macro snatchsetbanks + .byte 0xed + .endm + + .macro removelightscreenreflect + .byte 0xee + .endm + + .macro handleballthrow + .byte 0xef + .endm + + .macro givecaughtmon + .byte 0xf0 + .endm + + .macro trysetcaughtmondexflags address + .byte 0xf1 + .4byte \address + .endm + + .macro displaydexinfo + .byte 0xf2 + .endm + + .macro trygivecaughtmonnick address + .byte 0xf3 + .4byte \address + .endm + + .macro subattackerhpbydmg + .byte 0xf4 + .endm + + .macro removeattackerstatus1 + .byte 0xf5 + .endm + + .macro finishaction + .byte 0xf6 + .endm + + .macro finishturn + .byte 0xf7 + .endm + + .macro trainerslideout bank + .byte 0xf8 + .byte \bank + .endm + +@ various command changed to more readable macros + .macro cancelmultiturnmoves bank + various \bank, VARIOUS_CANCEL_MULTI_TURN_MOVES + .endm + + .macro setmagiccoattarget bank + various \bank, VARIOUS_SET_MAGIC_COAT_TARGET + .endm + + .macro getifcantrunfrombattle bank + various \bank, VARIOUS_IS_RUNNING_IMPOSSIBLE + .endm + + .macro getmovetarget bank + various \bank, VARIOUS_GET_MOVE_TARGET + .endm + + .macro various4 bank + various \bank, 4 + .endm + + .macro resetintrimidatetracebits bank + various \bank, VARIOUS_RESET_INTIMIDATE_TRACE_BITS + .endm + + .macro updatechoicemoveonlvlup bank + various \bank, VARIOUS_UPDATE_CHOICE_MOVE_ON_LVL_UP + .endm + + .macro various7 bank + various \bank, 7 + .endm + + .macro various8 bank + various \bank, 8 + .endm + + .macro various9 bank + various \bank, 9 + .endm + + .macro various10 bank + various \bank, 10 + .endm + + .macro various11 bank + various \bank, 11 + .endm + + .macro various12 bank + various \bank, 12 + .endm + + .macro forfeityesnobox bank + various \bank, VARIOUS_EMIT_YESNOBOX + .endm + + .macro various14 bank + various \bank, 14 + .endm + + .macro various15 bank + various \bank, 15 + .endm + + .macro various16 bank + various \bank, 16 + .endm + + .macro various17 bank + various \bank, 17 + .endm + + .macro waitcry bank + various \bank, VARIOUS_WAIT_CRY + .endm + + .macro returnopponentmon1toball bank + various \bank, VARIOUS_RETURN_OPPONENT_MON1 + .endm + + .macro returnopponentmon2toball bank + various \bank, VARIOUS_RETURN_OPPONENT_MON2 + .endm + + .macro various21 bank + various \bank, 21 + .endm + + .macro various22 bank + various \bank, 22 + .endm + + .macro various23 bank + various \bank, 23 + .endm + + .macro various24 bank + various \bank, 24 + .endm + + .macro setoutcomeonteleport bank + various \bank, VARIOUS_SET_TELEPORT_OUTCOME + .endm + + .macro playtrainerdefeatbgm bank + various \bank, VARIOUS_PLAY_TRAINER_DEFEATED_MUSIC + .endm + +@ helpful macros + .macro setstatchanger stat, stages, down + setbyte sSTATCHANGER \stat | \stages << 4 | \down << 7 + .endm + + .macro setmoveeffect effect + setbyte cEFFECT_CHOOSER \effect + .endm + + .macro chosenstatus1animation bank, status + chosenstatusanimation \bank 0x0 \status + .endm + + .macro chosenstatus2animation bank, status + chosenstatusanimation \bank 0x1 \status + .endm + + .macro sethword dst, value + setbyte \dst, \value & 0xFF + setbyte \dst + 1, (\value >> 8) & 0xFF + .endm + + .macro setword dst, value + setbyte \dst, \value & 0xFF + setbyte \dst + 1, (\value >> 8) & 0xFF + setbyte \dst + 2, (\value >> 16) & 0xFF + setbyte \dst + 3, (\value >> 24) & 0xFF + .endm + + .macro copybyte dst, src + copyarray \dst, \src, 0x1 + .endm + + .macro copyhword dst, src + copyarray \dst, \src, 0x2 + .endm + + .macro copyword dst, src + copyarray \dst, \src, 0x4 + .endm + + .macro jumpifbytenotequal byte1, byte2, jumpptr + jumpifarraynotequal \byte1, \byte2, 0x1, \jumpptr + .endm + + .macro jumpifbyteequal byte1, byte2, jumpptr + jumpifarrayequal \byte1, \byte2, 0x1, \jumpptr + .endm + + .macro jumpifmove move, jumpptr + jumpifhalfword EQUAL, gCurrentMove, \move, \jumpptr + .endm + + .macro jumpifnotmove move, jumpptr + jumpifhalfword NOT_EQUAL, gCurrentMove, \move, \jumpptr + .endm + + .macro jumpifstatus3 bank, status, jumpptr + jumpifstatus3condition \bank, \status, 0x0, \jumpptr + .endm + + .macro jumpifnostatus3 bank, status, jumpptr + jumpifstatus3condition \bank, \status, 0x1, \jumpptr + .endm + + .macro jumpifmovehadnoeffect jumpptr + jumpifbyte COMMON_BITS, gBattleMoveFlags, MOVESTATUS_MISSED | MOVESTATUS_NOTAFFECTED | MOVESTATUS_FAILED, \jumpptr + .endm + + .macro jumpifbattletype flags, jumpptr + jumpifhalfword COMMON_BITS, gBattleTypeFlags, \flags, \jumpptr + .endm + + .macro jumpifnotbattletype flags, jumpptr + jumpifhalfword NO_COMMON_BITS, gBattleTypeFlags, \flags, \jumpptr + .endm diff --git a/include/macros/contest_ai_script.inc b/include/macros/contest_ai_script.inc new file mode 100644 index 000000000..05d70e351 --- /dev/null +++ b/include/macros/contest_ai_script.inc @@ -0,0 +1,506 @@ +@ Add a positive/negative value to the score of the move being evaluated. + + .macro score score + .byte 0x00 + .byte \score + .endm + +@ turn (AKA "Appeal No.") + + .macro get_turn + .byte 0x01 + .endm + + .macro if_turn_less_than param, addr + .byte 0x02 + .byte \param + .4byte \addr + .endm + + .macro if_turn_more_than param, addr + .byte 0x03 + .byte \param + .4byte \addr + .endm + + .macro if_turn_eq param, addr + .byte 0x04 + .byte \param + .4byte \addr + .endm + + .macro if_turn_not_eq param, addr + .byte 0x05 + .byte \param + .4byte \addr + .endm + +@ audience excitement + + .macro get_excitement + .byte 0x06 + .endm + + .macro if_excitement_less_than param, addr + .byte 0x07 + .byte \param + .4byte \addr + .endm + + .macro if_excitement_more_than param, addr + .byte 0x08 + .byte \param + .4byte \addr + .endm + + .macro if_excitement_eq param, addr + .byte 0x09 + .byte \param + .4byte \addr + .endm + + .macro if_excitement_not_eq param, addr + .byte 0x0A + .byte \param + .4byte \addr + .endm + +@ the order that the user goes in the current turn + + .macro get_user_order + .byte 0x0B + .endm + + .macro if_user_order_less_than param addr + .byte 0x0C + .byte \param + .4byte \addr + .endm + + .macro if_user_order_more_than param addr + .byte 0x0D + .byte \param + .4byte \addr + .endm + + .macro if_user_order_eq param addr + .byte 0x0E + .byte \param + .4byte \addr + .endm + + .macro if_user_order_not_eq param addr + .byte 0x0F + .byte \param + .4byte \addr + .endm + +@ user condition + + .macro get_user_condition + .byte 0x10 + .endm + + .macro if_user_condition_less_than param, addr + .byte 0x11 + .byte \param + .4byte \addr + .endm + + .macro if_user_condition_more_than param, addr + .byte 0x12 + .byte \param + .4byte \addr + .endm + + .macro if_user_condition_eq param, addr + .byte 0x13 + .byte \param + .4byte \addr + .endm + + .macro if_user_condition_not_eq param, addr + .byte 0x14 + .byte \param + .4byte \addr + .endm + +@ 15 +@ 16 +@ 17 +@ 18 +@ 19 +@ 1A +@ 1B +@ 1C +@ 1D +@ 1E + +@ contest type + + .macro get_contest_type + .byte 0x1F + .endm + + .macro if_contest_type_eq param, addr + .byte 0x20 + .byte \param + .4byte \addr + .endm + + .macro if_contest_type_not_eq param, addr + .byte 0x21 + .byte \param + .4byte \addr + .endm + +@ move excitement (change in excitement due to move) + + .macro get_move_excitement + .byte 0x22 + .endm + + .macro if_move_excitement_less_than param, addr + .byte 0x23 + .byte \param + .4byte \addr + .endm + + .macro if_move_excitement_more_than param, addr + .byte 0x24 + .byte \param + .4byte \addr + .endm + + .macro if_move_excitement_eq param, addr + .byte 0x25 + .byte \param + .4byte \addr + .endm + + .macro if_move_excitement_not_eq param, addr + .byte 0x26 + .byte \param + .4byte \addr + .endm + +@ move effect + + .macro get_effect + .byte 0x27 + .endm + + .macro if_effect_eq param, addr + .byte 0x28 + .byte \param + .4byte \addr + .endm + + .macro if_effect_not_eq param, addr + .byte 0x29 + .byte \param + .4byte \addr + .endm + +@ move effect type + + .macro get_effect_type + .byte 0x2A + .endm + + .macro if_effect_type_eq param, addr + .byte 0x2B + .byte \param + .4byte \addr + .endm + + .macro if_effect_type_not_eq param, addr + .byte 0x2C + .byte \param + .4byte \addr + .endm + +@ whether the current move is the most appealing in the user's moveset + + .macro check_most_appealing_move + .byte 0x2D + .endm + + .macro if_most_appealing_move addr + .byte 0x2E + .4byte \addr + .endm + +@ 2F +@ 30 +@ 31 +@ 32 +@ 33 +@ 34 +@ 35 +@ 36 +@ 37 +@ 38 +@ 39 +@ 3A + +@ number of times current move has been used + + .macro get_move_used_count + .byte 0x3B + .endm + + .macro if_move_used_count_less_than param, addr + .byte 0x3C + .byte \param + .4byte \addr + .endm + + .macro if_move_used_count_more_than param, addr + .byte 0x3D + .byte \param + .4byte \addr + .endm + + .macro if_move_used_count_eq param, addr + .byte 0x3E + .byte \param + .4byte \addr + .endm + + .macro if_move_used_count_not_eq param, addr + .byte 0x3F + .byte \param + .4byte \addr + .endm + +@ whether the current move is a combo starter (with another move in the moveset) + + .macro check_combo_starter + .byte 0x40 + .endm + + .macro if_combo_starter addr + .byte 0x41 + .4byte \addr + .endm + + .macro if_not_combo_starter addr + .byte 0x42 + .4byte \addr + .endm + +@ whether the current move is a combo finisher (with another move in the moveset) + + .macro check_combo_finisher + .byte 0x43 + .endm + + .macro if_combo_finisher addr + .byte 0x44 + .4byte \addr + .endm + + .macro if_not_combo_finisher addr + .byte 0x45 + .4byte \addr + .endm + +@ whether the current move would finish a combo + + .macro check_would_finish_combo + .byte 0x46 + .endm + + .macro if_would_finish_combo addr + .byte 0x47 + .4byte \addr + .endm + + .macro if_would_not_finish_combo addr + .byte 0x48 + .4byte \addr + .endm + +@ condition of mon (indexed by order) + + .macro get_condition mon + .byte 0x49 + .byte \mon + .endm + + .macro if_condition_less_than mon, value, addr + .byte 0x4A + .byte \mon + .byte \value + .4byte \addr + .endm + + .macro if_condition_more_than mon, value, addr + .byte 0x4B + .byte \mon + .byte \value + .4byte \addr + .endm + + .macro if_condition_eq mon, value, addr + .byte 0x4C + .byte \mon + .byte \value + .4byte \addr + .endm + + .macro if_condition_not_eq mon, value, addr + .byte 0x4D + .byte \mon + .byte \value + .4byte \addr + .endm + +@ whether the mon used a combo starter move +@ Even though this value is always 1 or 0 (i.e. TRUE/FALSE), +@ there are less-than and greater-than comparison operations for some reason. + + .macro get_used_combo_starter mon + .byte 0x4E + .byte \mon + .endm + + .macro if_used_combo_starter_less_than mon, value, addr + .byte 0x4F + .byte \mon + .byte \value + .4byte \addr + .endm + + .macro if_used_combo_starter_more_than mon, value, addr + .byte 0x50 + .byte \mon + .byte \value + .4byte \addr + .endm + + + .macro if_used_combo_starter_eq mon, value, addr + .byte 0x51 + .byte \mon + .byte \value + .4byte \addr + .endm + + .macro if_used_combo_starter_not_eq mon, value, addr + .byte 0x52 + .byte \mon + .byte \value + .4byte \addr + .endm + +@ whether the mon can make an appeal + + .macro check_can_participate mon + .byte 0x53 + .byte \mon + .endm + + .macro if_can_participate mon, addr + .byte 0x54 + .byte \mon + .4byte \addr + .endm + + .macro if_cannot_participate mon, addr + .byte 0x55 + .byte \mon + .4byte \addr + .endm + +@ 56 +@ 57 + + .macro contest_58 param addr + .byte 0x58 + .byte \param + .4byte \addr + .endm + +@ 59 +@ 5A +@ 5B +@ 5C +@ 5D +@ 5E +@ 5F +@ 60 +@ 61 +@ 62 +@ 63 +@ 64 +@ 65 +@ 66 +@ 67 +@ 68 +@ 69 +@ 6A +@ 6B +@ 6C +@ 6D +@ 6E +@ 6F +@ 70 +@ 71 +@ 72 +@ 73 +@ 74 +@ 75 +@ 76 +@ 77 +@ 78 +@ 79 +@ 7A +@ 7B +@ 7C + + .macro if_random param addr + .byte 0x7D + .byte \param + .4byte \addr + .endm + +@ 7E + + .macro jump addr + .byte 0x7F + .4byte \addr + .endm + + .macro call addr + .byte 0x80 + .4byte \addr + .endm + + .macro end + .byte 0x81 + .endm + + .macro check_user_has_exciting_move + .byte 0x82 + .endm + + .macro if_user_has_exciting_move addr + .byte 0x83 + .4byte \addr + .endm + + .macro if_user_doesnt_have_exciting_move addr + .byte 0x84 + .4byte \addr + .endm + +@ 85 +@ 86 + + .macro if_effect_in_user_moveset param addr + .byte 0x87 + .2byte \param + .4byte \addr + .endm diff --git a/include/macros/ec.inc b/include/macros/ec.inc new file mode 100644 index 000000000..d3fd45c2f --- /dev/null +++ b/include/macros/ec.inc @@ -0,0 +1,8 @@ + + .macro ec_duplicates count + .2byte 0xff00 + \count + .endm + + .macro ec_words_by_letter label + .2byte (gEasyChatWordsByLetter_\label - gEasyChatWordsAlphabetized) / 2 + .endm diff --git a/include/macros/event.inc b/include/macros/event.inc new file mode 100644 index 000000000..fcbd3a055 --- /dev/null +++ b/include/macros/event.inc @@ -0,0 +1,1481 @@ + @ 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 + .byte 0x04 + .4byte \destination + .endm + + @ Jumps to destination and continues script execution from there. + .macro goto destination + .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, destination + .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, destination + .byte 0x07 + .byte \condition + .4byte \destination + .endm + + @ Jumps to the standard function at index function. + .macro gotostd function + .byte 0x08 + .byte \function + .endm + + @ Calls the standard function at index function. + .macro callstd function + .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, function + .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, function + .byte 0x0b + .byte \condition + .byte \function + .endm + + @ Executes a script stored in a default RAM location. + .macro gotoram + .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 + .byte 0x0e + .byte \value + .endm + + @ Sets the specified script bank to value. + .macro loadword destination, value + .byte 0x0f + .byte \destination + .4byte \value + .endm + + @ Sets the specified script bank to value. + .macro loadbyte destination, value + .byte 0x10 + .byte \destination + .byte \value + .endm + + @ Sets the byte at offset to value. + .macro writebytetoaddr value, offset + .byte 0x11 + .byte \value + .4byte \offset + .endm + + @ Copies the byte value at source into the specified script bank. + .macro loadbytefromaddr destination, source + .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, destination + .byte 0x13 + .byte \source + .4byte \destination + .endm + + @ Copies the contents of bank source into bank destination. + .macro copylocal destination, source + .byte 0x14 + .byte \destination + .byte \source + .endm + + @ Copies the byte at source to destination, replacing whatever byte was previously there. + .macro copybyte destination, source + .byte 0x15 + .4byte \destination + .4byte \source + .endm + + @ Changes the value of destination to value. + .macro setvar destination, value + .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, value + .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, value + .byte 0x18 + .2byte \destination + .2byte \value + .endm + + @ Copies the value of source into destination. + .macro copyvar destination, source + .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, source + .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, byte2 + .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, b + .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, b + .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, b + .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, b + .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, b + .byte 0x20 + .4byte \a + .4byte \b + .endm + + @ Compares the value of `var` to a fixed word value (b). + .macro compare_var_to_value var, value + .byte 0x21 + .2byte \var + .2byte \value + .endm + + @ Compares the value of `var1` to the value of `var2`. + .macro compare_var_to_var var1, var2 + .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 0x4FFF and 0x8000 to 0x8FFF are considered event variable identifiers + .macro compare arg1, arg2 + .if (((\arg1) >> 12) == 4 || ((\arg1) >> 12) == 8) && (((\arg2) >> 12) == 4 || ((\arg2) >> 12) == 8) + compare_var_to_var (\arg1), (\arg2) + .elseif (((\arg1) >> 12) == 4 || ((\arg1) >> 12) == 8) && ((\arg2) >= -0xFFFF && (\arg2) <= 0xFFFF) + compare_var_to_value (\arg1), ((\arg2) & 0xFFFF) + .else + .error "Invalid arguments for 'compare'" + .endif + .endm + + @ Calls the native C function stored at `func`. + .macro callnative func + .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 + .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 + .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, function + .byte 0x26 + .2byte \output + .2byte SPECIAL_\function + .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 time (frames? milliseconds?). + .macro delay time + .byte 0x28 + .2byte \time + .endm + + @ Sets a to 1. + .macro setflag a + .byte 0x29 + .2byte \a + .endm + + @ Sets a to 0. + .macro clearflag a + .byte 0x2a + .2byte \a + .endm + + @ Compares a to 1. + .macro checkflag a + .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, minute + .byte 0x2c + .2byte \hour + .2byte \minute + .endm + + @ Runs time based events. In FireRed, this command is a nop. + .macro dodailyevents + .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 + .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 + .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. The byte is apparently supposed to be 0x00. + .macro playbgm song_number, unknown + .byte 0x33 + .2byte \song_number + .byte \unknown + .endm + + @ Saves the specified (song_number) song to be played later. + .macro savebgm song_number + .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 + .byte 0x36 + .2byte \song_number + .endm + + @ Fades out the currently-playing song. + .macro fadeoutbgm speed + .byte 0x37 + .byte \speed + .endm + + @ Fades the previously-playing song back in. + .macro fadeinbgm speed + .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, warp, X, Y + .byte 0x39 + map \map + .byte \warp + .2byte \X + .2byte \Y + .endm + + @ Clone of warp that does not play a sound effect. + .macro warpsilent map, warp, X, Y + .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, warp, X, Y + .byte 0x3b + map \map + .byte \warp + .2byte \X + .2byte \Y + .endm + + @ Warps the player to another map using a hole animation. + .macro warphole map + .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, warp, X, Y + .byte 0x3d + map \map + .byte \warp + .2byte \X + .2byte \Y + .endm + + @ Sets the warp destination to be used later. + .macro setwarp map, warp, X, Y + .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, warp, X, Y + .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, warp, X, Y + .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, warp, X, Y + .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, Y + .byte 0x42 + .2byte \X + .2byte \Y + .endm + + @ Retrieves the number of Pokemon in the player's party, and stores that number in variable 0x800D (LASTRESULT). + .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 variable 0x800D (LASTRESULT) will be set to 0x0001; otherwise, LASTRESULT is set to 0x0000. + .macro giveitem index, quantity + .byte 0x44 + .2byte \index + .2byte \quantity + .endm + + @ Removes quantity of item index from the player's Bag. + .macro takeitem index, quantity + .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 variable 0x800D (LASTRESULT) to 0x0001 if there is room, or 0x0000 is there is no room. + .macro checkitemspace index, quantity + .byte 0x46 + .2byte \index + .2byte \quantity + .endm + + @ Checks if the player has quantity or more of item index in their Bag. Sets variable 0x800D (LASTRESULT) to 0x0001 if the player has enough of the item, or 0x0000 if they have fewer than quantity of the item. + .macro checkitem index, quantity + .byte 0x47 + .2byte \index + .2byte \quantity + .endm + + @ Checks which Bag pocket the specified (index) item belongs in, and writes the value to variable 0x800D (LASTRESULT). 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 + .byte 0x48 + .2byte \index + .endm + + @ Adds a quantity amount of item index to the player's PC. Both arguments can be variables. + .macro givepcitem index, quantity + .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, quantity + .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 givedecoration decoration + .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 takedecoration decoration + .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 + .byte 0x4d + .2byte \decoration + .endm + + @ Checks if the player has enough space in their PC to hold decoration. Sets variable 0x800D (LASTRESULT) to 0x0001 if there is room, or 0x0000 is there is no room. In FireRed, this command is a nop. (The argument is read, but not used for anything.) + .macro checkdecorspace decoration + .byte 0x4e + .2byte \decoration + .endm + + @ Applies the movement data at movements to the specified (index) Object event. Also closes any standard message boxes that are still open. + @ This command in fact uses variables to access the Object event ID. So, for example, if you setvar 0x8000 to 0x3, and then use applymovementpos 0x8000 @move1, Object event 3 will have the movements at @move1 applied to them. + .macro applymovement index, movements, mapGroup, mapNum + .ifb \mapGroup + .byte 0x4f + .2byte \index + .4byte \movements + .else + .byte 0x50 + .2byte \index + .4byte \movements + .byte \mapGroup + .byte \mapNum + .endif + .endm + + @ Blocks script execution until the movements being applied to the specified (index) Object event finish. If the specified Object event is 0x0000, then the command will block script execution until all Object events affected by applymovement finish their movements. If the specified Object event is not currently being manipulated with applymovement, then this command does nothing. + .macro waitmovement index, mapBank, mapNum + .ifb \mapBank + .byte 0x51 + .2byte \index + .else + .byte 0x52 + .2byte \index + .byte \mapBank + .byte \mapNum + .endif + .endm + + @ Attempts to hide the specified (local_ID, a local ID) Object event on the specified 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 localId, mapGroup, mapNum + .ifb \mapGroup + .byte 0x53 + .2byte \localId + .else + .byte 0x54 + .2byte \localId + .byte \mapGroup + .byte \mapNum + .endif + .endm + + .macro addobject localId, mapGroup, mapNum + .ifb \mapGroup + .byte 0x55 + .2byte \localId + .else + .byte 0x56 + .2byte \localId + .byte \mapGroup + .byte \mapNum + .endif + .endm + + @ Sets the specified (index) Object's position on the current map. + .macro setobjectxy index, x, y + .byte 0x57 + .2byte \index + .2byte \x + .2byte \y + .endm + + .macro showobjectat index, map + .byte 0x58 + .2byte \index + map \map + .endm + + .macro hideobjectat index, map + .byte 0x59 + .2byte \index + map \map + .endm + + @ If the script was called by a Object event, then that Object will turn to face toward the tile that the player is stepping off of. + .macro faceplayer + .byte 0x5a + .endm + + .macro turnobject index, direction + .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, trainer, word, pointer1, pointer2, pointer3, pointer4 + .byte 0x5c + .byte \type + .2byte \trainer + .2byte \word + .if \type == 0 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .elseif \type == 1 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ event script + .elseif \type == 2 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ event script + .elseif \type == 3 + .4byte \pointer1 @ text + .elseif \type == 4 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ text + .elseif \type == 5 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .elseif \type == 6 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ text + .4byte \pointer4 @ event script + .elseif \type == 7 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ text + .elseif \type == 8 + .4byte \pointer1 @ text + .4byte \pointer2 @ text + .4byte \pointer3 @ text + .4byte \pointer4 @ event script + .endif + .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 + .byte 0x60 + .2byte \trainer + .endm + + @ Sets Flag (trainer + 0x500). + .macro settrainerflag trainer + .byte 0x61 + .2byte \trainer + .endm + + @ Clears Flag (trainer + 0x500). + .macro cleartrainerflag trainer + .byte 0x62 + .2byte \trainer + .endm + + .macro setobjectxyperm index, x, y + .byte 0x63 + .2byte \index + .2byte \x + .2byte \y + .endm + + .macro moveobjectoffscreen index + .byte 0x64 + .2byte \index + .endm + + .macro setobjectmovementtype word, byte + .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 + .byte 0x67 + .4byte \text + .endm + + @ Closes the current message box. + .macro closemessage + .byte 0x68 + .endm + + @ Ceases movement for all Objects on-screen. + .macro lockall + .byte 0x69 + .endm + + @ If the script was called by an Object, then that Object's movement will cease. + .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 variable 0x800D (LASTRESULT); 0x0000 for "NO" or if the user pressed B, and 0x0001 for "YES". + .macro yesnobox x, y + .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 and the one to be used is specified with list. If b 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, y, list, b + .byte 0x6f + .byte \x + .byte \y + .byte \list + .byte \b + .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 and the one to be used is specified with list. 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 b 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, y, list, default, b + .byte 0x70 + .byte \x + .byte \y + .byte \list + .byte \default + .byte \b + .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 and the one to be used is specified with list. The per_row argument determines how many list items will be shown on a single row of the box. + .macro multichoicegrid x, y, list, per_row, B + .byte 0x71 + .byte \x + .byte \y + .byte \list + .byte \per_row + .byte \B + .endm + + .macro drawbox byte1, byte2, byte3, byte4 + .byte 0x72 + .byte \byte1 + .byte \byte2 + .byte \byte3 + .byte \byte4 + .endm + + .macro erasebox byte1, byte2, byte3, byte4 + .byte 0x73 + .byte \byte1 + .byte \byte2 + .byte \byte3 + .byte \byte4 + .endm + + .macro drawboxtext byte1, byte2, byte3, byte4 + .byte 0x74 + .byte \byte1 + .byte \byte2 + .byte \byte3 + .byte \byte4 + .endm + + @ Displays a box containing the front sprite for the specified (species) Pokemon species. + .macro drawmonpic species, x, y + .byte 0x75 + .2byte \species + .byte \x + .byte \y + .endm + + @ Hides all boxes displayed with drawmonpic. + .macro erasemonpic + .byte 0x76 + .endm + + @ Draws an image of the winner of the contest. In FireRed, this command is a nop. (The argument is discarded.) + .macro drawcontestwinner a + .byte 0x77 + .byte \a + .endm + + @ Displays the string at pointer as braille text in a standard message box. The string must be formatted to use braille characters. + .macro braillemessage text + .byte 0x78 + .4byte \text + .endm + + @ Gives the player one of the specified (species) Pokemon at level level holding item. The unknown arguments should all be zeroes. + .macro givemon species, level, item, unknown1, unknown2, unknown3 + .byte 0x79 + .2byte \species + .byte \level + .2byte \item + .4byte \unknown1 + .4byte \unknown2 + .byte \unknown3 + .endm + + .macro giveegg species + .byte 0x7a + .2byte \species + .endm + + .macro setmonmove index, slot, move + .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, variable 0x800D (LASTRESULT) is set to the (zero-indexed) slot number of the first Pokemon that knows the move. If not, LASTRESULT is set to 0x0006. Variable 0x8004 is also set to this Pokemon's species. + .macro checkpartymove index + .byte 0x7c + .2byte \index + .endm + + @ Writes the name of the Pokemon at index species to the specified buffer. + .macro bufferspeciesname out, species + .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 + .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, slot + .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. + .macro bufferitemname out, item + .byte 0x80 + .byte \out + .2byte \item + .endm + + @ Writes the name of the decoration at index decoration to the specified buffer. In FireRed, this command is a nop. + .macro bufferdecorationname out, decoration + .byte 0x81 + .byte \out + .2byte \decoration + .endm + + @ Writes the name of the move at index move to the specified buffer. + .macro buffermovename out, move + .byte 0x82 + .byte \out + .2byte \move + .endm + + @ Converts the value of input to a decimal string, and writes that string to the specified buffer. + .macro buffernumberstring out, input + .byte 0x83 + .byte \out + .2byte \input + .endm + + @ Writes the standard string identified by index to the specified buffer. This command has no protections in place at all, so specifying an invalid standard string (e.x. 0x2B) can and usually will cause data corruption. + .macro bufferstdstring out, index + .byte 0x84 + .byte \out + .2byte \index + .endm + + @ Copies the string at offset to the specified buffer. + .macro bufferstring out, offset + .byte 0x85 + .byte \out + .4byte \offset + .endm + + @ Opens the Pokemart system, offering the specified products for sale. + .macro pokemart products + .byte 0x86 + .4byte \products + .endm + + @ Opens the Pokemart system and treats the list of items as decorations. + .macro pokemartdecoration products + .byte 0x87 + .4byte \products + .endm + + @ Apparent clone of pokemartdecoration. + .macro pokemartdecoration2 products + .byte 0x88 + .4byte \products + .endm + + @ Starts up the slot machine minigame. + .macro playslotmachine word + .byte 0x89 + .2byte \word + .endm + + @ Sets a berry tree's specific berry and growth stage. In FireRed, this command is a nop. + .macro setberrytree tree_id, berry, growth_stage + .byte 0x8a + .byte \tree_id + .byte \berry + .byte \growth_stage + .endm + + @ This allows you to choose a Pokemon to use in a contest. In FireRed, this command sets the byte at 0x03000EA8 to 0x01. + .macro choosecontestmon + .byte 0x8b + .endm + + @ Starts a contest. In FireRed, this command is a nop. + .macro startcontest + .byte 0x8c + .endm + + @ Shows the results of a contest. In FireRed, this command is a nop. + .macro showcontestresults + .byte 0x8d + .endm + + @ Starts a contest over a link connection. In FireRed, this command is a nop. + .macro contestlinktransfer + .byte 0x8e + .endm + + @ Stores a random integer between 0 and limit in variable 0x800D (LASTRESULT). + .macro random limit + .byte 0x8f + .2byte \limit + .endm + + @ If check is 0x00, this command adds value to the player's money. + .macro givemoney value, check + .byte 0x90 + .4byte \value + .byte \check + .endm + + @ If check is 0x00, this command subtracts value from the player's money. + .macro takemoney value, check + .byte 0x91 + .4byte \value + .byte \check + .endm + + @ If check is 0x00, this command will check if the player has value or more money; script variable 0x800D (LASTRESULT) is set to 0x0001 if the player has enough money, or 0x0000 if the do not. + .macro checkmoney value, check + .byte 0x92 + .4byte \value + .byte \check + .endm + + @ Spawns a secondary box showing how much money the player has. + .macro showmoneybox x, y + .byte 0x93 + .byte \x + .byte \y + .endm + + @ Hides the secondary box spawned by showmoney. + .macro hidemoneybox x, y + .byte 0x94 + .byte \x + .byte \y + .endm + + @ Updates the secondary box spawned by showmoney. Consumes but does not use arguments. + .macro updatemoneybox x, y + .byte 0x95 + .byte \x + .byte \y + .endm + + @ Gets the price reduction for the index given. In FireRed, this command is a nop. + .macro getpricereduction index + .byte 0x96 + .2byte \index + .endm + + @ Fades the screen to and from black and white. Mode 0x00 fades from black, mode 0x01 fades out to black, mode 0x2 fades in from white, and mode 0x3 fades out to white. + .macro fadescreen effect + .byte 0x97 + .byte \effect + .endm + + @ Fades the screen to and from black and white. Mode 0x00 fades from black, mode 0x01 fades out to black, mode 0x2 fades in from white, and mode 0x3 fades out to white. Other modes may exist. + .macro fadescreenspeed effect, speed + .byte 0x98 + .byte \effect + .byte \speed + .endm + + .macro setflashradius word + .byte 0x99 + .2byte \word + .endm + + .macro animateflash byte + .byte 0x9a + .byte \byte + .endm + + .macro messageautoscroll pointer + .byte 0x9b + .4byte \pointer + .endm + + @ Executes the specified field move animation. + .macro dofieldeffect animation + .byte 0x9c + .2byte \animation + .endm + + @ Sets up the field effect argument argument with the value value. + .macro setfieldeffectargument argument, param + .byte 0x9d + .byte \argument + .2byte \param + .endm + + @ Blocks script execution until all playing field move animations complete. + .macro waitfieldeffect animation + .byte 0x9e + .2byte \animation + .endm + + @ Sets which healing place the player will return to if all of the Pokemon in their party faint. + .macro setrespawn heallocation + .byte 0x9f + .2byte \heallocation + .endm + + @ Checks the player's gender. If male, then 0x0000 is stored in variable 0x800D (LASTRESULT). If female, then 0x0001 is stored in LASTRESULT. + .macro checkplayergender + .byte 0xa0 + .endm + + @ Plays the specified (species) Pokemon's cry. You can use waitcry to block script execution until the sound finishes. + .macro playmoncry species, effect + .byte 0xa1 + .2byte \species + .2byte \effect + .endm + + @ Changes the metatile at (x, y) on the current map. + .macro setmetatile x, y, metatile_number, tile_attrib + .byte 0xa2 + .2byte \x + .2byte \y + .2byte \metatile_number + .2byte \tile_attrib + .endm + + @ Queues a weather change to the default weather for the map. + .macro resetweather + .byte 0xa3 + .endm + + @ Queues a weather change to type weather. + .macro setweather type + .byte 0xa4 + .2byte \type + .endm + + @ Executes the weather change queued with resetweather or setweather. The current weather will smoothly fade into the queued weather. + .macro doweather + .byte 0xa5 + .endm + + @ This command manages cases in which maps have tiles that change state when stepped on (specifically, cracked/breakable floors). + .macro setstepcallback subroutine + .byte 0xa6 + .byte \subroutine + .endm + + .macro setmaplayoutindex index + .byte 0xa7 + .2byte \index + .endm + + .macro setobjectpriority index, map, priority + .byte 0xa8 + .2byte \index + map \map + .byte \priority + .endm + + .macro resetobjectpriority index, map + .byte 0xa9 + .2byte \index + map \map + .endm + + .macro createvobject sprite, byte2, x, y, elevation, direction + .byte 0xaa + .byte \sprite + .byte \byte2 + .2byte \x + .2byte \y + .byte \elevation + .byte \direction + .endm + + .macro turnvobject index, direction + .byte 0xab + .byte \index + .byte \direction + .endm + + @ Opens the door metatile at (X, Y) with an animation. + .macro opendoor x, y + .byte 0xac + .2byte \x + .2byte \y + .endm + + @ Closes the door metatile at (X, Y) with an animation. + .macro closedoor x, y + .byte 0xad + .2byte \x + .2byte \y + .endm + + @ Waits for the door animation started with opendoor or closedoor to finish. + .macro waitdooranim + .byte 0xae + .endm + + @ Sets the door tile at (x, y) to be open without an animation. + .macro setdooropen x, y + .byte 0xaf + .2byte \x + .2byte \y + .endm + + @ Sets the door tile at (x, y) to be closed without an animation. + .macro setdoorclosed x, y + .byte 0xb0 + .2byte \x + .2byte \y + .endm + + @ In FireRed, this command is a nop. + .macro addelevmenuitem + .byte 0xb1 + .endm + + @ In FireRed and Emerald, this command is a nop. + .macro showelevmenu + .byte 0xb2 + .endm + + .macro checkcoins out + .byte 0xb3 + .2byte \out + .endm + + .macro givecoins count + .byte 0xb4 + .2byte \count + .endm + + .macro takecoins count + .byte 0xb5 + .2byte \count + .endm + + @ Prepares to start a wild battle against a species at Level level holding item. Running this command will not affect normal wild battles. You start the prepared battle with dowildbattle. + .macro setwildbattle species, level, item + .byte 0xb6 + .2byte \species + .byte \level + .2byte \item + .endm + + @ Starts a wild battle against the Pokemon generated by setwildbattle. Blocks script execution until the battle finishes. + .macro dowildbattle + .byte 0xb7 + .endm + + .macro setvaddress long, word + .byte 0xb8 + .4byte \long + .2byte \word + .endm + + .macro vgoto pointer + .byte 0xb9 + .4byte \pointer + .endm + + .macro vcall pointer + .byte 0xba + .4byte \pointer + .endm + + .macro vgoto_if byte, pointer + .byte 0xbb + .byte \byte + .4byte \pointer + .endm + + .macro vcall_if byte, pointer + .byte 0xbc + .byte \byte + .4byte \pointer + .endm + + .macro vmessage pointer + .byte 0xbd + .4byte \pointer + .endm + + .macro vloadptr pointer + .byte 0xbe + .4byte \pointer + .endm + + .macro vbufferstring byte, pointer + .byte 0xbf + .byte \byte + .4byte \pointer + .endm + + @ Spawns a secondary box showing how many Coins the player has. + .macro showcoinsbox x, y + .byte 0xc0 + .byte \x + .byte \y + .endm + + @ Hides the secondary box spawned by showcoins. It consumes its arguments but doesn't use them. + .macro hidecoinsbox x, y + .byte 0xc1 + .byte \x + .byte \y + .endm + + @ Updates the secondary box spawned by showcoins. It consumes its arguments but doesn't use them. + .macro updatecoinsbox x, y + .byte 0xc2 + .byte \x + .byte \y + .endm + + @ Increases the value of the specified game stat by 1. The stat's value will not be allowed to exceed 0x00FFFFFF. + .macro incrementgamestat stat + .byte 0xc3 + .byte \stat + .endm + + @ Sets the destination that using an Escape Rope or Dig will take the player to. + .macro setescapewarp map, warp, x, y + .byte 0xc4 + map \map + .byte \warp + .2byte \x + .2byte \y + .endm + + @ Blocks script execution until cry finishes. + .macro waitmoncry + .byte 0xc5 + .endm + + @ Writes the name of the specified (box) PC box to the specified buffer. + .macro bufferboxname out, box + .byte 0xc6 + .byte \out + .2byte \box + .endm + + @ Sets the color of the text in standard message boxes. 0x00 produces blue (male) text, 0x01 produces red (female) text, 0xFF resets the color to the default for the current OW's gender, and all other values produce black text. + .macro textcolor color + .byte 0xc7 + .byte \color + .endm + + @ The exact purpose of this command is unknown, but it is related to the blue help-text box that appears on the bottom of the screen when the Main Menu is opened. + .macro loadhelp pointer + .byte 0xc8 + .4byte \pointer + .endm + + @ The exact purpose of this command is unknown, but it is related to the blue help-text box that appears on the bottom of the screen when the Main Menu is opened. + .macro unloadhelp + .byte 0xc9 + .endm + + @ After using this command, all standard message boxes will use the signpost frame. + .macro signmsg + .byte 0xca + .endm + + @ Ends the effects of signmsg, returning message box frames to normal. + .macro normalmsg + .byte 0xcb + .endm + + @ Compares the value of a hidden variable to a dword. + .macro comparehiddenvar a, value + .byte 0xcc + .byte \a + .4byte \value + .endm + +@ Supplementary + + .macro goto_if_trainer_not_defeated opponent, dest + checktrainerflag \opponent + goto_if 0, \dest + .endm + + .macro goto_if_trainer_defeated opponent, dest + checktrainerflag \opponent + goto_if 1, \dest + .endm + + .macro call_if_trainer_not_defeated opponent, dest + checktrainerflag \opponent + call_if 0, \dest + .endm + + .macro call_if_trainer_defeated opponent, dest + checktrainerflag \opponent + call_if 1, \dest + .endm + + .macro goto_if_unset flag, dest + checkflag \flag + goto_if 0, \dest + .endm + + .macro goto_if_set flag, dest + checkflag \flag + goto_if 1, \dest + .endm + + .macro goto_if_lt dest @ LESS THAN + goto_if 0, \dest + .endm + + .macro goto_if_eq dest @ EQUAL + goto_if 1, \dest + .endm + + .macro goto_if_gt dest @ GREATER THAN + goto_if 2, \dest + .endm + + .macro goto_if_le dest @ LESS THAN OR EQUAL + goto_if 3, \dest + .endm + + .macro goto_if_ge dest @ GREATER THAN OR EQUAL + goto_if 4, \dest + .endm + + .macro goto_if_ne dest @ NOT EQUAL + goto_if 5, \dest + .endm + + .macro call_if_unset flag, dest + checkflag \flag + call_if 0, \dest + .endm + + .macro call_if_set flag, dest + checkflag \flag + call_if 1, \dest + .endm + + .macro call_if_lt dest @ LESS THAN + call_if 0, \dest + .endm + + .macro call_if_eq dest @ EQUAL + call_if 1, \dest + .endm + + .macro call_if_gt dest @ GREATER THAN + call_if 2, \dest + .endm + + .macro call_if_le dest @ LESS THAN OR EQUAL + call_if 3, \dest + .endm + + .macro call_if_ge dest @ GREATER THAN OR EQUAL + call_if 4, \dest + .endm + + .macro call_if_ne dest @ NOT EQUAL + call_if 5, \dest + .endm + + .macro switch var + copyvar VAR_SPECIAL_0, \var + .endm + + .macro case condition, dest + compare_var_to_value VAR_SPECIAL_0, \condition + goto_if_eq \dest + .endm + + .macro msgbox text, type=4 + loadword 0, \text + callstd \type + .endm + + @ Message box types + MSGBOX_YESNO = 5 + + YES = 1 + NO = 0 + + .macro giveitem_std item, amount=1, function=0 + setorcopyvar VAR_SPECIAL_0, \item + setorcopyvar VAR_SPECIAL_1, \amount + callstd \function + .endm + + .macro givedecoration_std decoration + setorcopyvar VAR_SPECIAL_0, \decoration + callstd 7 + .endm diff --git a/include/macros/field_effect_script.inc b/include/macros/field_effect_script.inc new file mode 100644 index 000000000..d5895b0ef --- /dev/null +++ b/include/macros/field_effect_script.inc @@ -0,0 +1,42 @@ + .macro loadtiles address + .byte 0 + .4byte \address + .endm + + .macro loadfadedpal address + .byte 1 + .4byte \address + .endm + + .macro loadpal address + .byte 2 + .4byte \address + .endm + + .macro callnative address + .byte 3 + .4byte \address + .endm + + .macro end + .byte 4 + .endm + + .macro loadgfx_callnative tiles_address, palette_address, function_address + .byte 5 + .4byte \tiles_address + .4byte \palette_address + .4byte \function_address + .endm + + .macro loadtiles_callnative tiles_address, function_address + .byte 6 + .4byte \tiles_address + .4byte \function_address + .endm + + .macro loadfadedpal_callnative palette_address, function_address + .byte 7 + .4byte \palette_address + .4byte \function_address + .endm diff --git a/include/macros/function.inc b/include/macros/function.inc new file mode 100644 index 000000000..67fb373a8 --- /dev/null +++ b/include/macros/function.inc @@ -0,0 +1,29 @@ + .macro arm_func_start name + .align 2, 0 + .global \name + .arm + .type \name, function + .endm + + .macro arm_func_end name + .size \name, .-\name + .endm + + .macro thumb_func_start name + .align 2, 0 + .global \name + .thumb + .thumb_func + .type \name, function + .endm + + .macro non_word_aligned_thumb_func_start name + .global \name + .thumb + .thumb_func + .type \name, function + .endm + + .macro thumb_func_end name + .size \name, .-\name + .endm diff --git a/include/macros/m4a.inc b/include/macros/m4a.inc new file mode 100644 index 000000000..6c5abc09b --- /dev/null +++ b/include/macros/m4a.inc @@ -0,0 +1,13 @@ + .macro song label, music_player, unknown + .4byte \label + .2byte \music_player + .2byte \unknown + .endm + + .macro music_player info_struct, track_struct, unknown_1, unknown_2 + .4byte \info_struct + .4byte \track_struct + .byte \unknown_1 + .space 1 + .2byte \unknown_2 + .endm diff --git a/include/macros/map.inc b/include/macros/map.inc new file mode 100644 index 000000000..db37d9346 --- /dev/null +++ b/include/macros/map.inc @@ -0,0 +1,96 @@ + .macro map map_id + .byte \map_id >> 8 @ map group + .byte \map_id & 0xFF @ map num + .endm + + .macro map_script type, address + .byte \type + .4byte \address + .endm + + .macro map_script_2 word1, word2, address + .2byte \word1 + .2byte \word2 + .4byte \address + .endm + + .macro object_event byte1, word1, byte2, byte3, byte4, byte5, byte6, byte7, byte8, byte9, byte10, byte11, byte12, byte13, byte14, script, word2, byte15, byte16 + .byte \byte1 + .2byte \word1 + .byte \byte2, \byte3, \byte4, \byte5, \byte6, \byte7, \byte8, \byte9, \byte10, \byte11, \byte12, \byte13, \byte14 + .4byte \script + .2byte \word2 + .byte \byte15, \byte16 + inc _num_npcs + .endm + + .macro warp_def x, y, byte, warp, map_id + .2byte \x, \y + .byte \byte, \warp + .byte \map_id & 0xFF @ map num + .byte \map_id >> 8 @ map group + inc _num_warps + .endm + + .macro coord_event x, y, byte1, byte2, word1, word2, word3, script + .2byte \x, \y + .byte \byte1, \byte2 + .2byte \word1, \word2, \word3 + .4byte \script + inc _num_traps + .endm + + .macro coord_weather_event x, y, height, weather + coord_event \x, \y, \height, 0, \weather, 0, 0, 0x0 + .endm + + .macro bg_event x, y, byte, kind, word, arg6, arg7, arg8 + .2byte \x, \y + .byte \byte, \kind + .2byte \word + .if \kind < 5 + .4byte \arg6 + .else + .2byte \arg6 + .byte \arg7, \arg8 + .endif + inc _num_signs + .endm + + .macro bg_hidden_item_event x, y, height, item, flag + bg_event \x, \y, \height, 7, 0, \item, ((\flag) - FLAG_HIDDEN_ITEMS_START), 0 + .endm + + .macro bg_secret_base_event x, y, height, secret_base_id + bg_event \x, \y, \height, 8, 0, \secret_base_id, 0, 0 + .endm + + .macro map_events npcs, warps, traps, signs + .byte _num_npcs, _num_warps, _num_traps, _num_signs + .4byte \npcs, \warps, \traps, \signs + reset_map_events + .endm + + .macro reset_map_events + .set _num_npcs, 0 + .set _num_warps, 0 + .set _num_traps, 0 + .set _num_signs, 0 + .endm + + reset_map_events + + + .equiv connection_down, 1 + .equiv connection_up, 2 + .equiv connection_left, 3 + .equiv connection_right, 4 + .equiv connection_dive, 5 + .equiv connection_emerge, 6 + + .macro connection direction, offset, map, filler + .4byte connection_\direction + .4byte \offset + map \map + .space 2 + .endm diff --git a/include/macros/movement.inc b/include/macros/movement.inc new file mode 100644 index 000000000..674ce7169 --- /dev/null +++ b/include/macros/movement.inc @@ -0,0 +1,116 @@ + .macro create_movement name + enum _\name + .macro \name + .byte _\name + .endm + .endm + + enum_start + create_movement step_00 + create_movement step_01 + create_movement step_02 + create_movement step_03 + create_movement slow_step_down + create_movement slow_step_up + create_movement slow_step_left + create_movement slow_step_right + create_movement step_down + create_movement step_up + create_movement step_left + create_movement step_right + create_movement fast_step_down + create_movement fast_step_up + create_movement fast_step_left + create_movement fast_step_right + create_movement step_10 + create_movement step_11 + create_movement step_12 + create_movement step_13 + create_movement step_14 + create_movement step_15 + create_movement step_16 + create_movement step_17 + create_movement step_18 + create_movement step_19 + create_movement step_1a + create_movement step_1b + create_movement step_1c + create_movement step_1d + create_movement step_1e + create_movement step_1f + create_movement step_20 + create_movement step_21 + create_movement step_22 + create_movement step_23 + create_movement step_24 + create_movement step_25 + create_movement step_26 + create_movement step_27 + create_movement step_28 + create_movement step_29 + create_movement step_2a + create_movement step_2b + create_movement step_2c + create_movement step_2d + create_movement step_2e + create_movement step_2f + create_movement step_30 + create_movement step_31 + create_movement step_32 + create_movement step_33 + create_movement step_34 + create_movement step_35 + create_movement step_36 + create_movement step_37 + create_movement step_38 + create_movement step_39 + create_movement step_3a + create_movement step_3b + create_movement step_3c + create_movement step_3d + create_movement step_3e + create_movement step_3f + create_movement step_40 + create_movement step_41 + create_movement step_42 + create_movement step_43 + create_movement step_44 + create_movement step_45 + create_movement step_46 + create_movement step_47 + create_movement step_48 + create_movement step_49 + create_movement step_4a + create_movement step_4b + create_movement step_4c + create_movement step_4d + create_movement step_4e + create_movement step_4f + create_movement step_50 + create_movement step_51 + create_movement step_52 + create_movement step_53 + create_movement step_54 + create_movement step_55 + create_movement step_56 + create_movement step_57 + create_movement step_58 + create_movement step_59 + create_movement step_5a + create_movement step_5b + create_movement step_5c + create_movement step_5d + create_movement step_5e + create_movement step_5f + create_movement step_60 + create_movement step_61 + + enum_start 0x91 + create_movement step_91 + create_movement step_92 + + enum_start 0x96 + create_movement step_96 + + enum_start 0xfe + create_movement step_end diff --git a/include/macros/music_voice.inc b/include/macros/music_voice.inc new file mode 100644 index 000000000..b7a9e7f8d --- /dev/null +++ b/include/macros/music_voice.inc @@ -0,0 +1,125 @@ + .macro voice_directsound base_midi_key, pan, sample_data_pointer, attack, decay, sustain, release + .byte 0 + _voice_directsound \base_midi_key, \pan, \sample_data_pointer, \attack, \decay, \sustain, \release + .endm + + .macro voice_directsound_no_resample base_midi_key, pan, sample_data_pointer, attack, decay, sustain, release + .byte 8 + _voice_directsound \base_midi_key, \pan, \sample_data_pointer, \attack, \decay, \sustain, \release + .endm + + .macro voice_directsound_alt base_midi_key, pan, sample_data_pointer, attack, decay, sustain, release + .byte 16 + _voice_directsound \base_midi_key, \pan, \sample_data_pointer, \attack, \decay, \sustain, \release + .endm + + .macro _voice_directsound base_midi_key, pan, sample_data_pointer, attack, decay, sustain, release + .byte \base_midi_key + .byte 0 + .if \pan != 0 + .byte (0x80 | \pan) + .else + .byte 0 + .endif + .4byte \sample_data_pointer + .byte \attack + .byte \decay + .byte \sustain + .byte \release + .endm + + .macro voice_square_1 sweep, duty_cycle, attack, decay, sustain, release + _voice_square_1 1, \sweep, \duty_cycle, \attack, \decay, \sustain, \release + .endm + + .macro voice_square_1_alt sweep, duty_cycle, attack, decay, sustain, release + _voice_square_1 9, \sweep, \duty_cycle, \attack, \decay, \sustain, \release + .endm + + .macro _voice_square_1 type, sweep, duty_cycle, attack, decay, sustain, release + .byte \type, 60, 0 + .byte \sweep + .byte (\duty_cycle & 0x3) + .byte 0, 0, 0 + .byte (\attack & 0x7) + .byte (\decay & 0x7) + .byte (\sustain & 0xF) + .byte (\release & 0x7) + .endm + + .macro voice_square_2 duty_cycle, attack, decay, sustain, release + _voice_square_2 2, \duty_cycle, \attack, \decay, \sustain, \release + .endm + + .macro voice_square_2_alt duty_cycle, attack, decay, sustain, release + _voice_square_2 10, \duty_cycle, \attack, \decay, \sustain, \release + .endm + + .macro _voice_square_2 type, duty_cycle, attack, decay, sustain, release + .byte \type, 60, 0, 0 + .byte (\duty_cycle & 0x3) + .byte 0, 0, 0 + .byte (\attack & 0x7) + .byte (\decay & 0x7) + .byte (\sustain & 0xF) + .byte (\release & 0x7) + .endm + + .macro voice_programmable_wave wave_samples_pointer, attack, decay, sustain, release + _voice_programmable_wave 3, \wave_samples_pointer, \attack, \decay, \sustain, \release + .endm + + .macro voice_programmable_wave_alt wave_samples_pointer, attack, decay, sustain, release + _voice_programmable_wave 11, \wave_samples_pointer, \attack, \decay, \sustain, \release + .endm + + .macro _voice_programmable_wave type, wave_samples_pointer, attack, decay, sustain, release + .byte \type, 60, 0, 0 + .4byte \wave_samples_pointer + .byte (\attack & 0x7) + .byte (\decay & 0x7) + .byte (\sustain & 0xF) + .byte (\release & 0x7) + .endm + + .macro voice_noise period, attack, decay, sustain, release + _voice_noise 4, \period, \attack, \decay, \sustain, \release + .endm + + .macro voice_noise_alt period, attack, decay, sustain, release + _voice_noise 12, \period, \attack, \decay, \sustain, \release + .endm + + .macro _voice_noise type, period, attack, decay, sustain, release + .byte \type, 60, 0, 0 + .byte (\period & 0x1) + .byte 0, 0, 0 + .byte (\attack & 0x7) + .byte (\decay & 0x7) + .byte (\sustain & 0xF) + .byte (\release & 0x7) + .endm + + .macro voice_keysplit voice_group_pointer, keysplit_table_pointer + .byte 0x40, 0, 0, 0 + .4byte \voice_group_pointer + .4byte \keysplit_table_pointer + .endm + + .macro voice_keysplit_all voice_group_pointer + .byte 0x80, 0, 0, 0 + .4byte \voice_group_pointer + .4byte 0 + .endm + + .macro cry sample + .byte 0x20, 60, 0, 0 + .4byte \sample + .byte 0xff, 0, 0xff, 0 + .endm + + .macro cry2 sample + .byte 0x30, 60, 0, 0 + .4byte \sample + .byte 0xff, 0, 0xff, 0 + .endm diff --git a/include/macros/pokemon_data.inc b/include/macros/pokemon_data.inc new file mode 100644 index 000000000..b0a5f22e3 --- /dev/null +++ b/include/macros/pokemon_data.inc @@ -0,0 +1,57 @@ + .macro pokedex_entry pokemon_name, height, weight, pokemon_scale, pokemon_offset, trainer_scale, trainer_offset + .2byte \height @ in decimeters + .2byte \weight @ in hectograms + .4byte DexDescription_\pokemon_name\()_1 + .4byte DexDescription_\pokemon_name\()_2 + .2byte 0 @ unused + .2byte \pokemon_scale + .2byte \pokemon_offset + .2byte \trainer_scale + .2byte \trainer_offset + .2byte 0 @ padding + .endm + + .macro base_stats hp, attack, defense, speed, sp_attack, sp_defense + .byte \hp + .byte \attack + .byte \defense + .byte \speed + .byte \sp_attack + .byte \sp_defense + .endm + + .macro ev_yield hp, attack, defense, speed, sp_attack, sp_defense + .2byte (\sp_defense << 10) | (\sp_attack << 8) | (\speed << 6) | (\defense << 4) | (\attack << 2) | \hp + .endm + + .macro level_up_move level, move + .2byte (\level << 9) | \move + .endm + + .macro evo_entry method, parameter, target_species + .2byte \method + .2byte \parameter + .2byte \target_species + .2byte 0 @ padding + .endm + + .macro empty_evo_entries count + .fill 8 * \count, 1, 0 + .endm + + .macro egg_moves_begin species + .2byte 20000 + \species + .endm + +@ If the min level equals the max level, only one level argument is needed. + .macro wild_mon species, min_level, max_level + .byte \min_level + + .ifb \max_level + .byte \min_level + .else + .byte \max_level + .endif + + .2byte SPECIES_\species + .endm diff --git a/include/menu.h b/include/menu.h index 9a5ca62a0..3295cd5c5 100644 --- a/include/menu.h +++ b/include/menu.h @@ -26,45 +26,43 @@ extern u16 gMenuMessageBoxContentTileOffset; void CloseMenu(void); void AppendToList(u8 *list, u8 *pindex, u32 value); -void InitMenuWindow(const struct WindowConfig *); -void MultistepInitMenuWindowBegin(const struct WindowConfig *); +void InitMenuWindow(const struct WindowTemplate *); +void MultistepInitMenuWindowBegin(const struct WindowTemplate *); bool32 MultistepInitMenuWindowContinue(void); -void unref_sub_8071DA4(struct WindowConfig *, u16); -void MenuLoadTextWindowGraphics_OverrideFrameType(u8); -void MenuLoadTextWindowGraphics(void); -void BasicInitMenuWindow(const struct WindowConfig *); -void MenuPrint(const u8 *, u8, u8); -void MenuZeroFillWindowRect(u8, u8, u8, u8); -void MenuFillWindowRectWithBlankTile(u8, u8, u8, u8); -void MenuZeroFillScreen(void); -void MenuDrawTextWindow(u8, u8, u8, u8); +void unref_sub_8071DA4(struct WindowTemplate *, u16); +void Menu_LoadStdFrameGraphicsOverrideStyle(u8); +void Menu_LoadStdFrameGraphics(void); +void BasicInitMenuWindow(const struct WindowTemplate *); +void Menu_PrintText(const u8 *, u8, u8); +void Menu_EraseWindowRect(u8, u8, u8, u8); +void Menu_BlankWindowRect(u8, u8, u8, u8); +void Menu_EraseScreen(void); +void Menu_DrawStdWindowFrame(u8, u8, u8, u8); void sub_8071F40(const u8 *); void sub_8071F60(u8, u8, u8); u16 unref_sub_8071F98(u8, u8); void unref_sub_8071FBC(u16, u8, u8, u8, u8); -void MenuDisplayMessageBox(void); +void Menu_DisplayDialogueFrame(void); void MenuPrintMessage(const u8 *, u8, u8); void MenuPrintMessageDefaultCoords(const u8 *); -void MenuSetText(const u8 *); -u8 MenuUpdateWindowText(void); +void Menu_SetText(const u8 *); +u8 Menu_UpdateWindowText(void); u8 unref_sub_8072098(void); -void sub_80720B0(void); -u8 MoveMenuCursor(s8); -u8 MoveMenuCursorNoWrap(s8); -u8 GetMenuCursorPos(void); -s8 ProcessMenuInput(void); -s8 ProcessMenuInputNoWrap(void); -u8 MoveMenuCursor3(s8); -u8 MoveMenuCursor4(s8); +void Menu_ClearWindowText(void); +u8 Menu_MoveCursor(s8); +u8 Menu_MoveCursorNoWrap(s8); +u8 Menu_GetCursorPos(void); +s8 Menu_ProcessInput(void); +s8 Menu_ProcessInputNoWrap(void); void sub_807274C(u8, u8, u8, u8, const struct MenuAction[], u8, u32); -s8 sub_80727CC(void); -u8 sub_807288C(u8); -void PrintMenuItems(u8, u8, u8, const struct MenuAction[]); -void PrintMenuItemsReordered(u8 left, u8 top, u8 menuItemCount, const struct MenuAction2 menuItems[], const u8 *order); +s8 Menu_ProcessInputGridLayout(void); +u8 Menu_GetColumnXCoord(u8); +void Menu_PrintItems(u8, u8, u8, const struct MenuAction[]); +void Menu_PrintItemsReordered(u8 left, u8 top, u8 menuItemCount, const struct MenuAction2 menuItems[], const u8 *order); void InitYesNoMenu(u8, u8, u8); void DisplayYesNoMenu(u8, u8, u32); -s8 ProcessMenuInputNoWrap_(void); -u8 MenuPrint_PixelCoords(const u8 *, u8, u16, u8); +s8 Menu_ProcessInputNoWrap_(void); +u8 Menu_PrintTextPixelCoords(const u8 *, u8, u16, u8); u8 sub_8072A18(const u8 *, u8, u16, u8, u32); u8 unref_sub_8072A5C(u8 *, u8 *, u8, u16, u8, u32); int sub_8072AB0(const u8 *, u8, u16, u8, u8, u32); @@ -75,16 +73,15 @@ u8 *sub_8072C14(u8 *, s32, u8, u8); u8 *sub_8072C44(u8 *, s32, u8, u8); u8 *sub_8072C74(u8 *, const u8 *, u8, u8); u8 sub_8072CA4(const u8 *s); -u8 sub_8072CBC(void); -void sub_8072CD4(u8 *, u8 *, u8 *); -u32 MenuUpdateWindowText_OverrideLineLength(u8); +u8 Menu_GetTextWindowPaletteNum(void); +void Menu_GetTextColors(u8 *, u8 *, u8 *); +u32 Menu_UpdateWindowTextOverrideLineLength(u8); struct Window * unref_sub_8072D0C(void); u8 InitMenu(u8, u8, u8, u8, u8, u8); -void RedrawMenuCursor(u8, u8); void unref_sub_8072DC0(void); void sub_8072DCC(u8); void sub_8072DDC(u8); -void HandleDestroyMenuCursors(void); +void Menu_DestroyCursor(void); #if GERMAN u8 *de_sub_8073174(u8 *name, const u8 *format); diff --git a/include/menu_cursor.h b/include/menu_cursor.h index ca82ef244..8d9a4f23c 100644 --- a/include/menu_cursor.h +++ b/include/menu_cursor.h @@ -4,11 +4,11 @@ #include "sprite.h" void sub_814A590(void); -u8 sub_814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5); +u8 MenuCursor_Create814A5C0(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5); u8 sub_814A758(u8 a1, u8 a2, u8 a3, u8 a4); u8 unref_sub_814A7AC(u8 a1, u16 a2, u8 a3); void DestroyMenuCursor(void); -void sub_814A880(u8 a1, u8 a2); +void MenuCursor_SetPos814A880(u8 a1, u8 a2); void sub_814A904(void); void sub_814A958(u8 a1); void sub_814AABC(void (*callback)(struct Sprite *)); @@ -16,8 +16,8 @@ void sub_814AAF8(u16 a1); void sub_814AB84(void); void unref_sub_814ABE4(int a1); u8 CreateBlendedOutlineCursor(u8 a1, u16 a2, u8 a3, u16 a4, u8 a5); -void sub_814AD44(void); -void sub_814AD7C(u8 a1, u8 a2); +void MenuCursor_Destroy814AD44(void); +void MenuCursor_SetPos814AD7C(u8 a1, u8 a2); void sub_814ADC8(void); void sub_814ADF4(u8 a1); diff --git a/include/scanline_effect.h b/include/scanline_effect.h new file mode 100644 index 000000000..314a856fa --- /dev/null +++ b/include/scanline_effect.h @@ -0,0 +1,48 @@ +#ifndef GUARD_SCANLINE_EFFECT_H +#define GUARD_SCANLINE_EFFECT_H + +// DMA control value to ransfer a single 16-bit value at HBlank +#define SCANLINE_EFFECT_DMACNT_16BIT (((DMA_ENABLE | DMA_START_HBLANK | DMA_REPEAT | DMA_SRC_INC | DMA_DEST_INC | DMA_16BIT | DMA_DEST_RELOAD) << 16) | 1) + +#define SCANLINE_EFFECT_REG_BG0HOFS (REG_ADDR_BG0HOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG0VOFS (REG_ADDR_BG0VOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG1HOFS (REG_ADDR_BG1HOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG1VOFS (REG_ADDR_BG1VOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG2HOFS (REG_ADDR_BG2HOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG2VOFS (REG_ADDR_BG2VOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG3HOFS (REG_ADDR_BG3HOFS - REG_ADDR_BG0HOFS) +#define SCANLINE_EFFECT_REG_BG3VOFS (REG_ADDR_BG3VOFS - REG_ADDR_BG0HOFS) + +struct ScanlineEffectParams +{ + volatile void *dmaDest; + u32 dmaControl; + u8 initState; + u8 unused9; +}; + +struct ScanlineEffect +{ + void *dmaSrcBuffers[2]; + volatile void *dmaDest; + u32 dmaControl; + void (*setFirstScanlineReg)(void); + u8 srcBuffer; + u8 state; + u8 unused16; + u8 unused17; + u8 waveTaskId; + u8 filler19[0x7]; +}; + +extern struct ScanlineEffect gScanlineEffect; + +extern u16 gScanlineEffectRegBuffers[][0x3C0]; + +void ScanlineEffect_Stop(void); +void ScanlineEffect_Clear(void); +void ScanlineEffect_SetParams(struct ScanlineEffectParams); +void ScanlineEffect_InitHBlankDmaTransfer(void); +u8 ScanlineEffect_InitWave(u8 startLine, u8 endLine, u8 frequency, u8 amplitude, u8 delayInterval, u8 regOffset, bool8 a7); + +#endif // GUARD_SCANLINE_EFFECT_H diff --git a/include/text.h b/include/text.h index 281a0535a..71afd1d00 100644 --- a/include/text.h +++ b/include/text.h @@ -74,7 +74,7 @@ #define CHAR_NEWLINE 0xFE #define EOS 0xFF // end of string -struct WindowConfig +struct WindowTemplate { u8 bgNum; u8 charBaseBlock; @@ -126,7 +126,7 @@ struct Window /*0x20*/ const u8 *text; /*0x24*/ u8 *tileData; /*0x28*/ u16 *tilemap; - /*0x2C*/ const struct WindowConfig *config; + /*0x2C*/ const struct WindowTemplate *template; }; extern vu16 *const gBGControlRegs[]; @@ -137,65 +137,65 @@ extern const u16 gUnknown_081E29D8[]; extern const u16 gUnknown_081E29E0[]; extern const u16 gUnknown_081E29E8[]; -extern const struct WindowConfig gWindowConfig_81E6C3C; -extern const struct WindowConfig gWindowConfig_81E6C58; -extern const struct WindowConfig gWindowConfig_81E6C74; -extern const struct WindowConfig gWindowConfig_81E6C90; -extern const struct WindowConfig gWindowConfig_81E6CAC; -extern const struct WindowConfig gWindowConfig_81E6CC8; -extern const struct WindowConfig gWindowConfig_81E6CE4; -extern const struct WindowConfig gWindowConfig_81E6D00; -extern const struct WindowConfig gWindowConfig_81E6D1C; -extern const struct WindowConfig gWindowConfig_81E6D38; -extern const struct WindowConfig gWindowConfig_81E6D54; -extern const struct WindowConfig gWindowConfig_81E6D70; -extern const struct WindowConfig gWindowConfig_81E6D8C; -extern const struct WindowConfig gWindowConfig_81E6DA8; -extern const struct WindowConfig WindowConfig_TrainerCard_Back_Values; -extern const struct WindowConfig WindowConfig_TrainerCard_Back_Labels; -extern const struct WindowConfig gWindowConfig_81E6DFC; -extern const struct WindowConfig gWindowConfig_81E6E18; -extern const struct WindowConfig gWindowConfig_81E6E34; -extern const struct WindowConfig gWindowConfig_81E6E50; -extern const struct WindowConfig gWindowConfig_81E6E6C; -extern const struct WindowConfig gWindowConfig_81E6E88; -extern const struct WindowConfig gWindowConfig_81E6EA4; -extern const struct WindowConfig gWindowConfig_81E6EC0; -extern const struct WindowConfig gWindowConfig_81E6EDC; -extern const struct WindowConfig gWindowConfig_81E6EF8; -extern const struct WindowConfig gWindowConfig_81E6F14; -extern const struct WindowConfig gWindowConfig_81E6F30; -extern const struct WindowConfig gWindowConfig_81E6F4C; -extern const struct WindowConfig gWindowConfig_81E6F68; -extern const struct WindowConfig gWindowConfig_81E6F84; -extern const struct WindowConfig gWindowConfig_81E6FA0; -extern const struct WindowConfig gWindowConfig_81E6FBC; -extern const struct WindowConfig gWindowConfig_81E6FD8; -extern const struct WindowConfig gWindowConfig_81E6FF4; -extern const struct WindowConfig gWindowConfig_81E7010; -extern const struct WindowConfig gWindowConfig_81E702C; -extern const struct WindowConfig gWindowConfig_81E7048; -extern const struct WindowConfig gWindowConfig_81E7064; -extern const struct WindowConfig gWindowConfig_81E7080; -extern const struct WindowConfig gWindowConfig_81E709C; -extern const struct WindowConfig gWindowConfig_81E70B8; -extern const struct WindowConfig gWindowConfig_81E70D4; -extern const struct WindowConfig gWindowConfig_81E70F0; -extern const struct WindowConfig gWindowConfig_81E710C; -extern const struct WindowConfig gWindowConfig_81E7128; -extern const struct WindowConfig gWindowConfig_81E7144; -extern const struct WindowConfig gWindowConfig_81E7160; -extern const struct WindowConfig gWindowConfig_81E717C; -extern const struct WindowConfig gWindowConfig_81E7198; -extern const struct WindowConfig gWindowConfig_81E71B4; -extern const struct WindowConfig gWindowConfig_81E71D0; -extern const struct WindowConfig gWindowConfig_81E71EC; -extern const struct WindowConfig gWindowConfig_81E7208; -extern const struct WindowConfig gWindowConfig_81E7224; -extern const struct WindowConfig gWindowConfig_81E7240; -extern const struct WindowConfig gWindowConfig_81E725C; -extern const struct WindowConfig gWindowConfig_81E7278; -extern const struct WindowConfig gWindowConfig_81E7294; +extern const struct WindowTemplate gWindowTemplate_81E6C3C; +extern const struct WindowTemplate gWindowTemplate_81E6C58; +extern const struct WindowTemplate gWindowTemplate_81E6C74; +extern const struct WindowTemplate gWindowTemplate_81E6C90; +extern const struct WindowTemplate gWindowTemplate_81E6CAC; +extern const struct WindowTemplate gWindowTemplate_81E6CC8; +extern const struct WindowTemplate gWindowTemplate_81E6CE4; +extern const struct WindowTemplate gWindowTemplate_81E6D00; +extern const struct WindowTemplate gWindowTemplate_81E6D1C; +extern const struct WindowTemplate gWindowTemplate_81E6D38; +extern const struct WindowTemplate gWindowTemplate_81E6D54; +extern const struct WindowTemplate gWindowTemplate_81E6D70; +extern const struct WindowTemplate gWindowTemplate_81E6D8C; +extern const struct WindowTemplate gWindowTemplate_81E6DA8; +extern const struct WindowTemplate gWindowTemplate_TrainerCard_Back_Values; +extern const struct WindowTemplate gWindowTemplate_TrainerCard_Back_Labels; +extern const struct WindowTemplate gWindowTemplate_81E6DFC; +extern const struct WindowTemplate gWindowTemplate_81E6E18; +extern const struct WindowTemplate gWindowTemplate_81E6E34; +extern const struct WindowTemplate gWindowTemplate_81E6E50; +extern const struct WindowTemplate gWindowTemplate_81E6E6C; +extern const struct WindowTemplate gWindowTemplate_81E6E88; +extern const struct WindowTemplate gWindowTemplate_81E6EA4; +extern const struct WindowTemplate gWindowTemplate_81E6EC0; +extern const struct WindowTemplate gWindowTemplate_81E6EDC; +extern const struct WindowTemplate gWindowTemplate_81E6EF8; +extern const struct WindowTemplate gWindowTemplate_81E6F14; +extern const struct WindowTemplate gWindowTemplate_81E6F30; +extern const struct WindowTemplate gWindowTemplate_81E6F4C; +extern const struct WindowTemplate gWindowTemplate_81E6F68; +extern const struct WindowTemplate gWindowTemplate_81E6F84; +extern const struct WindowTemplate gWindowTemplate_81E6FA0; +extern const struct WindowTemplate gWindowTemplate_81E6FBC; +extern const struct WindowTemplate gWindowTemplate_81E6FD8; +extern const struct WindowTemplate gWindowTemplate_81E6FF4; +extern const struct WindowTemplate gWindowTemplate_81E7010; +extern const struct WindowTemplate gWindowTemplate_81E702C; +extern const struct WindowTemplate gWindowTemplate_81E7048; +extern const struct WindowTemplate gWindowTemplate_81E7064; +extern const struct WindowTemplate gWindowTemplate_81E7080; +extern const struct WindowTemplate gWindowTemplate_81E709C; +extern const struct WindowTemplate gWindowTemplate_81E70B8; +extern const struct WindowTemplate gWindowTemplate_81E70D4; +extern const struct WindowTemplate gWindowTemplate_81E70F0; +extern const struct WindowTemplate gWindowTemplate_81E710C; +extern const struct WindowTemplate gWindowTemplate_81E7128; +extern const struct WindowTemplate gWindowTemplate_81E7144; +extern const struct WindowTemplate gWindowTemplate_81E7160; +extern const struct WindowTemplate gWindowTemplate_81E717C; +extern const struct WindowTemplate gWindowTemplate_81E7198; +extern const struct WindowTemplate gWindowTemplate_81E71B4; +extern const struct WindowTemplate gWindowTemplate_81E71D0; +extern const struct WindowTemplate gWindowTemplate_81E71EC; +extern const struct WindowTemplate gWindowTemplate_81E7208; +extern const struct WindowTemplate gWindowTemplate_81E7224; +extern const struct WindowTemplate gWindowTemplate_81E7240; +extern const struct WindowTemplate gWindowTemplate_81E725C; +extern const struct WindowTemplate gWindowTemplate_81E7278; +extern const struct WindowTemplate gWindowTemplate_81E7294; extern u16 gBGTilemapBuffers[4][0x400]; @@ -205,51 +205,51 @@ extern u8 gStringVar3[]; extern u8 gStringVar4[]; extern u8 gTileBuffer[]; -void LoadFontDefaultPalette(const struct WindowConfig *winConfig); -void SetUpWindowConfig(const struct WindowConfig *winConfig); +void LoadFontDefaultPalette(const struct WindowTemplate *winConfig); +void Text_LoadWindowTemplate(const struct WindowTemplate *winConfig); u16 InitWindowTileData(struct Window *win, u16 startOffset); u32 MultistepInitWindowTileData(struct Window *win, u16 startOffset); bool32 MultistepLoadFont(void); -void InitWindowFromConfig(struct Window *win, const struct WindowConfig *winConfig); -void InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top); -void sub_8002E4C(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6); -void sub_8002E90(struct Window *win, const u8 *text); -void sub_8002EB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top); -u8 sub_8002F44(struct Window *win); -u8 sub_8003418(struct Window *win); -u8 sub_8003460(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top); +void Text_InitWindowWithTemplate(struct Window *win, const struct WindowTemplate *winConfig); +void Text_InitWindow(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top); +void Text_InitWindow8002E4C(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6); +void Text_SetWindowText(struct Window *win, const u8 *text); +void Text_InitWindow8002EB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top); +u8 Text_PrintWindow8002F44(struct Window *win); +u8 Text_PrintWindowSimple(struct Window *win); +u8 Text_InitWindowAndPrintText(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top); u8 sub_8003490(struct Window *win, u8 c, u16 tileDataStartOffset, u8 left, u8 top); void sub_80034D4(u8 *tileData, const u8 *text); u8 sub_80034EC(u8 *str); u8 *sub_8003504(u8 *dest, s32 value, u8 alignAmount, u8 alignType); u8 *sub_8003558(u8 *dest, const u8 *src, u8 alignAmount, u8 alignType); -u8 sub_80035AC(struct Window *win); -u8 sub_800374C(struct Window *win); -u8 sub_8003778(struct Window *win); -u8 sub_80037A0(struct Window *win); -u32 sub_80037C8(struct Window *win, u8 lineLength); -void ClearWindowTextLines(struct Window *win); -u16 GetWindowTilemapEntry(struct Window *win, u8 x, u8 y); -void DrawWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom); +u8 Text_UpdateWindow(struct Window *win); +u8 Text_UpdateWindowInBattle(struct Window *win); +u8 Text_UpdateWindowAutoscroll(struct Window *win); +u8 Text_UpdateWindowInContest(struct Window *win); +u32 Text_UpdateWindowOverrideLineLength(struct Window *win, u8 lineLength); +void Text_ClearWindow(struct Window *win); +u16 Text_GetWindowTilemapEntry(struct Window *win, u8 x, u8 y); +void Text_FillWindowBorder(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom); void DrawWindowRect_DefaultPalette(struct Window *win, u16 tileNum, u8 left, u8 top, u8 right, u8 bottom); -void FillWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom); -void FillWindowRect_DefaultPalette(struct Window *win, u16 tileNum, u8 left, u8 top, u8 right, u8 bottom); -void ZeroFillWindowRect(struct Window *win, u8 left, u8 top, u8 right, u8 bottom); -void FillWindowRectWithBlankTile(struct Window *win, u8 left, u8 top, u8 right, u8 bottom); +void Text_FillWindowRect(struct Window *win, u16 tilemapEntry, u8 left, u8 top, u8 right, u8 bottom); +void Text_FillWindowRectDefPalette(struct Window *win, u16 tileNum, u8 left, u8 top, u8 right, u8 bottom); +void Text_EraseWindowRect(struct Window *win, u8 left, u8 top, u8 right, u8 bottom); +void Text_BlankWindowRect(struct Window *win, u8 left, u8 top, u8 right, u8 bottom); u8 GetExtCtrlCodeLength(u8 code); u8 *AlignInt1(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignType); u8 *AlignInt2(struct Window *win, u8 *dest, s32 value, u8 alignAmount, u8 alignType); u8 *AlignString(struct Window *win, u8 *dest, const u8 *src, u8 alignAmount, u8 alignType); u8 GetStringWidth(struct Window *win, const u8 *s); -u8 sub_8004D04(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6); -u8 sub_8004D38(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top); -u8 sub_8004DB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top, u16 a6); -u8 sub_8004E24(struct Window *win); -void sub_8004E28(struct Window *win, u8 *foreground, u8 *background, u8 *shadow); -void sub_8004E3C(const struct WindowConfig *winConfig, u8 *tileData, const u8 *text); -u8 GetStringWidthGivenWindowConfig(const struct WindowConfig *winConfig, const u8 *s); +u8 Text_InitWindow8004D04(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u16 top, u32 a6); +u8 Text_InitWindow8004D38(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top); +u8 Text_InitWindow8004DB0(struct Window *win, const u8 *text, u16 tileDataStartOffset, u8 left, u8 top, u16 a6); +u8 Text_GetWindowPaletteNum(struct Window *win); +void Text_GetTextColors(struct Window *win, u8 *foreground, u8 *background, u8 *shadow); +void Text_InitWindow8004E3C(const struct WindowTemplate *winConfig, u8 *tileData, const u8 *text); +u8 Text_GetStringWidthFromWindowTemplate(const struct WindowTemplate *winConfig, const u8 *s); void ConvertInternationalString(u8 *s, u8 language); -void StripExtCtrlCodes(u8 *str); +void Text_StripExtCtrlCodes(u8 *str); s32 StringCompareWithoutExtCtrlCodes(const u8 *str1, const u8 *str2); u8 sub_8004FD0(struct Window *win, u8 *dest, const u8 *src, u16 tileDataStartOffset, u8 left, u16 top, u8 width, u32 a8); diff --git a/include/text_window.h b/include/text_window.h index 7df1453ca..21e05ece0 100644 --- a/include/text_window.h +++ b/include/text_window.h @@ -9,17 +9,17 @@ struct FrameGraphics const u16 *palette; }; -u16 SetTextWindowBaseTileNum(u16 baseTileNum); -void LoadTextWindowGraphics(struct Window *win); -void LoadTextWindowGraphics_OverridePalSlot(struct Window *win, u8 palSlot); -void LoadTextWindowGraphics_OverrideFrameType(struct Window *win, u8 frameType); -void DrawTextWindow(struct Window *win, u8 left, u8 top, u8 right, u8 bottom); -const struct FrameGraphics *GetTextWindowFrameGraphics(u8 frameType); -u16 SetMessageBoxBaseTileNum(u16 baseTileNum); +u16 TextWindow_SetBaseTileNum(u16 baseTileNum); +void TextWindow_LoadStdFrameGraphics(struct Window *win); +void TextWindow_LoadStdFrameGraphicsOverridePal(struct Window *win, u8 palSlot); +void TextWindow_LoadStdFrameGraphicsOverrideStyle(struct Window *win, u8 frameType); +void TextWindow_DrawStdFrame(struct Window *win, u8 left, u8 top, u8 right, u8 bottom); +const struct FrameGraphics *TextWindow_GetFrameGraphics(u8 frameType); +u16 TextWindow_SetDlgFrameBaseTileNum(u16 baseTileNum); void unref_sub_80651DC(struct Window *, u8 *); -void DisplayMessageBox(struct Window *); -void DrawStandardMessageBox(struct Window *win); -void LoadMessageBoxTiles(struct Window *win); -void ClearStandardMessageBox(struct Window *win); +void TextWindow_DisplayDialogueFrame(struct Window *); +void TextWindow_DrawDialogueFrame(struct Window *win); +void TextWindow_LoadDialogueFrameTiles(struct Window *win); +void TextWindow_EraseDialogueFrame(struct Window *win); #endif // GUARD_TEXT_WINDOW_H diff --git a/include/unknown_task.h b/include/unknown_task.h deleted file mode 100644 index 011e5f5b5..000000000 --- a/include/unknown_task.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef GUARD_UNKNOWN_TASK_H -#define GUARD_UNKNOWN_TASK_H - -struct UnknownTaskStruct -{ - volatile void *dest; - u32 control; - u8 unk8; - u8 unk9; -}; - -struct UnknownTaskStruct2 -{ - void *src[2]; - volatile void *dest; - u32 unkC; - void (*unk10)(void); - u8 srcBank; - u8 unk15; - u8 unk16; - u8 unk17; - u8 taskId; - u8 filler19[0x7]; -}; - -extern struct UnknownTaskStruct2 gUnknown_03004DC0; - -extern u16 gUnknown_03004DE0[][0x3C0]; - -void remove_some_task(void); -void remove_some_task(void); -void dp12_8087EA4(void); -void dp12_8087EA4(void); -//void sub_80895F8(u32 i, u32 i1, u32 i2); -//void sub_80895F8(); -void sub_80895F8(struct UnknownTaskStruct unk); -void sub_8089668(void); -void sub_8089668(); -//void sub_8089944(int i, int i1, int i2, int i3, int i4, int i5, int i6); -u8 sub_8089944(u8 a1, u8 a2, u8 a3, u8 a4, u8 a5, u8 a6, u8 a7); - -#endif // GUARD_UNKNOWN_TASK_H |