Jump to content




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

utility computer

4 replies to this topic

#1 JackMacWindows

  • Members
  • 20 posts

Posted 07 August 2019 - 06:50 AM

DISCLAIMER: CraftOS-PC 2 is being actively developed and is not finished software. Some features may be missing or incomplete. Use this beta software at your own risk until the program is officially released.

<insert cool banner logo here>

Current Version: v2.0b3

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
  • Configuration option to emulate LuaJ bugs for compatibility
(italics indicate unfinished features)

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. The beta releases will only have Windows and Mac builds available for download, but I will be adding CraftOS-PC 2 to my PPA upon the full 2.0 release, as well as providing raw DEB & RPM downloads. Since this is beta software, it's going to have plenty of bugs; if so, please don't hesitate to post an issue on the repository so I can find & fix it.

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.

Edited by JackMacWindows, 20 August 2019 - 07:15 AM.


#2 SquidDev

    Frickin' laser beams

  • Members
  • 1,402 posts
  • LocationDoes anyone put something serious here?

Posted 07 August 2019 - 11:31 AM

Always nice to see another emulator, goodness knows CCEmuX needs the competition. Very happy to see you're looking into adding some of CC:T's features too.

One thing I'd love to see in an emulator (AFAIK, only copy-cat does this, and it's not super usable), is built-in support for taking screenshots and screen recordings. Obviously it's possible to do this already - recgif and your OS's screenshot tools suffice, but building it into the emulator would be very cool.

 JackMacWindows, on 07 August 2019 - 06:50 AM, said:

while eliminating many of the bugs in LuaJ that plagued CraftOS. I've designed CraftOS-PC 2 to emulate ComputerCraft as close as possible.
This is always a bit of a tricky one - some LuaJ bugs (mostly tail-calling "C" functions) are depended on by a fair few CC programs. Would definitely be interesting to see if any programs out-right break using PUC Lua.

 JackMacWindows, on 07 August 2019 - 06:50 AM, said:

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.
One day when Graal is stable, we'll be able to AOT compile CCEmuX, and at least it will start up fast :).

Edited by SquidDev, 07 August 2019 - 11:31 AM.


#3 JackMacWindows

  • Members
  • 20 posts

Posted 13 August 2019 - 05:23 AM

Beta 2 is now released on GitHub. It adds support for the rest of the CraftOS-PC Classic APIs, as well as some new features and bugfixes.

View PostSquidDev, on 07 August 2019 - 11:31 AM, said:

One thing I'd love to see in an emulator (AFAIK, only copy-cat does this, and it's not super usable), is built-in support for taking screenshots and screen recordings. Obviously it's possible to do this already - recgif and your OS's screenshot tools suffice, but building it into the emulator would be very cool.
That is a good idea! I've added screenshot support to the latest beta (press F2), and I plan to add GIF recording support in the future.

View PostSquidDev, on 07 August 2019 - 11:31 AM, said:

View PostJackMacWindows, on 07 August 2019 - 06:50 AM, said:

while eliminating many of the bugs in LuaJ that plagued CraftOS. I've designed CraftOS-PC 2 to emulate ComputerCraft as close as possible.
This is always a bit of a tricky one - some LuaJ bugs (mostly tail-calling "C" functions) are depended on by a fair few CC programs. Would definitely be interesting to see if any programs out-right break using PUC Lua.
I might add a configuration option to emulate the bugs in LuaJ for compatibility with programs that rely on them, though it might not be implemented until after the 2.0 release.

#4 Lignum

  • Members
  • 558 posts

Posted 13 August 2019 - 06:13 AM

The emulator doesn't run on Windows since the installer doesn't seem to include SDL2. I'm guessing the same goes for Lua.

#5 JackMacWindows

  • Members
  • 20 posts

Posted 13 August 2019 - 11:27 PM

View PostLignum, on 13 August 2019 - 06:13 AM, said:

The emulator doesn't run on Windows since the installer doesn't seem to include SDL2. I'm guessing the same goes for Lua.
Forgot the Windows SDL & Lua libraries are dynamically linked. I updated the installer to include the DLLs.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users