"An Unexpected Journey"
"An Unexpected Journey" - a look from the inside
STD
Recently on zx-pk.ru a forum member from Psko─
va under the nickname STD posted in the general DOS─
stupid my text-graphic adventure
"An Unexpected Journey", which performed─
nena in a rather unconventional manner on
background of a mass of modern games made on
AGD engine.
We asked the author to talk about technology─
chesical part of this game.
* * *
Required lyrical introduction:
The author himself understands perfectly well that he created
the code they gave is clumsy and wooden, which
he eats Specky's memory, as if not in himself, but
also, that when viewing the listing by masters
level of Alone Coder and GoodBoy they take risks
earn eye bleeding. But. My
The engine still has one advantage. He
against all odds it works! So take a look─
view him and this article as a totality
some ideas that someone has already thought about, like
source material for your creativity and
improvement, be it your will.
So, what is “Unexpected─
new Journey" from a programmatic point of view─
hundred and how is everything organized there?
The program engine was written entirely by me
in assembler and completely in ZXASM - 100%
authentic development in2017, which is
gave me a lotpleasure itself
to yourself.
Memory allocation
When developing a game for the location
engine in memory I allocated space from26000 to
32767(#7FFF), that is, until the very end of the 2nd
memory window or only about7 KB. In action─
vitality in compiled form
the engine took 4-odd kilobytes, but
I didn't change anything.
From the address 32768 (#8000) and up to 37900 ras─
a buffer is placed for processing the current scene
games. Thus, any single
the game scene cannot occupy more than5123
bytes of memory. More about the scenes below.
From address 37900 and up to 38000 is located
space for flags in the game.1 flag = 1 byte.
Thus, you can operate in the game
a hundred flags.
From38000 there is a clipping buffer
various small sprites. I used it─
shaft for cutting and temporary storage of ku─
screen judgments when I opened the "leaf" window
points" (in which the player chose all actions
viya), because it was not strictly rectangular─
new form,which is why the standard is laid down─
The procedure for saving the game in the program─
fics under the opening window can’t handle it─
I was lying.
The game font is stored from address47000: 2KB
encoded 866 until the very end of the 3rd window
memory, that is, by49151 (#BFFF) enable─
flat.
As you can see, from the address38000 to 47000
entire 9 KB of space. For cutting small
you don't need so many sprites, of course. Yes so
It just so happened that such a hole remained.
From the address 49152 (#C000), as is known
even for kids, the 4th memory window begins,
where on128K you can connect banks (page
nits) memory0,1,3,4,6,7. I used them
as follows:
Page 0 - blocks are always loaded into it─
ki scenes, i.e. actual text files with
descriptions of locations, teams, etc. In my game
on the disk they have namesblscOO, blscO1,
blscO2, ... blsc13.
Page 1 - right blocks are loaded into it
items that the player sees in the "photo" window
fii" and which accompany the display of texts.
On the disk these are filesblspOO ... blspO5.
Page 3 - individual
sprites needed for the game (clip, medal─
ka in the achievements window, meme "wise old man",
floppy disk "save" and "leaves" for the window
selecting an action"). They are all stored in the file─
legfxOO.
Page 4 - from address #C000 it contains─
the main menu of the game is located, from the address57000 -
main game screen (actual block─
notes, pen, photograph).
Page 6 - not used.
Page 7 - reserved for buffer for co─
storing screen contents under the opening
we wash the window. The preservation procedure may dry─
wound sequentially up to4 open windows.
To the programmer about the addresses where exactly this is
within this page is saved, do─
no need for mother.
The principle of building the engine
The engine can be divided4 logically about─
assembled parts.
1.Initialization part.
Starting fromORG 26000 to the GLVOO mark.
This piece of code only works the first time
when starting the program, it displays a stagnation─
wki, initializes internal variables
program, downloads the font and uploads it to the page─
nitsu0 the first text file with the first block─
com game scenes -blscOO.
Field of this, the engine proceeds top.2.
2.Transferring the current scene to the buffer─
works.
From the markGLVOO to GLVO2 a small kuso─
the program check is taken from internal changes─
enginePOZGL (that is, POSITION GLOBAL─
naya) address of the beginning of a specific scene in the block
scenes that now need to be processed, and
transfers it from this address to a higher one─
specified buffer of the current scene at32768
(#8000). In this case, one scene from another from─
divided with a marker#FE. That is, as a result─
the work of this part of the program is a piece of memory─
from the zero page from the addressPOZGL to
the first code encountered#FE will be overridden─
roshen to addresses with32768 (#8000). At the same time
this piece, as I already wrote, should not be
more5123 bytes, otherwise it will overwrite the flags!
When you first start the programPOZGL for─
is worn#C000, so the GLVOO procedure...
GLVO2 will transfer the very first one to the buffer
(zero) scene fromblscOO.
After the program encounters the code
#FE, scene transfer ends. In pe─
belt POZIC (i.e. current POSITION) for─
the number is worn#8000, that is, we stand on─
the beginning of the buffer where the processed
scene, and go top.3.
3.Processing the current scene or "block"
control code recognition".
Starts with markOSNOO and goes to met─
ki OSNZCH. The engine runs in this block
90% of the time.
From the variable POZIC the address in
processing buffer of the current scene. If we
just started processing the scene, it will be
#8000. Now we take names from this address
commands and begin to compare them with command─
mi, hardwired into this part of the engine. Names
all possible commands are protected in this block
programs. As soon as all three successions─
the letters read from the buffer will coincide
with three letters of any command, zashi─
ty in this block, then this block calls
from4th part of the program directly
its handler. After processing in4th part
programs and control command execution
returns here again, variablePOZIC
increases (since after the command the usual─
but there are its parameters, which only
that they were used, processed, and now they are
necessaryskip) by as many bytes as
she started pointing to the next command,
and control returns to the beginning of this
block.
If this block contains the command
"go to another scene", then after it you─
addition to the variablePOZGL will be entered
address of this scene to go to,
and control will not return to the beginning of the block3,
a will be transmitted to block2.
4.Procedures for processing control codes─
Dov.
If the program block 3 only recognizes
commands and, after recognition, calls them
handlers, then the block4 contains names─
but these are the same handlers.
That is, all the procedures are located here
"open window","close window","print
sprite","print text", "wait for click
any key" etc.
There is really nothing more to say. This
the lower level, the very basis of the program.
Teams
To implement my game, I came up with
the following commands that were enough for me with
more than:
WWN- sets the parameters of the current
the window with which everyone will continue to work
procedureswindows;
WC1- clears the entire current window,
including frame field;
WC2- clears the inside of the current
entire windows, without frame margin;
WCL- fills the current window with color;
WRM- draws a frame in the current window;
WCT- cuts out the background under the current window in
buffer. Can save 4 sequentially
windows! The cut out window background is placed in
bank 7;
WST- completely draws the current window -
cleans it, fills it with color, draws a frame;
WPT- restores the saved background
from under the window from the buffer. The procedure can
therefore restore the background of 4 windows, co─
stored procedureWCT;
WN1- quick installation currentAND OUTPUT
game window 1 (i.e. the actual page at the bottom─
vnik, where all the text is printed);
W2O- quick installation, saving photos─
on and output of the sprite of the "Leaflets" - "selection" window
actions";W2С- quick closing of the "de-selection" window
actions";
WЗO- quick installation, saving the background
and the output of the "help" window sprite;
WЗC- quick closing of the "help" window;
WО- quick installation, saving the background
and the output of the "achievement" window sprite;
WЧC- quick closing of the "reached" window
nie";
";"- comment. All further text
ignored until line feed;
"Enter"- line feed sign, ignore─
rushes. Introduced for ease of editing─
nia;
BNK- "Enable the selected memory bank─
tee. Byte with memory page number +48
(i.e. just a text number from 0 to 9)";
PAU- wait for any key to be pressed;
CLS- clears the screen;
FDI- lights up the screen;
FDO- turns off the screen;
LDF-Uploading a file by name. Loading
always occurs at the address#C000and at that
memory bank, which at this moment is stored─
tan to this address with the commandBNK;
TXT- text printing command. Has its own
own control codes;
CSP- cut out an arbitrary sprite;
PSP- print an arbitrary sprite;
SP1- displays a sprite with a number from00
to16 from the sprite block to the "photo" window
fii";
JMP- unconditional transition to the scene with
the specified number in the current block of scenes;
FON- turns on the selected flag in the block
variables;
FOF- turns off the selected flag in the block
variables;
JMF- transition to the scene depending on
whether the selected flag is enabled or not;
VIB- transition to the scene in accordance withby pressing keys1-4,in the "leaflets" window;
VIN- special operator in the game. Used
the only time, to check whether he completed
the main character of all three tasks, and if so,
then he throws him to the witch’s mountain.
These simple commands were enough to
write a game. I will say more, of all of them
95% of cases are used with a dozen.
Commands WN1, W2O, W2С, WЗO, WЗC, WЧO,
WЧC were introduced for the convenience of setting scenes. Their
it would be possible not to enter, but then it would be done─
avoiding very frequent actions, such as opening
and closing the windows "clip", "leaflets" and
etc. would have to be done in a series of operations─
ratorWWN, WC1, WCT, WST, WPT with parameters─
ramie. Therefore, I thought that the most chapters─
New windows in the game can be designated as their own─
operators and open and close them
need to be by “proper name”, for example,
W2O/W2C. Once - and that's it!
Structure of scene blocks
The entire text of the game takes up about18OKB.
It is divided into files up to1bKB in size:
blscOO, blscO1, blscO2, ...blsc13.
At each moment of time per page0
only one of these can be loaded
files.
Inside, each file consists of separate
scenes that are separated from each other by mark─
rami#FE.
Each scene consists of commands for movement─
LCD, parameters of these commands and text for
player who is printed on the coma screen─
ndoyTXT.
The engine takes from the downloaded page─
nit0 block of scenes one scene (called
current) to the processing buffer of the current scene with
addresses #8000 and in this buffer are consecutive─
processes all its commands efficiently.
Since the scene is processed in this boo─
fer, and not in the zero page, then during
execution of this current scene by those located
in it you can easily switch commands
memory banks, load sprites there, load
other blocks of scenes and move to them.
The buffer was introduced precisely for this purpose.
Well, now, for example, a piece of the outcome─
of the scene block text. What does it look like in
game, you've seen it, but this is what it looks like
for its author in Notepad++:
;Scene 00 "Menu"
BNK 1 -turned on bank 1
LDF blspOO C - loaded the first block there
sprites
BNK 4 - turned on bank 4
FDI 49152 - brought the picture from there
main menu of the game, which
has already been uploaded there
BNK 0 - returned to bank 0
FOF 03:FOF 04:FOF 05:FOF 06 FOF 07:FOF 08
FOF 09:FOF 10:FOF 11:FOF 12:FOF 13:FOF 14
FOF 15:FOF 16:FOF 17:FOF 18 FOF 19:FOF 20
FOF 21:FOF 22 - reset all game flags
JMP 01 - moved to stage 1
· - this is the #FE marker of the end of the scene
;Scene 01 "Menu"
VIB 3,02,06,03 - the scene consists of one
commands: wait for the player
will press one of three possible
keys: 1, 2 or 3,
and move accordinglyto scenes 2, 6 or 3.
·
;Scene 02 "Introduction"
WWN 03,03,26,18,096,180,06,04
WCT:WST - with these commands we displayed a window
for the introduction, keeping the background under
him
TXT
Hello, my young friend!
I don’t know who you are, but you, in
turn, you don’t know what
for the book in your hands. And ho-
Your personality is important to me -
will always remain a secret, its own
I'll tell you a secret.
This is a Diary. Moreover -
this is a LIVE diary that co-
holds my LIVING memories.
Since you hold it in your hands,
means I,finally, years later,
found time to write down those
PAU:WC2:TXT - wait for any key to be pressed
clear and print further...
Conclusion
It seems to me that everything worked out overall
very simple and very elegant. If is─
use exactly the same interface as
me, then play in this style, but with my own
the plot can, in principle, develop something
a handyman who is not at all familiar with BASIC or
with assembler, just in Notepad++ (of course
if you do not take into account the need to create
blocks of sprites for "photos" that
I also created assembler programs
mami, and the need to change title
screens). But overall, still...
Of course, there are certain rough edges─
bitterness and absurdity even in those invented by me
teams. Already in the process of setting scenes, I...
realized that a couple of them should be very
change, but a lot of game has already been collected, and
I didn't redo it. This is exactly what caused─
indicated the presence in it of many “technical”
scenes that are not visible to the player, but they come─
elk to enter in order to correctly ha─
Show a dialogue window when the plot branches.
In general, I was quite fascinated by the idea of possibly
development requirements are truly universal─
a real engine for this type of game, what I'm talking about
alreadywrote on the forum. I think it was
it would be great if it appeared on the ZX platform─
there was a product that would allow
use different fonts, set a pair─
meters of their windows, and so on, and so on, and everything
this is without going beyond Notepad++. This
if only we had AGD - Adventure Game
Disinger from Russia wiz Love!8)
Always yours, STD.
Share your thoughts about the article