Today I began work on implementing access to both cc65 and ca65 from within the game engine. Once this is ready and available in-game, it will allow anyone to easily assemble or compile their own programs in Hacker's Edge. The player can either upload their assembly or C source code using FTP, or by merely pasting in their code directly from an editor on their PC.
The cc65 toolchain will be running in a protected environment to prevent players from reading important system files on the real world game server. The daemon I wrote today places itself into a chroot directory along with a statically compiled binary of the cc65 tools. From there, I copy in the standard C library include files, the assembler include and macro files. The chroot also contains the standard Hacker's Edge development kits files such as ioapi.inc, heos.h, he-bin.o, and most importantly the HackerOS C library he.lib. The daemon listens on a Redis queue, and sits idol otherwise.
The 65c02 Virtual Machine device for the HEAPI is updated with two new API calls which can be set into $fff2, $20, and $21, which provide access to either ca65 or cc65 respectively. To assemble or compile a program, place a pointer to the program buffer in $fff0, and then in $fff3 vector, place the size in bytes of the program buffer. The return code of $fff2 will either be 0 or 1, and in rare cases $ff. In the rare case mentioned, it means that the backend daemon which is used to assemble and compile programs is not running. A return code of 0 means success as in most C programming APIs.
Speaking of C, a few new functions will be added for your convenience. The first being useful across the board, but still non-standard C. save_file will allow you to save a specific buffer to disk. The first parameter is the filename, the second is a pointer to a buffer, and the third is the size of the this buffer to save. You should be-able to use sizeof in your C program to get the size of a buffer, or use your own variable which you were otherwise using to keep track of a buffer size.
The next two C functions are related to cc65 and ca65. The first is ca65, and the second is of course cc65. The parameters for both are the same, the first parameter is a pointer to a buffer which contains the code to be compiled or assembled. The second parameter is the size of this buffer. It will send the return code from the HE API directly back to the C program. The compiled or assembled code is currently placed back into the buffer provided. However, this is going to change before any ca65/cc65 code is released for public consumption. The main concern here is of course the buffer size, usually the compiled code is much smaller than the source code... However, this may not always be the case depending on which functions are called from C. The second concern here is if someone wants to create an interactive IDE of sorts in Hacker's Edge. You wouldn't just want your text editor buffer to be replaced by the compiled form of your code. Of course the editor can just save the source before compiling. All and all, this is just bad. I am thinking that the ca65 and cc65 C functions will have a source and destination buffers, along with a source size and destination return size.
Anyways, I do not see it taking much more time to complete this update and get it all deployed up so that new players can take advantage of being able to assemble and compile their code from within the game itself.