refactor(runtime,packages,examples): named constants, package enums, idiom sweep
- runtime: HEADLESS_FRAME_PATH, STICK_DEADZONE / STICK_LEFT_X/Y, key and byte codes as char literals throughout (`k == 'w'`, `fill(rt_map, ' ', …)`) - ludic.gameplay/stats: drop the duplicate `stat_field` (it answered "atk" for every build stat); Stats.base uses stats_field_name - ludic.shooter: compare aim modes and fire patterns with AimMode.* and WeaponPattern.* instead of raw ints; STICK_RIGHT_X/Y - ludic.npcai: DecisionMade / brain_set_state use AiState.* - examples/games/menu.ludic uses Font.load / Ui.* with FONT_PATH and BACKDROP named; strings.ludic header says what it prints - whole tree: `x = x + 1` → `x += 1` (single-term right-hand sides only), `0 - x` → `-x`, ASCII codes → char literals; every .ludic and every ```ludic fence reformatted with the fixed formatter (whitespace only) Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
parent
e3e1bc7784
commit
bf36bc8a8f
103 changed files with 1256 additions and 1252 deletions
|
|
@ -15,12 +15,12 @@
|
|||
# the standard alphabet value of a base64 character, or -1 for anything else
|
||||
# (whitespace, '=', stray bytes — the decoder skips them / stops on '=').
|
||||
function b64_val(c: int) -> int {
|
||||
if c >= 65 and c <= 90 { return c - 65 } # 'A'..'Z' -> 0..25
|
||||
if c >= 97 and c <= 122 { return c - 71 } # 'a'..'z' -> 26..51
|
||||
if c >= 48 and c <= 57 { return c + 4 } # '0'..'9' -> 52..61
|
||||
if c == 43 { return 62 } # '+'
|
||||
if c == 47 { return 63 } # '/'
|
||||
return 0 - 1
|
||||
if c >= 'A' and c <= 'Z' { return c - 65 } # 'A'..'Z' -> 0..25
|
||||
if c >= 'a' and c <= 'z' { return c - 71 } # 'a'..'z' -> 26..51
|
||||
if c >= '0' and c <= '9' { return c + 4 } # '0'..'9' -> 52..61
|
||||
if c == '+' { return 62 } # '+'
|
||||
if c == '/' { return 63 } # '/'
|
||||
return -1
|
||||
}
|
||||
|
||||
# decode NUL-terminated base64 `src` into the caller's `out` buffer; returns the
|
||||
|
|
@ -33,18 +33,18 @@ function b64_decode(src: pointer, out: pointer) -> int {
|
|||
var i = 0
|
||||
var c = src[i]
|
||||
while c != 0 {
|
||||
if c == 61 { return w } # '=' -> done
|
||||
if c == '=' { return w } # '=' -> done
|
||||
let v = b64_val(c)
|
||||
if v >= 0 {
|
||||
acc = (acc << 6) | v
|
||||
nbits = nbits + 6
|
||||
nbits += 6
|
||||
if nbits >= 8 {
|
||||
nbits = nbits - 8
|
||||
nbits -= 8
|
||||
out[w] = (acc >> nbits) & 255
|
||||
w = w + 1
|
||||
w += 1
|
||||
}
|
||||
}
|
||||
i = i + 1
|
||||
i += 1
|
||||
c = src[i]
|
||||
}
|
||||
return w
|
||||
|
|
@ -79,9 +79,9 @@ function base64_encode(src: pointer) -> pointer {
|
|||
let e2 = ((b1 & 15) << 2) | (b2 >> 6)
|
||||
let e3 = b2 & 63
|
||||
out = out + tab[e0..e0 + 1] + tab[e1..e1 + 1]
|
||||
if have >= 2 { out = out + tab[e2..e2 + 1] } else { out = out + "=" }
|
||||
if have >= 3 { out = out + tab[e3..e3 + 1] } else { out = out + "=" }
|
||||
i = i + 3
|
||||
if have >= 2 { out += tab[e2..e2 + 1] } else { out += "=" }
|
||||
if have >= 3 { out += tab[e3..e3 + 1] } else { out += "=" }
|
||||
i += 3
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue