PAGE 66,132 ;Setup page as 66 lines, 132 columns TITLE SCRN - Subroutines for BASIC to control text windowing COMMENT @ DESCRIPTION Copyright (c) 1983 by Bradley H. Hanson. Permission is granted for private, non-profit use. This program may NOT be used for trade or sale. Comments or corrections should be directed to: Brad Hanson, 3685 Eastwood Court, Bettendorf, IA 52722 319/332-4984, CompuServe 72115,22 This contains a series of screen service routines for access from a BASIC program. They can be loaded into a string array or unused file buffer in the program and then directly CALLed after defining entry variables to the routines. The following is a summary of the routines defined. An expanded description can be found in the file SCRN.DOC. First the routine must be loaded into memory and a variable defined to point to the first byte of the code. In this example the variable Z will point to the first byte and then the following entry variables are then defined to enter the actual routines: SCRN=Z+2: SCU=Z+4: SCD=Z+6: CEOL=Z+8: CEOS=Z+10 ATRB=Z+12: DEFW=Z+14 The actual variables used in the program can named different than those listed above but the relative offset into the code must remain the same. Routine and location definitions using the variables defined above: SCRN - POKE location to define the current window POKE SCRN,value ' value is a number from 1 to 6 initial value=1 SCU - Scroll the window up function I%=value: CALL SCU(I%) ' Scroll lines up. Clear window if value=0. Argument must be an integer. SCD - Scroll the window down function I%=value: CALL SCD(I%) ' Scroll lines down. Clear window if value=0. Argument must be an integer. CEOL - Clear from cursor to end of line with spaces CALL CEOL ' No arguments allowed. Cursor must be positioned within the current window. CEOS - Clear from cursor to end of window with spaces CALL CEOS ' No arguments allowed. Cursor must be positioned within the current window. ATRB - Change the default attribute in the window I%=value: CALL ATRB(I%) ' Change space fill attribute to DEFW - Define a window. Up to six windows can be defined. The current window will be changed to the window number defined. Six arguments are required as follows: A1% - Screen number to define. Value from 1 to 6. A2% - Upper left corner row position (1 to 24). A3% - Upper left corner column position (1 to 80). A4% - Lower right corner row position (1 to 24, >= A2). A5% - Lower right corner column position (1 to 80, >= A4). A6% - Attribute byte for space fill characters. Call: CALL DEFW(A1%,A2%,A3%,A4%,A5%,A6%) When initially loaded window 1 is defined with the following values: A1=1: A2=1: A3=1: A4=24: A5=80: A6=7 @ ; ; SUBTTL Code CSEG SEGMENT PARA PUBLIC 'CODE' START PROC FAR ;Routine ASSUME CS:CSEG,DS:CSEG,SS:NOTHING,ES:NOTHING ; ; ; The following define the bytes for each screen control entry at the ; end of the code of this bank. The order of these entries correspond ; to that on the call to DEFW routine to define a window. ; ULC EQU 0 ; Word entry containing next two bytes LCOL EQU 0 ; Left column for window (0 - 79) TROW EQU 1 ; Top row for window (0 - 24) LRC EQU 2 ; Word entry containing next two bytes RCOL EQU 2 ; Right column for window (0 - 79) BROW EQU 3 ; Bottom row for window (0-24) ATTR EQU 4 ; Window text attribute LENWIN EQU 5 ; Window length in bytes ; ; RET 0 ;Dummy return for zero callers DB ? ;Fill in case we expand entry zero ; WINUM DB 1 ;Window number (default window 1) LENT DB LENWIN ;Window size ; JMP SHORT SCU ;Scroll up JMP SHORT SCD ;Scroll down JMP SHORT CEOL ;Clear to end of line JMP SHORT CEOS ;Clear to end of window JMP SHORT ATRB ;Change window attribute JMP SHORT DEFW ;Define a window ; ; SCU LABEL NEAR ;Scroll up window MOV DH,6 ;Function scroll up JMP SHORT SCROLL ; ; SCD LABEL NEAR ;Scroll down window MOV DH,7 ;Function scroll down SCROLL LABEL NEAR ;Entry for SCU PUSH BP ;Common code MOV BP,SP ; MOV SI,[BP+6] ;Get argument address MOV AX,[SI] ;Get value MOV AH,DH ;Function CALL BASE ;Get data area base MOV CX,ULC[DI] ;Upper left corner MOV DX,LRC[DI] ;Lower right corner MOV BH,ATTR[DI] ;Attribute INT 10H ;Enter BIOS RET2: POP BP ; RET 2 ;Return ; ; CEOL LABEL NEAR ;Clear to end of line in window PUSH BP CALL GETP ;Get position CALL CLRLIN ;Clear to end POP BP ; RET 0 ;And go home ; ; CEOS LABEL NEAR ;Clear to end of screen window PUSH BP ; CALL GETP ;Get position PUSH DX ;Remember that CALL CLRLIN ;Clear rest of this line POP DX ;Recall what that was CMP DH,BROW[DI] ;Close to bottom? JZ CEOSX ;Yes, exactly MOV CH,DH ;No, scroll rest of lines INC CH ; MOV CL,LCOL[DI] ;Left column MOV DX,LRC[DI] ;Lower right corner MOV BH,ATTR[DI] ;Attribute to fill MOV AX,0700H ;Function 7 and 0 to clear INT 10H ;Call BIOS CEOSX LABEL NEAR POP BP ; RET 0 ;And go home ; ; ATRB LABEL NEAR ;Change attribute for current window PUSH BP MOV BP,SP CALL BASE MOV SI,[BP+6] MOV AL,[SI] MOV ATTR[DI],AL ;New attribute for window JMP SHORT RET2 ;Return to caller offset 2 ; ; DEFW LABEL NEAR ;Define a window PUSH BP MOV BP,SP MOV SI,[BP+16] ;1st agrgument is screen number MOV AX,[SI] ;Get value CALL SHORT NEXT1 ; NEXT1: POP DI ;Get Pregister SUB DI,OFFSET(NEXT1-START) ;Okay MOV WINUM[DI],AL ;And store it CALL BASE2 ;Base window area PUSH ES PUSH DS POP ES MOV SI,[BP+12] ;Left column MOVSB DEC BYTE PTR [DI-1] ;All coordinates need to be based (0,0) MOV SI,[BP+14] ;Top row MOVSB DEC BYTE PTR [DI-1] MOV SI,[BP+8] ;Right column MOVSB DEC BYTE PTR [DI-1] MOV SI,[BP+10] ;Bottom row MOVSB DEC BYTE PTR [DI-1] MOV SI,[BP+6] ;Attribute MOVSB POP ES POP BP RET 12 ; ; GETP PROC NEAR MOV BX,0 ; MOV AH,3 ;Read current position INT 10H ; RET ; GETP ENDP ; ; CLRLIN PROC NEAR CALL BASE ;Get data area base MOV CL,RCOL[DI] ;Right window limit MOV CH,0 ;Clear top end SUB CL,DL ;Subtract columns done ADD CL,1 ;Add one till we figure out whats wrong MOV AX,0920H ;Write blanks MOV BL,ATTR[DI] ;Attribute INT 10H ; RET ; CLRLIN ENDP ; ; BASE PROC NEAR CALL SHORT NEXT ;To capture P address NEXT: POP DI ;Get that for index SUB DI,OFFSET (NEXT-START) ;For code relative offset BASE2 LABEL NEAR ;Alternate entry PUSH AX MOV AL,WINUM[DI] ;Get window number DEC AL ;Make zero relative MUL LENT[DI] ;Multiply by lenth of window ADD AX,OFFSET DATA ;Move to data area ADD DI,AX ;Add into segment offset POP AX RET BASE ENDP ;That is all ; ; DATA DB 0,0,79,23,7 ; Window 1 default data ; ; START ENDP CSEG ENDS END