Skip to content
A DOS JavaScript Canvas with sound
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode the changed creation May 2, 2019
allegro-4.2.2-xc-master Version 0.9.6 (the crashing creation) May 26, 2019
doc Version 0.9.6 (the crashing creation) May 26, 2019
examples Version 0.9.6 (the crashing creation) May 26, 2019
jsboot Version 0.9.6 (the crashing creation) May 26, 2019
mujs-1.0.5 Version 0.9.6 (the crashing creation) May 26, 2019
tests Version 0.9.6 (the crashing creation) May 26, 2019
.gitignore the changed creation May 2, 2019
CHANGELOG.md
DOjS.c Version 0.9.6 (the crashing creation) May 26, 2019
DOjS.h Version 0.9.6 (the crashing creation) May 26, 2019
LICENSE the changed creation May 2, 2019
Makefile the changed creation May 2, 2019
Makefile.unix The second coming Feb 17, 2019
README.md the changed creation May 2, 2019
bitmap.c the changed creation May 2, 2019
bitmap.h Version 0.7 (the third installment) Mar 3, 2019
color.c Version 0.9.6 (the crashing creation) May 26, 2019
color.h Version 0.9.1 (the fixed foreboding) Apr 14, 2019
dialog.c The fifth foreboding Apr 7, 2019
dialog.h Version 0.7 (the third installment) Mar 3, 2019
dosbuff.c The second coming Feb 17, 2019
dosbuff.h The second coming Feb 17, 2019
edit.c the changed creation May 2, 2019
edit.h The fifth foreboding Apr 7, 2019
file.c Version 0.8 (the fourth forecoming) Mar 27, 2019
file.h Version 0.7 (the third installment) Mar 3, 2019
font.c Version 0.9.6 (the crashing creation) May 26, 2019
font.h the changed creation May 2, 2019
funcs.c the changed creation May 2, 2019
funcs.h Version 0.7 (the third installment) Mar 3, 2019
gfx.c Version 0.9.6 (the crashing creation) May 26, 2019
gfx.h the changed creation May 2, 2019
ipx.c The fifth foreboding Apr 7, 2019
ipx.h
lines.c The fifth foreboding Apr 7, 2019
lines.h Version 0.7 (the third installment) Mar 3, 2019
midiplay.c the changed creation May 2, 2019
midiplay.h the changed creation May 2, 2019
sound.c the changed creation May 2, 2019
sound.h the changed creation May 2, 2019
syntax.c the changed creation May 2, 2019
util.c the changed creation May 2, 2019
util.h the changed creation May 2, 2019

README.md

DOjS

A DOS JavaScript Canvas with sound.

DOjS is a JavaScript-able canvas with WAV and MIDI sound support for systems running MS-DOS, FreeDOS or any DOS based Windows (like 95, 98, ME). It was inspired by Processing which is described on Wikipedia as:

Processing is an open-source graphical library and integrated development environment (IDE) / playground built for the electronic arts, new media art, and visual design communities with the purpose of teaching non-programmers the fundamentals of computer programming in a visual context.

It also has a p5js compatibility mode where some of the functions of p5js are available and scripts can have a similar structure to Processing sketches.

You can type in a script with the builtin or your favorite text editor and then run it on a DOS command prompt.

DOjS is pronounces like doge, but ending with an "s".

DOjS logo

DOjS was only possible due to the work of these people/projects:

You can find me on Twitter if you want...

Download and quick start

You can find binary releases on the GitHub release page. Just extract the contents of the archive and run DOjS.

DOjS runs in Dosbox and on real hardware or a virtual machine with MS-DOS, FreeDOS or any DOS based Windows like Windows 95/98/ME.

If you run it on real hardware you need at least a 80386 with 4MB. I recommend a Pentium class machine (>= 100MHz) with at least 32MB RAM. The example files run fine on an Athlon 1GHz and with 256MB RAM.

A minimal script

You can find the following example in examples/exampl.js:

/*
** This function is called once when the script is started.
*/
function Setup() {
    pink = new Color(241, 66, 244, 255); // define the color pink
}

/*
** This function is repeatedly until ESC is pressed or Stop() is called.
*/
function Loop() {
    ClearScreen(EGA.BLACK);
    TextXY(SizeX() / 2, SizeY() / 2, "Hello World!", pink, NO_COLOR);

    TextXY(10, 10, "rate=" + GetFramerate(), EGA.BLACK, EGA.LIGHT_BLUE);
}

/*
** This function is called on any input.
*/
function Input(event) {
    str = JSON.stringify(event);
}

Open this script with DOjS.EXE examples\exampl.js or use DOjS.EXE -r examples\exampl.js to run it without starting the integrated editor first. If the script does not exist the editor loads the template for a new script.

p5js compatibility

If you want to write scripts using the syntax of p5js you need to use Include('p5'); as first line of your script. You can find the following example in examples/examplp5.js:

Include('p5');

/*
** This function is called once when the script is started.
*/
function setup() {
    pink = color(241, 66, 244); // define the color pink
}

/*
** This function is repeatedly until ESC is pressed or Stop() is called.
*/
function draw() {
    background(EGA.BLACK);
    stroke(pink);
    fill(pink);
    text("Hello World!", width / 2, height / 2);

    stroke(EGA.LIGHT_BLUE);
    fill(EGA.LIGHT_BLUE);
    text("rate=" + getFrameRate(), 10, 10);
}

More info can be found at the end of this README in the section Usage and in the API documentation. Take a look at the examples/ as well.

Compilation

You can compile DOjS on any modern Linux (the instructions below are for Debian based distributions) or on Windows 10 using Windows Subsystem for Linux (WSL). Setup Windows Subsystem for Linux (WSL) according to this guide (I used Ubuntu 18.04 LTS).

Preparation

Build and install DJGPP 7.2.0 according to this guide. I used the following command lines to update/install my dependencies:

sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install bison flex curl gcc g++ make texinfo zlib1g-dev g++ unzip htop screen git bash-completion build-essential npm
sudo npm install -g jsdoc
sudo npm install -g tui-jsdoc-template

And the following commands to build and install DJGPP to /home/ilu/djgpp.:

git clone https://github.com/andrewwutw/build-djgpp.git
cd build-djgpp
export DJGPP_PREFIX=/home/ilu/djgpp
./build-djgpp.sh 7.2.0

Getting & Compiling DOjS

Open a shell/command line in the directory where you want the source to reside.

Checkout DOjS from Github:

git clone https://github.com/SuperIlu/DOjS.git

Open the Makefile in a text editor and change the path to DJGPP according to your installation.

Now you are ready to compile DOjS with make clean all. This might take some time as the dependencies are quite a large. make distclean will clean dependencies as well. make zip will create the distribution ZIP and make doc will re-create the HTML help.

History

See the changelog for the projects history.

Planed work

  • Fix bugs!
  • Improve help viewer.
  • Anything fun...

Licenses

DOjS

All code from me is released under MIT license.

MuJS

MuJS is released under ISC license. See COPYING in the MuJS folder for details.

Allegro

Allegro 4 is released under the Giftware license (https://liballeg.org/license.html).

GRX

The GRX fonts are under MIT and other licenses. See copying.grx in LICENSE for details.

IPX and dosbuffer sub-system

This code is taken from the game Cylindrix by Hotwarez LLC, Goldtree Enterprises. It was released under GPLv2.

CWSDPMI.EXE

CWSDPMI DPMI host is licensed under GPL. The documentation states:

The files in this binary distribution may be redistributed under the GPL (with source) or without the source code provided.

Logo

The DOjS logo dog was downloaded from Pexels and kindly provided by Iago Garcia Garcia.

The logo font is Comic relief by Jeff Davis provided under SIL OPEN FONT LICENSE Version 1.1.

WAVs

All WAV files were downloaded from BigSoundBank and are licensed under WTFPL

MIDs

The MIDI files were downloaded from the FreeDOOM project and are licensed under this license.

p5js and examples

p5js is is released under LGPL.

The examples are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

Usage

Command line

Usage: DOjS.EXE [-r] [-s <p>:<i>:<d>] <script>
    -r             : Do not invoke the editor, just run the script.
    -w <width>     : Screen width: 320 or 640, Default: 640.
    -b <bpp>       : Bit per pixel:8, 16, 24, 32. Default: 32.
    -s             : No wave sound.
    -f             : No FM sound.
    -a             : Disable alpha (speeds up rendering).

Editor keys

    F1  : Open/Close help
    F3  : Save script
    F4  : Run script
    F7  : Find text
    F9  : Show/Close logfile
    F10 : Quit

    Shift-F4   : Truncate logfile and run script
    Shift-F7   : Find again
    CTRL-D     : Delete current line
    CTRL-LEFT  : Previous word
    CTRL-RIGHT : Next word
    PAGE-UP    : One page up.
    PAGE-DOWN  : One page down.
    HOME       : Go to start of line
    END        : Go to end of line
    CTRL-HOME  : Go to start of line
    CTRL-END   : Go to end of line

    TAB size is 4.
    The help viewer will remember the current position.

    The logfile can be truncated by pressing DEL in the log viewer.

API documentation

You can find the full API doc in the doc/html/ directory. Go to the p5.js hompage for p5.js reference.

Script format

Scripts need to provide three functions: Setup(), Loop() and Input(). Scripts are loaded and executed top-own. After that Setup() is called once and then Loop() repeatedly. Input() is called whenever mouse of keyboard input happens.

Setup()

This function is called once at startup. It can initialize variables, setup hardware, etc.

Loop()

This function is called after setup repeatedly until Stop() is called. After calling Stop() the program ends when Loop() exits.

Input(event)

This function is called whenever mouse/keyboard input happens.

IPX networking

DOjS supports IPX networking. Node addresses are arrays of 6 numbers between 0-255. Default socket number and broadcast address definitions can be found in jsboot/ipx.js.

Drawing functions

See API doc for details.

Processing/p5js compatibility layer

Add Include('p5'); as first line to your script. After that you have (limited) p5.js compatibility. Things that don't work:

  • Anything 3D (objects, lights camera, etc)
  • Key release events work different for Allegro and are simulated for p5js.
  • Only simple vertices are supported.
  • no DOM

Logfile

All output via Print() and Println() is sent to the file JSLOG.TXT. You can use Debug() instead and output is only generated when you set the global variable DEBUG=true.

Remote logging/debugging

This feature allows you to debug a running script via IPX networking and a second machine. To use remote logging do the following:

  • Put both machines on the same network.
  • Run DOJS.EXE -r JSBOOT\LOGVIEW.JS on one machine.
  • Enable debugging by setting DEBUG=true and enable remote debugging by REMOTE_DEBUG=true. You can either modify JSBOOT\FUNC.JS or change the variables at the very beginning of your script.

This works fine with two instances of DOSBox as well. Please note that if the log messages are transmitted to fast the receiving instance of DOJS might skip some of these when displaying.

You can’t perform that action at this time.