# dim msx basic

페이지 2/3
1 | | 3

Maybe a simple trick is not to use a 2d array but just a long '1D', that might remove 'some' of the multiplications for the look-up if your algorithm allows to incrementally traverse the array somehow.

@TheKid,
You mentioned 256 values, but you meant 512, right (32x16)?

@All,
I just made a experience in WEBMSX to compare DIM with POKE times (supposing each TheKid's data can be accommodated in bytes), and the results were not impressive:

List:

Edit: The image didn't show up, so here ir the URL: https://msx.pics/image/D77r

Run:

Edit: The image didn't show up, so here ir the URL: https://msx.pics/image/DnjC

Didn't everyone expect POKE to be somewhat faster? DId I do some dumb thing in my basic code?

I don't know how time accurate WEBMSX is, but since it plays games very well I think its results should be representative.

Well, "poke 12345,255" is slightly longer to parse than "a(12345)=255". Maybe that's a factor too?

@DamnedAngel: You are right, 32x16 isn't 256 But nice test, I was under the impression that using pokes would be much faster dan dim.

eeej The Kid. using poke is easy in basic. its faster and you can bsave the data.

do:

Clear XXXX, &HBFFF

The XXXX is the size. max 4096 bytes to use. but i do not use more than 2048 bytes
Then you can poke &HC000+(byte nummer),data

@Thanks Lord_Zett, I will give it a try and hope it's faster then the dim array.

yeah the easy bsave and bload the data is handy. you can just bsave "data.dat",&HC000, &HC000+(byte nummer max)

@DamnedAngel you defined variables I, J and X as INT, but you didn't define variable K, that's why the POKE version is not as fast as expected. If K is also INT, the POKE version is almost twice as fast!

I suggest that you make separate program that reads the text file. Then in the end you use COPY-command to store the table in to file and in your main program you use COPY again to restore the table values.

Lord_Zett wrote: