COPY
This page was last modified 17:11, 21 August 2018 by Mars2000you. Based on work by NYYRIKKI and Gdx and others.

Contents

Effect

Copies data between RAM, VRAM and disk.

Syntaxes

  • COPY [(<XS>,<YS>)]-[STEP](<XS2>,<YS2>)[,<source page>] TO (<XD>,<YD>)[,<destination page>][,<operator>]
  • COPY [(<XS>,<YS>)]-[STEP](<XS2>,<YS2>)[,<source page>] TO "[<devicename>:][\<path>][\]<filename>"
  • COPY [(<XS>,<YS>)]-[STEP](<XS2>,<YS2>)[,<source page>] TO <array>
  • COPY <array>[,<direction>] TO (<XD>,<YD>)[,<destination page>][,<operator>]
  • COPY <array> TO "[<devicename>:][\<path>][\]<filename>"
  • COPY "[<devicename>:][\<path>][\]<filename>",[<direction>] TO (<XD>,<YD>)[,<destination page>][,<operator>]
  • COPY "[<devicename>:][\<path>][\]<filename>"[,<direction>] TO "[<devicename>:][\<path>][\]<filename>"
  • COPY "[<devicename>:][\<path>][\]<filename>"[,<direction>] TO <array>

Note: Character backslash (\) is used in Disk BASIC 2.x. It is replaced by the character yen (¥) on Japanese MSX.

Parameters

Note: Coordinates and arrays can be used only in screen modes 5 to 8 and 10 to 12. (MSX-BASIC 2.0 or newer)

<XS> and <YS> are upper-left coordinates of transfer source (X=0-255/511, Y=0-211). If it is omited the current coordinates of cursor will be chosen.

<XS2> and <YS2> are lower-right coordinates of transfer source (X2=0-255/511, Y2=0-211).

STEP parameter changes X2 and Y2 coordinates to relative coordinates (and therefore allows the use of negative values).

<source page> is the page number in VRAM of transfer source. The number can be 0/1 or 0~3 depending used screen mode. (current page by default)

<XD> and <YD> are upper-left coordinates of transfer destination (X=0-255/511, Y=0-211).

<destination page> is the page number in VRAM of transfer destination. The number can be 0/1 or 0~3 depending used screen mode. (current page by default)

<operator> defines the logical operations to operate, how copied picture data is mixed with existing picture data. If logical operation is not defined, PSET (do not mix) is expected.

The available operators are AND, OR, PRESET, PSET (default), TAND, TOR, TPRESET, TPSET, TXOR, XOR. Specifying a logical operation preceded by "T" causes nothing to be done when copied color is transparent (color 0).

The effect of the operators is done on each corresponding bit as shown in the following table.

Current bit Copied color bit AND OR PRESET PSET XOR
0 0 0 0 1 0 0
0 1 0 1 0 1 1
1 0 0 1 1 0 1
1 1 1 1 0 1 0


<array> must be an array variable with one or two parameters (to transfer line X and Y pixel data). (Parameter available since MSX-BASIC 2.0)

<direction> determines the rotation of the picture and must be an integer. This parameter can be used only if destination is graphics coordinate.

Bit 0: Invert X-direction
Bit 1: Invert Y-direction

Direction Picture rotation
0 No rotation
1 Left - Right
2 Up - Down
3 Left - Right + Up - Down


<devicename> is the name for used device. It can only be a disk drive.

If you don't specify the drive, the computer will copy file(s) from or to the currently active drive (by default, it's drive A:)

Device type Device name Remark
Disk drive A, B, C, D, E, F, G, H A floppy disk interface can control until 2 drives.


Note: the destination device can be the text screen with CON (without :) in stead of CRT (followed by :).

<path> is used to specify the location in folders where you want display files. Each folder name in path are separate by a backslash (\). (Parameter available with the Disk BASIC 2.0 or newer)

<filename> is the file name in the format 8 characters followed by a point and an extension with 3 characters.

When copying from one diskdrive to another diskdrive
- the source name will be used as destination name if you don't specify the destination name
- several files can be handled together by COPY in a similar way as for other Disk BASIC commands

Examples

COPY "README.TXT" TO "CON" ' Display file on text screen
COPY "M*.*" TO "B:"  'Copy all files with M as 1st character in the name from drive A to drive B
 
COPY "*.BAS" TO "B:"  'Copy all files with the extension ".BAS" from drive A to drive B
 
COPY "TEST.BAS" TO "B:GAME.BAS" 'Copy one file from drive A to drive B and rename it
 
COPY  "*.*" TO "B:"  'Copy all the files from drive A to drive B

Next examples are made by: NYYRIKKI Please contact in case of questions.

' Endless lives to Xyzolog
DEFINT D:DIM D(8191):COPY "XYZOLOG.ROM" TO D:D(3342)=2072:COPY D TO "XYZOLOGC.ROM"
10 ' Create 3 little programs to change display Hz rate under DOS
20 DEFINTA-Z:DIMD(7):FORI=0TO7:READD(I):NEXT
30 FORI=0TO2:IFITHENN$=OCT$(32+I*8):READD(2)
40 COPYDTON$+"Hz.COM":NEXT
50 DATA-6111,32511,750,-3209,-26157,-30402,-26157,201,758,-538
10 ' Fill screen with cute pattern
20 SCREEN 5
30 PSET (0,0):PSET(4,4):CIRCLE(4,4),3
40 COPY (0,0)-(247,7) TO (8,0)
50 COPY (0,0)-(255,199) TO (0,8)
60 A$=INPUT$(1)
10 ' Creating shadow for an object using COPY-command
20 ' ------------------------------------------------
30 SH=1 ' Shadow color
40 ' Example object
50 COLOR 15,0,0
60 SCREEN 5
70 COLOR=(0,0,2,0)
80 FOR I=14 TO 5 STEP -1
90 CIRCLE (32,32),I*2,I,,,I/10
100 PAINT (32,32),I
110 NEXT
120 LINE (0,30)-(63,34),4,BF
130 ' Shadow
140 COPY (0,0)-STEP(63,63) TO (108,108),,TPRESET
150 COPY (0,0)-STEP(63,63) TO (108,108),,OR
160 LINE (108,108)-STEP(63,63),SH,BF,AND
170 ' Object
180 COPY (0,0)-STEP(63,63) TO (100,100),,TPSET
190 A$=INPUT$(1)
10 DIM D(16)
20 SCREEN 5
30 PSET (0,0):OPEN"GRP:" FOR OUTPUT AS #1:PRINT#1,"Copy":CLOSE
40 COPY (0,0)-(31,7) TO D ' Copy to array
50 COPY D,3 TO (255,211) ' Copy back to screen but upside down
60 A$=INPUT$(1)
10 ' Some Sierpinski-triangles
20 COLOR 15,0,0:SCREEN 5
30 FORI=RND(-5048) TO 6:PSET(RND(1)*255,RND(1)*211),RND(1)*13+2:NEXT I
40 FOR I=0 TO 211:H=IAND254:L=(IAND1)*2
50 COPY (1,H)-STEP(253,0) TO (L,H+2),,XOR
60 COPY (1,211-H)-STEP(253,0) TO (L,209-H),,XOR
70 NEXT I
80 A$=INPUT$(1)

Related to

AND, DIM, KILL, NAME, OR, SET PAGE, SCREEN, XOR

Compatibility

Disk BASIC 1.0 or higher. (Array variable, graphical coordinates and logical operations require MSX-BASIC 2.0 or higher)