all ints are 64-bit all arguments without explicit types are ints memory read(addr, size) -> int size can be 8 16 32 64 -8 -16 -32 -64 positive means unsigned, or negative signed write(addr, size, value) same as read but stores the value copy(dst, src, len) copy(dst, src) copy the bytes from src into dst fill(addr, val, len) fill addr with val up to len tostr(addr, len) -> string return a lua string of bytes at addr + len image create(addr, width, height) -> int returns a gpu image with the given bytes width and height are in pixels addr must contain 4 bytes per pixel (argb) NOTE: alpha is currently ignored delete(img) deletes the gpu image copy(dst, src, dx, dy) copy(dst, src, dx, dy, sx, sy, sw, sh) copies one image to another at given destination coordinates are in pixels update(img, dx, dy, dw, dh, addr, pitch=0) fills image with bytes coordinates are in pixels, pitch is in bytes pitch defaults to dw*4 asm assemble(addr, op, ...operands) -> int|string writes assembly to addr returns the byte after the last one written on error, writes nothing, returns error string op must be a mnemonic in asm.ops operands are each tables as follows: { asm.loc.reg, val, 'is4' } { asm.loc.ptr, 'segment', 'offset' } { asm.loc.mem, 'base', 'index', 'scale', 'disp', 'bytes' } { asm.loc.imm, val, 'signed' } bare args are sequential quoted args are table keys defaulting to 0 assembleall(addr, instrs...) -> int|[nil,string] same as assemble but allows more than one instruction on failure, returns [nil,error] disassemble(addr, len) -> string disassemble the code at addr up to len returns human readable assembly string exec(addr, ...) calls a function at addr, passing lua arguments NOTE: currently only lua numbers are valid args NOTE: currently only accepts single arg NOTE: currently does not return any values ops = { mov, nul, and, ret, jnbe, ... } reg = { rax, rsi, xmm0, eflags, ... } loc = { reg, mem, ptr, imm } sync (DO NOT USE) newthread(fn, ...) -> int|[nil,string] creates and returns a thread handle extra args are passed to fn returns error only on syntax errors sleep(ms) sleep the current thread for ms milliseconds newcritsec() -> int return a new critical section delcritsec(ms) delete a critical section entercritsec(ms) enter a critical section only one thread can enter at a time leavecritsec(ms) leave a critical section closehandle(int) frees resources and notifies waiters these must be manually closed: threads, semaphores globals int() called on interrupt event note that 30fps is an event fullscreen() toggle fullscreen print(str, x, y) draw text str at x,y default x,y starts at 0,0 increments default y+6 only useful for debugging lua language extensions integer[offset] :: *((uint8*)integer + offset) integer[offset]=n :: *((uint8*)integer + offset)=n integer(...) :: asm.exec(integer, ...) #integer :: *(uint64*)addr system memory 0x100000 bytes of user memory base addr = 0x10000 all pages are executable 0x10000 dword = last event 0x10004 dword = last event arg 0x10008 dword = system clock 0x10100 qword = addresses int screen void blit() void toggleFullscreen() int aplusbtimes2(int a, int b) int fontsheet 0x70000 nullt = third party licenses interrupt events name id argument -------------------------------- frame 1 mousemove 2 hi=x lo=y mousewheel 3 delta mousedown 4 button mouseup 5 button keydown 6 keycode keyup 7 keycode keychar 8 ascii code