dim msx basic

Pagina 2/3
1 | | 3

Van Sandy Brand

Master (156)

afbeelding van Sandy Brand

02-10-2017, 23:13

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.

Van DamnedAngel

Master (143)

afbeelding van DamnedAngel

02-10-2017, 23:40

@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.

Van wolf_

Ambassador_ (9769)

afbeelding van wolf_

03-10-2017, 00:23

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

Van TheKid

Paladin (818)

afbeelding van TheKid

03-10-2017, 07:37

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

Van Lord_Zett

Paladin (807)

afbeelding van Lord_Zett

03-10-2017, 10:10

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

to read D=poke(&Hc000+(byte nummer))

Van TheKid

Paladin (818)

afbeelding van TheKid

03-10-2017, 10:13

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

Van Lord_Zett

Paladin (807)

afbeelding van Lord_Zett

03-10-2017, 10:18

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

Van Arjan

Paladin (714)

afbeelding van Arjan

03-10-2017, 11:05

@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!

Van NYYRIKKI

Enlighted (5385)

afbeelding van NYYRIKKI

03-10-2017, 12:48

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.

See details here.

Van DamnedAngel

Master (143)

afbeelding van DamnedAngel

03-10-2017, 14:55

Lord_Zett wrote:

to read D=poke(&Hc000+(byte nummer))

To read, use peek instead of poke.

Arjan wrote:

@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!

It was intentional, since my stupid mind considered that int ranges from -7fffh to 8000h, leaving c000h out of the interval. But, of course c000h = -4000h(16 bits) which is or course within the range. Fool me.

@TheKid, new version, twice as fast, thanks to Arjan:

list:

https://msx.pics/image/DDzQ

run:

https://msx.pics/image/Db5W

[]s

Pagina 2/3
1 | | 3