Let's see how this X-Y positioning works, using sprite 1. Type this program:
10 PRINT"{CLEAR}":V=53248:POKEV+21,2:POKE2041,13 20 FORS=832TO895:POKES,255:NEXT:POKEV+40,7 30 POKEV+2,24 40 POKEV+3,50
This simple program establishes sprite 1 as a solid box and positions it at the upper left corner of the screen. Now change line 40 to read:
40 POKE V+3,229This moves the sprite to the bottom left corner of the screen. Now let's test the RIGHT X LIMIT of the sprite. Change line 30 as shown:
30 POKE V+2,255
This moves the sprite to the RIGHT but reaches the RIGHT X LIMIT, which is 255. At this point, the "most significant bit" in register 16 must be SET. In other words, you must type POKE V+ 16 and the number shown in the "RIGHT X" column in the X-Y POKE CHART above to RESTART the X position counter at the 256th pixel/position on the screen. Change line 30 as follows:
30 POKE V+16,PEEK(V+16)OR 2:POKE V+2,0POKE V+16,2 sets the most significant bit of the X position for sprite 1 and restarts it at the 256th pixel/position on the screen. POKE V+2,0 displays the sprite at the NEW POSITION ZERO, which is now reset to the 256th pixel.
To get back to the left side of the screen, you must reset the most significant bit of the X position counter to 0 by typing (for sprite 1):
POKE V+16, PEEK(V+16)AND 253
TO SUMMARIZE how the X positioning works... POKE the X POSITION for any sprite with a number from 0 to 255. To access a position beyond the 255th position/pixel across the screen, you must use an additional POKE (V+16) which sets the most significant bit of the X position and start counting from 0 again at the 256th pixel across the screen.
This page has been created by Sami Rautiainen. | |
Read the small print. | Last updated May 12, 2002. |