Programming - Fast and compact print driver 42 characters per line.

┌---------------------------------------┐
│░░░░░░░░░░ Programming ░░░░░░░░░░░░│
└---------------------------------------┘
                                          
 (C) PAWEL/RS
                                          
 To the programmer's library        
                                          
 Fast and compact driver       
     print 42 (..) characters per line     
                                          
                                          
   For many months I was accompanied by
the driver was improved and tested
water 42 characters per line. In front of you is
flawless product, and I hope from now on
and I won't have to look at the medical
Linearly printed text. The principle of using
bath in this driver if you look into it
very simple, you can even say a few
a banal phrase: - “Like everything ingenious.”
Of course I do not claim copyright,
it was used in one way or another
before, but I think I managed to achieve it
best results with small size
re programs.  Well of course if you need
even greater speed, then you can spin-
draw conclusionsymbol in every possible position
positions, according to my calculations it will take no more
more than 500 bytes. You can also use
ZX-ASM's method - output 4 at once
symbol. To quickly calculate the SIM address
ox in the font, a special one is used here
format different from ZX-ASM's. Not-
large font conversion procedure
is given.  The font should be positioned according to
even address, that is, the address with the lowest
byte equal to zero, just like the sign
masks. I hope you understand that the driver
must be compiled into a fast pas-
crush.  The program is typed in assembler
ZX-ASMZ. Load the text, remove all non-
necessary, perform the "Import" function.       
                                          
;42 Symbols driver by Pawel/RS/NHG        
Print text, HL -Address (code 0 - end)   
WRITE LD A,(HL)                    
        INC HL                        
        AND A                         
        RET Z                         
        CP 32                        
        JR C,WRIT2                   
WRIT1 PUSH HL                        
        CALL PRSYM                     
 POP HL                        
        JR WRITE                     
                                          
Processing control codes:              
;(Only two control codes are given here, but  
nothing will stop you from adding yours)      
WRIT2 CP 13                        
        JR Z,PR13                    
        CP 22                        
        JR Z,PR22                    
        LD A,63                      
        JR WRIT1                     
PR13 PUSH HL                        
        LD HL,(PSA)                  
        LD A,L                       
        AND 224                       
        ADD A,#20                     
        LD L,A                       
 JR NZ,PR13_1                 
        LD A,H                       
        ADD A,8                       
        LD H,A                       
        CP #58                       
        JR C,PR13_1                  
        LD H,#40                     
PR13_1 LD (PSA),HL                  
        XOR A                         
        LD(LBT),A                   
        POP HL                        
        JR WRITE                     
PR22 LD A,(HL)                    
        INC HL                        
        PUSH DE                        
        PUSH HL                        
        CALL 3742POP DE                        
LD A,(DE)                    
        INC DE                        
        ADD A,L                       
        LD L,A                       
        LD (PSA),HL                  
        XOR A                         
        LD(LBT),A                   
        POP HL                        
        EX DE,HL                     
        JP WRITE                     
                                          
The driver itself, in the A-character code      
PRSYM LD HL,0                      
PSA EQU $-2 ;current screen address.  
        LD E,A                       
LS LD D,FONT/256                
LBT EQU $+1:LD A,0 ;number of bits shifted      
        AND A                         
 JP Z,LSb                     
        LD C,A                       
        N.E.G.                               
        SUB JPSSL-SSL+2               
        LD(JPSSL+1),A               
        SLA C                         
        LD B,TABLS/256               
        LD A,(BC)                    
        LD (LS1+1),A                 
        INC C                         
        LD A,(BC)                    
        LD (LS2+1),ALD      B,9                       
        JP      LSS                       
        RRCA                              
        RRCA                              
        RRCA                              
        RRCA                              
        RRCA                              
        RRCA                              
        RRCA                              
        RRCA                              
SSL     LD      C,A                       
LS1     AND     0                         
        OR      (HL)                      
        LD      (HL),A                    
        INC     L                         
        LD      A,C                       
LS2     AND     0                         
        OR      (HL)                      
        LD      (HL),A                    
        DEC     L                         
        INC     H                         
LSS     LD      A,(DE)                    
        INC     D                         
JPSSL   DJNZ    SSL                       
LSбA  ;сюда можно вставить вывод атриб.   
        LD      A,(LBT)                   
        ADD     A,6                       
        LD      (LBT),A                   
        CP      8                         
        RET     C                         
        AND     7                         
        LD(LBT),A                   
        LD HL,(PSA)                  
        INC L                         
        JP NZ,PRSЗ                   
        LD A,H                       
        ADD A,8                       
        LD H,A                       
PRSЗ LD (PSA),HL                  
        RET                               
                                          
Untwisted character printing without shift,   
you can completely remove it or use a loop 
LSb LD A,(DE)                    
        INC D                         
        OR(HL)                      
        LD(HL),A                    
        INC H                         
        LD A,(DE)                    
        INC D                         
        OR(HL)                      
        LD(HL),A                    
        INC H                         
        LD A,(DE)                    
        INC D                         
        OR(HL)                      
        LD(HL),A                    
        INC H                         
        LD A,(DE)                    
        INC D                         
OR (HL)                      
        LD(HL),A                    
        INC HLD      A,(DE)                    
        INC     D                         
        OR      (HL)                      
        LD      (HL),A                    
        INC     H                         
        LD      A,(DE)                    
        INC     D                         
        OR      (HL)                      
        LD      (HL),A                    
        INC     H                         
        LD      A,(DE)                    
        INC     D                         
        OR      (HL)                      
        LD      (HL),A                    
        INC     H                         
        LD      A,(DE)                    
        INC     D                         
        OR      (HL)                      
        LD      (HL),A                    
        INC     H                         
        JP      LSбA                      
                                          
По ровному адресу:                        
FONT    INSERT  "Font10M" ;Ckohb.фонт     
                                          
Таблица, располагается по адресу с        
младшим байтом равным 0 (для быстрого     
расчета, но можно и по неровному адресу,  
предварительно подкорректировав расчет).  
TABLS   DB      %11111100,%00000000       
        DB%01111110,%00000000       
        DB %00111111,%00000000       
        DB %00011111,%10000000       
 DB %00001111,%11000000       
        DB %00000111,%11100000       
        DB %00000011,%11110000       
        DB %00000001,%11111000       
                                          
If you need to print characters with    
attributes, then insert the following pro-    
tsedurku:                                  
                                          
        LD HL,(PSA)                  
        LD A,H                       
        AND #18                       
        RRCA                              
        RRCA                              
        RRCA                              
        ADD A,#58                     
        LD H,A                       
ATR EQU $+1:LD A,7 ;current attributes      
 LD (HL),A                    
                                          
 By the way, the standard code for changing the attri-
There are 16 bottles, the second byte contains the attribute. Exactly
this format will support VIEW'er no-
howl version of REAL COMMANDER.              
                                          
 To print with the previous image cleared,
I need several marriagesмодифицированная
процедура:                                
                                          
LS      LD      E,A                       
        LD      D,FONT/256                
PSA     EQU     $+1                       
        LD      HL,0                      
LBT EQU $+1:LD  A,0                       
        AND     A                         
        JP      Z,LSб                     
        LD      C,A                       
        NEG                               
        SUB     JPSSL-SSL+2               
        LD      (JPSSL+1),A               
        SLA     C                         
        LD      B,TABLS/256               
        LD      A,(BC)                    
        LD      (LS1+1),A                 
        CPL                               
        LD      (LSЗ+1),A                 
        INC     C                         
        LD      A,(BC)                    
        LD      (LS2+1),A                 
        CPL                               
        LD      (LSЧ+1),A                 
        LD      B,9                       
        JP      LSS                       
        RRCA                              
        RRCA                              
        RRCA                              
        RRCA                              
        RRCARRCA                              
        RRCA                              
        RRCA                              
SSL     LD      C,A                       
        LD      A,(HL)                    
LSЗ     AND     0                         
        LD      (HL),A                    
        LD      A,C                       
LS1     AND     0                         
        OR      (HL)                      
        LD      (HL),A                    
        INC     L                         
        LD      A,(HL)                    
LSЧ     AND     0                         
        LD      (HL),A                    
        LD      A,C                       
LS2     AND     0                         
        OR      (HL)                      
        LD      (HL),A                    
        DEC     L                         
        INC     H                         
LSS     LD      A,(DE)                    
        INC     D                         
JPSSL   DJNZ    SSL                       
LSбA    LD      A,(LBT)                   
        ADD     A,6                       
        LD      (LBT),A                   
        CP      8                         
        RET     C                         
        AND     7                         
        LD      (LBT),A                   
        LDHL,(PSA)                  
        INC     L                         
        JP      NZ,PRSЗ                   
        LD      A,H                       
        ADD     A,8                       
        LD      H,A                       
PRSЗ    LD      (PSA),HL                  
        RET                               
                                          
Здесь заключено в цикл                    
LSб     LD      B,8                       
LSбB    LD      A,(HL)                    
        AND     %00000011                 
        LD      (HL),A                    
        LD      A,(DE)                    
        INC     D                         
        OR      (HL)                      
        LD      (HL),A                    
        INC     H                         
        DJNZ    LSбB                      
        JP      LSбA                      
                                          
КОНВЕРТОР ФОНТОВ ZX-ASM'а:                
        ORG     #6000                     
        LD      HL,FONT1                  
        LD      DE,FONT2                  
        LD      C,0                       
N1      LD      B,8                       
        PUSH    DE                        
N2      LD      A,(HL)                    
        LD      (DE),A                    
        INC     HLINC D                         
        DJNZ N2                        
        POP DE                        
        INC E                         
        DEC C                         
JP NZ,N1                     
        LD HL,FONT2                  
        LD DE,#4000                  
        LD BC,2048                   
        LDIR                              
        JP 7997                      
        ORG #8000                     
FONT1 INSERT "Font8"                   
FONT2 EQU $                         
                                          
 The program will convert and display the font,
to record it, find out the value of the label
FONT2 and go to TR-DOS and write it down (length
2048 bytes).                               
                                          
P.S.: This driver was successfully used
called in my latest program REAL COM-
MANDER.  If anyone else manages to get it
speed up, then write to me or the editor
newspapers LPRINT.                            

Share your thoughts about the article