dim msx basic

페이지 2/3
1 | | 3

By Sandy Brand

Master (230)

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.

By DamnedAngel

Master (221)

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.

By wolf_

Ambassador_ (9876)

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?

By TheKid

Paragon (1175)

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.

By Lord_Zett

Paladin (807)

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))

By TheKid

Paragon (1175)

TheKid의 아바타

03-10-2017, 10:13

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

By Lord_Zett

Paladin (807)

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)

By Arjan

Paladin (728)

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!

By NYYRIKKI

Enlighted (5776)

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.

By DamnedAngel

Master (221)

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

페이지 2/3
1 | | 3