dim msx basic

ページ 3/3
1 | 2 |

By DamnedAngel

Champion (266)

DamnedAngel さんの画像

03-10-2017, 15:31

Read times:

list:

https://msx.pics/image/Dd3K

run:

https://msx.pics/image/DKRg

full listing:

10 DEFINT I,J,X
20 DIM X(31,15)
100 REM ---------------
110 REM dim loop
120 REM ---------------
130 TIME = 0
140 FOR I = 0 TO 31
150 FOR J = 0 TO 15
160 X(I,J) = 0
170 NEXT
180 NEXT
190 PRINT "DIM WRITE TIME:";TIME
200 REM ---------------
210 REM poke loop
220 REM ---------------
230 TIME = 0
240 FOR I = &HC000 TO &HC1FF
250 POKE I, 0
260 NEXT
270 PRINT"POKE TIME:";TIME
300 REM ---------------
310 REM dim read loop
320 REM ---------------
330 TIME = 0
340 FOR I = 0 TO 31
350 FOR J = 0 TO 15
360 II=X(I,J)
370 NEXT
380 NEXT
390 PRINT "DIM READ TIME:";TIME
400 REM ---------------
410 REM peek loop
420 REM ---------------
430 TIME = 0
440 FOR I = &HC000 TO &HC1FF
450 II=PEEK(I)
460 NEXT
470 PRINT"PEEK TIME:";TIME

[]s

By tvalenca

Paladin (747)

tvalenca さんの画像

03-10-2017, 17:49

@DamnedAngel

Right, POKE is obviously faster. But the data POKEd on memory isn't usable as variables to BASIC. you still need to PEEK/POKE and if your program grows, you risk messing with BASIC data (or the other way around). BEST solution still is reading the entire text file, store into an array, then COPY it to a file that BASIC can understand (like NYYRIKKI said a little ago and I said yesterday). Good news is we can use openMSX for the conversion. If one's going to use BASIC, one's can't get in BASIC's way.

By DamnedAngel

Champion (266)

DamnedAngel さんの画像

03-10-2017, 18:25

@tvalenca

I partially agree. It depends on what is more relevant in every case:

  • If scalability and easy data access through BASIC variables are prioritized, COPY is the way to go.
  • If speed, including in random reading operations, is still more important, PEEK will do a much better job (for byte data, which seems to be adequate to TheKid's program) than BASIC variables.

Maybe COPY to load data in byte format to simplify loading operation and time AND peek afterwards to get maximum speed to random access could be the best of both worlds, if @TheKid is ready to compromise the direct access through BASIC variables...

By TheKid

Paragon (1238)

TheKid さんの画像

03-10-2017, 19:49

@everyone: Thanks for the help, I will go for the poke/peek approach. When the game is ready I will mention you all in the endcredits Smile

By tvalenca

Paladin (747)

tvalenca さんの画像

03-10-2017, 19:50

TheKid wrote:

@everyone: Thanks for the help, I will go for the poke/peek approach. When the game is ready I will mention you all in the endcredits Smile

A game? can't wait!

By Manuel

Ascended (19468)

Manuel さんの画像

03-10-2017, 20:50

If you want to load the data from a file, you can also BLOAD it in one go into RAM. No need to poke (perhaps only once to create the bloadable file).

By DamnedAngel

Champion (266)

DamnedAngel さんの画像

03-10-2017, 21:00

TheKid wrote:

I will go for the poke/peek approach.

As tvalenca well remembered, be careful not to POKE to:

  • BASIC program area;
  • BASIC data (variables/arrays) area;
  • Z80 stack; or
  • System work area (usually from f000h on).

Please refer to this content for more information.

As Lord_Zett said, you should be fine using up to 2k of memory from c000h on, and use

Clear XXXX, &HBFFF

to ensure BASIC knows that you are claiming that memory area. More info here.

TheKid wrote:

When the game is ready

YEAH! GO GAME!

ページ 3/3
1 | 2 |