Note: This is work in progress and should not be considered useful yet.
This is an experimental, standalone, graphical emulator for the DCPU. It includes fully implemented DCPU hardware and doubles as a code profiler and debugger.
Controlling the emulator happens through a command line UI. The LEM1802 or SPED3 displays are running separately in an OpenGL context.
Keyboard input for the CLI happens in the console window. The openGL window accepts keyboard input only through the DCPU keyboard hardware and is meant strictly to control the DCPU program, not the emulator.
These are all invoked from within the command line interface.
q: Start the CPU.
w: Stop the CPU.
e: Perform a single CPU step.
r: Reset the CPU to its initial state. This implicitly recompiles the program and loads it from disk and allows us to reload any changes to the source without restarting the emulator. Additionally it resets memory and registers to their beginning state. This will not reset breakpoints and memory watchers.
-: Decrease the CPU clock speed by 10x.
+: Increase the CPU clock speed by 10x.
/: This enters the commandline mode. We can enter commands manually this way.
esc: Hitting escape while in command line mode, will exit it.
Supported commands in command line mode are as follows:
exit: This cleanly exits the emulator.
b <address|sourcecontext>: This toggles a breakpoint. Either at the given memory address, or at the given source context. The source context looks as follows:
"test/hw/main.dasm" 13. This is the relative file path, along with the line number. If the breakpoint does not exist yet, it is created. Otherwise it is enabled/disabled.
be: Enable all breakpoints.
bd: Disable all breakpoints but do not remove them.
bc: Clears all breakpoints.
m <address>: Defines a memory watcher for the given address.
mc: Clears all memory watchers.
The command line interface has 4 output windows.
- Trace log: This log shows the current instruction as it is executed. It includes the PC, opcode, operands and all register states.
- Source log: This shows the cycle cost for the current instruction, along with the cimulative cycle cost for all invocations of this specific instruction. Next to that, the file/line in which the instruction was defined, followed by the actual source line.
- Watchers: This list shows the currently defined memory watchers.
- Breakpoints: This list shows the currently defined memory breakpoints.
At the bottom of the window is a single line input textbox. It can be activated
/ key and used to type in commands defined in the previous paragraph.
go get github.com/go-gl/gl go get github.com/go-gl/glfw go get github.com/go-gl/glh go get github.com/jteeuwen/keyboard/glfw
dcpu-emu -h for a listing of options.
DCPU, 0x10c and related materials are Copyright 2012 Mojang.
Unless otherwise stated, all of the work in this project is subject to a 1-clause BSD license. Its contents can be found in the enclosed LICENSE file.