Comparing to pico-8 builtins
This commit is contained in:
parent
26c0ff590c
commit
d68a207df6
45
builtins.ts
45
builtins.ts
@ -70,6 +70,7 @@ export const measureText = (text: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const faux = {
|
const faux = {
|
||||||
|
// Graphics
|
||||||
cls: () => {
|
cls: () => {
|
||||||
resetRepl();
|
resetRepl();
|
||||||
clearScreen();
|
clearScreen();
|
||||||
@ -78,16 +79,54 @@ const faux = {
|
|||||||
spr: drawSprite,
|
spr: drawSprite,
|
||||||
txt: drawText,
|
txt: drawText,
|
||||||
rect: fillRect,
|
rect: fillRect,
|
||||||
|
// Input
|
||||||
btn: keyDown,
|
btn: keyDown,
|
||||||
btnp: keyPressed,
|
btnp: keyPressed,
|
||||||
btnr: keyReleased,
|
btnr: keyReleased,
|
||||||
|
// Cart
|
||||||
|
save: saveCart,
|
||||||
|
load: loadCart,
|
||||||
|
// JS
|
||||||
|
Array,
|
||||||
|
BigInt: BigInt,
|
||||||
|
Boolean,
|
||||||
|
Date,
|
||||||
|
Error,
|
||||||
|
Function,
|
||||||
|
Infinity: Infinity,
|
||||||
|
JSON: JSON,
|
||||||
|
Map,
|
||||||
|
NaN: NaN,
|
||||||
|
Number,
|
||||||
|
Object,
|
||||||
|
Promise,
|
||||||
|
Proxy,
|
||||||
|
Reflect: Reflect,
|
||||||
|
RegExp,
|
||||||
|
Set,
|
||||||
|
String,
|
||||||
|
Symbol: Symbol,
|
||||||
|
WeakMap,
|
||||||
|
WeakRef,
|
||||||
|
WeakSet,
|
||||||
|
isFinite,
|
||||||
|
isNaN,
|
||||||
|
// Math
|
||||||
|
max: Math.max,
|
||||||
|
min: Math.min,
|
||||||
|
floor: Math.floor,
|
||||||
|
ceil: Math.ceil,
|
||||||
|
sin: Math.sin,
|
||||||
|
cos: Math.cos,
|
||||||
|
atan2: Math.atan2,
|
||||||
|
sqrt: Math.sqrt,
|
||||||
|
abs: Math.abs,
|
||||||
|
rand: Math.random,
|
||||||
|
// Other
|
||||||
code: (n: number) => {
|
code: (n: number) => {
|
||||||
return runCode(getCodeSheet(n));
|
return runCode(getCodeSheet(n));
|
||||||
},
|
},
|
||||||
log: console.log,
|
log: console.log,
|
||||||
JSON: JSON,
|
|
||||||
save: saveCart,
|
|
||||||
load: loadCart,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
for (const key in faux) {
|
for (const key in faux) {
|
||||||
|
@ -64,6 +64,8 @@ const values = [
|
|||||||
"null",
|
"null",
|
||||||
"true",
|
"true",
|
||||||
"undefined",
|
"undefined",
|
||||||
|
"NaN",
|
||||||
|
"Infinity",
|
||||||
];
|
];
|
||||||
const operator = [
|
const operator = [
|
||||||
"&&",
|
"&&",
|
||||||
@ -659,6 +661,9 @@ const draw = () => {
|
|||||||
const lines = token.value.split("\n");
|
const lines = token.value.split("\n");
|
||||||
lines.forEach((line, i) => {
|
lines.forEach((line, i) => {
|
||||||
let color = tokenColors[token.type];
|
let color = tokenColors[token.type];
|
||||||
|
if (builtins.includes(token.value)) {
|
||||||
|
color = builtinColor;
|
||||||
|
}
|
||||||
if (keywords.includes(token.value)) {
|
if (keywords.includes(token.value)) {
|
||||||
color = keywordColor;
|
color = keywordColor;
|
||||||
}
|
}
|
||||||
@ -671,9 +676,6 @@ const draw = () => {
|
|||||||
if (punctuation.includes(token.value)) {
|
if (punctuation.includes(token.value)) {
|
||||||
color = punctuationColor;
|
color = punctuationColor;
|
||||||
}
|
}
|
||||||
if (builtins.includes(token.value)) {
|
|
||||||
color = builtinColor;
|
|
||||||
}
|
|
||||||
drawText(1+x+cx-scrollX, 1+y+cy-scrollY, line, color);
|
drawText(1+x+cx-scrollX, 1+y+cy-scrollY, line, color);
|
||||||
if (i === lines.length-1) {
|
if (i === lines.length-1) {
|
||||||
cx += measureText(line)+1;
|
cx += measureText(line)+1;
|
||||||
|
126
pico8_builtins.txt
Normal file
126
pico8_builtins.txt
Normal file
@ -0,0 +1,126 @@
|
|||||||
|
- [x] load
|
||||||
|
- [x] save
|
||||||
|
- [ ] folder
|
||||||
|
- [ ] ls
|
||||||
|
- [x] run
|
||||||
|
- [ ] stop
|
||||||
|
- [ ] resume
|
||||||
|
- [ ] assert
|
||||||
|
- [ ] reboot
|
||||||
|
- [ ] reset
|
||||||
|
- [ ] info
|
||||||
|
- [ ] flip
|
||||||
|
- [ ] printh
|
||||||
|
- [ ] time/t
|
||||||
|
- [ ] stat
|
||||||
|
- [ ] extcmd
|
||||||
|
|
||||||
|
- [ ] clip
|
||||||
|
- [ ] pset
|
||||||
|
- [ ] pget
|
||||||
|
- [ ] sget
|
||||||
|
- [ ] sset
|
||||||
|
- [ ] fget
|
||||||
|
- [ ] fset
|
||||||
|
- [?] print
|
||||||
|
- [ ] cursor
|
||||||
|
- [ ] color
|
||||||
|
- [x] cls
|
||||||
|
- [ ] camera
|
||||||
|
- [ ] circ
|
||||||
|
- [ ] circfill
|
||||||
|
- [ ] oval
|
||||||
|
- [ ] ovalfill
|
||||||
|
- [ ] line
|
||||||
|
- [ ] rect
|
||||||
|
- [x] rectfill
|
||||||
|
- [ ] pal
|
||||||
|
- [ ] palt
|
||||||
|
- [x] spr
|
||||||
|
- [ ] sspr
|
||||||
|
- [ ] fillp
|
||||||
|
|
||||||
|
- [ ] add
|
||||||
|
- [ ] del
|
||||||
|
- [ ] deli
|
||||||
|
- [ ] count
|
||||||
|
- [ ] all
|
||||||
|
- [ ] foreach
|
||||||
|
- [ ] pairs
|
||||||
|
|
||||||
|
- [x] btn
|
||||||
|
- [x] btnp
|
||||||
|
|
||||||
|
- [ ] sfx
|
||||||
|
- [ ] music
|
||||||
|
|
||||||
|
- [ ] mget
|
||||||
|
- [ ] mset
|
||||||
|
- [ ] map
|
||||||
|
- [ ] tline
|
||||||
|
|
||||||
|
- [ ] peek
|
||||||
|
- [ ] poke
|
||||||
|
- [ ] peek2
|
||||||
|
- [ ] poke2
|
||||||
|
- [ ] peek4
|
||||||
|
- [ ] poke4
|
||||||
|
- [ ] memcpy
|
||||||
|
- [ ] reload
|
||||||
|
- [ ] cstore
|
||||||
|
- [ ] memset
|
||||||
|
|
||||||
|
- [x] max
|
||||||
|
- [x] min
|
||||||
|
- [ ] mid
|
||||||
|
- [x] flr
|
||||||
|
- [x] ceil
|
||||||
|
- [x] cos
|
||||||
|
- [x] sin
|
||||||
|
- [x] atan2
|
||||||
|
- [x] sqrt
|
||||||
|
- [x] abs
|
||||||
|
- [x] rnd
|
||||||
|
- [ ] srand
|
||||||
|
|
||||||
|
-- skipping these in favor of bitwise operations if needed
|
||||||
|
- [ ] band
|
||||||
|
- [ ] bor
|
||||||
|
- [ ] bxor
|
||||||
|
- [ ] bnot
|
||||||
|
- [ ] shl
|
||||||
|
- [ ] shr
|
||||||
|
- [ ] lshr
|
||||||
|
- [ ] rotl
|
||||||
|
- [ ] rotr
|
||||||
|
|
||||||
|
- [ ] menuitem
|
||||||
|
|
||||||
|
-- js comes with stuff here (String, Number, typeof, etc.)
|
||||||
|
- [ ] tostr
|
||||||
|
- [ ] tonum
|
||||||
|
- [ ] chr
|
||||||
|
- [ ] ord
|
||||||
|
- [ ] sub
|
||||||
|
- [ ] split
|
||||||
|
- [ ] type
|
||||||
|
|
||||||
|
- [ ] cartdata
|
||||||
|
- [ ] dget
|
||||||
|
- [ ] dset
|
||||||
|
|
||||||
|
- [ ] serial
|
||||||
|
|
||||||
|
- [ ] setmetatable
|
||||||
|
- [ ] getmetatable
|
||||||
|
- [ ] rawset
|
||||||
|
- [ ] rawget
|
||||||
|
- [ ] rawequal
|
||||||
|
- [ ] rawlen
|
||||||
|
|
||||||
|
-- js comes with stuff here
|
||||||
|
- [ ] cocreate
|
||||||
|
- [ ] coresume
|
||||||
|
- [ ] assert
|
||||||
|
- [ ] costatus
|
||||||
|
- [ ] yield
|
Loading…
x
Reference in New Issue
Block a user