Toys - Game development using the Evo SDK (part 1).

Info Guide #11
Game development using Evo SDK
 Moving on from abstract matters like
gameplay to more mundane. What is it on?
start the game? I can suggest Evo SDK.Why 
is it? Because I make games in OS─
new in this environment and quite good
studied it.

   I switched to it from the bundleC++, OpenGL
because I just wanted to do
your games, without much fiddling with the equipment─
e, development of a storage format for models and
creating a converter for it (OpenGL does not
has some standard storage format─
models), I wanted something more unique─
interesting than a banal PC. Ready engines
I was not satisfied, because game created on
someone else's engine, did not give the same joy as
a game written with your own hands entirely with
zero. I don’t speak assembly language, and the choice
I fell by myself on the Evo SDK. Here are a few
arguments in its favor (if, of course, you
the platform doesn't matter and you don't want to do it
3D games):
*Easy start. In order to simply
initialize the video card and create a launcher─ 
That window, on OpenGLyou need to write about 
code screen. The Evo SDK does not require any ini─ 
cialize, everything is ready. If there is ka─ 
image of the sprite, then you can display it all─ 
th a couple of calls. To get started you need 
just take the blankempty_project,
openmain.cand start writing your code. 
 * Resources.On the one hand, limited
Spectrum resources are a huge disadvantage 
compared to a regular PC with its gigabytes 
and gigahertz. But the limitations of the hardware 
are holding back the developer's ambitions, there are already 
It’s harder to get caught up in the preparation process 
resources. Also, unlike searching for ready-made 
textures, drawing pixel graphics is 
real art.  Programming in 
conditions of limited space with no 
a very fast processor, quickly honing it─ 
no programmer skills. Somehow I have to 
"squeeze", optimize code, invent 
faster algorithms, which in itself 
already quite interesting. 
 * "Warmth and lamp-like quality."Whatever one may say,
and ATM Turbo 2 is a ZX cloneSpectrum 
comes from the 90s, which brings back nostalgia. 

   What exactly is Evo?
SDK? This is SDCC - a cross-compiler for the languageC, 
plus a set of libraries that allow maximum─
It’s easy to distance yourself from low-level work with
hardware, and a set of utilities and scripts, allow─
lying as simply and quickly as possible from using─
finders and resources to assemble a ready-made image
TR-DOS. This whole system allows you to easily─
their body movements on a home computer, in
any editor convenient for you in a simple
and understandable languageC write a game that
will use ATM2 or Pent bells and whistles─
evo. True, you will have to pay for convenience─ 
suffer from loss of performance, increased─
large amount of code (the compiler is imperfect,
and where an experienced assembler programmer─
Lera will make do with ten teams, compilation─
Thor can use thirty or more) and
disabilities (this is not
big problem - assembler inserts
no one forbade doing it).

   You can get the current version here:
http://
alonecoder.nedopc.com/zx/evosdk_libs.rar

   In this article I will not go into detail
describe all the features of the Evo SDK and give
commentsto all its functions. All necessary─
the information you need is inreadme.txt, and
all functions are commented in detail in
evo.h. Here I will describe the new features of the SDK,
such as working with memory and disk, and so on─
there are several pitfalls with which
you may encounter when starting to work with the SDK.

   The SDK archive contains two versions
Wednesday:
 *Configured for SDCC version2.9;
 *Configured for SDCC version3.4.0(on─
available in the archiveevosdk_3_4_0_hippiman.7z)
   The differences between these versions are minimal, but they are
worth taking into account. SDCC version
3.4.0 compiles C code much better
compact and correct than SDCC2.9 version
and, it would seem, the need for an older
SDCC version is no longer required. However, SDCC is more
new version compiles the source code into
several times longer. On my Core i5 the time
compilation of SpaceMerc on SDCC3.4 takes
about four or fiveminutes versus 40-60
seconds in SDCC2.9. From here it follows I follow─
general advice. For the initial stages of the project,
when the source code is not too big and
test compilations are carried out frequently, it is better
use SDK configured for SDCC ver─
this 2.9, and in the later stages of development
upgrade to a newer version of the SDK.
   Also in the archive with the SDK build for SDCC
3.4.0 there are several additional
libraries:put_get_mem_atm.h (ra functions
bots with memory pages), additions.h
(collection of additional functions that
can significantly simplify game development─
ry). If you use the old one
SDK version, copy these headers there.

                 Graphics:

   Management says: "Graphics must
be prepared in formatBMPwithout compression─ 
tiya, with 16 or 256 colors (ne─ 
another 16 colors). For this they can use─ 
use any standard graphic editor─ 
ctors". Including standard Paint. However 
Paint can't edit the palette, but... 
saving, he selects the colors himself. For under─
cooking graphics are best suitedprograms like GIMP and Photoshop, which
are able to create “palette” images.
But there is one small detail here. GIMP
(starting from version 2.8) and new versions
Photoshop retains "palette"BMP does not─ 
how strange. From pictures taken in
these editors, the SDK cannot get pa─
liter, and all the information about flowers dry─
gets hurt, and if you put it in the image
already prepared palette, it will display─
It's okay. I highly recommend
use GIMP version2.6.9. In version
2.7.* there is a small glitch with the rendering of the work─
what space at high magnification.
   SDK can work with sprites16x1bpx
(up to 64 pieces simultaneously on the screen) and have─
There are two modes: sprite display is on─
on or off. When display is on─
using sprites, drawing all the tiles─
goes to two screens at once, when turned off
- only in the shadow screen. This needs to be learned─
when constructing an image. C is on─
With new sprites, drawing tiles goes well─
definitely slower.
   When rendering sprites transparent
colors after the 16th are considered, i.e. you can
use all the colors in the palette plusabout─
transparent, and when displaying tiles it is transparent─
The color must be specified from the palette. Next─
should be taken into account when developing a game that
transparent tiles have one color of pain─
che, and if you want to use all 16
flowers in transparent tiles, then draw them
in two layers with different transparent colors.

                  Sound:

   There should be no problems with the sound
or difficulties, but it is worth cautioning against
excessive use of Covox. Play─
conductingwav through Covox although it sounds wrong─
striking, but pauses execution
main program, which disrupts the dynamics
games, and the sounds themselves take up quite a lot─
th place in memory. Covox can be used─
when going to the menu or finishing a level
etc.

            Programming:

   Variables inside functions are desirable
declare using keyword
static, this significantly reduces the volume
compiled code.
   It is also advisable to avoid frequent calls─
wa functions with a large number of parameters─
ditch or with complex types as pa─
parameters. This increases the volume of compiled data─
bathroom code. If you work with such functions─
they cannot be avoided, they can be declared
the parameters of this function are as global ne─
belt and initialize them with data to
call.

   Game level maps andother large
arrays of data that are not needed often,
It's best to put it on separate pages
memory and, if necessary, load them into
temporary buffer in main memory. This is for─
slows down the program, but saves space in pa─
memory that can be used for more useful
things.
   To save even more space in
memory, level maps can be taken to the department─
data files on disk.

   The SDK manual promises about55 KB
under the compiled code, but the counter
code volume is lying. Already with a code volume of about
38 KB (this border can be shifted to that
or other side depending on the structure─
ry program) glitches may begin. Game
it will compile normally, but maybe not in advance─
bot, or during the game they will begin to self-promote
to appear and disappear at will
objects. If such oddities began
happens, then most likely yours has been compiled─
The code has exceeded the maximum size.

   Just above I said that the SDK can work─
thief with memory pages. For this you
you will need a headerput_get_mem_atm.h. For
writing data to memory has the following functions:
put_mem() (1 byte),put_memw() (2 bytes) and 
put_meml() (4 bytes). Where are the parameters:
 PG -number of the page where the data is written.
ADDR -address where data is written.
 DATA -the actual data itself.

   Be careful not to write data in
pages already occupied by the game for resources or
code. See which pages are under what from─
entered, it is possible after compiling the project in
compiler window. It should also be remembered
that these functions are designed to work with
ATM2 memory, and we have a total of64 pages─
nits -1 MB. The address where the data is written,
should look like this:32768+internal offset─
three pages.

   To receive data from memory there is a fu─
Functions:get_mem(), get_memw() and get_meml(),
which return 1, 2 and 4 bytes respectively─
actually.

   Now about working with the disk. In the SDK realities─
The function is called TR-DOS #3D13. Initially
it can only be called from assembly language
inserts, but inadditions.h there is a binding for this
functions onlanguageC:

void DOS (u8 pg, u8 operation, u8 blocks,
u8 sector, u8 track, u16 begin_page)
__naked

   Let's go through the parameters.

PG- number of the buffer page into which or
from which data is read or written when 
working with the disk. The value should look like: 
#0x7f-desired_page_number.
 Operation- operation number. There are more of us
In total, you will be interested in two operations: 5 - 
reading a block of sectors, 6 - writing a block 
sectors. 
Blocks- number of readable sections─
ditch 
 Sector - the initial sector from which
will read or write. 
 Track - the initial track from which
will read or write. 
 Begin_page- address in the PG page, start─
from which they will be stored in memory 
data from the disk or from which this data is 
will begin to be read(32768+offset inside
pages).

   Everything is quite simple, but it’s still painful─
For your convenience, inadditions.h there is another
function:

void load_file
(u8 *filename,u8 page,u8 saveload)

Filename- pointer to a buffer storing
disk file name (i.e. string). 
 Page- number of the page to write on
or from which to read data. 
 Saveload- operation: 1 - read, rest─
new values - record (does not create a file, it 
must be on disk). 

   Functionload_file reads the zero track─
disk disk to the buffer page specified in
dospage, then runs through the received
file records and searches for entries in them
the name of the file you are looking for. And then produces
reading or writing using theDOS function.

   To insert your files into the final─
new image and give it a freshly compiled
the program has access to them, you need to open itcompile.bat and after the line

 call ..evosdk_compile.bat

insert a line like this:

 call trdtool.exe + %output% filename.0

wherefilename is the name of the file you want─
add them to the image.

   A few words about additional functions
output text that has been added to
additions.h.
 There is a function for displaying individual characters─
specials:

void put_char_xy
(u8 n, u8 x,u8 y,u8 pcharmask)

   Displays the symboln by coordinate─
therex,y. The pcharmask parameter specifies the
character drawing method:
 -if pcharmask=0,then the symbol is drawn
excluding transparent color; 
 -ifpcharmask=1,then the symbol is drawn with
mask (transparent color number indicates─ 
viadraw_tile_key()). 

void put_char(u8 n)

   Outputs the symbol for the functionput_str(),
requires setting global
variablesoutput_x, output_y and pcharmask.

   Before using these functions also
should be selected as the current tile─
howl card card with font (via call
select_image() ).

   To display text line by line:
use function:

void put_str(u8* str,u8 fnt)

   Where str is a pointer to the string that
should be output, andfnt - image number
with font.
   Please install before use
global variablesoutput_x, output_y and
pcharmask. The symbol'^' is used in the same way as
like the null terminator, this symbol has a fun─
The function will stop outputting the line.
   These functions understand Russian and English─
English text (encoding depends on encoding
in your source code and your font, I have
CP866). INarchiveevosdk_3_4_0_hippiman.7z
in addition to additional headers you can find
graphic file font.bmp, which can be
use as a blank for your own font─
Comrade I think it’s clear that for work tex─
commercial functions must be loaded into the project─
this is an image or derivatives of
him.

   In general, that's all. According to Evo SDK I described
the most insidious moments, everything else is easy
understands it according to the SDK documentation. Just like
a good example can be found in the source code,
which come with the environment.

And for those who do not know how to write onC,on
Evo SDK the light has not converged like a wedge - there is more 
many development environments both with software─
rotation, and without. The main thing is that it is
desire, ideas and inspiration, the rest with─
lays down. Go for it!

Share your thoughts about the article