Add Templeng.

This commit is contained in:
CrazyEttin 2021-07-11 23:14:47 +03:00
parent 107c10ef83
commit fdaf782eca
7 changed files with 230 additions and 553 deletions

View File

@ -1,19 +0,0 @@
TEMPLE
======
TEMPLE is an assembly port for EttinOS of the web-based text adventure
game In the Temple by nortti. Its original readme is reproduced here:
A small game about a visit to a temple and the reasons for doing so.
Can be played online at https://ahti.space/~nortti/in-the-temple/ or at
https://nortti.itch.io/in-the-temple
The game is distributed under the Creative Commons Zero 1.0 Universal
license.
***
This package is part of EttinOS-extra, a collection of programs for
EttinOS, the git repository of which can be found at
https://ahti.space/git/crazyettin/EttinOS-extra.

View File

@ -1,530 +0,0 @@
cpu 8086
org 0x3000
;Intro
;Print the intro
intro:
mov si, introtxt
mov ah, 0x2
int 0x21
;Read any key to start
mov ah, 0x0
int 0x16
call readquit
;Start
;Print the text
mov si, startxt
mov ah, 0x2
int 0x21
;Read the player choice
readstart:
mov ah, 0x0
int 0x16
cmp al, "1"
je give
cmp al, "2"
je take
cmp al, "3"
je do
call readquit
jmp readstart
;Giving
;Print the text
give:
mov si, givetxt
mov ah, 0x2
int 0x21
;Read the player choice
readgive:
mov ah, 0x0
int 0x16
cmp al, "1"
je comb
cmp al, "2"
je coin
call readquit
jmp readgive
;Giving a Comb
;Print the text
comb:
mov si, combtxt
mov ah, 0x2
int 0x21
;Read any key to return back to the beginning
mov ah, 0x0
int 0x16
call readquit
mov si, crlf
mov ah, 0x0
int 0x21
jmp intro
;Giving a Coin
;Print the text
coin:
mov si, cointxt
mov ah, 0x2
int 0x21
;Read any key to return back to the beginning
mov ah, 0x0
int 0x16
call readquit
mov si, crlf
mov ah, 0x0
int 0x21
jmp intro
;Taking
;Print the text
take:
mov si, taketxt
mov ah, 0x2
int 0x21
;Read the player choice
readtake:
mov ah, 0x0
int 0x16
cmp al, "1"
je bowl
cmp al, "2"
je knife
cmp al, "3"
je idol
call readquit
jmp readtake
;Taking the Bowl
;Print the text
bowl:
mov si, bowltxt
mov ah, 0x2
int 0x21
;Read any key to return back to the beginning
mov ah, 0x0
int 0x16
call readquit
mov si, crlf
mov ah, 0x0
int 0x21
jmp intro
;Taking the Knife
;Print the text
knife:
mov si, knifetxt
mov ah, 0x2
int 0x21
;Read any key to return back to the beginning
mov ah, 0x0
int 0x16
call readquit
mov si, crlf
mov ah, 0x0
int 0x21
jmp intro
;Taking the Idol
;Print the text
idol:
mov si, idoltxt
mov ah, 0x2
int 0x21
;Read any key to return back to the beginning
mov ah, 0x0
int 0x16
call readquit
mov si, crlf
mov ah, 0x0
int 0x21
jmp intro
;Doing
;Print the text
do:
mov si, dotxt
mov ah, 0x2
int 0x21
;Read the player choice
reado:
mov ah, 0x0
int 0x16
cmp al, "1"
je sacrifice
cmp al, "2"
je iconoclasm
cmp al, "3"
je prayer
call readquit
jmp reado
;Making a Sacrifice
;Print the text
sacrifice:
mov si, sacrificetxt
mov ah, 0x2
int 0x21
;Read the player choice
readsacrifice:
mov ah, 0x0
int 0x16
cmp al, "1"
je bread
cmp al, "2"
je blood
call readquit
jmp readsacrifice
;A Sacrifice of Bread
;Print the text
bread:
mov si, breadtxt
mov ah, 0x2
int 0x21
;Read any key to return back to the beginning
mov ah, 0x0
int 0x16
call readquit
mov si, crlf
mov ah, 0x0
int 0x21
jmp intro
;A Sacrifice of Blood
;Print the text
blood:
mov si, bloodtxt
mov ah, 0x2
int 0x21
;Read any key to return back to the beginning
mov ah, 0x0
int 0x16
call readquit
mov si, crlf
mov ah, 0x0
int 0x21
jmp intro
;Iconoclasm
;Print the text
iconoclasm:
mov si, iconoclasmtxt
mov ah, 0x2
int 0x21
;Read any key to return back to the beginning
mov ah, 0x0
int 0x16
call readquit
mov si, crlf
mov ah, 0x0
int 0x21
jmp intro
;Prayer
;Print the text
prayer:
mov si, prayertxt
mov ah, 0x2
int 0x21
;Read any key to return back to the beginning
mov ah, 0x0
int 0x16
call readquit
mov si, crlf
mov ah, 0x0
int 0x21
jmp intro
;Return
done:
int 0x20
;Data
introtxt db "In the Temple", 0xd, 0xa,\
"=============", 0xd, 0xa,\
0xd, 0xa,\
"This is a story of your visit to the temple of ",\
"Arattavesh.",\
0xd, 0xa,\
0xd, 0xa,\
"Press the corresponding number to choose an option or ",\
"escape to quit the", 0xd, 0xa,\
"game.", 0xd, 0xa,\
0xd, 0xa,\
"Press any key to start.", 0x0
startxt db 0xd, 0xa,\
"Before the Idol", 0xd, 0xa,\
"---------------", 0xd, 0xa,\
0xd, 0xa,\
"You are in the back of the temple, before the idol of ",\
"Arattavesh. It is", 0xd, 0xa,\
"a well made wooden statue painted with gold and blue.",\
0xd, 0xa,\
0xd, 0xa,\
"In front of the statue there is an ornate knife and a ",\
"plain wooden bowl.", 0xd, 0xa,\
0xd, 0xa,\
"You have come here to the sanctum to...", 0xd, 0xa,\
" 1. give something.", 0xd, 0xa,\
" 2. take something.", 0xd, 0xa,\
" 3. do something.", 0x0
givetxt db 0xd, 0xa,\
"Giving", 0xd, 0xa,\
"------", 0xd, 0xa,\
0xd, 0xa,\
"You have arrived to deposit a votive offering to ",\
"Arattavesh for healing", 0xd, 0xa,\
"your sickness over the winter. You intend to give...",\
0xd, 0xa,\
" 1. a wooden comb.", 0xd, 0xa,\
" 2. a silver coin.", 0x0
combtxt db 0xd, 0xa,\
"Giving a Comb", 0xd, 0xa,\
"-------------", 0xd, 0xa,\
0xd, 0xa,\
"You hold a finely carved wooden comb in your hands. ",\
"It is a comb you", 0xd, 0xa,\
"have made yourself, the masterpiece that gave you ",\
"full rights in the", 0xd, 0xa,\
"guild. You are sacrificing not only its monetary ",\
"value, but its value to", 0xd, 0xa,\
"you personally.", 0xd, 0xa,\
0xd, 0xa,\
"You place the comb next to the knife, say a few words ",\
"asking Arattavesh", 0xd, 0xa,\
"to accept your payment, and walk back to the door to ",\
"the sanctum. A", 0xd, 0xa,\
"priest sprinkles water on you, and closes the heavy ",\
"door after you step", 0xd, 0xa,\
"outside.", 0xd, 0xa,\
0xd, 0xa,\
"Press any key to return back to the beginning.", 0x0
cointxt db 0xd, 0xa,\
"Giving a Coin", 0xd, 0xa,\
"-------------", 0xd, 0xa,\
0xd, 0xa,\
"You take out a silver coin from the pouch hanging ",\
"from your belt. It", 0xd, 0xa,\
"represents the work of several weeks as a cobbler.",\
0xd, 0xa,\
0xd, 0xa,\
"You take the coin and throw it to the fountain that ",\
"is behind the idol,", 0xd, 0xa,\
"where you hear it clink against other coins that have ",\
"been deposited", 0xd, 0xa,\
"previously.", 0xd, 0xa,\
0xd, 0xa,\
"You turn back and walk through the curtains to the ",\
"common side of the", 0xd, 0xa,\
"temple, where other devout are waiting for their turn ",\
"to enter the", 0xd, 0xa,\
"sanctum.", 0xd, 0xa,\
0xd, 0xa,\
"Press any key to return back to the beginning.", 0x0
taketxt db 0xd, 0xa,\
"Taking", 0xd, 0xa,\
"------", 0xd, 0xa,\
0xd, 0xa,\
"There it is. Right before you. You steal a glance ",\
"behing you hoping to", 0xd, 0xa,\
"make sure that nobody spots you in the darkness as ",\
"you reach out and", 0xd, 0xa,\
"grab...", 0xd, 0xa,\
" 1. the bowl.", 0xd, 0xa,\
" 2. the knife.", 0xd, 0xa,\
" 3. the idol.", 0x0
bowltxt db 0xd, 0xa,\
"Taking the Bowl", 0xd, 0xa,\
"---------------", 0xd, 0xa,\
0xd, 0xa,\
"The bowl you had offered just a week before is still ",\
"here. You had left", 0xd, 0xa,\
"it as a thanks of your husband's recovery, but now ",\
"your husband is gone,", 0xd, 0xa,\
"your fields are destroyed, and all this is the name ",\
"of Arattavesh.", 0xd, 0xa,\
0xd, 0xa,\
"If the gods shall curse you for breaching the ",\
"holiness of the sanctum", 0xd, 0xa,\
"let them, for you curse the gods too. You take that ",\
"which you dedicated", 0xd, 0xa,\
'to Arattavesh and quietly state "You have taken back ',\
"your gift and so I", 0xd, 0xa,\
'shall take back mine" before slipping back into the ',\
"night.", 0xd, 0xa,\
0xd, 0xa,\
"Press any key to return back to the beginning.", 0x0
knifetxt db 0xd, 0xa,\
"Taking the Knife", 0xd, 0xa,\
"----------------", 0xd, 0xa,\
0xd, 0xa,\
"The knife is very nicely made. You admire it for a ",\
"small while, before", 0xd, 0xa,\
"slipping it into the bag you carry around your ",\
"shoulders.", 0xd, 0xa,\
0xd, 0xa,\
"You aren't committing a sin, or if you are it's not a ",\
"great one. The", 0xd, 0xa,\
"chanter who lives in the main city has not yet come ",\
"and completed the", 0xd, 0xa,\
"dedication. The one who's knelt before the idol and ",\
"left it here has", 0xd, 0xa,\
"merely announced an intention to give it to their god ",\
"so it's still", 0xd, 0xa,\
"theirs, and they will not miss it.", 0xd, 0xa,\
0xd, 0xa,\
"If Nagiri holds up his end of the bargain your debt ",\
"shall be gone come", 0xd, 0xa,\
"tomorrow and you can leave the land you work but do ",\
"not own. You get", 0xd, 0xa,\
"excited, but then try to calm down. It is not over ",\
"yet.", 0xd, 0xa,\
0xd, 0xa,\
"You walk out into the evening crowd still in the ",\
"market before the", 0xd, 0xa,\
"sanctum. There are so many people here nobody will ",\
"remember and be able", 0xd, 0xa,\
"to speak against you.", 0xd, 0xa,\
0xd, 0xa,\
"Press any key to return back to the beginning.", 0x0
idoltxt db 0xd, 0xa,\
"Taking the Idol", 0xd, 0xa,\
"---------------", 0xd, 0xa,\
0xd, 0xa,\
"Here it is. The protector god of your village, taken ",\
"by force when you", 0xd, 0xa,\
"were but a small child.", 0xd, 0xa,\
0xd, 0xa,\
"They call her Arattavesh, after the river, but you ",\
"know better. As you", 0xd, 0xa,\
'lift the idol you whisper: "Panglya, you shall be ',\
'home soon."', 0xd, 0xa,\
0xd, 0xa,\
"Press any key to return back to the beginning.", 0x0
dotxt db 0xd, 0xa,\
"Doing", 0xd, 0xa,\
"-----", 0xd, 0xa,\
0xd, 0xa,\
"Yes, it is finally time. You make sure that ",\
"everything is just right,", 0xd, 0xa,\
"and...", 0xd, 0xa,\
" 1. take the knife.", 0xd, 0xa,\
" 2. raise your axe.", 0xd, 0xa,\
" 3. kneel before the idol.", 0x0
sacrificetxt db 0xd, 0xa,\
"Making a Sacrifice", 0xd, 0xa,\
"------------------", 0xd, 0xa,\
0xd, 0xa,\
"You take the blade, and think of the long nights ",\
"spent replaying the", 0xd, 0xa,\
"formula of the sacrifice in your head. You've seen ",\
"ones before, but", 0xd, 0xa,\
"never this one, for it is one that a priest must do ",\
"alone.", 0xd, 0xa,\
0xd, 0xa,\
"You say the words, and cut...", 0xd, 0xa,\
" 1. a loaf of bread.", 0xd, 0xa,\
" 2. your finger.", 0x0
breadtxt db 0xd, 0xa,\
"A Sacrifice of Bread", 0xd, 0xa,\
"--------------------", 0xd, 0xa,\
0xd, 0xa,\
"As Arattavesh gives you grain, you shall give her ",\
"back. A slice of every", 0xd, 0xa,\
"loaf made before the next new moon shall be hers, and ",\
"the bakers will be", 0xd, 0xa,\
"giving their share starting tomorrow. But this loaf ",\
"is special, the", 0xd, 0xa,\
"first loaf baked from new grain, and it is reserved ",\
"for the junior", 0xd, 0xa,\
"priest of the temple. Which is you.", 0xd, 0xa,\
0xd, 0xa,\
"You know that you shall not be too stingy and cut ",\
"only the skin. You", 0xd, 0xa,\
"also know you have to be exact and not cut a too big ",\
"of a slice off. But", 0xd, 0xa,\
"that is no issue. You end up with a slice that is ",\
"just right, and place", 0xd, 0xa,\
"it in the bowl before the idol.", 0xd, 0xa,\
0xd, 0xa,\
"After this is done, you lay the knife back down, and ",\
"recite one of the", 0xd, 0xa,\
"old hymns, too old for people to understand anymore. ",\
"You feel that", 0xd, 0xa,\
"Arattavesh is pleased in you as you walk up to the ",\
"roof of the temple", 0xd, 0xa,\
"house and then across to the end of the block.", 0xd,\
0xa,\
0xd, 0xa,\
"Press any key to return back to the beginning.", 0x0
bloodtxt db 0xd, 0xa,\
"A Sacrifice of Blood", 0xd, 0xa,\
"--------------------", 0xd, 0xa,\
0xd, 0xa,\
"It hurts a little but you do not care, as you let the ",\
"droplets of blood", 0xd, 0xa,\
"drip into the bowl. Just like mixing your blood with ",\
"that of your sworn", 0xd, 0xa,\
"sister cements your bond, so does giving it to your ",\
"god.", 0xd, 0xa,\
0xd, 0xa,\
"You are a fully fledged priest of Arattavesh, the one ",\
"who rules behind", 0xd, 0xa,\
"the waves and in the dark caverns of earth. You hurry ",\
"to your new family", 0xd, 0xa,\
"who are waiting at the foot of the mountain.", 0xd, 0xa,\
0xd, 0xa,\
"Press any key to return back to the beginning.", 0x0
iconoclasmtxt db 0xd, 0xa,\
"Iconoclasm", 0xd, 0xa,\
"----------", 0xd, 0xa,\
0xd, 0xa,\
"There is but one abomination in the eyes of gods bad ",\
"enough to warrant a", 0xd, 0xa,\
"death in the marshes. And that is the worship of ",\
"earthly images in their", 0xd, 0xa,\
"stead.", 0xd, 0xa,\
0xd, 0xa,\
"You raise your axe and let it fall onto the head of ",\
"the idol. There is a", 0xd, 0xa,\
"crunching sound and you see the wood split, maggots ",\
"crawling out of it.", 0xd, 0xa,\
"Of course, of course. The idol is as rotten as the ",\
"act of worshiping it.", 0xd, 0xa,\
0xd, 0xa,\
"The heathen ways are over again, and the temple shall ",\
"be cleansed. You", 0xd, 0xa,\
"raise your arms and shout as loud as you can: ",\
'"Witness me Arattavesh,', 0xd, 0xa,\
"for I will cleanse your house of the ways of the ",\
"Eluwing, and enact", 0xd, 0xa,\
'revenge on those who have it thus defiled!"', 0xd, 0xa,\
0xd, 0xa,\
"Press any key to return back to the beginning.", 0x0
prayertxt db 0xd, 0xa,\
"Prayer", 0xd, 0xa,\
"------", 0xd, 0xa,\
0xd, 0xa,\
'"You who will remain when I am gone', 0xd, 0xa,\
"To help my family in time of need", 0xd, 0xa,\
"To shield the eastern flank of this city", 0xd, 0xa,\
"To leave the graves of our ancestors safe", 0xd, 0xa,\
"To bring the flood as you have brought", 0xd, 0xa,\
'I ask you"', 0xd, 0xa,\
0xd, 0xa,\
"Press any key to return back to the beginning.", 0x0
crlf db 0xd, 0xa, 0x0
;***
;Quit the game
readquit:
;Check for keypress Q
cmp al, 0x1b
je done
;Return
ret

47
TEMPLENG/README.MD Normal file
View File

@ -0,0 +1,47 @@
TEMPLENG
========
TEMPLENG is a text adventure game engine based on my earlier, standalone
EttinOS port of In the Temple.
Syntax: TEMPLENG DATAFILE.DAT
Press any key other than escape to start the game or to return back to
the beginning after an ending, the corresponding number to choose an
option in a non-ending scene, or escape to quit the game.
TEMPLE
------
Included in the package is TEMPLE, a TEMPLENG port of the web-based text
adventure game In the Temple by nortti. Its original readme is
reproduced here:
> A small game about a visit to a temple and the reasons for doing so.
>
> Can be played online at https://ahti.space/~nortti/in-the-temple/ or
> at https://nortti.itch.io/in-the-temple
>
> The game is distributed under the Creative Commons Zero 1.0 Universal
> license.
The data files
--------------
A data file consists of an intro text ending in a null followed by any
number of scenes. See the included TEMPLE.DAT for an example.
A scene begins with a start of heading (0x1) and consists of its ID, the
number of options it has, and the scene text, all ending in a null. The
ID of a scene consists of a string of numbers representing the choices
that lead to it, and can be between 2 and 255 characters long including
the null. The ID of the first scene is 0. The number of options can be
anything between 0 and 9, 0 indicating an ending. The options of a scene
must point to scenes placed after it in the data file. The scene text
should not exceed 24 lines or all of it won't fit on the screen at once.
***
This package is part of EttinOS-extra, a collection of programs for
EttinOS, the git repository of which can be found at
https://ahti.space/git/crazyettin/EttinOS-extra.

BIN
TEMPLENG/TEMPLE.DAT Normal file

Binary file not shown.

179
TEMPLENG/TEMPLENG.ASM Normal file
View File

@ -0,0 +1,179 @@
cpu 8086
org 0x3000
;Set the stack
cli
mov sp, stack + 0x100
sti
;Check for an empty tail
;Check
cmp byte [si], 0x0
jne extract
;Print an error message and abort if the tail is empty
mov si, errormsg
mov ah, 0x2
int 0x21
je done
;Find the end of the data file name and add a null if needed
;Set DI at the tail
extract:
mov di, si
findend:
;Check for the string end
cmp byte [di], 0x0
je load
;Check for a space
cmp byte [di], 0x20
je addnull
inc di
jmp findend
;Add a null
addnull:
mov al, 0x0
stosb
;Load the data file
;Load
load:
mov bx, stack + 0x100
mov ah, 0x0
int 0x22
;Check for errors
cmp al, 0x0
jne done
;Setup
start:
;Set SI to the beginning of the data file
mov si, stack + 0x100
;Initialise the scene ID with zeroes and set DI at its beginning
mov di, sceneid
mov cx, 0xff
mov al, 0x0
rep stosb
mov di, sceneid
;Intro
;Print the intro
mov ah, 0x0
int 0x21
;Read any key to start
mov ah, 0x0
int 0x16
call readquit
;Set the ID of the first scene
mov al, "0"
stosb
;Search for the current scene
searchscene:
lodsb
cmp al, 0x1
je checkscene
jmp searchscene
;Check for the current scene
;Set DI to the current scene id
checkscene:
mov di, sceneid
;Load the current characters
checkloop:
mov al, [si]
mov bl, [di]
;Compare the characters
cmp al, bl
jne searchscene
;Check for the string end
cmp al, 0x0
je loadoptions
;Compare the next characters
inc si
inc di
jmp checkloop
;Load the number of options to BL
loadoptions:
inc si
lodsb
mov bl, al
;Print the scene
;Move SI to the beginning of the scene text
inc si
;Print the scene
mov ah, 0x0
int 0x21
;Read the player choice
;Set DI at the options key
readchoice:
mov di, options
;Set the maximum number of options
mov cx, 0x9
;Read a keypress
mov ah, 0x0
int 0x16
;Check for quitting
call readquit
;Check for an ending scene
cmp bl, "0"
je ending
;Compare the keypress to the key
cmpchoice:
cmp al, [di]
je setscene
cmp bl, [di]
je readchoice
inc di
loop cmpchoice
jmp readchoice
;Set the next scene
;Find the end of the current scene id
setscene:
mov di, sceneid
findidend:
cmp byte [di], 0x0
je addoption
inc di
jmp findidend
;Add the chosen option
addoption:
stosb
;Go to the next scene
jmp searchscene
ending:
mov si, crlf
mov ah, 0x0
int 0x21
jmp start
;Return to the system
done:
int 0x20
;Data
errormsg db "File not found", 0x0
sceneid times 0xff db 0x0
options db "123456789"
crlf db 0xd, 0xa, 0x0
;***
;Quit the game
readquit:
;Check for keypress escape
cmp al, 0x1b
je done
;Return
ret
;***
;Stack
stack:

View File

@ -19,8 +19,8 @@ zip -r ROT13.ZIP ROT13.BIN ROT13.ASM README.MD CC0 1>/dev/null
mv ROT13.ZIP ..
cd ..
cd TEMPLE/
nasm TEMPLE.ASM -f bin -o TEMPLE.BIN
zip -r TEMPLE.ZIP TEMPLE.BIN TEMPLE.ASM README.MD LICENSE.MD 1>/dev/null
mv TEMPLE.ZIP ..
cd TEMPLENG/
nasm TEMPLENG.ASM -f bin -o TEMPLENG.BIN
zip -r TEMPLENG.ZIP TEMPLENG.BIN TEMPLENG.ASM README.MD LICENSE.MD TEMPLE.DAT 1>/dev/null
mv TEMPLENG.ZIP ..
cd ..