rename aux to scripts
This commit is contained in:
17
scripts/build.sh
Executable file
17
scripts/build.sh
Executable file
@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
|
||||
LEGO=$HOME/src/lego/lms2012
|
||||
P="`pwd`"
|
||||
F="$P"/pxt
|
||||
set -e
|
||||
cd $LEGO/lmssrc/adk/lmsasm
|
||||
echo "Compiling..."
|
||||
java -jar assembler.jar $F
|
||||
cd "$P"
|
||||
echo "Hex to paste:"
|
||||
echo
|
||||
echo "const rbfTemplate = \`"
|
||||
node -p 'require("fs").readFileSync("pxt.rbf").toString("hex").replace(/5858585858(58)+/, "XX").replace(/.{1,80}/g, f => f + "\n").trim()'
|
||||
echo "\`"
|
||||
echo
|
||||
rm -f pxt.rbf
|
62
scripts/mkenum.js
Normal file
62
scripts/mkenum.js
Normal file
@ -0,0 +1,62 @@
|
||||
let lines = require("fs").readFileSync(process.argv[2], "utf8").split(/\n/)
|
||||
|
||||
let off = 0
|
||||
|
||||
let typemap = {
|
||||
DATA8: "int8",
|
||||
DATA16: "int16",
|
||||
DATA32: "int32",
|
||||
UBYTE: "uint8",
|
||||
UWORD: "uint16",
|
||||
ULONG: "uint32",
|
||||
SBYTE: "int8",
|
||||
SWORD: "int16",
|
||||
SLONG: "int32",
|
||||
DATAF: "float32",
|
||||
}
|
||||
|
||||
for (let l of lines) {
|
||||
l = l.trim()
|
||||
if (/= \[/.test(l)) {
|
||||
console.log("\n\nconst enum X {")
|
||||
off = 0
|
||||
continue
|
||||
}
|
||||
if (l == "]") {
|
||||
console.log(` Size = ${off}`)
|
||||
console.log("}")
|
||||
continue
|
||||
}
|
||||
if (!l) continue
|
||||
let m = /\('(\w+)', (\w+)( \* (\d+))?\)/.exec(l)
|
||||
if (!m)
|
||||
m = /\('(\w+)', \((\w+)( \* (\d+))\) \* (\d+)/.exec(l)
|
||||
if (!m)
|
||||
m = /\('(\w+)', \(\((\w+)( \* (\d+))\) \* (\d+)\) \* (\d+)/.exec(l)
|
||||
if (m) {
|
||||
let tp = typemap[m[2]]
|
||||
if (!tp) {
|
||||
console.log("unknown type: " + m[2])
|
||||
break
|
||||
}
|
||||
let sz = parseInt(tp.replace(/[^\d]/g, "")) / 8
|
||||
let suff = ""
|
||||
if (m[4]) {
|
||||
sz *= parseInt(m[4])
|
||||
suff = "[" + m[4] + "]"
|
||||
}
|
||||
if (m[5]) {
|
||||
sz *= parseInt(m[5])
|
||||
suff += "[" + m[5] + "]"
|
||||
}
|
||||
if (m[6]) {
|
||||
sz *= parseInt(m[6])
|
||||
suff += "[" + m[6] + "]"
|
||||
}
|
||||
console.log(` ${m[1]} = ${off}, // ${tp}${suff}`)
|
||||
off += sz
|
||||
} else {
|
||||
console.log("bad line: " + l)
|
||||
break
|
||||
}
|
||||
}
|
26
scripts/pxt.lms
Normal file
26
scripts/pxt.lms
Normal file
@ -0,0 +1,26 @@
|
||||
define appv 'RunAndWaitForEsc V0.00'
|
||||
vmthread MAIN
|
||||
{
|
||||
DATA8 State
|
||||
DATA32 Status
|
||||
DATA32 Timer
|
||||
DATA16 Serial
|
||||
|
||||
UI_WRITE(LED,LED_ORANGE)
|
||||
UI_DRAW(TEXT,FG_COLOR,48,62,'Starting...')
|
||||
UI_DRAW(UPDATE)
|
||||
// Make sure VM knows that /tmp/serial.txt is open for writing and can stream the content
|
||||
//FILE(OPEN_WRITE, '/tmp/serial.txt', Serial)
|
||||
// Actual filename is patched-in here
|
||||
SYSTEM('XXXXXXXXX', Status)
|
||||
Loop:
|
||||
//UI_BUTTON(WAIT_FOR_PRESS)
|
||||
//UI_BUTTON(SHORTPRESS,BACK_BUTTON,State)
|
||||
//JR_FALSE(State,Loop)
|
||||
//UI_WRITE(LED,LED_RED)
|
||||
TIMER_WAIT(100, Timer)
|
||||
TIMER_READY(Timer)
|
||||
UI_DRAW(TEXT,FG_COLOR,48,62,'Bye!')
|
||||
UI_DRAW(UPDATE)
|
||||
}
|
||||
|
Reference in New Issue
Block a user