![]() |
DIM At? - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: DIM At? (/showthread.php?tid=703) |
DIM At? - Haplo - 11-04-2015 Hi, I'm a newbie with Boriel's ZX Basic and I´m not sure if there is a way to do something like this: DIM charset(767) As uByte At 49152 => {0,12,48,36,....,(768th byte)} The idea is to place an array of 768 bytes (like a character set) at a specific memory direction(49152). I was read the Wiki and I found some references to "DIM At" but it's not clear for me . Re: DIM At? - boriel - 11-04-2015 Unfortunately DIM AT for arrays is not supported (yet). This is because ZXBASIC allocates a table of dimensions (one Uinteger per dimension) just before the data. I'm working on a Dynamic ARRAY scheme, so this could be possible in the future. RE: DIM At? - boriel - 11-10-2019 This has been implemented in ZX Basic 1.9+ RE: DIM At? - maeloterkim - 11-21-2019 (11-10-2019, 10:02 PM)boriel Wrote: This has been implemented in ZX Basic 1.9+ Hi ![]() What is the sintaxis for DIM at? Can you put some examples with initialized array and not initialized array? thanks RE: DIM At? - boriel - 11-21-2019 (11-21-2019, 01:03 PM)maeloterkim Wrote:(11-10-2019, 10:02 PM)boriel Wrote: This has been implemented in ZX Basic 1.9+ DIM AT does not allow initialized values. The content will be whatever there exists already at the given location. For arrays the syntax is DIM varname(dim1, dim2, dim3...) AS <type> AT <address>. For example: DIM a(6144) As UByte AT 16384 This is undocumented (yet) for arrays, but will be updated here: https://zxbasic.readthedocs.io/en/latest/dim/ Hope this helps RE: DIM At? - maeloterkim - 11-21-2019 (11-21-2019, 04:28 PM)boriel Wrote:(11-21-2019, 01:03 PM)maeloterkim Wrote:(11-10-2019, 10:02 PM)boriel Wrote: This has been implemented in ZX Basic 1.9+ Well i'm doing now this for the UDGs DIM MyUDGs(167) As uByte => {MY...UDG...BYTES} poke uinteger 23675, @MyUDGs would be very good do something like this ![]() DIM MyUDGs(167) As uByte AT (PEEK uinteger 23675) => {MY...UDG...BYTES} OR DIM MyUDGs(167) As uByte => {MY...UDG...BYTES} AT (PEEK uinteger 23675) where the UDGs are poked directly where they must be maybe you can "know" where the programmer want to put the values of the array ( calculate all the memory used and the memory left ) then you know what memory is left to put the compiled program and then you know if is compilable or not i don't know if i'm saying somethig stupid or is a posible idea ![]() Hope this helps RE: DIM At? - boriel - 11-22-2019 Not sure if I get you. When you declare an array it's a fixed location (for the moment). However it's possible to copy array content (if both arrays have the same type and size). For example: Code: DIM myUDGSet1(128) as UByte => {...} Does this help? What you're asking above looks more like a pointer and it's not yet :-) RE: DIM At? - maeloterkim - 11-22-2019 Well i don't know how the compiler works (take this in mind ![]() if i found a DIM with AT ( first i look for all of them) 1) i copy the bytes of the dim (or others AT) at the position of the AT or something like this or reserve space for this for write it after or an array of holes with data 2) i calculate the holes of empty memory to put the "normal" stuff maybe can make an array of empty memory holes end if if i found other stuff without AT i put this things on the empty memory holes in order end if I don't know if something like this can work with the compilator This way the program saves bytes from memory and from the program to copy bytes to other locations OR maybe another way 1) DIM AT 2) the compiler move the data to the AT place 3) the programmer knows that CAN'T use the array in a normal way to acces the values of the DIM (can't use array(2,3) per example) but is useful for example for poke directly some memory address like UDG by the way great compiler ![]() RE: DIM At? - boriel - 11-25-2019 DIM AT only maps an array to a memory region. It does not reserve memory. If you want to declare an array to map UDGs into it, you should use: DIM myUDGtable(...) as UBYTE => {...} POKE UInteger 23675, @myUDGTable(0, 0, ...) If you have several UDGs sets you can arrange them in different arrays and poke for each one as above when required, or better: put all the graphics in a single array, were each row is a new charset: Code: DIM myUDG1(8, 128) as UByte => { ... } Hope this helps. |