Programmers - Merging images, inverting the screen, shifting left by one pixel, shifting right by one pixel.

Star #01


+------------------------------+
|  ----- FOR PROGRAMMERS ----- |
+------------------------------+
                                
Today in the procedure section:    
1. "Merging pictures"            
2."Invert the screen"       
Z."Shift left one pixel"  
4."Shift right one pixel" 
                                
1. "Merging pictures"          
This procedure combines the pictures
ku stored in RAM with the current
screen. Attributes do not change.
                                
    LD HL,16З84                
    LD DE,ADDR                 
    LD VS,6144                 
LOP LD А,(DE)                  
    OR(HL)                    
                                
 LD (HL), A                  
    INC HL                      
    INC HL                      
    DEC Sun                      
    LD A,B                     
    OR C                       
    JR NZ,LOP                  
    RET                         
                                
How it works:              
A couple of HL registers are loaded
starting address of the screen, in pairs
registers DE loaded address  
pictures stored in RAM, registered
string pair BC serves as a counter
A byte is loaded into accumulator A
with an address in DE and is executed lo-
logical 'OR' (OR) of this sign
bytescreen. Result
fits into the screen area.    
HL and DE move on the following
th position, the counter decreases
If the counter is not zero, then
the procedure goes back for
repeating the process with the next one
byte.                         
                                
2. "Invert the screen"     
This procedure inverts everything into
screen: if the pixel is turned on, it
reset, if disabled then
is installed.                
                                
    LD HL,16З84                
    LD VS,6144                 
    LD D,255                   
LOP LD A,D                     
    SUB (HL)                    
    LD (HL),A                  
                                
    INC HL                      
    DEC Sun                      
 LD A, B                     
    OR C                       
    JR NZ,LOP                  
    RET                         
                                
How it works:              
A couple of HL registers are loaded
the address of the beginning of the screen, and in BC for-
its length is loaded. To D-register
the number 255 is written down. Every
time when the procedure returns
to LOP, the battery is loaded
value from the D-register. Meaning
byte stored at the address indicated
entered in HL, is deducted from the accu-
simulator, and the result is loaded
into the same byte. This way
zominversion is done.    
HL increases, indicating
next byte, and counter sun
decreases by one if it
is not equal to zero, then the procedure is possible
rotates to LOP.                
                                
Z."Shift left one pixel"  
This procedure shifts everything
screen content per pixel
to the left. Attributes do not change.
                                
     LD HL,22527              
     LD C,192                 
LOP1 LD В,З2                  
     OR A                     
LOP2 RL (HL)                  
     DEC HL                    
     DJNZ LOP2                  
     DEC C                     
                                
     JR NZ,LOP1               
     RET                        
                                
How it works:              
The HL register pair is loaded
the address of the last byte of the screen, and
the colli-
quality of lines on the screen. To register
' In ' loads quantity
bytes in one line. Transfer flag
nose is set to zero.    
The byte addressed to HL is shifted
one bit to the left, carry bit
copied to the rightmost bit,
and the leftmost bit is copied
to the carry flag. Register pair
HL is reduced to indicate
next byte. Counter 'B'
decreases. If it is not 0,
then the transition takes placeon
LOP2, otherwise the number of
quality of processed lines, and,
if it is not 0, the subroutine
returns to LOP1 procedure.  
                                
4."Shift right by one pixel" 
This procedure shifts everything
screen content per pixel
to the right. Attributes do not change.
                                
      LD HL,16З84             
      LD C,192                
LOP1 LD В,З2                 
      OR A                    
LOP2 RR (HL)                 
      INC HL                   
      DJNZ LOP2                 
      DEC C                    
      JR NZ,LOP1              
                                
      RET                       
                                
How it works:              
A couple of HL registers are loaded
the address of the beginning of the screen, and in the register
'C' is the number of lines on the screen.
The colli-
Number of bytes on one line.
The carry flag is set to
0.Byte at address HL is shifted
one bit to the right, carry bit
copied to the leftmost bit,
and the rightmost bit is copied
to the carry flag. A pair of registers
HL increases, indicating
next byte and counter 'B'
decreases. If it is not equal to 0,
then the program goes to LOP2,
otherwise the quantity decreases
lines being processed, and if not
equals 0, subroutinegoes over
to LOP1.                        
                                
Small pineapple -              
In the next release you can
find out:                        
How to install Magic protection on
Scorpion computer.           
How to intercept the Magic button in
the same computer.              
__________________________________________

Share your thoughts about the article