diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4d00d6b --- /dev/null +++ b/.gitignore @@ -0,0 +1,83 @@ +# Built application files +*.apk +*.ap_ +*.aab + +# Files for the ART/Dalvik VM +*.dex + +# Java class files +*.class + +# Generated files +bin/ +gen/ +out/ +release/ + +# Gradle files +.gradle/ +build/ + +# Local configuration file (sdk path, etc) +local.properties + +# Proguard folder generated by Eclipse +proguard/ + +# Log Files +*.log + +# Android Studio Navigation editor temp files +.navigation/ + +# Android Studio captures folder +captures/ + +# IntelliJ +*.iml +.idea/workspace.xml +.idea/tasks.xml +.idea/gradle.xml +.idea/assetWizardSettings.xml +.idea/dictionaries +.idea/libraries +# Android Studio 3 in .gitignore file. +.idea/caches +.idea/modules.xml +# Comment next line if keeping position of elements in Navigation Editor is relevant for you +.idea/navEditor.xml + +# Keystore files +# Uncomment the following lines if you do not want to check your keystore files in. +#*.jks +#*.keystore + +# External native build folder generated in Android Studio 2.2 and later +.externalNativeBuild +**/.cxx + +# Google Services (e.g. APIs or Firebase) +# google-services.json + +# Freeline +freeline.py +freeline/ +freeline_project_description.json + +# fastlane +fastlane/report.xml +fastlane/Preview.html +fastlane/screenshots +fastlane/test_output +fastlane/readme.md + +# Version control +vcs.xml + +# lint +lint/intermediates/ +lint/generated/ +lint/outputs/ +lint/tmp/ +# lint/reports/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..841f32c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "app/src/main/jni/garglk"] + path = app/src/main/jni/garglk + url = https://github.com/davidar/garglk.git diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml new file mode 100644 index 0000000..681f41a --- /dev/null +++ b/.idea/codeStyles/Project.xml @@ -0,0 +1,116 @@ + + + + + + + +
+ + + + xmlns:android + + ^$ + + + +
+
+ + + + xmlns:.* + + ^$ + + + BY_NAME + +
+
+ + + + .*:id + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + .*:name + + http://schemas.android.com/apk/res/android + + + +
+
+ + + + name + + ^$ + + + +
+
+ + + + style + + ^$ + + + +
+
+ + + + .* + + ^$ + + + BY_NAME + +
+
+ + + + .* + + http://schemas.android.com/apk/res/android + + + ANDROID_ATTRIBUTE_ORDER + +
+
+ + + + .* + + .* + + + BY_NAME + +
+
+
+
+
+
\ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..37a7509 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,9 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..7f68460 --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,12 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c12eeb7..db579ea 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="26" + android:versionName="1.5.0"> diff --git a/app/src/main/assets/open_source_licences.html b/app/src/main/assets/open_source_licences.html index e6642fe..0d8b863 100644 --- a/app/src/main/assets/open_source_licences.html +++ b/app/src/main/assets/open_source_licences.html @@ -74,3028 +74,134 @@

Licences

Fabularium incorporates some or all of the following libraries, subject to the below licences:

-

ADVSYS (ANSI) + NewParser

-

Website

- -
-
-AdvSys is copyright (c) 2009 David Betz.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-    * Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    * Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in the
-      documentation and/or other materials provided with the distribution.
-
-    * The name of the author may not be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY
-EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-    
-
- -

AGILITY 1.1.1

-

Website

- -
-
-=================================================
-AGILITY: THE (MOSTLY) UNIVERSAL AGT INTERPRETER
-Version 1.1.1
-=================================================
-
-  This is an interpreter for game files created with Malmberg and
-Welch's _Adventure Game Toolkit_. AGiliTy is universal in the sense
-that it understands and interprets most of the many versions of the
-AGT game file format (unlike the original interpreters which were
-only intended to run the game file format associated with them) and
-also in that it is written in ANSI C and so should be straightforward
-to port to other systems.
-
-  It is *not* a port of the original interpreters but rather a
-completely new interpreter built around the game file format; while it
-follows the original interpreters on most things, there are some
-differences which are described below.
-
-
-----------
- CONTENTS
-----------
-  INTRODUCTION
-  ACKNOWLEDGMENTS
-  AGT AND AGX GAME FILES
-  AGT VERSIONS SUPPORTED
-  DIFFERENCES BETWEEN AGILITY AND THE ORIGINAL INTERPRETERS
-  LIST OF SPECIAL VERBS
-  CONFIGURATION FILES
-  DEBUGGING OPTIONS
-  AGT GAME LIST
-
-
---------------
- INTRODUCTION
---------------
-   For general information on AGT, I recommend Jay Goemmer's web page
-at http://www.ltlink.com/~jgoemmer/agt.html.
-
-  The most recent release of this program can be found at the
-Interactive Fiction archive:
-    ftp://ftp.ifarchive.org/if-archive/programming/agt/agility/
-
-  This software is copyright 1996-1999,2001 by Robert Masenten.
-This program is free software; you can redistribute it and/or modify
-it under the terms of version 2 of the GNU General Public License,
-as published by the Free Software Foundation.
-  This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-  You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-  For information on compiling and porting this program, see the file
-'porting.txt'. A list of known bugs is in the file 'buglist' and a
-list of changes from earlier versions is in 'changes.txt'. (If this is
-with an executable and not the source version, some of these files may not
-be present).
-
-   Send comments and bug reports to Robert Masenten at:
-	rcm-math@pacbell.net
-
-
-
------------------
- ACKNOWLEDGMENTS
------------------
-Thanks to the following people:
- *Jay Goemmer, who has sent me pages and pages of comments and bug
-reports.
- *David Kinder, responsible for the both the Amiga and Windows ports and
-a source of much valuable feedback.
- *David Youd, who has uncovered many subtle and complex bugs in both
-AGiliTy and Magx.
- *Mitch Mlinar, who has contributed several patches.
- *Jan-Erik Karlsson, for his bug report/patch.
- *Everyone else who has sent me suggestions and bug reports, including
-Audrey De Lisle (responsible for the red smoke), David Doherty, Al
-Golden, John Hartnup, Walter Isaac, Sami Kivela, Alexander Lehmann,
-Grant E. Metcalf, Paul Mikell, Adam Myrow, Olav Nielsen, D.J. Picton,
-Kevin Soucy, Ben Straub, "Grand Moff Tarkin", Adam Thornton, Mark
-Tilford, David Turpin, and Gil Williamson.
- *Volker Blasius, maintainer of the Interactive Fiction Archive at
-ftp.ifarchive.org.
- *Robert Pelak, who suggested the name "AGiliTy".
- *All of the other people on rai-f who suggested names for my interpreter.
-
-
-------------------------
- AGT AND AGX GAME FILES
-------------------------
-  Games in the AGT format can be found at the Interactive Fiction archive:
-    ftp://ftp.ifarchive.org/if-archive/games/agt
-
-  AGT games are recognizable by having several different files with
-names like 'MYGAME.D$$', 'MYGAME.DA1', 'MYGAME.DA2', ... ,
-'MYGAME.DA6', 'MYGAME.TTL', etc. They also usually come with a DOS
-runtime interpreter (usually called RUN.EXE or MRUN.EXE), which can be
-deleted without affecting AGiliTy. (DOS users might want to keep it
-around 'just in case', depending on how much hard drive space is
-available)
-
-   AGiliTy also has its own file format (with extension "AGX", which
-stands for "Adventure Game eXecutable"); existing AGT games can be
-converted into this format using the utility agt2agx which comes with
-AGiliTy. They can also be created from AGT source code by using the
-Magx compiler, available in
-    ftp://ftp.ifarchive.org/if-archive/programming/agt/magx/
-
-  The new format takes all of the various AGT files (MYGAME.DA1,
-MYGAME.DA2, MYGAME.DA3, MYGAME.DA4, MYGAME.DA5, MYGAME.DA6, MYGAME.TTL,
-MYGAME.INS, MYGAME.VOC, MYGAME.D$$, MYGAME.OPT, and parts of
-MYGAME.CFG) and puts all of the data in one file (MYGAME.AGX).
-  Aside from the reduction in directory clutter, it has the
-following advantages:
- 1)It's smaller; for large games the new format can save over 100K
-    (The most extreme case I've run across so far is Shades of Gray:
-     790K vs. 568K uncompressed or 273K vs. 148K ZIPed)
- 2)It loads more quickly since it's closer in structure to AGiliTy's
-    internal format. (In particular, the interpreter doesn't need to
-    build the dictionary or convert metacommand opcodes into a common
-    format).
- 3)It's more portable. For example, there are platforms out there that
-    can't handle the 'D$$' extension.
-
-
-------------------------
- AGT VERSIONS SUPPORTED
-------------------------
-  AGiliTy understands the following versions of AGT (which includes
-every AGT game at ftp.ifarchive.org that I know of):
-  --1.0
-  --1.18
-  --the early "Classic AGT": e.g. 1.19, 1.2, 1.21
-  --"Classic AGT", both big and small: e.g. 1.3, 1.32, 1.35, 1.5, 1.7
-  --the "Even Bigger 1.32" used by _Cosmoserve_
-  --the "Chemically Altered 1.32" used by _Shades of Gray_,
-  --Menichelli's 1.82[untested] and 1.83
-  --Both known "proto-Master's Edition" 1.5 variants
-  --The proto-Master's Edition 1.6 variant used by Pork.
-  --Both Master's Edition 1.0 variants.
-  --The Master's Edition 1.5/1.51, 1.55, and 1.56/1.6/1.7.
-
-   _The Pyramids of Mars_ and _Cliff Diver_ require configuration
-options to be set; they use variant interpreters that are supported
-but can't be detected by the interpreter.
-  In particular, _Pyramids_ needs the ALT_ANY option and
-_Cliff Diver_ requires the IRUN option.
-
-   _Klaustrophobia_ is now supported. Use AGiliTy to play each of the
-chapters as usual. To switch between chapters, just SAVE at the end
-of one chapter and RESTORE at the beginning of the next (the
-game will tell you when to switch chapters; however, use SAVE instead
-of DONE1 or DONE2). This is still experimental and so I'd appreciate
-any feedback on how well it works (or doesn't work, as the case may
-be).
-  Unlike the MS-DOS programs that _Klaustrophobia_ originally used for
-this, AGiliTy doesn't check that you've actually reached the end of the
-previous chapter; be warned that if you switch chapters before the game
-tells you to, things may break.
-  There is also no way for AGiliTy to support the intermission or
-endgame text from the original game: these are all printed out
-by DOS programs rather than by the AGT interpreter.
-
-
------------------------------------------------------------
- DIFFERENCES BETWEEN AGILITY AND THE ORIGINAL INTERPRETERS
------------------------------------------------------------
- --Disambiguation is done on the normal command entry line rather than
-having a special prompt.
- --When asked "Which object do you mean?", it is possible to reply
-ANY, EITHER, BOTH, or ALL, as well as giving the name of an object.
- --LISTEXIT ON, LISTEXIT OFF will turn automatic listing of exits on or
-off (in AGT there is a LIST EXITS command, so some AGT games don't list
-exits to rooms).
- --OOPS, UNDO, and RESTART are supported (at least on systems with
-enough memory).
- --Adjective-only matches are accepted by the parser.
- --The parser is capable of intelligent disambiguation.
- --It is is also able to expand ALL and ALL EXCEPT (when appropriate
-options are set).
- --Some more multiple word verbs are automatically recognized (for
-example, GET IN is automatically translated into ENTER).
- --Some built-in verbs have additional synonyms. (In particular,
-standard one-letter abbreviations are supported: X for EXAMINE, Z for
-WAIT)
- --Game-specific synonyms are given a higher priority by the parser than
-the generic built-in synonyms.
- --The standard error messages are different than the original (except
-in Master's Edition games where most of the standard error messages
-are included in the game file)
- --SCRIPT output is sent to a file rather than to the printer.
- --AGiliTy has an extended AGILDEBUG debugging verb and supports more
-detailed metacommand tracing output.
- --AGiliTy uses a different save file format.
- --COLORS is not supported, although on some systems equivalent
-functionality is supported in the configuration file.
- --The special title screen effects of the Shades of Gray and Cosmoserve97
-interpreters aren't duplicated.
- --Graphics, sound, and fonts are not supported on all platforms.
-
-
------------------------
- LIST OF SPECIAL VERBS
------------------------
-These are all of the special verbs recognized by the interpreter:
-SCORE	Print out your score.
-NOTIFY	Turn score notification on and off
-INSTRUCTIONS or INS  Display the instructions for the game.
-INTRODUCTION or INTRO	Repeat the introduction of the game.
-VIEW   Views an illustration. (Not supported on all platforms.)
-BRIEF   Don't print room descriptions for rooms you've seen.
-VERBOSE Print room descriptions even  for rooms you've already seen.
-LIST EXITS List the exits from a room.
-LISTEXIT ON,OFF	 Turn on/off automatic listing of exits.
-SCRIPT	Start sending a transcript to a file.
-UNSCRIPT  Stop creating a transcript.
-SOUND ON, OFF  Turn sound on/off.
-LOG	Start sending all of your commands to a file.
-REPLAY   Replay your commands from a file, one every 
-	seconds.
-REPLAY FAST  Replay your commands from a file without waiting for you
-             to read the scrolling text.
-REPLAY STEP  Replay your commands from a file, one for every keypress.
-AGILDEBUG  Access debugging commands.
-MENU	Toggle menu mode on or off.
-OOPS	Correct a word you just mistyped; must be the first command on
-	a line.
-UNDO	Undo your last move; must be the first command on a line.
-SAVE	Save the game.
-RESTORE	Restore the game.
-RESTART	Restart the game.
-QUIT	Quit
-
-
----------------------
- CONFIGURATION FILES
----------------------
-  The interpreter gets configuration information from as many as three
-places: the global configuration file (containing things that you want
-to apply to every game you play), the game-specific configuration
-file (usually with an extension '.cfg'), and, in the case of AGX-format
-games, the game file itself.
-  Options in the game-specific file override options specified from
-the other two sources; options in the AGX file override those in the
-global file.
-
-  The following configuration options are supported on all platforms.
-Other options may be supported on your particular system; see
-appropriate platform-specific documentation for information.
-   Each option should be on a separate line in the configuration file.
-Lines starting with '#' will be treated as comments and ignored.
-Options can be negated by prefixing them with 'NO_' so that, for
-example, DEBUG would become NO_DEBUG.
-
-General options:
-  VERBOSE  Start the game in VERBOSE mode
-  DEBUG	Allow the use of AGILDEBUG for pre-Master's games (For
-	Master's Edition games, this decision is based on the DEBUG
-	flag in the game file itself)
-  DEFAULT_ERRORS  Cause AGiliTy to use its own internal defaults
-        for standard error messages even if the game file defines its own.
-	(Recommended for most Master's Edition games.)
-  PATH  Gives a space-separated search path for AGT games. [Not supported
-	on all platforms.]
-  TONE  Enables the *tone* action token, which allows games to make
-        annoying beeps on some platforms.  The only game I might recommend
-	enabling this for is  _CosmoServe_ which has some interesting
-	sound effects.  Not all platforms support this command.
-  INPUT_BOLD  Makes the input line bold. (This doesn't work on all platforms)
-  IBM_CHAR  Try to use the IBM character set; don't translate them.
-	If your platform doesn't support the IBM character set, this is
-	likely to produce garbage.
-  NO_ERROR  Supress GAME ERROR messages during play. Some poorly written
-        AGT games contain bad metacommands, out-of-range tokens, or other
-	problems; this option will supress the messages reporting these
-	sorts of problems.
-  SMART_DISAMBIG   This turns on smart disambiguation. This works better
-	with some games than others.
-  EXPAND_ALL  This turns on ALL and ALL EXCEPT expansion in the parser (by
-	default, expanding them is the responsibility of the individual
-	verb execution routines); see remarks on SMART_DISAMBIG: both of these
-	options use the same engine and so they are likely to work or fail
-	together. If you're using this, you'll probably also want to set
-	FIX_MULTINOUN.
-  IGNORE_SIZE Ignore weight and size limits on how much the player can
-        carry. (There remain limits on the size and weight of any
-        individual object.)
-
-Game specific options
-  (Many of these are more useful to game authors than game players.)
-  PROPER_CREATURE  Treat all creature names as proper nouns.
-     (In particular, this will cause them to be capitalized and to
-     not have "the" appear in front of them.)  Use of DEFAULT_ERRORS
-     is recommended with this option.
-  ROOMTITLE  Print the room title in bold before the room  description
-	in pre-Master's games. (Master's Edition games do this
-	automatically)
-  IRUN  Print error messages in first person. This should be set for
-	_Cliff Diver_.
-  NO_BLOCK_HOSTILE  Allow the player to leave a room containing a hostile
-	creature if they go back the way they came.
-  NO_GET_HOSTILE  Prevents the player from picking up objects in a room
-	containing a hostile creature. (Intended to be used with
-	NO_BLOCK_HOSTILE)
-  NO_OBJECT_NOTES  Turns off notes after object description,
-	such as '[providing light]'.
-  CONST_TIME  Increment time at a constant rate instead of randomly.
-  SLASH_BOLD  If set the slash character toggles bold on and off.
-	(This should be set automatically for 1.8x games, but you may still
-	 need to set it explicitly for version 1.82 )
-  PRONOUN_SUBS  Do $you$-style substitutions even in  game-author
-	defined messages.
-  ALT_ANY This scans the ANY metacommands *with* the 
-	metacommands rather than before them.  Should be set for
-	_Pyramids of Mars_ and not for any other games I know of.
-  CHECK_GRAMMAR  Print out error messages if the player enters a verb
-	with too many objects. (For example, "N KEY").
-  FORCE_LOAD  Force AGX game to load even if interpreter isn't of the
-        right version.  Don't use this unless you know what you're
-        doing: Magx doesn't assign minimum version numbers without
-        reason.
-  PURE_AFTER  Causes LOOK and other end-of-turn actions to take place
-      after AFTER commands. (This is on by default for Master's
-      Edition games.)
-  FIXED_FONT
-      Force system to use a fixed-pitch font.
-  NO_FIXED_FONT
-      Allow the system to use proportional fonts.
-
-Technical options: These are fine tuning.
-  FIX_METAVERB  Don't run ANY metacommands when executing a metaverb.
-  FIX_MULTINOUN	  Only advance one turn when manipulating multiple nouns,
-	rather than a turn for each noun.
-  PURE_ANSWER   Require AND-connected answers to be in the right order.
-	(The Master's Edition documentation claims order doesn't
-	matter, but with the actual interpreters it does)
-
-Parse Options: These are all pretty technical.
-  PURE_DUMMY   Allow dummy verbs to be run by typing "dummy_verb3"
-  PURE_SUBNAME Allow subroutines to be run by typing "subroutine3"
-  PURE_SYNONYM Treat synonyms exactly as nouns.
-  ADJ_NOUN     Don't pick noun matches over adjective-only matches.
-
--------------------
- DEBUGGING OPTIONS
--------------------
-  With AGILDEBUG you can access various debugging commands.  You can
-move objects around; change the values of flags, variables and
-counters; list objects in the game; examine and edit objects; and turn
-metacommand tracing on or off.
-
-  (Note: You can change almost all of the fields associated with
-an object using the View/Edit Object option; be warned that many of
-them are not SAVEd or RESTOREd since they can't be changed during
-normal play. If you change one of these and then RESTORE or UNDO, it
-will stay changed. Conversely, if you make a change, save, quit, and
-restore, the changed value will not be preserved. The fields having
-this behavior are marked.)
-
-  When metacommand tracing is on, every metacommand that is run will
-be displayed. You can turn off tracing of ANY metacommands and tracing
-of metacommands during disambiguation (the latter is off by default).
-
-  In addition, AGiliTy has a test mode which automatically reads a
-log file from .LOG (or equivalent) and writes a script to
-.SCR. In this mode, the random number generator is forced to
-be non-random, allowing for automated testing of games.
-  To use this, you create a LOG file (either by hand, by using the
-'-c' option, or by using LOG-- note that this log file needs to
-include everything from the very beginning, including the key hit at
-the end of the title screen, so if using the LOG command you'll need
-to add a line or two at the beginning.)
-  Run AGiliTy in test mode once to get the script. Copy the script
-to some other file.  Then, whenever you make a change to your game
-file, rerun AGiliTy and compare the new script with the old one.
-(There are programs that will do this automatically and just print
-out the lines that have changed.)
-
-
----------------
- AGT GAME LIST
----------------
-  Here is a list of a few of the better or more popular AGT games,
-along with their filename in ftp://ftp.ifarchive.org/if-archive/games/agt/;
-it is in no way exhaustive.
-   I've also included references to reviews in issues of SPAG and
-XYZZYnews; these can be found in if-archive/magazines/SPAG and
-if-archive/magazines/XYZZYnews respectively.
-
-
-Shades of Gray (soggy97.zip) by Mark Baker, Steve Bauman, Belisana
-    Magnificent, Mike Laskey, Judith Pintar, "Hercules", and Cindy Yans
-  Widely considered to be the best AGT game ever written. This is a
-  'real life' game that is concerned more with the protagonist's
-  ideals and mental state than with "adventuring".  You open the game
-  with amnesia and need to figure out who you are and recover your
-  memory. To say more would give too much away. It's a bit uneven (it
-  was written by a team of seven people) and it opens with an
-  arbitrary puzzle that's a potental show-stopper, but overall this is
-  an excellent game.
-    SPAG 2, 8; XYZZY 11(interview with one of the authors)
-
-
-Cosmoserve (cosmos97.zip)  Judith Pintar
-  Another strong AGT game. In it, you take the role of R.J. Wright,
-  free-lance programmer/plumber, who is trying to finish a program
-  that is due the next morning. You will need to log on to Cosmoserve
-  and interact with the other users in order to be able to do this.
-  It has a clever interface that really captures both the DOS
-  command-line and life online pre-GUI. This is, however, a game
-  you'll have to play through several times to win since it requires
-  tight timing to be in all of the right places at the right times.
-    SPAG 5; XYZZY 1, 11(interview with the author)
-
-
-The Jeweled Arena (tja.zip)  David S. Raley
-  This game is divided into four chapters; in each chapter you are
-  a different person (although the first and third chapters share the
-  same main character). Games like this often suffer from a lack of
-  unity; this game, however, holds together quite well.  In part, this
-  is because all of the chapters take place in a single, large,
-  setting: the city of Kumeran. You can visit locations multiple times, as
-  different characters. Locations that are unimportant in one chapter
-  may be of great importance in a later chapter. In general, the world
-  has a lot of depth, from diaries of the main characters to newspaper
-  articles to books on law. On the other hand, it could have used some
-  more beta-testing. There are several guess-the-verb puzzles and a quite
-  a few bugs; most of the bugs are just amusing, but at least one (in
-  chapter 3) can cause the game to become silently unwinnable for no
-  obvious reason if you do a certain action in the wrong place.
-
-
-Pastoral Pitfalls (pp20.zip) Guy Marquardt
-  In this game you are the pastor of a Lutheran church; you need to
-  make it through the day fufilling all of your responsibilities
-  (which include visiting the sick, teaching a confirmation class,
-  preparing a sermon, and still finding time to pray) I haven't
-  finished this game, but the parts I've seen I've liked.  The game
-  seems to have been well tested; it's mostly free of guess-the-verb
-  problems and bugs.   It feels very open; you have a lot of freedom
-  in what order to do things (although some care is needed so you don't
-  run out of time).
-    XYZZY 9(preview)
-
-
-The Multi-Dimensional Thief (mdthief1.zip)  Joel Finch
-    [Summary/review by Audrey De Lisle]
-  You are a thief desiring to become a member of the Thieves' Guild.
-  The test for this is to find the way out of the house.  This seems
-  rather easy, but it's not.  One feature is a visit to OZ; another
-  feat is done while quite small.  The amazing machine is fun to use
-  and you must learn how to use it to get in an otherwise closed room.
-  You can order things from a catalog and part of the game is to
-  figure out which items you need.  I would recommend this game to
-  those who like a little humor with their puzzles.
-  [There is also a non-AGT version of this game.]
-    SPAG 2, 4, 9
-
-    
-
- -
-
-AGiliTy, notes for the Glk version
-----------------------------------
-
-(General information can be found in readme.agility)
-
-
-Introduction
-------------
-
-This is a port of the AGiliTy interpreter to Glk.  The complete interface
-lives in the single file
-
-	os_glk.c
-
-The main test and development system for the port is Linux, with Xglk as the
-Glk library.
-
-Glk AGiliTy is configured to be as close as possible to the pure ANSI build.
-This is because Glk is a cross-platform I/O library, so using pure ANSI gives
-it the best chance of working on multiple Glk libraries.
-
-
-Acknowledgments
----------------
-
-Thanks to Robert Masenten, rcm-math@pacbell.net, for answering several queries
-about porting AGiliTy to Glk, and for writing AGiliTy in the first place; Ben
-Hines, bhines@alumni.ucsd.edu, for the Mac-specific portions of the Glk
-porting code; and Andrew Plotkin, , for Glk, and for
-putting me straight on a couple of the finer points of Glk operation.
-
-
-Running Games
--------------
-
-The interpreter understands both standard AGT game files and "AGX format"
-(AGiliTy file format) game files.  Standard AGT games are distributed as a
-collection of files, with different extensions (".d$$", ".da1", ".da2" and so
-on).  AGiliTy games use the extension ".agx".
-
-Give the name of the game to run at the system prompt.  For example, if the
-game is held in files "cosmos.d$$", "cosmos.da1", and so on, use
-
-	glkagil cosmos
-
-If several builds of Glk AGiliTy are available, linked with a selection of Glk
-libraries, they will be named appropriately, for example xagil, termagil, and
-cheapagil.
-
-The interpreter prefers that filename extensions be lower-case, that is,
-".da1", ".da2", ".agx", and so on, rather than ".DA1", ".DA2", and ".AGX".  If
-you are unpacking AGT files from ZIP archives, you may need to use unzip's '-L'
-option to make sure that filename are extracted correctly.
-
-Having said that, there's a minor GLK-specific patch in the core AGiliTy
-interpreter (filename.c, for what it's worth) that retries a file with an
-uppercase extension if the expected lowercase name is not found.  That should
-help with archives unpacked without the '-L' option.  Running a game then
-becomes
-
-	glkagil COSMOS
-
-Glk AGiliTy takes a small liberty with the C runtime on exit.  It might cause
-some problems, such as a core dump or abort, when the program exits on an
-error condition.  If you find that this happens on your system, you can either
-rebuild to avoid this, as described below, or set a value for the environment
-variable GLKAGIL_CLEAN_EXIT.
-
-As well as standard AGiliTy command line options, there are a number of Glk
-Agility specific command line options that you can specify, to vary the way
-that the game looks:
-
-	-gf	Force Glk to use only a fixed width font
-	-gp	Allow Glk to use only a proportional font
-	-ga	Try to use a suitable Glk font automatically
-	-gd	Delay for the full period in Glk
-	-gh	Delay for approximately half the period in Glk
-	-gn	Turn off all game delays in Glk
-	-gr	Turn off Glk text replacement
-	-gx	Turn off Glk abbreviation expansions
-	-gs	Display a short status window in Glk
-	-gl	Display an extended status window in Glk
-	-gc	Turn off Glk command escapes in games
-	-gD	Turn on Glk port module debug tracing
-	-g#	Test for clean exit (Glk module debugging only)
-
-See below for further information about what these options mean.
-
-
-Compiling
----------
-
-To compile Glk AGiliTy for Linux, first unpack the source files.  You might
-need to use the -a argument to unzip in order to convert text files for your
-system.
-
-Edit Makefile.glk so that it has the right path to the Glk library you wish to
-build with.  If you want to build the IFP plugin, also edit the parts of
-Makefile.glk that have paths to IFP components.
-
-To build a standalone version of Glk AGiliTy, use
-
-	make -f Makefile.glk glkagil
-
-To build the IFP plugin, use
-
-	make -f Makefile.glk agility-1.1.1.so
-
-To clean up and delete everything in the case of a build error, use
-
-	make -f Makefile.glk clean
-
-Glk AGiliTy contains a few non-ANSI/ISO artifacts that might cause problems on
-non-Linux systems:
-
-	Fdopen(), dup(), and file descriptors, used to open save and restore
-	files, are not portable.  You can turn off these features by defining
-	GLK_ANSI_ONLY in Makefile.glk.
-
-	At times the module may indirectly call exit() from within an
-	atexit() handler.  This is "undefined" in ANSI.  The Linux and SVR4
-	C runtime libraries behave well, but if you find it causes problems
-	(for example, an occasional core dump or abort on exit) you can turn
-	it off by defining GLK_CLEAN_EXIT in Makefile.glk.
-
-See the comments in the source for Glk AGiliTy for more information on these,
-and the information on "-g#" later on in this readme file for details on how
-to check for problems with exit() and atexit().
-
-For building on the Mac platform, Ben Hines has supplied a set of Code-Warrior
-and application specific settings in a resource file, for use with the Mac Glk
-library.  You should find this file in the source distribution under the name
-
-	os_glk_MacResFile.hqx
-
-The source of Glk AGiliTy has changed somewhat since Ben created this resource
-file, so it may, or may not, currently be fully functional.
-
-
-Configuration
--------------
-
-Glk AGiliTy opens no global configuration file, and takes no special
-configuration options.
-
-If you need to set options that can't be set with AGiliTy command-line flags,
-you'll need to create a special file called .cfg alongside the other AGT
-game files, or edit any existing .cfg.  Glk AGiliTy will find this file.
-
-
-Status Lines
-------------
-
-Glk AGiliTy displays a status window at the top of its display, providing the
-Glk library it is using supports separate windows.  The status window can show
-either one or two lines, for normal or extended status.
-
-The first line of status is the standard information printed by the core
-interpreter or the game, normally the location, and the game score and/or time.
-The second line shows a list of exits available, and if in a game delay, a
-waiting indicator.
-
-You can use the "-gs" option to select a short status display, and "-gl" to
-select an extended status display.
-
-Where the Glk library does not support separate windows, Glk AGiliTy will
-print the status line in "[...]" brackets at the beginning of any game output,
-but only when it has changed since the last game turn.  It will also only
-print the short status display; to get a list of exits, use the AGiliTy
-"listexits" command.
-
-
-Expanding Abbreviations
------------------------
-
-Many IF games systems allow a player to use single character abbreviations for
-selected common commands, for example, 'x' for 'examine', 'l' for look, and so
-on.
-
-AGiliTy expands many of these in the same way, but it's not completely
-consistent with other well-known systems.  To try to help with this, Glk
-AGiliTy will automatically expand a selection of single character commands,
-before passing the expanded string to the game as input.  It expands a command
-only if the first word of the command is a single letter, and one of the
-following:
-
-	'c' -> "close"		'g' -> "again"		'i' -> "inventory"
-	'k' -> "attack"		'l' -> "look"		'p' -> "open"
-	'q' -> "quit"		'r' -> "drop"		't' -> "take"
-	'x' -> "examine" 	'y' -> "yes"		'z' -> "wait"
-
-If you want to suppress abbreviation expansion, you can prefix your input with
-a single quote character (like putting literal strings into a spreadsheet).
-If you do this, the Glk interface will strip the quote, then pass the rest of
-the string to the main interpreter without any more changes.  So for example,
-
-	'x something
-
-will pass the string "x something" back to the game, whereas
-
-	x something
-
-will pass "examine something" back to the game.
-
-You can turn off abbreviation expansions with the command line option '-gx'.
-
-
-Game Text Output
-----------------
-
-AGT games generally presume they are running on fixed width font, 80x25 IBM PC
-displays.  They expect to have this screen width on many occasions, and use
-spaces, IBM box-drawing and other code page 437 characters, and other DOS
-'tricks' to achieve certain effects with output text, creating line breaks as
-needed.
-
-In comparison, Glk's basic text model is that the output library should take
-care of text formatting.  It behaves best when using a proportional font, and
-sticks rigidly to ISO-8859 Latin 1 character encoding which, while it has
-international characters in it, does not have box drawing characters.
-
-This leads to somewhat of a mismatch of requirements and capabilities for the
-Glk version of AGiliTy.  While Glk will work with fixed width fonts, it does
-not necessarily offer any form of attributes or color for such fonts, making
-the output appear one-dimensional and lifeless.  On the other hand, the
-assumption in games and the interpreter is that the font is fixed width, and
-the screen is 80 columns wide.
-
-To attempt to smooth over this, Glk AGiliTy will try to guess whether a chunk
-of game output text needs to be displayed in a fixed width font, or if it will
-look okay when rendered in a proportional one.  This is akin to a form of
-"screen scrape": Glk AGiliTy buffers all of the text that the game outputs,
-then runs over it with a set of functions that try to re-paragraph the text,
-identify any tables or other areas that are likely to be sensitive to font
-width, and finally print it out through Glk in what is hopefully an improved
-format.
-
-Doing this involves some guesswork on the part of Glk AGiliTy, but in testing,
-it seems to work well enough.
-
-You can use the "-ga" option to let Glk AGiliTy automatically select what
-appears to be a suitable font for output, "-gf" to force it to always use a
-fixed width font, or "-gp" to force it to always use a proportional font (if
-the Glk library has one).  You can also control it while in a game using the
-"glk fonts" command.
-
-Note that some games _do_ hint at the type of font they can be used with,
-though most don't.  A game may tell the interpreter
-
-	1) that a fixed width font is required, or
-	2) that a proportional font is acceptable, or
-	3) nothing
-
-In the third case, the interpreter does not know whether a proportional font
-can be used, or not.  The majority of AGT games seem to fall into the third
-case, and the interpreter rarely knows the font requirements of a game.
-
-Any game which does tell the interpreter what font it can use will cause Glk
-AGiliTy to use that font style on startup, and ignore any value set with the
-"-g" command line option.  You may still however alter the font control with
-"glk fonts" while in a game.
-
-In Glk libraries that have only fixed width fonts (for example, Glkterm, for
-ncurses), you will see much less difference in the display with the different
-values for font control, but it may still be useful if the text mode display
-differs widely from AGT's anticipated 80x25 dimension.
-
-Since many games rely on there being 80 columns of display width, Glk AGiliTy
-also offers a command to query the current display width.  The command to use
-is
-
-	glk width
-
-entered at the game's ">" prompt.  This prints the approximate width of the
-display window (actually, it prints the width of the status window, but
-assuming the fonts in use in each window are approximately the same, the result
-will usually be close enough).  Some Glk libraries are not able to return a
-window width.
-
-In general, where a game has a strong requirement for fixed width font text,
-80 columns or more of display width will probably be fine.
-
-
-Message Replacements
---------------------
-
-Because Glk AGiliTy buffers all game output, and scans the buffer for ways to
-try to improve text formatting, it can also replace some of the standard
-AGiliTy interpreter messages with ones that stand out a little better in a Glk
-display.
-
-For example, games usually start up with a message something like:
-
-                   This game is being executed by
- AGiliTy: The (Mostly) Universal AGT Interpreter  version 1.1.1
-           Copyright (C) 1996-99,2001 by Robert Masenten
-                           Glk version
-
-Glk AGiliTy will replace this with more or less the same text, but using
-heading and emphasized text.  It handles only a few messages in this way,
-typically LISTEXIT, VERBOSE, and BRIEF responses, game title pages, and the
-AGiliTy information page header.
-
-To turn this feature off, use the '-gr' command line option.
-
-
-Game Delays
------------
-
-In AGT games that use delays, these delays can become tiresome.  By default,
-Glk AGiliTy will delay for approximately half the time that the game specifies.
-
-You can vary this behavior with command line options: use "-gd" to make all
-delays full length; "-gh" to make all delays short, approximately half length;
-and "-gn" to turn off delays altogether.  You can also change the delay mode
-with "glk delays" while in a game.
-
-When the game is delaying, Glk AGiliTy displays a "Waiting..." indicator on
-the right hand side of the second line of any status window.
-
-You can cancel a game delay by pressing the space bar while the "Waiting..."
-indicator is active.  This will stop the delay immediately, and also suppress
-any further delays the game requests until it issues the next input line
-prompt or requests other keyboard input.
-
-A few games might not play correctly with delays turned off, so you should
-take a little care with this option.  For example, a game could clear the
-screen, print a message, delay for a short time, clear the screen again, and
-continue.  With delays turned off, Glk AGiliTy will not get the chance to
-display the message.
-
-Glk AGiliTy will not implement game delays if the Glk library does not support
-timers.
-
-
-Interpreting Commands Locally
------------------------------
-
-Glk AGiliTy will handle special commands if they are prefixed with the string
-'glk'.  It understands the following special commands:
-
-	help			Prints help on Glk special commands
-	summary			Prints all current Glk settings
-	version			Prints the Glk library and Glk port version
-				numbers
-	license			Prints the Glk port license
-
-	script on		Starts recording the game text output sent
-				to the main game window
-	script off		Turns off game text recording
-	inputlog on		Starts recording input lines typed by the
-				player
-	inputlog off		Stops recording input lines
-	readlog on		Reads an input log file as if it had been
-				typed by a player; reading stops automatic-
-				ally at the end of the file
-	abbreviations on	Turn abbreviation expansion on
-	abbreviations off	Turn abbreviation expansion off
-	glk fonts auto, or
-	glk fonts automatic	Let Glk AGiliTy determine the appropriate
-				font for a paragraph automatically
-	glk fonts fixed		Print all output in a fixed width font
-	glk fonts variable, or
-	glk fonts proportional	Print all output in a proportional font
-	width			Print the approximate display width; AGT
-				games may expect at least 80 characters
-	statusline extended	Show a two line, extended status display
-	statusline short	Show a single line, short status display
-	replacements on		Replace selected interpreter paragraphs with
-				improved formatted alternatives
-	replacements off	Don't replace selected interpreter paragraphs
-	delays full [or on]	Make all delays full length
-	delays short [or half]	Make all delays approximately half length
-	delays none [or off]	Turns off delays altogether
-	commands off		Turn of Glk special commands; once off, there
-				is no way to turn them back on
-
-You can abbreviate these commands, as long as the abbreviation you use is
-unambiguous.
-
-If for some reason you need to pass the string "glk" to the interpreter, you
-can, as with abbreviations above, prefix it with a single quote character.
-
-You can turn off local command handling with the command line option '-gc'.
-
-If both abbreviation expansion and local command handling are turned off, there
-is no need to use single quotes to suppress special interpreter features.
-
-
-Transcripts and Input Logs
---------------------------
-
-AGiliTy games can themselves set up transcripts and input logs.  However, the
-meta-verbs to set them up can occasionally conflict with commands in the game.
-It may therefore be more convenient to use Glk commands to create these logs.
-
-Any Glk AGiliTy transcript or input log is in addition to those that may be
-set up by the main AGiliTy interpreter, so although not wildly useful, it's
-possible to create two transcripts and input logs at the same time.
-
-
-Glk AGiliTy Debug Options
--------------------------
-
-The command line option "-gD" turns on debugging in the AGiliTy Glk I/O module.
-The output is really only useful when debugging Glk AGiliTy.
-
-The command line option "-g#" tests for clean program exit.  Glk AGiliTy takes
-a couple of liberties with the ANSI rules for exit handler functions.  For
-most systems, these don't cause any problems, but for some they might.
-
-To test to see if your system is affected, run Glk AGiliTy with "-g#".  The
-program will exit straight away, and if it exits cleanly (no core dumps or
-other ugly program termination), everything is fine.  Otherwise, you should
-either recompile with GLK_CLEAN_EXIT defined, or set environment variable
-GLKAGIL_CLEAN_EXIT to "true".
-
-
---
-
-Simon Baldwin, simon_baldwin@yahoo.com
-
-
- -
-
-This software is copyright 1996-1999,2001 by Robert Masenten.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of version 2 of the GNU General Public License,
-as published by the Free Software Foundation.
-
-  This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-  You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-
-
- -

ALAN 2.8.7 and ALAN 3.0beta5

-

Website

- -
-
-
-                Welcome to the
-            ALAN ADVENTURE LANGUAGE
-                  3.0beta5
-                 2015-06-23
-
-
-THE NEWS IN SHORT:
-
-Alan is a tool to create text adventure games, interactive fiction,
-text-based simulations for teaching or other similar types of
-interactive software.
-
-This is the third beta version (v3.0beta5) of Alan V3. Alan v3
-features many new enhancements especially object orientation.
-
-This package contains at least the compiler and the interpreter. It
-might also, depending on the distribution package, include the manual,
-the source for the Saviour game, a converter program which takes an
-Alan v2 source file and outputs a V3 version of the same source, the
-source and binary for a sample game. Read the particulars in the
-readme for your platform. If it does not you can find most of that at
-the Alan webspace:
-
-      http://www.alanif.se
-
-The changes between versions is described in the file CHANGES, which
-should also be included.
-
-
-
-THE LONG STORY:
-
-The Alan System is one of the most easy-to-use tools to create
-interactive fiction, aka. adventure games. The Alan System is based on
-a special purpose computer language designed to be easy to use for
-people more interested in authoring and designing games. The system
-consists of a compiler, which compiles Alan source to a compact and
-portable form, and an interpreter that interprets such a form to allow
-playing of the game.
-
-The Alan System is register-ware. To use Alan for authoring and
-distributing your games all you need to do is to register. Registration
-can be done with a simple email to thomas@alanif.se.
-
-Alan V3 has been evolving for a number of years and is now feature
-complete. It is stable enough to use for production type work, but
-will be released as a non-beta when enough beta test experience show
-that it is mature enough. You can help! Report any problem and
-suggestions. You can visit
-
-	http://wwww.alanif.se
-
-to find out more about Alan V3.
-
-You can also find the legacy v2.8 version there. It should now be
-considered completely obsolete and you should only look at it if are
-looking to run some old game. Otherwise you should *really* look at
-V3. Alan may also be found at
-
-	http://www.ifarchive.org
-
-and its mirrors.
-
-For complete copying conditions refer to the file COPYING in the
-distribution or the corresponding appendix in the manual.
-
-If you have any problems don't hesitate to contact the author at the
-following email address:
-
-	thomas@alanif.se
-
-Or join the Alan mailing list, which you can find at the Alan Home
-Pages
-
-	http://www.alanif.se
-
-All communication is welcome! Happy Authoring!
-
-Thomas Nilefalk
-thomas@alanif.se
-
-
- -
-
-The Alan System is distributed under the Artistic License 2.0 for which the full text
-follows. The intent of this licensing is that the Copyright Holder retain some
-control over the development of the Alan System, while still keeping it available as open
-source and free software.
-
-In practical terms this means that the licensing is choosen so that it should be possible to
-- freely distribute games produced with the Alan system, including for profit
-- re-distribute compiled versions of the Alan system, including together with a game which is
-  not open source or free, provided there is no charge for the Alan system
-- redistribute compiled and/or source versions of the original Alan system (the Standard Version)
-- aquire the source code for the Standard Version
-- modify the source code for private use
-- re-distribute compiled and/or source of a Modified Version provided they are done so under a
-  compatible license with appropriate attribution *and* that the modification is discribed and
-  made available, preferably by returning it to the Copyright Holder so that it can be merged
-  into the Standard Version
-
-
- -

BABEL 0.2B

-

Website

- -
-
-Version 0.2b, Treaty of Babel Revision 7
-This is the source code for babel, the Treaty of Babel analysis tool.
-
-Most of this code is (c) 2006 by L. Ross Raszewski
-
-The following files are public domain:
-zcode.c
-glulx.c
-executable.c
-level9.c
-magscrolls.c
-agt.c
-hugo.c
-advsys.c
-misc.c
-alan.c
-adrift.c
-treaty.h
-treaty_builder.h
-
-The following files are Copyright (C) 1999, 2000, 2002 Aladdin Enterprises:
-md5.c
-md5.h
-
-And are used in accordance with their licenses.
-
-All other files are (c) 2006 by L. Ross Raszewski and are released under
-the Creative Commons Attribution 2.5 License.
-
-To view a copy of this license, visit
-http://creativecommons.org/licenses/by/2.5/ or send a letter to
-
-Creative Commons,
-543 Howard Street, 5th Floor,
-San Francisco, California, 94105, USA.
-
-
- -

BEBEK 0.1

- -
-
-Bebek is a Java port of Campbell Wild's ADRIFT 5 Runner.
-
-Many thanks to Campbell for releasing the source code
-of the Runner into the public domain in early 2018; it has
-been my pleasure to port it to Java and I hope that Fabularium
-users will enjoy playing their ADRIFT 5 games on Android devices.
-
-Bebek is still in beta. While it should be fairly stable now, I
-have not made any serious attempts to optimise the code yet, so
-expect it to run significantly slower than SCARE.
-
-Bug reports welcome: email tcowperapps@gmail.com.
-
-                 -- Tim Cadogan-Cowper, 2018
-
-
- -
-
-Copyright 2018 Tim Cadogan-Cowper.
-
-Bebek is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License, version
-2 or 3, as published by the Free Software Foundation.
-
-Bebek is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-
- -

BOCFEL 1.0

-

Website

- -
-
-BOCFEL(6)		       BSD Games Manual 		     BOCFEL(6)
-
-NAME
-     bocfel — Z-machine interpreter ⟨http://bocfel.org/⟩
-
-SYNOPSIS
-     bocfel [-cCdDefgGhkmprstUxXyY] [-a eval_stack_size] [-A call_stack_size]
-	    [-E escape_string] [-l username] [-n number] [-N version]
-	    [-R replay_filename] [-S record_filename] [-T transcript_filename]
-	    [-u slots] [-z seed] [-Z device] file
-     bocfel -i file
-     bocfel -v
-
-DESCRIPTION
-     bocfel is a Z-machine interpreter.  It fully supports versions 1-5, 7,
-     and 8 of the Z-machine, with extremely limited support for version 6.  It
-     can read stories stored in Blorb files, but has no support for associated
-     graphics, if any exist.
-
-     The following options are available:
-
-     -a eval_stack_size
-	     The Z-machine contains an evaluation stack which games use as a
-	     sort of scratch space when performing calculations.  By default
-	     the size of this stack is set at 16384, which should be suffi‐
-	     cient for any game.  The entire stack is allocated at once, so if
-	     you are on a system with a small amount of memory, setting this
-	     to a smaller value will cause less memory to be allocated.
-
-	     The maximum value is limited only by system memory.  Each evalua‐
-	     tion stack entry takes two bytes.	If you ever encounter a “stack
-	     overflow” message with the default size, please let me know.
-
-     -A call_stack_size
-	     The Z-machine allows games to call routines in order to get work
-	     done; these routines can call other routines, and so on.  Infor‐
-	     mation about these routines is placed onto the call stack, which
-	     by default has a size of 1024.  This means that no more than 1024
-	     routines can be active at any single time.  This value should be
-	     much more than sufficient for any game.  As with the evaluation
-	     stack, memory for the call stack is allocated at one time, so
-	     machines with small amounts of memory can reduce this value to
-	     reduce memory consumption.
-
-	     The maximum value allowable by the Z-machine is 65535.  Each call
-	     stack entry takes between 40 and 50 bytes.
-
-     -c      If the Glk implementation being used is Gargoyle, or if Glk is
-	     not being used at all, support for colors is provided.  This
-	     option disables color support entirely.
-
-     -C      Do not read the configuration file $HOME/.bocfelrc.  Settings in
-	     the configuration file take precedence over those specified on
-	     the command line, so if you want to override the configuration
-	     file, use this option.
-
-     -d      Many Glk implementations allow timed input as used by games such
-	     as Border Zone.  This option disables timed input and informs
-	     games that timed input is not available.
-
-     -D      If Gargoyle is being used, sound effects are supported.  This
-	     option disables sound effects and informs games that sound
-	     effects are not available.
-
-     -e      Turn on ANSI escapes in the transcript. If this option is
-	     enabled, all user input in the transcript can be decorated with
-	     ANSI escape sequences so it stands out.  See the -E option.
-
-     -E escape_string
-	     If the -e option is used, this sets the escape string that will
-	     be used when highlighting user input in the transcript.  ^[[ is
-	     written, then escape_string, then ^[[0m.  By default “1m” is used
-	     as the escape string, providing bold text.
-
-     -f      Many Glk implementations allow a fixed-width font to be selected.
-	     This option disables fixed-width fonts and informs games that
-	     fixed-width fonts are not available. The game might still be dis‐
-	     played using a fixed-width font (e.g. if you are playing in a
-	     terminal), but the game has no way of knowing this.
-
-     -F      Glk does not allow the mixing of text styles, so it is not possi‐
-	     ble to request, for example, both fixed-width and reverse video.
-	     If both styles are requested, fixed-width takes precedence.  How‐
-	     ever, if bocfel is being run in a terminal (with, for example,
-	     the glktermw Glk implementation), the font will be fixed at all
-	     times.  The -F flag tells bocfel to assume that the current font
-	     is always fixed, allowing other styles to be applied simultane‐
-	     ously.  See the puzzle pieces in Graham Nelson's Jigsaw for an
-	     example of how this can be useful.
-
-	     See also the STYLES section.  Note that Gargoyle does allow the
-	     mixing of styles, so this option does nothing under Gargoyle.
-
-     -g      Disable the character graphics font. See the CHARACTER GRAPHICS
-	     FONT section below.
-
-     -G      Select an alternative style of box drawing characters.
-
-	     Most characters in the graphics font map fairly well to Unicode
-	     equivalents, but a few box drawing characters do not.  Two meth‐
-	     ods for drawing the missing characters are provided, each with
-	     pros and cons.  A description of the differences is not suffi‐
-	     cient, so it is recommended that you try Beyond Zork both with
-	     and without this option, paying attention to the map connections.
-	     See also the CHARACTER GRAPHICS FONT section below.
-
-     -h      Display a short help message then exit.
-
-     -i      Print out the ID of the specified game and exit. This ID is used
-	     to uniquely identify a game and is adapted from the Treaty of
-	     Babel standard.  Game IDs can be used in the configuration file
-	     to set options for specific games. See the CONFIGURATION FILE
-	     section for more information.
-
-     -k      The Z-machine has a concept of “terminating keys”.  When enabled,
-	     these keys, in addition to Enter, terminate input immedately.
-	     Beyond Zork, for example, uses this so that F1 automatically exe‐
-	     cutes “look around”, F2 does “inventory”, and so on.  However,
-	     Beyond Zork also claims the up arrow, which means that history
-	     browsing, in Glk implementations that support it, might not be
-	     able to be initiated with the up arrow.  This option disables the
-	     use of terminating keys.  Note that not all Glk implementations
-	     support terminating keys.
-
-     -l username
-	     Set the username by writing up to 8 bytes to the location 0x38 in
-	     the story file. This is not officially part of the Z-machine, but
-	     is at least used by Hollywood Hijinx, where a username starting
-	     with either “DA” or “TOMAS” enables the debugging command “flush
-	     33” which moves you to a junction room which leads to various
-	     other locations, allowing puzzles to be bypassed.
-
-     -m      Disable meta commands.  See META COMMANDS below for more informa‐
-	     tion.
-
-     -n number
-	     Z-machine interpreters are able to inform games what platform
-	     they are running on by setting an interpreter number in the range
-	     1 to 11.  The following are the valid values (taken from Graham
-	     Nelson's Z-Machine Standards Document 1.0):
-
-		   1.	DECSystem-20
-		   2.	Apple IIe
-		   3.	Macintosh
-		   4.	Amiga
-		   5.	Atari ST
-		   6.	IBM PC
-		   7.	Commodore 128
-		   8.	Commodore 64
-		   9.	Apple IIc
-		   10.	Apple IIgs
-		   11.	Tandy Color
-
-	     By and large this value is meaningless.  Some Infocom games do
-	     make small use of this information: Trinity, for example, has a
-	     “print emphasized” routine that is used to print emphasized
-	     (which generally means italicized) text; on any machine but the
-	     Atari, however, this routine makes sure not to print punctuation
-	     in italics.  Beyond Zork makes what is probably the most visible
-	     use of the interpreter number, using it to decide how to deal
-	     with character graphics. See section 16 of the Z-Machine
-	     Standards Document 1.0 for more information.  By default, the
-	     interpreter version is set to 1 becuase this causes Beyond Zork
-	     to prompt the user about the machine he is using, allowing him to
-	     select whether or not character graphics are used.
-
-	     I do not recommend setting this to 11.  At least Beyond Zork
-	     assumes that the largest it will be is 10, and setting it to 11
-	     can cause an out-of-bounds memory access. The instance I have
-	     seen of this is not fatal, but there may be other instances that
-	     are.
-
-     -N version
-	     Even more meaningless than the interpreter number is the inter‐
-	     preter version. This, as far as has been determined, is never
-	     used except when the user asks a game to either report its ver‐
-	     sion or to verify its disk image. In these cases, the version is
-	     simply printed out, nothing more.	This is a single character and
-	     there is no real reason to change it. The default is C.
-
-     -p      bocfel includes patches to work around some known bugs in games.
-	     This flag disables such patches.
-
-     -r      Play back a command record (see -s) as soon as the game begins.
-	     Some games provide a way to play back a record (typically through
-	     the REPLAY verb in Inform-based games, and #comm in some Infocom
-	     games), but this option is useful to start playback before you
-	     have an opportunity to call REPLAY, or if the game provides no
-	     way to play back such a record.
-
-	     Command records must be UTF-8.
-
-	     See also the META COMMANDS section.
-
-     -R replay_filename
-	     When command-record playback is enabled, you will be prompted for
-	     a filename. This prompt can be bypassed by providing a filename
-	     here.
-
-     -s      Turn on command recording. This records every keystroke the
-	     player makes, and (hopefully) creates a record that is suitable
-	     for playback either by using -r or through a game command.  Some
-	     games provide this functionality themselves (typically through
-	     the RECORDING verb in Inform-based games, and #reco in some Info‐
-	     com games), but this option is useful to start recording before
-	     you have an opportunity to call RECORDING, or if the game pro‐
-	     vides no way to start such a record.
-
-	     Command records are always written in UTF-8.
-
-	     See also the META COMMANDS section.
-
-     -S record_filename
-	     When command recording is enabled, you will be prompted for a
-	     filename.	This prompt can be bypassed by providing a filename
-	     here.
-
-     -t      Turn on transcripting. This records both the output of the game
-	     and user input. If the chosen transcript file exists, it will be
-	     appended to, not overwritten. This way you can easily continue a
-	     transcript every time you come back to a game.
-
-	     Transcripts are always written in UTF-8.
-
-	     See also the -y option and the META COMMANDS section.
-
-     -T transcript_filename
-	     When transcripting is enabled, you will be prompted for a file‐
-	     name. This prompt can be bypassed by providing a filename here.
-
-     -u slots
-	     Some games provide the ability to undo a turn. In fact, some
-	     games allow multiple turns to be undone. This option controls how
-	     many save slots are available. Unlike the stacks (see -a and -A),
-	     save slots are dynamic, meaning that unless a game provides sup‐
-	     port for undo, no memory will be used.  However, games that do
-	     support undo will typically take a snapshot each turn, causing
-	     memory to be allocated.  The size of each snapshot depends on the
-	     game and the current state of play. Memory usage is minimized as
-	     much as possible: at the beginning of Anchorhead, for example,
-	     each slot takes up roughly 900 bytes.  As the game progresses,
-	     though, the size of a save slot inevitably will increase: near
-	     the end of Anchorhead, my save slots were taking up roughly 4500
-	     bytes.
-
-	     Note that Inform-based games (at least by default) do not support
-	     multiple undo; two non-V6 Infocom games, to my knowledge, do:
-	     Sherlock and Beyond Zork.	However, bocfel includes the ability
-	     to perform multiple undo regardless of whether the game provides
-	     support for it.  See the META COMMANDS section for more informa‐
-	     tion.
-
-	     The default value is 100. A value of zero disables undo, and a
-	     negative value provides unlimited undo. This is probably a bad
-	     idea.
-
-     -U      One of the ways that undo slots (see -u) save memory is to use
-	     compression. On modern machines the compression time is minuscule
-	     and not noticeable. On slower systems, however, it is possible
-	     that the compression will be noticeable. This option disables
-	     compression, but be aware that without compression, the size
-	     really balloons: save slots in Anchorhead, with compression, take
-	     up about 900 bytes on game startup.  Without compression they
-	     take up over 40000 bytes.
-
-     -v      Display version information and show which compile-time options
-	     are set.
-
-     -x      Many games include abbreviations for commonly-used commands: x
-	     for EXAMINE, g for AGAIN, z for WAIT, and o for OOPS. Some early
-	     Infocom games, however, do not provide these.  For these Infocom
-	     games, x, g, z, and o are mapped to their respective commands,
-	     providing convenient shortcuts for games that don't provide them.
-	     If a game requires one of these letters for its own use, these
-	     abbreviations can be turned off with -x.
-
-     -X      The Tandy corporation licensed some Infocom games, but apparently
-	     The Witness was too scary for them, so some words were changed so
-	     as not to offend their ridiculously delicate sensibilities. If
-	     you want to laugh at Tandy's insecurities, this flag will turn on
-	     their censorship. In addition to the mangling of The Witness, a
-	     few other games unnecessarily add mention of Tandy in the output
-	     of the VERSION command.
-
-     -y      When transcripting is turned on and an existing file is selected,
-	     that file is appended to rather than overwritten. This option
-	     causes the file to be overwritten.
-
-     -Y      In almost all games, either the game's UNDO command or the /undo
-	     meta command will work.  However, if you encounter a game where
-	     undo appears broken, try using this option.  It will instruct
-	     bocfel to ignore the game's undo code, instead using only its own
-	     undo handling.  This might work if the game's undo handling is
-	     subpar, either by design or by accident.  Note that if this
-	     option is active, /undo must be used instead of the game's UNDO
-	     command.
-
-     -z seed
-	     Provide a seed to the pseudo-random number generator, causing it
-	     to yield predictable values. This option is probably only of use
-	     to game authors who are doing testing.
-
-     -Z device
-	     Provide a device from which a seed for the pseudo-random number
-	     generator is read.  This is meant to be used with special files
-	     such as /dev/urandom, although it can be used with any file from
-	     which at least 32 bits can be read.  The -z option overrides this
-	     option.
-
-CONFIGURATION FILE
-     bocfel allows to you control its behavior through a configuration file.
-     This obviates the need to provide command-line arguments each time you
-     start a game, as well as allowing customization based on which game is
-     being played.
-
-     The configuration file is located in $HOME/.bocfelrc, and a general out‐
-     line is as follows:
-
-	   enable_escape = 1
-	   disable_color = 1
-
-	   [1-990831-d8b4]
-	   disable_color = 0
-
-	   [57-871221]
-	   int_number = 1
-
-     The first lines are general, and apply to all games.  The bracketed lines
-     start a new group based on the ID contained in the brackets (see the -i
-     option).  Thus disable_color is set to zero only for 1-990831-d8b4, and
-     int_number is set to 1 only for 57-871221.  Comments begin with a # and
-     continue to the end of the line. Trailing whitespace is ignored.
-
-     The following are all the possible options, which are hopefully
-     self-explanatory:
-
-	   eval_stack_size (n)
-	   call_stack_size (n)
-	   disable_color (b)
-	   disable_timed (b)
-	   enable_escape (b)
-	   escape_string (s)
-	   disable_fixed (b)
-	   assume_fixed (b)
-	   disable_graphics_font (b)
-	   enable_alt_graphics (b)
-	   disable_term_keys (b)
-	   username (s)
-	   disable_meta_commands (b)
-	   max_saves (n)
-	   disable_undo_compression (b)
-	   int_number (n)
-	   int_version (c)
-	   disable_patches (b)
-	   replay_on (b)
-	   replay_name (s)
-	   record_on (b)
-	   record_name (s)
-	   transcript_on (b)
-	   transcript_name (s)
-	   disable_abbreviations (b)
-	   enable_censorship (b)
-	   overwrite_transcript (b)
-	   override_undo (b)
-	   random_seed (n)
-	   random_device (s)
-
-     The parenthesized character describes the type of argument: b is a bool‐
-     ean (1 is true, 0 is false), c is a character, n is a number, and s is a
-     string.  These all correspond to possible command-line arguments.
-
-     In addition to analogs to the command-line arguments, there are a couple
-     of other options that can be set through the configuration file.  One is
-     “cheat”: see the CHEATING section below.  The other is fine-grained con‐
-     trol over colors in Gargoyle; this does not apply to any other build
-     types.
-
-     At the most basic, there are 8 colors that the Z-machine can use, corre‐
-     sponding to ANSI colors: black, red, green, yellow, blue, magenta, cyan,
-     and white.  The syntax for setting these is:
-
-	   color_red = 0xc23621
-
-     The color is specified as a 24-bit RGB value, 8 bits per color.  The
-     above is thus 0xc2 red, 0x36 green, and 0x21 blue.  The value must be
-     specified in hexadecimal, with an optional leading 0x.
-
-STYLES
-     The Z-machine allows for different text styles to be selected: these are
-     emphasized (typically italicized or underlined), bold, and reverse video.
-     In addition, a fixed-width font can be selected.  Glk does not guarantee
-     the appearance of styles; it only allows you to select from a list of
-     uses, rather than appearances.  The following Glk styles are how bocfel
-     maps the Z-machine's text styles:
-
-     Italic (or emphasized) uses the Emphasized style.	Bold uses the Sub‐
-     header style.  Reverse video uses the Alert style.  Fixed-width uses the
-     Preformatted style.
-
-     These were chosen because they map appropriately in the glktermw Glk
-     implementation.  If your Glk implementation does not render these styles
-     in a manner you like, consult its documentation to see if it is possible
-     to change the appearance of the various Glk styles.
-
-     Gargoyle, although a Glk implementation, does not have these issues.  The
-     combination of styles is possible, and the appearance of styles can be
-     guaranteed.
-
-CHARACTER GRAPHICS FONT
-     Beyond Zork can make use of a character graphics font. This font is used
-     for drawing the interactive map, arrows, and runes. Most of the runes and
-     arrows have Unicode equivalents and can be displayed if you have a font
-     that contains these characters. Unicode also includes box-drawing charac‐
-     ters which can be used to approximate the map in Beyond Zork.  These are
-     not perfect, but they are not terrible.
-
-     The -g option disables the character graphics font, but unfortunately the
-     ability to tell a game that a particular font is unavailable postdates
-     Infocom, so this flag will not prevent Beyond Zork from trying to use it.
-     Instead, Beyond Zork makes use of the interpreter number (see -n) to
-     decide whether to use character graphics. If you are using a font that
-     does not provide the necessary Unicode characters, you will want to run
-     Beyond Zork without the character graphics font. This is easily accom‐
-     plished by answering “No” when the game asks you if you are using a
-     VT-220 (this only happens when the interpreter number is set to 1, which
-     is the default).
-
-     If the character font is disabled with -g and a game tries to use it any‐
-     way (as is the case with Beyond Zork), the output will appear garbled,
-     but only for that font. Anything the game prints out in a normal font
-     will look fine.
-
-     See section 16 of the Z-Machine Standards Document 1.0 for more informa‐
-     tion.
-
-META COMMANDS
-     bocfel includes support for “meta commands”, which are commands inter‐
-     preted by bocfel itself instead of the game.  These are introduced with a
-     slash (‘/’), chosen in an attempt to not clash with game commands.  These
-     meta commands can be entered at any point the game requests user input,
-     e.g. on each turn.  They are as follows, and are case sensitive:
-
-	   /undo       Undo a turn.  This is similar to the UNDO command some
-		       games provide, but has two distinct advantages: it
-		       works even in games that do not provide undo, and it
-		       provides multiple undo even in games which do not sup‐
-		       port multiple undo.
-
-	   /scripton   Start a transcript.
-
-	   /scriptoff  Stop a transcript.
-
-	   /recon      Start a command record.
-
-	   /recoff     Stop a command record.
-
-	   /replay     Replay a command record.
-
-	   /save       Save the game.  This creates save files that are incom‐
-		       patible with those created by SAVE, so they should only
-		       be restored with /restore.  bocfel has built-in protec‐
-		       tion to prevent a file saved with a normal SAVE command
-		       from being confused with one saved by /save, and vice
-		       versa.
-
-		       Because it creates non-standard save files, this com‐
-		       mand should be avoided unless it is absoulutely neces‐
-		       sary, e.g. if the game has disabled saving.  It was
-		       added to bocfel solely for the case of such anti-social
-		       games.
-
-	   /restore    Restore a game saved by /save.  Do not attempt to use
-		       /restore to restore games saved with a normal SAVE com‐
-		       mand.
-
-	   /ps	       Push a save state onto the in-memory stack.
-
-		       This is meant to serve as an alternative to on-disk
-		       save files for when you are trying something dangerous
-		       in a game.  In such a case, there is generally no need
-		       for a save file to be stored on the disk because the
-		       save state is not meant to be persistent: it only needs
-		       to last long enough to be restored in the same session.
-
-		       Because a stack is used, /ps can be used multiple
-		       times, allowing you to jump backward as many times as
-		       there are states.  The maximum number of states stored
-		       is 25.  Once this number of states is reached, each new
-		       state causes the oldest state to be dropped.
-
-	   /ps [description]
-		       Identical to /ps, except that when the save state is
-		       displayed by /ls, the supplied description is shown
-		       rather than the time of the save.
-
-		       Please note that at the current time, any characters
-		       which are not printable ASCII characters will be
-		       replaced with a question mark.
-
-	   /pop        Restore the last-stored in-memory save state, as cre‐
-		       ated by /ps, removing it from the stack.
-
-	   /pop [slot]
-		       Restore the specified in-memory save slot.  [slot] must
-		       correspond to one of the slot numbers shown by /ls.
-		       The specified save, as well as any newer saves, will be
-		       removed from the stack.
-
-	   /drop       Drop the last-stored in-memory save state, as created
-		       by /ps, removing it from the stack.
-
-	   /drop [slot]
-		       Drop the specified in-memory save slot.	[slot] must
-		       correspond to one of the slot numbers shown by /ls.
-		       The specified save, as well as any newer saves, will be
-		       removed from the stack.
-
-	   /drop all   Drop all in-memory save slots, removing them from the
-		       stack.
-
-	   /ls	       List all available in-memory save states.  Each state
-		       is shown either as a string representing the time when
-		       the state was saved, or, if it was supplied, the
-		       description passed to /ps.  The last-listed state,
-		       which is marked with an asterisk, is the default state
-		       which will be restored with /pop.
-
-	   /status     Display the status line.  This only works for V1, V2,
-		       and V3 games, and is meant to be used either in non-Glk
-		       mode, or if the Glk implementation being used does not
-		       support windows (e.g. cheapglk).
-
-	   /disable    Disable meta commands for the remainder of the session.
-		       This is useful if the game itself expects input to
-		       start with a slash character.
-
-	   /say [command]
-		       Pretend like [command] was typed.  As with /disable,
-		       this is meant for games which expect input to start
-		       with a slash character.
-
-	   /debug [...]
-		       Perform a debugging operation; see META DEBUG COMMANDS.
-
-     Please note that /save and /restore are experimental.
-
-     Mixing in-memory saves with undo can have odd effects.  For example, if a
-     save state is pushed, and undo is then called multiple times, returning
-     to a point which occurred before the /ps call, popping the save state
-     will still jump to the /ps save position, effectively cancelling the undo
-     calls.  The undo states will not be recreated.  Similarly, if undo is
-     called right after /pop, it will succeed, but will not undo the /pop
-     call.  Instead, the effect is the same as if undo had been called on the
-     turn before /pop was called.  This is because meta commands are not con‐
-     sidered game commands and thus do not cause undo states to be stored.
-
-META DEBUG COMMANDS
-     The /debug command starts a debugging operation.  For some debugging
-     operations, an address is expected.  This is either an absolute address,
-     specified in hexadecimal with an optional leading 0x, or it is a global
-     variable.	Global variables have the syntax Gxx, where xx is a hexadeci‐
-     mal value in the range [00, ef], corresponding to global variables 0 to
-     239.
-
-     The debug commands are as follows:
-
-	   change start
-		       Begin a “change” operation.  This tracks word-sized
-		       memory addresses, allowing you to see if the values at
-		       any addresses have increased or decreased since the
-		       last check.  This is primarily useful for cheating (see
-		       CHEATING), helping, for example, to determine which
-		       memory address is used to track hunger or thirst.
-
-	   change dec  Display a list of all memory addresses which have
-		       decreased since the last change operation (either a
-		       change start, change inc, or change dec.  Values are
-		       treated as signed words, so a change from 0 to 65535 is
-		       considered a decrease from 0 to -1.
-
-	   change inc  Display a list of all memory addresses which have
-		       decreased since the last change operation.
-
-	   scan start  Begin a “scan” operation.  This tracks word-sized mem‐
-		       ory addresses, checking if particular addresses have
-		       specific values over time.  As with “change” opera‐
-		       tions, this is useful mainly for cheating.  An example
-		       would be tracking which memory address holds the amount
-		       of money being carried.	If you have $50, you can scan
-		       all addresses for the value 50.	After spending $5,
-		       scan all addresses for 45.  Repeat until only one
-		       address matches and that is likely where the money
-		       count is being stored.
-
-	   scan [N]    Scan all memory addresses for the value N, which is a
-		       signed decimal integer (hexadecimal if a leading 0x is
-		       used, octal if a leading 0 is used).  The total number
-		       of matching addresses (constrained by previous scan
-		       operations) is then printed.
-
-	   scan show   Display all addresses matching all previous scan crite‐
-		       ria.  This is a separate operation because initial
-		       scans will potentially match thousands of addresses.
-
-	   print [address]
-		       Print the word (as both signed decimal and unsigned
-		       hexadecimal) at address.
-
-	   freeze [address] [value]
-		       Freeze a 16-bit value in memory; this is analogous to
-		       the freeze configuration variable (see CHEATING).
-		       address is the address to freeze, and value is the
-		       value it should be frozen to.  value can be decimal,
-		       hexadecimal, or octal, with a leading 0x signifying
-		       hexadecimal and a leading 0 signifying octal.
-
-		       Please note that it is possible for bocfel to be built
-		       without cheating support, so this and related commands
-		       might not work.
-
-	   unfreeze [address]
-		       Unfreeze the 16-bit value which is frozen at address;
-		       the address is parsed identically as for freeze.  It is
-		       not an error to unfreeze an unfrozen value.
-
-	   show_freeze
-		       Display all frozen values.
-
-	   watch [address]
-		       Report any changes to the 16-bit word at address.
-
-		       Please note that it is possible for bocfel to be built
-		       without watch support, so this and related commands
-		       might not work.
-
-	   watch all   Watch every address for changes.  This will likely pro‐
-		       duce a lot of output.
-
-	   unwatch [address]
-		       Stop watching address for changes.  It is not an error
-		       to stop watching an address which is not being watched.
-
-	   unwatch all
-		       Stop watching all addresses which are currently being
-		       watched.
-
-	   show_watch  Display all watched-for values.
-
-SOUND EFFECTS
-     Currently, sound effects are only available when Gargoyle is used as the
-     Glk implementation.  The sound effects should be bundled in a Blorb file.
-     If the story file itself is stored in a Blorb file, that file is used to
-     find the sound effects.  Otherwise, a separate Blorb file must exist and
-     be named as follows: if the story file is /foo/bar/sherlock.z5, then the
-     Blorb file must be /foo/bar/sherlock.blb.	Sound effect support is exper‐
-     imental and does not currently conform fully to the Z-machine standard.
-     Bleeps are not supported, nor is section 9.4.4, nor is the hack regarding
-     The Lurking Horror mentioned in the Remarks section.
-
-CHEATING
-     There is extremely rudimentary support for “cheating”.  bocfel is able to
-     freeze certain areas of memory so that they always report the same value.
-     The idea behind this is to prevent hunger and thirst counters from forc‐
-     ing you to eat and drink.
-
-     Cheating is available through the configuration file as well as through
-     meta debug commands (see META DEBUG COMMANDS for information on using
-     meta debug commands to cheat).
-
-     When the configuration file is used, cheats are treated like any other
-     configuration variable.  The syntax is as follows: freeze:address:value.
-
-     This causes the word (an unsigned 16-bit value) at address address to
-     always contain the value value; value can be decimal, hexadecimal, or
-     octal, with a leading 0x signifying hexadecimal and a leading 0 signify‐
-     ing octal.
-
-     Example:
-
-	   cheat = freeze:0xabcd:0
-	   cheat = freeze:G00:0
-
-     Visit http://bocfel.org/cheats/ for a list of a few cheats for some Info‐
-     com games.  More cheats are potentially discoverable using meta debug
-     commands (see the META DEBUG COMMANDS section).  A more detailed explana‐
-     tion of how to figure out cheats is beyond the scope of this document.
-
-     Please note that it is possible for bocfel to be built without support
-     for cheating, in which case these cheats will silently do nothing.  The
-     -v option can be used to determine whether this is the case.
-
-SEE ALSO
-     iconv(1), fizmo(6), frotz(6), nitfol(6)
-
-STANDARDS
-     bocfel is believed to comply fully with version 1.1 of The Z-machine
-     Standards Document; see
-	   http://www.inform-fiction.org/zmachine/standards/z1point0/index.html
-     and .:
-	   http://ifarchive.org/if-archive/infocom/interpreters/specification/ZSpec11.txt
-
-AUTHORS
-     Chris Spiegel 
-
-BSD			       December 6, 2017 			   BSD
-
-
- -
-
-Copyright 2010-2012 Chris Spiegel.
-
-Bocfel is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License, version
-2 or 3, as published by the Free Software Foundation.
-
-Bocfel is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-
- -

GARGOYLE

-

Website

- -
-
-The Gargoyle Glk library is copyright 2009 Tor Andersson. It is released under the terms of the GNU General Public License.
-
-
- -

GIT 1.3.5

-

Website

- -
-
-Git is an interpreter for the Glulx virtual machine. Its homepage is here:
-
-http://ifarchive.org/indexes/if-archiveXprogrammingXglulxXinterpretersXgit.html
-
-Git's main goal in life is to be fast. It's about five times faster than Glulxe,
-and about twice as fast as Frotz (using the same Inform source compiled for the
-Z-machine). It also tries to be reasonably careful with memory: it's possible to
-trade speed off against memory by changing the sizes of Git's internal buffers.
-
-I wrote Git because I want people to be able to write huge games or try out
-complicated algorithms without worrying about how fast their games are going to
-run. I want to play City of Secrets on a Palm without having to wait ten seconds
-between each prompt.
-
-Have fun, and let me know what you think!
-
-  Iain Merrick (Original author)
-  iain@diden.net
-
-  David Kinder (Current maintainer)
-  davidk@davidkinder.co.uk
-
---------------------------------------------------------------------------------
-
-* Credits
-
-Andrew Plotkin invented Glulx, so obviously Git wouldn't exist without him. I
-also reused some code from his Glulxe interpreter (glkop.c and search.c), which
-saved me a lot of time and let me concentrate on the more interesting stuff.
-
-Many thanks are due to John Cater, who not only persuaded me to use source
-control, but let me use his own CVS server. John also provided lots of useful
-advice and encouragement, as did Sean Barrett.
-
-Thanks also to Joe Mason, Adam Thornton, Simon Baldwin and Joonas Pihlaja who
-were among the first to try it out and complain that it wasn't working. Joonas
-also gets special brownie points for trying out more bizarre boundary cases than
-I realised existed in the first place.
-
-Tor Andersson was apparently the first person to use setmemsize, since he also
-explained why it didn't work and contributed a fix. Thanks, Tor!
-
-David Kinder has done a stellar job of maintaining the code recently. Thanks
-also to Eliuk Blau for tracking down bugs in the memory management opcodes.
-
---------------------------------------------------------------------------------
-
-* Version History
-
-1.3.4 2015-06-13  Performance improvements from Peter De Wachter, which give
-                  approximately a 15% speed increase.
-
-1.3.3 2014-03-15  Added acceleration functions 8 through 13, which work
-                  correctly when the Inform 6 compiler setting NUM_ATTR_BYTES
-                  is changed, contributed by Andrew Plotkin.
-
-1.3.2 2013-03-26  A further fix to glkop.c, following the similar fix added to
-                  Glulxe 0.5.1.
-                  Increased the default undo buffer size in all ports to 2Mb.
-
-1.3.1 2012-11-09  Further fixes to glkop.c, following similar fixes added to
-                  Glulxe 0.5.0.
-
-1.3.0 2011-12-16  Fixed a bug in glkop.c dispatching, to do with arrays
-                  of opaque objects, following a similar fix in Glulxe.
-                  Fixed a problem with the memory heap not being sorted
-                  correctly on restore, contributed by Brady Garvin.
-
-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
-                  similar fix in Glulxe.
-
-1.2.7 2010-08-20  Floating point opcode support (VM spec 3.1.2).
-                  Restart does not now discard undo information, so that a
-                  restart can be undone.
-
-1.2.6 2010-02-09  Imported fix for retained Glk array handling from Glulxe.
-
-1.2.5 2009-11-21  Fixes for problems shown by Andrew Plotkin's glulxercise test
-                  cases, from David Kinder.
-
-1.2.4 2009-04-02  More David Kinder! Accelerated opcode support (VM spec 3.1.1).
-
-1.2.3 2009-02-22  David Kinder and Eliuk Blau fixed some memory management bugs.
-                  Added a regression test (thanks to Emily Short for assistance)
-                  Switched to MIT-style license (see above).
-
-1.2.2 2009-01-21  malloc & mfree contributed by the most excellent David Kinder.
-
-1.2.1 2008-09-14  Support for 64-bit machines, contributed by Alexander Beels.
-                  Fix for crashing bug in RESTORE, contributed by David Kinder.
-                  Non-Unicode display bug fix, contributed by Jeremy Bernstein.
-
-1.2   2008-01-06  Minor version increment for VM spec 3.1.
-                  Implemented mzero and mcopy, but not malloc and mfree (yet).
-
-1.1.3 2006-10-04  Fixed a bug in the cache logic that broke the game Floatpoint.
-                  Added some other caching tweaks and put in a few more asserts.
-
-1.1.2 2006-08-22  streamnum in filter I/O mode no longer prints a garbage char.
-                  Merged in David Kinder's updated Windows startup code.
-
-1.1.1 2006-08-17  Wow, over a year since the last update.
-                  Rolled in Tor Andersson's fix for setmemsize.
-
-1.1   2004-12-22  Minor version increment because we now implement VM spec 3.0.
-                  Implemented new Unicode opcodes and string types.
-
-1.0.6 2004-12-10  Random number generator now handles random(0) correctly.
-                  Code cache now tracks the number of function calls properly.
-                  Fixed a bug that could hang the terp when the cache filled up.
-
-1.0.5 2004-05-31  Random number generator is now initialised properly.
-                  Some source files had Mac line-endings, now fixed.
-                  Version number is now set in the Makefile, not in git.h.
-                  Merged David Kinder's Windows Git code into main distribution.
-
-1.0.4 2004-03-13  Fixed a silly bug in direct threading mode that broke stkroll.
-                  Memory access bounds checking has been tightened up slightly.
-                  aload and astore now work correctly with negative offsets.
-                  Rewrote the shift opcodes a bit more defensively.
-                  Implemented the "verify" opcode.
-                  Code in RAM is no longer cached by default.
-                  Adding some special opcodes to control the code cache.
-                  Bad instructions are now caught in the terp, not the compiler.
-                  Now passes all of Joonas' indirect string decoding tests.
-
-1.0.3 2004-01-22  No longer hangs when using streamnum in the "filter" I/O mode.
-                  setstringtbl opcode now works correctly.
-
-1.0.2 2003-10-25  Stupid bug in 1.0.1 -- gitWithStream() was broken and wasn't
-                  able to load Blorb files. Now it's *really* fixed.
-
-1.0.1 2003-10-23  Fixed a bug where strings were printed as "[string]"
-                  Fixed a bug in tailcall
-                  Implemented setmemsize
-                  Implemented protect
-                  Moved git_init_dispatch() call out of startup code, into git.c
-                  Added divide-by-zero check
-                  Compiler now stops when it finds a 'quit' or 'restart'
-                  Added gitWithStream() as a workaround for xglk
-
-1.0   2003-10-18  First public release
-
-
- -
-
-(MIT LICENCE)
-Copyright (c) 2003 Iain Merrick
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
-the Software without restriction, including without limitation the rights to
-use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
-the Software, and to permit persons to whom the Software is furnished to do so,
-subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
-FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
-COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
-IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
- -

GLULXE 0.5.4

-

Website

- -
-
-The MIT License
-
-Copyright (c) 1999-2016, Andrew Plotkin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-
-
- -

HUGO 3.1.03

-

Website

- -
-
-NOTES ON GLK HUGO
------------------
-
-This is a port of Hugo to Glk, the multi-platform interface layer designed
-by Andrew Plotkin, which enables Hugo to run on platforms to which it has
-not been directly ported.
-
-Because Glk does not itself support all of Hugo's features, the limitations
-of Glk Hugo on various platforms may include any or all of:
-
-	- No graphics display
-	- No sound or music
-	- No colored text
-	- No arbitrary window positioning
-	- Main display limited to a proportional font
-	- Windows limited to fixed-fonts
-
-However, most Hugo games should work, since Glk Hugo makes every attempt to
-gracefully work around these features even if they are used.
-
-ADDITIONAL NOTES:
-
-- With mouse-based versions of Glk, it may be possible to change the window
-focus by clicking in a different window.  If you are unable to type a
-command when Glk Hugo seems to be waiting for one, try clicking on the input
-window to restore focus.
-
-
------
-Kent Tessman
-January 23, 1999
-
-
- -
-
-HUGO LICENSE - December 19, 2003
---------------------------------
-
-Copyright (c) 2003 by Kent Tessman
-The General Coffee Company Film Productions
-
-
-1.   Definitions
-
-"Copyright Holder" refers to Kent Tessman.
-
-"End User" refers to a user of the Software.
-
-"End User Program" refers to a computer program created by an End
-User, written using the Hugo Programming Language and compiled using
-the Hugo Compiler.
-
-"Hugo" refers to the Hugo Interactive Fiction Development System, created
-by the Copyright Holder.
-
-"Hugo Programming Language" refers to the Hugo programming language and
-its characteristic syntax.
-
-"Hugo Source Code" refers to the human-readable source code of the
-Software.
-
-"License" refers to this license.
-
-"Software" refers to the Hugo Compiler, the Hugo Engine, the Hugo
-Debugger, the Hugo Library, and any other related programs or files.
-
-
-2.   Ownership and Grant of Rights
-
-2.1  Hugo is the property of the Copyright Holder.  The Copyright Holder
-retains its copyright in the Software, without limitation.
-
-2.2  The Copyright Holder grants to the End User the right to use the
-Software solely for the purposes of:
-
-     (a) running programs created with the Software; and
-
-     (b) creating End User Programs.
-
-2.3  End User Programs are the property of the End User.
-
-
-3.   Provision of the Hugo Source Code
-
-3.1  The Copyright Holder has made available to the End User the Hugo
-Source Code for the purposes of:
-
-     (a) porting the Software to operating systems for which the
-         Software is not yet available; and
-
-     (b) investigating the functionality of the Software.
-
-3.2  In no way does the Copyright Holder's act of making available the
-Hugo Source code reduce or otherwise affect in any way its rights in
-the Hugo Source Code.
-
-
-4.   Modification and Distribution
-
-4.1  Distribution of the Software or the Hugo Source Code, in whole or
-in part, in a modified form without the express written consent of the
-Copyright Holder is prohibited.
-
-4.2  Distribution of the Software or the Hugo Source Code, in whole or
-in part, for profit or other commercial intent or monetary transaction
-without the express written consent of the Copyright Holder is
-prohibited.
-
-4.3  This License must be distributed with any distribution of the
-Software or the Hugo Source Code.
-
-
-5.   Warranty
-
-The Software and the Hugo Source Code are provided "as is" without
-warranty of any kind, either expressed or implied, including but not
-limited to the implied warranties of merchantability and fitness for a
-particular purpose.  In no event shall the Copyright Holder or The
-General Coffee Company Film Productions or any other related or
-unrelated party be liable to the End User or any other individual or
-entity for damages arising out of the use or inability to use these or
-other programs.  Use of the Software indicates acceptance of these
-terms.
-
-
- -

INFORM 6.34 (6.12 LIBRARY)

-

Website -

- -
-
-Inform Release Notes
-
-Inform Compiler 6.34, 6.33, 6.32, 6.31, 6.30
-Inform Library 6/11
-
-Introduction
-
-This is a maintenance release of the Inform system for creating adventure
-games, intended to address issues that have arisen since the 6.21 compiler and
-6/10 library files were released in 1999, and subsequently since the 6.30
-compiler was released in 2004. The focus is primarily on fixing problems, but a
-small number of enhancements are included.
-
-Although just about all known bugs are fixed, the approach to enhancing Inform
-is more conservative. The selection of suggestions to implement has been
-governed by three factors:
-
-    * avoidance of changes which might cause existing games to misbehave;
-
-    * minimisation of features which would require updates to the Inform
-Designer’s Manual;
-
-    * essential simplicity. With Graham Nelson’s permission, this release has
-been produced by a volunteer taskforce, whose enthusiasm has been tempered by a
-certain lack of familiarity with the internals of Inform. Thus, we have
-concentrated on ‘safe’ changes; the implementation of some good ideas has been
-postponed until we are more confident that we know what we’re doing.
-
-Having said that, this release does incorporate one major advance. It is based
-on Andrew Plotkin’s bi-platform — Z-machine and Glulx — compiler and library
-files, which were in turn derived from the the 6.21 compiler and 6/10 library.
-The result is that the two Virtual Machine (VM) strands have merged into a
-single compiler and library which, although continuing by default to produce
-Z-code, can alternatively generate code for the Glulx VM if you supply the -G
-compiler switch. There’s more on this topic in Support for Glulx. Before that,
-though, we’ll summarise the changes to the compiler and to the library files.
-
-If you’ve translated the 6/10 library into another language, you may find
-Information for translators helpful.
-
-Acknowledgements
-
-Far too many people contributed towards this release — reporting and resolving
-bugs, making helpful suggestions, providing support and facilities, testing,
-and so on — for their names to be individually listed. So instead, this is a
-general thank-you to everybody who has made this release happen, and specific
-ones to Graham for permitting it in the first place, and to Andrew for his
-pioneering work on Glulx. There are, naturally, sure to be imperfections in the
-release, and these should be reported through the Inform bug tracker.
-
-
- -
-
-The compiler and standard library for Inform6 are licensed under
-1) The traditional Inform license as described by the DM4, or
-2) The Artistic License 2.0.
-
-The user is free to choose which license to accept, i.e., free to choose
-either set of terms and conditions.
-
-Here is the relevant bit from the Inform Designer's Manual, 4th edition:
-
-      Copyright on Inform, the program and its source code, its example
-      games and documentation (including this book) is retained by Graham
-      Nelson, who asserts the moral right to be identified as the author
-      under the Copyrights, Designs and Patents Act 1988.  Having said
-      this, I am happy for it to be freely distributed to anybody who wants
-      a copy, provided that: (a) distributed copies are not substantially
-      different from those archived by the author, (b) this and other
-      copyright messages are always retained in full, and (c) no profit is
-      involved.  (Exceptions to these rules must be negotiated directly
-      with the author.)  However, a story file produced with the Inform
-      compiler (and libraries) then belongs to its author, and may be sold
-      for profit if desired, provided that its game banner contains the
-      information that it was compiled by Inform, and the Inform version
-      number.
-
-* The license status of the contributed material (demos, include, tutor) is
-  what it says in each file.
-
-
- -

LEVEL9 5.1

-

Website -

- -
-
-
-        Level 9 Interpreter v5.1
-        An interpreter for Level 9 games in any format,
-        including Spectrum snapshots.
-
-        Copyright (c) 1996-2011 Glen Summers and contributors.
-        Contributions from David Kinder, Alan Staniforth,
-        Simon Baldwin, Dieter Baron and Andreas Scherrer.
-
-        Level9 is released under the terms of the GNU General
-        Public License. See the file COPYING that is included
-        with this program for details.
-
-
-Introduction
-------------
-
-During the 1980s a small British company called Level 9, run by two brothers
-(Mike and Pete Austin), produced a series of text adventure games for a
-variety of computers. These games received considerable critical acclaim and
-are probably the best text adventures written for the small cassette based 8
-bit computers common in Britain in the 80s.
-
-Level 9 wrote their games using a custom designed system known as "A-Code",
-which evolved from games on the 8 bit computers such as the Acorn BBC Model
-B, the Sinclair Spectrum and the Commodore 64 to the (then new) 16 bit
-machines such as the Amiga and the Atari ST.
-
-From disassembly of Level 9 games there are thought to be four variants of
-A-Code, which are detailed below, and all of which are supported by this
-interpreter. Thanks go to Paul David Doherty for analysing the games and
-producing the table which follows.
-
-  v1    This was used for the earliest games. Spectrum v1 games had
-        black text on a grey background. Games known to be released in
-        this format:
-
-                Colossal Adventure
-                Adventure Quest
-                Dungeon Adventure
-                Snowball
-                Lords of Time
-
-  v2    These releases were made between 1984 and 1985 (and usually say
-        so in the initial copyright message). This version introduced
-        the yellow text on a black background which became standard.
-        Games in this format were:
-
-                Adventure Quest
-                Dungeon Adventure
-                Lords of Time
-                Snowball
-                Return to Eden
-                Erik the Viking
-                Emerald Isle
-                Red Moon
-
-  v3    This format, dated 1986, was used by the largest number of
-        releases. These were:
-
-                Worm in Paradise
-                The Price of Magick
-                The Secret Diary of Adrian Mole
-                The Growing Pains of Adrian Mole
-                The Archers
-                The Jewels of Darkness Trilogy (Colossal Adventure,
-                Adventure Quest and Dungeon Adventure released as
-                one package)
-                The Silicon Dreams Trilogy
-                (Snowball, Return to Eden and Worm in Paradise)
-
-  v4    This was used for the Time and Magick Trilogy (Lords of Time,
-        Red Moon and The Price of Magick), and all Level 9's new games
-        from 1987 onwards:
-
-                Knight Orc
-                Gnome Ranger
-                Ingrid's Back
-                Lancelot
-                Scapeghost
-
-
-Supported Formats
------------------
-
-On several machines (such as the Amiga) Level 9 games were distributed as
-an interpreter plus a data file, usually called "gamedata.dat" or something
-similar. These games can be played with this interpreter simply by loading
-the "gamedata.dat" file.
-
-For the Amiga (and some other formats) the v4 games were released in three
-parts, each in a separate data file:
-
-        gamedat1.dat
-        gamedat2.dat
-        gamedat3.dat
-
-Starting the first game gives a menu from which you can choose which part or
-game to play. For this to work the files must have the same basic structure
-with a number in it somewhere, e.g. file names
-
-        TimeAndMagick1.dat
-        TimeAndMagick2.dat
-        TimeAndMagick3.dat
-
-will work.
-
-On other (especially older and smaller) computers the games were distributed
-as a single file containing both an interpreter and the game data. Level9
-can cope with these files as well, as it automatically searches files for
-valid Level 9 games. This however requires that the file not be compressed
-in any way. For example, there are several Spectrum snapshots of Level 9
-games available which this interpreter can play, but these snapshots must
-be in an uncompressed format (e.g. SNA). Commonly snapshots are available in
-the compressed Z80 format, but these files can be converted to SNA using the
-widely available conversion program "SPConv". Version 1.06 or higher of
-"SPConv" is recommended.
-
-Paul David Doherty has written "L9Cut", which can extract Level 9 games from
-many different formats. L9Cut can also remove copy protection from Level 9
-games. L9Cut can be downloaded from
-
-  http://www.ifarchive.org/indexes/if-archiveXlevel9Xtools.html
-
-This program has been tested on files obtained from releases for the Amiga,
-Atari ST, IBM PC, C-64, Spectrum, Atari 800, BBC, Amstrad CPC, Apple 2,
-Apple Mac and MSX computers.
-
-
-Graphics
---------
-
-The first games from Level 9 were text only, but later games included line-
-drawn graphics, and then bitmap graphics for the last games. These graphics
-are supported by some versions of the interpreter (The 32-bit DOS version
-does support graphics, while the 16-bit DOS version does not.).
-
-On some platforms the line-drawn graphics were placed into separate files
-(For example, in the Amiga release of "Jewels of Darkness" the game is in
-"gamedata.dat" and the graphics in "picture.dat".). In order to show these
-pictures the graphics file can be passed as a second command line argument
-when starting the interpreter. If no graphics file is specified in this
-way, the interpreter will look for a file with the same name as the game
-data, but with a file extension of ".pic", ".cga" or ".hrc" (the latter
-two being used for graphics files in MS-DOS Level 9 releases).
-
-If no line-drawn graphics file is specified, Level 9 will search the given
-game data file for graphics data. This is useful when the game data is a
-Spectrum SNA snapshot or a similar memory dump of an emulator.
-
-The last Level 9 games use bitmap graphics. The interpreter can display the
-bitmap graphics from C64, Amiga, Atari ST, MS-DOS, Apple Macintosh, BBC B,
-Amstrad CPC and Spectrum +3 versions of the games (though for the last three,
-there is currently no way to extract the A-code game data in a usable form).
-
-The graphics files contain a number somewhere in the file name, and there
-may also be a title picture with a different file name. The interpreter
-searches for suitably named graphics files using the following rules. In
-all cases copy the graphics and title files to the same directory as the
-game.
-
-Amiga, Macintosh and some Atari ST
-  The graphics file name is just the number (e.g. "1", "2", etc.).
-  The title file is called "title".
-
-Later Atari ST
-  The graphics file name is the number with a "squ" file extension
-  (e.g. "1.squ", "2.squ", etc.). The title file is just one of the
-  normal graphics files.
-
-MS-DOS
-  The graphics file name is the number with a "pic" file extension
-  (e.g. "1.pic", "2.pic", etc.). The title file is just one of the
-  normal graphics files.
-
-C64
-  The graphics file name is "pic" followed by the number (e.g.
-  "pic1", "pic2", etc.). The title file is called "title mpic".
-
-BBC B "Lancelot"
-  As for C64, except that the title file is called "title".
-
-BBC B except "Lancelot"
-  The graphics file name is "P.Pic" followed by the number (e.g.
-  "P.Pic1", "P.Pic2", etc.). The title file is called "P.Title".
-
-Amstrad CPC and Spectrum +3
-  All but the first graphic are contained in a single file called
-  "allpics.pic". The first graphics file is "1.pic" and the title
-  file is "title.pic".
-
-
-Meta Commands
--------------
-
-Level9 supports several meta commands, which can be entered on the input
-line. These commands are handled by the interpreter rather than being passed
-to the game. They are:
-
-  #save         Saves out a game position directly, bypassing any
-                prompting (such as for disk changes).
-
-  #restore      Loads in a saved position directly, bypassing any
-                protection code within the game.
-
-  #quit         Quits the current game.
-
-  #cheat        Tries to bypass the copy protection code which asks for
-                a specific word. This is done by trying every word in
-                the game's dictionary. On a slow machine, this can take
-                a long time.
-
-  #dictionary   Lists the game dictionary. Press a key to stop the
-                listing and return to the input line.
-
-  #picture      If graphics are available, shows the picture specified
-                as a number after the picture command, e.g. "#picture 520".
-
-  #seed         Sets the seed of the random number generator to the value
-                given, e.g. "#seed 42". This will make randomness within
-                the game predictable, which is useful for testing.
-
-  #play         Prompts the user for a text file from which to read
-                further input from. Input lines are read from the file
-                until the end is reached, at which point the game reverts
-                to asking the user for input.
-
-The 32-bit DOS version of Level 9 also supports several hotkeys. Press
-Alt-H when playing a game to view a list of the available hotkeys.
-
-
-History
--------
-
-  v5.1  The bitmap graphics from the US Macintosh release of Lancelot
-        now display correctly.
-
-  v5.0  V1 games are also now supported.
-        The input logic now correctly handles commas and full stops
-        in the user's input for v3 or later games.
-        The input logic now allows hyphens and apostrophes to be
-        input, which is needed for some v2 games.
-        The dictionary listing for v2 games no longer has junk on the
-        end.
-        The graphics detection algorithm has been improved, so that it
-        now correctly finds graphics in all known games.
-        A difference in the logic between the v2 and v3 line-drawn
-        graphics has been implemented, which corrects the scaling for
-        some v2 graphics.
-        Added #seed and #play meta commands.
-
-  v4.1  Corrected a bug that made Lancelot unplayable.
-        BBC B bitmaps are now shown as they appeared on the original
-        computer.
-
-  v4.0  Implemented support for bitmap graphics.
-
-  v3.0  Implemented support for line-drawn graphics.
-        Fixed a problem with v4 detection that stopped some versions of
-        Scapeghost running correctly.
-        Implemented an opcode used by the disk based versions of
-        Time and Magick, which now means that saving from these games
-        works.
-        The interpreter now gives you a reasonable amount of time to
-        enter the Lenslok code in protected games, and also tells you
-        what the code should be.
-
-  v2.0  Revised the description of v4 games to include all the post-1987
-        games, which are now supported.
-        V2 games are also now supported.
-        Added meta commands.
-
-  v1.0  First release.
-
-
-Credits
--------
-
-The Level9 interpreter was originally written by Glen Summers. The changes for
-version 3.0 were made by David Kinder with additional code from Alan Staniforth
-and Simon Baldwin.
-
-For version 4.0, David Kinder integrated the various bitmap decoders, but all
-the difficult work was done by Alan Staniforth and Dieter Baron. Alan also
-supplied the BBC B bitmap changes for version 4.1.
-
-David and Andreas Scherrer worked on version 5.0 to integrate script playback
-from Andreas' .NET port of the interpreter. Andreas created a test harness to
-play through all the games, and David and Andreas then worked through the
-problems this showed up. Andreas also put much effort into painstakingly
-checking all the graphics in the games, which revealed several issues.
-
-Help, testing and information on the various Level 9 formats was provided by
-Paul David Doherty. Testing of the fix for Lancelot in version 4.1 was
-performed by Guido Mureddu.
-
-If you have any comments or queries, contact David Kinder.
-Web: http://www.davidkinder.co.uk/
-Email: davidk.kinder@virgin.net
-
-
-The Interactive Fiction Archive
--------------------------------
-
-If you have access to the Internet and are interested in text adventures,
-then you can find all sorts of programs and information at The Interactive
-Fiction Archive:
-
-  http://www.ifarchive.org/
-
-The latest version of this program can always be found on this site, in
-
-  http://www.ifarchive.org/indexes/if-archiveXlevel9XinterpretersXlevel9.html
-
-
- -
-
-Level 9 Interpreter, Glk Notes
-------------------------------
-
-
-Introduction
-------------
-
-This is a port of the Level 9 interpreter to Glk.  The complete interface
-lives in the single file
-
-	glk.c
-
-The main test and development system for the port is Linux, with Xglk as the
-Glk library.
-
-
-Acknowledgements
-----------------
-
-Thanks to Alan Staniforth for considerable help with getting the some of the
-source for the base interpreter together, and for his hints on how to cover
-the porting requirements, and to David Kinder for a complete reality check on
-the port progress, and also for the Level 9 interpreter.
-
-Thanks also to Ben Hines  for the Mac code, which, if
-I have transcribed it correctly from earlier work with AGiliTy, should permit
-this port to run on Mac platforms with Glk.
-
-
-Running Games
--------------
-
-The interpreter understands game files that use the "Spectrum snapshot" format.
-A file in this format usually has the extension ".sna" or ".SNA".
-
-Give the name of the game file to run at the system prompt.  For example
-
-	glklevel9 colossal.sna
-
-If the game has an external line drawing graphics file, make sure that the file
-lives in the same directory as the game file, and has the same base name with
-the extension ".pic", or is named "picture.dat".  The Glk interpreter will
-find this file automatically, if it exists, and use it to create game pictures.
-Line drawn graphics are not always held in an external graphics file; a game
-may l hold its graphics internally, in which case no addtional files are
-required.
-
-If the game has external bitmap pictures, these will normally appear as
-multiple files with ".pic", ".squ", ".picN", or ".title" extensions.  As with
-line drawn graphics, ensure that these files are in the same directory as the
-main game file, so that the Glk interpreter can find them.
-
-If there are no graphics files, the interpreter will run in text only mode.  It
-will also do this if it cannot open the graphics files, or if the files do not
-seem to contain usable game graphics.
-
-There are a few command line options that you can also add, to vary the way
-that the game looks:
-
-	-np     Don't display game pictures initially
-	-ni	Don't intercept 'quit', 'restart', 'save', and 'restore'
-	-ne	Don't add an extra prompt on line input
-	-nl	Don't attempt to detect infinite loops in games
-	-na	Don't expand single-letter abbreviations
-	-nc	Don't attempt to interpret selected commands locally
-
-See below for further information about what these options mean.
-
-
-Intercepting Game Commands
---------------------------
-
-Some Level 9 games are written for cassette tape based microprocessor systems,
-and the way in which they save, restore, and restart games generally reflects
-this.  Additionally, there's often no straightforward way to quit from a game.
-
-To try to make things a bit more convenient for a player, Glk Level 9 traps the
-following command words in its interface:
-
-	quit, restart, save, restore, and load (synonym for restore)
-
-When it sees one of these entered on an input line, it tries to handle the
-command itself.  In the case of "quit" and "restart", it will confirm that you
-want to end the current game.
-
-In the case of "save" and "restore", Glk Level 9 will try to handle saving or
-loading game state to or from system files using the Level 9 interpreter
-internal routines, rather than the ones built into the game itself.  This
-bypasses the inconvenient "Lenslok" check built into some games, and also works
-round a couple of possible Level 9 interpreter bugs.
-
-If you prefix a command with a single quote, Glk Level 9 will not try to handle
-the command itself, but will remove the quote, and pass the remaining string
-to the game without change.
-
-You can turn off command interception with the command line option '-ni'.
-
-
-Extra Prompting
----------------
-
-Early Level 9 games generally output a prompt something like
-
-	What now?
-
-However, it's not always printed when the game is expecting line input.  Simply
-leaning on the Return key will scroll the game with no prompting, and the
-Adrian Mole games offer no prompt at all when not in menu modes.
-
-Some later Level 9 games begin with the "What now?" (or "What gnow?"), then
-switch to issuing a "> " prompt later on.
-
-To try to make it a little clearer to see what's going on, the Glk Level 9 will
-add it's own "> " prompt when the game is expecting line input, but only when
-it determines that the game has not already issued its own prompt.
-
-You can turn this off with the '-ne' option.
-
-
-Displaying Pictures
--------------------
-
-Level 9 games may contain graphics, and while not essential to the game, they
-can enhance the experience of playing.
-
-Unfortunately, Glk does not provide a method to directly display an image
-bitmap, so Glk Level 9 needs to adopt some tricks to get a picture to display.
-The end result is that, on Linux Xglk at least, it can take several seconds to
-render a complete picture.
-
-To reduce the problems caused by a game pausing for several seconds for a
-picture,  Glk Level 9 does its picture rendering using a background "thread".
-This draws in the complete picture over a series of smaller image updates,
-while at the same time still allowing game play.  To speed up picture
-rendering, Glk Level 9 also goes to considerable effort to try to minimize the
-amount of Glk graphics operations it uses.
-
-If you move to a location with a new picture before the current one has been
-fully rendered, Glk Level 9 will simply start working on the newer picture.
-
-Most Level 9 games accept the "graphics" and "text" commands, which turn
-pictures on and off respectively.  It is also possible to turn off pictures
-directly in Glk, for games that don't support these two commands.
-
-You can use the "-np" option to turn off pictures.  Glk Level 9 also will not
-show pictures if the Glk library does not support both graphics and timers, if
-there are no graphics files, built in graphics, or bitmaps, or if the
-interpreter cannot open graphics files successfully.  See below for further
-notes about displaying pictures.
-
-
-Game Infinite Loop Checking
----------------------------
-
-Some Level 9 games can enter an infinite loop if they have nothing better to
-do.  For example, at then end of Adrian Mole, you have the option to play the
-last part again.  If you decline, the game will spin in a tight loop which
-does nothing.
-
-Because it's hard to break into this loop without killing the interpreter
-completely, Glk Level 9 notes how much work the interpreter is doing over time.
-If it notices that the interpreter has neither printed anything nor asked for
-input for five seconds or so, it assumes that the game is in an infinite loop,
-and offers you the chance to stop the game.
-
-In the unlikely event that this check triggers with a game that is not in an
-infinite loop, you can turn off the option with "-nl".
-
-
-Status Line
------------
-
-Level 9 games do not print a status line, so Glk Level 9 will use the status
-window, a separate window above the main window created by Glk libraries that
-support separate windows, to display the game's name and version details.
+

BABEL 0.2B

+

Website

+ +
+
+Version 0.2b, Treaty of Babel Revision 7
+This is the source code for babel, the Treaty of Babel analysis tool.
 
-For other Glk libraries, Glk Level 9 will print the game's name in "[...]"
-brackets above the standard game output following each turn, but only when the
-game name has changed since the last turn (that is, in multi-file games).
+Most of this code is (c) 2006 by L. Ross Raszewski
 
+The following files are public domain:
+zcode.c
+glulx.c
+executable.c
+level9.c
+magscrolls.c
+agt.c
+hugo.c
+advsys.c
+misc.c
+alan.c
+adrift.c
+treaty.h
+treaty_builder.h
 
-Expanding Abbreviations
------------------------
+The following files are Copyright (C) 1999, 2000, 2002 Aladdin Enterprises:
+md5.c
+md5.h
 
-Many IF games systems allow a player to use single character abbreviations for
-selected common commands, for example, 'x' for 'examine', 'l' for look, and so
-on.  Not all Level 9 games offer this feature, however.
+And are used in accordance with their licenses.
 
-To try to help the player, Glk Level 9 will automatically expand a selection
-of single character commands, before passing the expanded string to the game as
-input.  It expands a command only if the first word of the command is a single
-letter, and one of the following:
+All other files are (c) 2006 by L. Ross Raszewski and are released under
+the Creative Commons Attribution 4.0 International (CC BY 4.0).
 
-	'c' -> "close"		'g' -> "again"		'i' -> "inventory"
-	'k' -> "attack"		'l' -> "look"		'p' -> "open"
-	'q' -> "quit"		'r' -> "drop"		't' -> "take"
-	'x' -> "examine" 	'y' -> "yes"		'z' -> "wait"
+To view a copy of this license, visit
+http://creativecommons.org/licenses/by/4.0/ or send a letter to
 
-If you want to suppress abbreviation expansion, you can prefix your input with
-a single quote character (like putting literal strings into a spreadsheet).
-If you do this, Glk Level 9 will strip the quote, then pass the rest of the
-string to the main interpreter without any more changes.  So for example,
+Creative Commons,
+543 Howard Street, 5th Floor,
+San Francisco, California, 94105, USA.
+
+
- 'x something +

GARGOYLE

+

Website

+ +
+
+Gargoyle contains several components, aggregated together to form a package. Parts of this package are distributed under the terms of the GNU General Public License (GPL). Redistribution of this package is freely allowed, provided that the terms of the GPL are adhered to, including the requirement that the source code for all GPL licensed parts of this package be available from the same location as any binary package.
 
-will pass the string "x something" back to the game, whereas
+The Gargoyle Glk library is copyright 2009 Tor Andersson. It is released under the terms of the GNU General Public License.
 
-	x something
+AdvSys is copyright (c) David Michael Betz. It is released under the terms of the BSD license.
 
-will pass "examine something" back to the game.
+AGiliTy is copyright (c) Robert Masenten. It is released under the terms of the GNU General Public License.
 
-You can turn off abbreviation expansions with the command line option '-na'.
+Alan is copyright (c) Thomas Nilsson. It is released under the terms of the Artistic License 2.0.
 
+Bocfel is copyright (c) Chris Spiegel. It is released under the terms of the GNU General Public License.
 
-Interpreting Commands Locally
------------------------------
+Frotz is copyright (c) Stefan Jokisch. It is released under the terms of the GNU General Public License.
 
-Glk Level 9 will handle special commands if they are prefixed with the string
-'glk'.  It understands the following special commands:
+Geas is copyright (c) Mark Tilford and David Jones. It is released under the terms of the GNU General Public License.
 
-	help		  Prints help on Glk special commands
-	summary		  Prints all current Glk settings
-	version		  Prints the Glk library and Glk port version numbers
-	license		  Prints the Glk port license
-
-	script on	  Starts recording the game text output sent to the
-			  main game window
-	script off	  Turns off game text recording
-	inputlog on	  Starts recording input lines typed by the player
-	inputlog off	  Stops recording input lines
-	readlog on	  Reads an input log file as if it had been typed by
-			  a player; reading stops automatically at the end of
-			  the file
-	abbreviations on  Turn abbreviation expansion on
-	abbreviations off Turn abbreviation expansion off
-	graphics on       Turn on Glk graphics
-	graphics off      Turn off Glk graphics (see below)
-	loopchecks on	  Turn game infinite loop checking on
-	loopchecks off	  Turn game infinite loop checking off
-	locals on	  Turn local interception of 'quit', 'restart',
-			  'save' and 'restore' on
-	locals off	  Turn local interception of 'quit', etc. off
-	prompts on	  Turn extra "> " prompting on
-	prompts off	  Turn extra "> " prompting off
-	commands off	  Turn of Glk special commands; once off, there is no
-			  way to turn them back on
+Git is copyright (c) Iain Merrick. It is released under the terms of the MIT License.
 
-You can abbreviate these commands, as long as the abbreviation you use is
-unambiguous.
+Glulxe is copyright (c) Andrew Plotkin.
 
-If for some reason you need to pass the string "glk" to the interpreter, you
-can, as with abbreviations above, prefix it with a single quote character.
-
-You can turn off local command handling with the command line option '-nc'.
-
-If all of abbreviation expansion, local command handling, and game command
-interceptions are turned off, there is no need to use single quotes to suppress
-special interpreter features.
+Hugo is copyright (c) Kent Tessman. It is released with permission under the terms of the Simplified 2-Clause BSD license.
 
+JACL is copyright (c) Stuart Allen.  It is released under the terms of the GNU General Public License.
 
-Multi-file Games
-----------------
-
-Some Level 9 games come in multiple files, for example
+Level 9 is copyright (c) Glen Summers, David Kinder, Alan Staniforth, Simon Baldwin and Dieter Baron. It is released under the terms of the GNU General Public License.
 
-	gamedat1.sna
-	gamedat2.sna
-	...
-
-and so on.  Once a game part is finished, the Level 9 interpreter queries the
-Glk interface for the next file.  When this happens, both for disk and for
-tape based games, the interface will try to generate the appropriate file name
-for the next game part, by incrementing the last digit found in the file's
-name.  The interpreter will then look in the same directory for the new file
-name.
+Magnetic is copyright (c) Niclas Karlsson, David Kinder, Stefan Meier and Paul David Doherty. It is released under the terms of the GNU General Public License.
 
-If this method fails, then you will need to run the separate game parts
-manually.  Alternatively, rename the files so that they match this pattern.
+Nitfol is copyright (c) Evin Robertson. It is released under the terms of the GNU General Public License.
 
+SCARE is copyright (c) Simon Baldwin. It is released under the terms of the GNU General Public License.
 
-Keyboard Polling
-----------------
-
-Some Level 9 games use the standard home microprocessor system method of
-waiting for a keypress, using a tight spin loop that samples the keyboard until
-a key is detected.  The Adrian Mole games use this keyboard sampling both for
-scroll pausing, and for their main menu selections, with something like:
-
-	for each line in the output paragraph
-		print the line
-		while (os_readchar() shows a key is pressed)
-			;
-		endwhile
-	endfor
-	selection = return value from os_readchar()
-	while (selection shows no key is pressed)
-		selection = return value from os_readchar()
-	handle selection...
-
-This means that os_readchar() _must_ be implemented according to the notes in
-Level 9's porting.txt.  That is, it must poll the keyboard for key presses,
-and return the key code if a key is pressed, or zero if no key is currently
-pressed.
-
-If os_readchar() waits for a key press on each call, Adrian Mole games will
-wait for a key press after each output line, which is not what we want.  On the
-other hand, if it doesn't wait for a key press at the menu selection point, the
-interpreter will consume all the available system CPU time, which is also very
-undesirable on a multi-tasking operating system.
-
-To solve this, Glk Level 9 uses two different techniques, and which it chooses
-depends on whether the Glk library it is linked with has timers.
-
-If the Glk library has timers, then on each call to os_readchar(), Glk Level 9
-starts a timeout for a short period, then waits for either a key press event,
-or a timeout.  If it receives a key press, it returns the code, otherwise it
-returns zero.  This lets games run correctly.  Continually cycling through the
-Glk timeout is fast enough to be acceptable to a player, but the timeout
-provides good protection against spinning wildly in a tight loop.
-
-If the Glk library does not have timers, then the interface will return zero
-for some large number of consecutive calls, then wait until a character is
-entered.  Since the initial number is large, this allows the game to progress,
-generally, to the point where it needs a key press to continue at all.  The
-only thing that might show slightly odd behaviour is the DEMO mode of Adrian
-Mole games.
-
-Also, this type of character polling cannot be used with reading input logs.
-So the Glk "readlog" command does not function with Adrian Mole games.
-
-To pretend that no key was pressed, when the interface is in fact waiting for
-a key press, you can type Control-U.  The Glk interface will return this to
-the game as a zero.
-
-Games that rarely, or never, use line input, but continually poll for input
-using os_readchar(), are difficult to stop.  To help with this, Glk Level 9
-offers Control-C as as way to quit the game, with a confirmation as for "quit"
-above.  Note that Control-C will only work when the game is using os_readchar()
-(that is, most of the time for Adrian Mole games, and occasionally, if ever,
-in other games).  For normal line input, use "quit" as described above.
+ScottFree is copyright (c) Alan Cox. It is released under the terms of the GNU General Public License.
 
-Control-C is turned off by the command line option "-nc".
+TADS is copyright (c) Michael J. Roberts. It is released under the terms of the GNU General Public License.
 
+The Linux Libertine fonts are copyright (c) Philipp H. Poll. They are released under the terms of the SIL Open Font License.
 
-A Few Last Words on Graphics
-----------------------------
+The Liberation fonts are copyright (c) Red Hat, Inc. They are released under the terms of the Liberation License.
 
-When turning graphics on and off with Glk commands, you should pay special
-attention to whether graphics are turned on or off in the game.  In order for
-graphics to be displayed, they must be turned on both in the game AND in Glk.
-Turning off graphics in Glk is a little more permanent than turning them off
-in a game; in fact, some games don't seem to allow you to turn off graphics
-within the game at all.
+The Noto Serif fonts are copyright (c) 2012, Google Inc. They are released under the terms of the SIL Open Font License (OFL), version 1.1.
 
-Why a secondary Glk way to turn off pictures?  Well, Level 9 games don't always
-behave the same way with the "graphics" and "text" commands, so a control
-inside Glk Level 9 itself gives a more consistent way to turn graphics on and
-off.  The command
+The Go Mono fonts are copyright (c) 2016 Bigelow & Holmes Inc. They are released under the terms of the 3-clause BSD license.
 
-	glk graphics
-
-with no on/off argument, prints out a brief information about the current state
-of a game's graphics.  In practice, it's probably best to stick to just one
-method of turning graphics on and off -- either the game's own way, or the
-'glk graphics' command if the former is not available.
-
-Glk Level 9 does not display all of the line drawn graphics correctly in a
-handful of games.  Games known to not display all graphics fully correctly are
-"Erik the Viking" (Spectrum, v2), "Return to Eden" (Spectrum48, v3), and
-"Price of Magik" (Spectrum48, v3).
-
-
---
-
-Simon Baldwin, simon_baldwin@yahoo.com
+The authors assume no liability for damages or loss of revenue resulting from the use of any of the software herein. The software is supplied "as is" and carries no warranty, actual or implied.
 
+ +

INFORM 6.34 (6.12 LIBRARY)

+

Website +

-Level 9 Interpreter v5.1
+The compiler and standard library for Inform6 are licensed under
+1) The traditional Inform license as described by the DM4, or
+2) The Artistic License 2.0.
 
-An interpreter for Level 9 games in any format,
-including Spectrum snapshots.
+The user is free to choose which license to accept, i.e., free to choose
+either set of terms and conditions.
+
+Here is the relevant bit from the Inform Designer's Manual, 4th edition:
 
-Copyright (c) 1996-2011 Glen Summers and contributors.
-Contributions from David Kinder, Alan Staniforth,
-Simon Baldwin, Dieter Baron and Andreas Scherrer.
+      Copyright on Inform, the program and its source code, its example
+      games and documentation (including this book) is retained by Graham
+      Nelson, who asserts the moral right to be identified as the author
+      under the Copyrights, Designs and Patents Act 1988.  Having said
+      this, I am happy for it to be freely distributed to anybody who wants
+      a copy, provided that: (a) distributed copies are not substantially
+      different from those archived by the author, (b) this and other
+      copyright messages are always retained in full, and (c) no profit is
+      involved.  (Exceptions to these rules must be negotiated directly
+      with the author.)  However, a story file produced with the Inform
+      compiler (and libraries) then belongs to its author, and may be sold
+      for profit if desired, provided that its game banner contains the
+      information that it was compiled by Inform, and the Inform version
+      number.
 
-Level9 is released under the terms of the GNU General
-Public License Version 2. See the file COPYING that is included
-with this program for details.
+* The license status of the contributed material (demos, include, tutor) is
+  what it says in each file.
 
@@ -3568,386 +674,6 @@

LINUX LIBERTINE AND BIOLINUM FONTS 5.3.0

-

MAGNETIC 2.3

-

- Website -

- -
-
-Magnetic Scrolls Interpreter, Glk Notes
----------------------------------------
-
-
-Introduction
-------------
-
-This is a port of the Magnetic Scrolls interpreter to Glk.  The complete
-interface lives in the single file
-
-	glk.c
-
-The main test and development system for the port is Linux, with Xglk as the
-Glk library.
-
-
-Acknowledgments
----------------
-
-Thanks to David Kinder for hints and tips on how to go about the port, and of
-course to Niclas Karlsson and his collaborators for the underlying Magnetic
-Scrolls interpreter, which looks like it probably wasn't a lot of fun to work
-on at times.
-
-Thanks also to Ben Hines  for the Mac code.  I've
-copied in from AGiliTy with, I think, the appropriate modifications, but it's
-untested at present.
-
-
-Running Games
--------------
-
-The interpreter understands game files that use the "Magnetic Scrolls" data
-format.  A file in this format usually has the extension ".MAG" or ".mag", and
-has "MaSc" in its first four data bytes.
-
-Give the name of the game file to run at the system prompt.  For example
-
-	glkmagnetic GUILD.MAG
-
-If the game has an associated graphics file, normally a file that has the
-extension ".GFX" or ".gfx", make sure that it is in the same directory as the
-main data file, and has the same base name.  For example, the matching graphics
-file for "GUILD.MAG" is "GUILD.GFX".  The Glk interpreter will find this file
-automatically, if it exists, and use it to create game pictures.
-
-The game may also have an associated hints file, with the extension ".HNT" or
-".hnt".  Like the graphics file, make sure it is in the same directory as other
-game files, and with the same base name, and the Glk interpreter will find the
-file automatically.  Hints files apply only to the later Magnetic Windows
-games, so not all the games you find will have them.  Also, hints for several
-games may be combined into a single file, so you might need to copy, or link,
-a file such as "COLL.HNT" to "CCORRUPT.HNT" to match with a "CCORRUPT.MAG"
-file.
-
-If there is no graphics file, the interpreter will run in text only mode.  It
-will also do this if it cannot open the graphics file, or if the file does not
-seem to contain game graphics.
-
-If there is no hints file, the interpreter will not be able to display game
-hints, but will otherwise run normally.
-
-As a short cut, you can omit the game extension, so for example
-
-	xmagnetic GUILD
-
-will run GUILD.MAG, and also use pictures from GUILD.GFX, and hints from
-GUILD.HNT, if either or both are available.
-
-Because of the way the Glk interpreter looks for files, you should make sure
-that the games are held in files with ".MAG" or ".mag" extensions, and any
-associated graphics and hints are held in files with ".GFX" or ".gfx" and
-".HNT" or ".hnt" extensions respectively.  Games held in files with other
-extensions may not work.
-
-There are a few command line options that you can add to vary the way that
-the game looks:
-
-	-np	Don't display game pictures initially
-	-ng	Don't automatically gamma correct game picture colours
-	-nx	Don't animate game pictures
-	-ne	Don't add an extra prompt on line input
-	-na	Don't expand single-letter abbreviations
-	-nc	Don't attempt to interpret selected commands locally
-
-See below for further information about what these options mean.
-
-
-Extra Prompting
----------------
-
-Magnetic Scrolls games always prompt with ">" when they are expecting input.
-However, Magnetic Windows ones are sometimes strangely silent, for example
-after receiving an empty line, they don't issue a second prompt.
-
-To try to make it a little clearer to see what's going on, Glk Magnetic will
-add its own ">" prompt when the game is expecting line input, but only when it
-determines that the game has not already issued its own prompt.
-
-You can turn this off with the '-ne' option.
-
-
-Displaying Pictures
--------------------
-
-Magnetic Scrolls games generally come with attractive graphics, and while not
-essential to the game, they do enhance the experience of playing.
-
-Unfortunately, Glk does not provide a method to directly display an image
-bitmap, so Glk Magnetic needs to adopt some tricks to get a picture to display.
-The end result is that, on Linux Xglk at least, it can take several seconds to
-render a complete picture.
-
-To reduce the problems caused by a game pausing for several seconds for a
-picture,  Glk Magnetic does its picture rendering using a background "thread".
-This draws in the complete picture over a series of smaller image updates,
-while at the same time still allowing game play.  To speed up picture
-rendering, Glk Magnetic also goes to considerable effort to try to minimize
-the amount of Glk graphics operations it uses.
-
-If you move to a location with a new picture before the current one has been
-fully rendered, Glk Magnetic will simply start working on the newer picture.
-
-Most Magnetic Windows and Magnetic Scrolls games accept the "graphics" command,
-which toggles pictures on and off.  Magnetic Scrolls games usually start with
-graphics enabled, but for some reason Magnetic Windows games tend to start
-with graphics disabled.  To get pictures, type "graphics" as more or less the
-first game command.
-
-You can use the "-np" option to turn off pictures.  Glk Magnetic also will not
-show pictures if the Glk library does not support both graphics and timers, if
-there is no suitable ".GFX" or ".gfx" graphics file, or if the interpreter
-cannot open the graphics file successfully.  See below for further notes about
-displaying pictures.
-
-
-Animated Pictures
------------------
-
-Some of the pictures in later Magnetic Windows games are animated, and Glk
-Magnetic will animate those pictures.
-
-Animations stretch the bitmap display capabilities of Glk even further than
-static pictures do.  Glk Magnetic uses several optimizations to try to reduce
-the graphics load on the system, and in particular animates only the portions
-of a picture that change between frames.  As a result, pictures with modest
-animations work well; pictures with large animated areas may however not
-display as effectively.  Fortunately, most of the animated pictures in
-Magnetic Windows games don't require large graphics repaints between frames.
-
-The speed and smoothness of animations will probably also depend on the CPU
-speed of your system, and on the graphics card, in particular any graphics
-acceleration, available.
-
-As with static pictures, Glk Magnetic interleaves animation frames with game
-play using a background "thread", if necessary breaking individual animation
-frames into pieces so that that game play is not interrupted for too long.
-
-You can use the "-nx" option to turn off picture animation.  Glk Magnetic will
-then display just the static portions of a game's pictures.
-
-
-Gamma Colour Corrections
-------------------------
-
-Some of the Magnetic Scrolls pictures look fine without gamma corrections.  On
-the other hand, others, in particular those in "Corruption", and several from
-"Wonderland", can look very dark if not corrected.
-
-To try to adjust for this, Glk Magnetic will apply an automatic gamma
-correction to each picture.  It selects a suitable gamma based on analyzing the
-colours that the picture uses, and choosing one that gives reasonable colour
-contrast.
-
-There are two levels of automatic gamma correction: 'normal' and 'high'.  In
-normal mode, the gamma correction is half of that needed to completely even
-out the contrast between picture colours, offering a reasonable balance between
-the amount of picture brightening and garish or faded colours.  In high mode,
-the gamma correction is that needed to fully even out the contrast between
-picture colours.  Use "glk gamma" when in a game to switch between these modes,
-or to turn gamma correction off altogether.
-
-You can use the "-ng" option to turn off gamma colour corrections.  In this
-case, all pictures are displayed using their original colour palette.
-
-
-Game Hints
-----------
-
-Where a game comes with hints (Wonderland, and the "collection" games), Glk
-Magnetic will try to display them if possible.
-
-For Glk libraries that support separate windows, Glk Magnetic shows hints in a
-pair of windows which overlay the main game text window.  The upper hint
-window gives a menu of hint topics.  The lower one shows the game hints one at
-a time.
-
-For Glk libraries that don't support separate windows, Glk Magnetic shows hints
-in the main game window, using the best formatting it can arrange.
-
-Glk Magnetic will not show hints if there is no suitable ".HNT" or ".hnt" hints
-file, or if the interpreter cannot open the hints file successfully.
-
-
-Status Line
------------
-
-Magnetic Scrolls games print a status line, and Glk Magnetic will display this
-in a separate window above the main window, for Glk libraries that support
-separate windows.
-
-For other Glk libraries, Glk Magnetic will print the status line in "[...]"
-brackets above the standard game output following each turn, but only when the
-status line has changed since the last turn.
-
-Note that Magnetic Windows games generally do not print a status line.  For
-these games, Glk Magnetic will instead try to identify the game's title, and
-display it, if identifiable, on the status line.
-
-
-Expanding Abbreviations
------------------------
-
-Many IF games systems allow a player to use single character abbreviations for
-selected common commands, for example, 'x' for 'examine', 'l' for look, and so
-on.  Not all Magnetic Scrolls games offer this feature, however.
-
-To try to help the player, Glk Magnetic will automatically expand a selection
-of single character commands, before passing the expanded string to the game
-as input.  It expands a command only if the first word of the command is a
-single letter, and one of the following:
-
-	'c' -> "close"		'g' -> "again"		'i' -> "inventory"
-	'k' -> "attack"		'l' -> "look"		'p' -> "open"
-	'q' -> "quit"		'r' -> "drop"		't' -> "take"
-	'x' -> "examine" 	'y' -> "yes"		'z' -> "wait"
-
-If you want to suppress abbreviation expansion, you can prefix your input with
-a single quote character (like putting literal strings into a spreadsheet).
-If you do this, the Glk interface will strip the quote, then pass the rest of
-the string to the main interpreter without any more changes.  So for example,
-
-	'x something
-
-will pass the string "x something" back to the game, whereas
-
-	x something
-
-will pass "examine something" back to the game.
-
-You can turn off abbreviation expansions with the command line option '-na'.
-
-
-Interpreting Commands Locally
------------------------------
-
-Glk Magnetic will handle special commands if they are prefixed with the string
-'glk'.  It understands the following special commands:
-
-	help		  Prints help on Glk special commands
-	summary		  Prints all current Glk settings
-	version		  Prints the Glk library and Glk port version numbers
-	license		  Prints the Glk port license
-
-	undo		  Undoes the prior game move
-	script on	  Starts recording the game text output sent to the
-			  main game window
-	script off	  Turns off game text recording
-	inputlog on	  Starts recording input lines typed by the player
-	inputlog off	  Stops recording input lines
-	readlog on	  Reads an input log file as if it had been typed by
-			  a player; reading stops automatically at the end of
-			  the file
-	abbreviations on  Turn abbreviation expansion on
-	abbreviations off Turn abbreviation expansion off
-	graphics on	  Turn on Glk graphics
-	graphics off	  Turn off Glk graphics (see below)
-	gamma normal	  Set automatic gamma colour correction mode to normal
-	gamma high	  Set automatic gamma colour correction mode to high
-	gamma off	  Turn automatic gamma colour correction off
-	animations off	  Turn picture animation off
-	animations on	  Turn picture animation on
-	prompts on	  Turn extra "> " prompting on
-	prompts off	  Turn extra "> " prompting off
-	commands off	  Turn of Glk special commands; once off, there is no
-			  way to turn them back on
-
-You can abbreviate these commands, as long as the abbreviation you use is
-unambiguous.  To improve compatibility with other IF games systems, Glk
-Magnetic also recognizes the single word command "undo" as being equivalent
-to "glk undo".
-
-If for some reason you need to pass the string "glk" to the interpreter, you
-can, as with abbreviations above, prefix it with a single quote character.
-
-You can turn off local command handling with the command line option '-nc'.
-
-If both abbreviation expansion and local command handling are turned off, there
-is no need to use single quotes to suppress special interpreter features.
-
-
-A Few Last Words on Graphics
-----------------------------
-
-When turning graphics on and off with Glk commands, you should pay special
-attention to whether graphics are turned on or off in the game.  In order for
-graphics to be displayed, they must be turned on both in the game AND in Glk.
-Turning off graphics in Glk is a little more permanent than turning them off
-in a game.  In some games, turning graphics off seems to mean do not display
-new pictures, but leave the current picture on the display; turning off
-graphics in Glk closes the graphics display window completely.
-
-What can also be confusing is the tendency of Magnetic Windows games to display
-a picture automatically only on your first visit to a game location, unless in
-'verbose' mode.  On subsequent visits, a "look" command is needed to redisplay
-the picture.  This appears not to happen with Magnetic Scrolls games.
-
-Why an additional Glk way to turn off pictures?  Well, the Magnetic Windows and
-Magnetic Scrolls games don't always behave the same way with the "graphics"
-command, so a control inside Glk Magnetic itself gives a more consistent way
-to turn graphics on and off.  The command
-
-	glk graphics
-
-with no on/off argument, prints out a brief information about the current state
-of a game's graphics.  In practice, it's probably best to stick to just one
-method of turning graphics on and off -- either the game's own way, or the
-'glk graphics' command.
-
-
---
-
-Simon Baldwin, simon_baldwin@yahoo.com
-
-
- -
-
-Magnetic - Magnetic Scrolls Interpreter.
-
-Written by Niclas Karlsson ,
-            David Kinder ,
-            Stefan Meier  and
-            Paul David Doherty 
-
-Copyright (C) 1997-2008  Niclas Karlsson
-
-     This program is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published by
-     the Free Software Foundation; either version 2 of the License, or
-     (at your option) any later version.
-
-     This program is distributed in the hope that it will be useful,
-     but WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-     GNU General Public License for more details.
-
-GLK Port
---------
-
-Thanks to David Kinder for hints and tips on how to go about the port, and of
-course to Niclas Karlsson and his collaborators for the underlying Magnetic
-Scrolls interpreter, which looks like it probably wasn't a lot of fun to work
-on at times.
-
-Thanks also to Ben Hines  for the Mac code.  I've
-copied in from AGiliTy with, I think, the appropriate modifications, but it's
-untested at present.
-
--- Simon Baldwin, simon_baldwin@yahoo.com
-
-
-

NAMED REGEX 0.2.5

Website

@@ -3969,446 +695,6 @@

NAMED REGEX 0.2.5

-

SCARE 1.3.10

-

Website

- -
-
-
-SCARE is secondary clone of jAsea, Mark J. Tilford's Java GPL clone of the
-Adrift Runner.
-
-It aims to provide an ANSI/ISO C core Adrift interpreter, capable of running
-Adrift version 4.00, version 3.90, and version 3.80 games, and portable enough
-to run on Linux, Windows, DOS, Macintosh, Amiga, or any platform that offers
-an ANSI/ISO C compiler.
-
-For details on building SCARE, please see the file BUILDING.  For details on
-porting SCARE to various input/output schemes, please see PORTING.  For
-details on running Adrift games in SCARE, please see RUNNING.  For details on
-the game debugger in SCARE, please see DEBUGGER.  For details on SCARE's test
-suite, please see TESTING.  For details on compatibility with the Adrift
-Runner, please see FEATURES.
-
-SCARE is based on jAsea.  For more information on jAsea, please visit
-
-    http://sourceforge.net/projects/jasea
-
-SCARE also contains copious code from Zlib, to the point where it actually
-carries around a full copy of the Zlib source within it.  Zlib is
-
-    Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
-
-    Jean-loup Gailly        Mark Adler
-    jloup@gzip.org          madler@alumni.caltech.edu
-
-The SCARE source code is released under the GPL.  The ubiquitous COPYING file
-contains everything you need to know on that.
-
-SCARE's home on the Web is in the IF Archive, under programming/adrift.
-
-Thanks to Jan-Erik Karlsson for work on SCARE for Amiga; Uli Kusterer for work
-on the Macintosh SCARE build; Thomas Payerle for slogging through the Adrift
-version 3.90 TAF file format; Rik Snel for his work to uncovering the TAF file
-obfuscation used by Adrift versions 3.90 and 3.80; David Kinder for the
-Windows specific Glk startup code; Emily Short for uncovering bugs that only
-showed up well into a couple of games; Robert Goodwin, Richard Otter, Eric
-Mayer, Todd Watson, Nick Rogers, and Sam Trenholme for miscellaneous bug
-reports; and David Whyld for bug reports and detailed game walkthroughs for
-reference and testing.
-
-And, of course, to Mark J. Tilford who started this whole thing in the first
-place with jAsea, providing almost all of the Adrift reverse engineering that
-SCARE uses.  Without jAsea, there would be no SCARE.
-
-Simon Baldwin, simon_baldwin@yahoo.com
-
-
- -
-
-SCARE is secondary clone of jAsea, Mark J. Tilford's Java GPL clone of the
-Adrift Runner.
-
-It aims to provide an ANSI/ISO C core Adrift interpreter, capable of running
-Adrift version 4.00, version 3.90, and version 3.80 games, and portable enough
-to run on Linux, Windows, DOS, Macintosh, Amiga, or any platform that offers
-an ANSI/ISO C compiler.
-
-For details on building SCARE, please see the file BUILDING.  For details on
-porting SCARE to various input/output schemes, please see PORTING.  For
-details on running Adrift games in SCARE, please see RUNNING.  For details on
-the game debugger in SCARE, please see DEBUGGER.  For details on SCARE's test
-suite, please see TESTING.  For details on compatibility with the Adrift
-Runner, please see FEATURES.
-
-SCARE is based on jAsea.  For more information on jAsea, please visit
-
-    http://sourceforge.net/projects/jasea
-
-SCARE also contains copious code from Zlib, to the point where it actually
-carries around a full copy of the Zlib source within it.  Zlib is
-
-    Copyright (C) 1995-2005 Jean-loup Gailly and Mark Adler
-
-    Jean-loup Gailly        Mark Adler
-    jloup@gzip.org          madler@alumni.caltech.edu
-
-The SCARE source code is released under the GNU General Public Licence
-Version 2. The ubiquitous COPYING file contains everything you need
-to know on that.
-
-SCARE's home on the Web is in the IF Archive, under programming/adrift.
-
-Thanks to Jan-Erik Karlsson for work on SCARE for Amiga; Uli Kusterer for work
-on the Macintosh SCARE build; Thomas Payerle for slogging through the Adrift
-version 3.90 TAF file format; Rik Snel for his work to uncovering the TAF file
-obfuscation used by Adrift versions 3.90 and 3.80; David Kinder for the
-Windows specific Glk startup code; Emily Short for uncovering bugs that only
-showed up well into a couple of games; Robert Goodwin, Richard Otter, Eric
-Mayer, Todd Watson, Nick Rogers, and Sam Trenholme for miscellaneous bug
-reports; and David Whyld for bug reports and detailed game walkthroughs for
-reference and testing.
-
-And, of course, to Mark J. Tilford who started this whole thing in the first
-place with jAsea, providing almost all of the Adrift reverse engineering that
-SCARE uses.  Without jAsea, there would be no SCARE.
-
-Simon Baldwin, simon_baldwin@yahoo.com
-
-
- -

SCOTT 1.14

-

Website -

- -
-
-This is my second serious production edition of the Scott Adams game
-player. It needs curses (or an equivalent - eg pccurses. A non-curses
-port should be easy too), and an ANSI C compiler.
-
-This code has been tested on a SUN3(SunOS 4.1.1) and on a Pyramid 9820 in
-the att universe.
-
-
-Operation
----------
-
-ScottFree reads and executes TRS80 format Scott Adams datafiles. It is
-possible to run other formats either by writing a loader for that format or
-a convertor to TRS80 format. Remember the Scott Adams games are still
-copyright - you need to buy or obtain the games legally for use with this
-interpreter. Some Scott Adams material is available fairly freely . Dec 1980
-Byte contains a game driver and also a program to write a version of Pirate
-Adventure. A PC-SIG disk contains Adventureland in BASIC with a database in
-DATA statements. The file 'Definition' in this archive explains the TRS80
-format as I believe it exists. Much of this definition comes from P.D.Doherty
-who provided a lot of information.
-
-ScottFree should run all the Scott Adams, Brian Howarth and some other
-Adventure International games. (Gremlins and Supergran have a compressed
-action table,  Robin Of Sherwood and Seas Of Blood have both a compressed
-action table and compressed text.  Seas Of Blood won't run straight off due
-to the bizarre Fighting Fantasy (tm) combat system built into it.)
-
-Command Options
----------------
-
-ScottFree [flags]  [save-file]
-
-Specifying save-file causes a restore of the save to take place.
-
-The flags are
-
--d	Debugging info on load
--i	Generate 'I am' type messages (default)
--y	Generate 'You are', 'You are carrying' type messages for games that
-	use these instead (eg Robin Of Sherwood)
--s	Generate authentic Scott Adams driver light messages rather than
-	other driver style ones (Light goes out in %d turns..)
--t	Generate TRS80 style display (terminal width is 64 characters; a
-	line <-----------------> is displayed after the top stuff; objects
-	have periods after them instead of hyphens
-
-
-Statement Of Copyright/License
-------------------------------
-
-This software is supplied subject to the GNU software copyleft (version 2)
-available from GNU or for FTP from prep.ai.mit.edu. All material in this
-program was developed by Swansea University Computer Society without
-disassembly of any other game drivers, only of game databases as permitted
-by EEC law (for purposes of compatibility). It is your responsibility not
-to transfer this software to any country where such reverse engineering is
-not permitted. This software license does not include any rights with
-regards to the Scott Adams games themselves. These games are copyright and
-you should obtain them from a legal source.
-
-The following information sources were used to produce the game driver:
-
-PC-SIG disk of Adventureland:
-	This gives the Adventureland database as well as about 80% of the
-full interpreter system. The core of the gamedriver was written using this
-as a reference to the game code.
-
-Byte Dec 1980:
-	This contains a good article about Scott and his games, as well as
-a TRS80 driver and datafile writer for the 'Pirate Adventure' game. This
-filled in some more answers as well as bits of the TRS80 data format
-
-P.D.Doherty:
-	Many thanks go to him for figuring out a load more actions, testing,
-hunting for games which used unknown actions and for writing a Scott Adams
-database to readable text convertor. This helped resolve several other
-actions.
-
-
-Changes 1.14
-------------
-
-o	Bit flag 16 support
-o	Lamp behaviour flag '-p' for prehistoric databases which don't use
-	bit 16
-o	Light out messages don't appear when the lamp is elsewhere.
-o	Automatic get/drop has synonym support.
-
-Changes 1.13
-------------
-
-o	Darkness is now done like the actual Scott driver seems to do it,
-	using bit flag 15. Fixes problems in The Count
-o	Display problem with 4.4BSD curses fixed (added a wmove() call)
-o	Can't TAKE ALL in a dark room.
-
-Changes 1.12a
--------------
-
-o	Merged in some fixes by Steve Rice 
-	(Variables for terminal size, wrong wraparound due to bug in Look(),
-	TRS80 style option)
-o	Updated PC version.
-
-Changes 1.12
-------------
-
-o	Merged in some fixes by Antoine Sabot-Durand 
-	(Redraw in dark rooms, darkness flag testing, Action 74 bug).
-	'Pirate Adventure' should now work.
-o	Added some comments
-o	Added a makefile
-o	Fixed several missing redraws.
-
-Changes 1.11
-------------
-
-o	Major bug in file reading routines fixed. This should now read
-	_ALL_ the Scott Adams files without you having to add spaces.
-o	Knows about the use of // in item texts and correctly handles it.
-o	Uses unsigned char for the location of an item so that it correctly
-	behaves like the spectrum editions on wrapping. This makes a lot
-	more of the Brian Howarth material work.
-o	Rewrote the awful OutBuf() function to be a bit neater.
-o	Messed up the neat OutBuf() function by supporting old BSD curses
-	too. Linux people and 386BSD people should now be in luck, as
-	should any old BSD4.x users.
-o	TAKE ALL/DROP ALL. Emulates Brian Howarth driver including the
-	number of moves bug.
-	NOTE:: TAKE ALL/DROP ALL count as one move. In some games that
-	give limited moves for things this makes it easier or enables
-	you to do things you should not be able to. The Brian Howarth
-	games all have this feature and should be fine.
-o	Started work on an Xview version - don't expect it just yet.
-o	Fixed a major cockup in the execution rules for lines. Robin Of
-	Sherwood lets you out of the cell without killing you at last.
-o	Place item -> location failed with some compilers (most), now
-	made portable.
-o	WAIT action refreshes display first
-o	Redraws any pending display changes before the status table
-o	Option flags tidied up.
-
-Changes 1.10
-------------
-
-o	Action 75 added (dunno how it was missed)
-o	Corrected second Byte year reference
-
-Changes 1.9
------------
-
-o	Inventory short cut
-o	Swap room flag/location now fixed. This should make Claymorgue work
-	correctly (ha!).
-o	Corrected Byte reference from 1990 to 1980.
-
-Changes 1.8
------------
-
-o	Move location action sets the redraw flag
-o	Driver ignored last line of table (now fixed)
-o	Save/Load implemented.
-o	N,E,S,W,U,D shortcuts added. I will add the item ones once I've
-	loaded a few more fake saves into the genuine Brian Howarth driver
-	to figure out how it works.
-
-To Do
------
-
-o	Tidy up TAKE ALL/DROP ALL. They match the Spectrum version -
-	which appears to be buggy. Also note that using GET ALL / DROP ALL
-	with older games _MAY_BREAK_THINGS_. Maybe this should be a flagged
-	option.
-
-
- -
-
-This software is supplied subject to the GNU software copyleft (version 2)
-available from GNU or for FTP from prep.ai.mit.edu. All material in this
-program was developed by Swansea University Computer Society without
-disassembly of any other game drivers, only of game databases as permitted
-by EEC law (for purposes of compatibility). It is your responsibility not
-to transfer this software to any country where such reverse engineering is
-not permitted. This software license does not include any rights with
-regards to the Scott Adams games themselves. These games are copyright and
-you should obtain them from a legal source.
-
-The following information sources were used to produce the game driver:
-
-PC-SIG disk of Adventureland:
-	This gives the Adventureland database as well as about 80% of the
-full interpreter system. The core of the gamedriver was written using this
-as a reference to the game code.
-
-Byte Dec 1980:
-	This contains a good article about Scott and his games, as well as
-a TRS80 driver and datafile writer for the 'Pirate Adventure' game. This
-filled in some more answers as well as bits of the TRS80 data format
-
-P.D.Doherty:
-	Many thanks go to him for figuring out a load more actions, testing,
-hunting for games which used unknown actions and for writing a Scott Adams
-database to readable text convertor. This helped resolve several other
-actions.
-
-
- -

TADS 2/3 + FrobTADS

-

Website

- -
-
-TADS 2 FREEWARE SOURCE CODE LICENSE
-
-The TADS 2 source code is Copyright 1991, 2003 by Michael J. Roberts.
-
-The author hereby grants you permission to use, copy, and
-distribute this software, if you agree to the following conditions:
-
-    1. You must include this license and the copyright notice with
-       all copies.
-    2. You may not require or collect a fee for copies of this
-       software, or any part of this software, that you give to
-       other people.
-    3. You may not include this software with any other software
-       for which a fee is collected.
-    4. You may not modify this software except as permitted below
-       (see "derivative works"), and each copy you make and
-       distribute must be a full and complete copy of the software
-       you originally received.
-    5. Anyone to whom you give a copy of this software receives
-       all of the same permissions that you did under this license
-       and is subject to all of the same restrictions.
-    6. You are not allowed to create derivative works, which are
-       works that contain or are based on all or part of this work,
-       except under the conditions described below.
-    7. Any derivative works are subject to this same license.
-
-
-Derivative Works
-----------------
-
-This source code is distributed for the specific purpose of
-facilitating the creation of versions of TADS on various computers and
-operating systems.  All other derivative works are prohibited without
-the written permission of the author.  Please contact the author if
-you have any questions about this or if you'd like permission to
-create a derived work.
-
-If you port TADS to a new platform, the author does grant permission
-for you to distribute your ported version - I encourage it, in fact.
-We ask that you provide your contact information in any distribution
-package you create, so that users of your version will know how to
-contact you if they have any questions relating specifically to your
-version.
-
->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-TADS 3 FREEWARE SOURCE CODE LICENSE
-
-The TADS 3 source code is Copyright 1998, 2012 by Michael J. Roberts.
-
-The author hereby grants you permission to use, copy, and distribute
-this software, if you agree to the following conditions:
-
-    1. You must include this license and the copyright notice with
-       all copies.
-    2. You may not require or collect a fee for copies of this
-       software, or any part of this software, that you give to
-       other people.
-    3. You may not include this software with any other software
-       for which a fee is collected.
-    4. You may not modify this software except as permitted below
-       (see "derivative works"), and each copy you make and
-       distribute must be a full and complete copy of the software
-       you originally received.
-    5. Anyone to whom you give a copy of this software receives
-       all of the same permissions that you did under this license
-       and is subject to all of the same restrictions.
-    6. You are not allowed to create derivative works, which are
-       works that contain or are based on all or part of this work,
-       except under the conditions described below.
-    7. Any derivative works are subject to this same license.
-
-
-Derivative Works
-----------------
-
-This source code is distributed for the specific purpose of porting
-TADS, so that you can run the software on any system of your choosing.
-All other derivative works are prohibited without the written
-permission of the author.  I want to avoid the creation of variations
-on the system, because it leads to confusion on the part of users if
-there are multiple incompatible flavors floating around.  However, if
-you have a specific idea in mind, I'd be happy to at least consider
-it.  Please contact the author if you have any questions about this or
-if you would like permission to create a derived work.
-
-If you port TADS to a new platform, the author does grant permission
-for you to distribute your ported version - I encourage it, in fact.
-I ask that you include your contact information in any distribution
-package you create, so that users of your version will know how to
-contact you if they have any questions relating specifically to your
-version.
-
->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
-FROBTADS LICENSE
-
-Copyright (c) Nikos Chantziaras.
-
-This software is distributed under the terms and conditions of the
-"TADS 3 FREEWARE SOURCE CODE LICENSE".  The text of this license can be
-found in tads3/LICENSE.TXT, as included in the packaging of this file.
-
-Note to distributors and packagers:
-
-The license does not permit distribution of this software if a fee is
-collected for this service, nor inclusion of this software with other
-software for which a fee is collected without the maintainer's
-permission.
-
-
-
-

Additional Acknowledgements

Special thanks to:

@@ -5455,4 +1741,4 @@

Standard Licences

- \ No newline at end of file + diff --git a/app/src/main/jni/CMakeLists.txt b/app/src/main/jni/CMakeLists.txt index 33de0aa..27cb2e1 100644 --- a/app/src/main/jni/CMakeLists.txt +++ b/app/src/main/jni/CMakeLists.txt @@ -50,7 +50,7 @@ target_link_libraries( glk target_include_directories ( glk PRIVATE - terps glk ) + garglk/terps glk ) ################################################################# # TERPS @@ -58,15 +58,9 @@ target_include_directories ( glk ################################################################# # ADVSYS + ANSI + NewParser + parts of glkize -# http://www.ifarchive.org/indexes/if-archiveXprogrammingXadvsys.html -# Rather than muck around applying patches, we just use Gargoyle's -# version of the code. -# -# Changes: -# - none ################################################################# addprefix( ADVSYS_SRC - terps/advsys + garglk/terps/advsys advmsg.c advtrm.c advprs.c advdbs.c advint.c advjunk.c advexe.c glkstart.c ) add_library( advsys @@ -83,16 +77,10 @@ target_link_libraries( advsys target_include_directories( advsys PRIVATE - terps/advsys terps glk ) + garglk/terps/advsys garglk/terps glk ) ################################################################# # AGILITY 1.1.1 -# http://www.ifarchive.org/if-archive/programming/agt/agility/agil111src_glk.zip -# -# Changes (see agility.diff): -# - os_glk.c: as with Gargoyle version, make gagt_get_user_file -# use GLK prompting rather than ask for a text name or do -# "bad voodoo". To enable this, define GARGLK. ################################################################# set( BASE agtread.c gamedata.c util.c agxfile.c auxfile.c filename.c ) @@ -105,7 +93,7 @@ set( INTERFACE interface.c os_glk.c ) addprefix( AGIL_SRC - terps/agility + garglk/terps/agility ${BASE} ${AGIL} ${INTERFACE} ) add_library( agility @@ -123,22 +111,10 @@ target_link_libraries( agility target_include_directories( agility PRIVATE - terps/agility terps glk utilities ) + garglk/terps/agility garglk/terps glk utilities ) ################################################################# # ALAN 2.8.7 -# http://www.alanif.se/21-downloads/download-v2 -# -# Changes (see alan2.diff): -# - acode.h: use and portable definitions of Aword, Aaddr, -# Abool, Aint, CodeValue and WrdKind. -# -# - main.c: fix security vulnerability in logprint, -# replace fprintf(logfil, str) with fprintf(logfil, "%s", str) -# -# - exe.c: as with the Gargoyle version, change the -# save/restore code to use GLK prompting rather than -# ask for a text name. To enable this define GARGLK. ################################################################# set( GLKOBJS glkstart.c glkio.c ) @@ -148,7 +124,7 @@ set( OBJECTS stack.c decode.c term.c reverse.c readline.c params.c sysdep.c alan.version.c ) addprefix( ALAN2_SRC - terps/alan/alan2 + garglk/terps/alan2 ${GLKOBJS} ${OBJECTS} ) add_library( alan2 @@ -166,22 +142,17 @@ target_link_libraries( alan2 target_include_directories( alan2 PRIVATE - terps/alan/alan2 terps glk ) + garglk/terps/alan2 garglk/terps glk ) ################################################################# # ALAN V3.0beta5 -# https://www.alanif.se/download-alan-v3/source-code -# https://bitbucket.org/alanif/alan -# -# Changes -# - none ################################################################# set( GLKOBJS glkstart.c glkio.c ) set( OBJECTS act.c actor.c alan.version.c AltInfo.c args.c arun.c - attribute.c chartest.c checkentry.c class.c compatibility.c + attribute.c checkentry.c class.c compatibility.c Container.c current.c debug.c decode.c dictionary.c event.c exe.c fnmatch.c glkio.c glkstart.c instance.c inter.c lists.c literal.c Location.c main.c memory.c msg.c @@ -190,7 +161,7 @@ set( OBJECTS StateStack.c syntax.c sysdep.c syserr.c term.c types.c utils.c word.c ) addprefix( ALAN3_SRC - terps/alan/alan3/interpreter + garglk/terps/alan3 ${GLKOBJS} ${OBJECTS} ) add_library( alan3 @@ -208,17 +179,13 @@ target_link_libraries( alan3 target_include_directories( alan3 PRIVATE - terps/alan/alan3/interpreter terps glk ) + garglk/terps/alan3 garglk/terps glk ) ################################################################# # BOCFEL 1.0 -# https://cspiegel.github.io/bocfel/downloads.html -# -# Changes: -# - none ################################################################# addprefix( BOCFELMAIN - terps/bocfel + garglk/terps/bocfel blorb.c branch.c dict.c glkstart.c iff.c io.c math.c meta.c memory.c objects.c osdep.c patches.c process.c random.c screen.c sound.c stack.c unicode.c util.c zoom.c zterp.c ) @@ -238,23 +205,15 @@ target_link_libraries( bocfel target_include_directories( bocfel PRIVATE - terps/bocfel terps glk ) + garglk/terps/bocfel garglk/terps glk ) ################################################################# # GIT 1.3.5 -# https://github.com/DavidKinder/Git # N.B.: Don't compile with -DDIRECT_THREADING as this seems # to cause git to crash on some devices. -# -# Changes (see git.diff): -# - glkop.c: the original source assumes that GLK objects are -# referenced by (opaque) C pointers. But our GLK implementation -# is in Java. To work around this, pass GLK object IDs -# rather than pointers and remove C code relating to class -# registration / unregistration as this is done on the Java side. ################################################################# addprefix( GITMAIN - terps/git + garglk/terps/git git.c memory.c compiler.c opcodes.c operands.c peephole.c terp.c glkop.c search.c git_unix.c savefile.c saveundo.c gestalt.c heap.c accel.c ) @@ -274,17 +233,13 @@ target_link_libraries( git target_include_directories( git PRIVATE - terps/git terps glk ) + garglk/terps/git garglk/terps glk ) ################################################################# # GLULXE 0.5.4 -# http://eblong.com/zarf/glulx/index.html -# -# Changes (see glulxe.diff): -# - glkop.c: same as GIT, see above. ################################################################# addprefix( GLULXEMAIN - terps/glulxe + garglk/terps/glulxe main.c files.c vm.c exec.c funcs.c operand.c string.c glkop.c heap.c serial.c search.c accel.c float.c gestalt.c osdepend.c profile.c debugger.c unixstrt.c ) @@ -304,26 +259,18 @@ target_link_libraries( glulxe target_include_directories( glulxe PRIVATE - terps/glulxe terps glk ) + garglk/terps/glulxe garglk/terps glk ) ################################################################# # HUGO 3.1.03 -# http://www.generalcoffee.com/hugo/gethugo.html -# http://www.ifarchive.org/if-archive/programming/hugo/source/ -# -# Changes (see hugo.diff): -# - hemisc.c: fix two security vulnerabilities by -# replacing printf(line) with printf("%s", line). -# -# - heglk.c: include the gargoyle port's hemedia.c. ################################################################# addprefix( HUGOMAIN - terps/hugo/source + garglk/terps/hugo/source he.c heexpr.c hemisc.c heobject.c heparse.c heres.c herun.c heset.c stringfn.c ) addprefix( HUGOGLK - terps/hugo/heglk + garglk/terps/hugo/heglk heglk.c heglkunix.c ) add_library( hugo @@ -341,19 +288,13 @@ target_link_libraries( hugo target_include_directories( hugo PRIVATE - terps/hugo/heglk terps/hugo/source terps glk ) + garglk/terps/hugo/heglk garglk/terps/hugo/source garglk/terps glk ) ################################################################# # LEVEL9 5.1 -# http://www.ifarchive.org/indexes/if-archiveXlevel9XinterpretersXlevel9.html -# -# Changes (see level9.diff): -# - level9.h: improve portability by including and using -# the typedefs from there, rather than assuming width of types -# like unsigned int, etc. ################################################################# addprefix( LEVEL9_SRC - terps/level9 + garglk/terps/level9 level9.c bitmap.c Glk/glk.c ) add_library( level9 @@ -372,22 +313,13 @@ target_link_libraries( level9 target_include_directories( level9 PRIVATE - terps/level9 terps/level9/Glk terps glk ) + garglk/terps/level9 garglk/terps/level9/Glk garglk/terps glk ) ################################################################# # MAGNETIC 2.3 -# http://www.ifarchive.org/indexes/if-archiveXmagnetic-scrollsXinterpretersXmagnetic.html -# -# Changes (see magnetic.diff): -# - glk.c: always use GLK save / restore prompts, even if -# game has already asked user to enter filename. -# -# - defs.h: improve portability by including and using -# the typedefs from there, rather than assuming width of types -# like unsigned int, etc. ################################################################# addprefix( MAGNETIC_SRC - terps/magnetic + garglk/terps/magnetic Generic/emu.c Glk/glk.c ) add_library( magnetic @@ -405,17 +337,13 @@ target_link_libraries( magnetic target_include_directories( magnetic PRIVATE - terps/magnetic/Generic terps/magnetic/Glk terps glk ) + garglk/terps/magnetic/Generic garglk/terps/magnetic/Glk garglk/terps glk ) ################################################################# # SCARE 1.3.10 -# http://www.ifarchive.org/indexes/if-archiveXprogrammingXadrift.html -# -# Changes (see scare.diff): -# - os_glk.c: handle images and sound using same strategy as Hugo port ################################################################# addprefix( SCAREMAIN - terps/scare/source + garglk/terps/scare sctafpar.c sctaffil.c scprops.c scvars.c scexpr.c scprintf.c scinterf.c scparser.c sclibrar.c scrunner.c scevents.c scnpcs.c scobjcts.c sctasks.c screstrs.c scgamest.c scserial.c @@ -436,17 +364,13 @@ target_link_libraries( scare target_include_directories( scare PRIVATE - terps/scare/source terps glk ) + garglk/terps/scare garglk/terps glk ) ################################################################# # SCOTT 1.14 -# https://github.com/cspiegel/scottfree-glk -# -# Changes: -# - none ################################################################# addprefix( SCOTTMAIN - terps/scott + garglk/terps/scott scott.c bsd.c ) add_library( scott @@ -463,36 +387,20 @@ target_link_libraries( scott target_include_directories( scott PRIVATE - terps/scott terps glk ) + garglk/terps/scott garglk/terps glk ) ################################################################# # TADS 2 AND 3 -# http://www.tads.org/t2_patch.htm -# http://www.tads.org/t3dl/t3_src.zip -# -# Changes (see tads.diff): -# - oemfab.c, osfab.cc, osfab.h, osglk.c, vmglk23.cpp: -# new source files to implement Fabularium port. -# These files draw heavily from frobtads and qtads. -# -# - os.h: include a reference to our Fabularium port. -# -# - resfind.h: we need to do some fiddling with this to ensure -# it is included in the "right" way depending on whether linking -# to C++ or just C files. -# -# - vmtz.cpp: explicitly cast to (void *) for pointer comparison -# to fix compiler error. ################################################################# ####### SOURCE FILES COMMON TO TERP AND COMPILER ############### addprefix( T2COMMON - terps/tads/tads2 + garglk/tads/tads2 osifc.c osstzprs.c osrestad.c ) addprefix( T3COMMON - terps/tads/tads3 + garglk/tads/tads3 charmap.cpp md5.cpp resldexe.cpp resload.cpp sha2.cpp std_dbg.cpp std.cpp tccmdutl.cpp tcerr.cpp @@ -520,7 +428,7 @@ addprefix( T3COMMON vmundo.cpp vmvec.cpp ) addprefix( TCOMMON - terps/tads + garglk/tads osfab.cc tads3/derived/vmuni_cs.cpp tads3/indlg_tx3.cpp ) @@ -536,13 +444,13 @@ target_compile_options( tadsc target_include_directories( tadsc PRIVATE - terps terps/tads terps/tads/tads2 terps/tads/tads3 terps/tads/tads3/unix - terps/tads/tads3/test ) + garglk/terps garglk/tads garglk/tads/tads2 garglk/tads/tads3 garglk/tads/tads3/unix + garglk/tads/tads3/test ) ##################### TADS TERP ################################# addprefix( T2TERP - terps/tads/tads2 + garglk/tads/tads2 argize.c askf_os.c bif.c bifgdum.c cmap.c cmd.c dat.c dbgtr.c errmsg.c execmd.c fio.c fioxor.c getstr.c @@ -553,13 +461,13 @@ addprefix( T2TERP trd.c voc.c vocab.c ) addprefix( T3TERP - terps/tads/tads3 + garglk/tads/tads3 gameinfl.cpp gameinfo.cpp resfind.cpp tcprs_rt.cpp tcprsnf.cpp tcprsnl.cpp tct3_d.cpp tct3nl.cpp vmbifl.cpp vmconhtm.cpp vmmain.cpp vmsa.cpp ) addprefix( TERP - terps/tads + garglk/tads oemfab.c osglk.c tads3/askf_os3.cpp vmglk23.cpp ) @@ -579,19 +487,19 @@ target_link_libraries( tads target_include_directories( tads PRIVATE - glk terps terps/tads terps/tads/tads2 terps/tads/tads3 terps/tads/tads3/unix ) + glk garglk/terps garglk/tads garglk/tads/tads2 garglk/tads/tads3 garglk/tads/tads3/unix ) ##################### TADS COMPILER ################################# addprefix( T3COMP - terps/tads/tads3 + garglk/tads/tads3 askf_tx3.cpp os_stdio.cpp osnetdum.cpp rcmain.cpp tcgenfil.cpp tcmake.cpp tcmakecl.cpp tcprsfil.cpp tcprsimg.cpp tcprsprg.cpp tct3img.cpp tct3prg.cpp vmbifc.cpp vmconmor.cpp vmimgrb.cpp vmpreini.cpp vmwrtimg.cpp ) addprefix( TCOMP - terps/tads + garglk/tads ost3comp.cc ) add_library( t3make @@ -609,8 +517,8 @@ target_link_libraries( t3make target_include_directories( t3make PRIVATE - terps terps/tads terps/tads/tads2 terps/tads/tads3 terps/tads/tads3/unix - terps/tads/tads3/test + garglk/terps garglk/tads garglk/tads/tads2 garglk/tads/tads3 garglk/tads/tads3/unix + garglk/tads/tads3/test utilities ) ################################################################# @@ -639,15 +547,12 @@ target_include_directories ( utils # AGT2AGX # (tool provided by AGILITY to convert bundle of AGT files into # one AGX file) -# -# Changes: -# - none ################################################################# set( BASE agtread.c gamedata.c util.c agxfile.c auxfile.c filename.c ) addprefix( AGT2AGX_SRC - terps/agility + garglk/terps/agility ${BASE} agt2agx.c agilstub.c ) add_library( agt2agx @@ -665,14 +570,11 @@ target_link_libraries( agt2agx target_include_directories( agt2agx PRIVATE - terps/agility + garglk/terps/agility utilities ) ################################################################# # BABEL -# -# Changes: -# - none ################################################################# set( TREATY_OBJS zcode.c magscrolls.c blorb.c glulx.c hugo.c agt.c level9.c executable.c advsys.c tads.c tads2.c tads3.c adrift.c alan.c ) @@ -706,9 +608,6 @@ target_include_directories( babel ################################################################# # INFORM 6.33 # http://www.ifarchive.org/indexes/if-archiveXinfocomXcompilersXinform6Xsource.html -# -# Changes: -# - none ################################################################# addprefix( OBJECTS utilities/inform/src @@ -733,4 +632,4 @@ target_include_directories( inform PRIVATE utilities/inform/lib utilities/inform/src - utilities ) \ No newline at end of file + utilities ) diff --git a/app/src/main/jni/README.txt b/app/src/main/jni/README.txt index 45b3916..6ed8ad2 100644 --- a/app/src/main/jni/README.txt +++ b/app/src/main/jni/README.txt @@ -1,5 +1,3 @@ -File last updated: 21 Nov 2016 - -------------------------------- GLK FILES -------------------------------- @@ -19,87 +17,44 @@ Fabularium-specific files: - glkblorb.c contains Fabularium-specific blorb functions, including the two required by gi_blorb.h (giblorb_set_resource_map(str), giblorb_get_resource_map()) - glkstart.c provides entry points for the Java module to run terps. -Licences: - - - babel: public domain, Aladdin-specific licence for md5.c and Creative Commons Attribution2.5 License for the other files - - GLK and blorb: Andrew Plotkin's custom licence - - others: (c) Tim Cadogan-Cowper 2016, GPL v2. - -------------------------------- FABULARIUM C/C++ TERP PLUGIN SYSTEM -------------------------------- All terps need to be ported to GLK first. -Then: - -1) Dump the C or C++ source files for the new terp into a new subfolder (e.g. jni/scott or jni/scare). - -2) Update the Android.mk file in the parent folder to ensure that your new terp is compiled. Include the glkterp.c with the rest of the source files. - -3) Update class Terp in the Java code to correctly select your terp. +Then update CMakeLists.txt to ensure that your new terp is compiled, and class Terp in the Java code to correctly select your terp. At the moment, Fabularium includes the following terps: ADVSYS (ANSI) + NewParser - Licence: BSD licence. - (http://www.ifarchive.org/indexes/if-archiveXprogrammingXadvsys.html) AGILITY 1.1.1 - Licence: GPL v2. - (http://www.ifarchive.org/if-archive/programming/agt/agility/agil111src_glk.zip) ALAN 2.8.7 and ALAN 3. - Licence: Artistic Licence 2.0 - N.B. linked website below states that: - "The licensing for Alan v3 also applies for Alan v2. You can find the license in the - Alan v3 manual." - (ALAN 2.8.7: http://www.alanif.se/21-downloads/download-v2) BOCFEL 1.0 - Licence: GPL v3. - (https://cspiegel.github.io/bocfel/downloads.html) GIT 1.3.5 - Licence: MIT. - (https://github.com/DavidKinder/Git) GLULXE 0.5.4 - Licence: MIT. - (http://eblong.com/zarf/glulx/index.html) HUGO 3.1.03 - Licence: Custom. May need to get permission before can release. - (http://www.generalcoffee.com/hugo/gethugo.html) LEVEL9 5.1 - Licence: GPL v2. - (http://www.ifarchive.org/indexes/if-archiveXlevel9XinterpretersXlevel9.html) MAGNETIC 2.3 - Licence: GPL v2. - (http://www.ifarchive.org/indexes/if-archiveXmagnetic-scrollsXinterpretersXmagnetic.html) SCARE 1.3.10 - Licence: GPL v2. - (http://www.ifarchive.org/indexes/if-archiveXprogrammingXadrift.html) SCOTT 1.14 - Licence: GPL v2. - (http://www.ifarchive.org/indexes/if-archiveXscott-adamsXinterpretersXscottfree.html) TADS 2 - Licence: Custom. - (http://www.tads.org/t2_patch.htm) TADS 3 - Licence: Same as TADS2 - Custom. - (http://www.tads.org/t3dl/t3_src.zip) Also uses these tools: inform compiler 6.33 and library 6.12.1 - Licence: Artistic Licence - (http://www.ifarchive.org/indexes/if-archiveXinfocomXcompilersXinform6Xsource.html) diff --git a/app/src/main/jni/diffs/agility.diff b/app/src/main/jni/diffs/agility.diff deleted file mode 100644 index 1bf112a..0000000 --- a/app/src/main/jni/diffs/agility.diff +++ /dev/null @@ -1,14 +0,0 @@ -diff -r agil111src_glk/agt2agx.c terps/agility/agt2agx.c -8d7 -< -diff -r agil111src_glk/gamedata.c terps/agility/gamedata.c -14d13 -< -diff -r agil111src_glk/os_glk.c terps/agility/os_glk.c -5912a5913,5916 -> #ifdef GARGLK -> retfile = fopen(garglk_fileref_get_name(fileref), fdtype); -> #else -> -5954a5959 -> #endif /* GARGLK */ diff --git a/app/src/main/jni/diffs/alan2.diff b/app/src/main/jni/diffs/alan2.diff deleted file mode 100644 index 4e7a74e..0000000 --- a/app/src/main/jni/diffs/alan2.diff +++ /dev/null @@ -1,4584 +0,0 @@ -diff -r /home/nothus/orig-terps/interpreter287src/acode.h ../terps/alan/alan2/acode.h -4,7c4,16 -< typedef unsigned long Aword; /* Type for an ACODE word */ -< typedef unsigned long Aaddr; /* Type for an ACODE address */ -< typedef unsigned long Abool; /* Type for an ACODE Boolean value */ -< typedef signed long Aint; /* Type for an ACODE Integer value */ ---- -> /* Original source below assumes that sizeof(long) will be 32 bits (4 bytes), -> * but this may not be true on some hardware. Use stdint library to improve -> * portability - TCC Dec 2017 */ -> #include -> typedef uint32_t Aword; /* Type for an ACODE word */ -> typedef uint32_t Aaddr; /* Type for an ACODE address */ -> typedef uint32_t Abool; /* Type for an ACODE Boolean value */ -> typedef int32_t Aint; /* Type for an ACODE Integer value */ -> -> /*typedef unsigned long Aword;*/ /* Type for an ACODE word */ -> /*typedef unsigned long Aaddr;*/ /* Type for an ACODE address */ -> /*typedef unsigned long Abool;*/ /* Type for an ACODE Boolean value */ -> /*typedef signed long Aint;*/ /* Type for an ACODE Integer value */ -15c24,25 -< typedef long CodeValue; ---- -> typedef int32_t CodeValue; -> /*typedef long CodeValue;*/ -28c38,39 -< typedef int WrdKind; ---- -> typedef int16_t WrdKind; -> /*typedef int WrdKind;*/ -diff -r /home/nothus/orig-terps/interpreter287src/exe.c ../terps/alan/alan2/exe.c -10a11,12 -> #include "glk.h" -> -1521a1524 -> #ifndef GARGLK -1534a1538,1546 -> #else -> frefid_t fref; -> fref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Write, 0); -> if (fref == NULL) -> error(M_SAVEFAILED); -> strcpy(str, garglk_fileref_get_name(fref)); -> glk_fileref_destroy(fref); -> #endif -> -1608a1621 -> #ifndef GARGLK -1621a1635,1643 -> #else -> frefid_t fref; -> fref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Read, 0); -> if (fref == NULL) -> error(M_SAVEFAILED); -> strcpy(str, garglk_fileref_get_name(fref)); -> glk_fileref_destroy(fref); -> #endif -> -diff -r /home/nothus/orig-terps/interpreter287src/main.c ../terps/alan/alan2/main.c -1,1896c1,1896 -< /*----------------------------------------------------------------------*\ -< -< MAIN.C -< -< Main module of interpreter for ALAN Adventure Language -< -< \*----------------------------------------------------------------------*/ -< -< #define V27COMPATIBLE -< -< #include "sysdep.h" -< -< #include "types.h" -< #include "main.h" -< -< #include -< #ifdef USE_READLINE -< #include "readline.h" -< #endif -< -< #ifdef HAVE_SHORT_FILENAMES -< #include "av.h" -< #else -< #include "alan.version.h" -< #endif -< -< #include "args.h" -< #include "parse.h" -< #include "inter.h" -< #include "rules.h" -< #ifdef REVERSED -< #include "reverse.h" -< #endif -< #include "debug.h" -< #include "stack.h" -< #include "exe.h" -< #include "term.h" -< -< #ifdef GLK -< #include "glk.h" -< #include "glkio.h" -< #endif -< -< /* PUBLIC DATA */ -< -< /* The Amachine memory */ -< Aword *memory; -< static AcdHdr dummyHeader; /* Dummy to use until memory allocated */ -< AcdHdr *header = &dummyHeader; -< -< int memTop = 0; /* Top of load memory */ -< -< int conjWord; /* First conjunction in dictonary, for ',' */ -< -< -< /* Amachine variables */ -< CurVars cur; -< -< /* Amachine structures */ -< WrdElem *dict; /* Dictionary pointer */ -< ActElem *acts; /* Actor table pointer */ -< LocElem *locs; /* Location table pointer */ -< VrbElem *vrbs; /* Verb table pointer */ -< StxElem *stxs; /* Syntax table pointer */ -< ObjElem *objs; /* Object table pointer */ -< CntElem *cnts; /* Container table pointer */ -< RulElem *ruls; /* Rule table pointer */ -< EvtElem *evts; /* Event table pointer */ -< MsgElem *msgs; /* Message table pointer */ -< Aword *scores; /* Score table pointer */ -< Aword *freq; /* Cumulative character frequencies */ -< -< int dictsize; -< -< Boolean verbose = FALSE; -< Boolean errflg = TRUE; -< Boolean trcflg = FALSE; -< Boolean dbgflg = FALSE; -< Boolean stpflg = FALSE; -< Boolean logflg = FALSE; -< Boolean statusflg = TRUE; -< Boolean fail = FALSE; -< Boolean anyOutput = FALSE; -< -< -< /* The files and filenames */ -< char *advnam; -< FILE *txtfil; -< FILE *logfil; -< -< -< /* Screen formatting info */ -< int col, lin; -< int paglen, pagwidth; -< -< Boolean needsp = FALSE; -< Boolean skipsp = FALSE; -< -< /* Restart jump buffer */ -< jmp_buf restart_label; -< -< -< /* PRIVATE DATA */ -< static jmp_buf jmpbuf; /* Error return long jump buffer */ -< -< -< -< /*====================================================================== -< -< terminate() -< -< Terminate the execution of the adventure, e.g. close windows, -< return buffers... -< -< */ -< #ifdef _PROTOTYPES_ -< void terminate(int code) -< #else -< void terminate(code) -< int code; -< #endif -< { -< #ifdef __amiga__ -< #ifdef AZTEC_C -< #include -< extern struct _dev *_devtab; -< char buf[85]; -< -< if (con) { /* Running from WB, created a console so kill it */ -< /* Running from WB, so we created a console and -< hacked the Aztec C device table to use it for all I/O -< so now we need to make it close it (once!) */ -< _devtab[1].fd = _devtab[2].fd = 0; -< } else -< #else -< /* Geek Gadgets GCC */ -< #include -< #include -< #include -< -< if (_WBenchMsg != NULL) { -< Close(window); -< if (_WBenchMsg->sm_ArgList != NULL) -< UnLock(CurrentDir(cd)); -< } else -< #endif -< #endif -< newline(); -< free(memory); -< if (logflg) -< fclose(logfil); -< -< #ifdef __MWERKS__ -< printf("Command-Q to close window."); -< #endif -< -< #ifdef GLK -< glk_exit(); -< #else -< exit(code); -< #endif -< } -< -< /*====================================================================== -< -< usage() -< -< */ -< #ifdef _PROTOTYPES_ -< void usage(void) -< #else -< void usage() -< #endif -< { -< printf("Usage:\n\n"); -< printf(" %s [] \n\n", PROGNAME); -< printf("where the possible optional switches are:\n"); -< #ifdef GLK -< glk_set_style(style_Preformatted); -< #endif -< printf(" -v verbose mode\n"); -< printf(" -l log player commands and game output to a file\n"); -< printf(" -i ignore version and checksum errors\n"); -< printf(" -n no Status Line\n"); -< printf(" -d enter debug mode\n"); -< printf(" -t trace game execution\n"); -< printf(" -s single instruction trace\n"); -< #ifdef GLK -< glk_set_style(style_Normal); -< #endif -< } -< -< -< /*====================================================================== -< -< syserr() -< -< Print a little text blaming the user for the system error. -< -< */ -< #ifdef _PROTOTYPES_ -< void syserr(char *str) -< #else -< void syserr(str) -< char *str; -< #endif -< { -< output("$n$nAs you enter the twilight zone of Adventures, you stumble \ -< and fall to your knees. In front of you, you can vaguely see the outlines \ -< of an Adventure that never was.$n$nSYSTEM ERROR: "); -< output(str); -< output("$n$n"); -< -< if (logflg) -< fclose(logfil); -< newline(); -< -< #ifdef __amiga__ -< #ifdef AZTEC_C -< { -< char buf[80]; -< -< if (con) { /* Running from WB, wait for user ack. */ -< printf("press RETURN to quit"); -< gets(buf); -< } -< } -< #endif -< #endif -< -< terminate(0); -< } -< -< -< /*====================================================================== -< -< error() -< -< Print an error message, force new player input and abort. -< -< */ -< #ifdef _PROTOTYPES_ -< void error(MsgKind msgno) /* IN - The error message number */ -< #else -< void error(msgno) -< MsgKind msgno; /* IN - The error message number */ -< #endif -< { -< if (msgno != MSGMAX) -< prmsg(msgno); -< wrds[wrdidx] = EOF; /* Force new player input */ -< dscrstkp = 0; /* Reset describe stack */ -< longjmp(jmpbuf,TRUE); -< } -< -< -< /*====================================================================== -< -< statusline() -< -< Print the the status line on the top of the screen. -< -< */ -< void statusline(void) -< { -< #ifdef GLK -< glui32 glkWidth; -< char line[100]; -< int pcol = col; -< -< if (NULL == glkStatusWin) -< return; -< -< glk_set_window(glkStatusWin); -< glk_window_clear(glkStatusWin); -< glk_window_get_size(glkStatusWin, &glkWidth, NULL); -< -< col = 1; -< glk_window_move_cursor(glkStatusWin, 1, 0); -< say(where(HERO)); -< if (header->maxscore > 0) -< sprintf(line, "Score %d(%d)/%d moves", cur.score, (int)header->maxscore, cur.tick); -< else -< sprintf(line, "%d moves", cur.tick); -< glk_window_move_cursor(glkStatusWin, glkWidth - col - strlen(line), 0); -< printf(line); -< needsp = FALSE; -< -< col = pcol; -< -< glk_set_window(glkMainWin); -< #else -< #ifdef HAVE_ANSI -< char line[100]; -< int i; -< int pcol = col; -< -< if (!statusflg) return; -< /* ansi_position(1,1); ansi_bold_on(); */ -< printf("\x1b[1;1H"); -< printf("\x1b[7m"); -< col = 1; -< say(where(HERO)); -< if (header->maxscore > 0) -< sprintf(line, "Score %ld(%ld)/%ld moves", cur.score, (int)header->maxscore, cur.tick); -< else -< sprintf(line, "%ld moves", cur.tick); -< for (i=0; i < pagwidth - col - strlen(line); i++) putchar(' '); -< printf(line); -< printf("\x1b[m"); -< printf("\x1b[%d;1H", paglen); -< needsp = FALSE; -< -< col = pcol; -< #endif -< #endif -< } -< -< -< /*====================================================================== -< -< logprint() -< -< Print some text and log it if logging is on. -< -< */ -< void logprint(char str[]) -< { -< printf(str); -< if (logflg) -< fprintf(logfil, str); -< } -< -< -< -< /*====================================================================== -< -< newline() -< -< Make a newline, but check for screen full. -< -< */ -< #ifdef _PROTOTYPES_ -< void newline(void) -< #else -< void newline() -< #endif -< { -< #ifdef GLK -< glk_put_char('\n'); -< #else -< char buf[256]; -< -< col = 1; -< if (lin >= paglen - 1) { -< logprint("\n"); -< needsp = FALSE; -< prmsg(M_MORE); -< #ifdef USE_READLINE -< (void) readline(buf); -< #else -< fgets(buf, 256, stdin); -< #endif -< getPageSize(); -< lin = 0; -< } else -< logprint("\n"); -< -< lin++; -< needsp = FALSE; -< #endif -< } -< -< -< /*====================================================================== -< -< para() -< -< Make a new paragraph, i.e one empty line (one or two newlines). -< -< */ -< #ifdef _PROTOTYPES_ -< void para(void) -< #else -< void para() -< #endif -< { -< #ifdef GLK -< glk_put_char('\n'); -< glk_put_char('\n'); -< #else -< if (col != 1) -< newline(); -< newline(); -< #endif -< } -< -< -< /*====================================================================== -< -< clear() -< -< Clear the screen. -< -< */ -< #ifdef _PROTOTYPES_ -< void clear(void) -< #else -< void clear() -< #endif -< { -< #ifdef GLK -< glk_window_clear(glkMainWin); -< #else -< #ifdef HAVE_ANSI -< if (!statusflg) return; -< printf("\x1b[2J"); -< printf("\x1b[%d;1H", paglen); -< #endif -< #endif -< } -< -< -< /*====================================================================== -< -< allocate() -< -< Safely allocate new memory. -< -< */ -< #ifdef _PROTOTYPES_ -< void *allocate(unsigned long len) /* IN - Length to allocate */ -< #else -< void *allocate(len) -< unsigned long len; /* IN - Length to allocate */ -< #endif -< { -< void *p = (void *)malloc((size_t)len); -< -< if (p == NULL) -< syserr("Out of memory."); -< -< return p; -< } -< -< -< /*---------------------------------------------------------------------- -< -< just() -< -< Justify a string so that it wraps at end of screen. -< -< */ -< #ifdef _PROTOTYPES_ -< static void just(char str[]) -< #else -< static void just(str) -< char str[]; -< #endif -< { -< #ifdef GLK -< logprint(str); -< #else -< int i; -< char ch; -< -< if (col >= pagwidth && !skipsp) -< newline(); -< -< while (strlen(str) > pagwidth - col) { -< i = pagwidth - col - 1; -< while (!isSpace(str[i]) && i > 0) /* First find wrap point */ -< i--; -< if (i == 0 && col == 1) /* If it doesn't fit at all */ -< /* Wrap immediately after this word */ -< while (!isSpace(str[i]) && str[i] != '\0') -< i++; -< if (i > 0) { /* If it fits ... */ -< ch = str[i]; /* Save space or NULL */ -< str[i] = '\0'; /* Terminate string */ -< logprint(str); /* and print it */ -< skipsp = FALSE; /* If skipping, now we're done */ -< str[i] = ch; /* Restore character */ -< /* Skip white after printed portion */ -< for (str = &str[i]; isSpace(str[0]) && str[0] != '\0'; str++); -< } -< newline(); /* Then start a new line */ -< } -< logprint(str); /* Print tail */ -< col = col + strlen(str); /* Update column */ -< #endif -< } -< -< -< /*---------------------------------------------------------------------- -< -< space() -< -< Output a space if needed. -< -< */ -< #ifdef _PROTOTYPES_ -< static void space(void) -< #else -< static void space() -< #endif -< { -< if (skipsp) -< skipsp = FALSE; -< else { -< if (needsp) { -< logprint(" "); -< col++; -< } -< } -< needsp = FALSE; -< } -< -< -< -< /*---------------------------------------------------------------------- -< -< sayparam() -< -< A parameter needs to be said, check for words the player used and use -< them if possible. -< -< */ -< #ifdef _PROTOTYPES_ -< static void sayparam(int p) -< #else -< static void sayparam(p) -< int p; -< #endif -< { -< int i; -< -< for (i = 0; i <= p; i++) -< if (params[i].code == EOF) -< syserr("Nonexistent parameter referenced."); -< -< if (params[p].firstWord == EOF) /* Any words he used? */ -< say(params[p].code); -< else /* Yes, so use them... */ -< for (i = params[p].firstWord; i <= params[p].lastWord; i++) { -< just((char *)addrTo(dict[wrds[i]].wrd)); -< if (i < params[p].lastWord) -< just(" "); -< } -< } -< -< -< /*---------------------------------------------------------------------- -< -< prsym() -< -< Print an expanded symbolic reference. -< -< N = newline -< I = indent on a new line -< P = new paragraph -< L = current location name -< O = current object -> first parameter! -< V = current verb -< A = current actor -< T = tabulation -< $ = no space needed after this -< */ -< #ifdef _PROTOTYPES_ -< static void prsym( -< char *str /* IN - The string starting with '$' */ -< ) -< #else -< static void prsym(str) -< char *str; /* IN - The string starting with '$' */ -< #endif -< { -< switch (toLower(str[1])) { -< case 'n': -< newline(); -< needsp = FALSE; -< break; -< case 'i': -< newline(); -< logprint(" "); -< col = 5; -< needsp = FALSE; -< break; -< case 'o': -< sayparam(0); -< needsp = TRUE; /* We did print something non-white */ -< break; -< case '1': -< case '2': -< case '3': -< case '4': -< case '5': -< case '6': -< case '7': -< case '8': -< case '9': -< sayparam(str[1]-'1'); -< needsp = TRUE; /* We did print something non-white */ -< break; -< case 'l': -< say(cur.loc); -< needsp = TRUE; /* We did print something non-white */ -< break; -< case 'a': -< say(cur.act); -< needsp = TRUE; /* We did print something non-white */ -< break; -< case 'v': -< just((char *)addrTo(dict[vrbwrd].wrd)); -< needsp = TRUE; /* We did print something non-white */ -< break; -< case 'p': -< para(); -< needsp = FALSE; -< break; -< case 't': { -< int i; -< int spaces = 4-(col-1)%4; -< -< for (i = 0; i 0) { -< just(str); /* Output part before '$' */ -< if (str[strlen(str)-1] == ' ') -< needsp = FALSE; -< } -< *symptr = ch; /* restore '$' */ -< prsym(symptr); /* Print the symbolic reference */ -< str = &symptr[2]; /* Advance to after symbol and continue */ -< } -< if (str[0] != 0) { -< just(str); /* Output trailing part */ -< skipsp = FALSE; -< if (str[strlen(str)-1] != ' ') -< needsp = TRUE; -< } -< anyOutput = TRUE; -< free(copy); -< } -< -< -< /*====================================================================== -< -< prmsg() -< -< Print a message from the message table. -< -< */ -< #ifdef _PROTOTYPES_ -< void prmsg(MsgKind msg) /* IN - message number */ -< #else -< void prmsg(msg) -< MsgKind msg; /* IN - message number */ -< #endif -< { -< interpret(msgs[msg].stms); -< } -< -< -< /*----------------------------------------------------------------------*\ -< -< Various check functions -< -< endOfTable() -< isObj, isLoc, isAct, IsCnt & isNum -< -< \*----------------------------------------------------------------------*/ -< -< /* How to know we are at end of a table */ -< #ifdef _PROTOTYPES_ -< Boolean eot(Aword *adr) -< #else -< Boolean eot(adr) -< Aword *adr; -< #endif -< { -< return *adr == EOF; -< } -< -< -< #ifdef _PROTOTYPES_ -< Boolean isObj(Aword x) -< #else -< Boolean isObj(x) -< Aword x; -< #endif -< { -< return x >= OBJMIN && x <= OBJMAX; -< } -< -< #ifdef _PROTOTYPES_ -< Boolean isCnt(Aword x) -< #else -< Boolean isCnt(x) -< Aword x; -< #endif -< { -< return (x >= CNTMIN && x <= CNTMAX) || -< (isObj(x) && objs[x-OBJMIN].cont != 0) || -< (isAct(x) && acts[x-ACTMIN].cont != 0); -< } -< -< #ifdef _PROTOTYPES_ -< Boolean isAct(Aword x) -< #else -< Boolean isAct(x) -< Aword x; -< #endif -< { -< return x >= ACTMIN && x <= ACTMAX; -< } -< -< #ifdef _PROTOTYPES_ -< Boolean isLoc(Aword x) -< #else -< Boolean isLoc(x) -< Aword x; -< #endif -< { -< return x >= LOCMIN && x <= LOCMAX; -< } -< -< #ifdef _PROTOTYPES_ -< Boolean isNum(Aword x) -< #else -< Boolean isNum(x) -< Aword x; -< #endif -< { -< return x >= LITMIN && x <= LITMAX && litValues[x-LITMIN].type == TYPNUM; -< } -< -< #ifdef _PROTOTYPES_ -< Boolean isStr(Aword x) -< #else -< Boolean isStr(x) -< Aword x; -< #endif -< { -< return x >= LITMIN && x <= LITMAX && litValues[x-LITMIN].type == TYPSTR; -< } -< -< #ifdef _PROTOTYPES_ -< Boolean isLit(Aword x) -< #else -< Boolean isLit(x) -< Aword x; -< #endif -< { -< return x >= LITMIN && x <= LITMAX; -< } -< -< -< -< /*====================================================================== -< -< exitto() -< -< Is there an exit from one location to another? -< -< */ -< #ifdef _PROTOTYPES_ -< Boolean exitto(int to, int from) -< #else -< Boolean exitto(to, from) -< int to, from; -< #endif -< { -< ExtElem *ext; -< -< if (locs[from-LOCMIN].exts == 0) -< return(FALSE); /* No exits */ -< -< for (ext = (ExtElem *) addrTo(locs[from-LOCMIN].exts); !endOfTable(ext); ext++) -< if (ext->next == to) -< return(TRUE); -< -< return(FALSE); -< } -< -< -< -< #ifdef CHECKOBJ -< /*====================================================================== -< -< checkobj() -< -< Check that the object given is valid, else print an error message -< or find out what he wanted. -< -< This routine is not used any longer, kept for sentimental reasons ;-) -< -< */ -< void checkobj(obj) -< Aword *obj; -< { -< Aword oldobj; -< -< if (*obj != EOF) -< return; -< -< oldobj = EOF; -< for (cur.obj = OBJMIN; cur.obj <= OBJMAX; cur.obj++) { -< /* If an object is present and it is possible to perform his action */ -< if (isHere(cur.obj) && possible()) -< if (oldobj == EOF) -< oldobj = cur.obj; -< else -< error(WANT); /* And we didn't find multiple objects */ -< } -< -< if (oldobj == EOF) -< error(WANT); /* But we found ONE */ -< -< *obj = cur.obj = oldobj; -< output("($o)"); /* Then he surely meant this object */ -< } -< #endif -< -< -< -< -< /*---------------------------------------------------------------------- -< count() -< -< Count the number of items in a container. -< -< */ -< #ifdef _PROTOTYPES_ -< static int count(int cnt) /* IN - the container to count */ -< #else -< static int count(cnt) -< int cnt; /* IN - the container to count */ -< #endif -< { -< int i, j = 0; -< -< for (i = OBJMIN; i <= OBJMAX; i++) -< if (in(i, cnt)) -< /* Then it's in this container also */ -< j++; -< return(j); -< } -< -< -< -< /*---------------------------------------------------------------------- -< sumatr() -< -< Sum the values of one attribute in a container. Recursively. -< -< */ -< #ifdef _PROTOTYPES_ -< static int sumatr( -< Aword atr, /* IN - the attribute to sum over */ -< Aword cnt /* IN - the container to sum */ -< ) -< #else -< static int sumatr(atr, cnt) -< Aword atr; /* IN - the attribute to sum over */ -< Aword cnt; /* IN - the container to sum */ -< #endif -< { -< int i; -< int sum = 0; -< -< for (i = OBJMIN; i <= OBJMAX; i++) -< if (objs[i-OBJMIN].loc == cnt) { /* Then it's in this container */ -< if (objs[i-OBJMIN].cont != 0) /* This is also a container! */ -< sum = sum + sumatr(atr, i); -< sum = sum + attribute(i, atr); -< } -< return(sum); -< } -< -< -< -< -< /*====================================================================== -< checklim() -< -< Checks if a limit for a container is exceeded. -< -< */ -< #ifdef _PROTOTYPES_ -< Boolean checklim( -< Aword cnt, /* IN - Container code */ -< Aword obj /* IN - The object to add */ -< ) -< #else -< Boolean checklim(cnt, obj) -< Aword cnt; /* IN - Container code */ -< Aword obj; /* IN - The object to add */ -< #endif -< { -< LimElem *lim; -< Aword props; -< -< fail = TRUE; -< if (!isCnt(cnt)) -< syserr("Checking limits for a non-container."); -< -< /* Find the container properties */ -< if (isObj(cnt)) -< props = objs[cnt-OBJMIN].cont; -< else if (isAct(cnt)) -< props = acts[cnt-ACTMIN].cont; -< else -< props = cnt; -< -< if (cnts[props-CNTMIN].lims != 0) { /* Any limits at all? */ -< for (lim = (LimElem *) addrTo(cnts[props-CNTMIN].lims); !endOfTable(lim); lim++) -< if (lim->atr == 0) { -< if (count(cnt) >= lim->val) { -< interpret(lim->stms); -< return(TRUE); /* Limit check failed */ -< } -< } else { -< if (sumatr(lim->atr, cnt) + attribute(obj, lim->atr) > lim->val) { -< interpret(lim->stms); -< return(TRUE); -< } -< } -< } -< fail = FALSE; -< return(FALSE); -< } -< -< -< -< -< -< /*----------------------------------------------------------------------*\ -< -< Action routines -< -< \*----------------------------------------------------------------------*/ -< -< -< -< /*---------------------------------------------------------------------- -< trycheck() -< -< Tries a check, returns TRUE if it passed, FALSE else. -< -< */ -< #ifdef _PROTOTYPES_ -< static Boolean trycheck( -< Aaddr adr, /* IN - ACODE address to check table */ -< Boolean act /* IN - Act if it fails ? */ -< ) -< #else -< static Boolean trycheck(adr, act) -< Aaddr adr; /* IN - ACODE address to check table */ -< Boolean act; /* IN - Act if it fails ? */ -< #endif -< { -< ChkElem *chk; -< -< chk = (ChkElem *) addrTo(adr); -< if (chk->exp == 0) { -< interpret(chk->stms); -< return(FALSE); -< } else { -< while (!endOfTable(chk)) { -< interpret(chk->exp); -< if (!(Abool)pop()) { -< if (act) -< interpret(chk->stms); -< return(FALSE); -< } -< chk++; -< } -< return(TRUE); -< } -< } -< -< -< /*====================================================================== -< go() -< -< Move hero in a direction. -< -< */ -< #ifdef _PROTOTYPES_ -< void go(int dir) -< #else -< void go(dir) -< int dir; -< #endif -< { -< ExtElem *ext; -< Boolean ok; -< Aword oldloc; -< -< ext = (ExtElem *) addrTo(locs[cur.loc-LOCMIN].exts); -< if (locs[cur.loc-LOCMIN].exts != 0) -< while (!endOfTable(ext)) { -< if (ext->code == dir) { -< ok = TRUE; -< if (ext->checks != 0) { -< if (trcflg) { -< printf("\n\n"); -< } -< ok = trycheck(ext->checks, TRUE); -< } -< if (ok) { -< oldloc = cur.loc; -< if (ext->action != 0) { -< if (trcflg) { -< printf("\n\n"); -< } -< interpret(ext->action); -< } -< /* Still at the same place? */ -< if (where(HERO) == oldloc) { -< if (trcflg) { -< printf("\n\n"); -< } -< locate(HERO, ext->next); -< } -< } -< return; -< } -< ext++; -< } -< error(M_NO_WAY); -< } -< -< -< -< /*---------------------------------------------------------------------- -< -< findalt() -< -< Find the verb alternative wanted in a verb list and return -< the address to it. -< -< */ -< #ifdef _PROTOTYPES_ -< static AltElem *findalt( -< Aword vrbsadr, /* IN - Address to start of list */ -< Aword param /* IN - Which parameter to match */ -< ) -< #else -< static AltElem *findalt(vrbsadr, param) -< Aword vrbsadr; /* IN - Address to start of list */ -< Aword param; /* IN - Which parameter to match */ -< #endif -< { -< VrbElem *vrb; -< AltElem *alt; -< -< if (vrbsadr == 0) -< return(NULL); -< -< for (vrb = (VrbElem *) addrTo(vrbsadr); !endOfTable(vrb); vrb++) -< if (vrb->code == cur.vrb) { -< for (alt = (AltElem *) addrTo(vrb->alts); !endOfTable(alt); alt++) -< if (alt->param == param || alt->param == 0) -< return alt; -< return NULL; -< } -< return NULL; -< } -< -< -< -< -< /*====================================================================== -< -< possible() -< -< Check if current action is possible according to the CHECKs. -< -< */ -< #ifdef _PROTOTYPES_ -< Boolean possible(void) -< #else -< Boolean possible() -< #endif -< { -< AltElem *alt[MAXPARAMS+2]; /* List of alt-pointers, one for each param */ -< int i; /* Parameter index */ -< -< fail = FALSE; -< alt[0] = findalt(header->vrbs, 0); -< /* Perform global checks */ -< if (alt[0] != 0 && alt[0]->checks != 0) { -< if (!trycheck(alt[0]->checks, FALSE)) return FALSE; -< if (fail) return FALSE; -< } -< -< /* Now CHECKs in this location */ -< alt[1] = findalt(locs[cur.loc-LOCMIN].vrbs, 0); -< if (alt[1] != 0 && alt[1]->checks != 0) -< if (!trycheck(alt[1]->checks, FALSE)) -< return FALSE; -< -< for (i = 0; params[i].code != EOF; i++) { -< alt[i+2] = findalt(objs[params[i].code-OBJMIN].vrbs, i+1); -< /* CHECKs in a possible parameter */ -< if (alt[i+2] != 0 && alt[i+2]->checks != 0) -< if (!trycheck(alt[i+2]->checks, FALSE)) -< return FALSE; -< } -< -< for (i = 0; i < 2 || params[i-2].code != EOF; i++) -< if (alt[i] != 0 && alt[i]->action != 0) -< break; -< if (i >= 2 && params[i-2].code == EOF) -< /* Didn't find any code for this verb/object combination */ -< return FALSE; -< else -< return TRUE; -< } -< -< -< -< /*---------------------------------------------------------------------- -< -< do_it() -< -< Execute the action commanded by hero. -< -< */ -< #ifdef _PROTOTYPES_ -< static void do_it(void) -< #else -< static void do_it() -< #endif -< { -< AltElem *alt[MAXPARAMS+2]; /* List of alt-pointers, one for each param */ -< Boolean done[MAXPARAMS+2]; /* Is it done */ -< int i; /* Parameter index */ -< char trace[80]; /* Trace string buffer */ -< -< fail = FALSE; -< alt[0] = findalt(header->vrbs, 0); -< /* Perform global checks */ -< if (alt[0] != 0 && alt[0]->checks != 0) { -< if (trcflg) -< printf("\n\n", cur.vrb); -< if (!trycheck(alt[0]->checks, TRUE)) return; -< if (fail) return; -< } -< -< /* Now CHECKs in this location */ -< alt[1] = findalt(locs[cur.loc-LOCMIN].vrbs, 0); -< if (alt[1] != 0 && alt[1]->checks != 0) { -< if (trcflg) -< printf("\n\n", cur.vrb); -< if (!trycheck(alt[1]->checks, TRUE)) return; -< if (fail) return; -< } -< -< for (i = 0; params[i].code != EOF; i++) { -< if (isLit(params[i].code)) -< alt[i+2] = 0; -< else { -< if (isObj(params[i].code)) -< alt[i+2] = findalt(objs[params[i].code-OBJMIN].vrbs, i+1); -< else if (isAct(params[i].code)) -< alt[i+2] = findalt(acts[params[i].code-ACTMIN].vrbs, i+1); -< else -< syserr("Illegal parameter type."); -< /* CHECKs in the parameters */ -< if (alt[i+2] != 0 && alt[i+2]->checks != 0) { -< if (trcflg) -< printf("\n\n", cur.vrb, i); -< if (!trycheck(alt[i+2]->checks, TRUE)) return; -< if (fail) return; -< } -< } -< } -< -< /* Check for anything to execute... */ -< for (i = 0; i < 2 || params[i-2].code != EOF; i++) -< if (alt[i] != 0 && alt[i]->action != 0) -< break; -< if (i >= 2 && params[i-2].code == EOF) -< /* Didn't find any code for this verb/object combination */ -< error(M_CANT0); -< -< /* Perform actions! */ -< -< /* First try any BEFORE or ONLY from outside in */ -< done[0] = FALSE; -< done[1] = FALSE; -< for (i = 2; params[i-2].code != EOF; i++) -< done[i] = FALSE; -< i--; -< while (i >= 0) { -< if (alt[i] != 0) -< if (alt[i]->qual == (Aword)Q_BEFORE || alt[i]->qual == (Aword)Q_ONLY) { -< if (alt[i]->action != 0) { -< if (trcflg) { -< if (i == 0) -< strcpy(trace, "GLOBAL"); -< else if (i == 1) -< strcpy(trace, "in LOCATION"); -< else -< sprintf(trace, "in PARAMETER %d", i-1); -< if (alt[i]->qual == (Aword)Q_BEFORE) -< printf("\n\n", cur.vrb, trace); -< else -< printf("\n\n", cur.vrb, trace); -< } -< interpret(alt[i]->action); -< if (fail) return; -< if (alt[i]->qual == (Aword)Q_ONLY) return; -< } -< done[i] = TRUE; -< } -< i--; -< } -< -< /* Then execute any not declared as AFTER, i.e. the default */ -< for (i = 0; i < 2 || params[i-2].code != EOF; i++) { -< if (alt[i] != 0) -< if (alt[i]->qual != (Aword)Q_AFTER) { -< if (!done[i] && alt[i]->action != 0) { -< if (trcflg) { -< if (i == 0) -< strcpy(trace, "GLOBAL"); -< else if (i == 1) -< strcpy(trace, "in LOCATION"); -< else -< sprintf(trace, "in PARAMETER %d", i-1); -< printf("\n\n", cur.vrb, trace); -< } -< interpret(alt[i]->action); -< if (fail) return; -< } -< done[i] = TRUE; -< } -< } -< -< /* Finally, the ones declared as after */ -< i--; -< while (i >= 0) { -< if (alt[i] != 0) -< if (!done[i] && alt[i]->action != 0) { -< if (trcflg) { -< if (i == 0) -< strcpy(trace, "GLOBAL"); -< else if (i == 1) -< strcpy(trace, "in LOCATION"); -< else -< sprintf(trace, "in PARAMETER %d", i-1); -< printf("\n\n", cur.vrb, trace); -< } -< interpret(alt[i]->action); -< if (fail) return; -< } -< i--; -< } -< } -< -< -< -< /*====================================================================== -< -< action() -< -< Execute all activities commanded. Handles possible multiple actions -< such as THEM or lists of objects. -< -< */ -< #ifdef _PROTOTYPES_ -< void action( -< ParamElem plst[] /* IN - Plural parameter list */ -< ) -< #else -< void action(plst) -< ParamElem plst[]; -< #endif -< { -< int i, mpos; -< char marker[10]; -< -< if (plural) { -< /* -< The code == 0 means this is a multiple position. We must loop -< over this position (and replace it by each present in the plst) -< */ -< for (mpos = 0; params[mpos].code != 0; mpos++); /* Find multiple position */ -< sprintf(marker, "($%d)", mpos+1); /* Prepare a printout with $1/2/3 */ -< for (i = 0; plst[i].code != EOF; i++) { -< params[mpos] = plst[i]; -< output(marker); -< do_it(); -< if (plst[i+1].code != EOF) -< para(); -< } -< params[mpos].code = 0; -< } else -< do_it(); -< } -< -< -< -< /*----------------------------------------------------------------------*\ -< -< Event Handling -< -< eventchk() -< -< \*----------------------------------------------------------------------*/ -< -< -< /*---------------------------------------------------------------------- -< eventchk() -< -< Check if any events are pending. If so execute them. -< */ -< #ifdef _PROTOTYPES_ -< static void eventchk(void) -< #else -< static void eventchk() -< #endif -< { -< while (etop != 0 && eventq[etop-1].time == cur.tick) { -< etop--; -< if (isLoc(eventq[etop].where)) -< cur.loc = eventq[etop].where; -< else -< cur.loc = where(eventq[etop].where); -< if (trcflg) { -< printf("\n\n"); -< } -< interpret(evts[eventq[etop].event-EVTMIN].code); -< } -< } -< -< -< -< -< -< /*----------------------------------------------------------------------*\ -< -< Main program and initialisation -< -< codfil -< filenames -< -< checkvers() -< load() -< checkdebug() -< initheader() -< initstrings() -< start() -< init() -< -< \*----------------------------------------------------------------------*/ -< -< -< static FILE *codfil; -< static char codfnm[256] = ""; -< static char txtfnm[256] = ""; -< static char logfnm[256] = ""; -< -< -< /*---------------------------------------------------------------------- -< -< checkvers() -< -< */ -< #ifdef _PROTOTYPES_ -< static void checkvers(AcdHdr *header) -< #else -< static void checkvers(header) -< AcdHdr *header; -< #endif -< { -< char vers[4]; -< char state[2]; -< -< /* Construct our own version */ -< vers[0] = alan.version.version; -< vers[1] = alan.version.revision; -< -< /* Check version of .ACD file */ -< if (dbgflg) { -< state[0] = header->vers[3]; -< state[1] = '\0'; -< printf("", -< advnam, -< (int)(header->vers[0]), -< (int)(header->vers[1]), -< (int)(header->vers[2]), -< (header->vers[3])==0? "": state); -< newline(); -< } -< -< /* Compatible if version and revision match... */ -< if (strncmp(header->vers, vers, 2) != 0) { -< #ifdef V25COMPATIBLE -< if (header->vers[0] == 2 && header->vers[1] == 5) /* Check for 2.5 version */ -< /* This we can convert later if needed... */; -< else -< #endif -< #ifdef V27COMPATIBLE -< if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ -< /* This we can convert later if needed... */; -< else -< #endif -< if (errflg) { -< char str[80]; -< sprintf(str, "Incompatible version of ACODE program. Game is %ld.%ld, interpreter %ld.%ld.", -< (int)(header->vers[0]), -< (int)(header->vers[1]), -< alan.version.version, -< alan.version.revision); -< syserr(str); -< } else -< output("\n"); -< } -< } -< -< -< /*---------------------------------------------------------------------- -< -< load() -< -< */ -< #ifdef _PROTOTYPES_ -< static void load(void) -< #else -< static void load() -< #endif -< { -< AcdHdr tmphdr; -< Aword crc = 0; -< int i; -< char err[100]; -< -< rewind(codfil); -< fread(&tmphdr, sizeof(tmphdr), 1, codfil); -< rewind(codfil); -< checkvers(&tmphdr); -< -< /* Allocate and load memory */ -< -< #ifdef REVERSED -< reverseHdr(&tmphdr); -< #endif -< -< /* No memory allocated yet? */ -< if (memory == NULL) { -< #ifdef V25COMPATIBLE -< if (tmphdr.vers[0] == 2 && tmphdr.vers[1] == 5) -< /* We need some more memory to expand 2.5 format*/ -< memory = allocate((tmphdr.size+tmphdr.objmax-tmphdr.objmin+1+2)*sizeof(Aword)); -< else -< #endif -< memory = allocate(tmphdr.size*sizeof(Aword)); -< } -< header = (AcdHdr *) addrTo(0); -< -< memTop = fread(addrTo(0), sizeof(Aword), tmphdr.size, codfil); -< if (memTop != tmphdr.size) -< syserr("Could not read all ACD code."); -< -< /* Calculate checksum */ -< for (i = sizeof(tmphdr)/sizeof(Aword); i < memTop; i++) { -< crc += memory[i]&0xff; -< crc += (memory[i]>>8)&0xff; -< crc += (memory[i]>>16)&0xff; -< crc += (memory[i]>>24)&0xff; -< #ifdef CRCLOG -< printf("%6x\t%6lx\t%6lx\n", i, crc, memory[i]); -< #endif -< } -< if (crc != tmphdr.acdcrc) { -< sprintf(err, "Checksum error in .ACD file (0x%lx instead of 0x%lx).", -< crc, tmphdr.acdcrc); -< if (errflg) -< syserr(err); -< else { -< output("$n"); -< } -< } -< -< #ifdef REVERSED -< if (dbgflg||trcflg||stpflg) -< output("$n"); -< #endif -< -< #ifdef V25COMPATIBLE -< /* Check for 2.5 version */ -< if (tmphdr.vers[0] == 2 && tmphdr.vers[1] == 5) { -< if (dbgflg||trcflg||stpflg) -< output("$n"); -< } -< #endif -< -< } -< -< -< /*---------------------------------------------------------------------- -< -< checkdebug() -< -< */ -< #ifdef _PROTOTYPES_ -< static void checkdebug(void) -< #else -< static void checkdebug() -< #endif -< { -< /* Make sure he can't debug if not allowed! */ -< if (!header->debug) { -< if (dbgflg|trcflg|stpflg) -< printf("\n", advnam); -< para(); -< dbgflg = FALSE; -< trcflg = FALSE; -< stpflg = FALSE; -< } -< -< if (dbgflg) /* If debugging */ -< srand(0); /* use no randomization */ -< else -< srand(time(0)); /* seed random generator */ -< } -< -< -< /*---------------------------------------------------------------------- -< -< initheader() -< -< */ -< #ifdef _PROTOTYPES_ -< static void initheader(void) -< #else -< static void initheader() -< #endif -< { -< dict = (WrdElem *) addrTo(header->dict); -< /* Find out number of entries in dictionary */ -< for (dictsize = 0; !endOfTable(&dict[dictsize]); dictsize++); -< vrbs = (VrbElem *) addrTo(header->vrbs); -< stxs = (StxElem *) addrTo(header->stxs); -< locs = (LocElem *) addrTo(header->locs); -< acts = (ActElem *) addrTo(header->acts); -< objs = (ObjElem *) addrTo(header->objs); -< evts = (EvtElem *) addrTo(header->evts); -< cnts = (CntElem *) addrTo(header->cnts); -< ruls = (RulElem *) addrTo(header->ruls); -< msgs = (MsgElem *) addrTo(header->msgs); -< scores = (Aword *) addrTo(header->scores); -< -< if (header->pack) -< freq = (Aword *) addrTo(header->freq); -< } -< -< -< /*---------------------------------------------------------------------- -< -< initstrings() -< -< */ -< #ifdef _PROTOTYPES_ -< static void initstrings(void) -< #else -< static void initstrings() -< #endif -< { -< IniElem *init; -< -< for (init = (IniElem *) addrTo(header->init); !endOfTable(init); init++) { -< getstr(init->fpos, init->len); -< memory[init->adr] = pop(); -< } -< } -< -< -< /*---------------------------------------------------------------------- -< -< start() -< -< */ -< #ifdef _PROTOTYPES_ -< static void start(void) -< #else -< static void start() -< #endif -< { -< int startloc; -< -< cur.tick = -1; -< cur.loc = startloc = where(HERO); -< cur.act = HERO; -< cur.score = 0; -< if (trcflg) -< printf("\n\n"); -< interpret(header->start); -< para(); -< -< acts[HERO-ACTMIN].loc = 0; -< locate(HERO, startloc); -< } -< -< -< -< /*---------------------------------------------------------------------- -< init() -< -< Initialization, program load etc. -< -< */ -< #ifdef _PROTOTYPES_ -< static void init(void) -< #else -< static void init() -< #endif -< { -< int i; -< -< /* Initialise some status */ -< etop = 0; /* No pending events */ -< looking = FALSE; /* Not looking now */ -< dscrstkp = 0; /* No describe in progress */ -< -< load(); -< -< initheader(); -< checkdebug(); -< -< /* Initialise string attributes */ -< initstrings(); -< -< getPageSize(); -< -< /* Find first conjunction and use that for ',' handling */ -< for (i = 0; i < dictsize; i++) -< if (isConj(i)) { -< conjWord = i; -< break; -< } -< -< /* Start the adventure */ -< clear(); -< start(); -< } -< -< -< -< /*---------------------------------------------------------------------- -< movactor() -< -< Let the current actor move. If player, ask him. -< -< */ -< #ifdef _PROTOTYPES_ -< static void movactor(void) -< #else -< static void movactor() -< #endif -< { -< ScrElem *scr; -< StepElem *step; -< ActElem *act = (ActElem *) &acts[cur.act-ACTMIN]; -< -< cur.loc = where(cur.act); -< if (cur.act == HERO) { -< parse(); -< fail = FALSE; /* fail only aborts one actor */ -< rules(); -< } else if (act->script != 0) { -< for (scr = (ScrElem *) addrTo(act->scradr); !endOfTable(scr); scr++) -< if (scr->code == act->script) { -< /* Find correct step in the list by indexing */ -< step = (StepElem *) addrTo(scr->steps); -< step = (StepElem *) &step[act->step]; -< /* Now execute it, maybe. First check wait count */ -< if (step->after > act->count) { -< /* Wait some more */ -< if (trcflg) { -< printf("\n\n", -< act->script, act->step+1, step->after-act->count); -< } -< act->count++; -< rules(); -< return; -< } else -< act->count = 0; -< /* Then check possible expression */ -< if (step->exp != 0) { -< if (trcflg) { -< printf("\n\n", -< act->script, act->step+1); -< } -< interpret(step->exp); -< if (!(Abool)pop()) { -< rules(); -< return; /* Hadn't happened yet */ -< } -< } -< /* OK, so finally let him do his thing */ -< act->step++; /* Increment step number before executing... */ -< if (trcflg) { -< printf("\n\n", -< act->script, act->step); -< } -< interpret(step->stm); -< step++; -< /* ... so that we can see if he is USEing another script now */ -< if (act->step != 0 && endOfTable(step)) -< /* No more steps in this script, so stop him */ -< act->script = 0; -< fail = FALSE; /* fail only aborts one actor */ -< rules(); -< return; -< } -< syserr("Unknown actor script."); -< } else if (trcflg) { -< printf("\n\n"); -< rules(); -< return; -< } -< } -< -< /*---------------------------------------------------------------------- -< -< openFiles() -< -< Open the necessary files. -< -< */ -< #ifdef _PROTOTYPES_ -< static void openFiles(void) -< #else -< static void openFiles() -< #endif -< { -< char str[256]; -< char *usr = ""; -< time_t tick; -< -< /* Open Acode file */ -< strcpy(codfnm, advnam); -< strcat(codfnm, ".acd"); -< if ((codfil = fopen(codfnm, READ_MODE)) == NULL) { -< strcpy(str, "Can't open adventure code file '"); -< strcat(str, codfnm); -< strcat(str, "'."); -< syserr(str); -< } -< -< /* Open Text file */ -< strcpy(txtfnm, advnam); -< strcat(txtfnm, ".dat"); -< if ((txtfil = fopen(txtfnm, READ_MODE)) == NULL) { -< strcpy(str, "Can't open adventure text data file '"); -< strcat(str, txtfnm); -< strcat(str, "'."); -< syserr(str); -< } -< -< /* If logging open log file */ -< if (logflg) { -< char *namstart; -< -< if((namstart = strrchr(advnam, ']')) == NULL -< && (namstart = strrchr(advnam, '>')) == NULL -< && (namstart = strrchr(advnam, '/')) == NULL -< && (namstart = strrchr(advnam, '\\')) == NULL -< && (namstart = strrchr(advnam, ':')) == NULL) -< namstart = &advnam[0]; -< else -< namstart++; -< -< time(&tick); -< sprintf(logfnm, "%s%d%s.log", namstart, (int)tick, usr); -< if ((logfil = fopen(logfnm, "w")) == NULL) -< logflg = FALSE; -< } -< } -< -< -< /*====================================================================== -< -< run() -< -< Run the adventure -< -< */ -< void run(void) -< { -< openFiles(); -< -< setjmp(restart_label); /* Return here if he wanted to restart */ -< -< init(); /* Load, initialise and start the adventure */ -< -< while (TRUE) { -< #ifdef MALLOC -< if (malloc_verify() == 0) syserr("Error in heap."); -< #endif -< if (dbgflg) -< debug(); -< -< eventchk(); -< cur.tick++; -< (void) setjmp(jmpbuf); -< -< /* Move all characters */ -< for (cur.act = ACTMIN; cur.act <= ACTMAX; cur.act++) -< movactor(); -< } -< } -< ---- -> /*----------------------------------------------------------------------*\ -> -> MAIN.C -> -> Main module of interpreter for ALAN Adventure Language -> -> \*----------------------------------------------------------------------*/ -> -> #define V27COMPATIBLE -> -> #include "sysdep.h" -> -> #include "types.h" -> #include "main.h" -> -> #include -> #ifdef USE_READLINE -> #include "readline.h" -> #endif -> -> #ifdef HAVE_SHORT_FILENAMES -> #include "av.h" -> #else -> #include "alan.version.h" -> #endif -> -> #include "args.h" -> #include "parse.h" -> #include "inter.h" -> #include "rules.h" -> #ifdef REVERSED -> #include "reverse.h" -> #endif -> #include "debug.h" -> #include "stack.h" -> #include "exe.h" -> #include "term.h" -> -> #ifdef GLK -> #include "glk.h" -> #include "glkio.h" -> #endif -> -> /* PUBLIC DATA */ -> -> /* The Amachine memory */ -> Aword *memory; -> static AcdHdr dummyHeader; /* Dummy to use until memory allocated */ -> AcdHdr *header = &dummyHeader; -> -> int memTop = 0; /* Top of load memory */ -> -> int conjWord; /* First conjunction in dictonary, for ',' */ -> -> -> /* Amachine variables */ -> CurVars cur; -> -> /* Amachine structures */ -> WrdElem *dict; /* Dictionary pointer */ -> ActElem *acts; /* Actor table pointer */ -> LocElem *locs; /* Location table pointer */ -> VrbElem *vrbs; /* Verb table pointer */ -> StxElem *stxs; /* Syntax table pointer */ -> ObjElem *objs; /* Object table pointer */ -> CntElem *cnts; /* Container table pointer */ -> RulElem *ruls; /* Rule table pointer */ -> EvtElem *evts; /* Event table pointer */ -> MsgElem *msgs; /* Message table pointer */ -> Aword *scores; /* Score table pointer */ -> Aword *freq; /* Cumulative character frequencies */ -> -> int dictsize; -> -> Boolean verbose = FALSE; -> Boolean errflg = TRUE; -> Boolean trcflg = FALSE; -> Boolean dbgflg = FALSE; -> Boolean stpflg = FALSE; -> Boolean logflg = FALSE; -> Boolean statusflg = TRUE; -> Boolean fail = FALSE; -> Boolean anyOutput = FALSE; -> -> -> /* The files and filenames */ -> char *advnam; -> FILE *txtfil; -> FILE *logfil; -> -> -> /* Screen formatting info */ -> int col, lin; -> int paglen, pagwidth; -> -> Boolean needsp = FALSE; -> Boolean skipsp = FALSE; -> -> /* Restart jump buffer */ -> jmp_buf restart_label; -> -> -> /* PRIVATE DATA */ -> static jmp_buf jmpbuf; /* Error return long jump buffer */ -> -> -> -> /*====================================================================== -> -> terminate() -> -> Terminate the execution of the adventure, e.g. close windows, -> return buffers... -> -> */ -> #ifdef _PROTOTYPES_ -> void terminate(int code) -> #else -> void terminate(code) -> int code; -> #endif -> { -> #ifdef __amiga__ -> #ifdef AZTEC_C -> #include -> extern struct _dev *_devtab; -> char buf[85]; -> -> if (con) { /* Running from WB, created a console so kill it */ -> /* Running from WB, so we created a console and -> hacked the Aztec C device table to use it for all I/O -> so now we need to make it close it (once!) */ -> _devtab[1].fd = _devtab[2].fd = 0; -> } else -> #else -> /* Geek Gadgets GCC */ -> #include -> #include -> #include -> -> if (_WBenchMsg != NULL) { -> Close(window); -> if (_WBenchMsg->sm_ArgList != NULL) -> UnLock(CurrentDir(cd)); -> } else -> #endif -> #endif -> newline(); -> free(memory); -> if (logflg) -> fclose(logfil); -> -> #ifdef __MWERKS__ -> printf("Command-Q to close window."); -> #endif -> -> #ifdef GLK -> glk_exit(); -> #else -> exit(code); -> #endif -> } -> -> /*====================================================================== -> -> usage() -> -> */ -> #ifdef _PROTOTYPES_ -> void usage(void) -> #else -> void usage() -> #endif -> { -> printf("Usage:\n\n"); -> printf(" %s [] \n\n", PROGNAME); -> printf("where the possible optional switches are:\n"); -> #ifdef GLK -> glk_set_style(style_Preformatted); -> #endif -> printf(" -v verbose mode\n"); -> printf(" -l log player commands and game output to a file\n"); -> printf(" -i ignore version and checksum errors\n"); -> printf(" -n no Status Line\n"); -> printf(" -d enter debug mode\n"); -> printf(" -t trace game execution\n"); -> printf(" -s single instruction trace\n"); -> #ifdef GLK -> glk_set_style(style_Normal); -> #endif -> } -> -> -> /*====================================================================== -> -> syserr() -> -> Print a little text blaming the user for the system error. -> -> */ -> #ifdef _PROTOTYPES_ -> void syserr(char *str) -> #else -> void syserr(str) -> char *str; -> #endif -> { -> output("$n$nAs you enter the twilight zone of Adventures, you stumble \ -> and fall to your knees. In front of you, you can vaguely see the outlines \ -> of an Adventure that never was.$n$nSYSTEM ERROR: "); -> output(str); -> output("$n$n"); -> -> if (logflg) -> fclose(logfil); -> newline(); -> -> #ifdef __amiga__ -> #ifdef AZTEC_C -> { -> char buf[80]; -> -> if (con) { /* Running from WB, wait for user ack. */ -> printf("press RETURN to quit"); -> gets(buf); -> } -> } -> #endif -> #endif -> -> terminate(0); -> } -> -> -> /*====================================================================== -> -> error() -> -> Print an error message, force new player input and abort. -> -> */ -> #ifdef _PROTOTYPES_ -> void error(MsgKind msgno) /* IN - The error message number */ -> #else -> void error(msgno) -> MsgKind msgno; /* IN - The error message number */ -> #endif -> { -> if (msgno != MSGMAX) -> prmsg(msgno); -> wrds[wrdidx] = EOF; /* Force new player input */ -> dscrstkp = 0; /* Reset describe stack */ -> longjmp(jmpbuf,TRUE); -> } -> -> -> /*====================================================================== -> -> statusline() -> -> Print the the status line on the top of the screen. -> -> */ -> void statusline(void) -> { -> #ifdef GLK -> glui32 glkWidth; -> char line[100]; -> int pcol = col; -> -> if (NULL == glkStatusWin) -> return; -> -> glk_set_window(glkStatusWin); -> glk_window_clear(glkStatusWin); -> glk_window_get_size(glkStatusWin, &glkWidth, NULL); -> -> col = 1; -> glk_window_move_cursor(glkStatusWin, 1, 0); -> say(where(HERO)); -> if (header->maxscore > 0) -> sprintf(line, "Score %d(%d)/%d moves", cur.score, (int)header->maxscore, cur.tick); -> else -> sprintf(line, "%d moves", cur.tick); -> glk_window_move_cursor(glkStatusWin, glkWidth - col - strlen(line), 0); -> printf(line); -> needsp = FALSE; -> -> col = pcol; -> -> glk_set_window(glkMainWin); -> #else -> #ifdef HAVE_ANSI -> char line[100]; -> int i; -> int pcol = col; -> -> if (!statusflg) return; -> /* ansi_position(1,1); ansi_bold_on(); */ -> printf("\x1b[1;1H"); -> printf("\x1b[7m"); -> col = 1; -> say(where(HERO)); -> if (header->maxscore > 0) -> sprintf(line, "Score %ld(%ld)/%ld moves", cur.score, (int)header->maxscore, cur.tick); -> else -> sprintf(line, "%ld moves", cur.tick); -> for (i=0; i < pagwidth - col - strlen(line); i++) putchar(' '); -> printf(line); -> printf("\x1b[m"); -> printf("\x1b[%d;1H", paglen); -> needsp = FALSE; -> -> col = pcol; -> #endif -> #endif -> } -> -> -> /*====================================================================== -> -> logprint() -> -> Print some text and log it if logging is on. -> -> */ -> void logprint(char str[]) -> { -> printf(str); -> if (logflg) -> fprintf(logfil, "%s", str); -> } -> -> -> -> /*====================================================================== -> -> newline() -> -> Make a newline, but check for screen full. -> -> */ -> #ifdef _PROTOTYPES_ -> void newline(void) -> #else -> void newline() -> #endif -> { -> #ifdef GLK -> glk_put_char('\n'); -> #else -> char buf[256]; -> -> col = 1; -> if (lin >= paglen - 1) { -> logprint("\n"); -> needsp = FALSE; -> prmsg(M_MORE); -> #ifdef USE_READLINE -> (void) readline(buf); -> #else -> fgets(buf, 256, stdin); -> #endif -> getPageSize(); -> lin = 0; -> } else -> logprint("\n"); -> -> lin++; -> needsp = FALSE; -> #endif -> } -> -> -> /*====================================================================== -> -> para() -> -> Make a new paragraph, i.e one empty line (one or two newlines). -> -> */ -> #ifdef _PROTOTYPES_ -> void para(void) -> #else -> void para() -> #endif -> { -> #ifdef GLK -> glk_put_char('\n'); -> glk_put_char('\n'); -> #else -> if (col != 1) -> newline(); -> newline(); -> #endif -> } -> -> -> /*====================================================================== -> -> clear() -> -> Clear the screen. -> -> */ -> #ifdef _PROTOTYPES_ -> void clear(void) -> #else -> void clear() -> #endif -> { -> #ifdef GLK -> glk_window_clear(glkMainWin); -> #else -> #ifdef HAVE_ANSI -> if (!statusflg) return; -> printf("\x1b[2J"); -> printf("\x1b[%d;1H", paglen); -> #endif -> #endif -> } -> -> -> /*====================================================================== -> -> allocate() -> -> Safely allocate new memory. -> -> */ -> #ifdef _PROTOTYPES_ -> void *allocate(unsigned long len) /* IN - Length to allocate */ -> #else -> void *allocate(len) -> unsigned long len; /* IN - Length to allocate */ -> #endif -> { -> void *p = (void *)malloc((size_t)len); -> -> if (p == NULL) -> syserr("Out of memory."); -> -> return p; -> } -> -> -> /*---------------------------------------------------------------------- -> -> just() -> -> Justify a string so that it wraps at end of screen. -> -> */ -> #ifdef _PROTOTYPES_ -> static void just(char str[]) -> #else -> static void just(str) -> char str[]; -> #endif -> { -> #ifdef GLK -> logprint(str); -> #else -> int i; -> char ch; -> -> if (col >= pagwidth && !skipsp) -> newline(); -> -> while (strlen(str) > pagwidth - col) { -> i = pagwidth - col - 1; -> while (!isSpace(str[i]) && i > 0) /* First find wrap point */ -> i--; -> if (i == 0 && col == 1) /* If it doesn't fit at all */ -> /* Wrap immediately after this word */ -> while (!isSpace(str[i]) && str[i] != '\0') -> i++; -> if (i > 0) { /* If it fits ... */ -> ch = str[i]; /* Save space or NULL */ -> str[i] = '\0'; /* Terminate string */ -> logprint(str); /* and print it */ -> skipsp = FALSE; /* If skipping, now we're done */ -> str[i] = ch; /* Restore character */ -> /* Skip white after printed portion */ -> for (str = &str[i]; isSpace(str[0]) && str[0] != '\0'; str++); -> } -> newline(); /* Then start a new line */ -> } -> logprint(str); /* Print tail */ -> col = col + strlen(str); /* Update column */ -> #endif -> } -> -> -> /*---------------------------------------------------------------------- -> -> space() -> -> Output a space if needed. -> -> */ -> #ifdef _PROTOTYPES_ -> static void space(void) -> #else -> static void space() -> #endif -> { -> if (skipsp) -> skipsp = FALSE; -> else { -> if (needsp) { -> logprint(" "); -> col++; -> } -> } -> needsp = FALSE; -> } -> -> -> -> /*---------------------------------------------------------------------- -> -> sayparam() -> -> A parameter needs to be said, check for words the player used and use -> them if possible. -> -> */ -> #ifdef _PROTOTYPES_ -> static void sayparam(int p) -> #else -> static void sayparam(p) -> int p; -> #endif -> { -> int i; -> -> for (i = 0; i <= p; i++) -> if (params[i].code == EOF) -> syserr("Nonexistent parameter referenced."); -> -> if (params[p].firstWord == EOF) /* Any words he used? */ -> say(params[p].code); -> else /* Yes, so use them... */ -> for (i = params[p].firstWord; i <= params[p].lastWord; i++) { -> just((char *)addrTo(dict[wrds[i]].wrd)); -> if (i < params[p].lastWord) -> just(" "); -> } -> } -> -> -> /*---------------------------------------------------------------------- -> -> prsym() -> -> Print an expanded symbolic reference. -> -> N = newline -> I = indent on a new line -> P = new paragraph -> L = current location name -> O = current object -> first parameter! -> V = current verb -> A = current actor -> T = tabulation -> $ = no space needed after this -> */ -> #ifdef _PROTOTYPES_ -> static void prsym( -> char *str /* IN - The string starting with '$' */ -> ) -> #else -> static void prsym(str) -> char *str; /* IN - The string starting with '$' */ -> #endif -> { -> switch (toLower(str[1])) { -> case 'n': -> newline(); -> needsp = FALSE; -> break; -> case 'i': -> newline(); -> logprint(" "); -> col = 5; -> needsp = FALSE; -> break; -> case 'o': -> sayparam(0); -> needsp = TRUE; /* We did print something non-white */ -> break; -> case '1': -> case '2': -> case '3': -> case '4': -> case '5': -> case '6': -> case '7': -> case '8': -> case '9': -> sayparam(str[1]-'1'); -> needsp = TRUE; /* We did print something non-white */ -> break; -> case 'l': -> say(cur.loc); -> needsp = TRUE; /* We did print something non-white */ -> break; -> case 'a': -> say(cur.act); -> needsp = TRUE; /* We did print something non-white */ -> break; -> case 'v': -> just((char *)addrTo(dict[vrbwrd].wrd)); -> needsp = TRUE; /* We did print something non-white */ -> break; -> case 'p': -> para(); -> needsp = FALSE; -> break; -> case 't': { -> int i; -> int spaces = 4-(col-1)%4; -> -> for (i = 0; i col = col + spaces; -> needsp = FALSE; -> break; -> } -> case '$': -> skipsp = TRUE; -> break; -> default: -> logprint("$"); -> break; -> } -> } -> -> -> -> /*====================================================================== -> -> output() -> -> Output a string to suit the screen. Any symbolic inserts ('$') are -> recogniced and performed. -> -> */ -> #ifdef _PROTOTYPES_ -> void output(char original[]) -> #else -> void output(original) -> char original[]; -> #endif -> { -> char ch; -> char *str, *copy; -> char *symptr; -> -> copy = strdup(original); -> str = copy; -> -> if (str[0] != '$' || str[1] != '$') -> space(); /* Output space if needed (& not inhibited) */ -> -> while ((symptr = strchr(str, '$')) != (char *) NULL) { -> ch = *symptr; /* Terminate before symbol */ -> *symptr = '\0'; -> if (strlen(str) > 0) { -> just(str); /* Output part before '$' */ -> if (str[strlen(str)-1] == ' ') -> needsp = FALSE; -> } -> *symptr = ch; /* restore '$' */ -> prsym(symptr); /* Print the symbolic reference */ -> str = &symptr[2]; /* Advance to after symbol and continue */ -> } -> if (str[0] != 0) { -> just(str); /* Output trailing part */ -> skipsp = FALSE; -> if (str[strlen(str)-1] != ' ') -> needsp = TRUE; -> } -> anyOutput = TRUE; -> free(copy); -> } -> -> -> /*====================================================================== -> -> prmsg() -> -> Print a message from the message table. -> -> */ -> #ifdef _PROTOTYPES_ -> void prmsg(MsgKind msg) /* IN - message number */ -> #else -> void prmsg(msg) -> MsgKind msg; /* IN - message number */ -> #endif -> { -> interpret(msgs[msg].stms); -> } -> -> -> /*----------------------------------------------------------------------*\ -> -> Various check functions -> -> endOfTable() -> isObj, isLoc, isAct, IsCnt & isNum -> -> \*----------------------------------------------------------------------*/ -> -> /* How to know we are at end of a table */ -> #ifdef _PROTOTYPES_ -> Boolean eot(Aword *adr) -> #else -> Boolean eot(adr) -> Aword *adr; -> #endif -> { -> return *adr == EOF; -> } -> -> -> #ifdef _PROTOTYPES_ -> Boolean isObj(Aword x) -> #else -> Boolean isObj(x) -> Aword x; -> #endif -> { -> return x >= OBJMIN && x <= OBJMAX; -> } -> -> #ifdef _PROTOTYPES_ -> Boolean isCnt(Aword x) -> #else -> Boolean isCnt(x) -> Aword x; -> #endif -> { -> return (x >= CNTMIN && x <= CNTMAX) || -> (isObj(x) && objs[x-OBJMIN].cont != 0) || -> (isAct(x) && acts[x-ACTMIN].cont != 0); -> } -> -> #ifdef _PROTOTYPES_ -> Boolean isAct(Aword x) -> #else -> Boolean isAct(x) -> Aword x; -> #endif -> { -> return x >= ACTMIN && x <= ACTMAX; -> } -> -> #ifdef _PROTOTYPES_ -> Boolean isLoc(Aword x) -> #else -> Boolean isLoc(x) -> Aword x; -> #endif -> { -> return x >= LOCMIN && x <= LOCMAX; -> } -> -> #ifdef _PROTOTYPES_ -> Boolean isNum(Aword x) -> #else -> Boolean isNum(x) -> Aword x; -> #endif -> { -> return x >= LITMIN && x <= LITMAX && litValues[x-LITMIN].type == TYPNUM; -> } -> -> #ifdef _PROTOTYPES_ -> Boolean isStr(Aword x) -> #else -> Boolean isStr(x) -> Aword x; -> #endif -> { -> return x >= LITMIN && x <= LITMAX && litValues[x-LITMIN].type == TYPSTR; -> } -> -> #ifdef _PROTOTYPES_ -> Boolean isLit(Aword x) -> #else -> Boolean isLit(x) -> Aword x; -> #endif -> { -> return x >= LITMIN && x <= LITMAX; -> } -> -> -> -> /*====================================================================== -> -> exitto() -> -> Is there an exit from one location to another? -> -> */ -> #ifdef _PROTOTYPES_ -> Boolean exitto(int to, int from) -> #else -> Boolean exitto(to, from) -> int to, from; -> #endif -> { -> ExtElem *ext; -> -> if (locs[from-LOCMIN].exts == 0) -> return(FALSE); /* No exits */ -> -> for (ext = (ExtElem *) addrTo(locs[from-LOCMIN].exts); !endOfTable(ext); ext++) -> if (ext->next == to) -> return(TRUE); -> -> return(FALSE); -> } -> -> -> -> #ifdef CHECKOBJ -> /*====================================================================== -> -> checkobj() -> -> Check that the object given is valid, else print an error message -> or find out what he wanted. -> -> This routine is not used any longer, kept for sentimental reasons ;-) -> -> */ -> void checkobj(obj) -> Aword *obj; -> { -> Aword oldobj; -> -> if (*obj != EOF) -> return; -> -> oldobj = EOF; -> for (cur.obj = OBJMIN; cur.obj <= OBJMAX; cur.obj++) { -> /* If an object is present and it is possible to perform his action */ -> if (isHere(cur.obj) && possible()) -> if (oldobj == EOF) -> oldobj = cur.obj; -> else -> error(WANT); /* And we didn't find multiple objects */ -> } -> -> if (oldobj == EOF) -> error(WANT); /* But we found ONE */ -> -> *obj = cur.obj = oldobj; -> output("($o)"); /* Then he surely meant this object */ -> } -> #endif -> -> -> -> -> /*---------------------------------------------------------------------- -> count() -> -> Count the number of items in a container. -> -> */ -> #ifdef _PROTOTYPES_ -> static int count(int cnt) /* IN - the container to count */ -> #else -> static int count(cnt) -> int cnt; /* IN - the container to count */ -> #endif -> { -> int i, j = 0; -> -> for (i = OBJMIN; i <= OBJMAX; i++) -> if (in(i, cnt)) -> /* Then it's in this container also */ -> j++; -> return(j); -> } -> -> -> -> /*---------------------------------------------------------------------- -> sumatr() -> -> Sum the values of one attribute in a container. Recursively. -> -> */ -> #ifdef _PROTOTYPES_ -> static int sumatr( -> Aword atr, /* IN - the attribute to sum over */ -> Aword cnt /* IN - the container to sum */ -> ) -> #else -> static int sumatr(atr, cnt) -> Aword atr; /* IN - the attribute to sum over */ -> Aword cnt; /* IN - the container to sum */ -> #endif -> { -> int i; -> int sum = 0; -> -> for (i = OBJMIN; i <= OBJMAX; i++) -> if (objs[i-OBJMIN].loc == cnt) { /* Then it's in this container */ -> if (objs[i-OBJMIN].cont != 0) /* This is also a container! */ -> sum = sum + sumatr(atr, i); -> sum = sum + attribute(i, atr); -> } -> return(sum); -> } -> -> -> -> -> /*====================================================================== -> checklim() -> -> Checks if a limit for a container is exceeded. -> -> */ -> #ifdef _PROTOTYPES_ -> Boolean checklim( -> Aword cnt, /* IN - Container code */ -> Aword obj /* IN - The object to add */ -> ) -> #else -> Boolean checklim(cnt, obj) -> Aword cnt; /* IN - Container code */ -> Aword obj; /* IN - The object to add */ -> #endif -> { -> LimElem *lim; -> Aword props; -> -> fail = TRUE; -> if (!isCnt(cnt)) -> syserr("Checking limits for a non-container."); -> -> /* Find the container properties */ -> if (isObj(cnt)) -> props = objs[cnt-OBJMIN].cont; -> else if (isAct(cnt)) -> props = acts[cnt-ACTMIN].cont; -> else -> props = cnt; -> -> if (cnts[props-CNTMIN].lims != 0) { /* Any limits at all? */ -> for (lim = (LimElem *) addrTo(cnts[props-CNTMIN].lims); !endOfTable(lim); lim++) -> if (lim->atr == 0) { -> if (count(cnt) >= lim->val) { -> interpret(lim->stms); -> return(TRUE); /* Limit check failed */ -> } -> } else { -> if (sumatr(lim->atr, cnt) + attribute(obj, lim->atr) > lim->val) { -> interpret(lim->stms); -> return(TRUE); -> } -> } -> } -> fail = FALSE; -> return(FALSE); -> } -> -> -> -> -> -> /*----------------------------------------------------------------------*\ -> -> Action routines -> -> \*----------------------------------------------------------------------*/ -> -> -> -> /*---------------------------------------------------------------------- -> trycheck() -> -> Tries a check, returns TRUE if it passed, FALSE else. -> -> */ -> #ifdef _PROTOTYPES_ -> static Boolean trycheck( -> Aaddr adr, /* IN - ACODE address to check table */ -> Boolean act /* IN - Act if it fails ? */ -> ) -> #else -> static Boolean trycheck(adr, act) -> Aaddr adr; /* IN - ACODE address to check table */ -> Boolean act; /* IN - Act if it fails ? */ -> #endif -> { -> ChkElem *chk; -> -> chk = (ChkElem *) addrTo(adr); -> if (chk->exp == 0) { -> interpret(chk->stms); -> return(FALSE); -> } else { -> while (!endOfTable(chk)) { -> interpret(chk->exp); -> if (!(Abool)pop()) { -> if (act) -> interpret(chk->stms); -> return(FALSE); -> } -> chk++; -> } -> return(TRUE); -> } -> } -> -> -> /*====================================================================== -> go() -> -> Move hero in a direction. -> -> */ -> #ifdef _PROTOTYPES_ -> void go(int dir) -> #else -> void go(dir) -> int dir; -> #endif -> { -> ExtElem *ext; -> Boolean ok; -> Aword oldloc; -> -> ext = (ExtElem *) addrTo(locs[cur.loc-LOCMIN].exts); -> if (locs[cur.loc-LOCMIN].exts != 0) -> while (!endOfTable(ext)) { -> if (ext->code == dir) { -> ok = TRUE; -> if (ext->checks != 0) { -> if (trcflg) { -> printf("\n (char *)addrTo(dict[wrds[wrdidx-1]].wrd), cur.loc); -> debugsay(cur.loc); -> printf("), Checking:>\n"); -> } -> ok = trycheck(ext->checks, TRUE); -> } -> if (ok) { -> oldloc = cur.loc; -> if (ext->action != 0) { -> if (trcflg) { -> printf("\n (char *)addrTo(dict[wrds[wrdidx-1]].wrd), cur.loc); -> debugsay(cur.loc); -> printf("), Executing:>\n"); -> } -> interpret(ext->action); -> } -> /* Still at the same place? */ -> if (where(HERO) == oldloc) { -> if (trcflg) { -> printf("\n (char *)addrTo(dict[wrds[wrdidx-1]].wrd), cur.loc); -> debugsay(cur.loc); -> printf("), Moving:>\n"); -> } -> locate(HERO, ext->next); -> } -> } -> return; -> } -> ext++; -> } -> error(M_NO_WAY); -> } -> -> -> -> /*---------------------------------------------------------------------- -> -> findalt() -> -> Find the verb alternative wanted in a verb list and return -> the address to it. -> -> */ -> #ifdef _PROTOTYPES_ -> static AltElem *findalt( -> Aword vrbsadr, /* IN - Address to start of list */ -> Aword param /* IN - Which parameter to match */ -> ) -> #else -> static AltElem *findalt(vrbsadr, param) -> Aword vrbsadr; /* IN - Address to start of list */ -> Aword param; /* IN - Which parameter to match */ -> #endif -> { -> VrbElem *vrb; -> AltElem *alt; -> -> if (vrbsadr == 0) -> return(NULL); -> -> for (vrb = (VrbElem *) addrTo(vrbsadr); !endOfTable(vrb); vrb++) -> if (vrb->code == cur.vrb) { -> for (alt = (AltElem *) addrTo(vrb->alts); !endOfTable(alt); alt++) -> if (alt->param == param || alt->param == 0) -> return alt; -> return NULL; -> } -> return NULL; -> } -> -> -> -> -> /*====================================================================== -> -> possible() -> -> Check if current action is possible according to the CHECKs. -> -> */ -> #ifdef _PROTOTYPES_ -> Boolean possible(void) -> #else -> Boolean possible() -> #endif -> { -> AltElem *alt[MAXPARAMS+2]; /* List of alt-pointers, one for each param */ -> int i; /* Parameter index */ -> -> fail = FALSE; -> alt[0] = findalt(header->vrbs, 0); -> /* Perform global checks */ -> if (alt[0] != 0 && alt[0]->checks != 0) { -> if (!trycheck(alt[0]->checks, FALSE)) return FALSE; -> if (fail) return FALSE; -> } -> -> /* Now CHECKs in this location */ -> alt[1] = findalt(locs[cur.loc-LOCMIN].vrbs, 0); -> if (alt[1] != 0 && alt[1]->checks != 0) -> if (!trycheck(alt[1]->checks, FALSE)) -> return FALSE; -> -> for (i = 0; params[i].code != EOF; i++) { -> alt[i+2] = findalt(objs[params[i].code-OBJMIN].vrbs, i+1); -> /* CHECKs in a possible parameter */ -> if (alt[i+2] != 0 && alt[i+2]->checks != 0) -> if (!trycheck(alt[i+2]->checks, FALSE)) -> return FALSE; -> } -> -> for (i = 0; i < 2 || params[i-2].code != EOF; i++) -> if (alt[i] != 0 && alt[i]->action != 0) -> break; -> if (i >= 2 && params[i-2].code == EOF) -> /* Didn't find any code for this verb/object combination */ -> return FALSE; -> else -> return TRUE; -> } -> -> -> -> /*---------------------------------------------------------------------- -> -> do_it() -> -> Execute the action commanded by hero. -> -> */ -> #ifdef _PROTOTYPES_ -> static void do_it(void) -> #else -> static void do_it() -> #endif -> { -> AltElem *alt[MAXPARAMS+2]; /* List of alt-pointers, one for each param */ -> Boolean done[MAXPARAMS+2]; /* Is it done */ -> int i; /* Parameter index */ -> char trace[80]; /* Trace string buffer */ -> -> fail = FALSE; -> alt[0] = findalt(header->vrbs, 0); -> /* Perform global checks */ -> if (alt[0] != 0 && alt[0]->checks != 0) { -> if (trcflg) -> printf("\n\n", cur.vrb); -> if (!trycheck(alt[0]->checks, TRUE)) return; -> if (fail) return; -> } -> -> /* Now CHECKs in this location */ -> alt[1] = findalt(locs[cur.loc-LOCMIN].vrbs, 0); -> if (alt[1] != 0 && alt[1]->checks != 0) { -> if (trcflg) -> printf("\n\n", cur.vrb); -> if (!trycheck(alt[1]->checks, TRUE)) return; -> if (fail) return; -> } -> -> for (i = 0; params[i].code != EOF; i++) { -> if (isLit(params[i].code)) -> alt[i+2] = 0; -> else { -> if (isObj(params[i].code)) -> alt[i+2] = findalt(objs[params[i].code-OBJMIN].vrbs, i+1); -> else if (isAct(params[i].code)) -> alt[i+2] = findalt(acts[params[i].code-ACTMIN].vrbs, i+1); -> else -> syserr("Illegal parameter type."); -> /* CHECKs in the parameters */ -> if (alt[i+2] != 0 && alt[i+2]->checks != 0) { -> if (trcflg) -> printf("\n\n", cur.vrb, i); -> if (!trycheck(alt[i+2]->checks, TRUE)) return; -> if (fail) return; -> } -> } -> } -> -> /* Check for anything to execute... */ -> for (i = 0; i < 2 || params[i-2].code != EOF; i++) -> if (alt[i] != 0 && alt[i]->action != 0) -> break; -> if (i >= 2 && params[i-2].code == EOF) -> /* Didn't find any code for this verb/object combination */ -> error(M_CANT0); -> -> /* Perform actions! */ -> -> /* First try any BEFORE or ONLY from outside in */ -> done[0] = FALSE; -> done[1] = FALSE; -> for (i = 2; params[i-2].code != EOF; i++) -> done[i] = FALSE; -> i--; -> while (i >= 0) { -> if (alt[i] != 0) -> if (alt[i]->qual == (Aword)Q_BEFORE || alt[i]->qual == (Aword)Q_ONLY) { -> if (alt[i]->action != 0) { -> if (trcflg) { -> if (i == 0) -> strcpy(trace, "GLOBAL"); -> else if (i == 1) -> strcpy(trace, "in LOCATION"); -> else -> sprintf(trace, "in PARAMETER %d", i-1); -> if (alt[i]->qual == (Aword)Q_BEFORE) -> printf("\n\n", cur.vrb, trace); -> else -> printf("\n\n", cur.vrb, trace); -> } -> interpret(alt[i]->action); -> if (fail) return; -> if (alt[i]->qual == (Aword)Q_ONLY) return; -> } -> done[i] = TRUE; -> } -> i--; -> } -> -> /* Then execute any not declared as AFTER, i.e. the default */ -> for (i = 0; i < 2 || params[i-2].code != EOF; i++) { -> if (alt[i] != 0) -> if (alt[i]->qual != (Aword)Q_AFTER) { -> if (!done[i] && alt[i]->action != 0) { -> if (trcflg) { -> if (i == 0) -> strcpy(trace, "GLOBAL"); -> else if (i == 1) -> strcpy(trace, "in LOCATION"); -> else -> sprintf(trace, "in PARAMETER %d", i-1); -> printf("\n\n", cur.vrb, trace); -> } -> interpret(alt[i]->action); -> if (fail) return; -> } -> done[i] = TRUE; -> } -> } -> -> /* Finally, the ones declared as after */ -> i--; -> while (i >= 0) { -> if (alt[i] != 0) -> if (!done[i] && alt[i]->action != 0) { -> if (trcflg) { -> if (i == 0) -> strcpy(trace, "GLOBAL"); -> else if (i == 1) -> strcpy(trace, "in LOCATION"); -> else -> sprintf(trace, "in PARAMETER %d", i-1); -> printf("\n\n", cur.vrb, trace); -> } -> interpret(alt[i]->action); -> if (fail) return; -> } -> i--; -> } -> } -> -> -> -> /*====================================================================== -> -> action() -> -> Execute all activities commanded. Handles possible multiple actions -> such as THEM or lists of objects. -> -> */ -> #ifdef _PROTOTYPES_ -> void action( -> ParamElem plst[] /* IN - Plural parameter list */ -> ) -> #else -> void action(plst) -> ParamElem plst[]; -> #endif -> { -> int i, mpos; -> char marker[10]; -> -> if (plural) { -> /* -> The code == 0 means this is a multiple position. We must loop -> over this position (and replace it by each present in the plst) -> */ -> for (mpos = 0; params[mpos].code != 0; mpos++); /* Find multiple position */ -> sprintf(marker, "($%d)", mpos+1); /* Prepare a printout with $1/2/3 */ -> for (i = 0; plst[i].code != EOF; i++) { -> params[mpos] = plst[i]; -> output(marker); -> do_it(); -> if (plst[i+1].code != EOF) -> para(); -> } -> params[mpos].code = 0; -> } else -> do_it(); -> } -> -> -> -> /*----------------------------------------------------------------------*\ -> -> Event Handling -> -> eventchk() -> -> \*----------------------------------------------------------------------*/ -> -> -> /*---------------------------------------------------------------------- -> eventchk() -> -> Check if any events are pending. If so execute them. -> */ -> #ifdef _PROTOTYPES_ -> static void eventchk(void) -> #else -> static void eventchk() -> #endif -> { -> while (etop != 0 && eventq[etop-1].time == cur.tick) { -> etop--; -> if (isLoc(eventq[etop].where)) -> cur.loc = eventq[etop].where; -> else -> cur.loc = where(eventq[etop].where); -> if (trcflg) { -> printf("\n debugsay(cur.loc); -> printf("):>\n"); -> } -> interpret(evts[eventq[etop].event-EVTMIN].code); -> } -> } -> -> -> -> -> -> /*----------------------------------------------------------------------*\ -> -> Main program and initialisation -> -> codfil -> filenames -> -> checkvers() -> load() -> checkdebug() -> initheader() -> initstrings() -> start() -> init() -> -> \*----------------------------------------------------------------------*/ -> -> -> static FILE *codfil; -> static char codfnm[256] = ""; -> static char txtfnm[256] = ""; -> static char logfnm[256] = ""; -> -> -> /*---------------------------------------------------------------------- -> -> checkvers() -> -> */ -> #ifdef _PROTOTYPES_ -> static void checkvers(AcdHdr *header) -> #else -> static void checkvers(header) -> AcdHdr *header; -> #endif -> { -> char vers[4]; -> char state[2]; -> -> /* Construct our own version */ -> vers[0] = alan.version.version; -> vers[1] = alan.version.revision; -> -> /* Check version of .ACD file */ -> if (dbgflg) { -> state[0] = header->vers[3]; -> state[1] = '\0'; -> printf("", -> advnam, -> (int)(header->vers[0]), -> (int)(header->vers[1]), -> (int)(header->vers[2]), -> (header->vers[3])==0? "": state); -> newline(); -> } -> -> /* Compatible if version and revision match... */ -> if (strncmp(header->vers, vers, 2) != 0) { -> #ifdef V25COMPATIBLE -> if (header->vers[0] == 2 && header->vers[1] == 5) /* Check for 2.5 version */ -> /* This we can convert later if needed... */; -> else -> #endif -> #ifdef V27COMPATIBLE -> if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ -> /* This we can convert later if needed... */; -> else -> #endif -> if (errflg) { -> char str[80]; -> sprintf(str, "Incompatible version of ACODE program. Game is %ld.%ld, interpreter %ld.%ld.", -> (int)(header->vers[0]), -> (int)(header->vers[1]), -> alan.version.version, -> alan.version.revision); -> syserr(str); -> } else -> output("\n"); -> } -> } -> -> -> /*---------------------------------------------------------------------- -> -> load() -> -> */ -> #ifdef _PROTOTYPES_ -> static void load(void) -> #else -> static void load() -> #endif -> { -> AcdHdr tmphdr; -> Aword crc = 0; -> int i; -> char err[100]; -> -> rewind(codfil); -> fread(&tmphdr, sizeof(tmphdr), 1, codfil); -> rewind(codfil); -> checkvers(&tmphdr); -> -> /* Allocate and load memory */ -> -> #ifdef REVERSED -> reverseHdr(&tmphdr); -> #endif -> -> /* No memory allocated yet? */ -> if (memory == NULL) { -> #ifdef V25COMPATIBLE -> if (tmphdr.vers[0] == 2 && tmphdr.vers[1] == 5) -> /* We need some more memory to expand 2.5 format*/ -> memory = allocate((tmphdr.size+tmphdr.objmax-tmphdr.objmin+1+2)*sizeof(Aword)); -> else -> #endif -> memory = allocate(tmphdr.size*sizeof(Aword)); -> } -> header = (AcdHdr *) addrTo(0); -> -> memTop = fread(addrTo(0), sizeof(Aword), tmphdr.size, codfil); -> if (memTop != tmphdr.size) -> syserr("Could not read all ACD code."); -> -> /* Calculate checksum */ -> for (i = sizeof(tmphdr)/sizeof(Aword); i < memTop; i++) { -> crc += memory[i]&0xff; -> crc += (memory[i]>>8)&0xff; -> crc += (memory[i]>>16)&0xff; -> crc += (memory[i]>>24)&0xff; -> #ifdef CRCLOG -> printf("%6x\t%6lx\t%6lx\n", i, crc, memory[i]); -> #endif -> } -> if (crc != tmphdr.acdcrc) { -> sprintf(err, "Checksum error in .ACD file (0x%lx instead of 0x%lx).", -> crc, tmphdr.acdcrc); -> if (errflg) -> syserr(err); -> else { -> output(" output(err); -> output("$$ Ignored, proceed at your own risk.>$n"); -> } -> } -> -> #ifdef REVERSED -> if (dbgflg||trcflg||stpflg) -> output(" reverseACD(tmphdr.vers[0] == 2 && tmphdr.vers[1] == 5); /* Reverse all words in the ACD file */ -> if (dbgflg||trcflg||stpflg) -> output("OK.>$n"); -> #endif -> -> #ifdef V25COMPATIBLE -> /* Check for 2.5 version */ -> if (tmphdr.vers[0] == 2 && tmphdr.vers[1] == 5) { -> if (dbgflg||trcflg||stpflg) -> output(" c25to26ACD(); -> if (dbgflg||trcflg||stpflg) -> output("OK.>$n"); -> } -> #endif -> -> } -> -> -> /*---------------------------------------------------------------------- -> -> checkdebug() -> -> */ -> #ifdef _PROTOTYPES_ -> static void checkdebug(void) -> #else -> static void checkdebug() -> #endif -> { -> /* Make sure he can't debug if not allowed! */ -> if (!header->debug) { -> if (dbgflg|trcflg|stpflg) -> printf("\n", advnam); -> para(); -> dbgflg = FALSE; -> trcflg = FALSE; -> stpflg = FALSE; -> } -> -> if (dbgflg) /* If debugging */ -> srand(0); /* use no randomization */ -> else -> srand(time(0)); /* seed random generator */ -> } -> -> -> /*---------------------------------------------------------------------- -> -> initheader() -> -> */ -> #ifdef _PROTOTYPES_ -> static void initheader(void) -> #else -> static void initheader() -> #endif -> { -> dict = (WrdElem *) addrTo(header->dict); -> /* Find out number of entries in dictionary */ -> for (dictsize = 0; !endOfTable(&dict[dictsize]); dictsize++); -> vrbs = (VrbElem *) addrTo(header->vrbs); -> stxs = (StxElem *) addrTo(header->stxs); -> locs = (LocElem *) addrTo(header->locs); -> acts = (ActElem *) addrTo(header->acts); -> objs = (ObjElem *) addrTo(header->objs); -> evts = (EvtElem *) addrTo(header->evts); -> cnts = (CntElem *) addrTo(header->cnts); -> ruls = (RulElem *) addrTo(header->ruls); -> msgs = (MsgElem *) addrTo(header->msgs); -> scores = (Aword *) addrTo(header->scores); -> -> if (header->pack) -> freq = (Aword *) addrTo(header->freq); -> } -> -> -> /*---------------------------------------------------------------------- -> -> initstrings() -> -> */ -> #ifdef _PROTOTYPES_ -> static void initstrings(void) -> #else -> static void initstrings() -> #endif -> { -> IniElem *init; -> -> for (init = (IniElem *) addrTo(header->init); !endOfTable(init); init++) { -> getstr(init->fpos, init->len); -> memory[init->adr] = pop(); -> } -> } -> -> -> /*---------------------------------------------------------------------- -> -> start() -> -> */ -> #ifdef _PROTOTYPES_ -> static void start(void) -> #else -> static void start() -> #endif -> { -> int startloc; -> -> cur.tick = -1; -> cur.loc = startloc = where(HERO); -> cur.act = HERO; -> cur.score = 0; -> if (trcflg) -> printf("\n\n"); -> interpret(header->start); -> para(); -> -> acts[HERO-ACTMIN].loc = 0; -> locate(HERO, startloc); -> } -> -> -> -> /*---------------------------------------------------------------------- -> init() -> -> Initialization, program load etc. -> -> */ -> #ifdef _PROTOTYPES_ -> static void init(void) -> #else -> static void init() -> #endif -> { -> int i; -> -> /* Initialise some status */ -> etop = 0; /* No pending events */ -> looking = FALSE; /* Not looking now */ -> dscrstkp = 0; /* No describe in progress */ -> -> load(); -> -> initheader(); -> checkdebug(); -> -> /* Initialise string attributes */ -> initstrings(); -> -> getPageSize(); -> -> /* Find first conjunction and use that for ',' handling */ -> for (i = 0; i < dictsize; i++) -> if (isConj(i)) { -> conjWord = i; -> break; -> } -> -> /* Start the adventure */ -> clear(); -> start(); -> } -> -> -> -> /*---------------------------------------------------------------------- -> movactor() -> -> Let the current actor move. If player, ask him. -> -> */ -> #ifdef _PROTOTYPES_ -> static void movactor(void) -> #else -> static void movactor() -> #endif -> { -> ScrElem *scr; -> StepElem *step; -> ActElem *act = (ActElem *) &acts[cur.act-ACTMIN]; -> -> cur.loc = where(cur.act); -> if (cur.act == HERO) { -> parse(); -> fail = FALSE; /* fail only aborts one actor */ -> rules(); -> } else if (act->script != 0) { -> for (scr = (ScrElem *) addrTo(act->scradr); !endOfTable(scr); scr++) -> if (scr->code == act->script) { -> /* Find correct step in the list by indexing */ -> step = (StepElem *) addrTo(scr->steps); -> step = (StepElem *) &step[act->step]; -> /* Now execute it, maybe. First check wait count */ -> if (step->after > act->count) { -> /* Wait some more */ -> if (trcflg) { -> printf("\n debugsay(cur.act); -> printf(" (at "); -> debugsay(cur.loc); -> printf("), SCRIPT %ld, STEP %ld, Waiting %ld more>\n", -> act->script, act->step+1, step->after-act->count); -> } -> act->count++; -> rules(); -> return; -> } else -> act->count = 0; -> /* Then check possible expression */ -> if (step->exp != 0) { -> if (trcflg) { -> printf("\n debugsay(cur.act); -> printf(" (at "); -> debugsay(cur.loc); -> printf("), SCRIPT %ld, STEP %ld, Evaluating:>\n", -> act->script, act->step+1); -> } -> interpret(step->exp); -> if (!(Abool)pop()) { -> rules(); -> return; /* Hadn't happened yet */ -> } -> } -> /* OK, so finally let him do his thing */ -> act->step++; /* Increment step number before executing... */ -> if (trcflg) { -> printf("\n debugsay(cur.act); -> printf(" (at "); -> debugsay(cur.loc); -> printf("), SCRIPT %ld, STEP %ld, Executing:>\n", -> act->script, act->step); -> } -> interpret(step->stm); -> step++; -> /* ... so that we can see if he is USEing another script now */ -> if (act->step != 0 && endOfTable(step)) -> /* No more steps in this script, so stop him */ -> act->script = 0; -> fail = FALSE; /* fail only aborts one actor */ -> rules(); -> return; -> } -> syserr("Unknown actor script."); -> } else if (trcflg) { -> printf("\n debugsay(cur.act); -> printf(" (at "); -> debugsay(cur.loc); -> printf("), Idle>\n"); -> rules(); -> return; -> } -> } -> -> /*---------------------------------------------------------------------- -> -> openFiles() -> -> Open the necessary files. -> -> */ -> #ifdef _PROTOTYPES_ -> static void openFiles(void) -> #else -> static void openFiles() -> #endif -> { -> char str[256]; -> char *usr = ""; -> time_t tick; -> -> /* Open Acode file */ -> strcpy(codfnm, advnam); -> strcat(codfnm, ".acd"); -> if ((codfil = fopen(codfnm, READ_MODE)) == NULL) { -> strcpy(str, "Can't open adventure code file '"); -> strcat(str, codfnm); -> strcat(str, "'."); -> syserr(str); -> } -> -> /* Open Text file */ -> strcpy(txtfnm, advnam); -> strcat(txtfnm, ".dat"); -> if ((txtfil = fopen(txtfnm, READ_MODE)) == NULL) { -> strcpy(str, "Can't open adventure text data file '"); -> strcat(str, txtfnm); -> strcat(str, "'."); -> syserr(str); -> } -> -> /* If logging open log file */ -> if (logflg) { -> char *namstart; -> -> if((namstart = strrchr(advnam, ']')) == NULL -> && (namstart = strrchr(advnam, '>')) == NULL -> && (namstart = strrchr(advnam, '/')) == NULL -> && (namstart = strrchr(advnam, '\\')) == NULL -> && (namstart = strrchr(advnam, ':')) == NULL) -> namstart = &advnam[0]; -> else -> namstart++; -> -> time(&tick); -> sprintf(logfnm, "%s%d%s.log", namstart, (int)tick, usr); -> if ((logfil = fopen(logfnm, "w")) == NULL) -> logflg = FALSE; -> } -> } -> -> -> /*====================================================================== -> -> run() -> -> Run the adventure -> -> */ -> void run(void) -> { -> openFiles(); -> -> setjmp(restart_label); /* Return here if he wanted to restart */ -> -> init(); /* Load, initialise and start the adventure */ -> -> while (TRUE) { -> #ifdef MALLOC -> if (malloc_verify() == 0) syserr("Error in heap."); -> #endif -> if (dbgflg) -> debug(); -> -> eventchk(); -> cur.tick++; -> (void) setjmp(jmpbuf); -> -> /* Move all characters */ -> for (cur.act = ACTMIN; cur.act <= ACTMAX; cur.act++) -> movactor(); -> } -> } -> -diff -r /home/nothus/orig-terps/interpreter287src/sysdep.h ../terps/alan/alan2/sysdep.h -1,364c1,364 -< /*----------------------------------------------------------------------*\ -< -< sysdep.h Date: 1995-08-19/thoni@softlab.se -< -< System dependencies file for Alan Adventure Language system -< -< N.B. The test for symbols used here should really be of three types -< - processor name (like PC, x86, ...) -< - os name (DOS, WIN32, Solaris2, ...) -< - compiler name and version (DJGPP, CYGWIN, GCC271, THINK-C, ...) -< -< The set symbols should indicate if a feature is on or off like the GNU -< AUTOCONFIG package does. -< -< This is not completely done yet! -< -< \*----------------------------------------------------------------------*/ -< #ifndef _SYSDEP_H_ -< #define _SYSDEP_H_ -< -< -< /* Place definitions of OS and compiler here if necessary */ -< #ifdef AZTEC_C -< #define __amiga__ -< #endif -< -< #ifndef __sun__ -< #ifdef sun -< #define __sun__ -< #endif -< #endif -< -< #ifdef _INCLUDE_HPUX_SOURCE -< #define __hp__ -< #endif -< -< #ifndef __unix__ -< #ifdef unix -< #define __unix__ -< #endif -< #endif -< -< #ifdef vax -< #define __vms__ -< #endif -< -< #ifdef THINK_C -< #define __mac__ -< #endif -< -< #ifdef __MWERKS__ -< #ifdef macintosh -< #define __mac__ -< #else -< #define __dos__ -< #endif -< #endif -< -< #ifdef DOS -< #define __dos__ -< #endif -< -< #ifdef __BORLANDC__ -< #define __dos__ -< #endif -< -< #ifdef __CYGWIN__ -< #define __win__ -< #endif -< -< #ifdef __MINGW32__ -< #define __win__ -< #endif -< -< #ifdef __PACIFIC__ -< #define __dos__ -< #define HAVE_SHORT_FILENAMES -< #endif -< -< -< /*---------------------------------------------------------------------- -< -< Below follows OS and compiler dependent settings. They should not be -< changed except for introducing new sections when porting to new -< environments. -< -< */ -< -< /************/ -< /* Includes */ -< /************/ -< -< #include -< #include -< -< #ifdef __STDC__ -< #define _PROTOTYPES_ -< #include -< #include -< #endif -< -< #ifdef __vms__ -< /* Our VAXC doesn't define __STDC__ */ -< #define _PROTOTYPES_ -< #include -< #include -< #endif -< -< -< #ifdef __mac__ -< #define _PROTOTYPES_ -< #include -< #include -< #include -< #endif -< -< #ifdef __MWERKS__ -< #define strdup _strdup -< #endif -< -< /***********************/ -< /* ISO character sets? */ -< /***********************/ -< -< /* Common case first */ -< #define ISO 1 -< #define NATIVECHARSET 0 -< -< #ifdef GLK -< #undef ISO -< #define ISO 1 -< #undef NATIVECHARSET -< #define NATIVECHARSET 0 -< #else /* Glk is ISO, no matter what the OS */ -< -< #ifdef __dos__ -< #undef ISO -< #define ISO 0 -< #undef NATIVECHARSET -< #define NATIVECHARSET 2 -< #endif -< -< #ifdef __win__ -< #undef ISO -< #define ISO 1 -< #undef NATIVECHARSET -< #define NATIVECHARSET 2 -< #endif -< -< #ifdef __mac__ -< #undef ISO -< #define ISO 0 -< #undef NATIVECHARSET -< #define NATIVECHARSET 1 -< #endif -< -< #endif -< -< /**************************/ -< /* Strings for file modes */ -< /**************************/ -< #define READ_MODE "r" -< #define WRITE_MODE "w" -< -< #ifdef __mac__ -< /* File open mode (binary) */ -< #undef READ_MODE -< #define READ_MODE "rb" -< #undef WRITE_MODE -< #define WRITE_MODE "wb" -< #endif -< -< #ifdef __dos__ -< /* File open mode (binary) */ -< #undef READ_MODE -< #define READ_MODE "rb" -< #undef WRITE_MODE -< #define WRITE_MODE "wb" -< #endif -< -< #ifdef __win__ -< /* File open mode (binary) */ -< #undef READ_MODE -< #define READ_MODE "rb" -< #undef WRITE_MODE -< #define WRITE_MODE "wb" -< #endif -< -< /*****************/ -< /* Byte ordering */ -< /*****************/ -< -< #ifdef __dos__ -< #define REVERSED -< #endif -< -< #ifdef __vms__ -< #define REVERSED -< #endif -< -< #ifdef __win__ -< #define REVERSED -< #endif -< -< -< /****************************/ -< /* Allocates cleared bytes? */ -< /****************************/ -< -< #ifdef __CYGWIN__ -< #define NOTCALLOC -< #endif -< -< #ifdef __MINGW32__ -< #define NOTCALLOC -< #endif -< -< #ifdef __unix__ -< #define NOTCALLOC -< #endif -< -< -< /****************/ -< /* Have termio? */ -< /****************/ -< -< #ifdef GLK -< /* don't need TERMIO */ -< #else -< -< #ifdef __CYGWIN__ -< #define HAVE_TERMIO -< #endif -< -< #ifdef __unix__ -< #define HAVE_TERMIO -< #endif -< -< #endif -< -< /*******************************/ -< /* Is ANSI control available? */ -< /*******************************/ -< -< #ifdef GLK -< /* don't need ANSI */ -< #else -< -< #ifdef __CYGWIN__ -< #define HAVE_ANSI -< #endif -< -< #endif -< -< /******************************/ -< /* Use the READLINE function? */ -< /******************************/ -< -< #ifdef GLK -< /* Glk always uses readline(), no matter what the OS */ -< #define USE_READLINE -< #else -< -< #ifdef __unix__ -< #define USE_READLINE -< #endif -< -< #ifdef x__dos__ -< #define USE_READLINE -< #endif -< -< #ifdef __win__ -< #define USE_READLINE -< #endif -< -< #endif -< -< /* Special cases and definition overrides */ -< #ifdef __unix__ -< #define MULTI -< #endif -< -< -< -< -< #ifdef __vms__ -< -< #define MULTI -< -< extern char *strdup(char str[]); -< -< /* Cheat implementation of strftime */ -< extern size_t strftime (char *, size_t, const char *, const struct tm *); -< -< #endif -< -< #ifdef __mac__ -< -< extern char *strdup(char *str); -< -< #endif -< -< -< #ifdef __dos__ -< -< /* Return codes */ -< #define EXIT_SUCCESS 0 -< #define EXIT_FAILURE 1 -< -< #endif -< -< -< #ifdef _PROTOTYPES_ -< -< /* Native character functions */ -< extern int isSpace(int c); /* IN - Native character to test */ -< extern int isLower(int c); /* IN - Native character to test */ -< extern int isUpper(int c); /* IN - Native character to test */ -< extern int isLetter(int c); /* IN - Native character to test */ -< extern int toLower(int c); /* IN - Native character to convert */ -< extern int toUpper(int c); /* IN - Native character to convert */ -< extern char *strlow(char str[]); /* INOUT - Native string to convert */ -< extern char *strupp(char str[]); /* INOUT - Native string to convert */ -< -< /* ISO character functions */ -< extern int isISOLetter(int c); /* IN - ISO character to test */ -< extern char toLowerCase(int c); /* IN - ISO character to convert */ -< extern char toUpperCase(int c); /* IN - ISO character to convert */ -< extern char *stringLower(char str[]); /* INOUT - ISO string to convert */ -< extern char *stringUpper(char str[]); /* INOUT - ISO string to convert */ -< -< /* ISO string conversion functions */ -< extern void toIso(char copy[], /* OUT - Mapped string */ -< char original[], /* IN - string to convert */ -< int charset); /* IN - The current character set */ -< -< extern void fromIso(char copy[], /* OUT - Mapped string */ -< char original[]); /* IN - string to convert */ -< -< extern void toNative(char copy[], /* OUT - Mapped string */ -< char original[], /* IN - string to convert */ -< int charset); /* IN - current character set */ -< #else -< extern int isSpace(); -< extern int isLower(); -< extern int isUpper(); -< extern int isLetter(); -< extern int toLower(); -< extern int toUpper(); -< extern char *strlow(); -< extern char *strupp(); -< -< extern int isISOLetter(); -< extern char toLowerCase(); -< extern char toUpperCase(); -< extern char *stringLower(); -< extern char *stringUpper(); -< -< extern void toIso(); -< extern void fromIso(); -< #endif -< -< #endif /* -- sysdep.h -- */ -< ---- -> /*----------------------------------------------------------------------*\ -> -> sysdep.h Date: 1995-08-19/thoni@softlab.se -> -> System dependencies file for Alan Adventure Language system -> -> N.B. The test for symbols used here should really be of three types -> - processor name (like PC, x86, ...) -> - os name (DOS, WIN32, Solaris2, ...) -> - compiler name and version (DJGPP, CYGWIN, GCC271, THINK-C, ...) -> -> The set symbols should indicate if a feature is on or off like the GNU -> AUTOCONFIG package does. -> -> This is not completely done yet! -> -> \*----------------------------------------------------------------------*/ -> #ifndef _SYSDEP_H_ -> #define _SYSDEP_H_ -> -> -> /* Place definitions of OS and compiler here if necessary */ -> #ifdef AZTEC_C -> #define __amiga__ -> #endif -> -> #ifndef __sun__ -> #ifdef sun -> #define __sun__ -> #endif -> #endif -> -> #ifdef _INCLUDE_HPUX_SOURCE -> #define __hp__ -> #endif -> -> #ifndef __unix__ -> #ifdef unix -> #define __unix__ -> #endif -> #endif -> -> #ifdef vax -> #define __vms__ -> #endif -> -> #ifdef THINK_C -> #define __mac__ -> #endif -> -> #ifdef __MWERKS__ -> #ifdef macintosh -> #define __mac__ -> #else -> #define __dos__ -> #endif -> #endif -> -> #ifdef DOS -> #define __dos__ -> #endif -> -> #ifdef __BORLANDC__ -> #define __dos__ -> #endif -> -> #ifdef __CYGWIN__ -> #define __win__ -> #endif -> -> #ifdef __MINGW32__ -> #define __win__ -> #endif -> -> #ifdef __PACIFIC__ -> #define __dos__ -> #define HAVE_SHORT_FILENAMES -> #endif -> -> -> /*---------------------------------------------------------------------- -> -> Below follows OS and compiler dependent settings. They should not be -> changed except for introducing new sections when porting to new -> environments. -> -> */ -> -> /************/ -> /* Includes */ -> /************/ -> -> #include -> #include -> -> #ifdef __STDC__ -> #define _PROTOTYPES_ -> #include -> #include -> #endif -> -> #ifdef __vms__ -> /* Our VAXC doesn't define __STDC__ */ -> #define _PROTOTYPES_ -> #include -> #include -> #endif -> -> -> #ifdef __mac__ -> #define _PROTOTYPES_ -> #include -> #include -> #include -> #endif -> -> #ifdef __MWERKS__ -> #define strdup _strdup -> #endif -> -> /***********************/ -> /* ISO character sets? */ -> /***********************/ -> -> /* Common case first */ -> #define ISO 1 -> #define NATIVECHARSET 0 -> -> #ifdef GLK -> #undef ISO -> #define ISO 1 -> #undef NATIVECHARSET -> #define NATIVECHARSET 0 -> #else /* Glk is ISO, no matter what the OS */ -> -> #ifdef __dos__ -> #undef ISO -> #define ISO 0 -> #undef NATIVECHARSET -> #define NATIVECHARSET 2 -> #endif -> -> #ifdef __win__ -> #undef ISO -> #define ISO 1 -> #undef NATIVECHARSET -> #define NATIVECHARSET 2 -> #endif -> -> #ifdef __mac__ -> #undef ISO -> #define ISO 0 -> #undef NATIVECHARSET -> #define NATIVECHARSET 1 -> #endif -> -> #endif -> -> /**************************/ -> /* Strings for file modes */ -> /**************************/ -> #define READ_MODE "r" -> #define WRITE_MODE "w" -> -> #ifdef __mac__ -> /* File open mode (binary) */ -> #undef READ_MODE -> #define READ_MODE "rb" -> #undef WRITE_MODE -> #define WRITE_MODE "wb" -> #endif -> -> #ifdef __dos__ -> /* File open mode (binary) */ -> #undef READ_MODE -> #define READ_MODE "rb" -> #undef WRITE_MODE -> #define WRITE_MODE "wb" -> #endif -> -> #ifdef __win__ -> /* File open mode (binary) */ -> #undef READ_MODE -> #define READ_MODE "rb" -> #undef WRITE_MODE -> #define WRITE_MODE "wb" -> #endif -> -> /*****************/ -> /* Byte ordering */ -> /*****************/ -> -> #ifdef __dos__ -> #define REVERSED -> #endif -> -> #ifdef __vms__ -> #define REVERSED -> #endif -> -> #ifdef __win__ -> #define REVERSED -> #endif -> -> -> /****************************/ -> /* Allocates cleared bytes? */ -> /****************************/ -> -> #ifdef __CYGWIN__ -> #define NOTCALLOC -> #endif -> -> #ifdef __MINGW32__ -> #define NOTCALLOC -> #endif -> -> #ifdef __unix__ -> #define NOTCALLOC -> #endif -> -> -> /****************/ -> /* Have termio? */ -> /****************/ -> -> #ifdef GLK -> /* don't need TERMIO */ -> #else -> -> #ifdef __CYGWIN__ -> #define HAVE_TERMIO -> #endif -> -> #ifdef __unix__ -> #define HAVE_TERMIO -> #endif -> -> #endif -> -> /*******************************/ -> /* Is ANSI control available? */ -> /*******************************/ -> -> #ifdef GLK -> /* don't need ANSI */ -> #else -> -> #ifdef __CYGWIN__ -> #define HAVE_ANSI -> #endif -> -> #endif -> -> /******************************/ -> /* Use the READLINE function? */ -> /******************************/ -> -> #ifdef GLK -> /* Glk always uses readline(), no matter what the OS */ -> #define USE_READLINE -> #else -> -> #ifdef __unix__ -> #define USE_READLINE -> #endif -> -> #ifdef x__dos__ -> #define USE_READLINE -> #endif -> -> #ifdef __win__ -> #define USE_READLINE -> #endif -> -> #endif -> -> /* Special cases and definition overrides */ -> #ifdef __unix__ -> #define MULTI -> #endif -> -> -> -> -> #ifdef __vms__ -> -> #define MULTI -> -> extern char *strdup(char str[]); -> -> /* Cheat implementation of strftime */ -> extern size_t strftime (char *, size_t, const char *, const struct tm *); -> -> #endif -> -> #ifdef __mac__ -> -> extern char *strdup(char *str); -> -> #endif -> -> -> #ifdef __dos__ -> -> /* Return codes */ -> #define EXIT_SUCCESS 0 -> #define EXIT_FAILURE 1 -> -> #endif -> -> -> #ifdef _PROTOTYPES_ -> -> /* Native character functions */ -> extern int isSpace(int c); /* IN - Native character to test */ -> extern int isLower(int c); /* IN - Native character to test */ -> extern int isUpper(int c); /* IN - Native character to test */ -> extern int isLetter(int c); /* IN - Native character to test */ -> extern int toLower(int c); /* IN - Native character to convert */ -> extern int toUpper(int c); /* IN - Native character to convert */ -> extern char *strlow(char str[]); /* INOUT - Native string to convert */ -> extern char *strupp(char str[]); /* INOUT - Native string to convert */ -> -> /* ISO character functions */ -> extern int isISOLetter(int c); /* IN - ISO character to test */ -> extern char toLowerCase(int c); /* IN - ISO character to convert */ -> extern char toUpperCase(int c); /* IN - ISO character to convert */ -> extern char *stringLower(char str[]); /* INOUT - ISO string to convert */ -> extern char *stringUpper(char str[]); /* INOUT - ISO string to convert */ -> -> /* ISO string conversion functions */ -> extern void toIso(char copy[], /* OUT - Mapped string */ -> char original[], /* IN - string to convert */ -> int charset); /* IN - The current character set */ -> -> extern void fromIso(char copy[], /* OUT - Mapped string */ -> char original[]); /* IN - string to convert */ -> -> extern void toNative(char copy[], /* OUT - Mapped string */ -> char original[], /* IN - string to convert */ -> int charset); /* IN - current character set */ -> #else -> extern int isSpace(); -> extern int isLower(); -> extern int isUpper(); -> extern int isLetter(); -> extern int toLower(); -> extern int toUpper(); -> extern char *strlow(); -> extern char *strupp(); -> -> extern int isISOLetter(); -> extern char toLowerCase(); -> extern char toUpperCase(); -> extern char *stringLower(); -> extern char *stringUpper(); -> -> extern void toIso(); -> extern void fromIso(); -> #endif -> -> #endif /* -- sysdep.h -- */ -> diff --git a/app/src/main/jni/diffs/babel.diff b/app/src/main/jni/diffs/babel.diff deleted file mode 100644 index 7e2fb58..0000000 --- a/app/src/main/jni/diffs/babel.diff +++ /dev/null @@ -1,3 +0,0 @@ -Only in utilities/babel/: babel_android.c -Only in utilities/babel/: babel_android.h -Only in utilities/babel/: babel_rev9.txt diff --git a/app/src/main/jni/diffs/bocfel.diff b/app/src/main/jni/diffs/bocfel.diff deleted file mode 100644 index e69de29..0000000 diff --git a/app/src/main/jni/diffs/git.diff b/app/src/main/jni/diffs/git.diff deleted file mode 100644 index 19a28ea..0000000 --- a/app/src/main/jni/diffs/git.diff +++ /dev/null @@ -1,643 +0,0 @@ -diff -r Git-1.3.5/glkop.c terps/git/glkop.c -75,86c75,76 -< #define CaptureCArray(addr, len, passin) \ -< (grab_temp_c_array(addr, len, passin)) -< #define ReleaseCArray(ptr, addr, len, passout) \ -< (release_temp_c_array(ptr, addr, len, passout)) -< #define CaptureIArray(addr, len, passin) \ -< (grab_temp_i_array(addr, len, passin)) -< #define ReleaseIArray(ptr, addr, len, passout) \ -< (release_temp_i_array(ptr, addr, len, passout)) -< #define CapturePtrArray(addr, len, objclass, passin) \ -< (grab_temp_ptr_array(addr, len, objclass, passin)) -< #define ReleasePtrArray(ptr, addr, len, objclass, passout) \ -< (release_temp_ptr_array(ptr, addr, len, objclass, passout)) ---- -> #define AddressOfArray(addr) \ -> ((addr) < gRamStart ? (gInitMem + (addr)) : (gMem + (addr))) -196,258d185 -< /* We maintain a linked list of arrays being used for Glk calls. It is -< only used for integer (glui32) arrays -- char arrays are handled in -< place. It's not worth bothering with a hash table, since most -< arrays appear here only momentarily. */ -< -< typedef struct arrayref_struct arrayref_t; -< struct arrayref_struct { -< void *array; -< glui32 addr; -< glui32 elemsize; -< glui32 len; /* elements */ -< int retained; -< arrayref_t *next; -< }; -< -< static arrayref_t *arrays = NULL; -< -< /* We maintain a hash table for each opaque Glk class. classref_t are the -< nodes of the table, and classtable_t are the tables themselves. */ -< -< typedef struct classref_struct classref_t; -< struct classref_struct { -< void *obj; -< glui32 id; -< int bucknum; -< classref_t *next; -< }; -< -< #define CLASSHASH_SIZE (31) -< typedef struct classtable_struct { -< glui32 lastid; -< classref_t *bucket[CLASSHASH_SIZE]; -< } classtable_t; -< -< /* The list of hash tables, for the git_classes. */ -< static int num_classes = 0; -< classtable_t **git_classes = NULL; -< -< static classtable_t *new_classtable(glui32 firstid); -< static void *classes_get(int classid, glui32 objid); -< static classref_t *classes_put(int classid, void *obj, glui32 origid); -< static void classes_remove(int classid, void *obj); -< -< static gidispatch_rock_t glulxe_classtable_register(void *obj, -< glui32 objclass); -< static void glulxe_classtable_unregister(void *obj, glui32 objclass, -< gidispatch_rock_t objrock); -< static gidispatch_rock_t glulxe_retained_register(void *array, -< glui32 len, char *typecode); -< static void glulxe_retained_unregister(void *array, glui32 len, -< char *typecode, gidispatch_rock_t objrock); -< -< /* The library_select_hook is called every time the VM blocks for input. -< The app might take this opportunity to autosave, for example. */ -< static void (*library_select_hook)(glui32) = NULL; -< -< static char *grab_temp_c_array(glui32 addr, glui32 len, int passin); -< static void release_temp_c_array(char *arr, glui32 addr, glui32 len, int passout); -< static glui32 *grab_temp_i_array(glui32 addr, glui32 len, int passin); -< static void release_temp_i_array(glui32 *arr, glui32 addr, glui32 len, int passout); -< static void **grab_temp_ptr_array(glui32 addr, glui32 len, int objclass, int passin); -< static void release_temp_ptr_array(void **arr, glui32 addr, glui32 len, int objclass, int passout); -< -265,266d191 -< static maybe_unused char *get_game_id(void); -< -272,303d196 -< int ix; -< -< /* What with one thing and another, this *could* be called more than -< once. We only need to allocate the tables once. */ -< if (git_classes) -< return TRUE; -< -< /* Set up the game-ID hook. (This is ifdeffed because not all Glk -< libraries have this call.) */ -< #ifdef GI_DISPA_GAME_ID_AVAILABLE -< gidispatch_set_game_id_hook(&get_game_id); -< #endif /* GI_DISPA_GAME_ID_AVAILABLE */ -< -< /* Allocate the class hash tables. */ -< num_classes = gidispatch_count_classes(); -< git_classes = (classtable_t **)glulx_malloc(num_classes -< * sizeof(classtable_t *)); -< if (!git_classes) -< return FALSE; -< -< for (ix=0; ix garglist[gargnum].array = (void*) AddressOfArray(varglist[ix]); -651c536 -< garglist[gargnum].array = CaptureIArray(varglist[ix], varglist[ix+1], passin); ---- -> garglist[gargnum].array = AddressOfArray(varglist[ix]); -659c544 -< garglist[gargnum].array = CapturePtrArray(varglist[ix], varglist[ix+1], (*cx-'a'), passin); ---- -> garglist[gargnum].array = AddressOfArray(varglist[ix]); -706,715c591 -< if (thisval) { -< opref = classes_get(*cx-'a', thisval); -< if (!opref) { -< fatalError("Reference to nonexistent Glk object."); -< } -< } -< else { -< opref = NULL; -< } -< garglist[gargnum].opaqueref = opref; ---- -> garglist[gargnum].opaqueref = (void *) thisval; -851d726 -< ReleaseCArray(garglist[gargnum].array, varglist[ix], varglist[ix+1], passout); -858d732 -< ReleaseIArray(garglist[gargnum].array, varglist[ix], varglist[ix+1], passout); -865d738 -< ReleasePtrArray(garglist[gargnum].array, varglist[ix], varglist[ix+1], (*cx-'a'), passout); -901,909c774 -< opref = garglist[gargnum].opaqueref; -< if (opref) { -< gidispatch_rock_t objrock = -< gidispatch_get_objrock(opref, *cx-'a'); -< thisval = ((classref_t *)objrock.ptr)->id; -< } -< else { -< thisval = 0; -< } ---- -> thisval = (glui32)garglist[gargnum].opaqueref; -1011,1012c876 -< /* Recall that class 1 ("b") is streams. */ -< return classes_get(gidisp_Class_Stream, objid); ---- -> return (strid_t) objid; -1020,1021d883 -< gidispatch_rock_t objrock; -< -1025,1026c887 -< objrock = gidispatch_get_objrock(win, gidisp_Class_Window); -< return ((classref_t *)objrock.ptr)->id; ---- -> return (glui32) win; -1034,1035d894 -< gidispatch_rock_t objrock; -< -1039,1040c898 -< objrock = gidispatch_get_objrock(str, gidisp_Class_Stream); -< return ((classref_t *)objrock.ptr)->id; ---- -> return (glui32) str; -1048,1049d905 -< gidispatch_rock_t objrock; -< -1053,1054c909 -< objrock = gidispatch_get_objrock(fref, gidisp_Class_Fileref); -< return ((classref_t *)objrock.ptr)->id; ---- -> return (glui32) fref; -1062,1063d916 -< gidispatch_rock_t objrock; -< -1067,1207c920 -< objrock = gidispatch_get_objrock(schan, gidisp_Class_Schannel); -< return ((classref_t *)objrock.ptr)->id; -< } -< -< /* Build a hash table to hold a set of Glk objects. */ -< static classtable_t *new_classtable(glui32 firstid) -< { -< int ix; -< classtable_t *ctab = (classtable_t *)glulx_malloc(sizeof(classtable_t)); -< if (!ctab) -< return NULL; -< -< for (ix=0; ixbucket[ix] = NULL; -< -< ctab->lastid = firstid; -< -< return ctab; -< } -< -< /* Find a Glk object in the appropriate hash table. */ -< static void *classes_get(int classid, glui32 objid) -< { -< classtable_t *ctab; -< classref_t *cref; -< if (classid < 0 || classid >= num_classes) -< return NULL; -< ctab = git_classes[classid]; -< cref = ctab->bucket[objid % CLASSHASH_SIZE]; -< for (; cref; cref = cref->next) { -< if (cref->id == objid) -< return cref->obj; -< } -< return NULL; -< } -< -< /* Put a Glk object in the appropriate hash table. If origid is zero, -< invent a new unique ID for it. */ -< static classref_t *classes_put(int classid, void *obj, glui32 origid) -< { -< int bucknum; -< classtable_t *ctab; -< classref_t *cref; -< if (classid < 0 || classid >= num_classes) -< return NULL; -< ctab = git_classes[classid]; -< cref = (classref_t *)glulx_malloc(sizeof(classref_t)); -< if (!cref) -< return NULL; -< cref->obj = obj; -< if (!origid) { -< cref->id = ctab->lastid; -< ctab->lastid++; -< } -< else { -< cref->id = origid; -< if (ctab->lastid <= origid) -< ctab->lastid = origid+1; -< } -< bucknum = cref->id % CLASSHASH_SIZE; -< cref->bucknum = bucknum; -< cref->next = ctab->bucket[bucknum]; -< ctab->bucket[bucknum] = cref; -< return cref; -< } -< -< /* Delete a Glk object from the appropriate hash table. */ -< static void classes_remove(int classid, void *obj) -< { -< classtable_t *ctab; -< classref_t *cref; -< classref_t **crefp; -< gidispatch_rock_t objrock; -< if (classid < 0 || classid >= num_classes) -< return; -< ctab = git_classes[classid]; -< objrock = gidispatch_get_objrock(obj, classid); -< cref = objrock.ptr; -< if (!cref) -< return; -< crefp = &(ctab->bucket[cref->bucknum]); -< for (; *crefp; crefp = &((*crefp)->next)) { -< if ((*crefp) == cref) { -< *crefp = cref->next; -< cref->obj = NULL; -< cref->id = 0; -< cref->next = NULL; -< glulx_free(cref); -< return; -< } -< } -< return; -< } -< -< /* The object registration/unregistration callbacks that the library calls -< to keep the hash tables up to date. */ -< -< static gidispatch_rock_t glulxe_classtable_register(void *obj, -< glui32 objclass) -< { -< classref_t *cref; -< gidispatch_rock_t objrock; -< cref = classes_put(objclass, obj, 0); -< objrock.ptr = cref; -< return objrock; -< } -< -< static void glulxe_classtable_unregister(void *obj, glui32 objclass, -< gidispatch_rock_t objrock) -< { -< classes_remove(objclass, obj); -< } -< -< static char *grab_temp_c_array(glui32 addr, glui32 len, int passin) -< { -< arrayref_t *arref = NULL; -< char *arr = NULL; -< glui32 ix, addr2; -< -< if (len) { -< arr = (char *)glulx_malloc(len * sizeof(char)); -< arref = (arrayref_t *)glulx_malloc(sizeof(arrayref_t)); -< if (!arr || !arref) -< fatalError("Unable to allocate space for array argument to Glk call."); -< -< arref->array = arr; -< arref->addr = addr; -< arref->elemsize = 1; -< arref->retained = FALSE; -< arref->len = len; -< arref->next = arrays; -< arrays = arref; -< -< if (passin) { -< for (ix=0, addr2=addr; ix return (glui32) schan; -1209,1504d921 -< -< static void release_temp_c_array(char *arr, glui32 addr, glui32 len, int passout) -< { -< arrayref_t *arref = NULL; -< arrayref_t **aptr; -< glui32 ix, val, addr2; -< -< if (arr) { -< for (aptr=(&arrays); (*aptr); aptr=(&((*aptr)->next))) { -< if ((*aptr)->array == arr) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatalError("Unable to re-find array argument in Glk call."); -< if (arref->addr != addr || arref->len != len) -< fatalError("Mismatched array argument in Glk call."); -< -< if (arref->retained) { -< return; -< } -< -< *aptr = arref->next; -< arref->next = NULL; -< -< if (passout) { -< for (ix=0, addr2=addr; ixarray = arr; -< arref->addr = addr; -< arref->elemsize = 4; -< arref->retained = FALSE; -< arref->len = len; -< arref->next = arrays; -< arrays = arref; -< -< if (passin) { -< for (ix=0, addr2=addr; ixnext))) { -< if ((*aptr)->array == arr) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatalError("Unable to re-find array argument in Glk call."); -< if (arref->addr != addr || arref->len != len) -< fatalError("Mismatched array argument in Glk call."); -< -< if (arref->retained) { -< return; -< } -< -< *aptr = arref->next; -< arref->next = NULL; -< -< if (passout) { -< for (ix=0, addr2=addr; ixarray = arr; -< arref->addr = addr; -< arref->elemsize = sizeof(void *); -< arref->retained = FALSE; -< arref->len = len; -< arref->next = arrays; -< arrays = arref; -< -< if (passin) { -< for (ix=0, addr2=addr; ixnext))) { -< if ((*aptr)->array == arr) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatalError("Unable to re-find array argument in Glk call."); -< if (arref->addr != addr || arref->len != len) -< fatalError("Mismatched array argument in Glk call."); -< -< if (arref->retained) { -< return; -< } -< -< *aptr = arref->next; -< arref->next = NULL; -< -< if (passout) { -< for (ix=0, addr2=addr; ixid; -< } -< else { -< val = 0; -< } -< memWrite32(addr2, val); -< } -< } -< glulx_free(arr); -< glulx_free(arref); -< } -< } -< -< static gidispatch_rock_t glulxe_retained_register(void *array, -< glui32 len, char *typecode) -< { -< gidispatch_rock_t rock; -< arrayref_t *arref = NULL; -< arrayref_t **aptr; -< int elemsize = 0; -< -< if (typecode[4] == 'C') -< elemsize = 1; -< else if (typecode[4] == 'I') -< elemsize = 4; -< -< if (!elemsize || array == NULL) { -< rock.ptr = NULL; -< return rock; -< } -< -< for (aptr=(&arrays); (*aptr); aptr=(&((*aptr)->next))) { -< if ((*aptr)->array == array) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatalError("Unable to re-find array argument in Glk call."); -< if (arref->elemsize != elemsize || arref->len != len) -< fatalError("Mismatched array argument in Glk call."); -< -< arref->retained = TRUE; -< -< rock.ptr = arref; -< return rock; -< } -< -< static void glulxe_retained_unregister(void *array, glui32 len, -< char *typecode, gidispatch_rock_t objrock) -< { -< arrayref_t *arref = NULL; -< arrayref_t **aptr; -< glui32 ix, addr2, val; -< int elemsize = 0; -< -< if (typecode[4] == 'C') -< elemsize = 1; -< else if (typecode[4] == 'I') -< elemsize = 4; -< -< if (!elemsize || array == NULL) { -< return; -< } -< -< for (aptr=(&arrays); (*aptr); aptr=(&((*aptr)->next))) { -< if ((*aptr)->array == array) -< break; -< } -< arref = *aptr; -< if (!arref) { -< if (objrock.num == 0) -< return; -< fatalError("Unable to re-find array argument in Glk call."); -< } -< if (arref != objrock.ptr) -< fatalError("Mismatched array reference in Glk call."); -< if (!arref->retained) -< fatalError("Unretained array reference in Glk call."); -< if (arref->elemsize != elemsize || arref->len != len) -< fatalError("Mismatched array argument in Glk call."); -< -< *aptr = arref->next; -< arref->next = NULL; -< -< if (elemsize == 1) { -< for (ix=0, addr2=arref->addr; ixlen; ix++, addr2+=1) { -< val = ((char *)array)[ix]; -< memWrite8(addr2, val); -< } -< } -< else if (elemsize == 4) { -< for (ix=0, addr2=arref->addr; ixlen; ix++, addr2+=4) { -< val = ((glui32 *)array)[ix]; -< memWrite32(addr2, val); -< } -< } -< -< glulx_free(array); -< glulx_free(arref); -< } -< -< void set_library_select_hook(void (*func)(glui32)) -< { -< library_select_hook = func; -< } -< -< /* Create a string identifying this game. We use the first 64 bytes of the -< memory map, encoded as hex, -< */ -< static char *get_game_id() -< { -< /* This buffer gets rewritten on every call, but that's okay -- the caller -< is supposed to copy out the result. */ -< static char buf[2*64+2]; -< int ix, jx; -< -< if (!gInitMem) -< return NULL; -< -< for (ix=0, jx=0; ix<64; ix++) { -< char ch = gInitMem[ix]; -< int val = ((ch >> 4) & 0x0F); -< buf[jx++] = ((val < 10) ? (val + '0') : (val + 'A' - 10)); -< val = (ch & 0x0F); -< buf[jx++] = ((val < 10) ? (val + '0') : (val + 'A' - 10)); -< } -< buf[jx++] = '\0'; -< -< return buf; -< } -< diff --git a/app/src/main/jni/diffs/glulxe.diff b/app/src/main/jni/diffs/glulxe.diff deleted file mode 100644 index 9890ee7..0000000 --- a/app/src/main/jni/diffs/glulxe.diff +++ /dev/null @@ -1,739 +0,0 @@ -diff -r glulxe-master/glkop.c terps/glulxe/glkop.c -54,65d53 -< #define CaptureCArray(addr, len, passin) \ -< (grab_temp_c_array(addr, len, passin)) -< #define ReleaseCArray(ptr, addr, len, passout) \ -< (release_temp_c_array(ptr, addr, len, passout)) -< #define CaptureIArray(addr, len, passin) \ -< (grab_temp_i_array(addr, len, passin)) -< #define ReleaseIArray(ptr, addr, len, passout) \ -< (release_temp_i_array(ptr, addr, len, passout)) -< #define CapturePtrArray(addr, len, objclass, passin) \ -< (grab_temp_ptr_array(addr, len, objclass, passin)) -< #define ReleasePtrArray(ptr, addr, len, objclass, passout) \ -< (release_temp_ptr_array(ptr, addr, len, objclass, passout)) -69a58,59 -> #define AddressOfArray(addr) \ -> ((addr) < ramstart ? (gamefile_start + (addr)) : (memmap + (addr))) -96,166d85 -< /* We maintain a linked list of arrays being used for Glk calls. It is -< only used for integer (glui32) arrays -- char arrays are handled in -< place. It's not worth bothering with a hash table, since most -< arrays appear here only momentarily. */ -< -< typedef struct arrayref_struct arrayref_t; -< struct arrayref_struct { -< void *array; -< glui32 addr; -< glui32 elemsize; -< glui32 len; /* elements */ -< int retained; -< arrayref_t *next; -< }; -< -< static arrayref_t *arrays = NULL; -< -< /* We maintain a hash table for each opaque Glk class. classref_t are the -< nodes of the table, and classtable_t are the tables themselves. */ -< -< typedef struct classref_struct classref_t; -< struct classref_struct { -< void *obj; -< glui32 id; -< int bucknum; -< classref_t *next; -< }; -< -< #define CLASSHASH_SIZE (31) -< typedef struct classtable_struct { -< glui32 lastid; -< classref_t *bucket[CLASSHASH_SIZE]; -< } classtable_t; -< -< /* The list of hash tables, for the classes. */ -< static int num_classes = 0; -< classtable_t **classes = NULL; -< -< static classtable_t *new_classtable(glui32 firstid); -< static void *classes_get(int classid, glui32 objid); -< static classref_t *classes_put(int classid, void *obj, glui32 origid); -< static void classes_remove(int classid, void *obj); -< -< static gidispatch_rock_t glulxe_classtable_register(void *obj, -< glui32 objclass); -< static void glulxe_classtable_unregister(void *obj, glui32 objclass, -< gidispatch_rock_t objrock); -< static gidispatch_rock_t glulxe_retained_register(void *array, -< glui32 len, char *typecode); -< static void glulxe_retained_unregister(void *array, glui32 len, -< char *typecode, gidispatch_rock_t objrock); -< static long glulxe_array_locate(void *array, glui32 len, -< char *typecode, gidispatch_rock_t objrock, int *elemsizeref); -< static gidispatch_rock_t glulxe_array_restore(long bufkey, -< glui32 len, char *typecode, void **arrayref); -< -< /* This is only needed for autorestore. */ -< extern gidispatch_rock_t glulxe_classtable_register_existing(void *obj, -< glui32 objclass, glui32 dispid); -< -< /* The library_select_hook is called every time the VM blocks for input. -< The app might take this opportunity to autosave, for example. */ -< static void (*library_select_hook)(glui32) = NULL; -< -< static char *grab_temp_c_array(glui32 addr, glui32 len, int passin); -< static void release_temp_c_array(char *arr, glui32 addr, glui32 len, int passout); -< static glui32 *grab_temp_i_array(glui32 addr, glui32 len, int passin); -< static void release_temp_i_array(glui32 *arr, glui32 addr, glui32 len, int passout); -< static void **grab_temp_ptr_array(glui32 addr, glui32 len, int objclass, int passin); -< static void release_temp_ptr_array(void **arr, glui32 addr, glui32 len, int objclass, int passout); -< -173,174d91 -< static char *get_game_id(void); -< -180,218d96 -< int ix; -< -< /* What with one thing and another, this *could* be called more than -< once. We only need to allocate the tables once. */ -< if (classes) -< return TRUE; -< -< /* Set up the game-ID hook. (This is ifdeffed because not all Glk -< libraries have this call.) */ -< #ifdef GI_DISPA_GAME_ID_AVAILABLE -< gidispatch_set_game_id_hook(&get_game_id); -< #endif /* GI_DISPA_GAME_ID_AVAILABLE */ -< -< /* Allocate the class hash tables. */ -< num_classes = gidispatch_count_classes(); -< classes = (classtable_t **)glulx_malloc(num_classes -< * sizeof(classtable_t *)); -< if (!classes) -< return FALSE; -< -< for (ix=0; ix garglist[gargnum].array = (void*) AddressOfArray(varglist[ix]); -574c444 -< garglist[gargnum].array = CaptureIArray(varglist[ix], varglist[ix+1], passin); ---- -> garglist[gargnum].array = AddressOfArray(varglist[ix]); -586c456 -< garglist[gargnum].array = CapturePtrArray(varglist[ix], varglist[ix+1], (*cx-'a'), passin); ---- -> garglist[gargnum].array = AddressOfArray(varglist[ix]); -633,642c503 -< if (thisval) { -< opref = classes_get(*cx-'a', thisval); -< if (!opref) { -< fatal_error("Reference to nonexistent Glk object."); -< } -< } -< else { -< opref = NULL; -< } -< garglist[gargnum].opaqueref = opref; ---- -> garglist[gargnum].opaqueref = (void *) thisval; -778d638 -< ReleaseCArray(garglist[gargnum].array, varglist[ix], varglist[ix+1], passout); -785d644 -< ReleaseIArray(garglist[gargnum].array, varglist[ix], varglist[ix+1], passout); -792d650 -< ReleasePtrArray(garglist[gargnum].array, varglist[ix], varglist[ix+1], (*cx-'a'), passout); -828,836c686 -< opref = garglist[gargnum].opaqueref; -< if (opref) { -< gidispatch_rock_t objrock = -< gidispatch_get_objrock(opref, *cx-'a'); -< thisval = ((classref_t *)objrock.ptr)->id; -< } -< else { -< thisval = 0; -< } ---- -> thisval = (glui32)garglist[gargnum].opaqueref; -939c789 -< return classes_get(gidisp_Class_Stream, objid); ---- -> return (strid_t) objid; -947,948d796 -< gidispatch_rock_t objrock; -< -952,955c800 -< objrock = gidispatch_get_objrock(win, gidisp_Class_Window); -< if (!objrock.ptr) -< return 0; -< return ((classref_t *)objrock.ptr)->id; ---- -> return (glui32) win; -963,964d807 -< gidispatch_rock_t objrock; -< -968,971c811 -< objrock = gidispatch_get_objrock(str, gidisp_Class_Stream); -< if (!objrock.ptr) -< return 0; -< return ((classref_t *)objrock.ptr)->id; ---- -> return (glui32) str; -979,980d818 -< gidispatch_rock_t objrock; -< -984,987c822 -< objrock = gidispatch_get_objrock(fref, gidisp_Class_Fileref); -< if (!objrock.ptr) -< return 0; -< return ((classref_t *)objrock.ptr)->id; ---- -> return (glui32) fref; -995,996d829 -< gidispatch_rock_t objrock; -< -1000,1513c833 -< objrock = gidispatch_get_objrock(schan, gidisp_Class_Schannel); -< if (!objrock.ptr) -< return 0; -< return ((classref_t *)objrock.ptr)->id; -< } -< -< /* Build a hash table to hold a set of Glk objects. */ -< static classtable_t *new_classtable(glui32 firstid) -< { -< int ix; -< classtable_t *ctab = (classtable_t *)glulx_malloc(sizeof(classtable_t)); -< if (!ctab) -< return NULL; -< -< for (ix=0; ixbucket[ix] = NULL; -< -< ctab->lastid = firstid; -< -< return ctab; -< } -< -< /* Find a Glk object in the appropriate hash table. */ -< static void *classes_get(int classid, glui32 objid) -< { -< classtable_t *ctab; -< classref_t *cref; -< if (classid < 0 || classid >= num_classes) -< return NULL; -< ctab = classes[classid]; -< cref = ctab->bucket[objid % CLASSHASH_SIZE]; -< for (; cref; cref = cref->next) { -< if (cref->id == objid) -< return cref->obj; -< } -< return NULL; -< } -< -< /* Put a Glk object in the appropriate hash table. If origid is zero, -< invent a new unique ID for it. */ -< static classref_t *classes_put(int classid, void *obj, glui32 origid) -< { -< int bucknum; -< classtable_t *ctab; -< classref_t *cref; -< if (classid < 0 || classid >= num_classes) -< return NULL; -< ctab = classes[classid]; -< cref = (classref_t *)glulx_malloc(sizeof(classref_t)); -< if (!cref) -< return NULL; -< cref->obj = obj; -< if (!origid) { -< cref->id = ctab->lastid; -< ctab->lastid++; -< } -< else { -< cref->id = origid; -< if (ctab->lastid <= origid) -< ctab->lastid = origid+1; -< } -< bucknum = cref->id % CLASSHASH_SIZE; -< cref->bucknum = bucknum; -< cref->next = ctab->bucket[bucknum]; -< ctab->bucket[bucknum] = cref; -< return cref; -< } -< -< /* Delete a Glk object from the appropriate hash table. */ -< static void classes_remove(int classid, void *obj) -< { -< classtable_t *ctab; -< classref_t *cref; -< classref_t **crefp; -< gidispatch_rock_t objrock; -< if (classid < 0 || classid >= num_classes) -< return; -< ctab = classes[classid]; -< objrock = gidispatch_get_objrock(obj, classid); -< cref = objrock.ptr; -< if (!cref) -< return; -< crefp = &(ctab->bucket[cref->bucknum]); -< for (; *crefp; crefp = &((*crefp)->next)) { -< if ((*crefp) == cref) { -< *crefp = cref->next; -< if (!cref->obj) { -< nonfatal_warning("attempt to free NULL object!"); -< } -< cref->obj = NULL; -< cref->id = 0; -< cref->next = NULL; -< glulx_free(cref); -< return; -< } -< } -< return; -< } -< -< /* The object registration/unregistration callbacks that the library calls -< to keep the hash tables up to date. */ -< -< static gidispatch_rock_t glulxe_classtable_register(void *obj, -< glui32 objclass) -< { -< classref_t *cref; -< gidispatch_rock_t objrock; -< cref = classes_put(objclass, obj, 0); -< objrock.ptr = cref; -< return objrock; -< } -< -< static void glulxe_classtable_unregister(void *obj, glui32 objclass, -< gidispatch_rock_t objrock) -< { -< classes_remove(objclass, obj); -< } -< -< gidispatch_rock_t glulxe_classtable_register_existing(void *obj, -< glui32 objclass, glui32 dispid) -< { -< classref_t *cref; -< gidispatch_rock_t objrock; -< cref = classes_put(objclass, obj, dispid); -< objrock.ptr = cref; -< return objrock; -< } -< -< static char *grab_temp_c_array(glui32 addr, glui32 len, int passin) -< { -< arrayref_t *arref = NULL; -< char *arr = NULL; -< glui32 ix, addr2; -< -< if (len) { -< arr = (char *)glulx_malloc(len * sizeof(char)); -< arref = (arrayref_t *)glulx_malloc(sizeof(arrayref_t)); -< if (!arr || !arref) -< fatal_error("Unable to allocate space for array argument to Glk call."); -< -< arref->array = arr; -< arref->addr = addr; -< arref->elemsize = 1; -< arref->retained = FALSE; -< arref->len = len; -< arref->next = arrays; -< arrays = arref; -< -< if (passin) { -< for (ix=0, addr2=addr; ixnext))) { -< if ((*aptr)->array == arr) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatal_error("Unable to re-find array argument in Glk call."); -< if (arref->addr != addr || arref->len != len) -< fatal_error("Mismatched array argument in Glk call."); -< -< if (arref->retained) { -< return; -< } -< -< *aptr = arref->next; -< arref->next = NULL; -< -< if (passout) { -< for (ix=0, addr2=addr; ixarray = arr; -< arref->addr = addr; -< arref->elemsize = 4; -< arref->retained = FALSE; -< arref->len = len; -< arref->next = arrays; -< arrays = arref; -< -< if (passin) { -< for (ix=0, addr2=addr; ixnext))) { -< if ((*aptr)->array == arr) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatal_error("Unable to re-find array argument in Glk call."); -< if (arref->addr != addr || arref->len != len) -< fatal_error("Mismatched array argument in Glk call."); -< -< if (arref->retained) { -< return; -< } -< -< *aptr = arref->next; -< arref->next = NULL; -< -< if (passout) { -< for (ix=0, addr2=addr; ixarray = arr; -< arref->addr = addr; -< arref->elemsize = sizeof(void *); -< arref->retained = FALSE; -< arref->len = len; -< arref->next = arrays; -< arrays = arref; -< -< if (passin) { -< for (ix=0, addr2=addr; ixnext))) { -< if ((*aptr)->array == arr) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatal_error("Unable to re-find array argument in Glk call."); -< if (arref->addr != addr || arref->len != len) -< fatal_error("Mismatched array argument in Glk call."); -< -< if (arref->retained) { -< return; -< } -< -< *aptr = arref->next; -< arref->next = NULL; -< -< if (passout) { -< for (ix=0, addr2=addr; ixid; -< } -< else { -< val = 0; -< } -< MemW4(addr2, val); -< } -< } -< glulx_free(arr); -< glulx_free(arref); -< } -< } -< -< static gidispatch_rock_t glulxe_retained_register(void *array, -< glui32 len, char *typecode) -< { -< gidispatch_rock_t rock; -< arrayref_t *arref = NULL; -< arrayref_t **aptr; -< int elemsize = 0; -< -< if (typecode[4] == 'C') -< elemsize = 1; -< else if (typecode[4] == 'I') -< elemsize = 4; -< -< if (!elemsize || array == NULL) { -< rock.ptr = NULL; -< return rock; -< } -< -< for (aptr=(&arrays); (*aptr); aptr=(&((*aptr)->next))) { -< if ((*aptr)->array == array) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatal_error("Unable to re-find array argument in Glk call."); -< if (arref->elemsize != elemsize || arref->len != len) -< fatal_error("Mismatched array argument in Glk call."); -< -< arref->retained = TRUE; -< -< rock.ptr = arref; -< return rock; -< } -< -< static void glulxe_retained_unregister(void *array, glui32 len, -< char *typecode, gidispatch_rock_t objrock) -< { -< arrayref_t *arref = NULL; -< arrayref_t **aptr; -< glui32 ix, addr2, val; -< int elemsize = 0; -< -< if (typecode[4] == 'C') -< elemsize = 1; -< else if (typecode[4] == 'I') -< elemsize = 4; -< -< if (!elemsize || array == NULL) { -< return; -< } -< -< for (aptr=(&arrays); (*aptr); aptr=(&((*aptr)->next))) { -< if ((*aptr)->array == array) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatal_error("Unable to re-find array argument in Glk call."); -< if (arref != objrock.ptr) -< fatal_error("Mismatched array reference in Glk call."); -< if (!arref->retained) -< fatal_error("Unretained array reference in Glk call."); -< if (arref->elemsize != elemsize || arref->len != len) -< fatal_error("Mismatched array argument in Glk call."); -< -< *aptr = arref->next; -< arref->next = NULL; -< -< if (elemsize == 1) { -< for (ix=0, addr2=arref->addr; ixlen; ix++, addr2+=1) { -< val = ((char *)array)[ix]; -< MemW1(addr2, val); -< } -< } -< else if (elemsize == 4) { -< for (ix=0, addr2=arref->addr; ixlen; ix++, addr2+=4) { -< val = ((glui32 *)array)[ix]; -< MemW4(addr2, val); -< } -< } -< -< glulx_free(array); -< glulx_free(arref); -< } -< -< static long glulxe_array_locate(void *array, glui32 len, -< char *typecode, gidispatch_rock_t objrock, int *elemsizeref) -< { -< arrayref_t *arref = NULL; -< arrayref_t **aptr; -< int elemsize = 0; -< -< if (typecode[4] == 'C') -< elemsize = 1; -< else if (typecode[4] == 'I') -< elemsize = 4; -< -< if (!elemsize || array == NULL) { -< *elemsizeref = 0; /* No need to save the array separately */ -< return (unsigned char *)array - memmap; -< } -< -< for (aptr=(&arrays); (*aptr); aptr=(&((*aptr)->next))) { -< if ((*aptr)->array == array) -< break; -< } -< arref = *aptr; -< if (!arref) -< fatal_error("Unable to re-find array argument in array_locate."); -< if (arref != objrock.ptr) -< fatal_error("Mismatched array reference in array_locate."); -< if (!arref->retained) -< fatal_error("Unretained array reference in array_locate."); -< if (arref->elemsize != elemsize || arref->len != len) -< fatal_error("Mismatched array argument in array_locate."); -< -< *elemsizeref = arref->elemsize; -< return arref->addr; -< } -< -< static gidispatch_rock_t glulxe_array_restore(long bufkey, -< glui32 len, char *typecode, void **arrayref) -< { -< gidispatch_rock_t rock; -< int elemsize = 0; -< -< if (typecode[4] == 'C') -< elemsize = 1; -< else if (typecode[4] == 'I') -< elemsize = 4; -< -< if (!elemsize) { -< unsigned char *buf = memmap + bufkey; -< *arrayref = buf; -< rock.ptr = NULL; -< return rock; -< } -< -< if (elemsize == 1) { -< char *cbuf = grab_temp_c_array(bufkey, len, FALSE); -< rock = glulxe_retained_register(cbuf, len, typecode); -< *arrayref = cbuf; -< } -< else { -< glui32 *ubuf = grab_temp_i_array(bufkey, len, FALSE); -< rock = glulxe_retained_register(ubuf, len, typecode); -< *arrayref = ubuf; -< } -< return rock; -< } -< -< void set_library_select_hook(void (*func)(glui32)) -< { -< library_select_hook = func; -< } -< -< /* Create a string identifying this game. We use the first 64 bytes of the -< memory map, encoded as hex, -< */ -< static char *get_game_id() -< { -< /* This buffer gets rewritten on every call, but that's okay -- the caller -< is supposed to copy out the result. */ -< static char buf[2*64+2]; -< int ix, jx; -< -< if (!memmap) -< return NULL; -< -< for (ix=0, jx=0; ix<64; ix++) { -< char ch = memmap[ix]; -< int val = ((ch >> 4) & 0x0F); -< buf[jx++] = ((val < 10) ? (val + '0') : (val + 'A' - 10)); -< val = (ch & 0x0F); -< buf[jx++] = ((val < 10) ? (val + '0') : (val + 'A' - 10)); -< } -< buf[jx++] = '\0'; -< -< return buf; ---- -> return (glui32) schan; diff --git a/app/src/main/jni/diffs/hugo.diff b/app/src/main/jni/diffs/hugo.diff deleted file mode 100644 index e59d668..0000000 --- a/app/src/main/jni/diffs/hugo.diff +++ /dev/null @@ -1,169 +0,0 @@ -diff -r hugov31_source/heglk/heglk.c terps/hugo/heglk/heglk.c -38a39,41 -> #ifdef GARGLK -> #include "hemedia.c" /* gargoyle! */ -> #endif -Only in terps/hugo/heglk: hemedia.c -diff -r hugov31_source/source/hemisc.c terps/hugo/source/hemisc.c -1343c1343 -< printf(line); ---- -> printf("%s", line); -1362c1362 -< printf(line); ---- -> printf("%s", line); -2204,2213c2204,2213 -< case 'a': s = (char)0xe0; break; /* */ -< case 'e': s = (char)0xe8; break; /* */ -< case 'i': s = (char)0xec; break; /* */ -< case 'o': s = (char)0xf2; break; /* */ -< case 'u': s = (char)0xf9; break; /* */ -< case 'A': s = (char)0xc0; break; /* */ -< case 'E': s = (char)0xc8; break; /* */ -< case 'I': s = (char)0xcc; break; /* */ -< case 'O': s = (char)0xd2; break; /* */ -< case 'U': s = (char)0xd9; break; /* */ ---- -> case 'a': s = (char)0xe0; break; /* \E0 */ -> case 'e': s = (char)0xe8; break; /* \E8 */ -> case 'i': s = (char)0xec; break; /* \EC */ -> case 'o': s = (char)0xf2; break; /* \F2 */ -> case 'u': s = (char)0xf9; break; /* \F9 */ -> case 'A': s = (char)0xc0; break; /* \C0 */ -> case 'E': s = (char)0xc8; break; /* \C8 */ -> case 'I': s = (char)0xcc; break; /* \CC */ -> case 'O': s = (char)0xd2; break; /* \D2 */ -> case 'U': s = (char)0xd9; break; /* \D9 */ -2224,2228c2224,2228 -< case 'a': s = (char)0xe1; break; /* */ -< case 'e': s = (char)0xe9; break; /* */ -< case 'i': s = (char)0xed; break; /* */ -< case 'o': s = (char)0xf3; break; /* */ -< case 'u': s = (char)0xfa; break; /* */ ---- -> case 'a': s = (char)0xe1; break; /* \E1 */ -> case 'e': s = (char)0xe9; break; /* \E9 */ -> case 'i': s = (char)0xed; break; /* \ED */ -> case 'o': s = (char)0xf3; break; /* \F3 */ -> case 'u': s = (char)0xfa; break; /* \FA */ -2230,2235c2230,2235 -< case 'A': s = (char)0xc1; break; /* */ -< case 'E': s = (char)0xc9; break; /* */ -< case 'I': s = (char)0xcd; break; /* */ -< case 'O': s = (char)0xd3; break; /* */ -< case 'U': s = (char)0xda; break; /* */ -< case 'Y': s = (char)0xdd; break; /* */ ---- -> case 'A': s = (char)0xc1; break; /* \C1 */ -> case 'E': s = (char)0xc9; break; /* \C9 */ -> case 'I': s = (char)0xcd; break; /* \CD */ -> case 'O': s = (char)0xd3; break; /* \D3 */ -> case 'U': s = (char)0xda; break; /* \DA */ -> case 'Y': s = (char)0xdd; break; /* \DD */ -2246,2251c2246,2251 -< case 'a': s = (char)0xe3; break; /* */ -< case 'n': s = (char)0xf1; break; /* */ -< case 'o': s = (char)0xf5; break; /* */ -< case 'A': s = (char)0xc3; break; /* */ -< case 'N': s = (char)0xd1; break; /* */ -< case 'O': s = (char)0xd5; break; /* */ ---- -> case 'a': s = (char)0xe3; break; /* \E3 */ -> case 'n': s = (char)0xf1; break; /* \F1 */ -> case 'o': s = (char)0xf5; break; /* \F5 */ -> case 'A': s = (char)0xc3; break; /* \C3 */ -> case 'N': s = (char)0xd1; break; /* \D1 */ -> case 'O': s = (char)0xd5; break; /* \D5 */ -2262,2271c2262,2271 -< case 'a': s = (char)0xe2; break; /* */ -< case 'e': s = (char)0xea; break; /* */ -< case 'i': s = (char)0xee; break; /* */ -< case 'o': s = (char)0xf4; break; /* */ -< case 'u': s = (char)0xfb; break; /* */ -< case 'A': s = (char)0xc2; break; /* */ -< case 'E': s = (char)0xca; break; /* */ -< case 'I': s = (char)0xce; break; /* */ -< case 'O': s = (char)0xd4; break; /* */ -< case 'U': s = (char)0xdb; break; /* */ ---- -> case 'a': s = (char)0xe2; break; /* \E2 */ -> case 'e': s = (char)0xea; break; /* \EA */ -> case 'i': s = (char)0xee; break; /* \EE */ -> case 'o': s = (char)0xf4; break; /* \F4 */ -> case 'u': s = (char)0xfb; break; /* \FB */ -> case 'A': s = (char)0xc2; break; /* \C2 */ -> case 'E': s = (char)0xca; break; /* \CA */ -> case 'I': s = (char)0xce; break; /* \CE */ -> case 'O': s = (char)0xd4; break; /* \D4 */ -> case 'U': s = (char)0xdb; break; /* \DB */ -2282,2292c2282,2292 -< case 'a': s = (char)0xe4; break; /* */ -< case 'e': s = (char)0xeb; break; /* */ -< case 'i': s = (char)0xef; break; /* */ -< case 'o': s = (char)0xf6; break; /* */ -< case 'u': s = (char)0xfc; break; /* */ -< /* case 'y': s = (char)0xff; break; */ /* */ -< case 'A': s = (char)0xc4; break; /* */ -< case 'E': s = (char)0xcb; break; /* */ -< case 'I': s = (char)0xcf; break; /* */ -< case 'O': s = (char)0xd6; break; /* */ -< case 'U': s = (char)0xdc; break; /* */ ---- -> case 'a': s = (char)0xe4; break; /* \E4 */ -> case 'e': s = (char)0xeb; break; /* \EB */ -> case 'i': s = (char)0xef; break; /* \EF */ -> case 'o': s = (char)0xf6; break; /* \F6 */ -> case 'u': s = (char)0xfc; break; /* \FC */ -> /* case 'y': s = (char)0xff; break; */ /* \FF */ -> case 'A': s = (char)0xc4; break; /* \C4 */ -> case 'E': s = (char)0xcb; break; /* \CB */ -> case 'I': s = (char)0xcf; break; /* \CF */ -> case 'O': s = (char)0xd6; break; /* \D6 */ -> case 'U': s = (char)0xdc; break; /* \DC */ -2303,2304c2303,2304 -< case 'C': s = (char)0xc7; break; /* */ -< case 'c': s = (char)0xe7; break; /* */ ---- -> case 'C': s = (char)0xc7; break; /* \C7 */ -> case 'c': s = (char)0xe7; break; /* \E7 */ -2311c2311 -< s = (char)0xab; /* */ ---- -> s = (char)0xab; /* \AB */ -2316c2316 -< s = (char)0xbb; /* */ ---- -> s = (char)0xbb; /* \BB */ -2321c2321 -< s = (char)0xa1; /* */ ---- -> s = (char)0xa1; /* \A1 */ -2326c2326 -< s = (char)0xbf; /* */ ---- -> s = (char)0xbf; /* \BF */ -2331c2331 -< s = (char)0xe6; ++*i; /* */ ---- -> s = (char)0xe6; ++*i; /* \E6 */ -2338c2338 -< s = (char)0xc6; ++*i; /* */ ---- -> s = (char)0xc6; ++*i; /* \C6 */ -2345c2345 -< s = (char)0xa2; /* */ ---- -> s = (char)0xa2; /* \A2 */ -2350c2350 -< s = (char)0xa3; /* */ ---- -> s = (char)0xa3; /* \A3 */ -2355c2355 -< s = (char)0xa5; /* */ ---- -> s = (char)0xa5; /* \A5 */ -2360c2360 -< /* s = (char)0x97; */ /* */ ---- -> /* s = (char)0x97; */ /* \97 */ diff --git a/app/src/main/jni/diffs/level9.diff b/app/src/main/jni/diffs/level9.diff deleted file mode 100644 index 7a8bea4..0000000 --- a/app/src/main/jni/diffs/level9.diff +++ /dev/null @@ -1,11 +0,0 @@ -diff -r Level9_5.1_Source/level9.h terps/level9/level9.h -23a24 -> #include -25,27c26,28 -< typedef unsigned char L9BYTE; -< typedef unsigned short L9UINT16; -< typedef unsigned long L9UINT32; ---- -> typedef uint8_t L9BYTE; -> typedef uint16_t L9UINT16; -> typedef uint32_t L9UINT32; diff --git a/app/src/main/jni/diffs/magnetic.diff b/app/src/main/jni/diffs/magnetic.diff deleted file mode 100644 index 09823e6..0000000 --- a/app/src/main/jni/diffs/magnetic.diff +++ /dev/null @@ -1,42 +0,0 @@ -diff -r Magnetic23Src/Generic/defs.h terps/magnetic/Generic/defs.h -36a37 -> #include -38,43c39,44 -< typedef unsigned char type8; -< typedef signed char type8s; -< typedef unsigned short type16; -< typedef signed short type16s; -< typedef unsigned long type32; -< typedef signed long type32s; ---- -> typedef uint8_t type8; -> typedef int8_t type8s; -> typedef uint16_t type16; -> typedef int16_t type16s; -> typedef uint32_t type32; -> typedef int32_t type32s; -diff -r Magnetic23Src/Glk/glk.c terps/magnetic/Glk/glk.c -3906,3908c3906,3908 -< void ms_playmusic(type8 * midi_data, type32 length, type16 tempo) -< { -< } ---- -> void ms_playmusic(type8 * midi_data, type32 length, type16 tempo) -> { -> } -5507a5508 -> #ifndef FAB -5510a5512 -> #endif -5530a5533 -> #ifndef FAB -5568a5572 -> #endif -5580a5585 -> #ifndef FAB -5583a5589 -> #endif -5613a5620 -> #ifndef FAB -5636a5644 -> #endif diff --git a/app/src/main/jni/diffs/scare.diff b/app/src/main/jni/diffs/scare.diff deleted file mode 100644 index d4ae981..0000000 --- a/app/src/main/jni/diffs/scare.diff +++ /dev/null @@ -1,159 +0,0 @@ -diff -r scare-1.3.10/source/os_glk.c terps/scare/source/os_glk.c -1704a1705,1817 -> #ifdef FAB -> -> /* Fabularium addition - 2016: we follow the same tactic as the HUGO media */ -> #define PIC 0 -> #define SND 1 -> #define MAXRES 1024 -> -> static long resids[2][MAXRES]; -> static int numres[2] = { 0, 0 }; -> static schanid_t schannel = NULL; -> static char *gsclinux_game_file = NULL; -> -> static int loadres(FILE* infile, int reslen, int type) -> { -> char buf[4096]; -> frefid_t fileref; -> strid_t stream; -> long offset; -> int id; -> int i, n; -> -> offset = ftell(infile); -> for (i = 0; i < numres[type]; i++) -> if (resids[type][i] == offset) -> return i; -> -> /* Too many resources loaded... */ -> if (numres[type] + 1 == MAXRES) -> return -1; -> -> id = numres[type]++; -> sprintf(buf, "%s%d", type == PIC ? "PIC" : "SND", id); -> resids[type][id] = offset; -> -> fileref = glk_fileref_create_by_name(fileusage_Data, buf, 0); -> if (!fileref) -> { -> return -1; -> } -> -> stream = glk_stream_open_file(fileref, filemode_Write, 0); -> if (!stream) -> { -> glk_fileref_destroy(fileref); -> return -1; -> } -> -> glk_fileref_destroy(fileref); -> -> while (reslen > 0) -> { -> n = fread(buf, 1, reslen < sizeof buf ? reslen : sizeof buf, infile); -> if (n <= 0) -> break; -> glk_put_buffer_stream(stream, buf, n); -> reslen -= n; -> } -> -> glk_stream_close(stream, NULL); -> -> return id; -> } -> -> void initsound() -> { -> if (!glk_gestalt(gestalt_Sound, 0)) -> return; -> schannel = glk_schannel_create(0); -> } -> -> void -> os_play_sound (const sc_char *filepath, -> sc_int offset, sc_int length, sc_bool is_looping) -> { -> const sc_char *unused1; -> unused1 = filepath; -> -> if (!schannel) initsound(); -> -> if (schannel && length > 0) -> { -> FILE* f = fopen(gsclinux_game_file, "r"); -> int id; -> if (f == NULL) { -> /* error */ -> return; -> } -> if (fseek(f, offset, SEEK_SET) < 0) { -> /* error */ -> fclose(f); -> return; -> } -> id = loadres(f, length, SND); -> if (id < 0) { -> /* error */ -> fclose(f); -> return; -> } -> fclose(f); -> glk_schannel_play_ext(schannel, id, is_looping ? -1 : 1, 0); -> } -> } -> -> void -> os_stop_sound (void) -> { -> if (!schannel) initsound(); -> if (!schannel) return; -> glk_schannel_stop(schannel); -> } -> -> #else -> -1728c1841 -< ---- -> #endif -1773a1887,1919 -> #ifdef FAB -> void -> os_show_graphic (const sc_char *filepath, sc_int offset, sc_int length) -> { -> const sc_char *unused1; -> unused1 = filepath; -> -> if (length > 0) { -> FILE* f = fopen(gsclinux_game_file, "r"); -> int id; -> if (f == NULL) { -> /* error */ -> return; -> } -> if (fseek(f, offset, SEEK_SET) < 0) { -> /* error */ -> fclose(f); -> return; -> } -> id = loadres(f, length, PIC); -> if (id < 0) { -> /* error */ -> fclose(f); -> return; -> } -> fclose(f); -> -> /* Draw, then move cursor down to the next line. */ -> glk_image_draw(gsc_main_window, id, imagealign_InlineUp, 0); -> glk_put_char('\n'); -> } -> } -> #else -1783a1930 -> #endif -3455c3602 -< #ifdef LINUX_GRAPHICS ---- -> #if defined(LINUX_GRAPHICS) || defined(FAB) diff --git a/app/src/main/jni/diffs/scott.diff b/app/src/main/jni/diffs/scott.diff deleted file mode 100644 index e69de29..0000000 diff --git a/app/src/main/jni/diffs/tads.diff b/app/src/main/jni/diffs/tads.diff deleted file mode 100644 index 0c04473..0000000 --- a/app/src/main/jni/diffs/tads.diff +++ /dev/null @@ -1,7336 +0,0 @@ -Only in terps/tads: oemfab.c -Only in terps/tads: osfab.cc -Only in terps/tads: osfab.h -Only in terps/tads: osglk.c -Only in terps/tads: ost3comp.cc -diff -r /home/nothus/orig-terps/tads/tads2/os.h terps/tads/tads2/os.h -109a110,119 -> /* -> * The Fabularium app is defined to work on multiple architectures, especially -> * ARM, which doesn't have x86's tolerance for unaligned pointer dereferencing. -> * So we use the PPC definitions which are more strict, at the cost of slightly -> * worse performance. -> */ -> #ifdef FAB -> #include "h_ppc.h" -> #endif -> -191a202,206 -> -> #ifdef FAB -> /* Fabularium-specific definitions are in osfab.h */ -> #include "osfab.h" -> #endif -diff -r /home/nothus/orig-terps/tads/tads2/output.c terps/tads/tads2/output.c -1,3579c1,3580 -< #ifdef RCSID -< static char RCSid[] = -< "$Header: d:/cvsroot/tads/TADS2/Output.c,v 1.2 1999/05/17 02:52:12 MJRoberts Exp $"; -< #endif -< -< /* -< * Copyright (c) 1987, 1988 by Michael J. Roberts. All Rights Reserved. -< * -< * Please see the accompanying license file, LICENSE.TXT, for information -< * on using and copying this software. -< */ -< /* -< Name -< output - TADS Interpreter and Compiler formatted Output routines -< Function -< Provides formatted output support. Text that is sent through outformat() -< is displayed with word-wrap so that words fill the line but are not broken -< across lines. Other routines allow flushing the output buffer, displaying -< blank lines, and logging output to a file as well as to the display. -< Notes -< We use the global variables G_os_pagelength and G_os_linewidth, defined -< in the OS code, to determine the size of the display area and to determine -< the number of lines to display between page pauses (MORE prompts). Line -< breaking and MORE prompting can be handled by the OS code if desired; -< the USE_MORE macro controls this setting. -< Returns -< None -< Modified -< 04/05/92 MJRoberts - TADS 2.0 changes -< 03/29/92 MJRoberts - fix unfound formatstring handling -< 08/01/91 MJRoberts - no more mode when debugger is running -< 07/18/91 MJRoberts - improve t_outline [more] behavior -< 07/01/91 MJRoberts - Mac porting changes -< 06/05/91 MJRoberts - add format string support -< 03/27/91 MJRoberts - debugger enhancements -< 03/10/91 MJRoberts - integrate John's qa-scripter mods -< 04/24/90 MJRoberts - add \^ (equivalent to calling "caps()" intrinsic) -< 04/16/89 MJRoberts - add outcformat for compressed strings -< 10/30/88 MJRoberts - add outhide() and outshow() functions -< 10/29/88 MJRoberts - break lines on hyphens -< 12/22/87 MJRoberts - created -< */ -< -< #include -< #include -< #include -< #include -< #include -< -< #include "os.h" -< #include "std.h" -< #include "run.h" -< #include "voc.h" -< #include "tio.h" -< #include "mcm.h" -< #include "dbg.h" -< #include "cmap.h" -< -< /* -< * use our own isxxx - anything outside the US ASCII range is not reliably -< * classifiable by the normal C isxxx routines -< */ -< #define outissp(c) (((uchar)(c)) <= 127 && isspace((uchar)(c))) -< #define outisal(c) (((uchar)(c)) <= 127 && isalpha((uchar)(c))) -< #define outisdg(c) (((uchar)(c)) <= 127 && isdigit((uchar)(c))) -< #define outisup(c) (((uchar)(c)) <= 127 && isupper((uchar)(c))) -< #define outislo(c) (((uchar)(c)) <= 127 && islower((uchar)(c))) -< -< -< /* -< * Turn on formatter-level MORE mode, EXCEPT under any of the following -< * conditions: -< * -< * - this is a MAC OS port -< *. - this is an HTML TADS interpreter -< *. - USE_OS_LINEWRAP is defined -< * -< * Formatter-level MORE mode and formatter-level line wrapping go together; -< * you can't have one without the other. So, if USE_OS_LINEWRAP is -< * defined, we must also use OS-level MORE mode, which means we don't want -< * formatter-level MORE mode. -< * -< * For historical reasons, we check specifically for MAC_OS. This was the -< * first platform for which OS-level MORE mode and OS-level line wrapping -< * were invented; at the time, we foolishly failed to anticipate that more -< * platforms might eventually come along with the same needs, so we coded a -< * test for MAC_OS rather than some more abstract marker. For -< * compatibility, we retain this specific test. -< * -< * USE_OS_LINEWRAP is intended as the more abstract marker we should -< * originally have used. A port should #define USE_OS_LINEWRAP in its -< * system-specific os_xxx.h header to turn on OS-level line wrapping and -< * OS-level MORE mode. Ports should avoid adding new #ifndef tests for -< * specific platforms here; we've only retained the MAC_OS test because we -< * don't want to break the existing MAC_OS port. -< */ -< #ifndef MAC_OS -< # ifndef USE_HTML -< # ifndef USE_OS_LINEWRAP -< # define USE_MORE /* activate formatter-level more-mode */ -< # endif /* USE_OS_LINEWRAP */ -< # endif /* USE_HTML */ -< #endif /* MAC_OS */ -< -< /* -< * In HTML mode, don't use MORE mode. Note that we explicitly turn MORE -< * mode OFF, even though we won't have turned it on above, because it might -< * have been turned on by an os_xxx.h header. This is here for historical -< * reasons; in particular, some of the HTML interpreter builds include -< * headers that were originally written for the normal builds for those -< * same platforms, and those original headers explicitly #define USE_MORE -< * somewhere. So, to be absolutely sure we get it right here, we have to -< * explicitly turn off USE_MORE when compiling for HTML mode. -< */ -< #ifdef USE_HTML -< # ifdef USE_MORE -< # undef USE_MORE -< # endif -< #endif -< -< /* -< * QSPACE is the special character for a quoted space (internally, the -< * sequence "\ " (backslash-space) is converted to QSPACE). It must not -< * be any printable character. The value here may need to be changed in -< * the extremely unlikely event that TADS is ever ported to an EBCDIC -< * machine. -< */ -< #define QSPACE 26 -< -< /* -< * QTAB is a special hard tab character indicator. We use this when we -< * need to generate a hard tab to send to the underlying output layer -< * (in particular, we use this to send hard tabs to the HTML formatter -< * when we're in HTML mode). -< */ -< #define QTAB 25 -< -< -< /* maximum width of the display */ -< #define MAXWIDTH OS_MAXWIDTH -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Globals and statics. These should really be moved into a context -< * structure, so that the output formatter subsystem could be shared -< * among multiple clients. For now, there's no practical problem using -< * statics, because we only need a single output subsystem at one time. -< */ -< -< /* current script (command input) file */ -< extern osfildef *scrfp; -< -< /* -< * This should be TRUE if the output should have two spaces after a -< * period (or other such punctuation. It should generally be TRUE for -< * fixed-width fonts, and FALSE for proportional fonts. -< */ -< static int doublespace = 1; -< -< /* -< * Log file handle and name. If we're copying output to a log file, -< * these will tell us about the file. -< */ -< osfildef *logfp; -< static char logfname[OSFNMAX]; -< -< /* flag indicating whether output has occurred since last check */ -< static uchar outcnt; -< -< /* flag indicating whether hidden output has occurred */ -< static uchar hidout; -< -< /* flag indicating whether to show (TRUE) or hide (FALSE) output */ -< static uchar outflag; -< -< /* flag indicating whether output is hidden for debugging purposes */ -< int dbghid; -< -< /* -< * Current recursion level in formatter invocation -< */ -< static int G_recurse = 0; -< -< /* active stream in current recursion level */ -< static struct out_stream_info *G_cur_stream; -< -< /* watchpoint mode flag */ -< static uchar outwxflag; -< -< /* -< * User filter function. When this function is set, we'll invoke this -< * function for each string that's displayed through the output -< * formatter. -< */ -< static objnum G_user_filter = MCMONINV; -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Hack to run with TADS 2.0 with minimal reworking. Rather than using -< * an allocated output layer context, store our subsystem context -< * information in some statics. This is less clean than using a real -< * context, but doesn't create any practical problems as we don't need -< * to share the output formatter subsystem among multiple simultaneous -< * callers. -< */ -< static runcxdef *runctx; /* execution context */ -< static uchar *fmsbase; /* format string area base */ -< static uchar *fmstop; /* format string area top */ -< static objnum cmdActor; /* current actor */ -< -< /* forward declarations of static functions */ -< static void outstring_stream(struct out_stream_info *stream, char *s); -< static void outchar_noxlat_stream(struct out_stream_info *stream, char c); -< static char out_parse_entity(char *outbuf, size_t outbuf_size, -< char **sp, size_t *slenp); -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * HTML lexical analysis mode -< */ -< #define HTML_MODE_NORMAL 0 /* normal text, not in a tag */ -< #define HTML_MODE_TAG 1 /* parsing inside a tag */ -< #define HTML_MODE_SQUOTE 2 /* in a single-quoted string in a tag */ -< #define HTML_MODE_DQUOTE 3 /* in a double-quoted string in a tag */ -< -< /* -< * HTML parsing mode flag for
tags. We defer these until we've -< * read the full tag in order to obey an HEIGHT attribute we find. When -< * we encounter a
, we figure out whether we think we'll need a -< * flush or a blank line; if we find a HEIGHT attribute, we may change -< * this opinion. -< */ -< #define HTML_DEFER_BR_NONE 0 /* no pending
*/ -< #define HTML_DEFER_BR_FLUSH 1 /* only need an outflush() */ -< #define HTML_DEFER_BR_BLANK 2 /* need an outblank() */ -< -< /* -< * If we're compiling for an HTML-enabled underlying output subsystem, -< * we want to call the underlying OS layer when switching in and out of -< * HTML mode. If the underlying system doesn't process HTML, we don't -< * need to let it know anything about HTML mode. -< */ -< #ifdef USE_HTML -< # define out_start_html(stream) os_start_html() -< # define out_end_html(stream) os_end_html() -< #else -< # define out_start_html(stream) -< # define out_end_html(stream) -< #endif -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Output formatter stream state structure. This structure encapsulates -< * the state of an individual output stream. -< */ -< typedef struct out_stream_info out_stream_info; -< struct out_stream_info -< { -< /* low-level display routine (va_list version) */ -< void (*do_print)(out_stream_info *stream, const char *str); -< -< /* current line position and output column */ -< uchar linepos; -< uchar linecol; -< -< /* number of lines on the screen (since last MORE prompt) */ -< int linecnt; -< -< /* output buffer */ -< char linebuf[MAXWIDTH]; -< -< /* -< * attribute buffer - we keep one attribute entry for each character in -< * the line buffer -< */ -< int attrbuf[MAXWIDTH]; -< -< /* current attribute for text we're buffering into linebuf */ -< int cur_attr; -< -< /* last attribute we wrote to the osifc layer */ -< int os_attr; -< -< /* CAPS mode - next character output is converted to upper-case */ -< uchar capsflag; -< -< /* NOCAPS mode - next character output is converted to lower-case */ -< uchar nocapsflag; -< -< /* ALLCAPS mode - all characters output are converted to upper-case */ -< uchar allcapsflag; -< -< /* capture information */ -< mcmcxdef *capture_ctx; /* memory context to use for capturing */ -< mcmon capture_obj; /* object holding captured output */ -< uint capture_ofs; /* write offset in capture object */ -< int capturing; /* true -> we are capturing output */ -< -< /* "preview" state for line flushing */ -< int preview; -< -< /* flag indicating that we just flushed a new line */ -< int just_did_nl; -< -< /* this output stream uses "MORE" mode */ -< int use_more_mode; -< -< /* -< * This output stream uses OS-level line wrapping - if this is set, -< * the output formatter will not insert a newline at the end of a -< * line that it's flushing for word wrapping, but will instead let -< * the underlying OS display layer handle the wrapping. -< */ -< int os_line_wrap; -< -< /* -< * Flag indicating that the underlying output system wants to -< * receive its output as HTML. -< * -< * If this is true, we'll pass through HTML to the underlying output -< * system, and in addition generate HTML sequences for certain -< * TADS-native escapes (for example, we'll convert the "\n" sequence -< * to a
sequence). -< * -< * If this is false, we'll do just the opposite: we'll remove HTML -< * from the output stream and convert it into normal text sequences. -< */ -< int html_target; -< -< /* -< * Flag indicating that the target uses plain text. If this flag is -< * set, we won't add the OS escape codes for highlighted characters. -< */ -< int plain_text_target; -< -< /* -< * Flag indicating that the caller is displaying HTML. We always -< * start off in text mode; the client can switch to HTML mode by -< * displaying a special escape sequence, and can switch back to text -< * mode by displaying a separate special escape sequence. -< */ -< int html_mode; -< -< /* current lexical analysis mode */ -< unsigned int html_mode_flag; -< -< /*
defer mode */ -< unsigned int html_defer_br; -< -< /* -< * HTML "ignore" mode - we suppress all output when parsing the -< * contents of a or <ABOUTBOX> tag -< */ -< int html_in_ignore; -< -< /* -< * HTML <TITLE> mode - when we're in this mode, we're gathering the -< * title (i.e., we're inside a <TITLE> tag's contents). We'll copy -< * characters to the title buffer rather than the normal output -< * buffer, and then call os_set_title() when we reach the -< * tag. -< */ -< int html_in_title; -< -< /* buffer for the title */ -< char html_title_buf[256]; -< -< /* pointer to next available character in title buffer */ -< char *html_title_ptr; -< -< /* quoting level */ -< int html_quote_level; -< -< /* PRE nesting level */ -< int html_pre_level; -< -< /* -< * Parsing mode flag for ALT attributes. If we're parsing a tag -< * that allows ALT, such as IMG or SOUND, we'll set this flag, then -< * insert the ALT text if we encounter it during parsing. -< */ -< int html_allow_alt; -< }; -< -< /* -< * Default output converter. This is the output converter for the -< * standard display. Functions in the public interface that do not -< * specify an output converter will use this converter by default. -< */ -< static out_stream_info G_std_disp; -< -< /* -< * Log file converter. This is the output converter for a log file. -< * Whenever we open a log file, we'll initialize this converter; as we -< * display text to the main display, we'll also copy it to the log file. -< * -< * We maintain an entire separate conversion context for the log file, -< * so that we can perform a different set of conversions on it. We may -< * want, for example, to pass HTML text through to the OS display -< * subsystem (this is the case for the HTML-enabled interpreter), but -< * we'll still want to convert log file output to text. By keeping a -< * separate display context for the log file, we can format output to -< * the log file using an entirely different style than we do for the -< * display. -< */ -< static out_stream_info G_log_disp; -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * low-level output handlers for the standard display and log file -< */ -< -< /* standard display printer */ -< static void do_std_print(out_stream_info *stream, const char *str) -< { -< VARUSED(stream); -< -< /* display the text through the OS layer */ -< os_printz(str); -< } -< -< /* log file printer */ -< static void do_log_print(out_stream_info *stream, const char *str) -< { -< VARUSED(stream); -< -< /* display to the log file */ -< if (logfp != 0 && G_os_moremode) -< { -< os_fprintz(logfp, str); -< osfflush(logfp); -< } -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * initialize a generic output formatter state structure -< */ -< static void out_state_init(out_stream_info *stream) -< { -< /* start out at the first column */ -< stream->linepos = 0; -< stream->linecol = 0; -< stream->linebuf[0] = '\0'; -< -< /* set normal text attributes */ -< stream->cur_attr = 0; -< stream->os_attr = 0; -< -< /* start out at the first line */ -< stream->linecnt = 0; -< -< /* we're not in either "caps", "nocaps", or "allcaps" mode yet */ -< stream->capsflag = stream->nocapsflag = stream->allcapsflag = FALSE; -< -< /* we're not capturing yet */ -< stream->capturing = FALSE; -< stream->capture_obj = MCMONINV; -< -< /* we aren't previewing a line yet */ -< stream->preview = 0; -< -< /* we haven't flushed a new line yet */ -< stream->just_did_nl = FALSE; -< -< /* presume this stream does not use "MORE" mode */ -< stream->use_more_mode = FALSE; -< -< /* presume this stream uses formatter-level line wrapping */ -< stream->os_line_wrap = FALSE; -< -< /* assume that the underlying system is not HTML-enabled */ -< stream->html_target = FALSE; -< -< /* presume this target accepts OS highlighting sequences */ -< stream->plain_text_target = FALSE; -< -< /* start out in text mode */ -< stream->html_mode = FALSE; -< -< /* start out in "normal" lexical state */ -< stream->html_mode_flag = HTML_MODE_NORMAL; -< -< /* not in an ignored tag yet */ -< stream->html_in_ignore = FALSE; -< -< /* not in title mode yet */ -< stream->html_in_title = FALSE; -< -< /* not yet deferring line breaks */ -< stream->html_defer_br = HTML_DEFER_BR_NONE; -< -< /* not yet in quotes */ -< stream->html_quote_level = 0; -< -< /* not yet in a PRE block */ -< stream->html_pre_level = 0; -< -< /* not in an ALT tag yet */ -< stream->html_allow_alt = FALSE; -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * initialize a standard display stream -< */ -< static void out_init_std(out_stream_info *stream) -< { -< /* there's no user output filter function yet */ -< out_set_filter(MCMONINV); -< -< /* initialize the basic stream state */ -< out_state_init(stream); -< -< /* set up the low-level output routine */ -< G_std_disp.do_print = do_std_print; -< -< #ifdef USE_MORE -< /* -< * We're compiled for MORE mode, and we're not compiling for an -< * underlying HTML formatting layer, so use MORE mode for the -< * standard display stream. -< */ -< stream->use_more_mode = TRUE; -< #else -< /* -< * We're compiled for OS-layer (or HTML-layer) MORE handling. For -< * this case, use OS-layer (or HTML-layer) line wrapping as well. -< */ -< stream->os_line_wrap = TRUE; -< #endif -< -< #ifdef USE_HTML -< /* -< * if we're compiled for HTML mode, set the standard output stream -< * so that it knows it has an HTML target - this will ensure that -< * HTML tags are passed through to the underlying stream, and that -< * we generate HTML equivalents for our own control sequences -< */ -< stream->html_target = TRUE; -< #endif -< } -< -< /* -< * initialize a standard log file stream -< */ -< static void out_init_log(out_stream_info *stream) -< { -< /* initialize the basic stream state */ -< out_state_init(stream); -< -< /* set up the low-level output routine */ -< stream->do_print = do_log_print; -< -< /* use plain text in the log file stream */ -< stream->plain_text_target = TRUE; -< } -< -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * table of '&' character name sequences -< */ -< struct amp_tbl_t -< { -< /* entity name */ -< const char *cname; -< -< /* HTML Unicode character value */ -< uint html_cval; -< -< /* native character set expansion */ -< char *expan; -< }; -< -< /* -< * HTML entity mapping table. When we're in non-HTML mode, we keep our -< * own expansion table so that we can map HTML entity names into the -< * local character set. -< * -< * The entries in this table must be in sorted order (by HTML entity -< * name), because we use a binary search to find an entity name in the -< * table. -< */ -< static struct amp_tbl_t amp_tbl[] = -< { -< { "AElig", 198, 0 }, -< { "Aacute", 193, 0 }, -< { "Abreve", 258, 0 }, -< { "Acirc", 194, 0 }, -< { "Agrave", 192, 0 }, -< { "Alpha", 913, 0 }, -< { "Aogon", 260, 0 }, -< { "Aring", 197, 0 }, -< { "Atilde", 195, 0 }, -< { "Auml", 196, 0 }, -< { "Beta", 914, 0 }, -< { "Cacute", 262, 0 }, -< { "Ccaron", 268, 0 }, -< { "Ccedil", 199, 0 }, -< { "Chi", 935, 0 }, -< { "Dagger", 8225, 0 }, -< { "Dcaron", 270, 0 }, -< { "Delta", 916, 0 }, -< { "Dstrok", 272, 0 }, -< { "ETH", 208, 0 }, -< { "Eacute", 201, 0 }, -< { "Ecaron", 282, 0 }, -< { "Ecirc", 202, 0 }, -< { "Egrave", 200, 0 }, -< { "Eogon", 280, 0 }, -< { "Epsilon", 917, 0 }, -< { "Eta", 919, 0 }, -< { "Euml", 203, 0 }, -< { "Gamma", 915, 0 }, -< { "Iacute", 205, 0 }, -< { "Icirc", 206, 0 }, -< { "Igrave", 204, 0 }, -< { "Iota", 921, 0 }, -< { "Iuml", 207, 0 }, -< { "Kappa", 922, 0 }, -< { "Lacute", 313, 0 }, -< { "Lambda", 923, 0 }, -< { "Lcaron", 317, 0 }, -< { "Lstrok", 321, 0 }, -< { "Mu", 924, 0 }, -< { "Nacute", 323, 0 }, -< { "Ncaron", 327, 0 }, -< { "Ntilde", 209, 0 }, -< { "Nu", 925, 0 }, -< { "OElig", 338, 0 }, -< { "Oacute", 211, 0 }, -< { "Ocirc", 212, 0 }, -< { "Odblac", 336, 0 }, -< { "Ograve", 210, 0 }, -< { "Omega", 937, 0 }, -< { "Omicron", 927, 0 }, -< { "Oslash", 216, 0 }, -< { "Otilde", 213, 0 }, -< { "Ouml", 214, 0 }, -< { "Phi", 934, 0 }, -< { "Pi", 928, 0 }, -< { "Prime", 8243, 0 }, -< { "Psi", 936, 0 }, -< { "Racute", 340, 0 }, -< { "Rcaron", 344, 0 }, -< { "Rho", 929, 0 }, -< { "Sacute", 346, 0 }, -< { "Scaron", 352, 0 }, -< { "Scedil", 350, 0 }, -< { "Sigma", 931, 0 }, -< { "THORN", 222, 0 }, -< { "Tau", 932, 0 }, -< { "Tcaron", 356, 0 }, -< { "Tcedil", 354, 0 }, -< { "Theta", 920, 0 }, -< { "Uacute", 218, 0 }, -< { "Ucirc", 219, 0 }, -< { "Udblac", 368, 0 }, -< { "Ugrave", 217, 0 }, -< { "Upsilon", 933, 0 }, -< { "Uring", 366, 0 }, -< { "Uuml", 220, 0 }, -< { "Xi", 926, 0 }, -< { "Yacute", 221, 0 }, -< { "Yuml", 376, 0 }, -< { "Zacute", 377, 0 }, -< { "Zcaron", 381, 0 }, -< { "Zdot", 379, 0 }, -< { "Zeta", 918, 0 }, -< { "aacute", 225, 0 }, -< { "abreve", 259, 0 }, -< { "acirc", 226, 0 }, -< { "acute", 180, 0 }, -< { "aelig", 230, 0 }, -< { "agrave", 224, 0 }, -< { "alefsym", 8501, 0 }, -< { "alpha", 945, 0 }, -< { "amp", '&', 0 }, -< { "and", 8743, 0 }, -< { "ang", 8736, 0 }, -< { "aogon", 261, 0 }, -< { "aring", 229, 0 }, -< { "asymp", 8776, 0 }, -< { "atilde", 227, 0 }, -< { "auml", 228, 0 }, -< { "bdquo", 8222, 0 }, -< { "beta", 946, 0 }, -< { "breve", 728, 0 }, -< { "brvbar", 166, 0 }, -< { "bull", 8226, 0 }, -< { "cacute", 263, 0 }, -< { "cap", 8745, 0 }, -< { "caron", 711, 0 }, -< { "ccaron", 269, 0 }, -< { "ccedil", 231, 0 }, -< { "cedil", 184, 0 }, -< { "cent", 162, 0 }, -< { "chi", 967, 0 }, -< { "circ", 710, 0 }, -< { "clubs", 9827, 0 }, -< { "cong", 8773, 0 }, -< { "copy", 169, 0 }, -< { "crarr", 8629, 0 }, -< { "cup", 8746, 0 }, -< { "curren", 164, 0 }, -< { "dArr", 8659, 0 }, -< { "dagger", 8224, 0 }, -< { "darr", 8595, 0 }, -< { "dblac", 733, 0 }, -< { "dcaron", 271, 0 }, -< { "deg", 176, 0 }, -< { "delta", 948, 0 }, -< { "diams", 9830, 0 }, -< { "divide", 247, 0 }, -< { "dot", 729, 0 }, -< { "dstrok", 273, 0 }, -< { "eacute", 233, 0 }, -< { "ecaron", 283, 0 }, -< { "ecirc", 234, 0 }, -< { "egrave", 232, 0 }, -< { "emdash", 8212, 0 }, -< { "empty", 8709, 0 }, -< { "endash", 8211, 0 }, -< { "eogon", 281, 0 }, -< { "epsilon", 949, 0 }, -< { "equiv", 8801, 0 }, -< { "eta", 951, 0 }, -< { "eth", 240, 0 }, -< { "euml", 235, 0 }, -< { "exist", 8707, 0 }, -< { "fnof", 402, 0 }, -< { "forall", 8704, 0 }, -< { "frac12", 189, 0 }, -< { "frac14", 188, 0 }, -< { "frac34", 190, 0 }, -< { "frasl", 8260, 0 }, -< { "gamma", 947, 0 }, -< { "ge", 8805, 0 }, -< { "gt", '>', 0 }, -< { "hArr", 8660, 0 }, -< { "harr", 8596, 0 }, -< { "hearts", 9829, 0 }, -< { "hellip", 8230, 0 }, -< { "iacute", 237, 0 }, -< { "icirc", 238, 0 }, -< { "iexcl", 161, 0 }, -< { "igrave", 236, 0 }, -< { "image", 8465, 0 }, -< { "infin", 8734, 0 }, -< { "int", 8747, 0 }, -< { "iota", 953, 0 }, -< { "iquest", 191, 0 }, -< { "isin", 8712, 0 }, -< { "iuml", 239, 0 }, -< { "kappa", 954, 0 }, -< { "lArr", 8656, 0 }, -< { "lacute", 314, 0 }, -< { "lambda", 955, 0 }, -< { "lang", 9001, 0 }, -< { "laquo", 171, 0 }, -< { "larr", 8592, 0 }, -< { "lcaron", 318, 0 }, -< { "lceil", 8968, 0 }, -< { "ldq", 8220, 0 }, -< { "ldquo", 8220, 0 }, -< { "le", 8804, 0 }, -< { "lfloor", 8970, 0 }, -< { "lowast", 8727, 0 }, -< { "loz", 9674, 0 }, -< { "lsaquo", 8249, 0 }, -< { "lsq", 8216, 0 }, -< { "lsquo", 8216, 0 }, -< { "lstrok", 322, 0 }, -< { "lt", '<', 0 }, -< { "macr", 175, 0 }, -< { "mdash", 8212, 0 }, -< { "micro", 181, 0 }, -< { "middot", 183, 0 }, -< { "minus", 8722, 0 }, -< { "mu", 956, 0 }, -< { "nabla", 8711, 0 }, -< { "nacute", 324, 0 }, -< { "nbsp", QSPACE, 0 }, -< { "ncaron", 328, 0 }, -< { "ndash", 8211, 0 }, -< { "ne", 8800, 0 }, -< { "ni", 8715, 0 }, -< { "not", 172, 0 }, -< { "notin", 8713, 0 }, -< { "nsub", 8836, 0 }, -< { "ntilde", 241, 0 }, -< { "nu", 957, 0 }, -< { "oacute", 243, 0 }, -< { "ocirc", 244, 0 }, -< { "odblac", 337, 0 }, -< { "oelig", 339, 0 }, -< { "ogon", 731, 0 }, -< { "ograve", 242, 0 }, -< { "oline", 8254, 0 }, -< { "omega", 969, 0 }, -< { "omicron", 959, 0 }, -< { "oplus", 8853, 0 }, -< { "or", 8744, 0 }, -< { "ordf", 170, 0 }, -< { "ordm", 186, 0 }, -< { "oslash", 248, 0 }, -< { "otilde", 245, 0 }, -< { "otimes", 8855, 0 }, -< { "ouml", 246, 0 }, -< { "para", 182, 0 }, -< { "part", 8706, 0 }, -< { "permil", 8240, 0 }, -< { "perp", 8869, 0 }, -< { "phi", 966, 0 }, -< { "pi", 960, 0 }, -< { "piv", 982, 0 }, -< { "plusmn", 177, 0 }, -< { "pound", 163, 0 }, -< { "prime", 8242, 0 }, -< { "prod", 8719, 0 }, -< { "prop", 8733, 0 }, -< { "psi", 968, 0 }, -< { "quot", '"', 0 }, -< { "rArr", 8658, 0 }, -< { "racute", 341, 0 }, -< { "radic", 8730, 0 }, -< { "rang", 9002, 0 }, -< { "raquo", 187, 0 }, -< { "rarr", 8594, 0 }, -< { "rcaron", 345, 0 }, -< { "rceil", 8969, 0 }, -< { "rdq", 8221, 0 }, -< { "rdquo", 8221, 0 }, -< { "real", 8476, 0 }, -< { "reg", 174, 0 }, -< { "rfloor", 8971, 0 }, -< { "rho", 961, 0 }, -< { "rsaquo", 8250, 0 }, -< { "rsq", 8217, 0 }, -< { "rsquo", 8217, 0 }, -< { "sacute", 347, 0 }, -< { "sbquo", 8218, 0 }, -< { "scaron", 353, 0 }, -< { "scedil", 351, 0 }, -< { "sdot", 8901, 0 }, -< { "sect", 167, 0 }, -< { "shy", 173, 0 }, -< { "sigma", 963, 0 }, -< { "sigmaf", 962, 0 }, -< { "sim", 8764, 0 }, -< { "spades", 9824, 0 }, -< { "sub", 8834, 0 }, -< { "sube", 8838, 0 }, -< { "sum", 8721, 0 }, -< { "sup", 8835, 0 }, -< { "sup1", 185, 0 }, -< { "sup2", 178, 0 }, -< { "sup3", 179, 0 }, -< { "supe", 8839, 0 }, -< { "szlig", 223, 0 }, -< { "tau", 964, 0 }, -< { "tcaron", 357, 0 }, -< { "tcedil", 355, 0 }, -< { "there4", 8756, 0 }, -< { "theta", 952, 0 }, -< { "thetasym", 977, 0 }, -< { "thorn", 254, 0 }, -< { "thorn", 254, 0 }, -< { "tilde", 732, 0 }, -< { "times", 215, 0 }, -< { "trade", 8482, 0 }, -< { "uArr", 8657, 0 }, -< { "uacute", 250, 0 }, -< { "uarr", 8593, 0 }, -< { "ucirc", 251, 0 }, -< { "udblac", 369, 0 }, -< { "ugrave", 249, 0 }, -< { "uml", 168, 0 }, -< { "upsih", 978, 0 }, -< { "upsilon", 965, 0 }, -< { "uring", 367, 0 }, -< { "uuml", 252, 0 }, -< { "weierp", 8472, 0 }, -< { "xi", 958, 0 }, -< { "yacute", 253, 0 }, -< { "yen", 165, 0 }, -< { "yuml", 255, 0 }, -< { "zacute", 378, 0 }, -< { "zcaron", 382, 0 }, -< { "zdot", 380, 0 }, -< { "zeta", 950, 0 } -< }; -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * turn on CAPS mode for a stream -< */ -< static void outcaps_stream(out_stream_info *stream) -< { -< /* turn on CAPS mode */ -< stream->capsflag = TRUE; -< -< /* turn off NOCAPS and ALLCAPS mode */ -< stream->nocapsflag = FALSE; -< stream->allcapsflag = FALSE; -< } -< -< /* -< * turn on NOCAPS mode for a stream -< */ -< static void outnocaps_stream(out_stream_info *stream) -< { -< /* turn on NOCAPS mode */ -< stream->nocapsflag = TRUE; -< -< /* turn off CAPS and ALLCAPS mode */ -< stream->capsflag = FALSE; -< stream->allcapsflag = FALSE; -< } -< -< /* -< * turn on or off ALLCAPS mode for a stream -< */ -< static void outallcaps_stream(out_stream_info *stream, int all_caps) -< { -< /* set the ALLCAPS flag */ -< stream->allcapsflag = all_caps; -< -< /* clear the CAPS and NOCAPS flags */ -< stream->capsflag = FALSE; -< stream->nocapsflag = FALSE; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * write a string to a stream -< */ -< static void stream_print(out_stream_info *stream, char *str) -< { -< /* call the stream's do_print method */ -< (*stream->do_print)(stream, str); -< } -< -< /* -< * Write out a line -< */ -< static void t_outline(out_stream_info *stream, int nl, -< const char *txt, const int *attr) -< { -< extern int scrquiet; -< -< /* -< * Check the "script quiet" mode - this indicates that we're reading -< * a script and not echoing output to the display. If this mode is -< * on, and we're writing to the display, suppress this write. If -< * the mode is off, or we're writing to another stream (such as the -< * log file), show the output as normal. -< */ -< if (!scrquiet || stream != &G_std_disp) -< { -< size_t i; -< char buf[MAXWIDTH]; -< char *dst; -< -< /* -< * Check to see if we've reached the end of the screen, and if -< * so run the MORE prompt. Note that we don't make this check -< * at all if USE_MORE is undefined, since this means that the OS -< * layer code is taking responsibility for pagination issues. -< * We also don't display a MORE prompt when reading from a -< * script file. -< * -< * Note that we suppress the MORE prompt if nl == 0, since this -< * is used to flush a partial line of text without starting a -< * new line (for example, when displaying a prompt where the -< * input will appear on the same line following the prompt). -< * -< * Skip the MORE prompt if this stream doesn't use it. -< */ -< if (stream->use_more_mode -< && scrfp == 0 -< && G_os_moremode -< && nl != 0 && nl != 4 -< && stream->linecnt++ >= G_os_pagelength) -< { -< /* display the MORE prompt */ -< out_more_prompt(); -< } -< -< /* -< * Display the text. Run through the text in pieces; each time the -< * attributes change, set attributes at the osifc level. -< */ -< for (i = 0, dst = buf ; txt[i] != '\0' ; ++i) -< { -< /* if the attribute is changing, notify osifc */ -< if (attr != 0 && attr[i] != stream->os_attr) -< { -< /* flush the preceding text */ -< if (dst != buf) -< { -< *dst = '\0'; -< stream_print(stream, buf); -< } -< -< /* set the new attribute */ -< os_set_text_attr(attr[i]); -< -< /* remember this as the last OS attribute */ -< stream->os_attr = attr[i]; -< -< /* start with a fresh buffer */ -< dst = buf; -< } -< -< /* buffer this character */ -< *dst++ = txt[i]; -< } -< -< /* flush the last chunk of text */ -< if (dst != buf) -< { -< *dst = '\0'; -< stream_print(stream, buf); -< } -< } -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Flush the current line to the display. The 'nl' argument specifies -< * what kind of flushing to do: -< * -< * 0: flush the current line but do not start a new line; more text will -< * follow on the current line. This is used, for example, to flush text -< * after displaying a prompt and before waiting for user input. -< * -< * 1: flush the line and start a new line. -< * -< * 2: flush the line as though starting a new line, but don't add an -< * actual newline character to the output, since the underlying OS -< * display code will handle this. Instead, add a space after the line. -< * (This differs from mode 0 in that mode 0 shouldn't add anything at -< * all after the line.) -< * -< * 3: "preview" mode. Flush the line, but do not start a new line, and -< * retain the current text in the buffer. This is used for systems that -< * handle the line wrapping in the underlying system code to flush a -< * partially filled line that will need to be flushed again later. -< * -< * 4: same as mode 0, but used for internal buffer flushes only. Do not -< * involve the underlying OS layer in this type of flush - simply flush -< * our buffers with no separation. -< */ -< -< /* flush a given output stream */ -< static void outflushn_stream(out_stream_info *stream, int nl) -< { -< int i; -< -< /* null-terminate the current output line buffer */ -< stream->linebuf[stream->linepos] = '\0'; -< -< /* note the position of the last character to display */ -< i = stream->linepos - 1; -< -< /* if we're adding anything, remove trailing spaces */ -< if (nl != 0 && nl != 4) -< { -< /* look for last non-space character */ -< for ( ; i >= 0 && outissp(stream->linebuf[i]) ; --i) ; -< } -< -< /* check the output mode */ -< if (nl == 3) -< { -< /* -< * this is the special "preview" mode -- only display the part -< * that we haven't already previewed for this same line -< */ -< if (i + 1 > stream->preview) -< { -< /* write out the line */ -< t_outline(stream, 0, &stream->linebuf[stream->preview], -< &stream->attrbuf[stream->preview]); -< -< /* skip past the part we wrote */ -< stream->preview += strlen(&stream->linebuf[stream->preview]); -< } -< } -< else -< { -< char *suffix; /* extra text to add after the flushed text */ -< int countnl = 0; /* true if line counts for [more] paging */ -< -< /* null-terminate the buffer at the current position */ -< stream->linebuf[++i] = '\0'; -< -< /* check the mode */ -< switch(nl) -< { -< case 0: -< case 3: -< case 4: -< /* no newline - just flush out what we have with no suffix */ -< suffix = 0; -< break; -< -< case 1: -< /* -< * Add a newline. If there's nothing in the current line, -< * or we just wrote out a newline, do not add an extra -< * newline. Keep all newlines in PRE mode. -< */ -< if (stream->linecol != 0 || !stream->just_did_nl -< || stream->html_pre_level != 0) -< { -< /* add a newline after the text */ -< suffix = "\n"; -< -< /* count the line in the page size */ -< countnl = 1; -< } -< else -< { -< /* don't add a newline */ -< suffix = 0; -< } -< break; -< -< case 2: -< /* -< * we're going to depend on the underlying OS output layer -< * to do line breaking, so don't add a newline, but do add a -< * space, so that the underlying OS layer knows we have a -< * word break here -< */ -< suffix = " "; -< break; -< } -< -< /* -< * display the line, as long as we have something buffered to -< * display; even if we don't, display it if our column is -< * non-zero and we didn't just do a newline, since this must -< * mean that we've flushed a partial line and are just now doing -< * the newline -< */ -< if (stream->linebuf[stream->preview] != '\0' -< || (stream->linecol != 0 && !stream->just_did_nl) -< || stream->html_pre_level > 0) -< { -< /* write it out */ -< t_outline(stream, countnl, &stream->linebuf[stream->preview], -< &stream->attrbuf[stream->preview]); -< -< /* write the suffix, if any */ -< if (suffix != 0) -< t_outline(stream, 0, suffix, 0); -< } -< -< /* generate an HTML line break if necessary */ -< if (nl == 1 && stream->html_mode && stream->html_target) -< t_outline(stream, 0, "
", 0); -< -< if (nl == 0) -< { -< /* we're not displaying a newline, so flush what we have */ -< os_flush(); -< } -< else -< { -< /* we displayed a newline, so reset the column position */ -< stream->linecol = 0; -< } -< -< /* reset the line output buffer position */ -< stream->linepos = stream->preview = 0; -< -< /* -< * If we just output a newline, note it. If we didn't just -< * output a newline, but we did write out anything else, note -< * that we're no longer at the start of a line on the underlying -< * output device. -< */ -< if (nl == 1) -< stream->just_did_nl = TRUE; -< else if (stream->linebuf[stream->preview] != '\0') -< stream->just_did_nl = FALSE; -< } -< -< /* -< * If the osifc-level attributes don't match the current attributes, -< * bring the osifc layer up to date. This is necessary in cases where -< * we set attributes immediately before asking for input - we -< * essentially need to flush the attributes without flushing any text. -< */ -< if (stream->cur_attr != stream->os_attr) -< { -< /* set the osifc attributes */ -< os_set_text_attr(stream->cur_attr); -< -< /* remember the new attributes as the current osifc attributes */ -< stream->os_attr = stream->cur_attr; -< } -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Determine if we're showing output. Returns true if output should be -< * displayed, false if it should be suppressed. We'll note the output -< * for hidden display accounting as needed. -< */ -< static int out_is_hidden() -< { -< /* check the output flag */ -< if (!outflag) -< { -< /* trace the hidden output if desired */ -< if (dbghid && !hidout) -< trchid(); -< -< /* note the hidden output */ -< hidout = 1; -< -< /* -< * unless we're showing hidden text in the debugger, we're -< * suppressing output, so return true -< */ -< if (!dbghid) -< return TRUE; -< } -< -< /* we're not suppressing output */ -< return FALSE; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Display a blank line to the given stream -< */ -< static void outblank_stream(out_stream_info *stream) -< { -< /* flush the stream */ -< outflushn_stream(stream, 1); -< -< /* if generating for an HTML display target, add an HTML line break */ -< if (stream->html_mode && stream->html_target) -< outstring_stream(stream, "
"); -< -< /* write out the newline */ -< t_outline(stream, 1, "\n", 0); -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Generate a tab for a "\t" sequence in the game text. -< * -< * Standard (non-HTML) version: we'll generate enough spaces to take us -< * to the next tab stop. -< * -< * HTML version: if we're in native HTML mode, we'll just generate a -< * ; if we're not in HTML mode, we'll generate a hard -< * tab character, which the HTML formatter will interpret as a . -< */ -< static void outtab_stream(out_stream_info *stream) -< { -< /* check to see what the underlying system is expecting */ -< if (stream->html_target) -< { -< /* the underlying system is HTML - check for HTML mode */ -< if (stream->html_mode) -< { -< /* we're in HTML mode, so use the HTML tag */ -< outstring_stream(stream, ""); -< } -< else -< { -< /* we're not in HTML mode, so generate a hard tab character */ -< outchar_noxlat_stream(stream, QTAB); -< } -< } -< else -< { -< int maxcol; -< -< /* -< * We're not in HTML mode - expand the tab with spaces. Figure -< * the maximum column: if we're doing our own line wrapping, never -< * go beyond the actual display width. -< */ -< maxcol = (stream->os_line_wrap ? OS_MAXWIDTH : G_os_linewidth); -< -< /* add the spaces */ -< do -< { -< stream->attrbuf[stream->linepos] = stream->cur_attr; -< stream->linebuf[stream->linepos++] = ' '; -< ++(stream->linecol); -< } while (((stream->linecol + 1) & 3) != 0 -< && stream->linecol < maxcol); -< } -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Flush a line -< */ -< static void out_flushline(out_stream_info *stream, int padding) -< { -< /* -< * check to see if we're using the underlying display layer's line -< * wrapping -< */ -< if (stream->os_line_wrap) -< { -< /* -< * In the HTML version, we don't need the normal *MORE* -< * processing, since the HTML layer will handle that. -< * Furthermore, we don't need to provide actual newline breaks -< * -- that happens after the HTML is parsed, so we don't have -< * enough information here to figure out actual line breaks. -< * So, we'll just flush out our buffer whenever it fills up, and -< * suppress newlines. -< * -< * Similarly, if we have OS-level MORE processing, don't try to -< * figure out where the line breaks go -- just flush our buffer -< * without a trailing newline whenever the buffer is full, and -< * let the OS layer worry about formatting lines and paragraphs. -< * -< * If we're using padding, use mode 2. If we don't want padding -< * (which is the case if we completely fill up the buffer -< * without finding any word breaks), write out in mode 0, which -< * just flushes the buffer exactly like it is. -< */ -< outflushn_stream(stream, padding ? 2 : 4); -< } -< else -< { -< /* -< * Normal mode - we process the *MORE* prompt ourselves, and we -< * are responsible for figuring out where the actual line breaks -< * go. Use outflush() to generate an actual newline whenever we -< * flush out our buffer. -< */ -< outflushn_stream(stream, 1); -< } -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Write a character to an output stream without translation -< */ -< static void outchar_noxlat_stream(out_stream_info *stream, char c) -< { -< int i; -< int qspace; -< -< /* check for the special quoted space character */ -< if (c == QSPACE) -< { -< /* it's a quoted space - note it and convert it to a regular space */ -< qspace = 1; -< c = ' '; -< } -< else if (c == QTAB) -< { -< /* it's a hard tab - convert it to an ordinary tab */ -< c = '\t'; -< qspace = 0; -< } -< else -< { -< /* translate any whitespace character to a regular space character */ -< if (outissp(c)) -< c = ' '; -< -< /* it's not a quoted space */ -< qspace = 0; -< } -< -< /* check for the caps/nocaps flags */ -< if ((stream->capsflag || stream->allcapsflag) && outisal(c)) -< { -< /* capsflag is set, so capitalize this character */ -< if (outislo(c)) -< c = toupper(c); -< -< /* okay, we've capitalized something; clear flag */ -< stream->capsflag = 0; -< } -< else if (stream->nocapsflag && outisal(c)) -< { -< /* nocapsflag is set, so minisculize this character */ -< if (outisup(c)) -< c = tolower(c); -< -< /* clear the flag now that we've done the job */ -< stream->nocapsflag = 0; -< } -< -< /* if in capture mode, simply capture the character */ -< if (stream->capturing) -< { -< uchar *p; -< -< /* if we have a valid capture object, copy to it */ -< if (stream->capture_obj != MCMONINV) -< { -< /* lock the object holding the captured text */ -< p = mcmlck(stream->capture_ctx, stream->capture_obj); -< -< /* make sure the capture object is big enough */ -< if (mcmobjsiz(stream->capture_ctx, stream->capture_obj) -< <= stream->capture_ofs) -< { -< /* expand the object by another 256 bytes */ -< p = mcmrealo(stream->capture_ctx, stream->capture_obj, -< (ushort)(stream->capture_ofs + 256)); -< } -< -< /* add this character */ -< *(p + stream->capture_ofs++) = c; -< -< /* unlock the capture object */ -< mcmtch(stream->capture_ctx, stream->capture_obj); -< mcmunlck(stream->capture_ctx, stream->capture_obj); -< } -< -< /* -< * we're done - we don't want to actually display the character -< * while capturing -< */ -< return; -< } -< -< /* add the character to out output buffer, flushing as needed */ -< if (stream->linecol + 1 < G_os_linewidth) -< { -< /* -< * there's room for this character, so add it to the buffer -< */ -< -< /* ignore non-quoted space at start of line outside of PRE */ -< if (outissp(c) && c != '\t' && stream->linecol == 0 && !qspace -< && stream->html_pre_level == 0) -< return; -< -< /* is this a non-quoted space not at the start of the line? */ -< if (outissp(c) && c != '\t' && stream->linecol != 0 && !qspace -< && stream->html_pre_level == 0) -< { -< int pos1 = stream->linepos - 1; -< char p = stream->linebuf[pos1]; /* check previous character */ -< -< /* ignore repeated spaces - collapse into a single space */ -< if (outissp(p)) -< return; -< -< /* -< * Certain punctuation requires a double space: a period, a -< * question mark, an exclamation mark, or a colon; or any of -< * these characters followed by any number of single and/or -< * double quotes. First, scan back to before any quotes, if -< * are on one now, then check the preceding character; if -< * it's one of the punctuation marks requiring a double -< * space, add this space a second time. (In addition to -< * scanning back past quotes, scan past parentheses, -< * brackets, and braces.) Don't double the spacing if we're -< * not in the normal doublespace mode; some people may -< * prefer single spacing after punctuation, so we make this -< * a run-time option. -< */ -< if (doublespace) -< { -< /* find the previous relevant punctuation character */ -< while (pos1 && -< (p == '"' || p == '\'' || p == ')' || p == ']' -< || p == '}')) -< { -< p = stream->linebuf[--pos1]; -< } -< if ( p == '.' || p == '?' || p == '!' || p == ':' ) -< { -< /* a double-space is required after this character */ -< stream->attrbuf[stream->linepos] = stream->cur_attr; -< stream->linebuf[stream->linepos++] = c; -< ++(stream->linecol); -< } -< } -< } -< -< /* add this character to the buffer */ -< stream->attrbuf[stream->linepos] = stream->cur_attr; -< stream->linebuf[stream->linepos++] = c; -< -< /* advance the output column position */ -< ++(stream->linecol); -< return; -< } -< -< /* -< * The line would overflow if this character were added. Find the -< * most recent word break, and output the line up to the previous -< * word. Note that if we're trying to output a space, we'll just -< * add it to the line buffer. If the last character of the line -< * buffer is already a space, we won't do anything right now. -< */ -< if (outissp(c) && c != '\t' && !qspace) -< { -< /* this is a space, so we're at a word break */ -< if (stream->linebuf[stream->linepos - 1] != ' ') -< { -< stream->attrbuf[stream->linepos] = stream->cur_attr; -< stream->linebuf[stream->linepos++] = ' '; -< } -< return; -< } -< -< /* -< * Find the most recent word break: look for a space or dash, starting -< * at the end of the line. -< * -< * If we're about to write a hyphen, we want to skip all contiguous -< * hyphens, because we want to keep them together as a single -< * punctuation mark; then keep going in the normal manner, which will -< * keep the hyphens plus the word they're attached to together as a -< * single unit. If spaces precede the sequence of hyphens, include -< * the prior word as well. -< */ -< i = stream->linepos - 1; -< if (c == '-') -< { -< /* skip any contiguous hyphens at the end of the line */ -< for ( ; i >= 0 && stream->linebuf[i] == '-' ; --i) ; -< -< /* skip any spaces preceding the sequence of hyphens */ -< for ( ; i >= 0 && outissp(stream->linebuf[i]) ; --i) ; -< } -< -< /* -< * Now find the preceding space. If we're doing our own wrapping -< * (i.e., we're not using OS line wrapping), then look for the -< * nearest hyphen as well. -< */ -< for ( ; i >= 0 && !outissp(stream->linebuf[i]) -< && !(!stream->os_line_wrap && stream->linebuf[i] == '-') ; --i) ; -< -< /* check to see if we found a good place to break */ -< if (i < 0) -< { -< /* -< * we didn't find any good place to break - flush the entire -< * line as-is, breaking arbitrarily in the middle of a word -< */ -< out_flushline(stream, FALSE); -< -< /* -< * we've completely cleared out the line buffer, so reset all of -< * the line buffer counters -< */ -< stream->linepos = 0; -< stream->linecol = 0; -< stream->linebuf[0] = '\0'; -< } -< else -< { -< char brkchar; -< char tmpbuf[MAXWIDTH]; -< int tmpattr[MAXWIDTH]; -< size_t tmpcnt; -< -< /* remember the word-break character */ -< brkchar = stream->linebuf[i]; -< -< /* null-terminate the line buffer */ -< stream->linebuf[stream->linepos] = '\0'; -< -< /* the next line starts after the break - save a copy */ -< tmpcnt = strlen(&stream->linebuf[i+1]); -< memcpy(tmpbuf, &stream->linebuf[i+1], tmpcnt + 1); -< memcpy(tmpattr, &stream->attrbuf[i+1], tmpcnt * sizeof(tmpattr[0])); -< -< /* -< * terminate the buffer at the space or after the hyphen, -< * depending on where we broke -< */ -< if (outissp(brkchar)) -< stream->linebuf[i] = '\0'; -< else -< stream->linebuf[i+1] = '\0'; -< -< /* write out everything up to the word break */ -< out_flushline(stream, TRUE); -< -< /* copy the next line into line buffer */ -< memcpy(stream->linebuf, tmpbuf, tmpcnt + 1); -< memcpy(stream->attrbuf, tmpattr, tmpcnt * sizeof(tmpattr[0])); -< stream->linepos = tmpcnt; -< -< /* -< * figure what column we're now in - count all of the printable -< * characters in the new line -< */ -< for (stream->linecol = 0, i = 0 ; i < stream->linepos ; ++i) -< { -< /* if it's printable, count it */ -< if (((unsigned char)stream->linebuf[i]) >= 26) -< ++(stream->linecol); -< } -< } -< -< /* add the new character to buffer */ -< stream->attrbuf[stream->linepos] = stream->cur_attr; -< stream->linebuf[stream->linepos++] = c; -< -< /* advance the column counter */ -< ++(stream->linecol); -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Write out a character, translating to the local system character set -< * from the game's internal character set. -< */ -< static void outchar_stream(out_stream_info *stream, char c) -< { -< outchar_noxlat_stream(stream, cmap_i2n(c)); -< } -< -< /* -< * write out a string, translating to the local system character set -< */ -< static void outstring_stream(out_stream_info *stream, char *s) -< { -< /* write out each character in the string */ -< for ( ; *s ; ++s) -< outchar_stream(stream, *s); -< } -< -< /* -< * write out a string without translation -< */ -< static void outstring_noxlat_stream(out_stream_info *stream, char *s) -< { -< for ( ; *s ; ++s) -< outchar_noxlat_stream(stream, *s); -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Write out an HTML character value, translating to the local character -< * set. -< */ -< static void outchar_html_stream(out_stream_info *stream, -< unsigned int htmlchar) -< { -< struct amp_tbl_t *ampptr; -< -< /* -< * search for a mapping entry for this entity, in case it's defined -< * in an external mapping file -< */ -< for (ampptr = amp_tbl ; -< ampptr < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++ampptr) -< { -< /* if this is the one, stop looking */ -< if (ampptr->html_cval == htmlchar) -< break; -< } -< -< /* -< * If we found a mapping table entry, and the entry has an expansion -< * from the external character mapping table file, use the external -< * expansion; otherwise, use the default expansion. -< */ -< if (ampptr >= amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) -< || ampptr->expan == 0) -< { -< char xlat_buf[50]; -< -< /* -< * there's no external mapping table file expansion -- use the -< * default OS mapping routine -< */ -< os_xlat_html4(htmlchar, xlat_buf, sizeof(xlat_buf)); -< outstring_noxlat_stream(stream, xlat_buf); -< } -< else -< { -< /* -< * use the explicit mapping from the mapping table file -< */ -< outstring_noxlat_stream(stream, ampptr->expan); -< } -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Enter a recursion level. Returns TRUE if the caller should proceed -< * with the operation, FALSE if not. -< * -< * If we're making a recursive call, thereby re-entering the formatter, -< * and this stream is not the same as the enclosing stream, we want to -< * ignore this call and suppress any output to this stream, so we'll -< * return FALSE. -< */ -< static int out_push_stream(out_stream_info *stream) -< { -< /* -< * if we're already in the formatter, and the new stream doesn't -< * match the enclosing recursion level's stream, tell the caller to -< * abort the operation -< */ -< if (G_recurse != 0 && G_cur_stream != stream) -< return FALSE; -< -< /* note the active stream */ -< G_cur_stream = stream; -< -< /* count the entry */ -< ++G_recurse; -< -< /* tell the caller to proceed */ -< return TRUE; -< } -< -< /* -< * Leave a recursion level -< */ -< static void out_pop_stream() -< { -< /* count the exit */ -< --G_recurse; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * nextout() returns the next character in a string, and updates the -< * string pointer and remaining length. Returns zero if no more -< * characters are available in the string. -< */ -< /* static char nextout(char **s, uint *len); */ -< #define nextout(s, len) ((char)(*(len) == 0 ? 0 : (--(*(len)), *((*(s))++)))) -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Get the next character, writing the previous character to the given -< * output stream if it's not null. -< */ -< static char nextout_copy(char **s, size_t *slen, -< char prv, out_stream_info *stream) -< { -< /* if there's a stream, write the previous character to the stream */ -< if (stream != 0) -< outchar_stream(stream, prv); -< -< /* return the next character */ -< return nextout(s, slen); -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Read an HTML tag, for our primitive mini-parser. If 'stream' is not -< * null, we'll copy each character we read to the output stream. Returns -< * the next character after the tag name. -< */ -< static char read_tag(char *dst, size_t dstlen, int *is_end_tag, -< char **s, size_t *slen, out_stream_info *stream) -< { -< char c; -< -< /* skip the opening '<' */ -< c = nextout_copy(s, slen, '<', stream); -< -< /* skip spaces */ -< while (outissp(c)) -< c = nextout_copy(s, slen, c, stream); -< -< /* note if this is a closing tag */ -< if (c == '/' || c == '\\') -< { -< /* it's an end tag - note it and skip the slash */ -< *is_end_tag = TRUE; -< c = nextout_copy(s, slen, c, stream); -< -< /* skip yet more spaces */ -< while (outissp(c)) -< c = nextout_copy(s, slen, c, stream); -< } -< else -< *is_end_tag = FALSE; -< -< /* -< * find the end of the tag name - the tag continues to the next space, -< * '>', or end of line -< */ -< for ( ; c != '\0' && !outissp(c) && c != '>' ; -< c = nextout_copy(s, slen, c, stream)) -< { -< /* add this to the tag buffer if it fits */ -< if (dstlen > 1) -< { -< *dst++ = c; -< --dstlen; -< } -< } -< -< /* null-terminate the tag name */ -< if (dstlen > 0) -< *dst = '\0'; -< -< /* return the next character */ -< return c; -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * display a string of a given length to a given stream -< */ -< static int outformatlen_stream(out_stream_info *stream, -< char *s, size_t slen) -< { -< char c; -< int done = 0; -< char fmsbuf[40]; /* space for constructing translation string */ -< uint fmslen; -< char *f = 0; -< char *f1; -< int infmt = 0; -< -< /* -< * This routine can recurse because of format strings ("%xxx%" -< * sequences). When we recurse, we want to ensure that the -< * recursion is directed to the original stream only. So, note the -< * current stream statically in case we re-enter the formatter. -< */ -< if (!out_push_stream(stream)) -< return 0; -< -< /* get the first character */ -< c = nextout(&s, &slen); -< -< /* if we have anything to show, show it */ -< while (c != '\0') -< { -< /* check if we're collecting translation string */ -< if (infmt) -< { -< /* -< * if the string is too long for our buffer, or we've come -< * across a backslash (illegal in a format string), or we've -< * come across an HTML-significant character ('&' or '<') in -< * HTML mode, we must have a stray percent sign; dump the -< * whole string so far and act as though we have no format -< * string -< */ -< if (c == '\\' -< || f == &fmsbuf[sizeof(fmsbuf)] -< || (stream->html_mode && (c == '<' || c == '&'))) -< { -< outchar_stream(stream, '%'); -< for (f1 = fmsbuf ; f1 < f ; ++f1) -< outchar_stream(stream, *f1); -< infmt = 0; -< -< /* process this character again */ -< continue; -< } -< else if (c == '%' && f == fmsbuf) /* double percent sign? */ -< { -< outchar_stream(stream, '%'); /* send out a single '%' */ -< infmt = 0; /* no longer processing translation string */ -< } -< else if (c == '%') /* found end of string? translate it if so */ -< { -< uchar *fms; -< int initcap = FALSE; -< int allcaps = FALSE; -< char fmsbuf_srch[sizeof(fmsbuf)]; -< -< /* null-terminate the string */ -< *f = '\0'; -< -< /* check for an init cap */ -< if (outisup(fmsbuf[0])) -< { -< /* -< * note the initial capital, so that we follow the -< * original capitalization in the substituted string -< */ -< initcap = TRUE; -< -< /* -< * if the second letter is capitalized as well, -< * capitalize the entire substituted string -< */ -< if (fmsbuf[1] != '\0' && outisup(fmsbuf[1])) -< { -< /* use all caps */ -< allcaps = TRUE; -< } -< } -< -< /* convert the entire string to lower case for searching */ -< strcpy(fmsbuf_srch, fmsbuf); -< os_strlwr(fmsbuf_srch); -< -< /* find the string in the format string table */ -< fmslen = strlen(fmsbuf_srch); -< for (fms = fmsbase ; fms < fmstop ; ) -< { -< uint propnum; -< uint len; -< -< /* get the information on this entry */ -< propnum = osrp2(fms); -< len = osrp2(fms + 2) - 2; -< -< /* check for a match */ -< if (len == fmslen && -< !memcmp(fms + 4, fmsbuf_srch, (size_t)len)) -< { -< int old_all_caps; -< -< /* note the current ALLCAPS mode */ -< old_all_caps = stream->allcapsflag; -< -< /* -< * we have a match - set the appropriate -< * capitalization mode -< */ -< if (allcaps) -< outallcaps_stream(stream, TRUE); -< else if (initcap) -< outcaps_stream(stream); -< -< /* -< * evaluate the associated property to generate -< * the substitution text -< */ -< runppr(runctx, cmdActor, (prpnum)propnum, 0); -< -< /* turn off ALLCAPS mode */ -< outallcaps_stream(stream, old_all_caps); -< -< /* no need to look any further */ -< break; -< } -< -< /* move on to next formatstring if not yet found */ -< fms += len + 4; -< } -< -< /* if we can't find it, dump the format string as-is */ -< if (fms == fmstop) -< { -< outchar_stream(stream, '%'); -< for (f1 = fmsbuf ; f1 < f ; ++f1) -< outchar_stream(stream, *f1); -< outchar_stream(stream, '%'); -< } -< -< /* no longer reading format string */ -< infmt = 0; -< } -< else -< { -< /* copy this character of the format string */ -< *f++ = c; -< } -< -< /* move on to the next character and continue scanning */ -< c = nextout(&s, &slen); -< continue; -< } -< -< /* -< * If we're parsing HTML here, and we're inside a tag, skip -< * characters until we reach the end of the tag. -< */ -< if (stream->html_mode_flag != HTML_MODE_NORMAL) -< { -< switch(stream->html_mode_flag) -< { -< case HTML_MODE_TAG: -< /* -< * keep skipping up to the closing '>', but note when we -< * enter any quoted section -< */ -< switch(c) -< { -< case '>': -< /* we've reached the end of the tag */ -< stream->html_mode_flag = HTML_MODE_NORMAL; -< -< /* if we have a deferred
, process it now */ -< switch(stream->html_defer_br) -< { -< case HTML_DEFER_BR_NONE: -< /* no deferred
*/ -< break; -< -< case HTML_DEFER_BR_FLUSH: -< outflushn_stream(stream, 1); -< break; -< -< case HTML_DEFER_BR_BLANK: -< outblank_stream(stream); -< break; -< } -< -< /* no more deferred
pending */ -< stream->html_defer_br = HTML_DEFER_BR_NONE; -< -< /* no more ALT attribute allowed */ -< stream->html_allow_alt = FALSE; -< break; -< -< case '"': -< /* enter a double-quoted string */ -< stream->html_mode_flag = HTML_MODE_DQUOTE; -< break; -< -< case '\'': -< /* enter a single-quoted string */ -< stream->html_mode_flag = HTML_MODE_SQUOTE; -< break; -< -< default: -< /* if it's alphabetic, note the attribute name */ -< if (outisal(c)) -< { -< char attrname[128]; -< char attrval[256]; -< char *dst; -< -< /* gather up the attribute name */ -< for (dst = attrname ; -< dst + 1 < attrname + sizeof(attrname) ; ) -< { -< /* store this character */ -< *dst++ = c; -< -< /* get the next character */ -< c = nextout(&s, &slen); -< -< /* if it's not alphanumeric, stop scanning */ -< if (!outisal(c) && !outisdg(c)) -< break; -< } -< -< /* null-terminate the result */ -< *dst++ = '\0'; -< -< /* gather the value if present */ -< if (c == '=') -< { -< char qu; -< -< /* skip the '=' */ -< c = nextout(&s, &slen); -< -< /* if we have a quote, so note */ -< if (c == '"' || c == '\'') -< { -< /* remember the quote */ -< qu = c; -< -< /* skip it */ -< c = nextout(&s, &slen); -< } -< else -< { -< /* no quote */ -< qu = 0; -< } -< -< /* read the value */ -< for (dst = attrval ; -< dst + 1 < attrval + sizeof(attrval) ; ) -< { -< /* store this character */ -< *dst++ = c; -< -< /* read the next one */ -< c = nextout(&s, &slen); -< if (c == '\0') -< { -< /* -< * we've reached the end of the -< * string, and we're still inside -< * this attribute - abandon the -< * attribute but note that we're -< * inside a quoted string if -< * necessary -< */ -< if (qu == '"') -< stream->html_mode_flag = -< HTML_MODE_DQUOTE; -< else if (qu == '\'') -< stream->html_mode_flag = -< HTML_MODE_SQUOTE; -< else -< stream->html_mode_flag -< = HTML_MODE_TAG; -< -< /* stop scanning the string */ -< break; -< } -< -< /* -< * if we're looking for a quote, check -< * for the closing quote; otherwise, -< * check for alphanumerics -< */ -< if (qu != 0) -< { -< /* if this is our quote, stop scanning */ -< if (c == qu) -< break; -< } -< else -< { -< /* if it's non-alphanumeric, we're done */ -< if (!outisal(c) && !outisdg(c)) -< break; -< } -< } -< -< /* skip the closing quote, if necessary */ -< if (qu != 0 && c == qu) -< c = nextout(&s, &slen); -< -< /* null-terminate the value string */ -< *dst = '\0'; -< } -< else -< { -< /* no value */ -< attrval[0] = '\0'; -< } -< -< /* -< * see if we recognize it, and it's meaningful -< * in the context of the current tag -< */ -< if (!stricmp(attrname, "height") -< && stream->html_defer_br != HTML_DEFER_BR_NONE) -< { -< int ht; -< -< /* -< * If the height is zero, always treat this -< * as a non-blanking flush. If it's one, -< * treat it as we originally planned to. If -< * it's greater than one, add n blank lines. -< */ -< ht = atoi(attrval); -< if (ht == 0) -< { -< /* always use non-blanking flush */ -< stream->html_defer_br = HTML_DEFER_BR_FLUSH; -< } -< else if (ht == 1) -< { -< /* keep original setting */ -< } -< else -< { -< for ( ; ht > 0 ; --ht) -< outblank_stream(stream); -< } -< } -< else if (!stricmp(attrname, "alt") -< && !stream->html_in_ignore -< && stream->html_allow_alt) -< { -< /* write out the ALT string */ -< outstring_stream(stream, attrval); -< } -< -< /* -< * since we already read the next character, -< * simply loop back immediately -< */ -< continue; -< } -< break; -< } -< break; -< -< case HTML_MODE_DQUOTE: -< /* if we've reached the closing quote, return to tag state */ -< if (c == '"') -< stream->html_mode_flag = HTML_MODE_TAG; -< break; -< -< case HTML_MODE_SQUOTE: -< /* if we've reached the closing quote, return to tag state */ -< if (c == '\'') -< stream->html_mode_flag = HTML_MODE_TAG; -< break; -< } -< -< /* -< * move on to the next character, and start over with the -< * new character -< */ -< c = nextout(&s, &slen); -< continue; -< } -< -< /* -< * If we're in a title, and this isn't the start of a new tag, -< * skip the character - we suppress all regular text output -< * inside a ... sequence. -< */ -< if (stream->html_in_ignore && c != '<') -< { -< /* check for entities */ -< char cbuf[50]; -< if (c == '&') -< { -< /* translate the entity */ -< c = out_parse_entity(cbuf, sizeof(cbuf), &s, &slen); -< } -< else -< { -< /* it's an ordinary character - copy it out literally */ -< cbuf[0] = c; -< cbuf[1] = '\0'; -< -< /* get the next character */ -< c = nextout(&s, &slen); -< } -< -< /* -< * if we're gathering a title, and there's room in the title -< * buffer for more (always leaving room for a null -< * terminator), add this to the title buffer -< */ -< if (stream->html_in_title) -< { -< char *cbp; -< for (cbp = cbuf ; *cbp != '\0' ; ++cbp) -< { -< /* if there's room, add it */ -< if (stream->html_title_ptr + 1 < -< stream->html_title_buf -< + sizeof(stream->html_title_buf)) -< *stream->html_title_ptr++ = *cbp; -< } -< } -< -< /* don't display anything in an ignore section */ -< continue; -< } -< -< if ( c == '%' ) /* translation string? */ -< { -< infmt = 1; -< f = fmsbuf; -< } -< else if ( c == '\\' ) /* special escape code? */ -< { -< c = nextout(&s, &slen); -< -< if (stream->capturing && c != '^' && c != 'v' && c != '\0') -< { -< outchar_stream(stream, '\\'); -< outchar_stream(stream, c); -< -< /* keep the \- and also put out the next two chars */ -< if (c == '-') -< { -< outchar_stream(stream, nextout(&s, &slen)); -< outchar_stream(stream, nextout(&s, &slen)); -< } -< } -< else -< { -< switch(c) -< { -< case 'H': /* HTML mode entry */ -< /* turn on HTML mode in the renderer */ -< switch(c = nextout(&s, &slen)) -< { -< case '-': -< /* if we have an HTML target, notify it */ -< if (stream->html_target) -< { -< /* flush its stream */ -< outflushn_stream(stream, 0); -< -< /* tell the OS layer to switch to normal mode */ -< out_end_html(stream); -< } -< -< /* switch to normal mode */ -< stream->html_mode = FALSE; -< break; -< -< case '+': -< default: -< /* if we have an HTML target, notify it */ -< if (stream->html_target) -< { -< /* flush the underlying stream */ -< outflushn_stream(stream, 0); -< -< /* tell the OS layer to switch to HTML mode */ -< out_start_html(stream); -< } -< -< /* switch to HTML mode */ -< stream->html_mode = TRUE; -< -< /* -< * if the character wasn't a "+", it's not part -< * of the "\H" sequence, so display it normally -< */ -< if (c != '+' && c != 0) -< outchar_stream(stream, c); -< break; -< } -< -< /* this sequence doesn't result in any actual output */ -< break; -< -< case 'n': /* newline? */ -< outflushn_stream(stream, 1); /* yes, output line */ -< break; -< -< case 't': /* tab? */ -< outtab_stream(stream); -< break; -< -< case 'b': /* blank line? */ -< outblank_stream(stream); -< break; -< -< case '\0': /* line ends here? */ -< done = 1; -< break; -< -< case ' ': /* quoted space */ -< if (stream->html_target && stream->html_mode) -< { -< /* -< * we're generating for an HTML target and we're -< * in HTML mode - generate the HTML non-breaking -< * space -< */ -< outstring_stream(stream, " "); -< } -< else -< { -< /* -< * we're not in HTML mode - generate our -< * internal quoted space character -< */ -< outchar_stream(stream, QSPACE); -< } -< break; -< -< case '^': /* capitalize next character */ -< stream->capsflag = 1; -< stream->nocapsflag = 0; -< break; -< -< case 'v': -< stream->nocapsflag = 1; -< stream->capsflag = 0; -< break; -< -< case '(': -< /* generate HTML if in the appropriate mode */ -< if (stream->html_mode && stream->html_target) -< { -< /* send HTML to the renderer */ -< outstring_stream(stream, ""); -< } -< else -< { -< /* turn on the 'hilite' attribute */ -< stream->cur_attr |= OS_ATTR_HILITE; -< } -< break; -< -< case ')': -< /* generate HTML if in the appropriate mode */ -< if (stream->html_mode && stream->html_target) -< { -< /* send HTML to the renderer */ -< outstring_stream(stream, ""); -< } -< else -< { -< /* turn off the 'hilite' attribute */ -< stream->cur_attr &= ~OS_ATTR_HILITE; -< } -< break; -< -< case '-': -< outchar_stream(stream, nextout(&s, &slen)); -< outchar_stream(stream, nextout(&s, &slen)); -< break; -< -< default: /* just pass invalid escapes as-is */ -< outchar_stream(stream, c); -< break; -< } -< } -< } -< else if (!stream->html_target -< && stream->html_mode -< && (c == '<' || c == '&')) -< { -< /* -< * We're in HTML mode, but the underlying target does not -< * accept HTML sequences. It appears we're at the start of -< * an "&" entity or a tag sequence, so parse it, remove it, -< * and replace it (if possible) with a text-only equivalent. -< */ -< if (c == '<') -< { -< /* read the tag */ -< char tagbuf[50]; -< int is_end_tag; -< c = read_tag(tagbuf, sizeof(tagbuf), &is_end_tag, -< &s, &slen, 0); -< -< /* -< * Check to see if we recognize the tag. We only -< * recognize a few simple tags that map easily to -< * character mode. -< */ -< if (!stricmp(tagbuf, "br")) -< { -< /* -< * line break - if there's anything buffered up, -< * just flush the current line, otherwise write out -< * a blank line -< */ -< if (stream->html_in_ignore) -< /* suppress breaks in ignore mode */; -< else if (stream->linepos != 0) -< stream->html_defer_br = HTML_DEFER_BR_FLUSH; -< else -< stream->html_defer_br = HTML_DEFER_BR_BLANK; -< } -< else if (!stricmp(tagbuf, "b") -< || !stricmp(tagbuf, "i") -< || !stricmp(tagbuf, "em") -< || !stricmp(tagbuf, "strong")) -< { -< int attr; -< -< /* choose the attribute flag */ -< switch (tagbuf[0]) -< { -< case 'b': -< case 'B': -< attr = OS_ATTR_BOLD; -< break; -< -< case 'i': -< case 'I': -< attr = OS_ATTR_ITALIC; -< break; -< -< case 'e': -< case 'E': -< attr = OS_ATTR_EM; -< break; -< -< case 's': -< case 'S': -< attr = OS_ATTR_STRONG; -< break; -< } -< -< /* bold on/off - send out appropriate os-layer code */ -< if (stream->html_in_ignore) -< { -< /* suppress any change in 'ignore' mode */ -< } -< else if (!is_end_tag) -< { -< /* turn on the selected attribute */ -< stream->cur_attr |= attr; -< } -< else -< { -< /* turn off the selected attribute */ -< stream->cur_attr &= ~attr; -< } -< } -< else if (!stricmp(tagbuf, "p")) -< { -< /* paragraph - send out a blank line */ -< if (!stream->html_in_ignore) -< outblank_stream(stream); -< } -< else if (!stricmp(tagbuf, "tab")) -< { -< /* tab - send out a \t */ -< if (!stream->html_in_ignore) -< outtab_stream(stream); -< } -< else if (!stricmp(tagbuf, "img") || !stricmp(tagbuf, "sound")) -< { -< /* IMG and SOUND - allow ALT attributes */ -< stream->html_allow_alt = TRUE; -< } -< else if (!stricmp(tagbuf, "hr")) -< { -< int rem; -< -< if (!stream->html_in_ignore) -< { -< /* start a new line */ -< outflushn_stream(stream, 1); -< -< /* write out underscores to the display width */ -< for (rem = G_os_linewidth - 1 ; rem > 0 ; ) -< { -< char dashbuf[100]; -< int cur; -< -< /* do as much as we can on this pass */ -< cur = rem; -< if ((size_t)cur > sizeof(dashbuf) - 1) -< cur = sizeof(dashbuf) - 1; -< -< /* do a buffer-full of dashes */ -< memset(dashbuf, '_', cur); -< dashbuf[cur] = '\0'; -< outstring_stream(stream, dashbuf); -< -< /* deduct this from the total */ -< rem -= cur; -< } -< -< /* put a blank line after the underscores */ -< outblank_stream(stream); -< } -< } -< else if (!stricmp(tagbuf, "q")) -< { -< unsigned int htmlchar; -< -< if (!stream->html_in_ignore) -< { -< /* if it's an open quote, increment the level */ -< if (!is_end_tag) -< ++(stream->html_quote_level); -< -< /* add the open quote */ -< htmlchar = -< (!is_end_tag -< ? ((stream->html_quote_level & 1) == 1 -< ? 8220 : 8216) -< : ((stream->html_quote_level & 1) == 1 -< ? 8221 : 8217)); -< -< /* -< * write out the HTML character, translated to -< * the local character set -< */ -< outchar_html_stream(stream, htmlchar); -< -< /* if it's a close quote, decrement the level */ -< if (is_end_tag) -< --(stream->html_quote_level); -< } -< } -< else if (!stricmp(tagbuf, "title")) -< { -< /* -< * Turn ignore mode on or off as appropriate, and -< * turn on or off title mode as well. -< */ -< if (is_end_tag) -< { -< /* -< * note that we're leaving an ignore section and -< * a title section -< */ -< --(stream->html_in_ignore); -< --(stream->html_in_title); -< -< /* -< * if we're no longer in a title, call the OS -< * layer to tell it the title string, in case it -< * wants to change the window title or otherwise -< * make use of the title -< */ -< if (stream->html_in_title == 0) -< { -< /* null-terminate the title string */ -< *stream->html_title_ptr = '\0'; -< -< /* tell the OS about the title */ -< os_set_title(stream->html_title_buf); -< } -< } -< else -< { -< /* -< * if we aren't already in a title, set up to -< * capture the title into the title buffer -< */ -< if (!stream->html_in_title) -< stream->html_title_ptr = stream->html_title_buf; -< -< /* -< * note that we're in a title and in an ignore -< * section, since nothing within gets displayed -< */ -< ++(stream->html_in_ignore); -< ++(stream->html_in_title); -< } -< } -< else if (!stricmp(tagbuf, "aboutbox")) -< { -< /* turn ignore mode on or off as appropriate */ -< if (is_end_tag) -< --(stream->html_in_ignore); -< else -< ++(stream->html_in_ignore); -< } -< else if (!stricmp(tagbuf, "pre")) -< { -< /* count the nesting level if starting PRE mode */ -< if (!is_end_tag) -< stream->html_pre_level += 1; -< -< /* surround the PRE block with line breaks */ -< outblank_stream(stream); -< -< /* count the nesting level if ending PRE mode */ -< if (is_end_tag && stream->html_pre_level != 0) -< stream->html_pre_level -= 1; -< } -< -< /* suppress everything up to the next '>' */ -< stream->html_mode_flag = HTML_MODE_TAG; -< -< /* -< * continue with the current character; since we're in -< * html tag mode, we'll skip everything until we get to -< * the closing '>' -< */ -< continue; -< } -< else if (c == '&') -< { -< /* parse it */ -< char xlat_buf[50]; -< c = out_parse_entity(xlat_buf, sizeof(xlat_buf), &s, &slen); -< -< /* write it out (we've already translated it) */ -< outstring_noxlat_stream(stream, xlat_buf); -< -< /* proceed with the next character */ -< continue; -< } -< } -< else if (stream->html_target && stream->html_mode && c == '<') -< { -< /* -< * We're in HTML mode, and we have an underlying HTML target. -< * We don't need to do much HTML interpretation at this level. -< * However, we do need to keep track of when we're in a PRE -< * block, so that we can pass whitespaces and newlines through -< * to the underlying HTML engine without filtering when we're -< * in preformatted text. -< */ -< char tagbuf[50]; -< int is_end_tag; -< c = read_tag(tagbuf, sizeof(tagbuf), &is_end_tag, -< &s, &slen, stream); -< -< /* check for special tags */ -< if (!stricmp(tagbuf, "pre")) -< { -< /* count the nesting level */ -< if (!is_end_tag) -< stream->html_pre_level += 1; -< else if (is_end_tag && stream->html_pre_level != 0) -< stream->html_pre_level -= 1; -< } -< -< /* copy the last character after the tag to the stream */ -< outchar_stream(stream, c); -< } -< else -< { -< /* normal character */ -< outchar_stream(stream, c); -< } -< -< /* move on to the next character, unless we're finished */ -< if (done) -< c = '\0'; -< else -< c = nextout(&s, &slen); -< } -< -< /* if we ended up inside what looked like a format string, dump string */ -< if (infmt) -< { -< outchar_stream(stream, '%'); -< for (f1 = fmsbuf ; f1 < f ; ++f1) -< outchar_stream(stream, *f1); -< } -< -< /* exit a recursion level */ -< out_pop_stream(); -< -< /* success */ -< return 0; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Parse an HTML entity markup -< */ -< static char out_parse_entity(char *outbuf, size_t outbuf_size, -< char **sp, size_t *slenp) -< { -< char ampbuf[10]; -< char *dst; -< char *orig_s; -< size_t orig_slen; -< const struct amp_tbl_t *ampptr; -< size_t lo, hi, cur; -< char c; -< -< /* -< * remember where the part after the '&' begins, so we can come back -< * here later if necessary -< */ -< orig_s = *sp; -< orig_slen = *slenp; -< -< /* get the character after the ampersand */ -< c = nextout(sp, slenp); -< -< /* if it's numeric, parse the number */ -< if (c == '#') -< { -< uint val; -< -< /* skip the '#' */ -< c = nextout(sp, slenp); -< -< /* check for hex */ -< if (c == 'x' || c == 'X') -< { -< /* skip the 'x' */ -< c = nextout(sp, slenp); -< -< /* read the hex number */ -< for (val = 0 ; isxdigit((uchar)c) ; c = nextout(sp, slenp)) -< { -< /* accumulate the current digit into the value */ -< val *= 16; -< if (outisdg(c)) -< val += c - '0'; -< else if (c >= 'a' && c <= 'f') -< val += c - 'a' + 10; -< else -< val += c - 'A' + 10; -< } -< } -< else -< { -< /* read the number */ -< for (val = 0 ; outisdg(c) ; c = nextout(sp, slenp)) -< { -< /* accumulate the current digit into the value */ -< val *= 10; -< val += c - '0'; -< } -< } -< -< /* if we found a ';' at the end, skip it */ -< if (c == ';') -< c = nextout(sp, slenp); -< -< /* translate the character into the output buffer */ -< os_xlat_html4(val, outbuf, outbuf_size); -< -< /* we're done with this character */ -< return c; -< } -< -< /* -< * Parse the sequence after the '&'. Parse up to the closing -< * semicolon, or any non-alphanumeric, or until we fill up the buffer. -< */ -< for (dst = ampbuf ; -< c != '\0' && (outisdg(c) || outisal(c)) -< && dst < ampbuf + sizeof(ampbuf) - 1 ; -< *dst++ = c, c = nextout(sp, slenp)) ; -< -< /* null-terminate the name */ -< *dst = '\0'; -< -< /* do a binary search for the name */ -< lo = 0; -< hi = sizeof(amp_tbl)/sizeof(amp_tbl[0]) - 1; -< for (;;) -< { -< int diff; -< -< /* if we've converged, look no further */ -< if (lo > hi || lo >= sizeof(amp_tbl)/sizeof(amp_tbl[0])) -< { -< ampptr = 0; -< break; -< } -< -< /* split the difference */ -< cur = lo + (hi - lo)/2; -< ampptr = &_tbl[cur]; -< -< /* see where we are relative to the target item */ -< diff = strcmp(ampptr->cname, ampbuf); -< if (diff == 0) -< { -< /* this is it */ -< break; -< } -< else if (diff > 0) -< { -< /* make sure we don't go off the end */ -< if (cur == hi && cur == 0) -< { -< /* we've failed to find it */ -< ampptr = 0; -< break; -< } -< -< /* this one is too high - check the lower half */ -< hi = (cur == hi ? hi - 1 : cur); -< } -< else -< { -< /* this one is too low - check the upper half */ -< lo = (cur == lo ? lo + 1 : cur); -< } -< } -< -< /* skip to the appropriate next character */ -< if (c == ';') -< { -< /* name ended with semicolon - skip the semicolon */ -< c = nextout(sp, slenp); -< } -< else if (ampptr != 0) -< { -< int skipcnt; -< -< /* found the name - skip its exact length */ -< skipcnt = strlen(ampptr->cname); -< for (*sp = orig_s, *slenp = orig_slen ; skipcnt != 0 ; -< c = nextout(sp, slenp), --skipcnt) ; -< } -< -< /* if we found the entry, write out the character */ -< if (ampptr != 0) -< { -< /* -< * if this one has an external mapping table entry, use the mapping -< * table entry; otherwise, use the default OS routine mapping -< */ -< if (ampptr->expan != 0) -< { -< /* -< * we have an explicit expansion from the mapping table file - -< * use it -< */ -< size_t copylen = strlen(ampptr->expan); -< if (copylen > outbuf_size - 1) -< copylen = outbuf_size - 1; -< -< memcpy(outbuf, ampptr->expan, copylen); -< outbuf[copylen] = '\0'; -< } -< else -< { -< /* -< * there's no mapping table expansion - use the default OS code -< * expansion -< */ -< os_xlat_html4(ampptr->html_cval, outbuf, outbuf_size); -< } -< } -< else -< { -< /* -< * didn't find it - output the '&' literally, then back up and -< * output the entire sequence following -< */ -< *sp = orig_s; -< *slenp = orig_slen; -< c = nextout(sp, slenp); -< -< /* fill in the '&' return value */ -< outbuf[0] = '&'; -< outbuf[1] = '\0'; -< } -< -< /* return the next character */ -< return c; -< } -< -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Initialize the output formatter -< */ -< void out_init() -< { -< /* not yet hiding output */ -< outflag = 1; -< outcnt = 0; -< hidout = 0; -< -< /* initialize the standard display stream */ -< out_init_std(&G_std_disp); -< -< /* initialize the log file stream */ -< out_init_log(&G_log_disp); -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * initialize the property translation table -< */ -< void tiosetfmt(tiocxdef *ctx, runcxdef *rctx, uchar *fbase, uint flen) -< { -< VARUSED(ctx); -< fmsbase = fbase; -< fmstop = fbase + flen; -< runctx = rctx; -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Map an HTML entity to a local character value. The character table -< * reader will call this routine during initialization if it finds HTML -< * entities in the mapping table file. We'll remember these mappings -< * for use in translating HTML entities to the local character set. -< * -< * Note that the standard run-time can only display a single character -< * set, so every HTML entity that we display must be mapped to the -< * single active native character set. -< */ -< void tio_set_html_expansion(unsigned int html_char_val, -< const char *expansion, size_t expansion_len) -< { -< struct amp_tbl_t *p; -< -< /* find the character value */ -< for (p = amp_tbl ; -< p < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++p) -< { -< /* if this is the one, store it */ -< if (p->html_cval == html_char_val) -< { -< /* allocate space for it */ -< p->expan = (char *)osmalloc(expansion_len + 1); -< -< /* save it */ -< memcpy(p->expan, expansion, expansion_len); -< p->expan[expansion_len] = '\0'; -< -< /* no need to look any further */ -< return; -< } -< } -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Write out a c-style (null-terminated) string. -< */ -< int outformat(char *s) -< { -< return outformatlen(s, strlen(s)); -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * This routine sends out a string, one character at a time (via outchar). -< * Escape codes ('\n', and so forth) are handled here. -< */ -< int outformatlen(char *s, uint slen) -< { -< char c; -< uint orig_slen; -< char *orig_s; -< int ret; -< int called_filter; -< -< /* presume we'll return success */ -< ret = 0; -< -< /* presume we won't call the filter function */ -< called_filter = FALSE; -< -< /* if there's a user filter function to invoke, call it */ -< if (G_user_filter != MCMONINV) -< { -< /* push the string */ -< runpstr(runctx, s, slen, 1); -< -< /* call the filter */ -< runfn(runctx, G_user_filter, 1); -< -< /* -< * note that we called the filter, so that we'll remove the -< * result of the filter from the stack before we return -< */ -< called_filter = TRUE; -< -< /* if the result is a string, use it in place of the original text */ -< if (runtostyp(runctx) == DAT_SSTRING) -< { -< runsdef val; -< uchar *p; -< -< /* pop the value */ -< runpop(runctx, &val); -< -< /* -< * get the text from the string, and use it as a replacement -< * for the original string -< */ -< p = val.runsv.runsvstr; -< slen = osrp2(p) - 2; -< s = (char *)(p + 2); -< -< /* -< * push the string back onto the stack - this will ensure -< * that the string stays referenced while we're working, so -< * that the garbage collector won't delete it -< */ -< runrepush(runctx, &val); -< } -< } -< -< /* remember the original string, before we scan the first character */ -< orig_s = s; -< orig_slen = slen; -< -< /* get the first character to display */ -< c = nextout(&s, &slen); -< -< /* if the string is non-empty, note that we've displayed something */ -< if (c != 0) -< outcnt = 1; -< -< /* check to see if we're hiding output */ -< if (out_is_hidden()) -< goto done; -< -< /* if the debugger is showing watchpoints, suppress all output */ -< if (outwxflag) -< goto done; -< -< /* display the string */ -< ret = outformatlen_stream(&G_std_disp, orig_s, orig_slen); -< -< /* if there's a log file, write to the log file as well */ -< if (logfp != 0) -< { -< outformatlen_stream(&G_log_disp, orig_s, orig_slen); -< osfflush(logfp); -< } -< -< done: -< /* if we called the filter, remove the result from the stack */ -< if (called_filter) -< rundisc(runctx); -< -< /* return the result from displaying to the screen */ -< return ret; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Display a blank line -< */ -< void outblank() -< { -< /* note that we've displayed something */ -< outcnt = 1; -< -< /* check to see if we're hiding output */ -< if (out_is_hidden()) -< return; -< -< /* generate the newline to the standard display */ -< outblank_stream(&G_std_disp); -< -< /* if we're logging, generate the newline to the log file as well */ -< if (logfp != 0) -< { -< outblank_stream(&G_log_disp); -< osfflush(logfp); -< } -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * outcaps() - sets an internal flag which makes the next letter output -< * a capital, whether it came in that way or not. Set the same state in -< * both formatters (standard and log). -< */ -< void outcaps(void) -< { -< outcaps_stream(&G_std_disp); -< outcaps_stream(&G_log_disp); -< } -< -< /* -< * outnocaps() - sets the next letter to a miniscule, whether it came in -< * that way or not. -< */ -< void outnocaps(void) -< { -< outnocaps_stream(&G_std_disp); -< outnocaps_stream(&G_log_disp); -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Open a log file -< */ -< int tiologopn(tiocxdef *ctx, char *fn) -< { -< /* if there's an old log file, close it */ -< if (tiologcls(ctx)) -< return 1; -< -< /* save the filename for later */ -< strcpy(logfname, fn); -< -< /* open the new file */ -< logfp = osfopwt(fn, OSFTLOG); -< -< /* -< * Reset the log file's output formatter state, since we're opening -< * a new file. -< */ -< out_init_log(&G_log_disp); -< -< /* -< * Set the log file's HTML source mode flag to the same value as is -< * currently being used in the main display stream, so that it will -< * interpret source markups the same way that the display stream is -< * going to. -< */ -< G_log_disp.html_mode = G_std_disp.html_mode; -< -< /* return 0 on success, non-zero on failure */ -< return (logfp == 0); -< } -< -< /* -< * Close the log file -< */ -< int tiologcls(tiocxdef *ctx) -< { -< /* if we have a file, close it */ -< if (logfp != 0) -< { -< /* close the handle */ -< osfcls(logfp); -< -< /* set the system file type to "log file" */ -< os_settype(logfname, OSFTLOG); -< -< /* forget about our log file handle */ -< logfp = 0; -< } -< -< /* success */ -< return 0; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Write text explicitly to the log file. This can be used to add -< * special text (such as prompt text) that would normally be suppressed -< * from the log file. When more mode is turned off, we don't -< * automatically copy text to the log file; any text that the caller -< * knows should be in the log file during times when more mode is turned -< * off can be explicitly added with this function. -< * -< * If nl is true, we'll add a newline at the end of this text. The -< * caller should not include any newlines in the text being displayed -< * here. -< */ -< void out_logfile_print(char *txt, int nl) -< { -< /* if there's no log file, there's nothing to do */ -< if (logfp == 0) -< return; -< -< /* add the text */ -< os_fprintz(logfp, txt); -< -< /* add a newline if desired */ -< if (nl) -< { -< /* add a normal newline */ -< os_fprintz(logfp, "\n"); -< -< /* if the logfile is an html target, write an HTML line break */ -< if (G_log_disp.html_target && G_log_disp.html_mode) -< os_fprintz(logfp, "
\n"); -< } -< -< /* flush the output */ -< osfflush(logfp); -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Set the current MORE mode -< */ -< int setmore(int state) -< { -< int oldstate = G_os_moremode; -< -< G_os_moremode = state; -< return oldstate; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Run the MORE prompt. If the output layer takes responsibility for -< * pagination issues (i.e., USE_MORE is defined), we'll simply display -< * the prompt and wait for input. Otherwise, the OS layer controls the -< * MORE prompt, so we'll call the OS-layer function to display the -< * prompt. -< */ -< void out_more_prompt() -< { -< #ifdef USE_MORE -< /* -< * USE_MORE defined - we take responsibility for pagination. Show -< * our default MORE prompt and wait for a keystroke. -< */ -< -< int done; -< int next_page; -< -< /* display the "MORE" prompt */ -< os_printz("[More]"); -< os_flush(); -< -< /* wait for an acceptable keystroke */ -< for (done = FALSE ; !done ; ) -< { -< os_event_info_t evt; -< -< /* get an event */ -< switch(os_get_event(0, FALSE, &evt)) -< { -< case OS_EVT_KEY: -< switch(evt.key[0]) -< { -< case ' ': -< /* stop waiting, show one page */ -< done = TRUE; -< next_page = TRUE; -< break; -< -< case '\r': -< case '\n': -< /* stop waiting, show one line */ -< done = TRUE; -< next_page = FALSE; -< break; -< -< default: -< /* ignore any other keystrokes */ -< break; -< } -< break; -< -< case OS_EVT_EOF: -< /* end of file - there's nothing to wait for now */ -< done = TRUE; -< next_page = TRUE; -< -< /* don't use more prompts any more, as the user can't respond */ -< G_os_moremode = FALSE; -< break; -< -< default: -< /* ignore other events */ -< break; -< } -< } -< -< /* -< * Remove the prompt from the screen by backing up and overwriting -< * it with spaces. (Note that this assumes that we're running in -< * some kind of terminal or character mode with a fixed-pitch font; -< * if that's not the case, the OS layer should be taking -< * responsibility for pagination anyway, so this code shouldn't be -< * in use in the first place.) -< */ -< os_printz("\r \r"); -< -< /* -< * if they pressed the space key, it means that we should show an -< * entire new page, so reset the line count to zero; otherwise, -< * we'll want to display another MORE prompt at the very next line, -< * so leave the line count alone -< */ -< if (next_page) -< G_std_disp.linecnt = 0; -< -< #else /* USE_MORE */ -< -< /* -< * USE_MORE is undefined - this means that the OS layer is taking -< * all responsibility for pagination. We must ask the OS layer to -< * display the MORE prompt, because we can't make any assumptions -< * about what the prompt looks like. -< */ -< -< os_more_prompt(); -< -< #endif /* USE_MORE */ -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * reset output -< */ -< void outreset(void) -< { -< G_std_disp.linecnt = 0; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Determine if HTML mode is active. Returns true if so, false if not. -< * Note that this merely indicates whether an "\H+" sequence is -< * currently active -- this will return true after an "\H+" sequence, -< * even on text-only interpreters. -< */ -< int tio_is_html_mode() -< { -< /* return the current HTML mode flag for the standard display stream */ -< return G_std_disp.html_mode; -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Capture routines. Capture affects only the standard display output -< * stream; there's no need to capture information redundantly in the log -< * file stream. -< */ -< -< /* -< * Begin/end capturing -< */ -< void tiocapture(tiocxdef *tioctx, mcmcxdef *memctx, int flag) -< { -< if (flag) -< { -< /* create a new object if necessary */ -< if (G_std_disp.capture_obj == MCMONINV) -< { -< mcmalo(memctx, 256, &G_std_disp.capture_obj); -< mcmunlck(memctx, G_std_disp.capture_obj); -< } -< -< /* remember the memory context */ -< G_std_disp.capture_ctx = memctx; -< } -< -< /* -< * remember capture status in the standard output stream as well as -< * the log stream -< */ -< G_std_disp.capturing = flag; -< G_log_disp.capturing = flag; -< } -< -< /* clear all captured output */ -< void tioclrcapture(tiocxdef *tioctx) -< { -< G_std_disp.capture_ofs = 0; -< } -< -< /* clear captured output back to a given size */ -< void tiopopcapture(tiocxdef *tioctx, uint orig_size) -< { -< G_std_disp.capture_ofs = orig_size; -< } -< -< /* get the object handle of the captured output */ -< mcmon tiogetcapture(tiocxdef *ctx) -< { -< return G_std_disp.capture_obj; -< } -< -< /* get the amount of text captured */ -< uint tiocapturesize(tiocxdef *ctx) -< { -< return G_std_disp.capture_ofs; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * set the current actor -< */ -< void tiosetactor(tiocxdef *ctx, objnum actor) -< { -< VARUSED(ctx); -< cmdActor = actor; -< } -< -< /* -< * get the current actor -< */ -< objnum tiogetactor(tiocxdef *ctx) -< { -< VARUSED(ctx); -< return cmdActor; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Flush the output line. We'll write to both the standard display and -< * the log file, as needed. -< */ -< void outflushn(int nl) -< { -< /* flush the display stream */ -< outflushn_stream(&G_std_disp, nl); -< -< /* flush the log stream, if we have an open log file */ -< if (logfp != 0) -< { -< outflushn_stream(&G_log_disp, nl); -< osfflush(logfp); -< } -< } -< -< /* -< * flush the current line, and start a new line -< */ -< void outflush(void) -< { -< /* use the common flushing routine in mode 1 (regular newline) */ -< outflushn(1); -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Hidden text routines -< */ -< -< /* -< * outhide - hide output in the standard display stream -< */ -< void outhide(void) -< { -< outflag = 0; -< outcnt = 0; -< hidout = 0; -< } -< -< /* -< * Check output status. Indicate whether output is currently hidden, -< * and whether any hidden output has occurred. -< */ -< void outstat(int *hidden, int *output_occurred) -< { -< *hidden = !outflag; -< *output_occurred = outcnt; -< } -< -< /* set the flag to indicate that output has occurred */ -< void outsethidden(void) -< { -< outcnt = 1; -< hidout = 1; -< } -< -< /* -< * outshow() - turns output back on, and returns TRUE (1) if any output -< * has occurred since the last outshow(), FALSE (0) otherwise. -< */ -< int outshow(void) -< { -< /* turn output back on */ -< outflag = 1; -< -< /* if we're debugging, note the end of hidden output */ -< if (dbghid && hidout) -< { -< hidout = 0; -< trcsho(); -< } -< -< /* return the flag indicating whether hidden output occurred */ -< return outcnt; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * start/end watchpoint evaluation - suppress all dstring output -< */ -< void outwx(int flag) -< { -< outwxflag = flag; -< } -< -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Set the user filter function. Setting this to MCMONINV clears the -< * filter. -< */ -< void out_set_filter(objnum filter_fn) -< { -< /* remember the filter function */ -< G_user_filter = filter_fn; -< } -< -< /* ------------------------------------------------------------------------ */ -< /* -< * Set the double-space mode -< */ -< void out_set_doublespace(int dbl) -< { -< /* remember the new setting */ -< doublespace = dbl; -< } -< ---- -> #ifdef RCSID -> static char RCSid[] = -> "$Header: d:/cvsroot/tads/TADS2/Output.c,v 1.2 1999/05/17 02:52:12 MJRoberts Exp $"; -> #endif -> -> /* -> * Copyright (c) 1987, 1988 by Michael J. Roberts. All Rights Reserved. -> * -> * Please see the accompanying license file, LICENSE.TXT, for information -> * on using and copying this software. -> */ -> /* -> Name -> output - TADS Interpreter and Compiler formatted Output routines -> Function -> Provides formatted output support. Text that is sent through outformat() -> is displayed with word-wrap so that words fill the line but are not broken -> across lines. Other routines allow flushing the output buffer, displaying -> blank lines, and logging output to a file as well as to the display. -> Notes -> We use the global variables G_os_pagelength and G_os_linewidth, defined -> in the OS code, to determine the size of the display area and to determine -> the number of lines to display between page pauses (MORE prompts). Line -> breaking and MORE prompting can be handled by the OS code if desired; -> the USE_MORE macro controls this setting. -> Returns -> None -> Modified -> 04/05/92 MJRoberts - TADS 2.0 changes -> 03/29/92 MJRoberts - fix unfound formatstring handling -> 08/01/91 MJRoberts - no more mode when debugger is running -> 07/18/91 MJRoberts - improve t_outline [more] behavior -> 07/01/91 MJRoberts - Mac porting changes -> 06/05/91 MJRoberts - add format string support -> 03/27/91 MJRoberts - debugger enhancements -> 03/10/91 MJRoberts - integrate John's qa-scripter mods -> 04/24/90 MJRoberts - add \^ (equivalent to calling "caps()" intrinsic) -> 04/16/89 MJRoberts - add outcformat for compressed strings -> 10/30/88 MJRoberts - add outhide() and outshow() functions -> 10/29/88 MJRoberts - break lines on hyphens -> 12/22/87 MJRoberts - created -> */ -> -> #include -> #include -> #include -> #include -> #include -> -> #include "os.h" -> #include "std.h" -> #include "run.h" -> #include "voc.h" -> #include "tio.h" -> #include "mcm.h" -> #include "dbg.h" -> #include "cmap.h" -> -> /* -> * use our own isxxx - anything outside the US ASCII range is not reliably -> * classifiable by the normal C isxxx routines -> */ -> #define outissp(c) (((uchar)(c)) <= 127 && isspace((uchar)(c))) -> #define outisal(c) (((uchar)(c)) <= 127 && isalpha((uchar)(c))) -> #define outisdg(c) (((uchar)(c)) <= 127 && isdigit((uchar)(c))) -> #define outisup(c) (((uchar)(c)) <= 127 && isupper((uchar)(c))) -> #define outislo(c) (((uchar)(c)) <= 127 && islower((uchar)(c))) -> -> -> /* -> * Turn on formatter-level MORE mode, EXCEPT under any of the following -> * conditions: -> * -> * - this is a MAC OS port -> *. - this is an HTML TADS interpreter -> *. - USE_OS_LINEWRAP is defined -> * -> * Formatter-level MORE mode and formatter-level line wrapping go together; -> * you can't have one without the other. So, if USE_OS_LINEWRAP is -> * defined, we must also use OS-level MORE mode, which means we don't want -> * formatter-level MORE mode. -> * -> * For historical reasons, we check specifically for MAC_OS. This was the -> * first platform for which OS-level MORE mode and OS-level line wrapping -> * were invented; at the time, we foolishly failed to anticipate that more -> * platforms might eventually come along with the same needs, so we coded a -> * test for MAC_OS rather than some more abstract marker. For -> * compatibility, we retain this specific test. -> * -> * USE_OS_LINEWRAP is intended as the more abstract marker we should -> * originally have used. A port should #define USE_OS_LINEWRAP in its -> * system-specific os_xxx.h header to turn on OS-level line wrapping and -> * OS-level MORE mode. Ports should avoid adding new #ifndef tests for -> * specific platforms here; we've only retained the MAC_OS test because we -> * don't want to break the existing MAC_OS port. -> */ -> #ifndef MAC_OS -> # ifndef USE_HTML -> # ifndef USE_OS_LINEWRAP -> # define USE_MORE /* activate formatter-level more-mode */ -> # endif /* USE_OS_LINEWRAP */ -> # endif /* USE_HTML */ -> #endif /* MAC_OS */ -> -> /* -> * In HTML mode, don't use MORE mode. Note that we explicitly turn MORE -> * mode OFF, even though we won't have turned it on above, because it might -> * have been turned on by an os_xxx.h header. This is here for historical -> * reasons; in particular, some of the HTML interpreter builds include -> * headers that were originally written for the normal builds for those -> * same platforms, and those original headers explicitly #define USE_MORE -> * somewhere. So, to be absolutely sure we get it right here, we have to -> * explicitly turn off USE_MORE when compiling for HTML mode. -> */ -> #ifdef USE_HTML -> # ifdef USE_MORE -> # undef USE_MORE -> # endif -> #endif -> -> /* -> * QSPACE is the special character for a quoted space (internally, the -> * sequence "\ " (backslash-space) is converted to QSPACE). It must not -> * be any printable character. The value here may need to be changed in -> * the extremely unlikely event that TADS is ever ported to an EBCDIC -> * machine. -> */ -> #define QSPACE 26 -> -> /* -> * QTAB is a special hard tab character indicator. We use this when we -> * need to generate a hard tab to send to the underlying output layer -> * (in particular, we use this to send hard tabs to the HTML formatter -> * when we're in HTML mode). -> */ -> #define QTAB 25 -> -> -> /* maximum width of the display */ -> #define MAXWIDTH OS_MAXWIDTH -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Globals and statics. These should really be moved into a context -> * structure, so that the output formatter subsystem could be shared -> * among multiple clients. For now, there's no practical problem using -> * statics, because we only need a single output subsystem at one time. -> */ -> -> /* current script (command input) file */ -> extern osfildef *scrfp; -> -> /* -> * This should be TRUE if the output should have two spaces after a -> * period (or other such punctuation. It should generally be TRUE for -> * fixed-width fonts, and FALSE for proportional fonts. -> */ -> static int doublespace = 1; -> -> /* -> * Log file handle and name. If we're copying output to a log file, -> * these will tell us about the file. -> */ -> osfildef *logfp; -> static char logfname[OSFNMAX]; -> -> /* flag indicating whether output has occurred since last check */ -> static uchar outcnt; -> -> /* flag indicating whether hidden output has occurred */ -> static uchar hidout; -> -> /* flag indicating whether to show (TRUE) or hide (FALSE) output */ -> static uchar outflag; -> -> /* flag indicating whether output is hidden for debugging purposes */ -> int dbghid; -> -> /* -> * Current recursion level in formatter invocation -> */ -> static int G_recurse = 0; -> -> /* active stream in current recursion level */ -> static struct out_stream_info *G_cur_stream; -> -> /* watchpoint mode flag */ -> static uchar outwxflag; -> -> /* -> * User filter function. When this function is set, we'll invoke this -> * function for each string that's displayed through the output -> * formatter. -> */ -> static objnum G_user_filter = MCMONINV; -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Hack to run with TADS 2.0 with minimal reworking. Rather than using -> * an allocated output layer context, store our subsystem context -> * information in some statics. This is less clean than using a real -> * context, but doesn't create any practical problems as we don't need -> * to share the output formatter subsystem among multiple simultaneous -> * callers. -> */ -> static runcxdef *runctx; /* execution context */ -> static uchar *fmsbase; /* format string area base */ -> static uchar *fmstop; /* format string area top */ -> static objnum cmdActor; /* current actor */ -> -> /* forward declarations of static functions */ -> static void outstring_stream(struct out_stream_info *stream, char *s); -> static void outchar_noxlat_stream(struct out_stream_info *stream, char c); -> static char out_parse_entity(char *outbuf, size_t outbuf_size, -> char **sp, size_t *slenp); -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * HTML lexical analysis mode -> */ -> #define HTML_MODE_NORMAL 0 /* normal text, not in a tag */ -> #define HTML_MODE_TAG 1 /* parsing inside a tag */ -> #define HTML_MODE_SQUOTE 2 /* in a single-quoted string in a tag */ -> #define HTML_MODE_DQUOTE 3 /* in a double-quoted string in a tag */ -> -> /* -> * HTML parsing mode flag for
tags. We defer these until we've -> * read the full tag in order to obey an HEIGHT attribute we find. When -> * we encounter a
, we figure out whether we think we'll need a -> * flush or a blank line; if we find a HEIGHT attribute, we may change -> * this opinion. -> */ -> #define HTML_DEFER_BR_NONE 0 /* no pending
*/ -> #define HTML_DEFER_BR_FLUSH 1 /* only need an outflush() */ -> #define HTML_DEFER_BR_BLANK 2 /* need an outblank() */ -> -> /* -> * If we're compiling for an HTML-enabled underlying output subsystem, -> * we want to call the underlying OS layer when switching in and out of -> * HTML mode. If the underlying system doesn't process HTML, we don't -> * need to let it know anything about HTML mode. -> */ -> #ifdef USE_HTML -> # define out_start_html(stream) os_start_html() -> # define out_end_html(stream) os_end_html() -> #else -> # define out_start_html(stream) -> # define out_end_html(stream) -> #endif -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Output formatter stream state structure. This structure encapsulates -> * the state of an individual output stream. -> */ -> typedef struct out_stream_info out_stream_info; -> struct out_stream_info -> { -> /* low-level display routine (va_list version) */ -> void (*do_print)(out_stream_info *stream, const char *str); -> -> /* current line position and output column */ -> uchar linepos; -> uchar linecol; -> -> /* number of lines on the screen (since last MORE prompt) */ -> int linecnt; -> -> /* output buffer */ -> char linebuf[MAXWIDTH]; -> -> /* -> * attribute buffer - we keep one attribute entry for each character in -> * the line buffer -> */ -> int attrbuf[MAXWIDTH]; -> -> /* current attribute for text we're buffering into linebuf */ -> int cur_attr; -> -> /* last attribute we wrote to the osifc layer */ -> int os_attr; -> -> /* CAPS mode - next character output is converted to upper-case */ -> uchar capsflag; -> -> /* NOCAPS mode - next character output is converted to lower-case */ -> uchar nocapsflag; -> -> /* ALLCAPS mode - all characters output are converted to upper-case */ -> uchar allcapsflag; -> -> /* capture information */ -> mcmcxdef *capture_ctx; /* memory context to use for capturing */ -> mcmon capture_obj; /* object holding captured output */ -> uint capture_ofs; /* write offset in capture object */ -> int capturing; /* true -> we are capturing output */ -> -> /* "preview" state for line flushing */ -> int preview; -> -> /* flag indicating that we just flushed a new line */ -> int just_did_nl; -> -> /* this output stream uses "MORE" mode */ -> int use_more_mode; -> -> /* -> * This output stream uses OS-level line wrapping - if this is set, -> * the output formatter will not insert a newline at the end of a -> * line that it's flushing for word wrapping, but will instead let -> * the underlying OS display layer handle the wrapping. -> */ -> int os_line_wrap; -> -> /* -> * Flag indicating that the underlying output system wants to -> * receive its output as HTML. -> * -> * If this is true, we'll pass through HTML to the underlying output -> * system, and in addition generate HTML sequences for certain -> * TADS-native escapes (for example, we'll convert the "\n" sequence -> * to a
sequence). -> * -> * If this is false, we'll do just the opposite: we'll remove HTML -> * from the output stream and convert it into normal text sequences. -> */ -> int html_target; -> -> /* -> * Flag indicating that the target uses plain text. If this flag is -> * set, we won't add the OS escape codes for highlighted characters. -> */ -> int plain_text_target; -> -> /* -> * Flag indicating that the caller is displaying HTML. We always -> * start off in text mode; the client can switch to HTML mode by -> * displaying a special escape sequence, and can switch back to text -> * mode by displaying a separate special escape sequence. -> */ -> int html_mode; -> -> /* current lexical analysis mode */ -> unsigned int html_mode_flag; -> -> /*
defer mode */ -> unsigned int html_defer_br; -> -> /* -> * HTML "ignore" mode - we suppress all output when parsing the -> * contents of a or <ABOUTBOX> tag -> */ -> int html_in_ignore; -> -> /* -> * HTML <TITLE> mode - when we're in this mode, we're gathering the -> * title (i.e., we're inside a <TITLE> tag's contents). We'll copy -> * characters to the title buffer rather than the normal output -> * buffer, and then call os_set_title() when we reach the -> * tag. -> */ -> int html_in_title; -> -> /* buffer for the title */ -> char html_title_buf[256]; -> -> /* pointer to next available character in title buffer */ -> char *html_title_ptr; -> -> /* quoting level */ -> int html_quote_level; -> -> /* PRE nesting level */ -> int html_pre_level; -> -> /* -> * Parsing mode flag for ALT attributes. If we're parsing a tag -> * that allows ALT, such as IMG or SOUND, we'll set this flag, then -> * insert the ALT text if we encounter it during parsing. -> */ -> int html_allow_alt; -> }; -> -> /* -> * Default output converter. This is the output converter for the -> * standard display. Functions in the public interface that do not -> * specify an output converter will use this converter by default. -> */ -> static out_stream_info G_std_disp; -> -> /* -> * Log file converter. This is the output converter for a log file. -> * Whenever we open a log file, we'll initialize this converter; as we -> * display text to the main display, we'll also copy it to the log file. -> * -> * We maintain an entire separate conversion context for the log file, -> * so that we can perform a different set of conversions on it. We may -> * want, for example, to pass HTML text through to the OS display -> * subsystem (this is the case for the HTML-enabled interpreter), but -> * we'll still want to convert log file output to text. By keeping a -> * separate display context for the log file, we can format output to -> * the log file using an entirely different style than we do for the -> * display. -> */ -> static out_stream_info G_log_disp; -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * low-level output handlers for the standard display and log file -> */ -> -> /* standard display printer */ -> static void do_std_print(out_stream_info *stream, const char *str) -> { -> VARUSED(stream); -> -> /* display the text through the OS layer */ -> os_printz(str); -> } -> -> /* log file printer */ -> static void do_log_print(out_stream_info *stream, const char *str) -> { -> VARUSED(stream); -> -> /* display to the log file */ -> if (logfp != 0 && G_os_moremode) -> { -> os_fprintz(logfp, str); -> osfflush(logfp); -> } -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * initialize a generic output formatter state structure -> */ -> static void out_state_init(out_stream_info *stream) -> { -> /* start out at the first column */ -> stream->linepos = 0; -> stream->linecol = 0; -> stream->linebuf[0] = '\0'; -> -> /* set normal text attributes */ -> stream->cur_attr = 0; -> stream->os_attr = 0; -> -> /* start out at the first line */ -> stream->linecnt = 0; -> -> /* we're not in either "caps", "nocaps", or "allcaps" mode yet */ -> stream->capsflag = stream->nocapsflag = stream->allcapsflag = FALSE; -> -> /* we're not capturing yet */ -> stream->capturing = FALSE; -> stream->capture_obj = MCMONINV; -> -> /* we aren't previewing a line yet */ -> stream->preview = 0; -> -> /* we haven't flushed a new line yet */ -> stream->just_did_nl = FALSE; -> -> /* presume this stream does not use "MORE" mode */ -> stream->use_more_mode = FALSE; -> -> /* presume this stream uses formatter-level line wrapping */ -> stream->os_line_wrap = FALSE; -> -> /* assume that the underlying system is not HTML-enabled */ -> stream->html_target = FALSE; -> -> /* presume this target accepts OS highlighting sequences */ -> stream->plain_text_target = FALSE; -> -> /* start out in text mode */ -> stream->html_mode = FALSE; -> -> /* start out in "normal" lexical state */ -> stream->html_mode_flag = HTML_MODE_NORMAL; -> -> /* not in an ignored tag yet */ -> stream->html_in_ignore = FALSE; -> -> /* not in title mode yet */ -> stream->html_in_title = FALSE; -> -> /* not yet deferring line breaks */ -> stream->html_defer_br = HTML_DEFER_BR_NONE; -> -> /* not yet in quotes */ -> stream->html_quote_level = 0; -> -> /* not yet in a PRE block */ -> stream->html_pre_level = 0; -> -> /* not in an ALT tag yet */ -> stream->html_allow_alt = FALSE; -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * initialize a standard display stream -> */ -> static void out_init_std(out_stream_info *stream) -> { -> /* there's no user output filter function yet */ -> out_set_filter(MCMONINV); -> -> /* initialize the basic stream state */ -> out_state_init(stream); -> -> /* set up the low-level output routine */ -> G_std_disp.do_print = do_std_print; -> -> #ifdef USE_MORE -> /* -> * We're compiled for MORE mode, and we're not compiling for an -> * underlying HTML formatting layer, so use MORE mode for the -> * standard display stream. -> */ -> stream->use_more_mode = TRUE; -> #else -> /* -> * We're compiled for OS-layer (or HTML-layer) MORE handling. For -> * this case, use OS-layer (or HTML-layer) line wrapping as well. -> */ -> stream->os_line_wrap = TRUE; -> #endif -> -> #ifdef USE_HTML -> /* -> * if we're compiled for HTML mode, set the standard output stream -> * so that it knows it has an HTML target - this will ensure that -> * HTML tags are passed through to the underlying stream, and that -> * we generate HTML equivalents for our own control sequences -> */ -> stream->html_target = TRUE; -> #endif -> } -> -> /* -> * initialize a standard log file stream -> */ -> static void out_init_log(out_stream_info *stream) -> { -> /* initialize the basic stream state */ -> out_state_init(stream); -> -> /* set up the low-level output routine */ -> stream->do_print = do_log_print; -> -> /* use plain text in the log file stream */ -> stream->plain_text_target = TRUE; -> } -> -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * table of '&' character name sequences -> */ -> struct amp_tbl_t -> { -> /* entity name */ -> const char *cname; -> -> /* HTML Unicode character value */ -> uint html_cval; -> -> /* native character set expansion */ -> char *expan; -> }; -> -> /* -> * HTML entity mapping table. When we're in non-HTML mode, we keep our -> * own expansion table so that we can map HTML entity names into the -> * local character set. -> * -> * The entries in this table must be in sorted order (by HTML entity -> * name), because we use a binary search to find an entity name in the -> * table. -> */ -> static struct amp_tbl_t amp_tbl[] = -> { -> { "AElig", 198, 0 }, -> { "Aacute", 193, 0 }, -> { "Abreve", 258, 0 }, -> { "Acirc", 194, 0 }, -> { "Agrave", 192, 0 }, -> { "Alpha", 913, 0 }, -> { "Aogon", 260, 0 }, -> { "Aring", 197, 0 }, -> { "Atilde", 195, 0 }, -> { "Auml", 196, 0 }, -> { "Beta", 914, 0 }, -> { "Cacute", 262, 0 }, -> { "Ccaron", 268, 0 }, -> { "Ccedil", 199, 0 }, -> { "Chi", 935, 0 }, -> { "Dagger", 8225, 0 }, -> { "Dcaron", 270, 0 }, -> { "Delta", 916, 0 }, -> { "Dstrok", 272, 0 }, -> { "ETH", 208, 0 }, -> { "Eacute", 201, 0 }, -> { "Ecaron", 282, 0 }, -> { "Ecirc", 202, 0 }, -> { "Egrave", 200, 0 }, -> { "Eogon", 280, 0 }, -> { "Epsilon", 917, 0 }, -> { "Eta", 919, 0 }, -> { "Euml", 203, 0 }, -> { "Gamma", 915, 0 }, -> { "Iacute", 205, 0 }, -> { "Icirc", 206, 0 }, -> { "Igrave", 204, 0 }, -> { "Iota", 921, 0 }, -> { "Iuml", 207, 0 }, -> { "Kappa", 922, 0 }, -> { "Lacute", 313, 0 }, -> { "Lambda", 923, 0 }, -> { "Lcaron", 317, 0 }, -> { "Lstrok", 321, 0 }, -> { "Mu", 924, 0 }, -> { "Nacute", 323, 0 }, -> { "Ncaron", 327, 0 }, -> { "Ntilde", 209, 0 }, -> { "Nu", 925, 0 }, -> { "OElig", 338, 0 }, -> { "Oacute", 211, 0 }, -> { "Ocirc", 212, 0 }, -> { "Odblac", 336, 0 }, -> { "Ograve", 210, 0 }, -> { "Omega", 937, 0 }, -> { "Omicron", 927, 0 }, -> { "Oslash", 216, 0 }, -> { "Otilde", 213, 0 }, -> { "Ouml", 214, 0 }, -> { "Phi", 934, 0 }, -> { "Pi", 928, 0 }, -> { "Prime", 8243, 0 }, -> { "Psi", 936, 0 }, -> { "Racute", 340, 0 }, -> { "Rcaron", 344, 0 }, -> { "Rho", 929, 0 }, -> { "Sacute", 346, 0 }, -> { "Scaron", 352, 0 }, -> { "Scedil", 350, 0 }, -> { "Sigma", 931, 0 }, -> { "THORN", 222, 0 }, -> { "Tau", 932, 0 }, -> { "Tcaron", 356, 0 }, -> { "Tcedil", 354, 0 }, -> { "Theta", 920, 0 }, -> { "Uacute", 218, 0 }, -> { "Ucirc", 219, 0 }, -> { "Udblac", 368, 0 }, -> { "Ugrave", 217, 0 }, -> { "Upsilon", 933, 0 }, -> { "Uring", 366, 0 }, -> { "Uuml", 220, 0 }, -> { "Xi", 926, 0 }, -> { "Yacute", 221, 0 }, -> { "Yuml", 376, 0 }, -> { "Zacute", 377, 0 }, -> { "Zcaron", 381, 0 }, -> { "Zdot", 379, 0 }, -> { "Zeta", 918, 0 }, -> { "aacute", 225, 0 }, -> { "abreve", 259, 0 }, -> { "acirc", 226, 0 }, -> { "acute", 180, 0 }, -> { "aelig", 230, 0 }, -> { "agrave", 224, 0 }, -> { "alefsym", 8501, 0 }, -> { "alpha", 945, 0 }, -> { "amp", '&', 0 }, -> { "and", 8743, 0 }, -> { "ang", 8736, 0 }, -> { "aogon", 261, 0 }, -> { "aring", 229, 0 }, -> { "asymp", 8776, 0 }, -> { "atilde", 227, 0 }, -> { "auml", 228, 0 }, -> { "bdquo", 8222, 0 }, -> { "beta", 946, 0 }, -> { "breve", 728, 0 }, -> { "brvbar", 166, 0 }, -> { "bull", 8226, 0 }, -> { "cacute", 263, 0 }, -> { "cap", 8745, 0 }, -> { "caron", 711, 0 }, -> { "ccaron", 269, 0 }, -> { "ccedil", 231, 0 }, -> { "cedil", 184, 0 }, -> { "cent", 162, 0 }, -> { "chi", 967, 0 }, -> { "circ", 710, 0 }, -> { "clubs", 9827, 0 }, -> { "cong", 8773, 0 }, -> { "copy", 169, 0 }, -> { "crarr", 8629, 0 }, -> { "cup", 8746, 0 }, -> { "curren", 164, 0 }, -> { "dArr", 8659, 0 }, -> { "dagger", 8224, 0 }, -> { "darr", 8595, 0 }, -> { "dblac", 733, 0 }, -> { "dcaron", 271, 0 }, -> { "deg", 176, 0 }, -> { "delta", 948, 0 }, -> { "diams", 9830, 0 }, -> { "divide", 247, 0 }, -> { "dot", 729, 0 }, -> { "dstrok", 273, 0 }, -> { "eacute", 233, 0 }, -> { "ecaron", 283, 0 }, -> { "ecirc", 234, 0 }, -> { "egrave", 232, 0 }, -> { "emdash", 8212, 0 }, -> { "empty", 8709, 0 }, -> { "endash", 8211, 0 }, -> { "eogon", 281, 0 }, -> { "epsilon", 949, 0 }, -> { "equiv", 8801, 0 }, -> { "eta", 951, 0 }, -> { "eth", 240, 0 }, -> { "euml", 235, 0 }, -> { "exist", 8707, 0 }, -> { "fnof", 402, 0 }, -> { "forall", 8704, 0 }, -> { "frac12", 189, 0 }, -> { "frac14", 188, 0 }, -> { "frac34", 190, 0 }, -> { "frasl", 8260, 0 }, -> { "gamma", 947, 0 }, -> { "ge", 8805, 0 }, -> { "gt", '>', 0 }, -> { "hArr", 8660, 0 }, -> { "harr", 8596, 0 }, -> { "hearts", 9829, 0 }, -> { "hellip", 8230, 0 }, -> { "iacute", 237, 0 }, -> { "icirc", 238, 0 }, -> { "iexcl", 161, 0 }, -> { "igrave", 236, 0 }, -> { "image", 8465, 0 }, -> { "infin", 8734, 0 }, -> { "int", 8747, 0 }, -> { "iota", 953, 0 }, -> { "iquest", 191, 0 }, -> { "isin", 8712, 0 }, -> { "iuml", 239, 0 }, -> { "kappa", 954, 0 }, -> { "lArr", 8656, 0 }, -> { "lacute", 314, 0 }, -> { "lambda", 955, 0 }, -> { "lang", 9001, 0 }, -> { "laquo", 171, 0 }, -> { "larr", 8592, 0 }, -> { "lcaron", 318, 0 }, -> { "lceil", 8968, 0 }, -> { "ldq", 8220, 0 }, -> { "ldquo", 8220, 0 }, -> { "le", 8804, 0 }, -> { "lfloor", 8970, 0 }, -> { "lowast", 8727, 0 }, -> { "loz", 9674, 0 }, -> { "lsaquo", 8249, 0 }, -> { "lsq", 8216, 0 }, -> { "lsquo", 8216, 0 }, -> { "lstrok", 322, 0 }, -> { "lt", '<', 0 }, -> { "macr", 175, 0 }, -> { "mdash", 8212, 0 }, -> { "micro", 181, 0 }, -> { "middot", 183, 0 }, -> { "minus", 8722, 0 }, -> { "mu", 956, 0 }, -> { "nabla", 8711, 0 }, -> { "nacute", 324, 0 }, -> { "nbsp", QSPACE, 0 }, -> { "ncaron", 328, 0 }, -> { "ndash", 8211, 0 }, -> { "ne", 8800, 0 }, -> { "ni", 8715, 0 }, -> { "not", 172, 0 }, -> { "notin", 8713, 0 }, -> { "nsub", 8836, 0 }, -> { "ntilde", 241, 0 }, -> { "nu", 957, 0 }, -> { "oacute", 243, 0 }, -> { "ocirc", 244, 0 }, -> { "odblac", 337, 0 }, -> { "oelig", 339, 0 }, -> { "ogon", 731, 0 }, -> { "ograve", 242, 0 }, -> { "oline", 8254, 0 }, -> { "omega", 969, 0 }, -> { "omicron", 959, 0 }, -> { "oplus", 8853, 0 }, -> { "or", 8744, 0 }, -> { "ordf", 170, 0 }, -> { "ordm", 186, 0 }, -> { "oslash", 248, 0 }, -> { "otilde", 245, 0 }, -> { "otimes", 8855, 0 }, -> { "ouml", 246, 0 }, -> { "para", 182, 0 }, -> { "part", 8706, 0 }, -> { "permil", 8240, 0 }, -> { "perp", 8869, 0 }, -> { "phi", 966, 0 }, -> { "pi", 960, 0 }, -> { "piv", 982, 0 }, -> { "plusmn", 177, 0 }, -> { "pound", 163, 0 }, -> { "prime", 8242, 0 }, -> { "prod", 8719, 0 }, -> { "prop", 8733, 0 }, -> { "psi", 968, 0 }, -> { "quot", '"', 0 }, -> { "rArr", 8658, 0 }, -> { "racute", 341, 0 }, -> { "radic", 8730, 0 }, -> { "rang", 9002, 0 }, -> { "raquo", 187, 0 }, -> { "rarr", 8594, 0 }, -> { "rcaron", 345, 0 }, -> { "rceil", 8969, 0 }, -> { "rdq", 8221, 0 }, -> { "rdquo", 8221, 0 }, -> { "real", 8476, 0 }, -> { "reg", 174, 0 }, -> { "rfloor", 8971, 0 }, -> { "rho", 961, 0 }, -> { "rsaquo", 8250, 0 }, -> { "rsq", 8217, 0 }, -> { "rsquo", 8217, 0 }, -> { "sacute", 347, 0 }, -> { "sbquo", 8218, 0 }, -> { "scaron", 353, 0 }, -> { "scedil", 351, 0 }, -> { "sdot", 8901, 0 }, -> { "sect", 167, 0 }, -> { "shy", 173, 0 }, -> { "sigma", 963, 0 }, -> { "sigmaf", 962, 0 }, -> { "sim", 8764, 0 }, -> { "spades", 9824, 0 }, -> { "sub", 8834, 0 }, -> { "sube", 8838, 0 }, -> { "sum", 8721, 0 }, -> { "sup", 8835, 0 }, -> { "sup1", 185, 0 }, -> { "sup2", 178, 0 }, -> { "sup3", 179, 0 }, -> { "supe", 8839, 0 }, -> { "szlig", 223, 0 }, -> { "tau", 964, 0 }, -> { "tcaron", 357, 0 }, -> { "tcedil", 355, 0 }, -> { "there4", 8756, 0 }, -> { "theta", 952, 0 }, -> { "thetasym", 977, 0 }, -> { "thorn", 254, 0 }, -> { "thorn", 254, 0 }, -> { "tilde", 732, 0 }, -> { "times", 215, 0 }, -> { "trade", 8482, 0 }, -> { "uArr", 8657, 0 }, -> { "uacute", 250, 0 }, -> { "uarr", 8593, 0 }, -> { "ucirc", 251, 0 }, -> { "udblac", 369, 0 }, -> { "ugrave", 249, 0 }, -> { "uml", 168, 0 }, -> { "upsih", 978, 0 }, -> { "upsilon", 965, 0 }, -> { "uring", 367, 0 }, -> { "uuml", 252, 0 }, -> { "weierp", 8472, 0 }, -> { "xi", 958, 0 }, -> { "yacute", 253, 0 }, -> { "yen", 165, 0 }, -> { "yuml", 255, 0 }, -> { "zacute", 378, 0 }, -> { "zcaron", 382, 0 }, -> { "zdot", 380, 0 }, -> { "zeta", 950, 0 } -> }; -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * turn on CAPS mode for a stream -> */ -> static void outcaps_stream(out_stream_info *stream) -> { -> /* turn on CAPS mode */ -> stream->capsflag = TRUE; -> -> /* turn off NOCAPS and ALLCAPS mode */ -> stream->nocapsflag = FALSE; -> stream->allcapsflag = FALSE; -> } -> -> /* -> * turn on NOCAPS mode for a stream -> */ -> static void outnocaps_stream(out_stream_info *stream) -> { -> /* turn on NOCAPS mode */ -> stream->nocapsflag = TRUE; -> -> /* turn off CAPS and ALLCAPS mode */ -> stream->capsflag = FALSE; -> stream->allcapsflag = FALSE; -> } -> -> /* -> * turn on or off ALLCAPS mode for a stream -> */ -> static void outallcaps_stream(out_stream_info *stream, int all_caps) -> { -> /* set the ALLCAPS flag */ -> stream->allcapsflag = all_caps; -> -> /* clear the CAPS and NOCAPS flags */ -> stream->capsflag = FALSE; -> stream->nocapsflag = FALSE; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * write a string to a stream -> */ -> static void stream_print(out_stream_info *stream, char *str) -> { -> /* call the stream's do_print method */ -> (*stream->do_print)(stream, str); -> } -> -> /* -> * Write out a line -> */ -> static void t_outline(out_stream_info *stream, int nl, -> const char *txt, const int *attr) -> { -> extern int scrquiet; -> -> /* -> * Check the "script quiet" mode - this indicates that we're reading -> * a script and not echoing output to the display. If this mode is -> * on, and we're writing to the display, suppress this write. If -> * the mode is off, or we're writing to another stream (such as the -> * log file), show the output as normal. -> */ -> if (!scrquiet || stream != &G_std_disp) -> { -> size_t i; -> char buf[MAXWIDTH]; -> char *dst; -> -> /* -> * Check to see if we've reached the end of the screen, and if -> * so run the MORE prompt. Note that we don't make this check -> * at all if USE_MORE is undefined, since this means that the OS -> * layer code is taking responsibility for pagination issues. -> * We also don't display a MORE prompt when reading from a -> * script file. -> * -> * Note that we suppress the MORE prompt if nl == 0, since this -> * is used to flush a partial line of text without starting a -> * new line (for example, when displaying a prompt where the -> * input will appear on the same line following the prompt). -> * -> * Skip the MORE prompt if this stream doesn't use it. -> */ -> if (stream->use_more_mode -> && scrfp == 0 -> && G_os_moremode -> && nl != 0 && nl != 4 -> && stream->linecnt++ >= G_os_pagelength) -> { -> /* display the MORE prompt */ -> out_more_prompt(); -> } -> -> /* -> * Display the text. Run through the text in pieces; each time the -> * attributes change, set attributes at the osifc level. -> */ -> for (i = 0, dst = buf ; txt[i] != '\0' ; ++i) -> { -> /* if the attribute is changing, notify osifc */ -> if (attr != 0 && attr[i] != stream->os_attr) -> { -> /* flush the preceding text */ -> if (dst != buf) -> { -> *dst = '\0'; -> stream_print(stream, buf); -> } -> -> /* set the new attribute */ -> os_set_text_attr(attr[i]); -> -> /* remember this as the last OS attribute */ -> stream->os_attr = attr[i]; -> -> /* start with a fresh buffer */ -> dst = buf; -> } -> -> /* buffer this character */ -> *dst++ = txt[i]; -> } -> -> /* flush the last chunk of text */ -> if (dst != buf) -> { -> *dst = '\0'; -> stream_print(stream, buf); -> } -> } -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Flush the current line to the display. The 'nl' argument specifies -> * what kind of flushing to do: -> * -> * 0: flush the current line but do not start a new line; more text will -> * follow on the current line. This is used, for example, to flush text -> * after displaying a prompt and before waiting for user input. -> * -> * 1: flush the line and start a new line. -> * -> * 2: flush the line as though starting a new line, but don't add an -> * actual newline character to the output, since the underlying OS -> * display code will handle this. Instead, add a space after the line. -> * (This differs from mode 0 in that mode 0 shouldn't add anything at -> * all after the line.) -> * -> * 3: "preview" mode. Flush the line, but do not start a new line, and -> * retain the current text in the buffer. This is used for systems that -> * handle the line wrapping in the underlying system code to flush a -> * partially filled line that will need to be flushed again later. -> * -> * 4: same as mode 0, but used for internal buffer flushes only. Do not -> * involve the underlying OS layer in this type of flush - simply flush -> * our buffers with no separation. -> */ -> -> /* flush a given output stream */ -> static void outflushn_stream(out_stream_info *stream, int nl) -> { -> int i; -> -> /* null-terminate the current output line buffer */ -> stream->linebuf[stream->linepos] = '\0'; -> -> /* note the position of the last character to display */ -> i = stream->linepos - 1; -> -> /* if we're adding anything, remove trailing spaces */ -> if (nl != 0 && nl != 4) -> { -> /* look for last non-space character */ -> for ( ; i >= 0 && outissp(stream->linebuf[i]) ; --i) ; -> } -> -> /* check the output mode */ -> if (nl == 3) -> { -> /* -> * this is the special "preview" mode -- only display the part -> * that we haven't already previewed for this same line -> */ -> if (i + 1 > stream->preview) -> { -> /* write out the line */ -> t_outline(stream, 0, &stream->linebuf[stream->preview], -> &stream->attrbuf[stream->preview]); -> -> /* skip past the part we wrote */ -> stream->preview += strlen(&stream->linebuf[stream->preview]); -> } -> } -> else -> { -> char *suffix; /* extra text to add after the flushed text */ -> int countnl = 0; /* true if line counts for [more] paging */ -> -> /* null-terminate the buffer at the current position */ -> stream->linebuf[++i] = '\0'; -> -> /* check the mode */ -> switch(nl) -> { -> case 0: -> case 3: -> case 4: -> /* no newline - just flush out what we have with no suffix */ -> suffix = 0; -> break; -> -> case 1: -> /* -> * Add a newline. If there's nothing in the current line, -> * or we just wrote out a newline, do not add an extra -> * newline. Keep all newlines in PRE mode. -> */ -> if (stream->linecol != 0 || !stream->just_did_nl -> || stream->html_pre_level != 0) -> { -> /* add a newline after the text */ -> suffix = "\n"; -> -> /* count the line in the page size */ -> countnl = 1; -> } -> else -> { -> /* don't add a newline */ -> suffix = 0; -> } -> break; -> -> case 2: -> /* -> * we're going to depend on the underlying OS output layer -> * to do line breaking, so don't add a newline, but do add a -> * space, so that the underlying OS layer knows we have a -> * word break here -> */ -> suffix = " "; -> break; -> } -> -> /* -> * display the line, as long as we have something buffered to -> * display; even if we don't, display it if our column is -> * non-zero and we didn't just do a newline, since this must -> * mean that we've flushed a partial line and are just now doing -> * the newline -> */ -> if (stream->linebuf[stream->preview] != '\0' -> || (stream->linecol != 0 && !stream->just_did_nl) -> || stream->html_pre_level > 0) -> { -> /* write it out */ -> t_outline(stream, countnl, &stream->linebuf[stream->preview], -> &stream->attrbuf[stream->preview]); -> -> /* write the suffix, if any */ -> if (suffix != 0) -> t_outline(stream, 0, suffix, 0); -> } -> -> /* generate an HTML line break if necessary */ -> if (nl == 1 && stream->html_mode && stream->html_target) -> t_outline(stream, 0, "
", 0); -> -> if (nl == 0) -> { -> /* we're not displaying a newline, so flush what we have */ -> os_flush(); -> } -> else -> { -> /* we displayed a newline, so reset the column position */ -> stream->linecol = 0; -> } -> -> /* reset the line output buffer position */ -> stream->linepos = stream->preview = 0; -> -> /* -> * If we just output a newline, note it. If we didn't just -> * output a newline, but we did write out anything else, note -> * that we're no longer at the start of a line on the underlying -> * output device. -> */ -> if (nl == 1) -> stream->just_did_nl = TRUE; -> else if (stream->linebuf[stream->preview] != '\0') -> stream->just_did_nl = FALSE; -> } -> -> /* -> * If the osifc-level attributes don't match the current attributes, -> * bring the osifc layer up to date. This is necessary in cases where -> * we set attributes immediately before asking for input - we -> * essentially need to flush the attributes without flushing any text. -> */ -> if (stream->cur_attr != stream->os_attr) -> { -> /* set the osifc attributes */ -> os_set_text_attr(stream->cur_attr); -> -> /* remember the new attributes as the current osifc attributes */ -> stream->os_attr = stream->cur_attr; -> } -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Determine if we're showing output. Returns true if output should be -> * displayed, false if it should be suppressed. We'll note the output -> * for hidden display accounting as needed. -> */ -> static int out_is_hidden() -> { -> /* check the output flag */ -> if (!outflag) -> { -> /* trace the hidden output if desired */ -> if (dbghid && !hidout) -> trchid(); -> -> /* note the hidden output */ -> hidout = 1; -> -> /* -> * unless we're showing hidden text in the debugger, we're -> * suppressing output, so return true -> */ -> if (!dbghid) -> return TRUE; -> } -> -> /* we're not suppressing output */ -> return FALSE; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Display a blank line to the given stream -> */ -> static void outblank_stream(out_stream_info *stream) -> { -> /* flush the stream */ -> outflushn_stream(stream, 1); -> -> /* if generating for an HTML display target, add an HTML line break */ -> if (stream->html_mode && stream->html_target) -> outstring_stream(stream, "
"); -> -> /* write out the newline */ -> t_outline(stream, 1, "\n", 0); -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Generate a tab for a "\t" sequence in the game text. -> * -> * Standard (non-HTML) version: we'll generate enough spaces to take us -> * to the next tab stop. -> * -> * HTML version: if we're in native HTML mode, we'll just generate a -> * ; if we're not in HTML mode, we'll generate a hard -> * tab character, which the HTML formatter will interpret as a * MULTIPLE=4>. -> */ -> static void outtab_stream(out_stream_info *stream) -> { -> /* check to see what the underlying system is expecting */ -> if (stream->html_target) -> { -> /* the underlying system is HTML - check for HTML mode */ -> if (stream->html_mode) -> { -> /* we're in HTML mode, so use the HTML tag */ -> outstring_stream(stream, ""); -> } -> else -> { -> /* we're not in HTML mode, so generate a hard tab character */ -> outchar_noxlat_stream(stream, QTAB); -> } -> } -> else -> { -> int maxcol; -> -> /* -> * We're not in HTML mode - expand the tab with spaces. Figure -> * the maximum column: if we're doing our own line wrapping, never -> * go beyond the actual display width. -> */ -> maxcol = (stream->os_line_wrap ? OS_MAXWIDTH : G_os_linewidth); -> -> /* add the spaces */ -> do -> { -> stream->attrbuf[stream->linepos] = stream->cur_attr; -> stream->linebuf[stream->linepos++] = ' '; -> ++(stream->linecol); -> } while (((stream->linecol + 1) & 3) != 0 -> && stream->linecol < maxcol); -> } -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Flush a line -> */ -> static void out_flushline(out_stream_info *stream, int padding) -> { -> /* -> * check to see if we're using the underlying display layer's line -> * wrapping -> */ -> if (stream->os_line_wrap) -> { -> /* -> * In the HTML version, we don't need the normal *MORE* -> * processing, since the HTML layer will handle that. -> * Furthermore, we don't need to provide actual newline breaks -> * -- that happens after the HTML is parsed, so we don't have -> * enough information here to figure out actual line breaks. -> * So, we'll just flush out our buffer whenever it fills up, and -> * suppress newlines. -> * -> * Similarly, if we have OS-level MORE processing, don't try to -> * figure out where the line breaks go -- just flush our buffer -> * without a trailing newline whenever the buffer is full, and -> * let the OS layer worry about formatting lines and paragraphs. -> * -> * If we're using padding, use mode 2. If we don't want padding -> * (which is the case if we completely fill up the buffer -> * without finding any word breaks), write out in mode 0, which -> * just flushes the buffer exactly like it is. -> */ -> outflushn_stream(stream, padding ? 2 : 4); -> } -> else -> { -> /* -> * Normal mode - we process the *MORE* prompt ourselves, and we -> * are responsible for figuring out where the actual line breaks -> * go. Use outflush() to generate an actual newline whenever we -> * flush out our buffer. -> */ -> outflushn_stream(stream, 1); -> } -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Write a character to an output stream without translation -> */ -> static void outchar_noxlat_stream(out_stream_info *stream, char c) -> { -> int i; -> int qspace; -> -> /* check for the special quoted space character */ -> if (c == QSPACE) -> { -> /* it's a quoted space - note it and convert it to a regular space */ -> qspace = 1; -> c = ' '; -> } -> else if (c == QTAB) -> { -> /* it's a hard tab - convert it to an ordinary tab */ -> c = '\t'; -> qspace = 0; -> } -> else -> { -> /* translate any whitespace character to a regular space character */ -> if (outissp(c)) -> c = ' '; -> -> /* it's not a quoted space */ -> qspace = 0; -> } -> -> /* check for the caps/nocaps flags */ -> if ((stream->capsflag || stream->allcapsflag) && outisal(c)) -> { -> /* capsflag is set, so capitalize this character */ -> if (outislo(c)) -> c = toupper(c); -> -> /* okay, we've capitalized something; clear flag */ -> stream->capsflag = 0; -> } -> else if (stream->nocapsflag && outisal(c)) -> { -> /* nocapsflag is set, so minisculize this character */ -> if (outisup(c)) -> c = tolower(c); -> -> /* clear the flag now that we've done the job */ -> stream->nocapsflag = 0; -> } -> -> /* if in capture mode, simply capture the character */ -> if (stream->capturing) -> { -> uchar *p; -> -> /* if we have a valid capture object, copy to it */ -> if (stream->capture_obj != MCMONINV) -> { -> /* lock the object holding the captured text */ -> p = mcmlck(stream->capture_ctx, stream->capture_obj); -> -> /* make sure the capture object is big enough */ -> if (mcmobjsiz(stream->capture_ctx, stream->capture_obj) -> <= stream->capture_ofs) -> { -> /* expand the object by another 256 bytes */ -> p = mcmrealo(stream->capture_ctx, stream->capture_obj, -> (ushort)(stream->capture_ofs + 256)); -> } -> -> /* add this character */ -> *(p + stream->capture_ofs++) = c; -> -> /* unlock the capture object */ -> mcmtch(stream->capture_ctx, stream->capture_obj); -> mcmunlck(stream->capture_ctx, stream->capture_obj); -> } -> -> /* -> * we're done - we don't want to actually display the character -> * while capturing -> */ -> return; -> } -> -> /* add the character to out output buffer, flushing as needed */ -> if (stream->linecol + 1 < G_os_linewidth) -> { -> /* -> * there's room for this character, so add it to the buffer -> */ -> -> /* ignore non-quoted space at start of line outside of PRE */ -> if (outissp(c) && c != '\t' && stream->linecol == 0 && !qspace -> && stream->html_pre_level == 0) -> return; -> -> /* is this a non-quoted space not at the start of the line? */ -> if (outissp(c) && c != '\t' && stream->linecol != 0 && !qspace -> && stream->html_pre_level == 0) -> { -> int pos1 = stream->linepos - 1; -> char p = stream->linebuf[pos1]; /* check previous character */ -> -> /* ignore repeated spaces - collapse into a single space */ -> if (outissp(p)) -> return; -> -> /* -> * Certain punctuation requires a double space: a period, a -> * question mark, an exclamation mark, or a colon; or any of -> * these characters followed by any number of single and/or -> * double quotes. First, scan back to before any quotes, if -> * are on one now, then check the preceding character; if -> * it's one of the punctuation marks requiring a double -> * space, add this space a second time. (In addition to -> * scanning back past quotes, scan past parentheses, -> * brackets, and braces.) Don't double the spacing if we're -> * not in the normal doublespace mode; some people may -> * prefer single spacing after punctuation, so we make this -> * a run-time option. -> */ -> if (doublespace) -> { -> /* find the previous relevant punctuation character */ -> while (pos1 && -> (p == '"' || p == '\'' || p == ')' || p == ']' -> || p == '}')) -> { -> p = stream->linebuf[--pos1]; -> } -> if ( p == '.' || p == '?' || p == '!' || p == ':' ) -> { -> /* a double-space is required after this character */ -> stream->attrbuf[stream->linepos] = stream->cur_attr; -> stream->linebuf[stream->linepos++] = c; -> ++(stream->linecol); -> } -> } -> } -> -> /* add this character to the buffer */ -> stream->attrbuf[stream->linepos] = stream->cur_attr; -> stream->linebuf[stream->linepos++] = c; -> -> /* advance the output column position */ -> ++(stream->linecol); -> return; -> } -> -> /* -> * The line would overflow if this character were added. Find the -> * most recent word break, and output the line up to the previous -> * word. Note that if we're trying to output a space, we'll just -> * add it to the line buffer. If the last character of the line -> * buffer is already a space, we won't do anything right now. -> */ -> if (outissp(c) && c != '\t' && !qspace) -> { -> /* this is a space, so we're at a word break */ -> if (stream->linebuf[stream->linepos - 1] != ' ') -> { -> stream->attrbuf[stream->linepos] = stream->cur_attr; -> stream->linebuf[stream->linepos++] = ' '; -> } -> return; -> } -> -> /* -> * Find the most recent word break: look for a space or dash, starting -> * at the end of the line. -> * -> * If we're about to write a hyphen, we want to skip all contiguous -> * hyphens, because we want to keep them together as a single -> * punctuation mark; then keep going in the normal manner, which will -> * keep the hyphens plus the word they're attached to together as a -> * single unit. If spaces precede the sequence of hyphens, include -> * the prior word as well. -> */ -> i = stream->linepos - 1; -> if (c == '-') -> { -> /* skip any contiguous hyphens at the end of the line */ -> for ( ; i >= 0 && stream->linebuf[i] == '-' ; --i) ; -> -> /* skip any spaces preceding the sequence of hyphens */ -> for ( ; i >= 0 && outissp(stream->linebuf[i]) ; --i) ; -> } -> -> /* -> * Now find the preceding space. If we're doing our own wrapping -> * (i.e., we're not using OS line wrapping), then look for the -> * nearest hyphen as well. -> */ -> for ( ; i >= 0 && !outissp(stream->linebuf[i]) -> && !(!stream->os_line_wrap && stream->linebuf[i] == '-') ; --i) ; -> -> /* check to see if we found a good place to break */ -> if (i < 0) -> { -> /* -> * we didn't find any good place to break - flush the entire -> * line as-is, breaking arbitrarily in the middle of a word -> */ -> out_flushline(stream, FALSE); -> -> /* -> * we've completely cleared out the line buffer, so reset all of -> * the line buffer counters -> */ -> stream->linepos = 0; -> stream->linecol = 0; -> stream->linebuf[0] = '\0'; -> } -> else -> { -> char brkchar; -> char tmpbuf[MAXWIDTH]; -> int tmpattr[MAXWIDTH]; -> size_t tmpcnt; -> -> /* remember the word-break character */ -> brkchar = stream->linebuf[i]; -> -> /* null-terminate the line buffer */ -> stream->linebuf[stream->linepos] = '\0'; -> -> /* the next line starts after the break - save a copy */ -> tmpcnt = strlen(&stream->linebuf[i+1]); -> memcpy(tmpbuf, &stream->linebuf[i+1], tmpcnt + 1); -> memcpy(tmpattr, &stream->attrbuf[i+1], tmpcnt * sizeof(tmpattr[0])); -> -> /* -> * terminate the buffer at the space or after the hyphen, -> * depending on where we broke -> */ -> if (outissp(brkchar)) -> stream->linebuf[i] = '\0'; -> else -> stream->linebuf[i+1] = '\0'; -> -> /* write out everything up to the word break */ -> out_flushline(stream, TRUE); -> -> /* copy the next line into line buffer */ -> memcpy(stream->linebuf, tmpbuf, tmpcnt + 1); -> memcpy(stream->attrbuf, tmpattr, tmpcnt * sizeof(tmpattr[0])); -> stream->linepos = tmpcnt; -> -> /* -> * figure what column we're now in - count all of the printable -> * characters in the new line -> */ -> for (stream->linecol = 0, i = 0 ; i < stream->linepos ; ++i) -> { -> /* if it's printable, count it */ -> if (((unsigned char)stream->linebuf[i]) >= 26) -> ++(stream->linecol); -> } -> } -> -> /* add the new character to buffer */ -> stream->attrbuf[stream->linepos] = stream->cur_attr; -> stream->linebuf[stream->linepos++] = c; -> -> /* advance the column counter */ -> ++(stream->linecol); -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Write out a character, translating to the local system character set -> * from the game's internal character set. -> */ -> static void outchar_stream(out_stream_info *stream, char c) -> { -> outchar_noxlat_stream(stream, cmap_i2n(c)); -> } -> -> /* -> * write out a string, translating to the local system character set -> */ -> static void outstring_stream(out_stream_info *stream, char *s) -> { -> /* write out each character in the string */ -> for ( ; *s ; ++s) -> outchar_stream(stream, *s); -> } -> -> /* -> * write out a string without translation -> */ -> static void outstring_noxlat_stream(out_stream_info *stream, char *s) -> { -> for ( ; *s ; ++s) -> outchar_noxlat_stream(stream, *s); -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Write out an HTML character value, translating to the local character -> * set. -> */ -> static void outchar_html_stream(out_stream_info *stream, -> unsigned int htmlchar) -> { -> struct amp_tbl_t *ampptr; -> -> /* -> * search for a mapping entry for this entity, in case it's defined -> * in an external mapping file -> */ -> for (ampptr = amp_tbl ; -> ampptr < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++ampptr) -> { -> /* if this is the one, stop looking */ -> if (ampptr->html_cval == htmlchar) -> break; -> } -> -> /* -> * If we found a mapping table entry, and the entry has an expansion -> * from the external character mapping table file, use the external -> * expansion; otherwise, use the default expansion. -> */ -> if (ampptr >= amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) -> || ampptr->expan == 0) -> { -> char xlat_buf[50]; -> -> /* -> * there's no external mapping table file expansion -- use the -> * default OS mapping routine -> */ -> os_xlat_html4(htmlchar, xlat_buf, sizeof(xlat_buf)); -> outstring_noxlat_stream(stream, xlat_buf); -> } -> else -> { -> /* -> * use the explicit mapping from the mapping table file -> */ -> outstring_noxlat_stream(stream, ampptr->expan); -> } -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Enter a recursion level. Returns TRUE if the caller should proceed -> * with the operation, FALSE if not. -> * -> * If we're making a recursive call, thereby re-entering the formatter, -> * and this stream is not the same as the enclosing stream, we want to -> * ignore this call and suppress any output to this stream, so we'll -> * return FALSE. -> */ -> static int out_push_stream(out_stream_info *stream) -> { -> /* -> * if we're already in the formatter, and the new stream doesn't -> * match the enclosing recursion level's stream, tell the caller to -> * abort the operation -> */ -> if (G_recurse != 0 && G_cur_stream != stream) -> return FALSE; -> -> /* note the active stream */ -> G_cur_stream = stream; -> -> /* count the entry */ -> ++G_recurse; -> -> /* tell the caller to proceed */ -> return TRUE; -> } -> -> /* -> * Leave a recursion level -> */ -> static void out_pop_stream() -> { -> /* count the exit */ -> --G_recurse; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * nextout() returns the next character in a string, and updates the -> * string pointer and remaining length. Returns zero if no more -> * characters are available in the string. -> */ -> /* static char nextout(char **s, uint *len); */ -> #define nextout(s, len) ((char)(*(len) == 0 ? 0 : (--(*(len)), *((*(s))++)))) -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Get the next character, writing the previous character to the given -> * output stream if it's not null. -> */ -> static char nextout_copy(char **s, size_t *slen, -> char prv, out_stream_info *stream) -> { -> /* if there's a stream, write the previous character to the stream */ -> if (stream != 0) -> outchar_stream(stream, prv); -> -> /* return the next character */ -> return nextout(s, slen); -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Read an HTML tag, for our primitive mini-parser. If 'stream' is not -> * null, we'll copy each character we read to the output stream. Returns -> * the next character after the tag name. -> */ -> static char read_tag(char *dst, size_t dstlen, int *is_end_tag, -> char **s, size_t *slen, out_stream_info *stream) -> { -> char c; -> -> /* skip the opening '<' */ -> c = nextout_copy(s, slen, '<', stream); -> -> /* skip spaces */ -> while (outissp(c)) -> c = nextout_copy(s, slen, c, stream); -> -> /* note if this is a closing tag */ -> if (c == '/' || c == '\\') -> { -> /* it's an end tag - note it and skip the slash */ -> *is_end_tag = TRUE; -> c = nextout_copy(s, slen, c, stream); -> -> /* skip yet more spaces */ -> while (outissp(c)) -> c = nextout_copy(s, slen, c, stream); -> } -> else -> *is_end_tag = FALSE; -> -> /* -> * find the end of the tag name - the tag continues to the next space, -> * '>', or end of line -> */ -> for ( ; c != '\0' && !outissp(c) && c != '>' ; -> c = nextout_copy(s, slen, c, stream)) -> { -> /* add this to the tag buffer if it fits */ -> if (dstlen > 1) -> { -> *dst++ = c; -> --dstlen; -> } -> } -> -> /* null-terminate the tag name */ -> if (dstlen > 0) -> *dst = '\0'; -> -> /* return the next character */ -> return c; -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * display a string of a given length to a given stream -> */ -> static int outformatlen_stream(out_stream_info *stream, -> char *s, size_t slen) -> { -> char c; -> int done = 0; -> char fmsbuf[40]; /* space for constructing translation string */ -> uint fmslen; -> char *f = 0; -> char *f1; -> int infmt = 0; -> -> /* -> * This routine can recurse because of format strings ("%xxx%" -> * sequences). When we recurse, we want to ensure that the -> * recursion is directed to the original stream only. So, note the -> * current stream statically in case we re-enter the formatter. -> */ -> if (!out_push_stream(stream)) -> return 0; -> -> /* get the first character */ -> c = nextout(&s, &slen); -> -> /* if we have anything to show, show it */ -> while (c != '\0') -> { -> /* check if we're collecting translation string */ -> if (infmt) -> { -> /* -> * if the string is too long for our buffer, or we've come -> * across a backslash (illegal in a format string), or we've -> * come across an HTML-significant character ('&' or '<') in -> * HTML mode, we must have a stray percent sign; dump the -> * whole string so far and act as though we have no format -> * string -> */ -> if (c == '\\' -> || f == &fmsbuf[sizeof(fmsbuf)] -> || (stream->html_mode && (c == '<' || c == '&'))) -> { -> outchar_stream(stream, '%'); -> for (f1 = fmsbuf ; f1 < f ; ++f1) -> outchar_stream(stream, *f1); -> infmt = 0; -> -> /* process this character again */ -> continue; -> } -> else if (c == '%' && f == fmsbuf) /* double percent sign? */ -> { -> outchar_stream(stream, '%'); /* send out a single '%' */ -> infmt = 0; /* no longer processing translation string */ -> } -> else if (c == '%') /* found end of string? translate it if so */ -> { -> uchar *fms; -> int initcap = FALSE; -> int allcaps = FALSE; -> char fmsbuf_srch[sizeof(fmsbuf)]; -> -> /* null-terminate the string */ -> *f = '\0'; -> -> /* check for an init cap */ -> if (outisup(fmsbuf[0])) -> { -> /* -> * note the initial capital, so that we follow the -> * original capitalization in the substituted string -> */ -> initcap = TRUE; -> -> /* -> * if the second letter is capitalized as well, -> * capitalize the entire substituted string -> */ -> if (fmsbuf[1] != '\0' && outisup(fmsbuf[1])) -> { -> /* use all caps */ -> allcaps = TRUE; -> } -> } -> -> /* convert the entire string to lower case for searching */ -> strcpy(fmsbuf_srch, fmsbuf); -> os_strlwr(fmsbuf_srch); -> -> /* find the string in the format string table */ -> fmslen = strlen(fmsbuf_srch); -> for (fms = fmsbase ; fms < fmstop ; ) -> { -> uint propnum; -> uint len; -> -> /* get the information on this entry */ -> propnum = osrp2(fms); -> len = osrp2(fms + 2) - 2; -> -> /* check for a match */ -> if (len == fmslen && -> !memcmp(fms + 4, fmsbuf_srch, (size_t)len)) -> { -> int old_all_caps; -> -> /* note the current ALLCAPS mode */ -> old_all_caps = stream->allcapsflag; -> -> /* -> * we have a match - set the appropriate -> * capitalization mode -> */ -> if (allcaps) -> outallcaps_stream(stream, TRUE); -> else if (initcap) -> outcaps_stream(stream); -> -> /* -> * evaluate the associated property to generate -> * the substitution text -> */ -> runppr(runctx, cmdActor, (prpnum)propnum, 0); -> -> /* turn off ALLCAPS mode */ -> outallcaps_stream(stream, old_all_caps); -> -> /* no need to look any further */ -> break; -> } -> -> /* move on to next formatstring if not yet found */ -> fms += len + 4; -> } -> -> /* if we can't find it, dump the format string as-is */ -> if (fms == fmstop) -> { -> outchar_stream(stream, '%'); -> for (f1 = fmsbuf ; f1 < f ; ++f1) -> outchar_stream(stream, *f1); -> outchar_stream(stream, '%'); -> } -> -> /* no longer reading format string */ -> infmt = 0; -> } -> else -> { -> /* copy this character of the format string */ -> *f++ = c; -> } -> -> /* move on to the next character and continue scanning */ -> c = nextout(&s, &slen); -> continue; -> } -> -> /* -> * If we're parsing HTML here, and we're inside a tag, skip -> * characters until we reach the end of the tag. -> */ -> if (stream->html_mode_flag != HTML_MODE_NORMAL) -> { -> switch(stream->html_mode_flag) -> { -> case HTML_MODE_TAG: -> /* -> * keep skipping up to the closing '>', but note when we -> * enter any quoted section -> */ -> switch(c) -> { -> case '>': -> /* we've reached the end of the tag */ -> stream->html_mode_flag = HTML_MODE_NORMAL; -> -> /* if we have a deferred
, process it now */ -> switch(stream->html_defer_br) -> { -> case HTML_DEFER_BR_NONE: -> /* no deferred
*/ -> break; -> -> case HTML_DEFER_BR_FLUSH: -> outflushn_stream(stream, 1); -> break; -> -> case HTML_DEFER_BR_BLANK: -> outblank_stream(stream); -> break; -> } -> -> /* no more deferred
pending */ -> stream->html_defer_br = HTML_DEFER_BR_NONE; -> -> /* no more ALT attribute allowed */ -> stream->html_allow_alt = FALSE; -> break; -> -> case '"': -> /* enter a double-quoted string */ -> stream->html_mode_flag = HTML_MODE_DQUOTE; -> break; -> -> case '\'': -> /* enter a single-quoted string */ -> stream->html_mode_flag = HTML_MODE_SQUOTE; -> break; -> -> default: -> /* if it's alphabetic, note the attribute name */ -> if (outisal(c)) -> { -> char attrname[128]; -> char attrval[256]; -> char *dst; -> -> /* gather up the attribute name */ -> for (dst = attrname ; -> dst + 1 < attrname + sizeof(attrname) ; ) -> { -> /* store this character */ -> *dst++ = c; -> -> /* get the next character */ -> c = nextout(&s, &slen); -> -> /* if it's not alphanumeric, stop scanning */ -> if (!outisal(c) && !outisdg(c)) -> break; -> } -> -> /* null-terminate the result */ -> *dst++ = '\0'; -> -> /* gather the value if present */ -> if (c == '=') -> { -> char qu; -> -> /* skip the '=' */ -> c = nextout(&s, &slen); -> -> /* if we have a quote, so note */ -> if (c == '"' || c == '\'') -> { -> /* remember the quote */ -> qu = c; -> -> /* skip it */ -> c = nextout(&s, &slen); -> } -> else -> { -> /* no quote */ -> qu = 0; -> } -> -> /* read the value */ -> for (dst = attrval ; -> dst + 1 < attrval + sizeof(attrval) ; ) -> { -> /* store this character */ -> *dst++ = c; -> -> /* read the next one */ -> c = nextout(&s, &slen); -> if (c == '\0') -> { -> /* -> * we've reached the end of the -> * string, and we're still inside -> * this attribute - abandon the -> * attribute but note that we're -> * inside a quoted string if -> * necessary -> */ -> if (qu == '"') -> stream->html_mode_flag = -> HTML_MODE_DQUOTE; -> else if (qu == '\'') -> stream->html_mode_flag = -> HTML_MODE_SQUOTE; -> else -> stream->html_mode_flag -> = HTML_MODE_TAG; -> -> /* stop scanning the string */ -> break; -> } -> -> /* -> * if we're looking for a quote, check -> * for the closing quote; otherwise, -> * check for alphanumerics -> */ -> if (qu != 0) -> { -> /* if this is our quote, stop scanning */ -> if (c == qu) -> break; -> } -> else -> { -> /* if it's non-alphanumeric, we're done */ -> if (!outisal(c) && !outisdg(c)) -> break; -> } -> } -> -> /* skip the closing quote, if necessary */ -> if (qu != 0 && c == qu) -> c = nextout(&s, &slen); -> -> /* null-terminate the value string */ -> *dst = '\0'; -> } -> else -> { -> /* no value */ -> attrval[0] = '\0'; -> } -> -> /* -> * see if we recognize it, and it's meaningful -> * in the context of the current tag -> */ -> if (!stricmp(attrname, "height") -> && stream->html_defer_br != HTML_DEFER_BR_NONE) -> { -> int ht; -> -> /* -> * If the height is zero, always treat this -> * as a non-blanking flush. If it's one, -> * treat it as we originally planned to. If -> * it's greater than one, add n blank lines. -> */ -> ht = atoi(attrval); -> if (ht == 0) -> { -> /* always use non-blanking flush */ -> stream->html_defer_br = HTML_DEFER_BR_FLUSH; -> } -> else if (ht == 1) -> { -> /* keep original setting */ -> } -> else -> { -> for ( ; ht > 0 ; --ht) -> outblank_stream(stream); -> } -> } -> else if (!stricmp(attrname, "alt") -> && !stream->html_in_ignore -> && stream->html_allow_alt) -> { -> /* write out the ALT string */ -> outstring_stream(stream, attrval); -> } -> -> /* -> * since we already read the next character, -> * simply loop back immediately -> */ -> continue; -> } -> break; -> } -> break; -> -> case HTML_MODE_DQUOTE: -> /* if we've reached the closing quote, return to tag state */ -> if (c == '"') -> stream->html_mode_flag = HTML_MODE_TAG; -> break; -> -> case HTML_MODE_SQUOTE: -> /* if we've reached the closing quote, return to tag state */ -> if (c == '\'') -> stream->html_mode_flag = HTML_MODE_TAG; -> break; -> } -> -> /* -> * move on to the next character, and start over with the -> * new character -> */ -> c = nextout(&s, &slen); -> continue; -> } -> -> /* -> * If we're in a title, and this isn't the start of a new tag, -> * skip the character - we suppress all regular text output -> * inside a ... sequence. -> */ -> if (stream->html_in_ignore && c != '<') -> { -> /* check for entities */ -> char cbuf[50]; -> if (c == '&') -> { -> /* translate the entity */ -> c = out_parse_entity(cbuf, sizeof(cbuf), &s, &slen); -> } -> else -> { -> /* it's an ordinary character - copy it out literally */ -> cbuf[0] = c; -> cbuf[1] = '\0'; -> -> /* get the next character */ -> c = nextout(&s, &slen); -> } -> -> /* -> * if we're gathering a title, and there's room in the title -> * buffer for more (always leaving room for a null -> * terminator), add this to the title buffer -> */ -> if (stream->html_in_title) -> { -> char *cbp; -> for (cbp = cbuf ; *cbp != '\0' ; ++cbp) -> { -> /* if there's room, add it */ -> if (stream->html_title_ptr + 1 < -> stream->html_title_buf -> + sizeof(stream->html_title_buf)) -> *stream->html_title_ptr++ = *cbp; -> } -> } -> -> /* don't display anything in an ignore section */ -> continue; -> } -> -> if ( c == '%' ) /* translation string? */ -> { -> infmt = 1; -> f = fmsbuf; -> } -> else if ( c == '\\' ) /* special escape code? */ -> { -> c = nextout(&s, &slen); -> -> if (stream->capturing && c != '^' && c != 'v' && c != '\0') -> { -> outchar_stream(stream, '\\'); -> outchar_stream(stream, c); -> -> /* keep the \- and also put out the next two chars */ -> if (c == '-') -> { -> outchar_stream(stream, nextout(&s, &slen)); -> outchar_stream(stream, nextout(&s, &slen)); -> } -> } -> else -> { -> switch(c) -> { -> case 'H': /* HTML mode entry */ -> /* turn on HTML mode in the renderer */ -> switch(c = nextout(&s, &slen)) -> { -> case '-': -> /* if we have an HTML target, notify it */ -> if (stream->html_target) -> { -> /* flush its stream */ -> outflushn_stream(stream, 0); -> -> /* tell the OS layer to switch to normal mode */ -> out_end_html(stream); -> } -> -> /* switch to normal mode */ -> stream->html_mode = FALSE; -> break; -> -> case '+': -> default: -> /* if we have an HTML target, notify it */ -> if (stream->html_target) -> { -> /* flush the underlying stream */ -> outflushn_stream(stream, 0); -> -> /* tell the OS layer to switch to HTML mode */ -> out_start_html(stream); -> } -> -> /* switch to HTML mode */ -> stream->html_mode = TRUE; -> -> /* -> * if the character wasn't a "+", it's not part -> * of the "\H" sequence, so display it normally -> */ -> if (c != '+' && c != 0) -> outchar_stream(stream, c); -> break; -> } -> -> /* this sequence doesn't result in any actual output */ -> break; -> -> case 'n': /* newline? */ -> outflushn_stream(stream, 1); /* yes, output line */ -> break; -> -> case 't': /* tab? */ -> outtab_stream(stream); -> break; -> -> case 'b': /* blank line? */ -> outblank_stream(stream); -> break; -> -> case '\0': /* line ends here? */ -> done = 1; -> break; -> -> case ' ': /* quoted space */ -> if (stream->html_target && stream->html_mode) -> { -> /* -> * we're generating for an HTML target and we're -> * in HTML mode - generate the HTML non-breaking -> * space -> */ -> outstring_stream(stream, " "); -> } -> else -> { -> /* -> * we're not in HTML mode - generate our -> * internal quoted space character -> */ -> outchar_stream(stream, QSPACE); -> } -> break; -> -> case '^': /* capitalize next character */ -> stream->capsflag = 1; -> stream->nocapsflag = 0; -> break; -> -> case 'v': -> stream->nocapsflag = 1; -> stream->capsflag = 0; -> break; -> -> case '(': -> /* generate HTML if in the appropriate mode */ -> if (stream->html_mode && stream->html_target) -> { -> /* send HTML to the renderer */ -> outstring_stream(stream, ""); -> } -> else -> { -> /* turn on the 'hilite' attribute */ -> stream->cur_attr |= OS_ATTR_HILITE; -> } -> break; -> -> case ')': -> /* generate HTML if in the appropriate mode */ -> if (stream->html_mode && stream->html_target) -> { -> /* send HTML to the renderer */ -> outstring_stream(stream, ""); -> } -> else -> { -> /* turn off the 'hilite' attribute */ -> stream->cur_attr &= ~OS_ATTR_HILITE; -> } -> break; -> -> case '-': -> outchar_stream(stream, nextout(&s, &slen)); -> outchar_stream(stream, nextout(&s, &slen)); -> break; -> -> default: /* just pass invalid escapes as-is */ -> outchar_stream(stream, c); -> break; -> } -> } -> } -> else if (!stream->html_target -> && stream->html_mode -> && (c == '<' || c == '&')) -> { -> /* -> * We're in HTML mode, but the underlying target does not -> * accept HTML sequences. It appears we're at the start of -> * an "&" entity or a tag sequence, so parse it, remove it, -> * and replace it (if possible) with a text-only equivalent. -> */ -> if (c == '<') -> { -> /* read the tag */ -> char tagbuf[50]; -> int is_end_tag; -> c = read_tag(tagbuf, sizeof(tagbuf), &is_end_tag, -> &s, &slen, 0); -> -> /* -> * Check to see if we recognize the tag. We only -> * recognize a few simple tags that map easily to -> * character mode. -> */ -> if (!stricmp(tagbuf, "br")) -> { -> /* -> * line break - if there's anything buffered up, -> * just flush the current line, otherwise write out -> * a blank line -> */ -> if (stream->html_in_ignore) -> /* suppress breaks in ignore mode */; -> else if (stream->linepos != 0) -> stream->html_defer_br = HTML_DEFER_BR_FLUSH; -> else -> stream->html_defer_br = HTML_DEFER_BR_BLANK; -> } -> else if (!stricmp(tagbuf, "b") -> || !stricmp(tagbuf, "i") -> || !stricmp(tagbuf, "em") -> || !stricmp(tagbuf, "strong")) -> { -> int attr; -> -> /* choose the attribute flag */ -> switch (tagbuf[0]) -> { -> case 'b': -> case 'B': -> attr = OS_ATTR_BOLD; -> break; -> -> case 'i': -> case 'I': -> attr = OS_ATTR_ITALIC; -> break; -> -> case 'e': -> case 'E': -> attr = OS_ATTR_EM; -> break; -> -> case 's': -> case 'S': -> attr = OS_ATTR_STRONG; -> break; -> } -> -> /* bold on/off - send out appropriate os-layer code */ -> if (stream->html_in_ignore) -> { -> /* suppress any change in 'ignore' mode */ -> } -> else if (!is_end_tag) -> { -> /* turn on the selected attribute */ -> stream->cur_attr |= attr; -> } -> else -> { -> /* turn off the selected attribute */ -> stream->cur_attr &= ~attr; -> } -> } -> else if (!stricmp(tagbuf, "p")) -> { -> /* paragraph - send out a blank line */ -> if (!stream->html_in_ignore) -> outblank_stream(stream); -> } -> else if (!stricmp(tagbuf, "tab")) -> { -> /* tab - send out a \t */ -> if (!stream->html_in_ignore) -> outtab_stream(stream); -> } -> else if (!stricmp(tagbuf, "img") || !stricmp(tagbuf, "sound")) -> { -> /* IMG and SOUND - allow ALT attributes */ -> stream->html_allow_alt = TRUE; -> } -> else if (!stricmp(tagbuf, "hr")) -> { -> int rem; -> -> if (!stream->html_in_ignore) -> { -> /* start a new line */ -> outflushn_stream(stream, 1); -> -> /* write out underscores to the display width */ -> for (rem = G_os_linewidth - 1 ; rem > 0 ; ) -> { -> char dashbuf[100]; -> int cur; -> -> /* do as much as we can on this pass */ -> cur = rem; -> if ((size_t)cur > sizeof(dashbuf) - 1) -> cur = sizeof(dashbuf) - 1; -> -> /* do a buffer-full of dashes */ -> memset(dashbuf, '_', cur); -> dashbuf[cur] = '\0'; -> outstring_stream(stream, dashbuf); -> -> /* deduct this from the total */ -> rem -= cur; -> } -> -> /* put a blank line after the underscores */ -> outblank_stream(stream); -> } -> } -> else if (!stricmp(tagbuf, "q")) -> { -> unsigned int htmlchar; -> -> if (!stream->html_in_ignore) -> { -> /* if it's an open quote, increment the level */ -> if (!is_end_tag) -> ++(stream->html_quote_level); -> -> /* add the open quote */ -> htmlchar = -> (!is_end_tag -> ? ((stream->html_quote_level & 1) == 1 -> ? 8220 : 8216) -> : ((stream->html_quote_level & 1) == 1 -> ? 8221 : 8217)); -> -> /* -> * write out the HTML character, translated to -> * the local character set -> */ -> outchar_html_stream(stream, htmlchar); -> -> /* if it's a close quote, decrement the level */ -> if (is_end_tag) -> --(stream->html_quote_level); -> } -> } -> else if (!stricmp(tagbuf, "title")) -> { -> /* -> * Turn ignore mode on or off as appropriate, and -> * turn on or off title mode as well. -> */ -> if (is_end_tag) -> { -> /* -> * note that we're leaving an ignore section and -> * a title section -> */ -> --(stream->html_in_ignore); -> --(stream->html_in_title); -> -> /* -> * if we're no longer in a title, call the OS -> * layer to tell it the title string, in case it -> * wants to change the window title or otherwise -> * make use of the title -> */ -> if (stream->html_in_title == 0) -> { -> /* null-terminate the title string */ -> *stream->html_title_ptr = '\0'; -> -> /* tell the OS about the title */ -> os_set_title(stream->html_title_buf); -> } -> } -> else -> { -> /* -> * if we aren't already in a title, set up to -> * capture the title into the title buffer -> */ -> if (!stream->html_in_title) -> stream->html_title_ptr = stream->html_title_buf; -> -> /* -> * note that we're in a title and in an ignore -> * section, since nothing within gets displayed -> */ -> ++(stream->html_in_ignore); -> ++(stream->html_in_title); -> } -> } -> else if (!stricmp(tagbuf, "aboutbox")) -> { -> /* turn ignore mode on or off as appropriate */ -> if (is_end_tag) -> --(stream->html_in_ignore); -> else -> ++(stream->html_in_ignore); -> } -> else if (!stricmp(tagbuf, "pre")) -> { -> /* count the nesting level if starting PRE mode */ -> if (!is_end_tag) -> stream->html_pre_level += 1; -> -> /* surround the PRE block with line breaks */ -> outblank_stream(stream); -> -> /* count the nesting level if ending PRE mode */ -> if (is_end_tag && stream->html_pre_level != 0) -> stream->html_pre_level -= 1; -> } -> -> /* suppress everything up to the next '>' */ -> stream->html_mode_flag = HTML_MODE_TAG; -> -> /* -> * continue with the current character; since we're in -> * html tag mode, we'll skip everything until we get to -> * the closing '>' -> */ -> continue; -> } -> else if (c == '&') -> { -> /* parse it */ -> char xlat_buf[50]; -> c = out_parse_entity(xlat_buf, sizeof(xlat_buf), &s, &slen); -> -> /* write it out (we've already translated it) */ -> outstring_noxlat_stream(stream, xlat_buf); -> -> /* proceed with the next character */ -> continue; -> } -> } -> else if (stream->html_target && stream->html_mode && c == '<') -> { -> /* -> * We're in HTML mode, and we have an underlying HTML target. -> * We don't need to do much HTML interpretation at this level. -> * However, we do need to keep track of when we're in a PRE -> * block, so that we can pass whitespaces and newlines through -> * to the underlying HTML engine without filtering when we're -> * in preformatted text. -> */ -> char tagbuf[50]; -> int is_end_tag; -> c = read_tag(tagbuf, sizeof(tagbuf), &is_end_tag, -> &s, &slen, stream); -> -> /* check for special tags */ -> if (!stricmp(tagbuf, "pre")) -> { -> /* count the nesting level */ -> if (!is_end_tag) -> stream->html_pre_level += 1; -> else if (is_end_tag && stream->html_pre_level != 0) -> stream->html_pre_level -= 1; -> } -> -> /* copy the last character after the tag to the stream */ -> if (c != 0) -> outchar_stream(stream, c); -> } -> else -> { -> /* normal character */ -> outchar_stream(stream, c); -> } -> -> /* move on to the next character, unless we're finished */ -> if (done) -> c = '\0'; -> else -> c = nextout(&s, &slen); -> } -> -> /* if we ended up inside what looked like a format string, dump string */ -> if (infmt) -> { -> outchar_stream(stream, '%'); -> for (f1 = fmsbuf ; f1 < f ; ++f1) -> outchar_stream(stream, *f1); -> } -> -> /* exit a recursion level */ -> out_pop_stream(); -> -> /* success */ -> return 0; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Parse an HTML entity markup -> */ -> static char out_parse_entity(char *outbuf, size_t outbuf_size, -> char **sp, size_t *slenp) -> { -> char ampbuf[10]; -> char *dst; -> char *orig_s; -> size_t orig_slen; -> const struct amp_tbl_t *ampptr; -> size_t lo, hi, cur; -> char c; -> -> /* -> * remember where the part after the '&' begins, so we can come back -> * here later if necessary -> */ -> orig_s = *sp; -> orig_slen = *slenp; -> -> /* get the character after the ampersand */ -> c = nextout(sp, slenp); -> -> /* if it's numeric, parse the number */ -> if (c == '#') -> { -> uint val; -> -> /* skip the '#' */ -> c = nextout(sp, slenp); -> -> /* check for hex */ -> if (c == 'x' || c == 'X') -> { -> /* skip the 'x' */ -> c = nextout(sp, slenp); -> -> /* read the hex number */ -> for (val = 0 ; isxdigit((uchar)c) ; c = nextout(sp, slenp)) -> { -> /* accumulate the current digit into the value */ -> val *= 16; -> if (outisdg(c)) -> val += c - '0'; -> else if (c >= 'a' && c <= 'f') -> val += c - 'a' + 10; -> else -> val += c - 'A' + 10; -> } -> } -> else -> { -> /* read the number */ -> for (val = 0 ; outisdg(c) ; c = nextout(sp, slenp)) -> { -> /* accumulate the current digit into the value */ -> val *= 10; -> val += c - '0'; -> } -> } -> -> /* if we found a ';' at the end, skip it */ -> if (c == ';') -> c = nextout(sp, slenp); -> -> /* translate the character into the output buffer */ -> os_xlat_html4(val, outbuf, outbuf_size); -> -> /* we're done with this character */ -> return c; -> } -> -> /* -> * Parse the sequence after the '&'. Parse up to the closing -> * semicolon, or any non-alphanumeric, or until we fill up the buffer. -> */ -> for (dst = ampbuf ; -> c != '\0' && (outisdg(c) || outisal(c)) -> && dst < ampbuf + sizeof(ampbuf) - 1 ; -> *dst++ = c, c = nextout(sp, slenp)) ; -> -> /* null-terminate the name */ -> *dst = '\0'; -> -> /* do a binary search for the name */ -> lo = 0; -> hi = sizeof(amp_tbl)/sizeof(amp_tbl[0]) - 1; -> for (;;) -> { -> int diff; -> -> /* if we've converged, look no further */ -> if (lo > hi || lo >= sizeof(amp_tbl)/sizeof(amp_tbl[0])) -> { -> ampptr = 0; -> break; -> } -> -> /* split the difference */ -> cur = lo + (hi - lo)/2; -> ampptr = &_tbl[cur]; -> -> /* see where we are relative to the target item */ -> diff = strcmp(ampptr->cname, ampbuf); -> if (diff == 0) -> { -> /* this is it */ -> break; -> } -> else if (diff > 0) -> { -> /* make sure we don't go off the end */ -> if (cur == hi && cur == 0) -> { -> /* we've failed to find it */ -> ampptr = 0; -> break; -> } -> -> /* this one is too high - check the lower half */ -> hi = (cur == hi ? hi - 1 : cur); -> } -> else -> { -> /* this one is too low - check the upper half */ -> lo = (cur == lo ? lo + 1 : cur); -> } -> } -> -> /* skip to the appropriate next character */ -> if (c == ';') -> { -> /* name ended with semicolon - skip the semicolon */ -> c = nextout(sp, slenp); -> } -> else if (ampptr != 0) -> { -> int skipcnt; -> -> /* found the name - skip its exact length */ -> skipcnt = strlen(ampptr->cname); -> for (*sp = orig_s, *slenp = orig_slen ; skipcnt != 0 ; -> c = nextout(sp, slenp), --skipcnt) ; -> } -> -> /* if we found the entry, write out the character */ -> if (ampptr != 0) -> { -> /* -> * if this one has an external mapping table entry, use the mapping -> * table entry; otherwise, use the default OS routine mapping -> */ -> if (ampptr->expan != 0) -> { -> /* -> * we have an explicit expansion from the mapping table file - -> * use it -> */ -> size_t copylen = strlen(ampptr->expan); -> if (copylen > outbuf_size - 1) -> copylen = outbuf_size - 1; -> -> memcpy(outbuf, ampptr->expan, copylen); -> outbuf[copylen] = '\0'; -> } -> else -> { -> /* -> * there's no mapping table expansion - use the default OS code -> * expansion -> */ -> os_xlat_html4(ampptr->html_cval, outbuf, outbuf_size); -> } -> } -> else -> { -> /* -> * didn't find it - output the '&' literally, then back up and -> * output the entire sequence following -> */ -> *sp = orig_s; -> *slenp = orig_slen; -> c = nextout(sp, slenp); -> -> /* fill in the '&' return value */ -> outbuf[0] = '&'; -> outbuf[1] = '\0'; -> } -> -> /* return the next character */ -> return c; -> } -> -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Initialize the output formatter -> */ -> void out_init() -> { -> /* not yet hiding output */ -> outflag = 1; -> outcnt = 0; -> hidout = 0; -> -> /* initialize the standard display stream */ -> out_init_std(&G_std_disp); -> -> /* initialize the log file stream */ -> out_init_log(&G_log_disp); -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * initialize the property translation table -> */ -> void tiosetfmt(tiocxdef *ctx, runcxdef *rctx, uchar *fbase, uint flen) -> { -> VARUSED(ctx); -> fmsbase = fbase; -> fmstop = fbase + flen; -> runctx = rctx; -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Map an HTML entity to a local character value. The character table -> * reader will call this routine during initialization if it finds HTML -> * entities in the mapping table file. We'll remember these mappings -> * for use in translating HTML entities to the local character set. -> * -> * Note that the standard run-time can only display a single character -> * set, so every HTML entity that we display must be mapped to the -> * single active native character set. -> */ -> void tio_set_html_expansion(unsigned int html_char_val, -> const char *expansion, size_t expansion_len) -> { -> struct amp_tbl_t *p; -> -> /* find the character value */ -> for (p = amp_tbl ; -> p < amp_tbl + sizeof(amp_tbl)/sizeof(amp_tbl[0]) ; ++p) -> { -> /* if this is the one, store it */ -> if (p->html_cval == html_char_val) -> { -> /* allocate space for it */ -> p->expan = (char *)osmalloc(expansion_len + 1); -> -> /* save it */ -> memcpy(p->expan, expansion, expansion_len); -> p->expan[expansion_len] = '\0'; -> -> /* no need to look any further */ -> return; -> } -> } -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Write out a c-style (null-terminated) string. -> */ -> int outformat(char *s) -> { -> return outformatlen(s, strlen(s)); -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * This routine sends out a string, one character at a time (via outchar). -> * Escape codes ('\n', and so forth) are handled here. -> */ -> int outformatlen(char *s, uint slen) -> { -> char c; -> uint orig_slen; -> char *orig_s; -> int ret; -> int called_filter; -> -> /* presume we'll return success */ -> ret = 0; -> -> /* presume we won't call the filter function */ -> called_filter = FALSE; -> -> /* if there's a user filter function to invoke, call it */ -> if (G_user_filter != MCMONINV) -> { -> /* push the string */ -> runpstr(runctx, s, slen, 1); -> -> /* call the filter */ -> runfn(runctx, G_user_filter, 1); -> -> /* -> * note that we called the filter, so that we'll remove the -> * result of the filter from the stack before we return -> */ -> called_filter = TRUE; -> -> /* if the result is a string, use it in place of the original text */ -> if (runtostyp(runctx) == DAT_SSTRING) -> { -> runsdef val; -> uchar *p; -> -> /* pop the value */ -> runpop(runctx, &val); -> -> /* -> * get the text from the string, and use it as a replacement -> * for the original string -> */ -> p = val.runsv.runsvstr; -> slen = osrp2(p) - 2; -> s = (char *)(p + 2); -> -> /* -> * push the string back onto the stack - this will ensure -> * that the string stays referenced while we're working, so -> * that the garbage collector won't delete it -> */ -> runrepush(runctx, &val); -> } -> } -> -> /* remember the original string, before we scan the first character */ -> orig_s = s; -> orig_slen = slen; -> -> /* get the first character to display */ -> c = nextout(&s, &slen); -> -> /* if the string is non-empty, note that we've displayed something */ -> if (c != 0) -> outcnt = 1; -> -> /* check to see if we're hiding output */ -> if (out_is_hidden()) -> goto done; -> -> /* if the debugger is showing watchpoints, suppress all output */ -> if (outwxflag) -> goto done; -> -> /* display the string */ -> ret = outformatlen_stream(&G_std_disp, orig_s, orig_slen); -> -> /* if there's a log file, write to the log file as well */ -> if (logfp != 0) -> { -> outformatlen_stream(&G_log_disp, orig_s, orig_slen); -> osfflush(logfp); -> } -> -> done: -> /* if we called the filter, remove the result from the stack */ -> if (called_filter) -> rundisc(runctx); -> -> /* return the result from displaying to the screen */ -> return ret; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Display a blank line -> */ -> void outblank() -> { -> /* note that we've displayed something */ -> outcnt = 1; -> -> /* check to see if we're hiding output */ -> if (out_is_hidden()) -> return; -> -> /* generate the newline to the standard display */ -> outblank_stream(&G_std_disp); -> -> /* if we're logging, generate the newline to the log file as well */ -> if (logfp != 0) -> { -> outblank_stream(&G_log_disp); -> osfflush(logfp); -> } -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * outcaps() - sets an internal flag which makes the next letter output -> * a capital, whether it came in that way or not. Set the same state in -> * both formatters (standard and log). -> */ -> void outcaps(void) -> { -> outcaps_stream(&G_std_disp); -> outcaps_stream(&G_log_disp); -> } -> -> /* -> * outnocaps() - sets the next letter to a miniscule, whether it came in -> * that way or not. -> */ -> void outnocaps(void) -> { -> outnocaps_stream(&G_std_disp); -> outnocaps_stream(&G_log_disp); -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Open a log file -> */ -> int tiologopn(tiocxdef *ctx, char *fn) -> { -> /* if there's an old log file, close it */ -> if (tiologcls(ctx)) -> return 1; -> -> /* save the filename for later */ -> strcpy(logfname, fn); -> -> /* open the new file */ -> logfp = osfopwt(fn, OSFTLOG); -> -> /* -> * Reset the log file's output formatter state, since we're opening -> * a new file. -> */ -> out_init_log(&G_log_disp); -> -> /* -> * Set the log file's HTML source mode flag to the same value as is -> * currently being used in the main display stream, so that it will -> * interpret source markups the same way that the display stream is -> * going to. -> */ -> G_log_disp.html_mode = G_std_disp.html_mode; -> -> /* return 0 on success, non-zero on failure */ -> return (logfp == 0); -> } -> -> /* -> * Close the log file -> */ -> int tiologcls(tiocxdef *ctx) -> { -> /* if we have a file, close it */ -> if (logfp != 0) -> { -> /* close the handle */ -> osfcls(logfp); -> -> /* set the system file type to "log file" */ -> os_settype(logfname, OSFTLOG); -> -> /* forget about our log file handle */ -> logfp = 0; -> } -> -> /* success */ -> return 0; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Write text explicitly to the log file. This can be used to add -> * special text (such as prompt text) that would normally be suppressed -> * from the log file. When more mode is turned off, we don't -> * automatically copy text to the log file; any text that the caller -> * knows should be in the log file during times when more mode is turned -> * off can be explicitly added with this function. -> * -> * If nl is true, we'll add a newline at the end of this text. The -> * caller should not include any newlines in the text being displayed -> * here. -> */ -> void out_logfile_print(char *txt, int nl) -> { -> /* if there's no log file, there's nothing to do */ -> if (logfp == 0) -> return; -> -> /* add the text */ -> os_fprintz(logfp, txt); -> -> /* add a newline if desired */ -> if (nl) -> { -> /* add a normal newline */ -> os_fprintz(logfp, "\n"); -> -> /* if the logfile is an html target, write an HTML line break */ -> if (G_log_disp.html_target && G_log_disp.html_mode) -> os_fprintz(logfp, "
\n"); -> } -> -> /* flush the output */ -> osfflush(logfp); -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Set the current MORE mode -> */ -> int setmore(int state) -> { -> int oldstate = G_os_moremode; -> -> G_os_moremode = state; -> return oldstate; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Run the MORE prompt. If the output layer takes responsibility for -> * pagination issues (i.e., USE_MORE is defined), we'll simply display -> * the prompt and wait for input. Otherwise, the OS layer controls the -> * MORE prompt, so we'll call the OS-layer function to display the -> * prompt. -> */ -> void out_more_prompt() -> { -> #ifdef USE_MORE -> /* -> * USE_MORE defined - we take responsibility for pagination. Show -> * our default MORE prompt and wait for a keystroke. -> */ -> -> int done; -> int next_page; -> -> /* display the "MORE" prompt */ -> os_printz("[More]"); -> os_flush(); -> -> /* wait for an acceptable keystroke */ -> for (done = FALSE ; !done ; ) -> { -> os_event_info_t evt; -> -> /* get an event */ -> switch(os_get_event(0, FALSE, &evt)) -> { -> case OS_EVT_KEY: -> switch(evt.key[0]) -> { -> case ' ': -> /* stop waiting, show one page */ -> done = TRUE; -> next_page = TRUE; -> break; -> -> case '\r': -> case '\n': -> /* stop waiting, show one line */ -> done = TRUE; -> next_page = FALSE; -> break; -> -> default: -> /* ignore any other keystrokes */ -> break; -> } -> break; -> -> case OS_EVT_EOF: -> /* end of file - there's nothing to wait for now */ -> done = TRUE; -> next_page = TRUE; -> -> /* don't use more prompts any more, as the user can't respond */ -> G_os_moremode = FALSE; -> break; -> -> default: -> /* ignore other events */ -> break; -> } -> } -> -> /* -> * Remove the prompt from the screen by backing up and overwriting -> * it with spaces. (Note that this assumes that we're running in -> * some kind of terminal or character mode with a fixed-pitch font; -> * if that's not the case, the OS layer should be taking -> * responsibility for pagination anyway, so this code shouldn't be -> * in use in the first place.) -> */ -> os_printz("\r \r"); -> -> /* -> * if they pressed the space key, it means that we should show an -> * entire new page, so reset the line count to zero; otherwise, -> * we'll want to display another MORE prompt at the very next line, -> * so leave the line count alone -> */ -> if (next_page) -> G_std_disp.linecnt = 0; -> -> #else /* USE_MORE */ -> -> /* -> * USE_MORE is undefined - this means that the OS layer is taking -> * all responsibility for pagination. We must ask the OS layer to -> * display the MORE prompt, because we can't make any assumptions -> * about what the prompt looks like. -> */ -> -> os_more_prompt(); -> -> #endif /* USE_MORE */ -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * reset output -> */ -> void outreset(void) -> { -> G_std_disp.linecnt = 0; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Determine if HTML mode is active. Returns true if so, false if not. -> * Note that this merely indicates whether an "\H+" sequence is -> * currently active -- this will return true after an "\H+" sequence, -> * even on text-only interpreters. -> */ -> int tio_is_html_mode() -> { -> /* return the current HTML mode flag for the standard display stream */ -> return G_std_disp.html_mode; -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Capture routines. Capture affects only the standard display output -> * stream; there's no need to capture information redundantly in the log -> * file stream. -> */ -> -> /* -> * Begin/end capturing -> */ -> void tiocapture(tiocxdef *tioctx, mcmcxdef *memctx, int flag) -> { -> if (flag) -> { -> /* create a new object if necessary */ -> if (G_std_disp.capture_obj == MCMONINV) -> { -> mcmalo(memctx, 256, &G_std_disp.capture_obj); -> mcmunlck(memctx, G_std_disp.capture_obj); -> } -> -> /* remember the memory context */ -> G_std_disp.capture_ctx = memctx; -> } -> -> /* -> * remember capture status in the standard output stream as well as -> * the log stream -> */ -> G_std_disp.capturing = flag; -> G_log_disp.capturing = flag; -> } -> -> /* clear all captured output */ -> void tioclrcapture(tiocxdef *tioctx) -> { -> G_std_disp.capture_ofs = 0; -> } -> -> /* clear captured output back to a given size */ -> void tiopopcapture(tiocxdef *tioctx, uint orig_size) -> { -> G_std_disp.capture_ofs = orig_size; -> } -> -> /* get the object handle of the captured output */ -> mcmon tiogetcapture(tiocxdef *ctx) -> { -> return G_std_disp.capture_obj; -> } -> -> /* get the amount of text captured */ -> uint tiocapturesize(tiocxdef *ctx) -> { -> return G_std_disp.capture_ofs; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * set the current actor -> */ -> void tiosetactor(tiocxdef *ctx, objnum actor) -> { -> VARUSED(ctx); -> cmdActor = actor; -> } -> -> /* -> * get the current actor -> */ -> objnum tiogetactor(tiocxdef *ctx) -> { -> VARUSED(ctx); -> return cmdActor; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Flush the output line. We'll write to both the standard display and -> * the log file, as needed. -> */ -> void outflushn(int nl) -> { -> /* flush the display stream */ -> outflushn_stream(&G_std_disp, nl); -> -> /* flush the log stream, if we have an open log file */ -> if (logfp != 0) -> { -> outflushn_stream(&G_log_disp, nl); -> osfflush(logfp); -> } -> } -> -> /* -> * flush the current line, and start a new line -> */ -> void outflush(void) -> { -> /* use the common flushing routine in mode 1 (regular newline) */ -> outflushn(1); -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Hidden text routines -> */ -> -> /* -> * outhide - hide output in the standard display stream -> */ -> void outhide(void) -> { -> outflag = 0; -> outcnt = 0; -> hidout = 0; -> } -> -> /* -> * Check output status. Indicate whether output is currently hidden, -> * and whether any hidden output has occurred. -> */ -> void outstat(int *hidden, int *output_occurred) -> { -> *hidden = !outflag; -> *output_occurred = outcnt; -> } -> -> /* set the flag to indicate that output has occurred */ -> void outsethidden(void) -> { -> outcnt = 1; -> hidout = 1; -> } -> -> /* -> * outshow() - turns output back on, and returns TRUE (1) if any output -> * has occurred since the last outshow(), FALSE (0) otherwise. -> */ -> int outshow(void) -> { -> /* turn output back on */ -> outflag = 1; -> -> /* if we're debugging, note the end of hidden output */ -> if (dbghid && hidout) -> { -> hidout = 0; -> trcsho(); -> } -> -> /* return the flag indicating whether hidden output occurred */ -> return outcnt; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * start/end watchpoint evaluation - suppress all dstring output -> */ -> void outwx(int flag) -> { -> outwxflag = flag; -> } -> -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Set the user filter function. Setting this to MCMONINV clears the -> * filter. -> */ -> void out_set_filter(objnum filter_fn) -> { -> /* remember the filter function */ -> G_user_filter = filter_fn; -> } -> -> /* ------------------------------------------------------------------------ */ -> /* -> * Set the double-space mode -> */ -> void out_set_doublespace(int dbl) -> { -> /* remember the new setting */ -> doublespace = dbl; -> } -> -diff -r /home/nothus/orig-terps/tads/tads3/resfind.h terps/tads/tads3/resfind.h -1,68c1,74 -< /* -< * Copyright (c) 2001, 2002 Michael J. Roberts. All Rights Reserved. -< * -< * Please see the accompanying license file, LICENSE.TXT, for information -< * on using and copying this software. -< */ -< /* -< Name -< resfind.cpp - find a multimedia resource in a tads 2 or tads 3 game file -< Function -< Searches a compiled tads 2 game file or a compiled tads 3 image file -< for a multimedia resource of a given name. The caller doesn't have to -< know which tads version created the file; we'll sense the file type and -< parse it accordingly. -< -< This implementation is independent of any tads 2 or tads 3 subsystem -< except osifc, which it uses for portable file I/O and portable byte format -< conversions. -< Notes -< -< Modified -< 09/24/01 MJRoberts - Creation -< */ -< -< #ifndef RESFIND_H -< #define RESFIND_H -< -< /* -< * Resource locator. This gives the seek offset and size of a resource -< * within a larger file. -< */ -< struct tads_resinfo -< { -< /* seek location of start of resource */ -< unsigned long seek_pos; -< -< /* size of resource in bytes */ -< unsigned long siz; -< }; -< -< /* -< * Find a multimedia resource with the given name in the given file. The -< * file must be positioned at the start of the tads game file when we're -< * invoked - this allows searching for a resource within a game file that -< * is embedded in a larger file stream, since we don't care where within -< * the osfildef stream the tads game file starts. -< * -< * Fills in the resource information structure with the seek offset and -< * size of the resource in the file and returns true if the resource is -< * found; returns false if a resource with the given name doesn't exist in -< * the file. -< */ -< int tads_find_resource_fp(osfildef *fp, const char *resname, -< tads_resinfo *info); -< -< /* -< * Find a resource in a file, given the filename. -< * -< * Fills in the resource information structure with the seek offset and -< * size of the resource in the file and returns true if the resource is -< * found; returns false if a resource with the given name doesn't exist in -< * the file. -< */ -< int tads_find_resource(const char *fname, const char *resname, -< tads_resinfo *info); -< -< -< #endif /* RESFIND_H */ ---- -> /* -> * Copyright (c) 2001, 2002 Michael J. Roberts. All Rights Reserved. -> * -> * Please see the accompanying license file, LICENSE.TXT, for information -> * on using and copying this software. -> */ -> /* -> Name -> resfind.cpp - find a multimedia resource in a tads 2 or tads 3 game file -> Function -> Searches a compiled tads 2 game file or a compiled tads 3 image file -> for a multimedia resource of a given name. The caller doesn't have to -> know which tads version created the file; we'll sense the file type and -> parse it accordingly. -> -> This implementation is independent of any tads 2 or tads 3 subsystem -> except osifc, which it uses for portable file I/O and portable byte format -> conversions. -> Notes -> -> Modified -> 09/24/01 MJRoberts - Creation -> */ -> -> #ifndef RESFIND_H -> #define RESFIND_H -> -> #ifdef __cplusplus -> #define EXTERNC extern "C" -> #else -> #define EXTERNC -> #endif -> -> /* -> * Resource locator. This gives the seek offset and size of a resource -> * within a larger file. -> */ -> typedef struct -> { -> /* seek location of start of resource */ -> unsigned long seek_pos; -> -> /* size of resource in bytes */ -> unsigned long siz; -> } tads_resinfo; -> -> /* -> * Find a multimedia resource with the given name in the given file. The -> * file must be positioned at the start of the tads game file when we're -> * invoked - this allows searching for a resource within a game file that -> * is embedded in a larger file stream, since we don't care where within -> * the osfildef stream the tads game file starts. -> * -> * Fills in the resource information structure with the seek offset and -> * size of the resource in the file and returns true if the resource is -> * found; returns false if a resource with the given name doesn't exist in -> * the file. -> */ -> EXTERNC int tads_find_resource_fp(osfildef *fp, const char *resname, -> tads_resinfo *info); -> -> /* -> * Find a resource in a file, given the filename. -> * -> * Fills in the resource information structure with the seek offset and -> * size of the resource in the file and returns true if the resource is -> * found; returns false if a resource with the given name doesn't exist in -> * the file. -> */ -> EXTERNC int tads_find_resource(const char *fname, const char *resname, -> tads_resinfo *info); -> -> #undef EXTERNC -> #endif /* RESFIND_H */ -diff -r /home/nothus/orig-terps/tads/tads3/vmtz.cpp terps/tads/tads3/vmtz.cpp -1987c1987 -< result->set(tcur > 0 ? tcur - 1 : tcur); ---- -> result->set(tcur != (void *) 0 ? tcur - 1 : tcur); -Only in terps/tads: vmglk23.cpp diff --git a/app/src/main/jni/garglk b/app/src/main/jni/garglk new file mode 160000 index 0000000..0efbee5 --- /dev/null +++ b/app/src/main/jni/garglk @@ -0,0 +1 @@ +Subproject commit 0efbee5eb31c6458beb503f7b6b1ad4c8330d11a diff --git a/app/src/main/jni/glk/glk.c b/app/src/main/jni/glk/glk.c index 3a88615..4c3d61f 100644 --- a/app/src/main/jni/glk/glk.c +++ b/app/src/main/jni/glk/glk.c @@ -1995,6 +1995,10 @@ strid_t glk_stream_open_resource_uni(glui32 filenum, glui32 rock) { * NON-OFFICIAL GLK EXTENSIONS * =================================================== */ +void glkunix_set_base_file(char *filename) +{ +} + strid_t glkunix_stream_open_pathname(char *pathname, glui32 textmode, glui32 rock) { #ifdef JNI_DEBUG diff --git a/app/src/main/jni/glk/glk.h b/app/src/main/jni/glk/glk.h index f96001b..75cd41d 100644 --- a/app/src/main/jni/glk/glk.h +++ b/app/src/main/jni/glk/glk.h @@ -455,7 +455,7 @@ extern strid_t glk_stream_open_resource_uni(glui32 filenum, glui32 rock); /* XXX non-official Glk functions that may or may not exist */ -#define GARGLK 1 +//#define GARGLK 1 extern char* garglk_fileref_get_name(frefid_t fref); diff --git a/app/src/main/jni/terps/advsys/LICENSE b/app/src/main/jni/terps/advsys/LICENSE deleted file mode 100644 index 681e8cd..0000000 --- a/app/src/main/jni/terps/advsys/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -AdvSys is copyright (c) 2009 David Betz. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - * The name of the author may not be used to endorse or promote products - derived from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY -EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/app/src/main/jni/terps/advsys/advdbs.c b/app/src/main/jni/terps/advsys/advdbs.c deleted file mode 100644 index 5a74fe5..0000000 --- a/app/src/main/jni/terps/advsys/advdbs.c +++ /dev/null @@ -1,461 +0,0 @@ -/* advdbs.c - adventure database access routines */ -/* - Copyright (c) 1986, by David Michael Betz - All rights reserved -*/ - -#include "header.h" -#include "advint.h" -#include "advdbs.h" -#include - -#define RMODE 0x8001 - -/* global variables */ -int h_init; /* initialization code */ -int h_update; /* update code */ -int h_before; /* before handler code */ -int h_after; /* after handler code */ -int h_error; /* error handling code */ -strid_t datafd; /* data file descriptor */ - -/* external variables */ -extern jmp_buf restart; - -/* table base addresses */ -char *wtable; /* word table */ -char *wtypes; /* word type table */ -int wcount; /* number of words */ -char *otable; /* object table */ -int ocount; /* number of objects */ -char *atable; /* action table */ -int acount; /* number of actions */ -char *vtable; /* variable table */ -int vcount; /* number of variables */ -char *data; /* base of data tables */ -char *base; /* current base address */ -char *dbase; /* base of the data space */ -char *cbase; /* base of the code space */ -glui32 length; /* length of resident data structures */ - -/* data file header */ -static char hdr[HDR_SIZE]; - -/* save parameters */ -static long saveoff; /* save data file offset */ -static char *save; /* save area base address */ -static glui32 slen; /* save area length */ - -/* db_init - read and decode the data file header */ -void db_init(strid_t realfd) -{ - int woff,ooff,aoff,voff,n; - - /* open the data file */ - datafd = realfd; // glk_stream_open_file(name, filemode_Read, 0); - - // if (datafd == NULL) - // error("can't open data file"); - - /* read the header */ - if (glk_get_buffer_stream(datafd,hdr,HDR_SIZE) != HDR_SIZE) - error("bad data file"); - - complement(hdr,HDR_SIZE); - base = hdr; - - /* check the magic information */ - if (strncmp(&hdr[HDR_MAGIC],"ADVSYS",6) != 0) - error("not an adventure data file"); - - /* check the version number */ - if ((n = getword(HDR_VERSION)) < 101 || n > VERSION) - error("wrong version number"); - - /* decode the resident data length header field */ - length = getword(HDR_LENGTH); - - /* allocate space for the resident data structure */ - if ((data = malloc(length)) == 0) - error("insufficient memory"); - - /* compute the offset to the data */ - saveoff = (long)getword(HDR_DATBLK) * 512L; - - /* read the resident data structure */ - glk_stream_set_position(datafd,saveoff,seekmode_Start); - if (glk_get_buffer_stream(datafd,data,length) != length) - error("bad data file"); - complement(data,length); - - /* get the table base addresses */ - wtable = data + (woff = getword(HDR_WTABLE)); - wtypes = data + getword(HDR_WTYPES) - 1; - otable = data + (ooff = getword(HDR_OTABLE)); - atable = data + (aoff = getword(HDR_ATABLE)); - vtable = data + (voff = getword(HDR_VTABLE)); - - /* get the save data area */ - saveoff += (long)getword(HDR_SAVE); - save = data + getword(HDR_SAVE); - slen = getword(HDR_SLEN); - - /* get the base of the data and code spaces */ - dbase = data + getword(HDR_DBASE); - cbase = data + getword(HDR_CBASE); - - /* initialize the message routines */ - msg_init(datafd,getword(HDR_MSGBLK)); - - /* get the code pointers */ - h_init = getword(HDR_INIT); - h_update = getword(HDR_UPDATE); - h_before = getword(HDR_BEFORE); - h_after = getword(HDR_AFTER); - h_error = getword(HDR_ERROR); - - /* get the table lengths */ - base = data; - wcount = getword(woff); - ocount = getword(ooff); - acount = getword(aoff); - vcount = getword(voff); - - /* setup the base of the resident data */ - base = dbase; - - /* set the object count */ - setvalue(V_OCOUNT,ocount); - - /* CHANGED FOR GLK */ - -#ifdef GARGLK - garglk_set_story_name(&hdr[HDR_ANAME]); -#endif - -#ifdef WINDOWS - { - int i; - char *buf; - - i = strlen(&hdr[HDR_ANAME]); - i += 1; - i += strlen("GLK AdvSys - "); - - buf = malloc( sizeof(char) * i ); - wsprintf(buf, "GLK AdvSys - %s", &hdr[HDR_ANAME]); - winglk_window_set_title(buf); - } -#endif -} - -/* db_save - save the current database */ -int db_save() -{ - return (advsave(&hdr[HDR_ANAME],20,save,slen) ? T : NIL); -} - -/* db_restore - restore a saved database */ -int db_restore() -{ - return (advrestore(&hdr[HDR_ANAME],20,save,slen) ? T : NIL); -} - -/* db_restart - restart the current game */ -int db_restart() -{ - glk_stream_set_position(datafd,saveoff,seekmode_Start); - if (glk_get_buffer_stream(datafd,save,slen) != slen) - return (NIL); - complement(save,slen); - setvalue(V_OCOUNT,ocount); - - longjmp(restart,1); -} - -/* complement - complement a block of memory */ -void complement(char *adr,int len) -{ - for (; len--; adr++) - *adr = ~(*adr + 30); -} - -/* findword - find a word in the dictionary */ -int findword(char *word) -{ - char sword[WRDSIZE+1]; - int wrd,i; - - /* shorten the word */ - strncpy(sword,word,WRDSIZE); sword[WRDSIZE] = 0; - - /* look up the word */ - for (i = 1; i <= wcount; i++) { - wrd = getwloc(i); - if (strcmp(base+wrd+2,sword) == 0) - return (getword(wrd)); - } - return (NIL); -} - -/* wtype - return the type of a word */ -int wtype(int wrd) -{ - return (wtypes[wrd]); -} - -/* match - match an object against a name and list of adjectives */ -int match(int obj,int noun,int *adjs) -{ - int *aptr; - - if (!hasnoun(obj,noun)) - return (FALSE); - for (aptr = adjs; *aptr != NIL; aptr++) - if (!hasadjective(obj,*aptr)) - return (FALSE); - return (TRUE); -} - -/* checkverb - check to see if this is a valid verb */ -int checkverb(int *verbs) -{ - int act; - - /* look up the action */ - for (act = 1; act <= acount; act++) - if (hasverb(act,verbs)) - return (act); - return (NIL); -} - -/* findaction - find an action matching a description */ -int findaction(int *verbs,int preposition,int flag) -{ - int act,mask; - - /* look up the action */ - for (act = 1; act <= acount; act++) { - if (preposition && !haspreposition(act,preposition)) - continue; - if (!hasverb(act,verbs)) - continue; - mask = ~getabyte(act,A_MASK); - if ((flag & mask) == (getabyte(act,A_FLAG) & mask)) - return (act); - } - return (NIL); -} - -/* getp - get the value of an object property */ -int getp(int obj,int prop) -{ - int p; - - for (; obj; obj = getofield(obj,O_CLASS)) - if (p = findprop(obj,prop)) - return (getofield(obj,p)); - return (NIL); -} - -/* setp - set the value of an object property */ -int setp(int obj,int prop,int val) -{ - int p; - - for (; obj; obj = getofield(obj,O_CLASS)) - if (p = findprop(obj,prop)) - return (putofield(obj,p,val)); - return (NIL); -} - -/* findprop - find a property */ -int findprop(int obj,int prop) -{ - int n,i,p; - - n = getofield(obj,O_NPROPERTIES); - for (i = p = 0; i < n; i++, p += 4) - if ((getofield(obj,O_PROPERTIES+p) & ~P_CLASS) == prop) - return (O_PROPERTIES+p+2); - return (NIL); -} - -/* hasnoun - check to see if an object has a specified noun */ -int hasnoun(int obj,int noun) -{ - while (obj) { - if (inlist(getofield(obj,O_NOUNS),noun)) - return (TRUE); - obj = getofield(obj,O_CLASS); - } - return (FALSE); -} - -/* hasadjective - check to see if an object has a specified adjective */ -int hasadjective(int obj,int adjective) -{ - while (obj) { - if (inlist(getofield(obj,O_ADJECTIVES),adjective)) - return (TRUE); - obj = getofield(obj,O_CLASS); - } - return (FALSE); -} - -/* hasverb - check to see if this action has this verb */ -int hasverb(int act,int *verbs) -{ - int link,word,*verb; - - /* get the list of verbs */ - link = getafield(act,A_VERBS); - - /* look for this verb */ - while (link != NIL) { - verb = verbs; - word = getword(link+L_DATA); - while (*verb != NIL && word != NIL) { - if (*verb != getword(word+L_DATA)) - break; - verb++; - word = getword(word+L_NEXT); - } - if (*verb == NIL && word == NIL) - return (TRUE); - link = getword(link+L_NEXT); - } - return (FALSE); -} - -/* haspreposition - check to see if an action has a specified preposition */ -int haspreposition(int act, int preposition) -{ - return (inlist(getafield(act,A_PREPOSITIONS),preposition)); -} - -/* inlist - check to see if a word is an element of a list */ -int inlist(int link, int word) -{ - while (link != NIL) { - if (word == getword(link+L_DATA)) - return (TRUE); - link = getword(link+L_NEXT); - } - return (FALSE); -} - -/* getofield - get a field from an object */ -int getofield(int obj, int off) -{ - return (getword(getoloc(obj)+off)); -} - -/* putofield - put a field into an object */ -int putofield(int obj,int off,int val) -{ - return (putword(getoloc(obj)+off,val)); -} - -/* getafield - get a field from an action */ -int getafield(int act,int off) -{ - return (getword(getaloc(act)+off)); -} - -/* getabyte - get a byte field from an action */ -int getabyte(int act,int off) -{ - return (getbyte(getaloc(act)+off)); -} - -/* getoloc - get an object from the object table */ -int getoloc(int n) -{ - if (n < 1 || n > ocount) - nerror("object number out of range: %d",n); - return (getdword(otable+n+n)); -} - -/* getaloc - get an action from the action table */ -int getaloc(int n) -{ - if (n < 1 || n > acount) - nerror("action number out of range: %d",n); - return (getdword(atable+n+n)); -} - -/* getvalue - get the value of a variable from the variable table */ -int getvalue(int n) -{ - if (n < 1 || n > vcount) - nerror("variable number out of range: %d",n); - return (getdword(vtable+n+n)); -} - -/* setvalue - set the value of a variable in the variable table */ -int setvalue(int n, int v) -{ - if (n < 1 || n > vcount) - nerror("variable number out of range: %d",n); - return (putdword(vtable+n+n,v)); -} - -/* getwloc - get a word from the word table */ -int getwloc(int n) -{ - if (n < 1 || n > wcount) - nerror("word number out of range: %d",n); - return (getdword(wtable+n+n)); -} - -/* getword - get a word from the data array */ -int getword(int n) -{ - return (getdword(base+n)); -} - -/* putword - put a word into the data array */ -int putword(int n,int w) -{ - return (putdword(base+n,w)); -} - -/* getbyte - get a byte from the data array */ -int getbyte(int n) -{ - return (*(base+n) & 0xFF); -} - -/* getcbyte - get a code byte */ -int getcbyte(int n) -{ - return (*(cbase+n) & 0xFF); -} - -/* getcword - get a code word */ -int getcword(int n) -{ - return (getdword(cbase+n)); -} - -/* getdword - get a word from the data array */ -int getdword(char *p) -{ - return (((*p & 0xFF) | (*(p+1) << 8))&0xFFFF); -} - -/* putdword - put a word into the data array */ -int putdword(char *p,int w) -{ - *p = w; *(p+1) = w >> 8; - return (w); -} - -/* nerror - handle errors with numeric arguments */ -void nerror(char *fmt,int n) -{ - char buf[100]; - sprintf(buf,fmt,n); - error(buf); -} diff --git a/app/src/main/jni/terps/advsys/advdbs.h b/app/src/main/jni/terps/advsys/advdbs.h deleted file mode 100644 index 744bb81..0000000 --- a/app/src/main/jni/terps/advsys/advdbs.h +++ /dev/null @@ -1,142 +0,0 @@ -/* advdbs.h - adventure database definitions */ -/* - Copyright (c) 1986, by David Michael Betz - All rights reserved -*/ - -/* useful constants */ -#define T -1 -#define NIL 0 -#define WRDSIZE 6 - -/* data structure version number */ -#define VERSION 102 - -/* file header offsets */ -#define HDR_LENGTH 0 /* length of header in bytes */ -#define HDR_MAGIC 2 /* magic information (6 bytes) */ -#define HDR_VERSION 8 /* data structure version number */ -#define HDR_ANAME 10 /* adventure name (18 bytes) */ -#define HDR_AVERSION 28 /* adventure version number */ -#define HDR_WTABLE 30 /* offset to word table */ -#define HDR_WTYPES 32 /* offset to word type table */ -#define HDR_OTABLE 34 /* offset to object table */ -#define HDR_ATABLE 36 /* offset to action table */ -#define HDR_VTABLE 38 /* offset to variable table */ -#define HDR_DBASE 40 /* offset to base of data space */ -#define HDR_CBASE 42 /* offset to base of code space */ -#define HDR_DATBLK 44 /* first data block */ -#define HDR_MSGBLK 46 /* first message text block */ -#define HDR_INIT 48 /* initialization code */ -#define HDR_UPDATE 50 /* update code */ -#define HDR_BEFORE 52 /* code to execute before verb handler */ -#define HDR_AFTER 54 /* code to execute after verb handler */ -#define HDR_ERROR 56 /* error handler code */ -#define HDR_SAVE 58 /* save area offset */ -#define HDR_SLEN 60 /* save area length */ -#define HDR_SIZE 62 /* size of header */ - -/* word types */ -#define WT_UNKNOWN 0 -#define WT_VERB 1 -#define WT_NOUN 2 -#define WT_ADJECTIVE 3 -#define WT_PREPOSITION 4 -#define WT_CONJUNCTION 5 -#define WT_ARTICLE 6 - -/* object fields */ -#define O_CLASS 0 -#define O_NOUNS 2 -#define O_ADJECTIVES 4 -#define O_NPROPERTIES 6 -#define O_PROPERTIES 8 -#define O_SIZE 8 - -/* action fields */ -#define A_VERBS 0 -#define A_PREPOSITIONS 2 -#define A_FLAG 4 -#define A_MASK 5 -#define A_CODE 6 -#define A_SIZE 8 - -/* link fields */ -#define L_DATA 0 -#define L_NEXT 2 -#define L_SIZE 4 - -/* property flags */ -#define P_CLASS 0x8000 /* class property */ - -/* action flags */ -#define A_ACTOR 0x01 /* actor */ -#define A_DOBJECT 0x02 /* direct object */ -#define A_IOBJECT 0x04 /* indirect object */ - -/* opcodes */ -#define OP_BRT 0x01 /* branch on true */ -#define OP_BRF 0x02 /* branch on false */ -#define OP_BR 0x03 /* branch unconditionally */ -#define OP_T 0x04 /* load top of stack with t */ -#define OP_NIL 0x05 /* load top of stack with nil */ -#define OP_PUSH 0x06 /* push nil onto stack */ -#define OP_NOT 0x07 /* logical negate top of stack */ -#define OP_ADD 0x08 /* add two numeric expressions */ -#define OP_SUB 0x09 /* subtract two numeric expressions */ -#define OP_MUL 0x0A /* multiply two numeric expressions */ -#define OP_DIV 0x0B /* divide two numeric expressions */ -#define OP_REM 0x0C /* remainder of two numeric expressions */ -#define OP_BAND 0x0D /* bitwise and of two numeric expressions */ -#define OP_BOR 0x0E /* bitwise or of two numeric expressions */ -#define OP_BNOT 0x0F /* bitwise not of two numeric expressions */ -#define OP_LT 0x10 /* less than */ -#define OP_EQ 0x11 /* equal to */ -#define OP_GT 0x12 /* greater than */ -#define OP_LIT 0x13 /* load literal */ -#define OP_VAR 0x14 /* load a variable value */ -#define OP_GETP 0x15 /* get the value of an object property */ -#define OP_SETP 0x16 /* set the value of an object property */ -#define OP_SET 0x17 /* set the value of a variable */ -#define OP_PRINT 0x18 /* print messages */ -#define OP_TERPRI 0x19 /* terminate the print line */ -#define OP_PNUMBER 0x1A /* print a number */ -#define OP_FINISH 0x1B /* finish handling this command */ -#define OP_CHAIN 0x1C /* chain to the next handler */ -#define OP_ABORT 0x1D /* abort this command */ -#define OP_EXIT 0x1E /* exit the program */ -#define OP_RETURN 0x1F /* return from interpreter */ -#define OP_CALL 0x20 /* call a function */ -#define OP_SVAR 0x21 /* short load a variable */ -#define OP_SSET 0x22 /* short set a variable */ -#define OP_SPLIT 0x23 /* short load a positive literal */ -#define OP_SNLIT 0x24 /* short load a negative literal */ -#define OP_YORN 0x25 /* yes-or-no predicate */ -#define OP_SAVE 0x26 /* save data structures */ -#define OP_RESTORE 0x27 /* restore data structures */ -#define OP_ARG 0x28 /* load an argument value */ -#define OP_ASET 0x29 /* set an argument value */ -#define OP_TMP 0x2A /* load a temporary variable value */ -#define OP_TSET 0x2B /* set a temporary variable */ -#define OP_TSPACE 0x2C /* allocate temporary variable space */ -#define OP_CLASS 0x2D /* get the class of an object */ -#define OP_MATCH 0x2E /* match a noun phrase with an object */ -#define OP_PNOUN 0x2F /* print a noun phrase */ -#define OP_RESTART 0x30 /* restart the current game */ -#define OP_RAND 0x31 /* generate a random number */ -#define OP_RNDMIZE 0x32 /* seed the random number generator */ -#define OP_SEND 0x33 /* send a message to an object */ -#define OP_VOWEL 0x34 /* check for vowel beginning string */ - -#define OP_XVAR 0x40 /* extra short load a variable */ -#define OP_XSET 0x60 /* extra short set a variable */ -#define OP_XPLIT 0x80 /* extra short load a positive literal */ -#define OP_XNLIT 0xC0 /* extra short load a negative literal */ - -/* builtin variables */ -#define V_ACTOR 1 /* actor noun phrase number */ -#define V_ACTION 2 /* action from parse */ -#define V_DOBJECT 3 /* first direct object noun phrase number */ -#define V_NDOBJECTS 4 /* number of direct object noun phrases */ -#define V_IOBJECT 5 /* indirect object noun phrase number */ -#define V_OCOUNT 6 /* total object count */ diff --git a/app/src/main/jni/terps/advsys/advexe.c b/app/src/main/jni/terps/advsys/advexe.c deleted file mode 100644 index 8848397..0000000 --- a/app/src/main/jni/terps/advsys/advexe.c +++ /dev/null @@ -1,353 +0,0 @@ - -/* advexe.c - adventure code executer */ -/* - Copyright (c) 1986, by David Michael Betz - All rights reserved -*/ - -#include "header.h" -#include "advint.h" -#include "advdbs.h" - -/* external variables */ -extern char line[]; -extern int nouns[],*adjectives[]; - -/* local variables */ -int pc,opcode,p2,p3,sts; -int stack[STKSIZE],*sp,*fp,*top; -long rseed = 1L; - -/* Function Prototypes. Gosh */ -void exe_one(void); -int getboperand(); -int getwoperand(); -void print(int msg); -int vowel(int msg) ; -void pnumber(int n); -int getrand(int n); -void setrand(long n); - -/* execute - execute adventure code */ -int execute(int code) -{ - /* setup initial program counter */ - if ((pc = code) == NIL) - return (CHAIN); - - /* initialize */ - sp = fp = top = stack + STKSIZE; - - /* execute the code */ - for (sts = 0; sts == 0; ) - exe_one(); - - return (sts); -} - -/* exe_one - execute one instruction */ -void exe_one() -{ - /* get the opcode */ - opcode = getcbyte(pc); pc++; - - /* execute the instruction */ - switch (opcode) { - case OP_CALL: - *--sp = getboperand(); - *--sp = pc; - *--sp = (int)(top - fp); - fp = sp; - pc = getafield(fp[fp[2]+3],A_CODE); - break; - case OP_SEND: - *--sp = getboperand(); - *--sp = pc; - *--sp = (int)(top - fp); - fp = sp; - if (p2 = fp[fp[2]+3]) - p2 = getofield(p2,O_CLASS); - else - p2 = fp[fp[2]+2]; - if (p2 && (p2 = getp(p2,fp[fp[2]+1]))) { - pc = getafield(p2,A_CODE); - break; - } - *sp = NIL; - /* return NIL if there is no method for this message */ - case OP_RETURN: - if (fp == top) - sts = CHAIN; - else { - p2 = *sp; - sp = fp; - fp = top - *sp++; - pc = *sp++; - p3 = *sp++; - sp += p3; - *sp = p2; - } - break; - case OP_TSPACE: - sp -= getboperand(); - break; - case OP_TMP: - p2 = getboperand(); - *sp = fp[-p2-1]; - break; - case OP_TSET: - p2 = getboperand(); - fp[-p2-1] = *sp; - break; - case OP_ARG: - p2 = getboperand(); - if (p2 >= fp[2]) - error("too few arguments"); - *sp = fp[p2+3]; - break; - case OP_ASET: - p2 = getboperand(); - if (p2 >= fp[2]) - error("too few arguments"); - fp[p2+3] = *sp; - break; - case OP_BRT: - pc = (*sp ? getwoperand() : pc+2); - break; - case OP_BRF: - pc = (*sp ? pc+2 : getwoperand()); - break; - case OP_BR: - pc = getwoperand(); - break; - case OP_T: - *sp = T; - break; - case OP_NIL: - *sp = NIL; - break; - case OP_PUSH: - *--sp = NIL; - break; - case OP_NOT: - *sp = (*sp ? NIL : T); - break; - case OP_ADD: - p2 = *sp++; - *sp += p2; - break; - case OP_SUB: - p2 = *sp++; - *sp -= p2; - break; - case OP_MUL: - p2 = *sp++; - *sp *= p2; - break; - case OP_DIV: - p2 = *sp++; - *sp = (p2 == 0 ? 0 : *sp / p2); - break; - case OP_REM: - p2 = *sp++; - *sp = (p2 == 0 ? 0 : *sp % p2); - break; - case OP_BAND: - p2 = *sp++; - *sp &= p2; - break; - case OP_BOR: - p2 = *sp++; - *sp |= p2; - break; - case OP_BNOT: - *sp = ~*sp; - break; - case OP_LT: - p2 = *sp++; - *sp = (*sp < p2 ? T : NIL); - break; - case OP_EQ: - p2 = *sp++; - *sp = (*sp == p2 ? T : NIL); - break; - case OP_GT: - p2 = *sp++; - *sp = (*sp > p2 ? T : NIL); - break; - case OP_LIT: - *sp = getwoperand(); - break; - case OP_SPLIT: - *sp = getboperand(); - break; - case OP_SNLIT: - *sp = -getboperand(); - break; - case OP_VAR: - *sp = getvalue(getwoperand()); - break; - case OP_SVAR: - *sp = getvalue(getboperand()); - break; - case OP_SET: - setvalue(getwoperand(),*sp); - break; - case OP_SSET: - setvalue(getboperand(),*sp); - break; - case OP_GETP: - p2 = *sp++; - *sp = getp(*sp,p2); - break; - case OP_SETP: - p3 = *sp++; - p2 = *sp++; - *sp = setp(*sp,p2,p3); - break; - case OP_PRINT: - print(*sp); - break; - case OP_PNUMBER: - pnumber(*sp); - break; - case OP_PNOUN: - show_noun(*sp); - break; - case OP_TERPRI: - trm_chr('\n'); - break; - case OP_FINISH: - sts = FINISH; - break; - case OP_CHAIN: - sts = CHAIN; - break; - case OP_ABORT: - sts = ABORT; - break; - case OP_EXIT: - trm_done(); - glk_exit(); - break; - case OP_YORN: - trm_get(line); - *sp = (line[0] == 'Y' || line[0] == 'y' ? T : NIL); - break; - case OP_CLASS: - *sp = getofield(*sp,O_CLASS); - break; - case OP_MATCH: - p2 = *sp++; - *sp = (match(*sp,nouns[p2-1],adjectives[p2-1]) ? T : NIL); - break; - case OP_SAVE: - if ((*sp = db_save()) == NIL) // VB: added if - trm_str("Sorry, I couldn't save to this file.\n"); - break; - case OP_RESTORE: - if ((*sp = db_restore()) == NIL) // VB: added if - trm_str("Sorry, I couldn't restore from this file.\n"); - break; - case OP_RESTART: - *sp = db_restart(); - break; - case OP_RAND: - *sp = getrand(*sp); - break; - case OP_RNDMIZE: - setrand(time(0L)); - *sp = NIL; - break; - case OP_VOWEL: // patch for smart articles by MRP - *sp = vowel(*sp); // patch for smart articles by MRP - break; // patch for smart articles by MRP - default: - if (opcode >= OP_XVAR && opcode < OP_XSET) - *sp = getvalue(opcode - OP_XVAR); - else if (opcode >= OP_XSET && opcode < OP_XPLIT) - setvalue(opcode - OP_XSET,*sp); - else if (opcode >= OP_XPLIT && opcode < OP_XNLIT) - *sp = opcode - OP_XPLIT; - else if (opcode >= OP_XNLIT && opcode < 256) - *sp = OP_XNLIT - opcode; - else - trm_str("Bad opcode\n"); - break; - } -} - -/* getboperand - get data byte */ -int getboperand() -{ - int data; - data = getcbyte(pc); pc += 1; - return (data); -} - -/* getwoperand - get data word */ -int getwoperand() -{ - int data; - data = getcword(pc); pc += 2; - return (data); -} - -/* print - print a message */ -void print(int msg) -{ - int ch; - - msg_open(msg); - while (ch = msg_byte()) - trm_chr(ch); -} - -/* vowel - check for vowel */ // patch for smart articles by MRP -int vowel(int msg) // patch for smart articles by MRP -{ // patch for smart articles by MRP - int ch,r; // patch for smart articles by MRP - // patch for smart articles by MRP - msg_open(msg); // patch for smart articles by MRP - ch = msg_byte(); // patch for smart articles by MRP - if (ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u') // patch by MRP - r = T; // patch for smart articles by MRP - else // patch for smart articles by MRP - r = NIL; // patch for smart articles by MRP - while (ch) // patch for smart articles by MRP - ch = msg_byte(); // patch for smart articles by MRP - return (r); // patch for smart articles by MRP -} // patch for smart articles by MRP - -/* pnumber - print a number */ -void pnumber(int n) -{ - char buf[10]; - - sprintf(buf,"%d",n); - trm_str(buf); -} - -/* getrand - get a random number between 0 and n-1 */ -int getrand(int n) -{ - long k1; - - /* make sure we don't get stuck at zero */ - if (rseed == 0L) rseed = 1L; - - /* algorithm taken from Dr. Dobbs Journal, November 1985, page 91 */ - k1 = rseed / 127773L; - if ((rseed = 16807L * (rseed - k1 * 127773L) - k1 * 2836L) < 0L) - rseed += 2147483647L; - - /* return a random number between 0 and n-1 */ - return ((int)(rseed % (long)n)); -} - -/* setrand - set the random number seed */ -void setrand(long n) -{ - rseed = n; -} - diff --git a/app/src/main/jni/terps/advsys/advint.c b/app/src/main/jni/terps/advsys/advint.c deleted file mode 100644 index 5715031..0000000 --- a/app/src/main/jni/terps/advsys/advint.c +++ /dev/null @@ -1,133 +0,0 @@ - -/* advint.c - an interpreter for adventure games */ -/* - Copyright (c) 1986, by David Michael Betz - All rights reserved -*/ - -#include "header.h" - -#include "advint.h" -#include "advdbs.h" - - -/* global variables */ -jmp_buf restart; - -/* CHANGED TO WORK WITH GLK */ -/* Modernize it */ -void play(void); -int single_action(void); - -/* GLK Specifics */ -winid_t window; -strid_t screen; - -extern char *gas_filename; - -/* main - the main routine */ -void glk_main() -{ - char *fname,*lname; - int rows,cols; - - frefid_t file; - - window = glk_window_open(0, 0, 0, wintype_TextBuffer, WINDOW); - screen = glk_window_get_stream(window); - glk_stream_set_current(screen); - -#ifdef GARGLK - garglk_set_program_name("AdvSys 1.2"); - garglk_set_program_info( - "ADVINT v1.2 - Copyright (c) 1986 by David Betz\n" - "GLK Build v0.1 - Copyright (c) 2000 by Zenki\n" - "Gargoyle tweaks by Tor Andersson"); -#else - -#ifdef WINDOWS - glk_put_string("ADVINT v1.2 - Copyright (c) 1986, by David Betz\n" - "GLK Build v0.1 - Copyright (c) 2000 by Zenki\n\n"); -#endif -#ifdef UNIX - glk_put_string("ADVINT v1.2 - Copyright (c) 1986, by David Betz\n" - "GLK Build v0.1 - Copyright(c) 2000 by Zenki\n\n"); -#endif -#endif - - fname = NULL; - lname = NULL; - rows = 24; - cols = 80; - - /* initialize terminal i/o */ - trm_init(rows,cols,lname); - - /* Get the file reference. */ - if (!gas_filename) - error("AdvSys: No file given"); - - file = glkunix_stream_open_pathname(gas_filename, 0, SOURCEFILE); - -/* END OF CHANGES FOR GLK */ - - /* initialize the database */ - db_init(file); - - /* play the game */ - play(); -} - -/* play - the main loop */ -void play() -{ - /* establish the restart point */ - setjmp(restart); - - /* execute the initialization code */ - execute(h_init); - - /* turn handling loop */ - for (;;) { - - /* execute the update code */ - execute(h_update); - - /* parse the next input command */ - if (parse()) { - if (single_action()) - while (next() && single_action()) - ; - } - - /* parse error, call the error handling code */ - else - execute(h_error); - } -} - -/* single_action - handle a single action */ -int single_action() -{ - /* execute the before code */ - switch (execute(h_before)) { - case ABORT: /* before handler aborted sequence */ - return (FALSE); - case CHAIN: /* execute the action handler */ - if (execute(getafield(getvalue(V_ACTION),A_CODE)) == ABORT) - return (FALSE); - case FINISH:/* execute the after code */ - if (execute(h_after) == ABORT) - return (FALSE); - break; - } - return (TRUE); -} - -/* error - print an error message and exit */ -void error(char *msg) -{ - trm_str(msg); - trm_chr('\n'); - glk_exit(); -} diff --git a/app/src/main/jni/terps/advsys/advint.h b/app/src/main/jni/terps/advsys/advint.h deleted file mode 100644 index dc5b769..0000000 --- a/app/src/main/jni/terps/advsys/advint.h +++ /dev/null @@ -1,21 +0,0 @@ -/* advint.h - adventure interpreter definitions */ -/* - Copyright (c) 1986, by David Michael Betz - All rights reserved -*/ - -#include -#include - -/* useful definitions */ -#define TRUE 1 -#define FALSE 0 -#define EOS '\0' - -/* program limits */ -#define STKSIZE 500 - -/* code completion codes */ -#define FINISH 1 -#define CHAIN 2 -#define ABORT 3 diff --git a/app/src/main/jni/terps/advsys/advjunk.c b/app/src/main/jni/terps/advsys/advjunk.c deleted file mode 100644 index fac7a71..0000000 --- a/app/src/main/jni/terps/advsys/advjunk.c +++ /dev/null @@ -1,111 +0,0 @@ - - -#include "header.h" -#define UNIX -#include - -long _seed = 1L; - -#ifndef UNIX -int rand() -{ - _seed *= 397204094L; - return (_seed & 0x7FFF); -} - -srand(n) - long n; -{ - _seed = n; -} -#endif - -int getch() -{ -#ifdef UNIX - return getchar(); -#else - int ch; - if ((ch = bdos(1) & 0xFF) == '\r') { bdos(6,'\n'); ch = '\n'; } - return (ch); -#endif -} - -waitch() -{ -#ifndef UNIX - bdos(7); -#endif -} - -putch(ch,fp) - int ch; FILE *fp; -{ -#ifdef UNIX - putc(ch,fp); -#else - aputc(ch,fp); -#endif -} - -int advsave(char *hdr,int hlen,char *save,int slen) -{ - frefid_t fdref; - strid_t fd; - - fdref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Write, 0); - fd = glk_stream_open_file(fdref, filemode_Write, 0); - - glk_put_buffer_stream(fd,hdr,hlen); - - /* write the data */ - glk_put_buffer_stream(fd,save,slen); - - /* close the file and return successfully */ - glk_stream_close(fd, NULL); - glk_fileref_destroy(fdref); - return (1); -} - -int advrestore(char *hdr,int hlen,char *save,int slen) -{ - char hbuf[50],*p; - frefid_t fdref; - strid_t fd; - - - if (hlen > 50) - error("save file header buffer too small"); - - fdref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Read, 0); - fd = glk_stream_open_file(fdref, filemode_Read, 0); - - - /* read the header */ - if (glk_get_buffer_stream(fd,hbuf,hlen) != hlen) { - glk_stream_close(fd, NULL); - glk_fileref_destroy(fdref); - return (0); - } - - /* compare the headers */ - for (p = hbuf; hlen--; ) - if (*hdr++ != *p++) { - trm_str("This save file does not match the adventure!\n"); - return (0); - } - - /* read the data */ - if (glk_get_buffer_stream(fd,save,slen) != slen) { - glk_stream_close(fd, NULL); - glk_fileref_destroy(fdref); - return (0); - } - - /* close the file and return successfully */ - glk_stream_close(fd, NULL); - glk_fileref_destroy(fdref); - return (1); -} - - diff --git a/app/src/main/jni/terps/advsys/advmsg.c b/app/src/main/jni/terps/advsys/advmsg.c deleted file mode 100644 index 1cbffc5..0000000 --- a/app/src/main/jni/terps/advsys/advmsg.c +++ /dev/null @@ -1,117 +0,0 @@ - -/* advmsg.c - adventure interpreter message routines */ -/* - Copyright (c) 1986, by David Michael Betz - All rights reserved -*/ -#include "header.h" - -/* cache size */ -#define CSIZE 8 - - -/* message block cache */ -static char *mbuffer[CSIZE]; /* message text block cache buffers */ -static int mblock[CSIZE]; /* message text block cache block numbers */ -static int mnext[CSIZE]; /* next most recently used block */ -static int mhead,mtail; /* head and tail of lru list */ - -/* message file variables */ -static int mbase; /* message base block */ -static strid_t mfd; /* message file descriptor */ - -/* current message variables */ -static int mblk; /* current block */ -static char *mbuf; /* current buffer */ -static int moff; /* current buffer offset */ - - -/* Headers */ -void get_block(unsigned int blk); -int decode(int ch); - - - -/* msg_init - initialize the message routines */ -void msg_init(strid_t fd,int base) -{ - char *p; - int i; - - /* remember the message file descriptor and base */ - mbase = base; - mfd = fd; - - /* initialize the cache */ - if ((p = malloc(CSIZE * 512)) == NULL) - error("insufficient memory"); - - for (i = 0; i < CSIZE; i++) { - mbuffer[i] = p; p += 512; - mblock[i] = -1; - mnext[i] = i+1; - } - mhead = 0; mtail = CSIZE-1; mnext[mtail] = -1; -} - -/* msg_open - open a message */ -void msg_open(unsigned int msg) -{ - /* save the current message block */ - mblk = msg >> 7; - - /* make sure the first block is in a buffer */ - get_block(mblk); - - /* setup the initial offset into the block */ - moff = (msg & 0x7F) << 2; -} - -/* msg_byte - get a byte from a message */ -int msg_byte() -{ - /* check for end of block and get next block */ - if (moff >= 512) { - get_block(++mblk); - moff = 0; - } - - /* return the next message byte */ - return (decode(mbuf[moff++])); -} - -/* decode - decode a character */ -int decode(int ch) -{ - return ((ch + 30) & 0xFF); -} - -/* get_block - get a block of message text */ -void get_block(unsigned int blk) -{ - int last,n; - long loff; - - /* first check the cache */ - for (n = mhead; n != -1; last = n, n = mnext[n]) - if (blk == mblock[n]) { - if (n != mhead) { - if ((mnext[last] = mnext[n]) == -1) - mtail = last; - mnext[n] = mhead; - mhead = n; - } - mbuf = mbuffer[n]; - return; - } - - /* overwrite the least recently used buffer */ - mblock[mtail] = blk; - loff = ((long) mbase + (long) blk) << 9; - glk_stream_set_position(mfd,loff,seekmode_Start); - if (glk_get_buffer_stream(mfd,mbuffer[mtail],512) != 512) - error("error reading message text"); - - /* get the block */ - get_block(blk); -} diff --git a/app/src/main/jni/terps/advsys/advprs.c b/app/src/main/jni/terps/advsys/advprs.c deleted file mode 100644 index 96d3d29..0000000 --- a/app/src/main/jni/terps/advsys/advprs.c +++ /dev/null @@ -1,341 +0,0 @@ - -/* advprs.c - adventure parser */ -/* - Copyright (c) 1986, by David Michael Betz - All rights reserved -*/ - -#include "header.h" -#include "advint.h" -#include "advdbs.h" - -/* parser result variables */ -int nouns[20]; -int *adjectives[20]; -static int actor,action,dobject,ndobjects,iobject; -static int flag; - -/* external routines */ -extern char *trm_get(); - -/* external variables */ -extern char line[]; /* line buffer */ - -/* local variables */ -static char *lptr; /* line pointer */ -static int words[100]; /* word table */ -static char *wtext[100];/* word text table */ -static int *wptr; /* word pointer */ -static int wcnt; /* word count */ - -static int verbs[3]; /* words in the verb phrase */ -static int nnums[20]; /* noun word numbers */ -static int nptr; /* noun pointer (actually, an index) */ -static int adjs[100]; /* adjective lists */ -static int anums[100]; /* adjective word numbers */ -static int aptr; /* adjective pointer (actually, an index) */ - - -/* Function Headers */ -int parse1(); -int getverb(); -int getnoun(); -int get_line(); -int skip_spaces(); -void show_noun(int n); -int get_word(); -int spacep(int ch); -void parse_error(); - -/* parse - read and parse an input line */ -int parse() -{ - if (!parse1()) - return (FALSE); - setvalue(V_ACTOR,actor); - setvalue(V_ACTION,action); - setvalue(V_DOBJECT,dobject); - setvalue(V_NDOBJECTS,ndobjects); - setvalue(V_IOBJECT,iobject); - return (TRUE); -} - -/* next - get the next command (next direct object) */ -int next() -{ - if (getvalue(V_NDOBJECTS) > 1) { - setvalue(V_ACTOR,actor); - setvalue(V_ACTION,action); - setvalue(V_DOBJECT,getvalue(V_DOBJECT) + 1); - setvalue(V_NDOBJECTS,getvalue(V_NDOBJECTS) - 1); - setvalue(V_IOBJECT,iobject); - return (TRUE); - } - else - return (FALSE); -} - -/* parse1 - the main parser */ -int parse1() -{ - int noun1,cnt1,noun2,cnt2; - int preposition,flag; - - /* initialize */ - noun1 = noun2 = NIL; cnt1 = cnt2 = 0; - nptr = aptr = 0; - preposition = 0; - flag = 0; - - /* initialize the parser result variables */ - actor = action = dobject = iobject = NIL; - ndobjects = 0; - - /* get an input line */ - if (!get_line()) - return (FALSE); - - /* check for actor */ - if (wtype(*wptr) == WT_ADJECTIVE || wtype(*wptr) == WT_NOUN) { - if ((actor = getnoun()) == NIL) - return (FALSE); - flag |= A_ACTOR; - } - - /* get verb phrase */ - if (!getverb()) - return (FALSE); - - /* direct object, preposition and indirect object */ - if (*wptr) { - - /* get the first set of noun phrases (direct objects) */ - noun1 = nptr+1; - for (;;) { - - /* get the next direct object */ - if (getnoun() == NIL) - return (FALSE); - ++cnt1; - - /* check for more direct objects */ - if (*wptr == NIL || wtype(*wptr) != WT_CONJUNCTION) - break; - wptr++; - } - - /* get the preposition and indirect object */ - if (*wptr) { - - /* get the preposition */ - if (wtype(*wptr) == WT_PREPOSITION) - preposition = *wptr++; - - /* get the second set of noun phrases (indirect object) */ - noun2 = nptr+1; - for (;;) { - - /* get the next direct object */ - if (getnoun() == NIL) - return (FALSE); - ++cnt2; - - /* check for more direct objects */ - if (*wptr == NIL || wtype(*wptr) != WT_CONJUNCTION) - break; - wptr++; - } - } - - /* make sure this is the end of the sentence */ - if (*wptr) { - parse_error(); - return (FALSE); - } - } - - /* setup the direct and indirect objects */ - if (preposition) { - if (cnt2 > 1) { - parse_error(); - return (FALSE); - } - dobject = noun1; - ndobjects = cnt1; - iobject = noun2; - } - else if (noun2) { - if (cnt1 > 1) { - parse_error(); - return (FALSE); - } - preposition = findword("to"); - dobject = noun2; - ndobjects = cnt2; - iobject = noun1; - } - else { - dobject = noun1; - ndobjects = cnt1; - } - - /* setup the flags for the action lookup */ - if (dobject) flag |= A_DOBJECT; - if (iobject) flag |= A_IOBJECT; - - /* find the action */ - if ((action = findaction(verbs,preposition,flag)) == NIL) { - parse_error(); - return (FALSE); - } - - /* return successfully */ - return (TRUE); -} - -/* getverb - get a verb phrase and return the action it refers to */ -int getverb() -{ - /* get the verb */ - if (*wptr == NIL || wtype(*wptr) != WT_VERB) { - parse_error(); - return (NIL); - } - verbs[0] = *wptr++; - verbs[1] = NIL; - - /* check for a word following the verb */ - if (*wptr) { - verbs[1] = *wptr; - verbs[2] = NIL; - if (checkverb(verbs)) - wptr++; - else { - verbs[1] = words[wcnt-1]; - if (checkverb(verbs)) - words[--wcnt] = NIL; - else { - verbs[1] = NIL; - if (!checkverb(verbs)) { - parse_error(); - return (NIL); - } - } - } - } - return (T); -} - -/* getnoun - get a noun phrase and return the object it refers to */ -int getnoun() -{ - /* initialize the adjective list pointer */ - adjectives[nptr] = adjs + aptr; - - /* get the optional article */ - if (*wptr != NIL && wtype(*wptr) == WT_ARTICLE) - wptr++; - - /* get optional adjectives */ - while (*wptr != NIL && wtype(*wptr) == WT_ADJECTIVE) { - adjs[aptr] = *wptr++; - anums[aptr] = wptr - words - 1; - aptr++; - } - adjs[aptr++] = NULL; - - /* get the noun itself */ - if (*wptr == NIL || wtype(*wptr) != WT_NOUN) { - parse_error(); - return (NIL); - } - - /* save the noun */ - nouns[nptr] = *wptr++; - nnums[nptr] = wptr - words - 1; - return (++nptr); -} - -/* get_line - get the input line and lookup each word */ -int get_line() -{ - /* read an input line */ - trm_chr('>'); - if ((lptr = trm_get(line)) == NULL) { - trm_str("Speak up! I can't hear you!\n"); - return (FALSE); - } - - /* get each word on the line */ - for (wcnt = 0; skip_spaces(); wcnt++) - if (get_word() == NIL) - return (FALSE); - words[wcnt] = NIL; - - /* check for a blank line */ - if (wcnt == 0) { - trm_str("Speak up! I can't hear you!\n"); - return (FALSE); - } - - /* point to the first word and return successfully */ - wptr = words; - return (TRUE); -} - -/* skip_spaces - skip leading spaces */ -int skip_spaces() -{ - while (spacep(*lptr)) - lptr++; - return (*lptr != EOS); -} - -/* show_noun - show a noun phrase */ -void show_noun(int n) -{ - int adj,*p; - - /* print the adjectives */ - for (p = adjectives[n-1], adj = FALSE; *p; p++, adj = TRUE) { - if (adj) trm_chr(' '); - trm_str(wtext[anums[p-adjs]]); - } - - /* print the noun */ - if (adj) trm_chr(' '); - trm_str(wtext[nnums[n-1]]); -} - -/* get_word - get the next word */ -int get_word() -{ - int ch; - - /* get the next word */ - for (wtext[wcnt] = lptr; (ch = *lptr) != EOS && !spacep(ch); ) - *lptr++ = (isupper(ch) ? tolower(ch) : ch); - if (*lptr != EOS) *lptr++ = EOS; - - /* look up the word */ - if (words[wcnt] = findword(wtext[wcnt])) - return (words[wcnt]); - else { - trm_str("I don't know the word \""); - trm_str(wtext[wcnt]); - trm_str("\".\n"); - return (NIL); - } -} - -/* spacep - is this character a space? */ -int spacep(int ch) -{ - return (ch == ' ' || ch == ',' || ch == '.'); -} - -/* parse_error - announce a parsing error */ -void parse_error() -{ - trm_str("I don't understand.\n"); -} diff --git a/app/src/main/jni/terps/advsys/advtrm.c b/app/src/main/jni/terps/advsys/advtrm.c deleted file mode 100644 index aa3f817..0000000 --- a/app/src/main/jni/terps/advsys/advtrm.c +++ /dev/null @@ -1,110 +0,0 @@ - -/* advtrm.c - terminal i/o routines */ -/* - Copyright (c) 1986, by David Michael Betz - All rights reserved -*/ - -#include "header.h" - -/* useful definitions */ -#define TRUE 1 -#define FALSE 0 -#define EOS '\0' -#define LINEMAX 200 -#define WORDMAX 100 - -/* global variables */ -char line[LINEMAX+1]; - -/* local variables */ -static int col,maxcol,row,maxrow; -static int scnt,wcnt; -static char word[WORDMAX+1],*wptr; -static FILE *logfp = NULL; - -/* forward declarations */ -char *trm_line(); - -/* trm_init - initialize the terminal module */ -void trm_init(int rows, int cols, char *name) -{ - /* initialize the terminal i/o variables */ - maxcol = cols-1; col = 0; - maxrow = rows-1; row = 0; - wptr = word; wcnt = 0; - scnt = 0; - -} - -/* trm_done - finish terminal i/o */ -void trm_done() -{ - /* Do nothing now */ -} - -/* trm_get - get a line */ -char *trm_get(char *line) -{ - return (trm_line(line)); -} - -/* trm_str - output a string */ -void trm_str(char *str) -{ - glk_put_string(str); -} - -/* trm_xstr - output a string without logging or word wrap */ -void trm_xstr(char *str) -{ - glk_put_string(str); -} - -/* trm_chr - output a character */ -void trm_chr(int ch) -{ - if (ch == '\t') - glk_put_string(" "); - else - glk_put_char(ch); -} - -/* trm_word - output the current word */ -void trm_word() -{ - /* Do nothing */ -} - -/* trm_eol - end the current line */ -void trm_eol() -{ - glk_put_char('\n'); - -} - -/* trm_wait - wait for the user to type return */ -void trm_wait() -{ - /* Do nothing. GLK does waiting for us */ -} - -/* trm_line - get an input line */ -char *trm_line(char *line) -{ - event_t event; - - do { - glk_request_line_event(window, line, LINEMAX, 0); - glk_select(&event); - - switch (event.type) { - case evtype_LineInput: - line[event.val1] = 0; /* Null terminate it */ - break; - }; - } while (event.type != evtype_LineInput); - - return line; -} - diff --git a/app/src/main/jni/terps/advsys/glkstart.c b/app/src/main/jni/terps/advsys/glkstart.c deleted file mode 100644 index 34ca14a..0000000 --- a/app/src/main/jni/terps/advsys/glkstart.c +++ /dev/null @@ -1,29 +0,0 @@ -/* glkstart.c: Unix-specific startup code -- sample file. - Designed by Andrew Plotkin - http://www.eblong.com/zarf/glk/index.html - - This is Unix startup code for the simplest possible kind of Glk - program -- no command-line arguments; no startup files; no nothing. - - Remember, this is a sample file. You should copy it into the Glk - program you are compiling, and modify it to your needs. This should - *not* be compiled into the Glk library itself. -*/ - -#include "glk.h" -#include "glkstart.h" - -char *gas_filename = NULL; - -glkunix_argumentlist_t glkunix_arguments[] = { - { "", glkunix_arg_ValueFollows, "filename: The game file to load." }, - { NULL, glkunix_arg_End, NULL } -}; - -int glkunix_startup_code(glkunix_startup_t *data) -{ - if (data->argc == 2) - gas_filename = data->argv[1]; - return TRUE; -} - diff --git a/app/src/main/jni/terps/advsys/header.h b/app/src/main/jni/terps/advsys/header.h deleted file mode 100644 index d7b7f69..0000000 --- a/app/src/main/jni/terps/advsys/header.h +++ /dev/null @@ -1,133 +0,0 @@ -/* - * header for the annoying stuff ignored in advsys - Zenki - * michael.h.chen@yale.edu - * ^ - * +--- Stupid for forgetting this bit. - */ - -/* - * Indicate your platform - */ - -#define UNIX -/* #define WINDOWS */ - - -#include - - -#include -#include -#include -#include - -#ifdef WINDOWS -# include -#endif - - -#include "glk.h" -#include "glkstart.h" - - -/* Rocks to use to keep track of stuff */ -#define WINDOW (1) -#define SOURCEFILE (2) - -/* Exported by advint.c */ -extern void error(char *); -extern winid_t window; -extern strid_t screen; - - -/* Exported by advdbs.c */ -extern int db_save(); -extern void db_init(strid_t name); -extern int db_restore(); -extern int db_restart(); -extern void complement(char *adr,int len); -extern int findword(char *word); -extern int wtype(int wrd); -extern int match(int obj,int noun,int *adjs); -extern int checkverb(int *verbs); -extern int findaction(int *verbs,int preposition,int flag); -extern int getp(int obj,int prop); -extern int setp(int obj,int prop,int val); -extern int findprop(int obj,int prop); -extern int hasnoun(int obj,int noun); -extern int hasadjective(int obj,int adjective); -extern int hasverb(int act,int *verbs); -extern int haspreposition(int act, int preposition); -extern int inlist(int link, int word); -extern int getofield(int obj, int off); -extern int putofield(int obj,int off,int val); -extern int getafield(int act,int off); -extern int getabyte(int act,int off); -extern int getoloc(int n); -extern int getaloc(int n); -extern int getvalue(int n); -extern int setvalue(int n, int v); -extern int getwloc(int n); -extern int getword(int n); -extern int putword(int n,int w); -extern int getbyte(int n); -extern int getcbyte(int n); -extern int getcword(int n); -extern int getdword(char *p); -extern int putdword(char *p,int w); -extern void nerror(char *fmt,int n); - -extern int h_init; -extern int h_update; -extern int h_before; -extern int h_after; -extern int h_error; - - -/* Exported by advexe.c */ -extern int execute(int code); - -/* Exported by advjunk.c */ -extern int advsave(char *hdr,int hlen,char *save,int slen); -extern int advrestore(char *hdr,int hlen,char *save,int slen); - -/* Exported by advmsg.c */ -extern void msg_init(strid_t fd,int base); -extern void msg_open(unsigned int msg); -extern int msg_byte(); - -/* Exported by Advprs.c */ -extern int parse(); -extern int next(); - -/* exported by advtrm.c */ -void trm_init(int rows, int cols, char *name); -void trm_done(); -char *trm_get(char *line); -void trm_str(char *str); -void trm_xstr(char *str); -void trm_chr(int ch); -void trm_word(); -void trm_eol(); -void trm_wait(); -char *trm_line(char *line); - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/jni/terps/agility/GPL b/app/src/main/jni/terps/agility/GPL deleted file mode 100644 index d60c31a..0000000 --- a/app/src/main/jni/terps/agility/GPL +++ /dev/null @@ -1,340 +0,0 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 - - Copyright (C) 1989, 1991 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Library General Public License instead.) You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Library General -Public License instead of this License. diff --git a/app/src/main/jni/terps/agility/Makefile.dos b/app/src/main/jni/terps/agility/Makefile.dos deleted file mode 100644 index d0692aa..0000000 --- a/app/src/main/jni/terps/agility/Makefile.dos +++ /dev/null @@ -1,49 +0,0 @@ - -CC= gcc-go32 -WARNINGS= -Wall -Wtraditional -Wpointer-arith -Wcast-qual \ - -Waggregate-return -Wstrict-prototypes -fno-common -PEDWARN= -Wid-clash-6 -CFLAGS= -O2 -DMSDOS32 $(WARNINGS) -BASE= agtread.o gamedata.o util.o agxfile.o auxfile.o filename.o -AGIL= parser.o exec.o runverb.o metacommand.o savegame.o debugcmd.o agil.o \ - token.o disassemble.o object.o -INTERFACE= interface.o os_dos.o -OS_LIB= - -all: agil.exe agtout.exe agt2agx.exe - -agil.exe: $(BASE) $(AGIL) $(INTERFACE) - $(CC) $(CFLAGS) -o agil.exe $(AGIL) $(BASE) $(INTERFACE) $(OS_LIB) - -agtout.exe: agtout.o disassemble.o agilstub.o $(BASE) - $(CC) $(CFLAGS) -o agtout.exe agtout.o disassemble.o agilstub.o \ - $(BASE) - -agt2agx.exe: agt2agx.o agilstub.o $(BASE) - $(CC) $(CFLAGS) -o agt2agx.exe agt2agx.o agilstub.o $(BASE) - -agilstub.o: agilstub.c -agtread.o : agtread.c agility.h config.h -auxfile.o: auxfile.c agility.h config.h -agxfile.o : agxfile.c agility.h config.h -agt2agx.o : agt2agx.c agility.h config.h -gamedata.o : gamedata.c agility.h config.h -agthash.o : agthash.c agility.h config.h -parser.o: parser.c agility.h config.h interp.h -exec.o: exec.c agility.h config.h interp.h exec.h -runverb.o: runverb.c agility.h config.h interp.h exec.h -metacommand.o: metacommand.c agility.h config.h interp.h exec.h -token.o: token.c agility.h config.h interp.h exec.h -debugcmd.o: debugcmd.c agility.h config.h interp.h exec.h -disassemble.o: disassemble.c agility.h config.h -savegame.o: savegame.c interp.h agility.h config.h -agtout.o : agtout.c agility.h config.h -util.o: util.c agility.h config.h -filename.o: filename.c agility.h config.h -interface.o: interface.c agility.h config.h interp.h -os_none.o: os_none.c agility.h config.h interp.h -os_dos.o: os_dos.c agility.h config.h interp.h -agil.o: agil.c agility.h config.h interp.h -object.o: object.c agility.h config.h interp.h exec.h - - diff --git a/app/src/main/jni/terps/agility/Makefile.glk b/app/src/main/jni/terps/agility/Makefile.glk deleted file mode 100644 index cc18791..0000000 --- a/app/src/main/jni/terps/agility/Makefile.glk +++ /dev/null @@ -1,137 +0,0 @@ -# Set locations of Glk library and include directories, and Glk make include. -# For building the IFP plugin, you should probably use Xglk headers. -# For X Glk library: -GLKLIBDIR = ../xglk -GLKINCDIR = ../xglk -GLKMAKEINC = ../xglk/Make.xglk -# ..., or for curses Glk library: -#GLKLIBDIR = ../glkterm -#GLKINCDIR = ../glkterm -#GLKMAKEINC = ../glkterm/Make.glkterm -# ..., or for the "cheap" Glk library: -#GLKLIBDIR = ../cheapglk -#GLKINCDIR = ../cheapglk -#GLKMAKEINC = ../cheapglk/Make.cheapglk - -# Set locations of IFP library and include directories, and header tool. -# For installed IFP, these would be something like: -IFPLIBDIR = /usr/lib -IFPINCDIR = /usr/include -IFPHDRTOOL = /usr/bin/ifphdr -# ...whereas for IFP newly built alongside xglk, more like: -#IFPLIBDIR = ../ifp -#IFPINCDIR = ../ifp -#IFPHDRTOOL = ../ifp/ifphdr - -# IFP header definition. -IFPHDR = agility.hdr - -# AGiliTy version. -VERSION = 1.1.1 - -# Common definitions. -CC = gcc -WARNINGS = -Wall # -W -DEBUG = -OPTIMIZE = -O2 - -# Get the definitions for Glk LINKLIBS and GLKLIB. -include $(GLKMAKEINC) - -CFLAGS = -fPIC -ansi -DGLK -I$(GLKINCDIR) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -# CFLAGS= -I$(GLKINCDIR) $(WARNINGS) $(DEBUG) $(OPTIMIZE) -LDFLAGS = $(DEBUG) - -BASE = agtread.o gamedata.o util.o agxfile.o auxfile.o filename.o -AGIL = parser.o exec.o runverb.o metacommand.o savegame.o debugcmd.o agil.o \ - token.o disassemble.o object.o -INTERFACE= interface.o os_glk.o -OS_LIB = $(LINKLIBS) -L$(GLKLIBDIR) $(GLKLIB) - -all:glkagil agtout agt2agx agility-$(VERSION).so - -# Build the standalone Glk AGiliTy. -# See os_glk.c __wrap_exit() comments for details on -Wl,--wrap... option. -glkagil: $(BASE) $(AGIL) $(INTERFACE) - $(CC) $(LDFLAGS) -o glkagil $(AGIL) $(BASE) $(INTERFACE) $(OS_LIB)\ - -Wl,--wrap,toupper,--wrap,tolower - -# Build the support tools. -agtout: agtout.o disassemble.o agilstub.o $(BASE) - $(CC) $(LDFLAGS) -o agtout agtout.o disassemble.o agilstub.o $(BASE) - -agt2agx: agt2agx.o agilstub.o $(BASE) - $(CC) $(CFLAGS) -o agt2agx agt2agx.o agilstub.o $(BASE) - -# Build an AGiliTy IFP plugin. -# Wrapper toupper and tolower as above, and see os_glk.c __wrap_exit() -# comments for full details on why we also have to wrapper exit here. -agility-$(VERSION).so: $(BASE) $(AGIL) $(INTERFACE) $(IFPHDR) - rm -f agility_plugin.c - $(IFPHDRTOOL) $(IFPHDR) agility_plugin.c - $(CC) -I$(IFPINCDIR) $(CFLAGS) -c agility_plugin.c - $(LD) -u ifpi_force_link -shared -Bsymbolic \ - -o $@ $(AGIL) $(BASE) $(INTERFACE) \ - agility_plugin.o -L$(IFPLIBDIR) -lifppi -lc \ - --wrap toupper --wrap tolower --wrap exit - -# Directory cleanup. -clean: - rm -f *.o glkagil agility-$(VERSION).so agility_plugin.c - rm -f agtout agt2agx core - rm -rf distribution binaries - -# Distribution. -distclean: clean -maintainer-clean: clean -dist: distclean - mkdir distribution binaries - zip -r distribution/agil111src_glk.zip * -x distribution/\* binaries/ - cp GPL readme.agility readme.glk binaries - $(MAKE) -f Makefile.glk \ - GLKLIBDIR=../xglk GLKINCDIR=../xglk \ - GLKMAKEINC=../xglk/Make.xglk agility-$(VERSION).so - mv agility-$(VERSION).so binaries - $(MAKE) -f Makefile.glk \ - GLKLIBDIR=../xglk GLKINCDIR=../xglk \ - GLKMAKEINC=../xglk/Make.xglk glkagil - mv glkagil binaries/xagil - $(MAKE) -f Makefile.glk \ - GLKLIBDIR=../glkterm GLKINCDIR=../glkterm \ - GLKMAKEINC=../glkterm/Make.glkterm glkagil - mv glkagil binaries/termagil - $(MAKE) -f Makefile.glk \ - GLKLIBDIR=../cheapglk GLKINCDIR=../cheapglk \ - GLKMAKEINC=../cheapglk/Make.cheapglk glkagil - mv glkagil binaries/cheapagil - $(MAKE) -f Makefile.glk agtout agt2agx - mv agtout agt2agx binaries - cd binaries; tar zcvf ../distribution/agil111linux_glk.tgz * - -# Dependencies. -agilstub.o: agilstub.c -agtread.o : agtread.c agility.h config.h -agxfile.o : agxfile.c agility.h config.h -auxfile.o : auxfile.c agility.h config.h -agt2agx.o : agt2agx.c agility.h config.h -gamedata.o : gamedata.c agility.h config.h -parser.o: parser.c agility.h config.h interp.h -exec.o: exec.c agility.h config.h interp.h exec.h -runverb.o: runverb.c agility.h config.h interp.h exec.h -metacommand.o: metacommand.c agility.h config.h interp.h exec.h -token.o: token.c agility.h config.h interp.h exec.h -debugcmd.o: debugcmd.c agility.h config.h interp.h exec.h -disassemble.o: disassemble.c agility.h config.h -savegame.o: savegame.c interp.h agility.h config.h -agtout.o : agtout.c agility.h config.h -util.o: util.c agility.h config.h -interface.o: interface.c agility.h config.h interp.h -os_none.o: os_none.c agility.h config.h interp.h -os_termcap.o: os_termcap.c agility.h config.h interp.h -os_curses.o: os_curses.c agility.h config.h interp.h -os_msdos.o: os_msdos.c agility.h config.h interp.h -os_glk.o: os_glk.c agility.h config.h interp.h -agil.o: agil.c agility.h config.h interp.h -object.o: object.c agility.h config.h interp.h exec.h -filename.o: filename.c agility.h config.h - diff --git a/app/src/main/jni/terps/agility/Makefile.linux b/app/src/main/jni/terps/agility/Makefile.linux deleted file mode 100644 index 8af89fd..0000000 --- a/app/src/main/jni/terps/agility/Makefile.linux +++ /dev/null @@ -1,49 +0,0 @@ - -CC= gcc -WARNINGS= -Wall - -CFLAGS= -ansi -static -DLINUX $(WARNINGS) -# CFLAGS= -DHPUX $(WARNINGS) -# CFLAGS= -DSUN $(WARNINGS) - -BASE= agtread.o gamedata.o util.o agxfile.o auxfile.o filename.o -AGIL= parser.o exec.o runverb.o metacommand.o savegame.o debugcmd.o agil.o \ - token.o disassemble.o object.o -INTERFACE= interface.o os_curses.o -OS_LIB= -lncurses - -all:agil agtout agt2agx - -agil: $(BASE) $(AGIL) $(INTERFACE) - $(CC) $(CFLAGS) -o agil $(AGIL) $(BASE) $(INTERFACE) $(OS_LIB) - -agtout: agtout.o disassemble.o agilstub.o $(BASE) - $(CC) $(CFLAGS) -o agtout agtout.o disassemble.o agilstub.o $(BASE) - -agt2agx: agt2agx.o agilstub.o $(BASE) - $(CC) $(CFLAGS) -o agt2agx agt2agx.o agilstub.o $(BASE) - - -agilstub.o: agilstub.c -agtread.o : agtread.c agility.h config.h -agxfile.o : agxfile.c agility.h config.h -auxfile.o : auxfile.c agility.h config.h -agt2agx.o : agt2agx.c agility.h config.h -gamedata.o : gamedata.c agility.h config.h -parser.o: parser.c agility.h config.h interp.h -exec.o: exec.c agility.h config.h interp.h exec.h -runverb.o: runverb.c agility.h config.h interp.h exec.h -metacommand.o: metacommand.c agility.h config.h interp.h exec.h -token.o: token.c agility.h config.h interp.h exec.h -debugcmd.o: debugcmd.c agility.h config.h interp.h exec.h -disassemble.o: disassemble.c agility.h config.h -savegame.o: savegame.c interp.h agility.h config.h -agtout.o : agtout.c agility.h config.h -util.o: util.c agility.h config.h -interface.o: interface.c agility.h config.h interp.h -os_none.o: os_none.c agility.h config.h interp.h -os_termcap.o: os_termcap.c agility.h config.h interp.h -os_curses.o: os_curses.c agility.h config.h interp.h -agil.o: agil.c agility.h config.h interp.h -object.o: object.c agility.h config.h interp.h exec.h -filename.o: filename.c agility.h config.h diff --git a/app/src/main/jni/terps/agility/Makefile.plain b/app/src/main/jni/terps/agility/Makefile.plain deleted file mode 100644 index 835de71..0000000 --- a/app/src/main/jni/terps/agility/Makefile.plain +++ /dev/null @@ -1,50 +0,0 @@ - -CC= gcc -WARNINGS= -Wall - -CFLAGS= -ansi $(WARNINGS) -# CFLAGS= -DHPUX $(WARNINGS) -# CFLAGS= -DSUN $(WARNINGS) - -BASE= agtread.o gamedata.o util.o agxfile.o auxfile.o filename.o -AGIL= parser.o exec.o runverb.o metacommand.o savegame.o debugcmd.o agil.o \ - token.o disassemble.o object.o -INTERFACE= interface.o os_none.o -OS_LIB= - -all:agil agtout agt2agx - -agil: $(BASE) $(AGIL) $(INTERFACE) - $(CC) $(CFLAGS) -o agil $(AGIL) $(BASE) $(INTERFACE) $(OS_LIB) - -agtout: agtout.o disassemble.o agilstub.o $(BASE) - $(CC) $(CFLAGS) -o agtout agtout.o disassemble.o agilstub.o $(BASE) - -agt2agx: agt2agx.o agilstub.o $(BASE) - $(CC) $(CFLAGS) -o agt2agx agt2agx.o agilstub.o $(BASE) - -agilstub.o: agilstub.c -agtread.o : agtread.c agility.h config.h -agxfile.o : agxfile.c agility.h config.h -auxfile.o : auxfile.c agility.h config.h -agt2agx.o : agt2agx.c agility.h config.h -gamedata.o : gamedata.c agility.h config.h -parser.o: parser.c agility.h config.h interp.h -exec.o: exec.c agility.h config.h interp.h exec.h -runverb.o: runverb.c agility.h config.h interp.h exec.h -metacommand.o: metacommand.c agility.h config.h interp.h exec.h -token.o: token.c agility.h config.h interp.h exec.h -debugcmd.o: debugcmd.c agility.h config.h interp.h exec.h -disassemble.o: disassemble.c agility.h config.h -savegame.o: savegame.c interp.h agility.h config.h -agtout.o : agtout.c agility.h config.h -util.o: util.c agility.h config.h -interface.o: interface.c agility.h config.h interp.h -os_none.o: os_none.c agility.h config.h interp.h -os_termcap.o: os_termcap.c agility.h config.h interp.h -os_curses.o: os_curses.c agility.h config.h interp.h -os_msdos.o: os_msdos.c agility.h config.h interp.h -agil.o: agil.c agility.h config.h interp.h -object.o: object.c agility.h config.h interp.h exec.h -filename.o: filename.c agility.h config.h - diff --git a/app/src/main/jni/terps/agility/agil.c b/app/src/main/jni/terps/agility/agil.c deleted file mode 100644 index cec071b..0000000 --- a/app/src/main/jni/terps/agility/agil.c +++ /dev/null @@ -1,938 +0,0 @@ -/* agil.c-- initialization and the main execution loop */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy: the (Mostly) */ -/* Universal AGT Interpreter */ - -/* This file contains the initialization and clean-up code - as well as the interpreter's main loop. */ - -/* Overview of the source for AGiliTy: - agil.c - --initialization - --tokeniser - - parser.c: - --parser - --disambiguation - --menuing system - - exec.c - --verb execution wrapper - --standard utilities for running actions - - runverb.c: - --standard verbs and the main routine for executing the player's action. - - object.c - --Utility functions for manipulating game objects (nouns, creatures, etc.) - including scope routines. - - metacommand.c - --metacommand execution: scan the metacommands and execute them - in the proper order. The actual execution of each individual command - is handled in token.c. - - token.c - --this module contains the actual code to run each of the (several hundered) - different metacommands; called from metacommand.c. - - - debugcmd.c - --Routines to execute debugging verb - - savegame.c - --save and restore - --undo and restart - - util.c - --general utilities - --memory management - --buffered file i/o - - interface.c - --high level input/output - --general utilities - - disassemble.c - --Metacommand debugging output - - os_.c - --low level input/output - --other platform dependent code -*/ - - -#include -#include "agility.h" -#include "interp.h" - -/* The following are AGT 'purity' flags; they turn off features of */ -/* my interpreter that are not fully consistent with the original AGT */ -/* and so could break some games. Some of these are trivial improvements; */ -/* some are more radical and should be used with caution. Several are */ -/* only useful if a game was designed with them in mind. */ -/* In all cases, setting the flag to 1 more closely follows the */ -/* behavior of the original interpreters */ -/* WARNING: Most of these haven't been tested in the non-default state. */ -/* Most of these will eventually become variables settable by the user */ -/* or from a (possibly game-specific) configuration file */ - -rbool PURE_INPUT=1; /* Is the input line bold? */ - -rbool PURE_TONE=0; /* Is low level sound enabled? */ - - -/*-------------------------------------------------------------------*/ -/* Misc. things to support the tokenizer and the dictionry. */ -/*-------------------------------------------------------------------*/ - -/* The following should not be changed without also changing the - wtype enum statement in interp.h to match */ -static const char* ext_voc[]= -{"the","my","a","an", /* These 4 are ignored in canonical AGT */ - "then",".",";","and", "," , "its", "all","undo", "look","g", - "pick","go","exits","talk","take","door","again","but","except", - "scene","everything","listexit","listexits","close", - "verb","noun","adjective","prep","object","name","step", - " any","either","both","everyone","everybody", - "he","she","it","they","him","her","them","is","are","oops", - "was","were", - /* Everything between 'in' and 'about' should be a preposition */ - "in","out", "into","at","to","across","inside","with","near","for", - "of","behind", "beside", "on", "off", "under", "from","through", - "toward", "towards", "between", "around", "upon", "thru", - "by", "over", "up", "down", - "about"}; - /* 'about' must be the last element of this list */ - - -/*-------------------------------------------------------------------*/ -/* Routines to read in and use various auxilary files. */ -/* (.TTL, .INS, .VOC, .CFG) */ -/*-------------------------------------------------------------------*/ - -static rbool emptyline(unsigned char *s) -/* Check if s consists only of white space and control characters */ -{ - unsigned char *p; - - for(p=s;*p!=0;p++) - if (!rspace(*p) && *p>26) return 0; - return 1; -} - -static void print_title(fc_type fc) -{ - int height; - signed char center_mode; /* Center title? */ - descr_line *buff; - char *s; - rbool skip_line; /* Skip first line: it has COLORS */ - - if (agx_file) - buff=read_descr(title_ptr.start,title_ptr.size); - else - buff=read_ttl(fc); - - if (buff==NULL) { - char *s; - - writeln("");writeln(""); - s=formal_name(fc,fNONE); - if (s!=NULL) { - s[0]=toupper(s[0]); - agt_center(1); - agt_textcolor(-1); - writeln(s); - agt_textcolor(-2); - agt_center(0); - rfree(s); - } - writeln("");writeln(""); - - if (avervm_width) vm_width=n; - } -} - -/* .CFG reading routines -------------------------------------------- */ - -#define opt(s) (strcasecmp(optstr[0],s)==0) - -/* These are the interpreter specific options; this is called - from cfg_option in agtdata.c. */ -void agil_option(int optnum,char *optstr[], rbool setflag, rbool lastpass) -{ - if (opt("ibm_char")) fix_ascii_flag=!setflag; - else if (!lastpass) return; /* On the first pass through the game specific - file, we ignore all but the above options */ - else if (opt("tone")) PURE_TONE=setflag; - else if (opt("input_bold")) PURE_INPUT=setflag; - else if (opt("force_load")) FORCE_VERSION=setflag; - else if (!agt_option(optnum,optstr,setflag)) /* Platform specific options */ - rprintf("Invalid option %s\n",optstr[0]); -} - -/*-------------------------------------------------------------------*/ -/* Tokeniser: Split input into words and look them up in dictionary */ -/*-------------------------------------------------------------------*/ - -static rbool noise_word(word w) -{ - if (w==ext_code[wthe] || w==ext_code[wa] || w==ext_code[wan]) return 1; - if (w==ext_code[wmy]) return 1; - if (aver>=AGT18 && aver<=AGT18MAX && w==ext_code[wis]) return 1; - return 0; -} - - -static rbool check_dot(char *prevtext, int prevcnt, char *lookahead) - /* This routine is devoted to trying to figure out whether - we should treat '.' as punctuation or as a letter. */ - /* It returns true if '.' should be treated as punctuation. */ - /* prevtext=the current word, as far as it has been parsed. - prevcnt=the number of letters in prevtext - [which is *not* 0 terminated] */ - /* lookahead=the rest of the current input line *after* the period. */ -{ - int i, endword, restcnt; - - if (!PURE_DOT) return 1; /* No words with periods in them, so it must - be punctuation. */ - /* We just start scanning the dictionary to see if any of them - are possible matches, looking ahead as neccessary. */ - - /* Find the next unambiguous word end. This ignores possible - word ends caused by periods. */ - for(endword=0;lookahead[endword]!=0;endword++) - if (isspace(lookahead[endword]) || - lookahead[endword]==',' || lookahead[endword]==';') - break; - - for(i=0;iendword) continue; /* Dictionary entry is longer than - following text */ - - /* Check to see if the dictionary entry can be found in the lookahead - buffer */ - if (strncasecmp(lookahead,dict[i]+prevcnt+1,restcnt)!=0) continue; - - if (restcnt==endword) return 0; /* We have a match */ - /* At this point, we know that restcnt0) /* End of word: add it to input */ - { - in_text[ip][j]=0; - input[ip]=search_dict(in_text[ip]); - if (input[ip]==-1) input[ip]=0; - else if (input[ip]==0) input[ip]=ext_code[w_any]; /* _Real_ 'ANY' */ - if (!noise_word(input[ip])) ip+=1; - /* i.e. if not one of the four ignored words, advance */ - j=0; - } /* If j=0 and not punct, then no new word; just skip the whitespace */ - if (punctuation) { - in_text[ip][0]=buff[k];in_text[ip][1]=0; - input[ip]=search_dict(in_text[ip]); - if (input[ip]==-1) input[ip]=0; - j=0;ip++; - } - if (ip>=MAXINPUT-1) { - writeln("Too many words in input; ignoring rest of line."); - break; - } - if (buff[k]==0) break; - } - input[ip]=-1; - in_text[ip][0]=0; -} - - - -/*-------------------------------------------------------------------*/ -/* Main game loop: Get player input and call the parser. */ -/*-------------------------------------------------------------------*/ - -static void game_end(void) -{ - rbool done_flag; - char *s; - - if (winflag || deadflag) { - writeln("");writeln("");agt_center(1); - if (winflag) - gen_sysmsg(148,"***** $You$ have won! *****",MSG_MAIN,NULL); - if (deadflag) - gen_sysmsg(147,"***** $You$ have died! *****",MSG_MAIN,NULL); - writeln("");writeln("");agt_center(0); - } - if (deadflag && !endflag) { - if (curr_lives>1) { /* Resurrection code */ - if (curr_lives==max_lives) - gen_sysmsg(151,"Hmmm.... so $you$'ve gotten $your$self killed. " - "Would you like me to try a resurrection?",MSG_MAIN,NULL); - else gen_sysmsg(152," $You$'ve died *again*. " - "Would you like me to try another resurrection?", - MSG_MAIN,NULL); - if (yesno("? ")) { /* Now do resurrection */ - curr_lives--; - quitflag=deadflag=0; - gen_sysmsg(154, - "$You$ emerge coughing from a cloud of dark green smoke.", - MSG_MAIN,NULL); - writeln(""); - loc=resurrect_room-first_room; - newlife_flag=1; - set_statline(); - do_look=do_autoverb=1; - newroom(); - return; - } else writeln("As you wish..."); - } - else if (max_lives>1) - gen_sysmsg(153,"$You$'ve used up all of $your$ lives.",MSG_MAIN,NULL); - } - writeln(""); - print_score(); - writeln(""); - done_flag=quitflag; /* If player has QUIT, don't ask again */ - while (!done_flag && !quitflag) { - writestr("Would you like to "); - if (restart_state!=NULL) writestr("restart, "); - writestr("restore"); - if (undo_state!=NULL && can_undo) - writestr(", undo,"); - else if (restart_state!=NULL) writestr(","); - writestr(" or quit? "); - s=agt_readline(5); - if (strncasecmp(s,"RESTART",7)==0) - if (restart_state!=NULL) - {restart_game();done_flag=1;} - else writeln("Sorry, I'm unable to do that because of limited memory."); - else if (strncasecmp(s,"RESTORE",7)==0) - if (loadgame()) {done_flag=1;} - else writeln("(RESTORE failed)"); - else if (strncasecmp(s,"UNDO",4)==0) - if (can_undo && undo_state!=NULL) - {putstate(undo_state);done_flag=1;} - else writeln("Insufficiant memory to support UNDO"); - else if (toupper(s[0])=='Q') - {quitflag=1;done_flag=1;} - } - set_statline(); -} - - -static void parse_loop(void) -/* This exists to deal with THEN lists; parse() handles the indiviudual - commands */ -{ - for(ip=0;ip>=0 && ip=0 && ip --> EXAMINE */ - for(i=0;i0 || command[i].noun_adj>0 - || command[i].objcmd>0 || command[i].obj_adj>0 - || command[i].prep>0) ) - smart_look=0; - } - - pictable=rmalloc(sizeof(int)*maxpict); - for(i=0;i 'dummy verb5' */ - dict[ syntbl[auxsyn[21]] ][6]=' '; /* change_locations */ - dict[ syntbl[auxsyn[55]] ][5]=' '; /* magic_word */ - } - - if (!PURE_SUBNAME) /* Replace the 'e' by a space */ - for(i=0;i=AGT18 && aver<=AGT18MAX) PURE_DOT=0; - else { - PURE_DOT=FORCE_PURE_DOT; - for(i=0;i Views an illustration. (Not supported on all " - "platforms.)"); - writeln(" BRIEF Don't print room descriptions for rooms you've seen."); - writeln(" VERBOSE Print room descriptions even for rooms you've already " - "seen."); - writeln(" LIST EXITS List the exits from a room."); - writeln(" LISTEXIT ON/OFF Turn on/off automatic listing of exits."); - writeln(" SCRIPT Start sending a transcript to a file."); - writeln(" UNSCRIPT Stop creating a transcript."); - writeln(" SOUND ON, OFF Turn sound on/off."); - writeln(" LOG Start sending all of your commands to a file."); - writeln(" REPLAY Replay your commands from a file, " - "executing one every seconds."); - writeln(" REPLAY FAST Replay your commands from a file without waiting " - "for you to read the scrolling text."); - writeln(" REPLAY STEP Replay your commands from a file, " - "one for every keypress."); - writeln(" AGILDEBUG Access debugging commands."); - writeln(" MENU Toggle menu mode on or off."); - writeln(" OOPS Correct a word you just mistyped; must be the first " - "command on a line."); - writeln(" UNDO Undo your last move; must be the first command on a line."); - writeln(" SAVE Save the game."); - writeln(" RESTORE Restore the game."); - writeln(" RESTART Restart the game."); - writeln(" QUIT Quit."); - writeln(""); -} - - -/* This is a hack to get rid of the "What Now?" prompt. */ -static void fix_prompt(void) -{ - descr_line *d; - - if (err_ptr==NULL) return; - d=read_descr(err_ptr[0].start,err_ptr[0].size); - if (d==NULL) return; - if (strncasecmp(d[0],"What Now?",9)==0) - err_ptr[0].size=err_ptr[0].start=0; - free_descr(d); -} - - - -void close_game(void); /* Called by setup_game, and so needs - to be defined here. */ - -static fc_type setup_game(fc_type fc) -/* game_name is the common filename of the AGT game files */ -{ - int can_save; - char choice; - rbool have_ins; - - bold_mode=0; - rm_acct=1;rm_trap=1; - rm_size=ralloc_cnt=rfree_cnt=0; - mars_fix=0; no_auxsyn=0; - debug_disambig=0;debug_any=1; - dbg_nomsg=1; /* Supress output of MSG arguments to metacommands */ - textbold=0;debug_mode=0;aver=0; - verboseflag=1;notify_flag=0;logflag=0;menu_mode=0; - fast_replay=0; - stable_random=BATCH_MODE || make_test; - if (make_test) BATCH_MODE=0; - hold_fc=fc; - set_default_filenames(fc); - - init_stack(); - read_config(agt_globalfile(0),1); /* Global configuration file */ - - /* Now that we *have* PATH information, go looking for the games */ - /* At the very least, it creates an rmalloc'd copy of game_name */ - read_config(openfile(fc,fCFG,NULL,0),0); - text_file=0; - /* First pass through game specific config file */ - build_trans_ascii(); -#ifdef PROFILE - resetwatch(); -#endif - writeln("Loading game..."); - if (!read_agx(fc,0) && !readagt(fc,0)) - fatal("Unable to load game."); -#ifdef PROFILE - writeln(stopwatch()); - agt_waitkey(); -#endif - if (have_opt) - menu_mode=opt_data[5]; /* See agtread.c for discussion of OPT file - format */ - text_file=1; - read_config(openfile(fc,fCFG,NULL,0),1);/*Game specific config file*/ - text_file=0; - if (min_ver>AGIL_VERID) { - if (FORCE_VERSION) - agtwarn("This game requires a later version of AGiliTy.",0); - else - fatal("This game requires a later version of AGiliTy."); - } - sort_cmd(); - ext_dict(); - build_verbmenu(); - fix_dummy(); /* Prevent player from calling dummy verbs or subroutines by - typing 'Subroutine n' on the command line */ - can_save=init(); - if (!agx_file) open_descr(fc); - fix_prompt(); /* Kill off 'What Now?' prompt. */ - if (BATCH_MODE || make_test) - set_test_mode(fc); - start_interface(fc); - fontcmd(2,0); /* Set initial font */ - if (intro_first && intro_ptr.size>0) { - agt_clrscr(); - print_descr(intro_ptr,1); - wait_return(); - } - if (aver>=AGTME10) - pictcmd(3,0); /* Show title image, if there is one */ - print_title(fc); - have_ins=open_ins_file(fc,0); - do { - if (have_ins) - writestr("Choose nstructions, GiliTy Information, " - "or to start the game"); - else - writestr("Choose GiliTy Information or to start the game"); - choice=tolower(agt_getchar()); /* Wait for keypress */ - agt_clrscr(); - if (have_ins && choice=='i') print_instructions(fc); - else if (choice=='a') print_license(); - } while ( (choice=='i' && have_ins) || choice=='a'); - close_ins_file(); - if (!intro_first && intro_ptr.size>0) { - print_descr(intro_ptr,1); - wait_return(); - agt_clrscr(); - } - if (maxroom -#include -#include - -/* Platform-specific configuration info */ -#include "config.h" - -/* ------------------------------------------------------------------- */ -/* This is a preprocessor trick to ensure that space is only allocated - for global variables once. 'global' should only be defined in one - source file; for all of the other modules, it will be converted to - extern by the following lines */ -/* ------------------------------------------------------------------- */ -#ifndef global /* Don't touch this */ -#define global extern -#define global_defined_agtread -#endif - - -/* ------------------------------------------------------------------- */ -/* DEFINITIONS OF SPECIAL DATA TYPES */ -/* These should by platform-independent. */ -/* ------------------------------------------------------------------- */ - -#ifdef force16 /* This is for debugging purposes */ -#define int short int -#endif - -/* General data types */ -typedef unsigned char uchar; -typedef signed char schar; -typedef short integer; /* Should be a 16+-bit signed numeric type */ - /* For technical reasons, it must be big enough to - hold a value of type word (see below) */ -typedef unsigned long int32; /* Should be a 32+-bit unsigned numeric type */ -typedef unsigned long uint32; -typedef uchar rbool; - -#define WORD_LENG 25 - -/* Game-specific data type */ -typedef char tline[81]; /* Both of these must include terminating null */ -typedef char words[WORD_LENG]; /* ...23 in classic, 16 in master's */ -typedef short word; /* A pointer into the dictionary */ -typedef short slist; /* Index into synlist marking beginning of this - synonym list. [SYNCNT] - list of word pointers -- eg synonyms */ -typedef char *descr_line; /* This is the type used to return descriptions. - They are actually returned as an array of - pointers to char, one for each line. - It is NULL terminated. */ -typedef char *filename; /* Datatype used for picture, sound, etc. names*/ - - -typedef enum {fNONE, - fDA1,fDA2,fDA3,fDA4,fDA5,fDA6,fDSS, - fHNT,fOPT,fTTL, - fSAV,fSCR,fLOG, - fAGX,fINS,fVOC,fCFG, - fAGT,fDAT,fMSG,fCMD,fSTD,fAGT_STD} filetype; - - -/* ------------------------------------------------------------------- */ -/* GLOBAL FLAGS */ -/* Many of the following should be made into command line options */ -/* ------------------------------------------------------------------- */ - -/* #define AGT_16BIT */ /* Force interpreter to use 16-bit quantities */ -/* #define DUMP_VLIST */ /* Dump out the verb list info */ -/* #define USE_CMD_INDEX */ /* Read in metacommand index data for objects */ - - -#define SS_GRAIN 1024 /* Granularity of size request for static string - array (to avoid calling rrealloc too often) */ -#define SYN_GRAIN 32 /* Granularity of requests for synonym array; this - is in units of sizeof(word) */ -#define MAX_BADTOK 10 /* How many bad tokens to report before giving - up */ - - - -/* The following are defaults that can be overridden from the command line */ -/* The real variable has the name without the "def_" */ - -#define def_DIAG 0 /* Print out diagnostic data? */ -#define def_interp_arg 1 /* Decipher arguments to opcodes? */ -#define def_debug_da1 0 /* used to analyse .DA1 files */ -#define def_RAW_CMD_OUT 0 /*Print CMDs out raw, undecoded; sometimes useful - when trying to understand new gamefile version */ -#define def_ERR_LEVEL 2 /* Level of error reporting. */ - /* 0== almost none */ - /* 1== Report possibly serious conditions */ - /* 2== Report any fall from perfection */ - - - - - - - -/* ------------------------------------------------------------------- */ -/* DEFINES OF GLOBAL PARAMETERS */ -/* ------------------------------------------------------------------- */ - -#define FORMAT_CODE 0xFF /* Character used for special formatting codes: - --in 1.8x games, it designates bold - --in AGX+ games, it will prefix format codes - --otherwise it designates black (replacing - 0, which has obvious problems) */ -#define LAST_TEXTCODE 8 /* Last ascii code to be used for text attributes */ - - - -#define MAX_PIX 31 -#define MAX_FLAG_NOUN 31 - - - -#define OLD_VERB 59 /* Number of built in verbs in original interpreters-- - this number includes ANY, which is verb 0. */ -#define DIR_ADDR_CODE (OLD_VERB+17) /* Verb ID used for direct address */ -#define AUX_VERB 18 /* Additional verbs supported by the interpreter */ -#define BASE_VERB (OLD_VERB+AUX_VERB) /* Total number of built-in verbs */ -#define DUMB_VERB (DVERB+MAX_SUB) /* Number of dummy verbs and subroutines */ -#define TOTAL_VERB (BASE_VERB+DUMB_VERB) /* Total count of verbs */ - - -/* The following numbers refer to the ideal code we are translating into, - not the parameters for the actual data file we're reading. */ -#define MAX_COND 143 /* Last condition token id */ -#define START_ACT 1000 /* First action code */ -#define PREWIN_ACT 1161 /* Last action code before WinGame */ -#define WIN_ACT 2000 /* Value of WinGame opcode */ -#define END_ACT (WIN_ACT+2) /* Lowest command-terminating action code */ -#define MAX_ACT (WIN_ACT+4) /* Highest action code */ - -/* Note: the following values are used by Magx internally: - 3000-- Used to mark 'no entry' in the opcode hash table. - 8000-- Used for NEXT - 8001-- Used for PREV - */ - -#define MAX_TOKEN_ID 250 /* Upper limit on legal (raw) token values - read from AGT files. Doesn't need to be exact. */ - -/* Number of built in properties and attributes. */ -#define NUM_PROP 14 -#define NUM_ATTR 26 - - -/* - None of these are used any more, but I leave them here for reference - #define MAX_ROOM 300 - #define MAX_NOUN 300 - #define MAX_CREAT 200 - #define MAX_CMD 1500 - #define MAX_QUEST 100 - #define MAX_MSG 1000 - #define MAX_PICT 250 - #define ABS_MAX_REC_CMD 34 - #define MAX_OBJ (MAX_ROOM+MAX_NOUN+MAX_CREAT) - #define SYNCNT 15 -*/ - - - -/* --------------------------------------------------------------------- */ -/* DATA STRUCTURE DEFINITIONS */ -/* */ -/* All of the internal data structures used to store the contents of the */ -/* game file */ -/* --------------------------------------------------------------------- */ - -/* First, pointers to game descriptions */ -/* start and size may be measured in units of characters or in units */ -/* of tline */ -typedef struct { - long start; - long size; -} descr_ptr; - - -/* Entries in the opcode tables: the name of the opcode, the number of - arguments, and the types of those arguments */ -typedef struct { - char *opcode; - integer argnum; - integer arg1,arg2; -} opdef; /* Opcode table entry */ - - - -/* This is the data type for opcode correction entries */ -/* These are used to translate the opcodes from the various versions */ -/* to a uniform internal format. */ -/* The actual translation tables built with this are in agtdata.c */ -typedef struct { - integer told,tnew; /* Old and new values. */ -} cmd_fix_rec; - -typedef const cmd_fix_rec *fix_array; - - -/* ROOMS */ -typedef struct { - const char *name; /* [31] */ - int32 flag_noun_bits,PIX_bits; /* Master's Ed. only */ - slist replacing_word; /* List of words to be replaced */ - word replace_word; /* Word that does replacing */ - word autoverb; /* Verb automatically executed on entry to room */ - integer path[13]; - integer key; - integer contents; /* Used internally by the interpreter; not read in - from the game file */ - integer points; - integer light; /* Object that lights room; 0=none needed, 1=any */ - integer pict,initdesc; - integer oclass; - rbool seen, locked_door; - rbool end, win, killplayer; - rbool unused; /* True if this room entry is unused */ -} room_rec; - - -/* NOUNS */ -typedef struct { - const char *shortdesc; /* tline */ - const char *position; - /* 23 characters in position for classic ed, 31 for ME */ - const char *initpos; /*Starting value of position;used for RESTART/RESTORE*/ - int scratch; /* Scratch space for use by various parser routines. */ - slist syns; /* List of synonyms */ - word name, adj; - word related_name; /* Word that should appear on menu when this noun - is in scope */ - word pos_prep, pos_name; /* Used internally by the interpreter */ - /* pos_prep==-1 means use noun.position */ - integer nearby_noun; /* Noun this noun is behind */ - integer num_shots; - integer points; - integer weight, size; - integer key; - integer initdesc,pict; - integer location; /* 1=carried, 1000=worn */ - integer contents, next; /* Used internally by the interpreter; not read in - from the game file */ - integer oclass; - integer flagnum; /* Number of associated flag + 1. 0=no flag. */ - rbool scope; /* Used internally by the interpreter */ - rbool isglobal; /* True if global object */ - uchar plural; - rbool something_pos_near_noun; /* Anybody behind us? */ - rbool has_syns; - rbool pushable, pullable, turnable, playable, readable; - rbool on, closable, open, lockable, locked, edible, wearable; - rbool drinkable, poisonous, movable, light; - rbool shootable; - rbool win; - rbool unused; /* True if this noun entry is unused */ - rbool seen; /* True if this noun has been seen by the player */ - rbool proper; /* True if noun's name is to be treated as proper noun. */ -} noun_rec; - - -/* CREATURES */ -typedef struct { - const char *shortdesc; /* tline */ - int scratch; /* Scratch space for use by various parser routines. */ - slist syns; - word name; - word adj; - integer location; - integer contents, next; /* Used internally by the interpreter; not read in - from the game file */ - integer weapon; /* Killed by this */ - integer points; - integer counter; /* How many times has player been nasty to it? */ - integer threshold, timethresh, timecounter; - integer pict,initdesc; - integer oclass; - integer flagnum; /* Number of associated flag + 1. 0=no flag. */ - rbool scope; /* Used internally by the interpreter */ - rbool isglobal; /* True if global object */ - rbool has_syns; - rbool groupmemb; - rbool hostile; - uchar gender; - rbool unused; /* True if this creature entry is unused */ - rbool seen; /* True if this creature has been seen by the player */ - rbool proper; /* True if this creature's name is to be treated as a proper - noun (i.e. not prepended with "the") */ -} creat_rec; - -/* These records are used to hold reference information for - user-defined flags and properties */ -/* These give the base index offset in objflag/objprop of each flag/prop - for rooms, nouns, and creatures. The flag record also contains the - bit offset in the given byte. */ -/* This approach allows for a single property to be located in different - places for each of the three types of objects. */ -/* A value of -1 for any of the three fields indicates that this - property doesn't exist for the given type of object. */ - -typedef struct { - long r,n,c; - long str_cnt; /* values from 0..(str_cnt-1) have assoc strings */ - long str_list; /* Index into propstr[] array */ -} propdef_rec; - -typedef struct { - long r,n,c; - char rbit,nbit,cbit; - const char *ystr, *nstr; /* Yes and no strings */ -} attrdef_rec; - -typedef struct { - long str_cnt; - long str_list; -} vardef_rec; - - -typedef struct { - const char *ystr, *nstr; -} flagdef_rec; - -/* Metacommand headers and a pointer to the actual sequence of tokens - to execute if the metacommand is run. */ -typedef struct { - integer actor; /* Contains the actor object number; - 1==self(no explicit actor) 2=anybody - It is multiplied by negative one for redirected - commands */ - /* 0 in any of the following word variables denotes ANY; - -1 denotes <*none*> and will only occur in Magx-generated files. - (verbcmd cannot be equal to -1). Support for -1 is still experimental */ - word verbcmd, nouncmd, objcmd, prep; /* prep only in ME games */ - word noun_adj, obj_adj; /* Adjectives for noun and obj; not - supported in original AGT games */ - integer noun_obj, obj_obj; /* Actual object numbers, - or 0 if none specified */ - integer *data; /* MaxSizeCommand */ - integer cmdsize; /* Number of commands */ -/* integer ptr; */ /* In ME games-- see below for replacement */ -} cmd_rec; - - -/* FRS=file record size; these are the sizes to be allocated to the buffer - used to read in the various records from the files; they should be at - least as big as the worst case scenario. */ -#define FRS_ROOM 220 -#define FRS_NOUN 310 -#define FRS_CREAT 240 -#define FRS_CMD 150 - - -/* This is the record used to hold menu information for verbs */ -typedef struct { /*verb menu entry */ - word verb; /* Verb word */ - word prep; /* Associated preposition */ - short objnum; /* Number of objects */ -} verbentry_rec; - - -/* This is the datatype that will be used (tenatively) for hint info */ -/* This isn't implemented yet. */ -typedef struct { - integer dtype; /* The hint element type */ - integer child; /* The hint element value */ - char *name; /* The hint element name */ -} hint_rec; - - -/* This is the data type used to hold information about - built-in attributes and properties */ -typedef struct { - char *name; /* Property name. */ - int room,noun,creature; /* Offsets for the various object types. */ -} prop_struct; - - -/* The following data structure is used to store info on fields of a struct - that may need to be read from/written to a file. */ -/* They are used by both the AGX and the Savefile routines */ -/* They should be organized in ftype==0 terminated arrays, - in the order they occur in the file (the file is assumed to have - no padding, so we don't need file offsets: they can be computed) */ -/* The following is used for both global variables and fields in - structures. For global variables, ptr is set to point at the variable - and offset is 0. For fields, offset is set to the offset of the field - in the structure and ptr is set internally */ -typedef struct { - int ftype; /* Type in file */ - int dtype; /* Data type of field in memory; often ignored */ - void *ptr; /* Pointer to variable */ - size_t offset; /* Offset of field in structure */ -} file_info; - - - -/* This contains all of the information needed to find files. */ -#ifndef REPLACE_FC -typedef struct { - char *gamename; /* Name as entered by user */ - char *path; /* The path */ - char *shortname; /* The filename w/o directory information */ - char *ext; /* The preexisting extension/prefix */ - filetype ft; /* The filetype corresponding to ext */ - int special; /* Used to mark special files, such as UNIX pipes */ -} file_context_rec; - -typedef file_context_rec *fc_type; - -#endif - - -/* ------------------------------------------------------------------- */ -/* GLOBAL VARIABLES */ -/* ------------------------------------------------------------------- */ - -/* ------------------------------------------------------------------- */ -/* Flags used internally by the interpreter and reading routines */ - -global uchar DIAG, interp_arg, debug_da1, RAW_CMD_OUT; -global int ERR_LEVEL; - -global rbool agx_file; /* Are we reading an AGX file? */ -global rbool have_opt; /* Do we have an OPT file? */ -global rbool skip_descr; /* Causes read_filerec() to skip over description - pointers without actually reading them in. - Used to support RESTORE for multi-part games - such as Klaustrophobia */ -global rbool no_auxsyn; /* Prevents building of auxsyn and preplist - synonym lists; used by agt2agx. */ - - -global rbool BATCH_MODE, make_test; -/* These indicates we are in testing mode: - -- The random number generator should be set to a standard state. - -- Automatically send output to .scr - -- Automatically read/write input from .log - (depending on whether we are in BATCH_MODE or make_test mode, - respectivly). -*/ - - -/* ------------------------------------------------------------------- */ -/* Flags reflecting game version and configuration */ - -global rbool have_meta; /* Do we have any metacommands? */ -global rbool debug_mode, freeze_mode, milltime_mode, bold_mode; -global uchar score_mode, statusmode; -global rbool intro_first; -global rbool box_title; -global rbool mars_fix; -global rbool fix_ascii_flag; /* Translate IBM characters? - Defaults to fix_ascii #define'd above */ -global rbool dbg_nomsg; /* Causes printing of arguments by - debug disassembler to be supressed */ - -global rbool irun_mode; /* If true, all messages will be in 1st person */ -global rbool verboseflag; - -global int font_status; /* 0=unknown; 1=force fixed font, - 2=allow proportional font. */ - - -/* The following are AGT 'purity' flags; they turn off features of */ -/* my interpreter that are not fully consistent with the original AGT. */ -/* They are defined in auxfile.c (see also interp.h and agil.c for */ -/* interpreter-specific flags) */ -/* Anything added here should also be correctly initialized in agt2agx */ - -extern rbool PURE_ANSWER, PURE_TIME, PURE_ROOMTITLE; -extern rbool PURE_AND, PURE_METAVERB, PURE_ERROR; -extern rbool PURE_SYN, PURE_NOUN, PURE_ADJ, PURE_SIZE; -extern rbool PURE_DUMMY, PURE_SUBNAME, PURE_PROSUB; -extern rbool PURE_HOSTILE, PURE_GETHOSTILE; -extern rbool PURE_DISAMBIG, PURE_ALL, PURE_OBJ_DESC; -extern rbool PURE_GRAMMAR, PURE_SYSMSG, PURE_AFTER; -extern rbool PURE_PROPER; - -extern rbool TWO_CYCLE, FORCE_VERSION; -extern rbool MASTERS_OR; - -/* ------------------------------------------------------------------- */ -/* Variables containing limits and counts of objects */ - -global integer FLAG_NUM, CNT_NUM, VAR_NUM; /* (255, 50, 50) */ -global integer MAX_USTR; /* Maximum number of user strings (25) */ -global integer MAX_SUB; /* Number of subroutines (15) */ -global integer DVERB; /* Number of real dummy_verbs (50) */ -global integer NUM_ERR; /* For ME is 185 */ - -/* Number of objflags and objprops for each type of object */ -/* The flag counts are for groups of 8 flags. */ -global integer num_rflags, num_nflags, num_cflags; -global integer num_rprops, num_nprops, num_cprops; -global integer oprop_cnt, oflag_cnt; /* Size of flag and property tables */ - -global integer maxroom, maxnoun, maxcreat; -global long MaxQuestion; -global integer first_room, first_noun, first_creat, last_obj; -global long last_message, last_cmd; -global long numglobal; /* Number of global nouns */ -global long maxpict, maxpix, maxfont, maxsong; -global long num_prep; /* Number of user-defined prepositions */ -global int num_auxcomb; -global int num_comb; - -global integer exitmsg_base; /* Number added to messages used as - "illegal direction" messages */ - - -/* ------------------------------------------------------------------- */ -/* Miscellaneous other variables read in from the game file */ - -global integer start_room, treas_room, resurrect_room, max_lives; -global long max_score; -global integer start_time, delta_time; - -/* ver contains the size of the game, aver indicates its version */ -/* See the #define's below for details */ -global int ver,aver; /* ver: 0=unknown, 1=small, 2=big, 4=masters1.5 */ -global long game_sig; /* 2-byte quantity used to identify game files */ - /* (It's declared long to avoid overflow problems when - computing it) */ -global int vm_size; /* Size of verb menu */ - -global int min_ver; /* Lowest version of AGiliTy this will run on. */ - -/* ------------------------------------------------------------------- */ -/* Miscellaneous Game Data Structures */ - -/* All of the following are allocated dynamically */ -global room_rec *room; /* [MAX_ROOM]; */ -global creat_rec *creature; /* [MAX_CREAT]; */ -global noun_rec *noun; /* [MAX_NOUN]; */ -global cmd_rec *command; - -global unsigned char *objflag; -global long *objprop; - -/* Next we have tables linking abstract flag/property values to - the indices with the objflag/objprop arrays. */ -global attrdef_rec *attrtable; -global propdef_rec *proptable; -global vardef_rec *vartable; /* For itemized variables */ -global flagdef_rec *flagtable; - -/* Output strings associated with various property values. */ -/* See propdef_rec */ -global const char **propstr; -global long propstr_size; - -global tline *userstr; /*[MAX_USTR];*/ -global word *sub_name; /* [MAX_SUB] Dictionary id's of all subroutines */ - -/* Verb information */ -global verbentry_rec *verbinfo; /* Verb information */ -global short *verbptr,*verbend; /* [TOTAL_VERB] */ -global slist *synlist; /* [MAX_VERBS+1];*/ -global slist *comblist; /* Global combination list */ -global word *old_agt_verb; /* List of non-canonical verb synonyms in the - original AGT; these are not allowed to be - expanded as dummy verbs. */ - - -global slist *userprep; /* Array of user-defined prepostions */ - -global word flag_noun[MAX_FLAG_NOUN],*globalnoun; -global word pix_name[MAX_PIX]; -global filename *pictlist,*pixlist,*fontlist,*songlist; - -global uchar opt_data[14]; /* Contents of OPT file. For the format of this - block, see the comments to read_opt() in - agtread.c */ - -/* These are built by reinit_dict */ - -global slist *auxsyn; /* [TOTAL_VERB] Built-in synonym list */ -global slist *preplist; /* [TOTAL_VERB] */ -global uchar *verbflag; /* [TOTAL_VERB] Verb flags; see below */ -global slist *auxcomb; /* Built-in combination lists (for multi-word - verbs) */ - -#ifdef PATH_SEP -global char **gamepath; -#endif - -/* ------------------------------------------------------------------- */ -/* Description Pointers */ - - -global descr_ptr intro_ptr; -global descr_ptr title_ptr, ins_ptr; /* Only defined if agx_file is true */ -global descr_ptr *err_ptr; /* [NUM_ERR];*/ - -global descr_ptr *msg_ptr; /* [MAX_MSG];*/ -global descr_ptr *help_ptr, *room_ptr, *special_ptr; /*[ROOM] */ -global descr_ptr *noun_ptr, *text_ptr, *turn_ptr, /* [NOUN] */ - *push_ptr, *pull_ptr, *play_ptr; -global descr_ptr *talk_ptr, *ask_ptr, *creat_ptr; /* [CREAT] */ - -global descr_ptr *quest_ptr, *ans_ptr; /* [MAX_QUEST] */ -global tline *question, *answer; /* [MAX_QUEST] */ - - - -/* ------------------------------------------------------------------------ */ -/* Dynamically allocated data blocks (which are pointed to from elsewhere) */ - -global char **dict; /* dict[n] points to the nth dictionary word */ -global long dp; /* Dictionary pointer: number of words in dict */ - -#define DICT_INIT 12*1024 /* Starting size of dictstr */ -#define DICT_GRAN 1024 /* Granularity of dictstr size requests - must be at least 4. */ -global char *dictstr; /* Pointer to memory block containing dict words */ -global long dictstrptr, dictstrsize; - /* dictstrptr points to the first unused byte in dictstr. - dictstrsize points to the end of the space currently allocated for - dictstr. - */ - -global char *static_str; /*Static string space */ -global long ss_end; /* Pointer to end of used space in above */ -global long ss_size; /* Current size of static string space */ - -global word *syntbl; /* Synonym list space */ -global slist synptr; /* Points to end of used space */ -global long syntbl_size; /* Long so we can catch overflows */ - -global long descr_maxmem; -global char *mem_descr; /* Copy of descriptor in memory */ - - - -/* ------------------------------------------------------------------------ */ -/* Data structures used internally by agtread.c */ - -/*The following are all set to NULL after agtread finishes. */ -global long *cmd_ptr; /* ME only;Points to cmd start locs in gamefile.*/ -global long *room_name,*noun_sdesc,*noun_pos,*creat_sdesc; -global long *t_pictlist, *t_pixlist, *t_songlist, *t_fontlist; - -/* These are only used by agtout (to allow the AGT reading routines to - pass back the count of nouns inside the given object) */ -global integer *room_inside, *noun_inside, *creat_inside; - -/* This is used to translate ASCII codes */ -global uchar fixchar[256]; - -global rbool text_file; /* Set if we are currently opening a binary file. */ -#ifdef OPEN_AS_TEXT -global rbool open_as_binary; /* Open text files as binary, anyhow. */ -#endif - - -/* ------------------------------------------------------------------ */ -/* SYMBOLIC CONSTANTS: VERSION CODES */ -/* These are the values stored in the variable 'aver'. */ -/* ------------------------------------------------------------------ */ - -#define AGT10 1 /* SPA */ -#define AGT118 2 /* TAMORET, PORK II */ -#define AGT12 3 /* SOS,... */ -#define AGTCOS 4 /* COSMOS and SOGGY: enhanced versions of 1.3x */ -#define AGT135 5 /* By far the most common version; includes practically - every version of Classic AGT from 1.19 to 1.7 */ -#define AGT182 6 -#define AGT183 7 -#define AGT15 8 /* HOTEL */ -#define AGT15F 9 /* MDTHIEF */ -#define AGT16 10 /* PORK */ -#define AGTME10 11 /* CLIFF2, ELF20 */ -#define AGTME10A 12 /* HURRY */ -#define AGTME15 13 /* WOK */ -#define AGTME155 14 /* TJA */ -#define AGTME16 15 /* also includes v1.56 and 1.7 */ -#define AGX00 16 /* Tenative */ - -#define AGTMAST AGTME16 -#define AGTCLASS AGT16 /* Dividing line between master's ed and classic */ -#define AGT18 AGT182 /* Defines lowest 1.8x version */ -#define AGT18MAX AGT183 /* Defines the highest 1.8x version */ -#define AGTSTD AGT135 /* "Default" version of AGT */ - - - -/* ------------------------------------------------------------------ */ -/* SYMBOLIC CONSTANTS: ARGUMENT TYPES */ -/* These are used to encode the argument types of metacommands for */ -/* opcode tables. */ -/* ------------------------------------------------------------------ */ - -#define AGT_UNK 0 /* Unknown argument type */ - -/* The following can all mix and match in various ways and so are - put together as powers of two. */ -#define AGT_NONE 1 /* 0 is allowed */ -#define AGT_SELF 2 /* 1 is allowed */ -#define AGT_WORN 4 /* 1000 is allowed */ -#define AGT_ROOM 8 /* A room # is allowed */ -#define AGT_ITEM 16 /* An item # is allowed */ -#define AGT_CREAT 32 /* A creature # is allowed */ - -/* AGT_VAR is special, since it is always combined with another type-- - the type that the variable is expected to be */ -#define AGT_VAR 64 - -/* The rest of the values are always distinct; they never mix and so - they can be given simple consecutive indices */ -#define AGT_NUM 128 -#define AGT_FLAG 129 -#define AGT_QUEST 130 /* Question */ -#define AGT_MSG 131 /* Message */ -#define AGT_STR 132 /* String */ -#define AGT_CNT 133 /* Counter */ -#define AGT_DIR 134 /* Direction */ -#define AGT_SUB 135 /* Subroutine */ -#define AGT_PIC 136 /* Picture */ -#define AGT_PIX 137 /* Room picture */ -#define AGT_FONT 138 -#define AGT_SONG 139 -#define AGT_ROOMFLAG 140 -#define AGT_TIME 141 -#define AGT_ERR 142 -#define AGT_OBJFLAG 143 /* User defined object flags */ -#define AGT_OBJPROP 144 /* User defined object properties */ -#define AGT_ATTR 145 /* Built-in attribute */ -#define AGT_PROP 146 /* Built-in property */ - - -/* These next three may not occur as operand types */ -#define AGT_EXIT 147 /* Valid values for an exit: room, msg+msgbase, 0 */ -#define AGT_GENFLAG 148 /* PIX or Room Flag; used internally by compiler */ -#define AGT_GENPROP 149 /* ObjProp/Property */ - -/* certain restrictions. Used internally - by the compiler in the parsing - of "[obj].[prop].[prop].[flag]" - constructions. */ - -#define AGT_LVAL 150 /* Used by the compiler in certain psuedo-ops */ - - -#define AGT_DEFINE 256 - - - -/* ------------------------------------------------------------------ */ -/* Verb flags for verbflag[]; these should be powers of 2 */ - -#define VERB_TAKEOBJ 1 -#define VERB_META 2 -#define VERB_MULTI 4 /* Can the verb take mulitple objects? */ -#define VERB_GLOBAL 8 /* Does the verb have global scope? */ - -/* ------------------------------------------------------------------ */ -/* SYMBOLIC CONSTANTS: FILE DATA TYPES */ -/* Data type specifiers for file i/o routines */ -/* The FT_* constants specify file data types */ -/* The DT_* constants specify internal data types */ -/* ------------------------------------------------------------------ */ - -#define FT_COUNT 17 /* Number of file data types */ - -#define FT_END 0 /* End of list of fields/variables in file */ -#define FT_INT16 1 /* DT_SHORT */ -#define FT_UINT16 2 /* DT_LONG */ -#define FT_INT32 3 /* DT_LONG */ -#define FT_UINT32 4 -#define FT_BYTE 5 /* aka uchar; DT_UCHAR */ -#define FT_VERSION 6 /* Game version */ -#define FT_BOOL 7 /* DT_BOOL. Adjacent rbooleans are packed */ -#define FT_DESCPTR 8 /* DT_DESCPTR */ -#define FT_STR 9 /* Integer pointer into static string array */ -#define FT_SLIST 10 /* Synonym list index */ -#define FT_WORD FT_INT16 /* Index into dictionary */ -#define FT_PATHARRAY 11 /* 13 integers in an array of directions */ -#define FT_CMDPTR 12 /* Pointer into command block */ -#define FT_DICTPTR 13 /* Pointer into dictionary text */ -#define FT_TLINE 14 /* TextLine */ -#define FT_CHAR 15 /* Characters. */ -#define FT_CFG 16 /* Configuration byte; 0=false, 1=true, - 2=none (don't change) */ - -#define DT_DEFAULT 0 /* Default internal type for */ -#define DT_LONG 1 -#define DT_DESCPTR 2 /* Description pointer, which are treated specially */ -#define DT_CMDPTR 3 /* Command block pointer, also treated specially */ - -/* This is the end marker for the file definitions used by the file I/O - routines */ -#define endrec {FT_END,0,NULL,0} - - -/* ------------------------------------------------------------------- */ -/* Date type macros */ -/* ------------------------------------------------------------------- */ -#define troom(x) ((x)>=first_room && (x)<=maxroom) -#define tnoun(x) ((x)>=first_noun && (x)<=maxnoun) -#define tcreat(x) ((x)>=first_creat && (x)<=maxcreat) - - -/* ------------------------------------------------------------------- */ -/* FUNCTION PROTOTYPES AND INITIALIZED TABLES */ -/* ------------------------------------------------------------------- */ - -/* This is intended for removing whitespace in AGT data files. */ -#define rspace(c) ((c)==' ' || (c)=='\t') - -/* ------------------------------------------------------------------- */ -/* In GAMEDATA.C */ -/* This module contains the major initialized data structures and */ -/* routines to manipulate game data structures, in particular the */ -/* game's dictionary */ -/* ------------------------------------------------------------------- */ - -void init_dict(void); /* 1=set of verblist, 0=don't */ -void build_verblist(void); /* Creates verblist */ -void reinit_dict(void); -void free_dict(void); -word search_dict(const char*); -word add_dict(const char*); -const char *gdict(word w); /* Almost equivalent to dict[w], but with - some error checking and handling for - the w==-1 case. */ - -int verb_code(word); -int verb_builtin(word); -int verb_authorsyn(word); -void addsyn(word); -slist add_multi_word(word); - -/* Commands to manipulate object flags */ -long objextsize(char op); -long op_objprop(int op, int obj, int propid, long val); -rbool op_objflag(int op, integer obj, int flagid); -long lookup_objflag(int id, int t, char *ofs); -long lookup_objprop(int id, int t); -rbool have_objattr(rbool prop,integer obj,int id); -int num_oattrs(int t, rbool isflag); -rbool op_simpflag(uchar *flag, char ofs, int op); - /* op: 0=clear, 1=set, 2=nop, 3=toggle two bits: */ -const char *get_objattr_str(int dtype,int id,long val); - - -const opdef *get_opdef(integer op); -char *objname(int); -void sort_cmd(void); - -void agtwarn(const char*,int elev); -void agtnwarn(const char*,int,int elev); - -void init_flags(void); - -#ifdef ZIP -#define fatal agil_fatal -#endif -void fatal(const char*); - -long new_str(char *buff,int max_leng,rbool pasc); - -descr_line *read_descr(long start,long size); -void free_descr(descr_line *p); - -extern const char trans_ibm[]; -extern const char nonestr[]; - -/* Tables of opcodes */ -extern const opdef cond_def[], act_def[], end_def[], illegal_def; - -/* Table of built in properties and attributes */ -extern const prop_struct proplist[NUM_PROP]; -extern const prop_struct attrlist[NUM_ATTR]; - -global words *verblist; /* List of prexisting words, intialized by init_dict */ -extern const fix_array FIX_LIST[]; -extern const char *exitname[13]; -extern const char *verstr[], *averstr[]; -extern const char *version_str,*portstr; - - -/* ------------------------------------------------------------------- */ -/* In AGTREAD.C */ -/* Routines to read in AGT data files */ -/* ------------------------------------------------------------------- */ - -void open_descr(fc_type fc); -void close_descr(void); -descr_line *agt_read_descr(long start,long len); -rbool readagt(fc_type fc, rbool diag); -void free_all_agtread(void); /* Cleans up everything allocated in agtread - should only be called at the very end of - the program */ -void free_ttl(descr_line *title); - - -/* ------------------------------------------------------------------- */ -/* In AGXFILE.C */ -/* Routines to read and write AGX files */ -/* ------------------------------------------------------------------- */ - -int read_agx(fc_type fc, rbool diag); -descr_line *agx_read_descr(long start,long size); -void agx_close_descr(void); - -/* The following are in the order they should be called */ -void agx_create(fc_type fc); -void write_descr(descr_ptr *dp,descr_line *txt); -void agx_write(void); -void agx_wclose(void); -void agx_wabort(void); - -/* ------------------------------------------------------------------- */ -/* In AUXFILE.C */ -/* Routines to read VOC, OPT, CFG, TTL, INS, etc. files */ -/* ------------------------------------------------------------------- */ -void read_opt(fc_type fc); -void read_config(genfile cfgfile, rbool lastpass); -rbool parse_config_line(char *s, rbool lastpass); - -descr_line *read_ttl(fc_type fc); /* This returns the title. The return string - must be freed with free_ttl() and not - with free_descr */ -void free_ttl(descr_line *title); - -void read_voc(fc_type fc); -void init_verbrec(void); -void add_verbrec(char *verbline,rbool addnew); /* addnew should be 0 */ -void finish_verbrec(void); - -descr_line *read_ins(fc_type fc); -void free_ins(descr_line *instr); -rbool open_ins_file(fc_type fc, rbool report_error); -char *read_ins_line(void); /* Reuses buffer, so return value should be copied - if it needs to be used past the next call to - read_ins_line or close_ins_file */ -void close_ins_file(void); - -void build_fixchar(void); - -/* ------------------------------------------------------------------- */ -/* In or used by DISASSEMBLE.C */ -/* Routines to disassemble metacommands (used by the interpreter for */ -/* tracing and by agtout to produce the metacommand output). */ -/* ------------------------------------------------------------------- */ - -global rbool *dbgflagptr; -global long *dbgvarptr; -global short *dbgcntptr; - -void dbgprintf(const char *fmt,...); -void debugout(const char *s); -int argout(int dtype, int dval, int optype); - -/* ------------------------------------------------------------------- */ -/* In INTERFACE.C, AGIL.C and/or AGILSTUB.C */ -/* agilstub.c provides minimal versions of these routines for use by */ -/* programs other than the interpreter */ -/* ------------------------------------------------------------------- */ - -void writeln(const char *s); -void writestr(const char *s); -void agil_option(int optnum,char *optstr[], rbool setflag, rbool lastpass); -void close_interface(void); - -void print_tos(void); /* Called by the disassembler; in either TOKEN.C - or AGTOUT.C */ - - -/* ------------------------------------------------------------------- */ -/* In UTIL.C */ -/* Low-level utilites, including memory allocation, string manip., */ -/* and buffered file I/O. */ -/* ------------------------------------------------------------------- */ - -global uchar trans_ascii[256]; /* Table to translate ascii values read - in from file */ - -void build_trans_ascii(void); /* Set up the above table. */ - -void rprintf(const char *fmt, ...); /* General output routine, mainly used - for diagnostics. There can be a newline - at the end, but there shouldn't be - one in the middle of the string */ - - - -/* Memory management variables and routines */ - -extern rbool rm_trap; /* Trap memory allocation failures? */ -global rbool rm_acct; /* Turn on rmem accounting, to locate memory leaks */ -global long rfree_cnt, ralloc_cnt; /* # of allocs/frees since acct turned on */ -global long rm_size, rm_freesize; /* These hold worst case values */ - -long get_rm_size(void); /* These get the current values */ -long get_rm_freesize(void); -void *rmalloc(long size); -void r_free(void *p); -#define rfree(p) (r_free(p),p=NULL) /* Traps errors & catch memory leaks */ -void *rrealloc(void *p,long size); -char *rstrdup(const char *s); - - -/* String utilities */ - -char *concdup(const char *s1,const char *s2); /* Concacate and duplicate */ -char *rstrncpy(char *dest,const char *src,int max); - /* Copy at most max-1 characters */ -rbool match_str(const char **pstr,const char *match); - -#ifdef NEED_STR_CMP -int strcasecmp(const char *s1,const char *s2); -#endif -#ifdef NEED_STRN_CMP -int strncasecmp(const char *s1,const char *s2,size_t n); -#endif - - -/* The fixsign.. routines put together unsigned bytes to form signed ints */ - -#ifndef FAST_FIXSIGN -short fixsign16(uchar n1,uchar n2); -long fixsign32(uchar n1,uchar n2,uchar n3,uchar n4); -#else -#define fixsign16(u1,u2) ( (u1) | ((u2)<<8) ) -#define fixsign32(u1,u2,u3,u4) ( ((long)u1) | (((long)u2)<<8) | \ - (((long)u3)<<16) | (((long)u4)<<24) ) -#endif - - -/* Miscellaneous */ -long rangefix(long n); - -/* File routines */ -genfile openfile(fc_type fc,filetype ext,char *err,rbool ferr); -genfile openbin(fc_type fc,filetype ext,char *err,rbool ferr); - -char *readln(genfile f, char *buff, int n); - /* Read a line from a 'text' file */ - -/* (None of the following routines are at all reentrant) */ -long buffopen(fc_type fc, filetype ext, - long minbuffsize,char *rectype,long recnum); - /* Open file for our buffered routines and make it our current file; - returns the record size. Prints out error message on failure - rectype="noun","room",etc.; recnum=expected # of objects in file */ -uchar *buffread(long index); - /* seek to index*recsize, read buff_rsize bytes, return pointer to a - buffer with them. */ -void buffclose(void); /* Close the current file */ - -void bw_open(fc_type fc,filetype ext); /* Open buffered file for writing */ -void bw_close(void); /* Close buffered file */ -void bw_abort(void); /* Close and delete buffered file */ - -/* "Universal" file routines */ -extern const size_t ft_leng[FT_COUNT]; /* File lengths of the data types */ -long compute_recsize(file_info *recinfo); -void *read_recblock(void *base,int ftype,long numrec, long offset, - long blocksize); - /* Only works for FT_BYTE, FT_SLIST, FT_WORD, FT_DICTTEXT, FT_INT16 */ -void *read_recarray(void *base, long eltsize, long numelts, - file_info *field_info, char *rectype, - long file_offset,long file_blocksize); -void read_globalrec(file_info *global_info, char *rectype, - long file_offset, long file_blocksize); - -long write_recarray(void *base, long eltsize, long numelts, - file_info *field_info, long file_offset); -long write_globalrec(file_info *global_info, long file_offset); -long write_recblock(void *base,int ftype,long numrec, long offset); - -void set_internal_buffer(void *p); -/* Causes all of the above routines to write to the block of memory pointed - at by p instead of to a file */ - -#ifdef PROFILE_SUPPORT -/* These are functions to do quick-and-dirty timing of routines; - I added them to check the performance of the AGX code. - They aren't likely to work on anything other than a *nix box */ -void resetwatch(void); -void startwatch(void); -char *stopwatch(void); -char *timestring(void); -#define runwatch(cmd) do{resetwatch();cmd;printf("%s\n",stopwatch());}while(0) -#else -#define runwatch(cmd) cmd -#endif - - - -/* ------------------------------------------------------------------- */ -/* In FILENAME.C */ -/* The low-level file routines */ -/* ------------------------------------------------------------------- */ - -fc_type init_file_context(const char *game_name, filetype ft); -/* This sets up the filename system, based around a game with name - "gamename". Must be called before any of the following are called - with relative filetypes (all filetypes that depend on the game's - name and location-- everything but the global config file.) */ -/* ft indicates the file type class. At the moment, it can be - fAGX, fSAV, fSCR, fLOG - */ -void fix_file_context(fc_type fc, filetype ft); -fc_type convert_file_context(fc_type fc,filetype ft, const char *name); -void release_file_context(fc_type *pfc); - - -char *formal_name(fc_type fc, filetype ft); /* Used for messages */ -genfile badfile(filetype ft); /* Bad file of type ft */ -rbool fileexist(fc_type fc, filetype ft); - -genfile readopen(fc_type fc, filetype ft, char **errstr); -genfile writeopen(fc_type fc, filetype ft, - file_id_type *pfileid, char **errstr); -rbool filevalid(genfile f, filetype ft); -void readclose(genfile f); -void writeclose(genfile f, file_id_type fileid); - -void binremove(genfile f, file_id_type fileid); -void binseek(genfile f, long offset); -rbool binread(genfile f, void *buff, long recsize, long recnum, char **errstr); -long varread(genfile f, void *buff, long recsize, long recnum, char **errstr); -rbool binwrite(genfile f, void *buff, long recsize, long recnum, rbool ferr); -long binsize(genfile f); /* Size of an open binary file */ - -rbool textrewind(genfile f); - -char *assemble_filename(const char *path, const char *root, - const char *ext); - - -#ifdef global_defined_agtread -#undef global -#undef global_defined_agtread -#endif - - - diff --git a/app/src/main/jni/terps/agility/agility.hdr b/app/src/main/jni/terps/agility/agility.hdr deleted file mode 100644 index 3611789..0000000 --- a/app/src/main/jni/terps/agility/agility.hdr +++ /dev/null @@ -1,32 +0,0 @@ -# -# IFP header definitions for AGiliTy 1.1.1. -# -# The AGT game file format comes in two types. The original format is -# a whole cluster of files. One of these is game.d$$, and this always -# begins with ".. >> Temporary...". Once found, we can invoke the inter- -# preter with the path to this file, and it will strip the unwanted -# extension and run the right game. The other format is AGX, as defined -# by AGiliTy. This is easier to spot - it begins "58 C7 C1 51". -# -IFP_ENGINE_TYPE="AGT" -IFP_ENGINE_NAME="AGiliTy" -IFP_ENGINE_VERSION="1.1.1" - -IFP_ACCEPTOR_OFFSET=0 -IFP_ACCEPTOR_LENGTH=6 -IFP_ACCEPTOR_PATTERN="^(58 C7 C1 51 .. ..|.. 20 3E 3E 20 54)$" - -IFP_AUTHOR_NAME="Robert Masenten" -IFP_AUTHOR_EMAIL="rcm-math@pacbell.net" -IFP_ENGINE_HOME_URL=\ -"ftp://ftp.ifarchive.org/if-archive/programming/agt/agility/" - -IFP_BUILDER_NAME="Simon Baldwin" -IFP_BUILDER_EMAIL="simon_baldwin@yahoo.com" - -IFP_ENGINE_DESCRIPTION=\ -"This is an interpreter for game files created with Malmberg and - Welch's _Adventure Game Toolkit_. AGiliTy is universal in the sense - that it understands and interprets most of the many versions of the - AGT game file format.\n" -IFP_ENGINE_COPYRIGHT="Copyright (C) 1996-1999,2001 by Robert Masenten.\n" diff --git a/app/src/main/jni/terps/agility/agilstub.c b/app/src/main/jni/terps/agility/agilstub.c deleted file mode 100644 index fed3c0b..0000000 --- a/app/src/main/jni/terps/agility/agilstub.c +++ /dev/null @@ -1,36 +0,0 @@ -/* agilcomp.c-- Stubs for routines defined in agil but */ -/* refered to elsewhere. */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ - -/* This is part of the source for AGiliTy: the (Mostly) */ -/* Universal AGT Interpreter */ - -#include "agility.h" - -void debugout(const char *s) -{ - fputs(s,stdout); -} - -void writestr(const char *s) -{ - fputs(s,stdout); -} - -void writeln(const char *s) -{ - printf("%s\n",s); -} - -void agil_option(int optnum,char *optstr[], rbool setflag, rbool lastpass) -{ - /* Do nothing; this is just a place holder */ -} - -void close_interface(void) -{ -} - - diff --git a/app/src/main/jni/terps/agility/agt2agx.c b/app/src/main/jni/terps/agility/agt2agx.c deleted file mode 100644 index 2349fe8..0000000 --- a/app/src/main/jni/terps/agility/agt2agx.c +++ /dev/null @@ -1,297 +0,0 @@ -/* AGT2AGX, AGT to AGX file converter */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy, the (Mostly) Universal */ -/* AGT Interpreter */ -#include - -#define global -#include "agility.h" - - - -static long cntvar, cntflag, cntcnt, cntquest, cntstr, cntsub; -/* We can't count messages because they can be referenced by variable */ - -#define m(cnt) do {if (arg>cnt) cnt=arg; return;} while(0) - -void check_arg(integer argtype, integer arg) -{ - if (argtype & AGT_VAR) argtype=AGT_VAR; - switch(argtype) - { - case AGT_VAR:m(cntvar); - case AGT_FLAG:m(cntflag); - case AGT_CNT:m(cntcnt); - case AGT_QUEST:m(cntquest); - case AGT_STR:m(cntstr); - case AGT_SUB:m(cntsub); -#if 0 /* These are already taken care of AFAIK */ - case AGT_PIC:m(cntpic); - case AGT_PIX:m(cntpix); - case AGT_FONT:m(cntfont); - case AGT_SONG:m(cntsong); - case AGT_ROOMFLAG:m(cntroomflag); -#endif - default:break; - } -} - -#undef m - -/* AGT stores a lot of junk in the command blocks. This shortens the - command blocks to their real length (Determined by scanning for - end markers). */ -/* This also analyzes commands to determine the maximum - variable,flag,counter,question,and userstr used. */ -void truncate_cmd(void) -{ - int i, j; - const opdef *opdata; - - cntvar=cntflag=cntcnt=cntquest=cntstr=cntsub=0; - - for(i=0;i=END_ACT) break; - opdata=get_opdef(command[i].data[j++]); - if (opdata==&illegal_def) - agtwarn("Illegal opcode found.",1); - - if (j+opdata->argnum>command[i].cmdsize || - opdata==&illegal_def) { - j=command[i].cmdsize; /* To prevent cmdsize from being changed */ - if (!(opdata==&illegal_def)) - agtwarn("Command block overrun",0); - break; - } - /* Note: j now points to the token *after* the opcode */ - if (opdata->argnum>=1) { - check_arg(opdata->arg1,command[i].data[j++]); - if (opdata->argnum>=2) - check_arg(opdata->arg2,command[i].data[j++]); - } - } - if (jcntvar) VAR_NUM=cntvar; - if (FLAG_NUM>cntflag) FLAG_NUM=cntflag; - if (CNT_NUM>cntcnt) CNT_NUM=cntcnt; - if (MAX_USTR>cntstr) MAX_USTR=cntstr; - if (MAX_SUB>cntsub) MAX_SUB=cntsub; - if (MaxQuestion>cntquest) MaxQuestion=cntquest; -} - - -/* This transfers descriptions from an AGT D$$ file to our AGX file */ -/* Note that this overwrites the descr_ptr it is sent */ -void copydesc(descr_ptr *descp,int num) -{ - int i; - descr_line *txt; - - if (num<=0 || descp==NULL) return; - for(i=0;i \n"); - printf("Options:\n"); - printf("(all of these can be turned off by putting a - after the option)\n"); - printf("-h Print this help message.\n"); - printf("-o Specify output file root.\n"); -#ifdef OPEN_AS_TEXT - printf(" -b Open data files as binary files.\n"); -#endif -} - -char *outname; /* Name of output file */ - -int parse_options(char *opt,char *next) -{ - if (opt[0]=='-' && opt[1]==0) /* -- */ - {end_cmd_options=1;return 0;} - for(;*opt!=0;opt++) - switch(tolower(*opt)) - { - case '?': case 'h': - helpmsg(); - exit(EXIT_SUCCESS); - case 'i': - if (opt[1]=='-') {DIAG=0;opt++;} - else if (opt[1]=='+') {DIAG=1;opt++;} - else DIAG=1; - break; -#ifdef OPEN_FILE_AS_TEXT - case 'b': - if (opt[1]=='-') {open_as_binary=0;opt++;} - else if (opt[1]=='+') {open_as_binary=1;opt++;} - else open_as_binary=1; - break; -#endif - case 'o': - if (opt[1]!=0 || next!=NULL) { - if (opt[1]!=0) outname=opt+1; - else outname=next; - return (opt[1]==0); /* Skip next argument if opt[1]==0 */ - } else { - printf("-o requires a file name\n"); - exit(EXIT_FAILURE); - } - default:printf("Do not recognize option %c\n",*opt); - helpmsg(); - exit(EXIT_FAILURE); - } - return 0; -} - - -int main(int argc,char *argv[]) -{ - int i; - char *gamefile; - fc_type fc, fc_out; - - end_cmd_options=0; - - init_flags(); - - no_auxsyn=1; - fix_ascii_flag=0; /* We don't want to translate the character - set when we're converting files */ - - /* Mark all of the purity settings as "undecided" */ - PURE_ANSWER=PURE_TIME=PURE_ROOMTITLE=2; - PURE_AND=PURE_METAVERB=PURE_SYN=PURE_NOUN=PURE_ADJ=2; - PURE_DUMMY=PURE_SUBNAME=PURE_PROSUB=PURE_HOSTILE=2; - PURE_GETHOSTILE=PURE_DISAMBIG=PURE_ALL=2; - irun_mode=verboseflag=2; - - build_trans_ascii(); - - printf("agt2agx: Convert AGT game files into AGX files\n"); - printf("%s\n",version_str); - printf(" Copyright (C) 1996-1999,2001 Robert Masenten\n"); - printf("[%s]\n\n",portstr); - - outname=gamefile=NULL; - for(i=1;i -#define global -#include "agility.h" - -#define AGX_DESC 1 - -/* These are for the sake of the disassembler */ -integer dobj=0, iobj=0, actor=0; - - - -/* DICTFIX */ - -#define verbose_dump 1 - -rbool printmsg, printdict, sortflag; -global rbool dbg_msgrange; /* Print the range of messages for - RandomMessage (only checked if - dbg_nomsg isn't set) */ -global rbool quick_rndmsg; /* Don't give RandomMessage special treatment. */ -global rbool no_badobj; /* Filter out objects with garbage names. */ - -long msgcnt(int ver,int aver) -{ - switch(ver) { - case 1:return 250; - case 2:if (aver==AGTCOS) return 700; /* Cosmosrv */ - else if (aver<=AGT12) return 500; - else return 600; /* 500? */ - case 3:return 700; - case 4:return 900; - } - printf("INTERNAL ERROR: Invalid VER\n"); - return 0; -} - -long cmdcnt(int ver,int aver) -{ - switch(ver) { - case 1:return 400; - case 2: if (aver==AGTCOS) return 1100; - else return 900; /* 700? */ - case 3:return 900; - case 4:return 1500; - } - printf("INTERNAL ERROR: Invalid VER\n"); - return 0; - - -} - -long cmdsize(void) -{ - int i; - long size; - - size=0; - for(i=0;i60) { - printf("\n"); - x=0; - } -} - - -void nprintopt(char *s, char opt) -{ - if (opt==1) opt=0; - else if (opt==0) opt=1; - printopt(s,opt); -} - - -void info_out(void) -{ - integer creatcnt; - long tmp; - - printf("\nGeneral Information:(ver=%d, aver=%d)\n",ver,aver); - printf("Signature: %ld\n",game_sig); - printf("AGT Version %s, (Size:%s)\n",averstr[aver],verstr[ver]); - printf("\tStart room: %d Treas Room: %d Resurrect Room: %d\n", - start_room,treas_room,resurrect_room); - printf("\tLives: %d Max Score: %ld\n",max_lives,max_score); - printf("\t"); - if (debug_mode) printf("\t"); - if (have_meta) printf("\t"); - if (freeze_mode) printf("\t"); - if (mars_fix) printf("\t"); - printf("Status Mode %d Score mode %d",statusmode,score_mode); - printf(" Time %d+%d\n",start_time,delta_time); - if (milltime_mode) printf("\t"); - printf("\n"); - printf("Ranges-- Room: %d..%d Noun: %d..%d Creature: %d..%d\n", - first_room,maxroom,first_noun,maxnoun,first_creat,maxcreat); - printf(" ExitMsg Base:%d\n",exitmsg_base); - printf("Max--\tVars: %d Counters: %d Flags: %d User Strings: %d\n", - VAR_NUM, CNT_NUM, FLAG_NUM, MAX_USTR); - printf("\tMetacommands: %ld Subroutines: %d Error Messages: %d\n", - last_cmd, MAX_SUB, NUM_ERR); - if (aver>=AGTME10) - printf("\tGlobal Nouns: %ld Picts: %ld RoomPIXs: %ld Fonts: %ld " - "Songs: %ld\n", - numglobal,maxpict,maxpix,maxfont,maxsong); - if (aver>=AGX00) { - printf("\tObject flags: %d/%d/%d \tObject Props: %d/%d/%d\n", - 8*num_rflags,8*num_nflags,8*num_cflags, - num_rprops,num_nprops,num_cprops); - printf("\t(Total ObjFlags: %d \tTotal ObjProps: %d )\n", - oflag_cnt,oprop_cnt); - } - printf("\tVocabulary: %ld\n",dp); - printf("\n"); - printf("\nStatistics:\n"); - printf(" Static String Size: %6ld Syntbl Size: %6ld\n", - ss_end,((long)synptr)*sizeof(word)); - if (maxcreat>=first_creat) creatcnt=maxcreat-first_creat+1; - else creatcnt=0; - printf(" Data size-- Room: %5ld Noun: %5ld Creat: %5ld\n", - sizeof(room_rec)*(long)(maxroom-first_room+1), - sizeof(noun_rec)*(long)(maxnoun-first_noun+1), - sizeof(creat_rec)*(long)creatcnt); - tmp=cmdsize(); - printf(" Commands: Headers: %5ld Text: %5ld Total: %5ld\n", - sizeof(cmd_rec)*last_cmd,tmp,sizeof(cmd_rec)*last_cmd+tmp); - printf(" Dictionary: Dict: %5ld Text: %5ld(%5ld) Tot: %5ld\n", - ((long)dp)*sizeof(char*), - dictstrptr,dictstrsize,dp*sizeof(char*)+dictstrptr); - printf("\n"); - printf(" Num of Objs-- Room: %3d/%3d Noun: %3d/%3d Creat: %3d/%3d\n", - maxroom-first_room+1, first_noun-first_room, - maxnoun-first_noun+1, first_creat-first_noun, - creatcnt, last_obj-first_creat+1); - printf(" Message: %3ld/%3ld Cmd: %4ld/%4ld\n", - last_message,msgcnt(ver,aver), last_cmd,cmdcnt(ver,aver)); - printf("\n"); - printf("Settings:\n"); - printopt(NULL,0); - printopt("INTRO_FIRST",intro_first); - printopt("SLASH_BOLD",bold_mode); - printopt("PURE_ANSWER",PURE_ANSWER); - nprintopt("CONST_TIME", PURE_TIME); - nprintopt("ROOMTITLE", PURE_ROOMTITLE); - nprintopt("FIX_MULTINOUN",PURE_AND); - nprintopt("FIX_METAVERB",PURE_METAVERB); - nprintopt("CHECK_GRAMMAR",PURE_GRAMMAR); - /* - printopt( PURE_SYN); - printopt( PURE_NOUN); - printopt( PURE_ADJ); - */ - printopt("PURE_DUMMY",PURE_DUMMY); - printopt("PURE_SUBNAME",PURE_SUBNAME); - nprintopt("PRONOUN_SUBS",PURE_PROSUB); - printopt("BLOCK_HOSTILE",PURE_HOSTILE); - printopt("GET_HOSTILE",PURE_GETHOSTILE); - nprintopt("SMART_DISAMBIG",PURE_DISAMBIG); - nprintopt("EXPAND_ALL",PURE_ALL); - printopt("IRUN",irun_mode); - printopt("VERBOSE",verboseflag); - printf("\n"); -} - - - -/* Doprint=0 ==>don't print, = 1: do print unless size 0, - =2: print regardless */ -void print_descr(char *name,descr_ptr dp, int doprint) -{ - int j; - descr_line *txt; - - if (doprint==0) return; - if (doprint==1 && dp.size==0) return; - - printf("%s (%ld,%ld)\n",name,dp.start,dp.size); - if (agx_file && !AGX_DESC) return; - txt=read_descr(dp.start,dp.size); - if (txt!=NULL) - for(j=0;txt[j]!=NULL;j++) - printf("%s\n",txt[j]); - free_descr(txt); -} - - -void dump_attr(int t, int objnum) - /* t=0 for room, 1 for noun, 2 for creature */ - /* objnum is the object index */ -{ - int i, line; - char ofs; - - if (num_oattrs(t,0)>0) { /* List flags */ - printf(" FLAGS:\n"); - line=0; - for(i=0;i0) { /* List properties */ - printf(" PROPS:\n"); - line=0; - for(i=0;i=AGTME10 || !no_badobj) - return 0; /* ME games shouldn't have gaps. */ - for(;*s!=0;s++) - if (*s<32) return 1; - return 0; -} - - -void rooms_out(void) -{ - long i,j; - - printf("\nRoom List:"); - for(i=0;i":noun[i].position); - printf(" Location:%d (behind %d) Points:%d", - noun[i].location,noun[i].nearby_noun,noun[i].points); - if (noun_inside!=NULL) - printf(" #Nouns=%d\n",noun_inside[i]); - else printf("\n"); - printf(" Wt=%d Size=%d Key:%d #Shots=%d\n", - noun[i].weight,noun[i].size,noun[i].key,noun[i].num_shots); - printf(" ATTR:"); - if (noun[i].plural) printf(" pl "); - else printf(" sing "); - if (noun[i].something_pos_near_noun) printf(" in_front "); - if (noun[i].win) printf(" WIN "); - if (noun[i].has_syns) printf(" syns "); - printf("\n CAN:"); - if (noun[i].pushable) printf(" push "); - if (noun[i].pullable) printf(" pull "); - if (noun[i].turnable) printf(" turn "); - if (noun[i].playable) printf(" play "); - if (noun[i].readable) printf(" read "); - if (noun[i].closable) printf(" close "); - if (noun[i].lockable) printf(" lock "); - if (noun[i].edible) printf(" eat "); - if (noun[i].wearable) printf(" wear "); - if (noun[i].drinkable) printf(" drink "); - if (noun[i].movable) printf(" move "); - printf("\n ATT2:"); - if (noun[i].on) printf(" on "); - if (noun[i].open) printf(" open "); - if (noun[i].locked) printf(" locked "); - if (noun[i].poisonous) printf(" poison "); - if (noun[i].light) printf(" light "); - if (noun[i].shootable) printf(" shoot "); - if (noun[i].isglobal) printf(" global "); - printf("\n"); - if (noun[i].has_syns) { - printf(" Syns:"); - print_slist(noun[i].syns);printf("\n"); - } - if (ver==3) - printf(" Initial=%d Picture=%d Related->%d\n", - noun[i].initdesc,noun[i].pict,noun[i].related_name); - dump_attr(1,i+first_noun); - if (verbose_dump) { - print_descr("DESCR:",noun_ptr[i],2); - print_descr("TEXT:",text_ptr[i],noun[i].readable); - print_descr("PUSH:",push_ptr[i],noun[i].pushable); - print_descr("PULL:",pull_ptr[i],noun[i].pullable); - print_descr("TURN:",turn_ptr[i],noun[i].turnable); - print_descr("PLAY:",play_ptr[i],noun[i].playable); - } - } -} - -void creat_out(void) -{ - int i; - printf("\n\nCreature List:"); - for(i=0;i0) { - printf("\n\nGLOBAL NOUNS:\n"); - for(i=0;ilast_message) return; - for(i=msg1;i<=msg2;i++) { - printf("\n\t"); - argout(AGT_MSG,i,0); - } -} - -void cmd_codes_out(integer *clist,int cnt) -{ - int ip,j; - const opdef *opdata; - char endflag; - char save_dbg_nomsg; - int op, optype; - - ip=0;endflag=0; - save_dbg_nomsg=0; /* Just to silence compiler warnings */ - while(ip=END_ACT) { /* End codes */ - /* Magx games support Goto commands, so we can't stop just - because we hit an end code-- it might be possible to jump - beyond it. */ - if (averopcode); - if (op==1063 && !quick_rndmsg) { - save_dbg_nomsg=dbg_nomsg; - dbg_nomsg=1; - } - for(j=0;jargnum;j++) { - printf("\t"); - if (iparg1 : opdata->arg2 , - ip>2); - optype=optype<<2; - } - if (op==1063 && !quick_rndmsg) { - dbg_nomsg=save_dbg_nomsg; - if (optype==0 && !dbg_nomsg && dbg_msgrange && ip>=2) - print_message_range(clist[ip-2],clist[ip-1]); - } - printf("\n"); - } - } -} - - - -void raw_cmd_codes_out(integer *clist,int cnt) -{ - int j,col; - - printf(" "); col=5; - for(j=0;j70) { - if (j>200) break; - printf("\n "); - col=5; - } - printf(" %04d",clist[j]);col+=6; - } - printf("\n"); - if (j!=cnt) - printf(" .... ....\n",cnt-j); -} - -/* This is called from the disassembler */ -void print_tos(void) -{ - printf("TOS"); /* Reference to the Top of Stack */ -} - -void commands_out(void) -{ - int i, v, a; - word w; - rbool noncanon; /* Header verb-code != verb-word */ - - printf("\nCommands:\n"); - if (last_cmd==0) { - printf("\n"); - return; - } - for(i=0;i=BASE_VERB && v0) { - printf("CMD %d: ",i); - a=command[i].actor; - } else { - printf("REDIR: "); - a=-command[i].actor; - } - if (a==2) - printf("anybody, "); - else if (a>2) { - char *name; - name=objname(a); - name[0]=toupper(name[0]); - printf("%s, ",name); - rfree(name); - } - - /* Now to print out the actually command to be matched. */ - printf("%s",dict[w]); - if (noncanon) printf("[%d]",v); - printf(" "); - if (command[i].noun_adj!=0) - printf("%s ",gdict(command[i].noun_adj) ); - printf("%s",gdict(command[i].nouncmd)); - if (command[i].noun_obj!=0) printf("[%d]",command[i].noun_obj); - printf(" %s ",(ver==3) ? gdict(command[i].prep) : "->"); - if (command[i].obj_adj!=0) - printf("%s ",gdict(command[i].obj_adj) ); - printf("%s",gdict(command[i].objcmd) ); - if (command[i].obj_obj!=0) printf("[%d]",command[i].obj_obj); - - if (ver==3 ||agx_file) printf(" ===> %lx (%lx) [%d]\n",cmd_ptr[i], - cmd_ptr[i]*2-2,command[i].cmdsize); - else - printf("\n"); - if (!RAW_CMD_OUT) - cmd_codes_out(command[i].data,command[i].cmdsize); - else - raw_cmd_codes_out(command[i].data,command[i].cmdsize); - } -} - - -void strings_out(void) -{ - int i; - printf("\n\nStrings:\n"); - if (userstr!=NULL) - for(i=0;i\n"); - printf("\n"); -} - -void msg_out(void) -{ - int i; - char s[50]; - - printf("\n\nMessages:\n"); - for(i=0;i\n"); - return; - } - for(i=0;i=AGTME10) num_verb+=MAX_SUB; - - build_verblist(); - - printf("\nSynonyms:\n"); - for(i=0;i0) { - propstr_out(vartable[i].str_list,vartable[i].str_cnt); - printf("\n"); - } - } - } - if (flagtable) { - printf("\n\nItemized Flags:\n"); - for(i=0;i<=FLAG_NUM;i++) { - printf("%3d: ",i); - if (flagtable[i].ystr!=NULL || flagtable[i].nstr!=NULL) { - printf("\"%s\" / \"%s\"",flagtable[i].ystr,flagtable[i].nstr); - printf("\n"); - } - } - } -} - - - - -rbool end_cmd_options; - -void helpmsg(void) -{ - printf("Syntax: agtout \n"); - printf("Options:\n"); - printf("(all of these can be turned off by putting a - after the option)\n"); - printf("-v Verbose: equivalent to -dmia\n"); - printf("-i Print basic diagnostic information\n"); - printf("-d Print out dictionary\n"); - printf("-m Dump messages\n"); - printf("-o Try to avoid printing 'undefined' objects.\n"); - printf("-s Show all possible messages printed out by RandomMessage.\n"); - printf("-q Quick RandomMessage printout (only show actual arguments).\n"); - printf("-u Leave commands unsorted.\n"); - printf("-x Examine .DA1 file as it is read (implies -i).\n"); - printf("-a Interpret arguments to metacommands (implies -r-).\n"); - printf("-r Raw command out: don't disassemble metacommands (implies -a-)\n"); -} - -static rbool setarg(char **optptr) -{ - if ( (*optptr)[1]=='+') {(*optptr)++;return 1;} - if ( (*optptr)[1]=='-') {(*optptr)++;return 0;} - return 1; -} - -void parse_options(char *opt,char *next) -{ - if (opt[0]=='-' && opt[1]==0) /* -- */ - {end_cmd_options=1;return;} - for(;*opt!=0;opt++) - switch(tolower(*opt)) - { - case 'v': - printdict=1; printmsg=1; DIAG=1; - interp_arg=1; - break; - case '?': case 'h': - helpmsg(); - exit(EXIT_SUCCESS); - case 'd': printdict=setarg(&opt);break; - case 's': dbg_msgrange=setarg(&opt);break; - case 'q': quick_rndmsg=setarg(&opt);break; - case 'm': printmsg=setarg(&opt);break; - case 'i': DIAG=setarg(&opt);break; - case 'o': no_badobj=setarg(&opt); break; - case 'a': interp_arg=setarg(&opt); - if (interp_arg) RAW_CMD_OUT=0; - break; - case 'x': debug_da1=setarg(&opt); - if (debug_da1) DIAG=1; - break; - case 'r': RAW_CMD_OUT=setarg(&opt); - if (RAW_CMD_OUT) interp_arg=0; - break; - case 'u': sortflag=!setarg(&opt);break; -#ifdef OPEN_FILE_AS_TEXT - case 'b': open_as_binary=setarg(&opt);break; -#endif - default:printf("Do not recognize option %c\n",*opt); - helpmsg(); - exit(EXIT_FAILURE); - } -} - - -int main(int argc,char *argv[]) -{ - int i; - char *gamefile; - fc_type fc; - - end_cmd_options=0; - - init_flags(); - debug_mode=1; /* Unless something turns it off explictly */ - build_trans_ascii(); - - printmsg=printdict=0; - sortflag=1; - dbg_msgrange=0; /* Don't print out message range for RandomMessage */ - quick_rndmsg=0; /* Don't print out arguments to RandomMessage - (except perhaps the range above) */ - - printf("AGTOut: Prints contents of AGT files in human readable form\n"); - printf("%s\n",version_str); - printf(" Copyright (C) 1996-1999,2001 Robert Masenten\n"); - printf("[%s]\n\n",portstr); - - gamefile=NULL; - for(i=1;i -#include "agility.h" - - -static void read_da6(fc_type fc); -static void check_cmd_version(void); -static void build_cmd_table(void); -static void fixcmd(integer*,int); - -/* This parses the block of integers of a command to standardize - the command numbers */ -static short *cmd_table; /* Holds the command translation table used - by fixcmd */ -int topcmd; /* The highest legal opcode in the current AGT version. */ - - - -static genfile fd_desc; /* File pointer for description file. */ -static long desc_size; /* Size of description file. */ - -static int top_quest; /* Highest question actually referenced */ - /* This is computed by fixcmd */ - -static int SL_NAME,SL_TEXT,SL_ROOM,SL_WORD; -static integer MAX_CMD_SIZE; - -static rbool encrypt_desc=1; /* Are descriptions encrypted? */ - - -/* This translates v1.8 status mode codes into ME statue mode codes */ -const uchar agt18_statmode[]={0,4,3,1}; - - -/*-------------------------------------------------------------------------*/ -/* Utilities to convert strings, do ASCII translation, etc. and to add */ -/* words to the dictionary (the actual dictionary routines are in */ -/* agtdata.c; these routines here are just wrappers that prepare words */ -/* to be added). */ -/*-------------------------------------------------------------------------*/ - - - -static void fatals(char *msg,char *fname) -{ - char *err; - - err=rmalloc(strlen(msg)+strlen(fname)+1); - sprintf(err,msg,fname); - rfree(fname); - fatal(err); - rfree(err); /* This should never be executed */ -} - - -static word add_dic1(uchar *buff, int n) -{ - char nbuff[100]; - - int i; - if (n>100) n=100; - for(i=0;i80) fatal("Invalid game file format"); - for(j=1;j<=buff[0];j++) - if (rspace(buff[j]) && k>0) - { - nbuff[k]=0; - addsyn(add_dict(nbuff)); - k=0; - } - else nbuff[k++]=buff[j]; - if (k>0) { - nbuff[k]=0; - addsyn(add_dict(nbuff)); - } - addsyn(-1); /* End of list marker */ - return start_ptr; -} - - - - -/*-------------------------------------------------------------------------*/ -/* Description file manipulation routines: routines to open and close the */ -/* description file and read in individual descriptions. */ -/*-------------------------------------------------------------------------*/ - -/* The memory-based stuff is not done yet */ - - -void convert_agt_descr(uchar *s) - /* Convert encrypted pascal string into plaintext C string */ -{ - int j,n; - - n=s[0]; - if (n>80) { - s[0]=0; - return; - } - - if (encrypt_desc) - for(j=0;j Now need to figure out if the input is encoded. Do this by - reading a few random lines and seeing if they "look" encoded */ - alpha=cnt=0; - if (aver>AGT135 || aver==AGTCOS) - encrypt_desc=1; - else { - binread(fd_desc,buff,81,1,&errstr); /* Throw away first line */ - while(cnt<300) - { - if (!binread(fd_desc,buff,81,1,&errstr)) /* EOF */ - { - writeln(""); - agtwarn("EOF while analyzing descriptions",0); - rprintf("......assuming type "); - break; - } - if (buff[0]>0 && buff[1]!=' ' && buff[1]>0) /* To avoid "banner" - lines */ - { - for(i=1;i<=buff[0];i++) - { - if (buff[i]>='A' && buff[i]<='z') alpha++; - if (buff[i]!=' ') cnt++; - } - } - } - if (3*cnt<4*alpha) { - encrypt_desc=0; - if (aver==AGT135) aver=AGT12; - } - else encrypt_desc=1; - } - if (DIAG) { - if (encrypt_desc) rprintf(" [encrypted]\n"); - else rprintf(" [plaintext: %d/%d]\n",alpha,cnt);} - - mem_descr=NULL; - if (desc_size<=descr_maxmem) { - /* This is where we need to read the data in and convert it: - encrypted Pascal strings --> plaintext C strings */ - binseek(fd_desc,0); - mem_descr=rmalloc(desc_size); - /* Read in the whole file */ - binread(fd_desc,mem_descr,desc_size,1,&errstr); - if (errstr!=NULL) fatal(errstr); - for(i=0;i=AGT15) set32(flag_noun_bits); /* Menu flags */ - else room[i].flag_noun_bits=0; - - if (aver>=AGTME10) set32(PIX_bits); /* PIX bits */ - else room[i].PIX_bits=0; - - seti(path[12]); /* Special */ - - /* There's a small possibility that the 1.5/Hotel flag_noun_bits - goes here, rather than above; 1.5/F is known to go above */ - - setb(seen); - seti(key);setb(locked_door); - if (room_inside!=NULL) - room_inside[i]=fixsign16(buff[bp],buff[bp+1]); - bp+=2; /* Skip # of nouns in this room */ - - seti(points);seti(light);setb(end);setb(win); - if (aver!=AGT10) setb(killplayer); /* I'm guessing here */ - else room[i].killplayer=room[i].end; - - if (aver>=AGTME10) - { seti(initdesc);seti(pict);} - else {room[i].initdesc=0;room[i].pict=0;} - if (aver>=AGTME15) room[i].autoverb=setd(SL_WORD); - else room[i].autoverb=0; - room[i].oclass=0; - room[i].seen=0; - } - if (DIAG) - rprintf(" Internal:%ld\n",bp); - buffclose(); -} - - - -/*-------------------------------------------------------------------------*/ -/* Read DA3: The Noun File. */ -/*-------------------------------------------------------------------------*/ - -#undef seti -#undef setb -#define seti(a) (noun[i].a=buff[bp] | (buff[bp+1]<<8),bp+=2) -#define setb(a) (noun[i].a=buff[bp],bp++) - -static void read_da3(fc_type fc) -{ - int i, numnoun; - long recsize; - uchar *buff; /* [FRS_NOUN];*/ - long bp; - - numnoun=maxnoun-first_noun+1; - if (numnoun<0) return; - noun_sdesc=rmalloc(numnoun*sizeof(long)); - noun_pos=rmalloc(numnoun*sizeof(long)); - - recsize=buffopen(fc,fDA3,FRS_NOUN,"noun",numnoun); - if (aver==AGT15 && recsize>263) aver=AGT15F; - - bp=0; - for(i=0;i=AGT15F) seti(initdesc); - else noun[i].initdesc=0; - - setb(plural); - /* The following is a guess for ME games */ - noun_pos[i]=setstr((ver==3)?SL_ROOM:SL_NAME); - setb(something_pos_near_noun); /* These may not be valid */ - seti(nearby_noun); /* in masters ed. */ - - setb(has_syns); - noun[i].syns=setsl(); /*,SL_TEXT);*/ - if (aver>=AGT15) - noun[i].related_name=setd(SL_NAME); - else - noun[i].related_name=0; - seti(location);seti(weight);seti(size); - seti(key); -/* All of following flags known to be valid except - pullable, on, and win */ - setb(pushable);setb(pullable);setb(turnable);setb(playable); - setb(readable);setb(on);setb(closable);setb(open);setb(lockable); - setb(locked);setb(edible);setb(wearable);setb(drinkable); - setb(poisonous);setb(movable);setb(light);setb(shootable); - seti(num_shots);seti(points); - if (noun_inside!=NULL) - noun_inside[i]=fixsign16(buff[bp],buff[bp+1]); - bp+=2; /* Skip # of nouns contained in this one */ - setb(win); - if (ver==3) seti(pict); - else noun[i].pict=0; - noun[i].oclass=0; /* AGT games don't support classes */ - noun[i].isglobal=0; - noun[i].flagnum=0; - noun[i].seen=0; - noun[i].proper=0; - } - if (DIAG) - rprintf(" Internal:%ld\n",bp); - buffclose(); -} - - -#undef seti -#undef setb -#define seti(a) (creature[i].a=buff[bp] | (buff[bp+1]<<8),bp+=2) -#define setb(a) (creature[i].a=buff[bp],bp++) - - - -/*-------------------------------------------------------------------------*/ -/* Read DA4: The Creature File. */ -/*-------------------------------------------------------------------------*/ - -static void read_da4(fc_type fc) -{ - int i, numcreat; - uchar *buff; /* [FRS_CREAT];*/ - long bp; - - numcreat=maxcreat-first_creat+1; - if (numcreat<=0) return; - creat_sdesc=rmalloc(numcreat*sizeof(long)); - - buffopen(fc,fDA4,FRS_CREAT,"creature",numcreat); - - bp=0; - for(i=0;i=redir_val) { - vnum=vnum%redir_val; - redir=1; - } else redir=0; - - anycode=(aver<=AGT18MAX) ? 106 : 123; - - /* Now to correct ANYBODY to something consistent and set verb - references to 1 since we don't need them and they just confuse things */ - if (vnum=AGT15F) cmd_ptr=rmalloc(sizeof(long)*last_cmd); - else cmd_ptr=NULL; - - bp=0; - for(i=0;i=AGTME10) - command[i].prep=setd(SL_WORD); - else command[i].prep=0; - command[i].objcmd=setd(SL_WORD); - command[i].noun_adj=command[i].obj_adj=0; - command[i].noun_obj=command[i].obj_obj=0; - if (aver=AGT15F) read_da6(fc); - check_cmd_version(); /* This uses the opcodes to check gamefile - version information and change it if neccesary. */ - build_cmd_table(); /* Create the command translation table for - this version of AGT. */ - - badtokcnt=0; - if (!RAW_CMD_OUT) - for(i=0;iMAX_BADTOK) - agtnwarn("Total number of bad opcodes:",badtokcnt,1); -} - - - -static void read_da6(fc_type fc) -/* This will only be called for versions with a DA6 file-- - i.e. Master's Edition and proto-ME games. */ -{ - genfile fda6; - char *fullname, *errstr; - long fsize; /* Size of the file */ - long frame; /* The first element of the file that is in the buffer. */ - uchar *cbuf; /* Buffer */ - long cfile_size, cbuf_size; /* Number of tokens in file and in buffer */ - long i, j; - long cmdstart, cmdend; /* Marks the start and end of the current command */ - long ip; /* Points to instruction in cmd.data[] that we are writing to */ - long bp; /* Pointer into buffer */ - long endp; /* Used to indicate end of current read loop - (with an infinite buffer, this would always be an adjusted - cmdend) */ - long adj_cbuf_size; /* Stores number of bytes actually read in to cbuf */ - - fda6=openbin(fc,fDA6,"Could not open code file '%s'.",1); - fsize=binsize(fda6); - fullname=formal_name(fc,fDA6); - if (DIAG) rprintf("Reading code file %s (size:%ld)\n",fullname,fsize); - - if (aver==AGT15F && fsize==20000) aver=AGT16; - if (aver>=AGTME10) cfile_size=20000; - else if (aver==AGT16) cfile_size=10000; - else cfile_size=5000; - - if (fsize!=2*cfile_size) - fatals("Code file %s is the wrong size.",fullname); - - cbuf_size= (cfile_size=2) { - for(j=i+1;jcfile_size) fatals("Code file overrun(%s)",fullname); - --cmdend; - cmdstart=cmd_ptr[i]-1; - command[i].cmdsize=cmdend-cmdstart; - command[i].data=rmalloc(command[i].cmdsize*sizeof(integer)); - - ip=0; - bp=cmdstart-frame; - adj_cbuf_size=cbuf_size; - - while(ip=adj_cbuf_size) { /* Read in new block */ - frame=frame+bp; - binseek(fda6,frame*2); - if (frame+cbuf_size<=cfile_size) - adj_cbuf_size=cbuf_size; - else - adj_cbuf_size=cfile_size-frame; - if (adj_cbuf_size<=0) fatal("Unexpected end of file."); - if (!binread(fda6,cbuf,2,adj_cbuf_size,&errstr)) - fatal(errstr); - bp=0; - } - endp=cmdend-frame; - if (endp>cbuf_size) endp=cbuf_size; - for(;bp0) { - tok=command[i].data[command[i].cmdsize-1]; - if (tok>=0 && tok<=MAX_TOKEN_ID) count[tok]++; - } - maxcnt=maxtok=0; /* nextcnt=0;*/ - for(i=0;i<=MAX_TOKEN_ID;i++) - if (count[i]>=maxcnt) { -/* nextcnt=maxcnt; */ - maxcnt=count[i]; - maxtok=i;} - return maxtok; -} - -static int compute_endcode(int ver) -/* Computes the correct endcode for a given gamefile version */ -{ - int i; - - for(i=0;FIX_LIST[ver][i].tnew!=-1;i++); - return (FIX_LIST[ver][i].told-3); /* -3 to get to EndCmd */ -} - - -static void check_cmd_version(void) -/* Run through the commands looking at the last legal byte. This is - normally the EndCmd token code, which can give us info on which - token encoding scheme is being used. */ -{ - int endcode; - - endcode=check_endcmd(); - if (DIAG) rprintf(" (EndCmd=%d)\n",endcode); - if (endcode<150) return; /* No metacommands, or something else is wrong. */ - if (endcode==compute_endcode(aver)) return; /* We're okay */ - - /* Check for the special cases we know about */ - if (aver==AGT135) { - if (endcode==compute_endcode(AGT182)) {aver=AGT182;return;} - else if (endcode==compute_endcode(AGT118)) {aver=AGT118; return;} - } - if (aver==AGTME10) - if (endcode==compute_endcode(AGTME10A)) {aver=AGTME10A;return;} - if (aver==AGTMAST) - if (endcode==compute_endcode(AGTME155)) {aver=AGTME155;return;} - - /* If we still haven't fixed the problem, print out a warning and - pray. */ - agtnwarn("Game has invalid EndCmd: ",endcode,1); -} - - - -static void build_cmd_table(void) -{ - int told,tnew,fp; - const cmd_fix_rec *fixtbl; - - topcmd=compute_endcode(aver)+3; - cmd_table=rmalloc(sizeof(short)*topcmd); - - fixtbl=FIX_LIST[aver]; - fp=0; /* Pointer into fix table */ - tnew=0; /* This shouldn't be neccessary */ - for(told=0;told=topcmd || clist[ip]<0) - badtokerr("Invalid token found: ",clist[ip]); - else { - - clist[ip]=cmd_table[clist[ip]]; /* Translate */ - - /* Now increment ip by the length of the instruction */ - /* Remember that we are already incrementing by one automatically */ - - if (clist[ip]>=END_ACT) break; /* CMD end marker */ - if (clist[ip]<=MAX_COND) - ip+=cond_def[clist[ip]].argnum; - else if (clist[ip]=s && (*t==0 || *t=='\r'|| *t=='\n');t--); - *(t+1)=0; -} - -static void fix_answer(char *s) -/* Put answer s into standard format: all lower case and with trailing/ - following whitespace removed */ -{ - char *t, *p; - - for(t=s;*t!=0;t++) - *t=tolower(*t); - /* Eliminate trailing space and newlines */ - for(;t>=s && (*t==0 || rspace(*t)); t--); - *(t+1)=0; - /* Eliminate leading space and newlines */ - for(t=s;rspace(*t);t++); - if (t!=s) { - for(p=s;*t!=0;) - *(p++)=*(t++); - *p=0; - } -} - - -static char linebuffer[81]; -static int bhold; -static int linenum; -static rbool unexpected_eof; - -static void read_line(genfile fd,char *typestr) -/* Read a line into buffer, unless bhold=1 in which case we want - to use the last line read */ -{ - if (bhold==0) - { - readln(fd,linebuffer,80); - if (linebuffer[0]==0 && texteof(fd)) { - unexpected_eof=1; - strcpy(linebuffer,">End Of File<");} - else chop_newline(linebuffer); - linenum++; - } - if (debug_da1 && typestr!=NULL) - { - rprintf("%s %4d:%s",typestr,linenum,linebuffer); - if (bhold) rprintf(" *"); - writeln(""); - } - bhold=0; -} - - -static void report(char *s,genfile fd) -{ - if (DIAG) rprintf("REPORT:%s at %d\n",s,linenum); -} - -static int isbool(genfile fd) -{ - read_line(fd,NULL); - bhold=1; - return (strncasecmp(linebuffer,"TRUE",4)==0 || - strncasecmp(linebuffer,"FALSE",5)==0); -} - -static int isnum(genfile fd) -{ - char *errstr; - - read_line(fd,NULL); - bhold=1; - strtol(linebuffer,&errstr,10); - while (*errstr=='\n' || *errstr=='\r') errstr++; - if (debug_da1) - rprintf("NUMCHK: %s==>%c\n",linebuffer,*errstr); - return (*errstr=='\0'); -} - -static rbool readrbool(genfile fd) -{ - read_line(fd,"BOOL"); - return (strncasecmp(linebuffer,"TRUE",4)==0); -} - - -static long readnum(genfile fd) -{ - read_line(fd,"NUM "); - return strtol(linebuffer,NULL,10); -} - - -static void readptr(genfile fd,descr_ptr *desc) -{ - read_line(fd,"PTR "); - desc->start=strtol(linebuffer,NULL,10); - read_line(fd,"LEN"); - desc->size=strtol(linebuffer,NULL,10); -} - - -static void readjunk(genfile fd) -{ - read_line(fd,"JUNK"); -} - -static void readtext(genfile fd,tline s) -{ - read_line(fd,"TEXT"); - strncpy((char*)s,linebuffer,80); - s[80]=0; -} - -static long readfname(genfile fd) -{ - read_line(fd,"FILE"); - return new_str(linebuffer,0,0); - /* Copy filename string to static string space and return index */ -} - -static word readdict(genfile fd) -{ - read_line(fd,"DICT"); - return add_dict(linebuffer); -} - - -static slist readslist(genfile fd) /* Read in synonym list line */ -{ - slist start_ptr; - char nbuff[50]; - int j,k; - - start_ptr=synptr; - read_line(fd,"SYN "); -/* Need to see if it is none or * terminated. */ - for(j=0;linebuffer[j]!=0 && linebuffer[j]!='*';j++); - linebuffer[j]=0; - k=0; - for(j=0;linebuffer[j]!=0;j++) - if (rspace(linebuffer[j]) && k>0) - { - nbuff[k]=0; - addsyn(add_dict(nbuff)); - k=0; - } - else if (!rspace(linebuffer[j])) - nbuff[k++]=linebuffer[j]; - if (k>0) { - nbuff[k]=0; - addsyn(add_dict(nbuff)); - } - addsyn(-1); - return start_ptr; -} - - - -/*-------------------------------------------------------------------------*/ -/* Version analysis: Utilities to analyse the file format version and */ -/* deduce sizes. */ -/*-------------------------------------------------------------------------*/ - -static int soggy_test(fc_type fc) -{ - genfile fda3; - long fsize; - - if (DIAG) { - char *s; - s=formal_name(fc,fDA3); - rprintf("Testing %s for abnormal noun organization....",s); - rfree(s); - } - fda3=openbin(fc,fDA3,"Could not find room file '%s'.",1); - fsize=binsize(fda3); - readclose(fda3); - - if (fsize % (maxnoun-300+1)!=0) { - if (DIAG) rprintf("FOUND!\n"); - return 1; - } - if (fsize / (maxnoun-300+1) > 300) { - if (DIAG) rprintf("FOUND!\n"); - return 1; - } - if (DIAG) rprintf("nope.\n"); - return 0; -} - - -static void deduce_sizes(fc_type fc, rbool diag) - /* If diag is true, we will also allocate space for - noun inside information; this is used by agtout */ -{ - if (ver==0) { - ver=1; - if (maxroom>=200) ver=2; - else if (maxnoun!=0) - if (maxnoun<300) - if (maxcreat!=0) - if (maxcreat>=500) ver=4; /* SOGGY */ - else ver=1; /* Small */ - else if (aver==AGTCOS) ver=4; /* SOGGY */ - else ver=1; /* Small */ - else if (aver!=AGTCOS) ver=2; /* Large */ - else if (soggy_test(fc)) ver=4; - else ver=2; - else if (maxcreat!=0) - if (maxcreat>=500) - if (aver!=AGTCOS) ver=2; /* Large */ - else if (soggy_test(fc)) ver=4; /* Either large or SOGGY */ - else ver=2; - else ver=1; /* Small */ - else - agtwarn("No nouns or creatures: unable to determine version." - "\nAssuming AGT Small",0); - } - - if (aver=AGT18 && aver<=AGT18MAX) { - bold_mode=1; - build_fixchar(); - fixchar['\\']=FORMAT_CODE; - } - - if (aver=AGTME10) { - MAX_USTR=25; - MAX_SUB=15; - } - else MAX_SUB=MAX_USTR=0; - - if (aver>=AGT15) - NUM_ERR=185; /* Number of standard error messages */ - else - NUM_ERR=0; - - DVERB=50; - FLAG_NUM=255; - CNT_NUM=VAR_NUM=50; - exitmsg_base=1000; - - num_rflags=num_nflags=num_cflags=0; - num_rprops=num_nprops=num_cprops=0; - objflag=NULL; objprop=NULL; - attrtable=NULL; proptable=NULL; - oflag_cnt=0; oprop_cnt=0; - propstr=NULL; propstr_size=0; - vartable=NULL; flagtable=NULL; - - - -/* Now to allocate space for all of the 'immortal' data structures */ -/* We do this all at once to avoid fragmentation; all of the following - will be around for the life of the program (unless we restart) and so - should be allocated first */ - - synlist=rmalloc(sizeof(slist)*TOTAL_VERB); - comblist=NULL; /* The original AGT didn't support multi-word verbs */ - num_comb=0; - userprep=NULL; /* ... nor did it allow user-defined prepostions */ - num_prep=0; - - if (numglobal>0) - globalnoun=rmalloc(numglobal*sizeof(word)); - - if (aver=AGTME15) { - quest_ptr=rmalloc(MaxQuestion*sizeof(descr_ptr)); - ans_ptr=rmalloc(MaxQuestion*sizeof(descr_ptr));} - msg_ptr=rmalloc((last_message)*sizeof(descr_ptr)); - - if (maxroom>=first_room) { - room=rmalloc((maxroom-first_room+1)*sizeof(room_rec)); - room_ptr=rmalloc((maxroom-first_room+1)*sizeof(descr_ptr)); - help_ptr=rmalloc((maxroom-first_room+1)*sizeof(descr_ptr)); - special_ptr=rmalloc((maxroom-first_room+1)*sizeof(descr_ptr)); - if (diag) room_inside=rmalloc((maxroom-first_room+1)*sizeof(integer)); - } - - if (maxnoun>=first_noun) { - noun=rmalloc((maxnoun-first_noun+1)*sizeof(noun_rec)); - noun_ptr=rmalloc((maxnoun-first_noun+1)*sizeof(descr_ptr)); - push_ptr=rmalloc((maxnoun-first_noun+1)*sizeof(descr_ptr)); - pull_ptr=rmalloc((maxnoun-first_noun+1)*sizeof(descr_ptr)); - text_ptr=rmalloc((maxnoun-first_noun+1)*sizeof(descr_ptr)); - turn_ptr=rmalloc((maxnoun-first_noun+1)*sizeof(descr_ptr)); - play_ptr=rmalloc((maxnoun-first_noun+1)*sizeof(descr_ptr)); - if (diag) noun_inside=rmalloc((maxnoun-first_noun+1)*sizeof(integer)); - } - - if (maxcreat>=first_creat) { - creature=rmalloc((maxcreat-first_creat+1)*sizeof(creat_rec)); - creat_ptr=rmalloc((maxcreat-first_creat+1)*sizeof(descr_ptr)); - ask_ptr=rmalloc((maxcreat-first_creat+1)*sizeof(descr_ptr)); - talk_ptr=rmalloc((maxcreat-first_creat+1)*sizeof(descr_ptr)); - if (diag) creat_inside=rmalloc((maxcreat-first_creat+1)*sizeof(integer)); - } - - if (aver>=AGTME10) { - userstr=rmalloc(MAX_USTR*sizeof(tline)); - sub_name=rmalloc(MAX_SUB*sizeof(word)); - } - command=rmalloc(sizeof(cmd_rec)*last_cmd); - - if (aver>=AGT15) - err_ptr=rmalloc(NUM_ERR*sizeof(descr_ptr)); - - - reinit_dict(); /* The dictionary grows dynamically so we want to - allocate it AFTER we have allocated all the permenent - things */ -} - - - - -/*-------------------------------------------------------------------------*/ -/* Read DA1: The Info file; this is a text file containing a miscellany of */ -/* game information that wouldn't fit elsewhere */ -/*-------------------------------------------------------------------------*/ - -static int try_read_da1(fc_type fc,genfile fda1,rbool diag) -/* Returns new aver value to try, or 0 on success. */ -/* diag determines if noun inside info will be read */ -/* VER values: 1=Small - 2=Large - 3=Master's Edition - 4="Soggy Large", with a larger last_room -*/ -/* AVER values: see agility.h for the current values */ -/* NOTE: This routine is allowed to set *ver*, but is not allowed to - change *aver*; should it be neccessary to change *aver*, then the routine - should return the new *aver* value. - (The only exception to this is in the very beginning-- and that may get - changed) - [This is done to allow the user to force a version number] -*/ -{ - int i; - - MAX_CMD_SIZE=30; - maxpict=maxpix=maxfont=maxsong=0; - linenum=0;bhold=0; - game_sig=0; - unexpected_eof=0; - - if (aver==0 && isbool(fda1)) aver=AGTMAST; - /* From this point on can assume ME detected */ - - freeze_mode=0; /* The default values */ - if (aver>=AGTME10) { /* 2 rbool */ - debug_mode=readrbool(fda1); /* DEBUG */ - if (aver>=AGTME15) { - if (!isbool(fda1)) aver=AGTME10; - else freeze_mode=readrbool(fda1); } /* FREEZE */ - ver=3; - } - - start_room=readnum(fda1); - treas_room=readnum(fda1); - if (aver!=AGT10) resurrect_room=readnum(fda1); - else resurrect_room=start_room; - if (aver>=AGTME10) { /* 4 int */ - score_mode=readnum(fda1); /* Score option */ - statusmode=readnum(fda1); /* Status option */ - start_time=readnum(fda1); /* Starting time */ - delta_time=readnum(fda1); /* Delta_time */ - } else - { - score_mode=statusmode=0; - start_time=delta_time=0; - } - max_lives=readnum(fda1); - if (aver!=AGT10) max_score=readnum(fda1); - else max_score=0; - maxroom=readnum(fda1); - maxnoun=readnum(fda1); - maxcreat=readnum(fda1); - if (aver>=AGTME10) numglobal=readnum(fda1);/* # of global nouns? */ - else numglobal=0; - last_cmd=readnum(fda1); - readjunk(fda1); /* Number of items being carried */ - readjunk(fda1); /* Number of items being worn */ - if (isbool(fda1)) return AGT10; /* AGT v1.0 */ - /* From this point on, can assume AGT v1.0 is detected. */ - readptr(fda1,&intro_ptr); - - deduce_sizes(fc,diag); - - if (aver>=AGTME10) { - - (void)readdict(fda1); /* ?!?! Not sure what this is */ - - report("Reading global and flag nouns",fda1); - - for(i=0;i=AGTME15) { - /* There are 400 lines of description pointers, meaning - 200 descriptions. I'm guessing they're all questions and - answers, which means that there are 100 questions here. */ - for(i=0;i=AGTME10 && last_cmd==0) have_meta=0; - - report("Reading synonyms",fda1); - - for(i=0;i */ - - if (aver>=AGTME10) { /* Unknown verbs */ - synlist[56]=readslist(fda1); /* VIEW */ - synlist[57]=synlist[14]; /* AFTER */ - synlist[14]=readslist(fda1); /* THROW */ - } - - if (aver==AGT183) { - /* Eliminate LIST_EXITS and add INSTRUCTIONS */ - synlist[58]=synlist[52]; - /* Move 'REMOVE'-- the last thing before INS in 1.83 verblist -- - up to INSTRUCTIONS where it belongs */ - for(i=52;i>42;i--) /* i:=Remove to Brief (above List Exits) */ - synlist[i]=synlist[i-1]; - synlist[41]=synptr; /* LIST_EXITS, which doesn't exist in 1.83 and so - can't have synonyms */ - addsyn(-1); - } - - report("Starting dummy verbs",fda1); - for(i=0;i<25;i++) { - if (i!=0 || aver=AGTME10) { - synlist[BASE_VERB]=readslist(fda1); - for(i=0;i<15;i++) /* Subroutines */ - synlist[i+BASE_VERB+50]=readslist(fda1); - } - report("Reading DESC ptrs",fda1); - if (aver>=AGT15) - for(i=0;i=first_creat) { - for(i=0;i<=maxcreat-first_creat;i++) { - readptr(fda1,&creat_ptr[i]); - if (aver!=0 && aver<=AGTCLASS) { - ask_ptr[i].start=talk_ptr[i].start=0; - ask_ptr[i].size=talk_ptr[i].size=-1; - } - else{ - readptr(fda1,&talk_ptr[i]); - readptr(fda1,&ask_ptr[i]); - if (aver==0 && (talk_ptr[i].size==0 || ask_ptr[i].size==0 || - unexpected_eof)) return AGT135; - } - } - } - if (aver==AGT135 && unexpected_eof) return AGT12; - - if (aver>=AGTME10) - { - if (aver>=AGTME155 && !isnum(fda1)) return AGTME15; - - maxpict=rangefix(readnum(fda1)); /* Number of pictures */ - maxpix=rangefix(readnum(fda1)); /* Numper of PIXs */ - maxsong=rangefix(readnum(fda1)); /* Number of sounds */ - maxfont=rangefix(readnum(fda1)); /* Number of fonts. */ - - if (maxpix>MAX_PIX) { - rprintf("Invalid MAXPIX value?!?\n"); - maxpix=MAX_PIX; - } - - t_pictlist=rmalloc(sizeof(long)*maxpict); - t_pixlist=rmalloc(sizeof(long)*maxpix); - t_songlist=rmalloc(sizeof(long)*maxsong); - t_fontlist=rmalloc(sizeof(long)*maxfont); - - for(i=0;i=1 && tval<=4) - statusmode=agt18_statmode[tval-1]; - else statusmode=0; - tval=readnum(fda1); /* Hours */ - start_time=readnum(fda1); /* Minutes */ - tval+=start_time/60; start_time=(start_time%60)+100*tval; - if (readrbool(fda1) && start_time<1200) - start_time+=1200; - milltime_mode=readrbool(fda1); /* Military time */ - delta_time=readnum(fda1); - } - if (DIAG) rprintf("Read in %d lines\n",linenum); - return 0; -} - - - -static void set_da1_null(void) -/* Set pointers that are malloc'd by try_read_da1 to NULL, to clear - the way for free_da1_stuff to recover them */ -{ - static_str=NULL;ss_end=ss_size=0; - command=NULL; cmd_ptr=NULL; synlist=NULL; - userstr=NULL; sub_name=NULL; globalnoun=NULL; err_ptr=NULL; - quest_ptr=ans_ptr=NULL; - question=answer=NULL; - msg_ptr=room_ptr=help_ptr=special_ptr=NULL; - noun_ptr=push_ptr=pull_ptr=text_ptr=turn_ptr=play_ptr=NULL; - room_inside=noun_inside=creat_inside=NULL; - creat_ptr=ask_ptr=talk_ptr=NULL; - pictlist=pixlist=fontlist=songlist=NULL; - room=NULL;noun=NULL;creature=NULL;command=NULL; - t_pictlist=t_pixlist=t_fontlist=t_songlist=NULL; -} - - - -static void free_da1_stuff(void) - /* Free all data structures malloc'd by try_read_da1 */ - /* (This is neccessary since try_read_da1 may have to restart) */ - /* Note that if a pointer is NULL, rfree does nothing */ - /* Recall that rfree() is a macro that sets its argument to NULL */ - /* after freeing it */ -{ - rfree(static_str);ss_end=ss_size=0; - rfree(userstr);rfree(sub_name);rfree(globalnoun);rfree(err_ptr); - rfree(synlist); - rfree(quest_ptr);rfree(ans_ptr); - rfree(question);rfree(answer); - rfree(msg_ptr);rfree(room_ptr);rfree(help_ptr);rfree(special_ptr); - rfree(noun_ptr);rfree(push_ptr);rfree(pull_ptr);rfree(text_ptr); - rfree(room_inside);rfree(noun_inside);rfree(creat_inside); - rfree(turn_ptr);rfree(play_ptr); - rfree(creat_ptr);rfree(ask_ptr);rfree(talk_ptr); - rfree(t_pictlist);rfree(t_pixlist);rfree(t_songlist);rfree(t_fontlist); - rfree(room);rfree(noun);rfree(creature);rfree(command); - free_dict(); -} - -static rbool read_da1(fc_type fc, rbool diag) - /* diag is set by agtout to save extra diagnostic information */ - /* It has nothing to do with DIAG */ -{ - genfile fda1; - int i; - - ver=0;aver=0; - top_quest=0; /* Highest question actually referenced; set by fixcmd */ - fda1=openfile(fc,fDA1,NULL,0); - if (!filevalid(fda1,fDA1)) return 0; - - if (DIAG) { - char *s; - s=formal_name(fc,fDA1); - rprintf("Reading info file %s\n",s); - rfree(s); - } - set_da1_null(); - while( (i=try_read_da1(fc,fda1,diag))!=0) - { - if (aver==i) { - rprintf("[Recoginiton loop: AVER=%d]\n",aver); - fatal("AGT version not recognized\n"); - } - aver=i; - /* fseek(fda1,0,SEEK_SET); Go back to beginning... */ - textrewind(fda1); - if (DIAG) - rprintf("...Found incompatibility; restarting, w/ AVER=%d\n",aver); - free_da1_stuff(); - /* set_da1_null();*/ - ver=0; - } - if (aver==0) aver=AGTSTD; /* i.e. if we didn't notice any differences from - standard format, it must be a standard file. */ - readclose(fda1); - return 1; /* Success */ -} - - - -/*-------------------------------------------------------------------------*/ -/* Miscellaneous routines to tie up loose ends and clean up afterwards. */ -/*-------------------------------------------------------------------------*/ - -static void finish_read(rbool cleanup) -/* cleanup=0 means it will leave cmd_ptr, 1=it cleans up cmd_ptr */ -/* The only reason to set cleanup==0 is if we are writing a diagnostic - program of some sort */ -{ - int i; - - if (aver>=AGT18 && aver<=AGT18MAX) { - intro_first=1; - max_lives=1; - TWO_CYCLE=1; - PURE_AFTER=0; - } else { - intro_first=0; - TWO_CYCLE=0; - PURE_AFTER=1; - } - - min_ver=0; /* All original AGT games will run with any version of - AGiliTy. */ - - if (aver>=AGTME10) - PURE_ROOMTITLE=0; - - if (aver>=AGT15) - box_title=1; - else box_title=0; - - /* Compute max_score if it isn't already computed */ - if (max_score==0) { - for(i=0;i0) - static_str=rrealloc(static_str,sizeof(char)*ss_end); - - /* Now convert string handles into honest pointers */ - for(i=0;i<=maxroom-first_room;i++) - room[i].name=static_str+room_name[i]; - for(i=0;i<=maxnoun-first_noun;i++) { - noun[i].shortdesc=static_str+noun_sdesc[i]; - noun[i].position=static_str+noun_pos[i]; - } - for(i=0;i<=maxcreat-first_creat;i++) - creature[i].shortdesc=static_str+creat_sdesc[i]; - - if (aver>=AGTME10) { - pictlist=rmalloc(sizeof(filename)*maxpict); - pixlist=rmalloc(sizeof(filename)*maxpix); - songlist=rmalloc(sizeof(filename)*maxsong); - fontlist=rmalloc(sizeof(filename)*maxfont); - - for(i=0;i -#include -#include - -#define AGX_NUMBLOCK 37 -#define AGT_FILE_SIG 0x51C1C758L - -/* AGX File format: - (This tends to lag a little behind the code below; - you should double check against the actual file_info definitions - below) -All integer values stored little-endian. -desc_ptrs: int32 ofs, int32 leng (both in lines) -dictionary word: int16 -slist ptr: int16 -tline: char[81] -filename: char[10] -rbool values are packed into bytes, 1 bit per value, from lsb to msb. -cfgopt: 0=false, 1=true, 2=leave alone - -Mandatory blocks are marked with astericks. - -*File header: 16 bytes - uint 32 File ID [AGT_FILE_SIG, 4 bytes] - byte Version owner: 'R' - byte Version 0 - byte Extension owner 'R' - byte Extension 0 - char[2]: '\n\r' -- to catch download errors - byte Extension fallback. For non-'R' extensions, this gives the - 'R' extension to fall back to. - char[5] Reserved for future use (should be 0 right now) -*0-File index: - For each block (including itself): [16 bytes] - uint32 starting offset - uint32 block size - uint32 number of records - uint32 size of a record (recsize*numrec == blocksize) -11-Description strings (block of tline) -12-Command text (block of int16) -*1-Game header - uint16 AGT_version_code; +1 for "big/soggy" games - uint32 game_sig (game signature, used to check save files and debug info) - rbool debug_mode, freeze_mode, milltime_mode, bold_mode, - have_meta, mars_fix, intro_first, TWO_CYCLE; - uchar score_mode, statusmode; - uint16 max_lives - uint32 max_score; - uint16 start_time, delta_time; - descr_ptr intro_ptr, title_ptr, ins_ptr; - int16 start_room, treas_room, resurrect_room - int16 first_room, first_noun, first_creat - int16 FLAG_NUM, CNT_NUM, VAR_NUM - int16 BASE_VERB - cfgopt PURE_ANSWER, PURE_TIME, PURE_ROOMTITLE; - cfgopt PURE_AND, PURE_METAVERB; - cfgopt PURE_SYN, PURE_NOUN, PURE_ADJ; - cfgopt PURE_DUMMY, PURE_SUBNAME, PURE_PROSUB; - cfgopt PURE_HOSTILE, PURE_GETHOSTILE; - cfgopt PURE_DISAMBIG, PURE_ALL; - cfgopt irun_mode, verboseflag; - cfgopt PURE_GRAMMAR (Extension R1-R3) - rbool TWO_CYCLE (R1-R4) - PURE_AFTER (R1-R5) - int16 min_ver - uchar font_status; - int16 num_rflags, num_nflags, num_cflags; - int16 num_rprops, num_nprops, num_cprops; -2-Room data (room_rec format, pointers->int ref into static string) - include help, desc, special ptrs -3-Noun data (noun_rec format) - include noun, text, turn, push, pull, play ptrs -4-Creature data (creat_rec format) - include creature, talk, ask ptrs -5-Command headers (cmd_rec format), pointers into command text - must be in increasing order. -6-Standard error message ptrs (array of descptr -7-Message ptrs (array of descptr) -8-Question pointers (array of descptr) -9-Answer pointers (array of descptr) -10-User strings (array of tline) -*13-Static string block (block of chars) -14-Subroutine dictionary ids (array of word:int16) -*15-Synlist (for verbs) (array of slist:int16) -16-Pix names (array of word:int16 -- pointers into dictionary) -17-Global nouns (array of word:int16 -- ptrs into dictionary) -18-Flag nouns (array of word:int16) -*19-Syntbl (block of word:int16) -*20-Dictionary text (block of char) -*21-Dictionary 'index' (array of uint32) -22-OPT block (14 bytes) -23-Picture filename ptrs -24-Pix filename ptrs -25-Font filename ptrs -26-Sound filename ptrs -27-VOC block, an array of verbinfo_rec -28-Multi-word verbs (Extension R1-R1) -29-Prep table (Extension R1-R1) -30- ObjFlag Data (Extension R1-R7) -31- ObjProp Data (Extension R1-R7) -32- ObjFlag Lookup (Extension R1-R7) -33- ObjProp Lookup (Extension R1-R7) -34- ObjProp string pointers (array of FT_STR) (Extension R2-R2) -35- Variable itemization array (Extension R2-R2) -36- Flag itemization array (Extension R2-R2) - -*/ - -/* AGT Version IDs; +1 for LARGE/SOGGY - 00000=v1.0 - 01800=v1.18 - 01900=v1.19 - 02000=v1.20 ("Early Classic") - 03200=v1.32/COS - 03500=v1.35 ("Classic") - 05000=v1.5/H - 05050=v1.5/F (MDT) - 05070=v1.6 (PORK) - 08200=v1.82 - 08300=v1.83 - 10000=ME/1.0 - 15000=ME/1.5 - 15500=ME/1.55 - 16000=ME/1.6 - 20000=Magx/0.0 - etc. -*/ - - - - -/* ------------------------------------------------------------- */ -/* AGX Block Descriptions */ -/* ------------------------------------------------------------- */ - - -static integer old_base_verb; - -/* AGX file info blocks */ - -#define g(ft,dt,var) {ft,dt,&var,0} -#define r(ft,dt,str,f) {ft,dt,NULL,offsetof(str,f)} -#define dptype {FT_DESCPTR,DT_DESCPTR,NULL,0} -#define xx DT_DEFAULT -#define u16 FT_UINT16 -#define u32 FT_UINT32 -#define bb FT_BOOL -#define i16 FT_INT16 - -static file_info fi_gameinfo[]={ - /* 0 */ - g(FT_VERSION,xx,aver), /* FT_VERSION converter also sets ver */ - g(u32,DT_LONG,game_sig), - /* 6 */ - g(bb,xx,debug_mode), g(bb,xx,freeze_mode), g(bb,xx,milltime_mode), - g(bb,xx,bold_mode), g(bb,xx,have_meta), g(bb,xx,mars_fix), - g(bb,xx,intro_first),g(bb,xx,box_title), - /* 7 */ - g(FT_BYTE,xx,score_mode), g(FT_BYTE,xx,statusmode), - g(i16,xx,max_lives), g(u32,DT_LONG,max_score), - /* 15 */ - g(i16,xx,start_time),g(i16,xx,delta_time), - /* 19 */ - g(FT_DESCPTR,xx,intro_ptr), g(FT_DESCPTR,xx,title_ptr), - g(FT_DESCPTR,xx,ins_ptr), - /* 43 */ - g(i16,xx,treas_room), - g(i16,xx,start_room),g(i16,xx,resurrect_room), - g(i16,xx,first_room), g(i16,xx,first_noun), - g(i16,xx,first_creat), g(i16,xx,FLAG_NUM), - g(i16,xx,CNT_NUM), g(i16,xx,VAR_NUM), - g(i16,xx,old_base_verb), - /* 63 */ - g(FT_CFG,xx,PURE_ANSWER), g(FT_CFG,xx,PURE_ROOMTITLE), - g(FT_CFG,xx,PURE_AND), g(FT_CFG,xx,PURE_METAVERB), - g(FT_CFG,xx,PURE_SYN), g(FT_CFG,xx,PURE_NOUN), g(FT_CFG,xx,PURE_ADJ), - g(FT_CFG,xx,PURE_DUMMY), g(FT_CFG,xx,PURE_SUBNAME), - g(FT_CFG,xx,PURE_PROSUB), g(FT_CFG,xx,PURE_HOSTILE), - g(FT_CFG,xx,PURE_GETHOSTILE), g(FT_CFG,xx,PURE_DISAMBIG), - g(FT_CFG,xx,PURE_ALL), - g(FT_CFG,xx,irun_mode),g(FT_CFG,xx,verboseflag), - g(FT_CFG,xx,PURE_TIME), /* Ext R0-1 */ - g(FT_CFG,xx,PURE_OBJ_DESC), /* Ext R0-1 */ - /* 81 */ - g(i16,xx,exitmsg_base), /* Ext R0-1 */ - /* 83 */ - g(FT_CFG,xx,PURE_GRAMMAR), /* Ext R1-3 */ - g(bb,xx,TWO_CYCLE), /* Ext R1-4 */ - g(bb,xx,PURE_AFTER), /* Ext R1-5 */ - g(i16,xx,min_ver), /* Ext R1-5 */ - g(FT_BYTE,xx,font_status), /* Ext R1-5 */ - g(i16,xx,num_rflags),g(i16,xx,num_nflags),g(i16,xx,num_cflags),/* Ext R1-7 */ - g(i16,xx,num_rprops),g(i16,xx,num_nprops),g(i16,xx,num_cprops),/* Ext R1-7 */ - endrec -}; - -static file_info fi_room[]={ - dptype, /* help */ - dptype, /* desc */ - dptype, /* special */ - r(FT_STR,xx,room_rec,name), - r(FT_INT32,xx,room_rec,flag_noun_bits), - r(FT_INT32,xx,room_rec,PIX_bits), - r(FT_SLIST,xx,room_rec,replacing_word), - r(FT_WORD,xx,room_rec,replace_word), - r(FT_WORD,xx,room_rec,autoverb), - r(FT_PATHARRAY,xx,room_rec,path), - r(FT_INT16,xx,room_rec,key), - r(FT_INT16,xx,room_rec,points), - r(FT_INT16,xx,room_rec,light), - r(FT_INT16,xx,room_rec,pict), - r(FT_INT16,xx,room_rec,initdesc), - r(bb,xx,room_rec,seen), r(bb,xx,room_rec,locked_door), - r(bb,xx,room_rec,end),r(bb,xx,room_rec,win),r(bb,xx,room_rec,killplayer), - r(bb,xx,room_rec,unused), /* Ext R1-2: Can add here since rbool */ - r(FT_INT16,xx,room_rec,oclass), /* Ext R1-1 */ - endrec -}; - -static file_info fi_noun[]={ - dptype, /* Noun */ - dptype, /* Text */ - dptype, dptype, dptype, dptype, /* Turn, push, pull, play */ - r(FT_STR,xx,noun_rec,shortdesc), - r(FT_STR,xx,noun_rec,position), - r(FT_SLIST,xx,noun_rec,syns), - r(FT_WORD,xx,noun_rec,name), r(FT_WORD,xx,noun_rec,adj), - /* r(FT_WORD,xx,noun_rec,pos_prep), r(FT_WORD,xx,noun_rec,pos_name),*/ - r(FT_INT16,xx,noun_rec,nearby_noun), - r(FT_INT16,xx,noun_rec,num_shots), r(FT_INT16,xx,noun_rec,points), - r(FT_INT16,xx,noun_rec,weight), r(FT_INT16,xx,noun_rec,size), - r(FT_INT16,xx,noun_rec,key), - r(FT_INT16,xx,noun_rec,initdesc), r(FT_INT16,xx,noun_rec,pict), - r(FT_INT16,xx,noun_rec,location), - r(bb,xx,noun_rec,plural), - r(bb,xx,noun_rec,something_pos_near_noun), - r(bb,xx,noun_rec,has_syns), - r(bb,xx,noun_rec,pushable), r(bb,xx,noun_rec,pullable), - r(bb,xx,noun_rec,turnable), r(bb,xx,noun_rec,playable), - r(bb,xx,noun_rec,readable), r(bb,xx,noun_rec,on), - r(bb,xx,noun_rec,closable), r(bb,xx,noun_rec,open), - r(bb,xx,noun_rec,lockable), r(bb,xx,noun_rec,locked), - r(bb,xx,noun_rec,edible), r(bb,xx,noun_rec,wearable), - r(bb,xx,noun_rec,drinkable), r(bb,xx,noun_rec,poisonous), - r(bb,xx,noun_rec,movable), r(bb,xx,noun_rec,light), - r(bb,xx,noun_rec,shootable), r(bb,xx,noun_rec,win), - r(bb,xx,noun_rec,unused), /* Ext R1-2: Can add here since packed rbool*/ - r(bb,xx,noun_rec,isglobal), /* Ext R1-4: ditto (&room for 1 more). */ - r(FT_WORD,xx,noun_rec,related_name), /* Ext R0-1 */ - r(FT_INT16,xx,noun_rec,oclass), /* Ext R1-1 */ - r(FT_INT16,xx,noun_rec,flagnum), /* Ext R1-4 */ - r(bb,xx,noun_rec,seen), /* Ext R1-6 */ - r(bb,xx,noun_rec,proper), /* Ext R2-1 */ - endrec -}; - -static file_info fi_creat[]={ - dptype, /* Creature */ - dptype, dptype, /* Talk, ask */ - r(FT_STR,xx,creat_rec,shortdesc), - r(FT_SLIST,xx,creat_rec,syns), - r(FT_WORD,xx,creat_rec,name),r(FT_WORD,xx,creat_rec,adj), - r(FT_INT16,xx,creat_rec,location), - r(FT_INT16,xx,creat_rec,weapon), r(FT_INT16,xx,creat_rec,points), - r(FT_INT16,xx,creat_rec,counter), r(FT_INT16,xx,creat_rec,threshold), - r(FT_INT16,xx,creat_rec,timethresh), r(FT_INT16,xx,creat_rec,timecounter), - r(FT_INT16,xx,creat_rec,pict), r(FT_INT16,xx,creat_rec,initdesc), - r(bb,xx,creat_rec,has_syns), r(bb,xx,creat_rec,groupmemb), - r(bb,xx,creat_rec,hostile), - r(bb,xx,creat_rec,unused), /* Ext R1-2: Can add since packed rbool */ - r(bb,xx,creat_rec,isglobal), /* Ext R1-4: ditto (& space for 3 more) */ - r(FT_BYTE,xx,creat_rec,gender), - r(FT_INT16,xx,creat_rec,oclass), /* Ext R1-1 */ - r(FT_INT16,xx,creat_rec,flagnum), /* Ext R1-4 */ - r(bb,xx,creat_rec,seen), /* Ext R1-6 */ - r(bb,xx,creat_rec,proper), /* Ext R2-1 */ - endrec -}; - -static file_info fi_cmdhead[]={ - {FT_CMDPTR,DT_CMDPTR,NULL,0}, - r(FT_INT16,xx,cmd_rec,actor), - r(FT_WORD,xx,cmd_rec,verbcmd), r(FT_WORD,xx,cmd_rec,nouncmd), - r(FT_WORD,xx,cmd_rec,objcmd), r(FT_WORD,xx,cmd_rec,prep), - r(FT_INT16,xx,cmd_rec,cmdsize), - r(FT_WORD,xx,cmd_rec,noun_adj), r(FT_WORD,xx,cmd_rec,obj_adj), /* Ext R0-1*/ - r(FT_INT16,xx,cmd_rec,noun_obj), /* Ext R2-2 */ - r(FT_INT16,xx,cmd_rec,obj_obj), /* Ext R2-2 */ - endrec -}; - -static file_info fi_verbentry[]={ - r(FT_WORD,xx,verbentry_rec,verb), - r(FT_WORD,xx,verbentry_rec,prep), - r(FT_INT16,xx,verbentry_rec,objnum), - endrec -}; - - -static file_info fi_descptr[]={ - r(FT_INT32,xx,descr_ptr,start), - r(FT_INT32,xx,descr_ptr,size), - endrec -}; - -static file_info fi_tline[]={ - {FT_TLINE,xx,NULL,0}, - endrec -}; - -static file_info fi_attrrec[]={ /* Ext R1-R7 */ - r(FT_INT32,xx,attrdef_rec,r), - r(FT_INT32,xx,attrdef_rec,n), - r(FT_INT32,xx,attrdef_rec,c), - r(FT_BYTE,xx,attrdef_rec,rbit), - r(FT_BYTE,xx,attrdef_rec,nbit), - r(FT_BYTE,xx,attrdef_rec,cbit), - r(FT_STR,xx,attrdef_rec,ystr), /* Ext R2-R2 */ - r(FT_STR,xx,attrdef_rec,nstr), /* Ext R2-R2 */ - endrec -}; - -static file_info fi_proprec[]={ /* Ext R1-R7 */ - r(FT_INT32,xx,propdef_rec,r), - r(FT_INT32,xx,propdef_rec,n), - r(FT_INT32,xx,propdef_rec,c), - r(FT_INT32,xx,propdef_rec,str_cnt), /* Ext R2-R2 */ - r(FT_INT32,xx,propdef_rec,str_list), /* Ext R2-R2 */ - endrec -}; - -static file_info fi_varrec[]={ /* Ext R2-R2 */ - r(FT_INT32,xx,vardef_rec,str_cnt), - r(FT_INT32,xx,vardef_rec,str_list), - endrec -}; - -static file_info fi_flagrec[]={ /* Ext R2-R2 */ - r(FT_STR,xx,flagdef_rec,ystr), - r(FT_STR,xx,flagdef_rec,nstr), - endrec -}; - -#undef g -#undef r -#undef xx -#undef u16 -#undef u32 -#undef bb -#undef i16 -#undef dptype - -static void set_endrec(file_info *fi,int index) -{ - fi[index].ftype=FT_END; - fi[index].dtype=0; - fi[index].ptr=NULL; - fi[index].offset=0; -} - -/* ------------------------------------------------------------- */ - -/* If is true, convert "0" string ptrs to "yes/no" ptrs. - If it is false, convert the other way. */ -/* This is done for the sake of downward compatibility. - It *does* mean that the first string in static_str cannot - be an attribute's yes/no string. */ - -/* "0" pointers in this case will actually be equal to static_str - (since that is the base point for all pointers to static strings.) */ - -const char base_yesstr[]="yes"; -const char base_nostr[]="no"; - -static void conv_fstr(const char **s, rbool yes, rbool to_intern) -{ - if (to_intern) { /* Convert to internal form */ - assert(*s!=NULL); - if (*s==static_str) *s= yes ? base_yesstr : base_nostr; - } else { /* convert to external form */ - if (*s==NULL || *s== base_yesstr || *s==base_nostr) - *s=static_str; - } -} - -static void fix_objflag_str(rbool to_intern) -{ - int i; - for(i=0;i= old_base_verb to BASE_VERB */ - memmove(synlist+BASE_VERB,synlist+old_base_verb, - sizeof(slist)*(DVERB+MAX_SUB) ); - - if (BASE_VERB2) { - rprintf("Unsupported AGX file version.\n"); - rprintf(" Either the file is corrupted or or you need a more recent " - "version of AGiliTy.\n"); - rprintf("\n"); - fatal("Can't read AGX file."); - } - - index_recsize=compute_recsize(fi_index); - if (filehead.version==0) { - if (debug_da1) - rprintf("[AGX version 0: obsolete.]\n"); - index_recsize+=8; /* Extra junk block in version 0. */ - index_start=8; - } else { - index_start=16; - if (filehead.eol_chk1!='\n' || filehead.eol_chk2!='\r') - fatal("File apparently downloaded as non-binary file."); - } - if (filehead.ext_own!='R' - || (filehead.version==0 && filehead.extnum>1) - || (filehead.version==1 && filehead.extnum>7) - || (filehead.version==2 && filehead.extnum>2) ) - agtwarn("Unrecognized extension to AGX file format.",0); - if (filehead.ext_own!='R') { /* Assume lowest common denomenator */ - if (filehead.version<2) - fatal("Extensions of AGX beta versions not supported."); - if (filehead.fallback_ext<1) filehead.fallback_ext=1; - } - - /* Now read master index */ - /* This assumes that the file is long enough to absorb any - 'extra' blocks we read in in early versions with fewer blocks. */ - /* (Right now, this must be true: the next block alone is big enough) */ - index=read_recarray(NULL,sizeof(index_rec),AGX_NUMBLOCK, - fi_index, "File Index",index_start, - index_recsize*AGX_NUMBLOCK); - - /* Zero index entries for any blocks that are beyond the bounds of the - file's index */ - if (AGX_NUMBLOCK>index[0].numrec) - memset(index+index[0].numrec,0, - (AGX_NUMBLOCK-index[0].numrec)*sizeof(index_rec)); - - if (DIAG) { - rprintf("\n"); - rprintf("File Index:\n"); - rprintf(" Offset Size NumRec RecSz\n"); - rprintf(" ------ ------ ------ ------\n"); - for(i=0;ifsize) - fatal("File index points past end of file."); - } - - /* Check for mandatory fields */ - if (!index[0].numrec /* File index */ - || !index[1].numrec /* Game header */ - || !index[13].numrec /* Static string block */ - || !index[15].numrec /* Synonym list */ - || !index[19].numrec /* Syntbl */ - || !index[20].numrec /* Dictionary text */ - || !index[21].numrec /* Dictionary index */ - ) - fatal("AGX file missing mandatory block."); - - - read_globalrec(fi_gameinfo,"Game Info",index[1].file_offset, - index[1].blocksize); - if (filehead.version==0 && filehead.extnum==0) { - exitmsg_base=1000; - if (aver>=AGT15) - box_title=1; - } - if (index[1].blocksize==83 && filehead.version==1 && filehead.extnum>=5) { - /* Detect 0.8-compatibility hack */ - filehead.extnum=2; - } - if (filehead.version==0 || (filehead.version==1 && filehead.extnum<5)) { - if (aver>=AGT182 && aver<=AGT18MAX) - {if (filehead.extnum<4) TWO_CYCLE=1;} - else - PURE_AFTER=1; - } - - /* Need to read in ss_array before rooms/nouns/creatures */ - ss_size=ss_end=index[13].numrec; - static_str=read_recblock(NULL,FT_CHAR, - index[13].numrec,index[13].file_offset, - index[13].blocksize); - - synptr=syntbl_size=index[19].numrec; - syntbl=read_recblock(NULL,FT_WORD,index[19].numrec,index[19].file_offset, - index[19].blocksize); - - maxroom=first_room+index[2].numrec-1; - set_roomdesc(fi_room); - room=read_recarray(NULL,sizeof(room_rec),index[2].numrec, - fi_room,"Room",index[2].file_offset,index[2].blocksize); - - maxnoun=first_noun+index[3].numrec-1; - set_noundesc(fi_noun); - noun=read_recarray(NULL,sizeof(noun_rec),index[3].numrec, - fi_noun,"Noun",index[3].file_offset,index[3].blocksize); - - last_obj=maxcreat=first_creat+index[4].numrec-1; - set_creatdesc(fi_creat); - creature=read_recarray(NULL,sizeof(creat_rec),index[4].numrec, - fi_creat,"Creature",index[4].file_offset, - index[4].blocksize); - - last_cmd=index[5].numrec; - set_cmdptr(fi_cmdhead); - command=read_recarray(NULL,sizeof(cmd_rec),index[5].numrec, - fi_cmdhead,"Metacommand",index[5].file_offset, - index[5].blocksize); - if (filehead.ext_own!='R' && filehead.fallback_ext<=1) { - int i; - for(i=0;iMAX_PIX) { - index[16].numrec=MAX_PIX; - index[16].blocksize=index[16].recsize*index[16].numrec; - } - maxpix=index[16].numrec; - for(i=0;iMAX_FLAG_NOUN) { - index[18].numrec=MAX_FLAG_NOUN; - index[18].blocksize=index[18].recsize*index[18].numrec; - } - - for(i=0;i14) index[22].numrec=14; - read_recblock(opt_data,FT_BYTE,index[22].numrec,index[22].file_offset, - index[22].blocksize); - } - - maxpict=index[23].numrec; - pictlist=read_recblock(NULL,FT_STR,index[23].numrec,index[23].file_offset, - index[23].blocksize); - maxpix=index[24].numrec; - pixlist=read_recblock(NULL,FT_STR,index[24].numrec,index[24].file_offset, - index[24].blocksize); - maxfont=index[25].numrec; - fontlist=read_recblock(NULL,FT_STR,index[25].numrec,index[25].file_offset, - index[25].blocksize); - maxsong=index[26].numrec; - songlist=read_recblock(NULL,FT_STR,index[26].numrec,index[26].file_offset, - index[26].blocksize); - - vm_size=index[27].numrec; - verbinfo=read_recarray(NULL,sizeof(verbentry_rec),index[27].numrec, - fi_verbentry,"Menu Vocabulary",index[27].file_offset, - index[27].blocksize); - - /* Check that objflag and objprop fields are of correct size */ - if (index[30].numrec != objextsize(0)) - fatal("Object flag block not of the correct size."); - - if (index[31].numrec != objextsize(1)) - fatal("Object property block not of the correct size."); - - objflag=read_recblock(NULL,FT_BYTE,index[30].numrec,index[30].file_offset, - index[30].blocksize); - objprop=read_recblock(NULL,FT_INT32,index[31].numrec,index[31].file_offset, - index[31].blocksize); - - oflag_cnt=index[32].numrec; - attrtable=read_recarray(NULL,sizeof(attrdef_rec),index[32].numrec, - fi_attrrec,"Object Flag Table", - index[32].file_offset, - index[32].blocksize); - /* Objflags are converted to internal form later, after - block 36 has been read in. */ - - oprop_cnt=index[33].numrec; - proptable=read_recarray(NULL,sizeof(propdef_rec),index[33].numrec, - fi_proprec,"Object Property Table", - index[33].file_offset, - index[33].blocksize); - - if (filehead.ext_own!='R' && filehead.fallback_ext<=1) { - /* Non-standard extension */ - int i; - for(i=0;istart=0; - dp->size=0; - return; - } - - for(i=0;txt[i]!=NULL;i++) /* Compute size */ - size+=strlen(txt[i])+1; /* Remember trailing \0 */ - buff=rmalloc(sizeof(char)*size); - - buffptr=buff; - for(i=0;txt[i]!=NULL;i++) { - for(src=txt[i];*src!=0;src++,buffptr++) - *buffptr=*src; - *buffptr++=0; - } - dp->start=gindex[11].numrec; - dp->size=size; - gindex[11].numrec+= - write_recblock(buff,FT_CHAR,size, - gindex[11].file_offset+gindex[11].numrec); - rfree(buff); -} - -/* Write command text to file and return number of bytes written. */ -static long write_command(long cmdofs) -{ - long i, cnt; - - cmd_ptr=rmalloc(sizeof(long)*last_cmd); - cnt=0; - for(i=0;i -#include -#include "agility.h" - -/* ------------------------------------------------------------------- */ -/* Purity flag initialization */ -/* Logically, these belong in agtdata.c, but I wanted to keep them */ -/* near the CFG reading routines. */ -/* ------------------------------------------------------------------- */ -/* The following are AGT 'purity' flags; they turn off features of */ -/* my interpreter that are not fully consistent with the original AGT */ -/* and so could break some games. Some of these are trivial improvements; */ -/* some are more radical and should be used with caution. Several are */ -/* only useful if a game was designed with them in mind. */ -/* In all cases, setting the flag to 1 more closely follows the */ -/* behavior of the original interpreters */ -/* WARNING: Many of these haven't been tested extenstivly in the non-default - state. */ - - -rbool PURE_ANSWER=0; /* For ME questions, requires that AND-separated - answers be in the same order in the player's - answer as they are in the game file. According - to the AGT documentation, AND should ignore - the order, but the original AGT interpreters - (at least the one I've tested) don't conform - to this. */ - -rbool PURE_TIME=1; /* Set to 0 causes time to always be increased - by delta_time rather than by a random amount - between 0 and delta_time. Only really of any use - to a game author who wanted to write a game - explicitly for AGiliTy. */ - -/* rbool PURE_BOLD=1; Set to 0 causes the backslash to toggle bold on and - off for all versions of AGT, not just 1.8x. - I can think of no reason to do this unless - you are an AGT author who wants to use the 1.8x - bold feature with the Master's Edition compiler. */ - -rbool PURE_AND=1; /* increment the turn counter for each noun in a - chain of AND AND ... If 0, the turn - counter will only be incremented by one in such a case. - (need to do something about metacommands, as well...) */ - -rbool PURE_METAVERB=1; /* If set, ANY and AFTER commands are run even - if you type in a metaverb (SAVE, RESTORE,... - that is, any verb that doesn't cause time to - pass). Verb specific metacommands are _always_ - run. */ - -rbool PURE_ROOMTITLE=1; /* If 0, the interpreter will print out room - names before room descriptions even for - pre-ME games */ - -rbool PURE_SYN=0; /* Treats synonyms as nouns when parsing: that is, they - must show up only as the last word and they have the - same priority as noun matches during disambiguation. - If this is 0, then synonyms can appear anywhere in - the name the player types in but are still - disambiguated as nouns. */ - -rbool PURE_NOUN=0; /* _Requires_ a noun to end a word. This is only - imperfectly supported: if there are no other - possible matches the parser will take the adjective- - only one anyhow. Frankly, I can't think of any reason - to set this to 1, but it's included for completeness - sake (and for any AGT Purists out there :-) ) */ - -rbool PURE_ADJ=1; /* Picks noun/syn-matches over pure adj matches - when disambiguating. This is redundant if PURE_NOUN=1 - since in that case pure adjective matches will - be rejected anyhow. */ - -rbool PURE_DUMMY=0; /* If set, the player can running dummy verbs - in the game by typing 'dummy_verb3'; otherwise, - this will produce an error message */ - -rbool PURE_SUBNAME=0; /* If set, the player can run subroutines from - the parse line by typing (e.g.) 'subroutine4' - (yes, the original AGT interpreters actually - allow this). If cleared, this cheat isn't - available */ -rbool PURE_PROSUB=0; /* If clear, then $you$ substitutions are done - everywhere $$ substitutions are, even in - messages written by the game author. - If set, these substitutions are only made - in internal game messages */ - -rbool PURE_HOSTILE=1; /* =0 Will allow you to leave a room with a hostile - creature if you go back the way you came */ -rbool PURE_ALL=1; /* =0 will cause the parser to expand ALL */ -rbool PURE_DISAMBIG=1; /* =0 will cause intelligent disambiguation */ -rbool PURE_GETHOSTILE=1; /* =0 will prevent the player from picking things - up in a room with a hostile creature */ - -rbool PURE_OBJ_DESC=1; /* =0 prevents [providing light] messages - from being shown */ - -rbool PURE_ERROR=0; /* =1 means no GAME ERROR messages will be printed - out */ - -rbool PURE_SIZE=1; /* =0 eliminates size/weight limits on how many - things the player can wear or carry. (But it's - still impossible to pick things up that are - in themselves larger than the player's capacity) */ - -rbool PURE_GRAMMAR=1; /* =0 prints error messages if the player uses a - built in verb with an extra object. - (e.g. YELL CHAIR). Otherwise, the extra object - will just be ignored. */ - -rbool PURE_SYSMSG=1; /* =0 causes AGiliTy to always use the default - messages even if the game file has its own - standard error messages. */ - -rbool PURE_AFTER=1; /* =0 causes LOOK and other end-of-turn events - to happen *before* AFTER commands run. */ - -rbool PURE_PROPER=1; /* Don't automatically treat creatures as proper nouns */ - -rbool TWO_CYCLE=0; /* AGT 1.83-style two-cycle metacommand execution. */ -rbool FORCE_VERSION=0; /* Load even if the version is wrong. */ - - -/*-------------------------------------------------------------------------*/ -/* .CFG reading routines */ -/*-------------------------------------------------------------------------*/ - -/* The main interpreter handles configuration in this order: - 1) Global configuration file - 2) First pass through game specific CFG to get the settings for - SLASH_BOLD and IBM_CHAR which we need to know _before_ reading - in the game. - 3) Read in the game. - 4) Main pass through game specific CFG. Doing it here ensures that - its settings will override those in the gamefile. - Secondary programs (such as agt2agx) usually only call this once, for - the game specific configuration file. - */ - -#define opt(s) (strcasecmp(optstr[0],s)==0) - -static void cfg_option(int optnum,char *optstr[], rbool lastpass) -/* This is passed each of the options; it is responsible for parsing - them or passing them on to the platform-specific option handler - agt_option() */ -/* lastpass is set if it is the last pass through this configuration - file; it is false only on the first pass through the game specific - configuration file during the run of the main interpreter */ -{ - rbool setflag; - - if (optnum==0 || optstr[0]==NULL) return; - - if (strncasecmp(optstr[0],"no_",3)==0) { - optstr[0]+=3; - setflag=0; - } else setflag=1; - - if (opt("slash_bold")) bold_mode=setflag; - else if (!lastpass) { - /* On the first pass, we ignore all but a few options */ - agil_option(optnum,optstr,setflag,lastpass); - return; - } - else if (opt("irun")) irun_mode=setflag; - else if (opt("block_hostile")) PURE_HOSTILE=setflag; - else if (opt("get_hostile")) PURE_GETHOSTILE=setflag; - else if (opt("debug")) { - if (!agx_file && aver<=AGTME10) debug_mode=setflag; - if (setflag==0) debug_mode=0; /* Can always turn debugging support off */ - } - else if (opt("pure_answer")) PURE_ANSWER=setflag; - else if (opt("const_time")) PURE_TIME=!setflag; - else if (opt("fix_multinoun")) PURE_AND=!setflag; - else if (opt("fix_metaverb")) PURE_METAVERB=!setflag; - else if (opt("roomtitle")) PURE_ROOMTITLE=!setflag; - else if (opt("pure_synonym")) PURE_SYN=setflag; - else if (opt("adj_noun")) PURE_ADJ=!setflag; - else if (opt("pure_dummy")) PURE_DUMMY=setflag; - else if (opt("pure_subroutine")) PURE_SUBNAME=setflag; - else if (opt("pronoun_subs")) PURE_PROSUB=!setflag; - else if (opt("verbose")) verboseflag=setflag; - else if (opt("fixed_font")) font_status=1+!setflag; - else if (opt("alt_any")) mars_fix=setflag; - else if (opt("smart_disambig")) PURE_DISAMBIG=!setflag; - else if (opt("expand_all")) PURE_ALL=!setflag; - else if (opt("object_notes")) PURE_OBJ_DESC=setflag; - else if (opt("error")) PURE_ERROR=!setflag; - else if (opt("ignore_size")) PURE_SIZE=!setflag; - else if (opt("check_grammar")) PURE_GRAMMAR=!setflag; - else if (opt("default_errors")) PURE_SYSMSG=!setflag; - else if (opt("pure_after")) PURE_AFTER=!setflag; - else if (opt("proper_creature")) PURE_PROPER=!setflag; - else agil_option(optnum,optstr,setflag,lastpass); -} - -#undef opt - -/* Returns false if it there are too many tokens on the line */ -rbool parse_config_line(char *buff, rbool lastpass) -{ - char *opt[50], *p; - int optc; - - optc=0; - opt[0]=NULL; - for(p=buff;*p;p++) { - if (isspace(*p)) { /* Whitespace */ - if (opt[optc]!=NULL) {/*... which means this is the first whitespace */ - if (optc==50) return 0; /* Too many */ - opt[++optc]=NULL; - } - *p=0; - } else /* No whitespace */ - if (opt[optc]==NULL) /* ...this is the first non-whitespace */ - opt[optc]=p; - } - if (opt[optc]!=NULL) opt[++optc]=NULL; - cfg_option(optc,opt,lastpass); - return 1; -} - - -/* For the meaning of lastpass, see comments to cfg_option() above */ -void read_config(genfile cfgfile, rbool lastpass) -{ - char buff[100]; - - if (!filevalid(cfgfile,fCFG)) return; - - while(readln(cfgfile,buff,99)) { - if (buff[0]=='#') continue; /* Comments */ - /* Now we parse the line into words, with opt[] pointing at the words - and optc counting how many there are. */ - if (!parse_config_line(buff,lastpass)) - rprintf("Too many tokens on configuration line.\n"); - } - readclose(cfgfile); -} - - - -/*-------------------------------------------------------------------------*/ -/* Read OPT file */ -/* (most of these routines used to be in agil.c) */ -/*-------------------------------------------------------------------------*/ - -/* .OPT reading routines */ -/* I've put the comments on the format here because they don't really - belong anywhere else. (Maybe in agility.h, but I don't want to further - clutter that already quite cluttered file with something as peripheral - as this) */ -/* OPT file format: the .OPT file consists of 14 bytes. They are: - 0 Screen size(0=43/50 rows, 1=25 rows) - 1 Status line(1=top, 0=none, -1=bottom) - 2 Unknown, always seems to be 0 - 3 Put box around status line? - 4 Sound on? - 5 Menus on? - 6 Fixed input line? - 7 Print transcript? - 8 Height of menus (3, 4, 5, 6, 7, or 8) - 9 Unknown, always seems to be 0 - 10-13 Color scheme: output/status/input/menu, specified in DOS attribute - format (Bbbbffff, B=blink, b=backround, f=foreground, - MSB of foreground specifies intensity ("bold") ). */ -/* The interpreter ignores almost all of this. */ - -void read_opt(fc_type fc) -{ - char *errstr; - genfile optfile; - - have_opt=0; - optfile=openbin(fc,fOPT,NULL,0); - if (filevalid(optfile,fOPT)) { - if (!binread(optfile,opt_data,14,1,&errstr)) - fatal("Invalid OPT file."); - have_opt=1; - readclose(optfile); - } -} - - -/*-------------------------------------------------------------------------*/ -/* Read and process TTL */ -/* (most of these routines used to be in agil.c) */ -/*-------------------------------------------------------------------------*/ - -/* Shades of Gray uses a custom interpreter that prints out the names - of the authors as the program loads. */ -/* Normally I wouldn't bother with this, but Shades of Gray is probably - the best known of all AGT games */ - -#define SOGCREDIT 7 -static const char *sogauthor[SOGCREDIT]={ - "Mark \"Sam\" Baker", - "Steve \"Aaargh\" Bauman", - "Belisana \"The\" Magnificent", - "Mike \"of Locksley\" Laskey", - "Judith \"Teela Brown\" Pintar", - "Hercules \"The Loyal\" SysOp", - "Cindy \"Nearly Amelia\" Yans" -}; - -static rbool check_dollar(char *s) -/* Determines if s consists of an empty string with a single dollar sign - and possibly whitespace */ -{ - rbool dfound; - dfound=0; - for(;*s!=0;s++) - if (*s=='$' && !dfound) dfound=1; - else if (!rspace(*s)) return 0; - return dfound; -} - -descr_line *read_ttl(fc_type fc) -{ - genfile ttlfile; - int i, j, height; - descr_line *buff; - - ttlfile=openfile(fc,fTTL,NULL,0); - /* "Warning: Could not open title file '%s'." */ - if (!filevalid(ttlfile,fTTL)) return NULL; - build_fixchar(); - - buff=rmalloc(sizeof(descr_line)); - i=0; - while( NULL!=(buff[i]=readln(ttlfile,NULL,0)) ) { - if (strncmp(buff[i],"END OF FILE",11)==0) break; - else if (aver>=AGT18 && aver<=AGT18MAX && check_dollar(buff[i])) - statusmode=4; - else { - for(j=0;buff[i][j]!=0;j++) - buff[i][j]=fixchar[(uchar)buff[i][j]]; - /* Advance i and set the next pointer to NULL */ - buff=rrealloc(buff,sizeof(descr_line)*(++i + 1)); - buff[i]=NULL; - } - rfree(buff[i]); - } - readclose(ttlfile); - - rfree(buff[i]); - while(buff[i]==NULL || strlen(buff[i])<=1) { /* Discard 'empty' lines */ - if (i==0) break; - rfree(buff[i]); - i--; - } - height=i; - - if (aver==AGTCOS && ver==4 && height>=17) /* SOGGY */ - for(i=0;i0) - add_verbrec(newvoc[newindex++],1); - - verbinfo=rrealloc(verbinfo,(vm_size+1)*sizeof(verbentry_rec)); - - s[0]=verbline[0];s[1]=0; - verbinfo[vm_size].objnum=strtol(s,NULL,10)-1; - - verbline+=2; /* Skip over number */ - - verbinfo[vm_size].verb=verbinfo[vm_size].prep=0; - p=verbline; - if (*p!=0) { - while(*p && !rspace(*p)) p++; - if (*p!=0) { - *p=0; - p++; - } - verbinfo[vm_size].verb=search_dict(verbline); - if (verbinfo[vm_size].verb==-1) { - verbinfo[vm_size].verb=0;return;} - if (*p!=0) { - verbinfo[vm_size].prep=search_dict(p); - if (verbinfo[vm_size].prep==-1) - verbinfo[vm_size].prep=0; - } - } - vm_size++; -} - -void init_verbrec(void) -/* Need to insert special verbs into verbinfo */ -/* Fill in vnum field */ -/* UNDO, RESTART, MENU */ -{ - verbinfo=NULL; - vm_size=0; - newindex=0; - if (freeze_mode) newindex=1; /* Don't include MENU option if we can't - use it. */ -} - -void finish_verbrec(void) -{ - for(;newindex<3;newindex++) add_verbrec(newvoc[newindex],1); -} - - -void read_voc(fc_type fc) -{ - char linbuf[80]; - genfile vocfile; - - init_verbrec(); - vocfile=openfile(fc,fVOC,NULL,0); - if (filevalid(vocfile,fVOC)) { /* Vocabulary file exists */ - while(readln(vocfile,linbuf,79)) - add_verbrec(linbuf,0); - readclose(vocfile); - finish_verbrec(); - } -} - - - - -/*-------------------------------------------------------------------------*/ -/* Read INS file */ -/* (most of these routines used to be in agil.c) */ -/*-------------------------------------------------------------------------*/ - - -static genfile insfile=BAD_TEXTFILE; -static char *ins_buff; - -static descr_line *ins_descr=NULL; -static int ins_line; /* Current instruction line */ - - -/* Return 1 on success, 0 on failure */ -rbool open_ins_file(fc_type fc, rbool report_error) -{ - ins_buff=NULL; - ins_line=0; - - if (ins_descr!=NULL) return 1; - - if (filevalid(insfile,fINS)) { - textrewind(insfile); - return 1; - } - - if (agx_file) { - ins_descr=read_descr(ins_ptr.start,ins_ptr.size); - if (ins_descr!=NULL) return 1; - - /* Note that if the AGX file doesn't contain an INS block, we - don't immediatly give up but try opening .INS */ - } - - insfile=openfile(fc, fINS, - report_error - ? "Sorry, Instructions aren't available for this game" - : NULL, - 0); - return(filevalid(insfile,fINS)); -} - -char *read_ins_line(void) -{ - if (ins_descr) { - if (ins_descr[ins_line]!=NULL) - return ins_descr[ins_line++]; - else return NULL; - } else { - rfree(ins_buff); - ins_buff=readln(insfile,NULL,0); - return ins_buff; - } -} - -void close_ins_file(void) -{ - if (ins_descr) { - free_descr(ins_descr); - ins_descr=NULL; - } else if (filevalid(insfile,fINS)) { - rfree(ins_buff); - readclose(insfile); - insfile=BAD_TEXTFILE; - } -} - - - -descr_line *read_ins(fc_type fc) -{ - descr_line *txt; - char *buff; - int i; - - i=0; - txt=NULL; - if (open_ins_file(fc,0)) { /* Instruction file exists */ - while ( NULL!=(buff=read_ins_line()) ) { - /* Enlarge txt; we use (i+2) here to leave space for the trailing \0 */ - txt=rrealloc(txt,sizeof(descr_ptr)*(i+2)); - txt[i++]=rstrdup(buff); - } - if (txt!=NULL) - txt[i]=0; /* There is space for this since we used (i+2) above */ - close_ins_file(); - } - return txt; -} - - -void free_ins(descr_line *instr) -{ - int i; - if (instr==NULL) return; - for(i=0;instr[i]!=NULL;i++) - rfree(instr[i]); - rfree(instr); -} - - - -/* Character translation routines, used by agtread.c and read_ttl() */ -void build_fixchar(void) -{ - int i; - for(i=0;i<256;i++) { - if (i=='\r' || i=='\n') fixchar[i]=' '; - else if (i=='\\' && bold_mode) fixchar[i]=FORMAT_CODE; - else if (i>=0x80 && fix_ascii_flag) - fixchar[i]=trans_ibm[i & 0x7f]; - else if (i==0) /* Fix color and blink codes */ - fixchar[i]=FORMAT_CODE; - else fixchar[i]=i; - } -} - - - diff --git a/app/src/main/jni/terps/agility/changes.txt b/app/src/main/jni/terps/agility/changes.txt deleted file mode 100644 index 288ab4f..0000000 --- a/app/src/main/jni/terps/agility/changes.txt +++ /dev/null @@ -1,641 +0,0 @@ -LIST OF CHANGES SINCE VERSION 0.1 - -CHANGES FOR VERSION 1.1.1 - --Fixed output function: paragraph filling corrected; made filling -less agressive for Magx games; fixed print_statline to work with a -screen width greater than 100. - --Object loops more carefully trapped, avoiding infinite loops. Object -loop error no longer printed out. - --IsWorn and IsCarried no longer look inside closed objects. [Al] - --Fixed handling of AGT_DEBUG_CMD by agt_newgame(). [Kinder] - --*nix port changes: MORE handling fixed; os_linux.c renamed os_termcap.c; -os_curses.c is now the main *nix interface; os_curses version of fix_loc() -fixed; os_curses batch support fixed. - --32-Bit DOS port: BIOS option now works. - --Fixed formatting in debugger object editor. - - -CHANGES FOR VERSION 1.1 - --The interpreter will now work correctly when passed an AGT file -name with an extension (instead of trying to read it as an AGX file). - --Overhauled STANDARD message handling: ATTACK messages will now get -the $noun$ and $object$ in the right order; parser messages now -replaceable; $noun$-type substitutions are prevented in cases where -they are not meaningful; added message fallback system to stdmsg(); -added '-s' command line option for debugging standard messages; added -$the_name$, $name_pro$, $name_indir$; fixed capitalization of proper -$name$s; $/# substitution routines simplified. - --Debugger now supports objprops, objflags, and PROPER. - --New metacommand tokens: CanGo and MoveInDirection. - --Added support for printing objprops and objflags. - --Added support for itemized objprops/variables/objflags/flags. - --Added support for explicit objects to redirection and command -headers. - --Null NOUN/OBJECT/ACTOR args to conditional tokens will no longer -generate GAME ERROR messages. - --Added $ and # expansion to shortdescs of nouns and creatures. - --Misc bug fixes:initialization of seen and proper for original AGT games; -types in GAME ERROR messages; objswap in exec_verb(); parse_noun will -no longer look for multiple nouns when parsing the actor; possible -buffer overrun in wordcode_match; added second line of vb== conditions -to verify_scope. - --Overhauled handling of dobj_rec, iobj_rec, actor_rec: they -are now copied and freed by runverbs() and objcheck_cycle(); -added copy_parserec(), free_all_parserec(); - --Fixed e-mail address and Jay's URL. - - -CHANGES FOR VERSION 1.0 - --Added support for proper names of creatures and nouns, indicated -by the object in question having the PROPER flag set. Proper names -are printed capitalized and without the definite article ("Fred" -instead of "the fred"). Note that this change only affects built-in -messages, and game messages that use the new $the_n$, $the_o$, and -$the_c$ substitutions. - --As part of this change, added the PROPER_CREATURE configuration -option which will make *all* creature names proper. - --For pre-Magx games, built-in verb synonyms now take precedence -over author-defined ones. For example, N will now be interpretered as -NORTH, even in games that try to redefine it as meaning "NO". (Games -created using VERSION MAGX will still honor the author's intent.) - --PLAY WITH is longer automatically converted to PLAY. [Metcalf] - --TURN ON can now trigger specials [Metcalf]; in general, the -handling of constructions for pre-Magx -games has been fixed. - --Items contained in worn objects are now also considered to be worn. - --Short description used instead of adjective-noun for nested -inventory items. [Metcalf] - --Fixed problem with empty filenames in get_user_file. - --$ strings no longer forced to lower case before substitution. - --32-bit DOS version now supports graphics and fonts. - --'strptr' changed to 'ss_end', to conform to ANSI C namespace -requirements. - - -CHANGES FOR VERSION 0.9.1 - --Fixed reading of Master's Edition games, which was broken by the -roomflag changes in 0.9. - - -CHANGES FOR VERSION 0.9 - --ALL now ignores the contents of objects that are already selected. - --Fixed RoomFlag handling for more than 16 roomflags; reduced -the official limit on number of roomflags to 31. [Mlinar] - --KillPlayer now ends metacommand execution. [Jay] - --DescribeThing now works correctly. [Tarkin] - --Disambiguation of GET fixed to deal with containers. [Turpin] - --Fixed conflict between autoexec verbs and AFTER. [Turpin] - --Fixed reading in of answers from large AGX files. [Myrow] - --Typographical fixes: pronoun references in v_attack() error messages -and the spelling of resurrection. - --Dissassember changes: top-of-stack and indirect references fixed; -newlines after OnFailGoto corrected; debug settings in AGTOUT fixed. - - -CHANGES FOR VERSION 0.8.9 - --DOS binary recompiled with correct source files. - --Fixed AGX incompatibility problem with pre-0.8.8 interpreters. -Standard AGX version raised to 2. - --Fixed large save-file support: DOS version can now handle save -files up to 64K and there is a (theoretical) upper limit of 2GB for -appropriate platforms. - --Fixed reading of AGX files with no descriptions. - - -CHANGES FOR VERSION 0.8.8 - --Added REPLAY FAST command and fast_replay flag. - --Room descriptions are now printed out after ressurection. [Jay] - --The debugger now splits noun attributes across three columns. - --Added support for user defined object flags and properties, including -new metacommand tokens ObjFlagOn, ObjFlagOff, TurnObjFlagOn, TurnObjFlagOff, -ToggleObjFlag, PushObjProp, and PopObjProp. - --Action tokens that only affect the stack no longer force then end of -an OR block. (This allows the stack to be used for computations in such a -block.) - --Changed names of IsSet/Set/Clear to AttrOn/TurnAttrOn/TurnAttrOff. - --Two-argument metacommand tokens now work correctly with NOUN and OBJECT. - --Two-argument metacommands with a double top-of-stack reference now -pops the second argument first. - --Fixed handling of NOUNInRoom, DescribeThing, and EndDisambig tokens. - --Fixed 16-bit overflow bug in loadgame(). [Tarkin] - --DOS DA6 buffering adjusted to fit in 32K. - - -CHANGES FOR VERSION 0.8.7 - --COLOURS option (as synonym for COLORS) added. - --Added 50_LINE and BLOCK_CURSOR configuration options to DOS port. - --Most command line options are now case-insensitive - --Added support for $FLAG[obj]$, $ON[obj]$, $OPEN[obj]$, $LOCKED[obj]$ -[Patch contributed by Mitch Mlinar]. - --New token: HasSeen. (Warning: this is untested.) - --Pure-stack operations are no longer treated as action tokens for -disambiguation purposes. - --The game stack is now cleared before each major metacommand scan -although not before DoSubroutine or RedirectTo initiated scans. - --Delay no longer divides by two. - --Corrected handling of RoomNeedsLight. - --Bugs fixed: direct address with multiple actors of same name, -"start==-1" problem in agtread.c, objname handling of missing -adjectives, object.c problems with creatureless games, agtout display -of non-printable owner-ids, BeforeCommand/AfterCommand handling during -disambiguation, premature closing of the description file in agt2agx -(giving a "Bad file number" error under DOS), DOS memory allocation -error ("Failed Assertion: size>=0" when loading games with 500 or more -nouns), and a couple of typos in game messages. - --Fixed PUSH error message handling and compute_addr diagnostics -[Patch submitted by Paul Mikell]. - --Addition of quitflag tests in a few places [Patch contributed by -Mitch Mlinar]. - - -CHANGES FOR VERSION 0.8.6 - --Added NAVARROW configuration option to Linux and DOS version, -which allows the arrow keys to be used for navigation instead of editing. - --Added PURE_AFTER configuration option. (This affects whether LOOKs -occur before or after AFTER commands.) - --OncePerTurn now triggers on _last_ object in a list if called from -AFTER or COMMAND AFTER block. Furthermore, AfterCommand is now true in -a COMMAND AFTER block. - --Bad operand errors will no longer stop metacommand execution. - --Added version detection support, including the FORCE_LOAD -configuration option to override it. - --Added string tokens: CompareStrings, StringBefore, StringAfter, -StringIsAnswer,, CopyString, UpcaseString, DowncaseString. - --Added XRedirect metacommand token to allow multiple RedirecTos in -an AGATE command structure. - --Added fixed font formatting code as well as FIXED_FONT -configuration option. - --Filename handling has been completely overhauled. All file I/O now -goes through the new file "filename.c". All FILE* references have -been replace by "genfile" and all uses of the game name have been -replaced by 'file context' elements. - --Miscellaneous fixes: bold text in the DOS port should now be the -right color; use of 'class' and 'new' was eliminated from the source -code to avoid conflict with C++; eliminated error message when title -file not found; disambiguation now correctly accounts for two-cycle -execution; fixed bug in rsort() so it can deal with multiple -RedirectTo headers; tweaked concdup(); started adding hint data -structures; handling of user strings fixed. - - -CHANGES FOR VERSION 0.8.5 - --Added DEFAULT_ERRORS configuration option. - --TALK to a nonexistant object goes to STD 179 instead of 184. [Y23/24] - --Platform dependent information has been broken off into a seperate -include file, config.h, which is #included in agility.h. - --Changed source code filenames to improve readability: - agtread.h-->agility.h; uagt.h-->interp.h; - agtdata.c-->gamedata.c; agtdbg.c-->disassemble.c; - agttest.c-->agtout.c; rmem.c-->util.c - --Converted bool to rbool to avoid conflicts with other libraries and -systems. - --Documentation of agt_textcolor() fixed. - --Fixed 1.83 command sequence and moved Master's Edition AFTER commands -after 1.83 after-command group. - --Added TWO_CYCLE option to turn on the 1.83-style command sequence. - --Added flagnum and isglobal to nouns and creatures. [YS2] - --Bugs fixed: unmovable objects and DROP [Y22]; segfault if D$$ file -not present; buffer sizing in buffopen() and buffreopen; DOS titlebox -colors. - --Fixed $turn$ message. - --Added range checking to the debugger. - - -CHANGES FOR VERSION 0.8.4 - --Corrected AGT 1.5/P to AGT 1.6. - --Added BIOS option to DOS port. - --Added EndDisambig token. - --Made UNMOVABLE nouns undropable/unremovable. [YS1] - --Fixed error messages for THROW, TALK, and REMOVE [Y19,20,21] - --Bugs fixed: actor metacommands not scanned correctly; spurious -"Preposition needs object" message [Y18]; TURN ON/OFF not parsed -correctly; ToggleMovable broken; yank segfault under Linux. - --Eliminated spurious "preposition needs object" message. [Y18] - --DOS port: Turned off common subexpression elimination in compiler -to fix PORK "climb tree" bug. - - -CHANGES FOR VERSION 0.8.3 - --Added CHECK_GRAMMAR configuration option. - --DOS output now goes through BIOS calls. - --File routines now chop AGX, D$$, and DA1 extensions off before adding -another extension. - --SHOW without an object now converted to SHOW EXITS. [Y12] - --LOOK converted into EXAMINE (unless the game has a -metacommand overriding LOOK ). [Y16] - --Global noun handling fixed: EXAMINING one now gives a sensible -message and $adjective$ handling has been fixed to deal with them. [Y10&11] - --SHOOT will now treat a lone object as the target if it is not -shootable. [Y6] - --Eliminated internal error caused by "TALK" with no object. [Y7] - --Trace output now prints out metacommand adjective match fields. - --Redirection turns off checking for excess objects under certain -conditions. [Y4/17] - --The tokensier uses context is used to determine whether '.' should -be treated as a letter or as puncutation. - --Added support for fields in metacommand header distinct -from ANY fields. (Untested) - --Fixed restoring of noun.position. - - -CHANGES FOR VERSION 0.8.2 - --Fixed Room debugging fields - --Added $you're$ and rewrote some of the error messages to take -advantage of it. - --Fixed enter and exit messages. - --Tweaked display of contents of invisible items. - --Support for new tokens: Equal, GT, LT, GE, LE, Goto, OnFailGoto. - --Parser now recognizes roomflag nouns even when they aren't present. - --Fixed verb redirection bug. - --Rewrote run_metacommand. - --Rewrote visibility checking routines to handle roomflags and other -virtual objects more carefully. - --Fixed bug in check_obj. - - -CHANGES FOR VERSION 0.8.1 - --Error message for unparsable noun has been made clearer. - --GO will not be condensed to if GO has been -overridden. - --LOOK now generates action even after DoneWithTurn. - --Fixed direction names in ChangePassageway debugging output. - --Command offsets now printed for non-ME AGX files. - --Spaces now stripped from end of pre-Magx description lines - --Added 'unused' field to rooms,nouns,creatures and to agtread.c - --Added unused checking to score computation and agttest.c - --Whitespace recognition in AGT files changed to be -platform-independent. - --Fixed read_filerec so it won't read past end-of-block. - --rrealloc explicitly returns NULL (and frees the original pointer) -if passed a size of 0. - - -CHANGES FOR VERSION 0.8 - --The interpreter can now recognize AGX files that don't end in '.agx'. - --Added NO_ERROR and IGNORE_SIZE options for the CFG file. - --The parser accepts ANY, EITHER, BOTH, and ALL as responses to -disambiguation queries. - --The save file format has changed again :-(. - --Tweaked title-printing routines to use less space when the title -is large. - --Agtout now doesn't print messages for PrintRandomMessage except -by request (and then it prints the whole range, not just the actual two -arguments). - --AGTout doesn't print out standard messages unless -m flag is set. - --Added -o option to agtout. - --Debugging screens now mark fields that aren't saved/restored. - --Token tables: added support for new ME/1.0 variant, fixed the 1.83 -token translation table, and unified 1.83 and 1.83a (using 1.83a table). - --Added PATH option to Linux and DOS ports. - --Illustrations are now listed inroom description. - --Linux and DOS ports now support graphics, fonts and function keys. - --For Unix, DOS, and similar systems, RESTORE will list existing -save files. - --Linux allows script and log output to be piped. - --Added ^P,^N,^B,^F to Linux/DOS line editor - --Test mode (option -t) for automated testing of games has been added, -resulting in a new variable test_mode and more careful control of -calls to agt_readkey(). - --Added infrastructure for PATH support (gamepath). - --Moved gamename argument from init_interface to start_interface. - --Added set_file_context() and related code. - --DESCR_BUFFSIZE now controls buffering of description text for AGX -format games; AGT games are partially supported. - --New language features: direction-triggered verbs, game-defined -multiple-word verbs, game-defined prepositions, and classes. - --New tokens, for manipulating CLASS and the expression stack, -accessing arbitrary properties and attributes, and checking player -input for numbers. - --DoSubroutine now uses an explicit stack. - --POINTS added to save file. - --SPECIAL descriptions now correctly printed by agtout. - --"Scanning..." messages now use verb synonym for dummy verbs. - --The debugger adds newlines after some metacommand tokens (those -that print out messages). - --Changed ressurection smoke to dark green :-). - --Objects whose contents are all INVISIBLE won't print "Which contains:" - --Fixed $adjective$ and $noun$ substitution to avoid double-words -(e.g. 'silver silver'). - --Overhaul of built in verbs: can no longer lock open objects; -v_throw() has been rewritten to handle liquids correctly; the error -messages map more closely to the original AGT messages, including two -different messages for darkness; weight and size have been completely -rewritten to be bug-compatible with the different AGT versions. - --Handling of DOOR in parser and built-in verbs has been reworked; -it now has a lower disambig priority than any real object it the game -and Magx games no longer recognize it at all. - --Metacommand scanning is now bug-compatible with the original -interpreters; metacommands are no longer sorted at all. - -- $object$, $noun$ objects now work with $name$ as well in redirect. - --Redirection no longer changes the *real* actor. (unless a $-form -is used, of course). - --Eliminated ignore_grammer - --$verb$ will now refer to last real verb rather than "g". - --Changed verb_id() so built-in synonyms are checked before room -synonyms (although only if there is no author-defined synonym). - --noun[].pict, noun[].related_names, and creature[].pict are all now -initialized for pre-Master's Edition games. - --Bugs fixed: NOUN/OBJECT arguments with 2-arg opcodes work; COLORS -check at beginning of title now case-insensitive; AGX titles now work -with slash_bold; Statusmode 4 does what it's supposed to; eliminated -format_string() 200-character limit; counters now printed out -correctly; TurnOnCounter now sets counter to 1; capitalization of -$...$ forms with '_' fixed; FailMessage works corerctly. - --EVERYBODY now has limited support. - --Tweaked DOS color support. - --DOS doesn't create status line window until after the title is printed. - --Code reorganizations: removed FAR; moved some global variable -intialization to agtdata.c; converted \E to \033 in os_linux.c to -silence warning messages about non-ANSI escape sequences; reorganized -os_linux.c for better readability. - - -CHANGES FOR VERSION 0.7.2 - --Fixed bug in AGX file code; upped AGX file version number. - --Added #include to rmem.c and interface.c - --Fix Sun support and added Next support. - --Reorganized file name routines and added PREFIX_EXT option. - - -CHANGES FOR VERSION 0.7.1 - --Saving of counters/flags/variables and incrementing of counters -now correctly includes the last one in each group. - --Bugs fixed: memory overrun in ask_for_number() fixed, -initialization of flag/variable/counter debugging pointers now done -correctly. - --Linux port: Eliminated extra MOREs. - - -CHANGES FOR VERSION 0.7 - --The DOS and Linux versions now support command history. - --The built-in getfile() has default filenames. - --The parser uses the exitance of an ALL metacommand to determine if -a given verb should accept multiple objects. - --Whenever possible, errors are reported using the words the player -typed in. - --Configuration option NO_OBJECT_NOTES has been added. - --Noun field RELATED_NAME is supported. - --The disambiguator has been rewritten (yet again): disambiguation is -now done using a scored system (rather than the previous pass-fail -approach); it will arbitrarily pick in the case of two or more -'identical' objects; actor disambiguation has been fixed; visibile -scope is no longer assumed for dummy_verbs; a GLOBAL_SCOPE verb option -has been added to allow game authors to define verbs that act on -non-visible objects. - --Added support for multiple commands to NPCs. - --Support for new metacommands: OnDisambig, IsHostile, -HostilePresent, NameWasPresent, OncePerTurn, SubtractFromTime, -SetDisambigPriority, SetVariableToDeltaTime, ChangeStatus, -MultiplyVariable, DivideVariable, ComputeRemainder, WaitForKey, SetHE, -SetSHE, SetIT, SetTHEY, PrintMessagesNoNL, StandardMessage, -FailMessage, FailStdMessage, ErrMessage, ErrStdMessage, and AND. - --Added adjective support to the metacommand scanner. - --Assigned standard message numbers to error messages that weren't -supported by the original AGT. - --Added support for generalized operand types and NAME. - --Added color code 9 for 'true' white. - --New #define added: OPEN_AS_TEXT. - --Changed AGX writing code to avoid seeks beyond end of file. - --Created auxfile.c, moving code out of agtread.c and agtdata.c - --If EndGame is run after a 'q' command has been entered, the game -will quit without asking questions. - --A couple of bugs in the tokeniser have been fixed. - --Miscellaneous bugs fixed: noun initial descriptions print at the -correct times; SendTreasureToRoom and IsCarryingTreasure, THROW/AFTER -synonyms, BLOCK_HOSTILE, and noun.position are fixed; SHOW prints a more -reasonable default error message; fixed the error message printed when -ALL doesn't refer to anything; sorting of actor metacommands is now -correct. - --Reorganized command line argument parsing routine - - -CHANGES FOR VERSION 0.6 - --Added support for Klaustrophbia's multiple game files and save files -from previous versions of the same game. - --Added INTRO verb to reprint the introduction of the game. - --The introduction will now wait for you to hit any key before continuing. - --Pronouns are now assigned to the last direct object in preference -to the last indirect object. - --agt_save(), agt_restore(), agt_newgame(), and agt_quit() added for -use by event-driven ports. - --For DOS and Linux: Title box formatting changed slightly, and -COMPASS option added. - --Line is no longer wrapped if the remainder consists only of spaces. - --SHOOT now works. - --Eliminated redundant (being worn) message. - --Scope checks for built-in verbs have been centralized. - --agtread.h now defaults to PLAIN platform. - --Cleaned up header files. - --SAVE now uses the last UNDO block which saves memory and allows -asyncronous saves. - --Other bugs fixed: the ordering of agildebug menu, the scoring of nouns -and creatures, and processing of $your$. - - -CHANGES FOR VERSION 0.5 - --Added support for new "AGX" file format, in agxfile.c; a new set -of file manipulation routines have been added to rmem.c to support the -format. There is a new pAGX #define for the extension of the new format. - --Save and restore were rewritten to use the same file I/O code as the -AGX routines; savefmt.h no longer exists. This seems to have fixed the -bug with RESTART and UNDO overwriting the dictionary under DOS. - --Save, restore, script, and log files now add an extension automatically. - --Both the interpreter and agttest.c have been modified slightly to -work with the new file format and a new program, agt2agx, has been -added to convert AGT files to the AGX format. - --To support the new format, the TTL and INS routines in agil.c have -been rewritten. - --The interpreter now waits until there is something on the status -line before printing it out. - --Extensions to the debugger: roomflags now can be viewed and -modified; so can the gender field of creatures and user strings; -formatting of output has been improved(thanks to Jay Goemmer's -suggestions); main debugging menu reorganized; can now turn -tracing of disambiguaion and of ANY verbs off; metacommand trace now -prints out actors and REDIR instead of cryptic numbers to represent -the first field of the command header. - --dbg_nomsg added so messages will only be printed once when tracing -metacommands rather than twice. - --The function init_interface() has been replace by two functions, -init_interface() and start_interface(); - --Split exec.c into exec.c and object.c - --Added a new file, agilstub.c, which needs to be linked with the -non-interpreter utilities. - --File read/write routines now do more comprehensive error checking. - --AMIGA and HP-UX configurations have been added to the header -(thanks to David Kinder and Alexander Lehmann) - --Boxes under the DOS interface are now in reverse video. - --Fixed reading of CFG file so SLASH_BOLD would work. - --All agtread output now goes through rprintf and from there through -writestr and writeln. DIAG now defaults to 0 so there should be less -output to begin with. - --Added fix_ascii_flag and IBM_CHAR option which allow the decision -about character translation to be made at run time. - --Made a lot more limits dynamically set, including the number flags, -variables, counters, dummy verbs, and subroutines; - --LookAtRoom now prints the room description directly, rather than waiting -until the end of the turn. - --Object lists are now sorted by object number, so they will maintain -a consistent ordering. - --Changed handling of REPLACE_WORD so it will also replace synonyms. - --Line break section of writestr() rewritten to fix a couple of bugs -and os_dos.c has been fixed to get rid of extra line breaks. - --The 1.5/F decoding of the DA2 file has been fixed so _The -Multi-dimensional Thief_ should now work. - --Bugs fixed: exits now printed correctly by debugger; a few -spelling errors fixed; YesNo and Chance bug; maxpix, maxpict, etc. are -now converted to zero if they are negative; UserStrings now numbered -from 1..25 rather than 0..24; fixed centering of status line; AFTER -commands not scanned after GameEnd token anymore. - --Eliminated extra newline in Linux script files. - --Fixed bug in os_linux.c, agt_option(), that caused it to report an -error with COLORTERM - --General cleaning up of the code: picture/sound/font filenames are -now stored in the main static string array; several redundant -variables eliminated; read_descr() rewritten to work with new file -format; eliminated distinction between regular and auxilary verbs; -added get_opdef(); - --Moved most of the purity flags from uagt.h/agil.c to -agtread.h/agtdata.c, so they would be visible to agxfile.c. - --ReDirect now marked by a flip in sign instead of adding 2000; -ANYBODY has been moved to 2 from 123; and is now -represented by 1 instead of 0 (so it can be negated). - --Replace fixchar() and IBM character set translations by a look-up -table to speed up reading of descriptions. - --Tweaked room description printing so SPECIALS that send you to the same -room don't cause the room description to be printed out again. - --For Master's Edition games, now set have_meta flag based on -last_cmd rather than on the value in the DA1 file (which is always -true for ME games even if there are no metacommands). - --Made several int data type more specific and made sure they were consistent -with the corresponding save/restore/AGX file types. - --Rewrote readnum() in agtread.c - --Moved dictionary diagnostic stuff into a separate routine, which -we can call from agttest. - - -CHANGES FOR VERSION 0.4 - --Added intelligent disambiguation and ALL expansion. - --Added simple object viewers/editors to debugging system - --The parser now converts SHOOT x AT y into SHOOT y WITH x - --The parser now handles TELL TO ... correctly. - --NO_BLOCK_HOSTILE and GET_HOSTILE are now supported. - --Added SOUND ON, SOUND OFF, INSTRUCTIONS (or INS) - --Prompt is now bold as well as input text. - --Added synonyms: 'inv' as synonym for 'inventory'; 'in' and 'inside' -as synonyms for 'enter' - --Classic version 1.0 is now supported as is the version used by -Cosmoserve 97, and the 1.5 variants used by Hotel Notell and The -Multidimensional Thief. - --The status line is now updated every time the player's location changes. - --Version 1.83 now properly recognized even if there are no creatures. - --Titles in v1.83 are no longer automatically centered (to conform with -the original interpreter). - --Split metacommand.c into metacommand.c and token.c - --The contents of variables are now type-checked; fixed type output -in agtdbg.c to accomadate the new variable format. - --Interpreter now computes maximum score itself if value in .DA1 file is 0. - --Fixed timing of "Creature is getting angrier" message - --Fixed color/bold code in Linux. - --Bold/color settings are now reset to normal after each description block. - --For Master's Edition games, the 'door' virtual object is now given a lower -disambiguation priority than non-present objects. - --Instructions now pass through IBM character decoding - --Formating characters now stripped from status line. - --Code reorganizations: metacommands are now sorted by verb to speed -up processing; reorganized dict data structures to be more compact; -put in additonal error checking in check_lastcmd(); broke up -exec_token() into exec_token(), exec_cond(), and exec_action(). - --Fixed bugs: title centering detection fixed; GetNumberInput's -argument list fixed; NamePresent and ANYBODY commands have been -corrected; DescribeThing is now able to describe rooms; -SetVariableTime now normalizes its data type; PlayerHas; 1.83 verb -list was off; there was an extra "the" in the AGT info entry. - - -CHANGES FOR VERSION 0.3 - --Instructions and an information screen can be viewed. - --The title is now centered. - --Added debugging features. - --'it' refers to plural as well as singular antecedents. - --SOGGY credits are printed out - --Added IRUN support (-1 command line option) - --AGiliTy can now understand the variant 1.5 versions. - --Added LOG and REPLAY - --Changed script output to append instead of replace existing files. - --Added support for menu-driven input. - --Added global and game-specific configuration files (.CFG) - --Shrunk save files again. - --Getfile now asks before overwriting. - --Added pINS, pVOC, pOPT, pHNT - --Removed the last call to stat() from core code. - --Moved file_size() to rmem.c - --Split parser.c into parser.c and agil.c and reorganized -initialization. - --Added version and port strings - --Rewrote DA6 reading code to work with only partial buffers. - --Rewrote the type checking system to be more precise - --DEBUG_AGT_CMD is now equivelent to flag[0]. - --rmalloc, rrealloc trap errors if too large a block is requested -(determined by MAXSTRUCT). - --Rewrote color code to avoid collision of color tokens with '\t' and -remapped the 1.83 '\' bold character. - --Moved terminal tokens up to code 2000, to make it easier to add new -tokens. - --Code reorganization: moved concdup() from agtdata.c to rmem.c, making -it public; reorganized file code in agtread.c and rmem.c; removed -underline translator in tokeniser; rewrote fix_cmd; reorganized memory -allocation in agtread.c to reduce fragmentation; added 'static' to a -lot of declarations and reduced external linkage requirement to 8 -characters; rfree macro rewritten; word lists("slists") now stored -dynamically; opcode name list uses pointers instead of fixed length -arrays. - --Fixed various bugs: various problems with PUT IN; ME/1.0 pictures, -fonts,songs, and user strings ignored; cosmetic errors in -print_contents; dictionary search case senstitive; various problems -with INVISIBLE; 1.83 games crashed; ANYBODY not properly matched. - - -CHANGES FOR VERSION 0.2: - --The save file format has shrunk. - --Fixed print_title() to do IBM character translation for the title file. - --RESTORE now verifies that save files are from the correct game. - --Added support for version 1.18 games. - --Metacommand debugging information now goes throught the standard -screen output routines. - --The interpreter now loads the game faster due to file buffering and -a hash table for search_dict(). - --When program finds a lot of bad tokens it no longer floods the screen -with warning messages - --OR metacommand tokens are now handled consitently with the original -interpreters. - --Reorganized exec.c into three files: exec.c, runverb.c, and metacommand.c -and a header exec.h - --DEBUG_OUT is now defined in uagt.h. - --Completed internal support for fonts, music, and graphics. Of -course these still require a port actually capable of using of this. - --Rewrote file size functions to be more portable; eliminated NO_FILESIZE -and REPLACE_FILESIZE - --Added FAST_SETSIGN, using macros to speed this up on compatible systems. - --Got rid of HUGE #defines; any individual data structure now fits in 64k - --Changed print_obj() to not print out an object's short description if it -starts with INVISIBLE even if it contains other words. - --Changed MEM_MARGIN to 16k which should prevent the interpreter from -starting up without enough memory and then dying mid-game. - --Changed the way noun.position is handled to reduce the size of save -files. - --Cleaned up DA1 reading routines in agtread.c and aver encoding. - --'long int' and 'short int' changed to 'long' and 'short' to allow -#define int short int (for debugging purposes) - --Cleaned up BRIEF and VERBOSE messages. - --it_sdesc converted into a function - --The code for reading DA6 files should now be endian independent. - --Descriptions with '$' symbols now print correctly. - --r?alloc calls with size zero are now handled correctly and rmem_trap -is now correctly set. - --Several memory leaks have been fixed. - --Several other minor bugs have been fixed. - - -VERSION 0.1 - --First public release \ No newline at end of file diff --git a/app/src/main/jni/terps/agility/config.h b/app/src/main/jni/terps/agility/config.h deleted file mode 100644 index 84f3862..0000000 --- a/app/src/main/jni/terps/agility/config.h +++ /dev/null @@ -1,477 +0,0 @@ -/* config.h-- Configuration information for AGiliTy. */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* - This file contains most of the configuration information - including the platform-dependent #define statements - It's in three major sections: - --Platform specific defines for various platforms, each - surrounded by "#ifdef " and "#endif" - --Various defaults - --Filename extensions - - Ideally, a port to a new platform should only need to modify this - file, the makefile, os_.c, and possibly filename.c. (In - practice, you may also need to tweak the the high-level I/O code - in interface.c or the memory-allocation code in util.c. If you - find yourself needing to do more than that, get in touch with me.) */ - - - - -/* Default to PLAIN platform */ -/* At the moment, you can replace this with LINUX, HPUX, AMIGA, */ -/* MSDOS, SUN, or NEXT; some of these may require the correct os_... */ -/* file to work */ -/* (In particular, AMIGA requires David Kinder's os_amiga.c file) */ -/* The actual platform specific defines don't start until a few */ -/* lines down, past the #includes and the definition of global */ -#ifndef PLAIN -#define PLAIN -#endif - - -#if defined(__MSDOS__) || defined(_DOS) - /* These work under Borland C and Visual C++ 1.52, respectively */ -#ifndef MSDOS -#define MSDOS -#endif -#ifndef MSDOS32 -#define MSDOS16 -#endif -#endif - -/* ------------------------------------------------------------------- */ -/* PLATFORM SPECIFIC DEFINITIONS, ETC. */ -/* See agility.doc or porting.txt for more information. */ -/* Things you can currently define: */ -/* fix_ascii: 1=translate IBM character set, 0=don't */ -/* NEED_STR_CMP: define if strcasecmp() not defined on your system */ -/* NEED_STRN_CMP: define if strncasecmp() not defined on your system */ -/* HAVE_STRDUP: define if strdup() exists on your system */ -/* REPLACE_GETFILE: define if you replace the default get_user_file(). */ -/* REPLACE_MENU if you replace agt_menu(). */ -/* REPLACE_MAIN: define if you replace the default main(). */ -/* (replacements should be defined in the relevant os_.c file) */ -/* DA1,DA2,...DA6,DSS,pTTL: file name extensions for the various AGT - files */ -/* HAVE_SLEEP if your platform has the sleep() function */ -/* BUFF_SIZE is the maximum size of the buffer to use when reading - in files. Regardless, it will be made no bigger than the file - being read in and no smaller than the record size; thus setting - it to 0 will cause the smallest buffer to always be used and - setting this to 1MB will in practice always use a buffer the - sizs of the file. It defaults to 32K */ -/* CBUF_SIZE is the maximum size of the buffer used for reading in - the Master's Edition DA6 files; the size of the buffer in bytes - is twice this value (since an individual token is two bytes long). */ -/* DESCR_BUFFSIZE is the maximum size of the description text block before - the interpreter will read it from disk rather than storing it in - memory during play. At the moment this only affects AGX games; - original AGT games always use the disk. */ -/* DOHASH to use a hash table for dictionary searches; the only - reason not to have this would be memory */ -/* HASHBITS determines the size of the hash table: (2^HASHBITS)*sizeof(word); - the hash table must be at least as large as the dictionary. - In practice this means HASHBITS should be at least 12; - this is the current default. */ -/* MAXSTRUC The maximum size (in chars) which a single data structure can - be on this platform. This defaults to 1MB (i.e. no limit for - practical purposes). In practice I know of no game files that - require any structures bigger than about 30K. */ -/* LOWMEM Define this if you are low on memory. At the moment this - only saves a few K.*/ -/* PORTSTR Is the string describing this particular port. - e.g. #define PORTSTR "OrfDOS Port by R.J. Wright" */ -/* UNIX_IO if you have Unix-like low level file I/O functions. - (MS-DOS, for example, does). This speeds up the reading - of the large game data files on some platforms. If this is - defined, READFLAG, WRITEFLAG, and FILE_PERM also need to - be defined. (Giving the flags needed for opening a file for - reading or writing, and the file permissions to be given to newly - created files. */ -/* OPEN_AS_TEXT Define to cause text files to be opened as text files. */ -/* PREFIX_EXT Add filename extensions at the beginning of the name, - rather than at the end. */ -/* PATH_SEP, if defined, is a string containing all characters which - can be used to separate the path from the filename. */ -/* pathtest(s) is a macro that should check whether the given string - is an absolute path. If this is left undefined, then _all_ - paths will be treated as absolute. You don't need to define - this if you are replacing filename.c. */ -/* ------------------------------------------------------------------- */ - -/* force16 is used purely for debugging purposes, to make sure that - everything works okay even with 16-bit ints */ -/* #define force16 */ - -#define DOHASH - -/* This is intended for DJGPP */ -#ifdef MSDOS32 -#define HAVE_STRDUP -#define BUFF_SIZE (1024L*1024L) -#define INBUFF_SIZE (8*1024) /* Used by Magx */ -#define MAXSTRUC (4*1024L*1024L) /* If we're asking for over 4 MB, something - is wrong. */ -#define DESCR_BUFFSIZE (4*1025L*1024L) -#define CBUF_SIZE (20000L) -#define PORTSTR "DOS 386 Version" -#define READFLAG O_RDONLY -#define WRITEFLAG (O_WRONLY|O_CREAT|O_TRUNC) -#define FILE_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) -#include -#ifndef MSDOS -#define MSDOS -#endif -#ifdef __DJGPP__ -#define REPLACE_BNW /* Enable picture and font support */ -#endif -#endif - - - -/* This works with Borland C; I don't know about other DOS C compilers */ -#ifdef MSDOS16 -#define strcasecmp(s1,s2) stricmp(s1,s2) -#define NEED_STRN_CMP -#define BUFF_SIZE (16*1024L) -#define INBUFF_SIZE (2*1024) /* Used by Magx */ -#define CBUF_SIZE (10000L) /* DOS file routines used signed ints, and - so can only handle 32K sized blocks */ -#define MAXSTRUC (64L*1024L) /* DOS 64K Limit */ -#define PORTSTR "DOS Version" -#define READFLAG (O_RDONLY | O_BINARY) -#define WRITEFLAG (O_WRONLY | O_BINARY | O_CREAT | O_TRUNC) -#define FILE_PERM (S_IWRITE | S_IREAD) -#define REPLACE_BNW -/* #define LOWMEM*/ -#define DOSFARDATA far -#define HASHBITS 13 -#ifndef MSDOS -#define MSDOS -#endif -#endif - - -/* This is common configuration information shared by both - DOS16 and DOS32 */ -#ifdef MSDOS -#define fnamecmp strcasecmp /* Case insensitive file name comparison */ -#define fix_ascii 0 /* DON'T translate IBM character set */ -#define HAVE_SLEEP -#define FAST_FIXSIGN -#define UNIX_IO -#define PATH_SEP ":\\" -#define pathtest(s) (s[0]=='\\' || strchr(s,':')!=NULL); -#undef PLAIN -#endif - - - - -#ifdef LINUX -#define LINUX_COLOR -#define fix_ascii 1 -/* #define HAVE_TPARAM */ -#define UNIX -#define HAVE_STRDUP -#define BUFF_SIZE (1024L*1024L) -#define INBUFF_SIZE (8*1024) /* Used by Magx */ -#define MAXSTRUC (4*1024L*1024L) /* If we're asking for over 4 MB, something - is wrong. */ -#define DESCR_BUFFSIZE (4*1025L*1024L) -#define CBUF_SIZE (20000L) -/* If you're compiling for a 32-bit platform, you can uncomment the following - for a modest performance increase. */ -/* #define FAST_FIXSIGN */ -#define PORTSTR "Linux Version" -#define REPLACE_BNW -#undef PLAIN -#endif - - -/* The following configuration was contributed by Alexander Lehmann */ -/* It was originally written for 0.3, but it should work for later */ -/* versions as well. */ -#ifdef HPUX -#define HAVE_TPARAM -#define UNIX -#define HAVE_STRDUP -#define BUFF_SIZE (1024L*1024L) -#define MAXSTRUCT (1024L*1024L) -#define DESCR_BUFFSIZE (1024L*1024L) -#define CBUF_SIZE (20000L) -#define FAST_FIXSIGN -#define PORTSTR "HP-UX Version" -#undef PLAIN -#endif - - - -#ifdef SUN -#define NO_TERMCAP_H -#define UNIX -#define BUFF_SIZE (1024L*1024L) -#define MAXSTRUC (1024L*1024L) -#define DESCR_BUFFSIZE (1024L*1024L) -#define CBUF_SIZE (20000L) -#define PORTSTR "UNIX Version" -#undef PLAIN -#endif - - -/* This can presumably be tweaked to support various flavors of BSD */ -#ifdef NEXT -#define NO_TERMCAP_H -#define UNIX -#define BSD_TERM -#define BUFF_SIZE (1024L*1024L) -#define MAXSTRUC (1024L*1024L) -#define DESCR_BUFFSIZE (1024L*1024L) -#define CBUF_SIZE (20000L) -#define PORTSTR "NEXT/BSD Version" -#define _POSIX_SOURCE -#include -#include -#undef PLAIN -#endif - - -/* From David Kinder's Amiga port; you'll also need his os_amiga.c file */ -#ifdef AMIGA -#define NEED_STR_CMP -#define NEED_STRN_CMP -#undef HAVE_STRDUP -#define REPLACE_GETFILE -#define FAST_FIXSIGN -#define BUFF_SIZE (256L*1024L) -#define CBUF_SIZE (20000L) -#define UNIX_IO -#define PORTSTR "Amiga Version by David Kinder" -#define READFLAG O_RDONLY -#define WRITEFLAG (O_WRONLY|O_CREAT|O_TRUNC) -#define FILE_PERM 0 -#undef PLAIN -/* Fix for DICE compiler problem */ -#ifdef _DCC -#ifdef INT_MIN -#undef INT_MIN -#endif -#define INT_MIN -2147483647 -#endif -#endif - - - - -/* For David Kinder's Windows port; you will also need his source files */ -#ifdef _WIN32 -#define NEED_STR_CMP -#define NEED_STRN_CMP -#undef HAVE_STRDUP -#define REPLACE_GETFILE -#define FAST_FIXSIGN -#define BUFF_SIZE (256L*1024L) -#define CBUF_SIZE (20000L) -#define UNIX_IO -#define PORTSTR "Windows Version by David Kinder" -#define READFLAG O_RDONLY -#define WRITEFLAG (O_WRONLY|O_CREAT|O_TRUNC) -#define FILE_PERM 0 -#undef PLAIN -#endif - - -/* - * The Glk port is very similar to plain ASCII, to give it the best - * chance at success on multiple Glk platforms. The only basic change - * is to turn off IBM character translations; Glk works in ISO 8859 - * Latin-1, which can offer slightly closer translation of the IBM - * code page 437 characters that the simpler mappings in the core - * AGiliTy code. The os_glk.c module handles the translations. - */ -#ifdef GLK -#define NEED_STR_CMP /* Inherited from PLAIN. */ -#define NEED_STRN_CMP /* Inherited from PLAIN. */ -#define BUFF_SIZE 0 /* Inherited from PLAIN. */ -#define CBUF_SIZE (5000L) /* Inherited from PLAIN. */ -#define INBUFF_SIZE (1024) /* Inherited from PLAIN. */ -#define fix_ascii 0 /* os_glk.c does translations. */ -#define MAXSTRUC (1024L*1024L) /* 32Kb from PLAIN is too small for - several games (including Soggy). */ -#define PORTSTR "Glk version" /* Identify ourselves discreetly. */ -#define REPLACE_GETFILE /* Override get_user_file. */ -#define REPLACE_MAIN /* Override main. */ -#define fnamecmp strcasecmp /* Case insensitive filename compare. */ -#undef PLAIN -#endif - - -/* PLAIN should always come last, giving everyone else a chance - to #undef it. */ -#ifdef PLAIN /* This should work if nothing else does */ -#define NEED_STR_CMP -#define NEED_STRN_CMP -#define BUFF_SIZE 0 -#define CBUF_SIZE (5000L) -#define INBUFF_SIZE (1024) /* Used by Magx */ -#define MAXSTRUC (32L*1024L) /* IIRC, 32K is the minimum required by - the ANSI standard */ -#define PORTSTR "Pure ANSI C version" -#endif - - -/* __GNUC__ */ - - -/* ------------------------------------------------------------------- */ -/* DEFAULTS FOR "PLATFORM SPECIFIC" DEFINES */ -/* ------------------------------------------------------------------- */ - -#ifdef __POSIX__ -#ifndef UNIX -#define UNIX -#endif -#endif - -#ifdef UNIX -#define HAVE_SLEEP -#define UNIX_IO -#define READFLAG O_RDONLY -#define WRITEFLAG (O_WRONLY|O_CREAT|O_TRUNC) -#define FILE_PERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) -#define PATH_SEP "/" -#define pathtest(s) (s[0]=='/'); -#include -#endif - -#ifdef __STRICT_ANSI__ -#define NEED_STR_CMP -#define NEED_STRN_CMP -#undef HAVE_STRDUP -#endif - -#ifndef fix_ascii -#define fix_ascii 1 /* Translate IBM character set by default */ -#endif - -#ifndef BUFF_SIZE -#ifdef LOWMEM -#define BUFF_SIZE 0 /* i.e. unbuffered */ -#else -#define BUFF_SIZE (32L*1024L) /* 32K */ -#endif -#endif /* BUFF_SIZE */ - -#ifndef MAXSTRUC -#define MAXSTRUC (1024L*1024L) -#endif - -#ifndef DESCR_BUFFSIZE -#define DESCR_BUFFSIZE 0 /* Always load descriptions from disk */ -#endif - -#ifndef HASHBITS -#ifdef LOWMEM -#define HASHBITS 12 /* 4K entries */ -#else -#define HASHBITS 13 /* 8K entries in hash table */ -#endif -#endif /* HASHBITS */ - -#ifndef fnamecmp /* Used to compare filenames */ -#define fnamecmp strcmp -#endif - -#ifndef fnamencmp /* Also used to compare filenames */ -#define fnamencmp strncmp -#endif - -/* If DOSFARDATA hasn't been defined, define it as the empty string. */ -#ifndef DOSFARDATA -#define DOSFARDATA -#endif - -/* ---------------------------------------------------------------------- */ -/* FILENAME EXTENSIONS */ -/* These are the various filename extensions for the different data files.*/ -/* ---------------------------------------------------------------------- */ - -/* The following are only used by the interpreter, agtout, and agt2agx */ -#ifndef DA1 -#define DA1 ".da1" /* General info (text file) */ -#define DA2 ".da2" /* Rooms */ -#define DA3 ".da3" /* Items */ -#define DA4 ".da4" /* Creatures */ -#define DA5 ".da5" /* Commands, headers */ -#define DA6 ".da6" /* Commands, code (Master's Ed only) */ -#define DSS ".d$$" /* Description strings */ -#define pHNT ".hnt" /* Popup hint file; not used yet. */ -#define pOPT ".opt" /* Interface specification file */ -#endif - -/* The following are only used by the Magx compiler */ -#ifndef pAGT -#define pAGT ".agt" -#define pDAT ".dat" -#define pMSG ".msg" -#define pCMD ".cmd" -#define pSTD ".std" -#define AGTpSTD "agt.std" /* Default error message file */ -#endif - -/* The following are used by both the interpreter and the compiler */ -#ifndef pAGX -#define pAGX ".agx" /* Extension for new Adventure Game eXecutable format */ -#define pTTL ".ttl" /* Title file */ -#define pINS ".ins" /* Instruction file */ -#define pVOC ".voc" /* Menu vocabulary file */ -#define pCFG ".cfg" /* Game configuration file */ -#define pEXT "." /* Separator between extension and base of filename */ -#endif - - -#ifndef pSAV -#define pSAV ".sav" /* Extension for save files */ -#endif - -#ifndef pSCR -#define pSCR ".scr" /* Script file */ -#endif - -#ifndef pLOG -#define pLOG ".log" /* LOG/REPLAY file */ -#endif - - - - - -/* Finally, two potentially platform dependent type defintions, - for binary and text files respectively. Don't change these - unless you are also changing filename.c */ - -typedef FILE* genfile; -typedef char* file_id_type; /* i.e. the filename */ - -#define NO_FILE_ID NULL -#define BAD_TEXTFILE NULL -#define BAD_BINFILE NULL - -#define textgetc(f) fgetc(f) -#define textungetc(f,c) ungetc(c,f) -#define textgets(f,s,n) fgets(s,n,f) -#define texteof(f) feof(f) -#define textputs(f,s) fputs(s,f) - - -#if 0 -int textgetc(genfile f); -void textungetc(genfile f, char c); -int texteof(genfile f); -void textgets(genfile f, char *buff, long leng); -void textputs(genfile f, const char *s); -#endif - diff --git a/app/src/main/jni/terps/agility/debugcmd.c b/app/src/main/jni/terps/agility/debugcmd.c deleted file mode 100644 index da9a783..0000000 --- a/app/src/main/jni/terps/agility/debugcmd.c +++ /dev/null @@ -1,725 +0,0 @@ -/* debugcmd.c-- Built in debugging commands */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy, the (Mostly) Universal */ -/* AGT Interpreter */ - -#include -#include "agility.h" -#include "interp.h" -#include "exec.h" - -static void d_moveobj(int obj,int dest) -/* 1=the player, -1=unknown: ask */ -{ - if (obj==-1) { - writestr("Which object? "); - obj=read_number(); - if (obj!=1 && !tnoun(obj) && !tcreat(obj)) { - writeln("Invalid object"); - return; - } - } - if (dest==-1) { - writestr("To where? "); - dest=read_number(); - if (dest!=1 && dest!=0 && !tnoun(dest) && !tcreat(dest) && !troom(dest)) { - writeln("Invalid object"); - return; - } - } - if (obj!=1) - it_move(obj,dest); - else { - if (!troom(dest)) { - writeln("Player can only be moved to a room"); - return; - } - goto_room(dest-first_room); - } -} - - -static int print_objid(int obj) -{ - char buff[10]; - char *s; - int n; - - sprintf(buff,"%4d: ",obj); - writestr(buff); - s=objname(obj); - for(n=0;s[n]!=0;n++) - if (s[n]<=8 || (uchar)s[n]==0xFF) s[n]=' '; /* Strip out format codes */ - writestr(s); - n=strlen(s); - rfree(s); - return n; -} - - -static void d_listroom(void) -{ - int i; - - writeln(" ROOM"); - writeln(" ------"); - writeln(""); - for(i=0;i<=maxroom-first_room;i++) { - print_objid(i+first_room); - writeln(""); - } -} - - - -#define SEPLENG 27 /* Width between beginning of object column and - location column */ - - -static void d_listnoun(void) -{ - int i; - int len; - - writestr(" NOUN ");padout(SEPLENG-6);writeln(" LOCATION "); - writestr(" ------");padout(SEPLENG-6);writeln(" ----------"); - writeln(""); - len=SEPLENG-print_objid(1); - padout(len); - writestr("["); - print_objid(loc); - writeln("]"); - - nounloop(i) { - len=print_objid(i+first_noun); - len=SEPLENG-len; - if (len>0) padout(len); - writestr("["); - print_objid(noun[i].location); - writeln("]"); - } -} - -static void d_listcreat(void) -{ - int i; - int len; - - writestr(" CREATURE ");padout(SEPLENG-11);writeln(" LOCATION "); - writestr(" ----------");padout(SEPLENG-11);writeln(" ----------"); - writeln(""); - - creatloop(i) { - len=print_objid(i+first_creat); - len=SEPLENG-len; - if (len>0) padout(len); - writestr(" ["); - print_objid(creature[i].location); - writeln("]"); - } -} - - -static void writetbl(const char *s,int width) -/* This writes out s and then prints out any additional spaces needed - to make the output string *width* wide. */ -{ - writestr(s); - width=width-strlen(s); - if (width>0) padout(width); -} - - -static void var_edit(int vtype) -/* vtype=0 for variable, 1 for counter, 2 for flag */ -{ - long n; - int i; - int imax; - char sbuff[30]; - - switch (vtype) - { - case 0: imax=VAR_NUM;break; - case 1: imax=CNT_NUM;break; - case 2: imax=FLAG_NUM;break; - default: writeln("INTERNAL ERROR: Invalid vtype."); - return; - } - - for(;;) { - agt_clrscr(); - writeln(""); - switch (vtype) { - case 0:writeln("Variables");break; - case 1:writeln("Counters (-1 means the counter is off)");break; - case 2:writeln("Flags ( f=false [OFF] and t=true [ON] )");break; - } - writeln(""); - for(i=0;i<=imax;i++) { - switch (vtype) { - case 0:sprintf(sbuff,"[Var%3d]=%4ld",i,(long)agt_var[i]);break; - case 1:sprintf(sbuff,"[Cnt%3d]=%4ld",i,(long)agt_counter[i]);break; - case 2:sprintf(sbuff,"%3d%c",i,flag[i]?'t':'f');break; - } - writetbl(sbuff,(vtype==2)? 5 : 20); - } - writeln("");writeln(""); - for(;;) { - switch (vtype) { - case 0:writestr("Variable to change");break; - case 1:writestr("Counter to change");break; - case 2:writestr("Flag to toggle");break; - } - writestr(" (-1 to quit): "); - i=read_number(); - if (i<0) return; - if (i<=imax) { - if (vtype!=2) { - if (vtype==0) - sprintf(sbuff,"[Var%d]=%ld",i,(long)agt_var[i]); - else sprintf(sbuff,"[Cnt%d]=%ld (-1 means it's off)", - i,(long)agt_counter[i]); - writestr(sbuff); - writestr("; new value = "); - n=read_number(); - if (vtype==0) - agt_var[i]=n; - else - if (n<-1 || n>(((long)1)<<15)-1 ) - writeln("Invalid value for a counter."); - else agt_counter[i]=n; - } else flag[i]=!flag[i]; - break; - } else - writeln("Invalid index."); - } - } -} - -/* Routines to edit user strings */ -static void edit_str(void) -{ - int i,j; - char buff[10]; - char *tmpstr; - - if (MAX_USTR==0 || userstr==NULL) { - writeln("This game doesn't contain any user strings"); - return; - } - for(;;) { - agt_clrscr(); - writeln("User Definable Strings"); - writeln(""); - for(i=0;i0 && i<=MAX_USTR) { - writeln("Enter new string:"); - tmpstr=agt_readline(3); - j=strlen(tmpstr)-1; - if (j>0 && tmpstr[j]=='\n') tmpstr[j]=0; - strncpy(userstr[i-1],tmpstr,80); - } else writeln("Invalid string number"); - } -} - -static uchar attrcol; /* Determines which column the attribute is put in */ -static uchar attrwidth; /* Number of attribute columns */ - -static void next_col(void) -{ - if (++attrcol==attrwidth) { - writeln(""); - attrcol=0; - } - else - padout(10); -} - -static void writeattr(char *attrname,rbool attrval) -{ - writestr(attrname); - padout(15-strlen(attrname)); - if (attrval) writestr("yes"); else writestr("no "); - next_col(); -} - -static void writegender(char *gendername, uchar genderval) -{ - writestr(gendername); - padout(15-strlen(gendername)-3); - switch(genderval) - { - case 2: writestr("Male ");break; - case 1: writestr("Female");break; - case 0: writestr("Thing");break; - } - next_col(); -} - -static void writeprop(char *propname,int obj) -{ - writestr(propname); - writestr(" ["); - print_objid(obj); - writeln("]"); -} - -static int writedir(int index,int dir,int obj) -{ - char sbuff[40]; - - sprintf(sbuff,"%2d.%-2s %d",index,exitname[dir],obj); - writestr(sbuff); - return strlen(sbuff); -} - -void writenum(char *propname,int n) -{ - char sbuff[20]; - - writestr(propname); - sprintf(sbuff,"%4d",n); - writeln(sbuff); -} - -static void writeflags(char *flagname, int32 flags) -{ - int i; - char sbuff[5]; - - writestr(flagname); - for(i=0;i<32;i++) { - if (flags & 1) { - sprintf(sbuff,"%2d ",i); - writestr(sbuff); - } else - writestr(" "); - flags>>=1; - if (i%12==11) { - writeln(""); - padout(strlen(flagname)); - } - } - writeln(""); -} - - -static void readflags(int32 *flags) -{ - long n; - - writestr("Room flag to toggle (0-31)? "); - n=read_number(); - if (n<=31 && n>=0) - *flags^=( ((long)1) << n ); -} - -static long readval(const char *prompt,int type) -{ - long val; - - for(;;) { - writestr(prompt); - writestr(" "); - val=read_number(); - if (argvalid(type,val)) return val; - writeln("Invalid value."); - } -} - - -static uchar readgender(void) -{ - char c; - - writestr("Gender (M/F/N): "); - for(;;) { - c=tolower(agt_getchar()); - switch(c) - { - case 'm': return 2; - case 'w': - case 'f': return 1; - case 'n': - case 't': return 0; - default: ;/* Do nothing */ - } - } -} - - -static void edit_objattr(int obj) -{ - int i,k, kprop, n; - long v; - - for(;;) { - k=1; - agt_clrscr(); - print_objid(obj); - writeln(""); - if (oflag_cnt>0) { - writeln("ObjFlags:"); - for(i=0;i0) { - writeln("ObjProps:"); - for(i=0;i=k) continue; - k=0; - if (n=10 && n<22) { /* Direction */ - room[i].path[n-10]=readval(exitname[n-10],AGT_NUM); - } - else writeln("Invalid field"); - } - } -} - - -#define tog(x) {x=!x;break;} - -static void noun_edit(int i) -{ - int n; - - for(;;) { - agt_clrscr(); - /* writeln("");*/ - writestr("NOUN "); - print_objid(i+first_noun); - /* writeln("");*/ - /* writeln("");*/ - writeprop(" Location=",noun[i].location); - writeln(""); - attrcol=0;attrwidth=3; - writeattr(" 1.*Pushable:",noun[i].pushable); - writeattr(" 8.*Lockable:",noun[i].lockable); - writeattr("15.*Drinkable:",noun[i].drinkable); - writeattr(" 2.*Pullable:",noun[i].pullable); - writeattr(" 9.*Light:",noun[i].light); - writeattr("16.*Poisonous:",noun[i].poisonous); - writeattr(" 3.*Turnable:",noun[i].turnable); - writeattr("10.*Plural:",noun[i].plural); - writeattr("17. Open:",noun[i].open); - writeattr(" 4.*Playable:",noun[i].playable); - writeattr("11. Movable:",noun[i].movable); - writeattr("18. Locked:",noun[i].locked); - writeattr(" 5.*Readable:",noun[i].readable); - writeattr("12.*Shootable:",noun[i].shootable); - writeattr("19.*Win Game:",noun[i].win); - writeattr(" 6.*Wearable:",noun[i].wearable); - writeattr("13. On:",noun[i].on); - writeattr("20.*Global:",noun[i].isglobal); - writeattr(" 7.*Closable:",noun[i].closable); - writeattr("14.*Edible:",noun[i].edible); - writeattr("21.*Proper:",noun[i].proper); - - writeln(""); - writenum("22. Shots =",noun[i].num_shots); - writenum("23. Points =",noun[i].points); - writenum("24. Weight =",noun[i].weight); - writenum("25. Size =",noun[i].size); - writeprop("26.*Key =",noun[i].key); - writeprop("27. Class =",noun[i].oclass); - writenum("28. Flag =",noun[i].flagnum); - writeln(""); - /* writeln(""); */ - writeln("29. Object properties and attributes."); - writeln(""); - writeln("(Fields marked with an * are not saved or restored.)"); - writestr("Field to change (0 to exit)? "); - n=read_number(); - if (n==0) return; - switch (n) - { - case 1:tog(noun[i].pushable); /* tog() macro includes break */ - case 2:tog(noun[i].pullable); - case 3:tog(noun[i].turnable); - case 4:tog(noun[i].playable); - case 5:tog(noun[i].readable); - case 6:tog(noun[i].wearable); - case 7:tog(noun[i].closable); - case 8:tog(noun[i].lockable); - case 9:tog(noun[i].light); - case 10:tog(noun[i].plural); - case 11:tog(noun[i].movable); - case 12:tog(noun[i].shootable); - case 13:tog(noun[i].on); - case 14:tog(noun[i].edible); - case 15:tog(noun[i].drinkable); - case 16:tog(noun[i].poisonous); - case 17:tog(noun[i].open); - case 18:tog(noun[i].locked); - case 19:tog(noun[i].win); - case 20:tog(noun[i].isglobal); - case 21:tog(noun[i].proper); - - case 22:noun[i].num_shots=readval("Shots =",AGT_NUM);break; - case 23:noun[i].points=readval("Points =",AGT_NUM);break; - case 24:noun[i].weight=readval("Weight =",AGT_NUM);break; - case 25:noun[i].size=readval("Size =",AGT_NUM);break; - case 26:noun[i].key=readval("Key =",AGT_ITEM|AGT_NONE);break; - case 27:noun[i].oclass=readval("Class =",AGT_ITEM|AGT_NONE);break; - case 28:noun[i].flagnum=readval("Flag Number=",AGT_ROOMFLAG);break; - case 29:edit_objattr(i+first_noun);break; - default:writeln("Invalid field"); - } - } -} - - -static void creat_edit(int i) -{ - int n; - - for(;;) { - agt_clrscr(); - writestr("CREATURE "); - print_objid(i+first_creat); - writeln(""); - writeln(""); - writeprop("Location =",creature[i].location); - writeln(""); - attrcol=0;attrwidth=2; - writeattr(" 1. Hostile:",creature[i].hostile); - writeattr(" 4. Global:",creature[i].isglobal); - writeattr(" 2. Grp member:",creature[i].groupmemb); - writeattr(" 5.*Proper:",creature[i].proper); - writegender(" 3.*Gender:",creature[i].gender); - writeln("");writeln(""); - writeprop(" 6.*Weapon = ",creature[i].weapon); - writenum(" 7. Points = ",creature[i].points); - writenum(" 8.*Attack Threshold = ",creature[i].threshold); - writenum(" 9. Attack counter = ",creature[i].counter); - writenum("10.*Attack Time Limit = ",creature[i].timethresh); - writenum("11. Attack timer = ",creature[i].timecounter); - writeprop("12. Class = ",creature[i].oclass); - writenum("13. Flag = ",creature[i].flagnum); - writeln(""); - writeln("14. Object properties and attributes."); - writeln(""); - writeln("(Fields marked with an * are not saved or restored.)"); - writeln(""); - writestr("Field to change (0 to exit)? "); - n=read_number(); - if (n==0) return; - switch (n) - { - case 1:tog(creature[i].hostile); - case 2:tog(creature[i].groupmemb); - case 3:tog(creature[i].isglobal); - case 4:tog(creature[i].proper); - - case 5:creature[i].gender=readgender();break; - case 6:creature[i].weapon=readval("Weapon =",AGT_ITEM|AGT_NONE);break; - case 7:creature[i].points=readval("Points =",AGT_NUM);break; - case 8:creature[i].threshold=readval("Threshold =",AGT_NUM);break; - case 9:creature[i].counter=readval("Attack counter =",AGT_NUM);break; - case 10:creature[i].timethresh=readval("Time limit =",AGT_NUM);break; - case 11:creature[i].timecounter=readval("Timer =",AGT_NUM);break; - case 12:creature[i].oclass=readval("Class =",AGT_ITEM|AGT_NONE);break; - case 13:noun[i].flagnum=readval("Flag Number=",AGT_ROOMFLAG);break; - case 14:edit_objattr(i+first_creat);break; - default:writeln("Invalid field"); - } - } -} - -#undef tog - - - - - -static void obj_edit(void) -{ - int n; - - for(;;) { - writeln(""); - do { - writestr("Enter object number (0 to exit)? "); - n=read_number(); - if (n<=0) return; - } while (!troom(n) && !tnoun(n) && !tcreat(n)); - - if (troom(n)) room_edit(n-first_room); - else if (tnoun(n)) noun_edit(n-first_noun); - else if (tcreat(n)) creat_edit(n-first_creat); - else writeln("[Not yet implemented]"); - - } -} - -static char *yesnostr[]={"No","Yes"}; - -static void set_debug_options(void) -{ - char buff[80]; - int n; - - for(;;) { - agt_clrscr(); - writeln("DEBUGGING OPTIONS:"); - writeln(""); - sprintf(buff," 1. Trace metacommands: %s",yesnostr[DEBUG_AGT_CMD]); - writeln(buff); - sprintf(buff," 2. Trace ANY metacommands: %s",yesnostr[debug_any]); - writeln(buff); - sprintf(buff," 3. Trace during disambiguation: %s", - yesnostr[debug_disambig]); - writeln(buff); - writeln(""); - writeln("(<2> and <3> are ignored if <1> is not set; option <1> can" - " also be changed from the main debugging menu)"); - writeln(""); - writestr("Option to toggle (0 to exit): "); - n=read_number(); - switch(n) - { - case 0:return; - case 1:DEBUG_AGT_CMD=!DEBUG_AGT_CMD;break; - case 2:debug_any=!debug_any;break; - case 3:debug_disambig=!debug_disambig;break; - default:writeln("Not a valid option"); - } - } -} - - -void get_debugcmd(void) -{ - int n; - - for(;;) { - writeln("DEBUGGING COMMANDS"); - writeln(""); - writeln("1. Move player 8. List Rooms"); - writeln("2. Get Noun 9. List Nouns"); - writeln("3. Move object 10. List Creatures"); - writeln("4. View/Edit object 11. List/Set Flags"); - writeln("5. Toggle Trace 12. List/Set Variables"); - writeln("6. Set Debug Options 13. List/Set Counters"); - writeln("7. Edit User Strings"); - writeln(""); - writestr("Enter choice (0 to exit): "); - n=read_number(); - switch(n) - { - case -1: - case 0:return; - case 1:d_moveobj(1,-1);break; - case 2:d_moveobj(-1,1);break; - case 3:d_moveobj(-1,-1);break; - case 4:obj_edit();break; - case 5:DEBUG_AGT_CMD=!DEBUG_AGT_CMD;break; - case 6:set_debug_options();break; - case 7:edit_str();break; - case 8:d_listroom();break; - case 9:d_listnoun();break; - case 10:d_listcreat();break; - case 11:var_edit(2);break; - case 12:var_edit(0);break; - case 13:var_edit(1);break; - default:writeln("Not a valid option"); - } - writeln(""); - }; -} diff --git a/app/src/main/jni/terps/agility/disassemble.c b/app/src/main/jni/terps/agility/disassemble.c deleted file mode 100644 index c79a800..0000000 --- a/app/src/main/jni/terps/agility/disassemble.c +++ /dev/null @@ -1,294 +0,0 @@ -/* disassemble.c-- Metacommand debugging output */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy: the (Mostly) Universal */ -/* AGT Interpreter */ - -/* This contains the disassembler used by AGiliTY and AGTOut. */ - -#include -#include -#include "agility.h" - - -void dbgprintf(const char *fmt,...) -{ - va_list vp; - char buff[300]; - - va_start(vp,fmt); - vsprintf(buff,fmt,vp); - va_end(vp); - - debugout(buff); -} - - -static void print_msg(descr_ptr dp) -{ - int j; - descr_line *txt; - - txt=read_descr(dp.start,dp.size); - if (txt!=NULL) { - for(j=0;txt[j]!=NULL;j++) - { - dbgprintf("\n"); - debugout(txt[j]); - } - } - free_descr(txt); -} - - -static char *getname(int inum) -/* Name should be 20 chars or less */ -{ - if (inum==0) return rstrdup("* 0 *"); - return objname(inum); -} - - -extern integer dobj, iobj, actor; - -void print_special_obj(int i) - /* This is called by the disassembler in agtdbg.c */ - /* i=0 NOUN, 1 OBJECT, 2 NAME */ -{ - int dval; - char *s; - switch(i) - { - case 0: dval=dobj; dbgprintf("NOUN"); break; - case 1: dval=iobj; dbgprintf("OBJECT"); break; - case 2: dval=actor; dbgprintf("NAME"); break; - default: - dval=0; /* Silence compiler warnings. */ - fatal("INTERNAL ERROR: Invalid *dval* in print_special_obj."); - } - if (dbgflagptr==NULL) - /* This determines whether we are linked with agtout or agil */ - return; - s=getname(dval); - dbgprintf("(%d:%s)",dval,s); - rfree(s); -} - -#define printval(str,index,ptr) {dbgprintf("[%s%d",str,index);\ - if (ptr==NULL) dbgprintf("]");\ - else dbgprintf("=%ld]",(long)ptr[index]);} - -int argout(int dtype, int dval, int optype) -{ - char *s; - - if (dtype&AGT_VAR) dtype=AGT_VAR; - - if ((optype&3)==1) /* variable */ - dtype=AGT_VAR; - if (optype&2) {/* NOUN or OBJECT */ - if (dtype>=64 && dtype!=AGT_NUM) - dbgprintf("ILL:"); - if (optype==2) - print_special_obj(0); /* NOUN */ - else - print_special_obj(1); /* OBJECT */ - return 0; - } - - if (!interp_arg) - dbgprintf("%d",dval); - else { - if (dtype<64) { - if (dval==-1) - print_special_obj(2); /* NAME */ - else { - s=getname(dval); - if (dtype&(AGT_ITEM|AGT_CREAT|AGT_SELF|AGT_WORN)) - dbgprintf("<%d:%s>",dval,s); - else - dbgprintf("{%d:%s}",dval,s); - rfree(s); - } - } else if ( (dtype&AGT_VAR)!=0) { - if (dval==-1) - print_tos(); - else - printval("Var",dval,dbgvarptr); - } else switch(dtype) - { - case AGT_TIME: - dbgprintf("%2d:%2d",dval/100,dval%100);break; - case AGT_NUM: /* Numeric */ - dbgprintf("%d",dval);break; - case AGT_FLAG: /* Flag */ - printval("Flg",dval,dbgflagptr);break; - case AGT_ROOMFLAG: /* Roomflag */ - dbgprintf("RoomFlag%d",dval);break; - case AGT_QUEST: /* Question */ - if (dval<=MaxQuestion && dval>=1 && question!=NULL) { - dbgprintf("\nQ%d:%s\n",dval,question[dval-1]); - dbgprintf("[A:%s]",answer[dval-1]); - } else if (quest_ptr!=NULL) { - dbgprintf("\nQ%d: ",dval); - print_msg(quest_ptr[dval-1]); - dbgprintf("[A:"); - print_msg(ans_ptr[dval-1]); - } - break; - case AGT_MSG: /* Message */ - if (dval>last_message || dval<1 || msg_ptr==NULL) - dbgprintf("ILLEGAL MESSAGE"); - else { - dbgprintf("(Msg%d)",dval); - if (!dbg_nomsg) - print_msg(msg_ptr[dval-1]); - } - break; - case AGT_ERR: /* Message */ - if (dval>NUM_ERR || dval<1 || err_ptr==NULL) - dbgprintf("ILLEGAL MESSAGE"); - else { - dbgprintf("(Std%d)",dval); - if (!dbg_nomsg) - print_msg(err_ptr[dval-1]); - } - break; - case AGT_STR: /* String */ - if (dval-1>=MAX_USTR || userstr==NULL) - dbgprintf("ILLEGAL STRING"); - else - dbgprintf("\nStr%d:%s",dval,userstr[dval]); - break; - case AGT_CNT: /* Counter */ - printval("Cnt",dval,dbgcntptr);break; - case AGT_DIR: /* Direction */ - if (dval>=1 && dval<=13) - dbgprintf("%s",exitname[dval-1]); - else dbgprintf("ILL_DIR(%d)",dval); - break; - case AGT_SUB: /* Subroutine */ - dbgprintf("Subroutine %d",dval);break; - case AGT_PIC: /* Picture */ - case AGT_PIX: - dbgprintf("Picture #%d",dval);break; - case AGT_FONT: /* Font */ - dbgprintf("Font #%d",dval);break; - case AGT_SONG: /* Song */ - dbgprintf("Song #%d",dval);break; - case AGT_OBJFLAG: - dbgprintf("ObjFlag%d",dval);break; - case AGT_OBJPROP: - dbgprintf("ObjProp%d",dval);break; - case AGT_ATTR: - if (dval<0 || dval>=NUM_ATTR) - dbgprintf("UnkownAttr%d",dval); - else - dbgprintf("%s",attrlist[dval].name); - break; - case AGT_PROP: - if (dval<0 || dval>=NUM_PROP) - dbgprintf("UnknownProp%d",dval); - else - dbgprintf("%s",proplist[dval].name); - break; - case AGT_EXIT: - if (dval>=exitmsg_base) - argout(AGT_MSG,dval-exitmsg_base,0); - else - argout(AGT_ROOM,dval,0); - break; - default: - dbgprintf("?+%d",dval); - } - } - return 1; -} - - -void debug_newline(integer op, rbool first_nl) -{ - rbool early_nl; - - if (!dbg_nomsg) return; - early_nl=(op==1008||op==1027||op==1083||op==1105 - ||(op>=1126&&op<=1131)); - if (early_nl==first_nl) - debugout("\n"); -} - - -void debug_cmd_out(int ip,integer op,int arg1,int arg2, int optype) -{ - int j; - const opdef *opdata; - rbool save_dbg_nomsg; - - dbgprintf(" %2d:",ip); - save_dbg_nomsg=0; /* Just to silence compiler warnings. */ - - opdata=get_opdef(op); - if (opdata==&illegal_def) - dbgprintf("ILLEGAL %d\n",op); - else { - if (op>=END_ACT) dbgprintf("!"); /* "Terminal" Actions */ - else if (op<=MAX_COND) dbgprintf("?"); /* Condition */ - if (op==1063) { /* RandomMessage needs special handling */ - save_dbg_nomsg=dbg_nomsg; - dbg_nomsg=1; - } - dbgprintf("%s",opdata->opcode); - for(j=0;jargnum;j++) { - dbgprintf("\t"); - argout(j==0 ? opdata->arg1 : opdata->arg2 , j==0 ? arg1 : arg2, - optype>>2); - optype<<=2; - } - if (op==1063) - dbg_nomsg=save_dbg_nomsg; - } - debug_newline(op,1); -} - - -void debug_head(int i) -{ - int v, w, a; - - v=verb_code(command[i].verbcmd); - if (v>=BASE_VERB && v0) { - dbgprintf("CMD %d: ",i); - a=command[i].actor; - } else { - dbgprintf("REDIR: "); - a=-command[i].actor; - } - - if (a==2) - dbgprintf("anybody, "); - else if (a>2) { - char *name; - name=objname(a); - name[0]=toupper(name[0]); - dbgprintf("%s, ",name); - rfree(name); - } - - dbgprintf("%s ", w==0 ? "any" : dict[w]); - if (command[i].noun_adj!=0) - dbgprintf("%s ",gdict(command[i].noun_adj) ); - dbgprintf("%s %s ",gdict(command[i].nouncmd), - (ver==3)? gdict(command[i].prep) : "->"); - if (command[i].obj_adj!=0) - dbgprintf("%s ",gdict(command[i].obj_adj) ); - dbgprintf("%s\n",gdict(command[i].objcmd) ); - -} - - - diff --git a/app/src/main/jni/terps/agility/exec.c b/app/src/main/jni/terps/agility/exec.c deleted file mode 100644 index af96f0c..0000000 --- a/app/src/main/jni/terps/agility/exec.c +++ /dev/null @@ -1,1333 +0,0 @@ -/* exec.c-- player command execution utilities */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy */ - -/* This file contains the wrapper for running player commands, - routines run at the end of the turn, and various other functions - needed by runverb.c and token.c. */ - -#define global - -#include -#include -#include -#include - -#include "agility.h" -#include "interp.h" -#include "exec.h" - -static rbool pronoun_mode; - -word realverb=0; /* Name of current verb. (normally ~= input[vp])*/ - - -/* ------------------------------------------------------------------- */ -/* High level output functions, used for printing messages, error */ -/* messages, and everything else. They call the direct output functions */ -/* in interface.c The reason they're in runverb.c is that they need to */ -/* access item info in order to fill in the blanks */ - - -/* This updates the contents of compass_rose, which can be used by the - OS layer to print out some sort of representation of which way the - player can go. */ - -static void set_compass_rose(void) -{ - int i, bit; - - compass_rose=0; - if (!islit()) return; /* No compass in darkness */ - for(i=0,bit=1;i<12;i++,bit<<=1) - if (troom(room[loc].path[i])) compass_rose|=bit; -} - -static void time_out(char *s) -{ - int hr,min; - - hr=curr_time/100; - min=curr_time%100; - - if (milltime_mode) - sprintf(s,"%02d:%02d",hr,min); - else { - if (hr>12) hr=hr-12; - if (hr==0) hr=12; - sprintf(s,"%2d:%02d %s",hr,min,(curr_time>=1200)?"pm":"am"); - } -} - - - - - -void set_statline() -{ - char timestr[20]; - - recompute_score(); - set_compass_rose(); - - rstrncpy(l_stat,room[loc].name,81); - - time_out(timestr); - - switch(statusmode) { - case 0:sprintf(r_stat,"Score: %ld Moves: %d",tscore,turncnt);break; - case 1:sprintf(r_stat,"Score: %ld %s",tscore,timestr);break; - case 2:sprintf(r_stat,"Moves: %d",turncnt);break; - case 3:sprintf(r_stat,"%s",timestr);break; - case 4:r_stat[0]='\0';break; /* 'Trinity style' status line */ - case 5:sprintf(r_stat,"Score: %ld",tscore);break; - } -} - - -/* -------------------------------------------------------------------- */ -/* Message printing / $ substitution Routines */ -/* -------------------------------------------------------------------- */ - -#define FILL_SIZE 100 - - -/* Tries to convert *pstr to a number, which it returns. - If it fails, or if the number is not in the range 0..maxval, - it returns -1. - It advances *pstr to point after the number and after the - terminating character, if relevant. - is the terminating character; if this is 0, then - the calling routine will worry about the terminating character. - of 0 indicates no upper bound -*/ - -static int extract_number(const char **pstr, int maxval, - char term_char) -{ - const char *s; - long n; /* n holds the value to be returned; i holds - the number of characters parsed. */ - n=0; - s=*pstr; - while(*s==' '||*s=='\t') s++; - for(;*s!=0;s++) { - if (*s<'0' || *s>'9') break; - n=10*n + (*s-'0'); - if (maxval && n>maxval) return -1; - } - if (term_char) { - if (*s==term_char) s++; - else return -1; - } - *pstr=s; - return n; -} - -#define BAD_PROP (-1000) - -/* This is used by #PROP[obj].[prop]# and $ATTR[obj].[attr]$, etc. */ -/* isprop: Are we looking for a property (as opposed to an attribute)? */ -static void extract_prop_val(const char **pstr, - int *id, int *val, - rbool isprop, const char term_char) -{ - const char *s; - int v; /* object number / final value */ - int i; /* Attribute id */ - rbool builtin; /* Expect builtin property or attribute? */ - - *id=i=BAD_PROP; *val=0; /* Failure case by default */ - builtin=0; - s=*pstr; - if (match_str(&s,"NOUN")) v=dobj; - else if (match_str(&s,"OBJECT")) v=iobj; - else v=extract_number(&s,maxcreat,0); /* Must be object number */ - while(*s=='.') { - s++; - if (*s=='-') { - builtin=1; s++; - } else - builtin=0; - i=extract_number(&s,0,0); - if (!troom(v) && !tnoun(v) && !tcreat(v)) {i=-1;continue;} - if (isprop || *s=='.') /* Treat as property */ - v=builtin ? getprop(v,i) : op_objprop(2,v,i,0); - else /* Treat as attribute */ - v=builtin ? getattr(v,i) : op_objflag(2,v,i); - } - if ( *s!=term_char) return; - *pstr=s+1; - if (i<0) return; - *id=builtin ? -1 : i; - *val=v; -} - - - - -static word it_pronoun(int item, rbool ind_form) -/* Return the correct pronoun to go with item; - ind_form is 1 if we want the object form, 0 if we want the - subject form */ -{ - if (it_plur(item)) - return (ind_form ? ext_code[wthem] : ext_code[wthey]); - if (tcreat(item)) - switch (creature[item-first_creat].gender) { - case 0:return ext_code[wit]; - case 1:return (ind_form ? ext_code[wher] : ext_code[wshe]); - case 2:return (ind_form ? ext_code[whim] : ext_code[whe]); - } - return ext_code[wit]; -} - -/* This sets the value of "The" for the given noun. */ -/* (In particular, proper nouns shouldn't have a "the") */ -static void theset(char *buff, int item) -{ - if (it_proper(item)) - strcpy(buff,""); - else - strcpy(buff,"the "); -} - - -static void num_name_func(parse_rec *obj_rec,char *fill_buff, word prev_adj) -/* This is a subroutine to wordcode_match. */ -/* It gives either a noun name or a number, depending. */ -/* prev_adj is a word if this was preceded by its associated $adjective$; - the goal is to avoid having $adjective$ $noun$ expand to (e.g.) - 'silver silver' when the player types in "get silver" to pick up - a magic charm with synonym 'silver'. */ -{ - word w; - - if (obj_rec==NULL) { - strcpy(fill_buff,""); - return; - } - - w=0; - if (obj_rec->noun!=0) w=obj_rec->noun; - if ( (w==0 || w==prev_adj) && obj_rec->obj!=0) - w=it_name(obj_rec->obj); - - if (w==0) { - if (obj_rec->info==D_NUM) sprintf(fill_buff,"%ld",(long)obj_rec->num); - else strcpy(fill_buff,""); -#if 0 - strcpy(fill_buff,"that"); /* We can try and hope */ -#endif - return; - } - - if (w==prev_adj) /* ... and prev_adj!=0 but we don't need to explicity - test that since w!=0 */ - fill_buff[0]=0; /* i.e. an empty string */ - else { - rstrncpy(fill_buff,dict[w],FILL_SIZE); - if (it_proper(obj_rec->obj)) fill_buff[0]=toupper(fill_buff[0]); - } -} - -static word get_adj( parse_rec *obj_rec, char *buff) -{ - word w; - - if (obj_rec->adj!=0) w=obj_rec->adj; - else w=it_adj(obj_rec->obj); - - if (w==0) strcpy(buff,""); - else { - rstrncpy(buff,dict[w],FILL_SIZE); - if (it_proper(obj_rec->obj)) buff[0]=toupper(buff[0]); - } - - return w; -} - - - -#define d2buff(i) {rstrncpy(fill_buff,dict[i],FILL_SIZE);return 1;} -#define num_name(obj_rec,jsa) {num_name_func(obj_rec,fill_buff,jsa);return 1;} -/* jsa= Just seen adj */ -#define youme(mestr,youstr) {strcpy(fill_buff,irun_mode?mestr:youstr);\ - return 1;} - -word just_seen_adj; /* This determines if we just saw $adjective$; if so, - this is set to it, otherwise it is zero. See - num_name_func above. */ - -static int wordcode_match(const char **pvarname,char *fill_buff, - int context,const char *pword) -/* Check <*p*pvarname> for a match; put subs text in fill_buf - indicates who called us; this determines - what substitutions are valid. See interp.h for possible - values. Move *p*pvarname after whatever is matched. - contains the parse word when context is MSG_PARSE. */ -/* $ forms: - $verb$, $noun$, $adjective$, $prep$, $object$, $name$, - $n_pro$, $o_pro$, $n_indir$, $o_indir$, - $name_pro$, $name_indir$ - $n_is$, $o_is$, $name_is$ - $c_name$ - $n_was$, $o_was$, $name_was$ - $the_n$, $the_o$, $the_name$ - */ -/* Also $STRn$, $FLAGn$, $ONn$, $OPENn$, $LOCKEDn$ */ -/* Support for FLAG, ON, OPEN, and LOCKED added by Mitch Mlinar */ -/* Return 0 if no match, 1 if there is */ -{ - int hold_val, hold_id; - - fill_buff[0]=0; /* By default, return "\0" string */ - if (match_str(pvarname,"STR")) { /* String variable */ - hold_id=extract_number(pvarname,MAX_USTR,'$'); - if (hold_id<1) return 0; - rstrncpy(fill_buff,userstr[hold_id-1],FILL_SIZE); - return 1; - } - else if (match_str(pvarname,"VAR")) { - hold_id=extract_number(pvarname,VAR_NUM,'$'); - if (hold_id<0) return 0; - hold_val=agt_var[hold_id]; - rstrncpy(fill_buff, - get_objattr_str(AGT_VAR,hold_id,hold_val),FILL_SIZE); - return 1; - } else if (match_str(pvarname,"FLAG")) { - hold_id=extract_number(pvarname,FLAG_NUM,'$'); - if (hold_id<0) return 0; - rstrncpy(fill_buff, - get_objattr_str(AGT_FLAG,hold_id,flag[hold_id]),FILL_SIZE); - return 1; - } else if (match_str(pvarname,"ATTR")) { - extract_prop_val(pvarname,&hold_id,&hold_val,0,'$'); - if (hold_id==BAD_PROP) return 1; - rstrncpy(fill_buff, - get_objattr_str(AGT_OBJFLAG,hold_id,hold_val),FILL_SIZE); - return 1; - } else if (match_str(pvarname,"PROP")) { - extract_prop_val(pvarname,&hold_id,&hold_val,1,'$'); - if (hold_id==BAD_PROP) return 1; - rstrncpy(fill_buff, - get_objattr_str(AGT_OBJPROP,hold_id,hold_val),FILL_SIZE); - return 1; - } else if (match_str(pvarname,"OPEN")) { - hold_val = extract_number(pvarname,maxnoun,'$'); - strcpy(fill_buff,it_open(hold_val)? "open" : "closed"); - return 1; - } - else if (match_str(pvarname,"ON")) { - hold_val = extract_number(pvarname,maxnoun,'$'); - strcpy(fill_buff,it_on(hold_val)? "on" : "off"); - return 1; - } - else if (match_str(pvarname,"LOCKED")) { - hold_val = extract_number(pvarname,maxnoun,'$'); - strcpy(fill_buff,it_locked(hold_val,0) ? "locked" : "unlocked"); - return 1; - } - - if (context==MSG_MAIN) return 0; - - if (context==MSG_PARSE) { - /* The only special subsitution allowed is $word$. */ - if (match_str(pvarname,"WORD$")) { - if (pword==NULL) fill_buff[0]=0; - else rstrncpy(fill_buff,pword,FILL_SIZE); - return 1; - } else return 0; - } - -/* d2buff is a macro that returns 1 */ - if (match_str(pvarname,"NOUN$")) - num_name(dobj_rec,just_seen_adj); - just_seen_adj=0; /* It doesn't matter. */ - if (match_str(pvarname,"VERB$")) - d2buff(realverb); /* auxsyn[vb][0] */ - if (match_str(pvarname,"OBJECT$")) - num_name(iobj_rec,0); - if (match_str(pvarname,"NAME$")) - num_name(actor_rec,0); - if (match_str(pvarname,"ADJECTIVE$")) { - just_seen_adj=get_adj(dobj_rec,fill_buff); - return 1; - } - if (match_str(pvarname,"PREP$")) - d2buff(prep); - if (match_str(pvarname,"N_PRO$")) - d2buff(it_pronoun(dobj,0)); - if (match_str(pvarname,"O_PRO$")) - d2buff(it_pronoun(iobj,0)); - if (match_str(pvarname,"NAME_PRO$")) - d2buff(it_pronoun(actor,0)); - if (match_str(pvarname,"N_INDIR$")) - d2buff(it_pronoun(dobj,1)); - if (match_str(pvarname,"O_INDIR$")) - d2buff(it_pronoun(iobj,1)); - if (match_str(pvarname,"NAME_INDIR$")) - d2buff(it_pronoun(actor,1)); - if (match_str(pvarname,"N_IS$")) { - if (!it_plur(dobj)) d2buff(ext_code[wis]) - else d2buff(ext_code[ware]); - } - if (match_str(pvarname,"O_IS$")) { - if (!it_plur(iobj)) d2buff(ext_code[wis]) - else d2buff(ext_code[ware]); - } - if (match_str(pvarname,"NAME_IS$")) { - if (!it_plur(actor)) d2buff(ext_code[wis]) - else d2buff(ext_code[ware]); - } - - if (match_str(pvarname,"N_WAS$")) { - if (!it_plur(dobj)) d2buff(ext_code[wwas]) - else d2buff(ext_code[wwere]); - } - if (match_str(pvarname,"O_WAS$")) { - if (!it_plur(iobj)) d2buff(ext_code[wwas]) - else d2buff(ext_code[wwere]); - } - if (match_str(pvarname,"NAME_WAS$")) { - if (!it_plur(actor)) d2buff(ext_code[wwas]) - else d2buff(ext_code[wwere]); - } - if (match_str(pvarname,"THE_N$")) - {theset(fill_buff,dobj);return 1;} - if (match_str(pvarname,"THE_O$")) - {theset(fill_buff,iobj);return 1;} - if (match_str(pvarname,"THE_NAME$")) - {theset(fill_buff,actor);return 1;} - if (match_str(pvarname,"THE_C$")) - {theset(fill_buff,curr_creat_rec->obj); return 1;} - if (match_str(pvarname,"C_NAME$")) - num_name(curr_creat_rec,0); - if (match_str(pvarname,"TIME$")) - {time_out(fill_buff);return 1;} - - if (pronoun_mode && match_str(pvarname,"YOU$")) - youme("I","you"); - if (pronoun_mode && match_str(pvarname,"ARE$")) - youme("am","are"); - if (pronoun_mode && match_str(pvarname,"YOU_OBJ$")) - youme("me","you"); - if (pronoun_mode && match_str(pvarname,"YOUR$")) - youme("my","your"); - if (pronoun_mode && match_str(pvarname,"YOU'RE$")) - youme("i'm","you're"); - return 0; /* Don't recognize $word$ */ -} - - - -static int capstate(const char *varname) -{ - if (islower(varname[0])) return 0; /* $word$ */ - if (islower(varname[1])) return 2; /* $Word$ */ - if (!isalpha(varname[1]) && varname[1]!=0 - && islower(varname[2])) return 2; - else return 1; /* $WORD$ */ -} - -static char fill_buff[FILL_SIZE]; /* Buffer to hold returned string */ - -static char *wordvar_match(const char **pvarname,char match_type, - int context, const char *pword) - /* Match_type=='#' for variables, '$' for parsed words */ - /* Possible # forms: #VARn#, #CNTn# */ - /* See above for $ forms */ - /* Moves *pvarname to point after matched object */ -{ - int i, hold_val, hold_prop; - const char *start; - - start=*pvarname; - if (match_type=='$') { - i=wordcode_match(pvarname,fill_buff,context,pword); - if (i==0) return NULL; - /* Now need to fix capitalization */ - switch (capstate(start)) { - case 0:break; /* $word$ */ - case 1: /* $WORD$ */ - for(i=0;fill_buff[i]!='\0';i++) - fill_buff[i]=toupper(fill_buff[i]); - break; - case 2: /* $Word$ */ - fill_buff[0]=toupper(fill_buff[0]); - break; - } - } else { /* So match type is '#' */ - if (match_str(pvarname,"VAR")) { - hold_val=extract_number(pvarname,VAR_NUM,'#'); - if (hold_val<0) return NULL; - hold_val=agt_var[hold_val]; - } - else if (match_str(pvarname,"CNT")|| - match_str(pvarname,"CTR")) { - hold_val=extract_number(pvarname,CNT_NUM,'#'); - if (hold_val<0) return NULL; - hold_val=cnt_val(agt_counter[hold_val]); - } - else if (match_str(pvarname,"PROP")) { - extract_prop_val(pvarname,&hold_prop,&hold_val,1,'#'); - if (hold_prop==BAD_PROP) hold_val=0; - } - else - return NULL; - - /* Now to convert hold_val into a string */ - sprintf(fill_buff,"%d",hold_val); - - } - return fill_buff; -} - -static char *format_line(const char *s,int context,const char *pword) -/* Do $word$ substituations; return the result */ -{ - char *t; /* The new string after all the substitutions. */ - int t_size; /* How much space has been allocated for it. */ - const char *p, *oldp; /* Pointer to the original string */ - int i; - char *fill_word, *q; /* Word used to fill in the blanks, and a pointer - used to iterate through it*/ - char fill_type; /* '#'=#variable#, '$'=$word$ */ - - /* Need to do subsitutions and also correct for tabs */ - t_size=200; - t=rmalloc(t_size+FILL_SIZE+10); - just_seen_adj=0; - - /* Note that I leave some margin here: t is 310 characters, but i will never - be allowed above around 200. This is to avoid having to put special - checking code throughout the following to make sure t isn't overrun */ - for(p=s,i=0;*p!='\0';p++) { - if (i>=t_size) { - t_size=i+100; - t=rrealloc(t,t_size+FILL_SIZE+10); - } - if (!rspace(*p) && *p!='$') - just_seen_adj=0; - if (*p=='$' || *p=='#') { - /* Read in $word$ or #var# and do substitution */ - fill_type=*p; - oldp=p++; /* Save old value in case we are wrong and then - increment p */ - fill_word=wordvar_match(&p,fill_type,context,pword); - if (fill_word==NULL) { - /*i.e. no match-- so just copy it verbatim */ - t[i++]=fill_type; - just_seen_adj=0; - p=oldp; /* Go back and try again... */ - } else { /* Fill in word */ - p--; - if (fill_word[0]=='\0') { /* Empty string */ - /* We need to eliminate a 'double space' in this case */ - if ( ( oldp==s || rspace(*(oldp-1)) ) && rspace(*(p+1))) - p++; - } else /* Normal case */ - for(q=fill_word;*q!='\0';) - t[i++]=*q++; - } - } /* End $/# matcher */ - else - t[i++]=*p; - } /* End scanning loop */ - - if (aver0 && t[i-1]==' ') { - /* For pre-Magx, delete trailing spaces */ - do - i--; - while(i>0 && t[i]==' '); - i++; - } - t[i]=0; - t=rrealloc(t,i+1); - return t; -} - -void raw_lineout(const char *s, rbool do_repl, int context, const char *pword) -{ - char *outstr; - - if (do_repl) { - outstr=format_line(s,context,pword); - writestr(outstr); - rfree(outstr); - } else - writestr(s); -} - - -static void lineout(const char *s, rbool nl,int context,const char *pword) -{ - raw_lineout(s,1,context,pword); - if (nl) writeln(""); - else writestr(" "); -} - -static void gen_print_descr(descr_ptr dp,rbool nl, - int context,const char *pword) -{ - int j; - descr_line *txt; - - agt_textcolor(7); - textbold=0; - agt_par(1); - txt=read_descr(dp.start,dp.size); - if (txt!=NULL) - for(j=0;txt[j]!=NULL;j++) - lineout(txt[j], nl || (txt[j+1]!=NULL), context,pword); - free_descr(txt); - agt_par(0); - agt_textcolor(7); - textbold=0; -} - -void print_descr(descr_ptr dp,rbool nl) -{ - gen_print_descr(dp,nl,MSG_DESC,NULL); -} - -void quote(int msgnum) -{ - char **qptr; - descr_line *txt; - int i; - int len; - - txt=read_descr(msg_ptr[msgnum-1].start, msg_ptr[msgnum-1].size); - if (txt!=NULL) { - for(len=0;txt[len]!=NULL;len++); - qptr=rmalloc(len*sizeof(char*)); - for(i=0;i or default msg ; - A of 0 means there is no standard message counterpart. - determines what $$ substitutions are meaningful - gives the $pword$ substitution for MSG_PARSE messages - msgid 3 should probably *not* be redirected to avoid giving hints to - the player as to what nouns exist in the game. -*/ -{ - /* Use gamefile's redefined version of message? */ - rbool use_game_msg; - rbool nl; /* Should it be followed by a newline? */ - - nl=1; /* By default, follow message with newline */ - - /* The following msgids shouldn't be followed by newlines: */ - if (msgid==1 || msgid==145 || (msgid>=218 && msgid<=223) - || msgid==225) - nl=0; - - if (DEBUG_SMSG) rprintf("\nSTD %d",msgid); - - use_game_msg=( (PURE_SYSMSG || s==NULL) - && msgid!=0 && msgid<=NUM_ERR - && err_ptr!=NULL ); - - if (use_game_msg) { - /* Check for fall-back messages */ - if (err_ptr[msgid-1].size<=0 - && msgid>OLD_MAX_STD_MSG && msgid<=MAX_NUM_ERR) { - msgid=stdmsg_fallback[msgid-OLD_MAX_STD_MSG-1]; - if (DEBUG_SMSG) rprintf("==> %3d"); - } - if (msgid!=0 && err_ptr[msgid-1].size>0) { - if (DEBUG_SMSG) rprintf(" : From gamefile\n"); - gen_print_descr(err_ptr[msgid-1],nl,context,pword); - } else use_game_msg=0; - } - - if (DEBUG_SMSG && !use_game_msg) rprintf(" : Default\n"); - - if (!use_game_msg) { - /* Either the game doesn't redefine the message, or we're ignoring - redefinitions */ - if (s==NULL) return; - pronoun_mode=1; - lineout(s,nl,context,pword); - pronoun_mode=!PURE_PROSUB; - } -} - - -void sysmsg(int msgid,char *s) -{ - gen_sysmsg(msgid,s,MSG_RUN,NULL); -} - - -void alt_sysmsg(int msgid,char *s, - parse_rec *new_dobjrec,parse_rec *new_iobjrec) -{ - parse_rec *save_dobjrec, *save_iobjrec; - integer save_dobj, save_iobj; - - save_dobj=dobj; save_dobjrec=dobj_rec; - dobj=p_obj(new_dobjrec); dobj_rec=new_dobjrec; - - save_iobj=iobj; save_iobjrec=iobj_rec; - iobj=p_obj(new_iobjrec); iobj_rec=new_iobjrec; - - gen_sysmsg(msgid,s,MSG_RUN,NULL); - - dobj=save_dobj; dobj_rec=save_dobjrec; - iobj=save_iobj; iobj_rec=save_iobjrec; -} - - -void sysmsgd(int msgid,char *s,parse_rec *new_dobjrec) -/* Front end for sysmsg w/alternative direct object */ -{ - alt_sysmsg(msgid,s,new_dobjrec,NULL); -} - - -/* -------------------------------------------------------------------- */ -/* QUESTION and ANSWER processing */ -/* -------------------------------------------------------------------- */ - - -static char *match_string(char *ans,char *corr_ans,int n) -/* Searches for s (w/ surrounding whitespace removed) inside ans */ -/* looking at only n characters of s */ -{ - char *s; - char *corr; - int i; - - s=rstrdup(corr_ans); - for(i=n-1;i>0 && isspace(s[i]);i--); /* Kill trailing whitespace */ - s[i+1]=0; - for(i=0;s[i]!=0;i++) s[i]=tolower(s[i]); - for(i=0;isspace(s[i]);i++); /* Kill leading whitespace */ - corr=strstr(ans,s+i); - rfree(s); - return corr; -} - - -static rbool check_answer(char *ans,long start,long size) -/* qnum has already been fixed to start from 0 */ -/* Master's edition answer checker. Master's edition answers can */ -/* be seperate by AND and OR characters. If there is one OR in the */ -/* answer, all ANDs will also be treated as ORs */ -/* Furthermore, AND-delimited strings must appear in the correct order */ -/* unless PURE_ANSWER is false */ -{ - char *corr, *corr2; /* Pointer into answer to match correct answers */ - int match_mode; /* 0=AND mode, 1=OR mode */ - descr_line *astr; /* Holds the answer string */ - int i; /* Index to line of astr we're on. */ - char *p,*q, *r; /* Used to break astr up into pieces and - loop over them */ - - astr=read_descr(start,size); - if (astr==NULL) { - if (!PURE_ERROR) - writeln("GAME ERROR: Empty answer field."); - return 1; } - - match_mode=0; - for(i=0;astr[i]!=NULL;i++) - if (strstr(astr[i],"OR")!=NULL) {match_mode=1;break;} - - corr=ans; - for(i=0;astr[i]!=NULL;i++) { /* loop over all lines of the answer */ - p=astr[i]; - do { - q=strstr(p,"OR"); - r=strstr(p,"AND"); - if (q==NULL || (r!=NULL && r=INT_MAX); - return n; -} - - - - -void runptr(int i, descr_ptr dp[], char *msg, int msgid, - parse_rec *nounrec, parse_rec *objrec) -/* Prints out description unless it doesn't exist, in which - case it prints out either system message #msgid or the message - contained in msg. */ -{ - if (dp[i].size>0) print_descr(dp[i],1); - else alt_sysmsg(msgid,msg,nounrec,objrec); -} - - - -/* Score modes: - S:Score, R:Room +=list '(out of..'), -=don't list at all. - 0-- S+ R+ - 1-- S+ R - 2-- S R+ - 3-- S R - 4-- S+ R- - 5-- S R- - 6-- S- R+ - 7-- S- R - 8-- S- R- and disable SCORE. - */ - - -void print_score(void) -{ - char s[80]; - int i,rmcnt, totroom; - - if (score_mode<5) { - if (score_mode==0 || score_mode==1 || score_mode==4) - sprintf(s,"Your score is %ld (out of %ld possible).",tscore,max_score); - else sprintf(s,"Your score is %ld.",tscore); - writeln(s); - } - - if (score_mode<4 || score_mode==6 || score_mode==7) { - rmcnt=0; - totroom=0; - for(i=0;i<=maxroom-first_room;i++) - if (!room[i].unused) { - if (room[i].seen) rmcnt++; - /* Should really compute this once at the beginning, but */ - /* I don't want to add yet another global variable, particulary */ - /* since this is only used here. */ - totroom++; - } - if (score_mode%2==0) - sprintf(s,"You have visited %d locations (out of %d in the game)",rmcnt, - totroom); - else sprintf(s,"You have visited %d locations.",rmcnt); - writeln(s); - } -} - - -int normalize_time(int tnum) /* Convert hhmm so mm<60 */ -{ - int min,hr; - - min=tnum % 100; /* The minutes */ - hr=tnum / 100; /* The hours */ - hr+=min/60; min=min%60; - while(hr<0) hr+=24; - hr=hr%24; - return hr*100+min; -} - - -void add_time(int dt) -{ - int min,hr; - - min=curr_time % 100; /* The minutes */ - hr=curr_time / 100; /* The hours */ - if (aver==AGT183) min+=dt; /* AGT 1.83 version */ - else { /* Normal version */ - min+=dt%100; - hr+=dt/100;} - while(min<0) {min=min+60;hr++;} - hr+=min/60; min=min%60; - while(hr<0) hr+=24; - hr=hr%24; - curr_time=hr*100+min; -} - - -void look_room(void) -{ - compute_seen(); - writeln(""); - if (islit()) { - if (room[loc].name!=NULL && room[loc].name[0]!=0 && - (!PURE_ROOMTITLE) ) - { - agt_textcolor(-1); /* Emphasized text on */ - writestr(room[loc].name); - agt_textcolor(-2); - writeln(""); - } /* Emphasized text off */ - if (room_firstdesc && room[loc].initdesc!=0) - msgout(room[loc].initdesc,1); - else if (room_ptr[loc].size>0) - print_descr(room_ptr[loc],1); - print_contents(loc+first_room,1); - if (listexit_flag) - v_listexit(); - } - else - sysmsg( room[loc].light==1?6:7, - "It is dark. $You$ can't see anything."); - room_firstdesc=0; - do_look=0; -} - - -static void run_autoverb(void) -{ - int v0; /* Will hold the verb number of the autoverb */ - int savevb; - integer saveactor, savedobj, saveiobj; - parse_rec *save_actor_rec, *save_dobj_rec, *save_iobj_rec; - word saveprep; - - - beforecmd=1; - - /* This is the penalty for vb, actor, etc being global variables. */ - savevb=vb; - saveactor=actor; savedobj=dobj; saveprep=prep; saveiobj=iobj; - save_actor_rec=copy_parserec(actor_rec); - save_dobj_rec=copy_parserec(dobj_rec); - save_iobj_rec=copy_parserec(iobj_rec); - - if (room[loc].autoverb!=0) { - v0=verb_code(room[loc].autoverb); - (void)scan_metacommand(0,v0,0,0,0,NULL); - } - free_all_parserec(); - vb=savevb; - actor=saveactor; dobj=savedobj; iobj=saveiobj; - actor_rec=save_actor_rec; dobj_rec=save_dobj_rec; iobj_rec=save_iobj_rec; - prep=saveprep; -} - - - -/* ------------------------------------------------------------------- */ -/* MAIN COMMAND EXECUTION ROUTINES-- */ -/* These routines handle the execution of player commands */ -/* Then they change the status line, update counters, etc. */ -/* ------------------------------------------------------------------- */ - -static void creat_initdesc(void) -{ - int i; - - creatloop(i) - if (creature[i].location==loc+first_room && - creature[i].initdesc!=0) { - msgout(creature[i].initdesc,1); - creature[i].initdesc=0; - } -} - -/* Print out picture names, remember to put intro before first one. */ -/* This should be called with s==NULL before and after: - before to reset it, after to put the trailing newline on. */ -void listpictname(char *s) -{ - static rbool first_pict=1; /* True until we output first picture */ - - if (s==NULL) { - if (!first_pict) writeln(""); /* Trailing newline */ - first_pict=1; - return; - } - if (first_pict) { - writeln(""); /* Skip a line */ - sysmsg(219," Illustrations:"); - first_pict=0; - } - writestr(" "); - writestr(s); -} - - -void listpict(int obj) -{ - char *s; - - if (it_pict(obj)!=0 ) { - s=objname(obj); - listpictname(s); - rfree(s); - } -} - - -void list_viewable(void) - /* List pictures that can be viewed, if any */ -{ - int i; - - listpictname(NULL); - - if (room[loc].pict!=0) - listpictname("scene"); - contloop(i,1) - listpict(i); - contloop(i,1000) - listpict(i); - contloop(i,loc+first_room) - listpict(i); - - for(i=0;i=AGTME10) - list_viewable(); /* Print out picts that can be viewed here. */ - do_look=0; - - prevloc=loc; - if (do_autoverb) { - do_autoverb=0; - run_autoverb(); - } - - if (!room[loc].seen) { /* This only runs on the first turn */ - room[loc].seen=1; - tscore+=room[loc].points; - } - } while (prevloc!=loc); /* Autoverb could move player */ -} - - -static int min_delta(void) -{ - return (aver==AGT183) ? 1 : 0 ; -} - - -void increment_turn(void) -{ - int i; - - compute_seen(); - - newlife_flag=0; - - if (quitflag) return; - - newroom(); - - if (winflag || deadflag || endflag) return; - - if (was_metaverb) return; /* No time should pass during a metaverb. */ - - turncnt++; - /* Now increment the time counter */ - if (delta_time>0) { - if (PURE_TIME) - add_time(agt_rand(min_delta(),delta_time)); - else /* if !PURE_TIME */ - add_time(delta_time); - } - - for(i=0;i<=CNT_NUM;i++) - if (agt_counter[i]>=0) ++agt_counter[i]; - creatloop(i) - if (creature[i].location==loc+first_room && creature[i].hostile && - creature[i].timethresh>0) - { - parse_rec tmpcreat; /* Used for creature messages */ - make_parserec(i+first_creat,&tmpcreat); - curr_creat_rec=&tmpcreat; - - if (++creature[i].timecounter>=creature[i].timethresh) - { /* Creature attacks */ - sysmsg(16,"$The_c$$c_name$ suddenly attacks $you_obj$!"); - sysmsg(creature[i].gender==0 ? 17 : 18, - " $You$ try to defend $your$self, but $the_c$$c_name$ " - "kills $you_obj$ anyhow."); - deadflag=1; - } - else /* 'Angrier' messages */ - if (creature[i].timethresh>0 && - creature[i].timecounter>creature[i].timethresh-3) - sysmsg(15,"$The_c$$c_name$ seems to be getting angrier."); - } -} - - -/* Wrapper for increment_turn used by exec routines below. - This just checks to make sure we're not one of the 1.8x versions - (which call increment turn from elsewhere) */ -static void exec_increment_turn(void) -{ - if (PURE_AFTER) increment_turn(); -} - -static void end_turn(void) -{ - if (textbold) agt_textcolor(-2); - textbold=0; - set_statline(); - - if (quitflag) return; - - if (notify_flag && !was_metaverb) { - if (old_scoretscore) - sysmsg(228," [Your score just went down]"); - } - old_score=tscore; - -} - - - -static void set_pronoun(int item) -{ - if (item==0) return; - switch (it_gender(item)) { - case 0: - if (it_plur(item)) - last_they=item; - last_it=item; /* Change: last_it will be set even if the - noun is plural */ - break; - case 1: last_she=item;break; - case 2: last_he=item;break; - } -} - - -/* True if the current noun is the last one in the list. */ -static rbool lastnoun(parse_rec *list) -{ - if (list->info==D_END) return 1; - list++; - while(list->info==D_AND) list++; - return (list->info==D_END); -} - - - - -static void runverbs(parse_rec *actor0,int vnum, - parse_rec *lnoun,word prep0,parse_rec *iobj0) -/* The zeros are postpended simply to avoid a name conflict */ -{ - parse_rec *currnoun; - - textbold=0; - do_look=0;do_autoverb=0; - was_metaverb=0; - actor=actor0->obj; - actor_rec=copy_parserec(actor0); - vb=vnum; - dobj=lnoun[0].obj; - dobj_rec=copy_parserec(lnoun); - prep=prep0; - iobj=iobj0->obj; - iobj_rec=copy_parserec(iobj0); - set_pronoun(actor); /* Basically the last one that isn't 0 will stick */ - set_pronoun(iobj0->obj); - was_metaverb=0; /* Most verbs are not metaverbs; assume this by default */ - start_of_turn=1; end_of_turn=0; - - if (lnoun[0].info==D_END || lnoun[0].info==D_ALL) { - end_of_turn=1; - exec_verb(); - if (doing_restore) {free_all_parserec();return;} - if (PURE_AND) exec_increment_turn(); - } - else for(currnoun=lnoun;currnoun->info!=D_END;currnoun++) - if (currnoun->info!=D_AND) { - free_all_parserec(); - end_of_turn=lastnoun(currnoun); - actor=actor0->obj; - actor_rec=copy_parserec(actor0); - vb=vnum; - dobj=currnoun->obj; - dobj_rec=copy_parserec(currnoun); - iobj=iobj0->obj; - iobj_rec=copy_parserec(iobj0); - set_pronoun(dobj); - exec_verb(); - if (doing_restore) return; - if (PURE_AND) - exec_increment_turn(); - else - start_of_turn=0; - if (quitflag || winflag || deadflag || endflag) - break; - } - assert(end_of_turn); - if (!PURE_AND) exec_increment_turn(); - end_turn(); - free_all_parserec(); -} - - -/* The following store values for use by AGAIN */ -/* (so AGAIN can be implemented just by executing runverbs w/ the saved - values) */ -static int save_vnum; -static word save_prep; -static parse_rec save_actor; -static parse_rec save_obj; -parse_rec *save_lnoun=NULL; - - - -void exec(parse_rec *actor, int vnum, - parse_rec *lnoun, word prep, parse_rec *iobj) -{ - - cmd_saveable=0; - pronoun_mode=!PURE_PROSUB; - - if (vnum==verb_code(ext_code[wagain]) && lnoun[0].info==D_END - && iobj->info==D_END && - (actor->info==D_END || actor->obj==save_actor.obj) ) - if (save_lnoun==NULL) { - rfree(lnoun); - sysmsg(186, - "You can't use AGAIN until you've entered at least one command."); - return; - } else { - memcpy(actor,&save_actor,sizeof(parse_rec)); - vnum=save_vnum; - prep=save_prep; - memcpy(iobj,&save_obj,sizeof(parse_rec)); - rfree(lnoun); - lnoun=save_lnoun;save_lnoun=NULL; - } - else - realverb=input[vp]; - - - runverbs(actor,vnum,lnoun,prep,iobj); - - if (cmd_saveable) { - if (save_lnoun!=NULL) rfree(save_lnoun); - - memcpy(&save_actor,actor,sizeof(parse_rec)); - save_vnum=vnum; - save_lnoun=lnoun; lnoun=NULL; - save_prep=prep; - memcpy(&save_obj,iobj,sizeof(parse_rec)); - } - else - rfree(lnoun); -} diff --git a/app/src/main/jni/terps/agility/exec.h b/app/src/main/jni/terps/agility/exec.h deleted file mode 100644 index 89d0d89..0000000 --- a/app/src/main/jni/terps/agility/exec.h +++ /dev/null @@ -1,254 +0,0 @@ -/* exec.h-- Header file for verb execution routines */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy: the (Mostly) Universal */ -/* AGT Interpreter */ - - -#ifndef global /* Don't touch this */ -#define global extern -#define global_defined_exec -#endif - - - -/* This contains the decoding of the current instruction */ -typedef struct { - integer op; - int arg1; - int arg2; - int optype; - int argcnt; /* Actual number of argument words present */ - const opdef *opdata; - const char *errmsg; - rbool disambig; /* Trigger disambiguation? */ - rbool negate; /* NOT? (cond token only) */ - rbool failmsg; /* Run only on failure? */ - rbool endor; /* End any OR blocks? (action tokens, mainly) */ -} op_rec; - - - -/* The following determines if we are doing disambiguation - or actually executing a verb */ -global uchar do_disambig; /* 0= execution - 1= disambiguating noun - 2= disambiguating object */ - - -/* Flags used during turn execution */ -global rbool beforecmd; /* Only used by 1.8x games */ -global rbool supress_debug; /* Causes debugging info to _not_ be printed - even if debugging is on; used by disambiguator - and to supress ANY commands */ -global rbool was_metaverb; /* Was the verb that just executed a metaverb? */ - /* Metaverbs are commands that should not take game time - to execute: SAVE, RESTORE, RESTART, QUIT, SCRIPT, UNSCRIPT, - NOTIFY, SCORE, etc. */ -global integer oldloc; /* Save old location for NO_BLOCK_HOSTILE purposes */ - -/* This is a hack to pass the subroutine number from exec_token - back to scan_metacommand when a DoSubroutine is done */ -global integer subcall_arg; - -/* This fixes a bug in the original AGT spec, causing "actor, verb ..." - commands to misfire if there is more than one creature of the same - name. */ -global integer *creat_fix; - - -/* -------------------------------------------------------------------- */ -/* Defined in EXEC.C */ -/* -------------------------------------------------------------------- */ -void raw_lineout(const char *s, rbool do_repl, - int context, const char *pword); -void msgout(int msgnum,rbool add_nl); -void sysmsg(int msgid,char *s); -void alt_sysmsg(int msgid,char *s, - parse_rec *new_dobjrec,parse_rec *new_iobjrec); -void sysmsgd(int msgid,char *s,parse_rec *new_dobj_rec); - -rbool ask_question(int qnum); -void increment_turn(void); - -/* Warning: the following function rfrees */ -rbool match_answer(char *ans, int anum); - -void look_room(void); -void runptr(int i, descr_ptr dp[], char *msg, int msgid, - parse_rec *nounrec,parse_rec *objrec); - -int normalize_time(int tnum); /* Convert hhmm so mm<60 */ -void add_time(int dt); - - -/* -------------------------------------------------------------------- */ -/* Defined in OBJECT.C */ -/* -------------------------------------------------------------------- */ -parse_rec *make_parserec(int obj,parse_rec *rec); -parse_rec *copy_parserec(parse_rec *rec); -void free_all_parserec(void); /* Freeds doj_rec, iobj_rec, and actor_rec */ - -rbool in_scope(int item); -rbool islit(void); -rbool it_possess(int item); -rbool it_proper(int item); -rbool it_isweapon(int item); -rbool it_door(int obj,word noun); /* Is obj a door? */ -rbool is_within(integer obj1, integer obj2, rbool stop_if_closed); - -integer it_room(int item); /* Returns the room that the item is in */ - -int lightcheck(int parent,int roomlight,rbool active); -/* If active is false, we don't care if the light is actually working. */ - -#define it_move(a,b) it_reposition(a,b,0) -#define it_destroy(item) it_move(item,0) -#define get_obj(dobj) it_move(dobj,1) -#define drop_obj(dobj) it_move(dobj,loc+first_room) - -void it_reposition(int item,int newloc,rbool save_pos); -void goto_room(int newroom); - -void it_describe(int dobj); -int print_contents(int obj,int ind_lev); - -void recompute_score(void); - -int check_fit(int obj1, int obj2); - -/* And its possible return values: */ - -#define FIT_OK 0 /* Fits */ -#define FIT_WEIGHT 1 /* Too heavy [*] */ -#define FIT_NETWEIGHT 2 /* With other stuff is too heavy [*] */ -#define FIT_SIZE 3 /* Too big */ -#define FIT_NETSIZE 4 /* With other stuff is too big */ -/* [*]-- These can only occur if obj2==1 or for ME/1.5-1.7 */ - - -long getprop(int obj, int prop); -void setprop(int obj, int prop, long val); -rbool getattr(int obj, int prop); -void setattr(int obj, int prop, rbool val); - -rbool matchclass(int obj, int oclass); - -/* ---------------------------------------------------------------------- */ -/* Define in RUNVERB.C */ -/* ---------------------------------------------------------------------- */ - -/* Verbs actually used elsewhere in th interpreter */ -void v_inventory(void); -void v_look(void); -void v_listexit(void); - -/* The routine that actually runs the current player command */ -void exec_verb(void); - - -/* ---------------------------------------------------------------------- */ -/* In METACOMMAND.C */ -/* ---------------------------------------------------------------------- */ -/* The main routine to search the metacommand list and run the appropriate - meta-commands */ -int scan_metacommand(integer m_actor,int vcode, - integer m_dobj, word m_prep, integer m_iobj, - int *redir_flag); - -/* The type checking routine */ -rbool argvalid(int argtype,int arg); - -/* ---------------------------------------------------------------------- */ -/* In TOKEN.C */ -/* ---------------------------------------------------------------------- */ -int exec_instr(op_rec *oprec); /* Execute instruction */ -long pop_expr_stack(void); /* Wrapper around routine to access TOS */ - -/* ---------------------------------------------------------------------- */ -/* Defined in DEBUGCMD.C */ -/* ---------------------------------------------------------------------- */ -void get_debugcmd(void); /* Get and execute debugging commands */ - - -/* ------------------------------------------------------------------- */ -/* Macros for getting information about items */ -/* (mainly used to blackbox the difference between nouns and creatures) */ -/* -------------------------------------------------------------------- */ - -/* A note on object codes: - <0 obj is a 'virtual' object, existing only as the word - dict[-obj], e.g. DOOR, flag nouns, global nouns - 0 No object (or any object) - 1 Self(i.e. the player) - first_room..last_room Rooms - first_noun..last_noun Nouns - first_creat..last_creat Creatures - 1000 Being worn by the player */ - - -/* The following macro loops over the contents of an object */ -#define contloop(i,obj) for(i=it_contents(obj);i!=0;i=it_next(i)) -#define safecontloop(i,j,obj) for(i=it_contents(obj),j=it_next(i); \ - i!=0;i=j,j=it_next(i)) - -#define cnt_val(c) ((c)==-1 ? 0 : (c)) - - -/* -------------------------------------------------------------------- */ -/* These are the macros that should usually be used to determine */ -/* information about the objects in the game, unless the object type */ -/* is definitely known */ -/* ------------------------------------------------------------------- */ - -#define it_on(item) nounattr(item,on) -#define it_group(item) creatattr(item,groupmemb) -#define it_adj(item) objattr(item,adj) -#define it_pushable(item) nounattr(item,pushable) -#define it_pullable(item) nounattr(item,pullable) -#define it_turnable(item) nounattr(item,turnable) -#define it_playable(item) nounattr(item,playable) -#define it_plur(item) nounattr(item,plural) -#define it_gender(item) creatattr(item,gender) - -#define it_pict(item) objattr(item,pict) -#define it_class(item) anyattr(item,oclass) -#define it_next(item) objattr(item,next) -#define it_isglobal(item) objattr(item,isglobal) -#define it_flagnum(item) objattr(item,flagnum) -#define it_seen(item) anyattr(item,seen) - - -#define it_name(item) objattr2(item,name,(item<0) ? -item : 0) -#define it_open(item) nounattr2(item,open, tcreat(item) || \ - (tdoor(item) && !room[loc].locked_door)) - - /* This checks to make sure the object isn't unmovable. */ - /* (As such, all non-nouns automatically pass) */ -#define it_canmove(item) (!tnoun(item) || noun[(item)-first_noun].movable) - - -#ifdef IT_MACRO -#define it_contents(item) objattr2(item,contents,\ - roomattr2(item,contents,\ - (item==1) ? player_contents : \ - (item==1000) ? player_worn : 0)) -#define it_lockable(item) nounattr2(item,lockable, (tdoor(item) ? 1 : 0) ) -#define it_locked(item,name) nounattr2(item,locked,\ - (tdoor(item) && room[loc].locked_door ? \ - 1 : 0)) -#else -int it_contents(integer obj); -rbool it_lockable(integer obj,word noun); -rbool it_locked(integer obj, word noun); -#endif - - -#ifdef global_defined_exec -#undef global -#undef global_defined_exec -#endif - - diff --git a/app/src/main/jni/terps/agility/filename.c b/app/src/main/jni/terps/agility/filename.c deleted file mode 100644 index 9ba51d2..0000000 --- a/app/src/main/jni/terps/agility/filename.c +++ /dev/null @@ -1,771 +0,0 @@ -/* filename.c-- Low level file i/o and routines to deal */ -/* with filename. */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for both AGiliTy: the (Mostly) Universal */ -/* AGT Interpreter and for the Magx adventure game compiler. */ - -/* Notes for docs: - file_type_id must be a type that can be set to 0. - */ - -#include -#include -#include -#include -#include - -#include "agility.h" - -#ifdef force16 -#undef int -#endif - -#ifdef UNIX_IO -#include -#include /* Needed only for file permission bits */ - -#ifdef __STRICT_ANSI__ -int fileno(FILE *f); -FILE *popen(char *s,char *how); -int pclose(FILE *p); -#endif - -#ifdef MSDOS16 -#include -#endif -#endif /* UNIX_IO */ - -#ifdef force16 -#define int short -#endif - - -/*----------------------------------------------------------------------*/ -/* Filetype Data */ -/*----------------------------------------------------------------------*/ -const char *extname[]={ - "", - DA1, DA2, DA3, DA4, DA5, DA6, DSS, - pHNT, pOPT, pTTL, - pSAV, pSCR, pLOG, - pAGX, pINS, pVOC, pCFG, - pAGT, pDAT, pMSG, pCMD, pSTD, AGTpSTD}; - - -#ifdef PATH_SEP -static const char *path_sep=PATH_SEP; -#else -static const char *path_sep=NULL; -#endif - -/* This returns the options to use when opening the given file type */ -/* rw is true if we are writing, false if we are reading. */ -const char *filetype_info(filetype ft, rbool rw) -{ - if (ft=fCFG) return (open_as_binary ? "rb" : "r"); -#else - if (ft>=fCFG) return "rb"; -#endif - if (ft==fSCR) { - if (rw) - return (BATCH_MODE || make_test) ? "w" : "a"; - else return "r"; - } - if (ft==fLOG) return rw ? "w" : "r"; - fatal("INTERNAL ERROR: Invalid filetype."); - return NULL; -} - - -/* Returns true if ft is a possible extension in general context ft_base */ -static rbool compat_ext(filetype ft, filetype ft_base) -{ - if (ft_base==fNONE || ft_base==fDA1 || ft_base==fAGX) { /* Game file */ - return ( ft>=fDA1 && ft<=fDSS) - || ft==fOPT || ft==fTTL - || (ft>=fAGX && ft<=fCFG); - } - - if (ft_base==fSAV || ft_base==fSCR || ft_base==fLOG) - return (ft==ft_base); - - if (ft_base==fAGT) { /* Source code */ - return (ft>=fAGT && ft<=fCMD) - || ft==fTTL || ft==fCFG; - } - - fatal("INTERNAL ERROR: Invalid file class."); - return 0; -} - - - -/*----------------------------------------------------------------------*/ -/* Misc. utilities */ -/*----------------------------------------------------------------------*/ - -char *assemble_filename(const char *path, const char *root, - const char *ext) -{ - int len1, len2, len3; - char *name; - - len1=len2=len3=0; - if (path!=NULL) len1=strlen(path); - if (root!=NULL) len2=strlen(root); - if (ext!=NULL) len3=strlen(ext); - name=rmalloc(len1+len2+len3+1); - if (path!=NULL) memcpy(name,path,len1); -#ifdef PREFIX_EXT - if (ext!=NULL) memcpy(name+len1,ext,len3); - if (root!=NULL) memcpy(name+len1+len3,root,len2); -#else - if (root!=NULL) memcpy(name+len1,root,len2); - if (ext!=NULL) memcpy(name+len1+len2,ext,len3); -#endif - name[len1+len2+len3]=0; - return name; -} - -/* This works for binary files; we don't care about non-binary - files since this only used to search for game files. */ -static rbool file_exist(const char *fname) -{ - FILE *f; - f=fopen(fname,"rb"); - if (f==NULL) return 0; - fclose(f); - return 1; -} - - - -/* This checks to see if c matches any of the characters in matchset */ -static rbool smatch(char c, const char *matchset) -{ - for(;*matchset!=0;matchset++) - if (*matchset==c) return 1; - return 0; -} - - - -/*----------------------------------------------------------------------*/ -/* Taking Apart the Filename */ -/*----------------------------------------------------------------------*/ - -static int find_path_sep(const char *name) -{ - int i; - - if (path_sep==NULL) - return -1; - for(i=strlen(name)-1;i>=0;i--) - if (smatch(name[i],path_sep)) break; - return i; -} - - -/* Checks to see if the filename (which must be path-free) - has an extension. Returns the length of the extensions - and writes the extension type in pft */ -static int search_for_ext(const char *name, filetype base_ft, - filetype *pft) -{ - filetype t; - int xlen,len; - - *pft=fNONE; - len=strlen(name); - if (len==0) return 0; - for(t=fNONE+1;t<=fSTD;t++) - if (compat_ext(t,base_ft)) { - xlen=strlen(extname[t]); - if (xlen==0 || xlen>len) continue; -#ifdef PREFIX_EXT - if (strncasecmp(name,extname[t],xlen)==0) -#else - if (fnamecmp(name+len-xlen,extname[t])==0) -#endif - { - *pft=t; - return xlen; - } - } -#ifdef UNIX_IO - /* This is code to make the Unix/etc ports easier to use under - tab-completing shells (which often complete "gamename._" or - "gamename.ag_" since there are other files in the directory - with the same root.) */ - assert(*pft==fNONE); - if (name[len-1]=='.') return 1; - if (fnamecmp(name+len-3,".ag")==0) { - if (base_ft==fDA1 || base_ft==fAGX) *pft=fAGX; - if (base_ft==fAGT) *pft=fAGT; - } - if (fnamecmp(name+len-3,".da")==0) { - if (base_ft==fDA1 || base_ft==fAGX) *pft=fDA1; - if (base_ft==fAGT) *pft=fAGT; - } - if (*pft!=fNONE) return 3; -#endif - return 0; -} - - -/* Extract root filename or extension from - pathless name, given that the extension is of length extlen. */ -/* If isext is true, extract the extension. If isext is false, - then extrac the root. */ -static char *extract_piece(const char *name, int extlen, rbool isext) -{ - char *root; - int len, xlen; - rbool first; /* If true, extract from beginning; if false, extract - from end */ - - len=strlen(name)-extlen; - xlen=extlen; - if (isext) { - int tmp; - tmp=len; len=xlen; xlen=tmp; - } - if (len==0) return NULL; - root=rmalloc((len+1)*sizeof(char)); -#ifdef PREFIX_EXT - first=isext ? 1 : 0; -#else - first=isext ? 0 : 1; -#endif - if (first) { - memcpy(root,name,len); - root[len]=0; - } else { - memcpy(root,name+xlen,len); - root[len]=0; - } - return root; -} - - -/* This returns true if "path" is absolute, false otherwise. - This is _very_ platform dependent. */ -static rbool absolute_path(char *path) -{ -#ifdef pathtest - return pathtest(path); -#else - return 1; -#endif -} - -/*----------------------------------------------------------------------*/ -/* Basic routines for dealing with file contexts */ -/*----------------------------------------------------------------------*/ - -#define FC(x) ((file_context_rec*)(x)) - -/* formal_name is used to get filenames for diagnostic messages, etc. */ -char *formal_name(fc_type fc, filetype ft) -{ - if (FC(fc)->special) return FC(fc)->gamename; - if (ft==fNONE) - return rstrdup(FC(fc)->shortname); - if (ft==fAGT_STD) - return rstrdup(AGTpSTD); - return assemble_filename("",FC(fc)->shortname,extname[ft]); -} - -#ifdef PATH_SEP -static rbool test_file(const char *path, const char *root, const char *ext) -{ - char *name; - rbool tmp; - - name=assemble_filename(path,root,ext); - tmp=file_exist(name); - rfree(name); - return tmp; -} - -/* This does a path search for the game files. */ -static void fix_path(file_context_rec *fc) -{ - char **ppath; - - - if (gamepath==NULL) return; - for(ppath=gamepath;*ppath!=NULL;ppath++) - if (test_file(*ppath,fc->shortname,fc->ext) - || test_file(*ppath,fc->shortname,pAGX) - || test_file(*ppath,fc->shortname,DA1)) - { - fc->path=rstrdup(*ppath); - return; - } -} -#endif - - -/* This creates a new file context based on gamename. */ -/* ft indicates the rough use it will be put towards: - ft=fNONE indicates it's the first pass read, before PATH has been - read in, and so the fc shouldn't be filled out until - fix_file_context() is called. - ft=pDA1 indicates that name refers to the game files. - ft=pAGX indicates the name of the AGX file to be written to. - ft=pSAV,pLOG,pSCR all indicate that name corresponds to the - related type of file. */ -fc_type init_file_context(const char *name,filetype ft) -{ - file_context_rec *fc; - int p, x; /* Path and extension markers */ - - fc=rmalloc(sizeof(file_context_rec)); - fc->special=0; - -#ifdef UNIX - if (name[0]=='|') { /* Output pipe */ - name++; - fc->special=1; - } -#endif - - fc->gamename=rstrdup(name); - -#ifdef UNIX - x=strlen(fc->gamename); - if (fc->gamename[x-1]=='|') { /* Input pipe */ - fc->gamename[x-1]=0; - fc->special|=2; - } - if (fc->special) { - fc->path=fc->shortname=fc->ext=NULL; - return fc; - } -#endif - - p=find_path_sep(fc->gamename); - if (p<0) - fc->path=NULL; - else { - fc->path=rmalloc((p+2)*sizeof(char)); - memcpy(fc->path,fc->gamename,p+1); - fc->path[p+1]='\0'; - } - x=search_for_ext(fc->gamename+p+1,ft,&fc->ft); - fc->shortname=extract_piece(fc->gamename+p+1,x,0); - fc->ext=extract_piece(fc->gamename+p+1,x,1); - -#ifdef PATH_SEP - if (fc->path==NULL && ft==fDA1) - fix_path(fc); -#endif - return fc; -} - - -void fix_file_context(fc_type fc,filetype ft) -{ -#ifdef PATH_SEP - if (FC(fc)->path==NULL && ft==fDA1) - fix_path(FC(fc)); -#endif -} - - -/* This creates new file contexts from old. */ -/* This is used to create save/log/script filenames from the game name, - and to create include files in the same directory as the source file. */ -fc_type convert_file_context(fc_type fc,filetype ft,const char *name) -{ - file_context_rec *nfc; - rbool local_ftype; /* Indicates file should be in working directory, - not game directory. */ - - local_ftype=(ft==fSAV || ft==fSCR || ft==fLOG ); - if (BATCH_MODE || make_test) local_ftype=0; - - if (name==NULL) { - nfc=rmalloc(sizeof(file_context_rec)); - nfc->gamename=NULL; - nfc->path=NULL; - nfc->shortname=rstrdup(fc->shortname); - nfc->ext=NULL; - nfc->ft=fNONE; - nfc->special=0; - } else { - nfc=init_file_context(name,ft); - } - - /* If path already defined, then combine paths. */ - if (!local_ftype && nfc->path!=NULL && !absolute_path(nfc->path)) { - char *newpath; - newpath=nfc->path; - newpath=assemble_filename(fc->path,nfc->path,""); - rfree(nfc->path); - nfc->path=newpath; - } - - /* scripts, save-games and logs should go in the working directory, - not the game directory, so leave nfc->path equal to NULL for them. */ - if (!local_ftype && nfc->path==NULL) - nfc->path=rstrdup(fc->path); /* Put files in game directory */ - return nfc; -} - -void release_file_context(fc_type *pfc) -{ - file_context_rec *fc; - fc=FC(*pfc); - rfree(fc->gamename); - rfree(fc->path); - rfree(fc->shortname); - rfree(fc->ext); - rfree(fc); -} - - -/*----------------------------------------------------------------------*/ -/* Routines for Finding Files */ -/*----------------------------------------------------------------------*/ - -#ifdef UNIX -/* This requires that no two sav/scr/log files be open at the same time. */ -static int pipecnt=0; -static FILE *pipelist[6]; - -static genfile try_open_pipe(fc_type fc, filetype ft, rbool rw) -{ - FILE *f; - - errno=0; - if (ft!=fSAV && ft!=fSCR && ft!=fLOG) return NULL; - if (rw && fc->special!=1) return NULL; - if (!rw && fc->special!=2) return NULL; - if (pipecnt>=6) return NULL; - - f=popen(fc->gamename,rw ? "w" : "r"); /* Need to indicate this is a pipe */ - pipelist[pipecnt++]=f; - return f; -} -#endif - - -static genfile try_open_file(const char *path, const char *root, - const char *ext, const char *how, - rbool nofix) -{ - char *name; - FILE *f; - - name=assemble_filename(path,root,ext); - f=fopen(name,how); -#ifndef MSDOS -#ifndef GLK - if (f==NULL && !nofix) { /* Try uppercasing it. */ - char *s; - for(s=name;*s!=0;s++) - *s=toupper(*s); - f=fopen(name,how); - } -#else - /* - * Try converting just the file name extension to uppercase. This - * helps us to handle cases where AGT games are unzipped without - * filename case conversions - in these cases, the files will carry - * extensions .TTL, .DA1, and so on, whereas we'll be looking for - * files with extensions .ttl, .da1, etc. This is one part of - * being file name case insensitive - the other part is to define - * fnamecmp as strcasecmp, which we do in config.h. - */ - if (f == NULL && !nofix && ext != NULL) { - char *uc_ext; - int i; - - /* Free the existing name. */ - rfree (name); - - /* Convert the extension to uppercase. */ - uc_ext = rmalloc (strlen (ext) + 1); - for (i = 0; i < strlen (ext); i++) - uc_ext[i] = toupper (ext[i]); - uc_ext[strlen (ext)] = '\0'; - - /* Form a new filename and try to open that one. */ - name = assemble_filename (path, root, uc_ext); - rfree (uc_ext); - f = fopen (name, how); - } -#endif -#endif - rfree(name); - return f; -} - - -static genfile findread(file_context_rec *fc, filetype ft) -{ - genfile f; - - f=NULL; - -#ifdef UNIX - if (fc->special) { /* It's a pipe */ - f=try_open_pipe(fc,ft,0); - return f; - } -#endif - if (ft==fAGT_STD) { - f=try_open_file(fc->path,AGTpSTD,"",filetype_info(ft,0),0); - return f; - } - if (ft==fAGX || ft==fNONE) /* Try opening w/o added extension */ - f=try_open_file(fc->path,fc->shortname,fc->ext,filetype_info(ft,0),0); - if (f==NULL) - f=try_open_file(fc->path,fc->shortname,extname[ft],filetype_info(ft,0),0); - return f; -} - - -/*----------------------------------------------------------------------*/ -/* File IO Routines */ -/*----------------------------------------------------------------------*/ - -genfile readopen(fc_type fc, filetype ft, char **errstr) -{ - genfile f; - - *errstr=NULL; - f=findread(fc,ft); - if (f==NULL) { - const char *s, *t; -#ifdef UNIX - if (errno==0 && fc->special) { /* Bad pipe type */ - *errstr=rstrdup("Invalid pipe request."); - return f; - } -#endif - s=strerror(errno); - t=formal_name(fc,ft); - *errstr=rmalloc(30+strlen(t)+strlen(s)); - sprintf(*errstr,"Cannot open file %s: %s.",t,s); - } - return f; -} - -rbool fileexist(fc_type fc, filetype ft) -{ - genfile f; - - if (fc->special) return 0; - f=try_open_file(fc->path,fc->shortname,extname[ft],filetype_info(ft,0),1); - if (f!=NULL) { /* File already exists */ - readclose(f); - return 1; - } - return 0; -} - - -genfile writeopen(fc_type fc, filetype ft, - file_id_type *pfileid, char **errstr) -{ - char *name; - genfile f; - - *errstr=NULL; - name=NULL; - -#ifdef UNIX - if (fc->special) { /* It's a pipe */ - f=try_open_pipe(fc,ft,1); - if (f==NULL && errno==0) { - *errstr=rstrdup("Invalid pipe request."); - return f; - } - if (f==NULL) /* For error messages */ - name=rstrdup(fc->gamename); - } else -#endif - { - name=assemble_filename(FC(fc)->path,FC(fc)->shortname,extname[ft]); - f=fopen(name,filetype_info(ft,1)); - } - if (f==NULL) { - const char *s; - s=strerror(errno); - *errstr=rmalloc(30+strlen(name)+strlen(s)); - sprintf(*errstr,"Cannot open file %s: %s.",name,s); - } - if (pfileid==NULL) - rfree(name); - else - *pfileid=(void*)name; - return f; -} - - -rbool filevalid(genfile f, filetype ft) -{ - return (f!=NULL); -} - - - -void binseek(genfile f, long offset) -{ - assert(f!=NULL); - assert(offset>=0); -#ifdef UNIX_IO - if (lseek(fileno(f),offset,SEEK_SET)==-1) -#else - if (fseek(f,offset,SEEK_SET)!=0) -#endif - fatal(strerror(errno)); -} - - -/* This returns the number of bytes read, or 0 if there was an error. */ -long varread(genfile f, void *buff, long recsize, long recnum, char **errstr) -{ - long num; - - *errstr=NULL; - assert(f!=NULL); -#ifdef UNIX_IO -#ifdef MSDOS16 - num=(unsigned int)read(fileno(f),buff,recsize*recnum); - if (num==(unsigned int)-1) -#else - num=read(fileno(f),buff,recsize*recnum); - if (num==-1) -#endif - { - *errstr=rstrdup(strerror(errno)); - return 0; - } -#else - errno=0; - num=fread(buff,recsize,recnum,f); - if (num!=recnum && errno!=0) - *errstr=rstrdup(strerror(errno)); - num=num*recsize; -#endif - return num; -} - -rbool binread(genfile f, void *buff, long recsize, long recnum, char **errstr) -{ - long num; - - num=varread(f,buff,recsize,recnum,errstr); - if (num -#include -#include - - -/* ------------------------------------------------------------------- */ -/* Preinitialized data structures */ -/* Most of the preinitialized data structures used by all of the */ -/* AGT-related programs go here . */ -/* ------------------------------------------------------------------- */ - - -/* ------------------------------------------------------------ */ -/* The PC --> ASCII conversion table. This converts the 8th-bit */ -/* PC characters to their nearest ASCII equivalent. */ -/* ------------------------------------------------------------ */ - -const char trans_ibm[]= -"CueaaaaceeeiiiAA" /* 80 */ -"E@@ooouuyOUc$$pf" /* 90 */ -"aiounNao?....!<>" /* A0 */ -"###|++|+++|\\/++\\" /* B0 */ -"\\+++-+||\\/+++=+=" /* C0 */ -"+=+++++++//@@@@@" /* D0 */ -"abGpSsmtFTOd.fe^" /* E0 */ -"=+> n-55 105,122 - Dummy_verb1...Dummy_Verb50 */ - -/* Possible extension to verb definitons (not implemented): - If it _requires_ a prep, use : ? - If it takes a prep and no dobj, use | ? -*/ - -/* These are alternative (that is, non-canonical) forms of verbs that - were present in the oringal AGT interpreters. They have the property - that they have no effect if used in a dummy_verb declaration. */ -/* Their dictionary indices are stored in old_agt_verb, which is - initialized by reinit_dict. */ -/* PICK, GO */ -char *old_agt_verb_str[]={ - "n","s","e","w","ne","nw","se","sw","u","d","in","inside","leave", - "cast","dump","shut","l","ex","inspect","check","kill","fight","hit", - "shout","scream","place","q","talk","i","take","touch","ext", - "shoot","h","ins",NULL}; - - - -/* ------------------------------------------------------------------- */ -/* Dictionary primitives: the basic functions for manipulating the */ -/* dictionary data structures. */ -/* ------------------------------------------------------------------- */ -#define HASHSIZE (1<>HASHBITS))&HASHMASK; - } - return (n & HASHMASK); -} - -static word search0_dict(const char *s) -{ - int i; - -#ifdef DOHASH - for(i=hashfunc(s); - hash[i]!=-1 && strcmp(s,dict[hash[i]])!=0; - i=(i+1)&HASHMASK); - return hash[i]; -#else - for(i=0; strcmp(s,dict[i])!=0 && idictstrsize) { /* Enlarge dictstr */ - if (dictstrsize==0) dictstrsize=DICT_INIT; - while(newptr>dictstrsize) - dictstrsize+=DICT_GRAN; - newstr=rrealloc(dictstr,dictstrsize); - /* Now need to update all of our pointers */ - for(i=0;iHASHSIZE) fatal("Hash table overflow"); - for(i=hashfunc(s);hash[i]!=-1;i=(i+1)&HASHMASK); - hash[i]=dp; -#endif - return dp++; -} - -#ifdef DOHASH - -static void init_hash(void) -{ - int i; - - for(i=0;iHASHSIZE) fatal("Hash table overflow"); - init_hash(); - - for(i=0;i0) { /* word just ended: need to add it to dictionary etc */ - curr[n]=0;n=0; - addsyn(add0_dict(curr)); /* Add to syn list or prep list, depending */ - } - if (!isspace(*p)) - addsyn(-1); /* Mark the end of the list */ - if (*p==';' || *p=='.' || *p=='!') { - if (*p==';') verbflag[vp]|=VERB_TAKEOBJ; - if (*p=='!') verbflag[vp]|=VERB_META; - if (have_multiword) - verb_multiword(vp); - have_multiword=0; - vp++; - if (vp>=TOTAL_VERB) break; - auxsyn[vp]=synptr; /* The following words will be the syn list */ - } - else if (*p==',') - preplist[vp]=synptr; /* The following words will be the prep list */ - } - else if (*p=='&') { - curr[n++]=' '; - have_multiword=1; - } - else curr[n++]=*p; -} - - - - -void init_dict(void) -{ - dict=NULL;verblist=NULL;syntbl=NULL;no_syn=0; - auxsyn=NULL;preplist=NULL;verbflag=NULL; - auxcomb=NULL; - old_agt_verb=NULL; - num_auxcomb=0; -} - -/* This is called by agttest.c */ -void build_verblist(void) -{ - int i; - - verblist=rmalloc(sizeof(words)*TOTAL_VERB); - for(i=0;i "); - for(j=preplist[i];syntbl[j]!=0;j++) - rprintf(" %s",dict[ syntbl[preplist[i]]] ); - writeln(""); - } - } -#endif -} - - - -void set_verbflag(void) -{ - verbflag[14]|=VERB_MULTI; /* throw */ - verbflag[29]|=VERB_MULTI; /* put */ - verbflag[33]|=VERB_MULTI; /* get */ - verbflag[41]|=VERB_MULTI; /* drop */ - verbflag[51]|=VERB_MULTI; /* wear */ - verbflag[52]|=VERB_MULTI; /* remove */ -} - - -void reinit_dict(void) -/* reinit_dict initializes verblist and sets up aux_syn as well - as loading the initial vocabulary into the dictionary. */ -{ - char buff[16]; /* Needs to be big enough to hold dummy_verbNNN\0 - or subroutineNNN\0 */ - int i; - - no_syn=no_auxsyn; - - auxsyn=rmalloc(sizeof(slist)*TOTAL_VERB); - auxcomb=NULL; num_auxcomb=0; - preplist=rmalloc(sizeof(slist)*TOTAL_VERB); - verbflag=rmalloc(sizeof(uchar)*TOTAL_VERB); - - if (!agx_file) - init0_dict(); -#ifdef DOHASH - else - rebuild_hash(); -#endif - - for(i=0;i0; j--); - s[j+1]=0; - /* Okay, now make sure it isn't 'none' */ - if (strcmp(s,"none")==0) return 0; - /* Finally, add it to the dictionary if it isn't already there */ - return add0_dict(s); -} - -/* Adds w to dynamically grown synonym list */ -/* If no_syn is set, then *don't* add a synonym: return immediatly */ -/* (This is done by agt2agx to avoid creating the auxsyn lists, */ -/* since those should be created when the interpreter loads the */ -/* game file and not before) */ -void addsyn(word w) -{ - if (no_syn) return; - if (w==0) return; - if (w==-1) w=0; - if (synptr>=syntbl_size) { - syntbl_size+=SYN_GRAIN; - if (syntbl_size>0x7FFF) - fatal("Too many synonyms."); - syntbl=rrealloc(syntbl,((long)syntbl_size)*sizeof(word)); } - syntbl[synptr++]=w; -} - - -/* Returns the given dictionary word with some checking for -1 */ -const char *gdict(word w) -{ - assert(w>=-1 && w0;i--) - for(j=synlist[i];syntbl[j]!=0;j++) - if (w==syntbl[j]) return i; - return 0; -} - - -int verb_code(word w) -/* Given a word w, searches auxsyn and returns the verb id */ -{ - int canon, tmp; - - /* Expand author-defined synonyms */ - tmp=verb_authorsyn(w); - if (tmp!=0) return tmp; - - /* Expand built-in synonyms */ - canon=verb_builtin(w); - if (canon!=0) { - /* Allow built-in verbs to be overridden */ - tmp=verb_authorsyn(syntbl[auxsyn[canon]]); - if (tmp!=0) return tmp; - } - - return canon; /* No new synonyms; return canonical match if it exists */ -} - - -/* This is a faster version of the above for use in the special case of - command headers where the verb word is much more restricted; it should - be the first auxsyn entry and it should never by a synlist entry. */ -static int cmdverb_code(word w) -{ - int i,j; - - for(i=0;i=first_room && i<=maxroom) - return rstrdup(room[i-first_room].name); - if ( (i>=first_noun && i<=maxnoun) || (i>=first_creat && i<=maxcreat) ) - { - word adjw,nounw; - if (i>=first_noun && i<=maxnoun) { - adjw=noun[i-first_noun].adj; - nounw=noun[i-first_noun].name; - } - else { - adjw=creature[i-first_creat].adj; - nounw=creature[i-first_creat].name; - } - if (adjw==0 || !strcmp(dict[adjw],"no_adjective")) - return rstrdup(dict[nounw]); - return concdup(dict[adjw],dict[nounw]); - } - /* At this point we can't get a name: return ILLn. */ - s=rmalloc(3+1+(5*sizeof(int))/2+1); - /* Make sure we have enough space in case i is big */ - sprintf(s,"ILL%d",i); - return s; -} - - - -/* ------------------------------------------------------------------- */ -/* Routines to sort the command array and construct verbptr */ -/* ------------------------------------------------------------------- */ - -#define SORT_META - -#ifdef SORT_META - -#define ch1 ((const cmd_rec*)cmd1) -#define ch2 ((const cmd_rec*)cmd2) - -/* See notes below before trying to decipher this routine; - during the sort, many of the fields are being used for nonstandard - purposes */ - - - -#define s_verb(cmd) ( (cmd)->actor<0 ? (cmd)->data[0] : (cmd)->verbcmd) - -static int cmp_cmd(const void *cmd1, const void *cmd2) -{ - word v1,v2; - - /* We are sorting on command[].verbcmd, but if one of the headers - is really the object of a redirect command then we need to use - its parent's verbcmd */ - /* For commands with actors, we need to avoid sorting them at all. */ - v1=s_verb(ch1); - v2=s_verb(ch2); - - if (v1v2) return +1; - - /* v1==v2, so leave them in the same order as before */ - /* We have to take absolute values here because we are using negatives - to indicate redirection objects */ - if ( abs(ch1->actor) < abs(ch2->actor) ) - return -1; - else if (abs(ch1->actor) == abs(ch2->actor) ) - return 0; - else return 1; - /* Equality should be impossible */ -} - -#undef ch1 -#undef ch2 - -/* This sets things up for qsort */ -/* We need a sort that is - i) Stable and - ii) Keeps "redirection headers" attached to the correct command */ -/* We steal the field actor for this purpose */ -/* actor will equal the index of the header in the original list. */ -/* (or negative the header if the command is a redirection) */ -/* For redirected commands, we steal the data pointer since it shouldn't - be being used anyhow. */ -/* In a field pointed to by data we store the verb word */ -/* NOTE: this routine requires that the data type of *data (namely - integer) is big enough to hold a value of type word. */ - -static void rsort(void) -{ - long i; - integer *save_actor; - word *save_verb; - - save_actor=rmalloc(last_cmd*sizeof(integer)); - save_verb=rmalloc(last_cmd*sizeof(word)); - - /* The following loop does three things: - i) Copies command[].actor to save_actor[] - ii) Sets command[].actor to the commands index in the array - iii) For actor commands, sets the verb to .... after saving it - in save_verb. - iv) For redirection commands, stores the verb of the owning - header in a block pointed to by data */ - - for(i=0;i1) /* i.e. there _is_ an actor */ - command[i].verbcmd=syntbl[auxsyn[DIR_ADDR_CODE]]; - save_actor[i]=command[i].actor; - command[i].actor=i; - if (save_actor[i]<0) { /* Redirected command */ - int j; - - command[i].actor=-i; - rfree(command[i].data); /* data should be NULL, anyhow */ - command[i].data=rmalloc(sizeof(integer)); - for(j=i;j>0 && save_actor[j]<0;j--); - if (save_actor[j]>0) - command[i].data[0]=command[j].verbcmd; - else { - command[i].data[0]=0; - agtwarn("First command header is REDIRECT object!",0); - } - } - } - - /* Now do the sort... */ - qsort(command,last_cmd,sizeof(cmd_rec),cmp_cmd); - -#if 0 /* This is code to test the integrity of the sort */ - for(i=0;i=AGX00) rsort(); -#endif - - - if (no_auxsyn) return; /* Used by agt2agx */ - - for(i=0;i1) - curr_vb=DIR_ADDR_CODE; - else - curr_vb=cmdverb_code(command[i].verbcmd); - if (iverbend[curr_vb]) verbend[curr_vb]=i; - } - - for(i=0;iMAX_COND && opPREWIN_ACT && opMAX_ACT) ) { - return &illegal_def; - } - if (op>=2000) - return &end_def[op-2000]; - if (op>=1000) - return &act_def[op-1000]; - return &cond_def[op]; -} - - - -/* ------------------------------------------------------------------- */ -/* Functions for processing strings */ -/* ------------------------------------------------------------------- */ - -long new_str(char *buff,int max_leng,rbool pasc) -/* Stores the (up to leng) characters of a string - into our master string space (enlarging it if neccessary) - and returns the offset into the array. - pasc=1 ==> pascal-style string - pasc=0 ==> C-style string; ignore max_leng and NONE strings - */ -{ - int leng, i; - long p; - - if (pasc) { - leng=buff[0]; - if (leng>max_leng) leng=max_leng; - } else - leng=strlen(buff); - - if (ss_size empty string */ - if (ss_end!=0) return (ss_end-1); /* Points to last \0 */ - else { /* Very first string */ - static_str[0]=0;ss_end=1; - return 0; - } - } - - p=ss_end; /* Remember begining of string */ - for(i=0;i=oflag_cnt) return -1; - switch (t) - { - case 0: *ofs=attrtable[id].rbit; return attrtable[id].r; - case 1: *ofs=attrtable[id].nbit; return attrtable[id].n; - case 2: *ofs=attrtable[id].cbit; return attrtable[id].c; - default: rprintf("INT ERROR: Invalid object type.\n"); - return -1; - } -} - -long lookup_objprop(int id, int t) -{ - if (id<0 || id>=oprop_cnt) return -1; - switch (t) - { - case 0: return proptable[id].r; - case 1: return proptable[id].n; - case 2: return proptable[id].c; - default: rprintf("INT ERROR: Invalid object type.\n"); - return -1; - } -} - -int num_oattrs(int t, rbool isflag) -{ - switch(t) - { - case 0: return isflag ? num_rflags : num_rprops; - case 1: return isflag ? num_nflags : num_nprops; - case 2: return isflag ? num_cflags : num_cprops; - default: rprintf("INT ERROR: Invalid object type.\n"); - return 0; - } -} - -rbool op_simpflag(uchar *pf, char ofs, int op) - /* op: 0=clear, 1=set, 2=nop, 3=toggle two bits: */ -{ - unsigned char mask, amask, bmask; - - mask=1<>1) << ofs ); - bmask=(op&1)< %d\n",base,obj,ocnt,rval); */ - return rval; -} - - -rbool have_objattr(rbool prop,integer obj,int id) -{ - int t; - char ofs; - - if (troom(obj)) t=0; - else if (tnoun(obj)) t=1; - else if (tcreat(obj)) t=2; - else return 0; - if (prop) - return (lookup_objprop(id,t)>=0); - else - return (lookup_objflag(id,t,&ofs)>=0); -} - - - -rbool op_objflag(int op, integer obj, int id) -{ - /* op: 0=clear, 1=set, 2=nop, 3=toggle two bits: */ - /* = (&)^ ) */ - int index; - int t, firstobj; - char ofs; - - if (troom(obj)) {t=0;firstobj=first_room;} - else if (tnoun(obj)) {t=1;firstobj=first_noun;} - else if (tcreat(obj)) {t=2;firstobj=first_creat;} - else return 0; - - index=calcindex(obj,firstobj,num_oattrs(t,1),lookup_objflag(id,t,&ofs)); - if (index==-1) return 0; - - return op_simpflag(&objflag[index],ofs,op); -} - -long op_objprop(int op, int obj, int id, long val) -{ - /* op: 2=get, 1=set */ - int index, t, firstobj; - - if (troom(obj)) {t=0;firstobj=first_room;} - else if (tnoun(obj)) {t=1;firstobj=first_noun;} - else if (tcreat(obj)) {t=2;firstobj=first_creat;} - else return 0; - - index=calcindex(obj,firstobj,num_oattrs(t,0),lookup_objprop(id,t)); - if (index==-1) return 0; - - if (op==2) return objprop[index]; - else objprop[index]=val; - return val; -} - -const char *get_objattr_str(int dtype,int id,long val) -{ - int max_val; - - if (dtype==AGT_OBJPROP) { - if (!proptable || !propstr || id<0 || id>=oprop_cnt) return ""; - max_val=proptable[id].str_cnt; - if (val<0) val=0; - if (val>=max_val) val=max_val-1; - if (max_val>0) - return propstr[ proptable[id].str_list + val ]; - return ""; - } else if (dtype==AGT_VAR) { - if (!vartable || !propstr || id<0 || id>VAR_NUM) return ""; - max_val=vartable[id].str_cnt; - if (val<0) val=0; - if (val>=max_val) val=max_val-1; - if (max_val>0) - return propstr[ vartable[id].str_list + val ]; - return ""; - } else if (dtype==AGT_OBJFLAG) { - if (attrtable && id>=0 && id=0 && id<=FLAG_NUM) - return val ? flagtable[id].ystr : flagtable[id].nstr; - else - return val ? "on" : "off"; - } else - rprintf("INTERNAL ERROR: Invalid data type for get_objattr_str()."); - return ""; -} - -/* ------------------------------------------------------------------- */ -/* Warning and error functions */ -/* ------------------------------------------------------------------- */ - -void agtwarn(const char *s,int elev) -{ - if (ERR_LEVEL>=elev) - rprintf("Warning: %s\n",s); -} - -void agtnwarn(const char *s,int n,int elev) -{ - if (ERR_LEVEL>=elev) - rprintf("Warning: %s%d.\n",s,n); -} - -void fatal(const char *s) -{ - /* Should really change this so it uses only low-level primitives, - instead of rprintf (which depends on writestr, etc.) */ - rprintf("Fatal error: %s\n",s); - close_interface(); - exit(EXIT_FAILURE); -} - -void init_flags(void) -{ - rm_trap=1; - DIAG=def_DIAG; interp_arg=def_interp_arg; - debug_da1=def_debug_da1; RAW_CMD_OUT=def_RAW_CMD_OUT; - ERR_LEVEL=def_ERR_LEVEL; - irun_mode=0; - fix_ascii_flag=fix_ascii; - descr_maxmem=DESCR_BUFFSIZE; - bold_mode=0; - dbg_nomsg=0; /* Print out MSG arguments to metacommands */ - debug_mode=0; - dbgflagptr=NULL; - dbgvarptr=NULL; - dbgcntptr=NULL; - no_auxsyn=0; - text_file=0; -#ifdef PATH_SEP - gamepath=NULL; -#endif - BATCH_MODE=make_test=0; - font_status=0; -#ifdef OPEN_AS_TEXT - open_as_binary=0; -#endif -} - diff --git a/app/src/main/jni/terps/agility/interface.c b/app/src/main/jni/terps/agility/interface.c deleted file mode 100644 index b531e45..0000000 --- a/app/src/main/jni/terps/agility/interface.c +++ /dev/null @@ -1,1125 +0,0 @@ -/* interface.c-- high-level interface functions and misc. utilities */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* */ -/* This is part of the source for AGiliTy, the (Mostly) Universal */ -/* AGT Interpreter */ - -/* This module contains a miscellany of things that are somewhat */ -/* system dependent but not enough so to justify being put in */ -/* OS_.c */ -/* --writestr() and writeln().*/ -/* --Hooks for sound, pictures, and fonts. */ -/* --yesno() and wait_return() */ -/* --Some lower level file stuff */ -/* --main() and command line parseing stuff */ - -#include -#include -#include -#include - -#include "agility.h" -#include "interp.h" - -#ifdef _DOS -#ifdef UNIX_IO -#undef UNIX_IO -#endif -#endif - -#ifndef REPLACE_GETFILE -#ifdef UNIX_IO -#include -#endif -#endif - - -#ifdef UNIX - /* Needed because we are compiling with ANSI set */ -FILE *popen(const char*,const char*); -int pclose(FILE*); -#endif - -#ifndef REPLACE_BNW - -/* #define DEBUG_BELLS_AND_WHISTLES */ - -/* Warning for fontcmd, pictcmd, musiccmd: - These all extract filenames from fontlist, pictlist, pixlist, songlist. - Any of these are allowed to be NULL and this should be checked - before accessing them. */ - -#ifdef DEBUG_BELLS_AND_WHISTLES -void bnw_report(char *cmdstr,filename *list,int index) -{ - writeln(""); - writestr(">** ");writestr(cmdstr);writestr(" "); - if (list!=NULL) { - writestr(list[index]); - writestr(" ");} - writeln("**<"); -} -#endif /* DEBUG_BELLS_AND_WHISTLES */ - -void fontcmd(int cmd,int font) -/* 0=Load font, name is fontlist[font] - 1=Restore original (pre-startup) font - 2=Set startup font. (.FNT) -*/ -{ -#ifdef DEBUG_BELLS_AND_WHISTLES - if (cmd==0) bnw_report("Loading Font",fontlist,font); - else if (cmd==1) bnw_report("Restoring original font",NULL,0); -#endif - return; -} - -void pictcmd(int cmd,int pict) -/* 1=show global picture, name is pictlist[pict] - 2=show room picture, name is pixlist[pict] - 3=show startup picture .P.. - */ -{ -#ifdef DEBUG_BELLS_AND_WHISTLES - if (cmd==1) bnw_report("Showing picture",pictlist,pict); - else if (cmd==2) bnw_report("Showing pix",pixlist,pict); - agt_waitkey(); -#endif - return; -} - - - -int musiccmd(int cmd,int song) -/* For cmd=1 or 2, the name of the song is songlist[song] - The other commands don't take an additional argument. - 1=play song - 2=repeat song - 3=end repeat - 4=end song - 5=suspend song - 6=resume song - 7=clean-up - 8=turn sound on - 9=turn sound off - -1=Is a song playing? (0=false, -1=true) - -2=Is the sound on? (0=false, -1=true) -*/ -{ - if (cmd==8) sound_on=1; - else if (cmd==9) sound_on=0; -#ifdef DEBUG_BELLS_AND_WHISTLES - switch (cmd) { - case 1:bnw_report("Play song",songlist,song);break; - case 2:bnw_report("Repeat song",songlist,song);break; - case 3:bnw_report("End repeat",NULL,0);break; - case 4:bnw_report("End song",NULL,0);break; - case 5:bnw_report("Suspend song",NULL,0);break; - case 6:bnw_report("Resume song",NULL,0);break; - case 7:bnw_report("Clean up",NULL,0);break; - case 8:bnw_report("Sound On",NULL,0);break; - case 9:bnw_report("Sound Off",NULL,0);break; - case -1:return yesno("Is song playing?"); - case -2:return 1; - } -#endif - return 0; -} - -#endif /* REPLACE_BNW */ - -static char linebuff[100]; -static int lp; /* Line pointer */ -static rbool savenl=0; -static rbool needfill; /* Used for paragraph filling */ -static rbool quotemode=0; - -#ifdef UNIX -static rbool ispipe[3]={0,0,0}; /* script, log_in, log_out */ -#endif - - - -void debugout(const char *s) -{ - int i; - - if (DEBUG_OUT) fputs(s,debugfile); - else { - lp=0; - for(;*s!=0;s++) { - if (curr_x+lp>=screen_width || lp>80) { - if (lp+curr_x>=screen_width) - lp=screen_width-curr_x-1; - linebuff[lp]=0; - agt_puts(linebuff); - agt_newline(); - lp=0; - } - if (*s=='\n') - {linebuff[lp]=0; - agt_puts(linebuff); - agt_newline(); - lp=0;} - else if (*s=='\t') - {for(i=0;i<3;i++) linebuff[lp++]=' ';} - else if (*s>=0 && *s<=9) linebuff[lp++]=' '; - else linebuff[lp++]=*s; - } - linebuff[lp]=0; - agt_puts(linebuff); - } -} - - -int close_pfile(genfile f, int ft) - /* ft=0 for script, 4 for log_in, 5 for log_out */ -{ -#ifdef UNIX - if (ft>=4) ft-=3; - if (ispipe[ft]) { - ispipe[ft]=0; - pclose(f); - return 0; - } -#endif - if (ft==4) - writeclose(f,NO_FILE_ID); - else - readclose(f); - return 0; -} - - - -static char *get_log(void) -/* Read string from logfile_in */ -{ - char *s; - static int dead_log; - - if (!filevalid(log_in,fLOG)) { /* We are finishing up */ - if (++dead_log>100) fatal("Internal error: LOG."); - assert(BATCH_MODE); - s=rmalloc(2); - s[0]=' '; - s[1]=0; - return s; - } - - s=rmalloc(1000);s[0]=' ';s[1]=0; - textgets(log_in,s,1000); - if (texteof(log_in)) { /* Reached end of logfile */ - close_pfile(log_in,1); - log_in=BAD_TEXTFILE; - if (BATCH_MODE) { - writeln(""); - writeln("ERROR: Unexpected end of log file."); - agt_quit(); /* This doesn't actually quit; it just sets things - up so we *will* quit. */ - dead_log=0; - } else { - logflag&=~2; - fast_replay=0; - } - } else { /* Need to delay or wait for keypress */ - if (logdelay==-1) agt_waitkey(); - else agt_delay(logdelay); - if (s[0]!=0) writeln(s); - } - return s; -} - - -static void put_log(const char *s) -/* Write s to logfile_out */ -{ - textputs(log_out,s); - if (s[strlen(s)-1]!='\n') - textputs(log_out,"\n"); -} - - -char *agt_readline(int in_type) -{ - char *s; - - if (PURE_INPUT) agt_textcolor(-1); - if (logflag&2) - s=get_log(); - else - s=agt_input(in_type); - if (PURE_INPUT) agt_textcolor(-2); - - if (logflag&1) - put_log(s); - - return s; -} - -char agt_getchar(void) -{ - char c, *s, buff[2]; - - if (PURE_INPUT) agt_textcolor(-1); - if (logflag&2) { - s=get_log(); - c=s[0]; - rfree(s); - } else - c=agt_getkey(1); - if (PURE_INPUT) agt_textcolor(-2); - if (logflag&1) { - buff[0]=c;buff[1]=0; - put_log(buff); - } - return c; -} - -void agt_center(rbool b) -/* 1=turn on text centering, 0=turn off */ -/* At the moment, this is only used for game end messages */ -/* When it is on, text output with writeln() should be 'centered'; */ -/* it is up to the interface to decide what that means. */ -/* writestr() should not be called while centering is on. */ -{ - center_on=b; -} - -void agt_par(rbool b) -/* This has been added for the sake of anyone trying to get this to */ -/* work on less-than-80 column screens. My personal opinion is that this */ -/* is probably hopeless; many AGT games assume 80-column format for */ -/* creating tables and ascii graphics. Nevertheless... */ -/* Text between an agt_par(1) and an agt_par(0) is logically connected */ -/* (all part of one description) and so it *might* be possible to reformat */ -/* it, treating multiple lines as being one paragraph. */ -/* At the very least, you should look for blank lines and indentation */ -/* since a single section of text could contain multiple paragraphs. */ -/* Sections of text _not_ between an agt_par(1) and an agt_par(0) should */ -/* be treated as though each line were a new paragraph */ -{ - par_fill_on=b; - if (b==0 && savenl) agt_newline(); - savenl=0;needfill=0; -} - -/* This handles the various format code. They all show up after - '\r'; unrecogonized codes are just ignored */ -static uchar xlat_format_code(uchar c) -{ - if (c==0xFF) { - if (fix_ascii) return trans_ibm[0xFF-0x80]; - else return 0xFF; - } - return 0; -} - -#define FMT_CODE_CNT 15 - -static void run_format_code(uchar c) -{ - if (c0 && c<=LAST_TEXTCODE)||((uchar)c==FORMAT_CODE)) - -void writestr(const char *s) -{ - int i, j; - char c; - int endmark, old_x; - - if (savenl) { - assert(par_fill_on); - if (!isalnum(s[0])) agt_newline(); - else agt_puts(" "); - /* If combining two lines, insert a space between them. */ - } - savenl=0; - i=0;lp=0; - - while(s[i]!=0) { - for(;s[i]!=0 && lp<90 && curr_x+lp0 && !isspace(linebuff[endmark])); - } - - if (endmark==0 && !isspace(linebuff[endmark])) { /* Can't find a break */ - if (curr_x+lp0) /* already stuff on this line printed previously */ - endmark=0; /* i.e. print out nothing; move it to next line */ - else /* We have a single word that is longer than our line */ - endmark=screen_width; /* Give up */ - } - - c=linebuff[endmark]; - linebuff[endmark]=0; - old_x=curr_x; - - agt_puts(linebuff); - - linebuff[endmark]=c; - - if (old_x+lp>=screen_width) - /* Need to insert line break and skip any spaces */ - { - if (!quotemode) agt_newline(); - else return; /* In quote mode, just truncate */ - - /* Now set up beginning of next line: skip over whitespace */ - while(endmark0 && s[i]<=LAST_TEXTCODE) - agt_textcolor(s[i++]); - else if (s[i]=='\r') { - run_format_code((uchar)s[i+1]); - i+=2; - } - else if (s[i]=='\n') { - i+=1; - agt_newline(); - } - } -} - - - -void writeln(const char *s) -{ - int i,pad; - char *padstr; - - if (center_on && strlen(s)+curr_x=AGX00) agt_newline(); - else savenl=1; - else if (needfill!=2) - agt_newline(); - needfill=0; -} - - -static char fixstatchar(uchar c) -/* Eliminate formating characters in the status line */ -{ - if (c=='\t' || c<=LAST_TEXTCODE || - (c==FORMAT_CODE) || c=='\r' || c=='\n') - return ' '; - return c; -} - -void print_statline(void) -/* Use strings in l_stat and r_stat */ -{ - int i,j; - char *s, *t; - static rbool lastline=0; /* Was a non-empty status line printed last time? */ - - s=rmalloc((status_width+1)*sizeof(char)); - - /* If both strings empty, don't print the status line */ - if (l_stat[0]==0 && r_stat[0]==0 && !lastline) return; - lastline=(l_stat[0] || r_stat[0]); - - i=status_width-strlen(l_stat)-strlen(r_stat); - - j=0; - if (r_stat[0]==0) {/* Center the status line */ - while(j6) {s[j++]=' ';i-=2;} /* If statline is wide enough, put a - space on each side */ - - if (strlen(l_stat)0;i--) s[j++]=' '; /* Insert space between left and right sides */ - - if (j+strlen(r_stat)<=status_width) /*Copy right side into s */ - for(t=r_stat;*t!=0;t++) s[j++]=fixstatchar(*t); - - while(jwidth) width=linewidth[i]; - } - - agt_makebox(width,len,flags&~(TB_BOLD|TB_CENTER)); - quotemode=1; /* So newlines will cause truncation rather than a - real newline */ - for(i=0;i=size) break; - sprintf(sbuff,"%2d.",j*colheight+i+1); - writestr(sbuff); - writestr(menu[j*colheight+i]); - if (j=size) - writeln("Please choose an option from the menu."); - } while (i<0 || i>=size); - return i; -} - -#endif /* REPLACE_MENU */ - - - -void prompt_out(int n) -/* n=1 standard prompt - n=2 question prompt */ -{ - agt_textcolor(7); - if (PURE_INPUT && n==1) agt_textcolor(-1); - if (n==1) { - agt_newline(); - gen_sysmsg(1,">",MSG_MAIN,NULL); - } - if (n==2) agt_puts("? "); - agt_textcolor(7); -} - -void agt_waitkey(void) -{ - if (BATCH_MODE || fast_replay) - return; - agt_getkey(0); -} - - -void wait_return(void) -{ - writeln(" --- HIT ANY KEY ---"); - agt_waitkey(); -} - - -rbool yesno(const char *s) -/* True for yes, false for no. */ -{ - char c; - - writestr(s);writestr(" "); - c='y'; - do { - if (c!='y') - writestr("Please answer es or o. "); - c=tolower(agt_getchar()); - } while (c!='y' && c!='n' && !quitflag); - return (c=='y'); -} - - -void set_test_mode(fc_type fc) -{ - char *errstr; - - log_in=readopen(fc,fLOG,&errstr); - - if (make_test) { - if (errstr==NULL) - fatal("Log file already exists."); - log_out=writeopen(fc,fLOG,NULL,&errstr); - if (errstr!=NULL) - fatal("Couldn't create log file."); - logflag=1; - return; - } - - logdelay=0; - if (errstr!=NULL) - fatal("Couldn't open log file."); - logflag=2; - - script_on=1; - scriptfile=writeopen(fc,fSCR,NULL,&errstr); - if (errstr!=NULL) - fatal("Couldn't open script file."); -} - - -#ifndef REPLACE_GETFILE - - -#ifdef UNIX_IO - -extern const char *extname[]; /* From filename.c */ - -static rbool check_fname(char *name, filetype ext) -{ - return 0==strcmp(name+strlen(name)-strlen(extname[ext]),extname[ext]); -} - - -static void list_files(char *type, filetype ext) -{ - DIR *currdir; - struct dirent *entry; - char **filelist; - int filecnt, listsize; - int maxleng; /* Longest filename; used for formatting */ - int i,j; - int numcols, height; - - filelist=NULL; filecnt=listsize=0; maxleng=0; - currdir=opendir("."); - if (currdir==NULL) return; /* Nothing we can do except give up */ - do { - entry=readdir(currdir); - if ( entry!=NULL && check_fname(entry->d_name,ext) ) { - /* It has the right extension; add it to our list of files */ - if (filecnt>=listsize) { - listsize+=5; - filelist=rrealloc(filelist,listsize*sizeof(char*)); - } - filelist[filecnt]=rstrdup(entry->d_name); - i=strlen(entry->d_name); - if (i>screen_width-1) { - filelist[filecnt][screen_width-1]=0; - i=screen_width-1; - } - if (i>maxleng) maxleng=i; - filecnt++; - } - } while (entry!=NULL); - closedir(currdir); - if (filecnt==0) return; /* No files */ - - numcols=(screen_width-1)/(maxleng+2); /* Two spaces between columns */ - if (numcols<1) - numcols=1; - height=(filecnt+numcols-1)/numcols; /* Height, rounded up. */ - - writeln(""); - writestr("Existing ");writestr(type);writestr("files:"); - for(i=0;ispecial) - f=writeopen(fc,ext,NULL,&errstr); - else -#endif - { - if (fileexist(fc,ext) && ext!=fSCR) { - if (!yesno("This file already exists; overwrite?")) - /* That is, DON'T overwrite */ - return badfile(ext); - } - f=writeopen(fc,ext,NULL,&errstr); - } - } else - f=readopen(fc,ext,&errstr); - if (errstr!=NULL) writeln(errstr); - return f; -} - -static fc_type last_save=NULL; -static fc_type last_log=NULL; -static fc_type last_script=NULL; - - -genfile get_user_file(int ft) -/* ft= 0:script, 1:save 2:restore, 3:log(read) 4:log(write) */ -/* Should return file in open state, ready to be read or written to, - as the case may be */ -{ - /* int extlen;*/ - rbool rw; /* True if writing, false if reading */ - filetype ext; - genfile fd; - fc_type def_fc, fc; - char *fname; - char *ftype; - char *p,*q; - - switch (ft) { - case 0: ftype="script "; - def_fc=last_script; - rw=1;ext=fSCR; break; - case 1: ftype="save "; - def_fc=last_save; - rw=1;ext=fSAV;break; - case 2: ftype="restore "; - def_fc=last_save; - rw=0;ext=fSAV;break; - case 3: ftype="log "; - def_fc=last_log; - rw=0;ext=fLOG;break; - case 4: ftype="log "; - def_fc=last_log; - rw=1;ext=fLOG;break; - default: writeln(""); - return badfile(fSAV); - } -#ifdef UNIX_IO - if (!rw) { /* List available files. */ - list_files(ftype,ext); - ftype=NULL; - } else -#else - writestr(" "); -#endif - writestr("Enter "); - if (ftype!=NULL) writestr(ftype); - writestr("file name"); - if (def_fc!=NULL) { - char *s; - s=formal_name(def_fc,ext); - writestr(" ("); - writestr(s); - writestr(")"); - rfree(s); - } - writestr(": "); - - if (PURE_INPUT) agt_textcolor(-1); - fname=agt_input(4); - if (PURE_INPUT) agt_textcolor(-2); - - /* Delete whitespace before and after the file name. */ - for(p=fname;isspace(*p);p++); - if (*p==0) { /* Line is all whitespace; use default if there is one */ - if (def_fc==NULL) { - writeln("Never mind."); - rfree(fname); - return badfile(ext);} - else { - rfree(fname); - fc=def_fc; - } - } else { /* Line is _not_ all whitespace: we have a file name */ - for(q=fname;*p!=0;p++,q++) - *q=*p; - q--; - while(isspace(*q)) q--; - q++; - *q=0; - fc=init_file_context(fname,ext); - } - - fd=uf_open(fc,ext,rw); - - if (!filevalid(fd,ext)) { - if (fc!=def_fc) release_file_context(&fc); - return fd; - } - - switch(ft) - { - case 0: last_script=fc;break; - case 1: last_save=fc; break; - case 2: last_save=fc; break; - case 3: last_log=fc; break; - case 4: last_log=fc; break; - } - if (fc!=def_fc) release_file_context(&def_fc); - return fd; -} - - -void set_default_filenames(fc_type fc) -{ - last_save=convert_file_context(fc,fSAV,NULL); - last_log=convert_file_context(fc,fLOG,NULL); - last_script=convert_file_context(fc,fSCR,NULL); -} - - - -#endif /* REPLACE_GETFILE */ - - - - -void script(uchar onp) -{ - if (onp==script_on) - if (onp==0) writeln("Scripting wasn't on."); - else writeln("Scripting is already on."); - else if (onp==1) { - scriptfile=get_user_file(0); - if (filevalid(scriptfile,fSCR)) script_on=1; - } else if (filevalid(scriptfile,fSCR)) { - if (close_pfile(scriptfile,0)) - rprintf("Script file: %s",strerror(errno)); - scriptfile=BAD_TEXTFILE; - script_on=0; - } -} - - -void logon(void) -{ - if (logflag&1) { - writeln("Already logging"); - return;} - log_out=get_user_file(4); - if (filevalid(log_out,fLOG)) - logflag|=1; -} - -void replay(int delay) -{ - if (logflag&2) return; /* Nested replays are meaningless */ - log_in=get_user_file(3); - if (filevalid(log_in,fLOG)) { - logflag|=2; - logdelay=delay; - } -} - - -/* These two are intended to be called by the platform-dependent - interface (e.g. if the user had chosen these from some general purpose - menu) */ -/* They're never called from the rest of the code */ - -void agt_save(void) -{ - savegame(); -} - -void agt_restore(void) -{ - doing_restore=1; -} - -void agt_restart(void) -{ - doing_restore=2; -} - -void agt_quit(void) -{ - doing_restore=4; -} - - -/* This should be rmalloc'd */ -static fc_type newgame_fc; - -fc_type new_game(void) -{ - return newgame_fc; -} - -void agt_newgame(fc_type fc) -{ - newgame_fc=fc; - doing_restore=3; -} - -static rbool end_cmd_options; - -void set_default_options(void) -{ - init_flags(); - flag=rmalloc(sizeof(rbool)); - debug_parse=0; - DEBUG_AGT_CMD=0; - DEBUG_EXEC_VERB=0; - DEBUG_DISAMBIG=0; - DEBUG_SMSG=0; -} - -void helpmsg(void) -{ - printf("AGiliTy: " - "The (Mostly) Universal AGT Interpreter, "); - printf("%s\n",version_str); - printf(" Copyright (C) 1996-1999,2001 Robert Masenten\n"); - printf("[%s]\n",portstr); - printf("Syntax: agil \n"); - printf("Options:\n"); - printf("(all of these can be turned off by putting a - after the option)\n"); - printf(" -i Try to use IBM character set.\n"); - printf(" -1 IRUN Mode: Print messages in first person\n"); - printf(" -h Print out this message\n"); - printf(" -d Debug metacommand execution\n"); - printf(" -t Test mode; see accompanying documentation. Implies -r.\n"); - printf(" -c Create test file.\n"); - printf(" -m Force descriptions to be loaded from disk.\n"); -#ifdef OPEN_AS_TEXT - printf(" -b Open data files as binary files.\n"); -#endif - printf("\nTechnical options (intended for debugging AGiliTy itself).\n"); - printf(" -p Debug parser\n"); - printf(" -x Debug verb execution loop\n"); - printf(" -a Debug disambiguation system\n"); - printf(" -s Debug STANDARD message handler\n"); -#ifdef MEM_INFO - printf(" -M Debug memory allocation\n"); -#endif -} - - -static rbool setarg(char **optptr) -{ - if ( (*optptr)[1]=='+') {(*optptr)++;return 1;} - if ( (*optptr)[1]=='-') {(*optptr)++;return 0;} - return 1; -} - -#ifdef UNIX -#define fixcase(c) (c) -#else -#define fixcase(c) tolower(c) -#endif - -void parse_options(char *opt,char *next) -{ - if (opt[0]=='-' && opt[1]==0) /* -- */ - {end_cmd_options=1;return;} - for(;*opt!=0;opt++) - switch(fixcase(*opt)) - { - case '?': case 'h': - helpmsg(); - exit(EXIT_SUCCESS); - case 'p': debug_parse=setarg(&opt);break; - case 'a': DEBUG_DISAMBIG=setarg(&opt);break; - case 'd': DEBUG_AGT_CMD=setarg(&opt);break; - case 'x':DEBUG_EXEC_VERB=setarg(&opt);break; - case 's':DEBUG_SMSG=setarg(&opt);break; -#ifdef MEM_INFO - case 'M': DEBUG_MEM=setarg(&opt);break; -#endif - case 'm': descr_maxmem=0; break; - case 'i': fix_ascii_flag=!setarg(&opt);break; - case 't': BATCH_MODE=setarg(&opt); break; - case 'c': make_test=setarg(&opt); break; - case '1': irun_mode=setarg(&opt);break; -#ifdef OPEN_FILE_AS_TEXT - case 'b': open_as_binary=setarg(&opt);break; -#endif - default:printf("Do not recognize option %c\n",*opt); - helpmsg(); - exit(EXIT_FAILURE); - } -} - - -#ifndef REPLACE_MAIN - -#ifdef MSDOS -extern rbool use_bios; -#endif - - -int main(int argc,char *argv[]) -{ - int i; - char *gamefile; -#ifdef MSDOS - rbool biosvar=0; -#endif - - set_default_options(); - end_cmd_options=0; - gamefile=NULL; - for(i=1;i=0 is numerical delay */ -global genfile log_in, log_out; - -global rbool fast_replay; /* If true, don't print MORE prompts. */ - -global rbool sound_on; /* Manipulated by music_cmd; can be used by interface - to determine if a tone should be made */ - -global integer *pictable; /* Used to decode picture numbers */ -global fc_type hold_fc; /* Needed to print instructions on demand */ - -global unsigned short compass_rose; /* Used to pass compass info to - the os layer */ - - -/* -------------------------------------------------------------------- */ -/* Game State */ -/* -------------------------------------------------------------------- */ - -global rbool quitflag, deadflag, winflag, endflag; -global rbool first_visit_flag, newlife_flag, room_firstdesc; - -global rbool start_of_turn; /* True if running the command on the first - noun in the list */ -global rbool end_of_turn; /* True if running command on last noun in - the list. */ - -global rbool actor_in_scope; /* Used to determine if the actor was in - scope when the command was originally - given */ - -global integer loc; /* Player's location */ -global integer player_contents, player_worn; /* Worn and carried objects*/ - -global long totwt, totsize; /* Size and wt player is carrying around */ - -global integer curr_lives; /* Number of lives left. */ - -global long tscore, old_score; /* Total score */ -global long objscore; /* Portion of tscore that comes from the POINTS - field of nouns and creatures. */ - -global integer turncnt; /* Number of turns that have passed */ -global integer curr_time; /* The time in the game; in the format - 1243==12:43 */ - -global rbool *flag; /* AGT Flags */ -global short *agt_counter; /* AGT counters */ -#ifdef AGT_16BIT -global short *agt_var; /*AGT variables */ -#else -global long *agt_var; -#endif - -global long agt_number; /* The number entered by the player */ -global rbool agt_answer; /* Did the player get the answer to the last question - right? */ - -global tline l_stat, r_stat; /* Left and right parts of status line */ - /* If r_stat is the empty string, l_stat should be - centered to create a Trinity-like status line */ - -global rbool nomatch_aware; /* Does the game use the nomatch extension - to the metacommand format? - (which allow and ANY to be - distingused) */ - -global rbool smart_look; /* If true, then LOOK will be converted - to EXAMINE. This is set automatically in agil.c, - based on whether the game file uses - LOOK in any of the metacommands; if it - does, then smart_look is set to 0. */ - -/* -------------------------------------------------------------------- */ -/* Menu data structures */ -/* -------------------------------------------------------------------- */ - -#define MENU_WIDTH 50 -typedef char menuentry[MENU_WIDTH]; - -global int vm_width; /* Width of widest element */ -global menuentry *verbmenu; - - - -/* -------------------------------------------------------------------- */ -/* Parser Data Structures */ -/* This also includes "parser-related" variables like dobj and iobj */ -/* -------------------------------------------------------------------- */ - -/* This extracts the object number from a parse rec */ -#define p_obj(objrec) ((objrec) ? (objrec)->obj : 0) - -/* The following data structures are used for disambiguation of nouns */ -typedef struct { - long num; /* Numeric value of object; 0 if object doesn't have one */ - int obj; /* Object number; negative values point into the dictionary */ - int info; /* Disambiguation info */ - /* -1=last record; ignore obj field. */ - word noun, adj; /* Used for printing out error messages */ - short score; /* Disambiguation score */ -} parse_rec; /* Stores objects that have been found during parse */ - - -/* In an ideal world, the following would all be local variables. */ -/* Unfortunately, they're used in too many different places for this - to be practical */ - -global int vb; -global integer actor, dobj, iobj; -global parse_rec *actor_rec, *dobj_rec, *iobj_rec; -global word prep; -global parse_rec *curr_creat_rec; - /* Creature currently behaving in a hostile way: - used to fill in $c_name$ messages */ - -global int disambig_score; /* Used to rank objects during disambiguation */ - -#define DISAMBIG_SUCC 1000 /* Score given to an object that triggers a - built-in verb or an action token */ - - -#define MAXINPUT 200 /* Max number of words input */ - -global word input[MAXINPUT]; /* 200 words of input should be enough */ -global words in_text[MAXINPUT]; - /* The corrospoinding strings, for error reporting purposes */ - -global short ip,ep; /* input pointer and error pointer */ -global short ap,vp,np,pp,op; /* Points to first word in actor, verb, noun, - and object resp. */ - - - -/* The following needs to be kept consistant with ext_voc[] in - agil.c */ -typedef enum{wthe,wmy,wa,wan,wthen,wp,wsc,wand,wc,wits,wall,wundo,wlook,wg, - wpick,wgo,wexits,wtalk,wtake,wdoor,wagain,wbut,wexcept, - wscene,weverything,wlistexit,wlistexits,wclose, - wdverb,wdnoun,wdadjective,wdprep,wdobject,wdname, - wstep,w_any,weither,wboth,weveryone,weverybody, - whe,wshe,wit,wthey,whim,wher,wthem,wis,ware,woops, - wwas, wwere, - win,wout,winto,wat,wto,wacross,winside,wwith,wnear,wfor, - wof,wbehind,wbeside,won,woff,wunder,wfrom, wthrough, - wtoward, wtowards, wbetween, waround, wupon, wthru, - wby, wover, wup, wdown, - wabout} wtype; -global word ext_code[wabout+1]; /* Codes for the above */ -global short last_he, last_she, last_it, last_they; - /* Used for pronoun support */ - - - -/* -------------------------------------------------------------------- */ -/* Noun List Data structures and constants */ -/* -------------------------------------------------------------------- */ - - -/* The following are used in noun lists */ -#define AND_MARK (-ext_code[wand]) -#define ALL_MARK (-ext_code[wall]) - -#define D_END 50 /* Marks end of disambiguation list */ -#define D_AND 51 /* Used to seperate multiple objects during disambig */ -#define D_NOUN 0 /* Noun match */ -#define D_SYN 1 /* Adjective/synonym only match */ -#define D_ADJ 2 /* Adj only match */ -#define D_FLAG 3 /* Flag noun */ -#define D_GLOBAL 4 /* Global noun */ -#define D_PIX 5 /* PIX name */ -#define D_PRO 6 /* Pronoun */ -#define D_ALL 7 /* ALL, or a header to an ALL EXCEPT _ AND _ ... list */ -#define D_INTERN 8 /* Internal nouns: DOOR, SCENE */ -#define D_NUM 9 /* A number, value is in obj */ -#define D_EITHER 10 /* EITHER or ANY, used only to resolve disambiguation */ - -#define D_MARK 0x80 /* Used as a temporary marker, usually to indicate - this noun is being considered for elimination */ - - - -/* -------------------------------------------------------------------- */ -/* These are used for text boxes (quotes and the title) */ -/* -------------------------------------------------------------------- */ -#define TB_TTL 1 /* We're printing the title */ -#define TB_BOLD 2 /* Print it bold */ -#define TB_BORDER 4 /* Give it a border */ -#define TB_CENTER 8 /* Center the text inside */ -#define TB_NOCENT 16 /* Don't center the whole box */ - - -/* -------------------------------------------------------------------- */ -/* In AGIL.C */ -/* -------------------------------------------------------------------- */ -void print_instructions(fc_type fc); -void run_game(fc_type fc); - -/* -------------------------------------------------------------------- */ -/* In PARSER.C */ -/* -------------------------------------------------------------------- */ -rbool parse(void); /* Returns true unless there is ambiguity */ -void menu_cmd(void); - - -/* -------------------------------------------------------------------- */ -/* In EXEC.C */ -/* -------------------------------------------------------------------- */ - -/* Legal values for gen_sysmsg context; they indicate who is calling it */ -#define MSG_PARSE 0 /* The parser */ -#define MSG_MAIN 1 /* The main execution loop */ -#define MSG_RUN 2 /* The routines that execute the player's commands */ -#define MSG_DESC 3 /* Printing out description. */ - -void gen_sysmsg(int msgid,char *s,int context,const char *pword); -/* Prints either STANDARD message or default msg ; - determines what $$ substitutions are meaningful - gives the $pword$ substitution for MSG_PARSE messages */ - -void exec(parse_rec *actor,int vnum, parse_rec *lnoun, - word prep, parse_rec *iobj); -void set_statline(void); -void newroom(void); -void print_descr(descr_ptr dp,rbool nl); -void quote(int msgnum); -void print_score(void); -long read_number(void); - - -/* -------------------------------------------------------------------- */ -/* In TOKEN.C */ -/* -------------------------------------------------------------------- */ -void init_stack(void); /* Set up expression stack */ -void clear_stack(void); /* Set stack back to empty state */ - -/* -------------------------------------------------------------------- */ -/* In OBJECT.C */ -/* -------------------------------------------------------------------- */ -rbool player_has(int item); -rbool visible(int item); -rbool genvisible(parse_rec *dobj); -int *get_nouns(void); /* Returns list of in scope nouns */ -void add_object(int loc, int item); /* Adds item to loc's contents list */ -void tmpobj(parse_rec *objrec); -void compute_scope(void); /* Sets scope flags for all of the objects */ -void compute_seen(void); /* Determine HAS_SEEN flag for nouns and creatures */ - -void init_creat_fix(void); -void free_creat_fix(void); - -/* ------------------------------------------------------------------- */ -/* The following are intended as building blocks to construct macros */ -/* to extract information about general objects, regardless of whether */ -/* they are nouns, creatures, or virtual nouns with no associated */ -/* data structure. */ -/* ------------------------------------------------------------------- */ -/* nounattr(item,attr) -- returns 0 if not noun. - creatattr(item,attr) -- returns 0 if not creature - objattr(item,attr) -- Returns attribute for noun or creature, 0 otherwise - anyattr(item,attr) -- Returns attribute for noun, creature, or room, - 0 otherwise. -*/ - -#define creatattr2(item,attr,op3) (tcreat(item)? \ - creature[(item)-first_creat].attr:\ - (op3)) -#define creatattr(item,attr) creatattr2(item,attr,0) -#define nounattr2(item,attr,alt) (tnoun(item)? \ - noun[(item)-first_noun].attr:(alt)) -#define nounattr(item,attr) nounattr2(item,attr,0) -#define objattr(item,attr) nounattr2(item,attr,creatattr(item,attr)) -#define objattr2(item,attr,op3) nounattr2(item,attr,creatattr2(item,attr,op3)) -#define roomattr2(item,attr,op3) (troom(item)?\ - room[(item)-first_room].attr:(op3)) -#define anyattr(item,attr) roomattr2(item,attr,objattr(item,attr)) - -#define it_scratch(item) objattr(item,scratch) -#define it_loc(item) objattr2(item,location,\ - (tdoor(item)) ? loc+first_room : 0) - - -/* -------------------------------------------------------------------- */ -/* In RUNVERB.C */ -/* -------------------------------------------------------------------- */ -int check_obj(parse_rec *act, int verbid, - parse_rec *donum, word prep, parse_rec *ionum); - - -/* -------------------------------------------------------------------- */ -/* In AGTDBG.C */ -/* -------------------------------------------------------------------- */ -void debug_cmd_out(int,int,int,int,int); -void debug_head(int); -void debug_newline(integer op, rbool first_nl); - -/* -------------------------------------------------------------------- */ -/* In SAVEGAME.C */ -/* -------------------------------------------------------------------- */ -void savegame(void); -rbool loadgame(void); -void init_state_sys(void); /* Must be called before either of the following */ -uchar *getstate(uchar *gs); - /* Returns malloc'd block containing game state. */ -void putstate(uchar *gs); /* Restores games state. */ -void init_vals(void); /* Compute dependent variables - such as totwt, totsize, etc. */ -void restart_game(void); - - -/* -------------------------------------------------------------------- */ -/* In OS_.C */ -/* -------------------------------------------------------------------- */ -global volatile int screen_width, status_width; -global int screen_height; -global volatile int curr_x; - -void init_interface(int argc,char *argv[]); -void start_interface(fc_type fc); -void close_interface(void); -char *agt_input(int in_type); /* read line, return malloc'd string */ -char agt_getkey(rbool echo_char); -void agt_clrscr(void); -void agt_textcolor(int c); -void agt_delay(int n); /* n in seconds */ -int agt_rand(int a,int b); /* Return random number from a to b, inclusive */ -void agt_newline(void); -void agt_puts(const char *s); /* Output string */ -void agt_statline(const char *s); /* Prints s out on status line */ -void agt_tone(int hz,int ms); -void agt_makebox(int width,int height,unsigned long flags); -void agt_qnewline(void); -void agt_endbox(void); -genfile agt_globalfile(int fid); /* When fid=0, return global config file */ -rbool agt_option(int optnum,char *optstr[],rbool setflag); - -/* These have stubs defined in interface.c that would ened to be - commented out if you actually wanted to support these */ -void fontcmd(int cmd,int font); /* fontlist[font] */ -void pictcmd(int cmd,int pict); /* pictlist[pict] or pixlist[pict] */ -int musiccmd(int cmd,int song); /* songlist[song] */ - - -/* -------------------------------------------------------------------- */ -/* In INTERFACE.C */ -/* -------------------------------------------------------------------- */ -/* init_interface() (in os_?????.c) is responsible for initializing these */ -global rbool par_fill_on, center_on; -global rbool textbold; /* Is the text currently bold? */ - -void wait_return(void); -void agt_waitkey(void); - -void agt_center(rbool b); /* 1=turn on text centering, 0=turn off */ -void agt_par(rbool b); /* 1=turn on "paragraph" mode, 0=turn off */ -char *agt_readline(int in_type); /* Front end for agt_input */ -char agt_getchar(void); /* Front end for some uses of agt_getkey */ -void prompt_out(int); /* 1=standard prompt, 2=question prompt */ -genfile get_user_file(int ft); /* 0=script, 1=save, 2=restore */ -void set_default_filenames(fc_type fc); -void script(uchar); /* 0=turn off, 1=turn on */ -void logon(void); /* Turn on logging */ -int close_pfile(genfile f, int ft); /* ft is the same as for get_user_file */ -void replay(int delay); /* REPLAY */ -rbool yesno(const char*); -void textbox(char *(txt[]),int len,unsigned long flags); -void padout(int padleng); /* Outputs padleng spaces */ -int agt_menu(char *header,int size,int width,menuentry *menu); -fc_type new_game(void); - -void set_test_mode(fc_type fc); - /* This sets up scripting and replaying for testing mode */ - -/* These are intended to be called by the os layer */ -void print_statline(void); - -void agt_save(void); -void agt_restore(void); -void agt_restart(void); -void agt_quit(void); -void agt_newgame(fc_type fc); - -/* -------------------------------------------------------------------- */ -/* Object manipulation macros */ -/* -------------------------------------------------------------------- */ -#define objloop(i) for(i=first_noun; i<=maxnoun || i<=maxcreat; \ - (i<=maxnoun || i>=first_creat) ? (i++) : (i=first_creat) ) -#define nounloop(i) for(i=0;i<=maxnoun-first_noun;i++) -#define creatloop(i) for(i=0;i<=maxcreat-first_creat;i++) - -#define tdoor(x) ((x)==-ext_code[wdoor]) - -#ifdef uagt_defined_global -#undef global -#undef uagt_define_global -#endif - - - diff --git a/app/src/main/jni/terps/agility/linux_pict b/app/src/main/jni/terps/agility/linux_pict deleted file mode 100755 index 1e1ad7d..0000000 --- a/app/src/main/jni/terps/agility/linux_pict +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -# This is a script for viewing files, invoked by AGiliTy -# -# Customize as needed for your platform and preferred graphics file viewers -# -# For X-windows, it uses xv and xanim. -# If X-Windows isn't running, it uses flip and zgv. -# AFAIK all of these programs can all be found at sunsite. -# -# If any of these send anything to stderr, they may confuse -# AGiliTy's screen routines (Ctrl-L should put everything right). -# AGiliTy doesn't redirect stderr because some svgalib programs won't -# run correctly if stderr doesn't point at a "real" screen. -# -# One problem is that some viewers use file name extensions to identify -# file type, and AGT uses nonstandard extensions for PCX files. -# (".P06", ".P13", ".P16", etc.) -# - -if [ "$DISPLAY" = "" ]; then -# Put your non-X PCX file viewer here, if you have one. -# It has to be able to run with stdout redirected, though - case $1 in - *.fl[ic] ) flip $1;; - *.pcx ) grav $1;; - *.p[0-9][0-9]) # Alternative PCX file names - # This is not as careful as it should be - tmpname=/tmp/agilpict-$PPID-$RANDOM.pcx - ln -s $PWD/$1 $tmpname - grav $tmpname - rm $tmpname;; -## echo "PCX files not supported.";; - * ) zgv $1;; - esac -else -# You can replace the next line with the X-windows viewer of your choice. - case $1 in - *.fl[ic] ) xanim $1 2>/dev/null &;; - * ) xv $1 2>/dev/null &;; - esac -fi - diff --git a/app/src/main/jni/terps/agility/metacommand.c b/app/src/main/jni/terps/agility/metacommand.c deleted file mode 100644 index 70bca21..0000000 --- a/app/src/main/jni/terps/agility/metacommand.c +++ /dev/null @@ -1,1106 +0,0 @@ -/* metacommand.c-- handles metacommand execution */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for the AGiliTy */ - -/* This contains the code for scanning and running metacommands. - Note that while the code here deals with all of the flow-of-execution - details, the code for executing individual tokens is actually - in token.c (With a few exceptions for commands that impact - the order of execution). */ - - -#include -#include -#include - -#include "agility.h" -#include "interp.h" -#include "exec.h" - -#define DEBUG_SCAN 1 - -#define MAX_REDIR 50000L /* Maximum number of redirects, to catch - infinite loops. If this is 0, allow infinitely - many */ - -#define MAX_SUBCALL 2047 /* Maximum number of subroutine calls. - If this is 0, no limit (except for the - program's stack size). */ - - -/* - -scan_metacommand - -2=end of cycle, something happened (disambiguation only) - 0=end of this cycle (disambig: end of cycle, nothing happened) - 1=end of all commands (disambig: end of cycle, nothing happened) - 2=end of turn (disambig: nothing happened) - -run_metacommand - 0 to go on to next metacommand, - 1 to stop running metacommands, and - 2 to end the turn. - 3 indicates that redirection has just occured - 4 indicates a subcall has just occured. - 5 to go on to next metacommand after a return has occured. - -2 means we're doing disambiguation and just hit an action token. - -*/ - - -/* ====================================================================*/ -/* RUN METACOMMAND: The following are the routines used to execute */ -/* a single metacommand block. run_metacommand is invoked by */ -/* scan_metacommand, which is further down in this file. */ -/* ====================================================================*/ - -/* ------------------------------------------------------------------- */ -/* TYPE CHECKING ROUTINES */ -/* Routines used to do type checking for metacommands. */ -/* ------------------------------------------------------------------- */ - - -rbool argvalid(int argtype,int arg) -{ - if (argtype&AGT_VAR) { /* We have a variable */ - /* First, verify that arg actually indexes a variable */ - if (arg<0 || arg>VAR_NUM) return 0; /* Nope */ - - if (argtype==AGT_VAR) return 1; /* Pure variable; contents don't matter */ - - /* Next, verify its contents, using the rest of this routine */ - arg=agt_var[arg]; - argtype&=~AGT_VAR; /* Mask off AGT_VAR */ - } - - if (argtype<128) { - if (tnoun(arg)) return (argtype&AGT_ITEM)!=0; - if (troom(arg)) return (argtype&AGT_ROOM)!=0; - if (arg==0) return (argtype&AGT_NONE)!=0; - if (arg==1) return (argtype&AGT_SELF)!=0; - if (tcreat(arg)) return (argtype&AGT_CREAT)!=0; - if (arg==1000) return (argtype&AGT_WORN)!=0; - return 0; - } - else switch(argtype) - { - case AGT_NUM:return 1; - case AGT_DIR:return (arg>=1 && arg<=12); - case AGT_FLAG:return (arg>=0 && arg<=FLAG_NUM); - case AGT_CNT:return (arg>=0 && arg<=CNT_NUM); - case AGT_QUEST:return (arg>=1 && arg<=MaxQuestion); - case AGT_MSG:return (arg>=1 && arg<=last_message); - case AGT_ERR:return (arg>=1 && arg<=NUM_ERR); - case AGT_STR:return (arg>=1 && arg<=MAX_USTR); - case AGT_SUB:return (arg>=1 && arg<=MAX_SUB); - case AGT_PIC:return (arg>=1 && arg<=maxpict); - case AGT_PIX:return (arg>=1 && arg<=maxpix); - case AGT_FONT:return (arg>=1 && arg<=maxfont); - case AGT_SONG:return (arg>=1 && arg<=maxsong); - case AGT_ROOMFLAG:return (arg>=1 && arg<=32); - case AGT_EXIT: return ( argvalid(AGT_ROOM|AGT_NONE,arg) - || argvalid(AGT_MSG,arg-exitmsg_base) - || (arg<0 && aver>=AGX00) ); /* Treat as verb */ - case AGT_OBJFLAG: return (arg>=0 && arg=0 && arg is set true for NOUN, OBJECT, NAME variables that are 0 */ -/* (In this case, some error handling is suppressed) */ - -static rbool argfix(int argtype, int *arg, int optype, rbool *special) -{ - *special=0; - switch(optype) - { - case 0:break; /* Direct: The easy case */ - case 1: /* Variable */ - if (*arg==-1) { /* Top-of-stack */ - *arg=pop_expr_stack(); - break; - } - if (!argvalid(AGT_VAR,*arg)) return 0; - *arg=(int)agt_var[*arg]; - break; - case 2: *arg=dobj; *special=(dobj==0); break; /* NOUN */ - case 3: *arg=iobj; *special=(iobj==0); break; /* OBJECT */ - default: rprintf("Internal error: Invalid optype."); - return 0; - } - if (!(optype&2)) { - /* i.e. we have direct or variable type */ - /* The noun and object types below are useless for direct use, - but may be useful when used as values of variables. */ - if (argtype<64) { - if (*arg==-1) /* NAME */ - {*arg=actor; *special=(actor==0);} - else if (*arg==-2) /* NOUN */ - {*arg=dobj; *special=(dobj==0);} - else if (*arg==-3) /* OBJECT */ - {*arg=iobj; *special=(iobj==0);} - } - } - return argvalid(argtype,*arg); -} - - -/* These are handled in the order ARG2 then ARG1 so that - top-of-stack references will pop the stack in that order - (so that the push-order will corrospond to the argument order) */ -/* is true if "bad" argument is NOUN/OBJECT/etc. and - is 0. */ -static int argok(const opdef *opdata,int *arg1,int *arg2, int optype, - rbool *grammer_arg) -{ - if ( (opdata->argnum)>1 && !argfix(opdata->arg2,arg2,optype%4,grammer_arg) ) - return 0; - if ( (opdata->argnum)>0 && !argfix(opdata->arg1,arg1,optype/4,grammer_arg) ) - return 0; - return 1; -} - -/* ------------------------------------------------------------------- */ -/* INSTRUCTION DECODING ROUTINES */ -/* Routines for decoding opcodes and their arguments */ -/* ------------------------------------------------------------------- */ - -static int decode_instr(op_rec *oprec, const integer *data, int maxleng) -{ - integer op; - int optype; - int leng; - rbool special_arg1; /* Is the first argument a special 0-length argument? */ - - oprec->negate=oprec->failmsg=oprec->disambig=0; - oprec->errmsg=NULL; - oprec->op=-1; - oprec->opdata=&illegal_def; - oprec->argcnt=0; - oprec->endor=1; - - special_arg1=0; - - if (maxleng<=0) { - oprec->errmsg="GAME ERROR: Unexpected end of token sequence."; - return 1; - } - op=data[0]; - if (op<0) { - oprec->errmsg="GAME ERROR: Negative token found."; - return 1; - } - oprec->optype=optype=op/2048; /* Split op into operand proper and optype */ - oprec->op=op=op%2048; - oprec->opdata=get_opdef(op); - - if (oprec->opdata==&illegal_def) { - if (operrmsg="GAME ERROR: Illegal condition token encountered."; - else - oprec->errmsg="GAME ERROR: Illegal action token encountered."; - return 1; - } - - if (op<1000) oprec->endor=0; /* Conditional tokens don't end OR block */ - - /* Recall that oprec->disambig is initialized to 0 */ - switch(op) - { - case 89: case 95: case 96: case 97: - oprec->disambig=1; break; /* YesNo and Chance */ - case WIN_ACT: case WIN_ACT+1: - oprec->disambig=1; break; /* WinGame, EndGame */ - - case 1037: case 1038: /* DoSubroutine, Return */ - case 1062: case 1115: /* RedirectTo, SetDisambigPriority */ - case 1132: /* AND */ - case 1149: case 1150: /* Goto and OnFailGoto */ - case 1151: /* EndDisambig */ - case 1152: /* XRedirect */ - break; /* Accept default of 0: these tokens don' trigger disambig */ - - case 1135: case 1137: case 1138: case 1139: case 1140: - case 1141: case 1142: case 1143: case 1147: case 1159: - oprec->endor=0; - break; /* Operations that only affect the stack don't - stop disambiguation, either. They also - don't mark the end of an OR block */ - - default: - /* Aside from the above exceptions, all actions will stop - disambiguation (with success) and all conditions will let it - continue. */ - oprec->disambig=(op>=START_ACT && op=1128 && op<=1131) /* FailMessage group */ - oprec->failmsg=1; - - leng=oprec->opdata->argnum+1; - if (optype!=0) { /* Correct leng for NOUN and OBJECT args */ - special_arg1= ((optype&8)==8); - leng-= special_arg1 + ((optype&2)==2); - if (leng<1) { - oprec->errmsg="GAME ERROR: Token list corrupted."; - return 1; - } - } - if (leng>maxleng) { - oprec->errmsg="GAME ERROR: Unexpected end of token sequence"; - return 1; - } - - if (op==108) { /* NOT */ - leng=1+decode_instr(oprec,data+1,maxleng-1); - oprec->negate=!oprec->negate; - return leng; - } - oprec->argcnt=leng-1; - oprec->arg1=oprec->arg2=0; - if (leng>=2) { - if (special_arg1) { - assert(leng==2); - oprec->arg2=data[1]; - oprec->arg1=0; - } else oprec->arg1=data[1]; - } - if (leng>=3) oprec->arg2=data[2]; - if (leng>=4) writeln("INTERNAL ERROR: Too many token arguments."); - return leng; -} - - -/* decode_args checks and decodes the arguments to metacommand tokens */ -/* Returns false on an error */ -static rbool decode_args(int ip,op_rec *oprec) -{ - rbool grammer_arg; /* Have NOUN/OBJECT that is 0 and so failed argok tests */ - - if (oprec->errmsg!=NULL) { - if (!PURE_ERROR) - writeln(oprec->errmsg); - return 0; - } - if (DEBUG_AGT_CMD && !supress_debug) { - if (oprec->negate) { /* Output NOT */ - debug_cmd_out(ip,108,0,0,0); - ip++; - } - } - - if (DEBUG_AGT_CMD && !supress_debug) - debug_cmd_out(ip,oprec->op,oprec->arg1,oprec->arg2,oprec->optype); - - /* This checks and translates the arguments */ - if (!argok(oprec->opdata,&(oprec->arg1),&(oprec->arg2), - oprec->optype,&grammer_arg)) { - /* Don't report errors for null NOUN/OBJECT/ACTOR arguments - used in conditional tokens */ - if (grammer_arg && oprec->op<=MAX_COND) - return 0; - if (!PURE_ERROR) { - if (DEBUG_AGT_CMD && !supress_debug) debugout("\n"); - writeln("GAME ERROR: Invalid argument to metacommand token."); - } - return 0; - } - return 1; -} - - - - -/* ------------------------------------------------------------------- */ -/* Subroutine Call Stack routines */ -/* ------------------------------------------------------------------- */ -/* Note: run_metacommand() passes subroutine calls up to it's parent, - but it processes Returns on its own (and is the routine responsible - for maintaining the subcall stack-- scan_metacommand treats - a subroutine call just like RedirecTo) */ -/* The progression for subroutine calls goes like this: - run_metacommand hits a DoSubroutine token; - the subroutine id is saved in subcall_arg by exec_token. - run_metacommand does push_subcall, saving cnum and ip, - and then returns 4 to scan_metacommand. - scan_metacommand saves grammar state to the new stack entry - with push_subcall and then starts scanning SUBROUTINEnn - - Many tokens are executed. - - run_metacommand hits Return. It sets restart_state and - returns 5 to its parent. - scan_metacommand then runs pop_subcall_grammar and restores - the original scanning grammer. It subtracts one from cnum - so the original cnum will be rerun. - run_metacommand sees that restart_state is set and pops the - rest of the information (cnum and ip) off of the stack. - Things continue as usual. - */ - - - -typedef struct { - /* run_metacommand state */ - short cnum, ip, failaddr; - /* scan_metacommand state */ - integer mactor, mdobj, miobj; - word mprep; - short vcode; - /* Global state (is this really saved?) */ - short vb; - word prep; -} subcall_rec; - - -static subcall_rec *substack=NULL; -static short subcnt=0; -static short subsize=0; - - -static rbool push_subcall(int cnum, int ip, int failaddr) -{ - subcall_rec *savestack; /* In case something goes wrong. */ - - if (MAX_SUBCALL!=0 && ++subcnt>MAX_SUBCALL) - return 0; - if (subcnt>subsize) { - subsize+=5; - savestack=substack; - rm_trap=0; - substack=rrealloc(substack,subsize*sizeof(subcall_rec)); - rm_trap=1; - if (substack==NULL) { /* out of memory */ - substack=savestack; - return 0; - } - } - substack[subcnt-1].cnum=cnum; - substack[subcnt-1].ip=ip; - substack[subcnt-1].failaddr=failaddr; - return 1; -} - - -/* pop_subcall_grammar is called before this */ -static void pop_subcall(int *rcnum, int *rip, int *rfailaddr) -{ - assert(*rcnum==substack[subcnt-1].cnum); - /* *rcnum=substack[subcnt-1].cnum; */ - *rip=substack[subcnt-1].ip; - *rfailaddr=substack[subcnt-1].failaddr; - subcnt--; -} - -/* This is called after push_subcall */ -static void push_subcall_grammar(int m_actor,int vcode,int m_dobj,word m_prep, - int m_iobj, int cnum) -{ - /* run_metacommand should already have pushed cnum on the stack */ - substack[subcnt-1].vb=vb; - substack[subcnt-1].prep=prep; - substack[subcnt-1].mactor=m_actor; - substack[subcnt-1].vcode=vcode; - substack[subcnt-1].mdobj=m_dobj; - substack[subcnt-1].mprep=m_prep; - substack[subcnt-1].miobj=m_iobj; -} - -/* Return false if something goes wrong-- such as stack underflow. */ -/* This is called *before* pop_subcall */ -static rbool pop_subcall_grammar(integer *m_actor,int *vcode, - integer *m_dobj,word *m_prep,integer *m_iobj, - int *cnum) -{ - if (subcnt==0) return 0; - vb=substack[subcnt-1].vb; - prep=substack[subcnt-1].prep; - *cnum=substack[subcnt-1].cnum; - *m_actor=substack[subcnt-1].mactor; - *vcode=substack[subcnt-1].vcode; - *m_dobj=substack[subcnt-1].mdobj; - *m_prep=substack[subcnt-1].mprep; - *m_iobj=substack[subcnt-1].miobj; - return 1; -} - - - - -/* ------------------------------------------------------------------- */ -/* Run Metacommand */ -/* ------------------------------------------------------------------- */ - -static int run_metacommand(int cnum, int *redir_offset) -/* cnum=command number to run. */ -/* *redir_offset=offset of redirect header, if we exit with redirection. */ -/* Return - 0 to go on to next metacommand, - 1 to stop running metacommands, and - 2 to end the turn. - 3 indicates that redirection has just occured - 4 indicates a subcall has just occured. - 5 Is used to go on to the next metacommand after a Return. - -2 means we're doing disambiguation and just hit an action token. */ -{ - int ip, oip; /* ip=Instruction pointer, oip=Old instruction pointer */ - int r; /* Used to hold return value from token execution */ - int fail_addr; /* What address to jump to on failure */ - rbool fail; /* Last token was a conditional token that failed */ - rbool ortrue, blocktrue, orflag; /* OR stuff - orflag: Are we in an OR group? - ortrue: Is current OR group true? - blocktrue: Is current block w/in OR true? - */ - static rbool restart=0; /* Restarting after subroutine? */ - op_rec currop; /* Information on the current token and its args */ - - fail_addr=32000; /* Fall off the end when we fail */ - fail=0; - ip=0; - orflag=blocktrue=ortrue=0; - *redir_offset=1; /* Default: This is what RedirectTo does. - Only XRedirect can send a different value */ - - - if (restart) /* finish up Return from subroutine */ - pop_subcall(&cnum,&ip,&fail_addr); - - if (DEBUG_AGT_CMD && !supress_debug) { - debug_head(cnum); - if (restart) debugout(" (Resuming after subroutine)\n"); - } - - restart=0; - - - /* ========== Main Loop ================= */ - while(ip Call\n"); - return 4; - } - - if (currop.op==1038) { /* Return */ - restart=1; - if (DEBUG_AGT_CMD && !supress_debug) debugout("--> Return\n"); - return 5; - } - - if (currop.op==1149) { /* Goto */ - ip=currop.arg1; - if (DEBUG_AGT_CMD && !supress_debug) debugout("\n"); - continue; - } - - if (currop.op==1150) { /* OnFailGoto */ - fail_addr=currop.arg1; - if (DEBUG_AGT_CMD && !supress_debug) debugout("\n"); - continue; - } - - if (currop.op==1152) /* XRedirect */ - *redir_offset=currop.arg1; - - /* ---------- Disambiguation Success -------------- */ - if (do_disambig && currop.disambig) { - if (DEBUG_AGT_CMD && !supress_debug) debugout("==> ACTION\n"); - return -2; - } - - /* ---------- Run normal metacommands -------------- */ - switch(r=exec_instr(&currop)) - { - case 0: /* Normal action token or successful conditional token */ - if (DEBUG_AGT_CMD && !supress_debug) debug_newline(op,0); - continue; - case 1: /* Conditional token: fail */ - if (DEBUG_AGT_CMD && !supress_debug) { - if (orflag) debugout(" (-->FAIL)\n"); - else debugout("--->FAIL\n"); - } - fail=1; - continue; - default: /* Return explicit value */ - if (DEBUG_AGT_CMD && !supress_debug) { - if (r==103) debugout("-->Redirect\n"); - else debugout("==> END\n"); - } - return r-100; - } - } - return 0; -} - - - -/* ====================================================================*/ -/* SCAN METACOMMAND: These are the routines that scan through the */ -/* metacommand headers and find the appropriate ones to execute */ -/* Redirection is also handled at this level */ -/* ====================================================================*/ - - -/* ------------------------------------------------------------------- */ -/* Support routines for extracting object information */ -/* ------------------------------------------------------------------- */ - -/* For $ strings. Returns object number if there is one, or negative - the dictionary index. - This is used by the metacommand redirection routines */ - -static integer expand_redirect(word w) -{ - assert(w!=-1); /* <*NONE*> object shouldn't make it this far */ - if (w==0 || aver */ - return 0; - - obj=expand_redirect(name); - adj=it_name(expand_redirect(adj)); - - if (obj>0) { /* $noun$, $object$, or $name$ */ - if (adj==0 || adj==it_adj(obj)) - return obj; /* We're done */ - name=it_name(obj); - } else - name=-obj; - - if (adj==0) return -name; /* Adjectives required for CLASS redirect */ - nounloop(i) - if (noun[i].name==name && noun[i].adj==adj) return i+first_noun; - creatloop(i) - if (creature[i].name==name && creature[i].adj==adj) - return i+first_creat; - /* Hmm... just hope it's an internal noun. */ - writeln("GAME ERROR: Redirect statement with bad object name."); - return -name; -} - - -/* ------------------------------------------------------------------- */ -/* Redirection Routines */ -/* ------------------------------------------------------------------- */ - - -#define wordcode_fix(w) it_name(expand_redirect(w)); - -/* 'real_obj' below is the dobj_obj/iobj_obj field; it takes - precedence over anything else if it is nonzero. - It represents an *explicitly* declared object in - the header */ - -static void fix_objnum(integer *objnum, word match, - int real_obj, - int actor, int dobj, int iobj) -{ - if (real_obj) *objnum=real_obj; - else if (match==ext_code[wdobject]) *objnum=iobj; - else if (match==ext_code[wdnoun]) *objnum=dobj; - else if (match==ext_code[wdname]) *objnum=actor; -} - -/* Returns TRUE if we changed *objrec, FALSE otherwise */ -/* (This is needed for memory allocation purposes) */ -static rbool fix_objrec(parse_rec **objrec, word match, - int real_obj, - parse_rec *actrec, parse_rec *dobjrec, - parse_rec *iobjrec) -{ - if (real_obj) *objrec=make_parserec(real_obj,NULL); - else if (match==ext_code[wdobject]) *objrec=copy_parserec(iobjrec); - else if (match==ext_code[wdnoun]) *objrec=copy_parserec(dobjrec); - else if (match==ext_code[wdname]) *objrec=copy_parserec(actrec); - else return 0; /* *objrec unchanged */ - - return 1; /* *objrec changed */ -} - -static void objcode_fix(cmd_rec *cmd) -/* For $ strings. Fixes object redirection if neccessary */ -{ - int actorword; - word nounword, objword; - int dobj_obj, iobj_obj; - int savedobj, saveactor; - parse_rec *savedrec, *saveactrec, *saveirec; - rbool achange, dchange, ichange; /* Did the given _rec ptr change? */ - - /* dobj_obj/iobj_obj take precedence over anything else */ - actorword=cmd->actor; nounword=cmd->nouncmd; objword=cmd->objcmd; - dobj_obj=cmd->noun_obj; iobj_obj=cmd->obj_obj; - - /* Make temporary copies of things for when more than one thing is - being shuffled around; we don't need to save iobj since - it's processed last */ - saveactor=actor; saveactrec=actor_rec; - savedobj=dobj; savedrec=dobj_rec; - saveirec=iobj_rec; /* Saved only so it can be freed */ - - /* Fix object numbers... */ - fix_objnum(&actor,actorword,0,saveactor,savedobj,iobj); - fix_objnum(&dobj,nounword,dobj_obj,saveactor,savedobj,iobj); - fix_objnum(&iobj,objword,iobj_obj,saveactor,savedobj,iobj); - - /* ... and records */ - achange=fix_objrec(&actor_rec,actorword,0,saveactrec,savedrec,iobj_rec); - dchange=fix_objrec(&dobj_rec,nounword,dobj_obj,saveactrec,savedrec,iobj_rec); - ichange=fix_objrec(&iobj_rec,objword,iobj_obj,saveactrec,savedrec,iobj_rec); - - /* Free up whatever needs freeing */ - if (achange) rfree(saveactrec); - if (dchange) rfree(savedrec); - if (ichange) rfree(saveirec); -} - - -/* Redirection is very superficial-- normally all it does is */ -/* change the matching pattern, not the underlying objects */ -/* The one exception is when we use the special redirection tokens */ -/* NOUN or OBJECT */ - -void redirect_exec(cmd_rec *cmd,word *m_actor,int *vcode, - word *m_dobj,word *m_prep,word *m_iobj) -{ - *m_actor=extract_actor(cmd->actor); - vb=*vcode=verb_code(it_name(expand_redirect(cmd->verbcmd))); - *m_dobj=extract_obj(cmd->nouncmd,cmd->noun_adj); - if (cmd->prep==-1) - *m_prep=0; - else - *m_prep=it_name(expand_redirect(cmd->prep)); - *m_iobj=extract_obj(cmd->objcmd,cmd->obj_adj); - - /* This shuffles the _real_ objects if $noun$ forms are being - used */ - objcode_fix(cmd); -} - - - - -/* ------------------------------------------------------------------- */ -/* Scan Metacommand and the matching function it uses */ -/* ------------------------------------------------------------------- */ - -/* This is used to match the elements of metacommand trigger patterns */ -/* Sees if w2 matches COMMMAND pattern word w1; w1==0 corresponds to ANY */ -#define cmatch(w1,w2) ((w1)==0 || (w1)==(w2) || ((w1)==-1 && (w2)==0)) - -static int cm_actor(int actnum,int actor) - /* cmd: actnum, player entry: actor */ -{ - if (aver [x_obj]? */ -/* --[obj] must match up with */ -/* --If x_obj(the explicit object) is defined, it must match with - the "real" object-- that is, the global dobj or iobj value. */ -static rbool cm_obj(word name, word adj, int x_obj, int obj, int real_obj) -{ - if (name==-1) return (obj==0); /* */ - - if (x_obj && !cm_x_obj(x_obj,real_obj)) return 0; - - /* (Note that ANY does not match ALL) */ - if (obj==-ext_code[wall]) - return(name==ext_code[wall] && adj==0); - - do { /* Work our way up the class hierarchy */ - if (cmatch(name,it_name(obj)) && cmatch(adj,it_adj(obj))) - return 1; - obj=it_class(obj); - } while(obj!=0); - - return 0; -} - - - -static void scan_dbg(int vcode) -{ - char buff[220]; - word w; - - if (vcode>=BASE_VERB && vcode200) return; /* Just in case... */ - sprintf(buff,"+++++Scanning %s\n",dict[w]); - debugout(buff); -} - -#define not_any(n,a) (n!=0 || a!=0) - -/* This returns true if we redirect from VERB OBJ {PREP OBJ} - to something that has fewer objects or no (explicit) preposition. - This is less perfect than I would like since there is currently - no way of distinguishing between ANY and an empty slot unless - the new "NOMATCH" extension is used. */ - -static rbool redir_narrows_grammar(cmd_rec *cmd1, cmd_rec *cmd2) -{ - /* Check inward from obj to prep to noun; if in any of these - fields cmd2 has ANY and cmd1 doesn't, return 1. - Stop as soon as we find a non-ANY field in either one. */ - - /* If we *are* using the new extension, we can just use that info */ - if (cmd2->objcmd==-1) { - if (cmd1->objcmd!=-1) return 1; - if (cmd1->prep==-1) { - if (cmd1->prep!=-1) return 1; - if (cmd2->nouncmd==-1 && cmd1->objcmd!=-1) return 1; - } - } - if (nomatch_aware) return 0; /* If we are using nomatch, don't need - to go through the rest of this nonsense. */ - - if (not_any(cmd2->objcmd,cmd2->obj_adj)) return 0; - if (not_any(cmd1->objcmd,cmd1->obj_adj)) return 1; - - if (cmd2->prep!=0) return 0; - if (cmd1->prep!=0) return 1; - - if (not_any(cmd2->nouncmd,cmd2->noun_adj)) return 0; - if (not_any(cmd1->nouncmd,cmd1->noun_adj)) return 1; - - return 0; /* They are both all ANY. */ -} - - - -static rbool cm_command(cmd_rec *cmd, - integer m_actor, int m_verb, - integer m_dobj, word m_prep, integer m_iobj) -{ - if (cmd->verbcmd==0) { /* ANY */ - if (cmd->actor==0 && aver>=AGX00) - return (m_verb==0); /* ANY command: rest of line ignored */ - /* Else ANY matchs; go on to test other things. */ - } else - if (cmd->verbcmd!=m_verb) return 0; - - return - cm_actor(cmd->actor,m_actor) - && cm_obj(cmd->nouncmd,cmd->noun_adj,cmd->noun_obj,m_dobj,dobj) - && cmatch(cmd->prep,m_prep) - && cm_obj(cmd->objcmd,cmd->obj_adj,cmd->obj_obj,m_iobj,iobj); -} - - - -static void scan_for_actor(integer m_actor, int *start, int *end) -{ - int i; - - assert(m_actor!=0); - - if (aver>=AGX00) { - if (start!=NULL) *start=verbptr[DIR_ADDR_CODE]; - *end=verbend[DIR_ADDR_CODE]; - return; - } - for(i=verbend[DIR_ADDR_CODE];i>verbptr[DIR_ADDR_CODE];i--) - if (creat_fix[command[i].actor-first_creat] - ==creat_fix[m_actor-first_creat]) { - i++; - break; - } - *end=i; - - if (start==NULL) return; - - for(i=verbptr[DIR_ADDR_CODE];i<=*end;i++) - if (creat_fix[command[i].actor-first_creat] - ==creat_fix[m_actor-first_creat]) - break; - *start=i; -} - - -/* m_ are the matching criterion; they have no *neccessary* - connection to dobj, iobj, etc. */ - -int scan_metacommand(integer m_actor,int vcode, - integer m_dobj, word m_prep, integer m_iobj, - int *redir_flag) -/* Return codes: 0=end of this cycle, 1=end of all commands - 2=end of turn */ -/* If doing disambiguation, then -2=end of cycle, something happened; - 0 or 1=end of cycle; nothing happened; 2=end of turn, nothing happened. */ -/* If redir_flag is non-NULL, it is set when redirection occurs: - 1+=Redirection occured - 2=Grammar-changing redirection occured. */ -{ - int i, oldi; - word m_verb; - int scanend; - int redir_offset; /* Used for multiple redirects in the same - metacommand (which can occur in AGATE-style - commands)-- this is used to hold the offset - of the given redirect. */ - long redirect_count; /* This is a safety measure: this keeps track of how - many redirections have occured on a single turn, and - if there are "too many" it will issue an error message - and stop. This is to prevent the system from getting - into a redirection loop. The number should be set - high enough not to prevent deliberate loops, - however. */ - - rfree(substack); subcnt=0; subsize=0; - redirect_count=0; - - if (mars_fix) - if (vcode==0 || m_actor==2) return 0; - /* Don't explicity scan ANY metacommands if MARS fix is active. */ - if (m_actor==-ext_code[weverybody]) m_actor=2; - - - if (DEBUG_AGT_CMD && DEBUG_SCAN &&!supress_debug) scan_dbg(vcode); - - m_verb=syntbl[auxsyn[vcode]]; - if (m_actor==0) { - i=verbptr[vcode]; - scanend=verbend[vcode]; - } else - scan_for_actor(m_actor,&i,&scanend); - for(;i0) { - if (!PURE_ERROR) writeln("GAME ERROR: Invalid REDIRECT token."); - rfree(substack); - return 2; - } - if (MAX_REDIR!=0 && ++redirect_count>MAX_REDIR) { - if (!PURE_ERROR) writeln("GAME ERROR: Infinite REDIRECT loop."); - rfree(substack); - return 2; - } - if (DEBUG_AGT_CMD && !supress_debug) { - debugout(" ==>"); - debug_head(i); - } - - /* REDIRECT :If we do a redirect from a broader grammar to a - narrower grammer, it will be noted so that certain types - of grammer checking can be disabled. */ - if (redir_flag!=NULL) { - if (*redir_flag<2 - && redir_narrows_grammar(&command[oldi],&command[i])) - *redir_flag=2; - - /* Set *redir_flag to at least 1 if we do *any* redirection. */ - if (!*redir_flag) *redir_flag=1; - } - - /* REDIRECT: Do the actual redirection, building the new command - header and shuffling around nouns and verbs as - neccessary */ - redirect_exec(&command[i],&m_actor,&vcode, - &m_dobj,&m_prep,&m_iobj); - - /* REDIRECT: Start scanning again from the beginning */ - if (!mars_fix) {/* In MARS, we *don't* go back to the top */ - if (m_actor!=0) - scan_for_actor(m_actor,&i,&scanend); - else { - i=verbptr[vcode]; - scanend=verbend[vcode]; - } - i--; /* Back up one so that the following i++ we'll - be at the right location */ - } - - /* So when i is incremented, we start back at the correct start: i.e. - we start scanning again from the beginning. It's even possible - to use REDIRECT to run verb commands from an AFTER command, - although it precludes other AFTER commands from running. */ - m_verb=syntbl[auxsyn[vcode]]; - break; - - - - /* -------- SUBROUTINE CALL ------------ */ - case 4: /* Subroutine Call -- same idea as RedirectTo, - but less complicated */ - push_subcall_grammar(m_actor,vcode,m_dobj,m_prep,m_iobj,i); - vcode=verb_code(sub_name[subcall_arg-1]); - m_actor=m_dobj=m_iobj=0; m_prep=0; - - if (!mars_fix) /* In MARS, we *don't* go back to the top */ - i=verbptr[vcode]-1; - scanend=verbend[vcode]; - m_verb=syntbl[auxsyn[vcode]]; - break; - - - /* -------- RETURN ------------ */ - case 5: /* Return: pop grammar state, then ... ? */ - if (!pop_subcall_grammar(&m_actor,&vcode, - &m_dobj,&m_prep,&m_iobj,&i)) { - writeln("GAME ERROR: Return without DoSubroutine."); - rfree(substack); - return 2; - } - - if (m_actor==0) - scanend=verbend[vcode]; - else - scan_for_actor(m_actor,NULL,&scanend); - m_verb=syntbl[auxsyn[vcode]]; - - i--; /* Cause the last command to restart, - at which point run_command will pop the rest of the - stack. */ - - break; - } - rfree(substack); - return 0; /* Done with this cycle of metacommands */ -} - -/* ====================================================================*/ - -#undef cm - diff --git a/app/src/main/jni/terps/agility/object.c b/app/src/main/jni/terps/agility/object.c deleted file mode 100644 index 43c5f65..0000000 --- a/app/src/main/jni/terps/agility/object.c +++ /dev/null @@ -1,1095 +0,0 @@ -/* object.c-- functions to manipulate rooms, nouns, and creatures */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy */ -/* */ -/* This module contains most of the routines that implement the */ -/* "physics" of the AGT world, including the scope routines. */ - -#include -#include -#include -#include "agility.h" -#include "interp.h" -#include "exec.h" - - -/* ------------------------------------------------------------------- */ -/* Functions for manipulating parse_recs */ -/* ------------------------------------------------------------------- */ - -/* Make artificial parse record for an object */ -parse_rec *make_parserec(int obj,parse_rec *rec) -{ - if (rec==NULL) rec=rmalloc(sizeof(parse_rec)); - rec->obj=obj; - rec->info=D_NOUN; - rec->noun=it_name(obj); - rec->adj=it_adj(obj); - rec->num=0; - return rec; -} - -/* This is used by the parser to initialize a blank parse_rec */ -void tmpobj(parse_rec *objrec) -{ - objrec->info=D_NOUN; - objrec->num=0; - objrec->noun=objrec->adj=0; - objrec->obj=0; -} - -parse_rec *copy_parserec(parse_rec *rec) -{ - parse_rec *newrec; - if (rec==NULL) return NULL; - newrec=rmalloc(sizeof(parse_rec)); - memcpy(newrec,rec,sizeof(parse_rec)); - return newrec; -} - -void free_all_parserec(void) -{ - rfree(actor_rec);rfree(dobj_rec);rfree(iobj_rec); -} - - -/* ------------------------------------------------------------------- */ -/* Functions for doing basic manipulation of items and extracting */ -/* nformation about these items */ -/* (often used to blackbox the difference between nouns and creatures) */ - - - -rbool matchclass(int obj, int oclass) -{ - int i; - if (oclass==0) return 0; - for(i=obj;i!=oclass && i!=0;i=it_class(i)); - return i==oclass; -} - - -/* Functions for getting bascic information about items */ - -static const char *it_sdesc(int item) -{ - if (tnoun(item)) return noun[item-first_noun].shortdesc; - if (tcreat(item)) return creature[item-first_creat].shortdesc; - if (item<0) return dict[-item]; - return NULL; -} - -rbool it_possess(int item) -{ - int l; - - l=it_loc(item); - return (l==1 || l==1000); -} - -rbool it_proper(int item) -{ - if (tcreat(item)) - return (!PURE_PROPER) || creature[item-first_creat].proper; - if (tnoun(item)) - return noun[item-first_noun].proper; - return 0; -} - - -static rbool invischeck(const char *s) -{ - while(rspace(*s)) s++; - return strncasecmp(s,"INVISIBLE",9)==0; -} - - -static rbool it_invisible(int item, rbool sdesc_flag) -{ - if (sdesc_flag) - return invischeck(it_sdesc(item)); - else { - char *s; - rbool tmp; - - if (it_name(item)==0 && it_adj(item)==0) return 1; - s=objname(item); /* Must remember to rfree s before exiting */ - tmp=invischeck(s); - rfree(s); - return tmp; - } -} - - -static rbool it_appears_empty(int item) -{ - int i; - int sdesc_flag; - - if (item<0) return 1; - sdesc_flag=!player_has(item); - - contloop(i,item) - if (!it_invisible(i,sdesc_flag)) return 0; - return 1; -} - -/* We classify something as a weapon if it kills something. */ -rbool it_isweapon(int objnum) -{ - int i; - - creatloop(i) - if (matchclass(objnum,creature[i].weapon)) return 1; - return 0; -} - -/* This used to be a macro like troom, tnoun, and tcreat, but it - got too complicated and isn't used in time-critical areas, - anyhow */ - -rbool it_door(int obj,word nword) -{ - if (aver>=AGX00) return 0; /* No doors under Magx */ - if (tdoor(obj)) return 1; /* The basic door */ - if (it_loc(obj)==loc+first_room) return 0; - return (nword==ext_code[wdoor]); -} - - -/* ------------------------------------------------------------------- */ -/* Routines that manipulate the linked lists representing containment */ -/* information */ - -static void set_contents(int p, int newval) -{ - if (troom(p)) room[p-first_room].contents=newval; - else if (p==1) player_contents=newval; - else if (p==1000) player_worn=newval; - else if (tnoun(p)) noun[p-first_noun].contents=newval; - else if (tcreat(p)) creature[p-first_creat].contents=newval; - else {writeln("INT ERR: Invalid object heading chain.");return;} -} - -static void set_next(int p, int newval) -{ - if (tnoun(p)) noun[p-first_noun].next=newval; - else if (tcreat(p)) creature[p-first_creat].next=newval; - else {writeln("INT ERR: Invalid object in chain.");return;} -} - -void add_object(int loc,int item) -{ - int p, q; - - set_next(item,0); - - if (loc==0) return; - p=it_contents(loc); - - if (p==0 || p>item) { - set_contents(loc,item); - set_next(item,p); - } else { /* Figure out where to put the item */ - do { - q=p; - p=it_next(p); - } while (p!=0 && p=maxroom && i!=1000 && cnt<40000L; - cnt++) { - i=it_loc(i); - if (stop_if_closed && !it_open(i)) break; - } - if (cnt>=40000L) { - /* writeln("GAME ERROR: Loop in object tree.");*/ - return 0; - } - if (i==obj2) return 1; - return 0; -} - - - -int check_fit(int obj1, int obj2) - /* Does obj1 fit inside obj2? Return one of the FIT_... values - defined in exec.h */ -{ - int size, weight; - long net; - - assert(tnoun(obj1)); /* This should have been checked earlier */ - if (obj2==1000) obj2=1; - - if (obj2==1) size=weight=100; - else { - assert(tnoun(obj2)); /* check_fit shouldn't be called otherwise */ - size=noun[obj2-first_noun].size; - weight=noun[obj2-first_noun].weight; - } - - /* Weight */ - if (obj2==1 || (aver>AGTME15 && aver=AGX00) net+=contweight(obj1); - if (net>weight) return FIT_WEIGHT; - - if (obj2==1){ - if (is_within(obj1,1,0) || is_within(obj1,1000,0)) net=0; - net+=contweight(1); - if (aver>=AGX00) - net+=contweight(1000); - if (!PURE_SIZE) net=0; - } else { - if (is_within(obj1,obj2,0)) net=0; /* Avoid double-counting */ - net+=contweight(obj2); /* Net size of contents of obj2 */ - } - if (net>weight) return FIT_NETWEIGHT; - } - - net=noun[obj1-first_noun].size; - if (net>size) return FIT_SIZE; - - if (obj2==1 && !PURE_SIZE) return FIT_OK; - - if (obj2==1 || aver>AGTME15) { - /* Pre-ME/1.56 interpreters didn't check this except for the player's - inventory */ - if (it_loc(obj1)==obj2 - || (aversize) return FIT_NETSIZE; - } - - return FIT_OK; -} - - - -/* ------------------------------------------------------------------- */ -/* Scope and visibility routines */ - -integer it_room(int item) -{ - int tmploc; - long cnt; - - cnt=0; - while(!troom(item)) { - tmploc=item; - if (item==0) return 0; - if (item==1 || item==1000) item=loc; - else item=it_loc(item); - if (item==tmploc || ++cnt>=40000L) { - /* writeln("GAME ERROR: Loop in object tree."); */ - return 0; - } - } - return item; -} - -rbool player_has(int item) -{ - return is_within(item,1,0) || is_within(item,1000,0); -} - - -rbool in_scope(int item) -/* strictly speaking, visible actually checks scope; this routine - determines if an object would be in scope if there were no light - problems. */ -{ - int curloc; - int tmp; - long cnt; - - if (it_isglobal(item)) return 1; /* Global objects always in scope. */ - - /* Flag objects in scope if their associated flag is set. */ - tmp=it_flagnum(item); - if (tmp && - (room[loc].flag_noun_bits & (1L<<(tmp-1)))) return 1; - - curloc=it_loc(item); /* Should work for nouns or creatures */ - cnt=0; - while (curloc>maxroom && curloc!=1000 && it_open(curloc)) { - int tmploc; - tmploc=it_loc(curloc); - if (tmploc==curloc || ++cnt>=40000L) { - /* writeln("GAME ERROR: Loop in the object tree."); */ - return 0; - } - else curloc=tmploc; - } - if (curloc==1 || curloc==1000 || curloc==loc+first_room) return 1; - else return 0; -} - - -static int good_light(int obj,int roomlight,rbool active) - /* obj is a noun number */ - /* If active is false, we don't care if the light is actually turned - on is the valid light */ -{ - if (roomlight==1 && !noun[obj].light) - return 0; /* obj is not a light source */ - if (roomlight>1) { - if (!matchclass(first_noun+obj,roomlight)) - return 0; /* Not the correct light */ - else return 1; /* The correct light _always_ illuminates the room */ - } - if (!active) return 1; - /* Now need to determine if obj is actually providing light */ - if (!noun[obj].on) - return 0; /* Light source is off or extinguished */ - return 1; -} - -int lightcheck(int parent,int roomlight,rbool active) - /* This checks to see if anything contained in parent is a valid - room light */ - /* active=1 means that we only want active lights; - active=0 indicates that extinguished light sources are okay. */ -{ - int i; - - contloop(i,parent) { - if (tnoun(i) && good_light(i-first_noun,roomlight,active)) return 1; - if (it_open(i) && lightcheck(i,roomlight,active)) - return 1; /* Check children */ - } - return 0; -/* - nounloop(i) - if (good_light(i,room[loc].light) && in_scope(i+first_noun)) - return 1; - return 0;*/ -} - - -rbool islit(void) -{ - if (room[loc].light==0) return 1; - if (lightcheck(loc+first_room,room[loc].light,1)) return 1; - if (lightcheck(1,room[loc].light,1)) return 1; /* Player carried light */ - if (lightcheck(1000,room[loc].light,1)) return 1; /* Worn light */ - return 0; -} - -/* Is item visible to player? */ -/* visible only works for "normal" items; if the object could - be a virtual object (i.e. with negative item number), then use - gen_visible() below */ -rbool visible(int item) -{ - assert(item>=0); - if (islit()) - return in_scope(item); - else - return player_has(item); -} - -rbool genvisible(parse_rec *dobj) -{ - int i; - - if (dobj->obj>0) return visible(dobj->obj); - - if (dobj->info==D_INTERN) { - if (dobj->obj!=-ext_code[wdoor]) return 1; - return islit(); /* If item is a is a door */ - } - if (dobj->info==D_GLOBAL || dobj->info==D_NUM) return 1; - if (dobj->info==D_FLAG) { - for(i=0;iobj==-flag_noun[i] - && (room[loc].flag_noun_bits & (1L<info==D_PIX) { - for(i=0;iobj==-pix_name[i] && - (room[loc].PIX_bits & (1L<0) - print_descr(dp[i],1); - else if (!invischeck(shortdesc)) - raw_lineout(shortdesc,1,MSG_DESC,NULL); - else sysmsg(msgid,"$You$ see nothing unexpected."); -} - -void it_describe(int dobj) -{ - if (troom(dobj)) - print_descr(room_ptr[dobj-first_room],1); - else if (tnoun(dobj)) - rundesc(dobj-first_noun,noun_ptr,noun[dobj-first_noun].shortdesc,194); - else if (tcreat(dobj)) - rundesc(dobj-first_creat,creat_ptr, - creature[dobj-first_creat].shortdesc,195); - else if (dobj==-ext_code[wdoor]) /* i.e. DOOR */ - { - if (room[loc].locked_door) - sysmsg(21,"$You$ see a locked door."); - else sysmsg(22,"$You$ see a perfectly normal doorway."); - } - else sysmsg(194,"$You$ see nothing unexpected."); - if (tnoun(dobj) && - (noun[dobj-first_noun].open || !noun[dobj-first_noun].closable) && - !it_appears_empty(dobj)) { - sysmsg(228,"Which contains:"); - print_contents(dobj,1); - } -} - - - -static char *build_position(word prep,word name) -/* Return the malloc'd string '$prep$ the $name$' */ -{ - int leng; - char *s; - - leng=strlen(dict[prep])+strlen(dict[name])+6; /* includes final '\0' */ - s=rmalloc(leng*sizeof(char)); - - strcpy(s,dict[prep]); - strcat(s," the "); - strcat(s,dict[name]); - assert(strlen(s)+1==leng); - return s; -} - - - - - - -static int print_obj(int obj,int ind_lev) -/* Prints out s on a line of its own if obj isn't INVISIBLE */ -/* parent_descr is true if the parent has been described, false - otherwise (say if the parent is invisible). */ -/* ind_lev=indentation level */ -/* Return 1 if we actually printed something, 0 if obj is invisible */ -{ - int sdesc_flag; /* True if should print out as sdesc rather than - as adjective-noun */ - int i, retval, parent; - const char *s; - char *t, *s0, *posstr; - - if (tcreat(obj) && creature[obj-first_creat].initdesc!=0) - return 0; /* Don't print normal description if printing initdesc */ - - s0=NULL; - sdesc_flag=!player_has(obj); /* This should be tested. */ - sdesc_flag=sdesc_flag||(ind_lev>1); /* It seems that AGT uses the - sdesc for describing items - contained in other items */ - /* Some code below relies on this, as well */ - - if (sdesc_flag) - s=it_sdesc(obj); - else if (it_name(obj)==0 && it_adj(obj)==0) /* Invisible */ - return 0; - else { - s0=objname(obj); /* Must remember to rfree s before exiting */ - if (aver>=AGTME10) { - for(t=s0;isspace(*t);t++); /* Skip over initial whitespace... */ - *t=toupper(*t); /* ...and upcase the first non-space character */ - } - s=s0; - } - - retval=0; - if (sdesc_flag && tnoun(obj) && noun[obj-first_noun].initdesc!=0) { - retval=1; - msgout(noun[obj-first_noun].initdesc,1); - noun[obj-first_noun].initdesc=0; /* Only show it once */ - } - else if (!invischeck(s)) { - retval=1; /* We're actually going to print something */ - for(i=0;i=first_noun && it_invisible(parent,sdesc_flag) - && (it_name(parent)!=0 || it_adj(parent)!=0) ) { - /* If the parent object *isn't* invisible, we will already have - printed it out */ - /* This also relies on sdesc_flag being the same for parent - and child objects */ - - if (parent>=first_creat && parent<=maxcreat) - sysmsg(221,"(Carried by"); - else - sysmsg(222," (Inside"); - t=objname(parent); - writestr(t);rfree(t); - sysmsg(223,")"); - } - if (tnoun(obj) && noun[obj-first_noun].light && noun[obj-first_noun].on - && PURE_OBJ_DESC) - sysmsg(220," (Providing light)"); - writeln(""); - } - if (!sdesc_flag) - rfree(s0); - return retval; -} - - -int print_contents(int obj,int ind_lev) -/* obj=object to list contents of; ind_lev=indentation level */ -/* Returns number of objects contained in obj that were listed */ -{ - int i, cnt; - - cnt=0; - - contloop(i,obj) { - if (print_obj(i,ind_lev)) cnt++; - if (it_open(i)) print_contents(i,ind_lev+1); - } - return cnt; -} - - -/* ------------------------------------------------------------------- */ -/* Routines for directly getting and setting object properties and */ -/* attributes. */ - - -#define NUM_WPROP 6 -#define NUM_WATTR 6 - - -static void *compute_addr(int obj, int prop, const prop_struct *ptable) -{ - int ofs; - void *base; - - if (DIAG) - rprintf("(Accessing %s->%s)\n",dict[it_name(obj)],ptable[prop].name); - if (troom(obj)) { - base=(void*)(&room[obj-first_room]); - ofs=ptable[prop].room; - } - else if (tnoun(obj)) { - base=(void*)(&noun[obj-first_noun]); - ofs=ptable[prop].noun; - } - else if (tcreat(obj)) { - base=(void*)(&creature[obj-first_creat]); - ofs=ptable[prop].creature; - } - else return NULL; - - if (ofs==-1) /* Field doesn't exist in this type of object */ - return NULL; - - return (void*) ( ((char*)base) + ofs ); -} - - -long getprop(int obj, int prop) -{ - integer *paddr; - - if (prop>=NUM_PROP) return 0; - paddr=(integer*)compute_addr(obj,prop,proplist); - if (paddr==NULL) return 0; - return *paddr; -} - -void setprop(int obj, int prop, long val) -{ - integer *paddr; - - if (prop>=NUM_WPROP) { - writeln("GAME ERROR: Read-only or non-existant property."); - return; - } - - paddr=(integer*)compute_addr(obj,prop,proplist); - if (paddr==NULL) { - writeln("GAME ERROR: Property-object mismatch."); - return; - } - *paddr=val; -} - -rbool getattr(int obj, int prop) -{ - rbool *paddr; - - if (prop>=NUM_ATTR) return 0; - paddr=(rbool*)compute_addr(obj,prop,attrlist); - if (paddr==NULL) return 0; - return *paddr; -} - -void setattr(int obj, int prop, rbool val) -{ - rbool *paddr; - - if (prop>=NUM_WATTR && prop!=24) { - writeln("GAME ERROR: Read-only or non-existant attribute."); - return; - } - - paddr=(rbool*)compute_addr(obj,prop,attrlist); - if (paddr==NULL) { - writeln("GAME ERROR: Property-object mismatch."); - return; - } - *paddr=val; -} - - - -/* ------------------------------------------------------------------- */ -/* This sets up the creat_fix[] array, which is used to determine the */ -/* scan ranges for addressed creatures in cases where there is more */ -/* than one creature of the same name */ - -void init_creat_fix(void) -{ - int i,j; - - creat_fix=rmalloc(rangefix(maxcreat-first_creat+1)*sizeof(integer)); - for(i=0;i i */ -} - -void free_creat_fix(void) -{ - rfree(creat_fix); -} - -/* ------------------------------------------------------------------- */ - -#ifndef IT_MACRO -int it_contents(integer obj) -{ - if (tnoun(obj)) return noun[obj-first_noun].contents; - else if (troom(obj)) return room[obj-first_room].contents; - else if (tcreat(obj)) return creature[obj-first_creat].contents; - else if (obj==1) return player_contents; - else if (obj==1000) return player_worn; - else return 0; -} - -rbool it_lockable(integer obj, word nword) -{ - if (tnoun(obj)) return noun[obj-first_noun].lockable; - else if (it_door(obj,nword)) return 1; - else return 0; -} - -rbool it_locked(integer obj, word nword) -{ - if (tnoun(obj)) return noun[obj-first_noun].locked; - else if (it_door(obj,nword) && room[loc].locked_door) return 1; - else return 0; -} - -#endif - - - - - - diff --git a/app/src/main/jni/terps/agility/os_curses.c b/app/src/main/jni/terps/agility/os_curses.c deleted file mode 100644 index e9f8222..0000000 --- a/app/src/main/jni/terps/agility/os_curses.c +++ /dev/null @@ -1,1821 +0,0 @@ -/* os_curse.c -- interface routines for ncurses systems */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for the (Mostly) Universal */ -/* AGT Interpreter */ - - - -#define RVID_BOX 1 /* Make box reverse video? */ -#define DEBUG_KEY 0 - -#if 0 -#define IMMED /* Immediate update mode? */ -#endif - -#define REFRESH_LINE_CNT 4 /* Redisplay screen every lines scrolled */ - -/*---------------------------------------------------------------------*/ -/* Header Files and Prototypes of terminal functions */ -/*---------------------------------------------------------------------*/ -#include "agility.h" -#include "interp.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef LINUX -#include /* Needed for the font changing commands */ -#endif - - - - - -#ifdef TIOCGWINSZ /* Both of these need to be defined. */ -#ifdef SIGWINCH -#define CATCH_WINDOW_CHANGE -#endif -#endif - -/* 0:Black, 1:Red, 2:Green, 3:Brown, 4:Blue, 5:Magenta, 6:Cyan, 7:White */ -/* 3n=foreground, 4n=background, semicolon seperated */ -/* The AGT color codes are as follows: */ -/* 0=Black, 1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta, 6=Brown, 7=White */ - -int agt_col[8]={COLOR_BLACK,COLOR_BLUE,COLOR_GREEN,COLOR_CYAN, - COLOR_RED,COLOR_MAGENTA,COLOR_YELLOW,COLOR_WHITE}; -rbool color_on; - - - -/*---------------------------------------------------------------------*/ -/* Misc. Global variables */ -/*---------------------------------------------------------------------*/ - -static rbool nav_arrow; /* NAVARROW set? */ -static rbool lower_file; /* Lowercase resource files? */ -static rbool font_enable; -static fc_type game_fc; -static char *viewer_name; /* Name of image viewing program */ - -rbool have_compass; -static int status_height; /* Number of lines in status line */ - -static int scroll_count; /* Count of how many lines we have printed since - last player input. */ -volatile int curr_y, winsize_flag; - -WINDOW *mainwin, *statwin; - -/* This gives the first function key in the following table; - earlier entries are other macro keys. */ -#define FIRST_FKEY 10 - -static char *fkey_text[FIRST_FKEY+64]={ /* Text for function keys */ - "exit\n", - "w\n","e\n","n\n","s\n", - "nw\n","sw\n","se\n","ne\n", - "enter\n", - "get ", /* <== This is FIRST_FKEY */ - "drop ", - "examine ","read ", - "open ","close ", - "inventory\n","look\n", - "score\n", "help\n", - "save\n","restore\n", - "","","","","","","","","","","","","", - "","","","","","","","","","","","","", - "","","","","","","","","","","","","", - "","","","","","","","","","","","","" -}; - -/* These are the macro-bindable non-function keys. */ -static const char *keylist[FIRST_FKEY]={ - "del", - "left","right","up","down", - "home","end","pgdn","pgup", - "ins"}; - -enum {fn_del=1010,fn_left,fn_right,fn_up,fn_down,fn_home,fn_end,fn_pgdn, - fn_pgup, fn_ins} fn_type; - -#if 0 -{ - "undo\n", - "get ","drop ", - "unlock ","read ", - "open ","close ", - "inventory\n","look\n", - "wait\n", - "save\n","restore\n"}; -#endif - -/* Other candidates: view, wait (z), examine (x), again (g) */ - - -/*---------------------------------------------------------------------*/ -/* Misc. minor functions */ -/*---------------------------------------------------------------------*/ - -#ifdef IMMED -#define updatesys() print_statline(); -#else -#define updatesys() print_statline();wrefresh(mainwin); -#endif - - -void agt_delay(int n) -{ - if (BATCH_MODE) return; - updatesys(); - sleep((n+1)/2); /* In theory this should be sleep(n) */ -} - -void agt_tone(int hz,int ms) -/* Produce a hz-Hertz sound for ms milliseconds */ -{ - if (BATCH_MODE) return; - return; -} - - -int agt_rand(int a,int b) -/* Return random number from a to b inclusive */ -{ - int n; - n=a+(rand()>>2)%(b-a+1); - return n; -} - -genfile agt_globalfile(int fid) -{ - char *homedir; - FILE *cfgfile; - char *fname; - - if (fid!=0) return badfile(fCFG); - homedir=getenv("HOME"); - fname=rmalloc(strlen(homedir)+10); - sprintf(fname,"%s/.agilrc",homedir); - cfgfile=fopen(fname,"r"); - return cfgfile; -} - -void script_out(const char *s) -{ - if (DEBUG_OUT) - fprintf(debugfile,"%s",s); - if (script_on) fprintf(scriptfile,"%s",s); -} - - - -/*---------------------------------------------------------------------*/ -/* Character Appearance Functions */ -/*---------------------------------------------------------------------*/ - -#define STATUS_STATE 0xA007 -#define START_STATE 0x0007 - -/* For state: - currently low 4 bits are color. - bit 13 (0x2000) indicates whether we are in standout mode or not - bit 14 (0x4000) indicates whether we are blinking or not - bit 15 (0x8000) indicates whether bold is on or not */ - -#define BOLD_BIT 0x8000 -#define BLINK_BIT 0x4000 -#define SL_BIT 0x2000 - -static int STAT_ATTR; /* Attribute settings for status line */ - -typedef unsigned short vstate; -static vstate state_stack[16]; -int stateptr=0; /* Points into state stack */ - -#define cstate state_stack[stateptr] /* Current state */ - -volatile short *r_f,*r_b; - - -static void set_state(vstate state) -{ - int c; /* Color */ - int attr; - - if (BATCH_MODE) return; - - attr=A_NORMAL; - - if (color_on) { - c=state & 0xF; - if (state & SL_BIT) /* Status line state */ - c+=8; - if (state & BOLD_BIT) /* BOLD */ - if (c==7) c=6; /* BOLD text will be yellow if not in Status line */ - attr=COLOR_PAIR(c+1); - } - - if (state & BOLD_BIT) /* BOLD */ - attr|=A_BOLD; - - if (!color_on) - if (state & SL_BIT) - attr|=A_REVERSE; - - if (state & BLINK_BIT) /* Blinking */ - attr|=A_BLINK; - - wattrset(mainwin,attr); - - cstate=state; -} - -static void push_state(vstate state) -{ - if (stateptr==15) fatal("State stack overflow!"); - stateptr++; - set_state(state); -} - -static void pop_state(void) -{ - if (stateptr==0) fatal("State stack error: POP without PUSH!"); - stateptr--; - set_state(cstate); -} - - - -void agt_textcolor(int c) -/* Set text color to color #c, where the colors are as follows: */ -/* 0=Black, 1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta, 6=Brown, */ -/* 7=White("normal"), 8=Blinking, */ -/* 9= *Just* White (not neccessarily "normal" and no need to turn off */ -/* blinking) */ -/* Also used to set other text attributes: */ -/* -1=emphasized text, used (e.g.) for room titles */ -/* -2=end emphasized text */ -{ - vstate nstate; - - nstate=cstate; - if (c==-1) - nstate=nstate|0x8000; - else if (c==-2) - nstate=nstate & ~0x8000; /* BOLD off */ - else if (c==8) - nstate=nstate | 0x4000; /* BLINK on */ - else if (c==7) - nstate=0x0007; /* "Normal" */ - else if (c==9) - nstate=(nstate & ~0xF) | 7; /* Set color to 7: white */ - else if (c>=0 && c<7) - nstate=(nstate & ~0xF) | c; /* Set color to c */ - set_state(nstate); -} - - - - -/*---------------------------------------------------------------------*/ -/* Low-level Terminal Functions: gotoxy(), etc. */ -/*---------------------------------------------------------------------*/ - -static void fix_loc(void) -/* This fixes the location if we are restoring from a suspended state */ -/* Also corrects for a changed window size */ -{ - struct winsize winsz; - int new_width, new_height; - -#ifdef CATCH_WINDOW_CHANGE - if (winsize_flag - && ioctl(STDOUT_FILENO,TIOCGWINSZ,&winsz)==0 - && winsz.ws_row!=0 && winsz.ws_col!=0) { - - winsize_flag=0; - new_width=winsz.ws_col; - new_height=winsz.ws_row; - resizeterm(new_height,new_width); - - set_state(7); /* Make sure we are in normal screen state */ - wresize(mainwin,new_height-status_height,new_width); - wresize(statwin,1,new_width); - - screen_width=status_width=new_width; - screen_height=new_height-status_height; - - if (curr_x>screen_width) - curr_x=screen_width-1; - if (curr_y>screen_height) - curr_y=screen_height-1; - - wmove(mainwin,curr_y,curr_x); - } -#endif -} - - -#ifdef CATCH_WINDOW_CHANGE -void window_change(int signum) -{ - signal(SIGWINCH,window_change); - winsize_flag=1; -} -#endif - - -void int_handler(int signum) -{ - close_interface(); - exit(0); -} - - - - -/*---------------------------------------------------------------------*/ -/* Functions to read and translate keys */ -/*---------------------------------------------------------------------*/ - -int read_a_key(void) -{ - int c; - int i; - - c=wgetch(mainwin); - switch(c) - { - case KEY_HOME: - if (nav_arrow) return fn_home; /* Otherwise fall through... */ - case '\001': return 1006; /* Ctrl-A ==> Home */ - case KEY_LEFT: - if (nav_arrow) return fn_left; /* Otherwise fall through... */ - case '\002': return 1002; /* Ctrl-B ==> Left arrow */ - case KEY_END: - if (nav_arrow) return fn_end; /* Otherwise fall through... */ - case '\005': return 1007; /* Ctrl-E ==> End */ - case KEY_RIGHT: - if (nav_arrow) return fn_right; /* Otherwise fall through... */ - case '\006': return 1003; /* Ctrl-F ==> Right arrow */ - case '\010': /* Fall though... */ - case KEY_BACKSPACE: - case '\177': return 1000;/* Ctrl-H and ==> Backspace */ - case KEY_DC: - if (nav_arrow) return fn_del; /* Otherwise fall through... */ - return 1001; /* Delete */ - case '\013': return 1500; /* Ctrl-K */ - case '\014': return 1502; /* Ctrl-L */ - case KEY_DOWN: - if (nav_arrow) return fn_down; /* Otherwise fall through... */ - case '\016': return 1005; /* Ctrl-N ==> Down arrow */ - case KEY_UP: - if (nav_arrow) return fn_up; /* Otherwise fall through... */ - case '\020': return 1004; /* Ctrl-P ==> Up arrow */ - case '\031': return 1501; /* Ctrl-Y */ - case KEY_PPAGE: - if (nav_arrow) return fn_pgup; /* Otherwise fall through... */ - return 1008; /* Page Up */ - case KEY_NPAGE: - if (nav_arrow) return fn_pgdn; /* Otherwise fall through... */ - return 1009; /* Page Down */ - default: - for (i=0;i<64;i++) - if (c==KEY_F(i)) { - return 1010+FIRST_FKEY+i-1; - } - if (isprint(c) || c=='\n' || c=='\r') return c; - return 2000; - } -} - -/* - 1000= backspace - 1001= delete - 1002= left - 1003= right - 1004= up - 1005= down - 1006= home - 1007= end - 1008= page up - 1009= page down - 101n= Function key F. (F0==F10) - 1020,1021: F11,F12 (?) - ... 1074 - 1500= ^K - 1501= ^Y - 1502= ^L - 2000= unknown control character -*/ - - - -/*---------------------------------------------------------------------*/ -/* Functions for the Built-In Line Editor */ -/*---------------------------------------------------------------------*/ - -void agt_putc(char c) -{ - fix_loc(); /* Fixup if returning from being suspended */ - waddch(mainwin,c); - curr_x+=1; -} - - -static int base_x,base_y; /* Base X value of first character of input */ - -/* This assumes the cursor is always positioned on the string - being edited */ -static void update_cursor(int cursor) -{ - curr_x=base_x+cursor; - curr_y=base_y; - while (curr_x>=screen_width) { - curr_x-=screen_width; - curr_y++; - } - wmove(mainwin,curr_y,curr_x); -} - -static rbool old_yheight=0; - -static void update_line(int cursor,char *buff) -{ - int yval, yheight, xpos, i; - - yheight=(base_x+strlen(buff)+screen_width-1)/screen_width; /* Round up */ - wmove(mainwin,screen_height-1,screen_width-1); - while (base_y+yheight>screen_height && base_y>0) { - base_y--; - waddch(mainwin,'\n'); - } - for(yval=yheight;yval0) { /* One key */ - if (state==1) { - agt_putc(key); - } - buff[0]=key; buff[1]=0; - buffleng=1; - break; - } - -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - if (key=='\n' || key=='\r') { - update_cursor(buffleng); - break; - } - /* add character to buffer */ - buffleng++; - if (buffleng+1>buffspace) buffspace+=20; - buff=rrealloc(buff,buffspace); - for(i=buffleng;i>cursor;i--) - buff[i]=buff[i-1]; - buff[cursor++]=key; - update_line(cursor,buff); - } - else switch(key-1000) - { /* Special key */ - - - case 0: /* Backspace */ - if (!editmode || cursor==0) break; - cursor--; - /* Fall through... */ - - - case 1: /* Delete */ - if (!editmode || buffleng==cursor) break; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - for(i=cursor;i0) - update_cursor(--cursor); - break; - - - case 3: /* Right arrow */ - if (editmode && cursor=histcount) { - /* Reached bottom: restore original line */ - curr_hist=histcount; - buff=savebuff; - savebuff=NULL; - } else - buff=hist[curr_hist]; - buffleng=strlen(buff); - cursor=0; - redisplay_line(buff); - break; -#endif - - case 6: /* Home */ - if (!editmode) break; - cursor=0; - update_cursor(cursor); - break; - - case 7: /* End */ - if (!editmode) break; - cursor=buffleng; - update_cursor(cursor); - break; - - case 8: /* Page up : Scroll back */ - case 9: /* Page down */ - break; - - - case 500: /* Ctrl-K: Delete to EOL */ - if (!editmode) break; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - rfree(yank_text); - yank_text=rstrdup(buff+cursor); - buffleng=cursor; - buff[buffleng]=0; - update_line(cursor,buff); - break; - - - case 501: /* Ctrl-Y: Yank */ - if (!editmode) break; - { - int txtleng; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - txtleng=strlen(yank_text); - buffleng+=txtleng; - while(buffleng+1>buffspace) buffspace+=20; - buff=rrealloc(buff,buffspace); - for(i=buffleng;i>=cursor+txtleng;i--) - buff[i]=buff[i-txtleng]; - for(i=0;i */ - default: - if (key-1010<0 || key-1010>=FIRST_FKEY+64) break; - if (!editmode) break; - { - int txtleng; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - txtleng=strlen(fkey_text[key-1010]); - if (fkey_text[key-1010][txtleng-1]=='\n') { - /* Newlines should only appear at the end; they indicate - that this function key should cause the line to be entered. */ - txtleng--; - exitflag=1; /* Finish entering this line */ - } - buffleng+=txtleng; - while(buffleng+1>buffspace) buffspace+=20; - buff=rrealloc(buff,buffspace); - for(i=buffleng;i>=cursor+txtleng;i--) - buff[i]=buff[i-txtleng]; - for(i=0;is) && (*t=='\n');t--); - if (*t!=0 || t=screen_height) - curr_y=screen_height-1; /* Scrolling has occured */ - return; - } - - if (curr_x=screen_height-1) - agt_more(); /* Print out MORE message */ - else { -#ifndef IMMED - refresh_count=refresh_count%REFRESH_LINE_CNT; - if (refresh_count==0) wrefresh(mainwin); -#endif - } - fix_loc(); /* Fixup if returning from being suspended */ -} - - -void agt_puts(const char *s) -/* This routine assumes that s is not wider than the screen */ -{ - script_out(s); - - if (BATCH_MODE) return; - - fix_loc(); /* Fixup if returning from being suspended */ - curr_x+=strlen(s); - waddstr(mainwin,s); - wmove(mainwin,curr_y,curr_x); -} - - -void agt_clrscr(void) -{ - winsize_flag=0; - scroll_count=0; - curr_x=0;curr_y=0; - script_out("\n\n\n\n\n"); - - if (BATCH_MODE) return; - - werase(mainwin); - wmove(mainwin,0,0); -} - - - - -/*---------------------------------------------------------------------*/ -/* Box Printing Routines */ -/*---------------------------------------------------------------------*/ - -static unsigned long boxflags; -static int box_startx; /* Starting x of box */ -static int box_width; -static int delta_scroll; /* Amount we are adding to vertical scroll - with the box */ - -#define bhline() waddch(mainwin,ACS_HLINE) -#define bvline() waddch(mainwin,ACS_VLINE) - -static void boxrule(void) -/* Draw line at top or bottom of box */ -{ - int i; - - if (RVID_BOX) agt_puts(" "); - else {waddch(mainwin,ACS_ULCORNER);bhline();} - - for(i=0;i=screen_height) curr_y=screen_height-1; - wmove(mainwin,curr_y,curr_x); - - script_out("\n"); - for(i=0;i=screen_height) /* Make room for credits */ - curr_y=screen_height-height-8-1; - if (curr_y<0) curr_y=0; - delta_scroll=0; - scroll_count=0; - } else { - /* Compute vertical position of non-title box */ - curr_y=curr_y-height; - if (curr_y<0) { - delta_scroll=1-curr_y; - curr_y=0; - } else delta_scroll=0; - } - - curr_x=box_startx; - wmove(mainwin,curr_y,curr_x); - - script_out("\n"); - for(i=0;i64) err=1; - n+=FIRST_FKEY; - } - if (err) { - writeln("Unrecognized KEY name."); - return; - } - - leng=0; - for(i=0;i=0 && s[i]=='+') { - s[i]='\n'; - s[i+1]=0; - } - if (keys_defined & (1<=2 && setflag) { - return 1; /* Curses version ignores this. */ - } -#ifdef LINUX - if (opt("FONT")) { - font_enable=setflag; - return 1; - } -#endif - if (opt("COMPASS")) { - have_compass=setflag; - status_height=1+setflag; - return 1; - } - if (opt("KEY") && optnum>=2) { - set_fkey(optstr[1],optstr+2,optnum-2); - return 1; - } - if (opt("HISTORY")) { - histmax=strtol(optstr[1],NULL,10); - if (histmax<0) histmax=0; - return 1; - } - if (opt("LOWER_FILE")) { - lower_file=setflag; - return 1; - } - if (opt("NAVARROW")) { - nav_arrow=setflag; - return 1; - } - if (opt("VIEWER")) { - viewer_name=rstrdup(optstr[1]); - return 1; - } - if (opt("PATH") && optnum>=2) { - if (gamepath!=NULL) return 1; /* First setting wins */ - gamepath=rmalloc((optnum+1)*sizeof(char*)); /* optnum-1+2 */ - gamepath[0]=""; /* ==> The current directory */ - for(i=1;ipath,name,ext); - f=fopen(fname,"rb"); - rfree(fname); - return f; -} - - - -/*------------------------------------------------------------------*/ -/* FONT Routines */ -/*------------------------------------------------------------------*/ - -static char *save_font; -static int save_font_height; - -static int set_font(char *fontdef, int font_height) -{ -#ifdef PIO_FONTX - struct consolefontdesc fontdesc; - - fontdesc.charcount=256; - fontdesc.charheight=font_height; - fontdesc.chardata=fontdef; - - return ioctl(STDOUT_FILENO,PIO_FONTX,&fontdesc); -#else -#ifdef PIO_FONT - return ioctl(STDOUT_FILENO,PIO_FONT,fontdef); -#endif -#endif -} - - -static int getfont(char *fontdef, int *font_height) -{ - int rval=-1; - -#ifdef GIO_FONTX - struct consolefontdesc fontdesc; - - fontdesc.chardata=fontdef; - rval=ioctl(STDOUT_FILENO,GIO_FONTX,&fontdesc); - *font_height=fontdesc.charheight; -#else -#ifdef GIO_FONT - rval=ioctl(STDOUT_FILENO,GIO_FONT,save_font); /* Get current font */ - *font_height=16; -#endif -#endif - return rval; -} - - -static void save_old_font(void) -{ - if (BATCH_MODE) return; - - /* Save existing font */ - save_font=rmalloc(256*32); - if (getfont(save_font,&save_font_height)) - /* Failed... issue warning? */ - rfree(save_font); -} - - -static void restore_font(void) -{ - if (BATCH_MODE) return; - if (save_font==NULL || set_font(save_font,save_font_height)) { - /* Couldn't restore save_font */ -#ifdef PIO_FONTRESET - ioctl(STDOUT_FILENO,PIO_FONTRESET); -#endif - } -} - - - -void fontcmd(int cmd,int font) -/* 0=Load font, name is fontlist[font] - 1=Restore original font - 2=Set startup font. (.FNT) -*/ -{ - FILE *fontfile; - char *buff, *fontname, *s; - int count, height; - - if (!font_enable) return; - /* (This should be off by default since it changes the fonts - on *all* of the VC's) */ - - if (cmd==2) - save_old_font(); - - if (cmd==0 || cmd==2) { - if (cmd==0) { - fontname=fontlist[font]; - if (lower_file) - for(s=fontname;*s!=0;s++) *s=tolower(*s); - /* Lowercase the font names as we use them */ - } - else fontname=game_fc->gamename; - - fontfile=linopen(fontname,".fnt"); - if (fontfile==NULL) return; - buff=rmalloc(256*32); - memset(buff,0,256*32); - fseek(fontfile,0,SEEK_END); - height=ftell(fontfile); - if (height%256!=0) { - /* Error message */ - return; - } - height=height/256; - - fseek(fontfile,0,SEEK_SET); - for(count=0;count<256;count++) - if (fread(buff+count*32,height,1,fontfile)!=1) break; - if (count!=256) { - fclose(fontfile); - rfree(buff); - return; - } - fclose(fontfile); - if (!BATCH_MODE) - if (set_font(buff,height)) { - /* Print error message */ - } - rfree(buff); - return; - } else if (cmd==1) - restore_font(); -} - - - -/*------------------------------------------------------------------*/ -/* Graphics Routines */ -/*------------------------------------------------------------------*/ - -#define GFX_EXT_CNT 17 -/* The extension indicates the video mode the picture was intended - to be viewed in. */ -static char *gfxext[GFX_EXT_CNT]={".pcx", - ".p06", /* 640x200x2 */ - ".p40",".p41",".p42",".p43", /* 320x200x4 */ - ".p13", /* 320x200x16 */ - ".p19", /* 320x200x256 */ - ".p14",".p16", /* 640x200x16, 640x350x16 */ - ".p18", /* 640x480x16 */ - ".gif",".png",".bmp",".jpg", - ".fli",".flc"}; - - -void pictcmd(int cmd,int pict) -/* 1=show global picture, name is pictlist[pict] - 2=show room picture, name is pixlist[pict] - 3=show startup picture .P.. - */ -{ - char *base, *cmdstr; - int gmode; - FILE *pcxfile; - - if (viewer_name==NULL) return; - - if (cmd==1) base=pictlist[pict]; - else if (cmd==2) base=pixlist[pict]; - else if (cmd==3) base=game_fc->gamename; - else return; - - /* Find graphics file; determine mode from extension... */ - for(gmode=GFX_EXT_CNT-1;gmode>=0;gmode--) { - pcxfile=linopen(base,gfxext[gmode]); - if (pcxfile!=NULL) break; - } - if (pcxfile==NULL) return; - fclose(pcxfile); - - base=assemble_filename(hold_fc->path,base,gfxext[gmode]); - - cmdstr=rmalloc(strlen(base)+strlen(viewer_name)+40); - sprintf(cmdstr,"%s %s >/dev/null",viewer_name,base); - - if (!BATCH_MODE) { - endwin(); - system(cmdstr); /* Don't bother to check return status since - there's nothing we could do anyhow */ - wrefresh(mainwin); - wrefresh(statwin); - } - - rfree(cmdstr); - rfree(base); - - return; -} - - - -/*------------------------------------------------------------------*/ -/* Sound Routines */ -/*------------------------------------------------------------------*/ - -#if 0 -static rbool repeat_song=0; -static rbool suspend_song=0; -#endif - -int musiccmd(int cmd,int song) -/* For cmd=1 or 2, the name of the song is songlist[song] - The other commands don't take an additional argument. - 1=play song - 2=repeat song - 3=end repeat - 4=end song - 5=suspend song - 6=resume song - 7=clean-up - 8=turn sound on - 9=turn sound off - -1=Is a song playing? (0=false, -1=true) - -2=Is the sound on? (0=false, -1=true) -*/ -{ - if (cmd==8) { - sound_on=1; - return 0; - } - if (cmd==9) {sound_on=0;return 0;} - if (cmd==-2) return sound_on; -#if 0 - if (cmd==3) {repeat_song=0;return 0;} - if (cmd==7) { - /* Stop song */ - /* Do clean-up */ - return 0; - } - if (cmd==2) repeat_song=1; - if (cmd==1 || cmd==2) { - /* Start song playing */ - } - if (cmd==4) { - /* Stop song */ - } - if (cmd==5) { - /* Suspend song */ - } - if (cmd==6) { - /* Resume song */ - } -#endif - return 0; -} - -#endif /* REPLACE_BNW */ - - - -/*------------------------------------------------------------------*/ -/* File Selection Menu */ -/*------------------------------------------------------------------*/ - -#ifdef REPLACE_GETFILE - -void list_files(char *type, char *ext) -{ - DIR *currdir; - struct dirent *entry; - ITEM **filelist; - int filecnt, listsize; - int i,j; - - filelist=NULL; filecnt=listsize=0; maxleng=0; - currdir=opendir("."); - if (currdir==NULL) return; /* Nothing we can do except give up */ - do { - entry=readdir(currdir); - if ( entry!=NULL && check_fname(entry->d_name,ext) ) { - /* It has the right extension; add it to our list of files */ - if (filecnt>=listsize) { - listsize+=5; - filelist=rrealloc(filelist,listsize*sizeof(ITEM*)); - } - filelist[filecnt]=new_item(entry->d_name,""); - filecnt++; - } - } while (entry!=NULL); - closedir(currdir); - if (filecnt==0) return; /* No files */ -} - - writestr("Existing ");writestr(type);writestr("files:"); - - - rfree(filelist); -} - - - - -/* This opens the file refered to by fname and returns it */ -static FILE *uf_open(char *fname, char *ext, char *otype) -{ - if (otype[0]=='w') { /* Check to see if we are overwriting... */ - FILE *fd; - - fd=fopen(fname,"r"); - if (fd!=NULL) { /* File already exists */ - fclose(fd); - if (!yesno("This file already exists; overwrite?")) - /* That is, DON'T overwrite */ - return NULL; - } - } - return fopen(fname,otype); -} - - - -static char *last_save=NULL; -static char *last_log=NULL; -static char *last_script=NULL; - -FILE *get_user_file(int ft) -/* ft= 0:script, 1:save 2:restore, 3:log(read) 4:log(write) */ -/* Should return file in open state, ready to be read or written to, - as the case may be */ -{ - /* int extlen;*/ - char *fname,*otype, *ext; - char *defname; /* Default file name */ - char *p,*q; - FILE *fd; - char *ftype; - - switch (ft) { - case 0: ftype="script "; - defname=last_script; - otype="a";ext=pSCR; break; - case 1: ftype="save "; - defname=last_save; - otype="wb";ext=pSAV;break; - case 2: ftype="restore "; - defname=last_save; - otype="rb";ext=pSAV;break; - case 3: ftype="log "; - defname=last_log; - otype="r";ext=pLOG;break; - case 4: ftype="log "; - defname=last_log; - otype="w";ext=pLOG;break; - default: writeln(""); - return NULL; - } - if (otype[0]=='r') { /* List available files. */ - list_files(ftype,ext); - ftype=NULL; - } else - - writestr("Enter "); - if (ftype!=NULL) writestr(ftype); - writestr("file name"); - if (defname!=NULL) { - writestr(" ("); - writestr(defname); - writestr(")"); - } - writestr(": "); - - if (PURE_INPUT) agt_textcolor(-1); - fname=agt_input(4); - if (PURE_INPUT) agt_textcolor(-2); - - /* Delete whitespace before and after the file name. */ - for(p=fname;isspace(*p);p++); - for(q=fname;*p!=0;p++,q++) - *q=*p; - q--; - while(isspace(*q)) q--; - q++; - *q=0; - - if (q==fname) /* ie we are left with the empty string */ - if (defname==NULL) { - writeln("Never mind."); - rfree(fname); - return NULL;} - else { - rfree(fname); - fname=defname; - } - -#ifdef UNIX - if ( (ft==0 || ft==4) && *fname=='|') { /* pipe => program */ - fd=popen(fname+1,"w"); - if (fd!=NULL) ispipe[ ft==0 ? 0 : 2 ]=1; - } else if (ft==3 && *(q-1)=='|') { /* pipe <= program */ - *(q-1)=0; - fd=popen(fname,"r"); - if (fd!=NULL) ispipe[1]=1; - *(q-1)='|'; /* For next time */ - } else -#endif - { - /* We've gotten a new file name; need to add default extension */ - if (fname!=defname && strlen(ext)>0 && !check_fname(fname,ext)) - fname=remake_fname(fname,ext); - - fd=uf_open(fname,ext,otype); - } - - if (fd==NULL) { - if (fname!=defname) rfree(fname); - return NULL; - } - - switch(ft) - { - case 0: last_script=fname;break; - case 1: last_save=fname; break; - case 2: last_save=fname; break; - case 3: last_log=fname; break; - case 4: last_log=fname; break; - } - if (fname!=defname) rfree(defname); - return fd; -} - - -void set_default_filenames(const char *gamename) -{ - fix_filename=2; /* Remove path: by default, all save files go in - the *current* directory, not the game's directory */ - last_save=make_fname(gamename,pSAV); - last_log=make_fname(gamename,pLOG); - last_script=make_fname(gamename,pSCR); - fix_filename=0; -} - -#endif /* REPLACE_GETFILE */ - - - - - - - - diff --git a/app/src/main/jni/terps/agility/os_dos.c b/app/src/main/jni/terps/agility/os_dos.c deleted file mode 100644 index 89d3548..0000000 --- a/app/src/main/jni/terps/agility/os_dos.c +++ /dev/null @@ -1,2431 +0,0 @@ -/* os_msdos.c -- interface routines for MS-DOS */ -/* Copyright (C) 1996,1997,1998 Robert Masenten */ -/* */ -/* This is part of the source for the (Mostly) Universal */ -/* AGT Interpreter */ - -/* This has been written to work under Borland C (MSDOS16) - and DJGPP (MSDOS32); it hasn't been tested with other compilers. */ - -/* NOTE: The library functions for screen location put the origin - at (1,1), but curr_x, curr_y, box_startx, and box_starty have - origin (0,0). */ - - - -/* What needs work for 32-bit case: - set_font() -*/ - -/* What's done: - rgetchar() - draw_scanline() - pictcmd(): Save/restore of text mode video memory - setup_card(): Setting video-mode palette -*/ - -#define USE_EDITLINE -#define DEBUG_KEY 0 /* Turns on debugging of key functions */ - -#include -#include -#include -#include -#include -#include -#include - -#include "agility.h" -#include "interp.h" - -#include - -#ifdef __DJGPP__ -#include -#include -#include -#include -#define outp(p,d) outportb(p,d) -#endif - -#define cleareol rclreol - - -rbool use_bios; /* If true, use the BIOS routines for text output. - (for the sake of blind users.) */ - -static int colorset[5]={7,14,0,15,1}; - - -/* cs_ stands for "color scheme" */ -enum {cs_normal=0, cs_bold, cs_back, cs_statfore, cs_statback} color_scheme; -/* normal/highlight/background/statfore/statback */ - -int scroll_count; /* Count of how many lines we have printed since - last player input. */ -int status_height; -rbool have_compass; -int top_row; /* The absolute y value of the current top row. */ - -static char *gamefile_name; -static rbool font_enable; -static rbool nav_arrow; -static rbool block_cursor; -static rbool tall_screen; /* 43/50 line mode? */ - -static char *active_font; /* Currently active font; NULL if none */ -static int active_font_height; - -typedef enum {MDA,CGA,MCGA,EGA64,EGA,VGA} gh_type; -static gh_type graph_hardware; - - -static char *fkey_text[24]={ /* Text for function keys */ - "help\n", - "get ","drop ", - "examine ","read ", - "open ","close ", - "inventory\n","look\n", - "score\n", - "save\n","restore\n", - "exit\n", - "w\n","e\n","n\n","s\n", - "nw\n","sw\n","ne\n","se\n", - "enter\n","up\n","down\n" -}; - - -#if 0 -{ - "undo\n", - "get ","drop ", - "read ","unlock ", - "open ","close ", - "inventory\n","look\n", - "wait\n", - "save\n","restore\n"}; -#endif - -/* Other candidates: - view - help - examine (x) - again (g) */ - - -#ifdef __DJGPP__ -/*------------------------------------------------------------------*/ -/* 32-bit library Compatibility Layer */ -/*------------------------------------------------------------------*/ - -/* Internal coordinates have an origin of (0,0), even though the - calling coordinates are (1,1). */ - -#define rgettextinfo gettextinfo -#define r_setcursortype _setcursortype - -static int winx1,winy1,winx2,winy2,screen_attr; -#if 0 -static int winx1=0,winy1=0,winx2=79,winy2=24,screen_attr=7; -static int winx1=1,winy1=1,winx2=80,winy2=25,screen_attr=7; -#endif - -/* This has an origin of (0,0) */ -void r0gotoxy(int x, int y) -{ - union REGS r; - r.h.ah=0x02; - r.h.dh=y; - r.h.dl=x; - r.h.bh=0; /* Page 0 */ - int86(0x10,&r,&r); -} - - -void get_cur_pos(int *px, int *py) -{ - union REGS r; - r.h.ah=0x03; - r.h.bh=0; /* Page 0 */ - int86(0x10,&r,&r); - *px=r.h.dl; - *py=r.h.dh; -} - -int rtextmode(int mode) -{ - union REGS r; - struct text_info term_data; - int height; - - textmode(mode); - gettextinfo(&term_data); - height=term_data.screenheight; /* Assume PC dimensions */ - - winx1=0; winy1=0; winx2=79; winy2=height-1; - screen_attr=7; - if (!directvideo) { - r.h.ah=5; - r.h.al=0; - int86(0x10,&r,&r); /* Set active page to 0 */ - r0gotoxy(0,0); - } - return height; -} - - -void rtextattr(int attr) -{ - screen_attr=attr; - if (directvideo) textattr(attr); -} - -void rwindow(int x1, int y1, int x2, int y2) -{ - winx1=x1-1; winy1=y1-1; winx2=x2-1; winy2=y2-1; - if (directvideo) window(x1,y1,x2,y2); -} - -void rclrscr(void) -{ - union REGS r; - if (directvideo) {clrscr();return;} - r.h.ah=0x06; /* Scroll up */ - r.h.al=0x00; /* Blank window */ - r.h.ch=winy1; r.h.cl=winx1; - r.h.dh=winy2; r.h.dl=winx2; - r.h.bh=screen_attr; - int86(0x10,&r,&r); - r0gotoxy(winx1,winy1); -} - -void rclreol(void) -{ - union REGS r; - int x,y; - - if (directvideo) {clreol();return;} - get_cur_pos(&x,&y); - r.h.ah=0x06; /* Scroll up */ - r.h.al=0x00; /* Blank window */ - r.h.ch=y; r.h.cl=x; - r.h.dh=y; r.h.dl=winx2; - r.h.bh=screen_attr; - int86(0x10,&r,&r); -} - -void rinsline(void) -{ - union REGS r; - int x,y; - if (directvideo) {insline();return;} - get_cur_pos(&x,&y); - r.h.ah=0x07; /* Scroll down */ - r.h.al=0x01; /* One line */ - r.h.ch=y; r.h.cl=winx1; - r.h.dh=winy2; r.h.dl=winx2; - r.h.bh=screen_attr; - int86(0x10,&r,&r); -} - -void rnewline(int *px,int *py) -{ - union REGS r; - *px=winx1; - if (*pywinx2) - rnewline(px,py); - r0gotoxy(*px,*py); - return 0; -} - - -int rputch(char c) -{ - int x,y; - if (directvideo) return putch(c); - get_cur_pos(&x,&y); - rfastputch(c,&x,&y); - return 0; -} - - -int rputs(const char *s) -{ - int x,y; - if (directvideo) return cputs(s); - get_cur_pos(&x,&y); - for(;*s!=0;s++) - rfastputch(*s,&x,&y); - return 0; -} - - -int rgetch(void) -{ - union REGS r; - if (directvideo) return getch(); - r.h.ah=0x00; - int86(0x16,&r,&r); - return r.h.al; -} - -int rgetche(void) -{ - int c; - if (directvideo) return getche(); - c=rgetch(); - rputch(c&0xFF); - return c; -} - -void rgotoxy(int x,int y) -{ - if (directvideo) {gotoxy(x,y);return;} - r0gotoxy(x-1+winx1,y-1+winy1); -} - -int rwherex(void) -{ - int x,y; - if (directvideo) return wherex(); - get_cur_pos(&x,&y); - return x+1-winx1; -} - -int rwherey(void) -{ - int x,y; - if (directvideo) return wherey(); - get_cur_pos(&x,&y); - return y+1-winy1; -} - - - -#else /* ...if not __DJGPP__ */ - -#define rtextattr textattr -#define rwindow window -#define rgettextinfo gettextinfo -#define r_setcursortype _setcursortype -#define rclrscr clrscr -#define rclreol clreol -#define rinsline insline -#define rgotoxy gotoxy -#define rwherex wherex -#define rwherey wherey -#define rputs cputs -#define rputch putch -#define rgetche getche -#define rgetch getch - -int rtextmode(int mode) -{ - struct text_info term_data; - - textmode(mode); - gettextinfo(&term_data); - return term_data.screenheight; /* Assume PC dimensions */ -} - - - -#endif - - -/*------------------------------------------------------------------*/ -/* Text Style */ -/*------------------------------------------------------------------*/ - -#define STATUS_STATE 0x3800 -#define BOX_STATE 0x2800 -#define START_STATE 0x0800 - -/* For state: - currently low 4 bits are color. - bit 11 (0x0800) indicates we should use "normal" color - bit 12 (0x1000) indicates we are printing the status line, so - supress blinking - bit 13 (0x2000) indicates whether we are in reverse video mode or not - bit 14 (0x4000) indicates whether we are blinking or not - bit 15 (0x8000) indicates whether bold is on or not - */ - -#define BOLD_BIT 0x8000 -#define BLINK_BIT 0x4000 -#define RVID_BIT 0x2000 -#define STAT_BIT 0x1000 -#define NORM_BIT 0x0800 - -typedef unsigned short vstate; -static vstate state_stack[16]; -int stateptr=0; /* Points into state stack */ - -#define cstate state_stack[stateptr] /* Current state */ - -static void set_state(vstate state) -{ - int c; /* Color */ - int bkgd; /* Background and blink bits */ - - /* 0=normal/1=highlight/2=background/3=statfore/4=statback */ - - if (state & NORM_BIT) - c=colorset[cs_normal]; - else - c=state & 0xF; /* Extract color */ - - if (state & RVID_BIT) { /* Reverse video */ - bkgd=colorset[cs_statback]; - if (state & NORM_BIT) - c=colorset[cs_statfore]; - } else - bkgd=colorset[cs_back]; - - if (state & BOLD_BIT) - if (state & NORM_BIT) - c=colorset[cs_bold]; - else c^=0x08; /* Toggle bold bit */ - - if ( (state & BLINK_BIT) && !(state & STAT_BIT) ) - bkgd|=0x08; /* Blinking */ - - bkgd=(bkgd<<4)|c; - rtextattr(bkgd); - cstate=state; -} - -static void reset_state(void) -{ - set_state(cstate); -} - -static void push_state(vstate state) -{ - if (stateptr==15) fatal("State stack overflow!"); - stateptr++; - set_state(state); -} - -static void pop_state(void) -{ - if (stateptr==0) fatal("State stack error: POP without PUSH!"); - stateptr--; - set_state(cstate); -} - -void agt_textcolor(int c) -/* Set text color to color #c, where the colors are as follows: */ -/* 0=Black, 1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta, 6=Brown, */ -/* 7=White("normal"), 8=Blinking. */ -/* 9= *Just* White (not neccessarily "normal" and no need to turn off */ -/* blinking) */ -/* Also used to set other text attributes: */ -/* -1=emphasized text, used (e.g.) for room titles */ -/* -2=end emphasized text */ -{ - vstate nstate; - - nstate=cstate; - if (c==-1) - nstate=nstate|0x8000; - else if (c==-2) - nstate=nstate & ~0x8000; /* BOLD off */ - else if (c==8) - nstate=nstate | 0x4000; /* BLINK on */ - else if (c==7) - nstate=START_STATE; /* "Normal" */ - else if (c==9) - nstate=(nstate & ~0x080F) | 7; /* Set color to 7: white */ - else if (c>=0 && c<7) - nstate=(nstate & ~0x080F) | c; /* Set color to c */ - set_state(nstate); -} - - - -/*------------------------------------------------------------------*/ -/* Misc. Functions */ -/*------------------------------------------------------------------*/ - - -void agt_delay(int n) -{ - if (BATCH_MODE) return; - print_statline(); - sleep(n); -} - - -void agt_tone(int hz,int ms) -/* Produce a hz-Hertz sound for ms milliseconds */ -{ - if (!sound_on) return; - sound(hz); - delay(ms); - nosound(); -} - -int agt_rand(int a,int b) -/* Return random number from a to b inclusive */ -{ - return a+(rand()>>2)%(b-a+1); -} - - - -/*------------------------------------------------------------------*/ -/* Key Tables */ -/*------------------------------------------------------------------*/ - - -/* - 1000= backspace - 1001= delete - 1002= left - 1003= right - 1004= up - 1005= down - 1006= home - 1007= end - 1008= page up - 1009= page down - 1010= ins - 1011= gray plus - 1012= gray minus - 10mm= Function key F with mm=n+13 (F0==F10) - 1500= ^K - 1501= ^Y - 1502= ^L - 2000= unknown control character -*/ - -#define KEY_CNT 25 -#define FKEY_BASE 13 -#define FKEY_CNT (12+8+4) - -static char keytrans[KEY_CNT]={ - 0x00,0x53, /* Delete and backspace */ - 0x4b,0x4d,0x48,0x50, /* Arrow keys */ - 0x47,0x4F, /* Home and End */ - 0x49,0x51, /* PgUp, PgDown */ - 0x52,0x4E,0x4A, /* Ins, Plus, Minus */ - 0x44, /* F10 */ - 0x3b,0x3c,0x3d,0x3e,0x3f, /* F1-F5 */ - 0x40,0x41,0x42,0x43, /* F6-F9 */ - 0x57,0x58}; /* F11-F12 */ - - -static const char *keylist[12]={ - "del","left","right","up","down","home","end","pgup","pgdn", - "ins", "plus", "minus"}; - - - - - -/*------------------------------------------------------------------*/ -/* Line Editor */ -/*------------------------------------------------------------------*/ - -static int saved_tab=0; - -unsigned xgetch(void) -{ - union REGS r; - - r.x.ax=0; - int86(0x16,&r,&r); - return r.x.ax; -} - - -int read_a_key(void) -{ - unsigned xc; - char c; - int i; - - scroll_count=0; - if (saved_tab>0) { - saved_tab--; - return ' '; - } - xc=xgetch(); - - if (xc==0x4e2b) xc=0x4e00; /* Gray plus */ - if (xc==0x4a2d) xc=0x4a00; /* Gray minus */ - c=xc&0xFF; - if ( c!=0 ) - if (isprint(c)) return c; - else if (c=='\n' || c=='\r') return '\n'; - else if (c=='\t') { - saved_tab=4; - return ' '; - } - else if (c=='\001') /* Ctrl-A ==> Home */ - return 1006; - else if (c=='\005') /* Ctrl-E ==> End */ - return 1007; - else if (c=='\010') /* Ctrl-H ==> Backspace */ - return 1000; - else if (c=='\013') /* Ctrl-K */ - return 1500; - else if (c=='\031') /* Ctrl-Y */ - return 1501; - else if (c=='\014') /* Ctrl-L */ - return 1502; - else return 2000; - - /* Get extended code */ - c=(xc>>8)&0xFF; - for(i=0;i=FKEY_BASE) - return 1000+i; - else return 1000+FKEY_BASE+12+i-1; - } - return 2000; -} - - - - -#ifdef USE_EDITLINE - -void agt_putc(char c) -{ -#ifdef UNIX - fix_loc(); /* Fixup if returning from being suspended */ -#endif - printf("%c",c); - curr_x+=1; -} - -static rbool old_yheight=0; -static int base_x,base_y; /* Base X value of first character of input */ - -/* This assumes the cursor is always positioned on the string - being edited */ -static void update_cursor(int cursor) -{ - int curr_y; - - curr_x=base_x+cursor; - curr_y=base_y; - while (curr_x>=screen_width) { - curr_x-=screen_width; - curr_y++; - } - rgotoxy(curr_x+1,curr_y+1); -} - -/* static rbool save_accum_text=0;*/ - -static void update_line(int cursor,char *buff) -{ - int yval, yheight, xpos, i, curr_y; - - yheight=(base_x+strlen(buff)+screen_width-1)/screen_width; /* Round up */ - /* printf("<%d+%d>",base_y,yheight);*/ - rgotoxy(screen_width,screen_height); - while (base_y+yheight+status_height>screen_height && base_y>1) { - base_y--; - /* save_accum_text=1;*/ - rputs("\r\n"); - /* save_accum_text=0;*/ - } - for(yval=yheight;yval0) { /* One key */ - if (state==1) { - agt_putc(key); - agt_newline(); - } - buff[0]=key; buff[1]=0; - break; - } - -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - if (key=='\n') { - update_cursor(buffleng); - break; - } - /* add character to buffer */ - buffleng++; - if (buffleng+1>buffspace) buffspace+=20; - buff=rrealloc(buff,buffspace); - for(i=buffleng;i>cursor;i--) - buff[i]=buff[i-1]; - buff[cursor++]=key; - update_line(cursor,buff); - } - else switch(key-1000) - { /* Special key */ - case 0: /* Backspace */ - if (!editmode || cursor==0) break; - cursor--; - /* Fall through... */ - case 1: /* Delete */ - if (!editmode || buffleng==cursor) break; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - for(i=cursor;i0) - update_cursor(--cursor); - break; - case 3: /* Right arrow */ - if (editmode && cursor=histcount) { - /* Reached bottom: restore original line */ - curr_hist=histcount; - buff=savebuff; - savebuff=NULL; - } else - buff=hist[curr_hist]; - buffleng=strlen(buff); - cursor=0; - redisplay_line(buff); - break; -#endif - case 6: /* Home */ - if (!editmode) break; - cursor=0; - update_cursor(cursor); - break; - case 7: /* End */ - if (!editmode) break; - cursor=buffleng; - update_cursor(cursor); - break; - case 8: /* Page up : Scroll back */ - case 9: /* Page down */ - break; - case 500: /* Ctrl-K: Delete to EOL */ - if (!editmode) break; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - rfree(yank_text); - yank_text=rstrdup(buff+cursor); - buffleng=cursor; - buff[buffleng]=0; - update_line(cursor,buff); - break; - case 501: /* Ctrl-Y: Yank */ - if (!editmode) break; - { - int txtleng; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - if (yank_text==NULL) - txtleng=0; - else - txtleng=strlen(yank_text); - buffleng+=txtleng; - while(buffleng+1>buffspace) buffspace+=20; - buff=rrealloc(buff,buffspace); - for(i=buffleng;i>=cursor+txtleng;i--) - buff[i]=buff[i-txtleng]; - for(i=0;i=1000+FKEY_BASE+FKEY_CNT) - break; - if (!editmode) break; - { - int txtleng; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - txtleng=strlen(fkey_text[key-1000-FKEY_BASE]); - if (fkey_text[key-1000-FKEY_BASE][txtleng-1]=='\n') { - /* Newlines should only appear at the end; they indicate - that this function key should cause the line to be entered. */ - txtleng--; - exitflag=1; /* Finish entering this line */ - } - buffleng+=txtleng; - while(buffleng+1>buffspace) buffspace+=20; - buff=rrealloc(buff,buffspace); - for(i=buffleng;i>=cursor+txtleng;i--) - buff[i]=buff[i-txtleng]; - for(i=0;i10) { - printf("Console read failure.\n"); - exit(1); - } - } input_error=0; - - s=rrealloc(s,s[1]+3); - memmove(s,s+2,s[1]+1); - printf("\n"); -#endif - - printf("\n"); - script_out(s);script_out("\n"); - curr_x=rwherex()-1; - return s; -} - -char agt_getkey(rbool echo_char) -/* Reads a character and returns it, possibly reading in a full line - depending on the platform */ -/* If echo_char=1, echo character. If 0, then the character is not - required to be echoed (and ideally shouldn't be) */ -{ - char c; - char s[2]; - - scroll_count=0; - print_statline(); - - if (echo_char) - c=rgetche(); /* Get with echo */ - else c=rgetch(); /* Get w/o echo */ - if (c==0) rgetch(); /* Throw away extended character */ - if (echo_char) { - s[0]=c;s[1]=0; - script_out(s); - agt_newline(); - } - curr_x=rwherex()-1; - return c; -} - - -static void print_compass(void) -{ - int cwidth, i; - - if (status_width< 9+4*12) return; - rgotoxy(1,2); - rputs(" EXITS: ");cwidth=9; - for(i=0;i<12;i++) - if (compass_rose & (1<\n\n"); - if (script_on) fprintf(scriptfile,"\n\n\n\n"); - scroll_count=0; -} - -rbool cursor_wrap; - -void agt_puts(const char *s) -{ - int old_x; - old_x=rwherex()-1; - rputs(s); - curr_x=rwherex()-1; - if (curr_x=screen_height-status_height-1) { - rputs(" --MORE--"); /* Notice: no newline */ - agt_waitkey(); - rgotoxy(1,rwherey()); /* Move to beginning of line */ - rclreol(); /* Clear to end of line: erase the --MORE-- */ - } -} - - - - -/*------------------------------------------------------------------*/ -/* Text Box Routines */ -/*------------------------------------------------------------------*/ - - -static unsigned long boxflags; -static int box_startx; /* Starting x of box; starts from 0 */ -static int box_width; -static int delta_scroll; /* Amount we are adding to vertical scroll - with the box */ - -static void box_border(char *c) -{ -#ifdef DRAW_BORDER - agt_puts(c); -#else - agt_puts(" "); -#endif -} - - -#define VLINE_STR "\263" /* 0xB3 or 0xBA */ - -static void boxrule(int bottom) -/* Draw line at top or bottom of box */ -{ - int i; - - if (bottom) - box_border("\300"); /* 0xC0 or 0xC8 */ - else - box_border("\332"); /* 0xDA or 0xC9 */ - for(i=0;iscreen_height) curr_y=screen_height; - rgotoxy(box_startx+1,curr_y+1); - curr_x=box_startx; -} - -void agt_makebox(int width,int height,unsigned long flags) -/* Flags: TB_TTL, TB_BORDER, TB_NOCENT */ -{ - int box_starty; - - boxflags=flags; - box_width=width; - if (boxflags&TB_BORDER) { /* Add space for border */ - width+=4; - height+=2; - } - if (boxflags&TB_NOCENT) box_startx=0; - else box_startx=(screen_width-width)/2; /* Center the box horizontally */ - if (box_startx<0) box_startx=0; - -/* Now we need to compute the vertical position of the box */ - if (flags & TB_TTL) { /* Title: centered horizontally */ - box_starty=(screen_height-height)/2; - if (box_starty+height+8>screen_height) /* Make room for credits */ - box_starty=screen_height-height-8; - if (box_starty<1) box_starty=1; - delta_scroll=0; - scroll_count=0; - rwindow(1,1,screen_width,screen_height); /* Titles get the whole screen */ - is_fullscreen=1; - } else { /* Compute vertical position of non-title box */ - box_starty=rwherey()-1-height; - if (box_starty<1) { - delta_scroll=1-box_starty; - box_starty=1; - } else delta_scroll=0; - } - - curr_x=box_startx; - rgotoxy(box_startx+1,box_starty+1); - - if (boxflags&TB_BORDER) { - push_state(BOX_STATE); - boxrule(0); - boxpos(); - box_border(VLINE_STR); - agt_puts(" "); - } -} - -void agt_qnewline(void) -{ - if (boxflags&TB_BORDER) { - agt_puts(" "); - box_border(VLINE_STR); - } - boxpos(); - if (boxflags&TB_BORDER) { - box_border(VLINE_STR); - agt_puts(" "); - } -} - -void agt_endbox(void) -{ - if (boxflags&TB_BORDER) { - agt_puts(" "); - box_border(VLINE_STR); - boxpos(); - boxrule(1); - pop_state(); - } - scroll_count+=delta_scroll; - agt_newline(); /* NOT agt_qnewline() */ - if ( (boxflags&TB_TTL) ) - while(rwherey()+1>=1) - if (changes & 1) { /* Check bit */ - - if (i==0) { /* COLOR */ - int j; - s=rmalloc(5+5*15); /* More than enough space */ - strcpy(s,"color"); - for(j=0;j<5;j++) { - strcat(s," "); - strcat(s,colorname[colorset[j]]); - } - - } else { /* Non-COLOR options */ - s=rmalloc(strlen(edops[i])+4); /* Room for NO_ & \0 */ - if (!checkopt(i)) - strcpy(s,"no_"); - else s[0]=0; - strcat(s,edops[i]); - } - - if (i>=0) { /* Change existing line */ - rfree(conf[numline]); - conf[numline]=s; - } else { /* Add new line */ - conf=rrealloc(++numline); - conf[numline-1]=s; - conf[numline]=NULL; - } - - } - writeconf(fc, conf); - - for(i=0;i5) cnum=5; - for(i=0;i12) err=1; - if (n==10) n=0; - if (n>10) n--; - } - if (err) { - writeln("Unrecognized KEY name."); - return; - } - - leng=0; - for(i=0;i=0 && s[i]=='+') { - s[i]='\n'; - s[i+1]=0; - } - - if (keys_defined & (1<=2) { - set_fkey(optstr[1],optstr+2,optnum-2); - return 1; - } - if (opt("PATH") && optnum>=2) { - free_gamepath(); /* Throw away previous settings */ - gamepath=rmalloc((optnum+1)*sizeof(char*)); /* optnum-1+1 */ - gamepath[0]=""; /* ==> The current directory */ - for(i=1;i=0 && r.h.bl<=3) && - (r.h.ch & 0xF0)==0 && (r.h.cl & 0xF0)==0) { - /* Okay, the function works; we have an EGA/VGA */ - - if (r.h.bl==0) graph_hardware=EGA64; - else graph_hardware=EGA; - - r.x.ax=0x1A00; - int86(0x10,&r,&r); - if (r.h.al==0x1A) /* We have a VGA */ - graph_hardware=VGA; - - } else { /* MDA/CGA/MCGA */ - r.x.ax=0x1A00; - int86(0x10,&r,&r); - if (r.h.al==0x1A) { /* We have an MCGA */ - graph_hardware=MCGA; - return; - } - - graph_hardware=CGA; - - r.h.ah=0x0F; /* Get current video mode */ - int86(0x10,&r,&r); - if ((r.h.al & 0x7F)==7) - graph_hardware=MDA; - } -} - - -static int save_mode; -static int save_attr; - -void init_interface(int argc,char *argv[]) -{ - struct text_info term_data; - - active_font=NULL; - - id_hardware(); - - if (argc>0) progname=argv[0]; else progname=NULL; - script_on=0;scriptfile=NULL; - scroll_count=0; - cursor_wrap=0; - font_enable=1; - nav_arrow=0; - have_compass=0;status_height=0; - block_cursor=0; tall_screen=0; - center_on=par_fill_on=0; - DEBUG_OUT=0;debugfile=stderr; - rgettextinfo(&term_data); - save_mode=term_data.currmode; - save_attr=term_data.attribute; - directvideo=0; /* During startup, go through BIOS. */ - use_bios=0; - rtextmode(C80); /* Change to color, 80 column mode */ - screen_height=25; /* Assume PC dimensions */ - status_width=screen_width=80; - rclrscr(); - rwindow(1,1,screen_width,screen_height); is_fullscreen=1; - top_row=1; - rgotoxy(1,1); /* Upper-left hand corner of just defined window */ -} - -void start_interface(fc_type fc) -{ - if (tall_screen) { - screen_height=rtextmode(C4350); /* Change to color, 80 column mode */ - rclrscr(); - rgotoxy(1,1); /* Upper-left hand corner of just defined window */ - } - directvideo=!use_bios; /* Set directvideo according to options */ - free_gamepath(); - if (stable_random) - srand(6); - else - srand(time(0)); - gamefile_name=fc->gamename; - if (block_cursor) - r_setcursortype(_SOLIDCURSOR); - else - r_setcursortype(_NORMALCURSOR); - rclrscr(); - curr_x=0;scroll_count=0; - if (have_compass) - status_height=2; - else - status_height=1; - rwindow(1,1,screen_width,screen_height); /* Set window to whole screen */ - is_fullscreen=1; /* We use the whole screen until the first status line - is printed */ - top_row=status_height+1; - set_state(7); -} - -void close_interface(void) -{ - if (scriptfile!=NULL) - fclose(scriptfile); - agt_newline();agt_newline(); - if (block_cursor) r_setcursortype(_NORMALCURSOR); - rtextmode(save_mode); - rtextattr(save_attr); - rgotoxy(1,25); - rclreol(); - rgotoxy(1,24); - rclreol(); - /* rclrscr();*/ -} - - - - - - -#ifdef REPLACE_BNW - -/*------------------------------------------------------------------*/ -/* GRAPHICS AND FONT SUPPORT */ -/*------------------------------------------------------------------*/ - - -/* This cheats a bit, using "hidden" data from filename.c */ - -static FILE *linopen(char *name, char *ext) -{ - FILE *f; - char *fname; - - fname=assemble_filename(hold_fc->path,name,ext); - f=fopen(fname,"rb"); - rfree(fname); - return f; -} - -/*------------------------------------------------------------------*/ -/* FONT Routines */ -/*------------------------------------------------------------------*/ - -static char *save_font; -static int save_font_height; - -static int set_font(char *fontdef, int font_height) -{ -#ifdef MSDOS16 - struct REGPACK r; - - r.r_ax=0x1100; - r.r_bx=font_height<<8; /* 8 bytes per character in BH; 0 in BL */ - r.r_cx=256; /* Number of characters defined */ - r.r_dx=0; /* Start at ASCII 0. */ - r.r_es=((long)fontdef)>>16; - r.r_bp=((long)fontdef)&0xFFFF; - intr(0x10,&r); - -#else /* MSDOS32 */ - - __dpmi_regs r; - - /* If the transfer buffer isn't large enough, we just silently fail. - We should really do something like allocate our own buffer - in this case. */ - if (font_height*256>_go32_info_block.size_of_transfer_buffer) - return 1; - - r.x.ax=0x1100; - r.h.bh=font_height; /* 8 bytes per character in BH; 0 in BL */ - r.h.bl=0; - r.x.cx=256; /* Number of characters defined */ - r.x.dx=0; /* Start at ASCII 0. */ - dosmemput(fontdef,font_height*256, __tb); - r.x.es=__tb>>4; /* Segment */ - r.x.bp=__tb&0x0F; /* Offset */ - __dpmi_int(0x10,&r); -#endif - return 0; -} - - -static void save_old_font(void) -{ - union REGS r; - - if (graph_hardware.FNT) -*/ -{ - FILE *fontfile; - char *buff, *fontname; - int height; - - if (!font_enable) return; - - if (cmd==2) - save_old_font(); - if (!font_enable) return; - - - if (cmd==0 || cmd==2) { - if (cmd==0) { - fontname=fontlist[font]; - } - else fontname=gamefile_name; - - fontfile=linopen(fontname,".fnt"); - if (fontfile==NULL) return; - fseek(fontfile,0,SEEK_END); - height=ftell(fontfile); - if (height%256!=0) { - /* Error message */ - return; - } - height=height/256; - buff=rmalloc(256*height); - memset(buff,0,256*height); - - fseek(fontfile,0,SEEK_SET); - if (fread(buff,height,256,fontfile)!=256) { - fclose(fontfile); - rfree(buff); - return; - } - fclose(fontfile); - if (set_font(buff,height)) { - /* Print error message */ - } - rfree(active_font); - active_font=buff; - active_font_height=height; - return; - } else if (cmd==1) { - rfree(active_font); - restore_font(); - } -} - - - - - -/*------------------------------------------------------------------*/ -/* Graphics Support */ -/*------------------------------------------------------------------*/ - -static rbool in_gmode=0; - -static char *gfxext[]={".P06", - ".P40",".P41",".P42",".P43", /* 0-4: CGA */ - ".P13", /* 5: EGA */ - ".P19", /* 6: MCGA */ - ".P14",".P16", /* 7-8: EGA */ - ".P18"}; /* 9: VGA */ - -/* Modes 1-4 differ only in pallette */ - -/* 0 1 2 3 4 5 6 7 8 9 */ -static int paltype[]={0, 1, 1, 1, 1, 2, 3, 2, 2, 2}; -static int mode_x[]={640,320,320,320,320, 320,320, 640,640, 640}; -static int mode_y[]={200,200,200,200,200, 200,200, 200,350, 480}; -static int mode[] ={ 6, 4, 4, 4, 4, 13, 19, 14, 16, 18}; - -/* paltype is the log_2 of the bit depth */ -/* Mode 16 with lowmem EGA only has 2bpp */ -/* Mode to start from for each video type */ -/* MDA, CGA, MCGA, EGA65, EGA, VGA */ -static int start_mode[]={-1,4,6,7,8,9}; - - -int pick_gmode(int gmode, int pmode, int xsize, int ysize) -{ - int save_gmode, work_gmode; - - if (gmode!=-1) /* Check that gmode is consitent with file */ - if (mode_x[gmode]>=xsize && mode_y[gmode]>=ysize && - paltype[gmode]==pmode) - return gmode; - - save_gmode=gmode; work_gmode=-1; - /* Okay, we don't know what mode we are; try to pick the best for - this image */ - /* work_gmode will contain the highest resolution mode with the - neccessary color depth; if we can't find a perfect mode, we'll - use this and clip. */ - for(gmode=0;gmode<=start_mode[graph_hardware];gmode++) { - if (gmode==6 && (graph_hardware==EGA || graph_hardware==EGA64)) - continue; - if (gmode==5 && graph_hardware==MCGA) continue; - - if (paltype[gmode]!=pmode) continue; - work_gmode=gmode; - if (mode_x[gmode] bitplanes) - 3: 0x00 (Function select: replace) - 5: 0x00 (Write and read mode 0) - 8: 0xFF (Bit Mask) */ - - /* First, basic initalization. Most of these are default values, - but it doesn't hurt to be careful */ - outp(0x3CE,0x01); /* Enable Set/Reset Register */ - outp(0x3CF,0x00); /* ... ignore Set/Reset register */ - outp(0x3CE,0x03); /* Function Select Register */ - outp(0x3CF,0x00); /* ... replace and don't rotate */ - outp(0x3CE,0x05); /* Mode Register */ - outp(0x3CF,0x00); /* ... write and read mode 0 */ - outp(0x3CE,0x08); /* Bit Mask Register */ - outp(0x3CF,0xFF); /* ... write to everything */ - } - return; - } - - target+=mode_bpl; /* Move to beginning of next line */ - - if (paltype[gmode]!=2) { /* The easy case: just one plane */ - linebuff[writesize-1]&=end_mask; - graphwrite(target,linebuff,writesize); - } else { /* 4 planes, 1 bit/pixel/plane */ - /* 3C4/3C5: Video Sequencer Registers - 2: Map Mask Register */ - for(i=0;i<4;i++) { - outp(0x3C4,2); /* Map Mask Register */ - outp(0x3C5,mmr[i]); /* ... select the given bitplane */ - linebuff[linesize*i+writesize-1]&=end_mask; - graphwrite(target,linebuff+linesize*i,writesize); - } - } -} - - - -/* This flips the bits and separates them by three bits */ -static const uchar paltrans[]={0,8,1,9}; - - -static uchar build_ega_pal(uchar red, uchar green, uchar blue) - /* Construct 6-bit color code, on pattern - 00rgbRGB, from Rrxxxxxx, Ggxxxxxx, Bbxxxxxx */ -{ - red>>=6; - green>>=6; - blue>>=6; - return paltrans[blue]+(paltrans[green]<<1)+(paltrans[red]<<2); -} - - -/* When dacflag is 0, this sets the video palette; - when dacflag is 1, it sets the DAC registers instead */ -static void bios_set_pal(uchar *palptr, unsigned leng, rbool dacflag) -{ -#ifdef MSDOS16 - union REGS r; - struct SREGS segreg; -#else /* MSDOS32 */ - __dpmi_regs r; -#endif - - if (!dacflag) - r.x.ax=0x1002; - else { - r.x.ax=0x1012; - r.x.bx=0; - r.x.cx=leng; - } -#ifdef MSDOS16 - r.x.dx=((long)palptr)&0xFFFF; - segreg.es=((long)palptr)>>16; - int86x(0x10,&r,&r,&segreg); -#else /* MSDOS32 */ - dosmemput(palptr,leng*(dacflag?3:1), __tb); - r.x.dx=__tb & 0x000F; /* Offset */ - r.x.es=__tb>>4; /* Segment */ - __dpmi_int(0x10,&r); -#endif -} - - -#define ival(n) (header[n]+(header[n+1]<<8)) - - -static rbool setup_card(FILE *pcxfile,uchar *header,int gmode, int pmode) -{ - int i; - uchar *tmppal, *pal; - int havepal; /* 0=No, 1=Yes, but not VGA, 2=Yes, maybe VGA */ - union REGS r; - - if (header[1]==5) havepal=2; - else if (header[1]==2) havepal=1; - else havepal=0; - - if (pmode==3 && havepal!=2) { - writeln("ERROR: PCX file corrupted: bad color depth."); - return 0; - } - - /*-------------------------------------*/ - /* Read in VGA palette */ - /*-------------------------------------*/ - - /* Next, read in the VGA palette if neccessary */ - pal=NULL; - if (pmode==3) { /* VGA palette */ - uchar c; - long n; - - pal=rmalloc(256*3); - fseek(pcxfile,0,SEEK_END); - n=ftell(pcxfile); - if (fseek(pcxfile,n-256*3-1,SEEK_SET) - || fread(&c,1,1,pcxfile)!=1) { - writeln("GAME ERROR: Errors reading picture file."); - rfree(pal); - return 0; - } - if (c!=12) { - writeln("ERROR: PCX file corrupted: bad palette."); - rfree(pal); - return 0; - } - if (fread(pal,768,1,pcxfile)!=1) { - writeln("GAME ERROR: Errors reading palette from picture file."); - rfree(pal); - return 0; - } - } - - - /*-------------------------------------*/ - /* Set up video mode */ - /*-------------------------------------*/ - - /* -- Need to save old video state here -- */ - - /* Set video mode */ - r.x.ax=mode[gmode]; - int86(0x10,&r,&r); - in_gmode=1; - - /*-------------------------------------*/ - /* Set up Palette */ - /*-------------------------------------*/ - -#if 0 - if (pmode==2 && paltype[gmode]==3) { - /* Set up fake EGA palette */ - pal=rmalloc(256*3); - for(i=0;i<3*16;i++) - pal[i]=header[16+i]; - for(i=3*16;i<3*256;i++) - pal[i]=0; - } else if (pmode<=1 && paltype[gmode]==2) { - /* This could occur with a high resolution 2 or 4 color image */ - - fatal("Unsupported image class."); - - } else assert(pmode==paltype[gmode]); -#endif - - assert(pmode==paltype[gmode]); - - /* Now to set the palette */ - if (paltype[gmode]==1) { /* CGA palette */ - r.h.ah=0x0B; - r.h.bh=1; - if (pmode==1 && havepal!=0) - r.h.bl=(header[19]>>6)&0x01; - else - r.h.bl=(gmode-1)>>1; /* Top bit==> palette */ - int86(0x10,&r,&r); - - r.h.ah=0x0B; /* Set background and intensity bits */ - r.h.bh=0; - if (pmode==1 && havepal!=0) - r.h.bl= ( (header[19]>>1) & 0x10 ) | (header[16]>>4); - else - r.h.bl=((gmode-1)&1)<<4; /* Background will be 0. */ - } - else if (paltype[gmode]==2 && havepal!=0) { /* EGA Palette */ - tmppal=rmalloc(17); - if (graph_hardware!=VGA) - for(i=0;i<16;i++) - tmppal[i]=build_ega_pal(header[16+3*i], - header[17+3*i], - header[18+3*i]); - else for(i=0;i<16;i++) tmppal[i]=i+1; /* For VGA hardware, point to DAC */ - tmppal[16]=0; /* Set overscan to 0 */ - bios_set_pal(tmppal,17,0); - rfree(tmppal); - - if (graph_hardware==VGA) { /* Now reprogram the DAC */ - tmppal=rmalloc(17*3); - for(i=0;i<16;i++) { - tmppal[3+3*i]=header[16+3*i]>>2; - tmppal[4+3*i]=header[17+3*i]>>2; - tmppal[5+3*i]=header[18+3*i]>>2; - } - tmppal[0]=tmppal[1]=tmppal[2]=0; /* Overscan color is black */ - bios_set_pal(tmppal,17,1); - } - } else if (paltype[gmode]==3 && havepal!=0) { /* MCGA Palette */ - for(i=0;i<256*3;i++) - pal[i]>>=2; - bios_set_pal(pal,256,1); - } - return 1; -} - - -#ifdef DEBUG_VIDCARD -static int test_pattern(int y, int p) -{ - if (p==1) return (1<<(y%8)); - return 0; -} -#endif - -static int save_pmode; /* Debugging only */ - - - -#define PCX_BUFFSIZE 16000 -static uchar *fbuff; -static int fb_index; - -static int readbyte(FILE *f) -{ - int n; - - if (fb_index==PCX_BUFFSIZE) { - n=fread(fbuff,1,PCX_BUFFSIZE,f); - if (n==0) return EOF; - if (nmode_x[gmode]) xsize=mode_x[gmode]; - if (ysize>mode_y[gmode]) ysize=mode_y[gmode]; - - save_pmode=pmode; - - if (!setup_card(pcxfile,header,gmode,pmode)) return; - - - /*-------------------------------------*/ - /* Draw picture */ - /*-------------------------------------*/ - - fseek(pcxfile,128,SEEK_SET); /* Beginning of picture data */ - - linesize=ival(66); - linebuff=rmalloc(linesize*header[65]); - - y_ofs=(mode_y[gmode]-ysize)/2; - - /* This will set up the scanline drawing routines */ - draw_scanline(NULL,gmode,y_ofs,linesize,xsize); - -#ifdef DEBUG_VIDCARD - for(i=0;i0 && j0) {save_pmode=-3;return;} - } else - linebuff[j++]=c; - } - draw_scanline(linebuff,gmode,y_ofs+i,linesize,xsize); - } - rfree(fbuff); - rfree(linebuff); -} - - - - -void pictcmd(int cmd,int pict) -/* 1=show global picture, name is pictlist[pict] - 2=show room picture, name is pixlist[pict] - 3=Show title picture. - */ -{ - union REGS r; - char *base; - int gmode; - FILE *pcxfile=NULL; - - int savex,savey; - char *save_vidmem; - - if (graph_hardware==MDA) return; /* MDA is out */ - - if (cmd==1) base=pictlist[pict]; - else if (cmd==2) base=pixlist[pict]; - else if (cmd==3) base=gamefile_name; - else return; - - while(kbhit()) rgetch(); /* Discard any buffered keypresses */ - - /* Find graphics file; determine mode from extension... */ - for(gmode=start_mode[graph_hardware];gmode>=0;gmode--) { - if (gmode==6 && (graph_hardware==EGA || graph_hardware==EGA64)) - continue; /* EGA should skip MCGA mode */ - if (gmode==5 && graph_hardware==MCGA) continue; /* ... and conversely */ - pcxfile=linopen(base,gfxext[gmode]); - if (pcxfile!=NULL) break; - } - if (gmode==-1) { - pcxfile=linopen(base,".pcx"); - if (pcxfile==NULL) return; - /* Leave gmode as -1 */ - } - - in_gmode=0; - savex=rwherex(); - savey=rwherey(); -#ifdef MSDOS16 - save_vidmem=rmalloc(2*25*80); - memcpy(save_vidmem,(void*)0xB8000000L,2*25*80); -#else /* MSDOS32 */ - if (graph_hardware>MCGA) - save_vidmem=rmalloc(2*ScreenRows()*ScreenCols()); - else - save_vidmem=rmalloc(2*25*80); - ScreenRetrieve(save_vidmem); -#endif - - display_PCX(pcxfile,gmode); - - fclose(pcxfile); - - /*-------------------------------------*/ - /* Wait for key and restore text mode */ - /*-------------------------------------*/ - - if (in_gmode) { - - if (!BATCH_MODE) rgetch(); /* Wait for a key-press */ - - r.x.ax=0x0003; /* Restore text mode */ - int86(0x10,&r,&r); - -#ifdef MSDOS16 - memcpy((void*)0xB8000000L,save_vidmem,2*25*80); /* Restore video mem */ -#else /* MSDOS32 */ - ScreenUpdate(save_vidmem); -#endif - rgotoxy(savex,savey); /* Restore cursor position */ - if (active_font!=NULL) /* Restore font, if neccessary */ - set_font(active_font,active_font_height); - reset_state(); - - /* -- Need to restore old video state here -- */ - /* -- Primary font (16*256=4K) */ - /* -- Screen memory (2*25*80=4K) */ - /* -- Cursor position and current screen attributes */ - - } - /* rprintf("Mode: %d\n",save_pmode); */ - rfree(save_vidmem); -} - - - -int musiccmd(int cmd,int song) -/* For cmd=1 or 2, the name of the song is songlist[song] - The other commands don't take an additional argument. - 1=play song - 2=repeat song - 3=end repeat - 4=end song - 5=suspend song - 6=resume song - 7=clean-up - 8=turn sound on - 9=turn sound off - -1=Is a song playing? (0=false, -1=true) - -2=Is the sound on? (0=false, -1=true) -*/ -{ - if (cmd==8) sound_on=1; - else if (cmd==9) sound_on=0; - if (cmd==-1) return sound_on; - return 0; -} - -#endif /* REPLACE_BNW */ diff --git a/app/src/main/jni/terps/agility/os_glk.c b/app/src/main/jni/terps/agility/os_glk.c deleted file mode 100644 index 56ec50a..0000000 --- a/app/src/main/jni/terps/agility/os_glk.c +++ /dev/null @@ -1,6784 +0,0 @@ -/* vi: set ts=2 shiftwidth=2 expandtab: - * - * Copyright (C) 2002-2006 Simon Baldwin, simon_baldwin@yahoo.com - * Mac portions Copyright (C) 2002 Ben Hines - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of version 2 of the GNU General Public License - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 - * USA - */ - -/* - * Glk interface for AGiliTy 1.1.1 - * ------------------------------- - * - * This module contains the the Glk porting layer for AGiliTy. It - * defines the Glk arguments list structure, the entry points for the - * Glk library framework to use, and all platform-abstracted I/O to - * link to Glk's I/O. - * - * The following items are omitted from this Glk port: - * - * o Calls to glk_tick(). The Glk documentation states that the - * interpreter should call glk_tick() every opcode or so. This is - * intrusive to code (it goes outside of this module), and since - * most Glk libraries do precisely nothing in glk_tick(), there is - * little motivation to add it. - * - * o Glk tries to assert control over _all_ file I/O. It's just too - * disruptive to add it to existing code, so for now, the AGiliTy - * interpreter is still dependent on stdio and the like. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef GLK_ANSI_ONLY -# if !defined (__USE_POSIX) -# define __USE_POSIX /* Gets fdopen() definition. */ -# include -# undef __USE_POSIX -# else -# include -# endif - -# if TARGET_RT_MAC_CFM -# include - /* Sys/types.h absent on CW MSL (aka CFM), replace with fcntls. */ -# include -# define FD_SETSIZE 1024 - /* - * CW's MSL defines exec() in unistd.h which conflicts with exec in - * interp. To work around this I'll put prototypes of the stuff we - * use from it here. - */ - _MSL_IMP_EXP_C int close (int); -# else -# include -# include -# include -# include -# endif -#else -# include -#endif - -#include "agility.h" -#include "interp.h" - -#include "glk.h" - -/* - * True and false definitions -- usually defined in glkstart.h, but we need - * them early, so we'll define them here too. We also need NULL, but that's - * normally from stdio.h or one of it's cousins. - */ -#ifndef FALSE -# define FALSE 0 -#endif -#ifndef TRUE -# define TRUE (!FALSE) -#endif - - -/*---------------------------------------------------------------------*/ -/* Module variables, miscellaneous externals not in header files */ -/*---------------------------------------------------------------------*/ - -/* Glk AGiliTy port version number. */ -static const glui32 GAGT_PORT_VERSION = 0x00010701; - -/* - * We use two Glk windows; one is two lines at the top of the display area - * for status, and the other is the remainder of the display area, used for, - * well, everything else. Where a particular Glk implementation won't do - * more than one window, the status window remains NULL. - */ -static winid_t gagt_main_window = NULL, - gagt_status_window = NULL; - -/* - * Transcript stream and input log. These are NULL if there is no current - * collection of these strings. - */ -static strid_t gagt_transcript_stream = NULL, - gagt_inputlog_stream = NULL; - -/* Input read log stream, for reading back an input log. */ -static strid_t gagt_readlog_stream = NULL; - -/* Options that may be turned off or set by command line flags. */ -static enum { - FONT_AUTOMATIC, FONT_FIXED_WIDTH, FONT_PROPORTIONAL, FONT_DEBUG -} -gagt_font_mode = FONT_AUTOMATIC; -static enum { - DELAY_FULL, DELAY_SHORT, DELAY_OFF -} -gagt_delay_mode = DELAY_SHORT; -static int gagt_replacement_enabled = TRUE, - gagt_extended_status_enabled = TRUE, - gagt_abbreviations_enabled = TRUE, - gagt_commands_enabled = TRUE; - -/* Forward declaration of event wait functions. */ -static void gagt_event_wait (glui32 wait_type, event_t * event); -static void gagt_event_wait_2 (glui32 wait_type_1, - glui32 wait_type_2, - event_t * event); - -/* - * Forward declaration of the glk_exit() wrapper. Normal functions in this - * module should not to call glk_exit() directly; they should always call it - * through the wrapper instead. - */ -static void gagt_exit (void); - - -/*---------------------------------------------------------------------*/ -/* Glk port utility functions */ -/*---------------------------------------------------------------------*/ - -/* - * gagt_fatal() - * - * Fatal error handler. The function returns, expecting the caller to - * abort() or otherwise handle the error. - */ -static void -gagt_fatal (const char *string) -{ - /* - * If the failure happens too early for us to have a window, print - * the message to stderr. - */ - if (!gagt_main_window) - { - fprintf (stderr, "\n\nINTERNAL ERROR: %s\n", string); - - fprintf (stderr, "\nPlease record the details of this error, try to" - " note down everything you did to cause it, and email" - " this information to simon_baldwin@yahoo.com.\n\n"); - return; - } - - /* Cancel all possible pending window input events. */ - glk_cancel_line_event (gagt_main_window, NULL); - glk_cancel_char_event (gagt_main_window); - - /* Print a message indicating the error. */ - glk_set_window (gagt_main_window); - glk_set_style (style_Normal); - glk_put_string ("\n\nINTERNAL ERROR: "); - glk_put_string ((char *) string); - - glk_put_string ("\n\nPlease record the details of this error, try to" - " note down everything you did to cause it, and email" - " this information to simon_baldwin@yahoo.com.\n\n"); -} - - -/* - * gagt_malloc() - * gagt_realloc() - * - * Non-failing malloc and realloc; call gagt_fatal() and exit if memory - * allocation fails. - */ -static void * -gagt_malloc (size_t size) -{ - void *pointer; - - pointer = malloc (size); - if (!pointer) - { - gagt_fatal ("GLK: Out of system memory"); - gagt_exit (); - } - - return pointer; -} - -static void * -gagt_realloc (void *ptr, size_t size) -{ - void *pointer; - - pointer = realloc (ptr, size); - if (!pointer) - { - gagt_fatal ("GLK: Out of system memory"); - gagt_exit (); - } - - return pointer; -} - - -/* - * gagt_strncasecmp() - * gagt_strcasecmp() - * - * Strncasecmp and strcasecmp are not ANSI functions, so here are local - * definitions to do the same jobs. - */ -static int -gagt_strncasecmp (const char *s1, const char *s2, size_t n) -{ - size_t index; - - for (index = 0; index < n; index++) - { - int diff; - - diff = glk_char_to_lower (s1[index]) - glk_char_to_lower (s2[index]); - if (diff < 0 || diff > 0) - return diff < 0 ? -1 : 1; - } - - return 0; -} - -static int -gagt_strcasecmp (const char *s1, const char *s2) -{ - size_t s1len, s2len; - int result; - - s1len = strlen (s1); - s2len = strlen (s2); - - result = gagt_strncasecmp (s1, s2, s1len < s2len ? s1len : s2len); - if (result < 0 || result > 0) - return result; - else - return s1len < s2len ? -1 : s1len > s2len ? 1 : 0; -} - - -/* - * gagt_debug() - * - * Handler for module debug output. If no debug, it ignores the call, - * otherwise it prints a debug message, prefixed by the function name. - */ -static void -gagt_debug (const char *function, const char *format, ...) -{ - if (DEBUG_OUT) - { - fprintf (debugfile, "%s (", function); - if (format && strlen (format) > 0) - { - va_list ap; - - va_start (ap, format); - vfprintf (debugfile, format, ap); - va_end (ap); - } - - fprintf (debugfile, ")\n"); - fflush (debugfile); - } -} - - -/*---------------------------------------------------------------------*/ -/* Functions not ported - functionally unchanged from os_none.c */ -/*---------------------------------------------------------------------*/ - -/* - * agt_tone() - * - * Produce a hz-Hertz sound for ms milliseconds. - */ -void -agt_tone (int hz, int ms) -{ - gagt_debug ("agt_tone", "hz=%d, ms=%d", hz, ms); -} - - -/* - * agt_rand() - * - * Return random number from a to b inclusive. The random number generator - * is seeded on the first call, to a reproducible sequence if stable_random, - * otherwise using time(). - */ -int -agt_rand (int a, int b) -{ - static int is_initialized = FALSE; - - int result; - - if (!is_initialized) - { - srand (stable_random ? 6 : time (0)); - - is_initialized = TRUE; - gagt_debug ("agt_rand", "[initialized]"); - } - - result = a + (rand () >> 2) % (b - a + 1); - gagt_debug ("agt_rand", "a=%d, b=%d -> %d", a, b, result); - return result; -} - - -/*---------------------------------------------------------------------*/ -/* Workrounds for bugs in core AGiliTy. */ -/*---------------------------------------------------------------------*/ - -/* - * gagt_workround_menus() - * - * Somewhere in AGiliTy's menu handling stuff is a condition that sets up - * an eventual NULL dereference in rstrncpy(), called from num_name_func(). - * For some reason, perhaps memory overruns, perhaps something else, it - * happens after a few turns have been made through agt_menu(). Replacing - * agt_menu() won't avoid it. - * - * However, the menu stuff isn't too useful, or attractive, in a game, so one - * solution is to simply disable it. While not possible to do this directly, - * there is a sneaky way, using our carnal knowledge of core AGiliTy. In - * runverb.c, there is code to prevent menu mode from being turned on where - * verbmenu is NULL. Verbmenu is set up in agil.c on loading the game, but, - * crucially, is set up before agil.c calls start_interface(). So... here - * we can free it, set it to NULL, set menu_mode to 0 (it probably is already) - * and AGiliTy behaves as if the game prevents menu mode. - */ -static void -gagt_workround_menus (void) -{ - free (verbmenu); - verbmenu = NULL; - - menu_mode = 0; -} - - -/* - * gagt_workround_fileexist() - * - * This function verifies that the game file can be opened, in effect second- - * guessing run_game(). - * - * AGiliTy's fileexist() has in it either a bug, or a misfeature. It always - * passes a nofix value of 1 into try_open_file(), which defeats the code to - * retry with both upper and lower cased filenames. So here we have to go - * round the houses, with readopen()/readclose(). - */ -static int -gagt_workround_fileexist (fc_type fc, filetype ft) -{ - genfile file; - char *errstr; - - errstr = NULL; - file = readopen (fc, ft, &errstr); - free (errstr); - - if (file) - { - readclose (file); - return TRUE; - } - return FALSE; -} - - -/*---------------------------------------------------------------------*/ -/* I/O interface start and stop functions. */ -/*---------------------------------------------------------------------*/ - -/* AGiliTy font_status values that indicate what font may be used. */ -enum { - GAGT_FIXED_REQUIRED = 1, GAGT_PROPORTIONAL_OKAY = 2 -}; - - -/* - * start_interface() - * close_interface() - * - * Startup and shutdown callout points. The start function for Glk looks - * at the value of font_status that the game sets, to see if it has a strong - * view of the font to use. If it does, then we'll reflect that in the - * module's font contol, perhaps overriding any command line options that the - * user has passed in. - */ -void -start_interface (fc_type fc) -{ - switch (font_status) - { - case GAGT_FIXED_REQUIRED: - gagt_font_mode = FONT_FIXED_WIDTH; - break; - - case GAGT_PROPORTIONAL_OKAY: - gagt_font_mode = FONT_PROPORTIONAL; - break; - - default: - break; - } - - gagt_workround_menus (); - - gagt_debug ("start_interface", "fc=%p", fc); -} - -void -close_interface (void) -{ - if (filevalid (scriptfile, fSCR)) - close_pfile (scriptfile, 0); - - gagt_debug ("close_interface", ""); -} - - -/*---------------------------------------------------------------------*/ -/* Code page 437 to ISO 8859 Latin-1 translations */ -/*---------------------------------------------------------------------*/ - -/* - * AGiliTy uses IBM code page 437 characters, and Glk works in ISO 8859 - * Latin-1. There's some good news, in that a number of the characters, - * especially international ones, in these two sets are the same. The bad - * news is that, for codes above 127 (that is, beyond 7-bit ASCII), or for - * codes below 32, they live in different places. So, here is a table of - * conversions for codes not equivalent to 7-bit ASCII, and a pair of - * conversion routines. - * - * Note that some code page 437 characters don't have ISO 8859 Latin-1 - * equivalents. Predominantly, these are the box-drawing characters, which - * is a pity, because these are the ones that are used the most. Anyway, - * in these cases, the table substitutes an approximated base ASCII char- - * acter in its place. - * - * The first entry of table comments below is the character's UNICODE value, - * just in case it's useful at some future date. - */ -typedef const struct -{ - const unsigned char cp437; /* Code page 437 character. */ - const unsigned char iso8859_1; /* ISO 8859 Latin-1 character. */ -} gagt_char_t; -typedef gagt_char_t *gagt_charref_t; - -static gagt_char_t GAGT_CHAR_TABLE[] = { - /* - * Low characters -- those below 0x20. These are the really odd code - * page 437 characters, rarely used by AGT games. Low characters are - * omitted from the reverse lookup, and participate only in the forwards - * lookup from code page 437 to ISO 8859 Latin-1. - */ - {0x01, '@'}, /* 263a White smiling face */ - {0x02, '@'}, /* 263b Black smiling face */ - {0x03, '?'}, /* 2665 Black heart suit */ - {0x04, '?'}, /* 2666 Black diamond suit */ - {0x05, '?'}, /* 2663 Black club suit */ - {0x06, '?'}, /* 2660 Black spade suit */ - {0x07, 0xb7}, /* 2022 Bullet */ - {0x08, 0xb7}, /* 25d8 Inverse bullet */ - {0x09, 0xb7}, /* 25e6 White bullet */ - {0x0a, 0xb7}, /* 25d9 Inverse white circle */ - {0x0b, '?'}, /* 2642 Male sign */ - {0x0c, '?'}, /* 2640 Female sign */ - {0x0d, '?'}, /* 266a Eighth note */ - {0x0e, '?'}, /* 266b Beamed eighth notes */ - {0x0f, 0xa4}, /* 263c White sun with rays */ - {0x10, '>'}, /* 25b6 Black right-pointing triangle */ - {0x11, '<'}, /* 25c0 Black left-pointing triangle */ - {0x12, 0xa6}, /* 2195 Up down arrow */ - {0x13, '!'}, /* 203c Double exclamation mark */ - {0x14, 0xb6}, /* 00b6 Pilcrow sign */ - {0x15, 0xa7}, /* 00a7 Section sign */ - {0x16, '#'}, /* 25ac Black rectangle */ - {0x17, 0xa6}, /* 21a8 Up down arrow with base */ - {0x18, '^'}, /* 2191 Upwards arrow */ - {0x19, 'v'}, /* 2193 Downwards arrow */ - {0x1a, '>'}, /* 2192 Rightwards arrow */ - {0x1b, '<'}, /* 2190 Leftwards arrow */ - {0x1c, '?'}, /* 2310 Reversed not sign */ - {0x1d, '-'}, /* 2194 Left right arrow */ - {0x1e, '^'}, /* 25b2 Black up-pointing triangle */ - {0x1f, 'v'}, /* 25bc Black down-pointing triangle */ - - /* - * High characters -- those above 0x7f. These are more often used by AGT - * games, particularly for box drawing. - */ - {0x80, 0xc7}, /* 00c7 Latin capital letter c with cedilla */ - {0x81, 0xfc}, /* 00fc Latin small letter u with diaeresis */ - {0x82, 0xe9}, /* 00e9 Latin small letter e with acute */ - {0x83, 0xe2}, /* 00e2 Latin small letter a with circumflex */ - {0x84, 0xe4}, /* 00e4 Latin small letter a with diaeresis */ - {0x85, 0xe0}, /* 00e0 Latin small letter a with grave */ - {0x86, 0xe5}, /* 00e5 Latin small letter a with ring above */ - {0x87, 0xe7}, /* 00e7 Latin small letter c with cedilla */ - {0x88, 0xea}, /* 00ea Latin small letter e with circumflex */ - {0x89, 0xeb}, /* 00eb Latin small letter e with diaeresis */ - {0x8a, 0xe8}, /* 00e8 Latin small letter e with grave */ - {0x8b, 0xef}, /* 00ef Latin small letter i with diaeresis */ - {0x8c, 0xee}, /* 00ee Latin small letter i with circumflex */ - {0x8d, 0xec}, /* 00ec Latin small letter i with grave */ - {0x8e, 0xc4}, /* 00c4 Latin capital letter a with diaeresis */ - {0x8f, 0xc5}, /* 00c5 Latin capital letter a with ring above */ - {0x90, 0xc9}, /* 00c9 Latin capital letter e with acute */ - {0x91, 0xe6}, /* 00e6 Latin small ligature ae */ - {0x92, 0xc6}, /* 00c6 Latin capital ligature ae */ - {0x93, 0xf4}, /* 00f4 Latin small letter o with circumflex */ - {0x94, 0xf6}, /* 00f6 Latin small letter o with diaeresis */ - {0x95, 0xf2}, /* 00f2 Latin small letter o with grave */ - {0x96, 0xfb}, /* 00fb Latin small letter u with circumflex */ - {0x97, 0xf9}, /* 00f9 Latin small letter u with grave */ - {0x98, 0xff}, /* 00ff Latin small letter y with diaeresis */ - {0x99, 0xd6}, /* 00d6 Latin capital letter o with diaeresis */ - {0x9a, 0xdc}, /* 00dc Latin capital letter u with diaeresis */ - {0x9b, 0xa2}, /* 00a2 Cent sign */ - {0x9c, 0xa3}, /* 00a3 Pound sign */ - {0x9d, 0xa5}, /* 00a5 Yen sign */ - {0x9e, 'p'}, /* 20a7 Peseta sign */ - {0x9f, 'f'}, /* 0192 Latin small letter f with hook */ - {0xa0, 0xe1}, /* 00e1 Latin small letter a with acute */ - {0xa1, 0xed}, /* 00ed Latin small letter i with acute */ - {0xa2, 0xf3}, /* 00f3 Latin small letter o with acute */ - {0xa3, 0xfa}, /* 00fa Latin small letter u with acute */ - {0xa4, 0xf1}, /* 00f1 Latin small letter n with tilde */ - {0xa5, 0xd1}, /* 00d1 Latin capital letter n with tilde */ - {0xa6, 0xaa}, /* 00aa Feminine ordinal indicator */ - {0xa7, 0xba}, /* 00ba Masculine ordinal indicator */ - {0xa8, 0xbf}, /* 00bf Inverted question mark */ - {0xa9, '.'}, /* 2310 Reversed not sign */ - {0xaa, 0xac}, /* 00ac Not sign */ - {0xab, 0xbd}, /* 00bd Vulgar fraction one half */ - {0xac, 0xbc}, /* 00bc Vulgar fraction one quarter */ - {0xad, 0xa1}, /* 00a1 Inverted exclamation mark */ - {0xae, 0xab}, /* 00ab Left-pointing double angle quotation mark */ - {0xaf, 0xbb}, /* 00bb Right-pointing double angle quotation mark */ - {0xb0, '#'}, /* 2591 Light shade */ - {0xb1, '#'}, /* 2592 Medium shade */ - {0xb2, '#'}, /* 2593 Dark shade */ - {0xb3, '|'}, /* 2502 Box light vertical */ - {0xb4, '+'}, /* 2524 Box light vertical and left */ - {0xb5, '+'}, /* 2561 Box vertical single and left double */ - {0xb6, '|'}, /* 2562 Box vertical double and left single */ - {0xb7, '+'}, /* 2556 Box down double and left single */ - {0xb8, '+'}, /* 2555 Box down single and left double */ - {0xb9, '+'}, /* 2563 Box double vertical and left */ - {0xba, '|'}, /* 2551 Box double vertical */ - {0xbb, '\\'}, /* 2557 Box double down and left */ - {0xbc, '/'}, /* 255d Box double up and left */ - {0xbd, '+'}, /* 255c Box up double and left single */ - {0xbe, '+'}, /* 255b Box up single and left double */ - {0xbf, '\\'}, /* 2510 Box light down and left */ - {0xc0, '\\'}, /* 2514 Box light up and right */ - {0xc1, '+'}, /* 2534 Box light up and horizontal */ - {0xc2, '+'}, /* 252c Box light down and horizontal */ - {0xc3, '+'}, /* 251c Box light vertical and right */ - {0xc4, '-'}, /* 2500 Box light horizontal */ - {0xc5, '+'}, /* 253c Box light vertical and horizontal */ - {0xc6, '|'}, /* 255e Box vertical single and right double */ - {0xc7, '|'}, /* 255f Box vertical double and right single */ - {0xc8, '\\'}, /* 255a Box double up and right */ - {0xc9, '/'}, /* 2554 Box double down and right */ - {0xca, '+'}, /* 2569 Box double up and horizontal */ - {0xcb, '+'}, /* 2566 Box double down and horizontal */ - {0xcc, '+'}, /* 2560 Box double vertical and right */ - {0xcd, '='}, /* 2550 Box double horizontal */ - {0xce, '+'}, /* 256c Box double vertical and horizontal */ - {0xcf, '='}, /* 2567 Box up single and horizontal double */ - {0xd0, '+'}, /* 2568 Box up double and horizontal single */ - {0xd1, '='}, /* 2564 Box down single and horizontal double */ - {0xd2, '+'}, /* 2565 Box down double and horizontal single */ - {0xd3, '+'}, /* 2559 Box up double and right single */ - {0xd4, '+'}, /* 2558 Box up single and right double */ - {0xd5, '+'}, /* 2552 Box down single and right double */ - {0xd6, '+'}, /* 2553 Box down double and right single */ - {0xd7, '+'}, /* 256b Box vertical double and horizontal single */ - {0xd8, '+'}, /* 256a Box vertical single and horizontal double */ - {0xd9, '/'}, /* 2518 Box light up and left */ - {0xda, '/'}, /* 250c Box light down and right */ - {0xdb, '@'}, /* 2588 Full block */ - {0xdc, '@'}, /* 2584 Lower half block */ - {0xdd, '@'}, /* 258c Left half block */ - {0xde, '@'}, /* 2590 Right half block */ - {0xdf, '@'}, /* 2580 Upper half block */ - {0xe0, 'a'}, /* 03b1 Greek small letter alpha */ - {0xe1, 0xdf}, /* 00df Latin small letter sharp s */ - {0xe2, 'G'}, /* 0393 Greek capital letter gamma */ - {0xe3, 'p'}, /* 03c0 Greek small letter pi */ - {0xe4, 'S'}, /* 03a3 Greek capital letter sigma */ - {0xe5, 's'}, /* 03c3 Greek small letter sigma */ - {0xe6, 0xb5}, /* 00b5 Micro sign */ - {0xe7, 't'}, /* 03c4 Greek small letter tau */ - {0xe8, 'F'}, /* 03a6 Greek capital letter phi */ - {0xe9, 'T'}, /* 0398 Greek capital letter theta */ - {0xea, 'O'}, /* 03a9 Greek capital letter omega */ - {0xeb, 'd'}, /* 03b4 Greek small letter delta */ - {0xec, '.'}, /* 221e Infinity */ - {0xed, 'f'}, /* 03c6 Greek small letter phi */ - {0xee, 'e'}, /* 03b5 Greek small letter epsilon */ - {0xef, '^'}, /* 2229 Intersection */ - {0xf0, '='}, /* 2261 Identical to */ - {0xf1, 0xb1}, /* 00b1 Plus-minus sign */ - {0xf2, '>'}, /* 2265 Greater-than or equal to */ - {0xf3, '<'}, /* 2264 Less-than or equal to */ - {0xf4, 'f'}, /* 2320 Top half integral */ - {0xf5, 'j'}, /* 2321 Bottom half integral */ - {0xf6, 0xf7}, /* 00f7 Division sign */ - {0xf7, '='}, /* 2248 Almost equal to */ - {0xf8, 0xb0}, /* 00b0 Degree sign */ - {0xf9, 0xb7}, /* 2219 Bullet operator */ - {0xfa, 0xb7}, /* 00b7 Middle dot */ - {0xfb, '/'}, /* 221a Square root */ - {0xfc, 'n'}, /* 207f Superscript latin small letter n */ - {0xfd, 0xb2}, /* 00b2 Superscript two */ - {0xfe, '#'}, /* 25a0 Black square */ - {0xff, 0xa0}, /* 00a0 No-break space */ - {0, 0} /* 0000 [END OF TABLE] */ -}; - - -/* - * gagt_cp_to_iso() - * - * Convert a string from code page 437 into ISO 8859 Latin-1. The input and - * output buffers may be one and the same. - */ -static void -gagt_cp_to_iso (const unsigned char *from_string, unsigned char *to_string) -{ - static int is_initialized = FALSE; - static unsigned char table[UCHAR_MAX + 1]; - - int index; - unsigned char cp437, iso8859_1; - assert (from_string && to_string); - - if (!is_initialized) - { - gagt_charref_t entry; - - /* - * Create a lookup entry for each code in the main table. Fill in gaps - * for 7-bit characters with their ASCII equivalent values. Any - * remaining codes not represented in the main table will map to zeroes - * in the lookup table, as static variables are initialized to zero. - */ - for (entry = GAGT_CHAR_TABLE; entry->cp437; entry++) - { - cp437 = entry->cp437; - iso8859_1 = entry->iso8859_1; - - assert (cp437 < 0x20 || (cp437 > SCHAR_MAX && cp437 <= UCHAR_MAX)); - table[cp437] = iso8859_1; - } - for (index = 0; index <= SCHAR_MAX; index++) - { - if (table[index] == 0) - table[index] = index; - } - - is_initialized = TRUE; - } - - for (index = 0; from_string[index] != '\0'; index++) - { - cp437 = from_string[index]; - iso8859_1 = table[cp437]; - - to_string[index] = iso8859_1 ? iso8859_1 : cp437; - } - - to_string[index] = '\0'; -} - - -/* - * gagt_iso_to_cp() - * - * Convert a string from ISO 8859 Latin-1 to code page 437. The input and - * output buffers may be one and the same. - */ -static void -gagt_iso_to_cp (const unsigned char *from_string, unsigned char *to_string) -{ - static int is_initialized = FALSE; - static unsigned char table[UCHAR_MAX + 1]; - - int index; - unsigned char iso8859_1, cp437; - assert (from_string && to_string); - - if (!is_initialized) - { - gagt_charref_t entry; - - /* - * Create a reverse lookup entry for each code in the main table, - * overriding all of the low table entries (that is, anything under - * 128) with their ASCII no matter what the table contained. - * - * Any codes not represented in the main table will map to zeroes in - * the reverse lookup table, since static variables are initialized to - * zero. The first 128 characters are equivalent to ASCII. Moreover, - * some ISO 8859 Latin-1 entries are faked as base ASCII; where an - * entry is already occupied, the main table entry is skipped, so the - * match, which is n:1 in the reverse direction, works in first-found - * mode. - */ - for (entry = GAGT_CHAR_TABLE; entry->iso8859_1; entry++) - { - cp437 = entry->cp437; - iso8859_1 = entry->iso8859_1; - - assert (iso8859_1 <= UCHAR_MAX); - if (table[iso8859_1] == 0) - table[iso8859_1] = cp437; - } - for (index = 0; index <= SCHAR_MAX; index++) - table[index] = index; - - is_initialized = TRUE; - } - - for (index = 0; from_string[index] != '\0'; index++) - { - iso8859_1 = from_string[index]; - cp437 = table[iso8859_1]; - - to_string[index] = cp437 ? cp437 : iso8859_1; - } - - to_string[index] = '\0'; -} - - -/*---------------------------------------------------------------------*/ -/* Glk port status line functions */ -/*---------------------------------------------------------------------*/ - -/* - * Buffered copy of the latest status line passed in by the interpreter. - * Buffering it means it's readily available to print for Glk libraries - * that don't support separate windows. We also need a copy of the last - * status buffer printed for non-windowing Glk libraries, for comparison. - */ -static char *gagt_status_buffer = NULL, - *gagt_status_buffer_printed = NULL; - -/* - * Indication that we are in mid-delay. The delay is silent, and can look - * kind of confusing, so to try to make it less so, we'll have the status - * window show something about it. - */ -static int gagt_inside_delay = FALSE; - - -/* - * agt_statline() - * - * This function is called from our call to print_statline(). Here we'll - * convert the string and buffer in an allocated area for later use. - */ -void -agt_statline (const char *cp_string) -{ - assert (cp_string); - - free (gagt_status_buffer); - gagt_status_buffer = gagt_malloc (strlen (cp_string) + 1); - gagt_cp_to_iso (cp_string, gagt_status_buffer); - - gagt_debug ("agt_statline", "string='%s'", cp_string); -} - - -/* - * gagt_status_update_extended() - * - * Helper for gagt_status_update() and gagt_status_in_delay(). This function - * displays the second line of any extended status display, giving a list of - * exits from the compass rose, and if in an AGT delay, a waiting indicator. - */ -static void -gagt_status_update_extended (void) -{ - glui32 width, height; - assert (gagt_status_window); - - glk_window_get_size (gagt_status_window, &width, &height); - if (height > 1) - { - int index, exit; - - /* Clear the second status line only. */ - glk_window_move_cursor (gagt_status_window, 0, 1); - glk_set_window (gagt_status_window); - for (index = 0; index < width; index++) - glk_put_char (' '); - - /* - * Check bits in the compass rose, and print out exit names from - * the exitname[] array. - */ - glk_window_move_cursor (gagt_status_window, 0, 1); - glk_put_string (" Exits: "); - for (exit = 0; exit < sizeof (exitname) / sizeof (exitname[0]); exit++) - { - if (compass_rose & (1 << exit)) - { - glk_put_string ((char *) exitname[exit]); - glk_put_char (' '); - } - } - - /* If the delay flag is set, print a waiting indicator at the right. */ - if (gagt_inside_delay) - { - glk_window_move_cursor (gagt_status_window, - width - strlen ("Waiting... "), 1); - glk_put_string ("Waiting... "); - } - - glk_set_window (gagt_main_window); - } -} - - -/* - * gagt_status_update() - * - * - * This function calls print_statline() to prompt the interpreter into calling - * our agt_statline(), then if we have a status window, displays the status - * string, and calls gagt_status_update_extended() if necessary to handle the - * second status line. If we don't see a call to our agt_statline, we output - * a default status string. - */ -static void -gagt_status_update (void) -{ - glui32 width, height; - assert (gagt_status_window); - - glk_window_get_size (gagt_status_window, &width, &height); - if (height > 0) - { - glk_window_clear (gagt_status_window); - glk_window_move_cursor (gagt_status_window, 0, 0); - glk_set_window (gagt_status_window); - - /* Call print_statline() to refresh status line buffer contents. */ - print_statline (); - - /* See if we have a buffered status line available. */ - if (gagt_status_buffer) - { - glui32 print_width; - - /* - * Print the basic buffered status string, truncating to the - * current status window width if necessary, then try adding a - * second line if extended status enabled. - */ - print_width = width < strlen (gagt_status_buffer) - ? width : strlen (gagt_status_buffer); - glk_put_buffer (gagt_status_buffer, print_width); - - if (gagt_extended_status_enabled) - gagt_status_update_extended (); - } - else - { - /* - * We don't (yet) have a status line. Perhaps we're at the - * very start of a game. Print a standard message. - */ - glk_put_string ("Glk AGiliTy version 1.1.1"); - } - - glk_set_window (gagt_main_window); - } -} - - -/* - * gagt_status_print() - * - * Print the current contents of the completed status line buffer out in the - * main window, if it has changed since the last call. This is for non- - * windowing Glk libraries. - * - * Like gagt_status_update(), this function calls print_statline() to prompt - * the interpreter into calling our agt_statline(), then if we have a new - * status line, it prints it. - */ -static void -gagt_status_print (void) -{ - /* Call print_statline() to refresh status line buffer contents. */ - print_statline (); - - /* - * Do no more if there is no status line to print, or if the status - * line hasn't changed since last printed. - */ - if (!gagt_status_buffer - || (gagt_status_buffer_printed - && strcmp (gagt_status_buffer, gagt_status_buffer_printed) == 0)) - return; - - /* Set fixed width font to try to preserve status line formatting. */ - glk_set_style (style_Preformatted); - - /* - * Bracket, and output the status line buffer. We don't need to put any - * spacing after the opening bracket or before the closing one, because - * AGiliTy puts leading/trailing spaces on its status lines. - */ - glk_put_string ("["); - glk_put_string (gagt_status_buffer); - glk_put_string ("]\n"); - - /* Save the details of the printed status buffer. */ - free (gagt_status_buffer_printed); - gagt_status_buffer_printed = gagt_malloc (strlen (gagt_status_buffer) + 1); - strcpy (gagt_status_buffer_printed, gagt_status_buffer); -} - - -/* - * gagt_status_notify() - * - * Front end function for updating status. Either updates the status window - * or prints the status line to the main window. - * - * Functions interested in updating the status line should call either this - * function, or gagt_status_redraw(), and not print_statline(). - */ -static void -gagt_status_notify (void) -{ - if (!BATCH_MODE) - { - if (gagt_status_window) - gagt_status_update (); - else - gagt_status_print (); - } -} - - -/* - * gagt_status_redraw() - * - * Redraw the contents of any status window with the buffered status string. - * This function handles window sizing, and updates the interpreter with - * status_width, so may, and should, be called on resize and arrange events. - * - * Functions interested in updating the status line should call either this - * function, or gagt_status_notify(), and not print_statline(). - */ -static void -gagt_status_redraw (void) -{ - if (!BATCH_MODE) - { - if (gagt_status_window) - { - glui32 width, height; - winid_t parent; - - /* - * Measure the status window, and update the interpreter's - * status_width variable. - */ - glk_window_get_size (gagt_status_window, &width, &height); - status_width = width; - - /* - * Rearrange the status window, without changing its actual - * arrangement in any way. This is a hack to work round - * incorrect window repainting in Xglk; it forces a complete - * repaint of affected windows on Glk window resize and - * arrange events, and works in part because Xglk doesn't - * check for actual arrangement changes in any way before - * invalidating its windows. The hack should be harmless to - * Glk libraries other than Xglk, moreover, we're careful to - * activate it only on resize and arrange events. - */ - parent = glk_window_get_parent (gagt_status_window); - glk_window_set_arrangement (parent, - winmethod_Above | winmethod_Fixed, - height, NULL); - - gagt_status_update (); - } - } -} - - -/* - * gagt_status_in_delay() - * - * Tells status line functions whether the game is delaying, or not. This - * function updates the extended status line, if present, automatically. - */ -static void -gagt_status_in_delay (int inside_delay) -{ - if (!BATCH_MODE) - { - /* Save the new delay status flag. */ - gagt_inside_delay = inside_delay; - - /* - * Update just the second line of the status window display, if - * extended status is being displayed. - */ - if (gagt_status_window && gagt_extended_status_enabled) - gagt_status_update_extended (); - } -} - - -/* - * gagt_status_cleanup() - * - * Free memory resources allocated by status line functions. Called on game - * end. - */ -static void -gagt_status_cleanup (void) -{ - free (gagt_status_buffer); - gagt_status_buffer = NULL; - - free (gagt_status_buffer_printed); - gagt_status_buffer_printed = NULL; -} - - -/*---------------------------------------------------------------------*/ -/* Glk port color and text attribute handling */ -/*---------------------------------------------------------------------*/ - -/* - * AGT color and character attribute definitions. This is the range of - * values passed in to agt_textcolor(). - */ -enum { - AGT_BLACK = 0, - AGT_BLUE = 1, - AGT_GREEN = 2, - AGT_CYAN = 3, - AGT_RED = 4, - AGT_MAGENTA = 5, - AGT_BROWN = 6, - AGT_NORMAL = 7, - AGT_BLINKING = 8, - AGT_WHITE = 9, - AGT_FIXED_FONT = 10, - AGT_VARIABLE_FONT = 11, - AGT_EMPHASIS = -1, - AGT_DE_EMPHASIS = -2 -}; - -/* - * AGiliTy colors and text attributes seem a bit confused. Let's see if we - * can sort them out. Sadly, once we have, it's often not possible to - * render the full range in all Glk's anyway. Nevertheless... - */ -typedef struct { - int color; /* Text color. */ - int blink; /* Text blinking flag. */ - int fixed; /* Text fixed font flag. */ - int emphasis; /* Text emphasized flag. */ -} gagt_attrset_t; - -/* - * Attributes as currently set by AGiliTy. The default values set up here - * correspond to AGT_NORMAL. - */ -static gagt_attrset_t gagt_current_attribute_set = { AGT_WHITE, FALSE, - FALSE, FALSE }; - -/* - * An extra flag to indicate if we have coerced fixed font override. On - * some occasions, we need to ensure that we get fixed font no matter what - * the game says. - */ -static int gagt_coerced_fixed = FALSE; - -/* - * Bit masks for packing colors and attributes. Normally, I don't like - * bit-twiddling all that much, but for packing all of the above into a - * single byte, that's what we need. Stuff color into the low four bits, - * convenient since color is from 0 to 9, then use three bits for the other - * attributes. - */ -static const unsigned char GAGT_COLOR_MASK = 0x0f, - GAGT_BLINK_MASK = 1 << 4, - GAGT_FIXED_MASK = 1 << 5, - GAGT_EMPHASIS_MASK = 1 << 6; - -/* Forward declaration of message function. */ -static void gagt_standout_string (const char *message); - - -/* - * agt_textcolor() - * - * The AGiliTy porting guide defines the use of this function as: - * - * Set text color to color #c, where the colors are as follows: - * 0=Black, 1=Blue, 2=Green, 3=Cyan, - * 4=Red, 5=Magenta, 6=Brown, - * 7=Normal("White"-- which may actually be some other color) - * This should turn off blinking, bold, color, etc. and restore - * the text mode to its default appearance. - * 8=Turn on blinking. - * 9= *Just* White (not neccessarily "normal" and no need to turn off - * blinking) - * 10=Turn on fixed pitch font. - * 11=Turn off fixed pitch font - * Also used to set other text attributes: - * -1=emphasized text, used (e.g.) for room titles - * -2=end emphasized text - * - * Here we try to make sense of all this. Given an argument, we'll try to - * update our separated color and text attributes flags to reflect the - * expected text rendering. - */ -void -agt_textcolor (int color) -{ - switch (color) - { - case AGT_BLACK: - case AGT_BLUE: - case AGT_GREEN: - case AGT_CYAN: - case AGT_RED: - case AGT_MAGENTA: - case AGT_BROWN: - case AGT_WHITE: - gagt_current_attribute_set.color = color; - break; - - case AGT_NORMAL: - gagt_current_attribute_set.color = AGT_WHITE; - gagt_current_attribute_set.blink = FALSE; - gagt_current_attribute_set.fixed = FALSE; - gagt_current_attribute_set.emphasis = FALSE; - break; - - case AGT_BLINKING: - gagt_current_attribute_set.blink = TRUE; - break; - - case AGT_FIXED_FONT: - gagt_current_attribute_set.fixed = TRUE; - break; - - case AGT_VARIABLE_FONT: - gagt_current_attribute_set.fixed = FALSE; - break; - - case AGT_EMPHASIS: - gagt_current_attribute_set.emphasis = TRUE; - break; - - case AGT_DE_EMPHASIS: - gagt_current_attribute_set.emphasis = FALSE; - break; - - default: - gagt_fatal ("GLK: Unknown color encountered"); - gagt_exit (); - } - - gagt_debug ("agt_textcolor", "color=% d -> %d%s%s%s", - color, - gagt_current_attribute_set.color, - gagt_current_attribute_set.blink ? " blink" : "", - gagt_current_attribute_set.fixed ? " fixed" : "", - gagt_current_attribute_set.emphasis ? " bold" : ""); -} - - -/* - * gagt_coerce_fixed_font() - * - * This coerces, or relaxes, a fixed font setting. Used by box drawing, to - * ensure that we get a temporary fixed font setting for known differenti- - * ated parts of game output text. Pass in TRUE to coerce fixed font, and - * FALSE to relax it. - */ -static void -gagt_coerce_fixed_font (int coerce) -{ - gagt_coerced_fixed = coerce; -} - - -/* - * gagt_pack_attributes() - * - * Pack a set of color and text rendering attributes into a single byte, - * and return it. This function is used so that a set of text attributes - * can be encoded into a byte array that parallels the output strings that - * we buffer from the interpreter. - */ -static unsigned char -gagt_pack_attributes (const gagt_attrset_t * attribute_set, int coerced) -{ - unsigned char packed; - assert (attribute_set); - - /* Set the initial result to be color; these are the low bits. */ - assert ((attribute_set->color & ~GAGT_COLOR_MASK) == 0); - packed = attribute_set->color; - - /* - * Now OR in the text attributes settings, taking either the value for - * fixed or the coerced fixed font. - */ - packed |= attribute_set->blink ? GAGT_BLINK_MASK : 0; - packed |= attribute_set->fixed || coerced ? GAGT_FIXED_MASK : 0; - packed |= attribute_set->emphasis ? GAGT_EMPHASIS_MASK : 0; - - return packed; -} - - -/* - * gagt_unpack_attributes() - * - * Unpack a set of packed current color and text rendering attributes from a - * single byte, and return the result of unpacking. This reconstitutes the - * text attributes that were current at the time of packing. - */ -static void -gagt_unpack_attributes (unsigned char packed, gagt_attrset_t * attribute_set) -{ - assert (attribute_set); - - attribute_set->color = packed & GAGT_COLOR_MASK; - attribute_set->blink = (packed & GAGT_BLINK_MASK) != 0; - attribute_set->fixed = (packed & GAGT_FIXED_MASK) != 0; - attribute_set->emphasis = (packed & GAGT_EMPHASIS_MASK) != 0; -} - - -/* - * gagt_pack_current_attributes() - * - * Pack the current color and text rendering attributes into a single byte, - * and return it. - */ -static unsigned char -gagt_pack_current_attributes (void) -{ - return gagt_pack_attributes (&gagt_current_attribute_set, gagt_coerced_fixed); -} - - -/* - * gagt_init_user_styles() - * - * Attempt to set up two defined styles, User1 and User2, to represent - * fixed font with AGT emphasis (rendered as Glk subheader), and fixed font - * with AGT blink (rendered as Glk emphasis), respectively. - * - * The Glk stylehints here may not actually be honored by the Glk library. - * We'll try to detect this later on. - */ -static void -gagt_init_user_styles (void) -{ - /* - * Set User1 to be fixed width, bold, and not italic. Here we're sort of - * assuming that the style starts life equal to Normal. - */ - glk_stylehint_set (wintype_TextBuffer, style_User1, - stylehint_Proportional, 0); - glk_stylehint_set (wintype_TextBuffer, style_User1, stylehint_Weight, 1); - glk_stylehint_set (wintype_TextBuffer, style_User1, stylehint_Oblique, 0); - - /* - * Set User2 to be fixed width, normal, and italic, with the same - * assumptions. - */ - glk_stylehint_set (wintype_TextBuffer, style_User2, - stylehint_Proportional, 0); - glk_stylehint_set (wintype_TextBuffer, style_User2, stylehint_Weight, 0); - glk_stylehint_set (wintype_TextBuffer, style_User2, stylehint_Oblique, 1); -} - - -/* - * gagt_confirm_appearance() - * - * Attempt to find out if a Glk style's on screen appearance matches a given - * expectation. There's a chance (often 100% with current Xglk) that we - * can't tell, in which case we'll play safe, and say that it doesn't (our - * caller is hoping it does). - * - * That is, when we return FALSE, we mean either it's not as expected, or we - * don't know. - */ -static int -gagt_confirm_appearance (glui32 style, glui32 stylehint, glui32 expected) -{ - glui32 result; - - if (glk_style_measure (gagt_main_window, style, stylehint, &result)) - { - /* - * Measurement succeeded, so return TRUE if the result matches the - * caller's expectation. - */ - if (result == expected) - return TRUE; - } - - /* No straight answer, or the style's stylehint failed to match. */ - return FALSE; -} - - -/* - * gagt_is_style_fixed() - * gagt_is_style_bold() - * gagt_is_style_oblique() - * - * Convenience functions for gagt_select_style(). A return of TRUE indicates - * that the style has this attribute; FALSE indicates either that it hasn't, - * or that it's not determinable. - */ -static int -gagt_is_style_fixed (glui32 style) -{ - return gagt_confirm_appearance (style, stylehint_Proportional, 0); -} - -static int -gagt_is_style_bold (glui32 style) -{ - return gagt_confirm_appearance (style, stylehint_Weight, 1); -} - -static int -gagt_is_style_oblique (glui32 style) -{ - return gagt_confirm_appearance (style, stylehint_Oblique, 1); -} - - -/* - * gagt_select_style() - * - * Given a set of AGT text attributes, this function returns a Glk style that - * is suitable (or more accurately, the best we can come up with) for render- - * ing this set of attributes. - * - * For now, we ignore color totally, and just concentrate on the other attr- - * ibutes. This is because few, if any, games use color (no Photopia here), - * few Glk libraries, at least on Linux, allow fine grained control over text - * color, and even if you can get it, the scarcity of user-defined styles in - * Glk makes it too painful to contemplate. - */ -static glui32 -gagt_select_style (gagt_attrset_t * attribute_set) -{ - glui32 style; - assert (attribute_set); - - /* - * Glk styles are mutually exclusive, so here we'll work here by making a - * precedence selection: AGT emphasis take precedence over AGT blinking, - * which itself takes precedence over normal text. Fortunately, few, if - * any, AGT games set both emphasis and blinking (not likely to be a - * pleasant combination). - * - * We'll try to map AGT emphasis to Glk Subheader, AGT blink to Glk - * Emphasized, and normal text to Glk Normal, with modifications to this - * for fixed width requests. - * - * First, then, see if emphasized text is requested in the attributes. - */ - if (attribute_set->emphasis) - { - /* - * Consider whether something requested a fixed width font or - * disallowed a proportional one. - * - * Glk Preformatted is boring, flat, and lifeless. It often offers no - * fine grained control over emphasis, and so on. So here we try to - * find something better. However, not all Glk libraries implement - * stylehints, so we need to try to be careful to ensure that we get a - * fixed width font, no matter what else we may miss out on. - */ - if (attribute_set->fixed) - { - /* - * To start off, we'll see if User1, the font we set up for fixed - * width bold, really is fixed width and bold. If it is, we'll - * use it. - * - * If it isn't, we'll check Subheader. Our Glk library probably - * isn't implementing stylehints, but if Subheader is fixed width, - * it may provide a better look than Preformatted -- certainly - * it's worth a go. - * - * If Subheader isn't fixed width, we'll take another look at User1. - * It could be that the check for bold wasn't definitive, but it - * is nevertheless bold. So check for fixed width -- if set, it's - * probably good enough to use this font, certainly no worse than - * Preformatted. - * - * If Subheader isn't guaranteed fixed width, nor is User1, we're - * cornered into Preformatted. - */ - if (gagt_is_style_fixed (style_User1) - && gagt_is_style_bold (style_User1)) - style = style_User1; - - else if (gagt_is_style_fixed (style_Subheader)) - style = style_Subheader; - - else if (gagt_is_style_fixed (style_User1)) - style = style_User1; - - else - style = style_Preformatted; - } - else - /* This is the easy case, use Subheader. */ - style = style_Subheader; - } - else if (attribute_set->blink) - { - /* - * Again, consider whether something requested a fixed width - * font or disallowed a proportional one. - */ - if (attribute_set->fixed) - { - /* - * As above, try to find something better than Preformatted, first - * trying User2, then Emphasized, then User2 again, and finally - * settling for Preformatted if neither of these two looks any - * better. - */ - if (gagt_is_style_fixed (style_User2) - && gagt_is_style_oblique (style_User2)) - style = style_User2; - - else if (gagt_is_style_fixed (style_Emphasized)) - style = style_Emphasized; - - else if (gagt_is_style_fixed (style_User2)) - style = style_User2; - - else - style = style_Preformatted; - } - else - /* This is the easy case, use Emphasized. */ - style = style_Emphasized; - } - else - { - /* - * There's no emphasis or blinking in the attributes. In this case, - * use Preformatted for fixed width, and Normal for text that can be - * rendered proportionally. - */ - if (attribute_set->fixed) - style = style_Preformatted; - else - style = style_Normal; - } - - return style; -} - - -/*---------------------------------------------------------------------*/ -/* Glk port output buffering functions */ -/*---------------------------------------------------------------------*/ - -/* - * Buffering game output happens at two levels. The first level is a single - * line buffer, used to catch text sent to us with agt_puts(). In parallel - * with the text strings, we keep and buffer the game text attributes, as - * handed to agt_textcolor(), that are in effect at the time the string is - * handed to us, packed for brevity. - * - * As each line is completed, by a call to agt_newline(), this single line - * buffer is transferred to a main text page buffer. The main page buffer - * has places in it where we can assign paragraph, font hints, and perhaps - * other marker information to a line. Initially unset, they're filled in - * at the point where we need to display the buffer. - */ - -/* - * Definition of font hints values. Font hints may be: - * o none, for lines not in a definite paragraph; - * o proportional, for lines that can probably be safely rendered in a - * proportional font (if the AGT game text attributes allow it) and - * where the newline may be replaced by a space; - * o proportional_newline, for lines that may be rendered using a - * proportional font, but where the newline looks like it matters; - * o proportional_newline_standout, for proportional_newline lines that - * are also standout (for spacing in display functions); - * o fixed_width, for tables and other text that looks like it is a - * candidate for fixed font output. - */ -typedef enum { - HINT_NONE, - HINT_PROPORTIONAL, - HINT_PROPORTIONAL_NEWLINE, - HINT_PROPORTIONAL_NEWLINE_STANDOUT, - HINT_FIXED_WIDTH -} gagt_font_hint_t; - -/* Magic number used to ensure a pointer points to a page buffer line. */ -static const unsigned int GAGT_LINE_MAGIC = 0x5bc14482; - -/* - * Definition of a single line buffer. This is a growable string and a - * parallel growable attributes array. The string is buffered without any - * null terminator -- not needed since we retain length. - */ -typedef struct { - unsigned char *data; /* Buffered character data. */ - unsigned char *attributes; /* Parallel character attributes, packed. */ - int allocation; /* Bytes allocated to each of the above. */ - int length; /* Amount of data actually buffered. */ -} gagt_string_t; -typedef gagt_string_t * gagt_stringref_t; - -/* - * Definition of a page buffer entry. This is a structure that holds the - * the result of a single line buffer above, plus additional areas that - * describe line text positioning, a blank line flag, a paragraph pointer - * (NULL if not in a paragraph), and a font hint. - */ -typedef struct gagt_line_s *gagt_lineref_t; -typedef struct gagt_paragraph_s *gagt_paragraphref_t; - -struct gagt_line_s -{ - unsigned int magic; /* Assertion check dog-tag. */ - - gagt_string_t buffer; /* Buffered line string data. */ - - int indent; /* Line indentation. */ - int outdent; /* Trailing line whitespace. */ - int real_length; /* Real line length. */ - int is_blank; /* Line blank flag. */ - int is_hyphenated; /* Line hyphenated flag. */ - - gagt_paragraphref_t paragraph; /* Paragraph containing the line. */ - gagt_font_hint_t font_hint; /* Line's font hint. */ - - gagt_lineref_t next; /* List next element. */ - gagt_lineref_t prior; /* List prior element. */ -}; - -/* - * Definition of the actual page buffer. This is a doubly-linked list of - * lines, with a tail pointer to facilitate adding entries at the end. - */ -static gagt_lineref_t gagt_page_head = NULL, - gagt_page_tail = NULL; - -/* - * Definition of the current output line; this one is appended to on - * agt_puts(), and transferred into the page buffer on agt_newline(). - */ -static gagt_string_t gagt_current_buffer = { NULL, NULL, 0, 0 }; - -/* - * gagt_string_append() - * gagt_string_transfer() - * gagt_string_free() - * - * String append, move, and allocation free for string_t buffers. - */ -static void -gagt_string_append (gagt_stringref_t buffer, const char *string, - unsigned char packed_attributes) -{ - int length, bytes; - - /* - * Find the size we'll need from the line buffer to add this string, - * and grow buffer if necessary. - */ - length = strlen (string); - for (bytes = buffer->allocation; bytes < buffer->length + length; ) - bytes = bytes == 0 ? 1 : bytes << 1; - - if (bytes > buffer->allocation) - { - buffer->data = gagt_realloc (buffer->data, bytes); - buffer->attributes = gagt_realloc (buffer->attributes, bytes); - - buffer->allocation = bytes; - } - - /* Add string to the line buffer, and store packed text attributes. */ - memcpy (buffer->data + buffer->length, string, length); - memset (buffer->attributes + buffer->length, packed_attributes, length); - - buffer->length += length; -} - -static void -gagt_string_transfer (gagt_stringref_t from, gagt_stringref_t to) -{ - *to = *from; - from->data = from->attributes = NULL; - from->allocation = from->length = 0; -} - -static void -gagt_string_free (gagt_stringref_t buffer) -{ - free (buffer->data); - free (buffer->attributes); - buffer->data = buffer->attributes = NULL; - buffer->allocation = buffer->length = 0; -} - - -/* - * gagt_get_string_indent() - * gagt_get_string_outdent() - * gagt_get_string_real_length() - * gagt_is_string_blank() - * gagt_is_string_hyphenated() - * - * Metrics functions for string_t buffers. - */ -static int -gagt_get_string_indent (const gagt_stringref_t buffer) -{ - int indent, index; - - indent = 0; - for (index = 0; - index < buffer->length && isspace (buffer->data[index]); - index++) - indent++; - - return indent; -} - -static int -gagt_get_string_outdent (const gagt_stringref_t buffer) -{ - int outdent, index; - - outdent = 0; - for (index = buffer->length - 1; - index >= 0 && isspace (buffer->data[index]); index--) - outdent++; - - return outdent; -} - - -static int -gagt_get_string_real_length (const gagt_stringref_t buffer) -{ - int indent, outdent; - - indent = gagt_get_string_indent (buffer); - outdent = gagt_get_string_outdent (buffer); - - return indent == buffer->length ? 0 : buffer->length - indent - outdent; -} - -static int -gagt_is_string_blank (const gagt_stringref_t buffer) -{ - return gagt_get_string_indent (buffer) == buffer->length; -} - -static int -gagt_is_string_hyphenated (const gagt_stringref_t buffer) -{ - int is_hyphenated; - - is_hyphenated = FALSE; - - if (!gagt_is_string_blank (buffer) - && gagt_get_string_real_length (buffer) > 1) - { - int last; - - last = buffer->length - gagt_get_string_outdent (buffer) - 1; - - if (buffer->data[last] == '-') - { - if (isalpha (buffer->data[last - 1])) - is_hyphenated = TRUE; - } - } - - return is_hyphenated; -} - - -/* - * gagt_output_delete() - * - * Delete all buffered page and line text. Free all malloc'ed buffer memory, - * and return the buffer variables to their initial values. - */ -static void -gagt_output_delete (void) -{ - gagt_lineref_t line, next_line; - - for (line = gagt_page_head; line; line = next_line) - { - assert (line->magic == GAGT_LINE_MAGIC); - next_line = line->next; - - gagt_string_free (&line->buffer); - - memset (line, 0, sizeof (*line)); - free (line); - } - - gagt_page_head = gagt_page_tail = NULL; - - gagt_string_free (&gagt_current_buffer); -} - - -/* - * agt_puts() - * - * Buffer the string passed in into our current single line buffer. The - * function converts to ISO 8859 Latin-1 encoding before buffering. - */ -void -agt_puts (const char *cp_string) -{ - assert (cp_string); - - if (!BATCH_MODE) - { - char *iso_string; - unsigned char packed; - int length; - - /* Update the apparent (virtual) window x position. */ - length = strlen (cp_string); - curr_x += length; - - /* - * Convert the buffer from IBM cp 437 to Glk's ISO 8859 Latin-1, and - * add string and packed text attributes to the current line buffer. - */ - iso_string = gagt_malloc (length + 1); - gagt_cp_to_iso (cp_string, iso_string); - packed = gagt_pack_current_attributes (); - gagt_string_append (&gagt_current_buffer, iso_string, packed); - - /* Add the string to any script file. */ - if (script_on) - textputs (scriptfile, iso_string); - - free (iso_string); - gagt_debug ("agt_puts", "string='%s'", cp_string); - } -} - - -/* - * agt_newline() - * - * Accept a newline to the main window. Our job here is to append the - * current line buffer to the page buffer, and clear the line buffer to - * begin accepting new text. - */ -void -agt_newline (void) -{ - if (!BATCH_MODE) - { - gagt_lineref_t line; - - /* Update the apparent (virtual) window x position. */ - curr_x = 0; - - /* Create a new line entry for the page buffer. */ - line = gagt_malloc (sizeof (*line)); - line->magic = GAGT_LINE_MAGIC; - - /* Move the line from the line buffer into the page buffer. */ - gagt_string_transfer (&gagt_current_buffer, &line->buffer); - - /* Fill in the line buffer metrics. */ - line->indent = gagt_get_string_indent (&line->buffer); - line->outdent = gagt_get_string_outdent (&line->buffer); - line->real_length = gagt_get_string_real_length (&line->buffer); - line->is_blank = gagt_is_string_blank (&line->buffer); - line->is_hyphenated = gagt_is_string_hyphenated (&line->buffer); - - /* For now, default the remaining page buffer fields for the line. */ - line->paragraph = NULL; - line->font_hint = HINT_NONE; - - /* Add to the list, creating a new list if necessary. */ - line->next = NULL; - line->prior = gagt_page_tail; - if (gagt_page_head) - gagt_page_tail->next = line; - else - gagt_page_head = line; - gagt_page_tail = line; - - /* Add a newline to any script file. */ - if (script_on) - textputs (scriptfile, "\n"); - - gagt_debug ("agt_newline", ""); - } -} - - -/* - * gagt_get_first_page_line() - * gagt_get_next_page_line() - * gagt_get_prior_page_line() - * - * Iterator functions for the page buffer. These functions return the first - * line from the page buffer, the next line, or the previous line, given a - * line, respectively. They return NULL if no lines, or no more lines, are - * available. - */ -static gagt_lineref_t -gagt_get_first_page_line (void) -{ - gagt_lineref_t line; - - line = gagt_page_head; - assert (!line || line->magic == GAGT_LINE_MAGIC); - return line; -} - -static gagt_lineref_t -gagt_get_next_page_line (const gagt_lineref_t line) -{ - gagt_lineref_t next_line; - assert (line && line->magic == GAGT_LINE_MAGIC); - - next_line = line->next; - assert (!next_line || next_line->magic == GAGT_LINE_MAGIC); - return next_line; -} - -static gagt_lineref_t -gagt_get_prior_page_line (const gagt_lineref_t line) -{ - gagt_lineref_t prior_line; - assert (line && line->magic == GAGT_LINE_MAGIC); - - prior_line = line->prior; - assert (!prior_line || prior_line->magic == GAGT_LINE_MAGIC); - return prior_line; -} - - -/*---------------------------------------------------------------------*/ -/* Glk port paragraphing functions and data */ -/*---------------------------------------------------------------------*/ - -/* Magic number used to ensure a pointer points to a paragraph. */ -static const unsigned int GAGT_PARAGRAPH_MAGIC = 0xb9a2297b; - -/* Forward definition of special paragraph reference. */ -typedef const struct gagt_special_s *gagt_specialref_t; - -/* - * Definition of a paragraph entry. This is a structure that holds a - * pointer to the first line buffer in the paragraph. - */ -struct gagt_paragraph_s -{ - unsigned int magic; /* Assertion check dog-tag. */ - - gagt_lineref_t first_line; /* First line in the paragraph. */ - gagt_specialref_t special; /* Special paragraph entry. */ - - int line_count; /* Number of lines in the paragraph. */ - int id; /* Paragraph id, sequence, for debug only. */ - - gagt_paragraphref_t next; /* List next element. */ - gagt_paragraphref_t prior; /* List prior element. */ -}; - -/* - * A doubly-linked list of paragraphs, with a tail pointer to facilitate - * adding entries at the end. - */ -static gagt_paragraphref_t gagt_paragraphs_head = NULL, - gagt_paragraphs_tail = NULL; - -/* - * gagt_paragraphs_delete() - * - * Delete paragraphs held in the list. This function doesn't delete the - * page buffer lines, just the paragraphs describing the page. - */ -static void -gagt_paragraphs_delete (void) -{ - gagt_paragraphref_t paragraph, next_paragraph; - - for (paragraph = gagt_paragraphs_head; paragraph; paragraph = next_paragraph) - { - assert (paragraph->magic == GAGT_PARAGRAPH_MAGIC); - next_paragraph = paragraph->next; - - memset (paragraph, 0, sizeof (*paragraph)); - free (paragraph); - } - - gagt_paragraphs_head = gagt_paragraphs_tail = NULL; -} - - -/* - * gagt_find_paragraph_start() - * - * Find and return the next non-blank line in the page buffer, given a start - * point. Returns NULL if there are no more blank lines. - */ -static gagt_lineref_t -gagt_find_paragraph_start (const gagt_lineref_t begin) -{ - gagt_lineref_t line, match; - - /* - * Advance line to the beginning of the next paragraph, stopping on the - * first non-blank line, or at the end of the page buffer. - */ - match = NULL; - for (line = begin; line; line = gagt_get_next_page_line (line)) - { - if (!line->is_blank) - { - match = line; - break; - } - } - - return match; -} - - -/* - * gagt_find_block_end() - * gagt_find_blank_line_block_end() - * - * Find and return the apparent end of a paragraph from the page buffer, - * given a start point, and an indentation reference. The end is either - * the point where indentation returns to the reference indentation, or - * the next blank line. - * - * Indentation reference can be -1, indicating that only the next blank - * line will end the paragraph. Indentation references less than 1 are - * also ignored. - */ -static gagt_lineref_t -gagt_find_block_end (const gagt_lineref_t begin, int indent) -{ - gagt_lineref_t line, match; - - /* - * Initialize the match to be the start of the block, then advance line - * until we hit a blank line or the end of the page buffer. At this point, - * match contains the last line checked. - */ - match = begin; - for (line = begin; line; line = gagt_get_next_page_line (line)) - { - /* - * Found if we reach a blank line, or when given an indentation to - * check for, we find it. - */ - if (line->is_blank || (indent > 0 && line->indent == indent)) - break; - - match = line; - } - - return match; -} - -static gagt_lineref_t -gagt_find_blank_line_block_end (const gagt_lineref_t begin) -{ - return gagt_find_block_end (begin, -1); -} - - -/* - * gagt_find_paragraph_end() - * - * Find and return the apparent end of a paragraph from the page buffer, - * given a start point. The function attempts to recognize paragraphs by - * the "shape" of indentation. - */ -static gagt_lineref_t -gagt_find_paragraph_end (const gagt_lineref_t first_line) -{ - gagt_lineref_t second_line; - - /* - * If the start line is the last line in the buffer, or if the next line - * is a blank line, return the start line as also being the end of the - * paragraph. - */ - second_line = gagt_get_next_page_line (first_line); - if (!second_line || second_line->is_blank) - { - return first_line; - } - - /* - * Time to look at line indentations... - * - * If either line is grossly indented, forget about trying to infer - * anything from this, and just break the paragraph on the next blank line. - */ - if (first_line->indent > screen_width / 4 - || second_line->indent > screen_width / 4) - { - return gagt_find_blank_line_block_end (second_line); - } - - /* - * If the first line is indented more than the second, end the paragraph - * on a blank line, or on a return in indentation to the level of the - * first line. Here we're looking for paragraphs with the shape - * - * aksjdj jfkasjd fjkasjd ajksdj fkaj djf akjsd fkjas dfs - * kasjdlkfjkj fj aksd jfjkasj dlkfja skjdk flaks dlf jalksdf - * ksjdf kjs kdf lasjd fkjalks jdfkjasjd flkjasl djfkasjfdkl - */ - else if (first_line->indent > second_line->indent) - { - return gagt_find_block_end (second_line, first_line->indent); - } - - /* - * If the second line is more indented than the first, this may indicate - * a title line, followed by normal indented paragraphing. In this case, - * use the second line indentation as the reference, and begin searching - * at the next line. This finds - * - * ksjdkfjask ksadf - * kajskd fksjkfj jfkj jfkslaj fksjlfj jkjskjlfa j fjksal - * sjkkdjf sj fkjkajkdlfj lsjak dfjk djkfjskl dklf alks dfll - * fjksja jkj dksja kjdk kaj dskfj aksjdf aksjd kfjaks fjks - * - * and - * - * asdfj kjsdf kjs - * akjsdkj fkjs kdjfa lskjdl fjalsj dlfjksj kdj fjkd jlsjd - * jalksj jfk slj lkfjsa lkjd lfjlaks dlfkjals djkj alsjd - * kj jfksj fjksjl alkjs dlkjf lakjsd fkjas ldkj flkja fsd - */ - else if (second_line->indent > first_line->indent) - { - gagt_lineref_t third_line; - - /* - * See if we have a third buffer line to look at. If we don't, or if - * we do but it's blank, the paragraph ends here. - */ - third_line = gagt_get_next_page_line (second_line); - if (!third_line || third_line->is_blank) - { - return second_line; - } - - /* As above, give up on gross indentation. */ - if (second_line->indent > screen_width / 4 - || third_line->indent > screen_width / 4) - { - return gagt_find_blank_line_block_end (third_line); - } - - /* - * If the second line indentation exceeds the third, this is probably - * a paragraph with a title line. In this case, end the paragraph on - * a return to the indentation of the second line. If not, just find - * the next blank line. - */ - else if (second_line->indent > third_line->indent) - { - return gagt_find_block_end (third_line, second_line->indent); - } - else - { - return gagt_find_blank_line_block_end (third_line); - } - } - - /* - * Otherwise, the first and second line indentations are the same, so - * break only on the next empty line. This finds the simple - * - * ksd kjal jdljf lakjsd lkj lakjsdl jfla jsldj lfaksdj fksj - * lskjd fja kjsdlk fjlakjs ldkjfksj lkjdf kjalskjd fkjklal - * skjd fkaj djfkjs dkfjal sjdlkfj alksjdf lkajs ldkjf alljjf - */ - else - { - assert (second_line->indent == first_line->indent); - return gagt_find_blank_line_block_end (second_line); - } -} - - -/* - * gagt_paragraph_page() - * - * This function breaks the page buffer into what appear to be paragraphs, - * based on observations of indentation and blank separator lines. - */ -static void -gagt_paragraph_page (void) -{ - gagt_lineref_t start; - - assert (!gagt_paragraphs_head && !gagt_paragraphs_tail); - - /* Find the start of the first paragraph. */ - start = gagt_find_paragraph_start (gagt_get_first_page_line ()); - while (start) - { - gagt_paragraphref_t paragraph; - gagt_lineref_t end, line; - - /* Create a new paragraph entry. */ - paragraph = gagt_malloc (sizeof (*paragraph)); - paragraph->magic = GAGT_PARAGRAPH_MAGIC; - paragraph->first_line = start; - paragraph->special = NULL; - paragraph->line_count = 1; - paragraph->id = gagt_paragraphs_tail ? gagt_paragraphs_tail->id + 1 : 0; - - /* Add to the list, creating a new list if necessary. */ - paragraph->next = NULL; - paragraph->prior = gagt_paragraphs_tail; - if (gagt_paragraphs_head) - gagt_paragraphs_tail->next = paragraph; - else - gagt_paragraphs_head = paragraph; - gagt_paragraphs_tail = paragraph; - - /* From the start, identify the paragraph end. */ - end = gagt_find_paragraph_end (start); - - /* - * Set paragraph in each line identified as part of this paragraph, - * and increment the paragraph's line count. - */ - for (line = start; - line != end; line = gagt_get_next_page_line (line)) - { - line->paragraph = paragraph; - paragraph->line_count++; - } - end->paragraph = paragraph; - - /* - * If there's another line, look for the next paragraph there, - * otherwise we're done. - */ - line = gagt_get_next_page_line (end); - if (line) - start = gagt_find_paragraph_start (line); - else - start = NULL; - } -} - - -/* - * gagt_get_first_paragraph() - * gagt_get_next_paragraph() - * - * Iterator functions for the paragraphs list. - */ -static gagt_paragraphref_t -gagt_get_first_paragraph (void) -{ - gagt_paragraphref_t paragraph; - - paragraph = gagt_paragraphs_head; - assert (!paragraph || paragraph->magic == GAGT_PARAGRAPH_MAGIC); - return paragraph; -} - -static gagt_paragraphref_t -gagt_get_next_paragraph (const gagt_paragraphref_t paragraph) -{ - gagt_paragraphref_t next_paragraph; - assert (paragraph && paragraph->magic == GAGT_PARAGRAPH_MAGIC); - - next_paragraph = paragraph->next; - assert (!next_paragraph || next_paragraph->magic == GAGT_PARAGRAPH_MAGIC); - return next_paragraph; -} - - -/* - * gagt_get_first_paragraph_line() - * gagt_get_next_paragraph_line() - * gagt_get_prior_paragraph_line() - * - * Iterator functions for the page buffer. These functions implement a - * paragraph-based view of the page buffer. - * - * The functions find the first line of a given paragraph; given a line, - * the next line in the same paragraph, or NULL if line is the last para- - * graph line (or the last line in the page buffer); and given a line, - * the previous line in the same paragraph, or NULL if line is the first - * paragraph line (or the first line in the page buffer). - */ -static gagt_lineref_t -gagt_get_first_paragraph_line (const gagt_paragraphref_t paragraph) -{ - assert (paragraph && paragraph->magic == GAGT_PARAGRAPH_MAGIC); - - /* Return the first line for the requested paragraph. */ - return paragraph->first_line; -} - -static gagt_lineref_t -gagt_get_next_paragraph_line (const gagt_lineref_t line) -{ - gagt_lineref_t next_line; - - /* Get the next line; return it if the paragraph matches, else NULL. */ - next_line = gagt_get_next_page_line (line); - if (next_line && next_line->paragraph == line->paragraph) - return next_line; - else - return NULL; -} - -static gagt_lineref_t -gagt_get_prior_paragraph_line (const gagt_lineref_t line) -{ - gagt_lineref_t prior_line; - - /* Get the previous line; return it if the paragraph matches, else NULL. */ - prior_line = gagt_get_prior_page_line (line); - if (prior_line && prior_line->paragraph == line->paragraph) - return prior_line; - else - return NULL; -} - - -/* - * gagt_get_paragraph_line_count() - * - * Return the count of lines contained in the paragraph. - */ -static int -gagt_get_paragraph_line_count (const gagt_paragraphref_t paragraph) -{ - assert (paragraph && paragraph->magic == GAGT_PARAGRAPH_MAGIC); - - return paragraph->line_count; -} - - -/*---------------------------------------------------------------------*/ -/* Glk port page buffer analysis functions */ -/*---------------------------------------------------------------------*/ - -/* - * Threshold for consecutive punctuation/spaces before we decide that a line - * is in fact part of a table, and a small selection of characters to apply - * a somewhat larger threshold to when looking for punctuation (typically, - * characters that appear together multiple times in non-table text). - */ -static const int GAGT_THRESHOLD = 4, - GAGT_COMMON_THRESHOLD = 8; -static const char * const GAGT_COMMON_PUNCTUATION = ".!?"; - - -/* - * gagt_line_is_standout() - * - * Return TRUE if a page buffer line appears to contain "standout" text. - * This is one of: - * - a line where all characters have some form of AGT text attribute - * set (blinking, fixed width font, or emphasis), - * - a line where each alphabetical character is uppercase. - * Typically, this describes room and other miscellaneous header lines. - */ -static int -gagt_line_is_standout (const gagt_lineref_t line) -{ - int index, all_formatted, upper_count, lower_count; - - /* - * Look at the line, for cases where all characters in it have AGT font - * attributes, and counting the upper and lower case characters. Iterate - * over only the significant characters in the string. - */ - all_formatted = TRUE; - upper_count = lower_count = 0; - for (index = line->indent; - index < line->buffer.length - line->outdent; index++) - { - gagt_attrset_t attribute_set; - unsigned char character; - - gagt_unpack_attributes (line->buffer.attributes[index], &attribute_set); - character = line->buffer.data[index]; - - /* - * If no AGT attribute is set for this character, then not all of the - * line is standout text. In this case, reset the all_formatted flag. - */ - if (!(attribute_set.blink - || attribute_set.fixed || attribute_set.emphasis)) - all_formatted = FALSE; - - /* Count upper and lower case characters. */ - if (islower (character)) - lower_count++; - else if (isupper (character)) - upper_count++; - } - - /* - * Consider standout if every character was formatted, or if the string - * is all uppercase. - */ - return all_formatted || (upper_count > 0 && lower_count == 0); -} - - -/* - * gagt_set_font_hint_proportional() - * gagt_set_font_hint_proportional_newline() - * gagt_set_font_hint_fixed_width() - * - * Helpers for assigning font hints. Font hints have strengths, and these - * functions ensure that gagt_assign_paragraph_font_hints() only increases - * strengths, and doesn't need to worry about checking before setting. In - * the case of newline, the function also adds standout to the font hint if - * appropriate. - */ -static void -gagt_set_font_hint_proportional (gagt_lineref_t line) -{ - /* The only weaker hint than proportional is none. */ - if (line->font_hint == HINT_NONE) - line->font_hint = HINT_PROPORTIONAL; -} - -static void -gagt_set_font_hint_proportional_newline (gagt_lineref_t line) -{ - /* - * Proportional and none are weaker than newline. Because of the way we - * set font hints, this function can't be called with a current line hint - * of proportional newline. - */ - if (line->font_hint == HINT_NONE || line->font_hint == HINT_PROPORTIONAL) - { - if (gagt_line_is_standout (line)) - line->font_hint = HINT_PROPORTIONAL_NEWLINE_STANDOUT; - else - line->font_hint = HINT_PROPORTIONAL_NEWLINE; - } -} - -static void -gagt_set_font_hint_fixed_width (gagt_lineref_t line) -{ - /* Fixed width font is the strongest hint. */ - if (line->font_hint == HINT_NONE - || line->font_hint == HINT_PROPORTIONAL - || line->font_hint == HINT_PROPORTIONAL_NEWLINE - || line->font_hint == HINT_PROPORTIONAL_NEWLINE_STANDOUT) - line->font_hint = HINT_FIXED_WIDTH; -} - - -/* - * gagt_assign_paragraph_font_hints() - * - * For a given paragraph in the page buffer, this function looks at the text - * style used, and assigns a font hint value to each line. Font hints - * indicate whether the line probably requires fixed width font, or may be - * okay in variable width, and for lines that look like they might be okay - * in variable width, whether the newline should probably be rendered at the - * end of the line, or if it might be omitted. - */ -static void -gagt_assign_paragraph_font_hints (const gagt_paragraphref_t paragraph) -{ - static int is_initialized = FALSE; - static int threshold[UCHAR_MAX + 1]; - - gagt_lineref_t line, first_line; - int is_table, in_list; - assert (paragraph); - - /* On first call, set up the table on punctuation run thresholds. */ - if (!is_initialized) - { - int character; - - for (character = 0; character <= UCHAR_MAX; character++) - { - /* - * Set the threshold, either a normal value, or a larger one for - * punctuation characters that tend to have consecutive runs in - * non-table text. - */ - if (ispunct (character)) - { - threshold[character] = strchr (GAGT_COMMON_PUNCTUATION, character) - ? GAGT_COMMON_THRESHOLD : GAGT_THRESHOLD; - } - } - - is_initialized = TRUE; - } - - /* - * Note the first paragraph line. This value is commonly used, and under - * certain circumstances, it's also modified later on. - */ - first_line = gagt_get_first_paragraph_line (paragraph); - assert (first_line); - - /* - * Phase 1 -- look for pages that consist of just one paragraph, - * itself consisting of only one line. - * - * There is no point in attempting alignment of text in a one paragraph, - * one line page. This would be, for example, an error message from the - * interpreter parser. In this case, set the line for proportional with - * newline, and return immediately. - */ - if (gagt_get_first_paragraph () == paragraph - && !gagt_get_next_paragraph (paragraph) - && !gagt_get_next_paragraph_line (first_line)) - { - /* - * Set the first paragraph line for proportional with a newline, and - * return. - */ - gagt_set_font_hint_proportional_newline (first_line); - return; - } - - /* - * Phase 2 -- try to identify paragraphs that are tables, based on - * looking for runs of punctuation. - * - * Search for any string that has a run of apparent line drawing or other - * formatting characters in it. If we find one, we'll consider the - * paragraph to be a "table", that is, it has some quality that we might - * destroy if we used a proportional font. - */ - is_table = FALSE; - for (line = first_line; - line && !is_table; line = gagt_get_next_paragraph_line (line)) - { - int index, counts[UCHAR_MAX + 1], total_counts; - - /* - * Clear the initial counts. Using memset() here is an order of - * magnitude or two faster than a for-loop. Also there's a total count - * to detect when counts needs to be recleared, or is already clear. - */ - memset (counts, 0, sizeof (counts)); - total_counts = 0; - - /* - * Count consecutive punctuation in the line, excluding the indentation - * and outdent. - */ - for (index = line->indent; - index < line->buffer.length - line->outdent && !is_table; index++) - { - int character; - character = line->buffer.data[index]; - - /* Test this character for punctuation. */ - if (ispunct (character)) - { - /* - * Increment the count for this character, and note that - * counts are no longer empty, then compare against threshold. - */ - counts[character]++; - total_counts++; - - is_table = (counts[character] >= threshold[character]); - } - else - { - /* - * Re-clear all counts, again with memset() for speed, but only - * if they need clearing. As they often won't, this optimization - * saves quite a bit of work. - */ - if (total_counts > 0) - { - memset (counts, 0, sizeof (counts)); - total_counts = 0; - } - } - } - } - - /* - * Phase 3 -- try again to identify paragraphs that are tables, based - * this time on looking for runs of whitespace. - * - * If no evidence found so far, look again, this time searching for any - * run of four or more spaces on the line (excluding any lead-in or - * trailing spaces). - */ - if (!is_table) - { - for (line = first_line; - line && !is_table; line = gagt_get_next_paragraph_line (line)) - { - int index, count; - - /* - * Count consecutive spaces in the line, excluding the indentation - * and outdent. - */ - count = 0; - for (index = line->indent; - index < line->buffer.length - line->outdent && !is_table; - index++) - { - int character; - character = line->buffer.data[index]; - - if (isspace (character)) - { - count++; - is_table = (count >= GAGT_THRESHOLD); - } - else - count = 0; - } - } - } - - /* - * If the paragraph appears to be a table, and if it consists of more than - * just a single line, mark all lines as fixed font output and return. - */ - if (is_table && gagt_get_next_paragraph_line (first_line)) - { - for (line = first_line; - line; line = gagt_get_next_paragraph_line (line)) - { - gagt_set_font_hint_fixed_width (line); - } - - /* Nothing more to do. */ - return; - } - - /* - * Phase 4 -- consider separating the first line from the rest of - * the paragraph. - * - * Not a table, so the choice is between proportional rendering with a - * newline, and proportional rendering without... - * - * If the first paragraph line is standout or short, render it pro- - * portionally with a newline, and don't consider it as a further part of - * the paragraph. - */ - if (gagt_line_is_standout (first_line) - || first_line->real_length < screen_width / 2) - { - /* Set the first paragraph line for a newline. */ - gagt_set_font_hint_proportional_newline (first_line); - - /* - * Disassociate this line from the rest of the paragraph by moving on - * the value of the first_line variable. If it turns out that there - * is no next paragraph line, then we have a one-line paragraph, and - * there's no more to do. - */ - first_line = gagt_get_next_paragraph_line (first_line); - if (!first_line) - return; - } - - /* - * Phase 5 -- try to identify lists by a simple initial look at line - * indentations. - * - * Look through the paragraph for apparent lists, and decide for each - * line whether it's appropriate to output a newline, and render - * proportionally, or just render proportionally. - * - * After this loop, each line will have some form of font hint assigned - * to it. - */ - in_list = FALSE; - for (line = first_line; - line; line = gagt_get_next_paragraph_line (line)) - { - gagt_lineref_t next_line; - - next_line = gagt_get_next_paragraph_line (line); - - /* - * Special last-iteration processing. The newline is always output at - * the end of a paragraph, so if there isn't a next line, then this - * line is the last paragraph line. Set its font hint appropriately, - * and do no more for the line. - */ - if (!next_line) - { - gagt_set_font_hint_proportional_newline (line); - continue; - } - - /* - * If the next line's indentation is deeper that that of the first - * line, this paragraph looks like it is trying to be some form of a - * list. In this case, make newline significant for the current line, - * and set the in_list flag so we can delay the return to proportional - * by one line. On return to first line indentation, make newline - * significant for the return line. - */ - if (next_line->indent > first_line->indent) - { - gagt_set_font_hint_proportional_newline (line); - in_list = TRUE; - } - else - { - if (in_list) - gagt_set_font_hint_proportional_newline (line); - else - gagt_set_font_hint_proportional (line); - in_list = FALSE; - } - } - - /* - * Phase 6 -- look again for lines that look like they are supposed - * to stand out from their neighbors. - * - * Now rescan the paragraph, looking this time for lines that stand out - * from their neighbours. Make newline significant for each such line, - * and the line above, if there is one. - * - * Here we split the loop on lines so that we avoid looking at the prior - * line of the current first line -- because of "adjustments", it may not - * be the real paragraph first line. - * - * So, deal with the current first line... - */ - if (gagt_line_is_standout (first_line)) - { - /* Make newline significant for this line. */ - gagt_set_font_hint_proportional_newline (first_line); - } - - /* ... then deal with the rest of the lines, looking for standouts. */ - for (line = gagt_get_next_paragraph_line (first_line); - line; line = gagt_get_next_paragraph_line (line)) - { - if (gagt_line_is_standout (line)) - { - gagt_lineref_t prior_line; - - /* Make newline significant for this line. */ - gagt_set_font_hint_proportional_newline (line); - - /* - * Make newline significant for the line above. There will always - * be one because we start the loop past the first line. - */ - prior_line = gagt_get_prior_paragraph_line (line); - gagt_set_font_hint_proportional_newline (prior_line); - } - } - - /* - * Phase 7 -- special case short lines at the paragraph start. - * - * Make a special case of lines that begin a paragraph, and are short and - * followed by a much longer line. This should catch games which output - * room titles above descriptions without using AGT fonts/bold/whatever. - * Without this trap, room titles and their descriptions are run together. - * This is more programmatic guesswork than heuristics. - */ - if (gagt_get_next_paragraph_line (first_line)) - { - gagt_lineref_t next_line; - - next_line = gagt_get_next_paragraph_line (first_line); - - /* - * See if the first line is less than half width, and the second line - * is more than three quarters width. If it is, set newline as - * significant for the first paragraph line. - */ - if (first_line->real_length < screen_width / 2 - && next_line->real_length > screen_width * 3 / 4) - { - gagt_set_font_hint_proportional_newline (first_line); - } - } - - /* - * Phase 8 -- special case paragraphs of only short lines. - * - * Make a special case out of paragraphs where all lines are short. This - * catches elements like indented addresses. - */ - if (gagt_get_next_paragraph_line (first_line)) - { - int all_short; - - all_short = TRUE; - for (line = first_line; - line; line = gagt_get_next_paragraph_line (line)) - { - /* Clear flag if this line isn't 'short'. */ - if (line->real_length >= screen_width / 2) - { - all_short = FALSE; - break; - } - } - - /* - * If all lines were short, mark the complete paragraph as having - * significant newlines. - */ - if (all_short) - { - for (line = first_line; - line; line = gagt_get_next_paragraph_line (line)) - { - gagt_set_font_hint_proportional_newline (line); - } - } - } -} - - -/* - * gagt_assign_font_hints() - * - * - * Sets a font hint for each line of each page buffer paragraph that is not - * a special paragraph. - */ -static void -gagt_assign_font_hints (void) -{ - gagt_paragraphref_t paragraph; - - for (paragraph = gagt_get_first_paragraph (); - paragraph; paragraph = gagt_get_next_paragraph (paragraph)) - { - if (!paragraph->special) - gagt_assign_paragraph_font_hints (paragraph); - } -} - - -/*---------------------------------------------------------------------*/ -/* Glk port special paragraph functions and data */ -/*---------------------------------------------------------------------*/ - -/* - * It's helpful to handle some AGiliTy interpreter output specially, to im- - * prove the look of the text where Glk fonts and styles are available. We - * build a table of paragraphs the interpreter can come out with, and the - * replacement text we'll use when we see this paragraph. Note that matches - * are made after factoring out indentation, and replacement lines do not - * automatically print with a newline. All clear, then? Here's the table - * entry definition. - */ -enum { GAGT_SPECIAL_MATCH_MAX = 5 }; - -typedef const struct gagt_special_s -{ - const int line_count; - const char * const compare[GAGT_SPECIAL_MATCH_MAX + 1]; - const char * const replace; -} gagt_special_t; - -/* - * Table of special AGiliTy interpreter strings and paragraphs -- where one - * appears in game output, we'll print out its replacement instead. Be - * warned; these strings are VERY specific to AGiliTy 1.1.1, and are extre- - * mely likely to change with any future interpreter releases. They also - * omit initializers with abandon, expecting the compiler to default these - * to NULL/zero. Replacement strings embed style encoding as |x, where x is - * E(mphasized), S(ubheader), or N(ormal) for convenience. - */ -static gagt_special_t GAGT_SPECIALS[] = { - - /* Initial screen AGT game type line. */ - {1, - {"[Created with Malmberg and Welch's Adventure Game Toolkit]"}, - "|ECreated with Malmberg and Welch's Adventure Game Toolkit|N\n"}, - - /* Normal version of initial interpreter information block. */ - {4, - {"This game is being executed by", - "AGiliTy: The (Mostly) Universal AGT Interpreter version 1.1.1", - "Copyright (C) 1996-99,2001 by Robert Masenten", - "Glk version"}, - "This game is being executed by:\n\n" - " |SAGiliTy, The (Mostly) Universal AGT Interpreter, Version 1.1.1|N\n" - " |ECopyright (C) 1996-1999,2001 by Robert Masenten|N\n" - " |EGlk version|N\n"}, - - /* AGiliTy "information" screen header block. */ - {5, - {"AGiliTy", - "The (Mostly) Universal AGT Interpreter, version 1.1.1", - "Copyright (C) 1996-1999,2001 by Robert Masenten", - "[Glk version]", - "-----------------------------------------------------------"}, - "|SAGiliTy, The (Mostly) Universal AGT Interpreter, Version 1.1.1|N\n" - "|ECopyright (C) 1996-1999,2001 by Robert Masenten|N\n" - "|EGlk version|N\n"}, - - /* "HIT ANY KEY" message, usually displayed after a game's introduction. */ - {1, - {"--- HIT ANY KEY ---"}, - "|E[Press any key...]|N"}, - - /* Alternative, shrunken version of initial interpreter information block. */ - {2, - {"Being run by AGiliTy version 1.1.1, Copyright (C) 1996-99,2001" - " Robert Masenten", - "Glk version"}, - "This game is being executed by:\n\n" - " |SAGiliTy, The (Mostly) Universal AGT Interpreter, Version 1.1.1|N\n" - " |ECopyright (C) 1996-1999,2001 by Robert Masenten|N\n" - " |EGlk version|N\n"}, - - /* Alternative, minimal version of initial interpreter information block. */ - {1, - {"Being run by AGiliTy version 1.1.1, Copyright (C) 1996-99,2001" - " Robert Masenten"}, - "This game is being executed by:\n\n" - " |SAGiliTy, The (Mostly) Universal AGT Interpreter, Version 1.1.1|N\n" - " |ECopyright (C) 1996-1999,2001 by Robert Masenten|N\n" - " |EGlk version|N\n"}, - - /* Lengthy version of the "Created with..." message. */ - {2, - {"This game was created with Malmberg and Welch's Adventure Game Toolkit;" - " it is", - "being executed by"}, - "|ECreated with Malmberg and Welch's Adventure Game Toolkit|N\n"}, - - /* Three-line version of initial interpreter information block. */ - {3, - {"AGiliTy: The (Mostly) Universal AGT Interpreter version 1.1.1", - "Copyright (C) 1996-99,2001 by Robert Masenten", - "Glk version"}, - "This game is being executed by:\n\n" - " |SAGiliTy, The (Mostly) Universal AGT Interpreter, Version 1.1.1|N\n" - " |ECopyright (C) 1996-1999,2001 by Robert Masenten|N\n" - " |EGlk version|N\n"}, - - /* - * Assorted special verb output messages, with the extra icky quality that - * we have to spot messages that wrap because we forced screen_width to 80. - */ - {2, - {"[Now in BRIEF mode (room descriptions will only be printed" - " when they are entered", - "the first time)]"}, - "|E[Now in BRIEF mode: Room descriptions will only be printed" - " when rooms are entered for the first time.]|N\n"}, - - {2, - {"[Now in VERBOSE mode (room descriptions will be printed" - " every time you enter a", - "room)]"}, - "|E[Now in VERBOSE mode: Room descriptions will be printed" - " every time you enter a room.]|N\n"}, - - {1, - {"[LISTEXIT mode on: room exits will be listed.]"}, - "|E[LISTEXIT mode on: Room exits will be listed.]|N\n"}, - - {1, - {"[LISTEXIT mode off: room exits will not be listed.]"}, - "|E[LISTEXIT mode off: Room exits will not be listed.]|N\n"}, - - /* End of table sentinel entry. Do not delete. */ - {0, {NULL}, NULL} -}; - - -/* - * gagt_compare_special_line() - * gagt_compare_special_paragraph() - * - * Helpers for gagt_find_equivalent_special(). Compare line data case- - * insensitively, taking care to use lengths rather than relying on line - * buffer data being NUL terminated (which it's not); and iterate a complete - * special paragraph comparison. - */ -static int -gagt_compare_special_line (const char *compare, const gagt_lineref_t line) -{ - /* - * Return true if the lengths match, and the real line data (excluding - * indent and outdent) also matches, ignoring case. - */ - return strlen (compare) == line->real_length - && gagt_strncasecmp (compare, - line->buffer.data + line->indent, - line->real_length) == 0; -} - -static int -gagt_compare_special_paragraph (const gagt_specialref_t special, - const gagt_paragraphref_t paragraph) -{ - /* If the line counts match, compare line by line. */ - if (special->line_count == gagt_get_paragraph_line_count (paragraph)) - { - gagt_lineref_t line; - int index, is_match; - - is_match = TRUE; - for (index = 0, line = gagt_get_first_paragraph_line (paragraph); - index < special->line_count && line; - index++, line = gagt_get_next_paragraph_line (line)) - { - if (!gagt_compare_special_line (special->compare[index], line)) - { - is_match = FALSE; - break; - } - } - - return is_match; - } - - /* Line count mismatch; return FALSE. */ - return FALSE; -} - - -/* - * gagt_find_equivalent_special() - * - * Given a paragraph, see if it matches any of the special ones set up in - * our array. Returns the special, or NULL if no match. - */ -static gagt_specialref_t -gagt_find_equivalent_special (gagt_paragraphref_t paragraph) -{ - gagt_specialref_t special, match; - - /* Check each special paragraph entry for a match against this paragraph. */ - match = NULL; - for (special = GAGT_SPECIALS; special->replace; special++) - { - if (gagt_compare_special_paragraph (special, paragraph)) - { - match = special; - break; - } - } - - return match; -} - - -/* - * gagt_mark_specials() - * - * Search for and mark any lines that match special paragraphs. - */ -static void -gagt_mark_specials (void) -{ - static int is_verified = FALSE; - - /* - * Verify special paragraphs table contents. This checks that each entry - * ends with a NULL comparison, has a replacement, and that the line count - * matches. - */ - if (!is_verified) - { - gagt_specialref_t special; - - for (special = GAGT_SPECIALS; special->replace; special++) - { - int line_count, index; - - line_count = 0; - for (index = 0; special->compare[index]; index++) - line_count++; - - assert (special->line_count == line_count); - assert (special->replace); - assert (!special->compare[GAGT_SPECIAL_MATCH_MAX]); - } - - is_verified = TRUE; - } - - /* - * Search all paragraphs for special matches, if enabled. When a special - * match is found, mark the paragraph with a pointer to the matching entry. - */ - if (gagt_replacement_enabled) - { - gagt_paragraphref_t paragraph; - - for (paragraph = gagt_get_first_paragraph (); - paragraph; paragraph = gagt_get_next_paragraph (paragraph)) - { - paragraph->special = gagt_find_equivalent_special (paragraph); - } - } -} - - -/* - * gagt_display_special() - * - * Display the replacement text for the specified special table entry. The - * current Glk style in force is passed in; we return the Glk style in force - * after we've done. - */ -static glui32 -gagt_display_special (const gagt_specialref_t special, glui32 current_style) -{ - glui32 set_style; - int index, marker, length; - const char *string; - assert (special); - - /* Extract replacement string and length. */ - string = special->replace; - assert (string); - length = strlen (string); - - set_style = current_style; - - /* - * Iterate each character in replacement string, looking for style escapes, - * and flushing delayed output when one is found. - */ - marker = 0; - for (index = 0; index < length; index++) - { - if (string[index] == '|') - { - glui32 style; - - /* Flush delayed output accumulated so far, excluding escape. */ - glk_put_buffer ((char *) string + marker, index - marker); - marker = index + 2; - - /* Determine any new text style. */ - style = set_style; - switch (string[++index]) - { - case 'E': - style = style_Emphasized; - break; - - case 'S': - style = style_Subheader; - break; - - case 'N': - style = style_Normal; - break; - - default: - gagt_fatal ("GLK: Invalid replacement style escape"); - gagt_exit (); - } - - /* If style changed, update Glk's style setting. */ - if (style != set_style) - { - glk_set_style (style); - set_style = style; - } - } - } - - /* Output any remaining delayed characters. */ - if (marker < length) - glk_put_buffer ((char *) string + marker, length - marker); - - return set_style; -} - - -/*---------------------------------------------------------------------*/ -/* Glk port output functions */ -/*---------------------------------------------------------------------*/ - -/* - * Flag for if the user entered "help" as their last input, or if hints have - * been silenced as a result of already using a Glk command. - */ -static int gagt_help_requested = FALSE, - gagt_help_hints_silenced = FALSE; - -/* - * gagt_display_register_help_request() - * gagt_display_silence_help_hints() - * gagt_display_provide_help_hint() - * - * Register a request for help, and print a note of how to get Glk command - * help from the interpreter unless silenced. - */ -static void -gagt_display_register_help_request (void) -{ - gagt_help_requested = TRUE; -} - -static void -gagt_display_silence_help_hints (void) -{ - gagt_help_hints_silenced = TRUE; -} - -static glui32 -gagt_display_provide_help_hint (glui32 current_style) -{ - if (gagt_help_requested && !gagt_help_hints_silenced) - { - glk_set_style (style_Emphasized); - glk_put_string ("[Try 'glk help' for help on special interpreter" - " commands]\n"); - - gagt_help_requested = FALSE; - return style_Emphasized; - } - - return current_style; -} - - -/* - * gagt_display_text_element() - * - * Display an element of a buffer string using matching packed attributes. - * The currently set Glk style is supplied, and the function returns the - * new currently set Glk style. - * - * The function handles a flag to coerce fixed width font. - */ -static glui32 -gagt_display_text_element (const char *string, const unsigned char *attributes, - int length, glui32 current_style, int fixed_width) -{ - int marker, index; - glui32 set_style; - assert (glk_stream_get_current ()); - - set_style = current_style; - - /* - * Iterate each character in the line range. We actually delay output - * until we see a change in style; that way, we can send a buffer of - * characters to Glk, rather than sending them just one at a time. - */ - marker = 0; - for (index = 0; index < length; index++) - { - gagt_attrset_t attribute_set; - glui32 style; - assert (attributes && string); - - /* - * Unpack the AGT font attributes for this character, and add fixed - * width font coercion. - */ - gagt_unpack_attributes (attributes[index], &attribute_set); - attribute_set.fixed |= fixed_width; - - /* - * Decide on any applicable new Glk text styling. If it's different - * to the current style, output the delayed characters, and update - * Glk's style setting. - */ - style = gagt_select_style (&attribute_set); - if (style != set_style) - { - glk_put_buffer ((char *) string + marker, index - marker); - marker = index; - - glk_set_style (style); - set_style = style; - } - } - - /* Output any remaining delayed characters. */ - if (marker < length) - glk_put_buffer ((char *) string + marker, length - marker); - - return set_style; -} - - -/* - * gagt_display_line() - * - * Display a page buffer line, starting in the current Glk style, and - * returning the new current Glk style. - * - * The function takes additional flags to force fixed width font, skip over - * indentation and trailing line whitespace, and trim hyphens (if skipping - * trailing whitespace). - */ -static glui32 -gagt_display_line (const gagt_lineref_t line, glui32 current_style, - int fixed_width, int skip_indent, int skip_outdent, - int trim_hyphen) -{ - int start, length; - glui32 set_style; - - /* - * Check the skip indent flag to find the first character to display, and - * the count of characters to display. - */ - start = 0; - length = line->buffer.length; - if (skip_indent) - { - start += line->indent; - length -= line->indent; - } - - /* Adjust length for skipping outdent and trimming hyphens. */ - if (skip_outdent) - { - length -= line->outdent; - if (trim_hyphen && line->is_hyphenated) - length--; - } - - /* Display this line segment. */ - set_style = gagt_display_text_element (line->buffer.data + start, - line->buffer.attributes + start, - length, current_style, fixed_width); - - return set_style; -} - - -/* - * gagt_display_hinted_line() - * - * Display a page buffer line, starting in the current Glk style, and - * returning the new current Glk style. The function uses the font hints - * from the line, and receives the font hint of the prior line. - */ -static glui32 -gagt_display_hinted_line (const gagt_lineref_t line, glui32 current_style, - gagt_font_hint_t prior_hint) -{ - glui32 style; - - style = current_style; - switch (line->font_hint) - { - case HINT_FIXED_WIDTH: - /* Force fixed width font on the line. */ - style = gagt_display_line (line, style, TRUE, FALSE, FALSE, FALSE); - - glk_put_char ('\n'); - break; - - case HINT_PROPORTIONAL: - /* - * Permit proportional font, and suppress outdent. Suppress indent - * too if this line follows a line that suppressed newline, or is the - * first line in the paragraph. For all cases, trim the hyphen from - * hyphenated lines. - */ - if (prior_hint == HINT_PROPORTIONAL || prior_hint == HINT_NONE) - style = gagt_display_line (line, style, FALSE, TRUE, TRUE, TRUE); - else - style = gagt_display_line (line, style, FALSE, FALSE, TRUE, TRUE); - - /* - * Where the line is not hyphenated, output a space in place of newline. - * This lets paragraph text to flow to the full display width. - */ - if (!line->is_hyphenated) - glk_put_char (' '); - break; - - case HINT_PROPORTIONAL_NEWLINE: - case HINT_PROPORTIONAL_NEWLINE_STANDOUT: - /* - * As above, permit proportional font, suppress outdent, and suppress - * indent too under certain conditions; in this case, only when the - * prior line suppressed newline. - */ - if (prior_hint == HINT_PROPORTIONAL) - style = gagt_display_line (line, style, FALSE, TRUE, TRUE, FALSE); - else - style = gagt_display_line (line, style, FALSE, FALSE, TRUE, FALSE); - - glk_put_char ('\n'); - break; - - case HINT_NONE: - gagt_fatal ("GLK: Page buffer line with no font hint"); - gagt_exit (); - - default: - gagt_fatal ("GLK: Invalid font hint encountered"); - gagt_exit (); - } - - return style; -} - - -/* - * gagt_display_auto() - * - * Display buffered output text to the Glk main window using a bunch of - * occasionally rather dodgy heuristics to try to automatically set a suitable - * font for the way the text is structured, while replacing special paragraphs - * with altered text. - */ -static void -gagt_display_auto (void) -{ - gagt_paragraphref_t paragraph; - glui32 style; - - style = style_Normal; - glk_set_style (style); - - /* Handle each paragraph. */ - for (paragraph = gagt_get_first_paragraph (); - paragraph; paragraph = gagt_get_next_paragraph (paragraph)) - { - /* If a special paragraph, output replacement text instead. */ - if (paragraph->special) - { - style = gagt_display_special (paragraph->special, style); - glk_put_char ('\n'); - } - else - { - gagt_lineref_t line; - gagt_font_hint_t prior_hint; - - /* Get the first line of the paragraph. */ - line = gagt_get_first_paragraph_line (paragraph); - - /* - * Output a blank line where the first line of the first paragraph - * is standout; this sets it apart from the prompt. - */ - if (paragraph == gagt_get_first_paragraph () - && line == gagt_get_first_paragraph_line (paragraph)) - { - if (line->font_hint == HINT_PROPORTIONAL_NEWLINE_STANDOUT) - glk_put_char ('\n'); - } - - /* Handle each line of the paragraph. */ - prior_hint = HINT_NONE; - for (; line; line = gagt_get_next_paragraph_line (line)) - { - /* - * Print this line according to its font hint, noting any change - * of style and the line's font hint for use next iteration as - * the prior hint. - */ - style = gagt_display_hinted_line (line, style, prior_hint); - prior_hint = line->font_hint; - } - - /* Output the newline for the end of the paragraph. */ - glk_put_char ('\n'); - } - } - - /* If no paragraphs at all, but a current buffer, output a newline. */ - if (!gagt_get_first_paragraph () && gagt_current_buffer.length > 0) - glk_put_char ('\n'); - - /* Output any help hint and unterminated line from the line buffer. */ - style = gagt_display_provide_help_hint (style); - style = gagt_display_text_element (gagt_current_buffer.data, - gagt_current_buffer.attributes, - gagt_current_buffer.length, style, FALSE); -} - - -/* - * gagt_display_manual() - * - * Display buffered output text in the Glk main window, with either a fixed - * width or a proportional font. - */ -static void -gagt_display_manual (int fixed_width) -{ - gagt_lineref_t line; - glui32 style; - - style = style_Normal; - glk_set_style (style); - - for (line = gagt_get_first_page_line (); - line; line = gagt_get_next_page_line (line)) - { - gagt_paragraphref_t paragraph; - - paragraph = line->paragraph; - - /* - * If this is a special paragraph, display the replacement text on - * its first line and ignore remaining special lines. Otherwise, - * display the page buffer line using either fixed or proportional - * font, as requested. - */ - if (paragraph && paragraph->special) - { - if (gagt_get_first_paragraph_line (paragraph) == line) - style = gagt_display_special (paragraph->special, style); - } - else - { - style = gagt_display_line (line, style, fixed_width, - FALSE, FALSE, FALSE); - glk_put_char ('\n'); - } - } - - /* Output any help hint and unterminated line from the line buffer. */ - style = gagt_display_provide_help_hint (style); - style = gagt_display_text_element (gagt_current_buffer.data, - gagt_current_buffer.attributes, - gagt_current_buffer.length, - style, fixed_width); -} - - -/* - * gagt_display_debug() - * - * Display the analyzed page buffer in a form that shows all of its gory - * detail. - */ -static void -gagt_display_debug (void) -{ - gagt_lineref_t line; - char buffer[256]; - - glk_set_style (style_Preformatted); - for (line = gagt_get_first_page_line (); - line; line = gagt_get_next_page_line (line)) - { - gagt_paragraphref_t paragraph; - - paragraph = line->paragraph; - sprintf (buffer, - "%2d:%2d->%2d A=%-3d L=%-2d I=%-2d O=%-2d R=%-2d %c%c| ", - paragraph ? paragraph->id + 1 : 0, - paragraph ? paragraph->line_count : 0, - paragraph && paragraph->special - ? paragraph->special - GAGT_SPECIALS + 1 : 0, - line->buffer.allocation, line->buffer.length, - line->indent, line->outdent, - line->real_length, - line->is_hyphenated ? 'h' : '_', - line->is_blank ? 'b' : - line->font_hint == HINT_PROPORTIONAL ? 'P' : - line->font_hint == HINT_PROPORTIONAL_NEWLINE ? 'N' : - line->font_hint == HINT_PROPORTIONAL_NEWLINE_STANDOUT ? 'S' : - line->font_hint == HINT_FIXED_WIDTH ? 'F' : '_'); - glk_put_string (buffer); - - glk_put_buffer (line->buffer.data, line->buffer.length); - glk_put_char ('\n'); - } - - if (gagt_current_buffer.length > 0) - { - sprintf (buffer, - "__,__->__ A=%-3d L=%-2d I=__ O=__ R=__ %s| ", - gagt_current_buffer.allocation, gagt_current_buffer.length, - gagt_help_requested ? "HR" : "__"); - glk_put_string (buffer); - - glk_put_buffer (gagt_current_buffer.data, gagt_current_buffer.length); - } - - gagt_help_requested = FALSE; -} - - -/* - * gagt_output_flush() - * - * Flush any buffered output text to the Glk main window, and clear the - * buffer ready for new output text. The function concerns itself with - * both the page buffer and any unterminated line in the line buffer. - */ -static void -gagt_output_flush (void) -{ - /* - * Run the analysis of page buffer contents. This will fill in the - * paragraph and font hints fields, any any applicable special pointer, - * for every line held in the buffer. - */ - gagt_paragraph_page (); - gagt_mark_specials (); - gagt_assign_font_hints (); - - /* - * Select the appropriate display routine to use, and call it. The display - * routines present somewhat different output, and are responsible for - * displaying both the page buffer _and_ any buffered current line text. - */ - switch (gagt_font_mode) - { - case FONT_AUTOMATIC: - gagt_display_auto (); - break; - - case FONT_FIXED_WIDTH: - gagt_display_manual (TRUE); - break; - - case FONT_PROPORTIONAL: - gagt_display_manual (FALSE); - break; - - case FONT_DEBUG: - gagt_display_debug (); - break; - - default: - gagt_fatal ("GLK: Invalid font mode encountered"); - gagt_exit (); - } - - /* Empty the buffer, ready for new game strings. */ - gagt_paragraphs_delete (); - gagt_output_delete (); -} - - -/* - * agt_clrscr() - * - * Clear the main playing area window. Although there may be little point - * in flushing (rather than emptying) the buffers, nevertheless that is - * what we do. - */ -void -agt_clrscr (void) -{ - if (!BATCH_MODE) - { - /* Update the apparent (virtual) window x position. */ - curr_x = 0; - - /* Flush any pending buffered output, and clear the main window. */ - gagt_output_flush (); - glk_window_clear (gagt_main_window); - - /* Add a series of newlines to any script file. */ - if (script_on) - textputs (scriptfile, "\n\n\n\n"); - - gagt_debug ("agt_clrscr", ""); - } -} - - -/* - * gagt_styled_string() - * gagt_styled_char() - * gagt_standout_string() - * gagt_standout_char() - * gagt_normal_string() - * gagt_normal_char() - * gagt_header_string() - * - * Convenience functions to print strings in assorted styles. A standout - * string is one that hints that it's from the interpreter, not the game. - */ -static void -gagt_styled_string (glui32 style, const char *message) -{ - assert (message); - - glk_set_style (style); - glk_put_string ((char *) message); - glk_set_style (style_Normal); -} - -static void -gagt_styled_char (glui32 style, char c) -{ - char buffer[2]; - - buffer[0] = c; - buffer[1] = '\0'; - gagt_styled_string (style, buffer); -} - -static void -gagt_standout_string (const char *message) -{ - gagt_styled_string (style_Emphasized, message); -} - -static void -gagt_standout_char (char c) -{ - gagt_styled_char (style_Emphasized, c); -} - -static void -gagt_normal_string (const char *message) -{ - gagt_styled_string (style_Normal, message); -} - -static void -gagt_normal_char (char c) -{ - gagt_styled_char (style_Normal, c); -} - -static void -gagt_header_string (const char *message) -{ - gagt_styled_string (style_Header, message); -} - - -/*---------------------------------------------------------------------*/ -/* Glk port delay functions */ -/*---------------------------------------------------------------------*/ - -/* Number of milliseconds in a second (traditionally, 1000). */ -static const int GAGT_MS_PER_SEC = 1000; - -/* - * Number of milliseconds to timeout. Because of jitter in the way Glk - * generates timeouts, it's worthwhile implementing a delay using a number - * of shorter timeouts. This minimizes inaccuracies in the actual delay. - */ -static const glui32 GAGT_DELAY_TIMEOUT = 50; - -/* The character key that can be pressed to cancel, and suspend, delays. */ -static const char GAGT_DELAY_SUSPEND = ' '; - -/* - * Flag to temporarily turn off all delays. This is set when the user - * cancels a delay with a keypress, and remains set until the next time - * that AGiliTy requests user input. This way, games that call agt_delay() - * sequentially don't require multiple keypresses to jump out of delay - * sections. - */ -static int gagt_delays_suspended = FALSE; - - -/* - * agt_delay() - * - * Delay for the specified number of seconds. The delay can be canceled - * by a user keypress. - */ -void -agt_delay (int seconds) -{ - glui32 milliseconds, delayed; - int delay_completed; - - /* Suppress delay if in fast replay or batch mode. */ - if (fast_replay || BATCH_MODE) - return; - - /* - * Do nothing if Glk doesn't have timers, if the delay state is set to - * ignore delays, if a zero or negative delay was specified, or if delays - * are currently temporarily suspended. - */ - if (!glk_gestalt (gestalt_Timer, 0) - || gagt_delay_mode == DELAY_OFF - || seconds <= 0 || gagt_delays_suspended) - return; - - /* Flush any pending buffered output, and refresh status to show waiting. */ - gagt_output_flush (); - gagt_status_in_delay (TRUE); - - /* Calculate the number of milliseconds to delay. */ - milliseconds = (seconds * GAGT_MS_PER_SEC) - / (gagt_delay_mode == DELAY_SHORT ? 2 : 1); - - /* Request timer events, and let a keypress cancel the delay. */ - glk_request_char_event (gagt_main_window); - glk_request_timer_events (GAGT_DELAY_TIMEOUT); - - /* - * Implement the delay using a sequence of shorter Glk timeouts, with an - * option to cancel the delay with a keypress. - */ - delay_completed = TRUE; - for (delayed = 0; delayed < milliseconds; delayed += GAGT_DELAY_TIMEOUT) - { - event_t event; - - /* Wait for the next timeout, or a character. */ - gagt_event_wait_2 (evtype_CharInput, evtype_Timer, &event); - if (event.type == evtype_CharInput) - { - /* - * If suspend requested, stop the delay, and set the delay - * suspension flag, and a note that the delay loop didn't complete. - * Otherwise, reissue the character input request. - */ - if (event.val1 == GAGT_DELAY_SUSPEND) - { - gagt_delays_suspended = TRUE; - delay_completed = FALSE; - break; - } - else - glk_request_char_event (gagt_main_window); - } - } - - /* Cancel any pending character input, and timer events. */ - if (delay_completed) - glk_cancel_char_event (gagt_main_window); - glk_request_timer_events (0); - - /* Clear the waiting indicator. */ - gagt_status_in_delay (FALSE); - - gagt_debug ("agt_delay", "seconds=%d [%lu mS] -> %s", seconds, milliseconds, - delay_completed ? "completed" : "canceled"); -} - - -/* - * gagt_delay_resume() - * - * Unsuspend delays. This function should be called by agt_input() and - * agt_getkey(), to re-enable delays when the interpreter next requests - * user input. - */ -static void -gagt_delay_resume (void) -{ - gagt_delays_suspended = FALSE; -} - - -/*---------------------------------------------------------------------*/ -/* Glk port box drawing functions */ -/*---------------------------------------------------------------------*/ - -/* Saved details of any current box dimensions and flags. */ -static unsigned long gagt_box_flags = 0; -static int gagt_box_busy = FALSE, - gagt_box_width = 0, - gagt_box_height = 0, - gagt_box_startx = 0; - - -/* - * gagt_box_rule() - * gagt_box_position() - * - * Draw a line at the top or bottom of a box, and position the cursor - * with a box indent. - */ -static void -gagt_box_rule (int width) -{ - char *ruler; - - /* Write a +--...--+ ruler to delimit a box. */ - ruler = gagt_malloc (width + 2 + 1); - memset (ruler + 1, '-', width); - ruler[0] = ruler[width + 1] = '+'; - ruler[width + 2] = '\0'; - agt_puts (ruler); - free (ruler); -} - -static void -gagt_box_position (int indent) -{ - char *spaces; - - /* Write a newline before the indent. */ - agt_newline (); - - /* Write the indent to the start of box text. */ - spaces = gagt_malloc (indent + 1); - memset (spaces, ' ', indent); - spaces[indent] = '\0'; - agt_puts (spaces); - free (spaces); -} - - -/* - * agt_makebox() - * agt_qnewline() - * agt_endbox() - * - * Start a box of given width, height, and with given flags. Write a new - * line in the box. And end the box. - */ -void -agt_makebox (int width, int height, unsigned long flags) -{ - assert (!gagt_box_busy); - - gagt_box_busy = TRUE; - gagt_box_flags = flags; - gagt_box_width = width; - gagt_box_height = height; - - /* If no centering requested, set the indent to zero. */ - if (gagt_box_flags & TB_NOCENT) - gagt_box_startx = 0; - else - { - int centering_width; - - /* - * Calculate the indent for centering, adding 4 characters for borders. - * Here, since screen_width is artificial, we'll center off status_width - * if it is less than screen width, otherwise we'll center by using - * screen_width. The reason for shrinking to screen_width is that if - * we don't, we could drive curr_x to beyond screen_width with our box - * indentations, and that confuses AGiliTy. - */ - if (status_width < screen_width) - centering_width = status_width; - else - centering_width = screen_width; - if (gagt_box_flags & TB_BORDER) - gagt_box_startx = (centering_width - gagt_box_width - 4) / 2; - else - gagt_box_startx = (centering_width - gagt_box_width) / 2; - - /* If the box turns out wider than the window, abandon centering. */ - if (gagt_box_startx < 0) - gagt_box_startx = 0; - } - - /* - * When in a box, we'll coerce fixed width font by setting it in the AGT - * font attributes. This ensures that the box displays as accurately as - * we're able to achieve. - */ - gagt_coerce_fixed_font (TRUE); - - /* Position the cursor for the box, and if bordered, write the rule. */ - gagt_box_position (gagt_box_startx); - if (gagt_box_flags & TB_BORDER) - { - gagt_box_rule (gagt_box_width + 2); - gagt_box_position (gagt_box_startx); - agt_puts ("| "); - } - - gagt_debug ("agt_makebox", "width=%d, height=%d, flags=0x%lx", - width, height, flags); -} - -void -agt_qnewline (void) -{ - assert (gagt_box_busy); - - /* Write box characters for the current and next line. */ - if (gagt_box_flags & TB_BORDER) - { - agt_puts (" |"); - gagt_box_position (gagt_box_startx); - agt_puts ("| "); - } - else - gagt_box_position (gagt_box_startx); - - gagt_debug ("agt_qnewline", ""); -} - -void -agt_endbox (void) -{ - assert (gagt_box_busy); - - /* Finish off the current box. */ - if (gagt_box_flags & TB_BORDER) - { - agt_puts (" |"); - gagt_box_position (gagt_box_startx); - gagt_box_rule (gagt_box_width + 2); - } - agt_newline (); - - /* An extra newline here improves the appearance. */ - agt_newline (); - - /* Back to allowing proportional font output again. */ - gagt_coerce_fixed_font (FALSE); - - gagt_box_busy = FALSE; - gagt_box_flags = gagt_box_width = gagt_box_startx = 0; - - gagt_debug ("agt_endbox", ""); -} - - -/*---------------------------------------------------------------------*/ -/* Glk command escape functions */ -/*---------------------------------------------------------------------*/ - -/* - * gagt_command_script() - * - * Turn game output scripting (logging) on and off. - */ -static void -gagt_command_script (const char *argument) -{ - assert (argument); - - if (gagt_strcasecmp (argument, "on") == 0) - { - frefid_t fileref; - - if (gagt_transcript_stream) - { - gagt_normal_string ("Glk transcript is already on.\n"); - return; - } - - fileref = glk_fileref_create_by_prompt (fileusage_Transcript - | fileusage_TextMode, - filemode_WriteAppend, 0); - if (!fileref) - { - gagt_standout_string ("Glk transcript failed.\n"); - return; - } - - gagt_transcript_stream = glk_stream_open_file (fileref, - filemode_WriteAppend, 0); - glk_fileref_destroy (fileref); - if (!gagt_transcript_stream) - { - gagt_standout_string ("Glk transcript failed.\n"); - return; - } - - glk_window_set_echo_stream (gagt_main_window, gagt_transcript_stream); - - gagt_normal_string ("Glk transcript is now on.\n"); - } - - else if (gagt_strcasecmp (argument, "off") == 0) - { - if (!gagt_transcript_stream) - { - gagt_normal_string ("Glk transcript is already off.\n"); - return; - } - - glk_stream_close (gagt_transcript_stream, NULL); - gagt_transcript_stream = NULL; - - glk_window_set_echo_stream (gagt_main_window, NULL); - - gagt_normal_string ("Glk transcript is now off.\n"); - } - - else if (strlen (argument) == 0) - { - gagt_normal_string ("Glk transcript is "); - gagt_normal_string (gagt_transcript_stream ? "on" : "off"); - gagt_normal_string (".\n"); - } - - else - { - gagt_normal_string ("Glk transcript can be "); - gagt_standout_string ("on"); - gagt_normal_string (", or "); - gagt_standout_string ("off"); - gagt_normal_string (".\n"); - } -} - - -/* - * gagt_command_inputlog() - * - * Turn game input logging on and off. - */ -static void -gagt_command_inputlog (const char *argument) -{ - assert (argument); - - if (gagt_strcasecmp (argument, "on") == 0) - { - frefid_t fileref; - - if (gagt_inputlog_stream) - { - gagt_normal_string ("Glk input logging is already on.\n"); - return; - } - - fileref = glk_fileref_create_by_prompt (fileusage_InputRecord - | fileusage_BinaryMode, - filemode_WriteAppend, 0); - if (!fileref) - { - gagt_standout_string ("Glk input logging failed.\n"); - return; - } - - gagt_inputlog_stream = glk_stream_open_file (fileref, - filemode_WriteAppend, 0); - glk_fileref_destroy (fileref); - if (!gagt_inputlog_stream) - { - gagt_standout_string ("Glk input logging failed.\n"); - return; - } - - gagt_normal_string ("Glk input logging is now on.\n"); - } - - else if (gagt_strcasecmp (argument, "off") == 0) - { - if (!gagt_inputlog_stream) - { - gagt_normal_string ("Glk input logging is already off.\n"); - return; - } - - glk_stream_close (gagt_inputlog_stream, NULL); - gagt_inputlog_stream = NULL; - - gagt_normal_string ("Glk input log is now off.\n"); - } - - else if (strlen (argument) == 0) - { - gagt_normal_string ("Glk input logging is "); - gagt_normal_string (gagt_inputlog_stream ? "on" : "off"); - gagt_normal_string (".\n"); - } - - else - { - gagt_normal_string ("Glk input logging can be "); - gagt_standout_string ("on"); - gagt_normal_string (", or "); - gagt_standout_string ("off"); - gagt_normal_string (".\n"); - } -} - - -/* - * gagt_command_readlog() - * - * Set the game input log, to read input from a file. - */ -static void -gagt_command_readlog (const char *argument) -{ - assert (argument); - - if (gagt_strcasecmp (argument, "on") == 0) - { - frefid_t fileref; - - if (gagt_readlog_stream) - { - gagt_normal_string ("Glk read log is already on.\n"); - return; - } - - fileref = glk_fileref_create_by_prompt (fileusage_InputRecord - | fileusage_BinaryMode, - filemode_Read, 0); - if (!fileref) - { - gagt_standout_string ("Glk read log failed.\n"); - return; - } - - if (!glk_fileref_does_file_exist (fileref)) - { - glk_fileref_destroy (fileref); - gagt_standout_string ("Glk read log failed.\n"); - return; - } - - gagt_readlog_stream = glk_stream_open_file (fileref, filemode_Read, 0); - glk_fileref_destroy (fileref); - if (!gagt_readlog_stream) - { - gagt_standout_string ("Glk read log failed.\n"); - return; - } - - gagt_normal_string ("Glk read log is now on.\n"); - } - - else if (gagt_strcasecmp (argument, "off") == 0) - { - if (!gagt_readlog_stream) - { - gagt_normal_string ("Glk read log is already off.\n"); - return; - } - - glk_stream_close (gagt_readlog_stream, NULL); - gagt_readlog_stream = NULL; - - gagt_normal_string ("Glk read log is now off.\n"); - } - - else if (strlen (argument) == 0) - { - gagt_normal_string ("Glk read log is "); - gagt_normal_string (gagt_readlog_stream ? "on" : "off"); - gagt_normal_string (".\n"); - } - - else - { - gagt_normal_string ("Glk read log can be "); - gagt_standout_string ("on"); - gagt_normal_string (", or "); - gagt_standout_string ("off"); - gagt_normal_string (".\n"); - } -} - - -/* - * gagt_command_abbreviations() - * - * Turn abbreviation expansions on and off. - */ -static void -gagt_command_abbreviations (const char *argument) -{ - assert (argument); - - if (gagt_strcasecmp (argument, "on") == 0) - { - if (gagt_abbreviations_enabled) - { - gagt_normal_string ("Glk abbreviation expansions are already on.\n"); - return; - } - - gagt_abbreviations_enabled = TRUE; - gagt_normal_string ("Glk abbreviation expansions are now on.\n"); - } - - else if (gagt_strcasecmp (argument, "off") == 0) - { - if (!gagt_abbreviations_enabled) - { - gagt_normal_string ("Glk abbreviation expansions are already off.\n"); - return; - } - - gagt_abbreviations_enabled = FALSE; - gagt_normal_string ("Glk abbreviation expansions are now off.\n"); - } - - else if (strlen (argument) == 0) - { - gagt_normal_string ("Glk abbreviation expansions are "); - gagt_normal_string (gagt_abbreviations_enabled ? "on" : "off"); - gagt_normal_string (".\n"); - } - - else - { - gagt_normal_string ("Glk abbreviation expansions can be "); - gagt_standout_string ("on"); - gagt_normal_string (", or "); - gagt_standout_string ("off"); - gagt_normal_string (".\n"); - } -} - - -/* - * gagt_command_fonts() - * - * Set the value for gagt_font_mode depending on the argument from the - * user's command escape. - * - * Despite our best efforts, font control may still be wrong in some games. - * This command gives us a chance to correct that. - */ -static void -gagt_command_fonts (const char *argument) -{ - assert (argument); - - if (gagt_strcasecmp (argument, "fixed") == 0) - { - if (gagt_font_mode == FONT_FIXED_WIDTH) - { - gagt_normal_string ("Glk font control is already 'fixed'.\n"); - return; - } - - gagt_font_mode = FONT_FIXED_WIDTH; - gagt_normal_string ("Glk font control is now 'fixed'.\n"); - } - - else if (gagt_strcasecmp (argument, "variable") == 0 - || gagt_strcasecmp (argument, "proportional") == 0) - { - if (gagt_font_mode == FONT_PROPORTIONAL) - { - gagt_normal_string ("Glk font control is already 'proportional'.\n"); - return; - } - - gagt_font_mode = FONT_PROPORTIONAL; - gagt_normal_string ("Glk font control is now 'proportional'.\n"); - } - - else if (gagt_strcasecmp (argument, "auto") == 0 - || gagt_strcasecmp (argument, "automatic") == 0) - { - if (gagt_font_mode == FONT_AUTOMATIC) - { - gagt_normal_string ("Glk font control is already 'automatic'.\n"); - return; - } - - gagt_font_mode = FONT_AUTOMATIC; - gagt_normal_string ("Glk font control is now 'automatic'.\n"); - } - - else if (gagt_strcasecmp (argument, "debug") == 0) - { - if (gagt_font_mode == FONT_DEBUG) - { - gagt_normal_string ("Glk font control is already 'debug'.\n"); - return; - } - - gagt_font_mode = FONT_DEBUG; - gagt_normal_string ("Glk font control is now 'debug'.\n"); - } - - else if (strlen (argument) == 0) - { - gagt_normal_string ("Glk font control is set to '"); - switch (gagt_font_mode) - { - case FONT_AUTOMATIC: - gagt_normal_string ("automatic"); - break; - - case FONT_FIXED_WIDTH: - gagt_normal_string ("fixed"); - break; - - case FONT_PROPORTIONAL: - gagt_normal_string ("proportional"); - break; - - case FONT_DEBUG: - gagt_normal_string ("debug"); - break; - - default: - gagt_fatal ("GLK: Invalid font mode encountered"); - gagt_exit (); - } - gagt_normal_string ("'.\n"); - } - - else - { - /* Avoid mentioning the debug setting. */ - gagt_normal_string ("Glk font control can be "); - gagt_standout_string ("fixed"); - gagt_normal_string (", "); - gagt_standout_string ("proportional"); - gagt_normal_string (", or "); - gagt_standout_string ("automatic"); - gagt_normal_string (".\n"); - } -} - - -/* - * gagt_command_delays() - * - * Set a value for gagt_delay_mode depending on the argument from - * the user's command escape. - */ -static void -gagt_command_delays (const char *argument) -{ - assert (argument); - - if (!glk_gestalt (gestalt_Timer, 0)) - { - gagt_normal_string ("Glk delays are not available.\n"); - return; - } - - if (gagt_strcasecmp (argument, "full") == 0 - || gagt_strcasecmp (argument, "on") == 0) - { - if (gagt_delay_mode == DELAY_FULL) - { - gagt_normal_string ("Glk delay mode is already 'full'.\n"); - return; - } - - gagt_delay_mode = DELAY_FULL; - gagt_normal_string ("Glk delay mode is now 'full'.\n"); - } - - else if (gagt_strcasecmp (argument, "short") == 0 - || gagt_strcasecmp (argument, "half") == 0) - { - if (gagt_delay_mode == DELAY_SHORT) - { - gagt_normal_string ("Glk delay mode is already 'short'.\n"); - return; - } - - gagt_delay_mode = DELAY_SHORT; - gagt_normal_string ("Glk delay mode is now 'short'.\n"); - } - - else if (gagt_strcasecmp (argument, "none") == 0 - || gagt_strcasecmp (argument, "off") == 0) - { - if (gagt_delay_mode == DELAY_OFF) - { - gagt_normal_string ("Glk delay mode is already 'none'.\n"); - return; - } - - gagt_delay_mode = DELAY_OFF; - gagt_normal_string ("Glk delay mode is now 'none'.\n"); - } - - else if (strlen (argument) == 0) - { - gagt_normal_string ("Glk delay mode is set to '"); - switch (gagt_delay_mode) - { - case DELAY_FULL: - gagt_normal_string ("full"); - break; - - case DELAY_SHORT: - gagt_normal_string ("short"); - break; - - case DELAY_OFF: - gagt_normal_string ("none"); - break; - - default: - gagt_fatal ("GLK: Invalid delay mode encountered"); - gagt_exit (); - } - gagt_normal_string ("'.\n"); - } - - else - { - gagt_normal_string ("Glk delay mode can be "); - gagt_standout_string ("full"); - gagt_normal_string (", "); - gagt_standout_string ("short"); - gagt_normal_string (", or "); - gagt_standout_string ("none"); - gagt_normal_string (".\n"); - } -} - - -/* - * gagt_command_width() - * - * Print out the (approximate) display width, from status_width. It's - * approximate because the main window might include a scrollbar that - * the status window doesn't have, may use a different size font, and so - * on. But the main window won't tell us a width at all - it always - * returns zero. If we don't happen to have a status window available - * to us, there's not much we can say. - * - * Note that this function uses the interpreter variable status_width, - * so it's important to keep this updated with the current window size at - * all times. - */ -static void -gagt_command_width (const char *argument) -{ - char buffer[16]; - assert (argument); - - if (!gagt_status_window) - { - gagt_normal_string ("Glk's current display width is unknown.\n"); - return; - } - - gagt_normal_string ("Glk's current display width is approximately "); - sprintf (buffer, "%d", status_width); - gagt_normal_string (buffer); - gagt_normal_string (status_width == 1 ? " character" : " characters"); - gagt_normal_string (".\n"); -} - - -/* - * gagt_command_replacements() - * - * Turn Glk special paragraph replacement on and off. - */ -static void -gagt_command_replacements (const char *argument) -{ - assert (argument); - - if (gagt_strcasecmp (argument, "on") == 0) - { - if (gagt_replacement_enabled) - { - gagt_normal_string ("Glk replacements are already on.\n"); - return; - } - - gagt_replacement_enabled = TRUE; - gagt_normal_string ("Glk replacements are now on.\n"); - } - - else if (gagt_strcasecmp (argument, "off") == 0) - { - if (!gagt_replacement_enabled) - { - gagt_normal_string ("Glk replacements are already off.\n"); - return; - } - - gagt_replacement_enabled = FALSE; - gagt_normal_string ("Glk replacements are now off.\n"); - } - - else if (strlen (argument) == 0) - { - gagt_normal_string ("Glk replacements are "); - gagt_normal_string (gagt_replacement_enabled ? "on" : "off"); - gagt_normal_string (".\n"); - } - - else - { - gagt_normal_string ("Glk replacements can be "); - gagt_standout_string ("on"); - gagt_normal_string (", or "); - gagt_standout_string ("off"); - gagt_normal_string (".\n"); - } -} - - -/* - * gagt_command_statusline() - * - * Turn the extended status line on and off. - */ -static void -gagt_command_statusline (const char *argument) -{ - assert (argument); - - if (!gagt_status_window) - { - gagt_normal_string ("Glk status window is not available.\n"); - return; - } - - if (gagt_strcasecmp (argument, "extended") == 0 - || gagt_strcasecmp (argument, "full") == 0) - { - if (gagt_extended_status_enabled) - { - gagt_normal_string ("Glk status line mode is already 'extended'.\n"); - return; - } - - /* Expand the status window down to a second line. */ - glk_window_set_arrangement (glk_window_get_parent (gagt_status_window), - winmethod_Above | winmethod_Fixed, 2, NULL); - gagt_extended_status_enabled = TRUE; - - gagt_normal_string ("Glk status line mode is now 'extended'.\n"); - } - - else if (gagt_strcasecmp (argument, "short") == 0 - || gagt_strcasecmp (argument, "normal") == 0) - { - if (!gagt_extended_status_enabled) - { - gagt_normal_string ("Glk status line mode is already 'short'.\n"); - return; - } - - /* Shrink the status window down to one line. */ - glk_window_set_arrangement (glk_window_get_parent (gagt_status_window), - winmethod_Above | winmethod_Fixed, 1, NULL); - gagt_extended_status_enabled = FALSE; - - gagt_normal_string ("Glk status line mode is now 'short'.\n"); - } - - else if (strlen (argument) == 0) - { - gagt_normal_string ("Glk status line mode is set to '"); - gagt_normal_string (gagt_extended_status_enabled ? "extended" : "short"); - gagt_normal_string ("'.\n"); - } - - else - { - gagt_normal_string ("Glk status line can be "); - gagt_standout_string ("extended"); - gagt_normal_string (", or "); - gagt_standout_string ("short"); - gagt_normal_string (".\n"); - } -} - - -/* - * gagt_command_print_version_number() - * gagt_command_version() - * - * Print out the Glk library version number. - */ -static void -gagt_command_print_version_number (glui32 version) -{ - char buffer[64]; - - sprintf (buffer, "%lu.%lu.%lu", - version >> 16, (version >> 8) & 0xff, version & 0xff); - gagt_normal_string (buffer); -} - -static void -gagt_command_version (const char *argument) -{ - glui32 version; - assert (argument); - - gagt_normal_string ("This is version "); - gagt_command_print_version_number (GAGT_PORT_VERSION); - gagt_normal_string (" of the Glk AGiliTy port.\n"); - - version = glk_gestalt (gestalt_Version, 0); - gagt_normal_string ("The Glk library version is "); - gagt_command_print_version_number (version); - gagt_normal_string (".\n"); -} - - -/* - * gagt_command_commands() - * - * Turn command escapes off. Once off, there's no way to turn them back on. - * Commands must be on already to enter this function. - */ -static void -gagt_command_commands (const char *argument) -{ - assert (argument); - - if (gagt_strcasecmp (argument, "on") == 0) - { - gagt_normal_string ("Glk commands are already on.\n"); - } - - else if (gagt_strcasecmp (argument, "off") == 0) - { - gagt_commands_enabled = FALSE; - gagt_normal_string ("Glk commands are now off.\n"); - } - - else if (strlen (argument) == 0) - { - gagt_normal_string ("Glk commands are "); - gagt_normal_string (gagt_commands_enabled ? "on" : "off"); - gagt_normal_string (".\n"); - } - - else - { - gagt_normal_string ("Glk commands can be "); - gagt_standout_string ("on"); - gagt_normal_string (", or "); - gagt_standout_string ("off"); - gagt_normal_string (".\n"); - } -} - - -/* - * gagt_command_license() - * - * Print licensing terms. - */ -static void -gagt_command_license (const char *argument) -{ - assert (argument); - - gagt_normal_string ("This program is free software; you can redistribute it" - " and/or modify it under the terms of version 2 of the" - " GNU General Public License as published by the Free" - " Software Foundation.\n\n"); - - gagt_normal_string ("This program is distributed in the hope that it will be" - " useful, but "); - gagt_standout_string ("WITHOUT ANY WARRANTY"); - gagt_normal_string ("; without even the implied warranty of "); - gagt_standout_string ("MERCHANTABILITY"); - gagt_normal_string (" or "); - gagt_standout_string ("FITNESS FOR A PARTICULAR PURPOSE"); - gagt_normal_string (". See the GNU General Public License for more" - " details.\n\n"); - - gagt_normal_string ("You should have received a copy of the GNU General" - " Public License along with this program; if not, write" - " to the Free Software Foundation, Inc., 59 Temple" - " Place, Suite 330, Boston, MA 02111-1307 USA\n\n"); - - gagt_normal_string ("Please report any bugs, omissions, or misfeatures to "); - gagt_standout_string ("simon_baldwin@yahoo.com"); - gagt_normal_string (".\n"); -} - - -/* Glk subcommands and handler functions. */ -typedef const struct -{ - const char * const command; /* Glk subcommand. */ - void (* const handler) (const char *argument); /* Subcommand handler. */ - const int takes_argument; /* Argument flag. */ -} gagt_command_t; -typedef gagt_command_t *gagt_commandref_t; - -static void gagt_command_summary (const char *argument); -static void gagt_command_help (const char *argument); - -static gagt_command_t GAGT_COMMAND_TABLE[] = { - {"summary", gagt_command_summary, FALSE}, - {"script", gagt_command_script, TRUE}, - {"inputlog", gagt_command_inputlog, TRUE}, - {"readlog", gagt_command_readlog, TRUE}, - {"abbreviations", gagt_command_abbreviations, TRUE}, - {"fonts", gagt_command_fonts, TRUE}, - {"delays", gagt_command_delays, TRUE}, - {"width", gagt_command_width, FALSE}, - {"replacements", gagt_command_replacements, TRUE}, - {"statusline", gagt_command_statusline, TRUE}, - {"version", gagt_command_version, FALSE}, - {"commands", gagt_command_commands, TRUE}, - {"license", gagt_command_license, FALSE}, - {"help", gagt_command_help, TRUE}, - {NULL, NULL, FALSE} -}; - - -/* - * gagt_command_summary() - * - * Report all current Glk settings. - */ -static void -gagt_command_summary (const char *argument) -{ - gagt_commandref_t entry; - assert (argument); - - /* - * Call handlers that have status to report with an empty argument, - * prompting each to print its current setting. - */ - for (entry = GAGT_COMMAND_TABLE; entry->command; entry++) - { - if (entry->handler == gagt_command_summary - || entry->handler == gagt_command_license - || entry->handler == gagt_command_help) - continue; - - entry->handler (""); - } -} - - -/* - * gagt_command_help() - * - * Document the available Glk commands. - */ -static void -gagt_command_help (const char *command) -{ - gagt_commandref_t entry, matched; - assert (command); - - if (strlen (command) == 0) - { - gagt_normal_string ("Glk commands are"); - for (entry = GAGT_COMMAND_TABLE; entry->command; entry++) - { - gagt_commandref_t next; - - next = entry + 1; - gagt_normal_string (next->command ? " " : " and "); - gagt_standout_string (entry->command); - gagt_normal_string (next->command ? "," : ".\n\n"); - } - - gagt_normal_string ("Glk commands may be abbreviated, as long as" - " the abbreviation is unambiguous. Use "); - gagt_standout_string ("glk help"); - gagt_normal_string (" followed by a Glk command name for help on that" - " command.\n"); - return; - } - - matched = NULL; - for (entry = GAGT_COMMAND_TABLE; entry->command; entry++) - { - if (gagt_strncasecmp (command, entry->command, strlen (command)) == 0) - { - if (matched) - { - gagt_normal_string ("The Glk command "); - gagt_standout_string (command); - gagt_normal_string (" is ambiguous. Try "); - gagt_standout_string ("glk help"); - gagt_normal_string (" for more information.\n"); - return; - } - matched = entry; - } - } - if (!matched) - { - gagt_normal_string ("The Glk command "); - gagt_standout_string (command); - gagt_normal_string (" is not valid. Try "); - gagt_standout_string ("glk help"); - gagt_normal_string (" for more information.\n"); - return; - } - - if (matched->handler == gagt_command_summary) - { - gagt_normal_string ("Prints a summary of all the current Glk AGiliTy" - " settings.\n"); - } - - else if (matched->handler == gagt_command_script) - { - gagt_normal_string ("Logs the game's output to a file.\n\nUse "); - gagt_standout_string ("glk script on"); - gagt_normal_string (" to begin logging game output, and "); - gagt_standout_string ("glk script off"); - gagt_normal_string (" to end it. Glk AGiliTy will ask you for a file" - " when you turn scripts on.\n"); - } - - else if (matched->handler == gagt_command_inputlog) - { - gagt_normal_string ("Records the commands you type into a game.\n\nUse "); - gagt_standout_string ("glk inputlog on"); - gagt_normal_string (", to begin recording your commands, and "); - gagt_standout_string ("glk inputlog off"); - gagt_normal_string (" to turn off input logs. You can play back" - " recorded commands into a game with the "); - gagt_standout_string ("glk readlog"); - gagt_normal_string (" command.\n"); - } - - else if (matched->handler == gagt_command_readlog) - { - gagt_normal_string ("Plays back commands recorded with "); - gagt_standout_string ("glk inputlog on"); - gagt_normal_string (".\n\nUse "); - gagt_standout_string ("glk readlog on"); - gagt_normal_string (". Command play back stops at the end of the" - " file. You can also play back commands from a" - " text file created using any standard editor.\n"); - } - - else if (matched->handler == gagt_command_abbreviations) - { - gagt_normal_string ("Controls abbreviation expansion.\n\nGlk AGiliTy" - " automatically expands several standard single" - " letter abbreviations for you; for example, \"x\"" - " becomes \"examine\". Use "); - gagt_standout_string ("glk abbreviations on"); - gagt_normal_string (" to turn this feature on, and "); - gagt_standout_string ("glk abbreviations off"); - gagt_normal_string (" to turn it off. While the feature is on, you" - " can bypass abbreviation expansion for an" - " individual game command by prefixing it with a" - " single quote.\n"); - } - - else if (matched->handler == gagt_command_fonts) - { - gagt_normal_string ("Controls the way Glk AGiliTy uses fonts.\n\n" - "AGT games normally assume 80x25 monospaced font" - " displays. Glk can often use proportional fonts." - " To try to improve text display, Glk AGiliTy will" - " attempt to automatically detect when game text" - " can be displayed safely in a proportional font," - " and when fixed width fonts are required. For" - " some games, however, you may need to override" - " it. Use "); - gagt_standout_string ("glk fonts automatic"); - gagt_normal_string (", "); - gagt_standout_string ("glk fonts proportional"); - gagt_normal_string (", and "); - gagt_standout_string ("glk fonts fixed"); - gagt_normal_string (" to switch between Glk AGiliTy font modes.\n"); - } - - else if (matched->handler == gagt_command_delays) - { - gagt_normal_string ("Shortens, or eliminates, AGT game delays.\n\nUse "); - gagt_standout_string ("glk delays full"); - gagt_normal_string (", "); - gagt_standout_string ("glk delays short"); - gagt_normal_string (", or "); - gagt_standout_string ("glk delays none"); - gagt_normal_string (". In Glk AGiliTy, you can also end an AGT game's" - " delay early, by pressing Space while the game is" - " delaying.\n"); - } - - else if (matched->handler == gagt_command_width) - { - gagt_normal_string ("Prints the screen width available for fixed font" - " display.\n\nEven though Glk AGiliTy tries to handle" - " issues surrounding proportional font displays for" - " you automatically, some game elements may still" - " need to display in fixed width fonts. These" - " elements will be happiest if the available screen" - " width is at least 80 columns.\n"); - } - - else if (matched->handler == gagt_command_replacements) - { - gagt_normal_string ("Controls game text scanning and replacement.\n\n" - "Glk AGiliTy can monitor the game's output, and" - " replace a few selected standard messages with" - " equivalents, printed using a style that stands" - " out better in Glk displays. Use "); - gagt_standout_string ("glk replacements on"); - gagt_normal_string (" to turn this feature on, and "); - gagt_standout_string ("glk replacements off"); - gagt_normal_string (" to turn it off.\n"); - } - - else if (matched->handler == gagt_command_statusline) - { - gagt_normal_string ("Controls the Glk AGiliTy status line display.\n\n" - "Use "); - gagt_standout_string ("glk statusline extended"); - gagt_normal_string (" to display a full, two line status display, and "); - gagt_standout_string ("glk statusline short"); - gagt_normal_string (" for a single line status display.\n"); - } - - else if (matched->handler == gagt_command_version) - { - gagt_normal_string ("Prints the version numbers of the Glk library" - " and the Glk AGiliTy port.\n"); - } - - else if (matched->handler == gagt_command_commands) - { - gagt_normal_string ("Turn off Glk commands.\n\nUse "); - gagt_standout_string ("glk commands off"); - gagt_normal_string (" to disable all Glk commands, including this one." - " Once turned off, there is no way to turn Glk" - " commands back on while inside the game.\n"); - } - - else if (matched->handler == gagt_command_license) - { - gagt_normal_string ("Prints Glk AGiliTy's software license.\n"); - } - - else if (matched->handler == gagt_command_help) - gagt_command_help (""); - - else - gagt_normal_string ("There is no help available on that Glk command." - " Sorry.\n"); -} - - -/* - * gagt_command_escape() - * - * This function is handed each input line. If the line contains a specific - * Glk port command, handle it and return TRUE, otherwise return FALSE. - */ -static int -gagt_command_escape (const char *string) -{ - int posn; - char *string_copy, *command, *argument; - assert (string); - - /* - * Return FALSE if the string doesn't begin with the Glk command escape - * introducer. - */ - posn = strspn (string, "\t "); - if (gagt_strncasecmp (string + posn, "glk", strlen ("glk")) != 0) - return FALSE; - - /* Take a copy of the string, without any leading space or introducer. */ - string_copy = gagt_malloc (strlen (string + posn) + 1 - strlen ("glk")); - strcpy (string_copy, string + posn + strlen ("glk")); - - /* - * Find the subcommand; the first word in the string copy. Find its end, - * and ensure it terminates with a NUL. - */ - posn = strspn (string_copy, "\t "); - command = string_copy + posn; - posn += strcspn (string_copy + posn, "\t "); - if (string_copy[posn] != '\0') - string_copy[posn++] = '\0'; - - /* - * Now find any argument data for the command, ensuring it too terminates - * with a NUL. - */ - posn += strspn (string_copy + posn, "\t "); - argument = string_copy + posn; - posn += strcspn (string_copy + posn, "\t "); - string_copy[posn] = '\0'; - - /* - * Try to handle the command and argument as a Glk subcommand. If it - * doesn't run unambiguously, print command usage. Treat an empty command - * as "help". - */ - if (strlen (command) > 0) - { - gagt_commandref_t entry, matched; - int matches; - - /* - * Search for the first unambiguous table command string matching - * the command passed in. - */ - matches = 0; - matched = NULL; - for (entry = GAGT_COMMAND_TABLE; entry->command; entry++) - { - if (gagt_strncasecmp (command, entry->command, strlen (command)) == 0) - { - matches++; - matched = entry; - } - } - - /* If the match was unambiguous, call the command handler. */ - if (matches == 1) - { - gagt_normal_char ('\n'); - matched->handler (argument); - - if (!matched->takes_argument && strlen (argument) > 0) - { - gagt_normal_string ("[The "); - gagt_standout_string (matched->command); - gagt_normal_string (" command ignores arguments.]\n"); - } - } - - /* No match, or the command was ambiguous. */ - else - { - gagt_normal_string ("\nThe Glk command "); - gagt_standout_string (command); - gagt_normal_string (" is "); - gagt_normal_string (matches == 0 ? "not valid" : "ambiguous"); - gagt_normal_string (". Try "); - gagt_standout_string ("glk help"); - gagt_normal_string (" for more information.\n"); - } - } - else - { - gagt_normal_char ('\n'); - gagt_command_help (""); - } - - /* The string contained a Glk command; return TRUE. */ - free (string_copy); - return TRUE; -} - - -/*---------------------------------------------------------------------*/ -/* Glk port input functions */ -/*---------------------------------------------------------------------*/ - -/* Longest line we're going to buffer for input. */ -enum { GAGT_INPUTBUFFER_LENGTH = 256 }; - -/* Table of single-character command abbreviations. */ -typedef const struct -{ - const char abbreviation; /* Abbreviation character. */ - const char * const expansion; /* Expansion string. */ -} gagt_abbreviation_t; -typedef gagt_abbreviation_t *gagt_abbreviationref_t; - -static gagt_abbreviation_t GAGT_ABBREVIATIONS[] = { - {'c', "close"}, {'g', "again"}, {'i', "inventory"}, - {'k', "attack"}, {'l', "look"}, {'p', "open"}, - {'q', "quit"}, {'r', "drop"}, {'t', "take"}, - {'x', "examine"}, {'y', "yes"}, {'z', "wait"}, - {'\0', NULL} -}; - - -/* - * gagt_expand_abbreviations() - * - * Expand a few common one-character abbreviations commonly found in other - * game systems, but not always normal in AGT games. - */ -static void -gagt_expand_abbreviations (char *buffer, int size) -{ - char *command, abbreviation; - const char *expansion; - gagt_abbreviationref_t entry; - assert (buffer); - - /* Ignore anything that isn't a single letter command. */ - command = buffer + strspn (buffer, "\t "); - if (!(strlen (command) == 1 - || (strlen (command) > 1 && isspace (command[1])))) - return; - - /* Scan the abbreviations table for a match. */ - abbreviation = glk_char_to_lower ((unsigned char) command[0]); - expansion = NULL; - for (entry = GAGT_ABBREVIATIONS; entry->expansion; entry++) - { - if (entry->abbreviation == abbreviation) - { - expansion = entry->expansion; - break; - } - } - - /* - * If a match found, check for a fit, then replace the character with the - * expansion string. - */ - if (expansion) - { - if (strlen (buffer) + strlen (expansion) - 1 >= size) - return; - - memmove (command + strlen (expansion) - 1, command, strlen (command) + 1); - memcpy (command, expansion, strlen (expansion)); - - gagt_standout_string ("["); - gagt_standout_char (abbreviation); - gagt_standout_string (" -> "); - gagt_standout_string (expansion); - gagt_standout_string ("]\n"); - } -} - - -/* - * agt_input() - * - * Read a line from the keyboard, allocating space for it using malloc. - * AGiliTy defines the following for the in_type argument: - * - * in_type: 0=command, 1=number, 2=question, 3=userstr, 4=filename, - * 5=RESTART,RESTORE,UNDO,QUIT - * Negative values are for internal use by the interface (i.e. this module) - * and so are free to be defined by the porter. - * - * Since it's unclear what use we can make of this information in Glk, - * for the moment the argument is ignored. It seems that no-one else - * uses it, either. - */ -char * -agt_input (int in_type) -{ - event_t event; - int length; - char *buffer; - - /* - * Update the current status line display, and flush any pending buffered - * output. Release any suspension of delays. - */ - gagt_status_notify (); - gagt_output_flush (); - gagt_delay_resume (); - - /* Reset current x, as line input implies a newline. */ - curr_x = 0; - - /* Allocate a line input buffer, allowing 256 characters and a NUL. */ - length = GAGT_INPUTBUFFER_LENGTH + 1; - buffer = gagt_malloc (length); - - /* - * If we have an input log to read from, use that until it is exhausted. - * On end of file, close the stream and resume input from line requests. - */ - if (gagt_readlog_stream) - { - glui32 chars; - - /* Get the next line from the log stream. */ - chars = glk_get_line_stream (gagt_readlog_stream, buffer, length); - if (chars > 0) - { - /* Echo the line just read in input style. */ - glk_set_style (style_Input); - glk_put_buffer (buffer, chars); - glk_set_style (style_Normal); - - /* - * Convert the string from Glk's ISO 8859 Latin-1 to IBM cp 437, - * add to any script, and return it. - */ - gagt_iso_to_cp (buffer, buffer); - if (script_on) - textputs (scriptfile, buffer); - return buffer; - } - - /* - * We're at the end of the log stream. Close it, and then continue - * on to request a line from Glk. - */ - glk_stream_close (gagt_readlog_stream, NULL); - gagt_readlog_stream = NULL; - } - - /* Set this up as a read buffer for the main window, and wait. */ - glk_request_line_event (gagt_main_window, buffer, length - 1, 0); - gagt_event_wait (evtype_LineInput, &event); - - /* Terminate the input line with a NUL. */ - assert (event.val1 < length); - buffer[event.val1] = '\0'; - - /* - * If neither abbreviations nor local commands are enabled, use the data - * read above without further massaging. - */ - if (gagt_abbreviations_enabled || gagt_commands_enabled) - { - char *command; - - /* - * If the first non-space input character is a quote, bypass all - * abbreviation expansion and local command recognition, and use the - * unadulterated input, less introductory quote. - */ - command = buffer + strspn (buffer, "\t "); - if (command[0] == '\'') - { - /* Delete the quote with memmove(). */ - memmove (command, command + 1, strlen (command)); - } - else - { - /* Check for, and expand, any abbreviated commands. */ - if (gagt_abbreviations_enabled) - gagt_expand_abbreviations (buffer, length); - - /* - * Check for standalone "help", then for Glk port special commands; - * suppress the interpreter's use of this input for Glk commands. - */ - if (gagt_commands_enabled) - { - int posn; - - posn = strspn (buffer, "\t "); - if (gagt_strncasecmp (buffer + posn, "help", strlen ("help"))== 0) - { - if (strspn (buffer + posn + strlen ("help"), "\t ") - == strlen (buffer + posn + strlen ("help"))) - { - gagt_display_register_help_request (); - } - } - - if (gagt_command_escape (buffer)) - { - gagt_display_silence_help_hints (); - buffer[0] = '\0'; - return buffer; - } - } - } - } - - /* - * If there is an input log active, log this input string to it. Note that - * by logging here we get any abbreviation expansions but we won't log glk - * special commands, nor any input read from a current open input log. - */ - if (gagt_inputlog_stream) - { - glk_put_string_stream (gagt_inputlog_stream, buffer); - glk_put_char_stream (gagt_inputlog_stream, '\n'); - } - - /* - * Convert from Glk's ISO 8859 Latin-1 to IBM cp 437, and add to any script. - */ - gagt_iso_to_cp (buffer, buffer); - if (script_on) - textputs (scriptfile, buffer); - - gagt_debug ("agt_input", "in_type=%d -> '%s'", in_type, buffer); - return buffer; -} - - -/* - * agt_getkey() - * - * Read a single character and return it. AGiliTy defines the echo_char - * argument as: - * - * If echo_char=1, echo character. If 0, then the character is not - * required to be echoed (and ideally shouldn't be). - * - * However, I've found that not all other ports really do this, and in - * practice it doesn't always look right. So for Glk, the character is - * always echoed to the main window. - */ -char -agt_getkey (rbool echo_char) -{ - event_t event; - char buffer[3]; - assert (glk_stream_get_current ()); - - /* - * Update the current status line display, and flush any pending buffered - * output. Release any suspension of delays. - */ - gagt_status_notify (); - gagt_output_flush (); - gagt_delay_resume (); - - /* Reset current x, as echoed character input implies a newline. */ - curr_x = 0; - - /* - * If we have an input log to read from, use that as above until it is - * exhausted. We take just the first character of a given line. - */ - if (gagt_readlog_stream) - { - glui32 chars; - char logbuffer[GAGT_INPUTBUFFER_LENGTH + 1]; - - /* Get the next line from the log stream. */ - chars = glk_get_line_stream (gagt_readlog_stream, - logbuffer, sizeof (logbuffer)); - if (chars > 0) - { - /* Take just the first character, adding a newline if necessary. */ - buffer[0] = logbuffer[0]; - buffer[1] = buffer[0] == '\n' ? '\0' : '\n'; - buffer[2] = '\0'; - - /* Echo the character just read in input style. */ - glk_set_style (style_Input); - glk_put_string (buffer); - glk_set_style (style_Normal); - - /* - * Convert from Glk's ISO 8859 Latin-1 to IBM cp 437, add to any - * script, and return the character. - */ - gagt_iso_to_cp (buffer, buffer); - if (script_on) - textputs (scriptfile, buffer); - return buffer[0]; - } - - /* - * We're at the end of the log stream. Close it, and then continue - * on to request a character from Glk. - */ - glk_stream_close (gagt_readlog_stream, NULL); - gagt_readlog_stream = NULL; - } - - /* - * Request a single character from main window, and wait. Ignore non- - * ASCII codes that Glk returns for special function keys; we just want - * one ASCII return value. (Glk does treat Return as a special key, - * though, and we want to pass that back as ASCII return.) - */ - do - { - glk_request_char_event (gagt_main_window); - gagt_event_wait (evtype_CharInput, &event); - } - while (event.val1 > UCHAR_MAX && event.val1 != keycode_Return); - - /* - * Save the character into a short string buffer, converting Return - * to newline, and adding a newline if not Return. - */ - buffer[0] = event.val1 == keycode_Return ? '\n' : event.val1; - buffer[1] = buffer[0] == '\n' ? '\0' : '\n'; - buffer[2] = '\0'; - - /* If there is an input log active, log this input string to it. */ - if (gagt_inputlog_stream) - glk_put_string_stream (gagt_inputlog_stream, buffer); - - /* - * No matter what echo_char says, as it happens, the output doesn't look - * great if we don't write out the character, and also a newline (c.f. - * the "Yes/No" confirmation of the QUIT command)... - */ - glk_set_style (style_Input); - glk_put_string (buffer); - glk_set_style (style_Normal); - - /* - * Convert from Glk's ISO 8859 Latin-1 to IBM cp 437, and add to any - * script. - */ - gagt_iso_to_cp (buffer, buffer); - if (script_on) - textputs (scriptfile, buffer); - - gagt_debug ("agt_getkey", "echo_char=%d -> '%c'", - echo_char, buffer[0] == '\n' ? '$' : buffer[0]); - return buffer[0]; -} - - -/*---------------------------------------------------------------------*/ -/* Glk port event functions */ -/*---------------------------------------------------------------------*/ - -/* - * We have some clever atexit() finalizer handling for exit() calls that - * come from the core interpreter. However, an exit() call could also come - * from Glk; Xkill for example. To tell the difference, we'll have the - * event wait functions set a flag to indicate when glk_select() is active. - */ -static int gagt_in_glk_select = FALSE; - -/* - * gagt_event_wait_2() - * gagt_event_wait() - * - * Process Glk events until one of the expected type, or types, arrives. - * Return the event of that type. - */ -static void -gagt_event_wait_2 (glui32 wait_type_1, glui32 wait_type_2, event_t * event) -{ - assert (event); - - do - { - gagt_in_glk_select = TRUE; - glk_select (event); - gagt_in_glk_select = FALSE; - - switch (event->type) - { - case evtype_Arrange: - case evtype_Redraw: - gagt_status_redraw (); - break; - } - } - while (!(event->type == wait_type_1 || event->type == wait_type_2)); -} - -static void -gagt_event_wait (glui32 wait_type, event_t * event) -{ - assert (event); - gagt_event_wait_2 (wait_type, evtype_None, event); -} - - -/* - * gagt_event_in_glk_select() - * - * Return TRUE if we're currently awaiting an event in glk_select(). Used - * by the finalizer to distinguish interpreter and glk exit() calls. - */ -static int -gagt_event_in_glk_select (void) -{ - return gagt_in_glk_select; -} - - -/*---------------------------------------------------------------------*/ -/* Miscellaneous Glk port startup and options functions */ -/*---------------------------------------------------------------------*/ - -/* - * Default screen height and width, and also a default status width for - * use with Glk libraries that don't support separate windows. - */ -static const int GAGT_DEFAULT_SCREEN_WIDTH = 80, - GAGT_DEFAULT_SCREEN_HEIGHT = 25, - GAGT_DEFAULT_STATUS_WIDTH = 76; - - -/* - * agt_option() - * - * Platform-specific setup and options handling. AGiliTy defines the - * arguments and options as: - * - * If setflag is 0, then the option was prefixed with NO_. Return 1 if - * the option is recognized. - * - * The Glk port has no options file handling, so none of this is - * implemented here. - */ -rbool -agt_option (int optnum, char *optstr[], rbool setflag) -{ - gagt_debug ("agt_option", "optnum=%d, optstr=%s, setflag=%d", - optnum, optstr[0], setflag); - return 0; -} - - -/* - * agt_globalfile() - * - * Global options file handle handling. For now, this is a stub, since - * there is no .agilrc for this port. - */ -genfile -agt_globalfile (int fid) -{ - gagt_debug ("agt_globalfile", "fid=%d", fid); - return badfile (fCFG); -} - - -/* - * init_interface() - * - * General initialization for the module; sets some variables, and creates - * the Glk windows to work in. Called from the AGiliTy main(). - */ -void -init_interface (int argc, char *argv[]) -{ - glui32 status_height; - - /* - * Begin with some default values for global variables that this module - * is somehow responsible for. - */ - script_on = center_on = par_fill_on = FALSE; - scriptfile = badfile (fSCR); - debugfile = stderr; - - /* - * Set up AGT-specific Glk styles. This needs to be done before any Glk - * window is opened. - */ - gagt_init_user_styles (); - - /* - * Create the main game window. The main game window creation must succeed. - * If it fails, we'll return, and the caller can detect this by looking - * for a NULL main window. - */ - gagt_main_window = glk_window_open (0, 0, 0, wintype_TextBuffer, 0); - if (!gagt_main_window) - return; - - /* - * Set the main window to be the default window, for convenience. We do - * this again in glk_main() -- this call is here just in case this version - * of init_interface() is ever called by AGiliTy's main. - */ - glk_set_window (gagt_main_window); - - /* - * Screen height is something we don't use. Linux Xglk returns dimensions - * of 0x0 for text buffer windows, so we can't measure the main window - * height anyway. But... the height does come into play in AGiliTy's - * agil.c, when the interpreter is deciding how to output game titles, and - * how much of its own subsequent verbiage to output. This gives us a - * problem, since this "verbiage" is stuff we look for and replace with - * our own special text. So... sigh, set 25, and try to cope in the - * special text we've set up with all the variations that ensue. - * - * Screen width does get used, but so, so many games, and for that matter - * the interpreter itself, assume 80 chars, so it's simplest just to set, - * and keep, this, and put up with the minor odd effects (making it match - * status_width, or making it something like MAX_INT to defeat the game's - * own wrapping, gives a lot of odder effects, trust me on this one...). - */ - screen_width = GAGT_DEFAULT_SCREEN_WIDTH; - screen_height = GAGT_DEFAULT_SCREEN_HEIGHT; - - /* - * Create a status window, with one or two lines as selected by user - * options or flags. We can live without a status window if we have to. - */ - status_height = gagt_extended_status_enabled ? 2 : 1; - gagt_status_window = glk_window_open (gagt_main_window, - winmethod_Above | winmethod_Fixed, - status_height, wintype_TextGrid, 0); - if (gagt_status_window) - { - /* - * Call gagt_status_redraw() to set the interpreter's status_width - * variable initial value. - */ - gagt_status_redraw (); - } - else - { - /* - * No status window, so set a suitable default status width. In this - * case, we're using a value four characters less than the set screen - * width. AGiliTy's status line code will fill to this width with - * justified text, and we add two characters of bracketing when - * displaying status lines for Glks that don't support separate windows, - * making a total of 78 characters, which should be fairly standard. - */ - status_width = GAGT_DEFAULT_STATUS_WIDTH; - } - - agt_clrscr (); - gagt_debug ("init_interface", "argc=%d, argv=%p", argc, argv); -} - - -/*---------------------------------------------------------------------*/ -/* Replacement interface.c functions */ -/*---------------------------------------------------------------------*/ - -/* Get_user_file() type codes. */ -enum { - AGT_SCRIPT = 0, - AGT_SAVE = 1, - AGT_RESTORE = 2, - AGT_LOG_READ = 3, - AGT_LOG_WRITE = 4 -}; - -/* Longest acceptable filename. */ -enum { GAGT_MAX_PATH = 1024 }; - - -#ifdef GLK_ANSI_ONLY -/* - * gagt_confirm() - * - * Print a confirmation prompt, and read a single input character, taking - * only [YyNn] input. If the character is 'Y' or 'y', return TRUE. - * - * This function is only required for the ANSI version of get_user_file(). - */ -static int -gagt_confirm (const char *prompt) -{ - event_t event; - unsigned char response; - assert (prompt); - - /* - * Print the confirmation prompt, in a style that hints that it's from the - * interpreter, not the game. - */ - gagt_standout_string (prompt); - - /* Wait for a single 'Y' or 'N' character response. */ - response = ' '; - do - { - glk_request_char_event (gagt_main_window); - gagt_event_wait (evtype_CharInput, &event); - - if (event.val1 <= UCHAR_MAX) - response = glk_char_to_upper (event.val1); - } - while (!(response == 'Y' || response == 'N')); - - /* Echo the confirmation response, and a blank line. */ - glk_set_style (style_Input); - glk_put_string (response == 'Y' ? "Yes" : "No"); - glk_set_style (style_Normal); - glk_put_string ("\n"); - - return response == 'Y'; -} -#endif - - -/* - * gagt_get_user_file() - * - * Alternative versions of functions to get a file name from the user, and - * return a file stream structure. These functions are front-ended by the - * main get_user_file() function, which first converts the AGT file type - * into Glk usage and filemode, and also a mode for fopen()/fdopen(). - * - * The ANSI version of the function prompts for the file using the simple - * method of querying the user through input in the main window. It then - * constructs a file stream around the path entered, and returns it. - * - * The non-ANSI, Glk version is more sneaky. It prompts for a file using - * Glk's functions to get filenames by prompt, file selection dialog, or - * whatever. Then it attempts to uncover which file descriptor Glk opened - * its file on, dup's it, closes the Glk stream, and returns a file stream - * built on this file descriptor. This is all highly non-ANSI, requiring - * dup() and fdopen(), and making some assumptions about the way that dup, - * open, and friends work. It works on Linux, and on Mac (CodeWarrior). - * It may also work for you, but if it doesn't, or if your system lacks - * things like dup or fdopen, define GLK_ANSI_ONLY and use the safe version. - */ -#ifdef GLK_ANSI_ONLY -static genfile -gagt_get_user_file (glui32 usage, glui32 fmode, const char *fdtype) -{ - char filepath[GAGT_MAX_PATH]; - event_t event; - int index, all_spaces; - genfile retfile; - assert (fdtype); - - /* Prompt in a similar way to Glk. */ - switch (usage) - { - case fileusage_SavedGame: - gagt_normal_string ("Enter saved game"); - break; - - case fileusage_Transcript: - gagt_normal_string ("Enter transcript file"); - break; - - case fileusage_InputRecord: - gagt_normal_string ("Enter command record file"); - break; - } - switch (fmode) - { - case filemode_Read: - gagt_normal_string (" to load: "); - break; - - case filemode_Write: - gagt_normal_string (" to store: "); - break; - } - - /* Get the path to the file from the user. */ - glk_request_line_event (gagt_main_window, filepath, sizeof (filepath) - 1, 0); - gagt_event_wait (evtype_LineInput, &event); - - /* Terminate the file path with a NUL. */ - assert (event.val1 < sizeof (filepath)); - filepath[event.val1] = '\0'; - - /* Reject file paths that only contain any whitespace characters. */ - all_spaces = TRUE; - for (index = 0; index < strlen (filepath); index++) - { - if (!isspace (filepath[index])) - { - all_spaces = FALSE; - break; - } - } - if (all_spaces) - return badfile (fSAV); - - /* Confirm overwrite of any existing file. */ - if (fmode == filemode_Write) - { - genfile file; - - file = fopen (filepath, "r"); - if (file) - { - fclose (file); - - if (!gagt_confirm ("Overwrite existing file? [y/n] ")) - return badfile (fSAV); - } - } - - /* Open and return a FILE* stream, or badfile if this fails. */ - retfile = fopen (filepath, fdtype); - return retfile ? retfile : badfile (fSAV); -} -#endif - -#ifndef GLK_ANSI_ONLY -static genfile -gagt_get_user_file (glui32 usage, glui32 fmode, const char *fdtype) -{ - frefid_t fileref; - strid_t stream; - int tryfd, glkfd, dupfd, retfd; - genfile retfile; - assert (fdtype); - - /* Try to get a Glk file reference with these attributes. */ - fileref = glk_fileref_create_by_prompt (usage, fmode, 0); - if (!fileref) - return badfile (fSAV); - - /* - * Reject the file reference if we're expecting to read from it, - * and the referenced file doesn't exist. - */ - if (fmode == filemode_Read && !glk_fileref_does_file_exist (fileref)) - { - glk_fileref_destroy (fileref); - return badfile (fSAV); - } - - /* - * Now, it gets ugly. Glk assumes that the interpreter will do all of - * its reading and writing using the Glk streams read/write functions. - * It won't; at least, not without major surgery. So here we're going - * to do some dangerous stuff... - * - * Since a Glk stream is opaque, it's hard to tell what the underlying - * file descriptor is for it. We can get it if we want to play around - * in the internals of the strid_t structure, but it's unpleasant. - * The alternative is, arguably, no more pleasant, but it makes for - * (perhaps) more portable code. What we'll do is to dup a file, then - * immediately close it, and call glk_stream_open_file(). The open() - * in glk_stream_open_file() will return the same file descriptor number - * that we just close()d (in theory...). This makes the following two - * major assumptions: - * - * 1) glk_stream_open_file() opens precisely one file with open() - * 2) open() always uses the lowest available file descriptor number, - * like dup() - * - * Believe it or not, this is better than the alternatives. There is - * no Glk function to return the filename from a frefid_t, and it - * moves about in different Glk libraries so we can't just take it - * from a given offset. And there is no Glk function to return the - * underlying file descriptor or FILE* from a Glk stream either. :-( - */ - -#ifdef GARGLK - retfile = fopen(garglk_fileref_get_name(fileref), fdtype); -#else - - /* So, start by dup()'ing the first file descriptor we can, ... */ - glkfd = -1; - for (tryfd = 0; tryfd < FD_SETSIZE; tryfd++) - { - glkfd = fcntl (tryfd, F_DUPFD, 0); - if (glkfd != -1) - break; - } - if (tryfd >= FD_SETSIZE) - { - glk_fileref_destroy (fileref); - return badfile (fSAV); - } - - /* ...then closing it, ... */ - close (glkfd); - - /* ...now open the Glk stream, assuming it opens on file 'glkfd', ... */ - stream = glk_stream_open_file (fileref, fmode, 0); - if (!stream) - { - glk_fileref_destroy (fileref); - return badfile (fSAV); - } - - /* ...dup() the Glk file onto another file descriptor, ... */ - dupfd = fcntl (glkfd, F_DUPFD, 0); - assert (dupfd != -1); - - /* ...close and destroy the Glk edifice for this file, ... */ - glk_stream_close (stream, NULL); - glk_fileref_destroy (fileref); - - /* ...for neatness, dup() back to the old Glk file descriptor, ... */ - retfd = fcntl (dupfd, F_DUPFD, 0); - assert (retfd != -1 && retfd == glkfd); - close (dupfd); - - /* ...and finally, open a FILE* stream onto the return descriptor. */ - retfile = fdopen (retfd, fdtype); - if (!retfile) - return badfile (fSAV); -#endif /* GARGLK */ - - /* - * The result of all of this should now be that retfile is a FILE* wrapper - * round a file descriptor open on a file indicated by the user through Glk. - * Return it. - */ - return retfile; -} -#endif - - -/* - * get_user_file() - * - * Get a file name from the user, and return the file stream structure. - * This is a front-end to ANSI and non-ANSI variants of the function. - */ -genfile -get_user_file (int type) -{ - glui32 usage = 0, fmode = 0; - char *fdtype; - genfile retfile; - - gagt_output_flush (); - - /* Map AGiliTy type to Glk usage and filemode. */ - switch (type) - { - case AGT_SCRIPT: - usage = fileusage_Transcript; - fmode = filemode_Write; - break; - - case AGT_SAVE: - usage = fileusage_SavedGame; - fmode = filemode_Write; - break; - - case AGT_RESTORE: - usage = fileusage_SavedGame; - fmode = filemode_Read; - break; - - case AGT_LOG_READ: - usage = fileusage_InputRecord; - fmode = filemode_Read; - break; - - case AGT_LOG_WRITE: - usage = fileusage_InputRecord; - fmode = filemode_Write; - break; - - default: - gagt_fatal ("GLK: Unknown file type encountered"); - gagt_exit (); - } - - /* From these, determine a mode type for the f[d]open() call. */ - if (fmode == filemode_Write) - fdtype = usage == fileusage_SavedGame ? "wb" : "w"; - else - fdtype = usage == fileusage_SavedGame ? "rb" : "r"; - - /* Get a file stream from these using the appropriate function. */ - retfile = gagt_get_user_file (usage, fmode, fdtype); - - gagt_debug ("get_user_file", "type=%d -> %p", type, retfile); - return retfile; -} - - -/* - * set_default_filenames() - * - * Set defaults for last save, log, and script filenames. - */ -void -set_default_filenames (fc_type fc) -{ - /* - * There is nothing to do in this function, since Glk has its own ideas on - * default names for files obtained with a prompt. - */ - gagt_debug ("set_default_filenames", "fc=%p", fc); -} - - -/*---------------------------------------------------------------------*/ -/* Functions intercepted by link-time wrappers */ -/*---------------------------------------------------------------------*/ - -/* - * __wrap_toupper() - * __wrap_tolower() - * - * Wrapper functions around toupper(), tolower(), and fatal(). The Linux - * linker's --wrap option will convert calls to mumble() to __wrap_mumble() - * if we give it the right options. We'll use this feature to translate - * all toupper() and tolower() calls in the interpreter code into calls to - * Glk's versions of these functions. - * - * It's not critical that we do this. If a linker, say a non-Linux one, - * won't do --wrap, then just do without it. It's unlikely that there - * will be much noticeable difference. - */ -int -__wrap_toupper (int ch) -{ - unsigned char uch; - - uch = glk_char_to_upper ((unsigned char) ch); - return (int) uch; -} - -int -__wrap_tolower (int ch) -{ - unsigned char lch; - - lch = glk_char_to_lower ((unsigned char) ch); - return (int) lch; -} - - -/*---------------------------------------------------------------------*/ -/* Replacements for AGiliTy main() and options parsing */ -/*---------------------------------------------------------------------*/ - -/* External declaration of interface.c's set default options function. */ -extern void set_default_options (void); - -/* - * The following values need to be passed between the startup_code and main - * functions. - */ -static int gagt_saved_argc = 0; /* Recorded argc. */ -static char **gagt_saved_argv = NULL, /* Recorded argv. */ - *gagt_gamefile = NULL, /* Name of game file. */ - *gagt_game_message = NULL; /* Error message. */ - -/* - * Flag to set if we want to test for a clean exit. Without this it's a - * touch tricky sometimes to corner AGiliTy into calling exit() for us; it - * tends to require a broken game file. - */ -static int gagt_clean_exit_test = FALSE; - - -/* - * gagt_parse_option() - * - * Glk-ified version of AGiliTy's parse_options() function. In practice, - * because Glk has got to them first, most options that come in here are - * probably going to be single-character ones, since this is what we told - * Glk in the arguments structure above. The Glk font control and other - * special tweaky flags will probably be the only multiple-character ones. - */ -static int -gagt_parse_option (const char *option) -{ - unsigned int index; - assert (option); - - assert (option[0] == '-'); - for (index = 1; option[index]; index++) - { - switch (option[index]) - { - case 'g': - switch (option[++index]) - { - case 'f': - gagt_font_mode = FONT_FIXED_WIDTH; - break; - case 'p': - gagt_font_mode = FONT_PROPORTIONAL; - break; - case 'a': - gagt_font_mode = FONT_AUTOMATIC; - break; - case 'd': - gagt_delay_mode = DELAY_FULL; - break; - case 'h': - gagt_delay_mode = DELAY_SHORT; - break; - case 'n': - gagt_delay_mode = DELAY_OFF; - break; - case 'r': - gagt_replacement_enabled = FALSE; - break; - case 'x': - gagt_abbreviations_enabled = FALSE; - break; - case 's': - gagt_extended_status_enabled = TRUE; - break; - case 'l': - gagt_extended_status_enabled = FALSE; - break; - case 'c': - gagt_commands_enabled = FALSE; - break; - case 'D': - DEBUG_OUT = TRUE; - break; - case '#': - gagt_clean_exit_test = TRUE; - break; - default: - return FALSE; - } - break; - - case 'p': - debug_parse = TRUE; - break; - case 'a': - DEBUG_DISAMBIG = TRUE; - break; - case 'd': - DEBUG_AGT_CMD = TRUE; - break; - case 'x': - DEBUG_EXEC_VERB = TRUE; - break; - case 's': - DEBUG_SMSG = TRUE; - break; -#ifdef MEM_INFO - case 'M': - DEBUG_MEM = TRUE; - break; -#endif - case 'm': - descr_maxmem = 0; - break; - case 't': - BATCH_MODE = TRUE; - break; - case 'c': - make_test = TRUE; - break; - case '1': - irun_mode = TRUE; - break; -#ifdef OPEN_FILE_AS_TEXT - case 'b': - open_as_binary = TRUE; - break; -#endif - - case '?': - default: - return FALSE; - } - } - - return TRUE; -} - - -/* - * gagt_startup_code() - * gagt_main() - * - * Together, these functions take the place of the original AGiliTy main(). - * The first one is called from glkunix_startup_code(), to parse and - * generally handle options. The second is called from glk_main(), and - * does the real work of running the game. - */ -static int -gagt_startup_code (int argc, char *argv[]) -{ - int argv_index; - - /* - * Before doing anything else, stash argc and argv away for use by - * gagt_main() below. - */ - gagt_saved_argc = argc; - gagt_saved_argv = argv; - - /* Make the mandatory call for initialization. */ - set_default_options (); - - /* Handle command line arguments. */ - for (argv_index = 1; - argv_index < argc && argv[argv_index][0] == '-'; argv_index++) - { - /* - * Handle an option string coming after "-". If the options parse - * fails, return FALSE. - */ - if (!gagt_parse_option (argv[argv_index])) - return FALSE; - } - - /* - * Get the name of the game file. Since we need this in our call from - * glk_main, we need to keep it in a module static variable. If the game - * file name is omitted, then here we'll set the pointer to NULL, and - * complain about it later in main. Passing the message string around - * like this is a nuisance... - */ - if (argv_index == argc - 1) - { - gagt_gamefile = argv[argv_index]; - gagt_game_message = NULL; - } - else - { - gagt_gamefile = NULL; - if (argv_index < argc - 1) - gagt_game_message = "More than one game file was given" - " on the command line."; - else - gagt_game_message = "No game file was given on the command line."; - } - - /* All startup options were handled successfully. */ - return TRUE; -} - -static void -gagt_main (void) -{ - fc_type fc; - assert (gagt_saved_argc != 0 && gagt_saved_argv); - - /* Ensure AGiliTy internal types have the right sizes. */ - if (sizeof (integer) < 2 || sizeof (int32) < 4 || sizeof (uint32) < 4) - { - gagt_fatal ("GLK: Types sized incorrectly, recompilation is needed"); - gagt_exit (); - } - - /* - * Initialize the interface. As it happens, init_interface() is in our - * module here (above), and ignores argc and argv, but since the main() in - * AGiliTy passes them, we'll do so here, just in case we ever want to go - * back to using AGiliTy's main() function. - * - * init_interface() can fail if there is a problem creating the main - * window. As it doesn't return status, we have to detect this by checking - * that gagt_main_window is not NULL. - */ - init_interface (gagt_saved_argc, gagt_saved_argv); - if (!gagt_main_window) - { - gagt_fatal ("GLK: Can't open main window"); - gagt_exit (); - } - glk_window_clear (gagt_main_window); - glk_set_window (gagt_main_window); - glk_set_style (style_Normal); - - /* If there's a problem with the game file, complain now. */ - if (!gagt_gamefile) - { - assert (gagt_game_message); - if (gagt_status_window) - glk_window_close (gagt_status_window, NULL); - gagt_header_string ("Glk AGiliTy Error\n\n"); - gagt_normal_string (gagt_game_message); - gagt_normal_char ('\n'); - gagt_exit (); - } - - /* - * Create a game file context, and try to ensure it will open successfully - * in run_game(). - */ - fc = init_file_context (gagt_gamefile, fDA1); - errno = 0; - if (!(gagt_workround_fileexist (fc, fAGX) - || gagt_workround_fileexist (fc, fDA1))) - { - if (gagt_status_window) - glk_window_close (gagt_status_window, NULL); - gagt_header_string ("Glk AGiliTy Error\n\n"); - gagt_normal_string ("Can't find or open game '"); - gagt_normal_string (gagt_gamefile); - gagt_normal_char ('\''); - if (errno != 0) - { - gagt_normal_string (": "); - gagt_normal_string (strerror (errno)); - } - gagt_normal_char ('\n'); - gagt_exit (); - } - - /* - * Run the game interpreter in AGiliTy. run_game() releases the file - * context, so we don't have to, don't want to, and shouldn't. - */ - run_game (fc); - - /* - * Handle any updated status, and flush all remaining buffered output; - * this also frees all malloc'ed memory in the buffers. - */ - gagt_status_notify (); - gagt_output_flush (); - - /* - * Free any temporary memory that may have been used by status line - * functions. - */ - gagt_status_cleanup (); - - /* Close any open transcript, input log, and/or read log. */ - if (gagt_transcript_stream) - { - glk_stream_close (gagt_transcript_stream, NULL); - gagt_transcript_stream = NULL; - } - if (gagt_inputlog_stream) - { - glk_stream_close (gagt_inputlog_stream, NULL); - gagt_inputlog_stream = NULL; - } - if (gagt_readlog_stream) - { - glk_stream_close (gagt_readlog_stream, NULL); - gagt_readlog_stream = NULL; - } -} - - -/*---------------------------------------------------------------------*/ -/* Linkage between Glk entry/exit calls and the AGiliTy interpreter */ -/*---------------------------------------------------------------------*/ - -/* - * Safety flags, to ensure we always get startup before main, and that - * we only get a call to main once. - */ -static int gagt_startup_called = FALSE, - gagt_main_called = FALSE; - -/* - * We try to catch calls to exit() from the interpreter, and redirect them - * to glk_exit(). To help tell these calls from a call to exit() from - * glk_exit() itself, we need to monitor when interpreter code is running, - * and when not. - */ -static int gagt_agility_running = FALSE; - - -/* - * gagt_finalizer() - * - * ANSI atexit() handler. This is the first part of trying to catch and re- - * direct the calls the core AGiliTy interpreter makes to exit() -- we really - * want it to call glk_exit(), but it's hard to achieve. There are three - * basic approaches possible, and all have drawbacks: - * - * o #define exit to gagt_something, and provide the gagt_something() - * function. This type of macro definition is portable for the most - * part, but tramples the code badly, and messes up the build of the - * non-interpreter "support" binaries. - * o Use ld's --wrap to wrapper exit. This only works with Linux's linker - * and so isn't at all portable. - * o Register an exit handler with atexit(), and try to cope in it after - * exit() has been called. - * - * Here we try the last of these. The one sticky part of it is that in our - * exit handler we'll want to call glk_exit(), which will in all likelihood - * call exit(). And multiple calls to exit() from a program are "undefined". - * - * In practice, C runtimes tend to do one of three things: they treat the - * exit() call from the exit handler as if it was a return; they recurse - * indefinitely through the hander; or they do something ugly (abort, for - * example). The first of these is fine, ideal in fact, and seems to be the - * Linux and SVR4 behavior. The second we can avoid with a flag. The last - * is the problem case, seen only with SVR3 (and even then, it occurs only - * on program exit, after everything's cleaned up, and for that matter only - * on abnormal exit). - * - * Note that here we're not expecting to get a call to this routine, and if - * we do, and interpreter code is still running, it's a sign that we need - * to take actions we'd hoped not to have to take. - */ -static void -gagt_finalizer (void) -{ - /* - * If interpreter code is still active, and we're not in a glk_select(), - * the core interpreter code called exit(). Handle cleanup. - */ - if (gagt_agility_running && !gagt_event_in_glk_select ()) - { - event_t event; - - /* - * If we have a main window, try to update status (which may go to the - * status window, or to the main window) and flush any pending buffered - * output. - */ - if (gagt_main_window) - { - gagt_status_notify (); - gagt_output_flush (); - } - - /* - * Clear the flag to avoid recursion, and call glk_exit() to clean up - * Glk and terminate. This is the call that probably re-calls exit(), - * and thus prods "undefined" bits of the C runtime, so we'll make it - * configurable and overrideable for problem cases. - */ - gagt_agility_running = FALSE; -#ifndef GLK_CLEAN_EXIT - if (!getenv ("GLKAGIL_CLEAN_EXIT")) - { - glk_exit (); - return; - } -#endif - - /* - * We've decided not to take the dangerous route. - * - * In that case, providing we have a main window, fake a Glk-like-ish - * hit-any-key-and-wait message using a simple string in the main - * window. Not great, but usable where we're forced into bypassing - * glk_exit(). If we have no main window, there's no point in doing - * anything more. - */ - if (gagt_main_window) - { - glk_cancel_char_event (gagt_main_window); - glk_cancel_line_event (gagt_main_window, NULL); - - glk_set_style (style_Alert); - glk_put_string ("\n\nHit any key to exit.\n"); - glk_request_char_event (gagt_main_window); - gagt_event_wait (evtype_CharInput, &event); - } - } -} - - -/* - * gagt_exit() - * - * Glk_exit() local wrapper. This is the second part of trying to catch - * and redirect calls to exit(). Glk_finalizer() above needs to know that - * we called glk_exit() already from here, so it doesn't try to do it again. - */ -static void -gagt_exit (void) -{ - assert (gagt_agility_running); - - /* - * Clear the running flag to neutralize gagt_finalizer(), throw out any - * buffered output data, and then call the real glk_exit(). - */ - gagt_agility_running = FALSE; - gagt_output_delete (); - glk_exit (); -} - - -/* - * __wrap_exit() - * - * Exit() wrapper where a linker does --wrap. This is the third part of - * trying to catch and redirect calls to exit(). - * - * This function is for use only with IFP, and avoids a nasty attempt at - * reusing a longjmp buffer. IFP will redirect calls to exit() into - * glk_exit() as a matter of course. It also handles atexit(), and we've - * registered a function with atexit() that calls glk_exit(), and - * IFP redirects glk_exit() to be an effective return from glk_main(). At - * that point it calls finalizers. So without doing something special for - * IFP, we'll find ourselves calling glk_exit() twice -- once as the IFP - * redirected exit(), and once from our finalizer. Two returns from the - * function glk_main() is a recipe for unpleasantness. - * - * As IFP is Linux-only, at present, --wrap will always be available to IFP - * plugin builds. So here, we'll wrap exit() before IFP can get to it, and - * handle it safely. For non-IFP/non-wrap links, this is just an unused - * function definition, and can be safely ignored... - */ -void -__wrap_exit (int status) -{ - assert (gagt_agility_running); - - /* - * In an IFP plugin, only the core interpreter code could have called exit() - * here -- we don't, and IFP redirects glk_exit(), the only other potential - * caller of exit(). (It also redirects exit() if we don't get to it here - * first.) - * - * So, if we have a main window, flush it. This is the same cleanup as - * done by the finalizer. - */ - if (gagt_main_window) - { - gagt_status_notify (); - gagt_output_flush (); - } - - /* Clear the running flag, and transform exit() into a glk_exit(). */ - gagt_agility_running = FALSE; - glk_exit (); -} - - -/* - * glk_main() - * - * Main entry point for Glk. Here, all startup is done, and we call our - * function to run the game. - */ -void -glk_main (void) -{ - assert (gagt_startup_called && !gagt_main_called); - gagt_main_called = TRUE; - - /* - * Register gagt_finalizer() with atexit() to cleanup on exit. Note that - * this module doesn't expect the atexit() handler to be called on all - * forms of exit -- see comments in gagt_finalizer() for more. - */ - if (atexit (gagt_finalizer) != 0) - { - gagt_fatal ("GLK: Failed to register finalizer"); - gagt_exit (); - } - - /* - * If we're testing for a clean exit, deliberately call exit() to see what - * happens. We're hoping for a clean process termination, but our exit - * code explores "undefined" ANSI. If we get something ugly, like a core - * dump, we'll want to set GLK[AGIL]_CLEAN_EXIT. - */ - if (gagt_clean_exit_test) - { - gagt_agility_running = TRUE; - exit (0); - } - - /* - * The final part of trapping exit(). Set the running flag, and call the - * interpreter main function. Clear the flag when the main function returns. - */ - gagt_agility_running = TRUE; - gagt_main (); - gagt_agility_running = FALSE; -} - - -/*---------------------------------------------------------------------*/ -/* Glk linkage relevant only to the UNIX platform */ -/*---------------------------------------------------------------------*/ -#ifdef __unix - -#include "glkstart.h" - -/* - * Glk arguments for UNIX versions of the Glk interpreter. - */ -glkunix_argumentlist_t glkunix_arguments[] = { - {(char *) "-gf", glkunix_arg_NoValue, - (char *) "-gf Force Glk to use only a fixed width font"}, - {(char *) "-gp", glkunix_arg_NoValue, - (char *) "-gp Allow Glk to use only a proportional font"}, - {(char *) "-ga", glkunix_arg_NoValue, - (char *) "-ga Try to use a suitable Glk font automatically"}, - {(char *) "-gd", glkunix_arg_NoValue, - (char *) "-gd Delay for the full period in Glk"}, - {(char *) "-gh", glkunix_arg_NoValue, - (char *) "-gh Delay for approximately half the period in Glk"}, - {(char *) "-gn", glkunix_arg_NoValue, - (char *) "-gn Turn off all game delays in Glk"}, - {(char *) "-gr", glkunix_arg_NoValue, - (char *) "-gr Turn off Glk text replacement"}, - {(char *) "-gx", glkunix_arg_NoValue, - (char *) "-gx Turn off Glk abbreviation expansions"}, - {(char *) "-gs", glkunix_arg_NoValue, - (char *) "-gs Display a short status window in Glk"}, - {(char *) "-gl", glkunix_arg_NoValue, - (char *) "-gl Display an extended status window in Glk"}, - {(char *) "-gc", glkunix_arg_NoValue, - (char *) "-gc Turn off Glk command escapes in games"}, - {(char *) "-gD", glkunix_arg_NoValue, - (char *) "-gD Turn on Glk port module debug tracing"}, - {(char *) "-g#", glkunix_arg_NoValue, - (char *) "-g# Test for clean exit (Glk module debugging only)"}, - {(char *) "-1", glkunix_arg_NoValue, - (char *) "-1 IRUN Mode: Print messages in first person"}, - {(char *) "-d", glkunix_arg_NoValue, - (char *) "-d Debug metacommand execution"}, - {(char *) "-t", glkunix_arg_NoValue, - (char *) "-t Test mode"}, - {(char *) "-c", glkunix_arg_NoValue, - (char *) "-c Create test file"}, - {(char *) "-m", glkunix_arg_NoValue, - (char *) "-m Force descriptions to be loaded from disk"}, -#ifdef OPEN_AS_TEXT - {(char *) "-b", glkunix_arg_NoValue, - (char *) "-b Open data files as binary files"}, -#endif - {(char *) "-p", glkunix_arg_NoValue, - (char *) "-p Debug parser"}, - {(char *) "-x", glkunix_arg_NoValue, - (char *) "-x Debug verb execution loop"}, - {(char *) "-a", glkunix_arg_NoValue, - (char *) "-a Debug disambiguation system"}, - {(char *) "-s", glkunix_arg_NoValue, - (char *) "-s Debug STANDARD message handler"}, -#ifdef MEM_INFO - {(char *) "-M", glkunix_arg_NoValue, - (char *) "-M Debug memory allocation"}, -#endif - {(char *) "", glkunix_arg_ValueCanFollow, - (char *) "filename game to run"}, - {NULL, glkunix_arg_End, NULL} -}; - - -/* - * glkunix_startup_code() - * - * Startup entry point for UNIX versions of Glk AGiliTy. Glk will call - * glkunix_startup_code() to pass in arguments. On startup, we call our - * function to parse arguments and generally set stuff up. - */ -int -glkunix_startup_code (glkunix_startup_t * data) -{ - assert (!gagt_startup_called); - gagt_startup_called = TRUE; - - return gagt_startup_code (data->argc, data->argv); -} -#endif /* _unix */ - - -/*---------------------------------------------------------------------*/ -/* Glk linkage relevant only to the Mac platform */ -/*---------------------------------------------------------------------*/ -#if TARGET_OS_MAC - -#include "macglk_startup.h" - -static strid_t gagt_mac_gamefile = NULL; -static short gagt_savedVRefNum = 0; -static long gagt_savedDirID = 0; - - -/* - * gagt_mac_whenselected() - * gagt_mac_whenbuiltin() - * macglk_startup_code() - * - * Startup entry points for Mac versions of Glk AGiliTy. Glk will call - * macglk_startup_code() for details on what to do when the application is - * selected. On selection, an argv[] vector is built, and passed to the - * normal AGiliTy startup code, after which, Glk will call glk_main(). - */ -static Boolean -gagt_mac_whenselected (FSSpec * file, OSType filetype) -{ - static char *argv[2]; - assert (!gagt_startup_called); - gagt_startup_called = TRUE; - - /* Set the WD to where the file is, so later fopens work. */ - if (HGetVol (0, &gagt_savedVRefNum, &gagt_savedDirID) != 0) - { - gagt_fatal ("GLK: HGetVol failed"); - return FALSE; - } - if (HSetVol (0, file->vRefNum, file->parID) != 0) - { - gagt_fatal ("GLK: HSetVol failed"); - return FALSE; - } - - /* Put a CString version of the PString name into argv[1]. */ - argv[1] = gagt_malloc (file->name[0] + 1); - BlockMoveData (file->name + 1, argv[1], file->name[0]); - argv[1][file->name[0]] = '\0'; - argv[2] = NULL; - - return gagt_startup_code (2, argv); -} - -static Boolean -gagt_mac_whenbuiltin (void) -{ - /* Not implemented yet. */ - return TRUE; -} - -Boolean -macglk_startup_code (macglk_startup_t * data) -{ - static OSType gagt_mac_gamefile_types[] = { 'AGTS' }; - - data->startup_model = macglk_model_ChooseOrBuiltIn; - data->app_creator = 'cAGL'; - data->gamefile_types = gagt_mac_gamefile_types; - data->num_gamefile_types = sizeof (gagt_mac_gamefile_types) - / sizeof (*gagt_mac_gamefile_types); - data->savefile_type = 'BINA'; - data->datafile_type = 0x3f3f3f3f; - data->gamefile = &gagt_mac_gamefile; - data->when_selected = gagt_mac_whenselected; - data->when_builtin = gagt_mac_whenbuiltin; - /* macglk_setprefs(); */ - return TRUE; -} -#endif /* TARGET_OS_MAC */ diff --git a/app/src/main/jni/terps/agility/os_glk_MacResFile.hqx b/app/src/main/jni/terps/agility/os_glk_MacResFile.hqx deleted file mode 100644 index 6207d5d..0000000 --- a/app/src/main/jni/terps/agility/os_glk_MacResFile.hqx +++ /dev/null @@ -1,439 +0,0 @@ -(This file must be converted with BinHex 4.0) -:$deKBb"6Eh9bBf9c,R0TG!"6593e8dP8)3#3"&)Q!*!%f+*6G(9QCNPd)#KM+6% -j16FY-M!`-5""E'&NC'PZ)&0jFh4PEA-X)%PZBbiX)'KdG(!k,bphN!-ZB@aKC'4 -TER0jFbjMEfd[8h4eCQC*G#m0#KS!"4!!!&)Q!*!$FJ!"!*!$FYb*$D@P8Q9cCA* -fC@5PT3#PN!3"!!!l!%#iN!"*S,L3!%l`!*!0#d1A!*!$d3!#&9S!!&&9!!00B@- -J8fpeFQ0PF`!!B!J!N"L!!*!(TC!%!3!!33!!Z'EIJlL3!%lB!*!$FJ!!'@F!N!0 -b!"&&,J!"Fc`!!"Ir!*!%$`"0B@0"CfPXDA4j4faV,QeMF!!"9cC069"b3eG*43# -3%)!!N!N"(J#3!b3!N!32!%,"e3Ym)m5JR$9jdLT,ip6e1%CmUPb1Z(NC'QR%)4* -T0AP!!%,"e0#Y,jc),iJ'hb,QRRpAkH3,D(%+-@KBFeG4K3Cd4K0Bbr'HbI"NbfC -JcNih*3Kc$likRiK&*H"Efh4c6&%15!1H@81a"ErJIQ2MDJmQR+LijI!8S1m4QGd -MI,9l6aj1'8-ahDRr@rF0r2Qq8VV3G[j)51$q6Uqa6SZd6qJ1q-"NL@`RJ##cbEb -`mbYq"0*dLherbQJ*lLDZdr3[hQSjE*hT`(,i6QJFQF%FU+*0YHhQLGrY@,L3!-p -HM,E+&Ikr9m@Rqe3S-[I11031*m-K5BF8JbJAKI2aQYbBqG-V3SSD3pFZ+1IqeLS -[P%S+Zh)hN9Ur%kkj'YP$0eBhr6`2R1"rrrf1Q+Z!$l$GUe!3Q*PUqYPXTq(qh8H -41*6&TeZZilK!Cr&S%+)1[&TJD1Ye#-3YT&R@-N6(p2LCN[HKVk0TR'fj+Q)[KRK -'$LjkfY#YhXZ-L@U#10224i9NQGP[T+adE9843k-ScT!!Aa2+bj(-(%jB-Vlb*h+ -DSS3f*a4-`%%TUdqK&Dl&bPN+%3i`JQ$+U&[)!4iVk9P!U'G@ArMkE'(XJYhQ4ND -VeP$Qjd5(f2Vj&LVL`%E5(+i9@GaS3d-PDT8B8JKY,KA#EVF4'r)ePqUk(`EreB1 -2FM`9HSDdT(1-QNBQ%`JHMB3SA)LS6P!i8NXJ@a5SK'd!jJX5JUhmQ-Y6YrK`&+D -LLq&#"Nb(+kP`kc`hShF!SZ8IB@*HXKKr%%G'196-qM(I#l0`N[1KLFXUBNMA@UX -0@RLfBHdZ#E%i@kYal2k&p9AE44Z9YmU6Jd*ZTHU(jp`V$rKfK@$+iFhI@U(LMR% -%F$8bdH0Mr6[08'[X9,JQU5$3'jqMh#h!DK11I9KLYhT0lpf',V`V394a3V+YL3R -3,fYb@jDDbXGL9frmK1hQ4DKM!kiKf$l"5HapL2k)!D,q4f'k[LD#L3k(()SB[aK -UhF([E6BmHHX%MFH2rUT&+QPED$'4e!c*Ked`8fPm[qZ2l%$PUqdj$Lb1IEbDmS, -IX3`,QHXf2lSR@0EIiF0&p(kcicj+#Afp!p0I2i5,[1YL$,C[[XhcH!b@#4i'iNi -`Q$&16D4)BdFDKPURjH8005lJ!(A11hGFX9930TFZNheQYbrrl[pH3[Ta4"IBSaH -MY',p%"'V92@LN!#Ya$q!mr"-1Y+I8KM1-S@af%L8akAeMcqHl#'1&KlfbBQp0IP --!S*`rL5Rhb"#2-%UU0ZcG)qDcJD!RJ%R9apalh8qCGrdA9#K(!-!!!bJk%&[peN -@FGfG3ZM,pY`9TQ341MZJDJ285I3%4YFCKq''-h1AZ#6Y-D3i9aDX+C*pZ+pma0U -ih3P&B5JF$BBSMha0"#I+UH6"@0&c8Np4jC@(R)c'NB5N4cd5EALUHdc're!2#c6 -1a`dUS3VAFD6j0Yq3!2EX08+QX#""JLGGhqSZ`E["A-Tjlaa*pS"ZH&rLfE8cc*U -RY#`X-rpVp+qDLU3-CXB9@!i*-H!9*l8HT*a#"[hj2"Q4R[*$B02!5Jq1K@m6&04 -pQN'FfmThArReYb29e#Hkq&%@'[i2`IAhbML1q6)XH-J9BH45X"a"l[#-H%NdR*M -Z8MH%reL5'mrK%phNIA*HK85SSD-Db8#H0p`kmUf`6CPPiIZ92*dGGJ[XTpPm*Qb -15!Z6hh61E)U%9bQ2'jaBhAc-+D80-M`#@rqKLI%6aE3'3lTT#9dLMQE8qak4j&R -ib5r"VH)6V%Qj)hP5i`d@CfPYU`dB[2bm`FhMqLj-BL!-)9(R9F6Ye5eA4VcGVBK -Zm665$Cq,M63EEA)3FIDc*4[(N63VXk#,'K(,L!'8eM2fTYGa"4QE1Gp-a2jTJ(F -PTUUZX$2F6eX'546B6pKHKmP)h`A,%F%r(Xk`N[#eLK5H)8p4%%-2akLahb5pJ", -(6PY3*Y8*`lLjSH"$S4-M1("XJ2c@QMbR[Qr'%)6bM'kaZhR'V33j(%hka)Pk(i` -6KRM00kYG0fp`'PRCbKMcI)'09(2UJMhd5*hjS2c(MBq2j!SjZ'62kR0rJ+GqBm# -!Ih$9ZTLq@6qI3#,[)bZl3QN(mS*TVh"@$E5f@JNBRG)V4fr5F1MLINbBpBjQP5[ -"#CET-fB%p,Fq(6N)UhD59Nj8hKiYc&V(XmZ4#!31dTrGaCjG,4D&b#PB-i'44EC -5e(rBZ0&(&L(Z26EUca%rTa-PG*IR@l%j&-[F"lf)4UQM!*di*!,KAJ0f"`"3C@3 -TK$pm[dTe$M@DY#LM&NdK!)%q[#E10$PQja&mar)9jp@CR,Q!'R`6DJTpDC+8jLb -U8RKY(8)UJA,I96NY#c,qVNH'$'U3!$Bk%PmGc-d0XHR5BMe*rYBT5r,1G50V3&V -(fC(!jm#UR*dHq8q1fS$N6CraH$HU)dk%aRSL9GP$i*rpbPJISL38XlIbV*K!5I@ -Xm6`l!CFl'2[&Im+Ti`jF)0Lkq'dSJN0M2$KKSCEFP8E2,X8!bSXARDVLfLFIAPa -23IK$E&(`MrE+TYa38@CB(kh`EQG&`%c'9)&60+aX2ESD8L&6SBr((&Ac6#c'1,5 -B(J[L,m*`&L28-IR4)2j!hl$6je3Ti(%`@$[6-GCr$I&UFpiTY9qr2q-m0jV"8P2 -2TRBqrdYl)'SRIHdHT3Y(eAGKeUY3Q3$N0CFj,UUXU$GH569f"A%[fi"&*GQqV`U -`ICU*(E5S36apT*9BAKFC*pX-M8-FU*3iJU-0f4(fh%R@bBI9j55[-Cp*k+@PdR@ -)r8rB!p#-1C4!4GHS(*!!BZ@A@QK0h&SSdf$5NTblZH&X@F1c`PV&4Ael2f9L(bB -3mpTRY5Z&!9Ad$d'%m!AGFZSQ4kGX*Z8416%b1LDUm!K6G)AJ8mcrJZbDcci*SVG -(N4-h8kPXKmpXUkbU+eH%HVEAJB)aYA46a2+M@#JBX*`D8kQbe)hm8))&3lmHP,k -DFd0EI#rBZB8`J42(3qah@eRBe0riNZV0qAY[m+3Lm0"i23ZGk2dQdca8Nb4Q)ii -PVAQqSdGc[NU'+BI5!K@#0jHC0Yl8@!@VNlj*MG5A"S#"YRdYHeccjil0@ll%!ka -K8kdlmj,bJVDcPYQLp`r*2X*6ThLh3HhMJ$JpJH'FKcT!GlGj-ZJR$D%82l'8&M2 -Ai84&qeHZ"mb5ZU8F-+J-"Vl*5C2RP*!!-+$dQf9T[9PQV6"lZNRkUB)b,3IKj2e -jLU4a`IbkbbC+06(dK-B$`rl6Dmd@)9RdpADTR%MYU0S2bRaj"QdRHRF#5%LRT@% -)pMiD1q)ARKJ9@q6J'QacaaGi8aV!+#Cd)LH4TAe9a6HGEma*A)#Z925)6+mD&Mm -A0hYS%+H%)f4Ci5&GcEq4GdA#[-8@,rXb$BSr,p@UHr$*S1Y@R1B3Pm3`l3i#+C6 -#d9RAS*e-IM2RCPcB['0p'HXX#8'42E"lS$K+f5pTLR84X309((0c0KeHe+FXT3! -PCQGPQ%Ic%qFPZ28&$1E-(U5lJ,PJpd3d@2A)MT'-[ZrTP)"f,$%eJb3`BKcHrXI -U"jPmrC-$"-affj9("QL&+(BjF@9%5H*U8$bMX4G!jS[bEAFbIYC2lE&b8VKJG2h -(dVU*0V#IV%lErYX[KZ)*d*Bp5EdM`k4r+GDf0X`FejjI[fVBmXdJ%0AIfhBDhE) -SSZ'PKFF-lhEaA9MLk5%m2"IqrHCh`dDIp,eQPkS[,95J$#SX)XMV"[BhVpUS0#% -GG&Rf3(pX8kh+PDh(C&%`MkG`CC8aa9X*%3-fG5,053KPH(4L[e[X9$c90YYDj2) -p2f088[-ZT`,V-pH0B1ZX(f+9fGedd)'Q3QBF4)3'!TpSi1DVc"#&Xmc'aM!YcSq -!1cAqSj@N%*fJHdVS@JlT1p6jdlZ0j4SCc'hXF(l*[S`dKT2`C)-5c#Q10r,*El@ -4pBrT`lp6MJbM1I(k0aS(6Xch$c-Z4K%2Tf`KJ3*c$ZfM[khZGJq"Ij1EUcX1Xa+ -l4'U@D1TU04q$kI9*8e4i6CdT`TM4SbBq-h`N5PJdQX#$440SP@84aY@SF1Nk'XA -c!Ka-D"MEE9`K&EGXrH+dJr0rbS&K2Xaj)b86XRf3!($d!VMb0CNCQ9'$2R'T,Gf -@TekSm-d"I'Y@DmLD@$CkrKhfdjfr$2J3ZcQ!E&f+3%N'h&12jJl0bQ+@)9Vh9$4 -rBeRP-P(p`Y!X)e8PY4ak`856Z'JCa%BVYCXZ1RE60l@T#&jpDAPAfHY!Q#iYB"( -m,r'j'NL@Eh'`f,Q6(r,r`1h9I'%YTTEPB4bEMTi*e-bITEj(DT+"qG$U(Cp&j5a -f#-(lS`&@hX2qSGNZl%e(j$KiJXURI14$)C&KcCZ@(hZJc8cE,GNaNN#`[GD#MGr -jf@b9a1%h-TjD4X'T5,T"YV%[Y"S$C,PiaCSai2`-eb1+b8dqR,99$rUeUp,p6%h -kLS,4M3Cf#H+%%YP*f&4A'fPNk66rVX6T'K,TJT&jDX"emSDpF%CX$DpBQNCZYi! -@AefmeGZ%QK"jf+S4'9iYbE!SM[Z2Z$DbN!"9kX([J[G#qflpR0pQ%8RkDih'6*K -M&LDD#'Vk'VC4a'5K0XEi@2$JYhrI$'hl1+PL8De6A"3RQIr@+CDc#,Lep5iN`(0 -T(N[1U*b5,,D6c4H'V!2c#`9T)(#hZp3mrR@BihS*KrVji2YNKe'6(`@jr8XqSY) -j,jP[1Gc4r5)GXjj-k&Z6@Ipq%#P2b'Tjh5#TQYNA*XJS$,IFqp!c[kS6ci02@FB -brKDiEm&q3cV[JBL'Hffi"4mVLj&"KKTArrq#H`-Tf4p[d+*r2CXPN4QJ#`p%`Zc -+#Qb`b@rkiQrS-jp%C0Rp%3!%kdq6'+YI+EU"3RKcV!8Umq93$56Ak0,mPaLqIie -kRS#2daL$%`*r1l,`3ed3%rIQlmF1V!8!XajFBqmXAh+cAj5`pN5)YD(#*"dYY)$ -X-HdRF-HlK[#c)#$U*dFX,%KL#3(0#ZALA96NZ&34cQ*$Z34XKi`SSfj"%A1,G)b -[AKa4%#)0H$[2Kbc$8[c-V'jRZ+RkaDc46$GTh2HK$IrlQDXmH5R+bXPm)cMAJ8J -*VU@%VeC(p)fKN!$+B6@(44aF`icGrIQFq3)ZLN8CRAQ$mj8&S*XeFKbj!3A5Y[Z -*+0kH1mNHp[*B4)XRZRQ5PQeSG05C@VGeX[hap@G@$M6q-Be2b*CCr28bGkMIB@Q -k0rZAY#bMkma(a`He$Hf6k#QKK'Vq["jMYT3AQrPN-lm5Sr$0[G-4A9A0YaaCPBQ -#8SD6HUGG&(KZbil&S08*-a(KZXZ,6,q%X0$,EqHm64@49D`HifHBDpc!Z+L3!%K -LUIBa!JpSVME%!LL453lrX!HbX*Ga+crl14"'f`qe1IH(Tk3*#RIFG6,V4SP08VR -8aU&$%h(8QY0hH*M*fAJKM(VM'48#e8LF#q9YXim3C&a*r2BX'3+QG&p,BRIK&AD -@#2(b%e"U39Echh1Nb5p&BQeZ(U`1l1M0,b5@Z'FNR81F[iA*X91RrdS#I[*XQX, -5pZX3ZU9!KkL3!)IV#X3[`db[pjH9B,3"!P'1kd`8amAZrhY%[H1aaDkD,`el&Mc -PP(q0m`0Ma4*8)ZH@,NLrbaLMaIlP,hSe(R((*i+rLUS@D[pF&G8VdGb%3*03UM1 -lrqT95)[@ic1hH&Xl8dfT*%6e2F#AHI5@dVp%I5B)hB)kcaX%6DZcL&$#db+NpM2 -dH02)$C!!JE8pH3Ak"9rFZl"$P%Bj$V[jXRm9%Gai,+p&5QGqH3Ze$rB&HBU8,KM -R)@BIRZ`XK(CkVR41$RE@'FG,*1i0Pb,$bAFQGEH1h11K4IR'-kLK6makjId4pjf -QmKL!jM"SYYPi"e#NhQN,6V#9farPFZmZjk2I#V+5PffJfRZ06TXerpp&KV@`0'E -$*RKpIi$5@,R'FHX3*ZFY(5*F"FF5+XZe1CScULRAUZC%8@E-2)Mm5iI+04FAQP% -aJ[*[[GB($rR1[iE2"lBPe2[(VJL3!2M$YeiY%YPEP9i1E@+Z)rLaVEF&(dZTm#1 -eD`L3!&8HC"a[8mU0TY+N,233Gq[%5-#"-J)FQY+9[9dD95GR33&C6HM"Mf84LjU -#iD-Rj5)A%&6'6$kRIb$Z)@f`a&IVDHBSr%(*M'$H4aem9jKX)GJjFSK6af)IU6L -#fN1kr2Ujkh324U%K%GYlKaUPl[mVZJQ2X(&H8CT*(-jR&@RF2**B*eI',e%P(bm -[9SfHHJf)b'-AU3rQRe&KGhjM'IK!-GL6k,p4j3`6eqLB)d)FIT!!X@$F)*TT'#j -)4p'k'P9HEhrBR0Y4-[YH6K#S26AmZY)BGHS$5eXhTZmDM5&2!6dbD8pAIZlMQ2Q -D`#&U31keVIk$05Udp5Db9"fR(8Rf2GP5bcDRX!XDrANpJ&Tjip`LFIaR)%(eML` -G(Y6TYMNA[cVl13-d$l1j2#k,Kk2GB'"4AURA44&@,X6md%hDF&'UHrB5MZDV6!L -TlNM*1[aIp8hI`iIUd()1l)j4DU*9IRlbe`,&ml,pA[cRckf'`NA9f5S$GdbIV"d -l&Vk(8)#"qI!j(Tce(pb%T[X9Ur`Hi@[q3*eic#kphqSRS85m)EIT1&M0@$+%,Pb -@p)J%5Aj#Yc*UXMD[Li'lk5dFi83*19P9f$#e`5Y84cdU1"IJfqqiXJDPe4X6fcB -j`!9eFA4,'FX-Ij44hfd*P,Pm`XcG3q*PKmJYFN0MdQ,5,Bp2*DS1S-Ulk,SQ$e5 -aZcB0f'+`DFaeL$B1Lf,Qf`3$9J54&5QV,&88f#XA25#dYr(4aAB(f&kE#1AIp5m -P85rBP9!ipS`NpXS%h6[S,e%F88@)bU#EP)*$MZNYl-*'SDkZKQ6,"PA8rLcETcY -YNGm#4XMR54ak(9Z(3IXBFe`Jj1mBAH35XaEZapchIqC$"S`Kkq,6(Y(e-mKF`TN -Pd[&#BhQJeN*KLjrZA2@VXDe9BH5mQjLq9KpiKqHZZTHj+EjP51#[qAHl,kp+"C% -5kZUB$GVX'-B-!3bI"41Yip,H(Q,&qR0mE!T*V)Tm+6`'1RIBXcMf(&q0@4a*El$ -h`GV[E"jIXXG$aBT$LiPm6PMj9$5%XlSR-G60hY08q5k8J'SP`"[&dLRi5QBa'YU -Gj'@CGV&aCac@Ha,Ha9NRCSZEpm'1"MiYEU0VGqRJR63l8G83)eS18aQ,2TCfIRN -Fdm+CpPLDm$l'10*@#kccUrG3mra(1BJPlb%1D"+KqRAbh*bZ&51Tk'B$516GLf0 -9"H9m(!Q,9brc,Qj&AeB@2(@Jf!V4$Ld5'F48,3h@dUKEa89E-TSBCG[I)3!0kCj -8K&C,Y%k,p#R'3HN@IJ#0[q-BQlE-6VY5,![`""+,I`mrNH#eHLEY*Rrl@2Y2,!E -q(R`JMJ5KKYX+*&+fCUlc@@fVPC,S03)bDEK6[F@j(BC!VQH#l1AmpZT,$RTbqd, -0+dYrA98GCTT6j0fpj6aD'J9[PiREKQmh8DEX'5CHHjVJG%fajV*Mb(RiRAIG#5S -$-AFl$J+kqU0mSeh"UX&#NUbZaEIdRTL+)e$J$KQm4c4m[eL%9Xr!9JT"U`i!'k9 -0'&)fp`#Z84pr9LfI(dV*&h(*lC4hJ[qQ'&*9(Rc#4XIDqM#p98rPDRV#0%N(Z@5 -ai`5((T-fIKhLT5c+r(,af)[acBVeQBJ!AEhE2V!0YA1'(l&8pBG$-c#ik5KVL6` -U"b81*4GL$CjhdjShA2l0jjc))N%"hKFF-rDKV@[@p,,C-%S)%+h3&bI(PrEbVMA -'YHF`bkIDX2EC8)(Z1'4!Qe!ZD-AD(U"CpJ2K14Yfp+qlYT0NXIbDXc-B5)mm+'S -P6q2CmZQp-8CJX@VBSVmHh-&J"5%0Dbbjhirf16J#D9hZ'VKYJ#eM'$d&(8Lb!`c -q3V6(jY6Ga*EmkbdYHmH9(KLRk3!(bB4i"Q6Q@,`%'GRiQV$+iamj!lT3cNQYpNH -Z3!53!-B-6(fm&lRPI(FPpNXYDQ!5"JXX53MXEj89,,G1!*M"QYiDkdh!)'1m4CP -M2R'GP$+$e%@N!IA*'&#"CJGMSe)jMrf0R"qPR0p4%cLD6+@NUrQM*L-dBR6LQ3I -'820Y6pF-8MI'c6)9GN`X1-[H)#SL08M"CqR,[c1b`@Cj*NX`fNp-Ha"(RX4D)lL -m@"D14Pi+'`b5Hkj``(kK(L+&*$Jd$fEc66HI3-qJCY'"63'S@e+F%2BCN!!$LE' -*YYUEpZN)i)$,J[2H'i5'5R5rUK$!TC!%!3!!3J!!XL-IIlKR`KN!N!24!!"3b!# -3!h)!%SH*!*!16@&M3@GTE'PdH8GXDbjbFh*M!!'QcR*cFQ058d9%!*!%!3%!N!U -!!*!*R`B!!$EY!*!%$`"#`G84"bAK`haqBSCdMe1H*(JHMr,GDXHR1SQP)4KjYjH -NAYjD)+Y8SDa1HFmpG)4Rf5*deVZ!9k3BD%!Vre"'bUG!fX&8$rZ5RCQlScdfiN& -64Y"Uk$VhL'U2%V31Yd-L,Z)&Za,b-cHc`p0ES4!X!1)$&Ep#l0pE(%(-fjI3Zh, -jH,IT4hZ`)UNNK$)RA&b"lQ+(#p4R1kVJB%QA5J1dmLBU-edJTh!1@)QQJ-4a3RX -jE&R2%Z+aZQ-5HHG[Gj2UhE4h')&'P#Y6ZJ)0qC+993kJpd+IAUEFPZ"hc[pZZ&I -*U'ZJHD"pX"D+bURrfc0L8XjkF5ULLB-HREa1h"PYY6p0)P((afU[c@%j#j!!5Vc -M1"[ZZ3SVR!&2kNY&$L*b6+-&-#RKAZc4&bPZJS#8AJ&jJjq(e(`HGbik(e8RDQ+ -QY$r#m%9Q!Dk86RlF0&+9cZA4FZGh&aSiNL5[1&mTeUa2@#clqfe1#GE1Rk9-aQ% -l5NG9X),h!AY4&HplB'b4IcXD#Q,r95jf5(K(d+Yh*+ZiEl!cPe6"+Ir+mQcL9&5 -I3h4VHVN[ViM!"VBmd`RB1'4d"iG3Qqh(LeHrQQQk-fdQL4S`6YHaRX2+b"@FZ1$ -#[Y(11Jf9HM@8m"d'`cDQQjrUm"D()bH2I@H`YH[2b681j(C-U$&$JJ['Z,H2q1P -BHc6(QrD#a2)i1U6SjaHjkLQYl(M4I!VVJqY3G,JBXYD8-!a)jUeXcpkI)ad&MQX -aBih`Q2dU'bQkFJRK)P@lYYhhbL-I[h(#QQG44*c23"&ChHR8`Qrem,XIL'EH(b* -pSXaX,bAV5hi8c(16SG$[%kab#3#p$!TAiAc+6leqcjr1L8[FfF6GmK+ZqrPZl+j -+,i+kH6,m'LXlGf9VdNf`M8R9b1[qC2Dq4fHmfqL52AIpQ$I%GmP21Sp4QS'l5F+ --LalGUHHF@Y3V"KNc&2iCSQZ`Z'5"2Gjl$&PZ2&+)cd(rV$llLQJAl%c$1dXql(" -2bE!a"X+0*(%UKJA-Acm*Q@VJ!M#YIXBdU6HFK+e`RAHUBUl+Z"Q"i48Q2D#`jpY -*)!M&QhB4mSDM@B*l!+aBfBkD[UpQBXU*qIhIcEC0&5JKYSe*H5VFT4Pr(XGrA%D -iP926QU2!`L6PK*bjqRr3,TL6N!"NZBj*#D(Umj!!q%1F%1b80GZRL#P[L8afC3M -MeL#B9pc8bhi1h9aB0M(kRTPZq(NqLp!5"Md8FkI0XhllZ3QBR@habY*M6mKBP`J -E*"!RHI%3EKQl%93BC@IZ)$Ucf"Jp4V53!1HY(`3NmTGC(V*`MRqm0LPd9Vp45`" -"N!$8Xj8jCBK"3pP+JDDPAB,Um*mdp3@0FJ!RqIc5keK'f5(d2e9V1ANH#![h1(X -*&I*#c8rHUH5T',ibj%c1JD#%H4)'SmP@)&22*Z4e(lIpcKlbBCk5P8"L$PIaDEc -hYbra-4S&4kIb+#SESEG%#+[&CB!-%jV"hYBm6a*NjpK$["YDSZ"N8llRDAKLMJK -28fZ%e8S[GYY5hKH*C*lS%MqB@&AVQJ+Mq-k)%cB@264dP"E4Z[3ldeSa&HHKM62 -0`HBSY2Z-p*D(B%FejY)EFF3,H28U9Q@VI4h&kjSU4j'+VT!!Pq@eE%[NMZjD[!$ -(UT09&HfhE+MI%cF(66AA4JNdK-+QFV2*ClNH6b!%PYqc3bkm1r$S`JckEi0[[hQ -QXe[FG5HHe+#@M62,JMf[-HiX9PmYQ8S%3aiB2kV#UF3L39@h#U[GrHFqlPm-(8Y -P@12J)hJiNZmNN9&qHc5YcYi'e2G'I1mG3CI!i-kpqTcLlV@d[iHBSThD6%M56Z" -k,PYJ!39*+i#0-XUXbU(B'3jEFeM9VMdNG,`X@C3NTe5QRr9-NKq)KPA)rK'@$@E -qC1Nq3*UArYp#aQbNjB6R&!3JF-jHjCbAfFm[V#P@S--RUrhmA0f[0&*V&DGL6#d -HQ&AZES'rUY23f)[9BJMUFBi0aq3C@e'Mc8L5EkMM*iYfH$!9iLQdimYZRYL6&+4 -3DM5$m%mXL$N**ifRe&6A8YMd*1jp'V!pFJ3#b,X8-(eU)Qr&KjF`(H9ADL@SAGU -ajP8*lBLp4M1@9'X0f@bMQX&"pZTHTXhA`Zblq,%HZic2"R3drR3miB(@&AQqcrm -)6pkpC*hr#(TG2E&kZIbf2cGMKf"H3lZ[)'4-L+BdAbfPaAGfik`VG%R2YA4KNJ4 -b'r+M8dqXFT1-IQq#qqQX3I4V!Mh-`iJ*iL'3!&MNmTQ,5b3LHA%0m`1)ZMec6jq --L`)13FH-CpUbdf42m5S+)&q!Gha1HYd'RX#4Q8ZDQEmNqPS%fZZe3m98Il81B4Q -4VAer0jBa$5&D%[VrfX""HEc!U)'%r)NK))JmQ#m`Ar1AlmAqP*'Q&"SfQQ*Z@b% -fVcikklZ`"FjpdTX3R-I,bUa!TYji@[MEAQc&eHQ0Nk"k5X3@)Y!FchYEeqZ-d[T -8$3d[`p!ZR)R(P&VfMjd'kh'+"k-'QQCJpF+0e@m4R2RSC3%B+!c6dIca5b8HLdQ -d,EXm*QhN[HiilrE*S!cL)VR2K-Zd+rCVDAlj0SfJN9"',!`0YTHYKNTH,BJJSk# -3!*PX&1E'IRfSUBD6kd8CcMT`j3""PXNV[G&"50@UVr$D3`LLkd&+X,Zah2df#!J -F*D#YJ*!!Jdp#NTS9Vc9[qH(qj(5K!h,"Nf*#0@!8(jJjJ-h$dbD4GhJHAelrG'& -jJ(Qji+,GaPSY$&VHd(TIQV*E0C0(#2HA8F+a$(Y4'j6FMR#IZ+fR`cjDb'Nj+a9 -m5SiRl3+(k!%!Yi4$CNV'aFaNmAih0*mF4CY(V(#%q)eKf9'G2R'5Pq08(NKfcEa -4EFCYPmKVhUR53I5Y4Pc1Fi4JpmI9qJlf,Mq`VLmf6CcdY1djJmk)AEVJ)[fKSKP -U3Fj`!(@$jm0%bEDSHC&rYlBYDTBYT45bX(Z#bdLH&6SK0fk!%jd#'alr95AMjmp -e8hIb8Vj6U[lN*APcmIHpM!!@4#rD$MA9mSB1"mY3b$ei2Qe'mLGF,62*+RFVJT& -#3p5)2)j@UQIc%"Fe%)qMNm5H84[k"q)%XH-G894PdC8K8+&qH5fpl'kHB,c1%Z! -TNNM@QXDfkJ6rRbF-43h[E&!rT88@pmf9KV&LC$'Dq3[m0AbkU*MFf%ZR!M[3kiX -T*YDe0pq,p21+$l)UFU*Ac)d23cj'Af,$p3e@N!$FBi,UP49A(*-NB@$*('3IU(- -haSM1d'9Sep2`DTMrJ-@Y%her#'-cXfL$rNB%qk-@5r+$LDiqb3Y"q0Vq6m6#U+K -MSQ"[l[#Rl(8T%DL+I1L'Lc*9(UKNqS#bbR#VAK2Rqdl5V`[m+*DM&SC&rN'L$TU -YfQ56dp4VS`i,M9X"8e56qC*b34q"#mpB+FjV@)R1im&*G$HTaBVG&c584[8b2GC -cXF$rP2+'AL"i0#RBL3JYR%8pEN6@'jq(U#FM96*,0l5i,L*8PD4MqdRPqEUFJ(E -5QHlZk2X9VQIElNIJ'A1B-RM[99`bDj*45jjGK8`8f*aQfUAX*FIJ$3mH'!CbXKT -%E(ZMU+BQh5Gq+'%,U)hm6cLII`m6Zb-qk8*!m5'A"3*l(Y*5QT[4P$rX@@bGX0T -86)eCVSmN4lfB,[am*+bc$UhLHLMMGHC&F[8DF)T[B,9-e8fPhc#VM!)!eSj*2i- -A(9C*aR$b[QRHEK'L&d90rVDYL**lZQe2k'3PH&McCDdc!+CGEUFl"`PZ4GkU*4X -JUI%3QEamcaR[,Jkr(q2k"&&45)TUVQMG@baGr(&Y)XFT4erMqELICTf+"*qBAp` -)D@$@+S'S*pBNpj4QHZ2,h0lBc33p%qBQT`@JA8+A'83pN!$a1rXB3-lpCX2C-Rf -M&ecV!MHcP#PN8RZId!lA@KI*U5H6k1mFPUQEC'mp-&Y9f!e"VED5kRG5!h,I)dD -r)E2TGTm%$,i6eh@GVbQ`Zr8BPme'PK'#3f-`BD"EFSVcC(hJ5@f+lVJ1'(jE!Cj -P0CE1SRZ'Ih8FBjjMLHDX!*chXa`hTFJa$V*Ip2P+aI543dr$eqh*)4USP3'0H*A -3(EM,YFA2[8FrY'mdU3[f#kb8Ke&+**a6DmrN(',%frm`94jRKE[q%4Jd6MXHfk4 -a@A9akb9KRT-5jrZ[Zd8SJHc(CSCK"Eb`KmMV&P3IBkVD&C-Hqe@i5c&$ZdlX6pR -G!M,[)MbPBD&MA'@r%d'h6hdfU4)PLmYJL&,9RS@C+RAC%FL*Z[i1PlX(j$!I6#0 -#CJar3[N66YXhq26%N!!H9T2lce4a)9'SFbrdrJqm"Pd@hbG)@hf6#Nc%"qe&*J( -VrSXN2-,[MKV(+(lRCe&NdGDV4IkU$J#i&aN*jB,d()!(Lkj`XrBIbL1QqYBJ'#6 -P9djU0(+VE!P[Slp(mE)H9pq8DB'j+XHLEPP+3RPb+Kf#H-`E,kKeZ*qV)8,)!i@ -@6q2*BL)'0KH%098G8&pQb58F`BaM(FVf2C3*I68`+hZ0%qP0&fYfCUmQb5CEX!S -C`E9H2r1Cb'X8Y!4C9q*5+q%D#I!!6S2S(`Be*`GXdI4)+XXeH)`%*c&l+dlI48T -%8he!)kb1-Ii"cY'()FKk4(i8TDdq3(K(rL62mfD)'8`YP%@@2))P4PDA$9*U&(E -F($mI,1l6&5eq4,-jhc)&iL"p4N-ea2c$T5[UC9$GIGPeLGc4l4M!,Xj(C,2b3#) -ZYFmNm'k6D895PHS!hCA,KZ@Cqee6LYINIG#Eb$fH8l5(fq`)+NBG&(*'3Xf"VJG -bN!!HC&(!2cE1Z`(3'l-1dR2,Y`H1VcfeEEP2K#+[0LKShE1HR)Uk!S5r33L'hqr -dbfL($46eGrk#K#-M)Zd9@!NAdLFQ`iF("#bJE&lp2`J!$3hm-eM)-lA$b%ZQfXa -GR$BR$V*DqeLDN@(1[G$cVT8QZk#-KFD8ATA1i`&[rjUi9b'C0)R&0MphGc1U`r& -4$2LEB,l"X`FEpIK6lU!!P@a&&0DkUIFLZDkVSC*6+rrm[NR0$RacbiH$NPYc3M1 -(Nc"CJCeCf&q5FpLJc59p)[Q$H2khU36*Na[56@1UBU49)%f3!11`S5&4*VA%jmP --b*XlU1+4R2Hh-V0$kk(M+HU(-&iHfh&80AN5X-pim-*KPU8MF1PNX`"Ge"T(-6C -4Q&EmD`UQZB#DcCRT)X6*c3TB3$Ap4b53!,6DEPPR!-q!ihS(&#-31,$BX@5G4)a -PiElqe,SVl['hcABihiVX%AC"rIF)Vd,L"PSjH)j)*AmD2VCA8[&KQi*BZm&XV,a -j@J4H&&@26T&ZTAr8fi'GH28G1r(H[c)R[$l2$NE65IJK#`,PPPaDcba[IRUQTer -JU`VZjD9S%Z`E5RHBh8(j45f&A3X2[PcTd'M)G4c0`0qhGA+0hNj*5'UmPJUhb@N -HQCpC4`@,J)'iD-N-4p8Ui[%18eV#&M[jfSE8a'Z!06X6IpCKBL,$emEe[#rPq5[ -H"%*94!Ak+8RL04Y,[)f##0LZ-eDJBPYrm-2ha9L!&DAaER+6r0R0A!ZFRbPfrdi -A5$HYZdHkJ*Qlai'Q-I5`9C8*`ThMSAB@pI0kj0KdUMHi6PiZiQUq4(H2DE2MMSA -)kEeN)T!!MG*-%h!BH!Id-a%&Z6N)Fe"dmJcUMm#T@c+r4@K8URdi&cd(D2B&B'f -P"JPh!jlMQqScJ$dRTjb%'4RY*"DH`fR2a1&AcqKkhA$CIC`PIJ5CZa45VEE1mCj -M4df'`G*V6!NM6Mfp#DRH!J!M5MZ4FJPHf"qN!kX"Ud`f-@#9+#Qe'mabL5+AU6Q -m1dmEY-rT4af0dNb8i4TRXa2$YT4))6p[dDhlc8+T!5G8*mPk9m&rU)1ir1Er#8A -fY#R"UKN"Y8eN`XfJ@5H@QLZlN!#5iKjj#RLH#XXl*`*qU&Z2L(Sibe2L!-CrJBN -'k'C!+!8X*qVpI`3AEJ0NFIL25T4END[KBH*XX[K1diX5I+T#lIj#JYJYEG2B$ZK -djbH%-3Va0PNkAF(qT-C9,`%DK$@qB(f)1CfR11-P%6-YR9T'"hi$bfV2$,39cd) -j&fF)Q-Y("qpBXVH2UVIB&eH8bNd&Xq(Z`RhiA6PabaaD%(M#YB&$b0l0Bd,T%*` -&&0Qe)K)4MU$,N!$TFAE%dU8-cYhGaC`2-bDT*(C9&6m2ZlER)PVG"K[-)B4HHV# -!*BlBIIPIMc"VHr*-%5er,iXEGISl`VF#rii+Yqljk&9S*&Q@Vl4P-PMXA613!&S -C4cGJDYImS8L$20D*#E$Glm40S4e,JZQ2LqGf"*K!l(e@$%i6V!""9)"FrQTNC38 -0k`E%D&F#8-YhpVmTXm(I%@Yf#pbYi5GSf!ATBlKHp$`6aq6%(c*YCpUZ1&!5dPR -"TZ0XQdE0j%)*Qc$-K9@)UpH"Y(2PpRa-VIi'V6AQ%QNiRPR5(h$'kE,i%P(lbER -aGQ1kSkRaP'2GZIXjC5((l$LT"!h4BqKNGZI&6D(Sa,%pHq4*"54NB0XM#`JcQ'd -fS!Pj)Vf0#UHl-Na1"58dl*Fhp$DQ8Hj,S#)+8@d"LEJ,mZF`3hiM22KalQT'UNh -Zq[F[H2B@6jJY+Gq5aHKp`fR[!D*[`AFZIce"#F[[1X&0A,A52N5Cfh)!#RCHVpm -Qjr*)+8!8fZUSY[%*hS-+e#T%8rX,4,"PAk!5ah6`3CleGmE`iPZMHV0aa5Vl9iC -(IRpElD34,#624DcJim&f(#feqfDr$,+Y56SPk8p+QZLbcm8k(XH6&XZEc(4JX6b -9@'I(el!HY80aCi6Mr#(DH&)jr$8+"q)-U[XbdA9[b)e@B09&1Y4rNCC&q`3NUBP -5#"I6kN0['hGY+TUb(VK$K+@6"dSL4!-m1@N8p%[NJ&XQ%p53!2i"Depch'lN3*l -pXMUIIZJUpQiNfRT53JH--RfVI)R[pZUZ9NUNd5l1j[,hM6Re8@Gm@8d-DA#5"M5 -(R5ZmMSafb0K9j1EaB0"bTA3R@BS(AlkqSRjl(Z#kpZI4F9ek!j4PdVT*Q4"QQ1Z -4B,hE#iiI5K,m#GdfCF$j*hiD1cf$F4rhL(dd2ZMmL@6,!JLJcJ4$XSB%'DlFXBB -#5Fd@K@C6Cf6P5CX%4K3VLP@%Qck2C(FhJc[4VjD[2-G[Mh$m5)mHe3lIRV`H!'S -cRrf)4#2QbSJSIaKrJ@JAfQK"PcU1*eeQ&jdVUDiqYA)V8Kj*CmdXKER@Z4jEeGc -[Qa4K#Q@d5VRqZ(qR0FG0%TVH8S`p+[m$"5MkT["@jYRf4HTHHc4IaI%(UPDj9hI -arZSq+8CT["l$QDLcfHG(QArFB*Y$KRbTPkZfd$MA@)Ibe2B@fY4$[N&"Q*Kk#Xq -ddfVD4paQ&[qa8*L6d'YaS('rYSfI0q01IVaa8bhEbLcjL#6d''QbVZPJK#aLNb* -IpDVhb*3Bf4`JS%'M+cAj&&TcdTKLNjHHUP%-kl-5GHJJjT`GL9VTK$[BUN@"D3@ -c*k![TVCC2#ZaDP,K9pcG4((H1&heJUJhA8F*fe#T%Q9Xje4Um$pNS@EllYfS)YY -X"C*G2&q@#5`i1Ap`$!cU&j!!@08bZ4rQTR"HQiI&m'EGjAHF9m4f9L*hXSZqFQ[ -flN-"$N,X#DiLP!08CeqZM+8,LJU2X,R9HCRSZ#EGSUdG+VH4bhp+pr'b)Jj6R3E -r(hSYQqf0S3ZLPrV1H&'2"H!1U@8,jIZGHbl01IZ3!#,mj)*j4aFB6Ri,3H1%%h` -abpJ[P@34ICpBdQ`q(26dFd-4C5$AmLL"f,QUXaX@m9m8MS!ZGA2KqVISi5L%XBC -p#cm'KaX%[$qLbE[S9+6e12qppLbpQ)m"FpMK@e#ik&99$Se8kk!M9(N@-qS1LDe -qeH-I2NR!ckB&lJpL6&`CRe@G0`q([&+`#ked26XH4MXeFq)YP0UpmV5(00*lf#P -NL-#9,VCf*aF,j``Ad"5DC9V[G(jai5I"N!#bF0)*FpFk0brKc)AQVDkQGjdZC%p -iPl4-S05RmBlV4d1Q0fre&VP@rA)`FUa!$J8BHqBH3)'NG3F5ZLi'(fVeQklN)p) -NYP!m)DRJ`eSq)Md2ZakZDBG[S)"Fb-DlGL92i@AUKh(J@%+Qc0mFFKl`$%VTJ5h -fl41NqFk)2U4$lD`Dq6*6@EpAQeXkCNVE(*+Xb0A#i$VJQj[EUFXfRQSZMb9D%c[ -KV#H4A&[DlR[rae"cpKN"*cj-bUc,cKZ",4dEAlr9-,BAerh%hFc&4B"TDCYZfZR -r`0aZ3@k%Q4TKri`9IGI'HAG#K(+[Ibk-Ca-j(Q2RY@UTQEMq4PF@JhV`I3MNd3J -S1X(+fYq2LFhV!dPSReJ98jTUj)N9*jQ#L"B63TD0mikGEL1b!&+(#Q8S6D'+[#8 -q*1'(iTE`&C4&6c9DpLXS%)["Vpam(CCS%U9k3&lS6%'aaR-YEADBY8Pj4$'LNQ2 -eaZ`I&,h*m3JmCa90UQK2%SUr@U@`fA-j3eTZ1VEiZlUKe*RP6'L5%XZCDF5jqac -fB@m-%CBCNbQH8#H%6#-(5$3)p0&IKbS"51h#(+BP368*GqN&Hr4UQH)r2&TA)QE -`B3abEprUU-ma#TH6jiQ)59"kRX0$m9)HXq(+Z$1b9kkAq$bc(abflm1DPI`k*SJ -9A@m$bp4h41TS)9"dm`9-Iai0(IL#2m"bGcZ3!$MN-6AVd,lNria3Pqdj)Nk@HpI -AaSp&K1*j)BT%VCeHDLkA$cA0$lLX2$I34H$TBa8c!#XC)!1!!bc5T&8hDTK[HdZ -r54ZRbp%rLJN4RTVXc-a-bFqmBJe!(RR3`mEXU*GLrrC[Z"h1C5aC@ML5*QYUFM1 -!lA6K8(jX40J4,(V-GL[Nl&c4bjB#GlJ1CEZ$X2PqF9kc8XVe!A8%LL)jeZ2mL&- -,RN((-kG0fKeU%QJ$,0,PX(Hm,@A,-S-#RJU*SVX"jE-$HcjkXaTTDV3&l*UA-cJ -TjKa,'@XFN5F)QMBA2D1[Y2#ml3IQH*c`i`Q*AiJp+V0ki(ql(mjejKrYdj2@FN@ -p!)ClqNT4AlJ94%T*0hJBCF5"((pT)91-DTpIMrd04k8)Xh6)eVG%Eqq-h"k(-$b -S4RV0+ihZN!#V+"I1D"`-!JG2ae"1%D,8p+`XEG%(P96S)Ha"Sh"E98R1QBQ!ZEA --Rp$)K8bpP%B#S14)El+)fY2Re([(HU1-V4daRrU9V15hTIl4qeHaAN0iR`(1lPS -)"rL@kFbVGHL%8&"f6QR!5P0)G#5Gjk**3Ye,kPPB`)d&b-23q+XqpK`[A@j8Q16 -Z2X[N@R(2L$2QS4Hfphdr1qX2PHLB1ciX%Gfar%p!,Yr4-UP[,$@i"0eh6b,hVkB -k0!(45'4&E'q[KHRk$M(mjGR["[$(8Ji$$@HhhT*CH),ES3kQJPbK`jR$C4A4rQP -'A0NqR+PH"Jbr"MUSaN)CV+Yl5Y@d[YMUbmD'UV-H2ID&pJGqC+cA2N2J3D,3Bl9 -*`-c@(AXP5PAa8K!2A9U0@E"XqBZ66fFNXE3bNJ1!JhkKSXEm"p[eC(UaXH-[m+i -U2KF4kUVLaDeJ`ehPEY!lrLBDZhHdpHULU*!!Ba6TLalYYFCE+81-(PF(BbMF*dF -)G[$5bmILr4F9RB`ZNlE!ke0d!kF)Er@,,mPMe8qI$Rj'MDCC""HM,'QlQ'S-0Eb -R#Jm6&Fk[Pm,8`L46S&R4k'm*q*2KNUD-"q[SHVASl+*c13%G&q`P'0&`+*PlZR% -h0V8&ph*QYC(d9iJmYfR1p!k(VS!pe1bI)'H1'm(ZLI"$1pkhe2kcZ0LhFjm-@pZ -VC2lR6F9c"1SmYE`hKR09&d4l9#'$&PT6"X6ZGBa$0D)3!G&de,!T'aZJ%EEMKQi -SH#UVh!dVR$CQkk-"ZIDZS)K6Km'%Ylp)JUe%UMU+(lYiH@''4J(f*d8a*p&rCkH -B9HcJ,$i!$T58Al,K-#A9*k3$[KAl29MhDaJ0(iDU60bA&U2UCPL8UX4De5XKAbE -,N!$8P"N)jSP$$M6-8+Di1X9N2#ke1B)2mMDUd,*#Zmp%A5P&&Hh)HaqehcEI@[C -ddLZY"8D!["RHrbPLeI%a"S#YI$&leNC@CkSVZB!$Gb4SFUB[42AS9Ia*plJqZk! -0JKDmFZ#X9mH4jrNXlI1J"GM%6j!!Te+b9fdKBiiaG+(+bRK)QVkkN!$pQ(F+k&M -m&1NKXjpVE6#`T-J9[CUIMTBU@6$6-L-XrTTr35$KTX'dj@L3!09ddLFrAI$B4*9 -cZP*cJehCU6E5)66p6!de0Pj3p*X!hbQR)3Rel*5aU1q!Grm!rZ6(2MaQ5TYVZme -%4SK14k['llUJ9kcQe*G(GG(BMLV#4T1DL+rhSqX&ZaCl&@NZ,!PGkP$pKJ258lh -LhH''*[0[*%"b6kZ!-`fShrK6aKc2,LD8dq,+*aPm+EhHbdc3#&FTVXGlK@P8!2m -b5cq$TabM+I$1PC@QXdmQTp5JjF42@8fXp-ZFeN1)i%2p,YBk8qeC2`#C'9SlR#) -%p'0X8i'92V,hSU1+UK@i'r$@[K,![QBXH11%*la9MaGrF502p%j,dD(D)QUR1E+ -l2[`HjAL$@8H-PEf",i$'ZGHff6Qr19cD&BLklLQ4i2@AHl9)2`AI!hX&efA8Lm, -kdHU-[TZI!-!MYFGBmCJNZ[j08BkBmJ9+F*2FKFpq-FV*eei44jcTbA(ir5kLDU# -XfN4iibUkm"Yfm'$ETNb)Z0+HN`&PNSLf4[Y'8I&L`4PQ#Z1E%)H0ND*"qfP*(N( -0$QpVq,GfdE@)($eI)Njf[#E!ckEUB"4aQXM,KX!L`C4QdbZ-2$AB9r$0N!"&@I* -``iI,pUpY0)+[3c%%JB6*a2lj9BaJV&LNFp**rK4DQJVbPC9dpjeVVfdIhY905!U -Dj&1*R1T'pUUad(pf5+j"SGB0(-J'26E4Q,XRq-CX+Q(!Ej2QKYFEG3ZqF(MUaMK -T,q0G`QFh`XMcli+rjJ@a'Eb+cS2JYG6cHr$!hK`$rk,qeklDrB-(-cf3!'GfrLJ -9rF4CF6*53A8$!*lV5'c3KUTbk#YYMAL43b)2$SlY(rMq`)H889HHUI6#T*RV#8* -Y&K*18A#c)B0A,UKJJK"Hda#0DUYGLle2l6I)TGZYGUV+dk!+-DP!"I&8Vj8q)(r -TVl93qc3C%"T0KmGGk*&0A9Da`,2GH'Q(%3rb3jcVJV0-Fd2")KbRlH6!+)am[28 -I5`Aa,MNi![VBlRGRTFmF%)Y&bIkcId(IhL"iE2h-pf'bF)C(Zpcb[T!!2@`aA!C --Zc8(pZZMm,L(qKSap3#`bI6XaB2SH64(q61hCQ1eT&i!"54pjf30Gf@fk0&pBJ9 -GULGRM-h5'c(arcYfHm,V5RUZFa4'Jh6d!cTPp&`Um+#qcIp)I5+Z$iM&T*P4'6c -Epd6LYBm`BM*pEm1`JjT[EjK8fT5#Q$iQ8!3LDDjqN@Ee&kACA3[cppVR%YIUfX$ -j6mH%X8JF%U-qYMpjFplM4+KeS%e2eF)r@%a[V($HKYZNeR0(5MV1D+bIlHKjrT6 -+4Xf&DqQYQbH&Fcf@,*T[F`##GL#i3[QC"CITcTCNR&NXDcc5HlKZH`63f!r,00G -cM$mDVZ1[H0Eb+G+f(#)8d'Vm'VS10Nl+G08'eq*+(N*4d#A[N!#B51G*Bd`P!&V -pBMd)5Q$!E#m'dXaTT"ZUCN"5Q,-4Zd2$*c&eimfmV1TD432)qU6K35pmDpEXk(0 -K8P&5K"6PMUGJX'@29@Pf-Hl6Y4j)R41)RqYS0*cXBZ0*kT3TFK5%HhXJiM8q6a` -q2GY)FF1IKm0h%#-##qJ,IYQKZ3N*$66%Y2*GR)d!'2(pQ!Q$lMX$f`-[-#i(9L@ -+A22AbC(3kb!Q8MQEjf2dQUF-DX)pMRc1A`2Mpi#B,Y6rRB*b(aNUM,FbjlL0-dC -!"[Ai#ZZD(*j6r-NqGHCK[I%@ep3j3#)E-ipiheMml"B4ZF+1H`+hp&AXATqDB9L -+2r2J*qaPKd4CHH'!Fm3"@28@fXpKjaF*!D*r9c!k&mci"`"8ieK+[eJfB"A*U!# -m[pc"C4Nl-(`RjdmmZl+bS5NER,p@5qFHA+cV",dc#U+Qdc#T-EGZrN@3!+DMTee -N$-'mBY4Z$kMFVedhId(+j,-km5Pb05heVqIh3LQPlrQbfqkBhGQP*Lq9r960[GH -j5HBhqV1L*kL$0N%$(0`,EIG`mB#*@)NUiE-$&EBa,3m2(rYH$Xai4@%X8@h(X&E -j+FFrRK[6apaP9@13!)C0eef[J-'S!XFkKdbEa++1NPEicMGB)TlPC,+52PCLmf1 -j1I[TVDRF4QKCm@S2"'r!2h(bpCHHG,!j4V@Sbb0Lp!#[@+iceD`N)TNJM8Tc`$r -K31F'2QfI%45IMjJkR@c)PDAChZf3!+c+[H6EQMmM+r1"RHA$@'CR[1hHT35l9U8 -X(D&"YYL$Rr"fBSlhKTHfT%6B'lR'+3+L&fP6)#cY+j5I[V3HSF8FPp2Bj)8J@!U -pq8-#iqUQ2j*Lkh($3k%HUrk43-lK5BlSM`,Vk#IGY*b6K-3cVPffZMc(GeDQ*kE -'1BX,$,dqB6A'6jUFLVa2,F06GK5h#af,IpJk&mRj6K8,%i$'63fiTkBN#+DMkpi -)3DTVe!XTYYX#mGN9FZ[&h86M2mY!109hddSE03G!+k&F(HB"@C45CFaX1XZT[iC -Z1a-kpLB`%qcEZ0dUi"V''"(C"jf%*!(J1d3e##,G0"*DD&VKra(8jR+V8J1m[k8 -%S(S*MjHRDi)(RMZ"kCA`KhRLH1"JUjA#EUr*1'9Kk"XENBRj!'Z%Yb)INlE-!#, -DdUp9AVDf``9ddDK-ck*I#GSN+N)''l%hQ[PM,3VVda[[F@lZJ-TUlSUR2A8LG-T -00CqAcrNe5(G!adXL,[rJAJSJ#N`CIDM1Cj+(cYEi2JfrkXpf[EAQ%HI"AkBHqZ+ -!pdQR'l"d2lAee164Vkmr@*Yr@T'H5#Eph!6-K&fGN!$&iU&VDmTpibLUC5I&N[Y -NKMNcBT1XKLR+EpHcmT'$RFMkS4C35i#UIKqYF40eb+"idl-c)()VGA#$!CN&LhC -,jI$BC`60PmG)lh"'13R#fEL%R%qPC*X2*Ja!IMb@Yfr"I`3S9lf&MdJ4QHlUc[c -qSP4'B839b3F[P2SL#jQQS$NDiMkrI5VVjbdlZI6YZ[0q3!h4U&*U'(&`6U[!G5d -B"*PCa8mHK$%X48#(q,a1KNl&hY6L"HZY#H9D+)6+bYXH$8A8A)UQ(Aa2SMI2Jm" -Y#A4SFRrTBjjCl[')j[iI&#aDQPI!NqcP6$'1X&RPE$M*e0N2Q*@mCLq6ed"p8D' -E%b6$)fVVTr&Ei6fcH),VR9Z6!@G@hDTfGY,p[)4`i'R9@FJ%4bSd9EeJAFh-iD2 -3`"$B%k`+U1NErX'8M[)8jiL[ed&!YDFkSd!ka9A$LAY64`FQ@YYAae'6e40DS6r -!NqR+K`)&3T(68%l$$',#rib$#QJ0CqaA3lXi*0UfT`LIPLb#rpPRf4-BkYkEHHB -RAYL"kM'3!*QSR!I@'U%%ReF'1(V@FrM)iT1+VqEm#$QKFb)S'VKUH0Eqb5+fU*2 -%c,YNdpb*Dp5iB-+LH`fUIMTV0c0LlF'-)N8)Y9N"p`BiS%$6DFb2QaU9TKGc`I9 -K-ap,,+c)edHUq*CALSbMiM#YbCBTfLYXarH[S$Iqb9d)NX`5drSq0m4+XaR"$)' -+SEa08R4G[Q9*fi$KrY+S,8'BibL%p6p4VeBe+B&LJ28UH5!dr*(KfhM33id!-3V -19+i@f-G@$qN-LG$QkNGV'KB3r8*Q8BdC'ZiriC&&*0!%T0'+k'HD"9V-!H98hGl -1hl9'3$U(b(@lYK`(#,B*b$V)5)N(jMm`F&C8VSNBjZ&#fk+@3ZHRID,C@S#FfF( -lH68%ZJBT'F%BZ+&klTaeVAeiKk&Y"ScmXQq1!6C-F+bb'pcXj6'f#R5RbNA'Y1% -6*BUm@&FiH13dB1(6NZ@U$1ieKP)QR3Bp3T+Y,D[XDP`!S,"MC@c`bC*4ZF)eLK& -(Gqm8UR`+ee`%qS54,Rr,r2rID@"q,XYrkQ!Z(bL0e("6q2##qSF*395MLESV1+j -k*e)r(&`6Y8Y'm4krFeD#cr)0mD`GIrEbY!S)EY`X9`5G4-1eP[CBp9Y5m'H*K#A -mQ((hI5`48YrH,0fKrB@+-`XM5VNGMYN-8Ci36j@i4P0GKPfd&fk)1Ql5CpEQKf! -hEYLY1H("J,d((3SqBH)d,I*M'$J%1KNppK!!P'[RaC!!VP&DRB6kD'`GBJ89Z$b -2&2aDBBP4-r!($)DPqEbl&bF9Naph4@&-d0&26*HJU3#*85M6XJc9KYckK2KZGfM -1`,pE9N5-$cf[Jqpr)A&4UIMMaHC,&3XT@XS4r3Br-3lkM(TfBVHh1EZ1[1EhlpK -T,0E"S*C9-U4Aa5["lqQS$#PpKN+McZPB&85B&p)Xlp1hVI$PkRi5d18$Cdf%%@D -K9TTU'V#-hl54hAR($q1fHFA%m3#*V6%IB3Xa5Jp8h5I-+UL[&h`r3BQ3!'j0aJK -0Q"B@GaPQ*ehVak+m)P)(qX9IPdec2e32lA[ra&4j8$Ej6%RcK50%qZlUUma�L -rh5Xc,!9ml59c9mZ5Mr,2M[-R3c8pYk3Deb4+cFQEhP)6qCV-bEUI@c"qk1&Bb0Y -@FXajacR%HbY18!Bc0NV-JY`M5Sde#)'-*3pIC`d"`!eU#2iEmjk4kSL,a60M[b% -QM(HDpGY"!GmLSe`q0hIRZ,fqTj-0NITbXVfb-G6GU&I!@I,$14QRK&jdUX'5EN) -#Q"$DLE*dGm6Dke"4!r)M#$R"6L1ciNFBk+cir&6h1#RGFi$iS4RLYSUIrFm$pbV -XPVdAd5-&NEbTh01@B0m+df#rSFZ18De[T9ERC!R(JkI$,a#fZH'1He"C8B6[6cF -aChV`"I$Nf#P6BNT'r0Ta8hN,C*T&M#DI+C5PIl[eIZGc*5)*dP#iV5)iqEq0kf@ -6EH()Qkr,e(P),idCBq3AB5dhZkMeSr3%TY`#T,"DJDpZ[+aMK65P3%0R#"(0,6e -Q%aA2R8(#9PF`H!@[!i2LKF&XZC6+[29k4,Sllb@IfYL9S'%d4hR9T(j+D)HhGAR -3Z+k,AmQV1ir[-jVF0h!!h[`qJjBpISi,G6%REZJ6)5EC1Lj8S)``IZcIB*,[mZQ -3!,3afK"rkNJF+,(ji1cqh'rE29'k+RZjIJ))JKHY32YcYVP)0!UfE[IaZa"*,SV -UG#2U2H-V5H41(1!C[*SI%U2NDFISaD4,3r-K!a2LZ3E-mPjEl+Y,b+r#3-Ae#N" -MMqL2br1k2F9'mPGjFDK,#&XDl40paE)8d#3p#pVrjMjlC+jjBL!8fM&m8PNJr1T -F-S"YrI3!BQ3*G3)c$IRrTAIFP(k#RQ[XbVcV![,E%,MAXGB#,6!V3D+,lj!!2Fe -*+Ai!R5Zc1F5eI81S(K`b9[SQrR5L'QSlTm,9iV(6G1%KSD,f9IGUV"Gfi"T--q2 -Q2T@'HiDNYHL0X`NDjV(#Be[SBN9[P%dlTD3ahKI&j80mh,Er(9H2GDa+"900I!3 -"+BT'EAjc*LTl&`i4`GIFPQfm-rp(T6E(i2d"1A@eJ6MbK!bc+5XX*dSjH[%hBq, -lCRUGY1Ip93T"II4h!E3H5&V#[(qAZBf1ILq"qSB'1M#(A*M+mSJGQce+5rBU$U8 -@,AjGA#f*hh5chTFL'%#9jCRQqdafb#!mAYHmkE)#h-(RjY$ZMVE,,QiThlGCZf* -K`SS(,DjaEhB[mbKM2II,V+Yq62P%2i,`M"9M6[b26a)r1dNe3Gk86ThXDaccUl( -#6X%$ri8+5KLX!VF[B5c+0dhhAcUC5Vd(56i&b'S'd[0ZiPqqaSqCd%fS$P(kiT, -0`c(B,SR'E#,)$pladYB9c#aP%Rf0@V`RIUH+6[m(4!i``Qjj[#HJB!)Y+Kq)Z)K -[(2'ME@#ir("N,,a-[[$86)e'&SZ3!,GA3$@m1Hjp`d'2kd8H2HQ*R8$l6SXCd0$ -)41T4,P551D(6TU91@elAK"C6Fh4RS,H1hI-ik6A&5*KK!(4*T0'85r!dbGe&Cf% -d[c-D)m+E'8K8,dlif,`[a2%"l'XNj2X@SjJdK+fDVKGZrm-RNU"k+`c4',G1#!f -+"TQ62Add[&#L6R8GcqM0PGFA4C`@+JIa6*iC-aQQrCPcr9em"M1BBVJ2h'0[4EI -3,m&f9`VIY25!5kUk4KdpXdk@[aGK+jZ(e2`55j@a6(i4ZG2E`TQf6%,XJ"91Zp- -I"6U4,afcD(QD&EkJ1IIUp)Kjj9J$'15cRIhS,VDSI+G!94hUAR#ICaDDXV3PeV# -*5)$J1M)Qi&pFYP'P"fFdL'd9#fIJ02!kadH&A"FVT[C0!GAE80ZE1ND4mmf-5[S -dK,%1UPk9&NE6j`F,@pY#dJSja'T$)HP)jBbNb$6fpd#G46i%!'l653!%#8"FkIp -Fle[%remh$+pH&e4KDrdMB!K"6(HYh2f'+KSf8HBqKCYck'aAjTAmNMaPrB)'eMb -,M(XA-ChV8D!`%'q-SH!TRQm&2,X*dJ8Nc[cX$-@@UrIbqLIEK%XG-RE+iJM$X!! -*"0R69#XY26qJpIHR[X&R0I@4jT,E(V`N8`kMUKDD5bLJ*-cY&)A`Y&caJ-"8*TD -rX3Z[+d9pmLp5XK($jcmGliAdMj!!rhK@iL29rU1YQPHQm&Ua$a)J@f[1Z`1PE"( -r##$30a&(8fqAJ&55F1Y),r%HJ#S#C0jE#TEN&*iCcriXfV#(M"ASaEXbLX4kE%e -%$j%jdB,-Q`VfEKq'R*1),'6bb3$r([p$VD3&eJ(Trc((2Ti((F9UP`*4-T&[##c -GZ'-FfA)ENHe'1hXl3@+50pGkjQ%lj*UTHq6%4M-!hUPBkcJHF68IeZA&p+Mbhd" -Q%Q&JXZ)AJQcj&[-ZRc,2JCEd5@1VCYI62PD6,60Cp-e'-C5(aT!!,SB4d4308@H -BkREQF$VR%E0Cj)!8R!eV+9NZIl$MfHUBVMfk4AZr1F3DN81Eb#NdiPGV1E$Gr,h -Il8if-Ie[B$Q'!q-)i8Ja*T2%!@"Shm69mBUV26!ibAcZZPYQN3)&ELc"Jc@3!!f -GlRHP#DKDVBV`9X@&88eKieeSVCIplj9BZLpir*I09,)QfQ$Akck@bj3#!XHp2TA -qU1PX09HQ*ShlTK'ZC,N4Y`)T!lmZpc8cI1RbQKTBLCpX5lq0+PHbP'U[qc,F!Gc -21kGkKa!Dj(`8(J+k4@Y[GIjDYC@FUKeH'3@$hr8d5i-cT9QqB`qeEJAIHlfMG%9 -A[SJS*PH&2)Ik5R'Fk)1j51Zr4KrEJDpT0['9NqH5am2-[[8+USH9lqrm&F5XULD -d&Rmbi&HZVll0*k%['C5$KeF'29[e&lTmP5I$c,1LGpGf!6rFrC@eMcXA-SXr45r -(18G'PVP4L8ji!*2a-(d9dMjNb5eKlJ9&QDEUPN26pJQ,pQ-CK1ADDKJSHM,ZRR( -5VNpVAcRX6H6+h1!15Lf"IBU[r80Xj`hljdNM39R$KZUHij@4A#i6&JIe!Y8U0dR -X"#r*CrVk$&5JC,l$KkH66i%2mf4#XZ'rRr2E%)rJ3e%m!SC4pa@02GZ&pLQ2&+B -HJ89,RiN)XGDkZR+0LrHDDpEd+Yb[)FJl!pR'QpY5(B'efK''SIj@$)M)bpbdp)d -@aaUJN89[@21Rd)6FMDRE2N%a1Gml8hi"41(@IH,a[['9AC*j!)4XZa1(ALlI1Zl -Me)@2fT,pj*G%hZ8q@r*DTIQRYYE'm'DrpH#d8,'fk!(%2e(&#"dmpPr`F8#EPRY -bS,8[#[Ma#+i%XQ8LCSBEHjlUcB6UdjqILUahHpS1r&6J(@F"+a&6p181U'N@cpX -i*p"V0[r'8ahQl)KHRE-'h25alBE1-'LMq5iMUY`9FlajZ+Y6k)eF$aGZc1k5LaX -EqL0+@[fNGS(!p&r,VMp`K%kLb`kkkeQhl#*%@9-BAfA5#)efr0"UDa*`*N-YAXJ -*'J$#3p@jd&eIeNhrF3PJ$2kM"lIld#bN`beCYK-Q$j(,Jh4hJ@3UL5il'fC3%'e -VqZe)miR[Pb2IT+1FEKEXX+S5Mc#`F$+apB`M+2'hd50BY2'idB$Zm$ibhl&Z'QD -q2#A@bP#RIA3q!Z@YT01R$Lip!qp1"Hi*"1%LCib&jr0G#SQ-"Z91Z@ZiU!#A*Rh -YV%eT2ZY2Z4mk+!K"N!"@TUbNm$#!rS5F6'-BSIX"hMF$e3,L8i&VBTAiV)'R9LY -"a1GNR233V`@%++f#%#AHl+d!M*2L%UD6D*!!*a`Tb%P5*JRqGe"k42),C(rRL11 -hjdX4%a%L%VKlRLQP3MeQ*MCYjZY#jA4rZi&CQQXEMC!!RaMh`P*2pT6'UZBcj@C -1m*08J)frpUD)-@D#LlZ"BNY-fGSr!-`T%q)M*LpjABE&me%FK4TpCVXL,,cNbqU -+0'F%fES8L0ld5CRL)UKkr+8BNka6'6epVP+,0RVhLhE!,N@Uc*l(6-*q4,"`kTV -S[+48Cjk[LJm[deDfVXLi#9r!PSSq3b0*"p89G%*RXfHUii1rfEer(,Q3!%5,$br -e*CCR1,KEU!$P"B"VS'R*q8EP3K3Rfik@S[Rkd3(ZHC1YB`1E@-pY,CBbUe5iQ`d -hS&2IMi4,@3Ci4`SQeI)p("JdV&%1hB$6EYaS4YUeIjF@R#38dNH[+4mLre'pXP$ -%%d%fYr9R8H4EkY`$i1@PUiUkKPj2G`HeB2C-j$SUl3a2pUXZFAD`MC1FBHcpIdV -1cB5Z6@5,REBb)1mbd(-9Ck056a'H6Vr&#T9$)2'-UYC@K,"FF'Sr63X60A,2e%Y -32BL$[S!"Rq04R$f#q!#PN!3"!!"&!"#iC[PUZ*!!5(8!!"PR!!"4pJ#3!h)!&I$ -%!*!$B!#3!e!!N!32!%eKBd&RD@aTG(P(E'Y3FQ9QDAJZD!!"eV9849K83eG*43# -3%)!!N!N"QJ#3!fF!N!32!%,"e3rPR@"@GJ)Nj5!bXicA%6F)hccE`fd'd&i)f!i -l`SP`-e!UfB0LQhQqk@X#V9m8RQDSf'P16I49i"jc2@eVE38lGahZp!eA@fMpd&$ -SUi`Z4XmR+#Fj[K-k1*,8*G(R#GVmdU"#`G6NB'4rX`6fh0kkkMYXe[#JLKG09K) -G92IipMTTfdY-!kCKThEERMdId-XP`KX$abP5IP6Kl&4-Y`UF0$eI@Scaf62++l9 -!lEEJAY8S!+@3"!%!!$!!3!#3#P$)!*!(FJ!!VAlrN!3!N!SVS3!!: \ No newline at end of file diff --git a/app/src/main/jni/terps/agility/os_none.c b/app/src/main/jni/terps/agility/os_none.c deleted file mode 100644 index 6a4dd0a..0000000 --- a/app/src/main/jni/terps/agility/os_none.c +++ /dev/null @@ -1,279 +0,0 @@ -/* os_none.c -- interface routine template for generic system */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy, the (Mostly) Universal */ -/* AGT Interpreter */ - -/* This should work on any system supporting ANSI C, at the price - of playing without a status line or other system-specific - i/o features. */ - - - -#include -#include - -#include -#include -#include - -#include "agility.h" -#include "interp.h" - - -int scroll_count; /* Count of how many lines we have printed since - last player input. */ -void print_statline(void); - - - - -void agt_delay(int n) -/* This should wait for n seconds */ -{ - if (fast_replay || BATCH_MODE) return; - print_statline(); - /* sleep(n);*/ -} - - -void agt_tone(int hz,int ms) -/* Produce a hz-Hertz sound for ms milliseconds */ -{ - return; -} - -int agt_rand(int a,int b) -/* Return random number from a to b inclusive */ -{ - return a+(rand()>>2)%(b-a+1); -} - - -char *agt_input(int in_type) -/* read a line from the keyboard, allocating space for it using malloc */ -/* in_type: 0=command, 1=number, 2=question, 3=userstr, 4=filename,*/ -/* 5=RESTART,RESTORE,UNDO,QUIT */ -/* Negative values are for internal use by the interface (i.e. this module) */ -/* and so are free to be defined by the porter. */ -{ - static int input_error=0; - char *s; - - scroll_count=0; - print_statline(); - s=rmalloc(1000); - - if (fgets(s,1000,stdin)==NULL) { - if (++input_error>25) { - printf("Read error on input\n"); - exit(EXIT_FAILURE); - } - s[0]=0; - clearerr(stdin); - } else input_error=0; /* Reset counter */ - - if (DEBUG_OUT) - fprintf(debugfile,"%s\n",s); - if (script_on) textputs(scriptfile,s); - return s; -} - -char agt_getkey(rbool echo_char) -/* Reads a character and returns it, possibly reading in a full line - depending on the platform */ -/* If echo_char=1, echo character. If 0, then the character is not - required to be echoed (and ideally shouldn't be) */ -{ - char *t, *s, c; - - print_statline(); - -/* We use agt_input here only because in pure ANSI C there is no way of */ -/* reading in input from the keyboard without waiting for return. */ -/* In general agt_getkey() and agt_input() will be independent. */ - t=agt_input(-1); - for(s=t;isspace(*s);s++); - c=*s; - rfree(t); - - return c; -} - -void agt_textcolor(int c) -/* Set text color to color #c, where the colors are as follows: */ -/* 0=Black, 1=Blue, 2=Green, 3=Cyan, */ -/* 4=Red, 5=Magenta, 6=Brown, */ -/* 7=Normal("White"-- which may actually be some other color) */ -/* This should turn off blinking, bold, color, etc. and restore */ -/* the text mode to its default appearance. */ -/* 8=Turn on blinking. */ -/* 9= *Just* White (not neccessarily "normal" and no need to turn off */ -/* blinking) */ -/* 10=Turn on fixed pitch font. */ -/* 11=Turn off fixed pitch font */ -/* Also used to set other text attributes: */ -/* -1=emphasized text, used (e.g.) for room titles */ -/* -2=end emphasized text */ -{ -#if 0 - if (c==-1) writestr("<<"); - if (c==-2) writestr(">>"); -#endif - return; -} - - - -void agt_statline(const char *s) -/* Output a string on the status line, if possible */ -{ - return; -} - - -void agt_clrscr(void) -/* This should clear the screen and put the cursor at the upper left - corner (or one down if there is a status line) */ -{ - int i; - - for(i=0;i\n\n"); - if (script_on) textputs(scriptfile,"\n\n\n\n"); - scroll_count=0; -} - - -void agt_puts(const char *s) -{ - printf("%s",s); - curr_x+=strlen(s); - if (DEBUG_OUT) fprintf(debugfile,"%s",s); - if (script_on) textputs(scriptfile,s); -} - -void agt_newline(void) -{ - printf("\n"); - curr_x=0; - if (DEBUG_OUT) fprintf(debugfile,"\n"); - if (script_on) textputs(scriptfile,"\n"); - scroll_count++; - if (scroll_count>=screen_height-2) { - printf(" --MORE--"); /* If possible, this should disappear after - a key is pressed */ - agt_waitkey(); - } -} - - -static unsigned long boxflags; -static int box_startx; /* Starting x of box */ -static int box_width; -static int delta_scroll; /* Amount we are adding to vertical scroll - with the box */ -static void boxrule(void) -/* Draw line at top or bottom of box */ -{ - int i; - - agt_puts("+"); - for(i=0;i -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef LINUX -#include -#undef HAVE_TPARAM -#endif - -#ifdef BSD_TERM -#define tcgetattr(fd,data) ioctl(fd,TIOCGETA,data) -#define tcsetattr(fd,junk,data) ioctl(fd,TIOCSETAF,data) -/* junk needs to be equal to TCSAFLUSH */ -#endif - -/* Need one of the following */ - -#ifdef NO_TERMCAP_H -char *tgoto(); -char *tparam(); -int tputs(); -extern char *BC, *UP; -extern int PC; -int tgetent(); -int tgetnum(); -char *tgetstr(); -#else -#include -#include -#endif - -#ifdef USE_READLINE -#include -#include -#endif - -#ifdef TIOCGWINSZ /* Both of these need to be defined. */ -#ifdef SIGWINCH -#define CATCH_WINDOW_CHANGE -#endif -#endif - -#ifdef LINUX_COLOR -/* 0:Black, 1:Red, 2:Green, 3:Brown, 4:Blue, 5:Magenta, 6:Cyan, 7:White */ -/* 3n=foreground, 4n=background, semicolon seperated */ -#define TS_LINUX_SL "\033[37;44m" -#define TS_LINUX_NORM "\033[m" -#define TS_LINUX_SETCOLOR "\033[3%dm" -/* The AGT color codes are as follows: */ -/* 0=Black, 1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta, 6=Brown, 7=White */ -int color_trans[8]={0,4,2,6,1,5,3,7}; -rbool color_on; -#endif - -#define pFNT ".fnt" - - -/*---------------------------------------------------------------------*/ -/* Misc. Global variables */ -/*---------------------------------------------------------------------*/ - -static rbool nav_arrow; /* NAVARROW set? */ -static rbool lower_file; /* Lowercase resource files? */ -static rbool font_enable; -static fc_type game_fc; -static char *viewer_name; /* Name of image viewing program */ - -rbool have_compass; -static int status_height; /* Number of lines in status line */ - -static int control_width; -static int scroll_count; /* Count of how many lines we have printed since - last player input. */ -volatile int curr_y, winsize_flag, cont_flag; - - - -/* NUM_KEYS must be less than 32 */ -#define NUM_KEYS 23 -#define FUN_KEY_BASE 11 -#define FUN_KEY_END 22 -#define LAST_FUN_KEY (FUN_KEY_END+10) -static char *term_keycap[NUM_KEYS]= -{"kb","kD", - "kl","kr","ku","kd", - "kh","@7", - "kN","kP","kI", - "k0","k1","k2","k3","k4","k5","k6","k7","k8","k9", - "F1","F2"}; -static char *term_key[NUM_KEYS]; - -static char *fkey_text[22]={ /* Text for function keys */ - "help\n", - "get ","drop ", - "examine ","read ", - "open ","close ", - "inventory\n","look\n", - "score\n", - "save\n","restore\n", - "exit\n", - "w\n","e\n","n\n","s\n", - "nw\n","sw\n","se\n","ne\n", - "enter\n" -}; - -static const char *keylist[12]={ - "del", - "left","right","up","down", - "home","end","pgdn","pgup", - "ins"}; - - -#if 0 - "undo\n", - "get ","drop ", - "unlock ","read ", - "open ","close ", - "inventory\n","look\n", - "wait\n", - "save\n","restore\n" -#endif - -/* Other candidates: view, wait (z), examine (x), again (g) */ - - -/* These are used to hold termcap strings */ -static char term_buff[3000]; -static char term_cmd_buff[3000]; - -static char *term_cmd[16]; - -#define TC_GOXY 0 -#define TC_CLRSCR 1 -#define TC_HIDE 2 -#define TC_SHOW 3 -#define TC_SL 4 -#define TC_ENDSL 5 -#define TC_BLINK 6 -#define TC_NORM 7 -#define TC_DELLINE 8 -#define TC_SETSCROLL 9 -#define TC_CR 10 -#define TC_CLEARLINE 11 -#define TC_BOLD 12 -#define TC_NOBOLD 13 -#define TC_INITKEY 14 -#define TC_RESTOREKEY 15 - - -/*---------------------------------------------------------------------*/ -/* Misc. minor functions */ -/*---------------------------------------------------------------------*/ - -void agt_delay(int n) -{ - if (fast_replay || BATCH_MODE) return; - print_statline(); - sleep((n+1)/2); /* In theory this should be sleep(n) */ -} - -void agt_tone(int hz,int ms) -/* Produce a hz-Hertz sound for ms milliseconds */ -{ - if (BATCH_MODE) return; - return; -} - - -int agt_rand(int a,int b) -/* Return random number from a to b inclusive */ -{ - int n; - n=a+(rand()>>2)%(b-a+1); - return n; -} - -genfile agt_globalfile(int fid) -{ - char *homedir; - FILE *cfgfile; - char *fname; - - if (fid!=0) return badfile(fCFG); - homedir=getenv("HOME"); - fname=rmalloc(strlen(homedir)+10); - sprintf(fname,"%s/.agilrc",homedir); - cfgfile=fopen(fname,"r"); - return cfgfile; -} - -void script_out(const char *s) -{ - if (DEBUG_OUT) - fprintf(debugfile,"%s",s); - if (script_on) textputs(scriptfile,s); -} - - -/*---------------------------------------------------------------------*/ -/* Low-level Terminal Functions: gotoxy(), etc. */ -/*---------------------------------------------------------------------*/ - -void fix_loc(void) -/* This fixes the location if we are restoring from a suspended state */ -{ -#ifdef LOCAL_FIX_CONT - char *cmd; -#endif - - if (cont_flag || winsize_flag) - agt_clrscr(); - -#ifdef LOCAL_FIX_CONT - { - cmd=tgoto(term_cmd[TC_GOXY],curr_x,curr_y); - cont_flag=winsize_flag=0; - tputs(cmd,1,putchar); - } -#endif -} - -static void gotoxy(int x,int y) -{ - char *cmd; - - if (BATCH_MODE) return; - cmd=tgoto(term_cmd[TC_GOXY],x,y); - tputs(cmd,1,putchar); -} - -static void cleareol(void) -{ - char *cmd; - int i; - - if (term_cmd[TC_CLEARLINE]!=NULL) - tputs(term_cmd[TC_CLEARLINE],1,putchar); - else { - for(i=0;i=screen_height) - curr_y=screen_height-1; /* Scrolling has occured */ - scroll_count++; - accum_text[0]=0;acc_ptr=0; -} - - -void add_accum_text(const char *s) -{ - while(*s!=0 && acc_ptr<80) - accum_text[acc_ptr++]=*(s++); - accum_text[acc_ptr]=0; -} - - - -void set_scroll(int top) -{ -#ifdef HAVE_TPARAM - char buff[20]; - char *buff2; - - if (term_cmd[TC_SETSCROLL]!=NULL) { - buff2=tparam(term_cmd[TC_SETSCROLL],buff,20,top,screen_height); - tputs(buff2,1,putchar); - if (buff2!=buff) free(buff2); - } -#endif -} - - -void show_cursor(rbool b) -/* 0=hide, 1=show */ -{ - if (b==0 && term_cmd[TC_HIDE]!=NULL) - tputs(term_cmd[TC_HIDE],1,putchar); - if (b==1 && term_cmd[TC_HIDE]!=NULL) - tputs(term_cmd[TC_SHOW],1,putchar); -} - - - -static struct termios termsave; - -/* Put the terminal in noncanonical mode */ -static void set_term_noncanon(void) -{ - struct termios newterm; - fflush(stdin); - tcgetattr(STDIN_FILENO,&termsave); /* Save terminal settings */ - tcgetattr(STDIN_FILENO,&newterm); - newterm.c_lflag&=~ICANON; /* Set noncanonical mode */ - newterm.c_lflag&=~ECHO; /* ...with no echo */ - newterm.c_cc[VMIN]=1; /* Read one character at a time */ - newterm.c_cc[VTIME]=0; /* No time limit */ - tcsetattr(STDIN_FILENO,TCSAFLUSH,&newterm); -} - -/* Restore terminal to previous state */ -static void set_term_normal(void) -{ - tcsetattr(STDIN_FILENO,TCSAFLUSH,&termsave); /* Restore terminal */ -} - - -#ifdef CATCH_WINDOW_CHANGE -void window_change(int signum) -{ - struct winsize winsz; - - signal(SIGWINCH,window_change); - if (ioctl(STDOUT_FILENO,TIOCGWINSZ,&winsz)!=0) return; - if (winsz.ws_row==0 || winsz.ws_col==0) return; - status_width=screen_width=winsz.ws_col; - screen_height=winsz.ws_row; - if (curr_x>screen_width) - {curr_x=screen_width;winsize_flag=1;} - if (curr_y>screen_height) - {curr_y=screen_height;winsize_flag=1;} -} -#endif - - -static struct termios term_save; - -void restore_terminal(void) -{ - show_cursor(1); - set_scroll(0); -#ifdef BSD_TERM - ioctl(STDIN_FILENO,TIOCSETA,&term_save); -#else - tcsetattr(STDIN_FILENO,TCSANOW,&term_save); -#endif -} - - -/* SIGTSTP, SIGCONT */ -void cont_handler(int signum) -{ - signal(SIGCONT,cont_handler); - cont_flag=1; -} - - - - -/*---------------------------------------------------------------------*/ -/* Character Appearance Functions */ -/*---------------------------------------------------------------------*/ - -#define STATUS_STATE 0xA800 -#define START_STATE 0x0800 - -/* For state: - currently low 4 bits are color. - bit 11 (0x0800) indicates normal color - bit 13 (0x2000) indicates whether we are in standout mode or not - bit 14 (0x4000) indicates whether we are blinking or not - bit 15 (0x8000) indicates whether bold is on or not */ - -#define NORM_BIT 0x0800 -#define BOLD_BIT 0x8000 -#define BLINK_BIT 0x4000 -#define SL_BIT 0x2000 - -typedef unsigned short vstate; -static vstate state_stack[16]; -int stateptr=0; /* Points into state stack */ - -#define cstate state_stack[stateptr] /* Current state */ - -static void set_state(vstate state) -{ - vstate diff; - char sbuff[10]; - int c; /* Color */ - - if (BATCH_MODE) return; - - diff=state^cstate; - - tputs(term_cmd[TC_NORM],1,putchar); /* First put the screen in known state */ - - c=state & 0xF; - if (state & NORM_BIT) c=7; - -/* if (term_cmd[TC_NOBOLD]!=NULL) - tputs(term_cmd[TC_NOBOLD],1,putchar);*/ -/* tputs(term_cmd[TC_ENDSL],1,putchar);*/ - - if (term_cmd[TC_BOLD]!=NULL) { - if (state & BOLD_BIT) { /* BOLD */ - tputs(term_cmd[TC_BOLD],1,putchar); - if ((state&NORM_BIT) && !(state&SL_BIT)) c=6; - /* BOLD text will be yellow */ - } - } else - if (diff & BOLD_BIT) { - if (state & BOLD_BIT) writestr("<<"); - else writestr(">>"); - } - - if ((state & BLINK_BIT) && term_cmd[TC_BLINK]!=NULL) /* Blinking */ - tputs(term_cmd[TC_BLINK],1,putchar); - - if ((state & SL_BIT) && term_cmd[TC_SL]!=NULL) /* Status line state */ - tputs(term_cmd[TC_SL],1,putchar); - -#ifdef LINUX_COLOR - if (color_on) { - sprintf(sbuff,TS_LINUX_SETCOLOR,color_trans[c]); - tputs(sbuff,1,putchar); - } -#endif - - cstate=state; -} - -static void push_state(vstate state) -{ - if (stateptr==15) fatal("State stack overflow!"); - stateptr++; - set_state(state); -} - -static void pop_state(void) -{ - if (stateptr==0) fatal("State stack error: POP without PUSH!"); - stateptr--; - set_state(cstate); -} - - -void agt_textcolor(int c) -/* Set text color to color #c, where the colors are as follows: */ -/* 0=Black, 1=Blue, 2=Green, 3=Cyan, 4=Red, 5=Magenta, 6=Brown, */ -/* 7=White("normal"), 8=Blinking, */ -/* 9= *Just* White (not neccessarily "normal" and no need to turn off */ -/* blinking) */ -/* Also used to set other text attributes: */ -/* -1=emphasized text, used (e.g.) for room titles */ -/* -2=end emphasized text */ -{ - vstate nstate; - - nstate=cstate; - if (c==-1) /* Bold on */ - nstate=nstate|0x8000; - else if (c==-2) - nstate=nstate & ~0x8000; /* BOLD off */ - else if (c==8) - nstate=nstate | 0x4000; /* BLINK on */ - else if (c==7) - nstate=0x0800; /* "Normal" */ - else if (c==9) - nstate=(nstate & ~0x80F) | 7; /* Set color to 7: white */ - else if (c>=0 && c<7) - nstate=(nstate & ~0x80F) | c; /* Set color to c */ - set_state(nstate); -} - - -/*---------------------------------------------------------------------*/ -/* Functions to read and translate keys */ -/*---------------------------------------------------------------------*/ - -#ifdef USE_EDITLINE - -#define KEYBUFF_SIZE 64 /* Needs to be power of 2 */ -static int keyptr=0; /* Where new characters go */ -static int keyread=0; /* Where old characters get lifted from */ -static char keybuff[KEYBUFF_SIZE]; - -static void push_keychar(char c) -{ - keyread=(keyread+KEYBUFF_SIZE-1)&(KEYBUFF_SIZE-1); - keybuff[keyread]=c; -} - -static void key_backup(int n) -{ - assert(n>=0); - keyread=(keyread+KEYBUFF_SIZE-n)&(KEYBUFF_SIZE-1); -} - -static int get_next_char(rbool timed_input) -{ - char c; - - if (keyread!=keyptr) { - c=keybuff[keyread]; - } else { - if (timed_input) { - read(STDIN_FILENO,&c,1); /* Actually read in the character */ - } else - read(STDIN_FILENO,&c,1); /* Actually read in the character */ - if (DEBUG_KEY) printf("<%d>",c); - keybuff[keyptr]=c; - keyptr=(keyptr+1)&(KEYBUFF_SIZE-1); - } - keyread=(keyread+1)&(KEYBUFF_SIZE-1); - return c; -} - - -int read_a_key(void) -{ - unsigned long keyflag; - int c; - int keymatch; /* Possible matched keys */ - int key_leng; /* Length of matched key */ - int i,j; - rbool nomatch; - - scroll_count=0; - keyflag=(1< Home */ - case '\002': return 1002; /* Ctrl-B ==> Left arrow */ - case '\005': return 1007; /* Ctrl-E ==> End */ - case '\006': return 1003; /* Ctrl-F ==> Right arrow */ - case '\010': /* Fall though... */ - case '\177': return 1000;/* Ctrl-H and ==> Backspace */ - case '\013': return 1500; /* Ctrl-K */ - case '\014': return 1502; /* Ctrl-L */ - case '\016': return 1005; /* Ctrl-N ==> Down arrow */ - case '\020': return 1004; /* Ctrl-P ==> Up arrow */ - case '\031': return 1501; /* Ctrl-Y */ - default: return 2000; - } - } - if (nav_arrow) { - /* Translate keymatches to macro codes */ - if (keymatch>=1 && keymatch<=1010) - keymatch+=FUN_KEY_END-1; - } - return keymatch+1000; -} - -/* - 1000= backspace - 1001= delete - 1002= left - 1003= right - 1004= up - 1005= down - 1006= home - 1007= end - 1008= page up - 1009= page down - 101n= Function key F. (F0==F10) - 1020,1021: F11,F12 (?) - - 1500= ^K - 1501= ^Y - 1502= ^L - 2000= unknown control character -*/ - - - -/*---------------------------------------------------------------------*/ -/* Functions for the Built-In Line Editor */ -/*---------------------------------------------------------------------*/ - -void agt_putc(char c) -{ - fix_loc(); /* Fixup if returning from being suspended */ - printf("%c",c); - curr_x+=1; -} - - -static int base_x,base_y; /* Base X value of first character of input */ - -/* This assumes the cursor is always positioned on the string - being edited */ -static void update_cursor(int cursor) -{ - curr_x=base_x+cursor; - curr_y=base_y; - while (curr_x>=screen_width) { - curr_x-=screen_width; - curr_y++; - } - gotoxy(curr_x,curr_y); -} - -static rbool save_accum_text=0; -static rbool old_yheight=0; - -static void update_line(int cursor,char *buff) -{ - int yval, yheight, xpos, i; - - yheight=(base_x+strlen(buff)+screen_width-1)/screen_width; /* Round up */ - gotoxy(screen_width-1,screen_height-1); - while (base_y+yheight>screen_height && base_y>1) { - base_y--; - save_accum_text=1; - agt_newline(); - save_accum_text=0; - } - for(yval=yheight;yval0) { /* One key */ - if (state==1) { - agt_putc(key); - } - buff[0]=key; buff[1]=0; - buffleng=1; - break; - } - -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - if (key=='\n') { - update_cursor(buffleng); - break; - } - /* add character to buffer */ - buffleng++; - if (buffleng+1>buffspace) buffspace+=20; - buff=rrealloc(buff,buffspace); - for(i=buffleng;i>cursor;i--) - buff[i]=buff[i-1]; - buff[cursor++]=key; - update_line(cursor,buff); - } - else switch(key-1000) - { /* Special key */ - - - case 0: /* Backspace */ - if (!editmode || cursor==0) break; - cursor--; - /* Fall through... */ - - - case 1: /* Delete */ - if (!editmode || buffleng==cursor) break; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - for(i=cursor;i0) - update_cursor(--cursor); - break; - - - case 3: /* Right arrow */ - if (editmode && cursor=histcount) { - /* Reached bottom: restore original line */ - curr_hist=histcount; - buff=savebuff; - savebuff=NULL; - } else - buff=hist[curr_hist]; - buffleng=strlen(buff); - cursor=0; - redisplay_line(buff); - break; -#endif - - case 6: /* Home */ - if (!editmode) break; - cursor=0; - update_cursor(cursor); - break; - - case 7: /* End */ - if (!editmode) break; - cursor=buffleng; - update_cursor(cursor); - break; - - case 8: /* Page up : Scroll back */ - case 9: /* Page down */ - break; - - - case 500: /* Ctrl-K: Delete to EOL */ - if (!editmode) break; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - rfree(yank_text); - yank_text=rstrdup(buff+cursor); - buffleng=cursor; - buff[buffleng]=0; - update_line(cursor,buff); - break; - - - case 501: /* Ctrl-Y: Yank */ - if (!editmode) break; - { - int txtleng; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - if (yank_text==NULL) - txtleng=0; - else - txtleng=strlen(yank_text); - buffleng+=txtleng; - while(buffleng+1>buffspace) buffspace+=20; - buff=rrealloc(buff,buffspace); - for(i=buffleng;i>=cursor+txtleng;i--) - buff[i]=buff[i-txtleng]; - for(i=0;i */ - default: - if (key-1000LAST_FUN_KEY) - break; - - if (!editmode) break; - { - int txtleng; -#ifdef ENABLE_HIST - if (savebuff!=NULL) { - rfree(savebuff); - buff=rstrdup(buff); - buffspace=buffleng+1; - } -#endif - txtleng=strlen(fkey_text[key-1010]); - if (fkey_text[key-1010][txtleng-1]=='\n') { - /* Newlines should only appear at the end; they indicate - that this function key should cause the line to be entered. */ - txtleng--; - exitflag=1; /* Finish entering this line */ - } - buffleng+=txtleng; - while(buffleng+1>buffspace) buffspace+=20; - buff=rrealloc(buff,buffspace); - for(i=buffleng;i>=cursor+txtleng;i--) - buff[i]=buff[i-txtleng]; - for(i=0;i10) { - printf("Read error on input\n"); - exit(EXIT_FAILURE); - } - s[0]=0; - clearerr(stdin); - } else input_error=0; /* Reset counter */ -#endif - -#ifdef TEST_NONL - { - char *t; - for(t=s+strlen(s)-1;(t>s) && (*t=='\n');t--); - if (*t!=0 || t=screen_width) { - curr_x-=screen_width; - set_new_line(); - } - set_new_line(); -#endif - - scroll_count=0; - return s; -} - - - - -char agt_getkey(rbool echo_char) -/* Reads a character and returns it */ -/* If echo_char=1, echo character. If 0, don't */ -{ - char c; -#ifdef USE_EDITLINE - char *s; -#endif - - print_statline(); - scroll_count=0; - -#ifdef USE_EDITLINE - s=line_edit(echo_char?1:2); - c=s[0]; - if (echo_char==1) { - script_out(s); - agt_newline(); - } - rfree(s); -#else - set_term_noncanon(); - read(STDIN_FILENO,&c,1); /* Actually read in the character */ - set_term_normal(); - if (echo_char) { - char cstr[2]; - - cstr[0]=c;cstr[1]=0; - agt_puts(cstr); - agt_newline(); - } -#endif - - scroll_count=0; - if (!save_accum_text) { - acc_ptr=0;accum_text[0]=0; - } - return c; -} - - - - -/*---------------------------------------------------------------------*/ -/* Printing the Status Line */ -/*---------------------------------------------------------------------*/ - -static void print_compass(void) -{ - int cwidth, i; - - if (status_width< 9+4*12) return; - - printf("\n EXITS: ");cwidth=9; - for(i=0;i<12;i++) - if (compass_rose & (1<=screen_height-(have_compass? 3 : 2) ) - agt_more(); /* Print out MORE message */ - fix_loc(); /* Fixup if returning from being suspended */ - } -} - - -void agt_puts(const char *s) -/* This routine assumes that s is not wider than the screen */ -{ - script_out(s); - curr_x+=strlen(s); - add_accum_text(s); - - if (BATCH_MODE) return; - - fix_loc(); /* Fixup if returning from being suspended */ - printf("%s",s); -} - - -void agt_clrscr(void) -{ - cont_flag=0;winsize_flag=0; - scroll_count=0; - curr_x=0; - if (have_compass) curr_y=2; - else curr_y=1; - script_out("\n\n\n\n\n"); - - if (BATCH_MODE) return; - - tputs(term_cmd[TC_CLRSCR],screen_height,putchar); - printf("\n"); /* To make space for status line */ - if (have_compass) printf("\n"); -} - - - - -/*---------------------------------------------------------------------*/ -/* Box Printing Routines */ -/*---------------------------------------------------------------------*/ - -static unsigned long boxflags; -static int box_startx; /* Starting x of box */ -static int box_width; -static int delta_scroll; /* Amount we are adding to vertical scroll - with the box */ - -static void boxrule(void) -/* Draw line at top or bottom of box */ -{ - int i; - - if (RVID_BOX) agt_puts(" "); - else agt_puts("+-"); - - for(i=0;i=screen_height) curr_y=screen_height-1; - gotoxy(curr_x,curr_y); - - script_out("\n"); - for(i=0;iscreen_height) /* Make room for credits */ - curr_y=screen_height-height-8; - if (curr_y<0) curr_y=0; - delta_scroll=0; - scroll_count=0; - } else { /* Compute vertical position of non-title box */ - curr_y=curr_y-height; - if (curr_y<1) { - delta_scroll=1-curr_y; - curr_y=1; - } else delta_scroll=0; - } - - curr_x=box_startx; - gotoxy(curr_x,curr_y); - - script_out("\n"); - for(i=0;i12) err=1; - if (n==10) n=0; - if (n>10) n--; - } - if (err) { - writeln("Unrecognized KEY name."); - return; - } - - leng=0; - for(i=0;i=0 && s[i]=='+') { - s[i]='\n'; - s[i+1]=0; - } - if (keys_defined & (1<=2 && setflag) { - for(i=1;i=2) { - set_fkey(optstr[1],optstr+2,optnum-2); - return 1; - } - if (opt("HISTORY")) { - histmax=strtol(optstr[1],NULL,10); - if (histmax<0) histmax=0; - return 1; - } - if (opt("LOWER_FILE")) { - lower_file=setflag; - return 1; - } - if (opt("NAVARROW")) { - nav_arrow=setflag; - return 1; - } - if (opt("VIEWER")) { - viewer_name=rstrdup(optstr[1]); - return 1; - } - if (opt("PATH") && optnum>=2) { - if (gamepath!=NULL) return 1; /* First setting wins */ - gamepath=rmalloc((optnum+1)*sizeof(char*)); /* optnum-1+2 */ - gamepath[0]=""; /* ==> The current directory */ - for(i=1;ipath,name,ext); - f=fopen(fname,"rb"); - rfree(fname); - return f; -} - - -/*------------------------------------------------------------------*/ -/* FONT Routines */ -/*------------------------------------------------------------------*/ - -static char *save_font; -static int save_font_height; - -static int set_font(char *fontdef, int font_height) -{ -#ifdef PIO_FONTX - struct consolefontdesc fontdesc; - - fontdesc.charcount=256; - fontdesc.charheight=font_height; - fontdesc.chardata=fontdef; - - return ioctl(STDOUT_FILENO,PIO_FONTX,&fontdesc); -#else -#ifdef PIO_FONT - return ioctl(STDOUT_FILENO,PIO_FONT,fontdef); -#endif -#endif -} - - -static int getfont(char *fontdef, int *font_height) -{ - int rval=-1; - -#ifdef GIO_FONTX - struct consolefontdesc fontdesc; - - fontdesc.chardata=fontdef; - rval=ioctl(STDOUT_FILENO,GIO_FONTX,&fontdesc); - *font_height=fontdesc.charheight; -#else -#ifdef GIO_FONT - rval=ioctl(STDOUT_FILENO,GIO_FONT,save_font); /* Get current font */ - *font_height=16; -#endif -#endif - return rval; -} - - -static void save_old_font(void) -{ - if (BATCH_MODE) return; - - /* Save existing font */ - save_font=rmalloc(256*32); - if (getfont(save_font,&save_font_height)) - /* Failed... issue warning? */ - rfree(save_font); -} - - -static void restore_font(void) -{ - if (BATCH_MODE) return; - if (save_font==NULL || set_font(save_font,save_font_height)) { - /* Couldn't restore save_font */ -#ifdef PIO_FONTRESET - ioctl(STDOUT_FILENO,PIO_FONTRESET); -#endif - } -} - - - -void fontcmd(int cmd,int font) -/* 0=Load font, name is fontlist[font] - 1=Restore original font - 2=Set startup font. (.FNT) -*/ -{ - FILE *fontfile; - char *buff, *fontname, *s; - int count, height; - - if (!font_enable) return; - /* (This should be off by default since it changes the fonts - on *all* of the VC's) */ - - if (cmd==2) - save_old_font(); - - if (cmd==0 || cmd==2) { - if (cmd==0) { - fontname=fontlist[font]; - if (lower_file) - for(s=fontname;*s!=0;s++) *s=tolower(*s); - /* Lowercase the font names as we use them */ - } - else fontname=game_fc->gamename; - - fontfile=linopen(fontname,pFNT); - if (fontfile==NULL) return; - buff=rmalloc(256*32); - memset(buff,0,256*32); - fseek(fontfile,0,SEEK_END); - height=ftell(fontfile); - if (height%256!=0) { - /* Error message */ - return; - } - height=height/256; - - fseek(fontfile,0,SEEK_SET); - for(count=0;count<256;count++) - if (fread(buff+count*32,height,1,fontfile)!=1) break; - if (count!=256) { - fclose(fontfile); - rfree(buff); - return; - } - fclose(fontfile); - if (!BATCH_MODE) - if (set_font(buff,height)) { - /* Print error message */ - } - rfree(buff); - return; - } else if (cmd==1) - restore_font(); -} - - - -/*------------------------------------------------------------------*/ -/* Graphics Routines */ -/*------------------------------------------------------------------*/ - -#define GFX_EXT_CNT 17 -/* The extension indicates the video mode the picture was intended - to be viewed in. */ -static char *gfxext[GFX_EXT_CNT]={".pcx", - ".p06", /* 640x200x2 */ - ".p40",".p41",".p42",".p43", /* 320x200x4 */ - ".p13", /* 320x200x16 */ - ".p19", /* 320x200x256 */ - ".p14",".p16", /* 640x200x16, 640x350x16 */ - ".p18", /* 640x480x16 */ - ".gif",".png",".bmp",".jpg", - ".fli",".flc"}; - - -void pictcmd(int cmd,int pict) -/* 1=show global picture, name is pictlist[pict] - 2=show room picture, name is pixlist[pict] - 3=show startup picture .P.. - */ -{ - char *base, *cmdstr; - int gmode; - FILE *pcxfile; - - if (viewer_name==NULL) return; - - if (cmd==1) base=pictlist[pict]; - else if (cmd==2) base=pixlist[pict]; - else if (cmd==3) base=game_fc->gamename; - else return; - - /* Find graphics file; determine mode from extension... */ - for(gmode=GFX_EXT_CNT-1;gmode>=0;gmode--) { - pcxfile=linopen(base,gfxext[gmode]); - if (pcxfile!=NULL) break; - } - if (pcxfile==NULL) return; - fclose(pcxfile); - - base=assemble_filename(hold_fc->path,base,gfxext[gmode]); - - cmdstr=rmalloc(strlen(base)+strlen(viewer_name)+40); - sprintf(cmdstr,"%s %s >/dev/null",viewer_name,base); - - if (!BATCH_MODE) - system(cmdstr); /* Don't bother to check return status since - there's nothing we could do anyhow */ - - rfree(cmdstr); - rfree(base); - - return; -} - - - -/*------------------------------------------------------------------*/ -/* Sound Routines */ -/*------------------------------------------------------------------*/ - -#if 0 -static rbool repeat_song=0; -static rbool suspend_song=0; -#endif - -int musiccmd(int cmd,int song) -/* For cmd=1 or 2, the name of the song is songlist[song] - The other commands don't take an additional argument. - 1=play song - 2=repeat song - 3=end repeat - 4=end song - 5=suspend song - 6=resume song - 7=clean-up - 8=turn sound on - 9=turn sound off - -1=Is a song playing? (0=false, -1=true) - -2=Is the sound on? (0=false, -1=true) -*/ -{ - if (cmd==8) { - sound_on=1; - return 0; - } - if (cmd==9) {sound_on=0;return 0;} - if (cmd==-2) return sound_on; -#if 0 - if (cmd==3) {repeat_song=0;return 0;} - if (cmd==7) { - /* Stop song */ - /* Do clean-up */ - return 0; - } - if (cmd==2) repeat_song=1; - if (cmd==1 || cmd==2) { - /* Start song playing */ - } - if (cmd==4) { - /* Stop song */ - } - if (cmd==5) { - /* Suspend song */ - } - if (cmd==6) { - /* Resume song */ - } -#endif - return 0; -} - -#endif /* REPLACE_BNW */ diff --git a/app/src/main/jni/terps/agility/parser.c b/app/src/main/jni/terps/agility/parser.c deleted file mode 100644 index 9abc206..0000000 --- a/app/src/main/jni/terps/agility/parser.c +++ /dev/null @@ -1,1589 +0,0 @@ -/* parser.c-- the parser and the menu manager. */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy: the (Mostly) */ -/* Universal AGT Interpreter */ - -/* - - This is probably the ugliest and least readable of all of the - source files. The parser isn't really that complex in principle, - but it has to deal with a lot of of special cases and also be - downward-compatible with the original parsers (which sometimes did - strange things) which adds a lot of additional code. The noun parsing - code is particularly convoluted. - - Also, there are a fair number of global variables in this module - that are really local variables at heart but ended up global - because they were needed in too many different places and I didn't - want to complicate things even more by having to explicitly pass - them all up and down through the parsing routines. (One of those - times it would be convenient to have the ability to nest procedures - and functions like Pascal.) - -*/ - - -#include -#include - -#include "agility.h" -#include "interp.h" - - -/* These store the previous turn's values for use in disambiguation and - implementing OOPS */ -/* parse_ip saves the ip after parsing, ip_back saves it before. */ -word input_back[MAXINPUT]; -words in_text_back[MAXINPUT]; -int ip_back, parse_ip; - -/* The following are global only for rfree() purposes and - in order to maintain state for disambiguation */ -static int vnum; /* Verb number from synonym scan */ - -/* Pointers to negative-terminated arrays of possible nouns */ -static parse_rec *lactor=NULL, *lobj=NULL, *lnoun=NULL; - -static int ambig_flag=0; - /* Was last input ambiguous? (so player could be entering - disambiguation info?) 1=ambig actor, 2=ambig noun, - 3=ambig obj */ - - -/* Empty ALL error messages, for those verbs that have their own */ -int all_err_msg[]={73,83,113,103, /* open, close, lock, unlock: 15 - 18 */ - 239,239,239,239, /* 19 - 22 */ - 123,125}; /* eat, drink: 23 - 24 */ - - - -/*-------------------------------------------------------------------*/ -/* DEBUGGING OUTPUT FUNCTIONS & MISC UTILITIES */ -/*-------------------------------------------------------------------*/ - -/* This routine frees the space used by the parsing data structures */ -static void freeall(void) -{ - rfree(lnoun);rfree(lobj); - lnoun=lobj=NULL; -} - - -/* Print out parse error message and abort the parse */ -static int parseerr(int msgid,char *s,int n) -{ - if (n>=0) - gen_sysmsg(msgid,s,MSG_PARSE,in_text[n]); - else - gen_sysmsg(msgid,s,MSG_PARSE,""); - freeall(); - ep=n; - ip=-1; - return -1; -} - - -/* Print out noun list; used for debugging the parser */ -static void print_nlist(parse_rec *n) -{ - char *s; - int c; - char buff[100]; - - if (n->info==D_END) - writestr("----"); - if (n->info==D_ALL) { - writestr("ALL ");n++;} - for(c=0;n->info!=D_END && c<20;n++,c++) - if (n->info==D_AND) writestr(" AND "); - else if (n->info==D_NUM) { /* Number entered */ - sprintf(buff,"#%ld(%d); ",n->num,n->obj); - writestr(buff); - } else if (n->obj<0) { - writestr(dict[-(n->obj)]); - sprintf(buff,"(%d); ",n->obj); - writestr(buff); - } else { - s=objname(n->obj);writestr(s);rfree(s); - sprintf(buff,"(%d) ['%s %s']; ",n->obj,dict[n->adj],dict[n->noun]); - writestr(buff); - } - if (n->info!=D_END) writestr("///"); - writeln(""); -} - -/* Output the parser's analysis of the current input line; used - for debugging */ -static int parse_out(parse_rec *lactor,int vb,parse_rec *lnoun,int prep, - parse_rec *lobj) -{ - writeln("ANALYSIS:"); - writestr("Actor: ");print_nlist(lactor); - writestr("Verb:");writeln(dict[ syntbl[auxsyn[vb]] ]); - writestr("DObj: ");print_nlist(lnoun); - writestr("Prep: "); - if (prep!=0) writeln(dict[prep]); else writeln("---"); - writestr("IObj: ");print_nlist(lobj); - return 0; -} - - -static void save_input(void) -{ - int i; - - for(i=0;input[i]!=-1 && i --> */ - w=input[ip+1]; - if (w!=0) i=verb_builtin(w); - else i=0; - if (i!=0) { - ip++; - return w; - } - } - - for(i=0;iGET, for example) - _unless_ there is an author-defined synonym. (The original AGT - didn't have this 'unless'.) - ii) Check room-synonyms - iii) ID the verb based first on game-specific synonyms and then - falling back to the built-in ones. - (AGT gave the built-in ones higher priority than the game-specific - ones, but this causes problems and is generally a bad idea.) - */ - -static int id_verb(void) -/* Identify verb at ip=i ; return verb id if found, 0 otherwise */ -{ - word w; - int j, canon_word, tmp; - - w=comb_verb(); /* Combine 2-word verbs */ - if (w==0) return 0; - - /* Pre-Canonization of w: see if w has any built-in synonyms */ - canon_word=verb_builtin(w); - if (canon_word!=0) { - if (aver=first_noun && obj<=maxnoun) - { - obj=obj-first_noun; - if (w==noun[obj].name) return 3; - if (noun[obj].has_syns) - for(i=noun[obj].syns;syntbl[i]!=0;i++) - if (w==syntbl[i]) return (PURE_SYN ? 3 : 2); - if (w==noun[obj].adj) return 1; - return 0; - } - if (obj>=first_creat && obj<=maxcreat) - { - obj=obj-first_creat; - if (w==creature[obj].name) return 3; - if (creature[obj].has_syns) - for(i=creature[obj].syns;syntbl[i]!=0;i++) - if (w==syntbl[i]) return (PURE_SYN ? 3: 2); - if (w==creature[obj].adj) return 1; - return 0; - } - return 0; /* If the object doesn't exist, can't have synonyms */ -} - - - -/*-------------------------------------------------------------------*/ -/* Noun-list manipulation functions. */ -/*-------------------------------------------------------------------*/ - -static parse_rec *new_list(void) -{ - parse_rec *list; - - list=rmalloc(sizeof(parse_rec)); - list[0].obj=0; - list[0].num=0; - list[0].adj=list[0].noun=0; - list[0].info=D_END; - return list; -} - -static parse_rec *add_w_rec(parse_rec *pold,int obj0,long num0,int info0, - word adj0, word noun0) -{ - parse_rec *pnew; - int n; - - for(n=0;pold[n].info!=D_END;n++); - pnew=rrealloc(pold,(n+2)*sizeof(parse_rec)); - pnew[n].obj=obj0; - pnew[n].num=num0; - pnew[n].info=info0; - pnew[n].adj=adj0; - pnew[n].noun=noun0; - pnew[n+1].obj=0; - pnew[n+1].info=D_END; - return pnew; -} - -static parse_rec *add_rec(parse_rec *old,int obj0,long num0,int info0) -{ - word w; - - if (obj0<0) w=-obj0; /* The NOUN field of literal words will just be - that word */ - else w=0; - return add_w_rec(old,obj0,num0,info0,0,w); -} - - -static parse_rec *kill_rec(parse_rec *old,int index) -/* Remove record old[index] */ -{ - parse_rec *pnew; - int i; - - for(i=index;old[i].info!=D_END;i++) { - old[i].obj=old[i+1].obj; - old[i].num=old[i+1].num; - old[i].noun=old[i+1].noun; - old[i].adj=old[i+1].adj; - old[i].info=old[i+1].info; - old[i].score=old[i+1].score; - } - pnew=rrealloc(old,i*sizeof(parse_rec)); /* Shrink it by one */ - return pnew; -} - -static parse_rec *concat_list(parse_rec *dest,parse_rec *src) -{ - int i,j; - - for(i=0;dest[i].info!=D_END;i++); /* Put i at end of first list */ - for(j=0;src[j].info!=D_END;j++); /* j marks end of the second list */ - dest=rrealloc(dest,sizeof(parse_rec)*(i+j+1)); - memcpy(dest+i,src,(j+1)*sizeof(parse_rec)); - return dest; -} - -static parse_rec *purge_list(parse_rec *list) -/* It should be possible to make this more efficiant */ -{ - int i; - - for(i=0;list[i].info!=D_END;) - if ( (list[i].info & D_MARK) != 0) - list=kill_rec(list,i); - else i++; /* (Note: we only increment i if we _don't_ kill) */ - return list; -} - -static void clean_list(parse_rec *list) -{ - for(;list->info!=D_END;list++) - list->info&=~D_MARK; /* Clear mark */ -} - - -static parse_rec *copy_list(parse_rec *list) -{ - parse_rec *cpy; - int i; - - cpy=new_list(); - for(i=0;list[i].info!=D_END;i++); - cpy=rmalloc(sizeof(parse_rec)*(i+1)); - memcpy(cpy,list,(i+1)*sizeof(parse_rec)); - return cpy; -} - - - -/* Among other things, this is used to add disambiguation information */ -static int scan_rec(int item,int num,parse_rec *list) -{ - int i; - - for(i=0;list[i].info!=D_END && list[i].info!=D_AND;i++) - if (list[i].obj==item && list[i].num==num) - return i; - return -1; -} - -static rbool scan_andrec(int item,parse_rec *list) -{ - for(;list->info!=D_END;list++) - if (list->obj==item && list->info!=D_AND - && list->info!=D_ALL) return 1; - return 0; -} - -static rbool multinoun(parse_rec *list) -/* Determines if LIST refers to a multiple object */ -{ - if (list->info==D_ALL) return 1; - for(;list->info!=D_END;list++) - if (list->info==D_AND) return 1; - return 0; -} - -/* This updates the adj and noun fields of a record and also - updates the disambiguation priority */ -/* We are already either D_ADJ or D_SYN; this just handles - possible promotion */ -static void add_words_to_rec(parse_rec *nrec, word w, int tmp) -{ - word w2; - - if (tmp==2 || tmp==3) { - w2=nrec->noun; - nrec->noun=w; - w=w2; - } - if (nrec->adj==0) - nrec->adj=w; - if (tmp==2) nrec->info=D_SYN; - else if (tmp==3) nrec->info=D_NOUN; -} - -/* This updates nrec with the information in newobj; this routine - is called while adding disambiguation information; newobj is from - what the player just typed in to clarify the ambiguity */ -void update_rec_words(parse_rec *nrec, parse_rec *newobj) -{ - int tmp; - - if (nrec->adj==0) nrec->adj=newobj->adj; - if (newobj->info==D_ADJ) tmp=1; - else if (newobj->info==D_SYN) tmp=2; - else if (newobj->info==D_NOUN) tmp=3; - else return; - add_words_to_rec(nrec,newobj->noun,tmp); -} - - -static rbool ident_objrec(parse_rec *p1, parse_rec *p2) -{ - word noun1,adj1, noun2, adj2; - - if (p1->obj==p2->obj) return 1; - if (p1->obj<=0 || p2->obj<=0) return 0; - if (tnoun(p1->obj)) { - noun1=noun[p1->obj-first_noun].name; - adj1=noun[p1->obj-first_noun].adj; - } else if (tcreat(p1->obj)) { - noun1=creature[p1->obj-first_creat].name; - adj1=creature[p1->obj-first_creat].adj; - } else return 0; - if (tnoun(p2->obj)) { - noun2=noun[p2->obj-first_noun].name; - adj2=noun[p2->obj-first_noun].adj; - } else if (tcreat(p2->obj)) { - noun2=creature[p2->obj-first_creat].name; - adj2=creature[p2->obj-first_creat].adj; - } else return 0; - return (noun1==noun2 && adj1==adj2); -} - -/*-------------------------------------------------------------------*/ -/* Disambiguation and ALL expansion routines */ -/*-------------------------------------------------------------------*/ - -/* Eliminate non-creatures and non-present creatures from list. */ -/* Very similar to disambig below, but simpler. */ -static parse_rec *fix_actor(parse_rec *alist) -{ - int i, cnt; - - assert(alist!=NULL); - if (alist[0].info==D_ALL) { /* ALL?! */ - rfree(alist); - return new_list();} - - /* Start by eliminating non-creatures */ - cnt=0; - for(i=0;alist[i].info!=D_END;i++) - if ( (alist[i].objmaxcreat) - && alist[i].obj!=-ext_code[weverybody]) { - if (alist[i].info!=D_AND) - alist[i].info|=D_MARK; - } else cnt++; - alist=purge_list(alist); - if (cnt<=1) return alist; - - /* Now eliminate those not present */ - cnt=0; - for(i=0;alist[i].info!=D_END;i++) - if (!genvisible(&alist[i])) { - if (alist[i].info!=D_AND) - alist[i].info|=D_MARK; - } else cnt++; - - if (cnt==0) alist[0].info&=~D_MARK; - - return purge_list(alist); -} - - -/* Convert disambig list to all list, moving things up. */ -static parse_rec *convert_to_all(parse_rec *list, int *ofsref) -{ - int i; - int cnt; - - for(i=*ofsref;list[i].info!=D_AND && list[i].info!=D_END;i++); - cnt=i-*ofsref; /* Number of objects. We will add cnt-1 ANDs */ - - while(list[i].info!=D_END) i++; - list=rrealloc(list,(i+cnt)*sizeof(parse_rec)); - memmove(list+*ofsref+2*cnt-1,list+*ofsref+cnt, - (i+1-cnt-*ofsref)*sizeof(parse_rec)); - for(i=cnt-1;i>=0;i--) { - int k; - list[*ofsref+2*i]=list[*ofsref+i]; - if (i==0) break; - k=*ofsref+2*i-1; - list[k].obj=0; - list[k].num=0; - list[k].adj=list[k].noun=0; - list[k].info=D_AND; - } - /* *ofsref+=2*cnt-1; */ - return list; -} - - - -static parse_rec *add_disambig_info(parse_rec *ilist, int ofs, - parse_rec *truenoun) - /* Basically, try to find interesection of tmp and truenoun, - or failing that, between ilist and truenoun */ - /* truenoun is what the player just typed in to resolve - the ambiguity */ -{ - int i, n; - - for(i=ofs;ilist[i].info!=D_AND && ilist[i].info!=D_END;i++) { - if (truenoun[0].info==D_EITHER) { - /* Mark all but the first for deletion */ - if (i>ofs) ilist[i].info|=D_MARK; - } else { - n=scan_rec(ilist[i].obj,ilist[i].num,truenoun); - if (n==-1) - ilist[i].info|=D_MARK; - else /* Add any new information to the words */ - update_rec_words(&ilist[i],&truenoun[n]); - } - } - ilist=purge_list(ilist); - truenoun[0].obj=0; - truenoun[0].num=0; - truenoun[0].info=D_END; /* Truenoun no longer useful */ - return ilist; -} - -static int max_disambig_score; - -static int score_disambig(parse_rec *rec, int ambig_type) -/* This is just a wrapper for check_obj (defined in runverb.c) */ -/* ambig_type=1 for actor, 2 for noun, 3 for object */ -/* We can assume that the earlier bits have already been disambiguated */ -/* Parse of current command in lactor, vnum, lnoun, prep, and lobj */ -{ - if (ambig_type==1) /* ACTOR */ - return DISAMBIG_SUCC; - else if (ambig_type==2) /* NOUN */ - return check_obj(lactor,vnum,rec,prep,NULL); - else if (ambig_type==3) /* IOBJ */ - return check_obj(lactor,vnum,lnoun,prep,rec); - else fatal("Invalid ambig_type!"); - return 0; -} - - -/* This routine does all expansion: it returns a list of ALL objects in the - current context (lactor, vnum, , prep, lobj) */ -/* lnoun is assumed to be a list of exceptions, which needs to be freed - at the end. (i.e. we want to expand to ALL EXCEPT ) */ -static parse_rec *expand_all(parse_rec *lnoun) -{ - parse_rec *list; - int i, j; - rbool prev_obj; /* Is there a previous object on the list? */ - rbool kill_obj; /* Don't put current object on ALL list after all */ - parse_rec temp_obj; /* Used to pass object info to disambiguation routine */ - - if (debug_parse) { - writestr("ALL BUT:"); - print_nlist(lnoun); - } - tmpobj(&temp_obj); - nounloop(i) - noun[i].scratch=0; - creatloop(i) - creature[i].scratch=0; - objloop(i) - if ( ( (verbflag[vnum]&VERB_GLOBAL)!=0 || visible(i) ) - && (lnoun==NULL || !scan_andrec(i,lnoun))) { - temp_obj.obj=i; - if (score_disambig(&temp_obj,2)>=500) { - if (tnoun(i)) noun[i-first_noun].scratch=1; - else if (tcreat(i)) creature[i-first_creat].scratch=1; - else writeln("INTERNAL ERROR: Invalid object type in expand_all()."); - } - } - - /* The following ensures that if an object and it's container - are both selected, only the container will actually make it - onto the list.*/ - list=new_list(); - prev_obj=0; - objloop(i) - if (it_scratch(i)) { - kill_obj=0; - for(j=it_loc(i);tnoun(j)||tcreat(j);j=it_loc(j)) - if (it_scratch(j)) {kill_obj=1;break;} - if (kill_obj) continue; - /* Now actually add object to list. */ - if (prev_obj) list=add_rec(list,0,0,D_AND); - list=add_rec(list,i,0,D_SYN); - prev_obj=1; - } - - if (debug_parse) { - writestr("ALL==>"); - print_nlist(list); - } - rfree(lnoun); - return list; -} - - - -/* disambig check checks for the various things that can eliminate a noun - from the list. The higher dlev is, the more things that are bad */ -/* Returns 1 if we should keep it, 0 if we should kill it */ -/* The elimination order is based on AGT: - 0-Eliminate adjective matches if PURE_NOUN is set and - out-of-scope adjectives that are not at the head of the list. - 1-Eliminate adj matches if the adjective is out-of-scope. - 2-eliminate SCENE and DOOR (D_INTERN) - 3-eliminate out-of-scope nouns that are not at the head of the list - 4-eliminate out-of-scope nouns - 5-eliminate numbers that don't have associated dictionary words - 6-eliminate adj only matches (i.e. noun-free) [only if PURE_ADJ] - 7-eliminate pronouns (D_PRO) - -eliminate ALL (D_ALL) - -eliminate numbers - (Never eliminated: FLAG,GLOBAL,PIX,SYN,NOUN) -*/ - -#define MAX_DSCHEME 3 -#define MAX_DLEV 2 -/* ambig_type=1 for actor, 2 for noun, 3 for object */ -/* We can assume that the earlier bits have already been disambiguated */ -/* Parse of current command in lactor, vnum, lnoun, prep, and lobj */ -/* pick_one is used to select the first noun in the case that all of - them get eliminated during visibility testing (if none of the nouns - are visible, we don't want to ask disambiguation questions) */ - -static rbool disambig_check(parse_rec *rec, int dsch, int dlev, - int ambig_type, rbool pick_one) -{ - switch(dsch) { - case 0: - switch(dlev) { /* Syntactic checks: pre-scope */ - case 0:return (!PURE_ADJ || rec->info!=D_ADJ); - case 1:return (rec->info!=D_INTERN); /* Elim SCENE and DOOR */ - case 2: return (rec->info!=D_NUM || rec->obj!=0); /* Eliminate numbers w/o - corrosponding word matches */ - default:return 0; - } - case 1: - switch(dlev) { /* Scope checks */ - case 0: - /* Just compute the scores, but don't eliminate anything yet */ - /* if PURE_DISAMBIG, no intel dismbig */ - if (PURE_DISAMBIG || rec->info==D_NUM) - rec->score=DISAMBIG_SUCC; - else rec->score=score_disambig(rec,ambig_type); - if (rec->score>=max_disambig_score) - max_disambig_score=rec->score; - return 1; - case 1: return (rec->score==max_disambig_score); - case 2: - return (rec->info==D_NUM - || ( (verbflag[vnum]&VERB_GLOBAL)!=0 && rec->score>=500 ) - || ( tnoun(rec->obj) && noun[rec->obj-first_noun].scope ) - || ( tcreat(rec->obj) && creature[rec->obj-first_creat].scope )); - default:return 1; - } - case 2: - switch(dlev) {/* Syntax, take 2 */ - case 0: /* Reserved for alternative adjective checking */ - return 1; - /* Kill internal matches */ - case 1:return (rec->info!=D_PRO && rec->info!=D_ALL && - rec->info!=D_INTERN && rec->info!=D_NUM); - default: return 0; - } - case 3: return pick_one; - default: return 0; - } -} - - -/* disambig_a_noun does disambiguation for a single AND-terminated block */ -/* *list* contains the list of possible objects, */ -/* *ofs* is our starting offset within the list (since with ANDs we */ -/* may not be starting at list[0]) */ - -static parse_rec *disambig_a_noun(parse_rec *list, int ofs, int ambig_type) -/* ambig_type=1 for actor, 2 for noun, 3 for object */ -/* We can assume that the earlier bits have already been disambiguated */ -/* Parse of current command in lactor, vnum, lnoun, prep, and lobj */ -{ - int i,cnt; /* cnt keeps track of how many nouns we've let through */ - int dsch; /* Dismabiguation scheme; we run through these in turn, - pushing dlev as high as possible for each scheme */ - int dlev; /* Disambiguation level: how picky do we want to be? - We keep raising this until we get a unique choice - or until we reach MAX_DLEV and have to give up */ - rbool one_in_scope; /* True if at least one noun is visible; if no nouns - are visible then we never ask for disambiguation - from the player (to avoid giving things away) but - just take the first one. */ - - cnt=2; /* Arbitrary number > 1 */ - one_in_scope=0; - max_disambig_score=-1000; /* Nothing built in returns anything lower than 0, - but some game author might come up with a - clever application of negative scores */ - for(dsch=0;dsch<=MAX_DSCHEME;dsch++) - for(dlev=0;dlev<=MAX_DLEV;dlev++) { - if (DEBUG_DISAMBIG) - rprintf("\nDISAMBIG%c%d:%d: ",(dsch==1?'*':' '),dsch,dlev); - cnt=0; - for(i=ofs;list[i].info!=D_END && list[i].info!=D_AND;i++) - if ( disambig_check( &list[i], dsch, dlev, ambig_type, - one_in_scope || (i==ofs)) - ) - { - cnt++; - if (DEBUG_DISAMBIG) - rprintf("+%d ",list[i].obj); - } else { - if (DEBUG_DISAMBIG) - rprintf("-%d ",list[i].obj); - list[i].info|=D_MARK; /* Mark it for deletion */ - } - if (cnt!=0) { - list=purge_list(list); /* Delete marked items */ - if (cnt==1) return list; - if (dsch==1 && dlev==MAX_DLEV) - one_in_scope=1; - } else { - clean_list(list); /* Remove marks; we're not purging */ - break; - } - } - /* Check to make sure we don't have a list of multiple identical items */ - for(i=ofs;list[i].info!=D_END && list[i].info!=D_AND;i++) { - if (!ident_objrec(&list[i],&list[ofs])) break; - list[i].info|=D_MARK; - } - if (list[i].info==D_END || list[i].info==D_AND) { - /* If all of the items are identical, just pick the first */ - if (one_in_scope) writeln("(Picking one at random)"); - list[0].info&=~D_MARK; - list=purge_list(list); - } else clean_list(list); - if (DEBUG_DISAMBIG) rprintf("\n"); - return list; -} - - - -/* Note that this routine must be _restartable_, when new input comes in. */ -/* Truenoun is 0 or else the "correct" noun for where disambig first - got stuck. */ -/* Returns the offset at which it got stuck, or -1 if everything - went ok. Return -2 if we eliminate everything */ -/* *tn_ofs* contains the offset where truenoun is supposed to be used */ - -#define list (*ilist) /* in disambig_phrase only */ - - -static int disambig_phrase(parse_rec **ilist,parse_rec *truenoun,int tn_ofs, - int ambig_type) -/* Note that ilist is double dereferenced: this is so we can realloc it */ -/* ambig_type=1 for actor, 2 for noun, 3 for object */ -/* We can assume that the earlier bits have already been disambiguated */ -{ - int ofs, i; - char *s; - - ofs=0; - if (list[0].info==D_END) return -1; /* No nouns, so no ambiguity */ - if (list[0].info==D_ALL) ofs=1; /* might have ALL EXCEPT construction */ -#ifdef OMEGA - return -1; /* No ambiguity over ALL, either */ - /* (at least if it appears as the first element of the list) */ -#endif - - while(list[ofs].info!=D_END) { /* Go through each AND block */ - if (ofs==tn_ofs) { - if (truenoun[0].info==D_ALL) /* Convert to ALL list */ - list=convert_to_all(list,&ofs); - else { - list=add_disambig_info(list,ofs,truenoun); - if ( list[ofs].info==D_END) { /* We have eliminated all matches */ - gen_sysmsg(240,"In that case, I don't know what you mean.", - MSG_PARSE,""); - return -2; - } - } - } - list=disambig_a_noun(list,ofs,ambig_type); - assert(list[ofs].info!=D_END && list[ofs].info!=D_AND); - if (list[ofs+1].info!=D_END && list[ofs+1].info!=D_AND) - /* Disambiguation failed */ - { writestr("Do you mean"); - for(i=ofs;list[i].info!=D_END && list[i].info!=D_AND;i++) { - if (list[i+1].info==D_END || list[i+1].info==D_AND) - if (i>ofs+1) writestr(", or"); - else writestr(" or"); - else if (i>ofs) writestr(","); - writestr(" the "); - if (list[i].info!=D_NUM || list[i].obj!=0) - s=objname(list[i].obj); - else { s=rmalloc(30*sizeof(char)); - sprintf(s,"%ld",list[i].num);} - writestr(s); - rfree(s); - } - writeln("?"); - return ofs;} - /* Skip forward to next AND */ - while((*ilist)[ofs].info!=D_END && (*ilist)[ofs].info!=D_AND) - ofs++; - if ((*ilist)[ofs].info==D_AND) ofs++; - } - return -1; -} - -#undef list - -static int disambig_ofs; /* Offset where disambig failed */ - -/* ambig_flag stores what we were disambiguating the last time this - routine was called: it tells us where we failed so that if the - player enters new disambiguation information, we can figure out where - it should go */ - -static parse_rec *disambig(int ambig_set, parse_rec *list, parse_rec *truenoun) -/* ambig_set = 1 for actor, 2 for noun, 3 for object */ -{ - if (ambig_flag==ambig_set || ambig_flag==0) /* restart where we left off...*/ - { - if (truenoun==NULL || truenoun[0].info==D_END) disambig_ofs=-1; - disambig_ofs=disambig_phrase(&list,truenoun,disambig_ofs,ambig_set); - if (disambig_ofs==-1) ambig_flag=0; /* Success */ - else if (disambig_ofs==-2) ambig_flag=-1; /* Error: elim all choices */ - else ambig_flag=ambig_set; - } - return list; -} - - - - -/*-------------------------------------------------------------------*/ -/* Noun parsing routines */ -/*-------------------------------------------------------------------*/ - - -/* PARSE_A_NOUN(), parses a single noun, leaves ip pointing after it. */ -/* Just be greedy: grab as many of the input words as possible */ -/* Leave ip pointing _after_ last word we get. */ -/* Return list of all possible objects */ -/* Go to some difficullty to make sure "all the kings men" will - not be accidentally parsed as "all" + "the kings men" */ -/* (Yes, yes, I know -- you can't have an AGT object with a name as - complex as 'all the king's men'-- but you could try to simulate it using - synonyms) */ -/* May also want to use more intellegence along the adj--noun distinction */ -/* all_ok indicates whether ALL is acceptable */ - -static parse_rec *parse_a_noun(void) -/* Returns a list of parse_rec's containing the various possible - nouns. */ -{ - parse_rec *nlist; - char *errptr; - int i, tmp, numval, num, oip; - - nlist=new_list(); - oip=ip; /* Save starting input pointer value */ - - if (input[ip]==-1) /* End of input */ - return nlist; - if (input[ip]==0) { /* i.e. tokeniser threw up its hands */ - numval=strtol(in_text[ip],&errptr,10); /* Is it a number? */ - if (errptr==in_text[ip]) /* Nope. */ - return nlist; - if (*errptr!=0) return nlist; /* May want to be less picky */ - nlist=add_rec(nlist,0,numval,D_NUM); - ip++; - return nlist; - } - - /* Basic strategy: try to match nouns. If all matches are of length<=1, - then go looking for flag nouns, global nouns, ALL, DOOR, etc. */ - num=0; - objloop(i) - if ((tmp=noun_syn(input[ip],i))!=0) { - numval=strtol(in_text[ip],&errptr,10); /* Is it a number, too? */ - if (*errptr!=0) numval=0; /* Only accept perfectly formed numbers */ - nlist=add_w_rec(nlist,i,numval, - (tmp==1) ? D_ADJ : (tmp==2 ? D_SYN : D_NOUN), - (tmp==1) ? input[ip] : 0, /* Adjective */ - (tmp==1) ? 0 : input[ip]); /* Noun */ - num++; - } - - /* Now we need to try to match more words and reduce our list. */ - /* Basically, we keep advancing ip until we get no matches at all. */ - /* Note that nouns may only come at the end, so if we find one we know */ - /* we are done. Synonyms and adjectives can come anywhere */ - /* (If PURE_SYN is set, then we won't see any synonyms-- they */ - /* get converted into nouns by noun_syn() */ - /* *num* is used to keep track of how many matches we have so we know */ - /* when to stop. */ - - /* compare against the next word in the queue */ - while(num>0 && input[ip]!=-1 && ip AND AND ... */ - while ( (all_except || w_and(input[ip])) && - saveinfo!=D_END) /* && saveinfo!=D_ALL */ - { - ip++; /* Skip over AND or EXCEPT */ - next=parse_a_noun(); saveinfo=next[0].info; - if (next[0].info!=D_END) { /* We found a word */ - if (!all_except) lnoun=add_rec(lnoun,AND_MARK,0,D_AND); - lnoun=concat_list(lnoun,next); - } else ip--; /* We hit trouble: back up to the AND */ - all_except=0; /* Only skip EXCEPT once */ - rfree(next); - } - return lnoun; - } - - -parse_rec *parse_disambig_answer(void) -{ - parse_rec *temp; - - if (input[ip+1]==-1) { - if (input[ip]==ext_code[wall] || input[ip]==ext_code[weverything] - || input[ip]==ext_code[wboth]) { - temp=new_list(); - ip++; - return add_rec(temp,ALL_MARK,0,D_ALL); - } - if (input[ip]==ext_code[weither] || input[ip]==ext_code[w_any]) { - temp=new_list(); - ip++; - return add_rec(temp,0,0,D_EITHER); - } - } - return parse_noun(0,0); -} - - - -/*-------------------------------------------------------------------*/ -/* Main parsing routines */ -/*-------------------------------------------------------------------*/ - - -static int parse_cmd(void) -/* Parse entered text and execute it, one statement at a time */ -/* Needs to leave ip pointing at beginning of next statement */ -{ - rbool new_actor; /* This is used for some error checking; it is set - if we just found an actor on this command - (as opposed to inheriting one from a previous - command in a multiple statement) */ - parse_rec *tmp; - int tp; - - /* First go looking for an actor. */ - ap=ip; - new_actor=0; - if (lactor==NULL) { - new_actor=1; - lactor=parse_noun(0,1); - /* Check that actor is a creature. */ - if (lactor[0].info!=D_END) { - lactor=fix_actor(lactor); /* eliminate non-creatures */ - if (lactor[0].info==D_END) { /* Not a creature. */ - /* print intelligent error message */ - if (input[ip]==ext_code[wc]) /* ie there is a comma */ - return parseerr(229,"Who is this '$word$' you are addressing?",ap); - else ip=ap; /* Otherwise, assume we shouldn't have parsed it as - an actor-- it may be a verb. */ - }} - if (lactor[0].info!=D_END && input[ip]==ext_code[wc]) - ip++; /* this skips over a comma after an actor. */ - } - /* Now onwards... */ - vp=ip; - vnum=id_verb(); /* May increment ip (ip will point at last word in verb) */ - if (vnum==0 && new_actor && lactor[0].info!=D_END) - { /* maybe actor is messing us up. */ - ip=ap; /* restart from beginning */ - vnum=id_verb(); - if (vnum==0) /* if it's still bad, probably we really have an actor */ - ip=vp; - else { /* no actor; really a verb */ - lactor[0].obj=0; - lactor[0].info=D_END; - vp=ap; - } - } - -TELLHack: /* This is used to restart the noun/prep/object scan - if we find a TELL TO ... command */ - - if (vnum==0) - return parseerr(230,"I don't understand '$word$' as a verb.",ip); - - /* Now we need to find noun, obj, and prep (if they all exist) */ - /* standard grammer: verb noun prep obj */ - prep=0; - np=++ip; /* ip now points just _after_ verb */ - lnoun=parse_noun( (verbflag[vnum]&VERB_MULTI)!=0, 0); - /* leaves ip pointing just after it.; - lnoun[0].info==D_END means no noun. */ - if (prep==0) { /* prep==0 unless we've met the special TURN ON|OFF case */ - pp=ip;prep=parse_prep(); /* Should be trivial */ - op=ip;lobj=parse_noun(prep==0,0); /* and_ok if no prep */ - } - - /* Check for TELL TO ... construction */ - /* If found, convert to , ... construction */ - if (lactor[0].info==D_END && lnoun[0].info!=D_END && - vnum==31 && prep==ext_code[wto] && !multinoun(lnoun)) - { - ip=op; /* Back up */ - rfree(lactor);rfree(lobj); - lactor=lnoun;lnoun=NULL; - vp=ip; /* Replace TELL with new verb */ - vnum=id_verb(); /* May increment ip (ip points att last word in verb) */ - goto TELLHack; /* Go back up and reparse the sentence from - the new start point. */ - } - - /* Convert TURN ON to TURN ON */ - if ( vnum==35 && (prep==ext_code[won] || prep==ext_code[woff]) - && lobj[0].info==D_END ) - { - tmp=lobj; lobj=lnoun; lnoun=tmp; - tp=op; np=op; op=tp; - } - - - /* For pre-Magx versions of AGT, - convert ==> */ - if (aver AT to - SHOOT WITH */ - if (vnum==49 && prep==ext_code[wat] && !multinoun(lnoun)) { - tmp=lobj; lobj=lnoun; lnoun=tmp; - tp=np;np=op;op=tp; - prep=ext_code[wwith]; - } - - /* Now to convert SHOW <*nothing*> to SHOW EXITS */ - if (vnum==40 && prep==0 && lnoun[0].info==D_END && lobj[0].info==D_END) - vnum=42; /* LISTEXITS */ - - /* Convert LOOK into EXAMINE */ - if (smart_look && vnum==19 && lnoun[0].info!=D_END) vnum=20; - - /* need better error msgs */ - if ( (verbflag[vnum]&VERB_MULTI)==0 && multinoun(lnoun) ) { - /* Multiple objects when they are not allowed */ - int msgnum; - if (vnum==31) msgnum=155; /* TALK */ - else if (vnum==34) msgnum=160; /* ASK */ - else msgnum=231; - return parseerr(msgnum, - "The verb '$word$' doesn't take multiple objects.",vp); - } else if ( multinoun(lobj) ) - return parseerr(232,"You can't use multiple indirect objects.",op); - else if (lnoun[0].info==D_END && !w_isterm(input[np]) && np!=pp) - /* i.e. invalid noun */ - return parseerr(233,"I don't understand the word '$word$' as a noun.",np); - else if (lnoun[0].obj==0 && lnoun[0].info==D_PRO) - return parseerr(234,"I don't know to what '$word$' refers.",np); - else if (lobj[0].info==D_END && !w_isterm(input[op])) - /* i.e. invalid object */ - return parseerr(235,"I don't understand the word '$word$' as a noun.",op); - else if (lobj[0].obj==0 && lobj[0].info==D_PRO) - return parseerr(236,"I don't know to what '$word$' refers.",op); - else if (!w_isterm(input[ip])) - return parseerr(238,"Extra input found: \"$word$...\"",ip); - - return 0; -} - - -static void v_undo(void) -{ - if (undo_state==NULL) { - writeln("There is insufficiant memory to support UNDO"); - ip=-1; - return; - } - if (can_undo==0) { - if (newlife_flag) - writeln("You can't UNDO on the first turn."); - else writeln("You can only UNDO one turn."); - ip=-1; - return; - } - writeln(""); - writeln("UNDOing a turn..."); - can_undo=0; - putstate(undo_state); - ip=1; - set_statline(); - return; -} - -rbool parse(void) -/* Wrapper around parse_cmd to handle disambiguation, etc */ -/* It returns 1 if everything is okay; 0 if there is ambiguity */ -{ - parse_rec *currnoun; - int fixword; - int start_ip; - - currnoun=NULL;start_ip=ip; - /* First, we need to see if someone has issued an OOPS command. - OOPS commands are always assumed to stand alone. (i.e. no - THEN nonsense). OOPS commands are always of the form - OOPS */ - if (ip==0 && input[0]==ext_code[woops] && input[1]>0 && - input[2]==-1 && ep>-1) { - fixword=input[ip+1]; - restore_input(); - input[ep]=fixword; - ambig_flag=0; - } - ep=-1; - - - /* Next, we need to determine if someone is trying to do - disambiguation. This is only the case if - i)ambig_flag is set - ii)ip=0 (no multiple command nonsense) - iii)there is only one noun on the line. */ - if (ip!=0) ambig_flag=0; - if (ambig_flag) { - currnoun=parse_disambig_answer(); - if (input[ip]==-1 && currnoun[0].info!=D_END) - {restore_input();ip=parse_ip;} /* Yep, we're disambiguaing. */ - else { /* nope; it's a new command */ - ip=0; - ambig_flag=0; - rfree(currnoun); - freeall(); - currnoun=NULL; - } - } - - /* Next we go looking for UNDO; again, this must be the first - thing on an empty line. */ - if (ip==0 && input[0]==ext_code[wundo] && input[1]==-1) - { - v_undo(); - return 1; - } - - save_input(); - - /* If starting a new line, clear out old the old actor */ - if (ip==0) { - actor_in_scope=0; /* Clear this */ - rfree(lactor); /* This resets lactor to NULL */ - } - - if (!ambig_flag) - if (parse_cmd()==-1) - return 1; /* error condition */ - - parse_ip=ip; - - if (debug_parse) - parse_out(lactor,vnum,lnoun,prep,lobj); - -/*Disambiguation routines; do it here instead of earlier to get - error messages in the right place (it's silly and annoying to ask the - player for disambiguation and then die on a parse error after they've - provided it) */ - compute_scope(); /* The disambig routines use this information */ - lactor=disambig(1,lactor,currnoun); - lnoun=disambig(2,lnoun,currnoun); - lobj=disambig(3,lobj,currnoun); - if (ambig_flag>0) return 0; /* We need to get disambig info */ - if (ambig_flag==-1) {ambig_flag=0;return 1;} - /* We got rid of too much */ - rfree(currnoun); - -/* Next, expand ALL if neccessary */ - if (!PURE_ALL && lnoun[0].info==D_ALL) { - lnoun=expand_all(lnoun); - if (lnoun[0].info==D_END) { /* ALL expands to nothing */ - int msgnum; - if (vnum>=15 && vnum<=24) - msgnum=all_err_msg[vnum-15]; - else - msgnum=239; - parseerr(msgnum,"I don't know what you are referring to.",np); - return 1; - } - } - -/* Now that we know that we have an executable command, - we save the undo state before executing if this is the first command - in a sequence. (That is, UNDO undoes whole lines of commands, - not just individual commands) */ - if (start_ip==0 && undo_state!=NULL) { - undo_state=getstate(undo_state); - can_undo=1; - } - -/* Now to actually execute the command that has been parsed. */ -/* Remember: disambiguation has been done by this time. */ - - exec(&lactor[0],vnum,lnoun,prep,&lobj[0]); - rfree(lobj); - - /* exec is responsible for freeing or whatever lnoun (this is for AGAIN) */ - -/* Now we clear lnoun and lobj; lactor is handled elsewhere since - we might have FRED, GET ROCK THEN GO NORTH */ - lnoun=lobj=NULL; - -/* Finally check for THENs */ - - if (ip!=-1 && w_and(input[ip]) && input[ip+1]==ext_code[wthen]) - ip++; /* AND THEN construction */ - if (ip!=-1 && input[ip]!=-1) ip++; - return 1; -} - - - - -void menu_cmd(void) -{ - int i,j; - int choice; - char *curr_cmd, *tmp1, *tmp2; /* String of current command */ - int objcnt; /* Number of objects taken by the current verb */ - int verbword; /* Verb word */ - parse_rec actrec; - - parse_rec mobj; - int vnum; /* Verb number */ - word prep; - - menuentry *nounmenu; - int *nounval; /* Object id's for the menu entries */ - int nm_size, nm_width; /* Size and width of noun menu */ - - - nounval=NULL; - nounmenu=NULL; - /* Get verb+prep */ - choice=agt_menu("",vm_size,vm_width,verbmenu); - if (choice==-1 || doing_restore) return; - - verbword=verbinfo[choice].verb; - prep=verbinfo[choice].prep; - objcnt=verbinfo[choice].objnum; - - /* Now identify the verb */ - ip=0; - input[0]=verbword;input[1]=input[2]=-1; - if (objcnt<=1 && prep!=0) input[1]=prep; - vnum=id_verb(); - - lnoun=rmalloc(sizeof(parse_rec)*2); - lnoun[0].obj=0;lnoun[0].num=0;lnoun[0].info=D_END; - - nm_size=nm_width=0; - - if (objcnt>=1) { - /* Construct noun list */ - nounval=get_nouns(); - for(nm_size=0;nounval[nm_size]!=0;nm_size++); - nounmenu=rmalloc(nm_size*sizeof(menuentry)); - nm_width=0; - for(i=0;inm_width) nm_width=j; - } - if (nm_width>MENU_WIDTH) nm_width=MENU_WIDTH; - - if (objcnt>=2 || prep==0) - curr_cmd=rstrdup(dict[verbword]); - else - curr_cmd=concdup(dict[verbword],dict[prep]); - - choice=agt_menu(curr_cmd,nm_size,nm_width,nounmenu); - rfree(curr_cmd); - if (choice==-1 || doing_restore) - {rfree(nounmenu);rfree(nounval);rfree(lnoun);return;} - - if (objcnt==1 && prep!=0) { /* VERB PREP OBJ construction */ - mobj.obj=nounval[choice]; - mobj.num=0; - mobj.info=D_NOUN; - } else { /* Normal VERB OBJ construction */ - lnoun[0].obj=nounval[choice]; - lnoun[0].num=0; - lnoun[0].info=D_NOUN; - lnoun[1].obj=0;lnoun[1].num=0;lnoun[1].info=D_END; - } - } - - if (objcnt>=2) { - tmp1=objname(lnoun[0].obj); /* Build up current command line */ - tmp2=concdup(dict[verbword],tmp1); /* VERB NOUN */ - rfree(tmp1); - curr_cmd=concdup(tmp2,dict[prep]); /* VERB NOUN PREP */ - rfree(tmp2); - - choice=agt_menu(curr_cmd,nm_size,nm_width,nounmenu); - rfree(curr_cmd); - if (choice==-1 || doing_restore) - {rfree(lnoun);rfree(nounmenu);rfree(nounval);return;} - - mobj.obj=nounval[choice]; - mobj.num=0; - mobj.info=D_NOUN; - } - - rfree(nounmenu);rfree(nounval); - - if (vnum==OLD_VERB+3) { /* UNDO */ - v_undo(); - return; - } - - if (undo_state!=NULL) { - undo_state=getstate(undo_state); - can_undo=1; - } - - /* Now to actually execute the command that has been selected. */ - tmpobj(&actrec); - actrec.obj=0; - exec(&actrec,vnum,lnoun,prep,&mobj); - lnoun=NULL; /* exec() is responsible for freeing lnoun */ -} - - - - - - - - - - -/* Grammer structures: - sverb, dverb (n,s,e,w,...,q,l,....) - overb noun (close,examine,read,eat,drink,pull,light,ext) - averb noun|ALL (drop,get,wear,remove) - TURN noun ON|OFF - TURN ON|OFF noun - a-verb noun ABOUT obj (tell, ask) - pverb noun [prep object] (put, throw) - w-verb noun [WITH object] (attack, open, lock, unlock, push, shoot) - SHOOT noun [AT object] - dummy noun [prep obj] -( pverb obj noun ==> pverb noun TO obj e.g. give dog the bone) -*/ diff --git a/app/src/main/jni/terps/agility/porting.txt b/app/src/main/jni/terps/agility/porting.txt deleted file mode 100644 index 201ade0..0000000 --- a/app/src/main/jni/terps/agility/porting.txt +++ /dev/null @@ -1,1138 +0,0 @@ -==================================================================== -AGILITY: THE (MOSTLY) UNIVERSAL AGT INTERPRETER Version 1.1.1 -MAGX: MAKE AGX, AGT-COMPATIBLE COMPILER Version 0.6.5 (beta) -==================================================================== - - This file contains notes on compiling and porting AGiliTy and Magx. See -'readme.agility' or 'readme.magx' for an introduction to the program. -The two programs are separate packages, but they have a fairly large -base of common code, so I've decided to merge their porting notes. - - This software may be freely redistributed under the terms of the GNU -General Public License, version 2. Since this is free software, there -is NO WARRANTY of any kind. - - The author, Robert Masenten, can be reached at - rcm-math@pacbell.net -Please tell me if you find any bugs or have any problems porting it -to a new system. - - ------------ - CONTENTS ------------ - This document has the following sections: - -1.0 LIST OF MAJOR CHANGES... - 1.1 ...TO AGILITY SINCE VERSION 0.8.4 - 1.2 ...TO MAGX SINCE VERSION 0.4 -2.0 SOURCE FILES - 2.1 COMMON SOURCE FILES - 2.2 AGILITY-SPECIFIC SOURCE FILES - 2.3 MAGX-SPECIFIC SOURCE FILES -3.0 COMPILING - 3.1 AGILITY PACKAGE - 3.2 MAGX PACKAGE -4.0 PORTING NOTES FOR BOTH SYSTEMS - 4.1 CONFIG.H: PLATFORM SPECIFIC #DEFINES - 4.2 VARIABLES AND FUNCTIONS DEFINED BY THE INTERPRETER - 4.3 FILENAME.C: OVERVIEW - 4.4 FILENAME.C: DATA TYPES - 4.5 FILENAME.C: FUNCTIONS -5.0 FURTHER NOTES ON PORTING AGILITY - 5.1 OS_*.C: THE PLATFORM-SPECIFIC INTERFACE - 5.2 VARIABLES AND FUNCTIONS DEFINED BY THE INTERPRETER - 5.3 OTHER FUNCTIONS THAT CAN OPTIONALLY BE SPECIFIED - 5.4 GRAPHICS, FONT, AND SOUND FUNCTIONS - - - -------------------------------- -1.0 LIST OF MAJOR CHANGES... -------------------------------- - - Theses are lists of the changes most likely to be relevant to -porters; all of the changes are more extensivly documented in the body -of this file and in the file 'changes.txt'. - - ----------------------------------------- -1.1 ...TO AGILITY SINCE VERSION 0.8.4 ----------------------------------------- - --os_linux.c has been renamed os_termcap.c; os_curses.c has become -the main Linux display module. - --replay_fast flag has been added; this should be checked by -agt_delay() and agt_newline(). - --Filename handling has been completely overhauled. All file I/O now -goes through the new file "filename.c". This has the following effects -on porters: - 1) filename.c needs to be compiled and linked with everything. - 2) agt_globalfile() and get_user_file() now have return-type - 'genfile'. (genfile is typedef'd to FILE* by default, so this - shouldn't break anything.) - 3) 'scriptfile' is now of type genfile. See comment 2. - 4) start_interface() now takes an argument of type 'fc_type' - instead of 'char*', as does set_default_filenames() - If you are using the default filename.c, then you can get - the old value by looking at "fc->gamename". - 5) If you're replacing main(), the call to run_game() now requires - a file context instead of a game name. (See notes on main()). -See section 4.5 for more information. - --Added fixed font formatting code as well as FIXED_FONT -configuration option. - --Platform dependent information has been broken off into a seperate -include file, config.h, which is #included in agility.h - --Changed source code filenames to improve readability: - agtread.h-->agility.h; uagt.h-->interp.h; - agtdata.c-->gamedata.c; agtdbg.c-->disassemble.c; - agttest.c-->agtout.c; rmem.c-->util.c - --Converted bool to rbool to avoid conflicts with other libraries and -systems. - --Documentation of agt_textcolor() fixed. - - ------------------------------------ -1.2 ...TO MAGX SINCE VERSION 0.4 ------------------------------------ - --New source file, objcomp.c, split off of compile.c. - --Platform dependent information has been broken off into a seperate -include file, config.h, which is #included in agility.h. - --Changed source code filenames to improve readability: - agtread.h-->agility.h; agtdata.c-->gamedata.c; rmem.c-->util.c - --Converted to using filename.c for file operations. See porting.txt -for details. - --Converted bool to rbool to avoid conflicts with other libraries and -systems and eliminated occurances of 'class'. - - -------------------- -2.0 SOURCE FILES -------------------- - This lists the source files that should be in this package. - - --------------------------- -2.1 COMMON SOURCE FILES --------------------------- -config.g -- Platform specific #defines. -agility.h -- The header for all of the above files. - -filename.c -- Functions for finding and opening files; this may - need to be edited or replaced on some platforms. - -agxfile.c -- Routines to read and write AGX game files. -auxfile.c -- Routines to read in various additional AGT files. -gamedata.c -- Static data structures and dictionary management routines -util.c -- Miscellaneous utilities including string functions, wrappers - for dynamic allocation routines, and file I/O. -agilstub.c -- This contains the basic output function used by the - utility programs; not part of the interpreter. - - ------------------------------------- -2.2 AGILITY-SPECIFIC SOURCE FILES ------------------------------------- -interp.h -- Header for the interpreter files; contains things used by the - interpreter but not by agtread.c. -exec.h -- Header for the verb execution files (exec.c, runverb.c, - metacommand.c, and debugcmd.c). - -os_none.c, os_termcap.c, os_dos.c, os_curses.c -- - platform specific functions, including the lowest level terminal - I/O routines. os_none.c provides a minimal interface that uses - only ANSI C library functions; it is intended mainly as a template. - os_termcap.c and os_curses.c are two alternative unix backends; - they were developed under Linux but should work under most - *nix variants. (Please e-mail me about any portability problems.) - -agtread.c -- Routines for reading AGT game files. -agil.c -- Initialization and the main program loop for the interpreter. -parser.c-- The parser and the menu system. -exec.c-- The top-level function for running player commands, - end-of-turn routines and miscellaneous utilities used during turn - execution. -metacommand.c-- Metacommand execution core. -token.c-- Decoding and execution of the actual metacommand tokens. -runverb.c-- Routines for executing verbs and the main routine - for executing player commands. -object.c -- Functions for manipulating the rooms, nouns, and creatures -debugcmd.c-- Routines for executing the debugging verbs. -interface.c -- The user interface for the interpreter and other semi-platform - dependent things including main() -disassemble.c -- Routines to print out the metacommand execution trace. - (Basically a disassembler for metacommands) -savegame.c -- Functions for saving and restoring the game state; used by - RESTART and UNDO as well as SAVE and RESTORE. -agtout.c -- Dumps out 'disassembled' AGT game files (originally written - as a test for agtread.c) -agt2agx.c -- Converts from AGT to AGX format. - - ---------------------------------- -2.3 MAGX-SPECIFIC SOURCE FILES ---------------------------------- -comp.h -- Header for all compiler-specific files. - -compstub.c -- Interface routines, main(), error reporting routine, - and stubs for routines not used by the compiler. -compile.c -- Core routines for compiling file. -objcomp.c -- Routines to compile rooms, nouns, and creatures. -command.c -- Routines to compile metacommands. -symbol.c -- Routines to manipulate labels and check ranges. -preproc.c -- Code for the Magx preprocessor. -opdump.c -- Program to print out the list of meta-command tokens. - - - ----------------- -3.0 COMPILING ----------------- - For all of the following, you should define your platform either from -the compiler or by adding a line to the top of config.h (e.g. #define -LINUX). Currently LINUX, SUN, HPUX, NEXT, AMIGA, MSDOS, and PLAIN are -supported, although some may require an appropriate os_.c -file to compile AGiliTY. (For example, AMIGA requires David Kinder's -os_amiga.c file which is not included). For Magx, only LINUX and -MSDOS have actually been tested. - - The following sections list the files that need to be compiled and -linked to make each of the possible programs. - - ----------------------- -3.1 AGILITY PACKAGE ----------------------- -AGTOut (AGT file dumper) - util.c, filename.c, gamedata.c, auxfile.c, agxfile.c, - agilstub.c, agtread.c, disassemble.c, agtout.c - -AGT2AGX (AGT to AGX conversion utility) - util.c, filename.c, gamedata.c, auxfile.c, agxfile.c, - agilstub.c, agtread.c, agt2agx.c - -AGiliTy (AGT/AGX interpreter) - util.c, filename.c, gamedata.c, auxfile.c, agxfile.c, - agtread.c, disassemble.c, agil.c, parser.c, object.c, - exec.c, runverb.c, metacommand.c, token.c, debugcmd.c, - savegame.c, interface.c, os_.c - (Filling in according to your platform.) - - os_curses.c uses curses.c; it has been written and tested on Linux -with ncurses, but should work on other *nix platforms. Use of ncurses -is recommended. Please e-mail me about any portability problems. - - os_termcap.c is termcap-based and in principal should work on any -UNIX platform with termcap, although I recommend instead using -os_curses. os_termcap.c has compiled and run successfully on both my -Linux box and a Sun workstation, but usually requires minor tweaks -between platforms, given the variation in terminal ioctrls between -platforms. - - os_none.c is intended mainly as a template for use by those trying -to port AGiliTy to a new platform. It should work on any platform -supporting ANSI C and a command line at the expense of having a status -line. (See PORTING below for details) - - os_dos.c was written to work with Borland C; I have no idea how it -will work under other libraries or with other compilers. This should -be compiled under the Huge memory model. - - -------------------- -3.2 MAGX PACKAGE -------------------- -OpDump (Prints list of metacommands and their argument types) - util.c, filename.c, gamedata.c, agilstub.c, opdump.c - -Magx (AGT compiler) - util.c, filename.c, gamedata.c, auxfile.c, agxfile.c, - compile.c, command.c, symbol.c, preproc.c - - - - -------------------------------------- -4.0 PORTING NOTES FOR BOTH SYSTEMS -------------------------------------- - If you are interested in porting AGiliTy or Magx to another platform -you should contact me to avoid duplicated effort; my e-mail address is - rcm-math@pacbell.net. -Also feel free to write if you run into any difficulties. - -The source code makes the following assumptions: ---ANSI C: it uses enums, typedefs, ANSI-style prototypes, etc. ---Text is encoded as ASCII. ---long ints are at least 32 bits. ---Negative numbers are represented in two's-complement. - - -AGILITY - In an ideal world, you should only need to change "config.h", -"os_.c", and possibly "filename.c". Then you could upgrade -your port to a new version of AGiliTy by just replacing the default -versions of these files with your own. (Any changes to the interface -defined by these three files will be listed in the "Changes" section -of this file.) - - In the real world, you may also need to tweak the memory allocation -routines in util.c, the higher level output routines defined in -interface.c, or the main() routines for any of the secondary programs. -If you need to change more than this, please send me a note so I can -try to fix whatever problem you ran into. - - -MAGX - It should compile and work "out of the box" on any system with a -command line that obeys the above assumptions and for which config.h -and filename.c have been set up correctly. - - All of the user interface routines (message output, argument -parsing, main(), etc.) are in compstub.c, so this is the only file -that should need to be edited to (e.g.) put a GUI front-end on the -compiler. - - ---------------------------------- -4.1 PLATFORM SPECIFIC #DEFINES ---------------------------------- - To begin with, you need to determine the appropriate settings for the -various platform-specific #define statements in config.h. Many of -these #define's are only needed for one system or the other. - The following symbols can be defined: - -PORTSTR: The string describing this particular port. - e.g. #define PORTSTR "OrfDOS Port by R.J. Wright" - -NEED_STR_CMP, NEED_STRN_CMP: These should be defined if your C library - doesn't have strcasecmp() and strncasecmp(), respectively. - These are case insensitive string compare operations. - -HAVE_STRDUP: Set this if strdup() is defined by your C library. - -fix_ascii: Set this equal to 1 if your platform doesn't support IBM's - extended ASCII character set (unless you want to write os_*.c - to deal with the extended character set). [AGiliTy only] - -FAST_FIXSIGN: This speeds the program up but assumes 16-bit shorts and - 32-bit longs. - -MAXSTRUCT: The largest size a single data structure can be. It - defaults to 1 MB. This should be at least as large as CBUF_SIZE, - BUFF_SIZE, and DESCR_BUFFSIZE; it should also be at least 32K. - -BUFF_SIZE: Sets the maximum size of the file buffer used to read in - the game files at the beginning. The buffer is allocated - dynamically and will not be made larger than the size of the file - regardless of the setting of this variable. It will also not be - set smaller than an individual record size (which depends on the - file). So you can choose to have minimal buffering by setting this - to 0 or choose to buffer the whole file by making this - sufficiently large (The Linux port uses 1MB, for example). - The larger this is the faster files will load but the more - memory will be used in the meantime. The default is 32K. - -CBUF_SIZE: This is the buffer size used when loading in Master's edition - '.DA6' (code) files, measured in 2-byte units. (So the actual size - is twice CBUF_SIZE). Nothing above 20,000 makes sense. [AGiliTy - only] - -DESCR_BUFFSIZE: The maximum size of the description text block before - the interpreter will read it from disk rather than storing it in - memory during play; it defaults to 0 (i.e. always use the disk). - It should not be any larger than MAXSTRUCT. At the moment this - only affects AGX games; games in the 'D$$' format will always - use the disk. - Setting this option will speed up text output during play - at the expense of a longer loading time (and more memory used). - (See also the buff_maxmem variable, below). - In practice, game description blocks range from around 50K to - around 440K (for Shades of Gray), with most around 100K. - [AGiliTy only] - -DOHASH: Define this to use hash tables for dictionary searches. - This speeds up loading and compiling dramatically at a small - increase in memory usage. - -UNIX_IO: If you have Unix-like low level file I/O functions. - (MS-DOS, for example, does). This speeds up the reading - of the large game data files on some platforms. If you set this, - you will also need to set values for FILE_PERM, READFLAG, and - WRITEFLAG; see the top of util.c. - -OPEN_AS_TEXT This causes text files to be opened as text files. - Normally they are opened as binary files and end-of-line - translation is done by hand, but if you have an operating - system for which this doesn't work you might need to define this. - If you define this, the variable open_as_binary can be set to - cause text files to be opened as binary files, anyhow. - (Which can be useful when trying to compile a file uploaded - from another system.) - -REPLACE_MENU: Define this if you replace the function agt_menu() which - creates menus for the player when a game is in menu mode. See 5.3. - [AGiliTy only] - -REPLACE_MAIN: Define this if you replace main(). See 5.3. [AGiliTy only] - -REPLACE_GETFILE: Define this if you replace the function get_user_file(), - say to allow the user to pick files from a menu. See 5.3 for - details. [AGiliTy only] - -REPLACE_FC: Indicates you want to redefine the fc_type type. - See the section 4.3 on the filename interface. - -pTTL, pINS, pVOC, pHNT, pCFG, pAGX [Both systems] -DA1, DA2, DA3, DA4, DA5, DA6, DSS, pOPT [AGiliTy only] -pAGT, pDAT, pMSG, pCMD, pSTD [Magx only] - These should be defined to be the extensions to the various files - that make up an AGT game. By default they will be ".da1", ".da2", - ".da3", ".da4", ".da5", ".da6", ".d$$", ".ttl", ".ins", ".voc", - ".opt", ".hnt", ".cfg", ".agx", ".agt", ".dat". "msg", ".cmd", and - ".std" which are the extensions under MS-DOS. - (Although not all of them are used by both programs, don't delete - the unused defaults as that will keep filename.c from compiling.) - If you are replacing filename.c, you don't need to define these. - -pSAV,pSCR,pLOG: These are the default extension for save, script, and - log files respectivly (by default they are ".sav", ".scr", and ".log"). - These are only used if REPLACE_GETFILE is not defined. [AGiliTy only] - -AGTpSTD: This should be the file name of the generic error message - file, which the compiler looks for if the game doesn't have its - own. (By default, this will be "agt.std".) You don't need to - define this if you are replacing filename.c. [Magx Only] - -PREFIX_EXT Put file name extensions before the base file name rather - than after. You don't need to worry about this if you are - replacing filename.c. - -PATH_SEP Define to be a string containing characters that could - separate the directory path from the filename. If not defined, - then AGiliTy will assume there are none and will not try - to extract the path from filenames. - You don't need to worry about this if you are replacing - filename.c. - -pathtest(s) This is a macro (although you could rewrite it as a function) - that should check whether the given string is an absolute - path (e.g. in Unix, paths starting with a slash.) - If this is left undefined, then _all_ paths will be - treated as absolute. You don't need to define this if you are - replacing filename.c. - -(There are also a handful of symbols specific to particular -os_.c files; see the relevant files for details). - - ---------------------------------------------------------- -4.2 FUNCTIONS DEFINED BY THE INTERPRETER ---------------------------------------------------------- - These are defined in util.c; you are welcome to use them -(and in unusual circumstances you might need to change them). - -void *rmalloc(long size) -void *rrealloc(void *ptr,long size) -void r_free(void *ptr) -rfree(ptr) -char *rstrdup(const char *s) - These are interpreter's own internal memory allocation routines; -these are wrappers around the usual functions that catch out-of-memory -conditions (and exit the program if neccessary). Note that is -of type , not . - is a macro that calls and then sets to NULL. - creates a duplicate copy of a string s, using -malloc. - - ---------------------------- -4.3 FILENAME.C: OVERVIEW ---------------------------- - You may not meed to change filename.c at all; the default interface -is fairly flexible and should work on most systems. In particular, if -your system has the following properties, then the original filename.c -should be adequate (and you can skip ahead to chapter 5): - - i) Files are labeled by filenames. In particular, the file name - (including extension) and path are enough to find the file - uniquely. - ii) File names can be split into a path (which says where the file - is) and a filename, and the separator symbol(s) can't occur in - the filename itself. - iii) The file "type" of the AGT files is indicated by an extension - (or prefix) to the filename. - iv) The ANSI file functions are all supported. - - If one or more of these conditions is broken (or if you want to do -something unusual, like read files straight out of ZIP archives), then -you will need to either edit or replace filename.c. All code for -dealing with filenames and file I/O goes through this file; by -changing it, you can radically alter the way AGiliTy and Magx find and -access files. - - If you make major changes to the filename system, you will -probably also need to replace get_user_file() and -set_default_filenames(); these are logically part of the filename -interface, but have been put in interface.c since they shouldn't be -linked into Magx or the various secondary programs. - - ------------------------------ -4.4 FILENAME.C: DATA TYPES ------------------------------ - There are a handful of definitions and typedefs in config.h; they -are listed here with their default settings. You can change any of -these (except for the filetype enum) and it won't break anything -outside of filename.c, get_user_file(), and the various -os_.c files. - -typdef FILE* genfile; - The basic file object. - -#define BAD_TEXTFILE NULL -#define BAD_BINFILE NULL - These define the value of genfile that means "this doesn't point to - a file." - -typedef char *file_id_type - Created by writeopen() for use by by binremove(). In the default - filename.c, this is just the filename. It must be a pointer type. - -typedef file_context_rec *fc_type; - This is in agility.h, but it can be redefined by #defining - "REPLACE_FC" in config.h. Nothing in the core system depends on the - internal structure of fc_type. (The only reason file_context_rec is in - agility.h at all is so that os_.c can use it.) This - specifies a "file context", basically a glorified (and generalized) - file name. - The file context should contain whatever information is required - to allow the various routines in filename.c to find the neccessary - files. - Although the default filename.c version is based around file names, - this isn't required (at least if you're willing to replace filename.c, - main(), and get_user_file()). - - -typedef enum { - fNONE no extension - fDA1 the info(DA1) file - fDA2 the room(DA2) file - fDA3 the noun(DA3) file - fDA4 the creature(DA4) file - fDA5 the metacommand(DA5) file - fDA6 the metacommand code(DA6) file - fDSS the string(DSS) file - fHNT the pophint file (not used yet) - fOPT the options file - fTTL the title file. - fSAV a save file - fSCR a script file - fLOG a log file - fAGX the AGX data file - fINS the instruction file - fVOC the vocabulary file (used for menuing) - fCFG the game-specific configuration file - fAGT,fDAT,fMSG,fCMD,fSTD AGT source files - fAGT_STD The standard error message file -} filetype; - These are all of the various file types that the file system can - be asked for. - - ----------------------------- -4.4 FILENAME.C: FUNCTIONS ----------------------------- - The following are all of the routines that must be defined by -filename.c. Several of these are macros by default (these are all -defined at the end of config.h). - -fc_type init_file_context(const char *name, filetype ft); - This creates a file context based on the given name and - on the file class 'ft'. The file class here doesn't refer to - a particular file type but rather to how the context will be used; - the following values of are used by AGiliTy (this is specific to - init_file_context; elsewhere the filetype denotes actual types of - files, not the broader classes here): - fDA1: "name" is the name of a game; the context will be used to - load the game data files. - (AGX, DA1, DA2, ... DSS, CFG, TTL, VOC,... etc.). - fNONE: As in fDA1, but gamepath hasn't been set yet, so - don't integrate path information until fix_file_context() is - called. - fSAV: "name" will be used to access a save file. - fSCR: "name" will be used to access a script file. - fLOG: "name" will be used to access a log file. - fAGX: "name" is name of an AGX file that is about to be written - to (agt2agx and Magx only). - fAGT: The context will be used to read source code. (Magx only) - This is called from main() and get_user_file() so if you replace - both of these (and the corresponding sections of agt2agx and - agtout), then you don't need to implement this function. - (Although you still need some way to create a file context to - pass to run_game() and the SAVE/RESTORE/LOG/SCRIPT routines.) - -void fix_file_context(fc_type fc, filetype ft); - Similar to creat_file_context, this is called after path information - has been read in. It should adjust the file context to take advantage - of that information. (On a port that doesn't support gamepath, this - doesn't do anything.) - -fc_type convert_file_context(fc_type fc,filetype ft,const char *name) - This creates a new file context based on fc and name, but possibly - altered in some ways, depending on the file type. - If name is NULL, then this routine should copy fc, making appropriate - changes. If name is not NULL, then the routine should build a file - context based on name, but possibly with information from fc. - This is used for two purposes: - i) To create save/script/log file contexts from a game name context. - (in which case name will be NULL). - E.g. converting "mygame.agx" to "mygame.sav" - ii) To create contexts for new files in the same location as - the context fc refers to. (For example, font files, include files, - etc.-- which may not have the game name in their filename.) - e.g. converting "/usr/local/spelunker/spelunk.agx" - to "/usr/local/spelunker/cavepic.pcx" - -void release_file_context(fc_type *pfc); - Free the file context pointed to by pfc. - -char *formal_name(fc_type fc, filetype ft); - Return a user-readable string refering to the file associated with -the given file context and type. This string will be used for -reporting errors and other messages. The string should have been -allocated with rmalloc. - -genfile badfile(filetype ft); - Return the bad file marker for files of type ft. - In the default filname.c, this always returns NULL. - -rbool fileexist(fc_type fc, filetype ft) - Returns true if the file referred to by fc and ft exists. - -genfile readopen(fc_type fc, filetype ft, char **errstr); - Open the file associated with the given file context and type for -reading. If there is an error, *errstr should be set to point to -an rmalloc'd error message; otherwise it should be set to NULL. - -genfile writeopen(fc_type fc, filetype ft, - file_id_type *pfileid, char **errstr); - Open the file associated with the given context and type for -writing. Set *pfileid to whatever information is needed -for binremove() to work; *set errstr as in readopen. - -rbool filevalid(genfile f, filetype ft); - Return true if f refers to a valid file (as opposed to being NULL, -say). ft contains the filetype of the given file, which can be -useful if genfile is a union of several different datatypes. - -void readclose(genfile f); - Close a file that was opened using readopen. - -void writeclose(genfile f, file_id_type fileid); - Close a file that was opened using writeopen and (if neccessary) -free any data pointed to by fileid. - -void binremove(genfile f, file_id_type fileid); - Remove a file opened by writeopen. - -void binseek(genfile f, long offset); - Seek to the location in the given file. - -rbool binread(genfile f, void *buff, long recsize, long recnum, - char **errstr); - Read a block of records each of size from the -given file into the buffer . *errstr should be set as for -binopen(). Return true on success, false on failure. - Hitting the end-of-file counts as an error. - -rbool binwrite(genfile f, void *buff, long recsize, long recnum, - rbool ferr); - Write a block of records each of size from -buffer into the given file. In the event of an error, -abort the program if 'ferr' is true; otherwise just return 0. - Return true on success, false on failure. - -long binsize(genfile f); - Return the size of an open binary file. - -rbool textrewind(genfile f); - Rewind the given text file to the beginning. - -int textgetc(genfile f); - Wrapper around fgetc(f). - -void textungetc(genfile f, char c); - Wrapper around ungetc(c,f). - (Note the reversal of the order of arguments, done for internal -consistency: all filename.c functions that require a file have it -as their first argument.) - -int texteof(genfile f); - Indicate if the given text file is at the end-of-file. - -void textgets(genfile f, char *buff, long leng); - Wrapper around fgets(buff,leng,f). - -void textputs(genfile f, const char *s); - Wrapper around fputs(buff,f). - - -The default version of filename.c exports one additional function, -which is only used by os_dos.c, os_termcap.c, and os_curses.c -(although you are free to use it in your os_.c file, too) -and so doesn't need to be defined if you're writing both your own -filename.c and os_.c: - -char *assemble_filename(const char *path, const char *root, - const char *ext); - Concacate path, root, and ext and return the resulting -rmalloc'd string. - - - - ----------------------------------------- -5.0 FURTHER NOTES ON PORTING AGILITY ----------------------------------------- - The rest of this file discusses the details of writing a new port of -AGiliTy. If you have any sort of command line, you may want to start -by getting os_none.c to work (it uses only ANSI functions) and then -work from there. - - Keep in mind that the current Linux and DOS ports have had a lot of -bells and whistles added; the interface doesn't need to be as -complicated as they have become. (The original os_dos.c was under 400 -lines.) - - ---------------------------------------------- -5.1 OS_*.C: THE PLATFORM-SPECIFIC INTERFACE ---------------------------------------------- - To port AGiliTy to another platform, you also need to create the -platform specific os_*.c file, which handles the platform -specific tasks of the interpreter. - -A few notes: - It is the responsibility of os_*.c to call for the updating -of the status line by calling the function print_statline(void) -periodically (it puts together the status line and then prints it out -by calling agt_statline() ). At the very least, it should be called -anytime the player is asked for input and should probably also be -called before delay(). - - Output should be in a fixed-pitch font, ideally 80 columns -wide. Some AGT games depend on both of these to format text vertically -(e.g. both Shades of Gray and Cosmoserve). - - os_*.c must contain the definitions of the following -functions (some of them can be empty functions, of course, and many of -them only require a few lines of code; os_none.c is both a template -and an example of a minimal os_*.c). - -void agt_delay(int n) - Wait n seconds. (If fast_replay is true, don't wait at all.) - -int agt_rand(int a,int b) - Return a random number from a to b, inclusive. - If stable_random is set, the random number generator should have been -initialized in a consistent way so the same numbers will be generated -each time the program is run. - -void init_interface(int argc,char *argv) -void start_interface(fc_type fc) - These should initialize the interface. init_interface() is called at -the very beginning of the program, before the game or any -configuration files have been read. It is passed the the command line -arguments. If you replace main() then you don't need to define -init_interface() but you need to provide similar functionality from -within your new main(). - start_interface() is called after the game has been read in and -needs to finish the initialization. You may assume only agt_newline(), -agt_puts(), and agt_option() will be called before start_interface(), -to print out diagnostic information. - In addition they need to set screen_width, screen_height, -status_width, and curr_x.(See below for what all of these are). They -also needs to set script_on=center_on=par_fill_on=0, after which the -interface can safely ignore the last two of the variables. It _is_ the -responsibility of the os_* code to echo everything to the script file -if script_on is 1. - These are two functions so that start_interface() can use -information from the game file (perhaps parsed by agt_option). If you -aren't doing this, you can just put all of the initialization in -init_interface() and leave start_interface() empty. - -void close_interface(void): - This should do any cleanup necessary. - -char *agt_input(int in_type) - This should read a line of input from the player and return it in a -malloc'd buffer. (The routine calling agt_input is responsible for -freeing this buffer). - in_type specifies the type of input being asked for: - 0: a normal command - 1: a number - 2: the answer to a question - 3: a string (e.g. asking for the player's name) - 4: a filename - 5: 'RESTART, RESTORE, UNDO, or QUIT?' - -char agt_getkey(rbool echo_char) - Get a single key-press from the keyboard. Echo it to the screen if -echo_char==1. - -void agt_puts(const char *s) - Output the string s. You may assume that s contains no newline -characters and that the string itself will not wrap (at least as long -as screen_width and curr_x have been correctly maintained). curr_x -should be incremented by the length of s. (It *is* possible for -characters to be output all the way to the rightmost column, which -could cause the *cursor* to wrap) - -void agt_newline(void) - Generate a newline, scrolling the screen up if necessary. - -void agt_clrscr(void) - Clear the screen and position the cursor in the upper left-hand - corner. - -void agt_statline(const char *s) - Display the string s on the status line. This should be printed - in a fixed-pitch font. - -void agt_textcolor(int c) - This really handles *all* of the details of text appearance, not -just color. - 0-6,9 are colors; see os_none.c for details. - 7= Normal: turn off all blinking, bold, color, etc. and restore - the text to its default appearance. - 8= Turn on blinking. (Which can only be turned off by c=7) - 10= Turn on fixed-pitch font. - 11= Turn off fixed-pitch font. - -1= Turn on emphasized text("Bold"). - -2= Turn off emphasized text. -None of these are toggles-- if any occur twice in a row, the second -should just be ignored. - If you are interested in implementing a proportional font interpreter, -you should also look at the description of font_status in 5.2. - - -void agt_tone(int hz,int ms) - Create a tone at a frequency of hz hertz for ms milliseconds. -This routine should check the sound_on variable; if it is 0, then the -routine shouldn't do anything. - - -void agt_makebox(int width,int height,unsigned long flags); - This creates a text box of the given width and height. (These only -include the text inside and do *not* include any border). The text -will be output by using agt_puts() and agt_qnewline(). - Flags can have the following bits set: - TB_TTL, if the title is being printed (the box should be - vertically centered in this case). - TB_BORDER, Print a border around the box. - TB_NOCENT, don't center the box horizontally; print it left justified -Other bits are reserved for future use. - The actual text of the box will be printed out using the regular -agt_puts() function interspersed with calls to the box-specific -agt_qnewline() (the 'q' stands for 'Quote'). - You may assume that _exactly_ *width* characters of text will be -printed out on each line (but possibly in multiple agt_puts() -statements). agt_qnewline() will be called between lines, but will -not be called after the last line (agt_endbox() will be called, -instead). You may also assume that exactly *height* lines will be -printed out. - On the other hand, it is legal for agt_textcolor() to be called -during the output of text in a box (which is one reason why there may be -multiple agt_puts() commands per line). - Text boxes should also be printed out in a fixed-pitch font. - -void agt_qnewline(void); - This is used instead of agt_newline() when text inside a box is -being printed out. See agt_makebox() for details. - -void agt_endbox(void); - This is used at the end of a box. See agt_makebox() for details. -It should leave the cursor in the left-most column on the line below -the box. - -genfile agt_globalfile(int fid); /* When fid=0, return global config file */ - When fid=0, this should return an open file descripter to the global -configuration file for the interpreter. - For example, in MS-DOS, this will be the file AGIL.CFG in the same -directory as the interpreter; in Linux it is the file '$HOME/.agilrc'. - For other values of fid, return NULL. - -rbool agt_option(int optnum,char *optstr[],rbool setflag); - As the interpreter parses the configuration files, it will pass any -options it doesn't understand to this function; this can be used to -support platform-specific configuration options. - The line will have been parsed into whitespace-separated words. -*optnum*=number of words, *optstr[]* is the array contain pointers to all -of them. optstr[0] will be the first word on the line (and hence the -option name). - *setflag* will be 1 unless the option name was prefixed by 'NO_' -(inverting its meaning) in which case it will be 0 (and the 'NO_' -prefix will have been stripped off). - Return 1 if agt_option() recognized the option, 0 otherwise -(which will cause a warning to be printed). - - ---------------------------------------------------------- -5.2 VARIABLES AND FUNCTIONS DEFINED BY THE INTERPRETER ---------------------------------------------------------- - - The following variables are defined elsewhere, but need to be set and -updated by the routines in os_*.c as they are used for -line-break information and to format the status line: - -int screen_width: the width of the screen - -int status_width: the width of the status line (on most systems this - will be the same as screen_width). - -int curr_x: The current x position (starting at 0). - -int screen_height: The height of the screen. - Currently the only routine that uses this is the title printing - routine. - -rbool script_on: This should be set to zero by init_interface() and - does not need to be changed by the interface code after that. - If it is 1 then all input and output should be echoed to the file - associated with scriptfile. - -genfile scriptfile: The file script output should go to. This is set - by interface.c. - - -rbool sound_on: This is set to 1 initially; if it is 0, then agt_tone() - shouldn't do anything. os_* may change this. - -char **gamepath: This is a pointer to a NULL-terminated array of - pointers to strings, each of with gives a possible path for the game - files. This is set to NULL initially, but you can set this to - a list of game file search paths if you want. It needs to be set - by init_interface() or agt_option() to have any effect. - If this is not NULL, the directories is lists will be searched - in order, *before* the current directory is checked. If you want - the current directory to be searched first, make sure that - gamepath[0] is the empty string "". - -rbool DEBUG_AGT_CMD: By default, this is set by main() according - to command line options but you can change it if you want. - It can also be set by the player using the AGILDEBUG command. - This determines whether metacommand debugging information is - printed out. - -rbool DEBUG_OUT: This should be set by init_interface(). If it is 0, - metacommand debugging output will go to the screen (using - agt_puts() and agt_newline()). If it is 1, debugging output will - be sent to debugfile and the interface code should also echo - everything to debugfile. Whether there is any debugging output - in the first place is determined by DEBUG_AGT_CMD. - -FILE *debugfile: This is the file where metacommand debugging output - will be sent if DEBUG_OUT is true. It should be set by init_interface(). - - (The Linux port, e.g., always sets debugfile to stderr and checks to - see if stderr and stdout refer to the same underlying file; if they - do it sets DEBUG_OUT to 0; if they are different, then it sets - DEBUG_OUT to 1. Thus if stderr is redirected by the user, then - a complete debugging log file will be written without cluttering - the screen. If it is not redirected then debugging output will be - sent to the screen through agt_puts().) - - -stable_random: When this is set, the random number generator should - behave consistantly so as to give the same set of values each time the - interpreter is run. - -BATCH_MODE: We are running the game with a fixed script and so - output can be supressed. - -menu_mode: If true, menu input will be used instead of the usual - command line. This variable is managed automatically by the - interpreter, but you can change it if you want. - - -compass_rose: This is an unsigned short with a bit set for each - direction the player can go; a fancy port of the interpreter could - use this to print something out below the status line (or even draw - an honest compass rose). There are 12 bits used; starting with the least - significant bit they represent N, S, E, W, NE, NW, SE, SW, U, D, IN, - and OUT. - -descr_maxmem: This is set to DESCR_BUFFSIZE at the beginning of the - program, but you could change it based on the amount of memory - available at runtime. It must be set before the game file is - read in from memory (after init_interface() but before - start_interface()). - It sets the upper limit on the size of the description block - before the interpreter will just leave it on disk rather than trying - to load it into memory at once. - -font_status: This is set by the interpreter; it tells whether a - proportional font can be use, or whether the interface must - use a fixed pitch font. There are three possible values: - 0 -- The interpreter doesn't know whether proportional fonts - are allowed or not; it's up to the interface (or the user) - to make this decision. This is the setting for original AGT - games and early Magx games. - 1 -- Fixed font needs to be on by default. - 2 -- Fixed font doesn't need to be on by default. - See also agt_textcolor(). - -rbool fast_replay Set by the interpreter, this is true if the - user is doing a fast replay from a log file. In this case, - delays should be supressed and text scrolling should not be - stopped each screen to wait for the user. - - The following functions are defined by the interpreter but can be -used by os_*.c - - -void agt_save(void) -void agt_restore(void) -void agt_quit(void) - These save, restore, and quit the game, respectivly. They can be called -asyncronously (although the quit or restore won't actually occur until -the end of the current turn). These are intended mainly for use in -event-driven GUIs. - (These haven't been tested extensively) - - -void agt_newgame(fc_type fc) - This loads a new game, replacing the current one; like the function -above, it doesn't take effect until the end of the current turn. -During the start of a new game, start_interface() (but not -init_interface) will be called again. This is intended mainly for use -in event-driven GUIs. - (This hasn't been tested at all) - - -------------------------------------------------------- -5.3 OTHER FUNCTIONS THAT CAN OPTIONALLY BE SPECIFIED -------------------------------------------------------- - The following functions may also, optionally, be defined in -os_*.c, but you must insert appropriate #define statements -into config.h to prevent the default versions from being created -(see above). The default versions of all of these functions are in -interface.c. - -genfile get_user_file(int ft) /* 0=script, 1=save, 2=restore, - 3=log(read) 4=log(write) */ - This gets a file name from the user, opens it, and returns the -appropriate data structure. If you redefine this then define -REPLACE_GET_FILE in config.h. You might want to redefine -this to allow the user to pick files from a menu, for example. - ft tells what sort of file the user is being asked for: 0=script, -1=save, 2=restore, 3=log file(read), 4=log file(write). - This is logically part of the filename system; see 4.5. - -void set_default_filenames(fc_type fc) - This is part of get_user_file and will also be left undefined - if REPLACE_GET_FILE is defined in config.h. - -int agt_menu(char *header,int size,int width,menuentry *menu); - This prints out a menu and gets a choice from the user. This is used -by a few games to get menu-driven input. You should define -REPLACE_MENU if you want to redefine this. - *header* is the header for the menu; e.g. 'PUT TUBA IN ?' - *size* is the number of entries in the menu - *width* is the width (in characters) of the widest one. - *menu[]* is the array of menu entries; menu entires are strings of -length MENU_WIDTH (currently 50). - (In interp.h: typedef char menuentry[MENU_WIDTH]; ) - Return the index corresponding to the menu entry chosen or -1 if -something strange happened (e.g. the player turned off menuing by -using special keys) - - -main() - By putting #define REPLACE_MAIN in config.h, you will prevent -main() from being defined in interface.c so that os_*.c can -define its own main function (on some platforms, this may be called -something other than 'main()'). - The main function needs to do the following: - --Call set_default_options() to make sure that all of the options are - initialized to the correct defaults. - --Set the various options, either from the command line or by other means - --Get the file name of the agt game being played (from the command line or - by other means). - --Do basic initialization of the interface (enough so that writestr() - and writeln() will work for diagnostic messages) - See the comments on init_interface() above. - --Call run_game( fc_type fc ), where fc is the file context of the - game file(s). If you're using the default filename.c, you can - get this context by calling init_file_context(gamename,fNONE). - --Terminate - - - - ------------------------------------------- -5.4 GRAPHICS, FONT, AND SOUND FUNCTIONS ------------------------------------------- - Master's Edition games included support for graphics and sound, -although only a very few games were made that made any use of these -features. The DOS and Linux ports support fonts and graphics; I don't -know of any ports that support sound, but the core interpreter -implements the necessary hooks. - - If you actually want to implement these, you'll want to track down -the documentation for the Master's Edition which discusses the file -naming conventions and file formats used for these. (You will also -want to get your hands on the game HURRY! HURRY! which demonstrates -all of these.) - - Stub versions of these functions are currently defined at the -beginning of interface.c; you'll need to comment out those functions -that you are replacing. - - -void fontcmd(int cmd,int font) - 0=Load font, the name is fontlist[font] - 1=Restore original (startup) font - 2=Set game's initial font (.FNT) - This sets the font used for all output text. Under DOS, the fonts -are stored in a file name .FNT. The data seems to be stored -simply as a collection of binary bitmaps, 8x8 pixels, with eight bytes -for each of the 256 characters in the font set (giving one byte per -row). There doesn't seem to be any sort of header or other -information. - - -void pictcmd(int cmd,int pict) - 1=Show global picture, name is pictlist[pict] - 2=Show room picture, name is pixlist[pict] - 3=Show title picture (usually .pcx) - Display the picture requested on the screen until the user presses -a key. Pictures are stored in the PCX file format, but with nonstandard -filename extensions which indicate the PC video mode the image was -supposed to be viewed in. - Animations are stored in the FLI format. - - -int musiccmd(int cmd,int song) - 1=play song, name is in songlist[song] - 2=play song repeatedly, name is in songlist[song] - 3=end repeat - 4=end song - 5=suspend song - 6=resume song - 7=clean-up sound system (called just before interpreter exits) - 8=turn sound on - 9=turn sound off - -1=Is a song playing? (0=false, 1=true) - -2=Is the sound on? (0=false, 1=true) -Songs are stored in the MUC file format: - The file format includes no header, but is a collection of -six-byte records. Each record consists of three unsigned 16-bit -numbers (stored little-endian like all numbers under AGT: the least -significant byte comes first): the frequency (in Hertz); the length of -time of the tone (in milliseconds); and a delay between tones (also in -milliseconds). - At least in theory, songs may also be stored in the VOC, MID, or CMF -formats. - - - diff --git a/app/src/main/jni/terps/agility/readme.agility b/app/src/main/jni/terps/agility/readme.agility deleted file mode 100644 index 929d0af..0000000 --- a/app/src/main/jni/terps/agility/readme.agility +++ /dev/null @@ -1,464 +0,0 @@ -================================================= -AGILITY: THE (MOSTLY) UNIVERSAL AGT INTERPRETER -Version 1.1.1 -================================================= - - This is an interpreter for game files created with Malmberg and -Welch's _Adventure Game Toolkit_. AGiliTy is universal in the sense -that it understands and interprets most of the many versions of the -AGT game file format (unlike the original interpreters which were -only intended to run the game file format associated with them) and -also in that it is written in ANSI C and so should be straightforward -to port to other systems. - - It is *not* a port of the original interpreters but rather a -completely new interpreter built around the game file format; while it -follows the original interpreters on most things, there are some -differences which are described below. - - ----------- - CONTENTS ----------- - INTRODUCTION - ACKNOWLEDGMENTS - AGT AND AGX GAME FILES - AGT VERSIONS SUPPORTED - DIFFERENCES BETWEEN AGILITY AND THE ORIGINAL INTERPRETERS - LIST OF SPECIAL VERBS - CONFIGURATION FILES - DEBUGGING OPTIONS - AGT GAME LIST - - --------------- - INTRODUCTION --------------- - For general information on AGT, I recommend Jay Goemmer's web page -at http://www.ltlink.com/~jgoemmer/agt.html. - - The most recent release of this program can be found at the -Interactive Fiction archive: - ftp://ftp.ifarchive.org/if-archive/programming/agt/agility/ - - This software is copyright 1996-1999,2001 by Robert Masenten. -This program is free software; you can redistribute it and/or modify -it under the terms of version 2 of the GNU General Public License, -as published by the Free Software Foundation. - This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - You should have received a copy of the GNU General Public License -along with this program; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - - For information on compiling and porting this program, see the file -'porting.txt'. A list of known bugs is in the file 'buglist' and a -list of changes from earlier versions is in 'changes.txt'. (If this is -with an executable and not the source version, some of these files may not -be present). - - Send comments and bug reports to Robert Masenten at: - rcm-math@pacbell.net - - - ------------------ - ACKNOWLEDGMENTS ------------------ -Thanks to the following people: - *Jay Goemmer, who has sent me pages and pages of comments and bug -reports. - *David Kinder, responsible for the both the Amiga and Windows ports and -a source of much valuable feedback. - *David Youd, who has uncovered many subtle and complex bugs in both -AGiliTy and Magx. - *Mitch Mlinar, who has contributed several patches. - *Jan-Erik Karlsson, for his bug report/patch. - *Everyone else who has sent me suggestions and bug reports, including -Audrey De Lisle (responsible for the red smoke), David Doherty, Al -Golden, John Hartnup, Walter Isaac, Sami Kivela, Alexander Lehmann, -Grant E. Metcalf, Paul Mikell, Adam Myrow, Olav Nielsen, D.J. Picton, -Kevin Soucy, Ben Straub, "Grand Moff Tarkin", Adam Thornton, Mark -Tilford, David Turpin, and Gil Williamson. - *Volker Blasius, maintainer of the Interactive Fiction Archive at -ftp.ifarchive.org. - *Robert Pelak, who suggested the name "AGiliTy". - *All of the other people on rai-f who suggested names for my interpreter. - - ------------------------- - AGT AND AGX GAME FILES ------------------------- - Games in the AGT format can be found at the Interactive Fiction archive: - ftp://ftp.ifarchive.org/if-archive/games/agt - - AGT games are recognizable by having several different files with -names like 'MYGAME.D$$', 'MYGAME.DA1', 'MYGAME.DA2', ... , -'MYGAME.DA6', 'MYGAME.TTL', etc. They also usually come with a DOS -runtime interpreter (usually called RUN.EXE or MRUN.EXE), which can be -deleted without affecting AGiliTy. (DOS users might want to keep it -around 'just in case', depending on how much hard drive space is -available) - - AGiliTy also has its own file format (with extension "AGX", which -stands for "Adventure Game eXecutable"); existing AGT games can be -converted into this format using the utility agt2agx which comes with -AGiliTy. They can also be created from AGT source code by using the -Magx compiler, available in - ftp://ftp.ifarchive.org/if-archive/programming/agt/magx/ - - The new format takes all of the various AGT files (MYGAME.DA1, -MYGAME.DA2, MYGAME.DA3, MYGAME.DA4, MYGAME.DA5, MYGAME.DA6, MYGAME.TTL, -MYGAME.INS, MYGAME.VOC, MYGAME.D$$, MYGAME.OPT, and parts of -MYGAME.CFG) and puts all of the data in one file (MYGAME.AGX). - Aside from the reduction in directory clutter, it has the -following advantages: - 1)It's smaller; for large games the new format can save over 100K - (The most extreme case I've run across so far is Shades of Gray: - 790K vs. 568K uncompressed or 273K vs. 148K ZIPed) - 2)It loads more quickly since it's closer in structure to AGiliTy's - internal format. (In particular, the interpreter doesn't need to - build the dictionary or convert metacommand opcodes into a common - format). - 3)It's more portable. For example, there are platforms out there that - can't handle the 'D$$' extension. - - ------------------------- - AGT VERSIONS SUPPORTED ------------------------- - AGiliTy understands the following versions of AGT (which includes -every AGT game at ftp.ifarchive.org that I know of): - --1.0 - --1.18 - --the early "Classic AGT": e.g. 1.19, 1.2, 1.21 - --"Classic AGT", both big and small: e.g. 1.3, 1.32, 1.35, 1.5, 1.7 - --the "Even Bigger 1.32" used by _Cosmoserve_ - --the "Chemically Altered 1.32" used by _Shades of Gray_, - --Menichelli's 1.82[untested] and 1.83 - --Both known "proto-Master's Edition" 1.5 variants - --The proto-Master's Edition 1.6 variant used by Pork. - --Both Master's Edition 1.0 variants. - --The Master's Edition 1.5/1.51, 1.55, and 1.56/1.6/1.7. - - _The Pyramids of Mars_ and _Cliff Diver_ require configuration -options to be set; they use variant interpreters that are supported -but can't be detected by the interpreter. - In particular, _Pyramids_ needs the ALT_ANY option and -_Cliff Diver_ requires the IRUN option. - - _Klaustrophobia_ is now supported. Use AGiliTy to play each of the -chapters as usual. To switch between chapters, just SAVE at the end -of one chapter and RESTORE at the beginning of the next (the -game will tell you when to switch chapters; however, use SAVE instead -of DONE1 or DONE2). This is still experimental and so I'd appreciate -any feedback on how well it works (or doesn't work, as the case may -be). - Unlike the MS-DOS programs that _Klaustrophobia_ originally used for -this, AGiliTy doesn't check that you've actually reached the end of the -previous chapter; be warned that if you switch chapters before the game -tells you to, things may break. - There is also no way for AGiliTy to support the intermission or -endgame text from the original game: these are all printed out -by DOS programs rather than by the AGT interpreter. - - ------------------------------------------------------------ - DIFFERENCES BETWEEN AGILITY AND THE ORIGINAL INTERPRETERS ------------------------------------------------------------ - --Disambiguation is done on the normal command entry line rather than -having a special prompt. - --When asked "Which object do you mean?", it is possible to reply -ANY, EITHER, BOTH, or ALL, as well as giving the name of an object. - --LISTEXIT ON, LISTEXIT OFF will turn automatic listing of exits on or -off (in AGT there is a LIST EXITS command, so some AGT games don't list -exits to rooms). - --OOPS, UNDO, and RESTART are supported (at least on systems with -enough memory). - --Adjective-only matches are accepted by the parser. - --The parser is capable of intelligent disambiguation. - --It is is also able to expand ALL and ALL EXCEPT (when appropriate -options are set). - --Some more multiple word verbs are automatically recognized (for -example, GET IN is automatically translated into ENTER). - --Some built-in verbs have additional synonyms. (In particular, -standard one-letter abbreviations are supported: X for EXAMINE, Z for -WAIT) - --Game-specific synonyms are given a higher priority by the parser than -the generic built-in synonyms. - --The standard error messages are different than the original (except -in Master's Edition games where most of the standard error messages -are included in the game file) - --SCRIPT output is sent to a file rather than to the printer. - --AGiliTy has an extended AGILDEBUG debugging verb and supports more -detailed metacommand tracing output. - --AGiliTy uses a different save file format. - --COLORS is not supported, although on some systems equivalent -functionality is supported in the configuration file. - --The special title screen effects of the Shades of Gray and Cosmoserve97 -interpreters aren't duplicated. - --Graphics, sound, and fonts are not supported on all platforms. - - ------------------------ - LIST OF SPECIAL VERBS ------------------------ -These are all of the special verbs recognized by the interpreter: -SCORE Print out your score. -NOTIFY Turn score notification on and off -INSTRUCTIONS or INS Display the instructions for the game. -INTRODUCTION or INTRO Repeat the introduction of the game. -VIEW Views an illustration. (Not supported on all platforms.) -BRIEF Don't print room descriptions for rooms you've seen. -VERBOSE Print room descriptions even for rooms you've already seen. -LIST EXITS List the exits from a room. -LISTEXIT ON,OFF Turn on/off automatic listing of exits. -SCRIPT Start sending a transcript to a file. -UNSCRIPT Stop creating a transcript. -SOUND ON, OFF Turn sound on/off. -LOG Start sending all of your commands to a file. -REPLAY Replay your commands from a file, one every - seconds. -REPLAY FAST Replay your commands from a file without waiting for you - to read the scrolling text. -REPLAY STEP Replay your commands from a file, one for every keypress. -AGILDEBUG Access debugging commands. -MENU Toggle menu mode on or off. -OOPS Correct a word you just mistyped; must be the first command on - a line. -UNDO Undo your last move; must be the first command on a line. -SAVE Save the game. -RESTORE Restore the game. -RESTART Restart the game. -QUIT Quit - - ---------------------- - CONFIGURATION FILES ---------------------- - The interpreter gets configuration information from as many as three -places: the global configuration file (containing things that you want -to apply to every game you play), the game-specific configuration -file (usually with an extension '.cfg'), and, in the case of AGX-format -games, the game file itself. - Options in the game-specific file override options specified from -the other two sources; options in the AGX file override those in the -global file. - - The following configuration options are supported on all platforms. -Other options may be supported on your particular system; see -appropriate platform-specific documentation for information. - Each option should be on a separate line in the configuration file. -Lines starting with '#' will be treated as comments and ignored. -Options can be negated by prefixing them with 'NO_' so that, for -example, DEBUG would become NO_DEBUG. - -General options: - VERBOSE Start the game in VERBOSE mode - DEBUG Allow the use of AGILDEBUG for pre-Master's games (For - Master's Edition games, this decision is based on the DEBUG - flag in the game file itself) - DEFAULT_ERRORS Cause AGiliTy to use its own internal defaults - for standard error messages even if the game file defines its own. - (Recommended for most Master's Edition games.) - PATH Gives a space-separated search path for AGT games. [Not supported - on all platforms.] - TONE Enables the *tone* action token, which allows games to make - annoying beeps on some platforms. The only game I might recommend - enabling this for is _CosmoServe_ which has some interesting - sound effects. Not all platforms support this command. - INPUT_BOLD Makes the input line bold. (This doesn't work on all platforms) - IBM_CHAR Try to use the IBM character set; don't translate them. - If your platform doesn't support the IBM character set, this is - likely to produce garbage. - NO_ERROR Supress GAME ERROR messages during play. Some poorly written - AGT games contain bad metacommands, out-of-range tokens, or other - problems; this option will supress the messages reporting these - sorts of problems. - SMART_DISAMBIG This turns on smart disambiguation. This works better - with some games than others. - EXPAND_ALL This turns on ALL and ALL EXCEPT expansion in the parser (by - default, expanding them is the responsibility of the individual - verb execution routines); see remarks on SMART_DISAMBIG: both of these - options use the same engine and so they are likely to work or fail - together. If you're using this, you'll probably also want to set - FIX_MULTINOUN. - IGNORE_SIZE Ignore weight and size limits on how much the player can - carry. (There remain limits on the size and weight of any - individual object.) - -Game specific options - (Many of these are more useful to game authors than game players.) - PROPER_CREATURE Treat all creature names as proper nouns. - (In particular, this will cause them to be capitalized and to - not have "the" appear in front of them.) Use of DEFAULT_ERRORS - is recommended with this option. - ROOMTITLE Print the room title in bold before the room description - in pre-Master's games. (Master's Edition games do this - automatically) - IRUN Print error messages in first person. This should be set for - _Cliff Diver_. - NO_BLOCK_HOSTILE Allow the player to leave a room containing a hostile - creature if they go back the way they came. - NO_GET_HOSTILE Prevents the player from picking up objects in a room - containing a hostile creature. (Intended to be used with - NO_BLOCK_HOSTILE) - NO_OBJECT_NOTES Turns off notes after object description, - such as '[providing light]'. - CONST_TIME Increment time at a constant rate instead of randomly. - SLASH_BOLD If set the slash character toggles bold on and off. - (This should be set automatically for 1.8x games, but you may still - need to set it explicitly for version 1.82 ) - PRONOUN_SUBS Do $you$-style substitutions even in game-author - defined messages. - ALT_ANY This scans the ANY metacommands *with* the - metacommands rather than before them. Should be set for - _Pyramids of Mars_ and not for any other games I know of. - CHECK_GRAMMAR Print out error messages if the player enters a verb - with too many objects. (For example, "N KEY"). - FORCE_LOAD Force AGX game to load even if interpreter isn't of the - right version. Don't use this unless you know what you're - doing: Magx doesn't assign minimum version numbers without - reason. - PURE_AFTER Causes LOOK and other end-of-turn actions to take place - after AFTER commands. (This is on by default for Master's - Edition games.) - FIXED_FONT - Force system to use a fixed-pitch font. - NO_FIXED_FONT - Allow the system to use proportional fonts. - -Technical options: These are fine tuning. - FIX_METAVERB Don't run ANY metacommands when executing a metaverb. - FIX_MULTINOUN Only advance one turn when manipulating multiple nouns, - rather than a turn for each noun. - PURE_ANSWER Require AND-connected answers to be in the right order. - (The Master's Edition documentation claims order doesn't - matter, but with the actual interpreters it does) - -Parse Options: These are all pretty technical. - PURE_DUMMY Allow dummy verbs to be run by typing "dummy_verb3" - PURE_SUBNAME Allow subroutines to be run by typing "subroutine3" - PURE_SYNONYM Treat synonyms exactly as nouns. - ADJ_NOUN Don't pick noun matches over adjective-only matches. - - - -------------------- - DEBUGGING OPTIONS -------------------- - With AGILDEBUG you can access various debugging commands. You can -move objects around; change the values of flags, variables and -counters; list objects in the game; examine and edit objects; and turn -metacommand tracing on or off. - - (Note: You can change almost all of the fields associated with -an object using the View/Edit Object option; be warned that many of -them are not SAVEd or RESTOREd since they can't be changed during -normal play. If you change one of these and then RESTORE or UNDO, it -will stay changed. Conversely, if you make a change, save, quit, and -restore, the changed value will not be preserved. The fields having -this behavior are marked.) - - When metacommand tracing is on, every metacommand that is run will -be displayed. You can turn off tracing of ANY metacommands and tracing -of metacommands during disambiguation (the latter is off by default). - - In addition, AGiliTy has a test mode which automatically reads a -log file from .LOG (or equivalent) and writes a script to -.SCR. In this mode, the random number generator is forced to -be non-random, allowing for automated testing of games. - To use this, you create a LOG file (either by hand, by using the -'-c' option, or by using LOG-- note that this log file needs to -include everything from the very beginning, including the key hit at -the end of the title screen, so if using the LOG command you'll need -to add a line or two at the beginning.) - Run AGiliTy in test mode once to get the script. Copy the script -to some other file. Then, whenever you make a change to your game -file, rerun AGiliTy and compare the new script with the old one. -(There are programs that will do this automatically and just print -out the lines that have changed.) - - ---------------- - AGT GAME LIST ---------------- - Here is a list of a few of the better or more popular AGT games, -along with their filename in ftp://ftp.ifarchive.org/if-archive/games/agt/; -it is in no way exhaustive. - I've also included references to reviews in issues of SPAG and -XYZZYnews; these can be found in if-archive/magazines/SPAG and -if-archive/magazines/XYZZYnews respectively. - - -Shades of Gray (soggy97.zip) by Mark Baker, Steve Bauman, Belisana - Magnificent, Mike Laskey, Judith Pintar, "Hercules", and Cindy Yans - Widely considered to be the best AGT game ever written. This is a - 'real life' game that is concerned more with the protagonist's - ideals and mental state than with "adventuring". You open the game - with amnesia and need to figure out who you are and recover your - memory. To say more would give too much away. It's a bit uneven (it - was written by a team of seven people) and it opens with an - arbitrary puzzle that's a potental show-stopper, but overall this is - an excellent game. - SPAG 2, 8; XYZZY 11(interview with one of the authors) - - -Cosmoserve (cosmos97.zip) Judith Pintar - Another strong AGT game. In it, you take the role of R.J. Wright, - free-lance programmer/plumber, who is trying to finish a program - that is due the next morning. You will need to log on to Cosmoserve - and interact with the other users in order to be able to do this. - It has a clever interface that really captures both the DOS - command-line and life online pre-GUI. This is, however, a game - you'll have to play through several times to win since it requires - tight timing to be in all of the right places at the right times. - SPAG 5; XYZZY 1, 11(interview with the author) - - -The Jeweled Arena (tja.zip) David S. Raley - This game is divided into four chapters; in each chapter you are - a different person (although the first and third chapters share the - same main character). Games like this often suffer from a lack of - unity; this game, however, holds together quite well. In part, this - is because all of the chapters take place in a single, large, - setting: the city of Kumeran. You can visit locations multiple times, as - different characters. Locations that are unimportant in one chapter - may be of great importance in a later chapter. In general, the world - has a lot of depth, from diaries of the main characters to newspaper - articles to books on law. On the other hand, it could have used some - more beta-testing. There are several guess-the-verb puzzles and a quite - a few bugs; most of the bugs are just amusing, but at least one (in - chapter 3) can cause the game to become silently unwinnable for no - obvious reason if you do a certain action in the wrong place. - - -Pastoral Pitfalls (pp20.zip) Guy Marquardt - In this game you are the pastor of a Lutheran church; you need to - make it through the day fufilling all of your responsibilities - (which include visiting the sick, teaching a confirmation class, - preparing a sermon, and still finding time to pray) I haven't - finished this game, but the parts I've seen I've liked. The game - seems to have been well tested; it's mostly free of guess-the-verb - problems and bugs. It feels very open; you have a lot of freedom - in what order to do things (although some care is needed so you don't - run out of time). - XYZZY 9(preview) - - -The Multi-Dimensional Thief (mdthief1.zip) Joel Finch - [Summary/review by Audrey De Lisle] - You are a thief desiring to become a member of the Thieves' Guild. - The test for this is to find the way out of the house. This seems - rather easy, but it's not. One feature is a visit to OZ; another - feat is done while quite small. The amazing machine is fun to use - and you must learn how to use it to get in an otherwise closed room. - You can order things from a catalog and part of the game is to - figure out which items you need. I would recommend this game to - those who like a little humor with their puzzles. - [There is also a non-AGT version of this game.] - SPAG 2, 4, 9 - - diff --git a/app/src/main/jni/terps/agility/readme.dos b/app/src/main/jni/terps/agility/readme.dos deleted file mode 100644 index 9f697ae..0000000 --- a/app/src/main/jni/terps/agility/readme.dos +++ /dev/null @@ -1,184 +0,0 @@ -AGiliTY, notes for DOS ports ----------------------------------------- - -(For a general introduction to this program, see the file README.AGI) - - -COMMAND LINE - - To run an AGT game file, run *agil* with the game file name as an -argument; don't include any extensions. For example, to run MYGAME, enter - -C:\AGT> AGIL MYGAME - - Command line options can be seen by running agil without any -arguments, but most of them were intended for debugging the -interpreter and will not be of general interest. The one exception is -the -d command, which outputs metacommand debugging information which -will be of interest to authors developing AGT games. - - - -CONFIGURATION - - The DOS global configuration file is the file AGIL.CFG in the same -directory as the executable; it can be used to set options you want to -hold for all games run with AGiliTy. - - You can provide individual configuration of a particular game by -creating or editing the game-specific configuration file, which should -be in the same directory as the game data file(s) and should be named -.CFG; e.g. MYGAME.CFG. Options specified in the -game-specific file take precedence over ones in the global -configuration file. - - -The DOS port supports several additional options: - -BIOS, which causes all output to go through the BIOS routines. - -COLORS, which allows the interface color scheme to be - set. The syntax is - COLORS - e.g COLORS LIGHTGRAY YELLOW BLACK WHITE BLUE, which is the default. - The colors are black, blue, green, cyan, red, magenta, brown, - lightgray, darkgray, lightblue, lightgreen, lightcyan, lightred, - lightmagenta, yellow, and white. Only the first eight can be used - as the background colors; all sixteen can be used for the other three - settings. - (The spellings COLOURS, lightgrey, and darkgrey are also recognized.) - -COMPASS, which causes the possible exits to be listed on the status - line. - -NAVARROW-- Use the keys on the numeric keypad for entering - movement commands instead of for editing. - -KEY -- - Define the text to be inserted on the line when a given function key is - typed. can be 'F1', 'F2', 'F3', ..., 'F12'. (If NAVARROW is set, - then 'HOME', 'END', 'PGUP', 'PGDN', 'UP', 'DOWN', 'LEFT', 'RIGHT', - 'INS', 'DEL', 'PLUS', and 'MINUS' can also be redefined.) The - default definitions are listed below. A '+' at the end of the last - word of the text will be converted to a newline. - -HISTORY -- This specifies the size of the command history list. - A value of 0 indicates no limit (the interpreter will remember - every line you typed since the beginning of the game). For DOS, the - default is 10. E.g. - history 0 - history 20 - -PATH -- This should contain a space-separated list of directories - which will be searched for AGT games. - -BLOCK_CURSOR -- Use a block cursor instead of the usual flashing underbar. - -50_LINE -- Display in 50-line mode. - - - - -LINE EDITING - The following keys can be used when typing in commands: -, -- do what you would expect. -, -- Move left/right. - or -- Move to beginning of the line. - or -- Move to end of the line. -, -- Scroll through past commands. - -- Kill to end of line. - -- Yank back the last thing killed. - -- -- These can be configured with strings of your choice; - see the KEY option above. By default, they are: - F1: get - F2: drop - F3: examine - F4: read - F5: open - F6: close - F7: inventory+ - F8: look+ - F9: score+ - F10: help+ - F11: save+ - F12: restore+ - -If NAVARROW is set, then the keys on the numeric keypad will generate -generate movement commands instead of being used for editing; these -can also be redefined with KEY: - UP: n+ - DOWN: s+ - LEFT: w+ - RIGHT: e+ - HOME: nw+ - END: sw+ - PGUP: ne+ - PGDN: se+ - INS: enter+ - DEL: exit+ - PLUS: up+ - MINUS: down+ - - -MISCELLANEOUS - The program *agtout* prints out the contents of AGT game files, -in human readable format, writing the output to standard output. -Under DOS, you will probably want to redirect the output to a file and -then view it with an editor; e.g. - AGTOUT MYGAME > MYGAME.LST -which will cause the output to go to MYGAME.LST. - Running it without arguments will give a list of command line options. - - - As described in README.AGI, AGT game files can be converted to the AGX -format by using AGT2AGX.EXE. Just type (for example): - -C:\AGT> AGT2AGX MYGAME - -This will create the file MYGAME.AGX from the other game files -You can use the '-o' option to give the output file a different name. -For example: - -C:\AGT> AGT2AGX MYGAME -o THEGAME - -will cause MYGAME.DA1...MYGAME.DA6, MYGAME.TTL, etc. to be converted into -the file THEGAME.AGX - - -NOTES ON THE DIFFERENT DOS RELEASES - - There are now two binary releases for DOS: a 32-bit version and a -16-bit version. As of 1.0, only the 32-bit version is being actively -updated. - - The 16-bit compiler is packaged as "agil092olddos.zip"; its only -benifit is that it will run on old (pre-386) computers that won't -run the 32-bit version. If you actually are in this situation, you -should drop me a note so that I know you exist. - - The 32-bit version is built with the DJGPP compiler and packaged -with the supplementary program "cwsdpmi.exe", a freeware DPMI server -which should be left in the same directory as "agil.exe". More -information on DJGPP (including the source code to "cwsdpmi.exe") can -be found at - http://www.delorie.com/djgpp/ - -The copyright notice for CWSDPMI.EXE follows: - -================================================================== -CWSDPMI is Copyright (C) 1995-1997 Charles W Sandmann (sandmann@clio.rice.edu) - 1206 Braelinn, Sugar Land, TX 77479 - -This is release 4. The files in this binary distribution may be -redistributed under the GPL (with source) or without the source code -provided: - -* CWSDPMI.EXE or CWSDPR0.EXE are not modified in any way except via -CWSPARAM - -* Notice to users that they have the right to receive the source code -and/or binary updates for CWSDPMI. Distributors should indicate a -site for the source in their documentation. -================================================================== - \ No newline at end of file diff --git a/app/src/main/jni/terps/agility/readme.glk b/app/src/main/jni/terps/agility/readme.glk deleted file mode 100644 index 8388c38..0000000 --- a/app/src/main/jni/terps/agility/readme.glk +++ /dev/null @@ -1,421 +0,0 @@ -AGiliTy, notes for the Glk version ----------------------------------- - -(General information can be found in readme.agility) - - -Introduction ------------- - -This is a port of the AGiliTy interpreter to Glk. The complete interface -lives in the single file - - os_glk.c - -The main test and development system for the port is Linux, with Xglk as the -Glk library. - -Glk AGiliTy is configured to be as close as possible to the pure ANSI build. -This is because Glk is a cross-platform I/O library, so using pure ANSI gives -it the best chance of working on multiple Glk libraries. - - -Acknowledgments ---------------- - -Thanks to Robert Masenten, rcm-math@pacbell.net, for answering several queries -about porting AGiliTy to Glk, and for writing AGiliTy in the first place; Ben -Hines, bhines@alumni.ucsd.edu, for the Mac-specific portions of the Glk -porting code; and Andrew Plotkin, , for Glk, and for -putting me straight on a couple of the finer points of Glk operation. - - -Running Games -------------- - -The interpreter understands both standard AGT game files and "AGX format" -(AGiliTy file format) game files. Standard AGT games are distributed as a -collection of files, with different extensions (".d$$", ".da1", ".da2" and so -on). AGiliTy games use the extension ".agx". - -Give the name of the game to run at the system prompt. For example, if the -game is held in files "cosmos.d$$", "cosmos.da1", and so on, use - - glkagil cosmos - -If several builds of Glk AGiliTy are available, linked with a selection of Glk -libraries, they will be named appropriately, for example xagil, termagil, and -cheapagil. - -The interpreter prefers that filename extensions be lower-case, that is, -".da1", ".da2", ".agx", and so on, rather than ".DA1", ".DA2", and ".AGX". If -you are unpacking AGT files from ZIP archives, you may need to use unzip's '-L' -option to make sure that filename are extracted correctly. - -Having said that, there's a minor GLK-specific patch in the core AGiliTy -interpreter (filename.c, for what it's worth) that retries a file with an -uppercase extension if the expected lowercase name is not found. That should -help with archives unpacked without the '-L' option. Running a game then -becomes - - glkagil COSMOS - -Glk AGiliTy takes a small liberty with the C runtime on exit. It might cause -some problems, such as a core dump or abort, when the program exits on an -error condition. If you find that this happens on your system, you can either -rebuild to avoid this, as described below, or set a value for the environment -variable GLKAGIL_CLEAN_EXIT. - -As well as standard AGiliTy command line options, there are a number of Glk -Agility specific command line options that you can specify, to vary the way -that the game looks: - - -gf Force Glk to use only a fixed width font - -gp Allow Glk to use only a proportional font - -ga Try to use a suitable Glk font automatically - -gd Delay for the full period in Glk - -gh Delay for approximately half the period in Glk - -gn Turn off all game delays in Glk - -gr Turn off Glk text replacement - -gx Turn off Glk abbreviation expansions - -gs Display a short status window in Glk - -gl Display an extended status window in Glk - -gc Turn off Glk command escapes in games - -gD Turn on Glk port module debug tracing - -g# Test for clean exit (Glk module debugging only) - -See below for further information about what these options mean. - - -Compiling ---------- - -To compile Glk AGiliTy for Linux, first unpack the source files. You might -need to use the -a argument to unzip in order to convert text files for your -system. - -Edit Makefile.glk so that it has the right path to the Glk library you wish to -build with. If you want to build the IFP plugin, also edit the parts of -Makefile.glk that have paths to IFP components. - -To build a standalone version of Glk AGiliTy, use - - make -f Makefile.glk glkagil - -To build the IFP plugin, use - - make -f Makefile.glk agility-1.1.1.so - -To clean up and delete everything in the case of a build error, use - - make -f Makefile.glk clean - -Glk AGiliTy contains a few non-ANSI/ISO artifacts that might cause problems on -non-Linux systems: - - Fdopen(), dup(), and file descriptors, used to open save and restore - files, are not portable. You can turn off these features by defining - GLK_ANSI_ONLY in Makefile.glk. - - At times the module may indirectly call exit() from within an - atexit() handler. This is "undefined" in ANSI. The Linux and SVR4 - C runtime libraries behave well, but if you find it causes problems - (for example, an occasional core dump or abort on exit) you can turn - it off by defining GLK_CLEAN_EXIT in Makefile.glk. - -See the comments in the source for Glk AGiliTy for more information on these, -and the information on "-g#" later on in this readme file for details on how -to check for problems with exit() and atexit(). - -For building on the Mac platform, Ben Hines has supplied a set of Code-Warrior -and application specific settings in a resource file, for use with the Mac Glk -library. You should find this file in the source distribution under the name - - os_glk_MacResFile.hqx - -The source of Glk AGiliTy has changed somewhat since Ben created this resource -file, so it may, or may not, currently be fully functional. - - -Configuration -------------- - -Glk AGiliTy opens no global configuration file, and takes no special -configuration options. - -If you need to set options that can't be set with AGiliTy command-line flags, -you'll need to create a special file called .cfg alongside the other AGT -game files, or edit any existing .cfg. Glk AGiliTy will find this file. - - -Status Lines ------------- - -Glk AGiliTy displays a status window at the top of its display, providing the -Glk library it is using supports separate windows. The status window can show -either one or two lines, for normal or extended status. - -The first line of status is the standard information printed by the core -interpreter or the game, normally the location, and the game score and/or time. -The second line shows a list of exits available, and if in a game delay, a -waiting indicator. - -You can use the "-gs" option to select a short status display, and "-gl" to -select an extended status display. - -Where the Glk library does not support separate windows, Glk AGiliTy will -print the status line in "[...]" brackets at the beginning of any game output, -but only when it has changed since the last game turn. It will also only -print the short status display; to get a list of exits, use the AGiliTy -"listexits" command. - - -Expanding Abbreviations ------------------------ - -Many IF games systems allow a player to use single character abbreviations for -selected common commands, for example, 'x' for 'examine', 'l' for look, and so -on. - -AGiliTy expands many of these in the same way, but it's not completely -consistent with other well-known systems. To try to help with this, Glk -AGiliTy will automatically expand a selection of single character commands, -before passing the expanded string to the game as input. It expands a command -only if the first word of the command is a single letter, and one of the -following: - - 'c' -> "close" 'g' -> "again" 'i' -> "inventory" - 'k' -> "attack" 'l' -> "look" 'p' -> "open" - 'q' -> "quit" 'r' -> "drop" 't' -> "take" - 'x' -> "examine" 'y' -> "yes" 'z' -> "wait" - -If you want to suppress abbreviation expansion, you can prefix your input with -a single quote character (like putting literal strings into a spreadsheet). -If you do this, the Glk interface will strip the quote, then pass the rest of -the string to the main interpreter without any more changes. So for example, - - 'x something - -will pass the string "x something" back to the game, whereas - - x something - -will pass "examine something" back to the game. - -You can turn off abbreviation expansions with the command line option '-gx'. - - -Game Text Output ----------------- - -AGT games generally presume they are running on fixed width font, 80x25 IBM PC -displays. They expect to have this screen width on many occasions, and use -spaces, IBM box-drawing and other code page 437 characters, and other DOS -'tricks' to achieve certain effects with output text, creating line breaks as -needed. - -In comparison, Glk's basic text model is that the output library should take -care of text formatting. It behaves best when using a proportional font, and -sticks rigidly to ISO-8859 Latin 1 character encoding which, while it has -international characters in it, does not have box drawing characters. - -This leads to somewhat of a mismatch of requirements and capabilities for the -Glk version of AGiliTy. While Glk will work with fixed width fonts, it does -not necessarily offer any form of attributes or color for such fonts, making -the output appear one-dimensional and lifeless. On the other hand, the -assumption in games and the interpreter is that the font is fixed width, and -the screen is 80 columns wide. - -To attempt to smooth over this, Glk AGiliTy will try to guess whether a chunk -of game output text needs to be displayed in a fixed width font, or if it will -look okay when rendered in a proportional one. This is akin to a form of -"screen scrape": Glk AGiliTy buffers all of the text that the game outputs, -then runs over it with a set of functions that try to re-paragraph the text, -identify any tables or other areas that are likely to be sensitive to font -width, and finally print it out through Glk in what is hopefully an improved -format. - -Doing this involves some guesswork on the part of Glk AGiliTy, but in testing, -it seems to work well enough. - -You can use the "-ga" option to let Glk AGiliTy automatically select what -appears to be a suitable font for output, "-gf" to force it to always use a -fixed width font, or "-gp" to force it to always use a proportional font (if -the Glk library has one). You can also control it while in a game using the -"glk fonts" command. - -Note that some games _do_ hint at the type of font they can be used with, -though most don't. A game may tell the interpreter - - 1) that a fixed width font is required, or - 2) that a proportional font is acceptable, or - 3) nothing - -In the third case, the interpreter does not know whether a proportional font -can be used, or not. The majority of AGT games seem to fall into the third -case, and the interpreter rarely knows the font requirements of a game. - -Any game which does tell the interpreter what font it can use will cause Glk -AGiliTy to use that font style on startup, and ignore any value set with the -"-g" command line option. You may still however alter the font control with -"glk fonts" while in a game. - -In Glk libraries that have only fixed width fonts (for example, Glkterm, for -ncurses), you will see much less difference in the display with the different -values for font control, but it may still be useful if the text mode display -differs widely from AGT's anticipated 80x25 dimension. - -Since many games rely on there being 80 columns of display width, Glk AGiliTy -also offers a command to query the current display width. The command to use -is - - glk width - -entered at the game's ">" prompt. This prints the approximate width of the -display window (actually, it prints the width of the status window, but -assuming the fonts in use in each window are approximately the same, the result -will usually be close enough). Some Glk libraries are not able to return a -window width. - -In general, where a game has a strong requirement for fixed width font text, -80 columns or more of display width will probably be fine. - - -Message Replacements --------------------- - -Because Glk AGiliTy buffers all game output, and scans the buffer for ways to -try to improve text formatting, it can also replace some of the standard -AGiliTy interpreter messages with ones that stand out a little better in a Glk -display. - -For example, games usually start up with a message something like: - - This game is being executed by - AGiliTy: The (Mostly) Universal AGT Interpreter version 1.1.1 - Copyright (C) 1996-99,2001 by Robert Masenten - Glk version - -Glk AGiliTy will replace this with more or less the same text, but using -heading and emphasized text. It handles only a few messages in this way, -typically LISTEXIT, VERBOSE, and BRIEF responses, game title pages, and the -AGiliTy information page header. - -To turn this feature off, use the '-gr' command line option. - - -Game Delays ------------ - -In AGT games that use delays, these delays can become tiresome. By default, -Glk AGiliTy will delay for approximately half the time that the game specifies. - -You can vary this behavior with command line options: use "-gd" to make all -delays full length; "-gh" to make all delays short, approximately half length; -and "-gn" to turn off delays altogether. You can also change the delay mode -with "glk delays" while in a game. - -When the game is delaying, Glk AGiliTy displays a "Waiting..." indicator on -the right hand side of the second line of any status window. - -You can cancel a game delay by pressing the space bar while the "Waiting..." -indicator is active. This will stop the delay immediately, and also suppress -any further delays the game requests until it issues the next input line -prompt or requests other keyboard input. - -A few games might not play correctly with delays turned off, so you should -take a little care with this option. For example, a game could clear the -screen, print a message, delay for a short time, clear the screen again, and -continue. With delays turned off, Glk AGiliTy will not get the chance to -display the message. - -Glk AGiliTy will not implement game delays if the Glk library does not support -timers. - - -Interpreting Commands Locally ------------------------------ - -Glk AGiliTy will handle special commands if they are prefixed with the string -'glk'. It understands the following special commands: - - help Prints help on Glk special commands - summary Prints all current Glk settings - version Prints the Glk library and Glk port version - numbers - license Prints the Glk port license - - script on Starts recording the game text output sent - to the main game window - script off Turns off game text recording - inputlog on Starts recording input lines typed by the - player - inputlog off Stops recording input lines - readlog on Reads an input log file as if it had been - typed by a player; reading stops automatic- - ally at the end of the file - abbreviations on Turn abbreviation expansion on - abbreviations off Turn abbreviation expansion off - glk fonts auto, or - glk fonts automatic Let Glk AGiliTy determine the appropriate - font for a paragraph automatically - glk fonts fixed Print all output in a fixed width font - glk fonts variable, or - glk fonts proportional Print all output in a proportional font - width Print the approximate display width; AGT - games may expect at least 80 characters - statusline extended Show a two line, extended status display - statusline short Show a single line, short status display - replacements on Replace selected interpreter paragraphs with - improved formatted alternatives - replacements off Don't replace selected interpreter paragraphs - delays full [or on] Make all delays full length - delays short [or half] Make all delays approximately half length - delays none [or off] Turns off delays altogether - commands off Turn of Glk special commands; once off, there - is no way to turn them back on - -You can abbreviate these commands, as long as the abbreviation you use is -unambiguous. - -If for some reason you need to pass the string "glk" to the interpreter, you -can, as with abbreviations above, prefix it with a single quote character. - -You can turn off local command handling with the command line option '-gc'. - -If both abbreviation expansion and local command handling are turned off, there -is no need to use single quotes to suppress special interpreter features. - - -Transcripts and Input Logs --------------------------- - -AGiliTy games can themselves set up transcripts and input logs. However, the -meta-verbs to set them up can occasionally conflict with commands in the game. -It may therefore be more convenient to use Glk commands to create these logs. - -Any Glk AGiliTy transcript or input log is in addition to those that may be -set up by the main AGiliTy interpreter, so although not wildly useful, it's -possible to create two transcripts and input logs at the same time. - - -Glk AGiliTy Debug Options -------------------------- - -The command line option "-gD" turns on debugging in the AGiliTy Glk I/O module. -The output is really only useful when debugging Glk AGiliTy. - -The command line option "-g#" tests for clean program exit. Glk AGiliTy takes -a couple of liberties with the ANSI rules for exit handler functions. For -most systems, these don't cause any problems, but for some they might. - -To test to see if your system is affected, run Glk AGiliTy with "-g#". The -program will exit straight away, and if it exits cleanly (no core dumps or -other ugly program termination), everything is fine. Otherwise, you should -either recompile with GLK_CLEAN_EXIT defined, or set environment variable -GLKAGIL_CLEAN_EXIT to "true". - - --- - -Simon Baldwin, simon_baldwin@yahoo.com diff --git a/app/src/main/jni/terps/agility/readme.linux b/app/src/main/jni/terps/agility/readme.linux deleted file mode 100644 index 2281332..0000000 --- a/app/src/main/jni/terps/agility/readme.linux +++ /dev/null @@ -1,175 +0,0 @@ -AGiliTy, notes for the Linux version ----------------------------------------- - -(General information can be found in readme.agility) - -COMMAND LINE - To run an AGT game file, run *agil* with the game file name as an -argument; don't include any extensions. For example, to run 'mygame', enter - ->agil mygame - - The interpreter expects the filename extensions to be lower-case -('.da1', '.da2', and '.agx' rather than '.DA1', '.DA2', and '.AGX'). -If you are unpacking AGT files from ZIP archives, remember to use the -'-L' option to ensure this. - - Command line options can be seen by running agil without any -arguments, but most of them were intended for debugging the -interpreter and will probably not be of general interest. The one -possible exception is the -d command which outputs metacommand -debugging information; this might be of interest to authors developing -AGT games. - Under Linux this is sent to stderr; if stderr and stdin point to -the same device, it will send output through the interpreter's display -routines. - ------------ -COMPILING ------------ - To compile this, just unpack the source files somewhere and type "make". -This should automatically generate the three files agil, agtout, and agt2agx. -(If you are running on a non-32-bit platform, you will first need to delete -the line containing "#define FAST_FIXSIGN" in the Linux configuration in -config.h.) - - ---------------- -CONFIGURATION ---------------- - The Linux global configuration file is ~/.agilrc; the interpreter -will also look for game-specific configuration files, named -.cfg-- for example, 'mygame.cfg'-- in the same directory as -the other game files. - - The Linux version of AGiliTy supports several additional options: - -COLORTERM -- this can be used to specify terminal types that support - ANSI color; e.g. - colorterm console - colorterm xterm -This only works with the termcap version of AGiliTy, not with the -curses version. - -COMPASS -- Turn on listing of exits just below the status line. - -FONT -- Enable fonts. This is off by default since font changes - affect *all* virtual consoles. - -HISTORY -- This specifies the size of the command history list. - A value of 0 indicates no limit (the interpreter will remember - every line you typed since the beginning of the game); this is - the default. E.g. - history 0 - history 20 - -IBM_CHAR -- If you're using the regular Linux console, specifying this - will cause the interpreter to use the IBM character set for display; - this improves the appearance of a lot of AGT games. - -NAVARROW-- Use the keys on the numeric keypad for entering - movement commands instead editing. - -KEY -- -KEY -- - Define the text to be inserted on the line when a given function key is - typed. can be 'F1', 'F2', 'F3', ..., 'F12'. (If NAVARROW is set, - then 'HOME', 'END', 'PGUP', 'PGDN', 'UP', 'DOWN', 'LEFT', 'RIGHT', - 'INS', 'DEL', 'PLUS', and 'MINUS' can also be redefined.) - A '+' at the end of the last word of the text will be converted to a - newline. Otherwise, a space will be added on to the end. Extra whitespace - will be ignored. - -LOWER_FILE -- Force font, picture, and sound file names to be all - lower case, regardless of what case the game file has. - (This is useful since most AGT games were created under DOS, - which is not case-sensitive.) - -PATH -- This should contain a whitespace-separated list of directories - which will be searched for AGT games. - If the environmental variable AGT_PATH is set, its value will - override this option. AGT_PATH entries may be separated by colons - as well as whitespace. - -VIEWER -- Give the name of the program to be used - for viewing graphics files. (Most AGT illustrations are in the - PCX file format with nonstandard filename extensions, although AGT - theoretically also supports the FLI animation format.) - I've include a sample shell script, linux_pict, which chooses - between file viewers depending on the file-name extension. - Extensions currently recognized by AGiliTy: - gif, png, bmp, jpg, fli, flc, pcx - as well as all of the nonstandard PCX extensions (p13, p14, p19, etc.) - Note: if the program sends any output to stderr, it may confuse - AGiliTy's screen routines (which don't expect anyone else to be writing - to the screen). Ctrl-L should fix any problems. - - --------------- -LINE EDITING --------------- - The following keys can be used when typing in commands: -, -- do what you would expect. - or -- Move left. - or -- Move right. - or -- Move to beginning of the line. - or -- Move to end of the line. - or -- Scroll back through past commands - or -- Scroll forward through past commands. - -- Kill to end of line. - -- Yank back the last thing killed. - -- Redraw screen. - -- -- These can be configured with strings of your choice; - see the KEY option above. By default, they are: - F1: get - F2: drop - F3: examine - F4: read - F5: open - F6: close - F7: inventory+ - F8: look+ - F9: score+ - F10: help+ - F11: save+ - F12: restore+ - -If NAVARROW is set, then the keys on the numeric keypad will generate -generate movement commands instead of being used for editing; these -can also be redefined with KEY: - UP: n+ - DOWN: s+ - LEFT: w+ - RIGHT: e+ - HOME: nw+ - END: sw+ - PGUP: ne+ - PGDN: se+ - INS: enter+ - DEL: exit+ - PLUS: up+ - MINUS: down+ - - ---------------- -MISCELLANEOUS ---------------- - The program *agtout* prints out the "disassembled" contents of AGT -game files, in human readable format, writing to standard output. - Running it without arguments will give a list of command line options. - - AGT files can be converted into the new AGT format by running agt2agx. -By default, the new file will be named .agx; this can be -changed by using the -o option; e.g. -> agt2agx mygame -o thegame -will create a file called 'thegame.agx'. - - Script and log files can be piped to another program by putting a -'|' character before/after the program's command line (before for -files being written, after for files being read). - E.g. '|lpr' to send output to the print spooler. - - - - diff --git a/app/src/main/jni/terps/agility/runverb.c b/app/src/main/jni/terps/agility/runverb.c deleted file mode 100644 index beba21b..0000000 --- a/app/src/main/jni/terps/agility/runverb.c +++ /dev/null @@ -1,1563 +0,0 @@ -/* Runverb.c-- handles built-in verbs */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for AGiliTy, the (Mostly) Universal */ -/* AGT Interpreter */ - -/* - - This file contains several things: - i) The code for each of the built-in verbs, all prefixed with 'v_' - (so, for example, the code for DROP is in v_drop()). - ii) The main routine for checking and running player commands. - iii) The main routine for doing intelligent disambiguation. - - */ - -#include -#include -#include -#include - -#include "agility.h" -#include "interp.h" -#include "exec.h" - - - -/* ------------------------------------------------------------------- */ -/* VERBS: Functions that implement the predefined verbs. */ -/* ------------------------------------------------------------------- */ - -void v_look() -{ - do_look=1; -} - - -static void v_go(int dir) -/* 1=N, etc. */ -{ - int newloc, tmploc; - int i; -/* rbool has_seen;*/ - - dir--; - - tmploc=loc; - newloc=room[loc].path[dir]; - if (newloc>exitmsg_base) /* Customized error messages */ - { msgout(newloc-exitmsg_base,1); - return;} - if (newloc<0) { /* Run autoverb */ - int v0; - - v0=verb_code(-newloc); - if (v0==0) { - if (!PURE_ERROR) - writeln("GAME ERROR: Invalid verb."); - return; - } - clear_stack(); - (void)scan_metacommand(0,v0,0,0,0,NULL); - return; - } - if (newlocmaxroom) { - if (!PURE_ERROR) - writeln("GAME ERROR: Invalid room number."); - return;} - - /* Then need to check for hostile creatures */ - /* (If we are going back to the room we came from and not PURE_HOSTILE - is set, then we don't need to check this) */ - - if (dir!=12 && (PURE_HOSTILE || newloc!=oldloc+first_room)) - creatloop(i) - if (creature[i].location==loc+first_room && - creature[i].hostile) { - parse_rec tmpcreat; - curr_creat_rec=&tmpcreat; - make_parserec(i+first_creat,&tmpcreat); - sysmsg(14,"$The_c$$c_name$ blocks $your$ way."); - curr_creat_rec=NULL; - return; - } - -/* has_seen=room[newloc-first_room].has_seen;*/ - goto_room(newloc-first_room); - if (dir!=12 && newloc!=tmploc+first_room) /* SPECIAL */ - oldloc=tmploc; /* Can backtrack as long as not from special */ - if (dir==12 && special_ptr[loc].size>0) - /* need to print special of NEW room */ - runptr(loc,special_ptr,"INTERNAL ERROR: Invalid special ptr",0,NULL,NULL); - - if (tmploc==loc && dir==12) /* SPECIAL that sends us nowhere */ - do_look=0; -} - - - - -static void v_noun(int vc,parse_rec *nounrec) -/* PUSH, PULL, TURN, PLAY, CHANGE_LOCATIONS */ -{ - int dobj; - - dobj=p_obj(nounrec); - - if (vc==0 && !it_pushable(dobj)) { - int msgnum; - if (!tcreat(dobj)) msgnum=172; - else if (creature[dobj-first_creat].gender==0) - if (creature[dobj-first_creat].hostile) msgnum=167; - else msgnum=168; - else - if (creature[dobj-first_creat].hostile) msgnum=169; - else msgnum=170; - sysmsgd(msgnum,"$You$ can't $verb$ $the_n$$noun$.",nounrec); /* Push */ - return; - } - if (vc==1 && !it_pullable(dobj)) { /* Pull */ - sysmsgd(tcreat(dobj)?173:175,"$You$ can't $verb$ $the_n$$noun$.", - nounrec); - return; - } - if (vc==2 && !it_turnable(dobj)) { /* Turn */ - sysmsgd(tcreat(dobj)?164:166,"$You$ can't $verb$ $the_n$$noun$.", - nounrec); - return; - } - if (vc==3 && !it_playable(dobj)) { /* Play */ - sysmsgd(tcreat(dobj)?176:178,"$You$ can't $verb$ $the_n$$noun$.", - nounrec); - return; - } - if (matchclass(dobj,room[loc].key)) { /* SPECIAL triggered */ - v_go(13); - return; - } - if (vc==4) { - sysmsgd(tcreat(dobj)?180:181,"Nothing happens.",nounrec); - return; - } - /* otherwise, print out relevent description. */ - if (vc==0) /* Push */ - runptr(dobj-first_noun,push_ptr, - "$You$ $verb$ $the_n$$noun$ for a while, but nothing happens.", - 171,nounrec,NULL); - if (vc==1) /* Pull */ - runptr(dobj-first_noun,pull_ptr, - "$You$ $verb$ $the_n$$noun$ a bit, but nothing happens.",174, - nounrec,NULL); - if (vc==2) /* Turn */ - runptr(dobj-first_noun,turn_ptr, - "$You$ $verb$ $the_n$$noun$, but nothing happens.",165, - nounrec,NULL); - if (vc==3) /* Play */ - runptr(dobj-first_noun,play_ptr, - "$You$ $verb$ $the_n$$noun$ for a bit, but nothing happens.",177, - nounrec,NULL); -} - -static void v_talk(int vc,parse_rec *nounrec,parse_rec *objrec) - /* vc==1 if ASK, 0 if TALK TO */ -{ - int dobj,iobj; - - dobj=p_obj(nounrec); - iobj=p_obj(objrec); - - if (nounrec->info==D_END || nounrec->info==D_AND) - {alt_sysmsg(211,"Who $are$ $you$ addressing?",nounrec,objrec);return;} - if (!genvisible(nounrec)) - {alt_sysmsg(212,"Who $are$ $you$ addressing?",nounrec,objrec);return;} - if (!tcreat(dobj)) - {alt_sysmsg(vc?161:156,"That isn't animate.",nounrec,objrec);return;} - if (vc==0) - runptr(dobj-first_creat, - talk_ptr,"$Your$ conversational gambit is ignored.", - creature[dobj-first_creat].gender==0 ? 157 : (iobj==0?159:158), - nounrec,objrec); - if (vc==1) - runptr(dobj-first_creat,ask_ptr,"$You$ get no answer.", - iobj==0?162:163,nounrec,objrec); -} - -static void v_examine(parse_rec *nounrec) -{ - if (!islit()) { - sysmsgd( room[loc].light==1?19:20,"It's too dark to see anything.", - nounrec); - } - it_describe(nounrec->obj); -} - -static void v_view(parse_rec *nounrec) /* VIEW a picture */ -{ - int i; - int dobj; - dobj=p_obj(nounrec); - - if (tnoun(dobj) && noun[dobj-first_noun].pict!=0) - pictcmd(1,pictable[noun[dobj-first_noun].pict-1]); - else if (tcreat(dobj) && creature[dobj-first_creat].pict!=0) - pictcmd(1,pictable[creature[dobj-first_creat].pict-1]); - else if (dobj==-ext_code[wscene] && room[loc].pict!=0) - /* View the room picture */ - pictcmd(1,pictable[room[loc].pict-1]); - else { /* room.PIX_bits */ - if (dobj<0) - for(i=0;i0) - runptr(dobj-first_noun,text_ptr, - "INTERNAL ERROR: Invalid read pointer",0,NULL,NULL); - else - runptr(dobj-first_noun,noun_ptr,"$You$ learn nothing new.", - 193,nounrec,NULL); -} - - -static void v_eat(int vc,parse_rec *nounrec) -{ - int dobj; - dobj=p_obj(nounrec); - - if (!tnoun(dobj)) - {sysmsgd(124,"That can't be consumed.",nounrec);return;} - if (vc==0 && !noun[dobj-first_noun].edible) - {sysmsgd(124,"$You$ can't eat that.",nounrec);return;} - if (vc==1 && !noun[dobj-first_noun].drinkable) - {sysmsgd(127,"$You$ can't drink that.",nounrec);return;} - - sysmsgd(128,"$You$ $verb$ $the_n$$adjective$ $noun$.",nounrec); - - if (noun[dobj-first_noun].movable) it_destroy(dobj); - if (noun[dobj-first_noun].poisonous) { - sysmsgd(129,"Unfortunatly, $n_pro$ $n_was$ poisonous.",nounrec); - deadflag=1; - } -} - - -static int can_wear(parse_rec *objrec) -/* assumes objrec is in the noun range */ -{ - static char *errs[]={ - "$The_n$$noun$ $n_is$ far too heavy to wear.", - "$You're$ already loaded down with too much weight as it is." - "$The_n$$noun$ $n_is$ too big and bulky to wear.", - "$You're$ wearing too much to also wear $the_n$$noun$."}; - int n; - - if (!it_canmove(objrec->obj)) { - sysmsgd(202,"$You$ can't move $the_n$$noun$.",objrec); - } - n=check_fit(objrec->obj,1000); - if (n==FIT_OK /* || n>=FIT_SIZE */ ) return 1; - sysmsgd(37+n,errs[n-1],objrec); - return 0; -} - - -static int can_carry(parse_rec *objrec) -/* assumes objrec is in the noun range */ -{ - static char *errs[]={ - "$The_n$$noun$ $n_is$ far too heavy to carry.", - "$You're$ already carrying too much weight as it is.", - "$The_n$$noun$ $n_is$ too big and bulky to pick up.", - "$You're$ carrying too much to also carry $the_n$$noun$."}; - int n; - - n=check_fit(objrec->obj,1); - if (n==FIT_OK) return 1; - sysmsgd(30+n-1,errs[n-1],objrec); - return 0; -} - -static int v_get(parse_rec *objrec) -{ - int cnt,i; - int obj; - - obj=objrec->obj; - - /* If there is a hostile creature in the room and PURE_GETHOSTILE isn't - set, then don't let the player pick up anything */ - if (!PURE_GETHOSTILE) - creatloop(i) - if (creature[i].location==loc+first_room && - creature[i].hostile) { - parse_rec tmpcreat; - make_parserec(i+first_creat,&tmpcreat); - curr_creat_rec=&tmpcreat; - sysmsgd(14,"$The_c$$c_name$ blocks $your$ way.",objrec); - return 0; - } - - if (objrec->info==D_ALL) { - cnt=0; - nounloop(i) - if (noun[i].location==loc+first_room && noun[i].movable) { - /* Need to add weight/size check */ - parse_rec tmpnoun; - make_parserec(i+first_noun,&tmpnoun); - if (can_carry(&tmpnoun)) { - get_obj(i+first_noun); - sysmsgd(8,"$You$ pick up $the_n$$adjective$ $noun$.",&tmpnoun); - } - cnt++; - } - if (cnt==0) { - sysmsgd(24,"There doesn't seem to be anything here to take.",objrec); - return 0; - } else return 1; - } - if (it_door(obj,objrec->noun)) { - if (room[loc].locked_door) - sysmsgd(25,"You can't pick up the door.",objrec); - else - sysmsgd(26,"You can't pick up the doorway.",objrec); - return 0; - } - if (!tnoun(obj) || !noun[obj-first_noun].movable) - { - sysmsgd( tcreat(obj)?(creature[obj-first_creat].hostile?34:35):29, - "$You$ can't pick $the_n$$noun$ up.", objrec ); - return 0; - } - if (it_loc(obj)==1) - {sysmsgd(27,"$You$ already have $the_n$$noun$.",objrec);return 1;} - if (!can_carry(objrec)) return 0; - get_obj(obj); - sysmsgd(8,"$You$ pick up $the_n$$adjective$ $noun$.",objrec); - return 1; -} - -static int v_remove(parse_rec *objrec) -{ - int i,j; - integer obj; - - obj=objrec->obj; - if (objrec->info==D_ALL) { - if (player_worn==0) { - sysmsgd(46,"$You're$ not wearing anything.",objrec); - return 0;} - safecontloop(i,j,1000) - if (it_canmove(i)) { - parse_rec tmp; - if (PURE_WEAR) drop_obj(i); - else it_move(i,1); /* Really need to check to make sure - we haven't exceeded weight requirement - here */ - make_parserec(i,&tmp); - sysmsgd(9,"$You$ take off $the_n$$noun$.",&tmp); - } - return 1; - } - if (it_loc(obj)!=1000) - {sysmsgd(213,"$You're$ not wearing that.",objrec);return 0;} - if (!it_canmove(obj)) { - sysmsgd(201,"$You're$ not able to remove $the_n$$noun$.",objrec);return 0; - } - sysmsgd(9,"$You$ take off $the_n$$noun$.",objrec); - if (PURE_WEAR) drop_obj(obj); /* Required to be consistent w/ AGT */ - else v_get(objrec); /* (trap can_carry problems) */ - return 1; -} - -static void v_drop(parse_rec *objrec) -{ - int i, j; - int obj; - obj=objrec->obj; - - if (obj==ALL_MARK) { - if (player_contents==0) - sysmsgd(45,"$You$ don't have anything to drop.",objrec); - else safecontloop(i,j,1) { - parse_rec tmp; - make_parserec(i,&tmp); - drop_obj(i); - sysmsgd(9,"$You$ $verb$ $the_n$$noun$.",&tmp); - } - return; - } - if (!it_possess(obj)) - {sysmsgd(47,"$You$ don't have that.",objrec);return;} - if (!it_canmove(obj)) { - sysmsgd(200,"$You're$ not able to $verb$ $the_n$$noun$.",objrec); - return; - } - if (it_loc(obj)==1000) { - sysmsgd(216,"(Taking it off first)",objrec); - } - sysmsgd(9,"$You$ $verb$ $the_n$$noun$.",objrec); - drop_obj(obj); -} - -static void v_wear(parse_rec *objrec) -{ - int i, cnt; - int obj; - - obj=objrec->obj; - if (objrec->info==D_ALL) { - cnt=0; - nounloop(i) - if (noun[i].location!=1000 && visible(i+first_noun) && - noun[i].wearable) { - parse_rec tmp; - make_parserec(i+first_noun,&tmp); - if (can_wear(&tmp)) { - it_move(i+first_noun,1000); - sysmsgd(42,"$You$ put on $the_n$$adjective$ $noun$.",&tmp); - } - cnt++; - } - if (cnt==0) - sysmsgd(36,"There doesn't seem to be anything $you$ can wear here.", - objrec); - return; - } - if (!tnoun(obj) || !noun[obj-first_noun].wearable) { - sysmsgd( tcreat(obj)?(creature[obj-first_creat].hostile?43:44):203, - "$You$ can't wear that.",objrec); - return; - } - if (it_loc(obj)==1000) - {sysmsgd(37,"$You$ $are$ already wearing $the_n$$noun$.",objrec);return;} - if (!can_wear(objrec)) return; - sysmsgd(42,"$You$ put on $the_n$$noun$.",objrec); - it_move(obj,1000); -} - -static int do_lock(uchar l_or_u, - parse_rec *nounrec, parse_rec *objrec) - /* l_or_u: 0=lock, 1=unlock */ -{ - int dnoun; - int dobj, iobj; - word dobj_word; - - dobj=p_obj(nounrec); - iobj=p_obj(objrec); - dobj_word=nounrec->noun; - - if (it_door(dobj,dobj_word) && l_or_u!=room[loc].locked_door) { - /* That is, trying to unlock an unlocked door, or lock a locked one. */ - if (l_or_u==0) - alt_sysmsg(114,"The door is already locked.",nounrec,objrec); - else - alt_sysmsg(105, - "There doesn't seem to be any door here that need unlocking.", - nounrec,objrec); - return 0; - } - if (!it_lockable(dobj,dobj_word)) { - alt_sysmsg( (l_or_u ? 108 : 118 ),"$The_n$$noun$ can't be $verb$ed.", - nounrec,objrec); - return 0; - } - if (tnoun(dobj) && noun[dobj-first_noun].closable && it_open(dobj)) { - if (l_or_u==0) { - alt_sysmsg(120,"$You$ will need to close $the_n$$noun$ first.", - nounrec,objrec); - return 0; - } else { /* l_or_u==1 */ - alt_sysmsg(110,"$The_n$$noun$ $n_is$ already open!", - nounrec,objrec); - return 0; - } - } - if (it_locked(dobj,dobj_word)!=l_or_u) { - alt_sysmsg( (l_or_u ? 109 : 119),"$The_n$$noun$ $n_is$ already $verb$ed", - nounrec,objrec); - return 0; - } - if (it_door(dobj,dobj_word) || dobj<0) { /* i.e. a door */ - alt_sysmsg( (l_or_u ? 104 :115), - "$You$ try to $verb$ $the_n$$noun$, but fail.", - nounrec,objrec); - return 0; - } - dnoun=dobj-first_noun; - if (iobj==0) { - alt_sysmsg( (l_or_u ? 106 : 208), - "$You$ will need to use something to do that.", - nounrec,objrec); - return 0; - } - if (!player_has(iobj)) { - alt_sysmsg( (l_or_u ? 107 : 117), "$You$ don't have $the_o$$object$.", - nounrec,objrec); - return 0; - } - if (!matchclass(iobj,noun[dnoun].key)) { - alt_sysmsg( l_or_u ? (vb==15?80:111) : 121, /* vb 15 is OPEN */ - "$The_o$$object$ doesn't fit.",nounrec,objrec); - return 0; - } - noun[dnoun].locked=!l_or_u; - return 1; -} - -static void v_lock(uchar l_or_u,parse_rec *nounrec,parse_rec *objrec) -/* First argument indicates lock or unlock-- 0=lock, 1=unlock */ -{ - if (!do_lock(l_or_u,nounrec,objrec)) return; - /* Need to fix these messages: */ - alt_sysmsg( (l_or_u ? 112 : 122), - "$You$ $verb$ $the_n$$noun$ with $the_o$$object$.", - nounrec,objrec); -} - -static void v_open(parse_rec *nounrec,parse_rec *objrec) -/* OPEN ... WITH ... */ -{ - int dnoun; - int dobj,iobj; - - dobj=p_obj(nounrec); - iobj=p_obj(objrec); - - dnoun=dobj-first_noun; - if (it_door(dobj,nounrec->noun)) { - if (room[loc].locked_door) - alt_sysmsg(71,"$The_n$$noun$ $n_is$ locked.", - nounrec,objrec); - else - alt_sysmsg(72,"$The_n$$noun$ $n_is$ already open.", - nounrec,objrec); - return; - } - if (it_open(dobj)) { - alt_sysmsg(78,"$The_n$$noun$ $n_is$ already open.",nounrec,objrec); - return; - } - if (!tnoun(dobj) || !noun[dnoun].closable) { - alt_sysmsg(77,"$You$ can't open $the_n$$noun$.",nounrec,objrec); - return; - } - if (iobj!=0) /* Need to do unlock action */ - { - if (!do_lock(1,nounrec,objrec)) return; - /* If something goes wrong, return */ - } - if (noun[dnoun].lockable && noun[dnoun].locked) { - alt_sysmsg(79,"It is locked.",nounrec,objrec); - return; - } - noun[dnoun].open=1; - if (iobj!=0) /* Obviously these messages need improvement */ - alt_sysmsg(81,"$You$ have opened $the_n$$noun$ with $the_o$$object$.", - nounrec,objrec); - else alt_sysmsg(82,"$You$ have opened $the_n$$noun$.",nounrec,objrec); - if (noun[dnoun].contents!=0) - alt_sysmsg(187,"Inside, $you$ see the following:",nounrec,objrec); - print_contents(dobj,1); -} - -static void v_close(parse_rec *nounrec) -{ - int dobj; - dobj=nounrec->obj; - - if (it_door(dobj,nounrec->noun)) { - if (room[loc].locked_door) - sysmsgd(84,"The door is already closed.",nounrec); - else - sysmsgd(85,"That apparently can't be closed.",nounrec); - return; - } - if (!it_open(dobj)) { - sysmsgd(88,"$The_n$$noun$ $n_is$ already closed.",nounrec); - return; - } - if (!tnoun(dobj) || !noun[dobj-first_noun].closable) { - sysmsgd(87,"$You$ can't close $the_n$$noun$.",nounrec); - return; - } - noun[dobj-first_noun].open=0; - sysmsgd(89,"$You$ have closed $the_n$$noun$.",nounrec); -} - - -static void v_light(int newstate,parse_rec *nounrec) -{ - int dobj; - dobj=p_obj(nounrec); - - if (!tnoun(dobj) || !noun[dobj-first_noun].light) { - sysmsgd(newstate?135:140,"$You$ can't $verb$ $the_n$$noun$.",nounrec); - return; - } - dobj-=first_noun; - if (noun[dobj].on==newstate) { - if (newstate) - sysmsgd(136,"$The_n$$noun$ $n_is$ already lit.",nounrec); - else sysmsgd(141, - "$The_n$$noun$ $n_is$n't lit, so $you$ can't extinguish $n_indir$", - nounrec); - return; - } - noun[dobj].on=newstate; - if (newstate) sysmsgd(138,"$The_n$$noun$ $n_is$ now lit.",nounrec); - else sysmsgd(143,"$The_n$$noun$ $n_is$ no longer lit.",nounrec); -} - -static void v_turn(word prep, parse_rec *nounrec) -{ - int newstate; /* 1=on, 0=off */ - int dobj; - dobj=p_obj(nounrec); - - newstate=(prep==ext_code[won]); /* ON or OFF ? */ - if (!it_turnable(dobj) && !nounattr(dobj,light)) { - sysmsgd(newstate?209:210, - "$You$ can't turn $the_n$$noun$ $prep$.",nounrec); - return; - } - if (matchclass(dobj,room[loc].key)) { /* SPECIAL triggered */ - v_go(13); - return; - } - if (!tnoun(dobj)) { /* This should be redundant */ - writeln("INTERNAL ERROR: Non-noun turn on/off not supported"); - return; - } - dobj-=first_noun; - if (noun[dobj].on==newstate) { - sysmsgd(newstate?137:142,"$The_n$$noun$ $n_is$ already $prep$.", - nounrec); - return; - } - noun[dobj].on=newstate; - sysmsgd(newstate?139:144,"$The_n$$noun$ $n_is$ now $prep$.",nounrec); -} - - - -static void v_attack(uchar missile,parse_rec *targrec,parse_rec *weprec) -/* Missile=1 if actually firing a weapon. */ -{ - int targ, wep; - targ=targrec->obj; - wep=weprec->obj; - - /* The following fix really belongs in the parser, but it might - break some games to do this translation before running metacommands */ - if (missile && targ==0) /* SHOOT */ - if (!tnoun(wep) || !noun[wep-first_noun].shootable) - {targ=wep; targrec=weprec; wep=0;} - - curr_creat_rec=targrec; /* So error messages will print properly */ - if (wep>0 && !player_has(wep)) { - alt_sysmsg(98,"(Getting $the_o$$object$ first)",targrec,weprec); - if (!v_get(weprec)) return; - } - if ((targ>0 && !tcreat(targ)) || targ<0) { - alt_sysmsg(missile ? 90 : 93, - "It only makes sense to attack living things.", - targrec,weprec); - return; - } - if (missile) { - if (wep==0) { - sysmsgd(94,"It's not clear what $you$ want to $verb$ with.",targrec); - return; - } - else if (!tnoun(wep) || !noun[wep-first_noun].shootable) { - alt_sysmsg(it_isweapon(wep)?96:95, - "$The_o$$object$ doesn't seem to be able to fire.", - targrec,weprec); - return; - } - else if (noun[wep-first_noun].num_shots<=0) { - alt_sysmsg(97,"$The_o$$object$ $o_is$ out of ammunition.", - targrec,weprec); - return;} - else noun[wep-first_noun].num_shots--; - } - - if (targ==0) { - if (!missile) { - alt_sysmsg(206,"Attack what???",NULL,weprec); - return; - } - else { - alt_sysmsg(188,"$You$ fire a shot into the air.",NULL,weprec); - return; - } - } - - if (wep==0) { /* and !missile, but that's taken care of above */ - sysmsgd(creature[targ-first_creat].hostile?91:92, - "$You$ attack $the_n$$noun$ with $your$ bare hands, but $n_pro$ " - "evades $your$ attack.",targrec); - return; - } - - if (matchclass(wep,creature[targ-first_creat].weapon)) - { - if (missile) - alt_sysmsg(creature[targ-first_creat].hostile?99:101, - "$You$ shoot $the_n$$noun$; " - "$n_pro$ vanishes in a cloud of red smoke." - ,targrec,weprec); - else - alt_sysmsg(creature[targ-first_creat].hostile?49:53, - "$You$ kill $the_o$$object$; " - "$o_pro$ vanishes in a cloud of red smoke.", - weprec,targrec); - it_destroy(targ); - if (!missile) drop_obj(wep); - return; - } - else { - if (!missile) { - int msgnum; - if (creature[targ-first_creat].hostile) { - alt_sysmsg(50,NULL,weprec,targrec); /* Preliminary message */ - msgnum=51; - } else msgnum=54; - if (noun[wep-first_noun].drinkable) { /* i.e. a liquid */ - alt_sysmsg(msgnum+1,"$You$ splash $the_o$$object$ with " - "$the_n$$noun$, but the liquid quickly evaporates " - "without noticable effect.",weprec,targrec); - it_destroy(wep); - } else { - alt_sysmsg(msgnum, - "$You$ strike at $the_o$$object$ with $the_n$$noun$, " - "but $your$ weapon bounces off of $o_indir$ harmlessly", - weprec,targrec); - drop_obj(wep); - } - } - else - alt_sysmsg(creature[targ-first_creat].hostile?100:102 , - "$You$ fire at $the_n$$noun$ with $the_o$$object$, but $your$ " - "shots don't seem to have any effect.",targrec,weprec); - - if (creature[targ-first_creat].hostile && - ++creature[targ-first_creat].counter>= - creature[targ-first_creat].threshold) - { - alt_sysmsg(204,"$The_n$$noun$ counterattacks! $N_pro$ fights " - "viciously and $you$ $are$ unable to defend $your$self " - "against $n_indir$.",targrec,weprec); - deadflag=1; - } - } -} - -/* child_proc is true if v_put is being called by v_put, and so - shouldn't print success messages */ -static rbool v_put(parse_rec *nounrec,word prep, - parse_rec *objrec,rbool child_proc) -{ - rbool in_prep; - int dobj,iobj; - - dobj=p_obj(nounrec); - iobj=p_obj(objrec); - - in_prep=(prep==ext_code[win] || prep==ext_code[winto] - || prep==ext_code[winside]); - - if (prep==0 || iobj==0) - { v_drop(nounrec); return 1;} - if (!tnoun(dobj)) { - alt_sysmsg(tcreat(dobj)?11:10, - "$You$ can't do that with $the_n$$noun$.", - nounrec,objrec); - return 0; - } - if (!noun[dobj-first_noun].movable) { - alt_sysmsg(61,"$You$ can't move $the_n$$adjective$ $noun$.", - nounrec,objrec); - return 0; - } - if (tcreat(iobj)) { - alt_sysmsg(189,"$The_o$$object$ doesn't want $n_indir$.", - nounrec,objrec); - return 0; - } - if (!tnoun(iobj)) { - alt_sysmsg(tcreat(iobj)?12:64, - "$You$ can't put something $prep$ $the_o$$object$.", - nounrec,objrec); - return 0; - } - if (dobj==iobj) { - alt_sysmsg(62,"$You$ can't put something $prep$ $n_indir$self.", - nounrec,objrec); - return 0; - } - if (!it_open(iobj) && in_prep) { - alt_sysmsg(65,"$The_o$$object$ $o_is$n't open.",nounrec,objrec); - return 0; - } - if (player_has(iobj) && !in_prep) { - alt_sysmsg(is_within(iobj,1,0)?68:69, - "$You$ can't put $the_n$$noun$ $prep$ something that $you$ " - "$are$ carrying.",nounrec,objrec); - return 0; - } - - if (in_prep) { /* PUT IN */ - if (check_fit(dobj,iobj)!=FIT_OK) { - alt_sysmsg(66,"$You$ can't fit $the_n$$noun$ into $the_o$$object$.", - nounrec,objrec); - return 0; - } - if (it_loc(dobj)==1000) - alt_sysmsg(216,"(Taking $n_indir$ off first)",nounrec,objrec); - it_move(dobj,iobj); - } - else { /* PUT with a preposition other than IN */ - int parent; - - parent=it_loc(iobj); - if (!troom(parent)) { - parse_rec parent_rec; - make_parserec(parent,&parent_rec); - if (!v_put(nounrec,ext_code[win],&parent_rec,1)) return 0; - } - else { - if (it_loc(dobj)==1000) - alt_sysmsg(216,"(Taking $n_indir$ off first)",nounrec,objrec); - drop_obj(dobj); - } - dobj-=first_noun; - assert(noun[dobj].pos_prep==0); /* v_put should have ensured this */ - noun[dobj].pos_prep=prep; - noun[dobj].pos_name=it_name(iobj); - if (iobj>0) noun[dobj].nearby_noun=iobj; - } - if (!child_proc) - alt_sysmsg(67,"$You$ place $the_n$$noun$ $prep$ $the_o$$object$.", - nounrec,objrec); - return 1; -} - - -static void v_throw(parse_rec *nounrec,word prep,parse_rec *objrec) -/* at, to, in, into, across, inside */ -{ - int dobj,iobj; - dobj=p_obj(nounrec); - iobj=p_obj(objrec); - - /* Need to check to see what the preposition is-- if it is AT - then we should send it to attack routine. */ - if (!player_has(nounrec->obj)) { - alt_sysmsg(47,"$You$ don't have $the_n$$noun$.",nounrec,objrec); - return; - } - if (prep==0) { - v_drop(nounrec); - return; - } - if (prep!=ext_code[wat]) - v_put(nounrec,prep,objrec,0); - else /* prep is AT */ - if (!noun[dobj-first_noun].movable) { - alt_sysmsg(215,"$You$ can't move $the_n$$adjective$ $noun$.", - nounrec,objrec); - return; - } - if (tcreat(iobj)) /* If a creature, treat as an attack */ - v_attack(0,objrec,nounrec); - else { /* THROW AT somethin inanimate */ - if (dobj==iobj) { - alt_sysmsg(56,"$You$ can't $verb$ $the_n$$noun$ $prep$ $n_indir$self.", - nounrec,objrec); - return; - } - if (it_loc(dobj)==1000) - alt_sysmsg(216,"(Taking it off first)",nounrec,objrec); - - if (tnoun(dobj) && noun[dobj-first_noun].drinkable) { - /* A liquid */ - if (tnoun(iobj) && noun[iobj-first_noun].open) - alt_sysmsg(58,"$You$ throw $the_n$$noun$ into $the_o$$object$, " - "but $n_pro$ quickly evaporates.", - nounrec,objrec); - else - alt_sysmsg(57,"$The_n$$noun$ splashes on $the_o$$object$ but " - "quickly evaporates.",nounrec,objrec); - it_destroy(dobj); - } else { /* _Not_ a liquid: */ - if (tnoun(iobj) && noun[iobj-first_noun].open) - if (check_fit(dobj,iobj)) { - alt_sysmsg(60,"$The_n$$noun$ lands inside $the_o$$object$.", - nounrec,objrec); - it_move(dobj,iobj); - return; - } else { - alt_sysmsg(205,"You $verb$ $the_n$$noun$ into $the_o$$object$, " - "but there isn't enough room and $n_pro$ falls out.", - nounrec,objrec); - } else - alt_sysmsg(59,"$The_n$$noun$ bounces off $the_o$$object$.", - nounrec,objrec); - /* At this point, either the object is closed or doesn't have enough - room */ - it_move(dobj,first_room+loc); - } - } -} - - - -void v_inventory(void) -{ - if (player_contents!=0) { - sysmsg(130,"$You're$ carrying:"); - print_contents(1,1); /* obj=1=self, ind_lev=1 */ - } else sysmsg(131,"$You$ $are$ empty-handed."); - if (player_worn!=0) { - sysmsg(132,"$You're$ wearing:"); - print_contents(1000,1); - } -} - - - - - -static void v_quit(void) -{ - sysmsg(145,"Are you sure you want to quit?"); - if (yesno("")) { - sysmsg(146,NULL); - quitflag=1; - } -} - -const char dirname[12][10]={"north","south","east","west", - "northeast","northwest","southeast","southwest", - "up","down","in","out"}; - -void v_listexit(void) -{ - int i, j,k; - - if (!islit()) { - sysmsg(23,"It is too dark to see anything.");return;} - j=k=0; - for(i=0;i<12;i++) - if (room[loc].path[i]!=0) k++; - if (k==0) - sysmsg(224,"There are no immediately visible exits."); - else { - sysmsg(225,"There are exits to"); - for(i=0;i<12;i++) - if (room[loc].path[i]!=0) { - j++; - if (j>1) writestr(", "); - if (j>1 && j==k) writestr("or "); - if (i<8) writestr("the "); - writestr(dirname[i]); - } - writeln("."); - } -} - - -static void v_yell(void) -{ - sysmsg(150,"YAAAAEEEEEEEEOOOOOOUUUUUAAAAHHHHHH!!!!!"); -} - - - -/* ------------------------------------------------------------------- */ -/* VERB EXECUTION AND GRAMMER CHECKING */ - - -static int checkgram(int vb,int dobj,word prep, int iobj, rbool redir_flag) -{ - int i; - int msgnum; - - /* We turn off certain sorts of grammar checking if either PURE_GRAMMAR - is set or there has been signicant redirection. */ - if (redir_flag<2) redir_flag=0; - if (PURE_GRAMMAR) redir_flag=1; - - /* First of all, no constraints on dummy_verb grammer */ - if (vb>=BASE_VERB && vb0) - && vb!=OLD_VERB+11) - { - if (redir_flag) return 0; /* Original AGT doesn't check this. */ - sysmsg(190,"$Verb$ doesn't take an object."); - return -1;} - - /* Now verify prepositons. If PURE_GRAMMAR is set, we don't - check prepositions unless the verb actually accepts at least one. - (this reflects the behavior of the original AGT interpreters). */ - if (prep>0 && !(redir_flag && syntbl[preplist[vb]]==0)) - { - for(i=preplist[vb];syntbl[i]!=0 && syntbl[i]!=prep;i++); - if (syntbl[i]!=prep) { - msgnum=191; - if (vb==15) msgnum=74; /* Open */ - if (vb==17) msgnum=116; /* Lock */ - if (vb==14) msgnum=48; /* Throw */ - sysmsg(msgnum,"$Verb$ doesn't take $prep$ as a preposition."); - return -1; - } - } - if (iobj==ALL_MARK) { - sysmsg(199,"You can't use ALL as an indirect object");return -1;} - if (dobj==ALL_MARK && vb!=33 && vb!=41 && vb!=51 && vb!=52) { - /* i.e. verb is not GET,DROP,WEAR,REMOVE */ - msgnum=5; - if (vb==31) msgnum=155; /* Talk */ - if (vb==34) msgnum=160; /* Ask */ - sysmsg(5,"You can't use ALL with '$verb$'.");return -1;} - return 0; -} - - -static rbool verify_scope(int vb,parse_rec *nounrec, - word prep, parse_rec *objrec) - /* This checks to make sure that all of the objects are present */ -{ - int msgnum; - int dobj,iobj; - dobj=nounrec->obj; iobj=objrec->obj; - - if (!(verbflag[vb]&VERB_TAKEOBJ)) return 1; - /* No objects (and we've already checked the grammar in - a previous routine) */ - - if (vb==31 || vb==34) /* TELL, ASK */ - return 1; /* These verbs handle this themselves */ - - if (dobj==0) { - sysmsg(184,"What do $you$ want to $verb$?"); - return 0; - } - if (dobj!=ALL_MARK && !genvisible(nounrec) - && !(it_door(dobj,nounrec->noun) && /* DOOR object handling */ - (vb==33 || vb==15 || vb==16 || vb==17 || vb==18 - || vb==29 || vb==24 || vb==22 || vb==21))) { - msgnum=3; - if (vb==33) msgnum=28; /* Get */ - if (vb==29) msgnum=63; /* Put */ - if (vb==15) msgnum=75; /* Open */ - if (vb==16) msgnum=86; /* Close */ - if (vb==24) msgnum=126; /* Drink */ - if (vb==22) msgnum=133; /* Read */ - if (vb==21) msgnum=179; /* Change_Locations */ - sysmsg(msgnum,"$You$ don't see any $noun$ here."); - return 0; - } - - if (prep!=0 && vb!=35) { /* verb 35 is TURN e.g. ON|OFF */ - if (iobj==0) { - msgnum=214; - if (vb==29) msgnum=70; /* Put */ - sysmsg(msgnum,"What do $you$ want to $verb$ $the_n$$noun$ $prep$?"); - return 0; - } - if (iobj==-ext_code[wdoor]) { - sysmsg(183,"You can't $verb$ $prep$ $the_o$$object$."); - return 0; - } - if (iobj!=ALL_MARK && !genvisible(objrec)) { - msgnum=4; - if (vb==15) msgnum=76; /* Open */ - if (vb==18) msgnum=207; /* Unlock */ - sysmsg(msgnum,"$You$ don't see any $object$ here."); - return 0; - } - } - return 1; -} - - -static void exec_verb_info(void) -{ - char *a,*b,*c; - char buff[200]; - - a=objname(dobj); - b=objname(iobj); - c=objname(actor); - sprintf(buff,"\t\t]]%s, %s %s(%ld) %s %s(%ld)",c,dict[ syntbl[auxsyn[vb]] ], - a, dobj_rec->num, prep==0 ? "->" : dict[prep], b, iobj_rec->num); - writeln(buff); - rfree(a);rfree(b);rfree(c); -} - - -/* Returns true if the turn is done. */ -rbool metacommand_cycle(int save_vb, int *p_redir_flag) -{ - if (!have_meta) return 0; - - - /* Now check metacommands */ - if (DEBUG_AGT_CMD) - debugout("*** Scanning: ANY metacommands ****\n"); - /* ANY metacommands: */ - supress_debug=!debug_any; - clear_stack(); - if ((PURE_METAVERB || !was_metaverb) - && 2==scan_metacommand(0,0,0,0,0,NULL)) - return 1; - - supress_debug=0; - - vb=save_vb; - actor_in_scope|=visible(actor); /* Set up for ActorWasPresent */ - - clear_stack(); - if (actor!=0 && averinfo!=D_NUM && iobj!=0) { - dobj=iobj; - rfree(dobj_rec); - dobj_rec=copy_parserec(iobj_rec); - objswap=1; - } else objswap=0; - - beforecmd=1; /* This is for 1.8x support */ - - turndone=metacommand_cycle(save_vb,&redir_flag) || deadflag; - - if (!turndone && DEBUG_AGT_CMD) - debugout("*** Executing Built-in Verbs ****\n"); - - if (actor>0 && !turndone) { - if (!actor_in_scope) - sysmsg(196,"I don't see whom $you$ $are$ trying to address here."); - else - sysmsg(192,"$The_name$$name$ doesn't want to."); - } - else if (vb==19 && dobj==0 && prep==0 && iobj==0) - /* LOOK: Doesn't matter if turn is done. */ - v_look(); - else if (!turndone) { - /* Execute normal verbs: check grammer and then call */ - if (!objswap) - {if (checkgram(vb,dobj,prep,iobj,redir_flag)==-1) return;} - else if (checkgram(vb,0,prep,iobj,redir_flag)==-1) return; - - if (!verify_scope(vb,dobj_rec,prep,iobj_rec)) return; - - if (vb<13 && vb>0) v_go(vb); - else switch(vb) { - - case 14: v_throw(dobj_rec,prep,iobj_rec);break; - case 29: v_put(dobj_rec,prep,iobj_rec,0);break; - - /* _with_ verbs */ - case 15: v_open(dobj_rec,iobj_rec);break; - case 16: v_close(dobj_rec);break; - case 17: v_lock(0,dobj_rec,iobj_rec);break; /* LOCK */ - case 18: v_lock(1,dobj_rec,iobj_rec);break; /* UNLOCK */ - case 36: v_noun(0,dobj_rec);break; /* PUSH (WITH);Ignore indir object*/ - - case 26: v_attack(0,dobj_rec,iobj_rec);break; - case 49: - if (prep==ext_code[wwith]) - v_attack(1,dobj_rec,iobj_rec); /* SHOOT WITH */ - else - v_attack(1,iobj_rec,dobj_rec); /* SHOOT AT */ - break; - - /* _about_ verbs */ - case 31: v_talk(0,dobj_rec,iobj_rec);break; /* TELL */ - case 34: v_talk(1,dobj_rec,iobj_rec);break; /* ASK */ - - case 28: v_yell();break; - case 27: - sysmsg(149,"Time passes..."); - break; /* wait */ - case 55: v_go(13);break; /* magic_word */ - - /* case 19: v_look();break; -- this is moved up above */ - - case 50: runptr(loc,help_ptr,"Sorry, you're on your own here.", - 2,NULL,NULL); - break; /* HELP */ - case 32: v_inventory();break; - case 56: v_view(dobj_rec); break; /* VIEW */ - case 35: - if (prep>0) - v_turn(prep,dobj_rec); /* TURN ON|OFF */ - else - v_noun(2,dobj_rec); /* TURN */ - break; - case 20: v_examine(dobj_rec);break; - case 22: v_read(dobj_rec);break; - case 23: v_eat(0,dobj_rec);break; /* EAT */ - case 24: v_eat(1,dobj_rec);break; /* DRINK */ - case 37: v_noun(1,dobj_rec);break; /* PULL */ - case 38: v_noun(3,dobj_rec);break; /* PLAY */ - case 47: v_light(1,dobj_rec);break; /* LIGHT */ - case 48: v_light(0,dobj_rec);break; /* EXTINGUISH */ - case 21: v_noun(4,dobj_rec);break; /* Change Location */ - - case 51: v_wear(dobj_rec);break; - case 33: v_get(dobj_rec);break; /* ? */ - case 52: v_remove(dobj_rec);break; - case 41: v_drop(dobj_rec);break; - - case 19: v_look();break; - case 25: print_score();break; - case 30: cmd_saveable=0; v_quit();break; - /* case 40: SHOW --> default message */ - case 39: - case 42: v_listexit();break; - case 43: cmd_saveable=0; verboseflag=0; /* BRIEF */ - writeln( - "[Now in BRIEF mode (room descriptions will only be printed" - " when they are entered the first time)]"); - break; - case 44: - cmd_saveable=0; verboseflag=1;v_look(); /* VERBOSE */ - writeln("[Now in VERBOSE mode (room descriptions will be" - " printed every time you enter a room)]"); - break; - case 45: cmd_saveable=0;savegame();break; - case 46: cmd_saveable=0;doing_restore=1; return;break; - case 53: cmd_saveable=0;script(1);break; - case 54: cmd_saveable=0;script(0);break; - case 58: /* INSTRUCTIONS */ - agt_clrscr(); - print_instructions(hold_fc); - close_ins_file(); - break; - case (OLD_VERB+1): cmd_saveable=0; /* RESTART */ - if (restart_state==NULL) - writeln("Sorry, too little memory to support RESTART."); - else {doing_restore=2;return;} - case (OLD_VERB+4): cmd_saveable=0; /* NOTIFY */ - notify_flag=!notify_flag; - if (notify_flag) writeln("Score notification is now on."); - else writeln("Score notification is now off."); break; - case (OLD_VERB+5): listexit_flag=1; - writeln("[LISTEXIT mode on: room exits will be listed.]"); - break; /* LISTEXIT ON */ - case (OLD_VERB+6): listexit_flag=0; - writeln("[LISTEXIT mode off: room exits will not be listed.]"); - break; - case (OLD_VERB+7): /* AGILDEBUG */ - if (debug_mode) get_debugcmd(); - else writeln("Nice try."); - break; - case (OLD_VERB+8): /* LOG, LOG ON */ - logon();break; - case (OLD_VERB+9): /* LOG OFF */ - if (logflag&2) break; /* We're replaying; ignore. */ - if (logflag&1) close_pfile(log_out,5); - logflag=0;break; - case (OLD_VERB+10): /* REPLAY n */ - fast_replay=0; - replay(dobj_rec->num);break; - case (OLD_VERB+11): /* REPLAY STEP */ - fast_replay=0; - replay(-1);break; - case (OLD_VERB+13): /* REPLAY FAST */ - fast_replay=1; - replay(0); break; - case (OLD_VERB+12): /* MENU */ - if (verbmenu==NULL) { - writeln("Sorry, but menus are not supported by this game."); - menu_mode=0; - break; - } - if (freeze_mode) { - writeln("Sorry, but that is not allowed."); - break; - } - menu_mode=!menu_mode; - break; - case 57: /* AFTER ?!? */ - writeln("INTERNAL ERROR: Invalid execution of AFTER"); - break; - case (OLD_VERB+14): /* SOUND ON */ - musiccmd(8,0);break; - case (OLD_VERB+15): /* SOUND OFF */ - musiccmd(9,0);break; - case (OLD_VERB+16): /* INTRO */ - agt_clrscr(); - print_descr(intro_ptr,1); - break; - default: sysmsg(185,"Don't know how to $verb$ here..."); - return; - } - } - - compute_seen(); - - if (!PURE_AFTER && !doing_restore && end_of_turn) - increment_turn(); - - beforecmd=0; - - /* In AGT 1.8x, run aftercommand verb metacommands. */ - /* (This is the most serious flaw in 1.82/1.83; it drastically changes the - semantics of metacommand execution from the earlier formats) */ - if (TWO_CYCLE && !quitflag && !turndone && !deadflag) { - if (DEBUG_AGT_CMD) - debugout("*** Scanning (after) metacommands ****\n"); - /* Normal treatment */ - turndone=turndone||metacommand_cycle(save_vb,&redir_flag); - } - - if (aver>=AGT15 && !quitflag && !endflag && !deadflag) { - if (DEBUG_AGT_CMD) - debugout("*** Scanning: AFTER metacommands ****\n"); - /* AFTER metacommands: */ - supress_debug=!debug_any; - clear_stack(); - if ((PURE_METAVERB || !was_metaverb) && - 2==scan_metacommand(0,57,0,0,0,NULL)) - turndone=1; - supress_debug=0; - } - - /* If the player really typed 'q' and we generated an "EndGame" - metacommand, then really quit. (usually it just gives the - "restart, restore, undo, quit..." message */ - if (save_vb==30 && endflag) quitflag=1; -} - - - - - - - -/* We need to be able to handle both NOUN and OBJECT searches */ -/* If obj==0, then we are doing a noun search, otherwise we are doing - an object search */ -/* Return the disambiguation score; - 0 if the object doesn't trigger anything - 1000 if it runs an action token or built in verb. - Other values may be returned if an ErrMessage token is encountered. - 500 is the cutoff for ALL expansion. - */ - - -int objcheck_cycle(rbool *success, parse_rec *act, int verbid, - parse_rec *dorec, word prep, parse_rec *iorec) -{ - int result; - - actor=act->obj; actor_rec=copy_parserec(act); - /* The xobj_rec don't really matter */ - dobj=dorec->obj; dobj_rec=copy_parserec(dorec); - if (iorec==NULL) { - iobj_rec=make_parserec(0,NULL); - iobj=0; - } else { - iobj=iorec->obj; iobj_rec=copy_parserec(iorec); - } - - clear_stack(); - *success=1; - supress_debug=!debug_disambig; - if (actor!=0 && aver -#include -#include - -#include "agility.h" -#include "interp.h" -#include "exec.h" - -#define DEBUG_SAVE_SIZE 0 - -long state_size; - - -/*-------------------------------------------------------------------*/ -/* INITIALISATION ROUTINES */ -/* These initialize all of the values that can be derived from */ -/* other data in the game file or that are reset when a game */ -/* is restored */ -/* See parser.c for the interpreter's main initialisation routines */ - -void init_vals(void) -/* Compute quantities that can be deduced from existing data */ -{ - int i; - - quitflag=winflag=deadflag=endflag=0; - cmd_saveable=0; - last_he=last_she=last_it=0; - totwt=totsize=0; - for(i=0;i<=maxroom-first_room;i++) - room[i].contents=0; - player_contents=player_worn=0; - for(i=0;i<=maxnoun-first_noun;i++) { - if (player_has(i+first_noun)) totwt+=noun[i].weight; - if (noun[i].location==1) totsize+=noun[i].size; - noun[i].something_pos_near_noun=0; - noun[i].contents=noun[i].next=0; - } - for(i=0;i<=maxcreat-first_creat;i++) - creature[i].contents=creature[i].next=0; - for(i=0;i<=maxnoun-first_noun;i++) { - add_object(noun[i].location,i+first_noun); - if (noun[i].nearby_noun>=first_noun && - noun[i].nearby_noun<=maxnoun) - noun[noun[i].nearby_noun-first_noun].something_pos_near_noun=1; - } - for(i=0;i<=maxcreat-first_creat;i++) - add_object(creature[i].location,i+first_creat); - objscore=0; /* Will need to recompute this ... */ -} - - - - -/*-------------------------------------------------------------------*/ -/* ROUTINES TO SAVE/RESTORE THE GAME STATE */ -/* These are used by RESTART and UNDO as well as SAVE and RESTORE */ - -/* Game State format: */ -/* The first two bytes indicate the length of the block (unsigned).*/ -/* The next two bytes indicate the game file somehow (so we don't try to */ -/* restore to a different game). */ -/* After this comes the game information itself. */ -/* All values are still little-endian (that is, LSB first) */ - -/* These are the macros for writing game information to the state block */ -/* There is no difference between signed and unsigned when storing them; - there will be problems when recovering them again. */ - -#define g(ft,var) {ft,DT_DEFAULT,&var,0} -#define r(ft,str,f) {ft,DT_DEFAULT,NULL,offsetof(str,f)} -#define dptype {FT_DESCPTR,DT_DESCPTR,NULL,0} - -static file_info fi_savehead[]={ - g(FT_INT16,loc), g(FT_INT32,tscore), g(FT_INT16,turncnt), - g(FT_BYTE,statusmode), - g(FT_BOOL,first_visit_flag), g(FT_BOOL,newlife_flag), - g(FT_BOOL,room_firstdesc), g(FT_BOOL,verboseflag), - g(FT_BOOL,notify_flag), g(FT_BOOL,listexit_flag), - g(FT_BOOL,menu_mode), g(FT_BOOL,sound_on), - g(FT_BOOL,agt_answer),g(FT_INT32,agt_number), - g(FT_INT16,curr_time),g(FT_INT16,curr_lives), - g(FT_INT16,delta_time), - endrec -}; - -static file_info fi_saveroom[]={ - dptype, - r(FT_BOOL,room_rec,seen), - r(FT_BOOL,room_rec,locked_door), - r(FT_INT16,room_rec,oclass), - r(FT_INT16,room_rec,points), - r(FT_INT16,room_rec,light), - r(FT_PATHARRAY,room_rec,path), - r(FT_UINT32,room_rec,flag_noun_bits), - endrec -}; - -static file_info fi_savenoun[]={ - dptype, - r(FT_INT16,noun_rec,location), - r(FT_INT16,noun_rec,nearby_noun), - r(FT_INT16,noun_rec,num_shots), - r(FT_INT16,noun_rec,initdesc), - r(FT_INT16,noun_rec,oclass), - r(FT_INT16,noun_rec,points), - r(FT_INT16,noun_rec,weight), - r(FT_INT16,noun_rec,size), - r(FT_BOOL,noun_rec,on), - r(FT_BOOL,noun_rec,open), - r(FT_BOOL,noun_rec,locked), - r(FT_BOOL,noun_rec,movable), - r(FT_BOOL,noun_rec,seen), - r(FT_WORD,noun_rec,pos_prep), - r(FT_WORD,noun_rec,pos_name), - endrec -}; - -static file_info fi_savecreat[]={ - dptype, - r(FT_INT16,creat_rec,location), - r(FT_INT16,creat_rec,counter), - r(FT_INT16,creat_rec,timecounter), - r(FT_INT16,creat_rec,initdesc), - r(FT_INT16,creat_rec,oclass), - r(FT_INT16,creat_rec,points), - r(FT_BOOL,creat_rec,groupmemb), - r(FT_BOOL,creat_rec,hostile), - r(FT_BOOL,creat_rec,seen), - endrec -}; - -static file_info fi_saveustr[]={ - {FT_TLINE,DT_DEFAULT,NULL,0}, - endrec -}; - - - -uchar *getstate(uchar *gs) -/* Returns block containing game state. - If gs!=NULL, uses that space as a buffer; - if gs==NULL, we malloc a new block and return it */ -{ - rbool new_block; /* True if we allocate a new block */ - long bp; - - if (gs==NULL) { - rm_trap=0; /* Don't exit on out-of-memory condition */ - gs=rmalloc(state_size); /* This should be enough. */ - rm_trap=1; - if (gs==NULL) /* This is why we set rm_trap to 0 before calling rmalloc */ - return NULL; - new_block=1; - } else new_block=0; - - /* First two bytes reserved for block size, which we don't know yet.*/ - gs[4]=game_sig&0xFF; - gs[5]=(game_sig>>8)&0xFF; - - tscore-=objscore; /* Only include "permanent" part of score; - objscore we can recompute on RESTORE */ - - /* Need to setup here */ - set_internal_buffer(gs); - fi_saveroom[0].ptr=room_ptr; - fi_savenoun[0].ptr=noun_ptr; - fi_savecreat[0].ptr=creat_ptr; - - bp=6; - bp+=write_globalrec(fi_savehead,bp); - bp+=write_recblock(flag,FT_BYTE,FLAG_NUM+1,bp); - bp+=write_recblock(agt_counter,FT_INT16,CNT_NUM+1,bp); - bp+=write_recblock(agt_var,FT_INT32,VAR_NUM+1,bp); - bp+=write_recarray(room,sizeof(room_rec),rangefix(maxroom-first_room+1), - fi_saveroom,bp); - bp+=write_recarray(noun,sizeof(noun_rec),rangefix(maxnoun-first_noun+1), - fi_savenoun,bp); - bp+=write_recarray(creature,sizeof(creat_rec), - rangefix(maxcreat-first_creat+1), - fi_savecreat,bp); - if (userstr!=NULL) - bp+=write_recarray(userstr,sizeof(tline),MAX_USTR,fi_saveustr,bp); - if (objflag!=NULL) - bp+=write_recblock(objflag,FT_BYTE, objextsize(0), bp); - if (objprop!=NULL) - bp+=write_recblock(objprop,FT_INT32, objextsize(1), bp); - set_internal_buffer(NULL); - gs[0]=bp & 0xFF; - gs[1]=(bp>>8) & 0xFF; - gs[2]=(bp>>16) & 0xFF; - gs[3]=(bp>>24) & 0x7F; /* Don't trust top bit */ - if (new_block) - gs=rrealloc(gs,bp); - tscore+=objscore; - return gs; -} - - - -void putstate(uchar *gs) /* Restores games state. */ -{ - long size, bp, numrec, i; - - - size=gs[0]+(((long)gs[1])<<8)+(((long)gs[2])<<16)+(((long)gs[3])<<24); - if (size!=state_size) { - writeln("Size difference in save files!"); - agt_delay(3); - return; - } - if (gs[4]+(((long)gs[5])<<8)!=game_sig) { - writestr("This appears to be a save file for a different game. Is this" - " from an earlier chapter in a multi-part game such as" - " Klaustrophobia"); - if (yesno("?")) - skip_descr=1; /* We don't want to overwrite the descriptions - with the pointers from the save file. */ - else { - writestr("Do you want to try using it anyhow (WARNING: This could" - " crash the interpreter)"); - if (!(yesno("?"))) { - writeln("Command cancelled!"); - agt_delay(3); - return; - } - } - } - - - /* setup... */ - set_internal_buffer(gs); - fi_saveroom[0].ptr=room_ptr; - fi_savenoun[0].ptr=noun_ptr; - fi_savecreat[0].ptr=creat_ptr; - bp=6; - - read_globalrec(fi_savehead,0,bp,0); - bp+=compute_recsize(fi_savehead); - read_recblock(flag,FT_BYTE,FLAG_NUM+1,bp,0); - bp+=ft_leng[FT_BYTE]*(FLAG_NUM+1); - read_recblock(agt_counter,FT_INT16,CNT_NUM+1,bp,0); - bp+=ft_leng[FT_INT16]*(CNT_NUM+1); - read_recblock(agt_var,FT_INT32,VAR_NUM+1,bp,0); - bp+=ft_leng[FT_INT32]*(VAR_NUM+1); - - numrec=rangefix(maxroom-first_room+1); - read_recarray(room,sizeof(room_rec),numrec,fi_saveroom,0,bp,0); - bp+=compute_recsize(fi_saveroom)*numrec; - numrec=rangefix(maxnoun-first_noun+1); - read_recarray(noun,sizeof(noun_rec),numrec,fi_savenoun,0,bp,0); - bp+=compute_recsize(fi_savenoun)*numrec; - numrec=rangefix(maxcreat-first_creat+1); - read_recarray(creature,sizeof(creat_rec),numrec,fi_savecreat,0,bp,0); - bp+=compute_recsize(fi_savecreat)*numrec; - if (userstr!=NULL) { - read_recarray(userstr,sizeof(tline),MAX_USTR,fi_saveustr,0,bp,0); - bp+=ft_leng[FT_TLINE]*MAX_USTR; - } - if (objflag!=NULL) { - i=objextsize(0); - read_recblock(objflag,FT_BYTE,i,bp,0); - bp+=ft_leng[FT_BYTE]*i; - } - if (objprop!=NULL) { - i=objextsize(1); - read_recblock(objprop,FT_INT32,i,bp,0); - bp+=ft_leng[FT_INT32]*i; - } - set_internal_buffer(NULL); - - if (skip_descr) /* Need to "fix" position information. This is a hack. */ - /* Basically, this sets the position of each object to its default */ - /* The problem here is that the usual position info is invalid-- we've - changed games, and hence dictionaries */ - for(i=0;imaxroom || loc<0 || turncnt<0 || - curr_lives<0 || curr_lives>max_lives) { - writeln("Error: Save file inconsistent."); - exit(EXIT_FAILURE); - } -} - -void init_state_sys(void) -/* Initializes the state saving mechanisms */ -/* Mainly it just computes the size of a state block */ -{ - state_size=compute_recsize(fi_savehead) - + compute_recsize(fi_saveroom)*rangefix(maxroom-first_room+1) - + compute_recsize(fi_savenoun)*rangefix(maxnoun-first_noun+1) - + compute_recsize(fi_savecreat)*rangefix(maxcreat-first_creat+1) - + ft_leng[FT_BYTE]*(FLAG_NUM+1) - + ft_leng[FT_INT16]*(CNT_NUM+1) - + ft_leng[FT_INT32]*(VAR_NUM+1) - + ft_leng[FT_BYTE]*objextsize(0) - + ft_leng[FT_INT32]*objextsize(1) - + 6; /* Six bytes in header */ - if (userstr!=NULL) state_size+=ft_leng[FT_TLINE]*MAX_USTR; -} - - -/*-------------------------------------------------------------------*/ -/* SAVE FILE ROUTINES */ - -void savegame(void) -{ - genfile savefile; - uchar *gs; - long size; - -#ifndef UNDO_SAVE - gs=getstate(NULL); -#else - gs=undo_state; -#endif - if (gs==NULL) { - writeln("Insufficiant memory to support SAVE."); - return; - } - savefile=get_user_file(1); - if (!filevalid(savefile,fSAV)) { - writeln("That is not a valid save file."); - return; - } - size=gs[0]+(((long)gs[1])<<8)+(((long)gs[2])<<16)+(((long)gs[3])<<24); - if (!binwrite(savefile,gs,size,1,0)) - writeln("Error writing save file."); -#ifndef UNDO_SAVE - rfree(gs); -#endif - writeclose(savefile,NO_FILE_ID); -} - - -rbool loadgame(void) -/* 1=success, 0=failure */ -{ - genfile loadfile; - long size; - uchar *gs; - char *errstr; - - loadfile=get_user_file(2); - if (!filevalid(loadfile,fSAV)) { - writeln("Unable to open file."); - return 0; - } - size=binsize(loadfile); - if (size==-1) { - writeln("Could not access file."); - readclose(loadfile); - return 0; - } - gs=rmalloc(size); - if (!binread(loadfile,gs,size,1,&errstr)) { - writeln("Error reading file."); - rfree(gs);readclose(loadfile); - return 0; - } - readclose(loadfile); - if (size!=gs[0]+(((long)gs[1])<<8)+(((long)gs[2])<<16)+(((long)gs[3])<<24)){ - if (size==gs[0]+(((long)gs[1])<<8)) { - /* Old save file format; patch to look like new format */ - gs=rrealloc(gs,size+2); - memmove(gs+4,gs+2,size-2); - gs[2]=gs[3]=0; - } else { - writeln("Save file corrupted or invalid."); - rfree(gs); - return 0; - } - } - putstate(gs); - rfree(gs); - set_statline(); - look_room(); - return 1; -} - -void restart_game(void) -{ - putstate(restart_state); - agt_clrscr(); - set_statline(); - do_look=do_autoverb=1; - if (intro_ptr.size>0) { - print_descr(intro_ptr,1); - wait_return(); - agt_clrscr(); - } - newroom(); -} - diff --git a/app/src/main/jni/terps/agility/token.c b/app/src/main/jni/terps/agility/token.c deleted file mode 100644 index 96f27c7..0000000 --- a/app/src/main/jni/terps/agility/token.c +++ /dev/null @@ -1,750 +0,0 @@ -/* token.c-- handles metacommand execution */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for the AGiliTy */ - -/* - - This contains the code for actually executing each of the - individual metacommand tokens as well as the routines for - doing range checking to prevent a bad metacommand from crashing - the interpreter. - -*/ - - -#include -#include -#include - -#include "agility.h" -#include "interp.h" -#include "exec.h" - - - - -static void it_newdesc(integer item,descr_ptr *newdesc) -{ - descr_ptr *desc; - - if (tnoun(item)) desc=noun_ptr+(item-first_noun); - else if (tcreat(item)) desc=creat_ptr+(item-first_creat); - else if (item>=first_room && item<=maxroom) - desc=room_ptr+(item-first_room); - else { - writeln("INTERNAL ERROR: it_newdesc called with invalid object"); - return; - } - desc->start=newdesc->start; - desc->size=newdesc->size; -} - -static void changepict(int old_pict,int new_pict) -/* Replace old_pict by new_pict */ -{ - pictable[old_pict-1]=new_pict-1; -} - - -static const int antidir[12]={1,0,3,2,7,6,5,4,9,8,11,10}; - -static void change_passage(int start,int dir,int newend) -/* dir is 1..12 */ -/* START is a room number: i.e. starting at 0. */ -/* NEWEND is an object number, so starts at first_room */ -{ - int oldend, i; - - dir--; /* Convert direction to 0..11 scale */ - oldend=room[start].path[dir]; - room[start].path[dir]=newend; - if (newend==0) { - if (room[oldend-first_room].path[antidir[dir]]==start+first_room) - room[oldend-first_room].path[antidir[dir]]=0; - else for(i=0;i<12;i++) - if (room[oldend-first_room].path[i]==start+first_room) - {room[oldend-first_room].path[i]=0;break;} - } - else - room[newend-first_room].path[antidir[dir]]=start+first_room; -} - - -static long ask_for_number(int n1,int n2) -{ - char s[50]; - int n; - - if (n1!=n2) - sprintf(s,"Enter a number from %d to %d: ",n1,n2); - else - sprintf(s,"Enter a number: "); - for(;;) { - writestr(s); - n=read_number(); - if (n1==n2 || ( n>=n1 && n<=n2)) return n; - writeln(""); - } -} - -/* Check if n1*n2 will fit in 32 bits and print an error message if not */ -/* This errs on the side of caution */ -static rbool mult_rangecheck(long n1, long n2) -{ - int cnt; - - if (n1==0 || n2==0) return 1; - if (n1<0) n1=-n1; - if (n2<0) n2=-n2; - - for(cnt=0;n1!=0;n1>>=1,cnt++); - for(;n2!=0;n2>>=1,cnt++); - cnt--; - - if (cnt<=31) return 1; /* We're okay */ - - if (!PURE_ERROR) - writeln("GAME ERROR: Multiplication out of range."); - return 0; -} - -static rbool is_numeric(parse_rec *objrec) -{ - char *s; - - if (objrec->num!=0 || objrec->info==D_NUM) return 1; - if (objrec->adj!=0) return 0; - if (objrec->noun<=0) return 0; - strtol(dict[objrec->noun],&s,10); - return (*s==0); /* *s==0 means no error-- it parsed as a number. */ -} - -static void setcase(char *s, rbool up) -{ - for(;*s!=0;s++) - if (up) *s=toupper(*s); - else *s=tolower(*s); -} - - -void move_in_dir(int obj, int dir) -{ - int r; - - r=it_room(obj); - if (!troom(r)) {writeln("GAME ERROR: Object not in a room."); return;} - r=room[r-first_room].path[dir-1]; - if (!troom(r)) return; /* Can't go that way; Fail silently */ - if (obj==1) - goto_room(r); - else - it_move(obj,r); -} - - -/* ------------------------------------------------------------------- */ -/* Stack routines: Manipulating the expression stack */ -/* ------------------------------------------------------------------- */ - -static long *stack=NULL; -static int sp=0; /* Stack pointer */ -static int stacksize=0; /* Actual space allocated to the stack */ - -void init_stack(void) -{ - rfree(stack); - sp=0; stacksize=0; -} - -/* This resets the stack to an empty state. */ -void clear_stack(void) -{ - sp=0; -} - -static void push_stack(long val) -{ - sp++; - if (sp>stacksize) { - stacksize+=10; - stack=rrealloc(stack,stacksize*sizeof(long)); - } - stack[sp-1]=val; -} - -static long pop_stack(void) -{ - long n; - if (sp==0) { - writeln("GAME ERROR: Stack underflow."); - return 0; - } - n=stack[--sp]; - if (sp+1000) - dbgprintf("TOS(%d)",stack[sp-1]); - else - debugout("TOS(xxx)"); -} - - - -/* ------------------------------------------------------------------- */ -/* METACOMMAND ROUTINES */ -/* Functions for scanning and decoding of metacommands */ -/* ------------------------------------------------------------------- */ - -/* #define cret(b) return ((b) ? -1 : 0)*/ -#define cret(b) return (b) -#define cretn(i,f) cret(tnoun(i) && noun[i-first_noun].f) -#define cretc(i,f) cret(tcreat(i) && creature[i-first_creat].f) -#define icretc(f) cret(do_disambig==1 || \ - (tcreat(iobj) && creature[iobj-first_creat].f)) - -static int obj_cond(int op, int obj, int arg) -{ - switch(op) { - case 0:cret(in_scope(obj)); /* Present-- - Do we want to use visible here?? */ - case 1:cret(is_within(obj,1000,1)); /* IsWearing */ - case 2:cret(is_within(obj,1,1)); - /* if (PURE_WEAR) return (it_loc(obj)==1); else */ - case 3:cret(it_loc(obj)==0); /* Nowhere */ - case 4:cret(it_loc(obj)!=0); - case 5:cret(!player_has(obj) && in_scope(obj)); - case 6:cret(it_loc(obj)==arg); - case 7:cret(it_on(obj)); - case 8:cret(!it_on(obj)); - case 9:cret(it_open(obj)); - case 10:cret(!it_open(obj)); - case 11:cretn(obj,locked); - case 12:cret(!tnoun(obj) || !noun[obj-first_noun].locked); - case 13:cretn(obj,edible); - case 14:cretn(obj,drinkable); - case 15:cretn(obj,poisonous); - case 16:cretn(obj,movable); - default: - writeln("INTERNAL ERROR: Bad obj_cond value."); - return 2; - } -} - - -static int exec_cond(int op, int arg1, int arg2) -{ - int i; - - switch(op) - { - /* First the conditions */ - case 0: cret(loc+first_room==arg1); /* AtLoc(Room) */ - case 1: cret(loc+first_room>arg1); - case 2: cret(loc+first_room0 && - room[loc].path[vb-1]>=first_room);/*DirOK*/ - case 6: cret(vb==arg1); /* DirectionIs */ - case 7: cret(loc+first_room>=arg1 && - loc+first_room<=arg2); /* BetweenRooms ?? */ - case 8: cret(room[arg1-first_room].seen); - case 9: /* Entered Object? i.e. is iobj valid */ - cret(do_disambig==1 || iobj>0); - case 10: cret(curr_time>arg1); /* TimeGT */ - case 11: cret(curr_time=arg1) return 1; - contloop(i,1000) - if (tnoun(i) && noun[i-first_noun].points>=arg1) return 1; - return 0; - case 19:cret(totwt==arg1); - case 20:cret(totwt>arg1); - case 21:cret(totwtarg1); - case 60:cretn(dobj,pointsarg1); - case 63:cretn(dobj,weightarg1); - case 73:cret(tscorearg1); - case 76:cret(agt_numberarg1); - case 81:cret(turncntarg2); - case 84:cret(cnt_val(agt_counter[arg1])arg2); - case 87:cret(agt_var[arg1]0 && vb<=13); - case 99:cret(tcreat(dobj)); - case 100:cretc(dobj,gender==2); /* man */ - case 101:cretc(dobj,gender==1); /* woman */ - case 102:cretc(dobj,gender==0); /* thing */ - case 103:cretc(iobj,gender==2); - case 104:cretc(iobj,gender==1); /* woman */ - case 105:cretc(iobj,gender==0); /* thing */ - case 106:cret(do_disambig==1 || tcreat(iobj)); - case 107:return (do_disambig==1 || obj_cond(0,iobj,0)); - /* OR and NOT are handled higher up. */ - /* The following are all v1.8x metacommands */ - case 110:cret(beforecmd); - case 111:cret(!beforecmd); - case 112:cret(curr_time/100==arg1); /* HoursEqual */ - case 113:cret(curr_time/100>arg1); - case 114:cret(curr_time/100arg1); - case 117:cret(curr_time%100arg2); - case 130: cret(arg1=arg2); - case 132: cret(arg1<=arg2); - case 133: cret(strcmp(userstr[arg1-1],userstr[arg2-1])==0); - case 134: cret(strcmp(userstr[arg1-1],userstr[arg2-1])<0); - case 135: cret(strcmp(userstr[arg1-1],userstr[arg2-1])>0); - case 136: cret(strcasecmp(userstr[arg1-1],userstr[arg2-1])==0); - case 137: cret(strcasecmp(userstr[arg1-1],userstr[arg2-1])<0); - case 138: cret(strcasecmp(userstr[arg1-1],userstr[arg2-1])>0); - case 139: cret(match_answer(rstrdup(userstr[arg1-1]),arg2-1)); - /* Note that match_answer rfrees it's first argument */ - case 140: cret(it_seen(arg1)); - case 141: cret(op_objflag(2,arg1,arg2)); - case 142: cret(!op_objflag(2,arg1,arg2)); - case 143: - i=it_room(arg1); - cret( troom(i) && troom(room[i-first_room].path[arg2-1]) ); - default: writeln("INTERNAL ERROR: Condition token not supported."); - rprintf("Condition #%d",op); - writeln(""); - return 0; - } -} - -#undef cret -#undef cretn -#undef cretc - - -static void obj_act(int op,int obj) -{ - switch(op) { - case 0: case 1: /* open and close */ - if (tnoun(obj)) - noun[obj-first_noun].open=(op==0); - break; - case 2: case 3: /* lock and unlock */ - if (tnoun(obj)) - noun[obj-first_noun].locked=(op==2); - } -} - - -static void exec_action(int op,int arg1,int arg2) -{ - int i, j; - char *tmpstr; - - switch(op) - { - case 1000:goto_room(arg1-first_room);break; - case 1001:goto_room(agt_rand(arg1,arg2)-first_room);break; - case 1002:agt_var[arg1]=loc+first_room;break; - case 1003:agt_var[arg1]=dobj;break; - case 1004:agt_var[arg1]=iobj;break; - case 1005:goto_room(agt_var[arg1]-first_room);break; - case 1006:it_move(arg1,agt_var[arg2]);break; - case 1007:get_obj(agt_var[arg1]);break; - case 1008:msgout(agt_var[arg1],1);break; - case 1009:get_obj(arg1);break; - case 1010:get_obj(arg1);it_move(arg1,1000);break; - case 1011:drop_obj(arg1);break; - case 1012: - if (it_loc(arg1)==1000) { - if (PURE_WEAR) drop_obj(arg1); - else it_move(arg1,1); - } - break; - case 1013:fontcmd(0,arg1-1);break; /* Load font */ - case 1014:pictcmd(1,pictable[arg1-1]);break; /* Show picture */ - case 1015:changepict(arg1,arg2);break; /* ChangePicture */ - case 1016: if (PICT_SUPPORT && - yesno("Would you like to see the picture?")) - pictcmd(1,pictable[arg1-1]);break; - case 1017:pictcmd(2,arg1);break; /* Show room pix */ - case 1018: if (PICT_SUPPORT && - yesno("Would you like to see the picture?")) - pictcmd(2,arg1-1);break; - case 1019:musiccmd(1,arg1-1);break; - case 1020:musiccmd(1,agt_rand(arg1,arg2)-1);break; - case 1021:musiccmd(2,arg1-1);break; - case 1022:musiccmd(3,-1); break; /* Stop Repeat */ - case 1023:musiccmd(4,-1); break; /* Stop song */ - case 1024:musiccmd(5,-1); break; /* Suspend song */ - case 1025:musiccmd(6,-1);break; /* Resume song */ - case 1026: - if (tnoun(dobj)) - noun[dobj-first_noun].movable=!noun[dobj-first_noun].movable; - break; - case 1027: it_newdesc(arg1,&msg_ptr[arg2-1]); break; - case 1028: - if (tnoun(arg1)) noun[arg1-first_noun].points=arg2; - else if (tcreat(arg1)) creature[arg1-first_creat].points=arg2; - else if (troom(arg1)) room[arg1-first_room].points=arg2; - break; - case 1029:it_destroy(iobj);break; - case 1030: - tmpstr=agt_readline(3); - i=strlen(tmpstr)-1; - if (i>0 && tmpstr[i]=='\n') tmpstr[i]=0; - strncpy(userstr[arg1-1],tmpstr,80); - rfree(tmpstr); - break; - case 1031:agt_var[arg1]=read_number();break; - case 1032:agt_var[arg1]=curr_time;break; - case 1033:curr_time=normalize_time(agt_var[arg1]);break; - case 1034:curr_time=normalize_time(arg1); break; - case 1035:add_time(arg1);break; - case 1036:delta_time=arg1;break; - /* 1037 and 1038 are subroutine commands */ - case 1039:get_obj(dobj);break; - case 1040:it_move(dobj,1000);break; - case 1041:drop_obj(dobj);break; - case 1042: - if (it_loc(dobj)==1000) { - if (PURE_WEAR) it_move(dobj,1); - else drop_obj(dobj); - } - break; - case 1043: /* drop all */ - safecontloop(i,j,1) drop_obj(i); - break; - case 1044: /* remove all */ - safecontloop(i,j,1000) drop_obj(i); - break; - case 1045:deadflag=1;break; - case 1046:it_move(arg1,loc+first_room);break; - case 1047:it_move(arg1,arg2);break; - case 1048:it_reposition(arg1,arg2,1);break; /* RePosition */ - case 1049:it_move(dobj,loc+first_room);break; - case 1050:it_move(dobj,arg1);break; - case 1051: - safecontloop(i,j,1) it_move(i,arg1); - safecontloop(i,j,1000) it_move(i,arg1); - break; - case 1052: - nounloop(i) - if (player_has(i+first_noun) && noun[i].points>arg2) - it_move(i+first_noun,arg1); - break; - case 1053: - safecontloop(i,j,arg1) - if (tnoun(i)) it_move(i,arg2); - break; - case 1054:it_destroy(arg1);break; - case 1055:it_destroy(dobj);break; - case 1056:i=it_loc(arg1); - it_move(arg1,it_loc(arg2)); - it_move(arg2,i); - break; - case 1057:it_move(arg1,it_loc(arg2));break; - case 1058:it_move(dobj,it_loc(arg2));break; - case 1059: case 1060: /* Add to/remove from group */ - if (tcreat(arg1)) - creature[arg1-first_creat].groupmemb=(op==1059); - break; - case 1061: /* Move group */ - safecontloop(i,j,loc+first_room) - if (it_group(i)) it_move(i,arg1); - break; - /* 1062 is RedirectTo */ - case 1063:msgout(agt_rand(arg1,arg2),1);break; - case 1064:print_contents(arg1,1);break; - case 1065: case 1066: case 1067: case 1068: - obj_act(op-1065,arg1);break; - case 1069: case 1070: case 1071: case 1072: - obj_act(op-1069,dobj);break; - case 1073:print_score();break; - case 1074: tscore+=arg1;break; - case 1075: tscore-=arg1;break; - case 1076:v_inventory();break; - case 1077:wait_return();break; - case 1078:writeln("Time passes...");break; - case 1079:agt_delay(arg1);break; - case 1080:agt_clrscr();break; - case 1081:it_describe(arg1);break; - case 1082:look_room();break; /* LOOK */ - case 1083:msgout(arg1,1);break; - case 1084:writeln("");break; - case 1085:if (PURE_TONE && sound_on) - agt_tone(arg1,arg2);break; /* Tone */ - case 1086:agt_number=ask_for_number(arg1,arg2);break; - case 1087:agt_answer=ask_question(arg1);break; - case 1088:change_passage(loc,arg1,arg2);break; - case 1089:flag[arg1]=1;break; - case 1090:flag[arg1]=0;break; - case 1091:flag[arg1]=!flag[arg1];break; - case 1092:room[loc].flag_noun_bits|=(1 << (arg1-1) ); - break; /* Roomflag on */ - case 1093:room[loc].flag_noun_bits&=~(1 << (arg1-1) );break; /* Off */ - case 1094:room[loc].flag_noun_bits^=(1 << (arg1-1) );break; /* Toggle */ - case 1095: /* if (agt_counter[arg1]==-1)*/ - agt_counter[arg1]=1;break; - case 1096:agt_counter[arg1]=-1;break; - case 1097:agt_var[arg1]=arg2;break; - case 1098:agt_var[arg1]+=arg2;break; - case 1099:agt_var[arg1]-=arg2;break; - case 1100:agt_var[arg1]+=agt_var[arg2];break; - case 1101:agt_var[arg1]-=agt_var[arg2];break; - case 1102:agt_var[arg1]=agt_rand(0,arg2);break; - case 1103:agt_var[arg1]=dobj_rec->num;break; - case 1104:agt_var[arg1]=iobj_rec->num;break; - - /* The following are v1.8x specific */ - case 1105:quote(arg1);break; - case 1106:add_time(arg1);break; - case 1107:add_time(-arg1);break; - case 1108:curr_time=(curr_time%100)+100*arg1;break; - case 1109:curr_time=(curr_time/100)*100+arg1;break; - case 1110:add_time(agt_var[arg1]);break; - case 1111:add_time(-agt_var[arg1]);break; - case 1112:curr_time=(curr_time%100)+100*agt_var[arg1];break; - case 1113:curr_time=(curr_time/100)*100+agt_var[arg1];break; - - /* Now for the AGX additions */ - case 1114:add_time(-arg1);break; /* ME-style SubtractFromTime */ - case 1115: disambig_score=arg1; break; /* SetDisambigPriority */ - case 1116:agt_var[arg1]=delta_time;break; - case 1117: /* ChangeStatus */ - statusmode=arg1; - break; - case 1118: - if (!mult_rangecheck(agt_var[arg1],arg2)) break; - agt_var[arg1]*=arg2;break; - case 1119: - if (arg2==0) { - if (!PURE_ERROR) - writeln("GAME ERROR: Division by zero."); - } else agt_var[arg1]/=arg2; - break; - case 1120: - if (arg2==0) { - if (!PURE_ERROR) - writeln("GAME ERROR: Attempt to divide by zero."); - } else agt_var[arg1]%=arg2; - break; - case 1121:agt_waitkey();break; - case 1122:last_he=arg1;break; /* SetHE */ - case 1123:last_she=arg1;break; - case 1124:last_it=arg1;break; - case 1125:last_they=arg1;break; - case 1126:msgout(arg1,0);break; - case 1127: - if (!PURE_ERROR) - sysmsg(arg1,"GAME ERROR: Standard message not defined."); - break; - case 1128: msgout(arg1,1);break; /* FailMessage */ - case 1129: /* StdMessage */ - sysmsg(arg1,"GAME ERROR: Standard message not defined."); - break; - case 1130: msgout(arg2,1);break; /* ErrMessage */ - case 1131: /* StdErrMessage */ - sysmsg(arg1,"GAME ERROR: Standard message not defined."); - break; - case 1132: /* AND */ - break; /* These don't do anything under normal circumstances */ - case 1133: /* SetClass */ - if (troom(arg1)) room[arg1-first_room].oclass=arg2; - else if (tnoun(arg1)) noun[arg1-first_noun].oclass=arg2; - else if (tcreat(arg1)) noun[arg1-first_creat].oclass=arg2; - break; - case 1134: agt_var[arg1]=it_class(arg2); break; /* SetVariableToClass */ - - /* Stack commands */ - case 1135: push_stack(arg1); break; - case 1136: agt_var[arg1]=pop_stack(); break; - case 1137: case 1138: case 1139: case 1140: case 1141: - op_stack(op-1137); /* +,-,*, /,% * */ - break; - case 1142: { /* DupStack */ - long n; - n=pop_stack(); - push_stack(n); - push_stack(n); - break; - } - case 1143: pop_stack();break; /* Discard TOS */ - case 1144: agt_var[arg1]=agt_number;break; /* SetVariableToInput */ - case 1145: setattr(arg1,arg2,1); break; /* Set */ - case 1146: setattr(arg1,arg2,0); break; /* Clear */ - case 1147: push_stack(getprop(arg1,arg2));break; /* PushProp */ - case 1148: setprop(arg1,arg2,pop_stack());break; /* PopProp */ - /* 1149, 1150 handled by run_metacommand */ - /* 1151 is EndDisambig */ - /* 1152 is XRedirect */ - case 1153: rstrncpy(userstr[arg1-1],userstr[arg2-1],81);break; - case 1154: setcase(userstr[arg1-1],1); break; - case 1155: setcase(userstr[arg1-1],0);break; - case 1156: op_objflag(1,arg1,arg2);break; - case 1157: op_objflag(0,arg1,arg2);break; - case 1158: op_objflag(3,arg1,arg2);break; - case 1159: push_stack(op_objprop(2,arg1,arg2,0)); break; - case 1160: op_objprop(1,arg1,arg2,pop_stack()); break; - case 1161: move_in_dir(arg1,arg2); break; - default: - writeln("INTERNAL ERROR: Action token not supported."); - rprintf("Action #%d",op); - writeln(""); - } -} - -int exec_instr(op_rec *oprec) -/* This routine is responsible for executing all conditions and action - tokens. Remember action tokens are numbered from 1000. */ -/* Return codes: - 0 to continue running commands - 1 for a failed conditional token - 100 Next metacommand - 101 Stop running metacommands - 102 End turn - 103 Redirection */ -{ - rbool r; - - if (oprec->op<1000) { - r=exec_cond(oprec->op,oprec->arg1,oprec->arg2); - return (oprec->negate ? r : !r); /* Is it prefixed by NOT? */ - } - switch(oprec->op) - { - case 1151: /* EndDisambig */ - if (do_disambig) { - disambig_score=oprec->arg1; - return 102; /* "End turn" if disambiguating */ - } - return 0; /* ... otherwise do nothing */ - case 1062: case 1152: return 103; /* Redirect */ - case WIN_ACT: winflag=1; return 0; /* win game */ - case (WIN_ACT+1): endflag=1; return 102; /* end game */ - case (WIN_ACT+2): return 100; /* end this command */ - case (WIN_ACT+3): return 101; /* end all commands */ - case (WIN_ACT+4): return 102; /* end turn */ - default: - exec_action(oprec->op,oprec->arg1,oprec->arg2); - if (oprec->failmsg) return 102; - else return 0; - } -} - - - - diff --git a/app/src/main/jni/terps/agility/util.c b/app/src/main/jni/terps/agility/util.c deleted file mode 100644 index 939c787..0000000 --- a/app/src/main/jni/terps/agility/util.c +++ /dev/null @@ -1,1404 +0,0 @@ -/* util.c-- wrappers around memory allocation and other misc. */ -/* utilities */ -/* Copyright (C) 1996-1999,2001 Robert Masenten */ -/* This program may be redistributed under the terms of the - GNU General Public License, version 2; see agility.h for details. */ -/* */ -/* This is part of the source for both AGiliTy: the (Mostly) Universal */ -/* AGT Interpreter and for the Magx adventure game compiler. */ - -/* This includes wrappers for malloc, realloc, strdup, and free - that exit gracefully if we run out of memory. */ -/* There are also various utilities: - concdup: Creates a new string that is concatation of two others. - strcasecmp: case insensitive comparison of strings - strncasecmp: case insensitive compare of first n characters of strings - fixsign16, fixsign32: routines to assemble signed ints out of - individual bytes in an endian-free way. */ -/* Also buffered file i/o routines and some misc. file utilites. */ - - -#include -#include -#include -#include -#include -#include "agility.h" - -#ifdef force16 -#undef int -#endif - -#ifdef PROFILE_SUPPORT -#include -#endif - -#ifdef MEM_INFO -#include -#endif - -#ifdef force16 -#define int short -#endif - - -long rangefix(long n) -{ - if (n>0) return n; - return 0; -} - -/*-------------------------------------------------------------------*/ -/* Sign fixing routines, to build a signed 16- and 32-bit quantities */ -/* out of their component bytes. */ -/*-------------------------------------------------------------------*/ - -#ifndef FAST_FIXSIGN -short fixsign16(uchar n1,uchar n2) -{ - rbool sflag; - short n; - - if (n2>0x80) {n2&=0x7F;sflag=1;} - else sflag=0; - - n=n1+(n2<<8); - if (sflag) n=n-0x7fff-1; - return n; -} - -long fixsign32(uchar n1,uchar n2,uchar n3,uchar n4) -{ - rbool sflag; - long n; - - if (n4>0x80) {n4&=0x7F;sflag=1;} - else sflag=0; - - n=n1+(((long)n2)<<8)+(((long)n3)<<16)+(((long)n4)<<24); - if (sflag) n=n-0x7fffffffL-1L; - return n; -} -#endif - - - -/*----------------------------------------------------------------------*/ -/* rprintf(), uses writestr for output */ -/* This function is used mainly for diagnostic information */ -/* There should be no newlines in the format string or in any of the */ -/* arguments as those could confuse writestr, except for the last */ -/* character in the string which can be a newline. */ -/*----------------------------------------------------------------------*/ - -void rprintf(const char *fmt, ...) -{ - int i; - char s[100]; - va_list args; - - va_start(args,fmt); - vsprintf(s,fmt,args); - va_end(args); - i=strlen(s)-1; - if (i>=0 && s[i]=='\n') { - s[i]=0; - writeln(s); - } - else writestr(s); -} - - -/*----------------------------------------------------------------------*/ -/* Memory allocation wrappers: All memory allocation should run through */ -/* these routines, which trap error conditions and do accounting to */ -/* help track down memory leaks. */ -/*----------------------------------------------------------------------*/ - -rbool rm_trap=1; - -long get_rm_size(void) -/* Return the amount of space being used by dynamically allocated things */ -{ -#ifdef MEM_INFO - struct mstats memdata; - - memdata=mstats(); - return memdata.bytes_used; -#endif - return 0; -} - -long get_rm_freesize(void) -/* Return estimate of amount of space left */ -{ -#ifdef MEM_INFO - struct mstats memdata; - - memdata=mstats(); - return memdata.bytes_free; -#endif - return 0; -} - - -void *rmalloc(long size) -{ - void *p; - - if (size>MAXSTRUC) { - printf("Memory allocation error: Over-sized structure requested.\n"); - exit(EXIT_FAILURE); - } - assert(size>=0); - if (size==0) return NULL; - p=malloc((size_t)size); - if (p==NULL && rm_trap && size>0) - { - printf("Memory allocation error: Out of memory.\n"); - exit(EXIT_FAILURE); - } - if (rm_acct) ralloc_cnt++; - return p; -} - -void *rrealloc(void *old,long size) -{ - void *p; - - if (size>MAXSTRUC) { - printf("Memory reallocation error: Oversized structure requested.\n"); - exit(EXIT_FAILURE); - } - assert(size>=0); - if (size==0) { - r_free(old); - return NULL; - } - if (rm_acct && old==NULL) ralloc_cnt++; - p=realloc(old,(size_t)size); - if (p==NULL && rm_trap && size>0) - { - printf("Memory reallocation error: Out of memory.\n"); - exit(EXIT_FAILURE); - } - return p; -} - -char *rstrdup(const char *s) -{ - char *t; -#ifndef HAVE_STRDUP - int i; -#endif - - if (s==NULL) return NULL; -#ifdef HAVE_STRDUP - t=strdup(s); -#else - t=malloc((strlen(s)+1)*sizeof(char)); -#endif - if (t==NULL && rm_trap) - { - printf("Memory duplication error: Out of memory.\n"); - exit(EXIT_FAILURE); - } - if (rm_acct) ralloc_cnt++; -#ifndef HAVE_STRDUP - for(i=0;s[i]!=0;i++) - t[i]=s[i]; - t[i]=0; -#endif - return t; -} - -void r_free(void *p) -{ - int tmp; - - if (p==NULL) return; - - tmp=get_rm_size(); /* Take worst case in all cases */ - if (tmp>rm_size) rm_size=tmp; - tmp=get_rm_freesize(); - if (tmp must be all upper case */ -/* *pstr is updated to point after the match, if it is succesful. - Otherwise *pstr is left alone. */ -rbool match_str(const char **pstr,const char *match) -{ - int i; - const char *s; - - s=*pstr; - for(i=0; match[i]!=0 && s[i]!=0;i++) - if (toupper(s[i])!=match[i]) return 0; - if (match[i]!=0) return 0; - *pstr+=i; - return 1; -} - - - - -/* Utility to concacate two strings with a space inserted */ - -char *concdup(const char *s1,const char *s2) -{ - int len1, len2; - char *s; - - len1=len2=0; - if (s1!=NULL) len1=strlen(s1); - if (s2!=NULL) len2=strlen(s2); - - s=rmalloc(sizeof(char)*(len1+len2+2)); - if (s1!=NULL) - memcpy(s,s1,len1); - memcpy(s+len1," ",1); - if (s2!=NULL) - memcpy(s+len1+1,s2,len2); - s[len1+len2+1]=0; - return s; -} - - -/* Misc. C utility functions that may be supported locally. - If they are, use the local functions since they'll probably be faster - and more efficiant. */ - -#ifdef NEED_STR_CMP -int strcasecmp(const char *s1,const char *s2) -/* Compare strings s1 and s2, case insensitive; */ -/* If equal, return 0. Otherwise return nonzero. */ -{ - int i; - - for(i=0;tolower(s1[i])==tolower(s2[i]) && s1[i]!=0;i++); - if (tolower(s1[i])==tolower(s2[i])) return 0; - if (s1[i]==0) return -1; - if (s2[i]==0) return 1; - if (tolower(s1[i])=n && buffsize>=0) { - buffsize+=READLN_GRAIN; n=buffsize-1; - buff=rrealloc(buff,buffsize*sizeof(char)); - } - - if (c==0) c=FORMAT_CODE; - else if (c!='\t') {if (in since we still need to discard - the rest of the line */ - } - - buff[i]=0; - - if (c=='\r') { /* Check for \r\n DOS-style newline */ - char newc; - newc=textgetc(f); - if (newc!='\n') textungetc(f,newc); - /* Replace the character we just read. */ - } else if (c==DOS_EOF) /* Ctrl-Z is the DOS EOF marker */ - textungetc(f,c); /* So it will be the first character we see next time */ - - if (i==0 && (c==EOF || c==DOS_EOF)) {/* We've hit the end of the file */ - if (buffsize>=0) rfree(buff); - return NULL; - } - - if (buffsize>=0) { /* Shrink buffer to appropriate size */ - buffsize=i+1; - buff=rrealloc(buff,buffsize); - } - - return buff; -} - - -/*-------------------------------------------------------------------------*/ -/* Buffered file Input: Routines to do buffered file I/O for files organized */ -/* into records. These routines are highly non-reentrant: they use a */ -/* global buffer and a global file id, so only they can only access one */ -/* file at a time. */ -/* buffopen() should not be called on a new file until buffclose has been */ -/* called on the old one. */ -/*-------------------------------------------------------------------------*/ - -genfile bfile; - -static uchar *buffer=NULL; -static long buffsize; /* How big the buffer is */ -static long record_size; /* Size of a record in the file */ -static long buff_frame; /* The file index corrosponding to buffer[0] */ -static long buff_fcnt; /* Number of records that can be held in the buffer */ -static long real_buff_fcnt; /* Number of records actually held in buffer */ -static long buff_rsize; /* Minimum amount that must be read. */ - -static long block_size; /* Size of the current block - (for non-AGX files, this is just the filesize) */ -static long block_offset; /* Offset of current block in file (this should - be zero for non-AGX files) */ - - -static void buff_setrecsize(long recsize) -{ - char *errstr; - - record_size=recsize; - real_buff_fcnt=buff_fcnt=buffsize/record_size; - buff_frame=0; - - /* Note that real_buff_cnt==buff_fcnt in this case because - the buffer will have already been resized to be <= - the block size-- so we don't need to worry about the - buffer being larger than the data we're reading in. */ - - binseek(bfile,block_offset); - if (!binread(bfile,buffer,record_size,real_buff_fcnt,&errstr)) - fatal(errstr); -} - - - -long buffopen(fc_type fc,filetype ext,long minbuff,char *rectype,long recnum) - /* Returns record size; print out error and halt on failure */ - /* (if agx_file, it returns the filesize instead) */ - /* rectype="noun","room", etc. recnum=number of records expected */ - /* If rectype==NULL, buffopen() will return 0 on failure instead of - halting */ - /* For AGX files, recsize should be set to minbuff... but - buffreopen will be called before any major file activity - (in particular, recnum should be 1) */ -{ - long filesize; - long recsize; - char ebuff[200]; - char *errstr; - - assert(buffer==NULL); /* If not, it means these routines have been - called by someone else who isn't done yet */ - - bfile=readopen(fc,ext,&errstr); - if (errstr!=NULL) { - if (rectype==NULL) - { rfree(errstr); return 0;} - else - fatal(errstr); - } - - filesize=binsize(bfile); - - block_size=filesize; - block_offset=0; - if (agx_file) block_size=minbuff; /* Just for the beginning */ - - if (block_size % recnum !=0) { - sprintf(ebuff,"Fractional record count in %s file.",rectype); - agtwarn(ebuff,0);} - buff_rsize=recsize=block_size/recnum; - if (buff_rsize>minbuff) buff_rsize=minbuff; - - /* No point in having a buffer bigger than the block size */ - buffsize=BUFF_SIZE; - if (block_size=buff_frame && indexbuff_fcnt) - real_buff_fcnt=buff_fcnt; /* Don't overflow buffer */ - if (!binread(bfile,buffer,record_size,real_buff_fcnt,&errstr)) - fatal(errstr); - buff_frame=index; - bptr=buffer; - } - if (!agx_file) compute_sig(bptr); - return bptr; -} - - -void buffclose(void) -{ - readclose(bfile); - rfree(buffer); -} - - -/* This changes the record size and offset settings of the buffered - file so we can read files that consist of multiple sections with - different structures */ -static void buffreopen(long f_ofs, long file_recsize, long recnum, - long bl_size, char *rectype) -{ - char ebuff[200]; - long recsize; - - /* Compute basic statistics */ - block_offset=f_ofs; /* Offset of this block */ - block_size=bl_size; /* Size of the entire block (all records) */ - if (block_size % recnum !=0) { - /* Check that the number of records divides the block size evenly */ - sprintf(ebuff,"Fractional record count in %s block.",rectype); - agtwarn(ebuff,0);} - buff_rsize=recsize=block_size/recnum; - if (buff_rsize>file_recsize) buff_rsize=file_recsize; - /* recsize is the size of each record in the file. - buff_rsize is the internal size of each record (the part - we actually look at, which may be smaller than recsize) */ - - /* No point in having a buffer bigger than the block size */ - buffsize=BUFF_SIZE; - if (block_sizebw_fileleng) - bw_fileleng=block_offset+bw_last*record_size; -#endif - bw_first=bw_last=0; -} - - - -static void bw_setblock(long fofs, long recnum, long rsize) - /* Set parameters for current block */ -{ - /* First, flush old block if neccessary */ - if (buffer!=NULL) { - bw_flush(); - rfree(buffer); - } - block_size=rsize*recnum; - block_offset=fofs; - record_size=rsize; - buff_frame=0;bw_first=bw_last=0; - buffsize=BUFF_SIZE; - if (buffsize>block_size) buffsize=block_size; - if (buffsizebw_last || index>=buff_fcnt) { - bw_flush(); - bw_first=bw_last=0; - buff_frame=buff_frame+index; - index=0; - } - if (index==bw_last) bw_last++; - return buffer+record_size*index; -} - - -/* This flushes all buffers to disk and closes all files */ -void bw_close(void) -{ - bw_flush(); - rfree(buffer); - writeclose(bfile,bw_fileid); -} - -void bw_abort(void) -{ - binremove(bfile,bw_fileid); -} - - -/*-------------------------------------------------------------------------*/ -/* Block reading and writing code and support for internal buffers */ -/*-------------------------------------------------------------------------*/ - - -/* If the internal buffer is not NULL, it is used instead of a file */ -/* (This is used by RESTART, etc. to save state to memory rather than - to a file) */ -static uchar *int_buff=NULL; -static long ibuff_ofs, ibuff_rsize; - -void set_internal_buffer(void *buff) -{ - int_buff=(uchar*)buff; -} - -static void set_ibuff(long offset, long rsize) -{ - ibuff_ofs=offset; - record_size=ibuff_rsize=rsize; -} - -static uchar *get_ibuff(long index) -{ - return int_buff+ibuff_ofs+index*ibuff_rsize; -} - -/* This does a block write to the currently buffered file. - At the moment this itself does no buffering at all; it's intended - for high speed reading of blocks of chars for which we've already - allocated the space. */ -static void buff_blockread(void *buff,long size,long offset) -{ - char *errstr; - - if (int_buff!=NULL) - memcpy((char*)buff,int_buff+offset,size); - else { - binseek(bfile,offset); - if (!binread(bfile,buff,size,1,&errstr)) fatal(errstr); - } -} - - -/* This writes buff to disk. */ -static void bw_blockwrite(char *buff,long size,long offset) -{ - if (int_buff!=NULL) - memcpy(int_buff+offset,(char*)buff,size); - else { - bw_flush(); - bw_seek(offset); - binwrite(bfile,buff,size,1,1); -#ifdef DEBUG_SEEK - if (offset+size>bw_fileleng) bw_fileleng=offset+size; -#endif - } -} - - -/*-------------------------------------------------------------------------*/ -/* Platform-independent record-based file I/O: Routines to read and write */ -/* files according to the file_info data structures. */ -/* These routines use the buffered I/O routines above */ -/*-------------------------------------------------------------------------*/ - - /* Length of file datatypes */ -const size_t ft_leng[FT_COUNT]={0,2,2, /* END, int16, and uint16 */ - 4,4, /* int32 and uint32 */ - 1,2,0, /* byte, version, rbool */ - 8,4, /* descptr, ss_ptr */ - 2,26, /* slist, path[13] */ - 4,4, /* cmdptr, dictptr */ - 81, /* tline */ - 1,1}; /* char, cfg */ - - -long compute_recsize(file_info *recinfo) -{ - long cnt, bcnt; - - cnt=0; - for(;recinfo->ftype!=FT_END;recinfo++) - if (recinfo->ftype==FT_BOOL) { - for(bcnt=0;recinfo->ftype==FT_BOOL;recinfo++,bcnt++); - recinfo--; - cnt+=(bcnt+7)/8; /* +7 is to round up */ - } else - cnt+=ft_leng[recinfo->ftype]; - return cnt; -} - -static const int agx_version[]={0,0000,1800,2000,3200,3500,8200,8300, - 5000,5050,5070,10000,10050,15000,15500,16000,20000}; - -static int agx_decode_version(int vercode) -{ - if (vercode&1) /* Large/Soggy */ - if (vercode==3201) ver=4; - else ver=2; - else - if (vercode<10000) ver=1; - else ver=3; - switch(vercode&(~1)) - { - case 0000: return AGT10; - case 1800: return AGT118; - case 1900: return AGT12; - case 2000: return AGT12; - case 3200: return AGTCOS; - case 3500: return AGT135; - case 5000: return AGT15; - case 5050: return AGT15F; - case 5070: return AGT16; - case 8200: return AGT182; - case 8300: return AGT183; - case 8350: return AGT183; - case 10000:return AGTME10; - case 10050:return AGTME10A; - case 15000:return AGTME15; - case 15500:return AGTME155; - case 16000:return AGTME16; - case 20000:return AGX00; - default:agtwarn("Unrecognize AGT version",0); - return 0; - } -} - -/* The following reads a section of a file into variables, doing - the neccessary conversions. It is the foundation of all the generic - file reading code */ - -#define p(t) ((t*)(rec_desc->ptr)) -#define fixu16(n1,n2) ( ((long)(n1))|( ((long)(n2))<<8 )) - -/* This is as large as the largest data structure we could run into */ -static const uchar zero_block[81]={0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0, - 0}; - -static void read_filerec(const file_info *rec_desc, const uchar *filedata) -{ - uchar mask; - rbool past_eob; /* Are we past the end of block? */ - const uchar *filebase; - - mask=1; - past_eob=0; - filebase=filedata; - for(;rec_desc->ftype!=FT_END;rec_desc++) { - if (mask!=1 && rec_desc->ftype!=FT_BOOL) { /* Just finished rboolean */ - mask=1; - filedata+=1; - } - if (filebase==NULL || (filedata-filebase)>=record_size ) { - /* We're past the end of the block; read in zeros for the rest - of entries. */ - past_eob=1; - filedata=zero_block; - filebase=NULL; - } - switch(rec_desc->ftype) - { - case FT_INT16: - if (rec_desc->dtype==DT_LONG) - *p(long)=fixsign16(filedata[0],filedata[1]); - else - *p(integer)=fixsign16(filedata[0],filedata[1]); - break; - case FT_UINT16: - *p(long)=fixu16(filedata[0],filedata[1]); - break; - case FT_CMDPTR: /* cmd ptr */ - case FT_INT32: - *p(long)=fixsign32(filedata[0],filedata[1], - filedata[2],filedata[3]); - break; - case FT_UINT32: - if (filedata[3]&0x80) - agtwarn("File value out of range",0); - *p(long)=fixsign32(filedata[0],filedata[1], - filedata[2],filedata[3]&0x7F); - break; - case FT_BYTE: *p(uchar)=filedata[0];break; - case FT_CHAR: - *p(uchar)=trans_ascii[filedata[0]^'r']; - break; - case FT_VERSION: - *p(int)=agx_decode_version(fixu16(filedata[0],filedata[1])); - break; - case FT_CFG: - if (filedata[0]!=2 && !past_eob) - *p(rbool)=filedata[0]; - break; - case FT_BOOL: - *p(rbool)=( (filedata[0]&mask)!=0); - if (mask==0x80) { - filedata++; mask=1; - } else - mask<<=1; - break; - case FT_DESCPTR: - if (skip_descr) break; - p(descr_ptr)->start=fixsign32(filedata[0],filedata[1], - filedata[2],filedata[3]); - p(descr_ptr)->size=fixsign32(filedata[4],filedata[5], - filedata[6],filedata[7]); - break; - case FT_STR: /* ss_string ptr */ - *p(char*)=static_str+fixsign32(filedata[0],filedata[1], - filedata[2],filedata[3]); - break; - case FT_SLIST: - *p(slist)=fixsign16(filedata[0],filedata[1]); - break; - case FT_PATHARRAY: /* integer array[13] */ - { - int i; - for(i=0;i<13;i++) - p(integer)[i]=fixsign16(filedata[2*i],filedata[2*i+1]); - break; - } - case FT_TLINE: { /* string of length at most 80 characters +null */ - uchar *s; - int i; - s=(uchar*)*p(tline); - for(i=0; i<80; i++) - s[i]=trans_ascii[filedata[i]^'r']; - s[80]=0; - break; - } - case FT_DICTPTR: /* ptr into dictstr */ - *p(char*)=dictstr+fixsign32(filedata[0],filedata[1], - filedata[2],filedata[3]); - break; - default:fatal("Unreconized field type"); - } - filedata+=ft_leng[rec_desc->ftype]; - } -} - - -#define v(t) (*(t*)(rec_desc->ptr)) -/* Here is the corresponding routien for _writing_ to files */ -/* This copies the contents of a record into a buffer */ - -static void write_filerec(const file_info *rec_desc, uchar *filedata) -{ - uchar mask; - - mask=1; - for(;rec_desc->ftype!=FT_END;rec_desc++) { - if (mask!=1 && rec_desc->ftype!=FT_BOOL) { /* Just finished rboolean */ - mask=1; - filedata+=1; - } - switch(rec_desc->ftype) - { - case FT_INT16: - if (rec_desc->dtype==DT_LONG) { - filedata[0]=v(long)&0xFF; - filedata[1]=(v(long)>>8)&0xFF; - } else { - filedata[0]=v(integer)&0xFF; - filedata[1]=(v(integer)>>8)&0xFF; - } - break; - case FT_UINT16: - filedata[0]=v(long)&0xFF; - filedata[1]=(v(long)>>8)&0xFF; - break; - case FT_CMDPTR: /* cmd ptr */ - case FT_INT32: - case FT_UINT32: - filedata[0]=v(long)&0xFF; - filedata[1]=(v(long)>>8)&0xFF; - filedata[2]=(v(long)>>16)&0xFF; - filedata[3]=(v(long)>>24)&0xFF; - break; - case FT_BYTE: filedata[0]=v(uchar);break; - case FT_CFG: filedata[0]=v(uchar);break; - case FT_CHAR: filedata[0]=v(uchar)^'r';break; - case FT_VERSION: - { - int tver; - tver=agx_version[v(int)]; - if (ver==2 || ver==4) tver+=1; - filedata[0]=tver&0xFF; - filedata[1]=(tver>>8)&0xFF; - break; - } - case FT_BOOL: - if (mask==1) filedata[0]=0; - filedata[0]|=v(rbool)?mask:0; - if (mask==0x80) { - filedata++; mask=1; - } else - mask<<=1; - break; - case FT_DESCPTR: - { - long i,n1,n2; - n1=p(descr_ptr)->start; - n2=p(descr_ptr)->size; - for(i=0;i<4;i++) { - filedata[i]=n1&0xFF; - filedata[i+4]=n2&0xFF; - n1>>=8;n2>>=8; - } - } - break; - case FT_STR: /* ss_string ptr */ - { - long delta; - delta=v(char*)-static_str; - filedata[0]=delta&0xFF; - filedata[1]=(delta>>8)&0xFF; - filedata[2]=(delta>>16)&0xFF; - filedata[3]=(delta>>24)&0xFF; - break; - } - case FT_SLIST: - filedata[0]=v(slist)&0xFF; - filedata[1]=(v(slist)>>8)&0xFF; - break; - case FT_PATHARRAY: /* integer array[13] */ - { - int i; - for(i=0;i<13;i++) { - filedata[2*i]=*(p(integer)+i)&0xFF; - filedata[2*i+1]=(*(p(integer)+i)>>8)&0xFF; - } - break; - } - case FT_TLINE: { /* string of length at most 80 characters +null */ - uchar *s; - int i; - s=(uchar*)v(tline); - for(i=0; i<80; i++) - filedata[i]=s[i]^'r'; - filedata[80]=0; - break; - } - case FT_DICTPTR: /* ptr into dictstr */ - { - long delta; - delta=v(char*)-dictstr; - filedata[0]=delta&0xFF; - filedata[1]=(delta>>8)&0xFF; - filedata[2]=(delta>>16)&0xFF; - filedata[3]=(delta>>24)&0xFF; - break; - } - default:fatal("Unreconized field type"); - } - filedata+=ft_leng[rec_desc->ftype]; - } -} - -#undef v -#undef p - - - - -/* This reads in a structure array */ -/* base=the beginning of the array. If NULL, this is malloc'd and returned - eltsize = the size of each structure - numelts = the number of elements in the array - field_info = the arrangement of fields within the strucutre - rectype = string to print out for error messages - file_offset = the offset of the beginning of the array into the file - */ -void *read_recarray(void *base, long eltsize, long numelts, - file_info *field_info, char *rectype, - long file_offset, long file_blocksize) -{ - long i; - file_info *curr; - uchar *file_data; - - if (numelts==0) return NULL; - - if (int_buff) - set_ibuff(file_offset,compute_recsize(field_info)); - else - buffreopen(file_offset, compute_recsize(field_info), numelts, - file_blocksize, rectype); - - if (base==NULL) - base=rmalloc(eltsize*numelts); - - for(curr=field_info;curr->ftype!=FT_END;curr++) - if (curr->dtype!=DT_DESCPTR && curr->dtype!=DT_CMDPTR) - curr->ptr=( (char*)base + curr->offset); - - for(i=0;iftype!=FT_END;curr++) - if (curr->dtype==DT_DESCPTR) - curr->ptr=(char*)(curr->ptr)+sizeof(descr_ptr); - else if (curr->dtype==DT_CMDPTR) - curr->ptr=(char*)(curr->ptr)+sizeof(long); - else - curr->ptr=(char*)(curr->ptr)+eltsize; - } - - return base; -} - - -/* A NULL value means to write junk; we're just producing - a placeholder for systems that can't seek beyond the end-of-file */ - -long write_recarray(void *base, long eltsize, long numelts, - file_info *field_info, long file_offset) -{ - long i; - file_info *curr; - uchar *file_data; - - if (numelts==0) return 0; - - if (int_buff) - set_ibuff(file_offset,compute_recsize(field_info)); - else - bw_setblock(file_offset, numelts, compute_recsize(field_info)); - - if (base!=NULL) - for(curr=field_info;curr->ftype!=FT_END;curr++) - if (curr->dtype!=DT_DESCPTR && curr->dtype!=DT_CMDPTR) - curr->ptr=( (char*)base + curr->offset); - - for(i=0;iftype!=FT_END;curr++) - if (curr->dtype==DT_DESCPTR) - curr->ptr=(char*)(curr->ptr)+sizeof(descr_ptr); - else if (curr->dtype==DT_CMDPTR) - curr->ptr=(char*)(curr->ptr)+sizeof(long); - else - curr->ptr=(char*)(curr->ptr)+eltsize; - } - } - return compute_recsize(field_info)*numelts; -} - - -void read_globalrec(file_info *global_info, char *rectype, - long file_offset, long file_blocksize) -{ - uchar *file_data; - - if (int_buff) { - set_ibuff(file_offset,compute_recsize(global_info)); - file_data=get_ibuff(0); - } else { - buffreopen(file_offset, compute_recsize(global_info), 1, file_blocksize, - rectype); - file_data=buffread(0); - } - read_filerec(global_info,file_data); -} - - -long write_globalrec(file_info *global_info, long file_offset) -{ - uchar *file_data; - - if (int_buff) { - set_ibuff(file_offset,compute_recsize(global_info)); - file_data=get_ibuff(0); - } else { - bw_setblock(file_offset, 1, compute_recsize(global_info)); - file_data=bw_getbuff(0); - } - write_filerec(global_info,file_data); - return compute_recsize(global_info); -} - - - -static file_info fi_temp[]={ - {0,DT_DEFAULT,NULL,0}, - endrec -}; - -/* This routine reads in an array of simple data */ - -void *read_recblock(void *base,int ftype,long numrec, - long offset, long bl_size) -{ - int dsize; - - switch(ftype) - { - case FT_CHAR: - case FT_BYTE: - if (base==NULL) base=rmalloc(numrec*sizeof(char)); - buff_blockread(base,numrec,offset); - if (ftype==FT_CHAR) { - long i; - for(i=0;i>--- -args.o: args.c args.h main.h types.h sysdep.h acode.h -arun.o: arun.c main.h types.h sysdep.h acode.h term.h version.h args.h -chartest.o: chartest.c -debug.o: debug.c types.h sysdep.h acode.h version.h readline.h inter.h \ - main.h parse.h exe.h debug.h -decode.o: decode.c main.h types.h sysdep.h acode.h decode.h -dumpacd.o: dumpacd.c types.h sysdep.h acode.h spa.h -exe.o: exe.c types.h sysdep.h acode.h readline.h main.h parse.h \ - inter.h stack.h decode.h exe.h -genalan.o: genalan.c spa.h -inter.o: inter.c types.h sysdep.h acode.h main.h parse.h exe.h stack.h \ - inter.h -main.o: main.c sysdep.h types.h acode.h main.h readline.h version.h \ - args.h parse.h inter.h rules.h debug.h stack.h exe.h term.h -params.o: params.c types.h sysdep.h acode.h params.h -parse.o: parse.c types.h sysdep.h acode.h readline.h main.h inter.h \ - exe.h term.h debug.h params.h parse.h -readline.o: readline.c readline.h types.h sysdep.h acode.h main.h -reverse.o: reverse.c types.h sysdep.h acode.h main.h reverse.h -rules.o: rules.c types.h sysdep.h acode.h main.h inter.h debug.h exe.h \ - stack.h rules.h -spa.o: spa.c spa.h -stack.o: stack.c types.h sysdep.h acode.h main.h stack.h -sysdep.o: sysdep.c sysdep.h -term.o: term.c main.h types.h sysdep.h acode.h term.h -version.o: version.c version.h diff --git a/app/src/main/jni/terps/alan/alan2/Makefile.cygwin b/app/src/main/jni/terps/alan/alan2/Makefile.cygwin deleted file mode 100755 index b7fd57a..0000000 --- a/app/src/main/jni/terps/alan/alan2/Makefile.cygwin +++ /dev/null @@ -1,86 +0,0 @@ -# Makefile for Alan interpreter to be built with CygWin - -#CYGWIN = -DCOMPILER=\"[MinGWb20]\" -mno-cygwin -I/cygnus/mingw/include -L/cygnus/mingw/lib -#CYGWIN = -DCOMPILER=\"[MinGWb20]\" -mno-cygwin -CYGWIN = -DCOMPILER=\"[CygWin32]\" - -# Define this to make interpreter log each crc calculation step -#CRCLOG = -DCRCLOG - -CFLAGS = -g -Wall -funsigned-char $(CYGWIN) $(CRCLOG) - -LDFLAGS = -g $(CYGWIN) $(VERBOSE) -#LIB = ../../Glk/WinGlk/Glk.lib -LIB = ../Glk/WinGlk/Glk.lib - -OBJECTS = arun.o \ - main.o \ - debug.o \ - args.o \ - exe.o \ - inter.o \ - parse.o \ - rules.o \ - stack.o \ - decode.o \ - term.o \ - reverse.o \ - readline.o \ - params.o \ - sysdep.o \ - alan.version.o - - -arun.exe : $(OBJECTS) - gcc -o arun.exe $(OBJECTS) $(LDFLAGS) $(LIB) - cp arun.exe ../bin - -dumpacd: dumpacd.o reverse.o spa.o - $(CC) -o dumpacd $(CFLAGS) dumpacd.o reverse.o spa.o - -spa.o: spa.c spa.h - gcc $(CFLAGS) -DSTDIONONCONST -c spa.c -o spa.o - - -strip: - strip arun - coff2exe arun - -alan.version.c : ../alan.version.c alan.version.h - cp ../alan.version.c . - -alan.version.h : ../alan.version.h version.h - cp ../alan.version.h . - -version.h : ../version.h - cp ../version.h . - - - -#---<< GENERATED DEPENDENCIES FOLLOWS >>--- -args.o: args.c args.h main.h types.h sysdep.h acode.h -arun.o: arun.c main.h types.h sysdep.h acode.h term.h version.h args.h -chartest.o: chartest.c -debug.o: debug.c types.h sysdep.h acode.h version.h readline.h inter.h \ - main.h parse.h exe.h debug.h -decode.o: decode.c main.h types.h sysdep.h acode.h decode.h -dumpacd.o: dumpacd.c types.h sysdep.h acode.h spa.h -exe.o: exe.c types.h sysdep.h acode.h readline.h main.h parse.h \ - inter.h stack.h decode.h exe.h -genalan.o: genalan.c spa.h -inter.o: inter.c types.h sysdep.h acode.h main.h parse.h exe.h stack.h \ - inter.h -main.o: main.c sysdep.h types.h acode.h main.h readline.h version.h \ - args.h parse.h inter.h rules.h debug.h stack.h exe.h term.h -params.o: params.c types.h sysdep.h acode.h params.h -parse.o: parse.c types.h sysdep.h acode.h readline.h main.h inter.h \ - exe.h term.h debug.h params.h parse.h -readline.o: readline.c readline.h types.h sysdep.h acode.h main.h -reverse.o: reverse.c types.h sysdep.h acode.h main.h reverse.h -rules.o: rules.c types.h sysdep.h acode.h main.h inter.h debug.h exe.h \ - stack.h rules.h -spa.o: spa.c spa.h -stack.o: stack.c types.h sysdep.h acode.h main.h stack.h -sysdep.o: sysdep.c sysdep.h -term.o: term.c main.h types.h sysdep.h acode.h term.h -version.o: version.c version.h diff --git a/app/src/main/jni/terps/alan/alan2/Makefile.gg b/app/src/main/jni/terps/alan/alan2/Makefile.gg deleted file mode 100755 index 4078603..0000000 --- a/app/src/main/jni/terps/alan/alan2/Makefile.gg +++ /dev/null @@ -1,71 +0,0 @@ -# Makefile for Alan interpreter to be built with Geek Gadgets GNU gcc on Amiga - -COMPILER = -DCOMPILER="\"[GG GCC 2.7.2.1]\"" - -# Define this to make interpreter log each crc calculation step -#CRCLOG = -DCRCLOG - -CFLAGS = -g -Wall -funsigned-char $(COMPILER) $(VERBOSE) $(CRCLOG) -DHAVE_ANSI - -LDFLAGS = -g -lamiga -noixemul - -OBJECTS = arun.o \ - main.o \ - debug.o \ - args.o \ - exe.o \ - inter.o \ - parse.o \ - rules.o \ - stack.o \ - decode.o \ - term.o \ - params.o \ - sysdep.o \ - alan.version.o - - -arun : $(OBJECTS) - gcc -o arun $(OBJECTS) $(LDFLAGS) $(LIB) - copy arun .. - -dumpacd: dumpacd.o reverse.o spa.o - $(CC) -o dumpacd $(CFLAGS) dumpacd.o reverse.o spa.o - -spa.o: spa.c spa.h - gcc $(CFLAGS) -DSTDIONONCONST -c spa.c -o spa.o - - -strip: - strip arun - coff2exe arun - - - -#---<< GENERATED DEPENDENCIES FOLLOWS >>--- -args.o: args.c args.h main.h types.h sysdep.h acode.h -arun.o: arun.c main.h types.h sysdep.h acode.h term.h alan.version.h args.h -chartest.o: chartest.c -debug.o: debug.c types.h sysdep.h acode.h alan.version.h readline.h inter.h \ - main.h parse.h exe.h debug.h -decode.o: decode.c main.h types.h sysdep.h acode.h decode.h -dumpacd.o: dumpacd.c types.h sysdep.h acode.h spa.h -exe.o: exe.c types.h sysdep.h acode.h readline.h main.h parse.h \ - inter.h stack.h decode.h exe.h -genalan.o: genalan.c spa.h -inter.o: inter.c types.h sysdep.h acode.h main.h parse.h exe.h stack.h \ - inter.h -main.o: main.c sysdep.h types.h acode.h main.h readline.h alan.version.h \ - args.h parse.h inter.h rules.h debug.h stack.h exe.h term.h -params.o: params.c types.h sysdep.h acode.h params.h -parse.o: parse.c types.h sysdep.h acode.h readline.h main.h inter.h \ - exe.h term.h debug.h params.h parse.h -readline.o: readline.c readline.h types.h sysdep.h acode.h main.h -reverse.o: reverse.c types.h sysdep.h acode.h main.h reverse.h -rules.o: rules.c types.h sysdep.h acode.h main.h inter.h debug.h exe.h \ - stack.h rules.h -spa.o: spa.c spa.h -stack.o: stack.c types.h sysdep.h acode.h main.h stack.h -sysdep.o: sysdep.c sysdep.h -term.o: term.c main.h types.h sysdep.h acode.h term.h - diff --git a/app/src/main/jni/terps/alan/alan2/Makefile.glk b/app/src/main/jni/terps/alan/alan2/Makefile.glk deleted file mode 100755 index 31fee00..0000000 --- a/app/src/main/jni/terps/alan/alan2/Makefile.glk +++ /dev/null @@ -1,121 +0,0 @@ -# Makefile for Alan interpreter to be built with Glk for Windows (using gcc) - -# Glk definitions - -GLKROOT = /home/thoni/Alan/WindowsGLK -GLKINCLUDEDIR = $(GLKROOT)/Include -#GLKLIBDIR = /usr/local/lib/glk -GLKLIB = $(GLKROOT)/Glk.lib -#GLKMAKEFILE = Make.xglk -GLKTARGET = winarun - -GLK = -DGLK -DWINGLK - -#A tag describing the type of build -#COMPILER = -DCOMPILER=\"[glk]\" -CYGWIN = -mno-cygwin -mwindows - -# Define this for more verbosity -#VERBOSE = -DVERBSOE - -# Define this to make interpreter log each crc calculation step -#CRCLOG = -DCRCLOG - -# Define this if the headers are reversed on this platform if not set in sysdep -#REVERSED = -DREVERSED - -# Define the program name -PROGNAME=-DPROGNAME=\"$(GLKTARGET)\" - -# Where do you want to put it? -INSTALLDIR = ../bin - - -#include $(GLKINCLUDEDIR)/$(GLKMAKEFILE) - -### Do not edit below this line ### - -ARUNOPTS = $(VERBOSE) $(CRCLOG) $(REVERSED) $(PROGNAME) $(GLK) $(CYGWIN) - -CC = gcc -CFLAGS = -g -Wall -funsigned-char -I$(GLKINCLUDEDIR) $(ARUNOPTS) - -LINK = gcc -LDFLAGS = -g $(ARUNOPTS) -LIBS = $(LINKLIBS) $(GLKLIB) - -INSTALL = install -INSTFLAGS = -g 0 -o 0 -s - -GLKOBJS = winglk.o glkstart.o glkio.o - -OBJECTS = arun.o \ - main.o \ - debug.o \ - args.o \ - exe.o \ - inter.o \ - parse.o \ - rules.o \ - stack.o \ - decode.o \ - term.o \ - reverse.o \ - readline.o \ - params.o \ - sysdep.o \ - alan.version.o - -# my package didn't include sources for dumpacd -#all: $(GLKTARGET) dumpacd -all: $(GLKTARGET) - -$(GLKTARGET) : $(OBJECTS) $(GLKOBJS) - $(LINK) -o $(GLKTARGET) $(OBJECTS) $(GLKOBJS) $(LDFLAGS) $(LIBS) - -dumpacd: dumpacd.o reverse.o spa.o - $(LINK) -o dumpacd $(LDFLAGS) dumpacd.o reverse.o spa.o - -spa.o: spa.c spa.h - $(CC) $(CFLAGS) -DSTDIONONCONST -c spa.c -o spa.o - -#install: $(GLKTARGET) dumpacd -install: $(GLKTARGET) - $(INSTALL) $(INSTFLAGS) $(GLKTARGET) $(INSTALLDIR) -# $(INSTALL) $(INSTFLAGS) dumpacd $(INSTALLDIR) - -clean: - rm -f $(GLKTARGET) dumpacd *.o *~ .arch - -#---<< Glk objects >>--- -glkstart.o: glkstart.c glkstart.h glkio.h -glkio.o: glkio.c glkio.h -winglk.o: winglk.c - -#---<< GENERATED DEPENDENCIES FOLLOWS >>--- -args.o: args.c args.h main.h types.h sysdep.h acode.h glkio.h -arun.o: arun.c main.h types.h sysdep.h acode.h term.h alan.version.h \ - args.h glkio.h -chartest.o: chartest.c -debug.o: debug.c types.h sysdep.h acode.h alan.version.h readline.h inter.h \ - main.h parse.h exe.h debug.h glkio.h -decode.o: decode.c main.h types.h sysdep.h acode.h decode.h -dumpacd.o: dumpacd.c types.h sysdep.h acode.h spa.h -exe.o: exe.c types.h sysdep.h acode.h readline.h main.h parse.h \ - inter.h stack.h decode.h exe.h -genalan.o: genalan.c spa.h -inter.o: inter.c types.h sysdep.h acode.h main.h parse.h exe.h stack.h \ - inter.h glkio.h -main.o: main.c sysdep.h types.h acode.h main.h readline.h alan.version.h \ - args.h parse.h inter.h rules.h debug.h stack.h exe.h term.h glkio.h -params.o: params.c types.h sysdep.h acode.h params.h -parse.o: parse.c types.h sysdep.h acode.h readline.h main.h inter.h \ - exe.h term.h debug.h params.h parse.h glkio.h -readline.o: readline.c readline.h types.h sysdep.h acode.h main.h -reverse.o: reverse.c types.h sysdep.h acode.h main.h reverse.h -rules.o: rules.c types.h sysdep.h acode.h main.h inter.h debug.h exe.h \ - stack.h rules.h glkio.h -spa.o: spa.c spa.h -stack.o: stack.c types.h sysdep.h acode.h main.h stack.h -sysdep.o: sysdep.c sysdep.h -term.o: term.c main.h types.h sysdep.h acode.h term.h diff --git a/app/src/main/jni/terps/alan/alan2/Makefile.gpp b/app/src/main/jni/terps/alan/alan2/Makefile.gpp deleted file mode 100755 index 1340225..0000000 --- a/app/src/main/jni/terps/alan/alan2/Makefile.gpp +++ /dev/null @@ -1,82 +0,0 @@ -CFLAGS = -g -ansi -pedantic -funsigned-char -Uunix -U__unix__ -D__dos__ - -LDFLAGS = -g - -OBJECTS = arun.o \ - debug.o \ - args.o \ - exe.o \ - inter.o \ - parse.o \ - rules.o \ - stack.o \ - decode.o \ - term.o \ - reverse.o \ - params.o \ - sysdep.o \ - version.o - - -arun.exe : $(OBJECTS) - gcc -o arun $(OBJECTS) $(LDFLAGS) - copy arun.exe .. - -strip: - strip arun - coff2exe arun - -#---<< GENERATED DEPENDENCIES FOLLOWS >>--- -args.obj: args.c args.h main.h types.h sysdep.h acode.h -arun.obj: arun.c main.h types.h sysdep.h acode.h term.h version.h args.h -chartest.obj: chartest.c -debug.obj: debug.c types.h sysdep.h acode.h version.h readline.h inter.h \ - main.h parse.h exe.h debug.h -decode.obj: decode.c main.h types.h sysdep.h acode.h decode.h -dumpacd.obj: dumpacd.c types.h sysdep.h acode.h spa.h -exe.obj: exe.c types.h sysdep.h acode.h readline.h main.h parse.h \ - inter.h stack.h decode.h exe.h -genalan.obj: genalan.c spa.h -inter.obj: inter.c types.h sysdep.h acode.h main.h parse.h exe.h stack.h \ - inter.h -main.obj: main.c sysdep.h types.h acode.h main.h readline.h version.h \ - args.h parse.h inter.h rules.h debug.h stack.h exe.h term.h -params.obj: params.c types.h sysdep.h acode.h params.h -parse.obj: parse.c types.h sysdep.h acode.h readline.h main.h inter.h \ - exe.h term.h debug.h params.h parse.h -readline.obj: readline.c readline.h types.h sysdep.h acode.h main.h -reverse.obj: reverse.c types.h sysdep.h acode.h main.h reverse.h -rules.obj: rules.c types.h sysdep.h acode.h main.h inter.h debug.h exe.h \ - stack.h rules.h -spa.obj: spa.c spa.h -stack.obj: stack.c types.h sysdep.h acode.h main.h stack.h -sysdep.obj: sysdep.c sysdep.h -term.obj: term.c main.h types.h sysdep.h acode.h term.h -version.obj: version.c version.h -#---<< GENERATED DEPENDENCIES FOLLOWS >>--- -args.obj: args.c args.h main.h types.h sysdep.h acode.h -arun.obj: arun.c main.h types.h sysdep.h acode.h term.h version.h args.h -chartest.obj: chartest.c -debug.obj: debug.c types.h sysdep.h acode.h version.h readline.h inter.h \ - main.h parse.h exe.h debug.h -decode.obj: decode.c main.h types.h sysdep.h acode.h decode.h -dumpacd.obj: dumpacd.c types.h sysdep.h acode.h spa.h -exe.obj: exe.c types.h sysdep.h acode.h readline.h main.h parse.h \ - inter.h stack.h decode.h exe.h -genalan.obj: genalan.c spa.h -inter.obj: inter.c types.h sysdep.h acode.h main.h parse.h exe.h stack.h \ - inter.h -main.obj: main.c sysdep.h types.h acode.h main.h readline.h version.h \ - args.h parse.h inter.h rules.h debug.h stack.h exe.h term.h -params.obj: params.c types.h sysdep.h acode.h params.h -parse.obj: parse.c types.h sysdep.h acode.h readline.h main.h inter.h \ - exe.h term.h debug.h params.h parse.h -readline.obj: readline.c readline.h types.h sysdep.h acode.h main.h -reverse.obj: reverse.c types.h sysdep.h acode.h main.h reverse.h -rules.obj: rules.c types.h sysdep.h acode.h main.h inter.h debug.h exe.h \ - stack.h rules.h -spa.obj: spa.c spa.h -stack.obj: stack.c types.h sysdep.h acode.h main.h stack.h -sysdep.obj: sysdep.c sysdep.h -term.obj: term.c main.h types.h sysdep.h acode.h term.h -version.obj: version.c version.h diff --git a/app/src/main/jni/terps/alan/alan2/Makefile.mgw b/app/src/main/jni/terps/alan/alan2/Makefile.mgw deleted file mode 100755 index d947d2c..0000000 --- a/app/src/main/jni/terps/alan/alan2/Makefile.mgw +++ /dev/null @@ -1,83 +0,0 @@ -CFLAGS = -g -ansi -pedantic -funsigned-char -D__win__ -DCOMPILER=\"[MinGW32]\" - -LDFLAGS = -g - -OBJECTS = arun.o \ - main.o \ - debug.o \ - args.o \ - exe.o \ - inter.o \ - parse.o \ - rules.o \ - stack.o \ - decode.o \ - term.o \ - reverse.o \ - params.o \ - sysdep.o \ - version.o - - -arun.exe : $(OBJECTS) - gcc -o arun.exe $(OBJECTS) $(LDFLAGS) - copy arun.exe .. - -strip: - strip arun - coff2exe arun - -#---<< GENERATED DEPENDENCIES FOLLOWS >>--- -args.obj: args.c args.h main.h types.h sysdep.h acode.h -arun.obj: arun.c main.h types.h sysdep.h acode.h term.h version.h args.h -chartest.obj: chartest.c -debug.obj: debug.c types.h sysdep.h acode.h version.h readline.h inter.h \ - main.h parse.h exe.h debug.h -decode.obj: decode.c main.h types.h sysdep.h acode.h decode.h -dumpacd.obj: dumpacd.c types.h sysdep.h acode.h spa.h -exe.obj: exe.c types.h sysdep.h acode.h readline.h main.h parse.h \ - inter.h stack.h decode.h exe.h -genalan.obj: genalan.c spa.h -inter.obj: inter.c types.h sysdep.h acode.h main.h parse.h exe.h stack.h \ - inter.h -main.obj: main.c sysdep.h types.h acode.h main.h readline.h version.h \ - args.h parse.h inter.h rules.h debug.h stack.h exe.h term.h -params.obj: params.c types.h sysdep.h acode.h params.h -parse.obj: parse.c types.h sysdep.h acode.h readline.h main.h inter.h \ - exe.h term.h debug.h params.h parse.h -readline.obj: readline.c readline.h types.h sysdep.h acode.h main.h -reverse.obj: reverse.c types.h sysdep.h acode.h main.h reverse.h -rules.obj: rules.c types.h sysdep.h acode.h main.h inter.h debug.h exe.h \ - stack.h rules.h -spa.obj: spa.c spa.h -stack.obj: stack.c types.h sysdep.h acode.h main.h stack.h -sysdep.obj: sysdep.c sysdep.h -term.obj: term.c main.h types.h sysdep.h acode.h term.h -version.obj: version.c version.h -#---<< GENERATED DEPENDENCIES FOLLOWS >>--- -args.obj: args.c args.h main.h types.h sysdep.h acode.h -arun.obj: arun.c main.h types.h sysdep.h acode.h term.h version.h args.h -chartest.obj: chartest.c -debug.obj: debug.c types.h sysdep.h acode.h version.h readline.h inter.h \ - main.h parse.h exe.h debug.h -decode.obj: decode.c main.h types.h sysdep.h acode.h decode.h -dumpacd.obj: dumpacd.c types.h sysdep.h acode.h spa.h -exe.obj: exe.c types.h sysdep.h acode.h readline.h main.h parse.h \ - inter.h stack.h decode.h exe.h -genalan.obj: genalan.c spa.h -inter.obj: inter.c types.h sysdep.h acode.h main.h parse.h exe.h stack.h \ - inter.h -main.obj: main.c sysdep.h types.h acode.h main.h readline.h version.h \ - args.h parse.h inter.h rules.h debug.h stack.h exe.h term.h -params.obj: params.c types.h sysdep.h acode.h params.h -parse.obj: parse.c types.h sysdep.h acode.h readline.h main.h inter.h \ - exe.h term.h debug.h params.h parse.h -readline.obj: readline.c readline.h types.h sysdep.h acode.h main.h -reverse.obj: reverse.c types.h sysdep.h acode.h main.h reverse.h -rules.obj: rules.c types.h sysdep.h acode.h main.h inter.h debug.h exe.h \ - stack.h rules.h -spa.obj: spa.c spa.h -stack.obj: stack.c types.h sysdep.h acode.h main.h stack.h -sysdep.obj: sysdep.c sysdep.h -term.obj: term.c main.h types.h sysdep.h acode.h term.h -version.obj: version.c version.h diff --git a/app/src/main/jni/terps/alan/alan2/Makefile.unix b/app/src/main/jni/terps/alan/alan2/Makefile.unix deleted file mode 100755 index cba729a..0000000 --- a/app/src/main/jni/terps/alan/alan2/Makefile.unix +++ /dev/null @@ -1,82 +0,0 @@ -# -------------------------------------------------------------------------- -# Unix Makefile -# -# Before trying to build, make sure you do the following: -# sh -# for file in `ls` -# do -# dos2unix $file $file -# done -# exit -# Otherwise, the line endings will be wrong and you will get weird errors. -# -# After you've done that, edit this file, and type 'make'. -# -# -------------------------------------------------------------------------- - -# -- Your C compiler. - -CC = gcc - -# -- Base C compiler options. - -CCDEBUG = -g -CCOPTIM = -O - -# -- Operating-system specific defines. - -#OSDEFS = -D__solarisX__ - -# -------------------------------------------------------------------------- -# Glk results in a nicer-looking display and consistency with other -# interfaces. -# -# If you don't have a Glk library installed, leave this section alone. -# Otherwise, uncomment the appropriate section. -# -------------------------------------------------------------------------- - -# -- Uncomment these to enable Glk support. -# -#GLKDEFS = -DGLK -#GLKOBJS = glkstart.o glkio.o - -# -- If you want to use GlkTerm (recommended), uncomment the line below. -# -#GLKLIBS = -lcurses -lglkterm - -# -- If you want to use CheapGlk, uncomment the line below. -# -#GLKLIBS = - lcheapglk - -# -------------------------------------------------------------------------- -# Don't change anything beyond this point. -# -------------------------------------------------------------------------- - -CFLAGS = $(CCDEBUG) $(CCOPTIM) -D__XXunix__ $(OSDEFS) $(GLKDEFS) -LIBS = $(GLKLIBS) - -ALANOBJS = arun.o \ - debug.o \ - args.o \ - exe.o \ - inter.o \ - parse.o \ - rules.o \ - stack.o \ - decode.o \ - term.o \ - reverse.o \ - params.o \ - sysdep.o \ - alan.version.o \ - main.o \ - readline.o - -OBJECTS = $(ALANOBJS) $(GLKOBJS) - -arun: $(OBJECTS) - $(CC) $(LIBS) -o arun $(OBJECTS) - -strip: - strip arun - diff --git a/app/src/main/jni/terps/alan/alan2/acode.h b/app/src/main/jni/terps/alan/alan2/acode.h deleted file mode 100755 index bed197a..0000000 --- a/app/src/main/jni/terps/alan/alan2/acode.h +++ /dev/null @@ -1,269 +0,0 @@ -#ifndef _ACODE_H_ -#define _ACODE_H_ - -/* Original source below assumes that sizeof(long) will be 32 bits (4 bytes), - * but this may not be true on some hardware. Use stdint library to improve - * portability - TCC Dec 2017 */ -#include -typedef uint32_t Aword; /* Type for an ACODE word */ -typedef uint32_t Aaddr; /* Type for an ACODE address */ -typedef uint32_t Abool; /* Type for an ACODE Boolean value */ -typedef int32_t Aint; /* Type for an ACODE Integer value */ - -/*typedef unsigned long Aword;*/ /* Type for an ACODE word */ -/*typedef unsigned long Aaddr;*/ /* Type for an ACODE address */ -/*typedef unsigned long Abool;*/ /* Type for an ACODE Boolean value */ -/*typedef signed long Aint;*/ /* Type for an ACODE Integer value */ - -/* Constants for the Acode file, words/block & bytes/block */ -#define BLOCKLEN 256L -#define BLOCKSIZE (BLOCKLEN*sizeof(Aword)) - - -/* Definitions for the packing process */ -typedef int32_t CodeValue; -/*typedef long CodeValue;*/ -#define VALUEBITS 16 - -#define EOFChar 256 -#define TOPVALUE (((CodeValue)1<>28) -#define I_OP(x) ((x&0x8000000)?(x)|0x0f0000000:(x)&0x0fffffff) - - -typedef struct AcdHdr { -/* Important info */ - char vers[4]; /* 01 - Version of compiler */ - Aword size; /* 02 - Size of ACD-file in Awords */ -/* Options */ - Abool pack; /* 03 - Is the text packed ? */ - Aword paglen; /* 04 - Length of a page */ - Aword pagwidth; /* 05 - and width */ - Aword debug; /* 06 - Option debug */ -/* Data structures */ - Aaddr dict; /* 07 - Dictionary */ - Aaddr oatrs; /* 08 - Object default attributes */ - Aaddr latrs; /* 09 - Location default attributes */ - Aaddr aatrs; /* 0a - Actor default attributes */ - Aaddr acts; /* 0b - Actor table */ - Aaddr objs; /* 0c - Object table */ - Aaddr locs; /* 0d - Location table */ - Aaddr stxs; /* 0e - Syntax table */ - Aaddr vrbs; /* 0f - Verb table */ - Aaddr evts; /* 10 - Event table */ - Aaddr cnts; /* 11 - Container table */ - Aaddr ruls; /* 12 - Rule table */ - Aaddr init; /* 13 - String init table */ - Aaddr start; /* 14 - Start code */ - Aword msgs; /* 15 - Messages table */ -/* Miscellaneous */ - Aword objmin, objmax; /* 16 - Interval for object codes */ - Aword actmin, actmax; /* 18 - Interval for actor codes */ - Aword cntmin, cntmax; /* 1a - Interval for container codes */ - Aword locmin, locmax; /* 1c - Interval for location codes */ - Aword dirmin, dirmax; /* 1e - Interval for direction codes */ - Aword evtmin, evtmax; /* 20 - Interval for event codes */ - Aword rulmin, rulmax; /* 22 - Interval for rule codes */ - Aword maxscore; /* 24 - Maximum score */ - Aaddr scores; /* 25 - Score table */ - Aaddr freq; /* 26 - Address to Char freq's for coding */ - Aword acdcrc; /* 27 - Checksum for acd code (excl. hdr) */ - Aword txtcrc; /* 28 - Checksum for text data file */ -} AcdHdr; - -/* Error message numbers */ -typedef enum MsgKind { - M_HUH, /* Obsolete */ - M_WHAT, - M_WHAT_ALL, - M_WHAT_IT, - M_WHAT_THEM, - M_MULTIPLE, - M_WANT, - M_NOUN, - M_AFTER_BUT, - M_BUT_ALL, - M_NOT_MUCH, - M_WHICH_ONE, - M_NO_SUCH, - M_NO_WAY, - M_CANT0, - M_CANT, - M_NOTHING, /* Obsolete */ - M_SEEOBJ1, - M_SEEOBJ2, - M_SEEOBJ3, - M_SEEOBJ4, - M_SEEACT, - M_CONTAINS1, - M_CONTAINS2, - M_CONTAINS3, - M_CONTAINS4, - M_CONTAINS5, - M_EMPTY1, - M_EMPTY2, - M_SCORE1, - M_SCORE2, - M_UNKNOWN_WORD, - M_MORE, - M_AGAIN, - M_SAVEWHERE, - M_SAVEOVERWRITE, - M_SAVEFAILED, - M_SAVEMISSING, - M_SAVEVERS, - M_SAVENAME, - M_RESTOREFROM, - M_REALLY, /* CHANGED: v2.7 from M_RESTART */ - M_QUITACTION, /* INTRODUCED: v2.7, so M_ARTICLE moved */ - M_ARTICLE, /* INTRODUCED: v2.6 but replaced the M_NOMSG*/ - MSGMAX -} MsgKind; - -#define M_ARTICLE26 M_QUITACTION -#define M_MSGMAX26 M_ARTICLE - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/alan.version b/app/src/main/jni/terps/alan/alan2/alan.version deleted file mode 100755 index db9a6bc..0000000 --- a/app/src/main/jni/terps/alan/alan2/alan.version +++ /dev/null @@ -1,15 +0,0 @@ -4.2 venum # venum 4.2 beta -Alan -Adventure Language System -2 -8 -7 - -979481622 2001-01-14 14:13:42 -Thomas Nilsson - -$v.$r{s $s}{c($c)} -$n $V -$H{z -- $z} ($D $t) - -cygwin diff --git a/app/src/main/jni/terps/alan/alan2/alan.version.c b/app/src/main/jni/terps/alan/alan2/alan.version.c deleted file mode 100755 index 31575bb..0000000 --- a/app/src/main/jni/terps/alan/alan2/alan.version.c +++ /dev/null @@ -1,19 +0,0 @@ -/* alan.c - Created by venum 4.2 beta */ - -#include "alan.version.h" - -Product alan = { - "Alan", - "Adventure Language System", - "Alan 2.8(7)", - "Alan 2.8(7) -- Adventure Language System (2001-01-14 15:13)", - "2001-01-14", - "15:13:42", - "Thomas Nilsson", - "", - "cygwin", - {"2.8(7)", 2, 8, 7, 979481622, ""} -}; - -static char *alanId = - "@(#)RELEASE "; diff --git a/app/src/main/jni/terps/alan/alan2/alan.version.h b/app/src/main/jni/terps/alan/alan2/alan.version.h deleted file mode 100755 index d57f52d..0000000 --- a/app/src/main/jni/terps/alan/alan2/alan.version.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _alan_version_h_ -#define _alan_version_h_ 2 - -#include "version.h" - -extern Product alan; - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/args.c b/app/src/main/jni/terps/alan/alan2/args.c deleted file mode 100755 index b0188d2..0000000 --- a/app/src/main/jni/terps/alan/alan2/args.c +++ /dev/null @@ -1,286 +0,0 @@ -/*----------------------------------------------------------------------*\ - - args - Argument handling for arun - - Handles the various startup methods on all machines. - - Main function args() will set up global variable advnam and the flags, - the terminal will also be set up and connected. - -\*----------------------------------------------------------------------*/ - -#ifndef __PACIFIC__ -#include "args.h" -#else -/* I have no idea at all why the include does not work in Pacific C ... */ -extern void args(int argc, char* argv[]); -#endif - - -#include "main.h" - -#ifdef __mac__ -#include "macArgs.h" -#endif - -#ifdef __amiga__ -#include -#ifdef AZTEC_C -struct FileHandle *con = NULL; -#else -/* Geek Gadgets GCC */ -BPTR window; -BPTR cd; -#endif -#endif - -#ifdef GLK -#include "glk.h" -#include "glkio.h" -#endif - -#ifdef _PROTOTYPES_ -static void switches( - unsigned argc, - char *argv[] -) -#else -static void switches(argc, argv) - unsigned argc; - char *argv[]; -#endif -{ - int i; - - advnam = ""; - for (i = 1; i < argc; i++) { - if (argv[i][0] == '-') { -#ifdef GLK - switch (glk_char_to_lower(argv[i][1])) { -#else - switch (tolower(argv[i][1])) { -#endif - case 'i': - errflg = FALSE; - break; - case 't': - trcflg = TRUE; - break; - case 'd': - dbgflg = TRUE; - break; - case 's': - trcflg = TRUE; - stpflg = TRUE; - break; - case 'l': - logflg = TRUE; - break; - case 'v': - verbose = TRUE; - break; - case 'n': - statusflg = FALSE; - break; - default: - printf("Unrecognized switch, -%c\n", argv[i][1]); - usage(); - terminate(0); - } - } else { - advnam = argv[i]; - if (strcmp(&advnam[strlen(advnam)-4], ".acd") == 0 - || strcmp(&advnam[strlen(advnam)-4], ".ACD") == 0 - || strcmp(&advnam[strlen(advnam)-4], ".dat") == 0 - || strcmp(&advnam[strlen(advnam)-4], ".DAT") == 0) - advnam[strlen(advnam)-4] = '\0'; - } - } -} - - - -#ifdef __amiga__ - -#include -#include - -#include -#include -#include - -#include - -extern struct Library *IconBase; - -#ifndef AZTEC_C -/* Actually Geek Gadgets GCC with libnix */ - -/* Aztec C has its own pre-main wbparse which was used in Arun 2.7, with GCC we - need to do it ourselves. */ - -#include - -extern unsigned long *__stdfiledes; /* The libnix standard I/O file descriptors */ - -void -wb_parse(void) -{ - char *cp; - struct DiskObject *dop; - struct FileHandle *fhp; - - if (_WBenchMsg->sm_NumArgs == 1) /* If no argument use program icon/info */ - dop = GetDiskObject((UBYTE *)_WBenchMsg->sm_ArgList[0].wa_Name); - else { - BPTR olddir = CurrentDir(_WBenchMsg->sm_ArgList[1].wa_Lock); - dop = GetDiskObject((UBYTE *)_WBenchMsg->sm_ArgList[1].wa_Name); - CurrentDir(olddir); - } - if (dop != 0 && (cp = (char *)FindToolType((UBYTE **)dop->do_ToolTypes, - (UBYTE *)"WINDOW")) != NULL) - ; - else /* Could not find a WINDOW tool type */ - cp = "CON:10/10/480/160/Arun:Default Window/CLOSE"; - if ((window = Open((UBYTE *)cp, (long)MODE_OLDFILE))) { - fhp = (struct FileHandle *) ((long)window << 2); - SetConsoleTask(fhp->fh_Type); - SelectInput(window); - SelectOutput(window); - __stdfiledes[0] = Input(); - __stdfiledes[1] = Output(); - } else - exit(-1L); - FreeDiskObject(dop); -} -#endif -#endif - - -#ifdef _PROTOTYPES_ -void args( - int argc, - char * argv[] -) -#else -void args(argc, argv) - int argc; - char *argv[]; -#endif -{ - char *prgnam; - -#ifdef __mac__ -#include -#ifdef __MWERKS__ -#include -#endif - short msg, files; - static char advbuf[256], prgbuf[256]; - /*AppFile af;*/ - OSErr oe; - -#ifdef __MWERKS__ - /*SIOUXSettings.setupmenus = FALSE;*/ - SIOUXSettings.autocloseonquit = FALSE; - SIOUXSettings.asktosaveonclose = FALSE; - SIOUXSettings.showstatusline = FALSE; -#endif - - GetMacArgs(advbuf); - advnam = advbuf; - -#else -#ifdef __amiga__ - - if (argc == 0) { /* If started from Workbench get WbArgs : Aztec C & GG GCC */ - struct WBStartup *WBstart; - - if ((IconBase = OpenLibrary("icon.library", 0)) == NULL) - syserr("Could not open 'icon.library'"); - /* If started from WB normal main is called with argc == 0 and argv = WBstartup message */ - WBstart = (struct WBStartup *)argv; -#ifndef AZTEC_C - /* Geek Gadgets GCC */ - wb_parse(); -#endif - advnam = prgnam = WBstart->sm_ArgList[0].wa_Name; - if (WBstart->sm_NumArgs > 0) { - cd = CurrentDir(DupLock(WBstart->sm_ArgList[1].wa_Lock)); - advnam = WBstart->sm_ArgList[1].wa_Name; - } - /* Possibly other tooltypes ... */ - } else { - /* Started from a CLI */ - if ((prgnam = strrchr(argv[0], '/')) == NULL - && (prgnam = strrchr(argv[0], ':')) == NULL) - prgnam = argv[0]; - else - prgnam++; - /* Now look at the switches and arguments */ - switches(argc, argv); - if (advnam[0] == '\0') - /* No game given, try program name */ - if (stricmp(prgnam, PROGNAME) != 0) - advnam = strdup(argv[0]); - } -#else -#if defined(__dos__) || defined(__win__) - if ((prgnam = strrchr(argv[0], '\\')) == NULL - && (prgnam = strrchr(argv[0], '/')) == NULL - && (prgnam = strrchr(argv[0], ':')) == NULL) - prgnam = argv[0]; - else - prgnam++; - if (strlen(prgnam) > 4 - && (strcmp(&prgnam[strlen(prgnam)-4], ".EXE") == 0 - || strcmp(&prgnam[strlen(prgnam)-4], ".exe") == 0)) - prgnam[strlen(prgnam)-4] = '\0'; - /* Now look at the switches and arguments */ - switches(argc, argv); - if (advnam[0] == '\0') - /* No game given, try program name */ - if (stricmp(prgnam, PROGNAME) != 0) - advnam = strdup(argv[0]); -#else -#if defined __vms__ - if ((prgnam = strrchr(argv[0], ']')) == NULL - && (prgnam = strrchr(argv[0], '>')) == NULL - && (prgnam = strrchr(argv[0], ':')) == NULL) - prgnam = argv[0]; - else - prgnam++; - if (strrchr(prgnam, ';') != NULL) - *strrchr(prgnam, ';') = '\0'; - if (strlen(prgnam) > 4 - && (strcmp(&prgnam[strlen(prgnam)-4], ".EXE") == 0 - || strcmp(&prgnam[strlen(prgnam)-4], ".exe") == 0)) - prgnam[strlen(prgnam)-4] = '\0'; - /* Now look at the switches and arguments */ - switches(argc, argv); - if (advnam[0] == '\0') - /* No game given, try program name */ - if (strcmp(prgnam, PROGNAME) != 0) - advnam = strdup(argv[0]); -#else -#if defined __unix__ - if ((prgnam = strrchr(argv[0], '/')) == NULL) - prgnam = strdup(argv[0]); - else - prgnam = strdup(&prgnam[1]); - if (strrchr(prgnam, ';') != NULL) - *strrchr(prgnam, ';') = '\0'; - /* Now look at the switches and arguments */ - switches(argc, argv); - if (advnam[0] == '\0') - /* No game given, try program name */ - if (strcmp(prgnam, PROGNAME) != 0) - advnam = strdup(argv[0]); -#else - Unimplemented OS! -#endif -#endif -#endif -#endif -#endif -} diff --git a/app/src/main/jni/terps/alan/alan2/args.h b/app/src/main/jni/terps/alan/alan2/args.h deleted file mode 100755 index 147eee4..0000000 --- a/app/src/main/jni/terps/alan/alan2/args.h +++ /dev/null @@ -1,37 +0,0 @@ -/*----------------------------------------------------------------------*\ - - args.h - - Argument handling - -\*----------------------------------------------------------------------*/ - -#ifdef __amiga__ - -#include - -#ifdef AZTEC_C -extern struct FileHandle *con; -#else - -#include -#include - -extern struct WBStartup *_WBenchMsg; /* From libnix */ - -extern BPTR window; -extern BPTR cd; - -#endif -#endif - -#ifndef PROGNAME -#define PROGNAME "arun" -#endif - -#ifdef _PROTOTYPES_ -extern void args(int argc, char *argv[]); -#else -extern void args(); -#endif - diff --git a/app/src/main/jni/terps/alan/alan2/arun.c b/app/src/main/jni/terps/alan/alan2/arun.c deleted file mode 100755 index 424f589..0000000 --- a/app/src/main/jni/terps/alan/alan2/arun.c +++ /dev/null @@ -1,117 +0,0 @@ -/*----------------------------------------------------------------------*\ - - ARUN.C - - Main program for interpreter for ALAN Adventure Language - - -\*----------------------------------------------------------------------*/ - -#include "main.h" -#include "term.h" -#ifdef HAVE_SHORT_FILENAMES -#include "av.h" -#else -#include "alan.version.h" -#endif -#include "args.h" - -#ifdef GLK -#include "glkio.h" -#ifdef __win__ -#include "WinGlk.h" -#else -#include "glk.h" -#endif -#endif - -/*====================================================================== - - main() - - Main program of main unit in Alan interpreter module, ARUN - - */ - -#ifdef GLK -#ifdef _PROTOTYPES_ -void glk_main(void) -#else -void glk_main() -#endif -#else -#ifdef _PROTOTYPES_ -int main( - int argc, - char *argv[] -) -#else -int main(argc, argv) - int argc; - char *argv[]; -#endif -#endif -{ -#ifdef MALLOC - malloc_debug(2); -#endif - - /* Set up page format in case we get a system error */ - lin = col = 1; - header->paglen = 24; - header->pagwidth = 70; - - getPageSize(); - -#ifdef GLK - /* args() is called from glkstart.c */ -#else - args(argc, argv); -#endif - - if (dbgflg||verbose) { - if (dbgflg) printf("<"); - printf("Arun, Adventure Interpreter version %s (%s %s)", - alan.version.string, alan.date, alan.time); - if (dbgflg) printf(">"); - newline(); - } - - if (advnam == NULL || *advnam == 0) { -#ifdef WINGLK - char *filename; - filename = (char*)winglk_get_initial_filename(NULL, "Arun : Select an Alan game file", - "Alan v2 Game Files (*.acd)|*.acd||"); - if (filename) { - char *directoryPart; - if (((directoryPart = strrchr(filename, '\\')) == NULL) - && ((directoryPart = strrchr(filename, ':')) == NULL)) - advnam = strdup(filename); - else - advnam = strdup(directoryPart+1); - advnam[strlen(advnam)-4] = '\0'; /* Strip off .A3C */ - } else { - printf("You should supply a game file to play.\n"); - usage(); - terminate(0); - } -#else - printf("You should supply a game file to play.\n"); - usage(); - terminate(0); -#endif - } - -#ifdef WINGLK - winglk_window_set_title(advnam); -#endif - - run(); - -#ifdef GLK - return; -#else - return(EXIT_SUCCESS); -#endif -} - diff --git a/app/src/main/jni/terps/alan/alan2/chartest.c b/app/src/main/jni/terps/alan/alan2/chartest.c deleted file mode 100755 index 5a4caac..0000000 --- a/app/src/main/jni/terps/alan/alan2/chartest.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include -#include -#include -#include - -static struct termios term; - -static void newtermio() -{ - struct termios newterm; - tcgetattr(0, &term); - newterm=term; - newterm.c_lflag&=~(ECHO|ICANON); - newterm.c_cc[VMIN]=1; - newterm.c_cc[VTIME]=0; - tcsetattr(0, TCSANOW, &newterm); -} - -static void restoretermio() -{ - tcsetattr(0, TCSANOW, &term); -} - - -void main() -{ - int endOfInput = 0; - char ch; - - while (!endOfInput) { - fflush(stdout); - if (read(0, &ch, 1) != 1) { - return; - } - printf("%d %x '%c'\n", (int)ch, (int)ch, ch); - } - return; -} diff --git a/app/src/main/jni/terps/alan/alan2/debug.c b/app/src/main/jni/terps/alan/alan2/debug.c deleted file mode 100755 index 3f19897..0000000 --- a/app/src/main/jni/terps/alan/alan2/debug.c +++ /dev/null @@ -1,491 +0,0 @@ -/*----------------------------------------------------------------------*\ - - debug.c - - Debugger unit in Alan interpreter ARUN - -\*----------------------------------------------------------------------*/ - -#include -#include - -#include "types.h" -#ifdef HAVE_SHORT_FILENAMES -#include "av.h" -#else -#include "alan.version.h" -#endif - - -#ifdef USE_READLINE -#include "readline.h" -#endif - - -#include "inter.h" -#include "main.h" -#include "parse.h" -#include "exe.h" - -#include "debug.h" - -#ifdef GLK -#include "glkio.h" -#endif - -#ifdef _PROTOTYPES_ -static void showatrs( - Aword atradr -) -#else -static void showatrs(atradr) - Aword atradr; -#endif -{ - AtrElem *at; - int i; - char str[80]; - - if (atradr == 0) return; - - i = 1; - for (at = (AtrElem *) addrTo(atradr); !endOfTable(at); at++) { - sprintf(str, "$i%3ld: %ld (%s)", i, at->val, (char *) addrTo(at->stradr)); -#if ISO == 0 - fromIso(str, str); -#endif - output(str); - i++; - } -} - - -#ifdef _PROTOTYPES_ -static void showobjs(void) -#else -static void showobjs() -#endif -{ - char str[80]; - int obj; - - output("OBJECTS:"); - for (obj = OBJMIN; obj <= OBJMAX; obj++) { - sprintf(str, "$i%3ld: ", obj); - output(str); - say(obj); - } -} - - -#ifdef _PROTOTYPES_ -static void showobj( - int obj -) -#else -static void showobj(obj) - int obj; -#endif -{ - char str[80]; -#define OBJ (obj-OBJMIN) - - - if (!isObj(obj)) { - sprintf(str, "Object number out of range. Between %ld and %ld, please.", OBJMIN, OBJMAX); - output(str); - return; - } - - sprintf(str, "OBJECT %d :", obj); - output(str); - say(obj); - - sprintf(str, "$iLocation = %ld", where(obj)); - output(str); - if (isLoc(objs[OBJ].loc)) - say(objs[OBJ].loc); - else if (isCnt(objs[OBJ].loc)) { - if (isObj(objs[OBJ].loc)) { - output("in"); - say(objs[OBJ].loc); - } else if (isAct(objs[OBJ].loc)) { - output("carried by"); - say(objs[OBJ].loc); - } else - interpret(cnts[objs[OBJ].loc-CNTMIN].nam); - } else if (objs[OBJ].loc == 0) - output("nowhere"); - else - output("Illegal location!"); - - - output("$iAttributes ="); - showatrs(objs[OBJ].atrs); - -#undef OBJ -} - - -#ifdef _PROTOTYPES_ -static void showcnts(void) -#else -static void showcnts() -#endif -{ - char str[80]; - int cnt; -#define CNT (cnt-CNTMIN) - - output("CONTAINERS:"); - for (cnt = CNTMIN; cnt <= CNTMAX; cnt++) { - sprintf(str, "$i%3ld: ", cnt); - output(str); - if (cnts[CNT].nam != 0) - interpret(cnts[CNT].nam); - if (cnts[CNT].parent != 0) - say(cnts[CNT].parent); - } - -#undef CNT -} - - -#ifdef _PROTOTYPES_ -static void showcnt( - int cnt -) -#else -static void showcnt(cnt) - int cnt; -#endif -{ - char str[80]; - int i; - Abool found = FALSE; -#define CNT (cnt-CNTMIN) - - if (cnt < CNTMIN || cnt > CNTMAX) { - sprintf(str, "Container number out of range. Between %ld and %ld, please.", CNTMIN, CNTMAX); - output(str); - return; - } - - sprintf(str, "CONTAINER %d :", cnt); - output(str); - if (cnts[CNT].nam != 0) - interpret(cnts[CNT].nam); - if (cnts[CNT].parent != 0) { - cnt = cnts[CNT].parent; - say(cnt); - sprintf(str, "$iLocation = %ld", where(cnt)); - output(str); - } - output("$iContains "); - for (i = OBJMIN; i <= OBJMAX; i++) { - if (in(i, cnt)) { /* Yes, it's in this container */ - if (!found) { - output("$n"); - found = TRUE; - } - sprintf(str, "$t$t%d: ", i); - output(str); - say(i); - } - } - if (!found) - output("nothing"); - -#undef CNT -} - - -#ifdef _PROTOTYPES_ -static void showlocs(void) -#else -static void showlocs() -#endif -{ - char str[80]; - int loc; - - output("LOCATIONS:"); - for (loc = LOCMIN; loc <= LOCMAX; loc++) { - sprintf(str, "$i%3ld: ", loc); - output(str); - say(loc); - } -} - - -#ifdef _PROTOTYPES_ -static void showloc( - int loc -) -#else -static void showloc(loc) - int loc; -#endif -{ - char str[80]; - - - if (!isLoc(loc)) { - sprintf(str, "Location number out of range. Between %ld and %ld, please.", LOCMIN, LOCMAX); - output(str); - return; - } - - sprintf(str, "LOCATION %d :", loc); - output(str); - say(loc); - - output("$iAttributes ="); - showatrs(locs[loc-LOCMIN].atrs); -} - - -#ifdef _PROTOTYPES_ -static void showacts(void) -#else -static void showacts() -#endif -{ - char str[80]; - int act; - - output("ACTORS:"); - for (act = ACTMIN; act <= ACTMAX; act++) { - sprintf(str, "$i%3ld:", act); - output(str); - say(act); - } -} - - -#ifdef _PROTOTYPES_ -static void showact( - int act -) -#else -static void showact(act) - int act; -#endif -{ - char str[80]; - Boolean oldstp; - - if (!isAct(act)) { - sprintf(str, "Actor number out of range. Between %ld and %ld, please.", ACTMIN, ACTMAX); - output(str); - return; - } - - sprintf(str, "ACTOR %d :", act); - output(str); - oldstp = stpflg; stpflg = FALSE; /* Make sure not to trace this! */ - say(act); - stpflg = oldstp; - - sprintf(str, "$iLocation = %ld", acts[act-ACTMIN].loc); - output(str); - if (isLoc(acts[act-ACTMIN].loc)) - say(acts[act-ACTMIN].loc); - else if (acts[act-ACTMIN].loc == 0) - output("nowhere"); - else - output("Illegal location!"); - - sprintf(str, "$iScript = %ld", acts[act-ACTMIN].script); - output(str); - - sprintf(str, "$iStep = %ld", acts[act-ACTMIN].step); - output(str); - - output("$iAttributes ="); - showatrs(acts[act-ACTMIN].atrs); -} - - -#ifdef _PROTOTYPES_ -static void showevts(void) -#else -static void showevts() -#endif -{ - int evt, i; - char str[80]; - Boolean scheduled; - - output("EVENTS:"); - for (evt = EVTMIN; evt <= EVTMAX; evt++) { - sprintf(str, "$i%d (%s):", evt, (char *)addrTo(evts[evt-EVTMIN].stradr)); -#if ISO == 0 - fromIso(str, str); -#endif - output(str); - scheduled = FALSE; - for (i = 0; i < etop; i++) - if ((scheduled = (eventq[i].event == evt))) - break; - if (scheduled) { - sprintf(str, "Scheduled for +%d, at ", eventq[i].time-cur.tick); - output(str); - say(eventq[i].where); - } else - output("Not scheduled."); - } -} - - -static Boolean trc, stp; -static int loc; - -#ifdef _PROTOTYPES_ -void saveInfo(void) -#else -void saveInfo() -#endif -{ - /* Save some important things */ - trc = trcflg; trcflg = FALSE; - stp = stpflg; stpflg = FALSE; - loc = cur.loc; cur.loc = where(HERO); -} - -#ifdef _PROTOTYPES_ -void restoreInfo(void) -#else -void restoreInfo() -#endif -{ - /* Restore! */ - trcflg = trc; - stpflg = stp; - cur.loc = loc; -} - - -#ifdef _PROTOTYPES_ -void debug(void) -#else -void debug() -#endif -{ - char buf[256]; - char c; - int i; - - saveInfo(); - while (TRUE) { - if (anyOutput) - para(); - do { - output("ABUG> "); -#ifdef USE_READLINE - (void) readline(buf); -#else - fgets(buf, 255, stdin); -#endif - lin = 1; - c = buf[0]; - i = 0; - sscanf(&buf[1], "%d", &i); - } while (buf && c == '\0'); - - switch (toUpper(c)) { - case 'H': - case '?': - output(alan.longHeader); - output("$nABUG Commands:\ - $iO [n] -- show object[s]\ - $iA [n] -- show actor[s]\ - $iL [n] -- show location[s]\ - $iC [n] -- show container[s]\ - $iE -- show events\ - $iG -- go on\ - $iT -- toggle trace mode\ - $iS -- toggle step mode\ - $iX -- exit debug mode\ - $iQ -- quit game"); - break; - case 'Q': - terminate(0); - case 'X': - dbgflg = FALSE; /* Fall through to 'G' */ - case 'G': - restoreInfo(); - return; - case 'O': - if (i == 0) - showobjs(); - else - showobj(i); - break; - case 'C': - if (i == 0) - showcnts(); - else - showcnt(i); - break; - case 'A': - if (i == 0) - showacts(); - else - showact(i); - break; - case 'L': - if (i == 0) - showlocs(); - else - showloc(i); - break; - case 'E': - showevts(); - break; - case 'S': - if ((stp = !stp)) - printf("Step on."); - else - printf("Step off."); - break; - case 'T': - if ((trc = !trc)) - printf("Trace on."); - else - printf("Trace off."); - break; - default: - output("Unknown ABUG command. ? for help."); - break; - } - } -} - - -/*====================================================================== - - debugsay() - - Say somethin, but make sure we don't disturb anything and that it is - shown to the player. - -*/ -#ifdef _PROTOTYPES_ -void debugsay(int item) -#else -void debugsay(item) - int item; -#endif -{ - saveInfo(); - needsp = FALSE; - col = 1; - if (item == 0) - printf("$null$"); - else - say(item); - needsp = FALSE; - col = 1; - restoreInfo(); -} diff --git a/app/src/main/jni/terps/alan/alan2/debug.h b/app/src/main/jni/terps/alan/alan2/debug.h deleted file mode 100755 index bd395d0..0000000 --- a/app/src/main/jni/terps/alan/alan2/debug.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _DEBUG_H_ -#define _DEBUG_H_ -/*----------------------------------------------------------------------*\ - - debug.h - - Header file for debug handler in Alan interpreter - -\*----------------------------------------------------------------------*/ - -/* TYPES */ - - -#ifdef _PROTOTYPES_ - -extern void saveInfo(void); -extern void restoreInfo(void); -extern void debug(void); -extern void debugsay(int item); -#else -extern void saveInfo(); -extern void restoreInfo(); -extern void debug(); -extern void debugsay(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/decode.c b/app/src/main/jni/terps/alan/alan2/decode.c deleted file mode 100755 index e1c10e2..0000000 --- a/app/src/main/jni/terps/alan/alan2/decode.c +++ /dev/null @@ -1,176 +0,0 @@ -/*----------------------------------------------------------------------*\ - - decode.c - - Arithmetic decoding module in Arun - -\*----------------------------------------------------------------------*/ - -#include - -#include "main.h" -#include "decode.h" - - -/* Bit output */ -static int decodeBuffer; /* Bits to be input */ -static int bitsToGo; /* Bits still in buffer */ -static int garbageBits; /* Bits past EOF */ - - -#ifdef _PROTOTYPES_ -static int inputBit(void) -#else -static int inputBit() -#endif -{ - int bit; - - if (!bitsToGo) { /* More bits available ? */ - decodeBuffer = getc(txtfil); /* No, so get more */ - if (decodeBuffer == EOF) { - garbageBits++; - if (garbageBits > VALUEBITS-2) - syserr("Error in encoded data file."); - } else - bitsToGo = 8; /* Another Char, 8 new bits */ - } - bit = decodeBuffer&1; /* Get next bit */ - decodeBuffer = decodeBuffer>>1; /* and remove it */ - bitsToGo--; - return bit; -} - - -/* Current state of decoding */ - -static CodeValue value; /* Currently seen code value */ -static CodeValue low, high; /* Current code region */ - - -#ifdef _PROTOTYPES_ -void startDecoding(void) -#else -void startDecoding() -#endif -{ - int i; - - bitsToGo = 0; - garbageBits = 0; - - value = 0; - for (i = 0; i < VALUEBITS; i++) - value = 2*value + inputBit(); - low = 0; - high = TOPVALUE; -} - - -#ifdef _PROTOTYPES_ -int decodeChar(void) -#else -int decodeChar() -#endif -{ - long range; - int f; - int symbol; - - range = (long)(high-low) + 1; - f = (((long)(value-low)+1)*freq[0]-1)/range; - - /* Find the symbol */ - for (symbol = 1; freq[symbol] > f; symbol++); - - high = low + range*freq[symbol-1]/freq[0]-1; - low = low + range*freq[symbol]/freq[0]; - - for (;;) { - if (high < HALF) - ; - else if (low >= HALF) { - value = value - HALF; - low = low - HALF; - high = high - HALF; - } else if (low >= ONEQUARTER && high < THREEQUARTER) { - value = value - ONEQUARTER; - low = low - ONEQUARTER; - high = high - ONEQUARTER; - } else - break; - - /* Scale up the range */ - low = 2*low; - high = 2*high+1; - value = 2*value + inputBit(); - } - return symbol-1; -} - - - -/* Structure for saved decode info */ -typedef struct DecodeInfo { - long fpos; - int buffer; - int bits; - CodeValue value; - CodeValue high; - CodeValue low; -} DecodeInfo; - - -/*====================================================================== - - pushDecode() - - Save so much info about the decoding process so it is possible to - restore and continue later. - - */ -#ifdef _PROTOTYPES_ -void *pushDecode(void) -#else -void *pushDecode() -#endif -{ - DecodeInfo *info; - - info = (DecodeInfo *) allocate(sizeof(DecodeInfo)); - info->fpos = ftell(txtfil); - info->buffer = decodeBuffer; - info->bits = bitsToGo; - info->value = value; - info->high = high; - info->low = low; - return(info); -} - - -/*====================================================================== - - popDecode() - - Restore enough info about the decoding process so it is possible to - continue after having decoded something else. - - */ -#ifdef _PROTOTYPES_ -void popDecode(void *i) -#else -void popDecode(i) - void *i; -#endif -{ - DecodeInfo *info = (DecodeInfo *) i; - - fseek(txtfil, info->fpos, 0); - decodeBuffer = info->buffer; - bitsToGo = info->bits; - value = info->value; - high = info->high; - low = info->low; - - free(info); -} diff --git a/app/src/main/jni/terps/alan/alan2/decode.h b/app/src/main/jni/terps/alan/alan2/decode.h deleted file mode 100755 index 3daa5c4..0000000 --- a/app/src/main/jni/terps/alan/alan2/decode.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef _DECODE_H_ -#define _DECODE_H_ -/*----------------------------------------------------------------------*\ - - decode.h - - Arithmetic decoding module in Arun - -\*----------------------------------------------------------------------*/ - -#include "types.h" - -/* Types: */ - -/* Data: */ - -/* Functions: */ - -#ifdef _PROTOTYPES_ -extern void startDecoding(void); -extern int decodeChar(void); -extern void *pushDecode(void); -extern void popDecode(void *info); -#else -extern void startDecoding(); -extern int decodeChar(); -extern void *pushDecode(); -extern void popDecode(); -#endif -#endif - diff --git a/app/src/main/jni/terps/alan/alan2/dependencies.mk b/app/src/main/jni/terps/alan/alan2/dependencies.mk deleted file mode 100755 index 66bcd39..0000000 --- a/app/src/main/jni/terps/alan/alan2/dependencies.mk +++ /dev/null @@ -1,27 +0,0 @@ -args.o: args.c args.h main.h types.h sysdep.h acode.h -arun.o: arun.c main.h types.h sysdep.h acode.h term.h version.h args.h -chartest.o: chartest.c -debug.o: debug.c types.h sysdep.h acode.h version.h readline.h inter.h \ - main.h parse.h exe.h debug.h -decode.o: decode.c main.h types.h sysdep.h acode.h decode.h -dumpacd.o: dumpacd.c types.h sysdep.h acode.h spa.h -spa.o: spa.c -exe.o: exe.c types.h sysdep.h acode.h readline.h main.h parse.h \ - inter.h stack.h decode.h exe.h -genalan.o: genalan.c spa.h -inter.o: inter.c types.h sysdep.h acode.h main.h parse.h exe.h stack.h \ - inter.h -main.o: main.c sysdep.h types.h acode.h main.h readline.h version.h \ - args.h parse.h inter.h rules.h debug.h stack.h exe.h term.h -params.o: params.c types.h sysdep.h acode.h params.h -parse.o: parse.c types.h sysdep.h acode.h readline.h main.h inter.h \ - exe.h term.h debug.h params.h parse.h -readline.o: readline.c readline.h types.h sysdep.h acode.h main.h -reverse.o: reverse.c types.h sysdep.h acode.h main.h reverse.h -rules.o: rules.c types.h sysdep.h acode.h main.h inter.h debug.h exe.h \ - stack.h rules.h -spa.o: spa.c spa.h -stack.o: stack.c types.h sysdep.h acode.h main.h stack.h -sysdep.o: sysdep.c sysdep.h -term.o: term.c main.h types.h sysdep.h acode.h term.h -version.o: version.c version.h diff --git a/app/src/main/jni/terps/alan/alan2/exe.c b/app/src/main/jni/terps/alan/alan2/exe.c deleted file mode 100755 index 8006354..0000000 --- a/app/src/main/jni/terps/alan/alan2/exe.c +++ /dev/null @@ -1,1813 +0,0 @@ -/*----------------------------------------------------------------------*\ - - exe.c - - Amachine instruction execution unit of Alan interpreter - -\*----------------------------------------------------------------------*/ - -#include "types.h" - -#include "glk.h" - -#ifdef USE_READLINE -#include "readline.h" -#endif - -#include "main.h" -#include "parse.h" -#include "inter.h" -#include "stack.h" -#include "decode.h" - -#include "exe.h" - -#define WIDTH 80 - -#define N_EVTS 100 - - -/* PUBLIC DATA */ - -/* The event queue */ -EvtqElem eventq[N_EVTS]; /* Event queue */ -int etop = 0; /* Event queue top pointer */ - -Boolean looking = FALSE; /* LOOKING? flag */ - -int dscrstkp = 0; /* Describe-stack pointer */ - - -#ifdef _PROTOTYPES_ -void dscrobjs(void); -void dscracts(void); -#else -void dscrobjs(); -void dscracts(); -#endif - - - -#ifdef _PROTOTYPES_ -void print(Aword fpos, Aword len) -#else -void print(fpos, len) - Aword fpos, len; -#endif -{ - char str[2*WIDTH]; /* String buffer */ - int outlen = 0; /* Current output length */ - int ch; - int i; - long savfp; /* Temporary saved text file position */ - static Boolean printFlag = FALSE; /* Printing already? */ - Boolean savedPrintFlag = printFlag; - void *info; /* Saved decoding info */ - - - if (len == 0) return; - - if (isHere(HERO)) { /* Check if the player will see it */ - if (printFlag) { /* Already printing? */ - /* Save current text file position and/or decoding info */ - if (header->pack) - info = pushDecode(); - else - savfp = ftell(txtfil); - } - printFlag = TRUE; /* We're printing now! */ - fseek(txtfil, fpos, 0); /* Position to start of text */ - if (header->pack) - startDecoding(); - for (outlen = 0; outlen != len; outlen = outlen + strlen(str)) { - /* Fill the buffer from the beginning */ - for (i = 0; i <= WIDTH || (i > WIDTH && ch != ' '); i++) { - if (outlen + i == len) /* No more characters? */ - break; - if (header->pack) - ch = decodeChar(); - else - ch = getc(txtfil); - if (ch == EOFChar) /* Or end of text? */ - break; - str[i] = ch; - } - str[i] = '\0'; -#if ISO == 0 - fromIso(str, str); -#endif - output(str); - } - /* And restore */ - printFlag = savedPrintFlag; - if (printFlag) { - if (header->pack) - popDecode(info); - else - fseek(txtfil, savfp, 0); - } - } -} - - -#ifdef _PROTOTYPES_ -void sys(Aword fpos, Aword len) -#else -void sys(fpos, len) - Aword fpos, len; -#endif -{ - char *command; - - getstr(fpos, len); /* Returns address to string on stack */ - command = (char *)pop(); - system(command); - free(command); -} - - -#ifdef _PROTOTYPES_ -void getstr(Aword fpos, Aword len) -#else -void getstr(fpos, len) - Aword fpos, len; -#endif -{ - char *buf = allocate(len+1); - - push((Aword) buf); /* Push the address to the string */ - fseek(txtfil, fpos, 0); /* Position to start of text */ - if (header->pack) - startDecoding(); - while (len--) - if (header->pack) - *(buf++) = decodeChar(); - else - *(buf++) = getc(txtfil); - *buf = '\0'; -} - - - -#ifdef _PROTOTYPES_ -void score(Aword sc) -#else -void score(sc) - Aword sc; -#endif -{ - char buf[80]; - - if (sc == 0) { - prmsg(M_SCORE1); - sprintf(buf, "%d", cur.score); - output(buf); - prmsg(M_SCORE2); - sprintf(buf, "%ld.", header->maxscore); - output(buf); - } else { - cur.score += scores[sc-1]; - scores[sc-1] = 0; - } -} - -#ifdef _PROTOTYPES_ -void visits(Aword v) -#else -void visits(v) - Aword v; -#endif -{ - cur.visits = v; -} - - -#ifdef _PROTOTYPES_ -Boolean confirm(MsgKind msgno) -#else -Boolean confirm(msgno) - MsgKind msgno; -#endif -{ - char buf[80]; - - /* This is a bit of a hack since we really want to compare the input, - it could be affirmative, but for now any input is NOT! */ - prmsg(msgno); - -#ifdef USE_READLINE - if (!readline(buf)) return TRUE; -#else - if (gets(buf) == NULL) return TRUE; -#endif - col = 1; - - return (buf[0] == '\0'); -} - - -#ifdef _PROTOTYPES_ -void quit(void) -#else -void quit() -#endif -{ - char buf[80]; - char choices[10]; - - para(); - while (TRUE) { - col = 1; - statusline(); - prmsg(M_QUITACTION); -#ifdef USE_READLINE - if (!readline(buf)) terminate(0); -#else - if (gets(buf) == NULL) terminate(0); -#endif - if (strcmp(buf, "restart") == 0) - longjmp(restart_label, TRUE); - else if (strcmp(buf, "restore") == 0) { - restore(); - return; - } else if (strcmp(buf, "quit") == 0) - terminate(0); - } - syserr("Fallthrough in QUIT"); -} - - - -#ifdef _PROTOTYPES_ -void restart(void) -#else -void restart() -#endif -{ - para(); - if (confirm(M_REALLY)) { - longjmp(restart_label, TRUE); - } else - return; - syserr("Fallthrough in RESTART"); -} - - - -#ifdef _PROTOTYPES_ -void cancl(Aword evt) -#else -void cancl(evt) - Aword evt; -#endif -{ - int i; - - for(i = etop-1; i>=0; i--) - if (eventq[i].event == evt) { - while (i < etop-1) { - eventq[i].event = eventq[i+1].event; - eventq[i].time = eventq[i+1].time; - eventq[i].where = eventq[i+1].where; - i++; - } - etop--; - return; - } -} - - -#ifdef _PROTOTYPES_ -void schedule(Aword evt, Aword whr, Aword aft) -#else -void schedule(evt, whr, aft) - Aword evt, whr, aft; -#endif -{ int i; - int time; - - cancl(evt); - /* Check for overflow */ - if (etop == N_EVTS) syserr("Out of event space."); - - time = cur.tick+aft; - - /* Bubble this event down */ - for (i = etop; i >= 1 && eventq[i-1].time <= time; i--) { - eventq[i].event = eventq[i-1].event; - eventq[i].time = eventq[i-1].time; - eventq[i].where = eventq[i-1].where; - } - - eventq[i].time = time; - eventq[i].where = whr; - eventq[i].event = evt; - etop++; -} - - -/*---------------------------------------------------------------------- - - getatr() - - Get an attribute value from an attribute list - - */ -#ifdef _PROTOTYPES_ -static Aword getatr( - Aaddr atradr, /* IN - ACODE address to attribute table */ - Aaddr atr /* IN - The attribute to read */ -) -#else -static Aword getatr(atradr, atr) - Aaddr atradr; /* IN - ACODE address to attribute table */ - Aaddr atr; /* IN - The attribute to read */ -#endif -{ - AtrElem *at; - - at = (AtrElem *) addrTo(atradr); - return at[atr-1].val; -} - - -/*---------------------------------------------------------------------- - - setatr() - - Set a particular attribute to a value. - - */ -#ifdef _PROTOTYPES_ -static void setatr( - Aaddr atradr, /* IN - ACODE address to attribute table */ - Aword atr, /* IN - attribute code */ - Aword val /* IN - new value */ -) -#else -static void setatr(atradr, atr, val) - Aaddr atradr; /* IN - ACODE address to attribute table */ - Aword atr; /* IN - attribute code */ - Aword val; /* IN - new value */ -#endif -{ - AtrElem *at; - - at = (AtrElem *) addrTo(atradr); - at[atr-1].val = val; -} - - -/*---------------------------------------------------------------------- - - make() - - */ - -#ifdef _PROTOTYPES_ -static void makloc(Aword loc, Aword atr, Aword val) -#else -static void makloc(loc, atr, val) - Aword loc, atr, val; -#endif -{ - setatr(locs[loc-LOCMIN].atrs, atr, val); -} - -#ifdef _PROTOTYPES_ -static void makobj(Aword obj, Aword atr, Aword val) -#else -static void makobj(obj, atr, val) - Aword obj, atr, val; -#endif -{ - setatr(objs[obj-OBJMIN].atrs, atr, val); -} - -#ifdef _PROTOTYPES_ -static void makact(Aword act, Aword atr, Aword val) -#else -static void makact(act, atr, val) - Aword act, atr, val; -#endif -{ - setatr(acts[act-ACTMIN].atrs, atr, val); -} - - -#ifdef _PROTOTYPES_ -void make(Aword id, Aword atr, Aword val) -#else -void make(id, atr, val) - Aword id, atr, val; -#endif -{ - char str[80]; - - if (isObj(id)) - makobj(id, atr, val); - else if (isLoc(id)) - makloc(id, atr, val); - else if (isAct(id)) - makact(id, atr, val); - else { - sprintf(str, "Can't MAKE item (%ld).", id); - syserr(str); - } -} - - -/*---------------------------------------------------------------------------- - - set() - - */ - -#ifdef _PROTOTYPES_ -static void setloc(Aword loc, Aword atr, Aword val) -#else -static void setloc(loc, atr, val) - Aword loc, atr, val; -#endif -{ - setatr(locs[loc-LOCMIN].atrs, atr, val); - locs[loc-LOCMIN].describe = 0; -} - - -#ifdef _PROTOTYPES_ -static void setobj(Aword obj, Aword atr, Aword val) -#else -static void setobj(obj, atr, val) - Aword obj, atr, val; -#endif -{ - setatr(objs[obj-OBJMIN].atrs, atr, val); -} - -#ifdef _PROTOTYPES_ -static void setact(Aword act, Aword atr, Aword val) -#else -static void setact(act, atr, val) - Aword act, atr, val; -#endif -{ - setatr(acts[act-ACTMIN].atrs, atr, val); -} - - -#ifdef _PROTOTYPES_ -void set(Aword id, Aword atr, Aword val) -#else -void set(id, atr, val) - Aword id, atr, val; -#endif -{ - char str[80]; - - if (isObj(id)) - setobj(id, atr, val); - else if (isLoc(id)) - setloc(id, atr, val); - else if (isAct(id)) - setact(id, atr, val); - else { - sprintf(str, "Can't SET item (%ld).", id); - syserr(str); - } -} - - -#ifdef _PROTOTYPES_ -void setstr(Aword id, Aword atr, Aword str) -#else -void setstr(id, atr, str) - Aword id, atr, str; -#endif -{ - free((char *)attribute(id, atr)); - set(id, atr, str); -} - - - -/*----------------------------------------------------------------------------- - - incr/decr - - */ - -/*---------------------------------------------------------------------- - - incratr() - - Increment a particular attribute by a value. - - */ -#ifdef _PROTOTYPES_ -static void incratr( - Aaddr atradr, /* IN - ACODE address to attribute table */ - Aword atr, /* IN - attribute code */ - Aword step /* IN - step to increment by */ -) -#else -static void incratr(atradr, atr, step) - Aaddr atradr, atr, step; -#endif -{ - AtrElem *at; - - at = (AtrElem *) addrTo(atradr); - at[atr-1].val += step; -} - - -#ifdef _PROTOTYPES_ -static void incrloc(Aword loc, Aword atr, Aword step) -#else -static void incrloc(loc, atr, step) - Aword loc, atr, step; -#endif -{ - incratr(locs[loc-LOCMIN].atrs, atr, step); - locs[loc-LOCMIN].describe = 0; -} - - -#ifdef _PROTOTYPES_ -static void incrobj(Aword obj, Aword atr, Aword step) -#else -static void incrobj(obj, atr, step) - Aword obj, atr, step; -#endif -{ - incratr(objs[obj-OBJMIN].atrs, atr, step); -} - -#ifdef _PROTOTYPES_ -static void incract(Aword act, Aword atr, Aword step) -#else -static void incract(act, atr, step) - Aword act, atr, step; -#endif -{ - incratr(acts[act-ACTMIN].atrs, atr, step); -} - - -#ifdef _PROTOTYPES_ -void incr(Aword id, Aword atr, Aword step) -#else -void incr(id, atr, step) - Aword id, atr, step; -#endif -{ - char str[80]; - - if (isObj(id)) - incrobj(id, atr, step); - else if (isLoc(id)) - incrloc(id, atr, step); - else if (isAct(id)) - incract(id, atr, step); - else { - sprintf(str, "Can't INCR item (%ld).", id); - syserr(str); - } -} - -#ifdef _PROTOTYPES_ -void decr(Aword id, Aword atr, Aword step) -#else -void decr(id, atr, step) - Aword id, atr, step; -#endif -{ - char str[80]; - - if (isObj(id)) - incrobj(id, atr, -step); - else if (isLoc(id)) - incrloc(id, atr, -step); - else if (isAct(id)) - incract(id, atr, -step); - else { - sprintf(str, "Can't DECR item (%ld).", id); - syserr(str); - } -} - - - -/*---------------------------------------------------------------------- - - attribute() - - */ - -#ifdef _PROTOTYPES_ -static Aword locatr(Aword loc, Aword atr) -#else -static Aword locatr(loc, atr) - Aword loc, atr; -#endif -{ - return getatr(locs[loc-LOCMIN].atrs, atr); -} - - - -#ifdef _PROTOTYPES_ -static Aword objatr(Aword obj, Aword atr) -#else -static Aword objatr(obj, atr) - Aword obj, atr; -#endif -{ - return getatr(objs[obj-OBJMIN].atrs, atr); -} - -#ifdef _PROTOTYPES_ -static Aword actatr(Aword act, Aword atr) -#else -static Aword actatr(act, atr) - Aword act, atr; -#endif -{ - return getatr(acts[act-ACTMIN].atrs, atr); -} - -#ifdef _PROTOTYPES_ -static Aword litatr(Aword lit, Aword atr) -#else -static Aword litatr(lit, atr) - Aword lit, atr; -#endif -{ - char str[80]; - - if (atr == 1) - return litValues[lit-LITMIN].value; - else { - sprintf(str, "Unknown attribute for literal (%ld).", atr); - syserr(str); - } - return(EOF); -} - - -#ifdef _PROTOTYPES_ -Aword attribute(Aword id, Aword atr) -#else -Aword attribute(id, atr) - Aword id, atr; -#endif -{ - char str[80]; - - if (isObj(id)) - return objatr(id, atr); - else if (isLoc(id)) - return locatr(id, atr); - else if (isAct(id)) - return actatr(id, atr); - else if (isLit(id)) - return litatr(id, atr); - else { - sprintf(str, "Can't ATTRIBUTE item (%ld).", id); - syserr(str); - } - return(EOF); -} - - -#ifdef _PROTOTYPES_ -Aword strattr(Aword id, Aword atr) -#else -Aword strattr(id, atr) - Aword id, atr; -#endif -{ - return (Aword) strdup((char *)attribute(id, atr)); -} - - -/*---------------------------------------------------------------------- - - where() - - */ - -#ifdef _PROTOTYPES_ -static Aword objloc(Aword obj) -#else -static Aword objloc(obj) - Aword obj; -#endif -{ - if (isCnt(objs[obj-OBJMIN].loc)) /* In something ? */ - if (isObj(objs[obj-OBJMIN].loc) || isAct(objs[obj-OBJMIN].loc)) - return(where(objs[obj-OBJMIN].loc)); - else /* Containers not anywhere is where the hero is! */ - return(where(HERO)); - else - return(objs[obj-OBJMIN].loc); -} - - -#ifdef _PROTOTYPES_ -static Aword actloc(Aword act) -#else -static Aword actloc(act) - Aword act; -#endif -{ - return(acts[act-ACTMIN].loc); -} - - -#ifdef _PROTOTYPES_ -Aword where(Aword id) -#else -Aword where(id) - Aword id; -#endif -{ - char str[80]; - - if (isObj(id)) - return objloc(id); - else if (isAct(id)) - return actloc(id); - else { - sprintf(str, "Can't WHERE item (%ld).", id); - syserr(str); - } - return(EOF); -} - - - -/*---------------------------------------------------------------------- - - aggregates - - */ - -#ifdef _PROTOTYPES_ -Aint agrmax(Aword atr, Aword whr) -#else -Aint agrmax(atr, whr) - Aword atr, whr; -#endif -{ - Aword i; - Aint max = 0; - - for (i = OBJMIN; i <= OBJMAX; i++) { - if (isLoc(whr)) { - if (where(i) == whr && attribute(i, atr) > max) - max = attribute(i, atr); - } else if (objs[i-OBJMIN].loc == whr && attribute(i, atr) > max) - max = attribute(i, atr); - } - return(max); -} - -#ifdef _PROTOTYPES_ -Aint agrsum(Aword atr, Aword whr) -#else -Aint agrsum(atr, whr) - Aword atr, whr; -#endif -{ - Aword i; - Aint sum = 0; - - for (i = OBJMIN; i <= OBJMAX; i++) { - if (isLoc(whr)) { - if (where(i) == whr) - sum += attribute(i, atr); - } else if (objs[i-OBJMIN].loc == whr) - sum += attribute(i, atr); - } - return(sum); -} - - -#ifdef _PROTOTYPES_ -Aint agrcount(Aword whr) -#else -Aint agrcount(whr) - Aword whr; -#endif -{ - Aword i; - Aword count = 0; - - for (i = OBJMIN; i <= OBJMAX; i++) { - if (isLoc(whr)) { - if (where(i) == whr) - count++; - } else if (objs[i-OBJMIN].loc == whr) - count++; - } - return(count); -} - - -/*---------------------------------------------------------------------- - - locate() - - */ - -#ifdef _PROTOTYPES_ -static void locobj(Aword obj, Aword whr) -#else -static void locobj(obj, whr) - Aword obj, whr; -#endif -{ - if (isCnt(whr)) { /* Into a container */ - if (whr == obj) - syserr("Locating something inside itself."); - if (checklim(whr, obj)) - return; - else - objs[obj-OBJMIN].loc = whr; - } else { - objs[obj-OBJMIN].loc = whr; - /* Make sure the location is described since it's changed */ - locs[whr-LOCMIN].describe = 0; - } -} - - -#ifdef _PROTOTYPES_ -static void locact(Aword act, Aword whr) -#else -static void locact(act, whr) - Aword act, whr; -#endif -{ - Aword prevact = cur.act; - Aword prevloc = cur.loc; - - cur.loc = whr; - acts[act-ACTMIN].loc = whr; - if (act == HERO) { - if (locs[acts[act-ACTMIN].loc-LOCMIN].describe % (cur.visits+1) == 0) - look(); - else { - if (anyOutput) - para(); - say(where(HERO)); - prmsg(M_AGAIN); - newline(); - dscrobjs(); - dscracts(); - } - locs[where(HERO)-LOCMIN].describe++; - locs[where(HERO)-LOCMIN].describe %= (cur.visits+1); - } else - locs[whr-LOCMIN].describe = 0; - if (locs[cur.loc-LOCMIN].does != 0) { - cur.act = act; - interpret(locs[cur.loc-LOCMIN].does); - cur.act = prevact; - } - - if (cur.act != act) - cur.loc = prevloc; -} - - -#ifdef _PROTOTYPES_ -void locate(Aword id, Aword whr) -#else -void locate(id, whr) - Aword id, whr; -#endif -{ - char str[80]; - - if (isObj(id)) - locobj(id, whr); - else if (isAct(id)) - locact(id, whr); - else { - sprintf(str, "Can't LOCATE item (%ld).", id); - syserr(str); - } -} - - -/*---------------------------------------------------------------------- - - isHere() - - */ - -#ifdef _PROTOTYPES_ -static Abool objhere(Aword obj) -#else -static Abool objhere(obj) - Aword obj; -#endif -{ - if (isCnt(objs[obj-OBJMIN].loc)) { /* In something? */ - if (isObj(objs[obj-OBJMIN].loc) || isAct(objs[obj-OBJMIN].loc)) - return(isHere(objs[obj-OBJMIN].loc)); - else /* If the container wasn't anywhere, assume where HERO is! */ - return(where(HERO) == cur.loc); - } else - return(objs[obj-OBJMIN].loc == cur.loc); -} - - -#ifdef _PROTOTYPES_ -static Aword acthere(Aword act) -#else -static Aword acthere(act) - Aword act; -#endif -{ - return(acts[act-ACTMIN].loc == cur.loc); -} - - -#ifdef _PROTOTYPES_ -Aword isHere(Aword id) -#else -Aword isHere(id) - Aword id; -#endif -{ - char str[80]; - - if (isObj(id)) - return objhere(id); - else if (isAct(id)) - return acthere(id); - else { - sprintf(str, "Can't HERE item (%ld).", id); - syserr(str); - } - return(EOF); -} - -/*---------------------------------------------------------------------- - - isNear() - - */ - -#ifdef _PROTOTYPES_ -static Aword objnear(Aword obj) -#else -static Aword objnear(obj) - Aword obj; -#endif -{ - if (isCnt(objs[obj-OBJMIN].loc)) { /* In something? */ - if (isObj(objs[obj-OBJMIN].loc) || isAct(objs[obj-OBJMIN].loc)) - return(isNear(objs[obj-OBJMIN].loc)); - else /* If the container wasn't anywhere, assume here, so not nearby! */ - return(FALSE); - } else - return(exitto(where(obj), cur.loc)); -} - - -#ifdef _PROTOTYPES_ -static Aword actnear(Aword act) -#else -static Aword actnear(act) - Aword act; -#endif -{ - return(exitto(where(act), cur.loc)); -} - - -#ifdef _PROTOTYPES_ -Abool isNear(Aword id) -#else -Abool isNear(id) - Aword id; -#endif -{ - char str[80]; - - if (isObj(id)) - return objnear(id); - else if (isAct(id)) - return actnear(id); - else { - sprintf(str, "Can't NEAR item (%ld).", id); - syserr(str); - } - return(EOF); -} - - - -/*---------------------------------------------------------------------- - - in() - - */ - -#ifdef _PROTOTYPES_ -Abool in(Aword obj, Aword cnt) -#else -Abool in(obj, cnt) - Aword obj; - Aword cnt; -#endif -{ - if (!isObj(obj)) - return(FALSE); - if (!isCnt(cnt)) - syserr("IN in a non-container."); - - return(objs[obj-OBJMIN].loc == cnt); -} - - -/*---------------------------------------------------------------------- - - say() - - */ - -#ifdef _PROTOTYPES_ -static void sayloc(Aword loc) -#else -static void sayloc(loc) - Aword loc; -#endif -{ - interpret(locs[loc-LOCMIN].nams); -} - - -#ifdef _PROTOTYPES_ -static void sayobj(Aword obj) -#else -static void sayobj(obj) - Aword obj; -#endif -{ - interpret(objs[obj-OBJMIN].dscr2); -} - -#ifdef _PROTOTYPES_ -static void sayact(Aword act) -#else -static void sayact(act) - Aword act; -#endif -{ - interpret(acts[act-ACTMIN].nam); -} - - -#ifdef _PROTOTYPES_ -void sayint(Aword val) -#else -void sayint(val) - Aword val; -#endif -{ - char buf[25]; - - if (isHere(HERO)) { - sprintf(buf, "%ld", val); - output(buf); - } -} - - -#ifdef _PROTOTYPES_ -void saystr(char *str) -#else -void saystr(str) - char *str; -#endif -{ - if (isHere(HERO)) - output(str); - free(str); -} - - -#ifdef _PROTOTYPES_ -static void saylit(Aword lit) -#else -static void saylit(lit) - Aword lit; -#endif -{ - char *str; - - if (isNum(lit)) - sayint(litValues[lit-LITMIN].value); - else { - str = (char *)strdup((char *)litValues[lit-LITMIN].value); - saystr(str); - } -} - - -#ifdef _PROTOTYPES_ -void sayarticle(Aword id) -#else -void sayarticle(id) - Aword id; -#endif -{ - if (!isObj(id)) - syserr("Trying to say article of something *not* an object."); - if (objs[id-OBJMIN].art != 0) - interpret(objs[id-OBJMIN].art); - else - prmsg(M_ARTICLE); -} - - -#ifdef _PROTOTYPES_ -void say(Aword id) -#else -void say(id) - Aword id; -#endif -{ - char str[80]; - - if (isHere(HERO)) { - if (isObj(id)) - sayobj(id); - else if (isLoc(id)) - sayloc(id); - else if (isAct(id)) - sayact(id); - else if (isLit(id)) - saylit(id); - else { - sprintf(str, "Can't SAY item (%ld).", id); - syserr(str); - } - } -} - - -/*---------------------------------------------------------------------- - - describe() - - */ - -#ifdef _PROTOTYPES_ -static void dscrloc(Aword loc) -#else -static void dscrloc(loc) - Aword loc; -#endif -{ - if (locs[loc-LOCMIN].dscr != 0) - interpret(locs[loc-LOCMIN].dscr); -} - - -#ifdef _PROTOTYPES_ -static void dscrobj(Aword obj) -#else -static void dscrobj(obj) - Aword obj; -#endif -{ - objs[obj-OBJMIN].describe = FALSE; - if (objs[obj-OBJMIN].dscr1 != 0) - interpret(objs[obj-OBJMIN].dscr1); - else { - prmsg(M_SEEOBJ1); - sayarticle(obj); - say(obj); - prmsg(M_SEEOBJ4); - if (objs[obj-OBJMIN].cont != 0) - list(obj); - } -} - - -#ifdef _PROTOTYPES_ -static void dscract(Aword act) -#else -static void dscract(act) - Aword act; -#endif -{ - ScrElem *scr = NULL; - - if (acts[act-ACTMIN].script != 0) { - for (scr = (ScrElem *) addrTo(acts[act-ACTMIN].scradr); !endOfTable(scr); scr++) - if (scr->code == acts[act-ACTMIN].script) - break; - if (endOfTable(scr)) scr = NULL; - } - if (scr != NULL && scr->dscr != 0) - interpret(scr->dscr); - else if (acts[act-ACTMIN].dscr != 0) - interpret(acts[act-ACTMIN].dscr); - else { - interpret(acts[act-ACTMIN].nam); - prmsg(M_SEEACT); - } - acts[act-ACTMIN].describe = FALSE; -} - - -static Aword dscrstk[255]; - -#ifdef _PROTOTYPES_ -void describe(Aword id) -#else -void describe(id) - Aword id; -#endif -{ - int i; - char str[80]; - - for (i = 0; i < dscrstkp; i++) - if (dscrstk[i] == id) - syserr("Recursive DESCRIBE."); - dscrstk[dscrstkp++] = id; - - if (isObj(id)) - dscrobj(id); - else if (isLoc(id)) - dscrloc(id); - else if (isAct(id)) - dscract(id); - else { - sprintf(str, "Can't DESCRIBE item (%ld).", id); - syserr(str); - } - - dscrstkp--; -} - - -/*---------------------------------------------------------------------- - - use() - - */ - -#ifdef _PROTOTYPES_ -void use(Aword act, Aword scr) -#else -void use(act, scr) - Aword act, scr; -#endif -{ - char str[80]; - - if (!isAct(act)) { - sprintf(str, "Item is not an Actor (%ld).", act); - syserr(str); - } - - acts[act-ACTMIN].script = scr; - acts[act-ACTMIN].step = 0; -} - - - -/*---------------------------------------------------------------------- - - list() - - */ - -#ifdef _PROTOTYPES_ -void list(Aword cnt) -#else -void list(cnt) - Aword cnt; -#endif -{ - int i; - Aword props; - Aword prevobj; - Boolean found = FALSE; - Boolean multiple = FALSE; - - /* Find container properties */ - if (isObj(cnt)) - props = objs[cnt-OBJMIN].cont; - else if (isAct(cnt)) - props = acts[cnt-ACTMIN].cont; - else - props = cnt; - - for (i = OBJMIN; i <= OBJMAX; i++) { - if (in(i, cnt)) { /* Yes, it's in this container */ - if (!found) { - found = TRUE; - if (cnts[props-CNTMIN].header != 0) - interpret(cnts[props-CNTMIN].header); - else { - prmsg(M_CONTAINS1); - if (cnts[props-CNTMIN].nam != 0) /* It has it's own name */ - interpret(cnts[props-CNTMIN].nam); - else - say(cnts[props-CNTMIN].parent); /* It is actually an object or actor */ - prmsg(M_CONTAINS2); - } - } else { - if (multiple) { - needsp = FALSE; - prmsg(M_CONTAINS3); - } - multiple = TRUE; - sayarticle(prevobj); - say(prevobj); - } - prevobj = i; - } - } - - if (found) { - if (multiple) - prmsg(M_CONTAINS4); - sayarticle(prevobj); - say(prevobj); - prmsg(M_CONTAINS5); - } else { - if (cnts[props-CNTMIN].empty != 0) - interpret(cnts[props-CNTMIN].empty); - else { - prmsg(M_EMPTY1); - if (cnts[props-CNTMIN].nam != 0) /* It has it's own name */ - interpret(cnts[props-CNTMIN].nam); - else - say(cnts[props-CNTMIN].parent); /* It is actually an actor or object */ - prmsg(M_EMPTY2); - } - } - needsp = TRUE; -} - - -/*---------------------------------------------------------------------- - - empty() - - */ - -#ifdef _PROTOTYPES_ -void empty(Aword cnt, Aword whr) -#else -void empty(cnt, whr) - Aword cnt; - Aword whr; -#endif -{ - int i; - - for (i = OBJMIN; i <= OBJMAX; i++) - if (in(i, cnt)) - locate(i, whr); -} - - - -/*----------------------------------------------------------------------*\ - - Description of current location - - dscrobjs() - dscracts() - look() - -\*----------------------------------------------------------------------*/ - -#ifdef _PROTOTYPES_ -void dscrobjs(void) -#else -void dscrobjs() -#endif -{ - int i; - int prevobj; - Boolean found = FALSE; - Boolean multiple = FALSE; - - /* First describe everything here with its own description */ - for (i = OBJMIN; i <= OBJMAX; i++) - if (objs[i-OBJMIN].loc == cur.loc && - objs[i-OBJMIN].describe && - objs[i-OBJMIN].dscr1) - describe(i); - - /* Then list everything else here */ - for (i = OBJMIN; i <= OBJMAX; i++) - if (objs[i-OBJMIN].loc == cur.loc && - objs[i-OBJMIN].describe) { - if (!found) { - prmsg(M_SEEOBJ1); - sayarticle(i); - say(i); - found = TRUE; - } else { - if (multiple) { - needsp = FALSE; - prmsg(M_SEEOBJ2); - sayarticle(prevobj); - say(prevobj); - } - multiple = TRUE; - } - prevobj = i; - } - - if (found) { - if (multiple) { - prmsg(M_SEEOBJ3); - sayarticle(prevobj); - say(prevobj); - } - prmsg(M_SEEOBJ4); - } - - /* Set describe flag for all objects */ - for (i = OBJMIN; i <= OBJMAX; i++) - objs[i-OBJMIN].describe = TRUE; -} - - -#ifdef _PROTOTYPES_ -void dscracts(void) -#else -void dscracts() -#endif -{ - int i; - - for (i = HERO+1; i <= ACTMAX; i++) - if (acts[i-ACTMIN].loc == cur.loc && - acts[i-ACTMIN].describe) - describe(i); - - /* Set describe flag for all actors */ - for (i = HERO; i <= ACTMAX; i++) - acts[i-ACTMIN].describe = TRUE; -} - - -#ifdef _PROTOTYPES_ -void look(void) -#else -void look() -#endif -{ - int i; - - if (looking) - syserr("Recursive LOOK."); - - looking = TRUE; - /* Set describe flag for all objects and actors */ - for (i = OBJMIN; i <= OBJMAX; i++) - objs[i-OBJMIN].describe = TRUE; - for (i = ACTMIN; i <= ACTMAX; i++) - acts[i-ACTMIN].describe = TRUE; - - if (anyOutput) - para(); - say(cur.loc); - needsp = FALSE; - output("."); - newline(); - describe(cur.loc); - dscrobjs(); - dscracts(); - looking = FALSE; -} - - - -static char savfnm[256]; - - -/*---------------------------------------------------------------------- - - save() - - */ - -#ifdef _PROTOTYPES_ -void save(void) -#else -void save() -#endif -{ - int i; - FILE *savfil; - char str[256]; - AtrElem *atr; - -#ifndef GARGLK - /* First save ? */ - if (savfnm[0] == '\0') { - strcpy(savfnm, advnam); - strcat(savfnm, ".sav"); - } - prmsg(M_SAVEWHERE); - sprintf(str, "(%s) : ", savfnm); - output(str); -#ifdef USE_READLINE - readline(str); -#else - gets(str); -#endif -#else - frefid_t fref; - fref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Write, 0); - if (fref == NULL) - error(M_SAVEFAILED); - strcpy(str, garglk_fileref_get_name(fref)); - glk_fileref_destroy(fref); -#endif - - if (str[0] == '\0') - strcpy(str, savfnm); - col = 1; - if ((savfil = fopen(str, READ_MODE)) != NULL) - /* It already existed */ - if (!confirm(M_SAVEOVERWRITE)) - error(MSGMAX); /* Return to player without saying anything */ - if ((savfil = fopen(str, WRITE_MODE)) == NULL) - error(M_SAVEFAILED); - strcpy(savfnm, str); - - /* Save version of interpreter and name of game */ - fwrite((void *)&header->vers, sizeof(Aword), 1, savfil); - fwrite((void *)advnam, strlen(advnam)+1, 1, savfil); - /* Save current values */ - fwrite((void *)&cur, sizeof(cur), 1, savfil); - /* Save actors */ - for (i = ACTMIN; i <= ACTMAX; i++) { - fwrite((void *)&acts[i-ACTMIN].loc, sizeof(Aword), 1, savfil); - fwrite((void *)&acts[i-ACTMIN].script, sizeof(Aword), 1, savfil); - fwrite((void *)&acts[i-ACTMIN].step, sizeof(Aword), 1, savfil); - fwrite((void *)&acts[i-ACTMIN].count, sizeof(Aword), 1, savfil); - if (acts[i-ACTMIN].atrs) - for (atr = (AtrElem *) addrTo(acts[i-ACTMIN].atrs); !endOfTable(atr); atr++) - fwrite((void *)&atr->val, sizeof(Aword), 1, savfil); - } - - /* Save locations */ - for (i = LOCMIN; i <= LOCMAX; i++) { - fwrite((void *)&locs[i-LOCMIN].describe, sizeof(Aword), 1, savfil); - if (locs[i-LOCMIN].atrs) - for (atr = (AtrElem *) addrTo(locs[i-LOCMIN].atrs); !endOfTable(atr); atr++) - fwrite((void *)&atr->val, sizeof(Aword), 1, savfil); - } - - /* Save objects */ - for (i = OBJMIN; i <= OBJMAX; i++) { - fwrite((void *)&objs[i-OBJMIN].loc, sizeof(Aword), 1, savfil); - if (objs[i-OBJMIN].atrs) - for (atr = (AtrElem *) addrTo(objs[i-OBJMIN].atrs); !endOfTable(atr); atr++) - fwrite((void *)&atr->val, sizeof(atr->val), 1, savfil); - } - - /* Save the event queue */ - eventq[etop].time = 0; /* Mark the top */ - fwrite((void *)&eventq[0], sizeof(eventq[0]), etop+1, savfil); - - /* Save scores */ - for (i = 0; scores[i] != EOF; i++) - fwrite((void *)&scores[i], sizeof(Aword), 1, savfil); - - fclose(savfil); -} - - -/*---------------------------------------------------------------------- - - restore() - - */ - -#ifdef _PROTOTYPES_ -void restore(void) -#else -void restore() -#endif -{ - int i; - FILE *savfil; - char str[256]; - AtrElem *atr; - char savedVersion[4]; - char savedName[256]; - -#ifndef GARGLK - /* First save ? */ - if (savfnm[0] == '\0') { - strcpy(savfnm, advnam); - strcat(savfnm, ".sav"); - } - prmsg(M_RESTOREFROM); - sprintf(str, "(%s) : ", savfnm); - output(str); -#ifdef USE_READLINE - readline(str); -#else - gets(str); -#endif -#else - frefid_t fref; - fref = glk_fileref_create_by_prompt(fileusage_SavedGame, filemode_Read, 0); - if (fref == NULL) - error(M_SAVEFAILED); - strcpy(str, garglk_fileref_get_name(fref)); - glk_fileref_destroy(fref); -#endif - - if (str[0] == '\0') - strcpy(str, savfnm); - col = 1; - if (str[0] == '\0') - strcpy(str, savfnm); /* Use the name temporarily */ - if ((savfil = fopen(str, READ_MODE)) == NULL) - error(M_SAVEMISSING); - strcpy(savfnm, str); /* Save it for future use */ - - fread((void *)&savedVersion, sizeof(Aword), 1, savfil); - /* 4f - save file version check doesn't seem to work on PC's! */ - if (strncmp(savedVersion, header->vers, 4)) { - fclose(savfil); - error(M_SAVEVERS); - return; - } - i = 0; - while ((savedName[i++] = fgetc(savfil)) != '\0'); - if (strcmp(savedName, advnam) != 0) { - fclose(savfil); - error(M_SAVENAME); - return; - } - - /* Restore current values */ - fread((void *)&cur, sizeof(cur), 1, savfil); - /* Restore actors */ - for (i = ACTMIN; i <= ACTMAX; i++) { - fread((void *)&acts[i-ACTMIN].loc, sizeof(Aword), 1, savfil); - fread((void *)&acts[i-ACTMIN].script, sizeof(Aword), 1, savfil); - fread((void *)&acts[i-ACTMIN].step, sizeof(Aword), 1, savfil); - fread((void *)&acts[i-ACTMIN].count, sizeof(Aword), 1, savfil); - if (acts[i-ACTMIN].atrs) - for (atr = (AtrElem *) addrTo(acts[i-ACTMIN].atrs); !endOfTable(atr); atr++) - fread((void *)&atr->val, sizeof(Aword), 1, savfil); - } - - /* Restore locations */ - for (i = LOCMIN; i <= LOCMAX; i++) { - fread((void *)&locs[i-LOCMIN].describe, sizeof(Aword), 1, savfil); - if (locs[i-LOCMIN].atrs) - for (atr = (AtrElem *) addrTo(locs[i-LOCMIN].atrs); !endOfTable(atr); atr++) - fread((void *)&atr->val, sizeof(Aword), 1, savfil); - } - - /* Restore objects */ - for (i = OBJMIN; i <= OBJMAX; i++) { - fread((void *)&objs[i-OBJMIN].loc, sizeof(Aword), 1, savfil); - if (objs[i-OBJMIN].atrs) - for (atr = (AtrElem *) addrTo(objs[i-OBJMIN].atrs); !endOfTable(atr); atr++) - fread((void *)&atr->val, sizeof(atr->val), 1, savfil); - } - - /* Restore the eventq */ - etop = 0; - do { - fread((void *)&eventq[etop], sizeof(eventq[0]), 1, savfil); - etop++; - } while (eventq[etop-1].time != 0); - etop--; - - /* Restore scores */ - for (i = 0; scores[i] != EOF; i++) - fread((void *)&scores[i], sizeof(Aword), 1, savfil); - - fclose(savfil); -} - - - -/*---------------------------------------------------------------------- - - rnd() - - */ - -#ifdef _PROTOTYPES_ -Aword rnd(Aword from, Aword to) -#else -Aword rnd(from, to) - Aword from, to; -#endif -{ - if (to == from) - return to; - else if (to > from) - return (rand()/10)%(to-from+1)+from; - else - return (rand()/10)%(from-to+1)+to; -} - - - -/*---------------------------------------------------------------------- - - btw() - - BETWEEN - - */ - -#ifdef _PROTOTYPES_ -Abool btw(Aint val, Aint low, Aint high) -#else -Abool btw(val, low, high) - Aint val, low, high; -#endif -{ - if (high > low) - return low <= val && val <= high; - else - return high <= val && val <= low; -} - - - -/*---------------------------------------------------------------------- - - contains() - - */ - -#ifdef _PROTOTYPES_ -Aword contains(Aword string, Aword substring) -#else -Aword contains(string, substring) - Aword string, substring;; -#endif -{ - Abool found; - - strlow((char *)string); - strlow((char *)substring); - - found = (strstr((char *)string, (char *)substring) != 0); - - free((char *)string); - free((char *)substring); - - return(found); -} - - - -/*---------------------------------------------------------------------- - - streq() - - Compare two strings approximately, ignore case - - */ -#ifdef _PROTOTYPES_ -Abool streq(char a[], char b[]) -#else -Abool streq(a, b) - char a[], b[]; /* IN - Strings to compare */ -#endif -{ - Boolean eq; - - strlow(a); - strlow(b); - - eq = (strcmp(a, b) == 0); - - free(a); - free(b); - - return(eq); -} diff --git a/app/src/main/jni/terps/alan/alan2/exe.h b/app/src/main/jni/terps/alan/alan2/exe.h deleted file mode 100755 index c6c93b0..0000000 --- a/app/src/main/jni/terps/alan/alan2/exe.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef _EXE_H_ -#define _EXE_H_ -/*----------------------------------------------------------------------*\ - - exe.h - - Header file for instruction execution unit in Alan interpreter - -\*----------------------------------------------------------------------*/ - -/* The event queue */ -extern EvtqElem eventq[]; /* Event queue */ -extern int etop; /* Event queue top pointer */ -extern Boolean looking; /* LOOKING? flag */ -extern int dscrstkp; /* Point into describe stack */ - -#ifdef _PROTOTYPES_ -extern void sys(Aword fpos, Aword len); -extern Boolean confirm(MsgKind msgno); -extern Aword attribute(Aword item, Aword atr); -extern void say(Aword item); -extern void saynum(Aword num); -extern void saystr(char *str); -extern Aword strattr(Aword id, Aword atr); -extern void setstr(Aword id, Aword atr, Aword str); -extern void getstr(Aword fpos, Aword len); -extern void print(Aword fpos, Aword len); -extern void look(void); -extern void make(Aword id, Aword atr, Aword val); -extern void set(Aword id, Aword atr, Aword val); -extern void incr(Aword id, Aword atr, Aword step); -extern void decr(Aword id, Aword atr, Aword step); -extern void use(Aword act, Aword scr); -extern void describe(Aword id); -extern void list(Aword cnt); -extern void locate(Aword id, Aword whr); -extern void empty(Aword cnt, Aword whr); -extern void score(Aword sc); -extern void visits(Aword v); -extern void schedule(Aword evt, Aword whr, Aword aft); -extern void cancl(Aword evt); -extern void quit(void); -extern void restart(void); -extern void save(void); -extern void restore(void); -extern void say(Aword id); -extern void sayint(Aword val); -extern Aword rnd(Aword from, Aword to); -extern Abool btw(Aint val, Aint from, Aint to); -extern Aword contains(Aword string, Aword substring); -extern Abool streq(char a[], char b[]); -extern Abool in(Aword obj, Aword cnt); -extern Aword where(Aword item); -extern Aint agrmax(Aword atr, Aword whr); -extern Aint agrsum(Aword atr, Aword whr); -extern Aint agrcount(Aword whr); -extern Abool isHere(Aword item); -extern Abool isNear(Aword item); - -#else -extern void sys(); -extern Boolean confirm(); -extern Aword attribute(); -extern void say(); -extern void saynum(); -extern void saystr(); -extern Aword strattr(); -extern void setstr(); -extern void getstr(); -extern void print(); -extern void look(); -extern void make(); -extern void set(); -extern void incr(); -extern void decr(); -extern void use(); -extern void describe(); -extern void list(); -extern void locate(); -extern void empty(); -extern void score(); -extern void visits(); -extern void schedule(); -extern void cancl(); -extern void quit(); -extern void restart(); -extern void save(); -extern void restore(); -extern void say(); -extern void sayint(); -extern Aword rnd(); -extern Abool btw(); -extern Aword contains() -extern Abool streq(); -extern Abool in(); -extern Aword where(); -extern Aword agrmax(); -extern Aword agrsum(); -extern Abool isHere(); -extern Abool isNear(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/glkio.c b/app/src/main/jni/terps/alan/alan2/glkio.c deleted file mode 100755 index d8a3de1..0000000 --- a/app/src/main/jni/terps/alan/alan2/glkio.c +++ /dev/null @@ -1,30 +0,0 @@ -/*----------------------------------------------------------------------*\ - - glkio.c - - Glk output for Alan interpreter - -\*----------------------------------------------------------------------*/ - -#include -#include - -#include "glk.h" -#include "glkio.h" - -void glkio_printf(char *fmt, ...) -{ - va_list argp; - va_start(argp, fmt); - if (NULL == glkMainWin) - /* assume stdio is available in this case only */ - vprintf(fmt, argp); - else - { - char buf[1024]; /* FIXME: buf size should be foolproof */ - vsprintf(buf, fmt, argp); - glk_put_string(buf); - } - va_end(argp); -} - diff --git a/app/src/main/jni/terps/alan/alan2/glkio.h b/app/src/main/jni/terps/alan/alan2/glkio.h deleted file mode 100755 index c12d04f..0000000 --- a/app/src/main/jni/terps/alan/alan2/glkio.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _GLKIO_H_ -#define _GLKIO_H_ - -/*----------------------------------------------------------------------*\ - - glkio.c - - Header file for Glk output for Alan interpreter - -\*----------------------------------------------------------------------*/ - -#include "glk.h" - -winid_t glkMainWin; -winid_t glkStatusWin; - -/* NB: this header must be included in any file which calls printf() */ - -#define printf glkio_printf - -void glkio_printf(char *, ...); - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/glkstart.c b/app/src/main/jni/terps/alan/alan2/glkstart.c deleted file mode 100755 index 4c95df6..0000000 --- a/app/src/main/jni/terps/alan/alan2/glkstart.c +++ /dev/null @@ -1,82 +0,0 @@ -/* glkstart.c: Unix-specific startup code - Adapted for Alan by Joe Mason - Based on the sample file designed by - Andrew Plotkin - http://www.eblong.com/zarf/glk/index.html - - Original release note follows: - - This is Unix startup code for the simplest possible kind of Glk - program -- no command-line arguments; no startup files; no nothing. - - Remember, this is a sample file. You should copy it into the Glk - program you are compiling, and modify it to your needs. This should - *not* be compiled into the Glk library itself. -*/ - -#include "glk.h" -#include "glkstart.h" -#include "glkio.h" -#include "args.h" -#include "resources.h" - -glkunix_argumentlist_t glkunix_arguments[] = { - { "-v", glkunix_arg_NoValue, "-v: verbose mode" }, - { "-l", glkunix_arg_NoValue, "-l: log player command and game output" }, - { "-i", glkunix_arg_NoValue, "-i: ignore version and checksum errors" }, - { "-d", glkunix_arg_NoValue, "-d: enter debug mode" }, - { "-t", glkunix_arg_NoValue, "-t: trace game execution" }, - { "-s", glkunix_arg_NoValue, "-s: single instruction trace" }, - { "", glkunix_arg_ValueFollows, "filename: The game file to load." }, - { NULL, glkunix_arg_End, NULL } -}; - -int glkunix_startup_code(glkunix_startup_t *data) -{ - /* first, open a window for error output */ - glkMainWin = glk_window_open(0, 0, 0, wintype_TextBuffer, 0); - if (NULL == glkMainWin) - { - printf("FATAL ERROR: Cannot open initial window"); - glk_exit(); - } - glkStatusWin = glk_window_open(glkMainWin, winmethod_Above | - winmethod_Fixed, 1, wintype_TextGrid, 0); - glk_set_window(glkMainWin); - - /* now process the command line arguments */ - args(data->argc, data->argv); - - return TRUE; -} - -#ifdef WINGLK -#include "WinGlk.h" -#include -int winglk_startup_code(const char* cmdline) -{ - char *argumentVector[2]; - - winglk_app_set_name("Arun"); - winglk_set_gui(IDR_ARUN); - - /* First, open a window for error output */ - glkMainWin = glk_window_open(0, 0, 0, wintype_TextBuffer, 0); - if (glkMainWin == NULL) - { - printf("FATAL ERROR: Cannot open initial window"); - glk_exit(); - } - - /* now process the command line arguments */ - argumentVector[0] = ""; - argumentVector[1] = (char *)cmdline; - args(2, &argumentVector); - - glkStatusWin = glk_window_open(glkMainWin, winmethod_Above | - winmethod_Fixed, 1, wintype_TextGrid, 0); - glk_set_window(glkMainWin); - - return TRUE; -} -#endif diff --git a/app/src/main/jni/terps/alan/alan2/glkstart.h b/app/src/main/jni/terps/alan/alan2/glkstart.h deleted file mode 100755 index 4ba0924..0000000 --- a/app/src/main/jni/terps/alan/alan2/glkstart.h +++ /dev/null @@ -1,62 +0,0 @@ -/* glkstart.h: Unix-specific header file for GlkTerm, CheapGlk, and XGlk - (Unix implementations of the Glk API). - Designed by Andrew Plotkin - http://www.eblong.com/zarf/glk/index.html -*/ - -/* This header defines an interface that must be used by program linked - with the various Unix Glk libraries -- at least, the three I wrote. - (I encourage anyone writing a Unix Glk library to use this interface, - but it's not part of the Glk spec.) - - Because Glk is *almost* perfectly portable, this interface *almost* - doesn't have to exist. In practice, it's small. -*/ - -#ifndef GT_START_H -#define GT_START_H - -/* We define our own TRUE and FALSE and NULL, because ANSI - is a strange world. */ -#ifndef TRUE -#define TRUE 1 -#endif -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef NULL -#define NULL 0 -#endif - -#define glkunix_arg_End (0) -#define glkunix_arg_ValueFollows (1) -#define glkunix_arg_NoValue (2) -#define glkunix_arg_ValueCanFollow (3) -#define glkunix_arg_NumberValue (4) - -typedef struct glkunix_argumentlist_struct { - char *name; - int argtype; - char *desc; -} glkunix_argumentlist_t; - -typedef struct glkunix_startup_struct { - int argc; - char **argv; -} glkunix_startup_t; - -/* The list of command-line arguments; this should be defined in your code. */ -extern glkunix_argumentlist_t glkunix_arguments[]; - -/* The external function; this should be defined in your code. */ -extern int glkunix_startup_code(glkunix_startup_t *data); - -/* Some helpful utility functions which the library makes available - to your code. Obviously, this is nonportable; so you should - only call it from glkunix_startup_code(). -*/ -extern strid_t glkunix_stream_open_pathname(char *pathname, glui32 textmode, - glui32 rock); - -#endif /* GT_START_H */ - diff --git a/app/src/main/jni/terps/alan/alan2/inter.c b/app/src/main/jni/terps/alan/alan2/inter.c deleted file mode 100755 index 4848135..0000000 --- a/app/src/main/jni/terps/alan/alan2/inter.c +++ /dev/null @@ -1,875 +0,0 @@ -/*----------------------------------------------------------------------*\ - - inter.c - - Interpreter unit for Alan interpreter Arun - -\*----------------------------------------------------------------------*/ - - -#include - -#include "types.h" -#include "main.h" -#include "parse.h" -#include "exe.h" -#include "stack.h" -#include "sysdep.h" - -#include "inter.h" - -#ifdef GLK -#include "glkio.h" -#endif - -/* PRIVATE DATA */ - -static int pc; - - -#ifdef _PROTOTYPES_ -static void if_( - Aword v -) -#else -static void if_(v) - Aword v; -#endif -{ - int lev = 1; - Aword i; - - if (!v) { - /* Skip to next ELSE or ENDIF on same level */ - while (TRUE) { - i = memory[pc++]; - if (I_CLASS(i) == (Aword)C_STMOP) - switch (I_OP(i)) { - case I_ELSE: - if (lev == 1) return; - break; - case I_IF: - lev++; - break; - case I_ENDIF: - lev--; - if (lev == 0) return; - break; - } - } - } -} - - -#ifdef _PROTOTYPES_ -static void else_(void) -#else -static void else_() -#endif -{ - int lev = 1; - Aword i; - - while (TRUE) { - /* Skip to ENDIF on the same level */ - i = memory[pc++]; - if (I_CLASS(i) == (Aword)C_STMOP) - switch (I_OP(i)) { - case I_ENDIF: - lev--; - if (lev == 0) return; - break; - case I_IF: - lev++; - break; - } - } -} - - -#ifdef _PROTOTYPES_ -static void depstart(void) -#else -static void depstart(void) -#endif -{ - /* A DEPSTART was executed so skip across the redundant DEPCASE to - start at the first expression */ - pc++; -} - - -#ifdef _PROTOTYPES_ -static void swap(void) -#else -static void swap() -#endif -{ - Aword v1 = pop(); - Aword v2 = pop(); - - push(v1); - push(v2); -} - - - -#ifdef _PROTOTYPES_ -static void depexec( - Aword v -) -#else -static void depexec(v) - Aword v; -#endif -{ - int lev = 1; - Aword i; - - if (!v) - /* The expression was not true, skip to next CASE on the same - level which could be a DEPCASE or DEPELSE */ - while (TRUE) { - i = memory[pc++]; - if (I_CLASS(i) == (Aword)C_STMOP) - switch (I_OP(i)) { - case I_DEPSTART: - lev++; - break; - case I_DEPEND: - if (lev == 1) return; - lev--; - break; - case I_DEPCASE: - case I_DEPELSE: - if (lev == 1) return; - break; - } - } -} - - -#ifdef _PROTOTYPES_ -static void depcase(void) -#else -static void depcase() -#endif -{ - int lev = 1; - Aword i; - - /* Skip to end of DEPENDING block (next DEPEND on same level) because - we have just executed a DEPCASE/DEPELSE statement as a result of a DEPCASE - catching */ - - while (TRUE) { - i = memory[pc++]; - if (I_CLASS(i) == (Aword)C_STMOP) - switch (I_OP(i)) { - case I_DEPSTART: - lev++; - break; - case I_DEPEND: - lev--; - if (lev == 0) return; - break; - } - } -} - - -#ifdef _PROTOTYPES_ -void interpret(Aaddr adr) -#else -void interpret(adr) - Aaddr adr; -#endif -{ - Aaddr oldpc; - Aword i; - - if (stpflg) printf("\n++++++++++++++++++++++++++++++++++++++++++++++++++"); - - oldpc = pc; - pc = adr; - while(TRUE) { - if (stpflg) printf("\n%4x: ", pc); - if (pc > memTop) - syserr("Interpreting outside program."); - - i = memory[pc++]; - - switch (I_CLASS(i)) { - case C_CONST: - if (stpflg) printf("PUSH \t%5ld", I_OP(i)); - push(I_OP(i)); - break; - case C_CURVAR: - switch (I_OP(i)) { - case V_PARAM: - if (stpflg) printf("PARAM \t%5ld\t\t(%ld)", top(), params[top()-1].code); - push(params[pop()-1].code); - break; - case V_CURLOC: - if (stpflg) printf("CURLOC \t\t\t(%d)", cur.loc); - push(cur.loc); - break; - case V_CURACT: - if (stpflg) printf("CURACT \t\t\t(%d)", cur.act); - push(cur.act); - break; - case V_CURVRB: - if (stpflg) printf("CURVRB \t\t\t(%d)", cur.vrb); - push(cur.vrb); - break; - case V_SCORE: - if (stpflg) printf("CURSCORE \t\t\t(%d)", cur.score); - push(cur.score); - break; - default: - syserr("Unknown CURVAR instruction."); - break; - } - break; - - case C_STMOP: - switch (I_OP(i)) { - case I_PRINT: { - Aword fpos, len; - fpos = pop(); - len = pop(); - if (stpflg) { - printf("PRINT \t%5ld, %5ld\t\"", fpos, len); - col = 34; /* To format it better! */ - } - print(fpos, len); - if (stpflg) - printf("\""); - break; - } - case I_SYSTEM: { - Aword fpos, len; - fpos = pop(); - len = pop(); - if (stpflg) { - printf("SYSTEM \t%5ld, %5ld\t\"", fpos, len); - col = 34; /* To format it better! */ - } - sys(fpos, len); - break; - } - case I_GETSTR: { - Aword fpos, len; - fpos = pop(); - len = pop(); - if (stpflg) - printf("GETSTR\t%5ld, %5ld", fpos, len); - getstr(fpos, len); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_QUIT: { - if (stpflg) - printf("QUIT"); - quit(); - break; - } - case I_LOOK: { - if (stpflg) - printf("LOOK"); - look(); - break; - } - case I_SAVE: { - if (stpflg) - printf("SAVE"); - save(); - break; - } - case I_RESTORE: { - if (stpflg) - printf("RESTORE"); - restore(); - break; - } - case I_RESTART: { - if (stpflg) - printf("RESTART"); - restart(); - break; - } - case I_LIST: { - Aword cnt; - cnt = pop(); - if (stpflg) - printf("LIST \t%5ld", cnt); - list(cnt); - break; - } - case I_EMPTY: { - Aword cnt, whr; - cnt = pop(); - whr = pop(); - if (stpflg) - printf("EMPTY \t%5ld, %5ld", cnt, whr); - empty(cnt, whr); - break; - } - case I_SCORE: { - Aword sc; - sc = pop(); - if (stpflg) - printf("SCORE \t%5ld\t\t(%ld)", sc, scores[sc-1]); - score(sc); - break; - } - case I_VISITS: { - Aword v; - v = pop(); - if (stpflg) - printf("VISITS \t%5ld", v); - visits(v); - break; - } - case I_SCHEDULE: { - Aword evt, whr, aft; - evt = pop(); - whr = pop(); - aft = pop(); - if (stpflg) - printf("SCHEDULE \t%5ld, %5ld, %5ld", evt, whr, aft); - schedule(evt, whr, aft); - break; - } - case I_CANCEL: { - Aword evt; - evt = pop(); - if (stpflg) - printf("CANCEL \t%5ld", evt); - cancl(evt); - break; - } - case I_MAKE: { - Aword id, atr, val; - id = pop(); - atr = pop(); - val = pop(); - if (stpflg) { - printf("MAKE \t%5ld, %5ld, ", id, atr); - if (val) printf("TRUE"); else printf("FALSE"); - } - make(id, atr, val); - break; - } - case I_SET: { - Aword id, atr, val; - id = pop(); - atr = pop(); - val = pop(); - if (stpflg) { - printf("SET \t%5ld, %5ld, %5ld", id, atr, val); - } - set(id, atr, val); - break; - } - case I_STRSET: { - Aword id, atr, str; - id = pop(); - atr = pop(); - str = pop(); - if (stpflg) { - printf("STRSET\t%5ld, %5ld, %5ld", id, atr, str); - } - setstr(id, atr, str); - break; - } - case I_INCR: { - Aword id, atr, step; - id = pop(); - atr = pop(); - step = pop(); - if (stpflg) { - printf("INCR\t%5ld, %5ld, %5ld", id, atr, step); - } - incr(id, atr, step); - break; - } - case I_DECR: { - Aword id, atr, step; - id = pop(); - atr = pop(); - step = pop(); - if (stpflg) { - printf("DECR\t%5ld, %5ld, %5ld", id, atr, step); - } - decr(id, atr, step); - break; - } - case I_ATTRIBUTE: { - Aword id, atr; - id = pop(); - atr = pop(); - if (stpflg) - printf("ATTRIBUTE %5ld, %5ld", id, atr); - push(attribute(id, atr)); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_STRATTR: { - Aword id, atr; - id = pop(); - atr = pop(); - if (stpflg) - printf("STRATTR \t%5ld, %5ld", id, atr); - push(strattr(id, atr)); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_LOCATE: { - Aword id, whr; - id = pop(); - whr = pop(); - if (stpflg) - printf("LOCATE \t%5ld, %5ld", id, whr); - locate(id, whr); - break; - } - case I_WHERE: { - Aword id; - id = pop(); - if (stpflg) - printf("WHERE \t%5ld", id); - push(where(id)); - if (stpflg) - printf("\t\t(%ld)", top()); - break; - } - case I_HERE: { - Aword id; - id = pop(); - if (stpflg) - printf("HERE \t%5ld", id); - push(isHere(id)); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_NEAR: { - Aword id; - id = pop(); - if (stpflg) - printf("NEAR \t%5ld", id); - push(isNear(id)); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_USE: { - Aword act, scr; - act = pop(); - scr = pop(); - if (stpflg) - printf("USE \t%5ld, %5ld", act, scr); - use(act, scr); - break; - } - case I_IN: { - Aword obj, cnt; - obj = pop(); - cnt = pop(); - if (stpflg) - printf("IN \t%5ld, %5ld ", obj, cnt); - push(in(obj, cnt)); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_DESCRIBE: { - Aword id; - id = pop(); - if (stpflg) { - printf("DESCRIBE \t%5ld\t", id); - col = 34; /* To format it better! */ - } - describe(id); - break; - } - case I_SAY: { - Aword id; - id = pop(); - if (stpflg) - printf("SAY \t%5ld\t\t\"", id); - say(id); - if (stpflg) - printf("\""); - break; - } - case I_SAYINT: { - Aword val; - val = pop(); - if (stpflg) - printf("SAYINT\t%5ld\t\t\"", val); - sayint(val); - if (stpflg) - printf("\""); - break; - } - case I_SAYSTR: { - Aword adr; - adr = pop(); - if (stpflg) - printf("SAYSTR\t%5ld\t\t\"", adr); - saystr((char *)adr); - if (stpflg) - printf("\""); - break; - } - case I_IF: { - Aword v; - v = pop(); - if (stpflg) { - printf("IF \t"); - if (v) printf(" TRUE"); else printf("FALSE"); - } - if_(v); - break; - } - case I_ELSE: { - if (stpflg) - printf("ELSE"); - else_(); - break; - } - case I_ENDIF: { - if (stpflg) - printf("ENDIF"); - break; - } - case I_AND: { - Aword lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) { - printf("AND \t"); - if (lh) printf("TRUE, "); else printf("FALSE, "); - if (rh) printf("TRUE"); else printf("FALSE"); - } - push(lh && rh); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_OR: { - Aword lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) { - printf("OR \t"); - if (lh) printf("TRUE, "); else printf("FALSE, "); - if (rh) printf("TRUE"); else printf("FALSE"); - } - push(lh || rh); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_NE: { - Aword lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("NE \t%5ld, %5ld", lh, rh); - push(lh != rh); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_EQ: { - Aword lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("EQ \t%5ld, %5ld", lh, rh); - push(lh == rh); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_STREQ: { - Aword lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("STREQ \t%5ld, %5ld", lh, rh); - push(streq((char *)lh, (char *)rh)); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_STREXACT: { - Aword lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("STREXACT \t%5ld, %5ld", lh, rh); - push(strcmp((char *)lh, (char *)rh) == 0); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - free((void *)lh); - free((void *)rh); - break; - } - case I_LE: { - Aint lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("LE \t%5ld, %5ld", lh, rh); - push(lh <= rh); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_GE: { - Aint lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("GE \t%5ld, %5ld", lh, rh); - push(lh >= rh); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_LT: { - Aint lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("LT \t%5ld, %5ld", lh, rh); - push((signed int)lh < (signed int)rh); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_GT: { - Aint lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("GT \t%5ld, %5ld", lh, rh); - push(lh > rh); - if (stpflg) - if (top()) printf("\t(TRUE)"); else printf("\t(FALSE)"); - break; - } - case I_PLUS: { - Aint lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("PLUS \t%5ld, %5ld", lh, rh); - push(lh + rh); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_MINUS: { - Aint lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("MINUS \t%5ld, %5ld", lh, rh); - push(lh - rh); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_MULT: { - Aint lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("MULT \t%5ld, %5ld", lh, rh); - push(lh * rh); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_DIV: { - Aint lh, rh; - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - swap(); - rh = pop(); - lh = pop(); - if (stpflg) - printf("DIV \t%5ld, %5ld", lh, rh); - push(lh / rh); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_NOT: { - Aword val; - val = pop(); - if (stpflg) { - printf("NOT \t"); - if (val) printf("TRUE"); else printf("FALSE"); - } - push(!val); - if (stpflg) - if (top()) printf("\t\t(TRUE)"); else printf("\t\t(FALSE)"); - break; - } - case I_MAX: { - Aword atr, whr; - atr = pop(); - whr = pop(); - if (stpflg) - printf("MAX \t%5ld, %5ld", atr, whr); - push(agrmax(atr, whr)); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_SUM: { - Aword atr, whr; - atr = pop(); - whr = pop(); - if (stpflg) - printf("SUM \t%5ld, %5ld", atr, whr); - push(agrsum(atr, whr)); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_COUNT: { - Aword whr; - whr = pop(); - if (stpflg) - printf("COUNT \t%5ld", whr); - push(agrcount(whr)); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_RND: { - Aword from, to; - from = pop(); - to = pop(); - if (stpflg) - printf("RANDOM \t%5ld, %5ld", from, to); - push(rnd(from, to)); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_BTW: { - Aint low, high, val; - high = pop(); - low = pop(); - val = pop(); - if (stpflg) - printf("BETWEEN \t%5ld, %5ld, %5ld", val, low, high); - push(btw(val, low, high)); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - case I_CONTAINS: { - Aword string, substring; - substring = pop(); - string = pop(); - if (stpflg) - printf("CONTAINS \t%5ld, %5ld", string, substring); - push(contains(string, substring)); - if (stpflg) - printf("\t(%ld)", top()); - break; - } - - case I_DEPSTART: - if (stpflg) - printf("DEPSTART"); - depstart(); - break; - - case I_DEPCASE: - if (stpflg) - printf("DEPCASE"); - depcase(); - break; - - case I_DEPEXEC: { - Aword v; - v = pop(); - if (stpflg) { - printf("DEPEXEC \t"); - if (v) printf(" TRUE"); else printf("FALSE"); - } - depexec(v); - break; - } - - case I_DEPELSE: - if (stpflg) - printf("DEPELSE"); - depcase(); - break; - - case I_DEPEND: - if (stpflg) - printf("DEPEND"); - break; - - case I_RETURN: - if (stpflg) - printf("RETURN\n--------------------------------------------------\n"); - pc = oldpc; - return; - - default: - syserr("Unknown STMOP instruction."); - break; - } - if (fail) { - pc = oldpc; - return; - } - break; - - default: - syserr("Unknown instruction class."); - break; - } - } -} diff --git a/app/src/main/jni/terps/alan/alan2/inter.h b/app/src/main/jni/terps/alan/alan2/inter.h deleted file mode 100755 index bb3b335..0000000 --- a/app/src/main/jni/terps/alan/alan2/inter.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _INTER_H_ -#define _INTER_H_ -/*----------------------------------------------------------------------*\ - - inter.h - - The interpreter of Acode. - -\*----------------------------------------------------------------------*/ - -/* Types: */ - -/* Data: */ - -/* Functions: */ - -#ifdef _PROTOTYPES_ - -extern void interpret(Aaddr adr); - -#else -extern void interpret(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/main.c b/app/src/main/jni/terps/alan/alan2/main.c deleted file mode 100755 index ca60719..0000000 --- a/app/src/main/jni/terps/alan/alan2/main.c +++ /dev/null @@ -1,1896 +0,0 @@ -/*----------------------------------------------------------------------*\ - - MAIN.C - - Main module of interpreter for ALAN Adventure Language - -\*----------------------------------------------------------------------*/ - -#define V27COMPATIBLE - -#include "sysdep.h" - -#include "types.h" -#include "main.h" - -#include -#ifdef USE_READLINE -#include "readline.h" -#endif - -#ifdef HAVE_SHORT_FILENAMES -#include "av.h" -#else -#include "alan.version.h" -#endif - -#include "args.h" -#include "parse.h" -#include "inter.h" -#include "rules.h" -#ifdef REVERSED -#include "reverse.h" -#endif -#include "debug.h" -#include "stack.h" -#include "exe.h" -#include "term.h" - -#ifdef GLK -#include "glk.h" -#include "glkio.h" -#endif - -/* PUBLIC DATA */ - -/* The Amachine memory */ -Aword *memory; -static AcdHdr dummyHeader; /* Dummy to use until memory allocated */ -AcdHdr *header = &dummyHeader; - -int memTop = 0; /* Top of load memory */ - -int conjWord; /* First conjunction in dictonary, for ',' */ - - -/* Amachine variables */ -CurVars cur; - -/* Amachine structures */ -WrdElem *dict; /* Dictionary pointer */ -ActElem *acts; /* Actor table pointer */ -LocElem *locs; /* Location table pointer */ -VrbElem *vrbs; /* Verb table pointer */ -StxElem *stxs; /* Syntax table pointer */ -ObjElem *objs; /* Object table pointer */ -CntElem *cnts; /* Container table pointer */ -RulElem *ruls; /* Rule table pointer */ -EvtElem *evts; /* Event table pointer */ -MsgElem *msgs; /* Message table pointer */ -Aword *scores; /* Score table pointer */ -Aword *freq; /* Cumulative character frequencies */ - -int dictsize; - -Boolean verbose = FALSE; -Boolean errflg = TRUE; -Boolean trcflg = FALSE; -Boolean dbgflg = FALSE; -Boolean stpflg = FALSE; -Boolean logflg = FALSE; -Boolean statusflg = TRUE; -Boolean fail = FALSE; -Boolean anyOutput = FALSE; - - -/* The files and filenames */ -char *advnam; -FILE *txtfil; -FILE *logfil; - - -/* Screen formatting info */ -int col, lin; -int paglen, pagwidth; - -Boolean needsp = FALSE; -Boolean skipsp = FALSE; - -/* Restart jump buffer */ -jmp_buf restart_label; - - -/* PRIVATE DATA */ -static jmp_buf jmpbuf; /* Error return long jump buffer */ - - - -/*====================================================================== - - terminate() - - Terminate the execution of the adventure, e.g. close windows, - return buffers... - - */ -#ifdef _PROTOTYPES_ -void terminate(int code) -#else -void terminate(code) - int code; -#endif -{ -#ifdef __amiga__ -#ifdef AZTEC_C -#include - extern struct _dev *_devtab; - char buf[85]; - - if (con) { /* Running from WB, created a console so kill it */ - /* Running from WB, so we created a console and - hacked the Aztec C device table to use it for all I/O - so now we need to make it close it (once!) */ - _devtab[1].fd = _devtab[2].fd = 0; - } else -#else - /* Geek Gadgets GCC */ -#include -#include -#include - - if (_WBenchMsg != NULL) { - Close(window); - if (_WBenchMsg->sm_ArgList != NULL) - UnLock(CurrentDir(cd)); - } else -#endif -#endif - newline(); - free(memory); - if (logflg) - fclose(logfil); - -#ifdef __MWERKS__ - printf("Command-Q to close window."); -#endif - -#ifdef GLK - glk_exit(); -#else - exit(code); -#endif -} - -/*====================================================================== - - usage() - - */ -#ifdef _PROTOTYPES_ -void usage(void) -#else -void usage() -#endif -{ - printf("Usage:\n\n"); - printf(" %s [] \n\n", PROGNAME); - printf("where the possible optional switches are:\n"); -#ifdef GLK - glk_set_style(style_Preformatted); -#endif - printf(" -v verbose mode\n"); - printf(" -l log player commands and game output to a file\n"); - printf(" -i ignore version and checksum errors\n"); - printf(" -n no Status Line\n"); - printf(" -d enter debug mode\n"); - printf(" -t trace game execution\n"); - printf(" -s single instruction trace\n"); -#ifdef GLK - glk_set_style(style_Normal); -#endif -} - - -/*====================================================================== - - syserr() - - Print a little text blaming the user for the system error. - - */ -#ifdef _PROTOTYPES_ -void syserr(char *str) -#else -void syserr(str) - char *str; -#endif -{ - output("$n$nAs you enter the twilight zone of Adventures, you stumble \ -and fall to your knees. In front of you, you can vaguely see the outlines \ -of an Adventure that never was.$n$nSYSTEM ERROR: "); - output(str); - output("$n$n"); - - if (logflg) - fclose(logfil); - newline(); - -#ifdef __amiga__ -#ifdef AZTEC_C - { - char buf[80]; - - if (con) { /* Running from WB, wait for user ack. */ - printf("press RETURN to quit"); - gets(buf); - } - } -#endif -#endif - - terminate(0); -} - - -/*====================================================================== - - error() - - Print an error message, force new player input and abort. - - */ -#ifdef _PROTOTYPES_ -void error(MsgKind msgno) /* IN - The error message number */ -#else -void error(msgno) - MsgKind msgno; /* IN - The error message number */ -#endif -{ - if (msgno != MSGMAX) - prmsg(msgno); - wrds[wrdidx] = EOF; /* Force new player input */ - dscrstkp = 0; /* Reset describe stack */ - longjmp(jmpbuf,TRUE); -} - - -/*====================================================================== - - statusline() - - Print the the status line on the top of the screen. - - */ -void statusline(void) -{ -#ifdef GLK - glui32 glkWidth; - char line[100]; - int pcol = col; - - if (NULL == glkStatusWin) - return; - - glk_set_window(glkStatusWin); - glk_window_clear(glkStatusWin); - glk_window_get_size(glkStatusWin, &glkWidth, NULL); - - col = 1; - glk_window_move_cursor(glkStatusWin, 1, 0); - say(where(HERO)); - if (header->maxscore > 0) - sprintf(line, "Score %d(%d)/%d moves", cur.score, (int)header->maxscore, cur.tick); - else - sprintf(line, "%d moves", cur.tick); - glk_window_move_cursor(glkStatusWin, glkWidth - col - strlen(line), 0); - printf(line); - needsp = FALSE; - - col = pcol; - - glk_set_window(glkMainWin); -#else -#ifdef HAVE_ANSI - char line[100]; - int i; - int pcol = col; - - if (!statusflg) return; - /* ansi_position(1,1); ansi_bold_on(); */ - printf("\x1b[1;1H"); - printf("\x1b[7m"); - col = 1; - say(where(HERO)); - if (header->maxscore > 0) - sprintf(line, "Score %ld(%ld)/%ld moves", cur.score, (int)header->maxscore, cur.tick); - else - sprintf(line, "%ld moves", cur.tick); - for (i=0; i < pagwidth - col - strlen(line); i++) putchar(' '); - printf(line); - printf("\x1b[m"); - printf("\x1b[%d;1H", paglen); - needsp = FALSE; - - col = pcol; -#endif -#endif -} - - -/*====================================================================== - - logprint() - - Print some text and log it if logging is on. - - */ -void logprint(char str[]) -{ - printf(str); - if (logflg) - fprintf(logfil, "%s", str); -} - - - -/*====================================================================== - - newline() - - Make a newline, but check for screen full. - - */ -#ifdef _PROTOTYPES_ -void newline(void) -#else -void newline() -#endif -{ -#ifdef GLK - glk_put_char('\n'); -#else - char buf[256]; - - col = 1; - if (lin >= paglen - 1) { - logprint("\n"); - needsp = FALSE; - prmsg(M_MORE); -#ifdef USE_READLINE - (void) readline(buf); -#else - fgets(buf, 256, stdin); -#endif - getPageSize(); - lin = 0; - } else - logprint("\n"); - - lin++; - needsp = FALSE; -#endif -} - - -/*====================================================================== - - para() - - Make a new paragraph, i.e one empty line (one or two newlines). - - */ -#ifdef _PROTOTYPES_ -void para(void) -#else -void para() -#endif -{ -#ifdef GLK - glk_put_char('\n'); - glk_put_char('\n'); -#else - if (col != 1) - newline(); - newline(); -#endif -} - - -/*====================================================================== - - clear() - - Clear the screen. - - */ -#ifdef _PROTOTYPES_ -void clear(void) -#else -void clear() -#endif -{ -#ifdef GLK - glk_window_clear(glkMainWin); -#else -#ifdef HAVE_ANSI - if (!statusflg) return; - printf("\x1b[2J"); - printf("\x1b[%d;1H", paglen); -#endif -#endif -} - - -/*====================================================================== - - allocate() - - Safely allocate new memory. - -*/ -#ifdef _PROTOTYPES_ -void *allocate(unsigned long len) /* IN - Length to allocate */ -#else -void *allocate(len) - unsigned long len; /* IN - Length to allocate */ -#endif -{ - void *p = (void *)malloc((size_t)len); - - if (p == NULL) - syserr("Out of memory."); - - return p; -} - - -/*---------------------------------------------------------------------- - - just() - - Justify a string so that it wraps at end of screen. - - */ -#ifdef _PROTOTYPES_ -static void just(char str[]) -#else -static void just(str) - char str[]; -#endif -{ -#ifdef GLK - logprint(str); -#else - int i; - char ch; - - if (col >= pagwidth && !skipsp) - newline(); - - while (strlen(str) > pagwidth - col) { - i = pagwidth - col - 1; - while (!isSpace(str[i]) && i > 0) /* First find wrap point */ - i--; - if (i == 0 && col == 1) /* If it doesn't fit at all */ - /* Wrap immediately after this word */ - while (!isSpace(str[i]) && str[i] != '\0') - i++; - if (i > 0) { /* If it fits ... */ - ch = str[i]; /* Save space or NULL */ - str[i] = '\0'; /* Terminate string */ - logprint(str); /* and print it */ - skipsp = FALSE; /* If skipping, now we're done */ - str[i] = ch; /* Restore character */ - /* Skip white after printed portion */ - for (str = &str[i]; isSpace(str[0]) && str[0] != '\0'; str++); - } - newline(); /* Then start a new line */ - } - logprint(str); /* Print tail */ - col = col + strlen(str); /* Update column */ -#endif -} - - -/*---------------------------------------------------------------------- - - space() - - Output a space if needed. - - */ -#ifdef _PROTOTYPES_ -static void space(void) -#else -static void space() -#endif -{ - if (skipsp) - skipsp = FALSE; - else { - if (needsp) { - logprint(" "); - col++; - } - } - needsp = FALSE; -} - - - -/*---------------------------------------------------------------------- - - sayparam() - - A parameter needs to be said, check for words the player used and use - them if possible. - -*/ -#ifdef _PROTOTYPES_ -static void sayparam(int p) -#else -static void sayparam(p) - int p; -#endif -{ - int i; - - for (i = 0; i <= p; i++) - if (params[i].code == EOF) - syserr("Nonexistent parameter referenced."); - - if (params[p].firstWord == EOF) /* Any words he used? */ - say(params[p].code); - else /* Yes, so use them... */ - for (i = params[p].firstWord; i <= params[p].lastWord; i++) { - just((char *)addrTo(dict[wrds[i]].wrd)); - if (i < params[p].lastWord) - just(" "); - } -} - - -/*---------------------------------------------------------------------- - - prsym() - - Print an expanded symbolic reference. - - N = newline - I = indent on a new line - P = new paragraph - L = current location name - O = current object -> first parameter! - V = current verb - A = current actor - T = tabulation - $ = no space needed after this - */ -#ifdef _PROTOTYPES_ -static void prsym( - char *str /* IN - The string starting with '$' */ -) -#else -static void prsym(str) - char *str; /* IN - The string starting with '$' */ -#endif -{ - switch (toLower(str[1])) { - case 'n': - newline(); - needsp = FALSE; - break; - case 'i': - newline(); - logprint(" "); - col = 5; - needsp = FALSE; - break; - case 'o': - sayparam(0); - needsp = TRUE; /* We did print something non-white */ - break; - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - sayparam(str[1]-'1'); - needsp = TRUE; /* We did print something non-white */ - break; - case 'l': - say(cur.loc); - needsp = TRUE; /* We did print something non-white */ - break; - case 'a': - say(cur.act); - needsp = TRUE; /* We did print something non-white */ - break; - case 'v': - just((char *)addrTo(dict[vrbwrd].wrd)); - needsp = TRUE; /* We did print something non-white */ - break; - case 'p': - para(); - needsp = FALSE; - break; - case 't': { - int i; - int spaces = 4-(col-1)%4; - - for (i = 0; i 0) { - just(str); /* Output part before '$' */ - if (str[strlen(str)-1] == ' ') - needsp = FALSE; - } - *symptr = ch; /* restore '$' */ - prsym(symptr); /* Print the symbolic reference */ - str = &symptr[2]; /* Advance to after symbol and continue */ - } - if (str[0] != 0) { - just(str); /* Output trailing part */ - skipsp = FALSE; - if (str[strlen(str)-1] != ' ') - needsp = TRUE; - } - anyOutput = TRUE; - free(copy); -} - - -/*====================================================================== - - prmsg() - - Print a message from the message table. - - */ -#ifdef _PROTOTYPES_ -void prmsg(MsgKind msg) /* IN - message number */ -#else -void prmsg(msg) - MsgKind msg; /* IN - message number */ -#endif -{ - interpret(msgs[msg].stms); -} - - -/*----------------------------------------------------------------------*\ - - Various check functions - - endOfTable() - isObj, isLoc, isAct, IsCnt & isNum - -\*----------------------------------------------------------------------*/ - -/* How to know we are at end of a table */ -#ifdef _PROTOTYPES_ -Boolean eot(Aword *adr) -#else -Boolean eot(adr) - Aword *adr; -#endif -{ - return *adr == EOF; -} - - -#ifdef _PROTOTYPES_ -Boolean isObj(Aword x) -#else -Boolean isObj(x) - Aword x; -#endif -{ - return x >= OBJMIN && x <= OBJMAX; -} - -#ifdef _PROTOTYPES_ -Boolean isCnt(Aword x) -#else -Boolean isCnt(x) - Aword x; -#endif -{ - return (x >= CNTMIN && x <= CNTMAX) || - (isObj(x) && objs[x-OBJMIN].cont != 0) || - (isAct(x) && acts[x-ACTMIN].cont != 0); -} - -#ifdef _PROTOTYPES_ -Boolean isAct(Aword x) -#else -Boolean isAct(x) - Aword x; -#endif -{ - return x >= ACTMIN && x <= ACTMAX; -} - -#ifdef _PROTOTYPES_ -Boolean isLoc(Aword x) -#else -Boolean isLoc(x) - Aword x; -#endif -{ - return x >= LOCMIN && x <= LOCMAX; -} - -#ifdef _PROTOTYPES_ -Boolean isNum(Aword x) -#else -Boolean isNum(x) - Aword x; -#endif -{ - return x >= LITMIN && x <= LITMAX && litValues[x-LITMIN].type == TYPNUM; -} - -#ifdef _PROTOTYPES_ -Boolean isStr(Aword x) -#else -Boolean isStr(x) - Aword x; -#endif -{ - return x >= LITMIN && x <= LITMAX && litValues[x-LITMIN].type == TYPSTR; -} - -#ifdef _PROTOTYPES_ -Boolean isLit(Aword x) -#else -Boolean isLit(x) - Aword x; -#endif -{ - return x >= LITMIN && x <= LITMAX; -} - - - -/*====================================================================== - - exitto() - - Is there an exit from one location to another? - - */ -#ifdef _PROTOTYPES_ -Boolean exitto(int to, int from) -#else -Boolean exitto(to, from) - int to, from; -#endif -{ - ExtElem *ext; - - if (locs[from-LOCMIN].exts == 0) - return(FALSE); /* No exits */ - - for (ext = (ExtElem *) addrTo(locs[from-LOCMIN].exts); !endOfTable(ext); ext++) - if (ext->next == to) - return(TRUE); - - return(FALSE); -} - - - -#ifdef CHECKOBJ -/*====================================================================== - - checkobj() - - Check that the object given is valid, else print an error message - or find out what he wanted. - - This routine is not used any longer, kept for sentimental reasons ;-) - - */ -void checkobj(obj) - Aword *obj; -{ - Aword oldobj; - - if (*obj != EOF) - return; - - oldobj = EOF; - for (cur.obj = OBJMIN; cur.obj <= OBJMAX; cur.obj++) { - /* If an object is present and it is possible to perform his action */ - if (isHere(cur.obj) && possible()) - if (oldobj == EOF) - oldobj = cur.obj; - else - error(WANT); /* And we didn't find multiple objects */ - } - - if (oldobj == EOF) - error(WANT); /* But we found ONE */ - - *obj = cur.obj = oldobj; - output("($o)"); /* Then he surely meant this object */ -} -#endif - - - - -/*---------------------------------------------------------------------- - count() - - Count the number of items in a container. - - */ -#ifdef _PROTOTYPES_ -static int count(int cnt) /* IN - the container to count */ -#else -static int count(cnt) - int cnt; /* IN - the container to count */ -#endif -{ - int i, j = 0; - - for (i = OBJMIN; i <= OBJMAX; i++) - if (in(i, cnt)) - /* Then it's in this container also */ - j++; - return(j); -} - - - -/*---------------------------------------------------------------------- - sumatr() - - Sum the values of one attribute in a container. Recursively. - - */ -#ifdef _PROTOTYPES_ -static int sumatr( - Aword atr, /* IN - the attribute to sum over */ - Aword cnt /* IN - the container to sum */ -) -#else -static int sumatr(atr, cnt) - Aword atr; /* IN - the attribute to sum over */ - Aword cnt; /* IN - the container to sum */ -#endif -{ - int i; - int sum = 0; - - for (i = OBJMIN; i <= OBJMAX; i++) - if (objs[i-OBJMIN].loc == cnt) { /* Then it's in this container */ - if (objs[i-OBJMIN].cont != 0) /* This is also a container! */ - sum = sum + sumatr(atr, i); - sum = sum + attribute(i, atr); - } - return(sum); -} - - - - -/*====================================================================== - checklim() - - Checks if a limit for a container is exceeded. - - */ -#ifdef _PROTOTYPES_ -Boolean checklim( - Aword cnt, /* IN - Container code */ - Aword obj /* IN - The object to add */ -) -#else -Boolean checklim(cnt, obj) - Aword cnt; /* IN - Container code */ - Aword obj; /* IN - The object to add */ -#endif -{ - LimElem *lim; - Aword props; - - fail = TRUE; - if (!isCnt(cnt)) - syserr("Checking limits for a non-container."); - - /* Find the container properties */ - if (isObj(cnt)) - props = objs[cnt-OBJMIN].cont; - else if (isAct(cnt)) - props = acts[cnt-ACTMIN].cont; - else - props = cnt; - - if (cnts[props-CNTMIN].lims != 0) { /* Any limits at all? */ - for (lim = (LimElem *) addrTo(cnts[props-CNTMIN].lims); !endOfTable(lim); lim++) - if (lim->atr == 0) { - if (count(cnt) >= lim->val) { - interpret(lim->stms); - return(TRUE); /* Limit check failed */ - } - } else { - if (sumatr(lim->atr, cnt) + attribute(obj, lim->atr) > lim->val) { - interpret(lim->stms); - return(TRUE); - } - } - } - fail = FALSE; - return(FALSE); -} - - - - - -/*----------------------------------------------------------------------*\ - - Action routines - -\*----------------------------------------------------------------------*/ - - - -/*---------------------------------------------------------------------- - trycheck() - - Tries a check, returns TRUE if it passed, FALSE else. - - */ -#ifdef _PROTOTYPES_ -static Boolean trycheck( - Aaddr adr, /* IN - ACODE address to check table */ - Boolean act /* IN - Act if it fails ? */ -) -#else -static Boolean trycheck(adr, act) - Aaddr adr; /* IN - ACODE address to check table */ - Boolean act; /* IN - Act if it fails ? */ -#endif -{ - ChkElem *chk; - - chk = (ChkElem *) addrTo(adr); - if (chk->exp == 0) { - interpret(chk->stms); - return(FALSE); - } else { - while (!endOfTable(chk)) { - interpret(chk->exp); - if (!(Abool)pop()) { - if (act) - interpret(chk->stms); - return(FALSE); - } - chk++; - } - return(TRUE); - } -} - - -/*====================================================================== - go() - - Move hero in a direction. - - */ -#ifdef _PROTOTYPES_ -void go(int dir) -#else -void go(dir) - int dir; -#endif -{ - ExtElem *ext; - Boolean ok; - Aword oldloc; - - ext = (ExtElem *) addrTo(locs[cur.loc-LOCMIN].exts); - if (locs[cur.loc-LOCMIN].exts != 0) - while (!endOfTable(ext)) { - if (ext->code == dir) { - ok = TRUE; - if (ext->checks != 0) { - if (trcflg) { - printf("\n\n"); - } - ok = trycheck(ext->checks, TRUE); - } - if (ok) { - oldloc = cur.loc; - if (ext->action != 0) { - if (trcflg) { - printf("\n\n"); - } - interpret(ext->action); - } - /* Still at the same place? */ - if (where(HERO) == oldloc) { - if (trcflg) { - printf("\n\n"); - } - locate(HERO, ext->next); - } - } - return; - } - ext++; - } - error(M_NO_WAY); -} - - - -/*---------------------------------------------------------------------- - - findalt() - - Find the verb alternative wanted in a verb list and return - the address to it. - - */ -#ifdef _PROTOTYPES_ -static AltElem *findalt( - Aword vrbsadr, /* IN - Address to start of list */ - Aword param /* IN - Which parameter to match */ -) -#else -static AltElem *findalt(vrbsadr, param) - Aword vrbsadr; /* IN - Address to start of list */ - Aword param; /* IN - Which parameter to match */ -#endif -{ - VrbElem *vrb; - AltElem *alt; - - if (vrbsadr == 0) - return(NULL); - - for (vrb = (VrbElem *) addrTo(vrbsadr); !endOfTable(vrb); vrb++) - if (vrb->code == cur.vrb) { - for (alt = (AltElem *) addrTo(vrb->alts); !endOfTable(alt); alt++) - if (alt->param == param || alt->param == 0) - return alt; - return NULL; - } - return NULL; -} - - - - -/*====================================================================== - - possible() - - Check if current action is possible according to the CHECKs. - - */ -#ifdef _PROTOTYPES_ -Boolean possible(void) -#else -Boolean possible() -#endif -{ - AltElem *alt[MAXPARAMS+2]; /* List of alt-pointers, one for each param */ - int i; /* Parameter index */ - - fail = FALSE; - alt[0] = findalt(header->vrbs, 0); - /* Perform global checks */ - if (alt[0] != 0 && alt[0]->checks != 0) { - if (!trycheck(alt[0]->checks, FALSE)) return FALSE; - if (fail) return FALSE; - } - - /* Now CHECKs in this location */ - alt[1] = findalt(locs[cur.loc-LOCMIN].vrbs, 0); - if (alt[1] != 0 && alt[1]->checks != 0) - if (!trycheck(alt[1]->checks, FALSE)) - return FALSE; - - for (i = 0; params[i].code != EOF; i++) { - alt[i+2] = findalt(objs[params[i].code-OBJMIN].vrbs, i+1); - /* CHECKs in a possible parameter */ - if (alt[i+2] != 0 && alt[i+2]->checks != 0) - if (!trycheck(alt[i+2]->checks, FALSE)) - return FALSE; - } - - for (i = 0; i < 2 || params[i-2].code != EOF; i++) - if (alt[i] != 0 && alt[i]->action != 0) - break; - if (i >= 2 && params[i-2].code == EOF) - /* Didn't find any code for this verb/object combination */ - return FALSE; - else - return TRUE; -} - - - -/*---------------------------------------------------------------------- - - do_it() - - Execute the action commanded by hero. - - */ -#ifdef _PROTOTYPES_ -static void do_it(void) -#else -static void do_it() -#endif -{ - AltElem *alt[MAXPARAMS+2]; /* List of alt-pointers, one for each param */ - Boolean done[MAXPARAMS+2]; /* Is it done */ - int i; /* Parameter index */ - char trace[80]; /* Trace string buffer */ - - fail = FALSE; - alt[0] = findalt(header->vrbs, 0); - /* Perform global checks */ - if (alt[0] != 0 && alt[0]->checks != 0) { - if (trcflg) - printf("\n\n", cur.vrb); - if (!trycheck(alt[0]->checks, TRUE)) return; - if (fail) return; - } - - /* Now CHECKs in this location */ - alt[1] = findalt(locs[cur.loc-LOCMIN].vrbs, 0); - if (alt[1] != 0 && alt[1]->checks != 0) { - if (trcflg) - printf("\n\n", cur.vrb); - if (!trycheck(alt[1]->checks, TRUE)) return; - if (fail) return; - } - - for (i = 0; params[i].code != EOF; i++) { - if (isLit(params[i].code)) - alt[i+2] = 0; - else { - if (isObj(params[i].code)) - alt[i+2] = findalt(objs[params[i].code-OBJMIN].vrbs, i+1); - else if (isAct(params[i].code)) - alt[i+2] = findalt(acts[params[i].code-ACTMIN].vrbs, i+1); - else - syserr("Illegal parameter type."); - /* CHECKs in the parameters */ - if (alt[i+2] != 0 && alt[i+2]->checks != 0) { - if (trcflg) - printf("\n\n", cur.vrb, i); - if (!trycheck(alt[i+2]->checks, TRUE)) return; - if (fail) return; - } - } - } - - /* Check for anything to execute... */ - for (i = 0; i < 2 || params[i-2].code != EOF; i++) - if (alt[i] != 0 && alt[i]->action != 0) - break; - if (i >= 2 && params[i-2].code == EOF) - /* Didn't find any code for this verb/object combination */ - error(M_CANT0); - - /* Perform actions! */ - - /* First try any BEFORE or ONLY from outside in */ - done[0] = FALSE; - done[1] = FALSE; - for (i = 2; params[i-2].code != EOF; i++) - done[i] = FALSE; - i--; - while (i >= 0) { - if (alt[i] != 0) - if (alt[i]->qual == (Aword)Q_BEFORE || alt[i]->qual == (Aword)Q_ONLY) { - if (alt[i]->action != 0) { - if (trcflg) { - if (i == 0) - strcpy(trace, "GLOBAL"); - else if (i == 1) - strcpy(trace, "in LOCATION"); - else - sprintf(trace, "in PARAMETER %d", i-1); - if (alt[i]->qual == (Aword)Q_BEFORE) - printf("\n\n", cur.vrb, trace); - else - printf("\n\n", cur.vrb, trace); - } - interpret(alt[i]->action); - if (fail) return; - if (alt[i]->qual == (Aword)Q_ONLY) return; - } - done[i] = TRUE; - } - i--; - } - - /* Then execute any not declared as AFTER, i.e. the default */ - for (i = 0; i < 2 || params[i-2].code != EOF; i++) { - if (alt[i] != 0) - if (alt[i]->qual != (Aword)Q_AFTER) { - if (!done[i] && alt[i]->action != 0) { - if (trcflg) { - if (i == 0) - strcpy(trace, "GLOBAL"); - else if (i == 1) - strcpy(trace, "in LOCATION"); - else - sprintf(trace, "in PARAMETER %d", i-1); - printf("\n\n", cur.vrb, trace); - } - interpret(alt[i]->action); - if (fail) return; - } - done[i] = TRUE; - } - } - - /* Finally, the ones declared as after */ - i--; - while (i >= 0) { - if (alt[i] != 0) - if (!done[i] && alt[i]->action != 0) { - if (trcflg) { - if (i == 0) - strcpy(trace, "GLOBAL"); - else if (i == 1) - strcpy(trace, "in LOCATION"); - else - sprintf(trace, "in PARAMETER %d", i-1); - printf("\n\n", cur.vrb, trace); - } - interpret(alt[i]->action); - if (fail) return; - } - i--; - } -} - - - -/*====================================================================== - - action() - - Execute all activities commanded. Handles possible multiple actions - such as THEM or lists of objects. - - */ -#ifdef _PROTOTYPES_ -void action( - ParamElem plst[] /* IN - Plural parameter list */ -) -#else -void action(plst) - ParamElem plst[]; -#endif -{ - int i, mpos; - char marker[10]; - - if (plural) { - /* - The code == 0 means this is a multiple position. We must loop - over this position (and replace it by each present in the plst) - */ - for (mpos = 0; params[mpos].code != 0; mpos++); /* Find multiple position */ - sprintf(marker, "($%d)", mpos+1); /* Prepare a printout with $1/2/3 */ - for (i = 0; plst[i].code != EOF; i++) { - params[mpos] = plst[i]; - output(marker); - do_it(); - if (plst[i+1].code != EOF) - para(); - } - params[mpos].code = 0; - } else - do_it(); -} - - - -/*----------------------------------------------------------------------*\ - - Event Handling - - eventchk() - -\*----------------------------------------------------------------------*/ - - -/*---------------------------------------------------------------------- - eventchk() - - Check if any events are pending. If so execute them. - */ -#ifdef _PROTOTYPES_ -static void eventchk(void) -#else -static void eventchk() -#endif -{ - while (etop != 0 && eventq[etop-1].time == cur.tick) { - etop--; - if (isLoc(eventq[etop].where)) - cur.loc = eventq[etop].where; - else - cur.loc = where(eventq[etop].where); - if (trcflg) { - printf("\n\n"); - } - interpret(evts[eventq[etop].event-EVTMIN].code); - } -} - - - - - -/*----------------------------------------------------------------------*\ - - Main program and initialisation - - codfil - filenames - - checkvers() - load() - checkdebug() - initheader() - initstrings() - start() - init() - -\*----------------------------------------------------------------------*/ - - -static FILE *codfil; -static char codfnm[256] = ""; -static char txtfnm[256] = ""; -static char logfnm[256] = ""; - - -/*---------------------------------------------------------------------- - - checkvers() - - */ -#ifdef _PROTOTYPES_ -static void checkvers(AcdHdr *header) -#else -static void checkvers(header) - AcdHdr *header; -#endif -{ - char vers[4]; - char state[2]; - - /* Construct our own version */ - vers[0] = alan.version.version; - vers[1] = alan.version.revision; - - /* Check version of .ACD file */ - if (dbgflg) { - state[0] = header->vers[3]; - state[1] = '\0'; - printf("", - advnam, - (int)(header->vers[0]), - (int)(header->vers[1]), - (int)(header->vers[2]), - (header->vers[3])==0? "": state); - newline(); - } - - /* Compatible if version and revision match... */ - if (strncmp(header->vers, vers, 2) != 0) { -#ifdef V25COMPATIBLE - if (header->vers[0] == 2 && header->vers[1] == 5) /* Check for 2.5 version */ - /* This we can convert later if needed... */; - else -#endif -#ifdef V27COMPATIBLE - if (header->vers[0] == 2 && header->vers[1] == 7) /* Check for 2.7 version */ - /* This we can convert later if needed... */; - else -#endif - if (errflg) { - char str[80]; - sprintf(str, "Incompatible version of ACODE program. Game is %ld.%ld, interpreter %ld.%ld.", - (int)(header->vers[0]), - (int)(header->vers[1]), - alan.version.version, - alan.version.revision); - syserr(str); - } else - output("\n"); - } -} - - -/*---------------------------------------------------------------------- - - load() - - */ -#ifdef _PROTOTYPES_ -static void load(void) -#else -static void load() -#endif -{ - AcdHdr tmphdr; - Aword crc = 0; - int i; - char err[100]; - - rewind(codfil); - fread(&tmphdr, sizeof(tmphdr), 1, codfil); - rewind(codfil); - checkvers(&tmphdr); - - /* Allocate and load memory */ - -#ifdef REVERSED - reverseHdr(&tmphdr); -#endif - - /* No memory allocated yet? */ - if (memory == NULL) { -#ifdef V25COMPATIBLE - if (tmphdr.vers[0] == 2 && tmphdr.vers[1] == 5) - /* We need some more memory to expand 2.5 format*/ - memory = allocate((tmphdr.size+tmphdr.objmax-tmphdr.objmin+1+2)*sizeof(Aword)); - else -#endif - memory = allocate(tmphdr.size*sizeof(Aword)); - } - header = (AcdHdr *) addrTo(0); - - memTop = fread(addrTo(0), sizeof(Aword), tmphdr.size, codfil); - if (memTop != tmphdr.size) - syserr("Could not read all ACD code."); - - /* Calculate checksum */ - for (i = sizeof(tmphdr)/sizeof(Aword); i < memTop; i++) { - crc += memory[i]&0xff; - crc += (memory[i]>>8)&0xff; - crc += (memory[i]>>16)&0xff; - crc += (memory[i]>>24)&0xff; -#ifdef CRCLOG - printf("%6x\t%6lx\t%6lx\n", i, crc, memory[i]); -#endif - } - if (crc != tmphdr.acdcrc) { - sprintf(err, "Checksum error in .ACD file (0x%lx instead of 0x%lx).", - crc, tmphdr.acdcrc); - if (errflg) - syserr(err); - else { - output("$n"); - } - } - -#ifdef REVERSED - if (dbgflg||trcflg||stpflg) - output("$n"); -#endif - -#ifdef V25COMPATIBLE - /* Check for 2.5 version */ - if (tmphdr.vers[0] == 2 && tmphdr.vers[1] == 5) { - if (dbgflg||trcflg||stpflg) - output("$n"); - } -#endif - -} - - -/*---------------------------------------------------------------------- - - checkdebug() - - */ -#ifdef _PROTOTYPES_ -static void checkdebug(void) -#else -static void checkdebug() -#endif -{ - /* Make sure he can't debug if not allowed! */ - if (!header->debug) { - if (dbgflg|trcflg|stpflg) - printf("\n", advnam); - para(); - dbgflg = FALSE; - trcflg = FALSE; - stpflg = FALSE; - } - - if (dbgflg) /* If debugging */ - srand(0); /* use no randomization */ - else - srand(time(0)); /* seed random generator */ -} - - -/*---------------------------------------------------------------------- - - initheader() - - */ -#ifdef _PROTOTYPES_ -static void initheader(void) -#else -static void initheader() -#endif -{ - dict = (WrdElem *) addrTo(header->dict); - /* Find out number of entries in dictionary */ - for (dictsize = 0; !endOfTable(&dict[dictsize]); dictsize++); - vrbs = (VrbElem *) addrTo(header->vrbs); - stxs = (StxElem *) addrTo(header->stxs); - locs = (LocElem *) addrTo(header->locs); - acts = (ActElem *) addrTo(header->acts); - objs = (ObjElem *) addrTo(header->objs); - evts = (EvtElem *) addrTo(header->evts); - cnts = (CntElem *) addrTo(header->cnts); - ruls = (RulElem *) addrTo(header->ruls); - msgs = (MsgElem *) addrTo(header->msgs); - scores = (Aword *) addrTo(header->scores); - - if (header->pack) - freq = (Aword *) addrTo(header->freq); -} - - -/*---------------------------------------------------------------------- - - initstrings() - - */ -#ifdef _PROTOTYPES_ -static void initstrings(void) -#else -static void initstrings() -#endif -{ - IniElem *init; - - for (init = (IniElem *) addrTo(header->init); !endOfTable(init); init++) { - getstr(init->fpos, init->len); - memory[init->adr] = pop(); - } -} - - -/*---------------------------------------------------------------------- - - start() - - */ -#ifdef _PROTOTYPES_ -static void start(void) -#else -static void start() -#endif -{ - int startloc; - - cur.tick = -1; - cur.loc = startloc = where(HERO); - cur.act = HERO; - cur.score = 0; - if (trcflg) - printf("\n\n"); - interpret(header->start); - para(); - - acts[HERO-ACTMIN].loc = 0; - locate(HERO, startloc); -} - - - -/*---------------------------------------------------------------------- - init() - - Initialization, program load etc. - - */ -#ifdef _PROTOTYPES_ -static void init(void) -#else -static void init() -#endif -{ - int i; - - /* Initialise some status */ - etop = 0; /* No pending events */ - looking = FALSE; /* Not looking now */ - dscrstkp = 0; /* No describe in progress */ - - load(); - - initheader(); - checkdebug(); - - /* Initialise string attributes */ - initstrings(); - - getPageSize(); - - /* Find first conjunction and use that for ',' handling */ - for (i = 0; i < dictsize; i++) - if (isConj(i)) { - conjWord = i; - break; - } - - /* Start the adventure */ - clear(); - start(); -} - - - -/*---------------------------------------------------------------------- - movactor() - - Let the current actor move. If player, ask him. - - */ -#ifdef _PROTOTYPES_ -static void movactor(void) -#else -static void movactor() -#endif -{ - ScrElem *scr; - StepElem *step; - ActElem *act = (ActElem *) &acts[cur.act-ACTMIN]; - - cur.loc = where(cur.act); - if (cur.act == HERO) { - parse(); - fail = FALSE; /* fail only aborts one actor */ - rules(); - } else if (act->script != 0) { - for (scr = (ScrElem *) addrTo(act->scradr); !endOfTable(scr); scr++) - if (scr->code == act->script) { - /* Find correct step in the list by indexing */ - step = (StepElem *) addrTo(scr->steps); - step = (StepElem *) &step[act->step]; - /* Now execute it, maybe. First check wait count */ - if (step->after > act->count) { - /* Wait some more */ - if (trcflg) { - printf("\n\n", - act->script, act->step+1, step->after-act->count); - } - act->count++; - rules(); - return; - } else - act->count = 0; - /* Then check possible expression */ - if (step->exp != 0) { - if (trcflg) { - printf("\n\n", - act->script, act->step+1); - } - interpret(step->exp); - if (!(Abool)pop()) { - rules(); - return; /* Hadn't happened yet */ - } - } - /* OK, so finally let him do his thing */ - act->step++; /* Increment step number before executing... */ - if (trcflg) { - printf("\n\n", - act->script, act->step); - } - interpret(step->stm); - step++; - /* ... so that we can see if he is USEing another script now */ - if (act->step != 0 && endOfTable(step)) - /* No more steps in this script, so stop him */ - act->script = 0; - fail = FALSE; /* fail only aborts one actor */ - rules(); - return; - } - syserr("Unknown actor script."); - } else if (trcflg) { - printf("\n\n"); - rules(); - return; - } -} - -/*---------------------------------------------------------------------- - - openFiles() - - Open the necessary files. - - */ -#ifdef _PROTOTYPES_ -static void openFiles(void) -#else -static void openFiles() -#endif -{ - char str[256]; - char *usr = ""; - time_t tick; - - /* Open Acode file */ - strcpy(codfnm, advnam); - strcat(codfnm, ".acd"); - if ((codfil = fopen(codfnm, READ_MODE)) == NULL) { - strcpy(str, "Can't open adventure code file '"); - strcat(str, codfnm); - strcat(str, "'."); - syserr(str); - } - - /* Open Text file */ - strcpy(txtfnm, advnam); - strcat(txtfnm, ".dat"); - if ((txtfil = fopen(txtfnm, READ_MODE)) == NULL) { - strcpy(str, "Can't open adventure text data file '"); - strcat(str, txtfnm); - strcat(str, "'."); - syserr(str); - } - - /* If logging open log file */ - if (logflg) { - char *namstart; - - if((namstart = strrchr(advnam, ']')) == NULL - && (namstart = strrchr(advnam, '>')) == NULL - && (namstart = strrchr(advnam, '/')) == NULL - && (namstart = strrchr(advnam, '\\')) == NULL - && (namstart = strrchr(advnam, ':')) == NULL) - namstart = &advnam[0]; - else - namstart++; - - time(&tick); - sprintf(logfnm, "%s%d%s.log", namstart, (int)tick, usr); - if ((logfil = fopen(logfnm, "w")) == NULL) - logflg = FALSE; - } -} - - -/*====================================================================== - - run() - - Run the adventure - - */ -void run(void) -{ - openFiles(); - - setjmp(restart_label); /* Return here if he wanted to restart */ - - init(); /* Load, initialise and start the adventure */ - - while (TRUE) { -#ifdef MALLOC - if (malloc_verify() == 0) syserr("Error in heap."); -#endif - if (dbgflg) - debug(); - - eventchk(); - cur.tick++; - (void) setjmp(jmpbuf); - - /* Move all characters */ - for (cur.act = ACTMIN; cur.act <= ACTMAX; cur.act++) - movactor(); - } -} - diff --git a/app/src/main/jni/terps/alan/alan2/main.h b/app/src/main/jni/terps/alan/alan2/main.h deleted file mode 100755 index 5813bbc..0000000 --- a/app/src/main/jni/terps/alan/alan2/main.h +++ /dev/null @@ -1,121 +0,0 @@ -#ifndef _MAIN_H_ -#define _MAIN_H_ -/*----------------------------------------------------------------------*\ - - MAIN.H - - Header file for main unit of ARUN Alan System interpreter - -\*----------------------------------------------------------------------*/ - -#include "types.h" -#include - - -/* DATA */ - -#define MEMORYSIZE 1000L - -extern int memTop; /* Top of memory */ - -extern int conjWord; /* First conjunction in dictionary */ - -/* The Amachine memory */ -extern Aword *memory; -extern AcdHdr *header; - -/* Amachine variables */ -extern CurVars cur; - -/* Amachine data structures */ -extern WrdElem *dict; /* Dictionary pointer */ -extern ActElem *acts; /* Actor table pointer */ -extern LocElem *locs; /* Location table pointer */ -extern VrbElem *vrbs; /* Verb table pointer */ -extern StxElem *stxs; /* Syntax table pointer */ -extern ObjElem *objs; /* Object table pointer */ -extern CntElem *cnts; /* Container table pointer */ -extern RulElem *ruls; /* Rule table pointer */ -extern EvtElem *evts; /* Event table pointer */ -extern MsgElem *msgs; /* Message table pointer */ -extern Aword *scores; /* Score table pointer */ -extern Aword *freq; /* Cumulated frequencies */ - -extern int dictsize; /* Number of entries in dictionary */ - -/* The text and message file */ -extern FILE *txtfil; -extern FILE *logfil; - -/* File names */ -extern char *advnam; - -/* Screen formatting info */ -extern int col, lin; -extern int paglen, pagwidth; - -/* Long jump buffer for restart */ -extern jmp_buf restart_label; - -extern Boolean verbose, errflg, trcflg, dbgflg, stpflg, logflg, statusflg; -extern Boolean fail; -extern Boolean anyOutput; -extern Boolean needsp; - -#define endOfTable(x) eot((Aword *) x) - - -#ifdef _PROTOTYPES_ -extern void *allocate(unsigned long len); -extern void terminate(int code); -extern void usage(void); -extern void error(MsgKind msg); -extern void syserr(char *msg); -extern void statusline(void); -extern void output(char string[]); -extern void prmsg(MsgKind msg); -extern void para(void); -extern void newline(void); - -extern Boolean checklim(Aword cnt, Aword obj); -extern Boolean possible(void); -extern Boolean exitto(int to, int from); -extern void action(ParamElem *plst); -extern void go(int dir); - -extern Boolean eot(Aword *adr); -extern Boolean isObj(Aword x); -extern Boolean isCnt(Aword x); -extern Boolean isAct(Aword x); -extern Boolean isLoc(Aword x); -extern Boolean isLit(Aword x); -extern Boolean isNum(Aword x); -extern Boolean isStr(Aword x); - -/* Run the game! */ -extern void run(void); - -#else -extern void *allocate(); -extern void terminate(); -extern void syserr(); -extern void usage(); -extern void error(); -extern void output(); -extern void statusline(); -extern void prmsg(); -extern void print(); -extern void para(); -extern void newline(); -extern Boolean checklim(); -extern Boolean possible(); -extern Boolean eot(); -extern Boolean isObj(); -extern Boolean isCnt(); -extern Boolean isAct(); -extern Boolean isLoc(); -extern Boolean isLit(); -extern void run(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/params.c b/app/src/main/jni/terps/alan/alan2/params.c deleted file mode 100755 index c849051..0000000 --- a/app/src/main/jni/terps/alan/alan2/params.c +++ /dev/null @@ -1,151 +0,0 @@ -/*----------------------------------------------------------------------*\ - - params.c - - Various utility functions for handling parameters: - - compress() Compact a list, i.e remove any NULL elements - lstlen() Count number of elements - inlst() Check if an element is in the list - sublst() Subract two lists - lstcpy() Copy one list onto another - mrglst() Merge the paramElems of one list into the first - isect() Take the intersection of two lists - cpyrefs() Copy the refs (in dictionary) to a paramList - -\*----------------------------------------------------------------------*/ - -#include "types.h" - -#include "params.h" - - -#ifdef _PROTOTYPES_ -void compress(ParamElem a[]) -#else -void compress(a) - ParamElem a[]; -#endif -{ - int i, j; - - for (i = 0, j = 0; a[j].code != EOF; j++) - if (a[j].code != 0) - a[i++] = a[j]; - a[i].code = EOF; -} - - -#ifdef _PROTOTYPES_ -int lstlen(ParamElem a[]) -#else -int lstlen(a) - ParamElem a[]; -#endif -{ - int i = 0; - - while (a[i].code != EOF) - i++; - return (i); -} - - -#ifdef _PROTOTYPES_ -Boolean inlst(ParamElem l[], Aword e) -#else -Boolean inlst(l, e) - ParamElem l[]; - Aword e; -#endif -{ - int i; - - for (i = 0; l[i].code != EOF && l[i].code != e; i++); - return (l[i].code == e); -} - - -#ifdef _PROTOTYPES_ -void lstcpy(ParamElem a[], ParamElem b[]) -#else -void lstcpy(a, b) - ParamElem a[], b[]; -#endif -{ - int i; - - for (i = 0; b[i].code != EOF; i++) - a[i] = b[i]; - a[i].code = EOF; -} - - -#ifdef _PROTOTYPES_ -void sublst(ParamElem a[], ParamElem b[]) -#else -void sublst(a, b) - ParamElem a[], b[]; -#endif -{ - int i; - - for (i = 0; a[i].code != EOF; i++) - if (inlst(b, a[i].code)) - a[i].code = 0; /* Mark empty */ - compress(a); -} - - -#ifdef _PROTOTYPES_ -void mrglst(ParamElem a[], ParamElem b[]) -#else -void mrglst(a, b) - ParamElem a[], b[]; -#endif -{ - int i,last; - - for (last = 0; a[last].code != EOF; last++); /* Find end of list */ - for (i = 0; b[i].code != EOF; i++) - if (!inlst(a, b[i].code)) { - a[last++] = b[i]; - a[last].code = EOF; - } -} - - -#ifdef _PROTOTYPES_ -void isect(ParamElem a[], ParamElem b[]) -#else -void isect(a, b) - ParamElem a[], b[]; -#endif -{ - int i, last = 0; - - for (i = 0; a[i].code != EOF; i++) - if (inlst(b, a[i].code)) - a[last++] = a[i]; - a[last].code = EOF; -} - - -#ifdef _PROTOTYPES_ -void cpyrefs(ParamElem p[], Aword r[]) -#else -void cpyrefs(p, r) - ParamElem p[]; - Aword r[]; -#endif -{ - int i; - - for (i = 0; r[i] != EOF; i++) { - p[i].code = r[i]; - p[i].firstWord = EOF; - } - p[i].code = EOF; -} - - diff --git a/app/src/main/jni/terps/alan/alan2/params.h b/app/src/main/jni/terps/alan/alan2/params.h deleted file mode 100755 index 5f32213..0000000 --- a/app/src/main/jni/terps/alan/alan2/params.h +++ /dev/null @@ -1,32 +0,0 @@ -/*----------------------------------------------------------------------*\ - - params.h - - Various utility functions for handling parameters - -\*----------------------------------------------------------------------*/ -#ifndef PARAMS_H -#include "types.h" - - -#ifdef _PROTOTYPES_ -extern void compress(ParamElem *a); -extern int lstlen(ParamElem *a); -extern Boolean inlst(ParamElem *l, Aword e); -extern void lstcpy(ParamElem *a, ParamElem *b); -extern void sublst(ParamElem *a, ParamElem *b); -extern void mrglst(ParamElem *a, ParamElem *b); -extern void isect(ParamElem *a, ParamElem *b); -extern void cpyrefs(ParamElem *p, Aword *r); -#else -extern void compress(); -extern int lstlen(); -extern Boolean inlst(); -extern void lstcpy(); -extern void sublst(); -extern void mrglst(); -extern void isect(); -extern void cpyrefs(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/parse.c b/app/src/main/jni/terps/alan/alan2/parse.c deleted file mode 100755 index c269cd7..0000000 --- a/app/src/main/jni/terps/alan/alan2/parse.c +++ /dev/null @@ -1,829 +0,0 @@ -/*----------------------------------------------------------------------*\ - - parse.c - - Command line parser unit for Alan interpreter ARUN - -\*----------------------------------------------------------------------*/ - -#include -#include - -#include "types.h" - -#ifdef USE_READLINE -#include "readline.h" -#endif - -#include "main.h" -#include "inter.h" -#include "exe.h" -#include "term.h" -#include "debug.h" -#include "params.h" - -#include "parse.h" - -#ifdef GLK -#include "glkio.h" -#endif - - -#define LISTLEN 100 - - -/* PUBLIC DATA */ - -int wrds[LISTLEN/2] = {EOF}; /* List of parsed words */ -int wrdidx; /* and an index into it */ - -Boolean plural = FALSE; - - -/* Syntax Parameters */ -int paramidx; /* Index in params */ -ParamElem *params; /* List of params */ -static ParamElem *pparams; /* Previous parameter list */ -static ParamElem *mlst; /* Multiple objects list */ -static ParamElem *pmlst; /* Previous multiple list */ - -/* Literals */ -LitElem litValues[MAXPARAMS+1]; -int litCount; - -/* What did the user say? */ -int vrbwrd; /* The word he used */ -int vrbcode; /* The code for that verb */ - - -/*----------------------------------------------------------------------*\ - - SCAN DATA & PROCEDURES - - All procedures for getting a command and turning it into a list of - dictionary entries are placed here. - - buf - unknown() - lookup() - token - getLine() - scan() - -\*----------------------------------------------------------------------*/ - - -/* PRIVATE DATA */ - -static char buf[LISTLEN+1]; /* The input buffer */ -static char isobuf[LISTLEN+1]; /* The input buffer in ISO */ - - -static Boolean eol = TRUE; /* Looking at End of line? Yes, initially */ - - - -#ifdef _PROTOTYPES_ -static void unknown( - char token[] -) -#else -static void unknown(token) - char token[]; -#endif -{ - char *str = allocate((int)strlen(token)+4); - - str[0] = '\''; - strcpy(&str[1], token); - strcat(str, "'?"); -#if ISO == 0 - fromIso(str, str); -#endif - output(str); - free(str); - eol = TRUE; - error(M_UNKNOWN_WORD); -} - - - -static char *token; - - -#ifdef _PROTOTYPES_ -static int lookup( - char wrd[] -) -#else -static int lookup(wrd) - char wrd[]; -#endif -{ - int i; - - for (i = 0; !endOfTable(&dict[i]); i++) { - if (strcmp(wrd, (char *) addrTo(dict[i].wrd)) == 0) - return (i); - } - unknown(wrd); - return(EOF); -} - - -#ifdef _PROTOTYPES_ -static int number( - char token[] /* IN - The string to convert to a number */ -) -#else -static int number(token) - char token[]; /* IN - The string to convert to a number */ -#endif -{ - int i; - - sscanf(token, "%d", &i); - return i; -} - -#ifdef _PROTOTYPES_ -static char *gettoken( - char *buf -) -#else -static char *gettoken(buf) - char *buf; -#endif -{ - static char *marker; - static char oldch; - - if (buf == NULL) - *marker = oldch; - else - marker = buf; - while (*marker != '\0' && isSpace(*marker) && *marker != '\n') marker++; - buf = marker; - if (isISOLetter(*marker)) - while (*marker&&(isISOLetter(*marker)||isdigit(*marker)||*marker=='\'')) marker++; - else if (isdigit(*marker)) - while (isdigit(*marker)) marker++; - else if (*marker == '\"') { - marker++; - while (*marker != '\"') marker++; - marker++; - } else if (*marker == '\0' || *marker == '\n') - return NULL; - else - marker++; - oldch = *marker; - *marker = '\0'; - return buf; -} - - -#ifdef _PROTOTYPES_ -static void getLine(void) -#else -static void getLine() -#endif -{ - para(); - do { -#if defined(HAVE_ANSI) || defined(GLK) - statusline(); -#endif - printf("> "); - if (logflg) - fprintf(logfil, "> "); -#ifdef USE_READLINE - if (!readline(buf)) { - newline(); - quit(); - } -#else - if (fgets(buf, LISTLEN, stdin) == NULL) { - newline(); - quit(); - } -#endif - getPageSize(); - anyOutput = FALSE; - if (logflg) -#ifndef __amiga__ - fprintf(logfil, "%s\n", buf); -#else - fprintf(logfil, "%s", buf); -#endif -#if ISO == 0 - toIso(isobuf, buf, NATIVECHARSET); -#else - strcpy(isobuf, buf); -#endif - token = gettoken(isobuf); - if (token != NULL && strcmp("debug", token) == 0 && header->debug) { - dbgflg = TRUE; - debug(); - token = NULL; - } - } while (token == NULL); - eol = FALSE; - lin = 1; -} - - -#ifdef _PROTOTYPES_ -static void scan(void) -#else -static void scan() -#endif -{ - int i; - int w; - char *str; - - getLine(); - wrds[0] = 0; - for (i = 0; i < litCount; i++) - if (litValues[i].type == TYPSTR && litValues[i].value != 0) - free((char *) litValues[i].value); - i = 0; - litCount = 0; - do { - if (isISOLetter(token[0])) { - (void) stringLower(token); - w = lookup(token); - if (!isNoise(w)) - wrds[i++] = w; - } else if (isdigit(token[0])) { - if (litCount > MAXPARAMS) - syserr("Too many parameters."); - wrds[i++] = dictsize+litCount; /* Word outside dictionary = literal */ - litValues[litCount].type = TYPNUM; - litValues[litCount++].value = number(token); - } else if (token[0] == '\"') { - if (litCount > MAXPARAMS) - syserr("Too many parameters."); - wrds[i++] = dictsize+litCount; /* Word outside dictionary = literal */ - litValues[litCount].type = TYPSTR; - /* Remove the string quotes while copying */ - str = strdup(&token[1]); - str[strlen(token)-2] = '\0'; - litValues[litCount++].value = (Aword) str; - } else if (token[0] == ',') { - wrds[i++] = conjWord; - } else - unknown(token); - wrds[i] = EOF; - eol = (token = gettoken(NULL)) == NULL; - } while (!eol); -} - - - -/*----------------------------------------------------------------------*\ - - PARSE DATA & PROCEDURES - - All procedures and data for getting a command and parsing it - - nonverb() - search for a non-verb command - buildall() - build a list of objects matching 'all' - unambig() - match an unambigous object reference - simple() - match a simple verb command - complex() - match a complex -"- - try() - to match a verb command - match() - find the verb class (not used currently) and 'try()' - -\*---------------------------------------------------------------------- */ - -static int allLength; /* No. of objects matching 'all' */ - - -#ifdef _PROTOTYPES_ -static void nonverb(void) -#else -static void nonverb() -#endif -{ - if (isDir(wrds[wrdidx])) { - wrdidx++; - if (wrds[wrdidx] != EOF && !isConj(wrds[wrdidx])) - error(M_WHAT); - else - go(dict[wrds[wrdidx-1]].code); - if (wrds[wrdidx] != EOF) - wrdidx++; - } else - error(M_WHAT); -} - - -#ifdef _PROTOTYPES_ -static void buildall( - ParamElem list[] -) -#else -static void buildall(list) - ParamElem list[]; -#endif -{ - int o, i = 0; - Boolean found = FALSE; - - for (o = OBJMIN; o <= OBJMAX; o++) - if (isHere(o)) { - found = TRUE; - list[i].code = o; - list[i++].firstWord = EOF; - } - if (!found) - error(M_WHAT_ALL); - else - list[i].code = EOF; -} - - -#ifdef _PROTOTYPES_ -static void unambig( - ParamElem plst[] -) -#else -static void unambig(plst) - ParamElem plst[]; -#endif -{ - int i; - Boolean found = FALSE; /* Adjective or noun found ? */ - static ParamElem *refs; /* Entities referenced by word */ - static ParamElem *savlst; /* Saved list for backup at EOF */ - int firstWord, lastWord; /* The words the player used */ - - if (refs == NULL) - refs = (ParamElem *)allocate((MAXENTITY+1)*sizeof(ParamElem)); - - if (savlst == NULL) - savlst = (ParamElem *)allocate((MAXENTITY+1)*sizeof(ParamElem)); - - if (isLiteral(wrds[wrdidx])) { - /* Transform the word into a reference to the literal value */ - plst[0].code = wrds[wrdidx++]-dictsize+LITMIN; - plst[0].firstWord = EOF; /* No words used! */ - plst[1].code = EOF; - return; - } - - plst[0].code = EOF; /* Make empty */ - if (isIt(wrds[wrdidx])) { - wrdidx++; - /* Use last object in previous command! */ - for (i = lstlen(pparams)-1; i >= 0 && (pparams[i].code == 0 || pparams[i].code >= LITMIN); i--); - if (i < 0) - error(M_WHAT_IT); - if (!isHere(pparams[i].code)) { - params[0].code = pparams[i].code; - params[0].firstWord = EOF; - params[1].code = EOF; - error(M_NO_SUCH); - } - plst[0] = pparams[i]; - plst[0].firstWord = EOF; /* No words used! */ - plst[1].code = EOF; - return; - } - - firstWord = wrdidx; - while (wrds[wrdidx] != EOF && isAdj(wrds[wrdidx])) { - /* If this word can be a noun and there is no noun following break loop */ - if (isNoun(wrds[wrdidx]) && (wrds[wrdidx+1] == EOF || !isNoun(wrds[wrdidx+1]))) - break; - cpyrefs(refs, (Aword *)addrTo(dict[wrds[wrdidx]].adjrefs)); - lstcpy(savlst, plst); /* To save it for backtracking */ - if (found) - isect(plst, refs); - else { - lstcpy(plst, refs); - found = TRUE; - } - wrdidx++; - } - if (wrds[wrdidx] != EOF) { - if (isNoun(wrds[wrdidx])) { - cpyrefs(refs, (Aword *)addrTo(dict[wrds[wrdidx]].nounrefs)); - if (found) - isect(plst, refs); - else { - lstcpy(plst, refs); - found = TRUE; - } - wrdidx++; - } else - error(M_NOUN); - } else if (found) { - if (isNoun(wrds[wrdidx-1])) { - /* Perhaps the last word was also a noun? */ - lstcpy(plst, savlst); /* Restore to before last adjective */ - cpyrefs(refs, (Aword *)addrTo(dict[wrds[wrdidx-1]].nounrefs)); - if (plst[0].code == EOF) - lstcpy(plst, refs); - else - isect(plst, refs); - } else - error(M_NOUN); - } - lastWord = wrdidx-1; - - /* Allow remote objects, but resolve ambiguities by presence */ - if (lstlen(plst) > 1) { - for (i=0; plst[i].code != EOF; i++) - if (!isHere(plst[i].code)) - plst[i].code = 0; - compress(plst); - } - - if (lstlen(plst) > 1 || (found && lstlen(plst) == 0)) { - params[0].code = 0; /* Just make it anything != EOF */ - params[0].firstWord = firstWord; /* Remember words for errors below */ - params[0].lastWord = lastWord; - params[1].code = EOF; /* But be sure to terminate */ - if (lstlen(plst) > 1) - error(M_WHICH_ONE); - else if (found && lstlen(plst) == 0) - error(M_NO_SUCH); - } else { - plst[0].firstWord = firstWord; - plst[0].lastWord = lastWord; - } -} - - -#ifdef _PROTOTYPES_ -static void simple( - ParamElem olst[] -) -#else -static void simple(olst) - ParamElem olst[]; -#endif -{ - static ParamElem *tlst = NULL; - int savidx = wrdidx; - Boolean savplur = FALSE; - int i; - - if (tlst == NULL) - tlst = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1)); - tlst[0].code = EOF; - - for (;;) { - if (isThem(wrds[wrdidx])) { - plural = TRUE; - for (i = 0; pmlst[i].code != EOF; i++) - if (!isHere(pmlst[i].code)) - pmlst[i].code = 0; - compress(pmlst); - if (lstlen(pmlst) == 0) - error(M_WHAT_THEM); - lstcpy(olst, pmlst); - olst[0].firstWord = EOF; /* No words used */ - wrdidx++; - } else { - unambig(olst); /* Look for unambigous noun phrase */ - if (lstlen(olst) == 0) { /* Failed! */ - lstcpy(olst, tlst); - wrdidx = savidx; - plural = savplur; - return; - } - } - mrglst(tlst, olst); - if (wrds[wrdidx] != EOF - && (isConj(wrds[wrdidx]) && - (isAdj(wrds[wrdidx+1]) || isNoun(wrds[wrdidx+1])))) { - /* More parameters in a conjunction separated list ? */ - savplur = plural; - savidx = wrdidx; - wrdidx++; - plural = TRUE; - } else { - lstcpy(olst, tlst); - return; - } - } -} - - -/*---------------------------------------------------------------------- - - complex() - - Above this procedure we can use the is* tests, but not below since - they work on words. Below all is converted to indices into the - entity tables. Particularly this goes for literals... - -*/ -#ifdef _PROTOTYPES_ -static void complex( - ParamElem olst[] -) -#else -static void complex(olst) - ParamElem olst[]; -#endif -{ - static ParamElem *alst = NULL; - - if (alst == NULL) - alst = (ParamElem *) allocate((MAXENTITY+1)*sizeof(ParamElem)); - - if (isAll(wrds[wrdidx])) { - plural = TRUE; - buildall(alst); /* Build list of all objects */ - wrdidx++; - if (wrds[wrdidx] != EOF && isBut(wrds[wrdidx])) { - wrdidx++; - simple(olst); - if (lstlen(olst) == 0) - error(M_AFTER_BUT); - sublst(alst, olst); - if (lstlen(alst) == 0) - error(M_NOT_MUCH); - } - lstcpy(olst, alst); - allLength = lstlen(olst); - } else - simple(olst); /* Look for simple noun group */ -} - - -#ifdef _PROTOTYPES_ -static Boolean claCheck( - ClaElem *cla /* IN - The cla elem to check */ -) -#else -static Boolean claCheck(cla) - ClaElem *cla; /* IN - The cla elem to check */ -#endif -{ - Boolean ok = FALSE; - - if ((cla->classes&(Aword)CLA_OBJ) != 0) - ok = ok || isObj(params[cla->code-1].code); - if ((cla->classes&(Aword)CLA_CNT) != 0) - ok = ok || isCnt(params[cla->code-1].code); - if ((cla->classes&(Aword)CLA_ACT) != 0) - ok = ok || isAct(params[cla->code-1].code); - if ((cla->classes&(Aword)CLA_NUM) != 0) - ok = ok || isNum(params[cla->code-1].code); - if ((cla->classes&(Aword)CLA_STR) != 0) - ok = ok || isStr(params[cla->code-1].code); - if ((cla->classes&(Aword)CLA_COBJ) != 0) - ok = ok || (isCnt(params[cla->code-1].code) && isObj(params[cla->code-1].code)); - if ((cla->classes&(Aword)CLA_CACT) != 0) - ok = ok || (isCnt(params[cla->code-1].code) && isAct(params[cla->code-1].code)); - return ok; -} - - -/*---------------------------------------------------------------------- - - resolve() - - In case the syntax did not indicate omnipotent powers (allowed - access to remote object), we need to remove non-present parameters - -*/ -static void resolve(ParamElem plst[]) -{ - int i; - - if (allLength > 0) return; /* ALL has already done this */ - - /* Resolve ambiguities by presence */ - for (i=0; plst[i].code != EOF; i++) - if (plst[i].code < LITMIN) /* Literals are always 'here' */ - if (!isHere(plst[i].code)) { - params[0] = plst[i]; /* Copy error param as first one for message */ - params[1].code = EOF; /* But be sure to terminate */ - error(M_NO_SUCH); - } -} - - -#ifdef _PROTOTYPES_ -static void try( - ParamElem mlst[] /* OUT - List of params allowed by multiple */ -) -#else -static void try(mlst) - ParamElem mlst[]; /* OUT - List of params allowed by multiple */ -#endif -{ - ElmElem *elms; /* Pointer to element list */ - StxElem *stx; /* Pointer to syntax list */ - ClaElem *cla; /* Pointer to class definitions */ - Boolean anyPlural = FALSE; /* Any parameter that was plural? */ - int i, p; - static ParamElem *tlst = NULL; /* List of params found by complex() */ - static Boolean *checked = NULL; /* Corresponding parameter checked? */ - - if (tlst == NULL) { - tlst = (ParamElem *) allocate((MAXENTITY+1)*sizeof(ParamElem)); - checked = (Boolean *) allocate((MAXENTITY+1)*sizeof(Boolean)); - } - - for (stx = stxs; !endOfTable(stx); stx++) - if (stx->code == vrbcode) - break; - if (endOfTable(stx)) - error(M_WHAT); - - elms = (ElmElem *) addrTo(stx->elms); - - while (TRUE) { - /* End of input? */ - if (wrds[wrdidx] == EOF || isConj(wrds[wrdidx])) { - while (!endOfTable(elms) && elms->code != EOS) - elms++; - if (endOfTable(elms)) - error(M_WHAT); - else - break; - } else { - /* A preposition? */ - if (isPrep(wrds[wrdidx])) { - while (!endOfTable(elms) && elms->code != dict[wrds[wrdidx]].code) - elms++; - if (endOfTable(elms)) - error(M_WHAT); - else - wrdidx++; - } else { - /* Must be a parameter! */ - while (!endOfTable(elms) && elms->code != 0) - elms++; - if (endOfTable(elms)) - error(M_WHAT); - /* Get it! */ - plural = FALSE; - complex(tlst); - if (lstlen(tlst) == 0) /* No object!? */ - error(M_WHAT); - if ((elms->flags & OMNIBIT) == 0) /* Omnipotent parameter? */ - /* If its not an omnipotent parameter, resolve by presence */ - resolve(tlst); - if (plural) { - if ((elms->flags & MULTIPLEBIT) == 0) /* Allowed multiple? */ - error(M_MULTIPLE); - else { - /* - Mark this as the multiple position in which to insert - actual parameter values later - */ - params[paramidx++].code = 0; - lstcpy(mlst, tlst); - anyPlural = TRUE; - } - } else - params[paramidx++] = tlst[0]; - params[paramidx].code = EOF; - } - elms = (ElmElem *) addrTo(elms->next); - } - } - - /* Now perform class checks */ - if (elms->next == 0) /* No verb code, verb not declared! */ - error(M_CANT0); - - for (p = 0; params[p].code != EOF; p++) /* Mark all parameters unchecked */ - checked[p] = FALSE; - for (cla = (ClaElem *) addrTo(elms->next); !endOfTable(cla); cla++) { - if (params[cla->code-1].code == 0) { - /* This was a multiple parameter, so check all and remove failing */ - for (i = 0; mlst[i].code != EOF; i++) { - params[cla->code-1] = mlst[i]; - if (!claCheck(cla)) { - /* Multiple could be both an explicit list of params and an ALL */ - if (allLength == 0) { - char marker[80]; - /* - It wasn't ALL, we need to say something about it, so - prepare a printout with $1/2/3 - */ - sprintf(marker, "($%ld)", cla->code); - output(marker); - interpret(cla->stms); - para(); - } - mlst[i].code = 0; /* In any case remove it from the list */ - } - } - params[cla->code-1].code = 0; - } else { - if (!claCheck(cla)) { - interpret(cla->stms); - error(MSGMAX); /* Return to player without saying anything */ - } - } - checked[cla->code-1] = TRUE; /* Remember that it's already checked */ - } - /* Now check the rest of the parameters, must be objects */ - for (p = 0; params[p].code != EOF; p++) - if (!checked[p]) { - if (params[p].code == 0) { - /* This was a multiple parameter, check all and remove failing */ - for (i = 0; mlst[i].code != EOF; i++) - if (mlst[i].code != 0) /* Skip any empty slots */ - if (!isObj(mlst[i].code)) - mlst[i].code = 0; - } else if (!isObj(params[p].code)) - error(M_CANT0); - } - - /* Set verb code */ - cur.vrb = ((Aword *) cla)[1]; /* Take first word after end of table! */ - - /* Finally, if ALL was used, try to find out what was applicable */ - if (allLength > 0) { - for (p = 0; params[p].code != 0; p++); /* Find multiple marker */ - for (i = 0; i < allLength; i++) { - if (mlst[i].code != 0) { /* Already empty? */ - params[p] = mlst[i]; - if (!possible()) - mlst[i].code = 0; /* Remove this from list */ - } - } - params[p].code = 0; /* Restore multiple marker */ - compress(mlst); - if (lstlen(mlst) == 0) { - params[0].code = EOF; - error(M_WHAT_ALL); - } - } else if (anyPlural) { - compress(mlst); - if (lstlen(mlst) == 0) - /* If there where multiple parameters but non left, exit without a */ - /* word, assuming we have already said enough */ - error(MSGMAX); - } - plural = anyPlural; /* Remember that we found plural objects */ -} - - -#ifdef _PROTOTYPES_ -static void match( - ParamElem *mlst /* OUT - List of params allowed by multiple */ -) -#else -static void match(mlst) - ParamElem *mlst; /* OUT - List of params allowed by multiple */ -#endif -{ - try(mlst); /* ... to understand what he said */ - if (wrds[wrdidx] != EOF && !isConj(wrds[wrdidx])) - error(M_WHAT); - if (wrds[wrdidx] != EOF) /* More on this line? */ - wrdidx++; /* If so skip the AND */ -} - - -#ifdef _PROTOTYPES_ -void parse(void) -#else -void parse() -#endif -{ - if (mlst == NULL) { /* Allocate large enough paramlists */ - mlst = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1)); - mlst[0].code = EOF; - pmlst = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1)); - params = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1)); - params[0].code = EOF; - pparams = (ParamElem *) allocate(sizeof(ParamElem)*(MAXENTITY+1)); - } - - if (wrds[wrdidx] == EOF) { - wrdidx = 0; - scan(); - } else if (anyOutput) - para(); - - allLength = 0; - paramidx = 0; - lstcpy(pparams, params); - params[0].code = EOF; - lstcpy(pmlst, mlst); - mlst[0].code = EOF; - if (isVerb(wrds[wrdidx])) { - vrbwrd = wrds[wrdidx]; - vrbcode = dict[vrbwrd].code; - wrdidx++; - match(mlst); - action(mlst); /* mlst contains possible multiple params */ - } else { - params[0].code = EOF; - pmlst[0].code = EOF; - nonverb(); - } -} diff --git a/app/src/main/jni/terps/alan/alan2/parse.h b/app/src/main/jni/terps/alan/alan2/parse.h deleted file mode 100755 index d6db560..0000000 --- a/app/src/main/jni/terps/alan/alan2/parse.h +++ /dev/null @@ -1,27 +0,0 @@ -/*----------------------------------------------------------------------*\ - - PARSE.H - - Parse data for ALAN interpreter module. - -\*----------------------------------------------------------------------*/ - -extern int wrds[]; /* List of Parsed Word */ -extern int wrdidx; /* and an index into it */ - -extern ParamElem *params; /* List of parameters */ -extern Boolean plural; - -extern LitElem litValues[]; -extern int litCount; - -extern int vrbwrd; - -#ifdef _PROTOTYPES_ - -/* Parse a new player command */ -extern void parse(void); - -#else -extern void parse(); -#endif diff --git a/app/src/main/jni/terps/alan/alan2/readline.c b/app/src/main/jni/terps/alan/alan2/readline.c deleted file mode 100755 index 12add97..0000000 --- a/app/src/main/jni/terps/alan/alan2/readline.c +++ /dev/null @@ -1,590 +0,0 @@ -/* - - Read line from user, with editing and history - - */ - -#ifdef GLK - -#include "readline.h" -#include "exe.h" -#include "main.h" -#include "glk.h" -#include "glkio.h" - -#ifdef WINGLK -#include "resources.h" -#include "WinGlk.h" - -BOOL CALLBACK AboutDialogProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) -{ - switch (message) - { - case WM_COMMAND: - switch (LOWORD(wParam)) - { - case IDOK: - EndDialog(hwndDlg, wParam); - return TRUE; - } - } - return FALSE; -} - -#endif - - -/*====================================================================== - - readline() - - Read a line from the user, with history and editing - - */ - -/* 4f - length of user buffer should be used */ -Boolean readline(char usrbuf[]) -{ - event_t event; -#ifdef WINGLK - INT_PTR e; -#endif - - glk_request_line_event(glkMainWin, usrbuf, 255, 0); - /* FIXME: buffer size should be infallible: all existing calls use 256 or - 80 character buffers, except parse which uses LISTLEN (currently 100) - */ - do - { - glk_select(&event); - switch (event.type) { - case evtype_Arrange: - statusline(); - break; -#ifdef WINGLK - case winglk_evtype_GuiInput: - switch (event.val1) { - case ID_MENU_RESTART: - restart(); - break; - case ID_MENU_SAVE: - printf("save\n"); - glk_set_style(style_Normal); - save(); - para(); - printf("> "); - break; - case ID_MENU_RESTORE: - printf("restore\n"); - glk_set_style(style_Normal); - restore(); - look(); - para(); - printf("> "); - break; - case ID_MENU_ABOUT: - e = DialogBox(NULL, MAKEINTRESOURCE(IDD_ABOUT), NULL, &AboutDialogProc); - break; - } - break; -#endif - } - } while (event.type != evtype_LineInput); - usrbuf[event.val1] = 0; - return TRUE; -} - -#else - -#include "sysdep.h" -#include -#include -#include - -#ifdef HAVE_TERMIO -#include -#endif - -#ifdef __PACIFIC__ -#include -#else -#include -#endif - -#include "readline.h" - -#include "main.h" - - -#ifdef HAVE_TERMIO -/*----------------------------------------------------------------------*\ - - termio handling - -\*----------------------------------------------------------------------*/ - -static struct termios term; - -static void newtermio() -{ - struct termios newterm; - tcgetattr(0, &term); - newterm=term; - newterm.c_lflag&=~(ECHO|ICANON); - newterm.c_cc[VMIN]=1; - newterm.c_cc[VTIME]=0; - tcsetattr(0, TCSANOW, &newterm); -} - -static void restoretermio() -{ - tcsetattr(0, TCSANOW, &term); -} - -#endif - - -/*----------------------------------------------------------------------*\ - - Global character buffers etc. - -\*----------------------------------------------------------------------*/ - -static unsigned char buffer[LINELENGTH+1]; -static int bufidx; - -static unsigned char *history[HISTORYLENGTH]; -static int histidx; /* Index where to store next history */ -static int histp; /* Points to the history recalled last */ - -static unsigned char ch; -static int endOfInput = 0; -static Boolean change; -static Boolean insert = TRUE; - - -/*----------------------------------------------------------------------*\ - - Character map types and maps - -\*----------------------------------------------------------------------*/ - -typedef struct {unsigned char min, max; void (*hook)(char ch);} KeyMap; - -/* Forward declaration of hooks */ -static void escHook(char ch); -static void insertCh(char ch); -static void arrowHook(char ch); -static void upArrow(char ch); -static void downArrow(char ch); -static void rightArrow(char ch); -static void leftArrow(char ch); -static void insertToggle(char ch); -static void newLine(char ch); -static void delFwd(char ch); -static void delBwd(char ch); - -#ifdef __XXunix__ -static KeyMap keymap[] = { - {0x00, 0x07, NULL}, - {0x08, 0x08, delBwd}, - {0x09, 0x09, NULL}, - {0x0a, 0x0a, newLine}, - {0x1b, 0x1b, escHook}, - {0x1c, 0x7e, insertCh}, - {0x7f, 0x7f, delFwd}, - {0x80, 0xff, insertCh}, - {0x00, 0x00, NULL} -}; - -/* I can't figure out what really coverns the esc-map characters... */ -#ifdef __solarisX__ -static KeyMap escmap[] = { - {0x00, 0x4e, NULL}, - {0x4f, 0x4f, arrowHook}, - {0x50, 0xff, NULL}, - {0x00, 0x00, NULL} -}; -#else -static KeyMap escmap[] = { - {0x00, 0x5a, NULL}, - {0x5b, 0x5b, arrowHook}, - {0x5c, 0xff, NULL}, - {0x00, 0x00, NULL} -}; -#endif - -static KeyMap arrowmap[] = { - {0x00, 0x31, NULL}, - {0x32, 0x32, insertToggle}, - {0x33, 0x40, NULL}, - {0x41, 0x41, upArrow}, - {0x42, 0x42, downArrow}, - {0x43, 0x43, rightArrow}, - {0x44, 0x44, leftArrow}, - {0x45, 0xff, NULL}, - {0x00, 0x00, NULL} -}; - -#endif - -#ifdef __win__ -static KeyMap keymap[] = { - {0x00, 0x01, NULL}, - {0x02, 0x02, leftArrow}, - {0x03, 0x05, NULL}, - {0x06, 0x06, rightArrow}, - {0x07, 0x07, NULL}, - {0x08, 0x08, delBwd}, - {0x09, 0x09, NULL}, - {0x0a, 0x0a, newLine}, - {0x1b, 0x1b, escHook}, - {0x1c, 0x7e, insertCh}, - {0x7f, 0x7f, delFwd}, - {0x80, 0xff, insertCh}, - {0x00, 0x00, NULL} -}; - -static KeyMap escmap[] = { - {0x00, 0x5a, NULL}, - {0x5b, 0x5b, arrowHook}, - {0x5c, 0xff, NULL}, - {0x00, 0x00, NULL} -}; - -static KeyMap arrowmap[] = { - {0x00, 0x31, NULL}, - {0x32, 0x32, insertToggle}, - {0x33, 0x40, NULL}, - {0x41, 0x41, upArrow}, - {0x42, 0x42, downArrow}, - {0x43, 0x43, rightArrow}, - {0x44, 0x44, leftArrow}, - {0x45, 0xff, NULL}, - {0x00, 0x00, NULL} -}; - -#endif - -#ifdef __dos__ -static KeyMap keymap[] = { - {0x00, 0x01, NULL}, - {0x02, 0x02, leftArrow}, - {0x03, 0x05, NULL}, - {0x06, 0x06, rightArrow}, - {0x07, 0x07, NULL}, - {0x08, 0x08, delBwd}, - {0x09, 0x09, NULL}, - {0x0a, 0x0a, newLine}, - {0x1b, 0x1b, escHook}, - {0x1c, 0x7e, insertCh}, - {0x7f, 0x7f, delFwd}, - {0x80, 0xff, insertCh}, - {0x00, 0x00, NULL} -}; - -static KeyMap escmap[] = { - {0x00, 0x5a, NULL}, - {0x5b, 0x5b, arrowHook}, - {0x5c, 0xff, NULL}, - {0x00, 0x00, NULL} -}; - -static KeyMap arrowmap[] = { - {0x00, 0x31, NULL}, - {0x32, 0x32, insertToggle}, - {0x33, 0x40, NULL}, - {0x41, 0x41, upArrow}, - {0x42, 0x42, downArrow}, - {0x43, 0x43, rightArrow}, - {0x44, 0x44, leftArrow}, - {0x45, 0xff, NULL}, - {0x00, 0x00, NULL} -}; - -#endif - - -static void doBeep(void) -{ - write(1, "\7", 1); -} - - -static void backspace(void) -{ - write(1, "\b", 1); -} - - -static void erase() -{ - int i; - - for (i = 0; i < bufidx; i++) backspace(); /* Backup to beginning of text */ - for (i = 0; i < strlen((char *)buffer); i++) write(1, " ", 1); /* Erase all text */ - for (i = 0; i < strlen((char *)buffer); i++) backspace(); /* Backup to beginning of text */ -} - -/*----------------------------------------------------------------------*\ - - Character handling hook functions - -\*----------------------------------------------------------------------*/ - -static void execute(KeyMap map[], unsigned char ch) -{ - int i = 0; - - for (i = 0; i <= 256; i++) { - if (i > 0 && map[i].min == 0x00) break; /* End marker is a 0,0,NULL */ - if (map[i].min <= ch && ch <= map[i].max) { - if (map[i].hook != NULL) { - map[i].hook(ch); - return; - } else - doBeep(); - } - } - doBeep(); -} - - -static void upArrow(char ch) -{ - /* Is there more history ? */ - if (history[(histp+HISTORYLENGTH-1)%HISTORYLENGTH] == NULL || - (histp+HISTORYLENGTH-1)%HISTORYLENGTH == histidx) { - write(1, "\7", 1); - return; - } - - erase(); - - /* Backup history pointer */ - histp = (histp+HISTORYLENGTH-1)%HISTORYLENGTH; - - /* Copy the history and write it */ - strcpy((char *)buffer, (char *)history[histp]); - bufidx = strlen((char *)buffer); - write(1, (void *)buffer, strlen((char *)buffer)); - -} - - -static void downArrow(char ch) -{ - /* Is there more history ? */ - if (histp == histidx) { - write(1, "\7", 1); - return; - } - - erase(); - - /* Advance history pointer */ - histp = (histp+1)%HISTORYLENGTH; - - /* If we are not at the most recent history entry, copy the history and write it */ - if (histp != histidx) { - strcpy((char *)buffer, (char *)history[histp]); - bufidx = strlen((char *)buffer); - write(1, (void *)buffer, strlen((char *)buffer)); - } else { - bufidx = 0; - buffer[0] = '\0'; - } -} - - -static void rightArrow(char ch) -{ - if (bufidx > LINELENGTH || buffer[bufidx] == '\0') - doBeep(); - else { - write(1, (void *)&buffer[bufidx], 1); - bufidx++; - } -} - - -static void leftArrow(char ch) -{ - if (bufidx == 0) - doBeep(); - else { - bufidx--; - backspace(); - } -} - - -static void insertToggle(char ch) -{ - read(0, &ch, 1); - if (ch != 'z') - doBeep(); - else - insert = !insert; -} - - -static void delBwd(char ch) -{ - if (bufidx == 0) - doBeep(); - else { - int i; - - change = TRUE; - backspace(); - bufidx--; - for (i = 0; i <= strlen((char *)&buffer[bufidx+1]); i++) - buffer[bufidx+i] = buffer[bufidx+1+i]; - write(1, (void *)&buffer[bufidx], strlen((char *)&buffer[bufidx])); - write(1, " ", 1); - for (i = 0; i <= strlen((char *)&buffer[bufidx]); i++) backspace(); - } -} - -static void delFwd(char ch) -{ - if (bufidx > LINELENGTH || buffer[bufidx] == '\0') - doBeep(); - else { - int i; - - change = TRUE; - strcpy((char *)&buffer[bufidx], (char *)&buffer[bufidx+1]); - write(1, (void *)&buffer[bufidx], strlen((char *)&buffer[bufidx])); - write(1, " ", 1); - for (i = 0; i <= strlen((char *)&buffer[bufidx]); i++) backspace(); - } -} - -static void escHook(char ch) { - read(0, &ch, 1); - execute(escmap, ch); -} - -static void arrowHook(char ch) { - read(0, &ch, 1); - execute(arrowmap, ch); -} - -static void newLine(char ch) -{ - endOfInput = 1; - write(1, "\n", 1); - - /* If the input is not the same as the previous, save it in the history */ - if (change && strlen((char *)buffer) > 0) { - if (history[histidx] == NULL) - history[histidx] = (unsigned char *)allocate(LINELENGTH+1); - strcpy((char *)history[histidx], (char *)buffer); - histidx = (histidx+1)%HISTORYLENGTH; - } -} - - -static void insertCh(char ch) { - if (bufidx > LINELENGTH) - doBeep(); - else { - /* If at end advance the NULL */ - if (buffer[bufidx] == '\0') - buffer[bufidx+1] = '\0'; - else if (insert) { - int i; - - /* If insert mode is on, move the characters ahead */ - for (i = strlen((char *)buffer); i >= bufidx; i--) - buffer[i+1] = buffer[i]; - write(1, (void *)&buffer[bufidx], strlen((char *)&buffer[bufidx])); - for (i = strlen((char *)&buffer[bufidx]); i > 0; i--) backspace(); - } - change = TRUE; - buffer[bufidx] = ch; - write(1, &ch, 1); - bufidx++; - } -} - -#ifdef __win__ -#include -#include -#include -#endif - -/*---------------------------------------------------------------------- - - echoOff() - - */ -static void echoOff() -{ -#ifdef HAVE_TERMIO - newtermio(); -#else -#ifdef __win__ - - DWORD handle = GetStdHandle(STD_INPUT_HANDLE); - - (void) SetConsoleMode(handle, 0); - -#endif -#endif -} - - -/*---------------------------------------------------------------------- - - echoOn() - - */ -static void echoOn() -{ -#ifdef HAVE_TERMIO - restoretermio(); -#else -#ifdef __win__ - - DWORD handle = GetStdHandle(STD_INPUT_HANDLE); - (void) SetConsoleMode(handle, ENABLE_ECHO_INPUT); - -#endif -#endif -} - - -/*====================================================================== - - readline() - - Read a line from the user, with history and editing - - */ - -/* 4f - length of user buffer should be used */ -Boolean readline(char usrbuf[]) -{ - fflush(stdout); - bufidx = 0; - histp = histidx; - buffer[0] = '\0'; - change = TRUE; - echoOff(); - endOfInput = 0; - while (!endOfInput) { - if (read(0, (void *)&ch, 1) != 1) { - echoOn(); - return FALSE; - } - execute(keymap, ch); - } - echoOn(); - strcpy(usrbuf, (char *)buffer); - return TRUE; -} - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/readline.h b/app/src/main/jni/terps/alan/alan2/readline.h deleted file mode 100755 index 8c2dddf..0000000 --- a/app/src/main/jni/terps/alan/alan2/readline.h +++ /dev/null @@ -1,23 +0,0 @@ -#ifndef _READLINE_H_ -#define _READLINE_H_ -/*----------------------------------------------------------------------*\ - - readline.h - - Header file for user input, history and editing support - -\*----------------------------------------------------------------------*/ - -#include "types.h" - -#define LINELENGTH 80 -#define HISTORYLENGTH 20 - -#ifdef _PROTOTYPES_ -extern Boolean readline(char usrbuf[]); - -#else -extern Boolean readline(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/resources.h b/app/src/main/jni/terps/alan/alan2/resources.h deleted file mode 100755 index 5c219ee..0000000 --- a/app/src/main/jni/terps/alan/alan2/resources.h +++ /dev/null @@ -1,10 +0,0 @@ -#define IDC_STATIC (-1) - -#define IDR_ARUN 1101 -#define IDR_ARUN_ICON 1102 -#define IDD_ABOUT 1103 - -#define ID_MENU_RESTART 25001 -#define ID_MENU_SAVE 25002 -#define ID_MENU_RESTORE 25003 -#define ID_MENU_ABOUT 25004 diff --git a/app/src/main/jni/terps/alan/alan2/reverse.c b/app/src/main/jni/terps/alan/alan2/reverse.c deleted file mode 100755 index 065e088..0000000 --- a/app/src/main/jni/terps/alan/alan2/reverse.c +++ /dev/null @@ -1,535 +0,0 @@ -/*----------------------------------------------------------------------*\ - - reverse.c - - Handles all reversing of data - -\*----------------------------------------------------------------------*/ - - -#include "types.h" -#include "main.h" - -#include "reverse.h" - - -/*---------------------------------------------------------------------- - - reversed() - - Return the reversed bytes in the Aword - -*/ -#ifdef _PROTOTYPES_ -Aword reversed(Aword w) /* IN - The ACODE word to swap bytes of */ -#else -Aword reversed(w) - Aword w; /* IN - The ACODE word to swap bytes of */ -#endif -{ - Aword s; /* The swapped ACODE word */ - char *wp, *sp; - int i; - - wp = (char *) &w; - sp = (char *) &s; - - for (i = 0; i < sizeof(Aword); i++) - sp[sizeof(Aword)-1 - i] = wp[i]; - - return s; -} - - -#ifdef _PROTOTYPES_ -void reverse(Aword *w) /* IN - The ACODE word to reverse bytes in */ -#else -void reverse(w) - Aword *w; /* IN - The ACODE word to reverse bytes in */ -#endif -{ - *w = reversed(*w); -} - - -#ifdef _PROTOTYPES_ -static void reverseTable(Aword adr, int len) -#else -static void reverseTable(adr, len) - Aword adr; - int len; -#endif -{ - Aword *e = &memory[adr]; - int i; - - if (adr != 0) - while (!endOfTable(e)) { - for (i = 0; i < len/sizeof(Aword); i++) { - reverse(e); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseStms(Aword adr) -#else -static void reverseStms(adr) - Aword adr; -#endif -{ - Aword *e = &memory[adr]; - - if (adr != 0) - while (TRUE) { - reverse(e); - if (*e == ((Aword)C_STMOP<<28|(Aword)I_RETURN)) break; - e++; - } -} - - -#ifdef _PROTOTYPES_ -static void reverseMsgs(Aword adr) -#else -static void reverseMsgs(adr) - Aword adr; -#endif -{ - MsgElem *e = (MsgElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(MsgElem)); - while (!endOfTable(e)) { - reverseStms(e->stms); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseWrds(Aword adr) -#else -static void reverseWrds(adr) - Aword adr; -#endif -{ - WrdElem *e = (WrdElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(WrdElem)); - while (!endOfTable(e)) { - if ((e->class & (1L<adjrefs, sizeof(Aword)); - reverseTable(e->nounrefs, sizeof(Aword)); - } - e++; - } - } -} - -#ifdef _PROTOTYPES_ -static void reverseChks(Aword adr) -#else -static void reverseChks(adr) - Aword adr; -#endif -{ - ChkElem *e = (ChkElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(ChkElem)); - while (!endOfTable(e)) { - reverseStms(e->exp); - reverseStms(e->stms); - e++; - } - } -} - -#ifdef _PROTOTYPES_ -static void reverseAlts(Aword adr) -#else -static void reverseAlts(adr) - Aword adr; -#endif -{ - AltElem *e = (AltElem *)&memory[adr]; - - if (adr != 0 && !endOfTable(e) && !e->done) { - reverseTable(adr, sizeof(AltElem)); - e->done = TRUE; - while (!endOfTable(e)) { - reverseChks(e->checks); - reverseStms(e->action); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseVrbs(Aword adr) -#else -static void reverseVrbs(adr) - Aword adr; -#endif -{ - VrbElem *e = (VrbElem *)&memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(VrbElem)); - while (!endOfTable(e)) { - reverseAlts(e->alts); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseSteps(Aword adr) -#else -static void reverseSteps(adr) - Aword adr; -#endif -{ - StepElem *e = (StepElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(StepElem)); - while (!endOfTable(e)) { - reverseStms(e->exp); - reverseStms(e->stm); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseScrs(Aword adr) -#else -static void reverseScrs(adr) - Aword adr; -#endif -{ - ScrElem *e = (ScrElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(ScrElem)); - while (!endOfTable(e)) { - reverseStms(e->dscr); - reverseSteps(e->steps); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseActs(Aword adr) -#else -static void reverseActs(adr) - Aword adr; -#endif -{ - ActElem *e = (ActElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(ActElem)); - while (!endOfTable(e)) { - reverseStms(e->nam); - reverseTable(e->atrs, sizeof(AtrElem)); - reverseScrs(e->scradr); - reverseVrbs(e->vrbs); - reverseStms(e->dscr); - e++; - } - } -} - -#ifdef _PROTOTYPES_ -static void reverseObjs(Aword adr, Boolean v2_5) -#else -static void reverseObjs(adr, v2_5) - Aword adr; - Boolean v2_5; /* TRUE if it's a v2.5 format game */ -#endif -{ - ObjElem *e = (ObjElem *) &memory[adr]; - ObjElem25 *e25 = (ObjElem25 *) &memory[adr]; - - if (v2_5) { - if (adr != 0 && !endOfTable(e25)) { - reverseTable(adr, sizeof(ObjElem25)); - while (!endOfTable(e25)) { - reverseTable(e25->atrs, sizeof(AtrElem)); - reverseVrbs(e25->vrbs); - reverseStms(e25->dscr1); - reverseStms(e25->dscr2); - e25++; - } - } - } else { - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(ObjElem)); - while (!endOfTable(e)) { - reverseTable(e->atrs, sizeof(AtrElem)); - reverseVrbs(e->vrbs); - reverseStms(e->art); - reverseStms(e->dscr1); - reverseStms(e->dscr2); - e++; - } - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseExts(Aword adr) -#else -static void reverseExts(adr) - Aword adr; -#endif -{ - ExtElem *e = (ExtElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(ExtElem)); - while (!endOfTable(e)) { - if (!e->done) { - reverseChks(e->checks); - reverseStms(e->action); - } - e++; - } - } -} - -#ifdef _PROTOTYPES_ -static void reverseLocs(Aword adr) -#else -static void reverseLocs(adr) - Aword adr; -#endif -{ - LocElem *e = (LocElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(LocElem)); - while (!endOfTable(e)) { - reverseStms(e->nams); - reverseStms(e->dscr); - reverseStms(e->does); - reverseTable(e->atrs, sizeof(AtrElem)); - reverseExts(e->exts); - reverseVrbs(e->vrbs); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseClas(Aword adr) -#else -static void reverseClas(adr) - Aword adr; -#endif -{ - ClaElem *e = (ClaElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(ClaElem)); - while (!endOfTable(e)) { - reverseStms(e->stms); - e++; - } - } - if (adr) - reverse(&((Aword *)e)[1]); /* The verb code is stored after the table */ -} - - -#ifdef _PROTOTYPES_ -static void reverseElms(Aword adr) -#else -static void reverseElms(adr) - Aword adr; -#endif -{ - ElmElem *e = (ElmElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(ElmElem)); - while (!endOfTable(e)) { - if (e->code == EOS) reverseClas(e->next); - else reverseElms(e->next); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseStxs(Aword adr) -#else -static void reverseStxs(adr) - Aword adr; -#endif -{ - StxElem *e = (StxElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(StxElem)); - while (!endOfTable(e)) { - reverseElms(e->elms); - e++; - } - } -} - -#ifdef _PROTOTYPES_ -static void reverseEvts(Aword adr) -#else -static void reverseEvts(adr) - Aword adr; -#endif -{ - EvtElem *e = (EvtElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(EvtElem)); - while (!endOfTable(e)) { - reverseStms(e->code); - e++; - } - } -} - - - -#ifdef _PROTOTYPES_ -static void reverseLims(Aword adr) -#else -static void reverseLims(adr) - Aword adr; -#endif -{ - LimElem *e = (LimElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(LimElem)); - while (!endOfTable(e)) { - reverseStms(e->stms); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseCnts(Aword adr) -#else -static void reverseCnts(adr) - Aword adr; -#endif -{ - CntElem *e = (CntElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(CntElem)); - while (!endOfTable(e)) { - reverseLims(e->lims); - reverseStms(e->header); - reverseStms(e->empty); - reverseStms(e->nam); - e++; - } - } -} - - -#ifdef _PROTOTYPES_ -static void reverseRuls(Aword adr) -#else -static void reverseRuls(adr) - Aword adr; -#endif -{ - RulElem *e = (RulElem *) &memory[adr]; - - if (adr != 0 && !endOfTable(e)) { - reverseTable(adr, sizeof(RulElem)); - while (!endOfTable(e)) { - reverseStms(e->exp); - reverseStms(e->stms); - e++; - } - } -} - - - -/*---------------------------------------------------------------------- - - reverseHdr() - - Reverse the header structure. - -*/ -#ifdef _PROTOTYPES_ -void reverseHdr(AcdHdr *hdr) -#else -void reverseHdr(hdr) - AcdHdr *hdr; -#endif -{ - int i; - - /* Reverse all words in the header except the first (version marking) */ - for (i = 1; i < sizeof(AcdHdr)/sizeof(Aword); i++) - reverse(&((Aword *)hdr)[i]); -} - -/*---------------------------------------------------------------------- - - reverseACD() - - Traverse all the data structures and reverse all integers. - Only performed in architectures with reversed byte ordering, which - makes the .ACD files fully compatible across architectures - - */ -#ifdef _PROTOTYPES_ -void reverseACD(Boolean v2_5) -#else -void reverseACD(v2_5) - Boolean v2_5; -#endif -{ - reverseHdr(header); - reverseWrds(header->dict); - reverseTable(header->oatrs, sizeof(AtrElem)); - reverseTable(header->latrs, sizeof(AtrElem)); - reverseTable(header->aatrs, sizeof(AtrElem)); - reverseActs(header->acts); - reverseObjs(header->objs, v2_5); - reverseLocs(header->locs); - reverseStxs(header->stxs); - reverseVrbs(header->vrbs); - reverseEvts(header->evts); - reverseCnts(header->cnts); - reverseRuls(header->ruls); - reverseTable(header->init, sizeof(IniElem)); - reverseStms(header->start); - reverseMsgs(header->msgs); - - reverseTable(header->scores, sizeof(Aword)); - reverseTable(header->freq, sizeof(Aword)); -} diff --git a/app/src/main/jni/terps/alan/alan2/reverse.h b/app/src/main/jni/terps/alan/alan2/reverse.h deleted file mode 100755 index 6d708ff..0000000 --- a/app/src/main/jni/terps/alan/alan2/reverse.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _REVERSE_H_ -#define _REVERSE_H_ -/*----------------------------------------------------------------------*\ - - reverse.h - - Header file for reverse-module - -\*----------------------------------------------------------------------*/ - -/* TYPES */ - - -#ifdef _PROTOTYPES_ - -extern void reverseHdr(AcdHdr *hdr); -extern void reverseACD(Boolean v25); -extern void reverse(Aword *word); -extern Aword reversed(Aword word); - -#else -extern void reverseHdr(); -extern void reverseACD(); -extern void reverse(); -extern Aword reversed(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/rules.c b/app/src/main/jni/terps/alan/alan2/rules.c deleted file mode 100755 index 9be269b..0000000 --- a/app/src/main/jni/terps/alan/alan2/rules.c +++ /dev/null @@ -1,65 +0,0 @@ -/*----------------------------------------------------------------------*\ - - rules.c - - Rule handling unit of Alan interpreter module, ARUN. - -\*----------------------------------------------------------------------*/ - -#include - -#include "types.h" -#include "main.h" -#include "inter.h" -#include "debug.h" -#include "exe.h" -#include "stack.h" - -#include "rules.h" - -#ifdef GLK -#include "glkio.h" -#endif - -#ifdef _PROTOTYPES_ -void rules(void) -#else -void rules() -#endif -{ - Boolean change = TRUE; - int i; - - for (i = 1; !endOfTable(&ruls[i-1]); i++) - ruls[i-1].run = FALSE; - - while (change) { - change = FALSE; - for (i = 1; !endOfTable(&ruls[i-1]); i++) - if (!ruls[i-1].run) { - if (trcflg) { - printf("\n\n"); - } - interpret(ruls[i-1].exp); - if (pop()) { - change = TRUE; - ruls[i-1].run = TRUE; - if (trcflg) - if (!stpflg) - printf(", Executing:>\n"); - else { - printf("\nRULE %d (at ", i); - debugsay(cur.loc); - printf("), Executing:>\n"); - } - interpret(ruls[i-1].stms); - } else if (trcflg && !stpflg) - printf(":>\n"); - } - } -} diff --git a/app/src/main/jni/terps/alan/alan2/rules.h b/app/src/main/jni/terps/alan/alan2/rules.h deleted file mode 100755 index 094ca22..0000000 --- a/app/src/main/jni/terps/alan/alan2/rules.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef _RULES_H_ -#define _RULES_H_ -/*----------------------------------------------------------------------*\ - - rules.h - - Header file for rules handler in Alan interpreter - -\*----------------------------------------------------------------------*/ - -/* TYPES */ - -#ifdef _PROTOTYPES_ - -extern void rules(void); - -#else -extern void rules(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/spa.c b/app/src/main/jni/terps/alan/alan2/spa.c deleted file mode 100755 index 8e45e6f..0000000 --- a/app/src/main/jni/terps/alan/alan2/spa.c +++ /dev/null @@ -1,926 +0,0 @@ -/*--------------------------------------------------------------------*\ - spa.c Date: 1995-04-13/reibert@home - - spa -- standard process of arguments (SoftLabs way) - - Author: Reibert Arbring. - Copyright (c) 1989 - 1995 SoftLab ab - - Legal Notice: As in spa.h - - History: - 4.2(1) - 1994-05-13/reibert@home -- Errors more severe - 4.2 - 1994-04-30/reibert@home -- SPA_COMMENT - 4.1(1) - 1994-01-08/reibert@home -- spaExit - 4.1 - 1993-11-01/reibert@home -- CMS/changed float interface - 4.0(1) - 1992-03-12/reibert@home -- bits: * - 4.0 - 1992-03-09/reibert@home -- SPA_ITEM outdated, "locale" messages, - mac adaption, files, alert ----- - 3.1 - 1992-02-26/reibert@roo -- SPA_PRINT_DEFAULT - 3.0(3) - 1993-02-16/thoni@rabbit -- SPA_Set with '--' requires no argument - 3.0(2) - 1992-02-26/reibert@roo -- Ambiguous was misspelled, spaArgumentNo - 3.0(1) - 1991-09-23/reibert@roo -- SPA_Set with '--' sets all on (good?) - 3.0 - 1991-08-28/reibert@roo -- SPA_KeyWord, all SPA_funs as arguments ----- - 2.4 - 1990-11-27/reibert@roo -- SPA_Report, SPA_Toggle etc. removed - 2.3(2) - 1990-11-20/reibert@roo -- ANSI-C && C++ - 2.3(1) - 1990-04-24/reibert@roo -- Some cleanup - 2.3 - 90-04-18/Reibert Olsson -- Multiple help lines, default settings - 2.2 - 90-02-13/Reibert Olsson -- SPA_Report - 2.1 - 89-12-03/Reibert Olsson -- SPA_Set, errfun is a SPA_FUNCTION, - SPA_Toggle - 2.0(1) - 89-11-27/Reibert Olsson - 2.0 - 89-11-20/Reibert Olsson -- Adapted to SoftLab rules, SPA ----- - 1.0 - 89-08-09/Reibert Olsson -\*--------------------------------------------------------------------*/ -#include "spa.h" -#if _SPA_H_!=42 -error "SPA header file version 4.2 required" -#endif - -#include -#include -#ifdef __NEWC__ -#include -#include -#else -#include -#endif - -typedef int boolean; -#ifndef FALSE -#define FALSE 0 -#endif -#ifndef TRUE -#define TRUE 1 -#endif - -#define PRIVATE static -#define PUBLIC - -#ifndef SPA_IGNORE_CASE -#define SPA_IGNORE_CASE TRUE /* Unsensitive to the case of options */ -#endif -#ifndef SPA_MATCH_PREFIX -#define SPA_MATCH_PREFIX TRUE /* Unique prefix is matching options */ -#endif -#ifndef SPA_PRINT_DEFAULT -#define SPA_PRINT_DEFAULT TRUE /* Spa tries to report default in help */ -#endif -#ifndef SPA_PRINT_ITEM_SZ -#define SPA_PRINT_ITEM_SZ 17 /* The item width in help printing */ -#endif -#ifndef SPA_LANG -#define SPA_LANG 0 /* Language for messages (English) */ -#endif - -#if SPA_LANG==46 /* Swedish */ -PRIVATE char *SpaFlagKeyWords[] = { - "AV", "P", - "NEJ", "JA", - "FALSK", "SANN", - "NIL", "T", - NULL -}; -PRIVATE char *SpaDefaultFormat = " (sknsvrde: %s)"; -PRIVATE char *SpaStrArg = "Parametrar:"; -PRIVATE char *SpaStrOpt = "Tillval:"; -PRIVATE char *SpaStrUsg = "Anvndning:"; -PRIVATE char *SpaStrNMK = "Nyckelord passar ej"; -PRIVATE char *SpaStrAMK = "Tvetydigt nyckelord"; -PRIVATE char *SpaStrNMO = "Tillval passar ej"; -PRIVATE char *SpaStrAMO = "Tvetydigt tillval"; -PRIVATE char *SpaStrILF = "Oknd funktionstyp"; -PRIVATE char *SpaStrISC = "Otilltet mngdtecken"; -PRIVATE char *SpaStrVE = "Frvntat vrde saknas"; -PRIVATE char *SpaStrIVE = "Heltal frvntat"; -PRIVATE char *SpaStrRVE = "Flyttal frvntat"; -PRIVATE char *SpaStrFRE = "Filen kunde ej ppnas fr lsning"; -PRIVATE char *SpaStrFWE = "Filen kunde ej ppnas fr skrivning"; -PRIVATE char *SpaStrTMA = "verfldig parameter"; -PRIVATE char *SpaStrAE = "Parameterfel"; - -PRIVATE char *SpaAlertStr[] = { - "Avlusning", "Information", "Varning", "Fel", - "Allvarligt fel", "Internt fel", "Oknt fel", - "Exekveringen avbryts" -}; - -#else /* English */ - -PRIVATE char *SpaFlagKeyWords[] = { /* The table for flag as argument */ - "OFF", "ON", - "FALSE", "TRUE", - "NO", "YES", - "NIL", "T", - NULL -}; - -PRIVATE char *SpaDefaultFormat = " (default: %s)"; /* How to print default values */ -PRIVATE char *SpaStrArg = "Arguments:"; -PRIVATE char *SpaStrOpt = "Options:"; -PRIVATE char *SpaStrUsg = "Usage:"; -PRIVATE char *SpaStrNMK = "Non-matching keyword"; -PRIVATE char *SpaStrAMK = "Ambiguous keyword"; -PRIVATE char *SpaStrNMO = "Non-matching option"; -PRIVATE char *SpaStrAMO = "Ambiguous option"; -PRIVATE char *SpaStrILF = "Illegal function type"; -PRIVATE char *SpaStrISC = "Illegal set character"; -PRIVATE char *SpaStrVE = "Value expected"; -PRIVATE char *SpaStrIVE = "Integer value expected"; -PRIVATE char *SpaStrRVE = "Real value expected"; -PRIVATE char *SpaStrFRE = "File could not be opened for reading"; -PRIVATE char *SpaStrFWE = "File could not be opened for writing"; -PRIVATE char *SpaStrTMA = "Superfluous argument"; -PRIVATE char *SpaStrAE = "Argument error"; - -PRIVATE char *SpaAlertStr[] = { - "Debug", "Information", "Warning", "Error", - "Fatal error", "Internal error", "Unknown error", - "Execution stopped" -}; - -#endif - - -/*---------------------------------------------------------------------- - These are to make the parameters to spaProcess accessible throughout - this file -*/ -PRIVATE char **pArgV; -PRIVATE int pArgC; -PRIVATE int pArg; /* Current arg, index in pArgV */ -PRIVATE _SPA_ITEM *pArguments; -PRIVATE _SPA_ITEM *pOptions; - -#ifdef __NEWC__ - -#define safeExecute(fun, item, raw, on) \ - if (fun) (*(void (*)(char *, char *, int))fun)(item->name, raw, on) -/* if (fun) (*(SpaFun)fun)(item->name, raw, on) */ - -#define FUNCTION(N,A) N( -#define PROCEDURE(N,A) void N( -#define IN(T,N) T N -#define OUT(T,N) T* N -#define IS ) -#define X , - -#else - -#define safeExecute(fun, item, raw, on) \ - if (fun) (*(void (*)())fun)(item->name, raw, on) - -#define FUNCTION(N,A) N A -#define PROCEDURE(N,A) void N A -#define IN(T,N) T N; -#define OUT(T,N) T* N; -#define X -#define IS - -#endif - - -PRIVATE SpaErrFun *pErrFun; /* Points to errorfunction */ - -#define spaErr(m, a, s) (*pErrFun)(s, m, a) - - -PRIVATE struct { /* Code reduction data structure */ - FILE *deffile; - char *iomode; -} fileDefault[2] = { /* We assume _SPA_OutFile-_SPA_InFile == 1 */ -#ifdef STDIONONCONST - { NULL, "r" }, /* Set file before use! */ - { NULL, "w" } -#else - { stdin, "r" }, - { stdout, "w" } -#endif -}; -#define mode(T) (fileDefault[(T)-_SPA_InFile].iomode) -#define file(T) (fileDefault[(T)-_SPA_InFile].deffile) - - -#if SPA_IGNORE_CASE -#include -#define lwr(C) (isupper(C)? tolower(C): C) -#else -#define lwr(C) C -#endif - -#define _SPA_EXACT (-TRUE) - - -/*---------------------------------------------------------------------- - Return SPA_MATCH_PREFIX if a true prefix is found, and _SPA_EXACT - if both strings are equal. The string is stripped of any comments - (i.e blank and following). -*/ -PRIVATE int FUNCTION(match, (p, s)) - IN(register char, *p) X /* User supplied argv-item */ - IN(register char, *s) /* SPA_ITEM string */ -IS { - while (*p) { - if (*s==' ' || lwr(*s)!=lwr(*p)) return FALSE; - s++; p++; - } - return (*s!=' '? SPA_MATCH_PREFIX: _SPA_EXACT); -} - - -/*---------------------------------------------------------------------- - Go thru a datastructure and match() to get any hits. Returns the - number of hits, and sets first found index (or -1). -*/ -PRIVATE int FUNCTION(find, (ai, kws, kwSz, kwO, found)) - IN(char, *ai) X /* User supplied argv-item */ - IN(register char, kws[]) X /* The matching words */ - IN(int, kwSz) X /* Size of kws */ - IN(int, kwO) X /* Offset to kws.name */ - OUT(int, found) /* The found items index */ -IS { - register int i, o; - int c, hits = 0; - - *found = -1; - for (o=kwO, i=0; *(char **)(&kws[o]); i++, o += kwSz) { - c= match(ai, *(char **)(&kws[o])); - if (c!=FALSE) { - if (*found==-1) *found = i; - if (c==_SPA_EXACT) { hits = 1; break; } - else hits++; - } - } - return hits; -} - - -/*---------------------------------------------------------------------- - Go thru the keywords and match() to get any hits. Returns the - found items index or the default. -*/ -PRIVATE int FUNCTION(findKeyWord, (thisWord, keyWords, def)) - IN(char, *thisWord) X /* User supplied argv-item */ - IN(char, *keyWords[]) X /* The keywords */ - IN(int, def) /* The default index */ -IS { - int found; - - switch (find(thisWord, (char *)keyWords, sizeof(char *), 0, &found)) { - case 0: - spaErr(SpaStrNMK, thisWord, 'F'); - break; - case 1: - break; - default: - spaErr(SpaStrAMK, thisWord, 'F'); - break; - } - return found<0 ? def: found; -} - - -/*---------------------------------------------------------------------- - Print help line for one SPA_ITEM. -*/ -PRIVATE PROCEDURE(printItem, (name, help, def, set, kws)) - IN(char *, name) X /* Name of item */ - IN(register char *, help) X /* Help string */ - IN(char *, def) X /* Default value string */ - IN(register char *, set) X /* Points to set string (or is NULL) */ - IN(char **,kws) /* Points to keyword array (or is NULL) */ -IS { - boolean nl = FALSE; - - printf(" %-*s ", SPA_PRINT_ITEM_SZ, name); - if (strlen(name)>SPA_PRINT_ITEM_SZ) - printf("\n %-*s ", SPA_PRINT_ITEM_SZ, ""); - if (help) { - printf("-- "); - for (;;) { - for (;*help; help++) { - if (*help=='\n') { help++; nl = TRUE; break; } - putchar(*help); - } - if (!*help) break; - printf("\n %-*s ", SPA_PRINT_ITEM_SZ, ""); - if (set) printf("%c -- ", *set++); - if (kws && *kws) printf("%s -- ", *kws++); - } -#if SPA_PRINT_DEFAULT - if (*def) { - if (nl) printf("\n %-*s ", SPA_PRINT_ITEM_SZ, ""); - printf(SpaDefaultFormat, def); - } -#endif - } - putchar('\n'); -} - - -/*---------------------------------------------------------------------- - Print a SPA_ITEMs name as argument. Static area! -*/ -PRIVATE char prName[128]; /* Used by p[AO]Name */ - -PRIVATE char* FUNCTION(pAName, (item)) - IN(_SPA_ITEM *, item) -IS { - switch (item->type) { - case _SPA_Flag: -#ifdef CMS - sprintf(prName, "(%s!%s)", SpaFlagKeyWords[1], SpaFlagKeyWords[0]); -#else - sprintf(prName, "[%s|%s]", SpaFlagKeyWords[1], SpaFlagKeyWords[0]); -#endif - break; - case _SPA_Bits: - sprintf(prName, "{%s}", item->s); - break; - default: - sprintf(prName, "<%s>", item->name); - break; - } - return prName; -} - - -/*---------------------------------------------------------------------- - Print a SPA_ITEMs name as option. Static area! -*/ -PRIVATE char* FUNCTION(pOName, (item)) - IN(_SPA_ITEM *, item) -IS { - static char *fmt[] = { -#ifdef CMS - "-%s", "-(-)%s", "-(-)%s {%s}" -#else - "-%s", "-[-]%s", "-[-]%s {%s}" -#endif - }; - int i = 0; /* -> fmt[0] */ - - switch (item->type) { - case _SPA_Bits: i++; /* -> fmt[2] */ - case _SPA_Flag: i++; /* -> fmt[1] */ - default: - break; - } - sprintf(prName, fmt[i], item->name, item->s); - return prName; -} - - -/*---------------------------------------------------------------------- - Report one SPA_ITEM. -*/ -PRIVATE PROCEDURE(reportItem, (item, name)) - IN(register _SPA_ITEM *, item) X - IN(char *, name) -IS { - char def[128]; /* Is this enough? Too much? No test ahead! */ - char *set = NULL; - char **kws = NULL; - - switch (item->type) { - case _SPA_None: return; - case _SPA_Comment: - printf("%s\n", (item->help? item->help: "")); - return; - default: - break; - } - - /* Set default values */ - *def = 0; -#if SPA_PRINT_DEFAULT - switch (item->type) { - case _SPA_Flag: - strcpy(def, item->i? SpaFlagKeyWords[1]: SpaFlagKeyWords[0]); - break; - case _SPA_Integer: - sprintf(def, "%d", item->i); - break; - case _SPA_Float: - sprintf(def, "%g", item->f); - break; - case _SPA_String: - case _SPA_InFile: - case _SPA_OutFile: - if (item->s) strcpy(def, item->s); - break; - case _SPA_KeyWord: - kws = item->sp; - strcpy(def, kws[item->i]); - break; - case _SPA_Bits: { - register int i = 0, j = 1; - def[0] = '{'; - set = item->s; - for (; set[i]; i++) { - if ((1<i) def[j++] = set[i]; - } - def[j++] = '}'; def[j] = 0; - } break; - default: - break; - } -#endif - printItem(name, item->help, def, set, kws); -} - - -/*---------------------------------------------------------------------- - Make a report list out of the arguments and options. -*/ -PRIVATE PROCEDURE(report, (args, opts)) - IN(register _SPA_ITEM, args[]) X - IN(register _SPA_ITEM, opts[]) -IS { - register int i; - - if (args[0].name && *args[0].name) printf("\n%s\n", SpaStrArg); - for (i= 0; args[i].name && *args[i].name; i++) - reportItem(&args[i], pAName(&args[i])); - - if (opts[0].name) printf("\n%s\n", SpaStrOpt); - for (i= 0; opts[i].name; i++) - reportItem(&opts[i], pOName(&opts[i])); - -} - - -/*---------------------------------------------------------------------- - Assert that the file was opened. -*/ -PRIVATE PROCEDURE(assertFile, (item)) - IN(register _SPA_ITEM, *item) -IS { - if (!*item->FP) { /* open failure */ - spaErr((item->type==_SPA_InFile? SpaStrFRE: SpaStrFWE), pArgV[pArg], 'F'); - *item->FP = file(item->type); - *item->sp = item->s; - } -} - -/*---------------------------------------------------------------------- - Set default values for one SPA_ITEM. -*/ -PRIVATE PROCEDURE(setDefault, (item)) - IN(register _SPA_ITEM, *item) -IS { - switch (item->type) { - case _SPA_Flag: - case _SPA_Integer: - case _SPA_KeyWord: - case _SPA_Bits: - *item->ip = item->i; - break; - case _SPA_Float: - *item->fp = item->f; - break; - case _SPA_String: - *item->sp = item->s; - break; - case _SPA_InFile: - case _SPA_OutFile: - *item->sp = item->s; - if (*item->sp && **item->sp) - *item->FP = fopen(*item->sp, mode(item->type)); - else *item->FP = file(item->type); - assertFile(item); - break; - case _SPA_Function: - case _SPA_Help: - case _SPA_Comment: - case _SPA_None: - break; - case _SPA_Private: - default: - spaErr(SpaStrILF, item->name, 'S'); - break; - } -} - - -/*---------------------------------------------------------------------- - Execute an SPA_ITEM. -*/ -PRIVATE PROCEDURE(execute, (item, option, on)) - IN(register _SPA_ITEM, *item) X - IN(boolean, option) X /* True if argv was an option */ - IN(register boolean, on) /* True if argv was an on-option */ -IS { - if (item) { - - if (option) - switch (item->type) { - case _SPA_Flag: - case _SPA_Function: - case _SPA_Help: - case _SPA_Comment: - case _SPA_None: - break; - default: - /* An option using next argv-item goes here */ - if (++pArg>=pArgC) { - --pArg; /* Too far, backup */ - setDefault(item); - spaErr(SpaStrVE, pArgV[pArg], 'E'); - goto postFun; - } - } - - switch (item->type) { - case _SPA_Flag: - if (option) *item->ip = on; - else { /* Parse the argument */ - *item->ip = findKeyWord(pArgV[pArg], SpaFlagKeyWords, item->i)&1 ; - } - break; - case _SPA_Bits: { - register char *arg, *bp; - boolean bon = on; - - for (arg= pArgV[pArg]; *arg; arg++) { /* Go thru argument */ - if (*arg=='-') { bon = !bon; continue; } - if (*arg=='*') { *item->ip = bon? -1: 0; continue; } - for (bp= item->s; *bp; bp++) /* and descriptor*/ - if (lwr(*arg)==lwr(*bp)) break; - if (*bp) { - if (bon) - *item->ip |= 1<<(bp-item->s); - else - *item->ip &= ~(1<<(bp-item->s)); - } else { - static char tmp[128]; - sprintf(tmp, "%s: %c", item->name, *arg); - spaErr(SpaStrISC, tmp, 'E'); - } - } - } break; - case _SPA_Integer: - if (sscanf(pArgV[pArg], "%i", item->ip)!=1) { - /* Number not ok */ - setDefault(item); - spaErr(SpaStrIVE, pArgV[pArg], 'E'); - } - break; - case _SPA_Float: - if (sscanf(pArgV[pArg], "%g", item->fp)!=1) { - /* Number not ok */ - setDefault(item); - spaErr(SpaStrRVE, pArgV[pArg], 'E'); - } - break; - case _SPA_String: - *item->sp= pArgV[pArg]; - break; - case _SPA_KeyWord: - *item->ip= findKeyWord(pArgV[pArg], item->sp, item->i); - break; - case _SPA_InFile: - case _SPA_OutFile: -#ifdef CMS - { /* We do assemble CMS 3-part file names into one string */ - char *file, *extension, *disk; - - file = pArgV[pArg]; - if (extension = spaArgument(1)) pArg++; else { extension = ""; } - if (disk = spaArgument(1)) pArg++; else { disk = ""; } - *item->sp = (char*)malloc( 40 ); /* What is the maximum? */ - /* strlen(file) + strlen(extension) + strlen(disk) + 3 */ - sprintf(*item->sp,"%s %s %s", file, extension, disk); - pArgV[pArg] = *item->sp; /* ! This could cause trouble if a hook reads previous items */ - } -#else - *item->sp = pArgV[pArg]; -#endif - if (*item->sp && **item->sp) { - if (*item->FP==file(item->type)) - *item->FP = fopen(*item->sp, mode(item->type)); - else - *item->FP = - freopen(*item->sp, mode(item->type), *item->FP); - } else *item->FP = file(item->type); - assertFile(item); - break; - case _SPA_Help: - safeExecute(item->hFun, item, pArgV[pArg], on); - report(pArguments, pOptions); - break; - case _SPA_Comment: - case _SPA_Function: - case _SPA_None: - case _SPA_Private: - break; - default: - /* This means that someone has dribbled with the option tables */ - spaErr(SpaStrILF, pArgV[pArg], 'S'); - break; - } - postFun: - safeExecute(item->postFun, item, pArgV[pArg], on); - } -} - - -/*---------------------------------------------------------------------- - Detect if current argv-item is an option, if so do as specified. -*/ -PRIVATE boolean FUNCTION(option, (options)) - IN(_SPA_ITEM, options[]) /* Possible options */ -IS { - int found; - register char *argvItem = pArgV[pArg]; - register int start; - - if (argvItem[0]=='-') { - start = (argvItem[1]=='-'? 2: 1); - if (argvItem[start]) { - switch (find(&argvItem[start], - (char *)options, - sizeof(_SPA_ITEM), - (int)((unsigned long)&options[0].name - - (unsigned long)&options[0]), - &found)) { - case 0: - spaErr(SpaStrNMO, argvItem, 'E'); - break; - case 1: - execute(&options[found], TRUE, start==1); - break; - default: - spaErr(SpaStrAMO, argvItem, 'E'); - break; - } - return TRUE; - } - } - return FALSE; -} - - -/*********************************************************************** - Builtin functions. -*/ - -/*---------------------------------------------------------------------- - Error function, uses spaAlert. -*/ -PRIVATE SPA_ERRFUN(biErrFun) { - spaAlert(sev, "%s: %s: %s", SpaStrAE, msg, add); -} - -PRIVATE SPA_FUN(biExit) { exit(1); (prettyName, rawName, on); } - -PRIVATE SPA_FUN(biArgTooMany) { - spaErr(SpaStrTMA, rawName, 'E'); - (prettyName, on); -} - -PRIVATE SPA_DECLARE(biArguments) - SPA_FUNCTION("", NULL, biArgTooMany) -SPA_END - -#ifdef __NEWC__ -PRIVATE SPA_FUN(biUsage); /* Forward */ -#else -PRIVATE void biUsage(); -#endif - -PRIVATE SPA_DECLARE(biOptions) -#if SPA_LANG==46 - SPA_HELP("hjlp", "ger denna utskrift", biUsage, biExit) -#else - SPA_HELP("help", "this help", biUsage, biExit) -#endif -SPA_END - -#ifdef CMS -# define oSTART " (" -# define oALT "!" -# define oSTOP ")..." -#else -# define oSTART " [" -# define oALT "|" -# define oSTOP "]..." -#endif - -PRIVATE SPA_FUN(biUsage) { - register int i, j; - - printf("%s %s", SpaStrUsg, SpaAlertName); - if (pOptions!=biOptions) { - printf(oSTART); - for (i=j=0; pOptions[i].name; i++) - if (pOptions[i].type && *pOptions[i].name) { - if (j++>0) printf(oALT); - printf(pOName(&pOptions[i])); - } - printf(oSTOP); - } - if (pArguments!=biArguments) { - for (i=0; pArguments[i].name; i++) - if (pArguments[i].type && *pArguments[i].name) - printf(" %s", pAName(&pArguments[i])); - } - printf("\n"); - (prettyName, rawName, on); -} - - -/*********************************************************************** - Public data & functions. -*/ - -/*====================================================================== - Program name for Alerts (tail of argv[0]) -*/ -PUBLIC char *SpaAlertName = NULL; - -/*====================================================================== - Alert at this level and higher -*/ -PUBLIC char SpaAlertLevel = 'I'; - -/*====================================================================== - File for alert messages (default stderr) -*/ -PUBLIC FILE *SpaAlertFile -#ifdef STDIONONCONST - = NULL; /* In this env stderr isn't a constant */ -#else - = stderr; -#endif - -/*---------------------------------------------------------------------- - Returns error severity as a number [0..6]. -*/ -PRIVATE int FUNCTION(level, (sev)) - IN(char, sev) /* Index in SpaAlertStr */ -IS { - static char *sevstr = "DIWEFS"; - register char *s; - - s = strchr(sevstr, sev); - return s? s-sevstr: 6; -} - -/*====================================================================== - Error notification (name: sev! ) to user. - Exits on severe errors. -*/ -#ifdef __NEWC__ -PUBLIC void spaAlert( /* Error notification; Exits on severe errors */ - char sev, /* IN - [DIWEFS] */ - char * fmt, /* IN - printf-format for additional things */ - ... /* IN - additional things */ -){ -#else -PUBLIC void spaAlert(va_alist) - va_dcl -{ - char sev; - char *fmt; -#endif - va_list ap; - register int lev; - -#ifdef __NEWC__ - va_start(ap, fmt); -#else - va_start(ap); - sev = va_arg(ap, char); - fmt = va_arg(ap, char *); -#endif - lev = level(sev); - if (lev>=level(SpaAlertLevel)) { - if (SpaAlertName) fprintf(SpaAlertFile, "%s: ", SpaAlertName); - fprintf(SpaAlertFile, "%s! ", SpaAlertStr[lev]); - vfprintf(SpaAlertFile, fmt, ap); - fprintf(SpaAlertFile, "\n"); - } - va_end(ap); - - if (lev>3 /*level('E')*/) { spaAlert('I', SpaAlertStr[7]); exit(1); } -} - - -/*====================================================================== - Return Nth argument in argv, NULL if outside argv. -*/ -PUBLIC char * FUNCTION(spaArgumentNo, (n)) - IN(register int, n) -IS { - return ( (n>=pArgC || n<0)? NULL: pArgV[n] ); -} - - -/*====================================================================== - Return Nth relative argument, NULL if outside argv. -*/ -PUBLIC char * FUNCTION(spaArgument, (n)) - IN(int, n) -IS { - return spaArgumentNo(pArg+n); -} - - -/*====================================================================== - Skip arguments N steps forward (or backward), stays inside argv. -*/ -PUBLIC PROCEDURE(spaSkip, (n)) - IN(int, n) -IS { - register int t= pArg+n; - - pArg= ( (t>=pArgC)? pArgC: (t<0? 0: t) ); -} - - -/*====================================================================== - Will walk through the arguments and try to act according to spec's. - Must not be called recursivly. -*/ -PUBLIC int FUNCTION(_spaProcess, (argc, argv, arguments, options, errfun)) - IN(int, argc) X - IN(char, *argv[]) X - IN(_SPA_ITEM, arguments[]) X - IN(_SPA_ITEM, options[]) X - IN(SpaErrFun, *errfun) -IS { - register int a, n; - register char *s; - -#ifdef STDIONONCONST - fileDefault[0].deffile = stdin; - fileDefault[1].deffile = stdout; - if (!SpaAlertFile) SpaAlertFile = stderr; -#endif - - pArgC= argc; - pArgV= (char **)argv; - pOptions= (options? options: biOptions); - pArguments= (arguments? arguments: biArguments); - pErrFun= (errfun? errfun: biErrFun); - - if (!SpaAlertName) { /* If no name given, get it from argv[0] */ - s = strrchr(argv[0], '/'); - SpaAlertName = s? s+1: argv[0]; - } - - for (n= 0; pArguments[n].name; n++) setDefault(&pArguments[n]); - for (a= -1, n= 0; pOptions[n].name; n++) { - setDefault(&pOptions[n]); - if (pOptions[n].type==_SPA_Help) a = n; - } - if (a<0) { /* No help declared */ - pOptions[n] = biOptions[0]; /* Insert builtin d:o */ - } - - for (a= n= 0, pArg= 1; pArg -PUBLIC int FUNCTION(_spaPreProcess, (argc, argv, arguments, options, errfun)) - IN(int, *argc) X - IN(char, **argv[]) X - IN(_SPA_ITEM, arguments[]) X - IN(_SPA_ITEM, options[]) X - IN(SpaErrFun, *errfun) -IS { -#ifdef THINK_C - console_options.title = CurApName; -#endif - *argc = ccommand(argv); - return _spaProcess(*argc, *argv, arguments, options, errfun); -} -#endif - - -/* == EoF =========================================================== */ diff --git a/app/src/main/jni/terps/alan/alan2/stack.c b/app/src/main/jni/terps/alan/alan2/stack.c deleted file mode 100755 index d9616a6..0000000 --- a/app/src/main/jni/terps/alan/alan2/stack.c +++ /dev/null @@ -1,57 +0,0 @@ -/*----------------------------------------------------------------------*\ - - STACK.C - - Stack Handling for Alan interpreter - -\*----------------------------------------------------------------------*/ - - -#include "types.h" -#include "main.h" - -#include "stack.h" - - -/* PRIVATE DATA */ - -#define STACKSIZE 100 - -/* The AMACHINE STACK */ -static Aword stack[STACKSIZE]; -static int stackp = 0; - - -#ifdef _PROTOTYPES_ -void push(Aword i) -#else -void push(i) - Aword i; -#endif -{ - if (stackp == STACKSIZE) - syserr("Out of stack space."); - stack[stackp++] = i; -} - - -#ifdef _PROTOTYPES_ -Aword pop(void) -#else -Aword pop() -#endif -{ - if (stackp == 0) - syserr("Stack underflow."); - return(stack[--stackp]); -} - - -#ifdef _PROTOTYPES_ -Aword top(void) -#else -Aword top() -#endif -{ - return(stack[stackp-1]); -} diff --git a/app/src/main/jni/terps/alan/alan2/stack.h b/app/src/main/jni/terps/alan/alan2/stack.h deleted file mode 100755 index ff6223b..0000000 --- a/app/src/main/jni/terps/alan/alan2/stack.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _STACK_H_ -#define _STACK_H_ -/*----------------------------------------------------------------------*\ - - stack.h - - Header file for stack handler in Alan interpreter - -\*----------------------------------------------------------------------*/ - -/* TYPES */ - -#ifdef _PROTOTYPES_ - -extern Aword pop(void); -extern void push(Aword item); -extern Aword top(void); - -#else -extern Aword pop(); -extern void push(); -extern Aword top(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/sysdep.c b/app/src/main/jni/terps/alan/alan2/sysdep.c deleted file mode 100755 index 326bccb..0000000 --- a/app/src/main/jni/terps/alan/alan2/sysdep.c +++ /dev/null @@ -1,481 +0,0 @@ -/*----------------------------------------------------------------------*\ - sysdep.c - - This file contains necessary system dependent routines and routines - possibly not implemented in the current environment. - - strdup() - - realloc() - strlow() - strupp() - memcpy() - memset() - -\*----------------------------------------------------------------------*/ - -#include -#include "sysdep.h" - -#ifdef GLK -#include "glk.h" -#endif - -#ifdef _PROTOTYPES_ -extern void syserr(char str[]); -#endif - -#ifdef __vms__ - -char *strdup(char str[]) /* IN - String to duplicate */ -{ - char *new = (char *) malloc(strlen(str)+1); - - if (!new) - syserr("Out of memory"); - strcpy(new, str); - return new; -} - -#endif - - -#ifdef __mac__ - -char *strdup(char str[]) /* IN - String to duplicate */ -{ - char *new = (char *) malloc((size_t)((int)strlen(str)+1)); - - if (!new) - syserr("Out of memory"); - strcpy(new, str); - return new; -} - -#endif - - -#ifdef __vms__ - -/* Cheat implementation of strftime */ -size_t strftime ( - char *outbuf, - size_t len, - const char *format, - const struct tm *t) -{ - char buf[100]; - time_t ticks; - - time(&ticks); - strcpy(buf, ctime(&ticks)); - buf[strlen(buf)-1] = '\0'; - strcpy(outbuf, &buf[4]); -} - -#endif - -#ifdef __dos__ -#endif - -#ifdef GLK - -/* Note to Glk maintainers: 'native' characters are used for output, in this - case, Glk's Latin-1. ISO characters are Alan's internal representation, - stored in the .DAT file, and must be converted to native before printing. - Glk could just use the ISO routines directly, but its safer to maintain - its own tables to guard against future changes in either Alan or Glk (ie. a - move to Unicode). - */ - -static char spcChrs[] = -{ - 0x0A, /* linefeed */ - 0x20, /* space */ - 0xA0, /* non-breaking space */ - 0x00 -}; - -static char lowChrs[] = -{ - 0x61, /* a */ 0x62, /* b */ 0x63, /* c */ 0x64, /* d */ - 0x65, /* e */ 0x66, /* f */ 0x67, /* g */ 0x68, /* h */ - 0x69, /* i */ 0x6A, /* j */ 0x6B, /* k */ 0x6C, /* l */ - 0x6D, /* m */ 0x6E, /* n */ 0x6F, /* o */ 0x70, /* p */ - 0x71, /* q */ 0x72, /* r */ 0x73, /* s */ 0x74, /* t */ - 0x75, /* u */ 0x76, /* v */ 0x77, /* w */ 0x78, /* x */ - 0x79, /* y */ 0x7A, /* z */ 0xDF, /* ss */ - 0xE0, /* a grave */ 0xE1, /* a acute */ - 0xE2, /* a circumflex */ 0xE3, /* a tilde */ - 0xE4, /* a diaeresis */ 0xE5, /* a ring */ - 0xE6, /* ae */ 0xE7, /* c cedilla */ - 0xE8, /* e grave */ 0xE9, /* e acute */ - 0xEA, /* e circumflex */ 0xEB, /* e diaeresis */ - 0xEC, /* i grave */ 0xED, /* i acute */ - 0xEE, /* i circumflex */ 0xEF, /* i diaeresis */ - 0xF0, /* */ 0xF1, /* n tilde */ - 0xF2, /* o grave */ 0xF3, /* o acute */ - 0xF4, /* o circumflex */ 0xF5, /* o tilde */ - 0xF6, /* o diaeresis */ 0xF8, /* o slash */ - 0xF9, /* u grave */ 0xFA, /* u acute */ - 0xFB, /* u circumflex */ 0xFC, /* u diaeresis */ - 0xFD, /* y acute */ 0xFE, /* */ - 0xFF, /* y diaeresis */ 0x00 -}; - -/* FIXME: ss and y diaeresis have no UC analogues - Are they really considered LC? - */ - -static char uppChrs[] = -{ - 0x41, /* A */ 0x42, /* B */ 0x43, /* C */ 0x44, /* D */ - 0x45, /* E */ 0x46, /* F */ 0x47, /* G */ 0x48, /* H */ - 0x49, /* I */ 0x4A, /* J */ 0x4B, /* K */ 0x4C, /* L */ - 0x4D, /* M */ 0x4E, /* N */ 0x4F, /* O */ 0x50, /* P */ - 0x51, /* Q */ 0x52, /* R */ 0x53, /* S */ 0x54, /* T */ - 0x55, /* U */ 0x56, /* V */ 0x57, /* W */ 0x58, /* X */ - 0x59, /* Y */ 0x5A, /* Z */ - 0xC0, /* A grave */ 0xC1, /* A acute */ - 0xC2, /* A circumflex */ 0xC3, /* A tilde */ - 0xC4, /* A diaeresis */ 0xC5, /* A ring */ - 0xC6, /* AE */ 0xC7, /* C cedilla */ - 0xC8, /* E grave */ 0xC9, /* E acute */ - 0xCA, /* E circumflex */ 0xCB, /* E diaeresis */ - 0xCC, /* I grave */ 0xCD, /* I acute */ - 0xCE, /* I circumflex */ 0xCF, /* I diaeresis */ - 0xD0, /* */ 0xD1, /* N tilde */ - 0xD2, /* O grave */ 0xD3, /* O acute */ - 0xD4, /* O circumflex */ 0xD5, /* O tilde */ - 0xD6, /* O diaeresis */ 0xD8, /* O slash */ - 0xD9, /* U grave */ 0xDA, /* U acute */ - 0xDB, /* U circumflex */ 0xDC, /* U diaeresis */ - 0xDD, /* Y acute */ 0xDE, /* */ - 0x00 -}; - -#else - -/* Theses work on native character sets */ - -static char spcChrs[] = " \t\n"; - -#ifdef __amiga__ - -/* Which can't read 8-bit chars but is ISO */ -static char lowChrs[] = "abcdefghijklmnopqrstuvwxyz\340\341\342\343\344\345\346\347\351\352\353\354\355\356\357\360\361\362\363\364\365\366\370\371\372\373\374\375\376\377"; - -static char uppChrs[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"; - -#else - -/* Use native characters */ -static char lowChrs[] = "abcdefghijklmnopqrstuvwxyz"; - -static char uppChrs[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - -#endif -#endif - -int isSpace(int c) /* IN - Native character to test */ -{ - return (c != '\0' && strchr(spcChrs, c) != 0); -} - - -int isLower(int c) /* IN - Native character to test */ -{ - return (c != '\0' && strchr(lowChrs, c) != 0); -} - - -int isUpper(int c) /* IN - Native character to test */ -{ - return (c != '\0' && strchr(uppChrs, c) != 0); -} - -int isLetter(int c) /* IN - Native character to test */ -{ - return(c != '\0' && (isLower(c)? !0: isUpper(c))); -} - - -int toLower(int c) /* IN - Native character to convert */ -{ -#ifdef GLK - return glk_char_to_lower(c); -#else -#ifdef __dos__ - char *cp; - - if ((cp = strchr(uppChrs, c)) != 0) - return(lowChrs[cp-uppChrs]); - else - return c; -#else -#ifdef __mac__ - char *cp; - - if ((cp = strchr(uppChrs, c)) != 0) - return(lowChrs[cp-uppChrs]); - else - return c; -#else - return (isUpper(c)? c + ('a' - 'A'): c); -#endif -#endif -#endif -} - -int toUpper(int c) /* IN - Native character to convert */ -{ -#ifdef GLK - return glk_char_to_upper(c); -#else -#ifdef __dos__ - char *cp; - - if ((cp = strchr(lowChrs, c)) != 0) - return(uppChrs[cp-lowChrs]); - else - return c; -#else -#ifdef __mac__ - char *cp; - - if ((cp = strchr(lowChrs, c)) != 0) - return(uppChrs[cp-lowChrs]); - else - return c; -#else - return (isLower(c)? c - ('a' - 'A'): c); -#endif -#endif -#endif -} - -char *strlow(char str[]) /* INOUT - Native string to convert */ -{ - char *s; - - for (s = str; *s; s++) - *s = toLower(*s); - return(str); -} - - -char *strupp(char str[]) /* INOUT - Native string to convert */ -{ - char *s; - - for (s = str; *s; s++) - *s = toUpper(*s); - return(str); -} - - -/* The following work on ISO characters */ - -int isLowerCase(int c) /* IN - ISO character to test */ -{ - static char lowChrs[] = "abcdefghijklmnopqrstuvwxyz\340\341\342\343\344\345\346\347\351\352\353\354\355\356\357\360\361\362\363\364\365\366\370\371\372\373\374\375\376\377"; - return (c != '\0' && strchr(lowChrs, c) != 0); -} - - -int isUpperCase(int c) /* IN - ISO character to test */ -{ - static char uppChrs[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337"; - return (c != '\0' && strchr(uppChrs, c) != 0); -} - - -int isISOLetter(int c) /* IN - ISO character to test */ -{ - return (isLowerCase(c) || isUpperCase(c)); -} - - -char toLowerCase(int c) /* IN - ISO character to convert */ -{ - return (isUpperCase(c)? c + ('a' - 'A'): c); -} - - -char toUpperCase(int c) /* IN - ISO character to convert */ -{ - return (isLowerCase(c)? c - ('a' - 'A'): c); -} - - -char *stringLower(char str[]) /* INOUT - ISO string to convert */ -{ - char *s; - - for (s = str; *s; s++) - *s = toLowerCase(*s); - return(str); -} - - -char *stringUpper(char str[]) /* INOUT - ISO string to convert */ -{ - char *s; - - for (s = str; *s; s++) - *s = toUpperCase(*s); - return(str); -} - - -/*---------------------------------------------------------------------- - toIso - - Converts the incoming string to ISO character set. The original is - in the current character set which in the case of the compiler might - be other than the native. - - */ -void toIso(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset) /* IN - the current character set */ -{ -static unsigned char macMap[256] -= { -0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0A,0x0E,0x0F, -0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, -0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F, -0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F, -0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, -0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F, -0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, -0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F, -0xC4,0xC5,0xC7,0xC9,0xD1,0xD6,0xDC,0xE1,0xE0,0xE2,0xE4,0xE3,0xE5,0xE7,0xE9,0xE8, -0xEA,0xEB,0xED,0xEC,0xEE,0xEF,0xF1,0xF3,0xF2,0xF4,0xF6,0xF5,0xFA,0xF9,0xFB,0xFC, -0xB9,0xB0,0xA2,0xA3,0xA7,0xB7,0xB6,0xDF,0xAE,0xA9,0xB2,0xB4,0xA8,0xD7,0xC6,0xD8, -0xA4,0xB1,0xCD,0xCC,0xA5,0xB5,0xF0,0xCA,0xDE,0xFE,0xA6,0xAA,0xBA,0xD4,0xE6,0xF8, -0xBF,0xA1,0xAC,0xCE,0xCF,0xC8,0xD0,0xAB,0xBB,0xCB,0xA0,0xC0,0xC3,0xD5,0xDD,0xFD, -0xAD,0xAF,0xDA,0xD9,0xB8,0xB3,0xF7,0xC2,0xFF,0xBC,0xBD,0xBE,0xC1,0xD2,0xD3,0xDB, -0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, -0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F}; - -static unsigned char dosMap[256] -= { -0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0A,0x0E,0x0F, -0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, -0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F, -0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F, -0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, -0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F, -0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, -0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F, -0xC7,0xFC,0xE9,0xE2,0xE4,0xE0,0xE5,0xE7,0xEA,0xEB,0xE8,0xEF,0xEE,0xEC,0xC4,0xC5, -0xC9,0xE6,0xC6,0xF4,0xF6,0xF2,0xFB,0xF9,0xFF,0xD6,0xDC,0xA2,0xA3,0xA5,0xDE,0xA6, -0xE1,0xED,0xF3,0xFA,0xF1,0xD1,0xAA,0xBA,0xBF,0xC0,0xC1,0xBD,0xBC,0xCF,0xAB,0xBB, -0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x8A,0x8B,0x8C,0x8D,0x8E,0x8F, -0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97,0x98,0x99,0x9A,0x9B,0x9C,0x9D,0x9E,0x9F, -0xA1,0xA7,0xAD,0xB3,0xB8,0xB9,0xC3,0xCE,0xD2,0xD3,0xDB,0xDD,0xE3,0xF5,0xF8,0xFD, -0xA9,0xDF,0xC8,0xB6,0xCA,0xA4,0xB5,0xAE,0xD5,0xD0,0xD4,0xF0,0xD7,0xD8,0xCB,0xC2, -0xBE,0xB1,0xD9,0xDA,0xCD,0xCC,0xF7,0xA8,0xB0,0xB7,0xAF,0xAC,0xFE,0xB2,0xB4,0xA0}; - unsigned char *o, *c; - - switch (charset) { - case 0: /* ISO */ - if (copy != original) - (void)strcpy(copy, original); - break; - case 1: /* Mac */ - for (o = (unsigned char *)original, c = (unsigned char *)copy; *o; o++, c++) - *c = macMap[*o]; - *c = '\0'; - break; - - case 2: /* Dos */ - for (o = (unsigned char *)original, c = (unsigned char *)copy; *o; o++, c++) - *c = dosMap[*o]; - *c = '\0'; - break; - } -} - -/*---------------------------------------------------------------------- - - fromIso - - Converts a string from global Iso format to native. Only used in - interpreter so character set is known at compile time. - - */ -void fromIso(char copy[], /* OUT - Mapped string */ - char original[]) /* IN - string to convert */ -{ -#if ISO == 0 - static unsigned char map[256] -#if defined __mac__ - = { - 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0D,0x0B,0x0C,0x0D,0x0E,0x0F, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, - 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F, - 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F, - 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, - 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F, - 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, - 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F, - 0xE0,0xE1,0xE2,0xE3,0xE4,0xE5,0xE6,0xE7,0xE8,0xE9,0xEA,0xEB,0xEC,0xED,0xEE,0xEF, - 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF, - 0xCA,0xC1,0xA2,0xA3,0xB0,0xB4,0xBA,0xA4,0xAC,0xA9,0xBB,0xC7,0xC2,0xD0,0xA8,0xD1, - 0xA1,0xB1,0xAA,0xD5,0xAB,0xB5,0xA6,0xA5,0xD4,0xA0,0xBC,0xC8,0xD9,0xDA,0xDB,0xC0, - 0xCB,0xDC,0xD7,0xCC,0x80,0x81,0xAE,0x82,0xC5,0x83,0xB7,0xC9,0xB3,0xB2,0xC3,0xC4, - 0xC6,0x84,0xDD,0xDE,0xBD,0xCD,0x85,0xAD,0xAF,0xD3,0xD2,0xDF,0x86,0xCE,0xB8,0xA7, - 0x88,0x87,0x89,0x8B,0x8A,0x8C,0xBE,0x8D,0x8F,0x8E,0x90,0x91,0x93,0x92,0x94,0x95, - 0xB6,0x96,0x98,0x97,0x99,0x9B,0x9A,0xD6,0xBF,0x9D,0x9C,0x9E,0x9F,0xCF,0xB9,0xD8} -#else -#if defined __dos__ - = { - 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0D,0x0B,0x0C,0x0D,0x0E,0x0F, - 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F, - 0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27,0x28,0x29,0x2A,0x2B,0x2C,0x2D,0x2E,0x2F, - 0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x3A,0x3B,0x3C,0x3D,0x3E,0x3F, - 0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4A,0x4B,0x4C,0x4D,0x4E,0x4F, - 0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5A,0x5B,0x5C,0x5D,0x5E,0x5F, - 0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x6A,0x6B,0x6C,0x6D,0x6E,0x6F, - 0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7A,0x7B,0x7C,0x7D,0x7E,0x7F, - 0xB0,0xB1,0xB2,0xB3,0xB4,0xB5,0xB6,0xB7,0xB8,0xB9,0xBA,0xBB,0xBC,0xBD,0xBE,0xBF, - 0xC0,0xC1,0xC2,0xC3,0xC4,0xC5,0xC6,0xC7,0xC8,0xC9,0xCA,0xCB,0xCC,0xCD,0xCE,0xCF, - 0xFF,0xD0,0x9B,0x9C,0xE5,0x9D,0x9F,0xD1,0xF7,0xE0,0xA6,0xAE,0xFB,0xD2,0xE7,0xFA, - 0xF8,0xF1,0xFD,0xD3,0xFE,0xE6,0xE3,0xF9,0xD4,0xD5,0xA7,0xAF,0xAC,0xAB,0xF0,0xA8, - 0xA9,0xAA,0xEF,0xD6,0x8E,0x8F,0x92,0x80,0xE2,0x90,0xE4,0xEE,0xF5,0xF4,0xD7,0xAD, - 0xE9,0xA5,0xD8,0xD9,0xEA,0xE8,0x99,0xEC,0xED,0xF2,0xF3,0xDA,0x9A,0xDB,0x9E,0xE1, - 0x85,0xA0,0x83,0xDC,0x84,0x86,0x91,0x87,0x8A,0x82,0x88,0x89,0x8D,0xA1,0x8C,0x8B, - 0xEB,0xA4,0x95,0xA2,0x93,0xDD,0x94,0xF6,0xDE,0x97,0xA3,0x96,0x81,0xDF,0xFC,0x98} -#endif - ; -#endif - unsigned char *o, *c; - - for (o = (unsigned char *)original, c = (unsigned char *)copy; *o; o++, c++) - *c = map[*o]; - *c = '\0'; -#else - if (copy != original) - (void)strcpy(copy, original); -#endif -} - - -/*---------------------------------------------------------------------- - toNative - - Converts the incoming string to the native character set from any of - the others. The original is in the current character set which in - the case of the compiler might be other than the native. - - */ -void toNative(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset) /* IN - the current character set */ -{ - toIso(copy, original, charset); - if (NATIVECHARSET != 0) - fromIso(copy, copy); -} diff --git a/app/src/main/jni/terps/alan/alan2/sysdep.h b/app/src/main/jni/terps/alan/alan2/sysdep.h deleted file mode 100755 index 5cb3f2a..0000000 --- a/app/src/main/jni/terps/alan/alan2/sysdep.h +++ /dev/null @@ -1,364 +0,0 @@ -/*----------------------------------------------------------------------*\ - - sysdep.h Date: 1995-08-19/thoni@softlab.se - - System dependencies file for Alan Adventure Language system - - N.B. The test for symbols used here should really be of three types - - processor name (like PC, x86, ...) - - os name (DOS, WIN32, Solaris2, ...) - - compiler name and version (DJGPP, CYGWIN, GCC271, THINK-C, ...) - - The set symbols should indicate if a feature is on or off like the GNU - AUTOCONFIG package does. - - This is not completely done yet! - -\*----------------------------------------------------------------------*/ -#ifndef _SYSDEP_H_ -#define _SYSDEP_H_ - - -/* Place definitions of OS and compiler here if necessary */ -#ifdef AZTEC_C -#define __amiga__ -#endif - -#ifndef __sun__ -#ifdef sun -#define __sun__ -#endif -#endif - -#ifdef _INCLUDE_HPUX_SOURCE -#define __hp__ -#endif - -#ifndef __unix__ -#ifdef unix -#define __unix__ -#endif -#endif - -#ifdef vax -#define __vms__ -#endif - -#ifdef THINK_C -#define __mac__ -#endif - -#ifdef __MWERKS__ -#ifdef macintosh -#define __mac__ -#else -#define __dos__ -#endif -#endif - -#ifdef DOS -#define __dos__ -#endif - -#ifdef __BORLANDC__ -#define __dos__ -#endif - -#ifdef __CYGWIN__ -#define __win__ -#endif - -#ifdef __MINGW32__ -#define __win__ -#endif - -#ifdef __PACIFIC__ -#define __dos__ -#define HAVE_SHORT_FILENAMES -#endif - - -/*---------------------------------------------------------------------- - - Below follows OS and compiler dependent settings. They should not be - changed except for introducing new sections when porting to new - environments. - - */ - -/************/ -/* Includes */ -/************/ - -#include -#include - -#ifdef __STDC__ -#define _PROTOTYPES_ -#include -#include -#endif - -#ifdef __vms__ -/* Our VAXC doesn't define __STDC__ */ -#define _PROTOTYPES_ -#include -#include -#endif - - -#ifdef __mac__ -#define _PROTOTYPES_ -#include -#include -#include -#endif - -#ifdef __MWERKS__ -#define strdup _strdup -#endif - -/***********************/ -/* ISO character sets? */ -/***********************/ - -/* Common case first */ -#define ISO 1 -#define NATIVECHARSET 0 - -#ifdef GLK -#undef ISO -#define ISO 1 -#undef NATIVECHARSET -#define NATIVECHARSET 0 -#else /* Glk is ISO, no matter what the OS */ - -#ifdef __dos__ -#undef ISO -#define ISO 0 -#undef NATIVECHARSET -#define NATIVECHARSET 2 -#endif - -#ifdef __win__ -#undef ISO -#define ISO 1 -#undef NATIVECHARSET -#define NATIVECHARSET 2 -#endif - -#ifdef __mac__ -#undef ISO -#define ISO 0 -#undef NATIVECHARSET -#define NATIVECHARSET 1 -#endif - -#endif - -/**************************/ -/* Strings for file modes */ -/**************************/ -#define READ_MODE "r" -#define WRITE_MODE "w" - -#ifdef __mac__ -/* File open mode (binary) */ -#undef READ_MODE -#define READ_MODE "rb" -#undef WRITE_MODE -#define WRITE_MODE "wb" -#endif - -#ifdef __dos__ -/* File open mode (binary) */ -#undef READ_MODE -#define READ_MODE "rb" -#undef WRITE_MODE -#define WRITE_MODE "wb" -#endif - -#ifdef __win__ -/* File open mode (binary) */ -#undef READ_MODE -#define READ_MODE "rb" -#undef WRITE_MODE -#define WRITE_MODE "wb" -#endif - -/*****************/ -/* Byte ordering */ -/*****************/ - -#ifdef __dos__ -#define REVERSED -#endif - -#ifdef __vms__ -#define REVERSED -#endif - -#ifdef __win__ -#define REVERSED -#endif - - -/****************************/ -/* Allocates cleared bytes? */ -/****************************/ - -#ifdef __CYGWIN__ -#define NOTCALLOC -#endif - -#ifdef __MINGW32__ -#define NOTCALLOC -#endif - -#ifdef __unix__ -#define NOTCALLOC -#endif - - -/****************/ -/* Have termio? */ -/****************/ - -#ifdef GLK -/* don't need TERMIO */ -#else - -#ifdef __CYGWIN__ -#define HAVE_TERMIO -#endif - -#ifdef __unix__ -#define HAVE_TERMIO -#endif - -#endif - -/*******************************/ -/* Is ANSI control available? */ -/*******************************/ - -#ifdef GLK -/* don't need ANSI */ -#else - -#ifdef __CYGWIN__ -#define HAVE_ANSI -#endif - -#endif - -/******************************/ -/* Use the READLINE function? */ -/******************************/ - -#ifdef GLK -/* Glk always uses readline(), no matter what the OS */ -#define USE_READLINE -#else - -#ifdef __unix__ -#define USE_READLINE -#endif - -#ifdef x__dos__ -#define USE_READLINE -#endif - -#ifdef __win__ -#define USE_READLINE -#endif - -#endif - -/* Special cases and definition overrides */ -#ifdef __unix__ -#define MULTI -#endif - - - - -#ifdef __vms__ - -#define MULTI - -extern char *strdup(char str[]); - -/* Cheat implementation of strftime */ -extern size_t strftime (char *, size_t, const char *, const struct tm *); - -#endif - -#ifdef __mac__ - -extern char *strdup(char *str); - -#endif - - -#ifdef __dos__ - -/* Return codes */ -#define EXIT_SUCCESS 0 -#define EXIT_FAILURE 1 - -#endif - - -#ifdef _PROTOTYPES_ - -/* Native character functions */ -extern int isSpace(int c); /* IN - Native character to test */ -extern int isLower(int c); /* IN - Native character to test */ -extern int isUpper(int c); /* IN - Native character to test */ -extern int isLetter(int c); /* IN - Native character to test */ -extern int toLower(int c); /* IN - Native character to convert */ -extern int toUpper(int c); /* IN - Native character to convert */ -extern char *strlow(char str[]); /* INOUT - Native string to convert */ -extern char *strupp(char str[]); /* INOUT - Native string to convert */ - -/* ISO character functions */ -extern int isISOLetter(int c); /* IN - ISO character to test */ -extern char toLowerCase(int c); /* IN - ISO character to convert */ -extern char toUpperCase(int c); /* IN - ISO character to convert */ -extern char *stringLower(char str[]); /* INOUT - ISO string to convert */ -extern char *stringUpper(char str[]); /* INOUT - ISO string to convert */ - -/* ISO string conversion functions */ -extern void toIso(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset); /* IN - The current character set */ - -extern void fromIso(char copy[], /* OUT - Mapped string */ - char original[]); /* IN - string to convert */ - -extern void toNative(char copy[], /* OUT - Mapped string */ - char original[], /* IN - string to convert */ - int charset); /* IN - current character set */ -#else -extern int isSpace(); -extern int isLower(); -extern int isUpper(); -extern int isLetter(); -extern int toLower(); -extern int toUpper(); -extern char *strlow(); -extern char *strupp(); - -extern int isISOLetter(); -extern char toLowerCase(); -extern char toUpperCase(); -extern char *stringLower(); -extern char *stringUpper(); - -extern void toIso(); -extern void fromIso(); -#endif - -#endif /* -- sysdep.h -- */ - diff --git a/app/src/main/jni/terps/alan/alan2/term.c b/app/src/main/jni/terps/alan/alan2/term.c deleted file mode 100755 index 5347ee2..0000000 --- a/app/src/main/jni/terps/alan/alan2/term.c +++ /dev/null @@ -1,105 +0,0 @@ -/*----------------------------------------------------------------------*\ - - term.c - - System dependent terminal oriented functions for ALAN interpreter ARUN - -\*----------------------------------------------------------------------*/ - -#include "main.h" - -#include "term.h" - - -/*====================================================================== - - getPageSize() - - Try to get the current page size from the system, else use the ones - from the header. - - */ -#ifdef _PROTOTYPES_ -void getPageSize(void) -#else -void getPageSize() -#endif -{ -#ifdef GLK - paglen = 0; - pagwidth = 0; - -#else -#ifdef HAVE_TERMIO - -#include - - extern int ioctl(); - - struct winsize win; - int ecode; - - ecode = ioctl(1, TIOCGWINSZ, &win); - - if (ecode != 0 || win.ws_row == 0) - paglen = header->paglen; - else - paglen = win.ws_row; - - if (ecode != 0 || win.ws_col == 0) - pagwidth = header->pagwidth; - else - pagwidth = win.ws_col; - -#else -#ifdef __amiga__ -#include -#include -#include -#include - - struct Process * proc; - struct InfoData *id; - struct Window *win; - struct TextFont *textFont; - struct StandardPacket *packet; - - proc = (struct Process *) FindTask(0L); - - id = (struct InfoData *) allocate(sizeof(struct InfoData)); - - if (proc->pr_ConsoleTask) { - packet = (struct StandardPacket *) allocate(sizeof(struct StandardPacket)); - packet->sp_Msg.mn_Node.ln_Name = (char *)&(packet->sp_Pkt); - packet->sp_Pkt.dp_Link = & packet->sp_Msg; - packet->sp_Pkt.dp_Port = & proc->pr_MsgPort; - packet->sp_Pkt.dp_Type = ACTION_DISK_INFO; - - packet->sp_Pkt.dp_Arg1 = ((LONG) id) >> 2; - - PutMsg ((struct MsgPort *) proc->pr_ConsoleTask, & packet->sp_Msg); - WaitPort(&proc->pr_MsgPort); - GetMsg(&proc->pr_MsgPort); - free((char *)packet); - - win = (struct Window *) id->id_VolumeNode; - free(id); - - /* Calculate number of characters and lines w.r.t font size and borders */ - textFont = win->IFont; - paglen = win->Height/textFont->tf_YSize-2; - pagwidth = win->Width/textFont->tf_XSize-3; - } else { - paglen = header->paglen; - pagwidth = header->pagwidth; - } - -#else - - paglen = header->paglen; - pagwidth = header->pagwidth; - -#endif -#endif -#endif -} diff --git a/app/src/main/jni/terps/alan/alan2/term.h b/app/src/main/jni/terps/alan/alan2/term.h deleted file mode 100755 index d7368ed..0000000 --- a/app/src/main/jni/terps/alan/alan2/term.h +++ /dev/null @@ -1,20 +0,0 @@ -#ifndef TERM -#define TERM -/*----------------------------------------------------------------------*\ - - term.h - - Header file for terminal functions in ARUN, the Alan interpreter - -\*----------------------------------------------------------------------*/ - - -#ifdef _PROTOTYPES_ - -extern void getPageSize(void); - -#else -extern void getPageSize(); -#endif - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/types.h b/app/src/main/jni/terps/alan/alan2/types.h deleted file mode 100755 index 20cc627..0000000 --- a/app/src/main/jni/terps/alan/alan2/types.h +++ /dev/null @@ -1,266 +0,0 @@ -#ifndef _ATYPES_H_ -#define _ATYPES_H_ -/*----------------------------------------------------------------------*\ - - types.h - - Header file for the Alan interpreter module. - -\*----------------------------------------------------------------------*/ - - -#include "sysdep.h" -#include "acode.h" - - -/* CONSTANTS */ - -#ifndef __mac__ -#ifndef TRUE -#define TRUE (0==0) -#endif -#ifndef FALSE -#define FALSE (!TRUE) -#endif -#endif - -#define ACTMIN (header->actmin) -#define ACTMAX (header->actmax) -#define OBJMIN (header->objmin) -#define OBJMAX (header->objmax) -#define LOCMIN (header->locmin) -#define LOCMAX (header->locmax) -#define CNTMIN (header->cntmin) -#define CNTMAX (header->cntmax) -#define LITMIN (header->locmax+1) -#define LITMAX (header->locmax+1+litCount) -#define EVTMIN (header->evtmin) -#define EVTMAX (header->evtmax) - -#define HERO ACTMIN - - -#define addrTo(x) (&memory[x]) - -/* The word classes are represented as numbers but in the dictonary they are generated as bits */ -#define isVerb(word) (word < dictsize && (dict[word].class&((Aword)1L<= dictsize) - - -/* TYPES */ - -#ifndef __mac__ -typedef int Boolean; /* Boolean values within interpreter */ -#endif - -/* Amachine variables */ -typedef struct CurVars { - int - vrb, - obj, - loc, - act, - tick, - score, - visits; -} CurVars; - -/* The various tables */ -typedef struct WrdElem { /* Dictionary */ - Aaddr wrd; /* ACODE address to string */ - Aword class; /* Word class */ - Aword code; - Aaddr adjrefs; /* Address to reference list */ - Aaddr nounrefs; /* Address to reference list */ -} WrdElem; - -typedef struct ActElem { /* ACTOR TABLE */ - Aword loc; /* Location */ - Abool describe; /* Description flag */ - Aaddr nam; /* Address to name printing code */ - Aaddr atrs; /* Address to attribute list */ - Aword cont; /* Code for the container props if any */ - Aword script; /* Which script is he using */ - Aaddr scradr; /* Address to script table */ - Aword step; - Aword count; - Aaddr vrbs; - Aaddr dscr; /* Address of description code */ -} ActElem; - -typedef struct ScrElem { /* SCRIPT TABLE */ - Aword code; /* Script number */ - Aaddr dscr; /* Optional description statements */ - Aaddr steps; /* Address to steps */ -} ScrElem; - -typedef struct StepElem { /* STEP TABLE */ - Aword after; /* After how many ticks? */ - Aaddr exp; /* Address to expression saying when */ - Aaddr stm; /* Address to the actual code */ -} StepElem; - -typedef struct LocElem { /* LOCATION TABLE */ - Aaddr nams; /* Address of name printing code */ - Aaddr dscr; /* Address of description code */ - Aaddr does; /* Address of does code */ - Aword describe; /* Description flag & counter */ - Aaddr atrs; /* Address of attribute list */ - Aaddr exts; /* Address of exit list */ - Aaddr vrbs; /* Address of local verb list */ -} LocElem; - -typedef struct ExtElem { /* EXIT TABLE structure */ - Abool done; /* Flag for reverse/convert process */ - Aword code; /* Direction code */ - Aaddr checks; /* Address of check table */ - Aaddr action; /* Address of action code */ - Aword next; /* Number of next location */ -} ExtElem; - -typedef struct ChkElem { /* CHECK TABLE */ - Aaddr exp; /* ACODE address to expression code */ - Aaddr stms; /* ACODE address to statement code */ -} ChkElem; - -typedef struct VrbElem { /* VERB TABLE */ - Aword code; /* Code for the verb */ - Aaddr alts; /* Address to alternatives */ -} VrbElem; - -typedef struct StxElem { /* SYNTAX TABLE */ - Aword code; /* Code for verb word */ - Aaddr elms; /* Address to element tables */ -} StxElem; - -typedef struct ElmElem26 { /* ELEMENT TABLES */ - Aword code; /* Code for this element, 0 -> parameter */ - Abool multiple; /* May be multiple (if parameter) */ - Aaddr next; /* Address to next element table ... */ - /* ... or class check if EOS */ -} ElmElem26; - -typedef struct ElmElem { /* ELEMENT TABLES */ - Aword code; /* Code for this element, 0 -> parameter */ - Aword flags; /* Flags for multiple/omni (if parameter) */ - /* CHANGED: v2.7 from Abool for multiple */ - Aaddr next; /* Address to next element table ... */ - /* ... or class check if EOS */ -} ElmElem; - -typedef struct ClaElem { /* CLASS DEFINITION TABLE */ - Aword code; /* Parameter number */ - Aword classes; /* Parameter classes */ - Aaddr stms; /* Exception statements */ -} ClaElem; - -typedef struct AltElem { /* VERB ALTERNATIVE TABLE */ - Abool done; /* Flag for patching (reverse/convert) process */ - Aword param; /* Parameter number */ - Aword qual; /* Verb execution qualifier */ - Aaddr checks; /* Address of the check table */ - Aaddr action; /* Address of the action code */ -} AltElem; - -typedef struct AtrElem { /* ATTRIBUTE LIST */ - Aword val; /* Its value */ - Aaddr stradr; /* Address to the name */ -} AtrElem; - -typedef struct ObjElem25 { /* OBJECT TABLE of 2.5 format*/ - Aword loc; /* Current location */ - Abool describe; /* Describe flag */ - Aaddr atrs; /* Address of attribute list */ - Aword cont; /* Index to container properties if any */ - Aaddr vrbs; /* Address to local verb table */ - Aaddr dscr1; /* Address to Aword description code */ - Aaddr dscr2; /* Address to short description code */ -} ObjElem25; - -typedef struct ObjElem { /* OBJECT TABLE */ - Aword loc; /* Current location */ - Abool describe; /* Describe flag */ - Aaddr atrs; /* Address of attribute list */ - Aword cont; /* Index to container properties if any */ - Aaddr vrbs; /* Address to local verb table */ - Aaddr dscr1; /* Address to Aword description code */ - Aaddr art; /* Article printing code? Else use default */ - /* INTRODUCED: v2.6 */ - Aaddr dscr2; /* Address to short description code */ -} ObjElem; - -typedef struct CntElem { /* CONTAINER TABLE */ - Aaddr lims; /* Address to limit check code */ - Aaddr header; /* Address to header code */ - Aaddr empty; /* Address to empty code */ - Aword parent; /* Object or actor index */ - Aaddr nam; /* Address to statement printing name */ -} CntElem; - -typedef struct LimElem { /* LIMIT Type */ - Aword atr; /* Attribute that limits */ - Aword val; /* And the limiting value */ - Aaddr stms; /* Statements if fail */ -} LimElem; - -typedef struct RulElem { /* RULE TABLE */ - Abool run; /* Is rule already run? */ - Aaddr exp; /* Address to expression code */ - Aaddr stms; /* Address to run */ -} RulElem; - -typedef struct EvtElem { /* EVENT TABLE */ - Aaddr stradr; /* Address to name string */ - Aaddr code; /* Address of code to run */ -} EvtElem; - -typedef struct EvtqElem { /* EVENT QUEUE ELEMENT */ - int time; - int event; - int where; -} EvtqElem; - -typedef struct IniElem { /* STRING INITIALISATION TABLE */ - Aword fpos; /* File position */ - Aword len; /* Length */ - Aword adr; /* Where to store the string */ -} IniElem; - -typedef struct MsgElem26 { /* MESSAGE TABLE */ - Aword fpos; /* File position */ - Aword len; /* Length of message */ -} MsgElem26; - -typedef struct MsgElem { /* MESSAGE TABLE */ - Aaddr stms; /* Address to statements*/ - /* Changed v2.7 from fpos+len in .dat */ -} MsgElem; - - -typedef struct ParamElem { /* PARAMETER */ - Aword code; /* Code for this parameter (0=multiple) */ - Aword firstWord; /* Index to first word used by player */ - Aword lastWord; /* d:o to last */ -} ParamElem; - -typedef enum Type {TYPNUM, TYPSTR} Type; - -typedef struct LitElem { /* LITERAL */ - Type type; - Aword value; -} LitElem; - -#define MAXPARAMS 9 -#define MAXENTITY (header->actmax) - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/version.h b/app/src/main/jni/terps/alan/alan2/version.h deleted file mode 100755 index f5d724c..0000000 --- a/app/src/main/jni/terps/alan/alan2/version.h +++ /dev/null @@ -1,28 +0,0 @@ -#ifndef _version_h_ -#define _version_h_ 1 - -#include - -typedef struct { - char* string; - int version; - int revision; - int correction; - time_t time; - char* state; -} Version; - -typedef struct { - char* name; - char* slogan; - char* shortHeader; - char* longHeader; - char* date; - char* time; - char* user; - char* host; - char* ostype; - Version version; -} Product; - -#endif diff --git a/app/src/main/jni/terps/alan/alan2/winglk.c b/app/src/main/jni/terps/alan/alan2/winglk.c deleted file mode 100755 index f519c48..0000000 --- a/app/src/main/jni/terps/alan/alan2/winglk.c +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Windows MFC GLK Libraries - * Startup code for Glk applications - */ - -#include -#include "Glk.h" -#include "WinGlk.h" - -int InitGlk(unsigned int iVersion); - -/* Entry point for all Glk applications */ -int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) -{ - /* Attempt to initialise Glk */ - if (InitGlk(0x00000601) == 0) - exit(0); - - /* Call the Windows specific initialization routine */ - if (winglk_startup_code(lpCmdLine) != 0) - { - /* Run the application */ - glk_main(); - - /* There is no return from this routine */ - glk_exit(); - } - - return 0; -} - - diff --git a/app/src/main/jni/terps/alan/alan3/.drone.yml b/app/src/main/jni/terps/alan/alan3/.drone.yml deleted file mode 100644 index 8ba1e9f..0000000 --- a/app/src/main/jni/terps/alan/alan3/.drone.yml +++ /dev/null @@ -1,27 +0,0 @@ -build: - image: xenial - env: - - LD_LIBRARY_PATH=/usr/local/lib - commands: - - sudo apt-get -q update - - sudo apt-get -q autoremove - - sudo DEBIAN_FRONTEND=noninteractive apt-get -q install libc6-dev-i386 - - sudo DEBIAN_FRONTEND=noninteractive apt-get -q install zip - - sudo DEBIAN_FRONTEND=noninteractive apt-get -q install wget - - wget https://github.com/cgreen-devs/cgreen/releases/download/1.0.0/cgreen_1.0.0_amd64.deb - - sudo dpkg -D1 -i cgreen_1.0.0_amd64.deb - - echo $BUILD_ID > BUILD_NUMBER - - make unit - - make build - - make JREGROUTPUT=-noansi test - - make package -notify: - slack: - webhook_url: 'https://hooks.slack.com/services/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' - username: 'drone' - channel: '#general' - template: > - Alan build #{{ build.number }} finished with a {{ build.status }} status - on_started: false - on_success: true - on_failure: true diff --git a/app/src/main/jni/terps/alan/alan3/.gitignore b/app/src/main/jni/terps/alan/alan3/.gitignore deleted file mode 100644 index 6711638..0000000 --- a/app/src/main/jni/terps/alan/alan3/.gitignore +++ /dev/null @@ -1,16 +0,0 @@ -*.zip -*.a3c -*.a3r -*.ifid -TEST-*.xml -*.output -*.log -*.tmp -*.vg -*.leaks -alan*linux.x86.tgz -BUILD_NUMBER -gargoyle-alan3_tmp.iss -*.o -*.dll -*.dat diff --git a/app/src/main/jni/terps/alan/alan3/BRANCHES b/app/src/main/jni/terps/alan/alan3/BRANCHES deleted file mode 100755 index 27f5468..0000000 --- a/app/src/main/jni/terps/alan/alan3/BRANCHES +++ /dev/null @@ -1,144 +0,0 @@ -This file attempts to describe how tags and branches are used to allow -making of releases, porting and other CM stuff. - -"make release" - - always checks that appropriate executables in the export - directory ($ALANDIR/bin/*) are up-to-date in respect to the - source files, you can't do a release if they are not (in that - case you have to make them...) - - A tag (vXYZ) is set at the current HEAD in the main branch, a - branch tag is also set here (vXYZ_branch) - - The file LASTRELEASE will contain the venum of the last - released version on the current branch. Finally the venum is - upgraded and committed (the next build will make - - vX.Y.(Z+1) - - Then that upcoming version is written to the file NEXTRELEASE. - - -"make " - - for NFS mounted platforms a build with the correct make - options are performed - - for amiga, pc etc. sources are exported from the tags as above - and sources packaged (or whatever). Tags (such as vXYZamiga) - are also set to indicated the place where the sources was taken. - - -The above scheme will make it possible to add changes done later to -the branches and then carefully merging them into the main branch. The -scheme for this is to add both a branch tag (vXYZ_branch) and -a specific tag (vXYZ) at the point where the sources was -taken. The source on that branch can then be checked out and changes -added and committed. The HEAD of the branch (the vXYZ_branch -tag) will now refer to *all* the changes performed on that branch. - -The merge can now be performed at anytime in the trunk by performing -the following command in a working directory on the trunk - - cvs update -jvXYZ -jvXYZ_branch - -This should introduce all changes performed on the branch for -into the sources in the working directory, tested and committed. - -To ensure that it is possible to continue doing changes on the branch -the source tag (vXYZ) should be moved to the current HEAD of -the branch vXYZ_branch. This is performed by - - cvs rtag -F -r vXYZ vXYZ_base - cvs rtag -F -r vXYZ_branch vXYZ - -The next time a branch is changed, just follow the same procedure... - - -Illustrations (uses RCS revision numbers which are just markers of no -other significance): - -A) After a "make release" (vXYZ) and "make " (vXYZ): - - --- tags: vXYZ & vXYZ - | - | - | - | - V -1.1----1.2 - - -B) After creating the vXYZ_branch and committing changes on it: - - --- tags: vXYZ & vXYZ - | - | 1.2.0.1----1.2.0.2----1.2.0.3 <---- vXYZ_branch - | / - | / - V/ -1.1----1.2 <---- trunk, main branch - - -C) After committing changes on the main trunk: - - --- tags: vXYZ & vXYZ - | - | - | 1.2.0.1----1.2.0.2----1.2.0.3 <---- vXYZ_branch - | / - | / - V/ -1.1----1.2----1.3----1.4----1.5 <---- trunk, main branch - - -D) The changes made on the branch is 1.2.0.3 - 1.2.0.1, or the -difference between vXYZ and the HEAD of the -vXYZ_branch, which is easily merged into a working directory -on the trunk: - - --- tags: vXYZ & vXYZ - | - | - | 1.2.0.1----1.2.0.2----1.2.0.3 <---- vXYZ_branch - | / < > - | / <------------------+---> - V/ | -1.1----1.2----1.3----1.4----1.5--+-1.6 <---- trunk, main branch - - -E) The vXYZ tag must now be moved so we know where to start -diffing the next time: - - ---- tag: vXYZ ----vXYZ - | | - | V - | 1.2.0.1----1.2.0.2----1.2.0.3 <---- vXYZ_branch - | / < > - | / <------------------+--> - V/ | -1.1----1.2----1.3----1.4----1.5--+-1.6 <---- trunk, main branch - - -F) Further changes on the vXYZ_branch can now be merged into the -trunk as before, diffing vXYZ with the HEAD of the branch: - - ---- tag: vXYZ ----vXYZ - | | - | V - | 1.2.0.1----1.2.0.2----1.2.0.3----1.2.0.4 - | / < diff/merge > < diff/merge > - | / <-------------------+> <-----------+> - V/ | | -1.1----1.2----1.3----1.4----1.5---+-1.6-----------+-1.7 <---- trunk, main branch - -G) Etc. If a new "make release" or "make " is performed -where back at B). - - -NOTE that this currently does not handle the case where we have -multiple portings going on for the same correction and platform, -because a new "make " moves the vXYZ forward to a -new position and this removes any possibilities to add changes on the -previous vXYZ_branch from which some sources where exported. diff --git a/app/src/main/jni/terps/alan/alan3/CHANGES b/app/src/main/jni/terps/alan/alan3/CHANGES deleted file mode 100755 index 68f79a5..0000000 --- a/app/src/main/jni/terps/alan/alan3/CHANGES +++ /dev/null @@ -1,277 +0,0 @@ -Changes in V3.0beta5: -- FEATURE: compiler now figures out the most general class taken transitively by containers and uses that instead of entity where applicable -- FEATURE: MacOS application to run text-only interpreter in a terminal -- BUGFIX: if the hero was already defined as something other than an actor, declaring it the compiler crashed -- CLEANUP: rebuilt Makefiles building on Windows10 and 64-bit, continuous integration with Jenkins etc. etc. after move to new machines and other infrastructure - -Changes in V3.0beta4: -- MAJOR FEATURE: 'Indirectly' keyword to complement 'Directly In', allowing explicit transitivity of containment -- FEATURE: The hero is now a container by default -- FEATURE: The hero may inherit from any subclass of actor -- FEATURE: Actor scripts are now aborted if an error, such as an extraction failure, occurs -- FEATURE: Debugger shows symbolic name of events when tracing -- FEATURE: WinAlan now generates the output file in the correct directory if a source file is dropped on the WinAlan icon -- BUGFIX: Locating something inside itself hanged the interpreter, now generates controlled Application Error -- BUGFIX: For Each loops with In-filters did not take transitivity into account, might now detect more errors -- BUGFIX: Initial locations in containers did not consider the Taking of the container -- BUGFIX: Debugger section trace crashed on verb bodies in locations - -Changes in V3.0beta3: -- MAJOR FEATURE: the class of parameters and locals can now be asserted using If .. Isa .. allowing general restrictions in parameter restrictions and more specific access (attributes, scripts, containers) with the If-statement -- FEATURE: Attributes from entity can now be referenced for literals -- FEATURE: Debugger now has a command to toggle a levels of trace off and on -- FEATURE: Debugger now lists the programmer name of instances as well as the player name -- FEATURE: Debugger can now list instances matching a wildcard pattern ("instance a*") -- FEATURE: Compiler now flags all occurrences of a multiply defined identifier -- BUGFIX: Out of memory error in interpreter for very large game fixed -- BUGFIX: sometimes locating a location At itself crashed the interpreter -- BUGFIX: comparing strings with '<>' did not work -- BUGFIX: using a location identifier as a direction sometimes caused a compiler crash -- BUGFIX: A DEBUG message would be printed in some games in some circumstances - -Changes in V3.0beta2: -- FEATURE: improved rules handling to simplify usage -- FEATURE: "Location Of" expression to investigate the current location of an instance -- FEATURE: syntax may now start with a parameter (an instance, like an actor name) -- FEATURE: TRANSCRIPT statement in language -- FEATURE: PROMPT section in language to control player input prompt -- FEATURE: new debugger command language -- FEATURE: tracing can now use symbolic parameter names -- BUGFIX: if a dollar sign was followed by a character not defined as a printing symbol, that character was lost -- BUGFIX: sometimes events would not be restored correctly from a save file -- BUGFIX: positioning of error pointers in -cc mode was not always correct causing AlanIDE to point to the wrong place -- BUGFIX: sometimes WinArun and Gargoyle interpreters hung on prompt -- BUGFIX: undo after quit did sometimes crash -- Updated documentation - -Changes in V3.0alpha9: -- Clearified licensing, read COPYING -- Upgraded WinGLK to 1.39 -- BUGFIX: WinArun did not follow preferences for window colouring and fonts -- BUGFIX: WinArun did not find sound and image resources when started from another directory than the game -- BUGFIX: a pronoun referencing an instance from a previous command that is no longer - available, the message was non-optimal -- FEATURE: Improved the tracing messages in the debugger - -Changes in V3.0alpha8: -- FEATURE: Entered is now inherited and nested in an accumulative way -- FEATURE: Entered is now executed before Description -- FEATURE: 'Can' is now added to 'Is', 'Has' and 'Are' for starting attribute declarations -- FEATURE: Instances listed after 'except'/'but' in player input using 'all', are now - handled in the same way as other syntax parameters -- BUGFIX: The location of a instance that is 'nowhere' could cause the interpreter to - crash -- BUGFIX: The pronoun handling could get confused if the player command referred to - multiple instance with the same pronoun -- BUGFIX: An UNDO command directly after a QUIT where the player choose to UNDO crashed -- BUGFIX: The compiler could crash if a reference attribute was not defined in the - parent class -- BUGFIX: Aggregating over an attribute might crash the interpreter if the - aggregating set contained containers taking instances not having the attribute -- BUGFIX: Entered did not always set This correctly -- BUGFIX: 'except' without preceeding parameters caused the interpreter to crash -- BUGFIX: A problem with literals caused the dial-sample to crash -- BUGFIX: Forward delete now works on MacOSX (and probably Linux too) -- BUGFIX: Some cases of disambiguating player references did not work as expected - -Changes in V3.0alpha7: -- BUGFIX: "undo" as a response to "Quit?" undid the wrong command in some cases -- BUGFIX: verb bodies in outer nested locations did not get executed -- Prohibited locating actors into containers -- BUGFIX: aggregating over things in restricted containers did not consider the - class restriction so did not find e.g. attributes defined for that class -- BUGFIX: In loops with an "In " filter this did not restrict the - class to the classes taken by the container -- BUGFIX: Isa expressions and loop filters did a general lookup for the class - name, so would find e.g. default syntax parameters -- BUGFIX: WinArun could try to restore from an empty file reference in some cases -- BUGFIX: If a multiple or omnipotent indicator was used for one syntax which shared - a common prefix (starting with the same verb e.g.) would sometimes miss the - indicator. Changed this to make an indicator implicitly apply to all syntaxes - with the same prefix. -- Extensive refactoring of the sources and Makefiles -- Removed support for the Metrowerks (old Mac) compiler - -Changes in V3.0alpha6: -- BUGFIX: Undo directly after restart would crash -- BUGFIX: Scheduled events imminent to run would get lost after undo - (typically the ones scheduled After 0) -- BUGFIX: Checksum calculation to work with pre-alpha5 games - -Changes in V3.0alpha5: -- Feature: nested locations, by locating locations in each other you - can create nested scopes. You can even do this during run-time, perhaps - a tool to create vehicles? Read more in the manual. -- Allowed more general expressions in Locate At statement and Isa expressions. -- Now generates an IFID as per The Babel Treaty. -- Rules are now also run immediately after the game is set-up. -- BUGFIX: A few problems with "open" verbs in the library. -- BUGFIX: added inherited reference attributes could sometimes cause a crash. -- A pronoun in player input, matching multiple parameters, now gives an - error message. -- BUGFIX: An empty container clause terminated by a full stop would cause - random errors caused by uninitialized data. -- BUGFIX: Renaming the WinArun interpreter to a game name would crash on game - save. -- BUGFIX: Negative integer literals would cause a system error -- BUGFIX: Full lists of multiply nested imported files would print incorrectly. - -Changes in V3.0alpha4: -- Corrected scope handling so that locations are not always in scope. -- Made CANCEL accept expressions. - -Changes in V3.0alpha3: -- Fixed a problem with multi-parameter syntaxes which allowed multiple - parameters in positions which where not the last. -- RESTART did not clear the buffer so continued command could be executed - as the first after a restart. -- Alpha interpreters will now warn if attempting to run games produced with - beta or release compilers. -- Made WinArun set window title to game name even if the game was opened - from the game open dialog. - -Changes in V3.0alpha2: -- Fixed a problem with items in an opaque container being possible to - manipulate using ALL. -- Fixed a problem with inherited reference attributes affecting proposed - door class implementation. Now works as specified. -- Fixed position calculation with -ide (for use with AlanIDE) to be - platform independent. - -Changes in V3.0alpha1: -- Unified the automatic display of objects and actors so that they now - both are listed in indefinite form. Actors are still listed separately - since they might carry things and have script descriptions. -- Moved the special actor handling of automatic display to the library -- Changed the message identifiers SEE_OBJ_xxxx to SEE_xxxx -- Removed the message identifier SEE_ACTOR -- Adjusted default listing of containers without a description so that - it always occurs unless the container is opaque. -- Added analysis of parameter references embedded in strings. -- Allowed expression in Step After (previously only allowed - integer) -- Fixed a problem where you could not refer to the script of an actor, if - the actor was a loop variable. -- Fixed inheritance of Initialize clause. - -Changes in v3.0dev36: -- Printing of pronouns -- SET statement can now set a literal set value; Set x Of l To {}. -- SET statement can now set a set to the value of another set; Set set1 Of i1 To set2 Of i1. -- IN can now test set membership in set literal; If int Of i In {1,3,5,7} Then... -- Saving did not handle sets and strings correctly, could cause crashes, fixed -- Initialization of a set attribute to an empty set is allowed and possible in two ways: - 1) The attribute is inherited so the member type and class is known - 2) A single class identifier is given instead of members -- Integer loops; For Each i Between 1 And limit Of bridge Do ... -- Loops over Sets and Containers; For Each i In friends Of hero Do ... -- Aggregation over Sets and Containers; Count In friends Of hero -- Reference attributes can be initialized with a class instead of an instance if - declared in a class. In this case all instances must give the attribute a value. -- Fixed WinArun startup so that it now prompts for a game name if the program is - activated instead of activating a game. -- Fixed the renaming feature of the interpreter which was broken (if renamed the - interpreter will look for game files with the corresponding name). -- Finally fixed the about box in WinArun to work in Win2000 and WinXP -- Debugger now knows on which lines it is possible to set breakpoints -- Added NEGATIVE ARTICLE/FORM for "Can't see any xyzzy here.", including a - corresponding Say form and embedded printing symbol. -- Fixed a bug where a single trailing $ caused spurious output, now correctly - outputs a single $ -- Removed M_???_ARTICLE and M_PRONOUN messages since they are equivalent to the - corresponding clause in the class 'entity' which now sets them as default. You - can override them by adding the clauses with an Add statement instead of using MESSAGE. -- Fixed numerous bugs in the UNDO handling: - o Now saves only states when player changes anything - o Now handles strings and sets correctly - o Now responds with "'' undone." which is a new customizable message -- Added more separators (characters that automatically inhibit space and force - capitalization) - -Changes in v3.0.35 development: -- The DIRECTLY qualifier can now be used for all Where-type expressions -- A container using the default description will list its content -- The List statement can now operate on expressions, notably involving - reference attributes -- Implemented text style hints which of course only works in some - interpreters, notably non-trivial GLK-variants -- Exits can be inherited and added -- Initialize clause added to classes and instances, this makes it easier - to control initializations locally -- Events can be referenced from attributes in the same way as instances -- NEW Play statement to play sounds, interpreter dependent support of course -- All media resources are now automatically packaged into a single resource - file (blorb-format) by the compiler -- Improved word handling to enable more correct parsings when words are of - multiple classes, e.g. verb&direction, adjective&verb and preposition&verb -- Nearby expression can test locations -- NEW Near expression which tests the adjacency between two instances -- Simplified the language grammar notation in the manaual - - -Changes in v3.0.34 development: -- Clean up of AT and IN. They are both now transitive/recursive. - Optional qualifier, "Directly", can be used in expressions to get - direct location or containment. -- Clean-up of pre-defined classes. Everything must inherit from some - class. "entity" can not have location (invisible and everywhere), - "thing" can but is not described automatically (invisible but - localized). "actor" and "object" are described automatically - (visible). Sub-classes to "entity" behave like "entity". This - harmonizes with the fact that "literal" is a subclass of "entity". -- Names are now inherited by adding names down the hierarchy. This - means that if a name is available for a more general class it will - also be available for the more special classes and instances. Good - candidates for use of this feature is fruit/apple/macintosh and - human/person/man. -- Initial locations are inherited. -- Restrictions on auto-generated syntaxes now matches the class the - verb was declared in. -- New statement "Random In" extracts a random element in a set or - container. -- Pronoun declarations. Instead of the previously built in - "IT"-handling and synonyms, it is now possible to declare pronouns - for a class or instance. These words can be used in player input to - refer to the instance if the instance was previously mentioned - explicitly in the previous player command. (This also solves the - problem with referring to a single instance using "them". "them" can - still be used to refer to the same multiple set of instances as used - in the previous command.) -- Improved use of correct case for words. -- Printing actor names are now done in the same way as for other - instances wrt. to definite/indefinite forms. -- Parameters are available in the Message sections for many - messages. This allows e.g. fixing the message wrt. to noun case (as - in German, "any" = kein/keine/keiner depending on noun case). -- Changed default messages to use parameter handling in as many cases - as possible, e.g. default location "content" listing, and container - listings. It is now possible to re-format these into tabulation - instead of the standard in-line form, for example. -- Added message for "unknown word". -- Interpreter now lists alternatives for ambiguous instance - references, which of course can be tweaked using a new message. -- Deprecated "$include" in favour of a new, equilvalent, "import" - statement. (***spoiler***) This makes future IDE-building easier. -- Verified that an inherited set or reference attribute retains the - original type even if the infered type of a redefinition is not the - same. A sub-class of the original is required. -- Fixed debug/trace output to show up also in winarun. -- Fixed command line arguments to winarun, you can now run the - debugger, trace etc. also in GLK-variants of the interpreter. -- Fixed a bug which mixed up several syntax-declarations so that - interpreter would respond with "You must supply a noun." for some - legal inputs. -- Fixed a bug with spacing in command line version. -- Fixed a bug with opaque attribute not being inherited for inherited - containers. -- Fixed a problem with some attributes not being saved and restored - correctly. - -Changes in v3.0.33 development: -- Changed DEPEND case separator from ':' to 'THEN' -- Added a new attribute type, set, declared using '{' and '}' -- Added a new interpretation of 'IN' which refers to sets -- Upgraded loop and aggregation filters to use 'IN' both for containers and sets -- Added messages for UNDO responses -- Added UNDO as a response to QUIT -- Empty player input is now interpreted as forfeiting that command turn diff --git a/app/src/main/jni/terps/alan/alan3/COPYING b/app/src/main/jni/terps/alan/alan3/COPYING deleted file mode 100755 index a389cbc..0000000 --- a/app/src/main/jni/terps/alan/alan3/COPYING +++ /dev/null @@ -1,186 +0,0 @@ -The Alan System is distributed under the Artistic License 2.0 for which the full text -follows. The intent of this licensing is that the Copyright Holder retain some -control over the development of the Alan System, while still keeping it available as open -source and free software. - -In practical terms this means that the licensing is choosen so that it should be possible to -- freely distribute games produced with the Alan system, including for profit -- re-distribute compiled versions of the Alan system, including together with a game which is - not open source or free, provided there is no charge for the Alan system -- redistribute compiled and/or source versions of the original Alan system (the Standard Version) -- aquire the source code for the Standard Version -- modify the source code for private use -- re-distribute compiled and/or source of a Modified Version provided they are done so under a - compatible license with appropriate attribution *and* that the modification is discribed and - made available, preferably by returning it to the Copyright Holder so that it can be merged - into the Standard Version - - -Artistic License 2.0 -==================== - -Preamble --------- - -This license establishes the terms under which a given free software Package may be copied, -modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains -some artistic control over the development of that Package while still keeping the Package -available as open source and free software. - -You are always permitted to make arrangements wholly outside of this license directly with the -Copyright Holder of a given Package. If the terms of this license do not permit the full use -that you propose to make of the Package, you should contact the Copyright Holder and seek a -different licensing arrangement. - - -Definitions ------------ - -"Copyright Holder" means the individual(s) or organization(s) named in the copyright notice -for the entire Package. - -"Contributor" means any party that has contributed code or other material to the Package, in -accordance with the Copyright Holder's procedures. - -"You" and "your" means any person who would like to copy, distribute, or modify the Package. - -"Package" means the collection of files distributed by the Copyright Holder, and derivatives -of that collection and/or of those files. A given Package may consist of either the Standard -Version, or a Modified Version. - -"Distribute" means providing a copy of the Package or making it accessible to anyone else, or -in the case of a company or organization, to others outside of your company or organization. - -"Distributor Fee" means any fee that you charge for Distributing this Package or providing -support for this Package to another party. It does not mean licensing fees. - -"Standard Version" refers to the Package if it has not been modified, or has been modified -only in ways explicitly requested by the Copyright Holder. - -"Modified Version" means the Package, if it has been changed, and such changes were not -explicitly requested by the Copyright Holder. - -"Original License" means this Artistic License as Distributed with the Standard Version of the -Package, in its current version or as it may be modified by The Copyright Holder in the future. - -"Source" form means the source code, documentation source, and configuration files for the -Package. - -"Compiled" form means the compiled bytecode, object code, binary, or any other form resulting -from mechanical transformation or translation of the Source form. - - -Permission for Use and Modification Without Distribution --------------------------------------------------------- - -(1) You are permitted to use the Standard Version and create and use Modified Versions for any -purpose without restriction, provided that you do not Distribute the Modified Version. - - -Permissions for Redistribution of the Standard Version ------------------------------------------------------- - -(2) You may Distribute verbatim copies of the Source form of the Standard Version of this -Package in any medium without restriction, either gratis or for a Distributor Fee, provided -that you duplicate all of the original copyright notices and associated disclaimers. At your -discretion, such verbatim copies may or may not include a Compiled form of the Package. - -(3) You may apply any bug fixes, portability changes, and other modifications made available -from the Copyright Holder. The resulting Package will still be considered the Standard -Version, and as such will be subject to the Original License. - - -Distribution of Modified Versions of the Package as Source ----------------------------------------------------------- - -(4) You may Distribute your Modified Version as Source (either gratis or for a Distributor -Fee, and with or without a Compiled form of the Modified Version) provided that you clearly -document how it differs from the Standard Version, including, but not limited to, documenting -any non-standard features, executables, or modules, and provided that you do at least ONE of -the following: - -(a) make the Modified Version available to the Copyright Holder of the Standard Version, under -the Original License, so that the Copyright Holder may include your modifications in the -Standard Version. - -(b) ensure that installation of your Modified Version does not prevent the user installing or -running the Standard Version. In addition, the Modified Version must bear a name that is -different from the name of the Standard Version. - -(c) allow anyone who receives a copy of the Modified Version to make the Source form of the -Modified Version available to others under - -(i) the Original License or - -(ii) a license that permits the licensee to freely copy, modify and redistribute the Modified -Version using the same licensing terms that apply to the copy that the licensee received, and -requires that the Source form of the Modified Version, and of any works derived from it, be -made freely available in that license fees are prohibited but Distributor Fees are allowed. - - -Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source ----------------------------------------------------------------------------------------------- -(5) You may Distribute Compiled forms of the Standard Version without the Source, provided -that you include complete instructions on how to get the Source of the Standard Version. Such -instructions must be valid at the time of your distribution. If these instructions, at any -time while you are carrying out such distribution, become invalid, you must provide new -instructions on demand or cease further distribution. If you provide valid instructions or -cease distribution within thirty days after you become aware that the instructions are -invalid, then you do not forfeit any of your rights under this license. - -(6) You may Distribute a Modified Version in Compiled form without the Source, provided that -you comply with Section 4 with respect to the Source of the Modified Version. - - -Aggregating or Linking the Package ----------------------------------- - -(7) You may aggregate the Package (either the Standard Version or Modified Version) with other -packages and Distribute the resulting aggregation provided that you do not charge a licensing -fee for the Package. Distributor Fees are permitted, and licensing fees for other components -in the aggregation are permitted. The terms of this license apply to the use and Distribution -of the Standard or Modified Versions as included in the aggregation. - -(8) You are permitted to link Modified and Standard Versions with other works, to embed the -Package in a larger work of your own, or to build stand-alone binary or bytecode versions of -applications that include the Package, and Distribute the result without restriction, provided -the result does not expose a direct interface to the Package. - - -Items That are Not Considered Part of a Modified Version --------------------------------------------------------- - -(9) Works (including, but not limited to, modules and scripts) that merely extend or make use -of the Package, do not, by themselves, cause the Package to be a Modified Version. In -addition, such works are not considered parts of the Package itself, and are not subject to -the terms of this license. - - -General Provisions ------------------- - -(10) Any use, modification, and distribution of the Standard or Modified Versions is governed -by this Artistic License. By using, modifying or distributing the Package, you accept this -license. Do not use, modify, or distribute the Package, if you do not accept this license. - -(11) If your Modified Version has been derived from a Modified Version made by someone other -than you, you are nevertheless required to ensure that your Modified Version complies with the -requirements of this license. - -(12) This license does not grant you the right to use any trademark, service mark, tradename, -or logo of the Copyright Holder. - -(13) This license includes the non-exclusive, worldwide, free-of-charge patent license to -make, have made, use, offer to sell, sell, import and otherwise transfer the Package with -respect to any patent claims licensable by the Copyright Holder that are necessarily infringed -by the Package. If you institute patent litigation (including a cross-claim or counterclaim) -against any party alleging that the Package constitutes direct or contributory patent -infringement, then this Artistic License to you shall terminate on the date that such -litigation is filed. - -(14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS -"AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE -EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR -WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY -WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file diff --git a/app/src/main/jni/terps/alan/alan3/LASTRELEASE b/app/src/main/jni/terps/alan/alan3/LASTRELEASE deleted file mode 100755 index ed0e53a..0000000 --- a/app/src/main/jni/terps/alan/alan3/LASTRELEASE +++ /dev/null @@ -1 +0,0 @@ -3_0beta5 \ No newline at end of file diff --git a/app/src/main/jni/terps/alan/alan3/Makefile b/app/src/main/jni/terps/alan/alan3/Makefile deleted file mode 100755 index f6ee784..0000000 --- a/app/src/main/jni/terps/alan/alan3/Makefile +++ /dev/null @@ -1,23 +0,0 @@ -####################################################################### -# This is the general Makefile for building the Alan System -# It figures out on which host platform (and possibly on which computer) -# it is running an will include specific Makefiles to build on that -# particular host -# -# In the included platform specific Makefiles you should handle all -# target specific compile and link settings -# - -OS=${if ${findstring CYGWIN, ${shell uname}},Cygwin,${strip ${shell uname}}} - -# Include the correct main Makefile depending on the system name -# -ifeq ($(findstring CYGWIN, $(shell uname)), CYGWIN) -ifeq ($(shell uname -n), thoni64) -include Makefile.thoni -else -include Makefile.cygwin -endif -else -include Makefile.$(shell uname) -endif diff --git a/app/src/main/jni/terps/alan/alan3/Makefile.Darwin b/app/src/main/jni/terps/alan/alan3/Makefile.Darwin deleted file mode 100755 index 3ebe1cf..0000000 --- a/app/src/main/jni/terps/alan/alan3/Makefile.Darwin +++ /dev/null @@ -1,64 +0,0 @@ -# -# Partial Makefile to be included from top level Makefile on Darwin -# - -VERSION := $(shell cat NEXTRELEASE) - -PACKAGE = alan$(VERSION)$(BUILDVERSION).macosx.x86_64.tgz - - -# There is no libxml-xpath-perl on Darwin so we need to use XML::XPath -# which does not allow switches (-q -e) -XPATH = xpath - - -# Default target -all : unit build - -v : - echo $(VERSION) - - -.PHONY: packages -packages: alan.readme.macosx $(PACKAGE) - -$(PACKAGE): bin/alan bin/arun - cp bin/alan bin/arun . - tar zcvf $(PACKAGE) alan arun alan.readme.macosx alan.readme COPYING CHANGES regression/saviour.alan regression/logo.png games/adventv3/adventV3.alan - -rm alan arun - - -############### -# Distribution -# -distribution: distribution-check distribution-build distribution-upload - -distribution-check: - @if [[ -f BUILD_NUMBER ]] ; then \ - echo Should not upload a distribution with BUILD_NUMBER, remove it first ; \ - exit 1 ; \ - fi - -distribution-build: - $(MAKE) clean all packages - $(MAKE) -C interpreter gararun MacArun - -distribution-upload: - alanupload $(PACKAGE) sdks/macosx - alanupload interpreter/gargoyle-updater-alan3-$(VERSION)$(BUILDVERSION).macosx.pkg interpreters/macosx - alanupload interpreter/MacArun$(VERSION)$(BUILDVERSION).zip interpreters/macosx - - -########## -# Snapshot -# -snapshot-build: - $(MAKE) BUILDNUMBER=$(BUILDNUMBER) clean all packages - $(MAKE) -C interpreter BUILDNUMBER=$(BUILDNUMBER) gararun MacArun - -snapshot-upload: - alanupload $(PACKAGE) snapshots/$(BUILDNAME) - alanupload interpreter/gargoyle-updater-alan3-$(VERSION)$(BUILDVERSION).macosx.pkg snapshots/$(BUILDNAME) - alanupload interpreter/MacArun$(VERSION)$(BUILDVERSION).zip snapshots/$(BUILDNAME) - -include Makefile.common diff --git a/app/src/main/jni/terps/alan/alan3/Makefile.Linux b/app/src/main/jni/terps/alan/alan3/Makefile.Linux deleted file mode 100755 index 2994280..0000000 --- a/app/src/main/jni/terps/alan/alan3/Makefile.Linux +++ /dev/null @@ -1,57 +0,0 @@ -# -# Partial Makefile to be included from top level Makefile on Linux -# - -VERSION := $(shell cat NEXTRELEASE) - -PLATFORM = linux.i386 # Since we only distribute 32bit versions - -PACKAGE = alan$(VERSION)$(BUILDVERSION).$(PLATFORM).tgz - -XPATH := xpath -q -e - - -# Default target -all : unit build - - -# We need to define how to package on Linux -packages: alan.readme.linux $(PACKAGE) - -$(PACKAGE): bin/alan bin/arun - cp bin/alan bin/arun . - tar zcvf $(PACKAGE) alan arun alan.readme.linux alan.readme COPYING CHANGES regression/saviour.alan games/adventv3/adventV3.alan - -rm alan arun - -############### -# Distribution -# -distribution: - @if [[ -f BUILD_NUMBER ]] ; then \ - echo Should not upload a version with BUILD_NUMBER, remove it first ; \ - exit 1 ; \ - fi - $(MAKE) distribution-build distribution-upload - -distribution-build: - $(MAKE) clean all package - $(MAKE) -C interpreter gararun - -distribution-upload: - alanupload $(PACKAGE) "sdks/linux/" - alanupload interpreter/gargoyle-alan3-$(VERSION)$(BUILDVERSION).linux.tgz interpreters/linux - alanupload interpreter/gargoyle-updater-alan3-$(VERSION)$(BUILDVERSION).linux.sh interpreters/linux - - -########## -# Snapshot -# -snapshot-build: - $(MAKE) BUILDNUMBER=$(BUILDNUMBER) BUILDVERSION=$(BUILDVERSION) clean all package - $(MAKE) -C interpreter BUILDNUMBER=$(BUILDNUMBER) gararun - -snapshot-upload: - alanupload $(PACKAGE) snapshots/$(BUILDNAME)/ - alanupload interpreter/gargoyle-updater-alan3-$(VERSION)$(BUILDVERSION).linux.sh snapshots/$(BUILDNAME)/ - -include Makefile.common diff --git a/app/src/main/jni/terps/alan/alan3/Makefile.common b/app/src/main/jni/terps/alan/alan3/Makefile.common deleted file mode 100755 index b9ceb8f..0000000 --- a/app/src/main/jni/terps/alan/alan3/Makefile.common +++ /dev/null @@ -1,86 +0,0 @@ -# Main common targets: clean build unit test -# "packages" must be defined in platform dependent makefiles - -ifneq ($(EMACS),) -JREGROUTPUT = -noansi -else -UNITOUTPUT ?= -c -endif - -PLATFORM = "Needs to be set by platform specific Makefile" - -.PHONY: clean -clean: - @echo "******** Target: $@ ***********" - -$(MAKE) -C compiler clean - -$(MAKE) -C interpreter clean - -$(MAKE) -C converter clean - @-rm -f alan3*.tgz - -.PHONY: build -build: - @echo "******** Target: $@ ***********" - $(MAKE) -C compiler BUILDNUMBER=$(BUILDNUMBER) build - $(MAKE) -C interpreter BUILDNUMBER=$(BUILDNUMBER) build - $(MAKE) -C converter BUILDNUMBER=$(BUILDNUMBER) build - -.PHONY: unit -unit: - @echo "******** Target: $@ ***********" - -$(MAKE) -C compiler UNITOUTPUT="$(UNITOUTPUT)" unit - -$(MAKE) -C interpreter UNITOUTPUT="$(UNITOUTPUT)" unit - -$(MAKE) -C converter UNITOUTPUT="$(UNITOUTPUT)" unit - -.PHONY: test -test: - @echo "******** Target: $@ ***********" -ifeq ($(OS), Linux) - @touch regression/isochars.suspended regression/unknownWordMessage.suspended -endif - @echo "***************** Test *****************" - -$(MAKE) -C compiler JREGROUTPUT=$(JREGROUTPUT) test - -$(MAKE) -C interpreter JREGROUTPUT=$(JREGROUTPUT) test - -$(MAKE) -C converter JREGROUTPUT=$(JREGROUTPUT) test - - -.PHONY: ci -ci: JREGROUTPUT = -xml -ci: UNITOUTPUT = --xml TEST -ci: buildnumbers all packages - -########################################################### -# Snapshot boiler plate - specifics in Makefile. -# -snapshot: buildnumbers snapshot-build snapshot-upload - @echo "******** Target: $@ ***********" - - -################################################## -# Build designations: -# BUILDNUMBER is just the number -# BUILDVERSION includes a dash, if no-empty, so can be used with $(VERSION)$(BUILDVERSION) -# BUILDNAME is "Build"$(BUILDNUMBER), e.g. "Build1667" -# -# You can call 'buildnumbers' to pick up the latest build from Jenkins, you can also -# set a BUILDNUMBER and then call it which will set the other dependent values correctly - -.PHONY: buildnumbers -buildnumbers: buildnumber - $(eval BUILDVERSION := -$(BUILDNUMBER)) - $(eval BUILDNAME := Build$(BUILDNUMBER)) - @echo BUILDNUMBER = $(BUILDNUMBER) - @echo BUILDVERSION = $(BUILDVERSION) - - -buildnumber: -ifeq ($(BUILDNUMBER),) - @echo "Getting BUILDNUMBER from Jenkins (should only happen when not building on Jenkins@thoni64)" - $(eval BUILDNUMBER := $(shell wget -q -O- 'ci.alanif.se:8080/job/Alan/api/xml?xpath=*/lastSuccessfulBuild/number' | $(XPATH) 'number/text()')) -endif - -.PHONY: x -x: - @echo BUILDNUMBER = $(BUILDNUMBER) - @echo BUILDVERSION = $(BUILDVERSION) - @echo BUILDNAME = $(BUILDNAME) - @echo PACKAGE=$(PACKAGE) diff --git a/app/src/main/jni/terps/alan/alan3/Makefile.cygwin b/app/src/main/jni/terps/alan/alan3/Makefile.cygwin deleted file mode 100755 index 299f8dc..0000000 --- a/app/src/main/jni/terps/alan/alan3/Makefile.cygwin +++ /dev/null @@ -1,171 +0,0 @@ -####################################################################### -# This Makefile is the top level for building the Alan System. -# It only works on ThoNi's machine. -####################################################################### - -VERSION := `venum alan -print '$$v_$$r{s$$s|_}$$c' | tr -d '\n\r'` -DISTDIR := ~/Utveckling/Alan/alanweb/downloads - -PLATFORM = win32.i386 # Since we only distribute windows 32-bit exe's - -# Location of Inno Setup Compiler -INNODIR = /cygdrive/c/Program\ Files\ \(x86\)/Inno\ Setup\ 5 - -XPATH = xpath -q -e - -default: unit build - -.PHONY: all -all: unit build documentation tests - -.PHONY:tests -tests: test cygwintests - -.PHONY: cygwintests -cygwintests: - @java -jar bin/jregr.jar -bin bin -dir regression/winalan $(JREGROUTPUT) - @java -jar bin/jregr.jar -bin bin -dir regression/versions/interpreter $(JREGROUTPUT) - -.PHONY: release -release: - @if ! git --no-pager diff --exit-code --quiet ; then \ - echo "Commit changes before making a release" ; \ - exit 1 ; \ - else if ! git --no-pager diff --exit-code --quiet --cached ; then \ - echo "Commit cached changes before making a release" ; \ - exit 1 ; \ - else if ! [[ -z `git rev-list @{upstream}.. -n 1` ]] ; then \ - echo "Push all local changes before making a release" ; \ - exit 1 ; \ - fi fi fi - $(MAKE) -f Makefile.thoni releasebuild - $(MAKE) -f Makefile.thoni test - $(MAKE) -f Makefile.thoni documentation - $(MAKE) -f Makefile.thoni zip setup gargoyle - $(MAKE) -f Makefile.thoni tags - $(MAKE) -f Makefile.thoni release-upload - - -.PHONY: snapshot-build -snapshot-build: - @echo "ERROR: Don't build snapshots on thoni, that should be done using Jenkins" - exit 2 - - -.PHONY: snapshot-upload -snapshot-upload: buildnumbers - ssh alanif.se "mkdir /www/downloads/snapshots/$(BUILDNAME)" - alanupload alan$(VERSION)$(BUILDVERSION).win32.x86.zip snapshots/$(BUILDNAME)/ - alanupload alan$(VERSION)$(BUILDVERSION).win32.x86.setup.exe snapshots/$(BUILDNAME)/ - alanupload winarun$(VERSION)$(BUILDVERSION).win32.x86.setup.exe snapshots/$(BUILDNAME)/ - alanupload doc/manual/manual.pdf snapshots/$(BUILDNAME)/ - alanupload doc/manual/conversion.pdf snapshots/$(BUILDNAME)/ - alanupload doc/manual/writing.pdf snapshots/$(BUILDNAME)/ - ssh alanif.se ls -td /www/downloads/snapshots/Build* | tail -1 | xargs ssh alanif.se rm -r - -.PHONY: release-upload -release-upload: - alanupload alan$(VERSION).win32.x86.zip sdks/windows - alanupload alan$(VERSION).win32.x86.setup.exe sdks/windows - alanupload winarun$(VERSION).win32.x86.setup.exe interpreters/windows - alanupload interpreter/gargoyle-alan3-$(VERSION).win32.x86.setup.exe interpreters/windows - alanupload interpreter/gargoyle-alan3-$(VERSION).win32.x86.zip interpreters/windows - alanupload doc/manual/manual.pdf documentation - alanupload doc/manual/conversion.pdf documentation - #alanupload doc/manual/writing.pdf documentation - - -# Create pdf from odt -.PHONY: documentation -documentation: - @echo "******** Target: $@ ***********" - $(MAKE) -C doc/manual - - -.PHONY: releasebuild -releasebuild: - $(MAKE) -C compiler release - $(MAKE) -C interpreter release - $(MAKE) -C converter release - -include Makefile.common - -.PHONY: tags -tags: last-release - git tag -f v$(VERSION)_$(OS) - @echo "If you are satisfied with the result, and on thoni's machine, do a 'venum alan correction', at least" - -.PHONY: last-release -last-release: - echo -n $(VERSION) > LASTRELEASE - - - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# Create all source for porting, should be done in an exported directory -# -.PHONY: srcdist -srcdist: - @if test -d .git; then \ - echo Do not do this in your working directory, export first ; \ - exit 1 ; \ - fi - venum -write always -all alan - cp version.h alan.version.[ch] compiler - cp version.h alan.version.[ch] interpreter - cp compiler/spa.* interpreter - -rm -r regression/pre3 regression/special - /usr/bin/find . -name \* -exec chmod u+w \{\} \; - /usr/bin/find . -name Makefile\* -exec dos2unix \{\} \; - /usr/bin/find . -name \*.\[ch\] -exec dos2unix \{\} \; - tar zcvf alansrc$(VERSION).tgz compiler interpreter converter regression COPYING bin/regr bin/jregr bin/jregr.jar - -rm $(DISTDIR)/Source/alansrc*.* - cp alansrc$(VERSION).tgz $(DISTDIR)/Source - -.PHONY: newVersion -newVersion: - venum alan - cvs commit -m 'New Version' alan.version - -################################################################################# - -.PHONY: packages -packages: zip setup - -.PHONY: zip -zip: doc/manual/manual.pdf bin/alan.exe bin/arun.exe alan.readme.txt CHANGES.txt alan.readme.windows.txt games/adventv3/adventV3.a3c regression/saviour.alan regression/logo.png COPYING - @echo "******** Target: $@ ***********" - -rm alan*.zip - zip -j alan$(VERSION)$(BUILDVERSION).$(PLATFORM).zip $^ - -.PHONY: setup -setup: COPYING.txt CHANGES.txt alan.readme.txt alan.readme.windows.txt converter/a2a3.readme.txt - @echo "******** Target: $@ ***********" - -rm winarun*setup.exe - sed -e s/VERSION/$(VERSION)$(BUILDVERSION)/ winarun.iss > winarun_tmp.iss - $(INNODIR)/iscc winarun_tmp.iss - -rm winarun_tmp.iss - -rm alan*setup.exe - sed -e s/VERSION/$(VERSION)$(BUILDVERSION)/ alan.iss > alan_tmp.iss - $(INNODIR)/iscc alan_tmp.iss - -rm alan_tmp.iss - -rm COPYING.txt CHANGES.txt alan.readme.txt alan.readme.windows.txt converter/a2a3.readme.txt - -games/adventv3/adventV3.a3c: games/adventv3/adventV3.alan bin/alan - cd games/adventv3; ../../bin/alan adventv3 - -COPYING.txt: COPYING - unix2dos >$@ <$< - -CHANGES.txt: CHANGES - unix2dos >$@ <$< - -alan.readme.txt: alan.readme - unix2dos >$@ <$< - -alan.readme.windows.txt: alan.readme.windows - unix2dos >$@ <$< - -converter/a2a3.readme.txt: converter/a2a3.readme - unix2dos >$@ <$< diff --git a/app/src/main/jni/terps/alan/alan3/Makefile.thoni b/app/src/main/jni/terps/alan/alan3/Makefile.thoni deleted file mode 100755 index 02e9f88..0000000 --- a/app/src/main/jni/terps/alan/alan3/Makefile.thoni +++ /dev/null @@ -1,7 +0,0 @@ -####################################################################### -# This Makefile is the top level for building the Alan System. -# It only works on ThoNi's machine. -####################################################################### -# It's actually the same as cygwin at this point - -include Makefile.cygwin diff --git a/app/src/main/jni/terps/alan/alan3/NEXTRELEASE b/app/src/main/jni/terps/alan/alan3/NEXTRELEASE deleted file mode 100644 index f7a41b8..0000000 --- a/app/src/main/jni/terps/alan/alan3/NEXTRELEASE +++ /dev/null @@ -1 +0,0 @@ -3_0beta6 diff --git a/app/src/main/jni/terps/alan/alan3/SETUP b/app/src/main/jni/terps/alan/alan3/SETUP deleted file mode 100755 index 0fcea46..0000000 --- a/app/src/main/jni/terps/alan/alan3/SETUP +++ /dev/null @@ -1,30 +0,0 @@ -Here are some quick reminders on how to set up for Alan development. - -Cygwin: - - - install cygwin, ensure you have selected xemacs/emacs, cvs, - gcc, mingw-runtime, gdb, make. I also use mintty as a - replacement for the Windows Command window. - -All: - - CGreen: To run unit tests you also need Cgreen. You can - install Cgreen from http://cgreen.sourceforge.net - - -Optional: - - Emacs: I actually got GNU Emacs 24.x for Windows working with - cygwin as its shell and command layer *and* xref, so now I'm - using that. I found some hints on the net to setup Emacs - - - AnsiCon: I installed AnsiCon 1.24 which is a consol add on - to make the XP and later console show ansi coloring (nice - when running jregr), but I am unsure if it is required when - using mintty. - - - Xref: to refactor C code in emacs I use the free C/Java - version from xref-tech. Download it, build and install it - according to the instructions there in. I compiled xref - using -mno-cygwin and a minor change of 'sleep' to 'Sleep' - (the Windows version). In this way it works on windows - (e.g. under GNU-Emacs). - diff --git a/app/src/main/jni/terps/alan/alan3/alan.iss b/app/src/main/jni/terps/alan/alan3/alan.iss deleted file mode 100755 index 8655779..0000000 --- a/app/src/main/jni/terps/alan/alan3/alan.iss +++ /dev/null @@ -1,74 +0,0 @@ -; Script generated by the Inno Setup Script Wizard. -; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -[Setup] -AppName=Alan V3 Adventure Language System for Windows -AppVerName=Alan VERSION -AppPublisher=ThoNi Adventure Factories -AppPublisherURL=http://www.alanif.se -AppSupportURL=http://www.alanif.se -AppUpdatesURL=http://www.alanif.se -DefaultDirName={pf}\Alan V3 for Windows -DefaultGroupName=Alan V3 for Windows -AllowNoIcons=yes -ChangesAssociations = yes -OutputDir=. -OutputBaseFilename=alanVERSION.win32.x86.setup -WizardImageFile=setup_wizard.bmp -WizardImageStretch=no - -[Registry] -Root: HKCR; Subkey: ".a3c"; ValueType: string; ValueName: ""; ValueData: "AlanV3Game"; Flags: uninsdeletevalue -Root: HKCR; Subkey: "AlanV3Game"; ValueType: string; ValueName: ""; ValueData: "Alan V3 Game"; Flags: uninsdeletekey -Root: HKCR; Subkey: "AlanV3Game\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\winarun.exe,0" -Root: HKCR; Subkey: "AlanV3Game\shell\open\command"; ValueType: string; ValueName: ""; ValueData: """{app}\winarun.exe"" ""%1""" -Root: HKCR; Subkey: ".alan"; ValueType: string; ValueName: ""; ValueData: "AlanV3Source"; Flags: uninsdeletevalue -Root: HKCR; Subkey: "AlanV3Source"; ValueType: string; ValueName: ""; ValueData: "Alan V3 Source"; Flags: uninsdeletekey -Root: HKCR; Subkey: "AlanV3Source\DefaultIcon"; ValueType: string; ValueName: ""; ValueData: "{app}\winalan.exe,0" -Root: HKCR; Subkey: "AlanV3Source\shell\edit\command"; ValueType: string; ValueName: ""; ValueData: """notepad.exe"" ""%1""" -Root: HKCR; Subkey: "AlanV3Source\shell\compile\command"; ValueType: string; ValueName: ""; ValueData: """{app}\winalan.exe"" ""%1""" - -[Tasks] -Name: "desktopicon"; Description: "Create &desktop icons"; GroupDescription: "Additional icons:" -Name: "quicklaunchicon"; Description: "Create &Quick Launch icons"; GroupDescription: "Additional icons:"; Flags: unchecked - -[Files] -Source: "bin\winalan.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "alan.readme.txt"; DestDir: "{app}"; Flags: ignoreversion -Source: "CHANGES.txt"; DestDir: "{app}"; Flags: ignoreversion -Source: "COPYING.txt"; DestDir: "{app}"; Flags: ignoreversion -Source: "bin\winarun.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "bin\a2a3.exe"; DestDir: "{app}"; Flags: ignoreversion -Source: "converter\a2a3.readme.txt"; DestDir: "{app}"; DestName: "a2a3.readme.txt"; Flags: ignoreversion -Source: "c:\Users\Thomas\Utveckling\Alan\WindowsGlk-145\Glk.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "c:\Users\Thomas\Utveckling\Alan\WindowsGlk-145\ScaleGfx.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "regression\saviour.alan"; DestDir: "{app}"; Flags: ignoreversion -Source: "regression\logo.png"; DestDir: "{app}"; Flags: ignoreversion -Source: "regression\saviour.a3c"; DestDir: "{app}"; Flags: ignoreversion -Source: "regression\saviour.a3r"; DestDir: "{app}"; Flags: ignoreversion -Source: "doc\manual\manual.pdf"; DestDir: "{app}"; Flags: ignoreversion -Source: "games\adventv3\adventV3.a3c"; DestDir: "{app}"; Flags: ignoreversion -; NOTE: Don't use "Flags: ignoreversion" on any shared system files - -[INI] -Filename: "{app}\alan.url"; Section: "InternetShortcut"; Key: "URL"; String: "http://www.alanif.se" - -[Icons] -Name: "{group}\Alan V3 Compiler for Windows"; Filename: "{app}\winalan.exe" -Name: "{group}\Alan VERSION ReadMe"; Filename: "{app}\alan.readme.txt" -Name: "{group}\CHANGES"; Filename: "{app}\CHANGES.txt" -Name: "{group}\COPYING"; Filename: "{app}\COPYING.txt" -Name: "{group}\Alan V3 Interpreter for Windows"; Filename: "{app}\winarun.exe" -Name: "{group}\Alan V2 to V3 Source Converter"; Filename: "{app}\a2a3.exe" -Name: "{group}\Alan V2 to V3 Source Converter ReadMe"; Filename: "{app}\a2a3.readme.txt" -Name: "{group}\Alan V3 Manual"; Filename: "{app}\manual.pdf" -Name: "{group}\Alan on the Web"; Filename: "{app}\alan.url" -Name: "{group}\Saviour - a sample game (compile)"; Filename: "{app}\saviour.alan" -Name: "{group}\Saviour - a sample game (run)"; Filename: "{app}\saviour.a3c" -Name: "{group}\Advent - a crude conversion of ADVENT"; Filename: "{app}\adventV3.a3c" -Name: "{group}\Uninstall Alan V3"; Filename: "{uninstallexe}" -Name: "{userdesktop}\Alan V3 Interpreter for Windows"; Filename: "{app}\winarun.exe"; Tasks: desktopicon -Name: "{userdesktop}\Alan V3 Compiler for Windows"; Filename: "{app}\winalan.exe"; Tasks: desktopicon -Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Alan V3 Interpreter for Windows"; Filename: "{app}\winarun.exe"; Tasks: quicklaunchicon -Name: "{userappdata}\Microsoft\Internet Explorer\Quick Launch\Alan V3 Compiler for Windows"; Filename: "{app}\winalan.exe"; Tasks: quicklaunchicon - diff --git a/app/src/main/jni/terps/alan/alan3/alan.readme b/app/src/main/jni/terps/alan/alan3/alan.readme deleted file mode 100755 index 61dfef1..0000000 --- a/app/src/main/jni/terps/alan/alan3/alan.readme +++ /dev/null @@ -1,81 +0,0 @@ - - Welcome to the - ALAN ADVENTURE LANGUAGE - 3.0beta5 - 2015-06-23 - - -THE NEWS IN SHORT: - -Alan is a tool to create text adventure games, interactive fiction, -text-based simulations for teaching or other similar types of -interactive software. - -This is the third beta version (v3.0beta5) of Alan V3. Alan v3 -features many new enhancements especially object orientation. - -This package contains at least the compiler and the interpreter. It -might also, depending on the distribution package, include the manual, -the source for the Saviour game, a converter program which takes an -Alan v2 source file and outputs a V3 version of the same source, the -source and binary for a sample game. Read the particulars in the -readme for your platform. If it does not you can find most of that at -the Alan webspace: - - http://www.alanif.se - -The changes between versions is described in the file CHANGES, which -should also be included. - - - -THE LONG STORY: - -The Alan System is one of the most easy-to-use tools to create -interactive fiction, aka. adventure games. The Alan System is based on -a special purpose computer language designed to be easy to use for -people more interested in authoring and designing games. The system -consists of a compiler, which compiles Alan source to a compact and -portable form, and an interpreter that interprets such a form to allow -playing of the game. - -The Alan System is register-ware. To use Alan for authoring and -distributing your games all you need to do is to register. Registration -can be done with a simple email to thomas@alanif.se. - -Alan V3 has been evolving for a number of years and is now feature -complete. It is stable enough to use for production type work, but -will be released as a non-beta when enough beta test experience show -that it is mature enough. You can help! Report any problem and -suggestions. You can visit - - http://wwww.alanif.se - -to find out more about Alan V3. - -You can also find the legacy v2.8 version there. It should now be -considered completely obsolete and you should only look at it if are -looking to run some old game. Otherwise you should *really* look at -V3. Alan may also be found at - - http://www.ifarchive.org - -and its mirrors. - -For complete copying conditions refer to the file COPYING in the -distribution or the corresponding appendix in the manual. - -If you have any problems don't hesitate to contact the author at the -following email address: - - thomas@alanif.se - -Or join the Alan mailing list, which you can find at the Alan Home -Pages - - http://www.alanif.se - -All communication is welcome! Happy Authoring! - -Thomas Nilefalk -thomas@alanif.se diff --git a/app/src/main/jni/terps/alan/alan3/alan.readme.linux b/app/src/main/jni/terps/alan/alan3/alan.readme.linux deleted file mode 100755 index 470bd1b..0000000 --- a/app/src/main/jni/terps/alan/alan3/alan.readme.linux +++ /dev/null @@ -1,20 +0,0 @@ -About the Alan distribution for Linux: - -This distribution does not contain anything apart from the executable -compiler and interpreter. As of now there are only command line -versions available of them for Linux from this source. There is -however the Gargoyle (https://code.google.com/p/garglk/downloads/list) -initiative which aims to unify most (if not all) interpreters under -the same hood. (You might need to install an update of the Alan3 -interpreter which you can find on the Alan website.) - -You can use any text editor to write you Alan game. A recommended GUI -to create new games is the AlanIDE, available from - - http://www.alanif.se. - -There you also can find documentation, an extensive standard library -as well as some sample code. - -This port was made on Ubuntu 15.04 in VirtualBox on a Win7 PC by -Thomas Nilefalk (thomas@alanif.se). diff --git a/app/src/main/jni/terps/alan/alan3/alan.readme.macosx b/app/src/main/jni/terps/alan/alan3/alan.readme.macosx deleted file mode 100755 index 682bdda..0000000 --- a/app/src/main/jni/terps/alan/alan3/alan.readme.macosx +++ /dev/null @@ -1,20 +0,0 @@ -About the Alan distribution for Mac OSX: - -This distribution does not contain anything apart from the executable -compiler and interpreter for Intel-based machines. As of now there are -only command line versions available of them. - -Gargoyle (https://code.google.com/p/garglk/downloads/list) is a multi- -interpreter GUI including an older alan interpreter. You can update it -using the slotin replacement available from the Alan Home Pages. - -You can use any text editor to write your Alan game. A recommended GUI -to create new games is the AlanIDE, available from - - http://www.alanif.se. - -There you also can find documentation, an extensive standard library -as well as some sample code. - -The port was made on a MacOSX 10.10 Intel Macbook Pro by Thomas Nilefalk -(thomas@alanif.se). diff --git a/app/src/main/jni/terps/alan/alan3/alan.readme.windows b/app/src/main/jni/terps/alan/alan3/alan.readme.windows deleted file mode 100755 index 3fa445e..0000000 --- a/app/src/main/jni/terps/alan/alan3/alan.readme.windows +++ /dev/null @@ -1,15 +0,0 @@ -About the Alan distribution for Microsoft Windows: - -Depending on if you downloaded the ZIP-archive or the Windows -installer you will get a command line version or a Windows GUI -version. - -Note: To run the Windows GUI interpreter 'winarun' you will need a -Windows "GLK.DLL". WindowsGLK DLL is included in this distribution but -can also be downloaded from: - -http://www.ifarchive.org/if-archive/programming/glk/implementations/WindowsGlk-?.zip - -You can also use Gargoyle (https://code.google.com/p/garglk/downloads/list) -to run Alan v3 games. You can update that with a slot in replacement available -from the Alan Home page (http://www.alanif.se). diff --git a/app/src/main/jni/terps/alan/alan3/alan.version b/app/src/main/jni/terps/alan/alan3/alan.version deleted file mode 100755 index 0506e11..0000000 --- a/app/src/main/jni/terps/alan/alan3/alan.version +++ /dev/null @@ -1,15 +0,0 @@ -4.2 venum # venum 4.2 beta -Alan -Adventure Language System -3 -0 -6 -beta -1504897136 2017-09-08 20:58:56 -Thomas -thoni64 -$v.$r{s$s|.}$c -$n $V -$H{z -- $z} ($D $t) - -cygwin32 diff --git a/app/src/main/jni/terps/alan/alan3/alan.version.c b/app/src/main/jni/terps/alan/alan3/alan.version.c deleted file mode 100644 index b939bcb..0000000 --- a/app/src/main/jni/terps/alan/alan3/alan.version.c +++ /dev/null @@ -1,19 +0,0 @@ -/* alan.c - Created by venum 4.2 beta */ - -#include "alan.version.h" - -Product alan = { - "Alan", - "Adventure Language System", - "Alan 3.0beta6", - "Alan 3.0beta6 -- Adventure Language System (2017-09-08 20:58)", - "2017-09-08", - "20:58:56", - "Thomas", - "thoni64", - "cygwin32", - {"3.0beta6", 3, 0, 6, 1504897136, "beta"} -}; - -char *alanId = - "@(#)RELEASE "; diff --git a/app/src/main/jni/terps/alan/alan3/alan.version.h b/app/src/main/jni/terps/alan/alan3/alan.version.h deleted file mode 100755 index 7cc1cc9..0000000 --- a/app/src/main/jni/terps/alan/alan3/alan.version.h +++ /dev/null @@ -1,8 +0,0 @@ -#ifndef _alan_version_h_ -#define _alan_version_h_ 3 - -#include "version.h" - -extern Product alan; - -#endif diff --git a/app/src/main/jni/terps/alan/alan3/bin/.gitignore b/app/src/main/jni/terps/alan/alan3/bin/.gitignore deleted file mode 100644 index 463f293..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -alan -arun -a2a3 -dumpacd -glkarun diff --git a/app/src/main/jni/terps/alan/alan3/bin/alanupload b/app/src/main/jni/terps/alan/alan3/bin/alanupload deleted file mode 100755 index 87599e7..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/alanupload +++ /dev/null @@ -1,15 +0,0 @@ -#! /bin/sh -# -if [ $# != 2 ] ; then - echo "Usage: `basename $0` " - echo - cat << EOF - This script allow you to upload files to the Alan Home Pages download area - from the command line. You need to have set up your ~/.ssh/config so that - you can use "ssh alanif.se" to log in to alanif.se without using a user or - password. One way to do that is to ssh-copy-id to set up your remote - ~/.ssh/authorized_keys -EOF - exit 1 -fi -scp $1 "alanif.se:/www/downloads/$2/`basename $1`" diff --git a/app/src/main/jni/terps/alan/alan3/bin/cgreen-gdb b/app/src/main/jni/terps/alan/alan3/bin/cgreen-gdb deleted file mode 100755 index 96ad014..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/cgreen-gdb +++ /dev/null @@ -1,4 +0,0 @@ -bp=${2//:/__} -echo break $bp > .cgreen-gdb-commands -echo run $1 $2 >> .cgreen-gdb-commands -cgdb -ex "set breakpoint pending on" cgreen-runner --command=.cgreen-gdb-commands diff --git a/app/src/main/jni/terps/alan/alan3/bin/cregr b/app/src/main/jni/terps/alan/alan3/bin/cregr deleted file mode 100755 index 616fc6e..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/cregr +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -if [ $# -ne 1 ] ; then - echo "Usage: `basename $0` " - echo "where" - echo " : name of the Jregr case to monitor" - echo - echo "Continuously monitor an Alan regression case file for changes" - echo "then run jregr on that case and display the output" - exit -fi -case="$1" -file=$case.alan -output=$case.output -shift -commands="$*" -d0=`perl -e '$mtime=(stat("'$file'"))[9]; print $mtime;'` -while true; do - d1=`perl -e '$mtime=(stat("'$file'"))[9]; print $mtime;'` - while [ $d0 -eq $d1 ] ; do - sleep 5 - d1=`perl -e '$mtime=(stat("'$file'"))[9]; print $mtime;'` - done - echo -ne '\033c' - jregr $case ; cat $output - d0=$d1 -done diff --git a/app/src/main/jni/terps/alan/alan3/bin/d b/app/src/main/jni/terps/alan/alan3/bin/d deleted file mode 100755 index e774c68..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/d +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh -# -# Script for running tests of Alan and Arun -# - -diffCase () -{ - echo "$case : " - if [ -x /usr/local/bin/DiffMerge ] ; then - DiffMerge $case.output $case.expected - else - diff -b -c $case.output $case.expected - fi -} - -if [ $# != 0 ] ; then - for f in ${*} ; do - case=`basename ${f%%.} .output` - if [ -f $case.output -a -f $case.expected ] ; then - diffCase - fi - done -else - for f in *.output ; do - case=`basename $f .output` - if [ -f $case.output -a -f $case.expected ] ; then - diffCase - fi - done -fi diff --git a/app/src/main/jni/terps/alan/alan3/bin/f b/app/src/main/jni/terps/alan/alan3/bin/f deleted file mode 100755 index cb8413d..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/f +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -if [ -f .jregr ] ; then - read ext _ < .jregr -else - ext=.alan -fi -for f in *$ext ; do - case=`basename $f $ext` - if [ -f $case.expected ] ; then - if [ -f $case.output ] ; then - /bin/echo -n "$case: failed" - if [ -f $case.suspended ] ; then - /bin/echo " (but suspended)" - else - /bin/echo - fi - fi - else - /bin/echo -n "$case: pending" - if [ -f $case.suspended ] ; then - /bin/echo " (and suspended)" - else - /bin/echo - fi - fi -done diff --git a/app/src/main/jni/terps/alan/alan3/bin/fok b/app/src/main/jni/terps/alan/alan3/bin/fok deleted file mode 100755 index 8e38428..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/fok +++ /dev/null @@ -1,47 +0,0 @@ -#! /bin/sh -# -# Diff all failing tests and ask if that's ok -# - -diffCase () -{ - if [ -x /usr/local/bin/DiffMerge ] ; then - DiffMerge $case.output $case.expected - else - diff -b -c $case.output $case.expected - fi -} - -ok () -{ -echo "Is the test case ok?" -PS3="OK? " -select yn in "Yes" "No"; do - case $yn in - Yes ) mv $1.output $1.expected; break;; - No ) break;; - esac -done -} - -if [ $# != 0 ] ; then - for f in ${*} ; do - case=`basename ${f%%.} .output` - if [ "$case" != "$f" ] ; then -echo Now! - diffCase - ok $case - elif [ -f $case.alan -a -f $case.expected ] ; then - diffCase - ok $case - fi - done -else - for f in *.output ; do - case=`basename $f .output` - if [ -f $case.alan -a -f $case.expected ] ; then - diffCase - ok $case - fi - done -fi diff --git a/app/src/main/jni/terps/alan/alan3/bin/jregr b/app/src/main/jni/terps/alan/alan3/bin/jregr deleted file mode 100755 index 33682ed..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/jregr +++ /dev/null @@ -1,10 +0,0 @@ -#! /bin/bash -d=`dirname $0` -uname=`uname -a` -if [[ "$uname" == *[Cc]ygwin* ]]; then - d=`cygpath -d $d`\\; -else - d=$d/; -fi -java -jar "$d"jregr.jar $@ - diff --git a/app/src/main/jni/terps/alan/alan3/bin/jregr.jar b/app/src/main/jni/terps/alan/alan3/bin/jregr.jar deleted file mode 100755 index 1cc79bf..0000000 Binary files a/app/src/main/jni/terps/alan/alan3/bin/jregr.jar and /dev/null differ diff --git a/app/src/main/jni/terps/alan/alan3/bin/jregradd b/app/src/main/jni/terps/alan/alan3/bin/jregradd deleted file mode 100755 index 0d5d33d..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/jregradd +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# Add the files of a new regression test case to the repository -if [ $# -ne 1 ] ; then - cat < -where - : the regresion case whose file should be added to the repository - -Add all existing and relevant files for a Jregr testcase to the Git repo. -At least the .alan file must exist. - -BUG: It should really look in the .jregr file to know which files to add. -EOF - exit -fi -c=${1%%\.} -git add "$c".alan -for x in expected input suspended; do - if [ -f "$c".$x ] ; then git add "$c".$x ; fi -done diff --git a/app/src/main/jni/terps/alan/alan3/bin/jregrcp b/app/src/main/jni/terps/alan/alan3/bin/jregrcp deleted file mode 100755 index 763dfef..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/jregrcp +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# Add the files of a new regression test case to the repository -if [ $# -ne 2 ] ; then - cat < -where - : name of the original test case - : name of the copy - -Copy all existing and relevant files for one test case to another. -At least the .alan file must exist. -EOF - exit -fi -cp "$1".alan "$2".alan -if [ -f "$1".expected ] ; then cp "$1".expected "$2".expected; fi -if [ -f "$1".input ] ; then cp "$1".input "$2".input ; fi diff --git a/app/src/main/jni/terps/alan/alan3/bin/jregrmv b/app/src/main/jni/terps/alan/alan3/bin/jregrmv deleted file mode 100755 index 41b4521..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/jregrmv +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# Move the files with pattern $1 replacing it for the string $2 -if [ $# -ne 2 ] ; then - cat << EOF -Usage: `basename $0` -where - : the string that will be matched to existing filenames with ** - : the string with which to replace it in the file names - -`basename $0` is aimed to rename Jregr testcases, but in fact just -does a replace of with in filenames in the -current directory. - -A special twist is that if the file renamed is a Jregr .expected file -then the replacement is also performed inside that file so that the -case name changes in order for the test to pass directly even after -the name change. - -If that is not a problem you can possibly use this to rename any set -of files matching a string. -EOF - exit -fi - -# Do the replace for all files matching -for f in *$1* -do - if [[ $f == *.expected ]] - then - echo sed -i.bak -e s%$1%$2%g $f - sed -i.bak -e s%$1%$2%g $f - fi - git mv $f ${f//$1/$2} -done diff --git a/app/src/main/jni/terps/alan/alan3/bin/l b/app/src/main/jni/terps/alan/alan3/bin/l deleted file mode 100755 index dee2331..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/l +++ /dev/null @@ -1,79 +0,0 @@ -#! /bin/sh -# -# Script for listing regression tests of Alan and Arun -# -verify() -{ - if [ -f $case.suspended ] - then - suspended=`expr $suspended + 1` - echo "$case: Suspended..." - else if [ -f $case.expected ] - then - if [ -f $case.output ] - then - failed=`expr $failed + 1` - echo "$case: *** FAILED!!! ***" - else - ok=`expr $ok + 1` - fi - else - new=`expr $new + 1` - echo "$case: NEW!" - fi - fi -} - -cases=0 -ok=0 -failed=0 -suspended=0 -new=0 -if [ $# != 0 ] ; then - for f in ${*} ; do - case=`basename $f .alan` - if [ "$case" != "$f" ] - then - verify - elif [ -f $case.alan ] - then - verify - fi - done -else - for d in *; do - if [ -d $d ] - then - if [ -f $d/regr ] - then - echo "Recursing: $d" - cd $d; regr; cd .. - echo "Leaving: $d" - fi - fi - done - - for f in *.alan ; do - case=`basename $f .alan` - verify - done -fi -if test $new -ne 0 -then - echo -n "$new new, " -fi -if test $suspended -ne 0 -then - echo -n "$suspended suspended, " -fi -if test $failed -eq 0 -then - if test $new -eq 0 - then - echo All $cases OK! - else - echo $ok OK! - fi -else - echo "*** $failed FAILED! ***" -fi diff --git a/app/src/main/jni/terps/alan/alan3/bin/monitor b/app/src/main/jni/terps/alan/alan3/bin/monitor deleted file mode 100755 index 4c4a16b..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/monitor +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/bash -# Continuously monitor a file for changes -# then run a command in current directory -if [ $# -lt 2 ] ; then - echo "Usage: `basename $0` " - echo "Run , then wait until changes and run it again" - exit -fi -file="$1" -shift -commands="$*" -d0=`perl -e '$mtime=(stat("'$file'"))[9]; print $mtime;'` -while true; do - echo -ne '\033c' - $commands - d0=$d1 - d1=`perl -e '$mtime=(stat("'$file'"))[9]; print $mtime;'` - while [ $d0 -eq $d1 ] ; do - sleep 5 - d1=`perl -e '$mtime=(stat("'$file'"))[9]; print $mtime;'` - done -done diff --git a/app/src/main/jni/terps/alan/alan3/bin/monitor2 b/app/src/main/jni/terps/alan/alan3/bin/monitor2 deleted file mode 100755 index 3116272..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/monitor2 +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/bash -# Continuously monitor a (set of) file(s) for changes -# then run a command in current directory -if [ $# -lt 2 ] ; then - echo "Usage: `basename $0` -e " - echo "where" - echo " : the file(s) to monitor" - echo " : the command(s) to run when changes" - exit -fi -commandoptiongiven=0 -while [[ $1 ]] ; do - case "$1" in - -e) - shift - commandoptiongiven=1 - break - ;; - *) - files+=("$1") - shift - ;; - esac -done - -if [ $commandoptiongiven -ne 1 ] ; then - echo "Error: no command given to execute (use -e as separator)" - exit -fi - -command="$*" - -lasttime=0 -while true ; do - while true ; do - d0=$lasttime - for file in ${files[@]} ; do - d1=`perl -e '$mtime=(stat("'$file'"))[9]; print $mtime;'` - if [ $d0 -lt $d1 ] ; then - f=$file - d0=$d1 - fi - done - if [ $d0 -gt $lasttime ] ; then - echo -ne '\033c' - echo "Triggered by $f:" - $command - lasttime=$d0 - fi - sleep 2 - done -done diff --git a/app/src/main/jni/terps/alan/alan3/bin/monitor3 b/app/src/main/jni/terps/alan/alan3/bin/monitor3 deleted file mode 100755 index 90824a5..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/monitor3 +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash -# Continuously monitor a (set of) file(s) for changes, -# files are specified using extensions and dir tree recursed, -# then run a command in current directory -if [ $# -lt 2 ] ; then - echo "Usage: `basename $0` -e " - echo "where" - echo " : the file extension(s) to monitor" - echo " : the command(s) to run when changes" - exit -fi -commandoptiongiven=0 -while [[ $1 ]] ; do - case "$1" in - -e) - shift - commandoptiongiven=1 - break - ;; - *) - extensions+=("$1") - shift - ;; - esac -done - -if [ $commandoptiongiven -ne 1 ] ; then - echo "Error: no command given to execute (use -e as separator)" - exit -fi - -command="$*" - -lasttime=0 -while true ; do - while true ; do - d0=$lasttime - for ext in ${extensions[@]} ; do - files=`find . -name \*$ext` - for file in ${files[@]} ; do - d1=`perl -e '$mtime=(stat("'$file'"))[9]; print $mtime;'` - if [ -n "$d1" ] ; then - if [ $d0 -lt $d1 ] ; then - f=$file - d0=$d1 - fi - fi - done - done - if [ $d0 -gt $lasttime ] ; then - echo -ne '\033c' - echo "Triggered by $f:" - $command - lasttime=$d0 - fi - sleep 2 - done -done diff --git a/app/src/main/jni/terps/alan/alan3/bin/o b/app/src/main/jni/terps/alan/alan3/bin/o deleted file mode 100755 index 3ded78d..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/o +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -f=${1%%\.} -f="${f%.output}" -f="${f%.}" -less $f.output - diff --git a/app/src/main/jni/terps/alan/alan3/bin/ok b/app/src/main/jni/terps/alan/alan3/bin/ok deleted file mode 100755 index e1e50f3..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/ok +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh -f=${1%%\.} -f="${f%.output}" -f="${f%.}" -mv $f.output $f.expected diff --git a/app/src/main/jni/terps/alan/alan3/bin/r b/app/src/main/jni/terps/alan/alan3/bin/r deleted file mode 100755 index 3fae0a5..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/r +++ /dev/null @@ -1,33 +0,0 @@ -#! /bin/sh -# -# Script for running tests of Alan and Arun -# - -run () -{ - /bin/echo -n "$case : " - if [ -f ./.regr ] ; then - ./.regr $case - else - alan -debug $case - arun $case < $case.input - fi - cases=`expr $cases + 1` -} - -cases=0 -if [ $# != 0 ] ; then - for f in ${*} ; do - case=`basename ${f%%.} .alan` - if [ "$case" != "$f" ] ; then - run - elif [ -f $case.alan ] ; then - run - fi - done -else - for f in *.alan ; do - case=`basename $f .alan` - run - done -fi diff --git a/app/src/main/jni/terps/alan/alan3/bin/regr b/app/src/main/jni/terps/alan/alan3/bin/regr deleted file mode 100755 index 241cc85..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/regr +++ /dev/null @@ -1,197 +0,0 @@ -#!/usr/bin/env bash -# -# Script for regression testing of Alan Adventure Language System -# Files: -# .regr - the command to be run using the case name as the single arg -# also indicates that this directory should be recursed into -# .case - the extension (including period) to be considered test cases -# if available indicates that there are cases in this directory -# .ignore - this complete directory is to be ignored when recursing -# .suspended - the case is suspended, probably pending some changes -# -function run () -{ - /bin/echo -n "$theCase : " -# if [ ! -f $theCase.suspended ] -# then - /bin/echo "########## $theCase ##########" >$theCase.output - ./.regr $theCase >>$theCase.output 2>&1 - cases=`expr $cases + 1` -# fi -} - -function verify() -{ - /bin/echo " " >> TEST-regr.xml - if [ -f $theCase.expected ] ; then - if diff -q -b $theCase.output $theCase.expected 1> /dev/null ; then - if [ -f $theCase.suspended ] ; then - suspended=`expr $suspended + 1` - suspendedok=`expr $suspendedok + 1` - /bin/echo "Suspended...(but OK)" - else - ok=`expr $ok + 1` - if [ $interactive = 1 ] ; then - tput cr - # TODO CYGWIN should be set on cygwin somehow, now it seems it's always true - if [ CYGWIN ] ; then - /bin/echo -n " " - tput cr - else - tput ce #- This should really work, but doesn't on cygwin ;-( so we need to do the two lines above instead - fi - else - /bin/echo "ok" - fi - fi - rm $theCase.output - else - if [ -f $theCase.suspended ] ; then - suspended=`expr $suspended + 1` - /bin/echo "Suspended...(and failed)" - else - failed=`expr $failed + 1` - /bin/echo "*** FAILED!!! ***" - /bin/echo " " >> TEST-regr.xml - /bin/echo "> TEST-regr.xml - diff -c -b $theCase.output $theCase.expected 1>> TEST-regr.xml - /bin/echo "]]>" >> TEST-regr.xml - /bin/echo " " >> TEST-regr.xml - fi - fi - else - if [ -f $theCase.suspended ] ; then - suspended=`expr $suspended + 1` - suspendedpending=`expr $suspendedpending + 1` - /bin/echo "Suspended...(pending)" - else - pending=`expr $pending + 1` - /bin/echo -n " " >> TEST-regr.xml - /bin/echo "The file '$theCase.output' does not exist" >> TEST-regr.xml - /bin/echo " " >> TEST-regr.xml - /bin/echo "PENDING!" - fi - fi -# fi - /bin/echo " " >> TEST-regr.xml -} - -function summary () -{ - /bin/echo -n "Total $cases tests" - if [ $suspended -ne 0 ] ; then - /bin/echo -n " ($suspended suspended" - if [ $suspendedpending -gt 0 ] ; then - /bin/echo -n ", $suspendedpending pending" - fi - if [ $suspendedok -gt 0 ] ; then - /bin/echo -n ", $suspendedok actually ok" - fi - /bin/echo -n ")" - fi - /bin/echo -n ", " - if [ $pending -ne 0 ] ; then - /bin/echo -n "$pending pending, " - fi - if [ $failed -eq 0 ] ; then - if [ $pending -eq 0 ] ; then - /bin/echo -n All OK! - else - /bin/echo -n $ok OK! - fi - else - /bin/echo -n "*** $failed FAILED! ***" - fi - /bin/echo -} - -# TODO recurse should build a path to use in run/verify so that "recursing"/"leaving" is unnecessary: -# sub/test1 ok -# sub/test2 ok -# a ok -# b ok - -function recurse() -{ - cd "$1" - runall "$2" - cd .. -} - -function runall() -{ - if [ ! -f .ignore ] ; then - local path="$1" - for d in * ; do - if [ -d "$d" ] ; then - recurse "$d" "$path.$d" - fi - done - - if [ -f .regr ] ; then - echo :: $path :: - /bin/echo "" > TEST-regr.xml - /bin/echo "" >> TEST-regr.xml - ext=`cat .case` - command=`cat .regr` - for f in *$ext ; do - theCase=`basename $f $ext` - run "$path" - verify "$path" - done - /bin/echo "" >> TEST-regr.xml - fi - fi -} - -function runselected() -{ - /bin/echo "" > TEST-regr.xml - /bin/echo "" >> TEST-regr.xml - ext=`cat .case` - command=`cat .regr` - for f in ${*} ; do - theCase=`basename $f $ext` - if [ "$theCase" != "$f" ] ; then - run $command - verify - elif [ -f $theCase$ext ] ; then - run - verify - fi - done - /bin/echo "" >> TEST-regr.xml -} - -cases=0 -ok=0 -failed=0 -suspended=0 -suspendedok=0 -suspendedpending=0 -pending=0 - -if [ -t 0 ] ; then - interactive=1 -else - interactive=0 -fi - -if [ $# -gt 0 ] ; then - while getopts ni OPTION ; do - case ${OPTION} in - n) interactive=0;; - i) interactive=1;; - \?) echo "'-n' for non-interactive, '-i' for interactive output mode" - exit 2;; - esac - done - shift $(($OPTIND-1)) -fi - -if [ $# != 0 ] ; then - runselected ${*} -else - runall `basename "$PWD"` -fi -summary diff --git a/app/src/main/jni/terps/alan/alan3/bin/ud b/app/src/main/jni/terps/alan/alan3/bin/ud deleted file mode 100755 index d4097ba..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/ud +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -f=${1%%\.} -meld $f.expected $f.output diff --git a/app/src/main/jni/terps/alan/alan3/bin/vd b/app/src/main/jni/terps/alan/alan3/bin/vd deleted file mode 100755 index 2545056..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/vd +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -f=${1%%\.} -os=$(uname -s) -case $os in - "Linux") - diff=meld ;; - "CYGWIN_NT-6.1") - diff=meld ;; - #diff=/cygdrive/c/Program/Winmerge/WinMergeU ;; - *) - echo "No visual diff defined for" $os ;; -esac -$diff $f.expected $f.output diff --git a/app/src/main/jni/terps/alan/alan3/bin/vg b/app/src/main/jni/terps/alan/alan3/bin/vg deleted file mode 100755 index 7bf70b0..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/vg +++ /dev/null @@ -1,7 +0,0 @@ -#! /bin/bash -logfile=$1.vg -valgrind --leak-check=full --log-file=$logfile arun -r $1 < $1.input -cp $logfile $1-`date +%F-%H.%M`.vg -echo -n `date +%F-%H.%M`: >> $1.leaks -grep "definitely lost:" $logfile >> $1.leaks - diff --git a/app/src/main/jni/terps/alan/alan3/bin/wm b/app/src/main/jni/terps/alan/alan3/bin/wm deleted file mode 100755 index 54fc5f6..0000000 --- a/app/src/main/jni/terps/alan/alan3/bin/wm +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -/cygdrive/c/Program/WinMerge/WinMergeU $1.expected $1.output diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/classes.i b/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/classes.i deleted file mode 100755 index 4f050be..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/classes.i +++ /dev/null @@ -1,1387 +0,0 @@ --- ALAN NEW LIBRARY: CLASSES (file name: 'classes.i') - - --- This library file defines various object and actor classes, as well as the instance 'hero' --- (=the player character). Many of these classes are frequently used in verb --- definitions in 'verbs.i' so they should be edited or removed with caution. - - - --- 1. OBJECT CLASSES --- ================= - --- BACKGROUND - -- is present in the location but cannot be reached or taken. - -- It doesn't appear automatically in room descriptions. - -- An example of a background is for example a mountain visible in the distance. - -- Compare this with 'scenery' below. - --- CLOTHING - -- = a piece of clothing that behaves according to Alan Bampton's 'xwear.i' extension. - -- This extension has been assimilated to this library. - -- This extension prevents clothes from being worn in an illogical order, e.g. you - -- cannot put on a shirt if you are already wearing a jacket, and so forth. - -- Also the verbs 'wear', 'remove' and 'undress' are defined here. - --- CONTAINER_OBJECT - -- is an object that can contain things. - -- The contents of the object will be listed both after 'look' (= in the room description) - -- and after 'examine'. - -- See the tips in this section to change the conditions of the contents listing more - -- suitable for your purposes. - --- DEVICE - -- A machine or an electronic device, for example a TV. Can be turned - -- (=switched) on and off if it is not broken. - -- Attributes: 'on' and NOT 'on'. - --- DOOR - -- can be opened, closed, locked and unlocked. - -- Is by default closed, not locked. - -- Attributes: closeable, (not) closed, lockable, (not) locked. - --- LIQUID - -- can only be taken if it is in a container. You can fill something with it, - -- and you can pour it somewhere. - -- A liquid is by default NOT drinkable. - --- LIGHTSOURCE - -- IS natural or NOT natural - -- (a natural lightsource is for example a match or a torch). - -- Can be turned on and off, lighted and extinguished (= put out) if it - -- is not broken. A natural lightsource - -- cannot be turned on or off, it can only be lighted and extinguished. - --- SCENERY - -- Behaves like a normal object, can be reached and manipulated but not taken. - -- The default message for 'take' will be "You deem the [object] as not important for - -- your purposes and leave it where it is." - -- The default message for 'examine' will be "The [object] doesn't appear particularly - -- interesting." - -- A scenery object is not automatically listed after the room description when - -- you type 'look'. You have to include it manually in the room description. - -- Compare this with 'background' above. - --- SOUND - -- Can be listened to but not examined, searched, smelled or manipulated. - -- Cannot be turned on or off, this has to be implemented manually by giving - -- the sound the 'switchable' attribute. - --- SUPPORTER - -- You can put things on this and you can stand on this. It is declared a container, - -- so you can take things from it, as well. When there's something on a supporter, - -- an automatic listing of it will appear in the room description. - --- WEAPON - -- IS fireable (e.g. a cannon) or NOT fireable (e.g. a baseball bat). - --- WINDOW - -- can be opened, closed, looked through and out of. - - - - --- 2. ACTOR CLASSES --- ================ - --- PERSON - -- is able to talk - --- NAMED_PERSON - -- has no article in front of the name - --- MALE - -- a person that can be referred to with the pronoun 'him' - --- FEMALE - -- a person that can be referred to with the pronoun 'her' - - - --- 3. INSTANCE --- =========== - - --- the hero - - - - --- ============================================================= - --- ============================================================= --- --- 1. Object classes --- --- ============================================================= - --- ============================================================= - - - - - --- ============================================================= - --- BACKGROUND - --- ============================================================= - - -EVERY background ISA THING - IS NOT reachable. - DESCRIPTION "" -END EVERY. - - - - - - - --- ============================================================== - --- CLOTHING (+ the verbs WEAR, REMOVE, UNDRESS) - --- ============================================================== - - - --- To use this subclass, see the documentation text right after the --- code below. --- This subclass makes use of Alan Bampton's 'xwear.i' extension --- written originally for ALAN V2, converted here to V3 and --- assimilated fully to the present library. - - - - - ------------------------------------------------------------------ --- First, we declare the container for clothing. ------------------------------------------------------------------ - - -THE worn ISA ENTITY - CONTAINER TAKING CLOTHING. - HEADER "You are wearing" - ELSE "You're not wearing anything." -END THE. - - - - -------------------------------------------------------------------- --- Next, we define the syntaxes for verbs needed for putting on --- and taking off clothing. -------------------------------------------------------------------- - - -SYNTAX wear = wear (obj) - WHERE obj ISA CLOTHING - ELSE "That's not something you can wear." - wear = put 'on' (obj). - wear = put (obj) 'on'. - wear = don (obj). - -SYNTAX remove = remove (obj) - WHERE obj ISA CLOTHING - ELSE "That's not something you can remove since you're not wearing it." - remove = take 'off' (obj). - remove = take (obj) 'off'. - remove = doff (obj). - -SYNTAX undress = undress. - - -------------------------------------------------------------------- --- Now, we define some common attributes for clothing as well as --- how the above verbs behave with this subclass. -------------------------------------------------------------------- - - -EVERY clothing ISA OBJECT - - IS wearable. - IS sex 0. - IS headcover 0. - IS handscover 0. - IS feetcover 0. - IS topcover 0. - IS botcover 0. - - CONTAINER - - - VERB wear - - CHECK THIS NOT IN worn - ELSE "You are already wearing" SAY THE THIS. "." - AND THIS IS takeable - ELSE "You can't pick" SAY THE THIS. "up." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND sex OF THIS = sex OF hero OR sex OF THIS = 0 - ELSE - "On second thoughts you decide" - SAY THE THIS. "really won't suit a" - IF sex OF hero =1 - THEN "man" - ELSE "woman" - END IF. - "like you at all." - - - DOES ONLY - --------------------------------------------------------------------- --- 'wear_flag' is a multi-purpose flag used for several purposes in --- this library, here it is reset to 0 before proceeding as a matter --- of 'housekeeping' for the code. --------------------------------------------------------------------- - - SET wear_flag OF hero TO 0. - --------------------------------------------------------------------- --- First check to see if the player is carrying the item already, if --- not, set the 'wear_flag' to 1 to indicate the item was picked up --- in this turn. --------------------------------------------------------------------- - - IF THIS NOT IN hero - THEN - SET wear_flag OF hero TO 1. - END IF. - --------------------------------------------------------------------- --- Now see if the player can put this item on by testing --- all of its coverage attributes against the player's state. --------------------------------------------------------------------- - --------------------------------------------------------------------- --- First check the 'topcover' attributes, if 'obj' fails this test --- then it means the hero is already wearing clothes that cover the --- topcover area and those clothes are of the same layer or a layer --- that belongs on top of the 'obj' item. In either case it would --- NOT be possible to put on the 'obj'. To 'flag' this condition add --- 5 to the 'wear_flag' attribute as an indicator this test failed. --------------------------------------------------------------------- - - IF topcover OF THIS <> 0 AND topcover OF THIS <= SUM OF topcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - --- IF THIS IN tempworn THEN - IF handscover OF THIS <> 0 AND handscover OF THIS <= SUM OF handscover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF feetcover OF THIS <> 0 AND feetcover OF THIS <= SUM OF feetcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF headcover OF THIS <> 0 AND headcover OF THIS <= SUM OF headcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - --------------------------------------------------------------------- --- botcover is a special case, adjust the 'tempcovered OF hero' --- attribute so that the code rejects non sensible options. --- First of all, discount any coatlike clothes as these never --- affect ability to put on other lower body only garments. --------------------------------------------------------------------- - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 and botcover OF THIS < 33 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not technically affect ability to put on lower body only clothes. --- Special clause here excludes the full body coverage 'teddy' type --- garment - as a skirt WOULD prevent that from being removed. --- ( dress/coat garments automatically prevent this by virtue of --- having higher 'topcover' settings than the teddy ) --------------------------------------------------------------------- - - IF tempcovered OF hero >31 AND botcover OF THIS < 16 and botcover OF THIS <> 4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - --------------------------------------------------------------------- --- IF tempcovered OF hero is still > 15 then must have trousers --- type clothing on - therefore disallow wearing dress type clothing --- because, although technically possible, it is not very sensible. --------------------------------------------------------------------- - - IF tempcovered OF hero >15 AND botcover OF THIS > 16 - THEN - SET tempcovered OF hero TO tempcovered OF hero +16. - END IF. - --------------------------------------------------------------------- --- From here down, clothes DO work as they do for other areas. --------------------------------------------------------------------- - - IF botcover OF THIS <> 0 AND botcover OF THIS <= tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - --------------------------------------------------------------------- --- At this point, 'wear_flag' will be 0 if the obj was held by the --- player and can be put on, or l if he picked it up this turn and --- it can be put on. Any higher value means one or more of the --- tests failed and the player cannot put on these clothes. --------------------------------------------------------------------- - - IF wear_flag OF hero >1 THEN - IF THIS NOT IN hero - THEN - "You pick up the" SAY THE THIS. "." - END IF. - LOCATE THIS IN hero. - EMPTY worn IN tempworn. - LIST tempworn. - "Trying to put" - SAY THE THIS. - "on isn't very sensible." - EMPTY tempworn IN worn. - ELSIF wear_flag OF hero = 1 - THEN - LOCATE THIS IN worn. - "You pick up the" SAY THE THIS. - IF THIS IS plural - THEN - "and put them on." - ELSE - "and put it on." - END IF. - ELSE - LOCATE THIS IN worn. - "You put on" SAY THE THIS. "." - END IF. - -END VERB. - - - - -VERB remove - CHECK THIS IN worn - ELSE - "You are not wearing" SAY THE THIS. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - - DOES ONLY - - - SET wear_flag OF hero TO 0. - --------------------------------------------------------------------- --- Check the total 'topcover' of items worn. Because of the number --- sequence used, by dividing the sum of the worn attributes by two --- and then comparing the result to the individual 'topcover' of the --- obj in question, ( the former can only ever be greater than the --- latter if an article of clothing is worn that goes over 'obj' ) --- it's easy to tell if the obj ought to be removable. A temporary --- attribute is used here because it needs to be manipulated. Once --- again 'wear_flag' is used to indicate the results. --------------------------------------------------------------------- - - SET tempcovered OF hero TO SUM OF topcover IN worn /2. - IF topcover OF THIS <> 0 AND topcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - SET tempcovered OF hero TO SUM OF handscover IN worn /2. - IF handscover OF THIS <> 0 AND handscover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF feetcover IN worn /2. - IF feetcover OF THIS <> 0 AND feetcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF headcover IN worn /2. - IF headcover OF THIS <> 0 AND headcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - --------------------------------------------------------------------- --- botcover is a special case - first discount any coatlike clothes --- as these do not affect ability to take off other lower garments. --------------------------------------------------------------------- - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not affect ability to take off other lower garments. The 'teddy' --- type garment is expressly NOT included in the exclusion here. --------------------------------------------------------------------- - - IF tempcovered OF hero >31 and botcover OF THIS <>4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - --------------------------------------------------------------------- --- Now process the manipulated value just as was done for the others --------------------------------------------------------------------- - - SET tempcovered OF hero TO tempcovered OF hero /2. - IF botcover OF THIS <> 0 AND botcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - --------------------------------------------------------------------- --- Depending on the value of 'wear_flag' print and process the obj --- as needed. If 'wear_flag' is NOT 0 then the clothes cannot be --- removed. --------------------------------------------------------------------- - - IF wear_flag OF hero >0 THEN - LIST worn. - "Trying to take" SAY THE THIS. "off isn't very sensible." - ELSE - LOCATE obj IN hero. - "You take off" SAY THE THIS. "." - END IF. -END VERB. - - - - - - -VERB undress - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF COUNT IN worn, ISA CLOTHING > 0 - THEN "You don't feel like undressing is a good idea right now." - ELSE "You're not wearing anything you can remove." - END IF. - - -- or, to make it work, use the following lines instead: - --IF COUNT IN worn, ISA CLOTHING > 0 - --THEN EMPTY worn IN hero. - --"You remove all the items you were wearing." - --ELSE "You're not wearing anything you can remove." - -- END IF. -END VERB. - - - - - -VERB examine - DOES AFTER - IF THIS IS NOT OPAQUE - THEN - IF COUNT ISA OBJECT, IN THIS > 0 - THEN LIST THIS. - END IF. - END IF. -END VERB. - -END EVERY. - - --------------------------------------------------------------------- --- These attributes are used internally in the library - ignore! --------------------------------------------------------------------- - -ADD TO EVERY ACTOR - IS tempcovered 0. - IS wear_flag 0. - IS sex 0. -END ADD TO. - --------------------------------------------------------------------- --- A container used to provide a temporary storage space - ignore! --------------------------------------------------------------------- - -THE tempworn ISA OBJECT - CONTAINER TAKING CLOTHING. - HEADER "You're already wearing" -END THE tempworn. - - - - ------------------------------------------------------------------------ - - - ------------------------------------------------------------------------ --- DOCUMENTATION FOR CLOTHING ------------------------------------------------------------------------ - - --- The quick guide ------------------- - --- Here follows a quick overview for using the subclass 'clothing'. A more closely-detailed --- description of this subclass is found below this overview. - - --- A piece of clothing in your game should look something like these three examples: - --- THE jacket ISA CLOTHING AT lobby --- IS topcover 32. --- END THE. - --- THE jeans ISA CLOTHING IN wardrobe --- IS botcover 16. --- END THE. - --- THE hat ISA CLOTHING IN worn -- IN worn = worn by the player character --- IS headcover 2. --- END THE. - --- In defining a piece of clothing, you should --- 1) define it ISA CLOTHING (and not: ISA OBJECT) --- 2) give it one of five attributes 'headcover', 'topcover', botcover', 'footcover' --- or 'handcover'; sometimes two of these are needed. --- Which attribute(s) to use depends on the type of clothing; see the clothing table below. --- 3) A number 2, 4, 8, 16, 32 or 64 needs to be added after the above attribute. --- You cannot decide the number yourself; look it up from the clothing table below. --- If the value of an attribute for a piece of clothing is 0 in the table, don't mention this --- attribute in connection with your clothing object. - --- The above is enough; the rest is then handled automatically by the library. - --- End of the quick guide. See the clothing table right below. The following chapters --- shed more light on the principles and the use of this subclass. - - - - --- The clothing 'table' ------------------------ - --- Here is the chart showing a selection of fairly typical clothing items and the values to --- set to obtain appropriate behaviour. Should you wish to create an article of clothing not --- listed, usually a bit of lateral thought as to what it is most like and where it fits into --- the scheme of things will suggest a workable set of values, but be aware that you MUST use --- values in this chart, simply adding things with intermediate values is probably going to --- create nasty bugs: - - - --- Clothing Headcover Topcover Botcover Footcover Handcover - --- hat 2 0 0 0 0 --- vest/bra 0 2 0 0 0 --- undies/panties 0 0 2 0 0 --- teddy 0 4 4 0 0 --- blouse/shirt/T-shirt 0 8 0 0 0 --- dress/coveralls 0 8 32 0 0 --- skirt 0 0 32 0 0 --- trousers/shorts 0 0 16 0 0 --- sweater/pullover 0 16 0 0 0 --- jacket 0 32 0 0 0 --- coat 0 64 64 0 0 --- socks/stockings 0 0 0 2 0 --- tights/pantiehose 0 0 8 2 0 --- shoes/boots 0 0 0 4 0 --- gloves 0 0 0 0 2 - - - - - - --- The concept of "xwear.i" (This and the following chapters are taken from Alan ---------------------------- Bampton's 'xwear' documentation) - --- The basic idea behind this part of the library is that clothing is worn in --- 'layers' and it is rather silly to allow players to (say) take off or put --- on a shirt if they are wearing a jacket. To simulate this in ALAN I've chosen --- to apply a numeric based layering system, and divide the body into five zones --- of coverage. The zones are 'head', 'hands', 'feet', 'top' (for top half of torso) --- and 'bot' (for bottom half of torso). --- All objects have these five zones defined as default attributes (set to 0), for the --- head zone the attribute is headcover for the hands zone handscover and so on. --- Every clothing object will thus need one or more of its 'zonecover' attributes --- set to reflect the zone(s) it covers and its relative position in the layers of --- clothing worn. A simple example would be a shirt, this covers only the 'top' zone --- and so needs its topcover attribute to be set (to 8, just why it's 8 will become --- clear shortly). --- The principle used is that the closer to the skin an item is normally worn, --- the lower its 'cover' attribute is. The library operates on the assumption that --- items with higher value cover attributes for a particular zone are worn over items --- with lower value attributes. When a player attempts to put on an article of clothing, --- each zone it would affect is checked and compared to the related zonal total of any --- clothes already worn. If the value of the new clothing is not greater that the total(s) --- of clothing already worn (on a zone by zone basis) then the library will not allow --- the wearing of that item. There are a few notable exceptions to this rule, but --- I'll come back to those a little later. - - - --- How it works in practice ---------------------------- - --- This part of the library might sound complex, but it is actually very simple to use, --- here's an example of how it works. --- Assume our hero starts the game wearing just vest and shorts and the player issues --- the command 'put on shirt'. A quick check of the chart below should reveal that a shirt --- has only its topcover attribute set to non-zero, (all the other zones are zero, --- which means they are irrelevant for this item). --- The library totals the topcover attributes of all the clothes currently worn, like so:- --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- As there are no other clothes to consider, the library now compares the topcover attribute --- of the item we are attempting to put on, (a shirt with a topcover attribute of 8 in --- this case) to the total value of items already worn (2). --- Because the topcover attribute of the shirt (8) is greater than the calculated total (2), --- this is evaluated as being a 'legal' instruction and the library allows the shirt to be put on. --- Now consider the situation had the player started the game wearing vest, shorts and a jacket, --- this is what happens should he try to 'put on the shirt.' --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- Finally the library checks the jacket, this has a topcover attribute of 32, so total --- topcover is 2 + 32 = 34. --- Because the topcover attribute of the shirt (8) is now not greater than the calculated --- total (34), this is evaluated as being an 'illegal' instruction and the library won't --- allow the shirt to be put on. --- That demonstrates the basic principle of the library, removing clothes uses a variation --- of the 'compare to total' equation to allow / disallow removal of clothing, an example would --- be that our vest, shorts and jacket wearing player would NOT be allowed to remove --- the vest while he still had the jacket on. - - - --- Exceptions to the rule... ----------------------------- - --- Now I'll confuse the issue. Firstly the numbers in my chart are not born of some sort of --- weird fixation with multiples, there is a very good reason why the numbers are set as they --- are, computer/maths types will recognise the sequence and realise it is all 'binary' based --- and know it makes it possible to calculate exactly what the player is wearing in terms of --- layers. --- Some female clothing breaks the rules defined above and is not so easy to deal with. An example, --- although pantyhose is worn under a skirt, dress or coat it can actually be put on or removed --- with the garment worn over it still on. The library recognises this capability and deals with --- it properly by assigning the dress/skirt and coat items particular properties in that they --- don't affect the ability to wear or remove lower layer clothing that covers the bottom of --- the torso only. --- Although it's physically possible to put on/remove trousers while wearing a skirt or dress, --- this (and a few other neat dressing/undressing tricks) is considered illegal here. - - - - --- How to create clothes that use 'xwear.i' -------------------------------------------- - --- That covers the way the library works, here's how to define objects to actually make --- use of it. As an example, this is how to define a dress and restrict it to being worn --- by a female. - - --- THE dress ISA CLOTHING IN changingroom - -- NAME little black dress - -- MENTIONED "little black dress" - -- IS - -- botcover 32. - -- topcover 8. - -- sex 2. --- END THE. - --- Notice that it is only necessary to mention the attributes that are non-zero, this --- minimises the amount of coding required. Apart from making sure the hero is set as --- 'sex 2.' if we wish her to be able to wear this dress, this is all the author needs --- to do, the library will police what is wearable and keep track of things without any --- further work. --- I expect most authors would prefer to start their games with a player at least partially --- dressed. This is just a matter of defining the required clothes object as being in the --- 'worn' container. Here's how to define underwear that our female hero(ine?) starts --- the game wearing. - - --- THE bra ISA CLOTHING IN worn - -- NAME white bra - -- MENTIONED "white bra" - -- IS - -- topcover 2. - -- sex 2. --- END THE bra. - - --- THE panties ISA CLOTHING IN worn - -- NAME white panties - -- MENTIONED "white panties" - -- IS - -- botcover 2. - -- plural. - -- sex 2. --- END THE panties. - - --- The library as it stands also prevents wearing of duplicate clothes, or things that are --- logically mutually exclusive - e.g. the player can wear a dress or a skirt, but not both. - - - --- ============================================================= - - --- CONTAINER_OBJECT - - --- ============================================================= - - - -EVERY container_object ISA OBJECT -- ACTORS are separately defined as containers further below - CONTAINER - - VERB examine - DOES AFTER - IF THIS IS NOT OPAQUE - THEN LIST THIS. - END IF. - END VERB. - - VERB look_in - DOES AFTER - IF THIS IS NOT OPAQUE - THEN LIST THIS. - END IF. - END VERB. - -END EVERY. - - --- Tips for using container objects: - - --- 1) - --- The contents of a normal CONTAINER are not listed when examined. --- If you wish to have the contents listed after 'examine', you should --- --- instead of: --- --- THE box ISA OBJECT --- CONTAINER --- ... --- END THE. --- --- do this: --- --- THE box ISA CONTAINER_OBJECT --- ... --- END THE. --- --- Then, 'examine' works fine and lists the contents of the container. - - --- 2) - --- For the command 'inventory' to list the contents of a container --- the hero is carrying, you should manually list all possible containers --- that can be carried by the hero in your game --- under the verb 'inventory' in the file 'verbs.i', thus: --- --- VERB i --- DOES LIST hero. --- ... --- IF bag IN hero --- THEN LIST bag. --- END IF. --- --- IF box IN hero --- THEN LIST box. --- END IF. --- ... --- END VERB. --- --- If you leave out these additions, the bag and the box will be listed after 'inventory' --- in the following way: --- --- "You are carrying a bag and a box." --- --- only. But with the above additions, the outcome is e.g. --- --- "You are carrying a bag and a box. The bag contains a loaf of bread. The box is empty." - - - --- 3) - --- To declare a container the contents of which should not be listed after 'look' or 'examine', --- declare it an 'opaque container' in the following way: - --- THE box ISA OBJECT --- OPAQUE CONTAINER --- ... --- END THE. - - --- Objects in an opaque container cannot be seen or manipulated. --- To change this, use e.g. --- --- MAKE box NOT OPAQUE. --- - - - - - - --- ============================================================= - --- DEVICE - --- ============================================================= - - -EVERY device ISA OBJECT - IS switchable. - IS NOT 'on'. - - - VERB examine - DOES - IF THIS IS 'on' - THEN "It is currently on." - ELSE "It is currently off." - END IF. - END VERB. - - - VERB turn_on1, turn_on2, switch_on1, switch_on2 - CHECK THIS IS NOT broken - ELSE "Nothing happens." - AND THIS IS NOT 'on' - ELSE SAY THE THIS. "is already on." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS 'on'. - END VERB. - - - VERB turn_off1, turn_off2, switch_off1, switch_off2 - CHECK THIS IS 'on' - ELSE SAY THE THIS. "is already off." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - END VERB. - - -END EVERY. - - - - --- ============================================================= - --- DOOR - --- ============================================================= - - -EVERY door ISA OBJECT - IS closeable. - IS closed. - IS lockable. - IS NOT locked. - IS NOT takeable. - - - VERB examine - DOES - IF THIS IS closed - THEN "It is currently closed." - ELSE "It is currently open." - END IF. - END VERB. - - - VERB look_behind - DOES ONLY - IF THIS IS closed - THEN "You cannot look behind the door; it is closed." - ELSE "You notice nothing special behind the door." - END IF. - END VERB. - - - VERB look_under - DOES ONLY - IF THIS IS closed - THEN "The space under the closed door is so narrow that you can't - see anything of what lies on the other side." - ELSE "You notice nothing special under the door." - END IF. - END VERB. - - -END EVERY. - - - - --- ============================================================= - --- LIGHTSOURCE - --- ============================================================= - - -EVERY lightsource ISA OBJECT - IS NOT lit. - IS natural. -- A natural lightsource is for example a candle, a match or a torch. - -- A NOT natural lightsource is for example a flashlight or a lamp. - -- You cannot switch on or off a natural lightsource. - - VERB examine - DOES - IF THIS IS lit - THEN "It is currently lit." - ELSE "It is currently not lit." - END IF. - END VERB. - - - VERB light - CHECK THIS IS NOT lit - ELSE SAY THE obj. "is already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS natural - THEN "You light" SAY THE THIS. "." - MAKE THIS lit. - - ELSE "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END IF. - END VERB. - - - VERB extinguish - CHECK THIS IS lit - ELSE "But" SAY THE THIS. "is not providing light." - DOES ONLY "You extinguish the" SAY THE THIS. "." - MAKE THIS NOT lit. - END VERB. - - - - VERB turn_on1, turn_on2, switch_on1, switch_on2 - CHECK THIS IS NOT natural - ELSE "That's not something you can turn on." - AND THIS IS NOT lit - ELSE SAY THE THIS. "is already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END VERB. - - - - VERB turn_off1, turn_off2, switch_off1, switch_off2 - CHECK THIS IS NOT natural - ELSE "That's not something you can turn off." - AND THIS IS lit - ELSE SAY THE THIS. "is already off." - DOES ONLY - "You turn off the" SAY THIS. "." - MAKE THIS NOT lit. - - END VERB. - - -END EVERY. - - - --- ============================================================== - --- LIQUID - --- ============================================================== - - -EVERY liquid ISA OBJECT - - - VERB take - DOES ONLY "You cannot carry" SAY THE THIS. "around in your hands." - END VERB. - - - VERB pour - DOES ONLY "You pour the liquid onto the ground where it quickly evaporates." - LOCATE THIS AT nowhere. - END VERB. - - VERB pour_in - WHEN obj1 - DOES ONLY "You pour" SAY THE THIS. "into" SAY THE obj2. - LOCATE THIS AT obj2. - END VERB. - - VERB pour_on - WHEN obj1 - DOES ONLY "That wouldn't accomplish anything." - END VERB. - - VERB put_in - WHEN obj1 - DOES ONLY "You pour" SAY THE THIS. "into" SAY THE obj2. "." - LOCATE THIS IN obj2. - END VERB. - -END EVERY. - - - - --- ============================================================== - --- SCENERY - --- ============================================================== - - - -EVERY scenery ISA OBJECT - - DESCRIPTION "" - - VERB examine - DOES ONLY SAY THE THIS. "doesn't appear particularly interesting to you." - END VERB. - - VERB take - DOES ONLY "You deem" SAY THE THIS. "as not important to your - purposes and leave it where it is." - END VERB. - - VERB take_from - WHEN obj1 - DOES ONLY "You deem" SAY THE THIS. "as not important to your - purposes and leave it where it is." - END VERB. - -END EVERY. - - - --- =============================================================== - --- SOUND - --- =============================================================== - - -EVERY sound ISA OBJECT - IS NOT examinable. - IS NOT reachable. - IS NOT movable. - - VERB smell - DOES ONLY "That's not something you can smell." - END VERB. - -END EVERY. - - - - --- ============================================================== - --- SUPPORTER - --- ============================================================== - - -EVERY supporter ISA OBJECT - CONTAINER - HEADER "On" SAY THE THIS. "you see" - ELSE "There's nothing on" SAY THE THIS. "." - - -VERB examine - DOES AFTER LIST THIS. -END VERB. - -VERB search - DOES ONLY "You find nothing further of interest." -END VERB. - - -END EVERY. - - - - - --- ============================================================== - --- WEAPON - --- ============================================================== - - -EVERY weapon ISA OBJECT - IS NOT fireable. -END EVERY. - - - - - - --- ============================================================== - --- WINDOW - --- ============================================================== - - -EVERY window ISA OBJECT - IS closeable. - IS closed. - IS NOT takeable. - - VERB examine - DOES - IF THIS IS closed - THEN "It is closed." - ELSE "It is open." - END IF. - END VERB. - - VERB look_behind - DOES ONLY - "That's not possible." - END VERB. - - VERB look_out_of - DOES ONLY "You see nothing special looking out of the window." - END VERB. - - VERB look_through - DOES ONLY "You see nothing special looking through the window." - END VERB. - - - -END EVERY. - - - - - --- =============================================================== - --- =============================================================== --- --- 2. Actor classes --- --- =============================================================== - --- =============================================================== - - - --- First, we declare some common characteristics for all actors: - - -ADD TO EVERY ACTOR - IS NOT inanimate. - - CONTAINER -- so that actors can possess things - - - VERB examine - DOES AFTER - IF COUNT ISA THING, IN THIS > 0 -- this if-statement will make a description of an - THEN LIST THIS. -- actor's possessions show up every time the actor is examined - END IF. - END VERB. - - -END ADD TO. - - - - --- ================================================================ - --- PERSON - --- ================================================================ - - -EVERY person ISA ACTOR - HAS can_talk. -END EVERY. - - - --- ================================================================ - --- NAMED_ACTOR -- HAS NOT can_talk - --- ================================================================ - - -EVERY named_actor ISA ACTOR - DESCRIPTION SAY THIS. "is here." - IF COUNT ISA THING, IN THIS > 0 - THEN LIST THIS. - END IF. - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" -END EVERY. - - - - --- ================================================================ - --- NAMED_PERSON -- HAS can_talk - --- ================================================================ - - -EVERY named_person ISA PERSON - DESCRIPTION SAY THIS. "is here." - IF COUNT ISA THING, IN THIS > 0 - THEN LIST THIS. - END IF. - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" -END EVERY. - - --- ================================================================ - --- FEMALE AND MALE - --- ================================================================ - - -EVERY female ISA PERSON - PRONOUN her -END EVERY. - - -EVERY male ISA PERSON - PRONOUN him -END EVERY. - - - - --- ================================================================ - --- ================================================================ - --- 3. The instance HERO - --- ================================================================ - --- ================================================================ - - -THE hero ISA ACTOR - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" - MENTIONED "yourself" - IS NOT sitting. - IS NOT lying_down. - - CONTAINER - LIMITS -- remove this whole section (until 'HEADER') if you wish to have no limits to - -- how much the hero can carry. - COUNT 10 Then - "You can't carry anything more. You have to drop something - first." - WEIGHT 50 Then - "You can't carry anything more. You have to drop something - first." - - HEADER - IF CURRENT LOCATION IS NOT lit - THEN "Although you cannot see your belongings in the dark, you - remember that you're carrying" - ELSE "You are carrying" - END IF. - ELSE - "You are empty-handed." - - - VERB examine - DOES ONLY "You notice nothing unusual about yourself." - IF COUNT ISA CLOTHING, IN worn > 0 - THEN LIST worn. - END IF. - END VERB. - - - -END THE. - - -SYNONYMS - me, myself, yourself, self = hero. - - - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/locations.i b/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/locations.i deleted file mode 100755 index bd707be..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/locations.i +++ /dev/null @@ -1,334 +0,0 @@ --- ALAN NEW LIBRARY: LOCATIONS (file name: 'locations.i') - - --- This library file defines the default directions (exits) and the location 'nowhere', a useful --- place to locate things when you want to remove them from play. --- This file also defines two specific location types: rooms (= indoor locations) and --- sites (= outdoor locations). In addition, a class 'dark_location' is defined in this file. --- You may modify this file in any way that suits your purposes. --- To use this file, you should have it in the same folder as your source code file , and the line --- --- IMPORT 'locations.i'. --- --- in your source code. - - - --- ======================================================= - --- 1. The location 'nowhere' and the default directions - --- ======================================================= - - -THE nowhere ISA LOCATION - - EXIT - north, - south, - east, - west, - northeast, - southeast, - northwest, - southwest, - up, - down, - 'in', - out - - TO nowhere. - - -END THE nowhere. - - -SYNONYMS - n = north. - s = south. - e = east. - w = west. - ne = northeast. - se = southeast. - nw = northwest. - sw = southwest. - u = up. - d = down. - - - - - - --- ======================================================================= - --- 2. Location classes 'room' and 'site' for indoor and outdoor locations - --- ======================================================================= - - --- ROOM and SITE are optional location classes you can use to ease up coding. --- All ROOMS have a floor, walls and a ceiling. All SITES have a ground and a sky. --- Thus, you will be able to define e.g. --- --- THE kitchen ISA ROOM --- --- and it will automatically have a floor, walls and a ceiling, --- --- or: --- --- THE greenmeadow ISA SITE --- --- and the ground and the sky are automatically found in that location. --- --- --- Of course, you will still be able to define locations in the usual way, e.g. --- --- THE kitchen ISA LOCATION --- --- etc, but the floor, walls and ceiling won't be automatically included there. --- The walls, floor, ceiling, ground and sky are not takeable or movable. --- This library file also defines the sky and the ceiling to be out of reach, --- so that they can't be e.g. touched. - - - - - -THE outdoor ISA LOCATION -END THE outdoor. - - -THE indoor ISA LOCATION -END THE indoor. - - -EVERY room ISA LOCATION AT indoor -END EVERY. - - -EVERY site ISA LOCATION AT outdoor -END EVERY. - - -EVERY roomobject ISA OBJECT AT indoor -END EVERY. - - -EVERY siteobject ISA OBJECT AT outdoor -END EVERY. - - -THE floor ISA roomobject - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - VERB examine DOES ONLY - "You notice nothing unusual about the floor here." - END VERB. - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - -END THE. - - -THE walls ISA roomobject - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - VERB examine DOES ONLY - "You notice nothing unusual about the walls here." - END VERB. - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - -END THE. - - -SYNONYMS wall = walls. - - -THE ceiling ISA roomobject - IS NOT reachable. - DESCRIPTION "" - - VERB examine DOES ONLY - "You notice nothing unusual about the ceiling here." - END VERB. - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - -END THE. - - -THE ground ISA siteobject - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - VERB examine - DOES ONLY "You notice nothing unusual about the ground here." - END VERB. - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - VERB dig - DOES ONLY "The ground is not suitable for digging here." - END VERB. - -END THE. - - -THE sky ISA siteobject - IS NOT reachable. - DESCRIPTION "" - - VERB examine DOES ONLY - "You notice nothing unusual about the sky." - END VERB. - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - -END THE. - - - - --- NOTE: it is often a good idea to modify the 'examine' verb for the above objects. --- Here is an example for 'walls': - --- THE walls ISA roomobject --- : --- : --- VERB examine DOES ONLY --- IF hero AT kitchen --- THEN "Numerous shelves, full of various kitchen utensils, line the walls." --- ELSIF hero AT livingroom --- THEN "The walls are decorated with flowery wallpaper here." --- : --- : --- END IF. --- END VERB. --- END THE walls. --- --- In other words, making the description of the walls, etc., individual for each room --- gives a better impression than if you just use the default messages. - - - - - - - - --- ========================================================== - --- 3. Dark locations - --- ========================================================== - - - -ADD TO EVERY LOCATION -IS lit. -END ADD TO. - -EVERY dark_location ISA LOCATION - IS NOT lit. - - ENTERED - IF COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - THEN MAKE THIS lit. - END IF. - - DESCRIPTION - CHECK COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - ELSE "It is pitch black. You can't see anything at all." - -END EVERY dark_location. - - -WHEN CURRENT LOCATION IS NOT lit AND COUNT ISA lightsource, IS lit, HERE > 0 => -MAKE CURRENT LOCATION lit. -LOOK. - - -WHEN CURRENT LOCATION ISA dark_location AND CURRENT LOCATION IS lit -AND COUNT ISA lightsource, IS lit, HERE = 0 => -MAKE CURRENT LOCATION NOT lit. -"It is now pitch black." - - - - - --- To define a dark location, use the formulation seen in the following example: - - --- THE basement ISA dark_location --- EXIT up TO kitchen. --- ... --- END THE. - - --- The description of a dark_location will automatically be: "It is pitch black. --- You can't see anything at all." --- If you add a description to a dark location, this description will be shown only --- if/when the location will be lit by any means: - --- THE basement ISA dark_location --- DESCRIPTION "Cobwebs and old junk are the only things you see here." --- EXIT up TO kitchen. --- END THE. - - - --- In darkness, you are not able to manipulate things other than turn on a lightsource --- and drop items you're carrying (these checks are found in 'verbs.i'). You can exit normally --- and use verbs that don't require seeing, such as 'smell', 'listen' and 'think'. --- If you are in a dark location with an NPC (= a non-player character), you are able to --- communicate with him by asking and telling but not by showing and giving. If you wish to --- change this, see the respective verbs in 'verbs.i' and edit their checks. - --- Note that you cannot change the name of a location mid-game. Thus, if you make a dark location --- called e.g. 'Darkness' and make it lit at some point in the game, the name will still be 'Darkness' --- even if the location description can be changed to describe the illuminated location. --- To change the name, you must locate the hero in another location when the dark location --- is lit. For example, --- --- --- --- THE lantern ISA LIGHTSOURCE -- (see 'classes.i') --- VERB turn_on --- DOES --- IF hero AT darkness --- THEN LOCATE hero AT treasure_chamber. --- ... --- END IF. --- ... --- END VERB. --- --- etc. --- --- --- Alternatively, you can also use a rule, e.g. --- --- WHEN lantern IS lit AND hero AT darkness => LOCATE hero AT treasure_chamber. --- --- - - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/messages.i b/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/messages.i deleted file mode 100755 index 16d8045..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/messages.i +++ /dev/null @@ -1,52 +0,0 @@ --- ALAN NEW LIBRARY: MESSAGES (file name: 'messages.i') - - --- This library file lists all the standard runtime messages listed in the manual, for easy modification. - - - -MESSAGE AFTER_BUT: "You must give at least one object after '$1'." - AGAIN: "(again)" -- if you wish to disable this, set this message to an empty string ("") - BUT_ALL: "You can only use '$1' AFTER '$2'." - CAN_NOT_CONTAIN: "$+1 can not contain $+2." - CANT0: "You can't do that." - CARRIES: "$+1 carries" - 'CONTAINS': "$+1 contains" - CONTAINS_COMMA: "$01," - CONTAINS_AND: "$01 and" - CONTAINS_END: "$01." - EMPTY_HANDED: "$+1 is empty-handed." - HAVE_SCORED: "You have scored $1 points out of $2." - IS_EMPTY: "$+1 is empty." - MORE: "" - MULTIPLE: "You can't refer to multiple objects with '$v'." - NO_SUCH: "I can't see any $1 here." - NO_WAY: "You can't go that way." - NOT_MUCH: "That doesn't leave much to $v!" - NOUN: "You must supply a noun." - NOT_A_SAVEFILE: "That file does not seem to be an Alan game save file." - QUIT_ACTION: "Do you want to RESTART, RESTORE, QUIT or UNDO? " - -- these four alternatives are hardwired to the interpreter and cannot be changed. - REALLY: "Are you sure (RETURN confirms)?" - RESTORE_FROM: "Enter file name to restore from" - SAVE_FAILED: "Sorry, save failed." - SAVE_MISSING: "Sorry, could not open the save file." - SAVE_NAME: "Sorry, the save file did not contain a save for this adventure." - SAVE_OVERWRITE: "That file already exists, overwrite (y)?" - SAVE_VERSION: "Sorry, the save file was created by a different version." - SAVE_WHERE: "Enter file name to save in" - SEE_START: "There is $01" - SEE_COMMA: ", $01" - SEE_AND: "and $01" - SEE_END: "here." - NO_UNDO: "No further undo available." - UNDONE: "'$1' undone." - UNKNOWN_WORD: "I don't know the word '$1'." - WHAT: "I don't understand." - WHAT_WORD: "I don't know what you mean by '$1'." - WHICH_PRONOUN_START: "I don't know if you by '$1'" - WHICH_PRONOUN_FIRST: "mean $+1" - WHICH_START: "I don't know if you mean $+1" - WHICH_COMMA: ", $+1" - WHICH_OR: "or $+1." - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/test1.alan b/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/test1.alan deleted file mode 100755 index 8a8e588..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/test1.alan +++ /dev/null @@ -1,24 +0,0 @@ --- testgame - -IMPORT 'locations.i'. -IMPORT 'classes.i'. -IMPORT 'verbs.i'. - -THE jacket ISA CLOTHING - AT room1 - IS topcover 32. - CONTAINER -END THE. - -THE shirt ISA CLOTHING - AT room1 - IS topcover 8. -END THE. - -THE wallet ISA object IN jacket -END THE wallet. - -The room1 ISA ROOM -END THE. - -START AT room1. diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/verbs.i b/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/verbs.i deleted file mode 100755 index 30d7d6e..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2009-10-06/verbs.i +++ /dev/null @@ -1,5203 +0,0 @@ --- ALAN NEW LIBRARY: VERBS (file name: verbs.i) - ------ This library defines common verbs needed in gameplay. The verbs are listed alphabetically. ------ This file also includes common commands which are not actually verbs, such as inventory, ------ verbose and again. You are free to edit this file for your own purposes in any way you ------ like by adding, deleting or modifying verbs. Verbs originally defined in this file ------ are the following: - - ------ about (+ help, info) ------ again (+ g) ------ answer (+ reply) ------ ask (+ enquire, inquire, interrogate) ------ attack (+ beat, fight, hit, kick, punch) ------ attack with ------ bite (+ chew, taste) ------ break (+ destroy) ------ brief ------ burn ------ burn with ------ buy (+ purchase) ------ catch ------ clean (+ polish, wipe) ------ climb ------ climb on ------ close ------ close with ------ consult ------ credits (+ acknowledgments, author) ------ dance ------ dig ------ dive ------ dive in ------ drink ------ drive ------ drop (+ discard, dump) ------ eat ------ empty ------ enter (+ obj) ------ examine (+ check, inspect, observe, x) ------ exit (+ obj) ------ extinguish (+ put out, quench) ------ fill ------ fill with ------ find (+ locate) ------ fire ------ flip ------ follow ------ free (+ release) ------ get up ------ get off ------ give ------ go to ------ hint (+ hints) ------ inventory (+ i, inv) ------ jump ------ jump in ------ jump on ------ kill (+ murder) ------ kill with ------ kiss (+ hug, embrace) ------ lie down ------ lie in ------ lie on ------ lift ------ light (+ lit) ------ listen ('listen0') ------ listen to ('listen') ------ lock ------ lock with ------ look (+ gaze, peek) ------ look at ------ look behind ------ look in ------ look out of ------ look through ------ look under ------ look up ------ no ------ open ------ open with ------ play ------ play with ------ pour ------ pour in ------ pour on ------ pray ------ pry ------ pry with ------ pull ------ push ------ push with ------ put (+ place) ------ put behind ------ put down (works as 'drop') ------ put in (+ insert) ------ put near ------ put on ------ put under ------ read ------ (remove) (+ take off, doff) (in 'classes.i', subclass 'clothing') ------ restart ------ restore ------ rub ------ save ------ say ------ say to ------ score ------ search ------ sell ------ shake ------ shoot (at) ------ shoot with ------ shout (+ yell) ------ show ------ sing ------ sip ------ sit (down) ------ sit on ------ sleep (+ rest) ------ smell ('smell0') ------ smell (+ obj) ------ squeeze ------ stand (up) ------ stand on ------ swim ------ swim in ------ take (+ carry, get, grab, hold, obtain) ------ take from (+ remove from) ------ talk ------ talk to (+ speak) ------ tear (+ rip) ------ think ------ think about ------ throw ------ throw at ------ tie ------ tie to ------ touch (+ feel) ------ turn ------ turn on (+ switch on) ------ turn off (+ switch off) ------ (undress) (in classes.i', subclass 'clothing') ------ unlock ------ unlock with ------ use ------ use with ------ verbose ------ wait (+ z) ------ (wear) (+ put on, don) (in 'classes.i', subclass 'clothing') ------ what am i ------ what is ------ where am i ------ where is ------ who am i ------ who is ------ write ------ yes - - - ------ Directions (north, south, up, etc.) are declared in the file 'locations.i'. - ------ Verbs connected with wearing clothes ('remove', 'undress' and 'wear', together with ------ synonyms) are defined in the file 'classes.i', subclass 'clothing'. - - - - - ------ We first declare some default attributes for things (= objects and actors). ------ These attributes are frequently checked in verb definitions, to hinder ------ the use of verbs with objects and actors in an irrational way. For example, the hero ------ won't be able to eat something that is not edible, and so forth. - ------ Specific object and actor attributes that override or complete the following ------ attributes are declared in 'classes.i'. - - - - -ADD TO EVERY THING - - IS examinable. - inanimate. - movable. - reachable. - takeable. - - NOT broken. - NOT can_talk. - NOT closeable. - NOT closed. - NOT drinkable. - NOT edible. - NOT lit. - NOT lockable. - NOT locked. - NOT plural. - NOT readable. - NOT wearable. - NOT writeable. - - HAS text "". - -END ADD TO. - - - ------ Next, we declare synonyms for some prepositions so that ------ it is possible for the player to type for example both "put ball in box" and ------ "put ball into box", etc. - - -SYNONYMS - - -into, inside = 'in'. -onto = on. -thru = through. - - - - - - - - ------ The verbs: - - - - - --- ============================================================= - - ------ ABOUT - - --- ============================================================= - - -SYNTAX 'about' = 'about'. - - -VERB 'about' - DOES STYLE emphasized. - "This is a text adventure, also called interactive fiction, which means that what - goes on in the story depends on what you type at the prompt. Commands you can type - are for example GO NORTH (or NORTH - or just N), WEST, SOUTHEAST, UP, IN etc for moving around, but you can try many - other things too, like TAKE LAMP, DROP EVERYTHING, EAT APPLE, EXAMINE BIRD or - FOLLOW OLD MAN, to name just a few. LOOK (L) describes your surroundings, and - INVENTORY (I) lists what you are carrying. You can SAVE your game and RESTORE it - later on. - $pType CREDITS to see information about the author and the copyright issues. - $pTo stop playing and end the program, type QUIT.$p" - STYLE normal. -END VERB. - - -SYNONYMS help, info = 'about'. - - - --- ============================================================= - - ------ AGAIN (= g) - - --- ============================================================= - - -SYNTAX - again = again. - -VERB again - DOES - "[The AGAIN command is not supported in this game. You can use the 'up' and 'down' arrow - keys to scroll through your previous commands.]" -END VERB. - -SYNONYMS - g = again. - - - --- ============================================================= - - ------ ASK (= enquire, inquire, interrogate) - - --- ============================================================= - - -SYNTAX - ask = ask (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That doesn't seem to be something you can talk about with" SAY THE act. "." - -ADD TO EVERY THING - VERB ask - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act <> hero - ELSE "It doesn't make much sense to ask yourself about something." - DOES - IF topic IN act - THEN SAY THE act. "doesn't seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. "chooses to be silent." - ELSIF topic = hero - THEN """I think you know more about yourself than what I do!""" SAY THE act. "snaps." - ELSE """I don't know anything about" SAY THE topic. "$$!,""" SAY THE act. "snaps." - END IF. - END VERB. -END ADD TO. - - - -SYNONYMS enquire, inquire, interrogate = ask. - - ------ note that 'consult' is defined separately - - - - - - --- ============================================================= - - ------ ATTACK (+ beat, fight, hit, kick, punch) - - --- ============================================================= - - -SYNTAX - attack = attack (obj) - WHERE obj ISA THING - ELSE "Thats not something you can attack." - -ADD TO EVERY THING - VERB attack - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND obj NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND obj NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "That would be needlessly brutal." - END VERB. -END ADD TO. - - -SYNONYMS - beat, fight, hit, kick, punch = attack. - - - - - --- ============================================================== - - ------ ATTACK WITH - - --- ============================================================== - - -SYNTAX - attack_with = attack (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can attack." - AND obj2 ISA WEAPON - ELSE - IF obj2 ISA ACTOR - THEN "You cannot use" SAY THE obj2. "to attack anything." - ELSE "There's no point attacking anything with" - SAY THE obj2. "." - END IF. - - -ADD TO EVERY THING - VERB attack_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can $v." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 In hero - ELSE "You are not holding" SAY THE obj2. "." - AND obj1 <> hero - ELSE "It doesn't make sense to $v yourself." - AND obj1 NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND obj1 NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- =============================================================== - - ------ BITE (+ chew, taste) - - --- =============================================================== - - - -SYNTAX bite = bite (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can bite." - - -ADD TO EVERY OBJECT -VERB bite - CHECK obj IN hero - ELSE "You don't have" SAY THE obj. "." - AND obj IS edible - ELSE "That's not something you should $v." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You take a bite of" SAY THE obj. ". It tastes rather good." -END VERB. -END ADD TO. - - -SYNONYMS chew, taste = bite. - - - - --- =============================================================== - - ------ BREAK - - --- =============================================================== - - -SYNTAX break = break (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "That would be needlessly brutal." - ELSE "That's not something you can break." - END IF. - - -ADD TO EVERY OBJECT -VERB break - CHECK obj IS examinable - ELSE "That's not something you can break." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That would be needlessly brutal." -END VERB. -END ADD TO. - - -SYNONYMS destroy = break. - - - - - --- ================================================================ - - ------ BRIEF - - --- ================================================================ - - --- Use "Visits 0." or "Visits 1000." in the START section if you want --- the game to start in verbose or brief mode. - - - -SYNTAX - brief = brief. - -VERB brief - DOES - Visits 1000. - "Brief mode is now on. Location descriptions will only be shown - the first time you visit." -END VERB brief. - - - - --- ================================================================= - - ------ BURN - - --- ================================================================= - - - -SYNTAX - burn = burn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "That would be needlessly brutal." - ELSE "That's not something you can burn." - END IF. - - -ADD TO EVERY OBJECT - VERB burn - CHECK obj IS examinable - ELSE "That's not something you can burn." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You must state what you want to burn" SAY THE obj. "with." - END VERB. -END ADD TO. - - - - --- ================================================================= - - ------ BURN WITH - - --- ================================================================= - - - -SYNTAX - burn_with = burn (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN "That would be needlessly brutal." - ELSE "That's not something you can burn." - END IF. - AND obj2 ISA OBJECT - ELSE - IF obj2 ISA ACTOR - THEN "It doesn't make sense to burn something with" SAY THE obj2. "." - ELSE "It's not possible to burn something with that." - END IF. - - -ADD TO EVERY THING - VERB burn_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can burn." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You're not holding" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to burn something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't burn" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - - --- ================================================================== - - ------ BUY (+ purchase) - - --- ================================================================== - - - -SYNTAX - buy = buy (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can buy." - - -ADD TO EVERY OBJECT - VERB buy - CHECK obj IS examinable - ELSE "That's not something you can buy." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That's not for sale." - END VERB. -END ADD TO. - - -SYNONYMS purchase = buy. - - - - --- ================================================================== - - ------ CATCH - - --- ================================================================== - - - - -SYNTAX - catch = catch (obj) - WHERE obj ISA THING - ELSE "That's not something you can catch." - - -ADD TO EVERY THING - VERB catch - CHECK obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND hero IS NOT sitting - ELSE "It is difficult to catch anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to catch anything while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That doesn't need to be caught." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ CLEAN ( + wipe, polish) - - --- ================================================================== - - -SYNTAX - clean = clean (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can clean." - - -ADD TO EVERY OBJECT - VERB clean - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS wipe, polish = clean. - - ------ notice that 'rub' is defined separately - - - - - --- ============================================================== - - ------ CLIMB - - --- ============================================================== - - - -SYNTAX - climb = climb (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can climb." - - -ADD TO EVERY OBJECT - VERB climb - CHECK obj IS examinable - ELSE "That's not something you can climb." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb while lying down." - DOES "That's not something you can climb." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB ON - - --- ============================================================== - - - -SYNTAX - climb_on = climb 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can climb on." - - -ADD TO EVERY OBJECT - VERB climb_on - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES "That's not something you can climb on." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ CLOSE (+ shut) - - --- ============================================================== - - - - -SYNTAX - close = close (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can close." - -ADD TO EVERY OBJECT -VERB close - CHECK obj IS closeable - ELSE "That's not something you can close." - AND obj IS NOT closed - ELSE "It is already closed." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - MAKE obj closed. - "You close the" SAY THE obj. "." -END VERB. -END ADD TO. - - -SYNONYMS shut = close. - - - - --- ============================================================== - - ------ CLOSE WITH - - --- ============================================================== - - - -SYNTAX - close_with = close (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - Else "That's not something you can close." - AND obj2 ISA OBJECT - Else "You can't close anything with that." - -ADD TO EVERY OBJECT - VERB close_with - WHEN obj1 - CHECK obj1 IS closeable - ELSE "That's not something you can open." - AND obj1 IS NOT closed - ELSE "It is already closed." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't close" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ CONSULT - - --- ============================================================== - - - - -SYNTAX consult = consult (obj1) about (obj2)! - WHERE obj1 ISA THING - ELSE "That's not something you can consult." - AND obj2 ISA THING - ELSE "That's not something you can find information about." - consult = 'look' 'up' (obj2) 'in' (obj1). - - -ADD TO EVERY THING -VERB consult - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can consult." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj1 <> hero - ELSE "It doesn't make sense to $v yourself about anything." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 ISA OBJECT - THEN "You find nothing useful about" SAY THE obj2. "in" SAY THE obj1. "." - ELSE SAY THE obj1. "chooses to be silent on that subject." - END IF. -END VERB. -END ADD TO. - - ---- another 'consult' formulation added to guide players to use the right phrasing: - -SYNTAX consult_error = consult (obj) - WHERE obj ISA THING - ELSE "That's not something you can consult." - -ADD TO EVERY THING -VERB consult_error - DOES "To consult something, use the formulation CONSULT PERSON/THING ABOUT PERSON/THING." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ CREDITS (+ acknowledgments) - - --- ============================================================== - - - -SYNTAX - credits = credits. - -VERB credits - DOES - "The author retains the copyright to this game. - $pThis game was written using the ALAN Adventure Language. ALAN is - an interactive fiction authoring system by Thomas Nilsson. - $nE-mail address: thomas.nilsson@progindus.se $pFurther information - about the ALAN system can be obtained from - the World Wide Web Internet site - $ihttp://www.alanif.se$p" -END VERB. - - -SYNONYMS acknowledgments, author = credits. - - - - --- ============================================================== - - ------ DANCE - - --- ============================================================== - - - - - -SYNTAX - dance = dance. - - -VERB dance - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dance while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dance while lying down." - DOES - "How about a waltz?" -END VERB. - - - - --- ============================================================== - - ------ DIG - - --- ============================================================== - - - - -SYNTAX dig = dig (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can dig." - - -ADD TO EVERY OBJECT -VERB dig - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dig anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dig anything while lying down." - DOES "There is nothing suitable to dig here." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ DIVE - - --- ============================================================== - - - - -SYNTAX dive = dive. - -VERB dive - CHECK hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "There is no water suitable for swimming here." -END VERB. - - - - --- ============================================================== - - ------ DIVE IN - - --- ============================================================== - - - - -SYNTAX dive_in = dive 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can dive into." - - -ADD TO EVERY OBJECT -VERB dive_in - CHECK hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That's not something you can dive into." -END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ DRINK - - --- ============================================================== - - -SYNTAX -drink = drink (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can drink." - -ADD TO EVERY OBJECT -VERB drink - CHECK obj IS drinkable - ELSE "That's not something you can drink." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IN hero - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - LOCATE obj AT nowhere. - "You drink all of" SAY THE obj. "." -END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ DRIVE - - --- ============================================================== - - - -SYNTAX drive = drive (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can drive." - - -ADD TO EVERY OBJECT -VERB drive - DOES - "That's not something you can drive." -END VERB. -END ADD TO. - - --- another 'drive' formulation added to guide players to use the right phrasing: - -SYNTAX drive_error = drive. - -VERB drive_error - DOES "To drive something, use the phrasing DRIVE SOMETHING." -END VERB. - - - - --- ============================================================== - - ------ DROP - - --- ============================================================== - - -SYNTAX - drop = drop (obj)* - WHERE obj ISA OBJECT - ELSE "That's not something you can drop." - drop = put (obj) * down. - drop = put down (obj)*. - - -ADD TO EVERY OBJECT - VERB drop - CHECK obj IN hero - ELSE "You aren't carrying" SAY THE obj. "." - DOES - LOCATE obj HERE. - "Dropped." - END VERB. -END ADD TO. - -SYNONYMS - discard, dump = drop. - - - - --- ============================================================== - - ------ EAT - - --- ============================================================== - - - -SYNTAX - eat = eat (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can eat." - - - -ADD TO EVERY OBJECT - VERB eat - CHECK obj IS edible - ELSE "That's not something you can eat." - AND obj IN hero - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - LOCATE obj AT nowhere. - "You eat all of" SAY THE obj. "." - END VERB. -END ADD. - - - - --- ============================================================== - - ------ EMPTY - - --- ============================================================== - - -SYNTAX 'empty' = 'empty' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can empty." - AND obj ISA CONTAINER - ELSE "That's not something you can empty." - - - -ADD TO EVERY OBJECT -VERB 'empty' - CHECK obj IN hero - ELSE "You're not holding" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You empty the contents of" SAY THE THIS. "on the floor." - LOCATE THIS AT hero. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ ENTER (+ obj) - - --- ============================================================== - - - -SYNTAX enter = enter (obj) - WHERE obj ISA CONTAINER - ELSE "That's not something you can enter." - - -ADD TO EVERY OBJECT -VERB enter - CHECK hero IS NOT sitting - ELSE "It is difficult to enter anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to enter anything while lying down." - DOES "That's not something you can enter." -END VERB. -END ADD TO. - - ---- another 'enter' formulation declared to guide players to use the right formulation: - - -SYNTAX enter_error = enter. - -VERB enter_error - DOES "You must state what you want to enter." -END VERB. - - - --- ============================================================== - - ------ EXAMINE (+ look at) - - --- ============================================================== - - - -SYNTAX - examine = examine (obj) - WHERE obj ISA THING - ELSE "That's not something you can examine." - - -SYNTAX - examine = 'look' 'at' (obj). - - -ADD TO EVERY THING - VERB examine - CHECK obj IS examinable - ELSE "You can't examine" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "You can't see anything in the dark." - DOES - IF obj IS readable - THEN - IF text OF obj = "" - THEN "There is nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. ". It says ""$$" SAY text OF obj. "$$""." - END IF. - ELSE "There is nothing special about" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - - -SYNONYMS - 'check', inspect, observe, x = examine. - - - - --- ============================================================== - - ------ EXIT (+ obj) - - --- ============================================================== - - - -SYNTAX 'exit' = 'exit' (obj) - WHERE obj ISA CONTAINER - ELSE "That's not something you can exit." - - -ADD TO EVERY OBJECT -VERB 'exit' - CHECK hero IN obj - ELSE "But you aren't in" SAY THE obj. "!" - DOES "You exit" SAY THE obj. "." - LOCATE hero AT CURRENT LOCATION. -END VERB. -END ADD TO. - - - ---- another 'exit' formulation added to guide players to use the right formulation: - - -SYNTAX exit_error = 'exit'. - - -VERB exit_error - DOES "You must state what you want to exit." -END VERB. - - - - --- ============================================================== - - ------ EXTINGUISH - - --- ============================================================== - - - - -SYNONYMS quench = extinguish. - - -SYNTAX extinguish = extinguish (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can extinguish." - extinguish = put 'out' (obj). - - -ADD TO EVERY OBJECT -VERB extinguish - DOES "That's not on fire." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL - - --- ============================================================== - - - - -SYNTAX fill = fill (obj) - WHERE obj ISA CONTAINER - ELSE "That's not something you can fill." - - -ADD TO EVERY OBJECT -VERB fill - DOES "You have to say what you want to fill" SAY THE obj. "with." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ FILL WITH - - --- ============================================================== - - -SYNTAX fill_with = fill (obj1) 'with' (obj2) - WHERE obj1 ISA CONTAINER - ELSE "That's not something you can fill." - AND obj2 ISA OBJECT - ELSE "It's not possible to fill something with that." - - - -ADD TO EVERY OBJECT -VERB fill_with - WHEN obj1 - CHECK obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to fill something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You fill" SAY THE obj1. "with" SAY THE obj2. "." - LOCATE obj2 IN obj1. -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ FIND - - --- ============================================================== - - - -SYNTAX - find = find (obj)! - WHERE obj ISA THING - ELSE "That's not something you need to find." - - -ADD TO EVERY THING - VERB find - CHECK obj NOT here - ELSE "The" SAY obj. "is right here!" - AND CURRENT LOCATION IS lit - ELSE "It's too dark to find anything here." - AND obj <> hero - ELSE "You're right here!" - DOES - "You'll have to find it yourself." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ FIRE - - --- ============================================================== - - - - -SYNTAX fire = fire (obj) - WHERE obj ISA WEAPON - ELSE "That's not something you can fire." - - -ADD TO EVERY OBJECT -VERB fire - CHECK obj IS fireable - ELSE "That's not something you can fire." - AND obj IN hero - ELSE "You are not holding" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You fire" SAY the obj. "into the air." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIRE AT - - --- ============================================================== - - - - -SYNTAX fire_at = fire (obj1) 'at' (obj2) - WHERE obj1 ISA WEAPON - ELSE "That's not something you can fire." - AND obj2 ISA THING - ELSE "That's not something you can shoot at." - - - -ADD TO EVERY OBJECT -VERB fire_at - WHEN obj1 - CHECK obj1 IS fireable - ELSE "That's not something you can fire." - AND obj1 IN hero - ELSE "You are not holding" SAY THE obj1. "." - AND obj2 <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That would be needlessly brutal." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ FIX (mend, repair) - - --- ============================================================== - - - -SYNTAX - fix = fix (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB fix - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS broken - ELSE "The" SAY obj. "doesn't need fixing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Please be more specific. How do you intend to fix it?" - END VERB. -END ADD TO. - - -SYNONYMS mend, repair = fix. - - - --- ============================================================== - - ------ FLIP - - --- ============================================================== - - - -SYNTAX flip = flip (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can flip." - - -ADD TO EVERY OBJECT -VERB flip - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES ONLY "That's not something you need to flip." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FOLLOW - - --- ============================================================== - - - - -SYNTAX follow = follow (obj)! - WHERE obj ISA THING - ELSE "That's not something you can follow." - - -ADD TO EVERY ACTOR -VERB follow - CHECK obj <> hero - ELSE "It doesn't make sense to follow yourself." - AND obj NOT AT hero - ELSE SAY THE obj. "is right here." - AND hero IS NOT sitting - ELSE "It is difficult to follow anybody while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to follow anybody while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj NOT NEAR hero - ELSE "You follow" SAY THE obj. - LOCATE hero AT obj. - DOES "You don't quite know where" SAY THE obj. "went. You must state a direction where you want to go." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FREE (+ release) - - --- ============================================================== - - - -SYNTAX free = free (obj) - WHERE obj ISA THING - ELSE "That's not something you can $v." - -ADD TO EVERY THING -VERB free - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj <> hero - ELSE "You don't need to be freed at present." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That doesn't need to be $vd." -END VERB. -END ADD TO. - - -SYNONYMS release = free. - - - - - --- ============================================================== - - ------- GET UP - - --- ============================================================== - - -SYNTAX get_up = take up. -- because 'get' is declared as a synonym of 'take' further below - - -VERB get_up - DOES - IF hero IS sitting - THEN "You stand up." - MAKE hero NOT sitting. - ELSIF hero IS lying_down - THEN "You get up." - MAKE hero NOT lying_down. - ELSE "You're standing up already." - END IF. -END VERB. - - - --- ============================================================== - - ------ GIVE (+ hand, offer) - - --- ============================================================== - - - - -SYNTAX - give = 'give' (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only give away objects." - AND obj2 ISA ACTOR - ELSE "That's not something you can give things to." - give = give (obj2) (obj1). - - -ADD TO EVERY OBJECT - VERB give - WHEN obj1 - CHECK obj1 IN hero - ELSE "You don't have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to give something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj2 = hero - THEN "You already have" SAY THE obj1. "!" - ELSE "You give" SAY THE obj1. "to" SAY THE obj2. "." - LOCATE obj1 IN obj2. - END IF. - END VERB. -END ADD TO. - - -SYNONYMS hand, offer = give. - - - - --- ============================================================== - - ------ GO TO - - --- ============================================================== - - -SYNTAX go_to = 'to' (obj)! -- because 'go' is predefined in the parser, it can't be used - WHERE obj ISA THING -- in verb definitions - ELSE "It's not possible to go to that." - -ADD TO EVERY THING -VERB go_to - CHECK obj <> hero - ELSE "You're right here!" - AND hero IS NOT sitting - ELSE "It is difficult to go anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to go anywhere while lying down." - DOES - IF obj AT hero - THEN - IF obj IS NOT reachable - THEN "You can't reach" SAY THE obj. "from here." - ELSE - IF CURRENT LOCATION IS lit - THEN "That's right here!" - ELSE "It is too dark to see." - END IF. - END IF. - ELSE "You can't see" SAY THE obj. "anywhere nearby. You must state a direction where you want to go." - END IF. -END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ HELP -> see ABOUT - - --- ============================================================== - - - - - - --- ============================================================== - - ------ HINT (+ hints) - - --- ============================================================== - - - -SYNONYMS - hints = hint. - -SYNTAX - hint = hint. - -VERB hint - DOES - "Unfortunately hints are not available in this game." -END VERB. - - - --- ============================================================== - - ------ INVENTORY (+ i, inv) - - --- ============================================================== - - - -ADD TO EVERY THING - IS weight 0. -END ADD TO THING. - - -ADD TO EVERY ACTOR IS - weight 50. -END ADD TO ACTOR. - - -ADD TO EVERY OBJECT -IS - weight 5. -END ADD TO OBJECT. - - -SYNTAX - i = i. - -VERB i - DOES LIST hero. - - IF COUNT IN worn > 0 -- see the file 'classes.i', subclass 'clothing' - THEN LIST worn. - END IF. - -END VERB. - - - -SYNONYMS inv, inventory = i. - - - - --- ============================================================== - - ------ JUMP - - --- ============================================================== - - - -SYNTAX - jump = jump. - -VERB jump - CHECK hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "You jump on the spot, to no avail." -END VERB. - - - - - --- ============================================================== - - ------ JUMP IN - - --- ============================================================== - - - - -SYNTAX - jump_in = jump 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can jump into." - AND obj ISA CONTAINER - ELSE "That's not something you can jump into." - -ADD TO EVERY OBJECT - VERB jump_in - CHECK obj IS reachable - ELSE SAY THE obj. "is too far away." - AND CURRENT LOCATION IS lit - ELSE "It's too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - IF obj ISA SUPPORTER - THEN "That's not something you can jump into." - ELSE "That wouldn't accomplish anything." - END IF. - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ JUMP ON - - --- ============================================================== - - - -SYNTAX - jump_on = jump 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can jump on." - AND obj ISA SUPPORTER - ELSE "That's not something you can jump on." - -ADD TO EVERY OBJECT - VERB jump_on - CHECK obj IS reachable - ELSE SAY THE obj. "is too far away." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL (+ murder) - - --- ============================================================== - - -SYNTAX kill = kill (obj) - WHERE obj ISA ACTOR - ELSE "That's not something you can $v." - - -ADD TO EVERY ACTOR -VERB kill - CHECK obj <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That would be needlessly brutal." -END VERB. -END ADD TO. - - - - - --- ============================================================== - - --- KILL WITH - - --- ============================================================== - - -SYNTAX kill_with = kill (obj1) 'with' (obj2) - WHERE obj1 ISA ACTOR - ELSE "That's not something you can $v." - AND obj2 ISA WEAPON - ELSE "You cannot kill anybody with" SAY THE obj2. "." - - -ADD TO EVERY ACTOR -VERB kill_with - WHEN obj1 - CHECK obj1 <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That would be needlessly brutal." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ KISS (+ hug, embrace) - - --- ============================================================== - - - -SYNTAX - kiss = kiss (obj) - WHERE obj ISA THING - ELSE "That's not something you can kiss." - -ADD TO EVERY THING -VERB kiss - CHECK obj IS examinable - ELSE "That's not something you can kiss." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj <> hero - ELSE "There is no time for that now." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj IS inanimate - THEN - "You $v" SAY THE obj. "." - ELSE - SAY THE obj. "avoids your advances." - END IF. -END VERB. -END ADD TO. - - -SYNONYMS hug, embrace = kiss. - - - - - --- ============================================================== - - ------ KNOCK - - --- ============================================================== - - - -SYNTAX - knock = knock 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can knock on." - -ADD TO EVERY OBJECT - VERB knock - CHECK obj IS examinable - ELSE "That's not something you can knock on." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You knock on" SAY THE obj. "$$. There's no reply." - END VERB. -END ADD TO. - - ---- another 'knock' formulation added to guide players to use the right phrasing: - -SYNTAX knock_error = knock. - -VERB knock_error - DOES "You need to specify what to knock on." -END VERB. - - - - --- ============================================================== - - ------ LIE DOWN - - --- ============================================================== - - - -SYNTAX lie_down = lie 'down'. - lie_down = lie. - - -VERB lie_down - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES "There's no need to lie down right now." -END VERB. - - - - - --- ============================================================== - - ------ LIE IN - - --- ============================================================== - - -SYNTAX lie_in = lie 'in' (obj) - WHERE obj ISA CONTAINER - ELSE "That's not something you can lie in." - lie_in = lie 'down' 'in' (obj). - - -ADD TO EVERY OBJECT -VERB lie_in - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES "There's no need to lie down in" SAY THE obj. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down in" SAY THE obj. "." - -- LOCATE hero IN obj. -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ LIE ON - - --- ============================================================== - - - -SYNTAX lie_on = lie 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can lie on." - lie_on = lie 'down' 'on' (obj). - - -ADD TO EVERY OBJECT -VERB lie_on - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES "There's no need to lie down on" SAY THE obj. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down on" SAY THE obj. "." - -- LOCATE hero IN obj. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LIFT - - --- ============================================================== - - - -SYNTAX lift = lift (obj) - WHERE obj ISA THING - ELSE "That's not something you can lift." - - -ADD TO EVERY THING -VERB lift - CHECK obj IS examinable - ELSE "That's not something you can lift." - AND obj IS reachable - ELSE "The object is too far away." - AND obj IS takeable - ELSE "It's not possible to lift that." - AND obj IS movable - ELSE "It's not possible to lift that." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND obj NOT IN hero - ELSE "You're already holding" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That wouldn't accomplish anything." - -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LIGHT (+ lit) - - --- ============================================================== - - - -SYNTAX - light = light (obj) - WHERE obj ISA LIGHTSOURCE - ELSE "That's not something you should lit." - - -ADD TO EVERY OBJECT - VERB light - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You don't have anything to light" SAY THE obj. "with." - END VERB. -END ADD TO. - - -SYNONYMS lit = light. - - - --- ============================================================== - - ------ LISTEN - - --- ============================================================== - - - - - -SYNTAX - listen0 = listen. - - -VERB listen0 - DOES - "You hear nothing unusual." -END VERB. - - - - --- ============================================================== - - ------ LISTEN TO - - --- ============================================================== - - - - -SYNTAX - listen = listen 'to' (obj)! - WHERE obj ISA THING - ELSE "That's not something you can listen to." - -ADD TO EVERY THING - VERB listen - CHECK obj <> hero - ELSE "It doesn't make sense to listen to yourself." - DOES - IF obj AT hero - - THEN "You hear nothing unusual." - ELSIF obj NEAR hero - THEN "You can't hear" SAY THE obj. "very well from here." - ELSE "You can't hear anything." - END IF. - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ LOCK - - --- ============================================================== - - -SYNTAX - lock = lock (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can lock." - - -ADD TO EVERY OBJECT - VERB lock - CHECK obj IS lockable - ELSE "That's not something you can lock." - AND obj IS NOT locked - ELSE "It's already locked." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You have to state what you want to lock" SAY THE obj. "with." - -- If you need this to work, use the following lines instead: - -- MAKE obj locked. "You" - -- IF obj IS NOT closed - -- THEN "close and" - -- MAKE obj closed. - -- END IF. - -- "lock" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK WITH - - --- ============================================================== - - - -SYNTAX - lock_with = lock (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can lock." - AND obj2 ISA OBJECT - ELSE "You can't lock anything with that." - -ADD TO EVERY OBJECT - VERB lock_with - WHEN obj1 - CHECK obj1 IS lockable - ELSE "That's not something you can lock." - AND obj1 IS NOT locked - ELSE "It's already locked." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IN hero - ELSE - "You don't have" SAY THE obj2. "." - DOES - "You can't lock" SAY THE obj1. "with" SAY THE obj2. "." - -- If you need this to work, use the following lines instead: - -- MAKE obj1 locked. "You" - -- IF obj1 IS NOT closed - -- THEN "close and" - -- MAKE obj1 closed. - -- END IF. - -- "lock" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK - - --- ============================================================== - - - -SYNONYMS - l = 'look'. - -SYNTAX - 'look' = 'look'. - -VERB 'look' - DOES - LOOK. -END VERB. - - - - --- ============================================================== - - ------ LOOK AT -> see EXAMINE - - --- ============================================================== - - - - - - - --- ============================================================== - - ------ LOOK BEHIND - - --- ============================================================== - - - - -SYNTAX look_behind = 'look' behind (obj) - WHERE obj ISA THING - ELSE "You can't look behind that." - -ADD TO EVERY THING -VERB look_behind - CHECK obj IS examinable - ELSE - "You can't look behind" Say The obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj <> hero - ELSE "Turning your head, you notice nothing unusual behind yourself." - DOES "You notice nothing unusual behind" SAY THE obj. "." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK IN - - --- ============================================================== - - - - -SYNTAX - look_in = 'look' 'in' (obj) - WHERE obj ISA OBJECT - ELSE "You can't look inside" SAY THE obj. "." - AND obj ISA CONTAINER - ELSE "You can't look inside" SAY THE obj. "." - - -ADD TO EVERY OBJECT - VERB look_in - CHECK obj IS examinable - ELSE - "You can't look inside" SAY THE obj. "." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - LIST obj. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK OUT OF - - --- ============================================================== - - -SYNTAX look_out_of = 'look' 'out' 'of' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can look out of." - -ADD TO EVERY OBJECT -VERB look_out_of - CHECK obj IS examinable - ELSE - "You can't look out of" Say The obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That's not something you can look out of." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK THROUGH - - --- ============================================================== - - - - -SYNTAX look_through = 'look' through (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can look through." - -ADD TO EVERY OBJECT -VERB look_through - CHECK obj IS examinable - ELSE - "You can't look through" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You can't see through" SAY THE obj. "." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ LOOK UNDER - - --- ============================================================== - - -SYNTAX look_under = 'look' under (obj) - WHERE obj ISA THING - ELSE "You can't look under that." - -ADD TO EVERY THING -VERB look_under - CHECK obj IS examinable - ELSE - "You can't look under" SAY THE obj. "." - AND obj <> hero - ELSE "It doesn't make sense to look under yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You notice nothing unusual under" SAY THE obj. "." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ LOOK UP -> see CONSULT - - --- ============================================================== - - - - - - - --- ============================================================== - - ------ NO - - --- ============================================================== - - - -SYNTAX 'no' = 'no'. - -VERB 'no' - DOES "You sound rather negative." -END VERB. - - - - - - - --- ============================================================== - - ------ OPEN - - --- ============================================================== - - - -SYNTAX - open = open (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can open." - -ADD TO EVERY OBJECT - VERB open - CHECK obj IS closeable - ELSE "That's not something you can open." - AND obj IS closed - ELSE "It's already open." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS NOT locked - ELSE SAY THE obj. "appears to be locked." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - MAKE obj NOT closed. - "You open" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ OPEN WITH - - --- ============================================================== - - -SYNTAX - open_with = open (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can open." - AND obj2 ISA OBJECT - ELSE "You can't open anything with" SAY THE obj2. - -ADD TO EVERY OBJECT - VERB open_with - WHEN obj1 - CHECK obj1 IS closeable - ELSE "That's not something you can open." - AND obj1 IS closed - ELSE SAY THE obj1. "is already open." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj1 IS NOT locked - ELSE SAY THE obj1. "appears to be locked." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't open" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY - - --- ============================================================== - - -SYNTAX 'play' = 'play' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can play." - - -ADD TO EVERY OBJECT -VERB 'play' - DOES "That's not something you can play." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ PLAY WITH - - --- ============================================================== - - -SYNTAX play_with = 'play' 'with' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can play with." - - -ADD TO EVERY OBJECT -VERB play_with - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You don't find it purposeful to start playing with" SAY THE obj. "." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR - - --- ============================================================== - - - -SYNTAX pour = pour (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can pour." - - - -ADD TO EVERY OBJECT -VERB pour - CHECK obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND obj IN hero - ELSE "You're not holding" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That's not something you can pour." -END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ POUR IN - - --- ============================================================== - - -SYNTAX pour_in = pour (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pour." - AND obj2 ISA CONTAINER - ELSE "You can't pour anything into that." - - -ADD TO EVERY OBJECT -VERB pour_in - WHEN obj1 - CHECK obj1 IN hero - ELSE "You don't have" SAY THE obj1. "." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is already in" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to pour something into itself." - AND obj2 IS NOT closed - ELSE "You can't, since the" SAY THE obj2. "is closed." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "It's not possible to pour" SAY THE obj1. "into" SAY THE obj2. "." - -- If you need to make this work, use the following lines instead: - -- "You pour" SAY THE obj1. "into" SAY THE obj2. "." - -- LOCATE obj1 IN obj2. -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ POUR ON - - --- ============================================================== - - - - -SYNTAX pour_on = pour (obj1) 'on' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pour." - AND obj2 ISA THING - ELSE "You can't pour anything onto that." - - -ADD TO EVERY OBJECT -VERB pour_on - WHEN obj1 - DOES - "That wouldn't accomplish anything." - -- (or, to make it work, use the following lines instead of the above: - -- "You pour" SAY THE obj1. "on" SAY THE obj2. ". Nothing happens." - LOCATE obj1 AT hero. -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ PRAY - - --- ============================================================== - - - -SYNTAX pray = pray. - -VERB pray - DOES "Prayers don't seem to help right now." -END VERB. - - - - --- ============================================================== - - ------ PRY - - --- ============================================================== - - -SYNTAX pry = pry (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can pry." - -ADD TO EVERY OBJECT -VERB pry - DOES "You must state what you want to pry" SAY THE obj. "with." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ PRY_WITH - - --- ============================================================== - - -SYNTAX pry_with = pry (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pry." - AND obj2 ISA OBJECT - ELSE "You can't pry anything with that." - - -ADD TO EVERY OBJECT -VERB pry_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can pry." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. - AND obj1 <> obj2 - ELSE "How intelligent." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That doesn't work." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ PULL - - --- ============================================================== - - -SYNTAX pull = pull (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN SAY THE obj. "wouldn't probably appreciate that." - ELSE "That's not something you can pull." - END IF. - - -ADD TO EVERY OBJECT -VERB pull - CHECK obj IS movable - ELSE "It's not possible to pull" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That wouldn't accomplish anything." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ PUSH - - --- ============================================================== - - -SYNTAX - push = push (obj) - WHERE obj ISA THING - ELSE "That's not something you can push." - - -ADD TO EVERY OBJECT - VERB PUSH - CHECK obj IS movable - ELSE "That's not something you can push." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj NOT IN hero - ELSE "But you're holding" SAY THE obj. "." - AND obj <> hero - ELSE "It doesn't make sense to push yourself." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You give" SAY THE obj. "a little push. Nothing happens." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ PUSH WITH - - --- ============================================================== - - - - -SYNTAX - push_with = push (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can push." - AND obj2 ISA OBJECT - ELSE "You can use only objects to push things with." - - -ADD TO EVERY OBJECT - VERB push_with - WHEN obj1 - CHECK obj1 IS movable - ELSE "That's not something you can push." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj1 NOT IN hero - ELSE "But you're holding" SAY THE obj1. "." - AND obj2 IN hero - ELSE "You're not holding" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to push something with itself." - AND obj1 <> hero - ELSE "It doesn't make sense to push yourself with something." - AND obj2 <> hero - ELSE "It doesn't make sense to push something with yourself." - AND obj1 IS inanimate - ELSE SAY THE obj1. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Using" SAY THE obj2. "you push" SAY THE obj1. "$$. Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT (+ lay, locate, place) - - --- ============================================================== - - - -SYNTAX - put = put (obj) * - WHERE obj ISA OBJECT - ELSE "You can't put that anywhere." - -ADD TO EVERY OBJECT - VERB put - CHECK obj IN HERO - ELSE "You don't have" SAY THE obj. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You must state where you want to put it." - END VERB. -END ADD TO. - -SYNONYMS - lay, 'locate', place = put. - - - --- ============================================================== - - ------ PUT DOWN (works as 'drop') - - --- ============================================================== - - ------ The syntax for 'put down' has been declared in the 'drop' verb. - - - - - - --- ============================================================== - - ------ PUT IN (+ insert) - - --- ============================================================== - - - -SYNTAX - put_in = put (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA CONTAINER - ELSE "You can't put anything there." - put_in = insert (obj1) 'in' (obj2). - - - -ADD TO EVERY OBJECT - VERB put_in - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to put something into itself." - AND obj1 <> hero - ELSE "You can't put yourself anywhere. If you want to enter something, just say so." - AND obj2 <> hero - ELSE "You can't put" SAY THE obj1. "into yourself! If you want to eat or drink something, - just say so." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is in" SAY THE obj2. "already!" - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS reachable AND obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - LOCATE obj1 IN obj2. - "Done." - ELSE "You haven't got" SAY THE obj1. "." - END IF. - ELSE - LOCATE obj1 IN obj2. - "Done." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT BEHIND, NEAR, UNDER - - --- ============================================================== - - -SYNTAX - put_near = put (obj1) 'near' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything near that." - - put_behind = put (obj1) behind (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything behind that." - - - - put_under = put (obj1) under (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything under that." - - -ADD TO EVERY OBJECT - VERB put_near, put_behind, put_under - WHEN obj1 - CHECK obj1 IN hero - ELSE - "You haven't got" SAY THE obj1. "." - AND obj2 NOT IN hero - ELSE - "That would be futile." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 <> obj2 - ELSE "That doesn't make sense." - AND obj2 <> hero - ELSE "That would be futile." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ PUT_ON - - --- ============================================================== - - --- to use this verb in the meaning 'wear', see the file 'classes.i', subclass 'clothing', verb 'wear'. - - - -SYNTAX put_on = put (obj1) 'on' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't well put anything on that." - AND obj2 ISA SUPPORTER - ELSE - IF obj2 ISA ACTOR - THEN SAY THE obj2. "might not appreciate that very much." - ELSE "You can't well put anything on that." - END IF. - - -ADD TO EVERY OBJECT - VERB put_on - WHEN obj1 - CHECK obj2 NOT IN hero - ELSE - "That would be futile." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 <> obj2 - ELSE "That doesn't make sense." - AND obj2 <> hero - ELSE "That would be futile." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is on" SAY THE obj2. "already." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS reachable AND obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN obj2. - "Done." - ELSE "You haven't got" SAY THE obj1. "." - END IF. - ELSE - LOCATE obj1 IN obj2. - "Done." - END IF. - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ PUT OUT (works as EXTINGUISH) - - --- ============================================================== - - - - - --- ============================================================== - - ------ QUIT - - --- ============================================================== - - - - -SYNONYMS q = 'quit'. - -SYNTAX - 'quit' = 'quit'. - -VERB 'quit' - DOES - QUIT. -END VERB. - - - --- ============================================================== - - ------ READ - - --- ============================================================== - - - -SYNTAX - read = read (obj) - WHERE obj ISA OBJECT - ELSE "You can't read that." - -ADD TO EVERY OBJECT - VERB read - CHECK obj IS examinable - ELSE "That's not something you can read." - AND obj IS readable - ELSE - "There is nothing written on" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF text OF obj = "" - THEN "There's nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. ". It says ""$$" SAY text OF obj. "$$""." - END IF. - END VERB. -END ADD TO. - - - - --- ============================================================== - - --- REMOVE - - --- ============================================================== - - - --- see the file 'classes.i', subclass 'clothing' for the definition of --- this verb - - - - - --- ============================================================== - - ------ REMOVE FROM ( => TAKE FROM) - - --- ============================================================== - - - - - --- ============================================================== - - ------ RESTART - - --- ============================================================== - - - -SYNTAX - 'restart' = 'restart'. - -VERB 'restart' - DOES - RESTART. -END VERB. - - --- ============================================================== - - ------ RESTORE - - --- ============================================================== - - - -SYNTAX - 'restore' = 'restore'. - -VERB 'restore' - DOES - RESTORE. -END VERB. - - - --- ============================================================== - - ------ RUB (+ massage) - - --- ============================================================== - - - - -SYNTAX - rub = rub (obj) - WHERE obj ISA THING - ELSE "That's not something you can rub." - - -ADD TO EVERY THING - VERB rub - CHECK obj IS examinable - ELSE "That's not something you can rub." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj <> hero - ELSE "There's no time for that now." - AND obj IS inanimate - ELSE "You aren't sure whether" SAY THE obj. "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS massage = rub. - - - --- ============================================================== - - ------ SAVE - - --- ============================================================== - - -SYNTAX - 'save' = 'save'. - -VERB 'save' - DOES - SAVE. -END VERB. - - - --- ============================================================== - - ------ SAY - - --- ============================================================== - - - -SYNTAX - say_word = 'say' (topic)! - WHERE topic ISA THING - ELSE "You can't say that." - -ADD TO EVERY THING - VERB say_word - DOES - SAY THE topic. "$$? That's a nice word!" - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SAY TO - - --- ============================================================== - - - -SYNTAX - say_to = 'say' (topic)! 'to' (act) - WHERE topic ISA THING - ELSE "Nothing happens." - AND act ISA ACTOR - Else "That's not something you can talk to." - -ADD TO EVERY THING - VERB say_to - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - DOES - SAY THE act. "doesn't seem interested." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ SCORE - - --- ============================================================== - - - -SYNTAX - 'score' = 'score'. - -VERB 'score' - DOES - SCORE. - -- (or, if you wish to disable the score, use the following kind of - -- line instead of the above:) - -- "There is no score in this game." -END VERB 'score'. - - - - - --- ============================================================== - - ------ SCRATCH - - --- ============================================================== - - -SYNTAX - scratch = scratch (obj) - WHERE obj ISA THING - ELSE "That's not something you can scratch." - - -ADD TO EVERY THING - VERB scratch - CHECK obj IS examinable - ELSE "That's not something you can scratch." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj <> hero - ELSE "That wouldn't help matters." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------- SEARCH - - --- ============================================================== - - - - -SYNTAX - search = search (obj) - WHERE obj ISA THING - ELSE "That's not something you can search." - - -ADD TO EVERY THING - VERB search - CHECK obj <> hero - ELSE LIST hero. - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "You can't see anything in the dark." - - DOES - "You find nothing of interest." - END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ SELL - - --- ============================================================== - - -SYNTAX - sell = sell (obj) - WHERE obj ISA THING - ELSE "That's not something you can sell." - - -ADD TO EVERY THING - VERB sell - CHECK obj IS examinable - ELSE "That's not something you can sell." - AND obj <> hero - ELSE "It doesn't make sense to sell yourself." - DOES - "There's nobody here who would be interested to buy" SAY THE obj. "." - END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ SHAKE - - --- ============================================================== - - - -SYNTAX shake = shake (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN SAY THE obj. "wouldn't probably appreciate that." - ELSE "That's not something you can shake." - END IF. - - - -ADD TO EVERY OBJECT -VERB shake - CHECK obj IN hero - ELSE "You're not holding" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You shake" SAY THE obj. "a bit. Nothing happens." -END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ SHOOT (AT) - - --- ============================================================== - - - -SYNTAX - shoot = shoot (obj) - WHERE obj ISA THING - ELSE "That's not something you can shoot at." - shoot = shoot 'at' (obj). - - -ADD TO EVERY THING - VERB shoot - CHECK obj <> hero - ELSE "There's no need to be that desperate." - DOES "You must state what you want shoot" SAY THE obj. "with." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ SHOOT WITH - - --- ============================================================== - - -SYNTAX - shoot_with = shoot (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can shoot." - AND obj2 ISA WEAPON - ELSE "That's not something you can shoot with." - -ADD TO EVERY THING - VERB shoot_with - WHEN obj1 - CHECK obj2 IN hero - ELSE "You are not carrying" SAY THE obj2. "." - AND obj1 IS examinable - ELSE "That's not something you can shoot." - AND obj1 <> hero - ELSE "There's no need to be that desperate." - AND obj1 <> obj2 - ELSE "It doesn't make sense to shoot something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ SHOUT - - --- ============================================================== - - - - -SYNTAX - shout = shout. - -VERB shout - DOES - "Nothing results from your $ving." -END VERB. - -SYNONYMS - yell, scream = shout. - - - - - --- ============================================================== - - ------ SHOW - - --- ============================================================== - - - -SYNTAX 'show' = 'show' (obj1) 'to' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can show." - AND obj2 ISA ACTOR - ELSE "That's not something you can show things to." - -ADD TO EVERY THING -VERB 'show' - WHEN obj1 - CHECK obj1 <> hero - ELSE "It doesn't make sense to show something to youself." - AND obj2 <> hero - ELSE "It doesn't make sense to show something to yourself." - AND obj1 <> obj2 - ELSE "It doesn't make sense to show something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES SAY THE obj2. "is not especially interested." -END VERB. -END ADD TO. - - - - - - --- ============================================================== - - ------ SING (+ hum, whistle) - - --- ============================================================== - - - - -SYNTAX - sing = sing. - -VERB sing - DOES - "You $v a little tune." -END VERB. - -SYNONYMS - hum, whistle = sing. - - - - - --- ============================================================== - - ------ SIP - - --- ============================================================== - - -SYNTAX -sip = sip (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can drink." - -ADD TO EVERY OBJECT -VERB sip - CHECK obj IS drinkable - ELSE "That's not something you can drink." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IN hero - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You take a sip of" SAY THE obj. ". It tastes rather good." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ SIT - - --- ============================================================== - - -SYNTAX sit = sit. - sit = sit 'down'. - - -VERB sit - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - DOES "You feel no urge to sit down at present." - -- (or, if you wish to make it work, use the following instead of the above: - -- "You sit down." - -- MAKE hero sitting. -END VERB. - - - - --- ============================================================== - - ------ SIT_ON - - --- ============================================================== - - -SYNTAX sit_on = sit 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can sit on." - -ADD TO EVERY SUPPORTER -VERB sit_on - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - DOES "You feel no urge to sit down at present." - -- (or, to make it work, use the following instead of the above:) - -- "You sit down on" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero sitting. -END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ SLEEP (+ rest) - - --- ============================================================== - - - -SYNTAX sleep = sleep. - - -VERB sleep - DOES "There's no need to $v right now." -END VERB. - - -SYNONYMS rest = sleep. - - - - - --- ============================================================== - - ------ SMELL (smell0) - - --- ============================================================== - - - -SYNTAX - smell0 = smell. - -VERB smell0 - DOES - "You smell nothing unusual." -END VERB. - - - --- ============================================================== - - ------ SMELL (+ obj) - - --- ============================================================== - - -SYNTAX - smell = smell (obj)! - WHERE obj ISA THING - ELSE "That's not something you can smell." - - -ADD TO EVERY THING - VERB smell - DOES - IF obj AT hero - THEN "You smell nothing unusual." - ELSIF obj NEAR hero - THEN "You smell nothing unusual." - ELSE "You can't smell" SAY THE obj. "from here." - END IF. - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ SQUEEZE - - --- ============================================================== - - -SYNTAX - squeeze = squeeze (obj) - WHERE obj ISA THING - Else "That's not something you can squeeze." - - -ADD TO EVERY THING - VERB squeeze - CHECK obj IS examinable - ELSE "That's not something you can squeeze." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE - IF obj = hero - THEN "Nothing would be achieved by that." - ELSE "It is too dark to see." - END IF. - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ STAND - - --- ============================================================== - - -SYNTAX stand = stand. - stand = stand 'up'. - - -VERB stand - CHECK hero IS NOT lying_down - ELSE "You get up." - MAKE hero NOT lying_down. - AND hero IS NOT sitting - ELSE "You stand up." - MAKE hero NOT sitting. - DOES "You're standing up already." -END VERB. - - - --- ============================================================== - - ------ STAND_ON - - --- ============================================================== - - -SYNTAX stand_on = stand 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can stand on." - - stand_on = take 'on' (obj). -- because 'get' is declared a synonym of 'take' - -- further below - -ADD TO EVERY SUPPORTER -VERB stand_on - DOES "You feel no urge to stand on" SAY THE obj. "." - -- or, to make it work, use the following instead of the above: - -- "You get on" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero NOT sitting. MAKE hero NOT lying_down. -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ SWIM - - --- ============================================================== - - - -SYNTAX swim = swim. - -VERB swim - CHECK hero IS NOT sitting - ELSE "It is difficult to try swimming while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to try swimming while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "There is no water suitable for swimming here." -END VERB. - - - - --- ============================================================== - - ------ SWIM IN - - --- ============================================================== - - - -SYNTAX swim_in = swim 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can swim in." - - -ADD TO EVERY OBJECT -VERB swim_in - CHECK hero IS NOT sitting - ELSE "It is difficult to swim anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to swim anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That's not something you can swim in." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ TAKE - - --- ============================================================== - - - - -SYNTAX - take = take (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN SAY THE obj. "would probably object to that." - ELSE "That's not something you can take." - END IF. - - -SYNTAX - pick_up1 = pick up (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can pick up." - - pick_up2 = pick (obj) up - WHERE obj ISA OBJECT - ELSE "That's not something you can pick up." - - -ADD TO EVERY OBJECT - VERB take, pick_up1, pick_up2 - CHECK obj IS movable - ELSE SAY THE obj. "is much too heavy for you to move." - AND obj IS takeable - ELSE "That's not something you can take." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - AND weight Of obj <=50 - ELSE SAY THE obj. "is too heavy to lift." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj IN hero - THEN - IF obj IN worn - THEN - IF obj ISA CLOTHING - THEN LOCATE obj IN hero. - "You take off" SAY THE obj. "and carry it in your hands." - ELSE LOCATE obj IN hero. - "Taken." - END IF. - ELSE "You already have" SAY THE obj. "." - END IF. - ELSE LOCATE obj IN hero. - "Taken." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - carry, get, grab, hold, obtain = take. - - - - - --- ============================================================== - - ------ TAKE FROM - - --- ============================================================== - - - -SYNTAX - take_from = 'take' (obj1) 'from' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only take objects." - AND obj2 ISA THING - ELSE "It's not possible to take things from there." - AND obj2 ISA CONTAINER - ELSE "It's not possible to take things from there." - - take_from = remove (obj1)* 'from' (obj2). - - -ADD TO EVERY OBJECT -VERB take_from - WHEN obj1 - CHECK obj2 <> hero - ELSE "You can't take things from yourself!" - AND obj2 ISA OBJECT - ELSE SAY THE obj2. "rather holds on to" - IF obj2 ISA FEMALE - THEN "her" - ELSIF obj2 ISA MALE - THEN "his" - ELSE "its" - END IF. - "belongings." - AND obj2 NOT IN hero - ELSE - LOCATE obj1 IN hero. - "You take" SAY THE obj1. "from" SAY THE obj2. "." - MAKE obj1 reachable. - AND obj1 NOT IN hero - ELSE "You already have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "You can't take something from itself!" - AND obj1 IN obj2 - ELSE - IF obj2 IS inanimate - THEN SAY THE obj1. "is not there." - ELSE SAY THE obj2. "doesn't have" SAY THE obj1. "." - END IF. - AND obj1 IS reachable - ELSE - IF obj2 ISA ACTOR - THEN "Maybe it would be polite to ask" SAY THE obj2. "first." - ELSE SAY THE obj1. "is out of your reach." - END IF. - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - AND obj1 IS takeable - ELSE "That's not something you can take." - AND obj1 IS movable - ELSE SAY THE obj1. "is much too heavy for you to take." - AND weight Of obj1 <=50 - ELSE SAY THE obj1. "is too heavy." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - LOCATE obj1 IN hero. - "You take" SAY THE obj1. "from" SAY THE obj2. "." - MAKE obj1 reachable. - -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TALK - - --- ============================================================== - - - -SYNTAX - talk_to = talk 'to' (act) about (topic)! - WHERE topic ISA THING - ELSE "That's not something you can ask about." - AND act ISA ACTOR - ELSE "That's not something you can talk to." - talk_to = tell (act) about (topic)!. - -ADD TO EVERY THING - VERB talk_to - WHEN topic - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - DOES - SAY THE act. "doesn't seem interested." - END VERB. -END ADD TO. - - -SYNTAX - talk_to_a = talk 'to' (act) - WHERE act ISA actor - ELSE "You can't talk to that." - -ADD TO EVERY THING - VERB talk_to_a - CHECK act HAS can_talk - ELSE "You can't talk to that." - DOES - SAY THE act. "looks at you, seemingly wondering if you have - anything specific to talk about." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ TEAR (+ rip) - - --- ============================================================== - - - -SYNTAX tear = tear (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can tear." - - -ADD TO EVERY OBJECT -VERB tear - CHECK obj IS examinable - ELSE "That's not something you can tear." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That's not a good idea." -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ THINK (+ ponder) - - --- ============================================================== - - - -SYNTAX think = think. - -VERB think - DOES "Nothing helpful comes to your mind." -END VERB. - - - -SYNONYMS ponder = think. - - - - --- ============================================================== - - ------ THINK ABOUT - - --- ============================================================== - - - -SYNTAX think_about = think 'about' (obj) - WHERE obj ISA THING - ELSE "That's not something fruitful to think about." - - -ADD TO EVERY THING -VERB think_about - DOES "Nothing helpful comes to your mind." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW (+ cast) - - --- ============================================================== - - - - -SYNTAX - throw = throw (obj) * - WHERE obj ISA OBJECT - ELSE "You can only throw objects." - - -ADD TO EVERY OBJECT - VERB throw - CHECK obj IN hero - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't throw very far;" SAY THE obj. "ends up on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj HERE. - END VERB. -END ADD TO. - - -SYNONYMS - cast = throw. - - - - - --- ============================================================== - - ------ THROW AT - - --- ============================================================== - - - -SYNTAX - throw_at = throw (obj1) 'at' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only throw objects." - AND obj2 ISA THING - ELSE "It's not possible to throw things at that." - - throw_to = throw (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only throw objects." - AND obj2 ISA THING - ELSE "It's not possible to throw things to that." - - -ADD TO EVERY OBJECT - VERB throw_at, throw_to - WHEN obj1 - CHECK obj1 IN hero - ELSE "You are not holding" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to throw something at itself." - AND obj2 NOT IN hero - ELSE - "You are carrying" SAY THE obj2. "." - AND obj2 <> hero - ELSE "You cannot throw things at yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj2 IS inanimate - THEN - SAY THE obj1. "bounces harmlessly off" - SAY THE obj2. "and ends up on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj1 HERE. - ELSE SAY THE obj2. "catches" SAY THE obj1. "and tosses" - IF THIS IS NOT plural - THEN "it" - ELSE "them" - END IF. - "back to you. You grab hold of it again." - END IF. - END VERB. -END ADD TO. - - - -SYNTAX - throw_in = throw (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can throw." - AND obj2 ISA OBJECT - ELSE "That's not something you can throw things into." - AND obj2 ISA CONTAINER - ELSE "That's not something you can throw things into." - - -ADD TO EVERY OBJECT - VERB throw_in - WHEN obj1 - CHECK obj1 NOT IN obj2 - ELSE SAY THE obj1. "is in" SAY THE obj2. "already!" - AND obj1 IN hero - ELSE "You are not holding" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to throw something into itself." - AND obj2 <> hero - ELSE "You can't throw" SAY THE obj1. "into yourself! If you wish to eat or drink - something, just say so." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - LOCATE obj1 IN obj2. - "Done." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ TIE - - --- ============================================================== - - - -SYNTAX tie = tie (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can tie." - - - -ADD TO EVERY OBJECT -VERB tie - DOES "You must state where do you want to tie" SAY obj. "." -END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ TIE TO - - --- ============================================================== - - -SYNTAX tie_to = tie (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can tie." - AND obj2 ISA OBJECT - ELSE "Nothing can be tied to that." - - -ADD TO EVERY OBJECT -VERB tie_to - WHEN obj1 - CHECK obj1 IN hero - ELSE "You don't have" SAY THE obj1. - AND obj1 <> obj2 - ELSE "It doesn't make sense to tie something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "It's not possible to tie" SAY THE obj1. "to" SAY THE obj2. "." -END VERB. -END ADD TO. - - - - - --- ============================================================== - - ------ TOUCH - - --- ============================================================== - - -SYNTAX - touch = touch (obj) - WHERE obj ISA THING - ELSE "That's not something you can touch." - - - -ADD TO EVERY THING - VERB touch - CHECK obj IS examinable - Else "That's not something you can touch." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS inanimate - ELSE "You are not sure whether" SAY THE obj. "would appreciate that." - DOES - "You feel nothing unexpected." - END VERB. -END ADD TO. - - - -SYNONYMS feel = touch. - - - --- ============================================================== - - ------ TOUCH WITH - - --- ============================================================== - - - -SYNTAX touch_with = touch (obj1) 'with' (obj2) - WHERE obj1 ISA THING - Else "That's not something you can touch." - AND obj2 ISA OBJECT - ELSE "You can only use objects to touch with." - -ADD TO EVERY THING -VERB touch_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can touch." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj1 <> obj2 - ELSE "It doesn't make sense to touch something with itself." - AND obj1 IS inanimate - ELSE "You are not sure whether" SAY THE obj1. "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You touch" SAY THE obj1. "with" SAY THE obj2. ". Nothing special happens." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN - - --- ============================================================== - - -SYNTAX turn = turn (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can turn." - -ADD TO EVERY OBJECT -VERB turn - CHECK obj IS examinable - ELSE "That's not something you can turn." - AND obj IS movable - ELSE "It's not possible to turn" SAY THE obj. "." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You turn" SAY THE obj. - IF obj IN hero - THEN "in your hands" - END IF. - "$$. You notice nothing unusual about it" - IF obj NOT IN hero - THEN "and return it to its original position" - END IF. - "." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN ON - - --- ============================================================== - ------ Only devices and lightsources can be turned on and off. These subclasses are defined in 'classes.i' ------ with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. Trying to turn on or off ------ an ordinary object will default here to "You can't turn that on". - - - - - -SYNTAX - turn_on1 = turn 'on' (obj) - WHERE obj ISA OBJECT - Else "That's not something you can turn on." - - turn_on2 = turn (obj) 'on' - WHERE obj ISA OBJECT - Else "That's not something you can turn on." - - switch_on1 = switch 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can switch on." - - switch_on2 = switch (obj) 'on' - WHERE obj ISA OBJECT - ELSE "That's not something you can switch on." - - -ADD TO EVERY OBJECT - VERB turn_on1, turn_on2, switch_on1, switch_on2 - CHECK obj IS examinable - ELSE "That's not something you can turn off." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "That's not something you can $v on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN OFF - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These subclasses are defined in 'classes.i' ------ with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. - - - -SYNTAX - turn_off1 = turn off (obj) - WHERE obj ISA OBJECT - ELSE "You can't turn that off." - - turn_off2 = turn (obj) off - WHERE obj ISA OBJECT - ELSE "You can't turn that off." - - switch_off1 = switch off (obj) - WHERE obj ISA OBJECT - ELSE "You can't switch that off." - - switch_off2 = switch (obj) off - WHERE obj ISA OBJECT - ELSE "You can't switch that off." - - -ADD TO EVERY OBJECT - VERB turn_off1, turn_off2, switch_off1, switch_off2 - CHECK obj IS examinable - ELSE "That's not something you can turn off." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "That's not something you can $v off." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ USE - - --- ============================================================== - - -SYNTAX - 'use' = 'use' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can use." - - -ADD TO EVERY OBJECT - VERB 'use' - DOES - "Please be more specific. How do you intend to use it?" - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE WITH - - --- ============================================================== - - - -SYNTAX use_with = 'use' (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - Else "You can only use objects." - AND obj2 ISA OBJECT - Else "You can only use objects." - -ADD TO EVERY OBJECT -VERB use_with - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "You can't use something with itself." - DOES "Please be more specific. How do you intend to use them together?" -END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ UNDRESS - - --- ============================================================== - - - - --- See the file 'classes.i', subclass 'clothing' for the definition --- of this verb. - - - - --- ============================================================== - - ------ UNLOCK - - --- ============================================================== - - - - -SYNTAX - unlock = unlock (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can unlock." - - -ADD TO EVERY OBJECT - VERB unlock - CHECK obj IS lockable - ELSE "That's not something you can unlock." - AND obj IS locked - ELSE "It's already unlocked." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You must state what you want to unlock" SAY THE obj. "with." - END VERB. -END ADD TO. - - - - --- ============================================================= - - ------ UNLOCK WITH - - --- ============================================================= - - - -SYNTAX - unlock_with = unlock (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can unlock." - And obj2 ISA OBJECT - ELSE "You can't unlock anything with that." - - - -ADD TO EVERY OBJECT - VERB unlock_with - WHEN obj1 - CHECK obj1 IS lockable - ELSE "That's not something you can unlock." - AND obj1 IS locked - ELSE "It's already unlocked." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 In hero - ELSE - "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to unlock something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - SAY THE obj2. "doesn't unlock" SAY THE obj1. - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ VERBOSE (see also -> BRIEF) - - --- ============================================================== - - - -SYNTAX - verbose = verbose. - -VERB verbose - DOES - VISITS 0. - "Verbose mode is now on. Location descriptions will be always shown in full." -END VERB verbose. - - - - - --- ============================================================== - - ------ WAIT (= z) - - --- ============================================================== - - - -SYNTAX - 'wait' = 'wait'. - -VERB 'wait' - DOES - "Time passes..." -END VERB. - -SYNONYMS - z = 'wait'. - - - - - --- ============================================================== - - ------ WEAR - - --- ============================================================== - - - - - --- See the file 'classes.i', subclass 'clothing' for definitions of the verbs --- 'wear', (put on), 'remove', (take off) and 'undress'. - - - - - - - --- ============================================================== - - ------ WHAT AM I - - --- ============================================================== - - - - -SYNTAX what_am_i = 'what' am i. - - -VERB what_am_i - DOES "Maybe examining yourself might help." -END VERB. - - - - --- ============================================================== - - ------ WHAT IS - - --- ============================================================== - - - -SYNTAX - what_is = 'what' 'is' (obj)! - WHERE obj ISA THING - ELSE "That's not something I know about." - - -ADD TO EVERY THING -VERB what_is - DOES "You'll have to find it out yourself." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHERE AM I - - --- ============================================================== - - -SYNTAX where_am_i = 'where' am i. - -VERB where_am_i - DOES LOOK. -END VERB. - - - --- ============================================================== - - ------ WHERE IS - - --- ============================================================== - - - -SYNTAX - where_is = 'where' 'is' (obj)! - WHERE obj ISA THING - ELSE "That's not something I know about." - - -ADD TO EVERY THING -VERB where_is - CHECK obj NOT AT hero - ELSE "That's right here!" - DOES "You'll have to find it out yourself." -END VERB. -END ADD TO. - - --- ============================================================== - - ------ WHO AM I - - --- ============================================================== - - -SYNTAX who_am_i = who am i. - -VERB who_am_i - DOES "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHO IS - - --- ============================================================== - - - -SYNTAX - who_is = 'who' 'is' (act)! - WHERE act ISA ACTOR - ELSE "That's not somebody I know." - - -ADD TO EVERY ACTOR -VERB who_is - DOES "You'll have to find it out yourself." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WRITE - - --- ============================================================== - - - -SYNTAX write = write (str) 'on' (obj) - WHERE str ISA STRING - ELSE "Please state inside double quotes ("""") what you want to write." - AND obj ISA OBJECT - ELSE "Nothing can be written there." - write = write (str) 'in' (obj). - - - - -ADD TO EVERY OBJECT -VERB write - WHEN obj - CHECK obj IS writeable - ELSE "Nothing can be written there." - AND obj IS reachable - ELSE "You can't reach" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF text OF obj = "" - THEN SET text OF obj TO str. - ELSE SET text OF obj TO text OF obj + " " + str. - END IF. - "You write ""$$" SAY str. "$$"" on" SAY THE obj. "." - MAKE obj readable. -END VERB. -END ADD TO. - - - - --- ================================================================ - - ------ YES - - --- ================================================================ - - - - -SYNTAX yes = yes. - -VERB yes - DOES "You sound rather positive." -END VERB. - - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/anssilib2010-08-05.alan b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/anssilib2010-08-05.alan deleted file mode 100755 index dddae16..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/anssilib2010-08-05.alan +++ /dev/null @@ -1,275 +0,0 @@ --- TESTGAME - - -IMPORT 'locations.i'. -IMPORT 'classes.i'. -IMPORT 'verbs.i'. -IMPORT 'messages.i'. - - - -THE testroom ISA ROOM - DESCRIPTION "This is a testroom for the beta version of a new ALAN library. - A white door leads north. A window decorates the western wall." - - EXIT north TO room2 - CHECK - IF door1 IS closed - THEN "You can't, since the door is closed." - ELSE "You walk north." - LOCATE hero AT room2. - LOCATE door1 AT room2. - END IF. - END EXIT. - - -END THE. - - -THE box ISA LISTABLE_CONTAINER - AT testroom - VERB attack DOES MAKE felix following. - MAKE dog following. - END VERB. -END THE. - - -THE table ISA SUPPORTER - AT testroom - IS NOT takeable. - VERB examine - DOES AFTER LIST table_parts. - END VERB. -END THE. - - -THE table_parts ISA OBJECT - AT testroom - CONTAINER - HEADER "In the table there are" - ELSE "" - DESCRIPTION "" -END THE. - - -THE drawer1 ISA LISTABLE_CONTAINER - IN table_parts - OPAQUE CONTAINER - NAME top drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - -THE drawer2 ISA LISTABLE_CONTAINER - IN table_parts - OPAQUE CONTAINER - NAME bottom drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - -THE secret_object ISA OBJECT - NAME secret 'object' - IN drawer1 -END THE. - - -THE door1 ISA DOOR - AT testroom - NAME white 'door' - DESCRIPTION "" -END THE. - - -THE window1 ISA WINDOW - AT testroom - NAME 'window' - DESCRIPTION "" -END THE. - - -THE flower ISA SCENERY - AT testroom -END THE. - - -THE note ISA OBJECT - IN table - IS writeable. - IS readable. - - - VERB burn - CHECK match IS lit - ELSE "How?" - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - VERB burn_with - WHEN obj1 - CHECK obj2 = match - ELSE "That's not possible." - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - -END THE. - - -THE bottle ISA LISTABLE_CONTAINER - In box -END THE. - - -THE juice ISA LIQUID - IN bottle - IS drinkable. - ARTICLE "some" -END THE. - - -THE match ISA LIGHTSOURCE - IN table - IS natural. -END THE. - - -THE flashlight ISA LIGHTSOURCE - IN box - IS NOT natural. -END THE. - - -THE waterpistol ISA WEAPON - IN table - IS fireable. -END THE. - - -THE room2 ISA SITE - NAME '' - DESCRIPTION "This is an outdoor location. The sky is clear. In the distance you see a mountain. - The" - IF door1 IS closed - THEN "closed" - ELSE "open" - END IF. - "door back to the testroom lies to the south. There is a black hole to the north. It looks like you might just try entering it." - IF THIS IS NOT visited - THEN "This room has not been visited before." - ELSE "This room has been visited before." - END IF. - - EXIT south TO testroom - CHECK - IF door1 IS closed - THEN "You can't, since the door is closed." - ELSE "You go back to the testroom." - LOCATE hero AT testroom. - LOCATE door1 AT testroom. - FOR EACH backdrop AT room2 DO - LOCATE backdrop AT nowhere. - END EACH. - END IF. - END EXIT. - - - EXIT north TO room3 - DOES "You enter the black hole." - END EXIT. - -END THE. - - - -THE mountain ISA OBJECT - IS NOT takeable. - IS NOT reachable. - AT room2 - DESCRIPTION -END THE. - - -THE hole ISA OBJECT - AT room2 - CONTAINER -- so that it can be entered - DESCRIPTION - - VERB enter - DOES ONLY LOCATE hero AT room3. - END VERB. - -END THE. - - -THE blue_ball ISA OBJECT - AT room2 - NAME blue ball -END THE. - - -THE room3 ISA DARK_LOCATION - NAME 'The Third Location' - EXIT south TO room2. - DESCRIPTION "This the lighted third location." -END THE. - - -THE shirt ISA CLOTHING - AT room3 - IS topcover 8. -END THE. - - -THE jacket ISA CLOTHING - AT room3 - IS topcover 32. -END THE. - - -THE wallet ISA OBJECT - IN jacket -END THE. - - -THE red_ball ISA OBJECT - AT room3 - NAME red ball - VERB attack - DOES ONLY DESCRIBE ending. - END VERB. -END THE. - - -THE felix ISA NAMED_ACTOR - AT testroom - NAME felix NAME himself - HAS can_talk. - MENTIONED "Felix" - PRONOUN 'him' - - - VERB examine - DOES ONLY "Felix is a boy." - END VERB. - -END THE. - - -THE dog ISA ACTOR - AT testroom -END THE. - -THE ending ISA OBJECT - DESCRIPTION "$p$p$t$t$t$t* * *$t The end$t * * *$p" - QUIT. -END THE. - - -START AT testroom. - - \ No newline at end of file diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/anssilib2010-08-05.input b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/anssilib2010-08-05.input deleted file mode 100755 index 4cc18c9..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/anssilib2010-08-05.input +++ /dev/null @@ -1,11 +0,0 @@ -take flashlight -turn it on -n -open door -n -n -take shirt -take jacket -put on shirt -put jacket on -take off shirt diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/classes.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/classes.i deleted file mode 100755 index 25c0355..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/classes.i +++ /dev/null @@ -1,1684 +0,0 @@ --- ALAN NEW LIBRARY: CLASSES (file name: 'classes.i') - - --- This library file defines various object and actor classes, as well as the --- instance 'hero'(=the player character). Many of these subclasses are frequently --- used in verb definitions in 'verbs.i' so they should be edited or --- removed with caution. - - --- 1. OBJECT CLASSES --- ================= - - --- BACKGROUND - -- Is present in the location but cannot be reached or taken. - -- Doesn't appear automatically in room descriptions. - -- A typical example of a background would be for example the sun, - -- or a mountain visible in the distance. - -- Compare this with 'scenery' below (a background object cannot be reached, - -- but a scenery object can.) - - --- CLOTHING - -- Is a piece of clothing that behaves according to Alan Bampton's 'xwear.i' extension. - -- The said extension has been fully assimilated to this library. - -- This extension prevents clothes from being worn in an illogical order, e.g. you - -- cannot put on a shirt if you are already wearing a jacket, and so forth. - -- Also the verbs 'wear', 'remove' and 'undress' are defined here. - - --- DEVICE - -- Is a machine or an electronic device, for example a TV. Can be turned - -- (=switched) on and off if it is not broken. - -- Attributes: 'on' and NOT 'on', NOT broken. - -- Is described automatically as being either on or off when examined. - - --- DOOR - -- Can be opened, closed, locked and unlocked. - -- Is by default closed, not locked. - -- Attributes: closeable, (NOT) closed, lockable, (NOT) locked. - -- Is described automatically as being either open or closed when examined. - - --- LIQUID - -- Can only be taken if it is in a container. You can fill something with it, - -- and you can pour it somewhere. - -- A liquid is by default NOT drinkable. - - --- LIGHTSOURCE - -- IS natural or NOT natural - -- (a natural lightsource is for example a match or a torch). - -- Can be turned on and off, lighted and extinguished (= put out) if it - -- is not broken. A natural lightsource - -- cannot be turned on or off, it can only be lighted and extinguished (= put out). - -- When examined, a lightsource is automatically supplied with a description of - -- whether it is providing light or not. - - --- LISTABLE_CONTAINER - -- Is a special kind of container, the contents of which will be listed both after - -- 'look' (= in the room description), 'look in' and 'examine' (if the container is open) - -- (the contents of a normal container object are not listed after 'examine' but only - -- after 'look' (=room description) and 'look in'). - - --- SCENERY - -- Behaves like a normal object, can be reached and manipulated but not taken. - -- The default message for 'take' will be "You deem the [object] as not important for - -- your purposes and leave it where it is." - -- The default message for 'examine' will be "The [object] doesn't appear particularly - -- interesting." - -- A scenery object is not automatically listed after the room description when - -- you type 'look'. You have to include it manually in the room description. - -- Compare this with 'background' above (a scenery object can be reached, - -- but a background object cannot.) - - --- SOUND - -- Can be listened to but not examined, searched, smelled or manipulated. - -- Cannot initially be turned on or off, this has to be implemented manually by giving - -- the sound the 'switchable' attribute. - - --- SUPPORTER - -- You can put things on this and you can stand on this. It is declared a container, - -- so you can take things from it, as well. When there's something on a supporter, - -- an automatic listing of it will appear in the room description and after 'examine'. - - --- WEAPON - -- IS fireable (e.g. a cannon) or NOT fireable (e.g. a baseball bat). - - --- WINDOW - -- Can be opened, closed, looked through and out of. - -- Will be automatically described as being either open or closed when examined. - - - --- 2. ACTOR CLASSES --- ================ - --- the ACTORS are defined here to be NOT inanimate CONTAINERS (so that they can e.g. --- receive and carry things. The 'contents' (= possessions) of an actor (except for the hero) --- are automatically listed after 'look' and 'examine'. (For the hero, the command 'inventory' --- must be used.) --- --- Actors are, like objects, usually preceded by an article in-game: --- e.g. "You see a man here." --- "There is nothing special about the dog." --- --- The following subclasses for actors are defined in this library: - - --- NAMED_ACTOR - -- has no article in front of the name when mentioned - -- e.g. "You see Spot here." - -- is not able to talk; this subclass is useful e.g. when defining animals - --- PERSON - -- has an article in front when mentioned (e.g. "a boy") - -- is able to talk - - --- NAMED_PERSON - -- has no article in front of the name when mentioned (e.g. "Jim") - -- is able to talk - - --- + instructions for expressing male and female actors with 'PRONOUN him' or 'PRONOUN her'. - - - --- 3. INSTANCES --- ============ - - --- the hero - - - - --- The contents end here. - - - --- ============================================================= - --- ============================================================= --- --- 1. Object classes --- --- ============================================================= - --- ============================================================= - - - --- ============================================================= - - ------ BACKGROUND - - --- ============================================================= - - -EVERY background ISA THING - IS NOT reachable. - DESCRIPTION "" -END EVERY. - - - --- ============================================================== - - ------ CLOTHING (+ the verbs WEAR, REMOVE, UNDRESS) - - --- ============================================================== - - --- To use this subclass, see the documentation text right after the --- code below. --- This subclass makes use of Alan Bampton's 'xwear.i' extension --- written originally for ALAN V2, converted here to V3 and --- assimilated fully to the present library. - - ------------------------------------------------------------------ --- First, we declare the container for clothing. ------------------------------------------------------------------ - - -THE worn ISA ENTITY -- an entity is present everywhere and thus the hero's - CONTAINER TAKING CLOTHING. -- clothing is always accessible - HEADER "You are wearing" - ELSE "You're not wearing anything." -END THE. - - -------------------------------------------------------------------- --- Next, we define the syntaxes for verbs needed for putting on --- and taking off clothing. -------------------------------------------------------------------- - - -SYNTAX wear = wear (obj) - WHERE obj ISA CLOTHING - ELSE "That's not something you can wear." - wear = put 'on' (obj). - wear = put (obj) 'on'. - wear = don (obj). - -SYNTAX remove = remove (obj) - WHERE obj ISA CLOTHING - ELSE "That's not something you can remove since you're not wearing it." - remove = take 'off' (obj). - remove = take (obj) 'off'. - remove = doff (obj). - -SYNTAX undress = undress. - - -------------------------------------------------------------------- --- Now, we define some common attributes for clothing as well as --- how the above verbs behave with this subclass. -------------------------------------------------------------------- - - -EVERY clothing ISA OBJECT - - IS wearable. - IS sex 0. - IS headcover 0. - IS handscover 0. - IS feetcover 0. - IS topcover 0. - IS botcover 0. - - CONTAINER - - - VERB wear - - CHECK THIS NOT IN worn - ELSE "You are already wearing" SAY THE THIS. "." - AND THIS IS takeable - ELSE "You can't pick" SAY THE THIS. "up." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND sex OF THIS = sex OF hero OR sex OF THIS = 0 - ELSE - "On second thoughts you decide" - SAY THE THIS. "really won't suit a" - IF sex OF hero =1 - THEN "man" - ELSE "woman" - END IF. - "like you at all." - - - DOES ONLY - - --------------------------------------------------------------------- --- 'wear_flag' is a multi-purpose flag used for several purposes in --- this library, here it is reset to 0 before proceeding as a matter --- of 'housekeeping' for the code. --------------------------------------------------------------------- - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- First check to see if the player is carrying the item already, if --- not, set the 'wear_flag' to 1 to indicate the item was picked up --- in this turn. --------------------------------------------------------------------- - - - IF THIS NOT IN hero - THEN - SET wear_flag OF hero TO 1. - END IF. - - --------------------------------------------------------------------- --- Now see if the player can put this item on by testing --- all of its coverage attributes against the player's state. --------------------------------------------------------------------- - - --------------------------------------------------------------------- --- First check the 'topcover' attributes, if 'obj' fails this test --- then it means the hero is already wearing clothes that cover the --- topcover area and those clothes are of the same layer or a layer --- that belongs on top of the 'obj' item. In either case it would --- NOT be possible to put on the 'obj'. To 'flag' this condition add --- 5 to the 'wear_flag' attribute as an indicator this test failed. --------------------------------------------------------------------- - - - IF topcover OF THIS <> 0 AND topcover OF THIS <= SUM OF topcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - --- IF THIS IN tempworn THEN - IF handscover OF THIS <> 0 AND handscover OF THIS <= SUM OF handscover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF feetcover OF THIS <> 0 AND feetcover OF THIS <= SUM OF feetcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF headcover OF THIS <> 0 AND headcover OF THIS <= SUM OF headcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case, adjust the 'tempcovered OF hero' --- attribute so that the code rejects non sensible options. --- First of all, discount any coatlike clothes as these never --- affect ability to put on other lower body only garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 and botcover OF THIS < 33 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not technically affect ability to put on lower body only clothes. --- Special clause here excludes the full body coverage 'teddy' type --- garment - as a skirt WOULD prevent that from being removed. --- ( dress/coat garments automatically prevent this by virtue of --- having higher 'topcover' settings than the teddy ) --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 AND botcover OF THIS < 16 and botcover OF THIS <> 4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- IF tempcovered OF hero is still > 15 then must have trousers --- type clothing on - therefore disallow wearing dress type clothing --- because, although technically possible, it is not very sensible. --------------------------------------------------------------------- - - - IF tempcovered OF hero >15 AND botcover OF THIS > 16 - THEN - SET tempcovered OF hero TO tempcovered OF hero +16. - END IF. - - --------------------------------------------------------------------- --- From here down, clothes DO work as they do for other areas. --------------------------------------------------------------------- - - - IF botcover OF THIS <> 0 AND botcover OF THIS <= tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- At this point, 'wear_flag' will be 0 if the obj was held by the --- player and can be put on, or l if he picked it up this turn and --- it can be put on. Any higher value means one or more of the --- tests failed and the player cannot put on these clothes. --------------------------------------------------------------------- - - - IF wear_flag OF hero >1 THEN - IF THIS NOT IN hero - THEN - "You pick up the" SAY THE THIS. "." - END IF. - LOCATE THIS IN hero. - EMPTY worn IN tempworn. - LIST tempworn. - "Trying to put" - SAY THE THIS. - "on isn't very sensible." - EMPTY tempworn IN worn. - ELSIF wear_flag OF hero = 1 - THEN - LOCATE THIS IN worn. - "You pick up the" SAY THE THIS. - IF THIS IS plural - THEN - "and put them on." - ELSE - "and put it on." - END IF. - ELSE - LOCATE THIS IN worn. - "You put on" SAY THE THIS. "." - END IF. - -END VERB. - - - -VERB remove - CHECK THIS IN worn - ELSE - "You are not wearing" SAY THE THIS. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - - DOES ONLY - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- Check the total 'topcover' of items worn. Because of the number --- sequence used, by dividing the sum of the worn attributes by two --- and then comparing the result to the individual 'topcover' of the --- obj in question, ( the former can only ever be greater than the --- latter if an article of clothing is worn that goes over 'obj' ) --- it's easy to tell if the obj ought to be removable. A temporary --- attribute is used here because it needs to be manipulated. Once --- again 'wear_flag' is used to indicate the results. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF topcover IN worn /2. - IF topcover OF THIS <> 0 AND topcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF handscover IN worn /2. - IF handscover OF THIS <> 0 AND handscover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF feetcover IN worn /2. - IF feetcover OF THIS <> 0 AND feetcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF headcover IN worn /2. - IF headcover OF THIS <> 0 AND headcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case - first discount any coatlike clothes --- as these do not affect ability to take off other lower garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not affect ability to take off other lower garments. The 'teddy' --- type garment is expressly NOT included in the exclusion here. --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 and botcover OF THIS <>4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- Now process the manipulated value just as was done for the others --------------------------------------------------------------------- - - - SET tempcovered OF hero TO tempcovered OF hero /2. - IF botcover OF THIS <> 0 AND botcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Depending on the value of 'wear_flag' print and process the obj --- as needed. If 'wear_flag' is NOT 0 then the clothes cannot be --- removed. --------------------------------------------------------------------- - - - IF wear_flag OF hero >0 THEN - LIST worn. - "Trying to take" SAY THE THIS. "off isn't very sensible." - ELSE - LOCATE obj IN hero. - "You take off" SAY THE THIS. "." - END IF. -END VERB. - - -VERB examine - DOES AFTER - IF THIS IS NOT OPAQUE - THEN - IF COUNT ISA OBJECT, IN THIS > 0 -- if the piece of clothing contains - THEN LIST THIS. -- something, e.g. if a jacket contains a wallet, - END IF. -- the wallet will be mentioned when the - END IF. -- jacket is examined -END VERB. - - -END EVERY. - - --------------------------------------------------------------------- --- The verb 'undress' needs to be defined outside the object class --- as it is intransitive: --------------------------------------------------------------------- - - -VERB undress - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF COUNT IN worn, ISA CLOTHING > 0 - THEN "You don't feel like undressing is a good idea right now." - ELSE "You're not wearing anything you can remove." - END IF. - - -- or, to make it work, use the following lines instead: - --IF COUNT IN worn, ISA CLOTHING > 0 - --THEN EMPTY worn IN hero. - --"You remove all the items you were wearing." - --ELSE "You're not wearing anything you can remove." - -- END IF. -END VERB. - - - --------------------------------------------------------------------- --- These attributes are used internally in the library - ignore! --------------------------------------------------------------------- - -ADD TO EVERY ACTOR - IS tempcovered 0. - IS wear_flag 0. - IS sex 0. -END ADD TO. - - --------------------------------------------------------------------- --- A container used to provide a temporary storage space - ignore! --------------------------------------------------------------------- - -THE tempworn ISA OBJECT - CONTAINER TAKING CLOTHING. - HEADER "You're already wearing" -END THE tempworn. - - - ------------------------------------------------------------------------ --- DOCUMENTATION FOR CLOTHING ------------------------------------------------------------------------ - - --- The quick guide ------------------- - --- Here is a quick overview for using the subclass 'clothing'. A more closely-detailed --- description of this subclass is found below this overview. - - --- A piece of clothing in your game should look something similar to these four examples: - - --- THE jacket ISA CLOTHING AT lobby --- IS topcover 32. --- END THE. - - --- THE jeans ISA CLOTHING IN wardrobe --- IS botcover 16. --- END THE. - - --- THE hat ISA CLOTHING IN worn -- IN worn = worn by the player character --- IS headcover 2. --- END THE. - - --- THE sweater ISA CLOTHING IN joe_worn -- = worn by an NPC called Joe. --- IS topcover 16. -- Define separate containers like this --- END THE. -- for clothes worn by non-player characters. - -- If you defined here 'IN joe', the clothing - -- would be listed in Joe's possessions: - -- "You see Joe here. Joe is carrying a book and - -- a sweater." - - --- In defining a piece of clothing, you should --- 1) define it ISA CLOTHING (and not: ISA OBJECT) --- 2) give it one of five attributes 'headcover', 'topcover', botcover', 'footcover' --- or 'handcover'; sometimes two of these are needed. --- Which attribute(s) to use depends on the type of clothing; see the clothing table below. --- 3) A number 2, 4, 8, 16, 32 or 64 needs to be added after the above attribute. --- You cannot decide the number yourself; look it up from the clothing table below. --- If the value of an attribute for a piece of clothing is 0 in the table, don't mention --- this attribute in connection with your clothing object. - - --- The above is enough; the rest is then handled automatically by the library. - - --- The quick guide ends here. The clothing table follows right after. The text following the --- table gives more details about the principles and the use of this subclass. - - --- The clothing table ------------------------ - - --- Here is the chart showing a selection of fairly typical clothing items and the values to --- set to obtain appropriate behaviour. Should you wish to create an article of clothing not --- listed, usually a bit of lateral thought as to what it is most like and where it fits into --- the scheme of things will suggest a workable set of values, but be aware that you MUST use --- values in this chart, simply adding things with intermediate values is probably going to --- create nasty bugs: - - --- Clothing Headcover Topcover Botcover Footcover Handcover - --- hat 2 0 0 0 0 --- vest/bra 0 2 0 0 0 --- undies/panties 0 0 2 0 0 --- teddy 0 4 4 0 0 --- blouse/shirt/T-shirt 0 8 0 0 0 --- dress/coveralls 0 8 32 0 0 --- skirt 0 0 32 0 0 --- trousers/shorts 0 0 16 0 0 --- sweater/pullover 0 16 0 0 0 --- jacket 0 32 0 0 0 --- coat 0 64 64 0 0 --- socks/stockings 0 0 0 2 0 --- tights/pantiehose 0 0 8 2 0 --- shoes/boots 0 0 0 4 0 --- gloves 0 0 0 0 2 - - - --- The concept of "xwear.i" (This and the following paragraphs are taken from Alan ---------------------------- Bampton's 'xwear' documentation) - - --- The basic idea behind this part of the library is that clothing is worn in --- 'layers' and it is rather silly to allow players to (say) take off or put --- on a shirt if they are wearing a jacket. To simulate this in ALAN I've chosen --- to apply a numeric based layering system, and divide the body into five zones --- of coverage. The zones are 'head', 'hands', 'feet', 'top' (for top half of torso) --- and 'bot' (for bottom half of torso). --- All objects have these five zones defined as default attributes (set to 0), for the --- head zone the attribute is headcover for the hands zone handscover and so on. --- Every clothing object will thus need one or more of its 'zonecover' attributes --- set to reflect the zone(s) it covers and its relative position in the layers of --- clothing worn. A simple example would be a shirt, this covers only the 'top' zone --- and so needs its topcover attribute to be set (to 8, just why it's 8 will become --- clear shortly). --- The principle used is that the closer to the skin an item is normally worn, --- the lower its 'cover' attribute is. The library operates on the assumption that --- items with higher value cover attributes for a particular zone are worn over items --- with lower value attributes. When a player attempts to put on an article of clothing, --- each zone it would affect is checked and compared to the related zonal total of any --- clothes already worn. If the value of the new clothing is not greater that the total(s) --- of clothing already worn (on a zone by zone basis) then the library will not allow --- the wearing of that item. There are a few notable exceptions to this rule, but --- I'll come back to those a little later. - - --- How it works in practice ---------------------------- - - --- This part of the library might sound complex, but it is actually very simple to use, --- here's an example of how it works. --- Assume our hero starts the game wearing just vest and shorts and the player issues --- the command 'put on shirt'. A quick check of the chart below should reveal that a shirt --- has only its topcover attribute set to non-zero, (all the other zones are zero, --- which means they are irrelevant for this item). --- The library totals the topcover attributes of all the clothes currently worn, like so:- --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- As there are no other clothes to consider, the library now compares the topcover attribute --- of the item we are attempting to put on, (a shirt with a topcover attribute of 8 in --- this case) to the total value of items already worn (2). --- Because the topcover attribute of the shirt (8) is greater than the calculated total (2), --- this is evaluated as being a 'legal' instruction and the library allows the shirt to be put on. --- Now consider the situation had the player started the game wearing vest, shorts and a jacket, --- this is what happens should he try to 'put on the shirt.' --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- Finally the library checks the jacket, this has a topcover attribute of 32, so total --- topcover is 2 + 32 = 34. --- Because the topcover attribute of the shirt (8) is now not greater than the calculated --- total (34), this is evaluated as being an 'illegal' instruction and the library won't --- allow the shirt to be put on. --- That demonstrates the basic principle of the library, removing clothes uses a variation --- of the 'compare to total' equation to allow / disallow removal of clothing, an example would --- be that our vest, shorts and jacket wearing player would NOT be allowed to remove --- the vest while he still had the jacket on. - - --- Exceptions to the rule... ----------------------------- - - --- Now I'll confuse the issue. Firstly the numbers in my chart are not born of some sort of --- weird fixation with multiples, there is a very good reason why the numbers are set as they --- are, computer/maths types will recognise the sequence and realise it is all 'binary' based --- and know it makes it possible to calculate exactly what the player is wearing in terms of --- layers. --- Some female clothing breaks the rules defined above and is not so easy to deal with. An example, --- although pantyhose is worn under a skirt, dress or coat it can actually be put on or removed --- with the garment worn over it still on. The library recognises this capability and deals with --- it properly by assigning the dress/skirt and coat items particular properties in that they --- don't affect the ability to wear or remove lower layer clothing that covers the bottom of --- the torso only. --- Although it's physically possible to put on/remove trousers while wearing a skirt or dress, --- this (and a few other neat dressing/undressing tricks) is considered illegal here. - - --- How to create clothes that use 'xwear.i' -------------------------------------------- - - --- That covers the way the library works, here's how to define objects to actually make --- use of it. As an example, this is how to define a dress and restrict it to being worn --- by a female. - - --- THE dress ISA CLOTHING IN changingroom - -- NAME little black dress - -- MENTIONED "little black dress" - -- IS - -- botcover 32. - -- topcover 8. - -- sex 2. --- END THE. - - --- Notice that it is only necessary to mention the attributes that are non-zero, this --- minimises the amount of coding required. Apart from making sure the hero is set as --- 'sex 2.' if we wish her to be able to wear this dress, this is all the author needs --- to do, the library will police what is wearable and keep track of things without any --- further work. --- I expect most authors would prefer to start their games with a player at least partially --- dressed. This is just a matter of defining the required clothes object as being in the --- 'worn' container. Here's how to define underwear that our female hero(ine?) starts --- the game wearing. - - --- THE bra ISA CLOTHING IN worn - -- NAME white bra - -- MENTIONED "white bra" - -- IS - -- topcover 2. - -- sex 2. --- END THE bra. - - --- THE panties ISA CLOTHING IN worn - -- NAME white panties - -- MENTIONED "white panties" - -- IS - -- botcover 2. - -- plural. - -- sex 2. --- END THE panties. - - --- The library as it stands also prevents wearing of duplicate clothes, or things that are --- logically mutually exclusive - e.g. the player can wear a dress or a skirt, but not both. - - - --- ============================================================= - - ------ DEVICE - - --- ============================================================= - - -EVERY device ISA OBJECT - IS switchable. - IS NOT 'on'. - - - VERB examine - DOES - IF THIS IS 'on' - THEN "It is currently on." - ELSE "It is currently off." - END IF. - END VERB. - - - VERB turn_on1, turn_on2 - CHECK THIS IS NOT broken - ELSE "Nothing happens." - AND THIS IS NOT 'on' - ELSE SAY THE THIS. "is already on." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS 'on'. - END VERB. - - - VERB turn_off1, turn_off2 - CHECK THIS IS 'on' - ELSE SAY THE THIS. "is already off." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - END VERB. - - --- We define the 'switch' verb here (a mere 'switch' with no 'on' or 'off' --- following). This verb switches a device off if the device is on, and vice versa. - - - VERB switch - CHECK THIS IS NOT broken - ELSE "Nothing happens." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES ONLY - IF THIS IS 'on' - THEN "You switch" SAY THE THIS. "off." - MAKE THIS NOT 'on'. - ELSE "You switch" SAY THE THIS. "on." - MAKE THIS 'on'. - END IF. - END VERB. - -END EVERY. - - - - - -SYNTAX switch = switch (obj) - WHERE obj ISA DEVICE - ELSE "That's not something you can switch." - - - - --- ============================================================= - - ------ DOOR - - --- ============================================================= - - -EVERY door ISA OBJECT - IS closeable. - IS closed. - IS lockable. - IS NOT locked. - IS NOT takeable. - - VERB examine - DOES - IF THIS IS closed - THEN "It is currently closed." - ELSE "It is currently open." - END IF. - END VERB. - - - VERB knock - DOES ONLY - IF THIS IS closed - THEN "You knock on" SAY THE THIS. "$$. There is no reply." - ELSE "You don't find it purposeful to knock on the open door." - END IF. - END VERB. - - - VERB look_behind - DOES ONLY - IF THIS IS closed - THEN "You cannot look behind the door - it is closed." - ELSE "You notice nothing special behind the door." - END IF. - END VERB. - - - VERB look_under - DOES ONLY - IF THIS IS closed - THEN "The gap under the closed door is so narrow that you can't - see anything of what lies on the other side." - ELSE "You notice nothing special under the door." - END IF. - END VERB. - - -END EVERY. - - - --- ============================================================= - - ------ LIGHTSOURCE - - --- ============================================================= - - -EVERY lightsource ISA OBJECT - IS NOT lit. - IS natural. -- A natural lightsource is for example a candle, a match or a torch. - -- A NOT natural lightsource is for example a flashlight or a lamp. - -- You cannot switch on or off a natural lightsource. - - VERB examine - DOES - IF THIS IS lit - THEN - IF THIS IS natural - THEN "It is currently lit." - ELSE "It is currently on." - END IF. - ELSE - IF THIS IS natural - THEN "It is currently not lit." - ELSE "It is currently off." - - END IF. - END IF. - END VERB. - - - VERB light - CHECK THIS IS NOT lit - ELSE SAY THE obj. "is already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS natural - THEN "You light" SAY THE THIS. "." - MAKE THIS lit. - - ELSE "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END IF. - END VERB. - - - VERB extinguish - CHECK THIS IS lit - ELSE "But" SAY THE THIS. "is not providing light." - DOES ONLY "You extinguish the" SAY THE THIS. "." - MAKE THIS NOT lit. - END VERB. - - - VERB turn_on1, turn_on2 - CHECK THIS IS NOT natural - ELSE "That's not something you can turn on." - AND THIS IS NOT lit - ELSE SAY THE THIS. "is already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END VERB. - - - VERB turn_off1, turn_off2 - CHECK THIS IS NOT natural - ELSE "That's not something you can turn off." - AND THIS IS lit - ELSE SAY THE THIS. "is already off." - DOES ONLY - "You turn off the" SAY THIS. "." - MAKE THIS NOT lit. - - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ LIQUID - - --- ============================================================== - - -EVERY liquid ISA OBJECT - CONTAINER -- we declare this class a container to make it work with the - -- verb 'pour'(see 'verbs.i'), and also to make possible commands - -- such as 'take pearl from water', 'throw sack into water' - -- and 'look into water'. - - VERB take - DOES ONLY "You cannot carry" SAY THE THIS. "around in your bare hands." - -- a liquid usually needs to be put into a container before it can be - -- carried around - END VERB. - - -END EVERY. - - - --- ============================================================= - - ------ LISTABLE_CONTAINER - - --- ============================================================= - - -EVERY LISTABLE_CONTAINER ISA OBJECT -- ACTORS are separately defined as - CONTAINER -- containers further below - - - VERB examine - DOES - IF THIS IS closeable - THEN - IF THIS IS closed - THEN "It is closed." - ELSE "It is open." - END IF. - END IF. - - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't see inside" SAY THE THIS. "." - END IF. - END VERB. - - - VERB look_in - DOES ONLY - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't, since" SAY THE THIS. "is closed." - END IF. - END VERB. - - - VERB open - DOES - MAKE THIS NOT OPAQUE. - LIST THIS. - END VERB. - - - VERB close - DOES - MAKE THIS OPAQUE. - END VERB. - - -END EVERY. - - - --- Tips for using container objects: - - --- 1) - - --- The contents of a normal CONTAINER are not listed when examined --- (you'll need to look *into* the object to see what it contains). --- If you wish to have the contents listed after 'examine' anyway, --- you should --- --- instead of: --- --- THE box ISA OBJECT --- CONTAINER --- ... --- END THE. --- --- do this: --- --- THE box ISA LISTABLE_CONTAINER --- ... --- END THE. --- --- Then, 'examine' lists the contents of the container. - - --- 2) - - --- For the command 'inventory' to list the contents of a container --- the hero is carrying, go to 'verbs.i', find the command 'inventory' --- and list there manually all relevant containers that the hero might carry, --- thus: --- --- VERB inventory --- DOES LIST hero. --- ... --- IF bag IN hero --- THEN LIST bag. --- END IF. --- --- IF box IN hero --- THEN LIST box. --- END IF. --- ... --- END VERB. --- --- --- If you leave out these additions, the bag and the box will be listed after the --- command 'inventory' in the following way: --- --- "You are carrying a bag and a box." --- --- only. But with the above additions, the outcome is e.g. --- --- "You are carrying a bag and a box. The bag contains a loaf of bread. The box --- is empty." - - --- 3) - - --- To declare a container the contents of which should not be listed after 'look' --- or 'examine', declare it an 'opaque container' in the following way: - - --- THE box ISA OBJECT --- OPAQUE CONTAINER --- ... --- END THE. - - --- or - - --- THE box ISA LISTABLE_CONTAINER --- OPAQUE CONTAINER --- ... --- END THE. - - --- Objects in an opaque container cannot be seen or manipulated. --- To change this, use --- --- MAKE box NOT OPAQUE. --- - - - --- ============================================================== - - ------ SCENERY - - --- ============================================================== - - -EVERY scenery ISA OBJECT - IS NOT takeable. - DESCRIPTION "" - - - VERB examine - DOES ONLY SAY THE THIS. "doesn't appear particularly interesting to you." - END VERB. - - -- see also checks in the verbs 'take' and 'take from' in 'verbs.i' - -END EVERY. - - - --- =============================================================== - - ------ SOUND - - --- =============================================================== - - -EVERY sound ISA OBJECT - IS NOT examinable. - IS NOT reachable. - IS NOT movable. - - - VERB smell - DOES ONLY "That's not something you can smell." - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ SUPPORTER - - --- ============================================================== - - -EVERY supporter ISA OBJECT - CONTAINER - HEADER "On" SAY THE THIS. "you see" - ELSE "There's nothing on" SAY THE THIS. "." - - - VERB examine - DOES LIST THIS. - END VERB. - - - VERB put_in - WHEN obj2 - DOES ONLY "You can't put anything inside" SAY THE THIS. "." - END VERB. - - - VERB search - DOES ONLY "You find nothing further of interest." - END VERB. - - -END EVERY. - - --- To place objects on a supporter, do the definition in the following way: --- --- Define the supporter first; e.g. --- --- THE tray ISA SUPPORTER --- ... --- END THE. --- --- --- Then, the objects on the supporter: --- --- --- THE apple ISA OBJECT --- IN tray -- note the IN here, even if the apple will be described as --- ... -- being on the tray --- END THE. --- --- --- THE book ISA OBJECT --- IN table --- ... --- END THE. --- --- --- Note that the 'examine' command will list what is on the surface of a supporter, not what, --- if anything, is inside the supporter. For example, if you have a supporter called table in your game --- with a drawer in it, --- --- DON'T do this: --- --- --- THE drawer ISA LISTABLE_CONTAINER --- IN table. --- END THE. --- --- This would result in something like --- --- "There's a table here. On the table you see a book and a drawer." --- --- --- Instead, do either of the two following things: --- --- --- 1) --- --- THE drawer ISA LISTABLE_CONTAINER --- AT bedroom --- END THE. --- --- --- In other words, just declare the drawer present in the location, not as part of the table. --- ('AT table' would not be possible, as all objects must be initially located to --- instances inheriting from the class 'location'.) --- If this method feels clumsy, try the next one: --- --- --- 2) --- --- THE table_parts ISA OBJECT --- AT bedroom --- DESCRIPTION "" -- we don't want this object to appear in the room description --- CONTAINER --- HEADER "In the table there is" --- ELSE "" -- if the parts are removed from the table, there will be no --- END THE. -- mention of them in the description of the table --- --- --- THE drawer ISA LISTABLE_CONTAINER --- IN table_parts --- ... --- END THE. --- --- --- THE table ISA SUPPORTER --- ... --- VERB examine --- DOES ONLY --- LIST table. -- lists what is on the table --- LIST table_parts. -- lists the components of the table, i.e. the drawer in this example --- ... --- END VERB. --- --- END THE. --- --- --- In other words, define a separate container for the component(s) in the supporter --- which will then be listed after the surface objects have been listed. --- Consequently, the above will result in something like this: --- --- > examine table --- On the table you see a book. In the table there is a drawer. --- --- --- Note that in a location description (e.g. after LOOK), only the things *on* a supporter --- (and not any components) will be described, according to how things are defined in --- this library. --- --- - - - --- ============================================================== - - ------ WEAPON - - --- ============================================================== - - -EVERY weapon ISA OBJECT - IS NOT fireable. -END EVERY. - - - --- ============================================================== - - ------ WINDOW - - --- ============================================================== - - --- You can look out of and through a window. --- When examined, a window is automatically described to be either open or closed. - - -EVERY window ISA OBJECT - IS closeable. - IS closed. - IS NOT takeable. - - - VERB examine - DOES - IF THIS IS closed - THEN "It is currently closed." - ELSE "It is currently open." - END IF. - END VERB. - - - VERB look_behind - DOES ONLY - "That's not possible." - END VERB. - - - VERB look_out_of - DOES ONLY "You see nothing special looking out of the window." - END VERB. - - - VERB look_through - DOES ONLY "You see nothing special looking through the window." - END VERB. - - -END EVERY. - - - --- =============================================================== - --- =============================================================== --- --- 2. Actor classes --- --- =============================================================== - --- =============================================================== - - --- First, we declare some common characteristics for all actors: - - -ADD TO EVERY ACTOR - IS NOT inanimate. - IS NOT following. - - CONTAINER - - INITIALIZE - USE SCRIPT following_hero FOR THIS. - - SCRIPT following_hero -- this code will make any actor follow the hero - STEP WAIT UNTIL hero NOT HERE -- if the actor is given the attribute 'following'. - IF THIS IS following - THEN - LOCATE THIS AT hero. - SAY THE THIS. "follows you." - END IF. - USE SCRIPT following_hero FOR THIS. - - - - - VERB examine - DOES - IF COUNT ISA THING, IN THIS > 0 -- This if-statement will make a description of an - THEN LIST THIS. -- actor's possessions show up every time the actor is examined. - END IF. -- Note that this doesn't apply to the hero which is defined - -- separately further below. - END VERB. - -END ADD TO. - - --- To make an actor follow the hero, give it the 'following' attribute, e.g.: - --- THE bob ISA ACTOR --- ... --- VERB blahblah --- DOES MAKE bob following. --- END VERB. --- .... --- --- END THE bob. --- --- etc. - --- --- If you wish to have an actor follow the hero right from the start of the game, you can naturally just declare --- --- THE servant ISA ACTOR --- IS following. --- ... --- END THE. --- --- - - - --- ================================================================ - - ------ PERSON -- HAS can_talk - - --- ================================================================ - - -EVERY person ISA ACTOR - HAS can_talk. -END EVERY. - - - --- ================================================================ - - ------ NAMED_ACTOR -- NOT can_talk - - --- ================================================================ - - -EVERY named_actor ISA ACTOR - DESCRIPTION SAY THIS. "is here." - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" -END EVERY. - - - --- ================================================================ - - ------ NAMED_PERSON -- HAS can_talk - - --- ================================================================ - - -EVERY named_person ISA PERSON - DESCRIPTION SAY THIS. "is here." - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" -END EVERY. - - - --- ================================================================ - - ------ Expressing FEMALE and MALE - - --- ================================================================ - - --- 'Male' and 'female' are not declared as separate classes in this library. --- This is to avoid numerous new subclasses such as female_actor, named_female_actor, --- female_person, named_female_person, and the same for male. Instead, just --- --- add the line --- --- PRONOUN him --- --- or --- --- PRONOUN her --- --- to any actor instance to make it possible for the player to refer to the --- actor with these pronouns. For example, --- --- THE jessie ISA NAMED_PERSON --- PRONOUN her --- ... --- END THE. - - - --- ================================================================ - --- ================================================================ - --- 3. The hero - --- ================================================================ - --- ================================================================ - - - - -THE hero ISA ACTOR - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" - MENTIONED "yourself" - IS NOT sitting. - IS NOT lying_down. - - CONTAINER - - LIMITS -- remove this whole section (from this line until 'HEADER') if you wish to have no limits to - -- how much the hero can carry. - COUNT 10 Then - "You can't carry anything more. You have to drop something - first." - WEIGHT 50 Then - "You can't carry anything more. You have to drop something - first." - - HEADER - IF CURRENT LOCATION IS NOT lit - THEN "Although you cannot see your belongings in the dark, you - remember that you're carrying" - ELSE "You are carrying" - END IF. - ELSE - "You are empty-handed." - - - VERB examine - DOES ONLY "You notice nothing unusual about yourself." - IF COUNT ISA CLOTHING, IN worn > 0 - THEN LIST worn. -- this will list what the hero is wearing - END IF. - END VERB. - - -END THE. - - -SYNONYMS - me, myself, yourself, self = hero. - - --- Please refer also 'verbs.i' where there are numerous verb checks for the hero, so that the hero cannot e.g. kick himself etc. - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/locations.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/locations.i deleted file mode 100755 index beb6c4d..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/locations.i +++ /dev/null @@ -1,472 +0,0 @@ --- ALAN NEW LIBRARY: LOCATIONS (file name: 'locations.i') - - --- This library file defines the default directions (exits) and the location 'nowhere', a useful --- place to locate things when you want to remove them from play. --- This file also defines three specific location classes: rooms (= indoor locations), --- sites (= outdoor locations) as well as the class 'dark_location'. --- Finally, the attribute 'visited' and the instance 'room' (to make possible player commands --- such as 'examine room' and 'exit room') are defined. --- You may modify this file in any way that suits your purposes. --- To use this file, you should have it in the same folder as your source code file , and the line --- --- IMPORT 'locations.i'. --- --- in your source code. - - - --- ======================================================== - - ------ 1. The location 'nowhere' and the default directions - - --- ======================================================== - - -THE nowhere ISA LOCATION - - EXIT - north, - south, - east, - west, - northeast, - southeast, - northwest, - southwest, - up, - down, - 'in', - out - - TO nowhere. - - -END THE nowhere. - - -SYNONYMS - n = north. - s = south. - e = east. - w = west. - ne = northeast. - se = southeast. - nw = northwest. - sw = southwest. - u = up. - d = down. - - --- Note: - - --- 1) the directions defined above (and their synonyms) are not predefined or hardwired --- to the interpreter in any way, so you can replace them altogether or add new --- ones to be used alongside with them. - - --- 2) when you want to remove things from play, you can --- --- LOCATE [object] AT nowhere. --- --- e.g. --- --- THE piece_of_paper ISA OBJECT --- ... --- VERB tear --- DOES ONLY "You tear the piece of paper to shreds." --- LOCATE piece_of_paper AT nowhere. --- END VERB. --- --- END THE piece_of_paper. - - - --- ========================================================================= - - ------ 2. Location classes 'room' and 'site' for indoor and outdoor locations - - --- ========================================================================= - - --- ROOM and SITE are optional location classes you can use to ease up coding. --- All ROOMS have a floor, walls and a ceiling. All SITES have a ground and a sky. --- Thus, you will be able to define e.g. --- --- THE kitchen ISA ROOM --- --- and it will automatically have a floor, walls and a ceiling, --- --- or: --- --- THE greenmeadow ISA SITE --- --- and the ground and the sky are automatically found in that location. --- --- --- Of course, you will still be able to define locations in the usual way, e.g. --- --- THE kitchen ISA LOCATION --- --- etc, but the floor, walls and ceiling won't be automatically included there. --- The walls, floor, ceiling, ground and sky are not takeable or movable. --- This library file also defines the sky and the ceiling to be out of reach, --- so that they can't be e.g. touched. - --- (We make use of ALAN's nested locations feature in the following definitions: ) - - -THE outdoor ISA LOCATION -END THE outdoor. - - -THE indoor ISA LOCATION -END THE indoor. - - -EVERY room ISA LOCATION AT indoor -END EVERY. - - -EVERY site ISA LOCATION AT outdoor -END EVERY. - - -EVERY room_object ISA OBJECT AT indoor -END EVERY. - - -EVERY site_object ISA OBJECT AT outdoor -END EVERY. - - -THE floor ISA room_object - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the floor here." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - -THE walls ISA room_object - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the walls here." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - -SYNONYMS wall = walls. - - -THE ceiling ISA room_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the ceiling here." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - -THE ground ISA site_object - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - - VERB examine - DOES ONLY "You notice nothing unusual about the ground here." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - - VERB dig - DOES ONLY "The ground is not suitable for digging here." - END VERB. - - -END THE. - - -THE sky ISA site_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the sky." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - --- NOTE: it is often a good idea to modify the 'examine' verb for the above objects. --- Here is an example for 'walls': - --- THE walls ISA room_object --- : --- : --- VERB examine DOES ONLY --- IF hero AT kitchen --- THEN "Numerous shelves, full of various kitchen utensils, line the walls." --- ELSIF hero AT livingroom --- THEN "The walls are decorated with flowery wallpaper here." --- : --- : --- END IF. --- END VERB. --- END THE walls. --- --- In other words, making the description of the walls, etc., individual for each room --- gives a better impression than if you just use the default messages. - - - --- ========================================================== - - ------ 3. Dark locations - - --- ========================================================== - - -ADD TO EVERY LOCATION - IS lit. -END ADD TO. - - -EVERY dark_location ISA LOCATION - IS NOT lit. - - ENTERED - - IF COUNT ISA lightsource, IS lit, HERE > 0 - THEN MAKE THIS lit. - END IF. - - IF COUNT ISA lightsource, IS lit, HERE = 0 - THEN MAKE THIS NOT lit. - END IF. - - -- these ENTERED statements take care - -- of the dark location being correctly lit or not lit at entrance, the WHEN rules below take care of - -- the change when the hero is already in the location. - - DESCRIPTION - CHECK COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - ELSE "It is pitch black. You can't see anything at all." - -END EVERY dark_location. - - -WHEN CURRENT LOCATION IS NOT lit - AND COUNT ISA lightsource, IS lit, HERE > 0 -THEN MAKE CURRENT LOCATION lit. - LOOK. - - -WHEN CURRENT LOCATION ISA dark_location - AND CURRENT LOCATION IS lit - AND COUNT ISA lightsource, IS lit, HERE = 0 -THEN MAKE CURRENT LOCATION NOT lit. - "It is now pitch black." - - --- To define a dark location, use a formulation like the following: - - --- THE basement ISA dark_location --- EXIT up TO kitchen. --- ... --- END THE. - - --- The description of a dark_location will automatically be: "It is pitch black. --- You can't see anything at all." (Edit the description in the code above to change this.) - - --- If you add a description to a dark_location, this description will be shown only --- if/when the location is lit by any means: - - --- THE basement ISA dark_location --- DESCRIPTION "Cobwebs and old junk are the only things you see here." --- EXIT up TO kitchen. --- END THE. - - --- In darkness, you are not able to manipulate things other than turn on a lightsource --- and drop items you're carrying (these checks are found in 'verbs.i'). You can exit normally --- and use verbs that don't require seeing, such as 'smell', 'listen' and 'think'. --- If you are in a dark location with an NPC (= a non-player character), you are able to --- communicate with him by asking and telling but not by showing and giving. If you wish to --- change this, see the respective verbs in 'verbs.i' and edit their checks. - - --- Note that you cannot change the name of a location mid-game. Thus, if you define a dark location --- called e.g. 'Darkness' and wish to make it lit at some point in the game, the name will still be 'Darkness' --- even if the location description can be changed to describe the illuminated location. --- To change the location name, you must locate the hero in another location when the dark location --- is lit. For example, --- --- --- THE lantern ISA LIGHTSOURCE -- (see 'classes.i') --- VERB turn_on --- DOES --- IF hero AT darkness --- THEN LOCATE hero AT treasure_chamber. --- ... --- END IF. --- ... --- END VERB. --- --- etc. --- --- --- Alternatively, you can also use a rule, e.g. --- --- --- WHEN lantern IS lit --- AND hero AT darkness --- THEN LOCATE hero AT treasure_chamber. --- --- - - --- ===================================================================== - - ------ 4. The attribute 'visited' - - --- ===================================================================== - - --- a location is 'NOT visited' until the hero visits it for the first time and the description of it is shown. --- This distinction is handy when you want the first-time description of a location to be different from --- the subsequent ones. - - -ADD TO EVERY LOCATION - IS NOT visited. - ENTERED - MAKE THIS visited. -END ADD TO. - - - --- Now, in your source code you can define something like the following: - - --- THE kitchen ISA LOCATION --- DESCRIPTION --- "You are in the kitchen." --- IF THIS IS NOT visited --- THEN "This is your first time here." --- ELSE "You've been here before." --- END IF. --- ... --- END THE. - --- etc. - - - --- ======================================================================= - - --- 5. The instance 'room' - - --- ======================================================================= - - - --- Through defining the instance 'room' we make possible player commands such as 'examine room' and --- 'exit room', among others. These commands only work in indoor locations. --- We have to identify this instance differently from 'room' which has already been defined as a subclass above, --- that's why we identify it here as 'thisroom'. Through the NAME statement, it can be still --- called a 'room' in-game. - - -THE thisroom ISA OBJECT - AT indoor - NAME 'room' - IS NOT takeable. - CONTAINER - DESCRIPTION "" - - - VERB examine - DOES ONLY DESCRIBE CURRENT LOCATION. - END VERB. - - - VERB search - DOES ONLY "Try examining one thing at a time." - END VERB. - - - VERB enter - DOES ONLY "You must state a direction where to go." - END VERB. - - - VERB 'exit' - DOES ONLY "You must state a direction where to go." - END VERB. - - -END THE. - - - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/messages.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/messages.i deleted file mode 100755 index 8c17152..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/messages.i +++ /dev/null @@ -1,72 +0,0 @@ --- ALAN NEW LIBRARY: MESSAGES (file name: 'messages.i') - - --- This library file lists all the standard runtime messages listed in the manual, for easy modification. - - - -MESSAGE AFTER_BUT: "You must give at least one object after '$1'." - AGAIN: "(again)" -- if you wish to disable this, make the string empty ("") - BUT_ALL: "You can only use '$1' AFTER '$2'." - CAN_NOT_CONTAIN: "$+1 can not contain $+2." - CANT0: "You can't do that." -- note that the fifth token in CANT0 is a zero, not an 'o'. - CARRIES: "$+1 carries" - 'CONTAINS': "$+1 contains" - CONTAINS_COMMA: "$01," - CONTAINS_AND: "$01 and" - CONTAINS_END: "$01." - EMPTY_HANDED: "$+1 is empty-handed." - HAVE_SCORED: "You have scored $1 points out of $2." - IS_EMPTY: "$+1 is empty." - MORE: "" - MULTIPLE: "You can't refer to multiple objects with '$v'." - NO_SUCH: "I can't see any $1 here." - NO_WAY: "You can't go that way." - NOT_MUCH: "That doesn't leave much to $v!" - NOUN: "You must supply a noun." - NOT_A_SAVEFILE: "That file does not seem to be an Alan game save file." - QUIT_ACTION: "Do you want to RESTART, RESTORE, QUIT or UNDO? " - -- these four alternatives are hardwired to the interpreter and cannot be changed. - REALLY: "Are you sure (RETURN confirms)?" - RESTORE_FROM: "Enter file name to restore from" - SAVE_FAILED: "Sorry, save failed." - SAVE_MISSING: "Sorry, could not open the save file." - SAVE_NAME: "Sorry, the save file did not contain a save for this adventure." - SAVE_OVERWRITE: "That file already exists, overwrite (y)?" - SAVE_VERSION: "Sorry, the save file was created by a different version." - SAVE_WHERE: "Enter file name to save in" - SEE_START: "There is $01" - SEE_COMMA: ", $01" - SEE_AND: "and $01" - SEE_END: "here." - NO_UNDO: "No further undo available." - UNDONE: "'$1' undone." - UNKNOWN_WORD: "I don't know the word '$1'." - WHAT: "I don't understand." - WHAT_WORD: "I don't know what you mean by '$1'." - WHICH_PRONOUN_START: "I don't know if you by '$1'" - WHICH_PRONOUN_FIRST: "mean $+1" - WHICH_START: "I don't know if you mean $+1" - WHICH_COMMA: ", $+1" - WHICH_OR: "or $+1." - - --- These messages are automatically translated into German or Swedish in your game --- if you define in the beginning of your source code --- --- OPTIONS --- LANGUAGE German. --- --- or --- --- OPTIONS --- LANGUAGE Swedish. --- --- Only the exact equivalents of the above phrases will then be shown; if you change the above English --- messages to your own wordings, the translations will still be only for the default. --- --- --- If you wish to make your game in some other language, you must manually translate --- the messages above. There might be support for more languages in the future, depending --- on demand. - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/setup b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/setup deleted file mode 100755 index b657069..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/setup +++ /dev/null @@ -1,3 +0,0 @@ -take flashlight and turn it on -open door, n, n -take the shirt and put it on \ No newline at end of file diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/verbs.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/verbs.i deleted file mode 100755 index f7dba49..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-05/verbs.i +++ /dev/null @@ -1,5803 +0,0 @@ --- ALAN NEW LIBRARY: VERBS (file name: verbs.i) - - ------ This library file defines common verbs needed in gameplay. The verbs are listed alphabetically. ------ This file also includes common commands which are not actually verbs, such as inventory, ------ verbose and again. You are free to edit this file for your own purposes in any way you ------ like by adding, deleting or modifying verbs. Verbs originally defined in this file ------ are the following: - ------ VERB SYNONYM - ------ about (+ help, info) ------ again (+ g) ------ answer (+ reply) ------ ask (+ enquire, inquire, interrogate) ------ attack (+ beat, fight, hit, kick, punch) ------ attack_with ------ bite (+ chew) ------ break (+ destroy) ------ break_with ------ brief ------ burn ------ burn_with ------ buy (+ purchase) ------ catch ------ clean (+ polish, wipe) ------ climb ------ climb_on ------ climb_through ------ close ------ close_with ------ consult ------ credits (+ acknowledgments, author, copyright) ------ cut ------ cut_with ------ dance ------ dig ------ dive ------ dive_in ------ drink ------ drive ------ drop (+ discard, dump, reject) ------ eat ------ empty ------ empty_in ------ empty_on ------ enter (+ obj) ------ examine (+ check, inspect, observe, x) ------ exit (+ obj) ------ extinguish (+ put out, quench) ------ fill ------ fill_with ------ find (+ locate) ------ fire ------ flip ------ follow ------ free (+ release) ------ get_up ------ get_off ------ give ------ go_to ------ hint (+ hints) ------ inventory (+ i, inv) ------ jump ------ jump_in ------ jump_on ------ kill (+ murder) ------ kill_with ------ kiss (+ hug, embrace) ------ lie_down ------ lie_in ------ lie_on ------ lift ------ light (+ lit) ------ listen0 (= 'listen', with no object) ------ listen (= 'listen to', with an object) ------ lock ------ lock_with ------ look (+ gaze, peek) ------ look_at ------ look_behind ------ look_in ------ look_out_of ------ look_through ------ look_under ------ look_up ------ no ------ open ------ open_with ------ play ------ play_with ------ pour ------ pour_in ------ pour_on ------ pray ------ pry ------ pry_with ------ pull ------ push ------ push_with ------ put (+ lay, place) ------ put_behind ------ put_down ------ put_in (+ insert) ------ put_near ------ put_on ------ put_under ------ read ------ restart ------ restore ------ rub ------ save ------ say ------ say_to ------ score ------ search ------ sell ------ shake ------ shoot (at) ------ shoot_with ------ shout (+ scream, yell) ------ show (+ reveal) ------ sing ------ sip ------ sit (down) ------ sit_on ------ sleep (+ rest) ------ smell0 (= 'smell', with no object) ------ smell (= 'smell' with an object) ------ squeeze ------ stand (up) ------ stand_on ------ swim ------ swim_in ------ switch_on ------ switch_off ------ take (+ carry, get, grab, hold, obtain) ------ take_from (+ remove from) ------ talk ------ talk_to (+ speak) ------ taste (+ lick) ------ tear (+ rip) ------ tell (+ enlighten, inform) ------ think ------ think_about ------ throw ------ throw_at ------ tie ------ tie_to ------ touch (+ feel) ------ turn (+ rotate) ------ turn_on (+ switch on) ------ turn_off (+ switch off) ------ unlock ------ unlock_with ------ use ------ use_with ------ verbose ------ wait (+ z) ------ what_am_i ------ what_is ------ where_am_i ------ where_is ------ who_am_i ------ who_is ------ write ------ yes - - ------ Directions (north, south, up, etc.) are declared in the file 'locations.i'. - - ------ Verbs having to do with wearing clothes are defined in the file 'classes.i', ------ subclass 'clothing'. These verbs, together with their synonyms, are: ------ ------ remove (+ doff, take off) ------ wear (+ don, put on) ------ undress - - - ------ We first declare some default attributes for things (= objects and actors) below. ------ These attributes are frequently checked in verb definitions, to prohibit ------ the use of verbs with objects and actors in an irrational way. For example, the hero ------ won't be able to eat something that is not edible, and so forth. - - ------ Specific object and actor attributes that override or complete the following ------ attributes are declared in 'classes.i'. - - - -ADD TO EVERY THING - - IS examinable. - inanimate. - movable. - reachable. - takeable. - - HAS text "". - - NOT broken. - NOT can_talk. - NOT closeable. - NOT closed. - NOT drinkable. - NOT edible. - NOT lit. - NOT lockable. - NOT locked. - NOT plural. - NOT readable. - NOT wearable. - NOT writeable. - -END ADD TO. - - ------ Next, we declare synonyms for some words so that it will be possible ------ for the player to type commands such as both "put ball in box" and "put ball into box", etc: - - -SYNONYMS - -into, inside = 'in'. -onto = on. -thru = through. -using = 'with'. - - - ------ The verbs and commands: - - --- ============================================================= - - ------ ABOUT - - --- ============================================================= - - -SYNTAX 'about' = 'about'. - - -VERB 'about' - DOES - STYLE emphasized. - "This is a text adventure, also called interactive fiction, which means that what - goes on in the story depends on what you type at the prompt. Commands you can type - are for example GO NORTH (or NORTH or just N), WEST, SOUTHEAST, UP, IN etc for - moving around, but you can try many - other things too, like TAKE LAMP, DROP EVERYTHING, EAT APPLE, EXAMINE BIRD or - FOLLOW OLD MAN, to name just a few. LOOK (L) describes your surroundings, and - INVENTORY (I) lists what you are carrying. You can SAVE your game and RESTORE it - later on. - $pType CREDITS to see information about the author and the copyright issues. - $pTo stop playing and end the program, type QUIT.$p" - STYLE normal. -END VERB. - - -SYNONYMS help, info = 'about'. - - - --- ============================================================= - - ------ AGAIN (= g) - - --- ============================================================= - - -SYNTAX again = again. - - -VERB again - DOES - "[The AGAIN command is not supported in this game. As a workaround, try using - the 'up' and 'down' arrow keys to scroll through your previous commands.]" -END VERB. - - -SYNONYMS g = again. - - - --- ============================================================= - - ------ ASK (= enquire, inquire, interrogate) - - --- ============================================================= - - -SYNTAX ask = ask (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That doesn't seem to be something you can talk about with" SAY THE act. "." - - -ADD TO EVERY THING - VERB ask - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act IS reachable -- in some situations, you might wish to remove this check, - -- e.g. if the non-player character is speaking on the phone with the hero - ELSE SAY THE act. "is too far away." - AND act <> hero - ELSE "It doesn't make much sense to ask yourself about something." - DOES - IF topic IN act - THEN SAY THE act. "doesn't seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. "chooses to be silent." - ELSIF topic = hero - THEN """I think you know more about yourself than what I do!""," SAY THE act. "snaps." - ELSE """I don't know anything about" SAY THE topic. "$$!""," SAY THE act. "snaps." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS enquire, inquire, interrogate = ask. - - ------ note that 'consult' is defined separately - - - --- ============================================================= - - ------ ATTACK (+ beat, fight, hit, kick, punch) - - --- ============================================================= - - -SYNTAX attack = attack (obj) - WHERE obj ISA THING - ELSE "Thats not something you can attack." - - -ADD TO EVERY THING - VERB attack - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND obj NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND obj NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - -SYNONYMS beat, fight, hit, kick, punch = attack. - - - --- ============================================================== - - ------ ATTACK WITH - - --- ============================================================== - - -SYNTAX attack_with = attack (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can attack." - AND obj2 ISA WEAPON - ELSE - IF obj2 ISA ACTOR - THEN - IF obj2 = hero - THEN "It doesn't make sense to attack something with yourself." - ELSE "You cannot use" SAY THE obj2. "to attack anything." - END IF. - ELSE "There's no point attacking anything with" - SAY THE obj2. "." - END IF. - - -ADD TO EVERY THING - VERB attack_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can $v." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 In hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> hero - ELSE "It doesn't make sense to $v yourself." - AND obj1 NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND obj1 NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - - --- =============================================================== - - ------ BITE (+ chew, taste) - - --- =============================================================== - - -SYNTAX bite = bite (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can bite." - - -ADD TO EVERY OBJECT - VERB bite - CHECK obj IS edible - ELSE "That's not something you should $v." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj NOT IN hero - THEN - IF obj IS takeable - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - "You take a bite of" SAY THE obj. "$$.It tastes rather good." - ELSE "You don't have" SAY THE obj. "." - END IF. - ELSE - "You take a bite of" SAY THE obj. "$$. It tastes rather good." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS chew = bite. - - - --- =============================================================== - - ------ BREAK - - --- =============================================================== - - -SYNTAX break = break (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "Resorting to violence is not the answer." - ELSE "That's not something you can break." - END IF. - - -ADD TO EVERY OBJECT - VERB break - CHECK obj IS examinable - ELSE "That's not something you can break." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - -SYNONYMS destroy = break. - - - - --- =============================================================== - - ------ BREAK WITH - - --- =============================================================== - - -SYNTAX break_with = break (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can break." - AND obj2 ISA OBJECT - ELSE "That's not something you can break things with." - - -ADD TO EVERY OBJECT - VERB break_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can break." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't break" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ BRIEF - - --- ================================================================ - - --- Use "Visits 0." or "Visits 1000." in the START section if you want --- the game to start in verbose or brief mode. - - -SYNTAX brief = brief. - - -VERB brief - DOES - Visits 1000. - "Brief mode is now on. Location descriptions will only be shown - the first time you visit." -END VERB. - - - --- ================================================================= - - ------ BURN - - --- ================================================================= - - -SYNTAX burn = burn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "That would be needlessly brutal." - ELSE "That's not something you can burn." - END IF. - - -ADD TO EVERY OBJECT - VERB burn - CHECK obj IS examinable - ELSE "That's not something you can burn." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You must state what you want to burn" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ================================================================= - - ------ BURN WITH - - --- ================================================================= - - -SYNTAX burn_with = burn (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN "That would be needlessly brutal." - ELSE "That's not something you can burn." - END IF. - AND obj2 ISA OBJECT - ELSE - IF obj2 ISA ACTOR - THEN "It doesn't make sense to burn something with" SAY THE obj2. "." - ELSE "It's not possible to burn something with that." - END IF. - - -ADD TO EVERY THING - VERB burn_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can burn." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to burn something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't burn" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ BUY (+ purchase) - - --- ================================================================== - - -SYNTAX buy = buy (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can buy." - - -ADD TO EVERY OBJECT - VERB buy - CHECK obj IS examinable - ELSE "That's not something you can buy." - DOES - "That's not for sale." - END VERB. -END ADD TO. - - -SYNONYMS purchase = buy. - - - --- ================================================================== - - ------ CATCH - - --- ================================================================== - - -SYNTAX catch = catch (obj) - WHERE obj ISA THING - ELSE "That's not something you can catch." - - -ADD TO EVERY THING - VERB catch - CHECK obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND hero IS NOT sitting - ELSE "It is difficult to catch anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to catch anything while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That doesn't need to be caught." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ CLEAN ( + wipe, polish) - - --- ================================================================== - - -SYNTAX clean = clean (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can clean." - - -ADD TO EVERY OBJECT - VERB clean - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS wipe, polish = clean. - - ------ notice that 'rub' is defined separately - - - --- ============================================================== - - ------ CLIMB - - --- ============================================================== - - -SYNTAX climb = climb (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can climb." - - -ADD TO EVERY OBJECT - VERB climb - CHECK obj IS examinable - ELSE "That's not something you can climb." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb while lying down." - DOES - "That's not something you can climb." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB ON - - --- ============================================================== - - -SYNTAX climb_on = climb 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can climb on." - - -ADD TO EVERY OBJECT - VERB climb_on - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - "That's not something you can climb on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB THROUGH - - --- ============================================================== - - -SYNTAX climb_through = climb through (obj) - WHERE obj ISA THING - ELSE "That's not something you can climb through." - - -ADD TO EVERY OBJECT - VERB climb_through - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - "That's not something you can climb through." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLOSE (+ shut) - - --- ============================================================== - - -SYNTAX close = close (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can close." - - -ADD TO EVERY OBJECT - VERB close - CHECK obj IS closeable - ELSE "That's not something you can close." - AND obj IS NOT closed - ELSE "It is already closed." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - MAKE obj closed. - "You close the" SAY THE obj. "." - END VERB. -END ADD TO. - - -SYNONYMS shut = close. - - - --- ============================================================== - - ------ CLOSE WITH - - --- ============================================================== - - -SYNTAX close_with = close (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can close." - AND obj2 ISA OBJECT - ELSE "You can't close anything with that." - - -ADD TO EVERY OBJECT - VERB close_with - WHEN obj1 - CHECK obj1 IS closeable - ELSE "That's not something you can open." - AND obj1 IS NOT closed - ELSE "It is already closed." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't close" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CONSULT - - --- ============================================================== - - -SYNTAX consult = consult (obj1) about (obj2)! - WHERE obj1 ISA THING - ELSE "That's not something you can consult." - AND obj2 ISA THING - ELSE "That's not something you can find information about." - - - consult = 'look' 'up' (obj2) 'in' (obj1). - - -ADD TO EVERY THING - VERB consult - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can consult." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj1 <> hero - ELSE "It doesn't make sense to $v yourself about anything." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 ISA OBJECT - THEN "You find nothing useful about" SAY THE obj2. "in" SAY THE obj1. "." - ELSE SAY THE obj1. "chooses to be silent on that subject." - END IF. - END VERB. -END ADD TO. - - ---- another 'consult' formulation added to guide players to use the right phrasing: - - -SYNTAX consult_error = consult (obj) - WHERE obj ISA THING - ELSE "That's not something you can consult." - - -ADD TO EVERY THING - VERB consult_error - DOES "To consult something, use the formulation CONSULT PERSON/THING ABOUT PERSON/THING." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CREDITS (+ acknowledgments, author, copyright) - - --- ============================================================== - - -SYNTAX credits = credits. - - -VERB credits - DOES - "The author retains the copyright to this game. - $pThis game was written using the ALAN Adventure Language. ALAN is - an interactive fiction authoring system by Thomas Nilsson. - $nE-mail address: thomas.nilsson@progindus.se $pFurther information - about the ALAN system can be obtained from - the World Wide Web Internet site - $ihttp://www.alanif.se$p" -END VERB. - - -SYNONYMS acknowledgments, author, copyright = credits. - - - --- ============================================================== - - ------ CUT - - --- ============================================================== - - -SYNTAX cut = cut (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can cut." - - -ADD TO EVERY OBJECT - VERB cut - DOES "You need to specify what you want to cut" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CUT WITH - - --- ============================================================== - - -SYNTAX cut_with = cut (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can cut." - AND obj2 ISA OBJECT - ELSE "That's not something you can cut with." - - -ADD TO EVERY OBJECT - VERB cut_with - WHEN obj1 - CHECK obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "You can't cut something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't cut" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DANCE - - --- ============================================================== - - -SYNTAX dance = dance. - - -VERB dance - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dance while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dance while lying down." - DOES - "How about a waltz?" -END VERB. - - - --- ============================================================== - - ------ DIG - - --- ============================================================== - - -SYNTAX dig = dig (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can dig." - - -ADD TO EVERY OBJECT - VERB dig - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dig anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dig anything while lying down." - DOES - "There is nothing suitable to dig here." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DIVE - - --- ============================================================== - - -SYNTAX dive = dive. - - -VERB dive - CHECK hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ DIVE IN - - --- ============================================================== - - -SYNTAX dive_in = dive 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can dive into." - - -ADD TO EVERY OBJECT - VERB dive_in - CHECK hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That's not something you can dive into." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DRINK - - --- ============================================================== - - -SYNTAX drink = drink (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can drink." - - -ADD TO EVERY OBJECT - VERB drink - CHECK obj IS drinkable - ELSE "That's not something you can drink." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj NOT IN hero - THEN - IF obj IS takeable - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - "You drink all of" SAY THE obj. "." - LOCATE obj AT nowhere. - ELSE "You don't have" SAY THE obj. "." - END IF. - ELSE LOCATE obj AT nowhere. - "You drink all of" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DRIVE - - --- ============================================================== - - -SYNTAX drive = drive (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can drive." - - -ADD TO EVERY OBJECT - VERB drive - DOES - "That's not something you can drive." - END VERB. -END ADD TO. - - --- another 'drive' formulation added to guide players to use the right phrasing: - - -SYNTAX drive_error = drive. - - -VERB drive_error - DOES "To drive something, use the phrasing DRIVE SOMETHING." -END VERB. - - - --- ============================================================== - - ------ DROP - - --- ============================================================== - - -SYNTAX drop = drop (obj)* - WHERE obj ISA OBJECT - ELSE "That's not something you can drop." - - - drop = put (obj) * down. - - - drop = put down (obj)*. - - -ADD TO EVERY OBJECT - VERB drop - CHECK obj IN hero - ELSE "You don't have" SAY THE obj. "." - DOES - LOCATE obj HERE. - "Dropped." - END VERB. -END ADD TO. - - -SYNONYMS - discard, dump, reject = drop. - - - --- ============================================================== - - ------ EAT - - --- ============================================================== - - -SYNTAX eat = eat (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can eat." - - -ADD TO EVERY OBJECT - VERB eat - CHECK obj IS edible - ELSE "That's not something you can eat." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj NOT IN hero - THEN - IF obj IS takeable - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - "You eat all of" SAY THE obj. "." - LOCATE obj AT nowhere. - ELSE "You don't have" SAY THE obj. "." - END IF. - ELSE - LOCATE obj AT nowhere. - "You eat all of" SAY THE obj. "." - END IF. - END VERB. -END ADD. - - - --- ============================================================== - - ------ EMPTY - - --- ============================================================== - - --- The verbs 'empty' and 'pour' work a bit differently from each other. --- You can both empty and pour a container object, and its contents will be --- emptied in (on the floor or on the ground of) the current location if you don't --- specify anything else. --- However, as far as liquids are concerned, you can only pour liquids --- but not empty them - it is only possible to empty container objects. --- This entails that if there is for example a bottle in your game that contains some water, both --- --- 'pour bottle' AND 'pour water' have the same effect in the game, --- --- whereas it is only possible to say --- --- 'empty bottle' but NOT 'empty water'. --- --- If you wish to change this, tweak these two verbs as you see fit for your purposes --- (for example, delete one of the verbs altogether and make it a synonym of the other one). - - -SYNTAX 'empty' = 'empty' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can empty." - AND obj ISA CONTAINER - ELSE "That's not something you can empty." - - -ADD TO EVERY OBJECT - VERB 'empty' - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - AND COUNT ISA OBJECT, IN obj > 0 - ELSE "There is nothing in" SAY THE obj. "." - DOES - IF obj ISA LIQUID - THEN "That's not something you can empty." - ELSIF obj NOT IN hero - THEN - IF obj IS takeable - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj AT hero. - "You empty the contents of" SAY THE obj. - IF floor HERE - THEN "on the floor" - ELSE "on the ground" - END IF. - "." - EMPTY obj AT hero. - ELSE "You don't have" SAY THE obj. "." - END IF. - ELSE "You empty the contents of" SAY THE obj. - IF floor HERE - THEN "on the floor" - ELSE "on the ground" - END IF. - "." - EMPTY obj AT hero. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ EMPTY IN - - --- ============================================================== - - -SYNTAX empty_in = 'empty' (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pour." - AND obj1 ISA CONTAINER -- only a container object can be emptied into something - ELSE "That's not something you can pour." - AND obj2 ISA OBJECT - ELSE "Pouring" SAY THE obj1. "into" SAY THE obj2. "is not possible." - AND obj2 ISA CONTAINER - ELSE "You can't pour anything into that." - - -ADD TO EVERY OBJECT - VERB empty_in - WHEN obj1 - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND COUNT ISA OBJECT, IN obj1 > 0 - ELSE SAY THE obj1. "is already empty." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is already in" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to empty something into itself." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS NOT closed - ELSE "You can't, since the" SAY THE obj2. "is closed." - - DOES - IF obj1 ISA LIQUID - THEN "That's not something you can empty." - ELSIF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - "It would serve no purpose to empty" SAY THE obj1. "into" SAY THE obj2. "." - -- If you need to make this work, use the following lines instead: - -- "You empty" SAY THE obj1. "into" SAY THE obj2. "." - -- EMPTY obj1 IN obj2. - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE "It would serve no purpose to empty" SAY THE obj1. "into" SAY THE obj2. "." - -- If you need to make this work, use the following lines instead: - -- "You empty" SAY THE obj1. "into" SAY THE obj2. "." - -- EMPTY obj1 IN obj2. - END IF. - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ EMPTY ON - - --- ============================================================== - - -SYNTAX empty_on = 'empty' (obj1) 'on' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pour." - AND obj1 ISA CONTAINER -- only (the contents of) a container object can be poured in something - ELSE "That's not something you can pour." - AND obj2 ISA THING - ELSE "You can't pour anything onto that." - - -ADD TO EVERY OBJECT -VERB empty_on - WHEN obj1 - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND COUNT ISA OBJECT, IN obj1 > 0 - ELSE SAY THE obj1. "is already empty." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 <> hero - ELSE "That wouldn't make sense." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - "It would serve no purpose to empty" SAY THE obj1. "on" SAY THE obj2. "." - -- (or, to make it work, use the following lines instead of the above: - -- "You empty" SAY THE obj1. "on" SAY THE obj2. ". Nothing special happens." - -- EMPTY obj1 AT hero.) - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE "It would serve no purpose to pour" SAY THE obj1. "on" SAY THE obj2. "." - -- (or, to make it work, use the following lines instead of the above: - -- "You pour" SAY THE obj1. "on" SAY THE obj2. ". Nothing special happens." - -- EMPTY obj1 AT hero.) - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ ENTER (+ obj) - - --- ============================================================== - - -SYNTAX enter = enter (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can enter." - AND obj ISA CONTAINER - ELSE "That's not something you can enter." - - -ADD TO EVERY OBJECT - VERB enter - CHECK hero IS NOT sitting - ELSE "It is difficult to enter anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to enter anything while lying down." - DOES - "That's not something you can enter." - END VERB. -END ADD TO. - - ---- another 'enter' formulation declared to guide players to use the right formulation: - - -SYNTAX enter_error = enter. - - -VERB enter_error - DOES "You must state what you want to enter." -END VERB. - - - --- ============================================================== - - ------ EXAMINE (+ look at) - - --- ============================================================== - - -SYNTAX examine = examine (obj) - WHERE obj ISA THING - ELSE "That's not something you can examine." - - -SYNTAX examine = 'look' 'at' (obj). - examine = 'look' (obj). -- note that this formulation is allowed, too - - -ADD TO EVERY THING - VERB examine - CHECK obj IS examinable - ELSE "You can't examine" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "You can't see anything in the dark." - DOES - IF obj IS readable - THEN - IF text OF obj = "" - THEN "There is nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. ". It says ""$$" SAY text OF obj. "$$""." - END IF. - ELSE "There is nothing special about" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - 'check', inspect, observe, x = examine. - - - --- ============================================================== - - ------ EXIT (obj) - - --- ============================================================== - - -SYNTAX 'exit' = 'exit' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can exit." - AND obj ISA CONTAINER - ELSE "That's not something you can exit." - - -ADD TO EVERY OBJECT - VERB 'exit' - CHECK hero IN obj - ELSE - IF obj = thisroom - THEN "You must state a direction where to go." - ELSE "But you aren't in" SAY THE obj. "!" - END IF. - DOES - "You exit" SAY THE obj. "." - LOCATE hero AT CURRENT LOCATION. - END VERB. -END ADD TO. - - ---- another 'exit' formulation added to guide players to use the right formulation: - - -SYNTAX exit_error = 'exit'. - - -VERB exit_error - DOES - "You must state what you want to exit." -END VERB. - - - --- ============================================================== - - ------ EXTINGUISH (+ put out) - - --- ============================================================== - - -SYNONYMS quench = extinguish. - - -SYNTAX extinguish = extinguish (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can extinguish." - extinguish = put 'out' (obj). - - -ADD TO EVERY OBJECT - VERB extinguish - DOES - "That's not on fire." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL - - --- ============================================================== - - -SYNTAX fill = fill (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can fill." - AND obj ISA CONTAINER - ELSE "That's not something you can fill." - - -ADD TO EVERY OBJECT - VERB fill - DOES - "You have to say what you want to fill" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL WITH - - --- ============================================================== - - -SYNTAX fill_with = fill (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can fill." - AND obj1 ISA CONTAINER - ELSE "That's not something you can fill." - AND obj2 ISA OBJECT - ELSE "It's not possible to fill something with that." - - -ADD TO EVERY OBJECT - VERB fill_with - WHEN obj1 - CHECK obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to fill something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You fill" SAY THE obj1. "with" SAY THE obj2. "." - LOCATE obj2 IN obj1. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIND - - --- ============================================================== - - -SYNTAX - find = find (obj)! - WHERE obj ISA THING - ELSE "That's not something you need to find." - - -ADD TO EVERY THING - VERB find - CHECK obj NOT here - ELSE "The" SAY obj. "is right here!" - AND CURRENT LOCATION IS lit - ELSE "It's too dark to find anything here." - AND obj <> hero - ELSE "You're right here!" - DOES - "You'll have to find it yourself." - END VERB. -END ADD TO. - - -SYNONYMS 'locate' = find. - - - --- ============================================================== - - ------ FIRE - - --- ============================================================== - - -SYNTAX fire = fire (obj) - WHERE obj ISA WEAPON - ELSE "That's not something you can fire." - - -ADD TO EVERY OBJECT - VERB fire - CHECK obj IS fireable - ELSE "That's not something you can fire." - AND obj IN hero - ELSE "You are not holding" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You fire" SAY the obj. "into the air." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIRE AT - - --- ============================================================== - - -SYNTAX fire_at = fire (obj1) 'at' (obj2) - WHERE obj1 ISA WEAPON - ELSE "That's not something you can fire." - AND obj2 ISA THING - ELSE "That's not something you can shoot at." - - -ADD TO EVERY OBJECT - VERB fire_at - WHEN obj1 - CHECK obj1 IS fireable - ELSE "That's not something you can fire." - AND obj1 IN hero - ELSE "You don't have" SAY THE obj1. "." - AND obj2 <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - --- another formulation added, to guide players to use the right syntax: - - -SYNTAX fire_at_error = fire 'at' (obj) - WHERE obj ISA THING - ELSE "That's not something you can fire at." - - -ADD TO EVERY THING -VERB fire_at_error - DOES - "Please use the formulation FIRE WEAPON AT OBJECT to fire at something." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIX (mend, repair) - - --- ============================================================== - - -SYNTAX - fix = fix (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB fix - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS broken - ELSE "The" SAY obj. "doesn't need fixing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Please be more specific. How do you intend to fix it?" - END VERB. -END ADD TO. - - -SYNONYMS mend, repair = fix. - - - --- ============================================================== - - ------ FLIP - - --- ============================================================== - - -SYNTAX flip = flip (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can flip." - - -ADD TO EVERY OBJECT - VERB flip - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES ONLY - "That's not something you need to flip." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FOLLOW - - --- ============================================================== - - -SYNTAX follow = follow (obj)! - WHERE obj ISA THING - ELSE "That's not something you can follow." - - -ADD TO EVERY ACTOR - VERB follow - CHECK obj <> hero - ELSE "It doesn't make sense to follow yourself." - AND obj NOT AT hero - ELSE SAY THE obj. "is right here." - AND hero IS NOT sitting - ELSE "It is difficult to follow anybody while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to follow anybody while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj NOT NEAR hero - ELSE "You follow" SAY THE obj. "." - LOCATE hero AT obj. - DOES - "You don't quite know where" SAY THE obj. "went. You must state a direction - where you want to go." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FREE (+ release) - - --- ============================================================== - - -SYNTAX free = free (obj) - WHERE obj ISA THING - ELSE "That's not something you can $v." - - -ADD TO EVERY THING - VERB free - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj <> hero - ELSE "You don't need to be freed at present." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That doesn't need to be $vd." - END VERB. -END ADD TO. - - -SYNONYMS release = free. - - - --- ============================================================== - - ------- GET OFF - - --- ============================================================== - - -SYNTAX get_off = get off (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can get off." - - -ADD TO EVERY OBJECT - VERB get_off - DOES - IF hero IS sitting OR hero IS lying_down - THEN "You get off" SAY THE obj. "." - MAKE hero NOT lying_down. - MAKE hero NOT sitting. - ELSE "You're standing up already." - END IF. - END VERB. -END ADD TO. - - --- ============================================================== - - ------- GET UP - - --- ============================================================== - - -SYNTAX get_up = get up. - - -VERB get_up - DOES - IF hero IS sitting - THEN "You stand up." - MAKE hero NOT sitting. - ELSIF hero IS lying_down - THEN "You get up." - MAKE hero NOT lying_down. - ELSE "You're standing up already." - END IF. -END VERB. - - - --- ============================================================== - - ------ GIVE (+ hand, offer) - - --- ============================================================== - - -SYNTAX give = 'give' (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only give away objects." - AND obj2 ISA ACTOR - ELSE "That's not something you can give things to." - - - give = give (obj2) (obj1). - - -ADD TO EVERY OBJECT - VERB give - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to give something to itself." - AND obj2 IS reachable - ELSE SAY THE obj2. "is too far away." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 <> hero - ELSE "It doesn't make sense to give something to yourself." - AND obj1 NOT IN obj2 - ELSE SAY THE obj2. "already has" SAY THE obj1. "." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - "You give" SAY THE obj1. "to" SAY THE obj2. "." - LOCATE obj1 IN obj2. - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE - "You give" SAY THE obj1. "to" SAY THE obj2. "." - LOCATE obj1 IN obj2. - END IF. - END VERB. -END ADD TO. - - -SYNONYMS hand, offer = give. - - - --- ============================================================== - - ------ GO TO - - --- ============================================================== - - -SYNTAX go_to = 'to' (obj)! -- because 'go' is predefined in the parser, it can't be used - WHERE obj ISA THING -- in verb definitions - ELSE "It's not possible to go to that." - - -ADD TO EVERY THING - VERB go_to - CHECK obj <> hero - ELSE "You're right here!" - AND hero IS NOT sitting - ELSE "It is difficult to go anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to go anywhere while lying down." - DOES - IF obj AT hero - THEN - IF obj IS NOT reachable - THEN "You can't reach" SAY THE obj. "from here." - ELSE - IF CURRENT LOCATION IS lit - THEN "That's right here!" - ELSE "It is too dark to see." - END IF. - END IF. - ELSE "You can't see" SAY THE obj. "anywhere nearby. You must state a - direction where you want to go." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS walk = go. -- here we define a synonym for the predefined parser word 'go' - -- which is not visible in the syntax itself. - -- Thus, you will be able to say e.g. both 'go to shop' and 'walk to shop' - -- (as well as e.g. 'go east' and 'walk east'). - - - --- ============================================================== - - ------ HELP -> see ABOUT - - --- ============================================================== - - - - - --- ============================================================== - - ------ HINT (+ hints) - - --- ============================================================== - - -SYNTAX hint = hint. - - -VERB hint - DOES - "Unfortunately hints are not available in this game." -END VERB. - - -SYNONYMS - hints = hint. - - - --- ============================================================== - - ------ INVENTORY (+ i, inv) - - --- ============================================================== - - -ADD TO EVERY THING - IS weight 0. -END ADD TO THING. - - -ADD TO EVERY ACTOR - IS weight 50. -END ADD TO ACTOR. - - -ADD TO EVERY OBJECT - IS weight 5. -END ADD TO OBJECT. - - -SYNTAX i = i. - - -VERB i - DOES - LIST hero. - - IF COUNT IN worn > 0 -- see the file 'classes.i', subclass 'clothing' - THEN LIST worn. - END IF. - - -- if the hero in your game carries any containers you want the contents of - -- to be listed after 'inventory', you should manually add the listing right here - -- according to the following example: - -- - -- IF bag IN hero - -- THEN LIST bag. - -- END IF. - -- - -- This way, 'inventory' will yield e.g. "You are carrying a bag. The bag contains a book." - -- If you live the above addition out, the outcome will be just "You are carrying a bag.", with - -- no comment on what is inside the bag. - -END VERB. - - -SYNONYMS inv, inventory = i. - - - --- ============================================================== - - ------ JUMP - - --- ============================================================== - - -SYNTAX jump = jump. - - -VERB jump - CHECK hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "You jump on the spot, to no avail." -END VERB. - - - --- ============================================================== - - ------ JUMP IN - - --- ============================================================== - - -SYNTAX jump_in = jump 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can jump into." - AND obj ISA CONTAINER - ELSE "That's not something you can jump into." - - -ADD TO EVERY OBJECT - VERB jump_in - CHECK obj IS reachable - ELSE SAY THE obj. "is too far away." - AND CURRENT LOCATION IS lit - ELSE "It's too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - IF obj ISA SUPPORTER - THEN "That's not something you can jump into." - ELSE "That wouldn't accomplish anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ JUMP ON - - --- ============================================================== - - -SYNTAX jump_on = jump 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can jump on." - AND obj ISA SUPPORTER - ELSE "That's not something you can jump on." - - -ADD TO EVERY OBJECT - VERB jump_on - CHECK obj IS reachable - ELSE SAY THE obj. "is too far away." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL (+ murder) - - --- ============================================================== - - -SYNTAX kill = kill (obj) - WHERE obj ISA ACTOR - ELSE "That's not something you can $v." - - -ADD TO EVERY ACTOR - VERB kill - CHECK obj <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL WITH - - --- ============================================================== - - -SYNTAX kill_with = kill (obj1) 'with' (obj2) - WHERE obj1 ISA ACTOR - ELSE "That's not something you can $v." - AND obj2 ISA WEAPON - ELSE "You cannot kill anybody with" SAY THE obj2. "." - - -ADD TO EVERY ACTOR - VERB kill_with - WHEN obj1 - CHECK obj1 <> hero - ELSE "There's no need to be that desperate." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ KISS (+ hug, embrace) - - --- ============================================================== - - -SYNTAX kiss = kiss (obj) - WHERE obj ISA THING - ELSE "That's not something you can kiss." - - -ADD TO EVERY THING - VERB kiss - CHECK obj IS examinable - ELSE "That's not something you can kiss." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj <> hero - ELSE "There is no time for that now." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj ISA ACTOR - THEN SAY THE obj. "avoids your advances." - ELSE "Nothing much would be achieved by that." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS hug, embrace = kiss. - - - --- ============================================================== - - ------ KNOCK - - --- ============================================================== - - -SYNTAX knock = knock 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can knock on." - - - knock = knock (obj). - - -ADD TO EVERY OBJECT - VERB knock - CHECK obj IS examinable - ELSE "That's not something you can knock on." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You knock on" SAY THE obj. "$$. Nothing happens." - END VERB. -END ADD TO. - - ---- another 'knock' formulation added to guide players to use the right phrasing: - - -SYNTAX knock_error = knock. - - -VERB knock_error - DOES - "Please use the formulation KNOCK ON OBJECT to knock on something." -END VERB. - - - --- ============================================================== - - ------ LIE DOWN - - --- ============================================================== - - -SYNTAX lie_down = lie 'down'. - - - lie_down = lie. - - -VERB lie_down - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down right now." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down." - -- MAKE hero lying_down. -END VERB. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE IN - - --- ============================================================== - - -SYNTAX lie_in = lie 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can lie in." - AND obj ISA CONTAINER - ELSE "That's not something you can lie in." - - - lie_in = lie 'down' 'in' (obj). - - -ADD TO EVERY OBJECT - VERB lie_in - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down in" SAY THE obj. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down in" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - --- ============================================================== - - ------ LIE ON - - --- ============================================================== - - -SYNTAX lie_on = lie 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can lie on." - - - lie_on = lie 'down' 'on' (obj). - - -ADD TO EVERY OBJECT - VERB lie_on - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down on" SAY THE obj. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down on" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIFT - - --- ============================================================== - - -SYNTAX lift = lift (obj) - WHERE obj ISA THING - ELSE "That's not something you can lift." - - -ADD TO EVERY THING - VERB lift - CHECK obj IS examinable - ELSE "That's not something you can lift." - AND obj IS reachable - ELSE "The object is too far away." - AND obj IS movable - ELSE "That's not something you can lift." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND obj <> hero - ELSE "It doesn't make sense to lift yourself." - AND obj NOT IN hero - ELSE "You're already holding" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LIGHT (+ lit) - - --- ============================================================== - - -SYNTAX light = light (obj) - WHERE obj ISA LIGHTSOURCE - ELSE "That's not something you can lit." - - -ADD TO EVERY OBJECT - VERB light - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You don't have anything to light" SAY THE obj. "with." - END VERB. -END ADD TO. - - -SYNONYMS lit = light. - - - --- ============================================================== - - ------ LISTEN - - --- ============================================================== - - -SYNTAX listen0 = listen. - - -VERB listen0 - DOES - "You hear nothing unusual." -END VERB. - - - --- ============================================================== - - ------ LISTEN TO - - --- ============================================================== - - -SYNTAX listen = listen 'to' (obj)! - WHERE obj ISA THING - ELSE "That's not something you can listen to." - - -ADD TO EVERY THING - VERB listen - CHECK obj <> hero - ELSE "It doesn't make sense to listen to yourself." - DOES - IF obj AT hero - THEN "You hear nothing unusual." - ELSIF obj NEAR hero - THEN "You can't hear" SAY THE obj. "very well from here." - ELSE "You can't hear anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK - - --- ============================================================== - - -SYNTAX lock = lock (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can lock." - - -ADD TO EVERY OBJECT - VERB lock - CHECK obj IS lockable - ELSE "That's not something you can lock." - AND obj IS NOT locked - ELSE "It's already locked." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You have to state what you want to lock" SAY THE obj. "with." - -- If you need this to work, use the following lines instead: - -- MAKE obj locked. "You" - -- IF obj IS NOT closed - -- THEN "close and" - -- MAKE obj closed. - -- END IF. - -- "lock" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK WITH - - --- ============================================================== - - -SYNTAX lock_with = lock (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can lock." - AND obj2 ISA OBJECT - ELSE "You can't lock anything with that." - - -ADD TO EVERY OBJECT - VERB lock_with - WHEN obj1 - CHECK obj1 IS lockable - ELSE "That's not something you can lock." - AND obj1 IS NOT locked - ELSE "It's already locked." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IN hero - ELSE - "You don't have" SAY THE obj2. "." - DOES - "You can't lock" SAY THE obj1. "with" SAY THE obj2. "." - -- If you need this to work, use the following lines instead: - -- MAKE obj1 locked. "You" - -- IF obj1 IS NOT closed - -- THEN "close and" - -- MAKE obj1 closed. - -- END IF. - -- "lock" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK - - --- ============================================================== - - -SYNTAX 'look' = 'look'. - - -VERB 'look' - DOES - LOOK. -END VERB. - - -SYNONYMS l = 'look'. - - - --- ============================================================== - - ------ LOOK AT -> see EXAMINE - - --- ============================================================== - - - - - --- ============================================================== - - ------ LOOK BEHIND - - --- ============================================================== - - -SYNTAX look_behind = 'look' behind (obj) - WHERE obj ISA THING - ELSE "You can't look behind that." - - -ADD TO EVERY THING - VERB look_behind - CHECK obj IS examinable - ELSE - "You can't look behind" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj <> hero - ELSE "Turning your head, you notice nothing unusual behind yourself." - DOES - "You notice nothing unusual behind" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK IN - - --- ============================================================== - - -SYNTAX - look_in = 'look' 'in' (obj) - WHERE obj ISA OBJECT - ELSE "You can't look inside" SAY THE obj. "." - AND obj ISA CONTAINER - ELSE "You can't look inside" SAY THE obj. "." - - -ADD TO EVERY OBJECT - VERB look_in - CHECK obj IS examinable - ELSE - "You can't look inside" SAY THE obj. "." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj ISA LIQUID - THEN - IF COUNT ISA THING, IN obj > 0 - THEN LIST obj. - ELSE "There is nothing in" SAY THE obj. "." - END IF. - ELSE LIST obj. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK OUT OF - - --- ============================================================== - - -SYNTAX look_out_of = 'look' 'out' 'of' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can look out of." - - -ADD TO EVERY OBJECT - VERB look_out_of - CHECK obj IS examinable - ELSE - "You can't look out of" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That's not something you can look out of." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK THROUGH - - --- ============================================================== - - -SYNTAX look_through = 'look' through (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can look through." - - -ADD TO EVERY OBJECT - VERB look_through - CHECK obj IS examinable - ELSE - "You can't look through" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't see through" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UNDER - - --- ============================================================== - - -SYNTAX look_under = 'look' under (obj) - WHERE obj ISA THING - ELSE "You can't look under that." - - -ADD TO EVERY THING - VERB look_under - CHECK obj IS examinable - ELSE "You can't look under" SAY THE obj. "." - AND obj <> hero - ELSE "It doesn't make sense to look under yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You notice nothing unusual under" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UP (-> see also CONSULT) - - --- ============================================================== - - -SYNTAX look_up = 'look' up. - - -VERB look_up - DOES "Looking up, you see nothing unusual." -END VERB. - - - --- ============================================================== - - ------ NO - - --- ============================================================== - - -SYNTAX 'no' = 'no'. - - -VERB 'no' - DOES "You sound rather negative." -END VERB. - - - --- ============================================================== - - ------ OPEN - - --- ============================================================== - - -SYNTAX open = open (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can open." - - -ADD TO EVERY OBJECT - VERB open - CHECK obj IS closeable - ELSE "That's not something you can open." - AND obj IS closed - ELSE "It's already open." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS NOT locked - ELSE SAY THE obj. "appears to be locked." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - MAKE obj NOT closed. - "You open" SAY THE obj. - IF obj ISA LISTABLE_CONTAINER - THEN "and look into it" - END IF. - "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ OPEN WITH - - --- ============================================================== - - -SYNTAX open_with = open (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can open." - AND obj2 ISA OBJECT - ELSE "You can't open anything with" SAY THE obj2. - - -ADD TO EVERY OBJECT - VERB open_with - WHEN obj1 - CHECK obj1 IS closeable - ELSE "That's not something you can open." - AND obj1 IS closed - ELSE SAY THE obj1. "is already open." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj1 IS NOT locked - ELSE SAY THE obj1. "appears to be locked." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't open" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY - - --- ============================================================== - - -SYNTAX 'play' = 'play' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can play." - - -ADD TO EVERY OBJECT - VERB 'play' - DOES - "That's not something you can play." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY WITH - - --- ============================================================== - - -SYNTAX play_with = 'play' 'with' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can play with." - - -ADD TO EVERY OBJECT - VERB play_with - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "After second thoughts you don't find it purposeful to start playing with" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR - - --- ============================================================== - - --- The verbs 'pour' and 'empty' work a bit differently from each other. --- You can both pour and empty a container object and its contents will be --- emptied in (on the floor or on the ground of) the current location if you don't --- specify anything else. --- However, as far as liquids are concerned, you can only pour liquids --- but not empty them - it is only possible to empty container objects. --- This entails that if there is for example a bottle in your game that contains some water, both --- --- 'pour bottle' AND 'pour water' have the same effect in the game, --- --- whereas it is only possible to say --- --- 'empty bottle' but NOT 'empty water'. --- --- If you wish to change this, tweak these two verbs as you see fit for your purposes --- (for example, delete one of the verbs altogether and make it a synonym of the other one). - - -SYNTAX pour = pour (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can pour." - AND obj ISA CONTAINER - ELSE "That's not something you can pour." - - -ADD TO EVERY OBJECT - VERB pour - CHECK obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND COUNT ISA OBJECT, IN obj > 0 - ELSE "There's nothing in" SAY THE obj. "." - DOES - IF obj NOT IN hero - THEN - IF obj IS takeable - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - "You pour" SAY THE obj. - IF floor HERE - THEN "on the floor" - ELSE "on the ground" - END IF. - "here." - END IF. - ELSE - "You pour" SAY THE obj. - IF floor HERE - THEN "on the floor" - ELSE "on the ground" - END IF. - "here." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR IN - - --- ============================================================== - - -SYNTAX pour_in = pour (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pour." - AND obj1 ISA CONTAINER -- only (the contents of) a container object can be poured into something - ELSE "That's not something you can pour." - AND obj2 ISA OBJECT - ELSE "Pouring" SAY THE obj1. "into" SAY THE obj2. "is not possible." - AND obj2 ISA CONTAINER - ELSE "You can't pour anything into that." - - -ADD TO EVERY OBJECT - VERB pour_in - WHEN obj1 - CHECK obj1 NOT IN obj2 - ELSE SAY THE obj1. "is already in" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to pour something into itself." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS NOT closed - ELSE "You can't, since the" SAY THE obj2. "is closed." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - "It would serve no purpose to pour" SAY THE obj1. "into" SAY THE obj2. "." - -- If you need to make this work, use the following lines instead: - -- "You pour" SAY THE obj1. "into" SAY THE obj2. "." - -- IF obj1 ISA LIQUID - -- THEN LOCATE obj1 IN obj2. - -- ELSE EMPTY obj1 IN obj2. - -- END IF. - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE "It would serve no purpose to pour" SAY THE obj1. "into" SAY THE obj2. "." - -- If you need to make this work, use the following lines instead: - -- "You pour" SAY THE obj1. "into" SAY THE obj2. "." - -- IF obj1 ISA LIQUID - -- THEN LOCATE obj1 IN obj2. - -- ELSE EMPTY obj1 IN obj2. - -- END IF. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR ON - - --- ============================================================== - - -SYNTAX pour_on = pour (obj1) 'on' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pour." - AND obj1 ISA CONTAINER -- only (the contents of) a container object can be poured in something - ELSE "That's not something you can pour." - AND obj2 ISA THING - ELSE "You can't pour anything onto that." - - -ADD TO EVERY OBJECT -VERB pour_on - WHEN obj1 - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 <> hero - ELSE "That wouldn't make sense." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - "It would serve no purpose to pour" SAY THE obj1. "on" SAY THE obj2. "." - -- (or, to make it work, use the following lines instead of the above: - -- "You pour" SAY THE obj1. "on" SAY THE obj2. ". Nothing special happens." - -- IF obj1 ISA LIQUID - -- THEN LOCATE obj1 AT hero. - -- ELSE EMPTY obj1 AT hero. - -- END IF. - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE "It would serve no purpose to pour" SAY THE obj1. "on" SAY THE obj2. "." - -- (or, to make it work, use the following lines instead of the above: - -- "You pour" SAY THE obj1. "on" SAY THE obj2. ". Nothing special happens." - -- IF obj1 ISA LIQUID - -- THEN LOCATE obj1 AT hero. - -- ELSE EMPTY obj1 AT hero. - -- END IF. - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PRAY - - --- ============================================================== - - -SYNTAX pray = pray. - - -VERB pray - DOES "Your prayers don't seem to help right now." -END VERB. - - - --- ============================================================== - - ------ PRY - - --- ============================================================== - - -SYNTAX pry = pry (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can pry." - - -ADD TO EVERY OBJECT -VERB pry - DOES "You must state what you want to pry" SAY THE obj. "with." -END VERB. -END ADD TO. - - --- ============================================================== - - ------ PRY_WITH - - --- ============================================================== - - -SYNTAX pry_with = pry (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pry." - AND obj2 ISA OBJECT - ELSE "You can't pry anything with that." - - -ADD TO EVERY OBJECT -VERB pry_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can pry." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. - AND obj1 <> obj2 - ELSE "How intelligent." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That doesn't work." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PULL - - --- ============================================================== - - -SYNTAX pull = pull (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense to pull yourself." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE "That's not something you can pull." - END IF. - - -ADD TO EVERY OBJECT -VERB pull - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS movable - ELSE "It's not possible to pull" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "That wouldn't accomplish anything." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUSH - - --- ============================================================== - - -SYNTAX push = push (obj) - WHERE obj ISA THING - ELSE "That's not something you can push." - - -ADD TO EVERY OBJECT - VERB PUSH - CHECK obj IS movable - ELSE "That's not something you can push." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj NOT IN hero - ELSE "But you're holding" SAY THE obj. "." - AND obj <> hero - ELSE "It doesn't make sense to push yourself." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You give" SAY THE obj. "a little push. Nothing happens." - END VERB. -END ADD TO. - - -SYNONYMS press = push. - - - --- ============================================================== - - ------ PUSH WITH - - --- ============================================================== - - -SYNTAX push_with = push (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can push." - AND obj2 ISA OBJECT - ELSE "You can use only objects to push things with." - - -ADD TO EVERY OBJECT - VERB push_with - WHEN obj1 - CHECK obj1 IS movable - ELSE "That's not something you can push." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj1 NOT IN hero - ELSE "But you're holding" SAY THE obj1. "." - AND obj2 IN hero - ELSE "You're not holding" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to push something with itself." - AND obj1 <> hero - ELSE "It doesn't make sense to push yourself with something." - AND obj1 IS inanimate - ELSE SAY THE obj1. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Using" SAY THE obj2. "you push" SAY THE obj1. "$$. Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT (+ lay, locate, place) - - --- ============================================================== - - -SYNTAX put = put (obj) - WHERE obj ISA OBJECT - ELSE "You can't put that anywhere." - - -ADD TO EVERY OBJECT - VERB put - CHECK obj IN HERO - ELSE "You don't have" SAY THE obj. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You must state where you want to put it." - END VERB. -END ADD TO. - - -SYNONYMS lay, place = put. - - - --- ============================================================== - - ------ PUT DOWN (works as 'drop') - - --- ============================================================== - - ------ The syntax for 'put down' has been declared in the 'drop' verb. - - - - - --- ============================================================== - - ------ PUT IN (+ insert) - - --- ============================================================== - - -SYNTAX put_in = put (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN - IF obj1 = hero - THEN "It doesn't make sense to put yourself into something." - ELSE SAY THE obj1. "wouldn't probably appreciate that." - END IF. - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA OBJECT - ELSE "That's not something you can put things in." - AND obj2 ISA CONTAINER - ELSE "You can't put anything there." - - - put_in = insert (obj1) 'in' (obj2). - - -ADD TO EVERY OBJECT - VERB put_in - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to put something into itself." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 NOT IN obj2 - ELSE - IF obj2 ISA SUPPORTER - THEN "You can't put" SAY THE obj1. "inside" SAY THE obj2. "." - ELSE SAY THE obj1. "is in" SAY THE obj2. "already." - END IF. - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN obj2. - "You put" SAY THE obj1. "into" SAY THE obj2. "." - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE - LOCATE obj1 IN obj2. - "You put" SAY THE obj1. "into" SAY THE obj2. "." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT BEHIND, NEAR, UNDER - - --- ============================================================== - - -SYNTAX put_near = put (obj1) 'near' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything near that." - - - put_behind = put (obj1) behind (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything behind that." - - - put_under = put (obj1) under (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything under that." - - -ADD TO EVERY OBJECT - VERB put_near, put_behind, put_under - WHEN obj1 - CHECK obj2 NOT IN hero - ELSE - "That would be futile." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 <> obj2 - ELSE "That doesn't make sense." - AND obj2 <> hero - ELSE "That would be futile." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - "That wouldn't accomplish anything." - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE "That wouldn't accomplish anything." - - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT_ON - - --- ============================================================== - - --- to use this verb in the meaning 'wear', see the file 'classes.i', subclass 'clothing', verb 'wear'. - - -SYNTAX put_on = put (obj1) 'on' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't well put anything on that." - AND obj2 ISA SUPPORTER - ELSE "You can't well put anything on that." - - -ADD TO EVERY OBJECT - VERB put_on - WHEN obj1 - CHECK obj2 NOT IN hero - ELSE - "That would be futile." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 <> obj2 - ELSE "That doesn't make sense." - AND obj2 <> hero - ELSE "That would be futile." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is on" SAY THE obj2. "already." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN obj2. - "You put" SAY THE obj1. "on" SAY THE obj2. "." - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE - LOCATE obj1 IN obj2. - "You put" SAY THE obj1. "on" SAY THE obj2. "." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT OUT (works as -> EXTINGUISH) - - --- ============================================================== - - ------ The syntax for 'put out' has been declared in the 'extinguish' verb. - - - --- ============================================================== - - ------ QUIT - - --- ============================================================== - - -SYNTAX - 'quit' = 'quit'. - - -VERB 'quit' - DOES - QUIT. -END VERB. - - -SYNONYMS q = 'quit'. - - - --- ============================================================== - - ------ READ - - --- ============================================================== - - -SYNTAX read = read (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can read." - - -ADD TO EVERY OBJECT - VERB read - CHECK obj IS examinable - ELSE "That's not something you can read." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND obj IS readable - ELSE - "There is nothing written on" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF text OF obj = "" - THEN "There's nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. ". It says ""$$" SAY text OF obj. "$$""." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - --- REMOVE - - --- ============================================================== - - --- see the file 'classes.i', subclass 'clothing' for the definition of --- this verb - - - - - --- ============================================================== - - ------ REMOVE FROM ( => TAKE FROM) - - --- ============================================================== - - ------ this verb works as 'take from' - - - --- ============================================================== - - ------ RESTART - - --- ============================================================== - - -SYNTAX 'restart' = 'restart'. - - -VERB 'restart' - DOES - RESTART. -END VERB. - - - --- ============================================================== - - ------ RESTORE - - --- ============================================================== - - -SYNTAX 'restore' = 'restore'. - - -VERB 'restore' - DOES - RESTORE. -END VERB. - - - --- ============================================================== - - ------ RUB (+ massage) - - --- ============================================================== - - -SYNTAX rub = rub (obj) - WHERE obj ISA THING - ELSE "That's not something you can rub." - - -ADD TO EVERY THING - VERB rub - CHECK obj IS examinable - ELSE "That's not something you can rub." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj <> hero - ELSE "There's no time for that now." - AND obj IS inanimate - ELSE "You aren't sure whether" SAY THE obj. "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS massage = rub. - - - --- ============================================================== - - ------ SAVE - - --- ============================================================== - - -SYNTAX 'save' = 'save'. - - -VERB 'save' - DOES - SAVE. -END VERB. - - - --- ============================================================== - - ------ SAY - - --- ============================================================== - - -SYNTAX 'say' = 'say' (str) - WHERE str ISA STRING - ELSE "That's not something you can say." - - -ADD TO EVERY THING - VERB 'say' - DOES - "You utter" SAY str. "$$. Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SAY TO - - --- ============================================================== - - -SYNTAX say_to = 'say' (str) 'to' (act) - WHERE str ISA STRING - ELSE "Nothing happens." - AND act ISA ACTOR - ELSE "That's not something you can talk to." - - -ADD TO EVERY THING - VERB say_to - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act IS reachable - ELSE SAY THE act. "is too far away." - DOES - SAY THE act. "doesn't seem interested." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SCORE - - --- ============================================================== - - -SYNTAX 'score' = 'score'. - - -VERB 'score' - DOES - SCORE. - -- (or, if you wish to disable the score, use the following kind of - -- line instead of the above:) - -- "There is no score in this game." -END VERB 'score'. - - - --- ============================================================== - - ------ SCRATCH - - --- ============================================================== - - -SYNTAX scratch = scratch (obj) - WHERE obj ISA THING - ELSE "That's not something you can scratch." - - -ADD TO EVERY THING - VERB scratch - CHECK obj IS examinable - ELSE "That's not something you can scratch." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj <> hero - ELSE "That wouldn't help matters." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------- SEARCH - - --- ============================================================== - - -SYNTAX search = search (obj) - WHERE obj ISA THING - ELSE "That's not something you can search." - - -ADD TO EVERY THING - VERB search - CHECK obj <> hero - ELSE LIST hero. - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "You can't see anything in the dark." - DOES - "You find nothing of interest." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SELL - - --- ============================================================== - - -SYNTAX sell = sell (obj) - WHERE obj ISA THING - ELSE "That's not something you can sell." - - -ADD TO EVERY THING - VERB sell - CHECK obj IS examinable - ELSE "That's not something you can sell." - AND obj <> hero - ELSE "It doesn't make sense to sell yourself." - DOES - "There's nobody here who would be interested to buy" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHAKE - - --- ============================================================== - - -SYNTAX shake = shake (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense to shake yourself." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE "That's not something you can shake." - END IF. - - -ADD TO EVERY OBJECT -VERB shake - CHECK obj IS examinable - ELSE "That's not something you can shake." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS movable - ELSE "Shaking" SAY THE obj. "is not possible." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj IN hero - THEN "You shake" SAY THE obj. "cautiously in your hands. Nothing happens." - ELSE "There is no reason to start shaking" SAY THE obj. "." - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOOT - - --- ============================================================== - - --- this verb is interpreted as 'incomplete', guiding the player to use the formulation --- 'shoot THING with WEAPON' - - -SYNTAX shoot = shoot (obj) - WHERE obj ISA THING - ELSE "That's not something you can shoot." - shoot = shoot 'at' (obj). - -ADD TO EVERY THING - VERB shoot - CHECK obj <> hero - ELSE "There's no need to be that desperate." - DOES - "To shoot something, use the formulation SHOOT THING WITH WEAPON." - END VERB. -END ADD TO. - - --- another incomplete 'shoot' formulation added, to guide players to use the right phrasing: - - -SYNTAX shoot_error = shoot. - - -VERB shoot_error - DOES "You must state what you want to shoot, e.g. SHOOT BEAR WITH RIFLE." -END VERB. - - - --- ============================================================== - - ------ SHOOT WITH - - --- ============================================================== - - -SYNTAX shoot_with = shoot (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can shoot." - AND obj2 ISA WEAPON - ELSE "That's not something you can shoot with." - - shoot_with = shoot (obj2) 'at' (obj1). - -- to count for player input such as 'shoot rifle at bear' - - -ADD TO EVERY THING - VERB shoot_with - WHEN obj1 - CHECK obj2 IN hero - ELSE "You are not carrying" SAY THE obj2. "." - AND obj1 IS examinable - ELSE "That's not something you can shoot." - AND obj1 <> hero - ELSE "There's no need to be that desperate." - AND obj1 <> obj2 - ELSE "It doesn't make sense to shoot something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOUT - - --- ============================================================== - - -SYNTAX shout = shout. - - -VERB shout - DOES - "Nothing results from your $ving." -END VERB. - - -SYNONYMS scream, yell = shout. - - - --- ============================================================== - - ------ SHOW - - --- ============================================================== - - -SYNTAX 'show' = 'show' (obj1) 'to' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can show." - AND obj2 ISA ACTOR - ELSE "That's not something you can show things to." - - -ADD TO EVERY THING - VERB 'show' - WHEN obj1 - CHECK obj2 <> hero - ELSE "It doesn't make sense to show something to yourself." - AND obj1 <> obj2 - ELSE "It doesn't make sense to show something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - SAY THE obj2. "is not especially interested." - END VERB. -END ADD TO. - - -SYNONYMS reveal = 'show'. - - - --- ============================================================== - - ------ SING (+ hum, whistle) - - --- ============================================================== - - -SYNTAX sing = sing. - - -VERB sing - DOES - "You $v a little tune." -END VERB. - - -SYNONYMS hum, whistle = sing. - - - --- ============================================================== - - ------ SIP - - --- ============================================================== - - -SYNTAX sip = sip (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can drink." - - -ADD TO EVERY OBJECT - VERB sip - CHECK obj IS drinkable - ELSE "That's not something you can drink." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj NOT IN hero - THEN - IF obj IS takeable - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - "You take a sip of" SAY THE obj. "$$. It tastes rather good." - ELSE "You don't have" SAY THE obj. "." - END IF. - ELSE - "You take a sip of" SAY THE obj. "$$. It tastes rather good." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SIT - - --- ============================================================== - - -SYNTAX sit = sit. - - - sit = sit 'down'. - - -VERB sit - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - DOES - "You feel no urge to sit down at present." - -- (or, if you wish to make it work, use the following instead of the above: - -- "You sit down." - -- MAKE hero sitting. -END VERB. - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SIT_ON - - --- ============================================================== - - -SYNTAX sit_on = sit 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can sit on." - - -ADD TO EVERY SUPPORTER - VERB sit_on - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - DOES - "You feel no urge to sit down at present." - -- (or, to make it work, use the following instead of the above:) - -- "You sit down on" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero sitting. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SLEEP (+ rest) - - --- ============================================================== - - -SYNTAX sleep = sleep. - - -VERB sleep - DOES - "There's no need to $v right now." -END VERB. - - -SYNONYMS rest = sleep. - - - --- ============================================================== - - ------ SMELL (smell0) - - --- ============================================================== - - -SYNTAX smell0 = smell. - - -VERB smell0 - DOES - "You smell nothing unusual." -END VERB. - - - --- ============================================================== - - ------ SMELL (+ obj) - - --- ============================================================== - - -SYNTAX smell = smell (obj)! - WHERE obj ISA THING - ELSE "That's not something you can smell." - - -ADD TO EVERY THING - VERB smell - DOES - IF obj ISA SOUND - THEN "That's not something you can smell." - ELSE "You smell nothing unusual." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SQUEEZE - - --- ============================================================== - - -SYNTAX squeeze = squeeze (obj) - WHERE obj ISA THING - ELSE "That's not something you can squeeze." - - -ADD TO EVERY THING - VERB squeeze - CHECK obj IS examinable - ELSE "That's not something you can squeeze." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE - IF obj = hero - THEN "Nothing would be achieved by that." - ELSE "It is too dark to see." - END IF. - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ STAND - - --- ============================================================== - - -SYNTAX stand = stand. - - - stand = stand 'up'. - - -VERB stand - CHECK hero IS NOT lying_down - ELSE "You get up." - MAKE hero NOT lying_down. - AND hero IS NOT sitting - ELSE "You stand up." - MAKE hero NOT sitting. - DOES - "You're standing up already." -END VERB. - - - --- ============================================================== - - ------ STAND_ON - - --- ============================================================== - - -SYNTAX stand_on = stand 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can stand on." - - - stand_on = get 'on' (obj). - - -ADD TO EVERY SUPPORTER -VERB stand_on - DOES - "You feel no urge to stand on" SAY THE obj. "." - -- or, to make it work, use the following instead of the above: - -- "You get on" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero NOT sitting. MAKE hero NOT lying_down. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWIM - - --- ============================================================== - - -SYNTAX swim = swim. - - -VERB swim - CHECK hero IS NOT sitting - ELSE "It is difficult to try swimming while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to try swimming while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ SWIM IN - - --- ============================================================== - - -SYNTAX swim_in = swim 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can swim in." - AND obj ISA CONTAINER - ELSE "That's not something you can swim in." - - -ADD TO EVERY OBJECT -VERB swim_in - CHECK hero IS NOT sitting - ELSE "It is difficult to swim anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to swim anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That's not something you can swim in." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH ON - - --- ============================================================== - - ------ The syntax for 'switch on' has been declared in the 'turn_on' verb. - - - - --- ============================================================== - - ------ SWITCH OFF - - --- ============================================================== - - ------ The syntax for 'switch off' has been declared in the 'turn_off' verb. - - - - --- ============================================================== - - ------ TAKE (+ carry, get, grab, hold, obtain, pick up) - - --- ============================================================== - - -SYNTAX take = take (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "Taking yourself is not possible." - ELSE SAY THE obj. "would probably object to that." - END IF. - ELSE "That's not something you can take." - END IF. - - - take = get (obj). - - - take = pick up (obj). - - - take = pick (obj) up. - - -ADD TO EVERY OBJECT - VERB take - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS takeable - ELSE - IF obj ISA SCENERY - THEN "You deem" SAY THE obj. "as not important for your purposes and leave it where it is." - ELSE "That's not something you can take." - END IF. - AND obj IS movable - ELSE SAY THE obj. "is much too heavy for you to move." - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - AND weight Of obj <=50 - ELSE SAY THE obj. "is too heavy to lift." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj DIRECTLY IN hero --| This distinction is made in order to - THEN "You already have" SAY THE obj. "." --| cover cases where the hero wants to take - ELSIF obj IN hero --| something out of a container (s)he's carrying. - THEN "Taken." --| I.e. the 'directly' checks that the hero is not carrying - LOCATE obj IN hero. --| the object in her/his hands already; the first 'elsif' - --| here allows e.g. a wallet to be taken out of a jacket - --| that the hero is carrying in her/his hands. - ELSIF obj IN worn -- i.e. the object to be taken is a piece of clothing that the player character is wearing; - -- here, this verb works in practise like 'take off'. - THEN "You take off" SAY THE obj. "and carry it in your hands." - LOCATE obj IN hero. - ELSE "Taken." - LOCATE obj IN hero. - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - carry, grab, hold, obtain = take. - - - --- ============================================================== - - ------ TAKE FROM - - --- ============================================================== - - -SYNTAX take_from = 'take' (obj1) 'from' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only take objects." - AND obj2 ISA THING - ELSE "It's not possible to take things from there." - AND obj2 ISA CONTAINER - ELSE "It's not possible to take things from there." - - - take_from = remove (obj1)* 'from' (obj2). - - - take_from = get (obj1) 'from' (obj2). - - -ADD TO EVERY OBJECT - VERB take_from - WHEN obj1 - CHECK obj2 <> hero - ELSE "You can't take things from yourself!" - AND obj1 NOT IN hero - ELSE "You already have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "You can't take something from itself!" - AND obj1 IN obj2 - ELSE - IF obj2 IS inanimate - THEN SAY THE obj1. "is not there." - ELSE SAY THE obj2. "doesn't have" SAY THE obj1. "." - END IF. - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - AND obj1 IS takeable - ELSE - IF obj1 ISA SCENERY - THEN "You deem" SAY THE obj1. "as not important for your purposes and leave it where it is." - ELSE "That's not something you can take." - END IF. - AND obj1 IS movable - ELSE SAY THE obj1. "is much too heavy for you to take." - AND weight Of obj1 <=50 - ELSE SAY THE obj1. "is too heavy." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - LOCATE obj1 IN hero. - "You take" SAY THE obj1. "from" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TALK - - --- ============================================================== - - -SYNTAX talk = talk. - - -VERB talk - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING - or TELL PERSON ABOUT THING." -END VERB. - - - --- ============================================================== - - ------ TALK_TO - - --- ============================================================== - - -SYNTAX talk_to = talk 'to' (act) - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - - -ADD TO EVERY THING - VERB talk_to - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - -SYNTAX talk_to_a = talk 'to' (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That's not something you can talk about." - - -ADD TO EVERY THING - VERB talk_to_a - WHEN act - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - --- ============================================================== - - ------ TASTE (+ lick) - - --- ============================================================== - - -SYNTAX taste = taste (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can taste." - - -ADD TO EVERY OBJECT - VERB taste - CHECK obj IS examinable - ELSE "That's not something you can taste." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You taste nothing unexpected." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TEAR (+ rip) - - --- ============================================================== - - -SYNTAX tear = tear (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can tear." - - -ADD TO EVERY OBJECT - VERB tear - CHECK obj IS examinable - ELSE "That's not something you can tear." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be futile." - END VERB. -END ADD TO. - - -SYNONYMS rip = tear. - - - --- ============================================================== - - ------ TELL (+ enlighten, inform) - - --- ============================================================== - - -SYNTAX tell = tell (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That doesn't seem to be something you can talk about with" SAY THE act. "." - - -ADD TO EVERY THING - VERB tell - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act IS reachable - ELSE SAY THE act. "is too far away." - AND act <> hero - ELSE "It doesn't make much sense to tell yourself about something." - DOES - IF topic IN act - THEN SAY THE act. "doesn't seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. "chooses to be silent." - ELSIF topic = hero - THEN SAY THE act. "doesn't seem interested." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS enlighten, inform = tell. - - - --- ============================================================== - - ------ THINK (+ ponder, meditate, reflect) - - --- ============================================================== - - -SYNTAX think = think. - - -VERB think - DOES - "Nothing helpful comes to your mind." -END VERB. - - -SYNONYMS ponder, meditate, reflect = think. - - - --- ============================================================== - - ------ THINK ABOUT - - --- ============================================================== - - -SYNTAX think_about = think 'about' (obj) - WHERE obj ISA THING - ELSE "That's not something fruitful to think about." - - -ADD TO EVERY THING - VERB think_about - DOES - "Nothing helpful comes to your mind." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW (+ cast) - - --- ============================================================== - - -SYNTAX throw = throw (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can throw." - - -ADD TO EVERY OBJECT - VERB throw - CHECK obj IS examinable - ELSE "That's not something you can throw." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj NOT IN hero - THEN - IF obj IS takeable - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - "You can't throw very far;" SAY THE obj. "ends up on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj HERE. - ELSE "You don't have" SAY THE obj. "." - END IF. - ELSE - "You can't throw very far;" SAY THE obj. "ends up on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj HERE. - - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - cast = throw. - - - --- ============================================================== - - ------ THROW AT (+ throw to) - - --- ============================================================== - - -SYNTAX throw_at = throw (obj1) 'at' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only throw objects." - AND obj2 ISA THING - ELSE "It's not possible to throw things at that." - - - throw_to = throw (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only throw objects." - AND obj2 ISA THING - ELSE "It's not possible to throw things to that." - - -ADD TO EVERY OBJECT - VERB throw_at, throw_to - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can throw." - AND obj2 IS examinable - ELSE "That's not something you can throw things at." - AND obj2 IS reachable - ELSE SAY THE obj2. "is too far away." - AND obj1 <> obj2 - ELSE "It doesn't make sense to throw something at itself." - AND obj2 NOT IN hero - ELSE - "You are carrying" SAY THE obj2. "." - AND obj2 <> hero - ELSE "You cannot throw things at yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - IF obj2 IS inanimate - THEN - "The" SAY obj1. "bounces harmlessly off" - SAY THE obj2. "and ends up on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj1 HERE. - ELSE "The" SAY obj2. "catches" SAY THE obj1. "and tosses" - IF THIS IS NOT plural - THEN "it" - ELSE "them" - END IF. - "back to you. You grab hold of it again." - END IF. - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE - IF obj2 IS inanimate - THEN - SAY THE obj1. "bounces harmlessly off" - SAY THE obj2. "and ends up on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj1 HERE. - ELSE - SAY THE obj2. "catches" SAY THE obj1. "and tosses" - IF THIS IS NOT plural - THEN "it" - ELSE "them" - END IF. - "back to you. You grab hold of" - IF THIS IS NOT plural - THEN "it" - ELSE "them" - END IF. - "again." - END IF. - END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------- THROW IN - - --- ============================================================== - - -SYNTAX throw_in = throw (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can throw." - AND obj2 ISA OBJECT - ELSE "That's not something you can throw things into." - AND obj2 ISA CONTAINER - ELSE "That's not something you can throw things into." - - -ADD TO EVERY OBJECT - VERB throw_in - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can throw." - AND obj2 IS examinable - ELSE "That's not something you can throw things into." - AND obj2 IS reachable - ELSE SAY THE obj2. "is too far away." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is in" SAY THE obj2. "already!" - AND obj1 <> obj2 - ELSE "It doesn't make sense to throw something into itself." - AND obj2 <> hero - ELSE "You can't throw" SAY THE obj1. "into yourself! (If you wish to eat or drink - something, just say so.)" - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY obj1. "first)$n" - LOCATE obj1 IN obj2. - "You throw" SAY THE obj1. "into" SAY THE obj2. "." - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE - LOCATE obj1 IN obj2. - "You throw" SAY THE obj1. "into" SAY THE obj2. "." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE - - --- ============================================================== - - -SYNTAX tie = tie (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can tie." - - -ADD TO EVERY OBJECT - VERB tie - DOES - "You must state where do you want to tie" SAY obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE TO - - --- ============================================================== - - -SYNTAX tie_to = tie (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can tie." - AND obj2 ISA OBJECT - ELSE "Nothing can be tied to that." - - -ADD TO EVERY OBJECT - VERB tie_to - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can tie." - AND obj2 IS examinable - ELSE "That's not something you can tie things to." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 <> obj2 - ELSE "It doesn't make sense to tie something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj1 NOT IN hero - THEN - IF obj1 IS takeable - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - "It's not possible to tie" SAY THE obj1. "to" SAY THE obj2. "." - ELSE "You don't have" SAY THE obj1. "." - END IF. - ELSE "It's not possible to tie" SAY THE obj1. "to" SAY THE obj2. "." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TOUCH - - --- ============================================================== - - -SYNTAX touch = touch (obj) - WHERE obj ISA THING - ELSE "That's not something you can touch." - - -ADD TO EVERY THING - VERB touch - CHECK obj IS examinable - Else "That's not something you can touch." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS inanimate - ELSE "You are not sure whether" SAY THE obj. "would appreciate that." - DOES - "You feel nothing unexpected." - END VERB. -END ADD TO. - - -SYNONYMS feel = touch. - - - --- ============================================================== - - ------ TOUCH WITH - - --- ============================================================== - - -SYNTAX touch_with = touch (obj1) 'with' (obj2) - WHERE obj1 ISA THING - Else "That's not something you can touch." - AND obj2 ISA OBJECT - ELSE "You can only use objects to touch with." - - -ADD TO EVERY THING - VERB touch_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can touch." - AND obj2 IS examinable - ELSE "That's not something you can touch things with." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj1 <> obj2 - ELSE "It doesn't make sense to touch something with itself." - AND obj1 IS inanimate - ELSE "You are not sure whether" SAY THE obj1. "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You touch" SAY THE obj1. "with" SAY THE obj2. ". Nothing special happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN (+ rotate) - - --- ============================================================== - - -SYNTAX turn = turn (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can turn." - - - turn = rotate (obj). -- we don't declare 'rotate' a synonym for 'turn' - -- through a SYNONYMS statement as we don't want - -- it to be possible for the player to type something - -- like 'rotate tv on' (see 'turn on' and 'turn off' below) - - -ADD TO EVERY OBJECT - VERB turn - CHECK obj IS examinable - ELSE "That's not something you can turn." - AND obj IS movable - ELSE "It's not possible to turn" SAY THE obj. "." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES "You turn" SAY THE obj. - IF obj IN hero - THEN "in your hands" - END IF. - "$$. You notice nothing unusual about it" - IF obj NOT IN hero - THEN "and return it to its original position" - END IF. - "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN ON - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These subclasses are defined in 'classes.i' ------ with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. Trying to turn on or off ------ an ordinary object will default here to "That's not something you can turn on". - - -SYNTAX turn_on1 = turn 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can turn on." - - turn_on1 = switch 'on' (obj). - - - turn_on2 = turn (obj) 'on' - WHERE obj ISA OBJECT - ELSE "That's not something you can turn on." - - turn_on2 = switch (obj) 'on'. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', subclass 'device'. --- This verb merely covers cases where the player forgets to type 'on' or 'off'. - - - -ADD TO EVERY OBJECT - VERB turn_on1, turn_on2 - CHECK obj IS examinable - ELSE "That's not something you can $v on." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "That's not something you can $v on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN OFF - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These subclasses are defined in 'classes.i' ------ with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. - - -SYNTAX turn_off1 = turn off (obj) - WHERE obj ISA OBJECT - ELSE "You can't turn that off." - - turn_off1 = switch off (obj). - - - turn_off2 = turn (obj) off - WHERE obj ISA OBJECT - ELSE "You can't turn that off." - - turn_off2 = switch (obj) off. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', subclass 'device'. --- This verb merely covers cases where the player forgets to type 'on' or 'off'. - - -ADD TO EVERY OBJECT - VERB turn_off1, turn_off2 - CHECK obj IS examinable - ELSE "That's not something you can $v off." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "That's not something you can $v off." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE - - --- ============================================================== - - -SYNTAX 'use' = 'use' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can use." - - -ADD TO EVERY OBJECT - VERB 'use' - DOES - "Please be more specific. How do you intend to use it?" - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE WITH - - --- ============================================================== - - -SYNTAX use_with = 'use' (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only use objects." - AND obj2 ISA OBJECT - ELSE "You can only use objects." - - -ADD TO EVERY OBJECT - VERB use_with - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "You can't use something with itself." - DOES - "Please be more specific. How do you intend to use them together?" - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ UNDRESS - - --- ============================================================== - - --- See the file 'classes.i', subclass CLOTHING for the definition --- of this verb. - - - - - --- ============================================================== - - ------ UNLOCK - - --- ============================================================== - - -SYNTAX unlock = unlock (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can unlock." - - -ADD TO EVERY OBJECT - VERB unlock - CHECK obj IS lockable - ELSE "That's not something you can unlock." - AND obj IS locked - ELSE "It's already unlocked." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You must state what you want to unlock" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ UNLOCK WITH - - --- ============================================================= - - -SYNTAX unlock_with = unlock (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can unlock." - AND obj2 ISA OBJECT - ELSE "You can't unlock anything with that." - - -ADD TO EVERY OBJECT - VERB unlock_with - WHEN obj1 - CHECK obj1 IS lockable - ELSE "That's not something you can unlock." - AND obj1 IS locked - ELSE "It's already unlocked." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 In hero - ELSE - "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to unlock something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - SAY THE obj2. "doesn't unlock" SAY THE obj1. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ VERBOSE (see also -> BRIEF) - - --- ============================================================== - - -SYNTAX verbose = verbose. - - -VERB verbose - DOES - VISITS 0. - "Verbose mode is now on. Location descriptions will be always shown in full." -END VERB. - - - --- ============================================================== - - ------ WAIT (= z) - - --- ============================================================== - - -SYNTAX 'wait' = 'wait'. - - -VERB 'wait' - DOES - "Time passes..." -END VERB. - - -SYNONYMS - z = 'wait'. - - - --- ============================================================== - - ------ WHAT AM I - - --- ============================================================== - - -SYNTAX what_am_i = 'what' am i. - - -VERB what_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHAT IS - - --- ============================================================== - - -SYNTAX what_is = 'what' 'is' (obj)! - WHERE obj ISA THING - ELSE "That's not something I know about." - - -ADD TO EVERY THING - VERB what_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHERE AM I - - --- ============================================================== - - -SYNTAX where_am_i = 'where' am i. - - -VERB where_am_i - DOES - LOOK. -END VERB. - - - --- ============================================================== - - ------ WHERE IS - - --- ============================================================== - - -SYNTAX where_is = 'where' 'is' (obj)! - WHERE obj ISA THING - ELSE "That's not something I know about." - - -ADD TO EVERY THING - VERB where_is - CHECK obj NOT AT hero - ELSE "That's right here!" - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHO AM I - - --- ============================================================== - - -SYNTAX who_am_i = who am i. - - -VERB who_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHO IS - - --- ============================================================== - - -SYNTAX who_is = 'who' 'is' (act)! - WHERE act ISA ACTOR - ELSE "That's not somebody I know." - - -ADD TO EVERY ACTOR - VERB who_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WRITE - - --- ============================================================== - - -SYNTAX write = write (str) 'on' (obj) - WHERE str ISA STRING - ELSE "Please state inside double quotes ("""") what you want to write." - AND obj ISA OBJECT - ELSE "Nothing can be written there." - - - write = write (str) 'in' (obj). - - -ADD TO EVERY OBJECT - VERB write - WHEN obj - CHECK obj IS writeable - ELSE "Nothing can be written there." - AND obj IS reachable - ELSE "You can't reach" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF text OF obj = "" - THEN SET text OF obj TO str. - ELSE SET text OF obj TO text OF obj + " " + str. - END IF. - "You write ""$$" SAY str. "$$"" on" SAY THE obj. "." - MAKE obj readable. - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ YES - - --- ================================================================ - - -SYNTAX yes = yes. - - -VERB yes - DOES "You sound rather positive." -END VERB. - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/classes.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/classes.i deleted file mode 100755 index 05c6af5..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/classes.i +++ /dev/null @@ -1,1957 +0,0 @@ --- ALAN NEW LIBRARY: CLASSES (file name: 'classes.i') - - --- This library file defines various object and actor classes, as well as the --- instance 'hero'(=the player character). Many of these subclasses are frequently --- used in verb definitions in 'verbs.i' so they should be edited or --- removed with caution. - - --- Contents: - - - --- 1. OBJECT CLASSES --- ================= - - --- BACKGROUND - -- Is present in the location but cannot be reached or taken. - -- Doesn't appear automatically in room descriptions. - -- A typical example of a background would be for example the sun, - -- or a mountain visible in the distance. - -- Compare this with 'scenery' below (a background object cannot be reached, - -- but a scenery object can.) - - --- CLOTHING - -- Is a piece of clothing that behaves according to Alan Bampton's 'xwear.i' extension. - -- The said extension has been fully assimilated to this library. - -- This extension prevents clothes from being worn in an illogical order, e.g. you - -- cannot put on a shirt if you are already wearing a jacket, and so forth. - -- Also the verbs 'wear', 'remove' and 'undress' are defined here. - - --- DEVICE - -- Is a machine or an electronic device, for example a TV. Can be turned - -- (=switched) on and off if it is not broken. - -- Attributes: 'on' and NOT 'on', NOT broken. - -- Is described automatically as being either on or off when examined. - - --- DOOR - -- Can be opened, closed, locked and unlocked. - - -- Is by default closed, not locked. - -- Attributes: closeable, (NOT) closed, lockable, (NOT) locked. - -- Is described automatically as being either open or closed when examined. - - --- LIQUID - -- Can only be taken if it is in a container. You can fill something with it, - -- and you can pour it somewhere. - -- A liquid is by default NOT drinkable. - - --- LIGHTSOURCE - -- IS natural or NOT natural - -- (a natural lightsource is for example a match or a torch). - -- Can be turned on and off, lighted and extinguished (= put out) if it - -- is not broken. A natural lightsource - -- cannot be turned on or off, it can only be lighted and extinguished (= put out). - -- When examined, a lightsource is automatically supplied with a description of - -- whether it is providing light or not. - - --- LISTABLE_CONTAINER - -- Is a special kind of container, the contents of which will be listed both after - -- 'look' (= in the room description), 'look in' and 'examine' (if the container is open) - -- (the contents of a normal container object are not listed after 'examine' but only - -- after 'look' (=room description) and 'look in'). - - --- SCENERY - -- Behaves like a normal object, can be reached and manipulated but not taken. - -- The default message for 'take' will be "Unimportant for your purposes, you decide to - -- leave the [object] where it is." - -- The default message for 'examine' will be "The [object] doesn't appear particularly - -- interesting." - -- A scenery object is not automatically listed after the room description when - -- you type 'look'. You have to include it manually in the room description. - -- Compare this with 'background' above (a scenery object can be reached, - -- but a background object cannot.) - - --- SOUND - -- Can be listened to but not examined, searched, smelled or manipulated. - -- Cannot initially be turned on or off, this has to be implemented manually by giving - -- the sound the 'switchable' attribute. - - --- SUPPORTER - -- You can put things on this and you can stand on this. It is declared a container, - -- so you can take things from it, as well. When there's something on a supporter, - -- an automatic listing of it will appear in the room description and after 'examine'. - - --- WEAPON - -- IS fireable (e.g. a cannon) or NOT fireable (e.g. a baseball bat). - - --- WINDOW - -- Can be opened, closed, looked through and out of. - -- Will be automatically described as being either open or closed when examined. - - - --- 2. ACTOR CLASSES --- ================ - --- the ACTORS are defined here to be NOT inanimate CONTAINERS (so that they can e.g. --- receive and carry things. The 'contents' (= possessions) of an actor (except for the hero) --- are automatically listed after 'look' and 'examine'. (For the hero, the command 'inventory' --- must be used.) --- --- Actors are, like objects, usually preceded by an article in-game: --- e.g. "You see a man here." --- "There is nothing special about the dog." --- --- The following subclasses for actors are defined in this library: - - --- NAMED_ACTOR - -- has no article in front of the name when mentioned - -- e.g. "You see Spot here." - -- is not able to talk; this subclass is useful e.g. when defining animals - --- PERSON - -- has an article in front when mentioned (e.g. "a boy") - -- is able to talk - - --- NAMED_PERSON - -- has no article in front of the name when mentioned (e.g. "Jim") - -- is able to talk - - --- + instructions for expressing male and female actors with 'PRONOUN him' or 'PRONOUN her'. - - - --- 3. INSTANCES --- ============ - - --- the hero - - - - --- The contents end here. - - - --- ============================================================= - --- ============================================================= --- --- 1. Object classes --- --- ============================================================= - --- ============================================================= - - - --- ============================================================= - - ------ BACKGROUND - - --- ============================================================= - - -EVERY background ISA THING - IS NOT reachable. - DESCRIPTION "" -END EVERY. - - --- Note that a background object in ALAN3 is different from the backdrop in Inform7 --- in that a background object is at one location at a time only, unless --- you use the nested locations feature in ALAN which makes the object available --- in several locations. --- Here is an example where a ceiling lamp is located in the lobby, the bedroom --- and the living-room of a house, but not in other locations: - - --- 1) First, define the area where the object(s) should be found: - --- THE lamp_rooms ISA LOCATION -- i.e. the area in which we'll nest --- END THE. -- the three rooms mentioned above - --- and then define which locations belong to that area: - --- THE lobby ISA LOCATION IN lamp_rooms --- END THE. - --- THE bedroom ISA LOCATION IN lamp_rooms --- END THE. - --- THE livingroom ISA LOCATION IN lamp_rooms --- END THE. - - - --- 2) Then, place the background object in the area: - --- THE ceiling_lamp ISA BACKGROUND IN lamp_rooms --- NAME ceiling lamp --- END THE. - - --- Now, the lamp is found in all of the above locations. - --- Note that in this code you could define exits to other rooms of the house in the --- normal way, without having to worry about the area at all, e.g.: - --- THE bedroom ISA LOCATION IN lamp_rooms --- EXIT west TO upstairs_landing. --- END THE. - --- THE upstairs_landing ISA LOCATION -- ( = a location outside the defined area) --- EXIT east TO bedroom. --- END THE. - --- etc. - --- Naturally, you could also define a scenery object or a normal object to be --- in several locations at once, in the same way. Note, however, that if you define --- a takeable object in this manner, it will disappear from the other locations once --- you take it in one location. Also, when manipulated (e.g. broken), the object --- will be affected in all of the locations it is found. - - - --- ============================================================== - - ------ CLOTHING (+ the verbs WEAR, REMOVE, UNDRESS) - - --- ============================================================== - - --- To use this subclass, see the documentation text right after the --- code below. --- This subclass makes use of Alan Bampton's 'xwear.i' extension --- written originally for ALAN V2, converted here to V3 and --- assimilated fully to the present library. Thanks to Alan Bampton --- for the permission to use the code here. - - ------------------------------------------------------------------ --- First, we declare the container for clothing. ------------------------------------------------------------------ - - -THE worn ISA ENTITY -- an entity is present everywhere and thus the hero's - CONTAINER TAKING CLOTHING. -- clothing is always accessible - HEADER "You are wearing" - ELSE "You're not wearing anything." -END THE. - - -------------------------------------------------------------------- --- Next, we define the syntaxes for verbs needed for putting on --- and taking off clothing. -------------------------------------------------------------------- - - -SYNTAX wear = wear (obj) - WHERE obj ISA CLOTHING - ELSE "That's not something you can wear." - wear = put 'on' (obj). - wear = put (obj) 'on'. - wear = don (obj). - -SYNTAX remove = remove (obj) - WHERE obj ISA CLOTHING - ELSE "That's not something you can remove since you're not wearing it." - remove = take 'off' (obj). - remove = take (obj) 'off'. - remove = doff (obj). - -SYNTAX undress = undress. - - -------------------------------------------------------------------- --- Now, we define some common attributes for clothing as well as --- how the above verbs behave with this subclass. -------------------------------------------------------------------- - - -EVERY clothing ISA OBJECT - - IS wearable. - IS sex 0. - IS headcover 0. - IS handscover 0. - IS feetcover 0. - IS topcover 0. - IS botcover 0. - - CONTAINER -- to allow e.g. a wallet to be put into a jacket - - - VERB wear - - CHECK THIS NOT IN worn - ELSE "You are already wearing" SAY THE THIS. "." - AND THIS IS takeable - ELSE "You can't pick" SAY THE THIS. "up." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND sex OF THIS = sex OF hero OR sex OF THIS = 0 - ELSE - "On second thoughts you decide" - SAY THE THIS. "really won't suit a" - IF sex OF hero =1 - THEN "man" - ELSE "woman" - END IF. - "like you at all." - - - DOES ONLY - - --------------------------------------------------------------------- --- 'wear_flag' is a multi-purpose flag used for several purposes in --- this library, here it is reset to 0 before proceeding as a matter --- of 'housekeeping' for the code. --------------------------------------------------------------------- - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- First check to see if the player is carrying the item already, if --- not, set the 'wear_flag' to 1 to indicate the item was picked up --- in this turn. --------------------------------------------------------------------- - - - IF THIS NOT IN hero - THEN - SET wear_flag OF hero TO 1. - END IF. - - --------------------------------------------------------------------- --- Now see if the player can put this item on by testing --- all of its coverage attributes against the player's state. --------------------------------------------------------------------- - - --------------------------------------------------------------------- --- First check the 'topcover' attributes, if 'obj' fails this test --- then it means the hero is already wearing clothes that cover the --- topcover area and those clothes are of the same layer or a layer --- that belongs on top of the 'obj' item. In either case it would --- NOT be possible to put on the 'obj'. To 'flag' this condition add --- 5 to the 'wear_flag' attribute as an indicator this test failed. --------------------------------------------------------------------- - - - IF topcover OF THIS <> 0 AND topcover OF THIS <= SUM OF topcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - --- IF THIS IN tempworn THEN - IF handscover OF THIS <> 0 AND handscover OF THIS <= SUM OF handscover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF feetcover OF THIS <> 0 AND feetcover OF THIS <= SUM OF feetcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF headcover OF THIS <> 0 AND headcover OF THIS <= SUM OF headcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case, adjust the 'tempcovered OF hero' --- attribute so that the code rejects non sensible options. --- First of all, discount any coatlike clothes as these never --- affect ability to put on other lower body only garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 and botcover OF THIS < 33 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not technically affect ability to put on lower body only clothes. --- Special clause here excludes the full body coverage 'teddy' type --- garment - as a skirt WOULD prevent that from being removed. --- ( dress/coat garments automatically prevent this by virtue of --- having higher 'topcover' settings than the teddy ) --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 AND botcover OF THIS < 16 and botcover OF THIS <> 4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- IF tempcovered OF hero is still > 15 then must have trousers --- type clothing on - therefore disallow wearing dress type clothing --- because, although technically possible, it is not very sensible. --------------------------------------------------------------------- - - - IF tempcovered OF hero >15 AND botcover OF THIS > 16 - THEN - SET tempcovered OF hero TO tempcovered OF hero +16. - END IF. - - --------------------------------------------------------------------- --- From here down, clothes DO work as they do for other areas. --------------------------------------------------------------------- - - - IF botcover OF THIS <> 0 AND botcover OF THIS <= tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- At this point, 'wear_flag' will be 0 if the obj was held by the --- player and can be put on, or l if he picked it up this turn and --- it can be put on. Any higher value means one or more of the --- tests failed and the player cannot put on these clothes. --------------------------------------------------------------------- - - - IF wear_flag OF hero >1 THEN - IF THIS NOT IN hero - THEN - "You pick up the" SAY THE THIS. "." - END IF. - LOCATE THIS IN hero. - EMPTY worn IN tempworn. - LIST tempworn. - "Trying to put" - SAY THE THIS. - "on isn't very sensible." - EMPTY tempworn IN worn. - ELSIF wear_flag OF hero = 1 - THEN - LOCATE THIS IN worn. - "You pick up the" SAY THE THIS. - IF THIS IS plural - THEN - "and put them on." - ELSE - "and put it on." - END IF. - ELSE - LOCATE THIS IN worn. - "You put on" SAY THE THIS. "." - END IF. - -END VERB. - - - -VERB remove - CHECK THIS IN worn - ELSE - "You are not wearing" SAY THE THIS. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - - DOES ONLY - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- Check the total 'topcover' of items worn. Because of the number --- sequence used, by dividing the sum of the worn attributes by two --- and then comparing the result to the individual 'topcover' of the --- obj in question, ( the former can only ever be greater than the --- latter if an article of clothing is worn that goes over 'obj' ) --- it's easy to tell if the obj ought to be removable. A temporary --- attribute is used here because it needs to be manipulated. Once --- again 'wear_flag' is used to indicate the results. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF topcover IN worn /2. - IF topcover OF THIS <> 0 AND topcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF handscover IN worn /2. - IF handscover OF THIS <> 0 AND handscover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF feetcover IN worn /2. - IF feetcover OF THIS <> 0 AND feetcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF headcover IN worn /2. - IF headcover OF THIS <> 0 AND headcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case - first discount any coatlike clothes --- as these do not affect ability to take off other lower garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not affect ability to take off other lower garments. The 'teddy' --- type garment is expressly NOT included in the exclusion here. --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 and botcover OF THIS <>4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- Now process the manipulated value just as was done for the others --------------------------------------------------------------------- - - - SET tempcovered OF hero TO tempcovered OF hero /2. - IF botcover OF THIS <> 0 AND botcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Depending on the value of 'wear_flag' print and process the obj --- as needed. If 'wear_flag' is NOT 0 then the clothes cannot be --- removed. --------------------------------------------------------------------- - - - IF wear_flag OF hero >0 THEN - LIST worn. - "Trying to take" SAY THE THIS. "off isn't very sensible." - ELSE - LOCATE obj IN hero. - "You take off" SAY THE THIS. "." - END IF. -END VERB. - - -VERB examine - DOES AFTER - IF THIS IS NOT OPAQUE - THEN - IF COUNT ISA OBJECT, IN THIS > 0 -- if the piece of clothing contains - THEN LIST THIS. -- something, e.g. if a jacket contains a wallet, - END IF. -- the wallet will be mentioned when the - END IF. -- jacket is examined -END VERB. - - -END EVERY. - - --------------------------------------------------------------------- --- The verb 'undress' needs to be defined outside the object class --- as it is intransitive: --------------------------------------------------------------------- - - -VERB undress - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF COUNT IN worn, ISA CLOTHING > 0 - THEN "You don't feel like undressing is a good idea right now." - ELSE "You're not wearing anything you can remove." - END IF. - - -- or, to make it work, use the following lines instead: - --IF COUNT IN worn, ISA CLOTHING > 0 - --THEN EMPTY worn IN hero. - --"You remove all the items you were wearing." - --ELSE "You're not wearing anything you can remove." - -- END IF. -END VERB. - - - --------------------------------------------------------------------- --- These attributes are used internally in the library - ignore! --------------------------------------------------------------------- - -ADD TO EVERY ACTOR - IS tempcovered 0. - IS wear_flag 0. - IS sex 0. -END ADD TO. - - --------------------------------------------------------------------- --- A container used to provide a temporary storage space - ignore! --------------------------------------------------------------------- - -THE tempworn ISA OBJECT - CONTAINER TAKING CLOTHING. - HEADER "You're already wearing" -END THE tempworn. - - - ------------------------------------------------------------------------ --- DOCUMENTATION FOR CLOTHING ------------------------------------------------------------------------ - - --- The quick guide ------------------- - --- Here is a quick overview for using the subclass 'clothing'. A more closely-detailed --- description of this subclass is found below this overview. - - --- A piece of clothing in your game code should look something similar to these four examples: - - --- THE jacket ISA CLOTHING AT lobby --- IS topcover 32. --- END THE. - - --- THE jeans ISA CLOTHING IN wardrobe --- IS botcover 16. --- END THE. - - --- THE hat ISA CLOTHING IN worn -- IN worn = worn by the player character --- IS headcover 2. --- END THE. - - --- THE sweater ISA CLOTHING IN joe_worn -- = worn by an NPC called Joe. --- IS topcover 16. -- Define separate containers like this --- END THE. -- for clothes worn by non-player characters. - -- If you defined here 'IN joe', the clothing - -- would be listed in Joe's possessions: - -- "You see Joe here. Joe is carrying a book and - -- a sweater." - - --- In defining a piece of clothing, you should --- 1) define it ISA CLOTHING (and not: ISA OBJECT) --- 2) give it one of five attributes 'headcover', 'topcover', botcover', 'footcover' --- or 'handcover'; sometimes two of these are needed. --- Which attribute(s) to use depends on the type of clothing; see the clothing table below. --- 3) A number 2, 4, 8, 16, 32 or 64 needs to be added after the above attribute. --- You cannot decide the number yourself; look it up from the clothing table below. --- If the value of an attribute for a piece of clothing is 0 in the table, don't mention --- this attribute in connection with your clothing object. - - --- The above is enough; the rest is then handled automatically by the library. - - --- The quick guide ends here. The clothing table follows right below. The text following the --- table gives more details about the principles and the use of this subclass. - - --- The clothing table ------------------------ - - --- Here is the chart showing a selection of fairly typical clothing items and the values to --- set to obtain appropriate behaviour. Should you wish to create an article of clothing not --- listed, usually a bit of lateral thought as to what it is most like and where it fits into --- the scheme of things will suggest a workable set of values, but be aware that you MUST use --- values in this chart, simply adding things with intermediate values is probably going to --- create nasty bugs: - - --- Clothing Headcover Topcover Botcover Footcover Handcover - --- hat 2 0 0 0 0 --- vest/bra 0 2 0 0 0 --- undies/panties 0 0 2 0 0 --- teddy 0 4 4 0 0 --- blouse/shirt/T-shirt 0 8 0 0 0 --- dress/coveralls 0 8 32 0 0 --- skirt 0 0 32 0 0 --- trousers/shorts 0 0 16 0 0 --- sweater/pullover 0 16 0 0 0 --- jacket 0 32 0 0 0 --- coat 0 64 64 0 0 --- socks/stockings 0 0 0 2 0 --- tights/pantiehose 0 0 8 2 0 --- shoes/boots 0 0 0 4 0 --- gloves 0 0 0 0 2 - - - --- The concept of "xwear.i" (This and the following paragraphs are taken from Alan ---------------------------- -- Bampton's original 'xwear' documentation, with minor - -- alterations.) - - --- The basic idea behind this part of the library is that clothing is worn in --- 'layers' and it is rather silly to allow players to (say) take off or put --- on a shirt if they are wearing a jacket. To simulate this in ALAN I've chosen --- to apply a numeric based layering system, and divide the body into five zones --- of coverage. The zones are 'head', 'hands', 'feet', 'top' (for top half of torso) --- and 'bot' (for bottom half of torso). --- All objects have these five zones defined as default attributes (set to 0), for the --- head zone the attribute is headcover for the hands zone handscover and so on. --- Every clothing object will thus need one or more of its 'zonecover' attributes --- set to reflect the zone(s) it covers and its relative position in the layers of --- clothing worn. A simple example would be a shirt, this covers only the 'top' zone --- and so needs its topcover attribute to be set (to 8, just why it's 8 will become --- clear shortly). --- The principle used is that the closer to the skin an item is normally worn, --- the lower its 'cover' attribute is. The library operates on the assumption that --- items with higher value cover attributes for a particular zone are worn over items --- with lower value attributes. When a player attempts to put on an article of clothing, --- each zone it would affect is checked and compared to the related zonal total of any --- clothes already worn. If the value of the new clothing is not greater that the total(s) --- of clothing already worn (on a zone by zone basis) then the library will not allow --- the wearing of that item. There are a few notable exceptions to this rule, but --- I'll come back to those a little later. - - --- How it works in practice ---------------------------- - - --- This part of the library might sound complex, but it is actually very simple to use, --- here's an example of how it works. --- Assume our hero starts the game wearing just vest and shorts and the player issues --- the command 'put on shirt'. A quick check of the chart below should reveal that a shirt --- has only its topcover attribute set to non-zero, (all the other zones are zero, --- which means they are irrelevant for this item). --- The library totals the topcover attributes of all the clothes currently worn, like so:- --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- As there are no other clothes to consider, the library now compares the topcover attribute --- of the item we are attempting to put on, (a shirt with a topcover attribute of 8 in --- this case) to the total value of items already worn (2). --- Because the topcover attribute of the shirt (8) is greater than the calculated total (2), --- this is evaluated as being a 'legal' instruction and the library allows the shirt to be put on. --- Now consider the situation had the player started the game wearing vest, shorts and a jacket, --- this is what happens should he try to 'put on the shirt.' --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- Finally the library checks the jacket, this has a topcover attribute of 32, so total --- topcover is 2 + 32 = 34. --- Because the topcover attribute of the shirt (8) is now not greater than the calculated --- total (34), this is evaluated as being an 'illegal' instruction and the library won't --- allow the shirt to be put on. --- That demonstrates the basic principle of the library, removing clothes uses a variation --- of the 'compare to total' equation to allow / disallow removal of clothing, an example would --- be that our vest, shorts and jacket wearing player would NOT be allowed to remove --- the vest while he still had the jacket on. - - --- Exceptions to the rule... ----------------------------- - - --- Now I'll confuse the issue. Firstly the numbers in my chart are not born of some sort of --- weird fixation with multiples, there is a very good reason why the numbers are set as they --- are, computer/maths types will recognise the sequence and realise it is all 'binary' based --- and know it makes it possible to calculate exactly what the player is wearing in terms of --- layers. --- Some female clothing breaks the rules defined above and is not so easy to deal with. An example, --- although pantyhose is worn under a skirt, dress or coat it can actually be put on or removed --- with the garment worn over it still on. The library recognises this capability and deals with --- it properly by assigning the dress/skirt and coat items particular properties in that they --- don't affect the ability to wear or remove lower layer clothing that covers the bottom of --- the torso only. --- Although it's physically possible to put on/remove trousers while wearing a skirt or dress, --- this (and a few other neat dressing/undressing tricks) is considered illegal here. - - --- How to create clothes that use 'xwear.i' -------------------------------------------- - - --- That covers the way the library works, here's how to define objects to actually make --- use of it. As an example, this is how to define a dress and restrict it to being worn --- by a female. - - --- THE dress ISA CLOTHING IN changingroom - -- NAME little black dress - -- MENTIONED "little black dress" - -- IS - -- botcover 32. - -- topcover 8. - -- sex 2. --- END THE. - - --- Notice that it is only necessary to mention the attributes that are non-zero, this --- minimises the amount of coding required. Apart from making sure the hero is set as --- 'sex 2.' if we wish her to be able to wear this dress, this is all the author needs --- to do, the library will police what is wearable and keep track of things without any --- further work. --- I expect most authors would prefer to start their games with a player at least partially --- dressed. This is just a matter of defining the required clothes object as being in the --- 'worn' container. Here's how to define underwear that our female hero(ine?) starts --- the game wearing. - - --- THE bra ISA CLOTHING IN worn - -- NAME white bra - -- MENTIONED "white bra" - -- IS - -- topcover 2. - -- sex 2. --- END THE bra. - - --- THE panties ISA CLOTHING IN worn - -- NAME white panties - -- MENTIONED "white panties" - -- IS - -- botcover 2. - -- plural. - -- sex 2. --- END THE panties. - - --- The library as it stands also prevents wearing of duplicate clothes, or things that are --- logically mutually exclusive - e.g. the player can wear a dress or a skirt, but not both. - - - --- ============================================================= - - ------ DEVICE - - --- ============================================================= - - -EVERY device ISA OBJECT - IS NOT 'on'. - - - VERB examine - DOES - IF THIS IS 'on' - THEN "It is currently on." - ELSE "It is currently off." - END IF. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT 'on' - ELSE SAY THE THIS. "is already on." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS 'on'. - END VERB. - - - VERB turn_off - CHECK THIS IS 'on' - ELSE SAY THE THIS. "is already off." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - END VERB. - - --- The following verb switches a device off if the device is on, and vice versa. - - - VERB switch - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS 'on' - THEN "You switch" SAY THE THIS. "off." - MAKE THIS NOT 'on'. - ELSE "You switch" SAY THE THIS. "on." - MAKE THIS 'on'. - END IF. - END VERB. - -END EVERY. - - - --- ============================================================= - - ------ DOOR - - --- ============================================================= - - -EVERY door ISA OBJECT - IS closeable. - IS closed. - IS lockable. - IS NOT locked. - IS NOT takeable. - - VERB examine - DOES - IF THIS IS closed - THEN "It is currently closed." - ELSE "It is currently open." - END IF. - END VERB. - - - VERB knock - DOES ONLY - IF THIS IS closed - THEN "You knock on" SAY THE THIS. "$$. There is no reply." - ELSE "You don't find it purposeful to knock on the open door." - END IF. - END VERB. - - - VERB look_behind - DOES ONLY - IF THIS IS closed - THEN "You cannot look behind the door - it is closed." - ELSE "You notice nothing special behind the door." - END IF. - END VERB. - - - VERB look_under - DOES ONLY - IF THIS IS closed - THEN "The gap under the closed door is so narrow that you can't - see anything of what lies on the other side." - ELSE "You notice nothing special under the door." - END IF. - END VERB. - - -END EVERY. - - - --- ============================================================= - - ------ LIGHTSOURCE - - --- ============================================================= - - -EVERY lightsource ISA OBJECT - IS NOT lit. - IS NOT broken. - IS natural. -- A natural lightsource is for example a candle, a match or a torch. - -- A NOT natural lightsource is for example a flashlight or a lamp. - -- You cannot switch on or off a natural lightsource. - - - - VERB examine - DOES - IF THIS IS lit - THEN - IF THIS IS natural - THEN "It is currently lit." - ELSE "It is currently on." - END IF. - ELSE - IF THIS IS natural - THEN "It is currently not lit." - ELSE "It is currently off." - END IF. - END IF. - END VERB. - - - VERB light - CHECK THIS IS NOT lit - ELSE SAY THE obj. "is already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS natural - THEN "You light" SAY THE THIS. "." - MAKE THIS lit. - - ELSE "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END IF. - END VERB. - - - VERB extinguish - CHECK THIS IS lit - ELSE "But" SAY THE THIS. "is not providing light!" - DOES ONLY "You extinguish the" SAY THE THIS. "." - MAKE THIS NOT lit. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT natural - ELSE "That's not something you can $v on." - AND THIS IS NOT lit - ELSE SAY THE THIS. "is already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END VERB. - - - VERB turn_off - CHECK THIS IS NOT natural - ELSE "That's not something you can $v off." - AND THIS IS lit - ELSE SAY THE THIS. "is already off." - DOES ONLY - "You turn off the" SAY THIS. "." - MAKE THIS NOT lit. - - END VERB. - - --- The following verb switches a NOT natural lightsource on if it is off, and vice versa. - - - VERB switch - CHECK THIS IS NOT natural - ELSE SAY THE obj. "is not something you can switch on or off." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - AND CURRENT LOCATION IS lit - ELSE - "You switch" SAY THE THIS. "on." - MAKE THIS lit. - DOES ONLY - IF THIS IS lit - THEN "You switch" SAY THE THIS. "off." - MAKE THIS NOT lit. - ELSE "You switch" SAY THE THIS. "on." - MAKE THIS lit. - END IF. - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ LIQUID - - --- ============================================================== - - -EVERY liquid ISA OBJECT - - CONTAINER -- We declare this subclass a container to enable player commands - -- such as 'throw sack in water', 'take pearl from water' and 'look into - -- water'. Also cases such as 'pour blue potion in red potion' require - -- that the liquid class behaves like a container. - - - HAS vessel zero_vessel. -- The 'vessel' attribute takes care of that if a liquid is in a container, - -- the verb 'take' will automatically take the container instead - -- (if the container is takeable). Trying to take a liquid that - -- is in a fixed-in-place container will yield "You can't carry - -- [the liquid] around in your bare hands." - -- The default value 'zero_vessel' tells the compiler that the liquid is - -- not in any container. - - - - -- If you have some liquid in a container in your game, you should declare the liquid thus: - - -- THE juice ISA LIQUID - -- IN bottle - -- HAS vessel bottle. -- i.e. the value of the 'vessel' attribute is the container - -- ... -- the liquid is in - -- END THE juice. - - - -- Then, taking and pouring liquids work smoothly. - -- If you leave the 'vessel' attribute out, taking a liquid will yield "You can't carry - -- [the liquid] around in your bare hands."; only taking its container will work. - - - INITIALIZE - SCHEDULE check_vessel AFTER 1. - - - - VERB take - DOES ONLY - IF vessel OF THIS = zero_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$nTaken." - END IF. - END VERB. - - - VERB drop - DOES ONLY - "($$" SAY THE vessel OF THIS. "$$)$nDropped." - LOCATE vessel OF THIS AT hero. - END VERB. - - - VERB give - WHEN obj1 - DOES ONLY - IF THIS NOT IN hero - THEN - IF vessel OF THIS = zero_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - - "You give" SAY THE vessel OF THIS. "to" SAY THE obj2. "." - LOCATE vessel OF THIS IN obj2. - END VERB. - - - VERB pour - DOES ONLY - IF THIS NOT IN hero - THEN - IF vessel OF THIS = zero_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't pour" SAY THE THIS. "anywhere since you are not - carrying it." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - - "You pour" SAY THE THIS. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - LOCATE THIS AT hero. - SET vessel OF THIS TO zero_vessel. - END VERB. - - - VERB pour_in - WHEN obj1 - DOES ONLY - IF THIS NOT IN hero - THEN - IF vessel OF THIS = zero_vessel OR vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - - "You pour" SAY THE THIS. "into" SAY THE obj2. "." - LOCATE THIS IN obj2. - SET vessel OF THIS TO obj2. - END VERB. - - - VERB pour_on - WHEN obj1 - DOES ONLY - IF THIS NOT IN hero - THEN - IF vessel OF THIS = zero_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$n" - END IF. - END IF. - - "You pour" SAY THE THIS. "on" SAY THE obj2. "." - IF obj2 = floor OR obj2 = ground - THEN LOCATE THIS AT hero. - SET vessel OF THIS TO zero_vessel. - ELSIF obj2 ISA SUPPORTER - THEN LOCATE THIS IN obj2. - SET vessel OF THIS TO zero_vessel. - ELSE "It wouldn't be sensible to pour anything on" SAY THE obj2. - END IF. - END VERB. - - - VERB fill_with - WHEN obj2 - DOES SET vessel OF THIS TO obj1. - END VERB. - - - VERB put_in - WHEN obj1 - DOES SET vessel OF THIS TO obj2. - END VERB. - - - VERB put_on - WHEN obj1 - DOES SET vessel OF THIS TO obj2. - END VERB. - - -END EVERY. - - - - --- We still declare the default vessel for liquids; if the vessel of a liquid is --- 'zero_vessel', it means that the liquid is not in any container. - - -THE zero_vessel ISA OBJECT - CONTAINER -END THE. - - --- Here is the event checking that if a liquid is at any time outside a container, --- its 'vessel' attribute will be 'zero_vessel': - - -EVENT check_vessel - FOR EACH liq ISA LIQUID DO - IF vessel OF liq <> zero_vessel - THEN - IF COUNT ISA LIQUID, IN vessel OF liq = 0 - THEN SET vessel OF liq TO zero_vessel. - END IF. - END IF. - END FOR. - SCHEDULE check_vessel AFTER 1. -END EVENT. - - -FOR EACH o ISA CONTAINER DO - "" -END FOR. - - --- ============================================================= - - ------ LISTABLE_CONTAINER - - --- ============================================================= - - -EVERY LISTABLE_CONTAINER ISA OBJECT -- ACTORS are separately defined as - CONTAINER -- containers further below - - - VERB examine - DOES - IF THIS IS closeable - THEN - IF THIS IS closed - THEN "It is closed." - ELSE "It is open." - END IF. - END IF. - - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't see inside" SAY THE THIS. "." - END IF. - END VERB. - - - VERB look_in - DOES ONLY - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't, since" SAY THE THIS. "is closed." - END IF. - END VERB. - - - VERB open - DOES - MAKE THIS NOT OPAQUE. - LIST THIS. - END VERB. - - - VERB close - DOES - MAKE THIS OPAQUE. - END VERB. - - -END EVERY. - - - --- Tips for using container objects: - - --- 1) - - --- The contents of a normal CONTAINER are not listed when examined --- (you'll need to look *into* the object to see what it contains). --- If you wish to have the contents listed after 'examine' anyway, --- you should --- --- instead of: --- --- THE box ISA OBJECT --- CONTAINER --- ... --- END THE. --- --- do this: --- --- THE box ISA LISTABLE_CONTAINER --- ... --- END THE. --- --- Then, 'examine' lists the contents of the container. - - --- 2) - - --- For the command 'inventory' to list the contents of a container --- the hero is carrying, go to 'verbs.i', find the command 'inventory' --- and list one by one all relevant containers that the hero might carry, --- thus: --- --- VERB inventory --- DOES LIST hero. --- ... --- IF bag IN hero --- THEN LIST bag. --- END IF. --- --- IF box IN hero --- THEN LIST box. --- END IF. --- ... --- END VERB. --- --- --- If you leave out these additions, the bag and the box will be listed after the --- command 'inventory' in the following way: --- --- "You are carrying a bag and a box." --- --- only. But with the above additions, the outcome is e.g. --- --- "You are carrying a bag and a box. The bag contains a loaf of bread. The box --- is empty." - - --- 3) - - --- To declare a container the contents of which should not be listed after 'look' --- or 'examine', declare it an 'opaque container' in the following way: - - --- THE box ISA OBJECT --- OPAQUE CONTAINER --- ... --- END THE. - - --- or - - --- THE box ISA LISTABLE_CONTAINER --- OPAQUE CONTAINER --- ... --- END THE. - - --- Objects in an opaque container cannot be seen or manipulated. --- To change this, declare e.g. --- --- MAKE box NOT OPAQUE. --- - - - --- ============================================================== - - ------ SCENERY - - --- ============================================================== - - -EVERY scenery ISA OBJECT - IS NOT takeable. - DESCRIPTION "" - - - VERB examine - DOES ONLY SAY THE THIS. "doesn't appear particularly interesting to you." - END VERB. - - -- see also checks in the verbs 'take' and 'take from' in 'verbs.i' - -END EVERY. - - - --- =============================================================== - - ------ SOUND - - --- =============================================================== - - -EVERY sound ISA OBJECT - IS NOT examinable. - IS NOT reachable. - IS NOT movable. - - - VERB smell - DOES ONLY "That's not something you can smell." - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ SUPPORTER - - --- ============================================================== - - -EVERY supporter ISA OBJECT - CONTAINER - HEADER "On" SAY THE THIS. "you see" - ELSE "There's nothing on" SAY THE THIS. "." - - - VERB examine - DOES LIST THIS. - END VERB. - - - VERB look_in - DOES ONLY "That's not something you can look into." - END VERB. - - - VERB put_in - WHEN obj2 - DOES ONLY "You can't put anything inside" SAY THE THIS. "." - END VERB. - - - VERB search - DOES ONLY "You find nothing further of interest." - END VERB. - - -END EVERY. - - --- To place objects on a supporter, do the definition in the following way: --- --- Define the supporter first; e.g. --- --- THE tray ISA SUPPORTER --- ... --- END THE. --- --- --- Then, the objects on the supporter: --- --- --- THE apple ISA OBJECT --- IN tray -- note the IN here, even if the apple will be described as --- ... -- being on the tray --- END THE. --- --- --- THE book ISA OBJECT --- IN table --- ... --- END THE. --- --- --- Note that the 'examine' command will list what is on the surface of a supporter, not what, --- if anything, is inside the supporter. For example, if you have a supporter called table in your game --- with a drawer in it, --- --- DON'T do this: --- --- --- THE drawer ISA LISTABLE_CONTAINER --- IN table. --- END THE. --- --- This would result in something like --- --- "There's a table here. On the table you see a book and a drawer." --- --- --- Instead, do either of the two following things: --- --- --- 1) --- --- THE drawer ISA LISTABLE_CONTAINER --- AT bedroom --- END THE. --- --- --- In other words, just declare the drawer present in the location, not as part of the table. --- ('AT table' would not be possible, as all objects must be initially located to --- instances inheriting from the class 'location'.) --- If this method feels clumsy, try the next one: --- --- --- 2) --- --- THE table_parts ISA OBJECT --- AT bedroom --- DESCRIPTION "" -- we don't want this object to appear in the room description --- CONTAINER --- HEADER "In the table there is" --- ELSE "" -- if the parts are removed from the table, there will be no --- END THE. -- mention of them in the description of the table --- --- --- THE drawer ISA LISTABLE_CONTAINER --- IN table_parts --- ... --- END THE. --- --- --- THE table ISA SUPPORTER --- ... --- VERB examine --- DOES ONLY --- LIST table. -- lists what is on the table --- LIST table_parts. -- lists the components of the table, i.e. the drawer in this example --- ... --- END VERB. --- --- END THE. --- --- --- In other words, define a separate container for the component(s) in the supporter --- which will then be listed after the surface objects have been listed. --- Consequently, the above will result in something like this: --- --- > examine table --- On the table you see a book. In the table there is a drawer. --- --- --- Note that in a location description (e.g. after LOOK), only the things *on* a supporter --- (and not any components) will be described, according to how things are defined in --- this library. --- --- - - - --- ============================================================== - - ------ WEAPON - - --- ============================================================== - - -EVERY weapon ISA OBJECT - IS NOT fireable. -END EVERY. - - --- see checks for this subclass in the file 'verbs.i', verbs 'attack_with', 'fire', --- 'fire_with', 'kill_with', 'shoot' and 'shoot_with'. - - - --- ============================================================== - - ------ WINDOW - - --- ============================================================== - - --- You can look out of and through a window. --- When examined, a window is automatically described to be either open or closed. - - -EVERY window ISA OBJECT - IS closeable. - IS closed. - IS NOT takeable. - - - VERB examine - DOES - IF THIS IS closed - THEN "It is currently closed." - ELSE "It is currently open." - END IF. - END VERB. - - - VERB look_behind - DOES ONLY - "That's not possible." - END VERB. - - - VERB look_out_of - DOES ONLY "You see nothing special looking out of the window." - END VERB. - - - VERB look_through - DOES ONLY "You see nothing special looking through the window." - END VERB. - - -END EVERY. - - - --- =============================================================== - --- =============================================================== --- --- 2. Actor classes --- --- =============================================================== - --- =============================================================== - - --- First, we declare some common characteristics for all actors: - - -ADD TO EVERY ACTOR - IS NOT inanimate. - IS NOT following. - IS NOT sitting. - IS NOT lying_down. - - CONTAINER -- so that actors can receive and carry objects - - INITIALIZE -- all actors will obey this script from the start of the game - USE SCRIPT following_hero FOR THIS. - - - SCRIPT following_hero -- this code will make any actor follow the hero - STEP WAIT UNTIL hero NOT HERE -- if the actor is given the attribute 'following'. - IF THIS IS following - THEN - LOCATE THIS AT hero. - SAY THE THIS. "follows you." - END IF. - USE SCRIPT following_hero FOR THIS. - - - - - VERB examine - DOES - IF COUNT ISA THING, IN THIS > 0 -- This if-statement will make a description of an - THEN LIST THIS. -- actor's possessions show up every time the actor is examined. - END IF. -- Note that this doesn't apply to the hero which is defined - -- separately further below. - END VERB. - -END ADD TO. - - --- To make an actor follow the hero, give it the 'following' attribute, e.g.: - --- THE bob ISA ACTOR --- ... --- VERB whatever --- DOES MAKE bob following. --- END VERB. --- .... --- --- END THE bob. --- --- etc. - --- --- If you wish to have an actor follow the hero right from the start of the game, you can naturally just declare --- --- THE servant ISA ACTOR --- IS following. --- ... --- END THE. --- --- - --- To stop an actor from following the hero, just make the actor NOT following. - - - - --- ================================================================ - - ------ PERSON -- HAS can_talk - - --- ================================================================ - - -EVERY person ISA ACTOR - HAS can_talk. -END EVERY. - - - --- ================================================================ - - ------ NAMED_ACTOR -- NOT can_talk - - --- ================================================================ - - -EVERY named_actor ISA ACTOR - DESCRIPTION SAY THIS. "is here." - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" -END EVERY. - - - --- ================================================================ - - ------ NAMED_PERSON -- HAS can_talk - - --- ================================================================ - - -EVERY named_person ISA PERSON - DESCRIPTION SAY THIS. "is here." - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" -END EVERY. - - - --- ================================================================ - - ------ Expressing FEMALE and MALE - - --- ================================================================ - - --- 'Male' and 'female' are not declared as separate classes in this library. --- This is to avoid numerous new subclasses such as female_actor, named_female_actor, --- female_person, named_female_person, and the same for male. Instead, just --- --- add the line --- --- PRONOUN him --- --- or --- --- PRONOUN her --- --- to any actor instance to make it possible for the player to refer to the --- actor with these pronouns. For example, --- --- THE jessie ISA NAMED_PERSON --- PRONOUN her --- ... --- END THE. - - - --- ================================================================ - --- ================================================================ - --- 3. The hero - --- ================================================================ - --- ================================================================ - - - - -THE hero ISA ACTOR - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" - MENTIONED "yourself" - IS NOT sitting. - IS NOT lying_down. - - CONTAINER - - LIMITS -- remove this whole section (from this line until 'HEADER') if you wish to have no limits to - -- how much the hero can carry. - COUNT 10 Then - "You can't carry anything more. You have to drop something - first." - WEIGHT 50 Then - "You can't carry anything more. You have to drop something - first." - - HEADER - IF CURRENT LOCATION IS NOT lit - THEN "Although you cannot see your belongings in the dark, you - remember that you're carrying" - ELSE "You are carrying" - END IF. - ELSE - "You are empty-handed." - - - VERB examine - DOES ONLY "You notice nothing unusual about yourself." - IF COUNT ISA CLOTHING, IN worn > 0 - THEN LIST worn. -- this will list what the hero is wearing - END IF. - END VERB. - - -END THE. - - -SYNONYMS - me, myself, yourself, self = hero. - - --- Please refer also 'verbs.i' where there are numerous verb checks for the hero, --- so that the hero cannot e.g. attack himself etc. - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/locations.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/locations.i deleted file mode 100755 index 92b1e91..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/locations.i +++ /dev/null @@ -1,536 +0,0 @@ --- ALAN NEW LIBRARY: LOCATIONS (file name: 'locations.i') - - --- This library file defines the default directions (exits) and the location 'nowhere', a useful --- place to locate things when you want to remove them from play. --- This file also defines three specific location classes: rooms (= indoor locations), --- sites (= outdoor locations) as well as the class 'dark_location'. --- Finally, the attributes 'visited' and 'described' as well as the instance 'room' --- (to make possible player commands such as 'examine room' and 'exit room') are defined. --- You may modify this file in any way that suits your purposes. --- To use this file, you should have it in the same folder as your source code file , and the line --- --- IMPORT 'locations.i'. --- --- in your source code. - - - --- ======================================================== - - ------ 1. The location 'nowhere' and the default directions - - --- ======================================================== - - -THE nowhere ISA LOCATION - - EXIT - north, - south, - east, - west, - northeast, - southeast, - northwest, - southwest, - up, - down, - 'in', - out - - TO nowhere. - - -END THE nowhere. - - -SYNONYMS - n = north. - s = south. - e = east. - w = west. - ne = northeast. - se = southeast. - nw = northwest. - sw = southwest. - u = up. - d = down. - - --- Note: - - --- 1) the directions defined above (and their synonyms) are not predefined in or --- hardwired to the interpreter in any way, so you can replace them altogether or add new --- ones to be used alongside with them. - - --- 2) when you want to remove things from play, you can --- --- LOCATE [object] AT nowhere. --- --- e.g. --- --- THE piece_of_paper ISA OBJECT --- ... --- VERB tear --- DOES ONLY "You tear the piece of paper to shreds." --- LOCATE piece_of_paper AT nowhere. --- END VERB. --- --- END THE piece_of_paper. - - - --- ========================================================================= - - ------ 2. Location classes 'room' and 'site' for indoor and outdoor locations - - --- ========================================================================= - - --- ROOM and SITE are optional location classes you can use to ease up coding. --- All ROOMS have a floor, walls and a ceiling. All SITES have a ground and a sky. --- Thus, you will be able to define e.g. --- --- THE kitchen ISA ROOM --- --- and it will automatically have a floor, walls and a ceiling, --- --- or: --- --- THE greenmeadow ISA SITE --- --- and the ground and the sky are automatically found in that location. --- --- --- Of course, you will still be able to define locations in the usual way, e.g. --- --- THE kitchen ISA LOCATION --- --- etc, but the floor, walls and ceiling won't be automatically included there. --- The walls, floor, ceiling, ground and sky are not takeable or movable. --- This library file also defines the sky and the ceiling to be out of reach, --- so that they can't be e.g. touched. - --- (We make use of ALAN's nested locations feature in the following definitions: ) - - -THE outdoor ISA LOCATION -END THE outdoor. - - -THE indoor ISA LOCATION -END THE indoor. - - -EVERY room ISA LOCATION AT indoor -END EVERY. - - -EVERY site ISA LOCATION AT outdoor -END EVERY. - - -EVERY room_object ISA OBJECT AT indoor -END EVERY. - - -EVERY site_object ISA OBJECT AT outdoor -END EVERY. - - -THE floor ISA room_object - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow 'empty/pour something on floor' - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the floor." - END VERB. - - - VERB look_in, look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - -THE walls ISA room_object - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the walls." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - -SYNONYMS wall = walls. - - -THE ceiling ISA room_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the ceiling." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - -THE ground ISA site_object - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow 'empty/pour something on ground' - DESCRIPTION "" - - - VERB examine - DOES ONLY "You notice nothing unusual about the ground here." - END VERB. - - - VERB look_in, look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - - VERB dig - DOES ONLY "The ground is not suitable for digging here." - END VERB. - - -END THE. - - -THE sky ISA site_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the sky." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - --- NOTE: it is often a good idea to modify the 'examine' verb for the above objects. --- Here is an example for 'walls': - --- THE walls ISA room_object --- : --- : --- VERB examine DOES ONLY --- IF hero AT kitchen --- THEN "Numerous shelves, full of various kitchen utensils, line the walls." --- ELSIF hero AT livingroom --- THEN "The walls are decorated with flowery wallpaper here." --- : --- : --- END IF. --- END VERB. --- END THE walls. --- --- In other words, making the description of the walls, etc., individual for each room --- gives a better impression than if you just use the default messages. - - - --- ========================================================== - - ------ 3. Dark locations - - --- ========================================================== - - -ADD TO EVERY LOCATION - IS lit. -END ADD TO. - - -EVERY dark_location ISA LOCATION - IS NOT lit. - - ENTERED - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - THEN MAKE THIS lit. - END IF. - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE = 0 - THEN MAKE THIS NOT lit. - END IF. - - -- these ENTERED statements take care - -- of the dark location being correctly lit or not lit at entrance, the WHEN rules below take care of - -- the change when the hero is already in the location. - - DESCRIPTION - CHECK COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - ELSE "It is pitch black. You can't see anything at all." - -END EVERY dark_location. - - -WHEN CURRENT LOCATION IS NOT lit - AND COUNT ISA lightsource, IS lit, HERE > 0 -THEN MAKE CURRENT LOCATION lit. - LOOK. - - -WHEN CURRENT LOCATION ISA dark_location - AND CURRENT LOCATION IS lit - AND COUNT ISA LIGHTSOURCE, IS lit, HERE = 0 -THEN MAKE CURRENT LOCATION NOT lit. - "It is now pitch black." - - --- To define a dark location, use a formulation like the following: - - --- THE basement ISA dark_location --- EXIT up TO kitchen. --- ... --- END THE. - - --- The description of a dark_location will automatically be: "It is pitch black. --- You can't see anything at all." (Edit the description in the code above to change this.) - - --- If you add a description to a dark_location, this description will be shown only --- if/when the location is lit by any means: - --- THE basement ISA dark_location --- DESCRIPTION "Cobwebs and old junk are the only things you see here." --- EXIT up TO kitchen. --- END THE. - - --- In darkness, you are not able to manipulate things other than turn on a lightsource --- and drop items you're carrying (these checks are found in 'verbs.i'). You can exit normally --- and use verbs that don't require seeing, such as 'smell', 'listen' and 'think'. --- If you are in a dark location with an NPC (= a non-player character), you are able to --- communicate with him by asking and telling but not by showing and giving. If you wish to --- change this, see the respective verbs in 'verbs.i' and edit their checks. - - --- Note that you cannot change the name of a location mid-game. Thus, if you define a dark location --- called e.g. 'Darkness' and wish to make it lit at some point in the game, the name will still be 'Darkness' --- even if the location description can be changed to describe the illuminated location. --- To change the location name, you must locate the hero in another location when the dark location --- is lit. For example, --- --- --- THE lantern ISA LIGHTSOURCE -- (see 'classes.i') --- VERB turn_on --- DOES --- IF hero AT darkness --- THEN LOCATE hero AT treasure_chamber. --- ... --- END IF. --- ... --- END VERB. --- --- etc. --- --- --- Alternatively, you can also use a rule, e.g. --- --- --- WHEN lantern IS lit --- AND hero AT darkness --- THEN LOCATE hero AT treasure_chamber. - - - --- Suppose you want all dark_locations in the game to become lighted. It can be done e.g. like this: - --- FOR EACH d1 ISA dark_location DO --- IF main_power_switch IS 'on' --- THEN MAKE d1 lit. --- END IF. --- END FOR. - --- FOR EACH makes a loop that affects all instances of the class described after the ISA statement. --- The 'd1' is a temporary variable needed in the FOR EACH phrase and not anywhere else in the game code. --- You can name this variable in any way you wish. --- It is needed to refer to each instance (in 'THEN MAKE d1 lit), because FOR EACH affects all --- *instances* of the defined class, not the class itself. - - - --- ===================================================================== - - ------ 4. The attributes 'visited' and 'described' - - --- ===================================================================== - - --- A location has the value 'visited 0' until the hero visits it for the first time, and the --- value increases on every subsequent visit. --- This helps when you need to control if or how many times a location has been visited, --- and also if you want the location description to be different after the first visit. - --- A location has the value 'described 0' before the first location description, --- and the value increases every time the description is shown. --- This distinction is handy when you want the first-time description of a location to be different from --- the subsequent ones, even if the hero is in the location still for the first time. - - -ADD TO EVERY LOCATION - HAS visited 0. - HAS described 0. - ENTERED - IF CURRENT ACTOR = hero - THEN INCREASE visited OF THIS. - INCREASE described OF THIS. -- this value also increases after 'look' (see 'verbs.i'.). - END IF. -END ADD TO. - - --- A location not visited at all has the 'visited' value 0. When the hero enters it --- the first time, the 'visited' value will change to 1. On the second visit the value will be 2, etc. --- Now, in your source code you can define something like the following: - - --- THE kitchen ISA LOCATION --- DESCRIPTION --- "You are in the kitchen." --- IF visited OF THIS = 1 --- THEN "This is your first time here." --- ELSE "You've been here before." --- END IF. --- ... --- END THE. - --- Note that if you have an NPC moving around in the game, the visited value of any location --- will increase when the NPC enters the location, as well. This is most often not what is wanted, --- and that's why the 'if' statement (IF CURRENT ACTOR = hero) is included above. - - --- You can also check whether the hero has been in a location if need be: - --- THE king ISA ACTOR --- ... --- VERB ask --- WHEN act --- IF topic = treasure_chamber --- THEN --- IF visited OF treasure_chamber = 0 --- THEN "You are not supposed to know anything about the treasure --- chamber - you haven't found it yet." --- ELSE """Just take what you want from the chamber"", the king smiles." --- END IF. --- ... --- END IF. --- END VERB. --- END THE. - - --- etc. - - --- Suppose you want the location description to be different after the first time the description is shown, --- even if you are in the location still for the first time. Then , you can use the 'described' attribute, e.g.: - - --- THE library ISA ROOM --- DESCRIPTION --- IF described OF THIS = 0 --- THEN "There is an old man reading at a table in one of the corners." --- ELSE "The old man keeps on reading at his table." --- END IF. --- END THE. - - - --- ======================================================================= - - --- 5. The instance 'room' - - --- ======================================================================= - - --- Through defining the instance 'room' we make possible player commands such as 'examine room' and --- 'exit room', among others. These commands only work in indoor locations. --- We have to identify this instance differently from 'room' which has already been defined as a subclass above, --- that's why we identify it here as 'current_room'. Through the NAME statement, it can be still --- called a 'room' in-game. - - -THE current_room ISA OBJECT - AT indoor - NAME 'room' - IS NOT takeable. - IS NOT movable. - CONTAINER - DESCRIPTION "" - - - VERB examine - DOES ONLY DESCRIBE CURRENT LOCATION. - END VERB. - - - VERB search - DOES ONLY "Try examining one thing at a time." - END VERB. - - - VERB enter - DOES ONLY "You must state a direction where to go." - END VERB. - - - VERB 'exit' - DOES ONLY "You must state a direction where to go." - END VERB. - - - VERB look_in, look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/messages.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/messages.i deleted file mode 100755 index 8c17152..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/messages.i +++ /dev/null @@ -1,72 +0,0 @@ --- ALAN NEW LIBRARY: MESSAGES (file name: 'messages.i') - - --- This library file lists all the standard runtime messages listed in the manual, for easy modification. - - - -MESSAGE AFTER_BUT: "You must give at least one object after '$1'." - AGAIN: "(again)" -- if you wish to disable this, make the string empty ("") - BUT_ALL: "You can only use '$1' AFTER '$2'." - CAN_NOT_CONTAIN: "$+1 can not contain $+2." - CANT0: "You can't do that." -- note that the fifth token in CANT0 is a zero, not an 'o'. - CARRIES: "$+1 carries" - 'CONTAINS': "$+1 contains" - CONTAINS_COMMA: "$01," - CONTAINS_AND: "$01 and" - CONTAINS_END: "$01." - EMPTY_HANDED: "$+1 is empty-handed." - HAVE_SCORED: "You have scored $1 points out of $2." - IS_EMPTY: "$+1 is empty." - MORE: "" - MULTIPLE: "You can't refer to multiple objects with '$v'." - NO_SUCH: "I can't see any $1 here." - NO_WAY: "You can't go that way." - NOT_MUCH: "That doesn't leave much to $v!" - NOUN: "You must supply a noun." - NOT_A_SAVEFILE: "That file does not seem to be an Alan game save file." - QUIT_ACTION: "Do you want to RESTART, RESTORE, QUIT or UNDO? " - -- these four alternatives are hardwired to the interpreter and cannot be changed. - REALLY: "Are you sure (RETURN confirms)?" - RESTORE_FROM: "Enter file name to restore from" - SAVE_FAILED: "Sorry, save failed." - SAVE_MISSING: "Sorry, could not open the save file." - SAVE_NAME: "Sorry, the save file did not contain a save for this adventure." - SAVE_OVERWRITE: "That file already exists, overwrite (y)?" - SAVE_VERSION: "Sorry, the save file was created by a different version." - SAVE_WHERE: "Enter file name to save in" - SEE_START: "There is $01" - SEE_COMMA: ", $01" - SEE_AND: "and $01" - SEE_END: "here." - NO_UNDO: "No further undo available." - UNDONE: "'$1' undone." - UNKNOWN_WORD: "I don't know the word '$1'." - WHAT: "I don't understand." - WHAT_WORD: "I don't know what you mean by '$1'." - WHICH_PRONOUN_START: "I don't know if you by '$1'" - WHICH_PRONOUN_FIRST: "mean $+1" - WHICH_START: "I don't know if you mean $+1" - WHICH_COMMA: ", $+1" - WHICH_OR: "or $+1." - - --- These messages are automatically translated into German or Swedish in your game --- if you define in the beginning of your source code --- --- OPTIONS --- LANGUAGE German. --- --- or --- --- OPTIONS --- LANGUAGE Swedish. --- --- Only the exact equivalents of the above phrases will then be shown; if you change the above English --- messages to your own wordings, the translations will still be only for the default. --- --- --- If you wish to make your game in some other language, you must manually translate --- the messages above. There might be support for more languages in the future, depending --- on demand. - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/testgame.alan b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/testgame.alan deleted file mode 100755 index 915c708..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/testgame.alan +++ /dev/null @@ -1,279 +0,0 @@ --- TESTGAME - - -IMPORT 'locations.i'. -IMPORT 'classes.i'. -IMPORT 'verbs.i'. -IMPORT 'messages.i'. - - - -THE testroom ISA ROOM - DESCRIPTION "This is a testroom for the beta version of a new ALAN library. - A white door leads north. A window decorates the western wall." - - EXIT north TO room2 - CHECK - IF door1 IS closed - THEN "You can't, since the door is closed." - ELSE "You walk north." - LOCATE hero AT room2. - LOCATE door1 AT room2. - END IF. - END EXIT. - - -END THE. - - -THE box ISA LISTABLE_CONTAINER - AT testroom - VERB attack DOES MAKE felix following. - MAKE dog following. - END VERB. -END THE. - - -THE table ISA SUPPORTER - AT testroom - IS NOT takeable. - VERB examine - DOES AFTER LIST table_parts. - END VERB. -END THE. - - -THE table_parts ISA OBJECT - AT testroom - CONTAINER - HEADER "In the table there are" - ELSE "" - DESCRIPTION "" -END THE. - - -THE drawer1 ISA LISTABLE_CONTAINER - IN table_parts - OPAQUE CONTAINER - NAME top drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - -THE drawer2 ISA LISTABLE_CONTAINER - IN table_parts - OPAQUE CONTAINER - NAME bottom drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - -THE secret_object ISA OBJECT - NAME secret 'object' - IN drawer1 -END THE. - - -THE door1 ISA DOOR - AT testroom - NAME white 'door' - DESCRIPTION "" -END THE. - - -THE window1 ISA WINDOW - AT testroom - NAME 'window' - DESCRIPTION "" -END THE. - - -THE flower ISA SCENERY - AT testroom -END THE. - - -THE note ISA OBJECT - IN table - IS writeable. - IS readable. - - - VERB burn - CHECK match IS lit - ELSE "How?" - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - VERB burn_with - WHEN obj1 - CHECK obj2 = match - ELSE "That's not possible." - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - -END THE. - - -THE bottle ISA LISTABLE_CONTAINER - In box -END THE. - - -THE juice ISA LIQUID - IN bottle - HAS vessel bottle. - IS drinkable. - ARTICLE "some" - - -END THE. - - -THE match ISA LIGHTSOURCE - IN table - IS natural. -END THE. - - -THE flashlight ISA LIGHTSOURCE - IN box - IS NOT natural. -END THE. - - -THE waterpistol ISA WEAPON - IN table - IS fireable. -END THE. - - -THE room2 ISA SITE - NAME '' - DESCRIPTION "This is an outdoor location. The sky is clear. In the distance you see a mountain. - The" - IF door1 IS closed - THEN "closed" - ELSE "open" - END IF. - "door back to the testroom lies to the south. There is a black hole to the north. It looks like you might just try entering it." - IF visited OF THIS = 1 - THEN "This room has not been visited before." - ELSE "This room has been visited before." - END IF. - IF described OF THIS = 0 - THEN "1111" - ELSE "over 1111" - END IF. - EXIT south TO testroom - CHECK - IF door1 IS closed - THEN "You can't, since the door is closed." - ELSE "You go back to the testroom." - LOCATE hero AT testroom. - LOCATE door1 AT testroom. - FOR EACH bg ISA background, AT room2 DO - LOCATE bg AT nowhere. - END EACH. - END IF. - END EXIT. - - - EXIT north TO room3 - DOES "You enter the black hole." - END EXIT. - -END THE. - - - -THE mountain ISA BACKGROUND - AT room2 - DESCRIPTION -END THE. - - -THE hole ISA OBJECT - AT room2 - CONTAINER -- so that it can be entered - DESCRIPTION - - VERB enter - DOES ONLY LOCATE hero AT room3. - END VERB. - -END THE. - - -THE blue_ball ISA OBJECT - AT room2 - NAME blue ball -END THE. - - -THE room3 ISA DARK_LOCATION - NAME 'The Third Location' - EXIT south TO room2. - DESCRIPTION "This the lighted third location." -END THE. - - -THE shirt ISA CLOTHING - AT room3 - IS topcover 8. -END THE. - - -THE jacket ISA CLOTHING - AT room3 - IS topcover 32. -END THE. - - -THE wallet ISA OBJECT - IN jacket -END THE. - - -THE red_ball ISA OBJECT - AT room3 - NAME red ball - VERB attack - DOES ONLY DESCRIBE ending. - END VERB. -END THE. - - -THE felix ISA NAMED_ACTOR - AT testroom - NAME felix NAME himself - HAS can_talk. - MENTIONED "Felix" - PRONOUN 'him' - - - VERB examine - DOES ONLY "Felix is a boy." - END VERB. - -END THE. - - -THE dog ISA ACTOR - AT testroom -END THE. - -THE ending ISA OBJECT - DESCRIPTION "$p$p$t$t$t$t* * *$t The end$t * * *$p" - QUIT. -END THE. - - -START AT testroom. - - \ No newline at end of file diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/verbs.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/verbs.i deleted file mode 100755 index 2791737..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-15/verbs.i +++ /dev/null @@ -1,5678 +0,0 @@ --- ALAN NEW LIBRARY: VERBS (file name: verbs.i) - - ------ This library file defines common verbs needed in gameplay. The verbs are listed alphabetically. ------ This file also includes common commands which are not actually verbs, such as inventory, ------ verbose and again. You are free to edit this file for your own purposes in any way you ------ like by adding, deleting or modifying verbs. Verbs originally defined in this file ------ are the following: - ------ VERB SYNONYM - ------ about (+ help, info) ------ again (+ g) ------ answer (+ reply) ------ ask (+ enquire, inquire, interrogate) ------ attack (+ beat, fight, hit, kick, punch) ------ attack_with ------ bite (+ chew) ------ break (+ destroy) ------ break_with ------ brief ------ burn ------ burn_with ------ buy (+ purchase) ------ catch ------ clean (+ polish, wipe) ------ climb ------ climb_on ------ climb_through ------ close ------ close_with ------ consult ------ credits (+ acknowledgments, author, copyright) ------ cut ------ cut_with ------ dance ------ dig ------ dive ------ dive_in ------ drink ------ drive ------ drop (+ discard, dump, reject) ------ eat ------ empty ------ empty_in ------ empty_on ------ enter (+ obj) ------ examine (+ check, inspect, observe, x) ------ exit (+ obj) ------ extinguish (+ put out, quench) ------ fill ------ fill_with ------ find (+ locate) ------ fire ------ flip ------ follow ------ free (+ release) ------ get_up ------ get_off ------ give ------ go_to ------ hint (+ hints) ------ inventory (+ i, inv) ------ jump ------ jump_in ------ jump_on ------ kill (+ murder) ------ kill_with ------ kiss (+ hug, embrace) ------ lie_down ------ lie_in ------ lie_on ------ lift ------ light (+ lit) ------ listen0 (= 'listen', with no object) ------ listen (= 'listen to', with an object) ------ lock ------ lock_with ------ look (+ gaze, peek) ------ look_at ------ look_behind ------ look_in ------ look_out_of ------ look_through ------ look_under ------ look_up ------ no ------ open ------ open_with ------ play ------ play_with ------ pour ------ pour_in ------ pour_on ------ pray ------ pry ------ pry_with ------ pull ------ push ------ push_with ------ put (+ lay, place) ------ put_behind ------ put_down ------ put_in (+ insert) ------ put_near ------ put_on ------ put_under ------ read ------ restart ------ restore ------ rub ------ save ------ say ------ say_to ------ score ------ search ------ sell ------ shake ------ shoot (at) ------ shoot_with ------ shout (+ scream, yell) ------ show (+ reveal) ------ sing ------ sip ------ sit (down) ------ sit_on ------ sleep (+ rest) ------ smell0 (= 'smell', with no object) ------ smell (= 'smell' with an object) ------ squeeze ------ stand (up) ------ stand_on ------ swim ------ swim_in ------ switch_on ------ switch_off ------ take (+ carry, get, grab, hold, obtain) ------ take_from (+ remove from) ------ talk ------ talk_to (+ speak) ------ taste (+ lick) ------ tear (+ rip) ------ tell (+ enlighten, inform) ------ think ------ think_about ------ throw ------ throw_at ------ tie ------ tie_to ------ touch (+ feel) ------ turn (+ rotate) ------ turn_on ------ turn_off ------ unlock ------ unlock_with ------ use ------ use_with ------ verbose ------ wait (+ z) ------ what_am_i ------ what_is ------ where_am_i ------ where_is ------ who_am_i ------ who_is ------ write ------ yes - - ------ Directions (north, south, up, etc.) are declared in the file 'locations.i'. - - ------ Verbs having to do with wearing clothes are defined in the file 'classes.i', ------ subclass 'clothing'. These verbs, together with their synonyms, are: ------ ------ remove (+ doff, take off) ------ undress ------ wear (+ don, put on) - - - - ------ We first declare some default attributes for things (= objects and actors) below. ------ These attributes are frequently checked in verb definitions to prohibit ------ the use of verbs with objects and actors in an irrational way. For example, the hero ------ won't be able to eat anything that is not edible, and so forth. - - ------ Specific object and actor attributes that override or complete the following ------ attributes are declared in 'classes.i'. - - - -ADD TO EVERY THING - - IS examinable. - inanimate. - movable. - reachable. - takeable. - - HAS text "". - - NOT broken. - NOT can_talk. - NOT closeable. - NOT closed. - NOT drinkable. - NOT edible. - NOT lit. - NOT lockable. - NOT locked. - NOT plural. - NOT readable. - NOT wearable. - NOT writeable. - -END ADD TO. - - ------ Next, we declare synonyms for some words so that it will be possible ------ for the player to type commands such as both "put ball in box" and "put ball into box", etc: - - -SYNONYMS - -into, inside = 'in'. -onto = on. -thru = through. -using = 'with'. - - - ------ The verbs and commands: - - - --- ============================================================= - - ------ ABOUT - - --- ============================================================= - - -SYNTAX 'about' = 'about'. - - -VERB 'about' - DOES - STYLE emphasized. - "This is a text adventure, also called interactive fiction, which means that what - goes on in the story depends on what you type at the prompt. Commands you can type - are for example GO NORTH (or NORTH or just N), WEST, SOUTHEAST, UP, IN etc for - moving around, but you can try many - other things too, like TAKE LAMP, DROP EVERYTHING, EAT APPLE, EXAMINE BIRD or - FOLLOW OLD MAN, to name just a few. LOOK (L) describes your surroundings, and - INVENTORY (I) lists what you are carrying. You can SAVE your game and RESTORE it - later on. - $pType CREDITS to see information about the author and the copyright issues. - $pTo stop playing and end the program, type QUIT.$p" - STYLE normal. -END VERB. - - -SYNONYMS help, info = 'about'. - - - --- ============================================================= - - ------ AGAIN (= g) - - --- ============================================================= - - -SYNTAX again = again. - - -VERB again - DOES - "[The AGAIN command is not supported in this game. As a workaround, try using - the 'up' and 'down' arrow keys to scroll through your previous commands.]" -END VERB. - - -SYNONYMS g = again. - - - --- ============================================================= - - ------ ASK (= enquire, inquire, interrogate) - - --- ============================================================= - - -SYNTAX ask = ask (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That doesn't seem to be something you can talk about with" SAY THE act. "." - - -ADD TO EVERY THING - VERB ask - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act IS reachable -- you might want to remove this check in some situations, e.g. - -- when an NPC (= a non-player character) is speaking on the phone with the hero - ELSE SAY THE act. "is too far away." - AND act <> hero - ELSE "It doesn't make much sense to ask yourself about something." - DOES - IF topic IN act - THEN SAY THE act. "doesn't seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. "chooses to be silent." - ELSIF topic = hero - THEN """I think you know more about yourself than what I do!""," SAY THE act. "snaps." - ELSE """I don't know anything about" SAY THE topic. "$$!""," SAY THE act. "snaps." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS enquire, inquire, interrogate = ask. - - ------ note that 'consult' is defined separately - - - --- ============================================================= - - ------ ATTACK (+ beat, fight, hit, punch) - - --- ============================================================= - - -SYNTAX attack = attack (obj) - WHERE obj ISA THING - ELSE "Thats not something you can $v." - - -ADD TO EVERY THING - VERB attack - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND obj NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND obj NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - -SYNONYMS beat, fight, hit, punch = attack. - --- Note that 'kick' is defined separately, to avoid absurd commands such as --- 'kick man with sword' (see 'attack_with' below) - - - --- ============================================================== - - ------ ATTACK WITH - - --- ============================================================== - - -SYNTAX attack_with = attack (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can $v." - AND obj2 ISA WEAPON - ELSE - IF obj2 ISA ACTOR - THEN - IF obj2 = hero - THEN "It doesn't make sense to attack something with yourself." - ELSE "You cannot use" SAY THE obj2. "to attack anything." - END IF. - ELSE "There's no point attacking anything with" SAY THE obj2. "." - END IF. - - -ADD TO EVERY THING - VERB attack_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can $v." - AND obj2 IS takeable - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> hero - ELSE "It doesn't make sense to $v yourself." - AND obj1 NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND obj1 NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - - --- =============================================================== - - ------ BITE (+ chew, taste) - - --- =============================================================== - - -SYNTAX bite = bite (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can bite." - - -ADD TO EVERY OBJECT - VERB bite - CHECK obj IS edible - ELSE "That's not something you should $v." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj NOT IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - - - "You take a bite of" SAY THE obj. "$$. It tastes rather good." - - END VERB. -END ADD TO. - - -SYNONYMS chew = bite. - - - --- =============================================================== - - ------ BREAK - - --- =============================================================== - - -SYNTAX break = break (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "Resorting to violence is not the answer." - ELSE "That's not something you can $v." - END IF. - - -ADD TO EVERY OBJECT - VERB break - CHECK obj IS examinable - ELSE "That's not something you can break." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - -SYNONYMS destroy = break. - - - - --- =============================================================== - - ------ BREAK WITH - - --- =============================================================== - - -SYNTAX break_with = break (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can $v." - AND obj2 ISA OBJECT - ELSE "That's not something you can $v things with." - - -ADD TO EVERY OBJECT - VERB break_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can break." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "You can't break" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ BRIEF - - --- ================================================================ - - --- Use "Visits 0." or "Visits 1000." in the START section if you want --- the game to start in verbose or brief mode. (By default, --- all games start in the verbose mode.) - - -SYNTAX brief = brief. - - -VERB brief - DOES - Visits 1000. - "Brief mode is now on. Location descriptions will only be shown - the first time you visit." -END VERB. - - - --- ================================================================= - - ------ BURN - - --- ================================================================= - - -SYNTAX burn = burn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "That would be needlessly brutal." - ELSE "That's not something you can burn." - END IF. - - -ADD TO EVERY OBJECT - VERB burn - CHECK obj IS examinable - ELSE "That's not something you can burn." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You must state what you want to burn" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ================================================================= - - ------ BURN WITH - - --- ================================================================= - - -SYNTAX burn_with = burn (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN "That would be needlessly brutal." - ELSE "That's not something you can burn." - END IF. - AND obj2 ISA OBJECT - ELSE - IF obj2 ISA ACTOR - THEN "It doesn't make sense to burn something with" SAY THE obj2. "." - ELSE "It's not possible to burn something with that." - END IF. - - -ADD TO EVERY THING - VERB burn_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can burn." - AND obj1 <> obj2 - ELSE "It doesn't make sense to burn something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - DOES - "You can't burn" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ BUY (+ purchase) - - --- ================================================================== - - -SYNTAX buy = buy (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB buy - CHECK obj IS examinable - ELSE "That's not something you can buy." - DOES - "That's not for sale." - END VERB. -END ADD TO. - - -SYNONYMS purchase = buy. - - - --- ================================================================== - - ------ CATCH - - --- ================================================================== - - -SYNTAX catch = catch (obj) - WHERE obj ISA THING - ELSE "That's not something you can catch." - - -ADD TO EVERY THING - VERB catch - CHECK obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to catch anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to catch anything while lying down." - DOES - "That doesn't need to be caught." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ CLEAN ( + wipe, polish) - - --- ================================================================== - - -SYNTAX clean = clean (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB clean - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS wipe, polish = clean. - - ------ notice that 'rub' is defined separately - - - --- ============================================================== - - ------ CLIMB - - --- ============================================================== - - -SYNTAX climb = climb (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can climb." - - -ADD TO EVERY OBJECT - VERB climb - CHECK obj IS examinable - ELSE "That's not something you can climb." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND hero IS NOT sitting - ELSE "It is difficult to climb while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb while lying down." - DOES - "That's not something you can climb." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB ON - - --- ============================================================== - - -SYNTAX climb_on = climb 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can climb on." - - -ADD TO EVERY OBJECT - VERB climb_on - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - "That's not something you can climb on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB THROUGH - - --- ============================================================== - - -SYNTAX climb_through = climb through (obj) - WHERE obj ISA THING - ELSE "That's not something you can climb through." - - -ADD TO EVERY OBJECT - VERB climb_through - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - "That's not something you can climb through." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLOSE (+ shut) - - --- ============================================================== - - -SYNTAX close = close (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB close - CHECK obj IS closeable - ELSE "That's not something you can close." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT closed - ELSE "It is already closed." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - MAKE obj closed. - "You close the" SAY THE obj. "." - END VERB. -END ADD TO. - - -SYNONYMS shut = close. - - - --- ============================================================== - - ------ CLOSE WITH - - --- ============================================================== - - -SYNTAX close_with = close (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can $v." - AND obj2 ISA OBJECT - ELSE "You can't $v anything with that." - - -ADD TO EVERY OBJECT - VERB close_with - WHEN obj1 - CHECK obj1 IS closeable - ELSE "That's not something you can $v." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS NOT closed - ELSE "It is already closed." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "You can't $v" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CONSULT - - --- ============================================================== - - -SYNTAX consult = consult (obj1) about (obj2)! - WHERE obj1 ISA THING - ELSE "That's not something you can consult." - AND obj2 ISA THING - ELSE "That's not something you can find information about." - - - consult = 'look' 'up' (obj2) 'in' (obj1). - - -ADD TO EVERY THING - VERB consult - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can consult." - AND obj1 <> hero - ELSE "It doesn't make sense to consult yourself about anything." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - IF obj1 ISA OBJECT - THEN "You find nothing useful about" SAY THE obj2. "in" SAY THE obj1. "." - ELSE SAY THE obj1. "chooses to be silent on that subject." - END IF. - END VERB. -END ADD TO. - - ---- another 'consult' formulation added to guide players to use the right phrasing: - - -SYNTAX consult_error = consult (obj) - WHERE obj ISA THING - ELSE "That's not something you can consult." - - -ADD TO EVERY THING - VERB consult_error - DOES "To consult something, use the formulation CONSULT PERSON/THING ABOUT PERSON/THING." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CREDITS (+ acknowledgments, author, copyright) - - --- ============================================================== - - -SYNTAX credits = credits. - - -VERB credits - DOES - "The author retains the copyright to this game. - $pThis game was written using the ALAN Adventure Language. ALAN is - an interactive fiction authoring system by Thomas Nilsson. - $nE-mail address: thomas.nilsson@progindus.se $pFurther information - about the ALAN system can be obtained from - the World Wide Web Internet site - $ihttp://www.alanif.se$p" -END VERB. - - -SYNONYMS acknowledgments, author, copyright = credits. - - - --- ============================================================== - - ------ CUT - - --- ============================================================== - - -SYNTAX cut = cut (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can cut." - - -ADD TO EVERY OBJECT - VERB cut - DOES "You need to specify what you want to cut" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CUT WITH - - --- ============================================================== - - -SYNTAX cut_with = cut (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can cut." - AND obj2 ISA OBJECT - ELSE "That's not something you can cut with." - - -ADD TO EVERY OBJECT - VERB cut_with - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "You can't cut something with itself." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "You can't cut" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DANCE - - --- ============================================================== - - -SYNTAX dance = dance. - - -VERB dance - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dance while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dance while lying down." - DOES - "How about a waltz?" -END VERB. - - - --- ============================================================== - - ------ DIG - - --- ============================================================== - - -SYNTAX dig = dig (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can dig." - - -ADD TO EVERY OBJECT - VERB dig - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dig anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dig anything while lying down." - DOES - "There is nothing suitable to dig here." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DIVE - - --- ============================================================== - - -SYNTAX dive = dive. - - -VERB dive - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ DIVE IN - - --- ============================================================== - - -SYNTAX dive_in = dive 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can dive into." - - -ADD TO EVERY OBJECT - VERB dive_in - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - - DOES - "That's not something you can dive into." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DRINK - - --- ============================================================== - - -SYNTAX drink = drink (obj) - WHERE obj ISA LIQUID -- see 'classes.i' - ELSE "That's not something you can drink." - - -ADD TO EVERY LIQUID - VERB drink - CHECK obj IS drinkable - ELSE "That's not something you can drink." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj NOT IN hero - THEN "(taking" SAY THE vessel OF obj. "first)$n" - LOCATE vessel OF obj IN hero. - END IF. - - "You drink all of" SAY THE obj. "." - LOCATE obj AT nowhere. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DRIVE - - --- ============================================================== - - -SYNTAX drive = drive (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can drive." - - -ADD TO EVERY OBJECT - VERB drive - DOES - "That's not something you can drive." - END VERB. -END ADD TO. - - --- another 'drive' formulation added to guide players to use the right phrasing: - - -SYNTAX drive_error = drive. - - -VERB drive_error - DOES "To drive something, use the phrasing DRIVE SOMETHING." -END VERB. - - - --- ============================================================== - - ------ DROP - - --- ============================================================== - - -SYNTAX drop = drop (obj)* - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - - drop = put (obj) * down. - - - drop = put down (obj)*. - - -ADD TO EVERY OBJECT - VERB drop - CHECK obj IN hero - ELSE "You don't have" SAY THE obj. "." - DOES - LOCATE obj HERE. - "Dropped." - END VERB. -END ADD TO. - - -SYNONYMS - discard, dump, reject = drop. - - - --- ============================================================== - - ------ EAT - - --- ============================================================== - - -SYNTAX eat = eat (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can eat." - - -ADD TO EVERY OBJECT - VERB eat - CHECK obj IS edible - ELSE "That's not something you can eat." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj NOT IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - - "You eat all of" SAY THE obj. "." - LOCATE obj AT nowhere. - - END VERB. -END ADD. - - --- ============================================================== - - ------ EMPTY - - --- ============================================================== - - - -SYNTAX 'empty' = 'empty' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - AND obj ISA CONTAINER - ELSE "You can only empty containers." - - -ADD TO EVERY OBJECT - VERB 'empty' - CHECK obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - DOES - IF obj NOT IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. - ELSE "You $v the contents of" SAY THE obj. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - EMPTY obj AT hero. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ ENTER (+ obj) - - --- ============================================================== - - -SYNTAX enter = enter (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can enter." - AND obj ISA CONTAINER - ELSE "That's not something you can enter." - - -ADD TO EVERY OBJECT - VERB enter - CHECK hero IS NOT sitting - ELSE "It is difficult to enter anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to enter anything while lying down." - DOES - "That's not something you can enter." - END VERB. -END ADD TO. - - ---- another 'enter' formulation declared to guide players to use the right formulation: - - -SYNTAX enter_error = enter. - - -VERB enter_error - DOES "You must state what you want to enter." -END VERB. - - - --- ============================================================== - - ------ EXAMINE (+ look at) - - --- ============================================================== - - -SYNTAX examine = examine (obj) - WHERE obj ISA THING - ELSE "That's not something you can examine." - - -SYNTAX examine = 'look' 'at' (obj). - examine = 'look' (obj). -- note that this formulation is allowed, too - - -ADD TO EVERY THING - VERB examine - CHECK obj IS examinable - ELSE "That's not something you can examine." - AND CURRENT LOCATION IS lit - ELSE "You can't see anything in the dark." - DOES - IF obj IS readable - THEN - IF text OF obj = "" - THEN "There is nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. ". It says ""$$" SAY text OF obj. "$$""." - END IF. - ELSE "There is nothing special about" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - 'check', inspect, observe, x = examine. - - - --- ============================================================== - - ------ EXIT (obj) - - --- ============================================================== - - -SYNTAX 'exit' = 'exit' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can exit." - AND obj ISA CONTAINER - ELSE "That's not something you can exit." - - -ADD TO EVERY OBJECT - VERB 'exit' - CHECK hero IN obj - ELSE - IF obj = current_room - THEN "You must state a direction where to go." - ELSE "But you aren't in" SAY THE obj. "!" - END IF. - DOES - "You exit" SAY THE obj. "." - LOCATE hero AT CURRENT LOCATION. - END VERB. -END ADD TO. - - ---- another 'exit' formulation added to guide players to use the right formulation: - - -SYNTAX exit_error = 'exit'. - - -VERB exit_error - DOES - "You must state what you want to exit." -END VERB. - - - --- ============================================================== - - ------ EXTINGUISH (+ put out) - - --- ============================================================== - - -SYNONYMS quench = extinguish. - - -SYNTAX extinguish = extinguish (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can extinguish." - extinguish = put 'out' (obj). - - -ADD TO EVERY OBJECT - VERB extinguish - DOES - "That's not on fire." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL - - --- ============================================================== - - -SYNTAX fill = fill (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can fill." - AND obj ISA CONTAINER - ELSE "That's not something you can fill." - - -ADD TO EVERY OBJECT - VERB fill - DOES - "You have to say what you want to fill" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL WITH - - --- ============================================================== - - -SYNTAX fill_with = fill (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can fill." - AND obj1 ISA CONTAINER - ELSE "That's not something you can fill." - AND obj2 ISA OBJECT - ELSE "It's not possible to fill something with that." - - -ADD TO EVERY OBJECT - VERB fill_with - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to fill something with itself." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - -- "That wouldn't accomplish anything." - - "You fill" SAY THE obj1. "with" SAY THE obj2. "." - LOCATE obj2 IN obj1. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIND - - --- ============================================================== - - -SYNTAX - find = find (obj)! - WHERE obj ISA THING - ELSE "That's not something you need to find." - - -ADD TO EVERY THING - VERB find - CHECK obj <> hero - ELSE "You're right here!" - AND CURRENT LOCATION IS lit - ELSE "It's too dark to find anything here." - AND obj NOT HERE - ELSE "The" SAY obj. "is right here!" - DOES - "You'll have to find it yourself." - END VERB. -END ADD TO. - - -SYNONYMS 'locate' = find. - - - --- ============================================================== - - ------ FIRE - - --- ============================================================== - - -SYNTAX fire = fire (obj) - WHERE obj ISA WEAPON - ELSE "That's not something you can fire." - - -ADD TO EVERY OBJECT - VERB fire - CHECK obj IS fireable - ELSE "That's not something you can fire." - AND obj IN hero - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You fire" SAY the obj. "into the air." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIRE AT - - --- ============================================================== - - -SYNTAX fire_at = fire (obj1) 'at' (obj2) - WHERE obj1 ISA WEAPON - ELSE "That's not something you can fire." - AND obj2 ISA THING - ELSE "That's not something you can shoot at." - - -ADD TO EVERY OBJECT - VERB fire_at - WHEN obj1 - CHECK obj1 IS fireable - ELSE "That's not something you can fire." - AND obj1 IN hero - ELSE "You don't have" SAY THE obj1. "." - AND obj2 <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - --- another formulation added: - - -SYNTAX fire_at_error = fire 'at' (obj) - WHERE obj ISA THING - ELSE "That's not something you can fire at." - - -ADD TO EVERY THING -VERB fire_at_error - CHECK COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE "You are not holding any firearm." - AND obj <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIX (mend, repair) - - --- ============================================================== - - -SYNTAX - fix = fix (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB fix - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS broken - ELSE "The" SAY obj. "doesn't need fixing." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "Please be more specific. How do you intend to fix it?" - END VERB. -END ADD TO. - - -SYNONYMS mend, repair = fix. - - - --- ============================================================== - - ------ FLIP - - --- ============================================================== - - -SYNTAX flip = flip (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can flip." - - -ADD TO EVERY OBJECT - VERB flip - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES ONLY - "That's not something you need to flip." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FOLLOW - - --- ============================================================== - - -SYNTAX follow = follow (obj)! - WHERE obj ISA THING - ELSE "That's not something you can follow." - - -ADD TO EVERY ACTOR - VERB follow - CHECK obj <> hero - ELSE "It doesn't make sense to follow yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj NOT AT hero - ELSE SAY THE obj. "is right here." - AND hero IS NOT sitting - ELSE "It is difficult to follow anybody while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to follow anybody while lying down." - AND obj NOT NEAR hero - ELSE "You follow" SAY THE obj. "." - LOCATE hero AT obj. - DOES - "You don't quite know where" SAY THE obj. "went. You must state a direction - where you want to go." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FREE (+ release) - - --- ============================================================== - - -SYNTAX free = free (obj) - WHERE obj ISA THING - ELSE "That's not something you can $v." - - -ADD TO EVERY THING - VERB free - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj <> hero - ELSE "You don't need to be freed at present." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "out of your reach." - DOES - "That doesn't need to be $vd." - END VERB. -END ADD TO. - - -SYNONYMS release = free. - - - --- ============================================================== - - ------- GET OFF - - --- ============================================================== - - -SYNTAX get_off = get off (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can get off." - - -ADD TO EVERY OBJECT - VERB get_off - DOES - IF hero IS sitting OR hero IS lying_down - THEN "You get off" SAY THE obj. "." - MAKE hero NOT lying_down. - MAKE hero NOT sitting. - ELSE "You're standing up already." - END IF. - END VERB. -END ADD TO. - - --- ============================================================== - - ------- GET UP - - --- ============================================================== - - -SYNTAX get_up = get up. - - -VERB get_up - DOES - IF hero IS sitting - THEN "You stand up." - MAKE hero NOT sitting. - ELSIF hero IS lying_down - THEN "You get up." - MAKE hero NOT lying_down. - ELSE "You're standing up already." - END IF. -END VERB. - - - --- ============================================================== - - ------ GIVE (+ hand, offer) - - --- ============================================================== - - -SYNTAX give = 'give' (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only give away objects." - AND obj2 ISA ACTOR - ELSE "That's not something you can give things to." - - - give = give (obj2) (obj1). - - -ADD TO EVERY OBJECT - VERB give - WHEN obj1 - CHECK obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to give something to itself." - AND obj2 <> hero - ELSE "It doesn't make sense to give something to yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is too far away." - AND obj1 NOT IN obj2 - ELSE SAY THE obj2. "already has" SAY THE obj1. "." - DOES - IF obj1 NOT IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - - "You give" SAY THE obj1. "to" SAY THE obj2. "." - LOCATE obj1 IN obj2. - - END VERB. -END ADD TO. - - -SYNONYMS hand, offer = give. - - - --- ============================================================== - - ------ GO TO - - --- ============================================================== - - -SYNTAX go_to = 'to' (obj)! -- because 'go' is predefined in the parser, it can't be used - WHERE obj ISA THING -- in verb definitions - ELSE "It's not possible to go to that." - - -ADD TO EVERY THING - VERB go_to - CHECK obj <> hero - ELSE "You're right here!" - AND hero IS NOT sitting - ELSE "It is difficult to go anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to go anywhere while lying down." - DOES - IF obj AT hero - THEN - IF obj IS NOT reachable - THEN "You can't reach" SAY THE obj. "from here." - ELSE - IF CURRENT LOCATION IS lit - THEN "That's right here!" - ELSE "It is too dark to see." - END IF. - END IF. - ELSE "You can't see" SAY THE obj. "anywhere nearby. You must state a - direction where you want to go." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS walk = go. -- here we define a synonym for the predefined parser word 'go' - -- which is not visible in the syntax itself. - -- Thus, you will be able to say e.g. both 'go to shop' and 'walk to shop' - -- (as well as e.g. both 'go east' and 'walk east'). - - - --- ============================================================== - - ------ HELP -> see ABOUT - - --- ============================================================== - - - - - --- ============================================================== - - ------ HINT (+ hints) - - --- ============================================================== - - -SYNTAX hint = hint. - - -VERB hint - DOES - "Unfortunately hints are not available in this game." -END VERB. - - -SYNONYMS - hints = hint. - - - --- ============================================================== - - ------ INVENTORY (+ i, inv) - - --- ============================================================== - - -ADD TO EVERY THING - IS weight 0. -END ADD TO THING. - - -ADD TO EVERY ACTOR - IS weight 50. -END ADD TO ACTOR. - - -ADD TO EVERY OBJECT - IS weight 5. -END ADD TO OBJECT. - - -SYNTAX i = i. - - -VERB i - DOES - LIST hero. - - IF COUNT IN worn > 0 -- see the file 'classes.i', subclass 'clothing' - THEN LIST worn. - END IF. - - -- if the hero in your game carries any containers you want the contents of - -- to be listed after 'inventory', you should manually add the listing right here - -- according to the following example: - -- - -- IF bag IN hero - -- THEN LIST bag. - -- END IF. - -- - -- This way, 'inventory' will yield e.g. "You are carrying a bag. The bag contains a book." - -- If you leave the above addition out, the outcome will be just "You are carrying a bag.", with - -- no comment on what is inside the bag. - -END VERB. - - -SYNONYMS inv, inventory = i. - - - --- ============================================================== - - ------ JUMP - - --- ============================================================== - - -SYNTAX jump = jump. - - -VERB jump - CHECK hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "You jump on the spot, to no avail." -END VERB. - - - --- ============================================================== - - ------ JUMP IN - - --- ============================================================== - - -SYNTAX jump_in = jump 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can jump into." - AND obj ISA CONTAINER - ELSE "That's not something you can jump into." - - -ADD TO EVERY OBJECT - VERB jump_in - CHECK CURRENT LOCATION IS lit - ELSE "It's too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - IF obj ISA SUPPORTER - THEN "That's not something you can jump into." - ELSE "That wouldn't accomplish anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ JUMP ON - - --- ============================================================== - - -SYNTAX jump_on = jump 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can jump on." - AND obj ISA SUPPORTER - ELSE "That's not something you can jump on." - - -ADD TO EVERY OBJECT - VERB jump_on - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - --- ============================================================= - - ------ KICK - - --- ============================================================= - - -SYNTAX kick = kick (obj) - WHERE obj ISA THING - ELSE "Thats not something you can kick." - - -ADD TO EVERY THING - VERB kick - CHECK obj IS examinable - ELSE "That's not something you can kick." - AND obj <> hero - ELSE "It doesn't make sense to kick yourself." - AND obj NOT IN hero - ELSE "It doesn't make much sense to kick something you're holding." - AND obj NOT IN worn - ELSE "It doesn't make sense to kick something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - DOES "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL (+ murder) - - --- ============================================================== - - -SYNTAX kill = kill (obj) - WHERE obj ISA ACTOR - ELSE "That's not something you can $v." - - -ADD TO EVERY ACTOR - VERB kill - CHECK obj <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL WITH - - --- ============================================================== - - -SYNTAX kill_with = kill (obj1) 'with' (obj2) - WHERE obj1 ISA ACTOR - ELSE "That's not something you can $v." - AND obj2 ISA WEAPON - ELSE "You cannot kill anybody with" SAY THE obj2. "." - - -ADD TO EVERY ACTOR - VERB kill_with - WHEN obj1 - CHECK obj1 <> hero - ELSE "There's no need to be that desperate." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ KISS (+ hug, embrace) - - --- ============================================================== - - -SYNTAX kiss = kiss (obj) - WHERE obj ISA THING - ELSE "That's not something you can kiss." - - -ADD TO EVERY THING - VERB kiss - CHECK obj IS examinable - ELSE "That's not something you can kiss." - AND obj <> hero - ELSE "There is no time for that now." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj ISA ACTOR - THEN SAY THE obj. "avoids your advances." - ELSE "Nothing would be achieved by that." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS hug, embrace = kiss. - - - --- ============================================================== - - ------ KNOCK - - --- ============================================================== - - -SYNTAX knock = knock 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can knock on." - - - knock = knock (obj). - - -ADD TO EVERY OBJECT - VERB knock - CHECK obj IS examinable - ELSE "That's not something you can knock on." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You knock on" SAY THE obj. "$$. Nothing happens." - END VERB. -END ADD TO. - - ---- another 'knock' formulation added to guide players to use the right phrasing: - - -SYNTAX knock_error = knock. - - -VERB knock_error - DOES - "Please use the formulation KNOCK ON SOMETHING to knock on something." -END VERB. - - - --- ============================================================== - - ------ LIE DOWN - - --- ============================================================== - - -SYNTAX lie_down = lie 'down'. - - - lie_down = lie. - - -VERB lie_down - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down right now." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down." - -- MAKE hero lying_down. -END VERB. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE IN - - --- ============================================================== - - -SYNTAX lie_in = lie 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can lie in." - AND obj ISA CONTAINER - ELSE "That's not something you can lie in." - - - lie_in = lie 'down' 'in' (obj). - - -ADD TO EVERY OBJECT - VERB lie_in - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down in" SAY THE obj. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down in" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE ON - - --- ============================================================== - - -SYNTAX lie_on = lie 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can lie on." - - - lie_on = lie 'down' 'on' (obj). - - -ADD TO EVERY OBJECT - VERB lie_on - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down on" SAY THE obj. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down on" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIFT - - --- ============================================================== - - -SYNTAX lift = lift (obj) - WHERE obj ISA THING - ELSE "That's not something you can lift." - - -ADD TO EVERY THING - VERB lift - CHECK obj IS examinable - ELSE "That's not something you can lift." - AND obj IS reachable - ELSE "The object is too far away." - AND obj IS movable - ELSE "That's not something you can lift." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND obj <> hero - ELSE "It doesn't make sense to lift yourself." - AND obj NOT IN hero - ELSE "You're already holding" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LIGHT (+ lit) - - --- ============================================================== - - -SYNTAX light = light (obj) - WHERE obj ISA LIGHTSOURCE - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB light - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "That's not something you can $v." - END VERB. -END ADD TO. - - -SYNONYMS lit = light. - - - --- ============================================================== - - ------ LISTEN - - --- ============================================================== - - -SYNTAX listen0 = listen. - - -VERB listen0 - DOES - "You hear nothing unusual." -END VERB. - - - --- ============================================================== - - ------ LISTEN TO - - --- ============================================================== - - -SYNTAX listen = listen 'to' (obj)! - WHERE obj ISA THING - ELSE "That's not something you can listen to." - - -ADD TO EVERY THING - VERB listen - CHECK obj <> hero - ELSE "It doesn't make sense to listen to yourself." - DOES - IF obj AT hero - THEN "You hear nothing unusual." - ELSIF obj NEAR hero - THEN "You can't hear" SAY THE obj. "very well from here." - ELSE "You can't hear anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK - - --- ============================================================== - - -SYNTAX lock = lock (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can lock." - - -ADD TO EVERY OBJECT - VERB lock - CHECK obj IS lockable - ELSE "That's not something you can lock." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS NOT locked - ELSE "It's already locked." - DOES - "You have to state what you want to lock" SAY THE obj. "with." - -- If you need this to work, use the following lines instead: - -- MAKE obj locked. "You" - -- IF obj IS NOT closed - -- THEN "close and" - -- MAKE obj closed. - -- END IF. - -- "lock" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK WITH - - --- ============================================================== - - -SYNTAX lock_with = lock (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can lock." - AND obj2 ISA OBJECT - ELSE "You can't lock anything with that." - - -ADD TO EVERY OBJECT - VERB lock_with - WHEN obj1 - CHECK obj1 IS lockable - ELSE "That's not something you can lock." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS NOT locked - ELSE "It's already locked." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE - "You don't have" SAY THE obj2. "." - DOES - "You can't lock" SAY THE obj1. "with" SAY THE obj2. "." - -- If you need this to work, use the following lines instead: - -- MAKE obj1 locked. "You" - -- IF obj1 IS NOT closed - -- THEN "close and" - -- MAKE obj1 closed. - -- END IF. - -- "lock" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK - - --- ============================================================== - - -SYNTAX 'look' = 'look'. - - -VERB 'look' - DOES - LOOK. - INCREASE described OF CURRENT LOCATION. -- see 'locations.i', attribute 'described'. -END VERB. - - -SYNONYMS l = 'look'. - - - --- ============================================================== - - ------ LOOK AT -> see EXAMINE - - --- ============================================================== - - - - - --- ============================================================== - - ------ LOOK BEHIND - - --- ============================================================== - - -SYNTAX look_behind = 'look' behind (obj) - WHERE obj ISA THING - ELSE "You can't look behind that." - - -ADD TO EVERY THING - VERB look_behind - CHECK obj IS examinable - ELSE - "You can't look behind" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj <> hero - ELSE "Turning your head, you notice nothing unusual behind yourself." - DOES - "You notice nothing unusual behind" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK IN - - --- ============================================================== - - -SYNTAX - look_in = 'look' 'in' (obj) - WHERE obj ISA OBJECT - ELSE "You can't look inside" SAY THE obj. "." - AND obj ISA CONTAINER - ELSE "You can't look inside" SAY THE obj. "." - - -ADD TO EVERY OBJECT - VERB look_in - CHECK obj IS examinable - ELSE - "You can't look inside" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - - DOES - LIST obj. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK OUT OF - - --- ============================================================== - - -SYNTAX look_out_of = 'look' 'out' 'of' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can look out of." - - -ADD TO EVERY OBJECT - VERB look_out_of - CHECK obj IS examinable - ELSE - "You can't look out of" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That's not something you can look out of." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK THROUGH - - --- ============================================================== - - -SYNTAX look_through = 'look' through (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can look through." - - -ADD TO EVERY OBJECT - VERB look_through - CHECK obj IS examinable - ELSE "You can't look through" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't see through" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UNDER - - --- ============================================================== - - -SYNTAX look_under = 'look' under (obj) - WHERE obj ISA THING - ELSE "You can't look under that." - - -ADD TO EVERY THING - VERB look_under - CHECK obj IS examinable - ELSE "You can't look under" SAY THE obj. "." - AND obj <> hero - ELSE "It doesn't make sense to look under yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You notice nothing unusual under" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UP (-> see also CONSULT) - - --- ============================================================== - - -SYNTAX look_up = 'look' up. - - -VERB look_up - DOES "Looking up, you see nothing unusual." -END VERB. - - - --- ============================================================== - - ------ NO - - --- ============================================================== - - -SYNTAX 'no' = 'no'. - - -VERB 'no' - DOES "You sound rather negative." -END VERB. - - - --- ============================================================== - - ------ OPEN - - --- ============================================================== - - -SYNTAX open = open (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can open." - - -ADD TO EVERY OBJECT - VERB open - CHECK obj IS closeable - ELSE "That's not something you can open." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS closed - ELSE SAY THE obj. "is already open." - AND obj IS NOT locked - ELSE SAY THE obj. "appears to be locked." - DOES - MAKE obj NOT closed. - "You open" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ OPEN WITH - - --- ============================================================== - - -SYNTAX open_with = open (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can open." - AND obj2 ISA OBJECT - ELSE "You can't open anything with" SAY THE obj2. - - -ADD TO EVERY OBJECT - VERB open_with - WHEN obj1 - CHECK obj1 IS closeable - ELSE "That's not something you can open." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 IS closed - ELSE SAY THE obj1. "is already open." - AND obj1 IS NOT locked - ELSE SAY THE obj1. "appears to be locked." - - DOES - "You can't open" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY - - --- ============================================================== - - -SYNTAX 'play' = 'play' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can play." - - -ADD TO EVERY OBJECT - VERB 'play' - DOES - "That's not something you can play." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY WITH - - --- ============================================================== - - -SYNTAX play_with = 'play' 'with' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can play with." - - -ADD TO EVERY OBJECT - VERB play_with - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "After second thoughts you don't find it purposeful to start playing with" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR - - --- ============================================================== - - -SYNTAX pour = pour (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can pour." - AND obj ISA CONTAINER - ELSE "That's not something you can pour." - - -ADD TO EVERY OBJECT -VERB pour - CHECK obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - DOES - IF obj NOT IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - - "You pour the contents of" SAY THE obj. "onto" - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - LOCATE obj AT hero. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR IN - - --- ============================================================== - - - -SYNTAX pour_in = pour (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pour." - AND obj2 ISA CONTAINER - ELSE "That's not something you can pour." - AND obj2 ISA OBJECT - ELSE "That's not something you can pour things into." - AND obj2 ISA CONTAINER - ELSE SAY THE obj2. "is not something you can pour things into." - - -ADD TO EVERY OBJECT -VERB pour_in - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to $v something into itself." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 NOT DIRECTLY IN obj2 - ELSE SAY THE obj1. "is already in" SAY THE obj2. "." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 IS NOT closed - ELSE "You can't, since" SAY THE THIS. "is closed." - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - DOES - IF obj1 NOT IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - - "You pour" SAY THE obj1. "into" SAY THE obj2. "." - LOCATE obj1 IN obj2. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR ON - - --- ============================================================== - - - -SYNTAX pour_on = pour (obj1) 'on' (obj2) - WHERE obj1 ISA LIQUID - ELSE "You can only pour liquids." - AND obj2 ISA OBJECT - ELSE - IF obj2 ISA ACTOR - THEN - IF obj2 = hero - THEN "That wouldn't make sense." - ELSE "That wouldn't be polite." - END IF. - ELSE "You can't $v anything onto" SAY THE obj2. "." - END IF. - AND obj2 ISA CONTAINER - ELSE SAY THE obj2. "is not something you can pour things onto." - - - -ADD TO EVERY OBJECT -VERB pour_on - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to $v something on itself." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 IS NOT closed - ELSE "You can't, since" SAY THE obj1. "is closed." - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - DOES - IF obj1 NOT IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - - IF obj2 = floor OR obj2 = ground - THEN LOCATE obj1 AT hero. - "You pour the contents" SAY THE obj1. "on" SAY THE obj2. "." - ELSIF obj2 ISA SUPPORTER - THEN LOCATE obj1 IN obj2. - "You pour the contents" SAY THE obj1. "on" SAY THE obj2. "." - ELSE "It wouldn't be sensible to pour anything on" SAY THE obj2. - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PRAY - - --- ============================================================== - - -SYNTAX pray = pray. - - -VERB pray - DOES "Your prayers don't seem to help right now." -END VERB. - - - --- ============================================================== - - ------ PRY - - --- ============================================================== - - -SYNTAX pry = pry (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can pry." - - -ADD TO EVERY OBJECT -VERB pry - DOES "You must state what you want to pry" SAY THE obj. "with." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PRY_WITH - - --- ============================================================== - - -SYNTAX pry_with = pry (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pry." - AND obj2 ISA OBJECT - ELSE "You can't pry anything with that." - - -ADD TO EVERY OBJECT -VERB pry_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can pry." - AND obj1 <> obj2 - ELSE "How intelligent." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES "That doesn't work." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PULL - - --- ============================================================== - - -SYNTAX pull = pull (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense to pull yourself." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE "That's not something you can pull." - END IF. - - -ADD TO EVERY OBJECT -VERB pull - CHECK obj IS movable - ELSE "It's not possible to pull" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES "That wouldn't accomplish anything." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUSH - - --- ============================================================== - - -SYNTAX push = push (obj) - WHERE obj ISA THING - ELSE "That's not something you can push." - - -ADD TO EVERY OBJECT - VERB PUSH - CHECK obj IS movable - ELSE "That's not something you can push." - AND obj NOT IN hero - ELSE "But you're holding" SAY THE obj. "." - AND obj <> hero - ELSE "It doesn't make sense to push yourself." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You give" SAY THE obj. "a little push. Nothing happens." - END VERB. -END ADD TO. - - -SYNONYMS press = push. - - - --- ============================================================== - - ------ PUSH WITH - - --- ============================================================== - - -SYNTAX push_with = push (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can push." - AND obj2 ISA OBJECT - ELSE "You can use only objects to push things with." - - -ADD TO EVERY OBJECT - VERB push_with - WHEN obj1 - CHECK obj1 IS movable - ELSE "That's not something you can push." - AND obj1 <> obj2 - ELSE "It doesn't make sense to push something with itself." - AND obj1 NOT IN hero - ELSE "But you're holding" SAY THE obj1. "." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> hero - ELSE "It doesn't make sense to push yourself with something." - AND obj1 IS inanimate - ELSE SAY THE obj1. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "Using" SAY THE obj2. "you push" SAY THE obj1. "$$. Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT (+ lay, locate, place) - - --- ============================================================== - - -SYNTAX put = put (obj) - WHERE obj ISA OBJECT - ELSE "You can't put that anywhere." - - -ADD TO EVERY OBJECT - VERB put - CHECK obj IN HERO - ELSE "You don't have" SAY THE obj. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You must state where you want to put it." - END VERB. -END ADD TO. - - -SYNONYMS lay, place = put. - - - --- ============================================================== - - ------ PUT DOWN (works as 'drop') - - --- ============================================================== - - ------ The syntax for 'put down' has been declared in the 'drop' verb. - - - - - --- ============================================================== - - ------ PUT IN (+ insert) - - --- ============================================================== - - -SYNTAX put_in = put (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN - IF obj1 = hero - THEN "It doesn't make sense to put yourself into something." - ELSE SAY THE obj1. "wouldn't probably appreciate that." - END IF. - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA OBJECT - ELSE "That's not something you can put things in." - AND obj2 ISA CONTAINER - ELSE "You can't put anything there." - - - put_in = insert (obj1) 'in' (obj2). - - -ADD TO EVERY OBJECT - VERB put_in - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to put something into itself." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND obj1 NOT IN obj2 - ELSE - IF obj2 ISA SUPPORTER - THEN "You can't put" SAY THE obj1. "inside" SAY THE obj2. "." - ELSE SAY THE obj1. "is in" SAY THE obj2. "already." - END IF. - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - IF obj1 NOT IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - - LOCATE obj1 IN obj2. - "You put" SAY THE obj1. "into" SAY THE obj2. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT BEHIND, NEAR, UNDER - - --- ============================================================== - - -SYNTAX put_near = put (obj1) 'near' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything near that." - - - put_behind = put (obj1) behind (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything behind that." - - - put_under = put (obj1) under (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything under that." - - -ADD TO EVERY OBJECT - VERB put_near, put_behind, put_under - WHEN obj1 - CHECK obj2 NOT IN hero - ELSE "That would be futile." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - - AND obj1 <> obj2 - ELSE "That doesn't make sense." - AND obj2 <> hero - ELSE "That would be futile." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - "That wouldn't accomplish anything." - - -- To make it work, type e.g.: - -- IF obj1 NOT IN hero - -- THEN "(taking" SAY THE obj1. "first)$n" - -- END IF. - -- "You put" SAY THE obj1. "near" --(or behind or under) SAY THE obj2. "." - -- (+ you would need to define some attributes to check that the object is behind another - -- object, etc.) - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT_ON - - --- ============================================================== - - --- To use this verb in the meaning 'wear', see the file 'classes.i', class 'clothing', verb 'wear'. - --- You can put things on the floor/ground or on a supporter. In other cases, the response will be --- "That wouldn't accomplish anything." - - - -SYNTAX put_on = put (obj1) 'on' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN - IF obj1 = hero - THEN "That would be futile." - ELSE SAY THE obj1. "wouldn't probably appreciate that." - END IF. - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA OBJECT - ELSE "You can't well put anything on that." - AND obj2 ISA CONTAINER - ELSE "You can't well put anything on that." - - -ADD TO EVERY OBJECT - VERB put_on - WHEN obj1 - CHECK obj2 NOT IN hero - ELSE "That would be futile." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "That doesn't make sense." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is on" SAY THE obj2. "already." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - IF obj1 NOT IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - - IF obj2 = floor OR obj2 = ground - THEN LOCATE obj1 AT hero. - "You put" SAY THE obj1. "on" SAY THE obj2. "." - ELSIF obj2 ISA SUPPORTER - THEN LOCATE obj1 IN obj2. - "You put" SAY THE obj1. "on" SAY THE obj2. "." - ELSE "That wouldn't accomplish anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT OUT (works as -> EXTINGUISH) - - --- ============================================================== - - ------ The syntax for 'put out' has been declared in the 'extinguish' verb. - - - --- ============================================================== - - ------ QUIT - - --- ============================================================== - - -SYNTAX - 'quit' = 'quit'. - - -VERB 'quit' - DOES - QUIT. -END VERB. - - -SYNONYMS q = 'quit'. - - - --- ============================================================== - - ------ READ - - --- ============================================================== - - -SYNTAX read = read (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can read." - - -ADD TO EVERY OBJECT - VERB read - CHECK obj IS readable - ELSE - "That's not something you can read." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - DOES - IF text OF obj = "" - THEN "There's nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. ". It says ""$$" SAY text OF obj. "$$""." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - --- REMOVE - - --- ============================================================== - - --- see the file 'classes.i', subclass 'clothing' for the definition of --- this verb - - - - - --- ============================================================== - - ------ REMOVE FROM ( => TAKE FROM) - - --- ============================================================== - - ------ this verb works as 'take from' - - - --- ============================================================== - - ------ RESTART - - --- ============================================================== - - -SYNTAX 'restart' = 'restart'. - - -VERB 'restart' - DOES - RESTART. -END VERB. - - - --- ============================================================== - - ------ RESTORE - - --- ============================================================== - - -SYNTAX 'restore' = 'restore'. - - -VERB 'restore' - DOES - RESTORE. -END VERB. - - - --- ============================================================== - - ------ RUB (+ massage) - - --- ============================================================== - - -SYNTAX rub = rub (obj) - WHERE obj ISA THING - ELSE "That's not something you can rub." - - -ADD TO EVERY THING - VERB rub - CHECK obj IS examinable - ELSE "That's not something you can rub." - AND obj <> hero - ELSE "There's no time for that now." - AND obj IS inanimate - ELSE "You aren't sure whether" SAY THE obj. "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS massage = rub. - - - --- ============================================================== - - ------ SAVE - - --- ============================================================== - - -SYNTAX 'save' = 'save'. - - -VERB 'save' - DOES - SAVE. -END VERB. - - - --- ============================================================== - - ------ SAY - - --- ============================================================== - - -SYNTAX 'say' = 'say' (str) - WHERE str ISA STRING - ELSE "That's not something you can say." - - -ADD TO EVERY THING - VERB 'say' - DOES - "You utter" SAY str. "$$. Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SAY TO - - --- ============================================================== - - -SYNTAX say_to = 'say' (str) 'to' (act) - WHERE str ISA STRING - ELSE "Nothing happens." - AND act ISA ACTOR - ELSE "That's not something you can talk to." - - -ADD TO EVERY THING - VERB say_to - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act IS reachable - ELSE SAY THE act. "is too far away." - DOES - SAY THE act. "doesn't seem interested." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SCORE - - --- ============================================================== - - -SYNTAX 'score' = 'score'. - - -VERB 'score' - DOES - SCORE. - -- (or, if you wish to disable the score, use the following kind of - -- line instead of the above:) - -- "There is no score in this game." -END VERB 'score'. - - - --- ============================================================== - - ------ SCRATCH - - --- ============================================================== - - -SYNTAX scratch = scratch (obj) - WHERE obj ISA THING - ELSE "That's not something you can scratch." - - -ADD TO EVERY THING - VERB scratch - CHECK obj IS examinable - ELSE "That's not something you can scratch." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND obj <> hero - ELSE "That wouldn't help matters." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------- SEARCH - - --- ============================================================== - - -SYNTAX search = search (obj) - WHERE obj ISA THING - ELSE "That's not something you can search." - - -ADD TO EVERY THING - VERB search - CHECK obj <> hero - ELSE LIST hero. - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You find nothing of interest." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SELL - - --- ============================================================== - - -SYNTAX sell = sell (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can sell." - - -ADD TO EVERY OBJECT - VERB sell - CHECK obj IS examinable - ELSE "That's not something you can sell." - DOES - "There's nobody here who would be interested to buy" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHAKE - - --- ============================================================== - - -SYNTAX shake = shake (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense to shake yourself." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE "That's not something you can shake." - END IF. - - -ADD TO EVERY OBJECT -VERB shake - CHECK obj IS examinable - ELSE "That's not something you can shake." - AND obj IS movable - ELSE "Shaking" SAY THE obj. "is not possible." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj IN hero - THEN "You shake" SAY THE obj. "cautiously in your hands. Nothing happens." - ELSE "There is no reason to start shaking" SAY THE obj. "." - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOOT - - --- ============================================================== - - - -SYNTAX shoot = shoot (obj) - WHERE obj ISA THING - ELSE "That's not something you can shoot." - shoot = shoot 'at' (obj). - -ADD TO EVERY THING - VERB shoot - CHECK obj <> hero - ELSE "There's no need to be that desperate." - AND COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE "You don't have anything to shoot with." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - --- another 'shoot' formulation added, to guide players to use the right phrasing: - - -SYNTAX shoot_error = shoot. - - -VERB shoot_error - DOES "You must state what you want to shoot, e.g. SHOOT BEAR WITH RIFLE." -END VERB. - - - --- ============================================================== - - ------ SHOOT WITH - - --- ============================================================== - - -SYNTAX shoot_with = shoot (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can shoot." - AND obj2 ISA WEAPON - ELSE "That's not something you can shoot with." - - shoot_with = shoot (obj2) 'at' (obj1). - -- to allow player input such as 'shoot rifle at bear' - - -ADD TO EVERY THING - VERB shoot_with - WHEN obj1 - CHECK obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 IS examinable - ELSE "That's not something you can shoot." - AND obj2 IS fireable - ELSE "That's not something you can shoot with." - AND obj1 <> hero - ELSE "There's no need to be that desperate." - AND obj1 <> obj2 - ELSE "It doesn't make sense to shoot something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOUT - - --- ============================================================== - - -SYNTAX shout = shout. - - -VERB shout - DOES - "Nothing results from your $ving." -END VERB. - - -SYNONYMS scream, yell = shout. - - - --- ============================================================== - - ------ SHOW - - --- ============================================================== - - -SYNTAX 'show' = 'show' (obj1) 'to' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can show." - AND obj2 ISA ACTOR - ELSE "That's not something you can show things to." - - -ADD TO EVERY THING - VERB 'show' - WHEN obj1 - CHECK obj1 IN hero - ELSE "You don't have" SAY THE obj1. "." - AND obj2 <> hero - ELSE "It doesn't make sense to show something to yourself." - AND obj1 <> obj2 - ELSE "It doesn't make sense to show something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - SAY THE obj2. "is not especially interested." - END VERB. -END ADD TO. - - -SYNONYMS reveal = 'show'. - - - --- ============================================================== - - ------ SING (+ hum, whistle) - - --- ============================================================== - - -SYNTAX sing = sing. - - -VERB sing - DOES - "You $v a little tune." -END VERB. - - -SYNONYMS hum, whistle = sing. - - - --- ============================================================== - - ------ SIP - - --- ============================================================== - - -SYNTAX sip = sip (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can drink." - - -ADD TO EVERY OBJECT - VERB sip - CHECK obj IS drinkable - ELSE "That's not something you can drink." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj NOT IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - - LOCATE obj IN hero. - "You take a sip of" SAY THE obj. "$$. It tastes rather good." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SIT - - --- ============================================================== - - -SYNTAX sit = sit. - - - sit = sit 'down'. - - -VERB sit - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - DOES - "You feel no urge to sit down at present." - -- (or, if you wish to make it work, use the following instead of the above: - -- IF hero IS lying_down - -- THEN "You sit up." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down." - -- END IF. - -- MAKE hero sitting. -END VERB. - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SIT_ON - - --- ============================================================== - - -SYNTAX sit_on = sit 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can sit on." - - -ADD TO EVERY SUPPORTER - VERB sit_on - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You feel no urge to sit down at present." - -- (or, to make it work, use the following instead of the above:) - -- IF hero lying_down - -- THEN "You get up and sit down on" SAY THE obj. "." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down on" SAY THE obj. "." - -- END IF. - -- LOCATE hero IN obj. - -- MAKE hero sitting. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SLEEP (+ rest) - - --- ============================================================== - - -SYNTAX sleep = sleep. - - -VERB sleep - DOES - "There's no need to $v right now." -END VERB. - - -SYNONYMS rest = sleep. - - - --- ============================================================== - - ------ SMELL (smell0) - - --- ============================================================== - - -SYNTAX smell0 = smell. - - -VERB smell0 - DOES - "You smell nothing unusual." -END VERB. - - - --- ============================================================== - - ------ SMELL (+ obj) - - --- ============================================================== - - -SYNTAX smell = smell (obj)! - WHERE obj ISA THING - ELSE "That's not something you can smell." - - -ADD TO EVERY THING - VERB smell - DOES - IF obj ISA SOUND - THEN "That's not something you can smell." - ELSE "You smell nothing unusual." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SQUEEZE - - --- ============================================================== - - -SYNTAX squeeze = squeeze (obj) - WHERE obj ISA THING - ELSE "That's not something you can squeeze." - - -ADD TO EVERY THING - VERB squeeze - CHECK obj IS examinable - ELSE "That's not something you can squeeze." - AND CURRENT LOCATION IS lit - ELSE - IF obj = hero - THEN "Nothing would be achieved by that." -- you can squeeze yourself in the dark, as well - ELSE "It is too dark to see." - END IF. - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - - DOES - IF obj ISA ACTOR - THEN "That wouldn't be polite." - ELSE "That's not possible." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ STAND - - --- ============================================================== - - -SYNTAX stand = stand. - - - stand = stand 'up'. - - -VERB stand - CHECK hero IS NOT lying_down - ELSE "You get up." - MAKE hero NOT lying_down. - AND hero IS NOT sitting - ELSE "You stand up." - MAKE hero NOT sitting. - DOES - "You're standing up already." -END VERB. - - - --- ============================================================== - - ------ STAND_ON - - --- ============================================================== - - -SYNTAX stand_on = stand 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can stand on." - - - stand_on = get 'on' (obj). - - -ADD TO EVERY SUPPORTER -VERB stand_on - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You feel no urge to stand on" SAY THE obj. "." - -- or, to make it work, use the following instead of the above: - -- "You get on" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero NOT sitting. MAKE hero NOT lying_down. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWIM - - --- ============================================================== - - -SYNTAX swim = swim. - - -VERB swim - CHECK hero IS NOT sitting - ELSE "It is difficult to try swimming while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to try swimming while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ SWIM IN - - --- ============================================================== - - -SYNTAX swim_in = swim 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can swim in." - AND obj ISA CONTAINER - ELSE "That's not something you can swim in." - - -ADD TO EVERY OBJECT -VERB swim_in - CHECK hero IS NOT sitting - ELSE "It is difficult to swim anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to swim anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That's not something you can swim in." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH - - --- ============================================================== - - --- This is a mere 'switch' verb with no 'on' or 'off' following after it. --- This verb is defined further in 'classes.i', under 'device' and 'lightsource'. --- This verb exists just to cover cases where the player forgets to write --- 'on' or 'off' after 'switch'. --- If the player types 'switch tv', the tv object will be switched on --- if it is off, and vice cersa. --- Below, just the basic syntax is declared. - - - -SYNTAX switch = switch (obj) - WHERE obj ISA THING - ELSE "That's not something you can switch." - - -ADD TO EVERY THING - VERB switch - DOES "That's not something you can switch." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH ON - - --- ============================================================== - - ------ The syntax for 'switch on' has been declared in the 'turn_on' verb. - - - - --- ============================================================== - - ------ SWITCH OFF - - --- ============================================================== - - ------ The syntax for 'switch off' has been declared in the 'turn_off' verb. - - - - --- ============================================================== - - ------ TAKE (+ carry, get, grab, hold, obtain, pick up) - - --- ============================================================== - - -SYNTAX take = take (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "Taking yourself is not possible." - ELSE SAY THE obj. "would probably object to that." - END IF. - ELSE "That's not something you can take." - END IF. - - - take = get (obj). - - - take = pick up (obj). - - - take = pick (obj) up. - - -ADD TO EVERY OBJECT - VERB take - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS takeable - ELSE - IF obj ISA SCENERY - THEN "Unimportant for your purposes, you leave the" SAY THE obj. "where it is." - ELSE "That's not something you can take." - END IF. - AND obj IS movable - ELSE SAY THE obj. "is much too heavy for you to move." - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND weight Of obj <=50 - ELSE SAY THE obj. "is too heavy to lift." - DOES - IF obj DIRECTLY IN hero -- i.e. the object to be taken is carried by the hero already - THEN "You already have" SAY THE obj. "." - ELSIF obj DIRECTLY IN worn -- i.e. the object to be taken is a piece of clothing that the player character is wearing; - -- here, this verb works in practise like 'take off'. - THEN "You take off" SAY THE obj. "and carry it in your hands." - LOCATE obj IN hero. - ELSE "Taken." -- this covers also cases where the object to be taken is in another container, - LOCATE obj IN hero. -- such as a wallet that is in a jacket the hero is carrying or wearing. - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - carry, grab, hold, obtain = take. - - - --- ============================================================== - - ------ TAKE FROM - - --- ============================================================== - - -SYNTAX take_from = 'take' (obj1) 'from' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only take objects." - AND obj2 ISA THING - ELSE "It's not possible to take things from there." - AND obj2 ISA CONTAINER - ELSE "It's not possible to take things from there." - - - take_from = remove (obj1)* 'from' (obj2). - - - take_from = get (obj1) 'from' (obj2). - - -ADD TO EVERY OBJECT - VERB take_from - WHEN obj1 - CHECK obj2 <> hero - ELSE "You can't take things from yourself!" - AND obj1 NOT IN hero - ELSE "You already have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "You can't take something from itself!" - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IN obj2 - ELSE - IF obj2 IS inanimate - THEN SAY THE obj1. "is not in" SAY THE obj2. "." - ELSE SAY THE obj2. "doesn't have" SAY THE obj1. "." - END IF. - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - AND obj1 IS movable - ELSE SAY THE obj1. "is much too heavy for you to take." - AND obj1 IS takeable - ELSE - IF obj1 ISA SCENERY - THEN "Unimportant for your purposes, you leave the" SAY THE obj1. "where it is." - ELSE "That's not something you can take." - END IF. - AND weight Of obj1 <=50 - ELSE SAY THE obj1. "is too heavy." - DOES - LOCATE obj1 IN hero. - "You take" SAY THE obj1. "from" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TALK - - --- ============================================================== - - -SYNTAX talk = talk. - - -VERB talk - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING - or TELL PERSON ABOUT THING." -END VERB. - - - --- ============================================================== - - ------ TALK_TO - - --- ============================================================== - - -SYNTAX talk_to = talk 'to' (act) - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - - -ADD TO EVERY THING - VERB talk_to - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - -SYNTAX talk_to_a = talk 'to' (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That's not something you can talk about." - - -ADD TO EVERY THING - VERB talk_to_a - WHEN act - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - --- ============================================================== - - ------ TASTE (+ lick) - - --- ============================================================== - - -SYNTAX taste = taste (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can taste." - - -ADD TO EVERY OBJECT - VERB taste - CHECK obj IS examinable - ELSE "That's not something you can taste." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES "You taste nothing unexpected." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TEAR (+ rip) - - --- ============================================================== - - -SYNTAX tear = tear (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can tear." - - -ADD TO EVERY OBJECT - VERB tear - CHECK obj IS examinable - ELSE "That's not something you can tear." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "That would be futile." - END VERB. -END ADD TO. - - -SYNONYMS rip = tear. - - - --- ============================================================== - - ------ TELL (+ enlighten, inform) - - --- ============================================================== - - -SYNTAX tell = tell (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That doesn't seem to be something you can talk about with" SAY THE act. "." - - -ADD TO EVERY THING - VERB tell - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act IS reachable - ELSE SAY THE act. "is too far away." - AND act <> hero - ELSE "It doesn't make much sense to tell yourself about something." - DOES - IF topic IN act - THEN SAY THE act. "doesn't seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. "chooses to be silent." - ELSIF topic = hero - THEN SAY THE act. "doesn't seem interested." - ELSE SAY THE act. "doesn't seem interested." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS enlighten, inform = tell. - - - --- ============================================================== - - ------ THINK (+ ponder, meditate, reflect) - - --- ============================================================== - - -SYNTAX think = think. - - -VERB think - DOES - "Nothing helpful comes to your mind." -END VERB. - - -SYNONYMS ponder, meditate, reflect = think. - - - --- ============================================================== - - ------ THINK ABOUT - - --- ============================================================== - - -SYNTAX think_about = think 'about' (obj) - WHERE obj ISA THING - ELSE "That's not something fruitful to think about." - - -ADD TO EVERY THING - VERB think_about - DOES - "Nothing helpful comes to your mind." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW (+ cast) - - --- ============================================================== - - -SYNTAX throw = throw (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can throw." - - -ADD TO EVERY OBJECT - VERB throw - CHECK obj IS examinable - ELSE "That's not something you can throw." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj NOT IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - - "You can't throw very far;" SAY THE obj. "ends up on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj AT hero. - - END VERB. -END ADD TO. - - -SYNONYMS - cast = throw. - - - --- ============================================================== - - ------ THROW AT (+ throw to) - - --- ============================================================== - - -SYNTAX throw_at = throw (obj1) 'at' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only throw objects." - AND obj2 ISA THING - ELSE "It's not possible to throw things at that." - - - throw_to = throw (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only throw objects." - AND obj2 ISA THING - ELSE "It's not possible to throw things to that." - - -ADD TO EVERY OBJECT - VERB throw_at, throw_to - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can throw." - AND obj2 IS examinable - ELSE "That's not something you can throw things at." - AND obj1 <> obj2 - ELSE "It doesn't make sense to throw something at itself." - AND obj2 NOT IN hero - ELSE "You are carrying" SAY THE obj2. "." - AND obj2 <> hero - ELSE "You cannot throw things at yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is too far away." - DOES - IF obj1 NOT IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - - IF obj2 IS inanimate - THEN "The" SAY obj1. "bounces harmlessly off" SAY THE obj2. "and ends up on the" - IF floor HERE - - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj1 HERE. - ELSE "The" SAY obj2. "catches" SAY THE obj1. "and tosses" - IF obj1 IS NOT plural - THEN "it" - ELSE "them" - END IF. - "back to you. You grab hold of" - IF obj1 IS NOT plural - THEN "it" - ELSE "them" - END IF. - - "again." - END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------- THROW IN - - --- ============================================================== - - -SYNTAX throw_in = throw (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can throw." - AND obj2 ISA OBJECT - ELSE "That's not something you can throw things into." - AND obj2 ISA CONTAINER - ELSE "That's not something you can throw things into." - - -ADD TO EVERY OBJECT - VERB throw_in - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can throw." - AND obj2 IS examinable - ELSE "That's not something you can throw things into." - AND obj1 <> obj2 - ELSE "It doesn't make sense to throw something into itself." - AND obj2 <> hero - ELSE "You can't throw" SAY THE obj1. "into yourself! (If you wish to eat or drink - something, just say so.)" - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is in" SAY THE obj2. "already!" - AND obj2 IS reachable - ELSE SAY THE obj2. "is too far away." - DOES - IF obj1 NOT IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - - LOCATE obj1 IN obj2. - "You throw" SAY THE obj1. "into" SAY THE obj2. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE - - --- ============================================================== - - -SYNTAX tie = tie (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can tie." - - -ADD TO EVERY OBJECT - VERB tie - DOES - "You must state where do you want to tie" SAY obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE TO - - --- ============================================================== - - -SYNTAX tie_to = tie (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can tie." - AND obj2 ISA OBJECT - ELSE "Nothing can be tied to that." - - -ADD TO EVERY OBJECT - VERB tie_to - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can tie." - AND obj2 IS examinable - ELSE "That's not something you can tie things to." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to tie something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - IF obj1 NOT IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - - LOCATE obj1 IN hero. - "It's not possible to tie" SAY THE obj1. "to" SAY THE obj2. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TOUCH - - --- ============================================================== - - -SYNTAX touch = touch (obj) - WHERE obj ISA THING - ELSE "That's not something you can touch." - - -ADD TO EVERY THING - VERB touch - CHECK obj IS examinable - ELSE "That's not something you can touch." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS inanimate - ELSE "You are not sure whether" SAY THE obj. "would appreciate that." - DOES - "You feel nothing unexpected." - END VERB. -END ADD TO. - - -SYNONYMS feel = touch. - - - --- ============================================================== - - ------ TOUCH WITH - - --- ============================================================== - - -SYNTAX touch_with = touch (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can touch." - AND obj2 ISA OBJECT - ELSE "You can only use objects to touch with." - - -ADD TO EVERY THING - VERB touch_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can touch." - AND obj2 IS examinable - ELSE "That's not something you can touch things with." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to touch something with itself." - AND obj1 IS inanimate - ELSE "You are not sure whether" SAY THE obj1. "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "You touch" SAY THE obj1. "with" SAY THE obj2. ". Nothing special happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN (+ rotate) - - --- ============================================================== - - -SYNTAX turn = turn (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can turn." - - - turn = rotate (obj). -- we don't declare 'rotate' a synonym for 'turn' - -- through a SYNONYMS statement as we don't want - -- it to be possible for the player to type something - -- like 'rotate tv on' (see 'turn on' and 'turn off' below) - - -ADD TO EVERY OBJECT - VERB turn - CHECK obj IS examinable - ELSE "That's not something you can turn." - AND obj IS movable - ELSE "It's not possible to turn" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES "You turn" SAY THE obj. - IF obj IN hero - THEN "in your hands" - END IF. - "$$. You notice nothing unusual about it" - IF obj NOT IN hero - THEN "and return it to its original position" - END IF. - "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN ON - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These subclasses are defined in 'classes.i' ------ with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. Trying to turn on or off ------ an ordinary object will default here to "That's not something you can turn on". - - -SYNTAX turn_on = turn 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v on." - - turn_on = switch 'on' (obj). - - - turn_on = turn (obj) 'on'. - - - turn_on = switch (obj) 'on'. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', subclass 'device'. --- This verb merely covers cases where the player forgets to type 'on' or 'off'. - - - -ADD TO EVERY OBJECT - VERB turn_on - DOES - "That's not something you can $v on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN OFF - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These subclasses are defined in 'classes.i' ------ with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. - - -SYNTAX turn_off = turn off (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v off." - - turn_off = switch off (obj). - - - turn_off = turn (obj) off. - - - turn_off = switch (obj) off. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', subclasses 'device' and 'lightsource'. --- This verb merely covers cases where the player forgets to type 'on' or 'off'. - - -ADD TO EVERY OBJECT - VERB turn_off - DOES - "That's not something you can $v off." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE - - --- ============================================================== - - -SYNTAX 'use' = 'use' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can use." - - -ADD TO EVERY OBJECT - VERB 'use' - DOES - "Please be more specific. How do you intend to use it?" - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE WITH - - --- ============================================================== - - -SYNTAX use_with = 'use' (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only use objects." - AND obj2 ISA OBJECT - ELSE "You can only use objects." - - -ADD TO EVERY OBJECT - VERB use_with - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "You can't use something with itself." - DOES - "Please be more specific. How do you intend to use them together?" - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ UNDRESS - - --- ============================================================== - - --- See the file 'classes.i', subclass CLOTHING for the definition --- of this verb. - - - - - --- ============================================================== - - ------ UNLOCK - - --- ============================================================== - - -SYNTAX unlock = unlock (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can unlock." - - -ADD TO EVERY OBJECT - VERB unlock - CHECK obj IS lockable - ELSE "That's not something you can unlock." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS locked - ELSE "It's already unlocked." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You must state what you want to unlock" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ UNLOCK WITH - - --- ============================================================= - - -SYNTAX unlock_with = unlock (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can unlock." - AND obj2 ISA OBJECT - ELSE "You can't unlock anything with that." - - -ADD TO EVERY OBJECT - VERB unlock_with - WHEN obj1 - CHECK obj1 IS lockable - ELSE "That's not something you can unlock." - AND obj2 In hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to unlock something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS locked - ELSE "It's already unlocked." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - SAY THE obj2. "doesn't unlock" SAY THE obj1. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ VERBOSE (see also -> BRIEF) - - --- ============================================================== - - -SYNTAX verbose = verbose. - - -VERB verbose - DOES - VISITS 0. - "Verbose mode is now on. Location descriptions will be always shown in full." -END VERB. - - - --- ============================================================== - - ------ WAIT (= z) - - --- ============================================================== - - -SYNTAX 'wait' = 'wait'. - - -VERB 'wait' - DOES - "Time passes..." -END VERB. - - -SYNONYMS - z = 'wait'. - - - --- ============================================================== - - ------ WHAT AM I - - --- ============================================================== - - -SYNTAX what_am_i = 'what' am i. - - -VERB what_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHAT IS - - --- ============================================================== - - -SYNTAX what_is = 'what' 'is' (obj)! - WHERE obj ISA THING - ELSE "That's not something I know about." - - -ADD TO EVERY THING - VERB what_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHERE AM I - - --- ============================================================== - - -SYNTAX where_am_i = 'where' am i. - - -VERB where_am_i - DOES - LOOK. -END VERB. - - - --- ============================================================== - - ------ WHERE IS - - --- ============================================================== - - -SYNTAX where_is = 'where' 'is' (obj)! - WHERE obj ISA THING - ELSE "That's not something I know about." - - -ADD TO EVERY THING - VERB where_is - CHECK obj NOT AT hero - ELSE "That's right here!" - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHO AM I - - --- ============================================================== - - -SYNTAX who_am_i = who am i. - - -VERB who_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHO IS - - --- ============================================================== - - -SYNTAX who_is = 'who' 'is' (act)! - WHERE act ISA ACTOR - ELSE "That's not somebody I know." - - -ADD TO EVERY ACTOR - VERB who_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WRITE - - --- ============================================================== - - -SYNTAX write = write (str) 'on' (obj) - WHERE str ISA STRING - ELSE "Please state inside double quotes ("""") what you want to write." - AND obj ISA OBJECT - ELSE "Nothing can be written there." - - - write = write (str) 'in' (obj). - - -ADD TO EVERY OBJECT - VERB write - WHEN obj - CHECK obj IS writeable - ELSE "Nothing can be written there." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF text OF obj = "" - THEN SET text OF obj TO str. - ELSE SET text OF obj TO text OF obj + " " + str. - END IF. - "You write ""$$" SAY str. "$$"" on" SAY THE obj. "." - MAKE obj readable. - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ YES - - --- ================================================================ - - -SYNTAX yes = yes. - - -VERB yes - DOES "You sound rather positive." -END VERB. - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/classes.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/classes.i deleted file mode 100755 index 0fcc63c..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/classes.i +++ /dev/null @@ -1,2035 +0,0 @@ --- ALAN NEW LIBRARY: CLASSES (file name: 'classes.i') - - --- This library file defines various object and actor classes, as well as the --- instance 'hero'(=the player character). Many of these classes are frequently --- used in verb definitions in 'verbs.i' so they should be edited or --- removed with caution. - - --- Contents: - - - --- 1. OBJECT CLASSES --- ================= - - --- BACKGROUND - -- Is present in the location but cannot be reached or taken. - -- Doesn't appear automatically in room descriptions. - -- A typical example of a background would be for example the sun, - -- or a mountain visible in the distance. - -- Compare this with 'scenery' below (a background object cannot be reached, - -- but a scenery object can.) - - --- CLOTHING - -- Is a piece of clothing that behaves according to Alan Bampton's 'xwear.i' extension. - -- The said extension has been fully assimilated to this library. - -- This extension prevents clothes from being worn in an illogical order, e.g. you - -- cannot put on a shirt if you are already wearing a jacket, and so forth. - -- Also the verbs 'wear', 'remove' and 'undress' are defined here. - - --- DEVICE - -- Is a machine or an electronic device, for example a TV. Can be turned - -- (=switched) on and off if it is not broken. - -- Attributes: 'on' and NOT 'on', NOT broken. - -- Is described automatically as being either on or off when examined. - - --- DOOR - -- Can be opened, closed, locked and unlocked. - -- Is by default closed, not locked. - -- Attributes: closeable, (NOT) closed, lockable, (NOT) locked. - -- Is described automatically as being either open or closed when examined. - - --- LIQUID - -- Can only be taken if it is in a container. You can fill something with it, - -- and you can pour it somewhere. - -- A liquid is by default NOT drinkable. - - --- LIGHTSOURCE - -- IS natural or NOT natural - -- (a natural lightsource is for example a match or a torch). - -- Can be turned on and off, lighted and extinguished (= put out) if it - -- is not broken. A natural lightsource - -- cannot be turned on or off, it can only be lighted and extinguished (= put out). - -- When examined, a lightsource is automatically supplied with a description of - -- whether it is providing light or not. - - --- LISTABLE_CONTAINER - -- Is a special kind of container, the contents of which will be listed both after - -- 'look' (= in the room description), 'look in' and 'examine' (if the container is open). - -- (The contents of a normal container object are not listed after 'examine' but only - -- after 'look' (=room description) and 'look in'). - - --- SCENERY - -- Behaves like a normal object, can be reached and manipulated but not taken. - -- The default message for 'take' will be "Unimportant for your purposes, you decide to - -- leave the [object] where it is." - -- The default message for 'examine' will be "The [object] doesn't appear particularly - -- interesting." - -- A scenery object is not automatically listed after the room description when - -- you type 'look'. You have to include it manually in the room description. - -- Compare this with 'background' above (a scenery object can be reached, - -- but a background object cannot.) - - --- SOUND - -- Can be listened to but not examined, searched, smelled or manipulated. - -- Cannot initially be turned on or off, this has to be implemented manually by giving - -- the sound the 'switchable' attribute. - - --- SUPPORTER - -- You can put things on this and you can stand on this. It is declared a container, - -- so you can take things from it, as well. When there's something on a supporter, - -- an automatic listing of it will appear in the room description and after 'examine'. - - --- WEAPON - -- IS fireable (e.g. a cannon) or NOT fireable (e.g. a baseball bat). - - --- WINDOW - -- Can be opened, closed, looked through and out of. - -- Will be automatically described as being either open or closed when examined. - - - --- 2. ACTOR CLASSES --- ================ - --- the ACTORS are defined here to be NOT inanimate CONTAINERS (so that they can e.g. --- receive and carry things. The 'contents' (= possessions) of an actor (except for the hero) --- are automatically listed after 'look' and 'examine'. (For the hero, the command 'inventory' --- must be used.) --- --- Actors are, like objects, usually preceded by an article in-game: --- e.g. "You see a man here." --- "There is nothing special about the dog." --- --- The following classes for actors are defined in this library: - - --- NAMED_ACTOR - -- has no article in front of the name when mentioned - -- e.g. "You see Spot here." - -- is not able to talk; this class is useful e.g. when defining animals - --- PERSON - -- has an article in front when mentioned (e.g. "a boy") - -- is able to talk - - --- NAMED_PERSON - -- has no article in front of the name when mentioned (e.g. "Jim") - -- is able to talk - - --- + instructions for expressing male and female actors with 'PRONOUN him' or 'PRONOUN her'. - - - --- 3. INSTANCES --- ============ - - --- the hero - - - - --- The contents end here. - - - --- ============================================================= - --- ============================================================= --- --- 1. Object classes --- --- ============================================================= - --- ============================================================= - - - --- ============================================================= - - ------ BACKGROUND - - --- ============================================================= - - -EVERY background ISA THING - IS NOT reachable. - DESCRIPTION "" -END EVERY. - - --- Note that a background object in ALAN3 is different from the backdrop in Inform7 --- in that a background object is at one location at a time only, unless --- you use the nested locations feature in ALAN which makes the object available --- in several locations. --- Here is an example where a ceiling lamp is located in the lobby, the bedroom --- and the living-room of a house, but not in other locations: - - --- 1) First, define the area where the object(s) should be found: - --- THE lamp_rooms ISA LOCATION -- i.e. the area in which we'll nest --- END THE. -- the three rooms mentioned above - --- and then define which locations belong to that area: - --- THE lobby ISA LOCATION IN lamp_rooms --- END THE. - --- THE bedroom ISA LOCATION IN lamp_rooms --- END THE. - --- THE livingroom ISA LOCATION IN lamp_rooms --- END THE. - - - --- 2) Then, place the background object in the area: - --- THE ceiling_lamp ISA BACKGROUND IN lamp_rooms --- NAME ceiling lamp --- END THE. - - --- Now, the lamp is found in all of the above locations. - --- Note that in this code you could define exits to other rooms of the house in the --- normal way, without having to worry about the area at all, e.g.: - --- THE bedroom ISA LOCATION IN lamp_rooms --- EXIT west TO upstairs_landing. --- END THE. - --- THE upstairs_landing ISA LOCATION -- ( = a location outside the defined area) --- EXIT east TO bedroom. --- END THE. - --- etc. - --- Naturally, you could also define a scenery object or a normal object to be --- in several locations at once, in the same way. Note, however, that if you define --- a takeable object in this manner, it will disappear from the other locations once --- you take it in one location. Also, when manipulated (e.g. broken), the object --- will be affected in all of the locations it is found. - - - --- ============================================================== - - ------ CLOTHING (+ the verbs WEAR, REMOVE, UNDRESS) - - --- ============================================================== - - --- To use this class, see the documentation text right after the --- code below. --- This class makes use of Alan Bampton's 'xwear.i' extension --- written originally for ALAN V2, converted here to V3 and --- assimilated fully to the present library. Thanks to Alan Bampton --- for the permission to use the code here. - - ------------------------------------------------------------------ --- First, we declare the container for clothing. ------------------------------------------------------------------ - - -THE worn ISA ENTITY -- an entity is present everywhere and thus the hero's - CONTAINER TAKING CLOTHING. -- clothing is always accessible - HEADER "You are wearing" - ELSE "You're not wearing anything." -END THE. - - -------------------------------------------------------------------- --- Next, we define the syntaxes for verbs needed for putting on --- and taking off clothing. -------------------------------------------------------------------- - - -SYNTAX wear = wear (obj) - WHERE obj ISA CLOTHING - ELSE "That's not something you can wear." - wear = put 'on' (obj). - wear = put (obj) 'on'. - wear = don (obj). - -SYNTAX remove = remove (obj) - WHERE obj ISA CLOTHING - ELSE "That's not something you can remove since you're not wearing it." - remove = take 'off' (obj). - remove = take (obj) 'off'. - remove = doff (obj). - -SYNTAX undress = undress. - - -------------------------------------------------------------------- --- Now, we define some common attributes for clothing as well as --- how the above verbs behave with this class. -------------------------------------------------------------------- - - -EVERY clothing ISA OBJECT - - IS wearable. - IS sex 0. - IS headcover 0. - IS handscover 0. - IS feetcover 0. - IS topcover 0. - IS botcover 0. - - CONTAINER -- to allow e.g. a wallet to be put into a jacket - - - VERB wear - - CHECK THIS NOT IN worn - ELSE "You are already wearing" SAY THE THIS. "." - AND THIS IS takeable - ELSE "You can't pick" SAY THE THIS. "up." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND sex OF THIS = sex OF hero OR sex OF THIS = 0 - ELSE - "On second thoughts you decide" - SAY THE THIS. "really won't suit a" - IF sex OF hero =1 - THEN "man" - ELSE "woman" - END IF. - "like you at all." - - - DOES ONLY - - --------------------------------------------------------------------- --- 'wear_flag' is a multi-purpose flag used for several purposes in --- this library, here it is reset to 0 before proceeding as a matter --- of 'housekeeping' for the code. --------------------------------------------------------------------- - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- First check to see if the player is carrying the item already, if --- not, set the 'wear_flag' to 1 to indicate the item was picked up --- in this turn. --------------------------------------------------------------------- - - - IF THIS NOT IN hero - THEN - SET wear_flag OF hero TO 1. - END IF. - - --------------------------------------------------------------------- --- Now see if the player can put this item on by testing --- all of its coverage attributes against the player's state. --------------------------------------------------------------------- - - --------------------------------------------------------------------- --- First check the 'topcover' attributes, if 'obj' fails this test --- then it means the hero is already wearing clothes that cover the --- topcover area and those clothes are of the same layer or a layer --- that belongs on top of the 'obj' item. In either case it would --- NOT be possible to put on the 'obj'. To 'flag' this condition add --- 5 to the 'wear_flag' attribute as an indicator this test failed. --------------------------------------------------------------------- - - - IF topcover OF THIS <> 0 AND topcover OF THIS <= SUM OF topcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - --- IF THIS IN tempworn THEN - IF handscover OF THIS <> 0 AND handscover OF THIS <= SUM OF handscover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF feetcover OF THIS <> 0 AND feetcover OF THIS <= SUM OF feetcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF headcover OF THIS <> 0 AND headcover OF THIS <= SUM OF headcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case, adjust the 'tempcovered OF hero' --- attribute so that the code rejects non sensible options. --- First of all, discount any coatlike clothes as these never --- affect ability to put on other lower body only garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 and botcover OF THIS < 33 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not technically affect ability to put on lower body only clothes. --- Special clause here excludes the full body coverage 'teddy' type --- garment - as a skirt WOULD prevent that from being removed. --- ( dress/coat garments automatically prevent this by virtue of --- having higher 'topcover' settings than the teddy ) --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 AND botcover OF THIS < 16 and botcover OF THIS <> 4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- IF tempcovered OF hero is still > 15 then must have trousers --- type clothing on - therefore disallow wearing dress type clothing --- because, although technically possible, it is not very sensible. --------------------------------------------------------------------- - - - IF tempcovered OF hero >15 AND botcover OF THIS > 16 - THEN - SET tempcovered OF hero TO tempcovered OF hero +16. - END IF. - - --------------------------------------------------------------------- --- From here down, clothes DO work as they do for other areas. --------------------------------------------------------------------- - - - IF botcover OF THIS <> 0 AND botcover OF THIS <= tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- At this point, 'wear_flag' will be 0 if the obj was held by the --- player and can be put on, or l if he picked it up this turn and --- it can be put on. Any higher value means one or more of the --- tests failed and the player cannot put on these clothes. --------------------------------------------------------------------- - - - IF wear_flag OF hero >1 THEN - IF THIS NOT IN hero - THEN "You pick up the" SAY THE THIS. "." - END IF. - LOCATE THIS IN hero. - EMPTY worn IN tempworn. - LIST tempworn. - "Trying to put" - SAY THE THIS. - "on isn't very sensible." - EMPTY tempworn IN worn. - ELSIF wear_flag OF hero = 1 - THEN - LOCATE THIS IN worn. - "You pick up the" SAY THE THIS. - IF THIS IS plural - THEN - "and put them on." - ELSE - "and put it on." - END IF. - ELSE - LOCATE THIS IN worn. - "You put on" SAY THE THIS. "." - END IF. - -END VERB. - - - -VERB remove - CHECK THIS IN worn - ELSE - "You are not wearing" SAY THE THIS. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - - DOES ONLY - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- Check the total 'topcover' of items worn. Because of the number --- sequence used, by dividing the sum of the worn attributes by two --- and then comparing the result to the individual 'topcover' of the --- obj in question, ( the former can only ever be greater than the --- latter if an article of clothing is worn that goes over 'obj' ) --- it's easy to tell if the obj ought to be removable. A temporary --- attribute is used here because it needs to be manipulated. Once --- again 'wear_flag' is used to indicate the results. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF topcover IN worn /2. - IF topcover OF THIS <> 0 AND topcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF handscover IN worn /2. - IF handscover OF THIS <> 0 AND handscover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF feetcover IN worn /2. - IF feetcover OF THIS <> 0 AND feetcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF headcover IN worn /2. - IF headcover OF THIS <> 0 AND headcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case - first discount any coatlike clothes --- as these do not affect ability to take off other lower garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not affect ability to take off other lower garments. The 'teddy' --- type garment is expressly NOT included in the exclusion here. --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 and botcover OF THIS <>4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- Now process the manipulated value just as was done for the others --------------------------------------------------------------------- - - - SET tempcovered OF hero TO tempcovered OF hero /2. - IF botcover OF THIS <> 0 AND botcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Depending on the value of 'wear_flag' print and process the obj --- as needed. If 'wear_flag' is NOT 0 then the clothes cannot be --- removed. --------------------------------------------------------------------- - - - IF wear_flag OF hero >0 THEN - LIST worn. - "Trying to take" SAY THE THIS. "off isn't very sensible." - ELSE - LOCATE obj IN hero. - "You take off" SAY THE THIS. "." - END IF. -END VERB. - - -VERB examine - DOES AFTER - IF THIS IS NOT OPAQUE - THEN - IF COUNT ISA OBJECT, IN THIS > 0 -- if the piece of clothing contains - THEN LIST THIS. -- something, e.g. if a jacket contains a wallet, - END IF. -- the wallet will be mentioned when the - END IF. -- jacket is examined -END VERB. - - -END EVERY. - - --------------------------------------------------------------------- --- The verb 'undress' needs to be defined outside the object class --- as it is intransitive: --------------------------------------------------------------------- - - -VERB undress - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF COUNT IN worn, ISA CLOTHING > 0 - THEN "You don't feel like undressing is a good idea right now." - ELSE "You're not wearing anything you can remove." - END IF. - - -- or, to make it work, use the following lines instead: - --IF COUNT IN worn, ISA CLOTHING > 0 - --THEN EMPTY worn IN hero. - --"You remove all the items you were wearing." - --ELSE "You're not wearing anything you can remove." - -- END IF. -END VERB. - - - --------------------------------------------------------------------- --- These attributes are used internally in the library - ignore! --------------------------------------------------------------------- - -ADD TO EVERY ACTOR - IS tempcovered 0. - IS wear_flag 0. - IS sex 0. -END ADD TO. - - --------------------------------------------------------------------- --- A container used to provide a temporary storage space - ignore! --------------------------------------------------------------------- - -THE tempworn ISA OBJECT - CONTAINER TAKING CLOTHING. - HEADER "You're already wearing" -END THE tempworn. - - - ------------------------------------------------------------------------ --- DOCUMENTATION FOR CLOTHING ------------------------------------------------------------------------ - - --- The quick guide ------------------- - --- Here is a quick overview for using the class 'clothing'. A more closely-detailed --- description of this class is found below this overview. - - --- A piece of clothing in your game code should look something similar to these four examples: - - --- THE jacket ISA CLOTHING AT lobby --- IS topcover 32. --- END THE. - - --- THE jeans ISA CLOTHING IN wardrobe --- IS botcover 16. --- END THE. - - --- THE hat ISA CLOTHING IN worn -- IN worn = worn by the player character --- IS headcover 2. --- END THE. - - --- THE sweater ISA CLOTHING IN joe_worn -- = worn by an NPC called Joe. --- IS topcover 16. -- Define separate containers like this --- END THE. -- for clothes worn by non-player characters. - -- If you defined here 'IN joe', the clothing - -- would be listed in Joe's possessions: - -- "You see Joe here. Joe is carrying a book and - -- a sweater." - - --- In defining a piece of clothing, you should --- 1) define it ISA CLOTHING (and not: ISA OBJECT) --- 2) give it one of five attributes 'headcover', 'topcover', botcover', 'footcover' --- or 'handcover'; sometimes two of these are needed. --- Which attribute(s) to use depends on the type of clothing; see the clothing table below. --- 3) A number 2, 4, 8, 16, 32 or 64 needs to be added after the above attribute. --- You cannot decide the number yourself; look it up from the clothing table below. --- If the value of an attribute for a piece of clothing is 0 in the table, don't mention --- this attribute in connection with your clothing object. - - --- The above is enough; the rest is then handled automatically by the library. - - --- The quick guide ends here. The clothing table follows right below. The text following the --- table gives more details about the principles and the use of this class. - - --- The clothing table ------------------------ - - --- Here is the chart showing a selection of fairly typical clothing items and the values to --- set to obtain appropriate behaviour. Should you wish to create an article of clothing not --- listed, usually a bit of lateral thought as to what it is most like and where it fits into --- the scheme of things will suggest a workable set of values, but be aware that you MUST use --- values in this chart, simply adding things with intermediate values is probably going to --- create nasty bugs: - - --- Clothing Headcover Topcover Botcover Footcover Handcover - --- hat 2 0 0 0 0 --- vest/bra 0 2 0 0 0 --- undies/panties 0 0 2 0 0 --- teddy 0 4 4 0 0 --- blouse/shirt/T-shirt 0 8 0 0 0 --- dress/coveralls 0 8 32 0 0 --- skirt 0 0 32 0 0 --- trousers/shorts 0 0 16 0 0 --- sweater/pullover 0 16 0 0 0 --- jacket 0 32 0 0 0 --- coat 0 64 64 0 0 --- socks/stockings 0 0 0 2 0 --- tights/pantiehose 0 0 8 2 0 --- shoes/boots 0 0 0 4 0 --- gloves 0 0 0 0 2 - - - --- The concept of "xwear.i" (This and the following paragraphs are taken from Alan ---------------------------- -- Bampton's original 'xwear' documentation, with minor - -- alterations.) - - --- The basic idea behind this part of the library is that clothing is worn in --- 'layers' and it is rather silly to allow players to (say) take off or put --- on a shirt if they are wearing a jacket. To simulate this in ALAN I've chosen --- to apply a numeric based layering system, and divide the body into five zones --- of coverage. The zones are 'head', 'hands', 'feet', 'top' (for top half of torso) --- and 'bot' (for bottom half of torso). --- All objects have these five zones defined as default attributes (set to 0), for the --- head zone the attribute is headcover for the hands zone handscover and so on. --- Every clothing object will thus need one or more of its 'zonecover' attributes --- set to reflect the zone(s) it covers and its relative position in the layers of --- clothing worn. A simple example would be a shirt, this covers only the 'top' zone --- and so needs its topcover attribute to be set (to 8, just why it's 8 will become --- clear shortly). --- The principle used is that the closer to the skin an item is normally worn, --- the lower its 'cover' attribute is. The library operates on the assumption that --- items with higher value cover attributes for a particular zone are worn over items --- with lower value attributes. When a player attempts to put on an article of clothing, --- each zone it would affect is checked and compared to the related zonal total of any --- clothes already worn. If the value of the new clothing is not greater that the total(s) --- of clothing already worn (on a zone by zone basis) then the library will not allow --- the wearing of that item. There are a few notable exceptions to this rule, but --- I'll come back to those a little later. - - --- How it works in practice ---------------------------- - - --- This part of the library might sound complex, but it is actually very simple to use, --- here's an example of how it works. --- Assume our hero starts the game wearing just vest and shorts and the player issues --- the command 'put on shirt'. A quick check of the chart below should reveal that a shirt --- has only its topcover attribute set to non-zero, (all the other zones are zero, --- which means they are irrelevant for this item). --- The library totals the topcover attributes of all the clothes currently worn, like so:- --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- As there are no other clothes to consider, the library now compares the topcover attribute --- of the item we are attempting to put on, (a shirt with a topcover attribute of 8 in --- this case) to the total value of items already worn (2). --- Because the topcover attribute of the shirt (8) is greater than the calculated total (2), --- this is evaluated as being a 'legal' instruction and the library allows the shirt to be put on. --- Now consider the situation had the player started the game wearing vest, shorts and a jacket, --- this is what happens should he try to 'put on the shirt.' --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- Finally the library checks the jacket, this has a topcover attribute of 32, so total --- topcover is 2 + 32 = 34. --- Because the topcover attribute of the shirt (8) is now not greater than the calculated --- total (34), this is evaluated as being an 'illegal' instruction and the library won't --- allow the shirt to be put on. --- That demonstrates the basic principle of the library, removing clothes uses a variation --- of the 'compare to total' equation to allow / disallow removal of clothing, an example would --- be that our vest, shorts and jacket wearing player would NOT be allowed to remove --- the vest while he still had the jacket on. - - --- Exceptions to the rule... ----------------------------- - - --- Now I'll confuse the issue. Firstly the numbers in my chart are not born of some sort of --- weird fixation with multiples, there is a very good reason why the numbers are set as they --- are, computer/maths types will recognise the sequence and realise it is all 'binary' based --- and know it makes it possible to calculate exactly what the player is wearing in terms of --- layers. --- Some female clothing breaks the rules defined above and is not so easy to deal with. An example, --- although pantyhose is worn under a skirt, dress or coat it can actually be put on or removed --- with the garment worn over it still on. The library recognises this capability and deals with --- it properly by assigning the dress/skirt and coat items particular properties in that they --- don't affect the ability to wear or remove lower layer clothing that covers the bottom of --- the torso only. --- Although it's physically possible to put on/remove trousers while wearing a skirt or dress, --- this (and a few other neat dressing/undressing tricks) is considered illegal here. - - --- How to create clothes that use 'xwear.i' -------------------------------------------- - - --- That covers the way the library works, here's how to define objects to actually make --- use of it. As an example, this is how to define a dress and restrict it to being worn --- by a female. - - --- THE dress ISA CLOTHING IN changingroom - -- NAME little black dress - -- MENTIONED "little black dress" - -- IS - -- botcover 32. - -- topcover 8. - -- sex 2. --- END THE. - - --- Notice that it is only necessary to mention the attributes that are non-zero, this --- minimises the amount of coding required. Apart from making sure the hero is set as --- 'sex 2.' if we wish her to be able to wear this dress, this is all the author needs --- to do, the library will police what is wearable and keep track of things without any --- further work. --- I expect most authors would prefer to start their games with a player at least partially --- dressed. This is just a matter of defining the required clothes object as being in the --- 'worn' container. Here's how to define underwear that our female hero(ine?) starts --- the game wearing. - - --- THE bra ISA CLOTHING IN worn - -- NAME white bra - -- MENTIONED "white bra" - -- IS - -- topcover 2. - -- sex 2. --- END THE bra. - - --- THE panties ISA CLOTHING IN worn - -- NAME white panties - -- MENTIONED "white panties" - -- IS - -- botcover 2. - -- plural. - -- sex 2. --- END THE panties. - - --- The library as it stands also prevents wearing of duplicate clothes, or things that are --- logically mutually exclusive - e.g. the player can wear a dress or a skirt, but not both. - - - --- ============================================================= - - ------ DEVICE - - --- ============================================================= - - -EVERY device ISA OBJECT - IS NOT 'on'. - - - VERB examine - DOES - IF THIS IS 'on' - THEN "It is currently on." - ELSE "It is currently off." - END IF. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT 'on' - ELSE SAY THE THIS. "is already on." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS 'on'. - END VERB. - - - VERB turn_off - CHECK THIS IS 'on' - ELSE SAY THE THIS. "is already off." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - END VERB. - - --- The following verb switches a device off if the device is on, and vice versa. - - - VERB switch - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS 'on' - THEN "You switch" SAY THE THIS. "off." - MAKE THIS NOT 'on'. - ELSE "You switch" SAY THE THIS. "on." - MAKE THIS 'on'. - END IF. - END VERB. - -END EVERY. - - - --- ============================================================= - - ------ DOOR - - --- ============================================================= - - -EVERY door ISA OBJECT - IS closeable. - IS closed. - IS lockable. - IS NOT locked. - IS NOT takeable. - - - VERB examine - DOES - IF THIS IS closed - THEN "It is currently closed." - ELSE "It is currently open." - END IF. - END VERB. - - - - VERB knock - DOES ONLY - IF THIS IS closed - THEN "You knock on" SAY THE THIS. "$$. There is no reply." - ELSE "You don't find it purposeful to knock on the open door." - END IF. - END VERB. - - - - VERB look_behind - DOES ONLY - IF THIS IS closed - THEN "You cannot look behind the door - it is closed." - ELSE "You notice nothing special behind the door." - END IF. - END VERB. - - - VERB look_under - DOES ONLY - IF THIS IS closed - THEN "The gap under the closed door is so narrow that you can't - see anything of what lies on the other side." - ELSE "You notice nothing special under the door." - END IF. - END VERB. - - -END EVERY. - - - --- ============================================================= - - ------ LIGHTSOURCE - - --- ============================================================= - - -EVERY lightsource ISA OBJECT - IS NOT lit. - IS NOT broken. - IS natural. -- A natural lightsource is for example a candle, a match or a torch. - -- A NOT natural lightsource is for example a flashlight or a lamp. - -- You cannot switch on or off a natural lightsource. - - - - VERB examine - DOES - IF THIS IS lit - THEN - IF THIS IS natural - THEN "It is currently lit." - ELSE "It is currently on." - END IF. - ELSE - IF THIS IS natural - THEN "It is currently not lit." - ELSE "It is currently off." - END IF. - END IF. - END VERB. - - - VERB light - CHECK THIS IS NOT lit - ELSE SAY THE obj. "is already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS natural - THEN "You light" SAY THE THIS. "." - MAKE THIS lit. - - ELSE "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END IF. - END VERB. - - - VERB extinguish - CHECK THIS IS lit - ELSE "But" SAY THE THIS. "is not providing light!" - DOES ONLY "You extinguish the" SAY THE THIS. "." - MAKE THIS NOT lit. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT natural - ELSE "That's not something you can $v on." - AND THIS IS NOT lit - ELSE SAY THE THIS. "is already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END VERB. - - - VERB turn_off - CHECK THIS IS NOT natural - ELSE "That's not something you can $v off." - AND THIS IS lit - ELSE SAY THE THIS. "is already off." - DOES ONLY - "You turn off the" SAY THIS. "." - MAKE THIS NOT lit. - - END VERB. - - --- The following verb switches a NOT natural lightsource on if it is off, and vice versa --- (when the player forgets, or doesn't bother, to type 'on' or 'off' after switch). - - - VERB switch - CHECK THIS IS NOT natural - ELSE SAY THE obj. "is not something you can switch on or off." - AND THIS IS reachable - ELSE SAY THE THIS. "is out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - AND CURRENT LOCATION IS lit - ELSE - "You switch" SAY THE THIS. "on." - MAKE THIS lit. - DOES ONLY - IF THIS IS lit - THEN "You switch" SAY THE THIS. "off." - MAKE THIS NOT lit. - ELSE "You switch" SAY THE THIS. "on." - MAKE THIS lit. - END IF. - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ LIQUID - - --- ============================================================== - - -EVERY liquid ISA OBJECT - - CONTAINER - HEADER "In" SAY THE THIS. "you see" - ELSE "There is nothing in" SAY THE THIS. "." - - -- We declare this class a container to enable player commands such as - -- 'throw sack into water', 'look into water' and 'take pearl from water'. - -- Also cases such as 'pour red potion into blue potion' require that this - -- class behaves like a container. - - - HAS vessel zero_vessel. -- The 'vessel' attribute takes care of that if a liquid is in a container, - -- the verb 'take' will automatically take the container instead - -- (if the container is takeable). Trying to take a liquid that - -- is in a fixed-in-place container will yield "You can't carry - -- [the liquid] around in your bare hands." - -- The default value 'zero_vessel' tells the compiler that the liquid is - -- not in any container. - - - - -- If you have some liquid in a container in your game, you should declare the - -- liquid instance thus: - - -- THE juice ISA LIQUID - -- IN bottle - -- HAS vessel bottle. -- i.e. the value of the 'vessel' attribute is the - -- ... -- container the liquid is in - -- END THE juice. - - -- Then, taking and pouring liquids work smoothly. - -- If you don't declare the 'vessel' attribute for the liquid instance, taking a liquid will - -- yield "You can't carry [the liquid] around in your bare hands."; only taking its - -- container will work in that case. - - -- The verb 'pour', as defined in this library, works also for the container of a liquid; - -- i.e. if there is some juice in a bottle, 'pour bottle' and 'pour juice' work equally well. - -- Note also that the verb 'empty' is not a synonym for 'pour'; - -- 'empty' only works for container objects. - - - INITIALIZE - SCHEDULE check_vessel AT THIS AFTER 0. -- this event is defined further below - - - VERB take - DOES ONLY - IF vessel OF THIS = zero_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$nTaken." - END IF. - END VERB. - - - VERB take_from - WHEN obj1 - DOES ONLY - IF vessel OF THIS = zero_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$nTaken." - END IF. - END VERB. - - - VERB drop - DOES ONLY - "($$" SAY THE vessel OF THIS. "$$)$nDropped." - LOCATE vessel OF THIS AT hero. - END VERB. - - - VERB give - WHEN obj1 - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = zero_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero -- i.e. if the implicit taking was successful - THEN - "You give" SAY THE vessel OF THIS. "to" SAY THE obj2. "." - LOCATE vessel OF THIS IN obj2. - END IF. - END VERB. - - - VERB pour - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = zero_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't pour" SAY THE THIS. "anywhere since you are not - carrying it." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero -- i.e. if the implicit taking was successful - THEN - "You pour" SAY THE THIS. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - LOCATE THIS AT hero. - SET vessel OF THIS TO zero_vessel. - END IF. - END VERB. - - - VERB pour_in - WHEN obj1 - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = zero_vessel OR vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero --i.e. if the implicit taking was successful - THEN - "You pour" SAY THE THIS. "into" SAY THE obj2. "." - LOCATE THIS IN obj2. - SET vessel OF THIS TO obj2. - END IF. - END VERB. - - - VERB pour_on - WHEN obj1 - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = zero_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero -- i.e. if the implicit taking was successful - THEN - IF obj2 = floor OR obj2 = ground - THEN LOCATE THIS AT hero. - "You pour" SAY THE THIS. "on" SAY THE obj2. "." - SET vessel OF THIS TO zero_vessel. - ELSIF obj2 ISA SUPPORTER - THEN LOCATE THIS IN obj2. - "You pour" SAY THE THIS. "on" SAY THE obj2. "." - SET vessel OF THIS TO zero_vessel. - ELSE "It wouldn't be sensible to pour anything on" SAY THE obj2. - END IF. - END IF. - END VERB. - - - VERB fill_with - WHEN obj2 - DOES SET vessel OF THIS TO obj1. - END VERB. - - - VERB put_in - WHEN obj1 - DOES SET vessel OF THIS TO obj2. - END VERB. - - - VERB put_on - WHEN obj1 - DOES SET vessel OF THIS TO obj2. - WHEN obj2 - DOES ONLY "It is not possible to $v" SAY obj1. "onto" SAY THE THIS. "." - END VERB. - - - -- The verbs 'empty', 'empty_in' and 'empty on' will be disabled as ungrammatical with liquids: - - VERB 'empty' - DOES ONLY "You can only empty containers." - END VERB. - - VERB empty_in, empty_on - WHEN obj1 - DOES ONLY "You can only empty containers." - END VERB. - - -END EVERY. - - - --- Here is the default vessel for liquids; if the vessel of a liquid is --- 'zero_vessel', it means that the liquid is not in any container. - - -THE zero_vessel ISA OBJECT - CONTAINER -END THE. - - - --- This event checks that if a liquid is outside a container, its container will --- be 'zero_vessel': - - -EVENT check_vessel - FOR EACH liq ISA LIQUID, DIRECTLY AT CURRENT LOCATION DO - SET vessel OF liq TO zero_vessel. - END FOR. - SCHEDULE check_vessel AFTER 1. -END EVENT. - - - - --- ============================================================= - - ------ LISTABLE_CONTAINER - - --- ============================================================= - - -EVERY LISTABLE_CONTAINER ISA OBJECT -- ACTORS are separately defined as - CONTAINER -- containers further below - - - VERB examine - DOES - IF THIS IS closeable - THEN - IF THIS IS closed - THEN "It is closed." - ELSE "It is open." - END IF. - END IF. - - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't see inside" SAY THE THIS. "." - END IF. - END VERB. - - - VERB look_in - DOES ONLY - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't, since" SAY THE THIS. "is closed." - END IF. - END VERB. - - - VERB open - DOES - MAKE THIS NOT OPAQUE. - LIST THIS. - END VERB. - - - VERB close - DOES - MAKE THIS OPAQUE. - END VERB. - - -END EVERY. - - - --- Tips for using container objects: - - --- 1) - - --- The contents of a normal CONTAINER are not listed when examined --- (you'll need to look *into* the object to see what it contains). --- If you wish to have the contents listed after 'examine' anyway, --- you should --- --- instead of: --- --- THE box ISA OBJECT --- CONTAINER --- ... --- END THE. --- --- do this: --- --- THE box ISA LISTABLE_CONTAINER --- ... --- END THE. --- --- Then, 'examine' lists the contents of the container. - - --- 2) - - --- For the command 'inventory' to list the contents of a container --- the hero is carrying, go to 'verbs.i', find the command 'inventory' --- and list one by one all relevant containers that the hero might carry, --- thus: --- --- VERB inventory --- DOES LIST hero. --- ... --- IF bag IN hero --- THEN LIST bag. --- END IF. --- --- IF box IN hero --- THEN LIST box. --- END IF. --- ... --- END VERB. --- --- --- If you leave out these additions, the bag and the box will be listed after the --- command 'inventory' in the following way: --- --- "You are carrying a bag and a box." --- --- only. But with the above additions, the outcome is e.g. --- --- "You are carrying a bag and a box. The bag contains a loaf of bread. The box --- is empty." - - --- 3) - - --- To declare a container the contents of which should not be listed after 'look' --- or 'examine', declare it an 'opaque container' in the following way: - - --- THE box ISA OBJECT --- OPAQUE CONTAINER --- ... --- END THE. - - --- or - - --- THE box ISA LISTABLE_CONTAINER --- OPAQUE CONTAINER --- ... --- END THE. - - --- Objects in an opaque container cannot be seen or manipulated. --- To change this, declare e.g. --- --- MAKE box NOT OPAQUE. --- - - - --- ============================================================== - - ------ SCENERY - - --- ============================================================== - - -EVERY scenery ISA OBJECT - IS NOT takeable. - DESCRIPTION "" - - - VERB examine - DOES ONLY SAY THE THIS. "doesn't appear particularly interesting to you." - END VERB. - - -- see also checks in the verbs 'take' and 'take from' in 'verbs.i' - -END EVERY. - - - --- =============================================================== - - ------ SOUND - - --- =============================================================== - - -EVERY sound ISA OBJECT - IS NOT examinable. - IS NOT reachable. - IS NOT movable. - - - VERB smell - DOES ONLY "That's not something you can smell." - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ SUPPORTER - - --- ============================================================== - - -EVERY supporter ISA OBJECT - CONTAINER - HEADER "On" SAY THE THIS. "you see" - ELSE "There's nothing on" SAY THE THIS. "." - - - VERB examine - DOES LIST THIS. - END VERB. - - - VERB look_in - DOES ONLY "That's not something you can look into." - END VERB. - - - VERB put_in - WHEN obj2 - DOES ONLY "You can't put anything inside" SAY THE THIS. "." - END VERB. - - - VERB search - DOES ONLY "You find nothing further of interest." - END VERB. - - -END EVERY. - - --- To place objects on a supporter, do the definition in the following way: --- --- Define the supporter first; e.g. --- --- THE tray ISA SUPPORTER --- ... --- END THE. --- --- --- Then, the objects on the supporter: --- --- --- THE apple ISA OBJECT --- IN tray -- note the IN here, even if the apple will be described as --- ... -- being on the tray --- END THE. --- --- --- THE book ISA OBJECT --- IN table --- ... --- END THE. --- --- --- Note that the 'examine' command will list what is on the surface of a supporter, not what, --- if anything, is inside the supporter. For example, if you have a supporter called 'table' in your game --- with a drawer in it, --- --- DON'T do this: --- --- THE drawer ISA OBJECT --- CONTAINER --- IN table. --- END THE. --- --- or this: --- --- THE drawer ISA LISTABLE_CONTAINER --- IN table. --- END THE. --- --- This would result in something like --- --- "There's a table here. On the table you see a book and a drawer." --- --- --- Instead, do either of the two following things: --- --- --- 1) --- --- THE drawer ISA OBJECT --- CONTAINER --- AT bedroom --- END THE. --- --- or --- --- THE drawer ISA LISTABLE_CONTAINER --- AT bedroom --- END THE. --- --- --- In other words, just declare the drawer present in the location, not as part of the table. --- ('AT table' would not be possible, as all objects must be initially located to --- instances inheriting from the class 'location'.) --- If this method feels clumsy, try the next one: --- --- --- 2) --- --- THE table_parts ISA OBJECT --- AT bedroom --- DESCRIPTION "" -- we don't want this object to appear in the room description --- CONTAINER --- HEADER "In the table there is" --- ELSE "" -- if the parts are removed from the table, there will be no --- END THE. -- mention of them in the description of the table --- --- --- THE drawer ISA LISTABLE_CONTAINER --- IN table_parts --- ... --- END THE. --- --- --- THE table ISA SUPPORTER --- ... --- VERB examine --- DOES ONLY --- LIST table. -- lists what is on the table --- LIST table_parts. -- lists the components of the table, i.e. the drawer in this example --- ... --- END VERB. --- --- END THE. --- --- --- In other words, define a separate container for the component(s) in the supporter --- which will then be listed after the surface objects have been listed. --- Consequently, the above will result in something like this: --- --- > examine table --- On the table you see a book. In the table there is a drawer. --- --- --- Note that in a location description (e.g. after LOOK), only the things *on* a supporter --- (and not any components) will be described, according to how things are defined in --- this library. --- --- - - - --- ============================================================== - - ------ WEAPON - - --- ============================================================== - - -EVERY weapon ISA OBJECT - IS NOT fireable. -END EVERY. - - --- see checks for this class in the file 'verbs.i', verbs 'attack_with', 'fire', --- 'fire_with', 'kill_with', 'shoot' and 'shoot_with'. - - - --- ============================================================== - - ------ WINDOW - - --- ============================================================== - - --- You can look out of and through a window. --- When examined, a window is automatically described to be either open or closed. - - -EVERY window ISA OBJECT - IS closeable. - IS closed. - IS NOT takeable. - - - VERB examine - DOES - IF THIS IS closed - THEN "It is currently closed." - ELSE "It is currently open." - END IF. - END VERB. - - - VERB look_behind - DOES ONLY - "That's not possible." - END VERB. - - - VERB look_out_of - DOES ONLY "You see nothing special looking out of the window." - END VERB. - - - VERB look_through - DOES ONLY "You see nothing special looking through the window." - END VERB. - - -END EVERY. - - - --- =============================================================== - --- =============================================================== --- --- 2. Actor classes --- --- =============================================================== - --- =============================================================== - - --- First, we declare some common characteristics for all actors: - - -ADD TO EVERY ACTOR - IS NOT inanimate. - IS NOT following. - IS NOT sitting. - IS NOT lying_down. - - CONTAINER -- so that actors can receive and carry objects - - INITIALIZE -- all actors will obey this script from the start of the game - USE SCRIPT following_hero FOR THIS. - - SCRIPT following_hero -- this code will make any actor follow the hero - STEP WAIT UNTIL hero NOT HERE -- if the actor is given the attribute 'following'. - IF THIS IS following - THEN - LOCATE THIS AT hero. - SAY THE THIS. "follows you." - END IF. - USE SCRIPT following_hero FOR THIS. - - - - - VERB examine - DOES - IF COUNT ISA THING, IN THIS > 0 -- This if-statement will make a description of an - THEN LIST THIS. -- actor's possessions show up every time the actor is examined. - END IF. -- Note that this doesn't apply to the hero which is defined - -- separately further below. - END VERB. - -END ADD TO. - - --- To make an actor follow the hero, give it the 'following' attribute, e.g.: - --- THE bob ISA ACTOR --- ... --- VERB whatever --- DOES MAKE bob following. --- END VERB. --- .... --- --- END THE bob. --- --- etc. - --- --- If you wish to have an actor follow the hero right from the start of the game, you can naturally just declare --- --- THE servant ISA ACTOR --- IS following. --- ... --- END THE. --- --- - --- To stop an actor from following the hero, just make the actor NOT following. - - - - --- ================================================================ - - ------ PERSON -- HAS can_talk - - --- ================================================================ - - -EVERY person ISA ACTOR - HAS can_talk. -END EVERY. - - - --- ================================================================ - - ------ NAMED_ACTOR -- NOT can_talk - - --- ================================================================ - - -EVERY named_actor ISA ACTOR - DESCRIPTION SAY THIS. "is here." - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" -END EVERY. - - - --- ================================================================ - - ------ NAMED_PERSON -- HAS can_talk - - --- ================================================================ - - -EVERY named_person ISA PERSON - DESCRIPTION SAY THIS. "is here." - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" -END EVERY. - - - --- ================================================================ - - ------ Expressing FEMALE and MALE - - --- ================================================================ - - --- 'Male' and 'female' are not declared as separate classes in this library. --- This is to avoid numerous new classes such as female_actor, named_female_actor, --- female_person, named_female_person, and the same for male. Instead, just --- --- add the line --- --- PRONOUN him --- --- or --- --- PRONOUN her --- --- to any actor instance to make it possible for the player to refer to the --- actor with these pronouns. For example, --- --- THE jessie ISA NAMED_PERSON --- PRONOUN her --- ... --- END THE. - - - --- ================================================================ - --- ================================================================ - --- 3. The hero - --- ================================================================ - --- ================================================================ - - - -THE hero ISA ACTOR - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" - MENTIONED "yourself" - IS NOT sitting. - IS NOT lying_down. - - ------------------------------------ - - -- These three attributes, as well as the 'schedule' statement following them, - -- are needed for the 'notify' command ('verbs.i'); ignore. - - HAS oldscore 0. -- Records previous score so 'checkscore' event - -- can compare with the current score - IS notify_on. -- Set by 'notify' verb, records whether - -- player wants to see score messages or not. - IS NOT seen_notify. -- Records whether player has seen the notify verb - -- instructions yet. - - INITIALIZE - SCHEDULE check_score AT hero AFTER 0. - - ------------------------------------ - - CONTAINER - - LIMITS -- Remove this whole section (from this line until 'HEADER') if you - -- wish to have no limits to how much the hero can carry. - COUNT 10 Then - "You can't carry anything more. You have to drop something - first." - WEIGHT 50 Then - "You can't carry anything more. You have to drop something - first." - - HEADER - IF CURRENT LOCATION IS NOT lit - THEN "Although you cannot see your belongings in the dark, you - remember that you're carrying" - ELSE "You are carrying" - END IF. - ELSE - "You are empty-handed." - - - - VERB examine - DOES ONLY "You notice nothing unusual about yourself." - IF COUNT ISA CLOTHING, IN worn > 0 - THEN LIST worn. -- this will list what the hero is wearing - END IF. - END VERB. - - -END THE. - - -SYNONYMS - me, myself, yourself, self = hero. - - --- Please refer also 'verbs.i' where there are numerous verb checks for the hero, --- so that the hero cannot e.g. attack himself etc. - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/locations.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/locations.i deleted file mode 100755 index e613587..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/locations.i +++ /dev/null @@ -1,536 +0,0 @@ --- ALAN NEW LIBRARY: LOCATIONS (file name: 'locations.i') - - --- This library file defines the default directions (exits) and the location 'nowhere', a useful --- place to locate things when you want to remove them from play. --- This file also defines three specific location classes: rooms (= indoor locations), --- sites (= outdoor locations) as well as the class 'dark_location'. --- Finally, the attributes 'visited' and 'described' as well as the instance 'room' --- (to make possible player commands such as 'examine room' and 'exit room') are defined. --- You may modify this file in any way that suits your purposes. --- To use this file, you should have it in the same folder as your source code file , and the line --- --- IMPORT 'locations.i'. --- --- in your source code. - - - --- ======================================================== - - ------ 1. The location 'nowhere' and the default directions - - --- ======================================================== - - -THE nowhere ISA LOCATION - - EXIT - north, - south, - east, - west, - northeast, - southeast, - northwest, - southwest, - up, - down, - 'in', - out - - TO nowhere. - - -END THE nowhere. - - -SYNONYMS - n = north. - s = south. - e = east. - w = west. - ne = northeast. - se = southeast. - nw = northwest. - sw = southwest. - u = up. - d = down. - - --- Note: - - --- 1) the directions defined above (and their synonyms) are not predefined in or --- hardwired to the interpreter in any way, so you can replace them altogether or add new --- ones to be used alongside with them. - - --- 2) when you want to remove things from play, you can --- --- LOCATE [object] AT nowhere. --- --- e.g. --- --- THE piece_of_paper ISA OBJECT --- ... --- VERB tear --- DOES ONLY "You tear the piece of paper to shreds." --- LOCATE piece_of_paper AT nowhere. --- END VERB. --- --- END THE piece_of_paper. - - - --- ========================================================================= - - ------ 2. Location classes 'room' and 'site' for indoor and outdoor locations - - --- ========================================================================= - - --- ROOM and SITE are optional location classes you can use to ease up coding. --- All ROOMS have a floor, walls and a ceiling. All SITES have a ground and a sky. --- Thus, you will be able to define e.g. --- --- THE kitchen ISA ROOM --- --- and it will automatically have a floor, walls and a ceiling, --- --- or: --- --- THE greenmeadow ISA SITE --- --- and the ground and the sky are automatically found in that location. --- --- --- Of course, you will still be able to define locations in the usual way, e.g. --- --- THE kitchen ISA LOCATION --- --- etc, but the floor, walls and ceiling won't be automatically included there. --- The walls, floor, ceiling, ground and sky are not takeable or movable. --- This library file also defines the sky and the ceiling to be out of reach, --- so that they can't be e.g. touched. - --- (We make use of ALAN's nested locations feature in the following definitions: ) - - -THE outdoor ISA LOCATION -END THE outdoor. - - -THE indoor ISA LOCATION -END THE indoor. - - -EVERY room ISA LOCATION AT indoor -END EVERY. - - -EVERY site ISA LOCATION AT outdoor -END EVERY. - - -EVERY room_object ISA OBJECT AT indoor -END EVERY. - - -EVERY site_object ISA OBJECT AT outdoor -END EVERY. - - -THE floor ISA room_object - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow 'empty/pour something on floor' - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the floor." - END VERB. - - - VERB look_in, look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - -THE walls ISA room_object - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the walls." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - -SYNONYMS wall = walls. - - -THE ceiling ISA room_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the ceiling." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - -THE ground ISA site_object - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow 'empty/pour something on ground' - DESCRIPTION "" - - - VERB examine - DOES ONLY "You notice nothing unusual about the ground here." - END VERB. - - - VERB look_in, look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - - VERB dig - DOES ONLY "The ground is not suitable for digging here." - END VERB. - - -END THE. - - -THE sky ISA site_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the sky." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - --- NOTE: it is often a good idea to modify the 'examine' verb for the above objects. --- Here is an example for 'walls': - --- THE walls ISA room_object --- : --- : --- VERB examine DOES ONLY --- IF hero AT kitchen --- THEN "Numerous shelves, full of various kitchen utensils, line the walls." --- ELSIF hero AT livingroom --- THEN "The walls are decorated with flowery wallpaper here." --- : --- : --- END IF. --- END VERB. --- END THE walls. --- --- In other words, making the description of the walls, etc., individual for each room --- gives a better impression than if you just use the default messages. - - - --- ========================================================== - - ------ 3. Dark locations - - --- ========================================================== - - -ADD TO EVERY LOCATION - IS lit. -END ADD TO. - - -EVERY dark_location ISA LOCATION - IS NOT lit. - - ENTERED - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - THEN MAKE THIS lit. - END IF. - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE = 0 - THEN MAKE THIS NOT lit. - END IF. - - -- these ENTERED statements take care - -- of the dark location being correctly lit or not lit at entrance, the WHEN rules below take care of - -- the change when the hero is already in the location. - - DESCRIPTION - CHECK COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - ELSE "It is pitch black. You can't see anything at all." - -END EVERY dark_location. - - -WHEN CURRENT LOCATION IS NOT lit - AND COUNT ISA lightsource, IS lit, HERE > 0 -THEN MAKE CURRENT LOCATION lit. - LOOK. - - -WHEN CURRENT LOCATION ISA dark_location - AND CURRENT LOCATION IS lit - AND COUNT ISA LIGHTSOURCE, IS lit, HERE = 0 -THEN MAKE CURRENT LOCATION NOT lit. - "It is now pitch black." - - --- To define a dark location, use a formulation like the following: - - --- THE basement ISA dark_location --- EXIT up TO kitchen. --- ... --- END THE. - - --- The description of a dark_location will automatically be: "It is pitch black. --- You can't see anything at all." (Edit the description in the code above to change this.) - - --- If you add a description to a dark_location, this description will be shown only --- if/when the location is lit by any means: - --- THE basement ISA dark_location --- DESCRIPTION "Cobwebs and old junk are the only things you see here." --- EXIT up TO kitchen. --- END THE. - - --- In darkness, you are not able to manipulate things other than turn on a lightsource --- and drop items you're carrying (these checks are found in 'verbs.i'). You can exit normally --- and use verbs that don't require seeing, such as 'smell', 'listen' and 'think'. --- If you are in a dark location with an NPC (= a non-player character), you are able to --- communicate with him by asking and telling but not by showing and giving. If you wish to --- change this, see the respective verbs in 'verbs.i' and edit their checks. - - --- Note that you cannot change the name of a location mid-game. Thus, if you define a dark location --- called e.g. 'Darkness' and wish to make it lit at some point in the game, the name will still be 'Darkness' --- even if the location description can be changed to describe the illuminated location. --- To change the location name, you must locate the hero in another location when the dark location --- is lit. For example, --- --- --- THE lantern ISA LIGHTSOURCE -- (see 'classes.i') --- VERB turn_on --- DOES --- IF hero AT darkness --- THEN LOCATE hero AT treasure_chamber. --- ... --- END IF. --- ... --- END VERB. --- --- etc. --- --- --- Alternatively, you can also use a rule, e.g. --- --- --- WHEN lantern IS lit --- AND hero AT darkness --- THEN LOCATE hero AT treasure_chamber. - - - --- Suppose you want all dark_locations in the game to become lighted. It can be done e.g. like this: - --- FOR EACH d1 ISA dark_location DO --- IF main_power_switch IS 'on' --- THEN MAKE d1 lit. --- END IF. --- END FOR. - --- FOR EACH makes a loop that affects all instances of the class described after the ISA statement. --- The 'd1' is a temporary variable needed in the FOR EACH phrase and not anywhere else in the game code. --- You can name this variable in any way you wish. --- It is needed to refer to each instance (in 'THEN MAKE d1 lit), because FOR EACH affects all --- *instances* of the defined class, not the class itself. - - - --- ===================================================================== - - ------ 4. The attributes 'visited' and 'described' - - --- ===================================================================== - - --- A location has the value 'visited 0' until the hero visits it for the first time, and the --- value increases on every subsequent visit. --- This helps when you need to control if or how many times a location has been visited, --- and also if you want the location description to be different after the first visit. - --- A location has the value 'described 0' before the first location description, --- and the value increases every time the description is shown. --- This distinction is handy when you want the first-time description of a location to be different from --- the subsequent ones, even if the hero is in the location still for the first time. - - -ADD TO EVERY LOCATION - HAS visited 0. - HAS described 0. - ENTERED - IF CURRENT ACTOR = hero - THEN INCREASE visited OF THIS BY 1. - INCREASE described OF THIS BY 1. -- this value also increases after 'look' (see 'verbs.i'.). - END IF. -END ADD TO. - - --- A location not visited at all has the 'visited' value 0. When the hero enters it --- the first time, the 'visited' value will change to 1. On the second visit the value will be 2, etc. --- Now, in your source code you can define something like the following: - - --- THE kitchen ISA LOCATION --- DESCRIPTION --- "You are in the kitchen." --- IF visited OF THIS = 1 --- THEN "This is your first time here." --- ELSE "You've been here before." --- END IF. --- ... --- END THE. - --- Note that if you have an NPC moving around in the game, the visited value of any location --- will increase when the NPC enters the location, as well. This is most often not what is wanted, --- and that's why the 'if' statement (IF CURRENT ACTOR = hero) is included above. - - --- You can also check whether the hero has been in a location if need be: - --- THE king ISA ACTOR --- ... --- VERB ask --- WHEN act --- IF topic = treasure_chamber --- THEN --- IF visited OF treasure_chamber = 0 --- THEN "You are not supposed to know anything about the treasure --- chamber - you haven't found it yet." --- ELSE """Just take what you want from the chamber"", the king smiles." --- END IF. --- ... --- END IF. --- END VERB. --- END THE. - - --- etc. - - --- Suppose you want the location description to be different after the first time the description is shown, --- even if you are in the location still for the first time. Then , you can use the 'described' attribute, e.g.: - - --- THE library ISA ROOM --- DESCRIPTION --- IF described OF THIS = 0 --- THEN "There is an old man reading at a table in one of the corners." --- ELSE "The old man keeps on reading at his table." --- END IF. --- END THE. - - - --- ======================================================================= - - --- 5. The instance 'room' - - --- ======================================================================= - - --- Through defining the instance 'room' we make possible player commands such as 'examine room' and --- 'exit room', among others. These commands only work in indoor locations. --- We have to identify this instance differently from 'room' which has already been defined as a subclass above, --- that's why we identify it here as 'current_room'. Through the NAME statement, it can be still --- called a 'room' in-game. - - -THE current_room ISA OBJECT - AT indoor - NAME 'room' - IS NOT takeable. - IS NOT movable. - CONTAINER - DESCRIPTION "" - - - VERB examine - DOES ONLY DESCRIBE CURRENT LOCATION. - END VERB. - - - VERB search - DOES ONLY "Try examining one thing at a time." - END VERB. - - - VERB enter - DOES ONLY "You must state a direction where to go." - END VERB. - - - VERB 'exit' - DOES ONLY "You must state a direction where to go." - END VERB. - - - VERB look_in, look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/messages.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/messages.i deleted file mode 100755 index 8c17152..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/messages.i +++ /dev/null @@ -1,72 +0,0 @@ --- ALAN NEW LIBRARY: MESSAGES (file name: 'messages.i') - - --- This library file lists all the standard runtime messages listed in the manual, for easy modification. - - - -MESSAGE AFTER_BUT: "You must give at least one object after '$1'." - AGAIN: "(again)" -- if you wish to disable this, make the string empty ("") - BUT_ALL: "You can only use '$1' AFTER '$2'." - CAN_NOT_CONTAIN: "$+1 can not contain $+2." - CANT0: "You can't do that." -- note that the fifth token in CANT0 is a zero, not an 'o'. - CARRIES: "$+1 carries" - 'CONTAINS': "$+1 contains" - CONTAINS_COMMA: "$01," - CONTAINS_AND: "$01 and" - CONTAINS_END: "$01." - EMPTY_HANDED: "$+1 is empty-handed." - HAVE_SCORED: "You have scored $1 points out of $2." - IS_EMPTY: "$+1 is empty." - MORE: "" - MULTIPLE: "You can't refer to multiple objects with '$v'." - NO_SUCH: "I can't see any $1 here." - NO_WAY: "You can't go that way." - NOT_MUCH: "That doesn't leave much to $v!" - NOUN: "You must supply a noun." - NOT_A_SAVEFILE: "That file does not seem to be an Alan game save file." - QUIT_ACTION: "Do you want to RESTART, RESTORE, QUIT or UNDO? " - -- these four alternatives are hardwired to the interpreter and cannot be changed. - REALLY: "Are you sure (RETURN confirms)?" - RESTORE_FROM: "Enter file name to restore from" - SAVE_FAILED: "Sorry, save failed." - SAVE_MISSING: "Sorry, could not open the save file." - SAVE_NAME: "Sorry, the save file did not contain a save for this adventure." - SAVE_OVERWRITE: "That file already exists, overwrite (y)?" - SAVE_VERSION: "Sorry, the save file was created by a different version." - SAVE_WHERE: "Enter file name to save in" - SEE_START: "There is $01" - SEE_COMMA: ", $01" - SEE_AND: "and $01" - SEE_END: "here." - NO_UNDO: "No further undo available." - UNDONE: "'$1' undone." - UNKNOWN_WORD: "I don't know the word '$1'." - WHAT: "I don't understand." - WHAT_WORD: "I don't know what you mean by '$1'." - WHICH_PRONOUN_START: "I don't know if you by '$1'" - WHICH_PRONOUN_FIRST: "mean $+1" - WHICH_START: "I don't know if you mean $+1" - WHICH_COMMA: ", $+1" - WHICH_OR: "or $+1." - - --- These messages are automatically translated into German or Swedish in your game --- if you define in the beginning of your source code --- --- OPTIONS --- LANGUAGE German. --- --- or --- --- OPTIONS --- LANGUAGE Swedish. --- --- Only the exact equivalents of the above phrases will then be shown; if you change the above English --- messages to your own wordings, the translations will still be only for the default. --- --- --- If you wish to make your game in some other language, you must manually translate --- the messages above. There might be support for more languages in the future, depending --- on demand. - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/testgame.alan b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/testgame.alan deleted file mode 100755 index 817a0cd..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/testgame.alan +++ /dev/null @@ -1,290 +0,0 @@ --- TESTGAME - - -IMPORT 'locations.i'. -IMPORT 'classes.i'. -IMPORT 'verbs.i'. -IMPORT 'messages.i'. - - - -THE sunny_room ISA ROOM - NAME 'Sunny Room' - DESCRIPTION "You are in a spacious room filled with bright sunlight entering through - the window and through an open doorway to the west leading to a small balcony. - A white door leads north." - - EXIT north TO closet - CHECK - IF door1 IS closed - THEN "You can't, since the door is closed." - ELSE "You walk into the closet. The door slams shut behind you." - LOCATE hero AT closet. - LOCATE door1 AT closet. - MAKE door1 closed. - END IF. - END EXIT. - - EXIT west TO balcony. - - - -END THE. - - - -THE table ISA SUPPORTER - AT sunny_room - IS NOT takeable. - VERB examine - DOES AFTER LIST table_parts. - END VERB. -END THE. - - - -THE box ISA LISTABLE_CONTAINER - AT sunny_room - -- leaving all 'description' statements out, the default description of the box will be shown - -- in the room description -END THE. - - -THE table_parts ISA OBJECT - AT sunny_room - CONTAINER - HEADER "In the table there are" - ELSE "" - DESCRIPTION "" -- this way no description of the object whatsoever is shown in the room description -END THE. - - -THE drawer1 ISA LISTABLE_CONTAINER - IN table_parts - OPAQUE CONTAINER - NAME top drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - -THE drawer2 ISA LISTABLE_CONTAINER - IN table_parts - OPAQUE CONTAINER - NAME bottom drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - - - - -THE door1 ISA DOOR - AT sunny_room - NAME white 'door' - DESCRIPTION "" -END THE. - - -THE window1 ISA WINDOW - AT sunny_room - NAME 'window' - DESCRIPTION "" -END THE. - - -THE flower ISA SCENERY - IN table -END THE. - - -THE note ISA OBJECT - IN table - IS writeable. - IS readable. - - VERB write - DOES BEFORE - IF pen NOT IN hero - THEN "(taking the pen first)$n" - LOCATE pen IN hero. - END IF. - END VERB. - - VERB burn - CHECK match IS lit - ELSE "How?" - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - VERB burn_with - WHEN obj1 - CHECK obj2 = match - ELSE "That's not possible." - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - -END THE. - - -THE pen ISA OBJECT - IN table -END THE. - - -THE bottle ISA LISTABLE_CONTAINER - In box -END THE. - - -THE juice ISA LIQUID - IN bottle - HAS vessel bottle. - IS drinkable. - ARTICLE "some" -END THE. - - -THE match ISA LIGHTSOURCE - IN box - IS natural. -END THE. - - -THE flashlight ISA LIGHTSOURCE - IN box - IS NOT natural. -END THE. - - -THE waterpistol ISA WEAPON - IN box - IS fireable. -END THE. - - -THE blue_ball ISA OBJECT - IN box - NAME blue ball NAME blue - VERB take - DOES SCORE 1. - END VERB. -END THE. - - -THE red_ball ISA OBJECT - AT sunny_room - NAME red ball NAME red - VERB take - DOES SCORE 1. - END VERB. -END THE. - - -THE yellow_ball ISA OBJECT - AT sunny_room - NAME yellow ball NAME yellow - VERB take - DOES SCORE 1. - END VERB. -END THE. - - -THE felix ISA NAMED_ACTOR - AT sunny_room - NAME felix NAME himself - HAS can_talk. - MENTIONED "Felix" - PRONOUN 'him' - DESCRIPTION "$pFelix, your grumpy butler, is standing off to one side." - - VERB examine - DOES ONLY "Felix is your grumpy butler, properly clad in a tuxedo." - END VERB. - -END THE. - - -THE dog ISA ACTOR - AT sunny_room - DESCRIPTION "$pA dog is here, looking at you with faithful eyes." -END THE. - - -THE balcony ISA ROOM - - DESCRIPTION "You're standing on a small balcony overlooking a garden. The sky is clear. In the distance you see a mountain. - The room is back to the east." - - IF visited OF balcony = 1 - THEN "$pHaving never been on this balcony before, you pause to take in the magnificent view." - ELSE "$pEven if you've been here before, the magnificent view never ceases to amaze you." - END IF. - - EXIT east TO sunny_room. - -END THE. - - - -THE mountain ISA BACKGROUND - AT balcony - DESCRIPTION -END THE. - - -THE garden ISA BACKGROUND - AT balcony - NAME garden NAME flowers - DESCRIPTION "The garden is green and full of blossoming flowers." -END THE. - - - -THE closet ISA DARK_LOCATION - - DESCRIPTION "This is a closet." - - EXIT south TO sunny_room - CHECK - IF door1 IS closed - THEN "You can't, since the door is closed." - ELSE "You walk back into the sunny room. The door slams shut behind you." - LOCATE hero AT closet. - LOCATE door1 AT closet. - MAKE door1 closed. - END IF. - END EXIT. - -END THE. - - -THE shirt ISA CLOTHING - AT closet - IS topcover 8. -END THE. - - -THE jacket ISA CLOTHING - AT closet - IS topcover 32. -END THE. - - -THE wallet ISA OBJECT - IN jacket -END THE. - - - - - -START AT sunny_room. -"This is a" STYLE alert. "testgame" STYLE normal. "for the new ALAN library. Experiment with - manipulating various objects and moving around. -Taking any ball will increase your score." - \ No newline at end of file diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/verbs.i b/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/verbs.i deleted file mode 100755 index 0542630..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2010-08-22/verbs.i +++ /dev/null @@ -1,5987 +0,0 @@ --- ALAN NEW LIBRARY: VERBS (file name: verbs.i) - - ------ This library file defines common verbs needed in gameplay. The verbs ------ are listed alphabetically. This file also includes common commands which are not ------ actually verbs, such as "inventory", "verbose" and "again". You are free to edit this ------ file for your own purposes in any way you like by adding, deleting or modifying verbs. ------ Verbs originally defined in this file are the following: - ------ VERB SYNONYM - ------ about (+ help, info) ------ again (+ g) ------ answer (+ reply) ------ ask (+ enquire, inquire, interrogate) ------ attack (+ beat, fight, hit, kick, punch) ------ attack_with ------ bite (+ chew) ------ break (+ destroy) ------ break_with ------ brief ------ burn ------ burn_with ------ buy (+ purchase) ------ catch ------ clean (+ polish, wipe) ------ climb ------ climb_on ------ climb_through ------ close ------ close_with ------ consult ------ credits (+ acknowledgments, author, copyright) ------ cut ------ cut_with ------ dance ------ dig ------ dive ------ dive_in ------ drink ------ drive ------ drop (+ discard, dump, reject) ------ eat ------ empty ------ empty_in ------ empty_on ------ enter (+ obj) ------ examine (+ check, inspect, observe, x) ------ exit (+ obj) ------ extinguish (+ put out, quench) ------ fill ------ fill_with ------ find (+ locate) ------ fire ------ flip ------ follow ------ free (+ release) ------ get_up ------ get_off ------ give ------ go_to ------ hint (+ hints) ------ inventory (+ i, inv) ------ jump ------ jump_in ------ jump_on ------ kill (+ murder) ------ kill_with ------ kiss (+ hug, embrace) ------ lie_down ------ lie_in ------ lie_on ------ lift ------ light (+ lit) ------ listen0 (= 'listen', with no object) ------ listen (= 'listen to', with an object) ------ lock ------ lock_with ------ look (+ gaze, peek) ------ look_at ------ look_behind ------ look_in ------ look_out_of ------ look_through ------ look_under ------ look_up ------ no ------ notify (on, off) ------ open ------ open_with ------ play ------ play_with ------ pour ------ pour_in ------ pour_on ------ pray ------ pry ------ pry_with ------ pull ------ push ------ push_with ------ put (+ lay, place) ------ put_behind ------ put_down ------ put_in (+ insert) ------ put_near ------ put_on ------ put_under ------ read ------ restart ------ restore ------ rub ------ save ------ say ------ say_to ------ score ------ search ------ sell ------ shake ------ shoot (at) ------ shoot_with ------ shout (+ scream, yell) ------ show (+ reveal) ------ sing ------ sip ------ sit (down) ------ sit_on ------ sleep (+ rest) ------ smell0 (= 'smell', with no object) ------ smell (= 'smell' with an object) ------ squeeze ------ stand (up) ------ stand_on ------ swim ------ swim_in ------ switch_on ------ switch_off ------ take (+ carry, get, grab, hold, obtain) ------ take_from (+ remove from) ------ talk ------ talk_to (+ speak) ------ taste (+ lick) ------ tear (+ rip) ------ tell (+ enlighten, inform) ------ think ------ think_about ------ throw ------ throw_at ------ tie ------ tie_to ------ touch (+ feel) ------ turn (+ rotate) ------ turn_on ------ turn_off ------ unlock ------ unlock_with ------ use ------ use_with ------ verbose ------ wait (+ z) ------ what_am_i ------ what_is ------ where_am_i ------ where_is ------ who_am_i ------ who_is ------ write ------ yes - - ------ Directions (north, south, up, etc.) are declared in the file 'locations.i'. - - ------ Verbs having to do with wearing clothes are defined in the file 'classes.i', ------ subclass 'clothing'. These verbs, together with their synonyms, are: ------ ------ remove (+ doff, take off) ------ undress ------ wear (+ don, put on) - - - - ------ We first declare some default attributes for things (= objects and actors) below. ------ These attributes are frequently checked in verb definitions to prohibit ------ the use of verbs with objects and actors in an irrational way. For example, the hero ------ won't be able to eat anything that is not edible, and so forth. - - ------ Specific class attributes that override or complete the following ------ attributes are declared in the files 'classes.i' and 'locations.i'. - - - -ADD TO EVERY THING - - IS examinable. - inanimate. - movable. - reachable. - takeable. - - HAS text "". - - NOT broken. - NOT can_talk. - NOT closeable. - NOT closed. - NOT drinkable. - NOT edible. - NOT lit. - NOT lockable. - NOT locked. - NOT plural. - NOT readable. - NOT wearable. - NOT writeable. - -END ADD TO. - - ------ Next, we declare synonyms for some words so that it will be possible ------ for the player to type commands such as both "put ball in box" and ------ "put ball into box", etc: - - -SYNONYMS - -into, inside = 'in'. -onto = on. -thru = through. -using = 'with'. - - - ------ The verbs and commands: - - - --- ============================================================= - - ------ ABOUT - - --- ============================================================= - - -SYNTAX 'about' = 'about'. - - -VERB 'about' - DOES - STYLE emphasized. - "This is a text adventure, also called interactive fiction, which means that what - goes on in the story depends on what you type at the prompt. Commands you can type - are for example GO NORTH (or NORTH or just N), WEST, SOUTHEAST, UP, IN etc for - moving around, but you can try many - other things too, like TAKE LAMP, DROP EVERYTHING, EAT APPLE, EXAMINE BIRD or - FOLLOW OLD MAN, to name just a few. LOOK (L) describes your surroundings, and - INVENTORY (I) lists what you are carrying. You can SAVE your game and RESTORE it - later on. - $pType CREDITS to see information about the author and the copyright issues. - $pTo stop playing and end the program, type QUIT.$p" - STYLE normal. -END VERB. - - -SYNONYMS help, info = 'about'. - - - --- ============================================================= - - ------ AGAIN (= g) - - --- ============================================================= - - -SYNTAX again = again. - - -VERB again - DOES - "[The AGAIN command is not supported in this game. As a workaround, try using - the 'up' and 'down' arrow keys to scroll through your previous commands.]" -END VERB. - - -SYNONYMS g = again. - - - --- ============================================================= - - ------ ASK (= enquire, inquire, interrogate) - - --- ============================================================= - - -SYNTAX ask = ask (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That doesn't seem to be something you can talk about with" SAY THE act. "." - - -ADD TO EVERY THING - VERB ask - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act IS reachable -- you might want to remove this check in some situations, e.g. - -- when an NPC (= a non-player character) is speaking - -- on the phone with the hero - ELSE SAY THE act. "is too far away." - AND act <> hero - ELSE "It doesn't make much sense to ask yourself about something." - DOES - IF topic IN act - THEN SAY THE act. "doesn't seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. "chooses to be silent." - ELSIF topic = hero - THEN """I think you know more about yourself than what I do!""," SAY THE act. "snaps." - ELSE """I don't know anything about" SAY THE topic. "$$!""," SAY THE act. "snaps." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS enquire, inquire, interrogate = ask. - - ------ note that 'consult' is defined separately - - - --- ============================================================= - - ------ ATTACK (+ beat, fight, hit, punch) - - --- ============================================================= - - -SYNTAX attack = attack (obj) - WHERE obj ISA THING - ELSE "Thats not something you can $v." - - -ADD TO EVERY THING - VERB attack - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND obj NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND obj NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - -SYNONYMS beat, fight, hit, punch = attack. - --- Note that 'kick' is defined separately, to avoid absurd commands such as --- 'kick man with sword' (see 'attack_with' below) - - - --- ============================================================== - - ------ ATTACK WITH - - --- ============================================================== - - -SYNTAX attack_with = attack (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can $v." - AND obj2 ISA WEAPON - ELSE - IF obj2 ISA ACTOR - THEN - IF obj2 = hero - THEN "It doesn't make sense to attack something with yourself." - ELSE "You cannot use" SAY THE obj2. "to attack anything." - END IF. - ELSE "There's no point attacking anything with" SAY THE obj2. "." - END IF. - - -ADD TO EVERY THING - VERB attack_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can $v." - AND obj2 IS takeable - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> hero - ELSE "It doesn't make sense to $v yourself." - AND obj1 NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND obj1 NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - - --- =============================================================== - - ------ BITE (+ chew, taste) - - --- =============================================================== - - -SYNTAX bite = bite (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can bite." - - -ADD TO EVERY OBJECT - VERB bite - CHECK obj IS edible - ELSE "That's not something you should $v." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - -- This if-statement takes care of implicit taking; i.e. if the hero - -- doesn't have the object, (s)he will take it automatically first. - -- This same if-statement is found in numerous other verbs throughout - -- the library, as well. - - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - - - "You take a bite of" SAY THE obj. "$$. It tastes rather good." - - END VERB. -END ADD TO. - - -SYNONYMS chew = bite. - - - --- =============================================================== - - ------ BREAK - - --- =============================================================== - - -SYNTAX break = break (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "Resorting to violence is not the answer." - ELSE "That's not something you can $v." - END IF. - - -ADD TO EVERY OBJECT - VERB break - CHECK obj IS examinable - ELSE "That's not something you can break." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - -SYNONYMS destroy = break. - - - - --- =============================================================== - - ------ BREAK WITH - - --- =============================================================== - - -SYNTAX break_with = break (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can $v." - AND obj2 ISA OBJECT - ELSE "That's not something you can $v things with." - - -ADD TO EVERY OBJECT - VERB break_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can break." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "Trying to break" SAY THE obj1. "with" SAY THE obj2. - "wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ BRIEF - - --- ================================================================ - - --- Use "Visits 0." or "Visits 1000." in the START section if you want --- the game to start in verbose or brief mode. (By default, --- all games start in the verbose mode.) - - -SYNTAX brief = brief. - - -VERB brief - DOES - Visits 1000. - "Brief mode is now on. Location descriptions will only be shown - the first time you visit." -END VERB. - - - --- ================================================================= - - ------ BURN - - --- ================================================================= - - -SYNTAX burn = burn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "That would be needlessly brutal." - ELSE "That's not something you can burn." - END IF. - - -ADD TO EVERY OBJECT - VERB burn - CHECK obj IS examinable - ELSE "That's not something you can burn." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You must state what you want to burn" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ================================================================= - - ------ BURN WITH - - --- ================================================================= - - -SYNTAX burn_with = burn (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN "That would be needlessly brutal." - ELSE "That's not something you can burn." - END IF. - AND obj2 ISA OBJECT - ELSE - IF obj2 ISA ACTOR - THEN "It doesn't make sense to burn something with" SAY THE obj2. "." - ELSE "It's not possible to burn something with that." - END IF. - - -ADD TO EVERY THING - VERB burn_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can burn." - AND obj1 <> obj2 - ELSE "It doesn't make sense to burn something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - DOES - "You can't burn" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ BUY (+ purchase) - - --- ================================================================== - - -SYNTAX buy = buy (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB buy - CHECK obj IS examinable - ELSE "That's not something you can buy." - DOES - "That's not for sale." - END VERB. -END ADD TO. - - -SYNONYMS purchase = buy. - - - --- ================================================================== - - ------ CATCH - - --- ================================================================== - - -SYNTAX catch = catch (obj) - WHERE obj ISA THING - ELSE "That's not something you can catch." - - -ADD TO EVERY THING - VERB catch - CHECK obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to catch anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to catch anything while lying down." - DOES - "That doesn't need to be caught." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ CLEAN ( + wipe, polish) - - --- ================================================================== - - -SYNTAX clean = clean (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB clean - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS wipe, polish = clean. - - ------ notice that 'rub' is defined separately - - - --- ============================================================== - - ------ CLIMB - - --- ============================================================== - - -SYNTAX climb = climb (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can climb." - - -ADD TO EVERY OBJECT - VERB climb - CHECK obj IS examinable - ELSE "That's not something you can climb." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND hero IS NOT sitting - ELSE "It is difficult to climb while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb while lying down." - DOES - "That's not something you can climb." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB ON - - --- ============================================================== - - -SYNTAX climb_on = climb 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can climb on." - - -ADD TO EVERY OBJECT - VERB climb_on - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - "That's not something you can climb on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB THROUGH - - --- ============================================================== - - -SYNTAX climb_through = climb through (obj) - WHERE obj ISA THING - ELSE "That's not something you can climb through." - - -ADD TO EVERY OBJECT - VERB climb_through - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - "That's not something you can climb through." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLOSE (+ shut) - - --- ============================================================== - - -SYNTAX close = close (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB close - CHECK obj IS closeable - ELSE "That's not something you can close." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT closed - ELSE "It is already closed." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - MAKE obj closed. - "You close the" SAY THE obj. "." - END VERB. -END ADD TO. - - -SYNONYMS shut = close. - - - --- ============================================================== - - ------ CLOSE WITH - - --- ============================================================== - - -SYNTAX close_with = close (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can $v." - AND obj2 ISA OBJECT - ELSE "You can't $v anything with that." - - -ADD TO EVERY OBJECT - VERB close_with - WHEN obj1 - CHECK obj1 IS closeable - ELSE "That's not something you can $v." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS NOT closed - ELSE "It is already closed." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "You can't $v" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CONSULT - - --- ============================================================== - - -SYNTAX consult = consult (obj1) about (obj2)! - WHERE obj1 ISA THING - ELSE "That's not something you can consult." - AND obj2 ISA THING - ELSE "That's not something you can find information about." - - - consult = 'look' 'up' (obj2) 'in' (obj1). - - -ADD TO EVERY THING - VERB consult - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can consult." - AND obj1 <> hero - ELSE "It doesn't make sense to consult yourself about anything." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - IF obj1 ISA OBJECT - THEN "You find nothing useful about" SAY THE obj2. "in" SAY THE obj1. "." - ELSE SAY THE obj1. "chooses to be silent on that subject." - END IF. - END VERB. -END ADD TO. - - ---- another 'consult' formulation added to guide players to use the right phrasing: - - -SYNTAX consult_error = consult (obj) - WHERE obj ISA THING - ELSE "That's not something you can consult." - - -ADD TO EVERY THING - VERB consult_error - DOES "To consult something, use the formulation CONSULT PERSON/THING ABOUT PERSON/THING." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CREDITS (+ acknowledgments, author, copyright) - - --- ============================================================== - - -SYNTAX credits = credits. - - -VERB credits - DOES - "The author retains the copyright to this game. - $pThis game was written using the ALAN Adventure Language. ALAN is - an interactive fiction authoring system by Thomas Nilsson. - $nE-mail address: thomas.nilsson@progindus.se $pFurther information - about the ALAN system can be obtained from - the World Wide Web Internet site - $ihttp://www.alanif.se$p" -END VERB. - - -SYNONYMS acknowledgments, author, copyright = credits. - - - --- ============================================================== - - ------ CUT - - --- ============================================================== - - -SYNTAX cut = cut (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can cut." - - -ADD TO EVERY OBJECT - VERB cut - DOES "You need to specify what you want to cut" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CUT WITH - - --- ============================================================== - - -SYNTAX cut_with = cut (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can cut." - AND obj2 ISA OBJECT - ELSE "That's not something you can cut with." - - -ADD TO EVERY OBJECT - VERB cut_with - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "You can't cut something with itself." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "You can't cut" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DANCE - - --- ============================================================== - - -SYNTAX dance = dance. - - -VERB dance - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dance while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dance while lying down." - DOES - "How about a waltz?" -END VERB. - - - --- ============================================================== - - ------ DIG - - --- ============================================================== - - -SYNTAX dig = dig (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can dig." - - -ADD TO EVERY OBJECT - VERB dig - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dig anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dig anything while lying down." - DOES - "There is nothing suitable to dig here." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DIVE - - --- ============================================================== - - -SYNTAX dive = dive. - - -VERB dive - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ DIVE IN - - --- ============================================================== - - -SYNTAX dive_in = dive 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can dive into." - - -ADD TO EVERY OBJECT - VERB dive_in - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - - DOES - "That's not something you can dive into." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DRINK - - --- ============================================================== - - -SYNTAX drink = drink (obj) - WHERE obj ISA LIQUID -- see 'classes.i' - ELSE "That's not something you can drink." - - -ADD TO EVERY LIQUID - VERB drink - CHECK obj IS drinkable - ELSE "That's not something you can drink." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - -- implicit taking: - IF vessel OF obj NOT DIRECTLY IN hero - THEN - IF vessel OF obj = zero_vessel OR vessel OF obj IS NOT takeable - THEN "You can't carry" SAY THE obj. "around in your bare hands." - ELSE LOCATE vessel OF obj IN hero. - "(taking" SAY THE vessel OF obj. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF obj IN hero -- i.e. if the implicit taking was successful - THEN - "You drink all of" SAY THE obj. "." - LOCATE obj AT nowhere. - END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DRIVE - - --- ============================================================== - - -SYNTAX drive = drive (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can drive." - - -ADD TO EVERY OBJECT - VERB drive - DOES - "That's not something you can drive." - END VERB. -END ADD TO. - - --- another 'drive' formulation added to guide players to use the right phrasing: - - -SYNTAX drive_error = drive. - - -VERB drive_error - DOES "To drive something, use the phrasing DRIVE SOMETHING." -END VERB. - - - --- ============================================================== - - ------ DROP - - --- ============================================================== - - -SYNTAX drop = drop (obj)* - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - - drop = put (obj) * down. - - - drop = put down (obj)*. - - -ADD TO EVERY OBJECT - VERB drop - CHECK obj IN hero - ELSE "You don't have" SAY THE obj. "." - DOES - LOCATE obj HERE. - "Dropped." - END VERB. -END ADD TO. - - -SYNONYMS - discard, dump, reject = drop. - - - --- ============================================================== - - ------ EAT - - --- ============================================================== - - -SYNTAX eat = eat (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can eat." - - -ADD TO EVERY OBJECT - VERB eat - CHECK obj IS edible - ELSE "That's not something you can eat." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - "You eat all of" SAY THE obj. "." - LOCATE obj AT nowhere. - - END VERB. -END ADD. - - - --- ============================================================== - - ------ EMPTY - - --- ============================================================== - - - -SYNTAX 'empty' = 'empty' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - AND obj ISA CONTAINER - ELSE "You can only empty containers." - - -ADD TO EVERY OBJECT - VERB 'empty' - CHECK obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. - ELSE "You $v the contents of" SAY THE obj. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - EMPTY obj AT hero. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ EMPTY IN - - --- ============================================================== - - - -SYNTAX empty_in = 'empty' (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can empty." - AND obj1 ISA CONTAINER - ELSE "That's not something you can empty." - AND obj2 ISA OBJECT - ELSE "That's not something you can empty things into." - AND obj2 ISA CONTAINER - ELSE SAY THE obj2. "is not something you can empty things into." - - -ADD TO EVERY OBJECT -VERB empty_in - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to $v something into itself." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 NOT DIRECTLY IN obj2 - ELSE SAY THE obj1. "is already in" SAY THE obj2. "." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 IS NOT closed - ELSE "You can't, since" SAY THE THIS. "is closed." - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj1 = 0 - THEN "There is nothing in" SAY THE obj1. "." - ELSE EMPTY obj1 IN obj2. - "You empty the contents of" SAY THE obj1. - "into" SAY THE obj2. "." - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ EMPTY ON - - --- ============================================================== - - - -SYNTAX empty_on = 'empty' (obj1) 'on' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can empty." - AND obj1 ISA CONTAINER - ELSE "That's not something you can empty." - AND obj2 ISA OBJECT - ELSE - IF obj2 ISA ACTOR - THEN - IF obj2 = hero - THEN "That wouldn't make sense." - ELSE "That wouldn't be polite." - END IF. - ELSE "You can't empty anything onto" SAY THE obj2. "." - END IF. - AND obj2 ISA CONTAINER - ELSE SAY THE obj2. "is not something you can empty things onto." - - - -ADD TO EVERY OBJECT -VERB empty_on - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to $v something on itself." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 IS NOT closed - ELSE "You can't, since" SAY THE obj1. "is closed." - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj1 = 0 - THEN "There is nothing in" SAY THE obj1. "." - ELSE - IF obj2 = floor OR obj2 = ground - THEN EMPTY obj1 AT hero. - "You empty the contents of" SAY THE obj1. "on" SAY THE obj2. "." - ELSIF obj2 ISA SUPPORTER - THEN EMPTY obj1 IN obj2. - "You empty the contents of" SAY THE obj1. "on" SAY THE obj2. "." - ELSE "It wouldn't be sensible to empty anything on" SAY THE obj2. - END IF. - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ ENTER (+ obj) - - --- ============================================================== - - -SYNTAX enter = enter (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can enter." - AND obj ISA CONTAINER - ELSE "That's not something you can enter." - - -ADD TO EVERY OBJECT - VERB enter - CHECK hero IS NOT sitting - ELSE "It is difficult to enter anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to enter anything while lying down." - DOES - "That's not something you can enter." - END VERB. -END ADD TO. - - ---- another 'enter' formulation declared to guide players to use the right formulation: - - -SYNTAX enter_error = enter. - - -VERB enter_error - DOES "You must state what you want to enter." -END VERB. - - - --- ============================================================== - - ------ EXAMINE (+ look at) - - --- ============================================================== - - -SYNTAX examine = examine (obj) - WHERE obj ISA THING - ELSE "That's not something you can examine." - - -SYNTAX examine = 'look' 'at' (obj). - examine = 'look' (obj). -- note that this formulation is allowed, too - - -ADD TO EVERY THING - VERB examine - CHECK obj IS examinable - ELSE "That's not something you can examine." - AND CURRENT LOCATION IS lit - ELSE "You can't see anything in the dark." - DOES - IF obj IS readable - THEN - IF text OF obj = "" - THEN "There is nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. ". It says ""$$" SAY text OF obj. "$$""." - END IF. - ELSE "There is nothing special about" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - 'check', inspect, observe, x = examine. - - - --- ============================================================== - - ------ EXIT (obj) - - --- ============================================================== - - -SYNTAX 'exit' = 'exit' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can exit." - AND obj ISA CONTAINER - ELSE "That's not something you can exit." - - -ADD TO EVERY OBJECT - VERB 'exit' - CHECK hero IN obj - ELSE - IF obj = current_room - THEN "You must state a direction where to go." - ELSE "But you aren't in" SAY THE obj. "!" - END IF. - DOES - "You exit" SAY THE obj. "." - LOCATE hero AT CURRENT LOCATION. - END VERB. -END ADD TO. - - ---- another 'exit' formulation added to guide players to use the right formulation: - - -SYNTAX exit_error = 'exit'. - - -VERB exit_error - DOES - "You must state what you want to exit." -END VERB. - - - --- ============================================================== - - ------ EXTINGUISH (+ put out) - - --- ============================================================== - - -SYNONYMS quench = extinguish. - - -SYNTAX extinguish = extinguish (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can extinguish." - extinguish = put 'out' (obj). - - -ADD TO EVERY OBJECT - VERB extinguish - DOES - "That's not on fire." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL - - --- ============================================================== - - -SYNTAX fill = fill (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can fill." - AND obj ISA CONTAINER - ELSE "That's not something you can fill." - - -ADD TO EVERY OBJECT - VERB fill - DOES - "You have to say what you want to fill" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL WITH - - --- ============================================================== - - -SYNTAX fill_with = fill (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can fill." - AND obj1 ISA CONTAINER - ELSE "That's not something you can fill." - AND obj2 ISA OBJECT - ELSE "It's not possible to fill something with that." - - -ADD TO EVERY OBJECT - VERB fill_with - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to fill something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 NOT IN obj1 - ELSE SAY THE obj1. "is already full of" SAY obj2. "." - AND obj1 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - -- "That wouldn't accomplish anything." - - "You fill" SAY THE obj1. "with" SAY obj2. "." - LOCATE obj2 IN obj1. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIND - - --- ============================================================== - - -SYNTAX - find = find (obj)! - WHERE obj ISA THING - ELSE "That's not something you need to find." - - -ADD TO EVERY THING - VERB find - CHECK obj <> hero - ELSE "You're right here!" - AND CURRENT LOCATION IS lit - ELSE "It's too dark to find anything here." - AND obj NOT HERE - ELSE "The" SAY obj. "is right here!" - DOES - "You'll have to find it yourself." - END VERB. -END ADD TO. - - -SYNONYMS 'locate' = find. - - - --- ============================================================== - - ------ FIRE - - --- ============================================================== - - -SYNTAX fire = fire (obj) - WHERE obj ISA WEAPON - ELSE "That's not something you can fire." - - -ADD TO EVERY OBJECT - VERB fire - CHECK obj IS fireable - ELSE "That's not something you can fire." - AND obj IN hero - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You fire" SAY the obj. "into the air." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIRE AT - - --- ============================================================== - - -SYNTAX fire_at = fire (obj1) 'at' (obj2) - WHERE obj1 ISA WEAPON - ELSE "That's not something you can fire." - AND obj2 ISA THING - ELSE "That's not something you can shoot at." - - -ADD TO EVERY OBJECT - VERB fire_at - WHEN obj1 - CHECK obj1 IS fireable - ELSE "That's not something you can fire." - AND obj1 IN hero - ELSE "You don't have" SAY THE obj1. "." - AND obj2 <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - --- another formulation added: - - -SYNTAX fire_at_error = fire 'at' (obj) - WHERE obj ISA THING - ELSE "That's not something you can fire at." - - -ADD TO EVERY THING -VERB fire_at_error - CHECK COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE "You are not holding any firearm." - AND obj <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIX (mend, repair) - - --- ============================================================== - - -SYNTAX - fix = fix (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB fix - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS broken - ELSE "The" SAY obj. "doesn't need fixing." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "Please be more specific. How do you intend to fix it?" - END VERB. -END ADD TO. - - -SYNONYMS mend, repair = fix. - - - --- ============================================================== - - ------ FLIP - - --- ============================================================== - - -SYNTAX flip = flip (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can flip." - - -ADD TO EVERY OBJECT - VERB flip - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES ONLY - "That's not something you need to flip." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FOLLOW - - --- ============================================================== - - -SYNTAX follow = follow (obj)! - WHERE obj ISA THING - ELSE "That's not something you can follow." - - -ADD TO EVERY ACTOR - VERB follow - CHECK obj <> hero - ELSE "It doesn't make sense to follow yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj NOT AT hero - ELSE SAY THE obj. "is right here." - AND hero IS NOT sitting - ELSE "It is difficult to follow anybody while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to follow anybody while lying down." - AND obj NOT NEAR hero - ELSE "You follow" SAY THE obj. "." - LOCATE hero AT obj. - DOES - "You don't quite know where" SAY THE obj. "went. You must state a direction - where you want to go." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FREE (+ release) - - --- ============================================================== - - -SYNTAX free = free (obj) - WHERE obj ISA THING - ELSE "That's not something you can $v." - - -ADD TO EVERY THING - VERB free - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj <> hero - ELSE "You don't need to be freed at present." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "out of your reach." - DOES - "That doesn't need to be $vd." - END VERB. -END ADD TO. - - -SYNONYMS release = free. - - - --- ============================================================== - - ------- GET OFF - - --- ============================================================== - - -SYNTAX get_off = get off (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can get off." - - -ADD TO EVERY OBJECT - VERB get_off - DOES - IF hero IS sitting OR hero IS lying_down - THEN "You get off" SAY THE obj. "." - MAKE hero NOT lying_down. - MAKE hero NOT sitting. - ELSE "You're standing up already." - END IF. - END VERB. -END ADD TO. - - --- ============================================================== - - ------- GET UP - - --- ============================================================== - - -SYNTAX get_up = get up. - - -VERB get_up - DOES - IF hero IS sitting - THEN "You stand up." - MAKE hero NOT sitting. - ELSIF hero IS lying_down - THEN "You get up." - MAKE hero NOT lying_down. - ELSE "You're standing up already." - END IF. -END VERB. - - - --- ============================================================== - - ------ GIVE (+ hand, offer) - - --- ============================================================== - - -SYNTAX give = 'give' (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only give away objects." - AND obj2 ISA ACTOR - ELSE "That's not something you can give things to." - - - give = give (obj2) (obj1). - - -ADD TO EVERY OBJECT - VERB give - WHEN obj1 - CHECK obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to give something to itself." - AND obj2 <> hero - ELSE "It doesn't make sense to give something to yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is too far away." - AND obj1 NOT IN obj2 - ELSE SAY THE obj2. "already has" SAY THE obj1. "." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - "You give" SAY THE obj1. "to" SAY THE obj2. "." - LOCATE obj1 IN obj2. - - END VERB. -END ADD TO. - - -SYNONYMS hand, offer = give. - - - --- ============================================================== - - ------ GO TO - - --- ============================================================== - - -SYNTAX go_to = 'to' (obj)! -- because 'go' is predefined in the parser, it can't be used - WHERE obj ISA THING -- in verb definitions - ELSE "It's not possible to go to that." - - -ADD TO EVERY THING - VERB go_to - CHECK obj <> hero - ELSE "You're right here!" - AND hero IS NOT sitting - ELSE "It is difficult to go anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to go anywhere while lying down." - DOES - IF obj AT hero - THEN - IF obj IS NOT reachable - THEN "You can't reach" SAY THE obj. "from here." - ELSE - IF CURRENT LOCATION IS lit - THEN "That's right here!" - ELSE "It is too dark to see." - END IF. - END IF. - ELSE "You can't see" SAY THE obj. "anywhere nearby. You must state a - direction where you want to go." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS walk = go. -- here we define a synonym for the predefined parser word 'go' - -- which is not visible in the syntax itself. - -- Thus, you will be able to say e.g. both 'go to shop' and 'walk to shop' - -- (as well as e.g. both 'go east' and 'walk east'). - - - --- ============================================================== - - ------ HELP -> see ABOUT - - --- ============================================================== - - - - - --- ============================================================== - - ------ HINT (+ hints) - - --- ============================================================== - - -SYNTAX hint = hint. - - -VERB hint - DOES - "Unfortunately hints are not available in this game." -END VERB. - - -SYNONYMS - hints = hint. - - - --- ============================================================== - - ------ INVENTORY (+ i, inv) - - --- ============================================================== - - -ADD TO EVERY THING - IS weight 0. -END ADD TO THING. - - -ADD TO EVERY ACTOR - IS weight 50. -END ADD TO ACTOR. - - -ADD TO EVERY OBJECT - IS weight 5. -END ADD TO OBJECT. - - -SYNTAX i = i. - - -VERB i - DOES - LIST hero. - - -- if the hero in your game carries any containers you want the contents of - -- to be listed after 'inventory', you should manually add the listing right here - -- according to the following example: - -- - -- IF bag IN hero - -- THEN LIST bag. - -- END IF. - -- - -- This way, 'inventory' will yield e.g. "You are carrying a bag. The bag contains a book." - -- If you leave the above addition out, the outcome will be just "You are carrying a bag.", with - -- no comment on what is inside the bag. - - IF COUNT IN worn > 0 -- see the file 'classes.i', subclass 'clothing' - THEN LIST worn. - END IF. - -END VERB. - - -SYNONYMS inv, inventory = i. - - - --- ============================================================== - - ------ JUMP - - --- ============================================================== - - -SYNTAX jump = jump. - - -VERB jump - CHECK hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "You jump on the spot, to no avail." -END VERB. - - - --- ============================================================== - - ------ JUMP IN - - --- ============================================================== - - -SYNTAX jump_in = jump 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can jump into." - AND obj ISA CONTAINER - ELSE "That's not something you can jump into." - - -ADD TO EVERY OBJECT - VERB jump_in - CHECK CURRENT LOCATION IS lit - ELSE "It's too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "That's not something you can jump into." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ JUMP ON - - --- ============================================================== - - -SYNTAX jump_on = jump 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can jump on." - AND obj ISA SUPPORTER - ELSE "That's not something you can jump on." - - -ADD TO EVERY OBJECT - VERB jump_on - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - IF obj ISA SUPPORTER - THEN "That wouldn't accomplish anything." - ELSE "That's not something you can jump onto." - END IF. - END VERB. -END ADD TO. - - --- ============================================================= - - ------ KICK - - --- ============================================================= - - -SYNTAX kick = kick (obj) - WHERE obj ISA THING - ELSE "Thats not something you can kick." - - -ADD TO EVERY THING - VERB kick - CHECK obj IS examinable - ELSE "That's not something you can kick." - AND obj <> hero - ELSE "It doesn't make sense to kick yourself." - AND obj NOT IN hero - ELSE "It doesn't make much sense to kick something you're holding." - AND obj NOT IN worn - ELSE "It doesn't make sense to kick something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - DOES "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL (+ murder) - - --- ============================================================== - - -SYNTAX kill = kill (obj) - WHERE obj ISA ACTOR - ELSE "That's not something you can $v." - - -ADD TO EVERY ACTOR - VERB kill - CHECK obj <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL WITH - - --- ============================================================== - - -SYNTAX kill_with = kill (obj1) 'with' (obj2) - WHERE obj1 ISA ACTOR - ELSE "That's not something you can $v." - AND obj2 ISA WEAPON - ELSE "You cannot kill anybody with" SAY THE obj2. "." - - -ADD TO EVERY ACTOR - VERB kill_with - WHEN obj1 - CHECK obj1 <> hero - ELSE "There's no need to be that desperate." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ KISS (+ hug, embrace) - - --- ============================================================== - - -SYNTAX kiss = kiss (obj) - WHERE obj ISA THING - ELSE "That's not something you can kiss." - - -ADD TO EVERY THING - VERB kiss - CHECK obj IS examinable - ELSE "That's not something you can kiss." - AND obj <> hero - ELSE "There is no time for that now." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj ISA ACTOR - THEN SAY THE obj. "avoids your advances." - ELSE "Nothing would be achieved by that." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS hug, embrace = kiss. - - - --- ============================================================== - - ------ KNOCK - - --- ============================================================== - - -SYNTAX knock = knock 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can knock on." - - - knock = knock (obj). - - -ADD TO EVERY OBJECT - VERB knock - CHECK obj IS examinable - ELSE "That's not something you can knock on." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You knock on" SAY THE obj. "$$. Nothing happens." - END VERB. -END ADD TO. - - ---- another 'knock' formulation added to guide players to use the right phrasing: - - -SYNTAX knock_error = knock. - - -VERB knock_error - DOES - "Please use the formulation KNOCK ON SOMETHING to knock on something." -END VERB. - - - --- ============================================================== - - ------ LIE DOWN - - --- ============================================================== - - -SYNTAX lie_down = lie 'down'. - - lie_down = lie. - - -VERB lie_down - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down right now." - -- If you need this to work, insert the following lines instead of the above: - -- DOES "You lie down." - -- MAKE hero lying_down. - -- MAKE hero NOT sitting_down. -END VERB. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE IN - - --- ============================================================== - - -SYNTAX lie_in = lie 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can lie in." - AND obj ISA CONTAINER - ELSE "That's not something you can lie in." - - - lie_in = lie 'down' 'in' (obj). - - -ADD TO EVERY OBJECT - VERB lie_in - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down in" SAY THE obj. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down in" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE ON - - --- ============================================================== - - -SYNTAX lie_on = lie 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can lie on." - - - lie_on = lie 'down' 'on' (obj). - - -ADD TO EVERY OBJECT - VERB lie_on - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down on" SAY THE obj. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down on" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIFT - - --- ============================================================== - - -SYNTAX lift = lift (obj) - WHERE obj ISA THING - ELSE "That's not something you can lift." - - -ADD TO EVERY THING - VERB lift - CHECK obj IS examinable - ELSE "That's not something you can lift." - AND obj IS reachable - ELSE "The object is too far away." - AND obj IS movable - ELSE "That's not something you can lift." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND obj <> hero - ELSE "It doesn't make sense to lift yourself." - AND obj NOT IN hero - ELSE "You're already holding" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LIGHT (+ lit) - - --- ============================================================== - - -SYNTAX light = light (obj) - WHERE obj ISA LIGHTSOURCE - ELSE "That's not something you can $v." - - -ADD TO EVERY OBJECT - VERB light - CHECK obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "That's not something you can $v." - END VERB. -END ADD TO. - - -SYNONYMS lit = light. - - - --- ============================================================== - - ------ LISTEN - - --- ============================================================== - - -SYNTAX listen0 = listen. - - -VERB listen0 - DOES - "You hear nothing unusual." -END VERB. - - - --- ============================================================== - - ------ LISTEN TO - - --- ============================================================== - - -SYNTAX listen = listen 'to' (obj)! - WHERE obj ISA THING - ELSE "That's not something you can listen to." - - -ADD TO EVERY THING - VERB listen - CHECK obj <> hero - ELSE "It doesn't make sense to listen to yourself." - DOES - IF obj AT hero - THEN "You hear nothing unusual." - ELSIF obj NEAR hero - THEN "You can't hear" SAY THE obj. "very well from here." - ELSE "You can't hear anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK - - --- ============================================================== - - -SYNTAX lock = lock (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can lock." - - -ADD TO EVERY OBJECT - VERB lock - CHECK obj IS lockable - ELSE "That's not something you can lock." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS NOT locked - ELSE "It's already locked." - DOES - "You have to state what you want to lock" SAY THE obj. "with." - -- If you need this to work, use the following lines instead: - -- MAKE obj locked. "You" - -- IF obj IS NOT closed - -- THEN "close and" - -- MAKE obj closed. - -- END IF. - -- "lock" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK WITH - - --- ============================================================== - - -SYNTAX lock_with = lock (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can lock." - AND obj2 ISA OBJECT - ELSE "You can't lock anything with that." - - -ADD TO EVERY OBJECT - VERB lock_with - WHEN obj1 - CHECK obj1 IS lockable - ELSE "That's not something you can lock." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS NOT locked - ELSE "It's already locked." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE - "You don't have" SAY THE obj2. "." - DOES - "You can't lock" SAY THE obj1. "with" SAY THE obj2. "." - -- If you need this to work, use the following lines instead: - -- MAKE obj1 locked. "You" - -- IF obj1 IS NOT closed - -- THEN "close and" - -- MAKE obj1 closed. - -- END IF. - -- "lock" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK - - --- ============================================================== - - -SYNTAX 'look' = 'look'. - - -VERB 'look' - DOES - LOOK. - INCREASE described OF CURRENT LOCATION. - -- see 'locations.i', attribute 'described'. -END VERB. - - -SYNONYMS l = 'look'. - - - --- ============================================================== - - ------ LOOK AT -> see EXAMINE - - --- ============================================================== - - - - - --- ============================================================== - - ------ LOOK BEHIND - - --- ============================================================== - - -SYNTAX look_behind = 'look' behind (obj) - WHERE obj ISA THING - ELSE "You can't look behind that." - - -ADD TO EVERY THING - VERB look_behind - CHECK obj IS examinable - ELSE - "You can't look behind" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj <> hero - ELSE "Turning your head, you notice nothing unusual behind yourself." - DOES - "You notice nothing unusual behind" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK IN - - --- ============================================================== - - -SYNTAX - look_in = 'look' 'in' (obj) - WHERE obj ISA OBJECT - ELSE "You can't look inside" SAY THE obj. "." - AND obj ISA CONTAINER - ELSE "You can't look inside" SAY THE obj. "." - - -ADD TO EVERY OBJECT - VERB look_in - CHECK obj IS examinable - ELSE - "You can't look inside" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - - DOES - LIST obj. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK OUT OF - - --- ============================================================== - - -SYNTAX look_out_of = 'look' 'out' 'of' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can look out of." - - -ADD TO EVERY OBJECT - VERB look_out_of - CHECK obj IS examinable - ELSE - "You can't look out of" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That's not something you can look out of." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK THROUGH - - --- ============================================================== - - -SYNTAX look_through = 'look' through (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can look through." - - -ADD TO EVERY OBJECT - VERB look_through - CHECK obj IS examinable - ELSE "You can't look through" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't see through" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UNDER - - --- ============================================================== - - -SYNTAX look_under = 'look' under (obj) - WHERE obj ISA THING - ELSE "You can't look under that." - - -ADD TO EVERY THING - VERB look_under - CHECK obj IS examinable - ELSE "You can't look under" SAY THE obj. "." - AND obj <> hero - ELSE "It doesn't make sense to look under yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You notice nothing unusual under" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UP (-> see also CONSULT) - - --- ============================================================== - - -SYNTAX look_up = 'look' up. - - -VERB look_up - DOES "Looking up, you see nothing unusual." -END VERB. - - - --- ============================================================== - - ------ NO - - --- ============================================================== - - -SYNTAX 'no' = 'no'. - - -VERB 'no' - DOES "You sound rather negative." -END VERB. - - - --- ============================================================== - - ------ NOTIFY - - --- ============================================================== - - --- Thanks to Steve Griffiths whose 'Score notification' sample was used --- in declaring this verb. - - - -SYNTAX notify = notify. - - notify_on = notify 'on'. -- The instructions tell the player that mere 'notify' - -- is enough, but these two verbs are implemented - notify_off = notify 'off'. -- in case (s)he adds the prepositions to the end anyway. - - -VERB notify - DOES - IF hero IS notify_on - THEN MAKE hero NOT notify_on. - "Score notification is now disabled. (You can turn it back on - using the NOTIFY command again.)" - ELSE MAKE hero notify_on. "Score notification is now enabled. - (You can turn it off using the NOTIFY command again.)" - END IF. -END VERB. - - -VERB notify_on - DOES - IF hero IS notify_on - THEN "Score notification is already enabled." - ELSE MAKE hero notify_on. - "Score notification is now enabled. - (You can turn it off using the NOTIFY command again.)" - END IF. -END VERB. - - -VERB notify_off - DOES - IF hero IS notify_on - THEN MAKE hero NOT notify_on. - "Score notification is now disabled. (You can turn it back on - using the NOTIFY command again.)" - ELSE "Score notification is already disabled." - END IF. -END VERB. - - --- The 'notify' verb allows the players to disable the score change --- messages. (Some players find such messages annoying.) --- The verb toggles the hero's 'notify_on' attribute on and off. That --- attribute is checked by the 'checkscore' event to determine whether --- to display the score msg or not. - - --- The following event is run each turn to check if the game score is greater than --- the last recorded score (which is stored in the Hero's 'oldscore' --- attribute). If the score is greater, then the 'Score has gone up...' --- text is displayed (as long as the player hasn't disabled it by using the --- 'notify' verb - which sets 'notify_on' to off --- - i.e. the hero 'IS NOT notify_on'.) - --- NOTE: The ALAN scoring system records the game score in a thing called --- score. It isn't called score OF anything; its just 'score'. - --- NOTE: This event assumes score can only increase, if score can go --- down then would need to modify this code a bit. - - -EVENT check_score - IF oldscore OF hero < score - THEN - IF hero IS notify_on - THEN -- ie: the player wants to see score msgs - "$p(Your score has just gone up by" SAY (score - oldscore OF hero). - IF (score - oldscore OF hero) = 1 - THEN "point.)" - ELSE "points.)" - END IF. - -- this msg only displayed the first time player is notified - -- of a score change - IF hero IS NOT seen_notify - THEN MAKE hero seen_notify. - "$p(You can use the NOTIFY command to disable score change messages.)" - END IF. - END IF. - - SET oldscore OF hero TO score. - END IF. - -- run the 'check_score' event again next turn: - SCHEDULE check_score AT hero AFTER 1. -END EVENT. - - - - --- ============================================================== - - ------ OPEN - - --- ============================================================== - - -SYNTAX open = open (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can open." - - -ADD TO EVERY OBJECT - VERB open - CHECK obj IS closeable - ELSE "That's not something you can open." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS closed - ELSE SAY THE obj. "is already open." - AND obj IS NOT locked - ELSE SAY THE obj. "appears to be locked." - DOES - MAKE obj NOT closed. - "You open" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ OPEN WITH - - --- ============================================================== - - -SYNTAX open_with = open (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can open." - AND obj2 ISA OBJECT - ELSE "You can't open anything with" SAY THE obj2. - - -ADD TO EVERY OBJECT - VERB open_with - WHEN obj1 - CHECK obj1 IS closeable - ELSE "That's not something you can open." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 IS closed - ELSE SAY THE obj1. "is already open." - AND obj1 IS NOT locked - ELSE SAY THE obj1. "appears to be locked." - DOES - "You can't open" SAY THE obj1. "with" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY - - --- ============================================================== - - -SYNTAX 'play' = 'play' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can play." - - -ADD TO EVERY OBJECT - VERB 'play' - DOES - "That's not something you can play." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY WITH - - --- ============================================================== - - -SYNTAX play_with = 'play' 'with' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can play with." - - -ADD TO EVERY OBJECT - VERB play_with - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "After second thoughts you don't find it purposeful to start - playing with" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR - - --- ============================================================== - - -SYNTAX pour = pour (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can pour." - AND obj ISA CONTAINER - ELSE "That's not something you can pour." - - -ADD TO EVERY OBJECT -VERB pour - CHECK obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. "is closed." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. "." - ELSE EMPTY obj AT hero. - "You pour the contents of" SAY THE obj. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - END IF. - -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR IN - - --- ============================================================== - - - -SYNTAX pour_in = pour (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pour." - AND obj1 ISA CONTAINER - ELSE "That's not something you can pour." - AND obj2 ISA OBJECT - ELSE "That's not something you can pour things into." - AND obj2 ISA CONTAINER - ELSE SAY THE obj2. "is not something you can pour things into." - - -ADD TO EVERY OBJECT -VERB pour_in - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to $v something into itself." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 NOT DIRECTLY IN obj2 - ELSE SAY THE obj1. "is already in" SAY THE obj2. "." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 IS NOT closed - ELSE "You can't, since" SAY THE THIS. "is closed." - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj1 = 0 - THEN "There is nothing in" SAY THE obj1. "." - ELSE EMPTY obj1 IN obj2. - "You pour the contents of" SAY THE obj1. - "into" SAY THE obj2. "." - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR ON - - --- ============================================================== - - - -SYNTAX pour_on = pour (obj1) 'on' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pour." - AND obj1 ISA CONTAINER - ELSE "That's not something you can pour." - AND obj2 ISA OBJECT - ELSE - IF obj2 ISA ACTOR - THEN - IF obj2 = hero - THEN "That wouldn't make sense." - ELSE "That wouldn't be polite." - END IF. - ELSE "You can't pour anything onto" SAY THE obj2. "." - END IF. - AND obj2 ISA CONTAINER - ELSE SAY THE obj2. "is not something you can pour things onto." - - - -ADD TO EVERY OBJECT -VERB pour_on - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to $v something on itself." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - AND obj1 IS NOT closed - ELSE "You can't, since" SAY THE obj1. "is closed." - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj1 = 0 - THEN "There is nothing in" SAY THE obj1. "." - ELSE - IF obj2 = floor OR obj2 = ground - THEN EMPTY obj1 AT hero. - "You pour the contents of" SAY THE obj1. "on" SAY THE obj2. "." - ELSIF obj2 ISA SUPPORTER - THEN EMPTY obj1 IN obj2. - "You pour the contents of" SAY THE obj1. "on" SAY THE obj2. "." - ELSE "It wouldn't be sensible to pour anything on" SAY THE obj2. - END IF. - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PRAY - - --- ============================================================== - - -SYNTAX pray = pray. - - -VERB pray - DOES "Your prayers don't seem to help right now." -END VERB. - - - --- ============================================================== - - ------ PRY - - --- ============================================================== - - -SYNTAX pry = pry (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can pry." - - -ADD TO EVERY OBJECT -VERB pry - DOES "You must state what you want to pry" SAY THE obj. "with." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PRY_WITH - - --- ============================================================== - - -SYNTAX pry_with = pry (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can pry." - AND obj2 ISA OBJECT - ELSE "You can't pry anything with that." - - -ADD TO EVERY OBJECT -VERB pry_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can pry." - AND obj1 <> obj2 - ELSE "How intelligent." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES "That doesn't work." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PULL - - --- ============================================================== - - -SYNTAX pull = pull (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense to pull yourself." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE "That's not something you can pull." - END IF. - - -ADD TO EVERY OBJECT -VERB pull - CHECK obj IS movable - ELSE "It's not possible to pull" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES "That wouldn't accomplish anything." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUSH - - --- ============================================================== - - -SYNTAX push = push (obj) - WHERE obj ISA THING - ELSE "That's not something you can push." - - -ADD TO EVERY OBJECT - VERB PUSH - CHECK obj IS movable - ELSE "That's not something you can push." - AND obj NOT IN hero - ELSE "But you're holding" SAY THE obj. "." - AND obj <> hero - ELSE "It doesn't make sense to push yourself." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You give" SAY THE obj. "a little push. Nothing happens." - END VERB. -END ADD TO. - - -SYNONYMS press = push. - - - --- ============================================================== - - ------ PUSH WITH - - --- ============================================================== - - -SYNTAX push_with = push (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can push." - AND obj2 ISA OBJECT - ELSE "You can use only objects to push things with." - - -ADD TO EVERY OBJECT - VERB push_with - WHEN obj1 - CHECK obj1 IS movable - ELSE "That's not something you can push." - AND obj1 <> obj2 - ELSE "It doesn't make sense to push something with itself." - AND obj1 NOT IN hero - ELSE "But you're holding" SAY THE obj1. "." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> hero - ELSE "It doesn't make sense to push yourself with something." - AND obj1 IS inanimate - ELSE SAY THE obj1. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "Using" SAY THE obj2. "you push" SAY THE obj1. "$$. Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT (+ lay, locate, place) - - --- ============================================================== - - -SYNTAX put = put (obj) - WHERE obj ISA OBJECT - ELSE "You can't put that anywhere." - - -ADD TO EVERY OBJECT - VERB put - CHECK obj IN HERO - ELSE "You don't have" SAY THE obj. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You must state where you want to put it." - END VERB. -END ADD TO. - - -SYNONYMS lay, place = put. - - - --- ============================================================== - - ------ PUT DOWN (works as 'drop') - - --- ============================================================== - - ------ The syntax for 'put down' has been declared in the 'drop' verb. - - - - - --- ============================================================== - - ------ PUT IN (+ insert) - - --- ============================================================== - - -SYNTAX put_in = put (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN - IF obj1 = hero - THEN "It doesn't make sense to put yourself into something." - ELSE SAY THE obj1. "wouldn't probably appreciate that." - END IF. - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA OBJECT - ELSE "That's not something you can put things in." - AND obj2 ISA CONTAINER - ELSE "You can't put anything there." - - - put_in = insert (obj1) 'in' (obj2). - - -ADD TO EVERY OBJECT - VERB put_in - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "It doesn't make sense to put something into itself." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND obj1 NOT IN obj2 - ELSE - IF obj2 ISA SUPPORTER - THEN "You can't put" SAY THE obj1. "inside" SAY THE obj2. "." - ELSE SAY THE obj1. "is in" SAY THE obj2. "already." - END IF. - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - LOCATE obj1 IN obj2. - "You put" SAY THE obj1. "into" SAY THE obj2. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT BEHIND, NEAR, UNDER - - --- ============================================================== - - -SYNTAX put_near = put (obj1) 'near' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything near that." - - - put_behind = put (obj1) behind (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything behind that." - - - put_under = put (obj1) under (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN SAY THE obj1. "wouldn't probably appreciate that." - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA THING - ELSE "You can't put anything under that." - - -ADD TO EVERY OBJECT - VERB put_near, put_behind, put_under - WHEN obj1 - CHECK obj2 NOT IN hero - ELSE "That would be futile." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - - AND obj1 <> obj2 - ELSE "That doesn't make sense." - AND obj2 <> hero - ELSE "That would be futile." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - "That wouldn't accomplish anything." - - -- To make it work, type e.g.: - -- IF obj1 NOT IN hero - -- THEN "(taking" SAY THE obj1. "first)$n" - -- END IF. - -- "You put" SAY THE obj1. "near" --(or behind or under) SAY THE obj2. "." - -- (+ you would need to define some attributes to check that - -- the object is behind another object, etc.) - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT_ON - - --- ============================================================== - - --- To use this verb in the meaning 'wear', see the file 'classes.i', --- class 'clothing', verb 'wear'. - --- You can put things on the floor/ground or on a supporter. In other --- cases, the response will be "That wouldn't accomplish anything." - - - -SYNTAX put_on = put (obj1) 'on' (obj2) - WHERE obj1 ISA OBJECT - ELSE - IF obj1 ISA ACTOR - THEN - IF obj1 = hero - THEN "That would be futile." - ELSE SAY THE obj1. "wouldn't probably - appreciate that." - END IF. - ELSE "You can't put that anywhere." - END IF. - AND obj2 ISA OBJECT - ELSE "You can't well put anything on that." - AND obj2 ISA CONTAINER - ELSE "You can't well put anything on that." - - -ADD TO EVERY OBJECT - VERB put_on - WHEN obj1 - CHECK obj2 NOT IN hero - ELSE "That would be futile." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "That doesn't make sense." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is on" SAY THE obj2. "already." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - IF obj2 = floor OR obj2 = ground - THEN LOCATE obj1 AT hero. - "You put" SAY THE obj1. "on" SAY THE obj2. "." - ELSIF obj2 ISA SUPPORTER - THEN LOCATE obj1 IN obj2. - "You put" SAY THE obj1. "on" SAY THE obj2. "." - ELSE "That wouldn't accomplish anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT OUT (works as -> EXTINGUISH) - - --- ============================================================== - - ------ The syntax for 'put out' has been declared in the 'extinguish' verb. - - - --- ============================================================== - - ------ QUIT - - --- ============================================================== - - -SYNTAX - 'quit' = 'quit'. - - -VERB 'quit' - DOES - QUIT. -END VERB. - - -SYNONYMS q = 'quit'. - - - --- ============================================================== - - ------ READ - - --- ============================================================== - - -SYNTAX read = read (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can read." - - -ADD TO EVERY OBJECT - VERB read - CHECK obj IS readable - ELSE - "That's not something you can read." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is too far away." - DOES - IF text OF obj = "" - THEN "There's nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. ". It says ""$$" SAY text OF obj. "$$""." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - --- REMOVE - - --- ============================================================== - - --- see the file 'classes.i', subclass 'clothing' for the definition of --- this verb - - - - - --- ============================================================== - - ------ REMOVE FROM ( => TAKE FROM) - - --- ============================================================== - - ------ this verb works as 'take from' - - - --- ============================================================== - - ------ RESTART - - --- ============================================================== - - -SYNTAX 'restart' = 'restart'. - - -VERB 'restart' - DOES - RESTART. -END VERB. - - - --- ============================================================== - - ------ RESTORE - - --- ============================================================== - - -SYNTAX 'restore' = 'restore'. - - -VERB 'restore' - DOES - RESTORE. -END VERB. - - - --- ============================================================== - - ------ RUB (+ massage) - - --- ============================================================== - - -SYNTAX rub = rub (obj) - WHERE obj ISA THING - ELSE "That's not something you can rub." - - -ADD TO EVERY THING - VERB rub - CHECK obj IS examinable - ELSE "That's not something you can rub." - AND obj <> hero - ELSE "There's no time for that now." - AND obj IS inanimate - ELSE "You aren't sure whether" SAY THE obj. - "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS massage = rub. - - - --- ============================================================== - - ------ SAVE - - --- ============================================================== - - -SYNTAX 'save' = 'save'. - - -VERB 'save' - DOES - SAVE. -END VERB. - - - --- ============================================================== - - ------ SAY - - --- ============================================================== - - -SYNTAX 'say' = 'say' (str) - WHERE str ISA STRING - ELSE "That's not something you can say." - - -ADD TO EVERY THING - VERB 'say' - DOES - "You utter" SAY str. "$$. Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SAY TO - - --- ============================================================== - - -SYNTAX say_to = 'say' (str) 'to' (act) - WHERE str ISA STRING - ELSE "Nothing happens." - AND act ISA ACTOR - ELSE "That's not something you can talk to." - - -ADD TO EVERY THING - VERB say_to - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act IS reachable - ELSE SAY THE act. "is too far away." - DOES - SAY THE act. "doesn't seem interested." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SCORE - - --- ============================================================== - - -SYNTAX 'score' = 'score'. - - -VERB 'score' - DOES - SCORE. - -- (or, if you wish to disable the score, use the following kind of - -- line instead of the above:) - -- "There is no score in this game." -END VERB 'score'. - - - --- ============================================================== - - ------ SCRATCH - - --- ============================================================== - - -SYNTAX scratch = scratch (obj) - WHERE obj ISA THING - ELSE "That's not something you can scratch." - - -ADD TO EVERY THING - VERB scratch - CHECK obj IS examinable - ELSE "That's not something you can scratch." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND obj <> hero - ELSE "That wouldn't help matters." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------- SEARCH - - --- ============================================================== - - -SYNTAX search = search (obj) - WHERE obj ISA THING - ELSE "That's not something you can search." - - -ADD TO EVERY THING - VERB search - CHECK obj <> hero - ELSE LIST hero. - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You find nothing of interest." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SELL - - --- ============================================================== - - -SYNTAX sell = sell (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can sell." - - -ADD TO EVERY OBJECT - VERB sell - CHECK obj IS examinable - ELSE "That's not something you can sell." - DOES - "There's nobody here who would be interested to buy" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHAKE - - --- ============================================================== - - -SYNTAX shake = shake (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense - to shake yourself." - ELSE SAY THE obj. "wouldn't probably - appreciate that." - END IF. - ELSE "That's not something you can shake." - END IF. - - -ADD TO EVERY OBJECT -VERB shake - CHECK obj IS examinable - ELSE "That's not something you can shake." - AND obj IS movable - ELSE "Shaking" SAY THE obj. "is not possible." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF obj IN hero - THEN "You shake" SAY THE obj. "cautiously in your hands. Nothing happens." - ELSE "There is no reason to start shaking" SAY THE obj. "." - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOOT - - --- ============================================================== - - - -SYNTAX shoot = shoot (obj) - WHERE obj ISA THING - ELSE "That's not something you can shoot." - shoot = shoot 'at' (obj). - -ADD TO EVERY THING - VERB shoot - CHECK obj <> hero - ELSE "There's no need to be that desperate." - AND COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE "You don't have anything to shoot with." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - --- another 'shoot' formulation added, to guide players to use the right phrasing: - - -SYNTAX shoot_error = shoot. - - -VERB shoot_error - DOES "You must state what you want to shoot, e.g. SHOOT BEAR WITH RIFLE." -END VERB. - - - --- ============================================================== - - ------ SHOOT WITH - - --- ============================================================== - - -SYNTAX shoot_with = shoot (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can shoot." - AND obj2 ISA WEAPON - ELSE "That's not something you can shoot with." - - shoot_with = shoot (obj2) 'at' (obj1). - -- to allow player input such as 'shoot rifle at bear' - - -ADD TO EVERY THING - VERB shoot_with - WHEN obj1 - CHECK obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 IS examinable - ELSE "That's not something you can shoot." - AND obj2 IS fireable - ELSE "That's not something you can shoot with." - AND obj1 <> hero - ELSE "There's no need to be that desperate." - AND obj1 <> obj2 - ELSE "It doesn't make sense to shoot something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the answer." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOUT - - --- ============================================================== - - -SYNTAX shout = shout. - - -VERB shout - DOES - "Nothing results from your $ving." -END VERB. - - -SYNONYMS scream, yell = shout. - - - --- ============================================================== - - ------ SHOW - - --- ============================================================== - - -SYNTAX 'show' = 'show' (obj1) 'to' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can show." - AND obj2 ISA ACTOR - ELSE "That's not something you can show things to." - - -ADD TO EVERY THING - VERB 'show' - WHEN obj1 - CHECK obj1 IN hero - ELSE "You don't have" SAY THE obj1. "." - AND obj2 <> hero - ELSE "It doesn't make sense to show something to yourself." - AND obj1 <> obj2 - ELSE "It doesn't make sense to show something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - SAY THE obj2. "is not especially interested." - END VERB. -END ADD TO. - - -SYNONYMS reveal = 'show'. - - - --- ============================================================== - - ------ SING (+ hum, whistle) - - --- ============================================================== - - -SYNTAX sing = sing. - - -VERB sing - DOES - "You $v a little tune." -END VERB. - - -SYNONYMS hum, whistle = sing. - - - --- ============================================================== - - ------ SIP - - --- ============================================================== - - -SYNTAX sip = sip (obj) - WHERE obj ISA LIQUID - ELSE "That's not something you can drink." - - -ADD TO EVERY OBJECT - VERB sip - CHECK obj IS drinkable - ELSE "That's not something you can drink." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF vessel OF obj NOT DIRECTLY IN hero - THEN - IF vessel OF obj = zero_vessel OR vessel OF obj IS NOT takeable - THEN "It's not worth the bother trying to take a sip of" SAY THE obj. "." - ELSE LOCATE vessel OF obj IN hero. - "(taking" SAY THE vessel OF obj. "first)$n" - END IF. - END IF. - - "You take a sip of" SAY THE obj. "$$. It tastes rather good." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SIT - - --- ============================================================== - - -SYNTAX sit = sit. - - - sit = sit 'down'. - - -VERB sit - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - DOES - "You feel no urge to sit down at present." - -- (or, if you wish to make it work, use the following instead of the above: - -- IF hero IS lying_down - -- THEN "You sit up." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down." - -- END IF. - -- MAKE hero sitting. -END VERB. - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SIT_ON - - --- ============================================================== - - -SYNTAX sit_on = sit 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can sit on." - - -ADD TO EVERY SUPPORTER - VERB sit_on - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You feel no urge to sit down at present." - -- (or, to make it work, use the following instead of the above:) - -- IF hero lying_down - -- THEN "You get up and sit down on" SAY THE obj. "." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down on" SAY THE obj. "." - -- END IF. - -- LOCATE hero IN obj. - -- MAKE hero sitting. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SLEEP (+ rest) - - --- ============================================================== - - -SYNTAX sleep = sleep. - - -VERB sleep - DOES - "There's no need to $v right now." -END VERB. - - -SYNONYMS rest = sleep. - - - --- ============================================================== - - ------ SMELL (smell0) - - --- ============================================================== - - -SYNTAX smell0 = smell. - - -VERB smell0 - DOES - "You smell nothing unusual." -END VERB. - - - --- ============================================================== - - ------ SMELL (+ obj) - - --- ============================================================== - - -SYNTAX smell = smell (obj)! - WHERE obj ISA THING - ELSE "That's not something you can smell." - - -ADD TO EVERY THING - VERB smell - DOES - IF obj ISA SOUND - THEN "That's not something you can smell." - ELSE "You smell nothing unusual." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SQUEEZE - - --- ============================================================== - - -SYNTAX squeeze = squeeze (obj) - WHERE obj ISA THING - ELSE "That's not something you can squeeze." - - -ADD TO EVERY THING - VERB squeeze - CHECK obj IS examinable - ELSE "That's not something you can squeeze." - AND CURRENT LOCATION IS lit - ELSE - IF obj = hero - THEN "Nothing would be achieved by that." - -- you can squeeze yourself in the dark, as well - ELSE "It is too dark to see." - END IF. - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - - DOES - IF obj ISA ACTOR - THEN "That wouldn't be polite." - ELSE "Trying to squeeze" SAY THE obj. "wouldn't be sensible." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ STAND - - --- ============================================================== - - -SYNTAX stand = stand. - - - stand = stand 'up'. - - -VERB stand - CHECK hero IS NOT lying_down - ELSE "You get up." - MAKE hero NOT lying_down. - AND hero IS NOT sitting - ELSE "You stand up." - MAKE hero NOT sitting. - DOES - "You're standing up already." -END VERB. - - - --- ============================================================== - - ------ STAND_ON - - --- ============================================================== - - -SYNTAX stand_on = stand 'on' (obj) - WHERE obj ISA SUPPORTER - ELSE "That's not something you can stand on." - - - stand_on = get 'on' (obj). - - -ADD TO EVERY SUPPORTER -VERB stand_on - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You feel no urge to stand on" SAY THE obj. "." - -- or, to make it work, use the following instead of the above: - -- "You get on" SAY THE obj. "." - -- LOCATE hero IN obj. - -- MAKE hero NOT sitting. MAKE hero NOT lying_down. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWIM - - --- ============================================================== - - -SYNTAX swim = swim. - - -VERB swim - CHECK hero IS NOT sitting - ELSE "It is difficult to try swimming while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to try swimming while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ SWIM IN - - --- ============================================================== - - -SYNTAX swim_in = swim 'in' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can swim in." - AND obj ISA CONTAINER - ELSE "That's not something you can swim in." - - -ADD TO EVERY OBJECT -VERB swim_in - CHECK hero IS NOT sitting - ELSE "It is difficult to swim anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to swim anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That's not something you can swim in." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH - - --- ============================================================== - - --- This is a mere 'switch' verb with no 'on' or 'off' following after it. --- This verb is defined further in 'classes.i', under 'device' and 'lightsource'. --- This verb exists just to cover cases where the player forgets to write --- 'on' or 'off' after 'switch'. --- If the player types 'switch tv', the tv object will be switched on --- if it is off, and vice cersa. --- Below, just the basic syntax is declared. - - - -SYNTAX switch = switch (obj) - WHERE obj ISA THING - ELSE "That's not something you can switch." - - -ADD TO EVERY THING - VERB switch - DOES "That's not something you can switch." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH ON - - --- ============================================================== - - ------ The syntax for 'switch on' has been declared in the 'turn_on' verb. - - - - --- ============================================================== - - ------ SWITCH OFF - - --- ============================================================== - - ------ The syntax for 'switch off' has been declared in the 'turn_off' verb. - - - - --- ============================================================== - - ------ TAKE (+ carry, get, grab, hold, obtain, pick up) - - --- ============================================================== - - -SYNTAX take = take (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "Taking yourself is not possible." - ELSE SAY THE obj. "would probably object to that." - END IF. - ELSE "That's not something you can take." - END IF. - - - take = get (obj). - - - take = pick up (obj). - - - take = pick (obj) up. - - -ADD TO EVERY OBJECT - VERB take - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS takeable - ELSE - IF obj ISA SCENERY - THEN "Unimportant for your purposes, you leave the" SAY THE obj. "where it is." - ELSE "That's not something you can take." - END IF. - AND obj IS movable - ELSE SAY THE obj. "is much too heavy for you to move." - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND weight Of obj <=50 - ELSE SAY THE obj. "is too heavy to lift." - DOES - IF obj DIRECTLY IN hero - -- i.e. the object to be taken is carried by the hero already - THEN "You already have" SAY THE obj. "." - ELSIF obj DIRECTLY IN worn - -- i.e. the object to be taken is a piece of clothing that the player character is wearing; - -- here, this verb works in practise like 'take off'. - THEN "You take off" SAY THE obj. "and carry it in your hands." - LOCATE obj IN hero. - ELSE "Taken." - -- this covers also cases where the object to be taken is in another container, - -- such as a wallet that is in a jacket the hero is carrying or wearing. - LOCATE obj IN hero. - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - carry, grab, hold, obtain = take. - - - --- ============================================================== - - ------ TAKE FROM - - --- ============================================================== - - -SYNTAX take_from = 'take' (obj1) 'from' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only take objects." - AND obj2 ISA THING - ELSE "It's not possible to take things from there." - AND obj2 ISA CONTAINER - ELSE "It's not possible to take things from there." - - - take_from = remove (obj1)* 'from' (obj2). - - - take_from = get (obj1) 'from' (obj2). - - -ADD TO EVERY OBJECT - VERB take_from - WHEN obj1 - CHECK obj2 <> hero - ELSE "You can't take things from yourself!" - AND obj1 NOT IN hero - ELSE "You already have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "You can't take something from itself!" - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IN obj2 - ELSE - IF obj2 IS inanimate - THEN SAY THE obj1. "is not in" SAY THE obj2. "." - ELSE SAY THE obj2. "doesn't have" SAY THE obj1. "." - END IF. - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - AND obj2 IS NOT closed - ELSE "You can't, since" SAY THE obj2. "is closed." - AND obj1 IS movable - ELSE SAY THE obj1. "is much too heavy for you to take." - AND obj1 IS takeable - ELSE - IF obj1 ISA SCENERY - THEN "Unimportant for your purposes, you leave the" - SAY THE obj1. "where it is." - ELSE "That's not something you can take." - END IF. - AND weight Of obj1 <=50 - ELSE SAY THE obj1. "is too heavy." - DOES - LOCATE obj1 IN hero. - "You take" SAY THE obj1. "from" SAY THE obj2. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TALK - - --- ============================================================== - - -SYNTAX talk = talk. - - -VERB talk - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING - or TELL PERSON ABOUT THING." -END VERB. - - - --- ============================================================== - - ------ TALK_TO - - --- ============================================================== - - -SYNTAX talk_to = talk 'to' (act) - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - - -ADD TO EVERY THING - VERB talk_to - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - -SYNTAX talk_to_a = talk 'to' (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That's not something you can talk about." - - -ADD TO EVERY THING - VERB talk_to_a - WHEN act - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - --- ============================================================== - - ------ TASTE (+ lick) - - --- ============================================================== - - -SYNTAX taste = taste (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can taste." - - -ADD TO EVERY OBJECT - VERB taste - CHECK obj IS examinable - ELSE "That's not something you can taste." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES "You taste nothing unexpected." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TEAR (+ rip) - - --- ============================================================== - - -SYNTAX tear = tear (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can tear." - - -ADD TO EVERY OBJECT - VERB tear - CHECK obj IS examinable - ELSE "That's not something you can tear." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "That would be futile." - END VERB. -END ADD TO. - - -SYNONYMS rip = tear. - - - --- ============================================================== - - ------ TELL (+ enlighten, inform) - - --- ============================================================== - - -SYNTAX tell = tell (act) about (topic)! - WHERE act ISA ACTOR - ELSE "That's not something you can talk to." - AND topic ISA THING - ELSE "That doesn't seem to be something you can talk - about with" SAY THE act. "." - - -ADD TO EVERY THING - VERB tell - WHEN act - CHECK act HAS can_talk - ELSE "That's not something you can talk to." - AND act IS reachable - ELSE SAY THE act. "is too far away." - AND act <> hero - ELSE "It doesn't make much sense to tell yourself about something." - DOES - IF topic IN act - THEN SAY THE act. "doesn't seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. "chooses to be silent." - ELSIF topic = hero - THEN SAY THE act. "doesn't seem interested." - ELSE SAY THE act. "doesn't seem interested." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS enlighten, inform = tell. - - - --- ============================================================== - - ------ THINK (+ ponder, meditate, reflect) - - --- ============================================================== - - -SYNTAX think = think. - - -VERB think - DOES - "Nothing helpful comes to your mind." -END VERB. - - -SYNONYMS ponder, meditate, reflect = think. - - - --- ============================================================== - - ------ THINK ABOUT - - --- ============================================================== - - -SYNTAX think_about = think 'about' (obj) - WHERE obj ISA THING - ELSE "That's not something fruitful to think about." - - -ADD TO EVERY THING - VERB think_about - DOES - "Nothing helpful comes to your mind." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW - - --- ============================================================== - - -SYNTAX throw = throw (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can throw." - - -ADD TO EVERY OBJECT - VERB throw - CHECK obj IS examinable - ELSE "That's not something you can throw." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - "You can't throw very far;" SAY THE obj. "ends up on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj AT hero. - - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ THROW AT (+ throw to) - - --- ============================================================== - - -SYNTAX throw_at = throw (obj1) 'at' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only throw objects." - AND obj2 ISA THING - ELSE "It's not possible to throw things at that." - - - throw_to = throw (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only throw objects." - AND obj2 ISA THING - ELSE "It's not possible to throw things to that." - - -ADD TO EVERY OBJECT - VERB throw_at, throw_to - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can throw." - AND obj2 IS examinable - ELSE "That's not something you can throw things at." - AND obj1 <> obj2 - ELSE "It doesn't make sense to throw something at itself." - AND obj2 NOT IN hero - ELSE "You are carrying" SAY THE obj2. "." - AND obj2 <> hero - ELSE "You cannot throw things at yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is too far away." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - IF obj2 IS inanimate - THEN "The" SAY obj1. "bounces harmlessly off" - SAY THE obj2. "and ends up on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE obj1 HERE. - ELSE "The" SAY obj2. "catches" SAY THE obj1. "and tosses" - IF obj1 IS NOT plural - THEN "it" - ELSE "them" - END IF. - "back to you. You grab hold of" - IF obj1 IS NOT plural - THEN "it" - ELSE "them" - END IF. - - "again." - END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------- THROW IN - - --- ============================================================== - - -SYNTAX throw_in = throw (obj1) 'in' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can throw." - AND obj2 ISA OBJECT - ELSE "That's not something you can throw things into." - AND obj2 ISA CONTAINER - ELSE "That's not something you can throw things into." - - -ADD TO EVERY OBJECT - VERB throw_in - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can throw." - AND obj2 IS examinable - ELSE "That's not something you can throw things into." - AND obj1 <> obj2 - ELSE "It doesn't make sense to throw something into itself." - AND obj2 <> hero - ELSE "You can't throw" SAY THE obj1. "into yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 NOT IN obj2 - ELSE SAY THE obj1. "is in" SAY THE obj2. "already!" - AND obj2 IS reachable - ELSE SAY THE obj2. "is too far away." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - LOCATE obj1 IN obj2. - "You throw" SAY THE obj1. "into" SAY THE obj2. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE - - --- ============================================================== - - -SYNTAX tie = tie (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can tie." - - -ADD TO EVERY OBJECT - VERB tie - DOES - "You must state where do you want to tie" SAY obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE TO - - --- ============================================================== - - -SYNTAX tie_to = tie (obj1) 'to' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can tie." - AND obj2 ISA OBJECT - ELSE "Nothing can be tied to that." - - -ADD TO EVERY OBJECT - VERB tie_to - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can tie." - AND obj2 IS examinable - ELSE "That's not something you can tie things to." - AND obj1 IS takeable - ELSE "You don't have" SAY THE obj1. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to tie something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj2 IS reachable - ELSE SAY THE obj2. "is out of your reach." - DOES - -- implicit taking: - IF obj1 NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj1. "first)$n" - LOCATE obj1 IN hero. - END IF. - -- end of implicit taking. - - LOCATE obj1 IN hero. - "It's not possible to tie" SAY THE obj1. "to" SAY THE obj2. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TOUCH - - --- ============================================================== - - -SYNTAX touch = touch (obj) - WHERE obj ISA THING - ELSE "That's not something you can touch." - - -ADD TO EVERY THING - VERB touch - CHECK obj IS examinable - ELSE "That's not something you can touch." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - AND obj IS inanimate - ELSE "You are not sure whether" SAY THE obj. "would appreciate that." - DOES - "You feel nothing unexpected." - END VERB. -END ADD TO. - - -SYNONYMS feel = touch. - - - --- ============================================================== - - ------ TOUCH WITH - - --- ============================================================== - - -SYNTAX touch_with = touch (obj1) 'with' (obj2) - WHERE obj1 ISA THING - ELSE "That's not something you can touch." - AND obj2 ISA OBJECT - ELSE "You can only use objects to touch with." - - -ADD TO EVERY THING - VERB touch_with - WHEN obj1 - CHECK obj1 IS examinable - ELSE "That's not something you can touch." - AND obj2 IS examinable - ELSE "That's not something you can touch things with." - AND obj2 IN hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to touch something with itself." - AND obj1 IS inanimate - ELSE "You are not sure whether" SAY THE obj1. "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - "You touch" SAY THE obj1. "with" SAY THE obj2. ". Nothing special happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN (+ rotate) - - --- ============================================================== - - -SYNTAX turn = turn (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can turn." - - - turn = rotate (obj). -- we don't declare 'rotate' a synonym for 'turn' - -- through a SYNONYMS statement as we don't want - -- it to be possible for the player to type something - -- like 'rotate tv on' (see 'turn on' and 'turn off' below) - - -ADD TO EVERY OBJECT - VERB turn - CHECK obj IS examinable - ELSE "That's not something you can turn." - AND obj IS movable - ELSE "It's not possible to turn" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES "You turn" SAY THE obj. - IF obj IN hero - THEN "in your hands" - END IF. - "$$. You notice nothing unusual about it" - IF obj NOT IN hero - THEN "and return it to its original position" - END IF. - "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN ON - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These classes are ------ defined in 'classes.i' with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. ------ Trying to turn on or off an ordinary object will default here to "That's not ------ something you can turn on". - - -SYNTAX turn_on = turn 'on' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v on." - - turn_on = switch 'on' (obj). - - - turn_on = turn (obj) 'on'. - - - turn_on = switch (obj) 'on'. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', subclass 'device'. --- This verb merely covers cases where the player forgets to type 'on' or 'off'. - - - -ADD TO EVERY OBJECT - VERB turn_on - DOES - "That's not something you can $v on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN OFF - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These classes ------ are defined in 'classes.i' with proper checks for 'on' and 'NOT on', ------ 'lit' and 'NOT lit'. - - -SYNTAX turn_off = turn off (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can $v off." - - turn_off = switch off (obj). - - - turn_off = turn (obj) off. - - - turn_off = switch (obj) off. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', subclasses 'device' and 'lightsource'. --- This verb merely covers cases where the player forgets to type 'on' or 'off'. - - -ADD TO EVERY OBJECT - VERB turn_off - DOES - "That's not something you can $v off." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE - - --- ============================================================== - - -SYNTAX 'use' = 'use' (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can use." - - -ADD TO EVERY OBJECT - VERB 'use' - DOES - "Please be more specific. How do you intend to use it?" - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE WITH - - --- ============================================================== - - -SYNTAX use_with = 'use' (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "You can only use objects." - AND obj2 ISA OBJECT - ELSE "You can only use objects." - - -ADD TO EVERY OBJECT - VERB use_with - WHEN obj1 - CHECK obj1 <> obj2 - ELSE "You can't use something with itself." - DOES - "Please be more specific. How do you intend to use them together?" - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ UNDRESS - - --- ============================================================== - - --- See the file 'classes.i', subclass CLOTHING for the definition --- of this verb. - - - - - --- ============================================================== - - ------ UNLOCK - - --- ============================================================== - - -SYNTAX unlock = unlock (obj) - WHERE obj ISA OBJECT - ELSE "That's not something you can unlock." - - -ADD TO EVERY OBJECT - VERB unlock - CHECK obj IS lockable - ELSE "That's not something you can unlock." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS locked - ELSE "It's already unlocked." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - "You must state what you want to unlock" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ UNLOCK WITH - - --- ============================================================= - - -SYNTAX unlock_with = unlock (obj1) 'with' (obj2) - WHERE obj1 ISA OBJECT - ELSE "That's not something you can unlock." - AND obj2 ISA OBJECT - ELSE "You can't unlock anything with that." - - -ADD TO EVERY OBJECT - VERB unlock_with - WHEN obj1 - CHECK obj1 IS lockable - ELSE "That's not something you can unlock." - AND obj2 In hero - ELSE "You don't have" SAY THE obj2. "." - AND obj1 <> obj2 - ELSE "It doesn't make sense to unlock something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj1 IS locked - ELSE "It's already unlocked." - AND obj1 IS reachable - ELSE SAY THE obj1. "is out of your reach." - DOES - SAY THE obj2. "doesn't unlock" SAY THE obj1. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ VERBOSE (see also -> BRIEF) - - --- ============================================================== - - -SYNTAX verbose = verbose. - - -VERB verbose - DOES - VISITS 0. - "Verbose mode is now on. Location descriptions will be - always shown in full." -END VERB. - - - --- ============================================================== - - ------ WAIT (= z) - - --- ============================================================== - - -SYNTAX 'wait' = 'wait'. - - -VERB 'wait' - DOES - "Time passes..." -END VERB. - - -SYNONYMS - z = 'wait'. - - - --- ============================================================== - - ------ WHAT AM I - - --- ============================================================== - - -SYNTAX what_am_i = 'what' am i. - - -VERB what_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHAT IS - - --- ============================================================== - - -SYNTAX what_is = 'what' 'is' (obj)! - WHERE obj ISA THING - ELSE "That's not something I know about." - - -ADD TO EVERY THING - VERB what_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHERE AM I - - --- ============================================================== - - -SYNTAX where_am_i = 'where' am i. - - -VERB where_am_i - DOES - LOOK. -END VERB. - - - --- ============================================================== - - ------ WHERE IS - - --- ============================================================== - - -SYNTAX where_is = 'where' 'is' (obj)! - WHERE obj ISA THING - ELSE "That's not something I know about." - - -ADD TO EVERY THING - VERB where_is - CHECK obj NOT AT hero - ELSE "That's right here!" - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHO AM I - - --- ============================================================== - - -SYNTAX who_am_i = who am i. - - -VERB who_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHO IS - - --- ============================================================== - - -SYNTAX who_is = 'who' 'is' (act)! - WHERE act ISA ACTOR - ELSE "That's not somebody I know." - - -ADD TO EVERY ACTOR - VERB who_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WRITE - - --- ============================================================== - - -SYNTAX write = write (str) 'on' (obj) - WHERE str ISA STRING - ELSE "Please state inside double quotes ("""") - what you want to write." - AND obj ISA OBJECT - ELSE "Nothing can be written there." - - - write = write (str) 'in' (obj). - - -ADD TO EVERY OBJECT - VERB write - WHEN obj - CHECK obj IS writeable - ELSE "Nothing can be written there." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. "is out of your reach." - DOES - IF text OF obj = "" - THEN SET text OF obj TO str. - ELSE SET text OF obj TO text OF obj + " " + str. - END IF. - "You write ""$$" SAY str. "$$"" on" SAY THE obj. "." - MAKE obj readable. - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ YES - - --- ================================================================ - - -SYNTAX yes = yes. - - -VERB yes - DOES "You sound rather positive." -END VERB. - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/classes.i b/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/classes.i deleted file mode 100644 index 19d7a40..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/classes.i +++ /dev/null @@ -1,2616 +0,0 @@ --- ALAN Standard Library v1.00 --- Classes (file name: 'classes.i') - - --- This library file defines various object and actor classes, as well as the --- instance 'hero'(=the player character). Many of these classes are frequently --- used in verb definitions in 'verbs.i' so they should be edited or --- removed with caution. However, to ease things up, it is mentioned at the --- beginning of every class below if and where the class is cross-referenced --- in the other library files. - - --- Contents: - - - - --- 1. OBJECT CLASSES --- ================= - - - --- BACKGROUND - -- Is present in the location but cannot be reached or taken. - -- Doesn't appear automatically in room descriptions. - -- A typical example of a background would be for example the sun, - -- or a mountain visible in the distance. - -- Compare this with 'scenery' below (a background object cannot be reached, - -- but a scenery object can.) - - --- CLOTHING - -- Is a piece of clothing that behaves according to Alan Bampton's 'xwear.i' extension. - -- The said extension has been fully assimilated to this library. - -- This extension prevents clothes from being worn in an illogical order, e.g. you - -- cannot put on a shirt if you are already wearing a jacket, and so forth. - -- Also the verbs 'wear', 'remove' and 'undress' are defined here. - - --- DEVICE - -- Is a machine or an electronic device, for example a TV. Can be turned - -- (=switched) on and off if it is not broken. - -- Attributes: 'on' and NOT 'on', NOT broken. - -- Is described automatically as being either on or off when examined. - - --- DOOR - -- Can be opened, closed, locked and unlocked. - -- Is by default closed, not locked. - -- Attributes: closeable, (NOT) closed, lockable, (NOT) locked. - -- Is described automatically as being either open or closed when examined. - - --- LIQUID - -- Can only be taken if it is in a container. You can fill something with it, - -- and you can pour it somewhere. - -- A liquid is by default NOT drinkable. - - --- LIGHTSOURCE - -- IS natural or NOT natural - -- (a natural lightsource is for example a match or a torch). - -- Can be turned on and off, lighted and extinguished (= put out) if it - -- is not broken. A natural lightsource - -- cannot be turned on or off, it can only be lighted and extinguished (= put out). - -- When examined, a lightsource is automatically supplied with a description of - -- whether it is providing light or not. - - --- LISTABLE_CONTAINER - -- Is a special kind of container, the contents of which will be listed both after - -- 'look' (= in the room description), 'look in' and 'examine' (if the container is open). - -- (The contents of a normal container object are not listed after 'examine' but only - -- after 'look' (=room description) and 'look in'). - - --- SCENERY - -- Behaves like a normal object, can be reached and manipulated but not taken. - -- The default message for 'take' will be "Unimportant for your purposes, you decide to - -- leave the [object] where it is." - -- The default message for 'examine' will be "The [object] doesn't appear particularly - -- interesting." - -- A scenery object is not automatically listed after the room description when - -- you type 'look'. You have to include it manually in the room description. - -- Compare this with 'background' above (a scenery object can be reached, - -- but a background object cannot.) - - --- SOUND - -- Can be listened to but not examined, searched, smelled or manipulated. - -- Cannot initially be turned on or off, this has to be implemented manually by giving - -- the sound the 'switchable' attribute. - - --- SUPPORTER - -- You can put things on this and you can stand on this. It is declared a container, - -- so you can take things from it, as well. When there's something on a supporter, - -- an automatic listing of it will appear in the room description and after 'examine'. - - --- WEAPON - -- IS fireable (e.g. a cannon) or NOT fireable (e.g. a baseball bat). - - --- WINDOW - -- Can be opened, closed, looked through and out of. - -- Will be automatically described as being either open or closed when examined. - - - --- 2. ACTOR CLASSES --- ================ - --- the ACTORS are defined here to be NOT inanimate CONTAINERS (so that they can e.g. --- receive and carry things. The 'contents' (= possessions) of an actor (except for the hero) --- are automatically listed after 'look' and 'examine'. (For the hero, the command 'inventory' --- must be used.) --- --- Actors are usually preceded by an article in-game: --- e.g. "You see a man here." --- "There is nothing special about the dog." --- unless they are declared as 'named'. --- --- The following classes for actors are defined in this library: - - --- PERSON - -- is able to talk (= 'CAN talk'). - - --- FEMALE - -- a subclass of person (= is able to talk) - -- can be referred to with the pronoun 'her' - - --- MALE - -- a subclass of person (= is able to talk) - -- can be referred to with the pronoun 'him' - - - - - --- 3. INSTANCES --- ============ - - --- the hero - - - - --- The contents end here. - - - --- ============================================================= - --- ============================================================= --- --- 1. Object classes --- --- ============================================================= - --- ============================================================= - - - - - --- ============================================================= - - ------ BACKGROUND - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY background ISA THING - IS NOT reachable. - DESCRIPTION "" -END EVERY. - - --- A background object is present in the location but cannot be reached. --- Note that a background object in ALAN3 is different from e.g. the backdrop in Inform7 --- in that a background object is at one location at a time only, unless --- you use the nested locations feature in ALAN which makes the object available --- in several locations. --- Here is an example where a ceiling lamp is located in the lobby, the bedroom --- and the living-room of a house, but not in other locations: - - --- 1) First, define the area where the object(s) should be found: - --- THE lamp_rooms ISA LOCATION -- i.e. the area in which we'll nest --- END THE. -- the three rooms mentioned above - --- and then define which locations belong to that area: - --- THE lobby ISA LOCATION IN lamp_rooms --- END THE. - --- THE bedroom ISA LOCATION IN lamp_rooms --- END THE. - --- THE livingroom ISA LOCATION IN lamp_rooms --- END THE. - - - --- 2) Then, place the background object in the area: - --- THE ceiling_lamp ISA BACKGROUND IN lamp_rooms --- NAME ceiling lamp --- END THE. - - --- Now, the lamp is found in all of the above locations. - --- Note that in this code you could define exits to other rooms of the house in the --- normal way, without having to worry about the area at all, e.g.: - --- THE bedroom ISA LOCATION IN lamp_rooms --- EXIT west TO upstairs_landing. --- END THE. - --- THE upstairs_landing ISA LOCATION -- ( = a location outside the defined area) --- EXIT east TO bedroom. --- END THE. - --- etc. - --- Naturally, you could also define a scenery object or a normal object to be --- in several locations at once, in the same way. Note, however, that if you define --- a takeable object in this manner, it will disappear from the other locations once --- you take it in one location. Also, when manipulated (e.g. broken), the object --- will be affected in all of the locations it is found. - - - --- ============================================================== - - ------ CLOTHING (+ the verbs WEAR, REMOVE, UNDRESS) - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'inventory' and 'take' where the --- container 'worn', defined below, is used in the verb definitions.) - - --- To use this class, see the documentation text right after the --- code below. --- This class makes use of Alan Bampton's 'xwear.i' extension --- written originally for ALAN V2, converted here to V3 and --- assimilated fully to the present library. Thanks to Alan Bampton --- for the permission to use the code here. - - ------------------------------------------------------------------ --- First, we declare the container for clothing. ------------------------------------------------------------------ - - -THE worn ISA ENTITY -- an entity is present everywhere and thus the hero's - CONTAINER TAKING CLOTHING. -- clothing is always accessible - HEADER "You are wearing" - ELSE "You're not wearing anything." -END THE. - - -------------------------------------------------------------------- --- Next, we define the syntaxes for verbs needed for putting on --- and taking off clothing. -------------------------------------------------------------------- - - -SYNTAX wear = wear (clothing) - WHERE clothing ISA CLOTHING - ELSE - IF clothing IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can wear." - wear = put 'on' (clothing). - wear = put (clothing) 'on'. - wear = don (clothing). - - -SYNTAX remove = remove (clothing) - WHERE clothing ISA CLOTHING - ELSE - IF clothing IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can remove since you're not wearing" - IF clothing IS NOT plural - THEN "it." - ELSE "them." - END IF. - remove = take 'off' (clothing). - remove = take (clothing) 'off'. - remove = doff (clothing). - -SYNTAX undress = undress. - - -------------------------------------------------------------------- --- Now, we define some common attributes for clothing as well as --- how the above verbs behave with this class. -------------------------------------------------------------------- - - -EVERY clothing ISA OBJECT - - IS wearable. - IS sex 0. - IS headcover 0. - IS handscover 0. - IS feetcover 0. - IS topcover 0. - IS botcover 0. - - CONTAINER -- to allow e.g. a wallet to be put into a jacket - - - VERB wear - - CHECK THIS NOT IN worn - ELSE "You are already wearing" SAY THE THIS. "." - AND THIS IS takeable - ELSE "You can't pick" SAY THE THIS. "up." - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND sex OF THIS = sex OF hero OR sex OF THIS = 0 - ELSE - "On second thoughts you decide" - SAY THE THIS. "really won't suit a" - IF sex OF hero =1 - THEN "man" - ELSE "woman" - END IF. - "like you at all." - - - DOES ONLY - - --------------------------------------------------------------------- --- 'wear_flag' is a multi-purpose flag used for several purposes in --- this library, here it is reset to 0 before proceeding as a matter --- of 'housekeeping' for the code. --------------------------------------------------------------------- - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- First check to see if the player is carrying the item already, if --- not, set the 'wear_flag' to 1 to indicate the item was picked up --- in this turn. --------------------------------------------------------------------- - - - IF THIS NOT IN hero - THEN - SET wear_flag OF hero TO 1. - END IF. - - --------------------------------------------------------------------- --- Now see if the player can put this item on by testing --- all of its coverage attributes against the player's state. --------------------------------------------------------------------- - - --------------------------------------------------------------------- --- First check the 'topcover' attributes, if 'obj' fails this test --- then it means the hero is already wearing clothes that cover the --- topcover area and those clothes are of the same layer or a layer --- that belongs on top of the 'obj' item. In either case it would --- NOT be possible to put on the 'obj'. To 'flag' this condition add --- 5 to the 'wear_flag' attribute as an indicator this test failed. --------------------------------------------------------------------- - - - IF topcover OF THIS <> 0 AND topcover OF THIS <= SUM OF topcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - --- IF THIS IN tempworn THEN - IF handscover OF THIS <> 0 AND handscover OF THIS <= SUM OF handscover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF feetcover OF THIS <> 0 AND feetcover OF THIS <= SUM OF feetcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF headcover OF THIS <> 0 AND headcover OF THIS <= SUM OF headcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case, adjust the 'tempcovered OF hero' --- attribute so that the code rejects non sensible options. --- First of all, discount any coatlike clothes as these never --- affect ability to put on other lower body only garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 and botcover OF THIS < 33 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not technically affect ability to put on lower body only clothes. --- Special clause here excludes the full body coverage 'teddy' type --- garment - as a skirt WOULD prevent that from being removed. --- ( dress/coat garments automatically prevent this by virtue of --- having higher 'topcover' settings than the teddy ) --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 AND botcover OF THIS < 16 and botcover OF THIS <> 4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- IF tempcovered OF hero is still > 15 then must have trousers --- type clothing on - therefore disallow wearing dress type clothing --- because, although technically possible, it is not very sensible. --------------------------------------------------------------------- - - - IF tempcovered OF hero >15 AND botcover OF THIS > 16 - THEN - SET tempcovered OF hero TO tempcovered OF hero +16. - END IF. - - --------------------------------------------------------------------- --- From here down, clothes DO work as they do for other areas. --------------------------------------------------------------------- - - - IF botcover OF THIS <> 0 AND botcover OF THIS <= tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- At this point, 'wear_flag' will be 0 if the obj was held by the --- player and can be put on, or l if he picked it up this turn and --- it can be put on. Any higher value means one or more of the --- tests failed and the player cannot put on these clothes. --------------------------------------------------------------------- - - - IF wear_flag OF hero >1 THEN - IF THIS NOT IN hero - THEN "You pick up the" SAY THE THIS. "." - END IF. - LOCATE THIS IN hero. - EMPTY worn IN tempworn. - LIST tempworn. - "Trying to put" - SAY THE THIS. - "on isn't very sensible." - EMPTY tempworn IN worn. - ELSIF wear_flag OF hero = 1 - THEN - LOCATE THIS IN worn. - "You pick up the" SAY THE THIS. - IF THIS IS NOT plural - THEN "and put it on." - ELSE "and put them on." - END IF. - ELSE - LOCATE THIS IN worn. - "You put on" SAY THE THIS. "." - END IF. - -END VERB. - - - -VERB remove - CHECK THIS IN worn - ELSE - "You are not wearing" SAY THE THIS. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - - DOES ONLY - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- Check the total 'topcover' of items worn. Because of the number --- sequence used, by dividing the sum of the worn attributes by two --- and then comparing the result to the individual 'topcover' of the --- obj in question, ( the former can only ever be greater than the --- latter if an article of clothing is worn that goes over 'obj' ) --- it's easy to tell if the obj ought to be removable. A temporary --- attribute is used here because it needs to be manipulated. Once --- again 'wear_flag' is used to indicate the results. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF topcover IN worn /2. - IF topcover OF THIS <> 0 AND topcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF handscover IN worn /2. - IF handscover OF THIS <> 0 AND handscover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF feetcover IN worn /2. - IF feetcover OF THIS <> 0 AND feetcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF headcover IN worn /2. - IF headcover OF THIS <> 0 AND headcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case - first discount any coatlike clothes --- as these do not affect ability to take off other lower garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not affect ability to take off other lower garments. The 'teddy' --- type garment is expressly NOT included in the exclusion here. --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 and botcover OF THIS <>4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- Now process the manipulated value just as was done for the others --------------------------------------------------------------------- - - - SET tempcovered OF hero TO tempcovered OF hero /2. - IF botcover OF THIS <> 0 AND botcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Depending on the value of 'wear_flag' print and process the obj --- as needed. If 'wear_flag' is NOT 0 then the clothes cannot be --- removed. --------------------------------------------------------------------- - - - IF wear_flag OF hero >0 THEN - LIST worn. - "Trying to take" SAY THE THIS. "off isn't very sensible." - ELSE - LOCATE THIS IN hero. - "You take off" SAY THE THIS. "." - END IF. -END VERB. - - --------------------------------------------------------------------- --- The verb 'undress' needs to be defined outside the object class --- as it is intransitive: --------------------------------------------------------------------- - - -VERB undress - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF COUNT IN worn, ISA CLOTHING > 0 - THEN "You don't feel like undressing is a good idea right now." - ELSE "You're not wearing anything you can remove." - END IF. - - -- or, to make it work, use the following lines instead: - --IF COUNT IN worn, ISA CLOTHING > 0 - --THEN EMPTY worn IN hero. - --"You remove all the items you were wearing." - --ELSE "You're not wearing anything you can remove." - -- END IF. -END VERB. - - - -VERB examine - DOES AFTER - IF THIS IS NOT OPAQUE - THEN - IF COUNT ISA OBJECT, IN THIS > 0 -- if the piece of clothing contains - THEN LIST THIS. -- something, e.g. if a jacket contains a wallet, - END IF. -- the wallet will be mentioned when the - END IF. -- jacket is examined -END VERB. - - -END EVERY. - - - --------------------------------------------------------------------- --- These attributes are used internally in the library - ignore! --------------------------------------------------------------------- - -ADD TO EVERY ACTOR - IS tempcovered 0. - IS wear_flag 0. - IS sex 0. -END ADD TO. - - --------------------------------------------------------------------- --- A container used to provide a temporary storage space - ignore! --------------------------------------------------------------------- - -THE tempworn ISA OBJECT - CONTAINER TAKING CLOTHING. - HEADER "You're already wearing" -END THE tempworn. - - - ------------------------------------------------------------------------ --- DOCUMENTATION FOR CLOTHING ------------------------------------------------------------------------ - - --- The quick guide ------------------- - --- Here is a quick overview for using the class 'clothing'. --- A more closely-detailed description of this class is found --- below this overview. - - --- A piece of clothing in your game code should look --- something similar to these four examples: - - --- THE jacket ISA CLOTHING AT lobby --- IS topcover 32. --- END THE. - - --- THE jeans ISA CLOTHING IN wardrobe -- IN wardrobe = in a container called the wardrobe; --- IS botcover 16. -- the wardrobe is not a separate location here. --- END THE. - - --- THE hat ISA CLOTHING IN worn -- IN worn = worn by the player character --- IS headcover 2. --- END THE. - - --- THE sweater ISA CLOTHING IN joe_worn -- = worn by an NPC called Joe. --- IS topcover 16. -- Define separate containers like this --- END THE. -- for clothes worn by non-player characters. - -- If you defined here 'IN joe', the clothing - -- would be listed in Joe's possessions: - -- "You see Joe here. Joe is carrying a book and - -- a sweater." For a concrete example of how to do - -- this, scroll down to the class 'actor'. - -- Note also that if the piece of clothing worn - -- by an NPC is not meant to be takeable by the - -- player character, you should declare the - -- the piece of clothing to be NOT takeable. - - --- In defining a piece of clothing, you should --- --- 1) define it ISA CLOTHING (and not: ISA OBJECT) --- --- 2) give it one of five attributes 'headcover', 'topcover', botcover', 'footcover' --- or 'handcover'; sometimes two of these are needed. --- Which attribute(s) to use depends on the type of clothing; see the clothing table below. - --- 3) A number 2, 4, 8, 16, 32 or 64 needs to be added after the above attribute. --- You cannot decide the number yourself; look it up from the clothing table below. --- If the value of an attribute for a piece of clothing is 0 in the table, don't mention --- this attribute in connection with your clothing object. - - --- The above is enough; the rest is then handled automatically by the library. - - --- The quick guide ends here. The clothing table follows right below. The text following the --- table gives more details about the principles and the use of this class. - - --- The clothing table ------------------------ - - --- Here is the chart showing a selection of fairly typical clothing items and the values to --- set to obtain appropriate behaviour. Should you wish to create an article of clothing not --- listed, usually a bit of lateral thought as to what it is most like and where it fits into --- the scheme of things will suggest a workable set of values, but be aware that you MUST use --- values in this chart, simply adding things with intermediate values is probably going to --- create nasty bugs: - - --- Clothing Headcover Topcover Botcover Footcover Handcover - --- hat 2 0 0 0 0 --- vest/bra 0 2 0 0 0 --- undies/panties 0 0 2 0 0 --- teddy 0 4 4 0 0 --- blouse/shirt/T-shirt 0 8 0 0 0 --- dress/coveralls 0 8 32 0 0 --- skirt 0 0 32 0 0 --- trousers/shorts 0 0 16 0 0 --- sweater/pullover 0 16 0 0 0 --- jacket 0 32 0 0 0 --- coat 0 64 64 0 0 --- socks/stockings 0 0 0 2 0 --- tights/pantiehose 0 0 8 2 0 --- shoes/boots 0 0 0 4 0 --- gloves 0 0 0 0 2 - - - --- The concept of "xwear.i" (This and the following paragraphs are taken from Alan ---------------------------- -- Bampton's original 'xwear' documentation, with minor - -- alterations.) - - --- The basic idea behind this part of the library is that clothing is worn in --- 'layers' and it is rather silly to allow players to (say) take off or put --- on a shirt if they are wearing a jacket. To simulate this in ALAN I've chosen --- to apply a numeric based layering system, and divide the body into five zones --- of coverage. The zones are 'head', 'hands', 'feet', 'top' (for top half of torso) --- and 'bot' (for bottom half of torso). --- All objects have these five zones defined as default attributes (set to 0), for the --- head zone the attribute is headcover for the hands zone handscover and so on. --- Every clothing object will thus need one or more of its 'zonecover' attributes --- set to reflect the zone(s) it covers and its relative position in the layers of --- clothing worn. A simple example would be a shirt, this covers only the 'top' zone --- and so needs its topcover attribute to be set (to 8, just why it's 8 will become --- clear shortly). --- The principle used is that the closer to the skin an item is normally worn, --- the lower its 'cover' attribute is. The library operates on the assumption that --- items with higher value cover attributes for a particular zone are worn over items --- with lower value attributes. When a player attempts to put on an article of clothing, --- each zone it would affect is checked and compared to the related zonal total of any --- clothes already worn. If the value of the new clothing is not greater that the total(s) --- of clothing already worn (on a zone by zone basis) then the library will not allow --- the wearing of that item. There are a few notable exceptions to this rule, but --- I'll come back to those a little later. - - --- How it works in practice ---------------------------- - - --- This part of the library might sound complex, but it is actually very simple to use, --- here's an example of how it works. --- Assume our hero starts the game wearing just vest and shorts and the player issues --- the command 'put on shirt'. A quick check of the chart below should reveal that a shirt --- has only its topcover attribute set to non-zero, (all the other zones are zero, --- which means they are irrelevant for this item). --- The library totals the topcover attributes of all the clothes currently worn, like so:- --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- As there are no other clothes to consider, the library now compares the topcover attribute --- of the item we are attempting to put on, (a shirt with a topcover attribute of 8 in --- this case) to the total value of items already worn (2). --- Because the topcover attribute of the shirt (8) is greater than the calculated total (2), --- this is evaluated as being a 'legal' instruction and the library allows the shirt to be put on. --- Now consider the situation had the player started the game wearing vest, shorts and a jacket, --- this is what happens should he try to 'put on the shirt.' --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- Finally the library checks the jacket, this has a topcover attribute of 32, so total --- topcover is 2 + 32 = 34. --- Because the topcover attribute of the shirt (8) is now not greater than the calculated --- total (34), this is evaluated as being an 'illegal' instruction and the library won't --- allow the shirt to be put on. --- That demonstrates the basic principle of the library, removing clothes uses a variation --- of the 'compare to total' equation to allow / disallow removal of clothing, an example would --- be that our vest, shorts and jacket wearing player would NOT be allowed to remove --- the vest while he still had the jacket on. - - --- Exceptions to the rule... ----------------------------- - - --- Now I'll confuse the issue. Firstly the numbers in my chart are not born of some sort of --- weird fixation with multiples, there is a very good reason why the numbers are set as they --- are, computer/maths types will recognise the sequence and realise it is all 'binary' based --- and know it makes it possible to calculate exactly what the player is wearing in terms of --- layers. --- Some female clothing breaks the rules defined above and is not so easy to deal with. An example, --- although pantyhose is worn under a skirt, dress or coat it can actually be put on or removed --- with the garment worn over it still on. The library recognises this capability and deals with --- it properly by assigning the dress/skirt and coat items particular properties in that they --- don't affect the ability to wear or remove lower layer clothing that covers the bottom of --- the torso only. --- Although it's physically possible to put on/remove trousers while wearing a skirt or dress, --- this (and a few other neat dressing/undressing tricks) is considered illegal here. - - --- How to create clothes that use 'xwear.i' -------------------------------------------- - - --- That covers the way the library works, here's how to define objects to actually make --- use of it. As an example, this is how to define a dress and restrict it to being worn --- by a female. - - --- THE dress ISA CLOTHING IN changingroom - -- NAME little black dress - -- MENTIONED "little black dress" - -- IS - -- botcover 32. - -- topcover 8. - -- sex 2. --- END THE. - - --- Notice that it is only necessary to mention the attributes that are non-zero, this --- minimises the amount of coding required. Apart from making sure the hero is set as --- 'sex 2.' if we wish her to be able to wear this dress, this is all the author needs --- to do, the library will police what is wearable and keep track of things without any --- further work. --- I expect most authors would prefer to start their games with a player at least partially --- dressed. This is just a matter of defining the required clothes object as being in the --- 'worn' container. Here's how to define underwear that our female hero(ine?) starts --- the game wearing. - - --- THE bra ISA CLOTHING IN worn - -- NAME white bra - -- MENTIONED "white bra" - -- IS - -- topcover 2. - -- sex 2. --- END THE bra. - - --- THE panties ISA CLOTHING IN worn - -- NAME white panties - -- MENTIONED "white panties" - -- IS - -- botcover 2. - -- plural. - -- sex 2. --- END THE panties. - - --- The library as it stands also prevents wearing of duplicate clothes, or things that are --- logically mutually exclusive - e.g. the player can wear a dress or a skirt, but not both. - - - - --- ============================================================= - - ------ DEVICE - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY device ISA OBJECT - IS NOT 'on'. - - - VERB examine - DOES - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - - IF THIS IS 'on' - THEN "currently on." - ELSE "currently off." - END IF. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT 'on' - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already on." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS 'on'. - END VERB. - - - VERB turn_off - CHECK THIS IS 'on' - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already off." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - END VERB. - - --- The following verb switches a device off if the device is on, and vice versa. - - - VERB switch - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS 'on' - THEN "You switch off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - ELSE "You switch on" SAY THE THIS. "." - MAKE THIS 'on'. - END IF. - END VERB. - -END EVERY. - - - --- ============================================================= - - ------ DOOR - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY door ISA OBJECT - IS closeable. - IS closed. - IS lockable. - IS NOT locked. - IS NOT takeable. - - - VERB examine - DOES - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - - IF THIS IS closed - THEN "currently closed." - ELSE "currently open." - END IF. - END VERB. - - - - VERB knock - DOES ONLY - IF THIS IS closed - THEN "You knock on" SAY THE THIS. "$$. There is no reply." - ELSE "You don't find it purposeful to knock on the open door" - IF THIS IS NOT plural - THEN "." - ELSE "$$s." - END IF. - - END IF. - END VERB. - - - - VERB look_behind - DOES ONLY - IF THIS IS closed - THEN "You cannot look behind" - IF THIS IS NOT plural - THEN "the door - it is closed." - ELSE "the doors - they are closed." - END IF. - ELSE "You notice nothing special behind the door" - IF THIS IS NOT plural - THEN "." - ELSE "$$s." - END IF. - END IF. - END VERB. - - - - VERB look_under - DOES ONLY - IF THIS IS closed - THEN "The gap under the closed door" - IF THIS IS plural - THEN "$$s" - END IF. - "is so narrow that you can't - see anything of what lies on the other side." - ELSE "You notice nothing special under the door" - IF THIS IS plural - THEN "$$s." - ELSE "." - END IF. - END IF. - END VERB. - - -END EVERY. - - - --- ============================================================= - - ------ LIGHTSOURCE - - --- ============================================================= - - --- (In the file 'verbs.i', ISA LIGHTSOURCE is used in the syntax definition of the verb 'light'.) - - -EVERY lightsource ISA OBJECT - IS NOT lit. - IS NOT broken. - IS natural. -- A natural lightsource is for example a candle, a match or a torch. - -- A NOT natural lightsource is for example a flashlight or a lamp. - -- You cannot switch on or off a natural lightsource. - - - - VERB examine - DOES - IF THIS IS lit - THEN - IF THIS IS natural - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently lit." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently on." - END IF. - ELSE - IF THIS IS natural - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently not lit." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently off." - END IF. - END IF. - END VERB. - - - VERB light - CHECK THIS IS NOT lit - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS natural - THEN "You light" SAY THE THIS. "." - MAKE THIS lit. - ELSE "You turn on" SAY THE THIS. "." - MAKE THIS lit. - END IF. - END VERB. - - - VERB extinguish - CHECK THIS IS lit - ELSE "But" SAY THE THIS. - IF THIS IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - "providing light!" - DOES ONLY "You extinguish the" SAY THE THIS. "." - MAKE THIS NOT lit. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT natural - ELSE - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "not something you can $v on." - AND THIS IS NOT lit - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END VERB. - - - VERB turn_off - CHECK THIS IS NOT natural - ELSE - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v off." - AND THIS IS lit - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already off." - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT lit. - - END VERB. - - --- The following verb switches a NOT natural lightsource on if it is off, and vice versa --- (when the player forgets, or doesn't bother, to type 'on' or 'off' after 'switch'). - - - VERB switch - CHECK THIS IS NOT natural - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - "something you can switch on or off." - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - AND CURRENT LOCATION IS lit - ELSE - "You switch" SAY THE THIS. "on." - MAKE THIS lit. - DOES ONLY - IF THIS IS lit - THEN "You switch off" SAY THE THIS. "." - MAKE THIS NOT lit. - ELSE "You switch on" SAY THE THIS. "." - MAKE THIS lit. - END IF. - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ LIQUID - - --- ============================================================== - - --- (In the file 'verbs.i', ISA LIQUID is used in the syntax definitions of the verbs 'drink' and 'sip'.) - - -EVERY liquid ISA OBJECT - - CONTAINER - HEADER "In" SAY THE THIS. "you see" - ELSE "There is nothing in" SAY THE THIS. "." - - -- We declare this class a container to enable player commands such as - -- 'throw sack into water', 'look into water' and 'take pearl from water'. - -- Also cases such as 'pour red potion into blue potion' require that this - -- class behaves like a container. - - - HAS vessel no_vessel. -- The 'vessel' attribute takes care that if a liquid is - -- in a container, the verb 'take' will automatically take the - -- container instead (if the container is takeable). Trying to - -- take a liquid that is in a fixed-in-place container, as well - -- as trying to take a liquid outside any container, will yield - -- "You can't carry [the liquid] around in your bare hands." - -- The default value 'no_vessel' tells the compiler that the liquid - -- is not in any container. no_vessel is a dummy default that can be - -- ignored. - - - - -- If you have some liquid in a container in your game, you should declare the - -- liquid instance thus: - - -- THE juice ISA LIQUID - -- IN bottle - -- HAS vessel bottle. -- i.e. the value of the 'vessel' attribute is the - -- ... -- container the liquid is in - -- END THE juice. - - -- Then, taking and pouring liquids work smoothly. - -- If you don't declare the 'vessel' attribute for the liquid instance, taking a liquid will - -- yield "You can't carry [the liquid] around in your bare hands."; only taking its - -- container will work in that case. - - -- The verb 'pour', as defined in this library, also works for the container of a liquid; - -- i.e. if there is some juice in a bottle, 'pour bottle' and 'pour juice' work equally well. - -- Note, however, that the verb 'empty' is not a synonym for 'pour'; - -- 'empty' only works for container objects. - - - INITIALIZE - SCHEDULE check_vessel AT THIS AFTER 0. -- this event is defined further below - - - VERB examine - DOES ONLY - IF vessel OF THIS <> no_vessel - THEN - IF vessel OF THIS IS NOT closed - THEN "You see nothing special in" SAY THE THIS. - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - -- Here we prohibit the player from examining - -- a liquid when the liquid is in a closed container. - END IF. - ELSE "You see nothing special in" SAY THE THIS. "." - END IF. - END VERB. - - - VERB look_in - DOES ONLY - IF vessel OF THIS <> no_vessel - THEN - IF vessel OF THIS IS NOT closed - THEN "You see nothing special in" SAY THE THIS. "." - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - -- Here we prohibit the player from looking into - -- a liquid when the liquid is in a closed container. - END IF. - ELSE "You see nothing special in" SAY THE THIS. "." - END IF. - END VERB. - - - VERB take - DOES ONLY - IF vessel OF THIS = no_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$nTaken." - END IF. - END VERB. - - - VERB take_from - WHEN obj - DOES ONLY - IF vessel OF THIS = no_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$nTaken." - END IF. - END VERB. - - - VERB drop - DOES ONLY - "($$" SAY THE vessel OF THIS. "$$)$nDropped." - LOCATE vessel OF THIS AT hero. - END VERB. - - - VERB give - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero -- i.e. if the implicit taking was successful - THEN - "You give" SAY THE vessel OF THIS. "to" SAY THE recip. "." - LOCATE vessel OF THIS IN recip. - END IF. - - -- there is no 'ELSE' statement in this last IF -clause, as the 'IF THIS NOT - -- IN hero' clause above it takes care of the 'ELSE' alternative. - - END VERB. - - - VERB pour - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't pour" SAY THE THIS. "anywhere since you are not - carrying" - IF THIS IS NOT plural - THEN "it." - ELSE "them." - END IF. - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero - THEN - "You pour" SAY THE THIS. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - LOCATE THIS AT hero. - SET vessel OF THIS TO no_vessel. - END IF. - - END VERB. - - - VERB pour_in - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero --i.e. if the implicit taking was successful - THEN - "You pour" SAY THE THIS. "into" SAY THE cont. "." - LOCATE THIS IN cont. - SET vessel OF THIS TO cont. - END IF. - WHEN cont - DOES ONLY - IF vessel OF THIS = no_vessel - THEN - "There's not much sense pouring" SAY THE obj. "into" SAY THE THIS. "." - ELSE - IF vessel OF THIS IS NOT closed - THEN "It wouldn't accomplish anything trying to pour" SAY THE obj. - "into" SAY THE THIS. "." - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - END IF. - END IF. - END VERB. - - - VERB pour_on - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero -- i.e. if the implicit taking was successful - THEN - IF surface = floor OR surface = ground - THEN LOCATE THIS AT hero. - "You pour" SAY THE THIS. "on" SAY THE surface. "." - SET vessel OF THIS TO no_vessel. - ELSIF surface ISA SUPPORTER - THEN LOCATE THIS IN surface. - "You pour" SAY THE THIS. "on" SAY THE surface. "." - SET vessel OF THIS TO no_vessel. - ELSE "It wouldn't be sensible to pour anything on" SAY THE surface. - END IF. - END IF. - END VERB. - - - VERB fill_with - WHEN substance -- i.e. when something is filled with a liquid, - DOES SET vessel OF THIS TO cont. -- this something becomes the vessel of the liquid. - END VERB. - - - VERB put_in - WHEN obj - DOES ONLY - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE - IF vessel OF THIS IS takeable - THEN - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - LOCATE vessel OF THIS IN cont. - "You put" SAY THE vessel OF THIS. "into" SAY THE cont. "." - - ELSE "You don't have" SAY THE vessel OF THIS. "." - END IF. - END IF. - WHEN cont - DOES ONLY - IF vessel OF THIS = no_vessel - THEN - "There's not much sense putting" SAY THE obj. "into" SAY THE THIS. "." - ELSE - IF vessel OF THIS IS NOT closed - THEN - IF obj = vessel OF THIS - THEN "That doesn't make sense." - ELSE "It wouldn't accomplish anything trying to put" SAY THE obj. - "into" SAY THE vessel OF THIS. "." - END IF. - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - END IF. - END IF. - END VERB. - - - VERB put_on - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero -- i.e. if the implicit taking was successful - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE - IF vessel OF THIS IS takeable - THEN "You put" SAY THE vessel OF THIS. "onto" SAY THE surface. "." - LOCATE vessel OF THIS IN surface. - ELSE "You can't carry" SAY THE THIS. "around in your bare hands." - END IF. - END IF. - END IF. - WHEN surface - DOES ONLY "It is not possible to $v" SAY obj. "onto" SAY THE THIS. "." - END VERB. - - - -- throwing liquids, whether in containers or not, is disabled: - - - VERB throw - DOES ONLY - "Throwing" SAY THE THIS. "around wouldn't be sensible." - END VERB. - - - VERB throw_at - WHEN projectile - DOES ONLY - "Throwing" - IF vessel OF THIS = no_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "around wouldn't be sensible." - WHEN target - DOES ONLY - IF projectile = vessel OF THIS - THEN "That doesn't make sense." - ELSE "It wouldn't accomplish anything trying to throw" SAY THE projectile. "at" - IF vessel OF THIS = no_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "." - END IF. - END VERB. - - - - VERB throw_to - WHEN projectile - DOES ONLY - "Throwing" - IF vessel OF THIS = no_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "to" SAY THE recipient. "wouldn't be sensible." - WHEN recipient - DOES ONLY - IF projectile = vessel OF THIS - THEN "That doesn't make sense." - ELSE - "Throwing something to" - IF vessel OF THIS = no_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "wouldn't accomplish anything." - END IF. - END VERB. - - - VERB throw_in - WHEN projectile - DOES ONLY - "It wouldn't be sensible throwing" SAY THE THIS. "into" SAY THE cont. "." - WHEN cont - DOES ONLY - IF projectile = vessel OF THIS - THEN "That doesn't make sense." - ELSE "It wouldn't be sensible trying to throw" SAY THE projectile. "in" SAY THE THIS. "." - END IF. - END VERB. - - - - -- The verbs 'empty', 'empty_in' and 'empty on' will be disabled as ungrammatical with liquids: - - VERB 'empty' - DOES ONLY "You can only empty containers." - END VERB. - - VERB empty_in - WHEN obj - DOES ONLY "You can only empty containers." - END VERB. - - VERB empty_on - WHEN obj - DOES ONLY "You can only empty containers." - END VERB. - - -END EVERY. - - - --- Here is the default vessel for liquids; if the vessel of a liquid is --- 'no_vessel', it means that the liquid is not in any container. - - -THE no_vessel ISA OBJECT - CONTAINER -END THE. - - - --- This event checks that if a liquid is outside a container, its container will --- be 'no_vessel': - - -EVENT check_vessel - FOR EACH liq ISA LIQUID, DIRECTLY AT CURRENT LOCATION DO - SET vessel OF liq TO no_vessel. - END FOR. - SCHEDULE check_vessel AFTER 1. -END EVENT. - - - - --- ============================================================= - - ------ LISTABLE_CONTAINER - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY LISTABLE_CONTAINER ISA OBJECT -- ACTORS are separately defined as - CONTAINER -- containers further below - - - VERB examine - DOES - IF THIS IS closeable - THEN - IF THIS IS closed - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "closed." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "open." - END IF. - END IF. - - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't see inside" SAY THE THIS. "." - END IF. - END VERB. - - - VERB look_in - DOES ONLY - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't, since" SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - END IF. - END VERB. - - --- Note that closed listable_containers are by default opaque and they become not opaque when --- they are opened: - - - VERB open - DOES - MAKE THIS NOT OPAQUE. - LIST THIS. - END VERB. - - - VERB close - DOES - MAKE THIS OPAQUE. - END VERB. - - -END EVERY. - - - - - - --- Tips for using container objects: - - --- 1) - - --- The contents of a normal CONTAINER are not listed when examined --- (you'll need to look *into* the object to see what it contains). --- If you wish to have the contents listed after 'examine' anyway, --- you should --- --- instead of: --- --- THE box ISA OBJECT --- CONTAINER --- ... --- END THE. --- --- do this: --- --- THE box ISA LISTABLE_CONTAINER --- ... --- END THE. --- --- Then, 'examine' lists the contents of the container. --- --- The contents of a listable_container are also listed when the container --- is opened. This doesn't happen with normal containers. - - --- 2) - - --- For the command 'inventory' to list the contents of a container --- the hero is carrying, go to 'verbs.i', find the command 'inventory' --- and list one by one all relevant containers that the hero might carry, --- thus: --- --- VERB inventory --- DOES LIST hero. --- ... --- IF bag IN hero --- THEN LIST bag. --- END IF. --- --- IF box IN hero --- THEN LIST box. --- END IF. --- ... --- END VERB. --- --- --- If you leave out these additions, the bag and the box will be listed after the --- command 'inventory' in the following way: --- --- "You are carrying a bag and a box." --- --- only. But with the above additions, the outcome is e.g. --- --- "You are carrying a bag and a box. The bag contains a loaf of bread. The box --- is empty." - - --- 3) - - --- To declare a container the contents of which should not be listed after 'look' --- or 'examine', declare it an 'opaque container' in the following way: - - --- THE box ISA OBJECT --- OPAQUE CONTAINER --- ... --- END THE. - - --- or - - --- THE box ISA LISTABLE_CONTAINER --- OPAQUE CONTAINER --- ... --- END THE. - - --- Objects in an opaque container cannot be seen or manipulated. --- To change this, declare e.g. --- --- MAKE box NOT OPAQUE. --- - - - --- ============================================================== - - ------ SCENERY - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'take' and 'take_from' where ISA SCENERY --- is used in verb checks.) - - -EVERY scenery ISA OBJECT - IS NOT takeable. - DESCRIPTION "" - - - VERB examine - DOES ONLY SAY THE THIS. - IF THIS IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "appear particularly interesting to you." - END VERB. - - -END EVERY. - - - --- =============================================================== - - ------ SOUND - - --- =============================================================== - - --- (This class is not cross-referenced in this or any other library file.) - - -EVERY sound ISA OBJECT - IS NOT examinable. - IS NOT reachable. - IS NOT movable. - - - VERB smell - DOES ONLY - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can smell." - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ SUPPORTER - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'climb_on', 'empty_on', 'get_off', 'jump_on', --- 'lie_on', 'pour_on', 'put_in', 'put_on', 'sit_on', 'stand_on', and 'take_from' --- where SUPPORTER is used in either syntax definitions, verb checks --- or verb definitions.) - - -EVERY supporter ISA OBJECT - CONTAINER - HEADER "On" SAY THE THIS. "you see" - ELSE "There's nothing on" SAY THE THIS. "." - - - VERB examine - DOES - LIST THIS. - END VERB. - - - -- in the following, we disable some verbs that are defined to work with normal containers: - - - VERB look_in - DOES ONLY - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look into." - END VERB. - - - VERB empty_in, pour_in - WHEN cont - DOES ONLY - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour things into." - END VERB. - - - VERB put_in - WHEN cont - DOES ONLY "You can't put anything inside" SAY THE THIS. "." - END VERB. - - - VERB throw_in - WHEN cont - DOES ONLY "You can't put anything inside" SAY THE THIS. "." - END VERB. - - -END EVERY. - - - --- To place objects on a supporter, define them in the following way: --- --- Define the supporter first; e.g. --- --- THE tray ISA SUPPORTER --- ... --- END THE. --- --- --- Then, the objects on the supporter: --- --- --- THE apple ISA OBJECT --- IN tray -- note the IN here, even if the apple will be described as --- ... -- being on the tray --- END THE. --- --- --- THE book ISA OBJECT --- IN table --- ... --- END THE. --- --- --- Note that the 'examine' command will list what is on the surface of a supporter, not what, --- if anything, is inside the supporter. For example, if you have a supporter called 'table' in your game --- with two drawers in it, --- --- DON'T do this: --- --- THE drawer1 ISA OBJECT --- NAME bottom drawer --- CONTAINER --- IN table. --- END THE. --- --- or this: --- --- THE drawer2 ISA LISTABLE_CONTAINER --- NAME top drawer --- IN table. --- END THE. --- --- This would result in something like --- --- "There's a table here. On the table you see a book, a bottom drawer and a top drawer." --- --- --- Instead, do the following: --- --- THE table ISA SUPPORTER --- AT bedroom --- HAS components {drawer1, drawer2}. --- ... --- VERB examine --- DOES --- FOR EACH c IN components OF THIS DO --- SAY "The table has" SAY AN c. "." --- IF c IS NOT closed --- THEN LIST c. --- ELSE SAY THE c. "is closed." --- END IF. --- END FOR. --- END VERB. --- ... --- END THE. --- --- THE drawer1 ISA LISTABLE_CONTAINER --- OPAQUE CONTAINER --- NAME bottom drawer --- AT bedroom --- IS closed. --- END THE. --- --- THE drawer2 ISA LISTABLE_CONTAINER --- NAME top drawer --- AT bedroom --- IS NOT closed. --- END THE. --- --- THE book ISA OBJECT IN table --- ... --- END THE book. --- --- THE diary ISA OBJECT IN drawer2 --- ... --- END THE diary. - - --- In other words, declare the drawers components of the table, in the manner described above. --- The result will then be e.g. something like this: --- --- "You see a table here. There is a book on the table. The table has a bottom drawer. The bottom drawer --- is closed. The table has a top drawer. The top drawer contains a diary." - - - - --- ============================================================== - - ------ WEAPON - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'attack_with', 'fire', --- 'fire_with', 'kill_with', 'shoot' and 'shoot_with' where WEAPON is used --- either in the syntax definitions or verb checks.) - - -EVERY weapon ISA OBJECT - IS NOT fireable. -END EVERY. - - - - --- ============================================================== - - ------ WINDOW - - --- ============================================================== - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - --- You can look out of and through a window. --- When examined, a window is automatically described as being either open or closed. - - -EVERY window ISA OBJECT - IS closeable. - IS closed. - IS NOT takeable. - - - VERB examine - DOES - IF THIS IS closed - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently closed." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently open." - END IF. - END VERB. - - - VERB look_behind - DOES ONLY - "That's not possible." - END VERB. - - - VERB look_out_of - DOES ONLY "You see nothing special looking out of the" - IF THIS IS NOT plural - THEN "window." - ELSE "windows." - END IF. - END VERB. - - - VERB look_through - DOES ONLY "You see nothing special looking through the" - IF THIS IS NOT plural - THEN "window." - ELSE "windows." - END IF. - END VERB. - - -END EVERY. - - - --- =============================================================== - --- =============================================================== --- --- 2. Actors --- --- =============================================================== - --- =============================================================== - - --- First, we declare some common characteristics for all actors: - - -ADD TO EVERY ACTOR - IS NOT inanimate. - IS NOT following. - IS NOT sitting. - IS NOT lying_down. - IS NOT named. -- = the actor's name is not known to the player; see also - -- the example below - - -- Important: if you don't need an article in front of an actor name (e.g. 'Jim', as opposed to - -- e.g. 'a/the man'), declare the instance as 'named': - - -- THE jim ISA ACTOR - -- IS named. - -- ... - -- END THE. - - -- (Remember also that all actors are 'CAN NOT talk' by default. If you want the actor to be able to talk, - -- give it the attribute 'CAN talk' or declare it ISA PERSON (see further below)) - - DEFINITE ARTICLE - IF THIS IS NOT named - THEN "the" - ELSE "" - END IF. - - INDEFINITE ARTICLE - IF THIS IS NOT named - THEN - IF THIS IS NOT plural - THEN "a" -- if you need "an", you must declare it separately at the actor instance - ELSE "" - END IF. - ELSE "" - END IF. - - - CONTAINER -- so that actors can receive and carry objects - - INITIALIZE -- all actors will obey this script from the start of the game - USE SCRIPT following_hero FOR THIS. - - SCRIPT following_hero -- this code will make any actor follow the hero - STEP WAIT UNTIL hero NOT HERE -- if the actor is given the attribute 'following'. - IF THIS IS following - THEN - LOCATE THIS AT hero. - "$p" SAY THE THIS. - IF THIS IS NOT plural - THEN "follows you." - ELSE "follow you." - END IF. - END IF. - USE SCRIPT following_hero FOR THIS. - - - - DESCRIPTION - IF THIS IS NOT named - THEN - IF THIS IS NOT plural - THEN "There is" SAY AN THIS. "here." - ELSE "There are" SAY THIS. "here." - END IF. - ELSE SAY THIS. - IF THIS IS NOT plural - THEN "is here." - ELSE "are here." - END IF. - END IF. - - - - VERB examine - DOES - IF COUNT ISA THING, IN THIS > 0 -- This if-statement will make a description of an - THEN LIST THIS. -- actor's possessions show up every time the actor is examined. - END IF. -- Note that this doesn't apply to the hero which is defined - -- separately further below.-- This listing will be overridden if you give an - -- individual response - END VERB. -- to the actor instance being examined using DOES ONLY. If you want to still - -- list the possessions of the actor after your own 'examine' - -- response, you should state 'LIST [actor].' in the 'examine' verb there. - - -END ADD TO. - - --- In order that clothing worn by an NPC is described after 'look' and --- 'examine' we need the following code. See the instructions right after it. - - - -EVERY npc_worn ISA OBJECT - HAS carrier no_carrier. -- The value of the 'carrier' attribute is the actor wearing the clothing. - -- Here, 'no_carrier' is a dummy default instance that can be ignored. - - CONTAINER TAKING CLOTHING. - HEADER SAY THE carrier OF THIS. "is wearing" - ELSE "" - - DESCRIPTION "" -- we don't want this container to appear in room descriptions - - INITIALIZE - LOCATE THIS AT carrier OF THIS. - SCHEDULE check_npc_worn AT THIS AFTER 0. - -END EVERY. - - - -EVENT check_npc_worn - FOR EACH nw ISA npc_worn DO - IF nw NOT AT carrier OF nw - THEN LOCATE nw AT carrier OF nw. - END IF. - END FOR. - SCHEDULE check_npc_worn AFTER 1. -END EVENT. - - -THE no_carrier ISA ACTOR -- a dummy default instance, ignore. -END THE. - - - --- To describe what an NPC is wearing (after the commands 'look and 'examine'), define the NPC e.g. like this: - - --- THE mr_smith ISA ACTOR --- DESCRIPTION --- "blah blah" LIST mr_smith_worn. -- Leave this LIST statement out if you don't want to --- -- have the actor's clothing listed after 'look'. --- VERB examine --- DOES ONLY "blah blah" --- (LIST mr_smith.) -- This lists what Mr Smith is carrying. --- LIST mr_smith_worn. -- this lists what Mr Smith is wearing. --- END VERB. --- --- END THE. - - --- THE mr_smith_worn ISA NPC_WORN -- All containers for clothing worn by NPCs should be declared ISA NPC_WORN. --- HAS carrier mr_smith. -- The value of the 'carrier' attribute is the actor wearing the clothes. --- END THE. - - --- THE bowler_hat ISA CLOTHING IN mr_smith_worn --- IS headcover 2. --- END THE. - - --- Note that if you don't want the player character to be able to take a piece of clothing worn --- by another character, you should declare the piece of clothing NOT takeable! - - ------------------------------------------- - - --- To make an actor follow the hero, give it the 'following' attribute, e.g.: --- --- THE bob ISA ACTOR --- ... --- VERB whatever --- DOES MAKE bob following. --- END VERB. --- .... --- --- END THE bob. --- --- etc. - - --- If you wish to have an actor follow the hero right from the start of the game, --- you can naturally just declare --- --- THE servant ISA ACTOR --- IS following. --- ... --- END THE. --- --- - --- To stop an actor from following the hero, just make the actor NOT following. - - --------------------------------------------- - - --- Tip: if you have in your game an actor that starts off as unnamed (such as 'a man'), --- and the player learns his name later on (say, 'Jim'), you should define the actor in --- e.g. the following way to make the player able to refer to him with --- both 'man' and 'Jim': - --- THE jim ISA PERSON --- NAME man NAME jim --- PRONOUN him --- MENTIONED --- IF jim IS NOT named -- By default, all actors are 'NOT named'. --- THEN "man" --- ELSE "Jim" --- END IF. --- .. --- VERB ask --- WHEN act --- IF topic = name --- THEN """My name is Jim"", he replies." --- MAKE jim named. --- END IF. --- END VERB. --- --- END THE. - --- The 'named' attribute is meant to be used in cases like this. The indefinite and definite --- articles don't have to be declared here, as their behavior has been declared in the --- general actor class above. - - - --- ================================================================ - - ------ PERSON -- CAN talk - - --- ================================================================ - - -EVERY person ISA ACTOR - CAN talk. -END EVERY. - - - --- ================================================================ - - ------ FEMALE and MALE - - --- ================================================================ - - --- MALE and FEMALE are actually subclasses of PERSON, and so they both --- have the ability to talk. - - -EVERY female ISA PERSON - PRONOUN her -END EVERY. - - -EVERY male ISA PERSON - PRONOUN him -END EVERY. - - - --- ================================================================ - --- ================================================================ - --- 3. The hero - --- ================================================================ - --- ================================================================ - - - -THE hero ISA ACTOR - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" - MENTIONED "yourself" - PRONOUN '' -- to disable 'it' from referring to 'me'. - CAN talk. - IS NOT sitting. - IS NOT lying_down. - - ------------------------------------ - - -- These three attributes, as well as the 'schedule' statement following them, - -- are needed for the 'notify' command ('verbs.i'); ignore. - - HAS oldscore 0. -- Records previous score so 'checkscore' event - -- can compare with the current score - IS notify_on. -- Set by 'notify' verb, records whether - -- player wants to see score messages or not. - IS NOT seen_notify. -- Records whether player has seen the notify verb - -- instructions yet. - - INITIALIZE - SCHEDULE check_score AT hero AFTER 0. - - ------------------------------------ - - CONTAINER - - LIMITS -- Remove this whole section (from this line until 'HEADER') if you - -- wish to have no limits to how much the hero can carry. - COUNT 10 Then - "You can't carry anything more. You have to drop something - first." - WEIGHT 50 Then - "You can't carry anything more. You have to drop something - first." - - HEADER - IF CURRENT LOCATION IS NOT lit - THEN "Although you cannot see your belongings in the dark, you - remember that you're carrying" - ELSE "You are carrying" - END IF. - ELSE - "You are empty-handed." - - - - VERB examine - DOES ONLY "You notice nothing unusual about yourself." -- edit this line to change the way the hero is - -- described after the player command 'examine myself'. - IF COUNT ISA CLOTHING, IN worn > 0 - THEN LIST worn. -- This will list what the hero is wearing. - END IF. -- (The verb 'inventory' in 'verbs.i' will take care - END VERB. -- of listing the hero's possessions.) - - -END THE. - - -SYNONYMS - me, myself, yourself, self = hero. - - --- Please refer also 'verbs.i' where there are numerous verb checks for the hero, --- so that the hero cannot e.g. attack himself etc. diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/library.i b/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/library.i deleted file mode 100644 index 17cf420..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/library.i +++ /dev/null @@ -1,6 +0,0 @@ --- Import the whole library - -IMPORT 'locations.i'. -IMPORT 'classes.i'. -IMPORT 'verbs.i'. -IMPORT 'messages.i'. diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/locations.i b/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/locations.i deleted file mode 100644 index 0f657f8..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/locations.i +++ /dev/null @@ -1,632 +0,0 @@ --- ALAN Standard Library v1.00 --- Locations (file name: 'locations.i') - - --- This library file defines the default directions (exits) and the location 'nowhere', --- a useful place to locate things when you want to remove them from play. --- This file also defines three specific location classes: rooms (= indoor locations), --- sites (= outdoor locations) as well as the class 'dark_location'. --- Finally, the attributes 'visited' and 'described' as well as the instance 'room' --- (to make possible player commands such as 'examine room' and 'exit room') are defined. --- You may modify this file in any way that suits your purposes. --- To use this file, you should have it in the same folder as your source code file, --- and the line --- --- IMPORT 'locations.i'. --- --- in your source code. - - - --- ======================================================== - - ------ 1. The location 'nowhere' and the default directions - - --- ======================================================== - - -THE nowhere ISA LOCATION - - EXIT - north, - south, - east, - west, - northeast, - southeast, - northwest, - southwest, - up, - down, - 'in', - out - - TO nowhere. - - -END THE nowhere. - - -SYNONYMS - n = north. - s = south. - e = east. - w = west. - ne = northeast. - se = southeast. - nw = northwest. - sw = southwest. - u = up. - d = down. - - --- Note: - - --- 1) the directions defined above (and their synonyms) are not predefined in or --- hardwired to the interpreter in any way, so you can replace them altogether or add new --- ones to be used alongside with them. - - --- 2) when you want to remove things from play, you can --- --- LOCATE [object] AT nowhere. --- --- e.g. --- --- THE piece_of_paper ISA OBJECT --- ... --- VERB tear --- DOES ONLY "You tear the piece of paper to shreds." --- LOCATE piece_of_paper AT nowhere. --- END VERB. --- --- END THE piece_of_paper. - - - --- ========================================================================= - - ------ 2. Location classes 'room' and 'site' for indoor and outdoor locations - - --- ========================================================================= - - --- ROOM and SITE are optional location classes you can use to ease up coding. --- All ROOMS have a floor, walls and a ceiling. All SITES have a ground and a sky. --- Thus, you will be able to define e.g. --- --- THE kitchen ISA ROOM --- --- and it will automatically have a floor, walls and a ceiling, --- --- or: --- --- THE greenmeadow ISA SITE --- --- and the ground and the sky are automatically found in that location. --- --- --- Of course, you will still be able to define locations in the usual way, e.g. --- --- THE kitchen ISA LOCATION --- --- etc, but the floor, walls and ceiling won't be automatically included there. --- The walls, floor, ceiling, ground and sky are not takeable or movable. --- This library file also defines the sky and the ceiling to be out of reach, --- so that they can't be e.g. touched. - --- (We make use of ALAN's nested locations feature in the following definitions: ) - - -THE outdoor ISA LOCATION -END THE outdoor. - - -THE indoor ISA LOCATION -END THE indoor. - - -EVERY room ISA LOCATION AT indoor -END EVERY. - - -EVERY site ISA LOCATION AT outdoor -END EVERY. - - -EVERY room_object ISA OBJECT AT indoor -END EVERY. - - -EVERY site_object ISA OBJECT AT outdoor -END EVERY. - - -THE floor ISA room_object - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow 'empty/pour something on floor' - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the floor." - END VERB. - - - -- As we have declared the floor a container, we will disable some verbs - -- defined to work with containers: - - - VERB empty_in, pour_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB look_in - DOES ONLY "That's not possible." - END VERB. - - - VERB put_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB take_from - WHEN holder - DOES ONLY "If you want to pick up something, just TAKE it." - END VERB. - - - VERB throw_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - -END THE. - - -THE wall ISA room_object - NAME wall NAME walls - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - - VERB examine - DOES ONLY "You notice nothing unusual about the walls here." - END VERB. - -END THE. - - - -THE ceiling ISA room_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the ceiling." - END VERB. - -END THE. - - - -THE ground ISA site_object - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow 'empty/pour something on ground' - DESCRIPTION "" - - - VERB examine - DOES ONLY "You notice nothing unusual about the ground." - END VERB. - - - VERB dig - DOES ONLY "The ground is not suitable for digging here." - END VERB. - - - -- As we have declared the floor to be a container, we will disable some verbs - -- defined to work with containers: - - - VERB empty_in, pour_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB look_in - DOES ONLY "That's not possible." - END VERB. - - - VERB put_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB take_from - WHEN holder - DOES ONLY "If you want to pick up something, just TAKE it." - END VERB. - - - VERB throw_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - -END THE. - - - -THE sky ISA site_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine - DOES ONLY "You notice nothing unusual about the sky." - END VERB. - - -END THE. - - --- We still declare some shared behaviour for all indoor and outdoor objects: - - -ADD TO EVERY room_object - - VERB put_behind, put_near, put_under - WHEN bulk - DOES ONLY "That's not possible." - END VERB. - - VERB look_behind, look_through, look_under - DOES ONLY "That's not possible." - END VERB. - -END ADD TO. - - -ADD TO EVERY site_object - - VERB put_behind, put_near, put_under - WHEN bulk - DOES ONLY "That's not possible." - END VERB. - - VERB look_behind, look_through, look_under - DOES ONLY "That's not possible." - END VERB. - -END ADD TO. - - --- NOTE: it is often a good idea to modify the 'examine' verb for the above objects. --- Here is an example for 'wall': - --- THE wall ISA room_object --- : --- : --- VERB examine DOES ONLY --- IF hero AT kitchen --- THEN "Numerous shelves, full of various kitchen utensils, line the walls." --- ELSIF hero AT livingroom --- THEN "The walls are decorated with flowery wallpaper here." --- : --- : --- END IF. --- END VERB. --- END THE wall. --- --- In other words, making the description of the walls, etc., individual for each room --- gives a better impression than if you just use the default messages. - - - --- ========================================================== - - ------ 3. Dark locations - - --- ========================================================== - - -ADD TO EVERY LOCATION - IS lit. -END ADD TO. - - -EVERY dark_location ISA LOCATION - IS NOT lit. - - ENTERED - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - THEN MAKE THIS lit. - IF CURRENT ACTOR <> hero - THEN LOOK. - END IF. - END IF. - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE = 0 - THEN MAKE THIS NOT lit. - END IF. - - -- These ENTERED statements take care - -- of the dark location being correctly lit or not lit at entrance, - -- the WHEN rules below take care of the change when the hero is - -- already in the location. - - DESCRIPTION - CHECK COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - ELSE "It is pitch black. You can't see anything at all." - -END EVERY dark_location. - - -WHEN location OF hero IS NOT lit - AND COUNT ISA lightsource, IS lit, AT hero > 0 -THEN MAKE location OF hero lit. - SCHEDULE light_on AT hero AFTER 0. - -EVENT light_on - LOOK. -END EVENT. - - -WHEN location OF hero ISA dark_location - AND location OF hero IS lit - AND COUNT ISA lightsource, IS lit, AT hero = 0 -THEN MAKE location OF hero NOT lit. - SCHEDULE light_off AT hero AFTER 0. - -EVENT light_off - "It is now pitch black." -END EVENT. - - --- To define a dark location, use a formulation like the following: - - --- THE basement ISA dark_location --- EXIT up TO kitchen. --- ... --- END THE. - - --- The description of a dark_location will automatically be: "It is pitch black. --- You can't see anything at all." (Edit the description in the code above to change this.) - - --- If you add a description to a dark_location, this description will be shown only --- if/when the location is lit by any means: - --- THE basement ISA dark_location --- DESCRIPTION "Cobwebs and old junk are the only things you see here." --- EXIT up TO kitchen. --- END THE. - - --- In darkness, you are not able to manipulate things other than turn on a lightsource --- and drop items you're carrying (these checks are found in 'verbs.i'). You can exit normally --- and use verbs that don't require seeing, such as 'smell', 'listen' and 'think'. --- If you are in a dark location with an NPC (= a non-player character), you are able to --- communicate with him by asking and telling but not by showing and giving. If you wish to --- change this, see the respective verbs in 'verbs.i' and edit their checks. - - --- Note that you cannot change the name of a location mid-game. Thus, if you define a dark location --- called e.g. 'Darkness' and wish to make it lit at some point in the game, the name will still be 'Darkness' --- even if the location description can be changed to describe the illuminated location. --- To change the location name, you must locate the hero in another location when the dark location --- is lit. For example, --- --- --- THE lantern ISA LIGHTSOURCE -- (see 'classes.i') --- VERB turn_on --- DOES --- IF hero AT darkness --- THEN LOCATE hero AT treasure_chamber. --- ... --- END IF. --- ... --- END VERB. --- --- etc. --- --- --- Alternatively, you can also use a rule, e.g. --- --- --- WHEN lantern IS lit --- AND hero AT darkness --- THEN LOCATE hero AT treasure_chamber. - - - --- Suppose you want all dark_locations in the game to become lighted. It can be done e.g. like this: - - --- THE main_power_switch ISA DEVICE --- VERB switch_on --- DOES ONLY --- FOR EACH d1 ISA dark_location DO --- MAKE d1 lit. --- END EACH. --- END VERB. --- END THE. - --- FOR EACH makes a loop that affects all instances of the class described after the ISA statement. --- The 'd1' above is a temporary variable needed in the FOR EACH phrase and not anywhere --- else in the game code. You can name this variable in any way you wish. - - - --- ===================================================================== - - ------ 4. The attributes 'visited' and 'described' - - --- ===================================================================== - - --- A location has the value 'visited 0' until the hero visits it for the first time, and the --- value increases on every subsequent visit. --- This helps when you need to control if or how many times a location has been visited, --- and also if you want the location description to be different after the first visit. - --- A location has the value 'described 0' before the first location description, --- and the value increases every time the description is shown. --- This distinction is handy when you want the first-time description of a location to be different from --- the subsequent ones (even if the hero is in the location still for the first time). - - -ADD TO EVERY LOCATION - HAS visited 0. - HAS described 0. - - ENTERED - IF CURRENT ACTOR = hero - THEN - INCREASE visited OF THIS. - INCREASE described OF THIS. -- this value also increases after 'look' (see 'verbs.i'.). - END IF. - -END ADD TO. - - --- A location not visited at all has the 'visited' value 0. When the hero enters it --- the first time, the 'visited' value will change to 1. On the second visit the value --- will be 2, etc. --- Now, in your source code you can define something like the following: - - --- THE kitchen ISA LOCATION --- DESCRIPTION --- "You are in the kitchen." --- IF visited OF THIS = 1 --- THEN "This is your first time here." --- ELSE "You remember you've been here before." --- END IF. --- ... --- END THE. - --- Note that if you have an NPC moving around in the game, the visited value of any location --- will increase when the NPC enters the location, as well (ENTERED applies to all moving actors). --- This is most often not what is wanted, and that's why the 'if' statement --- (IF CURRENT ACTOR = hero) is included above. - - --- You can also check whether the hero has been in a location if needed: - --- THE king ISA ACTOR --- ... --- VERB ask --- WHEN act --- IF topic = treasure_chamber --- THEN --- IF visited OF treasure_chamber = 0 --- THEN "You are not supposed to know anything about the treasure --- chamber - you haven't found it yet." --- ELSE """Just take what you want from the chamber"", the king smiles." --- END IF. --- ... --- END IF. --- END VERB. --- END THE. - - --- etc. - - --- Suppose you want the location description to be different after the first time the description is shown, --- even if you are in the location still for the first time. Then, you can use the 'described' attribute, e.g.: - - --- THE library ISA ROOM --- DESCRIPTION --- IF described OF THIS = 1 --- THEN "There is an old man reading at a table in one of the corners." --- ELSE "The old man keeps on reading at his table." --- END IF. --- END THE. - - - --- ======================================================================= - - --- 5. The instance 'room' - - --- ======================================================================= - - --- Through defining the instance 'room' we make possible player commands such as 'examine room' --- and 'exit room', among others. These commands only work in indoor locations. --- We have to identify this instance differently from 'room' which has already been --- defined as a class above, that's why we identify it here as 'current_room'. Through the NAME --- statement, it can be still called a 'room' in-game. - - -THE current_room ISA OBJECT - AT indoor - NAME 'room' - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow the player command 'exit room'. - DESCRIPTION "" - - - VERB examine - DOES ONLY LOOK. - INCREASE described OF CURRENT LOCATION. - END VERB. - - - VERB search - DOES ONLY "Try examining one thing at a time." - END VERB. - - - VERB enter - DOES ONLY "You must state a direction where to go." - END VERB. - - - VERB 'exit' - DOES ONLY "You must state a direction where to go." - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - END VERB. - - -END THE. - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/messages.i b/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/messages.i deleted file mode 100644 index cfcb2c5..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/messages.i +++ /dev/null @@ -1,73 +0,0 @@ --- ALAN Standard Library v1.00 --- Messages (file name: 'messages.i') - - --- This library file lists all the standard runtime messages listed in the manual, for easy modification. - - - -MESSAGE AFTER_BUT: "You must give at least one object after '$1'." - AGAIN: "(again)" -- if you wish to disable this, make the string empty ("") - BUT_ALL: "You can only use '$1' AFTER '$2'." - CAN_NOT_CONTAIN: "$+1 can not contain $+2." - CANT0: "You can't do that." -- note that the fifth token in CANT0 is a zero, not an 'o'. - CARRIES: "$+1 carries" - 'CONTAINS': "$+1 contains" - CONTAINS_COMMA: "$01," - CONTAINS_AND: "$01 and" - CONTAINS_END: "$01." - EMPTY_HANDED: "$+1 is empty-handed." - HAVE_SCORED: "You have scored $1 points out of $2." - IS_EMPTY: "$+1 is empty." - MORE: "" - MULTIPLE: "You can't refer to multiple objects with '$v'." - NO_SUCH: "I can't see any $1 here." - NO_WAY: "You can't go that way." - NOT_MUCH: "That doesn't leave much to $v!" - NOUN: "You must supply a noun." - NOT_A_SAVEFILE: "That file does not seem to be an Alan game save file." - QUIT_ACTION: "Do you want to RESTART, RESTORE, QUIT or UNDO? " - -- these four alternatives are hardwired to the interpreter and cannot be changed. - REALLY: "Are you sure (RETURN confirms)?" - RESTORE_FROM: "Enter file name to restore from" - SAVE_FAILED: "Sorry, save failed." - SAVE_MISSING: "Sorry, could not open the save file." - SAVE_NAME: "Sorry, the save file did not contain a save for this adventure." - SAVE_OVERWRITE: "That file already exists, overwrite (y)?" - SAVE_VERSION: "Sorry, the save file was created by a different version." - SAVE_WHERE: "Enter file name to save in" - SEE_START: "There is $01" - SEE_COMMA: ", $01" - SEE_AND: "and $01" - SEE_END: "here." - NO_UNDO: "No further undo available." - UNDONE: "'$1' undone." - UNKNOWN_WORD: "I don't know the word '$1'." - WHAT: "I don't understand." - WHAT_WORD: "I don't know what you mean by '$1'." - WHICH_PRONOUN_START: "I don't know if you by '$1'" - WHICH_PRONOUN_FIRST: "mean $+1" - WHICH_START: "I don't know if you mean $+1" - WHICH_COMMA: ", $+1" - WHICH_OR: "or $+1." - - --- These messages are automatically translated into German or Swedish in your game --- if you define in the beginning of your source code --- --- OPTIONS --- LANGUAGE German. --- --- or --- --- OPTIONS --- LANGUAGE Swedish. --- --- Only the exact equivalents of the above phrases will then be shown; if you change the above English --- messages to your own wordings, the translations will still be only for the default. --- --- --- If you wish to write your game in some other language, you must manually translate --- the messages above. There might be support for more languages in the future, depending --- on demand. - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/testgame.alan b/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/testgame.alan deleted file mode 100644 index 063824f..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/testgame.alan +++ /dev/null @@ -1,380 +0,0 @@ --- TESTGAME - - -IMPORT 'locations.i'. -IMPORT 'classes.i'. -IMPORT 'verbs.i'. -IMPORT 'messages.i'. - - - -THE sunny_room ISA ROOM -- all ROOMS automatically have a floor, walls and a ceiling - NAME sunny 'room' - DESCRIPTION "You are in a spacious room filled with bright sunlight entering through - the window and through an open doorway to the west leading to a small balcony. - A white door leads north. There is a staircase to the south." - - EXIT north TO closet - CHECK - IF door1 IS closed - THEN "You can't, since the door is closed." - ELSE "You walk into the closet. The door slams shut behind you." - LOCATE hero AT closet. - LOCATE door1 AT closet. - MAKE door1 closed. - END IF. - END EXIT. - - EXIT west TO balcony. - - EXIT south TO nowhere - CHECK "The staircase just leads out of here. Stay here to keep experimenting, - otherwise type QUIT to quit." - END EXIT. - - - -END THE. - - - -THE table ISA SUPPORTER -- you can place things on a supporter - AT sunny_room - IS NOT takeable. - HAS components {drawer1, drawer2}. - - VERB examine - DOES AFTER - FOR EACH c IN components OF THIS DO - "The table has" SAY AN c. "." - IF c IS NOT closed - THEN LIST c. - ELSE SAY THE c. "is closed." - END IF. - END FOR. - END VERB. - -END THE. - - -THE drawer1 ISA LISTABLE_CONTAINER - AT sunny_room - OPAQUE CONTAINER - NAME top drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - -THE drawer2 ISA LISTABLE_CONTAINER - AT sunny_room - OPAQUE CONTAINER - NAME bottom drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - - -THE pearls ISA OBJECT - In table. - IS plural. - PRONOUN 'them' - - VERB examine - DOES BEFORE - "This is an object with a plural name. Experiment with different commands to see - the responses and how they are different as compared with objects with a singular name.$p" - END VERB. - - -END THE. - - -THE box ISA LISTABLE_CONTAINER - AT sunny_room - - VERB examine - DOES ONLY "This is a listable container defined in the library. The contents should be - listed after both 'examine', 'look in' and 'look'." - END VERB. - -END THE. - - - - - - -THE door1 ISA DOOR - AT sunny_room - NAME white 'door' - DESCRIPTION "" - - VERB examine - DOES ONLY "This is a door object. Please experiment by opening and closing, knocking on - and looking under both when the door is opened and closed." - END VERB. - - -END THE. - - -THE window1 ISA WINDOW - AT sunny_room - NAME 'window' - DESCRIPTION "" -END THE. - - -THE flower ISA SCENERY - IN table -- Note the 'in' here; however, the flower will be described -END THE. -- to be *on* the table. - - - -THE note ISA OBJECT - IN table - IS writeable. - IS readable. - - - VERB examine - DOES ONLY "You can try writing something on the note." - END VERB. - - VERB write - WHEN obj - DOES BEFORE - IF pen NOT IN hero - THEN "(taking the pen first)$n" - LOCATE pen IN hero. - END IF. - END VERB. - - - VERB burn - CHECK match IS lit - ELSE "How?" - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - - VERB burn_with - WHEN obj - CHECK instr = match - ELSE "That's not possible." - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - -END THE. - - -THE pen ISA OBJECT - IN table -END THE. - - -THE bottle ISA LISTABLE_CONTAINER - IN box -END THE. - - -THE juice ISA LIQUID - IN bottle - HAS vessel bottle. - IS drinkable. - ARTICLE "some" -END THE. - - -THE match ISA LIGHTSOURCE - IN box - IS natural. -END THE. - - -THE flashlight ISA LIGHTSOURCE - IN box - IS NOT natural. -END THE. - - -THE waterpistol ISA WEAPON - IN box - IS fireable. -END THE. - - -THE blue_ball ISA OBJECT - IN box - NAME blue ball NAME blue - VERB take - DOES SCORE 1. - END VERB. -END THE. - - -THE red_ball ISA OBJECT - AT sunny_room - NAME red ball NAME red - VERB take - DOES SCORE 1. - END VERB. -END THE. - - -THE yellow_ball ISA OBJECT - AT sunny_room - NAME yellow ball NAME yellow - VERB take - DOES SCORE 1. - END VERB. -END THE. - - -THE felix ISA PERSON - AT sunny_room - NAME felix NAME himself NAME butler - IS named. - MENTIONED "Felix" - PRONOUN 'him' - DESCRIPTION "$pFelix, your grumpy butler, is standing off to one side." - - VERB examine - DOES ONLY "Felix is your grumpy butler. You could try talking to him, or asking him - for various things.$p" LIST felix. LIST felix_worn. - END VERB. - -END THE. - - -THE felix_worn ISA NPC_WORN - HAS carrier felix. -END THE. - - -THE tuxedo ISA CLOTHING IN felix_worn - IS topcover 64. botcover 64. - IS NOT takeable. -END THE. - - -THE dog ISA ACTOR - AT sunny_room - DESCRIPTION "$pA dog is here, looking at you with faithful eyes." - CONTAINER - HEADER "The dog is carrying" - ELSE "The dog is not carrying anything." - - - VERB examine - DOES ONLY "Give the blue ball to the dog and he will follow you." - LIST dog. - END VERB. - -END THE. - - -THE balcony ISA LOCATION - - DESCRIPTION "You're standing on a small balcony overlooking a garden. The sky is clear. - In the distance you see a mountain. - The room is back to the east." - - IF visited OF balcony = 1 - THEN "$pHaving never been on this balcony before, you pause to take in the magnificent view." - ELSE "$pEven if you've been here before, the magnificent view never ceases to amaze you." - END IF. - - EXIT east TO sunny_room. - -END THE. - - --- The balcony is neither a pure indoor or outdoor room, we need the floor but also the sky: - - -THE balcony_object ISA OBJECT AT balcony - NAME balcony - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" -END THE. - -THE balcony_floor ISA OBJECT AT balcony - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" -END THE. - - -THE balcony_sky ISA BACKGROUND AT balcony - DESCRIPTION "" -END THE. - - -THE mountain ISA BACKGROUND - AT balcony - DESCRIPTION -END THE. - - -THE garden ISA BACKGROUND - AT balcony - NAME garden NAME flowers - DESCRIPTION "The garden is green and full of blossoming flowers." -END THE. - - - -THE closet ISA DARK_LOCATION - - DESCRIPTION "This is a closet." - - EXIT south TO sunny_room - DOES "Aiming to the direction from where you remember coming, you manage to push the door open - and emerge back into the sunny room. The closet door slams shut behind you again." - LOCATE door1 AT sunny_room. - END EXIT. - -END THE. - - -THE shirt ISA CLOTHING - AT closet - IS topcover 8. -END THE. - - -THE jacket ISA CLOTHING - AT closet - IS topcover 32. -END THE. - - -THE wallet ISA OBJECT - IN jacket -END THE. - - -WHEN blue_ball IN dog AND dog IS NOT following - => MAKE dog following. - - -ADD TO EVERY LOCATION - INITIALIZE - LOCATE THIS AT test_loc. -END ADD TO. - -THE test_loc ISA LOCATION -END THE. - - -START AT sunny_room. -"This is a" STYLE alert. "testgame" STYLE normal. "for the new ALAN library. Experiment with - manipulating various objects and moving around. -Taking any ball will increase your score." diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/verbs.i b/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/verbs.i deleted file mode 100644 index 977a95b..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2013-12-03/verbs.i +++ /dev/null @@ -1,8128 +0,0 @@ --- ALAN Standard Library v1.00 --- Verbs (file name: 'verbs.i') - - ------ This library file defines common verbs needed in gameplay. The verbs ------ are listed alphabetically. This file also includes common commands which are not ------ actually verbs, such as "inventory", "verbose" and "again". You are free to edit this ------ file for your own purposes in any way you like by adding, deleting or modifying verbs. ------ Verbs originally defined in this file are the following: - - ------ VERB SYNONYMS SYNTAX ARITY OBJ - ------ about (+ help, info) about 0 ------ again (+ g) again 0 ------ answer (+ reply) answer (topic) 1 ------ ask (+ enquire, inquire, interrogate) ask (act) about (topic) 2 ------ ask for ask (act) for (obj) 2 x ------ attack (+ beat, fight, hit, punch) attack (target) 1 ------ attack_with attack (target) with (weapon) 2 ------ bite (+ chew) bite (obj) 1 x ------ break (+ destroy) break (obj) 1 x ------ break_with break (obj) with (instr) 2 x ------ brief brief 0 ------ burn burn (obj) 1 x ------ burn_with burn (obj) with (instr) 2 x ------ buy (+ purchase) buy (item) 1 ------ catch catch (obj) 1 x ------ clean (+ polish, wipe) clean (obj) 1 x ------ climb climb (obj) 1 x ------ climb_on climb on (surface) 1 ------ climb_through climb through (obj) 1 x ------ close (+ shut) close (obj) 1 x ------ close_with close (obj) with (instr) 2 x ------ consult consult (source) about (topic) 2 ------ credits (+ acknowledgments, author, copyright) credits 2 ------ cut cut (obj) 1 x ------ cut_with cut (obj) with (instr) 2 x ------ dance dance 0 ------ dig dig (obj) 1 x ------ dive dive 0 ------ dive_in dive in (liq) 1 ------ drink drink (liq) 1 ------ drive drive (vehicle) 1 ------ drop (+ discard, dump, reject) drop (obj) 1 x ------ eat eat (food) 1 ------ empty empty (obj) 1 x ------ empty_in empty (obj) in (cont) 2 x ------ empty_on empty (obj) in (cont) 2 x ------ enter enter (cont) 1 ------ examine (+ check, inspect, observe, x) examine (obj) 1 x ------ exit exit (cont) 1 ------ extinguish (+ put out, quench) extinguish (obj) 1 x ------ fill fill (cont) 1 ------ fill_with fill (cont) with (substance) 1 ------ find (+ locate) find (obj) 1 x ------ fire fire (weapon) 1 ------ flip flip (obj) 1 x ------ follow follow (act) 1 ------ free (+ release) free (obj) 1 x ------ get_up get up 0 ------ get_off get off (obj) 1 x ------ give give (obj) to (recip) 1 x ------ go_to go to (dest) 1 ------ hint (+ hints) hint 0 ------ inventory (+ i, inv) inventory 0 ------ jump jump 0 ------ jump_in jump in (cont) 1 ------ jump_on jump on (surface) 1 ------ kick kick (target) 1 ------ kill (+ murder) kill (victim) 1 ------ kill_with kill (victim) with (weapon) 2 ------ kiss (+ hug, embrace) kiss (obj) 1 x ------ lie_down lie down 0 ------ lie_in lie in (cont) 1 ------ lie_on lie on (surface) 1 ------ lift lift (obj) 1 x ------ light (+ lit) light (obj) 1 x ------ listen0 listen 0 ------ listen listen to (obj) 1 x ------ lock lock (obj) 1 x ------ lock_with lock (obj) with (instr) 2 x ------ look (+ gaze, peek) look 0 ------ look_at look at (obj) 1 x ------ look_behind look behind (bulk) 1 ------ look_in look in (cont) 1 ------ look_out_of look out of (obj) 1 x ------ look_through look through (bulk) 1 ------ look_under look under (bulk) 1 ------ look_up look up 0 ------ no no 0 ------ notify (on, off) notify. notify on. notify off 0 ------ open open (obj) 1 x ------ open_with open (obj) with (instr) 2 x ------ play play (obj) 1 x ------ play_with play with (obj) 1 x ------ pour (= defined at the verb 'empty) pour (obj) 1 x ------ pour_in (= defined at the verb 'emtpy_in') pour (obj) in (cont) 2 x ------ pour_on (= defined at the verb 'empty_on') pour (obj) on (surface) 2 x ------ pray pray 0 ------ pry pry (obj) 1 x ------ pry_with pry (obj) with (instr) 2 x ------ pull pull (obj) 1 x ------ push push (obj) 1 x ------ push_with push (obj) with (instr) 2 x ------ put (+ lay, place) put (obj) 1 x ------ put_against put (obj) against (bulk)) 2 x ------ put_behind put (obj) behind (bulk) 2 x ------ put_down put down (obj) 1 x ------ put_in (+ insert) put (obj) in (cont) 2 x ------ put_near put (obj) near (bulk) 2 x ------ put_on put (obj) on (surface) 2 x ------ put_under put (obj) under (bulk) 2 x ------ read read (obj) 1 x ------ restart restart 0 ------ restore restore 0 ------ rub rub (obj) 1 x ------ save save 0 ------ say say (topic) 1 ------ say_to say (topic) to (act) 2 ------ score score 0 ------ scratch scratch (obj) 1 x ------ script script. script on. script off. 0 ------ search search (obj) 1 x ------ sell sell (item) 1 ------ shake shake (obj) 1 x ------ shoot (at) shoot at (target)2 1 ------ shoot_with shoot (target) with (weapon) 2 ------ shout (+ scream, yell) shout 0 ------ show (+ reveal) show (obj) to (act) 2 x ------ sing sing 0 ------ sip sip (liq) 1 ------ sit (down) sit. sit down. 0 ------ sit_on sit on (surface) 1 ------ sleep (+ rest) sleep 0 ------ smell0 smell 0 ------ smell smell (odour) 1 ------ squeeze squeeze (obj) 1 x ------ stand (up) stand. stand up. 0 ------ stand_on stand on (surface) 1 ------ swim swim 0 ------ swim_in swim in (liq) 1 ------ switch_on switch on (app) 1 ------ switch_off switch off (app) 1 ------ take (+ carry, get, grab, hold, obtain) take (obj) 1 x ------ take_from (+ remove from) take (obj) from (holder) 2 x ------ talk talk 0 ------ talk_to (+ speak) talk to (act) 1 ------ taste (+ lick) taste (obj) 1 x ------ tear (+ rip) tear (obj) 1 x ------ tell (+ enlighten, inform) tell (act) about (topic) 2 ------ think think 0 ------ think_about think about (topic) 1 ------ throw throw (projectile) 1 ------ throw_at throw (projectile) at (target) 2 ------ throw_in throw (projectile) in (cont) 2 ------ throw_to throw (projectile) to (recipient) 2 ------ tie tie (obj) 1 x ------ tie_to tie (obj) to (target) 2 x ------ touch (+ feel) touch (obj) 1 x ------ turn (+ rotate) turn (obj) 1 x ------ turn_on turn on (app) 1 ------ turn_off turn off (app) 1 ------ unlock unlock (obj) 1 x ------ unlock_with unlock (obj) with (key) 2 x ------ use use (obj) 1 x ------ use_with use (obj) with (instr) 2 x ------ verbose verbose 0 ------ wait (+ z) wait 0 ------ what_am_i what am i 0 ------ what_is what is (obj) 1 x ------ where_am_i where am i 0 ------ where_is where is (obj) 1 x ------ who_am_i who am i 0 ------ who_is who is (obj) 1 x ------ write write (txt) on (obj) 2 x ------ yes yes 0 - - - ------ Verbs having to do with wearing clothes are defined in the file 'classes.i', ------ subclass 'clothing'. These verbs are: ------ ------ remove (+ doff, take off) remove (clothing) 1 ------ undress undress 0 ------ wear (+ don, put on) wear (clothing) 1 - - ------ Directions (north, south, up, etc.) are declared in the file 'locations.i'. - - - ------ We first declare some default attributes for things (= objects and actors) below. ------ These attributes are frequently checked in verb definitions to prohibit ------ the use of verbs with objects and actors in an irrational way. For example, the hero ------ won't be able to eat anything that is not edible, and so forth. - - ------ Specific class attributes that override or complete the following ------ attributes are declared in the files 'classes.i' and 'locations.i'. - - - -ADD TO EVERY THING - - IS examinable. - inanimate. - movable. - reachable. - takeable. - - HAS text "". - - NOT broken. - NOT closeable. - NOT closed. - NOT drinkable. - NOT edible. - NOT lit. - NOT lockable. - NOT locked. - NOT readable. - NOT wearable. - NOT writeable. - - CAN NOT talk. -- Since Alan3 alpha8, CAN is accepted as an attribute header word. - -- 'Talk' here doesn't refer to the verb 'talk'; it just means that an actor is - -- (or is not) able to talk. This is to make the code more readable. - -- (Cf. 'HAS can_talk', which was the formulation earlier.) -END ADD TO. - - - - --- We still define that plural nouns are preceded by "some" (and not "a" or "an"): - - -ADD TO EVERY THING - INDEFINITE ARTICLE - IF THIS IS plural - THEN "some" - ELSE "a" - END IF. -END ADD TO. - --- If you need "an", you should declare it separately at the instance, e.g.: - --- THE owl ISA ACTOR --- AT woods --- INDEFINITE ARTICLE "an" --- END THE. - - - --- (We add the 'plural' attribute to the 'entity' class, because the plural --- applies not only to things but also to e.g. parameters in syntax statements; ignore.) - - -ADD TO EVERY ENTITY - IS NOT plural. -END ADD TO. - - - --- (Other article and pronoun definitions are in the file 'classes.i'.) - - - ------ Next, we declare synonyms for some words so that it will be possible ------ for the player to type commands such as both "put ball in box" and ------ "put ball into box", etc: - - - -SYNONYMS - -into, inside = 'in'. -onto = on. -thru = through. -using = 'with'. - - - ------ The verbs and commands: - - - --- ============================================================= - - ------ ABOUT - - --- ============================================================= - - -SYNTAX 'about' = 'about'. - - -VERB 'about' - DOES - STYLE emphasized. - "This is a text adventure, also called interactive fiction, which means that what - goes on in the story depends on what you type at the prompt. Commands you can type - are for example GO NORTH (or NORTH or just N), WEST, SOUTHEAST, UP, IN etc for - moving around, but you can try many - other things too, like TAKE LAMP, DROP EVERYTHING, EAT APPLE, EXAMINE BIRD or - FOLLOW OLD MAN, to name just a few. LOOK (L) describes your surroundings, and - INVENTORY (I) lists what you are carrying. You can SAVE your game and RESTORE it - later on. - $pType CREDITS to see information about the author and the copyright issues. - $pTo stop playing and end the program, type QUIT.$p" - STYLE normal. -END VERB. - - -SYNONYMS help, info = 'about'. - - - --- ============================================================= - - ------ AGAIN (= g) - - --- ============================================================= - - -SYNTAX again = again. - - -VERB again - DOES - "[The AGAIN command is not supported in this game. As a workaround, try using - the 'up' and 'down' arrow keys to scroll through your previous commands.]" -END VERB. - - -SYNONYMS g = again. - - - --- ============================================================= - - ------ ANSWER (+ reply) - - --- ============================================================= - - -SYNTAX answer = answer (topic) - WHERE topic ISA STRING - ELSE "That's not something you can answer." - - -ADD TO EVERY STRING - VERB answer - DOES - IF COUNT ISA ACTOR, AT hero < 1 - THEN "There is no-one here to hear you talk." - ELSE "There is no reaction." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ ASK (= enquire, inquire, interrogate) - - --- ============================================================= - - -SYNTAX ask = ask (act) about (topic)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - AND topic ISA THING - ELSE - IF topic IS NOT plural - THEN "That's doesn't" - ELSE "Those don't" - END IF. - "seem to be something you can talk about with" SAY THE act. "." - - - ask = enquire (act) about (topic)!. - - ask = inquire (act) about (topic)!. - - ask = interrogate (act) about (topic)!. - - -- Above, we define the alternative verbs in the syntax rather than as synonyms, - -- as the verb 'ask_for' below doesn't sound correct with these alternatives allowed. - - -ADD TO EVERY ACTOR - VERB ask - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - AND act <> hero - ELSE "It doesn't make much sense to ask yourself about something." - AND act IS reachable -- you might want to remove this check in some situations, e.g. - -- when an NPC (= a non-player character) is speaking - -- on the phone with the hero - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away for you to talk to." - DOES - IF topic IN act - THEN SAY THE act. - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. - IF act IS NOT plural - THEN "chooses" - ELSE "choose" - END IF. - "to be silent." - ELSIF topic = hero - THEN """I think you know more about yourself than what I do!""," SAY THE act. - IF act IS NOT plural - THEN "remarks." - ELSE "remark." - END IF. - ELSE """I don't know anything about" SAY THE topic. "$$!""," SAY THE act. - IF act IS NOT plural - THEN "remarks." - ELSE "remark." - END IF. - END IF. - END VERB. -END ADD TO. - - - - ------ note that 'consult' is defined separately - - - --- ============================================================= - - ------ ASK FOR - - --- ============================================================= - - -SYNTAX ask_for = ask (act) 'for' (obj) - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can ask for things." - AND obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can ask for." - - -ADD TO EVERY ACTOR -VERB ask_for - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - AND act <> hero - ELSE "It doesn't make much sense to ask yourself for something." - AND act IS reachable -- you might want to remove this check in some situations, e.g. - -- when an NPC (= a non-player character) is speaking - -- on the phone with the hero - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away for you to talk to." - AND obj IS takeable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "not something that" SAY THE act. "could give to you." - AND obj IS reachable - ELSE SAY THE act. "can't reach" SAY THE obj. "." - AND obj NOT IN hero - ELSE "Why ask for something you already have?" - DOES - SAY THE act. - IF act IS NOT plural - THEN "gives you" - ELSE "give you" - END IF. - SAY THE obj. "." - LOCATE obj IN hero. -END VERB. -END ADD TO. - - ---- another 'ask_for' formulation added to guide players to use the right phrasing: - - -SYNTAX ask_for_error = ask 'for' (obj) - WHERE obj ISA OBJECT - ELSE "Please use the formulation ASK PERSON FOR THING to ask somebody for - something." - - -ADD TO EVERY OBJECT -VERB ask_for_error - DOES "Please use the formulation ASK PERSON FOR THING to ask somebody for - something." -END VERB. -END ADD TO. - - - --- ============================================================= - - ------ ATTACK (+ beat, fight, hit, punch) - - --- ============================================================= - - -SYNTAX attack = attack (target) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can attack." - - -ADD TO EVERY THING - VERB attack - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - AND target <> hero - ELSE "It doesn't make sense to $v yourself." - AND target NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND target NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND target IS reachable - ELSE SAY THE target. - IF target IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to brute force is not the solution here." - END VERB. -END ADD TO. - - -SYNONYMS beat, fight, hit, punch = attack. - --- Note that 'kick' is defined separately, to avoid absurd commands such as --- 'kick man with sword' (see 'attack_with' below) - - - --- ============================================================== - - ------ ATTACK WITH - - --- ============================================================== - - -SYNTAX attack_with = attack (target) 'with' (weapon) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - AND weapon ISA WEAPON - ELSE - IF weapon ISA ACTOR - THEN - IF weapon = hero - THEN "It doesn't make sense to attack something with yourself." - ELSE "You cannot use" SAY THE weapon. "to attack anything." - END IF. - ELSE "There's no point attacking anything with" SAY THE weapon. "." - END IF. - - -ADD TO EVERY THING - VERB attack_with - WHEN target - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - AND weapon IS takeable - ELSE "You don't have" SAY THE weapon. "." - AND target <> hero - ELSE "It doesn't make sense to $v yourself." - AND target NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - AND target NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND target IS reachable - ELSE SAY THE target. - IF target IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to brute force is not the solution here." - END VERB. -END ADD TO. - - - --- =============================================================== - - ------ BITE (+ chew, taste) - - --- =============================================================== - - -SYNTAX bite = bite (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can bite." - - -ADD TO EVERY OBJECT - VERB bite - CHECK obj IS edible - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you should $v." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - -- This if-statement takes care of implicit taking; i.e. if the hero - -- doesn't have the object, (s)he will take it automatically first. - -- This same if-statement is found in numerous other verbs throughout - -- the library, as well. - - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - - - "You take a bite of" SAY THE obj. "$$." - IF obj IS NOT plural - THEN "It tastes rather good." - ELSE "They taste rather good." - END IF. - - END VERB. -END ADD TO. - - -SYNONYMS chew = bite. - - - --- =============================================================== - - ------ BREAK - - --- =============================================================== - - -SYNTAX break = break (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "Resorting to brute force is not the solution here." - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - END IF. - - -ADD TO EVERY OBJECT - VERB break - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can break." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - - DOES - "Resorting to brute force is not the solution here." - END VERB. -END ADD TO. - - -SYNONYMS destroy = break. - - - --- =============================================================== - - ------ BREAK WITH - - --- =============================================================== - - -SYNTAX break_with = break (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - AND instr ISA OBJECT - ELSE - IF instr IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v things with." - - -ADD TO EVERY OBJECT - VERB break_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can break." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "Trying to break" SAY THE obj. "with" SAY THE instr. - "wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ BRIEF - - --- ================================================================ - - --- Use "Visits 0." or "Visits 1000." in the START section if you want --- the game to start in verbose or brief mode. (By default, --- all games start in the verbose mode.) - - -SYNTAX brief = brief. - - -VERB brief - DOES - Visits 1000. - "Brief mode is now on. Location descriptions will only be shown - the first time you visit." -END VERB. - - - --- ================================================================= - - ------ BURN - - --- ================================================================= - - -SYNTAX burn = burn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "That would be needlessly brutal." - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can burn." - END IF. - - -ADD TO EVERY OBJECT - VERB burn - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can burn." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "You must state what you want to burn" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ================================================================= - - ------ BURN WITH - - --- ================================================================= - - -SYNTAX burn_with = burn (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "That would be needlessly brutal." - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can ask for things." - END IF. - AND instr ISA OBJECT - ELSE - IF instr ISA ACTOR - THEN "It doesn't make sense to burn something with" SAY THE instr. "." - ELSE "It's not possible to burn something with" - IF instr IS NOT plural - THEN "that." - ELSE "those." - END IF. - END IF. - - -ADD TO EVERY OBJECT - VERB burn_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can burn." - AND obj <> instr - ELSE "It doesn't make sense to burn something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - DOES - "You can't burn" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ BUY (+ purchase) - - --- ================================================================== - - -SYNTAX buy = buy (item) - WHERE item ISA OBJECT - ELSE - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - - -ADD TO EVERY OBJECT - VERB buy - CHECK item IS examinable - ELSE - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can buy." - DOES - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "for sale." - END VERB. -END ADD TO. - - -SYNONYMS purchase = buy. - - - --- ================================================================== - - ------ CATCH - - --- ================================================================== - - -SYNTAX catch = catch (obj) - WHERE obj ISA THING - ELSE "That's not something you can catch." - - -ADD TO EVERY THING - VERB catch - CHECK obj <> hero - ELSE "It doesn't make sense to $v yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to catch anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to catch anything while lying down." - DOES - IF obj IS NOT plural - THEN "That doesn't" - ELSE "Those don't" - END IF. - "need to be caught." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ CLEAN ( + wipe, polish) - - --- ================================================================== - - -SYNTAX clean = clean (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - - -ADD TO EVERY OBJECT - VERB clean - CHECK obj IS examinable - ELSE IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS wipe, polish = clean. - - ------ notice that 'rub' is defined separately - - - --- ============================================================== - - ------ CLIMB - - --- ============================================================== - - -SYNTAX climb = climb (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb." - - -ADD TO EVERY OBJECT - VERB climb - CHECK obj IS examinable - ELSE IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND hero IS NOT sitting - ELSE "It is difficult to climb while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb while lying down." - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB ON - - --- ============================================================== - - -SYNTAX climb_on = climb 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb on." - - -ADD TO EVERY SUPPORTER - VERB climb_on - CHECK surface IS reachable - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB THROUGH - - --- ============================================================== - - -SYNTAX climb_through = climb through (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb through." - - -ADD TO EVERY OBJECT - VERB climb_through - CHECK obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb through." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLOSE (+ shut) - - --- ============================================================== - - -SYNTAX close = close (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - - -ADD TO EVERY OBJECT - VERB close - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can close." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT closed - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already closed." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - MAKE obj closed. - "You close the" SAY THE obj. "." - END VERB. -END ADD TO. - - -SYNONYMS shut = close. - - - --- ============================================================== - - ------ CLOSE WITH - - --- ============================================================== - - -SYNTAX close_with = close (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - AND instr ISA OBJECT - ELSE - IF instr IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "$v anything with that." - - -ADD TO EVERY OBJECT - VERB close_with - WHEN obj - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT closed - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already closed." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "You can't $v" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CONSULT - - --- ============================================================== - - -SYNTAX consult = consult (source) about (topic)! - WHERE source ISA THING - ELSE - IF source IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can consult." - AND topic ISA THING - ELSE - IF topic IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can find information about." - - - consult = 'look' 'up' (topic) 'in' (source). - - -ADD TO EVERY THING - VERB consult - WHEN source - CHECK source IS examinable - ELSE - IF source IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can consult." - AND source <> hero - ELSE "It doesn't make sense to consult yourself about anything." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND source IS reachable - ELSE SAY THE source. - IF source IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - IF source ISA OBJECT - THEN "You find nothing useful about" SAY THE topic. "in" SAY THE source. "." - ELSE SAY THE source. - IF source IS NOT plural - THEN "chooses" - ELSE "choose" - END IF. - "to be silent on that subject." - END IF. - END VERB. -END ADD TO. - - ---- another 'consult' formulation added to guide players to use the right phrasing: - - -SYNTAX consult_error = consult (source) - WHERE source ISA THING - ELSE "To consult something, please use the - formulation CONSULT PERSON/THING ABOUT PERSON/THING." - - -ADD TO EVERY THING - VERB consult_error - DOES "To consult something, please use the formulation CONSULT PERSON/THING - ABOUT PERSON/THING." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CREDITS (+ acknowledgments, author, copyright) - - --- ============================================================== - - -SYNTAX credits = credits. - - -VERB credits - DOES - "The author retains the copyright to this game. - $pThis game was written using the ALAN Adventure Language. ALAN is - an interactive fiction authoring system by Thomas Nilsson. - $nE-mail address: thomas.nilsson@progindus.se $pFurther information - about the ALAN system can be obtained from - the World Wide Web Internet site - $ihttp://www.alanif.se$p" -END VERB. - - -SYNONYMS acknowledgments, author, copyright = credits. - - - --- ============================================================== - - ------ CUT - - --- ============================================================== - - -SYNTAX cut = cut (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can cut." - - -ADD TO EVERY OBJECT - VERB cut - DOES "You need to specify what you want to cut" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CUT WITH - - --- ============================================================== - - -SYNTAX cut_with = cut (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can cut." - AND instr ISA OBJECT - ELSE - IF instr IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can cut with." - - -ADD TO EVERY OBJECT - VERB cut_with - WHEN obj - CHECK obj <> instr - ELSE "You can't cut something with itself." - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "You can't cut" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DANCE - - --- ============================================================== - - -SYNTAX dance = dance. - - -VERB dance - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dance while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dance while lying down." - DOES - "How about a waltz?" -END VERB. - - - --- ============================================================== - - ------ DIG - - --- ============================================================== - - -SYNTAX dig = dig (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can dig." - - -ADD TO EVERY OBJECT - VERB dig - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dig anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dig anything while lying down." - DOES - "There is nothing suitable to dig here." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DIVE - - --- ============================================================== - - -SYNTAX dive = dive. - - -VERB dive - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ DIVE IN - - --- ============================================================== - - -SYNTAX dive_in = dive 'in' (liq) - WHERE liq ISA LIQUID - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can dive into." - - -ADD TO EVERY OBJECT - VERB dive_in - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - - DOES - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can dive into." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DRINK - - --- ============================================================== - - -SYNTAX drink = drink (liq) - WHERE liq ISA LIQUID -- see 'classes.i' - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drink." - - -ADD TO EVERY LIQUID - VERB drink - CHECK liq IS drinkable - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drink." - AND liq IS takeable - ELSE "You don't have" SAY THE liq. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND liq IS reachable - ELSE SAY THE liq. - IF liq IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - IF vessel OF liq = no_vessel -- here, if the liquid is in no container, e.g. - -- the hero takes a sip of water from a river, - -- the action is allowed to succeed. - THEN "You drink a bit of" SAY THE liq. "." - ELSE - -- implicit taking: - IF vessel OF liq NOT DIRECTLY IN hero - THEN - IF vessel OF liq IS NOT takeable - THEN "You can't carry" SAY THE liq. "around in your bare hands." - ELSE LOCATE vessel OF liq IN hero. - "(taking" SAY THE vessel OF liq. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF liq IN hero -- i.e. if the implicit taking was successful - THEN - "You drink all of" SAY THE liq. "." - LOCATE liq AT nowhere. - END IF. - END IF. - - END VERB. -END ADD TO. - - --- Note that the verb 'sip' is defined separately, with a slightly different behaviour. - - - --- ============================================================== - - ------ DRIVE - - --- ============================================================== - - -SYNTAX drive = drive (vehicle) - WHERE vehicle ISA OBJECT - ELSE - IF vehicle IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drive." - - -ADD TO EVERY OBJECT - VERB drive - DOES - IF vehicle IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drive." - END VERB. -END ADD TO. - - --- another 'drive' formulation added to guide players to use the right phrasing: - - -SYNTAX drive_error = drive. - - -VERB drive_error - DOES "To drive something, use the phrasing DRIVE SOMETHING." -END VERB. - - - --- ============================================================== - - ------ DROP - - --- ============================================================== - - -SYNTAX drop = drop (obj)* - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - - - drop = put (obj) * down. - - - drop = put down (obj)*. - - -ADD TO EVERY OBJECT - VERB drop - CHECK obj IN hero - ELSE "You don't have" SAY THE obj. "." - DOES - LOCATE obj HERE. - "Dropped." - END VERB. -END ADD TO. - - -SYNONYMS - discard, dump, reject = drop. - - - --- ============================================================== - - ------ EAT - - --- ============================================================== - - -SYNTAX eat = eat (food) - WHERE food ISA OBJECT - ELSE - IF food IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can eat." - - -ADD TO EVERY OBJECT - VERB eat - CHECK food IS edible - ELSE - IF food IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can eat." - AND food IS takeable - ELSE "You don't have" SAY THE food. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND food IS reachable - ELSE SAY THE food. - IF food IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - -- implicit taking: - IF food NOT DIRECTLY IN hero - THEN "(taking" SAY THE food. "first)$n" - LOCATE food IN hero. - END IF. - -- end of implicit taking. - - "You eat all of" SAY THE food. "." - LOCATE food AT nowhere. - - END VERB. -END ADD. - - - --- ============================================================== - - ------ EMPTY (+ POUR) - - --- ============================================================== - - --- The verbs 'empty' and 'pour' have similar syntaxes and behaviour here. They are, however, --- not declared as synonyms but kept separate, as their usage doesn't overlap 100%; for example --- you can pour liquids but not empty them. --- That's why in 'classes.i', liquids are defined only to work with the verb 'pour', --- and the verb 'empty' is disabled for liquids. - - - - -SYNTAX 'empty' = 'empty' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - AND obj ISA CONTAINER - ELSE "You can only empty containers." - - pour = pour (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - AND obj ISA CONTAINER - ELSE "You can only pour containers." - - -ADD TO EVERY OBJECT - VERB 'empty', pour - CHECK obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. - ELSE "You $v the contents of" SAY THE obj. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - EMPTY obj AT hero. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ EMPTY IN (+ POUR IN) - - --- ============================================================== - - - -SYNTAX empty_in = 'empty' (obj) 'in' (cont) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - AND cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty things into." - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty things into." - - -pour_in = pour (obj) 'in' (cont) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - AND cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour things into." - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour things into." - - -ADD TO EVERY OBJECT -VERB empty_in, pour_in - WHEN obj - CHECK obj <> cont - ELSE "It doesn't make sense to $v something into itself." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj NOT DIRECTLY IN cont - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already in" SAY THE cont. "." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND cont IS reachable - ELSE SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - AND cont IS NOT closed - ELSE "You can't, since" SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. "." - ELSE EMPTY obj IN cont. - "You $v the contents of" SAY THE obj. - "into" SAY THE cont. "." - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ EMPTY ON (+ POUR ON) - - --- ============================================================== - - - -SYNTAX empty_on = 'empty' (obj) 'on' (surface) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - AND surface ISA OBJECT - ELSE - IF surface ISA ACTOR - THEN - IF surface = hero - THEN "That wouldn't make sense." - ELSE "That wouldn't be polite." - END IF. - ELSE "You can't empty anything onto" SAY THE surface. "." - END IF. - AND surface ISA CONTAINER - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - "something you can empty things onto." - - - pour_on = pour (obj) 'on' (surface) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - AND surface ISA OBJECT - ELSE - IF surface ISA ACTOR - THEN - IF surface = hero - THEN "That wouldn't make sense." - ELSE "That wouldn't be polite." - END IF. - ELSE "You can't pour anything onto" SAY THE surface. "." - END IF. - AND surface ISA CONTAINER - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - "something you can pour things onto." - - -ADD TO EVERY OBJECT -VERB empty_on, pour_on - WHEN obj - CHECK obj <> surface - ELSE "It doesn't make sense to $v something on itself." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND surface IS reachable - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. "." - ELSE - IF surface = floor OR surface = ground - THEN EMPTY obj AT hero. - "You $v the contents of" SAY THE obj. "on" SAY THE surface. "." - ELSIF surface ISA SUPPORTER - THEN EMPTY obj IN surface. - "You $v the contents of" SAY THE obj. "on" SAY THE surface. "." - ELSE "It wouldn't be sensible to $v anything on" SAY THE surface. - END IF. - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ ENTER - - --- ============================================================== - - -SYNTAX enter = enter (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can enter." - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can enter." - - -ADD TO EVERY OBJECT - VERB enter - CHECK hero IS NOT sitting - ELSE "It is difficult to enter anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to enter anything while lying down." - DOES - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can enter." - END VERB. -END ADD TO. - - ---- another 'enter' formulation declared to guide players to use the right formulation: - - -SYNTAX enter_error = enter. - - -VERB enter_error - DOES "You must state what you want to enter." -END VERB. - - - --- ============================================================== - - ------ EXAMINE (+ look at) - - --- ============================================================== - - -SYNTAX examine = examine (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can examine." - - -SYNTAX examine = 'look' 'at' (obj). - examine = 'look' (obj). -- note that this formulation is allowed, too - - -ADD TO EVERY THING - VERB examine - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can examine." - AND CURRENT LOCATION IS lit - ELSE "You can't see anything in the dark." - DOES - IF obj IS readable - THEN - IF text OF obj = "" - THEN "There is nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. "." - IF obj IS NOT plural - THEN "It says" - ELSE "They say" - END IF. - """$$" SAY text OF obj. "$$""." - END IF. - ELSE "There is nothing special about" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - 'check', inspect, observe, x = examine. - - - --- ============================================================== - - ------ EXIT - - --- ============================================================== - - -SYNTAX 'exit' = 'exit' (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can exit." - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can exit." - -ADD TO EVERY OBJECT - VERB 'exit' - CHECK hero IN cont - ELSE - IF cont = current_room - THEN "You must state a direction where to go." - ELSE "But you aren't in" SAY THE cont. "!" - END IF. - DOES - "You exit" SAY THE cont. "." - LOCATE hero AT CURRENT LOCATION. - MAKE hero NOT sitting. - MAKE hero NOT lying_down. - END VERB. -END ADD TO. - - ---- another 'exit' formulation added to guide players to use the right formulation: - - -SYNTAX exit_error = 'exit'. - - -VERB exit_error - DOES - "You must state what you want to exit." -END VERB. - - - --- ============================================================== - - ------ EXTINGUISH (+ put out) - - --- ============================================================== - - - -SYNTAX extinguish = extinguish (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can extinguish." - - extinguish = put 'out' (obj). - - -ADD TO EVERY OBJECT - VERB extinguish - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "on fire." - END VERB. -END ADD TO. - - -SYNONYMS quench = extinguish. - - - --- ============================================================== - - ------ FILL - - --- ============================================================== - - -SYNTAX fill = fill (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fill." - AND cont ISA CONTAINER - ELSE IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fill." - - -ADD TO EVERY OBJECT - VERB fill - DOES - "You have to say what you want to fill" SAY THE cont. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL WITH - - --- ============================================================== - - -SYNTAX fill_with = fill (cont) 'with' (substance) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fill." - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fill." - AND substance ISA OBJECT - ELSE "It's not possible to fill something with" - IF substance IS NOT plural - THEN "that." - ELSE "those." - END IF. - - -ADD TO EVERY OBJECT - VERB fill_with - WHEN cont - CHECK cont <> substance - ELSE "It doesn't make sense to fill something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND substance NOT IN cont - ELSE SAY THE cont. "is already full of" SAY substance. "." - AND cont IS reachable - ELSE SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - -- "That wouldn't accomplish anything." - - "You fill" SAY THE cont. "with" SAY substance. "." - LOCATE substance IN cont. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIND - - --- ============================================================== - - -SYNTAX - find = find (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you need to find." - - -ADD TO EVERY THING - VERB find - CHECK obj <> hero - ELSE "You're right here!" - AND CURRENT LOCATION IS lit - ELSE "It's too dark to find anything here." - AND obj NOT HERE - ELSE "The" SAY obj. "is right here!" - DOES - "You'll have to find it yourself." - END VERB. -END ADD TO. - - -SYNONYMS 'locate' = find. - - - --- ============================================================== - - ------ FIRE - - --- ============================================================== - - -SYNTAX fire = fire (weapon) - WHERE weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire." - - -ADD TO EVERY WEAPON - VERB fire - CHECK weapon IS fireable - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire." - AND weapon IN hero - ELSE "You don't have" SAY THE weapon. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You fire" SAY THE weapon. "into the air." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIRE AT - - --- ============================================================== - - -SYNTAX fire_at = fire (weapon) 'at' (target) - WHERE weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire." - AND target ISA THING - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shoot at." - - -ADD TO EVERY WEAPON - VERB fire_at - WHEN weapon - CHECK weapon IS fireable - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire." - AND weapon IN hero - ELSE "You don't have" SAY THE weapon. "." - AND target <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the solution here." - END VERB. -END ADD TO. - - --- another formulation added: - - -SYNTAX fire_at_error = fire 'at' (target) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire at." - - -ADD TO EVERY THING -VERB fire_at_error - CHECK COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE "You are not holding any firearm." - AND target <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the solution here." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIX (mend, repair) - - --- ============================================================== - - -SYNTAX - fix = fix (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - - -ADD TO EVERY OBJECT - VERB fix - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS broken - ELSE "The" SAY obj. "doesn't need fixing." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "Please be more specific. How do you intend to fix it?" - END VERB. -END ADD TO. - - -SYNONYMS mend, repair = fix. - - - --- ============================================================== - - ------ FLIP - - --- ============================================================== - - -SYNTAX flip = flip (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can flip." - - -ADD TO EVERY OBJECT - VERB flip - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES ONLY - "That's not something you need to flip." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FOLLOW - - --- ============================================================== - - -SYNTAX follow = follow (act)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can follow." - - -ADD TO EVERY THING - VERB follow - CHECK act <> hero - ELSE "It doesn't make sense to follow yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND act NOT AT hero - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "right here." - AND hero IS NOT sitting - ELSE "It is difficult to follow anybody while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to follow anybody while lying down." - AND act NOT NEAR hero -- this check presumes that if the actor to be followed - -- is in an adjacent location, the hero will be able to follow him/her. - ELSE "You follow" SAY THE act. "." - LOCATE hero AT act. - DOES - "You don't quite know where" SAY THE act. "went. You must state a direction - where you want to go." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FREE (+ release) - - --- ============================================================== - - -SYNTAX free = free (obj) - WHERE obj ISA THING - ELSE IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you need to $v." - - -ADD TO EVERY THING - VERB free - CHECK obj IS examinable - ELSE "That's not something you can $v." - AND obj <> hero - ELSE "You don't need to be freed at present." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "That doesn't need to be $vd." - END VERB. -END ADD TO. - - -SYNONYMS release = free. - - - --- ============================================================== - - ------- GET OFF - - --- ============================================================== - - -SYNTAX get_off = get off (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can get off." - - -ADD TO EVERY SUPPORTER - VERB get_off - DOES - IF hero IS sitting OR hero IS lying_down - THEN "You get off" SAY THE surface. "." - MAKE hero NOT lying_down. - MAKE hero NOT sitting. - ELSE "You're standing up already." - END IF. - END VERB. -END ADD TO. - - --- ============================================================== - - ------- GET UP - - --- ============================================================== - - -SYNTAX get_up = get up. - - -VERB get_up - DOES - IF hero IS sitting - THEN "You stand up." - MAKE hero NOT sitting. - ELSIF hero IS lying_down - THEN "You get up." - MAKE hero NOT lying_down. - ELSE "You're standing up already." - END IF. -END VERB. - - - --- ============================================================== - - ------ GIVE (+ hand, offer) - - --- ============================================================== - - -SYNTAX give = 'give' (obj) 'to' (recip) - WHERE obj ISA OBJECT - ELSE "You can only give away objects." - AND recip ISA ACTOR - ELSE - IF recip IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can give things to." - - - give = give (recip) (obj). - - -ADD TO EVERY OBJECT - VERB give - WHEN obj - CHECK obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND obj <> recip - ELSE "It doesn't make sense to give something to itself." - AND recip <> hero - ELSE "It doesn't make sense to give something to yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND recip IS reachable - ELSE SAY THE recip. - IF recip IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - AND obj NOT IN recip - ELSE SAY THE recip. "already" - IF recip IS NOT plural - THEN "has" - ELSE "have" - END IF. - SAY THE obj. "." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - "You give" SAY THE obj. "to" SAY THE recip. "." - LOCATE obj IN recip. - - END VERB. -END ADD TO. - - -SYNONYMS hand, offer = give. - - - --- ============================================================== - - ------ GO TO - - --- ============================================================== - - -SYNTAX go_to = 'to' (dest)! -- because 'go' is predefined in the parser, it can't be used - WHERE dest ISA THING -- in verb definitions - ELSE "It's not possible to go to there." - - -ADD TO EVERY THING - VERB go_to - CHECK dest <> hero - ELSE "You're right here!" - AND hero IS NOT sitting - ELSE "It is difficult to go anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to go anywhere while lying down." - DOES - IF dest AT hero - THEN - IF dest IS NOT reachable - THEN "You can't reach" SAY THE dest. "from here." - ELSE - IF CURRENT LOCATION IS lit - THEN IF dest IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - "right here!" - ELSE "It is too dark to see." - END IF. - END IF. - ELSE "You can't see" SAY THE dest. "anywhere nearby. You must state a - direction where you want to go." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS walk = go. -- here we define a synonym for the predefined parser word 'go' - -- which is not visible in the syntax itself. - -- Thus, you will be able to say e.g. both 'go to shop' and 'walk to shop' - -- (as well as e.g. both 'go east' and 'walk east'). - - - --- ============================================================== - - ------ HELP -> see ABOUT - - --- ============================================================== - - - - - --- ============================================================== - - ------ HINT (+ hints) - - --- ============================================================== - - -SYNTAX hint = hint. - - -VERB hint - DOES - "Unfortunately hints are not available in this game." -END VERB. - - -SYNONYMS - hints = hint. - - - --- ============================================================== - - ------ INVENTORY (+ i, inv) - - --- ============================================================== - - - -ADD TO EVERY THING - IS weight 0. -END ADD TO THING. - - -ADD TO EVERY ACTOR - IS weight 50. -END ADD TO ACTOR. - - -ADD TO EVERY OBJECT - IS weight 5. -END ADD TO OBJECT. - - -SYNTAX i = i. - - -VERB i - DOES - LIST hero. - - -- if the hero in your game carries any containers you want the contents of - -- to be listed after 'inventory', you should manually add the listing right here - -- according to the following example: - -- - -- IF bag IN hero - -- THEN LIST bag. - -- END IF. - -- - -- This way, 'inventory' will yield e.g. "You are carrying a bag. The bag contains a book." - -- If you leave the above addition out, the outcome will be just "You are carrying a bag.", with - -- no comment on what is inside the bag. - - IF COUNT IN worn > 0 -- See the file 'classes.i', subclass 'clothing'. - THEN LIST worn. -- This code will list what the hero is wearing. - END IF. - -END VERB. - - -SYNONYMS inv, inventory = i. - - - --- ============================================================== - - ------ JUMP - - --- ============================================================== - - -SYNTAX jump = jump. - - -VERB jump - CHECK hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "You jump on the spot, to no avail." -END VERB. - - - --- ============================================================== - - ------ JUMP IN - - --- ============================================================== - - -SYNTAX jump_in = jump 'in' (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump into." - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump into." - - -ADD TO EVERY OBJECT - VERB jump_in - CHECK CURRENT LOCATION IS lit - ELSE "It's too dark to see." - AND cont IS reachable - ELSE SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "That's not something you can jump into." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ JUMP ON - - --- ============================================================== - - -SYNTAX jump_on = jump 'on' (surface) - WHERE surface ISA OBJECT - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump on." - AND surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump on." - - -ADD TO EVERY OBJECT - VERB jump_on - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND surface IS reachable - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - IF surface ISA SUPPORTER - THEN "That wouldn't accomplish anything." - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump onto." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ KICK - - --- ============================================================= - - -SYNTAX kick = kick (target) - WHERE target ISA THING - ELSE IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can kick." - - -ADD TO EVERY THING - VERB kick - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can kick." - AND target <> hero - ELSE "It doesn't make sense to kick yourself." - AND target NOT IN hero - ELSE "It doesn't make much sense to kick something you're holding." - AND target NOT IN worn - ELSE "It doesn't make sense to kick something you're wearing." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND target IS reachable - ELSE SAY THE target. - IF target IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES "Resorting to brute force is not the solution here." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL (+ murder) - - --- ============================================================== - - -SYNTAX kill = kill (victim) - WHERE victim ISA ACTOR - ELSE - IF victim IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - - -ADD TO EVERY ACTOR - VERB kill - CHECK victim <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL WITH - - --- ============================================================== - - -SYNTAX kill_with = kill (victim) 'with' (weapon) - WHERE victim ISA ACTOR - ELSE - IF victim IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - AND weapon ISA WEAPON - ELSE "You cannot kill anybody with" SAY THE weapon. "." - - -ADD TO EVERY ACTOR - VERB kill_with - WHEN victim - CHECK victim <> hero - ELSE "There's no need to be that desperate." - AND weapon IN hero - ELSE "You don't have" SAY THE weapon. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ KISS (+ hug, embrace) - - --- ============================================================== - - -SYNTAX kiss = kiss (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can kiss." - - -ADD TO EVERY THING - VERB kiss - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can kiss." - AND obj <> hero - ELSE "There is no time for that now." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - IF obj ISA ACTOR - THEN SAY THE obj. "avoids your advances." - ELSE "Nothing would be achieved by that." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS hug, embrace = kiss. - - - --- ============================================================== - - ------ KNOCK - - --- ============================================================== - - -SYNTAX knock = knock 'on' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can knock on." - - - knock = knock (obj). - - -ADD TO EVERY OBJECT - VERB knock - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can knock on." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "You knock on" SAY THE obj. "$$. Nothing happens." - END VERB. -END ADD TO. - - ---- another 'knock' formulation added to guide players to use the right phrasing: - - -SYNTAX knock_error = knock. - - -VERB knock_error - DOES - "Please use the formulation KNOCK ON SOMETHING to knock on something." -END VERB. - - - --- ============================================================== - - ------ LIE DOWN - - --- ============================================================== - - -SYNTAX lie_down = lie 'down'. - - lie_down = lie. - - -VERB lie_down - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down right now." - -- If you need this to work, insert the following lines instead of the above: - -- DOES "You lie down." - -- MAKE hero lying_down. - -- MAKE hero NOT sitting_down. -END VERB. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE IN - - --- ============================================================== - - -SYNTAX lie_in = lie 'in' (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lie in." - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lie in." - - - lie_in = lie 'down' 'in' (cont). - - -ADD TO EVERY OBJECT - VERB lie_in - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down in" SAY THE cont. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down in" SAY THE cont. "." - -- LOCATE hero IN cont. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE ON - - --- ============================================================== - - -SYNTAX lie_on = lie 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lie on." - - - lie_on = lie 'down' 'on' (surface). - - -ADD TO EVERY OBJECT - VERB lie_on - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down on" SAY THE surface. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down on" SAY THE surface. "." - -- LOCATE hero IN surface. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIFT - - --- ============================================================== - - -SYNTAX lift = lift (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lift." - - -ADD TO EVERY THING - VERB lift - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lift." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND obj IS movable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lift." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND obj <> hero - ELSE "It doesn't make sense to lift yourself." - AND obj NOT IN hero - ELSE "You're already holding" SAY THE obj. "." - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LIGHT (+ lit) - - --- ============================================================== - - -SYNTAX light = light (obj) - WHERE obj ISA LIGHTSOURCE - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - - -ADD TO EVERY OBJECT - VERB light - CHECK obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - END VERB. -END ADD TO. - - -SYNONYMS lit = light. - - - --- ============================================================== - - ------ LISTEN - - --- ============================================================== - - -SYNTAX listen0 = listen. - - -VERB listen0 - DOES - "You hear nothing unusual." -END VERB. - - - --- ============================================================== - - ------ LISTEN TO - - --- ============================================================== - - -SYNTAX listen = listen 'to' (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can listen to." - - -ADD TO EVERY THING - VERB listen - CHECK obj <> hero - ELSE "It doesn't make sense to listen to yourself." - DOES - IF obj AT hero - THEN "You hear nothing unusual." - ELSIF obj NEAR hero - THEN "You can't hear" SAY THE obj. "very well from here." - ELSE "You can't hear anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK - - --- ============================================================== - - -SYNTAX lock = lock (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lock." - - -ADD TO EVERY OBJECT - VERB lock - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lock." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND obj IS NOT locked - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already locked." - DOES - "You have to state what you want to lock" SAY THE obj. "with." - -- If you need this to work, use the following lines instead: - -- MAKE obj locked. "You" - -- IF obj IS NOT closed - -- THEN "close and" - -- MAKE obj closed. - -- END IF. - -- "lock" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK WITH - - --- ============================================================== - - -SYNTAX lock_with = lock (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lock." - AND instr ISA OBJECT - ELSE "You can't lock anything with" SAY THE instr. "." - - -ADD TO EVERY OBJECT - VERB lock_with - WHEN obj - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lock." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT locked - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already locked." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND instr IN hero - ELSE - "You don't have" SAY THE instr. "." - DOES - "You can't lock" SAY THE obj. "with" SAY THE instr. "." - -- If you need this to work, use the following lines instead: - -- MAKE obj locked. "You" - -- IF obj IS NOT closed - -- THEN "close and" - -- MAKE obj closed. - -- END IF. - -- "lock" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK - - --- ============================================================== - - -SYNTAX 'look' = 'look'. - - -VERB 'look' - DOES - LOOK. - INCREASE described OF CURRENT LOCATION. - -- see 'locations.i', attribute 'described'. -END VERB. - - -SYNONYMS l = 'look'. - - - --- ============================================================== - - ------ LOOK AT -> see EXAMINE - - --- ============================================================== - - - - - --- ============================================================== - - ------ LOOK BEHIND - - --- ============================================================== - - -SYNTAX look_behind = 'look' behind (bulk) - WHERE bulk ISA THING - ELSE "You can't look behind" SAY THE bulk. "." - - -ADD TO EVERY THING - VERB look_behind - CHECK bulk IS examinable - ELSE - "You can't look behind" SAY THE bulk. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND bulk <> hero - ELSE "Turning your head, you notice nothing unusual behind yourself." - DOES - "You notice nothing unusual behind" SAY THE bulk. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK IN - - --- ============================================================== - - -SYNTAX - look_in = 'look' 'in' (cont) - WHERE cont ISA OBJECT - ELSE "You can't look inside" SAY THE cont. "." - AND cont ISA CONTAINER - ELSE "You can't look inside" SAY THE cont. "." - - -ADD TO EVERY OBJECT - VERB look_in - CHECK cont IS examinable - ELSE - "You can't look inside" SAY THE cont. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND cont IS NOT closed - ELSE "You can't, since" SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - - DOES - LIST cont. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK OUT OF - - --- ============================================================== - - -SYNTAX look_out_of = 'look' 'out' 'of' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look out of." - - -ADD TO EVERY OBJECT - VERB look_out_of - CHECK obj IS examinable - ELSE - "You can't look out of" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look out of." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK THROUGH - - --- ============================================================== - - -SYNTAX look_through = 'look' through (bulk) - WHERE bulk ISA THING - ELSE - IF bulk IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look through." - - -ADD TO EVERY THING - VERB look_through - CHECK bulk IS examinable - ELSE "You can't look through" SAY THE bulk. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't see through" SAY THE bulk. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UNDER - - --- ============================================================== - - -SYNTAX look_under = 'look' under (bulk) - WHERE bulk ISA THING - ELSE IF bulk IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look under." - - -ADD TO EVERY THING - VERB look_under - CHECK bulk IS examinable - ELSE "You can't look under" SAY THE bulk. "." - AND bulk <> hero - ELSE "It doesn't make sense to look under yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You notice nothing unusual under" SAY THE bulk. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UP (-> see also CONSULT) - - --- ============================================================== - - -SYNTAX look_up = 'look' up. - - -VERB look_up - DOES "Looking up, you see nothing unusual." -END VERB. - - - --- ============================================================== - - ------ NO - - --- ============================================================== - - -SYNTAX 'no' = 'no'. - - -VERB 'no' - DOES "You sound rather negative." -END VERB. - - - --- ============================================================== - - ------ NOTIFY - - --- ============================================================== - - --- Thanks to Steve Griffiths whose 'Score notification' sample was used --- in declaring this verb. - - - -SYNTAX notify = notify. - - notify_on = notify 'on'. -- The instructions tell the player that mere 'notify' - -- is enough, but these two verbs are implemented - notify_off = notify 'off'. -- in case (s)he adds the prepositions to the end anyway. - - -VERB notify - DOES - IF hero IS notify_on - THEN MAKE hero NOT notify_on. - "Score notification is now disabled. (You can turn it back on - using the NOTIFY command again.)" - ELSE MAKE hero notify_on. "Score notification is now enabled. - (You can turn it off using the NOTIFY command again.)" - END IF. -END VERB. - - -VERB notify_on - DOES - IF hero IS notify_on - THEN "Score notification is already enabled." - ELSE MAKE hero notify_on. - "Score notification is now enabled. - (You can turn it off using the NOTIFY command again.)" - END IF. -END VERB. - - -VERB notify_off - DOES - IF hero IS notify_on - THEN MAKE hero NOT notify_on. - "Score notification is now disabled. (You can turn it back on - using the NOTIFY command again.)" - ELSE "Score notification is already disabled." - END IF. -END VERB. - - --- The 'notify' verb allows the players to disable the score change --- messages. (Some players find such messages annoying.) --- The verb toggles the hero's 'notify_on' attribute on and off. That --- attribute is checked by the 'checkscore' event to determine whether --- to display the score msg or not. - - --- The following event is run each turn to check if the game score is greater than --- the last recorded score (which is stored in the Hero's 'oldscore' --- attribute). If the score is greater, then the 'Score has gone up...' --- text is displayed (as long as the player hasn't disabled it by using the --- 'notify' verb - which sets 'notify_on' to off --- - i.e. the hero 'IS NOT notify_on'.) - --- NOTE: The ALAN scoring system records the game score in a thing called --- score. It isn't called score OF anything; its just 'score'. - --- NOTE: This event assumes score can only increase, if score can go --- down then you would need to modify this code a bit. - - -EVENT check_score - IF oldscore OF hero < score - THEN - IF hero IS notify_on - THEN -- ie: the player wants to see score msgs - "$p(Your score has just gone up by" SAY (score - oldscore OF hero). - IF (score - oldscore OF hero) = 1 - THEN "point.)" - ELSE "points.)" - END IF. - -- this msg only displayed the first time player is notified - -- of a score change - IF hero IS NOT seen_notify - THEN MAKE hero seen_notify. - "$p(You can use the NOTIFY command to disable score change messages.)" - END IF. - END IF. - - SET oldscore OF hero TO score. - END IF. - -- run the 'check_score' event again next turn: - SCHEDULE check_score AT hero AFTER 1. -END EVENT. - - - - --- ============================================================== - - ------ OPEN - - --- ============================================================== - - -SYNTAX open = open (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can open." - - -ADD TO EVERY OBJECT - VERB open - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can open." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND obj IS closed - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already open." - AND obj IS NOT locked - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "appears" - ELSE "appear" - END IF. - "to be locked." - DOES - MAKE obj NOT closed. - "You open" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ OPEN WITH - - --- ============================================================== - - -SYNTAX open_with = open (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can open." - AND instr ISA OBJECT - ELSE "You can't open anything with" SAY THE instr. "." - - -ADD TO EVERY OBJECT - VERB open_with - WHEN obj - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can open." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - AND obj IS closed - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already open." - AND obj IS NOT locked - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "appears" - ELSE "appear" - END IF. - "to be locked." - DOES - "You can't open" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY - - --- ============================================================== - - -SYNTAX 'play' = 'play' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can play." - - -ADD TO EVERY OBJECT - VERB 'play' - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can play." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY WITH - - --- ============================================================== - - -SYNTAX play_with = 'play' 'with' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can play with." - - -ADD TO EVERY OBJECT - VERB play_with - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "After second thoughts you don't find it purposeful to start - playing with" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR, POUR IN, POUR ON - - --- ============================================================== - - - --- => SEE EMPTY, EMPTY IN, EMPTY ON - - - - --- ============================================================== - - ------ PRAY - - --- ============================================================== - - -SYNTAX pray = pray. - - -VERB pray - DOES "Your prayers don't seem to help right now." -END VERB. - - - --- ============================================================== - - ------ PRY - - --- ============================================================== - - -SYNTAX pry = pry (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pry." - - -ADD TO EVERY OBJECT -VERB pry - DOES "You must state what you want to pry" SAY THE obj. "with." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PRY_WITH - - --- ============================================================== - - -SYNTAX pry_with = pry (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pry." - AND instr ISA OBJECT - ELSE "You can't pry anything with" - IF instr IS NOT plural - THEN "that" - ELSE "those" - END IF. - "." - - -ADD TO EVERY OBJECT -VERB pry_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pry." - AND obj <> instr - ELSE "You can't pry something with itself." - AND instr IN hero - ELSE "You don't have" SAY THE instr. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES "That doesn't work." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PULL - - --- ============================================================== - - -SYNTAX pull = pull (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense to pull yourself." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pull." - END IF. - - -ADD TO EVERY OBJECT -VERB pull - CHECK obj IS movable - ELSE "It's not possible to pull" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES "That wouldn't accomplish anything." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUSH - - --- ============================================================== - - -SYNTAX push = push (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can push." - - -ADD TO EVERY THING - VERB PUSH - CHECK obj IS movable - ELSE - "That would be futile." - AND obj NOT IN hero - ELSE "But you're holding" SAY THE obj. "." - AND obj <> hero - ELSE "It doesn't make sense to push yourself." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "You give" SAY THE obj. "a little push. Nothing happens." - END VERB. -END ADD TO. - - -SYNONYMS press = push. - - - --- ============================================================== - - ------ PUSH WITH - - --- ============================================================== - - -SYNTAX push_with = push (obj) 'with' (instr) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can push." - AND instr ISA OBJECT - ELSE "You can use only objects to push things with." - - -ADD TO EVERY THING - VERB push_with - WHEN obj - CHECK obj IS movable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can push." - AND obj <> instr - ELSE "It doesn't make sense to push something with itself." - AND obj NOT IN hero - ELSE "But you're holding" SAY THE obj. "." - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - AND obj <> hero - ELSE "It doesn't make sense to push yourself with something." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "Using" SAY THE instr. "you push" SAY THE obj. "$$. Nothing special happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT (+ lay, locate, place) - - --- ============================================================== - - -SYNTAX put = put (obj) - WHERE obj ISA OBJECT - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - - -ADD TO EVERY OBJECT - VERB put - CHECK obj IN HERO - ELSE "You don't have" SAY THE obj. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You must state where you want to put" - IF obj IS NOT plural - THEN "it." - ELSE "them." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS lay, place = put. - - - --- ============================================================== - - ------ PUT DOWN (works as 'drop') - - --- ============================================================== - - ------ The syntax for 'put down' has been declared in the 'drop' verb. - - - - --- ============================================================== - - ------ PUT IN (+ insert) - - --- ============================================================== - - -SYNTAX put_in = put (obj) 'in' (cont) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense to put yourself into something." - ELSE "You can only put objects somewhere." - -- If you need to allow e.g. 'put child in bed' - -- then you should remove this check. - END IF. - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - AND cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can put things in." - AND cont ISA CONTAINER - ELSE "You can't put anything there." - - - put_in = insert (obj) 'in' (cont). - - -ADD TO EVERY OBJECT - VERB put_in - WHEN obj - CHECK obj <> cont - ELSE "It doesn't make sense to put something into itself." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj NOT IN cont - ELSE - IF cont ISA SUPPORTER - THEN "You can't put" SAY THE obj. "inside" SAY THE cont. "." - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "in" SAY THE cont. "already." - END IF. - AND cont IS NOT closed - ELSE "You can't, since" SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - AND cont IS reachable - ELSE SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - LOCATE obj IN cont. - "You put" SAY THE obj. "into" SAY THE cont. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT AGAINST - - --- ============================================================== - - -SYNTAX put_against = put (obj) against (bulk) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "That doesn't make sense." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - AND bulk ISA THING - ELSE "You can't put anything against that." - - -ADD TO EVERY OBJECT - VERB put_against - WHEN obj - CHECK bulk NOT IN hero - ELSE "That would achieve nothing." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND obj <> bulk - ELSE "That doesn't make sense." - AND bulk <> hero - ELSE "That would be futile." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND bulk IS reachable - ELSE SAY THE bulk. - IF bulk IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "That wouldn't accomplish anything." - - -- To make it work, type e.g.: - -- IF obj NOT IN hero - -- THEN "(taking" SAY THE obj. "first)$n" - -- END IF. - -- "You put" SAY THE obj. "against" SAY THE bulk. "." - -- (+ you would need probably need an attribute to check that the object is leaning against the bulk) - END VERB. -END ADD TO. - - --- ============================================================== - - ------ PUT BEHIND, NEAR, UNDER - - --- ============================================================== - - -SYNTAX put_near = put (obj) 'near' (bulk) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "That doesn't make sense." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - AND bulk ISA THING - ELSE "You can't put anything near that." - - - put_behind = put (obj) behind (bulk) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN SAY THE obj. "wouldn't probably appreciate that." - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - AND bulk ISA THING - ELSE "You can't put anything behind that." - - - put_under = put (obj) under (bulk) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN SAY THE obj. "wouldn't probably appreciate that." - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - AND bulk ISA THING - ELSE "You can't put anything under" - IF obj IS NOT plural - THEN "that." - ELSE "those." - END IF. - - -ADD TO EVERY OBJECT - VERB put_near, put_behind, put_under - WHEN obj - CHECK bulk NOT IN hero - ELSE "That would be futile." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND obj <> bulk - ELSE "That doesn't make sense." - AND bulk <> hero - ELSE "That would be futile." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND bulk IS reachable - ELSE SAY THE bulk. - IF bulk IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "That wouldn't accomplish anything." - - -- To make it work, type e.g.: - -- IF obj NOT IN hero - -- THEN "(taking" SAY THE obj. "first)$n" - -- END IF. - -- "You put" SAY THE obj. "near" --(or behind or under) SAY THE bulk. "." - -- (+ you would need to define some attributes to check that - -- the object is behind another object, etc.) - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT_ON - - --- ============================================================== - - --- To use this verb in the meaning 'wear', see the file 'classes.i', --- class 'clothing', verb 'wear'. - --- You can put things on the floor/ground or on a supporter. In other --- cases, the response will be "That wouldn't accomplish anything." - - - -SYNTAX put_on = put (obj) 'on' (surface) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "That would be futile." - ELSE SAY THE obj. "wouldn't probably - appreciate that." - END IF. - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - AND surface ISA OBJECT - ELSE "You can't well put anything on top of " - IF surface IS NOT plural - THEN "that." - ELSE "those." - END IF. - AND surface ISA CONTAINER - ELSE "You can't well put anything on top of" - IF surface IS NOT plural - THEN "that." - ELSE "those." - END IF. - - - -ADD TO EVERY OBJECT - VERB put_on - WHEN obj - CHECK surface NOT IN hero - ELSE "That would be futile." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND obj <> surface - ELSE "That doesn't make sense." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj NOT IN surface - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "on" SAY THE surface. "already." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND surface IS reachable - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF surface = floor OR surface = ground - THEN LOCATE obj AT hero. - "You put" SAY THE obj. "on" SAY THE surface. "." - ELSIF surface ISA SUPPORTER - THEN LOCATE obj IN surface. - "You put" SAY THE obj. "on" SAY THE surface. "." - ELSE "That wouldn't accomplish anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT OUT (works as -> EXTINGUISH) - - --- ============================================================== - - ------ The syntax for 'put out' has been declared in the 'extinguish' verb. - - - --- ============================================================== - - ------ QUIT - - --- ============================================================== - - -SYNTAX - 'quit' = 'quit'. - - -VERB 'quit' - DOES - QUIT. -END VERB. - - -SYNONYMS q = 'quit'. - - - --- ============================================================== - - ------ READ - - --- ============================================================== - - -SYNTAX read = read (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can read." - - -ADD TO EVERY OBJECT - VERB read - CHECK obj IS readable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can read." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - DOES - IF text OF obj = "" - THEN "There's nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. "." - IF obj IS NOT plural - THEN "It says" - ELSE "They say" - END IF. - """$$" SAY text OF obj. "$$""." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - --- REMOVE - - --- ============================================================== - - --- see the file 'classes.i', class 'clothing' for the definition of --- this verb - - - - - --- ============================================================== - - ------ REMOVE FROM ( => TAKE FROM) - - --- ============================================================== - - ------ this verb works as 'take from' - - - --- ============================================================== - - ------ RESTART - - --- ============================================================== - - -SYNTAX 'restart' = 'restart'. - - -VERB 'restart' - DOES - RESTART. -END VERB. - - - --- ============================================================== - - ------ RESTORE - - --- ============================================================== - - -SYNTAX 'restore' = 'restore'. - - -VERB 'restore' - DOES - RESTORE. -END VERB. - - - --- ============================================================== - - ------ RUB (+ massage) - - --- ============================================================== - - -SYNTAX rub = rub (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can rub." - - -ADD TO EVERY THING - VERB rub - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can rub." - AND obj <> hero - ELSE "There's no time for that now." - AND obj IS inanimate - ELSE "You aren't sure whether" SAY THE obj. - "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS massage = rub. - - - --- ============================================================== - - ------ SAVE - - --- ============================================================== - - -SYNTAX 'save' = 'save'. - - -VERB 'save' - DOES - SAVE. -END VERB. - - - --- ============================================================== - - ------ SAY - - --- ============================================================== - - -SYNTAX 'say' = 'say' (topic) - WHERE topic ISA STRING - ELSE "That's not something you can say." - - -ADD TO EVERY THING - VERB 'say' - DOES - "You utter """ SAY topic. "$$"". Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SAY TO - - --- ============================================================== - - -SYNTAX say_to = 'say' (topic) 'to' (act) - WHERE topic ISA STRING - ELSE "Nothing happens." - AND act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - - -ADD TO EVERY ACTOR - VERB say_to - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - AND act IS reachable - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - DOES - SAY THE act. - IF act IS NOT plural - THEN "doesn't look" - ELSE "don't look" - END IF. - "interested." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SCORE - - --- ============================================================== - - -SYNTAX 'score' = 'score'. - - -VERB 'score' - DOES - SCORE. - -- (or, if you wish to disable the score, use the following kind of - -- line instead of the above:) - -- "There is no score in this game." -END VERB 'score'. - - - --- ============================================================== - - ------ SCRATCH - - --- ============================================================== - - -SYNTAX scratch = scratch (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can scratch." - - -ADD TO EVERY THING - VERB scratch - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can scratch." - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - AND obj <> hero - ELSE "That wouldn't help matters." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------- SCRIPT - - --- ============================================================== - - -SYNTAX 'script' = 'script'. - script_on = 'script' 'on'. - script_off = 'script' 'off'. - -SYNONYMS 'transcript' = 'script'. - -VERB 'script' - DOES - "You can turn transcripting on and off using the 'script on/off' command within the game. - The transcript will be available in a file with a name starting with the game name. - $pIn a GUI version you can also find this in the drop-down menu in the interpreter. - $pIn a command line version you can start your game with the '-s' switch to get a transcript of the whole game." -END VERB. - -VERB script_on - DOES - TRANSCRIPT ON. - "Transcripting turned on." -END VERB. - -VERB script_off - DOES - TRANSCRIPT OFF. - "Transcripting turned off." -END VERB. - - - --- ============================================================== - - ------- SEARCH - - --- ============================================================== - - -SYNTAX search = search (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can search." - - -ADD TO EVERY THING - VERB search - CHECK obj <> hero - ELSE LIST hero. - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "You find nothing of interest." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SELL - - --- ============================================================== - - -SYNTAX sell = sell (item) - WHERE item ISA OBJECT - ELSE - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can sell." - - -ADD TO EVERY OBJECT - VERB sell - CHECK item IS examinable - ELSE - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can sell." - DOES - "There's nobody here who would be interested in buying" SAY THE item. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHAKE - - --- ============================================================== - - -SYNTAX shake = shake (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense - to shake yourself." - ELSE SAY THE obj. "wouldn't probably - appreciate that." - END IF. - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shake." - END IF. - - -ADD TO EVERY OBJECT -VERB shake - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shake." - AND obj IS movable - ELSE "Shaking" SAY THE obj. "is not possible." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - IF obj IN hero - THEN "You shake" SAY THE obj. "cautiously in your hands. Nothing happens." - ELSE "There is no reason to start shaking" SAY THE obj. "." - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOOT - - --- ============================================================== - - - -SYNTAX shoot = shoot (target) - WHERE target ISA THING - ELSE "That's not something you can shoot." - shoot = shoot 'at' (target). - - -ADD TO EVERY THING - VERB shoot - CHECK target <> hero - ELSE "There's no need to be that desperate." - AND COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE "You don't have anything to shoot with." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the solution here." - END VERB. -END ADD TO. - - --- another 'shoot' formulation added, to guide players to use the right phrasing: - - -SYNTAX shoot_error = shoot. - - -VERB shoot_error - DOES "You must state what you want to shoot, e.g. SHOOT BEAR WITH RIFLE." -END VERB. - - - --- ============================================================== - - ------ SHOOT WITH - - --- ============================================================== - - -SYNTAX shoot_with = shoot (target) 'with' (weapon) - WHERE target ISA THING - ELSE "That's not something you can shoot." - AND weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shoot with." - - shoot_with = shoot (weapon) 'at' (target). - -- to allow player input such as 'shoot rifle at bear' - - -ADD TO EVERY THING - VERB shoot_with - WHEN target - CHECK weapon IN hero - ELSE "You don't have" SAY THE weapon. "." - AND target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shoot." - AND target <> hero - ELSE "There's no need to be that desperate." - AND target <> weapon - ELSE "It doesn't make sense to shoot something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the solution here." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOUT - - --- ============================================================== - - -SYNTAX shout = shout. - - -VERB shout - DOES - "Nothing results from your $ving." -END VERB. - - -SYNONYMS scream, yell = shout. - - - --- ============================================================== - - ------ SHOW - - --- ============================================================== - - -SYNTAX 'show' = 'show' (obj) 'to' (act) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can show." - AND act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can show things to." - - -ADD TO EVERY THING - VERB 'show' - WHEN obj - CHECK obj IN hero - ELSE "You don't have" SAY THE obj. "." - AND act <> hero - ELSE "It doesn't make sense to show something to yourself." - AND obj <> act - ELSE "It doesn't make sense to show something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "not especially interested." - END VERB. -END ADD TO. - - -SYNONYMS reveal = 'show'. - - - --- ============================================================== - - ------ SING (+ hum, whistle) - - --- ============================================================== - - -SYNTAX sing = sing. - - -VERB sing - DOES - "You $v a little tune." -END VERB. - - -SYNONYMS hum, whistle = sing. - - - --- ============================================================== - - ------ SIP - - --- ============================================================== - - -SYNTAX sip = sip (liq) - WHERE liq ISA LIQUID - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drink." - - -ADD TO EVERY LIQUID - VERB sip - CHECK liq IS drinkable - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drink." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND liq IS reachable - ELSE SAY THE liq. - IF liq IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - IF vessel OF liq = no_vessel -- here, if the liquid is in no container, e.g. - -- the hero takes a sip of water from a river, - -- the action is allowed to succeed. - THEN "You take a sip of" SAY THE liq. "." - ELSE - -- implicit taking: - IF vessel OF liq NOT DIRECTLY IN hero - THEN - IF vessel OF liq IS NOT takeable - THEN "It's not worth the bother trying to take a sip of" SAY THE liq. "." - ELSE LOCATE vessel OF liq IN hero. - "(taking" SAY THE vessel OF liq. "first)$n" - END IF. - END IF. - -- end of implicit taking. - END IF. - - IF liq IN hero -- i.e. if the implicit taking was successful - THEN "You take a sip of" SAY THE liq. "." - END IF. - - END VERB. -END ADD TO. - - --- See also the verb 'drink'. - - --- ============================================================== - - ------ SIT - - --- ============================================================== - - -SYNTAX sit = sit. - - - sit = sit 'down'. - - -VERB sit - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - DOES - "You feel no urge to sit down at present." - -- (or, if you wish to make it work, use the following instead of the above: - -- IF hero IS lying_down - -- THEN "You sit up." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down." - -- END IF. - -- MAKE hero sitting. -END VERB. - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SIT_ON - - --- ============================================================== - - -SYNTAX sit_on = sit 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can sit on." - - -ADD TO EVERY SUPPORTER - VERB sit_on - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You feel no urge to sit down at present." - -- (or, to make it work, use the following instead of the above:) - -- IF hero lying_down - -- THEN "You get up and sit down on" SAY THE surface. "." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down on" SAY THE surface. "." - -- END IF. - -- LOCATE hero IN surface. - -- MAKE hero sitting. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SLEEP (+ rest) - - --- ============================================================== - - -SYNTAX sleep = sleep. - - -VERB sleep - DOES - "There's no need to $v right now." -END VERB. - - -SYNONYMS rest = sleep. - - - --- ============================================================== - - ------ SMELL (smell0) - - --- ============================================================== - - -SYNTAX smell0 = smell. - - -VERB smell0 - DOES - "You smell nothing unusual." -END VERB. - - - --- ============================================================== - - ------ SMELL (+ obj) - - --- ============================================================== - - -SYNTAX smell = smell (odour)! - WHERE odour ISA THING - ELSE - IF odour IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can smell." - - -ADD TO EVERY THING - VERB smell - DOES - "You smell nothing unusual." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SQUEEZE - - --- ============================================================== - - -SYNTAX squeeze = squeeze (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can squeeze." - - -ADD TO EVERY THING - VERB squeeze - CHECK obj IS examinable - ELSE IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can squeeze." - AND CURRENT LOCATION IS lit - ELSE - IF obj = hero - THEN "Nothing would be achieved by that." - -- you can squeeze yourself in the dark, as well - ELSE "It is too dark to see." - END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - - DOES - IF obj ISA ACTOR - THEN "That wouldn't be polite." - ELSE "Trying to squeeze" SAY THE obj. "wouldn't be sensible." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ STAND - - --- ============================================================== - - -SYNTAX stand = stand. - - - stand = stand 'up'. - - -VERB stand - CHECK hero IS NOT lying_down - ELSE "You get up." - MAKE hero NOT lying_down. - AND hero IS NOT sitting - ELSE "You stand up." - MAKE hero NOT sitting. - DOES - "You're standing up already." -END VERB. - - - --- ============================================================== - - ------ STAND_ON - - --- ============================================================== - - -SYNTAX stand_on = stand 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can stand on." - - - stand_on = get 'on' (surface). - - -ADD TO EVERY SUPPORTER -VERB stand_on - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You feel no urge to stand on" SAY THE surface. "." - -- or, to make it work, use the following instead of the above: - -- "You get on" SAY THE surface. "." - -- LOCATE hero IN surface. - -- MAKE hero NOT sitting. MAKE hero NOT lying_down. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWIM - - --- ============================================================== - - -SYNTAX swim = swim. - - -VERB swim - CHECK hero IS NOT sitting - ELSE "It is difficult to try swimming while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to try swimming while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ SWIM IN - - --- ============================================================== - - -SYNTAX swim_in = swim 'in' (liq) - WHERE liq ISA LIQUID - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can swim in." - - - -ADD TO EVERY OBJECT -VERB swim_in - CHECK hero IS NOT sitting - ELSE "It is difficult to swim anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to swim anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can swim in." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH - - --- ============================================================== - - --- This is a mere 'switch' verb with no 'on' or 'off' following after it. --- This verb is defined further in 'classes.i', under 'device' and 'lightsource'. --- This verb exists just to cover cases where the player forgets to write --- 'on' or 'off' after 'switch'. --- If the player types 'switch tv', the tv object will be switched on --- if it is off, and vice cersa. --- Below, just the basic syntax is declared. - - - -SYNTAX switch = switch (app) -- = apparatus, appliance - WHERE app ISA THING - ELSE "That's not something you can switch." - - -ADD TO EVERY THING - VERB switch - DOES - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "not something you can switch." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH ON - - --- ============================================================== - - ------ The syntax for 'switch on' has been declared in the 'turn_on' verb. - - - - --- ============================================================== - - ------ SWITCH OFF - - --- ============================================================== - - ------ The syntax for 'switch off' has been declared in the 'turn_off' verb. - - - - --- ============================================================== - - ------ TAKE (+ carry, get, grab, hold, obtain, pick up) - - --- ============================================================== - - -SYNTAX take = take (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "Taking yourself is not possible." - ELSE SAY THE obj. "would probably object to that." - END IF. - ELSE - IF obj IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - "not something you can take." - END IF. - - - take = get (obj). - - - take = pick up (obj). - - - take = pick (obj) up. - - -ADD TO EVERY OBJECT - VERB take - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS takeable - ELSE - IF obj ISA SCENERY - THEN "Unimportant for your purposes, you leave the" SAY THE obj. "where it is." - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can take." - END IF. - AND obj NOT DIRECTLY IN hero - -- i.e. the object to be taken is not carried by the hero already - ELSE "You already have" SAY THE obj. "." - AND obj NOT DIRECTLY IN worn - -- i.e. the object to be taken is a piece of clothing that the player character is wearing; - -- here, this verb works in practise like 'take off'. - ELSE "You take off" SAY THE obj. "and carry" - IF obj IS NOT plural - THEN "it" - ELSE "them" - END IF. - "in your hands." - LOCATE obj IN hero. - AND obj IS movable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "much too heavy for you to move." - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - - END IF. - "out of your reach." - AND weight Of obj <=50 - ELSE SAY THE obj. "is too heavy to lift." - DOES - "Taken." - LOCATE obj IN hero. - END VERB. -END ADD TO. - - -SYNONYMS - carry, grab, hold, obtain = take. - - - --- ============================================================== - - ------ TAKE FROM - - --- ============================================================== - - -SYNTAX take_from = 'take' (obj) 'from' (holder) - WHERE obj ISA OBJECT - ELSE "You can only take objects." - AND holder ISA THING - ELSE "It's not possible to take things from there." - AND holder ISA CONTAINER - ELSE "It's not possible to take things from there." - - - take_from = remove (obj)* 'from' (holder). - - - take_from = get (obj) 'from' (holder). - - -ADD TO EVERY OBJECT - VERB take_from - WHEN obj - CHECK holder <> hero - ELSE "You can't take things from yourself." - AND obj NOT IN hero - ELSE "You already have" SAY THE obj. "." - AND obj <> holder - ELSE "You can't take something from itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IN holder - ELSE - IF obj ISA CLOTHING -- A piece of clothing worn by an NPC is not *in* the NPC but in a special - -- npc_worn container (see 'classes.i', class 'actor'). We need to take the class 'clothing' separately - -- into account here. - THEN -- Here, we allow the piece of clothing to be taken if it is takeable, skipping the remaining checks below. - FOR EACH nw ISA NPC_WORN DO - IF carrier OF nw <> no_carrier - THEN - IF obj IS takeable - THEN LOCATE obj IN hero. - "You take" SAY THE obj. "from" SAY THE holder. "." - ELSE - IF THIS IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - "not something you can take." - END IF. - END IF. - END FOR. - ELSIF holder IS inanimate - THEN SAY THE obj. - IF obj IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - IF holder ISA SUPPORTER - THEN "on" - ELSE "in" - END IF. - SAY THE holder. "." - ELSE SAY THE holder. - IF holder IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "have" SAY THE obj. "." - END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND holder IS NOT closed - ELSE "You can't, since" SAY THE holder. - IF holder IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - AND obj IS movable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "much too heavy for you to take." - AND obj IS takeable - ELSE - IF obj ISA SCENERY - THEN "Unimportant for your purposes, you leave" - SAY THE obj. "where" - IF obj IS NOT plural - THEN "it is." - ELSE "they are." - END IF. - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can take." - END IF. - AND weight Of obj <=50 - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too heavy." - DOES - LOCATE obj IN hero. - "You take" SAY THE obj. "from" SAY THE holder. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TALK - - --- ============================================================== - - -SYNTAX talk = talk. - - -VERB talk - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING - or TELL PERSON ABOUT THING." -END VERB. - - - --- ============================================================== - - ------ TALK_TO - - - --- ============================================================== - - -SYNTAX talk_to = talk 'to' (act) - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - - -ADD TO EVERY ACTOR - VERB talk_to - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - -SYNTAX talk_to_a = talk 'to' (act) about (topic)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - AND topic ISA THING - ELSE "That's not something you can talk about." - - -ADD TO EVERY ACTOR - VERB talk_to_a - WHEN act - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - --- ============================================================== - - ------ TASTE (+ lick) - - --- ============================================================== - - -SYNTAX taste = taste (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can taste." - - -ADD TO EVERY OBJECT - VERB taste - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can taste." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES "You taste nothing unexpected." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TEAR (+ rip) - - --- ============================================================== - - -SYNTAX tear = tear (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tear." - - -ADD TO EVERY OBJECT - VERB tear - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tear." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "That would be futile." - END VERB. -END ADD TO. - - -SYNONYMS rip = tear. - - - --- ============================================================== - - ------ TELL (+ enlighten, inform) - - --- ============================================================== - - -SYNTAX tell = tell (act) about (topic)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - AND topic ISA THING - ELSE - IF topic IS NOT plural - THEN "That doesn't" - ELSE "Those don't" - END IF. - "seem to be something you can talk - about with" SAY THE act. "." - - -ADD TO EVERY ACTOR - VERB tell - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - AND act IS reachable - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - AND act <> hero - ELSE "It doesn't make much sense to tell yourself about something." - DOES - IF topic IN act - THEN SAY THE act. - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. - IF act IS NOT plural - THEN "chooses" - ELSE "choose" - END IF. - "to be silent." - ELSIF topic = hero - THEN SAY THE act. - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "look interested." - ELSE SAY THE act. - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "look interested." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS enlighten, inform = tell. - - - --- ============================================================== - - ------ THINK (+ ponder, meditate, reflect) - - --- ============================================================== - - -SYNTAX think = think. - - -VERB think - DOES - "Nothing helpful comes to your mind." -END VERB. - - -SYNONYMS ponder, meditate, reflect = think. - - - --- ============================================================== - - ------ THINK ABOUT - - --- ============================================================== - - -SYNTAX think_about = think 'about' (topic)! - WHERE topic ISA THING - ELSE - IF topic IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something fruitful to think about." - - -ADD TO EVERY THING - VERB think_about - DOES - "Nothing helpful comes to your mind." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW - - --- ============================================================== - - -SYNTAX throw = throw (projectile) - WHERE projectile ISA OBJECT - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - - -ADD TO EVERY OBJECT - VERB throw - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - AND projectile IS takeable - ELSE "You don't have" SAY THE projectile. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND projectile IS reachable - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - -- implicit taking: - IF projectile NOT DIRECTLY IN hero - THEN "(taking" SAY THE projectile. "first)$n" - LOCATE projectile IN hero. - END IF. - -- end of implicit taking. - - "You can't throw very far;" SAY THE projectile. - IF projectile IS NOT plural - THEN "ends up" - ELSE "end up" - END IF. - "on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE projectile AT hero. - - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ THROW AT - - --- ============================================================== - - -SYNTAX throw_at = throw (projectile) 'at' (target) - WHERE projectile ISA OBJECT - ELSE "You can only throw objects." - AND target ISA THING - ELSE "It's not possible to throw things at" - IF target IS NOT plural - THEN "that." - ELSE "those." - END IF. - - - -ADD TO EVERY OBJECT - VERB throw_at - WHEN projectile - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - AND projectile IS takeable - ELSE "You don't have" SAY THE projectile. "." - AND target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things at." - AND projectile <> target - ELSE "It doesn't make sense to throw something at itself." - AND target NOT IN hero - ELSE "You are carrying" SAY THE target. "." - AND target <> hero - ELSE "You cannot throw things at yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND projectile IS reachable - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - -- implicit taking: - IF projectile NOT DIRECTLY IN hero - THEN "(taking" SAY THE projectile. "first)$n" - LOCATE projectile IN hero. - END IF. - -- end of implicit taking. - - IF target IS inanimate - THEN - IF target NOT DIRECTLY AT hero -- e.g. the target is inside a box - THEN "It wouldn't accomplish anything trying to throw something at" SAY THE target. "." - ELSE - SAY THE projectile. - IF projectile IS NOT plural - THEN "bounces" - ELSE "bounce" - END IF. - "harmlessly off" - SAY THE target. "and" - IF projectile IS NOT plural - THEN "ends up" - ELSE "end up" - END IF. - "on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE projectile HERE. - END IF. - ELSE "You throw" SAY THE projectile. "at" SAY THE target. "who" - IF target IS NOT plural - THEN "ducks" - ELSE "duck" - END IF. - "just in time." - SAY THE projectile. - IF projectile IS NOT plural - THEN "ends up" - ELSE "end up" - END IF. - "on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "." - LOCATE projectile HERE. - END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW TO - - --- ============================================================== - - -SYNTAX throw_to = throw (projectile) 'to' (recipient) - WHERE projectile ISA OBJECT - ELSE "You can only throw objects." - AND recipient ISA THING - ELSE "It's not possible to throw things to" - IF recipient IS NOT plural - THEN "that." - ELSE "those." - END IF. - AND recipient ISA CONTAINER - ELSE "It is not possible to throw things to" - IF recipient IS NOT plural - THEN "that." - ELSE "those." - END IF. - -ADD TO EVERY OBJECT - VERB throw_to - WHEN projectile - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - AND projectile IS takeable - ELSE "You don't have" SAY THE projectile. "." - AND recipient IS examinable - ELSE - IF recipient IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things at." - AND projectile <> recipient - ELSE "It doesn't make sense to throw something at itself." - AND recipient NOT IN hero - ELSE "You are carrying" SAY THE recipient. "." - AND recipient <> hero - ELSE "You cannot throw things at yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND projectile IS reachable - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND recipient IS reachable - ELSE SAY THE recipient. - IF recipient IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - -- implicit taking: - IF projectile NOT DIRECTLY IN hero - THEN "(taking" SAY THE projectile. "first)$n" - LOCATE projectile IN hero. - END IF. - -- end of implicit taking. - - IF recipient IS inanimate - THEN - IF recipient NOT DIRECTLY AT hero -- e.g. the recipient is inside a box - THEN "It wouldn't accomplish anything trying to throw something at" SAY THE recipient. "." - ELSE - SAY THE projectile. - IF projectile IS NOT plural - THEN "bounces" - ELSE "bounce" - END IF. - "harmlessly off" - SAY THE recipient. "and" - IF projectile IS NOT plural - THEN "ends up" - ELSE "end up" - END IF. - "on the" - IF floor HERE - THEN "floor" - ELSE "ground" - END IF. - "nearby." - LOCATE projectile HERE. - END IF. - ELSE "You throw" SAY THE projectile. "to" SAY THE recipient. "who" - IF recipient IS NOT plural - THEN "catches" - ELSE "catch" - END IF. - IF projectile IS plural - THEN "them." - ELSE "it." - END IF. - LOCATE projectile IN recipient. - END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------- THROW IN - - --- ============================================================== - - -SYNTAX throw_in = throw (projectile) 'in' (cont) - WHERE projectile ISA OBJECT - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - AND cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things into." - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things into." - - -ADD TO EVERY OBJECT - VERB throw_in - WHEN projectile - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - AND projectile IS takeable - ELSE "You don't have" SAY THE projectile. "." - AND cont IS examinable - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things into." - AND projectile <> cont - ELSE "It doesn't make sense to throw something into itself." - AND cont <> hero - ELSE "You can't throw" SAY THE projectile. "into yourself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND projectile NOT IN cont - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "in" SAY THE cont. "already." - AND projectile IS reachable - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND cont IS reachable - ELSE SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND cont IS NOT closed - ELSE "You can't, since" SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - DOES - "You can't throw" SAY THE projectile. "into" SAY THE cont. "." - - -- To make it work, define: - - -- implicit taking: - -- IF obj NOT DIRECTLY IN hero - -- THEN "(taking" SAY THE obj. "first)$n" - -- LOCATE obj IN hero. - -- END IF. - -- end of implicit taking. - - -- LOCATE obj IN cont. - -- "You throw" SAY THE obj. "into" SAY THE cont. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE - - --- ============================================================== - - -SYNTAX tie = tie (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tie." - - -ADD TO EVERY OBJECT - VERB tie - DOES - - "You must state where do you want to tie" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE TO - - --- ============================================================== - - -SYNTAX tie_to = tie (obj) 'to' (target) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tie." - AND target ISA OBJECT - ELSE "Nothing can be tied to" - IF target IS NOT plural - THEN "that." - ELSE "those." - END IF. - - - -ADD TO EVERY OBJECT - VERB tie_to - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tie." - AND target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tie things to." - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - AND obj <> target - ELSE "It doesn't make sense to tie something to itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND target IS reachable - ELSE SAY THE target. - IF target IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - LOCATE obj IN hero. - "It's not possible to tie" SAY THE obj. "to" SAY THE target. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TOUCH - - --- ============================================================== - - -SYNTAX touch = touch (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch." - - -ADD TO EVERY THING - VERB touch - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND obj <> hero - ELSE "That wouldn't accomplish anything." - AND obj IS inanimate - ELSE "You are not sure whether" SAY THE obj. "would appreciate that." - DOES - "You feel nothing unexpected." - END VERB. -END ADD TO. - - -SYNONYMS feel = touch. - - - --- ============================================================== - - ------ TOUCH WITH - - --- ============================================================== - - -SYNTAX touch_with = touch (obj) 'with' (instr) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch." - AND instr ISA OBJECT - ELSE "You can only use objects to touch with." - - -ADD TO EVERY THING - VERB touch_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch." - AND instr IS examinable - ELSE - IF instr IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch things with." - AND obj <> instr - ELSE "You can't touch something with itself." - AND instr <> hero - ELSE "That doesn't make sense." - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - AND obj IS inanimate - ELSE "You are not sure whether" SAY THE obj. "would appreciate that." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "You touch" SAY THE obj. "with" SAY THE instr. ". Nothing special happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN (+ rotate) - - --- ============================================================== - - -SYNTAX turn = turn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can turn." - - - turn = rotate (obj). -- we don't declare 'rotate' a synonym for 'turn' - -- through a SYNONYMS statement as we don't want - -- it to be possible for the player to type something - -- like 'rotate tv on' (see 'turn on' and 'turn off' below) - - -ADD TO EVERY OBJECT - VERB turn - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can turn." - AND obj IS movable - ELSE "It's not possible to turn" SAY THE obj. "." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES "You turn" SAY THE obj. - IF obj IN hero - THEN "in your hands" - END IF. - "$$. You notice nothing unusual about" - IF obj IS NOT plural - THEN "it" - ELSE "them" - END IF. - IF obj NOT IN hero - THEN "and return" - IF obj IS NOT plural - THEN "it" - ELSE "them" - END IF. - "to" - IF obj IS NOT plural - THEN "its" - ELSE "their" - END IF. - "original position" - END IF. - "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN ON - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These classes are ------ defined in 'classes.i' with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. ------ Trying to turn on or off an ordinary object will default here to "That's not ------ something you can turn on". - - -SYNTAX turn_on = turn 'on' (app) - WHERE app ISA OBJECT - ELSE - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v on." - - turn_on = switch 'on' (app). - - - turn_on = turn (app) 'on'. - - - turn_on = switch (app) 'on'. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', classes 'device' and 'lightsource'. --- This verb merely covers cases where the player forgets (or doesn't bother) to type 'on' or 'off'. - - - -ADD TO EVERY OBJECT - VERB turn_on - DOES - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN OFF - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These classes ------ are defined in 'classes.i' with proper checks for 'on' and 'NOT on', ------ 'lit' and 'NOT lit'. - - -SYNTAX turn_off = turn off (app) - WHERE app ISA OBJECT - ELSE - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v off." - - turn_off = switch off (app). - - - turn_off = turn (app) off. - - - turn_off = switch (app) off. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', classes 'device' and 'lightsource'. --- This verb merely covers cases where the player forgets to type 'on' or 'off'. - - -ADD TO EVERY OBJECT - VERB turn_off - DOES - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v off." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ UNDRESS - - --- ============================================================== - - --- See the file 'classes.i', class CLOTHING for the definition --- of this verb. - - - --- ============================================================== - - ------ UNLOCK - - --- ============================================================== - - -SYNTAX unlock = unlock (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can unlock." - - -ADD TO EVERY OBJECT - VERB unlock - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can unlock." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS locked - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already unlocked." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "You must state what you want to unlock" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ UNLOCK WITH - - --- ============================================================= - - -SYNTAX unlock_with = unlock (obj) 'with' (key) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can unlock." - AND key ISA OBJECT - ELSE "You can't unlock anything with" - IF key IS NOT plural - THEN "that." - ELSE "those." - END IF. - - -ADD TO EVERY OBJECT - VERB unlock_with - WHEN obj - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can unlock." - AND key In hero - ELSE "You don't have" SAY THE obj. "." - AND obj <> key - ELSE "It doesn't make sense to unlock something with itself." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS locked - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already unlocked." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - SAY THE key. - IF key IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "unlock" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE - - --- ============================================================== - - -SYNTAX 'use' = 'use' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can use." - - -ADD TO EVERY OBJECT - VERB 'use' - DOES - "Please be more specific. How do you intend to use" - IF obj IS NOT plural - THEN "it?" - ELSE "them?" - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE WITH - - --- ============================================================== - - -SYNTAX use_with = 'use' (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE "You can only use objects." - AND instr ISA OBJECT - ELSE "You can only use objects." - - -ADD TO EVERY OBJECT - VERB use_with - WHEN obj - CHECK obj <> instr - ELSE "You can't use something with itself." - DOES - "Please be more specific. How do you intend to use them together?" - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ VERBOSE (see also -> BRIEF) - - --- ============================================================== - - -SYNTAX verbose = verbose. - - -VERB verbose - DOES - VISITS 0. - "Verbose mode is now on. Location descriptions will be - always shown in full." -END VERB. - - - --- ============================================================== - - ------ WAIT (= z) - - --- ============================================================== - - -SYNTAX 'wait' = 'wait'. - - -VERB 'wait' - DOES - "Time passes..." -END VERB. - - -SYNONYMS - z = 'wait'. - - - --- ============================================================== - - ------ WEAR - - --- ============================================================== - - --- See the file 'classes.i', class CLOTHING for the definition --- of this verb. - - - --- ============================================================== - - ------ WHAT AM I - - --- ============================================================== - - -SYNTAX what_am_i = 'what' am i. - - -VERB what_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHAT IS - - --- ============================================================== - - -SYNTAX what_is = 'what' 'is' (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something I know about." - - what_is = 'what' 'are' (obj)!. - - -ADD TO EVERY THING - VERB what_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHERE AM I - - --- ============================================================== - - -SYNTAX where_am_i = 'where' am i. - - -VERB where_am_i - DOES - LOOK. -END VERB. - - - --- ============================================================== - - ------ WHERE IS - - --- ============================================================== - - -SYNTAX where_is = 'where' 'is' (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something I know about." - - where_is = 'where' 'are' (obj)!. - - -ADD TO EVERY THING - VERB where_is - CHECK obj NOT AT hero - ELSE - IF obj IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - "right here!" - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHO AM I - - --- ============================================================== - - -SYNTAX who_am_i = who am i. - - -VERB who_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHO IS - - --- ============================================================== - - -SYNTAX who_is = 'who' 'is' (act)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not somebody" - ELSE "Those are not anybody" - END IF. - "I know." - - who_is = 'who' 'are' (act)!. - - -ADD TO EVERY ACTOR - VERB who_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WRITE - - --- ============================================================== - - -SYNTAX write = write (txt) 'on' (obj) - WHERE txt ISA STRING - ELSE "Please state inside double quotes ("""") - what you want to write." - AND obj ISA OBJECT - ELSE "Nothing can be written there." - - - write = write (txt) 'in' (obj). - - -ADD TO EVERY OBJECT - VERB write - WHEN obj - CHECK obj IS writeable - ELSE "Nothing can be written there." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - IF text OF obj = "" - THEN SET text OF obj TO txt. - ELSE SET text OF obj TO text OF obj + " " + txt. - END IF. - "You write ""$$" SAY txt. "$$"" on" SAY THE obj. "." - MAKE obj readable. - END VERB. -END ADD TO. - - --- A couple of other formulations are understood but they guide the player to --- use the correct syntax: - - -SYNTAX write_error1 = write 'on' (obj) - WHERE obj ISA OBJECT - ELSE "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - - -ADD TO EVERY OBJECT - VERB write_error1 - DOES "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - END VERB. -END ADD TO. - - -SYNTAX write_error2 = write. - -VERB write_error2 - DOES "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." -END VERB. - - -SYNTAX write_error3 = write (txt) - WHERE txt ISA STRING - ELSE "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - - -ADD TO EVERY STRING - VERB write_error3 - DOES "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ YES - - --- ================================================================ - - -SYNTAX yes = yes. - - -VERB yes - DOES "You sound rather positive." -END VERB. - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newclasses.i b/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newclasses.i deleted file mode 100644 index ca60ce8..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newclasses.i +++ /dev/null @@ -1,2338 +0,0 @@ --- ALAN Standard Library v1.10 --- Classes (file name: 'classes.i') - - --- This library file defines various object and actor classes. --- Many of these classes are frequently used in verb definitions in 'verbs.i' --- so they should be edited or removed with caution. However, to ease things up, --- it is mentioned at the beginning of every class below if and where the class --- is cross-referenced in the other library files. - - --- Contents: - - - - --- 1. OBJECT CLASSES --- ================= - - - --- BACKGROUND - -- Is present in the location but cannot be reached or taken. - -- Doesn't appear automatically in room descriptions. - -- A typical example of a background would be for example the sun, - -- or a mountain visible in the distance. - -- Compare this with 'scenery' below (a background object cannot be reached, - -- but a scenery object can.) - - --- CLOTHING - -- Is a piece of clothing that behaves according to Alan Bampton's 'xwear.i' extension. - -- The said extension has been fully assimilated to this library. - -- This extension prevents clothes from being worn in an illogical order, e.g. you - -- cannot put on a shirt if you are already wearing a jacket, and so forth. - -- Also the verbs 'wear', 'remove' and 'undress' are defined here. - - --- DEVICE - -- Is a machine or an electronic device, for example a TV. Can be turned - -- (=switched) on and off if it is not broken. - -- Attributes: 'on' and NOT 'on', NOT broken. - -- Is described automatically as being either on or off when examined. - - --- DOOR - -- Can be opened, closed, locked and unlocked. - -- Is by default closed, not locked. - -- Attributes: closeable, (NOT) closed, lockable, (NOT) locked. - -- Is described automatically as being either open or closed when examined. - - --- LIQUID - -- Can only be taken if it is in a container. You can fill something with it, - -- and you can pour it somewhere. - -- A liquid is by default NOT drinkable. - - --- LIGHTSOURCE - -- IS natural or NOT natural - -- (a natural lightsource is for example a match or a torch). - -- Can be turned on and off, lighted and extinguished (= put out) if it - -- is not broken. A natural lightsource - -- cannot be turned on or off, it can only be lighted and extinguished (= put out). - -- When examined, a lightsource is automatically supplied with a description of - -- whether it is providing light or not. - - --- LISTED_CONTAINER - -- Is a special kind of container, the contents of which will be listed both after - -- 'look' (= in the room description), 'look in' and 'examine' (if the container is open). - -- (The contents of a normal container object are not listed after 'examine' but only - -- after 'look' (=room description) and 'look in'). - - --- SOUND - -- Can be listened to but not examined, searched, smelled or manipulated. - -- Cannot initially be turned on or off, this has to be implemented manually by giving - -- the sound the 'switchable' attribute. - - --- SUPPORTER - -- You can put things on this and you can stand on this. It is declared a container, - -- so you can take things from it, as well. When there's something on a supporter, - -- an automatic listing of it will appear in the room description and after 'examine'. - - --- WEAPON - -- IS fireable (e.g. a cannon) or NOT fireable (e.g. a baseball bat). - - --- WINDOW - -- Can be opened, closed, looked through and out of. - -- Will be automatically described as being either open or closed when examined. - - - --- 2. ACTOR CLASSES --- ================ - --- the ACTORS are defined here to be NOT inanimate CONTAINERS (so that they can e.g. --- receive and carry things. The 'contents' (= possessions) of an actor (except for the hero) --- are automatically listed after 'look' and 'examine'. (For the hero, the command 'inventory' --- must be used.) --- --- Actors are usually preceded by an article in-game: --- e.g. "You see a man here." --- "There is nothing special about the dog." --- unless they are declared as 'named'. --- --- The following classes for actors are defined in this library: - - --- PERSON - -- is able to talk (= 'CAN talk'). - - --- FEMALE - -- a subclass of person (= is able to talk) - -- can be referred to with the pronoun 'her' - - --- MALE - -- a subclass of person (= is able to talk) - -- can be referred to with the pronoun 'him' - - - - - --- The contents end here. - - - --- ============================================================= - --- ============================================================= --- --- 1. Object classes --- --- ============================================================= - --- ============================================================= - - - - - --- ============================================================= - - ------ BACKGROUND - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY background ISA OBJECT - IS distant. - DESCRIPTION "" -END EVERY. - - --- A background object is present in the location but cannot be reached. --- Note that a background object in ALAN3 is different from e.g. the backdrop in Inform7 --- in that a background object is at one location at a time only, unless --- you use the nested locations feature in ALAN which makes the object available --- in several locations. --- Here is an example where a ceiling lamp is located in the lobby, the bedroom --- and the living-room of a house, but not in other locations: - - --- 1) First, define the area where the object(s) should be found: - --- THE lamp_rooms ISA LOCATION --- END THE. - --- and then define which locations belong to that area: - --- THE lobby ISA LOCATION IN lamp_rooms --- END THE. - --- THE bedroom ISA LOCATION IN lamp_rooms --- END THE. - --- THE livingroom ISA LOCATION IN lamp_rooms --- END THE. - - - --- 2) Then, place the background object in the area: - --- THE ceiling_lamp ISA BACKGROUND IN lamp_rooms --- NAME ceiling lamp --- END THE. - - --- Now, the lamp is in scope in all of the above locations. (You'll have to include in the --- location description manually though.) - --- Note that in this code you could define exits to other rooms of the house in the --- normal way, without having to worry about the area at all, e.g.: - --- THE bedroom ISA LOCATION IN lamp_rooms --- EXIT west TO upstairs_landing. --- END THE. - --- THE upstairs_landing ISA LOCATION - -- ( = a location outside the defined area) --- EXIT east TO bedroom. --- END THE. - --- etc. - --- Naturally, you could also define a scenery object or a normal object to be --- in several locations at once, in the same way. Note, however, that if you define --- a takeable object in this manner, it will disappear from the other locations once --- you take it in one location. Also, when manipulated (e.g. broken), the object --- will be affected in all of the locations it is found. - - - --- ============================================================== - - ------ CLOTHING (+ the verbs WEAR, REMOVE, UNDRESS) - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'inventory' and 'take' where the --- container 'worn', defined below, is used in the verb definitions.) - - --- To use this class, see the documentation text right after the --- code below. - --- This class makes use of Alan Bampton's 'xwear.i' extension --- written originally for ALAN V2, converted here to V3 and --- assimilated fully to the present library. Thanks to Alan Bampton --- for the permission to use the code here. - - ------------------------------------------------------------------ --- First, we declare the container for clothing. ------------------------------------------------------------------ - - --- an entity is present everywhere and thus the hero's clothing is always accessible: - -THE worn ISA ENTITY - CONTAINER TAKING CLOTHING. - HEADER SAY hero_worn_header OF my_game. - ELSE SAY hero_worn_else OF my_game. -END THE. - - - - - -------------------------------------------------------------------- --- Now, we define some common attributes for clothing as well as --- how the verbs 'wear' and 'remove' (and their synonyms) behave with this class. -------------------------------------------------------------------- - - -EVERY clothing ISA OBJECT - - IS wearable. - IS sex 0. - IS headcover 0. - IS handscover 0. - IS feetcover 0. - IS topcover 0. - IS botcover 0. - - CONTAINER - -- to allow e.g. a wallet to be put into a jacket - - - -- If the clothing contains something, e.g. if a jacket contains a wallet, - -- the wallet will be mentioned when the jacket is examined: - - VERB examine - DOES AFTER - IF THIS IS NOT OPAQUE - THEN - IF COUNT ISA OBJECT, IN THIS > 0 - THEN LIST THIS. - END IF. - END IF. - END VERB. - - - - VERB wear - CHECK THIS NOT IN worn - ELSE SAY check_obj_not_in_worn1 OF my_game. - AND THIS IS takeable - ELSE - IF THIS IS NOT plural - THEN SAY check_obj_takeable OF my_game. - ELSE SAY check_obj_takeable OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND sex OF THIS = sex OF hero OR sex OF THIS = 0 - ELSE SAY check_clothing_sex OF my_game. - - DOES ONLY - - --------------------------------------------------------------------- --- 'wear_flag' is a multi-purpose flag used for several purposes in --- this library, here it is reset to 0 before proceeding as a matter --- of 'housekeeping' for the code. --------------------------------------------------------------------- - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- First check to see if the player is carrying the item already, if --- not, set the 'wear_flag' to 1 to indicate the item was picked up --- in this turn. --------------------------------------------------------------------- - - - IF THIS NOT IN hero - THEN - SET wear_flag OF hero TO 1. - END IF. - - --------------------------------------------------------------------- --- Now see if the player can put this item on by testing --- all of its coverage attributes against the player's state. --------------------------------------------------------------------- - - --------------------------------------------------------------------- --- First check the 'topcover' attributes, if 'obj' fails this test --- then it means the hero is already wearing clothes that cover the --- topcover area and those clothes are of the same layer or a layer --- that belongs on top of the 'obj' item. In either case it would --- NOT be possible to put on the 'obj'. To 'flag' this condition add --- 5 to the 'wear_flag' attribute as an indicator this test failed. --------------------------------------------------------------------- - - - IF topcover OF THIS <> 0 AND topcover OF THIS <= SUM OF topcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - - --IF THIS IN tempworn - --THEN - - IF handscover OF THIS <> 0 AND handscover OF THIS <= SUM OF handscover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF feetcover OF THIS <> 0 AND feetcover OF THIS <= SUM OF feetcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF headcover OF THIS <> 0 AND headcover OF THIS <= SUM OF headcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case, adjust the 'tempcovered OF hero' --- attribute so that the code rejects non sensible options. --- First of all, discount any coatlike clothes as these never --- affect ability to put on other lower body only garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - - IF tempcovered OF hero >63 and botcover OF THIS < 33 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not technically affect ability to put on lower body only clothes. --- Special clause here excludes the full body coverage 'teddy' type --- garment - as a skirt WOULD prevent that from being removed. --- ( dress/coat garments automatically prevent this by virtue of --- having higher 'topcover' settings than the teddy ) --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 AND botcover OF THIS < 16 and botcover OF THIS <> 4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- IF tempcovered OF hero is still > 15 then must have trousers --- type clothing on - therefore disallow wearing dress type clothing --- because, although technically possible, it is not very sensible. --------------------------------------------------------------------- - - - IF tempcovered OF hero >15 AND botcover OF THIS > 16 - THEN - SET tempcovered OF hero TO tempcovered OF hero +16. - END IF. - - --------------------------------------------------------------------- --- From here down, clothes DO work as they do for other areas. --------------------------------------------------------------------- - - - IF botcover OF THIS <> 0 AND botcover OF THIS <= tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- At this point, 'wear_flag' will be 0 if the obj was held by the --- player and can be put on, or l if he picked it up this turn and --- it can be put on. Any higher value means one or more of the --- tests failed and the player cannot put on these clothes. --------------------------------------------------------------------- - - - IF wear_flag OF hero >1 - THEN - IF THIS NOT IN hero - THEN "You pick up the" SAY THE THIS. "." - END IF. - - LOCATE THIS IN hero. - EMPTY worn IN tempworn. - LIST tempworn. - - "Trying to put" SAY THE THIS. "on isn't very sensible." - - EMPTY tempworn IN worn. - - ELSIF wear_flag OF hero = 1 - THEN - LOCATE THIS IN worn. - - "You pick up the" SAY THE THIS. - - IF THIS IS NOT plural - THEN "and put it on." - ELSE "and put them on." - END IF. - - ELSE - LOCATE THIS IN worn. - "You put on" SAY THE THIS. "." - END IF. - -END VERB. - - - -VERB remove - CHECK THIS IN worn - ELSE SAY check_obj_in_worn OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - - DOES ONLY - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- Check the total 'topcover' of items worn. Because of the number --- sequence used, by dividing the sum of the worn attributes by two --- and then comparing the result to the individual 'topcover' of the --- obj in question, ( the former can only ever be greater than the --- latter if an article of clothing is worn that goes over 'obj' ) --- it's easy to tell if the obj ought to be removable. A temporary --- attribute is used here because it needs to be manipulated. Once --- again 'wear_flag' is used to indicate the results. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF topcover IN worn /2. - IF topcover OF THIS <> 0 AND topcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF handscover IN worn /2. - IF handscover OF THIS <> 0 AND handscover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF feetcover IN worn /2. - IF feetcover OF THIS <> 0 AND feetcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF headcover IN worn /2. - IF headcover OF THIS <> 0 AND headcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case - first discount any coatlike clothes --- as these do not affect ability to take off other lower garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not affect ability to take off other lower garments. The 'teddy' --- type garment is expressly NOT included in the exclusion here. --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 and botcover OF THIS <>4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- Now process the manipulated value just as was done for the others --------------------------------------------------------------------- - - - SET tempcovered OF hero TO tempcovered OF hero /2. - IF botcover OF THIS <> 0 AND botcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Depending on the value of 'wear_flag' print and process the obj --- as needed. If 'wear_flag' is NOT 0 then the clothes cannot be --- removed. --------------------------------------------------------------------- - - - IF wear_flag OF hero >0 - THEN - LIST worn. - "Trying to take" SAY THE THIS. "off isn't very sensible." - ELSE - LOCATE THIS IN hero. - "You take off" SAY THE THIS. "." - END IF. -END VERB. - - -END EVERY. - - - --------------------------------------------------------------------- --- These attributes are used internally in the library - ignore! --------------------------------------------------------------------- - -ADD TO EVERY ACTOR - IS tempcovered 0. - IS wear_flag 0. - IS sex 0. -END ADD TO. - - --------------------------------------------------------------------- --- A container used to provide a temporary storage space - ignore! --------------------------------------------------------------------- - -THE tempworn ISA OBJECT - CONTAINER TAKING CLOTHING. - HEADER "You're already wearing" -END THE tempworn. - - - ------------------------------------------------------------------------ --- INSTRUCTIONS FOR USING THE CLOTHING CLASS ------------------------------------------------------------------------ - - --- Here is a quick overview for using the class 'clothing'. - --- A piece of clothing in your game code should look --- something similar to the following four examples: - - --- THE jacket ISA CLOTHING AT lobby --- IS topcover 32. --- END THE. - - --- use IN to refer to containers: - --- THE jeans ISA CLOTHING IN wardrobe --- IS botcover 16. --- END THE. - - --- IN worn = worn by the player character (hero): - --- THE hat ISA CLOTHING IN worn --- IS headcover 2. --- END THE. - - --- worn by an NPC called Joe: - --- THE sweater ISA CLOTHING IN joe_worn - -- Don't declare clothing attributes for NPCs (unless the hero is meant to take - -- and wear the NPC's clothing). - -- NPCs cannot wear clothing in layers! --- END THE. - - --- Define separate containers like the above --- for clothes worn by non-player characters. --- If you defined here 'IN joe', the clothing --- would be listed in Joe's possessions: --- "You see Joe here. Joe is carrying a book and --- a sweater." For a concrete example of how to do --- this, scroll down to the class 'actor'. --- Note also that if the piece of clothing worn --- by an NPC is not meant to be takeable by the --- player character, you should declare the --- the piece of clothing to be NOT takeable. - - --- In defining a piece of clothing, you should --- --- 1) define it ISA CLOTHING (and not: ISA OBJECT) --- --- 2) give it one of five attributes 'headcover', 'topcover', botcover', 'footcover' --- or 'handcover'; sometimes two of these are needed. --- Which attribute(s) to use depends on the type of clothing; see the clothing table below. - --- 3) A number 2, 4, 8, 16, 32 or 64 needs to be added after the above attribute. --- You cannot decide the number yourself; look it up from the clothing table below. --- If the value of an attribute for a piece of clothing is 0 in the table, don't mention --- this attribute in connection with your clothing object. - - --- The above is enough; the rest is then handled automatically by the library. - - --- The quick guide ends here. The clothing table follows right below. The text following the --- table gives more details about the principles and the use of this class. - - --- The clothing table ------------------------ - - --- Here is the chart showing a selection of fairly typical clothing items and the values to --- set to obtain appropriate behaviour. Should you wish to create an article of clothing not --- listed, usually a bit of lateral thought as to what it is most like and where it fits into --- the scheme of things will suggest a workable set of values, but be aware that you MUST use --- values in this chart, simply adding things with intermediate values is probably going to --- create nasty bugs: - - --- Clothing Headcover Topcover Botcover Footcover Handcover - --- hat 2 0 0 0 0 --- vest/bra 0 2 0 0 0 --- undies/panties 0 0 2 0 0 --- teddy 0 4 4 0 0 --- blouse/shirt/T-shirt 0 8 0 0 0 --- dress/coveralls 0 8 32 0 0 --- skirt 0 0 32 0 0 --- trousers/shorts 0 0 16 0 0 --- sweater/pullover 0 16 0 0 0 --- jacket 0 32 0 0 0 --- coat 0 64 64 0 0 --- socks/stockings 0 0 0 2 0 --- tights/pantiehose 0 0 8 2 0 --- shoes/boots 0 0 0 4 0 --- gloves 0 0 0 0 2 - - - - --- ============================================================= - - ------ DEVICE - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY device ISA OBJECT - IS NOT 'on'. - - - VERB examine - DOES - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - - IF THIS IS 'on' - THEN "currently on." - ELSE "currently off." - END IF. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT 'on' - ELSE - IF THIS IS NOT plural - THEN SAY check_device_not_on_sg OF my_game. - ELSE SAY check_device_not_on_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND THIS IS reachable - ELSE - IF THIS IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - AND THIS IS NOT broken - ELSE SAY check_obj_not_broken OF my_game. - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS 'on'. - END VERB. - - - VERB turn_off - CHECK THIS IS 'on' - ELSE - IF THIS IS NOT plural - THEN SAY check_device_on_sg OF my_game. - ELSE SAY check_device_on_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND THIS IS reachable - ELSE - IF THIS IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - END VERB. - - --- The following verb switches a device off if the device is on, and vice versa. - - - VERB switch - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND THIS IS reachable - ELSE - IF THIS IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - AND THIS IS NOT broken - ELSE SAY check_obj_not_broken OF my_game. - DOES ONLY - IF THIS IS 'on' - THEN "You switch off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - ELSE "You switch on" SAY THE THIS. "." - MAKE THIS 'on'. - END IF. - END VERB. - -END EVERY. - - - --- ============================================================= - - ------ DOOR - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY door ISA OBJECT - IS closeable. - IS closed. - IS lockable. - IS NOT locked. - IS NOT takeable. - - HAS matching_key null_key. - - -- If a door is lockable/locked, you should state at the door instance - -- which object will unlock it, with the matching_key attribute. - -- e.g. - - -- THE attic_door ISA DOOR - -- HAS matching_key brass_key. - -- ... - -- END THE. - - -- null_key is a default dummy object which can be ignored. - - VERB examine - DOES - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - - IF THIS IS closed - THEN "currently closed." - ELSE "currently open." - END IF. - END VERB. - - - - VERB knock - DOES ONLY - IF THIS IS closed - THEN "You knock on" SAY THE THIS. "$$. There is no reply." - ELSE "You don't find it purposeful to knock on the open door" - IF THIS IS NOT plural - THEN "." - ELSE "$$s." - END IF. - - END IF. - END VERB. - - - - VERB look_behind - DOES ONLY - IF THIS IS closed - THEN "You cannot look behind" - IF THIS IS NOT plural - THEN "the door - it is closed." - ELSE "the doors - they are closed." - END IF. - ELSE "You notice nothing special behind the door" - IF THIS IS NOT plural - THEN "." - ELSE "$$s." - END IF. - END IF. - END VERB. - - - - VERB look_under - DOES ONLY - IF THIS IS closed - THEN "The gap under the closed door" - IF THIS IS plural - THEN "$$s" - END IF. - "is so narrow that you can't - see anything of what lies on the other side." - ELSE "You notice nothing special under the door" - IF THIS IS plural - THEN "$$s." - ELSE "." - END IF. - END IF. - END VERB. - - -END EVERY. - - -THE null_key ISA OBJECT -END THE. - - --- ============================================================= - - ------ LIGHTSOURCE - - --- ============================================================= - - --- (In the file 'verbs.i', ISA LIGHTSOURCE is used in the syntax definition of the verb 'light'.) - - -EVERY lightsource ISA OBJECT - IS NOT lit. - IS natural. -- A natural lightsource is for example a candle, a match or a torch. - -- A NOT natural lightsource is for example a flashlight or a lamp. - -- You cannot switch on or off a natural lightsource. - - - VERB examine - DOES - IF THIS IS lit - THEN - IF THIS IS natural - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently lit." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently on." - END IF. - ELSE - IF THIS IS natural - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently not lit." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently off." - END IF. - END IF. - END VERB. - - - VERB light - CHECK THIS IS NOT lit - ELSE - IF THIS IS NOT plural - THEN SAY check_lightsource_not_lit_sg OF my_game. - ELSE SAY check_lightsource_not_lit_pl OF my_game. - END IF. - AND THIS IS NOT broken - ELSE SAY check_obj_not_broken OF my_game. - DOES ONLY - IF THIS IS natural - THEN "You light" SAY THE THIS. "." - MAKE THIS lit. - ELSE "You turn on" SAY THE THIS. "." - MAKE THIS lit. - END IF. - END VERB. - - - VERB extinguish - CHECK THIS IS lit - ELSE - IF THIS IS NOT plural - THEN SAY check_lightsource_lit_sg OF my_game. - ELSE SAY check_lightsource_lit_pl OF my_game. - END IF. - DOES ONLY "You extinguish" SAY THE THIS. "." - MAKE THIS NOT lit. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT natural - ELSE - IF THIS IS NOT plural - THEN SAY check_obj_suitable_on_sg OF my_game. - ELSE SAY check_obj_suitable_on_pl OF my_game. - END IF. - AND THIS IS NOT lit - ELSE - IF THIS IS NOT plural - THEN SAY check_lightsource_not_lit_sg OF my_game. - ELSE SAY check_lightsource_not_lit_pl OF my_game. - END IF. - AND THIS IS NOT broken - ELSE SAY check_obj_not_broken OF my_game. - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END VERB. - - - VERB turn_off - CHECK THIS IS NOT natural - ELSE - IF THIS IS NOT plural - THEN SAY check_obj_suitable_off_sg OF my_game. - ELSE SAY check_obj_suitable_off_pl OF my_game. - END IF. - AND THIS IS lit - ELSE - IF THIS IS NOT plural - THEN SAY check_lightsource_lit_sg OF my_game. - ELSE SAY check_lightsource_lit_sg OF my_game. - END IF. - - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT lit. - - END VERB. - - --- The following verb switches a NOT natural lightsource on if it is off, and vice versa --- (when the player forgets, or doesn't bother, to type 'on' or 'off' after 'switch'). - - - VERB switch - CHECK THIS IS NOT natural - ELSE - IF THIS IS NOT plural - THEN SAY check_lightsource_switchable_sg OF my_game. - ELSE SAY check_lightsource_switchable_pl OF my_game. - END IF. - AND THIS IS reachable - ELSE - IF THIS IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - AND THIS IS NOT distant - ELSE - IF THIS IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - AND THIS IS NOT broken - ELSE SAY check_obj_not_broken OF my_game. - DOES ONLY - IF THIS IS lit - THEN "You switch off" SAY THE THIS. "." - MAKE THIS NOT lit. - ELSE "You switch on" SAY THE THIS. "." - MAKE THIS lit. - END IF. - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ LIQUID - - --- ============================================================== - - --- (In the file 'verbs.i', ISA LIQUID is used in the syntax definitions of the verbs 'drink' and 'sip'.) - - -EVERY liquid ISA OBJECT - - CONTAINER - HEADER "In" SAY THE THIS. "you see" - ELSE "There is nothing in" SAY THE THIS. "." - - -- We declare this class a container to enable player commands such as - -- 'throw sack into water', 'look into water' and 'take pearl from water'. - -- Also cases such as 'pour red potion into blue potion' require that this - -- class behaves like a container. - - - HAS vessel null_vessel. - - -- The 'vessel' attribute takes care that if a liquid is - -- in a container, the verb 'take' will automatically take the - -- container instead (if the container is takeable). Trying - -- take a liquid that is in a fixed-in-place container, as well - -- as trying to take a liquid outside any container, will yield - -- "You can't carry [the liquid] around in your bare hands." - -- The default value 'null_vessel' tells the compiler that the liquid - -- is not in any container. null_vessel is a dummy default that can be - -- ignored. - - - - -- If you have some liquid in a container in your game, you should declare the - -- liquid instance thus: - - -- THE juice ISA LIQUID - -- IN bottle - -- HAS vessel bottle. -- i.e. the value of the 'vessel' attribute is the - -- ... -- container the liquid is in - -- END THE juice. - - -- Then, taking and pouring liquids work smoothly. - -- If you don't declare the 'vessel' attribute for the liquid instance, taking a liquid will - -- yield "You can't carry [the liquid] around in your bare hands."; only taking its - -- container will work in that case. - - -- The verb 'pour', as defined in this library, also works for the container of a liquid; - -- i.e. if there is some juice in a bottle, 'pour bottle' and 'pour juice' work equally well. - -- Note, however, that the verb 'empty' is not a synonym for 'pour'; - -- 'empty' only works for container objects. - - - INITIALIZE - SCHEDULE check_vessel AT THIS AFTER 0. -- this event is defined further below - - - VERB examine - DOES ONLY - IF vessel OF THIS <> null_vessel - THEN - IF vessel OF THIS IS NOT closed - THEN "You notice nothing unusual about" SAY THE THIS. - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - -- Here we prohibit the player from examining - -- a liquid when the liquid is in a closed container. - END IF. - ELSE "You notice nothing unusual about" SAY THE THIS. "." - END IF. - END VERB. - - - VERB look_in - DOES ONLY - IF vessel OF THIS <> null_vessel - THEN - IF vessel OF THIS IS NOT closed - THEN "You see nothing special in" SAY THE THIS. "." - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - -- Here we prohibit the player from looking into - -- a liquid when the liquid is in a closed container. - END IF. - ELSE "You see nothing special in" SAY THE THIS. "." - END IF. - END VERB. - - - VERB take - DOES ONLY - IF vessel OF THIS = null_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$nTaken." - END IF. - END VERB. - - - VERB take_from - WHEN obj - DOES ONLY - IF vessel OF THIS = null_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$nTaken." - END IF. - END VERB. - - - VERB drop - DOES ONLY - "($$" SAY THE vessel OF THIS. "$$)$nDropped." - LOCATE vessel OF THIS AT hero. - END VERB. - - - VERB give - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = null_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero - -- i.e. if the implicit taking was successful - THEN - "You give" SAY THE vessel OF THIS. "to" SAY THE recip. "." - LOCATE vessel OF THIS IN recip. - END IF. - - -- there is no 'ELSE' statement in this last IF -clause, as the 'IF THIS NOT - -- IN hero' clause above it takes care of the 'ELSE' alternative. - - END VERB. - - - VERB pour - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = null_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't pour" SAY THE THIS. "anywhere since you are not - carrying" - IF THIS IS NOT plural - THEN "it." - ELSE "them." - END IF. - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero - THEN - "You pour" SAY THE THIS. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - LOCATE THIS AT hero. - SET vessel OF THIS TO null_vessel. - END IF. - - END VERB. - - - VERB pour_in - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = null_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero --i.e. if the implicit taking was successful - THEN - "You pour" SAY THE THIS. "into" SAY THE cont. "." - LOCATE THIS IN cont. - SET vessel OF THIS TO cont. - END IF. - WHEN cont - DOES ONLY - IF vessel OF THIS = null_vessel - THEN - "There's not much sense pouring" SAY THE obj. "into" SAY THE THIS. "." - ELSE - IF vessel OF THIS IS NOT closed - THEN "It wouldn't accomplish anything trying to pour" SAY THE obj. - "into" SAY THE THIS. "." - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - END IF. - END IF. - END VERB. - - - VERB pour_on - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = null_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero - -- i.e. if the implicit taking was successful - THEN - IF surface = floor OR surface = ground - THEN LOCATE THIS AT hero. - "You pour" SAY THE THIS. "on" SAY THE surface. "." - SET vessel OF THIS TO null_vessel. - ELSIF surface ISA SUPPORTER - THEN LOCATE THIS IN surface. - "You pour" SAY THE THIS. "on" SAY THE surface. "." - SET vessel OF THIS TO null_vessel. - ELSE "It wouldn't be sensible to pour anything on" SAY THE surface. - END IF. - END IF. - END VERB. - - - VERB fill_with - -- when something is filled with a liquid, this something becomes the - -- vessel of the liquid - WHEN substance - DOES SET vessel OF THIS TO cont. - END VERB. - - - VERB put_in - WHEN obj - DOES ONLY - IF vessel OF THIS = null_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE - IF vessel OF THIS IS takeable - THEN - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = null_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - LOCATE vessel OF THIS IN cont. - "You put" SAY THE vessel OF THIS. "into" SAY THE cont. "." - - ELSE "You don't have" SAY THE vessel OF THIS. "." - END IF. - END IF. - WHEN cont - DOES ONLY - IF vessel OF THIS = null_vessel - THEN - "There's not much sense putting" SAY THE obj. "into" SAY THE THIS. "." - ELSE - IF vessel OF THIS IS NOT closed - THEN - IF obj = vessel OF THIS - THEN "That doesn't make sense." - ELSE "It wouldn't accomplish anything trying to put" SAY THE obj. - "into" SAY THE vessel OF THIS. "." - END IF. - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - END IF. - END IF. - END VERB. - - - VERB put_on - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = null_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero - -- i.e. if the implicit taking was successful - THEN - IF vessel OF THIS = null_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE - IF vessel OF THIS IS takeable - THEN "You put" SAY THE vessel OF THIS. "onto" SAY THE surface. "." - LOCATE vessel OF THIS IN surface. - ELSE "You can't carry" SAY THE THIS. "around in your bare hands." - END IF. - END IF. - END IF. - WHEN surface - DOES ONLY "It is not possible to $v" SAY obj. "onto" SAY THE THIS. "." - END VERB. - - - -- throwing liquids, whether in containers or not, is disabled: - - - VERB throw - DOES ONLY - "Throwing" SAY THE THIS. "around wouldn't be sensible." - END VERB. - - - VERB throw_at - WHEN projectile - DOES ONLY - "Throwing" - IF vessel OF THIS = null_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "around wouldn't be sensible." - WHEN target - DOES ONLY - IF projectile = vessel OF THIS - THEN "That doesn't make sense." - ELSE "It wouldn't accomplish anything trying to throw" SAY THE projectile. "at" - IF vessel OF THIS = null_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "." - END IF. - END VERB. - - - - VERB throw_to - WHEN projectile - DOES ONLY - "Throwing" - IF vessel OF THIS = null_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "to" SAY THE recipient. "wouldn't be sensible." - WHEN recipient - DOES ONLY - IF projectile = vessel OF THIS - THEN "That doesn't make sense." - ELSE - "Throwing something to" - IF vessel OF THIS = null_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "wouldn't accomplish anything." - END IF. - END VERB. - - - VERB throw_in - WHEN projectile - DOES ONLY - "It wouldn't be sensible throwing" SAY THE THIS. "into" SAY THE cont. "." - WHEN cont - DOES ONLY - IF projectile = vessel OF THIS - THEN "That doesn't make sense." - ELSE "It wouldn't be sensible trying to throw" SAY THE projectile. "in" SAY THE THIS. "." - END IF. - END VERB. - - - - -- The verbs 'empty', 'empty_in' and 'empty_on' will be disabled as ungrammatical with liquids: - - VERB 'empty' - DOES ONLY "You can only empty containers." - END VERB. - - VERB empty_in - WHEN obj - DOES ONLY "You can only empty containers." - END VERB. - - VERB empty_on - WHEN obj - DOES ONLY "You can only empty containers." - END VERB. - - -END EVERY. - - - --- Here is the default vessel for liquids; if the vessel of a liquid is --- 'null_vessel', it means that the liquid is not in any container. - - -THE null_vessel ISA OBJECT - CONTAINER -END THE. - - - --- This event checks that if a liquid is outside a container, its container will --- be 'null_vessel': - - -EVENT check_vessel - FOR EACH liq ISA LIQUID, DIRECTLY AT CURRENT LOCATION DO - SET vessel OF liq TO null_vessel. - END FOR. - SCHEDULE check_vessel AFTER 1. -END EVENT. - - - - --- ============================================================= - - ------ LISTED_CONTAINER - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY LISTED_CONTAINER ISA OBJECT - CONTAINER - - -- (ACTORS are separately defined containers further below.) - - VERB examine - DOES - IF THIS IS closeable - THEN - IF THIS IS closed - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "closed." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "open." - END IF. - END IF. - - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't see inside" SAY THE THIS. "." - END IF. - END VERB. - - - VERB look_in - DOES ONLY - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't, since" SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - END IF. - END VERB. - - --- Note that closed listed_containers are by default opaque and they become not opaque when --- they are opened: - - - VERB open - DOES - MAKE THIS NOT OPAQUE. - LIST THIS. - END VERB. - - - VERB close - DOES - MAKE THIS OPAQUE. - END VERB. - - -END EVERY. - - - - - - --- Tips for using container objects: - - --- 1) - - --- The contents of a normal CONTAINER are not listed when examined --- (you'll need to look *into* the object to see what it contains). --- If you wish to have the contents listed after 'examine' anyway, --- you should --- --- instead of: --- --- THE box ISA OBJECT --- CONTAINER --- ... --- END THE. --- --- do this: --- --- THE box ISA LISTED_CONTAINER --- ... --- END THE. --- --- Then, 'examine' lists the contents of the container. --- --- The contents of a listed_container are also listed when the container --- is opened. This doesn't happen with normal containers. - - --- 2) - - --- For the command 'inventory' to list the contents of a container --- the hero is carrying, go to 'verbs.i', find the command 'inventory' --- and list one by one all relevant containers that the hero might carry, --- thus: --- --- VERB inventory --- DOES LIST hero. --- ... --- IF bag IN hero --- THEN LIST bag. --- END IF. --- --- IF box IN hero --- THEN LIST box. --- END IF. --- ... --- END VERB. --- --- --- If you leave out these additions, the bag and the box will be listed after the --- command 'inventory' in the following way: --- --- "You are carrying a bag and a box." --- --- only. But with the above additions, the outcome is e.g. --- --- "You are carrying a bag and a box. The bag contains a loaf of bread. The box --- is empty." - - --- 3) - - --- To declare a container the contents of which should not be listed after 'look' --- or 'examine', declare it an 'opaque container' in the following way: - - --- THE box ISA OBJECT --- OPAQUE CONTAINER --- ... --- END THE. - - --- or - - --- THE box ISA LISTED_CONTAINER --- OPAQUE CONTAINER --- ... --- END THE. - - --- Objects in an opaque container cannot be seen or manipulated. --- To change this, declare e.g. --- --- MAKE box NOT OPAQUE. --- - - - - --- =============================================================== - - ------ SOUND - - --- =============================================================== - - --- (This class is not cross-referenced in this or any other library file.) - - -EVERY sound ISA OBJECT - IS NOT examinable. - IS NOT takeable. - IS NOT reachable. - IS NOT movable. - - VERB smell - DOES ONLY - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can smell." - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ SUPPORTER - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'climb_on', 'empty_on', 'get_off', 'jump_on', --- 'lie_on', 'pour_on', 'put_in', 'put_on', 'sit_on', 'stand_on', and 'take_from' --- where SUPPORTER is used in either syntax definitions, verb checks --- or verb definitions.) - - -EVERY supporter ISA OBJECT - CONTAINER - HEADER "On" SAY THE THIS. "you see" - ELSE "There's nothing on" SAY THE THIS. "." - - - VERB examine - DOES - LIST THIS. - END VERB. - - - -- in the following, we disable some verbs that are defined to work with normal containers: - - - VERB look_in - DOES ONLY - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look into." - END VERB. - - - VERB empty_in, pour_in - WHEN cont - DOES ONLY - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour things into." - END VERB. - - - VERB put_in - WHEN cont - DOES ONLY "You can't put anything inside" SAY THE THIS. "." - END VERB. - - - VERB throw_in - WHEN cont - DOES ONLY "You can't put anything inside" SAY THE THIS. "." - END VERB. - - -END EVERY. - - - --- To place objects on a supporter, define them in the following way: --- --- Define the supporter first; e.g. --- --- THE tray ISA SUPPORTER --- ... --- END THE. --- --- --- Then, the objects on the supporter: --- --- --- THE apple ISA OBJECT --- IN tray --- ... --- END THE. --- --- Note the IN above, even if the apple will be described as being *on* the tray. --- --- --- THE book ISA OBJECT --- IN table --- ... --- END THE. --- --- --- Note that the 'examine' command will list what is on the surface of a supporter, not what, --- if anything, is inside the supporter. For example, if you have a supporter called 'table' --- in your game with two drawers in it, --- --- DON'T do this: --- --- THE drawer1 ISA OBJECT --- NAME bottom drawer --- CONTAINER --- IN table. --- END THE. --- --- or this: --- --- THE drawer2 ISA LISTED_CONTAINER --- NAME top drawer --- IN table. --- END THE. --- --- This would result in something like --- --- "There's a table here. On the table you see a book, a bottom drawer and a top drawer." --- --- --- Instead, do the following: --- --- THE table ISA SUPPORTER --- AT bedroom --- HAS components {drawer1, drawer2}. --- ... --- VERB examine --- DOES --- FOR EACH c IN components OF THIS DO --- SAY "The table has" SAY AN c. "." --- IF c IS NOT closed --- THEN LIST c. --- ELSE SAY THE c. "is closed." --- END IF. --- END FOR. --- END VERB. --- ... --- END THE. --- --- THE drawer1 ISA LISTED_CONTAINER --- OPAQUE CONTAINER --- NAME bottom drawer --- AT bedroom --- IS closed. --- END THE. --- --- THE drawer2 ISA LISTED_CONTAINER --- NAME top drawer --- AT bedroom --- IS NOT closed. --- END THE. --- --- THE book ISA OBJECT IN table --- ... --- END THE book. --- --- THE diary ISA OBJECT IN drawer2 --- ... --- END THE diary. - - --- In other words, declare the drawers components of the table, in the manner described above. --- The result will then be e.g. something like this: --- --- "You see a table here. There is a book on the table. The table has a bottom drawer. The bottom drawer --- is closed. The table has a top drawer. The top drawer contains a diary." - - - - --- ============================================================== - - ------ WEAPON - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'attack_with', 'fire', --- 'fire_with', 'kill_with', 'shoot' and 'shoot_with' where WEAPON is used --- either in the syntax definitions or verb checks.) - - -EVERY weapon ISA OBJECT - IS NOT fireable. -END EVERY. - - - - --- ============================================================== - - ------ WINDOW - - --- ============================================================== - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - --- You can look out of and through a window. --- When examined, a window is automatically described as being either open or closed. - - -EVERY window ISA OBJECT - IS closeable. - IS closed. - IS NOT takeable. - - - VERB examine - DOES - IF THIS IS closed - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently closed." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently open." - END IF. - END VERB. - - - VERB look_behind - DOES ONLY - "That's not possible." - END VERB. - - - VERB look_out_of - DOES ONLY "You see nothing special looking out of the" - IF THIS IS NOT plural - THEN "window." - ELSE "windows." - END IF. - END VERB. - - - VERB look_through - DOES ONLY "You see nothing special looking through the" - IF THIS IS NOT plural - THEN "window." - ELSE "windows." - END IF. - END VERB. - - -END EVERY. - - - --- =============================================================== - --- =============================================================== --- --- 2. Actors --- --- =============================================================== - --- =============================================================== - - --- First, we declare some common characteristics for all actors: - - -ADD TO EVERY ACTOR - IS NOT inanimate. - IS NOT following. - IS NOT sitting. - IS NOT lying_down. - IS NOT named. - -- = the actor's name is not known to the player; see also - -- the example below - - -- Important: if you don't need an article in front of an actor name (e.g. 'Jim', - -- as opposed to e.g. 'a/the man'), declare the instance as 'named': - - -- THE jim ISA ACTOR - -- IS named. - -- ... - -- END THE. - - -- (Remember also that all actors 'CAN NOT talk' by default. If you want the actor to be able - -- to talk, give it the attribute 'CAN talk' or declare it ISA PERSON (see further below)) - - DEFINITE ARTICLE - IF THIS IS NOT named - THEN "the" - ELSE "" - END IF. - - INDEFINITE ARTICLE - IF THIS IS NOT named - THEN - IF THIS IS NOT plural - THEN "a" - ELSE "" - END IF. - ELSE "" - END IF. - - -- if you need "an", you must declare it separately at the actor instance - - CONTAINER - -- so that actors can receive and carry objects - - INITIALIZE - -- all actors will obey this script from the start of the game - - IF THIS <> hero - THEN USE SCRIPT following_hero FOR THIS. - END IF. - - SCRIPT following_hero - -- this code will make any actor follow the hero - -- if the actor is given the attribute 'following'. - STEP WAIT UNTIL hero NOT HERE - - IF THIS IS following - THEN - LOCATE THIS AT hero. - "$p" SAY THE THIS. - IF THIS IS NOT plural - THEN "follows you." - ELSE "follow you." - END IF. - END IF. - - USE SCRIPT following_hero FOR THIS. - - - DESCRIPTION - IF THIS IS NOT named - THEN - IF THIS IS NOT plural - THEN "There is" SAY AN THIS. "here." - ELSE "There are" SAY THIS. "here." - END IF. - ELSE SAY THIS. - IF THIS IS NOT plural - THEN "is here." - ELSE "are here." - END IF. - END IF. - - - - VERB examine - DOES - IF COUNT ISA THING, IN THIS > 0 - THEN LIST THIS. - END IF. - - - END VERB. - - -- The above if-statement will make a description of an - -- actor's possessions show up every time the actor is examined. - -- Note that this doesn't apply to the hero which is defined - -- separately further below.-- This listing will be overridden if you define an - -- individual response to the actor instance being examined using DOES ONLY. - -- If your still want to list the possessions of the actor after your own 'examine' - -- response, you should state 'LIST [actor].' in the 'examine' verb there. - -END ADD TO. - - --- In order that clothing worn by an NPC is described after 'look' and --- 'examine' we need the following code. See the instructions right after it. - - - -EVERY npc_worn ISA THING - HAS carrier null_carrier. - -- The value of the 'carrier' attribute is the actor wearing the clothing. - -- Here, 'null_carrier' is a dummy default instance that can be ignored. - - - CONTAINER TAKING CLOTHING. - HEADER SAY THE carrier OF THIS. "is wearing" - ELSE "" - - DESCRIPTION "" - -- we don't want this container to appear in room descriptions - - INITIALIZE - LOCATE THIS AT carrier OF THIS. - SCHEDULE check_npc_worn AT THIS AFTER 0. - -END EVERY. - - - -EVENT check_npc_worn - FOR EACH npcw ISA npc_worn DO - IF npcw NOT AT carrier OF npcw - THEN LOCATE npcw AT carrier OF npcw. - END IF. - END FOR. - SCHEDULE check_npc_worn AFTER 1. -END EVENT. - - -THE null_carrier ISA ACTOR - -- a dummy default instance, ignore. -END THE. - - - --- To describe what an NPC is wearing (after the commands 'look and 'examine'), define the NPC e.g. like this: - - --- THE mr_smith ISA ACTOR --- DESCRIPTION --- "blah blah" LIST mr_smith_worn. - -- Leave this LIST statement out if you don't want to - -- have the actor's clothing listed after 'look'. - --- VERB examine --- DOES ONLY "blah blah" --- (LIST mr_smith.) - -- This lists what Mr Smith is carrying. --- LIST mr_smith_worn. - -- this lists what Mr Smith is wearing. --- END VERB. --- --- END THE. - - --- THE mr_smith_worn ISA NPC_WORN - -- All containers for clothing worn by NPCs should be declared ISA NPC_WORN. --- HAS carrier mr_smith. - -- The value of the 'carrier' attribute is the actor wearing the clothes. --- END THE. - - --- THE bowler_hat ISA CLOTHING IN mr_smith_worn - -- don't declare the clothing attributes (e.g. "IS headcover 2.") for NPCs - NPCs cannot - -- wear clothing in layers! --- END THE. - - --- Note that if you don't want the player character to be able to take a piece of clothing --- worn by another character, you should declare the piece of clothing NOT takeable! - - ------------------------------------------- - - --- To make an actor follow the hero, give it the 'following' attribute, e.g.: --- --- THE bob ISA ACTOR --- ... --- VERB whatever --- DOES MAKE bob following. --- END VERB. --- .... --- --- END THE bob. --- --- etc. - - --- If you wish to have an actor follow the hero right from the start of the game, --- you can naturally just declare --- --- THE servant ISA ACTOR --- IS following. --- ... --- END THE. --- --- - --- To stop an actor from following the hero, just make the actor NOT following. - - --------------------------------------------- - - --- Tip: if you have in your game an actor that starts off as unnamed (such as 'a man'), --- and the player learns his name later on (say, 'Jim'), you should define the actor in --- e.g. the following way to make the player able to refer to him with --- both 'man' and 'Jim': - --- THE jim ISA PERSON --- NAME man NAME jim --- PRONOUN him --- MENTIONED --- IF jim IS NOT named -- By default, all actors are 'NOT named'. --- THEN "man" --- ELSE "Jim" --- END IF. --- .. --- VERB ask --- WHEN act --- IF topic = name --- THEN """My name is Jim"", he replies." --- MAKE jim named. --- END IF. --- END VERB. --- --- END THE. - --- The 'named' attribute is meant to be used in cases like this. The indefinite and definite --- articles don't have to be declared here, as their behavior has been declared in the --- general actor class above. - - - --- ================================================================ - - ------ PERSON -- CAN talk - - --- ================================================================ - - -EVERY person ISA ACTOR - CAN talk. -END EVERY. - - - --- ================================================================ - - ------ FEMALE and MALE - - --- ================================================================ - - --- MALE and FEMALE are actually subclasses of PERSON, and so they both --- have the ability to talk. - - -EVERY female ISA PERSON - PRONOUN her -END EVERY. - - -EVERY male ISA PERSON - PRONOUN him -END EVERY. - - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newdefinitions.i b/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newdefinitions.i deleted file mode 100644 index 2bbacde..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newdefinitions.i +++ /dev/null @@ -1,724 +0,0 @@ --- ALAN Standard Library 1.10 --- Definitions (file name: 'definitions.i') - --- Included in this file: - -- general attributes - -- some article declarations - -- common synonyms - -- the definition_block class - -- attributes for the start section - -- messages for the hero - -- verb check messages - -- illegal parameter messages, used in SYNTAX definitions of verbs - -- implicit taking message - -- the start_section instance - -- the hero instance (the player character; "me") - - - --- General attributes --- ================== - --- We define general attributes for every thing ( = object or actor): - - -ADD TO EVERY THING - - IS examinable. - inanimate. - movable. - reachable. - -- See also 'distant' below - takeable. - - HAS matching_key null_key. - -- All lockable objects need a matching key to lock/unlock them. - -- "null_key" is a default dummy that can be ignored. - HAS text "". - - NOT broken. - NOT closeable. - NOT closed. - NOT distant. - -- Usage: you can e.g. talk to a "not reachable" actor but not to a "distant" one. - -- You can also throw things to or at a not reachable target but not to a distant one. - -- Default response for not reachable things: "The [thing] is out of your reach." - -- Default response for distant things: "The [thing] is too far away." - NOT drinkable. - NOT edible. - NOT fireable. - -- can be used as a firearm - NOT lockable. - NOT locked. - NOT readable. - NOT scenery. - -- Has special responses for 'examine' and 'take', behaves normally otherwise. - NOT wearable. - NOT writeable. - - CAN NOT talk. - - --- We still define that plural nouns are preceded by "some" (and not "a" or "an"): - - INDEFINITE ARTICLE - IF THIS IS plural - THEN "some" - ELSE "a" - END IF. - -END ADD TO. - - --- If you need "an", you should declare it separately at the instance, e.g.: - --- THE owl ISA ACTOR --- AT woods --- INDEFINITE ARTICLE "an" --- END THE. - - --- (We add the 'plural' attribute to the 'entity' class, because the plural --- applies not only to things but also to e.g. parameters in syntax statements; ignore.) - - -ADD TO EVERY ENTITY - IS NOT plural. -END ADD TO. - - --- Some weight attributes for things: - - -ADD TO EVERY THING - IS weight 0. -END ADD TO THING. - - -ADD TO EVERY ACTOR - IS weight 50. -END ADD TO ACTOR. - - -ADD TO EVERY OBJECT - IS weight 5. -END ADD TO OBJECT. - - - --- Common synonyms --- =============== - - --- Next, we declare synonyms for some words so that it will be possible --- for the player to type commands such as both "put ball in box" and --- "put ball into box", etc: - - -SYNONYMS - -into, inside = 'in'. -onto = on. -thru = through. -using = 'with'. - - - - --- Attributes for the my_game definition block --- =========================================== - --- Here, we create a class, "definition_block", to group various definitions under. --- In the game source file, the author should declare an instance 'my_game' which belongs --- to this class. - - - -EVERY definition_block ISA LOCATION - - - -- attributes for the start section: - -- ================================= - - HAS title "My New Game". - HAS subtitle "". - HAS author "An ALAN Author". - HAS year 2014. - HAS version 1. - - HAS intro_text "". - - - -- messages for the hero: - -- ====================== - - HAS hero_desc "". - HAS hero_cont_header "You are carrying". - HAS hero_cont_header_dark "Although you cannot see your belongings in the dark, - you recall that you're carrying". - HAS hero_cont_else "You are empty-handed.". - - HAS hero_worn_header "You are wearing". - HAS hero_worn_else "You're not wearing anything.". - - - -- description message for dark locations: - -- ======================================= - - HAS dark_loc_desc "It is pitch black. You can't see anything at all.". - - - - -- all illegal parameter messages, typically found in the ELSE parts of SYNTAX structures and - -- the first two below being by far the most common. - -- ========================================================================================== - - - -- the general message for when a parameter is not suitable with the verb: - -------------------------------------------------------------------------- - - HAS illegal_parameter_sg "That's not something you can $v.". -- (numerous) - HAS illegal_parameter_pl "Those are not something you can $v.". - - - -- variations of the above message when a preposition is required after the verb: - --------------------------------------------------------------------------------- - - HAS illegal_parameter_about_sg "That's not something you can $v about.". -- ask_about, consult_about, tell_about, think_about - HAS illegal_parameter_about_pl "Those are not something you can $v about.". - HAS illegal_parameter_at_sg "That's not something you can $v at.". -- fire_at - HAS illegal_parameter_at_pl "Those are not something you can $v at.". - HAS illegal_parameter2_at_sg "That's not something you can $v things at.". -- throw_at - HAS illegal_parameter2_at_pl "Those are not something you can $v things at.". - HAS illegal_parameter_for_sg "That's not something you can $v for.". -- ask_for - HAS illegal_parameter_for_pl "Those are not something you can $v for.". - HAS illegal_parameter2_from_sg "That's not something you can take things from.". -- take_from - HAS illegal_parameter2_from_pl "Those are not something you can take things from.". - HAS illegal_parameter_in_sg "That's not something you can $v in.". -- dive_in, jump_in, lie_in - HAS illegal_parameter_in_pl "Those are not something you can $v in.". - HAS illegal_parameter_on_sg "That's not something you can $v on.". -- climb_on, knock, lie_on, switch_on, turn_on - HAS illegal_parameter_on_pl "Those are not something you can $v on.". - HAS illegal_parameter_off_sg "That's not something you can $v off.". -- get_off, switch_off, turn_off - HAS illegal_parameter_off_pl "Those are not something you can $v off.". - HAS illegal_parameter_to_sg "That's not something you can $v to.". -- listen_to, talk_to - HAS illegal_parameter_to_pl "Those are not something you can $v to.". - HAS illegal_parameter2_to_sg "That's not something you can $v things to.". -- give, show, tell, tie_to, throw_to - HAS illegal_parameter2_to_pl "Those are not something you can $v things to.". - HAS illegal_parameter_with_sg "That's not something you can $v with.". -- kill_with, shoot_with, play_with - HAS illegal_parameter_with_pl "Those are not something you can $v with.". - HAS illegal_parameter2_with_sg "That's not something you can $v things with.". -- attack_with, break_with, burn_with, close_with, - -- + cut_with, fill_with, lock_with, open_with, pry_with, - -- + push_with, unlock_with - HAS illegal_parameter2_with_pl "Those are not something you can $v things with.". - - - -- other illegal parameter messages: - ------------------------------------ - - HAS illegal_parameter_examine_sg "That's not something you can examine.". -- examine - HAS illegal_parameter_examine_pl "Those are not something you can examine.". - - HAS illegal_parameter_look_out_sg "That's not something you can look out of.". -- look_out_of - HAS illegal_parameter_look_out_pl "Those are not something you can look out of.". - HAS illegal_parameter_look_through "You can't look through $+1.". -- look_through - - HAS illegal_parameter_obj "You can only $v objects.". -- give, put, use, use_with - - HAS illegal_parameter_string "Please state inside double quotes ("""") what you want to $v.". -- answer, say, write - - HAS illegal_parameter_talk_sg "That's not something you can talk to.". -- ask, ask_for, say_to, tell - HAS illegal_parameter_talk_pl "Those are not something you can talk to.". - - HAS illegal_parameter_there "It's not possible to $v there.". -- look_behind, look_under, go - HAS illegal_parameter2_there "It's not possible to $v anything there.". -- empty_in, empty_on, pour_in, pour_on, put_in, - -- + put_on, put_against, put_behind, put_near, - -- + put_under, throw_in, write - - HAS illegal_parameter_what_sg "That's not something I know about.". -- what_is, where_is - HAS illegal_parameter_what_pl "Those are not something I know about.". -- what_is, where_is - HAS illegal_parameter_who_sg "That's not somebody I know about.". -- who_is - HAS illegal_parameter_who_pl "Those are not somebody I know about.". -- who_is - - - -- verb check messages, found before DOES sections of verbs and used mainly in verbs.i: - -- ==================================================================================== - - - -- a) attribute checks - ---------------------- - - - -- the general check message for when an instance cannot be used with the verb : - -------------------------------------------------------------------------------- - - HAS check_obj_suitable_sg "That's not something you can $v.". -- (numerous) - HAS check_obj_suitable_pl "Those are not something you can $v.". - - - -- variations of the above message, needed e.g. when a preposition is required after the verb: - ---------------------------------------------------------------------------------------------- - - HAS check_obj_suitable_at_sg "That's not something you can $v at.". -- fire_at - HAS check_obj_suitable_at_pl "Those are not something you can $v at.". - HAS check_obj2_suitable_at_sg "That's not something you can $v things at.". -- throw_at - HAS check_obj2_suitable_at_pl "Those are not something you can $v things at.". - HAS check_obj2_suitable_for_sg "That's not something you can $v for.". -- ask_for - HAS check_obj2_suitable_for_pl "Those are not something you can $v for.". - HAS check_obj_suitable_off_sg "That's not something you can $v off.". -- turn_off, switch_off - HAS check_obj_suitable_off_pl "Those are not something you can $v off.". - HAS check_obj_suitable_on_sg "That's not something you can $v on.". -- knock, switch_on, turn_on - HAS check_obj_suitable_on_pl "Those are not something you can $v on." . - HAS check_obj_suitable_with_sg "That's not something you can $v with.". -- play_with - HAS check_obj_suitable_with_pl "Those are not something you can $v with.". - HAS check_obj2_suitable_with_sg "That's not something you can $v things with.". -- break_with, burn_with, cut_with, fill_with, - HAS check_obj2_suitable_with_pl "Those are not something you can $v things with.". -- + lock_with, open_with, pry_with, push_with, - -- + unlock_with - - HAS check_obj_suitable_examine_sg "That's not something you can examine.". -- examine - HAS check_obj_suitable_examine_pl "Those are not something you can examine.". -- examine - - HAS check_obj_suitable_look_out_sg "That's not something you can look out of.". -- look_out_of - HAS check_obj_suitable_look_out_pl "Those are not something you can look out of.". - HAS check_obj_suitable_look_through "You can't look through $+1.". -- look_through - - - -- checks for open, closed and locked objects: - ---------------------------------------------- - - HAS check_obj_closed_sg "$+1 is already open.". -- open, open_with - HAS check_obj_closed_pl "$+1 are already open.". - HAS check_obj_not_closed1_sg "$+1 is already closed.". -- close, close_with - HAS check_obj_not_closed1_pl "$+1 are already closed.". - HAS check_obj_not_closed2_sg "You can't, since $+1 is closed.". -- empty, empty (in/on), look_in, pour (in/on) - HAS check_obj_not_closed2_pl "You can't, since $+1 are closed.". - HAS check_obj2_not_closed_sg "You can't, since $+2 is closed.". -- empty_in, pour_in, put_in, take_from, throw_in - HAS check_obj2_not_closed_pl "You can't, since $+2 are closed.". - HAS check_obj_locked_sg "$+1 is already unlocked.". -- unlock, unlock_with - HAS check_obj_locked_pl "$+1 are already unlocked.". - HAS check_obj_not_locked1_sg "$+1 is already locked.". -- lock, lock_with - HAS check_obj_not_locked1_pl "$+1 are already locked.". - HAS check_obj_not_locked2_sg "$+1 appears to be locked.". -- open, open_with - HAS check_obj_not_locked2_pl "$+1 appear to be locked.". - - - -- checks for "not reachable" and "distant" objects: - ---------------------------------------------------- - - HAS check_obj_reachable_sg "$+1 is out of your reach.". -- (numerous) - HAS check_obj_reachable_pl "$+1 are out of your reach.". - HAS check_obj2_reachable_sg "$+2 is out of your reach.". -- fill_with, put_in, tie_to - HAS check_obj2_reachable_pl "$+2 are out of your reach.". - HAS check_obj_reachable_ask "$+1 can't reach $+2.". -- ask_for - HAS check_obj_not_distant_sg "$+1 is too far away.". -- (numerous) - HAS check_obj_not_distant_pl "$+1 are too far away.". - HAS check_obj2_not_distant_sg "$+2 is too far away.". -- empty_in, pour_in, put_in, throw_at, throw_in, throw_to - HAS check_obj2_not_distant_pl "$+2 are too far away.". - - - -- checks for the hero sitting or lying_down: - --------------------------------------------- - - HAS check_hero_not_sitting1 "It is difficult to $v while sitting down.". -- (with many intransitive verbs) - HAS check_hero_not_sitting2 "It is difficult to $v anything while sitting down.". -- (with many transitive verbs) - HAS check_hero_not_sitting3 "It is difficult to $v anywhere while sitting down.". -- (with many verbs of motion) - HAS check_hero_not_sitting4 "You're sitting down already.". -- sit, sit_on - HAS check_hero_not_lying_down1 "It is difficult to $v while lying down.". -- (with many intranstive verbs) - HAS check_hero_not_lying_down2 "It is difficult to $v anything while lying down.". -- (with many transitive verbs) - HAS check_hero_not_lying_down3 "It is difficult to $v anywhere while lying down.". -- (with many verbs of motion) - HAS check_hero_not_lying_down4 "You're lying down already.". -- lie_down, lie_in - - - -- other attribute checks: - -------------------------- - - HAS check_act_can_talk_sg "That's not something you can talk to.". -- ask, ask_for, say_to, tell - HAS check_act_can_talk_pl "Those are not something you can talk to.". - - HAS check_obj_broken_sg "That doesn't need fixing.". -- fix - HAS check_obj_broken_pl "Those don't need fixing.". - - HAS check_obj_inanimate1 "$+1 wouldn't probably appreciate that.". -- push, push_with, scratch, search - HAS check_obj_inanimate2 "You are not sure whether $+1 would appreciate that.". -- rub, touch, touch_with - - HAS check_obj_movable "It's not possible to $v $+1.". -- lift, pull, push - - HAS check_obj_not_scenery "Unimportant for your purposes, you decide to leave $+1 be.". -- examine, take, take_from - - HAS check_obj_suitable_there "It's not possible to $v there.". -- go, look_behind, look_under - HAS check_obj2_suitable_there "It's not possible to $v anything there.". -- tie_to - - HAS check_obj_takeable "You don't have $+1.". -- (numerous; this check is in verbs with implicit taking) - HAS check_obj2_takeable "You don't have $+2.". -- fill_with - - HAS check_obj_weight_sg "$+1 is too heavy to $v.". -- lift, take, take_from - HAS check_obj_weight_pl "$+1 are too heavy to $v.". - - HAS check_obj_writeable "Nothing can be written there.". -- write - - - -- b) location and containment checks for actors and objects - ------------------------------------------------------------ - - - -- containment checks for actors other than the hero (checks for the hero are listed separately below): - ---------------------------------------------------------------------------------------------- - - HAS check_act_near_hero "You don't quite know where $+1 went. -- follow - You should state direction where you want to go.". - - HAS check_obj_in_act_sg "$+1 doesn't have $+2.". -- take_from - HAS check_obj_in_act_pl "$+1 don't have $+2.". - HAS check_obj_not_in_act_sg "$+2 already has $+1.". -- give - HAS check_obj_not_in_act_pl "$+2 already have $+1.". - - - -- location and containment checks for the hero: - ------------------------------------------------ - - HAS check_count_obj_in_cont "There is nothing in $+1.". -- empty, empty_in, empty_on, pour, pour_in, pour_on - HAS check_count_weapon_in_act "You are not carrying any firearms.". -- shoot - - HAS check_hero_in_cont "But you aren't in $+1 at present.". -- exit - HAS check_hero_not_in_cont "But you are already in $+1!". -- enter - - - - HAS check_obj_not_at_hero_sg "$+1 is right here.". -- find, follow, go_to - HAS check_obj_not_at_hero_pl "$+1 are right here.". - HAS check_obj_in_hero "You don't have the $+1.". -- fire, put - HAS check_obj2_in_hero "You don't have the $+2.". -- (numerous) - HAS check_obj_not_in_hero1 "It doesn't make sense to $v something you're holding.". -- e.g. attack, shoot - HAS check_obj_not_in_hero2 "You already have $+1.". -- ask_for, take, take_from - HAS check_obj2_not_in_hero1 "You are carrying $+2.". -- e.g. throw_at, throw_to - HAS check_obj2_not_in_hero2 "That would be futile.". -- put_against, put_behind, put_near, put_under - - - -- checking whether an object is in a container or not: - ------------------------------------------------------- - - HAS check_obj_in_cont_sg "$+1 is not in $+2.". -- take_from - HAS check_obj_in_cont_pl "$+1 are not in $+2.". - HAS check_obj_not_in_cont_sg "The $+1 is in $+2 already.". -- put_in, throw_in - HAS check_obj_not_in_cont_pl "The $+1 are in $+2 already.". - HAS check_obj_not_in_cont2_sg "The $+1 is already full of $+2.". -- fill_with - HAS check_obj_not_in_cont2_pl "The $+1 is already full of $+2.". - - - -- checking whether an object is on a surface or not: - ----------------------------------------------------- - - HAS check_obj_on_surface_sg "$+1 is not on $+2.". -- take_from - HAS check_obj_on_surface_pl "$+1 are not on $+2.". - HAS check_obj_not_on_surface_sg "$+1 is already on $+2.". -- empty_on, pour_on, put_on - HAS check_obj_not_on_surface_pl "$+1 are already on $+2.". - - - -- checking whether an object is worn or not: - --------------------------------------------- - - HAS check_obj_in_worn "You are not wearing $+1.". -- e.g. take_off - HAS check_obj_not_in_worn1 "You are already wearing $+1.". -- e.g. put_on, wear - HAS check_obj_not_in_worn2 "It doesn't make sense to $v something you're wearing.". -- e.g. attack, shoot - HAS check_obj_not_in_worn3_sg "You take off $+1 and carry it in your hands.". -- remove, take - HAS check_obj_not_in_worn3_pl "You take off $+1 and carry them in your hands.". - - - -- c) checking location states - ------------------------------ - - HAS check_current_loc_lit "It is too dark to see.". -- (numerous) - - - -- d) logical checks - -------------------- - - HAS check_obj_not_hero1 "It doesn't make sense to $v yourself.". - HAS check_obj_not_hero2 "There is no need to be that desperate.". -- fire_at, kill, kill_with, shoot, shoot_with - HAS check_obj_not_hero3 "That wouldn't accomplish anything.". -- scratch, touch - HAS check_obj_not_hero4 "You're right here.". -- find, go_to - HAS check_obj_not_hero5 "You don't have to be freed.". -- free - HAS check_obj_not_hero6 "There is no time for that now.". -- kiss, rub, play_with - HAS check_obj_not_hero7 "Turning your head, you notice nothing unusual behind yourself.". -- look_behind - HAS check_obj_not_hero8 "You notice nothing unusual under yourself.". -- look_under - HAS check_obj_not_hero9 "You can't tie yourself to anything.". -- tie_to - HAS check_obj2_not_hero1 "That doesn't make sense.". - HAS check_obj2_not_hero2 "That would be futile.". -- put_against, put_behind, put_near, put_under - HAS check_obj2_not_hero3 "You can't $v things to yourself.". -- give, show, tie_to - - HAS check_obj_not_obj2_at "It doesn't make sense to $v something at itself.". -- fire_at, throw_at - HAS check_obj_not_obj2_from "It doesn't make sense to $v something from itself.". -- take_from - HAS check_obj_not_obj2_in "It doesn't make sense to $v something into itself.". -- empty_in, pour_in, put_in, throw_in - HAS check_obj_not_obj2_on "It doesn't make sense to $v something onto itself.". -- empty_on, pour_on - HAS check_obj_not_obj2_to "It doesn't make sense to $v something to itself.". -- throw_to, tie_to - HAS check_obj_not_obj2_with "It doesn't make sense to $v something with itself.". -- close_with, cut_with, fill_with lock_with, - -- + open_with, push_with, touch_with, - -- + unlock_with - - HAS check_obj_not_obj2_put "That doesn't make sense." . -- put_against, put_behind, put_near, put_under - - - -- e) additional checks for classes: - ------------------------------------ - - HAS check_clothing_sex "On second thoughts you decide $+1 won't really suit you.". -- clothing: wear - HAS check_cont_not_supporter "You can't put $+1 inside $+2.". -- supporter: put_in - HAS check_device_on_sg "$+1 is already off.". -- device: turn_off, switch_off - HAS check_device_on_pl "$+1 are already off.". - HAS check_device_not_on_sg "$+1 is already on.". -- device: turn_on, switch_on - HAS check_device_not_on_pl "$+1 are already on.". - HAS check_door_matching_key "You can't use $+2 to $v $+1.". -- door: lock_with, unlock_with - HAS check_lightsource_lit_sg "But $+1 is not lit.". -- lightsource: extinguish, turn_off - HAS check_lightsource_lit_pl "But $+1 are not lit.". - HAS check_lightsource_not_lit_sg "$+1 is already lit.". -- lightsource: light, turn_on - HAS check_lightsource_not_lit_pl "$+1 are already lit.". - HAS check_lightsource_switchable_sg "That's not something you can switch on and off." . -- lightsource: switch - HAS check_lightsource_switchable_pl "Those are not something you can switch on and off.". - HAS check_obj_not_broken "Nothing happens.". -- device, lightsource: light, turn_on - - - -- messages for implicit taking: - -- ============================= - - HAS implicit_taking_message "(taking $+1 first)$n". - - -- The following verbs are preceded by implicit taking: - -- bite, drink, eat, empty, empty_in, empty_on, give, pour, pour_in, pour_on, - -- put_in, put_on, throw, throw_at, throw_in, throw_to, tie_to. - -- In ditransitive verbs, only the first parameter (the direct object) is taken implicitly. - - -END EVERY. - - - - --- The start section: --- ================== - - -THE start_section ISA definition_block - - DESCRIPTION - SAY intro_text OF my_game. - - "$p" STYLE alert. SAY title OF my_game. STYLE normal. - - IF subtitle OF my_game = "" - THEN "$$" - ELSE "$n" SAY subtitle OF my_game. - END IF. - - "$n(C)" SAY year OF my_game. "by" SAY author OF my_game. - - "$nProgrammed with the ALAN Interactive Fiction Language v3.0" - - IF version OF my_game <> 0 - THEN "$nVersion" SAY version OF my_game. - END IF. - - "$nAll rights reserved." - -END THE start_section. - - - --- The my_game instance defined as a meta-location (ignore): --- ========================================================= - - -ADD TO EVERY LOCATION - HAS sections {my_game}. - - INITIALIZE - EXCLUDE my_game FROM sections OF THIS. - - - FOR EACH l ISA LOCATION - DO - IF l <> my_game - THEN LOCATE l AT my_game. - END IF. - END FOR. - - FOR EACH r1 ISA ROOM - DO - LOCATE r1 AT indoor. - END FOR. - - FOR EACH s1 ISA SITE - DO - LOCATE s1 AT outdoor. - END FOR. - - FOR EACH l ISA LOCATION DO - IF sections OF l <> {} AND l <> my_game - THEN - FOR EACH s IN sections OF l - DO - IF l <> my_game AND s <> my_game - THEN LOCATE s AT l. - END IF. - END FOR. - END IF. - END FOR. - - - - -END ADD TO. - - - --- All default runtime messages are listed below: --- ============================================== - - -MESSAGE - AFTER_BUT: "You must give at least one object after '$1'." - AGAIN: "" - BUT_ALL: "You can only use '$1' AFTER '$2'." - CAN_NOT_CONTAIN: "$+1 can not contain $+2." - CANT0: "You can't do that." - -- note that the fifth token in CANT0 is a zero, not an 'o'. - CARRIES: "$+1 carries" - 'CONTAINS': "$+1 contains" - CONTAINS_COMMA: "$01," - CONTAINS_AND: "$01 and" - CONTAINS_END: "$01." - EMPTY_HANDED: "$+1 is empty-handed." - HAVE_SCORED: "You have scored $1 points out of $2." - IMPOSSIBLE_WITH: "That's impossible with $+1." - IS_EMPTY: "$+1 is empty." - MORE: "" - MULTIPLE: "You can't refer to multiple objects with '$v'." - NO_SUCH: "I can't see any $1 here." - NO_WAY: "You can't go that way." - NOT_MUCH: "That doesn't leave much to $v!" - NOUN: "You must supply a noun." - NOT_A_SAVEFILE: "That file does not seem to be an Alan game save file." - QUIT_ACTION: "Do you want to RESTART, RESTORE, QUIT or UNDO? " - -- these four alternatives are hardwired to the interpreter and cannot be changed. - REALLY: "Are you sure (RETURN confirms)?" - RESTORE_FROM: "Enter file name to restore from" - SAVE_FAILED: "Sorry, save failed." - SAVE_MISSING: "Sorry, could not open the save file." - SAVE_NAME: "Sorry, the save file did not contain a save for this adventure." - SAVE_OVERWRITE: "That file already exists, overwrite (y)?" - SAVE_VERSION: "Sorry, the save file was created by a different version." - SAVE_WHERE: "Enter file name to save in" - SEE_START: - IF parameter1 IS NOT plural - THEN "There is $01" - ELSE "There are $01" - END IF. - SEE_COMMA: ", $01" - SEE_AND: "and $01" - SEE_END: "here." - NO_UNDO: "No further undo available." - UNDONE: "'$1' undone." - UNKNOWN_WORD: "I don't know the word '$1'." - WHAT: "I don't understand." - WHAT_WORD: "I don't know what you mean by '$1'." - WHICH_PRONOUN_START: "I don't know if you by '$1'" - WHICH_PRONOUN_FIRST: "mean $+1" - WHICH_START: "I don't know if you mean $+1" - WHICH_COMMA: ", $+1" - WHICH_OR: "or $+1." - - --- The messages above follow the default formulations given in the manual, except for --- AGAIN for which the original default is "(again)", and for --- SEE_START for which the original default is "There is $01" (no plural formulation given). - - --- The default messages are automatically translated into German or Swedish in your game --- if you define in the beginning of your source code --- --- OPTIONS --- LANGUAGE German. --- --- or --- --- OPTIONS --- LANGUAGE Swedish. --- --- Only the exact equivalents of the default phrases will then be shown; if you change --- the above messages to your own wordings, the translations will still be only for the default. --- --- If you wish to write your game in some other language, you must manually translate --- the messages above. There might be support for more languages in the future, depending --- on demand. - - - - --- The hero --- ======== - - -THE hero ISA ACTOR - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" - MENTIONED "yourself" - PRONOUN '' - -- to disable 'it' from referring to 'me'. - CAN talk. - IS NOT sitting. - IS NOT lying_down. - - ------------------------------------ - - -- These three attributes, as well as the 'schedule' statement following them, - -- are needed for the 'notify' command ('verbs.i'); ignore. - - HAS oldscore 0. - -- Records previous score so 'checkscore' event - -- can compare with the current score - IS notify_on. - -- Set by 'notify' verb, records whether - -- player wants to see score messages or not. - IS NOT seen_notify. - -- Records whether player has seen the notify verb - -- instructions yet. - - INITIALIZE - SCHEDULE check_score AT hero AFTER 0. - - ------------------------------------ - - - CONTAINER - - LIMITS - -- Remove this whole LIMITS section if you - -- wish to have no limits to how much the hero can carry. - - COUNT 10 Then - "You can't carry anything more. You have to drop something - first." - WEIGHT 50 Then - "You can't carry anything more. You have to drop something - first." - - HEADER - IF CURRENT LOCATION IS NOT lit - THEN "Although you cannot see your belongings in the dark, you - remember that you're carrying" - ELSE "You are carrying" - END IF. - ELSE - "You are empty-handed." - - -END THE. - - -SYNONYMS - me, myself, yourself, self = hero. - - --- Please refer also 'verbs.i' where there are numerous verb checks for the hero, --- so that the hero cannot e.g. attack himself etc. - - --- end of file. \ No newline at end of file diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newlocations.i b/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newlocations.i deleted file mode 100644 index 415b873..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newlocations.i +++ /dev/null @@ -1,580 +0,0 @@ --- ALAN Standard Library v1.10 --- Locations (file name: 'locations.i') - - --- This library file defines the default directions (exits) and the location 'nowhere', --- a useful place to locate things when you want to remove them from play. --- This file also defines three specific location classes: rooms (= indoor locations), --- sites (= outdoor locations) as well as the class 'dark_location'. --- Finally, the attributes 'visited' and 'described' are defined. --- You may modify this file in any way that suits your purposes. --- To use this file, you should have it in the same folder as your source code file, --- and the line --- --- IMPORT 'locations.i'. --- --- in your source code. - - - --- ======================================================== - - ------ 1. The location 'nowhere' and the default directions - - --- ======================================================== - - -THE nowhere ISA LOCATION - - EXIT - north, - south, - east, - west, - northeast, - southeast, - northwest, - southwest, - up, - down, - 'in', - out - - TO nowhere. - - -END THE nowhere. - - -SYNONYMS - n = north. - s = south. - e = east. - w = west. - ne = northeast. - se = southeast. - nw = northwest. - sw = southwest. - u = up. - d = down. - - --- Note: - - --- 1) the directions defined above (and their synonyms) are not predefined in or --- hardwired to the interpreter in any way, so you can replace them altogether or add new --- ones to be used alongside with them. - - --- 2) when you want to remove things from play, you can --- --- LOCATE [object] AT nowhere. --- --- e.g. --- --- THE piece_of_paper ISA OBJECT --- ... --- VERB tear --- DOES ONLY "You tear the piece of paper to shreds." --- LOCATE piece_of_paper AT nowhere. --- END VERB. --- --- END THE piece_of_paper. - - - --- ========================================================================= - - ------ 2. Location classes 'room' and 'site' for indoor and outdoor locations - - --- ========================================================================= - - --- ROOM and SITE are optional location classes you can use to ease up coding. --- All ROOMS have a floor, walls and a ceiling. All SITES have a ground and a sky. --- Thus, you will be able to define e.g. --- --- THE kitchen ISA ROOM --- --- and it will automatically have a floor, walls and a ceiling, --- --- or: --- --- THE greenmeadow ISA SITE --- --- and the ground and the sky are automatically found in that location. --- --- --- Of course, you will still be able to define locations in the usual way, e.g. --- --- THE kitchen ISA LOCATION --- --- etc, but the floor, walls and ceiling won't be automatically included there. --- The walls, floor, ceiling, ground and sky are not takeable or movable. --- This library file also defines the sky to be distant and the ceiling to be out of reach, --- so that they can't be e.g. touched. - --- (We make use of ALAN's nested locations feature in the following definitions: ) - - -THE outdoor ISA LOCATION -END THE outdoor. - - -THE indoor ISA LOCATION -END THE indoor. - - -EVERY room ISA LOCATION AT indoor -END EVERY. - - -EVERY site ISA LOCATION AT outdoor -END EVERY. - - -EVERY room_object ISA OBJECT AT indoor -END EVERY. - - -EVERY site_object ISA OBJECT AT outdoor -END EVERY. - - -THE floor ISA room_object - IS NOT takeable. - IS NOT movable. - CONTAINER - -- to allow 'empty/pour something on floor' - DESCRIPTION "" - - - -- As we have declared the floor a container, we will disable some verbs - -- defined to work with containers: - - - VERB empty_in, pour_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB look_in - DOES ONLY "That's not possible." - END VERB. - - - VERB put_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB take_from - WHEN holder - DOES ONLY "If you want to pick up something, just TAKE it." - END VERB. - - - VERB throw_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - -END THE. - - -THE wall ISA room_object - NAME wall NAME walls - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" -END THE. - - - -THE ceiling ISA room_object - IS NOT reachable. - DESCRIPTION "" -END THE. - - - -THE ground ISA site_object - IS NOT takeable. - IS NOT movable. - CONTAINER - -- to allow 'empty/pour something on ground' - DESCRIPTION "" - - - - -- As we have declared the floor to be a container, we will disable some verbs - -- defined to work with containers: - - - VERB empty_in, pour_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB look_in - DOES ONLY "That's not possible." - END VERB. - - - VERB put_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB take_from - WHEN holder - DOES ONLY "If you want to pick up something, just TAKE it." - END VERB. - - - VERB throw_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - -END THE. - - - -THE sky ISA site_object - IS distant. - DESCRIPTION "" -END THE. - - --- We still declare some shared behaviour for all indoor and outdoor objects: - - -ADD TO EVERY room_object - - VERB put_against - WHEN bulk - CHECK THIS = wall - ELSE "That's not possible." - END VERB. - - VERB put_behind, put_near, put_under - WHEN bulk - DOES ONLY "That's not possible." - END VERB. - - VERB look_behind, look_through, look_under - DOES ONLY "That's not possible." - END VERB. - -END ADD TO. - - -ADD TO EVERY site_object - - VERB put_against, put_behind, put_near, put_under - WHEN bulk - DOES ONLY "That's not possible." - END VERB. - - VERB look_behind, look_through, look_under - DOES ONLY "That's not possible." - END VERB. - -END ADD TO. - - --- NOTE: it is often a good idea to modify the 'examine' verb for the above objects. --- Here is an example for 'wall': - --- THE wall ISA room_object --- : --- : --- VERB examine DOES ONLY --- IF hero AT kitchen --- THEN "Numerous shelves, full of various kitchen utensils, line the walls." --- ELSIF hero AT livingroom --- THEN "The walls are decorated with flowery wallpaper here." --- : --- : --- END IF. --- END VERB. --- --- END THE wall. --- --- In other words, making the description of the walls, etc., individual for each room --- gives a better impression than if you just use the default message. - - - --- ========================================================== - - ------ 3. Dark locations - - --- ========================================================== - - -ADD TO EVERY LOCATION - IS lit. -END ADD TO. - - -EVERY dark_location ISA LOCATION - IS NOT lit. - - ENTERED - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - THEN MAKE THIS lit. - IF CURRENT ACTOR <> hero - THEN LOOK. - END IF. - END IF. - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE = 0 - THEN MAKE THIS NOT lit. - END IF. - - -- These ENTERED statements take care - -- of the dark location being correctly lit or not lit at entrance, - -- the WHEN rules below take care of the change when the hero is - -- already in the location. - - - DESCRIPTION - CHECK THIS IS lit - ELSE SAY dark_loc_desc OF my_game. - -END EVERY dark_location. - - -WHEN location OF hero IS NOT lit - AND COUNT ISA lightsource, IS lit, AT hero > 0 -THEN MAKE location OF hero lit. - SCHEDULE light_on AT hero AFTER 0. - -EVENT light_on - LOOK. -END EVENT. - - -WHEN location OF hero ISA dark_location - AND location OF hero IS lit - AND COUNT ISA lightsource, IS lit, AT hero = 0 -THEN MAKE location OF hero NOT lit. - SCHEDULE light_off AT hero AFTER 0. - -EVENT light_off - "It is now pitch black." -END EVENT. - - --- We make sure that dark_locations will be dark after the hero leaves them, if the hero took the --- lightsource with him: - -EVENT check_darkness - FOR EACH dl ISA dark_location, IS lit - DO - IF COUNT ISA LIGHTSOURCE, AT dl = 0 - THEN MAKE dl NOT lit. - END IF. - END FOR. - SCHEDULE check_darkness AFTER 1. -END EVENT. - - --- This event is initialized in the start_section instance ('definitions.i'). - - --- To define a dark location, use a formulation like the following: - - --- THE basement ISA dark_location --- EXIT up TO kitchen. --- ... --- END THE. - - --- The description of a dark_location will automatically be: "It is pitch black. --- You can't see anything at all." (Edit the description in the code above to change this.) - - --- If you add a description to a dark_location, this description will be shown only --- if/when the location is lit by any means: - --- THE basement ISA dark_location --- DESCRIPTION "Cobwebs and old junk are the only things you see here." --- EXIT up TO kitchen. --- END THE. - - --- In darkness, you are not able to manipulate things other than turn on a lightsource --- and drop items you're carrying (these checks are found in 'verbs.i'). You can exit normally --- and use verbs that don't require seeing, such as 'smell', 'listen' and 'think'. --- If you are in a dark location with an NPC (= a non-player character), you are able to --- communicate with him by asking and telling but not by showing and giving. If you wish to --- change this, see the respective verbs in 'verbs.i' and edit their checks. - - --- Note that you cannot change the name of a location mid-game. Thus, if you define a dark location --- called e.g. 'Darkness' and wish to make it lit at some point in the game, the name will still be --- 'Darkness' even if the location description can be changed to describe the illuminated location. --- To change the location name, you must locate the hero in another location when the dark location --- is lit. For example, --- --- --- THE lantern ISA LIGHTSOURCE -- (see 'classes.i') --- VERB turn_on --- DOES --- IF hero AT darkness --- THEN LOCATE hero AT treasure_chamber. --- ... --- END IF. --- ... --- END VERB. --- END THE. --- etc. --- --- --- Alternatively, you can also use a rule, e.g. --- --- --- WHEN lantern IS lit --- AND hero AT darkness --- THEN LOCATE hero AT treasure_chamber. - - - --- Suppose you want all dark_locations in the game to become lighted. It can be done e.g. like this: - - --- THE main_power_switch ISA DEVICE --- VERB switch_on --- DOES ONLY --- FOR EACH d1 ISA dark_location --- DO --- FOR EACH ls ISA LIGHTSOURCE, AT d1 --- MAKE ls lit. --- END FOR. --- MAKE d1 lit. --- -- This line is not necessarily needed because the lit lightsource --- -- in each dark location already makes the dar location lit. --- END EACH. --- END VERB. --- END THE. - --- FOR EACH makes a loop that affects all instances of the class described after the ISA statement. --- The 'd1' above is a temporary variable needed in the FOR EACH phrase and not anywhere --- else in the game code. You can name this variable in any way you wish. - - - --- ===================================================================== - - ------ 4. The attributes 'visited' and 'described' - - --- ===================================================================== - - --- A location has the value 'visited 0' until the hero visits it for the first time, and the --- value increases on every subsequent visit. --- This helps when you need to control if or how many times a location has been visited, --- and also if you want the location description to be different after the first visit. - --- A location has the value 'described 0' before the first location description, --- and the value increases every time the description is shown. --- This distinction is handy when you want the first-time description of a location to be different --- from the subsequent ones (even if the hero is in the location still for the first time). - - -ADD TO EVERY LOCATION - HAS visited 0. - HAS described 0. - - ENTERED - IF CURRENT ACTOR = hero - THEN - INCREASE visited OF THIS. - INCREASE described OF THIS. - -- The "described" attribute increases also after LOOK (see 'verbs.i'). - END IF. - -END ADD TO. - - --- A location not visited at all has the 'visited' value 0. When the hero enters it --- the first time, the 'visited' value will change to 1. On the second visit the value --- will be 2, etc. --- Now, in your source code you can define something like the following: - - --- THE kitchen ISA LOCATION --- DESCRIPTION --- "You are in the kitchen." --- IF visited OF THIS = 1 --- THEN "This is your first time here." --- ELSE "You remember you've been here before." --- END IF. --- ... --- END THE. - --- Note that if you have an NPC moving around in the game, the visited value of any location --- will increase when the NPC enters the location, as well (ENTERED applies to all moving actors). --- This is most often not what is wanted, and that's why the 'if' statement --- (IF CURRENT ACTOR = hero) is included above. - - --- You can also check whether the hero has been in a location if needed: - --- THE king ISA ACTOR --- ... --- VERB ask --- WHEN act --- IF topic = treasure_chamber --- THEN --- IF visited OF treasure_chamber = 0 --- THEN "You are not supposed to know anything about the treasure --- chamber - you haven't found it yet." --- ELSE """Just take what you want from the chamber"", the king smiles." --- END IF. --- ... --- END IF. --- END VERB. --- END THE. - - --- etc. - - --- Suppose you want the location description to be different after the first time the description is shown, --- even if you are in the location still for the first time. Then, you can use the 'described' attribute, e.g.: - - --- THE library ISA ROOM --- DESCRIPTION --- IF described OF THIS = 1 --- THEN "There is an old man reading at a table in one of the corners." --- ELSE "The old man keeps on reading at his table." --- END IF. --- END THE. - - - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newverbs.i b/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newverbs.i deleted file mode 100644 index d498ee3..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/newverbs.i +++ /dev/null @@ -1,8269 +0,0 @@ --- ALAN Standard Library v1.10 --- Verbs (file name: 'verbs.i') - - - ------ This library file defines common verbs needed in gameplay. The verbs ------ are listed alphabetically. This file also includes common commands which are not ------ actually verbs, such as "inventory", "verbose" and "again". ------ Verbs originally defined in this file are the following: - - ------ VERB SYNONYMS SYNTAX ARITY OBJ - ------ about (+ help, info) about 0 ------ again (+ g) again 0 ------ answer (+ reply) answer (topic) 1 ------ ask (+ enquire, inquire, interrogate) ask (act) about (topic) 2 ------ ask for ask (act) for (obj) 2 x ------ attack (+ beat, fight, hit, punch) attack (target) 1 ------ attack_with attack (target) with (weapon) 2 ------ bite bite (obj) 1 x ------ break (+ destroy) break (obj) 1 x ------ break_with break (obj) with (instr) 2 x ------ brief brief 0 ------ burn burn (obj) 1 x ------ burn_with burn (obj) with (instr) 2 x ------ buy (+ purchase) buy (item) 1 ------ catch catch (obj) 1 x ------ clean (+ polish, wipe) clean (obj) 1 x ------ climb climb (obj) 1 x ------ climb_on climb on (surface) 1 ------ climb_through climb through (obj) 1 x ------ close (+ shut) close (obj) 1 x ------ close_with close (obj) with (instr) 2 x ------ consult consult (source) about (topic) 2 ------ credits (+ acknowledgments, author, copyright) credits 2 ------ cut cut (obj) 1 x ------ cut_with cut (obj) with (instr) 2 x ------ dance dance 0 ------ dig dig (obj) 1 x ------ dive dive 0 ------ dive_in dive in (liq) 1 ------ drink drink (liq) 1 ------ drive drive (vehicle) 1 ------ drop (+ discard, dump, reject) drop (obj) 1 x ------ eat eat (food) 1 ------ empty empty (obj) 1 x ------ empty_in empty (obj) in (cont) 2 x ------ empty_on empty (obj) on (surface) 2 x ------ enter enter (cont) 1 ------ examine (+ check, inspect, observe, x) examine (obj) 1 x ------ exit exit (cont) 1 ------ extinguish (+ put out, quench) extinguish (obj) 1 x ------ fill fill (cont) 1 ------ fill_with fill (cont) with (substance) 1 ------ find (+ locate) find (obj) 1 x ------ fire fire (weapon) 1 ------ fire_at fire (weapon) at (target) 1 ------ follow follow (act) 1 ------ free (+ release) free (obj) 1 x ------ get_up get up 0 ------ get_off get off (obj) 1 x ------ give give (obj) to (recip) 1 x ------ go_to go to (dest) 1 ------ hint (+ hints) hint 0 ------ inventory (+ i, inv) inventory 0 ------ jump jump 0 ------ jump_in jump in (cont) 1 ------ jump_on jump on (surface) 1 ------ kick kick (target) 1 ------ kill (+ murder) kill (victim) 1 ------ kill_with kill (victim) with (weapon) 2 ------ kiss (+ hug, embrace) kiss (obj) 1 x ------ lie_down lie down 0 ------ lie_in lie in (cont) 1 ------ lie_on lie on (surface) 1 ------ lift lift (obj) 1 x ------ light (+ lit) light (obj) 1 x ------ listen0 listen 0 ------ listen listen to (obj) 1 x ------ lock lock (obj) 1 x ------ lock_with lock (obj) with (key) 2 x ------ look (+ gaze, peek) look 0 ------ look_at look at (obj) 1 x ------ look_behind look behind (bulk) 1 ------ look_in look in (cont) 1 ------ look_out_of look out of (obj) 1 x ------ look_through look through (bulk) 1 ------ look_under look under (bulk) 1 ------ look_up look up 0 ------ no no 0 ------ notify (on, off) notify. notify on. notify off 0 ------ open open (obj) 1 x ------ open_with open (obj) with (instr) 2 x ------ play play (obj) 1 x ------ play_with play with (obj) 1 x ------ pour (= defined at the verb 'empty) pour (obj) 1 x ------ pour_in (= defined at the verb 'emtpy_in') pour (obj) in (cont) 2 x ------ pour_on (= defined at the verb 'empty_on') pour (obj) on (surface) 2 x ------ pray pray 0 ------ pry pry (obj) 1 x ------ pry_with pry (obj) with (instr) 2 x ------ pull pull (obj) 1 x ------ push push (obj) 1 x ------ push_with push (obj) with (instr) 2 x ------ put (+ lay, place) put (obj) 1 x ------ put_against put (obj) against (bulk)) 2 x ------ put_behind put (obj) behind (bulk) 2 x ------ put_down put down (obj) 1 x ------ put_in (+ insert) put (obj) in (cont) 2 x ------ put_near put (obj) near (bulk) 2 x ------ put_on put (obj) on (surface) 2 x ------ put_under put (obj) under (bulk) 2 x ------ read read (obj) 1 x ------ remove remove (obj) 1 x ------ restart restart 0 ------ restore restore 0 ------ rub rub (obj) 1 x ------ save save 0 ------ say say (topic) 1 ------ say_to say (topic) to (act) 2 ------ score score 0 ------ scratch scratch (obj) 1 x ------ script script. script on. script off. 0 ------ search search (obj) 1 x ------ sell sell (item) 1 ------ shake shake (obj) 1 x ------ shoot (at) shoot at (target) 1 ------ shoot_with shoot (target) with (weapon) 2 ------ shout (+ scream, yell) shout 0 ------ show (+ reveal) show (obj) to (act) 2 x ------ sing sing 0 ------ sip sip (liq) 1 ------ sit (down) sit. sit down. 0 ------ sit_on sit on (surface) 1 ------ sleep (+ rest) sleep 0 ------ smell0 smell 0 ------ smell smell (odour) 1 ------ squeeze squeeze (obj) 1 x ------ stand (up) stand. stand up. 0 ------ stand_on stand on (surface) 1 ------ swim swim 0 ------ swim_in swim in (liq) 1 ------ switch_on switch on (app) 1 ------ switch_off switch off (app) 1 ------ take (+ carry, get, grab, hold, obtain) take (obj) 1 x ------ take_from (+ remove from) take (obj) from (holder) 2 x ------ talk talk 0 ------ talk_to (+ speak) talk to (act) 1 ------ taste (+ lick) taste (obj) 1 x ------ tear (+ rip) tear (obj) 1 x ------ tell (+ enlighten, inform) tell (act) about (topic) 2 ------ think think 0 ------ think_about think about (topic) 1 ------ throw throw (projectile) 1 ------ throw_at throw (projectile) at (target) 2 ------ throw_in throw (projectile) in (cont) 2 ------ throw_to throw (projectile) to (recipient) 2 ------ tie tie (obj) 1 x ------ tie_to tie (obj) to (target) 2 x ------ touch (+ feel) touch (obj) 1 x ------ turn (+ rotate) turn (obj) 1 x ------ turn_on turn on (app) 1 ------ turn_off turn off (app) 1 ------ undress undress 0 ------ unlock unlock (obj) 1 x ------ unlock_with unlock (obj) with (key) 2 x ------ use use (obj) 1 x ------ use_with use (obj) with (instr) 2 x ------ verbose verbose 0 ------ wait (+ z) wait 0 ------ wear wear (obj) 1 x ------ what_am_i what am i 0 ------ what_is what is (obj) 1 x ------ where_am_i where am i 0 ------ where_is where is (obj) 1 x ------ who_am_i who am i 0 ------ who_is who is (obj) 1 x ------ write write (txt) on (obj) 2 x ------ yes yes 0 - - - - ------ Directions (north, south, up, etc.) are declared in the file 'locations.i'. - - - - - - - ------ The verbs and commands: - - - --- ============================================================= - - ------ ABOUT - - --- ============================================================= - - -SYNTAX 'about' = 'about'. - - -VERB 'about' - DOES - "[This is a text adventure, also called interactive fiction, which means that what - goes on in the story depends on what you type at the prompt. Commands you can type - are for example GO NORTH (or NORTH or just N), WEST, SOUTHEAST, UP, IN etc for - moving around, but you can try many - other things too, like TAKE LAMP, DROP EVERYTHING, EAT APPLE, EXAMINE BIRD or - FOLLOW OLD MAN, to name just a few. LOOK (L) describes your surroundings, and - INVENTORY (I) lists what you are carrying. You can SAVE your game and RESTORE it - later on. - $pType CREDITS to see information about the author and the copyright issues. - $pTo stop playing and end the program, type QUIT.]$p" -END VERB. - - -SYNONYMS help, info = 'about'. - - - --- ============================================================= - - ------ AGAIN (= g) - - --- ============================================================= - - -SYNTAX again = again. - - -VERB again - DOES - "[The AGAIN command is not supported in this game. As a workaround, try using - the 'up' and 'down' arrow keys to scroll through your previous commands.]" -END VERB. - - -SYNONYMS g = again. - - - --- ============================================================= - - ------ ANSWER (+ reply) - - --- ============================================================= - - -SYNTAX answer = answer (topic) - WHERE topic ISA STRING - ELSE SAY illegal_parameter_string OF my_game. - - -ADD TO EVERY STRING - VERB answer - DOES - "Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ ASK (= enquire, inquire, interrogate) - - --- ============================================================= - - -SYNTAX ask = ask (act) about (topic)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN SAY illegal_parameter_talk_sg OF my_game. - ELSE SAY illegal_parameter_talk_pl OF my_game. - END IF. - AND topic ISA THING - ELSE - IF topic IS NOT plural - THEN SAY illegal_parameter_about_sg OF my_game. - ELSE SAY illegal_parameter_about_pl OF my_game. - END IF. - - ask = enquire (act) about (topic)!. - - ask = inquire (act) about (topic)!. - - ask = interrogate (act) about (topic)!. - - -- Above, we define the alternative verbs in the syntax rather than as synonyms, - -- as the verb 'ask_for' below doesn't sound correct with these alternatives allowed. - - -ADD TO EVERY ACTOR - VERB ask - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN SAY check_act_can_talk_sg OF my_game. - ELSE SAY check_act_can_talk_pl OF my_game. - END IF. - AND act <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - AND act IS NOT distant - ELSE - IF act IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_sg OF my_game. - END IF. - DOES - "There is no reply." - END VERB. -END ADD TO. - - - ------ note that 'consult' is defined separately - - - --- ============================================================= - - ------ ASK FOR - - --- ============================================================= - - -SYNTAX ask_for = ask (act) 'for' (obj) - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN SAY illegal_parameter_talk_sg OF my_game. - ELSE SAY illegal_parameter_talk_pl OF my_game. - END IF. - AND obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_for_sg OF my_game. - ELSE SAY illegal_parameter_for_pl OF my_game. - END IF. - - -ADD TO EVERY ACTOR - VERB ask_for - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN SAY check_act_can_talk_sg OF my_game. - ELSE SAY check_act_can_talk_pl OF my_game. - END IF. - AND act <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - AND obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_for_sg OF my_game. - ELSE SAY check_obj2_suitable_for_pl OF my_game. - END IF. - AND obj NOT IN hero - ELSE SAY check_obj_not_in_hero2 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND act IS NOT distant - ELSE - IF act IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN SAY check_obj_reachable_ask OF my_game. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - - DOES - SAY THE act. - - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - - "seem to want to let you have" - - SAY THE obj. "." - - END VERB. -END ADD TO. - ---- another 'ask_for' formulation added to guide players to use the right phrasing: - - -SYNTAX ask_for_error = ask 'for' (obj) - WHERE obj ISA OBJECT - ELSE "Please use the formulation ASK PERSON FOR THING to ask somebody for - something." - - -ADD TO EVERY OBJECT - VERB ask_for_error - DOES - "Please use the formulation ASK PERSON FOR THING to ask somebody for - something." - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ ATTACK (+ beat, fight, hit, punch) - - --- ============================================================= - - -SYNTAX attack = attack (target) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB attack - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND target <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - AND target NOT IN hero - ELSE SAY check_obj_not_in_hero1 OF my_game. - AND target NOT IN worn - ELSE SAY check_obj_not_in_worn2 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND target IS reachable AND target IS NOT distant - ELSE - IF target IS NOT reachable - THEN - IF target IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF target IS distant - THEN - IF target IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting2 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down2 OF my_game. - DOES - "Resorting to brute force is not the solution here." - END VERB. -END ADD TO. - - -SYNONYMS beat, fight, hit, punch = attack. - --- Note that 'kick' is defined separately, to avoid absurd commands such as --- 'kick man with sword' (see 'attack_with' below) - - - --- ============================================================== - - ------ ATTACK WITH - - --- ============================================================== - - -SYNTAX attack_with = attack (target) 'with' (weapon) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN SAY illegal_parameter2_with_sg OF my_game. - ELSE SAY illegal_parameter2_with_pl OF my_game. - END IF. - - - -ADD TO EVERY THING - VERB attack_with - WHEN target - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND weapon IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND target <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - AND target NOT IN hero - ELSE SAY check_obj_not_in_hero1 OF my_game. - AND target NOT IN worn - ELSE SAY check_obj_not_in_worn2 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND target IS reachable AND target IS NOT distant - ELSE - IF target IS NOT reachable - THEN - IF target IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF target IS distant - THEN - IF target IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting2 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down2 OF my_game. - DOES - "Resorting to brute force is not the solution here." - END VERB. -END ADD TO. - - - --- =============================================================== - - ------ BITE (+ chew, taste) - - --- =============================================================== - - -SYNTAX bite = bite (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - - -ADD TO EVERY OBJECT - VERB bite - CHECK obj IS edible - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS NOT distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - -- This if-statement takes care of implicit taking; i.e. if the hero - -- doesn't have the object, (s)he will take it automatically first. - -- This same if-statement is found in numerous other verbs throughout - -- the library, as well. - - IF obj NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE obj IN hero. - END IF. - - "You take a bite of" SAY THE obj. "$$." - - IF obj IS NOT plural - THEN "It tastes nothing out of the ordinary." - ELSE "They taste nothing out of the ordinary." - END IF. - - END VERB. -END ADD TO. - - - --- =============================================================== - - ------ BREAK - - --- =============================================================== - - -SYNTAX break = break (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB break - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "Resorting to brute force is not the solution here." - END VERB. -END ADD TO. - - -SYNONYMS destroy = break. - - - --- =============================================================== - - ------ BREAK WITH - - --- =============================================================== - - -SYNTAX break_with = break (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND instr ISA OBJECT - ELSE - IF instr IS NOT plural - THEN SAY illegal_parameter2_with_sg OF my_game. - ELSE SAY illegal_parameter2_with_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB break_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND instr IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND instr IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "Trying to break" SAY THE obj. "with" SAY THE instr. - "wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ BRIEF - - --- ================================================================ - - --- Use "Visits 0." or "Visits 1000." in the START section if you want --- the game to start in verbose or brief mode. (By default, --- all games start in the verbose mode.) - - -SYNTAX brief = brief. - - -VERB brief - DOES - Visits 1000. - "Brief mode is now on. Location descriptions will only be shown - the first time you visit." -END VERB. - - - --- ================================================================= - - ------ BURN - - --- ================================================================= - - -SYNTAX burn = burn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB burn - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You must state what you want to burn" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ================================================================= - - ------ BURN WITH - - --- ================================================================= - - -SYNTAX burn_with = burn (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND instr ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter2_with_sg OF my_game. - ELSE SAY illegal_parameter2_with_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB burn_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj <> instr - ELSE SAY check_obj_not_obj2_with OF my_game. - AND instr IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND instr IN hero - ELSE SAY check_obj2_in_hero OF my_game. - DOES - "You can't burn" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ BUY (+ purchase) - - --- ================================================================== - - -SYNTAX buy = buy (item) - WHERE item ISA OBJECT - ELSE - IF item IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB buy - CHECK item IS examinable - ELSE - IF item IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - DOES - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "for sale." - END VERB. -END ADD TO. - - -SYNONYMS purchase = buy. - - - --- ================================================================== - - ------ CATCH - - --- ================================================================== - - -SYNTAX catch = catch (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB catch - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting2 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down2 OF my_game. - DOES - IF obj IS NOT plural - THEN "That doesn't" - ELSE "Those don't" - END IF. - - "need to be caught." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ CLEAN ( + wipe, polish) - - --- ================================================================== - - -SYNTAX clean = clean (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - - -ADD TO EVERY OBJECT - VERB clean - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS wipe, polish = clean. - - ------ notice that 'rub' is defined separately - - - --- ============================================================== - - ------ CLIMB - - --- ============================================================== - - -SYNTAX climb = climb (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - - -ADD TO EVERY OBJECT - VERB climb - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting3 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down3 OF my_game. - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "something you can climb." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB ON - - --- ============================================================== - - -SYNTAX climb_on = climb 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN SAY illegal_parameter_on_sg OF my_game. - ELSE SAY illegal_parameter_on_pl OF my_game. - END IF. - - -ADD TO EVERY SUPPORTER - VERB climb_on - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND surface IS reachable AND surface IS NOT distant - ELSE - IF surface IS NOT reachable - THEN - IF surface IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF surface IS NOT distant - THEN - IF surface IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting3 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down3 OF my_game. - DOES - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "something you can climb on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB THROUGH - - --- ============================================================== - - -SYNTAX climb_through = climb through (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB climb_through - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting3 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down3 OF my_game. - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "something you can climb through." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLOSE (+ shut) - - --- ============================================================== - - -SYNTAX close = close (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB close - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND obj IS NOT closed - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_closed1_sg OF my_game. - ELSE SAY check_obj_not_closed1_pl OF my_game. - END IF. - DOES - MAKE obj closed. - "You close the" SAY THE obj. "." - END VERB. -END ADD TO. - - -SYNONYMS shut = close. - - - --- ============================================================== - - ------ CLOSE WITH - - --- ============================================================== - - -SYNTAX close_with = close (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND instr ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_with_sg OF my_game. - ELSE SAY illegal_parameter_with_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB close_with - WHEN obj - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND instr IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND instr IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND obj IS NOT closed - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_closed1_sg OF my_game. - ELSE SAY check_obj_not_closed1_pl OF my_game. - END IF. - - DOES - "You can't $v" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CONSULT - - --- ============================================================== - - -SYNTAX consult = consult (source) about (topic)! - WHERE source ISA OBJECT - ELSE - IF source IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND topic ISA THING - ELSE - IF topic IS NOT plural - THEN SAY illegal_parameter_about_sg OF my_game. ---- change!! - ELSE SAY illegal_parameter_about_pl OF my_game. - END IF. - - consult = 'look' 'up' (topic) 'in' (source). - - -ADD TO EVERY THING - VERB consult - WHEN source - CHECK source IS examinable - ELSE - IF source IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND source IS reachable AND source IS NOT distant - ELSE - IF source IS NOT reachable - THEN - IF source IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF source IS distant - THEN - IF source IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You find nothing useful about" SAY THE topic. "in" SAY THE source. "." - - END VERB. -END ADD TO. - - ---- another 'consult' formulation added to guide players to use the right phrasing: - - -SYNTAX consult_error = consult (source) - WHERE source ISA THING - ELSE "To consult something, please use the - formulation CONSULT THING ABOUT PERSON/THING." - - -ADD TO EVERY THING - VERB consult_error - DOES "To consult something, please use the formulation CONSULT THING - ABOUT PERSON/THING." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CREDITS (+ acknowledgments, author, copyright) - - --- ============================================================== - - -SYNTAX credits = credits. - - -VERB credits - DOES - "The author retains the copyright to this game. - $pThis game was written using the ALAN Adventure Language. ALAN is - an interactive fiction authoring system by Thomas Nilsson. - $nE-mail address: thomas@alanif.se $pFurther information - about the ALAN system can be obtained from - the World Wide Web Internet site - $ihttp://www.alanif.se$p" -END VERB. - - -SYNONYMS acknowledgments, author, copyright = credits. - - - --- ============================================================== - - ------ CUT - - --- ============================================================== - - -SYNTAX cut = cut (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB cut - DOES "You need to specify what you want to cut" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CUT WITH - - --- ============================================================== - - -SYNTAX cut_with = cut (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND instr ISA OBJECT - ELSE - IF instr IS NOT plural - THEN SAY illegal_parameter2_with_sg OF my_game. - ELSE SAY illegal_parameter2_with_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB cut_with - WHEN obj - CHECK obj <> instr - ELSE SAY check_obj_not_obj2_with OF my_game. - AND instr IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND instr IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You can't cut" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DANCE - - --- ============================================================== - - -SYNTAX dance = dance. - - -VERB dance - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting1 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down1 OF my_game. - DOES - "How about a waltz?" -END VERB. - - - --- ============================================================== - - ------ DIG - - --- ============================================================== - - -SYNTAX dig = dig (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB dig - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting2 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down2 OF my_game. - DOES - "There is nothing suitable to dig here." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DIVE - - --- ============================================================== - - -SYNTAX dive = dive. - - -VERB dive - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting3 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down3 OF my_game. - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ DIVE IN - - --- ============================================================== - - -SYNTAX dive_in = dive 'in' (liq) - WHERE liq ISA LIQUID -- see 'classes.i' - ELSE - IF liq IS NOT plural - THEN SAY illegal_parameter_in_sg OF my_game. - ELSE SAY illegal_parameter_in_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB dive_in - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting3 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down3 OF my_game. - DOES - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "something you can dive in." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DRINK - - --- ============================================================== - - -SYNTAX drink = drink (liq) - WHERE liq ISA LIQUID -- see 'classes.i' - ELSE - IF liq IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY LIQUID - VERB drink - CHECK liq IS drinkable - ELSE - IF liq IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND liq IS reachable AND liq IS NOT distant - ELSE - IF liq IS NOT reachable - THEN - IF liq IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF liq IS distant - THEN - IF liq IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - IF vessel OF liq = null_vessel - -- here, if the liquid is in no container, e.g. - -- the hero takes a sip of water from a river, - -- the action is allowed to succeed: - - THEN "You drink a bit of" SAY THE liq. "." - - ELSE - -- = if the liquid is in a container: - - -- implicit taking: - IF vessel OF liq NOT DIRECTLY IN hero - THEN - IF vessel OF liq IS NOT takeable - THEN "You can't carry" SAY THE liq. "around in your bare hands." - -- the action stops here if the container is not takeable. - ELSE LOCATE vessel OF liq IN hero. - "(taking" SAY THE vessel OF liq. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF liq IN hero - -- i.e. if the implicit taking was successful - THEN - "You drink all of" SAY THE liq. "." - LOCATE liq AT nowhere. - END IF. - END IF. - - END VERB. -END ADD TO. - - --- Note that the verb 'sip' is defined separately, with a slightly different behaviour. - - - --- ============================================================== - - ------ DRIVE - - --- ============================================================== - - -SYNTAX drive = drive (vehicle) - WHERE vehicle ISA OBJECT - ELSE - IF vehicle IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB drive - DOES - IF vehicle IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "something you can drive." - END VERB. -END ADD TO. - - --- another 'drive' formulation added to guide players to use the right phrasing: - - -SYNTAX drive_error = drive. - - -VERB drive_error - DOES "To drive something, use the phrasing DRIVE SOMETHING." -END VERB. - - - --- ============================================================== - - ------ DROP - - --- ============================================================== - - -SYNTAX drop = drop (obj)* - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - drop = put (obj) * down. - - drop = put down (obj)*. - - -ADD TO EVERY OBJECT - VERB drop - CHECK obj IN hero - ELSE SAY check_obj_in_hero OF my_game. - DOES - LOCATE obj HERE. - "Dropped." - END VERB. -END ADD TO. - - -SYNONYMS - discard, dump, reject = drop. - - - --- ============================================================== - - ------ EAT - - --- ============================================================== - - -SYNTAX eat = eat (food) - WHERE food ISA OBJECT - ELSE - IF food IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB eat - CHECK food IS edible - ELSE - IF food IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND food IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND food IS reachable AND food IS NOT distant - ELSE - IF food IS NOT reachable - THEN - IF food IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF food IS distant - THEN - IF food IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - -- implicit taking: - IF food NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE food IN hero. - END IF. - -- end of implicit taking. - - "You eat all of" SAY THE food. "." - LOCATE food AT nowhere. - - END VERB. -END ADD. - - - --- ============================================================== - - ------ EMPTY (+ POUR) - - --- ============================================================== - - --- The verbs 'empty' and 'pour' have similar syntaxes and behaviour here. They are, however, --- not declared as synonyms but kept separate, as their usage doesn't overlap 100%; for example --- you can pour liquids but not empty them. --- That's why in 'classes.i', liquids are defined only to work with the verb 'pour', --- and the verb 'empty' is disabled for liquids. - - - - -SYNTAX 'empty' = 'empty' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND obj ISA CONTAINER - ELSE SAY illegal_parameter_there OF my_game. - - pour = pour (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND obj ISA CONTAINER - ELSE SAY illegal_parameter_there OF my_game. - - -ADD TO EVERY OBJECT - VERB 'empty', pour - CHECK obj IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND obj IS NOT closed - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_closed2_sg OF my_game. - ELSE SAY check_obj_not_closed2_pl OF my_game. - END IF. - AND COUNT ISA OBJECT, IN obj > 0 - ELSE SAY check_count_obj_in_cont OF my_game. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. - ELSE "You $v the contents of" SAY THE obj. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - EMPTY obj AT hero. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ EMPTY IN (+ POUR IN) - - --- ============================================================== - - - -SYNTAX empty_in = 'empty' (obj) 'in' (cont) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND cont ISA OBJECT - ELSE SAY illegal_parameter_there OF my_game. - AND cont ISA CONTAINER - ELSE SAY illegal_parameter_there OF my_game. - - - -pour_in = pour (obj) 'in' (cont) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND cont ISA OBJECT - ELSE SAY illegal_parameter_there OF my_game. - AND cont ISA CONTAINER - ELSE SAY illegal_parameter_there OF my_game. - - - - -ADD TO EVERY OBJECT - VERB empty_in, pour_in - WHEN obj - CHECK obj <> cont - ELSE SAY check_obj_not_obj2_in OF my_game. - AND obj IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj NOT DIRECTLY IN cont - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_in_cont_sg OF my_game. - ELSE SAY check_obj_not_in_cont_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND cont IS NOT distant - -- note that it is possible to empty something in a "not reachable" container - ELSE - IF cont IS NOT plural - THEN SAY check_obj2_not_distant_sg OF my_game. - ELSE SAY check_obj2_not_distant_pl OF my_game. - END IF. - AND obj IS NOT closed - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_closed2_sg OF my_game. - ELSE SAY check_obj_not_closed2_pl OF my_game. - END IF. - AND cont IS NOT closed - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_not_closed_sg OF my_game. - ELSE SAY check_obj2_not_closed_pl OF my_game. - END IF. - AND COUNT ISA OBJECT, IN obj > 0 - ELSE SAY check_count_obj_in_cont OF my_game. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - EMPTY obj IN cont. - "You $v the contents of" SAY THE obj. - "into" SAY THE cont. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ EMPTY ON (+ POUR ON) - - --- ============================================================== - - - -SYNTAX empty_on = 'empty' (obj) 'on' (surface) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND surface ISA OBJECT - ELSE SAY illegal_parameter_there OF my_game. - AND surface ISA CONTAINER - ELSE SAY illegal_parameter_there OF my_game. - - pour_on = pour (obj) 'on' (surface) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND surface ISA OBJECT - ELSE SAY illegal_parameter2_there OF my_game. - AND surface ISA CONTAINER - ELSE SAY illegal_parameter2_there OF my_game. - - -ADD TO EVERY OBJECT - VERB empty_on, pour_on - WHEN obj - CHECK obj <> surface - ELSE SAY check_obj_not_obj2_on OF my_game. - AND obj IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND surface IS NOT distant - -- note that it is possible to empty something on a "not reachable" surface - ELSE - IF surface IS NOT plural - THEN SAY check_obj2_not_distant_sg OF my_game. - ELSE SAY check_obj2_not_distant_pl OF my_game. - END IF. - AND obj IS NOT closed - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_closed2_sg OF my_game. - ELSE SAY check_obj_not_closed2_pl OF my_game. - END IF. - AND COUNT ISA OBJECT, IN obj > 0 - ELSE SAY check_count_obj_in_cont OF my_game. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - "It wouldn't be sensible to $v anything on" SAY THE surface. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ ENTER - - --- ============================================================== - - -SYNTAX enter = enter (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB enter - CHECK hero NOT IN cont - ELSE SAY check_hero_not_in_cont OF my_game. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting2 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down2 OF my_game. - DOES - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "something you can enter." - END VERB. -END ADD TO. - - ---- another 'enter' formulation declared to guide players to use the right formulation: - - -SYNTAX enter_error = enter. - - -VERB enter_error - DOES "You must state what you want to enter." -END VERB. - - - --- ============================================================== - - ------ EXAMINE (+ look at) - - --- ============================================================== - - -SYNTAX examine = examine (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_examine_sg OF my_game. - ELSE SAY illegal_parameter_examine_pl OF my_game. - END IF. - - - examine = 'look' 'at' (obj). - - examine = 'look' (obj). - -- note that this formulation is allowed, too - - -ADD TO EVERY THING - VERB examine - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_examine_sg OF my_game. - ELSE SAY check_obj_suitable_examine_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS NOT scenery - ELSE SAY check_obj_not_scenery OF my_game. - - DOES - IF obj IS readable - -- for readable objects, 'examine' behaves just as 'read' - THEN - IF text OF obj = "" - THEN "There is nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. "." - IF obj IS NOT plural - THEN "It says" - ELSE "They say" - END IF. - """$$" SAY text OF obj. "$$""." - END IF. - ELSE "You notice nothing unusual about" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - 'check', inspect, observe, x = examine. - - - --- ============================================================== - - ------ EXIT - - --- ============================================================== - - -SYNTAX 'exit' = 'exit' (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - -ADD TO EVERY OBJECT - VERB 'exit' - CHECK hero IN cont - ELSE SAY check_hero_in_cont OF my_game. - DOES - "You exit" SAY THE cont. "." - LOCATE hero AT CURRENT LOCATION. - MAKE hero NOT sitting. - MAKE hero NOT lying_down. - END VERB. -END ADD TO. - - ---- another 'exit' formulation added to guide players to use the right formulation: - - -SYNTAX exit_error = 'exit'. - - -VERB exit_error - DOES - "You must state what you want to exit." -END VERB. - - - --- ============================================================== - - ------ EXTINGUISH (+ put out) - - --- ============================================================== - - - -SYNTAX extinguish = extinguish (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - extinguish = put 'out' (obj). - - extinguish = put (obj) 'out'. - - -ADD TO EVERY OBJECT - VERB extinguish - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "on fire." - END VERB. -END ADD TO. - - -SYNONYMS quench = extinguish. - - - --- ============================================================== - - ------ FILL - - --- ============================================================== - - -SYNTAX fill = fill (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB fill - DOES - "You have to say what you want to fill" SAY THE cont. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL WITH - - --- ============================================================== - - -SYNTAX fill_with = fill (cont) 'with' (substance) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND substance ISA OBJECT - ELSE - IF substance IS NOT plural - THEN SAY illegal_parameter2_with_sg OF my_game. - ELSE SAY illegal_parameter2_with_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB fill_with - WHEN cont - CHECK cont <> substance - ELSE SAY check_obj_not_obj2_with OF my_game. - AND substance IS examinable - ELSE - IF substance IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND substance NOT IN cont - ELSE - IF cont IS NOT plural - THEN SAY check_obj_not_in_cont2_sg OF my_game. - ELSE SAY check_obj_not_in_cont2_pl OF my_game. - END IF. - AND substance IS takeable - ELSE SAY check_obj2_takeable OF my_game. - AND cont IS reachable AND cont IS NOT distant - ELSE - IF cont IS NOT reachable - THEN - IF cont IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF cont IS distant - THEN - IF cont IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. "." - ELSE SAY check_obj_not_distant_pl OF my_game. "." - END IF. - END IF. - AND substance IS reachable AND substance IS NOT distant - ELSE - IF substance IS NOT reachable - THEN - IF substance IS NOT plural - THEN SAY check_obj2_reachable_sg OF my_game. - ELSE SAY check_obj2_reachable_pl OF my_game. - END IF. - ELSIF substance IS distant - THEN - IF substance IS NOT plural - THEN SAY check_obj2_not_distant_sg OF my_game. "." - ELSE SAY check_obj2_not_distant_pl OF my_game. "." - END IF. - END IF. - DOES - "You can't fill" SAY THE cont. "with" SAY THE substance. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIND - - --- ============================================================== - - -SYNTAX - find = find (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB find - CHECK obj <> hero - ELSE SAY check_obj_not_hero4 OF my_game. "." - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj NOT AT hero - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_at_hero_sg OF my_game. - ELSE SAY check_obj_not_at_hero_pl OF my_game. - END IF. - DOES - "You'll have to $v it yourself." - END VERB. -END ADD TO. - - -SYNONYMS 'locate' = find. - - - --- ============================================================== - - ------ FIRE - - --- ============================================================== - - -SYNTAX fire = fire (weapon) - WHERE weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY WEAPON - VERB fire - CHECK weapon IS fireable - ELSE - IF weapon IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND weapon IN hero - ELSE SAY check_obj_in_hero OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "You fire" SAY THE weapon. "into the air." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIRE AT - - --- ============================================================== - - -SYNTAX fire_at = fire (weapon) 'at' (target) - WHERE weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND target ISA THING - ELSE - IF target IS NOT plural - THEN SAY illegal_parameter_at_sg OF my_game. - ELSE SAY illegal_parameter_at_pl OF my_game. - END IF. - - -ADD TO EVERY WEAPON - VERB fire_at - WHEN weapon - CHECK weapon IS fireable - ELSE - IF weapon IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND target IS examinable - ELSE - IF weapon IS NOT plural - THEN SAY check_obj_suitable_at_sg OF my_game. - ELSE SAY check_obj_suitable_at_pl OF my_game. - END IF. - AND weapon IN hero - ELSE SAY check_obj_in_hero OF my_game. - AND target <> hero - ELSE SAY check_obj_not_hero2 OF my_game. - AND target IS NOT distant - -- note that it is possible to fire at a "not reachable" target - ELSE - IF target IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "Resorting to violence is not the solution here." - END VERB. -END ADD TO. - - --- another formulation added: - - -SYNTAX fire_at_error = fire 'at' (target) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB fire_at_error - CHECK COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE SAY check_count_weapon_in_act OF my_game. - AND target <> hero - ELSE SAY check_obj_not_hero2 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "Resorting to violence is not the solution here." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIX (mend, repair) - - --- ============================================================== - - -SYNTAX fix = fix (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB fix - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS broken - ELSE - IF obj IS NOT plural - THEN SAY check_obj_broken_sg OF my_game. - ELSE SAY check_obj_broken_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "Please be more specific. How do you intend to fix it?" - END VERB. -END ADD TO. - - -SYNONYMS mend, repair = fix. - - - --- ============================================================== - - ------ FOLLOW - - --- ============================================================== - - -SYNTAX follow = follow (act)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB follow - CHECK act <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND act NOT AT hero - ELSE - IF act IS NOT plural - THEN SAY check_obj_not_at_hero_sg OF my_game. - ELSE SAY check_obj_not_at_hero_pl OF my_game. - END IF. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting2 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down2 OF my_game. - AND act NEAR hero - ELSE SAY check_act_near_hero OF my_game. - DOES - "You follow" SAY THE act. "." - LOCATE hero AT act. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FREE (+ release) - - --- ============================================================== - - -SYNTAX free = free (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB free - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj <> hero - ELSE SAY check_obj_not_hero5 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - IF obj IS NOT plural - THEN "That doesn't need to be $vd." - ELSE "Those don't need to be $vd." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS release = free. - - - --- ============================================================== - - ------- GET OFF - - --- ============================================================== - - -SYNTAX get_off = get off (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN SAY illegal_parameter_off_sg OF my_game. - ELSE SAY illegal_parameter_off_pl OF my_game. - END IF. - -ADD TO EVERY SUPPORTER - VERB get_off - DOES - IF hero IS sitting OR hero IS lying_down - THEN "You get off" SAY THE surface. "." - MAKE hero NOT lying_down. - MAKE hero NOT sitting. - ELSE "You're standing up already." - END IF. - END VERB. -END ADD TO. - - --- ============================================================== - - ------- GET UP - - --- ============================================================== - - -SYNTAX get_up = get up. - - -VERB get_up - DOES - IF hero IS sitting - THEN "You stand up." - MAKE hero NOT sitting. - ELSIF hero IS lying_down - THEN "You get up." - MAKE hero NOT lying_down. - ELSE "You're standing up already." - END IF. -END VERB. - - - --- ============================================================== - - ------ GIVE (+ hand, offer) - - --- ============================================================== - - -SYNTAX give = 'give' (obj) 'to' (recip) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND recip ISA ACTOR - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_to_sg OF my_game. - ELSE SAY illegal_parameter_to_pl OF my_game. - END IF. - - give = give (recip) (obj). - - -ADD TO EVERY OBJECT - VERB give - WHEN obj - CHECK obj IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND obj <> recip - ELSE SAY check_obj_not_obj2_to OF my_game. - AND recip <> hero - ELSE SAY check_obj2_not_hero3 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj NOT IN recip - ELSE - IF recip IS NOT plural - THEN SAY check_obj_not_in_act_sg OF my_game. - ELSE SAY check_obj_not_in_act_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND recip IS reachable AND recip IS NOT distant - ELSE - IF recip IS NOT reachable - THEN - IF recip IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF recip IS distant - THEN - IF recip IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - "You give" SAY THE obj. "to" SAY THE recip. "." - LOCATE obj IN recip. - - END VERB. -END ADD TO. - - -SYNONYMS hand, offer = give. - - - --- ============================================================== - - ------ GO TO - - --- ============================================================== - - -SYNTAX go_to = 'to' (dest)! - -- because 'go' is predefined in the parser, it can't be used in verb definitions - WHERE dest ISA THING - ELSE SAY illegal_parameter_there OF my_game. - - -ADD TO EVERY THING - VERB go_to - CHECK dest <> hero - ELSE SAY check_obj_not_hero4 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting3 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down3 OF my_game. - AND dest NOT AT hero - ELSE - IF dest IS NOT plural - THEN SAY check_obj_not_at_hero_sg OF my_game. - ELSE SAY check_obj_not_at_hero_pl OF my_game. - END IF. - AND dest IS reachable AND dest IS NOT distant - ELSE - IF dest IS NOT reachable - THEN - IF dest IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF dest IS distant - THEN - IF dest IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You can't see" SAY THE dest. "anywhere nearby. You must state a - direction where you want to go." - END VERB. -END ADD TO. - - -SYNONYMS walk = go. - -- here we define a synonym for the predefined parser word 'go' - -- which is not visible in the syntax itself. - -- Thus, you will be able to say e.g. both 'go to shop' and 'walk to shop' - -- (as well as e.g. both 'go east' and 'walk east'). - - - --- ============================================================== - - ------ HELP -> see ABOUT - - --- ============================================================== - - - - - --- ============================================================== - - ------ HINT (+ hints) - - --- ============================================================== - - -SYNTAX hint = hint. - - -VERB hint - DOES - "Unfortunately hints are not available in this game." -END VERB. - - -SYNONYMS - hints = hint. - - - --- ============================================================== - - ------ INVENTORY (+ i, inv) - - --- ============================================================== - - - -SYNTAX i = i. - - -VERB i - DOES - LIST hero. - - -- if the hero in your game carries any containers you want the contents of - -- to be listed after 'inventory', you should manually add the listing right here - -- according to the following example: - -- - -- IF bag IN hero - -- THEN LIST bag. - -- END IF. - -- - -- This way, 'inventory' will yield e.g. "You are carrying a bag. The bag contains a book." - -- If you leave the above addition out, the outcome will be just "You are carrying a bag.", with - -- no comment on what is inside the bag. - - IF COUNT IN worn > 0 -- See the file 'classes.i', subclass 'clothing'. - THEN LIST worn. -- This code will list what the hero is wearing. - END IF. - -END VERB. - - -SYNONYMS inv, inventory = i. - - - --- ============================================================== - - ------ JUMP - - --- ============================================================== - - -SYNTAX jump = jump. - - -VERB jump - CHECK hero IS NOT sitting - ELSE SAY check_hero_not_sitting1 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down1 OF my_game. - DOES - "You jump on the spot, to no avail." -END VERB. - - - --- ============================================================== - - ------ JUMP IN - - --- ============================================================== - - -SYNTAX jump_in = jump 'in' (cont) - WHERE cont ISA OBJECT - ELSE SAY illegal_parameter_there OF my_game. - AND cont ISA CONTAINER - ELSE SAY illegal_parameter_there OF my_game. - - - -ADD TO EVERY OBJECT - VERB jump_in - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND cont IS reachable AND cont IS NOT distant - ELSE - IF cont IS NOT reachable - THEN - IF cont IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF cont IS distant - THEN - IF cont IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting1 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down1 OF my_game. - DOES - IF THIS IS NOT plural - THEN "That's not something you can jump into." - ELSE "Those are not something you can jump into." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ JUMP ON - - --- ============================================================== - - -SYNTAX jump_on = jump 'on' (surface) - WHERE surface ISA OBJECT - ELSE - IF surface IS NOT plural - THEN SAY illegal_parameter_on_sg OF my_game. - ELSE SAY illegal_parameter_on_pl OF my_game. - END IF. - AND surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN SAY illegal_parameter_on_sg OF my_game. - ELSE SAY illegal_parameter_on_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB jump_on - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - - AND hero IS NOT sitting - ELSE SAY check_hero_not_sitting1 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down1 OF my_game. - DOES - IF surface ISA SUPPORTER - THEN "That wouldn't accomplish anything." - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump onto." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ KICK - - --- ============================================================= - - -SYNTAX kick = kick (target) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB kick - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND target <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - AND target NOT IN hero - ELSE SAY check_obj_not_in_hero1 OF my_game. - AND target NOT IN worn - ELSE SAY check_obj_not_in_worn2 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND target IS reachable AND target IS NOT distant - ELSE - IF target IS NOT reachable - THEN - IF target IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF target IS distant - THEN - IF target IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES "Resorting to brute force is not the solution here." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL (+ murder) - - --- ============================================================== - - -SYNTAX kill = kill (victim) - WHERE victim ISA ACTOR - ELSE - IF victim IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY ACTOR - VERB kill - CHECK victim <> hero - ELSE SAY check_obj_not_hero2 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL WITH - - --- ============================================================== - - -SYNTAX kill_with = kill (victim) 'with' (weapon) - WHERE victim ISA ACTOR - ELSE - IF victim IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN SAY illegal_parameter_with_sg OF my_game. - ELSE SAY illegal_parameter_with_pl OF my_game. - END IF. - - -ADD TO EVERY ACTOR - VERB kill_with - WHEN victim - CHECK victim <> hero - ELSE SAY check_obj_not_hero2 OF my_game. - AND weapon IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ KISS (+ hug, embrace) - - --- ============================================================== - - -SYNTAX kiss = kiss (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB kiss - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj <> hero - ELSE SAY check_obj_not_hero6 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - IF obj ISA ACTOR - THEN SAY THE obj. "avoids your advances." - ELSE "Nothing would be achieved by that." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS hug, embrace = kiss. - - - --- ============================================================== - - ------ KNOCK - - --- ============================================================== - - -SYNTAX knock = knock 'on' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_on_sg OF my_game. - ELSE SAY illegal_parameter_on_pl OF my_game. - END IF. - - knock = knock (obj). - - -ADD TO EVERY OBJECT - VERB knock - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_on_sg OF my_game. - ELSE SAY check_obj_suitable_on_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You knock on" SAY THE obj. "$$. Nothing happens." - END VERB. -END ADD TO. - - ---- another 'knock' formulation added to guide players to use the right phrasing: - - -SYNTAX knock_error = knock. - - -VERB knock_error - DOES - "Please use the formulation KNOCK ON SOMETHING to knock on something." -END VERB. - - - --- ============================================================== - - ------ LIE DOWN - - --- ============================================================== - - -SYNTAX lie_down = lie 'down'. - - lie_down = lie. - - -VERB lie_down - CHECK hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down4 OF my_game. - DOES - "There's no need to lie down right now." - -- If you need this to work, insert the following lines instead of the above: - -- DOES "You lie down." - -- MAKE hero lying_down. - -- MAKE hero NOT sitting_down. -END VERB. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE IN - - --- ============================================================== - - -SYNTAX lie_in = lie 'in' (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_in_sg OF my_game. - ELSE SAY illegal_parameter_in_pl OF my_game. - END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN SAY illegal_parameter_in_sg OF my_game. - ELSE SAY illegal_parameter_in_pl OF my_game. - END IF. - - lie_in = lie 'down' 'in' (cont). - - -ADD TO EVERY OBJECT - VERB lie_in - CHECK hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down4 OF my_game. - DOES - "There's no need to lie down in" SAY THE cont. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down in" SAY THE cont. "." - -- LOCATE hero IN cont. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." - --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE ON - - --- ============================================================== - - -SYNTAX lie_on = lie 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN SAY illegal_parameter_on_sg OF my_game. - ELSE SAY illegal_parameter_on_pl OF my_game. - END IF. - - lie_on = lie 'down' 'on' (surface). - - -ADD TO EVERY OBJECT - VERB lie_on - CHECK hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down4 OF my_game. - DOES - "There's no need to lie down on" SAY THE surface. "." - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down on" SAY THE surface. "." - -- LOCATE hero IN surface. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIFT - - --- ============================================================== - - -SYNTAX lift = lift (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB lift - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj NOT IN hero - ELSE SAY check_obj_not_in_hero1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS movable - ELSE SAY check_obj_movable OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND weight OF obj < 50 - ELSE - IF obj IS NOT PLURAL - THEN SAY check_obj_weight_sg OF my_game. - ELSE SAY check_obj_weight_pl OF my_game. - END IF. - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LIGHT (+ lit) - - --- ============================================================== - - -SYNTAX light = light (obj) - WHERE obj ISA LIGHTSOURCE - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB light - CHECK obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - END VERB. -END ADD TO. - - -SYNONYMS lit = light. - - - --- ============================================================== - - ------ LISTEN - - --- ============================================================== - - -SYNTAX listen0 = listen. - - -VERB listen0 - DOES - "You hear nothing unusual." -END VERB. - - - --- ============================================================== - - ------ LISTEN TO - - --- ============================================================== - - -SYNTAX listen = listen 'to' (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_to_sg OF my_game. - ELSE SAY illegal_parameter_to_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB listen - CHECK obj <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - DOES - IF obj AT hero - THEN "You hear nothing unusual." - ELSIF obj NEAR hero - THEN "You can't hear" SAY THE obj. "very well from here." - ELSE "You can't hear anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK - - --- ============================================================== - - -SYNTAX lock = lock (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB lock - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND obj IS NOT locked - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_locked1_sg OF my_game. - ELSE SAY check_obj_not_locked1_pl OF my_game. - END IF. - DOES - IF matching_key OF obj IN hero - THEN MAKE obj locked. - "(with" SAY THE matching_key OF obj. "$$)$n" - "You" - - IF obj IS NOT closed - THEN "close and" - MAKE obj closed. - END IF. - - "lock" SAY THE obj. "." - ELSE "You have to state what you want to lock" SAY THE obj. "with." - END IF. - - -- If you need this to work, use the following lines instead: - -- MAKE obj locked. "You" - -- IF obj IS NOT closed - -- THEN "close and" - -- MAKE obj closed. - -- END IF. - -- "lock" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK WITH - - --- ============================================================== - - -SYNTAX lock_with = lock (obj) 'with' (key) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND key ISA OBJECT - ELSE - IF key IS NOT plural - THEN SAY illegal_parameter2_with_sg OF my_game. - ELSE SAY illegal_parameter2_with_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB lock_with - WHEN obj - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND key IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS NOT locked - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_locked1_sg OF my_game. - ELSE SAY check_obj_not_locked1_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND key IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND key = matching_key OF obj - ELSE SAY check_door_matching_key OF my_game. - DOES - MAKE obj locked. "You" - - IF obj IS NOT closed - THEN "close and" - MAKE obj closed. - END IF. - - "lock" SAY THE obj. "with" SAY THE key. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK - - --- ============================================================== - - -SYNTAX 'look' = 'look'. - - -VERB 'look' - DOES - LOOK. - INCREASE described OF CURRENT LOCATION. - -- see 'locations.i', attribute 'described'. -END VERB. - - -SYNONYMS l = 'look'. - - - --- ============================================================== - - ------ LOOK AT -> see EXAMINE - - --- ============================================================== - - - - - --- ============================================================== - - ------ LOOK BEHIND - - --- ============================================================== - - -SYNTAX look_behind = 'look' behind (bulk) - WHERE bulk ISA THING - ELSE SAY illegal_parameter_there OF my_game. - - -ADD TO EVERY THING - VERB look_behind - CHECK bulk IS examinable - ELSE SAY check_obj_suitable_there OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND bulk <> hero - ELSE SAY check_obj_not_hero7 OF my_game. - DOES - "You notice nothing unusual behind" SAY THE bulk. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK IN - - --- ============================================================== - - -SYNTAX - look_in = 'look' 'in' (cont) - WHERE cont ISA OBJECT - ELSE SAY illegal_parameter_there OF my_game. - AND cont ISA CONTAINER - ELSE SAY illegal_parameter_there OF my_game. - - -ADD TO EVERY OBJECT - VERB look_in - CHECK cont IS examinable - ELSE SAY check_obj_suitable_there OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND cont IS NOT closed - ELSE - IF cont IS NOT plural - THEN SAY check_obj_not_closed2_sg OF my_game. - ELSE SAY check_obj_not_closed2_pl OF my_game. - END IF. - DOES - LIST cont. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK OUT OF - - --- ============================================================== - - -SYNTAX look_out_of = 'look' 'out' 'of' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_look_out_sg OF my_game. - ELSE SAY illegal_parameter_look_out_pl OF my_game. - END IF. - - - -ADD TO EVERY OBJECT - VERB look_out_of - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_look_out_sg OF my_game. - ELSE SAY check_obj_suitable_look_out_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look out of." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK THROUGH - - --- ============================================================== - - -SYNTAX look_through = 'look' through (bulk) - WHERE bulk ISA THING - ELSE SAY illegal_parameter_look_through OF my_game. - - - -ADD TO EVERY THING - VERB look_through - CHECK bulk IS examinable - ELSE SAY check_obj_suitable_look_through OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "You can't see through" SAY THE bulk. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UNDER - - --- ============================================================== - - -SYNTAX look_under = 'look' under (bulk) - WHERE bulk ISA THING - ELSE SAY illegal_parameter_there OF my_game. - - - -ADD TO EVERY THING - VERB look_under - CHECK bulk IS examinable - ELSE SAY check_obj_suitable_there OF my_game. - AND bulk <> hero - ELSE SAY check_obj_not_hero8 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "You notice nothing unusual under" SAY THE bulk. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UP (-> see also CONSULT) - - --- ============================================================== - - -SYNTAX look_up = 'look' up. - - -VERB look_up - DOES "Looking up, you see nothing unusual." -END VERB. - - - --- ============================================================== - - ------ NO - - --- ============================================================== - - -SYNTAX 'no' = 'no'. - - -VERB 'no' - DOES "Really?" -END VERB. - - - --- ============================================================== - - ------ NOTIFY - - --- ============================================================== - - --- Thanks to Steve Griffiths whose 'Score notification' sample was used --- in declaring this verb. - - - -SYNTAX notify = notify. - - notify_on = notify 'on'. - -- The instructions tell the player that mere 'notify' - -- is enough, but these two verbs are implemented - notify_off = notify 'off'. - -- In case (s)he adds the prepositions to the end anyway. - - -VERB notify - DOES - IF hero IS notify_on - THEN MAKE hero NOT notify_on. - "Score notification is now disabled. (You can turn it back on - using the NOTIFY command again.)" - ELSE MAKE hero notify_on. "Score notification is now enabled. - (You can turn it off using the NOTIFY command again.)" - END IF. -END VERB. - - -VERB notify_on - DOES - IF hero IS notify_on - THEN "Score notification is already enabled." - ELSE MAKE hero notify_on. - "Score notification is now enabled. - (You can turn it off using the NOTIFY command again.)" - END IF. -END VERB. - - -VERB notify_off - DOES - IF hero IS notify_on - THEN MAKE hero NOT notify_on. - "Score notification is now disabled. (You can turn it back on - using the NOTIFY command again.)" - ELSE "Score notification is already disabled." - END IF. -END VERB. - - --- The 'notify' verb allows the players to disable the score change --- messages. (Some players find such messages annoying.) --- The verb toggles the hero's 'notify_on' attribute on and off. That --- attribute is checked by the 'checkscore' event to determine whether --- to display the score msg or not. - - --- The following event is run each turn to check if the game score is greater than --- the last recorded score (which is stored in the Hero's 'oldscore' --- attribute). If the score is greater, then the 'Score has gone up...' --- text is displayed (as long as the player hasn't disabled it by using the --- 'notify' verb - which sets 'notify_on' to off --- - i.e. the hero 'IS NOT notify_on'.) - --- NOTE: The ALAN scoring system records the game score in a thing called --- score. It isn't called score OF anything; its just 'score'. - --- NOTE: This event assumes score can only increase, if score can go --- down then you would need to modify this code a bit. - - -EVENT check_score - IF oldscore OF hero < score - THEN - IF hero IS notify_on - THEN - -- ie: the player wants to see score msgs - "$p(Your score has just gone up by" SAY (score - oldscore OF hero). - IF (score - oldscore OF hero) = 1 - THEN "point.)" - ELSE "points.)" - END IF. - -- this msg only displayed the first time player is notified - -- of a score change - IF hero IS NOT seen_notify - THEN MAKE hero seen_notify. - "$p(You can use the NOTIFY command to disable score change messages.)" - END IF. - END IF. - - SET oldscore OF hero TO score. - END IF. - -- run the 'check_score' event again next turn: - SCHEDULE check_score AT hero AFTER 1. -END EVENT. - - - - --- ============================================================== - - ------ OPEN - - --- ============================================================== - - -SYNTAX open = open (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB open - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND obj IS closed - ELSE SAY THE obj. - IF obj IS NOT plural - THEN SAY check_obj_closed_sg OF my_game. - ELSE SAY check_obj_closed_pl OF my_game. - END IF. - AND obj IS NOT locked - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_locked2_sg OF my_game. - ELSE SAY check_obj_not_locked2_pl OF my_game. - END IF. - DOES - MAKE obj NOT closed. - "You open" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ OPEN WITH - - --- ============================================================== - - -SYNTAX open_with = open (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND instr ISA OBJECT - ELSE - IF instr IS NOT plural - THEN SAY illegal_parameter2_with_sg OF my_game. - ELSE SAY illegal_parameter2_with_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB open_with - WHEN obj - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND instr IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND instr IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND obj IS closed - ELSE SAY THE obj. - IF obj IS NOT plural - THEN SAY check_obj_closed_sg OF my_game. - ELSE SAY check_obj_closed_pl OF my_game. - END IF. - "already open." - AND obj IS NOT locked - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_locked2_sg OF my_game. - ELSE SAY check_obj_not_locked2_pl OF my_game. - END IF. - - DOES - "You can't open" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY - - --- ============================================================== - - -SYNTAX 'play' = 'play' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB 'play' - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can play." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY WITH - - --- ============================================================== - - -SYNTAX play_with = 'play' 'with' (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_with_sg OF my_game. - ELSE SAY illegal_parameter_with_pl OF my_game. - END IF. - - - -ADD TO EVERY THING - VERB play_with - CHECK obj <> hero - ELSE SAY check_obj_not_hero6 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_with_sg OF my_game. - ELSE SAY check_obj_suitable_with_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "After second thought you don't find it purposeful to start - playing with" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR, POUR IN, POUR ON - - --- ============================================================== - - - --- => SEE EMPTY, EMPTY IN, EMPTY ON - - - - --- ============================================================== - - ------ PRAY - - --- ============================================================== - - -SYNTAX pray = pray. - - -VERB pray - DOES "Your prayers don't seem to help right now." -END VERB. - - - --- ============================================================== - - ------ PRY - - --- ============================================================== - - -SYNTAX pry = pry (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB pry - DOES "You must state what you want to pry" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PRY_WITH - - --- ============================================================== - - -SYNTAX pry_with = pry (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND instr ISA OBJECT - ELSE SAY illegal_parameter_with_sg OF my_game. - - -ADD TO EVERY OBJECT -VERB pry_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND instr IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND obj <> instr - ELSE "You can't pry something with itself." - AND instr IN hero - ELSE "You don't have" SAY THE instr. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES "That doesn't work." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PULL - - --- ============================================================== - - -SYNTAX pull = pull (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB pull - CHECK obj IS movable - ELSE SAY check_obj_movable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUSH - - --- ============================================================== - - -SYNTAX push = push (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB push - CHECK obj IS movable - ELSE SAY check_obj_movable OF my_game. - AND obj <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - AND obj IS inanimate - ELSE SAY check_obj_inanimate1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You give" SAY THE obj. "a little push. Nothing happens." - END VERB. -END ADD TO. - - -SYNONYMS press = push. - - - --- ============================================================== - - ------ PUSH WITH - - --- ============================================================== - - -SYNTAX push_with = push (obj) 'with' (instr) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND instr ISA OBJECT - ELSE SAY illegal_parameter2_with_sg OF my_game. - - -ADD TO EVERY THING - VERB push_with - WHEN obj - CHECK obj IS movable - ELSE SAY check_obj_movable OF my_game. - AND obj <> instr - ELSE SAY check_obj_not_obj2_with OF my_game. - AND instr IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND instr IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND obj <> hero - ELSE SAY check_obj_not_hero1 OF my_game. "with something." - AND obj IS inanimate - ELSE SAY check_obj_inanimate1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT (+ lay, locate, place) - - --- ============================================================== - - -SYNTAX put = put (obj) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - - - -ADD TO EVERY OBJECT - VERB put - CHECK obj IN HERO - ELSE SAY check_obj_in_hero OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "You must state where you want to put" - - IF obj IS NOT plural - THEN "it." - ELSE "them." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS lay, place = put. - - - --- ============================================================== - - ------ PUT DOWN (works as 'drop') - - --- ============================================================== - - ------ The syntax for 'put down' has been declared in the 'drop' verb. - - - - --- ============================================================== - - ------ PUT IN (+ insert) - - --- ============================================================== - - -SYNTAX put_in = put (obj) 'in' (cont) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND cont ISA OBJECT - ELSE SAY illegal_parameter2_there OF my_game. - AND cont ISA CONTAINER - ELSE SAY illegal_parameter2_there OF my_game. - - - put_in = insert (obj) 'in' (cont). - - -ADD TO EVERY OBJECT - VERB put_in - WHEN obj - CHECK obj <> cont - ELSE SAY check_obj_not_obj2_in OF my_game. - AND obj IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND obj NOT IN cont - ELSE - IF cont ISA SUPPORTER - THEN SAY check_cont_not_supporter OF my_game. - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_in_cont_sg OF my_game. - ELSE SAY check_obj_not_in_cont_pl OF my_game. - END IF. - END IF. - AND cont IS reachable AND cont IS NOT distant - ELSE - IF cont IS NOT reachable - THEN - IF cont IS NOT plural - THEN SAY check_obj2_reachable_sg OF my_game. - ELSE SAY check_obj2_reachable_pl OF my_game. - END IF. - ELSIF cont IS distant - THEN - IF cont IS NOT plural - THEN SAY check_obj2_not_distant_sg OF my_game. - ELSE SAY check_obj2_not_distant_pl OF my_game. - END IF. - END IF. - AND cont IS NOT closed - ELSE - IF cont IS NOT plural - THEN SAY check_obj2_not_closed_sg OF my_game. - ELSE SAY check_obj2_not_closed_pl OF my_game. - END IF. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - LOCATE obj IN cont. - "You put" SAY THE obj. "into" SAY THE cont. "." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ PUT AGAINST, BEHIND, NEAR, UNDER - - --- ============================================================== - - -SYNTAX put_against = put (obj) against (bulk) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND bulk ISA THING - ELSE SAY illegal_parameter2_there OF my_game. - - - -SYNTAX put_behind = put (obj) behind (bulk) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND bulk ISA THING - ELSE SAY illegal_parameter2_there OF my_game. - - - -SYNTAX put_near = put (obj) 'near' (bulk) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND bulk ISA THING - ELSE SAY illegal_parameter2_there OF my_game. - - - -SYNTAX put_under = put (obj) under (bulk) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND bulk ISA THING - ELSE SAY illegal_parameter2_there OF my_game. - - - -ADD TO EVERY OBJECT - VERB put_against, put_behind, put_near, put_under - WHEN obj - CHECK bulk NOT IN hero - ELSE SAY check_obj2_not_in_hero2 OF my_game. - AND obj IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND obj <> bulk - ELSE SAY check_obj_not_obj2_put OF my_game. - AND bulk <> hero - ELSE SAY check_obj2_not_hero2 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND bulk IS reachable AND bulk IS NOT distant - ELSE - IF bulk IS NOT reachable - THEN - IF bulk IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF bulk IS distant - THEN - IF bulk IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "That wouldn't accomplish anything." - - -- To make it work, type e.g.: - -- IF obj NOT IN hero - -- THEN SAY implicit_taking_message OF my_game. - -- END IF. - -- "You put" SAY THE obj. "against" --(or near or behind or under) SAY THE bulk. "." - -- (+ you would need to define some attributes to check that - -- the object is behind another object, etc.) - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT_ON - - --- ============================================================== - - --- To use this verb in the meaning 'wear', see the file 'classes.i', --- class 'clothing', verb 'wear'. - --- You can put things on the floor/ground (= drop them) or on a supporter. In other --- cases, the response will be "That wouldn't accomplish anything." - - - -SYNTAX put_on = put (obj) 'on' (surface) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND surface ISA SUPPORTER - ELSE SAY illegal_parameter_there OF my_game. - - - -ADD TO EVERY OBJECT - VERB put_on - WHEN obj - CHECK surface NOT IN hero - ELSE SAY check_obj2_not_in_hero2 OF my_game. - AND obj IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND obj <> surface - ELSE SAY check_obj_not_obj2_on OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj NOT IN surface - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_on_surface_sg OF my_game. - ELSE SAY check_obj_not_on_surface_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND surface IS reachable AND surface IS NOT distant - ELSE - IF surface IS NOT reachable - THEN - IF surface IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF surface IS distant - THEN - IF surface IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF surface = floor OR surface = ground - THEN LOCATE obj AT hero. - "You put" SAY THE obj. "on" SAY THE surface. "." - ELSE LOCATE obj IN surface. - "You put" SAY THE obj. "on" SAY THE surface. "." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT OUT (works as -> EXTINGUISH) - - --- ============================================================== - - ------ The syntax for 'put out' has been declared in the 'extinguish' verb. - - - --- ============================================================== - - ------ QUIT - - --- ============================================================== - - -SYNTAX - 'quit' = 'quit'. - - -VERB 'quit' - DOES - QUIT. -END VERB. - - -SYNONYMS q = 'quit'. - - - --- ============================================================== - - ------ READ - - --- ============================================================== - - -SYNTAX read = read (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB read - CHECK obj IS readable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - IF text OF obj = "" - THEN "There's nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. "." - - IF obj IS NOT plural - THEN "It says" - ELSE "They say" - END IF. - - """$$" SAY text OF obj. "$$""." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - --- REMOVE - - --- ============================================================== - - - -SYNTAX remove = remove (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. "since you're not wearing it." - ELSE SAY illegal_parameter_pl OF my_game. "since you're not wearing them." - END IF. - remove = take 'off' (obj). - remove = take (obj) 'off'. - remove = doff (obj). - - -ADD TO EVERY OBJECT - VERB remove - DOES - IF obj IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - - "not something you can remove since you're not wearing" - - IF obj IS NOT plural - THEN "it." - ELSE "them." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ REMOVE FROM ( => TAKE FROM) - - --- ============================================================== - - ------ this verb works as 'take from' - - - --- ============================================================== - - ------ RESTART - - --- ============================================================== - - -SYNTAX 'restart' = 'restart'. - - -VERB 'restart' - DOES - RESTART. -END VERB. - - - --- ============================================================== - - ------ RESTORE - - --- ============================================================== - - -SYNTAX 'restore' = 'restore'. - - -VERB 'restore' - DOES - RESTORE. -END VERB. - - - --- ============================================================== - - ------ RUB (+ massage) - - --- ============================================================== - - -SYNTAX rub = rub (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB rub - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj <> hero - ELSE SAY check_obj_not_hero6 OF my_game. - AND obj IS inanimate - ELSE SAY check_obj_inanimate2 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS massage = rub. - - - --- ============================================================== - - ------ SAVE - - --- ============================================================== - - -SYNTAX 'save' = 'save'. - - -VERB 'save' - DOES - SAVE. -END VERB. - - - --- ============================================================== - - ------ SAY - - --- ============================================================== - - -SYNTAX 'say' = 'say' (topic) - WHERE topic ISA STRING - ELSE SAY illegal_parameter_string OF my_game. - - -ADD TO EVERY STRING - VERB 'say' - DOES - "Nothing happens." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ SAY TO - - --- ============================================================== - - -SYNTAX say_to = 'say' (topic) 'to' (act) - WHERE topic ISA STRING - ELSE SAY illegal_parameter_string OF my_game. - AND act ISA ACTOR - ELSE - IF act IS NOT plural - THEN SAY illegal_parameter_talk_sg OF my_game. - ELSE SAY illegal_parameter_talk_pl OF my_game. - END IF. - - -ADD TO EVERY ACTOR - VERB say_to - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN SAY check_act_can_talk_sg OF my_game. - ELSE SAY check_act_can_talk_pl OF my_game. - END IF. - AND act IS NOT distant - ELSE - IF act IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - DOES - SAY THE act. - IF act IS NOT plural - THEN "doesn't look" - ELSE "don't look" - END IF. - "interested." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SCORE - - --- ============================================================== - - -SYNTAX 'score' = 'score'. - - -VERB 'score' - DOES - SCORE. - -- (or, if you wish to disable the score, use the following kind of - -- line instead of the above: - -- "There is no score in this game.") -END VERB 'score'. - - - --- ============================================================== - - ------ SCRATCH - - --- ============================================================== - - -SYNTAX scratch = scratch (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB scratch - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj IS inanimate - ELSE SAY check_obj_inanimate1 OF my_game. - AND obj <> hero - ELSE SAY check_obj_not_hero3 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------- SCRIPT - - --- ============================================================== - - -SYNTAX 'script' = 'script'. - script_on = 'script' 'on'. - script_off = 'script' 'off'. - -SYNONYMS 'transcript' = 'script'. - -VERB 'script' - DOES - "You can turn transcripting on and off using the 'script on/off' command within the game. - The transcript will be available in a file with a name starting with the game name. - $pIn a GUI version you can also find this in the drop-down menu in the interpreter. - $pIn a command line version you can start your game with the '-s' switch to get a transcript - of the whole game." -END VERB. - -VERB script_on - DOES - TRANSCRIPT ON. - "Transcripting turned on." -END VERB. - -VERB script_off - DOES - TRANSCRIPT OFF. - "Transcripting turned off." -END VERB. - - - --- ============================================================== - - ------- SEARCH - - --- ============================================================== - - -SYNTAX search = search (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB search - CHECK obj <> hero - ELSE LIST hero. - AND obj IS inanimate - ELSE SAY check_obj_inanimate1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You find nothing of interest." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SELL - - --- ============================================================== - - -SYNTAX sell = sell (item) - WHERE item ISA OBJECT - ELSE - IF item IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB sell - CHECK item IS examinable - ELSE - IF item IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - DOES - "There's nobody here who would be interested in buying" SAY THE item. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHAKE - - --- ============================================================== - - -SYNTAX shake = shake (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - - -ADD TO EVERY OBJECT - VERB shake - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj IS movable - ELSE SAY check_obj_movable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - IF obj IN hero - THEN "You shake" SAY THE obj. "cautiously in your hands. Nothing happens." - ELSE "There is no reason to start shaking" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOOT - - --- ============================================================== - - - -SYNTAX shoot = shoot (target) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - shoot = shoot 'at' (target). - - -ADD TO EVERY THING - VERB shoot - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND target <> hero - ELSE SAY check_obj_not_hero2 OF my_game. - AND COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE SAY check_count_weapon_in_act OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "Resorting to violence is not the solution here." - END VERB. -END ADD TO. - - --- another 'shoot' formulation added, to guide players to use the right phrasing: - - -SYNTAX shoot_error = shoot. - - -VERB shoot_error - DOES - "You must state what you want to shoot, e.g. SHOOT BEAR WITH RIFLE." -END VERB. - - - --- ============================================================== - - ------ SHOOT WITH - - --- ============================================================== - - -SYNTAX shoot_with = shoot (target) 'with' (weapon) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN SAY illegal_parameter2_with_sg OF my_game. - ELSE SAY illegal_parameter2_with_pl OF my_game. - END IF. - - shoot_with = shoot (weapon) 'at' (target). - -- to allow player input such as 'shoot rifle at bear' - - -ADD TO EVERY THING - VERB shoot_with - WHEN target - CHECK weapon IN hero - ELSE SAY check_obj_takeable OF my_game. - AND target IS examinable - ELSE - IF target IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND target <> hero - ELSE SAY check_obj_not_hero2 OF my_game. - AND target <> weapon - ELSE SAY check_obj_not_obj2_with OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "Resorting to violence is not the solution here." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOUT - - --- ============================================================== - - -SYNTAX shout = shout. - - -VERB shout - DOES - "Nothing results from your $ving." -END VERB. - - -SYNONYMS scream, yell = shout. - - - --- ============================================================== - - ------ SHOW - - --- ============================================================== - - -SYNTAX 'show' = 'show' (obj) 'to' (act) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND act ISA ACTOR - ELSE - IF act IS NOT plural - THEN SAY illegal_parameter2_to_sg OF my_game. - ELSE SAY illegal_parameter2_to_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB 'show' - WHEN obj - CHECK obj IN hero - ELSE SAY check_obj_in_hero OF my_game. - AND act <> hero - ELSE SAY check_obj2_not_hero1 OF my_game. - AND obj <> act - ELSE SAY check_obj_not_obj2_to OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - SAY THE act. - - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - - "not especially interested." - END VERB. -END ADD TO. - - -SYNONYMS reveal = 'show'. - - - --- ============================================================== - - ------ SING (+ hum, whistle) - - --- ============================================================== - - -SYNTAX sing = sing. - - -VERB sing - DOES - "You $v a little tune." -END VERB. - - -SYNONYMS hum, whistle = sing. - - - --- ============================================================== - - ------ SIP - - --- ============================================================== - - -SYNTAX sip = sip (liq) - WHERE liq ISA LIQUID - ELSE - IF liq IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY LIQUID - VERB sip - CHECK liq IS drinkable - ELSE - IF liq IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND liq IS reachable AND liq IS NOT distant - ELSE - IF liq IS NOT reachable - THEN - IF liq IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF liq IS distant - THEN - IF liq IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - IF vessel OF liq = null_vessel - -- here, if the liquid is in no container, e.g. - -- the hero takes a sip of water from a river, - -- the action is allowed to succeed. - THEN "You take a sip of" SAY THE liq. "." - ELSE - -- implicit taking: - IF vessel OF liq NOT DIRECTLY IN hero - THEN - IF vessel OF liq IS NOT takeable - THEN "It's not worth the bother trying to take a sip of" SAY THE liq. "." - ELSE LOCATE vessel OF liq IN hero. - "(taking" SAY THE vessel OF liq. "first)$n" - END IF. - END IF. - -- end of implicit taking. - END IF. - - IF liq IN hero -- i.e. if the implicit taking was successful - THEN - IF vessel OF liq IS closed - THEN "You can't, since" SAY THE vessel OF liq. "is closed." - ELSE "You take a sip of" SAY THE liq. "." - END IF. - END IF. - - END VERB. -END ADD TO. - - --- See also the verb 'drink'. - - --- ============================================================== - - ------ SIT - - --- ============================================================== - - -SYNTAX sit = sit. - - sit = sit 'down'. - - -VERB sit - CHECK hero IS NOT sitting - ELSE SAY check_hero_not_sitting4 OF my_game. - DOES - "You feel no urge to sit down at present." - -- (or, if you wish to make it work, use the following instead of the above: - -- IF hero IS lying_down - -- THEN "You sit up." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down." - -- END IF. - -- MAKE hero sitting. -END VERB. - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SIT_ON - - --- ============================================================== - - -SYNTAX sit_on = sit 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN SAY illegal_parameter_on_sg OF my_game. - ELSE SAY illegal_parameter_on_pl OF my_game. - END IF. - - -ADD TO EVERY SUPPORTER - VERB sit_on - CHECK hero IS NOT sitting - ELSE SAY check_hero_not_sitting4 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND surface IS reachable AND surface IS NOT distant - ELSE - IF surface IS NOT reachable - THEN - IF surface IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF surface IS distant - THEN - IF surface IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You feel no urge to sit down at present." - - -- (or, to make it work, use the following instead of the above:) - -- IF hero lying_down - -- THEN "You get up and sit down on" SAY THE surface. "." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down on" SAY THE surface. "." - -- END IF. - -- LOCATE hero IN surface. - -- MAKE hero sitting. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SLEEP (+ rest) - - --- ============================================================== - - -SYNTAX sleep = sleep. - - -VERB sleep - DOES - "There's no need to $v right now." -END VERB. - - -SYNONYMS rest = sleep. - - - --- ============================================================== - - ------ SMELL (smell0) - - --- ============================================================== - - -SYNTAX smell0 = smell. - - -VERB smell0 - DOES - "You smell nothing unusual." -END VERB. - - - --- ============================================================== - - ------ SMELL (+ obj) - - --- ============================================================== - - -SYNTAX smell = smell (odour)! - WHERE odour ISA THING - ELSE - IF odour IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB smell - DOES - "You smell nothing unusual." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SQUEEZE - - --- ============================================================== - - -SYNTAX squeeze = squeeze (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB squeeze - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "Trying to squeeze" SAY THE obj. "wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ STAND - - --- ============================================================== - - -SYNTAX stand = stand. - - stand = stand 'up'. - - -VERB stand - DOES - IF hero IS sitting OR hero IS lying_down - THEN "You get up." - MAKE hero NOT sitting. - MAKE hero NOT lying_down. - ELSE "You're standing up already." - END IF. -END VERB. - - - --- ============================================================== - - ------ STAND_ON - - --- ============================================================== - - -SYNTAX stand_on = stand 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN SAY illegal_parameter_on_sg OF my_game. - ELSE SAY illegal_parameter_on_pl OF my_game. - END IF. - stand_on = get 'on' (surface). - - -ADD TO EVERY SUPPORTER - VERB stand_on - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND surface IS reachable AND surface IS NOT distant - ELSE - IF surface IS NOT reachable - THEN - IF surface IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF surface IS distant - THEN - IF surface IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You feel no urge to stand on" SAY THE surface. "." - -- or, to make it work, use the following instead of the above: - -- "You get on" SAY THE surface. "." - -- LOCATE hero IN surface. - -- MAKE hero NOT sitting. MAKE hero NOT lying_down. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWIM - - --- ============================================================== - - -SYNTAX swim = swim. - - -VERB swim - CHECK hero IS NOT sitting - ELSE SAY check_hero_not_sitting1 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - "There is no water suitable for swimming here." -END VERB. - - - --- ============================================================== - - ------ SWIM IN - - --- ============================================================== - - -SYNTAX swim_in = swim 'in' (liq) - WHERE liq ISA LIQUID - ELSE - IF liq IS NOT plural - THEN SAY illegal_parameter_in_sg OF my_game. - ELSE SAY illegal_parameter_in_pl OF my_game. - END IF. - - - -ADD TO EVERY OBJECT - VERB swim_in - CHECK hero IS NOT sitting - ELSE SAY check_hero_not_sitting1 OF my_game. - AND hero IS NOT lying_down - ELSE SAY check_hero_not_lying_down3 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND liq IS reachable AND liq IS NOT distant - ELSE - IF liq IS NOT reachable - THEN - IF liq IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF liq IS distant - THEN - IF liq IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "something you can swim in." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH - - --- ============================================================== - - --- This is a mere 'switch' verb with no 'on' or 'off' following after it. --- This verb is defined further in 'classes.i', under 'device' and 'lightsource'. --- This verb exists just to cover cases where the player forgets to write --- 'on' or 'off' after 'switch'. --- If the player types 'switch tv', the tv object will be switched on --- if it is off, and vice cersa. --- Below, just the basic syntax is declared. - - - -SYNTAX switch = switch (app) -- app = apparatus, appliance - WHERE app ISA THING - ELSE - IF app IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB switch - DOES - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "not something you can switch." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH ON - - --- ============================================================== - - ------ The syntax for 'switch on' has been declared in the 'turn_on' verb. - - - - --- ============================================================== - - ------ SWITCH OFF - - --- ============================================================== - - ------ The syntax for 'switch off' has been declared in the 'turn_off' verb. - - - - --- ============================================================== - - ------ TAKE (+ carry, get, grab, hold, obtain, pick up) - - --- ============================================================== - - -SYNTAX take = take (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - take = get (obj). - - take = pick up (obj). - - take = pick (obj) up. - - -ADD TO EVERY OBJECT - VERB take - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS NOT scenery - ELSE SAY check_obj_not_scenery OF my_game. - AND obj IS movable - ELSE SAY check_obj_movable OF my_game. - AND obj IS takeable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj NOT DIRECTLY IN hero - -- i.e. the object to be taken is not carried by the hero already - ELSE SAY check_obj_not_in_hero2 OF my_game. - AND obj NOT DIRECTLY IN worn - -- i.e. the object to be taken is a piece of clothing that the player character is wearing; - -- here, this verb works in practise like 'take off'. - ELSE - LOCATE obj IN hero. - IF obj IS NOT plural - THEN SAY check_obj_not_in_worn3_sg OF my_game. - ELSE SAY check_obj_not_in_worn3_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND weight Of obj < 50 - ELSE - IF obj IS NOT plural - THEN SAY check_obj_weight_sg OF my_game. - ELSE SAY check_obj_weight_pl OF my_game. - END IF. - DOES - "Taken." - LOCATE obj IN hero. - END VERB. -END ADD TO. - - -SYNONYMS - carry, grab, hold, obtain = take. - - - --- ============================================================== - - ------ TAKE FROM - - --- ============================================================== - - -SYNTAX take_from = 'take' (obj) 'from' (holder) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND holder ISA THING - ELSE - IF holder IS NOT plural - THEN SAY illegal_parameter2_from_sg OF my_game. - ELSE SAY illegal_parameter2_from_pl OF my_game. - END IF. - AND holder ISA CONTAINER - ELSE - IF holder IS NOT plural - THEN SAY illegal_parameter2_from_sg OF my_game. - ELSE SAY illegal_parameter2_from_pl OF my_game. - END IF. - - take_from = remove (obj)* 'from' (holder). - - take_from = get (obj) 'from' (holder). - - -ADD TO EVERY OBJECT - VERB take_from - WHEN obj - CHECK holder <> hero - ELSE SAY check_obj2_not_hero1 OF my_game. - AND obj NOT IN hero - ELSE SAY check_obj_not_in_hero2 OF my_game. - AND obj <> holder - ELSE SAY check_obj_not_obj2_from OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS NOT scenery - ELSE SAY check_obj_not_scenery OF my_game. - AND obj IS movable - ELSE SAY check_obj_movable OF my_game. - AND obj IS takeable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND weight Of obj < 50 - ELSE - IF obj IS NOT plural - THEN SAY check_obj_weight_sg OF my_game. - ELSE SAY check_obj_weight_pl OF my_game. - END IF. - AND holder IS reachable AND holder IS NOT distant - ELSE - IF holder IS NOT reachable - THEN - IF holder IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF holder IS distant - THEN - IF holder IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND obj IN holder - ELSE - IF holder IS inanimate - THEN - IF holder ISA SUPPORTER - THEN - IF obj IS NOT plural - THEN SAY check_obj_on_surface_sg OF my_game. - ELSE SAY check_obj_on_surface_pl OF my_game. - END IF. - ELSE - IF obj IS NOT plural - THEN SAY check_obj_in_cont_sg OF my_game. - ELSE SAY check_obj_in_cont_pl OF my_game. - END IF. - END IF. - - ELSE SAY THE holder. - IF holder IS NOT plural - THEN SAY check_obj_in_act_sg OF my_game. - ELSE SAY check_obj_in_act_pl OF my_game. - END IF. - - END IF. - AND holder IS NOT closed - ELSE - IF holder IS NOT plural - THEN SAY check_obj2_not_closed_sg OF my_game. - ELSE SAY check_obj2_not_closed_pl OF my_game. - END IF. - - DOES - LOCATE obj IN hero. - "You take" SAY THE obj. "from" SAY THE holder. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TALK - - --- ============================================================== - - -SYNTAX talk = talk. - - -VERB talk - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING - or TELL PERSON ABOUT THING." -END VERB. - - - --- ============================================================== - - ------ TALK_TO - - - --- ============================================================== - - -SYNTAX talk_to = talk 'to' (act) - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN SAY illegal_parameter_to_sg OF my_game. - ELSE SAY illegal_parameter_to_pl OF my_game. - END IF. - - -ADD TO EVERY ACTOR - VERB talk_to - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TASTE (+ lick) - - --- ============================================================== - - -SYNTAX taste = taste (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB taste - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj IS edible OR obj IS drinkable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You taste nothing unexpected." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TEAR (+ rip) - - --- ============================================================== - - -SYNTAX tear = tear (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB tear - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "Trying to $v" SAY THE obj. "would be futile." - END VERB. -END ADD TO. - - -SYNONYMS rip = tear. - - - --- ============================================================== - - ------ TELL (+ enlighten, inform) - - --- ============================================================== - - -SYNTAX tell = tell (act) about (topic)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN SAY illegal_parameter_to_sg OF my_game. - ELSE SAY illegal_parameter_to_pl OF my_game. - END IF. - AND topic ISA THING - ELSE - IF topic IS NOT plural - THEN SAY illegal_parameter_about_sg OF my_game. - ELSE SAY illegal_parameter_about_pl OF my_game. - END IF. - - -ADD TO EVERY ACTOR - VERB tell - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN SAY check_act_can_talk_sg OF my_game. - ELSE SAY check_act_can_talk_pl OF my_game. - END IF. - AND act IS NOT distant - ELSE - IF act IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - AND act <> hero - ELSE SAY check_obj_not_hero1 OF my_game. - DOES - SAY THE act. - - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - - "look interested." - - END VERB. -END ADD TO. - - -SYNONYMS enlighten, inform = tell. - - - --- ============================================================== - - ------ THINK (+ ponder, meditate, reflect) - - --- ============================================================== - - -SYNTAX think = think. - - -VERB think - DOES - "Nothing helpful comes to your mind." -END VERB. - - -SYNONYMS ponder, meditate, reflect = think. - - - --- ============================================================== - - ------ THINK ABOUT - - --- ============================================================== - - -SYNTAX think_about = think 'about' (topic)! - WHERE topic ISA THING - ELSE - IF topic IS NOT plural - THEN SAY illegal_parameter_about_sg OF my_game. - ELSE SAY illegal_parameter_about_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB think_about - DOES - "Nothing helpful comes to your mind." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW - - --- ============================================================== - - -SYNTAX throw = throw (projectile) - WHERE projectile ISA OBJECT - ELSE - IF projectile IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB throw - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND projectile IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND projectile IS reachable AND projectile IS NOT distant - ELSE - IF projectile IS NOT reachable - THEN - IF projectile IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF projectile IS distant - THEN - IF projectile IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - -- implicit taking: - IF projectile NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE projectile IN hero. - END IF. - -- end of implicit taking. - - "You can't throw very far;" SAY THE projectile. - - IF projectile IS NOT plural - THEN "ends up" - ELSE "end up" - END IF. - - IF floor HERE - THEN "on the floor" - ELSIF ground HERE - THEN "on the ground" - END IF. - - "nearby." - LOCATE projectile AT hero. - - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ THROW AT - - --- ============================================================== - - -SYNTAX throw_at = throw (projectile) 'at' (target) - WHERE projectile ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND target ISA THING - ELSE - IF target IS NOT plural - THEN SAY illegal_parameter2_at_sg OF my_game. - ELSE SAY illegal_parameter2_at_pl OF my_game. - END IF. - - - -ADD TO EVERY OBJECT - VERB throw_at - WHEN projectile - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND projectile IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND target IS examinable - ELSE - IF target IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. "things at." - ELSE SAY check_obj_suitable_pl OF my_game. "things at." - END IF. - AND projectile <> target - ELSE SAY check_obj_not_obj2_at OF my_game. - AND target NOT IN hero - ELSE SAY check_obj2_not_in_hero2 OF my_game. - AND target <> hero - ELSE SAY check_obj2_not_hero1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND projectile IS reachable AND projectile IS NOT distant - ELSE - IF projectile IS NOT reachable - THEN - IF projectile IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF projectile IS distant - THEN - IF projectile IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND target IS NOT distant - -- it is possible to throw something at an (otherwise) not reachable target! - ELSE - IF target IS NOT plural - THEN SAY check_obj2_not_distant_sg OF my_game. - ELSE SAY check_obj2_not_distant_pl OF my_game. - END IF. - DOES - -- implicit taking: - IF projectile NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE projectile IN hero. - END IF. - -- end of implicit taking. - - IF target IS inanimate - THEN - IF target NOT DIRECTLY AT hero - -- e.g. the target is inside a box - THEN "It wouldn't accomplish anything trying to throw something at" SAY THE target. "." - ELSE - SAY THE projectile. - - IF projectile IS NOT plural - THEN "bounces" - ELSE "bounce" - END IF. - - "harmlessly off" - - SAY THE target. "and" - - IF projectile IS NOT plural - THEN "ends up" - ELSE "end up" - END IF. - - IF floor HERE - THEN "on the floor" - ELSIF ground HERE - THEN "on the ground" - END IF. - - "nearby." - LOCATE projectile HERE. - END IF. - - ELSE SAY THE target. "wouldn't probably appreciate that." - - END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW TO - - --- ============================================================== - - -SYNTAX throw_to = throw (projectile) 'to' (recipient) - WHERE projectile ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND recipient ISA ACTOR - ELSE SAY illegal_parameter2_there OF my_game. - - -ADD TO EVERY OBJECT - VERB throw_to - WHEN projectile - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND projectile IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND recipient IS examinable - ELSE - IF recipient IS NOT plural - THEN SAY check_obj2_suitable_at_sg OF my_game. - ELSE SAY check_obj2_suitable_at_pl OF my_game. - END IF. - AND projectile <> recipient - ELSE SAY check_obj_not_obj2_to OF my_game. - AND recipient NOT IN hero - ELSE SAY check_obj2_not_in_hero1 OF my_game. - AND recipient <> hero - ELSE SAY check_obj2_not_hero1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND projectile IS reachable AND projectile IS NOT distant - ELSE - IF projectile IS NOT reachable - THEN - IF projectile IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF projectile IS distant - THEN - IF projectile IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND recipient IS NOT distant - ELSE - IF recipient IS NOT plural - THEN SAY check_obj2_not_distant_sg OF my_game. - ELSE SAY check_obj2_not_distant_pl OF my_game. - END IF. - DOES - -- implicit taking: - IF projectile NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE projectile IN hero. - END IF. - -- end of implicit taking. - - "You throw" SAY THE projectile. "to" SAY THE recipient. "who" - - IF recipient IS NOT plural - THEN "catches" - ELSE "catch" - END IF. - - IF projectile IS NOT plural - THEN "it." - ELSE "them." - END IF. - - LOCATE projectile IN recipient. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------- THROW IN - - --- ============================================================== - - -SYNTAX throw_in = throw (projectile) 'in' (cont) - WHERE projectile ISA OBJECT - ELSE - IF projectile IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND cont ISA OBJECT - ELSE SAY illegal_parameter2_there OF my_game. - AND cont ISA CONTAINER - ELSE SAY illegal_parameter2_there OF my_game. - - -ADD TO EVERY OBJECT - VERB throw_in - WHEN projectile - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND projectile IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND cont IS examinable - ELSE - IF cont IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. "things into." - ELSE SAY check_obj_suitable_pl OF my_game. "things into." - END IF. - AND projectile <> cont - ELSE SAY check_obj_not_obj2_in OF my_game. - AND cont <> hero - ELSE SAY check_obj2_not_hero1 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND projectile NOT IN cont - ELSE - IF projectile IS NOT plural - THEN SAY check_obj_not_in_cont_sg OF my_game. - ELSE SAY check_obj_not_in_cont_pl OF my_game. - END IF. - AND projectile IS reachable AND projectile IS NOT distant - ELSE - IF projectile IS NOT reachable - THEN - IF projectile IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF projectile IS distant - THEN - IF projectile IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - - AND cont IS NOT distant - ELSE - IF cont IS NOT plural - THEN SAY check_obj2_not_distant_sg OF my_game. - ELSE SAY check_obj2_not_distant_pl OF my_game. - END IF. - AND cont IS NOT closed - ELSE - IF cont IS NOT plural - THEN SAY check_obj2_not_closed_sg OF my_game. - ELSE SAY check_obj2_not_closed_pl OF my_game. - END IF. - DOES - "That wouldn't accomplish anything." - - -- To make it work, define: - - -- implicit taking: - -- IF obj NOT DIRECTLY IN hero - -- THEN SAY implicit_taking_message OF my_game. - -- LOCATE obj IN hero. - -- END IF. - -- end of implicit taking. - - -- LOCATE obj IN cont. - -- "You throw" SAY THE obj. "into" SAY THE cont. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE - - --- ============================================================== - - -SYNTAX tie = tie (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB tie - DOES - "You must state where you want to tie" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE TO - - --- ============================================================== - - -SYNTAX tie_to = tie (obj) 'to' (target) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND target ISA OBJECT - ELSE SAY illegal_parameter2_there OF my_game. - - - -ADD TO EVERY OBJECT - VERB tie_to - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND target IS examinable - ELSE SAY check_obj2_suitable_there OF my_game. - AND obj IS takeable - ELSE SAY check_obj_takeable OF my_game. - AND obj <> target - ELSE SAY check_obj_not_obj2_to OF my_game. - -- in the next two checks, it is prohibited to tie the hero to anything, - -- or anything to the hero: - AND obj <> hero - ELSE SAY check_obj_not_hero9 OF my_game. - AND target <> hero - ELSE SAY check_obj2_not_hero3 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND target IS reachable AND target IS NOT distant - ELSE - IF target IS NOT reachable - THEN - IF target IS NOT plural - THEN SAY check_obj2_reachable_sg OF my_game. - ELSE SAY check_obj2_reachable_pl OF my_game. - END IF. - ELSIF target IS distant - THEN - IF target IS NOT plural - THEN SAY check_obj2_not_distant_sg OF my_game. - ELSE SAY check_obj2_not_distant_pl OF my_game. - END IF. - END IF. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN SAY implicit_taking_message OF my_game. - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - LOCATE obj IN hero. - "It's not possible to tie" SAY THE obj. "to" SAY THE target. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TOUCH - - --- ============================================================== - - -SYNTAX touch = touch (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB touch - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND obj <> hero - ELSE SAY check_obj_not_hero3 OF my_game. - AND obj IS inanimate - ELSE SAY check_obj_inanimate2 OF my_game. "." - DOES - "You feel nothing unexpected." - END VERB. -END ADD TO. - - -SYNONYMS feel = touch. - - - --- ============================================================== - - ------ TOUCH WITH - - --- ============================================================== - - -SYNTAX touch_with = touch (obj) 'with' (instr) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND instr ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter2_with_sg OF my_game. - ELSE SAY illegal_parameter2_with_pl OF my_game. - END IF. - - -ADD TO EVERY THING - VERB touch_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND instr IS examinable - ELSE - IF instr IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND obj <> instr - ELSE SAY check_obj_not_obj2_with OF my_game. - AND instr <> hero - ELSE SAY check_obj2_not_hero1 OF my_game. - AND instr IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND obj IS inanimate - ELSE SAY check_obj_inanimate2 OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - "You touch" SAY THE obj. "with" SAY THE instr. ". Nothing special happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN (+ rotate) - - --- ============================================================== - - -SYNTAX turn = turn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - turn = rotate (obj). - -- We don't declare 'rotate' a synonym for 'turn' - -- through a SYNONYMS statement as we don't want - -- it to be possible for the player to type something - -- like 'rotate tv on' (see 'turn on' and 'turn off' below). - - -ADD TO EVERY OBJECT - VERB turn - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND obj IS movable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - - DOES - IF obj DIRECTLY IN hero - THEN "You turn" SAY THE obj. "in your hands but notice nothing special." - ELSE "That wouldn't accomplish anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN ON - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These classes are ------ defined in 'classes.i' with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. ------ Trying to turn on or off an ordinary object will default here to "That's not ------ something you can turn on". - - -SYNTAX turn_on = turn 'on' (app) - WHERE app ISA OBJECT - ELSE - IF app IS NOT plural - THEN SAY illegal_parameter_on_sg OF my_game. - ELSE SAY illegal_parameter_on_pl OF my_game. - END IF. - - turn_on = switch 'on' (app). - - turn_on = turn (app) 'on'. - - turn_on = switch (app) 'on'. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', classes 'device' and 'lightsource'. --- This verb merely covers cases where the player forgets (or doesn't bother) to type 'on' or 'off'. - - - -ADD TO EVERY OBJECT - VERB turn_on - DOES - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "something you can $v on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN OFF - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These classes ------ are defined in 'classes.i' with proper checks for 'on' and 'NOT on', ------ 'lit' and 'NOT lit'. - - -SYNTAX turn_off = turn off (app) - WHERE app ISA OBJECT - ELSE - IF app IS NOT plural - THEN SAY illegal_parameter_off_sg OF my_game. - ELSE SAY illegal_parameter_off_pl OF my_game. - END IF. - - turn_off = switch off (app). - - turn_off = turn (app) off. - - turn_off = switch (app) off. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', classes 'device' and 'lightsource'. --- This verb merely covers cases where the player forgets to type 'on' or 'off'. - - -ADD TO EVERY OBJECT - VERB turn_off - DOES - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - - "something you can $v off." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ UNDRESS - - --- ============================================================== - - -SYNTAX undress = undress. - - -VERB undress - CHECK CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - DOES - IF COUNT IN worn, ISA CLOTHING > 0 - -- See 'classes.i', class 'clothing'. - THEN "You don't feel like undressing is a good idea right now." - ELSE "You're not wearing anything you can remove." - END IF. - - -- To make it work, use the following lines instead: - --IF COUNT IN worn, ISA CLOTHING > 0 - --THEN EMPTY worn IN hero. - --"You remove all the items you were wearing." - --ELSE "You're not wearing anything you can remove." - -- END IF. -END VERB. - - - --- ============================================================== - - ------ UNLOCK - - --- ============================================================== - - -SYNTAX unlock = unlock (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - - -ADD TO EVERY OBJECT - VERB unlock - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS locked - ELSE - IF obj IS NOT plural - THEN SAY check_obj_locked_sg OF my_game. - ELSE SAY check_obj_locked_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES - IF matching_key OF obj IN hero - THEN MAKE obj NOT locked. - "(with" SAY THE matching_key OF obj. "$$)$n" - "You unlock" SAY THE obj. "." - ELSE "You don't have the key that unlocks" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ UNLOCK WITH - - --- ============================================================= - - -SYNTAX unlock_with = unlock (obj) 'with' (key) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - AND key ISA OBJECT - ELSE SAY illegal_parameter_with_sg OF my_game. "." - - -ADD TO EVERY OBJECT - VERB unlock_with - WHEN obj - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN SAY check_obj_suitable_sg OF my_game. - ELSE SAY check_obj_suitable_pl OF my_game. - END IF. - AND key IS examinable - ELSE - IF obj IS NOT plural - THEN SAY check_obj2_suitable_with_sg OF my_game. - ELSE SAY check_obj2_suitable_with_pl OF my_game. - END IF. - AND key IN hero - ELSE SAY check_obj2_in_hero OF my_game. - AND obj <> key - ELSE SAY check_obj_not_obj2_with OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS locked - ELSE - IF obj IS NOT plural - THEN SAY check_obj_locked_sg OF my_game. - ELSE SAY check_obj_locked_pl OF my_game. - END IF. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - AND key = matching_key OF obj - ELSE SAY check_door_matching_key OF my_game. - DOES - MAKE obj NOT locked. - "You unlock" SAY THE obj. "with" SAY THE key. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE - - --- ============================================================== - - -SYNTAX 'use' = 'use' (obj) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - - - -ADD TO EVERY OBJECT - VERB 'use' - DOES - "Please be more specific. How do you intend to use" - - IF obj IS NOT plural - THEN "it?" - ELSE "them?" - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE WITH - - --- ============================================================== - - -SYNTAX use_with = 'use' (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - AND instr ISA OBJECT - ELSE SAY illegal_parameter_obj OF my_game. - - -ADD TO EVERY OBJECT - VERB use_with - WHEN obj - CHECK obj <> instr - ELSE SAY check_obj_not_obj2_with OF my_game. - DOES - "Please be more specific. How do you intend to use them together?" - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ VERBOSE (see also -> BRIEF) - - --- ============================================================== - - -SYNTAX verbose = verbose. - - -VERB verbose - DOES - VISITS 0. - "Verbose mode is now on. Location descriptions will be - always shown in full." -END VERB. - - - --- ============================================================== - - ------ WAIT (= z) - - --- ============================================================== - - -SYNTAX 'wait' = 'wait'. - - -VERB 'wait' - DOES - "Time passes..." -END VERB. - - -SYNONYMS - z = 'wait'. - - - --- ============================================================== - - ------ WEAR - - --- ============================================================== - - - -SYNTAX wear = wear (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_sg OF my_game. - ELSE SAY illegal_parameter_pl OF my_game. - END IF. - wear = put 'on' (obj). - wear = put (obj) 'on'. - wear = don (obj). - - -ADD TO EVERY OBJECT - VERB wear -- check how this agrees with classes.i! - CHECK obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - DOES ONLY - IF obj IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - - "not something you can wear." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHAT AM I - - --- ============================================================== - - -SYNTAX what_am_i = 'what' am i. - - -VERB what_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHAT IS - - --- ============================================================== - - -SYNTAX what_is = 'what' 'is' (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_what_sg OF my_game. - ELSE SAY illegal_parameter_what_pl OF my_game. - END IF. - - what_is = 'what' 'are' (obj)!. - - -ADD TO EVERY THING - VERB what_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHERE AM I - - --- ============================================================== - - -SYNTAX where_am_i = 'where' am i. - - -VERB where_am_i - DOES - LOOK. -END VERB. - - - --- ============================================================== - - ------ WHERE IS - - --- ============================================================== - - -SYNTAX where_is = 'where' 'is' (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN SAY illegal_parameter_what_sg OF my_game. - ELSE SAY illegal_parameter_what_pl OF my_game. - END IF. - - where_is = 'where' 'are' (obj)!. - - -ADD TO EVERY THING - VERB where_is - CHECK obj NOT AT hero - ELSE - IF obj IS NOT plural - THEN SAY check_obj_not_at_hero_sg OF my_game. - ELSE SAY check_obj_not_at_hero_pl OF my_game. - END IF. - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHO AM I - - --- ============================================================== - - -SYNTAX who_am_i = who am i. - - -VERB who_am_i - DOES - "Maybe examining yourself might help." -END VERB. - - - --- ============================================================== - - ------ WHO IS - - --- ============================================================== - - -SYNTAX who_is = 'who' 'is' (act)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN SAY illegal_parameter_who_sg OF my_game. - ELSE SAY illegal_parameter_who_pl OF my_game. - END IF. - - who_is = 'who' 'are' (act)!. - - -ADD TO EVERY ACTOR - VERB who_is - DOES - "You'll have to find it out yourself." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WRITE - - --- ============================================================== - - -SYNTAX write = write (txt) 'on' (obj) - WHERE txt ISA STRING - ELSE SAY illegal_parameter_string OF my_game. - AND obj ISA OBJECT - ELSE SAY illegal_parameter_there OF my_game. - - write = write (txt) 'in' (obj). - - -ADD TO EVERY OBJECT - VERB write - WHEN obj - CHECK obj IS writeable - ELSE SAY check_obj_writeable OF my_game. - AND CURRENT LOCATION IS lit - ELSE SAY check_current_loc_lit OF my_game. - AND obj IS reachable AND obj IS NOT distant - ELSE - IF obj IS NOT reachable - THEN - IF obj IS NOT plural - THEN SAY check_obj_reachable_sg OF my_game. - ELSE SAY check_obj_reachable_pl OF my_game. - END IF. - ELSIF obj IS distant - THEN - IF obj IS NOT plural - THEN SAY check_obj_not_distant_sg OF my_game. - ELSE SAY check_obj_not_distant_pl OF my_game. - END IF. - END IF. - - DOES - IF text OF obj = "" - THEN SET text OF obj TO txt. - ELSE SET text OF obj TO text OF obj + " " + txt. - END IF. - - "You write ""$$" SAY txt. "$$"" on" SAY THE obj. "." - MAKE obj readable. - END VERB. -END ADD TO. - - --- A couple of other formulations are understood but they guide the player to --- use the correct syntax: - - -SYNTAX write_error1 = write 'on' (obj) - WHERE obj ISA OBJECT - ELSE "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - - -ADD TO EVERY OBJECT - VERB write_error1 - DOES "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - END VERB. -END ADD TO. - - -SYNTAX write_error2 = write. - -VERB write_error2 - DOES "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." -END VERB. - - -SYNTAX write_error3 = write (txt) - WHERE txt ISA STRING - ELSE "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - - -ADD TO EVERY STRING - VERB write_error3 - DOES "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ YES - - --- ================================================================ - - -SYNTAX yes = yes. - - -VERB yes - DOES "Really?" -END VERB. - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/testgame.alan b/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/testgame.alan deleted file mode 100644 index 9eb61bf..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/testgame.alan +++ /dev/null @@ -1,410 +0,0 @@ --- TESTGAME - - -IMPORT 'newlocations.i'. -IMPORT 'newclasses.i'. -IMPORT 'newverbs.i'. -IMPORT 'newdefinitions.i'. - - - - - - -THE my_game ISA definition_block - - HAS title "Testgame1". - HAS author "Wendell Botbot". - HAS year 2014. - - HAS intro_text "". - - --Define the default behaviour for the verbs you want: - - VERB examine - DOES ONLY "This is my game's default response when the player examines something." - END VERB. - -End The. - - - - - - - -THE sunny_room ISA ROOM -- all ROOMS automatically have a floor, walls and a ceiling - NAME sunny 'room' - DESCRIPTION "You are in a spacious room filled with bright sunlight entering through - the window and through an open doorway to the west leading to a small balcony. - A white door leads north. There is a staircase to the south." - - EXIT north TO closet - CHECK - IF door1 IS closed - THEN "You can't, since the door is closed." - ELSE "You walk into the closet. The door slams shut behind you." - LOCATE hero AT closet. - LOCATE door1 AT closet. - MAKE door1 closed. - END IF. - END EXIT. - - EXIT west TO balcony. - - EXIT south TO nowhere - CHECK "The staircase just leads out of here. Stay here to keep experimenting, - otherwise type QUIT to quit." - END EXIT. - - -END THE. - - - - -THE table ISA SUPPORTER -- you can place things on a supporter - AT sunny_room - IS NOT takeable. - HAS components {drawer1, drawer2}. - - VERB examine - DOES AFTER - FOR EACH c IN components OF THIS - DO - "The table has" SAY AN c. "." - IF c IS NOT closed - THEN LIST c. - ELSE SAY THE c. "is closed." - END IF. - END FOR. - END VERB. - -END THE. - - -THE drawer1 ISA LISTED_CONTAINER - AT sunny_room - OPAQUE CONTAINER - NAME top drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - -THE drawer2 ISA LISTED_CONTAINER - AT sunny_room - OPAQUE CONTAINER - NAME bottom drawer - IS closeable. IS closed. - DESCRIPTION "" -END THE. - - - -THE pearls ISA OBJECT - In table. - IS plural. - PRONOUN 'them' - - VERB examine - DOES BEFORE - "This is an object with a plural name. Experiment with different commands to see - the responses and how they are different as compared with objects with a singular name.$p" - END VERB. - - -END THE. - - -THE box ISA LISTED_CONTAINER - AT sunny_room - - VERB examine - DOES BEFORE "This is a listed container defined in the library. The contents should be - listed after both 'examine', 'look in' and 'look'." - END VERB. - -END THE. - - - -THE door1 ISA DOOR - AT sunny_room - NAME white 'door' - DESCRIPTION "" - - VERB examine - DOES ONLY "This is a door object. Please experiment by opening and closing, knocking on - and looking under both when the door is opened and closed." - END VERB. - - -END THE. - - -THE window1 ISA WINDOW - AT sunny_room - NAME 'window' - DESCRIPTION "" -END THE. - - -THE flower ISA OBJECT - IS scenery. - IN table -- Note the 'in' here; however, the flower will be described - -- to be *on* the table. - - -END THE. - - - -THE note ISA OBJECT - IN table - IS writeable. - IS readable. - - - VERB examine - DOES ONLY "You can try writing something on the note." - END VERB. - - - VERB write - WHEN obj - DOES BEFORE - IF pen NOT IN hero - THEN "(taking the pen first)$n" - LOCATE pen IN hero. - END IF. - END VERB. - - - VERB burn - CHECK match IS lit - ELSE "How?" - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - - VERB burn_with - WHEN obj - CHECK instr = match - ELSE "That's not possible." - DOES ONLY "You burn the note to ashes." - LOCATE note AT nowhere. - END VERB. - - -END THE. - - -THE pen ISA OBJECT - IN table -END THE. - - -THE bottle ISA LISTED_CONTAINER - IN box -END THE. - - -THE juice ISA LIQUID - IN bottle - HAS vessel bottle. - IS drinkable. - ARTICLE "some" -END THE. - - -THE match ISA LIGHTSOURCE - IN box - IS natural. -END THE. - - -THE flashlight ISA LIGHTSOURCE - IN box - IS NOT natural. -END THE. - - -THE waterpistol ISA WEAPON - IN box - IS fireable. -END THE. - - -THE blue_ball ISA OBJECT - IN box - NAME blue ball NAME blue - VERB take - DOES SCORE 1. - END VERB. -END THE. - - -THE red_ball ISA OBJECT - AT sunny_room - NAME red ball NAME red - VERB take - DOES SCORE 1. - END VERB. -END THE. - - -THE yellow_ball ISA OBJECT - AT sunny_room - NAME yellow ball NAME yellow - VERB take - DOES SCORE 1. - END VERB. -END THE. - - -THE felix ISA PERSON - AT sunny_room - NAME felix NAME himself NAME butler - IS named. - MENTIONED "Felix" - PRONOUN 'him' - DESCRIPTION "$pFelix, your grumpy butler, is standing off to one side." - - VERB examine - DOES ONLY "Felix is your grumpy butler. You could try talking to him, or asking him - for various things.$p" LIST felix. LIST felix_worn. - END VERB. - -END THE. - - -THE felix_worn ISA NPC_WORN - HAS carrier felix. -END THE. - - -THE tuxedo ISA CLOTHING IN felix_worn - IS topcover 64. botcover 64. - IS NOT takeable. -END THE. - - -THE dog ISA ACTOR - AT sunny_room - DESCRIPTION "$pA dog is here, looking at you with faithful eyes." - CONTAINER - HEADER "The dog is carrying" - ELSE "The dog is not carrying anything." - - - VERB examine - DOES ONLY "Give the blue ball to the dog and he will follow you." - LIST dog. - END VERB. - -END THE. - - -THE balcony ISA LOCATION - - DESCRIPTION "You're standing on a small balcony overlooking a garden. The sky is clear. - In the distance you see a mountain. - The room is back to the east." - - IF visited OF balcony = 1 - THEN "$pHaving never been on this balcony before, you pause to take in the magnificent view." - ELSE "$pEven if you've been here before, the magnificent view never ceases to amaze you." - END IF. - - EXIT east TO sunny_room. - -END THE. - - --- The balcony is neither a pure indoor or outdoor room, we need the floor but also the sky: - - -THE balcony_object ISA OBJECT AT balcony - NAME balcony - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" -END THE. - -THE balcony_floor ISA OBJECT AT balcony - NAME floor - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" -END THE. - - -THE balcony_sky ISA BACKGROUND AT balcony - NAME sky - DESCRIPTION "" -END THE. - - -THE mountain ISA BACKGROUND - AT balcony - DESCRIPTION "" - VERB examine - DOES ONLY "Beautiful." - END VERB. -END THE. - - -THE garden ISA BACKGROUND - AT balcony - NAME garden NAME flowers - DESCRIPTION "The garden is green and full of blossoming flowers." -END THE. - - - -THE closet ISA DARK_LOCATION - - DESCRIPTION "This is a closet." - - EXIT south TO sunny_room - DOES "Aiming to the direction from where you remember coming, you manage to push the door open - and emerge back into the sunny room. The closet door slams shut behind you again." - LOCATE door1 AT sunny_room. - END EXIT. - -END THE. - - -THE shirt ISA CLOTHING - AT closet - IS topcover 8. -END THE. - - -THE jacket ISA CLOTHING - AT closet - IS topcover 32. -END THE. - - -THE wallet ISA OBJECT - IN jacket -END THE. - - -WHEN blue_ball IN dog AND dog IS NOT following - => MAKE dog following. - - - - - - - -START AT sunny_room. - -"This is a" STYLE alert. "testgame" STYLE normal. "for the new ALAN library. Experiment with - manipulating various objects and moving around. -Taking any ball will increase your score." diff --git a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/testgame.input b/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/testgame.input deleted file mode 100644 index 23373cd..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/2014-01-09/testgame.input +++ /dev/null @@ -1 +0,0 @@ -empty box in bottle diff --git a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/TPCover1.png b/app/src/main/jni/terps/alan/alan3/bugs/abandoned/TPCover1.png deleted file mode 100755 index c18df52..0000000 Binary files a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/TPCover1.png and /dev/null differ diff --git a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/abandoned.alan b/app/src/main/jni/terps/alan/alan3/bugs/abandoned/abandoned.alan deleted file mode 100755 index e671845..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/abandoned.alan +++ /dev/null @@ -1,2139 +0,0 @@ --- Ted Paladin And The Case Of The Abandoned House - - -IMPORT 'classes.i'. -IMPORT 'locations.i'. -IMPORT 'messages.i'. -IMPORT 'verbs.i'. - - --- THE OUTSIDE --------------------------------------------------------------------------------------------------------- - -THE oh_e ISA SITE - NAME Outside 'the' house '(to' 'the' 'east)' - ENTERED LOCATE house AT oh_e. - - DESCRIPTION "You are standing east of a desolate wooden two-storey house with two boards nailed across the front door. - There is also a boarded upstairs window above the front door. - The house is located in the middle of a largish estate stretching the whole block. - Otherwise the estate is an empty wasteland with overgrown grass abounding. - Beyond the estate, the modern city expands in all directions. - You can walk around the house to the northwest and to the southwest. - $pYou can see an old, dirty garden gnome some way off in the long grass." - - EXIT north, northwest TO oh_n. - EXIT south, southwest TO oh_s. - EXIT west, 'in' TO nowhere - CHECK "There is no obvious way of entering the house from here." - END EXIT. - EXIT east, northeast, southeast TO nowhere - CHECK "You don't want to escape the task you agreed to take care of." - END EXIT. - -END THE. - - -THE gnome ISA OBJECT AT oh_e - NAME garden gnome NAME old NAME dirty - - DESCRIPTION "" - VERB examine - DOES ONLY "In its degraded state the gnome is merely pitiful and not at all pleasant to look at." - END VERB. - - VERB take - DOES ONLY "You can't think of any reason why you should carry the gnome around so you leave it where it is." - END VERB. -END THE. - - -THE house ISA OBJECT AT oh_e. - NAME house NAME wall - IS NOT takeable. - IS NOT movable. - IS NOT 'entered'. - NAME house - DESCRIPTION "" - - VERB examine - DOES ONLY "The house has two storeys and is rather big. Back in its day it must have looked exquisite; now it emanates mainly - a depressing impression in its uncared state. The paint has faded and peeled off to such an extent that it is rather - impossible to say what the original colour has been." - END VERB. - - VERB put_against - WHEN bulk - CHECK obj = garden_ladder - ELSE "That wouldn't accomplish anything." - AND house AT oh_n - ELSE "It wouldn't be of much use to lean the ladder against this wall." - AND garden_ladder IS NOT leaning - ELSE "The piece of garden fence is already leaning against the wall." - DOES ONLY "You lift the remnants of the garden fence to an upright position and lean them on the wall. - The ladder you have thus created just about reaches to the unboarded upstairs window on this side of the house." - LOCATE garden_ladder AT hero. - MAKE garden_ladder leaning. - END VERB. - - VERB search - DOES ONLY "You are not inside the house." - END VERB. - -END THE. - - -THE front_door ISA DOOR AT oh_e - NAME front door NAME front - IS lockable. IS locked. - DESCRIPTION "" - - VERB examine - DOES ONLY "Three boards have been nailed across the door. It's obvious you're supposed to find another way in." - END VERB. - -END THE. - -THE boards ISA OBJECT AT oh_e - IS plural. - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - VERB examine - DOES ONLY - IF boards AT oh_e - THEN "Three boards have been nailed across the door. It's obvious you're supposed to find another way in." - ELSE "Three boards have been nailed across the door. You can't exit at present." - END IF. - END VERB. - - VERB saw - DOES - IF handsaw IN hero - THEN "You saw the boards quickly to bits." - SCHEDULE ending AT hero AFTER 0. - ELSE "You don't have a saw." - END IF. - END VERB. - - VERB cut_with - WHEN obj - DOES ONLY - IF handsaw IN hero - THEN "You saw the boards quickly to bits." - SCHEDULE ending AT hero AFTER 0. - ELSE "You don't have a saw." - END IF. - END VERB. - -END THE. - - -THE upstair_window_e ISA WINDOW AT oh_e - NAME upstair upstairs window - MENTIONED "upstairs window" - IS NOT reachable. - DESCRIPTION "" - - VERB examine - DOES ONLY "The upstairs window is boarded shut." - END VERB. - -END THE. - - - -THE oh_n ISA SITE - NAME outside 'the' house '(to' 'the' 'north)' - ENTERED LOCATE house AT oh_n. - - DESCRIPTION "You are standing north of the desolate house. On this side there are two downstairs windows with boards nailed across each, - and one upstairs window which, out of some oversight, is not boarded. - Beyond the barren estate, the modern city expands in all directions. - You can walk around the house to the southeast and to the southwest. - $pIn the long grass around the house you see an old, broken bicycle lying about." - - EXIT east, southeast TO oh_e. - EXIT west, southwest TO oh_w. - EXIT south, 'in' TO nowhere - CHECK "There is no obvious way of entering the house from here." - END EXIT. - EXIT north, northeast, northwest TO nowhere - CHECK "You don't want to escape the task you agreed to take care of." - END EXIT. - - EXIT up TO wbr - CHECK garden_ladder IS leaning - ELSE "You can't go that way." - DOES "You climb up the shaky ladder construction and reach the upstairs window. - The window is easy to force open as the frame is rather decayed. However, - the rickety ladder gives way under you and collapses onto the ground. - You manage to grab the window sill just in time to pull yourself into the house. - An old dresser has been pulled half in front of the window but you manage to make your way - into the room past it." - LOCATE hero AT wbr. SCHEDULE welcome AT hero AFTER 0. - MAKE house 'entered'. - END EXIT. - -END THE. - - -THE downstair_windows ISA WINDOW AT oh_n - NAME downstair downstairs first second right left 'window' NAME downstair downstairs windows - IS plural. - IS NOT closeable. - MENTIONED "downstairs windows" - DESCRIPTION "" - - VERB examine - DOES ONLY "Both downstairs windows on this wall are boarded shut." - END VERB. - -END THE. - - -THE upstair_window_n ISA WINDOW AT oh_n - NAME upstair upstairs window - MENTIONED "upstairs window" - IS NOT reachable. - DESCRIPTION "" - - VERB examine - DOES ONLY "The upstairs window is not boarded. Maybe it could provide an entrance into the house - if you could reach it." - END VERB. - -END THE. - - -THE bicycle ISA OBJECT AT oh_n - NAME old bike NAME old broken bicycle NAME old - DESCRIPTION "" - - VERB examine - DOES ONLY "It's a rusty bicycle with one wheel missing." - END VERB. - - - VERB take - DOES ONLY "You can't think of any reason why you would need the bike so you leave it be." - END VERB. - - - VERB ride - DOES "The rusty bicycle is not fit for riding." - END VERB. - -END THE. - - -THE oh_w ISA SITE - ENTERED LOCATE house AT oh_w. - - NAME outside 'the' house '(to' 'the' 'west)' - DESCRIPTION "You are standing west of the abandoned house. On the wall on this side you see one upstairs window - and one downstairs window, both boarded. - Beyond the barren estate, the modern city expands in all directions. - - You can walk around the house to the northeast and to the southeast." - EXIT north, northeast TO oh_n. - EXIT south, southeast TO oh_s. - EXIT east, 'in' TO nowhere - CHECK "There is no obvious way of entering the house from here." - END EXIT. - EXIT west, northwest, southwest TO nowhere - CHECK "You don't want to escape the task you agreed to take care of." - END EXIT. - -END THE. - - -THE foil ISA OBJECT - IS NOT found. -END THE. - -THE garden_ladder ISA OBJECT AT oh_w - NAME garden fence NAME garden ladder NAME remnants - MENTIONED "piece of garden fence" - IS NOT leaning. - - DESCRIPTION - IF garden_ladder IS leaning -- (= at oh_n) - THEN "$pYou have erected the remnants of the garden fence against the wall, - and it serves as a passable ladder leading to the unboarded upstairs window." - ELSE "$pThere is a piece of garden fence lying in the grass." - IF garden_ladder AT oh_w AND garden_ladder NOT IN hero AND foil IS NOT found - THEN "You spot something glittering under it." - END IF. - END IF. - - - - VERB examine - DOES ONLY - "It's a short piece of a decayed garden fence, about ten feet long and fallen down to the ground. - Who knows where the rest of the fence has disappeared in the course of years. - Some of the crossbars in it are missing." - IF garden_ladder AT oh_w AND garden_ladder NOT IN hero AND foil IS NOT found - THEN "You spot something glittering under the fallen piece of fence." - END IF. - END VERB. - - - VERB take - DOES ONLY - IF garden_ladder IS NOT leaning THEN - "You pick the piece of garden fence up and lift it upright." - IF foil IS NOT found - THEN "The glittering object under it was, however, just a small piece of foil that flies away in the wind." - MAKE foil found. - END IF. - "Turning to look again at the fence you're holding you come to think - that it could serve as a passable ladder. It is of quite a light structure and you manage to carry it - with some effort." - LOCATE garden_ladder IN hero. - ELSE "There is no reason to take the fence now." - END IF. - END VERB. - - - VERB lift - DOES ONLY - IF garden_ladder IS NOT leaning THEN - "You pick the piece of garden fence up and lift it upright." - IF foil IS NOT found - THEN "The glittering object under it was, however, just a small piece of foil that flies away in the wind." - MAKE foil found. - END IF. - "Turning to look again at the fence you're holding you come to think - that it could serve as a passable ladder. It is of quite a light structure and you manage to carry it - with some effort." - LOCATE garden_ladder IN hero. - ELSE "You see nothing unusual under the fence." - END IF. - END VERB. - - - VERB search - DOES ONLY - IF garden_ladder IS NOT leaning AND garden_ladder NOT IN hero - THEN "You should lift the fallen fence in order to search better under it." - ELSE "You find nothing further of interest." - END IF. - END VERB. - - - VERB look_under - DOES ONLY - IF garden_ladder IS NOT leaning AND garden_ladder NOT IN hero - THEN "You should lift the fence in order to search better under it." - ELSE "You notice nothing unusual under the fence." - END IF. - END VERB. - - - VERB climb - DOES ONLY - IF garden_ladder IS leaning - THEN "You climb up the shaky ladder construction and reach the upstairs window. - The window is easy to force open as the frame is rather decayed. However, - the rickety ladder gives way under you and collapses onto the ground. - You manage to grab the window sill just in time to pull yourself into the house. - An old dresser has been pulled half in front of the window but you manage to make your way - into the room past it." - LOCATE hero AT wbr. SCHEDULE welcome AT hero AFTER 0. MAKE house 'entered'. - ELSE "You'll have to have the ladder leaning against something before you can successfully climb it." - END IF. - END VERB. - - -END THE. - - -THE upstair_window_w ISA WINDOW AT oh_w - NAME upstair upstairs window - MENTIONED "upstairs window" - IS NOT reachable. - DESCRIPTION "" - - VERB examine - DOES ONLY "The upstairs window is boarded shut." - END VERB. - -END THE. - - -THE downstair_window_w ISA WINDOW AT oh_w - NAME downstair downstairs window - MENTIONED "boarded downstairs window" - IS NOT closeable. - DESCRIPTION "" - - VERB examine - DOES ONLY "The downstairs window is boarded shut." - END VERB. - -END THE. - - - -THE oh_s ISA SITE - ENTERED LOCATE house AT oh_s. - - NAME outside 'the' house '(to' 'the' 'south)' - DESCRIPTION "You are standing south of the house. On this wall there is only a single boarded downstairs window." - IF vine IS NOT broken - THEN "Some vines climb along the wall, - supported by a very fragile frame." - END IF. - "Beyond the estate, which stretches the whole block, the modern city expands in all directions. You can walk around the house - to the northeast and to the northwest. - $pIn the long grass around the house you see a pile of forsaken firewood." - - EXIT west, northwest TO oh_w. - EXIT east, northeast TO oh_e. - EXIT north, 'in' TO nowhere - CHECK "There is no obvious way of entering the house from here." - END EXIT. - EXIT south, southwest, southeast TO nowhere - CHECK "You don't want to escape the task you agreed to take care of." - END EXIT. - -END THE. - - - -THE downstair_window_s ISA WINDOW AT oh_s - NAME single boarded downstairs downstairs window NAME boarded - MENTIONED "window" - IS NOT closeable. - DESCRIPTION "" - - VERB examine - DOES ONLY "The window is boarded shut." - END VERB. - -END THE. - - - -THE firewood ISA SCENERY AT oh_s - IS NOT takeable. - NAME firewood NAME pile - - DESCRIPTION "" - - VERB burn - DOES ONLY "How would that help matters?" - END VERB. - -END THE. - - - -THE vine ISA OBJECT AT oh_s - NAME vine NAME vines NAME fragile frame NAME fragile - IS NOT broken. - DESCRIPTION - IF vine IS broken - THEN "$pThe vines and the frame that supported them are now lying on the ground, useless for your purposes." - END IF. - - VERB examine - DOES ONLY - IF vine IS NOT broken - THEN "Some vines climb along the wall on this side of the house, beside the boarded window. They almost reach the roof." - ELSE "The vines and the frame that supported them are now lying on the ground, useless for your purposes." - END IF. - END VERB. - - VERB climb - DOES ONLY - IF vine IS NOT broken - THEN "You try to climb the frame but it gives in under your weight, breaks apart and falls to the ground, useless." - MAKE vine broken. - ELSE "You can't climb the vine now." - END IF. - END VERB. - - - VERB take - DOES ONLY "That wouldn't accomplish anything." - END VERB. - - -END THE. - - -THE roof ISA OBJECT AT oh_s - IS NOT reachable. - DESCRIPTION "" -END THE. - - -THE city ISA BACKGROUND AT outdoor - DESCRIPTION "" - VERB examine - DOES ONLY "High-rise buildings, neonlights, sounds of traffic. All the usual fare of a modern city." - END VERB. -END THE. - - -THE estate ISA OBJECT AT outdoor - NAME estate NAME grass - MENTIONED "grassy estate" - IS NOT takeable. IS NOT movable. - DESCRIPTION "" - - VERB examine - DOES ONLY "Overgrown grass dominates the estate all around the house." - END VERB. - -END THE. - - --- THE INSIDE ------------------------------------------------------------------------------------------------------------- - - --- UPSTAIRS --------------------------------------------------------------------------------------------------------------- - - - -THE wbr ISA ROOM - NAME white bedroom - DESCRIPTION - - IF piano IS NOT found - THEN "--" - ELSE "An antique black piano against one of the walls gives - the otherwise plain room quite a dignified impression - even in its abandoned state." - END IF. - - - IF bed IS NOT found - THEN "--" - ELSE "The worn-out bed here with nothing, not even a mattress, on it looks rather mundane and uninviting beside it." - END IF. - - - IF wardrobe IS NOT found - THEN "--" - ELSE "A tall oaken wardrobe juts out from one of the corners." - END IF. - - - IF dresser IS NOT found - THEN "--" - ELSE "You can see also a white-painted wooden dresser here." - END IF. - - - IF wwindow IS NOT found - THEN "--" - ELSE "The window through which you entered faces north and allows bright daylight into the room." - END IF. - - - IF wdoor IS NOT found - THEN "--" - ELSE "There is a door to the south" - IF wdoor IS closed - THEN "which is currently closed" - ELSE "which is currently open" - END IF. - "and beside which you see a small device on the wall." - END IF. - - - EXIT north, out TO oh_n - CHECK "Looking out of the window you can see the collapsed ladder construction on the ground. You can't get out that way." - MAKE wwindow found. - END EXIT. - - - EXIT south TO landing - CHECK wdoor IS NOT closed - ELSE "You can't, since the door is closed." - MAKE wdoor found. - DOES "You exit the white bedroom." - MAKE wdoor found. - IF COUNT ISA OBJECT, IN hero > 0 - THEN - IF handsaw IN hero - THEN - IF bottle NOT IN hero - THEN "Before leaving, you politely return everything but the handsaw into their places." - EMPTY hero AT wbr. - LOCATE jacket IN wardrobe. - LOCATE note IN jacket. - LOCATE shoes IN drawer. - LOCATE handsaw IN hero. - ELSE "Before leaving, you politely return everything but the handsaw and the bottle into - their places." - EMPTY hero AT wbr. - LOCATE jacket IN wardrobe. - LOCATE note IN jacket. - LOCATE shoes IN drawer. - LOCATE handsaw IN hero. - LOCATE bottle IN hero. - END IF. - ELSIF bottle IN hero - THEN - IF handsaw NOT IN hero - THEN "Before leaving, you politely return everything but the bottle into their places." - EMPTY hero AT wbr. - LOCATE bottle IN hero. - ELSE "Before leaving, you politely return everything but the handsaw and the bottle into - their places." - EMPTY hero AT wbr. - LOCATE jacket IN wardrobe. - LOCATE note IN jacket. - LOCATE shoes IN drawer. - LOCATE handsaw IN hero. - LOCATE bottle IN hero. - END IF. - ELSE EMPTY hero AT wbr. - LOCATE jacket IN wardrobe. - LOCATE note IN jacket. - LOCATE shoes IN drawer. - "Before leaving, you politely return everything into their places." - END IF. - END IF. - END EXIT. - - - - -END THE. - - - -THE piano ISA OBJECT AT wbr - IS NOT takeable. - IS NOT found. - HAS value 0. - DESCRIPTION "" - - VERB examine - DOES ONLY - "It's an exquisite-looking, antique piano. The white keys have turned yellowish with age." - IF piano IS NOT found - THEN MAKE piano found. - END IF. - END VERB. - - - VERB 'play' - DOES ONLY "You play the piano a bit at random. With your perfect pitch you notice right away that the piano is - two whole steps out of tune. - $n(To press the individual piano keys, type ""PRESS/PLAY ""C"" ON THE PIANO, PRESS/PLAY ""D"" ON THE PIANO etc. (C and D being - any notes between A and G.)" - MAKE piano found. - END VERB. - - -END THE. - - -SYNTAX play_note = 'play' (str) 'on' 'piano' - WHERE str ISA STRING - ELSE "Please use the formulation PRESS/PLAY ""C"" ON THE PIANO (where C is any note between A and G) to play a note on the piano." - - play_note = 'play' (str) 'on' 'the' 'piano'. - play_note = press (str) 'on' 'piano'. - play_note = press (str) 'on' 'the' 'piano'. - - -ADD TO EVERY STRING -VERB play_note - DOES - IF str ="a" OR str ="b" OR str = "c" OR str = "d" OR str = "e" OR str = "e" OR str = "f" OR str = "g" - THEN - - "You press the note" SAY str. "on the piano." - IF str = "f" THEN SET value OF piano TO 1. - ELSIF str = "g" - THEN IF value OF piano = 1 - THEN INCREASE value OF piano BY 1. - ELSE SET value OF piano TO 0. - END IF. - ELSIF str = "d" - THEN IF value OF piano = 2 - THEN "$pHaving pushed the F, G and D notes, there is a click from the sound detector by the door. - A small secret compartment in it opens and spits out a small plastic bottle onto the floor. The compartment - closes again." - SET value OF piano TO 0. - LOCATE bottle AT wbr. - ELSE SET value OF piano TO 100. - END IF. - ELSIF str = "e" - THEN - IF value OF piano = 100 - THEN SET value OF piano TO 200. - ELSE SET value OF piano TO 0. - END IF. - ELSIF str = "b" - THEN IF value OF piano = 200 - THEN "$pHaving pushed the D, E and B notes, nothing happens. Hmm. You were sure this would work. - Could the fact that the piano is two steps out of tune have something to do with the - sound detector not identifying the notes?" - SET value OF piano TO 0. - ELSE SET value OF piano TO 0. - END IF. - ELSIF str = "a" - THEN SET value OF piano TO 0. - ELSIF str = "c" - THEN SET value OF piano TO 0. - END IF. - ELSE "That doesn't seem to be a note you can play." - - - END IF. -END VERB. -END ADD TO. - - - -THE dresser ISA SUPPORTER AT wbr - IS NOT found. - IS NOT takeable. - DESCRIPTION "" - - - VERB examine - DOES ONLY "The dresser, pulled half in front of the window, looks worn out and has many scratches on the surface. It has one drawer" - IF drawer IS closed - THEN "which is closed." - ELSE "which is open." - END IF. - IF dresser IS NOT found - THEN MAKE dresser found. - END IF. - IF drawer IS NOT found - THEN MAKE drawer found. - END IF. - MAKE wwindow found. - END VERB. - -END THE. - - - - -THE drawer ISA LISTABLE_CONTAINER AT wbr - OPAQUE CONTAINER - IS closeable. IS closed. - IS NOT takeable. - IS NOT found. - DESCRIPTION "" - - VERB examine - DOES ONLY - IF drawer IS closed - THEN "The drawer is closed." - ELSE "The drawer is open." - LIST drawer. - END IF. - END VERB. - -END THE. - - -THE shoes ISA CLOTHING IN drawer - NAME shoes NAME pair 'of' shoes NAME pair NAME shoe - MENTIONED "pair of shoes" - DESCRIPTION "" - - VERB examine - DOES ONLY "It's a pair of men's walking shoes with nothing special about them." - IF shoes IN drawer - THEN "Funny that somebody should have put them in the dresser; the wardrobe would have been a more - natural place for them." - END IF. - END VERB. - - VERB search - DOES ONLY "It's a pair of men's walking shoes. You find nothing of interest in or about them." - IF shoes IN drawer - THEN "Funny that somebody should have put them in the dresser; the wardrobe would have been a more - natural place for them." - END IF. - END VERB. - - VERB take - DOES ONLY "They're not your size. Besides, you're wearing your own shoes already." - END VERB. - - VERB wear - DOES ONLY "They're not your size. Besides, you're wearing your own shoes already." - END VERB. - -END THE. - - - -THE note ISA OBJECT IN jacket - IS readable. - IS NOT found. - DESCRIPTION "" - - VERB examine - DOES ONLY - "The note only says ""DEB"". Well well, who might that be?" - END VERB. - - - VERB read - DOES ONLY - "The note only says ""DEB"". Well well, who might that be?" - END VERB. - -END THE. - - - - -THE bed ISA SUPPORTER AT wbr - IS NOT takeable. - IS NOT found. - DESCRIPTION "" - - VERB examine - DOES ONLY "The bed doesn't have anything on it, not even a mattress." - IF bed IS NOT found - THEN MAKE bed found. - END IF. - END VERB. - - VERB search - DOES ONLY "You find some sheets of music under the bed. They have probably fallen off from the - piano." - LOCATE sheets AT wbr. - MAKE bed found. - END VERB. - - VERB look_under - DOES ONLY "You find some sheets of music. They have probably fallen off from the - piano." - LOCATE sheets AT wbr. - MAKE bed found. - END VERB. - -END THE. - - -THE sheets ISA SCENERY - NAME sheets NAME sheet NAME music NAME moonlight sonata - IS plural. - IS readable. - MENTIONED "sheets of music" - DESCRIPTION "" - - VERB examine - DOES ONLY "It's the sheet music for Beethoven's ""Moonlight Sonata"", 1st movement." - END VERB. - - VERB read - DOES ONLY "It's the sheet music for Beethoven's ""Moonlight Sonata"", 1st movement." - END VERB. - - VERB 'play' - DOES ONLY "The piano is so out of tune - two whole steps - you don't feel like playing the piece." - END VERB. - -END THE. - - - -THE wardrobe ISA LISTABLE_CONTAINER AT wbr - OPAQUE CONTAINER - IS closeable. IS closed. - IS NOT takeable. - IS NOT found. - DESCRIPTION "" - - VERB examine - DOES ONLY "It's a sturdy oaken wardrobe." - IF wardrobe IS NOT closed - THEN LIST wardrobe. - ELSE "It is closed." - END IF. - IF wardrobe IS NOT found - THEN MAKE wardrobe found. - END IF. - END VERB. - - VERB open - DOES MAKE wardrobe found. - END VERB. - -END THE. - - - -THE jacket ISA CLOTHING IN wardrobe - NAME brown jacket NAME brown - CONTAINER - IS NOT found. - DESCRIPTION "" - - VERB examine - DOES ONLY - "It's an old brown jacket." - IF note IN jacket - THEN "Something seems to protrude out of one of the pockets." - END IF. - MAKE jacket found. - END VERB. - - VERB look_in - DOES ONLY "You find a small note which you take." - LOCATE note IN hero. - END VERB. - - VERB search - DOES ONLY - IF note IS NOT found - THEN - "You find a small note which you take." - LOCATE note IN hero. MAKE note found. - ELSE - "You find nothing else of interest." - END IF. - END VERB. - - VERB take - DOES ONLY "You don't feel it's much use taking the jacket." - END VERB. - - VERB 'empty' - DOES ONLY - IF note IN jacket - THEN"You find a small note which you take." - LOCATE note In hero. - ELSE "You find nothing else of interest in the pocket." - END IF. - END VERB. - -END THE. - - -THE pocket ISA OBJECT - NAME pocket NAME pockets - CONTAINER - DESCRIPTION "" - - VERB examine - DOES ONLY - IF note IN jacket - THEN"You find a small note which you take." - LOCATE note In hero. - ELSE "You find nothing else of interest in the pocket." - END IF. - END VERB. - - VERB search - DOES ONLY - IF note IN jacket - THEN"You find a small note which you take." - LOCATE note In hero. - ELSE "You find nothing else of interest in the pocket." - END IF. - END VERB. - - VERB 'empty' - DOES ONLY - IF note IN jacket - THEN"You find a small note which you take." - LOCATE note In hero. - ELSE "You find nothing else of interest in the pocket." - END IF. - END VERB. - - -END THE. - - -THE wdoor ISA DOOR AT wbr - NAME door - MENTIONED "door" - IS NOT found. - IS NOT closed. - DESCRIPTION "" - - VERB examine - DOES ONLY "It's a white-painted wooden door. There is a small device next to it." - IF wdoor IS NOT found - THEN MAKE wdoor found. - END IF. - END VERB. - -END THE. - - - -THE wdevice ISA OBJECT AT wbr - NAME small device NAME sound detector - IS NOT takeable. - DESCRIPTION "" - - VERB examine - DOES ONLY "It is merely a flat, square surface with a small grille, resembling some kind of detector. - Sure enough, a small text at a corner of the device says ""AMCE (sic) Sound Detector"". You're - supposed to produce some kind of sound to solve the riddle of this room. But what kind of sound?" - END VERB. - - - VERB push - DOES ONLY "Nothing happens." - END VERB. - - -END THE. - - -THE deb ISA OBJECT -END THE. - -THE bottle ISA OBJECT - NAME oil bottle NAME oil NAME small - ARTICLE "an" - DESCRIPTION "$pThere is a small bottle of oil here." - - VERB examine - DOES ONLY "It's a small plastic bottle containing a quantity of lubricating oil." - IF hero AT lr - THEN - "$p$p(The Kitchen)$nIt's a small plastic bottle containing a quantity of lubricating oil." - END IF. - END VERB. - - - VERB drop - DOES ONLY "You feel you'd better hold on to the bottle. It was rewarded to you for a reason." - IF hero AT lr - THEN - "$p$p(The Kitchen)$nYou feel you'd better hold on to the bottle. It was rewarded to you for a reason." - END IF. - END VERB. - -END THE. - - -THE wwindow ISA WINDOW AT wbr - IS NOT takeable. - IS NOT found. - IS NOT closed. - NAME window - MENTIONED "window" - DESCRIPTION "" - - VERB examine - DOES ONLY "An old dresser has partly been pulled in front of the window." - IF wwindow IS NOT closed THEN "The window is currently open." ELSE "The window is currently closed." END IF. - IF wwindow IS NOT found - THEN MAKE wwindow found. - END IF. - END VERB. - - - VERB close - DOES ONLY "You close the window." - MAKE wwindow closed. - END VERB. - - - VERB open - DOES ONLY "You open the window." - MAKE wwindow NOT closed. - END VERB. - - - VERB look_through - DOES ONLY "You see nothing special looking out of the window." - END VERB. - - VERB look_out_of - DOES ONLY "You see nothing special looking out of the window." - END VERB. - - -END THE. - - - - ----------------------------------- - - - -THE bbr ISA ROOM - NAME Red bedroom - DESCRIPTION "This room, with red-painted walls, is much darker than the first bedroom because the window is boarded and only a few rays of sunlight - find their way in. The room is devoid of furniture except for a small table in the middle and a framed note on the wall. - On the table is an old-fashioned balance weight scale with two cups." - - IF described OF bbr = 1 - THEN "There are seven objects around the scale:$n" - ELSIF COUNT ISA OBJECT, IN table > 0 - THEN "On the table you see also:$n" - END IF. - - IF photo IN table THEN DESCRIBE photo. END IF. - IF doll IN table THEN DESCRIBE doll. END IF. - IF novel IN table THEN DESCRIBE novel. END IF. - IF mirror IN table THEN DESCRIBE mirror. END IF. - IF lp IN table THEN DESCRIBE lp. END IF. - IF pepper_dispenser IN table THEN DESCRIBE pepper_dispenser. END IF. - IF candle IN table THEN DESCRIBE candle. END IF. - - EXIT 'out', north TO landing - CHECK bdoor IS NOT closed - ELSE "You can't, since the door is closed." - DOES - IF COUNT ISA OBJECT, IN hero > 0 - THEN - IF handsaw IN hero - THEN - IF bottle NOT IN hero - THEN "Before leaving, you politely return everything but the handsaw onto the table." - EMPTY hero IN table. - LOCATE handsaw IN hero. - ELSE "Before leaving, you politely return everything but the handsaw and the bottle onto - the table." - EMPTY hero IN table. - LOCATE handsaw IN hero. - LOCATE bottle IN hero. - END IF. - ELSIF bottle IN hero - THEN - IF handsaw NOT IN hero - THEN "Before leaving, you politely return everything but the bottle onto the table." - EMPTY hero IN table. - LOCATE bottle IN hero. - ELSE "Before leaving, you politely return everything but the handsaw and the bottle onto - the table." - EMPTY hero IN table. - LOCATE handsaw IN hero. - LOCATE bottle IN hero. - END IF. - ELSE EMPTY hero IN table. - "Before leaving, you politely return everything onto the table." - END IF. - END IF. - END EXIT. - -END THE. - -ADD TO EVERY OBJECT - IS figured_out. -END ADD TO. - -THE note2 ISA OBJECT AT bbr - NAME framed note - IS readable. - DESCRIPTION "" - - VERB examine - DOES ONLY - "The framed note says: ""Valued guest: put three objects on the scale. - Only a certain three will do, the rest are *red* herrings. - When you have acted correctly, you will gain a prize.""" - END VERB. - - VERB read - DOES ONLY - "The framed note says: ""Valued guest: put three objects on the scale. - Only a certain three will do, the rest are *red* herrings. - When you have acted correctly, you will gain a prize.""" - END VERB. - - - VERB take - DOES ONLY "There is no reason to take the note." - END VERB. - -END THE. - - -THE table ISA SUPPORTER AT bbr - IS NOT takeable. - DESCRIPTION "" - - VERB examine - DOES ONLY "There is a balance scale on the table." - IF COUNT ISA OBJECT, IN table > 0 - THEN "You also see:" - - IF photo IN table THEN DESCRIBE photo. END IF. - IF doll IN table THEN DESCRIBE doll. END IF. - IF novel IN table THEN DESCRIBE novel. END IF. - IF mirror IN table THEN DESCRIBE mirror. END IF. - IF lp IN table THEN DESCRIBE lp. END IF. - IF pepper_dispenser IN table THEN DESCRIBE pepper_dispenser. END IF. - IF candle IN table THEN DESCRIBE candle. END IF. - - END IF. - END VERB. - -END THE. - - - -THE scale ISA LISTABLE_CONTAINER AT bbr - NAME cups NAME right left cup NAME scale NAME scales - MENTIONED "scale" - CONTAINER - LIMITS - COUNT 3 THEN - "You can't put anything more in the scale." - DESCRIPTION "" - - VERB examine - DOES ONLY "It is an old-fashioned decorated balance scale with two large cups hanging from chains." - "In one cup is a black weight." - IF COUNT ISA OBJECT, IN scale < 1 - THEN "The other cup is empty. Consequently the two cups are not level." - ELSE - IF handsaw NOT AT bbr - THEN - "You have placed something in the other cup but the two cups are still not level." - LIST scale. - ELSE - IF candle IN scale AND mirror IN scale AND photo IN scale - THEN "The other cup contains a candle, a mirror and a photo. The two cups are level." - ELSE "You have placed something in the other cup but the two cups are still not level." - LIST scale. - END IF. - END IF. - END IF. - END VERB. - - VERB take - DOES ONLY "There is no reason to take the scale." - END VERB. - -END THE. - - -THE black_weight ISA OBJECT AT bbr - NAME black 'weight' NAME black - DESCRIPTION "" - - VERB examine - DOES ONLY "In one of the cups in the weight device is a small black weight." - END VERB. - - VERB take - DOES ONLY "It wouldn't serve any purpose to take the weight." - END VERB. - -END THE. - - -THE photo ISA OBJECT - IN table - IS NOT found. - NAME photo NAME family - MENTIONED "photo" - DESCRIPTION - IF photo IS NOT found - THEN "$nThis one was shot by Mr Joseph O'Toole. You could have told that from his name, too." - ELSE "$nA withered black-and-white photo." - END IF. - - VERB examine DOES ONLY "A black-and-white photo of a group of people, presumably the family that used to live here, standing in an outdoor setting. - The photo itself doesn't rouse much interest in you." - MAKE photo found. - END VERB. - - VERB drop - DOES ONLY LOCATE photo IN table. - "You put the photo back on the table." - END VERB. - -END THE. - - - - -THE lp ISA OBJECT - IN table - IS NOT found. - NAME lp NAME vinyl record NAME vinyl - DESCRIPTION - IF lp IS NOT found - THEN "$n""Black, 33, 12,"" Sir Lionel Peasley, a lyric vendor, described one of his sales articles." - ELSE "$nA vinyl record." - END IF. - - - VERB examine - DOES ONLY "It's an old King Crimson LP." - MAKE lp found. - END VERB. - - - VERB listen_to - DOES ONLY "Just show me a record player and I'll be happy to." - MAKE lp found. - END VERB. - - VERB drop - DOES ONLY LOCATE lp IN table. - "You put the lp back on the table." - END VERB. - - -END THE. - - - -THE novel ISA OBJECT - IN table - IS NOT found. - IS readable. - NAME novel - DESCRIPTION - IF novel IS NOT found - THEN "$nThe opposite of Levon can be appreciated in Reading." - ELSE "$nAn old romance novel." - END IF. - - VERB examine - DOES ONLY "Leafing quickly through the novel, you find it contains mostly purple prose." - MAKE novel found. - END VERB. - - VERB read - DOES ONLY "Leafing quickly through the novel, you find it contains mostly purple prose." - MAKE novel found. - END VERB. - - VERB drop - DOES ONLY LOCATE novel IN table. - "You put the novel back on the table." - END VERB. - - -END THE. - - -SYNONYMS book = novel. - - -THE mirror ISA OBJECT - NAME mirror NAME looking glass - CONTAINER - IN table - IS NOT found. - - DESCRIPTION - IF mirror IS NOT found - THEN "$nLooking at it she saw a young lass. Only the beginning and the end count." - ELSE "$nA hand mirror." - END IF. - - VERB examine - DOES ONLY "You barely see your face in the blurry glass." - MAKE mirror found. - END VERB. - - - VERB look_in - DOES ONLY "You barely see your face in the blurry glass." - MAKE mirror found. - END VERB. - - VERB drop - DOES ONLY LOCATE mirror IN table. - "You put the mirror back on the table." - END VERB. - -END THE. - - -THE doll ISA OBJECT - IN table - IS NOT found. - DESCRIPTION - IF doll IS NOT found - THEN "$n""Can this one laugh or cry?"" asked little Moll while the month turned into a day." - ELSE "$nA ragdoll." - END IF. - - VERB examine - DOES ONLY "It's an old ragdoll with red hair. One of the eyes has dropped over the course of years." - MAKE doll found. - END VERB. - - VERB drop - DOES ONLY LOCATE doll IN table. - "You put the doll back on the table." - END VERB. - -END THE. - - -THE pepper_dispenser ISA OBJECT - NAME pepper dispenser - IN table - IS NOT found. - DESCRIPTION - IF pepper_dispenser IS NOT found - THEN "$nDid the late Lady D. (what was her last name again?) use one of these to spice her food?" - ELSE "$nA pepper dispenser." - END IF. - - VERB examine - DOES ONLY "A spice dispenser made of glass. It seems to contain ground ros pepper." - MAKE pepper_dispenser found. - END VERB. - - VERB drop - DOES ONLY LOCATE pepper_dispenser IN table. - "You put the dispenser back on the table." - END VERB. - -END THE. - - -THE candle ISA OBJECT - IN table - IS NOT found. - DESCRIPTION - IF candle IS NOT found - THEN "$nInstructions for use: handle with c. and drop your h's. Should be burnt at one end only." - ELSE "$nA yellow candle." - END IF. - - VERB examine - DOES ONLY "A thick yellow candle, only slightly used." - MAKE candle found. - END VERB. - - VERB burn - DOES ONLY "There is no time for that now. (For some reason, you feel you have to get out of here in max. two hours.)" - END VERB. - - VERB drop - DOES ONLY LOCATE candle IN table. - "You put the candle back on the table." - END VERB. - -END THE. - - -THE handsaw ISA OBJECT - NAME saw NAME handsaw - DESCRIPTION "$pThere is a small handsaw here." - - VERB examine - DOES ONLY "It's a small handsaw." - IF hero AT lr THEN "$p$p(The Kitchen)$nIt's a small handsaw." END IF. - END VERB. - - VERB drop - DOES ONLY "You decide to hold on to the handsaw. It was rewarded to you for a reason." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou decide to hold on to the handsaw. - It was rewarded to you for a reason." END IF. - END VERB. - -END THE. - - -THE bdoor ISA DOOR AT bbr - NAME door - MENTIONED "door" - IS NOT closed. - DESCRIPTION "" - - VERB examine - DOES ONLY "It's a white-painted wooden door." - END VERB. - -END THE. - - -THE bwindow ISA WINDOW AT bbr - NAME window - IS closed. - DESCRIPTION "" -END THE. - -WHEN COUNT ISA OBJECT, IN scale = 3 - THEN IF candle IN scale AND mirror IN scale AND photo IN scale - THEN SCHEDULE scale_solved_message AT hero AFTER 0. - ELSE SCHEDULE scale_losing_message AT hero AFTER 0. - END IF. - - -EVENT scale_solved_message - IF scale IS figured_out THEN - "$pWhen you place the candle, the mirror and the photo onto the scale, the two weights become now exactly level. - There is a quiet click and a secret compartment in the table turns open spitting out, of all things, a small handsaw. - The compartment closes again." - LOCATE handsaw AT bbr. - MAKE scale NOT figured_out. - ELSE "$pNothing special happens." - END IF. -END EVENT. - - - -EVENT scale_losing_message - "$pWhen you place the three objects onto the scale, nothing special happens. The two cups of the scale - are still unbalanced. You'll have to try something else. You empty the scale and place the objects again onto the table." - EMPTY scale IN table. -END EVENT. - - -SYNTAX hint_1 = hint 'on' first. -SYNTAX hint_2 = hint 'on' second. -SYNTAX hint_3 = hint 'on' third. -SYNTAX hint_4 = hint 'on' fourth. -SYNTAX hint_5 = hint 'on' fifth. -SYNTAX hint_6 = hint 'on' sixth. -SYNTAX hint_7 = hint 'on' seventh. - - - - -VERB hint_1 DOES "Did you try ""tool""? That doesn't work, so the answer must be something else. Could it be ""jos""? Or ""sepho""? Wait, - those are not objects... (No more hints for the first object.)" END VERB. - -VERB hint_2 DOES "Month is an M and day is a D. (No more hints for the second object.)" END VERB. - -VERB hint_3 DOES "An opposite often means the other way around. (No more hints for the third object.)" END VERB. - -VERB hint_4 DOES "The beginning and the end of the first sentence count. See what you get and use its more common synonym. - (No more hints for the fourth object.)" END VERB. - -VERB hint_5 DOES "Unscrambling ""lyric vendor"" will help. So do also the initials given in the riddle. (No more hints for the fifth - object.)" END VERB. - -VERB hint_6 DOES "Lady Diana's family name will reveal ca. 80% of this object's name. Where could the rest come from? - (No more hints for the sixth object.)" END VERB. - -VERB hint_7 DOES """Handle"" plus ""c"" equals something. Drop the ""h"" and you have the solution. (No more hints for the seventh object.)" - END VERB. - - ------------------------------------- - - - - -THE landing ISA ROOM - DESCRIPTION "You are standing on a small landing upstairs. There is a white bedroom to the north and - a darker, red-painted bedroom to the south. You can also go down the stairs to the living-room." - EXIT north TO wbr. - EXIT south TO bbr - DOES SCHEDULE bbr_briefing AT hero AFTER 0. - END EXIT. - EXIT down TO lr - DOES SCHEDULE livingroom_briefing AT hero AFTER 0. - END EXIT. -END THE. - - - --- DOWNSTAIRS ---------------------------------------------------------------------------------------------------------- - -THE lr ISA ROOM - NAME 'The' 'Living-Room' - - DESCRIPTION "Most furniture has been taken away from here. You only see an old threadbare sofa against the boarded - window which allows just enough sunlight in for you to see around well enough. On the northern wall there - is a small fireplace. The front door is to the east and currently" - - IF f_door IS locked - THEN "locked." - ELSIF f_door IS closed - THEN "unlocked but closed." - ELSE "open." - END IF. - - "Another door leads west into the kitchen." - - IF kitchen_door IS locked - THEN - "It is currently locked." - ELSIF kitchen_door IS closed - THEN "It is currently unlocked but closed." - ELSE "It is currently open." - END IF. - - IF ring AT lr - THEN "$pA silver ring lies in the ashes of the fireplace." - END IF. - - "$p$p(The Kitchen)$n" - DESCRIBE kitchen. - - - EXIT east, 'out' TO oh_e - CHECK - IF f_door IS locked - THEN "The front door is locked. - $p$p(The Kitchen) - $nThe door east to the living-room is locked." - ELSIF f_door IS closed - THEN "The front door is closed. - $p$p(The Kitchen) - $nThe door east to the living-room is locked." - ELSIF f_door IS NOT closed - THEN "The boards block your way. - $p$p(The Kitchen)$nThe door east to the living-room is locked." - END IF. - - END EXIT. - - - EXIT 'up' TO landing. - - - EXIT west TO kitchen - CHECK - IF kitchen_door IS locked - THEN "The door west to the kitchen is locked. - $p$p(The Kitchen) - $nYou can't go that way." - ELSIF kitchen_door IS closed - THEN "The door west to the kitchen is closed. - $p$p(The Kitchen) - $nYou can't go that way." - ELSE LOCATE hero AT kitchen. - END IF. - END EXIT. - - - - VERB 'wait' - DOES ONLY - "Time passes... - $p$p(The Kitchen) - $nTime passes..." - - END VERB. - - -END THE. - - - -THE f_door ISA DOOR AT lr - NAME front door NAME front - MENTIONED "front door" - DESCRIPTION "" - IS lockable. IS locked. - IS bolted. - - VERB examine - DOES ONLY "The white front door is equipped with both a lock and a bolt." - - IF f_door IS locked - THEN "The door is locked." - ELSE IF f_door IS closed - THEN - "The door is unlocked but closed." - ELSE - "The door is open." - END IF. - - END IF. - - IF bolt IS closed - THEN "You still have to open the bolt before the door can be opened." - END IF. - - - IF f_door IS locked - THEN - "$p(To try unlocking the door with a key, it is enough to type - UNLOCK DOOR WITH KEY; it is not necessary to refer to the lock.) - $p$p(The Kitchen)$nYou can't see any such thing." - END IF. - - IF f_door IS NOT closed - THEN "Three boards have been nailed across the door, blocking your way out." - END IF. - - END VERB. - - VERB unlock_with - WHEN obj - DOES ONLY - "You unlock the door. - $p$p(The Kitchen)$nYou can't see any such thing." - MAKE f_door NOT locked. - END VERB. - - VERB open - DOES ONLY - IF bolt IS closed OR bolt IS NOT oiled - THEN "You can't open the door since it is bolted. - $p$p(The Kitchen)$nYou can't see any such thing." - ELSE "You open the door. - The three boards that have been nailed across the front door block your passage out. - $p$p(The Kitchen)$nYou can't see any such thing." - LOCATE boards AT lr. MAKE f_door NOT closed. - END IF. - END VERB. - - VERB unbolt - DOES - IF bolt IS NOT oiled - THEN "The bolt won't budge however much you try to pull it. It seems to be rather rusty." - "$p$p(The Kitchen)$nYou can't see any such thing." - ELSE "You pull the oiled bolt open with relative ease." - "$p$p(The Kitchen)$nYou can't see any such thing." - MAKE bolt NOT closed. MAKE f_door NOT bolted. - END IF. - END VERB. - - VERB oil - DOES ONLY "The door itself doesn't seem to need oiling. - $p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - VERB push - DOES "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - VERB pull - DOES "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - - -END THE. - - -THE f_lock ISA OBJECT AT lr - NAME lock NAME keyhole - IS NOT takeable. - DESCRIPTION "" - - VERB examine - DOES ONLY "It's a normal keyhole accepting a medium-sized key." - "$p(To try unlocking the door, it is enough to UNLOCK DOOR WITH KEY; you don't have to refer to the lock." - "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - -END THE. - - - -THE bolt ISA OBJECT AT lr - NAME bolt NAME metal bar - IS closeable. IS closed. - IS NOT oiled. - IS NOT takeable. - DESCRIPTION "" - - VERB examine - DOES ONLY - IF bolt IS closed - THEN "The metal bar of the bolt is in the socket in the door frame. You'll have to pull the bolt open - for the door to open." - "$p$p(The Kitchen)$nYou can't see any such thing." - ELSE "You have pulled the bolt open." - "$p$p(The Kitchen)$nYou can't see any such thing." - END IF. - END VERB. - - - VERB open - DOES ONLY - IF bolt IS NOT oiled - THEN "The bolt won't budge however much you try to pull it. It seems to be rather rusty." - "$p$p(The Kitchen)$nYou can't see any such thing." - ELSE "You pull the oiled bolt open with relative ease." - "$p$p(The Kitchen)$nYou can't see any such thing." - MAKE bolt NOT closed. MAKE f_door NOT bolted. - END IF. - END VERB. - - - VERB pull - DOES ONLY - IF bolt IS NOT oiled - THEN "The bolt won't budge however much you try to pull it. It seems to be rather rusty." - "$p$p(The Kitchen)$nYou can't see any such thing." - ELSE "You pull the oiled bolt open with relative ease." - "$p$p(The Kitchen)$nYou can't see any such thing." - MAKE bolt NOT closed. MAKE f_door NOT bolted. - END IF. - END VERB. - - - VERB close - DOES ONLY "It wouldn't serve any of your purposes to close the bolt." - "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - - VERB oil - DOES ONLY - IF bottle IN hero - THEN "You oil the bolt using the bottle you found in the white bedroom." - MAKE bolt oiled. - "$p$p(The Kitchen)$nYou can't see any such thing." - ELSE "You don't have anything to oil the bolt with." - "$p$p(The Kitchen)$nYou can't see any such thing." - END IF. - END VERB. - - -END THE. - - -SYNTAX oil = oil (obj) - WHERE obj ISA OBJECT - ELSE "That doesn't need oiling." - -ADD TO EVERY OBJECT -VERB oil DOES "That doesn't need oiling." END VERB. -END ADD TO. - - -THE sofa ISA SUPPORTER AT lr - DESCRIPTION "" - IS NOT takeable. - - VERB examine - DOES ONLY "It's a threadbare, dusty sofa." - "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - VERB search - DOES ONLY "You find nothing further of interest." - "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - VERB look_under - DOES ONLY "You notice nothing unusual under the sofa." - "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - VERB look_behind - DOES ONLY "You notice nothing unusual behind the sofa." - "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - -END THE. - - -THE fireplace ISA OBJECT AT lr - NAME fireplace NAME ashes - DESCRIPTION "" - IS NOT takeable. - - VERB examine - DOES ONLY "It's a small fireplace built of red bricks. Some ashes have been left in the fireplace." - IF ring NOT AT lr - THEN "$pSomething glitters among the ashes." - END IF. - "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - VERB search - DOES ONLY - IF ring NOT AT lr - THEN - "You find a blackened silver ring amongst the ashes." - "$p$p(The Kitchen)$nYou can't see any such thing." - LOCATE ring AT lr. LOCATE silver AT lr. - ELSE - "You find nothing else of interest." - END IF. - END VERB. - -END THE. - - -THE ring ISA OBJECT - NAME silver ring NAME blackened - HAS value 1. - DESCRIPTION "" - - VERB examine - DOES ONLY "It's a small silver ring, blackened from having lied in the ashes for who knows how long." - "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - - VERB search - DOES ONLY "You find nothing further of interest." - "$p$p(The Kitchen)$nYou find nothing further of interest." - END VERB. - - VERB take - DOES ONLY - IF value OF ring = 1 - THEN - "You pick up the silver ring and turn it in your hands for a while. Well well, what should you make of this? - A final scene of divorce before the people who used to live here moved out altogether? You'll never know, - and you won't have to. Carefully you put the ring back to where you found it." - INCREASE value OF ring. - ELSE - "You don't feel like picking the ring up another time." - END IF. - "$p$p(The Kitchen)$nYou can't see any such thing." - END VERB. - - VERB wear - DOES ONLY "You don't feel like wearing somebody else's ring." - IF key AT kitchen - THEN "$p$p(The Kitchen)$nThat's not something you can wear." - END IF. - END VERB. - -END THE. - - -THE silver ISA OBJECT - MENTIONED "ring" - HAS value 1. - DESCRIPTION "" - - VERB examine - DOES ONLY "It's a small silver ring, blackened from having lied in the ashes for who knows how long." - IF key AT kitchen - THEN "$p$p(The Kitchen)$nIt's a shiny silver key." - END IF. - END VERB. - - - VERB search - DOES ONLY "You find nothing further of interest." - "$p$p(The Kitchen)$nYou find nothing further of interest." - END VERB. - - - VERB take - DOES ONLY - IF value OF ring = 1 - THEN - "You pick up the silver ring and turn it in your hands for a while. Well well, what should you make of this? - A final scene of divorce before the people who used to live here moved out altogether? You'll never know, - and you won't have to. Carefully you put the ring back to where you found it." - INCREASE value OF ring. - ELSE - "You don't feel like picking the ring up another time." - END IF. - IF key AT kitchen - THEN "$p$p(The Kitchen)$nTaken." - LOCATE key IN hero. - LOCATE silver AT nowhere. - END IF. - END VERB. - - VERB wear - DOES ONLY "You don't feel like wearing somebody else's ring." - IF key AT kitchen - THEN "$p$p(The Kitchen)$nThat's not something you can wear." - END IF. - END VERB. - -END THE. - - -THE lr_window ISA WINDOW AT lr - NAME window - DESCRIPTION "" -END THE. - - - - -THE kitchen_door ISA DOOR AT lr - NAME kitchen door - IS lockable. IS locked. - DESCRIPTION "" -END THE. - - -THE kitchen ISA ROOM - DESCRIPTION "An old oven stands against one wall, - and you can also see a rusty fridge and some cupboards here." - IF key AT kitchen - THEN IF key NOT IN hero - THEN "On a table in the middle of the room there is a shiny silver key." - END IF. - END IF. - "Otherwise there is nothing of importance to be seen around. The door to - the living-room is to the east." -END THE. - - - - - - -THE oven ISA SCENERY AT kitchen -END THE. - -THE fridge ISA SCENERY AT kitchen - NAME fridge NAME cupboards -END THE. - -THE k_table ISA SCENERY AT kitchen - NAME table -END THE. - -THE kitchen_window ISA WINDOW AT kitchen - NAME window -END THE. - -THE key ISA OBJECT AT kitchen - NAME silver key NAME silver NAME shiny - MENTIONED "key" - - VERB examine - DOES ONLY "It's a shiny silver key." - END VERB. - - VERB drop - DOES ONLY "Never throw away the keys you've found - that's what you've learned from - countless text adventures." - IF key IN hero - THEN "$p$p(The Kitchen)$nNever throw away the keys you've found - that's what you've learned from - countless text adventures." - END IF. - END VERB. - -END THE. - - - - --- EVENTS ------------------------------------------------------------------------------------------------------------------- - - - -EVENT welcome - "$p$p$pFor a while you look around, somewhat perplexed. Then the inevitable question pops into your mind: where the heck is - the location description? It looks as if you have to figure it out yourself, and that's what you will definitely do - until each of those - dotted lines is replaced by a sentence." - IF visited OF wbr < 2 - THEN - "You have the feeling that the house is playing - tricks on you in its attempts to resist being torn down." - END IF. -END EVENT. - - -THE bbr_object ISA OBJECT - HAS value 0. -END THE. - -EVENT bbr_briefing - IF value OF bbr_object < 2 - THEN - "$pIt seems that the names of the objects on the table have been obscured." - IF visited OF bbr < 2 THEN - "The house insists on giving you a hard time." - END IF. - "$p(To guess an object, just examine it straight with its real name.)" - INCREASE value OF bbr_object. - END IF. -END EVENT. - - -EVENT livingroom_briefing - IF visited OF lr < 2 - THEN - "$p$pHmm. Whats' up with the double location description, of both the living-room and the kitchen?" - SCHEDULE livingroom_briefing2 AT hero AFTER 1. - END IF. -END EVENT. - - -EVENT livingroom_briefing2 - "$p$pYou slowly deduce what's going on. - Here your every command is carried out first in the living-room and immediately afterwards in the kitchen, - as if you were present in the two locations simultaneously. It's also quite obvious that trying to do something unsuccessfully - in the living-room will stop the action, and the command won't be carried out in the kitchen. You'll have to be careful." -END EVENT. - - -EVENT ending - "$pYou emerge out of the house. - The constructors, having spotted you a while ago, are already waiting outside with their bulldozers, some way off. - $p""Well, what's your verdict, Paladin?"" they shout eagerly. - $pStanding in the doorway, it's suddenly crystal-clear what you have to say. With a loud voice, you shout back your message to them: - $p""I'm sorry to tell you, good sirs,"" you answer, ""that there will be no work for your machines today - this house is to stay erect. - It has given me great pleasure to roam through it; I've learned something of its character and - have actually grown quite fond of it. - I know that it has to go from this spot - I will have it transferred to a pleasant estate on the outskirts of town where it - shall stand in a location it deserves and where it shall receive a renovation that will do it justice. - You see, this house has got that spirit of adventure I know how to appreciate. - Gentlemen, it's been a pleasure working for you."" - $pWith all of that said you turn away, re-enter the house and close the door. - $p> sleep on sofa - $p$i * * * $tYou take a well-earned nap.$t* * *$p" - QUIT. -END EVENT. - - -VERB xyzzy DOES "Yeeeeeeeeeehaaaaaaaaaaaaa!" END VERB. -VERB plugh DOES "Sorry, we only serve coffee here." END VERB. -VERB clap DOES "Nothing happens against the empty echo of your clapping." END VERB. - - ------------------------------------------------------------------------------------------------------------------------------ - -VERB walkthru - - DOES - - "Getting into the house: nw, sw, lift fence, ne, put ladder against wall, u. - - $pWhite bedroom: x door, look under bed, x piano, play piano, x dresser, x drawer, open drawer, x shoes, - open wardrobe, x jacket, search jacket, read note, play ""f"" on the piano, play ""g"" on the piano, - play ""d"" on the piano, take bottle, s. - - $pRed bedroom: read note, x photo, x doll, x novel, x lp, x mirror, x dispenser, x candle, put photo on scale, - put mirror on scale, put candle on scale, take handsaw, n, d. - - $pLiving-room: oil bolt, open bolt, x fireplace, search ashes, take silver, unlock front door with key, open front door, saw boards, out." - -END VERB. - - -SYNONYMS walkthrough = walkthru. - - -THE banner ISA OBJECT - DESCRIPTION - STYLE alert. "$pTed Paladin And The Case of The Abandoned House" STYLE normal. - "$nby Anssi Risnen" -- enter your name here. - "$nVersion 1" -- provide a version number if you want, otherwise delete this entire line. - "$nProgrammed with ALAN 3 beta2 for IFComp 2011 - $nIf you're stuck, type 'help' or 'hint'. - $nType 'walkthru' to see the walkthrough. - $nType 'credits' for credits and acknowledgments. - $nAll rights reserved." - -END THE. - - -START AT oh_e. - SHOW 'TPCover1.png'. - "$pProgress is unstoppable. The world is in constant motion towards a brighter tomorrow. - Old things, when no longer of use, must yield to new concepts and ideas. - $pThis is where you come in. An age-old, abandoned house stands in the way of a new shopping complex scheduled to be built downtown. - All attempts at locating the legal proprietor of the house have failed, and you were approached in hopes of making - sure that it is safe to bulldoze the building with nothing of value left inside. - They couldn't have picked a better man for the job; after all, you're Ted Paladin, a seasoned text adventurer, - an intruder into the most impossibly implemented houses and an exposer of their darkest secrets. You're ready for another mission.$p" - - -DESCRIBE banner. - - - - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/classes.i b/app/src/main/jni/terps/alan/alan3/bugs/abandoned/classes.i deleted file mode 100755 index 1f9bbc2..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/classes.i +++ /dev/null @@ -1,2636 +0,0 @@ --- ALAN Standard Library v1.00 --- Classes (file name: 'classes.i') - - --- This library file defines various object and actor classes, as well as the --- instance 'hero'(=the player character). Many of these classes are frequently --- used in verb definitions in 'verbs.i' so they should be edited or --- removed with caution. However, to ease things up, it is mentioned at the --- beginning of every class below if and where the class is cross-referenced --- in the other library files. - - --- Contents: - - - - --- 1. OBJECT CLASSES --- ================= - - - --- BACKGROUND - -- Is present in the location but cannot be reached or taken. - -- Doesn't appear automatically in room descriptions. - -- A typical example of a background would be for example the sun, - -- or a mountain visible in the distance. - -- Compare this with 'scenery' below (a background object cannot be reached, - -- but a scenery object can.) - - --- CLOTHING - -- Is a piece of clothing that behaves according to Alan Bampton's 'xwear.i' extension. - -- The said extension has been fully assimilated to this library. - -- This extension prevents clothes from being worn in an illogical order, e.g. you - -- cannot put on a shirt if you are already wearing a jacket, and so forth. - -- Also the verbs 'wear', 'remove' and 'undress' are defined here. - - --- DEVICE - -- Is a machine or an electronic device, for example a TV. Can be turned - -- (=switched) on and off if it is not broken. - -- Attributes: 'on' and NOT 'on', NOT broken. - -- Is described automatically as being either on or off when examined. - - --- DOOR - -- Can be opened, closed, locked and unlocked. - -- Is by default closed, not locked. - -- Attributes: closeable, (NOT) closed, lockable, (NOT) locked. - -- Is described automatically as being either open or closed when examined. - - --- LIQUID - -- Can only be taken if it is in a container. You can fill something with it, - -- and you can pour it somewhere. - -- A liquid is by default NOT drinkable. - - --- LIGHTSOURCE - -- IS natural or NOT natural - -- (a natural lightsource is for example a match or a torch). - -- Can be turned on and off, lighted and extinguished (= put out) if it - -- is not broken. A natural lightsource - -- cannot be turned on or off, it can only be lighted and extinguished (= put out). - -- When examined, a lightsource is automatically supplied with a description of - -- whether it is providing light or not. - - --- LISTABLE_CONTAINER - -- Is a special kind of container, the contents of which will be listed both after - -- 'look' (= in the room description), 'look in' and 'examine' (if the container is open). - -- (The contents of a normal container object are not listed after 'examine' but only - -- after 'look' (=room description) and 'look in'). - - --- SCENERY - -- Behaves like a normal object, can be reached and manipulated but not taken. - -- The default message for 'take' will be "Unimportant for your purposes, you decide to - -- leave the [object] where it is." - -- The default message for 'examine' will be "The [object] doesn't appear particularly - -- interesting." - -- A scenery object is not automatically listed after the room description when - -- you type 'look'. You have to include it manually in the room description. - -- Compare this with 'background' above (a scenery object can be reached, - -- but a background object cannot.) - - --- SOUND - -- Can be listened to but not examined, searched, smelled or manipulated. - -- Cannot initially be turned on or off, this has to be implemented manually by giving - -- the sound the 'switchable' attribute. - - --- SUPPORTER - -- You can put things on this and you can stand on this. It is declared a container, - -- so you can take things from it, as well. When there's something on a supporter, - -- an automatic listing of it will appear in the room description and after 'examine'. - - --- WEAPON - -- IS fireable (e.g. a cannon) or NOT fireable (e.g. a baseball bat). - - --- WINDOW - -- Can be opened, closed, looked through and out of. - -- Will be automatically described as being either open or closed when examined. - - - --- 2. ACTOR CLASSES --- ================ - --- the ACTORS are defined here to be NOT inanimate CONTAINERS (so that they can e.g. --- receive and carry things. The 'contents' (= possessions) of an actor (except for the hero) --- are automatically listed after 'look' and 'examine'. (For the hero, the command 'inventory' --- must be used.) --- --- Actors are usually preceded by an article in-game: --- e.g. "You see a man here." --- "There is nothing special about the dog." --- unless they are declared as 'named'. --- --- The following classes for actors are defined in this library: - - --- PERSON - -- is able to talk (= 'CAN talk'). - - --- FEMALE - -- a subclass of person (= is able to talk) - -- can be referred to with the pronoun 'her' - - --- MALE - -- a subclass of person (= is able to talk) - -- can be referred to with the pronoun 'him' - - - - - --- 3. INSTANCES --- ============ - - --- the hero - - - - --- The contents end here. - - - --- ============================================================= - --- ============================================================= --- --- 1. Object classes --- --- ============================================================= - --- ============================================================= - - - - - --- ============================================================= - - ------ BACKGROUND - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY background ISA THING - IS NOT reachable. - DESCRIPTION "" -END EVERY. - - --- Note that a background object in ALAN3 is different from e.g. the backdrop in Inform7 --- in that a background object is at one location at a time only, unless --- you use the nested locations feature in ALAN which makes the object available --- in several locations. --- Here is an example where a ceiling lamp is located in the lobby, the bedroom --- and the living-room of a house, but not in other locations: - - --- 1) First, define the area where the object(s) should be found: - --- THE lamp_rooms ISA LOCATION -- i.e. the area in which we'll nest --- END THE. -- the three rooms mentioned above - --- and then define which locations belong to that area: - --- THE lobby ISA LOCATION IN lamp_rooms --- END THE. - --- THE bedroom ISA LOCATION IN lamp_rooms --- END THE. - --- THE livingroom ISA LOCATION IN lamp_rooms --- END THE. - - - --- 2) Then, place the background object in the area: - --- THE ceiling_lamp ISA BACKGROUND IN lamp_rooms --- NAME ceiling lamp --- END THE. - - --- Now, the lamp is found in all of the above locations. - --- Note that in this code you could define exits to other rooms of the house in the --- normal way, without having to worry about the area at all, e.g.: - --- THE bedroom ISA LOCATION IN lamp_rooms --- EXIT west TO upstairs_landing. --- END THE. - --- THE upstairs_landing ISA LOCATION -- ( = a location outside the defined area) --- EXIT east TO bedroom. --- END THE. - --- etc. - --- Naturally, you could also define a scenery object or a normal object to be --- in several locations at once, in the same way. Note, however, that if you define --- a takeable object in this manner, it will disappear from the other locations once --- you take it in one location. Also, when manipulated (e.g. broken), the object --- will be affected in all of the locations it is found. - - - --- ============================================================== - - ------ CLOTHING (+ the verbs WEAR, REMOVE, UNDRESS) - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'inventory' and 'take' where the --- container 'worn', defined below, is used in the verb definitions.) - - --- To use this class, see the documentation text right after the --- code below. --- This class makes use of Alan Bampton's 'xwear.i' extension --- written originally for ALAN V2, converted here to V3 and --- assimilated fully to the present library. Thanks to Alan Bampton --- for the permission to use the code here. - - ------------------------------------------------------------------ --- First, we declare the container for clothing. ------------------------------------------------------------------ - - -THE worn ISA ENTITY -- an entity is present everywhere and thus the hero's - CONTAINER TAKING CLOTHING. -- clothing is always accessible - HEADER "You are wearing" - ELSE "You're not wearing anything." -END THE. - - -------------------------------------------------------------------- --- Next, we define the syntaxes for verbs needed for putting on --- and taking off clothing. -------------------------------------------------------------------- - - -SYNTAX wear = wear (clothing) - WHERE clothing ISA CLOTHING - ELSE - IF clothing IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can wear." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - wear = put 'on' (clothing). - wear = put (clothing) 'on'. - wear = don (clothing). - - -SYNTAX remove = remove (clothing) - WHERE clothing ISA CLOTHING - ELSE - IF clothing IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can remove since you're not wearing" - IF clothing IS NOT plural - THEN "it." - ELSE "them." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - remove = take 'off' (clothing). - remove = take (clothing) 'off'. - remove = doff (clothing). - -SYNTAX undress = undress. - - -------------------------------------------------------------------- --- Now, we define some common attributes for clothing as well as --- how the above verbs behave with this class. -------------------------------------------------------------------- - - -EVERY clothing ISA OBJECT - - IS wearable. - IS sex 0. - IS headcover 0. - IS handscover 0. - IS feetcover 0. - IS topcover 0. - IS botcover 0. - - CONTAINER -- to allow e.g. a wallet to be put into a jacket - - - VERB wear - - CHECK THIS NOT IN worn - ELSE "You are already wearing" SAY THE THIS. "." - AND THIS IS takeable - ELSE "You can't pick" SAY THE THIS. "up." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND sex OF THIS = sex OF hero OR sex OF THIS = 0 - ELSE - "On second thoughts you decide" - SAY THE THIS. "really won't suit a" - IF sex OF hero =1 - THEN "man" - ELSE "woman" - END IF. - "like you at all." - - - DOES ONLY - - --------------------------------------------------------------------- --- 'wear_flag' is a multi-purpose flag used for several purposes in --- this library, here it is reset to 0 before proceeding as a matter --- of 'housekeeping' for the code. --------------------------------------------------------------------- - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- First check to see if the player is carrying the item already, if --- not, set the 'wear_flag' to 1 to indicate the item was picked up --- in this turn. --------------------------------------------------------------------- - - - IF THIS NOT IN hero - THEN - SET wear_flag OF hero TO 1. - END IF. - - --------------------------------------------------------------------- --- Now see if the player can put this item on by testing --- all of its coverage attributes against the player's state. --------------------------------------------------------------------- - - --------------------------------------------------------------------- --- First check the 'topcover' attributes, if 'obj' fails this test --- then it means the hero is already wearing clothes that cover the --- topcover area and those clothes are of the same layer or a layer --- that belongs on top of the 'obj' item. In either case it would --- NOT be possible to put on the 'obj'. To 'flag' this condition add --- 5 to the 'wear_flag' attribute as an indicator this test failed. --------------------------------------------------------------------- - - - IF topcover OF THIS <> 0 AND topcover OF THIS <= SUM OF topcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - --- IF THIS IN tempworn THEN - IF handscover OF THIS <> 0 AND handscover OF THIS <= SUM OF handscover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF feetcover OF THIS <> 0 AND feetcover OF THIS <= SUM OF feetcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - - IF headcover OF THIS <> 0 AND headcover OF THIS <= SUM OF headcover IN worn - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case, adjust the 'tempcovered OF hero' --- attribute so that the code rejects non sensible options. --- First of all, discount any coatlike clothes as these never --- affect ability to put on other lower body only garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 and botcover OF THIS < 33 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not technically affect ability to put on lower body only clothes. --- Special clause here excludes the full body coverage 'teddy' type --- garment - as a skirt WOULD prevent that from being removed. --- ( dress/coat garments automatically prevent this by virtue of --- having higher 'topcover' settings than the teddy ) --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 AND botcover OF THIS < 16 and botcover OF THIS <> 4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- IF tempcovered OF hero is still > 15 then must have trousers --- type clothing on - therefore disallow wearing dress type clothing --- because, although technically possible, it is not very sensible. --------------------------------------------------------------------- - - - IF tempcovered OF hero >15 AND botcover OF THIS > 16 - THEN - SET tempcovered OF hero TO tempcovered OF hero +16. - END IF. - - --------------------------------------------------------------------- --- From here down, clothes DO work as they do for other areas. --------------------------------------------------------------------- - - - IF botcover OF THIS <> 0 AND botcover OF THIS <= tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 5. - END IF. - - --------------------------------------------------------------------- --- At this point, 'wear_flag' will be 0 if the obj was held by the --- player and can be put on, or l if he picked it up this turn and --- it can be put on. Any higher value means one or more of the --- tests failed and the player cannot put on these clothes. --------------------------------------------------------------------- - - - IF wear_flag OF hero >1 THEN - IF THIS NOT IN hero - THEN "You pick up the" SAY THE THIS. "." - END IF. - LOCATE THIS IN hero. - EMPTY worn IN tempworn. - LIST tempworn. - "Trying to put" - SAY THE THIS. - "on isn't very sensible." - EMPTY tempworn IN worn. - ELSIF wear_flag OF hero = 1 - THEN - "You don't feel like putting on" SAY THE THIS. "." - ELSE - "You don't feel like putting on" SAY THE THIS. "." - END IF. - -END VERB. - - - -VERB remove - CHECK THIS IN worn - ELSE - "You are not wearing" SAY THE THIS. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - - DOES ONLY - - - SET wear_flag OF hero TO 0. - - --------------------------------------------------------------------- --- Check the total 'topcover' of items worn. Because of the number --- sequence used, by dividing the sum of the worn attributes by two --- and then comparing the result to the individual 'topcover' of the --- obj in question, ( the former can only ever be greater than the --- latter if an article of clothing is worn that goes over 'obj' ) --- it's easy to tell if the obj ought to be removable. A temporary --- attribute is used here because it needs to be manipulated. Once --- again 'wear_flag' is used to indicate the results. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF topcover IN worn /2. - IF topcover OF THIS <> 0 AND topcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Perform a similar test for other attributes. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF handscover IN worn /2. - IF handscover OF THIS <> 0 AND handscover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF feetcover IN worn /2. - IF feetcover OF THIS <> 0 AND feetcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - - SET tempcovered OF hero TO SUM OF headcover IN worn /2. - IF headcover OF THIS <> 0 AND headcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- botcover is a special case - first discount any coatlike clothes --- as these do not affect ability to take off other lower garments. --------------------------------------------------------------------- - - - SET tempcovered OF hero TO SUM OF botcover in worn. - IF tempcovered OF hero >63 - THEN - SET tempcovered OF hero TO tempcovered OF hero -64. - END IF. - - --------------------------------------------------------------------- --- Now discount any dress/ skirt coverall like clothes as these do --- not affect ability to take off other lower garments. The 'teddy' --- type garment is expressly NOT included in the exclusion here. --------------------------------------------------------------------- - - - IF tempcovered OF hero >31 and botcover OF THIS <>4 - THEN - SET tempcovered OF hero TO tempcovered OF hero -32. - END IF. - - --------------------------------------------------------------------- --- Now process the manipulated value just as was done for the others --------------------------------------------------------------------- - - - SET tempcovered OF hero TO tempcovered OF hero /2. - IF botcover OF THIS <> 0 AND botcover OF THIS < tempcovered OF hero - THEN - INCREASE wear_flag OF hero BY 1. - END IF. - - --------------------------------------------------------------------- --- Depending on the value of 'wear_flag' print and process the obj --- as needed. If 'wear_flag' is NOT 0 then the clothes cannot be --- removed. --------------------------------------------------------------------- - - - IF wear_flag OF hero >0 THEN - LIST worn. - "Trying to take" SAY THE THIS. "off isn't very sensible." - ELSE - LOCATE THIS IN hero. - "You take off" SAY THE THIS. "." - END IF. -END VERB. - - --------------------------------------------------------------------- --- The verb 'undress' needs to be defined outside the object class --- as it is intransitive: --------------------------------------------------------------------- - - -VERB undress - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF COUNT IN worn, ISA CLOTHING > 0 - THEN "You don't feel like undressing is a good idea right now." - ELSE "You're not wearing anything you can remove." - END IF. - - -- or, to make it work, use the following lines instead: - --IF COUNT IN worn, ISA CLOTHING > 0 - --THEN EMPTY worn IN hero. - --"You remove all the items you were wearing." - --ELSE "You're not wearing anything you can remove." - -- END IF. -END VERB. - - - -VERB examine - DOES AFTER - IF THIS IS NOT OPAQUE - THEN - IF COUNT ISA OBJECT, IN THIS > 0 -- if the piece of clothing contains - THEN LIST THIS. -- something, e.g. if a jacket contains a wallet, - END IF. -- the wallet will be mentioned when the - END IF. -- jacket is examined -END VERB. - - -END EVERY. - - - --------------------------------------------------------------------- --- These attributes are used internally in the library - ignore! --------------------------------------------------------------------- - -ADD TO EVERY ACTOR - IS tempcovered 0. - IS wear_flag 0. - IS sex 0. -END ADD TO. - - --------------------------------------------------------------------- --- A container used to provide a temporary storage space - ignore! --------------------------------------------------------------------- - -THE tempworn ISA OBJECT - CONTAINER TAKING CLOTHING. - HEADER "You're already wearing" -END THE tempworn. - - - ------------------------------------------------------------------------ --- DOCUMENTATION FOR CLOTHING ------------------------------------------------------------------------ - - --- The quick guide ------------------- - --- Here is a quick overview for using the class 'clothing'. --- A more closely-detailed description of this class is found --- below this overview. - - --- A piece of clothing in your game code should look --- something similar to these four examples: - - --- THE jacket ISA CLOTHING AT lobby --- IS topcover 32. --- END THE. - - --- THE jeans ISA CLOTHING IN wardrobe -- IN wardrobe = in a container called the wardrobe; --- IS botcover 16. -- the wardrobe is not a separate location here. --- END THE. - - --- THE hat ISA CLOTHING IN worn -- IN worn = worn by the player character --- IS headcover 2. --- END THE. - - --- THE sweater ISA CLOTHING IN joe_worn -- = worn by an NPC called Joe. --- IS topcover 16. -- Define separate containers like this --- END THE. -- for clothes worn by non-player characters. - -- If you defined here 'IN joe', the clothing - -- would be listed in Joe's possessions: - -- "You see Joe here. Joe is carrying a book and - -- a sweater." For a concrete example of how to do - -- this, scroll down to the class 'actor'. - -- Note also that if the piece of clothing worn - -- by an NPC is not meant to be takeable by the - -- player character, you should declare the - -- the piece of clothing to be NOT takeable. - - --- In defining a piece of clothing, you should --- --- 1) define it ISA CLOTHING (and not: ISA OBJECT) --- --- 2) give it one of five attributes 'headcover', 'topcover', botcover', 'footcover' --- or 'handcover'; sometimes two of these are needed. --- Which attribute(s) to use depends on the type of clothing; see the clothing table below. - --- 3) A number 2, 4, 8, 16, 32 or 64 needs to be added after the above attribute. --- You cannot decide the number yourself; look it up from the clothing table below. --- If the value of an attribute for a piece of clothing is 0 in the table, don't mention --- this attribute in connection with your clothing object. - - --- The above is enough; the rest is then handled automatically by the library. - - --- The quick guide ends here. The clothing table follows right below. The text following the --- table gives more details about the principles and the use of this class. - - --- The clothing table ------------------------ - - --- Here is the chart showing a selection of fairly typical clothing items and the values to --- set to obtain appropriate behaviour. Should you wish to create an article of clothing not --- listed, usually a bit of lateral thought as to what it is most like and where it fits into --- the scheme of things will suggest a workable set of values, but be aware that you MUST use --- values in this chart, simply adding things with intermediate values is probably going to --- create nasty bugs: - - --- Clothing Headcover Topcover Botcover Footcover Handcover - --- hat 2 0 0 0 0 --- vest/bra 0 2 0 0 0 --- undies/panties 0 0 2 0 0 --- teddy 0 4 4 0 0 --- blouse/shirt/T-shirt 0 8 0 0 0 --- dress/coveralls 0 8 32 0 0 --- skirt 0 0 32 0 0 --- trousers/shorts 0 0 16 0 0 --- sweater/pullover 0 16 0 0 0 --- jacket 0 32 0 0 0 --- coat 0 64 64 0 0 --- socks/stockings 0 0 0 2 0 --- tights/pantiehose 0 0 8 2 0 --- shoes/boots 0 0 0 4 0 --- gloves 0 0 0 0 2 - - - --- The concept of "xwear.i" (This and the following paragraphs are taken from Alan ---------------------------- -- Bampton's original 'xwear' documentation, with minor - -- alterations.) - - --- The basic idea behind this part of the library is that clothing is worn in --- 'layers' and it is rather silly to allow players to (say) take off or put --- on a shirt if they are wearing a jacket. To simulate this in ALAN I've chosen --- to apply a numeric based layering system, and divide the body into five zones --- of coverage. The zones are 'head', 'hands', 'feet', 'top' (for top half of torso) --- and 'bot' (for bottom half of torso). --- All objects have these five zones defined as default attributes (set to 0), for the --- head zone the attribute is headcover for the hands zone handscover and so on. --- Every clothing object will thus need one or more of its 'zonecover' attributes --- set to reflect the zone(s) it covers and its relative position in the layers of --- clothing worn. A simple example would be a shirt, this covers only the 'top' zone --- and so needs its topcover attribute to be set (to 8, just why it's 8 will become --- clear shortly). --- The principle used is that the closer to the skin an item is normally worn, --- the lower its 'cover' attribute is. The library operates on the assumption that --- items with higher value cover attributes for a particular zone are worn over items --- with lower value attributes. When a player attempts to put on an article of clothing, --- each zone it would affect is checked and compared to the related zonal total of any --- clothes already worn. If the value of the new clothing is not greater that the total(s) --- of clothing already worn (on a zone by zone basis) then the library will not allow --- the wearing of that item. There are a few notable exceptions to this rule, but --- I'll come back to those a little later. - - --- How it works in practice ---------------------------- - - --- This part of the library might sound complex, but it is actually very simple to use, --- here's an example of how it works. --- Assume our hero starts the game wearing just vest and shorts and the player issues --- the command 'put on shirt'. A quick check of the chart below should reveal that a shirt --- has only its topcover attribute set to non-zero, (all the other zones are zero, --- which means they are irrelevant for this item). --- The library totals the topcover attributes of all the clothes currently worn, like so:- --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- As there are no other clothes to consider, the library now compares the topcover attribute --- of the item we are attempting to put on, (a shirt with a topcover attribute of 8 in --- this case) to the total value of items already worn (2). --- Because the topcover attribute of the shirt (8) is greater than the calculated total (2), --- this is evaluated as being a 'legal' instruction and the library allows the shirt to be put on. --- Now consider the situation had the player started the game wearing vest, shorts and a jacket, --- this is what happens should he try to 'put on the shirt.' --- Starting with a total of 0, and checking the vest, this has a topcover attribute of 2, --- so total topcover is 0 + 2 = 2. --- Next the library checks the shorts, these have a topcover attribute of 0, so total --- topcover is 2 + 0 = 2. --- Finally the library checks the jacket, this has a topcover attribute of 32, so total --- topcover is 2 + 32 = 34. --- Because the topcover attribute of the shirt (8) is now not greater than the calculated --- total (34), this is evaluated as being an 'illegal' instruction and the library won't --- allow the shirt to be put on. --- That demonstrates the basic principle of the library, removing clothes uses a variation --- of the 'compare to total' equation to allow / disallow removal of clothing, an example would --- be that our vest, shorts and jacket wearing player would NOT be allowed to remove --- the vest while he still had the jacket on. - - --- Exceptions to the rule... ----------------------------- - - --- Now I'll confuse the issue. Firstly the numbers in my chart are not born of some sort of --- weird fixation with multiples, there is a very good reason why the numbers are set as they --- are, computer/maths types will recognise the sequence and realise it is all 'binary' based --- and know it makes it possible to calculate exactly what the player is wearing in terms of --- layers. --- Some female clothing breaks the rules defined above and is not so easy to deal with. An example, --- although pantyhose is worn under a skirt, dress or coat it can actually be put on or removed --- with the garment worn over it still on. The library recognises this capability and deals with --- it properly by assigning the dress/skirt and coat items particular properties in that they --- don't affect the ability to wear or remove lower layer clothing that covers the bottom of --- the torso only. --- Although it's physically possible to put on/remove trousers while wearing a skirt or dress, --- this (and a few other neat dressing/undressing tricks) is considered illegal here. - - --- How to create clothes that use 'xwear.i' -------------------------------------------- - - --- That covers the way the library works, here's how to define objects to actually make --- use of it. As an example, this is how to define a dress and restrict it to being worn --- by a female. - - --- THE dress ISA CLOTHING IN changingroom - -- NAME little black dress - -- MENTIONED "little black dress" - -- IS - -- botcover 32. - -- topcover 8. - -- sex 2. --- END THE. - - --- Notice that it is only necessary to mention the attributes that are non-zero, this --- minimises the amount of coding required. Apart from making sure the hero is set as --- 'sex 2.' if we wish her to be able to wear this dress, this is all the author needs --- to do, the library will police what is wearable and keep track of things without any --- further work. --- I expect most authors would prefer to start their games with a player at least partially --- dressed. This is just a matter of defining the required clothes object as being in the --- 'worn' container. Here's how to define underwear that our female hero(ine?) starts --- the game wearing. - - --- THE bra ISA CLOTHING IN worn - -- NAME white bra - -- MENTIONED "white bra" - -- IS - -- topcover 2. - -- sex 2. --- END THE bra. - - --- THE panties ISA CLOTHING IN worn - -- NAME white panties - -- MENTIONED "white panties" - -- IS - -- botcover 2. - -- plural. - -- sex 2. --- END THE panties. - - --- The library as it stands also prevents wearing of duplicate clothes, or things that are --- logically mutually exclusive - e.g. the player can wear a dress or a skirt, but not both. - - - - --- ============================================================= - - ------ DEVICE - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY device ISA OBJECT - IS NOT 'on'. - - - VERB examine - DOES - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - - IF THIS IS 'on' - THEN "currently on." - ELSE "currently off." - END IF. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT 'on' - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND THIS IS NOT broken - ELSE "Nothing happens." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS 'on'. - END VERB. - - - VERB turn_off - CHECK THIS IS 'on' - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already off." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - END VERB. - - --- The following verb switches a device off if the device is on, and vice versa. - - - VERB switch - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS 'on' - THEN "You switch off" SAY THE THIS. "." - MAKE THIS NOT 'on'. - ELSE "You switch on" SAY THE THIS. "." - MAKE THIS 'on'. - END IF. - END VERB. - -END EVERY. - - - --- ============================================================= - - ------ DOOR - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY door ISA OBJECT - IS closeable. - IS closed. - IS lockable. - IS NOT locked. - IS NOT takeable. - - - VERB examine - DOES - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - - IF THIS IS closed - THEN "currently closed." - ELSE "currently open." - END IF. - END VERB. - - - - VERB knock - DOES ONLY - IF THIS IS closed - THEN "You knock on" SAY THE THIS. "$$. There is no reply." - ELSE "You don't find it purposeful to knock on the open door" - IF THIS IS NOT plural - THEN "." - ELSE "$$s." - END IF. - - END IF. - END VERB. - - - - VERB look_behind - DOES ONLY - IF THIS IS closed - THEN "You cannot look behind" - IF THIS IS NOT plural - THEN "the door - it is closed." - ELSE "the doors - they are closed." - END IF. - ELSE "You notice nothing special behind the door" - IF THIS IS NOT plural - THEN "." - ELSE "$$s." - END IF. - END IF. - END VERB. - - - - VERB look_under - DOES ONLY - IF THIS IS closed - THEN "The gap under the closed door" - IF THIS IS plural - THEN "$$s" - END IF. - "is so narrow that you can't - see anything of what lies on the other side." - ELSE "You notice nothing special under the door" - IF THIS IS plural - THEN "$$s." - ELSE "." - END IF. - END IF. - END VERB. - - - VERB close - DOES ONLY "It wouldn't serve any purpose to close the door." - END VERB. - -END EVERY. - - - --- ============================================================= - - ------ LIGHTSOURCE - - --- ============================================================= - - --- (In the file 'verbs.i', ISA LIGHTSOURCE is used in the syntax definition of the verb 'light'.) - - -EVERY lightsource ISA OBJECT - IS NOT lit. - IS NOT broken. - IS natural. -- A natural lightsource is for example a candle, a match or a torch. - -- A NOT natural lightsource is for example a flashlight or a lamp. - -- You cannot switch on or off a natural lightsource. - - - - VERB examine - DOES - IF THIS IS lit - THEN - IF THIS IS natural - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently lit." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently on." - END IF. - ELSE - IF THIS IS natural - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently not lit." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "currently off." - END IF. - END IF. - END VERB. - - - VERB light - CHECK THIS IS NOT lit - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already providing light." - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - IF THIS IS natural - THEN "You light" SAY THE THIS. "." - MAKE THIS lit. - ELSE "You turn on" SAY THE THIS. "." - MAKE THIS lit. - END IF. - END VERB. - - - VERB extinguish - CHECK THIS IS lit - ELSE "But" SAY THE THIS. - IF THIS IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - "providing light!" - DOES ONLY "You extinguish the" SAY THE THIS. "." - MAKE THIS NOT lit. - END VERB. - - - VERB turn_on - CHECK THIS IS NOT natural - ELSE - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "not something you can $v on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND THIS IS NOT lit - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already providing light." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND THIS IS NOT broken - ELSE "Nothing happens." - DOES ONLY - "You turn on" SAY THE THIS. "." - MAKE THIS lit. - - END VERB. - - - VERB turn_off - CHECK THIS IS NOT natural - ELSE - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v off." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND THIS IS lit - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already off." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES ONLY - "You turn off" SAY THE THIS. "." - MAKE THIS NOT lit. - - END VERB. - - --- The following verb switches a NOT natural lightsource on if it is off, and vice versa --- (when the player forgets, or doesn't bother, to type 'on' or 'off' after 'switch'). - - - VERB switch - CHECK THIS IS NOT natural - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - "something you can switch on or off." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND THIS IS reachable - ELSE SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - AND THIS IS NOT broken - ELSE "Nothing happens." - AND CURRENT LOCATION IS lit - ELSE - "You switch" SAY THE THIS. "on." - MAKE THIS lit. - DOES ONLY - IF THIS IS lit - THEN "You switch off" SAY THE THIS. "." - MAKE THIS NOT lit. - ELSE "You switch on" SAY THE THIS. "." - MAKE THIS lit. - END IF. - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ LIQUID - - --- ============================================================== - - --- (In the file 'verbs.i', ISA LIQUID is used in the syntax definitions of the verbs 'drink' and 'sip'.) - - -EVERY liquid ISA OBJECT - - CONTAINER - HEADER "In" SAY THE THIS. "you see" - ELSE "There is nothing in" SAY THE THIS. "." - - -- We declare this class a container to enable player commands such as - -- 'throw sack into water', 'look into water' and 'take pearl from water'. - -- Also cases such as 'pour red potion into blue potion' require that this - -- class behaves like a container. - - - HAS vessel no_vessel. -- The 'vessel' attribute takes care that if a liquid is - -- in a container, the verb 'take' will automatically take the - -- container instead (if the container is takeable). Trying to - -- take a liquid that is in a fixed-in-place container, as well - -- as trying to take a liquid outside any container, will yield - -- "You can't carry [the liquid] around in your bare hands." - -- The default value 'no_vessel' tells the compiler that the liquid - -- is not in any container. - - - - -- If you have some liquid in a container in your game, you should declare the - -- liquid instance thus: - - -- THE juice ISA LIQUID - -- IN bottle - -- HAS vessel bottle. -- i.e. the value of the 'vessel' attribute is the - -- ... -- container the liquid is in - -- END THE juice. - - -- Then, taking and pouring liquids work smoothly. - -- If you don't declare the 'vessel' attribute for the liquid instance, taking a liquid will - -- yield "You can't carry [the liquid] around in your bare hands."; only taking its - -- container will work in that case. - - -- The verb 'pour', as defined in this library, also works for the container of a liquid; - -- i.e. if there is some juice in a bottle, 'pour bottle' and 'pour juice' work equally well. - -- Note, however, that the verb 'empty' is not a synonym for 'pour'; - -- 'empty' only works for container objects. - - - INITIALIZE - SCHEDULE check_vessel AT THIS AFTER 0. -- this event is defined further below - - - VERB examine - DOES ONLY - IF vessel OF THIS <> no_vessel - THEN - IF vessel OF THIS IS NOT closed - THEN "You see nothing special in" SAY THE THIS. - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - -- Here we prohibit the player from examining - -- a liquid when the liquid is in a closed container. - END IF. - ELSE "You see nothing special in" SAY THE THIS. - END IF. - END VERB. - - - VERB look_in - DOES ONLY - IF vessel OF THIS <> no_vessel - THEN - IF vessel OF THIS IS NOT closed - THEN "You see nothing special in" SAY THE THIS. "." - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - -- Here we prohibit the player from looking into - -- a liquid when the liquid is in a closed container. - END IF. - ELSE "You see nothing special in" SAY THE THIS. - END IF. - END VERB. - - - VERB take - DOES ONLY - IF vessel OF THIS = no_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$nTaken." - END IF. - END VERB. - - - VERB take_from - WHEN obj - DOES ONLY - IF vessel OF THIS = no_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "($$" SAY THE vessel OF THIS. "$$)$nTaken." - END IF. - END VERB. - - - VERB drop - DOES ONLY - "($$" SAY THE vessel OF THIS. "$$)$nDropped." - LOCATE vessel OF THIS AT hero. - END VERB. - - - VERB give - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero -- i.e. if the implicit taking was successful - THEN - "You give" SAY THE vessel OF THIS. "to" SAY THE recip. "." - LOCATE vessel OF THIS IN recip. - END IF. - - -- there is no 'ELSE' statement in this last IF -clause, as the 'IF THIS NOT - -- IN hero' clause above it takes care of the 'ELSE' alternative. - - END VERB. - - - VERB pour - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel OR vessel OF THIS IS NOT takeable - THEN "You can't pour" SAY THE THIS. "anywhere since you are not - carrying" - IF THIS IS NOT plural - THEN "it." - ELSE "them." - END IF. - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero - THEN - "You pour" SAY THE THIS. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - LOCATE THIS AT hero. - SET vessel OF THIS TO no_vessel. - END IF. - - END VERB. - - - VERB pour_in - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero --i.e. if the implicit taking was successful - THEN - "You pour" SAY THE THIS. "into" SAY THE cont. "." - LOCATE THIS IN cont. - SET vessel OF THIS TO cont. - END IF. - WHEN cont - DOES ONLY - IF vessel OF THIS = no_vessel - THEN - "There's not much sense pouring" SAY THE obj. "into" SAY THE THIS. "." - ELSE - IF vessel OF THIS IS NOT closed - THEN "It wouldn't accomplish anything trying to pour" SAY THE obj. - "into" SAY THE THIS. "." - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - END IF. - END IF. - END VERB. - - - VERB pour_on - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero -- i.e. if the implicit taking was successful - THEN - IF surface = floor OR surface = ground - THEN LOCATE THIS AT hero. - "You pour" SAY THE THIS. "on" SAY THE surface. "." - SET vessel OF THIS TO no_vessel. - ELSIF surface ISA SUPPORTER - THEN LOCATE THIS IN surface. - "You pour" SAY THE THIS. "on" SAY THE surface. "." - SET vessel OF THIS TO no_vessel. - ELSE "It wouldn't be sensible to pour anything on" SAY THE surface. - END IF. - END IF. - END VERB. - - - VERB fill_with - WHEN substance -- i.e. when something is filled with a liquid, - DOES SET vessel OF THIS TO cont. -- this something becomes the vessel of the liquid. - END VERB. - - - VERB put_in - WHEN obj - DOES ONLY - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE - IF vessel OF THIS IS takeable - THEN - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - LOCATE vessel OF THIS IN cont. - "You put" SAY THE vessel OF THIS. "into" SAY THE cont. "." - - ELSE "You don't have" SAY THE vessel OF THIS. "." - END IF. - END IF. - WHEN cont - DOES ONLY - IF vessel OF THIS = no_vessel - THEN - "There's not much sense putting" SAY THE obj. "into" SAY THE THIS. "." - ELSE - IF vessel OF THIS IS NOT closed - THEN - IF obj = vessel OF THIS - THEN "That doesn't make sense." - ELSE "It wouldn't accomplish anything trying to put" SAY THE obj. - "into" SAY THE vessel OF THIS. "." - END IF. - ELSE "You can't, since" SAY THE vessel OF THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - END IF. - END IF. - END VERB. - - - VERB put_on - WHEN obj - DOES ONLY - -- implicit taking: - IF THIS NOT IN hero - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSIF vessel OF THIS IS NOT takeable - THEN "You don't have" SAY THE vessel OF THIS. "." - ELSE LOCATE vessel OF THIS IN hero. - "(taking" SAY THE vessel OF THIS. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF THIS IN hero -- i.e. if the implicit taking was successful - THEN - IF vessel OF THIS = no_vessel - THEN "You can't carry" SAY THE THIS. "around in your bare hands." - ELSE - IF vessel OF THIS IS takeable - THEN "You put" SAY THE vessel OF THIS. "onto" SAY THE surface. "." - LOCATE vessel OF THIS IN surface. - ELSE "You can't carry" SAY THE THIS. "around in your bare hands." - END IF. - END IF. - END IF. - WHEN surface - DOES ONLY "It is not possible to $v" SAY obj. "onto" SAY THE THIS. "." - END VERB. - - - -- throwing liquids, whether in containers or not, is disabled: - - - VERB throw - DOES ONLY - "Throwing" SAY THE THIS. "around wouldn't be sensible." - END VERB. - - - VERB throw_at - WHEN projectile - DOES ONLY - "Throwing" - IF vessel OF THIS = no_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "around wouldn't be sensible." - WHEN target - DOES ONLY - IF projectile = vessel OF THIS - THEN "That doesn't make sense." - ELSE "It wouldn't accomplish anything trying to throw" SAY THE projectile. "at" - IF vessel OF THIS = no_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "." - END IF. - END VERB. - - - - VERB throw_to - WHEN projectile - DOES ONLY - "Throwing" - IF vessel OF THIS = no_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "to" SAY THE recipient. "wouldn't be sensible." - WHEN recipient - DOES ONLY - IF projectile = vessel OF THIS - THEN "That doesn't make sense." - ELSE - "Throwing something to" - IF vessel OF THIS = no_vessel - THEN SAY THE THIS. - ELSE SAY THE vessel OF THIS. - END IF. - "wouldn't accomplish anything." - END IF. - END VERB. - - - VERB throw_in - WHEN projectile - DOES ONLY - "It wouldn't be sensible throwing" SAY THE THIS. "into" SAY THE cont. "." - WHEN cont - DOES ONLY - IF projectile = vessel OF THIS - THEN "That doesn't make sense." - ELSE "It wouldn't be sensible trying to throw" SAY THE projectile. "in" SAY THE THIS. "." - END IF. - END VERB. - - - - -- The verbs 'empty', 'empty_in' and 'empty on' will be disabled as ungrammatical with liquids: - - VERB 'empty' - DOES ONLY "You can only empty containers." - END VERB. - - VERB empty_in - WHEN obj - DOES ONLY "You can only empty containers." - END VERB. - - VERB empty_on - WHEN obj - DOES ONLY "You can only empty containers." - END VERB. - - -END EVERY. - - - --- Here is the default vessel for liquids; if the vessel of a liquid is --- 'no_vessel', it means that the liquid is not in any container. - - -THE no_vessel ISA OBJECT - CONTAINER -END THE. - - - --- This event checks that if a liquid is outside a container, its container will --- be 'no_vessel' (= the dummy default container to be ignored): - - -EVENT check_vessel - FOR EACH liq ISA LIQUID, DIRECTLY AT CURRENT LOCATION DO - SET vessel OF liq TO no_vessel. - END FOR. - SCHEDULE check_vessel AFTER 1. -END EVENT. - - - - --- ============================================================= - - ------ LISTABLE_CONTAINER - - --- ============================================================= - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - -EVERY LISTABLE_CONTAINER ISA OBJECT -- ACTORS are separately defined as - CONTAINER -- containers further below - - - VERB examine - DOES - IF THIS IS closeable - THEN - IF THIS IS closed - THEN - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "closed." - ELSE - IF THIS IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "open." - END IF. - END IF. - - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't see inside" SAY THE THIS. "." - END IF. - END VERB. - - - VERB look_in - DOES ONLY - IF THIS IS NOT OPAQUE - THEN LIST THIS. - ELSE "You can't, since" SAY THE THIS. - IF THIS IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - END IF. - END VERB. - - - VERB open - DOES - MAKE THIS NOT OPAQUE. - LIST THIS. - END VERB. - - - VERB close - DOES - MAKE THIS OPAQUE. - END VERB. - - -END EVERY. - - - - - - --- Tips for using container objects: - - --- 1) - - --- The contents of a normal CONTAINER are not listed when examined --- (you'll need to look *into* the object to see what it contains). --- If you wish to have the contents listed after 'examine' anyway, --- you should --- --- instead of: --- --- THE box ISA OBJECT --- CONTAINER --- ... --- END THE. --- --- do this: --- --- THE box ISA LISTABLE_CONTAINER --- ... --- END THE. --- --- Then, 'examine' lists the contents of the container. --- --- The contents of a listable_container are also listed when the container --- is opened. This doesn't happen with normal containers. - - --- 2) - - --- For the command 'inventory' to list the contents of a container --- the hero is carrying, go to 'verbs.i', find the command 'inventory' --- and list one by one all relevant containers that the hero might carry, --- thus: --- --- VERB inventory --- DOES LIST hero. --- ... --- IF bag IN hero --- THEN LIST bag. --- END IF. --- --- IF box IN hero --- THEN LIST box. --- END IF. --- ... --- END VERB. --- --- --- If you leave out these additions, the bag and the box will be listed after the --- command 'inventory' in the following way: --- --- "You are carrying a bag and a box." --- --- only. But with the above additions, the outcome is e.g. --- --- "You are carrying a bag and a box. The bag contains a loaf of bread. The box --- is empty." - - --- 3) - - --- To declare a container the contents of which should not be listed after 'look' --- or 'examine', declare it an 'opaque container' in the following way: - - --- THE box ISA OBJECT --- OPAQUE CONTAINER --- ... --- END THE. - - --- or - - --- THE box ISA LISTABLE_CONTAINER --- OPAQUE CONTAINER --- ... --- END THE. - - --- Objects in an opaque container cannot be seen or manipulated. --- To change this, declare e.g. --- --- MAKE box NOT OPAQUE. --- - - - --- ============================================================== - - ------ SCENERY - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'take' and 'take_from' where ISA SCENERY --- is used in verb checks.) - - -EVERY scenery ISA OBJECT - IS NOT takeable. - DESCRIPTION "" - - - VERB examine - DOES ONLY SAY THE THIS. - IF THIS IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "appear particularly interesting to you." - END VERB. - - -END EVERY. - - - --- =============================================================== - - ------ SOUND - - --- =============================================================== - - --- (This class is not cross-referenced in this or any other library file.) - - -EVERY sound ISA OBJECT - IS NOT examinable. - IS NOT reachable. - IS NOT movable. - - - VERB smell - DOES ONLY - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can smell." - END VERB. - - -END EVERY. - - - --- ============================================================== - - ------ SUPPORTER - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'climb_on', 'empty_on', 'get_off', 'jump_on', --- 'lie_on', 'pour_on', 'put_in', 'put_on', 'sit_on', 'stand_on', and 'take_from' --- where SUPPORTER is used in either syntax definitions, verb checks --- or verb definitions.) - - -EVERY supporter ISA OBJECT - CONTAINER - HEADER "On" SAY THE THIS. "you see" - ELSE "There's nothing on" SAY THE THIS. "." - - - VERB examine - DOES - LIST THIS. - END VERB. - - - -- in the following, we disable some verbs that are defined to work with normal containers: - - - VERB look_in - DOES ONLY - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look into." - END VERB. - - - VERB empty_in, pour_in - WHEN cont - DOES ONLY - IF THIS IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour things into." - END VERB. - - - VERB put_in - WHEN cont - DOES ONLY "You can't put anything inside" SAY THE THIS. "." - END VERB. - - - VERB throw_in - WHEN cont - DOES ONLY "You can't put anything inside" SAY THE THIS. "." - END VERB. - - -END EVERY. - - - --- To place objects on a supporter, define them in the following way: --- --- Define the supporter first; e.g. --- --- THE tray ISA SUPPORTER --- ... --- END THE. --- --- --- Then, the objects on the supporter: --- --- --- THE apple ISA OBJECT --- IN tray -- note the IN here, even if the apple will be described as --- ... -- being on the tray --- END THE. --- --- --- THE book ISA OBJECT --- IN table --- ... --- END THE. --- --- --- Note that the 'examine' command will list what is on the surface of a supporter, not what, --- if anything, is inside the supporter. For example, if you have a supporter called 'table' in your game --- with two drawers in it, --- --- DON'T do this: --- --- THE drawer1 ISA OBJECT --- NAME bottom drawer --- CONTAINER --- IN table. --- END THE. --- --- or this: --- --- THE drawer2 ISA LISTABLE_CONTAINER --- NAME top drawer --- IN table. --- END THE. --- --- This would result in something like --- --- "There's a table here. On the table you see a book, a bottom drawer and a top drawer." --- --- --- Instead, do the following: --- --- THE table ISA SUPPORTER --- AT bedroom --- HAS components {drawer1, drawer2}. --- ... --- VERB examine --- DOES --- FOR EACH c IN components OF THIS DO --- SAY "The table has" SAY AN c. "." --- IF c IS NOT closed --- THEN LIST c. --- ELSE SAY THE c. "is closed." --- END IF. --- END FOR. --- END VERB. --- ... --- END THE. --- --- THE drawer1 ISA LISTABLE_CONTAINER --- OPAQUE CONTAINER --- NAME bottom drawer --- AT bedroom --- IS closed. --- END THE. --- --- THE drawer2 ISA LISTABLE_CONTAINER --- NAME top drawer --- AT bedroom --- IS NOT closed. --- END THE. - - - --- In other words, declare the drawers components of the table, in the manner described above. --- The result will then be e.g. something like this: --- --- "You see a table here. There is a book on the table. The table has a bottom drawer. The bottom drawer --- is closed. The table has a top drawer. The top drawer contains a diary." - - - - --- ============================================================== - - ------ WEAPON - - --- ============================================================== - - --- (See the file 'verbs.i', verbs 'attack_with', 'fire', --- 'fire_with', 'kill_with', 'shoot' and 'shoot_with' where WEAPON is used --- either in the syntax definitions or verb checks.) - - -EVERY weapon ISA OBJECT - IS NOT fireable. -END EVERY. - - - - --- ============================================================== - - ------ WINDOW - - --- ============================================================== - - --- (This class is not cross-referenced elsewhere in this or any other library file.) - - --- You can look out of and through a window. --- When examined, a window is automatically described as being either open or closed. - - -EVERY window ISA OBJECT - IS closeable. - IS closed. - IS NOT takeable. - - - VERB examine - DOES ONLY - "The window is boarded" - IF house IS 'entered' - THEN "and only lets a little light into the room" - END IF. - "." - IF hero AT lr - THEN - IF kitchen_window IS closed - THEN - "$p$p(The Kitchen)$nThe window is boarded and only lets a little light into the room." - ELSE - "It is currently open." - END IF. - END IF. - END VERB. - - - VERB look_behind - DOES ONLY - "That's not possible." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - - - VERB look_out_of - DOES ONLY "You can't look out of the boarded window." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou can't look out of the boarded window." END IF. - END VERB. - - - VERB look_through - DOES ONLY "You can't see through the boarded window." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou can't see through the boarded window." END IF. - END VERB. - - VERB open - DOES ONLY "You can't open the boarded window." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou can't open the boarded window." END IF. - END VERB. - -END EVERY. - - - --- =============================================================== - --- =============================================================== --- --- 2. Actors --- --- =============================================================== - --- =============================================================== - - --- First, we declare some common characteristics for all actors: - - -ADD TO EVERY ACTOR - IS NOT inanimate. - IS NOT following. - IS NOT sitting. - IS NOT lying_down. - IS NOT named. -- = the actor's name is not known to the player; see also - -- the example below - - -- Important: if you don't need an article in front of an actor name (e.g. 'Jim', as opposed to - -- e.g. 'a/the man'), declare the instance as 'named': - - -- THE jim ISA ACTOR - -- IS named. - -- ... - -- END THE. - - -- (Remember also that all actors are 'CAN NOT talk' by default. If you want the actor to be able to talk, - -- give it the attribute 'CAN talk' or declare it ISA PERSON (see further below)) - - DEFINITE ARTICLE - IF THIS IS NOT named - THEN "the" - ELSE "" - END IF. - - INDEFINITE ARTICLE - IF THIS IS NOT named - THEN - IF THIS IS NOT plural - THEN "a" -- if you need "an", you must declare it separately at the actor instance - ELSE "" - END IF. - ELSE "" - END IF. - - - CONTAINER -- so that actors can receive and carry objects - - INITIALIZE -- all actors will obey this script from the start of the game - USE SCRIPT following_hero FOR THIS. - - SCRIPT following_hero -- this code will make any actor follow the hero - STEP WAIT UNTIL hero NOT HERE -- if the actor is given the attribute 'following'. - IF THIS IS following - THEN - LOCATE THIS AT hero. - "$p" SAY THE THIS. - IF THIS IS NOT plural - THEN "follows you." - ELSE "follow you." - END IF. - END IF. - USE SCRIPT following_hero FOR THIS. - - - - DESCRIPTION - IF THIS IS NOT named - THEN - IF THIS IS NOT plural - THEN "There is" SAY AN THIS. "here." - ELSE "There are" SAY THIS. "here." - END IF. - ELSE SAY THIS. - IF THIS IS NOT plural - THEN "is here." - ELSE "are here." - END IF. - END IF. - - - - VERB examine - DOES - IF COUNT ISA THING, IN THIS > 0 -- This if-statement will make a description of an - THEN LIST THIS. -- actor's possessions show up every time the actor is examined. - END IF. -- Note that this doesn't apply to the hero which is defined - -- separately further below.-- This listing will be overridden if you give an - -- individual response - END VERB. -- to the actor instance being examined using DOES ONLY. If you want to still - -- list the possessions of the actor after your own 'examine' - -- response, you should state 'LIST [actor].' in the 'examine' verb there. - - -END ADD TO. - - --- In order that clothing worn by an NPC is described after 'look' and --- 'examine' we need the following code. See the instructions right after it. - - - -EVERY npc_worn ISA OBJECT - HAS carrier no_carrier. -- The value of the 'carrier' attribute is the actor wearing the clothing. - -- Here, 'no_carrier' is a dummy default instance that can be ignored. - - CONTAINER TAKING CLOTHING. - HEADER SAY THE carrier OF THIS. "is wearing" - ELSE "" - - DESCRIPTION "" -- we don't want this container to appear in room descriptions - - INITIALIZE - LOCATE THIS AT carrier OF THIS. - SCHEDULE check_npc_worn AT THIS AFTER 0. - -END EVERY. - - - -EVENT check_npc_worn - FOR EACH nw ISA npc_worn DO - IF nw NOT AT carrier OF nw - THEN LOCATE nw AT carrier OF nw. - END IF. - END FOR. - SCHEDULE check_npc_worn AFTER 1. -END EVENT. - - -THE no_carrier ISA ACTOR -- a dummy default instance, ignore. -END THE. - - - --- To describe what an NPC is wearing (after the commands 'look and 'examine'), define the NPC e.g. like this: - - --- THE mr_smith ISA ACTOR --- DESCRIPTION --- "blah blah" LIST mr_smith_worn. -- Leave this LIST statement out if you don't want to --- -- have the actor's clothing listed after 'look'. --- VERB examine --- DOES ONLY "blah blah" --- (LIST mr_smith.) -- This lists what Mr Smith is carrying. --- LIST mr_smith_worn. -- this lists what Mr Smith is wearing. --- END VERB. --- --- END THE. - - --- THE mr_smith_worn ISA NPC_WORN -- All containers for clothing worn by NPCs should be declared ISA NPC_WORN. --- HAS carrier mr_smith. -- The value of the 'carrier' attribute is the actor wearing the clothes. --- END THE. - - --- THE bowler_hat ISA CLOTHING IN mr_smith_worn --- IS headcover 2. --- END THE. - - --- Note that if you don't want the player character to be able to take a piece of clothing worn --- by another character, you should declare the piece of clothing NOT takeable! - - ------------------------------------------- - - --- To make an actor follow the hero, give it the 'following' attribute, e.g.: --- --- THE bob ISA ACTOR --- ... --- VERB whatever --- DOES MAKE bob following. --- END VERB. --- .... --- --- END THE bob. --- --- etc. - - --- If you wish to have an actor follow the hero right from the start of the game, --- you can naturally just declare --- --- THE servant ISA ACTOR --- IS following. --- ... --- END THE. --- --- - --- To stop an actor from following the hero, just make the actor NOT following. - - --------------------------------------------- - - --- Tip: if you have in your game an actor that starts off as unnamed (such as 'a man'), --- and the player learns his name later on (say, 'Jim'), you should define the actor in --- e.g. the following way to make the player able to refer to him with --- both 'man' and 'Jim': - --- THE jim ISA PERSON --- NAME man NAME jim --- PRONOUN him --- MENTIONED --- IF jim IS NOT named -- By default, all actors are 'NOT named'. --- THEN "man" --- ELSE "Jim" --- END IF. --- .. --- VERB ask --- WHEN act --- IF topic = name --- THEN """My name is Jim"", he replies." --- MAKE jim named. --- END IF. --- END VERB. --- --- END THE. - --- The 'named' attribute is meant to be used in cases like this. The indefinite and definite --- articles don't have to be declared here, as their behavior has been declared in the --- general actor class above. - - - --- ================================================================ - - ------ PERSON -- CAN talk - - --- ================================================================ - - -EVERY person ISA ACTOR - CAN talk. -END EVERY. - - - --- ================================================================ - - ------ FEMALE and MALE - - --- ================================================================ - - --- MALE and FEMALE are actually subclasses of PERSON, and so they both --- have the ability to talk. - - -EVERY female ISA PERSON - PRONOUN her -END EVERY. - - -EVERY male ISA PERSON - PRONOUN him -END EVERY. - - - --- ================================================================ - --- ================================================================ - --- 3. The hero - --- ================================================================ - --- ================================================================ - - - -THE hero ISA ACTOR - DEFINITE ARTICLE "" - INDEFINITE ARTICLE "" - MENTIONED "yourself" - PRONOUN '' -- to disable 'it' from referring to 'me'. - CAN talk. - IS NOT sitting. - IS NOT lying_down. - HAS i_value 0. -- for inventory message - - ------------------------------------ - - -- These three attributes, as well as the 'schedule' statement following them, - -- are needed for the 'notify' command ('verbs.i'); ignore. - - HAS oldscore 0. -- Records previous score so 'checkscore' event - -- can compare with the current score - IS notify_on. -- Set by 'notify' verb, records whether - -- player wants to see score messages or not. - IS NOT seen_notify. -- Records whether player has seen the notify verb - -- instructions yet. - - INITIALIZE - SCHEDULE check_score AT hero AFTER 0. - - ------------------------------------ - - CONTAINER - - LIMITS -- Remove this whole section (from this line until 'HEADER') if you - -- wish to have no limits to how much the hero can carry. - COUNT 10 Then - "You can't carry anything more. You have to drop something - first." - WEIGHT 50 Then - "You can't carry anything more. You have to drop something - first." - - HEADER - IF CURRENT LOCATION IS NOT lit - THEN "Although you cannot see your belongings in the dark, you - remember that you're carrying" - ELSE "You are carrying" - END IF. - ELSE - IF CURRENT LOCATION ISA SITE - THEN "You are carrying nothing." - IF i_value OF hero = 0 - THEN - "That's how you like to start." - INCREASE i_value OF hero. - END IF. - ELSE "You are empty-handed." - END IF. - - - VERB examine - DOES ONLY "You're Ted Paladin, text adventure hero. - You like to think there is no house implemented you can't get in or out of, - and so far that has held true. You have your reputation to defend, so you'll have to - take care not to spoil things this time either." - IF hero AT lr - THEN - "$p$p(The Kitchen)$n" - "You're Ted Paladin, text adventure hero. - You like to think there is no house implemented you can't get in or out of, - and so far that has held true. You have your reputation to defend, so you'll have to - take care not to spoil things this time either." - END IF. - - - IF COUNT ISA CLOTHING, IN worn > 0 - THEN LIST worn. -- This will list what the hero is wearing. - END IF. -- (The verb 'inventory' in 'verbs.i' will take care - END VERB. -- of listing the hero's possessions.) - - -END THE. - - -SYNONYMS - me, myself, yourself, self, ted, paladin = hero. - - --- Please refer also 'verbs.i' where there are numerous verb checks for the hero, --- so that the hero cannot e.g. attack himself etc. diff --git a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/locations.i b/app/src/main/jni/terps/alan/alan3/bugs/abandoned/locations.i deleted file mode 100755 index 02ca8c4..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/locations.i +++ /dev/null @@ -1,647 +0,0 @@ --- ALAN Standard Library v1.00 --- Locations (file name: 'locations.i') - - --- This library file defines the default directions (exits) and the location 'nowhere', --- a useful place to locate things when you want to remove them from play. --- This file also defines three specific location classes: rooms (= indoor locations), --- sites (= outdoor locations) as well as the class 'dark_location'. --- Finally, the attributes 'visited' and 'described' as well as the instance 'room' --- (to make possible player commands such as 'examine room' and 'exit room') are defined. --- You may modify this file in any way that suits your purposes. --- To use this file, you should have it in the same folder as your source code file, --- and the line --- --- IMPORT 'locations.i'. --- --- in your source code. - - - --- ======================================================== - - ------ 1. The location 'nowhere' and the default directions - - --- ======================================================== - - -THE nowhere ISA LOCATION - - EXIT - north, - south, - east, - west, - northeast, - southeast, - northwest, - southwest, - up, - down, - 'in', - out - - TO nowhere. - - -END THE nowhere. - - -SYNONYMS - n = north. - s = south. - e = east. - w = west. - ne = northeast. - se = southeast. - nw = northwest. - sw = southwest. - u = up. - d = down. - - --- Note: - - --- 1) the directions defined above (and their synonyms) are not predefined in or --- hardwired to the interpreter in any way, so you can replace them altogether or add new --- ones to be used alongside with them. - - --- 2) when you want to remove things from play, you can --- --- LOCATE [object] AT nowhere. --- --- e.g. --- --- THE piece_of_paper ISA OBJECT --- ... --- VERB tear --- DOES ONLY "You tear the piece of paper to shreds." --- LOCATE piece_of_paper AT nowhere. --- END VERB. --- --- END THE piece_of_paper. - --- "The evil Professor Murray bursts out laughing." - - --- ========================================================================= - - ------ 2. Location classes 'room' and 'site' for indoor and outdoor locations - - --- ========================================================================= - - --- ROOM and SITE are optional location classes you can use to ease up coding. --- All ROOMS have a floor, walls and a ceiling. All SITES have a ground and a sky. --- Thus, you will be able to define e.g. --- --- THE kitchen ISA ROOM --- --- and it will automatically have a floor, walls and a ceiling, --- --- or: --- --- THE greenmeadow ISA SITE --- --- and the ground and the sky are automatically found in that location. --- --- --- Of course, you will still be able to define locations in the usual way, e.g. --- --- THE kitchen ISA LOCATION --- --- etc, but the floor, walls and ceiling won't be automatically included there. --- The walls, floor, ceiling, ground and sky are not takeable or movable. --- This library file also defines the sky and the ceiling to be out of reach, --- so that they can't be e.g. touched. - --- (We make use of ALAN's nested locations feature in the following definitions: ) - - -THE outdoor ISA LOCATION -END THE outdoor. - - -THE indoor ISA LOCATION -END THE indoor. - - -EVERY room ISA LOCATION AT indoor -END EVERY. - - -EVERY site ISA LOCATION AT outdoor -END EVERY. - - -EVERY room_object ISA OBJECT AT indoor -END EVERY. - - -EVERY site_object ISA OBJECT AT outdoor -END EVERY. - - -THE floor ISA room_object - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow 'empty/pour something on floor' - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the floor." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou notice nothing unusual about the floor." END IF. - END VERB. - - - -- As we have declared the floor a container, we will disable some verbs - -- defined to work with containers: - - - VERB empty_in, pour_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - - - VERB look_in - DOES ONLY "That's not possible." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - - - VERB put_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - - - VERB take_from - WHEN holder - DOES ONLY "If you want to pick up something, just TAKE it." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - - - VERB throw_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - - VERB touch - DOES ONLY "You feel nothing unexpected." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou feel nothing unexpected." END IF. - END VERB. - - - - -END THE. - - -THE wall ISA room_object - NAME wall NAME walls - IS NOT takeable. - IS NOT movable. - DESCRIPTION "" - - - VERB examine - DOES ONLY "You notice nothing unusual about the walls here." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou notice nothing unusual about the walls here." END IF. - END VERB. - - - VERB touch - DOES ONLY "You feel nothing unexpected." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou feel nothing unexpected." END IF. - END VERB. - -END THE. - - - -THE ceiling ISA room_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine DOES ONLY - "You notice nothing unusual about the ceiling." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou notice nothing unusual about the ceiling." END IF. - END VERB. - -END THE. - - - -THE ground ISA site_object - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow 'empty/pour something on ground' - DESCRIPTION "" - - - VERB examine - DOES ONLY "You notice nothing unusual about the ground." - END VERB. - - - VERB dig - DOES ONLY "The ground is not suitable for digging here." - END VERB. - - - -- As we have declared the floor to be a container, we will disable some verbs - -- defined to work with containers: - - - VERB empty_in, pour_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB look_in - DOES ONLY "That's not possible." - END VERB. - - - VERB put_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - - VERB take_from - WHEN holder - DOES ONLY "If you want to pick up something, just TAKE it." - END VERB. - - - VERB throw_in - WHEN cont - DOES ONLY "That's not something you can $v things into." - END VERB. - - -END THE. - - - -THE sky ISA site_object - IS NOT reachable. - DESCRIPTION "" - - - VERB examine - DOES ONLY "You notice nothing unusual about the sky." - END VERB. - - -END THE. - - --- We still declare some shared behaviour for all indoor and outdoor objects: - - -ADD TO EVERY room_object - - VERB put_behind, put_near, put_under - WHEN bulk - DOES ONLY "That's not possible." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - - VERB look_behind, look_through, look_under - DOES ONLY "That's not possible." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - -END ADD TO. - - -ADD TO EVERY site_object - - VERB put_behind, put_near, put_under - WHEN bulk - DOES ONLY "That's not possible." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - - VERB look_behind, look_through, look_under - DOES ONLY "That's not possible." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. - -END ADD TO. - - --- NOTE: it is often a good idea to modify the 'examine' verb for the above objects. --- Here is an example for 'wall': - --- THE wall ISA room_object --- : --- : --- VERB examine DOES ONLY --- IF hero AT kitchen --- THEN "Numerous shelves, full of various kitchen utensils, line the walls." --- ELSIF hero AT livingroom --- THEN "The walls are decorated with flowery wallpaper here." --- : - --- : --- END IF. --- END VERB. --- END THE wall. --- --- In other words, making the description of the walls, etc., individual for each room --- gives a better impression than if you just use the default messages. - - - --- ========================================================== - - ------ 3. Dark locations - - --- ========================================================== - - -ADD TO EVERY LOCATION - IS lit. -END ADD TO. - - -EVERY dark_location ISA LOCATION - IS NOT lit. - - ENTERED - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - THEN MAKE THIS lit. - END IF. - - IF COUNT ISA LIGHTSOURCE, IS lit, HERE = 0 - THEN MAKE THIS NOT lit. - END IF. - - -- These ENTERED statements take care - -- of the dark location being correctly lit or not lit at entrance, - -- the WHEN rules below take care of the change when the hero is - -- already in the location. - - DESCRIPTION - CHECK COUNT ISA LIGHTSOURCE, IS lit, HERE > 0 - ELSE "It is pitch black. You can't see anything at all." - -END EVERY dark_location. - - - - --- To define a dark location, use a formulation like the following: - - --- THE basement ISA dark_location --- EXIT up TO kitchen. --- ... --- END THE. - - --- The description of a dark_location will automatically be: "It is pitch black. --- You can't see anything at all." (Edit the description in the code above to change this.) - - --- If you add a description to a dark_location, this description will be shown only --- if/when the location is lit by any means: - --- THE basement ISA dark_location --- DESCRIPTION "Cobwebs and old junk are the only things you see here." --- EXIT up TO kitchen. --- END THE. - - --- In darkness, you are not able to manipulate things other than turn on a lightsource --- and drop items you're carrying (these checks are found in 'verbs.i'). You can exit normally --- and use verbs that don't require seeing, such as 'smell', 'listen' and 'think'. --- If you are in a dark location with an NPC (= a non-player character), you are able to --- communicate with him by asking and telling but not by showing and giving. If you wish to --- change this, see the respective verbs in 'verbs.i' and edit their checks. - - --- Note that you cannot change the name of a location mid-game. Thus, if you define a dark location --- called e.g. 'Darkness' and wish to make it lit at some point in the game, the name will still be 'Darkness' --- even if the location description can be changed to describe the illuminated location. --- To change the location name, you must locate the hero in another location when the dark location --- is lit. For example, --- --- --- THE lantern ISA LIGHTSOURCE -- (see 'classes.i') --- VERB turn_on --- DOES --- IF hero AT darkness --- THEN LOCATE hero AT treasure_chamber. --- ... --- END IF. --- ... --- END VERB. --- --- etc. --- --- --- Alternatively, you can also use a rule, e.g. --- --- --- WHEN lantern IS lit --- AND hero AT darkness --- THEN LOCATE hero AT treasure_chamber. - - - --- Suppose you want all dark_locations in the game to become lighted. It can be done e.g. like this: - - --- THE main_power_switch ISA DEVICE --- VERB switch_on --- DOES ONLY --- FOR EACH d1 ISA dark_location DO --- MAKE d1 lit. --- END EACH. --- END VERB. --- END THE. - --- FOR EACH makes a loop that affects all instances of the class described after the ISA statement. --- The 'd1' above is a temporary variable needed in the FOR EACH phrase and not anywhere --- else in the game code. You can name this variable in any way you wish. - - - --- ===================================================================== - - ------ 4. The attributes 'visited' and 'described' - - --- ===================================================================== - - --- A location has the value 'visited 0' until the hero visits it for the first time, and the --- value increases on every subsequent visit. --- This helps when you need to control if or how many times a location has been visited, --- and also if you want the location description to be different after the first visit. - --- A location has the value 'described 0' before the first location description, --- and the value increases every time the description is shown. --- This distinction is handy when you want the first-time description of a location to be different from --- the subsequent ones (even if the hero is in the location still for the first time). - - -ADD TO EVERY LOCATION - HAS visited 0. - HAS described 0. - - ENTERED - IF CURRENT ACTOR = hero - THEN - INCREASE visited OF THIS. - INCREASE described OF THIS. -- this value also increases after 'look' (see 'verbs.i'.). - END IF. - -END ADD TO. - - --- A location not visited at all has the 'visited' value 0. When the hero enters it --- the first time, the 'visited' value will change to 1. On the second visit the value --- will be 2, etc. --- Now, in your source code you can define something like the following: - - --- THE kitchen ISA LOCATION --- DESCRIPTION --- "You are in the kitchen." --- IF visited OF THIS = 1 --- THEN "This is your first time here." --- ELSE "You remember you've been here before." --- END IF. --- ... --- END THE. - --- Note that if you have an NPC moving around in the game, the visited value of any location --- will increase when the NPC enters the location, as well (ENTERED applies to all moving actors). --- This is most often not what is wanted, and that's why the 'if' statement --- (IF CURRENT ACTOR = hero) is included above. - - --- You can also check whether the hero has been in a location if needed: - --- THE king ISA ACTOR --- ... --- VERB ask --- WHEN act --- IF topic = treasure_chamber --- THEN --- IF visited OF treasure_chamber = 0 --- THEN "You are not supposed to know anything about the treasure --- chamber - you haven't found it yet." --- ELSE """Just take what you want from the chamber"", the king smiles." --- END IF. --- ... --- END IF. --- END VERB. --- END THE. - - --- etc. - - --- Suppose you want the location description to be different after the first time the description is shown, --- even if you are in the location still for the first time. Then, you can use the 'described' attribute, e.g.: - - --- THE library ISA ROOM --- DESCRIPTION --- IF described OF THIS = 1 --- THEN "There is an old man reading at a table in one of the corners." --- ELSE "The old man keeps on reading at his table." --- END IF. --- END THE. - - - --- ======================================================================= - - --- 5. The instance 'room' - - --- ======================================================================= - - --- Through defining the instance 'room' we make possible player commands such as 'examine room' --- and 'exit room', among others. These commands only work in indoor locations. --- We have to identify this instance differently from 'room' which has already been --- defined as a class above, that's why we identify it here as 'current_room'. Through the NAME --- statement, it can be still called a 'room' in-game. - - -THE current_room ISA OBJECT - AT indoor - NAME 'room' - IS NOT takeable. - IS NOT movable. - CONTAINER -- to allow the player command 'exit room'. - DESCRIPTION "" - - - VERB examine - DOES ONLY LOOK. - INCREASE described OF CURRENT LOCATION. - END VERB. - - - VERB search - DOES ONLY "Try examining one thing at a time." - IF hero AT lr THEN "$p$p(The Kitchen)$nTry examining one thing at a time." END IF. - END VERB. - - - VERB enter - DOES ONLY "You must state a direction where to go." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou must state a direction where to go." END IF. - END VERB. - - - VERB 'exit' - DOES ONLY "You must state a direction where to go." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou must state a direction where to go." END IF. - - - END VERB. - - - VERB look_under, look_through, look_behind - DOES ONLY "That's not possible." - IF hero AT lr THEN "$p$p(The Kitchen)$nThat's not possible." END IF. - END VERB. - - -END THE. - - -THE kitchen_object ISA ROOM - NAME kitchen - DESCRIPTION "" -END THE. - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/messages.i b/app/src/main/jni/terps/alan/alan3/bugs/abandoned/messages.i deleted file mode 100755 index 09d49ca..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/messages.i +++ /dev/null @@ -1,104 +0,0 @@ --- ALAN Standard Library v1.00 --- Messages (file name: 'messages.i') - - --- This library file lists all the standard runtime messages listed in the manual, for easy modification. - - - -MESSAGE AFTER_BUT: "You must give at least one object after '$1'." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AGAIN: "(again)" -- if you wish to disable this, make the string empty ("") - BUT_ALL: "You can only use '$1' AFTER '$2'." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - CAN_NOT_CONTAIN: "$+1 can not contain $+2." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - CANT0: "You can't do that." -- note that the fifth token in CANT0 is a zero, not an 'o'. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - CARRIES: "$+1 carries" - 'CONTAINS': "$+1 contains" - CONTAINS_COMMA: "$01," - CONTAINS_AND: "$01 and" - CONTAINS_END: "$01." - EMPTY_HANDED: "$+1 is empty-handed." - HAVE_SCORED: "You have scored $1 points out of $2." - IS_EMPTY: "$+1 is empty." - MORE: "" - MULTIPLE: "You can't refer to multiple objects with '$v'." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - NO_SUCH: "You can't see any such thing." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - IF hero AT bbr - THEN - IF value OF bbr_m < 2 - THEN "(If you tried to guess an object, that was a good shot. Carry on!)" - INCREASE value OF bbr_m. - END IF. - END IF. - NO_WAY: "You can't go that way." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - NOT_MUCH: "That doesn't leave much to $v!" - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - NOUN: "You must supply a noun." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - NOT_A_SAVEFILE: "That file does not seem to be an Alan game save file." - QUIT_ACTION: "Do you want to RESTART, RESTORE, QUIT or UNDO? " - -- these four alternatives are hardwired to the interpreter and cannot be changed. - REALLY: "Are you sure (RETURN confirms)?" - RESTORE_FROM: "Enter file name to restore from" - SAVE_FAILED: "Sorry, save failed." - SAVE_MISSING: "Sorry, could not open the save file." - SAVE_NAME: "Sorry, the save file did not contain a save for this adventure." - SAVE_OVERWRITE: "That file already exists, overwrite (y)?" - SAVE_VERSION: "Sorry, the save file was created by a different version." - SAVE_WHERE: "Enter file name to save in" - SEE_START: "There is $01" - SEE_COMMA: ", $01" - SEE_AND: "and $01" - SEE_END: "here." - NO_UNDO: "No further undo available." - UNDONE: "'$1' undone." - UNKNOWN_WORD: "I don't know the word '$1'." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - IF hero AT bbr - THEN - IF value OF bbr_m < 2 - THEN "(If you tried to guess an object, that was a good shot. Carry on!)" - INCREASE value OF bbr_m. - END IF. - END IF. - WHAT: "I don't understand." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - WHAT_WORD: "I don't know what you mean by '$1'." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - WHICH_PRONOUN_START: "I don't know if you by '$1'" - WHICH_PRONOUN_FIRST: "mean $+1" - WHICH_START: "I don't know if you mean $+1" - WHICH_COMMA: ", $+1" - WHICH_OR: "or $+1." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - -THE bbr_m ISA OBJECT - HAS value 0. -END THE. - - --- These messages are automatically translated into German or Swedish in your game --- if you define in the beginning of your source code --- --- OPTIONS --- LANGUAGE German. --- --- or --- --- OPTIONS --- LANGUAGE Swedish. --- --- Only the exact equivalents of the above phrases will then be shown; if you change the above English --- messages to your own wordings, the translations will still be only for the default. --- --- --- If you wish to write your game in some other language, you must manually translate --- the messages above. There might be support for more languages in the future, depending --- on demand. - diff --git a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/play.input b/app/src/main/jni/terps/alan/alan3/bugs/abandoned/play.input deleted file mode 100755 index b6867f8..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/play.input +++ /dev/null @@ -1,7 +0,0 @@ -n -w -take fence -n -put ladder against house -u -play "c" diff --git a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/verbs.i b/app/src/main/jni/terps/alan/alan3/bugs/abandoned/verbs.i deleted file mode 100755 index 4999f4c..0000000 --- a/app/src/main/jni/terps/alan/alan3/bugs/abandoned/verbs.i +++ /dev/null @@ -1,8797 +0,0 @@ - --- ALAN Standard Library v1.00 --- Verbs (file name: 'verbs.i') - - ------ This library file defines common verbs needed in gameplay. The verbs ------ are listed alphabetically. This file also includes common commands which are not ------ actually verbs, such as "inventory", "verbose" and "again". You are free to edit this ------ file for your own purposes in any way you like by adding, deleting or modifying verbs. ------ Verbs originally defined in this file are the following: - - ------ VERB SYNONYMS SYNTAX ARITY OBJ - ------ about (+ help, info) about 0 ------ again (+ g) again 0 ------ answer (+ reply) answer (topic) 1 ------ ask (+ enquire, inquire, interrogate) ask (act) about (topic) 2 ------ ask for ask (act) for (obj) 2 x ------ attack (+ beat, fight, hit, punch) attack (target) 1 ------ attack_with attack (target) with (weapon) 2 ------ bite (+ chew) bite (obj) 1 x ------ break (+ destroy) break (obj) 1 x ------ break_with break (obj) with (instr) 2 x ------ brief brief 0 ------ burn burn (obj) 1 x ------ burn_with burn (obj) with (instr) 2 x ------ buy (+ purchase) buy (item) 1 ------ catch catch (obj) 1 x ------ clean (+ polish, wipe) clean (obj) 1 x ------ climb climb (obj) 1 x ------ climb_on climb on (surface) 1 ------ climb_through climb through (obj) 1 x ------ close (+ shut) close (obj) 1 x ------ close_with close (obj) with (instr) 2 x ------ consult consult (source) about (topic) 2 ------ credits (+ acknowledgments, author, copyright) credits 2 ------ cut cut (obj) 1 x ------ cut_with cut (obj) with (instr) 2 x ------ dance dance 0 ------ dig dig (obj) 1 x ------ dive dive 0 ------ dive_in dive in (liq) 1 ------ drink drink (liq) 1 ------ drive drive (vehicle) 1 ------ drop (+ discard, dump, reject) drop (obj) 1 x ------ eat eat (food) 1 ------ empty empty (obj) 1 x ------ empty_in empty (obj) in (cont) 2 x ------ empty_on empty (obj) in (cont) 2 x ------ enter enter (cont) 1 ------ examine (+ check, inspect, observe, x) examine (obj) 1 x ------ exit exit (cont) 1 ------ extinguish (+ put out, quench) extinguish (obj) 1 x ------ fill fill (cont) 1 ------ fill_with fill (cont) with (substance) 1 ------ find (+ locate) find (obj) 1 x ------ fire fire (weapon) 1 ------ flip flip (obj) 1 x ------ follow follow (act) 1 ------ free (+ release) free (obj) 1 x ------ get_up get up 0 ------ get_off get off (obj) 1 x ------ give give (obj) to (recip) 1 x ------ go_to go to (dest) 1 ------ hint (+ hints) hint 0 ------ inventory (+ i, inv) inventory 0 ------ jump jump 0 ------ jump_in jump in (cont) 1 ------ jump_on jump on (surface) 1 ------ kick kick (target) 1 ------ kill (+ murder) kill (victim) 1 ------ kill_with kill (victim) with (weapon) 2 ------ kiss (+ hug, embrace) kiss (obj) 1 x ------ lie_down lie down 0 ------ lie_in lie in (cont) 1 ------ lie_on lie on (surface) 1 ------ lift lift (obj) 1 x ------ light (+ lit) light (obj) 1 x ------ listen0 listen 0 ------ listen listen to (obj) 1 x ------ lock lock (obj) 1 x ------ lock_with lock (obj) with (instr) 2 x ------ look (+ gaze, peek) look 0 ------ look_at look at (obj) 1 x ------ look_behind look behind (bulk) 1 ------ look_in look in (cont) 1 ------ look_out_of look out of (obj) 1 x ------ look_through look through (bulk) 1 ------ look_under look under (bulk) 1 ------ look_up look up 0 ------ no no 0 ------ notify (on, off) notify. notify on. notify off 0 ------ open open (obj) 1 x ------ open_with open (obj) with (instr) 2 x ------ play play (obj) 1 x ------ play_with play with (obj) 1 x ------ pour (= defined at the verb 'empty) pour (obj) 1 x ------ pour_in (= defined at the verb 'emtpy_in') pour (obj) in (cont) 2 x ------ pour_on (= defined at the verb 'empty_on') pour (obj) on (surface) 2 x ------ pray pray 0 ------ pry pry (obj) 1 x ------ pry_with pry (obj) with (instr) 2 x ------ pull pull (obj) 1 x ------ push push (obj) 1 x ------ push_with push (obj) with (instr) 2 x ------ put (+ lay, place) put (obj) 1 x ------ put_against put (obj) against (bulk)) 2 x ------ put_behind put (obj) behind (bulk) 2 x ------ put_down put down (obj) 1 x ------ put_in (+ insert) put (obj) in (cont) 2 x ------ put_near put (obj) near (bulk) 2 x ------ put_on put (obj) on (surface) 2 x ------ put_under put (obj) under (bulk) 2 x ------ read read (obj) 1 x ------ restart restart 0 ------ restore restore 0 ------ rub rub (obj) 1 x ------ save save 0 ------ say say (topic) 1 ------ say_to say (topic) to (act) 2 ------ score score 0 ------ scratch scratch (obj) 1 x ------ script script. script on. script off. 0 ------ search search (obj) 1 x ------ sell sell (item) 1 ------ shake shake (obj) 1 x ------ shoot (at) shoot at (target) 1 ------ shoot_with shoot (target) with (weapon) 2 ------ shout (+ scream, yell) shout 0 ------ show (+ reveal) show (obj) to (act) 2 x ------ sing sing 0 ------ sip sip (liq) 1 ------ sit (down) sit. sit down. 0 ------ sit_on sit on (surface) 1 ------ sleep (+ rest) sleep 0 ------ smell0 smell 0 ------ smell smell (odour) 1 ------ squeeze squeeze (obj) 1 x ------ stand (up) stand. stand up. 0 ------ stand_on stand on (surface) 1 ------ swim swim 0 ------ swim_in swim in (liq) 1 ------ switch_on switch on (app) 1 ------ switch_off switch off (app) 1 ------ take (+ carry, get, grab, hold, obtain) take (obj) 1 x ------ take_from (+ remove from) take (obj) from (holder) 2 x ------ talk talk 0 ------ talk_to (+ speak) talk to (act) 1 ------ taste (+ lick) taste (obj) 1 x ------ tear (+ rip) tear (obj) 1 x ------ tell (+ enlighten, inform) tell (act) about (topic) 2 ------ think think 0 ------ think_about think about (topic) 1 ------ throw throw (projectile) 1 ------ throw_at throw (projectile) at (target) 2 ------ throw_in throw (projectile) in (cont) 2 ------ throw_to throw (projectile) to (recipient) 2 ------ tie tie (obj) 1 x ------ tie_to tie (obj) to (target) 2 x ------ touch (+ feel) touch (obj) 1 x ------ turn (+ rotate) turn (obj) 1 x ------ turn_on turn on (app) 1 ------ turn_off turn off (app) 1 ------ unlock unlock (obj) 1 x ------ unlock_with unlock (obj) with (key) 2 x ------ use use (obj) 1 x ------ use_with use (obj) with (instr) 2 x ------ verbose verbose 0 ------ wait (+ z) wait 0 ------ what_am_i what am i 0 ------ what_is what is (obj) 1 x ------ where_am_i where am i 0 ------ where_is where is (obj) 1 x ------ who_am_i who am i 0 ------ who_is who is (obj) 1 x ------ write write (txt) on (obj) 2 x ------ yes yes 0 - - - ------ Verbs having to do with wearing clothes are defined in the file 'classes.i', ------ subclass 'clothing'. These verbs are: ------ ------ remove (+ doff, take off) remove (clothing) 1 ------ undress undress 0 ------ wear (+ don, put on) wear (clothing) 1 - - ------ Directions (north, south, up, etc.) are declared in the file 'locations.i'. - - - ------ We first declare some default attributes for things (= objects and actors) below. ------ These attributes are frequently checked in verb definitions to prohibit ------ the use of verbs with objects and actors in an irrational way. For example, the hero ------ won't be able to eat anything that is not edible, and so forth. - - ------ Specific class attributes that override or complete the following ------ attributes are declared in the files 'classes.i' and 'locations.i'. - - - -ADD TO EVERY THING - - IS examinable. - inanimate. - movable. - reachable. - takeable. - - HAS text "". - - NOT broken. - NOT closeable. - NOT closed. - NOT drinkable. - NOT edible. - NOT lit. - NOT lockable. - NOT locked. - NOT readable. - NOT wearable. - NOT writeable. - - CAN NOT talk. -- Since Alan3 alpha8, CAN is accepted as an attribute header word. - -- 'Talk' here doesn't refer to the verb 'talk'; it just means that an actor is - -- (or is not) able to talk. This is to make the code more readable. - -- (Cf. 'HAS can_talk', which was the formulation earlier.) -END ADD TO. - - - - --- We still define that plural nouns are preceded by "some" (and not "a" or "an"): - - -ADD TO EVERY THING - INDEFINITE ARTICLE - IF THIS IS plural - THEN "some" - ELSE "a" - END IF. -END ADD TO. - --- If you need "an", you should declare it separately at the instance, e.g.: - --- THE owl ISA ACTOR --- AT woods --- INDEFINITE ARTICLE "an" --- END THE. - - - --- (We add the 'plural' attribute to the 'entity' class, because the plural --- applies not only to things but also to e.g. parameters in syntax statements; ignore.) - - -ADD TO EVERY ENTITY - IS NOT plural. -END ADD TO. - - - --- (Other article and pronoun definitions are in the file 'classes.i'.) - - - ------ Next, we declare synonyms for some words so that it will be possible ------ for the player to type commands such as both "put ball in box" and ------ "put ball into box", etc: - - - -SYNONYMS - -into, inside = 'in'. -onto = on. -thru = through. -using = 'with'. - - - ------ The verbs and commands: - - - --- ============================================================= - - ------ ABOUT - - --- ============================================================= - - -SYNTAX 'about' = 'about'. - - -VERB 'about' - DOES - "This is a text adventure, also called interactive fiction, which means that what - goes on in the story depends on what you type at the prompt. Commands you can type - are for example GO NORTH (or NORTH or just N), WEST, SOUTHEAST, UP, IN etc for - moving around, but you can try many - other things too, like TAKE LAMP, DROP EVERYTHING, EAT APPLE, EXAMINE BIRD or - FOLLOW OLD MAN, to name just a few. LOOK (L) describes your surroundings, and - INVENTORY (I) lists what you are carrying. You can SAVE your game and RESTORE it - later on. - - $pPlease note that in this game SEARCH is an important verb besides EXAMINE. - - $pType CREDITS to see information about the author and the copyright issues. - $pType HINTS (or H) for hints and WALKTHRU for the walkthrough. - $pTo stop playing and end the program, type QUIT.$p" -END VERB. - - -SYNONYMS help, info = 'about'. - - - --- ============================================================= - - ------ AGAIN (= g) - - --- ============================================================= - - -SYNTAX again = again. - - -VERB again - DOES - "[The AGAIN command is not supported in this game. As a workaround, try using - the 'up' and 'down' arrow keys to scroll through your previous commands.]" -END VERB. - - -SYNONYMS g = again. - - - --- ============================================================= - - ------ ANSWER (+ reply) - - --- ============================================================= - - -SYNTAX answer = answer (topic) - WHERE topic ISA STRING - ELSE "That's not something you can answer." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY STRING - VERB answer - DOES - IF COUNT ISA ACTOR, AT hero < 1 - THEN "There is no-one here to hear you talk." - IF hero AT lr THEN "$p$p(The Kitchen)$nThere is no-on here to hear you talk." END IF. - ELSE "There is no reaction." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ ASK (= enquire, inquire, interrogate) - - --- ============================================================= - - -SYNTAX ask = ask (act) about (topic)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND topic ISA THING - ELSE - IF topic IS NOT plural - THEN "That's doesn't" - ELSE "Those don't" - END IF. - "seem to be something you can talk about with" SAY THE act. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - - ask = enquire (act) about (topic)!. - - ask = inquire (act) about (topic)!. - - ask = interrogate (act) about (topic)!. - - -- Above, we define the alternative verbs in the syntax rather than as synonyms, - -- as the verb 'ask_for' below doesn't sound correct with these alternatives allowed. - - -ADD TO EVERY ACTOR - VERB ask - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND act <> hero - ELSE "It doesn't make much sense to ask yourself about something." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND act IS reachable -- you might want to remove this check in some situations, e.g. - -- when an NPC (= a non-player character) is speaking - -- on the phone with the hero - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away for you to talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF topic IN act - THEN SAY THE act. - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "seem to want to talk about" SAY THE topic. "." - - ELSIF topic = act - THEN SAY THE act. - IF act IS NOT plural - THEN "chooses" - ELSE "choose" - END IF. - "to be silent." - - ELSIF topic = hero - THEN """I think you know more about yourself than what I do!""," SAY THE act. - IF act IS NOT plural - THEN "remarks." - ELSE "remark." - END IF. - - ELSE """I don't know anything about" SAY THE topic. "$$!""," SAY THE act. - IF act IS NOT plural - THEN "remarks." - ELSE "remark." - END IF. - END IF. - END VERB. -END ADD TO. - - - - ------ note that 'consult' is defined separately - - - --- ============================================================= - - ------ ASK FOR - - --- ============================================================= - - -SYNTAX ask_for = ask (act) 'for' (obj) - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can ask for things." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can ask for." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY ACTOR -VERB ask_for - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND act <> hero - ELSE "It doesn't make much sense to ask yourself for something." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND act IS reachable -- you might want to remove this check in some situations, e.g. - -- when an NPC (= a non-player character) is speaking - -- on the phone with the hero - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away for you to talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "not something that" SAY THE act. "could give to you." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE act. "can't reach" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN hero - ELSE "Why ask for something you already have?" - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - SAY THE act. - IF act IS NOT plural - THEN "gives you" - ELSE "give you" - END IF. - SAY THE obj. "." - LOCATE obj IN hero. -END VERB. -END ADD TO. - - ---- another 'ask_for' formulation added to guide players to use the right phrasing: - - -SYNTAX ask_for_error = ask 'for' (obj) - WHERE obj ISA OBJECT - ELSE "Please use the formulation ASK PERSON FOR THING to ask somebody for - something." - - -ADD TO EVERY OBJECT -VERB ask_for_error - DOES "Please use the formulation ASK PERSON FOR THING to ask somebody for - something." -END VERB. -END ADD TO. - - - --- ============================================================= - - ------ ATTACK (+ beat, fight, hit, punch) - - --- ============================================================= - - -SYNTAX attack = attack (target) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can attack." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB attack - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target <> hero - ELSE "It doesn't make sense to $v yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND target IS reachable - ELSE SAY THE target. - IF target IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to brute force is not the solution here." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - -SYNONYMS beat, fight, hit, punch = attack. - --- Note that 'kick' is defined separately, to avoid absurd commands such as --- 'kick man with sword' (see 'attack_with' below) - - - --- ============================================================== - - ------ ATTACK WITH - - --- ============================================================== - - -SYNTAX attack_with = attack (target) 'with' (weapon) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND weapon ISA WEAPON - ELSE - IF weapon ISA ACTOR - THEN - IF weapon = hero - THEN "It doesn't make sense to attack something with yourself." - ELSE "You cannot use" SAY THE weapon. "to attack anything." - END IF. - ELSE "There's no point attacking anything with" SAY THE weapon. "." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB attack_with - WHEN target - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND weapon IS takeable - ELSE "You don't have" SAY THE weapon. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target <> hero - ELSE "It doesn't make sense to $v yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target NOT IN hero - ELSE "It doesn't make much sense to $v something you're holding." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target NOT IN worn - ELSE "It doesn't make sense to $v something you're wearing." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND target IS reachable - ELSE SAY THE target. - IF target IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND hero IS NOT sitting - ELSE "It is difficult to attack anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to attack anything while lying down." - DOES "Resorting to brute force is not the solution here." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- =============================================================== - - ------ BITE (+ chew, taste) - - --- =============================================================== - - -SYNTAX bite = bite (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can bite." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB bite - CHECK obj IS edible - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you should $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - -- This if-statement takes care of implicit taking; i.e. if the hero - -- doesn't have the object, (s)he will take it automatically first. - -- This same if-statement is found in numerous other verbs throughout - -- the library, as well. - - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - - - "You take a bite of" SAY THE obj. "$$." - IF obj IS NOT plural - THEN "It tastes rather good." - ELSE "They taste rather good." - END IF. - - END VERB. -END ADD TO. - - -SYNONYMS chew = bite. - - - --- =============================================================== - - ------ BREAK - - --- =============================================================== - - -SYNTAX break = break (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "Resorting to brute force is not the solution here." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END IF. - - -ADD TO EVERY OBJECT - VERB break - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can break." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - DOES - "Resorting to brute force is not the solution here." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - -SYNONYMS destroy = break. - - - --- =============================================================== - - ------ BREAK WITH - - --- =============================================================== - - -SYNTAX break_with = break (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr ISA OBJECT - ELSE - IF instr IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v things with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB break_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can break." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "Trying to break" SAY THE obj. "with" SAY THE instr. - "wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ BRIEF - - --- ================================================================ - - --- Use "Visits 0." or "Visits 1000." in the START section if you want --- the game to start in verbose or brief mode. (By default, --- all games start in the verbose mode.) - - -SYNTAX brief = brief. - - -VERB brief - DOES - "Brief mode is not in use in this game." -END VERB. - - - --- ================================================================= - - ------ BURN - - --- ================================================================= - - -SYNTAX burn = burn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "That would be needlessly brutal." - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can burn." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB burn - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can burn." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You must state what you want to burn" SAY THE obj. "with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ================================================================= - - ------ BURN WITH - - --- ================================================================= - - -SYNTAX burn_with = burn (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN "That would be needlessly brutal." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can ask for things." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END IF. - AND instr ISA OBJECT - ELSE - IF instr ISA ACTOR - THEN "It doesn't make sense to burn something with" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - ELSE "It's not possible to burn something with" - IF instr IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END IF. - - -ADD TO EVERY OBJECT - VERB burn_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can burn." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> instr - ELSE "It doesn't make sense to burn something with itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You can't burn" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ BUY (+ purchase) - - --- ================================================================== - - -SYNTAX buy = buy (item) - WHERE item ISA OBJECT - ELSE - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB buy - CHECK item IS examinable - ELSE - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can buy." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "for sale." - END VERB. -END ADD TO. - - -SYNONYMS purchase = buy. - - - --- ================================================================== - - ------ CATCH - - --- ================================================================== - - -SYNTAX catch = catch (obj) - WHERE obj ISA THING - ELSE "That's not something you can catch." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB catch - CHECK obj <> hero - ELSE "It doesn't make sense to $v yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to catch anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to catch anything while lying down." - DOES - IF obj IS NOT plural - THEN "That doesn't" - ELSE "Those don't" - END IF. - "need to be caught." - END VERB. -END ADD TO. - - - --- ================================================================== - - ------ CLEAN ( + wipe, polish) - - --- ================================================================== - - -SYNTAX clean = clean (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB clean - CHECK obj IS examinable - ELSE IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - -SYNONYMS wipe, polish = clean. - - ------ notice that 'rub' is defined separately - - - --- ============================================================== - - ------ CLIMB - - --- ============================================================== - - -SYNTAX climb = climb (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB climb - CHECK obj IS examinable - ELSE IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND hero IS NOT sitting - ELSE "It is difficult to climb while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb while lying down." - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB ON - - --- ============================================================== - - -SYNTAX climb_on = climb 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY SUPPORTER - VERB climb_on - CHECK surface IS reachable - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb on." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLIMB THROUGH - - --- ============================================================== - - -SYNTAX climb_through = climb through (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb through." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB climb_through - CHECK obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to climb anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to climb anywhere while lying down." - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can climb through." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CLOSE (+ shut) - - --- ============================================================== - - -SYNTAX close = close (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB close - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can close." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - - AND obj IS NOT closed - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - MAKE obj closed. - "You close the" SAY THE obj. "." - END VERB. -END ADD TO. - - -SYNONYMS shut = close. - - - --- ============================================================== - - ------ CLOSE WITH - - --- ============================================================== - - -SYNTAX close_with = close (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr ISA OBJECT - ELSE - IF instr IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "$v anything with that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB close_with - WHEN obj - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT closed - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You can't $v" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CONSULT - - --- ============================================================== - - -SYNTAX consult = consult (source) about (topic)! - WHERE source ISA THING - ELSE - IF source IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can consult." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND topic ISA THING - ELSE - IF topic IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can find information about." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - consult = 'look' 'up' (topic) 'in' (source). - - -ADD TO EVERY THING - VERB consult - WHEN source - CHECK source IS examinable - ELSE - IF source IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can consult." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND source <> hero - ELSE "It doesn't make sense to consult yourself about anything." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND source IS reachable - ELSE SAY THE source. - IF source IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF source ISA OBJECT - THEN "You find nothing useful about" SAY THE topic. "in" SAY THE source. "." - ELSE SAY THE source. - IF source IS NOT plural - THEN "chooses" - ELSE "choose" - END IF. - "to be silent on that subject." - END IF. - END VERB. -END ADD TO. - - ---- another 'consult' formulation added to guide players to use the right phrasing: - - -SYNTAX consult_error = consult (source) - WHERE source ISA THING - ELSE "To consult something, please use the - formulation CONSULT PERSON/THING ABOUT PERSON/THING." - - -ADD TO EVERY THING - VERB consult_error - DOES "To consult something, please use the formulation CONSULT PERSON/THING - ABOUT PERSON/THING." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CREDITS (+ acknowledgments, author, copyright) - - --- ============================================================== - - -SYNTAX credits = credits. - - -VERB credits - DOES - "(c) 2011 by Anssi Risnen - - $pBeta-testers: Jonathan Blask, Wade Clarke, Steve Griffiths and Lutein Hawthorne. All the remaining - shortcomings in this game are entirely my own fault. My sincere thanks to all of you! - $pAdditional thanks to Wade Clarke for the cover art. - Cover art includes the photo 'Stairway to Heaven' by Neal Sanche, licensed under a Creative Commons - Attribution - NonCommercial license: http://creativecommons.org/licenses/by-nc/2.0/ - - $pThis game was written using the ALAN Adventure Language. ALAN is - an interactive fiction authoring system by Thomas Nilsson. E-mail address: thomas.nilsson@progindus.se - $pFurther information - about the ALAN system can be obtained from - the World Wide Web Internet site - $ihttp://www.alanif.se$p" -END VERB. - - -SYNONYMS acknowledgments, author, copyright = credits. - - - --- ============================================================== - - ------ CUT - - --- ============================================================== - - -SYNTAX cut = cut (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can cut." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB cut - DOES "You need to specify what you want to cut" SAY THE obj. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ CUT WITH - - --- ============================================================== - - -SYNTAX cut_with = cut (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can cut." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr ISA OBJECT - ELSE - IF instr IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can cut with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB cut_with - WHEN obj - CHECK obj <> instr - ELSE "You can't cut something with itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You can't cut" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DANCE - - --- ============================================================== - - -SYNTAX dance = dance. - - -VERB dance - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dance while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dance while lying down." - DOES - "How about a waltz?" - "$p$p(The Kitchen) - $nHow about a waltz?" -END VERB. - - - --- ============================================================== - - ------ DIG - - --- ============================================================== - - -SYNTAX dig = dig (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can dig." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB dig - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dig anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dig anything while lying down." - DOES - "There is nothing suitable to dig here." - IF hero AT lr THEN "$p$p(The Kitchen)$nThere is nothing suitable to dig here." END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DIVE - - --- ============================================================== - - -SYNTAX dive = dive. - - -VERB dive - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - - DOES - "There is no water suitable for swimming here." - IF hero AT lr THEN "$p$p(The Kitchen)$nThere is no water suitable for swimming here." END IF. -END VERB. - - - --- ============================================================== - - ------ DIVE IN - - --- ============================================================== - - -SYNTAX dive_in = dive 'in' (liq) - WHERE liq ISA LIQUID - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can dive into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB dive_in - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND hero IS NOT sitting - ELSE "It is difficult to dive anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to dive anywhere while lying down." - - DOES - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can dive into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ DRINK - - --- ============================================================== - - -SYNTAX drink = drink (liq) - WHERE liq ISA LIQUID -- see 'classes.i' - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drink." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY LIQUID - VERB drink - CHECK liq IS drinkable - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drink." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND liq IS takeable - ELSE "You don't have" SAY THE liq. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND liq IS reachable - ELSE SAY THE liq. - IF liq IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF vessel OF liq = no_vessel -- here, if the liquid is in no container, e.g. - -- the hero takes a sip of water from a river, - -- the action is allowed to succeed. - THEN "You drink a bit of" SAY THE liq. "." - ELSE - -- implicit taking: - IF vessel OF liq NOT DIRECTLY IN hero - THEN - IF vessel OF liq IS NOT takeable - THEN "You can't carry" SAY THE liq. "around in your bare hands." - ELSE LOCATE vessel OF liq IN hero. - "(taking" SAY THE vessel OF liq. "first)$n" - END IF. - END IF. - -- end of implicit taking. - - IF liq IN hero -- i.e. if the implicit taking was successful - THEN - "You drink all of" SAY THE liq. "." - LOCATE liq AT nowhere. - END IF. - END IF. - - END VERB. -END ADD TO. - - --- Note that the verb 'sip' is defined separately, with a slightly different behaviour. - - - --- ============================================================== - - ------ DRIVE - - --- ============================================================== - - -SYNTAX drive = drive (vehicle) - WHERE vehicle ISA OBJECT - ELSE - IF vehicle IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drive." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB drive - DOES - IF vehicle IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drive." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - --- another 'drive' formulation added to guide players to use the right phrasing: - - -SYNTAX drive_error = drive. - - -VERB drive_error - DOES "To drive something, use the phrasing DRIVE SOMETHING." -END VERB. - - - --- ============================================================== - - ------ DROP - - --- ============================================================== - - -SYNTAX drop = drop (obj)* - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - drop = put (obj) * down. - - - drop = put down (obj)*. - - -ADD TO EVERY OBJECT - VERB drop - CHECK obj IN hero - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - LOCATE obj HERE. - "Dropped." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou can't see any such thing." END IF. - END VERB. -END ADD TO. - - -SYNONYMS - discard, dump, reject = drop. - - - --- ============================================================== - - ------ EAT - - --- ============================================================== - - -SYNTAX eat = eat (food) - WHERE food ISA OBJECT - ELSE - IF food IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can eat." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB eat - CHECK food IS edible - ELSE - IF food IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can eat." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND food IS takeable - ELSE "You don't have" SAY THE food. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND food IS reachable - ELSE SAY THE food. - IF food IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - -- implicit taking: - IF food NOT DIRECTLY IN hero - THEN "(taking" SAY THE food. "first)$n" - LOCATE food IN hero. - END IF. - -- end of implicit taking. - - "You eat all of" SAY THE food. "." - LOCATE food AT nowhere. - - END VERB. -END ADD. - - - --- ============================================================== - - ------ EMPTY (+ POUR) - - --- ============================================================== - - --- The verbs 'empty' and 'pour' have similar syntaxes and behaviour here. They are, however, --- not declared as synonyms but kept separate, as their usage doesn't overlap 100%; for example --- you can pour liquids but not empty them. --- That's why in 'classes.i', liquids are defined only to work with the verb 'pour', --- and the verb 'empty' is disabled for liquids. - - - - -SYNTAX 'empty' = 'empty' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj ISA CONTAINER - ELSE "You can only empty containers." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - pour = pour (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj ISA CONTAINER - ELSE "You can only pour containers." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB 'empty', pour - CHECK obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. - ELSE "You $v the contents of" SAY THE obj. - IF floor HERE - THEN "on the floor." - ELSE "on the ground." - END IF. - EMPTY obj AT hero. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ EMPTY IN (+ POUR IN) - - --- ============================================================== - - - -SYNTAX empty_in = 'empty' (obj) 'in' (cont) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -pour_in = pour (obj) 'in' (cont) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT -VERB empty_in, pour_in - WHEN obj - CHECK obj <> cont - ELSE "It doesn't make sense to $v something into itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj NOT DIRECTLY IN cont - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already in" SAY THE cont. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont IS reachable - ELSE SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont IS NOT closed - ELSE "You can't, since" SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. "." - ELSE EMPTY obj IN cont. - "You $v the contents of" SAY THE obj. - "into" SAY THE cont. "." - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ EMPTY ON (+ POUR ON) - - --- ============================================================== - - - -SYNTAX empty_on = 'empty' (obj) 'on' (surface) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can empty." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND surface ISA OBJECT - ELSE - IF surface ISA ACTOR - THEN - IF surface = hero - THEN "That wouldn't make sense." - ELSE "That wouldn't be polite." - END IF. - ELSE "You can't empty anything onto" SAY THE surface. "." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND surface ISA CONTAINER - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - "something you can empty things onto." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - pour_on = pour (obj) 'on' (surface) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj ISA CONTAINER - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pour." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND surface ISA OBJECT - ELSE - IF surface ISA ACTOR - THEN - IF surface = hero - THEN "That wouldn't make sense." - ELSE "That wouldn't be polite." - END IF. - ELSE "You can't pour anything onto" SAY THE surface. "." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND surface ISA CONTAINER - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - "something you can pour things onto." - - -ADD TO EVERY OBJECT -VERB empty_on, pour_on - WHEN obj - CHECK obj <> surface - ELSE "It doesn't make sense to $v something on itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND surface IS reachable - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS NOT closed - ELSE "You can't, since" SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF COUNT ISA OBJECT, IN obj = 0 - THEN "There is nothing in" SAY THE obj. "." - ELSE - IF surface = floor OR surface = ground - THEN EMPTY obj AT hero. - "You $v the contents of" SAY THE obj. "on" SAY THE surface. "." - ELSIF surface ISA SUPPORTER - THEN EMPTY obj IN surface. - "You $v the contents of" SAY THE obj. "on" SAY THE surface. "." - ELSE "It wouldn't be sensible to $v anything on" SAY THE surface. - END IF. - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ ENTER - - --- ============================================================== - - -SYNTAX enter = enter (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can enter." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE - IF cont = house - THEN "Yes, but how?" - ELSIF cont = upstair_window_n - THEN - IF garden_ladder IS NOT leaning - THEN "You can't go that way." - ELSE "You climb up the shaky ladder construction and reach the upstairs window. - The window is easy to force open as the frame is rather decayed. However, - the rickety ladder gives way under you and collapses onto the ground. - You manage to grab the window sill just in time to pull yourself into the house. - An old dresser has been pulled half in front of the window but you manage to make your way - into the room past it." - LOCATE hero AT wbr. SCHEDULE welcome AT hero AFTER 0. - MAKE house 'entered'. - END IF. - ELSIF cont IS NOT plural - THEN "That's not something you can enter." - ELSE "Those are not something you can enter." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB enter - CHECK hero IS NOT sitting - ELSE "It is difficult to enter anything while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to enter anything while lying down." - DOES - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can enter." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - ---- another 'enter' formulation declared to guide players to use the right formulation: - - -SYNTAX enter_error = enter. - - -VERB enter_error - DOES "You must state what you want to enter." -END VERB. - - - --- ============================================================== - - ------ EXAMINE (+ look at) - - --- ============================================================== - - -SYNTAX examine = examine (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can examine." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -SYNTAX examine = 'look' 'at' (obj). - examine = 'look' (obj). -- note that this formulation is allowed, too - - -ADD TO EVERY THING - VERB examine - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can examine." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "You can't see anything in the dark." - DOES - IF obj IS readable - THEN - IF text OF obj = "" - THEN "There is nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. "." - IF obj IS NOT plural - THEN "It says" - ELSE "They say" - END IF. - """$$" SAY text OF obj. "$$""." - END IF. - ELSE "There is nothing special about" SAY THE obj. "." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS - 'check', inspect, observe, x = examine. - - - --- ============================================================== - - ------ EXIT - - --- ============================================================== - - -SYNTAX 'exit' = 'exit' (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can exit." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can exit." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - -ADD TO EVERY OBJECT - VERB 'exit' - CHECK hero IN cont - ELSE - IF cont = current_room - THEN "You must state a direction where to go." - ELSE "But you aren't in" SAY THE cont. "!" - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You exit" SAY THE cont. "." - LOCATE hero AT CURRENT LOCATION. - MAKE hero NOT sitting. - MAKE hero NOT lying_down. - END VERB. -END ADD TO. - - ---- another 'exit' formulation added to guide players to use the right formulation: - - -SYNTAX exit_error = 'exit'. - - -VERB exit_error - DOES - "You must state what you want to exit." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. -END VERB. - - - --- ============================================================== - - ------ EXTINGUISH (+ put out) - - --- ============================================================== - - - -SYNTAX extinguish = extinguish (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can extinguish." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - extinguish = put 'out' (obj). - - -ADD TO EVERY OBJECT - VERB extinguish - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "on fire." - END VERB. -END ADD TO. - - -SYNONYMS quench = extinguish. - - - --- ============================================================== - - ------ FILL - - --- ============================================================== - - -SYNTAX fill = fill (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fill." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fill." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB fill - DOES - "You have to say what you want to fill" SAY THE cont. "with." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FILL WITH - - --- ============================================================== - - -SYNTAX fill_with = fill (cont) 'with' (substance) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fill." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fill." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND substance ISA OBJECT - ELSE "It's not possible to fill something with" - IF substance IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB fill_with - WHEN cont - CHECK cont <> substance - ELSE "It doesn't make sense to fill something with itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND substance NOT IN cont - ELSE SAY THE cont. "is already full of" SAY substance. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont IS reachable - ELSE SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - -- "That wouldn't accomplish anything." - - "You fill" SAY THE cont. "with" SAY substance. "." - LOCATE substance IN cont. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIND - - --- ============================================================== - - -SYNTAX - find = find (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you need to find." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB find - CHECK obj <> hero - ELSE "You're right here!" - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It's too dark to find anything here." - AND obj NOT HERE - ELSE "The" SAY obj. "is right here!" - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You'll have to find it yourself." - IF hero AT lr - THEN - IF obj AT kitchen - THEN "$p$p(The Kitchen)$n" SAY THE obj. "is right here!" - END IF. - END IF. - END VERB. -END ADD TO. - - -SYNONYMS 'locate' = find. - - - --- ============================================================== - - ------ FIRE - - --- ============================================================== - - -SYNTAX fire = fire (weapon) - WHERE weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY WEAPON - VERB fire - CHECK weapon IS fireable - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND weapon IN hero - ELSE "You don't have" SAY THE weapon. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You fire" SAY THE weapon. "into the air." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIRE AT - - --- ============================================================== - - -SYNTAX fire_at = fire (weapon) 'at' (target) - WHERE weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target ISA THING - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shoot at." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY WEAPON - VERB fire_at - WHEN weapon - CHECK weapon IS fireable - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND weapon IN hero - ELSE "You don't have" SAY THE weapon. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the solution here." - END VERB. -END ADD TO. - - --- another formulation added: - - -SYNTAX fire_at_error = fire 'at' (target) - WHERE target ISA THING - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can fire at." - - -ADD TO EVERY THING -VERB fire_at_error - CHECK COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE "You are not holding any firearm." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target <> hero - ELSE "There's no need to be that desperate." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the solution here." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FIX (mend, repair) - - --- ============================================================== - - -SYNTAX - fix = fix (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB fix - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS broken - ELSE "The" SAY obj. "doesn't need fixing." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "Please be more specific. How do you intend to fix it?" - END VERB. -END ADD TO. - - -SYNONYMS mend, repair = fix. - - - - - - - --- ============================================================== - - ------ FOLLOW - - --- ============================================================== - - -SYNTAX follow = follow (act)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can follow." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB follow - CHECK act <> hero - ELSE "It doesn't make sense to follow yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND act NOT AT hero - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "right here." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND hero IS NOT sitting - ELSE "It is difficult to follow anybody while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to follow anybody while lying down." - AND act NOT NEAR hero -- this check presumes that if the actor to be followed - -- is in an adjacent location, the hero will be able to follow him/her. - ELSE "You follow" SAY THE act. "." - LOCATE hero AT act. - DOES - "You don't quite know where" SAY THE act. "went. You must state a direction - where you want to go." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ FREE (+ release) - - --- ============================================================== - - -SYNTAX free = free (obj) - WHERE obj ISA THING - ELSE IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you need to $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB free - CHECK obj IS examinable - ELSE "That's not something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> hero - ELSE "You don't need to be freed at present." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "That doesn't need to be $vd." - END VERB. -END ADD TO. - - -SYNONYMS release = free. - - - --- ============================================================== - - ------- GET OFF - - --- ============================================================== - - -SYNTAX get_off = get off (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can get off." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY SUPPORTER - VERB get_off - DOES - IF hero IS sitting OR hero IS lying_down - THEN "You get off" SAY THE surface. "." - MAKE hero NOT lying_down. - MAKE hero NOT sitting. - ELSE "You're standing up already." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END IF. - END VERB. -END ADD TO. - - --- ============================================================== - - ------- GET UP - - --- ============================================================== - - -SYNTAX get_up = get up. - - -VERB get_up - DOES - IF hero IS sitting - THEN "You stand up." - MAKE hero NOT sitting. - ELSIF hero IS lying_down - THEN "You get up." - MAKE hero NOT lying_down. - ELSE "You're standing up already." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END IF. -END VERB. - - - --- ============================================================== - - ------ GIVE (+ hand, offer) - - --- ============================================================== - - -SYNTAX give = 'give' (obj) 'to' (recip) - WHERE obj ISA OBJECT - ELSE "You can only give away objects." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND recip ISA ACTOR - ELSE - IF recip IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can give things to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - give = give (recip) (obj). - - -ADD TO EVERY OBJECT - VERB give - WHEN obj - CHECK obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> recip - ELSE "It doesn't make sense to give something to itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND recip <> hero - ELSE "It doesn't make sense to give something to yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND recip IS reachable - ELSE SAY THE recip. - IF recip IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN recip - ELSE SAY THE recip. "already" - IF recip IS NOT plural - THEN "has" - ELSE "have" - END IF. - SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - "You give" SAY THE obj. "to" SAY THE recip. "." - LOCATE obj IN recip. - - END VERB. -END ADD TO. - - -SYNONYMS hand, offer = give. - - - --- ============================================================== - - ------ GO TO - - --- ============================================================== - - -SYNTAX go_to = 'to' (dest)! -- because 'go' is predefined in the parser, it can't be used - WHERE dest ISA THING -- in verb definitions - ELSE "It's not possible to go to there." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB go_to - CHECK dest <> hero - ELSE "You're right here!" - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND hero IS NOT sitting - ELSE "It is difficult to go anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to go anywhere while lying down." - DOES - IF dest AT hero - THEN - IF dest IS NOT reachable - THEN "You can't reach" SAY THE dest. "from here." - ELSE - IF CURRENT LOCATION IS lit - THEN IF dest IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - "right here!" - ELSE "It is too dark to see." - END IF. - END IF. - ELSE "You can't see" SAY THE dest. "anywhere nearby. You must state a - direction where you want to go." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS walk = go. -- here we define a synonym for the predefined parser word 'go' - -- which is not visible in the syntax itself. - -- Thus, you will be able to say e.g. both 'go to shop' and 'walk to shop' - -- (as well as e.g. both 'go east' and 'walk east'). - - - --- ============================================================== - - ------ HELP -> see ABOUT - - --- ============================================================== - - - - - --- ============================================================== - - ------ HINT (+ hints) - - --- ============================================================== - - -SYNTAX hint = hint. - -THE game_object ISA OBJECT AT nowhere - HAS hint_level 0. -END THE. - - -VERB hint - DOES - IF hint_level OF game_object = 0 - THEN "There are hints for every location in the game. - If you feel you're stuck, type 'hint' (or just 'H') and you will get a hint for the situation - you are in. If you need another hint, type 'hint' (or 'H') again." - INCREASE hint_level OF game_object. - ELSE - IF house IS NOT 'entered' -- (= hero is outdoors) - THEN - IF hint_level OF outdoor = 0 - THEN "(1/8) If you have gone around the house, there seem to be two spots worth trying to find a way in." - INCREASE hint_level OF outdoor. - ELSIF hint_level OF outdoor = 1 - THEN "(2/8) Did you try climbing the vines?" - INCREASE hint_level OF outdoor. - ELSIF hint_level OF outdoor = 2 - THEN "(3/8) That didn't work, so the only possibility is the unboarded upstairs window on the northern wall." - INCREASE hint_level OF outdoor. - ELSIF hint_level OF outdoor = 3 - THEN "(4/8) You must find a means of reaching it." - INCREASE hint_level OF outdoor. - ELSIF hint_level OF outdoor = 4 - THEN "(5/8) There is really only one object long enough about the house to help you reach the window." - INCREASE hint_level OF outdoor. - ELSIF hint_level OF outdoor = 5 - THEN "(6/8) It's on the western side of the house." - INCREASE hint_level OF outdoor. - ELSIF hint_level OF outdoor = 6 - THEN "(7/8) It's the piece of garden fence." - INCREASE hint_level OF outdoor. - ELSIF hint_level OF outdoor = 7 - THEN "(8/8) Take the piece of garden fence. You'll notice how it could pass for a ladder when turned upright. - Put it against the wall under the unboarded window. Climb it." - "$p(No more hints.)" - INCREASE hint_level OF outdoor. - ELSIF hint_level OF outdoor = 8 - THEN "(No more hints.)" - END IF. - ELSIF hero AT wbr - THEN - IF hint_level OF wbr = 0 - THEN "(1/14) Because there is no location description available, you must just examine what you think - (or know) is to be found here." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 1 - THEN "(2/14) You can for example examine the walls, the floor and the ceiling. That, however, doesn't give - you much help." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 2 - THEN - "(3/14) You came in through the window. There was something half in front of it, wasn't there? - Examining that object in detail will lead you to another crucial piece of furniture here." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 3 - THEN - "(4/14) Examine the shoes you find in the dresser. Another piece of furniture is mentioned in that description." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 4 - THEN "(5/14) Besides the wardrobe and the dresser we still need to find some other things. - Well, you can deduce something from the name of this location." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 5 - THEN "(6/14) It's also a good idea to look *under* the bed." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 6 - THEN "(7/14) I presume you examined the door already?" - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 7 - THEN "(8/14) If you examined the contents of the wardrobe you should by now have found a note - with some letters in it. - What do those letters remind you of?" - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 8 - THEN "(9/14) You shouldn't read those letters as one word but rather as separate units." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 9 - THEN "(10/14) If you tried to play the piano here, you should have a clue." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 10 - THEN "(11/14) The letters stand for different musical notes." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 11 - THEN "(12/14) You can play notes by typing PLAY ""C"" ON THE PIANO, etc. (where C stands for any note - between A and G)." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 12 - THEN "(13/14) You'll notice that playing the notes D, E and B in a row won't have any effect - (whatever that effect is supposed to be). Also you have noticed before that the piano is - two steps out of tune; in other words, the notes sound two steps lower than they should." - INCREASE hint_level OF wbr. - ELSIF hint_level OF wbr = 13 - THEN "(14/14) Play the notes ""F"", ""G"" and ""D"" (which will sound like the notes D, E and B) - on the piano and you should get a reward. $p(No more hints.)" - INCREASE hint_level OF wbr. - ELSE "(No more hints.)" - END IF. - ELSIF hero AT bbr THEN - IF hint_level OF bbr = 0 - THEN "In this room, you can get hints for the seven obscured objects by typing - HINT ON FIRST, HINT ON SECOND etc. (This refers to the order the objects are listed on the table, so they - should all be on the table for the command to work properly.) - If you type just H or HINT as usual, there will be hints for which of the objects - to place on the scale." - INCREASE hint_level OF bbr. - ELSIF hint_level OF bbr = 1 - THEN "(1/4) Did you read the note on the wall? It mentioned *red* herrings." - INCREASE hint_level OF bbr. - ELSIF hint_level OF bbr = 2 - THEN - "(2/4) Besides the usual meaning of red herrings, the colour must have - a special significance here, as the word *red* is emphasized." - INCREASE hint_level OF bbr. - ELSIF hint_level OF bbr = 3 - THEN - "(3/4) If you examine the objects, you'll notice that for most of them the colour - is described. Some are red, some are another colour." - INCREASE hint_level OF bbr. - ELSIF hint_level OF bbr = 4 - THEN - "(4/4) The objects described as being of a red colour (or a hue of red) will be unnecessary. - Place the three remaining objects on the scale. - $p(No more hints.)" - INCREASE hint_level OF bbr. - ELSE "(No more hints.)" - END IF. - ELSIF hero AT lr - THEN - IF hint_level OF lr = 0 - THEN "(1/12) The main goal here is to take the key from the kitchen table. It, however, - seems almost impossible because the action stops before you can take it." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 1 - THEN "(2/12) The solution to this puzzle makes use of a not fully stabilized but still a very common - method in playing IF: you don't always need to refer to an object by its name." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 2 - THEN "(3/12) Instead of the name, you can refer to an object by just using an attribute that - belongs to it. For example, to push a red button, you could just type ""push red"" - instead of ""push button""." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 3 - THEN "(4/12) You must find an object in the living-room that shares an attribute with the key." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 4 - THEN "(5/12) You can find that object in the fireplace." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 5 - THEN "(6/12) It's the ring." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 6 - THEN "(7/12) Note the material the ring and the key are both made of." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 7 - THEN "(8/12) Type ""TAKE SILVER"" to get hold of the key." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 8 - THEN "(9/12) Now we need to get out of here. The door has a bolt and a lock. - If you have solved the bedrooms upstairs successfully, you should know what to do." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 9 - THEN "(10/12) A bottle of oil helps for a rusty bolt. As for the lock, you know what it can be opened with." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 10 - THEN "(11/12) When you open the door, you'll notice that the boards are in your way. - Upstairs you" - IF handsaw IN hero THEN "found" - ELSE "should find" END IF. - "something that helps solve this problem." - INCREASE hint_level OF lr. - ELSIF hint_level OF lr = 11 - THEN "(12/12) It's the handsaw. - $p(No more hints.)" - - ELSE "(No more hints.)" - END IF. - ELSIF hero AT landing - THEN "(There are no hints for this location.)" - END IF. - END IF. -END VERB. - - -SYNONYMS - h, hints = hint. - - -ADD TO EVERY LOCATION - HAS hint_level 0. -END ADD TO. - - --- ============================================================== - - ------ INVENTORY (+ i, inv) - - --- ============================================================== - - - -ADD TO EVERY THING - IS weight 0. -END ADD TO THING. - - -ADD TO EVERY ACTOR - IS weight 50. -END ADD TO ACTOR. - - -ADD TO EVERY OBJECT - IS weight 5. -END ADD TO OBJECT. - - -SYNTAX i = i. - - -VERB i - DOES - LIST hero. - IF hero AT lr - THEN "$p$p(The Kitchen)$n" - LIST hero. - END IF. - - -- if the hero in your game carries any containers you want the contents of - -- to be listed after 'inventory', you should manually add the listing right here - -- according to the following example: - -- - -- IF bag IN hero - -- THEN LIST bag. - -- END IF. - -- - -- This way, 'inventory' will yield e.g. "You are carrying a bag. The bag contains a book." - -- If you leave the above addition out, the outcome will be just "You are carrying a bag.", with - -- no comment on what is inside the bag. - - IF COUNT IN worn > 0 -- See the file 'classes.i', subclass 'clothing'. - THEN LIST worn. -- This code will list what the hero is wearing. - END IF. - - -END VERB. - - -SYNONYMS inv, inventory = i. - - - --- ============================================================== - - ------ JUMP - - --- ============================================================== - - -SYNTAX jump = jump. - - -VERB jump - CHECK hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "You jump on the spot, to no avail." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou jump on the spot, to no avail." END IF. -END VERB. - - - --- ============================================================== - - ------ JUMP IN - - --- ============================================================== - - -SYNTAX jump_in = jump 'in' (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB jump_in - CHECK CURRENT LOCATION IS lit - ELSE "It's too dark to see." - AND cont IS reachable - ELSE SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - "That's not something you can jump into." - IF hero AT lr THEN "$p$p(The action stops.)" - END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ JUMP ON - - --- ============================================================== - - -SYNTAX jump_on = jump 'on' (surface) - WHERE surface ISA OBJECT - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB jump_on - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND surface IS reachable - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND hero IS NOT sitting - ELSE "It is difficult to jump while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to jump while lying down." - DOES - IF surface ISA SUPPORTER - THEN "That wouldn't accomplish anything." - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can jump onto." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ KICK - - --- ============================================================= - - -SYNTAX kick = kick (target) - WHERE target ISA THING - ELSE IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can kick." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB kick - CHECK target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can kick." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target <> hero - ELSE "It doesn't make sense to kick yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target NOT IN hero - ELSE "It doesn't make much sense to kick something you're holding." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target NOT IN worn - ELSE "It doesn't make sense to kick something you're wearing." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND target IS reachable - ELSE SAY THE target. - IF target IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES "Resorting to brute force is not the solution here." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL (+ murder) - - --- ============================================================== - - -SYNTAX kill = kill (victim) - WHERE victim ISA ACTOR - ELSE - IF victim IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY ACTOR - VERB kill - CHECK victim <> hero - ELSE "There's no need to be that desperate." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - END VERB. -END ADD TO. - - - --- ============================================================== - - --- KILL WITH - - --- ============================================================== - - -SYNTAX kill_with = kill (victim) 'with' (weapon) - WHERE victim ISA ACTOR - ELSE - IF victim IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND weapon ISA WEAPON - ELSE "You cannot kill anybody with" SAY THE weapon. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY ACTOR - VERB kill_with - WHEN victim - CHECK victim <> hero - ELSE "There's no need to be that desperate." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND weapon IN hero - ELSE "You don't have" SAY THE weapon. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "That would be needlessly brutal." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - --- ============================================================== - - ------ KISS (+ hug, embrace) - - --- ============================================================== - - -SYNTAX kiss = kiss (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can kiss." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB kiss - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can kiss." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> hero - ELSE "There is no time for that now." - IF hero AT lr THEN "$p$p(The Kitchen)$nThere is no time for that now." END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF obj ISA ACTOR - THEN SAY THE obj. "avoids your advances." - ELSE "Nothing would be achieved by that." - IF hero AT lr THEN "$p$p(The Kitchen)$nNothing would be achieved by that." END IF. - END IF. - END VERB. -END ADD TO. - - -SYNONYMS hug, embrace = kiss. - - - --- ============================================================== - - ------ KNOCK - - --- ============================================================== - - -SYNTAX knock = knock 'on' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can knock on." - - - knock = knock (obj). - - -ADD TO EVERY OBJECT - VERB knock - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can knock on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You knock on" SAY THE obj. "$$. Nothing happens." - END VERB. -END ADD TO. - - ---- another 'knock' formulation added to guide players to use the right phrasing: - - -SYNTAX knock_error = knock. - - -VERB knock_error - DOES - "Please use the formulation KNOCK ON SOMETHING to knock on something." -END VERB. - - - --- ============================================================== - - ------ LIE DOWN - - --- ============================================================== - - -SYNTAX lie_down = lie 'down'. - - lie_down = lie. - - -VERB lie_down - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down right now." - IF hero AT lr THEN "$p$p(The Kitchen)$nThere is no need to lie down right now." END IF. - -- If you need this to work, insert the following lines instead of the above: - -- DOES "You lie down." - -- MAKE hero lying_down. - -- MAKE hero NOT sitting_down. -END VERB. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE IN - - --- ============================================================== - - -SYNTAX lie_in = lie 'in' (cont) - WHERE cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lie in." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lie in." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - lie_in = lie 'down' 'in' (cont). - - -ADD TO EVERY OBJECT - VERB lie_in - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down in" SAY THE cont. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down in" SAY THE cont. "." - -- LOCATE hero IN cont. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIE ON - - --- ============================================================== - - -SYNTAX lie_on = lie 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lie on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - lie_on = lie 'down' 'on' (surface). - - -ADD TO EVERY OBJECT - VERB lie_on - CHECK hero IS NOT lying_down - ELSE "You're lying down already." - DOES - "There's no need to lie down on" SAY THE surface. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - -- If you need this to work, insert the following two lines instead of the above: - -- DOES "You lie down on" SAY THE surface. "." - -- LOCATE hero IN surface. - -- MAKE hero lying_down. - END VERB. -END ADD TO. - - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is lying down and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- lying down." --- Also, it is often essential to make certain objects NOT reachable when you are sitting --- or lying down. - - - --- ============================================================== - - ------ LIFT - - --- ============================================================== - - -SYNTAX lift = lift (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lift." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB lift - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lift." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS movable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lift." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> hero - ELSE "It doesn't make sense to lift yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN hero - ELSE "You're already holding" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "That wouldn't accomplish anything." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LIGHT (+ lit) - - --- ============================================================== - - -SYNTAX light = light (obj) - WHERE obj ISA LIGHTSOURCE - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB light - CHECK obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - -SYNONYMS lit = light. - - - --- ============================================================== - - ------ LISTEN - - --- ============================================================== - - -SYNTAX listen0 = listen. - - -VERB listen0 - DOES - "You hear nothing unusual." - IF hero AT lr THEN "$p$p(The Kitchen)You hear nothing unusual." END IF. -END VERB. - - - --- ============================================================== - - ------ LISTEN TO - - --- ============================================================== - - -SYNTAX listen = listen 'to' (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can listen to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB listen - CHECK obj <> hero - ELSE "It doesn't make sense to listen to yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF obj AT hero - THEN "You hear nothing unusual." - ELSIF obj NEAR hero - THEN "You can't hear" SAY THE obj. "very well from here." - ELSE "You can't hear anything." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou can't hear anything." END IF. - - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK - - --- ============================================================== - - -SYNTAX lock = lock (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lock." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB lock - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lock." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS NOT locked - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already locked." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You have to state what you want to lock" SAY THE obj. "with." - -- If you need this to work, use the following lines instead: - -- MAKE obj locked. "You" - -- IF obj IS NOT closed - -- THEN "close and" - -- MAKE obj closed. - -- END IF. - -- "lock" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOCK WITH - - --- ============================================================== - - -SYNTAX lock_with = lock (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lock." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr ISA OBJECT - ELSE "You can't lock anything with" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB lock_with - WHEN obj - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can lock." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS NOT locked - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already locked." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IN hero - ELSE - "You don't have" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You can't lock" SAY THE obj. "with" SAY THE instr. "." - -- If you need this to work, use the following lines instead: - -- MAKE obj locked. "You" - -- IF obj IS NOT closed - -- THEN "close and" - -- MAKE obj closed. - -- END IF. - -- "lock" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK - - --- ============================================================== - - -SYNTAX 'look' = 'look'. - - -VERB 'look' - DOES - LOOK. - INCREASE described OF CURRENT LOCATION. - -- see 'locations.i', attribute 'described'. -END VERB. - - -SYNONYMS l = 'look'. - - - --- ============================================================== - - ------ LOOK AT -> see EXAMINE - - --- ============================================================== - - - - - --- ============================================================== - - ------ LOOK BEHIND - - --- ============================================================== - - -SYNTAX look_behind = 'look' behind (bulk) - WHERE bulk ISA THING - ELSE "You can't look behind" SAY THE bulk. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB look_behind - CHECK bulk IS examinable - ELSE - "You can't look behind" SAY THE bulk. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND bulk <> hero - ELSE "Turning your head, you notice nothing unusual behind yourself." - DOES - "You notice nothing unusual behind" SAY THE bulk. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK IN - - --- ============================================================== - - -SYNTAX - look_in = 'look' 'in' (cont) - WHERE cont ISA OBJECT - ELSE "You can't look inside" SAY THE cont. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE "You can't look inside" SAY THE cont. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB look_in - CHECK cont IS examinable - ELSE - "You can't look inside" SAY THE cont. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont IS NOT closed - ELSE "You can't, since" SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - DOES - LIST cont. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK OUT OF - - --- ============================================================== - - -SYNTAX look_out_of = 'look' 'out' 'of' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look out of." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB look_out_of - CHECK obj IS examinable - ELSE - "You can't look out of" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look out of." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK THROUGH - - --- ============================================================== - - -SYNTAX look_through = 'look' through (bulk) - WHERE bulk ISA THING - ELSE - IF bulk IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look through." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB look_through - CHECK bulk IS examinable - ELSE "You can't look through" SAY THE bulk. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You can't see through" SAY THE bulk. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UNDER - - --- ============================================================== - - -SYNTAX look_under = 'look' under (bulk) - WHERE bulk ISA THING - ELSE IF bulk IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can look under." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB look_under - CHECK bulk IS examinable - ELSE "You can't look under" SAY THE bulk. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND bulk <> hero - ELSE "It doesn't make sense to look under yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You notice nothing unusual under" SAY THE bulk. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ LOOK UP (-> see also CONSULT) - - --- ============================================================== - - -SYNTAX look_up = 'look' up. - - -VERB look_up - DOES "Looking up, you see nothing unusual." - IF hero AT lr THEN "$p$p(The Kitchen)Looking up, you see nothing unusual." END IF. -END VERB. - - - --- ============================================================== - - ------ NO - - --- ============================================================== - - -SYNTAX 'no' = 'no'. - - -VERB 'no' - DOES "You sound rather negative." - IF hero AT lr THEN "$p$p(The Kitchen)You sound rather negative." END IF. -END VERB. - - - --- ============================================================== - - ------ NOTIFY - - --- ============================================================== - - --- Thanks to Steve Griffiths whose 'Score notification' sample was used --- in declaring this verb. - - - -SYNTAX notify = notify. - - notify_on = notify 'on'. -- The instructions tell the player that mere 'notify' - -- is enough, but these two verbs are implemented - notify_off = notify 'off'. -- in case (s)he adds the prepositions to the end anyway. - - -VERB notify - DOES - IF hero IS notify_on - THEN MAKE hero NOT notify_on. - "Score notification is now disabled. (You can turn it back on - using the NOTIFY command again.)" - ELSE MAKE hero notify_on. "Score notification is now enabled. - (You can turn it off using the NOTIFY command again.)" - END IF. -END VERB. - - -VERB notify_on - DOES - IF hero IS notify_on - THEN "Score notification is already enabled." - ELSE MAKE hero notify_on. - "Score notification is now enabled. - (You can turn it off using the NOTIFY command again.)" - END IF. -END VERB. - - -VERB notify_off - DOES - IF hero IS notify_on - THEN MAKE hero NOT notify_on. - "Score notification is now disabled. (You can turn it back on - using the NOTIFY command again.)" - ELSE "Score notification is already disabled." - END IF. -END VERB. - - --- The 'notify' verb allows the players to disable the score change --- messages. (Some players find such messages annoying.) --- The verb toggles the hero's 'notify_on' attribute on and off. That --- attribute is checked by the 'checkscore' event to determine whether --- to display the score msg or not. - - --- The following event is run each turn to check if the game score is greater than --- the last recorded score (which is stored in the Hero's 'oldscore' --- attribute). If the score is greater, then the 'Score has gone up...' --- text is displayed (as long as the player hasn't disabled it by using the --- 'notify' verb - which sets 'notify_on' to off --- - i.e. the hero 'IS NOT notify_on'.) - --- NOTE: The ALAN scoring system records the game score in a thing called --- score. It isn't called score OF anything; its just 'score'. - --- NOTE: This event assumes score can only increase, if score can go --- down then you would need to modify this code a bit. - - -EVENT check_score - IF oldscore OF hero < score - THEN - IF hero IS notify_on - THEN -- ie: the player wants to see score msgs - "$p(Your score has just gone up by" SAY (score - oldscore OF hero). - IF (score - oldscore OF hero) = 1 - THEN "point.)" - ELSE "points.)" - END IF. - -- this msg only displayed the first time player is notified - -- of a score change - IF hero IS NOT seen_notify - THEN MAKE hero seen_notify. - "$p(You can use the NOTIFY command to disable score change messages.)" - END IF. - END IF. - - SET oldscore OF hero TO score. - END IF. - -- run the 'check_score' event again next turn: - SCHEDULE check_score AT hero AFTER 1. -END EVENT. - - - - --- ============================================================== - - ------ OPEN - - --- ============================================================== - - -SYNTAX open = open (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can open." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB open - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can open." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS closed - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already open." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS NOT locked - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "appears" - ELSE "appear" - END IF. - "to be locked." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - MAKE obj NOT closed. - "You open" SAY THE obj. "." - END VERB. -END ADD TO. - - --- ============================================================== - - ------ OPEN WITH - - --- ============================================================== - - -SYNTAX open_with = open (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can open." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr ISA OBJECT - ELSE "You can't open anything with" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB open_with - WHEN obj - CHECK obj IS closeable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can open." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS closed - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "already open." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS NOT locked - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "appears" - ELSE "appear" - END IF. - "to be locked." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You can't open" SAY THE obj. "with" SAY THE instr. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY - - --- ============================================================== - - -SYNTAX 'play' = 'play' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can play." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB 'play' - DOES - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can play." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PLAY WITH - - --- ============================================================== - - -SYNTAX play_with = 'play' 'with' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can play with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB play_with - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "After second thoughts you don't find it purposeful to start - playing with" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ POUR, POUR IN, POUR ON - - --- ============================================================== - - - --- => SEE EMPTY, EMPTY IN, EMPTY ON - - - - --- ============================================================== - - ------ PRAY - - --- ============================================================== - - -SYNTAX pray = pray. - - -VERB pray - DOES "Your prayers don't seem to help right now." - IF hero AT lr THEN "$p$p(The Kitchen)Your prayers don't seem to help right now." END IF. -END VERB. - - - --- ============================================================== - - ------ PRY - - --- ============================================================== - - -SYNTAX pry = pry (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pry." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT -VERB pry - DOES "You must state what you want to pry" SAY THE obj. "with." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PRY_WITH - - --- ============================================================== - - -SYNTAX pry_with = pry (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pry." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr ISA OBJECT - ELSE "You can't pry anything with" - IF instr IS NOT plural - THEN "that" - ELSE "those" - END IF. - "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT -VERB pry_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pry." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> instr - ELSE "You can't pry something with itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IN hero - ELSE "You don't have" SAY THE instr. - - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES "That doesn't work." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PULL - - --- ============================================================== - - -SYNTAX pull = pull (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense to pull yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can pull." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END IF. - - - -ADD TO EVERY OBJECT -VERB pull - CHECK obj IS movable - ELSE "It's not possible to pull" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES "That wouldn't accomplish anything." -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUSH - - --- ============================================================== - - -SYNTAX push = push (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can push." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - push = press (obj). - -ADD TO EVERY THING - VERB PUSH - CHECK obj IS movable - ELSE - "That would be futile." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN hero - ELSE "But you're holding" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> hero - ELSE "It doesn't make sense to push yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You give" SAY THE obj. "a little push. Nothing happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUSH WITH - - --- ============================================================== - - -SYNTAX push_with = push (obj) 'with' (instr) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can push." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr ISA OBJECT - ELSE "You can use only objects to push things with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB push_with - WHEN obj - CHECK obj IS movable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can push." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> instr - ELSE "It doesn't make sense to push something with itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN hero - ELSE "But you're holding" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> hero - ELSE "It doesn't make sense to push yourself with something." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "Using" SAY THE instr. "you push" SAY THE obj. "$$. Nothing special happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT (+ lay, locate, place) - - --- ============================================================== - - -SYNTAX put = put (obj) - WHERE obj ISA OBJECT - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB put - CHECK obj IN HERO - ELSE "You don't have" SAY THE obj. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You must state where you want to put" - IF obj IS NOT plural - THEN "it." - ELSE "them." - END IF. - - END VERB. -END ADD TO. - - -SYNONYMS lay, place = put. - - - --- ============================================================== - - ------ PUT DOWN (works as 'drop') - - --- ============================================================== - - ------ The syntax for 'put down' has been declared in the 'drop' verb. - - - - --- ============================================================== - - ------ PUT IN (+ insert) - - --- ============================================================== - - -SYNTAX put_in = put (obj) 'in' (cont) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense to put yourself into something." - ELSE "You can only put objects somewhere." - -- If you need to allow e.g. 'put child in bed' - -- then you should remove this check. - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END IF. - AND cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can put things in." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE "You can't put anything there." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - put_in = insert (obj) 'in' (cont). - - -ADD TO EVERY OBJECT - VERB put_in - WHEN obj - CHECK obj <> cont - ELSE "It doesn't make sense to put something into itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN cont - ELSE - IF cont ISA SUPPORTER - THEN "You can't put" SAY THE obj. "inside" SAY THE cont. "." - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "in" SAY THE cont. "already." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont IS NOT closed - ELSE "You can't, since" SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont IS reachable - ELSE SAY THE cont. - - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - LOCATE obj IN cont. - "You put" SAY THE obj. "into" SAY THE cont. "." - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT AGAINST - - --- ============================================================== - - -SYNTAX put_against = put (obj) against (bulk) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "That doesn't make sense." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND bulk ISA THING - ELSE "You can't put anything against that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - put_against = lean (obj) against (bulk). - - -ADD TO EVERY OBJECT - VERB put_against - WHEN obj - CHECK bulk NOT IN hero - ELSE "That would achieve nothing." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> bulk - ELSE "That doesn't make sense." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND bulk <> hero - ELSE "That would be futile." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND bulk IS reachable - ELSE SAY THE bulk. - IF bulk IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "That wouldn't accomplish anything." - - -- To make it work, type e.g.: - -- IF obj NOT IN hero - -- THEN "(taking" SAY THE obj. "first)$n" - -- END IF. - -- "You put" SAY THE obj. "against" SAY THE bulk. "." - -- (+ you would probably need an attribute to check that the object is leaning against the bulk) - END VERB. -END ADD TO. - - --- ============================================================== - - ------ PUT BEHIND, NEAR, UNDER - - --- ============================================================== - - -SYNTAX put_near = put (obj) 'near' (bulk) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "That doesn't make sense." - ELSE SAY THE obj. "wouldn't probably appreciate that." - END IF. - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND bulk ISA THING - ELSE "You can't put anything near that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - put_behind = put (obj) behind (bulk) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN SAY THE obj. "wouldn't probably appreciate that." - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND bulk ISA THING - ELSE "You can't put anything behind that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - put_under = put (obj) under (bulk) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN SAY THE obj. "wouldn't probably appreciate that." - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND bulk ISA THING - ELSE "You can't put anything under" - IF obj IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB put_near, put_behind, put_under - WHEN obj - CHECK bulk NOT IN hero - ELSE "That would be futile." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> bulk - ELSE "That doesn't make sense." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND bulk <> hero - ELSE "That would be futile." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND bulk IS reachable - ELSE SAY THE bulk. - IF bulk IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "That wouldn't accomplish anything." - - -- To make it work, type e.g.: - -- IF obj NOT IN hero - -- THEN "(taking" SAY THE obj. "first)$n" - -- END IF. - -- "You put" SAY THE obj. "near" --(or behind or under) SAY THE bulk. "." - -- (+ you would need to define some attributes to check that - -- the object is behind another object, etc.) - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT_ON - - --- ============================================================== - - --- To use this verb in the meaning 'wear', see the file 'classes.i', --- class 'clothing', verb 'wear'. - --- You can put things on the floor/ground or on a supporter. In other --- cases, the response will be "That wouldn't accomplish anything." - - - -SYNTAX put_on = put (obj) 'on' (surface) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "That would be futile." - ELSE SAY THE obj. "wouldn't probably - appreciate that." - END IF. - ELSE "You can't put" - IF obj IS NOT plural - THEN "that" - ELSE "those" - END IF. - "anywhere." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND surface ISA OBJECT - ELSE "You can't well put anything on top of " - IF surface IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND surface ISA CONTAINER - ELSE "You can't well put anything on top of" - IF surface IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - -ADD TO EVERY OBJECT - VERB put_on - WHEN obj - CHECK surface NOT IN hero - ELSE "That would be futile." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> surface - ELSE "That doesn't make sense." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN surface - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "on" SAY THE surface. "already." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND surface IS reachable - ELSE SAY THE surface. - IF surface IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - -- implicit taking: - IF obj NOT DIRECTLY IN hero - THEN "(taking" SAY THE obj. "first)$n" - LOCATE obj IN hero. - END IF. - -- end of implicit taking. - - IF surface = scale - THEN LOCATE obj IN surface. - "You put" SAY THE obj. "onto" SAY THE surface. "." - ELSIF surface = floor OR surface = ground - THEN LOCATE obj AT hero. - "You put" SAY THE obj. "on" SAY THE surface. "." - ELSIF surface ISA SUPPORTER - THEN LOCATE obj IN surface. - "You put" SAY THE obj. "on" SAY THE surface. "." - ELSE "That wouldn't accomplish anything." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ PUT OUT (works as -> EXTINGUISH) - - --- ============================================================== - - ------ The syntax for 'put out' has been declared in the 'extinguish' verb. - - - --- ============================================================== - - ------ QUIT - - --- ============================================================== - - -SYNTAX - 'quit' = 'quit'. - - -VERB 'quit' - DOES - QUIT. -END VERB. - - -SYNONYMS q = 'quit'. - - - --- ============================================================== - - ------ READ - - --- ============================================================== - - -SYNTAX read = read (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can read." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB read - CHECK obj IS readable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can read." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF text OF obj = "" - THEN "There's nothing written on" SAY THE obj. "." - ELSE "You read" SAY THE obj. "." - IF obj IS NOT plural - THEN "It says" - ELSE "They say" - END IF. - """$$" SAY text OF obj. "$$""." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - --- REMOVE - - --- ============================================================== - - --- see the file 'classes.i', class 'clothing' for the definition of --- this verb - - - - - --- ============================================================== - - ------ REMOVE FROM ( => TAKE FROM) - - --- ============================================================== - - ------ this verb works as 'take from' - - - --- ============================================================== - - ------ RESTART - - --- ============================================================== - - -SYNTAX 'restart' = 'restart'. - - -VERB 'restart' - DOES - RESTART. -END VERB. - - - --- ============================================================== - - ------ RESTORE - - --- ============================================================== - - -SYNTAX 'restore' = 'restore'. - - -VERB 'restore' - DOES - RESTORE. -END VERB. - - - --- ============================================================== - - ------ RUB (+ massage) - - --- ============================================================== - - -SYNTAX rub = rub (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can rub." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB rub - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can rub." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> hero - ELSE "There's no time for that now." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS inanimate - ELSE "You aren't sure whether" SAY THE obj. - "would appreciate that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "Nothing would be achieved by that." - IF hero AT lr - THEN IF obj IN hero - THEN "$p$p(The Kitchen)$nNothing would be achieved by that." - ELSE "$p$p(The action stops.)" - END IF. - END IF. - END VERB. -END ADD TO. - - -SYNONYMS massage = rub. - - - --- ============================================================== - - ------ SAVE - - --- ============================================================== - - -SYNTAX 'save' = 'save'. - - -VERB 'save' - DOES - SAVE. -END VERB. - - - --- ============================================================== - - ------ SAY - - --- ============================================================== - - -SYNTAX 'say' = 'say' (topic)! - WHERE topic ISA THING - ELSE "That's not something you can say." - - -ADD TO EVERY THING - VERB 'say' - DOES - "You utter """ SAY topic. "$$"". Nothing happens." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou utter """ SAY topic. "$$"". Nothing happens." END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SAY TO - - --- ============================================================== - - -SYNTAX say_to = 'say' (topic) 'to' (act) - WHERE topic ISA STRING - ELSE "Nothing happens." - AND act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY ACTOR - VERB say_to - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND act IS reachable - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - SAY THE act. - IF act IS NOT plural - THEN "doesn't look" - ELSE "don't look" - END IF. - "interested." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SCORE - - --- ============================================================== - - -SYNTAX 'score' = 'score'. - - -VERB 'score' - DOES - "There is no score in this game." -END VERB 'score'. - - - --- ============================================================== - - ------ SCRATCH - - --- ============================================================== - - -SYNTAX scratch = scratch (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can scratch." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB scratch - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can scratch." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS inanimate - ELSE SAY THE obj. "wouldn't probably appreciate that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> hero - ELSE "That wouldn't help matters." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "Nothing would be achieved by that." - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------- SCRIPT - - --- ============================================================== - - - -SYNTAX 'script' = 'script'. - script_on = 'script' 'on'. - script_off = 'script' 'off'. - -SYNONYMS 'transcript' = 'script'. - - -VERB 'script' - DOES - "You can turn transcripting on and off using the 'script on/off' command within the game. - The transcript will be available in a file with a name starting with the game name. - $pIn a GUI version you can also find this in the drop-down menu in the interpreter. - $pIn a command line version you can start your game with the '-s' switch to get a transcript of the whole game." -END VERB. - - -VERB script_on - DOES - TRANSCRIPT ON. - "Transcripting turned on." -END VERB. - - -VERB script_off - DOES - TRANSCRIPT OFF. - "Transcripting turned off." -END VERB. - - - - --- ============================================================== - - ------- SEARCH - - --- ============================================================== - - -SYNTAX search = search (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can search." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB search - CHECK obj <> hero - ELSE LIST hero. - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You find nothing of interest." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou can't see any such thing." END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SELL - - --- ============================================================== - - -SYNTAX sell = sell (item) - WHERE item ISA OBJECT - ELSE - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can sell." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB sell - CHECK item IS examinable - ELSE - IF item IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can sell." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "There's nobody here who would be interested in buying" SAY THE item. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHAKE - - --- ============================================================== - - -SYNTAX shake = shake (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "It doesn't make sense - to shake yourself." - ELSE SAY THE obj. "wouldn't probably - appreciate that." - END IF. - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shake." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT -VERB shake - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shake." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS movable - ELSE "Shaking" SAY THE obj. "is not possible." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF obj IN hero - THEN "You shake" SAY THE obj. "cautiously in your hands. Nothing happens." - ELSE "There is no reason to start shaking" SAY THE obj. "." - END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOOT - - --- ============================================================== - - - -SYNTAX shoot = shoot (target) - WHERE target ISA THING - ELSE "That's not something you can shoot." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - shoot = shoot 'at' (target). - - -ADD TO EVERY THING - VERB shoot - CHECK target <> hero - ELSE "There's no need to be that desperate." - AND COUNT ISA WEAPON, IS fireable, IN hero > 0 - ELSE "You don't have anything to shoot with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the solution here." - END VERB. -END ADD TO. - - --- another 'shoot' formulation added, to guide players to use the right phrasing: - - -SYNTAX shoot_error = shoot. - - -VERB shoot_error - DOES "You must state what you want to shoot, e.g. SHOOT BEAR WITH RIFLE." -END VERB. - - - --- ============================================================== - - ------ SHOOT WITH - - --- ============================================================== - - -SYNTAX shoot_with = shoot (target) 'with' (weapon) - WHERE target ISA THING - ELSE "That's not something you can shoot." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND weapon ISA WEAPON - ELSE - IF weapon IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shoot with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - shoot_with = shoot (weapon) 'at' (target). - -- to allow player input such as 'shoot rifle at bear' - - -ADD TO EVERY THING - VERB shoot_with - WHEN target - CHECK weapon IN hero - ELSE "You don't have" SAY THE weapon. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can shoot." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target <> hero - ELSE "There's no need to be that desperate." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target <> weapon - ELSE "It doesn't make sense to shoot something with itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "Resorting to violence is not the solution here." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SHOUT - - --- ============================================================== - - -SYNTAX shout = shout. - - -VERB shout - DOES - "Nothing results from your $ving." - IF hero AT lr THEN "$p$p(The Kitchen)$nNothing results from your shouting." END IF. -END VERB. - - -SYNONYMS scream, yell = shout. - - - --- ============================================================== - - ------ SHOW - - --- ============================================================== - - -SYNTAX 'show' = 'show' (obj) 'to' (act) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can show." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can show things to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB 'show' - WHEN obj - CHECK obj IN hero - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND act <> hero - ELSE "It doesn't make sense to show something to yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> act - ELSE "It doesn't make sense to show something to itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "not especially interested." - END VERB. -END ADD TO. - - -SYNONYMS reveal = 'show'. - - - --- ============================================================== - - ------ SING (+ hum, whistle) - - --- ============================================================== - - -SYNTAX sing = sing. - - -VERB sing - DOES - "You $v a little tune." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou $v a little tune." END IF. -END VERB. - - -SYNONYMS hum, whistle = sing. - - - --- ============================================================== - - ------ SIP - - --- ============================================================== - - -SYNTAX sip = sip (liq) - WHERE liq ISA LIQUID - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drink." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY LIQUID - VERB sip - CHECK liq IS drinkable - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can drink." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND liq IS reachable - ELSE SAY THE liq. - IF liq IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF vessel OF liq = no_vessel -- here, if the liquid is in no container, e.g. - -- the hero takes a sip of water from a river, - -- the action is allowed to succeed. - THEN "You take a sip of" SAY THE liq. "." - ELSE - -- implicit taking: - IF vessel OF liq NOT DIRECTLY IN hero - THEN - IF vessel OF liq IS NOT takeable - THEN "It's not worth the bother trying to take a sip of" SAY THE liq. "." - ELSE LOCATE vessel OF liq IN hero. - "(taking" SAY THE vessel OF liq. "first)$n" - END IF. - END IF. - -- end of implicit taking. - END IF. - - IF liq IN hero -- i.e. if the implicit taking was successful - THEN "You take a sip of" SAY THE liq. "." - END IF. - - END VERB. -END ADD TO. - - --- See also the verb 'drink'. - - --- ============================================================== - - ------ SIT - - --- ============================================================== - - -SYNTAX sit = sit. - - - sit = sit 'down'. - - -VERB sit - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - DOES - "You feel no urge to sit down at present." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou feel no urge to sit down at present." END IF. - -- (or, if you wish to make it work, use the following instead of the above: - -- IF hero IS lying_down - -- THEN "You sit up." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down." - -- END IF. - -- MAKE hero sitting. -END VERB. - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SIT_ON - - --- ============================================================== - - -SYNTAX sit_on = sit 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can sit on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY SUPPORTER - VERB sit_on - CHECK hero IS NOT sitting - ELSE "You're sitting down already." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You feel no urge to sit down at present." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou can't see any such thing." END IF. - -- (or, to make it work, use the following instead of the above:) - -- IF hero lying_down - -- THEN "You get up and sit down on" SAY THE surface. "." - -- MAKE hero NOT lying_down. - -- ELSE "You sit down on" SAY THE surface. "." - -- END IF. - -- LOCATE hero IN surface. - -- MAKE hero sitting. - END VERB. -END ADD TO. - - --- When the hero is sitting or lying down, it will be impossible for her/him to --- perform certain actions, as numerous verbs in the library have checks for this. --- For example, if the hero is sitting and the player types 'attack [something]', --- the response will be "It will be difficult to attack anything while --- sitting down." --- Also, it is often essential to make certain objects NOT reachable when --- sitting or lying down. - - - --- ============================================================== - - ------ SLEEP (+ rest) - - --- ============================================================== - - -SYNTAX sleep = sleep. - - -VERB sleep - DOES - "There's no need to $v right now." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou feel no need to $v right now." END IF. -END VERB. - - -SYNONYMS rest = sleep. - - - --- ============================================================== - - ------ SMELL (smell0) - - --- ============================================================== - - -SYNTAX smell0 = smell. - - -VERB smell0 - DOES - "You smell nothing unusual." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou smell nothing unusual." END IF. -END VERB. - - - --- ============================================================== - - ------ SMELL (+ obj) - - --- ============================================================== - - -SYNTAX smell = smell (odour)! - WHERE odour ISA THING - ELSE - IF odour IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can smell." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB smell - DOES - "You smell nothing unusual." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou smell nothing unusual." END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SQUEEZE - - --- ============================================================== - - -SYNTAX squeeze = squeeze (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can squeeze." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB squeeze - CHECK obj IS examinable - ELSE IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can squeeze." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE - IF obj = hero - THEN "Nothing would be achieved by that." - -- you can squeeze yourself in the dark, as well - ELSE "It is too dark to see." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF obj ISA ACTOR - THEN "That wouldn't be polite." - ELSE IF obj = bottle - THEN "A drop of oil comes out of the bottle and drops onto the floor. (If you want to oil something, - just OIL [OBJECT]." - IF hero AT lr THEN - "A drop of oil comes out of the bottle and drops onto the floor. (If you want to oil something, - just OIL [OBJECT]." - END IF. - ELSE "Trying to squeeze" SAY THE obj. "wouldn't be sensible." - END IF. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ STAND - - --- ============================================================== - - -SYNTAX stand = stand. - - - stand = stand 'up'. - - -VERB stand - CHECK hero IS NOT lying_down - ELSE "You get up." - MAKE hero NOT lying_down. - AND hero IS NOT sitting - ELSE "You stand up." - MAKE hero NOT sitting. - DOES - "You're standing up already." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. -END VERB. - - - --- ============================================================== - - ------ STAND_ON - - --- ============================================================== - - -SYNTAX stand_on = stand 'on' (surface) - WHERE surface ISA SUPPORTER - ELSE - IF surface IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can stand on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - stand_on = get 'on' (surface). - - -ADD TO EVERY SUPPORTER -VERB stand_on - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "You feel no urge to stand on" SAY THE surface. "." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou can't see any such thing." END IF. - -- or, to make it work, use the following instead of the above: - -- "You get on" SAY THE surface. "." - -- LOCATE hero IN surface. - -- MAKE hero NOT sitting. MAKE hero NOT lying_down. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWIM - - --- ============================================================== - - -SYNTAX swim = swim. - - -VERB swim - CHECK hero IS NOT sitting - ELSE "It is difficult to try swimming while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to try swimming while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - "There is no water suitable for swimming here." - IF hero AT lr THEN "$p$p(The Kitchen)$nThere is no water suitable for swimming here." END IF. -END VERB. - - - --- ============================================================== - - ------ SWIM IN - - --- ============================================================== - - -SYNTAX swim_in = swim 'in' (liq) - WHERE liq ISA LIQUID - ELSE - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can swim in." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - -ADD TO EVERY OBJECT -VERB swim_in - CHECK hero IS NOT sitting - ELSE "It is difficult to swim anywhere while sitting down." - AND hero IS NOT lying_down - ELSE "It is difficult to swim anywhere while lying down." - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - DOES - IF liq IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can swim in." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. -END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH - - --- ============================================================== - - --- This is a mere 'switch' verb with no 'on' or 'off' following after it. --- This verb is defined further in 'classes.i', under 'device' and 'lightsource'. --- This verb exists just to cover cases where the player forgets to write --- 'on' or 'off' after 'switch'. --- If the player types 'switch tv', the tv object will be switched on --- if it is off, and vice cersa. --- Below, just the basic syntax is declared. - - - -SYNTAX switch = switch (app) -- = apparatus, appliance - WHERE app ISA THING - ELSE "That's not something you can switch." - - -ADD TO EVERY THING - VERB switch - DOES - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "not something you can switch." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ SWITCH ON - - --- ============================================================== - - ------ The syntax for 'switch on' has been declared in the 'turn_on' verb. - - - - --- ============================================================== - - ------ SWITCH OFF - - --- ============================================================== - - ------ The syntax for 'switch off' has been declared in the 'turn_off' verb. - - - - --- ============================================================== - - ------ TAKE (+ carry, get, grab, hold, obtain, pick up) - - --- ============================================================== - - -SYNTAX take = take (obj) - WHERE obj ISA OBJECT - ELSE - IF obj ISA ACTOR - THEN - IF obj = hero - THEN "Taking yourself is not possible." - ELSE SAY THE obj. "would probably object to that." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - ELSE - IF obj IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - "not something you can take." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END IF. - - - take = get (obj). - - - take = pick up (obj). - - - take = pick (obj) up. - - -ADD TO EVERY OBJECT - VERB take - CHECK CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS takeable - ELSE - IF obj ISA SCENERY - THEN "Unimportant for your purposes, you leave" SAY THE obj. "where" - IF obj IS plural - THEN "it is." - ELSE "they are." - END IF. - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can take." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS movable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "much too heavy for you to move." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS inanimate - ELSE SAY THE obj. "would probably object to that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND weight Of obj <=50 - ELSE SAY THE obj. "is too heavy to lift." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN hero - -- i.e. the object to be taken is carried by the hero already - ELSE "You already have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN worn - -- i.e. the object to be taken is a piece of clothing that the player character is wearing; - -- here, this verb works in practise like 'take off'. - ELSE "You take off" SAY THE obj. "and carry" - IF obj IS NOT plural - THEN "it" - ELSE "them" - END IF. - "in your hands." - LOCATE obj IN hero. - DOES - - "Taken." - -- this covers also cases where the object to be taken is in another container, - -- such as a wallet that is in a jacket the hero is carrying or wearing. - LOCATE obj IN hero. - - END VERB. -END ADD TO. - - -SYNONYMS - carry, grab, hold, obtain = take. - - - --- ============================================================== - - ------ TAKE FROM - - --- ============================================================== - - -SYNTAX take_from = 'take' (obj) 'from' (holder) - WHERE obj ISA OBJECT - ELSE "You can only take objects." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND holder ISA THING - ELSE "It's not possible to take things from there." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND holder ISA CONTAINER - ELSE "It's not possible to take things from there." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - take_from = remove (obj)* 'from' (holder). - - - take_from = get (obj) 'from' (holder). - - -ADD TO EVERY OBJECT - VERB take_from - WHEN obj - CHECK holder <> hero - ELSE "You can't take things from yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj NOT IN hero - ELSE "You already have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> holder - ELSE "You can't take something from itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IN holder - ELSE - IF obj ISA CLOTHING -- A piece of clothing worn by an NPC is not *in* the NPC but in a special - -- npc_worn container (see 'classes.i', class 'actor'). We need to take the class 'clothing' separately - -- into account here. - THEN -- Here, we allow the piece of clothing to be taken if it is takeable, skipping the remaining checks below. - FOR EACH nw ISA NPC_WORN DO - IF carrier OF nw <> no_carrier - THEN - IF obj IS takeable - THEN LOCATE obj IN hero. - "You take" SAY THE obj. "from" SAY THE holder. "." - ELSE - IF THIS IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - "not something you can take." - END IF. - END IF. - END FOR. - ELSIF holder IS inanimate - THEN SAY THE obj. - IF obj IS NOT plural - THEN "is not" - ELSE "are not" - END IF. - IF holder ISA SUPPORTER - THEN "on" - ELSE "in" - END IF. - SAY THE holder. "." - ELSE SAY THE holder. - IF holder IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "have" SAY THE obj. "." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND holder IS NOT closed - ELSE "You can't, since" SAY THE holder. - IF holder IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS movable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "much too heavy for you to take." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE - IF obj ISA SCENERY - THEN "Unimportant for your purposes, you leave" - SAY THE obj. "where" - IF obj IS NOT plural - THEN "it is." - ELSE "they are." - END IF. - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can take." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND weight Of obj <=50 - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too heavy." - DOES - LOCATE obj IN hero. - "You take" SAY THE obj. "from" SAY THE holder. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TALK - - --- ============================================================== - - -SYNTAX talk = talk. - - -VERB talk - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING - or TELL PERSON ABOUT THING." -END VERB. - - - --- ============================================================== - - ------ TALK_TO - - - --- ============================================================== - - -SYNTAX talk_to = talk 'to' (act) - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY ACTOR - VERB talk_to - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - -SYNTAX talk_to_a = talk 'to' (act) about (topic)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND topic ISA THING - ELSE "That's not something you can talk about." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY ACTOR - VERB talk_to_a - WHEN act - DOES - "To talk to somebody, you can ASK PERSON ABOUT THING or - TELL PERSON ABOUT THING." - END VERB. -END ADD TO. - - --- ============================================================== - - ------ TASTE (+ lick) - - --- ============================================================== - - -SYNTAX taste = taste (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can taste." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB taste - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can taste." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES "That's not something you should taste." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TEAR (+ rip) - - --- ============================================================== - - -SYNTAX tear = tear (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tear." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB tear - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tear." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "That would be futile." - IF obj IN hero - THEN IF hero AT lr - THEN "$p$p(The Kitchen)$nThat would be futile." - END IF. - END IF. - END VERB. -END ADD TO. - - -SYNONYMS rip = tear. - - - --- ============================================================== - - ------ TELL (+ enlighten, inform) - - --- ============================================================== - - -SYNTAX tell = tell (act) about (topic)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND topic ISA THING - ELSE - IF topic IS NOT plural - THEN "That doesn't" - ELSE "Those don't" - END IF. - "seem to be something you can talk - about with" SAY THE act. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY ACTOR - VERB tell - WHEN act - CHECK act CAN talk - ELSE - IF act IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can talk to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND act IS reachable - ELSE SAY THE act. - IF act IS NOT plural - THEN "is" - ELSE "are" - END IF. - "too far away." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND act <> hero - ELSE "It doesn't make much sense to tell yourself about something." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF topic IN act - THEN SAY THE act. - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "seem to want to talk about" SAY THE topic. "." - ELSIF topic = act - THEN SAY THE act. - IF act IS NOT plural - THEN "chooses" - ELSE "choose" - END IF. - "to be silent." - ELSIF topic = hero - THEN SAY THE act. - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "look interested." - ELSE SAY THE act. - IF act IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "look interested." - END IF. - END VERB. -END ADD TO. - - -SYNONYMS enlighten, inform = tell. - - - --- ============================================================== - - ------ THINK (+ ponder, meditate, reflect) - - --- ============================================================== - - -SYNTAX think = think. - - -VERB think - DOES - "Nothing helpful comes to your mind." - IF hero AT lr THEN "$p$p(The Kitchen)$nNothing helpful comes to your mind." END IF. -END VERB. - - -SYNONYMS ponder, meditate, reflect = think. - - - --- ============================================================== - - ------ THINK ABOUT - - --- ============================================================== - - -SYNTAX think_about = think 'about' (topic)! - WHERE topic ISA THING - ELSE - IF topic IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something fruitful to think about." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB think_about - DOES - "Nothing helpful comes to your mind." - IF hero AT lr THEN "$p$p(The Kitchen)$nNothing helpful comes to your mind." END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW - - --- ============================================================== - - -SYNTAX throw = throw (projectile) - WHERE projectile ISA OBJECT - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB throw - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile IS takeable - ELSE "You don't have" SAY THE projectile. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile IS reachable - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You don't find it purposeful to start throwing things around." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ THROW AT - - --- ============================================================== - - -SYNTAX throw_at = throw (projectile) 'at' (target) - WHERE projectile ISA OBJECT - ELSE "You can only throw objects." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target ISA THING - ELSE "It's not possible to throw things at" - IF target IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - -ADD TO EVERY OBJECT - VERB throw_at - WHEN projectile - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile IS takeable - ELSE "You don't have" SAY THE projectile. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things at." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile <> target - ELSE "It doesn't make sense to throw something at itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target NOT IN hero - ELSE "You are carrying" SAY THE target. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target <> hero - ELSE "You cannot throw things at yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND projectile IS reachable - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You don't find it purposeful to start throwing things around." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ THROW TO - - --- ============================================================== - - -SYNTAX throw_to = throw (projectile) 'to' (recipient) - WHERE projectile ISA OBJECT - ELSE "You can only throw objects." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND recipient ISA THING - ELSE "It's not possible to throw things to" - IF recipient IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND recipient ISA CONTAINER - ELSE "It is not possible to throw things to" - IF recipient IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - -ADD TO EVERY OBJECT - VERB throw_to - WHEN projectile - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile IS takeable - ELSE "You don't have" SAY THE projectile. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND recipient IS examinable - ELSE - IF recipient IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things at." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile <> recipient - ELSE "It doesn't make sense to throw something at itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND recipient NOT IN hero - ELSE "You are carrying" SAY THE recipient. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND recipient <> hero - ELSE "You cannot throw things at yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile IS reachable - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND recipient IS reachable - ELSE SAY THE recipient. - IF recipient IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You don't find it purposeful to start throwing things around." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------- THROW IN - - --- ============================================================== - - -SYNTAX throw_in = throw (projectile) 'in' (cont) - WHERE projectile ISA OBJECT - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA OBJECT - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont ISA CONTAINER - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB throw_in - WHEN projectile - CHECK projectile IS examinable - ELSE - IF projectile IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile IS takeable - ELSE "You don't have" SAY THE projectile. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont IS examinable - ELSE - IF cont IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can throw things into." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile <> cont - ELSE "It doesn't make sense to throw something into itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont <> hero - ELSE "You can't throw" SAY THE projectile. "into yourself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND projectile NOT IN cont - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "in" SAY THE cont. "already." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND projectile IS reachable - ELSE SAY THE projectile. - IF projectile IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont IS reachable - ELSE SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND cont IS NOT closed - ELSE "You can't, since" SAY THE cont. - IF cont IS NOT plural - THEN "is" - ELSE "are" - END IF. - "closed." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You don't find it purposeful to start throwing things into" SAY THE cont. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE - - --- ============================================================== - - -SYNTAX tie = tie (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tie." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB tie - DOES - - "You must state where do you want to tie" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TIE TO - - --- ============================================================== - - -SYNTAX tie_to = tie (obj) 'to' (target) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tie." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target ISA OBJECT - ELSE "Nothing can be tied to" - IF target IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB tie_to - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tie." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target IS examinable - ELSE - IF target IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can tie things to." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS takeable - ELSE "You don't have" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> target - ELSE "It doesn't make sense to tie something to itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND target IS reachable - ELSE SAY THE target. - IF target IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - - "It's not possible to tie" SAY THE obj. "to" SAY THE target. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TOUCH - - --- ============================================================== - - -SYNTAX touch = touch (obj) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB touch - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> hero - ELSE "That wouldn't accomplish anything." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS inanimate - ELSE "You are not sure whether" SAY THE obj. "would appreciate that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You feel nothing unexpected." - END VERB. -END ADD TO. - - -SYNONYMS feel = touch. - - - --- ============================================================== - - ------ TOUCH WITH - - --- ============================================================== - - -SYNTAX touch_with = touch (obj) 'with' (instr) - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr ISA OBJECT - ELSE "You can only use objects to touch with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY THING - VERB touch_with - WHEN obj - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IS examinable - ELSE - IF instr IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can touch things with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> instr - ELSE "You can't touch something with itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr <> hero - ELSE "That doesn't make sense." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr IN hero - ELSE "You don't have" SAY THE instr. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS inanimate - ELSE "You are not sure whether" SAY THE obj. "would appreciate that." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - DOES - "You touch" SAY THE obj. "with" SAY THE instr. ". Nothing special happens." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN (+ rotate) - - --- ============================================================== - - -SYNTAX turn = turn (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can turn." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - turn = rotate (obj). -- we don't declare 'rotate' a synonym for 'turn' - -- through a SYNONYMS statement as we don't want - -- it to be possible for the player to type something - -- like 'rotate tv on' (see 'turn on' and 'turn off' below) - - -ADD TO EVERY OBJECT - VERB turn - CHECK obj IS examinable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can turn." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS movable - ELSE "It's not possible to turn" SAY THE obj. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES "You turn" SAY THE obj. - IF obj IN hero - THEN "in your hands" - END IF. - "$$. You notice nothing unusual about" - IF obj IS NOT plural - THEN "it" - ELSE "them" - END IF. - IF obj NOT IN hero - THEN "and return" - IF obj IS NOT plural - THEN "it" - ELSE "them" - END IF. - "to" - IF obj IS NOT plural - THEN "its" - ELSE "their" - END IF. - "original position" - END IF. - "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN ON - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These classes are ------ defined in 'classes.i' with proper checks for 'on' and 'NOT on', 'lit' and 'NOT lit'. ------ Trying to turn on or off an ordinary object will default here to "That's not ------ something you can turn on". - - -SYNTAX turn_on = turn 'on' (app) - WHERE app ISA OBJECT - ELSE - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - turn_on = switch 'on' (app). - - - turn_on = turn (app) 'on'. - - - turn_on = switch (app) 'on'. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', classes 'device' and 'lightsource'. --- This verb merely covers cases where the player forgets (or doesn't bother) to type 'on' or 'off'. - - - -ADD TO EVERY OBJECT - VERB turn_on - DOES - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v on." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ TURN OFF - - --- ============================================================== - - ------ Only devices and lightsources can be turned on and off. These classes ------ are defined in 'classes.i' with proper checks for 'on' and 'NOT on', ------ 'lit' and 'NOT lit'. - - -SYNTAX turn_off = turn off (app) - WHERE app ISA OBJECT - ELSE - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v off." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - turn_off = switch off (app). - - - turn_off = turn (app) off. - - - turn_off = switch (app) off. - - - --- Note that 'switch' is not declared a synonym for 'turn'. --- This is because 'turn' has also other meanings, e.g. 'turn page' which is --- not equal with 'switch page'. --- A separate 'switch' verb is declared in 'classes.i', classes 'device' and 'lightsource'. --- This verb merely covers cases where the player forgets to type 'on' or 'off'. - - -ADD TO EVERY OBJECT - VERB turn_off - DOES - IF app IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can $v off." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ UNDRESS - - --- ============================================================== - - --- See the file 'classes.i', class CLOTHING for the definition --- of this verb. - - - --- ============================================================== - - ------ UNLOCK - - --- ============================================================== - - -SYNTAX unlock = unlock (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can unlock." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB unlock - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can unlock." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS locked - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already unlocked." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You must state what you want to unlock" SAY THE obj. "with." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================= - - ------ UNLOCK WITH - - --- ============================================================= - - -SYNTAX unlock_with = unlock (obj) 'with' (key) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can unlock." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND key ISA OBJECT - ELSE "You can't unlock anything with" - IF key IS NOT plural - THEN "that." - ELSE "those." - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB unlock_with - WHEN obj - CHECK obj IS lockable - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can unlock." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND key In hero - ELSE "You don't have" SAY THE key. "." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj <> key - ELSE "It doesn't make sense to unlock something with itself." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS locked - ELSE - IF obj IS NOT plural - THEN "It is" - ELSE "They are" - END IF. - "already unlocked." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - SAY THE key. - IF key IS NOT plural - THEN "doesn't" - ELSE "don't" - END IF. - "unlock" SAY THE obj. "." - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE - - --- ============================================================== - - -SYNTAX 'use' = 'use' (obj) - WHERE obj ISA OBJECT - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something you can use." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB 'use' - DOES - "Please be more specific. How do you intend to use" - IF obj IS NOT plural - THEN "it?" - ELSE "them?" - END IF. - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ USE WITH - - --- ============================================================== - - -SYNTAX use_with = 'use' (obj) 'with' (instr) - WHERE obj ISA OBJECT - ELSE "You can only use objects." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND instr ISA OBJECT - ELSE "You can only use objects." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - -ADD TO EVERY OBJECT - VERB use_with - WHEN obj - CHECK obj <> instr - ELSE "You can't use something with itself." - DOES - "Please be more specific. How do you intend to use them together?" - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - END VERB. -END ADD TO. - - - - --- ============================================================== - - ------ VERBOSE (see also -> BRIEF) - - --- ============================================================== - - -SYNTAX verbose = verbose. - - -VERB verbose - DOES - VISITS 0. - "Verbose mode is now on. Location descriptions will be - always shown in full." -END VERB. - - - --- ============================================================== - - ------ WAIT (= z) - - --- ============================================================== - - -SYNTAX 'wait' = 'wait'. - - -VERB 'wait' - DOES - "Time passes..." -END VERB. - - -SYNONYMS - z = 'wait'. - - - --- ============================================================== - - ------ WEAR - - --- ============================================================== - - --- See the file 'classes.i', class CLOTHING for the definition --- of this verb. - - - --- ============================================================== - - ------ WHAT AM I - - --- ============================================================== - - -SYNTAX what_am_i = 'what' am i. - - -VERB what_am_i - DOES - "Maybe examining yourself might help." - IF hero AT lr THEN "$p$p(The Kitchen)$nMaybe examining yourself might help." END IF. -END VERB. - - - --- ============================================================== - - ------ WHAT IS - - --- ============================================================== - - -SYNTAX what_is = 'what' 'is' (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something I know about." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - what_is = 'what' 'are' (obj)!. - - -ADD TO EVERY THING - VERB what_is - DOES - "You'll have to find it out yourself." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou'll have to find it out yourself." END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHERE AM I - - --- ============================================================== - - -SYNTAX where_am_i = 'where' am i. - - -VERB where_am_i - DOES - LOOK. -END VERB. - - - --- ============================================================== - - ------ WHERE IS - - --- ============================================================== - - -SYNTAX where_is = 'where' 'is' (obj)! - WHERE obj ISA THING - ELSE - IF obj IS NOT plural - THEN "That's not" - ELSE "Those are not" - END IF. - "something I know about." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - where_is = 'where' 'are' (obj)!. - - -ADD TO EVERY THING - VERB where_is - CHECK obj NOT AT hero - ELSE - IF obj IS NOT plural - THEN "That's" - ELSE "Those are" - END IF. - "right here!" - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - "You'll have to find it out yourself." - IF hero AT lr THEN - IF obj AT kitchen THEN "$p$p(The Kitchen)$nThat's right here!" - ELSE "$p$p(The Kitchen)$nYou'll have to find it out yourself." END IF. - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WHO AM I - - --- ============================================================== - - -SYNTAX who_am_i = who am i. - - -VERB who_am_i - DOES - "Maybe examining yourself might help." - IF hero AT lr THEN "$p$p(The Kitchen)$nMaybe examining yourself might help." END IF. -END VERB. - - - --- ============================================================== - - ------ WHO IS - - --- ============================================================== - - -SYNTAX who_is = 'who' 'is' (act)! - WHERE act ISA ACTOR - ELSE - IF act IS NOT plural - THEN "That's not somebody" - ELSE "Those are not anybody" - END IF. - "I know." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - who_is = 'who' 'are' (act)!. - - -ADD TO EVERY ACTOR - VERB who_is - DOES - IF act = hero - THEN "Maybe examining yourself might help." - IF hero AT lr THEN "$p$p(The Kitchen)$nMaybe examining yourself might help." END IF. - ELSE "You'll have to find that out yourself." - END IF. - END VERB. -END ADD TO. - - - --- ============================================================== - - ------ WRITE - - --- ============================================================== - - -SYNTAX write = write (txt) 'on' (obj) - WHERE txt ISA STRING - ELSE "Please state inside double quotes ("""") - what you want to write." - AND obj ISA OBJECT - ELSE "Nothing can be written there." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - - - write = write (txt) 'in' (obj). - - -ADD TO EVERY OBJECT - VERB write - WHEN obj - CHECK obj IS writeable - ELSE "Nothing can be written there." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - AND CURRENT LOCATION IS lit - ELSE "It is too dark to see." - AND obj IS reachable - ELSE SAY THE obj. - IF obj IS NOT plural - THEN "is" - ELSE "are" - END IF. - "out of your reach." - IF hero AT lr THEN "$p$p(The action stops.)" END IF. - DOES - IF text OF obj = "" - THEN SET text OF obj TO txt. - ELSE SET text OF obj TO text OF obj + " " + txt. - END IF. - "You write ""$$" SAY txt. "$$"" on" SAY THE obj. "." - MAKE obj readable. - END VERB. -END ADD TO. - - --- A couple of other formulations are understood but they guide the player to --- use the correct syntax: - - -SYNTAX write_error1 = write 'on' (obj) - WHERE obj ISA OBJECT - ELSE "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - - -ADD TO EVERY OBJECT - VERB write_error1 - DOES "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - END VERB. -END ADD TO. - - -SYNTAX write_error2 = write. - -VERB write_error2 - DOES "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." -END VERB. - - -SYNTAX write_error3 = write (txt) - WHERE txt ISA STRING - ELSE "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - - -ADD TO EVERY STRING - VERB write_error3 - DOES "Please use the formulation WRITE ""TEXT"" ON (IN) OBJECT - to write something." - END VERB. -END ADD TO. - - - --- ================================================================ - - ------ YES - - --- ================================================================ - - -SYNTAX yes = yes. - - -VERB yes - DOES "You sound rather positive." - IF hero AT lr THEN "$p$p(The Kitchen)$nYou sound rather positive." END IF. -END VERB. - - - diff --git a/app/src/main/jni/terps/alan/alan3/cgreen-runner-template.txt b/app/src/main/jni/terps/alan/alan3/cgreen-runner-template.txt deleted file mode 100644 index 2a662c0..0000000 --- a/app/src/main/jni/terps/alan/alan3/cgreen-runner-template.txt +++ /dev/null @@ -1,10 +0,0 @@ - -TestSuite *our_tests() { - TestSuite *suite = create_test_suite(); - add_test_with_context(suite, Parse, TheTest); - return suite; -} - -int main(int argc, char **argv) { - return run_single_test(our_tests(), "TheTest", create_text_reporter()); -} diff --git a/app/src/main/jni/terps/alan/alan3/compiler/.cproject b/app/src/main/jni/terps/alan/alan3/compiler/.cproject deleted file mode 100755 index 7e3b55a..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/.cproject +++ /dev/null @@ -1,289 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/app/src/main/jni/terps/alan/alan3/compiler/.directory_history b/app/src/main/jni/terps/alan/alan3/compiler/.directory_history deleted file mode 100755 index bbdcb51..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/.directory_history +++ /dev/null @@ -1,8 +0,0 @@ -alan/compiler/idTest.c - -alan/compiler/idTests.c -alan/compiler/idTest.c -alan/compiler/unit.c -alan/compiler/unittests.c -alan/compiler/unittests.c - diff --git a/app/src/main/jni/terps/alan/alan3/compiler/.gdbinit b/app/src/main/jni/terps/alan/alan3/compiler/.gdbinit deleted file mode 100644 index 444cd73..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/.gdbinit +++ /dev/null @@ -1 +0,0 @@ -source ../gdb/alan_commands.py diff --git a/app/src/main/jni/terps/alan/alan3/compiler/.gitignore b/app/src/main/jni/terps/alan/alan3/compiler/.gitignore deleted file mode 100644 index f69adf9..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/.gitignore +++ /dev/null @@ -1,29 +0,0 @@ -*.lmt -*.pml -*.pmt -*.smt -.lmkstamp -.pmkstamp -.smkstamp -.tmstamp -alan.rc -.alan -.unittests -.winalan -*.pmt2 -*.smt2 -smScan.dos -smScan.head -smScan.mac -smScan.tail -smScan.tbl -alan.res -alan.voc -alan -unittests -emitTestAcode -unittest.jpg -coverage -coverage*.info -.cgreen-gdb-commands -.alan64 diff --git a/app/src/main/jni/terps/alan/alan3/compiler/.project b/app/src/main/jni/terps/alan/alan3/compiler/.project deleted file mode 100755 index 06a6f74..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/.project +++ /dev/null @@ -1,77 +0,0 @@ - - - Alan - - - - - - org.eclipse.cdt.managedbuilder.core.genmakebuilder - clean,full,incremental, - - - ?name? - - - - org.eclipse.cdt.make.core.append_environment - true - - - org.eclipse.cdt.make.core.autoBuildTarget - all - - - org.eclipse.cdt.make.core.buildArguments - - - - org.eclipse.cdt.make.core.buildCommand - make - - - org.eclipse.cdt.make.core.cleanBuildTarget - clean - - - org.eclipse.cdt.make.core.contents - org.eclipse.cdt.make.core.activeConfigSettings - - - org.eclipse.cdt.make.core.enableAutoBuild - false - - - org.eclipse.cdt.make.core.enableCleanBuild - true - - - org.eclipse.cdt.make.core.enableFullBuild - true - - - org.eclipse.cdt.make.core.fullBuildTarget - all - - - org.eclipse.cdt.make.core.stopOnError - true - - - org.eclipse.cdt.make.core.useDefaultBuildCmd - true - - - - - org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder - - - - - - org.eclipse.cdt.core.cnature - org.eclipse.cdt.managedbuilder.core.ScannerConfigNature - org.eclipse.cdt.managedbuilder.core.managedBuildNature - - diff --git a/app/src/main/jni/terps/alan/alan3/compiler/Makefile b/app/src/main/jni/terps/alan/alan3/compiler/Makefile deleted file mode 100755 index 9446bb5..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/Makefile +++ /dev/null @@ -1,36 +0,0 @@ -####################################################################### -# This is the general Makefile for building the Alan Compiler -# It figures out on which host platform (and possibly on which computer) -# it is running an will include specific Makefiles to build on that -# particular host -# -# In the included platform specific Makefiles you should handle all -# target specific compile and link settings -# - -ifneq ($(EMACS),) -JREGROUTPUT = -noansi -else -UNITOUTPUT ?= -c -endif - -# Note that this must not have spaces in it lest the variable will include it -OS := ${if ${findstring CYGWIN,${shell uname}},Cygwin,${shell uname}} - -# Include the common source lists, need to be before the included rules -include sources.mk - -# Include the correct main Makefile depending on the system name -# -ifeq ($(findstring CYGWIN, $(shell uname)), CYGWIN) -ifeq ($(shell uname -n), thoni64) -include Makefile.thoni -else -include Makefile.cygwin -endif -else -include Makefile.$(shell uname) -endif - -# then platform and machine independent rules -include Makefile.common diff --git a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.Darwin b/app/src/main/jni/terps/alan/alan3/compiler/Makefile.Darwin deleted file mode 100755 index 5fa459c..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.Darwin +++ /dev/null @@ -1,17 +0,0 @@ -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# Makefile settings for compiling Alan compiler on MacOSX -# - -COMPILER = gcc -EXTRA_COMPILER_FLAGS = -g -Wall -funsigned-char -Wno-invalid-source-encoding - -LINKER = gcc -EXTRA_LINKER_FLAGS = - -CGREEN = yes -CGREENROOT = /usr/local -CGREENINCLUDE = -I$(CGREENROOT)/include -CGREENLIB = -lcgreen - -release: EXTRA_COMPILER_FLAGS = -O4 diff --git a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.Linux b/app/src/main/jni/terps/alan/alan3/compiler/Makefile.Linux deleted file mode 100755 index e4f1adc..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.Linux +++ /dev/null @@ -1,34 +0,0 @@ -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# Makefile settings for compiling Alan compiler on Linux -# - -UNAME := $(shell uname -m) - -#OSFLAGS = -m32 - -COMPILER = gcc -EXTRA_COMPILER_FLAGS = -g -Wall -funsigned-char -fPIC - -LINKER = gcc -EXTRA_LINKER_FLAGS = -Wl,--no-undefined - -release: EXTRA_COMPILER_FLAGS = -O4 - -# Cgreen unit testing settings -CGREEN = yes - -# If Cgreen is installed correctly and completely theses things should just work -# Otherwise you can try to set them to something that does work -#CGREENROOT = /usr/local -#CGREENINCLUDE = -I$(CGREENROOT)/include - -# On a 64-bit we should use 64-bit libraries -#ifeq ($(UNAME),x86_64) -# CGREENDIR=$(CGREENROOT)/lib/x86_64-linux-gnu -# RUNNER_PATH=$(CGREENROOT)/bin -#else -# CGREENDIR=$(CGREENROOT)/lib -# RUNNER_PATH=$(CGREENROOT)/bin -#endif -#CGREENLIB = -L$(CGREENDIR) -lcgreen -lm diff --git a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.common b/app/src/main/jni/terps/alan/alan3/compiler/Makefile.common deleted file mode 100755 index 6864936..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.common +++ /dev/null @@ -1,147 +0,0 @@ -# Generic make rules for alan compiler -# Set: -# COMPILER : which command to run the C compiler -# LINKER : which command to run the linker -# OSFLAGS : what flags must be passed to both compiler and linker -# EXTRA_COMPILER_FLAGS : what extra flags to pass to the compiler -# EXTRA_LINKER_FLAGS : what extra flags to pass to the linker - -ifneq ($(BUILDNUMBER),) - # For snapshots we use buildnumber for version info and filenames - BUILDVERSION = -$(BUILDNUMBER) -endif - -CC = $(COMPILER) -CFLAGS = -I../interpreter $(COMPILEFLAGS) $(EXTRA_COMPILER_FLAGS) -DBUILD=$(BUILDNUMBER) $(OSFLAGS) - -LINK = $(LINKER) -LINKFLAGS = $(OSFLAGS) $(EXTRA_LINKER_FLAGS) - -gprof: EXTRA_COMPILER_FLAGS = -pg -gprof: EXTRA_LINKER_FLAGS = -pg - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# Main target to do everything -# -.PHONY: all -all: unit build $(EXTRA_TARGETS) - -# Target to just build -.PHONY: build -build gprof: alan - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# Run all tests! -# -UNITOUTPUT ?= -c - -.PHONY: test -test: - @cd ..;bin/jregr -bin bin -dir compiler/testing $(JREGROUTPUT) - @cd ..;bin/jregr -bin bin -dir compiler/testing/positions $(JREGROUTPUT) - @cd ..;bin/jregr -bin bin -dir compiler/testing/dump $(JREGROUTPUT) - @cd ..;bin/jregr -dir compiler/testing/arguments $(JREGROUTPUT) - @cd ..;bin/jregr -bin bin -dir regression/debug $(JREGROUTPUT) - @cd ../regression/platforms; ../../bin/alan $(OS) - @cd ..;bin/jregr -bin bin -dir regression/platforms $(JREGROUTPUT) -# TODO: Since older interpreters barf on the tests for backwards compatibility of the compiler -# TODO: we need to split that up somehow -# @cd ..;java -jar bin/jregr.jar -bin bin -dir regression/versions/compiler $(JREGROUTPUT) - -# Clean -.PHONY: clean -clean: - @-rm -f *.dll .*/*.o .*/*.d .*/*.dll .*/*.gcno .*/*.gcda alan.res ../bin/alan ../bin/winalan - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# Alan command line compiler -# -ALANOBJDIR = .alan -ALANOBJECTS = $(addprefix $(ALANOBJDIR)/,${ALANSRCS:.c=.o}) $(ALANOBJDIR)/alan.version.o --include $(ALANOBJECTS:.o=.d) -$(ALANOBJECTS): $(ALANOBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -MMD -o $@ -c $< - -$(ALANOBJDIR): - @mkdir $(ALANOBJDIR) - -alan: $(ALANOBJDIR) $(ALANOBJECTS) - $(LINK) -o alan $(ALANOBJECTS) $(LINKFLAGS) - -@if ! test -d ../bin; then mkdir ../bin 2> /dev/null ; fi - cp alan ../bin/alan - - -################################################################# -# Unit testing -# -# Two types: -.PHONY: unit -unit: cgreenrunnertests isolated_unittests - -CGREENLIB ?= -lcgreen - -UNITTESTSOBJDIR = .unittests -UNITTESTSOBJECTS = $(addprefix $(UNITTESTSOBJDIR)/,${UNITTESTSSRCS:.c=.o}) $(UNITTESTSOBJDIR)/alan.version.o -UNITTESTSDLLOBJECTS = $(addprefix $(UNITTESTSOBJDIR)/,${UNITTESTSDLLSRCS:.c=.o}) $(UNITTESTSOBJDIR)/alan.version.o - -# Dependencies, if they don't exist yet --include $(UNITTESTSOBJECTS:.o=.d) - -# Rule to compile unittest objects to subdirectory -$(UNITTESTSOBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -MMD -o $@ -c $< -$(UNITTESTSOBJDIR)/%_tests.o: %_tests.c - $(CC) $(CFLAGS) -MMD -o $@ -c $< - -# Create directory if it doesn't exist -$(UNITTESTSOBJDIR): - @mkdir $(UNITTESTSOBJDIR) - -################################################################### -# Build a DLL of all unittests... -unittests.dll: CFLAGS += $(CGREENINCLUDE) -unittests.dll: LIBS = $(CGREENLIB) -unittests.dll: $(UNITTESTSOBJDIR) $(UNITTESTSOBJECTS) - $(LINK) -shared -o $@ $(UNITTESTSDLLOBJECTS) $(LINKFLAGS) $(LIBS) - -# ... that can be run with the cgreen runner -cgreenrunnertests: unittests.dll - $(CGREEN_LIBRARY_PATH) $(RUNNER_PATH)cgreen-runner ./$^ --suite compiler_unit_tests $(UNITOUTPUT) - - -##################################################################### -# Here we try to build a runnable DLL for each module where it can be -# tested in total isolation (with everything else mocked away, -# except lists.c and memory.c) - --include $(addprefix $(UNITTESTSOBJDIR)/,$(patsubst %,%.d,$(MODULES_WITH_ISOLATED_UNITTESTS))) --include $(addprefix $(UNITTESTSOBJDIR)/,$(patsubst %,%_tests.d,$(MODULES_WITH_ISOLATED_UNITTESTS))) - -ISOLATED_UNITTESTS_EXTRA_MODULES = util options sysdep lst dump opt type alan.version -ISOLATED_UNITTESTS_EXTRA_OBJS = $(addprefix $(UNITTESTSOBJDIR)/, $(addsuffix .o, $(ISOLATED_UNITTESTS_EXTRA_MODULES))) - -# A test .dll for a module is built from its .o and the _test.o (and some extras) -$(UNITTESTSOBJDIR)/%_tests.dll: $(UNITTESTSOBJDIR)/%.o $(UNITTESTSOBJDIR)/%_tests.o - $(LINK) -shared -o $@ $(sort $(ISOLATED_UNITTESTS_EXTRA_OBJS) $^) $(LINKFLAGS) $(LIBS) - -ISOLATED_UNITTESTS_DLLS = $(addprefix $(UNITTESTSOBJDIR)/,$(patsubst %,%_tests.dll,$(MODULES_WITH_ISOLATED_UNITTESTS))) - -# Then run all _tests.dll's with the cgreen-runner -isolated_unittests: CFLAGS += $(CGREENINCLUDE) -isolated_unittests: LIBS = $(CGREENLIB) -isolated_unittests: $(UNITTESTSOBJDIR) $(ISOLATED_UNITTESTS_EXTRA_OBJS) $(ISOLATED_UNITTESTS_DLLS) $(ISOLATED_UNITTESTS_EXTRA_OBJS) - $(CGREEN_LIBRARY_PATH) $(RUNNER_PATH)cgreen-runner $$f --suite Compiler $(UNITOUTPUT) $(ISOLATED_UNITTESTS_DLLS) - - -############################################ -# Coverage -coverage: EXTRA_COMPILER_FLAGS += --coverage -coverage: EXTRA_LINKER_FLAGS += --coverage -coverage: all test - cd ../regression; jregr - lcov --capture --directory . -b . --output-file coverage_tmp.info - lcov --extract coverage_tmp.info '*.c' -o coverage.info - genhtml coverage.info --output coverage diff --git a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.cygwin b/app/src/main/jni/terps/alan/alan3/compiler/Makefile.cygwin deleted file mode 100755 index 7393c65..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.cygwin +++ /dev/null @@ -1,82 +0,0 @@ -################################################## -# -# This Makefile is included from the Makefile and -# only sets some cygwin particular switches -# All rules are in Makefile.common and included by Makefile - -# Override "all" target -EXTRA_TARGETS = alan64 - -# Normally cross compile from cygwin to native Windows binaries -COMPILER = i686-w64-mingw32-gcc -LINKER = i686-w64-mingw32-gcc -WINDRES = i686-w64-mingw32-windres - - -# Except when compiling unit tests, since Cgreen can't be -# cross-compiled to Windows binaries -unit: COMPILER = gcc -unit: LINKER = gcc - -# Flags to send to both compiler & linker -OS_FLAGS = -OPTIMIZE = -g - -EXTRA_COMPILER_FLAGS = -Wall -funsigned-char $(OPTIMIZE) -#EXTRA_LINKER_FLAGS = -Wl,--no-undefined - -# Cgreen unit testing settings -CGREEN = yes -CGREENROOT = /usr/local -CGREENINCLUDE = -I$(CGREENROOT)/include -CGREENLIB = $(CGREENLIBDIR)/libcgreen.dll.a - -CGREENLIBDIR=$(CGREENROOT)/lib -RUNNER_PATH=$(CGREENROOT)/bin/ - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# WinAlan is only available on Windows (= MinGW = Cygwin without cygwin1.dll) -# -# Build with flags: -winalan: EXTRA_COMPILER_FLAGS = -std=c99 -Wall -funsigned-char $(OPTIMIZE) -DWINGUI #-DARGSDISPLAY -WINALANLIBS = -lshlwapi - -WINALANOBJDIR = .winalan -WINALANOBJECTS = $(addprefix $(WINALANOBJDIR)/,${ALANSRCS:.c=.o}) $(WINALANOBJDIR)/alan.version.o --include $(WINALANOBJECTS:.o=.d) -$(WINALANOBJECTS): $(WINALANOBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -MMD -o $@ -c $< - -$(WINALANOBJDIR): - @mkdir $(WINALANOBJDIR) - -winalan: $(WINALANOBJDIR) $(WINALANOBJECTS) alan.res - $(LINK) $(LINKFLAGS) -o winalan -mwindows $(WINALANOBJECTS) alan.res $(WINALANLIBS) - -@if ! test -d ../bin; then mkdir ../bin 2> /dev/null ; fi - cp winalan ../bin - -alan.res: alan.rc alan.ico - $(WINDRES) $< -O coff -o $@ - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# alan64 - command line alan compiler for Cygwin64 -# -# Build with flags and compilers: -alan64: COMPILER = gcc -alan64: LINKER = gcc - -ALAN64OBJDIR = .alan64 -ALAN64OBJECTS = $(addprefix $(ALAN64OBJDIR)/,${ALANSRCS:.c=.o}) $(ALAN64OBJDIR)/alan.version.o - -$(ALAN64OBJECTS): $(ALAN64OBJDIR)/%.o: %.c - $(CC) $(CFLAGS) -MMD -o $@ -c $< - -$(ALAN64OBJDIR): - @mkdir $(ALAN64OBJDIR) - -alan64: $(ALAN64OBJDIR) $(ALAN64OBJECTS) - $(LINK) $(LINKFLAGS) -o $@ $(ALAN64OBJECTS) $(ALAN64LIBS) - -@if ! test -d ../bin; then mkdir ../bin 2> /dev/null ; fi - cp $@ ../bin diff --git a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.thoni b/app/src/main/jni/terps/alan/alan3/compiler/Makefile.thoni deleted file mode 100755 index 8f48e3f..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.thoni +++ /dev/null @@ -1,66 +0,0 @@ -####################################################################### -# This Makefile is for building the Alan Compiler from scratch -# on ThoNi's machine. It is basically a Cygwin environment so it -# includes Makefile.cygwin but adds all the rules to build using -# ToolMaker compiler tools, etc. -# -# It is also the environment that will be used when running within -# the Hudson Continuous Integration server, since that is running on -# ThoNi's machine too -####################################################################### - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# Default target on thoni is : -# -all: tm unit build - -include Makefile.cygwin - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# Build all binaries -# -# 'build' is the target the continuous integration will use -.PHONY: build -build : alan winalan - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# -# release -# -release: OPTIMIZE = -O4 -.PHONY: release -release: clean build - @if ldd alan | grep -q cygwin1.dll ; then \ - echo Warning - alan is dependent on cygwin1.dll ; \ - exit 1 ; \ - fi - @if ldd winalan | grep -q cygwin1.dll ; then \ - echo Warning - alan is dependent on cygwin1.dll ; \ - exit 1 ; \ - fi - - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -## rndalan - Progam to generate a randomized Alan source -# -rndalan: rndalan.o - $(LINK) $(LINKFLAGS) -o rndalan rndalan.o - -@if ! test -f ../bin; then mkdir ../bin 2> /dev/null ; fi - cp rndalan ../bin - - -#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ -# ToolMaker stuff -# -.tmstamp: $(TMSRCS) - $(MAKE) -f Makefile.tm - -.PHONY: tm -tm: - -@if test "`uname -n`" = "thoni"; then \ - $(MAKE) -f Makefile.tm ; \ - fi - -include ../venum.mk diff --git a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.tm b/app/src/main/jni/terps/alan/alan3/compiler/Makefile.tm deleted file mode 100755 index e2d61dd..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.tm +++ /dev/null @@ -1,164 +0,0 @@ -# Makefile for alan compiler -# This makefile is to ensure that all sources are up-to-date -# It will generate parser, scanner, lister and version files -# using tools only available on ThoNi's machines -# Any source distribution should be complete with respect to these -# files and this Makefile can be ignored. -# -# REMEMBER: You have to set both the Path to include the ToolMaker -# directory and the TMHOME environment variable to point there! - -TMHOME = $(HOME)/Utveckling/ToolMaker -TMLIB = $(TMHOME)/lib/ansi-c - -EXTRAS = \ - alan.tmk \ - alan.lmk \ - alan.smk \ - alan.pmk - -TMSRCS = \ - pmParse.c pmPaSema.c \ - pmErr.c \ - smScanx.c smScSema.c\ - lmList.c alanCommon.h - -IMPQ = -sTMHOME\(\"$(TMHOME)\"\) - -all : tm smScanx.c sysdep.h sysdep.c version.h alan.atg alan.g - -.PHONY: x -x : - @echo TMLIB=$(TMLIB) - @echo TMHOME=$(TMHOME) - - -tm: .pmkstamp .smkstamp .lmkstamp alan.prod - touch .tmstamp - -.lmkstamp: alan.lmk alan.tmk $(TMLIB)/List.imp $(TMLIB)/Common.imp - lmk $(LMKQ) -generate tables alan - imp $(IMPQ) alan.lmt - touch .lmkstamp - -.pmkstamp: alan.pmk alan.tmk $(TMLIB)/Parse.imp $(TMLIB)/Err.imp $(TMLIB)/Common.imp - pmk $(PMKQ) -generate tables alan - sed -e "s/%%SET currentOs(\"WIN32\")/%%SET currentOs(\"cygwin\")/" alan.pmt > alan.pmt2 - imp $(IMPQ) alan.pmt2 - touch .pmkstamp - -alan.prod : prod.sed alan.pml - sed -f prod.sed alan.pml > alan.prod - -alan.atg : coco.sed coco.header alan.prod - cp coco.header alan.atg - sed -f coco.sed alan.prod >> alan.atg - -alan.g : antlr.sed antlr.header alan.prod - cp antlr.header alan.g - sed -f antlr.sed alan.prod >> alan.g - -.smkstamp : alan.smk alan.tmk alan.voc $(TMLIB)/Scan.imp $(TMLIB)/Common.imp - smk alan -generate tables - sed -e "s/%%SET currentOs(\"WIN32\")/%%SET currentOs(\"cygwin\")/" alan.smt > alan.smt2 - imp $(IMPQ) alan.smt2 - sed -e "1,/START of scanning tables/d" -e "/END of scanning tables/,$$ d" -e "/static UByte1 smMap/,/;/d" -e "/static UByte1 smDFAcolVal/,/;/d" -e "/static UByte1 smDFAerrCol/,/;/d" smScan.c > smScan.tbl - echo "/* ISO scanner tables */" > smScan.iso.new - echo "UByte1 smIsoMap[256]={" >> smScan.iso.new - sed -e "1,/static UByte1 smMap/d" -e "/;/,$$ d" smScan.c >> smScan.iso.new - echo ";" >> smScan.iso.new - echo "" >> smScan.iso.new - echo "UByte1 smIsoDFAcolVal[256]={" >> smScan.iso.new - sed -e "1,/static UByte1 smDFAcolVal/d" -e "/;/,$$ d" smScan.c >> smScan.iso.new - echo ";" >> smScan.iso.new - echo "" >> smScan.iso.new - echo "UByte1 smIsoDFAerrCol[256]={" >> smScan.iso.new - sed -e "1,/static UByte1 smDFAerrCol/d" -e "/;/,$$ d" smScan.c >> smScan.iso.new - echo ";" >> smScan.iso.new - echo "" >> smScan.iso.new - if test -f smScan.iso ; then \ - if cmp smScan.iso smScan.iso.new ; then \ - rm smScan.iso.new ; \ - else \ - mv smScan.iso.new smScan.iso ; \ - fi ; \ - else \ - mv smScan.iso.new smScan.iso ; \ - fi ; - smk -set MAC alan -generate tables - imp $(IMPQ) alan.smt - echo "/* MAC scanner tables */" > smScan.mac.new - echo "UByte1 smMacMap[256]={" >> smScan.mac.new - sed -e "1,/static UByte1 smMap/d" -e "/;/,$$ d" smScan.c >> smScan.mac.new - echo ";" >> smScan.mac.new - echo "" >> smScan.mac.new - echo "UByte1 smMacDFAcolVal[256]={" >> smScan.mac.new - sed -e "1,/static UByte1 smDFAcolVal/d" -e "/;/,$$ d" smScan.c >> smScan.mac.new - echo ";" >> smScan.mac.new - echo "" >> smScan.mac.new - echo "UByte1 smMacDFAerrCol[256]={" >> smScan.mac.new - sed -e "1,/static UByte1 smDFAerrCol/d" -e "/;/,$$ d" smScan.c >> smScan.mac.new - echo ";" >> smScan.mac.new - echo "" >> smScan.mac.new - if test -f smScan.mac ; then \ - if cmp smScan.mac smScan.mac.new ; then \ - rm smScan.mac.new ; \ - else \ - mv smScan.mac.new smScan.mac ; \ - fi ; \ - else \ - mv smScan.mac.new smScan.mac ; \ - fi ; - smk -set PC alan -generate tables - imp $(IMPQ) alan.smt - echo "/* DOS scanner tables */" > smScan.dos.new - echo "UByte1 smDosMap[256]={" >> smScan.dos.new - sed -e "1,/static UByte1 smMap/d" -e "/;/,$$ d" smScan.c >> smScan.dos.new - echo ";" >> smScan.dos.new - echo "" >> smScan.dos.new - echo "UByte1 smDosDFAcolVal[256]={" >> smScan.dos.new - sed -e "1,/static UByte1 smDFAcolVal/d" -e "/;/,$$ d" smScan.c >> smScan.dos.new - echo ";" >> smScan.dos.new - echo "" >> smScan.dos.new - echo "UByte1 smDosDFAerrCol[256]={" >> smScan.dos.new - sed -e "1,/static UByte1 smDFAerrCol/d" -e "/;/,$$ d" smScan.c >> smScan.dos.new - echo ";" >> smScan.dos.new - echo "" >> smScan.dos.new - if test -f smScan.dos ; then \ - if cmp smScan.dos smScan.dos.new ; then \ - rm smScan.dos.new ; \ - else \ - mv smScan.dos.new smScan.dos ; \ - fi ; \ - else \ - mv smScan.dos.new smScan.dos ; \ - fi - sed -e "1,/START of scanning tables/w smScan.head" -e "/END of scanning tables/,$$ w smScan.tail" smScan.c > /dev/null - cat smScan.head > smScanx.c - echo "UByte1 *smMap;" >> smScanx.c - echo "UByte1 *smDFAcolVal;" >> smScanx.c - echo "UByte1 *smDFAerrCol;" >> smScanx.c - echo "" >> smScanx.c - cat smScan.iso >> smScanx.c - cat smScan.mac >> smScanx.c - cat smScan.dos >> smScanx.c - cat smScan.tbl >> smScanx.c - cat smScan.tail >> smScanx.c - dos2unix smScanx.c - dos2unix smScSema.c - touch .smkstamp - -smScanx.c : .smkstamp - -pmParse.h pmParse.c pmPaSema.c pmErr.c alan.voc alan.pml: - -rm .pmkstamp - make -f Makefile.tm .pmkstamp - -smScan.h smScSema.c: - -rm .smkstamp - make -f Makefile.tm .smkstamp - -lmList.h lmList.c alanCommon.h: - -rm .lmkstamp - make -f Makefile.tm .lmkstamp - diff --git a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.unix b/app/src/main/jni/terps/alan/alan3/compiler/Makefile.unix deleted file mode 100755 index c5aeb26..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/Makefile.unix +++ /dev/null @@ -1,13 +0,0 @@ -# -# Makefile to compile Alan Compiler on generic Unix -# - -COMPILER = gcc -LINKER = gcc - -OS_FLAGS = - -EXTRA_COMPILER_FLAGS = -Wall -funsigned-char -EXTRA_LINKER_FLAGS = - -include Makefile.common diff --git a/app/src/main/jni/terps/alan/alan3/compiler/add.c b/app/src/main/jni/terps/alan/alan3/compiler/add.c deleted file mode 100644 index 338d210..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/add.c +++ /dev/null @@ -1,475 +0,0 @@ -/*----------------------------------------------------------------------*\ - - ADD.C - Add To Nodes - -\*----------------------------------------------------------------------*/ - -#include "add_x.h" - -/* IMPORT: */ -#include "adv_x.h" -#include "prop_x.h" -#include "sym_x.h" -#include "id_x.h" -#include "srcp_x.h" -#include "atr_x.h" -#include "lst_x.h" -#include "vrb_x.h" -#include "ext_x.h" -#include "whr_x.h" -#include "dump_x.h" -#include "description_x.h" -#include "context_x.h" - -#include "scr.h" -#include "ext.h" -#include "util.h" -#include "lmList.h" - - -/*======================================================================*/ -AddNode *newAdd(Srcp srcp, - Id *id, - Id *parent, - Properties *props) -{ - AddNode *new; - - progressCounter(); - - new = NEW(AddNode); - - new->srcp = srcp; - if (props) - new->props = props; - else - new->props = newEmptyProps(); - new->toId = id; - - if (parent != NULL) - lmLogv(&parent->srcp, 341, sevERR, "heritage", "", NULL); - - return(new); -} - - -#ifndef PROPERTIESOF -#define PROPERTIESOF(s) ((s)->fields.entity.props) -#endif - -/*----------------------------------------------------------------------*/ -static void addInitialLocation(AddNode *add, Symbol *original) -{ - Properties *props = add->props; - - if (props->whr != NULL) { - if (PROPERTIESOF(original)->whr != NULL) - lmLog(&add->props->whr->srcp, 336, sevERR, - "an Initial location when the class already have it"); - else { - if (!inheritsFrom(PROPERTIESOF(original)->id->symbol, thingSymbol) && props->whr != NULL) - lmLog(&props->whr->srcp, 405, sevERR, "have initial locations"); - else { - symbolizeWhere(props->whr); - if (verifyInitialLocation(props->whr, NULL)) - PROPERTIESOF(original)->whr = props->whr; - } - } - } -} - - -/*----------------------------------------------------------------------*/ -static void addNames(AddNode *add, Symbol *original) -{ - Properties *props = add->props; - - if (props->names != NULL) - PROPERTIESOF(original)->names = combine(props->names, - PROPERTIESOF(original)->names); -} - - -/*----------------------------------------------------------------------*/ -static void addPronouns(AddNode *add, Symbol *original) -{ - Properties *props = add->props; - - if (props->pronouns != NULL) { - if (PROPERTIESOF(original)->pronouns != NULL) - lmLog(&add->props->pronounsSrcp, 336, sevERR, - "Pronouns when the class already have it"); - else - PROPERTIESOF(original)->pronouns = props->pronouns; - } -} - -/*----------------------------------------------------------------------*/ -static void addAttributes(AddNode *add, Symbol *originalSymbol) -{ - List *addedAttributes = add->props->attributes; - Properties *originalProps = originalSymbol->fields.entity.props; - List *originalAttributes = originalProps->attributes; - List *l; - - if (addedAttributes == NULL) return; - symbolizeAttributes(addedAttributes, TRUE); - - ITERATE(l, addedAttributes) { - Attribute *originalAttribute = findAttribute(originalAttributes, l->member.atr->id); - if (originalAttribute != NULL) /* It was found in the original */ - lmLog(&l->member.atr->id->srcp, 336, sevERR, "an attribute which already exists"); - } - originalProps->attributes = combine(originalProps->attributes, - addedAttributes); -} - - -/*----------------------------------------------------------------------*/ -static void addInitialize(AddNode *add, Symbol *original) -{ - Properties *props = add->props; - - if (props->initialize != NULL) { - if (PROPERTIESOF(original)->initialize != NULL) - lmLog(&add->props->initializeSrcp, 336, sevERR, - "an Initialize clause when the class already have it"); - else - PROPERTIESOF(original)->initialize = props->initialize; - } -} - - -/*----------------------------------------------------------------------*/ -static void addDescriptionCheck(AddNode *add, Symbol *originalSymbol) -{ - Properties *addedProps = add->props; - Properties *originalProps = originalSymbol->fields.entity.props; - - if (checksOf(addedProps->description) != NULL) { - if (checksOf(originalProps->description) != NULL) - lmLogv(&addedProps->description->checkSrcp, 241, sevERR, "A Description Check is", - originalSymbol->string, NULL); - else { - if (originalProps->description == NULL) - originalProps->description = newDescription(addedProps->description->checkSrcp, - addedProps->description->checks, nulsrcp, NULL); - else { - originalProps->description->checkSrcp = addedProps->description->checkSrcp; - originalProps->description->checks = addedProps->description->checks; - } - } - } -} - - -/*----------------------------------------------------------------------*/ -static void addDescription(AddNode *add, Symbol *originalSymbol) -{ - Properties *addedProps = add->props; - Properties *originalProps = originalSymbol->fields.entity.props; - - if (doesOf(addedProps->description) != NULL) { - if (doesOf(originalProps->description) != NULL) - lmLogv(&addedProps->description->doesSrcp, 241, sevERR, "A Description is", - originalSymbol->string, NULL); - else { - if (originalProps->description == NULL) - originalProps->description = newDescription(nulsrcp, NULL, - addedProps->description->doesSrcp, - addedProps->description->does); - else { - originalProps->description->doesSrcp = addedProps->description->doesSrcp; - originalProps->description->does = addedProps->description->does; - } - } - } -} - - -/*----------------------------------------------------------------------*/ -static void addArticles(AddNode *add, Symbol *original) -{ - if (add->props->definite != NULL) { - if (original->fields.entity.props->definite != NULL) - lmLog(&add->props->definite->srcp, 336, sevERR, - "a Definite Article when the class already have it"); - else - original->fields.entity.props->definite = add->props->definite; - } - - if (add->props->indefinite != NULL) { - if (original->fields.entity.props->indefinite != NULL) - lmLog(&add->props->indefinite->srcp, 336, sevERR, - "Indefinite Article when the class already have it"); - else - original->fields.entity.props->indefinite = add->props->indefinite; - } - - if (add->props->negative != NULL) { - if (original->fields.entity.props->negative != NULL) - lmLog(&add->props->negative->srcp, 336, sevERR, - "Negative Article when the class already have it"); - else - original->fields.entity.props->negative = add->props->negative; - } -} - - -/*----------------------------------------------------------------------*/ -static void addMentioned(AddNode *add, Symbol *original) -{ - Properties *props = add->props; - - if (props->mentioned != NULL) { - if (original->fields.entity.props->mentioned != NULL) - lmLog(&add->props->mentionedSrcp, 336, sevERR, - "Mentioned clause when the class already have it"); - else - original->fields.entity.props->mentioned = add->props->mentioned; - } -} - - -/*----------------------------------------------------------------------*/ -static void addContainer(AddNode *add, Symbol *original) -{ - Properties *props = add->props; - - if (props->container == NULL) return; - - if (original->fields.entity.props->container != NULL) - lmLog(&props->container->body->srcp, 336, sevERR, - "container properties when the class already have it"); - else - original->fields.entity.props->container = props->container; - -} - - -/*----------------------------------------------------------------------*/ -static void addVerbs(AddNode *add, Symbol *originalSymbol) -{ - Properties *originalProps = originalSymbol->fields.entity.props; - List *verbList; - List *verbIdList; - Bool inhibitAdd = FALSE; - - if (add->props->verbs != NULL) { - if (originalSymbol == entitySymbol) - lmLog(&add->props->verbs->member.vrb->srcp, 426, sevWAR, ""); - ITERATE(verbList, add->props->verbs) { - ITERATE(verbIdList, verbList->member.vrb->ids) - if (verbIdFound(verbIdList->member.id, originalProps->verbs)) { - inhibitAdd = TRUE; - lmLogv(&verbIdList->member.id->srcp, 240, sevERR, "Verb", verbIdList->member.id->string, originalSymbol->string, NULL); - } - } - if (!inhibitAdd) - originalProps->verbs = combine(originalProps->verbs, add->props->verbs); - } -} - - -/*----------------------------------------------------------------------*/ -static void addScripts(AddNode *add, Symbol *original) -{ - Properties *props = add->props; - Properties *originalProps = original->fields.entity.props; - List *addedScripts; - List *originalScripts; - List *scriptsToAdd = NULL; - Bool doNotAdd = FALSE; - - if (props->scripts == NULL) return; - - if (!inheritsFrom(original, actorSymbol)) { - lmLog(&add->props->scripts->member.script->srcp, 336, sevERR, "scripts to a class which is not a subclass of the predefined class 'actor'"); - doNotAdd = TRUE; - } - ITERATE(addedScripts, props->scripts) { - Script *addedScript = addedScripts->member.script; - Bool duplicate = FALSE; - ITERATE(originalScripts, originalProps->scripts) { - Script *originalScript = originalScripts->member.script; - if (equalId(addedScript->id, originalScript->id)) { - lmLogv(&addedScript->srcp, 240, sevERR, - "Script", addedScript->id->string, add->toId->string, NULL); - duplicate = TRUE; - break; - } - } - if (!duplicate && !doNotAdd) - scriptsToAdd = concat(scriptsToAdd, addedScript, SCRIPT_LIST); - } - originalProps->scripts = combine(originalProps->scripts, scriptsToAdd); -} - - -/*----------------------------------------------------------------------*/ -static void addEntered(AddNode *add, Symbol *originalSymbol) -{ - Properties *props = add->props; - - if (props->enteredStatements != NULL) { - if (!inheritsFrom(originalSymbol, locationSymbol)) { - lmLog(&add->props->enteredSrcp, 336, sevERR, "Entered clause to something not inheriting from the predefined class 'location'"); - } else { - if (originalSymbol->fields.entity.props->enteredStatements != NULL) { - lmLogv(&add->props->enteredSrcp, 344, sevWAR, - "Entered clause", originalSymbol->string, NULL); - lmLog(&originalSymbol->fields.entity.props->enteredSrcp, 345, sevWAR, "Entered clause"); - } else { - PROPERTIESOF(originalSymbol)->enteredStatements = props->enteredStatements; - PROPERTIESOF(originalSymbol)->enteredSrcp = props->enteredSrcp; - } - } - } -} - - -/*----------------------------------------------------------------------*/ -static void addExits(AddNode *add, Symbol *originalSymbol) -{ - Properties *originalProps = originalSymbol->fields.entity.props; - List *exitList; - List *exitIdList; - Bool inhibitAdd = FALSE; - - if (add->props->exits != NULL) { - symbolizeExits(add->props->exits); - if (!inheritsFrom(originalSymbol, locationSymbol)) { - lmLog(&add->props->exits->member.ext->srcp, 336, sevERR, "Exits to something not inheriting from the predefined class 'location'"); - inhibitAdd = TRUE; - } - - ITERATE(exitList, add->props->exits) { - ITERATE(exitIdList, exitList->member.ext->directions) - if (exitIdFound(exitIdList->member.id, originalProps->exits)) { - inhibitAdd = TRUE; - lmLogv(&exitIdList->member.id->srcp, 240, sevERR, "Exit", exitIdList->member.id->string, originalSymbol->string, NULL); - } - } - if (!inhibitAdd) - /* If there was no error above we can combine the additions, - else it doesn't matter */ - originalProps->exits = combine(originalProps->exits, add->props->exits); - } -} - - -/*----------------------------------------------------------------------*/ -static void verifyAdd(AddNode *add, Symbol *originalSymbol) -{ - /* Can't add anything except verbs to non-instantiable classes */ - if (originalSymbol->fields.entity.prohibitedSubclassing) { - int propsCount = 1; /* Verbs-slot is not counted so start at 1 */ - - if (add->props->whr) - lmLogv(&add->props->whr->srcp, 424, sevERR, "initial location", originalSymbol->string, NULL); - propsCount++; - - if (add->props->names) - lmLogv(&add->srcp, 424, sevERR, "names", originalSymbol->string, NULL); - propsCount++; - - if (add->props->pronouns) - lmLogv(&add->srcp, 424, sevERR, "pronouns", originalSymbol->string, NULL); - propsCount++; - - if (add->props->attributes) - lmLogv(&add->props->attributes->member.atr->srcp, 424, sevERR, "attributes", originalSymbol->string, NULL); - propsCount++; - - if (add->props->initialize) - lmLogv(&add->props->initialize->srcp, 424, sevERR, "initialize", originalSymbol->string, NULL); - propsCount++; - - if (checksOf(add->props->description) != NULL || doesOf(add->props->description) != NULL) - lmLogv(&add->props->description->doesSrcp, 424, sevERR, "description", originalSymbol->string, NULL); - propsCount+=2; - - if (add->props->definite) - lmLogv(&add->props->definite->srcp, 424, sevERR, "article", originalSymbol->string, NULL); - propsCount++; - - if (add->props->indefinite) - lmLogv(&add->props->indefinite->srcp, 424, sevERR, "article", originalSymbol->string, NULL); - propsCount++; - - if (add->props->negative) - lmLogv(&add->props->negative->srcp, 424, sevERR, "article", originalSymbol->string, NULL); - propsCount++; - - if (add->props->mentioned) - lmLogv(&add->props->mentionedSrcp, 424, sevERR, "mentioned", originalSymbol->string, NULL); - propsCount++; - - if (add->props->container) - lmLogv(&add->props->container->body->srcp, 424, sevERR, "container", originalSymbol->string, NULL); - propsCount++; - - if (add->props->scripts) - lmLogv(&add->props->scripts->member.script->srcp, 424, sevERR, "scripts", originalSymbol->string, NULL); - propsCount++; - - if (add->props->enteredStatements) - lmLogv(&add->props->enteredSrcp, 424, sevERR, "entered", originalSymbol->string, NULL); - propsCount++; - - if (add->props->exits) - lmLogv(&add->props->exits->member.ext->srcp, 424, sevERR, "exits", originalSymbol->string, NULL); - propsCount++; - - if (propsCount != NOOFPROPS) - SYSERR("Wrong number of property checks", add->srcp); - } -} - - -/*----------------------------------------------------------------------*/ -static void addAddition(AddNode *add) -{ - Symbol *originalClass = symcheck(add->toId, CLASS_SYMBOL, NULL); - - if (originalClass != NULL) { - int propCount = 0; - verifyAdd(add, originalClass); - addInitialLocation(add, originalClass); propCount++; - addNames(add, originalClass); propCount++; - addPronouns(add, originalClass); propCount++; - addAttributes(add, originalClass); propCount++; - addInitialize(add, originalClass); propCount++; - addDescriptionCheck(add, originalClass); propCount++; - addDescription(add, originalClass); propCount++; - addArticles(add, originalClass); propCount+=3; - addMentioned(add, originalClass); propCount++; - addContainer(add, originalClass); propCount++; - addVerbs(add, originalClass); propCount++; - addScripts(add, originalClass); propCount++; - addEntered(add, originalClass); propCount++; - addExits(add, originalClass); propCount++; - if (propCount != NOOFPROPS) - SYSERR("Wrong property count", add->srcp); - } -} - - -/*======================================================================*/ -void addAdditions(void) -{ - List *l; - - for (l = adv.adds; l != NULL; l = l->next) - addAddition(l->member.add); -} - - -/*======================================================================*/ -void dumpAdd(AddNode *add) -{ - put("ADD: "); dumpSrcp(add->srcp); indent(); - put("toId: "); dumpId(add->toId); nl(); - put("props: "); dumpProps(add->props); out(); -} diff --git a/app/src/main/jni/terps/alan/alan3/compiler/add.h b/app/src/main/jni/terps/alan/alan3/compiler/add.h deleted file mode 100644 index 0a5bc3a..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/add.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef _ADD_H_ -#define _ADD_H_ -/*----------------------------------------------------------------------*\ - - ADD.H - Add To Nodes - -\*----------------------------------------------------------------------*/ - - -/* USE: */ -#include "types.h" -#include "id.h" -#include "prop.h" - - -/* TYPES: */ - -typedef struct AddNode { /* ADD TO */ - Srcp srcp; /* Source position */ - Id *toId; /* Class to add to */ - Properties *props; - Aaddr adr; /* Generated at address */ -} AddNode; - - -#endif diff --git a/app/src/main/jni/terps/alan/alan3/compiler/addTest.c b/app/src/main/jni/terps/alan/alan3/compiler/addTest.c deleted file mode 100644 index 6d32d0a..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/addTest.c +++ /dev/null @@ -1,118 +0,0 @@ -/*======================================================================*\ - - addTest.c - - Unit tests for ADD node in the Alan compiler - -\*======================================================================*/ - -#include "add.c" - -#include - -#include "cla_x.h" -#include "sym.h" - -Describe(Add); -BeforeEach(Add) {} -AfterEach(Add) {} - - -Ensure(Add, testMultipleAddAttribute) { - Id *theId = newId(nulsrcp, "aClassId"); - Attribute *theFirstAttribute = newBooleanAttribute(nulsrcp, newId(nulsrcp, "firstAttribute"), FALSE); - Attribute *theSecondAttribute = newBooleanAttribute(nulsrcp, newId(nulsrcp, "secondAttribute"), FALSE); - Properties *theFirstAttributeProps = newProps(NULL, NULL, - nulsrcp, NULL, - newList(theFirstAttribute, ATTRIBUTE_LIST), - NULL, NULL, - nulsrcp, NULL, NULL, NULL, NULL, - NULL, NULL, - nulsrcp, NULL, - NULL, NULL); - Properties *theSecondAttributeProps = newProps(NULL, NULL, - nulsrcp, NULL, - newList(theSecondAttribute, ATTRIBUTE_LIST), - NULL, NULL, - nulsrcp, NULL, NULL, NULL, NULL, - NULL, NULL, - nulsrcp, NULL, - NULL, NULL); - AddNode *add1 = newAdd(nulsrcp, theId, NULL, theFirstAttributeProps); - AddNode *add2 = newAdd(nulsrcp, theId, NULL, theSecondAttributeProps); - Symbol *aSymbol; - - (void) newClass(&nulsrcp, theId, NULL, NULL); - aSymbol = lookup("aClassId"); - assert_true(aSymbol != NULL); - assert_true(length(aSymbol->fields.entity.props->attributes) == 0); - - addAttributes(add1, aSymbol); - assert_true(length(aSymbol->fields.entity.props->attributes) == 1); - - addAttributes(add2, aSymbol); - assert_true(length(aSymbol->fields.entity.props->attributes) == 2); -} - - -Ensure(Add, testAddDescription) { - Description *addedDescription = newDescription(nulsrcp, NULL, nulsrcp, NULL); - Properties *addProps = newProps(NULL, NULL, - nulsrcp, NULL, - NULL, NULL, /*description*/ NULL, - nulsrcp, NULL, NULL, NULL, NULL, - NULL, NULL, - nulsrcp, NULL, - NULL, NULL); - AddNode *add = newAdd(nulsrcp, NULL, NULL, addProps); - - Properties *originalProps = newProps(NULL, NULL, - nulsrcp, NULL, - NULL, NULL, /*description*/ NULL, - nulsrcp, NULL, NULL, NULL, NULL, - NULL, NULL, - nulsrcp, NULL, - NULL, NULL); - Symbol *symbol = newClassSymbol(newId(nulsrcp, "testAddId"), originalProps, NULL); - List list; /* Dummy list */ - - /* Start by testing when the target symbols props are NULL */ - /* Added description is NULL */ - addDescriptionCheck(add, symbol); - assert_true(symbol->fields.entity.props->description == NULL); - - /* Added description exists but empty */ - addProps->description = addedDescription; - addDescriptionCheck(add, symbol); - assert_true(symbol->fields.entity.props->description == NULL); - - addedDescription->checks = &list; - addDescriptionCheck(add, symbol); - assert_true(symbol->fields.entity.props->description->checks == &list); - - - /* Now test descriptionDoes */ - /* No description */ - originalProps->description = NULL; /* Reset to empty */ - addProps->description = NULL; /* Reset to empty */ - addDescription(add, symbol); - assert_true(symbol->fields.entity.props->description == NULL); - - /* Empty description */ - addProps->description = addedDescription; - addDescription(add, symbol); - assert_true(symbol->fields.entity.props->description == NULL); - - /* Description with does */ - originalProps->description = NULL; /* Reset to empty */ - addedDescription->does = &list; - addDescription(add, symbol); - assert_true(symbol->fields.entity.props->description->does == &list); -} - -TestSuite *addTests() { - TestSuite *suite = create_test_suite(); - add_test_with_context(suite, Add, testMultipleAddAttribute); - add_test_with_context(suite, Add, testAddDescription); - return suite; -} diff --git a/app/src/main/jni/terps/alan/alan3/compiler/add_x.h b/app/src/main/jni/terps/alan/alan3/compiler/add_x.h deleted file mode 100644 index ca12bfa..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/add_x.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _ADD_X_H_ -#define _ADD_X_H_ -/*----------------------------------------------------------------------*\ - - Add To Nodes Export - -\*----------------------------------------------------------------------*/ - -#include "add.h" - -/* USE: */ - - -/* DATA: */ - - -/* METHODS: */ - -extern AddNode *newAdd(Srcp srcp, - Id *id, - Id *parent, - Properties *props); -extern void addAdditions(void); -extern void dumpAdd(AddNode *add); - -#endif diff --git a/app/src/main/jni/terps/alan/alan3/compiler/adv.c b/app/src/main/jni/terps/alan/alan3/compiler/adv.c deleted file mode 100644 index ee8976e..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/adv.c +++ /dev/null @@ -1,471 +0,0 @@ -/*----------------------------------------------------------------------*\ - - adv.c - Adventure Node - -\*----------------------------------------------------------------------*/ - -/* Own: */ -#include "adv.h" - -/* Imports: */ -#include "alan.h" -#include "util.h" - -#include "lmList.h" -#include "smScan.h" - -#include "add_x.h" -#include "cla_x.h" -#include "cnt_x.h" -#include "context_x.h" -#include "ins_x.h" -#include "lst_x.h" -#include "scr_x.h" -#include "srcp_x.h" -#include "stm_x.h" -#include "stx_x.h" -#include "sym_x.h" -#include "vrb_x.h" -#include "whr_x.h" -#include "wrd_x.h" -#include "atr_x.h" -#include "rul_x.h" -#include "ifid_x.h" -#include "resource_x.h" -#include "dump_x.h" - - -#include "ext.h" /* EXT-nodes */ -#include "evt.h" /* EVT-nodes */ -#include "syn.h" /* SYN-nodes */ -#include "msg.h" /* MSG-nodes */ - -#include "sco.h" /* SCORES */ -#include "opt.h" /* OPTIONS */ -#include "options.h" /* OPTIONS */ - -#include "emit.h" -#include "encode.h" -#include "acode.h" - - - -/* PUBLIC */ -Adventure adv; - - -/* PRIVATE */ -static SourceFileEntry *sourceFileEntries; - - - -/*======================================================================*/ -void initAdventure(void) -{ - initSymbols(); - initClasses(); - initInstances(); - adv.ifids = initIfids(); -} - - -/*======================================================================*/ -void symbolizeAdventure() -{ - symbolizeClasses(); - symbolizeInstances(); - - symbolizeWhere(adv.whr); -} - - -/*----------------------------------------------------------------------*/ -static void analyzeStartAt(void) -{ - Context *context = newStartContext(); - - if (adv.whr != NULL) - switch (adv.whr->kind) { - case WHERE_AT: { - What *what = adv.whr->what->fields.wht.wht; - if (what->kind == WHAT_ID) { - instanceCheck(what->id, "START statement", "location"); - } else - lmLog(&adv.whr->srcp, 211, sevERR, ""); - break; - } - default: - lmLog(&adv.whr->srcp, 211, sevERR, ""); - break; - } - - analyzeStatements(adv.stms, context); -} - - -/*----------------------------------------------------------------------*/ -static void analyzePrompt(void) -{ - Context *context = newStartContext(); - if (adv.prompt != NULL) - analyzeStatements(adv.prompt, context); -} - - -/*----------------------------------------------------------------------*/ -static void analyzeSourceFilenames() { - List *currentFile; - int count = 0; - - sourceFileEntries = allocate(length(fileNames)*sizeof(SourceFileEntry)); - ITERATE(currentFile,fileNames) { - sourceFileEntries[count].fpos = ftell(txtfil); - sourceFileEntries[count].len = strlen(currentFile->member.str); - fprintf(txtfil, "%s", currentFile->member.str); - count++; - } -} - - -/*====================================================================== */ -void analyzeAdventure(void) -{ - addHero(&adv); - if (nowhere == NULL || nowhere->code != NOWHERE) - SYSERR("Nowhere != 1", nulsrcp); - - addLiteralInstance(); - - symbolizeAdventure(); - - addAdditions(); - addHeroContainer(); - - setupDefaultProperties(); - - analyzeAllAttributes(); /* Make sure attributes are analyzed - and typed before expressions */ - numberAllAttributes(); /* Then we can number and type check - inherited attributes */ - - calculateTransitiveContainerContents(); - - replicateInherited(); - - prepareWords(); /* Prepare words in the dictionary */ - prepareMessages(); /* Prepare standard and user messages */ - prepareScores(); /* Prepare score handling */ - - verbose("Syntax definitions"); - analyzeSyntaxes(); - - verbose("Verbs"); - analyzeVerbs(adv.vrbs, NULL); - - verbose("Classes"); - analyzeClasses(); - - verbose("Instances"); - analyzeInstances(); - theHero->fields.entity.props->whr = adv.whr; - - numberContainers(); - - verbose("Events"); - analyzeEvents(); - - verbose("Rules"); - analyzeRules(); - - verbose("Synonyms"); - analyzeSynonyms(); - - verbose("Message"); - analyzeMessages(); - - analyzePrompt(); - - analyzeStartAt(); - analyzeAllWords(); - adv.resources = analyzeResources(adv.resources); - - if (debugFlag) - analyzeSourceFilenames(); - - finalizeWords(); -} - - -/*----------------------------------------------------------------------*/ -static Aaddr generateSourceFileTable() { - int count = 0; - Aaddr adr = nextEmitAddress(); - - if (opts[OPTDEBUG].value) - for (count = 0; count < length(fileNames); count++) { - long fpos, len; - fpos = sourceFileEntries[count].fpos; - len = sourceFileEntries[count].len; - encode(&fpos, &len); - sourceFileEntries[count].fpos = fpos; - sourceFileEntries[count].len = len; - emitEntry(&sourceFileEntries[count], sizeof(SourceFileEntry)); - } - emit(EOF); - return adr; -} - - -/*======================================================================*/ -void generateAdventure(char acodeFileName[], - char textFileName[], - char dataFileName[]) -{ - Aaddr parameterNamesAddress = 0; - - initEmit(acodeFileName); /* Initialise code emit */ - initEncoding(textFileName, dataFileName); /* Initialise encoding of text */ - if (lmSeverity() > sevWAR) - return; - - acodeHeader.ifids = generateIfids(adv.ifids); - - verbose("Dictionary"); - acodeHeader.dictionary = generateAllWords(); - - verbose("SyntaxTable"); - acodeHeader.syntaxTableAddress = generateParseTable(); - - verbose("Parameter Mapping"); - if (debugFlag) - parameterNamesAddress = generateParameterNames(adv.stxs); - acodeHeader.parameterMapAddress = generateParameterMappingTable(); - emit(parameterNamesAddress); - - acodeHeader.maxParameters = 10; /* TODO calculate and move this to a better place */ - - verbose("Verbs"); - acodeHeader.verbTableAddress = generateVerbs(adv.vrbs); - - verbose("Classes"); - acodeHeader.classTableAddress = generateClasses(); - - verbose("Instances"); - generateInstances(&acodeHeader); - - verbose("Containers"); - acodeHeader.containerTableAddress = generateContainers(&acodeHeader); - - verbose("Scripts"); - acodeHeader.scriptTableAddress = generateScripts(&acodeHeader); - - verbose("Events"); - acodeHeader.eventTableAddress = generateEvents(&acodeHeader); - - verbose("Rules"); - acodeHeader.ruleTableAddress = generateRules(); - - generateScores(&acodeHeader); - - verbose("Messages"); - acodeHeader.messageTableAddress = gemsgs(); - - verbose("Character Encoding"); - acodeHeader.freq = gefreq(); /* Character frequencies */ - - - /* Options */ - generateOptions(&acodeHeader); - - /* Player prompt */ - if (adv.prompt != NULL) { - acodeHeader.prompt = nextEmitAddress(); /* Save ACODE address to prompt */ - generateStatements(adv.prompt); - emit0(I_RETURN); - } - - /* Start statements */ - acodeHeader.start = nextEmitAddress(); /* Save ACODE address to start */ - generateStatements(adv.stms); - emit0(I_RETURN); - - /* String & Set attribute initialisation tables */ - acodeHeader.stringInitTable = generateStringInit(); - acodeHeader.setInitTable = generateSetInit(); - - /* Source filename and line table */ - acodeHeader.sourceFileTable = generateSourceFileTable(); - acodeHeader.sourceLineTable = generateSrcps(); - - /* All resource files found so package them */ - generateResources(adv.resources); - - terminateEncoding(); - - finalizeEmit(); - - - /* Finally, include all text data and write the file header */ - copyTextDataToAcodeFile(dataFileName); - writeHeader(&acodeHeader); - - terminateEmit(); -} - - - - -/*====================================================================== */ -void dumpAdventure(enum dmpKd dmp) -{ - if (dmp&DUMP_ALL) - dmp |= (-1L&~DUMP_ADDRESSES); - - - put("ADV: "); indent(); - - put("synonyms: "); - if (dmp&DUMP_SYNONYMS) - dumpList(adv.syns, SYNONYM_LIST); - else - put("--"); - nl(); - - put("syntaxes: "); - if (dmp&DUMP_SYNTAXTABLE) - dumpList(adv.stxs, SYNTAX_LIST); - else - put("--"); - nl(); - - put("verbs: "); - if (dmp&DUMP_VERBTABLE) - dumpList(adv.vrbs, VERB_LIST); - else - put("--"); - nl(); - - put("classes: "); - if (dmp&DUMP_CLASSES) { - dumpList(adv.clas, CLASS_LIST); - nl(); - put("additions: "); - dumpList(adv.adds, ADD_LIST); - } else - put("--"); - nl(); - - put("instances: "); - if (dmp&DUMP_INSTANCES) - dumpList(adv.inss, INSTANCE_LIST); - else - put("--"); - nl(); - - put("containers: "); - if (dmp&DUMP_CONTAINERS) - dumpList(adv.cnts, CONTAINER_LIST); - else - put("--"); - nl(); - - put("events: "); - if (dmp&DUMP_EVENTS) - dumpList(adv.evts, EVENT_LIST); - else - put("--"); - nl(); - - put("rules: "); - if (dmp&DUMP_RULES) - dumpList(adv.ruls, RULE_LIST); - else - put("--"); - nl(); - - put("symbols: "); - if (dmp&DUMP_SYMBOLTABLE) - dumpSymbols(); - else - put("--"); - nl(); - - put("whr: "); - dumpWhere(adv.whr); - nl(); - - put("stms: "); - dumpList(adv.stms, STATEMENT_LIST); - out(); - nl(); - - put("ifids: "); - dumpList(adv.ifids, IFID_LIST); - out(); - nl(); -} - - -/*----------------------------------------------------------------------*/ -static void xmlStart(FILE *xmlFile) { - fprintf(xmlFile, " \n", adv.whr->what->fields.wht.wht->id->string); -} - -/*======================================================================*/ -void xmlAdventure(void) { - char *xmlFileName = strdup(adv.name); - FILE *xmlFile; - - if (xmlFlag) { - xmlFileName = realloc(xmlFileName, strlen(xmlFileName)+4+1); - strcat(xmlFileName, ".xml"); - - xmlFile = fopen(xmlFileName, "w"); - fprintf(xmlFile, "\n"); - fprintf(xmlFile, "\n"); - xmlClasses(xmlFile); - xmlInstances(xmlFile); - xmlStart(xmlFile); - fprintf(xmlFile, "\n"); - fclose(xmlFile); - } -} - - -/*====================================================================== - - summary() - - Print out a short summary of the adventure. - -*/ -void summary(void) -{ - char str[80]; - - lmSkipLines(8); - - lmLiPrint(""); - lmLiPrint(" Summary"); - lmLiPrint(" -------"); - if (verbCount != 0) { - (void)sprintf(str, " Verbs: %6d", verbCount); - lmLiPrint(str); - } - if (classCount != 0) { - (void)sprintf(str, " Classes: %6d", classCount); - lmLiPrint(str); - } - if (instanceCount != 0) { - (void)sprintf(str, " Instances: %6d", instanceCount); - lmLiPrint(str); - } - (void)sprintf(str , " Words: %6d", words[WRD_CLASSES]); - lmLiPrint(str); - (void)sprintf(str, " Acode: %6d words (%d bytes)", - (int)acodeHeader.size, (int)(acodeHeader.size*sizeof(Aword))); - lmLiPrint(str); - (void)sprintf(str, " Text data: %6d bytes", txtlen); - lmLiPrint(str); -} diff --git a/app/src/main/jni/terps/alan/alan3/compiler/adv.h b/app/src/main/jni/terps/alan/alan3/compiler/adv.h deleted file mode 100644 index 5be3216..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/adv.h +++ /dev/null @@ -1,33 +0,0 @@ -#ifndef _ADV_H_ -#define _ADV_H_ - -/* USE other definitions */ -#include "lst.h" -#include "whr.h" - -/* Types: */ - -typedef struct Adventure { - char *name; /* The basename of the adventure */ - List *syns; /* List of synonyms */ - List *stxs; /* List of syntax definitions */ - List *stxsStartingWithInstanceReference; /* List of syntax definitions that starts with an instance reference */ - List *vrbs; /* List of global verbs */ - List *clas; /* List of defined classes */ - List *adds; /* List of additions to the classes */ - List *inss; /* List of defined instances */ - List *evts; /* List of events */ - List *cnts; /* List of containers */ - List *ruls; /* List of rules */ - List *stringAttributes; /* List of string attributes to initialize */ - List *setAttributes; /* List of set attributes to initialize */ - List *prompt; /* Statements for the user prompt, if any */ - Where *whr; /* Where to start */ - List *stms; /* List of start statements */ - int *scores; /* Pointer to array of scores */ - List *msgs; /* List of error messages */ - List *resources; /* List of resources */ - List *ifids; /* List of IF identifications, incl. IFID */ -} Adventure; - -#endif diff --git a/app/src/main/jni/terps/alan/alan3/compiler/adv.mock b/app/src/main/jni/terps/alan/alan3/compiler/adv.mock deleted file mode 100644 index 09a2be8..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/adv.mock +++ /dev/null @@ -1,20 +0,0 @@ -#include - -#include "adv.h" - -/* USE other definitions */ -#include "dump.h" - - -/* Data: */ -Adventure adv; - - -/* FUNCTIONS: */ - -void initAdventure(void) { (void)mock(); } -void symbolizeAdventure(void) { (void)mock(); } -void analyzeAdventure(void) { (void)mock(); } -void generateAdventure(char acdfnm[], char txtfnm[], char datfnm[]) { (void)mock(acdfnm, txtfnm, datfnm); } -void dumpAdventure(enum dmpKd dmp) { (void)mock(dmp); } -void summary(void) { (void)mock(); } diff --git a/app/src/main/jni/terps/alan/alan3/compiler/advTest.c b/app/src/main/jni/terps/alan/alan3/compiler/advTest.c deleted file mode 100644 index a632a86..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/advTest.c +++ /dev/null @@ -1,79 +0,0 @@ -/*======================================================================*\ - * - * advTest.c - * - * Unit tests for ADV node in the Alan compiler - * - *======================================================================*/ - -#include "adv.c" - -#include - -#include "unitList.h" - -#include "wht_x.h" -#include "exp_x.h" -#include "id_x.h" - -static Srcp srcp = {2,3,4}; -static Id *unknownId; -static Id *instanceId; -static Id *locationInstanceId; -static Id *classId; - -Describe(Adventure); -BeforeEach(Adventure) { - unknownId = newId(srcp, "UnknownId"); - instanceId = newId(srcp, "InstanceId"); - locationInstanceId = newId(srcp, "LocationInstanceId"); - classId = newId(srcp, "ClassId"); - initAdventure(); - (void) newClass(&srcp, classId, NULL, NULL); - (void) newInstance(&srcp, instanceId, NULL, NULL); - (void) newInstance(&srcp, locationInstanceId, newId(srcp, "location"), NULL); -} -AfterEach(Adventure) {} - -Ensure(Adventure, can_analyze_start_at_here) { - adv.whr = newWhere(&srcp, FALSE, WHERE_HERE, NULL); - symbolizeAdventure(); - analyzeStartAt(); /* Can not Start At Here */ - assert_that(readSev(), is_equal_to(sevERR)); - assert_that(readEcode(), is_equal_to(211)); -} - -Ensure(Adventure, can_analyze_start_at_unknown_id) { - adv.whr = newWhere(&srcp, FALSE, WHERE_AT, - newWhatExpression(srcp, newWhatId(srcp, unknownId))); - symbolizeAdventure(); - assert_that(readSev(), is_equal_to(sevERR)); - assert_that(readEcode(), is_equal_to(310)); -} - -Ensure(Adventure, can_analyze_start_at_class) { - adv.whr = newWhere(&srcp, FALSE, WHERE_AT, - newWhatExpression(srcp, newWhatId(srcp, classId))); - symbolizeAdventure(); - analyzeStartAt(); /* Can not Start At Id not an instance */ - assert_that(readSev(), is_equal_to(sevERR)); - assert_that(readEcode(), is_equal_to(351)); -} - -Ensure(Adventure, can_analyze_start_at_not_location){ - adv.whr = newWhere(&srcp, FALSE, WHERE_AT, - newWhatExpression(srcp, newWhatId(srcp, instanceId))); - symbolizeAdventure(); - analyzeStartAt(); /* Can not Start At Id not inheriting from location */ - assert_that(readSev(), is_equal_to(sevERR)); - assert_that(readEcode(), is_equal_to(351)); -} - -Ensure(Adventure, can_analyze_start_at_location) { - adv.whr = newWhere(&srcp, FALSE, WHERE_AT, - newWhatExpression(srcp, newWhatId(srcp, locationInstanceId))); - symbolizeAdventure(); - analyzeStartAt(); /* Can Start At Id that's an instance */ - assert_that(readSev(), is_equal_to(sevNONE)); - assert_that(readEcode(), is_equal_to(0)); -} diff --git a/app/src/main/jni/terps/alan/alan3/compiler/adv_x.h b/app/src/main/jni/terps/alan/alan3/compiler/adv_x.h deleted file mode 100644 index 82491e0..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/adv_x.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef _ADV_X_H_ -#define _ADV_X_H_ - -/* OWN definitions */ -#include "adv.h" - -/* USE other definitions */ -#include "dump.h" - - -/* Data: */ -extern Adventure adv; - - -/* FUNCTIONS: */ - -extern void initAdventure(void); -extern void symbolizeAdventure(void); -extern void analyzeAdventure(void); -extern void generateAdventure(char acdfnm[], char txtfnm[], char datfnm[]); -extern void dumpAdventure(enum dmpKd dmp); -extern void xmlAdventure(void); -extern void summary(void); - - -#endif diff --git a/app/src/main/jni/terps/alan/alan3/compiler/alan.atg b/app/src/main/jni/terps/alan/alan3/compiler/alan.atg deleted file mode 100755 index fc93283..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/alan.atg +++ /dev/null @@ -1,757 +0,0 @@ -COMPILER adventure - -IGNORECASE - -CHARACTERS - tab = '\t'. /* 9 = tabulator */ - lf = '\n'. /* 10 = line feed */ - cr = '\r'. /* 13 = carriage return */ - - zero = '0'. - zeroToThree = zero + "123" . - octalDigit = zero + "1234567" . - nonZeroDigit = "123456789". - digit = '0' + nonZeroDigit . - hexDigit = digit + "ABCDEFabcdef" . - letter = 'A' .. 'Z' + 'a' .. 'z' + '_' + '$' + - '\u00e0'..'\u00f6' + '\u00f8'..'\u00fe'. - - char = ANY - "'" - '\\' - cr - lf. - stringChar = ANY - "\"". - -TOKENS - Identifier = (letter {letter | digit | '_'}) - | ('\'' {char} '\''). - Integer = digit {digit}. - STRING = '"' {stringChar | "\"\"" } '"'. - Import = "import". - -COMMENTS FROM "--" TO lf - -IGNORE lf + cr + tab - -PRODUCTIONS - - adventure = optionaloptions declarations start - . - - optionaloptions = - | genSym0 options - . - - genSym0 = "options" - | "option" - . - - options = option - | options option - . - - option = ID "." - | ID ID "." - | ID Integer "." - . - - declarations = - | declarations declaration - . - - declaration = "import" - | prompt - | messages - | class - | instance - | rule - | synonyms - | syntax - | verb - | addition - | event - . - - prompt = "prompt" statements - . - - attributes = attributedefinition "." - | attributes attributedefinition "." - . - - attributedefinition = ID - | "not" ID - | ID STRING - | ID ID - | ID optionalminus Integer - | ID "{" optionalmembers "}" - . - - optionalmembers = - | setmembers - . - - setmembers = setmember - | setmembers "," setmember - . - - setmember = what - | STRING - | optionalminus Integer - . - - synonyms = "synonyms" synonymlist - . - - synonymlist = synonymdeclaration - | synonymlist synonymdeclaration - . - - synonymdeclaration = idlist "=" ID "." - . - - messages = "message" messagelist - . - - messagelist = message - | messagelist message - . - - message = ID ":" statements - . - - syntax = "syntax" syntaxlist - . - - syntaxlist = syntaxitem - | syntaxlist syntaxitem - . - - syntaxitem = ID "=" syntaxelements optionalsyntaxrestrictions - . - - syntaxelements = syntaxelement - | syntaxelements syntaxelement - . - - syntaxelement = ID - | "(" ID ")" optionalindicators - . - - optionalindicators = - | optionalindicators indicator - . - - indicator = "*" - | "!" - . - - syntaxrestrictionclauses = syntaxrestriction - | syntaxrestrictionclauses "and" - syntaxrestriction - . - - syntaxrestriction = ID "isa" restrictionclass "else" statements - . - - restrictionclass = ID - | "container" - . - - optionalsyntaxrestrictions = "." - | "where" syntaxrestrictionclauses - . - - verb = verbheader verbbody verbtail - . - - verbheader = optionalmeta "verb" idlist - . - - optionalmeta = - | "meta" - . - - verbbody = simpleverbbody - | verbalternatives - . - - verbalternatives = verbalternative - | verbalternatives verbalternative - . - - verbalternative = "when" ID simpleverbbody - . - - simpleverbbody = optionalchecks optionaldoes - . - - verbtail = "end" "verb" optionalid "." - . - - optionalchecks = - | "check" statements - | "check" checklist - . - - checklist = check - | checklist "and" check - . - - check = expression "else" statements - . - - optionaldoes = - | does - . - - does = "does" optionalqual statements - . - - class = "every" ID optionalheritage properties classtail - . - - classtail = "end" "every" optionalid genSym1 - . - - genSym1 = - | "." - . - - addition = "add" "to" genSym2 ID optionalheritage properties - addtail - . - - genSym2 = - | "every" - . - - addtail = "end" "add" genSym3 optionalid genSym4 - . - - genSym3 = - | "to" - . - - genSym4 = - | "." - . - - instance = "the" ID optionalheritage properties instancetail - . - - instancetail = "end" "the" optionalid genSym5 - . - - genSym5 = - | "." - . - - optionalheritage = - | heritage - . - - heritage = "isa" ID genSym6 - . - - genSym6 = - | "." - . - - properties = - | properties property - . - - property = where genSym7 - | containerproperties - | description - | genSym8 articleorform - | name - | pronoun - | initialize - | entered - | mentioned - | "definite" articleorform - | "negative" articleorform - | is attributes - | script - | exit - | verb - . - - genSym7 = - | "." - . - - genSym8 = - | "indefinite" - . - - exit = "exit" idlist "to" ID optionalexitbody "." - . - - optionalexitbody = - | optionalchecks optionaldoes "end" "exit" - optionalid - . - - is = "is" - | "are" - | "has" - | "can" - . - - optionaldescription = - | description - . - - description = "description" optionalchecks optionaldoes - | "description" statements - . - - articleorform = article - | form - . - - article = "article" - | "article" statements - . - - form = "form" - | "form" statements - . - - entered = "entered" statements - . - - initialize = "initialize" statements - . - - mentioned = "mentioned" statements - . - - name = "name" ids optionalfullstop - . - - pronoun = "pronoun" idlist optionalfullstop - . - - optionalfullstop = - | "." - . - - containerproperties = genSym9 optionallyopaque "container" - containerbody - . - - genSym9 = - | "with" - . - - optionallyopaque = - | "opaque" - . - - containerbody = optionaltaking optionallimits optionalheader - optionalempty optionalextract - | "." - . - - optionaltaking = - | "taking" ID "." - . - - optionallimits = - | "limits" limits - . - - limits = limit - | limits limit - . - - limit = limitattribute elseorthen statements - . - - elseorthen = "else" - | "then" - . - - limitattribute = attributedefinition - | "count" Integer - . - - optionalheader = - | "header" statements - . - - optionalempty = - | "else" statements - . - - optionalextract = - | "extract" optionalchecks optionaldoes - | "extract" statements - . - - event = eventheader statements eventtail - . - - eventheader = "event" ID - . - - eventtail = "end" "event" optionalid "." - . - - script = "script" ID genSym10 optionaldescription steplist - . - - genSym10 = - | "." - . - - steplist = step - | steplist step - . - - step = "step" statements - | "step" "after" expression genSym11 statements - | "step" "wait" "until" expression genSym12 statements - . - - genSym11 = - | "." - . - - genSym12 = - | "." - . - - rule = "when" expression then statements optionalendwhen - . - - then = "=>" - | "then" - . - - optionalendwhen = - | "end" "when" genSym13 - . - - genSym13 = - | "." - . - - start = "start" where "." optionalstatements - . - - optionalstatements = - | statements - . - - statements = statement - | statements statement - . - - statement = outputstatement - | specialstatement - | manipulationstatement - | actorstatement - | eventstatement - | assignmentstatement - | repetitionstatement - | conditionalstatement - . - - outputstatement = STRING - | "describe" what "." - | "say" sayform expression "." - | "list" primary "." - | "show" ID "." - | "play" ID "." - | "style" ID "." - . - - sayform = - | "the" - | "an" - | "it" - | "no" - . - - manipulationstatement = "empty" primary optionalwhere "." - | "locate" primary where "." - | "include" primary "in" what "." - | "exclude" primary "from" what "." - . - - eventstatement = "cancel" what "." - | "schedule" what optionalwhere "after" - expression "." - . - - assignmentstatement = "make" primary something "." - | "strip" optionalfirstorlast - optionalexpression - optionalwordorcharacter "from" expression - optionalinto "." - | "increase" attributereference - optionalbyclause "." - | "decrease" attributereference - optionalbyclause "." - | "set" attributereference "to" expression - "." - . - - optionalbyclause = - | "by" expression - . - - optionalfirstorlast = - | "first" - | "last" - . - - optionalwordorcharacter = - | "word" - | "words" - | "character" - | "characters" - . - - optionalinto = - | "into" expression - . - - conditionalstatement = ifstatement - | dependingstatement - . - - ifstatement = "if" expression "then" statements - optionalelsiflist optionalelsepart "end" "if" - "." - . - - optionalelsiflist = - | elsiflist - . - - elsiflist = "elsif" expression "then" statements - | elsiflist "elsif" expression "then" statements - . - - optionalelsepart = - | "else" statements - . - - dependingstatement = "depending" "on" primary dependcases "end" - genSym14 "." - . - - genSym14 = "depend" - | "depending" - . - - dependcases = dependcase - | dependcases dependcase - . - - dependcase = "else" statements - | righthandside "then" statements - . - - repetitionstatement = foreach ID optionalloopfilters "do" - statements "end" foreach genSym15 - . - - genSym15 = - | "." - . - - optionalloopfilters = - | filters - | "between" arithmetic "and" arithmetic - . - - foreach = "for" - | "each" - | "for" "each" - . - - actorstatement = "stop" what "." - | "use" "script" ID optionalforactor "." - . - - optionalforactor = - | "for" what - . - - specialstatement = "quit" "." - | "look" "." - | "save" "." - | "restore" "." - | "restart" "." - | "score" optionalinteger "." - | "transcript" onoroff "." - | "system" STRING "." - | "visits" Integer "." - . - - onoroff = "on" - | "off" - . - - optionalexpression = - | expression - . - - expression = term - | expression "or" term - . - - term = factor - | term "and" factor - . - - factor = arithmetic - | factor optionalnot where - | factor optionalnot relop arithmetic - | factor optionalnot "contains" arithmetic - | factor optionalnot "between" arithmetic "and" - arithmetic - . - - arithmetic = primary - | aggregate filters - | primary "isa" ID - | primary is something - | arithmetic binop primary - . - - filters = filter - | filters "," filter - . - - filter = optionalnot where - | optionalnot "isa" ID - | is something - . - - righthandside = filter - | optionalnot relop primary - | optionalnot "contains" factor - | optionalnot "between" arithmetic "and" - arithmetic - . - - primary = STRING - | what - | "score" - | optionalminus Integer - | "{" optionalmembers "}" - | "(" expression ")" - | "random" optionaltransitivity "in" primary - | "random" primary "to" primary - . - - aggregate = "count" - | aggregator "of" ID - . - - aggregator = "max" - | "min" - | "sum" - . - - something = optionalnot ID - . - - what = simplewhat - | attributereference - . - - simplewhat = ID - | "this" - | "current" "actor" - | "current" "location" - . - - attributereference = ID "of" what - | what ":" ID - . - - optionalwhere = - | where - . - - where = optionaltransitivity "here" - | optionaltransitivity "nearby" - | optionaltransitivity "at" primary - | optionaltransitivity "in" primary - | optionaltransitivity "near" what - . - - binop = "+" - | "-" - | "*" - | "/" - . - - relop = "<>" - | "=" - | "==" - | ">=" - | "<=" - | ">" - | "<" - . - - optionalqual = - | "before" - | "after" - | "only" - . - - optionalnot = - | "not" - . - - optionaltransitivity = - | "transitively" - | "directly" - | "indirectly" - . - - optionalid = - | ID - . - - ids = ID - | ids ID - . - - idlist = ID - | idlist "," ID - . - - optionalinteger = - | Integer - . - - optionalminus = - | "-" - . - - ID = Identifier - | "location" - | "actor" - | "opaque" - | "visits" - | "contains" - | "on" - | "it" - | "of" - | "first" - | "into" - | "taking" - | "off" - . - -END adventure. - diff --git a/app/src/main/jni/terps/alan/alan3/compiler/alan.c b/app/src/main/jni/terps/alan/alan3/compiler/alan.c deleted file mode 100644 index d6803ad..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/alan.c +++ /dev/null @@ -1,486 +0,0 @@ -/*----------------------------------------------------------------------*\ - - alan.c - - Alan compiler main program unit - -\*----------------------------------------------------------------------*/ - -#include "sysdep.h" -#include "types.h" -#include "util.h" - -#ifdef __sun__ -#include -#endif - -#include "alan.h" - -/* IMPORTS */ -#include "alan.version.h" -#include "opt.h" -#include "dump_x.h" -#include "lmList.h" -#include "pmParse.h" -#include "smScan.h" -#include "options.h" - -#include "srcp_x.h" -#include "adv_x.h" - -#ifdef WINGUI -#include -#endif - - -/* PUBLIC DATA */ -FILE *txtfil; /* File of collected text data */ -FILE *datfil; /* File of encoded text */ - -int fileNo = 0; /* File number to use next */ -long counter = 0; /* Number of new's so far, for verbose */ -#ifdef WINGUI -Bool guiMode = FALSE; /* Using the GUI? Or console? */ -#endif - - -/* PRIVATE */ - -static void *heap; /* Address to first free heap area - before */ - - -/* Timing */ -#include "timing.h" - - -static TIBUF tbuf; -static TIBUF totalTime; -static TIBUF compilationTime; - -static struct { - long int pars; - long int sem; - long int gen; - long int comp; - long int tot; -} tim; - - - -/*----------------------------------------------------------------------*/ -static void startTotalTiming(void) -{ - tistart(&totalTime); -} - - -/*----------------------------------------------------------------------*/ -static void startTimingCompilation(void) -{ - tistart(&compilationTime); -} - - -/*----------------------------------------------------------------------*/ -static void startTiming(void) -{ - tistart(&tbuf); -} - - -/*----------------------------------------------------------------------*/ -static void endParseTiming(void) -{ - tistop(&tbuf); - tim.pars = tbuf.pu_elapsed; -} - - -/*----------------------------------------------------------------------*/ -static void endSemanticsTiming(void) -{ - tistop(&tbuf); - tim.sem = tbuf.pu_elapsed; -} - - -/*----------------------------------------------------------------------*/ -static void endGenerationTiming(void) -{ - tistop(&tbuf); - tim.gen = tbuf.pu_elapsed; -} - - -/*----------------------------------------------------------------------*/ -static void endCompilationTiming(void) -{ - tistop(&compilationTime); - tim.comp = compilationTime.pu_elapsed; -} - - -/*----------------------------------------------------------------------*/ -static void endTotalTiming(void) -{ - tistop(&totalTime); - tim.tot = totalTime.pu_elapsed; -} - - -/*----------------------------------------------------------------------*/ -static void printTimes(void) -{ - char str[80]; - - lmSkipLines(8); - lmLiPrint(""); - lmLiPrint( " Timing"); - lmLiPrint( " ------"); - (void)sprintf(str, " Parse Time: %6ld", tim.pars); - lmLiPrint(str); - if (tim.sem != 0) { - (void)sprintf(str, " Analysis Time: %6ld", tim.sem); - lmLiPrint(str); - } - if (tim.gen != 0) { - (void)sprintf(str, " Code Generation Time: %6ld", tim.gen); - lmLiPrint(str); - } - (void)sprintf(str, " ------------------------------"); - lmLiPrint(str); - (void)sprintf(str, " Compilation Time: %6ld", tim.comp); - lmLiPrint(str); - lmLiPrint(""); - (void)sprintf(str, " Total Time: %6ld", tim.tot); - lmLiPrint(str); -} - - - -/*----------------------------------------------------------------------*/ -static void statistics(void) -{ - int lins; - char str[80]; - - lmSkipLines(7); - lmLiPrint(""); - - lins = scannedLines(); - if (fileNo > 1) - (void)sprintf(str, " %d source lines read from %d files.", lins, fileNo); - else - (void)sprintf(str, " %d source lines read.", lins); - lmLiPrint(str); - lmLiPrint(""); - - if (tim.tot != 0 && tim.comp != 0) { - (void)sprintf(str, " %d lines/CPUminute.", - (int)(60L*1000L*(long)lins/tim.comp)); - lmLiPrint(str); - lmLiPrint(""); - } - - (void)sprintf(str, " Estimated dynamic memory usage = %ld bytes.", - (long int)((char *)malloc(10000)-(char *)heap)); - lmLiPrint(str); - (void)sprintf(str, " Calculated - \"\" - = %ld bytes.", - allocated); - lmLiPrint(str); - lmLiPrint(""); -} - - -/* -- local variables for main() -- */ - -static char srcfnm[255]; /* File name of source file */ -static char txtfnm[255]; /* - " - of collected text file */ -static char datfnm[255]; /* - " - of encoded data file */ -static char acdfnm[255]; /* - " - of ACODE file */ -static char lstfnm[255]; /* - " - of listing file */ - - -/*---------------------------------------------------------------------- - - prepareNames() - - Prepare all file names needed. - - */ -static void prepareFileNames(void) -{ - /* Save source file name */ - strcpy(srcfnm, srcptr); - - /* -- Then strip directory -- */ - if((srcptr = strrchr(srcfnm, ']')) == NULL - && (srcptr = strrchr(srcfnm, '>')) == NULL - && (srcptr = strrchr(srcfnm, '/')) == NULL - && (srcptr = strrchr(srcfnm, '\\')) == NULL - && (srcptr = strrchr(srcfnm, ':')) == NULL) - srcptr = &srcfnm[0]; - else - srcptr++; - /* Save the basename as the name of the adventure */ - adv.name = strdup(srcptr); - - /* -- check for .ALAN suffix and add one if missing -- */ - if(strrchr(srcptr, '.') == NULL) { /* Point to last '.' */ -#ifdef __dos__ - strcat(srcptr, ".ala"); /* Was there none add */ -#else -#ifndef __mac__ - strcat(srcptr, ".alan"); /* Was there none add */ -#endif -#endif - } else { - char *p = strrchr(adv.name, '.'); - *p = '\0'; - } - - /* -- create list file name -- */ - strcpy(lstfnm, adv.name); - strcat(lstfnm, ".lis"); - - /* -- create string data file names -- */ - strcpy(txtfnm, adv.name); - strcat(txtfnm, ".tmp"); - strcpy(datfnm, adv.name); - strcat(datfnm, ".dat"); - - /* -- create ACODE file name -- */ - strcpy(acdfnm, adv.name); - strcat(acdfnm, ".a3c"); -} - - -/*----------------------------------------------------------------------*/ -static void bookmarkHeap() { - heap = malloc((size_t)10000); /* Remember where heap starts */ - free(heap); -} - - -/*----------------------------------------------------------------------*/ -static void setupCompilation() { - lmLiInit(alan.shortHeader, srcfnm, lm_ENGLISH_Messages); - setCharacterSet(charset); - - if (!smScanEnter(nulsrcp, srcfnm, FALSE)) { - /* Failed to open the source file */ - createListingOnScreen(liMSG, sevALL); - terminate(EXIT_FAILURE); - } -} - - -/*----------------------------------------------------------------------*/ -static void parse() { - verbose("Parsing"); - - startTimingCompilation(); /* Start timing compilation */ - - txtfil = fopen(txtfnm, "w+"); /* Open a temporary text file */ - if (!txtfil) { - char errorString[1000]; - sprintf(errorString, "Could not open output file '%s' for writing", txtfnm); - SYSERR(errorString, nulsrcp); - } - - /* First initialise */ - initAdventure(); - - /* Then parse the program and build internal representation */ - startTiming(); - pmParse(); - endParseTiming(); /* End of parsing pass */ -} - - -/*----------------------------------------------------------------------*/ -static void analyze() { - verbose("Analyzing"); - startTiming(); - analyzeAdventure(); /* Analyze the adventure */ - endSemanticsTiming(); /* End of semantic pass */ - /* All text is now output so close text file */ - fclose(txtfil); - -} - - -/*----------------------------------------------------------------------*/ -static void generate() { - /* OK so far ? */ - if (lmSeverity() < sevERR) { - /* Yes, so generate an adventure */ - verbose("Generating"); - - opts[OPTDEBUG].value = debugFlag; /* Debugging enabled? */ - if (packFlag) /* Force packing */ - opts[OPTPACK].value = TRUE; - startTiming(); - generateAdventure(acdfnm, txtfnm, datfnm); - endGenerationTiming(); /* End of generating pass */ - } else { - lmLog(NULL, 999, sevINF, ""); - } -} - - -/*----------------------------------------------------------------------*/ -static void removeTemporaryFiles() { - if (dumpFlags == 0) { - unlink(txtfnm); - unlink(datfnm); - } -} - - -/*----------------------------------------------------------------------*/ -static void dumpAndExitAfterPhase(int phase) { - if ((dumpFlags&phase) != 0) { - createListingOnScreen(liTINY, 0); - lmSkipLines(0); - dumpAdventure(dumpFlags); - terminate(EXIT_FAILURE); - } -} - - -/*----------------------------------------------------------------------*/ -static void listingOnFile() { - if (listingFlag) { - createListingOnFile(lstfnm, lcount, ccount, fullFlag?liFULL:liTINY, sevALL); - if (dumpFlags) { - lmSkipLines(0); - dumpAdventure(dumpFlags); - } - if (summaryFlag) { - if (lmSeverity() < sevERR) - summary(); - statistics(); - } - } -} - - -/*----------------------------------------------------------------------*/ -static void listingOnScreen() { - lmSev sevs; - - if (verboseFlag) printf("\n"); - - /* Check what messages to show on the screen */ - sevs = sevALL; - if (!warningFlag) - sevs &= ~sevWAR; - if (!infoFlag) - sevs &= ~sevINF; - createListingOnScreen(listingFlag?liTINY:(fullFlag?liFULL:liTINY), sevs); - - if (dumpFlags != 0 && !listingFlag) { - lmSkipLines(0); - dumpAdventure(dumpFlags); - } - if (summaryFlag) { - if (lmSeverity() < sevERR) - summary(); - endTotalTiming(); /* Stop timer */ - printTimes(); - statistics(); - } -} - -/* Import of dump functions to be used in initDumpers */ -extern void dumpAdd(); -extern void dumpAlternative(); -extern void dumpAttribute(); -extern void dumpCheck(); -extern void dumpClass(); -extern void dumpElement(); -extern void dumpEvent(); -extern void dumpExit(); -extern void dumpExpression(); -extern void dumpId(); -extern void dumpIfid(); -extern void dumpInstance(); -extern void dumpLimit(); -extern void dumpPointer(); -extern void dumpRestriction(); -extern void dumpRule(); -extern void dumpScript(); -extern void dumpStatement(); -extern void dumpStep(); -extern void dumpSyntax(); -extern void dumpSynonym(); -extern void dumpVerb(); - -extern void xmlClass(); -extern void xmlInstance(); -extern void xmlExit(); - -/*----------------------------------------------------------------------*/ -static void initDumpers(void) { - addListNodeDumper(ADD_LIST, &dumpAdd); - addListNodeDumper(ALTERNATIVE_LIST, &dumpAlternative); - addListNodeDumper(ATTRIBUTE_LIST, &dumpAttribute); - addListNodeDumper(CHECK_LIST, &dumpCheck); - addListNodeDumper(CLASS_LIST, &dumpClass); - addListNodeDumper(CONTAINER_LIST, &dumpPointer); - addListNodeDumper(ELEMENT_LIST, &dumpElement); - addListNodeDumper(EVENT_LIST, &dumpEvent); - addListNodeDumper(EXIT_LIST, &dumpExit); - addListNodeDumper(EXPRESSION_LIST, &dumpExpression); - addListNodeDumper(ID_LIST, &dumpId); - addListNodeDumper(IFID_LIST, &dumpIfid); - addListNodeDumper(INSTANCE_LIST, &dumpInstance); - addListNodeDumper(LIMIT_LIST, &dumpLimit); - addListNodeDumper(NAME_LIST, &dumpId); - addListNodeDumper(RESTRICTION_LIST, &dumpRestriction); - addListNodeDumper(RULE_LIST, &dumpRule); - addListNodeDumper(SCRIPT_LIST, &dumpScript); - addListNodeDumper(STATEMENT_LIST, &dumpStatement); - addListNodeDumper(STEP_LIST, &dumpStep); - addListNodeDumper(SYNTAX_LIST, &dumpSyntax); - addListNodeDumper(SYNONYM_LIST, &dumpSynonym); - addListNodeDumper(VERB_LIST, &dumpVerb); - - addXmlNodeDumper(CLASS_LIST, &xmlClass); - addXmlNodeDumper(INSTANCE_LIST, &xmlInstance); - addXmlNodeDumper(EXIT_LIST, &xmlExit); -} - - -/************************************************************************/ -void compile(void) { - - initDumpers(); - - startTotalTiming(); - prepareFileNames(); - - bookmarkHeap(); - setupCompilation(); - parse(); - dumpAndExitAfterPhase(DUMP_AFTER_PARSE); - analyze(); - dumpAndExitAfterPhase(DUMP_AFTER_ANALYSIS); - generate(); - endCompilationTiming(); - removeTemporaryFiles(); - xmlAdventure(); - listingOnFile(); - listingOnScreen(); - lmLiTerminate(); - -#ifdef MALLOC - if (malloc_verify() == 0) printf("Error in heap!\n"); -#endif - - if (lmSeverity() < sevERR) - terminate(EXIT_SUCCESS); - else - terminate(EXIT_FAILURE); -} diff --git a/app/src/main/jni/terps/alan/alan3/compiler/alan.coco b/app/src/main/jni/terps/alan/alan3/compiler/alan.coco deleted file mode 100755 index d012a97..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/alan.coco +++ /dev/null @@ -1,701 +0,0 @@ - -adventure : optional_options declarations start ; - -optional_options : - | __genSym0 options - ; - -__genSym0 : 'OPTIONS' - | 'OPTION' - ; - -options : option - | options option - ; - -option : ID '.' - | ID ID '.' - | ID INTEGER '.' - ; - -declarations : - | declarations declaration - ; - -declaration : messages - | class - | instance - | rule - | synonyms - | syntax - | verb - | addition - | event - ; - -attributes : attribute_definition '.' - | attributes attribute_definition '.' - ; - -attribute_definition : ID - | 'NOT' ID - | ID optional_minus INTEGER - | ID STRING - | ID ID - | ID '{' optional_members '}' - ; - -optional_members : - | set_members - ; - -set_members : set_member - | set_members ',' set_member - ; - -set_member : ID - | optional_minus INTEGER - | STRING - ; - -synonyms : 'SYNONYMS' synonym_list - ; - -synonym_list : synonym_declaration - | synonym_list synonym_declaration - ; - -synonym_declaration : id_list '=' ID '.' - ; - -messages : 'MESSAGE' message_list - ; - -message_list : message - | message_list message - ; - -message : ID ':' statements - ; - -syntax : 'SYNTAX' syntax_list - ; - -syntax_list : syntax_item - | syntax_list syntax_item - ; - -syntax_item : ID '=' syntax_elements optional_syntax_restrictions - ; - -syntax_elements : syntax_element - | syntax_elements syntax_element - ; - -syntax_element : ID - | '(' ID ')' optional_indicators - ; - -optional_indicators : - | optional_indicators indicator - ; - -indicator : '*' - | '!' - ; - -syntax_restriction_clauses : syntax_restriction - | syntax_restriction_clauses 'AND' - syntax_restriction - ; - -syntax_restriction : ID 'ISA' restriction_class 'ELSE' statements - ; - -restriction_class : ID - | 'CONTAINER' - ; - -optional_syntax_restrictions : '.' - | 'WHERE' syntax_restriction_clauses - ; - -verb : verb_header verb_body verb_tail - ; - -verb_header : 'VERB' id_list - ; - -verb_body : simple_verb_body - | verb_alternatives - ; - -verb_alternatives : verb_alternative - | verb_alternatives verb_alternative - ; - -verb_alternative : 'WHEN' ID simple_verb_body - ; - -simple_verb_body : optional_checks optional_does - ; - -verb_tail : 'END' 'VERB' optional_id '.' - ; - -optional_checks : - | 'CHECK' statements - | 'CHECK' check_list - ; - -check_list : check - | check_list 'AND' check - ; - -check : expression 'ELSE' statements - ; - -optional_does : - | does - ; - -does : 'DOES' optional_qual statements - ; - -class : 'EVERY' ID optional_heritage properties class_tail - ; - -class_tail : 'END' 'EVERY' optional_id __genSym1 - ; - -__genSym1 : - | '.' - ; - -addition : 'ADD' 'TO' __genSym2 ID optional_heritage properties - add_tail - ; - -__genSym2 : - | 'EVERY' - ; - -add_tail : 'END' 'ADD' __genSym3 optional_id __genSym4 - ; - -__genSym3 : - | 'TO' - ; - -__genSym4 : - | '.' - ; - -instance : 'THE' ID optional_heritage properties instance tail - ; - -instance tail : 'END' 'THE' optional_id __genSym5 - ; - -__genSym5 : - | '.' - ; - -optional_heritage : - | heritage - ; - -heritage : 'ISA' ID __genSym6 - ; - -__genSym6 : - | '.' - ; - -properties : - | properties property - ; - -property : where __genSym7 - | container_properties - | description - | __genSym8 article_or_form - | name - | entered - | mentioned - | 'DEFINITE' article_or_form - | is attributes - | script - | exit - | verb - ; - -__genSym7 : - | '.' - ; - -__genSym8 : - | 'INDEFINITE' - ; - -exit : 'EXIT' id_list 'TO' ID optional_exit_body '.' - ; - -optional_exit_body : - | optional_checks optional_does 'END' 'EXIT' - optional_id - ; - -optional_attributes : - | optional_attributes is attributes - ; - -is : 'IS' - | 'ARE' - | 'HAS' - | 'CAN' - ; - -optional_description : - | description - ; - -description : 'DESCRIPTION' optional_checks optional_does - | 'DESCRIPTION' statements - ; - -article_or_form : article - | form - ; - -article : 'ARTICLE' - | 'ARTICLE' statements - ; - -form : 'FORM' - | 'FORM' statements - ; - -entered : 'ENTERED' statements - ; - -mentioned : 'MENTIONED' statements - ; - -optional_names : - | optional_names name - ; - -name : 'NAME' ids optional_full_stop - ; - -optional_full_stop : - | '.' - ; - -container_properties : __genSym9 optionally_opaque 'CONTAINER' - container_body - ; - -__genSym9 : - | 'WITH' - ; - -optionally_opaque : - | 'OPAQUE' - ; - -container_body : optional_taking optional_limits optional_header - optional_empty optional_extract - | '.' - ; - -optional_taking : - | 'TAKING' ID '.' - ; - -optional_limits : - | 'LIMITS' limits - ; - -limits : limit - | limits limit - ; - -limit : limit_attribute else_or_then statements - ; - -else_or_then : 'ELSE' - | 'THEN' - ; - -limit_attribute : attribute definition - | 'COUNT' INTEGER - ; - -optional_header : - | 'HEADER' statements - ; - -optional_empty : - | 'ELSE' statements - ; - -optional_extract : - | 'EXTRACT' optional_checks optional_does - | 'EXTRACT' statements - ; - -event : event_header statements event_tail - ; - -event_header : 'EVENT' ID - ; - -event_tail : 'END' 'EVENT' optional_id '.' - ; - -script : 'SCRIPT' ID __genSym10 optional_description step_list - ; - -__genSym10 : - | '.' - ; - -step_list : step - | step_list step - ; - -step : 'STEP' statements - | 'STEP' 'AFTER' INTEGER statements - | 'STEP' 'WAIT' 'UNTIL' expression statements - ; - -rule : 'WHEN' expression then statements optional_end_when - ; - -then : '=>' - | 'THEN' - ; - -optional_end_when : - | 'END' 'WHEN' __genSym11 - ; - -__genSym11 : - | '.' - ; - -start : 'START' where '.' optional_statements - ; - -optional_statements : - | statements - ; - -statements : statement - | statements statement - ; - -statement : output_statement - | special_statement - | manipulation_statement - | actor_statement - | event_statement - | assignment_statement - | repetition_statement - | conditional_statement - ; - -output_statement : STRING - | 'DESCRIBE' what '.' - | 'SAY' say_form expression '.' - | 'LIST' what '.' - | 'SHOW' ID '.' - ; - -say_form : - | 'THE' - | 'AN' - ; - -manipulation_statement : 'EMPTY' what optional_where '.' - | 'LOCATE' what where '.' - | 'INCLUDE' primary 'IN' what '.' - | 'REMOVE' primary 'FROM' what '.' - ; - -event_statement : 'CANCEL' ID '.' - | 'SCHEDULE' ID optional_where 'AFTER' expression - '.' - ; - -assignment_statement : 'MAKE' what something '.' - | 'STRIP' optional_first_or_last - optional_expression - optional_word_or_character 'FROM' expression - optional_into '.' - | 'INCREASE' attribute_reference - optional_by_clause '.' - | 'DECREASE' attribute_reference - optional_by_clause '.' - | 'SET' attribute_reference 'TO' expression - '.' - ; - -optional_by_clause : - | 'BY' expression - ; - -optional_first_or_last : - | 'FIRST' - | 'LAST' - ; - -optional_word_or_character : - | 'WORD' - | 'WORDS' - | 'CHARACTER' - | 'CHARACTERS' - ; - -optional_into : - | 'INTO' expression - ; - -conditional_statement : if_statement - | depending_statement - ; - -if_statement : 'IF' expression 'THEN' statements - optional_elsif_list optional_else_part 'END' 'IF' - '.' - ; - -optional_elsif_list : - | elsif_list - ; - -elsif_list : 'ELSIF' expression 'THEN' statements - | elsif_list 'ELSIF' expression 'THEN' statements - ; - -optional_else_part : - | 'ELSE' statements - ; - -depending_statement : 'DEPENDING' 'ON' primary depend_cases 'END' - __genSym12 '.' - ; - -__genSym12 : 'DEPEND' - | 'DEPENDING' - ; - -depend_cases : depend_case - | depend_cases depend_case - ; - -depend_case : 'ELSE' statements - | right_hand_side ':' statements - ; - -repetition_statement : for_each ID optional_loop_restrictions 'DO' - statements 'END' for_each __genSym13 - ; - -__genSym13 : - | '.' - ; - -optional_loop_restrictions : - | filters - ; - -for_each : 'FOR' - | 'EACH' - | 'FOR' 'EACH' - ; - -actor_statement : 'STOP' what '.' - | 'USE' 'SCRIPT' ID optional_for_actor '.' - ; - -optional_for_actor : - | 'FOR' what - ; - -special_statement : 'QUIT' '.' - | 'LOOK' '.' - | 'SAVE' '.' - | 'RESTORE' '.' - | 'RESTART' '.' - | 'SCORE' optional_INTEGER '.' - | 'VISITS' INTEGER '.' - | 'SYSTEM' STRING '.' - ; - -optional_expression : - | expression - ; - -expression : term - | expression 'OR' term - ; - -term : factor - | term 'AND' factor - ; - -factor : arithmetic - | factor optional_not where - | factor optional_not relop arithmetic - | factor optional_not 'CONTAINS' arithmetic - | factor optional_not 'BETWEEN' arithmetic 'AND' - arithmetic - ; - -arithmetic : primary - | aggregate filters - | primary 'ISA' ID - | primary is something - | arithmetic binop primary - ; - -filters : filter - | filters ',' filter - ; - -filter : filter expression - ; - -filter expression : optional_not where - | optional_not 'ISA' ID - | is something - ; - -right_hand_side : filter expression - | optional_not relop primary - | optional_not 'CONTAINS' factor - | optional_not 'BETWEEN' factor 'AND' factor - ; - -primary : optional_minus INTEGER - | STRING - | what - | 'SCORE' - | '(' expression ')' - | 'RANDOM' primary 'TO' primary - ; - -aggregate : 'COUNT' - | aggregator 'OF' ID - ; - -aggregator : 'MAX' - | 'MIN' - | 'SUM' - ; - -something : optional_not ID - ; - -what : simple_what - | attribute_reference - ; - -simple_what : ID - | 'THIS' - | 'CURRENT' 'ACTOR' - | 'CURRENT' 'LOCATION' - ; - -attribute_reference : ID 'OF' what - | what ':' ID - ; - -optional_where : - | where - ; - -where : 'HERE' - | 'NEARBY' - | 'AT' what - | 'IN' what - ; - -binop : '+' - | '-' - | '*' - | '/' - ; - -relop : '<>' - | '=' - | '==' - | '>=' - | '<=' - | '>' - | '<' - ; - -optional_qual : - | 'BEFORE' - | 'AFTER' - | 'ONLY' - ; - -optional_not : - | 'NOT' - ; - -optional_id : - | ID - ; - -ids : ID - | ids ID - ; - -id_list : ID - | id_list ',' ID - ; - -optional_INTEGER : - | INTEGER - ; - -optional_minus : - | '-' - ; - -ID : Identifier - | 'LOCATION' - | 'ACTOR' - | 'OPAQUE' - | 'ON' - | 'OF' - | 'FIRST' - | 'INTO' - | 'TAKING' - ; - - -fragment INTEGER : - | '0' - | '1'..'9' ('0'..'9')* - ; - -fragment -Identifier - : (LETTER ! DIGIT ! '_') - | '\'' ([^\'\n]!'\'''\'')* ('\'' ! '\n') - ; - -fragment LETTER : 'a'..'z' | 'A'-'Z' ; //\xe0-\xf6\xf8-\xfe] ; - -fragment DIGIT - : '0'..'9' - ; - -COMMENT : '--' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} ; diff --git a/app/src/main/jni/terps/alan/alan3/compiler/alan.g b/app/src/main/jni/terps/alan/alan3/compiler/alan.g deleted file mode 100755 index 452a4da..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/alan.g +++ /dev/null @@ -1,738 +0,0 @@ -Grammar alan; - -WHITESPACE : (' '|'\r'|'\t'|'\u000C'|'\n') {$channel=HIDDEN;} ; - -LINE_COMMENT : '--' ~('\n'|'\r')* '\r'? '\n' {$channel=HIDDEN;} ; - -fragment DIGIT : '0'..'9' ; - -fragment LETTER : 'A' .. 'Z' | 'a' .. 'z' | '_' | '$' | '\u00e0'..'\u00f6' | '\u00f8'..'\u00fe' ; - -INTEGER : DIGIT+; - -STRING : '"' ~'"' '"' ; - -fragment IDENTIFIER : LETTER ( LETTER | DIGIT | '_' )* ; - - -adventure : optional_options declarations start - ; - -optional_options : - | genSym0 options - ; - -genSym0 : 'options' - | 'option' - ; - -options : option - | options option - ; - -option : ID '.' - | ID ID '.' - | ID INTEGER '.' - ; - -declarations : - | declarations declaration - ; - -declaration : 'import' - | prompt - | messages - | class - | instance - | rule - | synonyms - | syntax - | verb - | addition - | event - ; - -prompt : 'prompt' statements - ; - -attributes : attribute_definition '.' - | attributes attribute_definition '.' - ; - -attribute_definition : ID - | 'not' ID - | ID STRING - | ID ID - | ID optional_minus INTEGER - | ID '{' optional_members '}' - ; - -optional_members : - | set_members - ; - -set_members : set_member - | set_members ',' set_member - ; - -set_member : what - | STRING - | optional_minus INTEGER - ; - -synonyms : 'synonyms' synonym_list - ; - -synonym_list : synonym_declaration - | synonym_list synonym_declaration - ; - -synonym_declaration : id_list '=' ID '.' - ; - -messages : 'message' message_list - ; - -message_list : message - | message_list message - ; - -message : ID ':' statements - ; - -syntax : 'syntax' syntax_list - ; - -syntax_list : syntax_item - | syntax_list syntax_item - ; - -syntax_item : ID '=' syntax_elements optional_syntax_restrictions - ; - -syntax_elements : syntax_element - | syntax_elements syntax_element - ; - -syntax_element : ID - | '(' ID ')' optional_indicators - ; - -optional_indicators : - | optional_indicators indicator - ; - -indicator : '*' - | '!' - ; - -syntax_restriction_clauses : syntax_restriction - | syntax_restriction_clauses 'and' - syntax_restriction - ; - -syntax_restriction : ID 'isa' restriction_class 'else' statements - ; - -restriction_class : ID - | 'container' - ; - -optional_syntax_restrictions : '.' - | 'where' syntax_restriction_clauses - ; - -verb : verb_header verb_body verb_tail - ; - -verb_header : optional_meta 'verb' id_list - ; - -optional_meta : - | 'meta' - ; - -verb_body : simple_verb_body - | verb_alternatives - ; - -verb_alternatives : verb_alternative - | verb_alternatives verb_alternative - ; - -verb_alternative : 'when' ID simple_verb_body - ; - -simple_verb_body : optional_checks optional_does - ; - -verb_tail : 'end' 'verb' optional_id '.' - ; - -optional_checks : - | 'check' statements - | 'check' check_list - ; - -check_list : check - | check_list 'and' check - ; - -check : expression 'else' statements - ; - -optional_does : - | does - ; - -does : 'does' optional_qual statements - ; - -class : 'every' ID optional_heritage properties class_tail - ; - -class_tail : 'end' 'every' optional_id genSym1 - ; - -genSym1 : - | '.' - ; - -addition : 'add' 'to' genSym2 ID optional_heritage properties - add_tail - ; - -genSym2 : - | 'every' - ; - -add_tail : 'end' 'add' genSym3 optional_id genSym4 - ; - -genSym3 : - | 'to' - ; - -genSym4 : - | '.' - ; - -instance : 'the' ID optional_heritage properties instance_tail - ; - -instance_tail : 'end' 'the' optional_id genSym5 - ; - -genSym5 : - | '.' - ; - -optional_heritage : - | heritage - ; - -heritage : 'isa' ID genSym6 - ; - -genSym6 : - | '.' - ; - -properties : - | properties property - ; - -property : where genSym7 - | container_properties - | description - | genSym8 article_or_form - | name - | pronoun - | initialize - | entered - | mentioned - | 'definite' article_or_form - | 'negative' article_or_form - | is attributes - | script - | exit - | verb - ; - -genSym7 : - | '.' - ; - -genSym8 : - | 'indefinite' - ; - -exit : 'exit' id_list 'to' ID optional_exit_body '.' - ; - -optional_exit_body : - | optional_checks optional_does 'end' 'exit' - optional_id - ; - -is : 'is' - | 'are' - | 'has' - | 'can' - ; - -optional_description : - | description - ; - -description : 'description' optional_checks optional_does - | 'description' statements - ; - -article_or_form : article - | form - ; - -article : 'article' - | 'article' statements - ; - -form : 'form' - | 'form' statements - ; - -entered : 'entered' statements - ; - -initialize : 'initialize' statements - ; - -mentioned : 'mentioned' statements - ; - -name : 'name' ids optional_full_stop - ; - -pronoun : 'pronoun' id_list optional_full_stop - ; - -optional_full_stop : - | '.' - ; - -container_properties : genSym9 optionally_opaque 'container' - container_body - ; - -genSym9 : - | 'with' - ; - -optionally_opaque : - | 'opaque' - ; - -container_body : optional_taking optional_limits optional_header - optional_empty optional_extract - | '.' - ; - -optional_taking : - | 'taking' ID '.' - ; - -optional_limits : - | 'limits' limits - ; - -limits : limit - | limits limit - ; - -limit : limit_attribute else_or_then statements - ; - -else_or_then : 'else' - | 'then' - ; - -limit_attribute : attribute_definition - | 'count' INTEGER - ; - -optional_header : - | 'header' statements - ; - -optional_empty : - | 'else' statements - ; - -optional_extract : - | 'extract' optional_checks optional_does - | 'extract' statements - ; - -event : event_header statements event_tail - ; - -event_header : 'event' ID - ; - -event_tail : 'end' 'event' optional_id '.' - ; - -script : 'script' ID genSym10 optional_description step_list - ; - -genSym10 : - | '.' - ; - -step_list : step - | step_list step - ; - -step : 'step' statements - | 'step' 'after' expression genSym11 statements - | 'step' 'wait' 'until' expression genSym12 statements - ; - -genSym11 : - | '.' - ; - -genSym12 : - | '.' - ; - -rule : 'when' expression then statements optional_end_when - ; - -then : '=>' - | 'then' - ; - -optional_end_when : - | 'end' 'when' genSym13 - ; - -genSym13 : - | '.' - ; - -start : 'start' where '.' optional_statements - ; - -optional_statements : - | statements - ; - -statements : statement - | statements statement - ; - -statement : output_statement - | special_statement - | manipulation_statement - | actor_statement - | event_statement - | assignment_statement - | repetition_statement - | conditional_statement - ; - -output_statement : STRING - | 'describe' what '.' - | 'say' say_form expression '.' - | 'list' primary '.' - | 'show' ID '.' - | 'play' ID '.' - | 'style' ID '.' - ; - -say_form : - | 'the' - | 'an' - | 'it' - | 'no' - ; - -manipulation_statement : 'empty' primary optional_where '.' - | 'locate' primary where '.' - | 'include' primary 'in' what '.' - | 'exclude' primary 'from' what '.' - ; - -event_statement : 'cancel' what '.' - | 'schedule' what optional_where 'after' - expression '.' - ; - -assignment_statement : 'make' primary something '.' - | 'strip' optional_first_or_last - optional_expression - optional_word_or_character 'from' expression - optional_into '.' - | 'increase' attribute_reference - optional_by_clause '.' - | 'decrease' attribute_reference - optional_by_clause '.' - | 'set' attribute_reference 'to' expression - '.' - ; - -optional_by_clause : - | 'by' expression - ; - -optional_first_or_last : - | 'first' - | 'last' - ; - -optional_word_or_character : - | 'word' - | 'words' - | 'character' - | 'characters' - ; - -optional_into : - | 'into' expression - ; - -conditional_statement : if_statement - | depending_statement - ; - -if_statement : 'if' expression 'then' statements - optional_elsif_list optional_else_part 'end' 'if' - '.' - ; - -optional_elsif_list : - | elsif_list - ; - -elsif_list : 'elsif' expression 'then' statements - | elsif_list 'elsif' expression 'then' statements - ; - -optional_else_part : - | 'else' statements - ; - -depending_statement : 'depending' 'on' primary depend_cases 'end' - genSym14 '.' - ; - -genSym14 : 'depend' - | 'depending' - ; - -depend_cases : depend_case - | depend_cases depend_case - ; - -depend_case : 'else' statements - | right_hand_side 'then' statements - ; - -repetition_statement : for_each ID optional_loop_filters 'do' - statements 'end' for_each genSym15 - ; - -genSym15 : - | '.' - ; - -optional_loop_filters : - | filters - | 'between' arithmetic 'and' arithmetic - ; - -for_each : 'for' - | 'each' - | 'for' 'each' - ; - -actor_statement : 'stop' what '.' - | 'use' 'script' ID optional_for_actor '.' - ; - -optional_for_actor : - | 'for' what - ; - -special_statement : 'quit' '.' - | 'look' '.' - | 'save' '.' - | 'restore' '.' - | 'restart' '.' - | 'score' optional_integer '.' - | 'transcript' on_or_off '.' - | 'system' STRING '.' - | 'visits' INTEGER '.' - ; - -on_or_off : 'on' - | 'off' - ; - -optional_expression : - | expression - ; - -expression : term - | expression 'or' term - ; - -term : factor - | term 'and' factor - ; - -factor : arithmetic - | factor optional_not where - | factor optional_not relop arithmetic - | factor optional_not 'contains' arithmetic - | factor optional_not 'between' arithmetic 'and' - arithmetic - ; - -arithmetic : primary - | aggregate filters - | primary 'isa' ID - | primary is something - | arithmetic binop primary - ; - -filters : filter - | filters ',' filter - ; - -filter : optional_not where - | optional_not 'isa' ID - | is something - ; - -right_hand_side : filter - | optional_not relop primary - | optional_not 'contains' factor - | optional_not 'between' arithmetic 'and' - arithmetic - ; - -primary : STRING - | what - | 'score' - | optional_minus INTEGER - | '{' optional_members '}' - | '(' expression ')' - | 'random' optional_transitivity 'in' primary - | 'random' primary 'to' primary - ; - -aggregate : 'count' - | aggregator 'of' ID - ; - -aggregator : 'max' - | 'min' - | 'sum' - ; - -something : optional_not ID - ; - -what : simple_what - | attribute_reference - ; - -simple_what : ID - | 'this' - | 'current' 'actor' - | 'current' 'location' - ; - -attribute_reference : ID 'of' what - | what ':' ID - ; - -optional_where : - | where - ; - -where : optional_transitivity 'here' - | optional_transitivity 'nearby' - | optional_transitivity 'at' primary - | optional_transitivity 'in' primary - | optional_transitivity 'near' what - ; - -binop : '+' - | '-' - | '*' - | '/' - ; - -relop : '<>' - | '=' - | '==' - | '>=' - | '<=' - | '>' - | '<' - ; - -optional_qual : - | 'before' - | 'after' - | 'only' - ; - -optional_not : - | 'not' - ; - -optional_transitivity : - | 'transitively' - | 'directly' - | 'indirectly' - ; - -optional_id : - | ID - ; - -ids : ID - | ids ID - ; - -id_list : ID - | id_list ',' ID - ; - -optional_integer : - | INTEGER - ; - -optional_minus : - | '-' - ; - -ID : IDENTIFIER - | 'location' - | 'actor' - | 'opaque' - | 'visits' - | 'contains' - | 'on' - | 'it' - | 'of' - | 'first' - | 'into' - | 'taking' - | 'off' - ; - diff --git a/app/src/main/jni/terps/alan/alan3/compiler/alan.h b/app/src/main/jni/terps/alan/alan3/compiler/alan.h deleted file mode 100644 index 84b090f..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/alan.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef _ALAN_H_ -#define _ALAN_H_ - -#include "sysdep.h" -#include "types.h" - -/* USE other definitions */ - -#include "lst.h" - -/* Public data */ -extern int fileNo; /* Number of last found file */ -extern FILE *txtfil; /* File for collected text */ -extern FILE *datfil; /* File for encoded text */ -extern int charset; /* Which character set the source is in */ -extern List *importPaths; /* The list of include paths to check */ -#ifdef WINGUI -extern Bool guiMode; /* Using the GUI? Or console? */ -#endif - -/* Common procedures */ - -extern void compile(void); - -#endif diff --git a/app/src/main/jni/terps/alan/alan3/compiler/alan.ico b/app/src/main/jni/terps/alan/alan3/compiler/alan.ico deleted file mode 100755 index 400a200..0000000 Binary files a/app/src/main/jni/terps/alan/alan3/compiler/alan.ico and /dev/null differ diff --git a/app/src/main/jni/terps/alan/alan3/compiler/alan.lmk b/app/src/main/jni/terps/alan/alan3/compiler/alan.lmk deleted file mode 100755 index a3189af..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/alan.lmk +++ /dev/null @@ -1,197 +0,0 @@ -%%OPTIONS - - Prefix 'lm'; - Listings single; - Limit 1000; --- Message file; - -%%MESSAGES English - -0 '%1 Adventure Language System'; -1 ' No warnings or errors detected.'; -2 ' No detected warnings.'; -3 ' No detected errors.'; -4 ' %1 informational message(s).'; -5 ' %1 warning(s).'; -6 ' %1 error(s).'; -7 'Maximum number of messages exceeded.'; - -100 'Parsing resumed here.'; -101 'Syntax error. Inserting \"%1\" before this token.'; -102 'Syntax error. Ignoring \"%1\".'; -103 'Syntax error. Replacing \"%1\" with \"%2\".'; -104 'Severe syntax error, construct ignored.'; -105 'Syntax error, could not recover.'; -106 'Parse stack overflow.'; -107 'Parse table error.'; -108 'Parsing terminated.'; -109 'Syntax error in import statement, %1.'; - -150 'Unterminated STRING.'; -151 'File name missing for $INCLUDE directive.'; -152 'Unterminated quoted identifier.'; -153 'Resource file missing.'; -154 '$INCLUDE directive is deprecated. Use \'import\' statement instead.'; -197 'File \'%1\' already imported. Ignored.'; -198 'Could not open output file \'%1\' for writing.'; -199 'Adventure source file (%1) not found.'; - -200 'Mismatched block identifier, \'%1\' assumed.'; -201 'Multiple declaration of %1 \'%2\' %3.'; -202 'Multiple usage of direction \'%1\' in this EXIT.'; -203 'Multiple definition of EXIT \'%1\' in this location.'; -204 'Multiple use of %1 clause in this %2.'; -205 'This is the first occurrence of %1, see errors below.'; -206 'Incompatible parameters lists for multiple syntax definitions for verb \'%1\'. Multiple syntaxes for the same verb must contain the same number of parameters with the same name, but the order of the parameters can be changed.'; -207 'VERB \'%1\' is not defined.'; -208 '\'%1\' is not a VERB.'; -209 'First element in a SYNTAX must be a player word.'; -210 'Action qualification not allowed here.'; -211 'Adventure must start at an instance inheriting from \'location\'.'; -212 'Syntax parameter \'%1\' overrides symbol.'; -213 'Verb alternatives not allowed here.'; -214 'Parameter \'%1\' not defined in syntax for \'%2\'.%3'; -215 'Syntax not compatible with syntax for \'%1\'.'; -216 'Parameter \'%1\' multiply defined in this SYNTAX.'; -217 'Only one multiple parameter allowed for each syntax. This one ignored.'; -218 'Multiple definition of attribute \'%1\'.'; -219 'Global verbs cannot have parameters.'; -220 'Multiple definition of verb \'%1\' in this context.'; -221 'Multiple class restriction for parameter \'%1\'.'; -222 'Identifier \'%1\' in class restriction is not a parameter.'; -223 'This Verb body might be executed for every matching parameter in the syntax for \'%1\', depending on the parameter restrictions. You might want to use a WHEN clause to specify for which parameter this alternative is to be run.'; -224 'Multiple use of %1 in filter list for %2.'; -225 'The %1 aggregate will be applied to every instance (including locations, entities and instances of their subclasses). It is recommended to apply it to only instances of a particular class. Perhaps you mean \'%1 Isa object\'?'; -226 'Attributes cannot be used for filtering applied to instances of unknown class. Filter out instances of a particular class e.g. by adding a \'Isa \' filter.'; -227 'An unconditional check prohibits the declared statements (DOES) to ever be executed.'; -228 'Check not allowed in Description for Script.'; - -230 'No syntax defined for this global verb, automatically used \'%1\'.'; -231 'No syntax defined for this verb, automatically used \'%1 (%2) Where %2 Isa %2.\''; -232 'Default syntax for this verb restricted the parameter to class \'location\', which is probably not what you wanted. Suggest you add an explicit syntax instead.'; - -240 '%1 \'%2\' already defined for class \'%3\'. You cannot add it. You can override it by subclassing from class \'%3\'.'; -241 '%1 already defined for class \'%2\'. You cannot add it. You can override it by subclassing from class \'%2\'.'; - -250 'You can only declare restrictions for the first syntax for verb \'%1\'. The restrictions for subsequent syntaxes must be empty and will use the same as for the first.'; - -260 'You cannot declare a %1 named %2 since that would conflict with %3.'; - -270 'Instances without explicit inheritance is assumed to inherit from the predefined class \'entity\'.'; - -301 '\'%1\' also declared as a Direction.'; -303 '\'%1\' also declared as a Verb.'; -304 '\'%1\' also declared as an Instance (The).'; -305 '\'%1\' also declared as a Class (Every).'; -307 '\'%1\' also declared as an Event.'; -308 '\'%1\' already declared.'; -309 'In this context is THIS not a Container. Neither does the current entity inherit the Container property nor does it declare it.'; -310 'Identifier \'%1\' not defined.%2'; -311 '%1 is not guaranteed to be %2, %3.'; -312 '%1 \'%2\' is not guaranteed to be %3, %4.'; -313 'Attribute \'%1\' is not defined for THIS instance.'; -314 'Attribute \'%1\' is not defined for the Current %2 since the class \'%3\' does not have it.'; -315 'Attribute not defined for \'%1\'.'; -316 'Attribute \'%1\' is not defined for %2 \'%3\' since the class it is guaranteed to be in this context (\'%4\') does not have it.'; -317 'Attribute \'%1\' is not defined for %2 since the class it is guaranteed to be in this context (\'%3\') does not have it.'; -318 'The \'%1\' does not have the container property, which is required in %2.'; -319 'Identifier \'%1\' is not %2.'; -320 'Word \'%1\' belongs to multiple word classes (%2 and %3).'; -321 'Synonym target word \'%1\' not defined.'; -322 'Word \'%1\' already defined as a synonym.'; -323 'Cannot restrict a parameter to something not a class.'; -324 'Cannot refer to %1 in %2.'; -325 'Cannot use explicit transitivity (\'%1\') with %2.'; -326 'Pronoun clause not allowed on entities inheriting from \'location\'.'; -328 'Attribute \'%1\' is inherited from \'%2\' as an abstract attribute which is not initilized, only defined. Instances are required to initialize all abstract attributes.'; -329 'Attribute is inherited from class \'%1\', but the class %2 in this declaration (\'%3\') is not a subclass of the class infered for the inherited (\'%4\'), which it must be.'; -330 'Wrong type of expression in context of %2. Must be of %1 type.'; -331 'Incompatible types in %1.'; -332 'Attribute is inherited from class \'%1\' but does not match the original type (%2) which is required.'; -333 'The word \'%1\' is defined to be both a synonym and another word class.'; -334 'Multiple syntaxes are defined with this structure (words and parameters).'; -335 'ELSE clause of a DEPENDING statement must be the last.'; -336 'You cannot Add %1.'; -337 'You cannot Say values of %1 type.'; -338 'A Where specification is required in Aggregate statements.'; -339 'You can only use forms to Say instances. For other types of values use \'Say\' without any form indicator.'; - -340 'Initial location for \'%1\' declared twice. This occurence ignored.'; -341 'Cannot Add %1 to classes. %2'; -342 'Cannot inherit %1.'; -343 'Cannot inherit %1. (Yet!)'; -344 'Adding this %1 will overwrite an already existing %1 for \'%2\'. Consider sub-classing \'%2\' and adding the %1 to the subclass instead.'; -345 'This %1 will be overwritten by an Add.'; -350 'Cannot inherit from something not a class.'; -351 '%1 must refer to %2 inheriting from \'%3\'.'; -352 '%1 \'%2\' does not inherit from \'%3\', but has %4.'; -354 '%1 \'%2\' inherits from \'%3\', but has %4.'; -355 'Initial location can only refer to instances inheriting from \'location\' using AT or to instances having the container property using IN.'; -356 'Only instances or classes inheriting from \'actor\' can have scripts.'; - -399 'This is a previous declaration of \'%1\'.'; - -400 'Script \'%1\' not defined for %2 \'%3\'.'; -401 'Actor reference required outside Actor specification.'; -402 '%1 cannot be inside a Container.'; -403 'Script multiply defined for Actor \'%1\'.'; -404 'Container is restricted to only contain instances of \'%1\' and its subclasses.'; -405 'Only instances and classes inheriting from Thing can %1.'; -406 'You cannot modify attributes to Integer and String parameters.'; -407 'Attribute in Limits must be an attribute for every instance of the class the container accepts, in this case \'%1\'.'; -408 '%1 in %2 must be of %3 type.'; -409 'No parameters defined in this context.'; -410 'Incompatible types in %1. %2 Set can only contain %3.'; -411 '%1 ignored for Actor \'hero\'.'; -412 'Current %1 is not defined in %2.'; -413 'Empty Sets are not allowed unless the attribute is inherited. At least one member is necessary to infer the type and class of members.'; -414 'Invalid initial location for %1.'; -415 'Invalid Where specification in %1 statement.'; -416 'Interval of size 1 in RANDOM expression.'; -417 'Comparing two constant entities will always yield the same result.'; -418 'Aggregate is only allowed on integer type attributes.'; -419 '%1 SET statement cannot be of boolean type.'; -420 'Invalid What-specification in %1.'; -421 'THIS instance is not defined in this context.'; -422 'Explicit transitivity \'%1\' %2 %3.'; -423 'You cannot instantiate or sub-class \'%1\'.'; -424 'You cannot add %1 to non-instantiable class \'%2\'.'; -425 'A Mentioned clause overrides the Name for an instance inheriting from location.'; -426 'Adding a Verb to the pre-defined class \'entity\' will result in multiple executions of it, since it will be inherited by both all locations and all objects. This is probably not what you want. Try adding it to \'thing\' instead.'; -427 'A subsequent restriction for the same parameter (\'%1\') should restrict it further, to a subclass of \'%2\'.'; -428 '%1 must refer to %2.'; -429 'No inheritance defined, everything must inherit from some class.'; -430 'Incompatible assignment. You can only assign instances of class \'%1\' and its subclasses.'; -431 'Incompatible assignment. You can only assign a Set where members are instances of class \'%1\' and its subclasses.'; -432 'Incompatible assignment. You can only assign a Set where members are integers.'; -433 'Initialization of attribute must be a constant value.'; -434 '%1 can only be applied to instance valued expressions.'; -435 'Only SETs and CONTAINERs have content.'; -436 'Cannot modify readonly attribute.'; -440 '%1 filters can currently only accept boolean attributes.'; -441 'Incompatible filter. All filters must enumerate instances or values which are compatible, such as subclasses or compatible types.'; -442 'Only instances have attributes.'; -443 'There is no location defined in %1, so %2 is not defined.'; -444 'There is no location defined in %1, so output can never be seen by the player.'; -445 'The event will be executed at no location.'; -450 'Wrong type of resource file for %1 statement.'; - -501 'Location \'%1\' has no EXITs.'; -502 'Instance \'%1\' does not inherit from any of the common base classes.'; - -550 'Unknown text style. Use %1.'; -551 'String contains reference to a parameter that does not exist in this context.'; - -600 'Multiple use of option \'%1\', ignored.'; -601 'Unknown option, \'%1\'.'; -602 'Illegal value for option \'%1\'.'; - -700 'Unknown message identifier.'; - -800 'Deprecated construct. Use \'%1\' instead.'; -801 'Resource type not recognized. File name extension must indicate resource type.'; -802 'The inital location of Instance \'%1\' forms a circular reference.'; - -997 'SYSTEM ERROR: %1'; -998 'Feature not implemented in %1.'; -999 'No Adventure generated.'; diff --git a/app/src/main/jni/terps/alan/alan3/compiler/alan.pmk b/app/src/main/jni/terps/alan/alan3/compiler/alan.pmk deleted file mode 100755 index 47e3004..0000000 --- a/app/src/main/jni/terps/alan/alan3/compiler/alan.pmk +++ /dev/null @@ -1,2739 +0,0 @@ -%%OPTIONS - - Prefix 'pm'; - Listerprefix 'lm'; --- List Grammar, Statistics; - List Grammar, Statistics, Items; - StackLimit 64; - Pack RDS; - Line; --- Debug; - No Resolve; - -%%IMPORT - -#include "util.h" -#include "acode.h" - -#include "types.h" -#include "smScan.h" -#include "token.h" - -#include "lmList.h" - -#include "alt.h" -#include "evt.h" -#include "lim.h" -#include "msg.h" -#include "opt.h" -#include "sco.h" -#include "str.h" -#include "syn.h" -#include "adv_x.h" -#include "add_x.h" -#include "article_x.h" -#include "atr_x.h" -#include "cla_x.h" -#include "chk_x.h" -#include "cnt_x.h" -#include "elm_x.h" -#include "exp_x.h" -#include "ext_x.h" -#include "id_x.h" -#include "ins_x.h" -#include "description_x.h" -#include "initialize_x.h" -#include "resource_x.h" -#include "rul_x.h" -#include "lst_x.h" -#include "prop_x.h" -#include "res_x.h" -#include "scr_x.h" -#include "stm_x.h" -#include "stp_x.h" -#include "stx_x.h" -#include "sym_x.h" -#include "srcp_x.h" -#include "vrb_x.h" -#include "whr_x.h" -#include "wht_x.h" - -%%SCANNER - - smScan(lexContext, token); - - -%%INSERTSYMBOL - -{ - static int idno = 1; - - /* Make the requested token */ - token->code = code; - if (token->code == sm_MAIN_IDENTIFIER_Token) { - sprintf(token->chars, "$identifier#%d", idno++); -#ifdef INSERTIDINMESSAGE - strcat(insStr, " ('"); - strcat(insStr, token->chars); - strcat(insStr, "')"); -#endif - } else - strcpy(token->chars, symString); -} - -%%DECLARATIONS - -static int val(char str[]) -{ - int temp; - - sscanf(str, "%d", &temp); - return(temp); -} - - -%%ATTRIBUTES - - add %% AddNode *%1%%, - agr %% AggregateKind %1%%, - alt %% Alternative *%1%%, - alts %% List *%1%%, - article %% Article *%1%%, - atr %% Attribute *%1%%, - atrs %% List *%1%%, - bits %% int %1%%, - cases %% List *%1%%, - chk %% CheckNode *%1%%, - chks %% List *%1%%, - cla %% Class *%1%%, - clas %% List *%1%%, - cnt %% Container *%1%%, - cnts %% List *%1%%, - definite %% Article *%1%%, - definiteIsForm %% Bool %1%%, - definiteSrcp %% Srcp %1%%, - description %% Description *%1%%, - descriptionCheckSrcp %% Srcp %1%%, - descriptionChecks %% List *%1%%, -- of Checks: descriptionCheck-clause, - descriptionDoes %% List *%1%%, -- of Statements: descriptionDoes-clause, - descriptionSrcp %% Srcp %1%%, - elm %% Element *%1%%, - elms %% List *%1%%, - entered %% List *%1%%, - enteredSrcp %% Srcp %1%%, - initialize %% Initialize *%1%%, - evt %% Event *%1%%, - evts %% List *%1%%, - exp %% Expression *%1%%, - exps %% List *%1%%, - ext %% Exit *%1%%, - exts %% List *%1%%, - first %% Bool %1%%, - form %% List *%1%%, - id %% Id *%1%%, - idList %% List *%1%%, - idList2 %% List *%1%%, - indefinite %% Article *%1%%, - ins %% Instance *%1%%, -- Instance - inss %% List *%1%%, -- of Instances - isForm %% Bool %1%%, - lim %% LimNod *%1%%, - lims %% List *%1%%, - mentioned %% List *%1%%, -- of Statement: mentioned-clause, - mentionedSrcp %% Srcp %1%%, - isMeta %% Bool %1%%, - minus %% Bool %1%%, - msg %% Message *%1%%, - msgs %% List *%1%%, - nam %% List *%1%%, -- of NamNod: name-clause - nams %% List *%1%%, -- of NamNods: name-clause list (list of lists) - negative %% Article *%1%%, - on_or_off %% Bool %1%%, - op %% OperatorKind %1%%, - opaque %% Bool %1%%, - present %% Bool %1%%, -- an optional marker was present - prompt %% List *%1%%, - pronouns %% List *%1%%, - pronounsSrcp %% Srcp %1%%, - qual %% QualKind %1%%, - res %% Restriction *%1%%, - ress %% List *%1%%, - restrictionKind %% RestrictionKind %1%%, - rul %% RulNod *%1%%, - ruls %% List *%1%%, - sayForm %% SayForm %1%%, - scr %% Script *%1%%, - scrs %% List *%1%%, - set %% List *%1%%, - srcp %% Srcp %1%%, - srcp2 %% Srcp %1%%, - stm %% Statement *%1%%, - stms %% List *%1%%, - stms2 %% List *%1%%, - stms3 %% List *%1%%, - stp %% Step *%1%%, - stps %% List *%1%%, - str %% char *%1%%, - stx %% Syntax *%1%%, - stxs %% List *%1%%, - syn %% Synonym *%1%%, - syns %% List *%1%%, - transitivity %% Transitivity %1%%, - val %% int %1%%, - vrb %% Verb *%1%%, - vrbs %% List *%1%%, - whr %% Where *%1%%, - wht %% What *%1%%, - wordOrChar %% Bool %1%%; - -%%TERMINALS - - Identifier = 2,1,1 => ''; - Integer = 3, 2, 1; - -%%RECOVERY - - Fiducial('verb', 'the', 'every', 'exit', 'event', 'start', - 'syntax', 'script', 'synonyms', 'when', - 'mentioned', 'attributes', 'description', 'end', 'check', 'quit'); - - Separator(','); - - Skip(Identifier, Integer, '.'); - -%%RULES - ---> ADVENTURE - - = - ; - ----> OPTIONS - -- RETURNS: - = - ! ('options'|'option') - ; - - -- RETURNS: - =