From feeb96f20fc5195248b90bd09405f43eeb19b0a8 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 15 Jan 2020 11:32:24 -0500 Subject: [PATCH 1/5] Revert agbcc dependency to pret master --- .travis.yml | 4 ++-- INSTALL.md | 19 +++++++++++++++---- Makefile | 10 +++++----- asm/pokemon_summary_screen.s | 8 ++++++-- berry_fix/Makefile | 7 +++---- berry_fix/payload/Makefile | 8 ++++---- berry_fix/payload/src/agb_flash.c | 4 ++-- 7 files changed, 37 insertions(+), 23 deletions(-) diff --git a/.travis.yml b/.travis.yml index d12c7ddcb..9897e37b3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,8 +11,8 @@ cache: apt: true install: - pushd $HOME - - travis_retry git clone https://github.com/luckytyphlosion/agbcc.git -b new_layout_with_libs - - cd agbcc && make && make install prefix=$TRAVIS_BUILD_DIR + - travis_retry git clone https://github.com/pret/agbcc.git + - cd agbcc && sh build.sh && sh install.sh $TRAVIS_BUILD_DIR - popd matrix: include: diff --git a/INSTALL.md b/INSTALL.md index 1b2ba259e..fcc4601ac 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -21,12 +21,11 @@ In the case of Cygwin, [include](https://cygwin.com/cygwin-ug-net/setup-net.html To set up the repository: git clone https://github.com/pret/pokefirered - git clone https://github.com/luckytyphlosion/agbcc -b new_layout_with_libs + git clone https://github.com/pret/agbcc cd ./agbcc - make - make install prefix=../pokefirered - make install-sdk prefix=../pokefirered + sh build.sh + sh install.sh ../pokefirered cd ../pokefirered @@ -56,3 +55,15 @@ To confirm these match the respective official ROM images, prefix `compare_` to make -j$(nproc) compare_leafgreen **Note:** If the build command is not recognized on Linux, including the Linux environment used within Windows, run `nproc` and replace `$(nproc)` with the returned value (e.g.: `make -j4`). Because `nproc` is not available on macOS, the alternative is `sysctl -n hw.ncpu`. + +###Note for Mac users + +The BSD make that comes with Mac XCode can be buggy, so obtain GNU make and sed using [Homebrew](https://brew.sh): + + brew install make gnu-sed + +When compiling agbcc, substitute the `build.sh` line for + + gsed 's/^make/gmake/g' build.sh | sh + +Finally, use `gmake` instead of `make` to compile the ROM(s). diff --git a/Makefile b/Makefile index edaa183ed..8a739ccf4 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ +include $(DEVKITARM)/base_tools + COMPARE ?= 0 -AS := tools/binutils/bin/arm-none-eabi-as CPP := $(CC) -E -LD := tools/binutils/bin/arm-none-eabi-ld -OBJCOPY := tools/binutils/bin/arm-none-eabi-objcopy +LD := $(DEVKITARM)/bin/arm-none-eabi-ld include config.mk @@ -182,7 +182,7 @@ endif $(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep) @$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i @$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CFLAGS) -o $(C_BUILDDIR)/$*.s - @echo -e ".text\n\t.align\t2, 0\n" >> $(C_BUILDDIR)/$*.s + @echo -e ".text\n\t.align\t2, 0 @ Don't pad with nop\n" >> $(C_BUILDDIR)/$*.s $(AS) $(ASFLAGS) -o $@ $(C_BUILDDIR)/$*.s ifeq ($(NODEP),1) @@ -224,7 +224,7 @@ $(OBJ_DIR)/ld_script.ld: ld_script.txt $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_comm cd $(OBJ_DIR) && sed -f ../../ld_script.sed ../../$< | sed "s#tools/#../../tools/#g" > ld_script.ld $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) - cd $(OBJ_DIR) && ../../$(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(LIB) + cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../../$@ $(LIB) $(FIX) $@ -t"$(TITLE)" -c$(GAME_CODE) -m$(MAKER_CODE) -r$(GAME_REVISION) --silent $(ROM): $(ELF) diff --git a/asm/pokemon_summary_screen.s b/asm/pokemon_summary_screen.s index d14d64ee4..d6c3f548f 100644 --- a/asm/pokemon_summary_screen.s +++ b/asm/pokemon_summary_screen.s @@ -10503,7 +10503,9 @@ _08139BA0: movs r0, 0x2 b _08139C16 .align 2, 0 -_08139BD8: .double 0.8 +@ _08139BD8: .double 0.8 +_08139BD8: .4byte 0x3fe99999 +_08139BDC: .4byte 0x9999999a _08139BE0: .4byte gUnknown_203B170 _08139BE4: ldr r3, _08139C04+4 @ =0x33333333 @@ -10521,7 +10523,9 @@ _08139BE4: movs r0, 0x1 b _08139C16 .align 2, 0 -_08139C04: .double 0.6 +@ _08139C04: .double 0.6 +_08139C04: .4byte 0x3fe33333 +_08139C08: .4byte 0x33333333 _08139C0C: .4byte gUnknown_203B170 _08139C10: ldr r0, _08139C38 @ =gUnknown_203B170 diff --git a/berry_fix/Makefile b/berry_fix/Makefile index 44e816c52..1e0f3ee25 100644 --- a/berry_fix/Makefile +++ b/berry_fix/Makefile @@ -1,9 +1,8 @@ +include $(DEVKITARM)/base_tools COMPARE ?= 0 -AS := ../tools/binutils/bin/arm-none-eabi-as CPP := $(CC) -E -LD := ../tools/binutils/bin/arm-none-eabi-ld -OBJCOPY := ../tools/binutils/bin/arm-none-eabi-objcopy +LD := $(DEVKITARM)/bin/arm-none-eabi-ld ifeq ($(OS),Windows_NT) EXE := .exe @@ -160,7 +159,7 @@ $(SONG_BUILDDIR)/%.o: $(SONG_SUBDIR)/%.s $(AS) $(ASFLAGS) -I sound -o $@ $< $(ELF): ld_script.txt $(OBJS) - cd $(OBJ_DIR) && ../$(LD) $(LDFLAGS) -T ../ld_script.txt -o ../$@ + cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ../ld_script.txt -o ../$@ $(ROM): $(ELF) $(OBJCOPY) -O binary $< $@ diff --git a/berry_fix/payload/Makefile b/berry_fix/payload/Makefile index dabbe4582..c87a06c41 100644 --- a/berry_fix/payload/Makefile +++ b/berry_fix/payload/Makefile @@ -1,9 +1,8 @@ +include $(DEVKITARM)/base_tools COMPARE ?= 0 -AS := ../../tools/binutils/bin/arm-none-eabi-as CPP := $(CC) -E -LD := ../../tools/binutils/bin/arm-none-eabi-ld -OBJCOPY := ../../tools/binutils/bin/arm-none-eabi-objcopy +LD := $(DEVKITARM)/bin/arm-none-eabi-ld ifeq ($(OS),Windows_NT) EXE := .exe @@ -131,6 +130,7 @@ endif $(C_BUILDDIR)/%.o : $(C_SUBDIR)/%.c $$(c_dep) @$(CPP) $(CPPFLAGS) $< -o $(C_BUILDDIR)/$*.i @$(PREPROC) $(C_BUILDDIR)/$*.i charmap.txt | $(CC1) $(CC1FLAGS) -o $(C_BUILDDIR)/$*.s + @echo -e ".text\n\t.align 2, 0 @ Don't pad with nop\n" >> $(C_BUILDDIR)/$*.s $(AS) $(ASFLAGS) -o $@ $(C_BUILDDIR)/$*.s ifeq ($(NODEP),1) @@ -167,7 +167,7 @@ $(OBJ_DIR)/ld_script.ld: ld_script.txt $(OBJ_DIR)/sym_bss.ld $(OBJ_DIR)/sym_comm cd $(OBJ_DIR) && sed -f ../../ld_script.sed ../$< | sed "s#tools/#../tools/#g" > ld_script.ld $(ELF): $(OBJ_DIR)/ld_script.ld $(OBJS) - cd $(OBJ_DIR) && ../$(LD) $(LDFLAGS) -T ld_script.ld -o ../$@ $(LIB) + cd $(OBJ_DIR) && $(LD) $(LDFLAGS) -T ld_script.ld -o ../$@ $(LIB) $(ROM): $(ELF) $(OBJCOPY) -O binary $< $@ diff --git a/berry_fix/payload/src/agb_flash.c b/berry_fix/payload/src/agb_flash.c index cda3b73f6..2c2c96e6e 100644 --- a/berry_fix/payload/src/agb_flash.c +++ b/berry_fix/payload/src/agb_flash.c @@ -1,5 +1,5 @@ -#include -#include +#include "gba/gba.h" +#include "gba/flash_internal.h" static u8 sTimerNum; static u16 sTimerCount; From a79b21ee4330bba7a7db8326184b468932fbacad Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 15 Jan 2020 11:39:28 -0500 Subject: [PATCH 2/5] Fix .travis.yml --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9897e37b3..f4fc29652 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,10 @@ language: generic dist: bionic sudo: false +env: + global: + - DEVKITPRO=$HOME + - DEVKITARM=$DEVKITPRO/devkitARM addons: apt: packages: @@ -11,6 +15,8 @@ cache: apt: true install: - pushd $HOME + - travis_retry wget https://github.com/devkitPro/buildscripts/releases/download/devkitARM_r52/devkitARM_r52-linux.tar.xz + - tar xJf devkitARM*.tar.xz - travis_retry git clone https://github.com/pret/agbcc.git - cd agbcc && sh build.sh && sh install.sh $TRAVIS_BUILD_DIR - popd From b6c1fbf1c36830083b19830a88cae4aa0effbd25 Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 15 Jan 2020 12:02:10 -0500 Subject: [PATCH 3/5] Roll back dkA to r50 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f4fc29652..03be7612f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ cache: apt: true install: - pushd $HOME - - travis_retry wget https://github.com/devkitPro/buildscripts/releases/download/devkitARM_r52/devkitARM_r52-linux.tar.xz + - travis_retry wget https://github.com/devkitPro/buildscripts/releases/download/devkitARM_r50/devkitARM_r50-linux.tar.xz - tar xJf devkitARM*.tar.xz - travis_retry git clone https://github.com/pret/agbcc.git - cd agbcc && sh build.sh && sh install.sh $TRAVIS_BUILD_DIR From 6d47a7dda740d944bba2f3984f4c51ce5e3e590b Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 15 Jan 2020 12:11:34 -0500 Subject: [PATCH 4/5] Yoink dkA install instructions from Emerald --- INSTALL.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/INSTALL.md b/INSTALL.md index fcc4601ac..78ed7d0c2 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -15,6 +15,14 @@ Make sure that the `build-essential`, `git`, and `libpng-dev` packages are insta In the case of Cygwin, [include](https://cygwin.com/cygwin-ug-net/setup-net.html#setup-packages) the `make`, `git`, `gcc-core`, `gcc-g++`, and `libpng-devel` packages. +Install the **devkitARM** toolchain of [devkitPro](https://devkitpro.org/wiki/Getting_Started) and add its environment variables. For Windows versions without the Linux subsystem, the devkitPro [graphical installer](https://github.com/devkitPro/installer/releases) includes a preconfigured MSYS2 environment, thus the steps below are not required. + + sudo (dkp-)pacman -S gba-dev + export DEVKITPRO=/opt/devkitpro + echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc + export DEVKITARM=$DEVKITPRO/devkitARM + echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc + ## Installation From 19227f535af9b7e95185d0436285314ea1fdde0c Mon Sep 17 00:00:00 2001 From: PikalaxALT Date: Wed, 15 Jan 2020 12:17:22 -0500 Subject: [PATCH 5/5] Fix leading whitespace in INSTALL.md --- INSTALL.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/INSTALL.md b/INSTALL.md index 78ed7d0c2..d4e60bcef 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -18,36 +18,36 @@ In the case of Cygwin, [include](https://cygwin.com/cygwin-ug-net/setup-net.html Install the **devkitARM** toolchain of [devkitPro](https://devkitpro.org/wiki/Getting_Started) and add its environment variables. For Windows versions without the Linux subsystem, the devkitPro [graphical installer](https://github.com/devkitPro/installer/releases) includes a preconfigured MSYS2 environment, thus the steps below are not required. sudo (dkp-)pacman -S gba-dev - export DEVKITPRO=/opt/devkitpro - echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc - export DEVKITARM=$DEVKITPRO/devkitARM - echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc + export DEVKITPRO=/opt/devkitpro + echo "export DEVKITPRO=$DEVKITPRO" >> ~/.bashrc + export DEVKITARM=$DEVKITPRO/devkitARM + echo "export DEVKITARM=$DEVKITARM" >> ~/.bashrc ## Installation To set up the repository: - git clone https://github.com/pret/pokefirered - git clone https://github.com/pret/agbcc + git clone https://github.com/pret/pokefirered + git clone https://github.com/pret/agbcc - cd ./agbcc - sh build.sh - sh install.sh ../pokefirered + cd ./agbcc + sh build.sh + sh install.sh ../pokefirered - cd ../pokefirered + cd ../pokefirered To build **pokefirered.gba**: - make -j$(nproc) + make -j$(nproc) To confirm it matches the official ROM image while building, do this instead: - make compare -j$(nproc) + make compare -j$(nproc) If only `.c` or `.s` files were changed, turn off the dependency scanning temporarily. Changes to any other files will be ignored and the build will either fail or not reflect those changes. - make -j$(nproc) NODEP=1 + make -j$(nproc) NODEP=1 Convenient targets have been defined to build Pokémon LeafGreen and the 1.1 revisions of both games: