Forum
128k memory: saving and restoring data - 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: 128k memory: saving and restoring data (/showthread.php?tid=867)



128k memory: saving and restoring data - oblo - 12-04-2018

Hi all

I'm trying to program a game for the +2A/+2B/+3, so I can use more RAM. Thanks to a lot of info I found on the forums, I manage to access all memory banks with this:

Code:
asm
  di
end asm

poke 23388,16 + bank_number : OUT 32765,16 + bank_number

asm
  ei
end asm

Question is, I don't know how to efectively save and retrieve data in the 45152-65535 address range. I prepared some programs just with data arrays, saved with something like SAVE "databank6" CODE 49151,16384 and then load it from the main program but no data is restored, so I assume I'm doing it wrong and saving no data at all.

How can it be achieved? Thanks in advance an regards.


Re: 128k memory: saving and restoring data - boriel - 12-04-2018

ZX Basic is not currently prepared for bank switching. Despite that, some people have workarounded it. Basically, the switching code must be below that address you mention. The SAVE! and related instructions are not implemented. But you could read and transfer bytes from there using memcopy or memmove() functions, available in #include <memcopy.bas>

Code:
#include <memcopy.bas>

DIM myArray(255) as Ubyte
Const mygraphicsTable = 51000

MemCopy(mygraphicsTable, @myArray(0), 256) : REM Copies 256 bytes from myGraphicsTable Address into myArray



Re: 128k memory: saving and restoring data - oblo - 12-04-2018

Thanks! I'll give it a try Big Grin


Re: 128k memory: saving and restoring data - Joflof - 03-26-2019

Hi Oblo! Did you manage to find a way to do what you were aiming for?

I am trying to code a program which first, loads 64k of data on the four extra banks (16k ech) and finally executes itself, switching to the appropiate bank each time it needs to access data.

I don't know if you were trying to do something similar. If so, can you share your findings?

Also, in your asm code, what di the "di" and "ei" asm commands do? Is that related to the stack?

And finally, I read that there is a difference in bank numbering between 128 and +2A/B/3. Does it affect the data loading or it is only a matter of the contained memory being in diffrrent banks?

Thanks!