Skip to content

Commit

Permalink
Version 1.7.0 (The live animation)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilu committed Nov 12, 2021
1 parent 0ec83f3 commit 70ac969
Show file tree
Hide file tree
Showing 53 changed files with 12,320 additions and 146 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -120,4 +120,7 @@ TMP2.ZIP
openssl-1.1.1k/apps/progs.h
.picasa.ini
fddojs.zip
dosbox.conf
*.mpg
AUDIO.RAW
tests/deuwe.mp4
vscode/livedojs/node_modules/
2 changes: 1 addition & 1 deletion 3dfx-glide.c
Original file line number Diff line number Diff line change
Expand Up @@ -843,7 +843,7 @@ void init_3dfx(js_State *J) {

FILE *f = fopen("GLIDE3X.DXE", "r");
if (!f) {
LOG("GLIDE3X.DXE missing, please run one of the V_x.BAT scripts to get the driver matching your hardware! All 3dfx functions are disabled!");
LOG("GLIDE3X.DXE missing, please run one of the V_x.BAT scripts to get the driver matching your hardware! All 3dfx functions are disabled!\n");

js_newcfunction(J, f_dummy_fxInit, "fxInit", 0);
js_setglobal(J, "fxInit");
Expand Down
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
# Version 1.6.1 (The corruption) / September 17th, 2021
# Version 1.7.0 (The live animation) / November 12th, 2021
* Added FLIC playback (video)
* Added MPEG1 playback (audio/video) using plugin `mpeg1`.
* Added Ogg Vorbis playback plugin `vorbis`.
* Added `rawplay` plugin for raw 16 bit stereo audio data loaded from file system or ZIP.
* Added CTRL-F for 'search' (same as F7)
* Added live coding examples. Install the extension in the `vscode/` directory and run `DOjS -r examples\websvr.js`
* Fixed missing newline in error message.

# Version 1.6.1 (The calloc corruption) / September 17th, 2021
* Fixed memory corruption during javascript runtime exceptions.

# Version 1.6.0 (Does it blend) / August, 28th, 2021
# Version 1.6.0 (Does it blend) / August 28th, 2021
* Added JPEG loading through `jpeg` module
* Made `JSLOG.txt` optional and the filename can be changed as well
* Updated libcpuid to v0.5.1
Expand Down
25 changes: 25 additions & 0 deletions DOjS.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ SOFTWARE.
#include "edit.h"
#include "file.h"
#include "font.h"
#include "flic.h"
#include "funcs.h"
#include "gfx.h"
#include "joystick.h"
Expand Down Expand Up @@ -444,6 +445,7 @@ static void run_script(int argc, char **argv, int args) {
init_socket(J);
init_zipfile(J);
init_intarray(J);
init_flic(J);

// create canvas
bool screenSuccess = true;
Expand Down Expand Up @@ -545,6 +547,7 @@ static void run_script(int argc, char **argv, int args) {
LOG("DOjS Shutdown...\n");
js_freestate(J);
dojs_shutdown_libraries();
shutdown_flic();
shutdown_midi();
shutdown_sound();
shutdown_joystick();
Expand Down Expand Up @@ -721,6 +724,28 @@ void dojs_update_transparency() {
}
}

/**
* @brief cloe and re-open logfile to flush() all data and make the logfile accessible from Javascript.
*/
void dojs_logflush() {
if (DOjS.logfile) {
// close current logfile
fclose(DOjS.logfile);

// recreate logfile
if (DOjS.logfile_name) {
DOjS.logfile = fopen(DOjS.logfile_name, "a");
if (!DOjS.logfile) {
fprintf(stderr, "Could not open/create logfile %s.\n", DOjS.logfile_name);
exit(1);
}
setbuf(DOjS.logfile, 0);
} else {
DOjS.logfile = NULL;
}
}
}

/**
* @brief main entry point.
*
Expand Down
5 changes: 3 additions & 2 deletions DOjS.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ SOFTWARE.

#define SYSINFO ">>> " //!< logfile line prefix for system messages

#define DOSJS_VERSION 1.61 //!< version number
#define DOSJS_VERSION_STR "V1.6.1" //!< version number as string
#define DOSJS_VERSION 1.70 //!< version number
#define DOSJS_VERSION_STR "V1.7.0" //!< version number as string

#define JSBOOT_DIR "JSBOOT/" //!< directory with boot files.
#define JSBOOT_ZIP "JSBOOT.ZIP" //!< filename for ZIP of JSBOOT
Expand Down Expand Up @@ -254,5 +254,6 @@ extern void dojs_update_transparency(void);
extern bool dojs_register_library(const char *name, void *handle, void (*init)(js_State *J), void (*shutdown)(void));
extern bool dojs_check_library(js_State *J, const char *name, bool call_init);
extern int dojs_do_file(js_State *J, const char *fname);
extern void dojs_logflush(void);

#endif // __DOJS_H__
6 changes: 3 additions & 3 deletions FDOS/DOJS.LSM
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
Begin3
Title: DOjS
Version: 1.6.0
Version: 1.7.0
Entered-date: 2021-01-22
Description: A DOS JavaScript Canvas with sound
Summary: DOjS is a JavaScript-able canvas with WAV and MIDI sound support. 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.
Changes: V1.6 release
Changes: V1.7.0 added MPEG1/FLIC playback and live coding
Keywords: java, JavaScript
Author: SuperIlu
Maintained-by: SuperIlu
Primary-site: https://github.com/SuperIlu/DOjS
Original-site: https://github.com/SuperIlu/DOjS
Platforms: DOS
Copying-policy: Various Licenses, See LICENSE file
Modified-date: 2021-08-29
Modified-date: 2021-11-12
End
14 changes: 11 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ PARTS= \
$(BUILDDIR)/edit.o \
$(BUILDDIR)/file.o \
$(BUILDDIR)/font.o \
$(BUILDDIR)/flic.o \
$(BUILDDIR)/funcs.o \
$(BUILDDIR)/lowlevel.o \
$(BUILDDIR)/gfx.o \
Expand Down Expand Up @@ -177,19 +178,23 @@ TEXUS.EXE:
$(MAKE) -C $(TEXUS) clean all
cp $(TEXUS)/TEXUS.EXE .

exstream: liballegro
$(CC) $(CFLAGS) -c $(ALLEGRO)/examples/exstream.c -o exstream.o
$(CC) $(LDFLAGS) -o extream.exe exstream.o $(LIBS)

zip: all doc
rm -f $(RELZIP)
rm -f dxetest.DXE dxetest2.DXE
curl --remote-name --time-cond cacert.pem https://curl.se/ca/cacert.pem
cp $(GLIDE)/v1/lib/glide3x.dxe ./GLIDE3X.DXE
zip -9 -r $(RELZIP) $(EXE) WATTCP.CFG GLIDE3X.DXE CWSDPMI.EXE LICENSE *.md JSBOOT.ZIP examples/ $(DOCDIR) $(GLIDE)/*/lib/glide3x.dxe V_*.BAT TEXUS.EXE cacert.pem *.DXE

devzip: all doc $(RELZIP)
devzip: all doc
rm -f $(RELZIP)
curl --remote-name --time-cond cacert.pem https://curl.se/ca/cacert.pem
cp $(GLIDE)/v1/lib/glide3x.dxe ./GLIDE3X.DXE
cp $(OPENSSL)/apps/openssl.exe .
zip -9 -r $(RELZIP) $(EXE) WATTCP.CFG GLIDE3X.DXE CWSDPMI.EXE LICENSE *.md JSBOOT.ZIP examples/*.js tests/*.js tests/*.svg $(GLIDE)/*/lib/glide3x.dxe V_*.BAT TEXUS.EXE cacert.pem openssl.exe *.DXE
zip -9 -r $(RELZIP) $(EXE) WATTCP.CFG GLIDE3X.DXE CWSDPMI.EXE LICENSE *.md JSBOOT.ZIP examples/ tests/*.js tests/*.svg tests/*.mpg tests/*.ogg $(GLIDE)/*/lib/glide3x.dxe V_*.BAT TEXUS.EXE cacert.pem openssl.exe *.DXE
scp $(RELZIP) [email protected]:/sata/c64

doc:
Expand All @@ -204,7 +209,7 @@ init:

clean:
rm -rf $(BUILDDIR)/
rm -f $(EXE) DOJS.exe $(ZIP) JSLOG.TXT TEXUS.EXE GLIDE3X.DXE JSBOOT.ZIP cacert.pem
rm -f $(EXE) DOJS.exe $(ZIP) JSLOG.TXT TEXUS.EXE GLIDE3X.DXE JSBOOT.ZIP cacert.pem W32DHCP.TMP
for dir in $(DXE_DIRS); do \
$(MAKE) -C $$dir -f Makefile $@; \
done
Expand Down Expand Up @@ -241,6 +246,9 @@ curlclean:
$(MAKE) -C $(CURL)/lib -f Makefile.dj clean
rm -f $(CURL)/lib/libcurl.a

muclean:
rm -f $(MUJS)/build/release/libmujs.a

glideclean:
rm -rf glidedxe.c

Expand Down
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ The following hardware/functions are available:
* COM or serial port access
* IPX and TCP/IP networking
* ZIP file access
* GIF-Animation, FLC/FLI, MPEG1 or OggVorbis playback

## A minimal script
You can find the following example in `examples/exampl.js`:
Expand Down Expand Up @@ -176,12 +177,34 @@ If you used Windows-Tools to check out DOjS from git you may need to fix the new
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.

# Notes
## 3dfx/Glide3
In order to compile DOjS you need Glide3 includes and binaries. The ones included with the DOjS sources were created using my [glide repository](https://github.com/SuperIlu/glide) on GitHub.

## GRX Fonts
DOjS comes pre-bundled with all fonts included with GRX (files ending with ".FNT"). If you want/need additional fonts you can find a very simple tool to convert TTF/BDF fonts to GRX format [here](https://github.com/SuperIlu/GrxFntConv). Results may vary...

## Live coding
If you run DOjS on a computer with network interface and a matching packet driver you can (sort of) live code using the [VSCode](https://code.visualstudio.com/) extension in `vscode\livedojs-0.0.4.vsix`. You need to start `DOjS -r examples/websvr.js` and then set the IP address in VSCode using the command `DOjS: Set hostname`. Live coding sketches must look like below to work:
```
// livedojs
exports.Setup = function () {
}
exports.Loop = function () {
ClearScreen(EGA.BLACK);
FilledBox(10, 10, 70, 20, EGA.GREEN);
}
```
* The first line must be exactly `// livedojs`
* The file must end with `.js`
* Only `Setup()` and `Loop()` are available, `Input()` does not work.
* p5js compatibility does not work, you must code using DOjS native API
* If the hostname is set the sketch will be automatically be uploaded on save
* The sketch can be uploaded using `DOjS: Upload sketch` manually
* you can access the JSLOG.TXT of the running server by using `DOjS: get logfile`

# History
See the [changelog](/CHANGELOG.md) for the projects history.

Expand All @@ -196,6 +219,9 @@ See the [changelog](/CHANGELOG.md) for the projects history.
* https://github.com/evanw/lightgl.js
* Fix bugs!
* Anything fun...
* http://www.speech.cs.cmu.edu/flite/
* http://speect.sourceforge.net/
* http://espeak.sourceforge.net/

# Licenses
See [LICENSE](LICENSE) file for all licenses.
Expand Down
5 changes: 3 additions & 2 deletions doc/Bitmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ function Bitmap(filename) {
* Width in pixels
* @member {number}
*/
this.width = null;
this.width = 0;
/**
* Height in pixels
* @member {number}
*/
this.height = null;
this.height = 0;
};

/**
* Draw the image to the canvas at given coordinates.
* @param {number} x position to draw to.
Expand Down
4 changes: 3 additions & 1 deletion doc/COMPort.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* @see LoadLibrary()
*
* @class
*
* @param {number} port one of COM.PORT: COM1, COM2, COM3, COM4.
* @param {number} baud one of COM.BAUD: B50, B75, B110, B134, B150, B200, B300, B600, B1200, B1800, B2400, B4800, B9600, B19200, B38400, B57600, B115200
* @param {number} bits one of COM.BIT: BITS_5, BITS_6, BITS_7, BITS_8
Expand All @@ -15,7 +16,8 @@
* @param {number} [addr] optional: port io address
* @param {number} [irq] optional: port IRQ
*/
function COMPort(port, baud, bits, parity, stop, flow, addr, irq) { }
function COMPort(port, baud, bits, parity, stop, flow, addr, irq) { };

/**
* close port.
*/
Expand Down
1 change: 1 addition & 0 deletions doc/File.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/**
* Open a file, for file modes see {@link FILE}. Files can only either be read or written, never both. Writing to a closed file throws an exception.
* @class
*
* @param {string} filename the name of the file.
* @param {FILE} mode READ, WRITE or APPEND.
*/
Expand Down
2 changes: 1 addition & 1 deletion doc/Font.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function Font(filename) {
* Font height
* @member {number}
*/
this.height = null;
this.height = 0;
}
/**
* Draw a left aligned string to the canvas.
Expand Down
20 changes: 8 additions & 12 deletions doc/GifAnim.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
/**
* GITanim loader/render
* load a GIF animation.
*
* **Note: GIFanim module must be loaded by calling LoadLibrary("gifanim") before using!**
*
* @see LoadLibrary()
*
* @module gifanim
*/

/**
* load a GIF animation.
* @class
*
* @param {string} filename file name of the GIT to load
* @param {string} filename file name of the GIF to load
*/
function GIFanim(filename) {
/**
* name of gif
* @member {string}
*/
this.filename = 0;
this.filename = null;
/**
* width of GIF
* @member {number}
Expand Down Expand Up @@ -54,13 +50,13 @@ function GIFanim(filename) {
/**
* Close GIFanim after use
*/
function Close() { }
GIFanim.prototype.Close = function () { }

/**
* get gif anim comment
* @returns {string} the gif anim comment
*/
function GetComment() { }
GIFanim.prototype.GetComment = function () { }

/**
* play the next frame of the animation. Frames are rendered consecutive with each call.
Expand All @@ -70,10 +66,10 @@ function GetComment() { }
* @param {number} y y position to render the left, upper edge of the animation
* @returns {number} -1 if this was the last frame, else the delay for the next frame.
*/
function PlayFrame(x, y) { }
GIFanim.prototype.PlayFrame = function (x, y) { }

/**
* skip the rendering of a frame.
* @returns {number} -1 if this was the last frame, else the delay for the next frame.
*/
function SkipFrame() { }
GIFanim.prototype.SkipFrame = function () { }
Loading

0 comments on commit 70ac969

Please sign in to comment.