Merge pull request #732 from PikalaxALT/modern_gcc

Modernize code for compatibility with later releases of GCC
This commit is contained in:
PikalaxALT 2019-07-20 12:11:46 -04:00 committed by GitHub
commit 4d5c1ca03b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
96 changed files with 4366 additions and 897 deletions

View File

@ -30,7 +30,8 @@ matrix:
- g++-7
env: _="Build"
script:
- ./build_tools.sh g++-7
- make -j2 tools CXX=g++-7
- make -j2 compare
- make -j2 modern
after_success:
- .travis/calcrom/webhook.sh pokeemerald

View File

@ -13,12 +13,6 @@ Then get the compiler from https://github.com/pret/agbcc and run the following c
./install.sh PATH_OF_POKEEMERALD_DIRECTORY
```
Then in the pokeemerald directory, build the tools.
```
./build_tools.sh
```
Finally, build the rom.
```
@ -101,3 +95,22 @@ If you've only changed `.c` or `.s` files, you can turn off the dependency scann
`make NODEP=1`
# Building with devkitARM's C compiler
This project supports the `arm-none-eabi-gcc` compiler which ships with devkitARM r52. To build this target, simply run:
make modern
# Building with your own toolchain
To build Pokemon Emerald with a toolchain other than devkitARM, override the `TOOLCHAIN` environment variable with the path to your toolchain. Example:
make compare TOOLCHAIN=/usr/local/arm-none-eabi
The path you pass to the `TOOLCHAIN` variable must contain the subdirectory `bin`. If you compile the `modern` target with this toolchain, the subdirectories `lib`, `include`, and `arm-none-eabi` must also be present.
# Building with debug info
To build the ELF file with enhanced debug info, use the `DINFO` variable:
make compare DINFO=1

View File

@ -1,4 +1,12 @@
include $(DEVKITARM)/base_tools
TOOLCHAIN := $(DEVKITARM)
ifneq (,$(wildcard $(TOOLCHAIN)/base_tools))
include $(TOOLCHAIN)/base_tools
else
PREFIX := $(TOOLCHAIN)/bin/arm-none-eabi-
OBJCOPY := $(PREFIX)objcopy
CC := $(PREFIX)gcc
AS := $(PREFIX)as
endif
export CPP := $(PREFIX)cpp
export LD := $(PREFIX)ld
@ -12,12 +20,10 @@ TITLE := POKEMON EMER
GAME_CODE := BPEE
MAKER_CODE := 01
REVISION := 0
MODERN ?= 0
SHELL := /bin/bash -o pipefail
ROM := pokeemerald.gba
OBJ_DIR := build/emerald
ELF = $(ROM:.gba=.elf)
MAP = $(ROM:.gba=.map)
@ -34,16 +40,32 @@ DATA_ASM_BUILDDIR = $(OBJ_DIR)/$(DATA_ASM_SUBDIR)
SONG_BUILDDIR = $(OBJ_DIR)/$(SONG_SUBDIR)
MID_BUILDDIR = $(OBJ_DIR)/$(MID_SUBDIR)
ASFLAGS := -mcpu=arm7tdmi
ASFLAGS := -mcpu=arm7tdmi --defsym MODERN=$(MODERN)
GCC_VER := $(shell $(CC) -dumpversion)
ifeq ($(MODERN),0)
CC1 := tools/agbcc/bin/agbcc$(EXE)
override CFLAGS += -mthumb-interwork -Wimplicit -Wparentheses -Werror -O2 -fhex-asm
ROM := pokeemerald.gba
OBJ_DIR := build/emerald
LIBPATH := -L ../../tools/agbcc/lib
else
CC1 := $(shell $(PREFIX)gcc --print-prog-name=cc1) -quiet
override CFLAGS += -mthumb -mthumb-interwork -O2 -mabi=apcs-gnu -mtune=arm7tdmi -march=armv4t -fno-toplevel-reorder -fno-aggressive-loop-optimizations -Wno-pointer-to-int-cast
ROM := pokeemerald_modern.gba
OBJ_DIR := build/modern
LIBPATH := -L $(TOOLCHAIN)/lib/gcc/arm-none-eabi/$(GCC_VER)/thumb -L $(TOOLCHAIN)/arm-none-eabi/lib/thumb
endif
CPPFLAGS := -I tools/agbcc/include -I tools/agbcc -iquote include -Wno-trigraphs
CPPFLAGS := -iquote include -Wno-trigraphs -DMODERN=$(MODERN)
ifeq ($(MODERN),0)
CPPFLAGS += -I tools/agbcc/include -I tools/agbcc
endif
LDFLAGS = -Map ../../$(MAP)
LIB := -L ../../tools/agbcc/lib -lgcc -lc
LIB := $(LIBPATH) -lgcc -lc
SHA1 := $(shell { command -v sha1sum || command -v shasum; } 2>/dev/null) -c
GFX := tools/gbagfx/gbagfx$(EXE)
@ -66,7 +88,7 @@ JSONPROC := tools/jsonproc/jsonproc$(EXE)
# Secondary expansion is required for dependency variables in object rules.
.SECONDEXPANSION:
.PHONY: rom clean compare tidy
.PHONY: rom clean compare tidy tools mostlyclean clean-tools
C_SRCS := $(wildcard $(C_SUBDIR)/*.c $(C_SUBDIR)/*/*.c $(C_SUBDIR)/*/*/*.c)
C_OBJS := $(patsubst $(C_SUBDIR)/%.c,$(C_BUILDDIR)/%.o,$(C_SRCS))
@ -90,17 +112,33 @@ SUBDIRS := $(sort $(dir $(OBJS)))
AUTO_GEN_TARGETS :=
TOOLDIRS := $(filter-out tools/agbcc tools/binutils,$(wildcard tools/*))
TOOLBASE = $(TOOLDIRS:tools/%=%)
TOOLS = $(foreach tool,$(TOOLBASE),tools/%(tool)/$(tool)$(EXE))
$(shell mkdir -p $(SUBDIRS))
all: tools rom
tools: $(TOOLS)
$(TOOLS):
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) -C $(tooldir);)
rom: $(ROM)
# For contributors to make sure a change didn't affect the contents of the ROM.
compare: $(ROM)
compare: all
@$(SHA1) rom.sha1
clean: tidy
clean: mostlyclean clean-tools
clean-tools:
@$(foreach tooldir,$(TOOLDIRS),$(MAKE) clean -C $(tooldir);)
mostlyclean: tidy
rm -f sound/direct_sound_samples/*.bin
rm -f $(SONG_OBJS) $(MID_OBJS) $(MID_SUBDIR)/*.s
rm -f $(MID_SUBDIR)/*.s
find . \( -iname '*.1bpp' -o -iname '*.4bpp' -o -iname '*.8bpp' -o -iname '*.gbapal' -o -iname '*.lz' -o -iname '*.latfont' -o -iname '*.hwjpnfont' -o -iname '*.fwjpnfont' \) -exec rm {} +
rm -f $(DATA_ASM_SUBDIR)/layouts/layouts.inc $(DATA_ASM_SUBDIR)/layouts/layouts_table.inc
rm -f $(DATA_ASM_SUBDIR)/maps/connections.inc $(DATA_ASM_SUBDIR)/maps/events.inc $(DATA_ASM_SUBDIR)/maps/groups.inc $(DATA_ASM_SUBDIR)/maps/headers.inc
@ -109,7 +147,10 @@ clean: tidy
tidy:
rm -f $(ROM) $(ELF) $(MAP)
rm -r build/*
rm -r $(OBJ_DIR)
ifeq ($(MODERN),0)
@$(MAKE) tidy MODERN=1
endif
include graphics_file_rules.mk
include map_data_rules.mk
@ -133,6 +174,7 @@ sound/direct_sound_samples/cry_%.bin: sound/direct_sound_samples/cry_%.aif ; $(A
sound/%.bin: sound/%.aif ; $(AIF) $< $@
ifeq ($(MODERN),0)
$(C_BUILDDIR)/libc.o: CC1 := tools/agbcc/bin/old_agbcc
$(C_BUILDDIR)/libc.o: CFLAGS := -O2
@ -145,6 +187,7 @@ $(C_BUILDDIR)/agb_flash_mx.o: CFLAGS := -O -mthumb-interwork
$(C_BUILDDIR)/m4a.o: CC1 := tools/agbcc/bin/old_agbcc
$(C_BUILDDIR)/record_mixing.o: CFLAGS += -ffreestanding
endif
ifeq ($(NODEP),1)
$(C_BUILDDIR)/%.o: c_dep :=
@ -192,12 +235,23 @@ $(OBJ_DIR)/sym_common.ld: sym_common.txt $(C_OBJS) $(wildcard common_syms/*.txt)
$(OBJ_DIR)/sym_ewram.ld: sym_ewram.txt
$(RAMSCRGEN) ewram_data $< ENGLISH > $@
$(OBJ_DIR)/ld_script.ld: ld_script.txt $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld
cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../ld_script.txt > ld_script.ld
ifeq ($(MODERN),0)
LD_SCRIPT := ld_script.txt
LD_SCRIPT_DEPS := $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_common.ld $(OBJ_DIR)/sym_ewram.ld
else
LD_SCRIPT := ld_script_modern.txt
LD_SCRIPT_DEPS :=
endif
$(OBJ_DIR)/ld_script.ld: $(LD_SCRIPT) $(LD_SCRIPT_DEPS)
cd $(OBJ_DIR) && sed "s#tools/#../../tools/#g" ../../$(LD_SCRIPT) > ld_script.ld
$(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS)
cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(OBJS_REL) $(LIB)
$(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent
$(ROM): $(ELF)
$(OBJCOPY) -O binary $< $@
$(FIX) $@ -p -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(REVISION) --silent
$(FIX) $@ -p --silent
modern: ; @$(MAKE) MODERN=1

View File

@ -0,0 +1 @@
gUnknown_03006370

6
common_syms/librfu.txt Normal file
View File

@ -0,0 +1,6 @@
gUnknown_03007870
gUnknown_03007880
gUnknown_03007890
gUnknown_03007894
gUnknown_03007898
gUnknown_030078A0

View File

@ -0,0 +1 @@
gRfuState

View File

@ -23,9 +23,9 @@ int GetMapBorderIdAt(int x, int y);
int CanCameraMoveInDirection(int direction);
u16 GetBehaviorByMetatileId(u16 metatileId);
void GetCameraFocusCoords(u16 *x, u16 *y);
u8 MapGridGetMetatileLayerTypeAt(s32 x, s32 y);
u8 MapGridGetMetatileLayerTypeAt(int x, int y);
u8 MapGridGetZCoordAt(int x, int y);
u8 CameraMove(s32 deltaX, s32 deltaY);
bool8 CameraMove(int deltaX, int deltaY);
struct MapConnection *sub_8088950(u8 direction, int x, int y);
bool8 sub_80889A8(u8 direction, int x, int y, struct MapConnection *connection);
bool8 sub_8088A0C(int x, int src_width, int dest_width, int offset);

View File

@ -6,9 +6,16 @@
#define TRUE 1
#define FALSE 0
#define BSS_DATA __attribute__((section(".bss")))
#define IWRAM_DATA __attribute__((section("iwram_data")))
#define EWRAM_DATA __attribute__((section("ewram_data")))
#if MODERN
#define NOINLINE __attribute__((noinline))
#else
#define NOINLINE
#endif
#define ALIGNED(n) __attribute__((aligned(n)))
#define SOUND_INFO_PTR (*(struct SoundInfo **)0x3007FF0)

View File

@ -2,6 +2,7 @@
#define GUARD_GLOBAL_H
#include <string.h>
#include <limits.h>
#include "config.h" // we need to define config before gba headers as print stuff needs the functions nulled before defines.
#include "gba/gba.h"
#include "constants/global.h"
@ -62,6 +63,10 @@
#define min(a, b) ((a) < (b) ? (a) : (b))
#define max(a, b) ((a) >= (b) ? (a) : (b))
#if MODERN
#define abs(x) (((x) < 0) ? -(x) : (x))
#endif
// Extracts the upper 16 bits of a 32-bit number
#define HIHALF(n) (((n) & 0xFFFF0000) >> 16)

View File

@ -4005,9 +4005,6 @@ extern const u32 gBerryPalette_Starf[];
extern const u32 gBerryPic_Enigma[];
extern const u32 gBerryPalette_Enigma[];
//credits
extern const u32 gCreditsCopyrightEnd_Gfx[];
//pokenav
extern const u8 gPokenavConditionMarker_Gfx[];
extern const u16 gPokenavConditionMarker_Pal[];

View File

@ -278,7 +278,7 @@ bool32 sub_8011B90(void);
void sub_800FE50(u16 *a0);
bool32 sub_800E540(u16 id, u8 *name);
void sub_8011DE0(u32 arg0);
u8 sub_801100C(int a0);
u8 sub_801100C(s32 a0);
void sub_800EF7C(void);
bool8 sub_800DE7C(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx);
bool8 sub_800DF34(struct UnkLinkRfuStruct_02022B14 *buff1, u8 *buff2, u8 idx);

View File

@ -1,6 +1,8 @@
#ifndef GUARD_PLAYER_PC_H
#define GUARD_PLAYER_PC_H
#include "menu.h"
// local task defines
#define PAGE_INDEX data[0]
#define ITEMS_ABOVE_TOP data[1]

View File

@ -4,7 +4,7 @@
#include "bg.h"
#include "main.h"
typedef u32 (*LoopedTask)(int state);
typedef u32 (*LoopedTask)(s32 state);
// Return values of LoopedTask functions.
#define LT_INC_AND_PAUSE 0
@ -111,7 +111,7 @@ void sub_81C7850(u32 a0);
u32 sub_81C786C(void);
void LoadLeftHeaderGfxForIndex(u32 arg0);
void sub_81C7FA0(u32 arg0, bool32 arg1, bool32 arg2);
void sub_81C7AC0(int a0);
void sub_81C7AC0(s32 a0);
bool32 sub_81C8010(void);
void InitBgTemplates(const struct BgTemplate *templates, int count);
bool32 IsPaletteFadeActive(void);

View File

@ -485,7 +485,6 @@ extern const u8 gText_CryOf[];
extern const u8 gText_SizeComparedTo[];
extern const u8 gText_PokedexRegistration[];
extern const u8 gText_UnkCtrlF908Clear01[];
extern const u8 sText_TenDashes2[];
extern const u8 gText_5MarksPokemon[];
extern const u8 gText_UnkHeight[];
extern const u8 gText_UnkWeight[];

View File

@ -166,7 +166,11 @@ struct TextPrinter
void (*callback)(struct TextPrinterTemplate *, u16); // 0x10
union __attribute__((packed)) {
union
#if !MODERN
__attribute__((packed))
#endif
{
struct TextPrinterSubStruct sub;
u8 fields[7];
} subUnion;

View File

@ -47,293 +47,293 @@ SECTIONS {
.text :
ALIGN(4)
{
asm/crt0.o(.text);
src/main.o(.text);
src/alloc.o(.text);
src/dma3_manager.o(.text);
src/gpu_regs.o(.text);
src/bg.o(.text);
src/blit.o(.text);
src/window.o(.text);
src/text.o(.text);
src/sprite.o(.text);
src/string_util.o(.text);
src/link.o(.text);
src/link_rfu.o(.text);
src/union_room.o(.text);
src/mystery_gift.o(.text);
src/union_room_player_avatar.o(.text);
src/union_room_battle.o(.text);
src/mevent2.o(.text);
src/mevent_801BAAC.o(.text);
src/mevent_server.o(.text);
src/mevent_client.o(.text);
src/mevent_server_helpers.o(.text);
src/mevent_news.o(.text);
src/union_room_chat.o(.text);
src/berry_crush.o(.text);
asm/berry_crush.o(.text);
src/berry_powder.o(.text);
src/dodrio_berry_picking.o(.text);
asm/dodrio_berry_picking.o(.text);
src/pokemon_jump.o(.text);
asm/pokemon_jump.o(.text);
src/rtc.o(.text);
src/main_menu.o(.text);
src/battle_controllers.o(.text);
src/decompress.o(.text);
src/rom_8034C54.o(.text);
src/battle_bg.o(.text);
src/battle_main.o(.text);
src/battle_util.o(.text);
src/battle_script_commands.o(.text);
src/battle_util2.o(.text);
src/battle_controller_player.o(.text);
src/battle_gfx_sfx_util.o(.text);
src/battle_controller_opponent.o(.text);
src/battle_ai_switch_items.o(.text);
src/battle_controller_link_opponent.o(.text);
src/pokemon.o(.text);
src/trig.o(.text);
src/random.o(.text);
src/util.o(.text);
src/daycare.o(.text);
src/egg_hatch.o(.text);
src/battle_interface.o(.text);
src/smokescreen.o(.text);
src/pokeball.o(.text);
src/load_save.o(.text);
src/trade.o(.text);
src/berry_blender.o(.text);
src/play_time.o(.text);
src/new_game.o(.text);
src/overworld.o(.text);
src/fieldmap.o(.text);
src/metatile_behavior.o(.text);
src/field_camera.o(.text);
src/field_door.o(.text);
src/field_player_avatar.o(.text);
src/event_object_movement.o(.text);
src/field_message_box.o(.text);
src/event_obj_lock.o(.text);
src/text_window.o(.text);
src/script.o(.text);
src/scrcmd.o(.text);
src/field_control_avatar.o(.text);
src/event_data.o(.text);
src/coord_event_weather.o(.text);
src/field_tasks.o(.text);
src/clock.o(.text);
src/reset_rtc_screen.o(.text);
src/start_menu.o(.text);
src/tileset_anims.o(.text);
src/palette.o(.text);
src/sound.o(.text);
src/battle_anim.o(.text);
src/battle_anim_mons.o(.text);
src/task.o(.text);
src/reshow_battle_screen.o(.text);
src/battle_anim_status_effects.o(.text);
src/title_screen.o(.text);
src/field_weather.o(.text);
src/field_weather_effect.o(.text);
src/field_screen_effect.o(.text);
src/battle_setup.o(.text);
src/cable_club.o(.text);
src/trainer_see.o(.text);
src/wild_encounter.o(.text);
src/field_effect.o(.text);
src/scanline_effect.o(.text);
src/option_menu.o(.text);
src/pokedex.o(.text);
src/trainer_card.o(.text);
src/frontier_pass.o(.text);
src/pokemon_storage_system.o(.text);
src/pokemon_icon.o(.text);
src/script_movement.o(.text);
src/fldeff_cut.o(.text);
src/mail_data.o(.text);
src/map_name_popup.o(.text);
src/item_menu_icons.o(.text);
src/battle_anim_mon_movement.o(.text);
src/item.o(.text);
src/contest.o(.text);
src/shop.o(.text);
src/fldeff_escalator.o(.text);
src/berry.o(.text);
src/script_menu.o(.text);
src/naming_screen.o(.text);
src/money.o(.text);
src/contest_effect.o(.text);
src/record_mixing.o(.text);
src/secret_base.o(.text);
src/tv.o(.text);
src/contest_link_80F57C4.o(.text);
src/script_pokemon_util_80F87D8.o(.text);
src/field_poison.o(.text);
src/pokemon_size_record.o(.text);
src/fldeff_misc.o(.text);
src/field_special_scene.o(.text);
src/rotating_gate.o(.text);
src/safari_zone.o(.text);
src/contest_link_80FC4F4.o(.text);
src/item_use.o(.text);
src/battle_anim_effects_1.o(.text);
src/battle_anim_effects_2.o(.text);
src/water.o(.text);
src/fire.o(.text);
src/electric.o(.text);
src/ice.o(.text);
src/fight.o(.text);
src/poison.o(.text);
src/flying.o(.text);
src/psychic.o(.text);
src/bug.o(.text);
src/rock.o(.text);
src/ghost.o(.text);
src/dragon.o(.text);
src/dark.o(.text);
src/ground.o(.text);
src/normal.o(.text);
src/battle_anim_utility_funcs.o(.text);
src/battle_intro.o(.text);
src/bike.o(.text);
src/easy_chat.o(.text);
src/mon_markings.o(.text);
src/mauville_old_man.o(.text);
src/mail.o(.text);
src/menu_helpers.o(.text);
src/dewford_trend.o(.text);
src/heal_location.o(.text);
src/region_map.o(.text);
src/contest_painting_effects.o(.text);
src/decoration.o(.text);
src/slot_machine.o(.text);
src/contest_painting.o(.text);
src/battle_ai_script_commands.o(.text);
src/trader.o(.text);
src/starter_choose.o(.text);
src/wallclock.o(.text);
src/fldeff_rocksmash.o(.text);
src/fldeff_dig.o(.text);
src/pokeblock.o(.text);
src/fldeff_flash.o(.text);
src/post_battle_event_funcs.o(.text);
src/time_events.o(.text);
src/birch_pc.o(.text);
src/hof_pc.o(.text);
src/field_specials.o(.text);
src/battle_records.o(.text);
src/pokedex_area_screen.o(.text);
src/evolution_scene.o(.text);
src/roulette.o(.text);
src/pokedex_cry_screen.o(.text);
src/coins.o(.text);
src/landmark.o(.text);
src/fldeff_strength.o(.text);
src/battle_transition.o(.text);
src/battle_controller_link_partner.o(.text);
src/battle_message.o(.text);
src/cable_car.o(.text);
src/math_util.o(.text);
src/roulette_util.o(.text);
src/rom_81520A8.o(.text);
src/save.o(.text);
src/mystery_event_script.o(.text);
src/field_effect_helpers.o(.text);
src/contest_ai.o(.text);
src/battle_anim_sound_tasks.o(.text);
src/battle_controller_safari.o(.text);
src/fldeff_sweetscent.o(.text);
src/battle_anim_effects_3.o(.text);
src/move_relearner.o(.text);
src/fldeff_softboiled.o(.text);
src/decoration_inventory.o(.text);
src/roamer.o(.text);
src/battle_tower.o(.text);
src/use_pokeblock.o(.text);
src/battle_controller_wally.o(.text);
src/player_pc.o(.text);
src/intro.o(.text);
src/reset_save_heap.o(.text);
src/field_region_map.o(.text);
src/battle_anim_special.o(.text);
src/hall_of_fame.o(.text);
src/credits.o(.text);
src/lottery_corner.o(.text);
src/diploma.o(.text);
src/berry_tag_screen.o(.text);
src/mystery_event_menu.o(.text);
src/save_failed_screen.o(.text);
src/braille_puzzles.o(.text);
src/pokeblock_feed.o(.text);
src/clear_save_data_screen.o(.text);
src/intro_credits_graphics.o(.text);
src/evolution_graphics.o(.text);
src/bard_music.o(.text);
src/fldeff_teleport.o(.text);
src/battle_tv.o(.text);
src/pokemon_animation.o(.text);
src/recorded_battle.o(.text);
src/battle_controller_recorded_opponent.o(.text);
src/battle_controller_recorded_player.o(.text);
src/trainer_pokemon_sprites.o(.text);
src/lilycove_lady.o(.text);
src/battle_dome.o(.text);
src/battle_palace.o(.text);
src/match_call.o(.text);
src/menu.o(.text);
src/battle_factory_screen.o(.text);
src/apprentice.o(.text);
src/frontier_util.o(.text);
src/battle_arena.o(.text);
src/battle_factory.o(.text);
src/battle_pike.o(.text);
src/mossdeep_gym.o(.text);
src/battle_pyramid.o(.text);
src/item_menu.o(.text);
src/list_menu.o(.text);
src/dynamic_placeholder_text_util.o(.text);
src/save_location.o(.text);
src/item_icon.o(.text);
src/party_menu.o(.text);
src/battle_tent.o(.text);
src/unk_text_util_2.o(.text);
src/multiboot.o(.text);
src/unk_81BAD84.o(.text);
src/battle_controller_player_partner.o(.text);
src/mirage_tower.o(.text);
src/berry_fix_program.o(.text);
src/pokemon_summary_screen.o(.text);
src/unk_pokedex_area_screen_helper.o(.text);
src/battle_pyramid_bag.o(.text);
src/pokenav.o(.text);
src/pokenav_main_menu.o(.text);
src/pokenav_match_call_ui.o(.text);
src/pokenav_unk_1.o(.text);
src/pokenav_unk_2.o(.text);
asm/pokenav_unk_2.o(.text);
src/pokenav_unk_3.o(.text);
src/pokenav_unk_4.o(.text);
src/pokenav_unk_5.o(.text);
asm/pokenav_unk_6.o(.text);
asm/pokenav_unk_7.o(.text);
asm/pokenav_unk_8.o(.text);
asm/pokenav_unk_9.o(.text);
asm/pokenav_unk_10.o(.text);
src/pokenav_unk_10.o(.text);
src/pokenav_match_call_data.o(.text);
src/menu_specialized.o(.text);
src/ereader_helpers.o(.text);
src/faraway_island.o(.text);
src/ereader_screen.o(.text);
src/trainer_hill.o(.text);
src/rayquaza_scene.o(.text);
src/walda_phrase.o(.text);
src/contest_link_81D9DE4.o(.text);
src/gym_leader_rematch.o(.text);
src/unk_transition.o(.text);
src/international_string_util.o(.text);
asm/crt0.o(.text*);
src/main.o(.text*);
src/alloc.o(.text*);
src/dma3_manager.o(.text*);
src/gpu_regs.o(.text*);
src/bg.o(.text*);
src/blit.o(.text*);
src/window.o(.text*);
src/text.o(.text*);
src/sprite.o(.text*);
src/string_util.o(.text*);
src/link.o(.text*);
src/link_rfu.o(.text*);
src/union_room.o(.text*);
src/mystery_gift.o(.text*);
src/union_room_player_avatar.o(.text*);
src/union_room_battle.o(.text*);
src/mevent2.o(.text*);
src/mevent_801BAAC.o(.text*);
src/mevent_server.o(.text*);
src/mevent_client.o(.text*);
src/mevent_server_helpers.o(.text*);
src/mevent_news.o(.text*);
src/union_room_chat.o(.text*);
src/berry_crush.o(.text*);
asm/berry_crush.o(.text*);
src/berry_powder.o(.text*);
src/dodrio_berry_picking.o(.text*);
asm/dodrio_berry_picking.o(.text*);
src/pokemon_jump.o(.text*);
asm/pokemon_jump.o(.text*);
src/rtc.o(.text*);
src/main_menu.o(.text*);
src/battle_controllers.o(.text*);
src/decompress.o(.text*);
src/rom_8034C54.o(.text*);
src/battle_bg.o(.text*);
src/battle_main.o(.text*);
src/battle_util.o(.text*);
src/battle_script_commands.o(.text*);
src/battle_util2.o(.text*);
src/battle_controller_player.o(.text*);
src/battle_gfx_sfx_util.o(.text*);
src/battle_controller_opponent.o(.text*);
src/battle_ai_switch_items.o(.text*);
src/battle_controller_link_opponent.o(.text*);
src/pokemon.o(.text*);
src/trig.o(.text*);
src/random.o(.text*);
src/util.o(.text*);
src/daycare.o(.text*);
src/egg_hatch.o(.text*);
src/battle_interface.o(.text*);
src/smokescreen.o(.text*);
src/pokeball.o(.text*);
src/load_save.o(.text*);
src/trade.o(.text*);
src/berry_blender.o(.text*);
src/play_time.o(.text*);
src/new_game.o(.text*);
src/overworld.o(.text*);
src/fieldmap.o(.text*);
src/metatile_behavior.o(.text*);
src/field_camera.o(.text*);
src/field_door.o(.text*);
src/field_player_avatar.o(.text*);
src/event_object_movement.o(.text*);
src/field_message_box.o(.text*);
src/event_obj_lock.o(.text*);
src/text_window.o(.text*);
src/script.o(.text*);
src/scrcmd.o(.text*);
src/field_control_avatar.o(.text*);
src/event_data.o(.text*);
src/coord_event_weather.o(.text*);
src/field_tasks.o(.text*);
src/clock.o(.text*);
src/reset_rtc_screen.o(.text*);
src/start_menu.o(.text*);
src/tileset_anims.o(.text*);
src/palette.o(.text*);
src/sound.o(.text*);
src/battle_anim.o(.text*);
src/battle_anim_mons.o(.text*);
src/task.o(.text*);
src/reshow_battle_screen.o(.text*);
src/battle_anim_status_effects.o(.text*);
src/title_screen.o(.text*);
src/field_weather.o(.text*);
src/field_weather_effect.o(.text*);
src/field_screen_effect.o(.text*);
src/battle_setup.o(.text*);
src/cable_club.o(.text*);
src/trainer_see.o(.text*);
src/wild_encounter.o(.text*);
src/field_effect.o(.text*);
src/scanline_effect.o(.text*);
src/option_menu.o(.text*);
src/pokedex.o(.text*);
src/trainer_card.o(.text*);
src/frontier_pass.o(.text*);
src/pokemon_storage_system.o(.text*);
src/pokemon_icon.o(.text*);
src/script_movement.o(.text*);
src/fldeff_cut.o(.text*);
src/mail_data.o(.text*);
src/map_name_popup.o(.text*);
src/item_menu_icons.o(.text*);
src/battle_anim_mon_movement.o(.text*);
src/item.o(.text*);
src/contest.o(.text*);
src/shop.o(.text*);
src/fldeff_escalator.o(.text*);
src/berry.o(.text*);
src/script_menu.o(.text*);
src/naming_screen.o(.text*);
src/money.o(.text*);
src/contest_effect.o(.text*);
src/record_mixing.o(.text*);
src/secret_base.o(.text*);
src/tv.o(.text*);
src/contest_link_80F57C4.o(.text*);
src/script_pokemon_util_80F87D8.o(.text*);
src/field_poison.o(.text*);
src/pokemon_size_record.o(.text*);
src/fldeff_misc.o(.text*);
src/field_special_scene.o(.text*);
src/rotating_gate.o(.text*);
src/safari_zone.o(.text*);
src/contest_link_80FC4F4.o(.text*);
src/item_use.o(.text*);
src/battle_anim_effects_1.o(.text*);
src/battle_anim_effects_2.o(.text*);
src/water.o(.text*);
src/fire.o(.text*);
src/electric.o(.text*);
src/ice.o(.text*);
src/fight.o(.text*);
src/poison.o(.text*);
src/flying.o(.text*);
src/psychic.o(.text*);
src/bug.o(.text*);
src/rock.o(.text*);
src/ghost.o(.text*);
src/dragon.o(.text*);
src/dark.o(.text*);
src/ground.o(.text*);
src/normal.o(.text*);
src/battle_anim_utility_funcs.o(.text*);
src/battle_intro.o(.text*);
src/bike.o(.text*);
src/easy_chat.o(.text*);
src/mon_markings.o(.text*);
src/mauville_old_man.o(.text*);
src/mail.o(.text*);
src/menu_helpers.o(.text*);
src/dewford_trend.o(.text*);
src/heal_location.o(.text*);
src/region_map.o(.text*);
src/contest_painting_effects.o(.text*);
src/decoration.o(.text*);
src/slot_machine.o(.text*);
src/contest_painting.o(.text*);
src/battle_ai_script_commands.o(.text*);
src/trader.o(.text*);
src/starter_choose.o(.text*);
src/wallclock.o(.text*);
src/fldeff_rocksmash.o(.text*);
src/fldeff_dig.o(.text*);
src/pokeblock.o(.text*);
src/fldeff_flash.o(.text*);
src/post_battle_event_funcs.o(.text*);
src/time_events.o(.text*);
src/birch_pc.o(.text*);
src/hof_pc.o(.text*);
src/field_specials.o(.text*);
src/battle_records.o(.text*);
src/pokedex_area_screen.o(.text*);
src/evolution_scene.o(.text*);
src/roulette.o(.text*);
src/pokedex_cry_screen.o(.text*);
src/coins.o(.text*);
src/landmark.o(.text*);
src/fldeff_strength.o(.text*);
src/battle_transition.o(.text*);
src/battle_controller_link_partner.o(.text*);
src/battle_message.o(.text*);
src/cable_car.o(.text*);
src/math_util.o(.text*);
src/roulette_util.o(.text*);
src/rom_81520A8.o(.text*);
src/save.o(.text*);
src/mystery_event_script.o(.text*);
src/field_effect_helpers.o(.text*);
src/contest_ai.o(.text*);
src/battle_anim_sound_tasks.o(.text*);
src/battle_controller_safari.o(.text*);
src/fldeff_sweetscent.o(.text*);
src/battle_anim_effects_3.o(.text*);
src/move_relearner.o(.text*);
src/fldeff_softboiled.o(.text*);
src/decoration_inventory.o(.text*);
src/roamer.o(.text*);
src/battle_tower.o(.text*);
src/use_pokeblock.o(.text*);
src/battle_controller_wally.o(.text*);
src/player_pc.o(.text*);
src/intro.o(.text*);
src/reset_save_heap.o(.text*);
src/field_region_map.o(.text*);
src/battle_anim_special.o(.text*);
src/hall_of_fame.o(.text*);
src/credits.o(.text*);
src/lottery_corner.o(.text*);
src/diploma.o(.text*);
src/berry_tag_screen.o(.text*);
src/mystery_event_menu.o(.text*);
src/save_failed_screen.o(.text*);
src/braille_puzzles.o(.text*);
src/pokeblock_feed.o(.text*);
src/clear_save_data_screen.o(.text*);
src/intro_credits_graphics.o(.text*);
src/evolution_graphics.o(.text*);
src/bard_music.o(.text*);
src/fldeff_teleport.o(.text*);
src/battle_tv.o(.text*);
src/pokemon_animation.o(.text*);
src/recorded_battle.o(.text*);
src/battle_controller_recorded_opponent.o(.text*);
src/battle_controller_recorded_player.o(.text*);
src/trainer_pokemon_sprites.o(.text*);
src/lilycove_lady.o(.text*);
src/battle_dome.o(.text*);
src/battle_palace.o(.text*);
src/match_call.o(.text*);
src/menu.o(.text*);
src/battle_factory_screen.o(.text*);
src/apprentice.o(.text*);
src/frontier_util.o(.text*);
src/battle_arena.o(.text*);
src/battle_factory.o(.text*);
src/battle_pike.o(.text*);
src/mossdeep_gym.o(.text*);
src/battle_pyramid.o(.text*);
src/item_menu.o(.text*);
src/list_menu.o(.text*);
src/dynamic_placeholder_text_util.o(.text*);
src/save_location.o(.text*);
src/item_icon.o(.text*);
src/party_menu.o(.text*);
src/battle_tent.o(.text*);
src/unk_text_util_2.o(.text*);
src/multiboot.o(.text*);
src/unk_81BAD84.o(.text*);
src/battle_controller_player_partner.o(.text*);
src/mirage_tower.o(.text*);
src/berry_fix_program.o(.text*);
src/pokemon_summary_screen.o(.text*);
src/unk_pokedex_area_screen_helper.o(.text*);
src/battle_pyramid_bag.o(.text*);
src/pokenav.o(.text*);
src/pokenav_main_menu.o(.text*);
src/pokenav_match_call_ui.o(.text*);
src/pokenav_unk_1.o(.text*);
src/pokenav_unk_2.o(.text*);
asm/pokenav_unk_2.o(.text*);
src/pokenav_unk_3.o(.text*);
src/pokenav_unk_4.o(.text*);
src/pokenav_unk_5.o(.text*);
asm/pokenav_unk_6.o(.text*);
asm/pokenav_unk_7.o(.text*);
asm/pokenav_unk_8.o(.text*);
asm/pokenav_unk_9.o(.text*);
asm/pokenav_unk_10.o(.text*);
src/pokenav_unk_10.o(.text*);
src/pokenav_match_call_data.o(.text*);
src/menu_specialized.o(.text*);
src/ereader_helpers.o(.text*);
src/faraway_island.o(.text*);
src/ereader_screen.o(.text*);
src/trainer_hill.o(.text*);
src/rayquaza_scene.o(.text*);
src/walda_phrase.o(.text*);
src/contest_link_81D9DE4.o(.text*);
src/gym_leader_rematch.o(.text*);
src/unk_transition.o(.text*);
src/international_string_util.o(.text*);
} =0
script_data :
@ -352,70 +352,70 @@ SECTIONS {
lib_text :
ALIGN(4)
{
asm/libgcnmultiboot.o(.text);
asm/m4a_1.o(.text);
src/m4a.o(.text);
src/agb_flash.o(.text);
src/agb_flash_1m.o(.text);
src/agb_flash_mx.o(.text);
src/siirtc.o(.text);
src/librfu_stwi.o(.text);
src/librfu_intr.o(.text);
asm/librfu_intr.o(.text);
src/librfu_rfu.o(.text);
asm/librfu.o(.text);
asm/libagbsyscall.o(.text);
*libgcc.a:_call_via_rX.o(.text);
*libgcc.a:_divdi3.o(.text);
*libgcc.a:_divsi3.o(.text);
*libgcc.a:_dvmd_tls.o(.text);
*libgcc.a:_fixunsdfsi.o(.text);
*libgcc.a:_fixunssfsi.o(.text);
*libgcc.a:_modsi3.o(.text);
*libgcc.a:_muldi3.o(.text);
*libgcc.a:_udivdi3.o(.text);
*libgcc.a:_udivsi3.o(.text);
*libgcc.a:_umodsi3.o(.text);
*libgcc.a:dp-bit.o(.text);
*libgcc.a:fp-bit.o(.text);
*libgcc.a:_lshrdi3.o(.text);
*libgcc.a:_negdi2.o(.text);
*libc.a:memcpy.o(.text);
*libc.a:memset.o(.text);
*libc.a:strcmp.o(.text);
*libc.a:strcpy.o(.text);
*libc.a:vfprintf.o(.text);
*libc.a:vsprintf.o(.text);
*libc.a:fvwrite.o(.text);
*libc.a:locale.o(.text);
*libc.a:findfp.o(.text);
*libc.a:fflush.o(.text);
*libc.a:wsetup.o(.text);
*libc.a:mbtowc_r.o(.text);
*libc.a:s_isinf.o(.text);
*libc.a:s_isnan.o(.text);
*libc.a:memchr.o(.text);
*libc.a:strlen.o(.text);
*libc.a:dtoa.o(.text);
*libc.a:memmove.o(.text);
*libc.a:stdio.o(.text);
*libc.a:mprec.o(.text);
*libc.a:mallocr.o(.text);
*libc.a:fwalk.o(.text);
*libc.a:freer.o(.text);
*libc.a:makebuf.o(.text);
*libc.a:readr.o(.text);
*libc.a:writer.o(.text);
*libc.a:lseekr.o(.text);
*libc.a:closer.o(.text);
*libc.a:callocr.o(.text);
*libc.a:sbrkr.o(.text);
*libc.a:mlock.o(.text);
*libc.a:fstatr.o(.text);
*libc.a:libcfunc.o(.text);
*libc.a:syscalls.o(.text);
*libc.a:errno.o(.text);
src/libisagbprn.o(.text);
asm/libgcnmultiboot.o(.text*);
asm/m4a_1.o(.text*);
src/m4a.o(.text*);
src/agb_flash.o(.text*);
src/agb_flash_1m.o(.text*);
src/agb_flash_mx.o(.text*);
src/siirtc.o(.text*);
src/librfu_stwi.o(.text*);
src/librfu_intr.o(.text*);
asm/librfu_intr.o(.text*);
src/librfu_rfu.o(.text*);
asm/librfu.o(.text*);
asm/libagbsyscall.o(.text*);
*libgcc.a:_call_via_rX.o(.text*);
*libgcc.a:_divdi3.o(.text*);
*libgcc.a:_divsi3.o(.text*);
*libgcc.a:_dvmd_tls.o(.text*);
*libgcc.a:_fixunsdfsi.o(.text*);
*libgcc.a:_fixunssfsi.o(.text*);
*libgcc.a:_modsi3.o(.text*);
*libgcc.a:_muldi3.o(.text*);
*libgcc.a:_udivdi3.o(.text*);
*libgcc.a:_udivsi3.o(.text*);
*libgcc.a:_umodsi3.o(.text*);
*libgcc.a:dp-bit.o(.text*);
*libgcc.a:fp-bit.o(.text*);
*libgcc.a:_lshrdi3.o(.text*);
*libgcc.a:_negdi2.o(.text*);
*libc.a:memcpy.o(.text*);
*libc.a:memset.o(.text*);
*libc.a:strcmp.o(.text*);
*libc.a:strcpy.o(.text*);
*libc.a:vfprintf.o(.text*);
*libc.a:vsprintf.o(.text*);
*libc.a:fvwrite.o(.text*);
*libc.a:locale.o(.text*);
*libc.a:findfp.o(.text*);
*libc.a:fflush.o(.text*);
*libc.a:wsetup.o(.text*);
*libc.a:mbtowc_r.o(.text*);
*libc.a:s_isinf.o(.text*);
*libc.a:s_isnan.o(.text*);
*libc.a:memchr.o(.text*);
*libc.a:strlen.o(.text*);
*libc.a:dtoa.o(.text*);
*libc.a:memmove.o(.text*);
*libc.a:stdio.o(.text*);
*libc.a:mprec.o(.text*);
*libc.a:mallocr.o(.text*);
*libc.a:fwalk.o(.text*);
*libc.a:freer.o(.text*);
*libc.a:makebuf.o(.text*);
*libc.a:readr.o(.text*);
*libc.a:writer.o(.text*);
*libc.a:lseekr.o(.text*);
*libc.a:closer.o(.text*);
*libc.a:callocr.o(.text*);
*libc.a:sbrkr.o(.text*);
*libc.a:mlock.o(.text*);
*libc.a:fstatr.o(.text*);
*libc.a:libcfunc.o(.text*);
*libc.a:syscalls.o(.text*);
*libc.a:errno.o(.text*);
src/libisagbprn.o(.text*);
} =0
.rodata :
@ -429,7 +429,9 @@ SECTIONS {
data/io_reg.o(.rodata);
src/string_util.o(.rodata);
src/link.o(.rodata);
src/link.o(.rodata.str1.4);
src/link_rfu.o(.rodata);
src/link_rfu.o(.rodata.str1.4);
src/union_room.o(.rodata);
src/mystery_gift.o(.rodata);
src/union_room_player_avatar.o(.rodata);
@ -440,6 +442,7 @@ SECTIONS {
src/mevent_client.o(.rodata);
src/mevent_scripts.o(.rodata);
src/union_room_chat.o(.rodata);
src/berry_crush.o(.rodata);
data/berry_crush.o(.rodata);
data/berry_powder.o(.rodata);
src/dodrio_berry_picking.o(.rodata);
@ -448,6 +451,7 @@ SECTIONS {
data/pokemon_jump.o(.rodata);
src/rtc.o(.rodata);
src/main_menu.o(.rodata);
src/battle_controllers.o(.rodata);
src/rom_8034C54.o(.rodata);
src/data.o(.rodata);
src/battle_bg.o(.rodata);
@ -457,6 +461,7 @@ SECTIONS {
src/battle_controller_player.o(.rodata);
data/smokescreen.o(.rodata);
src/battle_controller_opponent.o(.rodata);
src/battle_ai_switch_items.o(.rodata);
src/battle_controller_link_opponent.o(.rodata);
src/pokemon.o(.rodata);
src/trig.o(.rodata);
@ -479,6 +484,7 @@ SECTIONS {
src/event_object_movement.o(.rodata);
src/text_window.o(.rodata);
src/scrcmd.o(.rodata);
src/field_control_avatar.o(.rodata);
src/coord_event_weather.o(.rodata);
src/field_tasks.o(.rodata);
src/reset_rtc_screen.o(.rodata);
@ -489,6 +495,7 @@ SECTIONS {
src/battle_anim.o(.rodata);
src/battle_anim_mons.o(.rodata);
data/map_events.o(.rodata);
src/reshow_battle_screen.o(.rodata);
src/battle_anim_status_effects.o(.rodata);
src/title_screen.o(.rodata);
src/field_weather.o(.rodata);
@ -499,6 +506,7 @@ SECTIONS {
src/trainer_see.o(.rodata);
src/wild_encounter.o(.rodata);
src/field_effect.o(.rodata);
src/scanline_effect.o(.rodata);
src/option_menu.o(.rodata);
src/pokedex.o(.rodata);
src/trainer_card.o(.rodata);
@ -521,12 +529,14 @@ SECTIONS {
src/record_mixing.o(.rodata);
src/secret_base.o(.rodata);
src/tv.o(.rodata);
src/contest_link_80F57C4.o(.rodata);
data/contest_link_80F57C4.o(.rodata);
src/script_pokemon_util_80F87D8.o(.rodata);
src/pokemon_size_record.o(.rodata)
src/fldeff_misc.o(.rodata);
src/field_special_scene.o(.rodata);
src/rotating_gate.o(.rodata);
src/contest_link_80FC4F4.o(.rodata);
src/item_use.o(.rodata);
src/battle_anim_effects_1.o(.rodata);
src/battle_anim_effects_2.o(.rodata);
@ -555,6 +565,7 @@ SECTIONS {
src/menu_helpers.o(.rodata);
src/heal_location.o(.rodata);
src/region_map.o(.rodata);
src/contest_painting_effects.o(.rodata);
data/contest_painting_effects.o(.rodata);
src/decoration.o(.rodata);
src/slot_machine.o(.rodata);
@ -581,6 +592,7 @@ SECTIONS {
src/save.o(.rodata);
src/field_effect_helpers.o(.rodata);
src/contest_ai.o(.rodata);
src/battle_anim_sound_tasks.o(.rodata);
src/battle_controller_safari.o(.rodata);
src/battle_anim_effects_3.o(.rodata);
src/move_relearner.o(.rodata);
@ -623,6 +635,7 @@ SECTIONS {
src/battle_arena.o(.rodata);
src/battle_factory.o(.rodata);
src/battle_pike.o(.rodata);
src/mossdeep_gym.o(.rodata);
data/mossdeep_gym.o(.rodata);
src/battle_pyramid.o(.rodata);
src/item_menu.o(.rodata);
@ -632,6 +645,7 @@ SECTIONS {
src/party_menu.o(.rodata);
src/battle_tent.o(.rodata);
src/unk_text_util_2.o(.rodata);
src/multiboot.o(.rodata);
src/unk_81BAD84.o(.rodata);
src/battle_controller_player_partner.o(.rodata);
src/mirage_tower.o(.rodata);
@ -644,11 +658,16 @@ SECTIONS {
src/pokenav_match_call_ui.o(.rodata);
src/pokenav_unk_1.o(.rodata);
data/pokenav.o(.rodata);
src/pokenav_unk_3.o(.rodata);
src/pokenav_unk_4.o(.rodata);
src/pokenav_unk_5.o(.rodata);
src/pokenav_unk_10.o(.rodata);
src/pokenav_match_call_data.o(.rodata);
src/menu_specialized.o(.rodata);
src/ereader_helpers.o(.rodata);
data/ereader_helpers.o(.rodata);
src/faraway_island.o(.rodata);
src/ereader_screen.o(.rodata);
data/ereader_screen.o(.rodata);
src/trainer_hill.o(.rodata);
src/rayquaza_scene.o(.rodata);
@ -1201,6 +1220,7 @@ SECTIONS {
lib_rodata :
SUBALIGN(4)
{
src/m4a.o(.rodata);
src/agb_flash.o(.rodata);
src/agb_flash_1m.o(.rodata);
src/agb_flash_mx.o(.rodata);

156
ld_script_modern.txt Normal file
View File

@ -0,0 +1,156 @@
ENTRY(Start)
gNumMusicPlayers = 4;
gMaxLines = 0;
SECTIONS {
. = 0x2000000;
ewram (NOLOAD) :
ALIGN(4)
{
gHeap = .;
. = 0x1C000;
src/*.o(ewram_data);
. = 0x40000;
}
. = 0x3000000;
iwram (NOLOAD) :
ALIGN(4)
{
/* .bss starts at 0x3000000 */
src/*.o(.bss);
asm/m4a_1.o(.bss);
/* .bss.code starts at 0x3001AA8 */
src/m4a.o(.bss.code);
/* COMMON starts at 0x30022A8 */
src/*.o(COMMON);
*libc.a:sbrkr.o(COMMON);
end = .;
. = 0x8000;
}
. = 0x8000000;
.text :
ALIGN(4)
{
asm/crt0.o(.text);
src/*.o(.text);
asm/*.o(.text);
} =0
script_data :
ALIGN(4)
{
data/*.o(script_data);
} =0
lib_text :
ALIGN(4)
{
asm/libgcnmultiboot.o(.text);
asm/m4a_1.o(.text);
src/m4a.o(.text);
src/agb_flash.o(.text);
src/agb_flash_1m.o(.text);
src/agb_flash_mx.o(.text);
src/siirtc.o(.text);
src/librfu_stwi.o(.text);
src/librfu_intr.o(.text);
asm/librfu_intr.o(.text);
src/librfu_rfu.o(.text);
asm/librfu.o(.text);
asm/libagbsyscall.o(.text);
*libgcc.a:*.o(.text*);
*libc.a:*.o(.text*);
src/libisagbprn.o(.text);
} =0
.rodata :
ALIGN(4)
{
src/*.o(.rodata*);
data/*.o(.rodata*);
} =0
song_data :
ALIGN(4)
{
sound/songs/*.o(.rodata);
} =0
lib_rodata :
SUBALIGN(4)
{
src/m4a.o(.rodata);
src/agb_flash.o(.rodata);
src/agb_flash_1m.o(.rodata);
src/agb_flash_mx.o(.rodata);
src/agb_flash_le.o(.rodata);
src/siirtc.o(.rodata);
data/librfu_rodata.o(.rodata);
*libgcc.a:*.o(.rodata*);
*libc.a:*.o(.rodata*);
*libc.a:*.o(.data*);
src/libisagbprn.o(.rodata);
} =0
other_data :
ALIGN(4)
{
data/unknown_serial_data.o(.rodata);
data/multiboot_berry_glitch_fix.o(.rodata);
data/multiboot_pokemon_colosseum.o(.rodata);
} =0
anim_mon_front_pic_data :
ALIGN(4)
{
src/anim_mon_front_pics.o(.rodata);
} =0
gfx_data :
ALIGN(4)
{
src/graphics.o(.rodata);
} =0
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
/* Discard everything not specifically mentioned above. */
/DISCARD/ :
{
*(*);
}
}

View File

@ -5354,7 +5354,7 @@ void sub_8102EB0(struct Sprite* sprite)
if (GetBattlerSide(gBattleAnimAttacker) == B_SIDE_OPPONENT)
{
a = gBattleAnimArgs[1];
(u16)gBattleAnimArgs[1] = -a;
*(u16 *)&gBattleAnimArgs[1] = -a;
}
sprite->pos1.x = GetBattlerSpriteCoord(gBattleAnimAttacker, 2) + gBattleAnimArgs[1];

View File

@ -1024,13 +1024,13 @@ static const union AnimCmd gUnknown_0860D020[] =
static const union AnimCmd gUnknown_0860D028[] =
{
ANIMCMD_FRAME(18, 129, .vFlip = TRUE),
ANIMCMD_FRAME(18, 1, .vFlip = TRUE),
ANIMCMD_END,
};
static const union AnimCmd gUnknown_0860D030[] =
{
ANIMCMD_FRAME(16, 65, .hFlip = TRUE),
ANIMCMD_FRAME(16, 1, .hFlip = TRUE),
ANIMCMD_END,
};

View File

@ -16,7 +16,7 @@
#include "constants/moves.h"
// IWRAM bss
static IWRAM_DATA bool8 sPerformedRentalSwap;
static bool8 sPerformedRentalSwap;
// This file's functions.
static void InitFactoryChallenge(void);

View File

@ -227,9 +227,9 @@ static EWRAM_DATA u8 *sSwapMenuTilemapBuffer = NULL;
static EWRAM_DATA u8 *sSwapMonCardBgTilemapBuffer = NULL;
// IWRAM bss
static IWRAM_DATA struct FactorySelectMonsStruct *sFactorySelectScreen;
static IWRAM_DATA void (*sSwap_CurrentTableFunc)(u8 taskId);
static IWRAM_DATA struct FactorySwapMonsStruct *sFactorySwapScreen;
static struct FactorySelectMonsStruct *sFactorySelectScreen;
static void (*sSwap_CurrentTableFunc)(u8 taskId);
static struct FactorySwapMonsStruct *sFactorySwapScreen;
// IWRAM common
u8 (*gUnknown_030062E8)(void);

View File

@ -72,6 +72,9 @@ extern const u8 *const gBattlescriptsForUsingItem[];
extern const u8 *const gBattlescriptsForSafariActions[];
// this file's functions
#if !defined(NONMATCHING) && MODERN
#define static
#endif
static void CB2_InitBattleInternal(void);
static void CB2_PreInitMultiBattle(void);
static void CB2_PreInitIngamePlayerPartnerBattle(void);

View File

@ -53,11 +53,11 @@ struct PikeWildMon
};
// IWRAM bss
static IWRAM_DATA u8 sRoomType;
static IWRAM_DATA u8 sStatusMon;
static IWRAM_DATA bool8 sUnknown_0300128E;
static IWRAM_DATA u32 sStatusFlags;
static IWRAM_DATA u8 sNpcId;
static u8 sRoomType;
static u8 sStatusMon;
static bool8 sUnknown_0300128E;
static u32 sStatusFlags;
static u8 sNpcId;
// This file's functions.
static void SetRoomType(void);

View File

@ -44,7 +44,7 @@ static void sub_81BA040(void);
static void sub_81B9EC0(void);
// IWRAM bss
static IWRAM_DATA u16 sRandMonSetId;
static u16 sRandMonSetId;
// const rom data
void static (*const gUnknown_086160B4[])(void) =

View File

@ -262,10 +262,10 @@ static bool8 sub_814842C(struct Sprite *sprite);
static bool8 sub_8148458(struct Sprite *sprite);
// iwram bss vars
IWRAM_DATA static s16 sUnusedRectangularSpiralVar;
IWRAM_DATA static u8 sTestingTransitionId;
IWRAM_DATA static u8 sTestingTransitionState;
IWRAM_DATA static struct StructRectangularSpiral sRectangularSpiralTransition[4];
static s16 sUnusedRectangularSpiralVar;
static u8 sTestingTransitionId;
static u8 sTestingTransitionState;
static struct StructRectangularSpiral sRectangularSpiralTransition[4];
// ewram vars
EWRAM_DATA static struct TransitionData *sTransitionStructPtr = NULL;

View File

@ -194,10 +194,10 @@ EWRAM_DATA static s32 sUnknown_020322BC[5] = {0};
EWRAM_DATA static u32 sUnknown_020322D0 = 0;
// IWRAM bss
IWRAM_DATA static s16 sUnknown_03000DE8[8];
IWRAM_DATA static s16 sUnknown_03000DF8[6];
IWRAM_DATA static s16 sUnknown_03000E04;
IWRAM_DATA static s16 sUnknown_03000E06;
static s16 sUnknown_03000DE8[8];
static s16 sUnknown_03000DF8[6];
static s16 sUnknown_03000E04;
static s16 sUnknown_03000E06;
// IWRAM common
u8 gInGameOpponentsNo;

View File

@ -37,9 +37,9 @@ struct BgConfig2
s32 bg_y;
};
static IWRAM_DATA struct BgControl sGpuBgConfigs;
static IWRAM_DATA struct BgConfig2 sGpuBgConfigs2[4];
static IWRAM_DATA u32 sDmaBusyBitfield[4];
static struct BgControl sGpuBgConfigs;
static struct BgConfig2 sGpuBgConfigs2[4];
static u32 sDmaBusyBitfield[4];
u32 gUnneededFireRedVariable;
@ -914,7 +914,6 @@ void CopyBgTilemapBufferToVram(u8 bg)
void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 width, u8 height)
{
const void *srcCopy;
u16 destX16;
u16 destY16;
u16 mode;
@ -924,27 +923,31 @@ void CopyToBgTilemapBufferRect(u8 bg, const void* src, u8 destX, u8 destY, u8 wi
switch (GetBgType(bg))
{
case 0:
srcCopy = src;
{
const u16 * srcCopy = src;
for (destY16 = destY; destY16 < (destY + height); destY16++)
{
for (destX16 = destX; destX16 < (destX + width); destX16++)
{
((u16*)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *((u16*)srcCopy)++;
((u16*)sGpuBgConfigs2[bg].tilemap)[((destY16 * 0x20) + destX16)] = *srcCopy++;
}
}
break;
}
case 1:
srcCopy = src;
{
const u8 * srcCopy = src;
mode = GetBgMetricAffineMode(bg, 0x1);
for (destY16 = destY; destY16 < (destY + height); destY16++)
{
for (destX16 = destX; destX16 < (destX + width); destX16++)
{
((u8*)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *((u8*)srcCopy)++;
((u8*)sGpuBgConfigs2[bg].tilemap)[((destY16 * mode) + destX16)] = *srcCopy++;
}
}
break;
}
}
}
}

View File

@ -245,7 +245,7 @@ static void CableCarMainCallback_Setup(void)
{
u16 imebak;
u8 i = 0;
int sizeOut = 0;
u32 sizeOut = 0;
switch (gMain.state)
{

View File

@ -269,8 +269,6 @@ extern const u8 gText_Contest_Fear[];
extern const u8 gText_BDot[];
extern const u8 gText_CDot[];
extern const u8 *const gUnknown_08587E10[];
extern const struct SpriteTemplate gSpriteTemplate_8587AD0;
extern const struct SpriteTemplate gSpriteTemplate_8587B18[];
extern void (*const gContestEffectFuncs[])(void);
static const u8 gUnknown_08587A6C[] =
@ -1268,7 +1266,7 @@ static void sub_80D8108(u8 taskId)
gTasks[taskId].data[0]++;
break;
case 1:
(s16)gBattle_BG1_Y += 7;
*(s16*)&gBattle_BG1_Y += 7;
if ((s16)gBattle_BG1_Y <= 160)
break;
gTasks[taskId].data[0]++;

View File

@ -28,11 +28,11 @@ struct ContestWinner *gUnknown_030061C0;
u16 *gContestPaintingMonPalette;
// IWRAM bss
IWRAM_DATA u8 gContestPaintingState;
IWRAM_DATA u16 gContestPaintingMosaicVal;
IWRAM_DATA u16 gContestPaintingFadeCounter;
IWRAM_DATA bool8 gUnknown_030011F6;
IWRAM_DATA u8 gContestPaintingWindowId;
static u8 gContestPaintingState;
static u16 gContestPaintingMosaicVal;
static u16 gContestPaintingFadeCounter;
static bool8 gUnknown_030011F6;
static u8 gContestPaintingWindowId;
static void ShowContestPainting(void);
static void HoldContestPainting(void);

View File

@ -8,7 +8,7 @@
#define DMA_REQUEST_COPY16 3
#define DMA_REQUEST_FILL16 4
IWRAM_DATA struct
BSS_DATA struct
{
const u8 *src;
u8 *dest;
@ -17,7 +17,7 @@ IWRAM_DATA struct
u32 value;
} gDma3Requests[MAX_DMA_REQUESTS];
static bool8 gDma3ManagerLocked;
static volatile bool8 gDma3ManagerLocked;
static u8 gDma3RequestCursor;
void ClearDma3Requests(void)

View File

@ -145,7 +145,7 @@ EWRAM_DATA u16 * gUnknown_02022CE4[4] = {NULL};
EWRAM_DATA struct DodrioBerryPickingStruct_2022CF4 * gUnknown_02022CF4 = NULL;
EWRAM_DATA struct DodrioBerryPickingSubstruct_0160 * gUnknown_02022CF8 = NULL;
IWRAM_DATA bool32 gUnknown_03000DB0;
static bool32 gUnknown_03000DB0;
void sub_8024A1C(void);
void sub_8024A30(struct DodrioBerryPickingStruct *);

View File

@ -73,7 +73,7 @@ static void CreateRandomEggShardSprite(void);
static void CreateEggShardSprite(u8 x, u8 y, s16 data1, s16 data2, s16 data3, u8 spriteAnimIndex);
// IWRAM bss
static IWRAM_DATA struct EggHatchData *sEggHatchData;
static struct EggHatchData *sEggHatchData;
// rom data
static const u16 sEggPalette[] = INCBIN_U16("graphics/pokemon/egg/normal.gbapal");

View File

@ -26,17 +26,17 @@ static void sub_81D414C(void);
static void sub_81D3F1C(u32, u32*, u32*);
static void sub_81D3F68(void);
IWRAM_DATA struct Unknown030012C8 gUnknown_030012C8;
IWRAM_DATA u16 gUnknown_030012E0;
IWRAM_DATA u16 gUnknown_030012E2;
IWRAM_DATA u16 gUnknown_030012E4;
IWRAM_DATA u16 gUnknown_030012E6;
IWRAM_DATA u32 gUnknown_030012E8;
IWRAM_DATA u16 gUnknown_030012EC;
IWRAM_DATA u16 gUnknown_030012EE;
IWRAM_DATA u16 gUnknown_030012F0;
IWRAM_DATA u16 gUnknown_030012F2;
IWRAM_DATA u16 gUnknown_030012F4;
static struct Unknown030012C8 gUnknown_030012C8;
static u16 gUnknown_030012E0;
static u16 gUnknown_030012E2;
static u16 gUnknown_030012E4;
static u16 gUnknown_030012E6;
static u32 gUnknown_030012E8;
static u16 gUnknown_030012EC;
static u16 gUnknown_030012EE;
static u16 gUnknown_030012F0;
static u16 gUnknown_030012F2;
static u16 gUnknown_030012F4;
extern const u8 gUnknown_08625B6C[][0x148];

View File

@ -38,7 +38,7 @@ struct Unk03006370
static void sub_81D5084(u8);
extern struct Unk03006370 gUnknown_03006370;
struct Unk03006370 gUnknown_03006370;
extern const u8 gUnknown_089A3470[];
extern const u8 gMultiBootProgram_BerryGlitchFix_Start[];

View File

@ -36,11 +36,11 @@ static void DrawMetatile(s32 a, u16 *b, u16 c);
static void CameraPanningCB_PanAhead(void);
// IWRAM bss vars
static IWRAM_DATA struct FieldCameraOffset sFieldCameraOffset;
static IWRAM_DATA s16 sHorizontalCameraPan;
static IWRAM_DATA s16 sVerticalCameraPan;
static IWRAM_DATA u8 gUnknown_03000E2C;
static IWRAM_DATA void (*sFieldCameraPanningCallback)(void);
static struct FieldCameraOffset sFieldCameraOffset;
static s16 sHorizontalCameraPan;
static s16 sVerticalCameraPan;
static u8 gUnknown_03000E2C;
static void (*sFieldCameraPanningCallback)(void);
struct CameraObject gFieldCamera;
u16 gTotalCameraPixelOffsetY;

View File

@ -232,7 +232,7 @@ static void Fldeff_MoveDeoxysRock_Step(u8 taskId);
// Static RAM declarations
static IWRAM_DATA u8 sActiveList[32];
static u8 sActiveList[32];
// External declarations
extern struct CompressedSpritePalette gMonPaletteTable[]; // GF made a mistake and did not extern it as const.

View File

@ -68,7 +68,7 @@ static u8 None_Finish(void);
EWRAM_DATA struct Weather gWeather = {0};
EWRAM_DATA static u8 sFieldEffectPaletteGammaTypes[32] = {0};
IWRAM_DATA static const u8 *sPaletteGammaTypes;
static const u8 *sPaletteGammaTypes;
// The drought weather effect uses a precalculated color lookup table. Presumably this
// is because the underlying color shift calculation is slow.

View File

@ -891,6 +891,7 @@ static void sub_81094D0(u8 taskId) // animate Move_ERUPTION?
break;
default:
break;
}
}

View File

@ -59,11 +59,11 @@ static void CutGrassSpriteCallbackEnd(struct Sprite *);
static void HandleLongGrassOnHyper(u8, s16, s16);
// IWRAM variables
static IWRAM_DATA u8 sCutSquareSide;
static IWRAM_DATA u8 sTileCountFromPlayer_X;
static IWRAM_DATA u8 sTileCountFromPlayer_Y;
static IWRAM_DATA u32 sUnused;
static IWRAM_DATA bool8 sHyperCutTiles[CUT_HYPER_AREA];
static u8 sCutSquareSide;
static u8 sTileCountFromPlayer_X;
static u8 sTileCountFromPlayer_Y;
static u32 sUnused;
static bool8 sHyperCutTiles[CUT_HYPER_AREA];
// EWRAM variables
static EWRAM_DATA u8 *sCutGrassSpriteArrayPtr = NULL;

View File

@ -1148,7 +1148,8 @@ static void sub_8112B78(struct Sprite *sprite)
if (++coeffB > 16)
coeffB = 16;
if (--(s16)coeffA < 0)
--coeffA;
if ((s16)coeffA < 0)
coeffA = 0;
SetGpuReg(REG_OFFSET_BLDALPHA, BLDALPHA_BLEND(coeffA, coeffB));

View File

@ -18,6 +18,9 @@
extern u16 gUnknown_0203CF30[];
// this file's functions
#if !defined(NONMATCHING) && MODERN
#define static
#endif
static bool8 CheckPyramidBagHasItem(u16 itemId, u16 count);
static bool8 CheckPyramidBagHasSpace(u16 itemId, u16 count);

View File

@ -127,7 +127,7 @@ void sub_81ABAE0(void);
u8 sub_81AB1F0(u8);
void sub_81AC23C(u8);
void BagMenu_MoveCursorCallback(s32 a, bool8 b, struct ListMenu*);
void PrintItemQuantityPlusGFX(u8 rboxId, int item_index_in_pocket, u8 a);
void PrintItemQuantityPlusGFX(u8 rboxId, s32 item_index_in_pocket, u8 a);
void ItemMenu_UseOutOfBattle(u8 taskId);
void ItemMenu_Toss(u8 taskId);
void ItemMenu_Register(u8 taskId);
@ -830,7 +830,7 @@ void BagMenu_MoveCursorCallback(s32 a, bool8 b, struct ListMenu *unused)
}
}
void PrintItemQuantityPlusGFX(u8 rboxId, int item_index_in_pocket, u8 a)
void PrintItemQuantityPlusGFX(u8 rboxId, s32 item_index_in_pocket, u8 a)
{
u16 itemId;
u16 itemQuantity;

9
src/librfu.c Normal file
View File

@ -0,0 +1,9 @@
#include "global.h"
#include "librfu.h"
struct RfuUnk1* gUnknown_03007870[4];
struct RfuUnk2* gUnknown_03007880[4];
struct RfuUnk5 *gUnknown_03007890;
u32 *gUnknown_03007894;
struct RfuUnk3* gUnknown_03007898;
u8 gUnknown_030078A0[12];

View File

@ -1,4 +1,5 @@
#include "global.h"
#include "main.h"
#include "librfu.h"
//TODO: decompile asm/librfu_intr.s to here

View File

@ -1,6 +1,8 @@
#include "global.h"
#include "librfu.h"
struct RfuStruct *gRfuState;
extern IntrFunc IntrSIO32(void);
extern void STWI_stop_timer(void);

View File

@ -52,22 +52,21 @@ struct LinkTestBGInfo
// Static RAM declarations
IWRAM_DATA struct BlockTransfer sBlockSend;
IWRAM_DATA u32 link_c_unused_03000d1c;
IWRAM_DATA struct BlockTransfer sBlockRecv[MAX_LINK_PLAYERS];
IWRAM_DATA u32 sBlockSendDelayCounter;
IWRAM_DATA u32 gUnknown_03000D54;
IWRAM_DATA u8 gUnknown_03000D58;
IWRAM_DATA u32 sPlayerDataExchangeStatus;
IWRAM_DATA u32 gUnknown_03000D60;
IWRAM_DATA u8 sLinkTestLastBlockSendPos;
ALIGNED() IWRAM_DATA u8 sLinkTestLastBlockRecvPos[MAX_LINK_PLAYERS];
IWRAM_DATA u8 sNumVBlanksWithoutSerialIntr;
IWRAM_DATA bool8 sSendBufferEmpty;
IWRAM_DATA u16 sSendNonzeroCheck;
IWRAM_DATA u16 sRecvNonzeroCheck;
IWRAM_DATA u8 sChecksumAvailable;
IWRAM_DATA u8 sHandshakePlayerCount;
static struct BlockTransfer sBlockSend;
static struct BlockTransfer sBlockRecv[MAX_LINK_PLAYERS];
static u32 sBlockSendDelayCounter;
static u32 gUnknown_03000D54;
static u8 gUnknown_03000D58;
static u32 sPlayerDataExchangeStatus;
static u32 gUnknown_03000D60;
static u8 sLinkTestLastBlockSendPos;
static u8 sLinkTestLastBlockRecvPos[MAX_LINK_PLAYERS];
static u8 sNumVBlanksWithoutSerialIntr;
static bool8 sSendBufferEmpty;
static u16 sSendNonzeroCheck;
static u16 sRecvNonzeroCheck;
static u8 sChecksumAvailable;
static u8 sHandshakePlayerCount;
u16 gLinkPartnersHeldKeys[6];
u32 gLinkDebugSeed;

View File

@ -24,10 +24,10 @@ extern u16 gHeldKeyCodeToSend;
struct UnkRfuStruct_1 gUnknown_03004140;
struct UnkRfuStruct_2 gUnknown_03005000;
IWRAM_DATA u8 gUnknown_03000D74;
ALIGNED(4) IWRAM_DATA u8 gUnknown_03000D78[8];
IWRAM_DATA u8 gUnknown_03000D80[16];
IWRAM_DATA u16 gUnknown_03000D90[8];
BSS_DATA u8 gUnknown_03000D74;
ALIGNED(4) BSS_DATA u8 gUnknown_03000D78[8];
BSS_DATA u8 gUnknown_03000D80[16];
BSS_DATA u16 gUnknown_03000D90[8];
EWRAM_DATA u8 gWirelessStatusIndicatorSpriteId = 0;
EWRAM_DATA ALIGNED(4) struct UnkLinkRfuStruct_02022B14 gUnknown_02022B14 = {};
@ -2021,6 +2021,8 @@ void sub_800DBF8(u8 *q1, u8 mode)
}
}
// File boundary here maybe?
void PkmnStrToASCII(u8 *q1, const u8 *q2)
{
s32 i;
@ -5142,4 +5144,3 @@ u32 GetRfuRecvQueueLength(void)
{
return gUnknown_03005000.unk_124.unk_8c2;
}

View File

@ -42,10 +42,10 @@ EWRAM_DATA struct LoadedSaveData gLoadedSaveData = {0};
EWRAM_DATA u32 gLastEncryptionKey = 0;
// IWRAM common
IWRAM_DATA bool32 gFlashMemoryPresent;
IWRAM_DATA struct SaveBlock1 *gSaveBlock1Ptr;
IWRAM_DATA struct SaveBlock2 *gSaveBlock2Ptr;
IWRAM_DATA struct PokemonStorage *gPokemonStoragePtr;
bool32 gFlashMemoryPresent;
struct SaveBlock1 *gSaveBlock1Ptr;
struct SaveBlock2 *gSaveBlock2Ptr;
struct PokemonStorage *gPokemonStoragePtr;
// code
void CheckForFlashMemory(void)

View File

@ -1,3 +1,4 @@
#include <string.h>
#include "gba/m4a_internal.h"
extern const u8 gCgb3Vol[];

View File

@ -85,7 +85,27 @@ void EnableVCountIntrAtLine150(void);
void AgbMain()
{
#if MODERN
// Modern compilers are liberal with the stack on entry to this function,
// so RegisterRamReset may crash if it resets IWRAM.
RegisterRamReset(RESET_ALL & ~RESET_IWRAM);
asm("mov\tr1, #0xC0\n"
"\tlsl\tr1, r1, #0x12\n"
"\tmov r2, #0xFC\n"
"\tlsl r2, r2, #0x7\n"
"\tadd\tr2, r1, r2\n"
"\tmov\tr0, #0\n"
"\tmov\tr3, r0\n"
"\tmov\tr4, r0\n"
"\tmov\tr5, r0\n"
".LCU0:\n"
"\tstmia r1!, {r0, r3, r4, r5}\n"
"\tcmp\tr1, r2\n"
"\tbcc\t.LCU0\n"
);
#else
RegisterRamReset(RESET_ALL);
#endif //MODERN
*(vu16 *)BG_PLTT = 0x7FFF;
InitGpuRegManager();
REG_WAITCNT = WAITCNT_PREFETCH_ENABLE | WAITCNT_WS0_S_1 | WAITCNT_WS0_N_3;

View File

@ -176,7 +176,7 @@
static EWRAM_DATA u8 gUnknown_02022D04 = 0;
static EWRAM_DATA u16 sCurrItemAndOptionMenuCheck = 0;
static IWRAM_DATA u8 sBirchSpeechMainTaskId;
static u8 sBirchSpeechMainTaskId;
// Static ROM declarations

View File

@ -33,7 +33,7 @@ static void Task_BardSong(u8 taskId);
static void StorytellerSetup(void);
static void Storyteller_ResetFlag(void);
IWRAM_DATA u8 sSelectedStory;
static u8 sSelectedStory;
struct BardSong gBardSong;

View File

@ -27,7 +27,7 @@ EWRAM_DATA static struct YesNoFuncTable gUnknown_0203A138 = {0};
EWRAM_DATA static u8 gUnknown_0203A140 = 0;
// IWRAM bss vars
IWRAM_DATA static TaskFunc gUnknown_0300117C;
static TaskFunc gUnknown_0300117C;
// const rom data
static const struct OamData sOamData_859F4E8 =

View File

@ -258,7 +258,7 @@ EWRAM_DATA static struct Struct203CF10 *sUnknown_0203CF10 = NULL;
EWRAM_DATA static struct BgRegOffsets *sBgShakeOffsets = NULL;
EWRAM_DATA struct MirageTowerPulseBlend *sMirageTowerPulseBlend = NULL;
IWRAM_DATA static u16 gUnknown_030012A8[8];
static u16 gUnknown_030012A8[8];
bool8 IsMirageTowerVisible(void)
{

View File

@ -1,7 +1,7 @@
#include "gba/gba.h"
#include "multiboot.h"
IWRAM_DATA static u16 MultiBoot_required_data[MULTIBOOT_NCHILD];
static u16 MultiBoot_required_data[MULTIBOOT_NCHILD];
static int MultiBootSend(struct MultiBootParam *mp, u16 data);
static int MultiBootHandShake(struct MultiBootParam *mp);
@ -435,7 +435,7 @@ static int MultiBootHandShake(struct MultiBootParam *mp)
#undef must_data
}
static void MultiBootWaitCycles(u32 cycles)
static NOINLINE void MultiBootWaitCycles(u32 cycles)
{
asm("mov r2, pc");
asm("lsr r2, #24");

View File

@ -186,15 +186,15 @@ static u8 GetAdjustedInitialDirection(struct InitialPlayerAvatarState *playerStr
static u16 GetCenterScreenMetatileBehavior(void);
// IWRAM bss vars
IWRAM_DATA static void *sUnusedOverworldCallback;
IWRAM_DATA static u8 sPlayerTradingStates[4];
static void *sUnusedOverworldCallback;
static u8 sPlayerTradingStates[4];
// This callback is called with a player's key code. It then returns an
// adjusted key code, effectively intercepting the input before anything
// can process it.
IWRAM_DATA static u16 (*sPlayerKeyInterceptCallback)(u32);
IWRAM_DATA static bool8 sUnknown_03000E18;
IWRAM_DATA static u8 sRfuKeepAliveTimer;
IWRAM_DATA static u32 sUnusedVar;
static u16 (*sPlayerKeyInterceptCallback)(u32);
static bool8 sUnknown_03000E18;
static u8 sRfuKeepAliveTimer;
static u32 sUnusedVar;
// IWRAM common
u16 *gBGTilemapBuffers1;

View File

@ -1596,8 +1596,8 @@ static void InitPartyMenu(u8 a, u8 b, u8 c, u8 d, u8 messageId, TaskFunc task, M
gUnknown_0203CEC4->task = task;
gUnknown_0203CEC4->exitCallback = NULL;
gUnknown_0203CEC4->unk8_1 = 0;
gUnknown_0203CEC4->unk8_2 = 0xFF;
gUnknown_0203CEC4->unk9_0 = 0xFF;
gUnknown_0203CEC4->unk8_2 = 0x7F;
gUnknown_0203CEC4->unk9_0 = 0x7F;
if (a == 4)
gUnknown_0203CEC4->unk8_0 = TRUE;
@ -1820,7 +1820,7 @@ static bool8 AllocPartyMenuBg(void)
static bool8 AllocPartyMiscGfx(void)
{
int sizeout;
u32 sizeout;
switch (gUnknown_0203CEC4->data[0])
{

View File

@ -763,11 +763,11 @@ static void sub_813D6B4(void)
static void CreateAreaMarkerSprites(void)
{
u8 spriteId;
static IWRAM_DATA s16 x;
static IWRAM_DATA s16 y;
static IWRAM_DATA s16 i;
static IWRAM_DATA s16 mapSecId;
static IWRAM_DATA s16 numSprites;
static s16 x;
static s16 y;
static s16 i;
static s16 mapSecId;
static s16 numSprites;
LoadSpriteSheet(&sAreaMarkerSpriteSheet);
LoadSpritePalette(&sAreaMarkerSpritePalette);

View File

@ -177,9 +177,9 @@ static void SpriteCB_SetDummyOnAnimEnd(struct Sprite *sprite);
#define STRUCT_COUNT 4
// IWRAM bss
static IWRAM_DATA struct UnkAnimStruct sUnknown_03001240[STRUCT_COUNT];
static IWRAM_DATA u8 sUnknown_03001270;
static IWRAM_DATA bool32 sUnknown_03001274;
static struct UnkAnimStruct sUnknown_03001240[STRUCT_COUNT];
static u8 sUnknown_03001270;
static bool32 sUnknown_03001274;
// const rom data
static const u8 sSpeciesToBackAnimSet[] =
@ -861,16 +861,27 @@ u8 GetSpeciesBackAnimSet(u16 species)
}
#define tState data[0]
#define tPtrLO data[1]
#define tPtrHI data[2]
#define tPtrHi data[1]
#define tPtrLo data[2]
#define tAnimId data[3]
#define tSaved0 data[4]
#define tSaved2 data[5]
// BUG: In vanilla, tPtrLo is read as an s16, so if bit 15 of the
// address were to be set it would cause the pointer to be read
// as 0xFFFFXXXX instead of the desired 0x02YYXXXX.
// By dumb luck, this is not an issue in vanilla. However,
// changing the link order revealed this bug.
#if MODERN
#define ANIM_SPRITE(taskId) ((struct Sprite *)((gTasks[taskId].tPtrHi << 16) | ((u16)gTasks[taskId].tPtrLo)))
#else
#define ANIM_SPRITE(taskId) ((struct Sprite *)((gTasks[taskId].tPtrHi << 16) | (gTasks[taskId].tPtrLo)))
#endif //MODERN
static void Task_HandleMonAnimation(u8 taskId)
{
u32 i;
struct Sprite *sprite = (struct Sprite*)(u32)((gTasks[taskId].tPtrLO << 0x10) | (gTasks[taskId].tPtrHI));
struct Sprite *sprite = ANIM_SPRITE(taskId);
if (gTasks[taskId].tState == 0)
{
@ -900,8 +911,8 @@ static void Task_HandleMonAnimation(u8 taskId)
void LaunchAnimationTaskForFrontSprite(struct Sprite *sprite, u8 frontAnimId)
{
u8 taskId = CreateTask(Task_HandleMonAnimation, 128);
gTasks[taskId].tPtrLO = (u32)(sprite) >> 0x10;
gTasks[taskId].tPtrHI = (u32)(sprite);
gTasks[taskId].tPtrHi = (u32)(sprite) >> 0x10;
gTasks[taskId].tPtrLo = (u32)(sprite);
gTasks[taskId].tAnimId = frontAnimId;
}
@ -916,8 +927,8 @@ void LaunchAnimationTaskForBackSprite(struct Sprite *sprite, u8 backAnimSet)
u8 nature, taskId, animId, battlerId;
taskId = CreateTask(Task_HandleMonAnimation, 128);
gTasks[taskId].tPtrLO = (u32)(sprite) >> 0x10;
gTasks[taskId].tPtrHI = (u32)(sprite);
gTasks[taskId].tPtrHi = (u32)(sprite) >> 0x10;
gTasks[taskId].tPtrLo = (u32)(sprite);
battlerId = sprite->data[0];
nature = GetNature(&gPlayerParty[gBattlerPartyIndexes[battlerId]]);
@ -927,8 +938,8 @@ void LaunchAnimationTaskForBackSprite(struct Sprite *sprite, u8 backAnimSet)
}
#undef tState
#undef tPtrLO
#undef tPtrHI
#undef tPtrHi
#undef tPtrLo
#undef tAnimId
#undef tSaved0
#undef tSaved2

View File

@ -269,8 +269,8 @@ int sub_802E354(int, u16, u16);
void sub_802E3A8(void);
void sub_802D12C(u8 taskId);
extern struct PokemonJump1 *gUnknown_02022CFC;
extern struct PokemonJump2 *gUnknown_02022D00;
EWRAM_DATA struct PokemonJump1 *gUnknown_02022CFC = NULL;
EWRAM_DATA struct PokemonJump2 *gUnknown_02022D00 = NULL;
const struct PokemonJumpMons gPkmnJumpSpecies[] =
{

View File

@ -443,7 +443,7 @@ enum
#define TAG_TILE_1 0x1
// IWRAM bss
IWRAM_DATA static u32 gUnknown_03000F78[98];
static u32 gUnknown_03000F78[98];
// EWRAM DATA
EWRAM_DATA static u8 sPreviousBoxOption = 0;
@ -464,6 +464,9 @@ EWRAM_DATA static u8 sMovingMonOrigBoxPos = 0;
EWRAM_DATA static bool8 sCanOnlyMove = 0;
// This file's functions.
#if !defined(NONMATCHING) && MODERN
#define static
#endif
static void CreatePCMenu(u8 whichMenu, s16 *windowIdPtr);
static void Cb2_EnterPSS(u8 boxOption);
static u8 GetCurrentBoxOption(void);

View File

@ -64,16 +64,16 @@ static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide);
static void HideLeftHeaderSprites(bool32 isOnRightSide);
static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide);
static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide);
static void MoveLeftHeader(struct Sprite *sprite, int startX, int endX, int duration);
static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration);
static void SpriteCB_MoveLeftHeader(struct Sprite *sprite);
static void InitPokenavMainMenuResources(void);
static void InitHoennMapHeaderSprites(void);
static void sub_81C7B74(void);
static u32 LoopedTask_ScrollMenuHeaderDown(int a0);
static u32 LoopedTask_ScrollMenuHeaderUp(int a0);
static u32 LoopedTask_ScrollMenuHeaderDown(s32 a0);
static u32 LoopedTask_ScrollMenuHeaderUp(s32 a0);
static void sub_81C7BF8(u32 a0);
static void SpriteCB_SpinningPokenav(struct Sprite* sprite);
static u32 LoopedTask_InitPokenavMenu(int a0);
static u32 LoopedTask_InitPokenavMenu(s32 a0);
const u16 gSpinningPokenavPaletteData[] = INCBIN_U16("graphics/pokenav/icon2.gbapal");
const u32 gSpinningPokenavGfx[] = INCBIN_U32("graphics/pokenav/icon2.4bpp.lz");
@ -360,7 +360,7 @@ bool32 WaitForPokenavShutdownFade(void)
return TRUE;
}
static u32 LoopedTask_InitPokenavMenu(int a0)
static u32 LoopedTask_InitPokenavMenu(s32 a0)
{
struct PokenavMainMenuResources *structPtr;
@ -440,7 +440,7 @@ bool32 MainMenuLoopedTaskIsBusy(void)
return IsLoopedTaskActive(structPtr->currentTaskId);
}
static u32 LoopedTask_ScrollMenuHeaderDown(int a0)
static u32 LoopedTask_ScrollMenuHeaderDown(s32 a0)
{
switch (a0)
{
@ -461,7 +461,7 @@ static u32 LoopedTask_ScrollMenuHeaderDown(int a0)
}
}
static u32 LoopedTask_ScrollMenuHeaderUp(int a0)
static u32 LoopedTask_ScrollMenuHeaderUp(s32 a0)
{
if (ChangeBgY(0, 384, 2) <= 0)
{
@ -637,7 +637,7 @@ _081C7AAE:\n\
.syntax divided");
}
void sub_81C7AC0(int a0)
void sub_81C7AC0(s32 a0)
{
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
@ -708,7 +708,7 @@ static void sub_81C7BF8(u32 windowId)
static void InitPokenavMainMenuResources(void)
{
int i;
s32 i;
u8 spriteId;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
@ -758,13 +758,13 @@ void ResumeSpinningPokenavSprite(void)
static void InitHoennMapHeaderSprites(void)
{
int i, spriteId;
s32 i, spriteId;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
LoadCompressedSpriteSheet(&sPokenavHoennMapLeftHeaderSpriteSheet);
AllocSpritePalette(1);
AllocSpritePalette(2);
for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
{
spriteId = CreateSprite(&sPokenavLeftHeaderHoennMapSpriteTemplate, 0, 0, 1);
structPtr->leftHeaderSprites[i] = &gSprites[spriteId];
@ -859,10 +859,10 @@ void sub_81C7FC4(u32 arg0, bool32 arg1)
void sub_81C7FDC(void)
{
int i;
s32 i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
{
structPtr->leftHeaderSprites[i]->invisible = TRUE;
structPtr->submenuLeftHeaderSprites[i]->invisible = TRUE;
@ -881,7 +881,7 @@ bool32 sub_81C8010(void)
static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
{
int start, end, i;
s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
if (!isOnRightSide)
@ -889,7 +889,7 @@ static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
else
start = 256, end = 160;
for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
{
structPtr->leftHeaderSprites[i]->pos1.y = startY;
MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12);
@ -898,7 +898,7 @@ static void ShowLeftHeaderSprites(u32 startY, bool32 isOnRightSide)
static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
{
int start, end, i;
s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
if (!isOnRightSide)
@ -906,7 +906,7 @@ static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
else
start = 256, end = 192;
for (i = 0; i < (int)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
{
structPtr->submenuLeftHeaderSprites[i]->pos1.y = startY;
MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12);
@ -915,7 +915,7 @@ static void ShowLeftHeaderSubmenuSprites(u32 startY, bool32 isOnRightSide)
static void HideLeftHeaderSprites(bool32 isOnRightSide)
{
int start, end, i;
s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
if (!isOnRightSide)
@ -923,7 +923,7 @@ static void HideLeftHeaderSprites(bool32 isOnRightSide)
else
start = 192, end = 256;
for (i = 0; i < (int)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->leftHeaderSprites); i++)
{
MoveLeftHeader(structPtr->leftHeaderSprites[i], start, end, 12);
}
@ -931,7 +931,7 @@ static void HideLeftHeaderSprites(bool32 isOnRightSide)
static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide)
{
int start, end, i;
s32 start, end, i;
struct PokenavMainMenuResources *structPtr = GetSubstructPtr(0);
if (!isOnRightSide)
@ -939,13 +939,13 @@ static void HideLeftHeaderSubmenuSprites(bool32 isOnRightSide)
else
start = 192, end = 256;
for (i = 0; i < (int)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
for (i = 0; i < (s32)ARRAY_COUNT(structPtr->submenuLeftHeaderSprites); i++)
{
MoveLeftHeader(structPtr->submenuLeftHeaderSprites[i], start, end, 12);
}
}
static void MoveLeftHeader(struct Sprite *sprite, int startX, int endX, int duration)
static void MoveLeftHeader(struct Sprite *sprite, s32 startX, s32 endX, s32 duration)
{
sprite->pos1.x = startX;
sprite->data[0] = startX * 16;

View File

@ -36,8 +36,8 @@ extern const u8 gText_RibbonsF700[];
extern const u8 *const gRibbonDescriptionPointers[][2];
extern const u8 *const gGiftRibbonDescriptionPointers[][2];
extern u32 gUnknown_030012C0;
extern u32 gUnknown_030012C4;
static u32 gUnknown_030012C0;
static u32 gUnknown_030012C4;
void sub_81D0E84(struct Pokenav10Struct2 *structPtr);
void sub_81D0FF0(struct Pokenav10Struct2 *structPtr);

View File

@ -34,7 +34,7 @@ static u32 sub_81CABFC(struct Pokenav3Struct *);
static u32 sub_81CAC04(struct Pokenav3Struct *);
static u32 sub_81CACB8(struct Pokenav3Struct *);
static u32 sub_81CACF8(struct Pokenav3Struct *);
static u32 sub_81CAD20(int);
static u32 sub_81CAD20(s32);
static bool32 sub_81CB1D0(void);
extern const u8 gUnknown_08622508[];
@ -190,7 +190,7 @@ static u32 sub_81CACF8(struct Pokenav3Struct *state)
return 0;
}
static u32 sub_81CAD20(int taskState)
static u32 sub_81CAD20(s32 taskState)
{
int i, j;
struct Pokenav3Struct *state = GetSubstructPtr(5);

View File

@ -50,7 +50,7 @@ struct Pokenav4Struct
};
static bool32 sub_81CB310(void);
static u32 sub_81CB324(int);
static u32 sub_81CB324(s32);
static void sub_81CBBB8(void);
static void sub_81CBC1C(void);
static void sub_81CC2B4(void);
@ -156,7 +156,7 @@ static bool32 sub_81CB310(void)
return IsLoopedTaskActive(state->unk4);
}
static u32 sub_81CB324(int taskState)
static u32 sub_81CB324(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -229,7 +229,7 @@ static u32 sub_81CB324(int taskState)
}
}
u32 sub_81CB510(int taskState)
u32 sub_81CB510(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -266,7 +266,7 @@ u32 sub_81CB510(int taskState)
return 4;
}
u32 sub_81CB588(int taskState)
u32 sub_81CB588(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -303,7 +303,7 @@ u32 sub_81CB588(int taskState)
return 4;
}
u32 sub_81CB600(int taskState)
u32 sub_81CB600(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -340,7 +340,7 @@ u32 sub_81CB600(int taskState)
return 4;
}
u32 sub_81CB678(int taskState)
u32 sub_81CB678(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -377,7 +377,7 @@ u32 sub_81CB678(int taskState)
return 4;
}
u32 sub_81CB6F0(int taskState)
u32 sub_81CB6F0(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -396,7 +396,7 @@ u32 sub_81CB6F0(int taskState)
return 4;
}
u32 sub_81CB734(int taskState)
u32 sub_81CB734(s32 taskState)
{
struct Pokenav4Struct *state;
u16 var0;
@ -408,7 +408,7 @@ u32 sub_81CB734(int taskState)
return 4;
}
u32 sub_81CB75C(int taskState)
u32 sub_81CB75C(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -427,7 +427,7 @@ u32 sub_81CB75C(int taskState)
return 4;
}
u32 sub_81CB7A0(int taskState)
u32 sub_81CB7A0(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -459,7 +459,7 @@ u32 sub_81CB7A0(int taskState)
return 4;
}
u32 sub_81CB824(int taskState)
u32 sub_81CB824(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -485,7 +485,7 @@ u32 sub_81CB824(int taskState)
return 4;
}
u32 sub_81CB888(int taskState)
u32 sub_81CB888(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
u32 result = 0;
@ -549,7 +549,7 @@ u32 sub_81CB888(int taskState)
return result;
}
u32 sub_81CB93C(int taskState)
u32 sub_81CB93C(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -578,7 +578,7 @@ u32 sub_81CB93C(int taskState)
return 4;
}
u32 sub_81CB9C8(int taskState)
u32 sub_81CB9C8(s32 taskState)
{
int index;
int var0;
@ -617,7 +617,7 @@ u32 sub_81CB9C8(int taskState)
return 4;
}
u32 sub_81CBA68(int taskState)
u32 sub_81CBA68(s32 taskState)
{
struct Pokenav4Struct *state = GetSubstructPtr(6);
switch (taskState)
@ -643,7 +643,7 @@ u32 sub_81CBA68(int taskState)
return 4;
}
u32 sub_81CBAD4(int taskState)
u32 sub_81CBAD4(s32 taskState)
{
int index;
int var0;
@ -682,7 +682,7 @@ u32 sub_81CBAD4(int taskState)
return 4;
}
u32 sub_81CBB74(int taskState)
u32 sub_81CBB74(s32 taskState)
{
switch (taskState)
{

View File

@ -42,8 +42,8 @@ struct CityZoomPic
static u32 sub_81CC568(struct Pokenav5Struct *);
static u32 sub_81CC5B4(struct Pokenav5Struct *);
static u32 sub_81CC5DC(struct Pokenav5Struct *);
static u32 sub_81CC6F4(int);
static u32 sub_81CCD34(int);
static u32 sub_81CC6F4(s32);
static u32 sub_81CCD34(s32);
static bool32 sub_81CC6BC(void);
static void sub_81CC9EC(void);
static void sub_81CC9C0(void);
@ -202,7 +202,7 @@ static bool8 sub_81CC6D0(void)
return gSaveBlock2Ptr->regionMapZoom == 1;
}
static u32 sub_81CC6F4(int taskState)
static u32 sub_81CC6F4(s32 taskState)
{
int var0;
struct RegionMap *regionMap;
@ -518,7 +518,7 @@ static bool32 sub_81CCD24(void)
return FuncIsActiveLoopedTask(sub_81CCD34);
}
static u32 sub_81CCD34(int taskState)
static u32 sub_81CCD34(s32 taskState)
{
struct Pokenav5Struct_2 *state = GetSubstructPtr(4);
if (taskState < (int)ARRAY_COUNT(gUnknown_08623118))

3
src/pokenav_unk_7.c Normal file
View File

@ -0,0 +1,3 @@
#include "global.h"
BSS_DATA u8 gUnknown_030012BC;

View File

@ -8,8 +8,8 @@ EWRAM_DATA static u8 sUnknown = 0;
EWRAM_DATA static u32 sRandCount = 0;
// IWRAM common
IWRAM_DATA u32 gRngValue;
IWRAM_DATA u32 gRng2Value;
u32 gRngValue;
u32 gRng2Value;
u16 Random(void)
{

View File

@ -82,21 +82,21 @@ union PlayerRecords
// Static RAM declarations
static IWRAM_DATA bool8 gUnknown_03001130;
static IWRAM_DATA struct SecretBase *sSecretBasesSave;
static IWRAM_DATA TVShow *sTvShowsSave;
static IWRAM_DATA PokeNews *sPokeNewsSave;
static IWRAM_DATA OldMan *sOldManSave;
static IWRAM_DATA struct EasyChatPair *sEasyChatPairsSave;
static IWRAM_DATA struct RecordMixingDayCareMail *gUnknown_03001148;
static IWRAM_DATA void *sBattleTowerSave;
static IWRAM_DATA LilycoveLady *sLilycoveLadySave;
static IWRAM_DATA void *sApprenticesSave;
static IWRAM_DATA void *sBattleTowerSave_Duplicate;
static IWRAM_DATA u32 sRecordStructSize;
static IWRAM_DATA u8 gUnknown_03001160;
static IWRAM_DATA u32 filler_03001164;
static IWRAM_DATA struct PlayerHallRecords *gUnknown_03001168[3];
static bool8 gUnknown_03001130;
static struct SecretBase *sSecretBasesSave;
static TVShow *sTvShowsSave;
static PokeNews *sPokeNewsSave;
static OldMan *sOldManSave;
static struct EasyChatPair *sEasyChatPairsSave;
static struct RecordMixingDayCareMail *gUnknown_03001148;
static void *sBattleTowerSave;
static LilycoveLady *sLilycoveLadySave;
static void *sApprenticesSave;
static void *sBattleTowerSave_Duplicate;
static u32 sRecordStructSize;
static u8 gUnknown_03001160;
static u32 filler_03001164;
static struct PlayerHallRecords *gUnknown_03001168[3];
static EWRAM_DATA struct RecordMixingDayCareMail gUnknown_02039F9C = {0};
static EWRAM_DATA union PlayerRecords *sReceivedRecords = NULL;

View File

@ -100,8 +100,8 @@ EWRAM_DATA static u8 sApprenticeId = 0;
EWRAM_DATA static u16 sEasyChatSpeech[6] = {0};
EWRAM_DATA static u8 sBattleOutcome = 0;
IWRAM_DATA static u8 sRecordMixFriendLanguage;
IWRAM_DATA static u8 sApprenticeLanguage;
static u8 sRecordMixFriendLanguage;
static u8 sApprenticeLanguage;
// this file's functions
static u8 sub_8185278(u8 *arg0, u8 *arg1, u8 *arg2);

View File

@ -142,7 +142,7 @@ static const union AnimCmd sSpriteAnim_85104CC[] =
static const union AnimCmd sSpriteAnim_85104D4[] =
{
ANIMCMD_FRAME(0, 158, .vFlip = TRUE),
ANIMCMD_FRAME(0, 30, .vFlip = TRUE),
ANIMCMD_JUMP(0),
};

View File

@ -14,7 +14,7 @@ void sub_81700F8(void)
imeBackup = REG_IME;
REG_IME = 0;
RegisterRamReset(0x00000001);
RegisterRamReset(RESET_EWRAM);
ClearGpuRegBits(REG_OFFSET_DISPCNT, DISPCNT_FORCED_BLANK);
REG_IME = imeBackup;
gMain.inBattle = FALSE;

View File

@ -43,9 +43,9 @@ static bool32 SharesPalWithAnyActive(u32 id);
static void sub_8035648(void);
// iwram
static IWRAM_DATA s32 gUnknown_03000DD4;
static IWRAM_DATA s32 gUnknown_03000DD8;
static IWRAM_DATA s32 gUnknown_03000DDC;
static s32 gUnknown_03000DD4;
static s32 gUnknown_03000DD8;
static s32 gUnknown_03000DDC;
// ewram
static EWRAM_DATA struct UnkStruct1 *gUnknown_02022E10 = {0};

View File

@ -3994,8 +3994,8 @@ static void sub_8144514(struct Sprite *sprite)
if (gUnknown_0203AB88->var94 > 40.f)
return;
gUnknown_0203AB88->var98 = -(4.0f / (float)gUnknown_0203AB88->var86);
gUnknown_0203AB88->var90 = -(gUnknown_0203AB88->var8C / (float)gUnknown_0203AB88->var86);
gUnknown_0203AB88->var98 = -(4.0f / (float)(gUnknown_0203AB88->var86));
gUnknown_0203AB88->var90 = -(gUnknown_0203AB88->var8C / (float)(gUnknown_0203AB88->var86));
sprite->animNum = 2;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;
@ -4010,8 +4010,8 @@ static void sub_81445D8(struct Sprite *sprite)
return;
m4aSongNumStartOrChange(SE_TAMAKORO_E);
gUnknown_0203AB88->var98 = -(20.0f / (float)gUnknown_0203AB88->var84);
gUnknown_0203AB88->var90 = ((1.0f - gUnknown_0203AB88->var8C) / (float)gUnknown_0203AB88->var84);
gUnknown_0203AB88->var98 = -(20.0f / (float)(gUnknown_0203AB88->var84));
gUnknown_0203AB88->var90 = ((1.0f - gUnknown_0203AB88->var8C) / (float)(gUnknown_0203AB88->var84));
sprite->animNum = 1;
sprite->animBeginning = TRUE;
sprite->animEnded = FALSE;

View File

@ -408,7 +408,8 @@ void UpdatePulseBlend(struct PulseBlend *pulseBlend)
}
}
break;
case 2: // Flip back and forth
case (MODERN ? -2 : 2): // Flip back and forth
// This code is never reached in vanilla
if (pulseBlendPalette->fadeDirection)
pulseBlendPalette->blendCoeff = 0;
else

View File

@ -4,10 +4,10 @@
#include "text.h"
// iwram bss
IWRAM_DATA static u16 sErrorStatus;
IWRAM_DATA static struct SiiRtcInfo sRtc;
IWRAM_DATA static u8 sProbeResult;
IWRAM_DATA static u16 sSavedIme;
static u16 sErrorStatus;
static struct SiiRtcInfo sRtc;
static u8 sProbeResult;
static u16 sSavedIme;
// iwram common
struct Time gLocalTime;

View File

@ -626,7 +626,10 @@ static u16 CalculateChecksum(void *data, u16 size)
u32 checksum = 0;
for (i = 0; i < (size / 4); i++)
checksum += *((u32 *)data)++;
{
checksum += *((u32 *)data);
data += sizeof(u32);
}
return ((checksum >> 16) + checksum);
}

View File

@ -62,7 +62,7 @@ static EWRAM_DATA u16 sMovingNpcMapBank = 0;
static EWRAM_DATA u16 sMovingNpcMapId = 0;
static EWRAM_DATA u16 sFieldEffectScriptId = 0;
IWRAM_DATA u8 gUnknown_03000F30;
static u8 gUnknown_03000F30;
extern const SpecialFunc gSpecials[];
extern const u8 *gStdScripts[];

View File

@ -10,12 +10,12 @@
extern const u8* gUnknown_020375C0;
// ewram bss
IWRAM_DATA static u8 sScriptContext1Status;
IWRAM_DATA static u32 sUnusedVariable1;
IWRAM_DATA static struct ScriptContext sScriptContext1;
IWRAM_DATA static u32 sUnusedVariable2;
IWRAM_DATA static struct ScriptContext sScriptContext2;
IWRAM_DATA static bool8 sScriptContext2Enabled;
static u8 sScriptContext1Status;
static u32 sUnusedVariable1;
static struct ScriptContext sScriptContext1;
static u32 sUnusedVariable2;
static struct ScriptContext sScriptContext2;
static bool8 sScriptContext2Enabled;
extern ScrCmdFunc gScriptCmdTable[];
extern ScrCmdFunc gScriptCmdTableEnd[];

View File

@ -1017,8 +1017,8 @@ const u8 *const gUnknown_0858BBEC[] =
EWRAM_DATA u8 gUnknown_02039F90 = 0;
IWRAM_DATA u8 gUnknown_03001124[7];
IWRAM_DATA u32 filler_0300112c;
static u8 gUnknown_03001124[7];
static u32 filler_0300112c;
static void Task_HandleMultichoiceInput(u8);
static void Task_HandleYesNoInput(u8);

View File

@ -71,7 +71,7 @@ static EWRAM_DATA struct SecretBaseRegistryMenu *sRegistryMenu = NULL;
static void Task_ShowSecretBaseRegistryMenu(u8 taskId);
static void BuildRegistryMenuItems(u8 taskId);
static void RegistryMenu_OnCursorMove(int unused, bool8 flag, struct ListMenu *menu);
static void RegistryMenu_OnCursorMove(s32 unused, bool8 flag, struct ListMenu *menu);
static void FinalizeRegistryMenu(u8 taskId);
static void AddRegistryMenuScrollArrows(u8 taskId);
static void HandleRegistryMenuInput(u8 taskId);
@ -932,7 +932,7 @@ static void BuildRegistryMenuItems(u8 taskId)
gMultiuseListMenuTemplate.maxShowed = data[3];
}
static void RegistryMenu_OnCursorMove(int unused, bool8 flag, struct ListMenu *menu)
static void RegistryMenu_OnCursorMove(s32 unused, bool8 flag, struct ListMenu *menu)
{
if (flag != TRUE)
PlaySE(SE_SELECT);

View File

@ -87,8 +87,8 @@ static void Task_ReturnToItemListAfterItemPurchase(u8 taskId);
static void Task_ReturnToItemListAfterDecorationPurchase(u8 taskId);
static void Task_HandleShopMenuBuy(u8 taskId);
static void Task_HandleShopMenuSell(u8 taskId);
static void BuyMenuPrintItemDescriptionAndShowItemIcon(int item, bool8 onInit, struct ListMenu *list);
static void BuyMenuPrintPriceInList(u8 windowId, int item, u8 y);
static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, struct ListMenu *list);
static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y);
static const struct YesNoFuncTable sShopPurchaseYesNoFuncs =
{
@ -521,7 +521,7 @@ static void BuyMenuSetListEntry(struct ListMenuItem *menuItem, u16 item, u8 *nam
menuItem->id = item;
}
static void BuyMenuPrintItemDescriptionAndShowItemIcon(int item, bool8 onInit, struct ListMenu *list)
static void BuyMenuPrintItemDescriptionAndShowItemIcon(s32 item, bool8 onInit, struct ListMenu *list)
{
const u8 *description;
if (onInit != TRUE)
@ -550,7 +550,7 @@ static void BuyMenuPrintItemDescriptionAndShowItemIcon(int item, bool8 onInit, s
BuyMenuPrint(2, description, 3, 1, 0, 0);
}
static void BuyMenuPrintPriceInList(u8 windowId, int item, u8 y)
static void BuyMenuPrintPriceInList(u8 windowId, s32 item, u8 y)
{
u8 x;

View File

@ -350,7 +350,7 @@ static EWRAM_DATA struct SpriteSheet *sUnknown_0203AB30 = NULL;
static EWRAM_DATA struct SlotMachineEwramStruct *sSlotMachine = NULL;
// IWRAM bss
static IWRAM_DATA struct SpriteFrameImage *gUnknown_03001188[26];
static struct SpriteFrameImage *gUnknown_03001188[26];
// Const rom data.
extern const struct UnkStruct1 *const gUnknown_083ED048[];

View File

@ -19,11 +19,11 @@ EWRAM_DATA struct MusicPlayerInfo* gMPlay_PokemonCry = NULL;
EWRAM_DATA u8 gPokemonCryBGMDuckingCounter = 0;
// iwram bss
IWRAM_DATA static u16 sCurrentMapMusic;
IWRAM_DATA static u16 sNextMapMusic;
IWRAM_DATA static u8 sMapMusicState;
IWRAM_DATA static u8 sMapMusicFadeInSpeed;
IWRAM_DATA static u16 sFanfareCounter;
static u16 sCurrentMapMusic;
static u16 sNextMapMusic;
static u8 sMapMusicState;
static u8 sMapMusicFadeInSpeed;
static u16 sFanfareCounter;
// iwram common
bool8 gDisableMusic;

View File

@ -285,10 +285,10 @@ static const struct OamDimensions sOamDimensions[3][4] =
};
// iwram bss
IWRAM_DATA static u16 sSpriteTileRangeTags[MAX_SPRITES];
IWRAM_DATA static u16 sSpriteTileRanges[MAX_SPRITES * 2];
IWRAM_DATA static struct AffineAnimState sAffineAnimStates[OAM_MATRIX_COUNT];
IWRAM_DATA static u16 sSpritePaletteTags[16];
static u16 sSpriteTileRangeTags[MAX_SPRITES];
static u16 sSpriteTileRanges[MAX_SPRITES * 2];
static struct AffineAnimState sAffineAnimStates[OAM_MATRIX_COUNT];
static u16 sSpritePaletteTags[16];
// iwram common
u32 gOamMatrixAllocBitmap;

View File

@ -51,7 +51,7 @@ void sub_81346DC(struct Sprite *sprite);
void sub_813473C(struct Sprite *sprite);
void StarterPokemonSpriteCallback(struct Sprite *sprite);
static IWRAM_DATA u16 sStarterChooseWindowId;
static u16 sStarterChooseWindowId;
// .rodata
const u16 gBirchBagGrassPal[][16] =

View File

@ -158,6 +158,9 @@ static EWRAM_DATA struct {
/*0xFE*/ u8 unk_FE;
} *gUnknown_020322A0 = {NULL};
#if !defined(NONMATCHING) && MODERN
#define static
#endif
static bool32 sub_8077260(void);
static void sub_80773D0(void);
static void sub_807811C(void);
@ -2779,7 +2782,7 @@ static void sub_8079398(void)
}
}
static void DisplayMessageAndContinueTask(void)
static void Wait2SecondsAndCreateYesNoMenu(void)
{
gUnknown_0203229C->unk_A8++;
@ -2918,7 +2921,7 @@ static void sub_80795AC(void)
sub_80781C8();
break;
case 14:
DisplayMessageAndContinueTask();
Wait2SecondsAndCreateYesNoMenu();
break;
case 15:
sub_8079034();

View File

@ -56,9 +56,9 @@ struct {
u16 move;
} sTV_SecretBaseVisitMonsTemp[10];
IWRAM_DATA u8 sTVShowMixingNumPlayers;
IWRAM_DATA u8 sTVShowNewsMixingNumPlayers;
IWRAM_DATA s8 sTVShowMixingCurSlot;
static u8 sTVShowMixingNumPlayers;
static u8 sTVShowNewsMixingNumPlayers;
static s8 sTVShowMixingCurSlot;
EWRAM_DATA u16 sPokemonAnglerSpecies = 0;
EWRAM_DATA u16 sPokemonAnglerAttemptCounters = 0;
@ -69,10 +69,9 @@ EWRAM_DATA ALIGNED(4) u8 sTVShowState = 0;
EWRAM_DATA u8 sTVSecretBaseSecretsRandomValues[3] = {};
// Static ROM declarations
extern const u8 *const sTVBravoTrainerTextGroup[];
extern const u8 *const sTVBravoTrainerBattleTowerTextGroup[];
#if !defined(NONMATCHING) && MODERN
#define static
#endif
void ClearPokemonNews(void);
u8 GetTVChannelByShowType(u8 kind);
u8 FindFirstActiveTVShowThatIsNotAMassOutbreak(void);

View File

@ -60,9 +60,9 @@ EWRAM_DATA u8 gUnknown_02022C3E = 0;
EWRAM_DATA struct TradeUnkStruct gUnknown_02022C40 = {};
// IWRAM vars
IWRAM_DATA struct UnkStruct_Leader *gUnknown_03000DA0;
IWRAM_DATA struct UnkStruct_Group *gUnknown_03000DA4;
IWRAM_DATA struct UnkStruct_URoom *gUnknown_03000DA8;
static struct UnkStruct_Leader *gUnknown_03000DA0;
static struct UnkStruct_Group *gUnknown_03000DA4;
static struct UnkStruct_URoom *gUnknown_03000DA8;
// this file's functions
void sub_80173E0(u8 windowId, u8 arg1, const u8 *str, u8 arg3, u8 arg4, u8 arg5);

View File

@ -40,7 +40,7 @@ struct UnkStruct_2022C6C
s16 a0;
};
IWRAM_DATA struct UnkStruct_3000DAC * gUnknown_03000DAC;
static struct UnkStruct_3000DAC * gUnknown_03000DAC;
EWRAM_DATA struct UnkStruct_2022C6C * gUnknown_02022C6C = NULL;

View File

@ -47,17 +47,8 @@
.include "src/multiboot.o"
.include "src/mirage_tower.o"
.include "src/berry_fix_program.o"
@ pokenav
gUnknown_030012BC: @ 30012BC
.space 0x4
gUnknown_030012C0: @ 30012C0
.space 0x4
gUnknown_030012C4: @ 30012C4
.space 0x4
.include "src/pokenav_unk_7.o"
.include "src/pokenav_unk_10.o"
.include "src/ereader_helpers.o"
.include "src/faraway_island.o"
.include "asm/m4a_1.o"

View File

@ -45,29 +45,8 @@
.space 0x44
gUnknown_03006370: @ 3006370
.space 0x10
.include "ereader_screen.o"
.include "m4a.o"
.include "agb_flash.o"
gRfuState: @ 3007868
.space 0x8
gUnknown_03007870: @ 3007870
.space 0x10
gUnknown_03007880: @ 3007880
.space 0x10
gUnknown_03007890: @ 3007890
.space 0x4
gUnknown_03007894: @ 3007894
.space 0x4
gUnknown_03007898: @ 3007898
.space 0x8
gUnknown_030078A0: @ 30078A0
.space 0xC
.include "librfu_stwi.o"
.include "librfu.o"

View File

@ -18,14 +18,7 @@
.include "src/berry_crush.o"
.include "src/berry_powder.o"
.include "src/dodrio_berry_picking.o"
@ pokemon_jump
gUnknown_02022CFC: @ 2022CFC
.space 0x4
gUnknown_02022D00: @ 2022D00
.space 0x4
.include "src/pokemon_jump.o"
.include "src/main_menu.o"
.include "src/battle_controllers.o"
.include "src/rom_8034C54.o"

3147
tools/gbafix/elf.h Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,45 +1,46 @@
/*
"$Id: gbafix.c,v 1.2 2008-07-30 17:12:51 wntrmute Exp $"
"$Id: gbafix.c,v 1.2 2008-07-30 17:12:51 wntrmute Exp $"
DevkitPro GBA ROM fix utility
DevkitPro GBA ROM fix utility
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA.
Please report all bugs and problems through the bug tracker at
"http://sourceforge.net/tracker/?group_id=114505&atid=668551".
Please report all bugs and problems through the bug tracker at
"http://sourceforge.net/tracker/?group_id=114505&atid=668551".
"$Header: /lvm/shared/ds/ds/cvs/devkitpro-cvsbackup/tools/gba/gbatools/gbafix.c,v 1.2 2008-07-30 17:12:51 wntrmute Exp $"
"$Header: /lvm/shared/ds/ds/cvs/devkitpro-cvsbackup/tools/gba/gbatools/gbafix.c,v 1.2 2008-07-30 17:12:51 wntrmute Exp $"
*/
//---------------------------------------------------------------------------------
// gbafix.c
//---------------------------------------------------------------------------------
/*
Gameboy Advance ROM fixer (by Dark Fader / BlackThunder / WinterMute / Diegoisawesome)
Validates header of GBA roms.
Gameboy Advance ROM fixer (by Dark Fader / BlackThunder / WinterMute / Diegoisawesome)
Validates header of GBA roms.
History
-------
v1.06 - added output silencing, (Diegoisawesome)
v1.05 - added debug offset argument, (Diegoisawesome)
v1.04 - converted to plain C, (WinterMute)
v1.03 - header.fixed, header.device_type
v1.02 - redefined the options (rgbfix style), checksum=0
v1.01 - fix in parameters
v1.00 - logo, complement
History
-------
v1.07 - added support for ELF input, (PikalaxALT)
v1.06 - added output silencing, (Diegoisawesome)
v1.05 - added debug offset argument, (Diegoisawesome)
v1.04 - converted to plain C, (WinterMute)
v1.03 - header.fixed, header.device_type
v1.02 - redefined the options (rgbfix style), checksum=0
v1.01 - fix in parameters
v1.00 - logo, complement
*/
#pragma pack(1)
@ -48,26 +49,27 @@
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include "elf.h"
#define VER "1.06"
#define ARGV argv[arg]
#define VALUE (ARGV+2)
#define NUMBER strtoul(VALUE, NULL, 0)
#define VER "1.07"
#define ARGV argv[arg]
#define VALUE (ARGV+2)
#define NUMBER strtoul(VALUE, NULL, 0)
typedef struct
{
uint32_t start_code; // B instruction
uint8_t logo[0xA0-0x04]; // logo data
uint8_t title[0xC]; // game title name
uint32_t game_code; //
uint16_t maker_code; //
uint8_t fixed; // 0x96
uint8_t unit_code; // 0x00
uint8_t device_type; // 0x00
uint8_t unused[7]; //
uint8_t game_version; // 0x00
uint8_t complement; // 800000A0..800000BC
uint16_t checksum; // 0x0000
uint32_t start_code; // B instruction
uint8_t logo[0xA0-0x04]; // logo data
uint8_t title[0xC]; // game title name
uint32_t game_code; //
uint16_t maker_code; //
uint8_t fixed; // 0x96
uint8_t unit_code; // 0x00
uint8_t device_type; // 0x00
uint8_t unused[7]; //
uint8_t game_version; // 0x00
uint8_t complement; // 800000A0..800000BC
uint16_t checksum; // 0x0000
} Header;
@ -77,55 +79,55 @@ unsigned short checksum_without_header = 0;
const Header good_header =
{
// start_code
0xEA00002E,
// logo
{ 0x24,0xFF,0xAE,0x51,0x69,0x9A,0xA2,0x21,0x3D,0x84,0x82,0x0A,0x84,0xE4,0x09,0xAD,
0x11,0x24,0x8B,0x98,0xC0,0x81,0x7F,0x21,0xA3,0x52,0xBE,0x19,0x93,0x09,0xCE,0x20,
0x10,0x46,0x4A,0x4A,0xF8,0x27,0x31,0xEC,0x58,0xC7,0xE8,0x33,0x82,0xE3,0xCE,0xBF,
0x85,0xF4,0xDF,0x94,0xCE,0x4B,0x09,0xC1,0x94,0x56,0x8A,0xC0,0x13,0x72,0xA7,0xFC,
0x9F,0x84,0x4D,0x73,0xA3,0xCA,0x9A,0x61,0x58,0x97,0xA3,0x27,0xFC,0x03,0x98,0x76,
0x23,0x1D,0xC7,0x61,0x03,0x04,0xAE,0x56,0xBF,0x38,0x84,0x00,0x40,0xA7,0x0E,0xFD,
0xFF,0x52,0xFE,0x03,0x6F,0x95,0x30,0xF1,0x97,0xFB,0xC0,0x85,0x60,0xD6,0x80,0x25,
0xA9,0x63,0xBE,0x03,0x01,0x4E,0x38,0xE2,0xF9,0xA2,0x34,0xFF,0xBB,0x3E,0x03,0x44,
0x78,0x00,0x90,0xCB,0x88,0x11,0x3A,0x94,0x65,0xC0,0x7C,0x63,0x87,0xF0,0x3C,0xAF,
0xD6,0x25,0xE4,0x8B,0x38,0x0A,0xAC,0x72,0x21,0xD4,0xF8,0x07 } ,
// title
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// game code
0x00000000,
// maker code
0x3130,
// fixed
0x96,
// unit_code
0x00,
// device type
0x00,
// unused
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// game version
0x00,
// complement
0x00,
// checksum
0x0000
// start_code
0xEA00002E,
// logo
{ 0x24,0xFF,0xAE,0x51,0x69,0x9A,0xA2,0x21,0x3D,0x84,0x82,0x0A,0x84,0xE4,0x09,0xAD,
0x11,0x24,0x8B,0x98,0xC0,0x81,0x7F,0x21,0xA3,0x52,0xBE,0x19,0x93,0x09,0xCE,0x20,
0x10,0x46,0x4A,0x4A,0xF8,0x27,0x31,0xEC,0x58,0xC7,0xE8,0x33,0x82,0xE3,0xCE,0xBF,
0x85,0xF4,0xDF,0x94,0xCE,0x4B,0x09,0xC1,0x94,0x56,0x8A,0xC0,0x13,0x72,0xA7,0xFC,
0x9F,0x84,0x4D,0x73,0xA3,0xCA,0x9A,0x61,0x58,0x97,0xA3,0x27,0xFC,0x03,0x98,0x76,
0x23,0x1D,0xC7,0x61,0x03,0x04,0xAE,0x56,0xBF,0x38,0x84,0x00,0x40,0xA7,0x0E,0xFD,
0xFF,0x52,0xFE,0x03,0x6F,0x95,0x30,0xF1,0x97,0xFB,0xC0,0x85,0x60,0xD6,0x80,0x25,
0xA9,0x63,0xBE,0x03,0x01,0x4E,0x38,0xE2,0xF9,0xA2,0x34,0xFF,0xBB,0x3E,0x03,0x44,
0x78,0x00,0x90,0xCB,0x88,0x11,0x3A,0x94,0x65,0xC0,0x7C,0x63,0x87,0xF0,0x3C,0xAF,
0xD6,0x25,0xE4,0x8B,0x38,0x0A,0xAC,0x72,0x21,0xD4,0xF8,0x07 } ,
// title
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// game code
0x00000000,
// maker code
0x3130,
// fixed
0x96,
// unit_code
0x00,
// device type
0x00,
// unused
{ 0x00,0x00,0x00,0x00,0x00,0x00,0x00 },
// game version
0x00,
// complement
0x00,
// checksum
0x0000
};
//---------------------------------------------------------------------------------
char HeaderComplement()
/*---------------------------------------------------------------------------------
Calculate Header complement check
Calculate Header complement check
---------------------------------------------------------------------------------*/
{
int n;
char c = 0;
char *p = (char *)&header + 0xA0;
for (n=0; n<0xBD-0xA0; n++)
{
c += *p++;
}
return -(0x19+c);
int n;
char c = 0;
char *p = (char *)&header + 0xA0;
for (n=0; n<0xBD-0xA0; n++)
{
c += *p++;
}
return -(0x19+c);
}
@ -133,157 +135,183 @@ char HeaderComplement()
int main(int argc, char *argv[])
//---------------------------------------------------------------------------------
{
int arg;
char *argfile = 0;
FILE *infile;
int silent = 0;
int arg;
char *argfile = 0;
FILE *infile;
int silent = 0;
int schedule_pad = 0;
int size,bit;
int size,bit;
// show syntax
if (argc <= 1)
{
printf("GBA ROM fixer v"VER" by Dark Fader / BlackThunder / WinterMute / Diegoisawesome \n");
printf("Syntax: gbafix <rom.gba> [-p] [-t[title]] [-c<game_code>] [-m<maker_code>] [-r<version>] [-d<debug>] [--silent]\n");
printf("\n");
printf("parameters:\n");
printf(" -p Pad to next exact power of 2. No minimum size!\n");
printf(" -t[<title>] Patch title. Stripped filename if none given.\n");
printf(" -c<game_code> Patch game code (four characters)\n");
printf(" -m<maker_code> Patch maker code (two characters)\n");
printf(" -r<version> Patch game version (number)\n");
printf(" -d<debug> Enable debugging handler and set debug entry point (0 or 1)\n");
printf(" --silent Silence non-error output\n");
return -1;
}
// show syntax
if (argc <= 1)
{
printf("GBA ROM fixer v"VER" by Dark Fader / BlackThunder / WinterMute / Diegoisawesome \n");
printf("Syntax: gbafix <rom.gba> [-p] [-t[title]] [-c<game_code>] [-m<maker_code>] [-r<version>] [-d<debug>] [--silent]\n");
printf("\n");
printf("parameters:\n");
printf(" -p Pad to next exact power of 2. No minimum size!\n");
printf(" -t[<title>] Patch title. Stripped filename if none given.\n");
printf(" -c<game_code> Patch game code (four characters)\n");
printf(" -m<maker_code> Patch maker code (two characters)\n");
printf(" -r<version> Patch game version (number)\n");
printf(" -d<debug> Enable debugging handler and set debug entry point (0 or 1)\n");
printf(" --silent Silence non-error output\n");
return -1;
}
// get filename
for (arg=1; arg<argc; arg++)
{
if (ARGV[0] != '-') { argfile=ARGV; }
if (strncmp("--silent", &ARGV[0], 7) == 0) { silent = 1; }
}
// get filename
for (arg=1; arg<argc; arg++)
{
if (ARGV[0] != '-') { argfile=ARGV; }
if (strncmp("--silent", &ARGV[0], 7) == 0) { silent = 1; }
}
// check filename
if (!argfile)
{
fprintf(stderr, "Filename needed!\n");
return -1;
}
// check filename
if (!argfile)
{
fprintf(stderr, "Filename needed!\n");
return -1;
}
// read file
infile = fopen(argfile, "r+b");
if (!infile) { fprintf(stderr, "Error opening input file!\n"); return -1; }
fseek(infile, 0, SEEK_SET);
fread(&header, sizeof(header), 1, infile);
uint32_t sh_offset = 0;
// fix some data
memcpy(header.logo, good_header.logo, sizeof(header.logo));
memcpy(&header.fixed, &good_header.fixed, sizeof(header.fixed));
memcpy(&header.device_type, &good_header.device_type, sizeof(header.device_type));
// read file
infile = fopen(argfile, "r+b");
if (!infile) { fprintf(stderr, "Error opening input file!\n"); return -1; }
fseek(infile, sh_offset, SEEK_SET);
fread(&header, sizeof(header), 1, infile);
// parse command line
for (arg=1; arg<argc; arg++)
{
if ((ARGV[0] == '-'))
{
switch (ARGV[1])
{
case 'p': // pad
{
fseek(infile, 0, SEEK_END);
size = ftell(infile);
for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break;
if (size != (1<<bit))
{
int todo = (1<<(bit+1)) - size;
while (todo--) fputc(0xFF, infile);
}
fseek(infile, 0, SEEK_SET);
break;
}
// elf check
Elf32_Shdr secHeader;
if (memcmp(&header, ELFMAG, 4) == 0) {
Elf32_Ehdr *elfHeader = (Elf32_Ehdr *)&header;
fseek(infile, elfHeader->e_shoff, SEEK_SET);
int i;
for (i = 0; i < elfHeader->e_shnum; i++) {
fread(&secHeader, sizeof(Elf32_Shdr), 1, infile);
if (secHeader.sh_type == SHT_PROGBITS && secHeader.sh_addr == elfHeader->e_entry) break;
}
if (i == elfHeader->e_shnum) { fprintf(stderr, "Error finding entry point!\n"); return 1; }
fseek(infile, secHeader.sh_offset, SEEK_SET);
sh_offset = secHeader.sh_offset;
fread(&header, sizeof(header), 1, infile);
}
case 't': // title
{
char title[256];
memset(title, 0, sizeof(title));
if (VALUE[0])
{
strncpy(title, VALUE, sizeof(header.title));
}
else
{
// use filename
char s[256], *begin=s, *t; strcpy(s, argfile);
t = strrchr(s, '\\'); if (t) begin = t+1;
t = strrchr(s, '/'); if (t) begin = t+1;
t = strrchr(s, '.'); if (t) *t = 0;
strncpy(title, begin, sizeof(header.title));
if (!silent) printf("%s\n",begin);
}
memcpy(header.title, title, sizeof(header.title)); // copy
break;
}
// fix some data
memcpy(header.logo, good_header.logo, sizeof(header.logo));
memcpy(&header.fixed, &good_header.fixed, sizeof(header.fixed));
memcpy(&header.device_type, &good_header.device_type, sizeof(header.device_type));
case 'c': // game code
{
//if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
//header.game_code = NUMBER;
header.game_code = VALUE[0] | VALUE[1]<<8 | VALUE[2]<<16 | VALUE[3]<<24;
break;
}
// parse command line
for (arg=1; arg<argc; arg++)
{
if ((ARGV[0] == '-'))
{
switch (ARGV[1])
{
case 'p': // pad
{
schedule_pad = 1;
break;
}
case 'm': // maker code
{
//if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
//header.maker_code = (unsigned short)NUMBER;
header.maker_code = VALUE[0] | VALUE[1]<<8;
break;
}
case 't': // title
{
char title[256];
memset(title, 0, sizeof(title));
if (VALUE[0])
{
strncpy(title, VALUE, sizeof(header.title));
}
else
{
// use filename
char s[256], *begin=s, *t; strcpy(s, argfile);
t = strrchr(s, '\\'); if (t) begin = t+1;
t = strrchr(s, '/'); if (t) begin = t+1;
t = strrchr(s, '.'); if (t) *t = 0;
strncpy(title, begin, sizeof(header.title));
if (!silent) printf("%s\n",begin);
}
memcpy(header.title, title, sizeof(header.title)); // copy
break;
}
case 'v': // ignored, compatability with other gbafix
{
break;
}
case 'c': // game code
{
//if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
//header.game_code = NUMBER;
header.game_code = VALUE[0] | VALUE[1]<<8 | VALUE[2]<<16 | VALUE[3]<<24;
break;
}
case 'r': // version
{
if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
header.game_version = (unsigned char)NUMBER;
break;
}
case 'm': // maker code
{
//if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
//header.maker_code = (unsigned short)NUMBER;
header.maker_code = VALUE[0] | VALUE[1]<<8;
break;
}
case 'd': // debug
{
if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
header.logo[0x9C-0x04] = 0xA5; // debug enable
header.device_type = (unsigned char)((NUMBER & 1) << 7); // debug handler entry point
break;
}
case '-': // long arguments
{
if (strncmp("silent", &ARGV[2], 6) == 0) { continue; }
break;
}
default:
{
printf("Invalid option: %s\n", ARGV);
}
}
}
}
case 'v': // ignored, compatability with other gbafix
{
break;
}
// update complement check & total checksum
header.complement = 0;
header.checksum = 0; // must be 0
header.complement = HeaderComplement();
//header.checksum = checksum_without_header + HeaderChecksum();
case 'r': // version
{
if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
header.game_version = (unsigned char)NUMBER;
break;
}
fseek(infile, 0, SEEK_SET);
fwrite(&header, sizeof(header), 1, infile);
fclose(infile);
case 'd': // debug
{
if (!VALUE[0]) { fprintf(stderr, "Need value for %s\n", ARGV); break; }
header.logo[0x9C-0x04] = 0xA5; // debug enable
header.device_type = (unsigned char)((NUMBER & 1) << 7); // debug handler entry point
break;
}
case '-': // long arguments
{
if (strncmp("silent", &ARGV[2], 6) == 0) { continue; }
break;
}
default:
{
printf("Invalid option: %s\n", ARGV);
}
}
}
}
if (!silent) printf("ROM fixed!\n");
// update complement check & total checksum
header.complement = 0;
header.checksum = 0; // must be 0
header.complement = HeaderComplement();
//header.checksum = checksum_without_header + HeaderChecksum();
return 0;
if (schedule_pad) {
if (sh_offset != 0) {
fprintf(stderr, "Warning: Cannot safely pad an ELF\n");
} else {
fseek(infile, 0, SEEK_END);
size = ftell(infile);
for (bit=31; bit>=0; bit--) if (size & (1<<bit)) break;
if (size != (1<<bit))
{
int todo = (1<<(bit+1)) - size;
while (todo--) fputc(0xFF, infile);
}
}
}
fseek(infile, sh_offset, SEEK_SET);
fwrite(&header, sizeof(header), 1, infile);
fclose(infile);
if (!silent) printf("ROM fixed!\n");
return 0;
}