Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DEFADD trick with ZX BASIC compiler?
#2
(09-22-2021, 07:45 PM)maeloterkim Wrote: Hi

In the normal basic of zx spectrum 48k there is a behaviour or trick like this

you can change the address of DEFADD variable

and after this you can copy bytes very fast  Is like an assembler LDIR

I will explain more

you can have 2 variables A$ and B$  for example

every one of this variables can have 1000 bytes

when you do A$ = B$  the 1000 bytes of B$ are copied on A$

Normally DEFADD points to the beginning of the variables definitions

for example  (invented numbers)

DEFADD_POINTER_ADDRESS    ;;'' defadd initial definitions of variables
A$ begins on 30000 and have 1000 bytes of size
B$ begins on 32000 and have 1000 bytes of size
etc ...

[...]

I tried this trick with compiled zx basic but is not working because seems
that string variables are not doing the same behavior that original ROM

You don't need this in ZX Basic. Use memcopy:
Code:
#include <memcopy.bas>

memcopy(32768, 16784, 256)

The above code copies from 32768 (source) to 16784 (dest) 256 bytes. Cool 
Hope this helps!

EDIT: I'm documenting the standard library bundled with ZX Basic, as it includes many things, like scroll, sprites (faster than print), etc. etc.
Reply


Messages In This Thread
RE: DEFADD trick with ZX BASIC compiler? - by boriel - 09-23-2021, 07:15 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)