Commit Graph

4 Commits

Author SHA1 Message Date
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
64420082be
Nicer logs (#1212)
![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/81e07623-f2d5-4b00-9624-7aa678593aa8)

Add colours to the various logs to make sense out of all the produced
noise. Also gets rid of the square brackets and use a nicer column
separator. Don't mind the error log being mis-labeled. My hunger for
copy&pasting code consistently betrays me.


![image](https://github.com/Xeeynamo/sotn-decomp/assets/6128729/1873521f-cb41-4a80-aa0c-7e6b6a752ffa)

but most importantly groups the logs to avoid spamming the same one for
every frame. The log count keeps getting updated on the left-hand side
of the log, replacing the beginning of the path (almost never relevant).
If the log is old, the logging function will go back, update the line
and go back down.

It is a tad bit slower than the original implementation, but logs are
never meant to be seen anyway, especially debug logs. I used a
relatively fast hashing function paired with a dictionary to avoid
unnecessary loops. There are two hashes. `logHash` simply works as an
index to the massive 65K entry dictionary to pick an index. If an entry
is found then check the other hash `altHash` to check if the dictionary
collided with an actually different log, effectively replacing it. Since
`entry->hash` is `0` at the beginning, that also works for new elements.

I believe the slowest part of the code are the two `while (nLinesBack--
> 0)`. I am thinking to maybe unroll the loop in a similar way `memcpy`
works internally to save `fputs` calls. But I have little clue on how to
measure improvements. If you know better on how to take advantage of
moving the cursor through the TTY, please let me know.

You can disable this entire functionality with `#define
FORCE_LINEAR_LOGS` and it gets disabled if `stderr` is not printing on a
terminal.
2024-05-30 22:10:53 +01:00
Luciano Ciccariello
1169fdc32a
Allow main roundtrip across different states (#804)
The most prominent change is the new macro which replaces the `DEBUGF`
for each stub, but that is the least interesting part. This allows to go
through the different steps `Game_Init`, `Game_NowLoading` and once it
finally lands into `Game_Play` it calls `func_800F298C`, which is our
new `main` function for testing stuff.
2023-11-22 22:52:10 +00:00
Luciano Ciccariello
c123b1819d
Sound test: add 42398.c (#799)
In Italian we say "Abbiamo fatto 30, facciamo 31". It literally means
"We come all the way up to 30, it wouldn't cost nothing to push a little
further for 31".

I moved `log.h` into `include/` to easily logging stuff elsewhere and
without weird `#ifdef VERSION_*` by adding `-DNO_LOGS` in the main
Makefile.

This is a bit hacky, but it does the trick. I had to expand `D_80138784`
otherwise I would get a segfault.

Both `SoundInit` and `func_801361F8` are called in the main, so I
removed them. To restore the previous behaviour and isolate the sound
engine, just replace `MainGame()` in the `main.c` with a `SoundInit()`
and then a loop that calls `UpdateGame()`.

Last, but not least, SDL2 is in.
2023-11-20 18:17:51 -08:00