├── vbalink.ini ├── payload ├── vbalink.ini ├── graphics │ ├── spinda_spots │ │ ├── spot_2.bin │ │ ├── spot_0.bin │ │ ├── spot_1.bin │ │ └── spot_3.bin │ ├── title.bin │ ├── title.png │ ├── message_box.png │ ├── party_menu.png │ ├── battle_screen.bin │ ├── battle_screen.png │ ├── battle_windows.bin │ ├── mon_info_icons.png │ ├── summary_icons.png │ ├── summary_screen.png │ ├── fonts │ │ ├── font0_jpn.png │ │ ├── font0_lat.png │ │ ├── font1_jpn.png │ │ ├── font1_lat.png │ │ └── font_null.png │ ├── type_status_icons.png │ ├── summary_screen_moves.bin │ ├── summary_screen_skills.bin │ ├── unk_0201A894.pal │ ├── unk_0201D3F0.pal │ ├── party_slots.bin │ └── party_menu.bin ├── rom.sha1 ├── sym_ewram.txt ├── common_syms │ ├── gflib │ │ ├── init.txt │ │ ├── keys.txt │ │ └── bg.txt │ ├── m4a.txt │ ├── berry_fix.txt │ └── agb_flash.txt ├── include │ ├── pokemon.h │ ├── gflib │ │ ├── types.h │ │ ├── gfxload.h │ │ ├── keys.h │ │ ├── init.h │ │ ├── sound.h │ │ ├── bg.h │ │ ├── sprite.h │ │ └── text.h │ ├── libpmagb │ │ ├── pic_uncomp.h │ │ ├── string_util.h │ │ ├── berry.h │ │ └── save.h │ ├── constants │ │ ├── songs.h │ │ ├── maps.h │ │ ├── berry.h │ │ ├── flags.h │ │ ├── battle.h │ │ ├── pokemon.h │ │ ├── items.h │ │ └── game_stat.h │ ├── libpmagb.h │ ├── pokedex.h │ ├── gflib.h │ ├── gba │ │ ├── gba.h │ │ ├── isagbprint.h │ │ ├── syscall.h │ │ ├── multiboot.h │ │ ├── defines.h │ │ └── flash_internal.h │ ├── rom_info.h │ ├── pokeball.h │ ├── mb_20094A8.h │ ├── berry_fix.h │ ├── iwram.h │ ├── graphics.h │ ├── m4a.h │ ├── siirtc.h │ ├── global.berry.h │ ├── unk_200C5DC.h │ └── all.h ├── sound │ ├── music_player_table.inc │ ├── songs │ │ └── midi │ │ │ ├── se_failure.mid │ │ │ └── se_select.mid │ ├── direct_sound_data.inc │ ├── direct_sound_samples │ │ └── se_select.aif │ └── song_table.inc ├── .gitignore ├── src │ ├── libpmagb │ │ └── pic_uncomp.c │ ├── gflib │ │ ├── gfxload.c │ │ ├── keys.c │ │ ├── sound.c │ │ └── init.c │ ├── agb_flash_le.c │ ├── graphics.c │ └── agb_flash_1m.c ├── constants │ ├── item_data_constants.inc │ ├── variables.inc │ ├── berry_constants.inc │ ├── constants.inc │ ├── type_constants.inc │ ├── battle_move_constants.inc │ ├── misc_constants.inc │ ├── contest_constants.inc │ └── contest_move_effects.inc ├── asm │ ├── macros │ │ ├── ec.inc │ │ ├── m4a.inc │ │ ├── asm.inc │ │ ├── function.inc │ │ ├── field_effect_script.inc │ │ ├── pokemon_data.inc │ │ └── map.inc │ └── libagbsyscall.s ├── songs.mk ├── data │ └── sound_data.s ├── sym_bss.txt ├── fonts.mk ├── sym_common.txt └── ld_script.txt ├── tools ├── bin2c │ ├── .gitignore │ ├── Makefile │ └── LICENSE ├── gbagfx │ ├── .gitignore │ ├── jasc_pal.h │ ├── rl.h │ ├── lz.h │ ├── convert_png.h │ ├── util.h │ ├── options.h │ ├── font.h │ ├── Makefile │ ├── global.h │ ├── huff.h │ ├── gfx.h │ ├── LICENSE │ └── util.c ├── jsonproc │ ├── .gitignore │ ├── Makefile │ ├── jsonproc.h │ └── jsonproc.cpp ├── mapjson │ ├── .gitignore │ ├── Makefile │ └── mapjson.h ├── mid2agb │ ├── .gitignore │ ├── Makefile │ ├── LICENSE │ ├── error.h │ ├── tables.h │ ├── agb.h │ ├── main.h │ ├── error.cpp │ └── midi.h ├── preproc │ ├── .gitignore │ ├── Makefile │ ├── LICENSE │ ├── utf8.h │ ├── string_parser.h │ ├── preproc.h │ ├── charmap.h │ ├── c_file.h │ ├── char_util.h │ └── asm_file.h ├── rsfont │ ├── .gitignore │ ├── convert_png.h │ ├── Makefile │ ├── util.h │ ├── global.h │ ├── LICENSE │ ├── font.h │ ├── gfx.h │ └── util.c ├── scaninc │ ├── .gitignore │ ├── Makefile │ ├── LICENSE │ ├── c_file.h │ ├── source_file.h │ └── scaninc.h ├── aif2pcm │ ├── .gitignore │ ├── Makefile │ └── LICENSE ├── ramscrgen │ ├── .gitignore │ ├── Makefile │ ├── LICENSE │ ├── elf.h │ ├── ramscrgen.h │ ├── char_util.h │ └── sym_file.h └── gbafix │ ├── .gitignore │ └── Makefile ├── colosseum-mb-em.sha1 ├── colosseum-mb-frlg.sha1 ├── data └── payload.s ├── fixrom.py ├── .gitignore ├── asm ├── libagbsyscall.s ├── macros │ ├── ec.inc │ ├── m4a.inc │ ├── asm.inc │ ├── function.inc │ ├── field_effect_script.inc │ ├── pokemon_data.inc │ └── map.inc ├── iwram.s └── crt0.s ├── constants ├── item_data_constants.inc ├── variables.inc ├── berry_constants.inc ├── constants.inc ├── type_constants.inc ├── battle_move_constants.inc ├── misc_constants.inc ├── contest_constants.inc ├── contest_move_effects.inc └── pokemon_data_constants.inc ├── README.md ├── include └── gba │ ├── gba.h │ ├── isagbprint.h │ ├── syscall.h │ ├── multiboot.h │ ├── defines.h │ └── flash_internal.h ├── .github └── workflows │ └── build.yml ├── src └── main.c └── ld_script.txt /vbalink.ini: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /payload/vbalink.ini: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tools/bin2c/.gitignore: -------------------------------------------------------------------------------- 1 | bin2c 2 | -------------------------------------------------------------------------------- /tools/gbagfx/.gitignore: -------------------------------------------------------------------------------- 1 | gbagfx 2 | -------------------------------------------------------------------------------- /tools/jsonproc/.gitignore: -------------------------------------------------------------------------------- 1 | jsonproc 2 | -------------------------------------------------------------------------------- /tools/mapjson/.gitignore: -------------------------------------------------------------------------------- 1 | mapjson 2 | -------------------------------------------------------------------------------- /tools/mid2agb/.gitignore: -------------------------------------------------------------------------------- 1 | mid2agb 2 | -------------------------------------------------------------------------------- /tools/preproc/.gitignore: -------------------------------------------------------------------------------- 1 | preproc 2 | -------------------------------------------------------------------------------- /tools/rsfont/.gitignore: -------------------------------------------------------------------------------- 1 | rsfont 2 | -------------------------------------------------------------------------------- /tools/scaninc/.gitignore: -------------------------------------------------------------------------------- 1 | scaninc 2 | -------------------------------------------------------------------------------- /tools/aif2pcm/.gitignore: -------------------------------------------------------------------------------- 1 | aif2pcm 2 | 3 | -------------------------------------------------------------------------------- /tools/ramscrgen/.gitignore: -------------------------------------------------------------------------------- 1 | ramscrgen 2 | -------------------------------------------------------------------------------- /tools/gbafix/.gitignore: -------------------------------------------------------------------------------- 1 | gbafix 2 | README 3 | -------------------------------------------------------------------------------- /payload/graphics/spinda_spots/spot_2.bin: -------------------------------------------------------------------------------- 1 | >> -------------------------------------------------------------------------------- /payload/rom.sha1: -------------------------------------------------------------------------------- 1 | 24d4b01fb2970f89fff487b9192812f3370a5be0 payload.gba 2 | -------------------------------------------------------------------------------- /payload/sym_ewram.txt: -------------------------------------------------------------------------------- 1 | 2 | gSaveBlockLoadRegions: 3 | .space 0xE000 4 | -------------------------------------------------------------------------------- /colosseum-mb-em.sha1: -------------------------------------------------------------------------------- 1 | 6cf444e998c39b74046c9715f3a07033b3262d12 colosseum-mb-em.gba 2 | -------------------------------------------------------------------------------- /payload/common_syms/gflib/init.txt: -------------------------------------------------------------------------------- 1 | gIntrTable 2 | gVBlankCounter 3 | gVBlankCallback 4 | -------------------------------------------------------------------------------- /payload/common_syms/gflib/keys.txt: -------------------------------------------------------------------------------- 1 | gNewKeys 2 | gNewAndRepeatedKeys 3 | gHeldKeys 4 | -------------------------------------------------------------------------------- /colosseum-mb-frlg.sha1: -------------------------------------------------------------------------------- 1 | 4f2dffaada52af7a64574d3c539f6329c3e63d00 colosseum-mb-frlg.gba 2 | -------------------------------------------------------------------------------- /data/payload.s: -------------------------------------------------------------------------------- 1 | .section .rodata 2 | Image:: 3 | .incbin "payload/payload.gba.lz" 4 | ImageEnd:: 5 | -------------------------------------------------------------------------------- /payload/include/pokemon.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/include/pokemon.h -------------------------------------------------------------------------------- /payload/graphics/title.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/title.bin -------------------------------------------------------------------------------- /payload/graphics/title.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/title.png -------------------------------------------------------------------------------- /payload/sound/music_player_table.inc: -------------------------------------------------------------------------------- 1 | gMPlayTable:: 2 | music_player gMPlay1Info, gMPlay1Track, 8, 0 3 | -------------------------------------------------------------------------------- /payload/common_syms/m4a.txt: -------------------------------------------------------------------------------- 1 | gSoundInfo 2 | gMPlayJumpTable 3 | gCgbChans 4 | gMPlay1Info 5 | gMPlayMemAccArea 6 | -------------------------------------------------------------------------------- /payload/graphics/message_box.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/message_box.png -------------------------------------------------------------------------------- /payload/graphics/party_menu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/party_menu.png -------------------------------------------------------------------------------- /payload/graphics/battle_screen.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/battle_screen.bin -------------------------------------------------------------------------------- /payload/graphics/battle_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/battle_screen.png -------------------------------------------------------------------------------- /payload/graphics/battle_windows.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/battle_windows.bin -------------------------------------------------------------------------------- /payload/graphics/mon_info_icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/mon_info_icons.png -------------------------------------------------------------------------------- /payload/graphics/summary_icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/summary_icons.png -------------------------------------------------------------------------------- /payload/graphics/summary_screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/summary_screen.png -------------------------------------------------------------------------------- /payload/graphics/fonts/font0_jpn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/fonts/font0_jpn.png -------------------------------------------------------------------------------- /payload/graphics/fonts/font0_lat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/fonts/font0_lat.png -------------------------------------------------------------------------------- /payload/graphics/fonts/font1_jpn.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/fonts/font1_jpn.png -------------------------------------------------------------------------------- /payload/graphics/fonts/font1_lat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/fonts/font1_lat.png -------------------------------------------------------------------------------- /payload/graphics/fonts/font_null.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/fonts/font_null.png -------------------------------------------------------------------------------- /payload/common_syms/berry_fix.txt: -------------------------------------------------------------------------------- 1 | gUpdateSuccessful 2 | gGameVersion 3 | gTimeSinceBerryUpdate 4 | gRtcUTCTime 5 | gUnusedWord 6 | -------------------------------------------------------------------------------- /payload/graphics/spinda_spots/spot_0.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/spinda_spots/spot_0.bin -------------------------------------------------------------------------------- /payload/graphics/spinda_spots/spot_1.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/spinda_spots/spot_1.bin -------------------------------------------------------------------------------- /payload/graphics/spinda_spots/spot_3.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/spinda_spots/spot_3.bin -------------------------------------------------------------------------------- /payload/graphics/type_status_icons.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/type_status_icons.png -------------------------------------------------------------------------------- /payload/sound/songs/midi/se_failure.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/sound/songs/midi/se_failure.mid -------------------------------------------------------------------------------- /payload/sound/songs/midi/se_select.mid: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/sound/songs/midi/se_select.mid -------------------------------------------------------------------------------- /payload/.gitignore: -------------------------------------------------------------------------------- 1 | sound/songs/midi/*.s 2 | sound/direct_sound_samples/*.bin 3 | *.[1248]bpp 4 | *.lz 5 | *.gbapal 6 | *.rl 7 | *.huff 8 | -------------------------------------------------------------------------------- /payload/graphics/summary_screen_moves.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/summary_screen_moves.bin -------------------------------------------------------------------------------- /payload/graphics/summary_screen_skills.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/graphics/summary_screen_skills.bin -------------------------------------------------------------------------------- /payload/common_syms/gflib/bg.txt: -------------------------------------------------------------------------------- 1 | gBgHofsBuffer 2 | gBgVofsBuffer 3 | gBgTilemapBufferTransferScheduled 4 | filler1 5 | filler2 6 | filler3 7 | -------------------------------------------------------------------------------- /fixrom.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python3 2 | 3 | import sys 4 | with open(sys.argv[1], 'r+b') as fp: 5 | fp.seek(0xbd) 6 | fp.write(b'\xf0') 7 | -------------------------------------------------------------------------------- /payload/sound/direct_sound_data.inc: -------------------------------------------------------------------------------- 1 | 2 | .align 2, 0 3 | 4 | gDirectSoundSample_se_select:: 5 | .incbin "sound/direct_sound_samples/se_select.bin" 6 | -------------------------------------------------------------------------------- /payload/sound/direct_sound_samples/se_select.aif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pret/colosseum-mb/HEAD/payload/sound/direct_sound_samples/se_select.aif -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.map 2 | *.gba 3 | *.elf 4 | build/ 5 | payload/build 6 | tools/agbcc 7 | tools/binutils 8 | *.exe 9 | *.lz 10 | *.dump 11 | .idea 12 | -------------------------------------------------------------------------------- /payload/include/gflib/types.h: -------------------------------------------------------------------------------- 1 | #ifndef GFLIB_TYPES_H 2 | #define GFLIB_TYPES_H 3 | 4 | typedef void (*IntrFunc)(void); 5 | 6 | #endif //GFLIB_TYPES_H 7 | -------------------------------------------------------------------------------- /payload/src/libpmagb/pic_uncomp.c: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | #include "iwram.h" 3 | 4 | void * GetPicUncompPtr(void) 5 | { 6 | return gPicUncompBuffer; 7 | } 8 | -------------------------------------------------------------------------------- /payload/sound/song_table.inc: -------------------------------------------------------------------------------- 1 | 2 | gSongTable:: 3 | song se_select, 0, 0 4 | song se_failure, 0, 0 5 | 6 | .align 2 7 | dummy_song_header: 8 | .byte 0, 0, 0, 0 9 | -------------------------------------------------------------------------------- /payload/include/libpmagb/pic_uncomp.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_LIBPMAGB_PIC_UNCOMP_H 2 | #define GUARD_LIBPMAGB_PIC_UNCOMP_H 3 | 4 | void * GetPicUncompPtr(void); 5 | 6 | #endif 7 | -------------------------------------------------------------------------------- /payload/include/gflib/gfxload.h: -------------------------------------------------------------------------------- 1 | #ifndef GFLIB_GFXLOAD_H 2 | #define GFLIB_GFXLOAD_H 3 | 4 | void AutoUnCompVram(const void * src, void * dest); 5 | 6 | #endif // GFLIB_GFXLOAD_H 7 | -------------------------------------------------------------------------------- /asm/libagbsyscall.s: -------------------------------------------------------------------------------- 1 | .include "asm/macros/function.inc" 2 | .text 3 | .syntax unified 4 | 5 | thumb_func_start RegisterRamReset 6 | RegisterRamReset: @ 0x0200FD24 7 | svc #1 8 | bx lr 9 | -------------------------------------------------------------------------------- /constants/item_data_constants.inc: -------------------------------------------------------------------------------- 1 | .set POCKET_ITEMS, 0x01 2 | .set POCKET_KEY_ITEMS, 0x02 3 | .set POCKET_POKE_BALLS, 0x03 4 | .set POCKET_TM_CASE, 0x04 5 | .set POCKET_BERRY_POUCH, 0x05 6 | -------------------------------------------------------------------------------- /payload/constants/item_data_constants.inc: -------------------------------------------------------------------------------- 1 | .set POCKET_ITEMS, 0x01 2 | .set POCKET_KEY_ITEMS, 0x02 3 | .set POCKET_POKE_BALLS, 0x03 4 | .set POCKET_TM_CASE, 0x04 5 | .set POCKET_BERRY_POUCH, 0x05 6 | -------------------------------------------------------------------------------- /asm/macros/ec.inc: -------------------------------------------------------------------------------- 1 | 2 | .macro ec_duplicates count 3 | .2byte 0xff00 + \count 4 | .endm 5 | 6 | .macro ec_words_by_letter label 7 | .2byte (gEasyChatWordsByLetter_\label - gEasyChatWordsAlphabetized) / 2 8 | .endm 9 | -------------------------------------------------------------------------------- /payload/asm/macros/ec.inc: -------------------------------------------------------------------------------- 1 | 2 | .macro ec_duplicates count 3 | .2byte 0xff00 + \count 4 | .endm 5 | 6 | .macro ec_words_by_letter label 7 | .2byte (gEasyChatWordsByLetter_\label - gEasyChatWordsAlphabetized) / 2 8 | .endm 9 | -------------------------------------------------------------------------------- /tools/gbafix/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | .PHONY: all clean 3 | 4 | SRCS = gbafix.c 5 | 6 | all: gbafix 7 | @: 8 | 9 | gbafix: $(SRCS) 10 | $(CC) $(SRCS) -o $@ $(LDFLAGS) 11 | 12 | clean: 13 | $(RM) gbafix gbafix.exe 14 | -------------------------------------------------------------------------------- /payload/include/constants/songs.h: -------------------------------------------------------------------------------- 1 | #ifndef COLOSSEUM_CONSTANTS_SONGS_H 2 | #define COLOSSEUM_CONSTANTS_SONGS_H 3 | 4 | #define SONG_SE_SELECT 0 5 | #define SONG_SE_FAILURE 1 6 | 7 | #endif //COLOSSEUM_CONSTANTS_SONGS_H 8 | -------------------------------------------------------------------------------- /payload/include/libpmagb/string_util.h: -------------------------------------------------------------------------------- 1 | #ifndef PMAGB_STRING_UTIL_H 2 | #define PMAGB_STRING_UTIL_H 3 | 4 | u8 *StringCopy(u8 *dest, const u8 *src); 5 | u8 *StringAppend(u8 *dest, const u8 *src); 6 | 7 | #endif //PMAGB_STRING_UTIL_H 8 | -------------------------------------------------------------------------------- /payload/songs.mk: -------------------------------------------------------------------------------- 1 | STD_REVERB = 0 2 | 3 | $(MID_SUBDIR)/se_select.s: %.s: %.mid 4 | $(MID) $< $@ -E -R$(STD_REVERB) -G127 -V127 -P10 5 | 6 | $(MID_SUBDIR)/se_failure.s: %.s: %.mid 7 | $(MID) $< $@ -E -R$(STD_REVERB) -G127 -V127 -P10 8 | -------------------------------------------------------------------------------- /constants/variables.inc: -------------------------------------------------------------------------------- 1 | .equiv FACING, 0x800C 2 | .equiv RESULT, 0x800D 3 | .equiv ITEM_ID, 0x800E 4 | .equiv LAST_TALKED, 0x800F 5 | .equiv CONTEST_RANK, 0x8010 6 | .equiv CONTEST_CATEGORY, 0x8011 7 | -------------------------------------------------------------------------------- /payload/common_syms/agb_flash.txt: -------------------------------------------------------------------------------- 1 | gFlashTimeoutFlag 2 | PollFlashStatus 3 | WaitForFlashWrite 4 | ProgramFlashSector 5 | gFlash 6 | ProgramFlashByte 7 | gFlashNumRemainingBytes 8 | EraseFlashChip 9 | EraseFlashSector 10 | gFlashMaxTime 11 | -------------------------------------------------------------------------------- /payload/constants/variables.inc: -------------------------------------------------------------------------------- 1 | .equiv FACING, 0x800C 2 | .equiv RESULT, 0x800D 3 | .equiv ITEM_ID, 0x800E 4 | .equiv LAST_TALKED, 0x800F 5 | .equiv CONTEST_RANK, 0x8010 6 | .equiv CONTEST_CATEGORY, 0x8011 7 | -------------------------------------------------------------------------------- /constants/berry_constants.inc: -------------------------------------------------------------------------------- 1 | .set BERRY_FIRMNESS_UNKNOWN, 0 2 | .set BERRY_FIRMNESS_VERY_SOFT, 1 3 | .set BERRY_FIRMNESS_SOFT, 2 4 | .set BERRY_FIRMNESS_HARD, 3 5 | .set BERRY_FIRMNESS_VERY_HARD, 4 6 | .set BERRY_FIRMNESS_SUPER_HARD, 5 7 | -------------------------------------------------------------------------------- /payload/constants/berry_constants.inc: -------------------------------------------------------------------------------- 1 | .set BERRY_FIRMNESS_UNKNOWN, 0 2 | .set BERRY_FIRMNESS_VERY_SOFT, 1 3 | .set BERRY_FIRMNESS_SOFT, 2 4 | .set BERRY_FIRMNESS_HARD, 3 5 | .set BERRY_FIRMNESS_VERY_HARD, 4 6 | .set BERRY_FIRMNESS_SUPER_HARD, 5 7 | -------------------------------------------------------------------------------- /payload/include/libpmagb.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_LIBPMAGB_H 2 | #define GUARD_LIBPMAGB_H 3 | 4 | #include "libpmagb/agb_rom.h" 5 | #include "libpmagb/save.h" 6 | #include "libpmagb/berry.h" 7 | #include "libpmagb/string_util.h" 8 | 9 | #endif //GUARD_LIBPMAGB_H 10 | -------------------------------------------------------------------------------- /tools/gbagfx/jasc_pal.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef JASC_PAL_H 4 | #define JASC_PAL_H 5 | 6 | void ReadJascPalette(char *path, struct Palette *palette); 7 | void WriteJascPalette(char *path, struct Palette *palette); 8 | 9 | #endif // JASC_PAL_H 10 | -------------------------------------------------------------------------------- /payload/include/gflib/keys.h: -------------------------------------------------------------------------------- 1 | #ifndef GFLIB_KEYS_H 2 | #define GFLIB_KEYS_H 3 | 4 | extern u16 gHeldKeys; 5 | extern u16 gNewKeys; 6 | extern u16 gNewAndRepeatedKeys; 7 | 8 | void ReadKeys(void); 9 | void SetKeyRepeatTiming(u16 delay, u16 rate); 10 | 11 | #endif //GFLIB_KEYS_H 12 | -------------------------------------------------------------------------------- /tools/bin2c/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | 3 | CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 4 | 5 | .PHONY: all clean 6 | 7 | SRCS = bin2c.c 8 | 9 | all: bin2c 10 | @: 11 | 12 | bin2c: $(SRCS) 13 | $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) 14 | 15 | clean: 16 | $(RM) bin2c bin2c.exe 17 | -------------------------------------------------------------------------------- /tools/rsfont/convert_png.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef CONVERT_PNG_H 4 | #define CONVERT_PNG_H 5 | 6 | #include "gfx.h" 7 | 8 | void ReadPng(char *path, struct Image *image); 9 | void WritePng(char *path, struct Image *image); 10 | 11 | #endif // CONVERT_PNG_H 12 | -------------------------------------------------------------------------------- /tools/gbagfx/rl.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2016 YamaArashi 2 | 3 | #ifndef RL_H 4 | #define RL_H 5 | 6 | unsigned char *RLDecompress(unsigned char *src, int srcSize, int *uncompressedSize); 7 | unsigned char *RLCompress(unsigned char *src, int srcSize, int *compressedSize); 8 | 9 | #endif // RL_H 10 | -------------------------------------------------------------------------------- /payload/data/sound_data.s: -------------------------------------------------------------------------------- 1 | .section .rodata 2 | 3 | .include "asm/macros/m4a.inc" 4 | .include "asm/macros/music_voice.inc" 5 | 6 | .include "sound/voice_groups.inc" 7 | .include "sound/music_player_table.inc" 8 | .include "sound/song_table.inc" 9 | .include "sound/direct_sound_data.inc" 10 | -------------------------------------------------------------------------------- /payload/graphics/unk_0201A894.pal: -------------------------------------------------------------------------------- 1 | JASC-PAL 2 | 0100 3 | 16 4 | 98 197 98 5 | 41 49 49 6 | 90 90 123 7 | 131 123 148 8 | 115 115 164 9 | 131 131 189 10 | 156 156 222 11 | 189 205 189 12 | 222 213 222 13 | 0 0 0 14 | 0 0 0 15 | 0 0 0 16 | 0 0 0 17 | 0 0 0 18 | 255 255 255 19 | 74 65 82 20 | -------------------------------------------------------------------------------- /payload/include/pokedex.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_POKEDEX_H 2 | #define GUARD_POKEDEX_H 3 | 4 | enum 5 | { 6 | FLAG_GET_SEEN, 7 | FLAG_GET_CAUGHT, 8 | FLAG_SET_SEEN, 9 | FLAG_SET_CAUGHT 10 | }; 11 | 12 | bool32 GetSetPokedexFlag(u16 nationalDexNo, u8 caseID); 13 | 14 | #endif // GUARD_POKEDEX_H 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | This repository builds the Pokemon Colosseum Multiboot image which comes compressed within Pokemon FireRed, LeafGreen, and Emerald. 2 | 3 | It builds the following images: 4 | 5 | 6cf444e998c39b74046c9715f3a07033b3262d12 colosseum-mb.gba 6 | 4f2dffaada52af7a64574d3c539f6329c3e63d00 colosseum-mb-frlg.gba 7 | -------------------------------------------------------------------------------- /include/gba/gba.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_GBA_H 2 | #define GUARD_GBA_GBA_H 3 | 4 | #include "gba/defines.h" 5 | #include "gba/io_reg.h" 6 | #include "gba/types.h" 7 | #include "gba/multiboot.h" 8 | #include "gba/syscall.h" 9 | #include "gba/macro.h" 10 | #include "gba/isagbprint.h" 11 | 12 | #endif // GUARD_GBA_GBA_H 13 | -------------------------------------------------------------------------------- /payload/include/gflib.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GFLIB_H 2 | #define GUARD_GFLIB_H 3 | 4 | #include "gflib/init.h" 5 | #include "gflib/bg.h" 6 | #include "gflib/keys.h" 7 | #include "gflib/sound.h" 8 | #include "gflib/gfxload.h" 9 | #include "gflib/sprite.h" 10 | 11 | void DetectROM(void); 12 | 13 | #endif //GUARD_GFLIB_H 14 | -------------------------------------------------------------------------------- /tools/gbagfx/lz.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef LZ_H 4 | #define LZ_H 5 | 6 | unsigned char *LZDecompress(unsigned char *src, int srcSize, int *uncompressedSize); 7 | unsigned char *LZCompress(unsigned char *src, int srcSize, int *compressedSize, const int minDistance); 8 | 9 | #endif // LZ_H 10 | -------------------------------------------------------------------------------- /payload/include/gba/gba.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_GBA_H 2 | #define GUARD_GBA_GBA_H 3 | 4 | #include "gba/defines.h" 5 | #include "gba/io_reg.h" 6 | #include "gba/types.h" 7 | #include "gba/multiboot.h" 8 | #include "gba/syscall.h" 9 | #include "gba/macro.h" 10 | #include "gba/isagbprint.h" 11 | 12 | #endif // GUARD_GBA_GBA_H 13 | -------------------------------------------------------------------------------- /asm/macros/m4a.inc: -------------------------------------------------------------------------------- 1 | .macro song label, music_player, unknown 2 | .4byte \label 3 | .2byte \music_player 4 | .2byte \unknown 5 | .endm 6 | 7 | .macro music_player info_struct, track_struct, unknown_1, unknown_2 8 | .4byte \info_struct 9 | .4byte \track_struct 10 | .byte \unknown_1 11 | .space 1 12 | .2byte \unknown_2 13 | .endm 14 | -------------------------------------------------------------------------------- /tools/aif2pcm/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | 3 | CFLAGS = -Wall -Wextra -Wno-switch -Werror -std=c11 -O2 4 | 5 | LIBS = -lm 6 | 7 | SRCS = main.c extended.c 8 | 9 | .PHONY: all clean 10 | 11 | all: aif2pcm 12 | @: 13 | 14 | aif2pcm: $(SRCS) 15 | $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) 16 | 17 | clean: 18 | $(RM) aif2pcm aif2pcm.exe 19 | -------------------------------------------------------------------------------- /tools/mapjson/Makefile: -------------------------------------------------------------------------------- 1 | CXX := g++ 2 | 3 | CXXFLAGS := -Wall -std=c++11 -O2 4 | 5 | SRCS := json11.cpp mapjson.cpp 6 | 7 | HEADERS := mapjson.h 8 | 9 | .PHONY: all clean 10 | 11 | all: mapjson 12 | @: 13 | 14 | mapjson: $(SRCS) $(HEADERS) 15 | $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) 16 | 17 | clean: 18 | $(RM) mapjson mapjson.exe 19 | -------------------------------------------------------------------------------- /payload/asm/macros/m4a.inc: -------------------------------------------------------------------------------- 1 | .macro song label, music_player, unknown 2 | .4byte \label 3 | .2byte \music_player 4 | .2byte \unknown 5 | .endm 6 | 7 | .macro music_player info_struct, track_struct, unknown_1, unknown_2 8 | .4byte \info_struct 9 | .4byte \track_struct 10 | .byte \unknown_1 11 | .space 1 12 | .2byte \unknown_2 13 | .endm 14 | -------------------------------------------------------------------------------- /payload/include/rom_info.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_ROM_INFO_H 2 | #define GUARD_ROM_INFO_H 3 | 4 | extern struct GFRomHeader gAgbPmRomParams_AXVE_rev0; 5 | extern struct GFRomHeader gAgbPmRomParams_AXVE_rev2; 6 | extern struct GFRomHeader gAgbPmRomParams_AXPE_rev0; 7 | extern struct GFRomHeader gAgbPmRomParams_AXPE_rev2; 8 | 9 | #endif // GUARD_ROM_INFO_H 10 | -------------------------------------------------------------------------------- /tools/gbagfx/convert_png.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef CONVERT_PNG_H 4 | #define CONVERT_PNG_H 5 | 6 | #include "gfx.h" 7 | 8 | void ReadPng(char *path, struct Image *image); 9 | void WritePng(char *path, struct Image *image); 10 | void ReadPngPalette(char *path, struct Palette *palette); 11 | 12 | #endif // CONVERT_PNG_H 13 | -------------------------------------------------------------------------------- /asm/macros/asm.inc: -------------------------------------------------------------------------------- 1 | .ifndef GUARD_ASM_MACROS_ASM_INC 2 | .set GUARD_ASM_MACROS_ASM_INC, 1 3 | 4 | .macro inc x 5 | .set \x, \x + 1 6 | .endm 7 | 8 | .macro enum_start x=0 9 | .set __enum__, \x 10 | .endm 11 | 12 | .macro enum constant 13 | .equiv \constant, __enum__ 14 | inc __enum__ 15 | .endm 16 | 17 | .endif @ GUARD_ASM_MACROS_ASM_INC 18 | -------------------------------------------------------------------------------- /payload/asm/macros/asm.inc: -------------------------------------------------------------------------------- 1 | .ifndef GUARD_ASM_MACROS_ASM_INC 2 | .set GUARD_ASM_MACROS_ASM_INC, 1 3 | 4 | .macro inc x 5 | .set \x, \x + 1 6 | .endm 7 | 8 | .macro enum_start x=0 9 | .set __enum__, \x 10 | .endm 11 | 12 | .macro enum constant 13 | .equiv \constant, __enum__ 14 | inc __enum__ 15 | .endm 16 | 17 | .endif @ GUARD_ASM_MACROS_ASM_INC 18 | -------------------------------------------------------------------------------- /payload/sym_bss.txt: -------------------------------------------------------------------------------- 1 | .include "src/all.o" 2 | .include "src/all4.o" 3 | .include "asm/m4a_1.o" 4 | .include "src/gflib/sprite.o" 5 | .include "src/gflib/text.o" 6 | .include "src/gflib/keys.o" 7 | .include "src/gflib/sound.o" 8 | .include "src/libpmagb/save.o" 9 | .include "src/agb_flash.o" 10 | .include "src/berry_fix.o" 11 | .include "src/siirtc.o" 12 | -------------------------------------------------------------------------------- /payload/include/constants/maps.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_CONSTANTS_MAPS_H 2 | #define GUARD_CONSTANTS_MAPS_H 3 | 4 | #include "constants/map_groups.h" 5 | 6 | #define MAP_NONE (0x7F | (0x7F << 8)) 7 | #define MAP_UNDEFINED (0xFF | (0xFF << 8)) 8 | 9 | #define MAP_GROUP(map) (MAP_##map >> 8) 10 | #define MAP_NUM(map) (MAP_##map & 0xFF) 11 | 12 | #endif // GUARD_CONSTANTS_MAPS_H 13 | -------------------------------------------------------------------------------- /payload/include/libpmagb/berry.h: -------------------------------------------------------------------------------- 1 | #ifndef PMAGB_BERRY_H 2 | #define PMAGB_BERRY_H 3 | 4 | u32 UNUSED GetEnigmaBerryChecksum(struct EnigmaBerry * enigmaBerry); 5 | bool32 IsEnigmaBerryValid(void); 6 | const struct Berry *GetBerryInfo(u8 berry); 7 | const u8 *ItemId_GetName(u16 itemId); 8 | void CopyItemName(u32 itemId, u8 *string, const u8 * berryString); 9 | 10 | #endif //PMAGB_BERRY_H 11 | -------------------------------------------------------------------------------- /tools/jsonproc/Makefile: -------------------------------------------------------------------------------- 1 | CXX := g++ 2 | 3 | CXXFLAGS := -Wall -std=c++11 -O2 4 | 5 | INCLUDES := -I . 6 | 7 | SRCS := jsonproc.cpp 8 | 9 | HEADERS := jsonproc.h inja.hpp nlohmann/json.hpp 10 | 11 | .PHONY: all clean 12 | 13 | all: jsonproc 14 | @: 15 | 16 | jsonproc: $(SRCS) $(HEADERS) 17 | $(CXX) $(CXXFLAGS) $(INCLUDES) $(SRCS) -o $@ $(LDFLAGS) 18 | 19 | clean: 20 | $(RM) jsonproc jsonproc.exe 21 | -------------------------------------------------------------------------------- /tools/ramscrgen/Makefile: -------------------------------------------------------------------------------- 1 | CXX := g++ 2 | 3 | CXXFLAGS := -std=c++11 -O2 -Wall -Wno-switch -Werror 4 | 5 | SRCS := main.cpp sym_file.cpp elf.cpp 6 | 7 | HEADERS := ramscrgen.h sym_file.h elf.h char_util.h 8 | 9 | .PHONY: all clean 10 | 11 | all: ramscrgen 12 | @: 13 | 14 | ramscrgen: $(SRCS) $(HEADERS) 15 | $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) 16 | 17 | clean: 18 | $(RM) ramscrgen ramscrgen.exe 19 | -------------------------------------------------------------------------------- /tools/scaninc/Makefile: -------------------------------------------------------------------------------- 1 | CXX = g++ 2 | 3 | CXXFLAGS = -Wall -Werror -std=c++11 -O2 4 | 5 | SRCS = scaninc.cpp c_file.cpp asm_file.cpp source_file.cpp 6 | 7 | HEADERS := scaninc.h asm_file.h c_file.h source_file.h 8 | 9 | .PHONY: all clean 10 | 11 | all: scaninc 12 | @: 13 | 14 | scaninc: $(SRCS) $(HEADERS) 15 | $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) 16 | 17 | clean: 18 | $(RM) scaninc scaninc.exe 19 | -------------------------------------------------------------------------------- /payload/include/pokeball.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_POKEBALL_H 2 | #define GUARD_POKEBALL_H 3 | 4 | enum 5 | { 6 | BALL_POKE, 7 | BALL_GREAT, 8 | BALL_SAFARI, 9 | BALL_ULTRA, 10 | BALL_MASTER, 11 | BALL_NET, 12 | BALL_DIVE, 13 | BALL_NEST, 14 | BALL_REPEAT, 15 | BALL_TIMER, 16 | BALL_LUXURY, 17 | BALL_PREMIER, 18 | POKEBALL_COUNT 19 | }; 20 | 21 | #endif // GUARD_POKEBALL_H 22 | -------------------------------------------------------------------------------- /tools/mid2agb/Makefile: -------------------------------------------------------------------------------- 1 | CXX := g++ 2 | 3 | CXXFLAGS := -std=c++11 -O2 -Wall -Wno-switch -Werror 4 | 5 | SRCS := agb.cpp error.cpp main.cpp midi.cpp tables.cpp 6 | 7 | HEADERS := agb.h error.h main.h midi.h tables.h 8 | 9 | .PHONY: all clean 10 | 11 | all: mid2agb 12 | @: 13 | 14 | mid2agb: $(SRCS) $(HEADERS) 15 | $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) 16 | 17 | clean: 18 | $(RM) mid2agb mid2agb.exe 19 | -------------------------------------------------------------------------------- /tools/rsfont/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | 3 | CFLAGS = -Wall -Wextra -Werror -std=c11 -O2 -DPNG_SKIP_SETJMP_CHECK 4 | 5 | LIBS = -lpng -lz 6 | 7 | SRCS = main.c convert_png.c util.c font.c 8 | 9 | .PHONY: all clean 10 | 11 | all: rsfont 12 | @: 13 | 14 | rsfont: $(SRCS) convert_png.h gfx.h global.h util.h font.h 15 | $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) 16 | 17 | clean: 18 | $(RM) rsfont rsfont.exe 19 | -------------------------------------------------------------------------------- /payload/include/constants/berry.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_CONSTANTS_BERRY_H 2 | #define GUARD_CONSTANTS_BERRY_H 3 | 4 | #define BERRY_NONE 0 5 | 6 | #define BERRY_FIRMNESS_UNKNOWN 0 7 | #define BERRY_FIRMNESS_VERY_SOFT 1 8 | #define BERRY_FIRMNESS_SOFT 2 9 | #define BERRY_FIRMNESS_HARD 3 10 | #define BERRY_FIRMNESS_VERY_HARD 4 11 | #define BERRY_FIRMNESS_SUPER_HARD 5 12 | 13 | #endif // GUARD_CONSTANTS_BERRY_H 14 | -------------------------------------------------------------------------------- /payload/src/gflib/gfxload.c: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | #include "gflib/gfxload.h" 3 | 4 | void AutoUnCompVram(const void * src, void * dest) 5 | { 6 | switch (*(u8 *)src & 0xF0) 7 | { 8 | case 0x10: 9 | LZ77UnCompVram(src, dest); 10 | break; 11 | case 0x20: 12 | HuffUnComp(src, dest); 13 | break; 14 | case 0x30: 15 | RLUnCompVram(src, dest); 16 | break; 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /payload/include/gflib/init.h: -------------------------------------------------------------------------------- 1 | #ifndef GFLIB_INIT_H 2 | #define GFLIB_INIT_H 3 | 4 | #include "gflib/types.h" 5 | 6 | #define TEST_BUTTON(arr, flags) ({(arr) & (flags);}) 7 | 8 | // Expose to crt0.s 9 | void AgbMain(void); 10 | extern IntrFunc gIntrTable[14u]; 11 | 12 | void SetIntrFunc(u32 i, IntrFunc func); 13 | void SetVBlankCallback(IntrFunc cb); 14 | u32 GetFrameTotal(void); 15 | void DelayFrames(u32 frames); 16 | 17 | #endif //GFLIB_INIT_H 18 | -------------------------------------------------------------------------------- /tools/gbagfx/util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef UTIL_H 4 | #define UTIL_H 5 | 6 | #include 7 | 8 | bool ParseNumber(char *s, char **end, int radix, int *intValue); 9 | char *GetFileExtension(char *path); 10 | unsigned char *ReadWholeFile(char *path, int *size); 11 | unsigned char *ReadWholeFileZeroPadded(char *path, int *size, int padAmount); 12 | void WriteWholeFile(char *path, void *buffer, int bufferSize); 13 | 14 | #endif // UTIL_H 15 | -------------------------------------------------------------------------------- /tools/rsfont/util.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef UTIL_H 4 | #define UTIL_H 5 | 6 | #include 7 | 8 | bool ParseNumber(char *s, char **end, int radix, int *intValue); 9 | char *GetFileExtension(char *path); 10 | unsigned char *ReadWholeFile(char *path, int *size); 11 | unsigned char *ReadWholeFileZeroPadded(char *path, int *size, int padAmount); 12 | void WriteWholeFile(char *path, void *buffer, int bufferSize); 13 | 14 | #endif // UTIL_H 15 | -------------------------------------------------------------------------------- /payload/include/constants/flags.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_CONSTANTS_FLAGS_H 2 | #define GUARD_CONSTANTS_FLAGS_H 3 | 4 | #define SYSTEM_FLAGS 0x800 5 | 6 | #define FLAG_SYS_POKEDEX_GET (SYSTEM_FLAGS + 0x01) 7 | #define FLAG_SYS_GAME_CLEAR (SYSTEM_FLAGS + 0x04) 8 | #define FLAG_SYS_NATIONAL_DEX (SYSTEM_FLAGS + 0x36) 9 | #define FLAG_SYS_RIBBON_GET (SYSTEM_FLAGS + 0x3B) 10 | #define FLAG_SYS_EXDATA_ENABLE (SYSTEM_FLAGS + 0x4C) 11 | 12 | #endif // GUARD_CONSTANTS_FLAGS_H 13 | -------------------------------------------------------------------------------- /payload/fonts.mk: -------------------------------------------------------------------------------- 1 | graphics/fonts/font0_lat.2bpp: graphics/fonts/font0_lat.png 2 | $(RSFONT) $< $@ 254 1 3 | 4 | graphics/fonts/font1_lat.2bpp: graphics/fonts/font1_lat.png 5 | $(RSFONT) $< $@ 110 2 6 | 7 | graphics/fonts/font0_jpn.2bpp: graphics/fonts/font0_jpn.png 8 | $(RSFONT) $< $@ 254 1 9 | 10 | graphics/fonts/font1_jpn.2bpp: graphics/fonts/font1_jpn.png 11 | $(RSFONT) $< $@ 110 2 12 | 13 | graphics/fonts/font_null.2bpp: graphics/fonts/font_null.png 14 | $(RSFONT) $< $@ 254 1 15 | -------------------------------------------------------------------------------- /tools/preproc/Makefile: -------------------------------------------------------------------------------- 1 | CXX := g++ 2 | 3 | CXXFLAGS := -std=c++11 -O2 -Wall -Wno-switch -Werror 4 | 5 | SRCS := asm_file.cpp c_file.cpp charmap.cpp preproc.cpp string_parser.cpp \ 6 | utf8.cpp 7 | 8 | HEADERS := asm_file.h c_file.h char_util.h charmap.h preproc.h string_parser.h \ 9 | utf8.h 10 | 11 | .PHONY: all clean 12 | 13 | all: preproc 14 | @: 15 | 16 | preproc: $(SRCS) $(HEADERS) 17 | $(CXX) $(CXXFLAGS) $(SRCS) -o $@ $(LDFLAGS) 18 | 19 | clean: 20 | $(RM) preproc preproc.exe 21 | -------------------------------------------------------------------------------- /tools/gbagfx/options.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2018 huderlem 2 | 3 | #ifndef OPTIONS_H 4 | #define OPTIONS_H 5 | 6 | #include 7 | 8 | struct GbaToPngOptions { 9 | char *paletteFilePath; 10 | int bitDepth; 11 | bool hasTransparency; 12 | int width; 13 | int metatileWidth; 14 | int metatileHeight; 15 | }; 16 | 17 | struct PngToGbaOptions { 18 | int numTiles; 19 | int bitDepth; 20 | int metatileWidth; 21 | int metatileHeight; 22 | }; 23 | 24 | #endif // OPTIONS_H 25 | -------------------------------------------------------------------------------- /payload/graphics/unk_0201D3F0.pal: -------------------------------------------------------------------------------- 1 | JASC-PAL 2 | 0100 3 | 32 4 | 98 197 98 5 | 41 49 49 6 | 74 74 106 7 | 115 106 131 8 | 98 98 148 9 | 115 115 172 10 | 139 139 205 11 | 172 189 172 12 | 222 213 222 13 | 0 0 0 14 | 0 0 0 15 | 0 0 0 16 | 0 0 0 17 | 0 0 0 18 | 255 255 255 19 | 74 65 82 20 | 0 0 0 21 | 197 197 197 22 | 164 205 246 23 | 65 65 65 24 | 98 98 131 25 | 0 131 197 26 | 0 197 197 27 | 255 255 255 28 | 0 0 0 29 | 0 0 0 30 | 0 0 0 31 | 0 0 0 32 | 0 0 0 33 | 0 0 0 34 | 0 0 0 35 | 0 0 0 36 | -------------------------------------------------------------------------------- /payload/graphics/party_slots.bin: -------------------------------------------------------------------------------- 1 | )0*0*0*0*0*0*0*0*0*0+0,0-0-0-0-0-0-0-0-0-0.0,0-0-0-0-0-0-0-0-0-0.0,0-0-0-0-0-0-0-0-0-0.0/000000000000000000010/0000000000000000000102030303030303030303040 0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!0!0"0#0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0$0%0&0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0'0(050606060606060606060606060606060606070809090909090909090909090909090909090:0;0<0<0<0<0<0<0<0<0<0<0<0<0<0<0<0<0<0=0 -------------------------------------------------------------------------------- /constants/constants.inc: -------------------------------------------------------------------------------- 1 | .include "constants/gba_constants.inc" 2 | .include "constants/misc_constants.inc" 3 | .include "constants/type_constants.inc" 4 | .include "constants/contest_constants.inc" 5 | @ .include "constants/item_data_constants.inc" 6 | .include "constants/battle_move_constants.inc" 7 | .include "constants/trainer_constants.inc" 8 | .include "constants/berry_constants.inc" 9 | .include "constants/version.inc" 10 | .include "constants/battle.inc" 11 | .include "constants/battle_text.inc" 12 | .include "constants/contest_move_effects.inc" 13 | -------------------------------------------------------------------------------- /constants/type_constants.inc: -------------------------------------------------------------------------------- 1 | .set TYPE_NORMAL, 0x00 2 | .set TYPE_FIGHTING, 0x01 3 | .set TYPE_FLYING, 0x02 4 | .set TYPE_POISON, 0x03 5 | .set TYPE_GROUND, 0x04 6 | .set TYPE_ROCK, 0x05 7 | .set TYPE_BUG, 0x06 8 | .set TYPE_GHOST, 0x07 9 | .set TYPE_STEEL, 0x08 10 | .set TYPE_MYSTERY, 0x09 11 | .set TYPE_FIRE, 0x0a 12 | .set TYPE_WATER, 0x0b 13 | .set TYPE_GRASS, 0x0c 14 | .set TYPE_ELECTRIC, 0x0d 15 | .set TYPE_PSYCHIC, 0x0e 16 | .set TYPE_ICE, 0x0f 17 | .set TYPE_DRAGON, 0x10 18 | .set TYPE_DARK, 0x11 19 | -------------------------------------------------------------------------------- /payload/constants/constants.inc: -------------------------------------------------------------------------------- 1 | .include "constants/gba_constants.inc" 2 | .include "constants/misc_constants.inc" 3 | .include "constants/type_constants.inc" 4 | .include "constants/contest_constants.inc" 5 | @ .include "constants/item_data_constants.inc" 6 | .include "constants/battle_move_constants.inc" 7 | .include "constants/trainer_constants.inc" 8 | .include "constants/berry_constants.inc" 9 | .include "constants/version.inc" 10 | .include "constants/battle.inc" 11 | .include "constants/battle_text.inc" 12 | .include "constants/contest_move_effects.inc" 13 | -------------------------------------------------------------------------------- /tools/gbagfx/font.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef FONT_H 4 | #define FONT_H 5 | 6 | #include 7 | #include "gfx.h" 8 | 9 | void ReadLatinFont(char *path, struct Image *image); 10 | void WriteLatinFont(char *path, struct Image *image); 11 | void ReadHalfwidthJapaneseFont(char *path, struct Image *image); 12 | void WriteHalfwidthJapaneseFont(char *path, struct Image *image); 13 | void ReadFullwidthJapaneseFont(char *path, struct Image *image); 14 | void WriteFullwidthJapaneseFont(char *path, struct Image *image); 15 | 16 | #endif // FONT_H 17 | -------------------------------------------------------------------------------- /payload/constants/type_constants.inc: -------------------------------------------------------------------------------- 1 | .set TYPE_NORMAL, 0x00 2 | .set TYPE_FIGHTING, 0x01 3 | .set TYPE_FLYING, 0x02 4 | .set TYPE_POISON, 0x03 5 | .set TYPE_GROUND, 0x04 6 | .set TYPE_ROCK, 0x05 7 | .set TYPE_BUG, 0x06 8 | .set TYPE_GHOST, 0x07 9 | .set TYPE_STEEL, 0x08 10 | .set TYPE_MYSTERY, 0x09 11 | .set TYPE_FIRE, 0x0a 12 | .set TYPE_WATER, 0x0b 13 | .set TYPE_GRASS, 0x0c 14 | .set TYPE_ELECTRIC, 0x0d 15 | .set TYPE_PSYCHIC, 0x0e 16 | .set TYPE_ICE, 0x0f 17 | .set TYPE_DRAGON, 0x10 18 | .set TYPE_DARK, 0x11 19 | -------------------------------------------------------------------------------- /asm/macros/function.inc: -------------------------------------------------------------------------------- 1 | .macro arm_func_start name 2 | .align 2, 0 3 | .global \name 4 | .arm 5 | .type \name, function 6 | .endm 7 | 8 | .macro arm_func_end name 9 | .size \name, .-\name 10 | .endm 11 | 12 | .macro thumb_func_start name 13 | .align 2, 0 14 | .global \name 15 | .thumb 16 | .thumb_func 17 | .type \name, function 18 | .endm 19 | 20 | .macro non_word_aligned_thumb_func_start name 21 | .global \name 22 | .thumb 23 | .thumb_func 24 | .type \name, function 25 | .endm 26 | 27 | .macro thumb_func_end name 28 | .size \name, .-\name 29 | .endm 30 | -------------------------------------------------------------------------------- /payload/asm/macros/function.inc: -------------------------------------------------------------------------------- 1 | .macro arm_func_start name 2 | .align 2, 0 3 | .global \name 4 | .arm 5 | .type \name, function 6 | .endm 7 | 8 | .macro arm_func_end name 9 | .size \name, .-\name 10 | .endm 11 | 12 | .macro thumb_func_start name 13 | .align 2, 0 14 | .global \name 15 | .thumb 16 | .thumb_func 17 | .type \name, function 18 | .endm 19 | 20 | .macro non_word_aligned_thumb_func_start name 21 | .global \name 22 | .thumb 23 | .thumb_func 24 | .type \name, function 25 | .endm 26 | 27 | .macro thumb_func_end name 28 | .size \name, .-\name 29 | .endm 30 | -------------------------------------------------------------------------------- /payload/include/libpmagb/save.h: -------------------------------------------------------------------------------- 1 | #ifndef PMAGB_SAVE_H 2 | #define PMAGB_SAVE_H 3 | 4 | #include "gflib/types.h" 5 | 6 | #define NUM_SECTORS 32 // defined in agb_flash but not in a header 7 | 8 | #define SAVE_STATUS_EMPTY 0 9 | #define SAVE_STATUS_OK 1 10 | #define SAVE_STATUS_CORRUPT 2 11 | #define SAVE_STATUS_NO_FLASH 4 12 | #define SAVE_STATUS_ERROR 0xFF 13 | 14 | bool32 sub_0200A2C8(s32 a); 15 | u8* ReadFirstSaveSector(void); 16 | void SetSaveSectorPtrs(void); 17 | u32 ReadSaveBlockChunks(void); 18 | s32 InitFlash(u32 timerNum, IntrFunc * intrFunc); 19 | 20 | #endif //PMAGB_SAVE_H 21 | -------------------------------------------------------------------------------- /constants/battle_move_constants.inc: -------------------------------------------------------------------------------- 1 | .set TARGET_SELECTED_POKEMON, 0 2 | 3 | .set F_TARGET_SPECIAL, 1 << 0 4 | .set F_TARGET_RANDOM, 1 << 2 5 | .set F_TARGET_BOTH_ENEMIES, 1 << 3 6 | .set F_TARGET_USER, 1 << 4 7 | .set F_TARGET_ALL_EXCEPT_USER, 1 << 5 8 | .set F_TARGET_ENEMY_SIDE, 1 << 6 9 | 10 | .set F_MAKES_CONTACT, 1 << 0 11 | .set F_AFFECTED_BY_PROTECT, 1 << 1 12 | .set F_AFFECTED_BY_MAGIC_COAT, 1 << 2 13 | .set F_AFFECTED_BY_SNATCH, 1 << 3 14 | .set F_MIRROR_MOVE_COMPATIBLE, 1 << 4 15 | .set F_AFFECTED_BY_KINGS_ROCK, 1 << 5 16 | -------------------------------------------------------------------------------- /payload/constants/battle_move_constants.inc: -------------------------------------------------------------------------------- 1 | .set TARGET_SELECTED_POKEMON, 0 2 | 3 | .set F_TARGET_SPECIAL, 1 << 0 4 | .set F_TARGET_RANDOM, 1 << 2 5 | .set F_TARGET_BOTH_ENEMIES, 1 << 3 6 | .set F_TARGET_USER, 1 << 4 7 | .set F_TARGET_ALL_EXCEPT_USER, 1 << 5 8 | .set F_TARGET_ENEMY_SIDE, 1 << 6 9 | 10 | .set F_MAKES_CONTACT, 1 << 0 11 | .set F_AFFECTED_BY_PROTECT, 1 << 1 12 | .set F_AFFECTED_BY_MAGIC_COAT, 1 << 2 13 | .set F_AFFECTED_BY_SNATCH, 1 << 3 14 | .set F_MIRROR_MOVE_COMPATIBLE, 1 << 4 15 | .set F_AFFECTED_BY_KINGS_ROCK, 1 << 5 16 | -------------------------------------------------------------------------------- /payload/include/gflib/sound.h: -------------------------------------------------------------------------------- 1 | #ifndef GFLIB_SOUND_H 2 | #define GFLIB_SOUND_H 3 | 4 | #include "m4a.h" 5 | 6 | bool32 EnableSoundVSync(bool32 enable); 7 | void InitSound(void); 8 | void PauseSoundVSync(void); 9 | void PlaySE(u16 song); 10 | void UNUSED StopSE(u16 song); 11 | void UNUSED StopAllSound(void); 12 | bool8 UNUSED ReturnTrue(void); 13 | void UNUSED FadeOutSE(u16 song, u16 _speed); 14 | void UNUSED SetSEVolume(u16 song, u16 volume); 15 | void UNUSED SetSETempo(u16 song, u16 tempo); 16 | void UNUSED SetSEPitch(u16 song, s16 pitch); 17 | void SoundVSyncOff(void); 18 | void SoundVSyncOn(void); 19 | 20 | #endif //GFLIB_SOUND_H 21 | -------------------------------------------------------------------------------- /payload/include/mb_20094A8.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_MB_20094A8_H 2 | #define GUARD_MB_20094A8_H 3 | 4 | extern const struct SpindaSpot gSpindaSpotGraphics[]; 5 | extern const u8 gText_Egg[]; 6 | extern const struct Berry gBerries[]; 7 | extern const u32 gBitTable[]; 8 | extern const u8 gTypeToPaletteNumber[]; 9 | extern const u8 gPPUpReadMasks[]; 10 | extern const u8 gGiftRibbonMonDataIds[]; 11 | extern const u16 gSpeciesToNationalPokedexNum[]; 12 | extern const u8 gExtCtrlCodeLengths[]; 13 | extern const u16 gRSPokemonCenterMaps[]; 14 | extern const u16 gRSSpecialAreaMaps[]; 15 | extern u8 gText_BadEgg[]; 16 | 17 | #endif // GUARD_MB_20094A8_H 18 | -------------------------------------------------------------------------------- /tools/gbagfx/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | 3 | CFLAGS = -Wall -Wextra -Werror -Wno-sign-compare -std=c11 -O2 -DPNG_SKIP_SETJMP_CHECK 4 | 5 | LIBS = -lpng -lz 6 | 7 | SRCS = main.c convert_png.c gfx.c jasc_pal.c lz.c rl.c util.c font.c huff.c 8 | 9 | .PHONY: all clean 10 | 11 | all: gbagfx 12 | @: 13 | 14 | gbagfx-debug: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h 15 | $(CC) $(CFLAGS) -DDEBUG $(SRCS) -o $@ $(LDFLAGS) $(LIBS) 16 | 17 | gbagfx: $(SRCS) convert_png.h gfx.h global.h jasc_pal.h lz.h rl.h util.h font.h 18 | $(CC) $(CFLAGS) $(SRCS) -o $@ $(LDFLAGS) $(LIBS) 19 | 20 | clean: 21 | $(RM) gbagfx gbagfx.exe 22 | -------------------------------------------------------------------------------- /payload/include/berry_fix.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_BERRY_FIX_H 2 | #define GUARD_BERRY_FIX_H 3 | 4 | #define RTC_INIT_ERROR 0x0001 5 | #define RTC_INIT_WARNING 0x0002 6 | 7 | #define RTC_ERR_12HOUR_CLOCK 0x0010 8 | #define RTC_ERR_POWER_FAILURE 0x0020 9 | #define RTC_ERR_INVALID_YEAR 0x0040 10 | #define RTC_ERR_INVALID_MONTH 0x0080 11 | #define RTC_ERR_INVALID_DAY 0x0100 12 | #define RTC_ERR_INVALID_HOUR 0x0200 13 | #define RTC_ERR_INVALID_MINUTE 0x0400 14 | #define RTC_ERR_INVALID_SECOND 0x0800 15 | 16 | #define RTC_ERR_FLAG_MASK 0x0FF0 17 | 18 | void BerryFix(u32 * state, void * unused1, u32 unused2); 19 | 20 | #endif // GUARD_BERRY_FIX_H 21 | -------------------------------------------------------------------------------- /payload/include/iwram.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_IWRAM_H 2 | #define GUARD_IWRAM_H 3 | 4 | IWRAM_DATA u8 _Iwram[0x8000]; 5 | 6 | #define gBgTilemapBuffers ((u16 *)IWRAM_START) 7 | #define BG_TILEMAP_BUFFER(i) ((u16 *)(IWRAM_START + BG_SCREEN_SIZE * (i))) 8 | #define BG_TILEMAP_BUFFERS_SIZE (BG_SCREEN_SIZE * 4) 9 | #define gFontHalfrowLookupTable ((u32 *)(IWRAM_START + 0x4000)) 10 | #define FONT_HALFROW_LOOKUP_TABLE_SIZE (0x400) 11 | #define gPicUncompBuffer ((u8 *)(IWRAM_START + 0x4400)) 12 | #define PIC_UNCOMP_BUFFER_SIZE (0x800) 13 | 14 | #endif //GUARD_IWRAM_H 15 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: [ master ] 4 | pull_request: 5 | 6 | jobs: 7 | build: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - name: Checkout 11 | uses: actions/checkout@master 12 | 13 | - name: Checkout agbcc 14 | uses: actions/checkout@master 15 | with: 16 | path: 'agbcc' 17 | repository: 'pret/agbcc' 18 | 19 | - name: Install binutils 20 | run: sudo apt install gcc-arm-none-eabi binutils-arm-none-eabi 21 | 22 | - name: Install agbcc 23 | run: | 24 | ./build.sh 25 | ./install.sh .. 26 | working-directory: agbcc 27 | 28 | - name: Build 29 | run: make compare 30 | -------------------------------------------------------------------------------- /tools/gbagfx/global.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef GLOBAL_H 4 | #define GLOBAL_H 5 | 6 | #include 7 | #include 8 | 9 | #ifdef _MSC_VER 10 | 11 | #define FATAL_ERROR(format, ...) \ 12 | do { \ 13 | fprintf(stderr, format, __VA_ARGS__); \ 14 | exit(1); \ 15 | } while (0) 16 | 17 | #define UNUSED 18 | 19 | #else 20 | 21 | #define FATAL_ERROR(format, ...) \ 22 | do { \ 23 | fprintf(stderr, format, ##__VA_ARGS__); \ 24 | exit(1); \ 25 | } while (0) 26 | 27 | #define UNUSED __attribute__((__unused__)) 28 | 29 | #endif // _MSC_VER 30 | 31 | #endif // GLOBAL_H 32 | -------------------------------------------------------------------------------- /tools/rsfont/global.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef GLOBAL_H 4 | #define GLOBAL_H 5 | 6 | #include 7 | #include 8 | 9 | #ifdef _MSC_VER 10 | 11 | #define FATAL_ERROR(format, ...) \ 12 | do { \ 13 | fprintf(stderr, format, __VA_ARGS__); \ 14 | exit(1); \ 15 | } while (0) 16 | 17 | #define UNUSED 18 | 19 | #else 20 | 21 | #define FATAL_ERROR(format, ...) \ 22 | do { \ 23 | fprintf(stderr, format, ##__VA_ARGS__); \ 24 | exit(1); \ 25 | } while (0) 26 | 27 | #define UNUSED __attribute__((__unused__)) 28 | 29 | #endif // _MSC_VER 30 | 31 | #endif // GLOBAL_H 32 | -------------------------------------------------------------------------------- /tools/mapjson/mapjson.h: -------------------------------------------------------------------------------- 1 | // mapjson.h 2 | 3 | #ifndef MAPJSON_H 4 | #define MAPJSON_H 5 | 6 | #include 7 | using std::fprintf; using std::exit; 8 | 9 | #include 10 | 11 | #ifdef _MSC_VER 12 | 13 | #define FATAL_ERROR(format, ...) \ 14 | do \ 15 | { \ 16 | fprintf(stderr, format, __VA_ARGS__); \ 17 | exit(1); \ 18 | } while (0) 19 | 20 | #else 21 | 22 | #define FATAL_ERROR(format, ...) \ 23 | do \ 24 | { \ 25 | fprintf(stderr, format, ##__VA_ARGS__); \ 26 | exit(1); \ 27 | } while (0) 28 | 29 | #endif // _MSC_VER 30 | 31 | #endif // MAPJSON_H 32 | -------------------------------------------------------------------------------- /tools/jsonproc/jsonproc.h: -------------------------------------------------------------------------------- 1 | // jsonproc.h 2 | 3 | #ifndef JSONPROC_H 4 | #define JSONPROC_H 5 | 6 | #include 7 | #include 8 | using std::fprintf; using std::exit; 9 | 10 | #include 11 | 12 | #ifdef _MSC_VER 13 | 14 | #define FATAL_ERROR(format, ...) \ 15 | do \ 16 | { \ 17 | fprintf(stderr, format, __VA_ARGS__); \ 18 | exit(1); \ 19 | } while (0) 20 | 21 | #else 22 | 23 | #define FATAL_ERROR(format, ...) \ 24 | do \ 25 | { \ 26 | fprintf(stderr, format, ##__VA_ARGS__); \ 27 | exit(1); \ 28 | } while (0) 29 | 30 | #endif // _MSC_VER 31 | 32 | #endif // JSONPROC_H 33 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | #include "gba/gba.h" 2 | 3 | extern u8 arm_LZ77UnCompWRAM_Buffer[]; 4 | extern u8 arm_LZ77UnCompWRAM_BufferEnd[]; 5 | extern u8 arm_LZ77UnCompWRAM_FuncStart[]; 6 | 7 | typedef void (*IntrFunc)(void); 8 | 9 | const IntrFunc gIntrTableTemplate[14] = {}; 10 | 11 | void arm_LZ77UnCompWRAM(void); 12 | 13 | void sub_0200023C(void) 14 | { 15 | 16 | } 17 | 18 | void AgbMain(void) 19 | { 20 | void (*func)(void) = (void *)arm_LZ77UnCompWRAM_FuncStart; 21 | REG_IME = 0; 22 | RegisterRamReset(RESET_ALL & ~(RESET_EWRAM | RESET_IWRAM)); 23 | REG_WAITCNT = WAITCNT_SRAM_4 | WAITCNT_WS0_N_3 | WAITCNT_WS0_S_1 | WAITCNT_WS1_N_3 | WAITCNT_WS1_S_1 | WAITCNT_WS2_N_3 | WAITCNT_WS2_S_1 | WAITCNT_PREFETCH_ENABLE; 24 | DmaCopy16(3, arm_LZ77UnCompWRAM, IWRAM_START, arm_LZ77UnCompWRAM_BufferEnd - arm_LZ77UnCompWRAM_Buffer); 25 | func(); 26 | while (1); 27 | } 28 | -------------------------------------------------------------------------------- /ld_script.txt: -------------------------------------------------------------------------------- 1 | SECTIONS { 2 | . = 0x02000000; 3 | .text : 4 | ALIGN(4) 5 | { 6 | asm/crt0.o(.text); 7 | src/main.o(.text); 8 | asm/libagbsyscall.o(.text); 9 | *libgcc.a:_call_via_rX.o(.text); 10 | . += 0x100; 11 | } =0 12 | 13 | .rodata : 14 | ALIGN(4) 15 | { 16 | data/payload.o(.rodata); 17 | . = ALIGN(16); 18 | src/main.o(.rodata); 19 | } =0 20 | bootstrap : 21 | ALIGN(4) 22 | { 23 | asm/iwram.o(.text); 24 | } =0 25 | 26 | . = 0x3000000; 27 | iwram (NOLOAD) : 28 | ALIGN(4) 29 | { 30 | arm_LZ77UnCompWRAM_Buffer = .; 31 | . += 0x130; 32 | arm_LZ77UnCompWRAM_FuncStart = .; 33 | . += 0x94; 34 | arm_LZ77UnCompWRAM_BufferEnd = .; 35 | } 36 | /DISCARD/ : 37 | { 38 | *(*); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /asm/macros/field_effect_script.inc: -------------------------------------------------------------------------------- 1 | .macro loadtiles address 2 | .byte 0 3 | .4byte \address 4 | .endm 5 | 6 | .macro loadfadedpal address 7 | .byte 1 8 | .4byte \address 9 | .endm 10 | 11 | .macro loadpal address 12 | .byte 2 13 | .4byte \address 14 | .endm 15 | 16 | .macro callnative address 17 | .byte 3 18 | .4byte \address 19 | .endm 20 | 21 | .macro end 22 | .byte 4 23 | .endm 24 | 25 | .macro loadgfx_callnative tiles_address, palette_address, function_address 26 | .byte 5 27 | .4byte \tiles_address 28 | .4byte \palette_address 29 | .4byte \function_address 30 | .endm 31 | 32 | .macro loadtiles_callnative tiles_address, function_address 33 | .byte 6 34 | .4byte \tiles_address 35 | .4byte \function_address 36 | .endm 37 | 38 | .macro loadfadedpal_callnative palette_address, function_address 39 | .byte 7 40 | .4byte \palette_address 41 | .4byte \function_address 42 | .endm 43 | -------------------------------------------------------------------------------- /payload/asm/macros/field_effect_script.inc: -------------------------------------------------------------------------------- 1 | .macro loadtiles address 2 | .byte 0 3 | .4byte \address 4 | .endm 5 | 6 | .macro loadfadedpal address 7 | .byte 1 8 | .4byte \address 9 | .endm 10 | 11 | .macro loadpal address 12 | .byte 2 13 | .4byte \address 14 | .endm 15 | 16 | .macro callnative address 17 | .byte 3 18 | .4byte \address 19 | .endm 20 | 21 | .macro end 22 | .byte 4 23 | .endm 24 | 25 | .macro loadgfx_callnative tiles_address, palette_address, function_address 26 | .byte 5 27 | .4byte \tiles_address 28 | .4byte \palette_address 29 | .4byte \function_address 30 | .endm 31 | 32 | .macro loadtiles_callnative tiles_address, function_address 33 | .byte 6 34 | .4byte \tiles_address 35 | .4byte \function_address 36 | .endm 37 | 38 | .macro loadfadedpal_callnative palette_address, function_address 39 | .byte 7 40 | .4byte \palette_address 41 | .4byte \function_address 42 | .endm 43 | -------------------------------------------------------------------------------- /tools/gbagfx/huff.h: -------------------------------------------------------------------------------- 1 | #ifndef HUFF_H 2 | #define HUFF_H 3 | 4 | union HuffNode; 5 | 6 | struct HuffData { 7 | unsigned value:31; 8 | unsigned isLeaf:1; 9 | }; 10 | 11 | struct HuffLeaf { 12 | struct HuffData header; 13 | unsigned char key; 14 | }; 15 | 16 | struct HuffBranch { 17 | struct HuffData header; 18 | union HuffNode * left; 19 | union HuffNode * right; 20 | }; 21 | 22 | union HuffNode { 23 | struct HuffData header; 24 | struct HuffLeaf leaf; 25 | struct HuffBranch branch; 26 | }; 27 | 28 | typedef union HuffNode HuffNode_t; 29 | 30 | struct BitEncoding { 31 | unsigned long long nbits:6; 32 | unsigned long long bitstring:58; 33 | }; 34 | 35 | unsigned char * HuffCompress(unsigned char * buffer, int srcSize, int * compressedSize_p, int bitDepth); 36 | unsigned char * HuffDecompress(unsigned char * buffer, int srcSize, int * uncompressedSize_p); 37 | 38 | #endif //HUFF_H 39 | -------------------------------------------------------------------------------- /tools/gbagfx/gfx.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #ifndef GFX_H 4 | #define GFX_H 5 | 6 | #include 7 | #include 8 | 9 | struct Color { 10 | unsigned char red; 11 | unsigned char green; 12 | unsigned char blue; 13 | }; 14 | 15 | struct Palette { 16 | struct Color colors[256]; 17 | int numColors; 18 | }; 19 | 20 | struct Image { 21 | int width; 22 | int height; 23 | int bitDepth; 24 | unsigned char *pixels; 25 | bool hasPalette; 26 | struct Palette palette; 27 | bool hasTransparency; 28 | }; 29 | 30 | void ReadImage(char *path, int tilesWidth, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); 31 | void WriteImage(char *path, int numTiles, int bitDepth, int metatileWidth, int metatileHeight, struct Image *image, bool invertColors); 32 | void FreeImage(struct Image *image); 33 | void ReadGbaPalette(char *path, struct Palette *palette); 34 | void WriteGbaPalette(char *path, struct Palette *palette); 35 | 36 | #endif // GFX_H 37 | -------------------------------------------------------------------------------- /payload/src/agb_flash_le.c: -------------------------------------------------------------------------------- 1 | #include "gba/gba.h" 2 | #include "gba/flash_internal.h" 3 | 4 | const u16 leMaxTime[] = 5 | { 6 | 10, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK, 7 | 10, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK, 8 | 2000, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK, 9 | 2000, 65469, TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_256CLK, 10 | }; 11 | 12 | const struct FlashSetupInfo LE26FV10N1TS = 13 | { 14 | ProgramFlashByte_MX, 15 | ProgramFlashSector_MX, 16 | EraseFlashChip_MX, 17 | EraseFlashSector_MX, 18 | WaitForFlashWrite_Common, 19 | leMaxTime, 20 | { 21 | 131072, // ROM size 22 | { 23 | 4096, // sector size 24 | 12, // bit shift to multiply by sector size (4096 == 1 << 12) 25 | 32, // number of sectors 26 | 0 // appears to be unused 27 | }, 28 | { 3, 1 }, // wait state setup data 29 | { { 0x62, 0x13 } } // ID 30 | } 31 | }; 32 | -------------------------------------------------------------------------------- /payload/include/gflib/bg.h: -------------------------------------------------------------------------------- 1 | #ifndef GFLIB_BG_H 2 | #define GFLIB_BG_H 3 | 4 | #define gBGTilemapBuffers ((void *)0x03000000) 5 | 6 | extern u16 gBgHofsBuffer[]; 7 | extern u16 gBgVofsBuffer[]; 8 | extern bool8 gBgTilemapBufferTransferScheduled[]; 9 | 10 | void ResetGpuBuffers(void); 11 | void DoGpuUpdateAndTilemapTransfers(void); 12 | void CopyToBgTilemapBufferRect(u32 bgNum, u32 left, u32 top, s32 width, u32 height, const u16 * src); 13 | void UNUSED CopyFromBgTilemapBufferRect(u32 bgNum, u32 left, u32 top, s32 width, u32 height, u16 * dest); 14 | void SetBgTilemapBufferPaletteRect(u32 bgNum, u32 left, u32 top, s32 width, u32 height, u32 paletteNum); 15 | void SetBgTilemapBufferTileAt(u32 bgNum, u32 x, u32 y, u16 tileNum); 16 | void FillBgTilemapBufferRect(u32 bgNum, u32 left, u32 top, s32 width, u32 height, u16 tileNum); 17 | void CopyRectWithinBgTilemapBuffer(u32 bgNum, u32 srcLeft, u32 srcTop, s32 width, u32 height, u32 destLeft, u32 destTop); 18 | void SetBgPos(u32 bgNum, s32 x, s32 y); 19 | 20 | #endif //GFLIB_BG_H 21 | -------------------------------------------------------------------------------- /payload/include/graphics.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GRAPHICS_H 2 | #define GUARD_GRAPHICS_H 3 | 4 | extern const u32 gTitle_Gfx[]; 5 | extern const u32 gTitle_Pal[]; 6 | extern const u32 gTitle_Tilemap[]; 7 | extern const u32 gUnknown_0201A894[]; 8 | extern const u32 gMonInfoIcons_Gfx[]; 9 | extern const u32 gPartyMenu_Gfx[]; 10 | extern const u32 gMessageBox_Gfx[]; 11 | extern const u32 gUnknown_0201B1A0[]; 12 | extern const u32 gPartyMenu_Tilemap[]; 13 | extern const u32 gPartySlots_Tilemap[]; 14 | extern const u32 gSummaryScreen_Gfx[]; 15 | extern const u32 gSummaryIcons_Gfx[]; 16 | extern const u32 gSummaryScreen_Pal[]; 17 | extern const u32 gSummaryScreen_Skills_Tilemap[]; 18 | extern const u32 gSummaryScreen_Moves_Tilemap[]; 19 | extern const u32 gTypeStatusIcons_Gfx[]; 20 | extern const u32 gTypeStatusIcons_Pal[]; 21 | extern const u32 gBattleScreen_Gfx[]; 22 | extern const u32 gBattleScreen_Pal[]; 23 | extern const u32 gBattleScreen_Tilemap[]; 24 | extern const u32 gBattleWindows_Tilemap[]; 25 | 26 | #endif // GUARD_GRAPHICS_H 27 | -------------------------------------------------------------------------------- /payload/src/gflib/keys.c: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | #include "gflib/keys.h" 3 | 4 | u16 gNewKeys; 5 | u16 gNewAndRepeatedKeys; 6 | u16 gHeldKeys; 7 | 8 | static u16 sKeyRepeatDelay; 9 | static u16 sKeyRepeatRate; 10 | static u16 sKeyRepeatTimer; 11 | 12 | void ReadKeys(void) 13 | { 14 | u32 keyInput; 15 | u16 * prevKeys = &gHeldKeys; 16 | u16 newKeys = (keyInput = REG_KEYINPUT ^ KEYS_MASK) & ~*prevKeys; 17 | gNewKeys = newKeys; 18 | 19 | if (gHeldKeys != keyInput) 20 | { 21 | gNewAndRepeatedKeys = keyInput; 22 | sKeyRepeatTimer = sKeyRepeatDelay; 23 | } 24 | else if (--sKeyRepeatTimer == 0) 25 | { 26 | gNewAndRepeatedKeys = keyInput; 27 | sKeyRepeatTimer = sKeyRepeatRate; 28 | } 29 | else 30 | { 31 | gNewAndRepeatedKeys = 0; 32 | } 33 | 34 | gHeldKeys = keyInput; 35 | } 36 | 37 | void SetKeyRepeatTiming(u16 delay, u16 rate) 38 | { 39 | sKeyRepeatDelay = delay; 40 | sKeyRepeatRate = rate; 41 | sKeyRepeatTimer = 1; 42 | } 43 | -------------------------------------------------------------------------------- /payload/include/constants/battle.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_CONSTANTS_BATTLE_H 2 | #define GUARD_CONSTANTS_BATTLE_H 3 | 4 | // Non-volatile status conditions 5 | // These persist remain outside of battle and after switching out 6 | #define STATUS1_NONE 0 7 | #define STATUS1_SLEEP (1 << 0 | 1 << 1 | 1 << 2) // First 3 bits (Number of turns to sleep) 8 | #define STATUS1_SLEEP_TURN(num) ((num) << 0) // Just for readability (or if rearranging statuses) 9 | #define STATUS1_POISON (1 << 3) 10 | #define STATUS1_BURN (1 << 4) 11 | #define STATUS1_FREEZE (1 << 5) 12 | #define STATUS1_PARALYSIS (1 << 6) 13 | #define STATUS1_TOXIC_POISON (1 << 7) 14 | #define STATUS1_TOXIC_COUNTER (1 << 8 | 1 << 9 | 1 << 10 | 1 << 11) 15 | #define STATUS1_TOXIC_TURN(num) ((num) << 8) 16 | #define STATUS1_PSN_ANY (STATUS1_POISON | STATUS1_TOXIC_POISON) 17 | #define STATUS1_ANY (STATUS1_SLEEP | STATUS1_POISON | STATUS1_BURN | STATUS1_FREEZE | STATUS1_PARALYSIS | STATUS1_TOXIC_POISON) 18 | 19 | #endif // GUARD_CONSTANTS_BATTLE_H 20 | -------------------------------------------------------------------------------- /tools/bin2c/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 YamaArashi 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /tools/gbagfx/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 YamaArashi 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /tools/mid2agb/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 YamaArashi 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /tools/preproc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 YamaArashi 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /tools/scaninc/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 YamaArashi 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /tools/ramscrgen/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 YamaArashi 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /tools/rsfont/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015-2016 YamaArashi 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /payload/include/m4a.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_M4A_H 2 | #define GUARD_M4A_H 3 | 4 | #include "gba/gba.h" 5 | #include "gba/m4a_internal.h" 6 | 7 | extern struct MusicPlayerInfo gMPlayInfo_BGM; 8 | extern struct MusicPlayerInfo gMPlayInfo_SE1; 9 | extern struct MusicPlayerInfo gMPlayInfo_SE2; 10 | extern struct MusicPlayerInfo gMPlayInfo_SE3; 11 | 12 | void m4aSoundVSync(void); 13 | void m4aSoundVSyncOn(void); 14 | 15 | void m4aSoundInit(void); 16 | void m4aSoundMain(void); 17 | void m4aSongNumStart(u16); 18 | void m4aSongNumStop(u16 n); 19 | void m4aMPlayAllStop(void); 20 | void m4aMPlayContinue(struct MusicPlayerInfo *mplayInfo); 21 | void m4aMPlayFadeOut(struct MusicPlayerInfo *mplayInfo, u16 speed); 22 | void m4aMPlayImmInit(struct MusicPlayerInfo *mplayInfo); 23 | void m4aMPlayFadeIn(struct MusicPlayerInfo *mplayInfo, u16 speed); 24 | void m4aMPlayImmInit(struct MusicPlayerInfo *mplayInfo); 25 | void m4aMPlayVolumeControl(struct MusicPlayerInfo * mplayInfo, u16 chanMask, u16 volume); 26 | void m4aMPlayTempoControl(struct MusicPlayerInfo * mplayInfo, u16 volume); 27 | void m4aMPlayPitchControl(struct MusicPlayerInfo * mplayInfo, u16 chanMask, s16 pitch); 28 | 29 | #endif //GUARD_M4A_H 30 | -------------------------------------------------------------------------------- /tools/aif2pcm/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 huderlem 2 | Copyright (c) 2005, 2006 by Marco Trillo 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /tools/mid2agb/error.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ERROR_H 22 | #define ERROR_H 23 | 24 | [[noreturn]] void RaiseError(const char* format, ...); 25 | 26 | #endif // ERROR_H 27 | -------------------------------------------------------------------------------- /tools/ramscrgen/elf.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ELF_H 22 | #define ELF_H 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | std::map GetCommonSymbols(std::string sourcePath, std::string path); 29 | 30 | #endif // ELF_H 31 | -------------------------------------------------------------------------------- /tools/mid2agb/tables.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef TABLES_H 22 | #define TABLES_H 23 | 24 | extern const int g_noteDurationLUT[]; 25 | extern const int g_noteVelocityLUT[]; 26 | extern const char* g_noteTable[]; 27 | extern const char* g_minusNoteTable[]; 28 | 29 | #endif // TABLES_H 30 | -------------------------------------------------------------------------------- /tools/preproc/utf8.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef UTF8_H 22 | #define UTF8_H 23 | 24 | #include 25 | 26 | struct UnicodeChar 27 | { 28 | std::int32_t code; 29 | int encodingLength; 30 | }; 31 | 32 | UnicodeChar DecodeUtf8(const char* s); 33 | 34 | #endif // UTF8_H 35 | -------------------------------------------------------------------------------- /payload/include/siirtc.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_RTC_H 2 | #define GUARD_RTC_H 3 | 4 | #include "gba/gba.h" 5 | 6 | #define SIIRTCINFO_INTFE 0x01 // frequency interrupt enable 7 | #define SIIRTCINFO_INTME 0x02 // per-minute interrupt enable 8 | #define SIIRTCINFO_INTAE 0x04 // alarm interrupt enable 9 | #define SIIRTCINFO_24HOUR 0x40 // 0: 12-hour mode, 1: 24-hour mode 10 | #define SIIRTCINFO_POWER 0x80 // power on or power failure occurred 11 | 12 | enum 13 | { 14 | MONTH_JAN = 1, 15 | MONTH_FEB, 16 | MONTH_MAR, 17 | MONTH_APR, 18 | MONTH_MAY, 19 | MONTH_JUN, 20 | MONTH_JUL, 21 | MONTH_AUG, 22 | MONTH_SEP, 23 | MONTH_OCT, 24 | MONTH_NOV, 25 | MONTH_DEC 26 | }; 27 | 28 | struct SiiRtcInfo 29 | { 30 | u8 year; 31 | u8 month; 32 | u8 day; 33 | u8 dayOfWeek; 34 | u8 hour; 35 | u8 minute; 36 | u8 second; 37 | u8 status; 38 | u8 alarmHour; 39 | u8 alarmMinute; 40 | }; 41 | 42 | void SiiRtcUnprotect(void); 43 | void SiiRtcProtect(void); 44 | u8 SiiRtcProbe(void); 45 | bool8 SiiRtcReset(void); 46 | bool8 SiiRtcGetStatus(struct SiiRtcInfo *rtc); 47 | bool8 SiiRtcSetStatus(struct SiiRtcInfo *rtc); 48 | bool8 SiiRtcGetDateTime(struct SiiRtcInfo *rtc); 49 | bool8 SiiRtcSetDateTime(struct SiiRtcInfo *rtc); 50 | bool8 SiiRtcGetTime(struct SiiRtcInfo *rtc); 51 | bool8 SiiRtcSetTime(struct SiiRtcInfo *rtc); 52 | bool8 SiiRtcSetAlarm(struct SiiRtcInfo *rtc); 53 | 54 | #endif // GUARD_RTC_H 55 | -------------------------------------------------------------------------------- /tools/mid2agb/agb.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef AGB_H 22 | #define AGB_H 23 | 24 | #include 25 | #include "midi.h" 26 | 27 | void PrintAgbHeader(); 28 | void PrintAgbTrack(std::vector& events); 29 | void PrintAgbFooter(); 30 | 31 | extern int g_agbTrack; 32 | 33 | #endif // AGB_H 34 | -------------------------------------------------------------------------------- /include/gba/isagbprint.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_ISAGBPRINT_H 2 | #define GUARD_GBA_ISAGBPRINT_H 3 | 4 | #ifdef NDEBUG 5 | #define AGBPrintInit() 6 | #define AGBPutc(cChr) 7 | #define AGBPrint(pBuf) 8 | #define AGBPrintf(pBuf, ...) 9 | #define AGBPrintFlush1Block() 10 | #define AGBPrintFlush() 11 | #define AGBAssert(pFile, nLine, pExpression, nStopProgram) 12 | #else 13 | void AGBPrintInit(void); 14 | void AGBPutc(const char cChr); 15 | void AGBPrint(const char *pBuf); 16 | void AGBPrintf(const char *pBuf, ...); 17 | void AGBPrintFlush1Block(void); 18 | void AGBPrintFlush(void); 19 | void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram); 20 | #endif 21 | 22 | #undef AGB_ASSERT 23 | #ifdef NDEBUG 24 | #define AGB_ASSERT(exp) 25 | #else 26 | #define AGB_ASSERT(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 1); 27 | #endif 28 | 29 | #undef AGB_WARNING 30 | #ifdef NDEBUG 31 | #define AGB_WARNING(exp) 32 | #else 33 | #define AGB_WARNING(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 0); 34 | #endif 35 | 36 | // for matching purposes 37 | 38 | #ifdef NDEBUG 39 | #define AGB_ASSERT_EX(exp, file, line) 40 | #else 41 | #define AGB_ASSERT_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 1); 42 | #endif 43 | 44 | #ifdef NDEBUG 45 | #define AGB_WARNING_EX(exp, file, line) 46 | #else 47 | #define AGB_WARNING_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 0); 48 | #endif 49 | 50 | #endif // GUARD_GBA_ISAGBPRINT_H 51 | -------------------------------------------------------------------------------- /tools/rsfont/font.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef FONT_H 22 | #define FONT_H 23 | 24 | #include 25 | #include "gfx.h" 26 | 27 | void ReadFont(char *path, struct Image *image, int numGlyphs, int bpp, int layout); 28 | void WriteFont(char *path, struct Image *image, int numGlyphs, int bpp, int layout); 29 | 30 | #endif // FONT_H 31 | -------------------------------------------------------------------------------- /payload/include/gba/isagbprint.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_ISAGBPRINT_H 2 | #define GUARD_GBA_ISAGBPRINT_H 3 | 4 | #ifdef NDEBUG 5 | #define AGBPrintInit() 6 | #define AGBPutc(cChr) 7 | #define AGBPrint(pBuf) 8 | #define AGBPrintf(pBuf, ...) 9 | #define AGBPrintFlush1Block() 10 | #define AGBPrintFlush() 11 | #define AGBAssert(pFile, nLine, pExpression, nStopProgram) 12 | #else 13 | void AGBPrintInit(void); 14 | void AGBPutc(const char cChr); 15 | void AGBPrint(const char *pBuf); 16 | void AGBPrintf(const char *pBuf, ...); 17 | void AGBPrintFlush1Block(void); 18 | void AGBPrintFlush(void); 19 | void AGBAssert(const char *pFile, int nLine, const char *pExpression, int nStopProgram); 20 | #endif 21 | 22 | #undef AGB_ASSERT 23 | #ifdef NDEBUG 24 | #define AGB_ASSERT(exp) 25 | #else 26 | #define AGB_ASSERT(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 1); 27 | #endif 28 | 29 | #undef AGB_WARNING 30 | #ifdef NDEBUG 31 | #define AGB_WARNING(exp) 32 | #else 33 | #define AGB_WARNING(exp) (exp) ? ((void*)0) : AGBAssert(__FILE__, __LINE__, #exp, 0); 34 | #endif 35 | 36 | // for matching purposes 37 | 38 | #ifdef NDEBUG 39 | #define AGB_ASSERT_EX(exp, file, line) 40 | #else 41 | #define AGB_ASSERT_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 1); 42 | #endif 43 | 44 | #ifdef NDEBUG 45 | #define AGB_WARNING_EX(exp, file, line) 46 | #else 47 | #define AGB_WARNING_EX(exp, file, line) (exp) ? ((void*)0) : AGBAssert(file, line, #exp, 0); 48 | #endif 49 | 50 | #endif // GUARD_GBA_ISAGBPRINT_H 51 | -------------------------------------------------------------------------------- /include/gba/syscall.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_SYSCALL_H 2 | #define GUARD_GBA_SYSCALL_H 3 | 4 | #define RESET_EWRAM 0x01 5 | #define RESET_IWRAM 0x02 6 | #define RESET_PALETTE 0x04 7 | #define RESET_VRAM 0x08 8 | #define RESET_OAM 0x10 9 | #define RESET_SIO_REGS 0x20 10 | #define RESET_SOUND_REGS 0x40 11 | #define RESET_REGS 0x80 12 | #define RESET_ALL 0xFF 13 | 14 | void SoftReset(u32 resetFlags); 15 | 16 | void RegisterRamReset(u32 resetFlags); 17 | 18 | void VBlankIntrWait(void); 19 | 20 | u16 Sqrt(u32 num); 21 | 22 | u16 ArcTan2(s16 x, s16 y); 23 | 24 | #define CPU_SET_SRC_FIXED 0x01000000 25 | #define CPU_SET_16BIT 0x00000000 26 | #define CPU_SET_32BIT 0x04000000 27 | 28 | void CpuSet(const void *src, void *dest, u32 control); 29 | 30 | #define CPU_FAST_SET_SRC_FIXED 0x01000000 31 | 32 | void CpuFastSet(const void *src, void *dest, u32 control); 33 | 34 | void BgAffineSet(struct BgAffineSrcData *src, struct BgAffineDstData *dest, s32 count); 35 | 36 | void ObjAffineSet(struct ObjAffineSrcData *src, void *dest, s32 count, s32 offset); 37 | 38 | void LZ77UnCompWram(const void *src, void *dest); 39 | 40 | void LZ77UnCompVram(const void *src, void *dest); 41 | 42 | void RLUnCompWram(const void *src, void *dest); 43 | 44 | void RLUnCompVram(const void *src, void *dest); 45 | 46 | void HuffUnComp(const void *src, void *dest); 47 | 48 | int MultiBoot(struct MultiBootParam *mp); 49 | 50 | int Div(int dividend, int divisor); 51 | int Mod(int dividend, int divisor); 52 | 53 | #endif // GUARD_GBA_SYSCALL_H 54 | -------------------------------------------------------------------------------- /payload/include/gba/syscall.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_SYSCALL_H 2 | #define GUARD_GBA_SYSCALL_H 3 | 4 | #define RESET_EWRAM 0x01 5 | #define RESET_IWRAM 0x02 6 | #define RESET_PALETTE 0x04 7 | #define RESET_VRAM 0x08 8 | #define RESET_OAM 0x10 9 | #define RESET_SIO_REGS 0x20 10 | #define RESET_SOUND_REGS 0x40 11 | #define RESET_REGS 0x80 12 | #define RESET_ALL 0xFF 13 | 14 | void SoftReset(u32 resetFlags); 15 | 16 | void RegisterRamReset(u32 resetFlags); 17 | 18 | void VBlankIntrWait(void); 19 | 20 | u16 Sqrt(u32 num); 21 | 22 | u16 ArcTan2(s16 x, s16 y); 23 | 24 | #define CPU_SET_SRC_FIXED 0x01000000 25 | #define CPU_SET_16BIT 0x00000000 26 | #define CPU_SET_32BIT 0x04000000 27 | 28 | void CpuSet(const void *src, void *dest, u32 control); 29 | 30 | #define CPU_FAST_SET_SRC_FIXED 0x01000000 31 | 32 | void CpuFastSet(const void *src, void *dest, u32 control); 33 | 34 | void BgAffineSet(struct BgAffineSrcData *src, struct BgAffineDstData *dest, s32 count); 35 | 36 | void ObjAffineSet(struct ObjAffineSrcData *src, void *dest, s32 count, s32 offset); 37 | 38 | void LZ77UnCompWram(const u32 *src, void *dest); 39 | 40 | void LZ77UnCompVram(const u32 *src, void *dest); 41 | 42 | void RLUnCompWram(const void *src, void *dest); 43 | 44 | void RLUnCompVram(const void *src, void *dest); 45 | 46 | void HuffUnComp(const void *src, void *dest); 47 | 48 | int MultiBoot(struct MultiBootParam *mp); 49 | 50 | int Div(int dividend, int divisor); 51 | int Mod(int dividend, int divisor); 52 | 53 | #endif // GUARD_GBA_SYSCALL_H 54 | -------------------------------------------------------------------------------- /payload/asm/libagbsyscall.s: -------------------------------------------------------------------------------- 1 | .include "asm/macros/function.inc" 2 | .text 3 | .syntax unified 4 | 5 | thumb_func_start CpuSet 6 | CpuSet: @ 0x0200FD04 7 | svc #0xb 8 | bx lr 9 | 10 | thumb_func_start Div 11 | Div: @ 0x0200FD08 12 | svc #6 13 | bx lr 14 | 15 | thumb_func_start Mod 16 | Mod: @ 0x0200FD0C 17 | svc #6 18 | adds r0, r1, #0 19 | bx lr 20 | .align 2, 0 21 | 22 | thumb_func_start HuffUnComp 23 | HuffUnComp: @ 0x0200FD14 24 | svc #0x13 25 | bx lr 26 | 27 | thumb_func_start LZ77UnCompVram 28 | LZ77UnCompVram: @ 0x0200FD18 29 | svc #0x12 30 | bx lr 31 | 32 | thumb_func_start LZ77UnCompWram 33 | LZ77UnCompWram: @ 0x0200FD1C 34 | svc #0x11 35 | bx lr 36 | 37 | thumb_func_start RLUnCompVram 38 | RLUnCompVram: @ 0x0200FD20 39 | svc #0x15 40 | bx lr 41 | 42 | thumb_func_start RegisterRamReset 43 | RegisterRamReset: @ 0x0200FD24 44 | svc #1 45 | bx lr 46 | 47 | thumb_func_start SoftReset 48 | SoftReset: @ 0x0200FD28 49 | ldr r3, =0x04000208 50 | movs r2, #0 51 | strb r2, [r3] 52 | ldr r1, =0x03007F00 53 | mov sp, r1 54 | svc #1 55 | svc #0 56 | movs r0, r0 57 | .align 2, 0 58 | .pool 59 | 60 | thumb_func_start VBlankIntrWait 61 | VBlankIntrWait: @ 0x0200FD40 62 | movs r2, #0 63 | svc #5 64 | bx lr 65 | .align 2, 0 66 | 67 | thumb_func_start SoftResetRom 68 | SoftResetRom: @ 0x0200FD48 69 | ldr r3, =0x04000208 70 | movs r2, #0 71 | strb r2, [r3] 72 | ldr r3, =0x03007FFA 73 | movs r2, #1 74 | strb r2, [r3] 75 | subs r3, #0xfa 76 | mov sp, r3 77 | movs r2, #1 78 | bics r0, r2 79 | svc #1 80 | svc #0 81 | .align 2, 0 82 | .pool 83 | -------------------------------------------------------------------------------- /asm/macros/pokemon_data.inc: -------------------------------------------------------------------------------- 1 | .macro pokedex_entry pokemon_name, height, weight, pokemon_scale, pokemon_offset, trainer_scale, trainer_offset 2 | .2byte \height @ in decimeters 3 | .2byte \weight @ in hectograms 4 | .4byte DexDescription_\pokemon_name\()_1 5 | .4byte DexDescription_\pokemon_name\()_2 6 | .2byte 0 @ unused 7 | .2byte \pokemon_scale 8 | .2byte \pokemon_offset 9 | .2byte \trainer_scale 10 | .2byte \trainer_offset 11 | .2byte 0 @ padding 12 | .endm 13 | 14 | .macro base_stats hp, attack, defense, speed, sp_attack, sp_defense 15 | .byte \hp 16 | .byte \attack 17 | .byte \defense 18 | .byte \speed 19 | .byte \sp_attack 20 | .byte \sp_defense 21 | .endm 22 | 23 | .macro ev_yield hp, attack, defense, speed, sp_attack, sp_defense 24 | .2byte (\sp_defense << 10) | (\sp_attack << 8) | (\speed << 6) | (\defense << 4) | (\attack << 2) | \hp 25 | .endm 26 | 27 | .macro level_up_move level, move 28 | .2byte (\level << 9) | \move 29 | .endm 30 | 31 | .macro evo_entry method, parameter, target_species 32 | .2byte \method 33 | .2byte \parameter 34 | .2byte \target_species 35 | .2byte 0 @ padding 36 | .endm 37 | 38 | .macro empty_evo_entries count 39 | .fill 8 * \count, 1, 0 40 | .endm 41 | 42 | .macro egg_moves_begin species 43 | .2byte 20000 + \species 44 | .endm 45 | 46 | @ If the min level equals the max level, only one level argument is needed. 47 | .macro wild_mon species, min_level, max_level 48 | .byte \min_level 49 | 50 | .ifb \max_level 51 | .byte \min_level 52 | .else 53 | .byte \max_level 54 | .endif 55 | 56 | .2byte SPECIES_\species 57 | .endm 58 | -------------------------------------------------------------------------------- /payload/asm/macros/pokemon_data.inc: -------------------------------------------------------------------------------- 1 | .macro pokedex_entry pokemon_name, height, weight, pokemon_scale, pokemon_offset, trainer_scale, trainer_offset 2 | .2byte \height @ in decimeters 3 | .2byte \weight @ in hectograms 4 | .4byte DexDescription_\pokemon_name\()_1 5 | .4byte DexDescription_\pokemon_name\()_2 6 | .2byte 0 @ unused 7 | .2byte \pokemon_scale 8 | .2byte \pokemon_offset 9 | .2byte \trainer_scale 10 | .2byte \trainer_offset 11 | .2byte 0 @ padding 12 | .endm 13 | 14 | .macro base_stats hp, attack, defense, speed, sp_attack, sp_defense 15 | .byte \hp 16 | .byte \attack 17 | .byte \defense 18 | .byte \speed 19 | .byte \sp_attack 20 | .byte \sp_defense 21 | .endm 22 | 23 | .macro ev_yield hp, attack, defense, speed, sp_attack, sp_defense 24 | .2byte (\sp_defense << 10) | (\sp_attack << 8) | (\speed << 6) | (\defense << 4) | (\attack << 2) | \hp 25 | .endm 26 | 27 | .macro level_up_move level, move 28 | .2byte (\level << 9) | \move 29 | .endm 30 | 31 | .macro evo_entry method, parameter, target_species 32 | .2byte \method 33 | .2byte \parameter 34 | .2byte \target_species 35 | .2byte 0 @ padding 36 | .endm 37 | 38 | .macro empty_evo_entries count 39 | .fill 8 * \count, 1, 0 40 | .endm 41 | 42 | .macro egg_moves_begin species 43 | .2byte 20000 + \species 44 | .endm 45 | 46 | @ If the min level equals the max level, only one level argument is needed. 47 | .macro wild_mon species, min_level, max_level 48 | .byte \min_level 49 | 50 | .ifb \max_level 51 | .byte \min_level 52 | .else 53 | .byte \max_level 54 | .endif 55 | 56 | .2byte SPECIES_\species 57 | .endm 58 | -------------------------------------------------------------------------------- /tools/mid2agb/main.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef MAIN_H 22 | #define MAIN_H 23 | 24 | #include 25 | #include 26 | 27 | extern FILE* g_inputFile; 28 | extern FILE* g_outputFile; 29 | 30 | extern std::string g_asmLabel; 31 | extern int g_masterVolume; 32 | extern int g_voiceGroup; 33 | extern int g_priority; 34 | extern int g_reverb; 35 | extern int g_clocksPerBeat; 36 | extern bool g_exactGateTime; 37 | extern bool g_compressionEnabled; 38 | 39 | #endif // MAIN_H 40 | -------------------------------------------------------------------------------- /constants/misc_constants.inc: -------------------------------------------------------------------------------- 1 | .set TRUE, 1 2 | .set FALSE, 0 3 | 4 | .set NULL, 0 5 | 6 | .set POKEMON_NAME_LENGTH, 11 7 | .set MOVE_NAME_LENGTH, 13 8 | 9 | .set SPRITE_SIZE_8x8, (OAM_SIZE_0 >> 28) | (OAM_SQUARE >> 14) 10 | .set SPRITE_SIZE_16x16, (OAM_SIZE_1 >> 28) | (OAM_SQUARE >> 14) 11 | .set SPRITE_SIZE_32x32, (OAM_SIZE_2 >> 28) | (OAM_SQUARE >> 14) 12 | .set SPRITE_SIZE_64x64, (OAM_SIZE_3 >> 28) | (OAM_SQUARE >> 14) 13 | 14 | .set SPRITE_SIZE_16x8, (OAM_SIZE_0 >> 28) | (OAM_H_RECTANGLE >> 14) 15 | .set SPRITE_SIZE_32x8, (OAM_SIZE_1 >> 28) | (OAM_H_RECTANGLE >> 14) 16 | .set SPRITE_SIZE_32x16, (OAM_SIZE_2 >> 28) | (OAM_H_RECTANGLE >> 14) 17 | .set SPRITE_SIZE_64x32, (OAM_SIZE_3 >> 28) | (OAM_H_RECTANGLE >> 14) 18 | 19 | .set SPRITE_SIZE_8x16, (OAM_SIZE_0 >> 28) | (OAM_V_RECTANGLE >> 14) 20 | .set SPRITE_SIZE_8x32, (OAM_SIZE_1 >> 28) | (OAM_V_RECTANGLE >> 14) 21 | .set SPRITE_SIZE_16x32, (OAM_SIZE_2 >> 28) | (OAM_V_RECTANGLE >> 14) 22 | .set SPRITE_SIZE_32x64, (OAM_SIZE_3 >> 28) | (OAM_V_RECTANGLE >> 14) 23 | 24 | .set OBJ_IMAGE_ANIM_H_FLIP, 1 << 6 25 | .set OBJ_IMAGE_ANIM_V_FLIP, 1 << 7 26 | 27 | .equiv DIR_SOUTH, 1 28 | .equiv DIR_NORTH, 2 29 | .equiv DIR_WEST, 3 30 | .equiv DIR_EAST, 4 31 | 32 | .equiv MALE, 0 33 | .equiv FEMALE, 1 34 | 35 | .ifdef ENGLISH 36 | .equiv GAME_LANGUAGE, 2 37 | .else 38 | .ifdef GERMAN 39 | .equiv GAME_LANGUAGE, 5 40 | .endif 41 | .endif 42 | 43 | .equiv ENEMY_TYPE1, 0 44 | .equiv ENEMY_TYPE2, 1 45 | .equiv PLAYER_TYPE1, 2 46 | .equiv PLAYER_TYPE2, 3 47 | .equiv CURRENT_MOVE, 4 48 | 49 | .equiv LESS_THAN, 0 50 | .equiv GREATER_THAN, 1 51 | .equiv EQUAL, 2 52 | -------------------------------------------------------------------------------- /payload/constants/misc_constants.inc: -------------------------------------------------------------------------------- 1 | .set TRUE, 1 2 | .set FALSE, 0 3 | 4 | .set NULL, 0 5 | 6 | .set POKEMON_NAME_LENGTH, 11 7 | .set MOVE_NAME_LENGTH, 13 8 | 9 | .set SPRITE_SIZE_8x8, (OAM_SIZE_0 >> 28) | (OAM_SQUARE >> 14) 10 | .set SPRITE_SIZE_16x16, (OAM_SIZE_1 >> 28) | (OAM_SQUARE >> 14) 11 | .set SPRITE_SIZE_32x32, (OAM_SIZE_2 >> 28) | (OAM_SQUARE >> 14) 12 | .set SPRITE_SIZE_64x64, (OAM_SIZE_3 >> 28) | (OAM_SQUARE >> 14) 13 | 14 | .set SPRITE_SIZE_16x8, (OAM_SIZE_0 >> 28) | (OAM_H_RECTANGLE >> 14) 15 | .set SPRITE_SIZE_32x8, (OAM_SIZE_1 >> 28) | (OAM_H_RECTANGLE >> 14) 16 | .set SPRITE_SIZE_32x16, (OAM_SIZE_2 >> 28) | (OAM_H_RECTANGLE >> 14) 17 | .set SPRITE_SIZE_64x32, (OAM_SIZE_3 >> 28) | (OAM_H_RECTANGLE >> 14) 18 | 19 | .set SPRITE_SIZE_8x16, (OAM_SIZE_0 >> 28) | (OAM_V_RECTANGLE >> 14) 20 | .set SPRITE_SIZE_8x32, (OAM_SIZE_1 >> 28) | (OAM_V_RECTANGLE >> 14) 21 | .set SPRITE_SIZE_16x32, (OAM_SIZE_2 >> 28) | (OAM_V_RECTANGLE >> 14) 22 | .set SPRITE_SIZE_32x64, (OAM_SIZE_3 >> 28) | (OAM_V_RECTANGLE >> 14) 23 | 24 | .set OBJ_IMAGE_ANIM_H_FLIP, 1 << 6 25 | .set OBJ_IMAGE_ANIM_V_FLIP, 1 << 7 26 | 27 | .equiv DIR_SOUTH, 1 28 | .equiv DIR_NORTH, 2 29 | .equiv DIR_WEST, 3 30 | .equiv DIR_EAST, 4 31 | 32 | .equiv MALE, 0 33 | .equiv FEMALE, 1 34 | 35 | .ifdef ENGLISH 36 | .equiv GAME_LANGUAGE, 2 37 | .else 38 | .ifdef GERMAN 39 | .equiv GAME_LANGUAGE, 5 40 | .endif 41 | .endif 42 | 43 | .equiv ENEMY_TYPE1, 0 44 | .equiv ENEMY_TYPE2, 1 45 | .equiv PLAYER_TYPE1, 2 46 | .equiv PLAYER_TYPE2, 3 47 | .equiv CURRENT_MOVE, 4 48 | 49 | .equiv LESS_THAN, 0 50 | .equiv GREATER_THAN, 1 51 | .equiv EQUAL, 2 52 | -------------------------------------------------------------------------------- /payload/include/gflib/sprite.h: -------------------------------------------------------------------------------- 1 | #ifndef GFLIB_SPRITE_H 2 | #define GFLIB_SPRITE_H 3 | 4 | struct Subsprites 5 | { 6 | u32 oam; 7 | s16 x; 8 | s16 y; 9 | u16 baseBlock; 10 | u16 unk_a; 11 | }; 12 | 13 | struct Sprite 14 | { 15 | u8 prev; 16 | u8 next; 17 | u8 flag; 18 | u16 paletteNum; 19 | u16 tileOffset; 20 | s16 x; 21 | s16 y; 22 | const struct Subsprites * spriteTemplates; 23 | void (*callback)(struct Sprite *); 24 | u32 data[4]; 25 | }; 26 | 27 | struct SpriteSheet 28 | { 29 | const u8 *data; // Raw uncompressed pixel data 30 | u16 size; 31 | u16 tag; 32 | }; 33 | 34 | struct CompressedSpriteSheet 35 | { 36 | const u32 *data; // LZ77 compressed pixel data 37 | u16 size; // Uncompressed size of pixel data 38 | u16 tag; 39 | }; 40 | 41 | struct SpritePalette 42 | { 43 | const u16 *data; // Raw uncompressed palette data 44 | u16 tag; 45 | }; 46 | 47 | struct CompressedSpritePalette 48 | { 49 | const u32 *data; // LZ77 compressed palette data 50 | u16 tag; 51 | }; 52 | 53 | void ResetSprites(void); 54 | void UpdateSprites(void); 55 | void DoOamBufferTransfer(void); 56 | struct Sprite * AddSprite(s32 x, s32 y, const struct Subsprites * subsprites); 57 | void MoveSpriteToHead(struct Sprite * sprite); 58 | void SetSpritePos(struct Sprite * sprite, s32 x, s32 y); 59 | void AddSpritePos(struct Sprite * sprite, s32 x, s32 y); 60 | void SetSpritePaletteNum(struct Sprite * sprite, s32 paletteNum); 61 | void SetSpriteTileOffset(struct Sprite * sprite, s32 tileOffset); 62 | void SetSpriteInvisible(struct Sprite * sprite, s32 invisible); 63 | 64 | #endif //GFLIB_SPRITE_H 65 | -------------------------------------------------------------------------------- /tools/mid2agb/error.cpp: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | // Reports an error diagnostic and terminates the program. 26 | [[noreturn]] void RaiseError(const char* format, ...) 27 | { 28 | const int bufferSize = 1024; 29 | char buffer[bufferSize]; 30 | std::va_list args; 31 | va_start(args, format); 32 | std::vsnprintf(buffer, bufferSize, format, args); 33 | std::fprintf(stderr, "error: %s\n", buffer); 34 | va_end(args); 35 | std::exit(1); 36 | } 37 | -------------------------------------------------------------------------------- /payload/include/global.berry.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GLOBAL_BERRY_H 2 | #define GUARD_GLOBAL_BERRY_H 3 | 4 | struct Berry 5 | { 6 | /*0x00*/ u8 name[7]; 7 | /*0x07*/ u8 firmness; 8 | /*0x08*/ u16 size; 9 | /*0x0A*/ u8 maxYield; 10 | /*0x0B*/ u8 minYield; 11 | /*0x0C*/ const u8 *description1; 12 | /*0x10*/ const u8 *description2; 13 | /*0x14*/ u8 stageDuration; 14 | /*0x15*/ u8 spicy; 15 | /*0x16*/ u8 dry; 16 | /*0x17*/ u8 sweet; 17 | /*0x18*/ u8 bitter; 18 | /*0x19*/ u8 sour; 19 | /*0x1A*/ u8 smoothness; 20 | }; 21 | 22 | struct EnigmaBerry 23 | { 24 | /*0x000*/ struct Berry berry; 25 | /*0x01B*/ u8 pic[(6 * 6) * TILE_SIZE_4BPP]; 26 | /*0x49C*/ u16 palette[16]; 27 | /*0x4BC*/ u8 description1[45]; 28 | /*0x4E9*/ u8 description2[45]; 29 | /*0x516*/ u8 itemEffect[18]; 30 | /*0x528*/ u8 holdEffect; 31 | /*0x529*/ u8 holdEffectParam; 32 | /*0x52C*/ u32 checksum; 33 | }; 34 | 35 | struct BattleEnigmaBerry 36 | { 37 | /*0x00*/ u8 name[7]; 38 | /*0x07*/ u8 holdEffect; 39 | /*0x08*/ u8 itemEffect[18]; 40 | /*0x1A*/ u8 holdEffectParam; 41 | }; 42 | 43 | struct BerryTree 44 | { 45 | /*0x00*/ u8 berry; 46 | /*0x01*/ u8 stage:7; 47 | /* 48 | A berry sparkle is a state that a berry tree 49 | can be in after growing within the player's 50 | viewport. 51 | */ 52 | /*0x01*/ bool8 growthSparkle:1; 53 | /*0x02*/ u16 minutesUntilNextStage; 54 | /*0x04*/ u8 berryYield; 55 | /*0x05*/ u8 regrowthCount:4; 56 | /*0x05*/ u8 watered1:1; 57 | /*0x05*/ u8 watered2:1; 58 | /*0x05*/ u8 watered3:1; 59 | /*0x05*/ u8 watered4:1; 60 | }; 61 | 62 | #endif // GUARD_GLOBAL_BERRY_H 63 | -------------------------------------------------------------------------------- /tools/rsfont/gfx.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef GFX_H 22 | #define GFX_H 23 | 24 | #include 25 | #include 26 | 27 | struct Color 28 | { 29 | unsigned char red; 30 | unsigned char green; 31 | unsigned char blue; 32 | }; 33 | 34 | struct Palette 35 | { 36 | struct Color colors[256]; 37 | int numColors; 38 | }; 39 | 40 | struct Image { 41 | int width; 42 | int height; 43 | int bitDepth; 44 | unsigned char *pixels; 45 | bool hasPalette; 46 | struct Palette palette; 47 | bool hasTransparency; 48 | }; 49 | 50 | #endif // GFX_H 51 | -------------------------------------------------------------------------------- /payload/include/gflib/text.h: -------------------------------------------------------------------------------- 1 | #ifndef GFLIB_TEXT_H 2 | #define GFLIB_TEXT_H 3 | 4 | #ifdef __cplusplus 5 | // To allow the use of C++ reserved keywords in this header 6 | extern "C" { 7 | #endif 8 | 9 | #include "gflib/characters.h" 10 | 11 | struct Window 12 | { 13 | u8 bg; // 0x0 14 | u8 left; // 0x1 15 | u8 top; // 0x2 16 | u8 width; // 0x3 17 | u8 height; // 0x4 18 | u16 baseBlock; // 0x6 19 | u8 fillValue; // 0x8 20 | u8 glyphSize; // 0x9 21 | void *vramCharBase; // 0xC 22 | const u8 *glyphGfx; // 0x10 23 | const u8 *glyphWidths; // 0x14 24 | u8 fgColor; // 0x18 25 | u8 shadowColor; // 0x19 26 | u8 currentX; // 0x1A 27 | u8 currentY; // 0x1B 28 | u8 glyphWidth; // 0x1C 29 | u8 startX; // 0x1D 30 | u8 startY; // 0x1E 31 | }; 32 | 33 | void DrawGlyphOnWindow_NoShadow(struct Window *window, u32 glyphId, u32 fgColor); 34 | void DrawGlyphOnWindow_WithShadow(struct Window *window, u32 glyphId, u32 fgColor, u32 shadowColor); 35 | struct Window *AddWindow(u32 windowId, const struct Window *template); 36 | void GenerateFontHalfrowLookupTable(u32 * buffer); 37 | void ClearWindowCharBuffer(struct Window * window, u32 tile); 38 | void FillWindowCharBufferRect(struct Window * window, s32 x, s32 y, s32 width, s32 height, u32 fillValue); 39 | void SetTextColor(struct Window * window, u8 fg, u8 shadow); 40 | void TextWindowNextLine(struct Window * window); 41 | void TextWindowSetXY(struct Window * window, u32 x, u32 y); 42 | void TextWindowShiftXY(struct Window * window, s32 dx, s32 dy); 43 | void UNUSED TextWindowPrintSimpleString(struct Window * window, const u8 * glyphs); 44 | void TextWindowFillTileBufferForText(struct Window * window); 45 | 46 | #ifdef __cplusplus 47 | } 48 | #endif 49 | 50 | #endif //GFLIB_TEXT_H 51 | -------------------------------------------------------------------------------- /payload/src/graphics.c: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | 3 | const u32 gTitle_Gfx[] = INCBIN_U32("graphics/title.8bpp.lz"); 4 | const u32 gTitle_Pal[] = INCBIN_U32("graphics/unk_0201A450.gbapal.rl"); 5 | const u32 gTitle_Tilemap[] = INCBIN_U32("graphics/title.bin.lz"); 6 | const u32 gUnknown_0201A894[] = INCBIN_U32("graphics/unk_0201A894.gbapal.rl"); 7 | 8 | const u32 gMonInfoIcons_Gfx[] = INCBIN_U32("graphics/mon_info_icons.4bpp.lz"); 9 | const u32 gPartyMenu_Gfx[] = INCBIN_U32("graphics/party_menu.4bpp.lz"); 10 | const u32 gMessageBox_Gfx[] = INCBIN_U32("graphics/message_box.4bpp.lz"); 11 | const u32 gUnknown_0201B1A0[] = INCBIN_U32("graphics/unk_0201B1A0.gbapal.lz"); // text palette? 12 | const u32 gPartyMenu_Tilemap[] = INCBIN_U32("graphics/party_menu.bin.lz"); 13 | const u32 gPartySlots_Tilemap[] = INCBIN_U32("graphics/party_slots.bin.lz"); 14 | 15 | const u32 gSummaryScreen_Gfx[] = INCBIN_U32("graphics/summary_screen.4bpp.lz"); 16 | const u32 gSummaryIcons_Gfx[] = INCBIN_U32("graphics/summary_icons.4bpp.lz"); 17 | const u32 gSummaryScreen_Pal[] = INCBIN_U32("graphics/unk_0201C10C.gbapal.lz"); 18 | const u32 gSummaryScreen_Skills_Tilemap[] = INCBIN_U32("graphics/summary_screen_skills.bin.lz"); 19 | const u32 gSummaryScreen_Moves_Tilemap[] = INCBIN_U32("graphics/summary_screen_moves.bin.lz"); 20 | 21 | const u32 gTypeStatusIcons_Gfx[] = INCBIN_U32("graphics/type_status_icons.4bpp.lz"); 22 | const u32 gTypeStatusIcons_Pal[] = INCBIN_U32("graphics/unk_0201D05C.gbapal.lz"); 23 | 24 | const u32 gBattleScreen_Gfx[] = INCBIN_U32("graphics/battle_screen.4bpp.lz"); 25 | const u32 gBattleScreen_Pal[] = INCBIN_U32("graphics/unk_0201D3F0.gbapal.rl"); 26 | const u32 gBattleScreen_Tilemap[] = INCBIN_U32("graphics/battle_screen.bin.lz"); 27 | const u32 gBattleWindows_Tilemap[] = INCBIN_U32("graphics/battle_windows.bin.lz"); 28 | -------------------------------------------------------------------------------- /include/gba/multiboot.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_MULTIBOOT_H 2 | #define GUARD_GBA_MULTIBOOT_H 3 | 4 | #define MULTIBOOT_NCHILD 3 // Maximum number of slaves 5 | #define MULTIBOOT_HEADER_SIZE 0xc0 // Header size 6 | #define MULTIBOOT_SEND_SIZE_MIN 0x100 // Minimum transmission size 7 | #define MULTIBOOT_SEND_SIZE_MAX 0x40000 // Maximum transmission size 8 | 9 | struct MultiBootParam 10 | { 11 | u32 system_work[5]; 12 | u8 handshake_data; 13 | u8 padding; 14 | u16 handshake_timeout; 15 | u8 probe_count; 16 | u8 client_data[MULTIBOOT_NCHILD]; 17 | u8 palette_data; 18 | u8 response_bit; 19 | u8 client_bit; 20 | u8 reserved1; 21 | u8 *boot_srcp; 22 | u8 *boot_endp; 23 | u8 *masterp; 24 | u8 *reserved2[MULTIBOOT_NCHILD]; 25 | u32 system_work2[4]; 26 | u8 sendflag; 27 | u8 probe_target_bit; 28 | u8 check_wait; 29 | u8 server_type; 30 | }; 31 | 32 | #define MULTIBOOT_ERROR_04 0x04 33 | #define MULTIBOOT_ERROR_08 0x08 34 | #define MULTIBOOT_ERROR_0c 0x0c 35 | #define MULTIBOOT_ERROR_40 0x40 36 | #define MULTIBOOT_ERROR_44 0x44 37 | #define MULTIBOOT_ERROR_48 0x48 38 | #define MULTIBOOT_ERROR_4c 0x4c 39 | #define MULTIBOOT_ERROR_80 0x80 40 | #define MULTIBOOT_ERROR_84 0x84 41 | #define MULTIBOOT_ERROR_88 0x88 42 | #define MULTIBOOT_ERROR_8c 0x8c 43 | #define MULTIBOOT_ERROR_NO_PROBE_TARGET 0x50 44 | #define MULTIBOOT_ERROR_NO_DLREADY 0x60 45 | #define MULTIBOOT_ERROR_BOOT_FAILURE 0x70 46 | #define MULTIBOOT_ERROR_HANDSHAKE_FAILURE 0x71 47 | 48 | #define MULTIBOOT_CONNECTION_CHECK_WAIT 15 49 | 50 | #define MULTIBOOT_SERVER_TYPE_NORMAL 0 51 | #define MULTIBOOT_SERVER_TYPE_QUICK 1 52 | 53 | #define MULTIBOOT_HANDSHAKE_TIMEOUT 400 54 | 55 | #endif // GUARD_GBA_MULTIBOOT_H 56 | -------------------------------------------------------------------------------- /include/gba/defines.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_DEFINES 2 | #define GUARD_GBA_DEFINES 3 | 4 | #include 5 | 6 | #define TRUE 1 7 | #define FALSE 0 8 | 9 | #define EWRAM_START 0x02000000 10 | #define IWRAM_START 0x03000000 11 | 12 | #define BSS_DATA __attribute__((section(".bss"))) 13 | #define IWRAM_DATA __attribute__((section("iwram_data"))) 14 | #define EWRAM_DATA __attribute__((section("ewram_data"))) 15 | #define UNUSED __attribute__((unused)) 16 | #define NAKED __attribute__((naked)) 17 | 18 | #define ALIGNED(n) __attribute__((aligned(n))) 19 | 20 | #define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0) 21 | #define INTR_CHECK (*(u16 *)0x3007FF8) 22 | #define INTR_VECTOR (*(void **)0x3007FFC) 23 | 24 | #define PLTT 0x5000000 25 | #define PLTT_SIZE 0x400 26 | 27 | #define BG_PLTT PLTT 28 | #define BG_PLTT_SIZE 0x200 29 | 30 | #define OBJ_PLTT (PLTT + 0x200) 31 | #define OBJ_PLTT_SIZE 0x200 32 | 33 | #define VRAM 0x6000000 34 | #define VRAM_SIZE 0x18000 35 | 36 | #define BG_VRAM VRAM 37 | #define BG_VRAM_SIZE 0x10000 38 | #define BG_CHAR_ADDR(n) (void *)(BG_VRAM + (0x4000 * (n))) 39 | #define BG_SCREEN_ADDR(n) (void *)(BG_VRAM + (0x800 * (n))) 40 | #define BG_TILE_ADDR(n) (void *)(BG_VRAM + (0x80 * (n))) 41 | 42 | // text-mode BG 43 | #define OBJ_VRAM0 (void *)(VRAM + 0x10000) 44 | #define OBJ_VRAM0_SIZE 0x8000 45 | 46 | // bitmap-mode BG 47 | #define OBJ_VRAM1 (void *)(VRAM + 0x14000) 48 | #define OBJ_VRAM1_SIZE 0x4000 49 | 50 | #define OAM 0x7000000 51 | #define OAM_SIZE 0x400 52 | 53 | #define DISPLAY_WIDTH 240 54 | #define DISPLAY_HEIGHT 160 55 | 56 | #define TILE_SIZE_4BPP 32 57 | #define TILE_SIZE_8BPP 64 58 | 59 | #define TOTAL_OBJ_TILE_COUNT 1024 60 | 61 | #define RGB(r, g, b) ((r) | ((g) << 5) | ((b) << 10)) 62 | 63 | #define RGB_BLACK RGB(0, 0, 0) 64 | #define RGB_WHITE RGB(31, 31, 31) 65 | 66 | #define WIN_RANGE(a, b) (((a) << 8) | (b)) 67 | 68 | #endif // GUARD_GBA_DEFINES 69 | -------------------------------------------------------------------------------- /payload/graphics/party_menu.bin: -------------------------------------------------------------------------------- 1 |   2 |     -------------------------------------------------------------------------------- /tools/ramscrgen/ramscrgen.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef RAMSCRGEN_H 22 | #define RAMSCRGEN_H 23 | 24 | #include 25 | #include 26 | 27 | #ifdef _MSC_VER 28 | 29 | #define FATAL_ERROR(format, ...) \ 30 | do \ 31 | { \ 32 | std::fprintf(stderr, format, __VA_ARGS__); \ 33 | std::exit(1); \ 34 | } while (0) 35 | 36 | #else 37 | 38 | #define FATAL_ERROR(format, ...) \ 39 | do \ 40 | { \ 41 | std::fprintf(stderr, format, ##__VA_ARGS__); \ 42 | std::exit(1); \ 43 | } while (0) 44 | 45 | #endif // _MSC_VER 46 | 47 | const int kMaxPath = 256; 48 | 49 | #endif // RAMSCRGEN_H 50 | -------------------------------------------------------------------------------- /payload/include/gba/multiboot.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_MULTIBOOT_H 2 | #define GUARD_GBA_MULTIBOOT_H 3 | 4 | #define MULTIBOOT_NCHILD 3 // Maximum number of slaves 5 | #define MULTIBOOT_HEADER_SIZE 0xc0 // Header size 6 | #define MULTIBOOT_SEND_SIZE_MIN 0x100 // Minimum transmission size 7 | #define MULTIBOOT_SEND_SIZE_MAX 0x40000 // Maximum transmission size 8 | 9 | struct MultiBootParam 10 | { 11 | u32 system_work[5]; // 00 12 | u8 handshake_data; // 14 13 | u8 padding; // 15 14 | u16 handshake_timeout; // 16 15 | u8 probe_count; // 18 16 | u8 client_data[MULTIBOOT_NCHILD]; // 19 17 | u8 palette_data; // 1c 18 | u8 response_bit; // 1d 19 | u8 client_bit; // 1e 20 | u8 reserved1; // 1f 21 | const u8 *boot_srcp; // 20 22 | const u8 *boot_endp; // 24 23 | const u8 *masterp; 24 | u8 *reserved2[MULTIBOOT_NCHILD]; 25 | u32 system_work2[4]; 26 | u8 sendflag; 27 | u8 probe_target_bit; 28 | u8 check_wait; 29 | u8 server_type; 30 | }; 31 | 32 | #define MULTIBOOT_ERROR_04 0x04 33 | #define MULTIBOOT_ERROR_08 0x08 34 | #define MULTIBOOT_ERROR_0c 0x0c 35 | #define MULTIBOOT_ERROR_40 0x40 36 | #define MULTIBOOT_ERROR_44 0x44 37 | #define MULTIBOOT_ERROR_48 0x48 38 | #define MULTIBOOT_ERROR_4c 0x4c 39 | #define MULTIBOOT_ERROR_80 0x80 40 | #define MULTIBOOT_ERROR_84 0x84 41 | #define MULTIBOOT_ERROR_88 0x88 42 | #define MULTIBOOT_ERROR_8c 0x8c 43 | #define MULTIBOOT_ERROR_NO_PROBE_TARGET 0x50 44 | #define MULTIBOOT_ERROR_NO_DLREADY 0x60 45 | #define MULTIBOOT_ERROR_BOOT_FAILURE 0x70 46 | #define MULTIBOOT_ERROR_HANDSHAKE_FAILURE 0x71 47 | 48 | #define MULTIBOOT_CONNECTION_CHECK_WAIT 15 49 | 50 | #define MULTIBOOT_SERVER_TYPE_NORMAL 0 51 | #define MULTIBOOT_SERVER_TYPE_QUICK 1 52 | 53 | #define MULTIBOOT_HANDSHAKE_TIMEOUT 400 54 | 55 | #endif // GUARD_GBA_MULTIBOOT_H 56 | -------------------------------------------------------------------------------- /tools/preproc/string_parser.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef STRING_PARSER_H 22 | #define STRING_PARSER_H 23 | 24 | #include 25 | #include 26 | #include "preproc.h" 27 | 28 | class StringParser 29 | { 30 | public: 31 | StringParser(char* buffer, long size) : m_buffer(buffer), m_size(size), m_pos(0) {} 32 | int ParseString(long srcPos, unsigned char* dest, int &destLength); 33 | 34 | private: 35 | struct Integer 36 | { 37 | std::uint32_t value; 38 | int size; 39 | }; 40 | 41 | char* m_buffer; 42 | long m_size; 43 | long m_pos; 44 | 45 | Integer ReadInteger(); 46 | Integer ReadDecimal(); 47 | Integer ReadHex(); 48 | std::string ReadCharOrEscape(); 49 | std::string ReadBracketedConstants(); 50 | void SkipWhitespace(); 51 | void SkipRestOfInteger(int radix); 52 | void RaiseError(const char* format, ...); 53 | }; 54 | 55 | #endif // STRING_PARSER_H 56 | -------------------------------------------------------------------------------- /payload/include/constants/pokemon.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_CONSTANTS_POKEMON_H 2 | #define GUARD_CONSTANTS_POKEMON_H 3 | 4 | #define MIN_LEVEL 1 5 | #define MAX_LEVEL 100 6 | 7 | #define MON_MALE 0x00 8 | #define MON_FEMALE 0xFE 9 | #define MON_GENDERLESS 0xFF 10 | 11 | #define TYPE_NORMAL 0x00 12 | #define TYPE_FIGHTING 0x01 13 | #define TYPE_FLYING 0x02 14 | #define TYPE_POISON 0x03 15 | #define TYPE_GROUND 0x04 16 | #define TYPE_ROCK 0x05 17 | #define TYPE_BUG 0x06 18 | #define TYPE_GHOST 0x07 19 | #define TYPE_STEEL 0x08 20 | #define TYPE_MYSTERY 0x09 21 | #define TYPE_FIRE 0x0a 22 | #define TYPE_WATER 0x0b 23 | #define TYPE_GRASS 0x0c 24 | #define TYPE_ELECTRIC 0x0d 25 | #define TYPE_PSYCHIC 0x0e 26 | #define TYPE_ICE 0x0f 27 | #define TYPE_DRAGON 0x10 28 | #define TYPE_DARK 0x11 29 | #define NUMBER_OF_MON_TYPES 0x12 30 | 31 | #define FRIENDSHIP_EVENT_GROW_LEVEL 0x0 32 | #define FRIENDSHIP_EVENT_VITAMIN 0x1 // unused 33 | #define FRIENDSHIP_EVENT_BATTLE_ITEM 0x2 // unused 34 | #define FRIENDSHIP_EVENT_LEAGUE_BATTLE 0x3 35 | #define FRIENDSHIP_EVENT_LEARN_TMHM 0x4 36 | #define FRIENDSHIP_EVENT_WALKING 0x5 37 | #define FRIENDSHIP_EVENT_FAINT_SMALL 0x6 38 | #define FRIENDSHIP_EVENT_FAINT_OUTSIDE_BATTLE 0x7 39 | #define FRIENDSHIP_EVENT_FAINT_LARGE 0x8 40 | 41 | #define STATUS_PRIMARY_NONE 0x0 42 | #define STATUS_PRIMARY_POISON 0x1 43 | #define STATUS_PRIMARY_PARALYSIS 0x2 44 | #define STATUS_PRIMARY_SLEEP 0x3 45 | #define STATUS_PRIMARY_FREEZE 0x4 46 | #define STATUS_PRIMARY_BURN 0x5 47 | #define STATUS_PRIMARY_POKERUS 0x6 48 | #define STATUS_PRIMARY_FAINTED 0x7 49 | 50 | #define MAX_TOTAL_EVS 510 51 | #define NUM_STATS 6 52 | #define UNOWN_FORM_COUNT 28 53 | 54 | #define MIN_STAT_STAGE 0 55 | #define DEFAULT_STAT_STAGE 6 56 | #define MAX_STAT_STAGE 12 57 | 58 | #define PLAYER_HAS_TWO_USABLE_MONS 0 59 | #define PLAYER_HAS_ONE_MON 1 60 | #define PLAYER_HAS_ONE_USABLE_MON 2 61 | 62 | #endif // GUARD_CONSTANTS_POKEMON_H 63 | -------------------------------------------------------------------------------- /payload/include/unk_200C5DC.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_unk_200C5DC_H 2 | #define GUARD_unk_200C5DC_H 3 | 4 | #define CONTINUE_GAME_WARP (1 << 0) 5 | #define POKECENTER_SAVEWARP (1 << 1) 6 | #define LOBBY_SAVEWARP (1 << 2) 7 | #define CHAMPION_SAVEWARP (1 << 7) 8 | 9 | #define LINK_CMD_RESET 0x00 10 | #define LINK_CMD_0x01 0x01 11 | #define LINK_CMD_TRAN_PLAYER_DATA2 0x04 12 | #define LINK_CMD_RECV_GIFT_DATA 0x22 13 | #define LINK_CMD_TRAN_GIFT_DATA 0x33 14 | #define LINK_CMD_0x44 0x44 15 | #define LINK_CMD_RECV_PARTY_MON 0x55 16 | #define LINK_CMD_SOFT_RESET_ROM 0x60 17 | #define LINK_CMD_SOFT_RESET 0x61 18 | #define LINK_CMD_RECV_MON_DATA 0x66 19 | #define LINK_CMD_RECV_UNKNOWN 0x77 20 | #define LINK_CMD_RECV_TEXT 0x88 21 | #define LINK_CMD_TRAN_PLAYER_DATA1 0x99 22 | #define LINK_CMD_READ_INPUT 0xAA 23 | 24 | struct TransferData 25 | { 26 | volatile u32 *data; 27 | u32 transferSize; 28 | u8 field8[2]; 29 | vu8 state; 30 | u8 field11; 31 | u8 field12; 32 | u8 field13; 33 | u8 field14; 34 | u8 field15; 35 | u8 field16; 36 | u8 currentCmd; 37 | u8 field18; 38 | u8 fill19; 39 | u8 field20; 40 | u8 fill21; 41 | u8 fill22; 42 | u8 fill23; 43 | u8 fill24; 44 | u8 fill25; 45 | u8 fill26; 46 | u8 fill27; 47 | u32 transferBytes; 48 | u32 gameCode; 49 | u32 field36; 50 | u32 lowerCaseGameCode; 51 | u32 gameCode2; 52 | u32 makerCode; 53 | }; 54 | 55 | extern volatile struct TransferData gTransferData; 56 | 57 | void SetSpeciesCaughtFlag(u32 species, struct Pokemon *mon); 58 | u8 GetPlayerMapType(void); 59 | u8 *GetTextBufferPointer(u32 id); 60 | struct PlayerLinkInfo *SetPlayerLinkInfo(u8 *sav2, u8 *sav1, u32 saveStatus); 61 | s32 StringCompare(const u8 *str1, const u8 *str2); 62 | u8 *StringCopy(u8 *dst, const u8 *src); 63 | u16 GetStringSizeHandleExtCtrlCodes(u8 *str); 64 | bool32 SetFlag(s32 flag); 65 | bool32 GetUnknownBoolean(void); 66 | 67 | #endif // GUARD_unk_200C5DC_H 68 | -------------------------------------------------------------------------------- /tools/scaninc/c_file.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2017 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef C_FILE_H 22 | #define C_FILE_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include "scaninc.h" 28 | 29 | class CFile 30 | { 31 | public: 32 | CFile(std::string path); 33 | ~CFile(); 34 | void FindIncbins(); 35 | const std::set& GetIncbins() { return m_incbins; } 36 | const std::set& GetIncludes() { return m_includes; } 37 | 38 | private: 39 | char *m_buffer; 40 | int m_pos; 41 | int m_size; 42 | int m_lineNum; 43 | std::string m_path; 44 | std::set m_incbins; 45 | std::set m_includes; 46 | 47 | bool ConsumeHorizontalWhitespace(); 48 | bool ConsumeNewline(); 49 | bool ConsumeComment(); 50 | void SkipWhitespace(); 51 | bool CheckIdentifier(const std::string& ident); 52 | void CheckInclude(); 53 | void CheckIncbin(); 54 | std::string ReadPath(); 55 | }; 56 | 57 | #endif // C_FILE_H 58 | -------------------------------------------------------------------------------- /tools/preproc/preproc.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef PREPROC_H 22 | #define PREPROC_H 23 | 24 | #include 25 | #include 26 | #include "charmap.h" 27 | 28 | #ifdef _MSC_VER 29 | 30 | #define FATAL_ERROR(format, ...) \ 31 | do \ 32 | { \ 33 | std::fprintf(stderr, format, __VA_ARGS__); \ 34 | std::exit(1); \ 35 | } while (0) 36 | 37 | #else 38 | 39 | #define FATAL_ERROR(format, ...) \ 40 | do \ 41 | { \ 42 | std::fprintf(stderr, format, ##__VA_ARGS__); \ 43 | std::exit(1); \ 44 | } while (0) 45 | 46 | #endif // _MSC_VER 47 | 48 | const int kMaxPath = 256; 49 | const int kMaxStringLength = 1024; 50 | const unsigned long kMaxCharmapSequenceLength = 16; 51 | 52 | extern Charmap* g_charmap; 53 | 54 | #endif // PREPROC_H 55 | -------------------------------------------------------------------------------- /payload/include/constants/items.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_CONSTANTS_ITEMS_H 2 | #define GUARD_CONSTANTS_ITEMS_H 3 | 4 | #define ITEM_NONE 0 5 | 6 | #define ITEM_MASTER_BALL 1 7 | #define ITEM_ULTRA_BALL 2 8 | #define ITEM_GREAT_BALL 3 9 | #define ITEM_POKE_BALL 4 10 | #define ITEM_SAFARI_BALL 5 11 | #define ITEM_NET_BALL 6 12 | #define ITEM_DIVE_BALL 7 13 | #define ITEM_NEST_BALL 8 14 | #define ITEM_REPEAT_BALL 9 15 | #define ITEM_TIMER_BALL 10 16 | #define ITEM_LUXURY_BALL 11 17 | #define ITEM_PREMIER_BALL 12 18 | 19 | #define ITEM_CHERI_BERRY 133 20 | #define ITEM_CHESTO_BERRY 134 21 | #define ITEM_PECHA_BERRY 135 22 | #define ITEM_RAWST_BERRY 136 23 | #define ITEM_ASPEAR_BERRY 137 24 | #define ITEM_LEPPA_BERRY 138 25 | #define ITEM_ORAN_BERRY 139 26 | #define ITEM_PERSIM_BERRY 140 27 | #define ITEM_LUM_BERRY 141 28 | #define ITEM_SITRUS_BERRY 142 29 | #define ITEM_FIGY_BERRY 143 30 | #define ITEM_WIKI_BERRY 144 31 | #define ITEM_MAGO_BERRY 145 32 | #define ITEM_AGUAV_BERRY 146 33 | #define ITEM_IAPAPA_BERRY 147 34 | #define ITEM_RAZZ_BERRY 148 35 | #define ITEM_BLUK_BERRY 149 36 | #define ITEM_NANAB_BERRY 150 37 | #define ITEM_WEPEAR_BERRY 151 38 | #define ITEM_PINAP_BERRY 152 39 | #define ITEM_POMEG_BERRY 153 40 | #define ITEM_KELPSY_BERRY 154 41 | #define ITEM_QUALOT_BERRY 155 42 | #define ITEM_HONDEW_BERRY 156 43 | #define ITEM_GREPA_BERRY 157 44 | #define ITEM_TAMATO_BERRY 158 45 | #define ITEM_CORNN_BERRY 159 46 | #define ITEM_MAGOST_BERRY 160 47 | #define ITEM_RABUTA_BERRY 161 48 | #define ITEM_NOMEL_BERRY 162 49 | #define ITEM_SPELON_BERRY 163 50 | #define ITEM_PAMTRE_BERRY 164 51 | #define ITEM_WATMEL_BERRY 165 52 | #define ITEM_DURIN_BERRY 166 53 | #define ITEM_BELUE_BERRY 167 54 | #define ITEM_LIECHI_BERRY 168 55 | #define ITEM_GANLON_BERRY 169 56 | #define ITEM_SALAC_BERRY 170 57 | #define ITEM_PETAYA_BERRY 171 58 | #define ITEM_APICOT_BERRY 172 59 | #define ITEM_LANSAT_BERRY 173 60 | #define ITEM_STARF_BERRY 174 61 | #define ITEM_ENIGMA_BERRY 175 62 | 63 | #define FIRST_BERRY_INDEX ITEM_CHERI_BERRY 64 | #define LAST_BERRY_INDEX ITEM_ENIGMA_BERRY 65 | 66 | #define ITEMS_COUNT 349 67 | 68 | #define ITEM_TO_BERRY(itemId)(((itemId) - FIRST_BERRY_INDEX) + 1) 69 | 70 | #endif // GUARD_CONSTANTS_BERRY_H 71 | -------------------------------------------------------------------------------- /tools/preproc/charmap.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef CHARMAP_H 22 | #define CHARMAP_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | class Charmap 30 | { 31 | public: 32 | Charmap(std::string filename); 33 | 34 | std::string Char(std::int32_t code) 35 | { 36 | auto it = m_chars.find(code); 37 | 38 | if (it == m_chars.end()) 39 | return std::string(); 40 | 41 | return it->second; 42 | } 43 | 44 | std::string Escape(unsigned char code) 45 | { 46 | return m_escapes[code]; 47 | } 48 | 49 | std::string Constant(std::string identifier) 50 | { 51 | auto it = m_constants.find(identifier); 52 | 53 | if (it == m_constants.end()) 54 | return std::string(); 55 | 56 | return it->second; 57 | } 58 | private: 59 | std::map m_chars; 60 | std::string m_escapes[128]; 61 | std::map m_constants; 62 | }; 63 | 64 | #endif // CHARMAP_H 65 | -------------------------------------------------------------------------------- /tools/preproc/c_file.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef C_FILE_H 22 | #define C_FILE_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "preproc.h" 29 | 30 | class CFile 31 | { 32 | public: 33 | CFile(std::string filename); 34 | CFile(CFile&& other); 35 | CFile(const CFile&) = delete; 36 | ~CFile(); 37 | void Preproc(); 38 | 39 | private: 40 | char* m_buffer; 41 | long m_pos; 42 | long m_size; 43 | long m_lineNum; 44 | std::string m_filename; 45 | 46 | bool ConsumeHorizontalWhitespace(); 47 | bool ConsumeNewline(); 48 | void SkipWhitespace(); 49 | void TryConvertString(); 50 | std::unique_ptr ReadWholeFile(const std::string& path, int& size); 51 | bool CheckIdentifier(const std::string& ident); 52 | void TryConvertIncbin(); 53 | void ReportDiagnostic(const char* type, const char* format, std::va_list args); 54 | void RaiseError(const char* format, ...); 55 | void RaiseWarning(const char* format, ...); 56 | }; 57 | 58 | #endif // C_FILE_H 59 | -------------------------------------------------------------------------------- /payload/src/agb_flash_1m.c: -------------------------------------------------------------------------------- 1 | #include "gba/gba.h" 2 | #include "gba/flash_internal.h" 3 | 4 | static const char AgbLibFlashVersion[] = "FLASH1M_V103"; 5 | 6 | const struct FlashSetupInfo * const sSetupInfos[] = 7 | { 8 | &MX29L010, 9 | &LE26FV10N1TS, 10 | &DefaultFlash 11 | }; 12 | 13 | u16 IdentifyFlash(void) 14 | { 15 | u16 result; 16 | u16 flashId; 17 | const struct FlashSetupInfo * const *setupInfo; 18 | 19 | REG_WAITCNT = (REG_WAITCNT & ~WAITCNT_SRAM_MASK) | WAITCNT_SRAM_8; 20 | 21 | flashId = ReadFlashId(); 22 | 23 | setupInfo = sSetupInfos; 24 | result = 1; 25 | 26 | for (;;) 27 | { 28 | if ((*setupInfo)->type.ids.separate.makerId == 0) 29 | break; 30 | 31 | if (flashId == (*setupInfo)->type.ids.joined) 32 | { 33 | result = 0; 34 | break; 35 | } 36 | 37 | setupInfo++; 38 | } 39 | 40 | ProgramFlashByte = (*setupInfo)->programFlashByte; 41 | ProgramFlashSector = (*setupInfo)->programFlashSector; 42 | EraseFlashChip = (*setupInfo)->eraseFlashChip; 43 | EraseFlashSector = (*setupInfo)->eraseFlashSector; 44 | WaitForFlashWrite = (*setupInfo)->WaitForFlashWrite; 45 | gFlashMaxTime = (*setupInfo)->maxTime; 46 | gFlash = &(*setupInfo)->type; 47 | 48 | return result; 49 | } 50 | 51 | u16 WaitForFlashWrite_Common(u8 phase, u8 *addr, u8 lastData) 52 | { 53 | u16 result = 0; 54 | u8 status; 55 | 56 | StartFlashTimer(phase); 57 | 58 | while ((status = PollFlashStatus(addr)) != lastData) 59 | { 60 | if (status & 0x20) 61 | { 62 | // The write operation exceeded the flash chip's time limit. 63 | 64 | if (PollFlashStatus(addr) == lastData) 65 | break; 66 | 67 | FLASH_WRITE(0x5555, 0xF0); 68 | result = phase | 0xA000u; 69 | break; 70 | } 71 | 72 | if (gFlashTimeoutFlag) 73 | { 74 | if (PollFlashStatus(addr) == lastData) 75 | break; 76 | 77 | FLASH_WRITE(0x5555, 0xF0); 78 | result = phase | 0xC000u; 79 | break; 80 | } 81 | } 82 | 83 | StopFlashTimer(); 84 | 85 | return result; 86 | } 87 | -------------------------------------------------------------------------------- /payload/include/gba/defines.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_DEFINES_H 2 | #define GUARD_GBA_DEFINES_H 3 | 4 | #include 5 | 6 | #define TRUE 1 7 | #define FALSE 0 8 | 9 | #define BSS_DATA __attribute__((section(".bss"))) 10 | #define IWRAM_DATA __attribute__((section("iwram_data"))) 11 | #define EWRAM_DATA __attribute__((section("ewram_data"))) 12 | #define NAKED __attribute__((naked)) 13 | #define UNUSED __attribute__((unused)) 14 | #define NO_RETURN __attribute__((noreturn)) 15 | 16 | #if MODERN 17 | #define NOINLINE __attribute__((noinline)) 18 | #else 19 | #define NOINLINE 20 | #endif 21 | 22 | #define ALIGNED(n) __attribute__((aligned(n))) 23 | 24 | #define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0) 25 | #define INTR_CHECK (*(u16 *)0x3007FF8) 26 | #define INTR_VECTOR (*(void **)0x3007FFC) 27 | 28 | #define EWRAM_START 0x02000000 29 | #define EWRAM_END (EWRAM_START + 0x40000) 30 | #define IWRAM_START 0x03000000 31 | #define IWRAM_END (IWRAM_START + 0x8000) 32 | 33 | #define PLTT 0x5000000 34 | #define PLTT_SIZE 0x400 35 | 36 | #define BG_PLTT PLTT 37 | #define BG_PLTT_SIZE 0x200 38 | 39 | #define OBJ_PLTT (PLTT + 0x200) 40 | #define OBJ_PLTT_SIZE 0x200 41 | 42 | #define VRAM 0x6000000 43 | #define VRAM_SIZE 0x18000 44 | 45 | #define BG_VRAM VRAM 46 | #define BG_VRAM_SIZE 0x10000 47 | #define BG_CHAR_SIZE 0x4000 48 | #define BG_SCREEN_SIZE 0x800 49 | #define BG_CHAR_ADDR(n) (BG_VRAM + (BG_CHAR_SIZE * (n))) 50 | #define BG_SCREEN_ADDR(n) (BG_VRAM + (BG_SCREEN_SIZE * (n))) 51 | 52 | #define BG_TILE_H_FLIP(n) (0x400 + (n)) 53 | #define BG_TILE_V_FLIP(n) (0x800 + (n)) 54 | 55 | #define NUM_BACKGROUNDS 4 56 | 57 | // text-mode BG 58 | #define OBJ_VRAM0 (VRAM + 0x10000) 59 | #define OBJ_VRAM0_SIZE 0x8000 60 | 61 | // bitmap-mode BG 62 | #define OBJ_VRAM1 (VRAM + 0x14000) 63 | #define OBJ_VRAM1_SIZE 0x4000 64 | 65 | #define OAM 0x7000000 66 | #define OAM_SIZE 0x400 67 | 68 | #define ROM_HEADER_SIZE 0xC0 69 | 70 | #define DISPLAY_WIDTH 240 71 | #define DISPLAY_HEIGHT 160 72 | 73 | #define TILE_SIZE_4BPP 32 74 | #define TILE_SIZE_8BPP 64 75 | 76 | #define TILE_OFFSET_4BPP(n) ((n) * TILE_SIZE_4BPP) 77 | #define TILE_OFFSET_8BPP(n) ((n) * TILE_SIZE_8BPP) 78 | 79 | #define TOTAL_OBJ_TILE_COUNT 1024 80 | 81 | #endif // GUARD_GBA_DEFINES_H 82 | -------------------------------------------------------------------------------- /asm/macros/map.inc: -------------------------------------------------------------------------------- 1 | .macro map map_id 2 | .byte \map_id >> 8 @ map group 3 | .byte \map_id & 0xFF @ map num 4 | .endm 5 | 6 | .macro map_script type, address 7 | .byte \type 8 | .4byte \address 9 | .endm 10 | 11 | .macro map_script_2 word1, word2, address 12 | .2byte \word1 13 | .2byte \word2 14 | .4byte \address 15 | .endm 16 | 17 | .macro object_event index:req, gfx:req, x:req, y:req, elevation:req, movement_type:req, x_radius:req, y_radius:req, trainer_type:req, sight_radius_tree_etc:req, script:req, event_flag:req 18 | .byte \index 19 | .2byte \gfx 20 | .byte 0 21 | .2byte \x, \y 22 | .byte \elevation, \movement_type, ((\y_radius << 4) | \x_radius), 0 23 | .2byte \trainer_type, \sight_radius_tree_etc 24 | .4byte \script 25 | .2byte \event_flag, 0 26 | inc _num_npcs 27 | .endm 28 | 29 | .macro warp_def x, y, byte, warp, map_id 30 | .2byte \x, \y 31 | .byte \byte, \warp 32 | .byte \map_id & 0xFF @ map num 33 | .byte \map_id >> 8 @ map group 34 | inc _num_warps 35 | .endm 36 | 37 | .macro coord_event x, y, byte1, byte2, word1, word2, word3, script 38 | .2byte \x, \y 39 | .byte \byte1, \byte2 40 | .2byte \word1, \word2, \word3 41 | .4byte \script 42 | inc _num_traps 43 | .endm 44 | 45 | .macro bg_event x, y, byte, kind, word, arg6, arg7, arg8 46 | .2byte \x, \y 47 | .byte \byte, \kind 48 | .2byte \word 49 | .if \kind < 5 50 | .4byte \arg6 51 | .else 52 | .2byte \arg6 53 | .byte \arg7, \arg8 54 | .endif 55 | inc _num_signs 56 | .endm 57 | 58 | .macro bg_hidden_item_event x, y, height, item, flag, unknown 59 | bg_event \x, \y, \height, 7, 0, \item, \flag, \unknown 60 | .endm 61 | 62 | .macro map_events npcs, warps, traps, signs 63 | .byte _num_npcs, _num_warps, _num_traps, _num_signs 64 | .4byte \npcs, \warps, \traps, \signs 65 | reset_map_events 66 | .endm 67 | 68 | .macro reset_map_events 69 | .set _num_npcs, 0 70 | .set _num_warps, 0 71 | .set _num_traps, 0 72 | .set _num_signs, 0 73 | .endm 74 | 75 | reset_map_events 76 | 77 | 78 | .equiv connection_down, 1 79 | .equiv connection_up, 2 80 | .equiv connection_left, 3 81 | .equiv connection_right, 4 82 | .equiv connection_dive, 5 83 | .equiv connection_emerge, 6 84 | 85 | .macro connection direction, offset, map, filler 86 | .4byte connection_\direction 87 | .4byte \offset 88 | map \map 89 | .space 2 90 | .endm 91 | -------------------------------------------------------------------------------- /payload/asm/macros/map.inc: -------------------------------------------------------------------------------- 1 | .macro map map_id 2 | .byte \map_id >> 8 @ map group 3 | .byte \map_id & 0xFF @ map num 4 | .endm 5 | 6 | .macro map_script type, address 7 | .byte \type 8 | .4byte \address 9 | .endm 10 | 11 | .macro map_script_2 word1, word2, address 12 | .2byte \word1 13 | .2byte \word2 14 | .4byte \address 15 | .endm 16 | 17 | .macro object_event index:req, gfx:req, x:req, y:req, elevation:req, movement_type:req, x_radius:req, y_radius:req, trainer_type:req, sight_radius_tree_etc:req, script:req, event_flag:req 18 | .byte \index 19 | .2byte \gfx 20 | .byte 0 21 | .2byte \x, \y 22 | .byte \elevation, \movement_type, ((\y_radius << 4) | \x_radius), 0 23 | .2byte \trainer_type, \sight_radius_tree_etc 24 | .4byte \script 25 | .2byte \event_flag, 0 26 | inc _num_npcs 27 | .endm 28 | 29 | .macro warp_def x, y, byte, warp, map_id 30 | .2byte \x, \y 31 | .byte \byte, \warp 32 | .byte \map_id & 0xFF @ map num 33 | .byte \map_id >> 8 @ map group 34 | inc _num_warps 35 | .endm 36 | 37 | .macro coord_event x, y, byte1, byte2, word1, word2, word3, script 38 | .2byte \x, \y 39 | .byte \byte1, \byte2 40 | .2byte \word1, \word2, \word3 41 | .4byte \script 42 | inc _num_traps 43 | .endm 44 | 45 | .macro bg_event x, y, byte, kind, word, arg6, arg7, arg8 46 | .2byte \x, \y 47 | .byte \byte, \kind 48 | .2byte \word 49 | .if \kind < 5 50 | .4byte \arg6 51 | .else 52 | .2byte \arg6 53 | .byte \arg7, \arg8 54 | .endif 55 | inc _num_signs 56 | .endm 57 | 58 | .macro bg_hidden_item_event x, y, height, item, flag, unknown 59 | bg_event \x, \y, \height, 7, 0, \item, \flag, \unknown 60 | .endm 61 | 62 | .macro map_events npcs, warps, traps, signs 63 | .byte _num_npcs, _num_warps, _num_traps, _num_signs 64 | .4byte \npcs, \warps, \traps, \signs 65 | reset_map_events 66 | .endm 67 | 68 | .macro reset_map_events 69 | .set _num_npcs, 0 70 | .set _num_warps, 0 71 | .set _num_traps, 0 72 | .set _num_signs, 0 73 | .endm 74 | 75 | reset_map_events 76 | 77 | 78 | .equiv connection_down, 1 79 | .equiv connection_up, 2 80 | .equiv connection_left, 3 81 | .equiv connection_right, 4 82 | .equiv connection_dive, 5 83 | .equiv connection_emerge, 6 84 | 85 | .macro connection direction, offset, map, filler 86 | .4byte connection_\direction 87 | .4byte \offset 88 | map \map 89 | .space 2 90 | .endm 91 | -------------------------------------------------------------------------------- /payload/src/gflib/sound.c: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | #include "gflib/sound.h" 3 | 4 | static bool8 sIsSoundVSyncPaused; 5 | static bool8 sIsSoundVsync; 6 | 7 | void InitSound(void) 8 | { 9 | sIsSoundVSyncPaused = 0; 10 | sIsSoundVsync = FALSE; 11 | m4aSoundInit(); 12 | } 13 | 14 | void PauseSoundVSync(void) 15 | { 16 | sIsSoundVSyncPaused = 1; 17 | sIsSoundVsync = FALSE; 18 | } 19 | 20 | bool32 EnableSoundVSync(u32 enable) 21 | { 22 | if (enable && sIsSoundVSyncPaused) 23 | sIsSoundVsync = TRUE; 24 | 25 | return sIsSoundVsync; 26 | } 27 | 28 | void PlaySE(u16 song) 29 | { 30 | struct MusicPlayerInfo * mPlayInfo; 31 | 32 | mPlayInfo = gMPlayTable[gSongTable[song].ms].info; 33 | MPlayStart(mPlayInfo, gSongTable[song].header); 34 | m4aMPlayImmInit(mPlayInfo); 35 | } 36 | 37 | void UNUSED StopSE(u16 song) 38 | { 39 | struct MusicPlayerInfo * mPlayInfo; 40 | 41 | mPlayInfo = gMPlayTable[gSongTable[song].ms].info; 42 | m4aMPlayStop(mPlayInfo); 43 | } 44 | 45 | void UNUSED StopAllSound(void) 46 | { 47 | m4aMPlayAllStop(); 48 | } 49 | 50 | bool8 UNUSED ReturnTrue(void) 51 | { 52 | return TRUE; 53 | } 54 | 55 | void UNUSED FadeOutSE(u16 song, u16 _speed) 56 | { 57 | struct MusicPlayerInfo * mPlayInfo; 58 | u16 speed = _speed >> 4; 59 | 60 | if (speed == 0) 61 | speed = 1; 62 | 63 | mPlayInfo = gMPlayTable[gSongTable[song].ms].info; 64 | m4aMPlayFadeOut(mPlayInfo, speed); 65 | } 66 | 67 | void UNUSED SetSEVolume(u16 song, u16 volume) 68 | { 69 | struct MusicPlayerInfo * mPlayInfo; 70 | 71 | mPlayInfo = gMPlayTable[gSongTable[song].ms].info; 72 | m4aMPlayVolumeControl(mPlayInfo, 0xFF, volume); 73 | } 74 | 75 | void UNUSED SetSETempo(u16 song, u16 tempo) 76 | { 77 | struct MusicPlayerInfo * mPlayInfo; 78 | 79 | mPlayInfo = gMPlayTable[gSongTable[song].ms].info; 80 | m4aMPlayTempoControl(mPlayInfo, tempo); 81 | } 82 | 83 | void UNUSED SetSEPitch(u16 song, s16 pitch) 84 | { 85 | struct MusicPlayerInfo * mPlayInfo; 86 | 87 | mPlayInfo = gMPlayTable[gSongTable[song].ms].info; 88 | m4aMPlayPitchControl(mPlayInfo, 0xFF, pitch); 89 | } 90 | 91 | void SoundVSyncOff(void) 92 | { 93 | sIsSoundVsync = FALSE; 94 | m4aSoundVSyncOff(); 95 | } 96 | 97 | void SoundVSyncOn(void) 98 | { 99 | m4aSoundVSyncOn(); 100 | sIsSoundVsync = TRUE; 101 | } 102 | -------------------------------------------------------------------------------- /tools/ramscrgen/char_util.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef CHAR_UTIL_H 22 | #define CHAR_UTIL_H 23 | 24 | #include 25 | #include 26 | 27 | inline bool IsAscii(unsigned char c) 28 | { 29 | return (c < 128); 30 | } 31 | 32 | inline bool IsAsciiAlpha(unsigned char c) 33 | { 34 | return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); 35 | } 36 | 37 | inline bool IsAsciiDigit(unsigned char c) 38 | { 39 | return (c >= '0' && c <= '9'); 40 | } 41 | 42 | inline bool IsAsciiHexDigit(unsigned char c) 43 | { 44 | return ((c >= '0' && c <= '9') 45 | || (c >= 'a' && c <= 'f') 46 | || (c >= 'A' && c <= 'F')); 47 | } 48 | 49 | inline bool IsAsciiAlphanum(unsigned char c) 50 | { 51 | return (IsAsciiAlpha(c) || IsAsciiDigit(c)); 52 | } 53 | 54 | inline bool IsAsciiPrintable(unsigned char c) 55 | { 56 | return (c >= ' ' && c <= '~'); 57 | } 58 | 59 | // Returns whether the character can start the identifier of a "{FOO}" constant in strings. 60 | inline bool IsIdentifierStartingChar(unsigned char c) 61 | { 62 | return IsAsciiAlpha(c) || c == '_'; 63 | } 64 | 65 | // Returns whether the character can be used in the identifier of a "{FOO}" constant in strings. 66 | inline bool IsIdentifierChar(unsigned char c) 67 | { 68 | return IsAsciiAlphanum(c) || c == '_'; 69 | } 70 | 71 | #endif // CHAR_UTIL_H 72 | -------------------------------------------------------------------------------- /tools/ramscrgen/sym_file.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef SYM_FILE_H 22 | #define SYM_FILE_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include "ramscrgen.h" 28 | 29 | enum class Directive 30 | { 31 | Include, 32 | Space, 33 | Align, 34 | Unknown 35 | }; 36 | 37 | class SymFile 38 | { 39 | public: 40 | SymFile(std::string filename); 41 | SymFile(SymFile&& other); 42 | SymFile(const SymFile&) = delete; 43 | ~SymFile(); 44 | Directive GetDirective(); 45 | std::string GetLabel(bool requireColon = true); 46 | std::string ReadPath(); 47 | bool ReadInteger(unsigned long& value); 48 | void ExpectEmptyRestOfLine(); 49 | void SkipLine(); 50 | bool IsAtEnd(); 51 | void HandleLangConditional(std::string lang); 52 | void RaiseError(const char* format, ...); 53 | void RaiseWarning(const char* format, ...); 54 | 55 | private: 56 | char* m_buffer; 57 | long m_pos; 58 | long m_size; 59 | long m_lineNum; 60 | long m_lineStart; 61 | std::string m_filename; 62 | bool m_inLangConditional; 63 | 64 | bool ConsumeComma(); 65 | void RemoveComments(); 66 | bool CheckForDirective(std::string name); 67 | void SkipWhitespace(); 68 | void ReportDiagnostic(const char* type, const char* format, std::va_list args); 69 | }; 70 | 71 | #endif // SYM_FILE_H 72 | -------------------------------------------------------------------------------- /tools/preproc/char_util.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef CHAR_UTIL_H 22 | #define CHAR_UTIL_H 23 | 24 | #include 25 | #include 26 | 27 | inline bool IsAscii(unsigned char c) 28 | { 29 | return (c < 128); 30 | } 31 | 32 | inline bool IsAsciiAlpha(unsigned char c) 33 | { 34 | return ((c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z')); 35 | } 36 | 37 | inline bool IsAsciiDigit(unsigned char c) 38 | { 39 | return (c >= '0' && c <= '9'); 40 | } 41 | 42 | inline bool IsAsciiHexDigit(unsigned char c) 43 | { 44 | return ((c >= '0' && c <= '9') 45 | || (c >= 'a' && c <= 'f') 46 | || (c >= 'A' && c <= 'F')); 47 | } 48 | 49 | inline bool IsAsciiAlphanum(unsigned char c) 50 | { 51 | return (IsAsciiAlpha(c) || IsAsciiDigit(c)); 52 | } 53 | 54 | inline bool IsAsciiPrintable(unsigned char c) 55 | { 56 | return (c >= ' ' && c <= '~'); 57 | } 58 | 59 | // Returns whether the character can start a C identifier or the identifier of a "{FOO}" constant in strings. 60 | inline bool IsIdentifierStartingChar(unsigned char c) 61 | { 62 | return IsAsciiAlpha(c) || c == '_'; 63 | } 64 | 65 | // Returns whether the character can be used in a C identifier or the identifier of a "{FOO}" constant in strings. 66 | inline bool IsIdentifierChar(unsigned char c) 67 | { 68 | return IsAsciiAlphanum(c) || c == '_'; 69 | } 70 | 71 | #endif // CHAR_UTIL_H 72 | -------------------------------------------------------------------------------- /tools/scaninc/source_file.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2019 Phlosioneer 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef SOURCE_FILE_H 22 | #define SOURCE_FILE_H 23 | 24 | #include 25 | #include "scaninc.h" 26 | #include "asm_file.h" 27 | #include "c_file.h" 28 | 29 | enum class SourceFileType 30 | { 31 | Cpp, 32 | Header, 33 | Asm, 34 | Inc 35 | }; 36 | 37 | SourceFileType GetFileType(std::string& path); 38 | 39 | class SourceFile 40 | { 41 | public: 42 | 43 | SourceFile(std::string path); 44 | ~SourceFile(); 45 | SourceFile(SourceFile const&) = delete; 46 | SourceFile(SourceFile&&) = delete; 47 | SourceFile& operator =(SourceFile const&) = delete; 48 | SourceFile& operator =(SourceFile&&) = delete; 49 | bool HasIncbins(); 50 | const std::set& GetIncbins(); 51 | const std::set& GetIncludes(); 52 | std::string& GetSrcDir(); 53 | SourceFileType FileType(); 54 | 55 | private: 56 | union InnerUnion { 57 | CFile c_file; 58 | struct AsmWrapper { 59 | std::set asm_incbins; 60 | std::set asm_includes; 61 | } asm_wrapper; 62 | 63 | // Construction and destruction handled by SourceFile. 64 | InnerUnion() {}; 65 | ~InnerUnion() {}; 66 | } m_source_file; 67 | SourceFileType m_file_type; 68 | std::string m_src_dir; 69 | }; 70 | 71 | #endif // SOURCE_FILE_H 72 | 73 | -------------------------------------------------------------------------------- /tools/preproc/asm_file.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef ASM_FILE_H 22 | #define ASM_FILE_H 23 | 24 | #include 25 | #include 26 | #include 27 | #include "preproc.h" 28 | 29 | enum class Directive 30 | { 31 | Include, 32 | String, 33 | Braille, 34 | Unknown 35 | }; 36 | 37 | class AsmFile 38 | { 39 | public: 40 | AsmFile(std::string filename); 41 | AsmFile(AsmFile&& other); 42 | AsmFile(const AsmFile&) = delete; 43 | ~AsmFile(); 44 | Directive GetDirective(); 45 | std::string GetGlobalLabel(); 46 | std::string ReadPath(); 47 | int ReadString(unsigned char* s); 48 | int ReadBraille(unsigned char* s); 49 | bool IsAtEnd(); 50 | void OutputLine(); 51 | void OutputLocation(); 52 | 53 | private: 54 | char* m_buffer; 55 | long m_pos; 56 | long m_size; 57 | long m_lineNum; 58 | long m_lineStart; 59 | std::string m_filename; 60 | 61 | bool ConsumeComma(); 62 | int ReadPadLength(); 63 | int ReadPadValue(); 64 | void RemoveComments(); 65 | bool CheckForDirective(std::string name); 66 | void SkipWhitespace(); 67 | void ExpectEmptyRestOfLine(); 68 | void ReportDiagnostic(const char* type, const char* format, std::va_list args); 69 | void RaiseError(const char* format, ...); 70 | void RaiseWarning(const char* format, ...); 71 | }; 72 | 73 | #endif // ASM_FILE_H 74 | -------------------------------------------------------------------------------- /include/gba/flash_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_FLASH_INTERNAL_H 2 | #define GUARD_GBA_FLASH_INTERNAL_H 3 | 4 | #define FLASH_BASE ((u8 *)0xE000000) 5 | 6 | #define FLASH_WRITE(addr, data) ((*(vu8 *)(FLASH_BASE + (addr))) = (data)) 7 | 8 | #define FLASH_ROM_SIZE_1M 131072 // 1 megabit ROM 9 | 10 | #define SECTORS_PER_BANK 16 11 | 12 | struct FlashSector 13 | { 14 | u32 size; 15 | u8 shift; 16 | u16 count; 17 | u16 top; 18 | }; 19 | 20 | struct FlashType { 21 | u32 romSize; 22 | struct FlashSector sector; 23 | u16 wait[2]; // game pak bus read/write wait 24 | 25 | // TODO: add support for anonymous unions/structs if possible 26 | union { 27 | struct { 28 | u8 makerId; 29 | u8 deviceId; 30 | } separate; 31 | u16 joined; 32 | } ids; 33 | }; 34 | 35 | struct FlashSetupInfo 36 | { 37 | u16 (*programFlashByte)(u16, u32, u8); 38 | u16 (*programFlashSector)(u16, void *); 39 | u16 (*eraseFlashChip)(void); 40 | u16 (*eraseFlashSector)(u16); 41 | u16 (*WaitForFlashWrite)(u8, u8 *, u8); 42 | const u16 *maxTime; 43 | struct FlashType type; 44 | }; 45 | 46 | extern u16 gFlashNumRemainingBytes; 47 | 48 | extern u16 (*ProgramFlashByte)(u16, u32, u8); 49 | extern u16 (*ProgramFlashSector)(u16, void *); 50 | extern u16 (*EraseFlashChip)(void); 51 | extern u16 (*EraseFlashSector)(u16); 52 | extern u16 (*WaitForFlashWrite)(u8, u8 *, u8); 53 | extern const u16 *gFlashMaxTime; 54 | extern const struct FlashType *gFlash; 55 | 56 | extern u8 (*PollFlashStatus)(u8 *); 57 | extern u8 gFlashTimeoutFlag; 58 | 59 | extern const struct FlashSetupInfo MX29L010; 60 | extern const struct FlashSetupInfo LE26FV10N1TS; 61 | extern const struct FlashSetupInfo DefaultFlash; 62 | 63 | void SwitchFlashBank(u8 bankNum); 64 | u16 ReadFlashId(void); 65 | void StartFlashTimer(u8 phase); 66 | void SetReadFlash1(u16 *dest); 67 | void StopFlashTimer(void); 68 | u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void)); 69 | u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src); 70 | void ReadFlash(u16 sectorNum, u32 offset, void *dest, u32 size); 71 | u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, void *dataSrc, u32 n); 72 | 73 | u16 WaitForFlashWrite_Common(u8 phase, u8 *addr, u8 lastData); 74 | 75 | u16 EraseFlashChip_MX(void); 76 | u16 EraseFlashSector_MX(u16 sectorNum); 77 | u16 ProgramFlashByte_MX(u16 sectorNum, u32 offset, u8 data); 78 | u16 ProgramFlashSector_MX(u16 sectorNum, void *src); 79 | 80 | // agb_flash_1m 81 | u16 IdentifyFlash(void); 82 | 83 | #endif // GUARD_GBA_FLASH_INTERNAL_H 84 | -------------------------------------------------------------------------------- /payload/include/gba/flash_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_GBA_FLASH_INTERNAL_H 2 | #define GUARD_GBA_FLASH_INTERNAL_H 3 | 4 | #define FLASH_BASE ((u8 *)0xE000000) 5 | 6 | #define FLASH_WRITE(addr, data) ((*(vu8 *)(FLASH_BASE + (addr))) = (data)) 7 | 8 | #define FLASH_ROM_SIZE_1M 131072 // 1 megabit ROM 9 | 10 | #define SECTORS_PER_BANK 16 11 | 12 | struct FlashSector 13 | { 14 | u32 size; 15 | u8 shift; 16 | u16 count; 17 | u16 top; 18 | }; 19 | 20 | struct FlashType { 21 | u32 romSize; 22 | struct FlashSector sector; 23 | u16 wait[2]; // game pak bus read/write wait 24 | 25 | // TODO: add support for anonymous unions/structs if possible 26 | union { 27 | struct { 28 | u8 makerId; 29 | u8 deviceId; 30 | } separate; 31 | u16 joined; 32 | } ids; 33 | }; 34 | 35 | struct FlashSetupInfo 36 | { 37 | u16 (*programFlashByte)(u16, u32, u8); 38 | u16 (*programFlashSector)(u16, void *); 39 | u16 (*eraseFlashChip)(void); 40 | u16 (*eraseFlashSector)(u16); 41 | u16 (*WaitForFlashWrite)(u8, u8 *, u8); 42 | const u16 *maxTime; 43 | struct FlashType type; 44 | }; 45 | 46 | extern u16 gFlashNumRemainingBytes; 47 | 48 | extern u16 (*ProgramFlashByte)(u16, u32, u8); 49 | extern u16 (*ProgramFlashSector)(u16, void *); 50 | extern u16 (*EraseFlashChip)(void); 51 | extern u16 (*EraseFlashSector)(u16); 52 | extern u16 (*WaitForFlashWrite)(u8, u8 *, u8); 53 | extern const u16 *gFlashMaxTime; 54 | extern const struct FlashType *gFlash; 55 | 56 | extern u8 (*PollFlashStatus)(u8 *); 57 | extern u8 gFlashTimeoutFlag; 58 | 59 | extern const struct FlashSetupInfo MX29L010; 60 | extern const struct FlashSetupInfo LE26FV10N1TS; 61 | extern const struct FlashSetupInfo DefaultFlash; 62 | 63 | void SwitchFlashBank(u8 bankNum); 64 | u16 ReadFlashId(void); 65 | void StartFlashTimer(u8 phase); 66 | void SetReadFlash1(u16 *dest); 67 | void StopFlashTimer(void); 68 | u16 SetFlashTimerIntr(u8 timerNum, void (**intrFunc)(void)); 69 | u32 ProgramFlashSectorAndVerify(u16 sectorNum, u8 *src); 70 | void ReadFlash(u16 sectorNum, u32 offset, void *dest, u32 size); 71 | u32 ProgramFlashSectorAndVerifyNBytes(u16 sectorNum, void *dataSrc, u32 n); 72 | 73 | u16 WaitForFlashWrite_Common(u8 phase, u8 *addr, u8 lastData); 74 | 75 | u16 EraseFlashChip_MX(void); 76 | u16 EraseFlashSector_MX(u16 sectorNum); 77 | u16 ProgramFlashByte_MX(u16 sectorNum, u32 offset, u8 data); 78 | u16 ProgramFlashSector_MX(u16 sectorNum, void *src); 79 | 80 | // agb_flash_1m 81 | u16 IdentifyFlash(void); 82 | 83 | #endif // GUARD_GBA_FLASH_INTERNAL_H 84 | -------------------------------------------------------------------------------- /tools/scaninc/scaninc.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2015-2017 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef SCANINC_H 22 | #define SCANINC_H 23 | 24 | #include 25 | #include 26 | 27 | #ifdef _MSC_VER 28 | 29 | #define FATAL_INPUT_ERROR(format, ...) \ 30 | do { \ 31 | fprintf(stderr, "%s:%d " format, m_path.c_str(), m_lineNum, __VA_ARGS__); \ 32 | exit(1); \ 33 | } while (0) 34 | 35 | #define FATAL_ERROR(format, ...) \ 36 | do { \ 37 | fprintf(stderr, format, __VA_ARGS__); \ 38 | exit(1); \ 39 | } while (0) 40 | 41 | #else 42 | 43 | #define FATAL_INPUT_ERROR(format, ...) \ 44 | do { \ 45 | fprintf(stderr, "%s:%d " format, m_path.c_str(), m_lineNum, ##__VA_ARGS__); \ 46 | exit(1); \ 47 | } while (0) 48 | 49 | #define FATAL_ERROR(format, ...) \ 50 | do { \ 51 | fprintf(stderr, format, ##__VA_ARGS__); \ 52 | exit(1); \ 53 | } while (0) 54 | 55 | #endif // _MSC_VER 56 | 57 | #define SCANINC_MAX_PATH 255 58 | 59 | #endif // SCANINC_H 60 | -------------------------------------------------------------------------------- /payload/src/gflib/init.c: -------------------------------------------------------------------------------- 1 | #include "global.h" 2 | #include "gflib/init.h" 3 | #include "gflib/bg.h" 4 | #include "gflib/sprite.h" 5 | #include "gflib/keys.h" 6 | #include "gflib/sound.h" 7 | 8 | extern void GF_Main(void); 9 | 10 | extern char bss_start[], bss_end[]; 11 | 12 | IntrFunc gIntrTable[14u]; 13 | u32 gVBlankCounter; 14 | IntrFunc gVBlankCallback; 15 | 16 | static void InitIntr(void); 17 | static void VBlankIntr(void); 18 | static void IntrDummy(void); 19 | 20 | #define SR_KEYS (A_BUTTON | B_BUTTON | SELECT_BUTTON | START_BUTTON) 21 | 22 | void AgbMain(void) 23 | { 24 | REG_IME = 0; 25 | RegisterRamReset(RESET_ALL & ~(RESET_EWRAM | RESET_IWRAM)); 26 | CpuFill16(0, bss_start, bss_end - bss_start); 27 | REG_WAITCNT = WAITCNT_SRAM_4 | WAITCNT_WS0_N_3 | WAITCNT_WS0_S_1 | WAITCNT_WS1_N_3 | WAITCNT_WS1_S_1 | WAITCNT_WS2_N_3 | WAITCNT_WS2_S_1 | WAITCNT_PREFETCH_ENABLE; 28 | InitIntr(); 29 | ResetGpuBuffers(); 30 | ResetSprites(); 31 | GF_Main(); 32 | SoftReset(RESET_ALL); 33 | } 34 | 35 | u32 GetFrameTotal(void) 36 | { 37 | return gVBlankCounter; 38 | } 39 | 40 | void DelayFrames(u32 frames) 41 | { 42 | for (; frames != 0; frames--) 43 | { 44 | UpdateSprites(); 45 | VBlankIntrWait(); 46 | ReadKeys(); 47 | if (TEST_BUTTON(gHeldKeys, SR_KEYS) == SR_KEYS) 48 | SoftReset(0); 49 | } 50 | } 51 | 52 | static void InitIntr(void) 53 | { 54 | u32 i; 55 | 56 | gVBlankCallback = NULL; 57 | 58 | for (i = 0; i < 14u; i++) 59 | gIntrTable[i] = IntrDummy; 60 | 61 | if (VBlankIntr != NULL) 62 | gIntrTable[1] = VBlankIntr; 63 | else 64 | gIntrTable[1] = IntrDummy; 65 | } 66 | 67 | void SetIntrFunc(u32 i, IntrFunc func) 68 | { 69 | if (func != NULL) 70 | gIntrTable[i] = func; 71 | else 72 | gIntrTable[i] = IntrDummy; 73 | } 74 | 75 | void SetVBlankCallback(IntrFunc cb) 76 | { 77 | u16 imeBak = REG_IME; 78 | REG_IME = 0; 79 | gVBlankCallback = cb; 80 | REG_IME = imeBak; 81 | } 82 | 83 | static void VBlankIntr(void) 84 | { 85 | if (EnableSoundVSync(0)) 86 | m4aSoundVSync(); 87 | 88 | DoOamBufferTransfer(); 89 | DoGpuUpdateAndTilemapTransfers(); 90 | gVBlankCounter++; 91 | INTR_CHECK = INTR_FLAG_VBLANK; 92 | 93 | if (gVBlankCallback != NULL) 94 | gVBlankCallback(); 95 | 96 | if (EnableSoundVSync(1)) 97 | m4aSoundMain(); 98 | } 99 | 100 | static void IntrDummy(void) 101 | { 102 | 103 | } 104 | -------------------------------------------------------------------------------- /payload/sym_common.txt: -------------------------------------------------------------------------------- 1 | 2 | gSaveStatus: 3 | .space 0x4 4 | 5 | gUnknown_020217B8: 6 | .space 0x8 7 | 8 | gStringBuffers: 9 | .space 0xa0 10 | 11 | gUnknown_02021860: 12 | .space 0x125 13 | 14 | gUnknown_02021985: 15 | .space 0xb 16 | 17 | gMonSummaryScreen: 18 | .space 0x54 19 | 20 | gMessageWindowPtr: 21 | .space 0xc 22 | 23 | gUnknown_020219F0: 24 | .space 0x10 25 | 26 | gUnknown_02021A00: 27 | .space 0x20 28 | 29 | gUnknown_02021A20: 30 | .space 0x20 31 | 32 | .include "m4a.o" 33 | .include "gflib/init.o" 34 | .include "gflib/bg.o" 35 | 36 | @ gflib/text.o 37 | gWindows: 38 | .space 0x280 @ 20 * 32 39 | 40 | .include "gflib/keys.o" 41 | 42 | @ gflib/agb_rom.o 43 | gPcItemsPtr: 44 | .space 0x4 45 | 46 | gPokemonStoragePtr: 47 | .space 0x4 48 | 49 | gSaveBlock1BakPtr: 50 | .space 0x4 51 | 52 | gPokedexPtr: 53 | .space 0x4 54 | 55 | gSaveBlock1Ptr: 56 | .space 0x4 57 | 58 | gSaveRngValue: 59 | .space 0x4 60 | 61 | gFlagsPtr: 62 | .space 0x4 63 | 64 | gSaveBlock2Ptr: 65 | .space 0x4 66 | 67 | gGiftRibbonsPtr: 68 | .space 0x4 69 | 70 | gDexSeen3Ptr: 71 | .space 0x4 72 | 73 | gVarsPtr: 74 | .space 0x4 75 | 76 | gEnigmaBerryPtr: 77 | .space 0x4 78 | 79 | gPlayerPartyBakPtr: 80 | .space 0x4 81 | 82 | gPlayerPartyCountPtr: 83 | .space 0x4 84 | 85 | gPlayerPartyPtr: 86 | .space 0x4 87 | 88 | gDexSeen2Ptr: 89 | .space 0x4 90 | 91 | gLastSaveBlockPtr: 92 | .space 0x4 93 | 94 | @ gflib/save.o 95 | gLastWrittenSector: 96 | .space 0x4 97 | 98 | gLastSaveCounter: 99 | .space 0xc 100 | 101 | gSaveStatusFlags: 102 | .space 0x14 103 | 104 | gLastKnownGoodSector: 105 | .space 0x4 106 | 107 | gDamagedSaveSectors: 108 | .space 0x4 109 | 110 | gSaveCounter: 111 | .space 0x4 112 | 113 | gReadWriteSector: 114 | .space 0x10 115 | 116 | gSaveReadBuffer: 117 | .space 0x1000 118 | 119 | gIncrementalSectorId: 120 | .space 0x10 121 | 122 | @ gflib/trade.o 123 | /* 124 | struct { 125 | u32 flags; 126 | u8 name[8]; 127 | u32 gender; 128 | u8 trainerId[4]; 129 | struct Pokemon party[6]; 130 | u8 giftRibbons[11]; 131 | }; 132 | */ 133 | gPlayerLinkInfo: 134 | .space 0x278 135 | 136 | .align 4 137 | gTextBuffer: 138 | .space 0x780 @ 6 * 320 139 | 140 | gUnknownBoolean: 141 | .space 0x10 142 | 143 | gMonLinkData: 144 | .space 0x884 145 | 146 | gRomDetection_IsEnglishROM: 147 | .space 0x4 148 | 149 | gAgbPmRomParams: 150 | .space 0x4 151 | 152 | gRomDetection_IsRubySapphire: 153 | .space 0x4 154 | 155 | gTransferData: 156 | .space 0x34 157 | 158 | .include "agb_flash.o" 159 | .include "berry_fix.o" 160 | -------------------------------------------------------------------------------- /tools/mid2agb/midi.h: -------------------------------------------------------------------------------- 1 | // Copyright(c) 2016 YamaArashi 2 | // 3 | // Permission is hereby granted, free of charge, to any person obtaining a copy 4 | // of this software and associated documentation files (the "Software"), to deal 5 | // in the Software without restriction, including without limitation the rights 6 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | // copies of the Software, and to permit persons to whom the Software is 8 | // furnished to do so, subject to the following conditions: 9 | // 10 | // The above copyright notice and this permission notice shall be included in 11 | // all copies or substantial portions of the Software. 12 | // 13 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | // THE SOFTWARE. 20 | 21 | #ifndef MIDI_H 22 | #define MIDI_H 23 | 24 | #include 25 | 26 | enum class MidiFormat 27 | { 28 | SingleTrack, 29 | MultiTrack 30 | }; 31 | 32 | enum class EventType 33 | { 34 | EndOfTie = 0x01, 35 | Label = 0x11, 36 | LoopEnd = 0x12, 37 | LoopEndBegin = 0x13, 38 | LoopBegin = 0x14, 39 | OriginalTimeSignature = 0x15, 40 | WholeNoteMark = 0x16, 41 | Pattern = 0x17, 42 | TimeSignature = 0x18, 43 | Tempo = 0x19, 44 | InstrumentChange = 0x21, 45 | Controller = 0x22, 46 | PitchBend = 0x23, 47 | KeyShift = 0x31, 48 | Note = 0x40, 49 | TimeSplit = 0xFE, 50 | EndOfTrack = 0xFF, 51 | }; 52 | 53 | struct Event 54 | { 55 | std::int32_t time; 56 | EventType type; 57 | std::uint8_t note; 58 | std::uint8_t param1; 59 | std::int32_t param2; 60 | 61 | bool operator==(const Event& other) 62 | { 63 | return (time == other.time 64 | && type == other.type 65 | && note == other.note 66 | && param1 == other.param1 67 | && param2 == other.param2); 68 | } 69 | 70 | bool operator!=(const Event& other) 71 | { 72 | return !(*this == other); 73 | } 74 | }; 75 | 76 | void ReadMidiFileHeader(); 77 | void ReadMidiTracks(); 78 | 79 | extern int g_midiChan; 80 | extern std::int32_t g_initialWait; 81 | 82 | inline bool IsPatternBoundary(EventType type) 83 | { 84 | return type == EventType::EndOfTrack || (int)type <= 0x17; 85 | } 86 | 87 | #endif // MIDI_H 88 | -------------------------------------------------------------------------------- /payload/include/constants/game_stat.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_CONSTANTS_GAME_STAT_H 2 | #define GUARD_CONSTANTS_GAME_STAT_H 3 | 4 | #define GAME_STAT_SAVED_GAME 0 5 | #define GAME_STAT_FIRST_HOF_PLAY_TIME 1 6 | #define GAME_STAT_STARTED_TRENDS 2 7 | #define GAME_STAT_PLANTED_BERRIES 3 8 | #define GAME_STAT_TRADED_BIKES 4 9 | #define GAME_STAT_STEPS 5 10 | #define GAME_STAT_GOT_INTERVIEWED 6 11 | #define GAME_STAT_TOTAL_BATTLES 7 12 | #define GAME_STAT_WILD_BATTLES 8 13 | #define GAME_STAT_TRAINER_BATTLES 9 14 | #define GAME_STAT_ENTERED_HOF 10 15 | #define GAME_STAT_POKEMON_CAPTURES 11 16 | #define GAME_STAT_FISHING_CAPTURES 12 17 | #define GAME_STAT_HATCHED_EGGS 13 18 | #define GAME_STAT_EVOLVED_POKEMON 14 19 | #define GAME_STAT_USED_POKECENTER 15 20 | #define GAME_STAT_RESTED_AT_HOME 16 21 | #define GAME_STAT_ENTERED_SAFARI_ZONE 17 22 | #define GAME_STAT_USED_CUT 18 23 | #define GAME_STAT_USED_ROCK_SMASH 19 24 | #define GAME_STAT_MOVED_SECRET_BASE 20 25 | #define GAME_STAT_POKEMON_TRADES 21 26 | #define GAME_STAT_UNKNOWN_22 22 27 | #define GAME_STAT_LINK_BATTLE_WINS 23 28 | #define GAME_STAT_LINK_BATTLE_LOSSES 24 29 | #define GAME_STAT_LINK_BATTLE_DRAWS 25 30 | #define GAME_STAT_USED_SPLASH 26 31 | #define GAME_STAT_USED_STRUGGLE 27 32 | #define GAME_STAT_SLOT_JACKPOTS 28 33 | #define GAME_STAT_CONSECUTIVE_ROULETTE_WINS 29 34 | #define GAME_STAT_ENTERED_BATTLE_TOWER 30 35 | #define GAME_STAT_UNKNOWN_31 31 36 | #define GAME_STAT_BATTLE_TOWER_BEST_STREAK 32 37 | #define GAME_STAT_POKEBLOCKS 33 38 | #define GAME_STAT_POKEBLOCKS_WITH_FRIENDS 34 39 | #define GAME_STAT_WON_LINK_CONTEST 35 40 | #define GAME_STAT_ENTERED_CONTEST 36 41 | #define GAME_STAT_WON_CONTEST 37 42 | #define GAME_STAT_SHOPPED 38 43 | #define GAME_STAT_USED_ITEMFINDER 39 44 | #define GAME_STAT_GOT_RAINED_ON 40 45 | #define GAME_STAT_CHECKED_POKEDEX 41 46 | #define GAME_STAT_RECEIVED_RIBBONS 42 47 | #define GAME_STAT_JUMPED_DOWN_LEDGES 43 48 | #define GAME_STAT_WATCHED_TV 44 49 | #define GAME_STAT_CHECKED_CLOCK 45 50 | #define GAME_STAT_WON_POKEMON_LOTTERY 46 51 | #define GAME_STAT_USED_DAYCARE 47 52 | #define GAME_STAT_RODE_CABLE_CAR 48 53 | #define GAME_STAT_ENTERED_HOT_SPRINGS 49 54 | #define NUM_GAME_STATS 50 55 | 56 | #endif // GUARD_CONSTANTS_GAME_STAT_H 57 | -------------------------------------------------------------------------------- /tools/jsonproc/jsonproc.cpp: -------------------------------------------------------------------------------- 1 | // jsonproc.cpp 2 | 3 | #include "jsonproc.h" 4 | 5 | #include 6 | 7 | #include 8 | using std::string; 9 | 10 | #include 11 | using namespace inja; 12 | using json = nlohmann::json; 13 | 14 | std::map customVars; 15 | 16 | void set_custom_var(string key, string value) 17 | { 18 | customVars[key] = value; 19 | } 20 | 21 | string get_custom_var(string key) 22 | { 23 | return customVars[key]; 24 | } 25 | 26 | int main(int argc, char *argv[]) 27 | { 28 | if (argc != 4) 29 | FATAL_ERROR("USAGE: jsonproc \n"); 30 | 31 | string jsonfilepath = argv[1]; 32 | string templateFilepath = argv[2]; 33 | string outputFilepath = argv[3]; 34 | 35 | Environment env; 36 | 37 | // Add custom command callbacks. 38 | env.add_callback("doNotModifyHeader", 0, [jsonfilepath, templateFilepath](Arguments& args) { 39 | return "//\n// DO NOT MODIFY THIS FILE! IT IS AUTO-GENERATED FROM " + jsonfilepath +" and Inja template " + templateFilepath + "\n//\n"; 40 | }); 41 | 42 | env.add_callback("setVar", 2, [=](Arguments& args) { 43 | string key = args.at(0)->get(); 44 | string value = args.at(1)->get(); 45 | set_custom_var(key, value); 46 | return ""; 47 | }); 48 | 49 | env.add_callback("getVar", 1, [=](Arguments& args) { 50 | string key = args.at(0)->get(); 51 | return get_custom_var(key); 52 | }); 53 | 54 | env.add_callback("concat", 2, [](Arguments& args) { 55 | string first = args.at(0)->get(); 56 | string second = args.at(1)->get(); 57 | return first + second; 58 | }); 59 | 60 | env.add_callback("removePrefix", 2, [](Arguments& args) { 61 | string rawValue = args.at(0)->get(); 62 | string prefix = args.at(1)->get(); 63 | string::size_type i = rawValue.find(prefix); 64 | if (i != 0) 65 | return rawValue; 66 | 67 | return rawValue.erase(0, prefix.length()); 68 | }); 69 | 70 | // Add custom command callbacks. 71 | env.add_callback("removeSuffix", 2, [](Arguments& args) { 72 | string rawValue = args.at(0)->get(); 73 | string suffix = args.at(1)->get(); 74 | string::size_type i = rawValue.rfind(suffix); 75 | if (i == string::npos) 76 | return rawValue; 77 | 78 | return rawValue.substr(0, i); 79 | }); 80 | 81 | try 82 | { 83 | env.write_with_json_file(templateFilepath, jsonfilepath, outputFilepath); 84 | } 85 | catch (const std::exception& e) 86 | { 87 | FATAL_ERROR("JSONPROC_ERROR: %s\n", e.what()); 88 | } 89 | 90 | return 0; 91 | } 92 | -------------------------------------------------------------------------------- /constants/contest_constants.inc: -------------------------------------------------------------------------------- 1 | .set CONTEST_COOL, 0x00 2 | .set CONTEST_BEAUTY, 0x01 3 | .set CONTEST_CUTE, 0x02 4 | .set CONTEST_SMART, 0x03 5 | .set CONTEST_TOUGH, 0x04 6 | 7 | .set COMBO_STARTER_RAIN_DANCE, 0x01 8 | .set COMBO_STARTER_RAGE, 0x02 9 | .set COMBO_STARTER_FOCUS_ENERGY, 0x03 10 | .set COMBO_STARTER_HYPNOSIS, 0x04 11 | .set COMBO_STARTER_ENDURE, 0x05 12 | .set COMBO_STARTER_HORN_ATTACK, 0x06 13 | .set COMBO_STARTER_SWORDS_DANCE, 0x07 14 | .set COMBO_STARTER_STOCKPILE, 0x08 15 | .set COMBO_STARTER_SUNNY_DAY, 0x09 16 | .set COMBO_STARTER_REST, 0x0A 17 | .set COMBO_STARTER_VICE_GRIP, 0x0B 18 | .set COMBO_STARTER_DEFENSE_CURL, 0x0C 19 | .set COMBO_STARTER_CHARGE, 0x0D 20 | .set COMBO_STARTER_ROCK_THROW, 0x0E 21 | .set COMBO_STARTER_YAWN, 0x0F 22 | .set COMBO_STARTER_SCARY_FACE, 0x10 23 | .set COMBO_STARTER_POWDER_SNOW, 0x11 24 | .set COMBO_STARTER_LOCK_ON, 0x12 25 | .set COMBO_STARTER_SOFT_BOILED, 0x13 26 | .set COMBO_STARTER_MEAN_LOOK, 0x14 27 | .set COMBO_STARTER_SCRATCH, 0x15 28 | .set COMBO_STARTER_GROWTH, 0x16 29 | .set COMBO_STARTER_HAIL, 0x17 30 | .set COMBO_STARTER_SANDSTORM, 0x18 31 | .set COMBO_STARTER_BELLY_DRUM, 0x19 32 | .set COMBO_STARTER_MIND_READER, 0x1A 33 | .set COMBO_STARTER_DRAGON_BREATH, 0x1B 34 | .set COMBO_STARTER_DRAGON_RAGE, 0x1C 35 | .set COMBO_STARTER_DRAGON_DANCE, 0x1D 36 | .set COMBO_STARTER_SURF, 0x1E 37 | .set COMBO_STARTER_DIVE, 0x1F 38 | .set COMBO_STARTER_STRING_SHOT, 0x20 39 | .set COMBO_STARTER_LEER, 0x21 40 | .set COMBO_STARTER_TAUNT, 0x22 41 | .set COMBO_STARTER_CHARM, 0x23 42 | .set COMBO_STARTER_HARDEN, 0x24 43 | .set COMBO_STARTER_SING, 0x25 44 | .set COMBO_STARTER_EARTHQUAKE, 0x26 45 | .set COMBO_STARTER_DOUBLE_TEAM, 0x27 46 | .set COMBO_STARTER_CURSE, 0x28 47 | .set COMBO_STARTER_SWEET_SCENT, 0x29 48 | .set COMBO_STARTER_SLUDGE, 0x2A 49 | .set COMBO_STARTER_SLUDGE_BOMB, 0x2B 50 | .set COMBO_STARTER_THUNDER_PUNCH, 0x2C 51 | .set COMBO_STARTER_FIRE_PUNCH, 0x2D 52 | .set COMBO_STARTER_ICE_PUNCH, 0x2E 53 | .set COMBO_STARTER_PECK, 0x2F 54 | .set COMBO_STARTER_METAL_SOUND, 0x30 55 | .set COMBO_STARTER_MUD_SPORT, 0x31 56 | .set COMBO_STARTER_WATER_SPORT, 0x32 57 | .set COMBO_STARTER_BONE_CLUB, 0x33 58 | .set COMBO_STARTER_BONEMERANG, 0x34 59 | .set COMBO_STARTER_BONE_RUSH, 0x35 60 | .set COMBO_STARTER_SAND_ATTACK, 0x36 61 | .set COMBO_STARTER_MUD_SLAP, 0x37 62 | .set COMBO_STARTER_FAKE_OUT, 0x38 63 | .set COMBO_STARTER_PSYCHIC, 0x39 64 | .set COMBO_STARTER_KINESIS, 0x3A 65 | .set COMBO_STARTER_CONFUSION, 0x3B 66 | .set COMBO_STARTER_POUND, 0x3C 67 | .set COMBO_STARTER_SMOG, 0x3D 68 | .set COMBO_STARTER_CALM_MIND, 0x3E 69 | -------------------------------------------------------------------------------- /tools/gbagfx/util.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "global.h" 10 | #include "util.h" 11 | 12 | bool ParseNumber(char *s, char **end, int radix, int *intValue) 13 | { 14 | char *localEnd; 15 | 16 | if (end == NULL) 17 | end = &localEnd; 18 | 19 | errno = 0; 20 | 21 | const long longValue = strtol(s, end, radix); 22 | 23 | if (*end == s) 24 | return false; // not a number 25 | 26 | if ((longValue == LONG_MIN || longValue == LONG_MAX) && errno == ERANGE) 27 | return false; 28 | 29 | if (longValue > INT_MAX) 30 | return false; 31 | 32 | if (longValue < INT_MIN) 33 | return false; 34 | 35 | *intValue = (int)longValue; 36 | 37 | return true; 38 | } 39 | 40 | char *GetFileExtension(char *path) 41 | { 42 | char *extension = path; 43 | 44 | while (*extension != 0) 45 | extension++; 46 | 47 | while (extension > path && *extension != '.') 48 | extension--; 49 | 50 | if (extension == path) 51 | return NULL; 52 | 53 | extension++; 54 | 55 | if (*extension == 0) 56 | return NULL; 57 | 58 | return extension; 59 | } 60 | 61 | unsigned char *ReadWholeFile(char *path, int *size) 62 | { 63 | FILE *fp = fopen(path, "rb"); 64 | 65 | if (fp == NULL) 66 | FATAL_ERROR("Failed to open \"%s\" for reading.\n", path); 67 | 68 | fseek(fp, 0, SEEK_END); 69 | 70 | *size = ftell(fp); 71 | 72 | unsigned char *buffer = malloc(*size); 73 | 74 | if (buffer == NULL) 75 | FATAL_ERROR("Failed to allocate memory for reading \"%s\".\n", path); 76 | 77 | rewind(fp); 78 | 79 | if (fread(buffer, *size, 1, fp) != 1) 80 | FATAL_ERROR("Failed to read \"%s\".\n", path); 81 | 82 | fclose(fp); 83 | 84 | return buffer; 85 | } 86 | 87 | unsigned char *ReadWholeFileZeroPadded(char *path, int *size, int padAmount) 88 | { 89 | FILE *fp = fopen(path, "rb"); 90 | 91 | if (fp == NULL) 92 | FATAL_ERROR("Failed to open \"%s\" for reading.\n", path); 93 | 94 | fseek(fp, 0, SEEK_END); 95 | 96 | *size = ftell(fp); 97 | 98 | unsigned char *buffer = calloc(*size + padAmount, 1); 99 | 100 | if (buffer == NULL) 101 | FATAL_ERROR("Failed to allocate memory for reading \"%s\".\n", path); 102 | 103 | rewind(fp); 104 | 105 | if (fread(buffer, *size, 1, fp) != 1) 106 | FATAL_ERROR("Failed to read \"%s\".\n", path); 107 | 108 | fclose(fp); 109 | 110 | return buffer; 111 | } 112 | 113 | void WriteWholeFile(char *path, void *buffer, int bufferSize) 114 | { 115 | FILE *fp = fopen(path, "wb"); 116 | 117 | if (fp == NULL) 118 | FATAL_ERROR("Failed to open \"%s\" for writing.\n", path); 119 | 120 | if (fwrite(buffer, bufferSize, 1, fp) != 1) 121 | FATAL_ERROR("Failed to write to \"%s\".\n", path); 122 | 123 | fclose(fp); 124 | } 125 | -------------------------------------------------------------------------------- /tools/rsfont/util.c: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2015 YamaArashi 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include "global.h" 10 | #include "util.h" 11 | 12 | bool ParseNumber(char *s, char **end, int radix, int *intValue) 13 | { 14 | char *localEnd; 15 | 16 | if (end == NULL) 17 | end = &localEnd; 18 | 19 | errno = 0; 20 | 21 | const long longValue = strtol(s, end, radix); 22 | 23 | if (*end == s) 24 | return false; // not a number 25 | 26 | if ((longValue == LONG_MIN || longValue == LONG_MAX) && errno == ERANGE) 27 | return false; 28 | 29 | if (longValue > INT_MAX) 30 | return false; 31 | 32 | if (longValue < INT_MIN) 33 | return false; 34 | 35 | *intValue = (int)longValue; 36 | 37 | return true; 38 | } 39 | 40 | char *GetFileExtension(char *path) 41 | { 42 | char *extension = path; 43 | 44 | while (*extension != 0) 45 | extension++; 46 | 47 | while (extension > path && *extension != '.') 48 | extension--; 49 | 50 | if (extension == path) 51 | return NULL; 52 | 53 | extension++; 54 | 55 | if (*extension == 0) 56 | return NULL; 57 | 58 | return extension; 59 | } 60 | 61 | unsigned char *ReadWholeFile(char *path, int *size) 62 | { 63 | FILE *fp = fopen(path, "rb"); 64 | 65 | if (fp == NULL) 66 | FATAL_ERROR("Failed to open \"%s\" for reading.\n", path); 67 | 68 | fseek(fp, 0, SEEK_END); 69 | 70 | *size = ftell(fp); 71 | 72 | unsigned char *buffer = malloc(*size); 73 | 74 | if (buffer == NULL) 75 | FATAL_ERROR("Failed to allocate memory for reading \"%s\".\n", path); 76 | 77 | rewind(fp); 78 | 79 | if (fread(buffer, *size, 1, fp) != 1) 80 | FATAL_ERROR("Failed to read \"%s\".\n", path); 81 | 82 | fclose(fp); 83 | 84 | return buffer; 85 | } 86 | 87 | unsigned char *ReadWholeFileZeroPadded(char *path, int *size, int padAmount) 88 | { 89 | FILE *fp = fopen(path, "rb"); 90 | 91 | if (fp == NULL) 92 | FATAL_ERROR("Failed to open \"%s\" for reading.\n", path); 93 | 94 | fseek(fp, 0, SEEK_END); 95 | 96 | *size = ftell(fp); 97 | 98 | unsigned char *buffer = calloc(*size + padAmount, 1); 99 | 100 | if (buffer == NULL) 101 | FATAL_ERROR("Failed to allocate memory for reading \"%s\".\n", path); 102 | 103 | rewind(fp); 104 | 105 | if (fread(buffer, *size, 1, fp) != 1) 106 | FATAL_ERROR("Failed to read \"%s\".\n", path); 107 | 108 | fclose(fp); 109 | 110 | return buffer; 111 | } 112 | 113 | void WriteWholeFile(char *path, void *buffer, int bufferSize) 114 | { 115 | FILE *fp = fopen(path, "wb"); 116 | 117 | if (fp == NULL) 118 | FATAL_ERROR("Failed to open \"%s\" for writing.\n", path); 119 | 120 | if (fwrite(buffer, bufferSize, 1, fp) != 1) 121 | FATAL_ERROR("Failed to write to \"%s\".\n", path); 122 | 123 | fclose(fp); 124 | } 125 | -------------------------------------------------------------------------------- /payload/constants/contest_constants.inc: -------------------------------------------------------------------------------- 1 | .set CONTEST_COOL, 0x00 2 | .set CONTEST_BEAUTY, 0x01 3 | .set CONTEST_CUTE, 0x02 4 | .set CONTEST_SMART, 0x03 5 | .set CONTEST_TOUGH, 0x04 6 | 7 | .set COMBO_STARTER_RAIN_DANCE, 0x01 8 | .set COMBO_STARTER_RAGE, 0x02 9 | .set COMBO_STARTER_FOCUS_ENERGY, 0x03 10 | .set COMBO_STARTER_HYPNOSIS, 0x04 11 | .set COMBO_STARTER_ENDURE, 0x05 12 | .set COMBO_STARTER_HORN_ATTACK, 0x06 13 | .set COMBO_STARTER_SWORDS_DANCE, 0x07 14 | .set COMBO_STARTER_STOCKPILE, 0x08 15 | .set COMBO_STARTER_SUNNY_DAY, 0x09 16 | .set COMBO_STARTER_REST, 0x0A 17 | .set COMBO_STARTER_VICE_GRIP, 0x0B 18 | .set COMBO_STARTER_DEFENSE_CURL, 0x0C 19 | .set COMBO_STARTER_CHARGE, 0x0D 20 | .set COMBO_STARTER_ROCK_THROW, 0x0E 21 | .set COMBO_STARTER_YAWN, 0x0F 22 | .set COMBO_STARTER_SCARY_FACE, 0x10 23 | .set COMBO_STARTER_POWDER_SNOW, 0x11 24 | .set COMBO_STARTER_LOCK_ON, 0x12 25 | .set COMBO_STARTER_SOFT_BOILED, 0x13 26 | .set COMBO_STARTER_MEAN_LOOK, 0x14 27 | .set COMBO_STARTER_SCRATCH, 0x15 28 | .set COMBO_STARTER_GROWTH, 0x16 29 | .set COMBO_STARTER_HAIL, 0x17 30 | .set COMBO_STARTER_SANDSTORM, 0x18 31 | .set COMBO_STARTER_BELLY_DRUM, 0x19 32 | .set COMBO_STARTER_MIND_READER, 0x1A 33 | .set COMBO_STARTER_DRAGON_BREATH, 0x1B 34 | .set COMBO_STARTER_DRAGON_RAGE, 0x1C 35 | .set COMBO_STARTER_DRAGON_DANCE, 0x1D 36 | .set COMBO_STARTER_SURF, 0x1E 37 | .set COMBO_STARTER_DIVE, 0x1F 38 | .set COMBO_STARTER_STRING_SHOT, 0x20 39 | .set COMBO_STARTER_LEER, 0x21 40 | .set COMBO_STARTER_TAUNT, 0x22 41 | .set COMBO_STARTER_CHARM, 0x23 42 | .set COMBO_STARTER_HARDEN, 0x24 43 | .set COMBO_STARTER_SING, 0x25 44 | .set COMBO_STARTER_EARTHQUAKE, 0x26 45 | .set COMBO_STARTER_DOUBLE_TEAM, 0x27 46 | .set COMBO_STARTER_CURSE, 0x28 47 | .set COMBO_STARTER_SWEET_SCENT, 0x29 48 | .set COMBO_STARTER_SLUDGE, 0x2A 49 | .set COMBO_STARTER_SLUDGE_BOMB, 0x2B 50 | .set COMBO_STARTER_THUNDER_PUNCH, 0x2C 51 | .set COMBO_STARTER_FIRE_PUNCH, 0x2D 52 | .set COMBO_STARTER_ICE_PUNCH, 0x2E 53 | .set COMBO_STARTER_PECK, 0x2F 54 | .set COMBO_STARTER_METAL_SOUND, 0x30 55 | .set COMBO_STARTER_MUD_SPORT, 0x31 56 | .set COMBO_STARTER_WATER_SPORT, 0x32 57 | .set COMBO_STARTER_BONE_CLUB, 0x33 58 | .set COMBO_STARTER_BONEMERANG, 0x34 59 | .set COMBO_STARTER_BONE_RUSH, 0x35 60 | .set COMBO_STARTER_SAND_ATTACK, 0x36 61 | .set COMBO_STARTER_MUD_SLAP, 0x37 62 | .set COMBO_STARTER_FAKE_OUT, 0x38 63 | .set COMBO_STARTER_PSYCHIC, 0x39 64 | .set COMBO_STARTER_KINESIS, 0x3A 65 | .set COMBO_STARTER_CONFUSION, 0x3B 66 | .set COMBO_STARTER_POUND, 0x3C 67 | .set COMBO_STARTER_SMOG, 0x3D 68 | .set COMBO_STARTER_CALM_MIND, 0x3E 69 | -------------------------------------------------------------------------------- /asm/iwram.s: -------------------------------------------------------------------------------- 1 | .include "asm/macros.inc" 2 | .include "constants/constants.inc" 3 | 4 | .text 5 | .syntax unified 6 | 7 | arm_func_start arm_LZ77UnCompWRAM 8 | arm_LZ77UnCompWRAM: @ 0x02016818 9 | mov ip, sp 10 | push {r4, r5, r6, r7, r8, sb, sl, fp, ip, lr, pc} 11 | sub fp, ip, #4 12 | mov r7, r0 13 | ldr r3, [r7], #4 14 | mov lr, r1 15 | add sb, lr, r3, asr #8 16 | cmp lr, sb 17 | bhs _02016940 18 | mov r8, #0xff0 19 | add r8, r8, #0xf 20 | _02016844: 21 | mov r5, #0x80 22 | ldrb sl, [r7], #1 23 | _0201684C: 24 | tst sl, r5 25 | beq _02016924 26 | ldrb r3, [r7], #1 27 | ldrb r1, [r7], #1 28 | sub r0, lr, #1 29 | orr r1, r1, r3, lsl #8 30 | and r3, r1, r8 31 | rsb r0, r3, r0 32 | orr r2, lr, r0 33 | tst r2, #1 34 | asr r1, r1, #0xc 35 | add r1, r1, #3 36 | bne _020168C0 37 | asr ip, r1, #2 38 | cmp ip, #0 39 | and r4, r1, #2 40 | and r6, r1, #1 41 | lsr r1, r5, #1 42 | beq _020168B0 43 | _02016898: 44 | ldrh r3, [r0], #2 45 | strh r3, [lr], #2 46 | ldrh r3, [r0], #2 47 | strh r3, [lr], #2 48 | subs ip, ip, #1 49 | bne _02016898 50 | _020168B0: 51 | cmp r4, #0 52 | ldrhne r3, [r0], #2 53 | strhne r3, [lr], #2 54 | b _02016914 55 | _020168C0: 56 | asr ip, r1, #2 57 | cmp ip, #0 58 | and r4, r1, #2 59 | and r6, r1, #1 60 | lsr r1, r5, #1 61 | beq _02016900 62 | _020168D8: 63 | ldrb r3, [r0], #1 64 | strb r3, [lr], #1 65 | ldrb r2, [r0], #1 66 | strb r2, [lr], #1 67 | ldrb r3, [r0], #1 68 | strb r3, [lr], #1 69 | ldrb r2, [r0], #1 70 | strb r2, [lr], #1 71 | subs ip, ip, #1 72 | bne _020168D8 73 | _02016900: 74 | cmp r4, #0 75 | ldrbne r3, [r0], #1 76 | strbne r3, [lr], #1 77 | ldrbne r2, [r0], #1 78 | strbne r2, [lr], #1 79 | _02016914: 80 | cmp r6, #0 81 | beq _02016930 82 | ldrb r3, [r0] 83 | b _0201692C 84 | _02016924: 85 | ldrb r3, [r7], #1 86 | lsr r1, r5, #1 87 | _0201692C: 88 | strb r3, [lr], #1 89 | _02016930: 90 | ands r5, r1, #0xff 91 | bne _0201684C 92 | cmp lr, sb 93 | blo _02016844 94 | _02016940: 95 | ldmdb fp, {r4, r5, r6, r7, r8, sb, sl, fp, sp, lr} 96 | bx lr 97 | 98 | arm_func_start arm_Bootstrap 99 | arm_Bootstrap: @ 0x02016948 100 | mov ip, sp 101 | push {r4, r5, fp, ip, lr, pc} 102 | mov r3, #0xac 103 | add r3, r3, #0x2000000 104 | mov r1, #0 105 | ldr r2, =ImageEnd 106 | sub fp, ip, #4 107 | ldr ip, =Image 108 | mov r5, #0x2000000 109 | ldr r4, [r3] 110 | rsb r2, ip, r2 111 | rsb r0, r2, #0x2000000 112 | add r0, r0, #0x3fc00 113 | add r0, r0, #0x300 114 | cmp r1, r2 115 | bge _0201699C 116 | _02016988: 117 | ldrb r3, [ip, r1] 118 | strb r3, [r0, r1] 119 | add r1, r1, #1 120 | cmp r1, r2 121 | blt _02016988 122 | _0201699C: 123 | mov r3, #0x208 124 | add r3, r3, #0x4000000 125 | mov r2, #0 126 | strh r2, [r3] 127 | mov r1, #0x2000000 128 | bl arm_LZ77UnCompWRAM 129 | mov r3, #0xac 130 | add r3, r3, #0x2000000 131 | str r4, [r3] 132 | mov lr, pc 133 | bx r5 134 | b _020169D4 135 | .pool 136 | _020169D4: @ 0x020169D4 137 | ldmdb fp, {r4, r5, fp, sp, lr} 138 | bx lr 139 | -------------------------------------------------------------------------------- /payload/ld_script.txt: -------------------------------------------------------------------------------- 1 | gNumMusicPlayers = 1; 2 | gMaxLines = 0; 3 | 4 | GPIOPortDirection = 0x080000C6; 5 | 6 | SECTIONS { 7 | . = 0x02000000; 8 | .text : 9 | ALIGN(4) 10 | { 11 | asm/crt0.o(.text); 12 | src/main.o(.text); 13 | src/all.o(.text); 14 | src/pokemon_summary_screen.o(.text); 15 | src/all4.o(.text); 16 | 17 | } =0 18 | 19 | lib_text : 20 | ALIGN(4) 21 | { 22 | asm/m4a_1.o(.text); 23 | src/m4a.o(.text); 24 | src/gflib/init.o(.text); 25 | src/gflib/bg.o(.text); 26 | src/gflib/sprite.o(.text); 27 | src/gflib/text.o(.text); 28 | src/gflib/keys.o(.text); 29 | src/gflib/gfxload.o(.text); 30 | src/gflib/sound.o(.text); 31 | src/libpmagb/agb_rom.o(.text); 32 | src/libpmagb/pic_uncomp.o(.text); 33 | src/libpmagb/save.o(.text); 34 | src/pokemon.o(.text); 35 | src/libpmagb/berry.o(.text); 36 | src/unk_200C5DC.o(.text); 37 | src/agb_flash.o(.text); 38 | src/agb_flash_1m.o(.text); 39 | src/agb_flash_mx.o(.text); 40 | src/agb_flash_le.o(.text); 41 | src/berry_fix.o(.text); 42 | src/siirtc.o(.text); 43 | asm/libagbsyscall.o(.text); 44 | *libgcc.a:_call_via_rX.o(.text); 45 | *libgcc.a:_divsi3.o(.text); 46 | *libgcc.a:_dvmd_tls.o(.text); 47 | *libgcc.a:_modsi3.o(.text); 48 | *libgcc.a:_umodsi3.o(.text); 49 | *libc.a:memcpy.o(.text); 50 | } =0 51 | .rodata : 52 | ALIGN(4) 53 | { 54 | src/all.o(.rodata); 55 | data/all.o(.rodata); 56 | src/strings.o(.rodata); 57 | src/graphics.o(.rodata); 58 | } =0 59 | 60 | m4a_rodata : 61 | ALIGN(4) 62 | { 63 | src/m4a_tables.o(.rodata); 64 | data/sound_data.o(.rodata); 65 | sound/songs/midi/se_select.o(.rodata); 66 | sound/songs/midi/se_failure.o(.rodata); 67 | } =0 68 | 69 | lib_rodata : 70 | ALIGN(4) 71 | { 72 | src/mb_20094A8.o(.rodata); 73 | src/rom_info.o(.rodata); 74 | src/agb_flash.o(.rodata); 75 | src/agb_flash_1m.o(.rodata); 76 | src/agb_flash_mx.o(.rodata); 77 | src/agb_flash_le.o(.rodata); 78 | src/berry_fix.o(.rodata); 79 | src/siirtc.o(.rodata); 80 | } =0 81 | 82 | .data : 83 | ALIGN(4) 84 | { 85 | data/all.o(.data); 86 | src/strings.o(.data); 87 | } =0 88 | 89 | lib_data : 90 | ALIGN(4) 91 | { 92 | src/libpmagb/save.o(.data); 93 | src/mb_20094A8.o(.data); 94 | src/rom_info.o(.data); 95 | } =0 96 | bss_start = .; 97 | wram (NOLOAD) : 98 | ALIGN(4) 99 | { 100 | INCLUDE sym_bss.ld; 101 | src/m4a.o(.bss.code); 102 | INCLUDE sym_common.ld; 103 | } 104 | bss_end = .; 105 | wram_extra (NOLOAD) : 106 | ALIGN(4) 107 | { 108 | INCLUDE sym_ewram.ld; 109 | } 110 | . = 0x02040000; /* Limit EWRAM size */ 111 | 112 | /DISCARD/ : 113 | { 114 | *(*); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /asm/crt0.s: -------------------------------------------------------------------------------- 1 | .include "asm/macros/function.inc" 2 | .include "constants/gba_constants.inc" 3 | .text 4 | .syntax unified 5 | 6 | arm_func_start _start 7 | _start: @ 0x02000000 8 | b _init 9 | .global RomHeaderNintendoLogo 10 | RomHeaderNintendoLogo: 11 | .space 156 12 | 13 | RomHeaderGameTitle: 14 | .space 12 15 | 16 | .global RomHeaderGameCode 17 | RomHeaderGameCode: 18 | .space 4 19 | 20 | RomHeaderMakerCode: 21 | .space 2 22 | 23 | RomHeaderMagic: 24 | .byte 0 25 | 26 | RomHeaderMainUnitCode: 27 | .byte 0 28 | 29 | RomHeaderDeviceType: 30 | .byte 0 31 | 32 | RomHeaderReserved1: 33 | .space 7 34 | 35 | .global RomHeaderSoftwareVersion 36 | RomHeaderSoftwareVersion: 37 | .byte 0 38 | 39 | RomHeaderChecksum: 40 | .byte 0 41 | 42 | RomHeaderReserved2: 43 | .space 2 44 | _init: 45 | mov r0, #0x12 46 | msr cpsr_fc, r0 47 | ldr sp, _020000F8 @=0x03007fa0 48 | mov r0, #0x1f 49 | msr cpsr_fc, r0 50 | ldr sp, _020000F4 @=0x03007e60 51 | ldr r1, _020000FC @=INTR_VECTOR 52 | adr r0, _intr 53 | str r0, [r1] 54 | ldr r1, _02000100 @=AgbMain 55 | mov lr, pc 56 | bx r1 57 | b _init 58 | .align 2, 0 59 | 60 | _020000F4: .4byte 0x03007e60 61 | _020000F8: .4byte 0x03007fa0 62 | _020000FC: .4byte INTR_VECTOR 63 | _02000100: .4byte AgbMain 64 | 65 | arm_func_start _intr 66 | _intr: @ 0x02000104 67 | mov r3, #0x4000000 68 | add r3, r3, #0x200 69 | ldr r2, [r3] 70 | ldrh r1, [r3, #8] 71 | mrs r0, spsr 72 | push {r0, r1, r2, r3, lr} 73 | mov r0, #1 74 | strh r0, [r3, #8] 75 | and r1, r2, r2, lsr #16 76 | mov ip, #0 77 | ands r0, r1, #0x80 78 | bne _020001D4 79 | add ip, ip, #4 80 | ands r0, r1, #1 81 | bne _020001D4 82 | add ip, ip, #4 83 | ands r0, r1, #2 84 | bne _020001D4 85 | add ip, ip, #4 86 | ands r0, r1, #4 87 | bne _020001D4 88 | add ip, ip, #4 89 | ands r0, r1, #8 90 | bne _020001D4 91 | add ip, ip, #4 92 | ands r0, r1, #0x10 93 | bne _020001D4 94 | add ip, ip, #4 95 | ands r0, r1, #0x20 96 | bne _020001D4 97 | add ip, ip, #4 98 | ands r0, r1, #0x40 99 | bne _020001D4 100 | add ip, ip, #4 101 | ands r0, r1, #0x100 102 | bne _020001D4 103 | add ip, ip, #4 104 | ands r0, r1, #0x200 105 | bne _020001D4 106 | add ip, ip, #4 107 | ands r0, r1, #0x400 108 | bne _020001D4 109 | add ip, ip, #4 110 | ands r0, r1, #0x800 111 | bne _020001D4 112 | add ip, ip, #4 113 | ands r0, r1, #0x1000 114 | bne _020001D4 115 | add ip, ip, #4 116 | ands r0, r1, #0x2000 117 | strbne r0, [r3, #-0x17c] 118 | _020001D0: 119 | bne _020001D0 120 | _020001D4: 121 | strh r0, [r3, #2] 122 | mov r1, #0x20c0 123 | bic r2, r2, r0 124 | and r1, r1, r2 125 | strh r1, [r3] 126 | mrs r3, apsr 127 | bic r3, r3, #0xdf 128 | orr r3, r3, #0x1f 129 | msr cpsr_fc, r3 130 | ldr r1, =gIntrTableTemplate 131 | add r1, r1, ip 132 | ldr r0, [r1] 133 | stmdb sp!, {lr} 134 | adr lr, _intr_ret 135 | bx r0 136 | _intr_ret: @ 0x02000210 137 | ldm sp!, {lr} 138 | mrs r3, apsr 139 | bic r3, r3, #0xdf 140 | orr r3, r3, #0x92 141 | msr cpsr_fc, r3 142 | pop {r0, r1, r2, r3, lr} 143 | strh r2, [r3] 144 | strh r1, [r3, #8] 145 | msr spsr_fc, r0 146 | bx lr 147 | .align 2, 0 148 | .pool 149 | -------------------------------------------------------------------------------- /constants/contest_move_effects.inc: -------------------------------------------------------------------------------- 1 | enum_start 2 | enum CONTEST_EFFECT_HIGHLY_APPEALING @ 0 3 | enum CONTEST_EFFECT_USER_MORE_EASILY_STARTLED @ 1 4 | enum CONTEST_EFFECT_GREAT_APPEAL_BUT_NO_MORE_MOVES @ 2 5 | enum CONTEST_EFFECT_REPETITION_NOT_BORING @ 3 6 | enum CONTEST_EFFECT_AVOID_STARTLE_ONCE @ 4 7 | enum CONTEST_EFFECT_AVOID_STARTLE @ 5 8 | enum CONTEST_EFFECT_AVOID_STARTLE_SLIGHTLY @ 6 9 | enum CONTEST_EFFECT_USER_LESS_EASILY_STARTLED @ 7 10 | enum CONTEST_EFFECT_STARTLE_FRONT_MON @ 8 11 | enum CONTEST_EFFECT_SLIGHTLY_STARTLE_PREV_MONS @ 9 12 | enum CONTEST_EFFECT_STARTLE_PREV_MON @ 10 13 | enum CONTEST_EFFECT_STARTLE_PREV_MONS @ 11 14 | enum CONTEST_EFFECT_BADLY_STARTLE_FRONT_MON @ 12 15 | enum CONTEST_EFFECT_BADLY_STARTLE_PREV_MONS @ 13 16 | enum CONTEST_EFFECT_STARTLE_PREV_MON_2 @ 14 17 | enum CONTEST_EFFECT_STARTLE_PREV_MONS_2 @ 15 18 | enum CONTEST_EFFECT_SHIFT_JUDGE_ATTENTION @ 16 19 | enum CONTEST_EFFECT_STARTLE_MON_WITH_JUDGES_ATTENTION @ 17 20 | enum CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN @ 18 21 | enum CONTEST_EFFECT_STARTLE_MONS_SAME_TYPE_APPEAL @ 19 22 | enum CONTEST_EFFECT_STARTLE_MONS_COOL_APPEAL @ 20 23 | enum CONTEST_EFFECT_STARTLE_MONS_BEAUTY_APPEAL @ 21 24 | enum CONTEST_EFFECT_STARTLE_MONS_CUTE_APPEAL @ 22 25 | enum CONTEST_EFFECT_STARTLE_MONS_SMART_APPEAL @ 23 26 | enum CONTEST_EFFECT_STARTLE_MONS_TOUGH_APPEAL @ 24 27 | enum CONTEST_EFFECT_MAKE_FOLLOWING_MON_NERVOUS @ 25 28 | enum CONTEST_EFFECT_MAKE_FOLLOWING_MONS_NERVOUS @ 26 29 | enum CONTEST_EFFECT_WORSEN_CONDITION_OF_PREV_MONS @ 27 30 | enum CONTEST_EFFECT_BADLY_STARTLES_MONS_IN_GOOD_CONDITION @ 28 31 | enum CONTEST_EFFECT_BETTER_IF_FIRST @ 29 32 | enum CONTEST_EFFECT_BETTER_IF_LAST @ 30 33 | enum CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES @ 31 34 | enum CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONE @ 32 35 | enum CONTEST_EFFECT_BETTER_WHEN_LATER @ 33 36 | enum CONTEST_EFFECT_QUALITY_DEPENDS_ON_TIMING @ 34 37 | enum CONTEST_EFFECT_BETTER_IF_SAME_TYPE @ 35 38 | enum CONTEST_EFFECT_BETTER_IF_DIFF_TYPE @ 36 39 | enum CONTEST_EFFECT_AFFECTED_BY_PREV_APPEAL @ 37 40 | enum CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS @ 38 41 | enum CONTEST_EFFECT_BETTER_WITH_GOOD_CONDITION @ 39 42 | enum CONTEST_EFFECT_NEXT_APPEAL_EARLIER @ 40 43 | enum CONTEST_EFFECT_NEXT_APPEAL_LATER @ 41 44 | enum CONTEST_EFFECT_MAKE_SCRAMBLING_TURN_ORDER_EASIER @ 42 45 | enum CONTEST_EFFECT_SCRAMBLE_NEXT_TURN_ORDER @ 43 46 | enum CONTEST_EFFECT_EXCITE_AUDIENCE_IN_ANY_CONTEST @ 44 47 | enum CONTEST_EFFECT_BADLY_STARTLE_MONS_WITH_GOOD_APPEALS @ 45 48 | enum CONTEST_EFFECT_BETTER_WHEN_AUDIENCE_EXCITED @ 46 49 | enum CONTEST_EFFECT_DONT_EXCITE_AUDIENCE @ 47 50 | -------------------------------------------------------------------------------- /payload/constants/contest_move_effects.inc: -------------------------------------------------------------------------------- 1 | enum_start 2 | enum CONTEST_EFFECT_HIGHLY_APPEALING @ 0 3 | enum CONTEST_EFFECT_USER_MORE_EASILY_STARTLED @ 1 4 | enum CONTEST_EFFECT_GREAT_APPEAL_BUT_NO_MORE_MOVES @ 2 5 | enum CONTEST_EFFECT_REPETITION_NOT_BORING @ 3 6 | enum CONTEST_EFFECT_AVOID_STARTLE_ONCE @ 4 7 | enum CONTEST_EFFECT_AVOID_STARTLE @ 5 8 | enum CONTEST_EFFECT_AVOID_STARTLE_SLIGHTLY @ 6 9 | enum CONTEST_EFFECT_USER_LESS_EASILY_STARTLED @ 7 10 | enum CONTEST_EFFECT_STARTLE_FRONT_MON @ 8 11 | enum CONTEST_EFFECT_SLIGHTLY_STARTLE_PREV_MONS @ 9 12 | enum CONTEST_EFFECT_STARTLE_PREV_MON @ 10 13 | enum CONTEST_EFFECT_STARTLE_PREV_MONS @ 11 14 | enum CONTEST_EFFECT_BADLY_STARTLE_FRONT_MON @ 12 15 | enum CONTEST_EFFECT_BADLY_STARTLE_PREV_MONS @ 13 16 | enum CONTEST_EFFECT_STARTLE_PREV_MON_2 @ 14 17 | enum CONTEST_EFFECT_STARTLE_PREV_MONS_2 @ 15 18 | enum CONTEST_EFFECT_SHIFT_JUDGE_ATTENTION @ 16 19 | enum CONTEST_EFFECT_STARTLE_MON_WITH_JUDGES_ATTENTION @ 17 20 | enum CONTEST_EFFECT_JAMS_OTHERS_BUT_MISS_ONE_TURN @ 18 21 | enum CONTEST_EFFECT_STARTLE_MONS_SAME_TYPE_APPEAL @ 19 22 | enum CONTEST_EFFECT_STARTLE_MONS_COOL_APPEAL @ 20 23 | enum CONTEST_EFFECT_STARTLE_MONS_BEAUTY_APPEAL @ 21 24 | enum CONTEST_EFFECT_STARTLE_MONS_CUTE_APPEAL @ 22 25 | enum CONTEST_EFFECT_STARTLE_MONS_SMART_APPEAL @ 23 26 | enum CONTEST_EFFECT_STARTLE_MONS_TOUGH_APPEAL @ 24 27 | enum CONTEST_EFFECT_MAKE_FOLLOWING_MON_NERVOUS @ 25 28 | enum CONTEST_EFFECT_MAKE_FOLLOWING_MONS_NERVOUS @ 26 29 | enum CONTEST_EFFECT_WORSEN_CONDITION_OF_PREV_MONS @ 27 30 | enum CONTEST_EFFECT_BADLY_STARTLES_MONS_IN_GOOD_CONDITION @ 28 31 | enum CONTEST_EFFECT_BETTER_IF_FIRST @ 29 32 | enum CONTEST_EFFECT_BETTER_IF_LAST @ 30 33 | enum CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONES @ 31 34 | enum CONTEST_EFFECT_APPEAL_AS_GOOD_AS_PREV_ONE @ 32 35 | enum CONTEST_EFFECT_BETTER_WHEN_LATER @ 33 36 | enum CONTEST_EFFECT_QUALITY_DEPENDS_ON_TIMING @ 34 37 | enum CONTEST_EFFECT_BETTER_IF_SAME_TYPE @ 35 38 | enum CONTEST_EFFECT_BETTER_IF_DIFF_TYPE @ 36 39 | enum CONTEST_EFFECT_AFFECTED_BY_PREV_APPEAL @ 37 40 | enum CONTEST_EFFECT_IMPROVE_CONDITION_PREVENT_NERVOUSNESS @ 38 41 | enum CONTEST_EFFECT_BETTER_WITH_GOOD_CONDITION @ 39 42 | enum CONTEST_EFFECT_NEXT_APPEAL_EARLIER @ 40 43 | enum CONTEST_EFFECT_NEXT_APPEAL_LATER @ 41 44 | enum CONTEST_EFFECT_MAKE_SCRAMBLING_TURN_ORDER_EASIER @ 42 45 | enum CONTEST_EFFECT_SCRAMBLE_NEXT_TURN_ORDER @ 43 46 | enum CONTEST_EFFECT_EXCITE_AUDIENCE_IN_ANY_CONTEST @ 44 47 | enum CONTEST_EFFECT_BADLY_STARTLE_MONS_WITH_GOOD_APPEALS @ 45 48 | enum CONTEST_EFFECT_BETTER_WHEN_AUDIENCE_EXCITED @ 46 49 | enum CONTEST_EFFECT_DONT_EXCITE_AUDIENCE @ 47 50 | -------------------------------------------------------------------------------- /constants/pokemon_data_constants.inc: -------------------------------------------------------------------------------- 1 | .set NATURE_HARDY, 0 2 | .set NATURE_LONELY, 1 3 | .set NATURE_BRAVE, 2 4 | .set NATURE_ADAMANT, 3 5 | .set NATURE_NAUGHTY, 4 6 | .set NATURE_BOLD, 5 7 | .set NATURE_DOCILE, 6 8 | .set NATURE_RELAXED, 7 9 | .set NATURE_IMPISH, 8 10 | .set NATURE_LAX, 9 11 | .set NATURE_TIMID, 10 12 | .set NATURE_HASTY, 11 13 | .set NATURE_SERIOUS, 12 14 | .set NATURE_JOLLY, 13 15 | .set NATURE_NAIVE, 14 16 | .set NATURE_MODEST, 15 17 | .set NATURE_MILD, 16 18 | .set NATURE_QUIET, 17 19 | .set NATURE_BASHFUL, 18 20 | .set NATURE_RASH, 19 21 | .set NATURE_CALM, 20 22 | .set NATURE_GENTLE, 21 23 | .set NATURE_SASSY, 22 24 | .set NATURE_CAREFUL, 23 25 | .set NATURE_QUIRKY, 24 26 | 27 | .set GROWTH_MEDIUM_FAST, 0x00 28 | .set GROWTH_ERRATIC, 0x01 29 | .set GROWTH_FLUCTUATING, 0x02 30 | .set GROWTH_MEDIUM_SLOW, 0x03 31 | .set GROWTH_FAST, 0x04 32 | .set GROWTH_SLOW, 0x05 33 | 34 | .set EGG_GROUP_NONE, 0x00 35 | .set EGG_GROUP_MONSTER, 0x01 36 | .set EGG_GROUP_WATER_1, 0x02 37 | .set EGG_GROUP_BUG, 0x03 38 | .set EGG_GROUP_FLYING, 0x04 39 | .set EGG_GROUP_FIELD, 0x05 40 | .set EGG_GROUP_FAIRY, 0x06 41 | .set EGG_GROUP_GRASS, 0x07 42 | .set EGG_GROUP_HUMAN_LIKE, 0x08 43 | .set EGG_GROUP_WATER_3, 0x09 44 | .set EGG_GROUP_MINERAL, 0x0a 45 | .set EGG_GROUP_AMORPHOUS, 0x0b 46 | .set EGG_GROUP_WATER_2, 0x0c 47 | .set EGG_GROUP_DITTO, 0x0d 48 | .set EGG_GROUP_DRAGON, 0x0e 49 | .set EGG_GROUP_UNDISCOVERED, 0x0f 50 | 51 | .set BODY_COLOR_RED, 0x00 52 | .set BODY_COLOR_BLUE, 0x01 53 | .set BODY_COLOR_YELLOW, 0x02 54 | .set BODY_COLOR_GREEN, 0x03 55 | .set BODY_COLOR_BLACK, 0x04 56 | .set BODY_COLOR_BROWN, 0x05 57 | .set BODY_COLOR_PURPLE, 0x06 58 | .set BODY_COLOR_GRAY, 0x07 59 | .set BODY_COLOR_WHITE, 0x08 60 | .set BODY_COLOR_PINK, 0x09 61 | 62 | .set F_SUMMARY_SCREEN_FLIP_SPRITE, 0x80 63 | 64 | .set EVO_FRIENDSHIP, 0x0001 @ Pokémon levels up with friendship ≥ 220 65 | .set EVO_FRIENDSHIP_DAY, 0x0002 @ Pokémon levels up during the day with friendship ≥ 220 66 | .set EVO_FRIENDSHIP_NIGHT, 0x0003 @ Pokémon levels up at night with friendship ≥ 220 67 | .set EVO_LEVEL, 0x0004 @ Pokémon reaches the specified level 68 | .set EVO_TRADE, 0x0005 @ Pokémon is traded 69 | .set EVO_TRADE_ITEM, 0x0006 @ Pokémon is traded while it's holding the specified item 70 | .set EVO_ITEM, 0x0007 @ specified item is used on Pokémon 71 | .set EVO_LEVEL_ATK_GT_DEF, 0x0008 @ Pokémon reaches the specified level with attack > defense 72 | .set EVO_LEVEL_ATK_EQ_DEF, 0x0009 @ Pokémon reaches the specified level with attack = defense 73 | .set EVO_LEVEL_ATK_LT_DEF, 0x000a @ Pokémon reaches the specified level with attack < defense 74 | .set EVO_LEVEL_SILCOON, 0x000b @ Pokémon reaches the specified level with a Silcoon personality value 75 | .set EVO_LEVEL_CASCOON, 0x000c @ Pokémon reaches the specified level with a Cascoon personality value 76 | .set EVO_LEVEL_NINJASK, 0x000d @ Pokémon reaches the specified level (special value for Ninjask) 77 | .set EVO_LEVEL_SHEDINJA, 0x000e @ Pokémon reaches the specified level (special value for Shedinja) 78 | .set EVO_BEAUTY, 0x000f @ Pokémon levels up with beauty ≥ specified value 79 | -------------------------------------------------------------------------------- /payload/include/all.h: -------------------------------------------------------------------------------- 1 | #ifndef GUARD_ALL_H 2 | #define GUARD_ALL_H 3 | 4 | struct ExternalEventData2 5 | { 6 | u32 unknownExternalDataFields1; 7 | u32 unknownExternalDataFields2; 8 | u32 currentPokeCoupons:24; 9 | u32 gotGoldPokeCouponTitleReward:1; 10 | u32 gotSilverPokeCouponTitleReward:1; 11 | u32 gotBronzePokeCouponTitleReward:1; 12 | u32 receivedAgetoCelebi:1; 13 | u32 unknownExternalDataFields3:4; 14 | u32 totalEarnedPokeCoupons:24; 15 | u32 unknownExternalDataFields4:8; 16 | }; 17 | 18 | struct MonName 19 | { 20 | u8 str[10]; 21 | u32 playerId:3; 22 | u32 isJapanese:1; 23 | u32 isNidoranF:1; 24 | u32 isNidoranM:1; 25 | u32 gender:2; 26 | }; 27 | 28 | struct MonData 29 | { 30 | u16 hp; // 0x24 31 | u32 status:12; // 0x26 32 | u32 giveMaxPokerusDays:1; 33 | u32 giveMaxPokerusStrain:1; 34 | u32 setMailTo1:1; 35 | u32 preserveHeldItem:1; 36 | u32 heldItem:16; // 0x28 37 | u16 unused; 38 | u16 moves[MAX_MON_MOVES]; // 0x2C , 0x2E , 0x30, 0x32 39 | u8 pps[MAX_MON_MOVES]; // 0x34-0x37 40 | u8 textBuffer[320]; 41 | }; 42 | 43 | struct MonLinkData 44 | { 45 | u32 partyCountNibblefield:PARTY_SIZE * 4; // Like a bitfield, but every party member is represented by 4 bits. For example, a party of 4 would be represented by 0x00FFFF 46 | u32 unk_03_0:7; 47 | u32 unk_03_7:1; 48 | u32 unk4:24; 49 | u32 monCount:8; 50 | u32 personality; 51 | u32 otId; 52 | u16 species; 53 | u16 unk12; 54 | u16 moves[MAX_MON_MOVES]; 55 | u8 pps[MAX_MON_MOVES]; 56 | u16 unk20; 57 | u8 unk22_0:4; 58 | u8 unk22_4:4; 59 | u8 unk23_0:4; 60 | u8 unk23_4:4; 61 | struct MonData monData[PARTY_SIZE]; 62 | struct MonName monName[4]; 63 | u8 unk84C_00:1; 64 | u8 transferComplete:1; 65 | u8 unk84C_02:1; 66 | u8 unk84C_03:1; 67 | u8 monId:4; 68 | u32 species2:16; 69 | u32 speciesLowerByte:8; 70 | u32 speciesUpperByte:8; 71 | u32 unk850_2:24; 72 | u32 *monPtr; 73 | u8 unk_858; 74 | u8 numMonsToSelect; 75 | u8 unk_85A; 76 | u8 species3; // Only 1 byte, so can not contain a Hoenn species 77 | u8 ALIGNED(4) giftRibbons[GIFT_RIBBONS_COUNT + 1]; // Aligned for u32 copy 78 | struct ExternalEventData2 externalEventData; 79 | u8 unk_878; 80 | u8 partyCount; 81 | u8 unk_87A; 82 | u8 unk_87B; 83 | u8 unk_87C; 84 | u8 filler_87D; 85 | u8 unk_87E; 86 | u8 unk_87F; 87 | u32 unk_880; 88 | }; 89 | 90 | extern volatile struct MonLinkData gMonLinkData; 91 | 92 | #include "gflib/text.h" 93 | 94 | void sub_02002A9C(s32 a0, u32 a1, u32 a2); 95 | void BufferString(u32 bufferId, const u8 *src); 96 | void DrawPartyMonHealthBar(int bgNum, int x, int y, u32 monId); 97 | void FadeIn(void); 98 | void OverrideScreenFadeState(bool32 faded); 99 | bool32 IsScreenFadedOut(void); 100 | void FadeOut(void); 101 | void DrawTextWindowBorder(u32 a0, u32 a1, s32 a2, s32 a3, u32 a4); 102 | u8 *NumToPmString3CustomZeroChar(s32 num, u8 *str, u32 zeroChar); 103 | void RenderText(struct Window *win, const u8 *str); 104 | void RenderTextAt(struct Window *win, u32 x, u32 y, const u8 *str); 105 | u8 *NumToPmString3RightAlign(u8 *str, s32 num); 106 | void ClearVram(void); 107 | 108 | #endif // GUARD_ALL_H 109 | --------------------------------------------------------------------------------