Skip to content

Commit

Permalink
work on output
Browse files Browse the repository at this point in the history
  • Loading branch information
dschwen committed Nov 16, 2013
1 parent 1bc1673 commit ee8092c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.debug
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ in jzip.html console:
spinupJS = Module.cwrap('spinupJS', 'number', ['string'])
spinupJS('zork2.z3')

interpret = Module.cwrap('_interpret','number')
2 changes: 1 addition & 1 deletion emscripten.mak
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ ckifzs : ckifzs.bc


clean :
-rm -f *.bc
-rm -f *.bc jzip.js

realclean :
-rm -f *bc jzip jzexe ckifzs
Expand Down
17 changes: 11 additions & 6 deletions emscriptenio.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,8 @@ void select_text_window( )
void create_status_window( )
{
int row, col;

EM_ASM( console.log('create_status_window()'); );
/*
if ( *CS )
{
Expand All @@ -370,6 +372,7 @@ void create_status_window( )
void delete_status_window( )
{
int row, col;
EM_ASM( console.log('delete_status_window()'); );
/*
if ( *CS )
{
Expand All @@ -384,7 +387,7 @@ void delete_status_window( )

void clear_line( )
{

EM_ASM( console.log('clear_line()'); );
///* tputs (CE, 1, outc);*/
int i;
/*
Expand All @@ -396,6 +399,7 @@ void clear_line( )
void clear_text_window( )
{
int i, row, col;
EM_ASM( console.log('clear_text_window()'); );
/*
get_cursor_position( &row, &col );
Expand All @@ -411,6 +415,7 @@ void clear_text_window( )

void clear_status_window( )
{
EM_ASM( console.log('clear_status_window()'); );
int i, row, col;
/*
get_cursor_position( &row, &col );
Expand All @@ -427,6 +432,9 @@ void clear_status_window( )

void move_cursor( int row, int col )
{
//EM_ASM( console.log('move_cursor(',_row,_col,')'); );
//asm("console.log('move_cursor(',%0,%1,')')" : "r"(row), "r"(col));
asm("console.log('move_cursor(',%0,%1,')')" : : "r"(row), "r"(col));
/*
tputs( tgoto( CM, col - 1, row - 1 ), 1, outc );
*/
Expand Down Expand Up @@ -467,6 +475,7 @@ void restore_cursor_position( )

void set_attribute( int attribute )
{
EM_ASM( console.log('set_attribute()'); );
#if defined HARD_COLORS
static int emph = 0, rev = 0;

Expand Down Expand Up @@ -537,11 +546,7 @@ void set_attribute( int attribute )

static void display_string( char *s )
{
EM_ASM(
console.log(s);
);
/* while ( *s )
display_char( *s++ );*/
asm("window['jsPrintString'](%0)" : : "r"(s) );
} /* display_string */

void display_char( int c )
Expand Down
8 changes: 8 additions & 0 deletions input.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
*
*/

#ifdef EMSCRIPTEN
#include <emscripten.h>
#endif

#include "ztypes.h"

/* Statically defined word separator list */
Expand Down Expand Up @@ -249,6 +253,10 @@ int get_line( char *cbuf, zword_t timeout, zword_t action_routine )
* call the timeout action routine. If the return status from the
* timeout routine was 0 then try to read the line again */

#ifdef EMSCRIPTEN
EM_ASM( console.log('get_line()'); );
exit(0);
#endif
do
{
c = input_line( buflen, buffer, timeout, &read_size );
Expand Down
9 changes: 9 additions & 0 deletions jzip.html
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@
break;
}
});

// functions to be called from the c code
window['jsPrintString'] = function(s) {
var c,t='',p=s;
while(c=Module.getValue(p++, 'i8')) {
t=t+String.fromCharCode(c)
}
console.log('display_string: ',t);
}
})();
</script>
</body>
Expand Down

0 comments on commit ee8092c

Please sign in to comment.