# Introduction

## What is GPC?

***

GPC is a C-based scripting language used to program Cronus Zen™ and CronusMAX® devices.

It allows you to:

• Read controller input\
• Modify input values\
• Automate sequences\
• Remap buttons\
• Implement timing-based actions

GPC runs on the device and processes input before it is sent to the console.

## How GPC Works

***

1. A GPC script is written in Zen Studio.
2. The script is compiled into bytecode.
3. The bytecode runs inside the Cronus virtual machine (VM).
4. The VM reads controller input, applies script logic, and outputs modified values to the console.

The process is real-time and must remain performance-efficient to avoid latency.

## Core Features

***

**Intuitive Commands:**\
The command structure is intuitive, allowing those new to programming to understand and use the language with relative ease.

**C Language Syntax:**\
Borrowing its basic syntax from C, GPC provides a familiar environment for those with C programming experience, including operators, variables, and control structures such as `if`, `while`, and `for`.

**Functions:**\
Core functions such as `init {}` and `main {}` are required. `init {}` runs once when the script starts, while `main {}` loops continuously as long as the script is active.

**Event Handlers:**\
Respond to specific events, such as `event_press {}` and `event_release {}` for button presses and releases.

## 32-Bit Support

***

**Enhanced Memory and Precision:**\
32-bit support allows scripts to handle more memory and perform more precise calculations. This is particularly useful for features that require accurate input adjustments.

**Value Representation:**\
A 16-bit system supports 2¹⁶ possible values, while a 32-bit system expands this to 2³² values, allowing a significantly larger range of data to be processed and manipulated.

**Compiler Settings:**\
Zen Studio defaults to 32-bit compilation for expanded capability, while retaining the option to compile 16-bit scripts for legacy compatibility.

## Bytecode and the Virtual Machine

***

**Bytecode Compilation:**\
GPC is compiled into bytecode, the low-level code executed by Cronus devices. This process is handled by the built-in compiler in Zen Studio.

**Virtual Machine (VM):**\
Cronus devices run a VM that interprets bytecode and processes controller input before sending the modified output to the console.

**Optimized Architecture:**\
The VM operates as a stack-based machine, designed to handle controller input and output efficiently for real-time responsiveness.

**CPU Load Management:**\
Keeping CPU load below 80% is recommended to prevent timing instability or output delays.

## Optimization and Error Handling

***

**Streamlined Error Checking:**\
The Cronus VM performs minimal, essential error checks to maintain speed and efficiency.

**Developer Awareness:**\
Programmers should understand GPC’s execution limits and structure to write efficient scripts that avoid excessive CPU load or performance instability.

## New to Scripting?

***

The GPC language is designed for clarity and ease of use, borrowing core structure from C to provide a straightforward scripting foundation.

**Free Downloads:**\
Download scripts from the GPC Library and study or modify them to understand how they work.

**Step-by-Step Learning:**\
Start with simple button remapping to learn basic structure and input handling.

**Resources:**\
Use available documentation, tutorials, and example scripts to build understanding.

**Gradual Progression:**\
Advance to conditional logic, timing control, and more complex input sequences as your understanding improves.

## For Advanced Developers

***

Developers familiar with stack-based systems and performance optimization can design more complex and efficient GPC scripts.

**Complex Logic Handling:**\
Create scripts that react dynamically to different in-game conditions.

**Timing and Precision:**\
Fine-tune delays and execution timing for accurate combo sequences and input control.

**Detailed Input Manipulation:**\
Modify input values at a granular level for precise control behavior.

**Memory Management:**\
Use available memory strategically for state tracking and advanced logic flow.

**Leveraging 32-Bit Support:**\
Take advantage of expanded precision and memory capacity for larger and more detailed scripts.
