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
  • 24 posts

Posted 07 August 2019 - 06:50 AM

Posted Image
Current Version: v2.4.3
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
  • Full support of ComputerCraft's API
  • Full support of all CC: Tweaked functionality
  • Full support of CraftOS-PC Classic's API, including:
  • periphemu API for attaching peripherals (monitor, printer, drive, modem, debugger)
  • 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)
  • 256-color graphics mode support
  • Debugger featuring GDB-style commands and profiler
  • Raw & CLI terminal I/O
  • 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
  • CCEmuX: TRoR terminal I/O through the console
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 the official website or 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.

Edited by JackMacWindows, 15 September 2020 - 04:07 AM.


#2 SquidDev

    Frickin' laser beams | Resident Necromancer

  • Members
  • 1,427 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.

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.

View PostJackMacWindows, 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
  • 24 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
  • 24 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