jbs30000 #1 Posted October 16, 2010 It's been a while since I've done this so I figured I'd better double check because my memory is crap. If I go dim MyArray=a Then MyArray[0] is a and MyArray[1] is b, correct? Quote Share this post Link to post Share on other sites
+Random Terrain #2 Posted October 16, 2010 I don't know for sure, but I thought arrays were read-only with bB: http://www.randomterrain.com/atari-2600-memories-batari-basic-commands.html#dataarrays Quote Share this post Link to post Share on other sites
SeaGtGruff #3 Posted October 16, 2010 It's been a while since I've done this so I figured I'd better double check because my memory is crap. If I go dim MyArray=a Then MyArray[0] is a and MyArray[1] is b, correct? Yes, that's right. The number in square brackets is the offset to the starting address, so an offset of 0 gives you the starting address (a). The assembly equivalent is ; MyArray[0] LDX 0 LDA MyArray,X ; MyArray[1] LDX 1 LDA MyArray,X Michael Quote Share this post Link to post Share on other sites
SeaGtGruff #4 Posted October 16, 2010 I don't know for sure, but I thought arrays were read-only with bB: If you dim an array to ROM, it will be a read-only array. But if you dim an array to RAM, it will be a read/write (variable) array. Note that if you dim an array to expansion RAM that requires separate read and write addresses, you'll need to either dim the array twice-- once for writing, and once for reading-- or you'll need to modify the index as needed if the expansion RAM is small enough. For example: rem dim a Superchip array for writing and reading dim w_MyArray=$F000 dim r_MyArray=$F080 w_MyArray[12]=rand w_MyArray[12]=r_MyArray[12]+1 rem modify the index instead of dimming twice dim MyArray=$F000 rem use index 0 to 127 for writing rem use index 128 to 255 for reading MyArray[12]=rand MyArray[12]=MyArray[140]+1 In the second example, note that 140=12+128, so it does the same thing as the first example (add 1 to the element with index 12). However, the second example/method is harder for the reader to understand, and it will work only for Superchip expansion RAM (since the Superchip has 128 bytes of RAM, so there are a total of 256 write and read addresses). Michael Quote Share this post Link to post Share on other sites