# khalifa007/capymobile architecture

> Architecture diagram of the GitHub repository khalifa007/capymobile, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/khalifa007/capymobile
- Repository: https://github.com/khalifa007/capymobile

## Overview

Capy Mobile is a native PS5 J2ME game player. The main workflow is to discover copied JARs, select a game, configure its phone screen and speed, then run it with DualSense input and render its picture and sound. The app also remembers per-game settings and exposes logs and saves. The README documents the major app capabilities; sampled source confirms key interfaces and PS5 platform behavior, but does not show every app call or the engine implementation, so some documented links are cited to the README.

Main entry points: [`src/app.c`](https://github.com/khalifa007/capymobile/blob/main/src/app.c) (Game list and menus), [`src/core.c`](https://github.com/khalifa007/capymobile/blob/main/src/core.c) (J2ME frontend), [`src/ps5/platform.c`](https://github.com/khalifa007/capymobile/blob/main/src/ps5/platform.c) (PS5 screen and pad), [`src/ps5/memory.c`](https://github.com/khalifa007/capymobile/blob/main/src/ps5/memory.c) (Large memory blocks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App experience"]
  node_appui["Game list and menus<br/>[app.c]"]
  node_catalog["JAR catalog and metadata<br/>[app.c]"]
  node_preferences["Game preferences<br/>[app.c]"]
  node_gamefiles["Installed games"]
  node_saves[("Saves and settings")]
end

subgraph group_runtime["Game runtime"]
  node_core["J2ME frontend<br/>[core.c]"]
  node_nojme["noJMe engine"]
  node_engineconfig["Engine environment<br/>[engine_env.h]"]
  node_drawing["UI drawing<br/>[draw.h]"]
end

subgraph group_io["Console I/O"]
  node_audio["Audio output<br/>[audio.c]"]
  node_platform["PS5 screen and pad<br/>[platform.c]"]
  node_log["App logging<br/>[log.c]"]
end

subgraph group_support["PS5 runtime support"]
  node_allocator["Memory allocation<br/>[alloc.c]"]
  node_memory["Large memory blocks<br/>[memory.c]"]
  node_contexts["Cooperative contexts<br/>[capy_ucontext.c]"]
  node_tls["Thread-local storage<br/>[emutls.c]"]
  node_libc["C library compatibility<br/>[libc_port.c]"]
end

node_player(("Player"))

node_player -->|"uses"| node_appui
node_gamefiles -->|"scans"| node_catalog
node_catalog -->|"lists games"| node_appui
node_player -->|"selects game"| node_appui
node_appui -->|"sets options"| node_preferences
node_preferences -->|"stores choices"| node_saves
node_appui -->|"uses game saves"| node_saves
node_appui -->|"drives game"| node_core
node_core -->|"fronts engine"| node_nojme
node_appui -->|"sets environment"| node_engineconfig
node_appui -->|"draws menus"| node_drawing
node_appui -->|"reads input and presents frames"| node_platform
node_core -->|"provides game sound"| node_audio
node_appui -->|"controls playback"| node_audio
node_appui -->|"writes diagnostics"| node_log
node_platform -->|"allocates frame"| node_memory
node_memory -->|"uses heap blocks"| node_allocator
node_nojme -->|"switches threads"| node_contexts
node_nojme -.->|"uses thread-local storage"| node_tls
node_nojme -.->|"uses compatibility layer"| node_libc
node_libc -->|"supplies environment"| node_engineconfig

click node_appui "https://github.com/khalifa007/capymobile/blob/main/src/app.c"
click node_catalog "https://github.com/khalifa007/capymobile/blob/main/src/app.c"
click node_preferences "https://github.com/khalifa007/capymobile/blob/main/src/app.c"
click node_core "https://github.com/khalifa007/capymobile/blob/main/src/core.c"
click node_engineconfig "https://github.com/khalifa007/capymobile/blob/main/src/engine_env.h"
click node_drawing "https://github.com/khalifa007/capymobile/blob/main/src/draw.h"
click node_audio "https://github.com/khalifa007/capymobile/blob/main/src/audio.c"
click node_platform "https://github.com/khalifa007/capymobile/blob/main/src/ps5/platform.c"
click node_log "https://github.com/khalifa007/capymobile/blob/main/src/log.c"
click node_allocator "https://github.com/khalifa007/capymobile/blob/main/src/ps5/alloc.c"
click node_memory "https://github.com/khalifa007/capymobile/blob/main/src/ps5/memory.c"
click node_contexts "https://github.com/khalifa007/capymobile/blob/main/src/ps5/capy_ucontext.c"
click node_tls "https://github.com/khalifa007/capymobile/blob/main/src/ps5/emutls.c"
click node_libc "https://github.com/khalifa007/capymobile/blob/main/src/ps5/libc_port.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_appui,node_catalog,node_preferences,node_gamefiles,node_saves toneBlue
class node_core,node_nojme,node_engineconfig,node_drawing toneAmber
class node_audio,node_platform,node_log toneMint
class node_allocator,node_memory,node_contexts,node_tls,node_libc toneRose
class node_player toneIndigo
```

## Components

### App experience

- [Game list and menus](https://github.com/khalifa007/capymobile/blob/main/src/app.c): `src/app.c`
- [JAR catalog and metadata](https://github.com/khalifa007/capymobile/blob/main/src/app.c): `src/app.c`
- [Game preferences](https://github.com/khalifa007/capymobile/blob/main/src/app.c): `src/app.c`
- **Installed games**
- **Saves and settings**

### Game runtime

- [J2ME frontend](https://github.com/khalifa007/capymobile/blob/main/src/core.c): `src/core.c`
- **noJMe engine**
- [Engine environment](https://github.com/khalifa007/capymobile/blob/main/src/engine_env.h): `src/engine_env.h`
- [UI drawing](https://github.com/khalifa007/capymobile/blob/main/src/draw.h): `src/draw.h`

### Console I/O

- [Audio output](https://github.com/khalifa007/capymobile/blob/main/src/audio.c): `src/audio.c`
- [PS5 screen and pad](https://github.com/khalifa007/capymobile/blob/main/src/ps5/platform.c): `src/ps5/platform.c`
- [App logging](https://github.com/khalifa007/capymobile/blob/main/src/log.c): `src/log.c`

### PS5 runtime support

- [Memory allocation](https://github.com/khalifa007/capymobile/blob/main/src/ps5/alloc.c): `src/ps5/alloc.c`
- [Large memory blocks](https://github.com/khalifa007/capymobile/blob/main/src/ps5/memory.c): `src/ps5/memory.c`
- [Cooperative contexts](https://github.com/khalifa007/capymobile/blob/main/src/ps5/capy_ucontext.c): `src/ps5/capy_ucontext.c`
- [Thread-local storage](https://github.com/khalifa007/capymobile/blob/main/src/ps5/emutls.c): `src/ps5/emutls.c`
- [C library compatibility](https://github.com/khalifa007/capymobile/blob/main/src/ps5/libc_port.c): `src/ps5/libc_port.c`

### Other components

- **Player**

## Connections

- Player → Game list and menus: uses (evidence: `README.md`)
- Installed games → JAR catalog and metadata: scans (evidence: `README.md`)
- JAR catalog and metadata → Game list and menus: lists games (evidence: `src/app.c`)
- Player → Game list and menus: selects game (evidence: `README.md`)
- Game list and menus → Game preferences: sets options (evidence: `src/app.c`)
- Game preferences → Saves and settings: stores choices (evidence: `src/app.c`)
- Game list and menus → Saves and settings: uses game saves (evidence: `README.md`)
- Game list and menus → J2ME frontend: drives game (evidence: `README.md`)
- J2ME frontend → noJMe engine: fronts engine (evidence: `README.md`)
- Game list and menus → Engine environment: sets environment (evidence: `src/engine_env.h`)
- Game list and menus → UI drawing: draws menus (evidence: `src/app.c`)
- Game list and menus → PS5 screen and pad: reads input and presents frames (evidence: `README.md`)
- J2ME frontend → Audio output: provides game sound (evidence: `README.md`)
- Game list and menus → Audio output: controls playback (evidence: `README.md`)
- Game list and menus → App logging: writes diagnostics (evidence: `src/app.c`)
- PS5 screen and pad → Large memory blocks: allocates frame (evidence: `src/ps5/platform.c`)
- Large memory blocks → Memory allocation: uses heap blocks
- noJMe engine → Cooperative contexts: switches threads
- noJMe engine → Thread-local storage: uses thread-local storage
- noJMe engine → C library compatibility: uses compatibility layer
- C library compatibility → Engine environment: supplies environment (evidence: `src/engine_env.h`)
