; FASTPRN2.ASM - Fast character printout ; J.G.Harston, 15 March 1985 ; Print characters directly to screen bypassing ROM calls ; ======================================================= ; A very simple and fast character printout routine. ; Characters are written directly to screen memory without any ROM calls. ; It uses the Spectrum ROM's system variables for the colours, print ; location and character set location, but these can be replaced. ; ; This version: ; prints character at DFCC with colour in ATTRP ; ; Total size: 49 bytes ; Speed: 524T per character ; +10T if print position goes over a screen third boundary ; ; WARNINGS: ; Control codes ignored ; There is no check for wrapping past bottom of screen CHARS EQU 23606 ; Address of character set DFCC EQU 23684 ; Address in display of current position ATTRP EQU 23693 ; Current colours ORG &5B00 ; Arbitary start LOAD ; Print out a character ; --------------------- ; On entry, A=character ; On exit, AF/BC/DE/HL corrupted ; PRCHAR LD DE,(CHARS) ; Get start of font PROUT LD H,0 LD L,A ADD HL,HL ADD HL,HL ADD HL,HL ; HL=char*8 ADD HL,DE ; HL=>font for character ; Print matrix ; ------------ ; HL=>8x8 character matrix ; PRMTX LD DE,(DFCC) ; DE=current print position PUSH DE ; Save print position for later LD B,8 ; 8 pixel lines PRMTXLP LD A,(HL) ; Get pixel line LD (DE),A ; Store in screen INC HL ; Step to next character line INC D ; Step to next pixel line DJNZ PRMTXLP ; Loop for 8 pixel lines POP HL ; Get print position back ; Set attribute ; ------------- PUSH HL ; Save print position LD A,H ; Convert to attribute address RRCA RRCA RRCA OR &58 LD H,A LD A,(ATTRP) ; Get current attributes LD (HL),A ; Set screen attribute POP HL ; Get print position back ; Update print position ; ---------------------- INC L ; Increment position JR NZ,PRSAVEP ; Not wrapped past 1/3 screen LD A,H ADD A,8 LD H,A ; Step to next 1/3 of screen PRSAVEP LD (DFCC),HL ; Save print position RET ; Attach channel 'P' to new printout code ; --------------------------------------- ENTRY LD HL,(23631) ; CHANS LD DE,15 ADD HL,DE ; HL=>'P' output address LD DE,PRCHAR LD (HL),E INC HL LD (HL),D RET DEFW LOAD,ENTRY