Exchange of experience - About the creation of the demonstration program "YES DEMO".

ZX News #01
                                
                                
         EXCHANGE OF EXPERIENCE.         
                                
   This section will describe
announced the creation of a demo
programs YES DEMO.             
We will analyze the entire program: from
BASIC auxiliary
procedures to the bootloader. But before
studying the following mathematics
rial, run this program and
study it carefully in your work.
                                
ATTENTION!!! To understand the math
rial, the reader must have
some knowledge.            
                                
                                
                                
                                
                                
                                
                                
 Production of any program
starts with screen planning
On the screen, if possible, not
there should be empty space.Pacno-
position of all elements of the screensaver
must obey certain
rules (this is in particular related to
but with inconvenient organization
attributes area).  For example,
frame, same as the drawing in
center, are located strictly in the
comets. It should also be noted that
that moving program elements
we (indicators, creeping line,
flying "YES") do not overlap
at each othersince it's not
provided.                 
   The screensaver was drawn in
ART STUDIO. File in A.S. format
has the name SCREEN. To reduce
amount of memory occupied by
wow, it was compressed
and is named SCREEN+ .           
                                
SCREEN+ file length is 1562
bytes, despite the fact that the file is SCREEN
has a length of 6912 bytes.         
   The character generator (font) was
also drawn in ART STUDIO.
Character generator length - 768 bytes
96 characters of eight bytes each
This file is named ABC.fnt.    
Now let's move on to consider
BASIC block BASIC.             
  Since addressing the screen
ZX-SPECTRUM area is not very good
convenient and the program would spend
a lot of time to recalculate
coordinates, then a table is created
addresses for the second third of the screen.
This table is created by 100 - 110
BASIC program lines (during
execution of these lines, the program
shows which addresses are entered-
included in the table). The table contains
64 double-byte addresses and subsequent
Actually, it is 128 bytes long.
The table file name is TABL 01$.  
 Now a little about the flying YES
(hereinafter referred to as a sprite). Position
sprite on the screen (horizontally
ntali) to predict in advance the un-
possible, and that's why he was drawn
van (again in ART STUDIO, file
SPRITE) in all eight possible
Each sprite is size 2 by
5familiar place and length 80 bytes.
After each sprite comes its
mask. Mask required Dima in order to entire surroundings sprite remained
untouched. The mask is like a cutout - There is no room for a sprite. By the way, this technique is used in all gaming programs. And again, all eight sprites and masks are inconveniently located for application, therefore with the help lines 10-40 of the BASIC program all it was translated into another fo- rmat, recorded under the name SPRITE+
The sprite will be moved along the ellipse theory. Each time, calculate show next coordinate trajectory would require a lot computer time, therefore ki 200-210 all the same program BASIC, create a coordinate table trajectories. In the considered pro- gram table of coordinates contains laughs at 101 coordinates given in the X,Y system. Thus, ta- blitz takes 202 bytes. Recognize com the ends of the table are two zeros. Final length tables - 204 bytes, name ELIPS. To write the text there were used Z00-Z80 lines pro- BASIC grams. At the end of the text stands zero - a sign of termination. The entire message has a length516 byte and name TEXT. The music was on written in the SOUND TRACKER editor Melody length - 333 bytes, address placement - Z4458, name - MUSIC. Let's move on to considering the first part of the program. If you have branded version of the magazine, then A printout was included with the disc. assembler demonstration. The writing of the program began with manufacturing of individual sub-products gram (hereinafter referred to as p/p). Every It’s convenient to write p/p separately and debug. First let's look at p/n of the creeping line, its beginning is line 1820. When accessing this the following happens: 1.shift the entire line by one pi- xel using SCROLL; 2.end check text (18Z0-1900); Z.finding the beginning of a letter in a sign cogenerator (1910-1960); 4.set the bit output address letters and number of output lines (1970-1980); 5.output of one letter bit (1990- 2180); 5.1.checking how much shift is needed no times byte letters (2000-2040) Shift counter - SCHET7; 5.2.lines 2060-2070 byte shift 5.3.direct bit output letters (2100-2140); 5.4.setting the next address screen area (2150) and following next address byte letter(2160); 5.5.checking for the end of output eighth bit of letter(2170-2180) 6.check SCHET7 onzero (2190- 2210). If not zero, then SCHET7= SCHET7-1 and output (2280-2290) . If zero, then set next letter address (2220 - 2240) and variable SCHET7(2250- 2260). P/n SCROLL (1690-1810)begins from setting the address of the right side the top corner of the running line and co- number of rows to be shifted (1690- 1700).Line shift (1710-1800). Next considered item there will be instructions for drawing indicators (2Z00-2680). The payment system itself uses the same fragment (2470- 2680) six times (for drawing six levels of indicators). For correct operation of this part you need to set the bottom address in HL indicator, and in A is the register number music coprocessor, with co- who needs to read the current channel amplitude. In lines (2З00- 2460) is performed six times setting these parameters and the INDIC fragment is used. Lines 2470-2500 read the value amplitude decrease, and 2510-2670 is not the indicator is displayed, height specified in register A. Color shifting along the frame (2690-З140). This p/n is called not at every interruption, but after times, since in the variable SCHETb two is installed. But in chalefulfillment instead of deuce the number is 190 and therefore the color begins to mix through non- how many seconds? Stirring pro- proceeds like this: shift right top horizontal (2770-2810), shift down right vertical (2850-2950) shift left bottom horizontal (2970-З010), shift up left verticals (Z070-Z120). Image flicker in center of the screen (З150-ЗЧЗО). In na- at the beginning of this procedure there is a RET, but he cleans up when he starts to re- the color on the frame (2740) gets in the way. But after replacing RET with NOP flickering will not begin immediately, since in the belt SCHETS costs 190 and not 2. The variable (3450) stores number of the color that will be painted sew image. Meaning this variable is cyclically changed ranges from 7 to 0. In lines 3280 - 3290 occurs setting image height B=5 and addresses in the upper left corner. Procedure (ЗЗOO-З420) produces coloring rectangle 5 on 7 acquaintances Now about two p/p-ahs, which work in pairs. This is RESTOR and WRITE. These two items serve for output of the shuffled sprite. The process looks like this: 1. Overwriting previously drawn "YES" (RESTOR); 2. Output of the sprite according to the new coordinates natam trajectory (WRITE); H. Delay and transition to 1.At the beginning of subsection RESTOR (1080-1З80) the height of the rubbing is set my sprite (1080) . In a loop (1090-1З70) the following is repeated translation of coordinates given in DE to (1110-1240) with the help second third address tables; finding the buffer address (1250- 1280) from which will be taken recovery information screen; restoring a line in five bytes (1290-1ЗЗО); increase vertical coordinate (1З40 -1З50); loop until All 16 lines have been restored. P/n WRITE has a structure similar to I'm chewing on the RESTOR payment card. Exactly the same the input data is the regi- string pair DE with vertical and horizontal coordinates. Only in lines 700-770 does there is a calculation going on, which sprite is from eight will be used, and then everything follows the same scenario. Lines 960-990 - immediate displaying the sprite on the screen. And now the last and most pro- flock of interrupt handling. P/n begins with the prohibition of interruption registration and entry of all registers into stack (1З90-1510). Then I call- We're mixing colors, you're water the next part of the music and flicker (1520-1540).After that all registers are restored, interruption and drainage is permitted a refund is provided from the payment order. The time has come to consider "se- rdcevin" program (1З0 - 690). At the beginning it happenssetting programs for work (1З0-З40), and namely, initialization of music, cleaning and blackening the screen, you- splash water, buffer formation ra second third of the screen, installation new character generator and parameters interruption. Then comes the main external program cycle (Z50 - 580): 1.Restoring that part of the screen on which it was imposed sprite (Z50-Z60); 2. Calculation of the next coordinate you trajectories (Z70-450); H. Setting the coordinates of the next recovery (460); 4.Calling the command line for drawing a sprite ticker and indicators (470-490); 5.Delay and timing (500) 6.Setting the next address trajectory tables (510-540); 7.Check for pressing the spacebar. If the spacebar is not pressed, then the entire the process is repeated from the first point. If the spacebar is pressed, then return all system parameters (590-660) and transition to zero TR-DOS ROM address (670-690), i.e. reset and start boot. After assembly, the machine The code is 630 bytes long and location address 37794, name CODE+ There are two files on the disk: one with the name CODE, which can be upload to GENS (which is also attached) and a file named CODE+, which is already ready for use.So, that's it for the demo to work. done. Load sequentially files to memory: address length name З0000 204 ELIPS З0204 128 TABLO1$ ZOZZ2 1280 SPRITE+ З1612 768 ABC.fnt Z2Z80 1562 SCREEN+ ZZ942 516 TEXT Z4458 ZZZb MUSIC З7794 6З0 CODE+ Upload the file from address 30000, 8424 bytes long (name LIBRARY), which includes all neo- required for work. Now if the LIBRARY file is loaded go to address 30000 and run from the address Z7794, then the demonstration will start working, but in this way running the program is inconvenient difficult and therefore you need to do it loader We'll make the bootloader mono- block (one file). For this load the GENS code file under address 30000; we type in BASIC two lines: 1 REM... 2 RANDOMIZE USR VAL "23872" By "..." we mean 34 spaces (that's how many bytes are required to place the loader). Run GENS ( RANDOMIZE USR 30000) and write a program to load zchika: 10 ORG 23872 20ENT $ 30 LD SP,29999 40 XOR A 50 LD BC,6911 60 LD DE,16385 70 LD HL,16384 80 LD (HL),A 90 LDIR 100 OUT (254),A 110 LD BC,#2105 120 LD DE,(23796) 130 LD HL,30000 140 CALL 15635 150 JP 37794 We assemble and exit the assembly Blair. Now in BASIC you can see that after REM something is written nonsense, this is machine code part of the bootloader. Take a clean one disk and in BASIC we type: RANDOMIZE USR 15619:REM:SAVE "YE S DEMO" LINE 2

Share your thoughts about the article