8x4 color printing procedure

ZXNet echo conference «code.zx»

From Dmitry Grigoryev To All 26 March 1999

Hello All! Here, maybe someone will find it useful... I dug it up in the source code. Interesting (in my opinion) look ;) algorithm for tracking attribute addresses, I don’t know if anyone has used it similar... You can also optimize it :) ══════════╡ImportBegin DISNAME0.TXT╞════════════════════════════════ prpage LD (adrtxt+1),HL CALL clear ; call clear screen LD D,#58 EXX LD DE,#4000 adrtxt LD HL,0 prpage1 PUSH DE color LD C,0 ; here is the current color attribute INC HL CALL prline ; call to print a line POP DE LD A,E ADD A,#20 LD E,A JR NC,prpage1 EXX INC D EXX LD A,D ADD A,#08 LD D,A CP #58 ; if the screen is not displayed completely, here JR NZ,prpage1 ; I'll have to use a more rotten limiter RET prline XOR A EX AF,AF' ; set the phase flag (needed for painting procedures) LD A,(HL) ; take the symbol code INC HL CP #21 ; if the code is less than 21, then proceed to processing JP C,esc ; control codes PUSH HL PUSH DE LD L,A ; the first phase of the font at #9000 in screen formatLD H,#90 ; and you say "calculating the font address" ;)) ; LD B,#F0 ; I will specifically leave the masking operations EX DE,HL BEGIN 7 ; This is a Masm operand, you’ll understand, I think LD A,(DE) ; AND B LD(HL),A INC H INC D END LD A,(DE) ; AND B LD(HL),A EXX ; set the color... LD A,D EXX LD H,A LD(HL),C ; that's all! and you "rra, rra, rra, rra, rra..." ;) POP DE POP HL prline2 EX AF,AF' ; phase flag (and here A cannot equal 0) LD A,(HL) ; take the symbol code INC HL CP #21 ; if the code is less than 21, then proceed to processing JP C,esc ; control codes PUSH HL PUSH DE LD L,A LD H,#98 ; address of the second phase of the font at #9800 ; LD B,#0F BEGIN 7 LD A,(DE) ; AND B OR(HL) LD(HL),A INC H INC D END LD A,(DE) ; AND B OR(HL) LD(HL),A EXX LD A,D EXX LD H,A LD(HL),C POP DE POP HL INC EJP prline ; As you can see, by removing masking, we saved 39 clock cycles per symbol! ; which compensated for the cost of painting with a margin. esc CP #20 JP Z,space CP#0D RET Z CP#10 JR Z, paper CP #11 JR Z,ink CP #09 JP Z,tab LD A,#02 OUT(#FE),A JR$; ;~( paper LD A,(color+1) AND #B8 OR(HL) INC HL LD (color+1),A EX AF,AF' OR A JP Z,prline JP prline2 ink LD A,(HL) INC HL ADD A,A ADD A,A ADD A,A LD B,A LD A,(color+1) AND #C7 OR B LD (color+1),A EX AF,AF' OR A JP Z,prline JP prline2 space EX AF,AF' ; did this work? Just drunk on beer OR A ; stuffed ;) LD A,1 JP Z, prline2 INC E JP prline tab LD A,E AND #FC ADD A,#04 LD E,A JP prline ══════════╡ImportEnd DISNAME0.TXT╞════════════════════════════════ Best regards, Dmitry (OLDMAN). 500:095/100.1@ZXNet oldman@i-connect.ru