Commit Graph

11 Commits

Author SHA1 Message Date
Mark Street
20c3370f4f
Use allegrex assembler for PSP (#1424)
I moved *some* of the PSX-specific stuff out of the common `Makefile`
and into the `Makefile.psx.mk` -- there is still more that could be done
here, but this should be enough to have the correct rules for PSX and
PSP with the desired assembler.


Also threw in a bonus feature where I've removed the `move` macro from
`macro.inc` because `maspsx` does this automagically for you now.
2024-07-22 15:36:28 -04:00
Luciano Ciccariello
151346d62c
Update clang-format as self-contained binary (#1257)
Version 18.1.6 pulled from
https://github.com/xeeynamo/sotn-decomp/releases and compiled with the
following:

```Dockerfile
FROM alpine:latest
RUN apk add --no-cache \
    build-base \
    cmake \
    git \
    ninja \
    libstdc++ \
    zlib-dev \
    python3
ENV LLVM_VERSION=llvmorg-18.1.6
RUN mkdir -p /opt/llvm \
    && cd /opt/llvm \
    && git clone --depth=1 --branch $LLVM_VERSION https://github.com/llvm/llvm-project.git \
    && mkdir -p llvm-project/build \
    && cd llvm-project/build \
    && cmake -G Ninja \
        -DLLVM_ENABLE_PROJECTS=clang \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_CXX_FLAGS="-static-libstdc++ -static-libgcc" \
        -DCMAKE_EXE_LINKER_FLAGS="-static" \
        -DLLVM_ENABLE_RTTI=ON \
        ../llvm \
    && ninja clang-format \
    && strip bin/clang-format
FROM scratch
COPY --from=0 /opt/llvm/llvm-project/build/bin/clang-format /clang-format
ENTRYPOINT ["/usr/local/bin/clang-format"]
```
`docker build --output . .`

Original source code:
https://github.com/llvm/llvm-project/tree/llvmorg-18.1.6
commit: `1118c2e05e67a36ed8ca250524525cdb66a55256`
2024-06-04 21:07:50 +01:00
Luciano Ciccariello
c6e1f2517e
TT_000 PSP func_801713C8 (#1143)
Matches `func_801713C8`.

This is an important milestone as it is the first function using the
`SEH` instruction. I got this new compiler (and many more) from someone
in ObscureGamers that kindly shared at
https://archive.org/download/compilers-no-license .

This still gives us no clue on what `f32` and the various `.i.hi` stuff
was actually meant to be.
2024-05-18 13:09:03 -07:00
Luciano Ciccariello
791e321b43
Add TT_000 overlay from PSP (#1113)
TT_000 is the first overlay from PlayStation 1 that we are now able to
compile from the source and produce a 1:1 binary. This lead me to start
exploring the same overlay from the game Castlevania: Dracula X
Chronicles, which contains a PSP re-build of Symphony of the Night.

This PR adds all the infrastructure to add the same flow for a PSP
matching decomp. Use `export VERSION=pspeu` and then the usual `sotn`
command to splat the overlay, build it and check if it matches. Running
`make extract_disk` should not be necessary as the same ISO used from
`VERSION=hd` is also used for `pspeu`, so you will probably have it
extracted already.

Some important notes about the PSP build:
* The whole PSP build seems to be compiled with `-O0`, which makes it
much easier to decompile
* Having ŧhe PSX, PSP and Saturn builds will allow to easily
cross-reference the code and reduce fake matches
* `disks/pspeu/PSP_GAME/USRDIR/res/ps/hdbin/tt_000.bin` is the HD PSX
build
* `disks/pspeu/PSP_GAME/USRDIR/res/ps/PSPBIN/tt_000.bin` has the same
code from the HD build, but for PSP
* `disks/pspeu/PSP_GAME/USRDIR/res/ps/PACK_E/TP00.BIN` is the same as
above, but it packs both overlay and graphics. This is the file the PSP
game seems to actually use
* The PSP build uses the Metrowerk CodeWarrior's C compiler, which is
very different from the GCC one used on PSX.
* Thanks to @mkst lead, we found a way to still use the GNU assembler
and linker
* MWCC uses [wibo](https://github.com/decompals/WiBo/), a think
compatibility layer to run Windows CLI tools on Linux. It is much more
lightweight than Wine.
* MWCC does not support the `INCLUDE_ASM` dialect, so the custom
pre-processor `tools/mwcpp` had to be created
* The exact MWCC compiler version is unknown, but I suspect it is `build
147`
* I am not yet sure of any implications for using GNU AS and GNU LD
instead of the MW correspondent tools
* Not all the functions can be correctly disassembled, spimdisasm will
just produce a bunch of `.word 0x________` due to the in-progress effort
of adding the Allegrex-specific opcodes support

---

TO-DO list before marking the PR as ready:
- [X] Add PSP build to the CI
- [x] Add progress reporting to the PSP build
- [x] Integrate source file from `src/servant/tt_000_psp` to
`src/servant/tt_000` to promote the psp build as first-citizen

---

TO-DO in a follow-up PR:
* Figure out what `header` is: can we extract it as assembly code? or
maybe as custom re-compilable asset via splat? Is it a MW stuff or a
Castlevania-specific file?
 * Get rid of the last line in `Makefile.psp.mk`
2024-04-21 02:18:10 +01:00
Luciano Ciccariello
45a71c03ac
Rewrite Saturn make rules (#660)
## What

Enhance the existing `Makefile` to build new rules for the Saturn side
of the decomp. This should allow more flexibility when adding new
overlays or when tuning existing rules.

## Changes

I separated part of the Saturn build process in the separate file
`Makefile.saturn.mk`. I realise that naming it `saturn.mk` would have
been enough, but I pre-pended `Makefile.` so it can be found right below
the main `Makefile` when listing files in an alphabetic order. I plan to
do the same with the psx and psp toolchain, therefore you will find
`include Makefile.*.mk` in the main `Makefile`.

I deleted all the game building process done with Docker. Now that we
have an established way to do it natively I think it is no longer
required. We can always run the entire buildchain within a Docker
container instead of having `_native` and `_docker`. Now all the
`_native` references are removed. `build_saturn_native` is now
`build_saturn`.

`check_saturn` is no longer responsible of stripping the ELF into a
binary. That is now part of `build_saturn`.

I removed the references to `_li.o` (e.g. `alucard_li.o`) and used
`.elf` instead, which is closer to how the PSX build chain works. If
`_li.o` was a better preference, please let me know.

I am no longer using `./compile_dosemu.sh`. Instead I am using the new
`$(DOSEMU)` to directly invoke the tool within the Makefile. I have done
that to reduce the amount of dependent files.

I tried minimising duplication as much as possible. We now have a list
of overlays found in `SATURN_OVL_TARGETS`. Each expected output triggers
a series of dependencies so seamlessly build everything. `Makefile` is
smart enough to call `$(SATURN_TOOLCHAIN)` only once. If the game was
already built but just one source or symbol file changed, triggering a
new `build_saturn` will only compile the modified overlay.

The Saturn ADPCM files are now extracted in `assets/` instead of
`build/`. I think `assets/` should contain all the uncompressed and
uncooked files. The list of PCM file is not hardcoded. Instead I am now
using `$(wildcard disks/saturn/SD/*.PCM)`. This now means the tool tries
to convert PCMs from `SDD0.PCM` to `SDF0.PCM` with no success. As the
tool is silently failing I decided to leave it as I wrote it.

## Problems

I rewrote everything thinking about concurrency in mind. But `make -j
build_saturn` gives some unexpected output on `stdout`. I did not dig
too much into it. I suspect it might be dosemu. This is not a stopper as
we were not using `-j` when building the game anyway.

I also noticed doing `VERSION=saturn make build` calls
`mipsel-linux-gnu-ld` for `stage_02`. I suspect it is calling the rule
`$(MAIN_TARGET).elf: $(MAIN_O_FILES)` and simply moving `include
Makefile.*.mk` above it should fix it. But then it would cause the same
problem if I split the PSX rules into their own separate file. We never
used `make build` by setting the env variable `VERSION`, so this is not
either a breaking change or a stopper.

## Post thoughts

I am happy with what I achieved so far. I used the knowledge I
accumulated when maintaining the PSX counterpart. Since I now better
understand how `make` works, I was able to make some better decisions in
the Saturn counterpart. For example triggering a new build when the
symbol list changes is something the PSX build chain lacks of. I think
in the future it would be nice to trigger `make extract` when either the
YAML or the symbol list changes.
2023-10-03 21:42:08 +01:00
Luciano Ciccariello
2aa856a9ab Update compiler to use little endian 2023-04-05 19:19:14 +01:00
Luciano Ciccariello
a3beeb0981 Delete unnecessary CC1 2.7.2 compiler 2023-02-11 22:35:34 +00:00
Luciano Ciccariello
121a8af028 Undo broken commit 2023-01-20 23:44:24 +00:00
Luciano Ciccariello
d337730a94 EntityWarpSmallRocks matching but jtbl not imported 2023-01-20 22:16:10 +00:00
Luciano Ciccariello
a0fc475575 Use GCC 2.6.3 to obtain better matching 2022-02-07 00:07:42 +00:00
Luciano Ciccariello
fcf1f0773a Upload disassembly 2022-01-02 13:35:44 +00:00