See all articles from SINCUS v5 n3
;Print pixel characters. Enter with DE pointing to pixel
; pattern, HL=display file address, BC=line/column
; Identical to Spectrum at 037F
06B4 79 L06B4 LD A,C
06B5 3D DEC A ;Move over one column
06B6 3E21 LD A,#21
06B8 200E JR NZ,L06C8 ;If there's still room on this line
06BA 05 DEC B ;Move down a line
06BB 4F LD C,A
06BC FDCB014E BIT 1,(IY+1) ;FLAGS - Printer/Screen
06C0 2806 JR Z,L06C8 ;If screen
06C2 D5 PUSH DE
06C3 CD230A CALL #0A23 ;Dump printer buffer to printer
06C6 D1 POP DE
06C7 79 LD A,C
06C8 B9 L06C8 CP C ;Check wether it's a new line
06C9 D5 PUSH DE
06CA CC9007 CALL Z,#0790 ;Check on scrolling, if it is
06CD D1 POP DE
06CE C5 PUSH BC ;Make print masks for INVERSE & OVER
06CF E5 PUSH HL ;B will be 00 for OVER 0
06D0 3A915C LD A,(P_FLAG) ; FF for OVER 1
06D3 06FF LD B,#FF
06D5 1F RRA
06D6 3801 JR C,L06D9
06D8 04 INC B
06D9 1F L06D9 RRA ;C will be 00 for INVERSE 0
06DA 1F RRA ; FF for INVERSE 1
06DB 9F SBC A,A
06DC 4F LD C,A
06DD 3E08 LD A,#08
06DF A7 AND A
06E0 FDCB014E BIT 1,(IY+1) ;FLAGS - Printer/Screen
06E4 2805 JR Z,L06EB ;If screen
06E6 FDCB30CE SET 1,(IY+48) ;FLAGS2 - There's info in print buffer
06EA 37 SCF
06EB EB L06EB EX DE,HL
;Finally!!! We actually PRINT a character!!!
; Identical to Spectrum at 0BB7
06EC 08 L06EC EX AF,AF' ;Save the CY (=1 for printer)
06ED 1A LD A,(DE) ;Present byte (if display file)
06EE A0 AND B
06EF AE XOR (HL) ;OVER requirements are met
06F0 A9 XOR C ;INVERSE requirements are met
06F1 12 LD (DE),A ;Ship out the result
06F2 08 EX AF,AF' ;CY still =1 for printer
06F3 3813 JR C,L0708 ;If printer
06F5 14 INC D ;Here for screen. point to next
06F6 23 L06F6 INC HL ; pixel line in display file...
06F7 3D DEC A
06F8 20F2 JR NZ,L06EC ;...and loop if character not done
06FA EB EX DE,HL ;Now fix up the attribute byte
06FB 25 DEC H
06FC FDCB014E BIT 1,(IY+1) ;FLAGS - Printer/Screen
0700 CC1007 CALL Z,#0710 ;Print the attribute byte
0703 E1 POP HL
0704 C1 POP BC
0705 0D DEC C
0706 23 INC HL
0707 C9 RET
0708 08 L0708 EX AF,AF' ;Here for printer. Save CY again
0709 3E20 LD A,#20 ;Character bytes are separated by #20
070B 83 ADD A,E
070C 5F LD E,A
070D 08 EX AF,AF'
070E 18E6 JR L06F6
;Write the attribute byte
; Identical to Spectrum at 0BDB
0710 7C LD A,H
0711 0F RRCA
0712 0F RRCA
0713 0F RRCA
0714 E603 AND #03
0716 F658 OR #58
0718 67 LD H,A
0719 ED5B8F5C LD DE,(ATTR_T)
071D 7E LD A,(HL)
071E AB XOR E
071F A2 AND D
0720 AB XOR E
0721 FDCB5776 BIT 6,(IY+87) ;P_FLAG - Paper=Compliment of INK
0725 2808 JR Z,L072F ;If we're not using PAPER 9
0727 E6C7 AND #C7
0729 CB57 BIT 2,A
072B 2002 JR NZ,L072F
072D EE38 XOR #38
072F FDCB5766 L072F BIT 4,(IY+87) ;P_FLAG - INK=Compliment of PAPER
0733 2808 JR Z,L073D ;If not using INK 9
0735 E6F8 AND #F8
0737 CB6F BIT 5,A
0739 2002 JR NZ,L073D
073B EE07 XOR #07
073D 77 L073D LD (HL),A
073E C9 RET
;Print messages & Tokens. Enter with A register = message #
; in table, and DE = address of the table.
; Similar to Spectrum at 0C0A
;Here to print a message from a message table
073F E5 PUSH HL
0740 2600 LD H,#00
0742 E3 EX (SP),HL
0743 180A JR L074F
;Here to expand a token from the Token Table
0745 119800 LD DE,#0098 ;Address of Token table
;The following 3 instructions "shift" the new tokens into the
; proper token sequence. Necessary because they don't follow
; the standard Spectrum tokens in their sequence.
0748 FE5B CP #5B
074A 3802 JR C,L074E
074C D61F SUB #1F
074E F5 L074E PUSH AF
074F CD7C07 L074F CALL #077C ;Find the right table entry
0752 3809 JR C,L075D ;If no leading space is needed
0754 3E20 LD A,#20 ;A space
0756 FDCB0146 BIT 0,(IY+1) ;FLAGS - Suppress space before tokens
075A CC7607 CALL Z,#0776 ;Print leading space if FLAGS requires
075D 1A L075D LD A,(DE) ;Get the character
075E E67F AND #7F ;Wipe an inverted MSB, if present
0760 CD7607 CALL #0776 ;Print the character
0763 1A LD A,(DE) ;Get same character
0764 13 INC DE ;Point to next
0765 87 ADD A,A ;We're done if MSB is set
0766 30F5 JR NC,L075D ;Loop if not
0768 D1 POP DE ;Contortions to decide wether to
0769 FE48 CP #48 ; print a trailing space
076B 2803 JR Z,L0770
076D FE82 CP #82
076F D8 RET C
0770 7A L0770 LD A,D
0771 FE03 CP #03
0773 D8 RET C
0774 3E20 LD A,#20
;Allow for recursive printing by preventing wiping of registers
;(The character printer effectively CALLs itself when expanding
; a Token character)
; Identical to Spectrum at 0C3B
0776 D5 PUSR DE
0777 D9 EXX ;Save necessary registers
0778 D7 RST #10 ;PRINT the A register
0779 D9 EXX
077A D1 POP DE ;Registers are restored
077B C9 RET
;Character string table search. Enter with DE=address of the
; table, A=entry number. Exit with DE=address of entry. Each
; entry has MSB=1 for last character.
; Identical to Spectrum at 0C41
077C F5 PUSH AF
077D EB EX DE,HL
077E 3C INC A
077F CB7E L077F BIT 7,(HL)
0781 23 INC HL
0782 28FB JR Z,L077F
0784 3D DEC A
0785 20F8 JR NZ,L077F
0787 EB EX DE,HL
0788 F1 POP AF
0789 FE20 CP #20
078B D8 RET C
078C 1A LD A,(DE)
078D D641 SUB #41
078F C9 RET
;Check wether the display needs to be scrolled
;
0790 FDCB014E BIT 1,(IY+1) ;FLAGS - Printer/Screen
0794 C0 RET NZ ;If printer, we never scroll
0795 111409 LD DE,#0914 ;Forces a RETurn through the code to
0798 D5 PUSH DE ; compute a printer/display address
0799 78 LD A,B
079A FDCB0246 BIT 0,(IY+2) ;TV_FLAG - Printing to lower screen
079E C23D08 JP NZ,#083D ;If not
07A1 FDBE31 CP (IY+49) ;DF_SZ
07A4 381B JR C,L07C1 ;Error if lower screen too small
07A6 C0 RET NZ
07A7 FDCB0266 BIT 4,(IY+2) ;TV_FLAG - Automatic listing
07AB 2816 JR Z,L07C3 ;If not
07AD FD5E2D LD E,(IY+45) ;BREG
07B0 1D DEC E ;Update line counter
07B1 285A JR Z,L080D ;If time to scroll the listing
07B3 3E00 LD A,#00 ;For channel "k" - lower screen
07B5 CD3012 CALL #1230 ;Make it the current channel
07B8 ED7B3F5C LD SP,(LIST_SP)
07BC FDCB02A6 RES 4,(IY+2) ;TV_FLAG - Auto Listing is done
07C0 C9 RET
;Error 5 - Out of screen
07C1 CF L07C1 RST 8
07C2 04 DEFB #04
;Check if "scroll?" prompt is needed
; Identical to Spectrum at 0C88
07C3 FD3552 L07C3 DEC (IY+82) ;SCR_CT scroll count is decreased
07C6 2045 JR NZ,L080D ;If it's not time to scroll
07C8 3E18 LD A,#18
07CA 90 SUB B
07CB 328C5C LD (SCR_CT),A
07CE 2A8F5C LD HL,(ATTR_T)
07D1 E5 PUSH HL
07D2 3A915C LD A,(P_FLAG)
07D5 F5 PUSH AF
07D6 3EFD LD A,#FD ;"Internal" pointer to channel "k"
07D8 CD3012 CALL #1230 ;Make it the current channel
07DB AF XOR A
07DC 113308 LD DE,#0833
07DF CD3F07 CALL #073F ;Prints "Scroll?"
07E2 FDCB02EE SET 5,(IY+2) ;TV_FLAG - Clear lower screen
07E6 213B5C LD HL,FLAGS
07E9 CBDE SET 3,(HL) ;L mode
07EB CBAE RES 5,(HL) ;Reset keypress indicator
07ED D9 EXX
07EE CDCF11 CALL #11CF ;Get a keypress
07F1 D9 EXX
07F2 FE20 CP #20 ;ASCII space
07F4 2845 JR Z,L083B ;Done, if spacebar was pressed
;Works also on BREAK
07F6 FEE2 CP #E2 ;STOP token
07F8 2841 JR Z,L083B ;Done, if STOP was pressed
07FA F620 OR #20 ;Convert to lowercase
07FC FE6E CP #6E ;ASCII "n"
07FE 283B JR Z,L083B ;Done, if N or n was pressed
0800 3EFE LD A,#FE ;Internal pointer to channel "s"
0802 CD3012 CALL #1230 ;Upper screen is current channel
0805 F1 POP AF
0806 32915C LD (P_FLAG),A
0809 E1 POP HL
080A 228F5C LD (ATTR_T),HL
080D CD3909 L080D CALL #0939 ;Scroll the screen
0810 FD4631 LD B,(IY+49) ;DF_SZ
0813 04 INC B
0814 0E21 LD C,#21 ;leftmost column
0816 C5 PUSH BC
0817 CDD609 CALL #09D6 ;Get disp file address for first char
081A 7C LD A,H
081B 0F RRCA
081C 0F RRCA
081D 0F RRCA
081E E603 AND #03
0820 F658 OR #58
0822 67 LD H,A ;HL=addr of attribute byte
0823 11E05A LD DE,#5AE0 ;Handle scrolling attributes
0826 1A LD A,(DE) ; for bottom line
0827 4E LD C,(HL)
0828 0620 LD B,#20
082A EB EX DE,HL
082B 12 L082B LD (DE),A
082C 71 LD (HL),C
082D 13 INC DE
082E 23 INC HL
082F 10FA DJNZ L082B
0831 C1 POP BC
0832 C9 RET
0833 80736372 DEFB #80,"scroll",?+#80
0837 6F6C6CBF
;Error D ; BREAK - CONT Repeats
083B CF L083B RST 8
083C 0C DEFB #0C