{
  "api_version": "1.0.0",
  "slug": "rea-th04-bullet-patterns",
  "url": "https://reversedwithai.com/p/rea-th04-bullet-patterns",
  "markdown_url": "https://reversedwithai.com/p/rea-th04-bullet-patterns.md",
  "json_url": "https://reversedwithai.com/p/rea-th04-bullet-patterns.json",
  "title": "Recovered Touhou 4's bullet-ring logic from its PC-98 DOS binary with REA",
  "tagline": "Touhou 4's aimed bullet rings, recovered as C++ that matches the original bytes.",
  "summary": "An agent used REA to analyse TH04's 16-bit MAIN.EXE and recover the aimed bullet-ring angle maths as C++; compiler checks match 2,139 bytes of the original as part of a full source reconstruction.",
  "target": {
    "name": "Touhou 4: Lotus Land Story",
    "type": "game",
    "type_label": "Games and mods"
  },
  "platform": "PC-98 (DOS)",
  "models": [],
  "tools": [
    "REA"
  ],
  "outcome": "partial",
  "outcome_label": "Partial",
  "human_effort": null,
  "time_spent": null,
  "cost": null,
  "license": "MIT",
  "checks": {
    "source_available": "yes",
    "repro_steps": "yes",
    "real_hardware": null,
    "independently_verified": null
  },
  "author": {
    "name": "N0zoM1z0",
    "url": "https://github.com/N0zoM1z0"
  },
  "sources": {
    "repository": "https://github.com/N0zoM1z0/th04",
    "writeup": "https://rea.tools/showcase/th04/",
    "discussions": [],
    "all": [
      "https://github.com/N0zoM1z0/th04",
      "https://rea.tools/showcase/th04/"
    ]
  },
  "image": {
    "url": "https://covers.reversedwithai.com/rea-th04-bullet-patterns.webp",
    "credit": "Image: rea.tools"
  },
  "commit_history": {
    "commits": 1189,
    "ai_commits": 0,
    "ai_days": 0,
    "first_ai_commit": null,
    "last_ai_commit": null,
    "credited_models": []
  },
  "added_at": "2026-10-14T00:00:47+00:00",
  "updated_at": "2026-10-14T00:00:47+00:00",
  "sources_reviewed_at": "2026-10-14T00:00:47+00:00",
  "reviewed_by": "editor",
  "human_notes": null,
  "reproduce": null,
  "body_md": "N0zoM1z0's TH04 project reconstructs the Japanese PC-98 game Touhou 4: Lotus Land Story as maintained C++ and assembly, with a C++17 port for Windows and Linux that runs without a DOS emulator. An REA case study shows an agent reading the 16-bit MAIN.EXE to explain how aimed bullet rings are calculated, and compiler checks show the bullet-generation code matching a 2,139-byte section of the original.\n\n### What REA recovered\n\nThe example prompt asks the agent to find how TH04 creates a ring of bullets and aims it at the player. REA first verified the DOS load image against the supplied executable, then returned instructions and pseudocode for bullet_velocity_and_angle_set(). The code multiplies the bullet index by 256 and divides by the ring count, subtracts to form player-minus-origin coordinates, calls a direction helper, and adds the template rotation stored in one byte. The case study maps each step to the maintained C++, which uses iatan2. TH04 stores a full turn in 256 angle units, so a 16-bullet ring places bullets 16 units apart. Elly's attack requests an aimed ring with a count of 16.\n\n### Build and checks\n\nThe DOS reconstruction on the main branch builds with pinned Turbo C++ 4.0J, TASM and TLINK under Wine, and uses the community ReC98 project as a migration input and validation reference. All four DOS executables build from maintained source. The README reports original and rebuilt runs agreeing on input, score, RNG and many state blocks across four bundled demos; full Boss defeat, process transitions and physical scanout timing remain open.\n\n### Playing the port\n\nA Windows x64 portable preview on the releases page supports Normal, Extra, Music Room, endings and saves, with sound. You need your own Japanese full-version game files (MAIN.EXE, the ED data file and the main data file, checked by hash). A bundled Python script builds a disk image from them, plus a font and sound data file, in one step. No game data is shipped. The portable source is on the port/modern-64 branch, with a Linux x86-64 build using CMake and SDL2.\n\n### How AI was used\n\nThe README says the reconstruction was built with AI coding agents and invites contributions. It names no model. The REA case study shows REA being used by an agent for inspection.\n\nSources:\n- https://github.com/N0zoM1z0/th04\n- https://rea.tools/showcase/th04/",
  "ai_use_excerpts": null
}
