dmsc / fastbasic

FastBasic - Fast BASIC interpreter for the Atari 8-bit computers
GNU General Public License v2.0
139 stars 20 forks source link

MSET improvement #19

Open ukcroupier opened 4 years ago

ukcroupier commented 4 years ago

Would it be possible to add an optional 4th parameter to MSET in order to to set every other byte or every 3rd byte etc.?

eg. MSET address, length, value[,step]

Why do I want this? In order to scroll I need to change every 3rd value in the DL with something like this:

pause 0 for i=DLscroll to DLscroll+51 step 3 poke i,y next

This is pretty slow and I actualy unroll the loop to get a bit of extra speed. If I could do this with the speed of MSET it would be way better, especially for 10 liners.

dmsc commented 4 years ago

Hi!

Would it be possible to add an optional 4th parameter to MSET in order to to set every other byte or every 3rd byte etc.?

No, sorry. Implementing an arbitrary step wold be very difficult without changing the whole code. Only way would be to add a new routine to do the "set with step".

Currently, MSET uses the same code used to clear variables and strings at startup, and to clear arrays on DIM, so it has to be fast.

Why do I want this? In order to scroll I need to change every 3rd value in the DL with something like this:

I understand, but a truly generic version would also need a step for the value to write - your example works because you are probably using 256 bytes for each line.

[about doing a FOR loop]

This is pretty slow and I actualy unroll the loop to get a bit of extra speed. If I could do this with the speed of MSET it would be way better, especially for 10 liners.

Perhaps one day FastBasic would be fast enough that this is not a problem :)

ukcroupier commented 4 years ago

Yeah, the scroll is with 256 bytes per line. No problem, in a full program I always have the option to do a VBI with a bit of assembler if I really need the speed - just thought it would be nice to do it via FB when I'm lazy or need to do a 10 liner.

The prospect of more speed is always nice to hear :)