VOGONS


First post, by Peter Swinkels

User metadata
Rank Oldbie
Rank
Oldbie

QBasic's PCOPY doesn't work properly with text 50 lines in text-mode. I fixed that:

Assembly:

; 50 lines text mode PCOPY substitute for QBasic.
push bp ; Save previous bp.
mov bp,sp ; Set new bp.
push ds ; Save ds.
push es ; Save es.
push di ; Save di.
push si ; Save si.

mov cx,0xb800 ; Set bx to the first screen page's segment address.
mov dx,0xba04 ; Set cx to the second screen page's segment address.
mov bx,[bp+6] ; Load parameter. (0 = copy, 1 = restore)
cmp word [bx],0 ; Unless parameter is zero, these addresses are swapped before copying.
je SkipSwap ;
xchg cx,dx ;
SkipSwap: ;

mov ds,cx ; Load source segment address.
mov es,dx ; Load target segment address.
xor di,di ; Set di to zero.
xor si,si ; Set si to zero.
mov cx,4000 ; Set the number of words to be copied.
rep movsw ; Copy the source screen page to the target page.

pop si ; Restore si.
pop di ; Restore di.
pop es ; Restore es.
pop ds ; Restore ds.
pop bp ; Restore bp.
retf 2 ; Return and remove arguments from stack.

QBasic demo:

DEFINT A-Z
CLS
WIDTH 80, 50

OPEN "PCOPY50" FOR INPUT LOCK READ WRITE AS 1
CLOSE 1

OPEN "PCOPY50" FOR BINARY LOCK READ WRITE AS 1
PCOPY50$ = INPUT$(LOF(1), 1)
CLOSE 1

PRINT STRING$(4000, "*");

SLEEP 1
DEF SEG = VARSEG(PCOPY50$)
CALL ABSOLUTE(0, SADD(PCOPY50$))

CLS
SLEEP 1
DEF SEG = VARSEG(PCOPY50$)
CALL ABSOLUTE(1, SADD(PCOPY50$))
END

My GitHub:
https://github.com/peterswinkels

Reply 1 of 2, by Jo22

User metadata
Rank l33t++
Rank
l33t++

Thanks! 😀

"Time, it seems, doesn't flow. For some it's fast, for some it's slow.
In what to one race is no time at all, another race can rise and fall..." - The Minstrel

//My video channel//

Reply 2 of 2, by Peter Swinkels

User metadata
Rank Oldbie
Rank
Oldbie

You're welcome, did you actually find a use for this?

My GitHub:
https://github.com/peterswinkels