![]() |
Initialising an array of addresses - 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: Initialising an array of addresses (/showthread.php?tid=369) |
Initialising an array of addresses - LTee - 08-10-2011 I was trying to keep a list of memory addresses (pointing to tile data) in an array to use as a cheap lookup table. I tried to do something like this: Code: 'data ... which doesn't work, because @Data isn't a constant so I get an "Initializer expression is not constant" compiler error. I could write and call a method which loads the array with the correct information on startup, but I just wanted to check that I wasn't missing an obvious trick which would allow me to avoid that? Thanks for any tips! ![]() Re: Initialising an array of addresses - boriel - 08-10-2011 You can't do it that way, but you can simply put those bytes in 16bit format: Code: dim tsAddress(TSMAXTILES) as uinteger => {0 + 256 * 0, 191 + 256 * 191, 191 + 256 * 191, 191 + 256 * 191, 0 ... Code: dim tsAddress(TSMAXTILES) as uinteger => {0x0000, 0xBFBF, 0xBFBF, 0xBFBF, 0x0000, ... Re: Initialising an array of addresses - LTee - 08-10-2011 Ah, interesting! I'll give that a try, thanks boriel! |