[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-116098":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":16,"stars7d":17,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":10,"archived":20,"fork":20,"defaultBranch":21,"hasWiki":22,"hasPages":20,"topics":23,"createdAt":10,"pushedAt":31,"updatedAt":32,"readmeContent":33,"aiSummary":34,"trendingCount":15,"starSnapshotCount":15,"syncStatus":35,"lastSyncTime":36,"discoverSource":37},116098,"sonic-adventure","reshaped\u002Fsonic-adventure","reshaped","A complete matching decompilation of the original Dreamcast release of Sonic Adventure","",null,"C",101,11,1,0,9,48,62,83.04,false,"main",true,[24,25,26,27,28,29,5,30],"decompilation","dreamcast","matching-decompilation","sega","sega-dreamcast","sonic","sonic-the-hedgehog","2026-11-22 06:26:16","2026-11-23 18:23:09","# sonic-adventure\n\nThe first complete matching decompilation of a retail Dreamcast game, including all of the Katana SDK code it links: *Sonic Adventure*, the original Japanese release, HDR-0001, version 1.007.\n\n\u003C!-- progress -->\n**100% of the game's code builds from source, byte for byte.**\n\n| | Binaries | Code bytes | C\\* | Assembly |\n|---|---:|---:|---:|---:|\n| Main executable | 1 | 1,090,074 | 95.5% | 4.5% |\n| SDK libraries | | 779,826 | 89.4% | 10.6% |\n| Stages | 15 | 1,100,478 | 100.0% | 0% |\n| Bosses | 11 | 331,606 | 100.0% | 0% |\n| Fields and Chao | 12 | 507,358 | 99.9% | 0.1% |\n| Events | 204 | 1,947,476 | 100.0% | 0% |\n| Menus and system | 4 | 63,640 | 99.9% | 0.1% |\n| **All** | **247** | **5,820,458** | **97.7%** | **2.3%** |\n\n*\\*SHC's assembly for 14 of the C sources matches once [shckit](https:\u002F\u002Fgithub.com\u002Freshaped\u002Fshckit) patches it ([Patched R10](TOOLCHAIN.md#patched-r10)). [Accounting](TOOLCHAIN.md#accounting) explains the percentages.*\n\nMost of the assembly was handwritten in the original, not compiled from C. Compiler analysis and original symbol names already provide [evidence](TAGS.md#assembly) of handwritten origins for 62.4% of its instructions and data.\n\u003C!-- \u002Fprogress -->\n\n## Build\n\nTested on x86-64 Linux with GNU make 4.3 and Python 3.8. The matching build and PC game run on x86-64 Linux. macOS supports `make dc`, `make dc-disc`, `make dc-check`, `make test`, `make lint` and `make format`, tested on Apple silicon with macOS 26.6, GNU make 4.4.1 and Xcode's Python 3.9.6. The Dreamcast port reads disc data through offsets the matching build records and checks on Linux ([Stub and full builds](TOOLCHAIN.md#stub-and-full-builds)).\n\nOn macOS, install Xcode's command-line tools and GNU make. Apple's `make` is 3.81; Homebrew installs GNU make as `gmake`. Use `gmake` wherever the commands below say `make`, from a terminal running natively rather than under Rosetta 2:\n\n```sh\nbrew install make\n```\n\nThe builds need a C compiler (`cc` by default, or set `CC`), `sha256sum` and `cmp`. The matching build also needs `timeout`; its first run downloads wibo and three releases of Hitachi's SHC. The Dreamcast port builds its GCC toolchain on first use and needs `c++`. Downloads need `curl` and `tar`, with `gzip` or `xz` where `tar` uses them. The first `make lint` or `make format` installs pinned clang-format and clang-tidy wheels into a Python venv, requiring `curl`, Python's `ensurepip` (`python3-venv` on Debian and Ubuntu) and pip 20.3 or later. The wheels support x86-64 Linux and macOS. Downloads are checked against [`tools\u002FSHA256SUMS`](tools\u002FSHA256SUMS) before installation.\n\nBring your own disc: the Japanese release, HDR-0001, version 1.007. None of the disc's files are in this repository. Put `1ST_READ.BIN`, `LOADER.BIN` and `SONICADV\u002F` in `orig\u002F`, named as on the disc, or put the disc's `.gdi` and its tracks there. Then:\n\n```sh\nmake           # rebuild every binary and check it against your disc\nmake check     # check the linked sources without the disc\nmake dc        # build the port with GCC, in build\u002Fdc\u002F\nmake dc-disc   # build a disc of the port, in build\u002Fdc\u002Fdisc\u002F\nmake dc-check  # build and sum the port's objects that need no disc\nmake pc        # build the PC game from your disc, in build\u002Fengine\u002F\nmake play      # play the PC game in a window, from Emerald Coast's start\n```\n\n`make` compiles every binary's code, reads the data its sources declare from your disc, and checks each binary it rebuilds against the original, PRS compression and all. They land under `build\u002F`, at the disc's own paths. `make` checks `1ST_READ.BIN`, `LOADER.BIN` and each file it reads from `SONICADV\u002F` against [`SHA256SUMS`](SHA256SUMS) before reading it. This is a matching build, so an edit that changes a byte of output fails it.\n\n`make check` needs no disc. It compiles the sources it can check without the disc, using placeholders for imported data where needed, and checks each linked source against its recorded hash, but builds no complete binary. [Checks](CONTRIBUTING.md#checks) says what each goal shows, and `make help` lists them all.\n\n`make dc` builds the sources with GCC 16.2 and links every image anew, under `build\u002Fdc\u002F` at the disc's paths. It needs the disc but neither SHC nor wibo. Its first run builds binutils and GCC from source ([Toolchain](PORTS.md#toolchain)); their logs are in `build\u002Ftoolchain\u002F`. `make dc-disc` needs the disc's `.gdi` and its tracks in `orig\u002F`, not its files alone. [The port's features](#the-ports-features) describes what it adds.\n\n`make dc-check` needs neither disc nor SHC. It builds the port's disc-independent objects and writes `build\u002Fdc\u002Fcheck.txt`: hashes of those objects, SH4ZAM's archive, the toolchain's `libgcc.a` and two compression results. Compare the file across hosts at the same commit, with the same `SH_ELF` ([Checks](CONTRIBUTING.md#checks)). Its first run builds the toolchain and fetches SH4ZAM, as `make dc` does.\n\n`make pc` builds the game from your disc, and `make play` runs it in a window. The engine's build goals need Python 3.9 or later; a window needs SDL3 and Vulkan. [Checks](CONTRIBUTING.md#checks) lists the other host requirements, and [Build goals](ENGINE.md#build-goals) lists the engine's commands.\n\nRun one `make` invocation at a time per checkout; `-j` within it is fine. SHC is a Windows program, and [wibo](https:\u002F\u002Fgithub.com\u002Fdecompals\u002Fwibo) runs it. SHC sometimes hangs under wibo, so `make` stops a tool after ten minutes. Run `make` again and it carries on. To use tools you already have, set `WIBO`, `R10`, `R26`, `R32` and `SH_ELF`: [Running SHC](TOOLCHAIN.md#running-shc) and [Toolchain](PORTS.md#toolchain) say what each must hold.\n\n## The port's features\n\n`make dc` adds 16:9, 60 fps, skips for movies and cutscenes, and a performance readout. The game decides when each may apply, and the engine draws them ([Dreamcast](ENGINE.md#dreamcast)).\n\n| Press, on the first pad | Does |\n|---|---|\n| Hold L and R, then up | Steps the readout |\n| Hold L and R, then right | Turns 16:9 on or off |\n| Hold L and R, then down | Turns 60 fps on or off |\n| Start, in a movie, or outside a demo in an event that holds control | Skips it |\n\nThe readout, 16:9 and 60 fps start off. The game saves the 16:9 and 60 fps settings, but not the readout. A chord's effect appears on screen for two seconds.\n\n### The readout\n\nUp steps through off, a page of frame times and a page of cache counters. On the PC it shows or hides one page ([The readout](ENGINE.md#the-readout)).\n\n### Skips\n\nStart skips any movie; the shipped game skips only the opening. During an event, a black curtain covers the scene while the script runs quickly, so its flags and placements still happen before control returns ([`skip.c`](src\u002Fevent\u002Fskip.c)).\n\n### 16:9\n\n16:9 widens the picture by a third while the Dreamcast still draws at 640 by 480 pixels. Attract demos and recordings stay at 4:3, and the game's visibility tests use the wider view during play ([16:9](ENGINE.md#169)).\n\n### 60 fps\n\n60 fps can split a game frame into two pictures without doubling the game's steps. It applies in play and the fade into it, not in Twinkle Circuit, Sky Chase, the Chao gardens or race, pause, other fades or game over. The PC uses the same split frame ([60 fps](ENGINE.md#60-fps)).\n\n## How the matching build works\n\n- Each binary has two tables in `config\u002F`: `splits.txt` places each source's sections at their original addresses, and `symbols.txt` names the addresses the code refers to. A binary with data no source holds has a third, `data.txt`, which types that data ([Generated ranges](TOOLCHAIN.md#generated-ranges)).\n- Each source compiles with a release of Hitachi's SHC 5.0 and flags chosen to reproduce its bytes. Some sources require documented assembly patches or grafts to achieve a match ([Releases](TOOLCHAIN.md#releases)). Shared sources compile once and link at each binary's original addresses.\n- Each binary is rebuilt from compiled source, explicitly declared disc data and linker fill. Any unaccounted-for byte fails the build.\n- For PRS files, the original is decompressed before the byte check and the rebuilt image is compressed afterward. Every binary `make` rebuilds is checked against the original.\n\nMatching binaries establish identical output, not the original source text or build settings.\n\n## The binaries\n\n*Sonic Adventure* isn't one binary. Its main executable, `1ST_READ.BIN`, stays in memory, and 246 overlays take turns beside it, among them the stages, the bosses, the fields, the Chao gardens, the menus, the movie player and the story's scenes. Even Sonic's opening scene in Station Square, `EV0001`, is an overlay of its own. [Images](TOOLCHAIN.md#images) maps where each one loads.\n\n## Layout\n\n```text\nsrc\u002F       the main executable\nsdk\u002F       the main executable's SDK libraries and C runtime, and two of the events' runtime helpers\nmodules\u002F   stages, bosses, fields, Chao, menus and the movie player\nevents\u002F    the story's scenes, and the code they share\nloader\u002F    the hand-off to Dream Passport\nengine\u002F    the portable engine, Dreamcast and PC backends, game adapter and native runner\nconfig\u002F    image and motion tables, compiler and port settings, source boundaries and fixed-address exceptions\noffsets\u002F   disc data offsets for the GCC Dreamcast port\ntools\u002F     the build's tools: its own, vendored and downloaded\ntests\u002F     the tools' tests\n```\n\n## Contributing\n\nContributions are welcome. [CONTRIBUTING.md](CONTRIBUTING.md) says what helps, and follows one source from its placement table to the checked binary.\n\n## Read on\n\n- [TOOLCHAIN.md](TOOLCHAIN.md) documents the build, compiler releases, disc data and accounting.\n- [PORTS.md](PORTS.md) documents the non-matching code and the Dreamcast port's compiler and link.\n- [ENGINE.md](ENGINE.md) documents the portable engine, game adapter, and Dreamcast and PC backends.\n- [TAGS.md](TAGS.md) defines the source annotations and their evidence requirements.\n- [prskit](https:\u002F\u002Fgithub.com\u002Freshaped\u002Fprskit), [gdi](https:\u002F\u002Fgithub.com\u002Freshaped\u002Fgdi) and [shckit](https:\u002F\u002Fgithub.com\u002Freshaped\u002Fshckit) are companion tools for PRS compression, disc extraction, and SHC assembly analysis and patching.\n\n## Acknowledgements\n\nSpecial thanks to some amazing engineers:\n\n- [wibo](https:\u002F\u002Fgithub.com\u002Fdecompals\u002Fwibo), by decompals, runs Hitachi's Windows toolchain on Linux. It makes the matching build possible.\n- [decomp.me](https:\u002F\u002Fdecomp.me) maintains the [compiler archive](https:\u002F\u002Fgithub.com\u002Fdecompme\u002Fcompilers) used by decompilation projects, including the three SHC releases this build downloads.\n- [SH4ZAM](https:\u002F\u002Fgithub.com\u002Fgyrovorbis\u002Fsh4zam) by Falco Girgis for hand-tuned SH-4 math functions used in the GCC Dreamcast port.\n- [sh4_fpu_approx.h](https:\u002F\u002Fgist.github.com\u002Fskmp\u002F4bd7b38149fc455978b5104201573236) by Stefanos Kornilios Mitsis Poiitidis for bit exact SH-4 FPU math.\n- [MAME](https:\u002F\u002Fgithub.com\u002Fmamedev\u002Fmame)'s AICA emulation by ElSemi, Deunan Knute and R. Belmont for the PC port's sound tables.\n\n## License\n\nThe Makefile, `dc.mk`, `config\u002Fcompilers.mk`, `config\u002Fgcc.mk`, `config\u002Fdreamcast.mk` and the files committed to `engine\u002F`, `tools\u002F` and `tests\u002F` are under the [MIT license](tools\u002FLICENSE), except where a file carries its own notice. The rest of the repository has no license.\n\nThis project isn't affiliated with or endorsed by SEGA.\n","这是一个对世嘉Dreamcast平台游戏《索尼克大冒险》（日版1.007）的完整匹配反编译项目，实现了源码级100%字节对齐重建。项目包含全部游戏逻辑模块（关卡、Boss、事件、菜单等）及所依赖的Katana SDK代码，C语言占比97.7%，辅以少量手工汇编；构建系统支持Linux\u002FmacOS，可生成与原版ROM完全一致的二进制文件。适用于游戏逆向研究、经典主机软件考古、SDK兼容性分析及复古游戏移植开发等场景。",2,"2026-11-24 04:52:49","CREATED_QUERY"]