{"id":30858770,"url":"https://github.com/zer0m4n/chip8_wasm","last_synced_at":"2026-04-20T10:33:23.696Z","repository":{"id":310168269,"uuid":"1032237167","full_name":"Zer0M4n/Chip8_WASM","owner":"Zer0M4n","description":"A lightweight CHIP-8 emulator compiled from C++ to WASM. Runs in the browser with keyboard input, timers, sound, and pixel-perfect rendering.","archived":false,"fork":false,"pushed_at":"2025-08-17T20:40:56.000Z","size":1963,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-10-14T01:41:35.616Z","etag":null,"topics":["ch8","chip-8","chip8","chip8-emulator","cpp","emulation","emulator","english-spanish","github","github-pages","learn","wasm","webassembly"],"latest_commit_sha":null,"homepage":"https://zer0m4n.github.io/Chip8_WASM/","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Zer0M4n.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-08-05T02:57:05.000Z","updated_at":"2025-10-07T10:41:20.000Z","dependencies_parsed_at":"2025-10-14T01:41:01.294Z","dependency_job_id":"91ecbc3a-af28-48e0-b0a3-35ea487a6974","html_url":"https://github.com/Zer0M4n/Chip8_WASM","commit_stats":null,"previous_names":["zer0m4n/chip8_wasm"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Zer0M4n/Chip8_WASM","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zer0M4n%2FChip8_WASM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zer0M4n%2FChip8_WASM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zer0M4n%2FChip8_WASM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zer0M4n%2FChip8_WASM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Zer0M4n","download_url":"https://codeload.github.com/Zer0M4n/Chip8_WASM/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Zer0M4n%2FChip8_WASM/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32043076,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["ch8","chip-8","chip8","chip8-emulator","cpp","emulation","emulator","english-spanish","github","github-pages","learn","wasm","webassembly"],"created_at":"2025-09-07T14:47:36.721Z","updated_at":"2026-04-20T10:33:23.676Z","avatar_url":"https://github.com/Zer0M4n.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🎮 Chip8_WASM  \n**CHIP-8 Emulator using WebAssembly (WASM)**  \n\nThis project implements a **CHIP-8** emulator compiled to **WebAssembly** with Emscripten, offering a high-performance emulation experience in web browsers.\n\n---\n![Grabación 2025-08-16 193637](https://github.com/user-attachments/assets/72b4c9d3-7a81-412d-b6dc-cb38e01c9247)\n\n## 📋 Overview\n\nCHIP-8 is an interpreted programming language developed by Joseph Weisbecker in the mid-1970s. This emulator allows running classic CHIP-8 ROMs directly in the browser using WebAssembly for optimal performance.\n\n### ✨ Features\n\n- 🚀 **High performance** with WebAssembly\n- 🎯 **Full compatibility** with CHIP-8 ROMs\n- 🔧 **Integrated debugging API**  \n- 🌐 **Browser execution** without plugins\n- 📱 **Responsive** and cross-platform\n\n---\n\n## ⚡ Compilation  \n\n### Prerequisites\n\n- **Emscripten SDK** installed and configured\n- **Source file** `chip8.cpp` \n- `.ch8` ROMs for testing\n\n### Compilation Command\n\nUse `emcc` to compile `chip8.cpp` into a JavaScript + WASM module:  \n\n```bash\nemcc chip8.cpp -o chip8.js \\\n  -s EXPORTED_FUNCTIONS='[\"_load_rom\",\"_getDebuggerString\",\"_step\",\"_malloc\",\"_free\"]' \\\n  -s EXPORTED_RUNTIME_METHODS='[\"ccall\",\"cwrap\",\"HEAPU8\",\"UTF8ToString\"]' \\\n  -s ALLOW_MEMORY_GROWTH=1 \\\n  -s TOTAL_MEMORY=67108864\n```\n\n### Compilation Parameters\n\n| Parameter | Description |\n|-----------|-------------|\n| `EXPORTED_FUNCTIONS` | C++ functions exposed to JavaScript |\n| `EXPORTED_RUNTIME_METHODS` | Runtime methods for interoperability |\n| `ALLOW_MEMORY_GROWTH` | Allows dynamic memory growth |\n| `TOTAL_MEMORY` | Initial allocated memory (64MB) |\n\n---\n\n## 🏗️ System Architecture\n\n### Flow Diagram\n\n```\n          ┌────────────┐\n          │   ROM .ch8 │\n          └──────┬─────┘\n                 │\n                 ▼\n        ┌─────────────────┐\n        │  C++ / Chip-8   │\n        │ (emulator core) │\n        └──────┬──────────┘\n               │ Compiled with\n               │ Emscripten\n               ▼\n        ┌─────────────────┐\n        │   WebAssembly   │\n        │   (chip8.wasm)  │\n        └──────┬──────────┘\n               │\n               ▼\n        ┌─────────────────┐\n        │  JavaScript API │\n        │ (ccall, cwrap)  │\n        └──────┬──────────┘\n               │\n       ┌───────▼─────────┐\n       │   render() JS   │\n       │ (CHIP8 graphics)│\n       └─────────────────┘\n```\n\n### Main Components\n\n1. **C++ Core**: Main CHIP-8 emulator logic\n2. **WebAssembly Module**: Optimized compiled code\n3. **JavaScript Bridge**: API for browser communication\n4. **Rendering System**: Graphics rendering system\n\n---\n\n## 🔧 API Reference\n\n### Exported Functions\n\n#### `load_rom(romData, size)`\nLoads a CHIP-8 ROM into memory.\n- **Parameters**: \n  - `romData`: Pointer to ROM data\n  - `size`: ROM size in bytes\n- **Returns**: `true` if loading was successful\n\n#### `step()`\nExecutes one instruction cycle of the emulator.\n- **Returns**: Current emulator state\n\n#### `getDebuggerString()`\nGets debug information of the current state.\n- **Returns**: String with register and memory information\n\n---\n\n## 🚀 Basic Usage\n\n### Change rom\n\n```javascript\n async function loadRom(path) {\n      const response = await fetch(path);\n      if (!response.ok) {\n        throw new Error(`Error cargando ROM: ${response.statusText}`);\n      }\n      const buffer = await response.arrayBuffer();\n      const bytes = new Uint8Array(buffer);\n\n      const ptr = Module._malloc(bytes.length);\n      if (!ptr) throw new Error('No memory load');\n\n      Module.HEAPU8.set(bytes, ptr);\n      Module.ccall('load_rom', null, ['number', 'number'], [ptr, bytes.length]);\n      Module._free(ptr);\n\n      console.log('ROM load !!!!:', path);\n    }\n\n    Module.onRuntimeInitialized = async function () {\n  console.log('WASM runtime listo');\n  try {\n    await loadRom('rom/1dcell.ch8');\n\n    const cyclesPerFrame = 10; \n    const frameMs = 1000 / 60; \n\n    setInterval(() =\u003e {\n      for (let i = 0; i \u003c cyclesPerFrame; i++) {\n        Module.ccall('step', null, [], []);\n      }\n      updateDebugger(); // actualizar debugger\n    }, frameMs);\n\n  } catch (e) {\n    console.error('Error load rom fail:', e);\n  }\n};\n    function updateDebugger() {\n      const ptr = Module.ccall('getDebuggerString', 'number', [], []);\n      const dbgStr = Module.UTF8ToString(ptr);\n      const html = dbgStr.replace(/\\n/g, \"\u003cbr\u003e\");\n      document.getElementById('screen_debugger').innerHTML = html;\n    }\n\n```\n\n\n---\n\n## 🎮 Controls\n\n### CHIP-8 Keyboard Mapping\n\n```\nCHIP-8 Keypad    Keyboard\n┌─┬─┬─┬─┐       ┌─┬─┬─┬─┐\n│1│2│3│C│       │1│2│3│4│\n├─┼─┼─┼─┤  --\u003e  ├─┼─┼─┼─┤\n│4│5│6│D│       │Q│W│E│R│\n├─┼─┼─┼─┤       ├─┼─┼─┼─┤\n│7│8│9│E│       │A│S│D│F│\n├─┼─┼─┼─┤       ├─┼─┼─┼─┤\n│A│0│B│F│       │Z│X│C│V│\n└─┴─┴─┴─┘       └─┴─┴─┴─┘\n```\n\n---\n\n## 🛠️ Development and Debug\n\n### Debug Flags\n\nFor debug compilation:\n\n```bash\nemcc chip8.cpp -o chip8.js \\\n  -s EXPORTED_FUNCTIONS='[\"_load_rom\",\"_getDebuggerString\",\"_step\",\"_malloc\",\"_free\"]' \\\n  -s EXPORTED_RUNTIME_METHODS='[\"ccall\",\"cwrap\",\"HEAPU8\",\"UTF8ToString\"]' \\\n  -s ALLOW_MEMORY_GROWTH=1 \\\n  -s TOTAL_MEMORY=67108864 \\\n  -s ASSERTIONS=1 \\\n  -O0 -g\n```\n\n---\n\n## 📦 Project Structure\n\n```\nchip8_wasm/\n├── rom/\n├── index.html\n├── chip8.cpp\n├── chip8.wasm #compiler output\n|── chip8.js #compiler output\n└── README.md\n```\n\n---\n\n## 🤝 Contributing\n\n1. Fork the project\n2. Create a feature branch (`git checkout -b feature/new-feature`)\n3. Commit your changes (`git commit -am 'Add new feature'`)\n4. Push to the branch (`git push origin feature/new-feature`)\n5. Open a Pull Request\n\n---\n\n\n## 🔗 References\n\n- [CHIP-8 Technical Reference](http://devernay.free.fr/hacks/chip8/C8TECH10.HTM)\n- [Emscripten Documentation](https://emscripten.org/docs/)\n- [WebAssembly Specification](https://webassembly.github.io/spec/)\n\n---\n\n\n**Enjoy coding and playing with CHIP-8!** 🎮✨\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzer0m4n%2Fchip8_wasm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzer0m4n%2Fchip8_wasm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzer0m4n%2Fchip8_wasm/lists"}