Revised BASIC framework and tools to build an adventure

development and releases of new/rewritten text adventures
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

Previously I had implemented an Excel spreadsheet to hold all of the data for an adventure and then referenced the message numbers and verbs etc. in a BBC Basic program to build the adventure (the data from the spreadsheet was exported to files which were dragged into an SSD and ran alongside the game program) - viewtopic.php?f=65&t=14770#p197797.

Using Excel is very clunky - you had to remember the message and verb numbers etc. and refer to them directly in the program. If you needed to change anything it was a pain having to renumber stuff.

To get around this (and learn some C sharp - can't find the hash key on my Mac) I decided to do something a little easier to use. The adventure messages, verbs, nouns and game specific logic is now built in an XML file (not a perfect medium but a good stop gap and very easy to work with using Notepad++) and then this is combined with a BBC Basic source file (as pure text) and an output file (and all the data files) is produced. This plain text program can either be tokenised (thanks to Richard Russel for posting a tokeniser on here - viewtopic.php?t=16476#p227021 - that I have included - hope thats OK!) or left as plain text - in which case it can be *EXEC'd into BBC Basic (I am thinking of trying this on my Tatung Einstein when I get it back from the repair shop) and run.

I have recreated Ransom using this process and included the files to build and run it. I have been looking around for a means of creating an SSD file directly from the output and it looks like there are some good candidates. If so then hopefully the whole thing can compile and if it works - tokenise, create an SSD file and launch Beeb-Em or similar. That may be an ambition too far but its nice to hope. :D
Last edited by Lardo Boffin on Fri May 08, 2020 9:40 pm, edited 2 times in total.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

The downside to writing this in c sharp is that we are moving over to .Net core at work and therefore this is written using .Net core 3.1 libraries. This means the .Net core runtime needs to be present to run the 'compiler'. This is a free download from Microsoft (https://dotnet.microsoft.com/download/d ... -installer).
The upside is that it looks like there is a runtime for the Mac as well as Windows.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

Anyway, attached is a ZIP file with everything (aside .Net Core 3.1) to build Ransom.

Updated, see latest post. Windows download - Mac is further down the post.
Attachments
AL.zip
Updated
(217.3 KiB) Downloaded 98 times
Last edited by Lardo Boffin on Mon May 18, 2020 2:37 pm, edited 3 times in total.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

There is a readme that I started this evening so it is not very detailed yet.

It says:

Install:

1) Extract this lot to a folder of your choice (but probably not a security restricted one!)
2) Please download .Net Core 3.1 from https://dotnet.microsoft.com/download/d ... -installer


Using:

1) The AdventureData.xml needs to be in the same folder as the AdventureLanguage.exe.
2) Ensure the SourceFile, OutputFilePath, Tokeniser and TokenisedFileName are set correctly (tokenising is optional) in the XML file
3) Double click the .exe or run from the Command prompt (cd to the correct directory and then type AdventureLanguage.exe)
4) The files will be placed in the specified output folder
5) Drag all the files into an SSD file (or similar) and then run from BeebEm etc.
6) If you tokenised then CHAIN "@@" where @@ is the setting TokenisedFileName
7) If you did not tokenise then you will need to convert the text file to BBC Basic (e.g. *EXEC <filename>)

The XML file assumes the files will be placed in C:\Beeb\AL but this can be changed easily.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

Here are the contents of the XML file:

Code: Select all

<?xml version="1.0" standalone="yes"?>
<AdventureData>
  <GlobalVariables>
    <Var id="IsDark" value="0">1 = Dark</Var>
    <Var id="HaveLight" value="0">1 = Has light source</Var>
  </GlobalVariables>
  <Sections>
    <Section>
      <GameTitle>Ransom</GameTitle>
      <ScreenWidth>40</ScreenWidth>
      <ScreenMode>7</ScreenMode>
      <SourceFile>source.txt</SourceFile>
      <OutputFile>rawtext.txt</OutputFile>
      <Tokeniser>C:\Beeb\AL\tokenise.exe</Tokeniser>
      <TokenisedFileName>Ransom</TokenisedFileName>
      <SSDBuilder>C:\Beeb\AL\MkImg.exe</SSDBuilder>
      <SSDName>Ransom.SSD</SSDName>
      <BeebEmPath>C:\Program Files (x86)\BeebEm\Beebem.exe</BeebEmPath>
      <SystemMessages>
        <Message id="Carrying">You are carrying</Message>
        <Message id="WhatNow">What now</Message>
        <Message id="CannotDoIt">You can't.</Message>
        <Message id="What">Pardon?</Message>
        <Message id="AnotherGame?">Press a key for another game...</Message>
        <Message id="Sure">Are you sure? (Y/N)...</Message>
        <Message id="GotThat">You've already got that.</Message>
        <Message id="HaveNotGotThat">You haven't got that.</Message>
        <Message id="CannotSeeIt">You can't see that.</Message>
        <Message id="TooHeavy">You're carrying too much to pick that up.</Message>
        <Message id="Score">Your score was </Message>
        <Message id="NoOfTurns">and you took </Message>
        <Message id="ItsDark">It is dark. You cannot see.</Message>
        <Message id="CannotFindIt">I can't find that anywhere.</Message>
        <Message id="AlsoSee">You can also see</Message>
        <Message id="OK">Okay </Message>
        <Message id="Turns">turns.</Message>
        <Message id="Nothing">nothing</Message>
      </SystemMessages>
      <GameVerbs>
        <Verb>North;N</Verb>
        <Verb>South;S</Verb>
        <Verb>East;E</Verb>
        <Verb>West;W</Verb>
        <Verb>Up;U</Verb>
        <Verb>Down;D</Verb>
        <Verb>Take;Get</Verb>
        <Verb>Drop</Verb>
        <Verb>Look</Verb>
        <Verb>Inventory;Inv</Verb>
        <Verb>Quit</Verb>
        <Verb>Words</Verb>
        <Verb>Pictures</Verb>
        <Verb>Save</Verb>
        <Verb>Restore</Verb>
        <Verb>Examine;Search</Verb>
        <Verb>Light;On</Verb>
        <Verb>Extinguish;Off</Verb>
        <Verb>Unlock;Open</Verb>
        <Verb>Score</Verb>
        <Verb>Eat</Verb>
        <Verb>Load</Verb>
      </GameVerbs>
      <Adverbs>
        <Adverb>WITH;USING</Adverb>
      </Adverbs>
      <Nouns>
        <Noun>Torch;Lamp</Noun>
        <Noun>Rat</Noun>
        <Noun>Key</Noun>
        <Noun>Gold;Bar</Noun>
        <Noun>Snake;Serpent</Noun>
        <Noun>Door</Noun>
        <Noun>It</Noun>
        <Noun>Tree</Noun>
        <Noun>CLS</Noun>
      </Nouns>
      <Variables>
        <Var id="TurnsInDark" value="0">Number of turns in the dark so far. 2 = death.</Var>
        <Var id="RatFed" value="0">1 = The snake has had a rat</Var>
        <Var id="IsFirstTurn" value="1">1 = first turn so maybe show an extended message</Var>
        <Var id="FoundKey" value="0">1 = have the key</Var>
        <Var id="DoorLocked" value="0">1 = the door is locked</Var>
      </Variables>
      <Objects>
        <Object id="_LAMP" number="1" weight="10" value="1" location="1" message="A lamp">
        </Object>
        <Object id="_RAT" number="2" weight="20" value="0" location="5" message="A dead rat">
        </Object>
        <Object id="_Key" number="3" weight="1" value="0" location="0" message="A key">
        </Object>
        <Object id="_GOLD" number="4" weight="100" value="150" location="6" message="A large, heavy gold bar">
        </Object>
        <Object id="_LIT_LAMP" number="5" weight="10" value="1" location="0" message="A lit lamp">
        </Object>
      </Objects>
      <Locations>
        <Location id="0">
        </Location>
        <Location id="1">
          <Message>You find yourself on the bank of a mountain stream, which is crossed by a stone bridge leading East to a dark cave.</Message>
          <Exit to="2">
            <Verb>EAST</Verb>
          </Exit>
        </Location>
        <Location id="2">
          <Message>This is a very gloomy cavern, with pale sunlight to the West, and dim tunnels leading South and East.</Message>
          <Exit to="3">
            <Verb>EAST</Verb>
          </Exit>
          <Exit to="1">
            <Verb>WEST</Verb>
          </Exit>
          <Exit to="5">
            <Verb>SOUTH</Verb>
          </Exit>
        </Location>
        <Location id="3">
          <Message>Traveling this East-West passage, you see another tunnel South, across a great crevasse. A small snake is asleep in its favourite cranny.</Message>
          <Exit to="4">
            <Verb>EAST</Verb>
          </Exit>
          <Exit to="2">
            <Verb>WEST</Verb>
          </Exit>
        </Location>
        <Location id="4">
          <Message>You have emerged onto the bank of a huge mountain lake. To the west is the tunnel, and a solitary tree graces the waters edge.</Message>
          <Exit to="3">
            <Verb>WEST</Verb>
          </Exit>
        </Location>
        <Location id="5">
          <Message>A moat to the East surrounds a titanic fortress. The cave is North, and a door lies beyond the lowered drawbridge.</Message>
          <Exit to="2">
            <Verb>NORTH</Verb>
          </Exit>
        </Location>
        <Location id="6">
          <Message>Inside the castle is a bit grim, especially for any unlucky soul locked here in its dungeon. The door to the West ensures few escape.</Message>
          <Exit to="5">
            <Verb>WEST</Verb>
          </Exit>
        </Location>
      </Locations>
      <PreRoom>
			PROCset(@IsDark,0)
			IF R%=2 OR R%=3 OR R%=6 THEN PROCset(@IsDark,1)
		</PreRoom>
      <Init>
			PROCset(@IsFirstTurn,1):PROCset(@TurnsInDark,3):PROCenc(111)
		</Init>
      <HighPriority>
			IF FNon(@IsDark) AND NOT FNon(@HaveLight) THEN PROCdec(@TurnsInDark)
			IF FNon(@IsDark) AND NOT FNon(@HaveLight) AND FNget(@TurnsInDark)=1 THEN PROCmsg("You hear scuffling noises close by.")
			IF FNon(@IsDark) AND NOT FNon(@HaveLight) AND FNget(@TurnsInDark)=0 THEN PROChold(50):PROCmsg("A giant spider with glowing red eyes leaps from the shadows and neatly severs your head with its powerful jaws before devouring you!"):PROCexit:=TRUE
			IF R%=3 THEN IF NOT FNavail(@_RAT) AND NOT FNon(@RatFed) THEN PROChold(50):PROCmsg("The snake awakens and springs out at you striking you with its venomous fangs. You die a fast but painful death."):PROCexit:=TRUE
			IF R%=3 THEN IF FNavail(@_RAT) AND NOT FNon(@RatFed) THEN PROChold(50):PROCmsg("The snake awakens and smells the dead rat. In an instant it has snatched it and eaten it! It then settles back into a deep sleep."):PROCset(@RatFed,1):PROCmove(@_RAT,0):CW%=CW%-20:=TRUE
			IF R%=1 THEN IF FNavail(@_GOLD):PROCmsg("Well done! The gold you have brought is enough to pay a king's ransom!!"):PROCexit:=TRUE
		</HighPriority>
      <LowPriority>
			IF V%=@On THEN IF N%=@CLS THEN PROCcls(1):=TRUE
			IF V%=@Off THEN IF N%=@CLS THEN PROCcls(0):=TRUE
			IF V%=@Save THEN PROCsave:=TRUE
			IF V%=@Load THEN PROCload:=TRUE
			IF R%=3 THEN IF V%=@Take AND N%=@Snake THEN PROCmsg("The snake awakens and springs out at you striking you with its venomous fangs. You die a fast but painful death."):PROCexit:=TRUE
			IF R%=3 THEN IF V%=@S THEN PROCmsg("Walls of granite rush past as you fall into the pit, consciousness deserts you and you perish on the rocks below!"):PROCexit:=TRUE
			IF R%=4 THEN IF V%=@Examine AND N%=@Tree AND NOT FNon(@FoundKey) THEN PROCset(@FoundKey,1):PROCmsg("On examining the tree, you dislodge something from a hole on a branch. It falls to the ground with a metallic clang."):PROCmove(@_KEY,4):=TRUE
			IF R%=5 THEN IF V%=@Unlock AND FNavail(@_KEY) AND N%=@Door AND NOT FNon(@DoorLocked):PROCset(@DoorLocked,1):PROCmsg("With a grating sound, the key turns in the lock and the door opens."):=TRUE
			IF R%=5 THEN IF V%=@East AND FNon(@DoorLocked) THEN:PROCgoto(6):=TRUE
			IF V%=@Examine THEN PROCmsg("You find nothing of interest."):=TRUE
			IF V%=@On THEN IF N%=@Lamp THEN IF FNinInv(@_LAMP) THEN PROCswap(@_LAMP,@_LIT_LAMP):PROCset(@HaveLight,1):PROCmsg("You have lit the lamp."):=TRUE
			IF V%=@Off THEN IF N%=@Lamp THEN IF FNinInv(@_LIT_LAMP) THEN PROCswap(@_LIT_LAMP,@_LAMP):PROCset(@HaveLight,0):PROCmsg("The lamp is off."):=TRUE
			IF V%=@Look THEN PROCgtRm(R%):=TRUE
			IF V%=@Drop THEN IF N%=@Lamp THEN IF FNinInv(@_LIT_LAMP) THEN PROCdrop(@_LIT_LAMP):=TRUE
			IF V%=@Get THEN IF N%=@Lamp THEN IF FNhere(@_LIT_LAMP) THEN PROCtake(@_LIT_LAMP):=TRUE
			IF V%=@Get THEN IF N%&lt;@Snake THEN PROCtake(N%):=TRUE
			IF V%=@Drop THEN IF N%&lt;@Snake THEN PROCdrop(N%):=TRUE
			IF V%=@Inv THEN PROCinv:=TRUE	
		</LowPriority>
    </Section>
  </Sections>
</AdventureData>
Last edited by Lardo Boffin on Sat May 16, 2020 11:11 pm, edited 2 times in total.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

The process is fairly straight forward:

1) Parse the contents of the XML file into various objects in memory - including locations, verbs etc.
2) Load the source BBC Basic file and make a few minor changes (such as screen width) based on the XML settings
3) Replace the magic number variables in the game logic sections with the actual ID numbers

Doing this process allows lines like:
IF FNon(@IsDark) AND NOT FNon(@HaveLight) THEN PROCdec(@TurnsInDark)
rather than
IF FNon(2) AND NOT FNon(4) THEN PROCdec(1)

4) Add the code from the logic sections into the source file
5) Create an output file (in plain text) that contains the source file plus the game logic
6) Optionally tokenise (don't include the tokeniser details if you don't want to do it)
7) Write all of the data files out

After that there is manual intervention to create the SSD and run it.
Last edited by Lardo Boffin on Thu May 07, 2020 11:17 pm, edited 1 time in total.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

There is still a lot to do with this.

Aside from improving the parser (I would at least like it to be able to use 'it', e.g. TAKE LAMP, LIGHT IT), including some sort of combat mechanic and improving the object / noun relationship I would like to fully implement multiple sectioning of larger adventures. The basics of the framework to do this are in place but it doesn't do anything yet beyond a single output.

To do this there are global variables and the XML is designed to take multiple 'Sections'. Each section will compile to a separate section of the game and separate program (as the logic is implemented directly as BBC Basic commands). This will in turn mean that all of the messages for a section can be loaded into the game in one go and therefore remove associated load times.

I will need to address save games (and loading) before this can properly work as the details of each section will need to be retained along with the global data (thus allowing the adventurer to return to sections perhaps with new objects etc.). I am currently thinking a single save for the global data and a separate save for each 'section'.

Each section can also have its own source file (the BBC Basic framework program) and therefore specific code could be included in each of these to assist in the sectioning process.
Last edited by Lardo Boffin on Thu May 07, 2020 11:11 pm, edited 1 time in total.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

The XML file has the following parts:

Code: Select all

GlobalVariables
  Sections
   Section
     Build details
     System messages ('What now' and 'You can't' etc.)
     Game Verbs (North, South and East etc.)
     Adverbs (With)
     Nouns (torch, rat, key etc.)
     Variables (these map to byte valued counters)
     Objects (location, message number etc.)
     Locations (with messages and exits)
     PreRoom (logic run before the room is loaded)
     Init (logic run once at the start of the game)
     High Priority (logic run after the room is loaded and before the player types anything)
     Low Priority (all the logic that runs after the player types something)
  /Section
/Sections
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

I have updated the download at the start of the thread as I have made a few changes:

. Line numbers are no longer used in the source.txt file (and I removed the last couple of GOTO statements...)
. Comments can be added to the source.txt file (VB style, so 'this is a comment) providing they are on a separate line and start the line
. I have started commenting the source file - still a long way to go...
. If you open the source.txt file in Notepad++ and set the language to Visual Basic it does a reasonable job of syntax highlighting
. All messages are now loaded at the start of the game rather than on demand so should be a bit faster
. Save games no longer go in the S directory (as opposed to $) so as to avoid causing issues with other filing systems (I hope) - they go in the current folder
. The screen mode is now set in the adventure.xml
. Achievements have been dropped (too much hassle with read only disc images)
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

I have made a number of changes:

The compiler will now call a tokeniser (thanks to Richard Russel) and tokenise the output text file.
The compiler will now build an SSD file with the created files - SSD creation thanks to JGHarston.
The compiler will now open BeebEm with the SSD file (assuming you tell it where BeebEm is of course).

The compiler itself has had a few internal changes. There are now two methods of use, either create project or build project.

1) Create project

Open a Command prompt and navigate to the folder where you placed the adventure language exe.
Call adventurelanguage.exe -new “C:\Beeb” Ransom
to create a new project called Ransom in the folder C:\Beeb\Ransom.

This will:
Create the folder structure.
Copy the source and xml base files to the source folder.
Rename various nodes in the XML based on the project name.
Create a !boot file (to call the main tokenised program - the name comes from the first 7 chars of the project name).
Create a build file - when double clicked it will call the adventure language exe with the command switch -b and pointing to the local adventure language xml file.

2) Compile the project

To create an adventure you amend the contents of the adventure.xml in the source folder of the project and then double click the build.bat file. This calls the compiler and depending on options will create an SSD file (set to *EXEC the !boot file) and run it in BeebEm.

The Ransom.SSD is no longer in the ZIP but if you create a new project called Ransom then it should create the project (the source files contain the Ransom code) which when built creates the Ransom.SSD.

Sorry - its all Windows based at the mo! I have a Mac and will try and make it work for that at some point. Not sure about a tokeniser and SSD creation tool for the Mac though.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
lurkio
Posts: 4351
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by lurkio »

Lardo Boffin wrote: Sun May 17, 2020 11:59 am Sorry - its all Windows based at the mo! I have a Mac and will try and make it work for that at some point. Not sure about a tokeniser and SSD creation tool for the Mac though.
I've been waiting to get a chance to try this but I'm on a Mac and I didn't realise your programs were all Windows-based! But isn't that dotnet thingy that you're using a commandline system that has a runtime for the Mac?

EDIT: Ah, I see there is and I think you're saying you might convert it for Mac if you get a chance. Apologies for hassling!

:?:
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

lurkio wrote: Sun May 17, 2020 12:33 pm
Lardo Boffin wrote: Sun May 17, 2020 11:59 am Sorry - its all Windows based at the mo! I have a Mac and will try and make it work for that at some point. Not sure about a tokeniser and SSD creation tool for the Mac though.
I've been waiting to get a chance to try this but I'm on a Mac and I didn't realise your programs were all Windows-based! But isn't that dotnet thingy that you're using a commandline system that has a runtime for the Mac?

:?:
The program itself is .net - I may have to publish it as OSX before it works on a Mac (will look at that tonight) but the tokeniser and SSD creators are both Windows based. Neither are necessary and if there are Mac versions you are aware of I can include them.
Also the batch files it creates are Windows based (build.bat etc.) - never tried creating one for the Mac! Sure it can’t be that difficult though. :shock:

I have committed the ultimate sin myself - I have boot-camped Windows 7 onto my Mac. :oops:
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
lurkio
Posts: 4351
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by lurkio »

Lardo Boffin wrote: Sun May 17, 2020 12:46 pm The program itself is .net - I may have to publish it as OSX before it works on a Mac (will look at that tonight) but the tokeniser and SSD creators are both Windows based. Neither are necessary and if there are Mac versions you are aware of I can include them.
I've dabbled a bit with sweh's Perl-based tools on the Mac, but I don't use them every day, so I can't remember many details:
I know they can create .SSDs and add and remove files from them.

They may also be able to de/tokenise BASIC files, but I don't think I've ever used that particular feature.

:idea:
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

Thanks Lurkio

Between us we may get there!

I have had some success getting the process to run on my Mac. I have never built anything for the mac before so it was a steep learning curve but assuming you have downloaded the .Net Core 3.1 for the Mac then this 'should' work. :shock:

1) Download the zip and extract it to Documents. It may work elsewhere but I have no idea.
2) Open up Terminal
3) Type in (change lardo for your log in name!)
cd /Users/lardo/Documents/AL to open the folder with the program
type dotnet al.dll -new /Users/lardo/Documents Ransom
and press enter (make sure the space is present between the folder path and project name).
4) This should build the Ransom folder in your Documents
5) Open the AdventureData.xml in the Source folder and amend the following line:
<SSDBuilder>/Users/lardo/Documents/Beeb</SSDBuilder>
This needs to point to the folder where sweh's MMB utils are installed
Still in this file amend the line:
<BeebEmPath>/Applications/BeebEmMac/BeebEm4.app</BeebEmPath>
This needs to point to BeebEm


To build and run the program: -
1) Type in the following changing your username from lardo
cd /Users/lardo/Documents/AL to open the folder with the program and then-
donet al.dll -b /Users/lardo/Documents/Ransom
2) This should compile the program, build the SSD and run BeebEm
3) Press cmd+W to unlock drive 0 (can't find a way to permanently change this setting) and then F0
4) This should *exec the program to BASIC, save and then run the game

I have hopefully added some path space tolerance to the tool chain process for the Mac. Probably still issues with the main project folder and spaces in the path but will get to those eventually...

I have also added a Mac command batch file to run the build process - this is build.command in the root of the project folder. If you double click this initially you will get an error about permissions. In order to give yourself permissions to run this you need to do the following (with the caveat that I do not fully understand Mac security so have no clue what it is actually doing :D): -

Open Terminal
Type in chmod u+x /Users/lardo/Documents/######/build.command
where ###### is the path to your project

After doing this you should be able to double click the build.command file to build the project.
Attachments
AL.zip
AL with more tolerances for spaces
(33.57 KiB) Downloaded 89 times
Last edited by Lardo Boffin on Fri May 29, 2020 11:26 pm, edited 7 times in total.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

Well, it was a partial success!

I combined the files into an SSD and then opened BeebEm.

I typed *EXEC "Rawtext" (having already removed the .txt extension) but it got a few lines in and froze.
It looks like the file built on the Mac does not contain carriage returns that it recognises and presumably the input buffer fills and it dies.

If I take a raw text file created on a Windows PC it *EXECs fine and then runs.

I can only assume that the Mac creates text files slightly differently? A question for another day.

Attached is the SSD with the dodgy rawtext file. Also attached is the file itself.
Attachments
rawtext.txt
(9.38 KiB) Downloaded 78 times
Ransom.ssd
(21.25 KiB) Downloaded 87 times
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
richardtoohey
Posts: 4075
Joined: Thu Dec 29, 2011 5:13 am
Location: Tauranga, New Zealand
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by richardtoohey »

Lardo Boffin wrote: Sun May 17, 2020 11:19 pmI can only assume that the Mac creates text files slightly differently? A question for another day.
Might be line endings? i.e. CR/LF vs CR vs LF? Can't remember what OS does what. Might be a red herring! (UTF8? BOMs?)
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

richardtoohey wrote: Mon May 18, 2020 12:20 am
Lardo Boffin wrote: Sun May 17, 2020 11:19 pmI can only assume that the Mac creates text files slightly differently? A question for another day.
Might be line endings? i.e. CR/LF vs CR vs LF? Can't remember what OS does what. Might be a red herring! (UTF8? BOMs?)
Although it is the same code Windows is doing: -

0D 0A at the end of each line.

Mac is doing: -

0A only

Looks like I need to switch from using a StreamWriter to a BinaryWriter and put my own line endings in.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
richardtoohey
Posts: 4075
Joined: Thu Dec 29, 2011 5:13 am
Location: Tauranga, New Zealand
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by richardtoohey »

It's one of the "joys" of cross-platform development. Not sure what the answer is in .Net.
EdwardianDuck
Posts: 326
Joined: Thu Aug 10, 2017 9:07 pm
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by EdwardianDuck »

StreamWriter derives from TextWriter which has a NewLine property which defines the line endings. I think this defaults to the "normal" value for the platform, but you can change it so something else.

Untested, but from reading the documentation, I think that will solve your problem.

Jeremy
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

EdwardianDuck wrote: Mon May 18, 2020 9:21 am StreamWriter derives from TextWriter which has a NewLine property which defines the line endings. I think this defaults to the "normal" value for the platform, but you can change it so something else.

Untested, but from reading the documentation, I think that will solve your problem.

Jeremy
Thanks. I tried a BinaryWriter and forcing the correct elements in but that didn’t work (although I ran out of time to test it fully) so will look at that tonight if I get chance.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
EdwardianDuck
Posts: 326
Joined: Thu Aug 10, 2017 9:07 pm
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by EdwardianDuck »

Here is a working example, running on a Mac, outputing Windows style line endings.

\r = CR, \n = LF

In response to an earlier comment, # = ALT+3 on a Mac, but it's not shown on older keyboards!

Jeremy

Screenshot 2020-05-18 at 11.10.16.png
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

Thanks, that did the trick and saved me a load of reading!

I have updated the main download for the Mac further up. It should now be possible to *EXEC the raw text file into Beeb BASIC now.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

lurkio wrote: Sun May 17, 2020 9:18 pm
Lardo Boffin wrote: Sun May 17, 2020 12:46 pm The program itself is .net - I may have to publish it as OSX before it works on a Mac (will look at that tonight) but the tokeniser and SSD creators are both Windows based. Neither are necessary and if there are Mac versions you are aware of I can include them.
I've dabbled a bit with sweh's Perl-based tools on the Mac, but I don't use them every day, so I can't remember many details:
I know they can create .SSDs and add and remove files from them.

They may also be able to de/tokenise BASIC files, but I don't think I've ever used that particular feature.

:idea:
I have managed to get sweh’s tools working from Terminal so hopefully after further experimentation I may be able to automate the build on the Mac.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

Some progress with the Mac stuff - I have managed to figure out the syntax to open BeebEm with a specified SSD file using .Net Core to call a bash command.

Having got this working it should (hopefully) be fairly easy to call the SSD build function from sweh’s library.

I can’t find a tokeniser for the Mac and don’t have time to write one so I’m thinking maybe have a couple of functions keys automatically defined in the !boot file so that you can F1 to *Exec <raw text filename>
F2 to save as <game filename>
F3 to chain <game filename>
Or something similar so that only a couple of key presses are required to get it running.

I will hopefully update the download soon.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

I have the Mac toolchain nearly working - it now builds an SSD file, includes the correct output files, sets Opt 4 etc. and opens it with BeebEm.

Some finishing touches and testing to do and then back to the improvements in the actual game engine. :D
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

The Mac toolchain is now working (any bugs that I have not noticed aside) so that the project is built and run automatically. Well, nearly - you have to press F0 to *exec the program into BASIC. The toolchain relies on https://github.com/sweharris/MMB_Utils

And press cmd+W to stop drive 0 being read only in BeebEm before the file finishes exec'ing otherwise it will fail to save.

Does anyone know how to make this a permanent change in BeebEm for Mac?

Regardless I have updated the Mac download further up the post.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
lurkio
Posts: 4351
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by lurkio »

Lardo Boffin wrote: Wed May 27, 2020 10:55 pm The Mac toolchain is now working (any bugs that I have not noticed aside) so that the project is built and run automatically. Well, nearly - you have to press F0 to *exec the program into BASIC. The toolchain relies on https://github.com/sweharris/MMB_Utils
Just tested it. It all works -- so long as the path to the folder in which you place the AL folder (which doesn't have to be the Documents folder) doesn't contain any spaces!

Lardo Boffin wrote: Wed May 27, 2020 10:55 pmAnd press cmd+W to stop drive 0 being read only in BeebEm before the file finishes exec'ing otherwise it will fail to save. Does anyone know how to make this a permanent change in BeebEm for Mac?
I think you have to un-tick "Protect on Load" and then click "Save Preferences" under "Options".

:idea:
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

Thanks Lurkio!

I didn’t think about the spaces on the Mac code path - the Windows path puts “ “ around the path regardless of spaces and works fine. I will see if I can do similar for the Mac side of things.

I tried unticking it and saving preferences but it didn’t seem to do anything. I couldn’t find a setting for it in .ini or any other file I searched.
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
User avatar
lurkio
Posts: 4351
Joined: Wed Apr 10, 2013 12:30 am
Location: Doomawangara
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by lurkio »

lurkio wrote: Thu May 28, 2020 4:26 pm Just tested it. It all works -- so long as the path to the folder in which you place the AL folder (which doesn't have to be the Documents folder) doesn't contain any spaces!
Or was it the path to mmb_utils? I can't remember which path it is that's space-sensitive.

:?:
User avatar
Lardo Boffin
Posts: 2977
Joined: Thu Aug 06, 2015 7:47 am
Contact:

Re: Revised BASIC framework and tools to build an adventure

Post by Lardo Boffin »

I have added path space tolerance to the toolchain process (still may be issues with the project folder but will check that at some point) and updated the Mac download further up the post. It should also now be possible to double click a batch file to run the build process.

Other changes:

Implemented IT. You can type TAKE LAMP and then type LIGHT IT. IT just means reuse the last noun.
Added a debug build setting to AdventureData.xml <BuildType>Debug</BuildType>
If this is set to Debug then any code in the source.txt file that is prefixed with "-" (a dash) will be included in the build. If it is set to anything else then none of the code will be included.
I have included some debug code in the source.txt - if included you can type the following when running Ransom:

*C show counters once (prints out all counters and their values)
*CON always show counters
*COFF switch off counters display
*WON switch on parsed word numbers (shows the numerical value of what the parser just decoded)
*WOFF switch off parsed word numbers display

The values assigned to variables and the various word types are shown in the file EventLog.txt, e.g.

Writing Variables
1 IsDark - 1 = Dark
2 HaveLight - 0 = Has light source
3 TurnsInDark - Number of turns in the dark so far. 2 = death.
4 RatFed - 1 = The snake has had a rat
5 IsFirstTurn - 1 = first turn so maybe show an extended message
6 FoundKey - 1 = have the key
7 DoorLocked - 1 = the door is locked

All fairly useful when trying to figure out why a game is not working...
Adventure Language on GitHub
Atom, issue 5, YARRB + video noise killer
Elk
A number of econetted (is that a word?) Beebs
BBC Master, Datacentre + HDD, pi co-proc, econet, NULA
Post Reply

Return to “new projects and releases: text and graphic adventures”