Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
128k memory: saving and restoring data
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:

end asm

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

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.
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>

#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
Thanks! I'll give it a try Big Grin
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?


Forum Jump:

Users browsing this thread: 1 Guest(s)