diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..61d61fa8 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,52 @@ +FROM ubuntu:22.04 as build + +# --- basic package installation --- +RUN apt-get update && \ + apt-get install -y \ + git \ + ninja-build \ + python3 \ + python3-pip \ + wget + +# --- python package installation --- +COPY ./requirements.txt /temp/requirements.txt +COPY ./tools/ppcdis/requirements.txt /temp/tools/ppcdis/requirements.txt +RUN pip install -r /temp/requirements.txt +RUN rm -rf /temp + +# --- wibo installation --- +RUN wget https://github.com/decompals/wibo/releases/latest/download/wibo +RUN install ./wibo /usr/bin +RUN rm wibo + +# --- devkitpro installation --- +RUN wget https://apt.devkitpro.org/install-devkitpro-pacman +RUN chmod +x install-devkitpro-pacman +## assume yes for in-script apt commands +RUN sed -i 's/^apt-get.*$/& -y/g' install-devkitpro-pacman +## now do dkp-pacman installation +RUN ./install-devkitpro-pacman +RUN rm install-devkitpro-pacman +## workaround for a dumb WSL bug that happens with Windows Docker. if we don't do this, devkitPPC installation fails on Windows. +RUN if [ ! -e /etc/mtab ]; then ln -s /proc/self/mounts /etc/mtab; fi +## and finally, we get to install devkitPPC +RUN dkp-pacman -S devkitPPC --noconfirm + +# --- stage ultralib headers --- +RUN mkdir -p /N64_SDK/ultra/usr/ +RUN git clone https://github.com/decompals/ultralib.git /N64_SDK/ultra/usr/ +## dockerfile does not seem to support extglob, so this monstrous command works around it to delete all of ultralib except the headers we need. +RUN cd /N64_SDK/ultra/usr/ && find -type f -maxdepth 1 -delete && find . -not -name 'include' -type d -maxdepth 1 -exec rm -r "{}" \; +## modify Gpopmtx's param member to be unsigned int +RUN sed -i 's/unsigned char param:8;/unsigned int param:8;/g' /N64_SDK/ultra/usr/include/PR/gbi.h + +# --- set up work directory and env vars --- +RUN mkdir /ac-decomp +WORKDIR /ac-decomp +ENV PATH="/ac-decomp/tools:${PATH}" +ENV N64_SDK="/N64_SDK" +ENV DEVKITPPC="/opt/devkitpro/devkitPPC" + +CMD echo 'Usage: docker run -it --rm -v ${PWD}:/ac-decomp ac-decomp python3 configure.py && ninja\n'\ + 'See https://github.com/Prakxo/ac-decomp/blob/master/README.MD for more information' diff --git a/README.MD b/README.MD index fe609ded..53827bfd 100644 --- a/README.MD +++ b/README.MD @@ -4,30 +4,50 @@ Decompilation in progress of Animal Crossing (GAFE01) -An N64 version of the game is being worked on [here](https://github.com/zeldaret/af) +A decompilation of the original N64 version of the game is being worked on [here](https://github.com/zeldaret/af). ## Cloning Use `--recursive` when cloning to have ppcdis in the repository. -## Build +## Building -**It's preferible to use [wibo](https://github.com/decompals/wibo), a lightweight -Wine replacement to work with the compilers, but Wine is still usable** +> ℹ️ When using Windows, it's recommended to use WSL. -### Building +### Docker -- Dump a copy of the game and extract **main.dol** and **foresta.rel.szs**. -- Decompress **foresta.rel.szs** with yaz0 found in *tools/*. -- Place **main.dol** and **foresta.rel** in *dump/*. -- Place CodeWarrior 1.3.2 in *tools/1.3.2/* and 1.2.5n in *tools/1.2.5n/*. -- Download [CodeWarrior 1.3.2r](https://mega.nz/file/WuBFTCLT#TmB5R4-1mEFkk4G1Vjn9_cHXRD9wOIH9CtOLaVSWEas) and extract it to *tools/1.3.2r/*. -- Set the `N64_SDK` environmental variables with the path of your libultra or equivalent headers. - - Headers should be at `$N64_SDK/ultra/usr/include`. - - You may need to modify `Gpopmtx`'s `param` member to be `unsigned int`. -- Install DevkitPPC, Ninja and Python: -- Install Python modules from requirements.txt (`pip install -r requirements.txt`) -- Run configure.py -- Run ninja +1. Dump a copy of the game and extract **main.dol** and **foresta.rel.szs**. +2. Decompress **foresta.rel.szs** with yaz0 found in *tools/* (`yaz0 -d foresta.rel.szs foresta.rel`). +3. Place **main.dol** and **foresta.rel** in *dump/*. +4. Download the [CodeWarrior 1.3.2 and 1.2.5n compilers](https://files.decomp.dev/compilers_20230715.zip) and extract them to *tools/1.3.2/* and *tools/1.2.5n/*, respectively. +5. Download the [CodeWarrior 1.3.2r compiler](https://mega.nz/file/WuBFTCLT#TmB5R4-1mEFkk4G1Vjn9_cHXRD9wOIH9CtOLaVSWEas) and extract it to *tools/1.3.2r/*. +6. Install Docker. +7. Build the Docker image (`docker build -t ac-decomp .`). +8. Run configure.py (`docker run -it --rm -v ${PWD}:/ac-decomp ac-decomp python3 configure.py`). +9. Run ninja (`docker run -it --rm -v ${PWD}:/ac-decomp ac-decomp ninja`). + +### Build manually + +> ℹ️ When building manually from a work directory originally used for Docker, you will need to run `sudo ninja -t clean` for the build to execute properly. + +1. Dump a copy of the game and extract **main.dol** and **foresta.rel.szs**. +2. Decompress **foresta.rel.szs** with yaz0 found in *tools/* (`yaz0 -d foresta.rel.szs foresta.rel`). +3. Place **main.dol** and **foresta.rel** in *dump/*. +4. Download the [CodeWarrior 1.3.2 and 1.2.5n compilers](https://files.decomp.dev/compilers_20230715.zip) and extract them to *tools/1.3.2/* and *tools/1.2.5n/*, respectively. +5. Download the [CodeWarrior 1.3.2r compiler](https://mega.nz/file/WuBFTCLT#TmB5R4-1mEFkk4G1Vjn9_cHXRD9wOIH9CtOLaVSWEas) and extract it to *tools/1.3.2r/*. +6. Install Python, pip, and [ninja](https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages#package-managers) using your package manager of choice. +7. Install Python modules from requirements.txt (`pip install -r requirements.txt`). +8. Install [wibo](https://github.com/decompals/wibo) + - Wibo is a lightweight Wine replacement that's tailor-made for use with decomp projects. Regular Wine can be used if preferred, but for the purposes of this guide, these instructions will use wibo. + - Download [the latest GitHub release](https://github.com/decompals/wibo/releases/latest) and run `install ./wibo /usr/bin` to install it to your system. +9. Install devkitPPC. + - To get devkitPPC, you'll need [devkitPro Pacman](https://devkitpro.org/wiki/devkitPro_pacman#Installing_devkitPro_Pacman). + - Run `dkp-pacman -S devkitPPC` once dkp-pacman is installed to install devkitPPC. + - Set the `DEVKITPPC` environment variable to */opt/devkitpro/devkitPPC*. +10. Set the `N64_SDK` environment variable to the path of your libultra or equivalent headers. If you need headers, you can use the ones from [ultralib](https://github.com/decompals/ultralib). + - Headers should be located at `$N64_SDK/ultra/usr/include`. + - You may need to modify `Gpopmtx`'s `param` member to be `unsigned int` in **gbi.h**. +11. Run `python3 configure.py`. +12. Run `ninja`. ## Credits diff --git a/requirements.txt b/requirements.txt index 1d99a60c..e2da4a36 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,7 @@ -r ./tools/ppcdis/requirements.txt +cxxfilt ninja_syntax -prettytable \ No newline at end of file +prettytable +python-Levenshtein +watchdog diff --git a/tools/yaz0.exe b/tools/yaz0.exe new file mode 100644 index 00000000..5f443447 Binary files /dev/null and b/tools/yaz0.exe differ