'ANSI Print for PowerBASIC 'CopyRight 1991 by Dave Navarro, Jr. - All Rights Reserved 'For questions, leave me a message on The Bard's Lair (718) 381-3651 'AnsiPrint() will display a string through DOS's PRINCHAR function 'which handles ANSI codes (if ANSI.SYS or equivalant is installed) 'It also tests for the cursor position and keeps the specified number of 'lines on the bottom of the screen from being overwritten. $CPU 8086 $ERROR ALL OFF $LIB ALL OFF $COMPILE UNIT SUB AnsiPrint(Text$,Lins%) PUBLIC REPLACE CHR$(27)+"[2J" WITH CHR$(12) IN Text$ FOR I%=1 TO LEN(Text$) Tmp$=MID$(Text$,I%,1) IF Tmp$=CHR$(12) THEN CALL ScrollUp(1,80,1,Lins%,0,CurColor%) LOCATE 1,1 GOTO ControlChar END IF CALL DPrintChar(Tmp$) IF DCSRLIN%>Lins% THEN LOCATE Lins%,DPOS% CALL ScrollUp(1,80,1,Lins%,1,CurColor%) END IF ControlChar: NEXT I% LOCATE DCSRLIN%,DPOS%,1 END SUB FUNCTION CurColor% CurColor%=SCREEN(DCSRLIN%,DPOS%,1) END FUNCTION 'ScrollUp - Scroll a specified part of the screen up SUB ScrollUp (LC%, RC%, TR%, BR%, Rows%, Atr%) REG 1, Rows%+256*6 REG 2, Atr%*256 REG 3, (LC%-1)+(256*(TR%-1)) REG 4, (RC%-1)+(256*(BR%-1)) CALL INTERRUPT &h10 END SUB SUB DPrintChar(Char$) REG 1, &h0200 REG 4, ASC(Char$) CALL INTERRUPT &h21 END SUB FUNCTION DCSRLIN% PUBLIC REG 1,&H0300 REG 2,&H0000 CALL INTERRUPT &H10 DCSRLIN%=(REG(4) AND &HFF00)/256+1 END FUNCTION FUNCTION DPOS% PUBLIC REG 1,&H0300 REG 2,&H0000 CALL INTERRUPT &H10 DPOS%=(REG(4) AND &H00FF)+1 END FUNCTION