Jump to content


JackMacWindows

Member Since 24 Jul 2016
Offline Last Active Sep 14 2019 10:24 PM
-----

Topics I've Started

CraftOS-PC 2: A small & speedy ComputerCraft emulator written in native code

07 August 2019 - 06:50 AM

Posted Image

Current Version: v2.0

After completing CraftOS-PC and using it for a while, I noticed that it runs relatively slowly compared to other real terminals. I also didn't like that it was tied to the JVM, which can use up quite a bit of my system's resources. (I'm also more on the new side when it comes to Java programming.) I started to ponder the idea of writing a ComputerCraft interpreter entirely in C. I first wrote a proof-of-concept called LinuxCC that used an ncurses terminal and ran in the root of the hard drive. After discovering how easy it was to write (not without ending up adding some C++ into the mix), I decided to bring it to a full product as a successor to the original CraftOS-PC. CraftOS-PC 2 uses the original Lua 5.1 API and SDL to create a terminal that runs CraftOS quickly while eliminating many of the bugs in LuaJ that plagued CraftOS. I've designed CraftOS-PC 2 to emulate ComputerCraft as close as possible.

Posted Image

CraftOS-PC 2's features:
  • Emulates an advanced computer with touch support, or a standard computer (only changes term.isColor() at the moment)
  • Full support of ComputerCraft's API
  • Full support of CraftOS-PC Classic's API, including:
  • periphemu API for attaching peripherals (monitor, printer, speaker)
  • mounter API for mounting local drives inside ComputerCraft
  • Terminal graphics mode for direct pixel writing
  • config API for adjusting the internal ComputerCraft configuration
  • Resizable terminals
  • HTTP server support
In addition, I've added some new features exclusive to CraftOS-PC 2:
  • Screenshot & GIF recording support (thanks for the idea, SquidDev)
  • More features soon?
I have also ported features from other ComputerCraft extensions:
  • CC: Tweaked: WebSocket support
  • CC: Tweaked: Native IO API
  • CCEmuX: Multiple computer support
  • CCEmuX: modem peripheral
The main selling point of CraftOS-PC 2 is its speed. CraftOS-PC 2 is up to 2x faster than CraftOS-PC Classic and 90% faster than CCEmuX[1]. It boots to the CraftOS shell immediately. And it's light on system resources: it only uses between 10~30 MB of memory while running, while CraftOS-PC Classic and CCEmuX both use over 100 MB of memory at startup. Since CraftOS-PC 2 doesn't have to rely on a JVM or intermediate bytecode, it can run much faster than its Java-based competitors. Lastly, CraftOS-PC 2 only takes up about 7 MB of space on disk, which is very lightweight compared to CraftOS-PC Classic's JAR size of 20 MB.

You can download the latest version of CraftOS-PC 2 on GitHub. I have included both Windows and Mac builds in the release; Ubuntu users can install craftos-pc from the official PPA (ppa:jackmacwindows/ppa).

CraftOS-PC 2 is licensed under the MIT license: see LICENSE in the repository for more information.

[1]Based on SciMark test results on CraftOS-PC Classic, CCEmuX, and CraftOS-PC 2 (results here). Benchmarks performed on an Intel Core i5 system clocked at 3.7 GHz with 16 GB RAM installed; running on Windows 10 1903 with no apps running. Synthetic benchmarks may not accurately represent actual performance gain.

TAR archive/unarchive library/program for CraftOS

02 August 2019 - 05:52 AM

I'm working on a project involving the use of TAR files (hint: it's a port of a popular Linux utility) and I figured I'd share the library I wrote to interact with TAR archives. It can read & write Unix Standard TAR (UStar) and read original TAR. I've also added permission modification if running under CCKernel2. You can either load the file as an API, or you can run the file directly, in which case it will work similarly to the GNU tar command. Running it under the shell will also provide the ability to use gzipped archives with the -z flag; this is provided by a ComputerCraft fork of the LibDeflate library by SafeteeWow. Here's the API reference:
API reference
You can use many of the switches from *nix tar on the command line, including `tar -xzf file.tar.gz` and `tar -cvf file.tar file1 file2 file3` just like on real machines. I've gotten rid of the switches that either a ) don't make sense on ComputerCraft, or b ) don't work at all on CraftOS, but much of the core functionality still works.

You can download it from the GitHub gist, which includes tar.lua + LibDeflate.lua. Note that this is BETA SOFTWARE and some functionality may be missing or buggy. I did not put it on pastebin yet since it doesn't support multiple files or keep revision history, though I might later without LibDeflate if I ever complete the CLI interface and add error checking.

CCKernel2: An Advanced Kernel for ComputerCraft

31 May 2019 - 03:43 AM

After many months of work, my custom CraftOS kernel, CCKernel2, is ready for a beta release. CCKernel2 adds to and extends standard CraftOS 1.8 to provide more control over the operating system, including:
  • Cooperative multitasking through coroutines
  • Native IPC calls
  • Process signaling
  • Built-in debugger
  • Multi-user system
  • File permissions
  • Device files (/dev)
  • Eight virtual terminals
  • Built-in logger
  • Unix-style file hierarchy
  • `os.loadAPI` resolution paths
  • Process I/O pipes
  • systemd-based init program
  • GUI setup program
  • Plenty of new commands relating to CCKernel2
  • Extensive kernel API
Here's a quick demo of some of the features: https://youtu.be/Z4Kfyn7Z-KI.

Screenshots

The source code can be found on GitHub, and the API reference for all added and changed functions can be found in the documentation. You can install CCKernel2 with this command:
pastebin run yY9StxvU
CCKernel2 requires CraftOS 1.8 or later, and is optimized for CraftOS-PC (but is not required).

Some applications of CCKernel2 (included at demos/ in the repository):
  • HTTP server running in the background (requires CraftOS-PC)
  • Remote shell server (server requires CraftOS-PC, client can run on any recent CraftOS but requires http_whitelist=*): Demo
I'm planning on building a full GUI OS based off of CCKernel2 in the future, using the multitasking to run multiple apps at once. I also want to write an extended shell that functions more like bash, but I ran into some roadblocks and decided to focus on polishing CCKernel2 before writing the new shell.
If you find any bugs, please submit a new issue on GitHub.

ComputerCraft text completion for Visual Studio Code

07 December 2018 - 03:45 AM

Just wanted to put this out there for anyone who uses Visual Studio Code to write ComputerCraft programs: I've released an extension that provides code completion for the CC APIs. You can get it here. It has support for every function and property available to ComputerCraft 1.74+, except for the turtle API and the global functions (forgot to add them in, will be there soon). If you would like to help with the documentation, you can find the source code here.

CCKit: UIKit for ComputerCraft

11 November 2018 - 07:25 AM

I created this project a few months ago when I realized how easy UI development is for ComputerCraft for a seasoned programmer, and how Apple's UIKit is easy to develop with on real devices. But I just realized I never really released this to the public, so I'm putting this up here real quick. CCKit allows you to use your knowledge on programming iOS with ComputerCraft. It features many similar classes to the real UIKit, such as CCViewController and CCView. As with iOS, every user interface element is a subclass of CCView, and they can be nested inside each other. Here is a demo application, showing a window, button, image, and text:

Posted Image

This is in really early stages of development and is buggy and missing many features. You can find the source code and info on how to use it here: https://github.com/MCJack123/CCKit