Memcopy

 BBS: Inland Empire Archive
Date: 04-09-93 (14:51)             Number: 296
From: JOHN GALLAS                  Refer#: NONE
  To: WAYNE VENABLES                Recvd: NO  
Subj: Memcopy                        Conf: (2) Quik_Bas
WV>I really need a good memory copy routine with...

WV>        Source Segment/Offset
WV>        Destination Segment/Offset
WV>        Number of bytes to copy

WV> I remember a memcopy.obj that was posted here a while ago, can anybody
WV> repost!!!

Yep!  Here it is..  Works great too.  I use it all the time.
Thanks Mark!

'===========================================================================
'Date: 10-14-92 (22:42)             Number: 184
'From: MARK BUTLER                  Refer#: 185
'  To: ALL                           Recvd: YES
'Subj: Screen save/rest               Conf: (9) Quick Basi
'
' Hi all, I had been fooling around with text mode screen save/restore ' routines and discovered something kinda neat. In the book "Microsoft ' QuickBASIC Programmer's Toolbox" there are two routines in 'C' to do ' this; 'MoveBytes' and 'MoveWords'. I looked the C code over and noticed ' that both make use of QuickC's "_movedata" funtion so I wondered "why ' bother to make a linkable C routine? Why not just link in the asm-based ' MOVEDATA.OBJ from MLIBCE.LIB directly?" (which was really all J. C. ' Craig's code seemed to be doing in the first place). Well, I fooled with ' it and found that it would work just fine. In the below 2 snippets the ' first is a simple text screen save/restore demo in Basic. The second is ' a debug script for movedata.obj. To run this demo create a QLB from ' movedata.obj or compile the program linking in movedata.obj. ' '==========================8< Cut Here 8<============================= '*** SCREEN SAVE/RESTORE DEMO by Mark H Butler DEFINT A-Z DECLARE SUB DrawBox (Uprow, Ltcol, Lorow, Rtcol) DECLARE SUB MoveData CDECL (BYVAL fromseg, BYVAL fromoff, BYVAL destseg, BYVAL DECLARE SUB RestScrn (Scr()) DECLARE SUB SaveScrn (Scr()) '*** create an array to hold all the text mode screen elements DIM SHARED Scr(2000) '*** print some junk to the screen COLOR 7, 1 CLS FOR i = 1 TO 13 FOR ch = 33 TO 176 PRINT CHR$(ch); NEXT ch NEXT i '*** save the current screen SaveScrn Scr() '*** draw a white window box with black text COLOR 0, 7 DrawBox 10, 10, 14, 70 LOCATE 12, 15 PRINT "Press any key to remove window non-destructively" COLOR 7, 0 '*** wait until a key is pressed DO UNTIL LEN(INKEY$): LOOP '*** restore the original screen RestScrn Scr() SUB DrawBox (Uprow, Ltcol, Lorow, Rtcol) STATIC Wide = (Rtcol - Ltcol) - 1 LOCATE Uprow, Ltcol PRINT CHR$(201); STRING$(Wide, CHR$(205)); CHR$(187); FOR i = Uprow + 1 TO Lorow - 1 LOCATE i, Ltcol PRINT CHR$(186); SPACE$(Wide); CHR$(186); NEXT i LOCATE Lorow, Ltcol PRINT CHR$(200); STRING$(Wide, CHR$(205)); CHR$(188); END SUB SUB RestScrn (Scr()) DEF SEG = &H40 equip = PEEK(&H10) IF (equip AND 48) = 48 THEN destseg = &HB000 ELSE destseg = &HB800 END IF destoff = 0 fromseg = VARSEG(Scr(0)) fromoff = VARPTR(Scr(0)) nbytes = 4000 MoveData fromseg, fromoff, destseg, destoff, nbytes END SUB SUB SaveScrn (Scr()) DEF SEG = &H40 equip = PEEK(&H10) IF (equip AND 48) = 48 THEN fromseg = &HB000 ELSE fromseg = &HB800 END IF fromoff = 0 destseg = VARSEG(Scr(0)) destoff = VARPTR(Scr(0)) nbytes = 4000 MoveData fromseg, fromoff, destseg, destoff, nbytes END SUB and now the .obj file: 'Save this script to a file, edit out all of the non-QB related text and 'execute it in a QB environment to retrieve MOVEDATA.OBJ. DEFINT A-Z:DIM SHARED C(32700),Q,T$:OPEN"B",1,"MOVEDATA.OBJ":N=146 T$="abcdefghijklmnopqrstuvwxyz":T$=T$+UCASE$(T$)+"0123456789()":K=256 G"a6aam02B2vgzHrxyUe2CTzQLFaaagq0rs9uvqrarbrvqem0tevubFruqufubFrvr G"yrfeyEaai5bagqqaWJ5baGeaauWabaHMeaGa)lWxqcbaaeqcF12B2vgzHrxyaaaa G"MIibaaGObenOIaqaaaqvlYUvx5HJEzWI2HGJgPWI(XWIo5W8K(XxETy5DTSXkkaa G"aqh" FOR A=1 TO N:LOCATE,1:?(100&*A)\N"%";:IF L=0 THEN W=C(I)*K-K:I=I+1:L=6 W=W\K OR (C(I)-1)*2^L:I=I+1:L=L-2:B$=CHR$(W AND 255):PUT 1,,B$:NEXT SUB G(A$):FOR A=1 TO 64:C(Q)=INSTR(T$,MID$(A$,A,1)):Q=Q+1:NEXT:END SUB * OLX 2.1 TD * I don't have a life, I have a BBS.. --- Maximus 2.01wb * Origin: Command Line BBS =Mpls. MN= V.32bis [612-788-6685] (1:282/2007)
Outer Court
Echo Basic Postings

Books at Amazon:

Back to BASIC: The History, Corruption, and Future of the Language

Hackers: Heroes of the Computer Revolution (including Tiny BASIC)

Go to: The Story of the Math Majors, Bridge Players, Engineers, Chess Wizards, Scientists and Iconoclasts who were the Hero Programmers of the Software Revolution

The Advent of the Algorithm: The Idea that Rules the World

Moths in the Machine: The Power and Perils of Programming

Mastering Visual Basic .NET