Classic Computer Magazine Archive BEST OF ANTIC VOLUME 1

Move-It

Move-It provides the ATARI programmer with the ability to move one byte of data into a range of memory locations. This assembly language routine is position independent. It is loaded into a string from data statements 250 and 260. The routine is useful for clearing sections of screen memory, Player/Missile memory, erasing a player, and clearing memory used in page flipping.

The parameters which control this routine are passed in a USR statement. The start location and the byte total to be moved are passed. There are no limitations on the total bytes which can be moved.

Interesting sounds are also generated by the BASIC routine. The soundless version moves bytes at the rate of almost a quarter of a million per second (256 x 960).

by Jerry White

MACHINE LANGUAGE LISTING

10 ; This is a position independent subroutine
20 ; found in DATA statements line numbered 250 and 260
22 ; of BASIC listing
30 ; Calling Sequence from BASIC is:
40 ; A = USR(ADR($STR),Start Addr,Count)
50 ;
60          *=   $600      ; can go anywhere
70          PLA            ; ignore arguement count
80          PLA            ; save lo-byte of dest addr
90          STA  $CC
0100        PLA            ; save hi-byte of dest addr
0110        STA  $CB
0120        PLA            ; save total to be moved
0130        STA  $CE       ; *
0140        PLA            ; save total to be moved
0150        STA  $CD       ; *
0160        LDX  $CE       ; count of bytes to move
0170        LDY  #0        ; init index
0180        LDA  #0        ; init character to be moved
0190 MOV    STA ($CB),Y    ; move data
0200        DEY            ; decrement index
0210        BNE  MOV       ; go move next character
0220        INC  $CC       ; incr dest addr lo-byte
0230        DEX            ; decr lo-byte count to move
0240        BMI  EXIT
0250        BNE  MOV       ; go move next character
0260        LDY  $CD       ; hi-byte of count to move
0270        BNE  MOV       ; go move next character
0280 EXIT   DEC  $CC       ; decr lo-byte dest addr
0290        LDY  #0
0300        STA  ($CD),Y
0310        RTS            ; return to BASIC
0320        .END

BASIC LISTING

5 GOTO 35
10 REM MOVIT UTILITY/DEMO BY JERRY WHITE 3/31/82
15 REM THATS INCREDIBLE SUBROUTINE
20 FOR M=0 TO 255
21 Z$(19,19)=CHR$(M)
22 Z=USR(ADR(Z$),SM,960)
23 NEXT M
24 RETURN
30 REM SM=SCREEN MEMORY C=SPEAKER
35 GRAPHICS 0
36 POKE 82,0
37 DIM Z$(42)
38 POKE 752,1
39 S=PEEK(560)+PEEK(561)*256+4
40 SM=PEEK(S)+PEEK(S+1)*256
41 C=53279
45 REM Z$=ASSEMBLER ROUTINE STRING (POSITION 19=CHARACTER TO MOVE)
50 REM Z=USR(ADR(Z$),START ADR,HOW MANY)
60 FOR X=1 TO 42
61 READ IT
62 Z$(X,X)=CHR$(IT)
63 NEXT X
64 POKE 82,0
65 ? "[backspace character]";
66 POKE 83,39
67 SOUND 0,0,0,0
68 Z$(19,19)=CHR$(128)
69 Z=USR(ADR(Z$)SM,960)
70 POKE 710,113
71 POSITION 39,0
72 ? CHR$(160);
75 ? "    This DEMO demonstrates an assembler "
76 ? "    MOVE routine called from BASIC.     "
80 ? "    Possible uses would be to move      "
81 ? "    blanks or special characters to an  "
85 ? "    area of screen memory, or to clear  "
86 ? "    RAM used for player missiles or     "
90 ? "    page flipping etc.                  "
95 ? "          SELECT OPTION NUMBER:         "
96 ? "      (1) FAST WITH SOUND               ":GOSUB 230
100 ? "      (2) VERY FAST WITH SOUND          ":GOSUB 230
105 ? "      (3) THAT'S INCREDIBLE (SILENT)    ":GOSUB 230
110 POKE 764,255
111 CLOSE #1
112 OPEN #1,4,0,"K:"
113 GET #1,K
114 CLOSE #1
115 REM ACCEPT ONLY A 1 2 OR 3
120 IF K<49 OR K>51 THEN FOR ME=15 TO 0 STEP -0.5
121 SOUND 0,102,12,ME
122 NEXT ME
123 GOTO 110
130 REM I LOVE SOUND ROUTINES
135 FOR J=1 TO 7
136 POKE 710,J*16
137 FOR X=2 TO 0 STEP -1
138 FOR ME=14 TO 0 STEP -2
139 SOUND 0,X+J,2,ME
140 NEXT ME
141 NEXT X
142 NEXT J
145 REM EXECUTE SELECTED MOVIT ROUTINE
150 IF K=51 THEN GOSUB 20:GOTO 175
155 IF K=50 THEN GOSUB 190:GOTO 175
160 GOSUB 210:GOTO 175
170 REM DING...ALL DONE...START OVER
175 FOR ME=15 TO 0 STEP -0.2
176 SOUND 0,0,2,ME
177 NEXT ME
178 RUN
185 REM VERY FAST SUBROUTINE WITH SOUND
190 FOR M=0 TO 255
191 Z$(19,19)=CHR$(M)
192 POKE 53761,168
193 POKE 53763,168
194 POKE 53760,255-M
195 POKE 53768,13
196 POKE 712,M
197 POKE 53762,M
198 POKE 53762,M/8
199 POKE 53768,2
200 Z=USR(ADR(Z$),SM,960)
201 POKE 53761,0
202 POKE 53763,0
203 NEXT M
204 RETURN
205 REM FAST SUBROUTINE WITH SOUND
210 FOR M=255 TO 0 STEP -1
211 Z$(19,19)=CHR$(M)
212 POKE 53760,M
213 FOR V=175 TO 160 STEP -1
214 POKE 53761,V
215 POKE 53768,V-160
216 NEXT V
217 POKE 712,M
218 Z=USR(ADR(Z$),SM,960)
219 NEXT M
220 RETURN
225 REM BLINK & BUZZ SUBROUTINE
230 FOR JW=0 TO 8
231 POKE 755,1
232 POKE C,0
233 POKE C,8
234 NEXT JW
235 FOR JW=0 TO 8
236 POKE 755,2
237 NEXT JW
238 RETURN
240 REM DATA TO CREATE Z$ ASSEMBLER SUBROUTINE
250 DATA 104,104,133,204,104,133,203,104,133,206,104
255 DATA 133,205,166,206,160,0,169,0,145,203,136
260 DATA 208,251,230,204,202,48,6,208,244,164,205
265 DATA 208,240,198,204,160,0,145,203,96

Listing 1: MOVEIT.SRC Download / View

Listing 2: MOVEIT.BAS Download