Skip to content

Commit

Permalink
Use native arm-none-eabi-gcc to assemble field and battle scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
lhearachel committed Jul 16, 2024
1 parent 3caaa4d commit c86dc1e
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/$(lsb_release -cs)/winehq-$(lsb_release -cs).sources
sudo dpkg --add-architecture i386
sudo apt-get update -y
sudo apt-get install -y --install-recommends python3-pip ninja-build winehq-stable binutils-arm-none-eabi
sudo apt-get install -y --install-recommends python3-pip ninja-build winehq-stable binutils-arm-none-eabi gcc-arm-none-eabi
pip install --user meson pyelftools
- name: Checkout Repo
Expand Down
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ RUN apt-get install -y \
python3-pip \
python-is-python3 \
binutils-arm-none-eabi \
gcc-arm-none-eabi \
wget
RUN dpkg --add-architecture i386
RUN mkdir -pm755 /etc/apt/keyrings
Expand Down
8 changes: 4 additions & 4 deletions INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,9 @@ You now have the choice between two different environments to use to build the p
3. Reopen an MSYS terminal (pink icon) and enter the following commands to install the necessary packages:
```
echo 'export MINGW_PACKAGE_PREFIX=mingw-w64-x86_64-' >> ~/.bashrc
echo 'export PATH=${PATH}:/mingw64/bin' >> ~/.bashrc
source ~/.bashrc
pacman -S git meson gcc "${MINGW_PACKAGE_PREFIX}arm-none-eabi-binutils"
pacman -S git meson gcc mingw-w64-x86_64-arm-none-eabi-{binutils,gcc}
```
Press 'Y' when prompted to confirm the installation.
Expand Down Expand Up @@ -77,7 +76,7 @@ You now have the choice between two different environments to use to build the p
7. Certain packages are required to build the repository. Install these packages by running the following command:
```bash
sudo apt install git build-essential binutils-arm-none-eabi
sudo apt install git build-essential binutils-arm-none-eabi gcc-arm-none-eabi
```
We are not done yet, the 'meson' package is also necessary, but the version provided by apt is too outdated. To get the most recent meson version, run:
Expand Down Expand Up @@ -114,7 +113,7 @@ These can be installed using Homebrew; if you do not have Homebrew installed, re
```
brew update
brew install gcc@14 meson libpng pkg-config arm-none-eabi-binutils
brew install gcc@14 meson libpng pkg-config arm-none-eabi-binutils arm-none-eabi-gcc
brew install --cask wine-stable
```
Expand All @@ -131,6 +130,7 @@ Building the ROM requires the following packages. If you cannot find one or more
* meson (>= 1.3.0)
* build-essentials (build-essential on Ubuntu)
* binutils-arm-none-eabi (arm-none-eabi-binutils on Arch Linux)
* gcc-arm-none-eabi (arm-none-eabi-gcc on Arch Linux)
* wine (to run the mwcc executables)
* pkg-config
Expand Down
2 changes: 0 additions & 2 deletions asm/macros/scrcmd.inc
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
.include "consts/scrcmd.inc"
.include "consts/sdat.inc"

.option alignment off

.macro Noop
.short 0
.endm
Expand Down
25 changes: 1 addition & 24 deletions res/battle/scripts/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,12 @@ subdir('effects')
subdir('moves')
subdir('subscripts')

relative_source_root = fs.relative_to(meson.project_source_root(), meson.project_build_root())
relative_build_dir = fs.relative_to(meson.current_build_dir(), meson.project_build_root())

s_to_bin_gen = generator(make_script_bin_sh,
arguments: [
'--mwrap',
'-i', relative_source_root / 'include',
'-i', relative_source_root / 'asm',
'-i', '.' / 'res' / 'text',
'-i', '.' / 'res',
'-i', '.',
'--assembler', mwrap_exe.full_path(),
'--objcopy', arm_none_eabi_objcopy_exe.full_path(),
'@EXTRA_ARGS@',
'@INPUT@',
],
depends: [
message_banks_narc, # for GMM headers
asm_consts_generators, # for ASM headers
c_consts_generators, # for C headers
],
output: '@BASENAME@'
)

sub_seq_basename = 'sub_seq'

be_seq_target_name = 'be_seq.narc'
waza_seq_target_name = 'waza_seq.narc'

sub_seq_basename = 'sub_seq'
sub_seq_narc_name = sub_seq_basename + '.narc'
sub_seq_naix_name = sub_seq_basename + '.naix'

Expand Down
27 changes: 25 additions & 2 deletions res/meson.build
Original file line number Diff line number Diff line change
@@ -1,12 +1,35 @@
nitrofs_files = []
naix_headers = []

# Prebuilt files
### PREBUILT FILES ###
subdir('prebuilt')

# Decompiled data directories
### DECOMPILED DATA DIRECTORIES ###
subdir('text') # must be listed first for GMM header targets

# Common generator for "scripting" files, i.e. field and battle scripts
relative_source_root = fs.relative_to(meson.project_source_root(), meson.project_build_root())

s_to_bin_gen = generator(make_script_bin_sh,
arguments: [
'-i', relative_source_root / 'include',
'-i', relative_source_root / 'asm',
'-i', '.' / 'res' / 'text',
'-i', '.' / 'res',
'-i', '.',
'--assembler', arm_none_eabi_gcc_exe.full_path(),
'--objcopy', arm_none_eabi_objcopy_exe.full_path(),
'@EXTRA_ARGS@',
'@INPUT@',
],
depends: [
message_banks_narc, # for GMM headers
asm_consts_generators, # for ASM headers
c_consts_generators, # for C headers
],
output: '@BASENAME@'
)

subdir('battle')
subdir('field')
subdir('items')
Expand Down
1 change: 1 addition & 0 deletions tools/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ makelcf_exe = find_program('makelcf', native: true)
makerom_exe = find_program('makerom', native: true)

# ARM binutils
arm_none_eabi_gcc_exe = find_program('arm-none-eabi-gcc', native: true)
arm_none_eabi_objcopy_exe = find_program('arm-none-eabi-objcopy', native: true)

# External tools
Expand Down
22 changes: 5 additions & 17 deletions tools/scripts/make_script_bin.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ help() {
echo " -a | --assembler path to the assembler executable"
echo " -o | --objcopy path to the objcopy executable for data extraction"
echo " -d | --out-dir directory for output files (default: current directory)"
echo " -m | --mwrap if set, will treat the assembler as mwrap"
}

INCLUDE_ARGS=()
SCRIPT_FILES=()
AS=""
AS="arm-none-eabi-gcc"
OBJCOPY="arm-none-eabi-objcopy"
MWRAP=false
OUTDIR="."

while [[ $# -gt 0 ]] ; do
Expand All @@ -25,7 +23,7 @@ while [[ $# -gt 0 ]] ; do
exit 0
;;
-i|--include)
INCLUDE_ARGS+=("-i" "$2")
INCLUDE_ARGS+=("-I$2")
shift
shift
;;
Expand All @@ -44,24 +42,14 @@ while [[ $# -gt 0 ]] ; do
shift
shift
;;
-m|--mwrap)
MWRAP=true
shift
;;
*)
SCRIPT_FILES+=("$1")
shift
;;
esac
done

MWRAP_ARG=""
if $MWRAP ; then
MWRAP_ARG=" mwasmarm"
fi

for script_file in "${SCRIPT_FILES[@]}" ; do
script_dir=${script_file%/*}
script_fname=${script_file##*/}
script_noext=${script_fname%.*}

Expand All @@ -70,7 +58,7 @@ for script_file in "${SCRIPT_FILES[@]}" ; do
script_bin="$OUTDIR/$script_noext"

# Convert + clean-up
$AS$MWRAP_ARG ${INCLUDE_ARGS[@]} -gccinc -o $script_obj $script_file
$OBJCOPY -O binary --file-alignment 4 $script_obj $script_bin
rm $script_obj
$AS -c -x assembler-with-cpp "${INCLUDE_ARGS[@]}" -o "$script_obj" "$script_file"
$OBJCOPY -O binary --file-alignment 4 "$script_obj" "$script_bin"
rm "$script_obj"
done

0 comments on commit c86dc1e

Please sign in to comment.