DCPU VM
Multi-platform DCPU-16 Virtual Machine
Note that this VM is aimed to implement and test some of the proposed hardware devices of the Trillek project. In addition, includes some extra tools.
Based on Benedek Vartok VM
COMPILATION
mkdir build
cd build
cmake ..
make
To make a Release build (compiling with optimizations):
cmake -DCMAKE_BUILD_TYPE=Release ..
To make a Debug build:
cmake -DCMAKE_BUILD_TYPE=Debug ..
Run make install to copy the executable to the root of the project This project fork is made to run perfectly on windows without boost
RUNNING
Just type dcpu-vm --help to get these infos.
dcpu-vm 0.1
usage : dcpu-vm [-options] <dcpu16-exe>
--------------------------------------------------------
options:
-assemble (-a) : assemble before load (experimental)
-output <filename> (-o) : output assembled filename
-debug (-d) : start in debug mode
F1 : next step
F2 : print CPU status
System + F12 : switch debug/run
-time (-t) : use timed emulation (else refresh based)
-vsync (-v) : use vertical synchronisation
(more accurate but may bug)
Hardware loadout options:
-loadout (-l) : XML file that describes hardware loadout. If isn't using
a loadout file, then a default loadout will be used. The default
loadout contains a generic clock, a generic keyboard, a monitor,
a floppy drive and a sound speaker.
The next options will be used to change the default loadout of
the virtual machine.
--monitor=<monitor_name> : use the following monitor
1802 -> Lem1802 (default) [c] (-1802)
1803 -> Lem1803 [c] (-1803)
cgm -> Colour Graphics Monitor (-cgm)
[c] : compatible with Lem1802 0x10c programs
--no-sound : disable the sound speaker device
-floppy <filenames...> (-fd) : floppy image files
There is a debug/step mode that can be activated and deactivated with System+F12:
- F1 : Single step (print the current instruction on the console)
- F2 : Print registers states into console
Available shortcuts all-time:
- F3 : Reset the DCPU
- F9 : Ejects/Inserts a floppy (warring! Uses the same disk image for all floppy devices!)
- System+F12 : Activate/Deactivate debug mode. Note that System is Windows/Apple/Super key
LOAD-OUT DESCRIPTION FILES
A custom device load-out can be set using a XML file describing what devices will be used. The XML file follow this structure :
<?xml version="1.0" encoding="utf-8"?>
<loadout>
<hardware>
<device type="GenericClock" />
<device type="GenericKeyboard" />
<device type="M35FD" />
<device type="LEM1803" />
<device type="CGM1084" />
<device type="SimpleSpeaker" />
</hardware>
</loadout>
The devices will be loaded in the same order that is in the XML file. Also can read the load-out from a .10csln solution file from DevKit. Actually admit this device list:
- GenericClock : Generic Clock
- GenericKeyboard : Generic Keyboard
- M35FD : Mackpar 3.5" Floppy drive
- LEM1802 : LEM 1802 monitor
- LEM1803 : LEM 1803 monitor
- CGM1084 : CGM 1084 monitor
- SimpleSpeaker : Basic buzzer / IBM PC like speaker device
TODO
- Manager of floppy disks in use.
- Implemente BadSector bitmap for floppies
- A tool to create floppies and fill/copy data to it.
- GUI of the floppy drive to eject and insert different floppies.
- Several optimizations on rendering monitor loops
- Rename variables/namespaces with a convention -> Apply code convention of Trillek proyect more strictly.
- More options to Debug mode
- DCPU manager and separated graphic rendering threads
- Correct bad English :P
TOOLS
PBM2FONT
PBM2FONT is a small tool to create LEM180x and CGM 1084 fonts. It uses a ASCII PBM image file to create the HEX data values that represents the font.
RUN
Just type pbm2font --help to get these infos.
usage : pbm2font [-options] <input-file>
--------------------------------------------------------
options:
-output <filename> (-o) : output filename
-charset=<charset_type> : use the following charset type
4x8 -> Generates 4x8 font charset
8x8 -> Generates 8x8 font charset
-format=<output_format> : use the following format
dat -> Uses universal .dat output format
hex_dump -> Generates a hexadecimal dump
By default, the ouput format is "dat" and the charset is 4x8
If no output file has been chosen, then it will write to standard out.
HOW IT WORKS
PBM2FONT reads the PBM file, and makes a grid of 4x8, or 8x8 cells. Each cell is converted to the appropriate format for 4x8 or 8x8 fonts. So to generate a font, you only need to use a graphics editor program that outputs ASCII PBM files (for example The Gimp), and set a grid of 4x8 or 8x8. Then you only need to draw each character in black and white and save the file.