Skip to content

Commit

Permalink
New version number, and fixes for glkop.c from Glulxe
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidKinder committed Aug 29, 2011
1 parent c836145 commit b32a533
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 8 deletions.
6 changes: 6 additions & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,12 @@ also to Eliuk Blau for tracking down bugs in the memory management opcodes.

* Version History

1.2.9 2011-08-28 Fixed a bug in glkop.c dispatching, to do with optional
array arguments, following a similar fix in Glulxe.
Glk array and string operations are now checked for memory
overflows (though not for ROM writing), following a similar
fix in Glulxe.

1.2.8 2010-08-25 Fixed a problem with 'undo' when compiled as 64 bit,
contributed by Ben Cressey.
Fixed a sign problem for the @fceil opcode, following a
Expand Down
1 change: 1 addition & 0 deletions git.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ extern void startProgram (size_t cacheSize, enum IOMode ioMode);
extern int git_init_dispatch();
extern glui32 git_perform_glk(glui32 funcnum, glui32 numargs, glui32 *arglist);
extern strid_t git_find_stream_by_id(glui32 id);
extern glui32 git_find_id_for_stream(strid_t str);

// git_search.c

Expand Down
57 changes: 54 additions & 3 deletions glkop.c
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,16 @@ glui32 git_perform_glk(glui32 funcnum, glui32 numargs, glui32 *arglist)
directly -- instead of bothering with the whole prototype
mess. */

case 0x0047: /* stream_set_current */
if (numargs != 1)
goto WrongArgNum;
glk_stream_set_current(git_find_stream_by_id(arglist[0]));
break;
case 0x0048: /* stream_get_current */
if (numargs != 0)
goto WrongArgNum;
retval = git_find_id_for_stream(glk_stream_get_current());
break;
case 0x0080: /* put_char */
if (numargs != 1)
goto WrongArgNum;
Expand All @@ -297,6 +307,16 @@ glui32 git_perform_glk(glui32 funcnum, glui32 numargs, glui32 *arglist)
goto WrongArgNum;
retval = glk_char_to_upper(arglist[0] & 0xFF);
break;
case 0x0128: /* put_char_uni */
if (numargs != 1)
goto WrongArgNum;
glk_put_char_uni(arglist[0]);
break;
case 0x012B: /* put_char_stream_uni */
if (numargs != 2)
goto WrongArgNum;
glk_put_char_stream_uni(git_find_stream_by_id(arglist[0]), arglist[1]);
break;

WrongArgNum:
fatalError("Wrong number of arguments to Glk function.");
Expand All @@ -306,7 +326,7 @@ glui32 git_perform_glk(glui32 funcnum, glui32 numargs, glui32 *arglist)
/* Go through the full dispatcher prototype foo. */
char *proto, *cx;
dispatch_splot_t splot;
int argnum;
int argnum, argnum2;

/* Grab the string. */
proto = gidispatch_prototype(funcnum);
Expand Down Expand Up @@ -335,9 +355,11 @@ glui32 git_perform_glk(glui32 funcnum, glui32 numargs, glui32 *arglist)
gidispatch_call(funcnum, argnum, splot.garglist);

/* Phase 3. */
argnum = 0;
argnum2 = 0;
cx = proto;
unparse_glk_args(&splot, &cx, 0, &argnum, 0, 0);
unparse_glk_args(&splot, &cx, 0, &argnum2, 0, 0);
if (argnum != argnum2)
fatalError("Argument counts did not match.");

break;
}
Expand Down Expand Up @@ -560,6 +582,12 @@ static void parse_glk_args(dispatch_splot_t *splot, char **proto, int depth,

switch (typeclass) {
case 'C':
/* This test checks for a giant array length, and cuts it down to
something reasonable. Future releases of this interpreter may
treat this case as a fatal error. */
if (varglist[ix+1] > gEndMem || varglist[ix]+varglist[ix+1] > gEndMem)
varglist[ix+1] = gEndMem - varglist[ix];

garglist[gargnum].array = (void*) AddressOfArray(varglist[ix]);
gargnum++;
ix++;
Expand All @@ -568,6 +596,10 @@ static void parse_glk_args(dispatch_splot_t *splot, char **proto, int depth,
cx++;
break;
case 'I':
/* See comment above. */
if (varglist[ix+1] > gEndMem/4 || varglist[ix+1] > (gEndMem-varglist[ix])/4)
varglist[ix+1] = (gEndMem - varglist[ix]) / 4;

garglist[gargnum].array = CaptureIArray(varglist[ix], varglist[ix+1], passin);
gargnum++;
ix++;
Expand Down Expand Up @@ -679,6 +711,8 @@ static void parse_glk_args(dispatch_splot_t *splot, char **proto, int depth,
}
else {
cx++;
if (isarray)
ix++;
}
}
}
Expand Down Expand Up @@ -885,6 +919,8 @@ static void unparse_glk_args(dispatch_splot_t *splot, char **proto, int depth,
}
else {
cx++;
if (isarray)
ix++;
}
}
}
Expand Down Expand Up @@ -916,6 +952,21 @@ strid_t git_find_stream_by_id(glui32 objid)
return classes_get(1, objid);
}

/* find_id_for_stream():
The converse of find_stream_by_id().
This is only needed in this file, so it's static.
*/
glui32 git_find_id_for_stream(strid_t str)
{
gidispatch_rock_t objrock;

if (!str)
return 0;

objrock = gidispatch_get_objrock(str, 1);
return ((classref_t *)objrock.ptr)->id;
}

/* Build a hash table to hold a set of Glk objects. */
static classtable_t *new_classtable(glui32 firstid)
{
Expand Down
2 changes: 1 addition & 1 deletion help/glk.htm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ <h1>Glk</h1>
The <a href="http://www.ifarchive.org/if-archive/programming/glk/glk-spec-070.txt">Glk specification</a>
was written by Andrew Plotkin as an attempt to define a standard input and output interface for general
use in IF related projects. Windows Git uses my (David Kinder) implementation of Glk, called Windows
Glk. Windows Glk is a complete implementation of all the features described in version 0.7.2 of the Glk
Glk. Windows Glk is a complete implementation of all the features described in version 0.7.3 of the Glk
specification.
<p>
The complete Windows Glk package, including developer information, can be downloaded from the IF Archive's
Expand Down
2 changes: 1 addition & 1 deletion help/glulx.htm
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h1>Glulx</h1>
the Inform compiler could compile to, without the limitations of its original output format, Infocom's
Z-Machine.
<p>
Windows Git is based on Iain Merrick's Git 1.2.8, which is a complete implementation of version 3.1.2
Windows Git is based on Iain Merrick's Git 1.2.9, which is a complete implementation of version 3.1.2
of the Glulx specification.
<p>
More information on Glulx is available from the Glulx web page:
Expand Down
2 changes: 1 addition & 1 deletion help/overview.htm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<link rel="stylesheet" type="text/css" href="Git.css">
</head>
<body>
<h1>Windows Git 1.2.8<br><font size="-1">(Windows Glk 1.43)</font></h1>
<h1>Windows Git 1.2.9<br><font size="-1">(Windows Glk 1.43)</font></h1>
Windows Git is an interpreter for <a href="glulx.htm">Glulx</a> games. Windows Git
consists of a core interpreter called Git, and an input/output library, called Windows
Glk. Together these two components form the Windows Git package, which has been created
Expand Down
5 changes: 4 additions & 1 deletion help/revision.htm
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@
<body>
<h1>Revision History</h1>

<b>Git 1.2.8 (Windows Glk 1.43)</b>
<b>Git 1.2.9 (Windows Glk 1.43)</b>
<ul>
<li>Updated to support Glk 0.7.3, which includes more control when playing sounds.
<li>[More] prompts now function even if the game has exited, allowing any
long amount of final text to be read.
<li>Fixed a bug with file streams when reading and writing to the same file.
<li>Updated to Git 1.2.9, which fixes bugs related to Glk call dispatching,
following similar fixes in Glulxe.
</ul>

<b>Git 1.2.8 (Windows Glk 1.42)</b>
Expand Down
2 changes: 1 addition & 1 deletion version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Automatically generated file -- do not edit!
#define GIT_MAJOR 1
#define GIT_MINOR 2
#define GIT_PATCH 8
#define GIT_PATCH 9

0 comments on commit b32a533

Please sign in to comment.