> For the complete documentation index, see [llms.txt](https://docs.perception.cx/perception/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.perception.cx/perception/readme.md).

# Enma - Overview

Enma compiles whole modules ahead of time to native x64 and follows C++ semantics. This site documents the APIs perception registers for scripts. For the language itself, see the [Enma documentation](https://enma-1.gitbook.io/enma).

## Available APIs

### Enma libraries

* [Core](https://docs.perception.cx/perception/enma-lang/addons/core)
* [STD Library](https://docs.perception.cx/perception/enma-lang/addons/std-library)
* [Math](https://docs.perception.cx/perception/enma-lang/addons/math)
* [Math:3D](https://docs.perception.cx/perception/enma-lang/addons/math-3d)
* [SIMD](https://docs.perception.cx/perception/enma-lang/addons/simd)
* [JSON](https://docs.perception.cx/perception/enma-lang/addons/json)
* [Regex](https://docs.perception.cx/perception/enma-lang/addons/regex)
* [Filesystem](https://docs.perception.cx/perception/enma-lang/addons/file)
* [Thread](https://docs.perception.cx/perception/enma-lang/addons/thread)
* [Atomic](https://docs.perception.cx/perception/enma-lang/addons/atomic)
* [Bits](https://docs.perception.cx/perception/enma-lang/addons/bits)
* [Time](https://docs.perception.cx/perception/enma-lang/addons/time)

### Perception script API

* [Lifecycle and Routines](/perception/lifecycle-and-routines.md)
* [Render](/perception/render-api.md)
* [Proc](/perception/proc-api.md)
* [CPU](/perception/cpu-api.md)
* [Sound](/perception/sound-api.md)
* [Zydis](/perception/zydis-api.md)
* [Win](/perception/win-api.md)
* [Input](/perception/input-api.md)
* [Unicorn](/perception/unicorn-api.md)
* [Net](/perception/net-api.md)
* [GUI](/perception/gui-api.md)

### AI agent API

* [MCP](/perception/mcp-api.md): JSON-RPC over local TCP or HTTP.

## Minimal script

```cpp
using namespace render;

int64 g_tick;

void my_draw(int64 data) {
    g_tick = g_tick + 1;
    color white = color(255, 255, 255, 255);
    color no_effect = color(0, 0, 0, 0);
    std::string text = "tick=" + std::to_string(g_tick);
    draw_text(text, vec2(40.0, 40.0), white, get_font20(), 0, no_effect, 0.0);
}

int64 main() {
    g_tick = 0;
    register_routine(reinterpret_cast<int64>(my_draw), 0);
    return 1;
}
```

See [Lifecycle and Routines](/perception/lifecycle-and-routines.md) for entry-point and routine behavior.

## Conventions

* **Colors and positions:** use `color(255, 255, 255, 255)` and `vec2(10.0, 20.0)`.
* **Float32 literals:** use `0.2f` for `float32` data.
* **Handles:** values returned by `create_*` and `load_*` calls are opaque. Pass them to the matching API and do not inspect them.
* **Casts:** use `static_cast<T>(x)` for numeric conversions and `reinterpret_cast<int64>(fn)` for routine and callback function handles.
* **Strings:** use `std::string` for values and returns, and `const char*` for read-only parameters. `std::to_string(n)` converts numeric values.
* **Containers:** use `std::vector<T>` for dynamic storage and `std::array<T, N>` for fixed-size storage.
