(name is subject to change - let me know if you have any suggestions)
I'm working on a patch for the CE Python app that allows you to call LibLoad library functions, among other things.
Currently, it's able to load LibLoad libraries and call functions from them, but I'm still working on creating reasonably Pythonic wrappers for the existing libraries.
Normally I'd share a animated screenshot here, but CEmu doesn't yet emulate the Python hardware well enough to get to the point where it could actually run my code. So instead, just have a code snippet (that works on hardware!) and like imagine what it looks like:
Code:
There's also this potato-quality YouTube video of an older build, I guess:
Those are basically the only functions implemented so far, but it's not particularly hard to add new ones. For functions that only take numeric arguments (no pointers) I just have to specify the argument names and the relative address of the function. I may do something fancier with classes for things like sprites.
Unfortunately performance isn't that great at the moment - the Python-side code takes a few milliseconds per function call, and all functions are blocking. I'll try to rewrite the Python code to minimize the number of memory allocations, since I didn't really care about that in my original implementation. I might also have the command for calling a function tell the ez80 whether and what to return, allowing for a non-blocking function.
Internally, the communication between the coprocessor and the ez80 uses CSI sequences, like the ti_graphics commands do. There are commands for checking the version, loading a LibLoad library, calling a function, reading data, writing data, setting memory to a single byte, allocating memory, freeing memory, and freeing all memory.
Variable-length data is transmitted with a 6-bit encoding, as values greater than 127 bork the coprocessor, and newlines get automatically converted to CRLF. It transmits data in 24-bit blocks, even if the data is not a multiple of 3, sinceI'm somewhat lazy it reduces code size.
I have a few other features I may add in the future, since I can change whatever I want in the app:
In order to distribute this without violating TI's EULA, I wrote a Javascript-based app patcher that uses the relocation table to patch an app locally without having to disassemble the entire thing or to distribute slightly-modified portions of TI code. Since apps need to be signed by TI, it instead creates a program that installs an app similarly to Cesium. You'll obviously need an exploit like arTIfiCE to use this.
Unfortunately it's still not ready for even a beta release at this point, as the installer tends to overwrite the OS if you haven't garbage collected recently or have too much data in archive. If you're interested in contributing or giving feedback, shoot me a DM and I can get you access to the repository.
I'm working on a patch for the CE Python app that allows you to call LibLoad library functions, among other things.
Currently, it's able to load LibLoad libraries and call functions from them, but I'm still working on creating reasonably Pythonic wrappers for the existing libraries.
Normally I'd share a animated screenshot here, but CEmu doesn't yet emulate the Python hardware well enough to get to the point where it could actually run my code. So instead, just have a code snippet (that works on hardware!) and like imagine what it looks like:
Code:
import graphxpy
with graphxpy.GfxContext() as gfx:
gfx.set_draw(1)
for i in range(128):
gfx.fill_screen(i)
gfx.set_color(255 - i)
gfx.fill_rectangle(25,i,50,12)
gfx.set_text_xy(26,i+1)
gfx.print_string("hello python")
gfx.blit(1)
There's also this potato-quality YouTube video of an older build, I guess:
Those are basically the only functions implemented so far, but it's not particularly hard to add new ones. For functions that only take numeric arguments (no pointers) I just have to specify the argument names and the relative address of the function. I may do something fancier with classes for things like sprites.
Unfortunately performance isn't that great at the moment - the Python-side code takes a few milliseconds per function call, and all functions are blocking. I'll try to rewrite the Python code to minimize the number of memory allocations, since I didn't really care about that in my original implementation. I might also have the command for calling a function tell the ez80 whether and what to return, allowing for a non-blocking function.
Internally, the communication between the coprocessor and the ez80 uses CSI sequences, like the ti_graphics commands do. There are commands for checking the version, loading a LibLoad library, calling a function, reading data, writing data, setting memory to a single byte, allocating memory, freeing memory, and freeing all memory.
Variable-length data is transmitted with a 6-bit encoding, as values greater than 127 bork the coprocessor, and newlines get automatically converted to CRLF. It transmits data in 24-bit blocks, even if the data is not a multiple of 3, since
I have a few other features I may add in the future, since I can change whatever I want in the app:
- Function for disabling keypad input to the terminal emulator - would be helpful when using libraries that access the keypad
Update to the latest circuitpython version - the main issue here is that TI distributed some modules in bytecode form which are incompatible with newer micropython versions, so I would have to either decompile or recreate these modules if I wanted this program to be backward-compatible
Add an ExecLib thing for running or editing a program from TI-BASIC or a compatible program (e.g. Cesium)
In order to distribute this without violating TI's EULA, I wrote a Javascript-based app patcher that uses the relocation table to patch an app locally without having to disassemble the entire thing or to distribute slightly-modified portions of TI code. Since apps need to be signed by TI, it instead creates a program that installs an app similarly to Cesium. You'll obviously need an exploit like arTIfiCE to use this.
Unfortunately it's still not ready for even a beta release at this point, as the installer tends to overwrite the OS if you haven't garbage collected recently or have too much data in archive. If you're interested in contributing or giving feedback, shoot me a DM and I can get you access to the repository.