{"id":30713252,"url":"https://github.com/alh477/idtech4-demod","last_synced_at":"2026-02-12T20:03:35.375Z","repository":{"id":312800851,"uuid":"1048792107","full_name":"ALH477/IDTECH4-DeMoD","owner":"ALH477","description":"Idtech4 engine with advanced networking and audio. Forks of modernized versions of Idtech will be made later.","archived":false,"fork":false,"pushed_at":"2025-09-02T03:25:33.000Z","size":17,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-10T10:33:40.244Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ALH477.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-02T03:16:24.000Z","updated_at":"2025-09-02T03:25:36.000Z","dependencies_parsed_at":"2025-09-02T05:32:25.847Z","dependency_job_id":"8769eba6-6005-4d85-ab6b-4740de6e5b6b","html_url":"https://github.com/ALH477/IDTECH4-DeMoD","commit_stats":null,"previous_names":["alh477/idtech4-demod"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ALH477/IDTECH4-DeMoD","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FIDTECH4-DeMoD","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FIDTECH4-DeMoD/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FIDTECH4-DeMoD/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FIDTECH4-DeMoD/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ALH477","download_url":"https://codeload.github.com/ALH477/IDTECH4-DeMoD/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ALH477%2FIDTECH4-DeMoD/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29379684,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-12T19:05:20.189Z","status":"ssl_error","status_checked_at":"2026-02-12T19:01:44.216Z","response_time":55,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-09-03T03:44:48.691Z","updated_at":"2026-02-12T20:03:35.356Z","avatar_url":"https://github.com/ALH477.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# idTech4-DeMoD: Enhanced idTech4 Fork with DSP Audio and DCF Networking for Petabyte Madness\n\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Build Status](https://img.shields.io/badge/build-Alpha-brightgreen.svg)](https://github.com/DeMoD-LLC/idTech4-DeMoD)\n[![Contributors](https://img.shields.io/badge/contributors-1-orange.svg)](https://github.com/DeMoD-LLC/idTech4-DeMoD/graphs/contributors)\n[![Coverage](https://img.shields.io/badge/Coverage-85%25-green.svg)](https://github.com/DeMoD-LLC/idTech4-DeMoD)\n\n## Project Overview\n\n**idTech4-DeMoD** is a fork of the idTech4 engine (based on Dhewm3), crafted by **DeMoD LLC** specifically to power their upcoming horror/cyberpunk game *Petabyte Madness*. This fork integrates two advanced mods developed by DeMoD LLC: the **idTech4-DSP-Audio** mod for hardware-accelerated audio processing and the **IDTECH4-DCF-PLUGIN** for enhanced multiplayer networking. It combines real-time ray-traced audio effects with low-latency P2P networking, tailored for the immersive single-player and experimental multiplayer experience of *Petabyte Madness*. The fork maintains compatibility with idTech4’s core systems (e.g., OpenAL, async networking) while introducing modder-friendly tools, debug features, and robust error handling.\n\n**Key Features**:\n- **DSP Audio**: Hardware-accelerated audio via USB-connected DSP (e.g., TMS320C674x) with real-time ray tracing, reverb, occlusion, and distortion, designed to enhance the atmospheric depth of *Petabyte Madness*.\n- **Audio Mode Zones**: Entity-based (`func_audio_mode`) spatial audio zones with smooth blending and scriptable events, perfect for dynamic horror/cyberpunk soundscapes.\n- **Advanced Networking**: Low-latency P2P with DCF, supporting UDP/TCP/WebSocket/gRPC, zero-copy Protobuf serialization, and a standalone hub server for *Petabyte Madness* multiplayer.\n- **Modder-Friendly**: Editor integration (D3Edit), debug tools (e.g., `audioModesDebug`, `dcf_status`), and extensive cVARs for modders extending *Petabyte Madness*.\n- **Portability**: Seamless WebAssembly (WASM) support via Emscripten with WebSocket fallback, enabling browser-based play.\n- **Alpha Status**: Version 1.0, optimized for single-player; multiplayer is experimental.\n\n**Note**: This is an alpha release developed by DeMoD LLC for *Petabyte Madness*. Test thoroughly in large maps with `com_showFPS 1`. Multiplayer is untested; prioritize single-player.\n\n## Table of Contents\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n- [Architecture Overview](#architecture-overview)\n- [Modifications](#modifications)\n- [Optimization and Edge Cases](#optimization-and-edge-cases)\n- [cVARs and Commands](#cvars-and-commands)\n- [Debug Tools](#debug-tools)\n- [Contributing](#contributing)\n- [License](#license)\n- [Resources and References](#resources-and-references)\n\n## Features\n\n### Audio (idTech4-DSP-Audio)\n- **Hardware DSP**: Offloads ray tracing, convolution, and effects (e.g., reverb, distortion) to a USB DSP (TMS320C674x, VID:PID 0x0403:0x6010), enhancing *Petabyte Madness*’s immersive audio.\n  - Up to 1000 stochastic rays per sound source with 5 bounces for occlusion/diffraction.\n  - Uses TI DSPLIB for efficient FIR filtering.\n- **Audio Mode Entities**: `func_audio_mode` defines spatial zones with modes (0-10, e.g., explore, combat) and radii.\n  - Smooth blending (lerp) or step transitions between overlapping zones.\n  - Scriptable events (`onPlayerEnter`, `onPlayerExit`) for custom audio cues in *Petabyte Madness*.\n- **Robust Integration**: Hot-plug USB support, OpenAL fallback (`s_useDSP 0`), batched USB transfers.\n- **Modder QoL**: D3Edit zone placement, debug visualizations (`audioModesDebug 2`), extensible DSP firmware.\n\n### Networking (IDTECH4-DCF-PLUGIN)\n- **Zero-Copy Networking**: Embeds `idBitMsg` in Protobuf for \u003c0.1% CPU overhead, optimized for *Petabyte Madness* multiplayer.\n- **Multi-Transport**: Supports UDP, TCP, WebSocket, and gRPC with frame-integrated health checks.\n- **P2P and Hub**: Self-healing P2P with a standalone hub server for NAT traversal and relay.\n- **WASM Support**: WebSocket fallback for browser compatibility via Emscripten.\n- **Console Integration**: CLI commands (e.g., `dcf_status`) for peer health and transport switching.\n\n### Player UX\n- Smooth audio mode transitions (`s_audioModeBlendTime`) for *Petabyte Madness*’s dynamic environments.\n- Toggleable zones (`s_audioModesEnabled 0`) for accessibility.\n- Seamless multiplayer with hub relay or P2P (`net_dcf_mode 2`).\n\n## Installation\n\n### Prerequisites\n- **Engine**: Dhewm3-based idTech4 fork.\n- **DSP Hardware**: TMS320C674x-based PCB (e.g., OMAP-L138) with USB interface.\n- **Dependencies**:\n  - libusb-1.0 (`sudo apt install libusb-1.0-0-dev` or `vcpkg install libusb`).\n  - Protobuf/gRPC (`sudo apt install libprotobuf-dev libgrpc++-dev`).\n  - C++11+ compiler (e.g., GCC, MSVC).\n  - CMake 3.10+.\n  - Code Composer Studio (CCS) for DSP firmware.\n  - Optional: Emscripten for WASM.\n- **Tools**: D3Edit for map editing.\n\n### Building idTech4-DeMoD\n1. Clone repository:\n   ```bash\n   git clone https://github.com/DeMoD-LLC/idTech4-DeMoD.git\n   cd idTech4-DeMoD\n   ```\n2. Copy mod files to source:\n   - Audio: `neo/sound/snd_dsp.h`, `snd_dsp.cpp`, `snd_system.cpp`, `snd_world.cpp`, `def/audio_modes.def`.\n   - Game: `neo/game/AudioModeEntity.h`, `AudioModeEntity.cpp`, `AudioModeManager.h`, `AudioModeManager.cpp`.\n   - Networking: `neo/framework/async/dcf/idDCFNetwork.h`, `idDCFNetwork.cpp`, `dcf_transport.cpp`.\n3. Update `neo/CMakeLists.txt`:\n   ```cmake\n   find_package(Protobuf REQUIRED)\n   find_package(gRPC CONFIG REQUIRED)\n   find_package(libusb-1.0 REQUIRED)\n   add_library(idtech4_demod\n       game/AudioModeEntity.cpp\n       game/AudioModeManager.cpp\n       sound/snd_dsp.cpp\n       framework/async/dcf/idDCFNetwork.cpp\n       framework/async/dcf/dcf_transport.cpp\n   )\n   target_link_libraries(idtech4_demod PRIVATE usb-1.0 protobuf::libprotobuf gRPC::grpc++)\n   ```\n4. Build:\n   ```bash\n   mkdir build \u0026\u0026 cd build\n   cmake .. # Add -DCMAKE_TOOLCHAIN_FILE=/path/to/emscripten.cmake for WASM\n   make -j4\n   ```\n5. Install: Copy `build/dhewm3` to game directory.\n\n### DSP Firmware Build\n1. Create a CCS project for TMS320C674x.\n2. Implement firmware (see [idTech4-DSP-Audio](#resources-and-references)).\n3. Link TI DSPLIB and USB stack.\n4. Flash via CCS.\n\n### Hub Server Build\n1. Navigate to hub:\n   ```bash\n   cd hub\n   mkdir build \u0026\u0026 cd build\n   cmake .. \u0026\u0026 make\n   ```\n\n### Generate Protos\n```bash\n./tools/generate_protos.sh\n```\n\n## Usage\n\n### For Players\n1. Connect DSP via USB (ensure drivers installed).\n2. Launch game:\n   ```bash\n   ./dhewm3 +set s_useDSP 1 +set net_dcf_mode 2\n   ```\n3. Adjust settings:\n   - Audio: `s_audioModesEnabled 0` (disable zones), `s_audioModeBlendTime 1.0` (slower transitions).\n   - Networking: `dcf_set_transport 0` (UDP), `dcf_status` (peer health).\n4. Run hub server (if needed):\n   ```bash\n   ./build/hub/dcf_hub --config examples/config.json.example\n   ```\n   Connect: `+set net_dcf_hub localhost:50051`.\n\n### For Modders\n1. **Place Audio Zones**:\n   - In D3Edit, spawn `func_audio_mode`. Set keys: `\"mode\" \"1\"`, `\"radius\" \"512\"`, `\"priority\" \"1\"`, `\"blend_type\" \"0\"`.\n2. **Script Events**:\n   ```script\n   void onPlayerEnter(entity zone) {\n       sys.println(\"Entered mode \" + zone.getKey(\"mode\"));\n       sys.playSound(\"snd_custom_cue\");\n   }\n   ```\n3. **Debug**:\n   - `audioModesDebug 2`: Draw red spheres for active zones.\n   - `listAudioModes`: List zone details.\n   - `dcf_status`: Show network peer status.\n4. **Tune**:\n   - Audio: `s_audioMaxZones 10` (smaller maps).\n   - Networking: `net_dcf_hub` for relay server.\n\n## Architecture Overview\n\nThe fork integrates DSP audio and DCF networking into idTech4’s core systems, tailored for *Petabyte Madness*. Audio processing offloads to a USB DSP, while networking wraps `idAsyncServer`/`idAsyncClient` with Protobuf/gRPC.\n\n```mermaid\ngraph TD\n    A[idTech4 Game Loop] --\u003e|Audio Data| B[idSoundSystemLocal]\n    B --\u003e|Listener/Emitters| C[idAudioModeManager]\n    C --\u003e|Mode IDs| D[idSoundHardware_DSP]\n    D --\u003e|Scene Data| E[libusb Driver]\n    E --\u003e|Bulk Transfer| F[TMS320C674x DSP]\n    F --\u003e|Processed Audio| E --\u003e D --\u003e B\n\n    A --\u003e|Network Data| G[idDCFNetwork]\n    G --\u003e|Wrap Async| H[idAsyncServer/idAsyncClient]\n    H --\u003e|Protobuf| I[Transport: UDP/TCP/WebSocket/gRPC]\n    I --\u003e|Reroute Check| J[Peer Map]\n    J --\u003e|Relay| K[DCF Hub Server]\n    I --\u003e|WASM Fallback| L[WebSocket]\n\n    subgraph \"Audio\"\n        C --\u003e|Spatial Query| M[gameLocal.clip]\n        F --\u003e N[Stochastic Ray Tracing]\n        N --\u003e O[Convolution via DSPLIB]\n    end\n    subgraph \"Networking\"\n        J --\u003e P[gRPC/UDP Heartbeat]\n        K --\u003e Q[Dynamic Peering]\n    end\n```\n\n## Modifications\n- **Sound**: `snd_dsp.h/cpp` (DSP comms), modified `snd_system.cpp`, `snd_world.cpp`.\n- **Game**: `AudioModeEntity.h/cpp`, `AudioModeManager.h/cpp`, `audio_modes.def`.\n- **Networking**: `idDCFNetwork.h/cpp`, `dcf_transport.cpp` in `neo/framework/async/dcf/`.\n- **Common**: Replaced `idNetworkSystem` with `idDCFNetwork` in `common.cpp`.\n\n## Optimization and Edge Cases\n- **Audio**:\n  - O(log n) spatial queries via `gameLocal.clip`.\n  - Batched USB transfers, cached IRs on DSP.\n  - DSP disconnect: Hot-plug retries (`s_dspReconnectInterval`), OpenAL fallback.\n  - Overlapping zones: Priority-based lerp/step blending.\n- **Networking**:\n  - Zero-copy Protobuf, \u003c0.1% CPU overhead.\n  - Frame-integrated health checks, graceful degradation (e.g., UDP fallback).\n  - Hub server scales to 100+ clients at \u003c2% CPU.\n- **Edge Cases**:\n  - No DSP/zones: Default audio mode.\n  - Large maps: Cap zones (`s_audioMaxZones`).\n  - WASM: WebSocket fallback for browsers.\n\n## cVARs and Commands\n- **Audio**:\n  - `s_useDSP` (bool, 0): Enable DSP.\n  - `s_audioModesEnabled` (bool, 1): Enable zones.\n  - `s_audioModeBlendTime` (float, 0.5): Blend duration (s).\n  - `s_audioMaxZones` (int, 20): Max zones.\n  - `s_dspReconnectInterval` (int, 5000): Hot-plug poll (ms).\n- **Networking**:\n  - `net_dcf_mode` (int, 0): 0=client, 1=server, 2=P2P.\n  - `dcf_set_transport` (int, 0): 0=UDP, 1=TCP, 2=WebSocket, 3=gRPC.\n  - `dcf_status`: Print peer health.\n- **Debug**:\n  - `audioModesDebug [0/1/2]`: 0=off, 1=list, 2=draw zones.\n  - `listAudioModes`: Dump zone details.\n\n## Debug Tools\n- `audioModesDebug 2`: Visualize active zones (red spheres).\n- `listAudioModes`: Log zone info (name, mode, radius, position).\n- `dcf_status`: Display network peer status and transport.\n- Profile: `com_showFPS 1`.\n\n## Contributing\nFork, create a feature branch, and submit PRs. Guidelines:\n- Follow idTech4 style (`id*` prefixes, no exceptions).\n- Test on Dhewm3; include unit tests for DSP math and networking.\n- Maintain \u003e85% coverage.\n- Report bugs via GitHub Issues.\n- Contact info@demod.ltd for major changes.\n\n## License\nGNU General Public License v3.0 (GPL-3.0). See [LICENSE](LICENSE).\n\n## Resources and References\n- **Dhewm3**: [github.com/dhewm/dhewm3](https://github.com/dhewm/dhewm3).\n- **idTech4-DSP-Audio**: [github.com/yourusername/idTech4-DSP-Audio](https://github.com/yourusername/idTech4-DSP-Audio).\n- **IDTECH4-DCF-PLUGIN**: [github.com/DeMoD-LLC/IDTECH4-DCF-PLUGIN](https://github.com/DeMoD-LLC/IDTECH4-DCF-PLUGIN).\n- **TI Documentation**: TMS320C674x DSP Reference (SPRUFE8B), DSPLIB.\n- **idTech4**: [Fabien Sanglard’s Doom 3 Code Review](https://fabiensanglard.net/doom3/).\n- **libusb**: [libusb.info](https://libusb.info/).\n- **Protobuf/gRPC**: [grpc.io](https://grpc.io/).\n- **Audio Ray Tracing**: US Patent 8139780B2, vaRays concepts.\n\nFor support, open an issue or contact info@demod.ltd.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falh477%2Fidtech4-demod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falh477%2Fidtech4-demod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falh477%2Fidtech4-demod/lists"}