Programmers - Basic - 8: End of description of Beta-Basic. Mega-Basic and Laser-Basic or what can be done on regular Basic.

ZX Format #08
Mega-Basic and Laser-Basic   
              or              
       what can be done       
      in regular BASIC       
                               
music by IRONMAN               
(C) D. Rudovsky                 
________________________________
                               
  PFirst of all, I should note that Me-
ga-Basic (hereinafter MB) differs little-
is available according to the capabilities of Beta-Basic, which
which was described in previous articles.
Therefore, the description of the MB that will be given
below will be based specifically on the description
Beta BASIC.                            
                               
          MEGA-BASIC          
                               
    Let's start with the technical characteristics:  
                               
  MB BB     
                               
Memory occupied: 21240 18577   
Average acceleration                  
 program operation: 1.2 2.5    
Number of additional                  
 procedures: 20 30    
functions: 18 21    
Working efficiency in                  
 comparison editor                  
with standard BASIC: 1.0-1.5 2-3   
                               
  As can be seen from the table, MB is inferior to BB in terms of
all parameters. However, MB still applies
due to more powerful window support
while the BASIC program is running, and also
no conflicts with TR-DOS.          
                               
        Text editor        
                               
  - Call to edit the current
lines.                                  
  - clears the input line.    
  - erases the character to the right of
cursor.                                 
 <>=> - cursor to the end of the line.           
 <<=> - cursor to the beginning of the line.          
 <<>> - removing text to the right of kypco-
ra.                                      
  - listing from the current line.   
  - current line pointer set
scroll to the previous line.               
  - current line pointer set
move to the next line.                
                               
      Description of commandsMB       
                               
   WINDOW_X,Y,D,W - this command allows
define arbitrary windows on the screen (
well, of course, within the screen itself
), while X,Y are the coordinates of the window, and D and
W - width and height respectively.      
   CURRENT_N - the previous command is available
I wanted to redefine the current window, and for
to select the current window, this code is used
cunt. Parameter N - (and it can be from 0
to 9) determines the number of the window that will be
children are active after using this co-
cunts.                                   
 CLW_N,A - Cleaning the window. Window number for
is given by parameter N, and parameter A specifies
cleaning method:                           
            A=0 - the window is cleared together  
                 with attributes;           
            A=1 - the window is cleared without at- 
                 ributs;                
            A=2 - window inversion;         
            A=3 - only attri- 
                 bottles.                   
   PAN_C,A - this command allows you to shift
move the contents of the window horizontally when
In this parameter C defines the fill color
vacated part of the window (0-Ink, 1-Pa-
reg), parameter A determines the direction and
shift value ("+" - left, "-" - right)
va).                                     
 SCROLL_C,A  - actually, this
the command is similar to the previous one, but
the only difference is that the content shifts
my windows are not horizontal, but vertical -
whether and, accordingly, parameter A determines
shift from above or below.                  
   PANW_A - this command is similar to the command
de PAN_, only here the cyclic
Czech shift, i.e. gone to the right appeared
appears on the left and vice versa and the parameter corresponds
responsible only one.                  
   SCROLLW_A -  cyclic window shift,
similar to SCROLL_, see details
she.                                      
   MODE_N,A - this command allows you to set
update the font size in window N according to
twee with parameter A:                     
           A=1 - 4x8 pixels;           
           A=2 - 8x8 pixels;           
           A=3 - 8x16 pixels;          
           A=4 - 16x16 pixels.         
                               
 STIPPLE_N - this command allows you to select
fill in the characters for the mode, set up
commanded by the MODE_N,4 command. N co-
holds a bitmask to fill.     
   FONT_N - command is necessary to install
New font N in the current window. The MB uses
uses 3 fonts: 0 - standard
BASIC font; 1, 2 - MB fonts that
You can replace it with your own.                   
   SPRINT_X,Y,A,P,A$ - this command is
is an alternative to the PRINT AT command and
allows you to display the text A$ in coordinates
X,Y with horizontal scaling of symbols
umbrellas with coefficient A, and vertically
with coefficient P.                       
   CHANGE_N,A - changes the attribute everywhere,
equal to N, to an attribute equal to A.          
   SWAP_N,X  - inserts the N attribute instead
attribute X and vice versa.                   
   FADE_N - consistently scans
attributes without changing those that are smaller
or equal to N, and reducing those that are more
she. The team works until everything is done
attributes will not become less than or equal to N. 
   INVERT - actually, the purpose
This command is evident from the name. She uhbeptu-
Opens the current window.                       
   DEFG_A$,N1,...,N8 - definition command
divides the user symbol A$, which
determined by 8 bytes N1...N8.          
   GET_0,A,Y,X,D,W -  very useful code
a command that allows you to save part of the screen
with coordinates X,Y and dimensions D and W in width
line and height, respectively, to A.  
   PUT_F,A,Y,X,D,W - the command is reverse
previous  It displays the previously recorded
addresses A part of the screen in X,Y coordinates,
height W and width D according to method F:       
            F=0 - COPY;                  
            F=1 - AND;                   
            F=2 - XOR;                   
            F=4 - COPY without attributes;    
            F=5 - AND without attributes;     
            F=6 - XOR without attributes.     
                               
   SPUT_A,Y,X,B,C,W,D - command similar -
onprevious, B and C scale factors
bidding.                               
   REPEAT ... UNTIL_N - cyclic design
la, alternative FOR... NEXT. Expressed
The value of N determines the condition for exiting the loop.
If N=0, then the body of the cycle is repeated, otherwise
why the cycle is interrupted.                     
   PUSH_A,B  -  pushes the number onto the stack
lines and operator number.                
   POP - pops the top value from the stack
tion.                                     
   MTASK_N - multitasking organizer
(2-task) mode. Upon receipt of the
mand, a second entry point is installed
into the program from line N. If N=0, then
single-tasking mode is restored.    
   PLAY_N,L,S,D,F  - Operator extension
FAN. N - tone (0-pure tone, 1-noise);    
         L - step length;                 
         S - initial frequency;  D - number of steps;           
         F - frequency increment per step. 
                               
   SON, SOFF - turn on and off the
hepatopa sounds on interruption.           
   SREP_N - number of data repetitions,
written to the buffer.                      
   SOUND_N,A,B,C,D -  entering data into
sound generator buffer.                 
                               
         N=0 - buffer clearing and recording from 
              started.                    
         N=1 - audio recording at the end of the  
              fera.                      
         A - similar to N in PLAY;        
        B - similar to F inPLAY;        
         C - number of steps for a single 
            startup;                     
         D - number of starts.             
                               
   DOKE_N,A  -  writing a word (2 bytes) to
memory.                                  
 CALL_N  - call a subroutine from the address
N.                                       
                               
         LASER-BASIC          
                               
   Laser-Basic (hereinafter referred to as LB) is intended
to create programs that use dynamic
mystical raster graphics. LB Editor
practically no different from standard
BASIC and as part of editing teams
text, only two commands were entered - .RNUM
and .REMK.                                 
    .RNUMa,b,c - is intended for re-
numbering. a - old line number, with
renumbering will be performed; b-
new number that will be assigned to the first
howl line from the block; c - step nepehymepa-
tions.                                     
    .REMK - removes all comments from
programs.                               
                               
   Basic Laser Variables    
                               
   For working with sprites and the screen in LB
several graphical variables have been introduced,
with which LB procedures work.        
                               
 .COL : horizontal coordinate;       
 .ROW : vertical coordinate;         
 .LEN : length;                           
 .HGT : height;                          
 .SRW : horizontal coordinate inside
        sprite;                         
 .SCL : vertical coordinate inside
        sprite;                         
 .NPX : shift value in ver- commands
        tick shift;               
 .SPN : current sprite number;          
 .SP1 : source sprite number for op-
        walkie-talkies with two sprites;         
 .SP2 : receiver sprite number for op-
        walkie-talkies with two sprites.         
                               
   The variables .COL, .ROW, .LEN and .HGT can be
can be used both for the screen window
on, and for the sprite window.              
                               
      Sprite processing       
                               
   Used to create sprites
the following commands:                       
                               
 .SPRT :                                
     allocates space for a sprite, opuehtu-
    based on the variables LEN and HGT. So
    thus allocated volumeequals
    9*HGT*LEN+5.  The place stands out for sure
    xy;                                  
 .ISPR :                                
     similar to the previous command, but
    space is allocated below;              
 .GTBL :                                
     fills the sprite with data from the screen, in
    according to the size of the sprite when
    emhuka. For this command in variables
    COL and ROW must be located coordinates
 the area of the screen that will be repainted
    moved to sprite.                   
 .GTOR :                                
     similar to .GTBL, but the transfer is
    referred to as OR;                   
 .GTND :                                
     similar to .GTBL, but the transfer is
    Identified by AND;                  
 .GTXR :                                
     similar to .GTBL, but the transfer is
    Available via XOR;                  
                               
   Along with sprite creation proceduresit is necessary to mention the removal procedures
sprites: there are also three of them. .WSPR reverse co-
mande .SPRT, .DSPR is the reverse of the command .ISPR,
and .CLSM clears the SPN sprite.              
                               
    Several service commands:          
                               
 .INVM :                                
     produces an inversion of the sprite, number
 which is specified in the SPN.                
 .MIRM :                                
     mirroring the sprite around
    its central axis.                 
 .MARM :                                
     reflection of sprite attributes.        
 .SPNM :                                
     rotate sprite SP2 90 degrees
    clockwise, the result is entered
    fits into sprite SP1.                  
 .DSPM :                                
     increasing the size of the SP2 sprite by 2
    times.  The result is entered into the sprite
    SP1.  SP1 should have twice the
    sizes bycompared to sprite SP2,
    otherwise damage to neighboring ones will occur
    sprites and the SP1 sprite will be corrupted.
 .SRTM :                                
     setting permanent INK attributes and
    PAPER in the SPN sprite.                 
                               
    And finally, the shift command:       
                               
 .WL1M, .WLХM, .WL8M :                  
     shift the sprite to the left by 1.4 and 8 pixels
    mudflows with return.                   
 .WR1M, .WRХM, .WR8M :                  
     shift the sprite to the right by 1.4 and 8 pixels
    mudflows with return.                   
 .SL1M, .SLХM, .SL8M :                  
     shift left without returning.           
 .SR1M, .SRХM, .SR8M :                  
     shift right without return.          
 .WCRM :                                
     vertical scrolling with return,
    direction and magnitude of shiftsets-
    Xia variable .NPX                   
 .SCRM :                                
     vertical scrolling without returning,
    the direction and magnitude of the shift is determined by
    Xia variable .NPX                   
 .ATLM :                                
     scrolling attributes to the left with return
    vol.                                 
 .ATRM :                                
     scrolling attributes to the right with return
    vol.                                 
 .ATUM :                                
     scrolling attributes up from return
    vol.                                 
 .ATDM :                                
     scrolling attributes down from return
    vol.                                 
                               
       Working with windows.        
                               
    The window in the LB is determined by the variables
COL, ROW, LEN, HGT, and sets of these
variables can be saved usingpe-
belt SET.  This variable allows
assign a number to the dial, so that later,
By assigning this number to the SET variable, we
restored the values of the variables of this
set.  There can be up to 16 sets in total.
Example:                                  
                               
 10 .SET=0: .COL=10: .ROW=10:          
 .HGT=5: .LEN=5                      
 20 .SET=1: .COL=0:.ROW=0: .HGT=22:    
 .LEN=32                            
 30 .SET=0: LET X=?COL: LET Y=?ROW:    
 LET L=?LEN: LET H=?HGT              
 40 PRINT X,Y,L,H                      
                               
Result:                               
                               
10   10                     
5   5 The .CLSV command is similar to the command
.CLSM, but executed for the current window,
and the .SETV command is similar to the .SRTM command,
although it is executed for a window.               
    Almost all teams working with
sprites are duplicated for windows,
only instead of M at the end of the command they have
costs V. Therefore, I will only focus on
commands for displaying sprites in a window.         
 .PTBL :                                
     displaying the sprite on the screen. COL and ROW
    contain the output coordinates, and SPN no-
    measures of the output sprite.              
 .PTOR,.PTND,.PTXR :                    
     similar to PTBL, but sprite overlay
    that is shown on the screen according to the principle
    OR, AND and XOR respectively.        
 .PWBL,.PWOR,.PWXR,.PWND :              
     this group of commands is identical to the group
    .PTBL, but produces non-sprite output
    entirely, and the windows from the sprite onto the screen.
    The following parameters are used:  
.COL,.ROW : output coordinates on the screen;  
.SCL,.SRW : window coordinates insprite;   
.HGT,.LEN : window sizes;                
.SPN : sprite number.                    
 .ATON,.ATOF :                          
     turning on and off the transfer mode
    nose attributes of the sprite to the screen.     
 .MOVE :                                
     moving the sprite.  Sprite SP1
 XOR principle is placed at the position
    COL,ROW;  then sprite SP2 is placed
    to position COL+LEN,ROW+HGT. Parameters:
.COL,.ROW : initial coordinates;        
.HGT,.LEN : movement offset;       
.SP1,.SP2 : start and end sprites.
                               
      Reading current       
     variable values      
                               
    Forobtaining values of LB variables
a special recording form is used:   
                               
       LET VAR=?FUN, where                 
                               
 VAR : BASIC variable;              
 FUN : LB variable.                   
                               
NB! constructions like:          
                               
    PRINT ?COL                          
    LET X=?COL+DX                       
                               
    In addition to the variables described above, in LB
there are several specific variables,
which cannot be installed:               
 ?KBF :                                
     is not equal to 0 if the COL key is from
    row row ROW is pressed;                   
 ?SCV :                                
     equals 0 if the location is familiar with the coordinate
    tami COL,ROW is empty;                  
 ?TST :                                
     looks for a sprite with an SPN number, if it
    no, it gives an error message,
    otherwise equal to its address, and in HGT and LEN
    its dimensions are recorded;            
 ?PEK(x) :                              
     reads a word (2 bytes) from an address
    x.                                   
                               
       A few words about        
    programming on LB     
                               
 When writing a program in LB, you need
take into account that all LB teams use
the same variables, so it is necessary
dimo use sets more widely (variable
SET).  An example of using sets when
writing the program is given below:       
                               
 10 .SET=0: .COL=0: .ROW=18: .SPN=6    
 20 .SET=1: .COL=26: .ROW=18: .SPN=8   
 30 .SET=2: .COL=0: .ROW=8              
 40 .SET=0: .PTXR: .SET=1: .PTXR       
  50 .SET=2: LET KEY=?KBF                
  60 IF KEY<>0 THEN STOP                 
  70 .SET=0: .PTXR: LET X=?COL           
  80 IF X=26 THEN LET X=-1               
  90 .COL=X+1                            
 100 .SET=1: .PTXR: LET X=?COL           
 110 IF X=0 THEN LET X=27                
 120 .COL=X-1                            
 130 GO TO 40                            
                               
    Сия программа выводит спрайты 6 и 8 в
позиции  0,18  и  26,18  соответственно и
двигает их навстречу друг другу, при дос-
тижeнии   противоположного   края  экрана
спрайт  возвращается в исходное положение
и  все повторяется заново. При нажатии на
 программа останавливается.       
                               
         Компилятор ЛБ         
                               
    Вdifference from other LB extensions
allows you to compile your programs,
which allows you to increase the speed of their
filling and free up more space in the pa-
wrinkle, because procedures used in the
compiled program takes up only
5K. top memory.                      
    For compilation it is necessary in pure
BASIC make CLEAR 59799, then load
create a compiler (COMPCODE), your own program
mu and start the compiler from address 59800.
During the compilation process, the text of your program
framework will be replaced by object code, which
which can be recorded as normal
basic  To execute the compiled
The program needs to be written as a bootloader. Example
The bootloader for TR-DOS is given below:     
                               
 10 CLEAR SPR-1                        
 20 RANDOMIZE USR 15619: REM:          
 LOAD "RTCODE" CODE            
 30 RANDOMIZE USR 15619: REM:          
 LOAD "SPRITES" CODE SPR       
 40 LET T=INT(SPR/256):                
POKE62464,SPR-256*T:          
 POKE 62465,T                  
 50 POKE 62466,255: POKE 62467,220      
 60 RANDOMIZE USR 15619: REM:          
 LOAD "PROG"                   
                               
    Here SPRITES : sprite file name;  
SPR : sprite loading address;           
PROG : name of the object code.              
    If the program did not use
sprites, then lines 30 and 40 can be omitted
tit, then the CLEAR address will be 59799.   
                               
          Literature.          
                               
  1. "Reference to system programs
for the ZX-Spectrum computer"; ed. "SILEX"
St. Petersburg, 1992, 2SSctp.                    
  2. "Handbook for system programs.ZX-Spectrum."; ed. "SOLON" Moscow, 1991,
261 p.                                  
                               
_______________________________

Share your thoughts about the article