Toggle menu
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.
The main server is currently down. We are running on a backup server, so editing and search functionality are temporarily disabled. Please check back in a few hours.

PocketCompiler 3DS: Difference between revisions

From GameBrew
Created page with "{{Infobox 3DS Homebrews |title=PocketCompiler |image=PocketCompiler3DS.png |description=An almost fully featured HTML/JS/CSS compiler application made for 3DS/n3DS consoles. |author=PlanetDogeCodes |lastupdated=2026/06/17 |type=Other Apps |version=0.36 |license=Apache-2.0 |download=https://dlhb.gamebrew.org/3dshomebrews/PocketCompiler3DS.7z |website=https://github.com/PlanetDogeCodes/Pocket-Compiler |source=https://github.com/PlanetDogeCodes/Pocket-Compiler }} PocketComp..."
 
0.38
Line 4: Line 4:
|description=An almost fully featured HTML/JS/CSS compiler application made for 3DS/n3DS consoles.
|description=An almost fully featured HTML/JS/CSS compiler application made for 3DS/n3DS consoles.
|author=PlanetDogeCodes
|author=PlanetDogeCodes
|lastupdated=2026/06/17
|lastupdated=2026/07/03
|type=Other Apps
|type=Other Apps
|version=0.36
|version=0.38
|license=Apache-2.0
|license=Apache-2.0
|download=https://dlhb.gamebrew.org/3dshomebrews/PocketCompiler3DS.7z
|download=https://dlhb.gamebrew.org/3dshomebrews/PocketCompiler3DS.7z
Line 115: Line 115:


== Changelog ==
== Changelog ==
'''v0.38'''
* '''Crash / correctness bugs:'''
** Canvas 2D silently broken — wc_install_bindings() built its property-setup script with snprintf into a 512-byte buffer, but the actual script is 854 bytes. It was truncating mid-statement, so ctx.fillStyle = 'red' and every other canvas property setter did nothing, with zero error shown. Now passed as a literal directly to duk_eval_string — no buffer, no truncation possible.
** Event listeners could misfire — DOMEvent.js_ref was a uint8_t, silently wrapping after the 255th addEventListener() call in a session and firing the wrong callback. Widened to uint16_t.
** Listener ref counter never reset — it was a function-local static that persisted across every recompile instead of resetting with the fresh Duktape context each page load gets. Moved to file scope with an explicit reset tied to context creation.
** Unchecked array access in we_document_open() — switched to the existing bounds-checked accessor so a corrupted sibling chain can't read out-of-bounds memory.
* '''Stack-safety hardening (3DS has only 256KB of stack):'''
** ~3KB of stacked buffers in the CSS parser — css_parse_inline's 2048-byte buffer is called while css_parse_stylesheet's 1024-byte buffer is still live. Both made static (verified safe: parsing is never re-entrant).
** Unbounded layout recursion — nothing stopped a deeply-nested DOM tree (up to the 1024-node cap) from recursing that many stack frames deep. Added a depth guard capped well above any realistic page.
* Version v0.37 was skipped due to issues with a beta build.
* CIA files will be added in version 1.0
'''v0.36'''
'''v0.36'''
* '''Crash / correctness fixes:'''
* '''Crash / correctness fixes:'''

Revision as of 02:41, 3 July 2026

PocketCompiler
General
AuthorPlanetDogeCodes
TypeOther Apps
Version0.38
LicenseApache-2.0
Last Updated2026/07/03
Links
Download
Website
Source

PocketCompiler is an experimental Nintendo 3DS HTML/JS/CSS compiler and code editor

It's designed to let you write HTML/JS/CSS on the 3DS, allowing for easy development. You can:

  • Edit code on the bottom screen.
  • Preview output/status on the top screen.
  • Save/load projects from the SD card.

The default project path is sdmc:/3ds/PocketCompiler/projects/

Features

  • Basic HTML parsing.
  • Simple CSS.
  • Basic JavaScript runtime capabilities.
  • DOM-like elements.
  • Keyboard/Mouse/Touch events.
  • Nearly complete iframe support.
  • document.write()
  • Limited API and link fetching.
  • IndexedDB-adjacent SD-card storage.
  • Custom Canvas rendering.
  • Custom WebGL rendering.
  • Image loading.
  • Web audio support.

Canvas / WebGL

PocketCompiler has rendering systems for:

  • canvas command buffers
  • rectangles, lines, text, placeholders
  • getContext("webgl") detection
  • buffers
  • shaders/programs
  • uniforms/attributes
  • textures
  • draw calls
  • viewport/depth/blend/scissor state
  • Citro3D backend scaffolding

This is not yet full WebGL.

Storage

PocketCompiler includes SD-card-backed storage systems:

sdmc:/3ds/PocketCompiler/idb/
sdmc:/3ds/PocketCompiler/cache_api/
sdmc:/3ds/PocketCompiler/resource_cache/

Supported or scaffolded:

  • IndexedDB-style databases/object stores
  • putgetdeleteclearcount
  • localStorage-style storage
  • sessionStorage-style storage
  • Cache API-style storage
  • binary-safe values
  • 1 MB per-value/resource cap

Audio

PocketCompiler includes a small Web Audio-style system:

  • AudioContext-like runtime
  • OscillatorNode-like node
  • GainNode-like node
  • sine/square/triangle/sawtooth tones
  • NDSP-backed output when available
  • safe fallback if audio fails

Limitations

PocketCompiler is still in early development.

It does not yet fully support:

  • Complete HTML parsing
  • Full CSS layout/cascade
  • Full modern JavaScript/browser behavior
  • Complete Promise/event-loop behavior
  • Full WebGL 1.0
  • Real GLSL shader translation
  • Full Canvas 2D API
  • Full Web Audio API
  • Full IndexedDB compatibility
  • Complete iframe isolation
  • Pointer lock

The 3DS also has very limited RAM, CPU, GPU power, and screen space, so PocketCompiler uses strict safety limits (1 MB per resource/value/cache entry, bounded event queues, bounded command buffers, bounded editor/runtime structures)

Controls

D-Pad - Arrow key movement

Circle Pad - Move mouse cursor (it's just a dot)

A - Click, Edit code line

B - Undo

X - Save project

Y - Load project

Start - Run/Compile

Select - Show controls menu

Screenshots

PocketCompiler3DS2.png PocketCompiler3DS3.png

Changelog

v0.38

  • Crash / correctness bugs:
    • Canvas 2D silently broken — wc_install_bindings() built its property-setup script with snprintf into a 512-byte buffer, but the actual script is 854 bytes. It was truncating mid-statement, so ctx.fillStyle = 'red' and every other canvas property setter did nothing, with zero error shown. Now passed as a literal directly to duk_eval_string — no buffer, no truncation possible.
    • Event listeners could misfire — DOMEvent.js_ref was a uint8_t, silently wrapping after the 255th addEventListener() call in a session and firing the wrong callback. Widened to uint16_t.
    • Listener ref counter never reset — it was a function-local static that persisted across every recompile instead of resetting with the fresh Duktape context each page load gets. Moved to file scope with an explicit reset tied to context creation.
    • Unchecked array access in we_document_open() — switched to the existing bounds-checked accessor so a corrupted sibling chain can't read out-of-bounds memory.
  • Stack-safety hardening (3DS has only 256KB of stack):
    • ~3KB of stacked buffers in the CSS parser — css_parse_inline's 2048-byte buffer is called while css_parse_stylesheet's 1024-byte buffer is still live. Both made static (verified safe: parsing is never re-entrant).
    • Unbounded layout recursion — nothing stopped a deeply-nested DOM tree (up to the 1024-node cap) from recursing that many stack frames deep. Added a depth guard capped well above any realistic page.
  • Version v0.37 was skipped due to issues with a beta build.
  • CIA files will be added in version 1.0

v0.36

  • Crash / correctness fixes:
    • editor_find and editor_find_prevstart_line was not clamped before use — with a corrupted or uninitialized value it could make editor_get_line walk off the end of the buffer. Now clamped to [0, total-1].
    • editor_replace_at: added col > llen guard so an exact-end-of-line replacement can't produce a negative memcpy count.
    • we_eval_js: added !g_web_engine.loaded check — without it, a stale non-NULL js_ctx pointer left from a previous we_unload() call could be dereferenced.
    • draw_consolei < WJS_LOG_MAX_LINES guard added — a corrupted g_wjs_log_n could have caused a read past the log array bounds.
  • Compiler warning fixes:
    • (down & KEY_X) && ... — explicit parentheses added (GCC -Wall warning eliminated).
    • Two strcat() calls replaced with strncat().
    • LAYOUT_ED_H corrected to 178.0f (was 180.0f) — the 2px mismatch caused the cursor-to-line mapping to select the wrong line near the bottom of the editor panel.

v0.34

  • Slight UI changes
  • Bordered rendering for text & iframe
  • Memory usage fixes
  • More accurate CSS parsing
File Fixes/Changes
web_layout.c Body avail_w bug fixed: was 2×margin_left, now margin_left + margin_right.
web_layout.c Text node lay_w uses full available container width for alignment.
web_render.c Scale formula size/11.0f → size/30.0f (correct for system font at scale 1.0 ≈ 30px).
web_render.c TEXT nodes use parent container width for proper text alignment.
web_render.c Bottom border drawn on document viewport to frame the output area.
web_engine.c css_apply_ua_defaults() called after css_reset(), before parse — so user styles always win.
web_engine.c RUNNING bar cleaned up; conflicting title bar overlay removed.

v0.33.5

  • Hopefully fixed crashing issues

v0.33.4

  • MAYBE fixed crashing issues (untested, will update when tested)

v0.33.3

  • Fixed surface-level crashing issues

v0.33.2

  • Maybe fixed crashing issues
  • Stability fixes
  • Fixed errors while compiling

v0.33

  • Fixed scrolling
  • Fixed line truncation
  • Added more complete rendering capabilities
  • Added pointer lock integration
  • Added page interaction

v0.32

  • Fixed the HTML rendering engine
  • Slight UI changes

v0.31.1

  • Completely overhauled the UI (AI was used to help with this)
  • New frame buffer that minimizes the visual bug to almost unnoticeable proportions.

Pre-Release v0.30

  • Fixed app crashing on file explorer open (MAYBE FR THIS TIME)
  • Fixed the visual bug (kinda)

Credits

PocketCompiler project and idea by PlanetDogeCodes (me). Some browser runtime features, custom Canvas/WebGL Integration, and 3DS Optimizations were all made with help from GPT-5.5 xhigh. Some UI elements and DOM-style event handling were made with help from Claude Sonnet 4.6

Built with:

  • Visual Studio Code
  • devkitPro
  • devkitARM
  • libctru
  • Citro2D
  • Citro3D

External links

Advertising: