You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
defexample():
x: int=0# With defaultname: string[20] ="Player"# String with capacityscores: array[byte, 10] # Array (no default)buffer: array[byte, 100] = [0] # Array filled with zerosdata: array[byte, 5] = (1,2,3) # Array with tuple init
Memory-mapped Variables
border: byte[0xD020] # Single value at addressscreen: array[byte, 1000][0x0400] # Array at addresscounter: irq_safe[word[0x0080]] # Atomic multi-byte accesstheme: SyntaxTheme[0x8814] # Class at address (no auto-init!)
Tuples (read-only data)
# Constant data - stored in data segmentcolors: tuple[byte] = (0, 2, 5, 7, 10, 14)
x: byte=colors[2] # Reading OK# Pointer variable - can be reassignedptr: tuple[byte] # Uninitialized (pointer)ptr=colors# Assign to dataprint(len(ptr)) # 6# String literals in tuple[char]/tuple[byte]menu: tuple[char] = (0x10, s"MENU", 0x11) # Screen codesmsg: tuple[byte] = (0x0D, "Hello", 0x0D) # PETSCII# Copy tuple to arraybuffer: array[byte, 10]
buffer=colors# Fast memcpybuffer[0] =99# Now modifiable
defexample():
enemy: Enemy=Enemy()
e: alias[Enemy]
alias(e, addr(enemy)) # Point to enemye.x=100# Modifies enemy.x# Pass composite types as alias (required!)defprocess(e: alias[Enemy]):
e.x=50defmain():
enemy: Enemy=Enemy()
process(enemy) # Auto-converted to alias
Built-in Functions
Function
Description
print(a, b, ...)
Output (no auto newline/space!)
printsep(sep, ...)
Output with separator
sprint(buf, ...)
Write to string buffer
str(value[, decimals])
Convert to string (primitives + objects)
len(s)
String/array/tuple length
size(x)
Memory size in bytes
getkey()
Non-blocking key read (0 if none)
waitkey()
Blocking key read
abs(x)
Absolute value
min(a, b)
Smaller value
max(a, b)
Larger value
addr(x)
Memory address of variable, property, element, or function
alias(ref, address)
Set alias to point to address
memfill(dest, value)
Fill memory with byte value
blkcpy(dest, src, n)
Copy n bytes from src to dest
Type Conversions
result=word(a) +word(b) # Prevent overflowi=int(f) # Truncate floatflag=bool(value) # Full value checkx=f16(5) # Fixed-point 8.8y=f32(3.14) # Fixed-point 16.16