-
Notifications
You must be signed in to change notification settings - Fork 8
Description
I propose a new, hidden system function _bytecode.load(number) that resets the VM an loads a new bytecode into memory. It would work analogously to the sound.{system,record,replay,play} functions:
- if a file named
Ax.aboexists on the SD, load it - if
x= 0 andvmcode.aboexists on the SD, load it - otherwise, if
xis in 0–6, load the corresponding system bytecode- 0: initial menu, 1: friendly, 2: explorer, 3:fearful, 4: attentive, 5: investigator, 6: obedient
- otherwise, beep (play note A4 for 10)
There is no _bytecode.save! Bytecodes cannot be written by programs, they must be saved on SD cards.
Pre-compiled byte codes can be added to the firmware with a new static const struct bytecode, analogous to static const struct music in playback.c.
Firmware 10 has the initial menu interface and default LED behavior hard-coded in behavior.c, and the six basic behaviors are hard-coded in C in mode.c. This is hard to maintain. There is no guarantee that the hard-coded behaviors can be imitated by student programmers in Aesl. With this function and steps 3–4, above, one could replace the behaviors written in C with stored bytecodes that were generated from Aesl programs.
With this function and steps 1–2, above, one could update the standard behaviors by placing the improved bytecode files on the SD.
This function could furthermore be used to define a new second-stage boot loader, replacing the initial menu system. Bytecode vmcode.abo on the SD card is run automatically and could present a different menu system, with a different choice of pre-programmed behaviors.
The other standard behaviors, such as updating the charging LEDs and changing the circle LEDs according to the accelerometer, should still be implemented in behavior.c.