DEFINITION MODULE SDL3Utils ; (* m2SDL3 - small pure-Modula-2 helpers over the FOR "C" bindings. CStrToM2 copies NUL-terminated C strings (ADDRESS) into Modula-2 CHAR arrays (NUL-terminated, truncated to fit). PollM2Event decodes one queued SDL_Event into a small record: SDL3 puts the Uint32 type at offset 0 of every event; key events (SDL_KeyboardEvent) carry the Uint32 keycode at offset 28 (see , verified with offsetof). Both QUIT (0100H) and WINDOW_CLOSE_REQUESTED (0210H) map to evQuit, so a plain "close window" button press terminates DrainEvents loops. VersionMajor/Minor/Micro decode the int returned by SDL3Version.SDL_GetVersion (major*1000000+minor*1000+micro). *) FROM SYSTEM IMPORT ADDRESS; EXPORT UNQUALIFIED EventKind, M2Event, CStrToM2, GetErrorString, PollM2Event, DrainEvents, VersionMajor, VersionMinor, VersionMicro; TYPE EventKind = (evQuit, evKey, evOther); M2Event = RECORD kind: EventKind; sym: INTEGER; (* valid when kind = evKey *) pressed: BOOLEAN; (* valid when kind = evKey *) END; PROCEDURE CStrToM2 (src: ADDRESS; VAR dst: ARRAY OF CHAR); PROCEDURE GetErrorString (VAR buf: ARRAY OF CHAR); PROCEDURE PollM2Event (VAR ev: M2Event) : BOOLEAN; PROCEDURE DrainEvents (VAR quit: BOOLEAN); PROCEDURE VersionMajor (v: INTEGER) : INTEGER; PROCEDURE VersionMinor (v: INTEGER) : INTEGER; PROCEDURE VersionMicro (v: INTEGER) : INTEGER; END SDL3Utils.