Math & utilities
Geometry helpers, the console's deterministic RNG and CRC-32 helpers. Math polyfills are listed on the System page.
Conventions on every page: Availability says whether a symbol exists on the console BIOS, the emulator, or both. c8b and C8B are the same table.
Contents
- Geometry (c8b.geometry)
c8b.geometry.rect.newc8b.geometry.rect.fast_intersectionc8b.geometry.rect:unpackc8b.geometry.rect:copyc8b.geometry.rect:offsetc8b.geometry.rect:offsetByc8b.geometry.rect:insetc8b.geometry.rect:insetByc8b.geometry.rect:isEmptyc8b.geometry.rect:containsPointc8b.geometry.rect:intersectsc8b.geometry.rect:intersectionc8b.geometry.rect:unionc8b.geometry.rect:centerPointc8b.geometry.point.newc8b.geometry.point:unpackc8b.geometry.point:copyc8b.geometry.point:offsetc8b.geometry.point:distanceToPoint
- Deterministic RNG (c8b.rng, console only)
- Low-level bindings (C8B.*)
Geometry (c8b.geometry)
c8b.geometry.rect.new
c8b.geometry.rect.new(x, y, width, height) | c8b.geometry.rect(x, y, w, h)
Creates a rect {x, y, width, height}.
- Returns: rect
- Availability: Console (BIOS) and emulator
c8b.geometry.rect.fast_intersection
c8b.geometry.rect.fast_intersection(ax, ay, aw, ah, bx, by, bw, bh)
Intersection of two rects given as numbers.
- Returns: x, y, width, height
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:unpack
rect:unpack()
x, y, width, height.
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:copy
rect:copy()
New rect.
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:offset
rect:offset(dx, dy)
Moves in place.
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:offsetBy
rect:offsetBy(dx, dy)
Moved copy.
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:inset
rect:inset(dx, dy)
Shrinks in place.
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:insetBy
rect:insetBy(dx, dy)
Shrunk copy.
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:isEmpty
rect:isEmpty()
Width or height <= 0.
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:containsPoint
rect:containsPoint(x, y) | (point)
Point inside (right/bottom edges exclusive).
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:intersects
rect:intersects(r)
Overlap test.
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:intersection
rect:intersection(r)
Overlap rect (empty rect 0,0,0,0 if none).
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:union
rect:union(r)
Bounding rect.
- Availability: Console (BIOS) and emulator
c8b.geometry.rect:centerPoint
rect:centerPoint()
Centre as a point.
- Availability: Console (BIOS) and emulator
c8b.geometry.point.new
c8b.geometry.point.new(x, y)
Creates a point {x, y}.
- Returns: point
- Availability: Console (BIOS) and emulator
c8b.geometry.point:unpack
point:unpack()
x, y.
- Availability: Console (BIOS) and emulator
c8b.geometry.point:copy
point:copy()
New point.
- Availability: Console (BIOS) and emulator
c8b.geometry.point:offset
point:offset(dx, dy)
Moves in place.
- Availability: Console (BIOS) and emulator
c8b.geometry.point:distanceToPoint
point:distanceToPoint(p)
Euclidean distance.
- Availability: Console (BIOS) and emulator
Deterministic RNG (c8b.rng, console only)
c8b.rng.seed
c8b.rng.seed(n)
Seeds the generator (for lock-step multiplayer).
- Availability: Console (BIOS) only
- Note: Not available in the emulator.
c8b.rng.next
c8b.rng.next()
Next raw 32-bit value.
- Returns: integer
- Availability: Console (BIOS) only
c8b.rng.nextInt
c8b.rng.nextInt(min, max)
Integer in [min, max].
- Returns: integer
- Availability: Console (BIOS) only
c8b.rng.nextFloat
c8b.rng.nextFloat()
Float in [0, 1).
- Returns: number
- Availability: Console (BIOS) only
c8b.rng.state
c8b.rng.state()
Current state (for sync checks).
- Returns: integer
- Availability: Console (BIOS) only
c8b.rng.calls
c8b.rng.calls()
Number of values drawn since seeding.
- Returns: integer
- Availability: Console (BIOS) only
Low-level bindings (C8B.*)
C8B.Util_crc32
C8B.Util_crc32(data)
CRC-32 of a string.
- Returns: 1 value(s): integer
- Availability: Console (BIOS) and emulator
C8B.Util_crc32Hex
C8B.Util_crc32Hex(data)
CRC-32 of a string as 8 hex digits.
- Returns: 1 value(s): string
- Availability: Console (BIOS) and emulator
C8B.Util_crc32File
C8B.Util_crc32File(path)
CRC-32 of a file.
- Returns: 1 value(s): integer
- Availability: Console (BIOS) and emulator
C8B.Util_crc32FileHex
C8B.Util_crc32FileHex(path)
CRC-32 of a file as hex.
- Returns: 1 value(s): string
- Availability: Console (BIOS) and emulator