CPCWiki forum

General Category => Programming => Topic started by: VincentGR on 17:14, 13 July 20

Title: Access second RAM bank though Basic
Post by: VincentGR on 17:14, 13 July 20
Hello everybody.


A friend made an excel clone on CPC's basic.
The prog runs fine but the memory is not enough.
He hasn't figured out how to access the rest 64K to create a table.


Thanks in advance.
Title: Re: Access second RAM bank though Basic
Post by: fgbrain on 18:22, 13 July 20
Not possible with Basic I am afraid...


You can access extra memory with OUT command but you cannot use it with Basic...
Title: Re: Access second RAM bank though Basic
Post by: andycadley on 19:15, 13 July 20
You could use the bankman rsx to access the extra memory from basic to some extent, but it's not necessarily suitable for all uses and obviously prevents your program from running on a 64K machine
Title: Re: Access second RAM bank though Basic
Post by: AMSDOS on 08:38, 15 July 20
Not sure this is what @VincentGR (https://www.cpcwiki.eu/forum/index.php?action=profile;u=1053) friend had in mind, which is storing a string to the 2nd RAM Bank by using POKE, ASC and MID$, the trouble is Excel Spreadsheets can have cells which carry Strings upto any number of characters, just like an BASIC String Array, but in order to store it in Memory, the full String needs to be extracted, just like my example.
After <any key> has been pressed, the code proceeds to the retrival and a WHILE loop is used to put the string back together.



100 a$="Hello 128k Memory From BASIC!"
110 CALL &BC02:OUT &7F00,&C4
120 FOR p=1 TO LEN(a$)
130   POKE &3FFF+p,ASC(MID$(a$,p,1))
140 NEXT p
150 OUT &7F00,&C0
160 a$="":INK 0,3:INK 1,26:BORDER 3:CALL &BB18
170 OUT &7F00,&C4
180 addr=&4000
190 WHILE PEEK(&4000+s)<>0
200   a$=a$+CHR$(PEEK(&4000+s)):s=s+1
210 WEND
220 OUT &7F00,&C0
230 PRINT a$
240 END
Title: Re: Access second RAM bank though Basic
Post by: roudoudou on 09:24, 15 July 20
Quote from: VincentGR on 17:14, 13 July 20
Hello everybody.


A friend made an excel clone on CPC's basic.
The prog runs fine but the memory is not enough.
He hasn't figured out how to access the rest 64K to create a table.


Thanks in advance.
If your basic programm is less than 16K you can switch upper bank in #4000-#7FFF zone
First protect the memory at #4000 and above => MEMORY &3FFF

Then you can use OUT to switch

out &7F00,&C4 : REM switch bank 4
out &7F00,&C5 : REM switch bank 5
out &7F00,&C6 : REM switch bank 6
out &7F00,&C7 : REM switch bank 7
out &7F00,&C0 : REM default configuration (bank 1)
see cpcwiki gate array bank switching for other configurations (not all possible in basic)
Then you can use PEEK and POKE to access the area
Title: Re: Access second RAM bank though Basic
Post by: VincentGR on 11:11, 15 July 20
Thank you very much all of you, I will try to translate your precious suggestions.
Title: Re: Access second RAM bank though Basic
Post by: ukmarkh on 14:22, 11 August 21
Quote from: andycadley on 19:15, 13 July 20
You could use the bankman rsx to access the extra memory from basic to some extent, but it's not necessarily suitable for all uses and obviously prevents your program from running on a 64K machine


Apologies for dragging this back up, but how can I access bankman?
Title: Re: Access second RAM bank though Basic
Post by: andycadley on 14:43, 11 August 21
Quote from: ukmarkh on 14:22, 11 August 21

Apologies for dragging this back up, but how can I access bankman?
There were a bunch of RSXs on one of the system disks with the 6128, I'd assume a copy is floating around on the internet somewhere if you don't have that any more.
Title: Re: Access second RAM bank though Basic
Post by: eto on 16:58, 11 August 21
Quote from: ukmarkh on 14:22, 11 August 21Apologies for dragging this back up, but how can I access bankman?

It's on the 6128 system disks: http://www.cpcwiki.eu/index.php/System_Disk (http://www.cpcwiki.eu/index.php/System_Disk)

For a description see chapter 1, page 84 of the 6128 manual:
http://www.cpcwiki.eu/manuals/AmstradCPC6128-hypertext-en-Sinewalker.pdf (http://www.cpcwiki.eu/manuals/AmstradCPC6128-hypertext-en-Sinewalker.pdf)
Title: Re: Access second RAM bank though Basic
Post by: Longshot on 19:18, 01 September 21
Hi.
You can also use the RSX MPACK set( https://cpcrulez.fr/applications_util-MPACK.htm (https://cpcrulez.fr/applications_util-MPACK.htm) )
You can save a basic program in the ram with MBSAVE and run it with MBRUN (there are other instructions like MLDIR, MSAVE, MLOAD, ...).
If your program is more than 16k, you can modify the code given by AMSDOS using MPACK.
You must remove the OUT &7F00,xx (line 110, 140, 170, 220) and replace the POKE by MPOKE,p,ASC(MID$(a$,p,1)) , line 180 addr=0, and PEEK by MPEEK, addr.(The address in MPACK is an address between 0 and 65535 to access the 64k)
Powered by SMFPacks Menu Editor Mod