Community

AGI Programming => AGI Development Tools => Topic started by: AGKorson on January 13, 2019, 04:57:24 PM

Title: Musings on Original AGI Game Source Code
Post by: AGKorson on January 13, 2019, 04:57:24 PM
I spent a lot of time going through the samples of game source code that Omer provided in this post (http://sciprogramming.com/community/index.php?topic=1799.msg12130#msg12130).

Here are a few random things I gleaned from those files:

-  Their coding style and even syntax varied quite a bit from game to game; Al Lowe appears to have preferred camelCase, and also had his own set of preferred names for some of the commands. Other programmers used the dot.separator style. All of the examples were consistent in using ALL_UPPER_CASE for defined numerical constants

-  Command names used in source code were defined on a game by game basis; apparently the compiler did not use text values for game code- the preprocessor is where command names got converted to numbers.

-  In one game, 'variable' commands (for example isset.v, print.at.v) were actually defined with an 'f' (isset.f, print.at.f). I wonder why they used an 'f'?

-  increment and decrement functions used 'pre-assignment' syntax (++v1, --v1) not 'post-assignment syntax (v1++, v1--). Since you can't write complex statements in AGI script it doesn't really matter. (WinAGI handles either syntax.)

-  All of the examples were consistent in the naming conventions for resources; prefix of 'r' for logics representing a location, 'lgc' other logics, 'm' for sounds designated as music, 's' for sound effects, 'v' for views.

-  logics not associated with a location (not a room) were consistently referred to as 'dynamic'.

-  The file extension for logic source files was 'CG'. I tried to think what that might refer to, but I can't think of anything. Anybody have a guess as to why 'CG'?

-  All the examples had comments that identified variable and flag numbers 0-29 as 'use by compiler only', 220-239 as 'local variables and flags', used by rooms, and 240-255 as 'dynamic', used by 'dynamic logics'. Most of them had a check so that whenever the new room flag was set, these variables and flags would be reset.

-  Local and dynamic flags and variables were given relative number values. For example, a variable might be defined as '#define thisVar lv0'. They included a header file that would convert 'lv0' to 'v220'. It worked, but that seems like a bit overcomplicated; why not just define it as v220?

-  They all say that numbers 0-29 are for use by compiler only, but we know that not all of them were actually in use. Looks like they wanted to make sure they had room to grow (but then never did, eventually switching to SCI.)

-  Although the style varied, the names for reserved flags and variables was consistent. (I have updated WinAGI to use the values listed here as default names instead of the fan-created names that have been around forever.)

-  In addition to allowing testing of flags by using just the flag ('if(f10)' is compiled as 'if(isset(f10))'), their compiler would also allow testing of variables ('if(v10)' would compile as 'if(greatern(v10,0)'). I'm looking at adding support for that syntax to WinAGI.

-  None of their logics include a return() command at the end. Apparently the compiler would add that automatically. I prefer enforcing it to make sure the programmer really meant the logic was done.

-  Their room logics were all very well structured; the initialization section at the top, a section for handling input, a section for non-input things, and then checking for room exits at the end. I'm going to try and redo the template game to match this structure

-  In their source code, words in the said() command were not enclosed in quotes, and dollar signs ($) were used as spaces. So 'said( dirty$word, rol)' instead of 'said( "dirty word", "rol")'

-  Based on their coding and comments, only Tandy computers used volume controls. I didn't know that; I assumed all non-PC systems could adjust volume. And they used the names 'crescendo' and 'decrescendo' for their volume controllers - I wouldn't have figured their programmers to be so 'sophisticated'.

-  In their game defines file, they all had a name of 'error' defined as a value of '-1'. This suggests their compiler could handle negative numbers.  There's not much use for negative numbers(the reposition() command is the only command that used them), but apparently they could use them if they wanted to? BTW, WinAGI will allow use of negative numbers (converting them to the appropriate 2s complement value) to make working with the reposition command easier.

-  In their list of constants for machine type, all the examples include 'CORTLAND', assigned a value of 8, but with a question mark as a comment. In AGI Specs, the value of 8 is identified as 'Apple IIgs'. The Cortland is a variety of apple, derived from the McIntosh. So I wonder if 'CORTLAND' was a pre-release codename for the Apple IIgs (or even some other computer from Apple). I find that interesting from a historical perspective.

Here are a few comments I found in the examples that I found entertaining. It must have been fun working at Sierra back in those days.

In Black Cauldron:
Code: [Select]
%define ego.is.a.dead.mother df1 [ the end
.
.
[*****
:no.input
:no.fucking.input
:also.no.mother.fucking.input
[*****

In KQ3:
Code: [Select]
current.status = sleeping; [ nightie, night sweet ego
.
.
if (ego.location == 9) [ do the "get out of bed" schtick
.
.
if (!edge.ego.hit && ego.y < 20) [ sweep up after Jeff's bugs
.
.
load.logics( lgc.PO'd.wiz); [ Bring on that little wizzer!

In PQ:
Code: [Select]
if ((said( show, belt) || said( show, gun))) [ Funny, you don't look Oriental!
Oh, in KQ3, the phrase to enter debug mode was originally 'rat shit', not 'rats ass'. Although due to synomyms 'rats ass' works, the source code clearly shows 'rat shit' is what was intended.
Title: Re: Musings on Original AGI Game Source Code
Post by: Kawa on January 13, 2019, 06:17:46 PM
Quote
These problems led to the cancellation of the IIx project, but later, a new project was formed to produce an updated Apple II. This project, which led to the released IIGS, was known by various codenames while the new system was being developed, including "Phoenix", "Rambo", "Gumby", and "Cortland".
https://en.wikipedia.org/wiki/Apple_IIGS#Development_and_codenames
Title: Re: Musings on Original AGI Game Source Code
Post by: AGKorson on January 13, 2019, 07:10:01 PM
Quote
These problems led to the cancellation of the IIx project, but later, a new project was formed to produce an updated Apple II. This project, which led to the released IIGS, was known by various codenames while the new system was being developed, including "Phoenix", "Rambo", "Gumby", and "Cortland".
https://en.wikipedia.org/wiki/Apple_IIGS#Development_and_codenames
Thx! When I searched google with the terms "cortland" and "computer", I got no hints that it was related to Apple.

Stupid Google.   ;D
Title: Re: Musings on Original AGI Game Source Code
Post by: Kawa on January 13, 2019, 07:41:59 PM
That's why I looked for Apple IIgs instead.