For the complete documentation index, see llms.txt. This page is also available as Markdown.

BVAR storage

Cronus Zen provides 1,024 BVAR entries, indexed 0..1023. Use get_bvar(index) to read one entry and set_bvar(index, value) to write one. Each entry stores a signed 16-bit word (-32768..32767), so validate or clamp a runtime value before writing it instead of assuming the runtime integer's wider range will persist.

bvar-edit-value.gpc
int edit_value;

main {
    if(event_press(PS5_CROSS)) {
        edit_value = -75;
        set_bvar(120, edit_value);
    }

    if(event_press(PS5_OPTIONS)) edit_value = get_bvar(120);
    set_val(TRACE_1, edit_value);
}

Keep BVAR writes behind explicit edit/save events rather than the base of main. Read a record during initialization, profile changes, or another deliberate cache refresh instead of rescanning the complete store every cycle.

Do not scatter numeric BVAR indexes. Define a schema:

define BVAR_SCHEMA_VERSION = 1;
define BVAR_HEADER_BASE = 0;
define BVAR_RECORD_BASE = 16;
define BVAR_RECORD_STRIDE = 8;
define BVAR_FIELD_ID = 0;
define BVAR_FIELD_LENGTH = 1;
define BVAR_FIELD_X = 2;
define BVAR_FIELD_Y = 3;

For record index r, compute:

Validate every computed index against 0..1023 and make the maximum record count a compile-time constant.

Last updated