| English | Português (Brasil) |
A program contains:
program keyword;type section;const section;var section;begin;end keyword;Example:
program Minimal;
const
DefaultBackgroundColor: nes_color = $21;
var
BackgroundColor: nes_color;
FrameCounter: byte;
RenderingEnabled: boolean;
procedure Initialize(Start: byte; Enabled: boolean);
begin
FrameCounter := Start;
RenderingEnabled := Enabled;
end;
begin
BackgroundColor := DefaultBackgroundColor;
Initialize($00, true);
nes.set_background_color(BackgroundColor);
nes.run;
end.
The declaration sections must appear in this order: type, const, then
var, followed by any interleaved procedures and
functions. The main block contains
the top-level initialization sequence and may continue with frame-synchronized
main-thread logic after nes.run.
The type section may declare nominal enumerations and
fixed-layout records. Record fields may use any declared enum in
the section; nested record fields remain unsupported.
Static nes.on_update(Procedure) and nes.on_vblank(Procedure) registrations,
when present, belong to the unconditional top-level initialization sequence
before nes.run. See Frame callbacks.
The optional nes.load_background() command is also an unconditional,
top-level initialization statement before nes.run. It has no arguments and
requires configured nametable data.
Bounded runtime background updates may be staged from main code or procedures. Their queue-mutating operations are not allowed on a VBlank callback path; the simple overflow query is safe there.