![]() |
DEFADD trick with ZX BASIC compiler? - Printable Version +- Forum (https://www.boriel.com/forum) +-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12) +--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11) +---- Forum: Help & Support (https://www.boriel.com/forum/forumdisplay.php?fid=16) +---- Thread: DEFADD trick with ZX BASIC compiler? (/showthread.php?tid=1439) |
DEFADD trick with ZX BASIC compiler? - maeloterkim - 09-22-2021 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 ... The trick is that in BASIC we can change the DEFADD address and put any thing for example we can do CHANGED_DEFADD_POINTER_ADDRESS ;;'' CHANGED defadd initial definitions of variables A$ begins on 16384 and have 256 bytes of size B$ begins on 32000 and have 256 bytes of size etc ... This way we can do A$ = B$ and copy 256 very fast to the screen !!! this is better explained here in spanish https://blog.jafma.net/2020/03/16/efficient-basic-coding-for-the-zx-spectrum-iv/#sp_5 and here in english https://blog.jafma.net/2020/03/16/efficient-basic-coding-for-the-zx-spectrum-iv/#en_5 and here a video in spanish explaining this trick https://www.youtube.com/watch?v=VKJ2dePykdA 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 RE: DEFADD trick with ZX BASIC compiler? - boriel - 09-23-2021 (09-22-2021, 07:45 PM)maeloterkim Wrote: Hi You don't need this in ZX Basic. Use memcopy: Code: #include <memcopy.bas> The above code copies from 32768 (source) to 16784 (dest) 256 bytes. ![]() 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. |