$CPU 8086 ' make compatible with XT systems $LIB ALL OFF ' turn off all PowerBASIC libraries $ERROR ALL OFF ' turn off all PowerBASIC error checking $OPTIMIZE SIZE ' optimize for smaller code $COMPILE UNIT ' compile to a UNIT (.PBU) '$COMPILE EXE ' compile to a UNIT (.PBU) DEFINT A-Z ' Required for all numeric functions, forces PB to not ' include floating point in UNIT (makes it smaller) '/*------------------------------------------------------------------*/ $CODE SEG "MLIB12" '/*------------------------------------------------------------------*/ ' PgCopy - Copy data from one text page to another ' ' SOURCEPAGE = Text page to copy from (starts with 0) ' TARGETPAGE = Text page to copy to (starts with 0) ' SUB VPGCOPY(BYVAL SOURCEPAGE AS INTEGER, BYVAL TARGETPAGE AS INTEGER) PUBLIC DIM PageSize AS INTEGER DIM ScrnSeg AS INTEGER IF (pbvScrnCard AND 1) = 1 THEN ' monochrome adaptor only has 1 page EXIT SUB END IF IF (pbvScrnRows = 25) AND (pbvScrnCols = 80) THEN PageSize = 4096 ' 80x25 = 4k page; could be buggy CGA ELSEIF (pbvScrnRows = 25) AND (pbvScrnCols = 40) THEN PageSize = 2048 ' 40x25 = 2k page; could be buggy CGA ELSE ! push DS ; save DS for PowerBASIC ! xor AX, AX ; clear AX ! mov DS, AX ; and DS ! mov AX, DS:[&H044C] ; get page size from BIOS ! mov PageSize, AX ; put it in PageSize ! pop DS ; restore DS for PowerBASIC END IF SOURCEPAGE = SOURCEPAGE * PageSize ' calculate offset of source page TARGETPAGE = TARGETPAGE * PageSize ' calculate offset of target page ScrnSeg = &HB800 ' only color adaptors have multiple pages ! push DS ; save DS for PowerBASIC ! mov AX, ScrnSeg ; put screen segment in AX ! mov ES, AX ; and in ES ! mov DS, AX ; and in DS ! mov SI, SOURCEPAGE ; put source page offset in SI ! mov DI, TARGETPAGE ; put target page offset in DI ! mov CX, PageSize ; put page size in CX ! shr CX, 1 ; divide by two ! rep movsw ; move data as words (faster than bytes) ! pop DS ; restore DS for PowerBASIC END SUB '/*------------------------------------------------------------------*/ ' VPGCOPY 0,1 ' CLS ' PRINT pbvScrnAPage ' INPUT Z ' VPGCOPY 1,0 ' DO ' Y$ = INKEY$ ' LOOP UNTIL Y$ <> ""