Skip to content

Commit

Permalink
v1.0.0 - With logging char input ZVM is now complete
Browse files Browse the repository at this point in the history
  • Loading branch information
curiousdannii committed Jan 20, 2017
1 parent 7d38292 commit dd11bfd
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tests/regtest.py:
$(CURL) -o tests/regtest.py https://raw.githubusercontent.com/erkyrath/plotex/master/regtest.py

# Run the test suite
test: dist/zvm.js tests/regtest.py
test: dist/zvm.min.js tests/regtest.py
cd tests && python regtest.py praxix.regtest
cd tests && python regtest.py praxix-bundled.regtest
cd tests && python regtest.py curses.regtest
4 changes: 2 additions & 2 deletions bin/zvm.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ if ( !fs.existsSync( storyfile ) )
return;
}

// Use the bundled VM if requested
var ZVM = require( argv.b ? '../dist/zvm.js' : '../src/zvm.js' );
// Use the bundled (and minified) VM if requested
var ZVM = require( argv.b ? '../dist/zvm.min.js' : '../src/zvm.js' );

var vm = new ZVM();
var Glk = GlkOte.Glk;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ifvms",
"title": "ifvms.js",
"version": "0.2.2",
"version": "1.0.0",
"description": "The Interactive Fiction Virtual Machines Suite - in Javascript",
"author": "Dannii Willis <[email protected]>",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/zvm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
ZVM - the ifvms.js Z-Machine (versions 3, 5 and 8)
==================================================
Copyright (c) 2016 The ifvms.js team
Copyright (c) 2017 The ifvms.js team
BSD licenced
http://github.com/curiousdannii/ifvms.js
Expand Down
30 changes: 29 additions & 1 deletion src/zvm/io.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,19 @@ module.exports = {
// Handle char input
handle_char_input: function( charcode )
{
this.variable( this.read_data.storer, ZSCII_keyCodes[ charcode ] || this.reverse_unicode_table[ charcode ] || 63 );
var stream4 = this.io.streams[4],
code = ZSCII_keyCodes[ charcode ] || this.reverse_unicode_table[ charcode ] || 63;
this.variable( this.read_data.storer, code );

// Echo to the commands log
if ( stream4.mode === 1 )
{
stream4.cache += code;
}
if ( stream4.mode === 2 )
{
this.Glk.glk_put_char_stream_uni( stream4.str, code );
}
},

// Handle the result of glk_fileref_create_by_prompt()
Expand Down Expand Up @@ -666,6 +678,22 @@ module.exports = {
// Request character input
read_char: function( storer, one, time, routine )
{
// Input stream 1
if ( this.io.streams[0] )
{
var code = this.Glk.glk_get_char_stream_uni( this.io.streams[0] );
// Check for EOF
if ( code === -1 )
{
this.input_stream( 0 );
}
else
{
this.variable( storer, code );
return this.stop = 0;
}
}

this.read_data = {
routine: routine,
storer: storer,
Expand Down

0 comments on commit dd11bfd

Please sign in to comment.