I am writing some memory management functions for CPC, and typically I
have been swapping 16k blocks in and out of #4000. The memory ports
etc I use are as follows:
;memory bank table for selection/deselection
;format - dw deselectport, startaddress, size, selectport
;34 banks defined below
MemoryBankData:
dw #7fc0, #2000, #6000, #7fc0
MemoryBankDataEntry2:
dw #7fc0, #4000, #4000, #7fc4
dw #7fc0, #4000, #4000, #7fc5
dw #7fc0, #4000, #4000, #7fc6
dw #7fc0, #4000, #4000, #7fc7
dw #7fc0, #4000, #4000, #7fcc
dw #7fc0, #4000, #4000, #7fcd
dw #7fc0, #4000, #4000, #7fce
dw #7fc0, #4000, #4000, #7fcf
dw #7fc0, #4000, #4000, #7fd4
dw #7fc0, #4000, #4000, #7fd5
dw #7fc0, #4000, #4000, #7fd6
dw #7fc0, #4000, #4000, #7fd7
dw #7fc0, #4000, #4000, #7fdc
dw #7fc0, #4000, #4000, #7fdd
dw #7fc0, #4000, #4000, #7fde
dw #7fc0, #4000, #4000, #7fdf
dw #7fc0, #4000, #4000, #7fe4
dw #7fc0, #4000, #4000, #7fe5
dw #7fc0, #4000, #4000, #7fe6
dw #7fc0, #4000, #4000, #7fe7
dw #7fc0, #4000, #4000, #7fec
dw #7fc0, #4000, #4000, #7fed
dw #7fc0, #4000, #4000, #7fee
dw #7fc0, #4000, #4000, #7fef
dw #7fc0, #4000, #4000, #7ff4
dw #7fc0, #4000, #4000, #7ff5
dw #7fc0, #4000, #4000, #7ff6
dw #7fc0, #4000, #4000, #7ff7
dw #7fc0, #4000, #4000, #7ffc
dw #7fc0, #4000, #4000, #7ffd
dw #7fc0, #4000, #4000, #7ffe
dw #7fc0, #4000, #4000, #7fff
dw #feea, #2000, #2000, #fee8 ;for multiface
of course you could argue that it's ineficient to deselect the ports
for dktronic RAM since it isn't explicitly needed, however my routines
are more generic and work fine with multiface too (seems ok, but can't
seem to view the RAM of multiface without block copying it out of it
within WinAPE).
There are other memory configurations than swapping 16k blocks out of
#4000, what are they? What are the ports and how is the memory
arranged?
thanks. Julian
ps, what other memory expansions are available and what are their
ports/mapping addresses and do any emulators emulate them for me to
test?
http://www.kjthacker.f2s.com/docs/mem.html
http://www.kjthacker.f2s.com/docs/rampage.html
This is for CPC 6128/DkTronics. Others expansions such as the Symbiface,
the Memcard, or the Yarek ram expansion are compatible but adds extra
"superbanks", wich are selected with other ports. So you can use each
superbank as a 512k DkTronics expansion, and select wich one you want to
use.
http://www.kjthacker.f2s.com/docs/sp512.html
This one is the SP512 from Vortex, only for CPC 464
thanks. with the superbanks for symbiface, does that mean to select a
bank, there is 2 port process, first to select which group of 512, then
to select which part of the 512?
Yes, I think it works like that.
looking at the SP512 docs, am I wrong in thinking that only entire 64kb
or alternatively 32kb blocks (upper & lower of each of the 8 64kb
blocks) must be paged into cpc address space at at time? that would
make it a real bugger trying to make software use it without having to
copy stuff through buffers in cpc's own ram all the time...
anyone got the ports/specs for using the symbiface additional ram? so I
can rework my memory functions... thanks.
looking here http://www.kjthacker.f2s.com/docs/rampage.html
at Configuration "2", we have all the 2nd bank of 64k mapped in, video
ram is still read from cpc's ram which is good. Configuration "3" is
needed to have a common block of ram to be able to store routines that
the program running in 2nd 64k can access the screen memory right?,
but... if a program is >64kb (ie: broken into chunks) then there is no
common bank across all maps unless we only use configurations 4,5,6,7
which is what I'm doing now (ie: the commonly accessible memory from
anywhere is the cpc's main memory below #4000 and above #7fff.
is there any advantages in using Configuration 2/3 other than something
like CP/M Plus (I suspect that's what it's using to give a 61k TPA)?
the SYMBiFACE II includes a standard 512KB ram expansion, which is
compatible to the CPC6128/dk'tronics/dobbertin standard.
OUT #7F00,0x11bbbmmm
bbb can be 0-7 and specifies the 64K bank number (8 banks * 64K =
512K)
mmm ist the banking-mode:
000=reset banking, you will see the full primary 64K
001=switch block 3 of bank bbb to #c000
010=show entire 64K of bank bbb
011=switch block 3 of bank bbb to #c000, and switch block 3 of the
primary bank to block 1 (#4000)
1xx=switch block xx of bank bbb to #4000
Jarek extended this bankswitching methode by using three bits of the
port address (high byte) to extend the amount of bank:
OUT 0x01111bbb,0x11bbbmmm
so you have 6 bits for the bank, which means, you can address
additional 4MB instead of 512KB.
http://8bit.yarek.pl/upgrade/cpc.cpc4mb/index.html
The Jarek 4MB expansion is emulated in WinApe and CPCE. SymbOS
supports the first 1MB.
The Vortex expansion was a very exotic one and not used very often.
CU,
Prodatron
There is no additional ram in the SYMBiFACE.
For read/write-accessing the SF2-ROM have a look here:
http://www.cpcwiki.com/index.php/SYMBiFACE_II:Rewriteable_roms
> is there any advantages in using Configuration 2/3 other than something
> like CP/M Plus
In SymbOS I use config 1,2 and 4-7. Applications are all stored in the
secondary 64K banks, while most parts of the OS is placed in the
primary 64K.
- Config 4-7 is used by the OS to access parts of the secondary 64K
banks.
- Config 2 is used while executing an application. So every
application can have up to 64K memory in one piece.
- Config 1 is used by an OS part, which is placed between #4000 and
#7fff, so it can't use 4-7. This part can only access block 3
("transfer area") of a secondary 64K bank. Config 1 is also used when
switching back from Config 2 to the OS (to pass variables via block 3
of the secondary bank).
CU,
Prodatron
thanks
I've been making my code as portable as possible. just curious, how
different was the memory management between the MSX and CPC versions of
Symbos? Can the MSX swap in parts of memory like Config 4-7 and does it
have something like Config 1-2 or did you have to come up with a totally
new scheme?
I'm trying to make my kernel as generic as possible, of course it'll
need customisation for each platform, but to make it so very little
needs changing - so far just the memory bank selection is hardware
dependant - the actually malloc/free is neutral. Apps will relocate
anywhere upon loading, and the OS can sit anywhere. IY contains the
entry point to the OS, so to call my OS functions from an app is
something like:
AppStart: ld c,OSVersionGet
call AppOSEntry
...
;this AppOSEntry would exist once within every App
AppOSEntry: push iy
ret
I think I had sent you a while ago some untested (not-working really
buggy) code. Anyway, now it's almost all tested what I have done so
far... and working of course - so I will soldier on - my code will be
publicly available eventually.
Thanks.
The MSX and the PCW both have a more flexible bank switching: The
visible 64K Ram is divided into 4 x 16K blocks, and all of them can be
swapped. So you have 4 registers, and each selects one block out of
128 (PCW -> 2MB) or 256 (MSX -> 4MB). It's also the same for the
Enterprise and the PCW16.
(The MSX even has additional slots (4x) and subslots (4x), so you
could have a theoretical maximum memory size of 64MB :-D)
The Sam Coupe has 2 banking registers, one for selecting a 32K block
at #0000-#7ffff and one for selecting a 32K block at #8000-#ffff
(similiar to the Vortex memory expansion for the CPC, but the Sam can
select the blocks in 16K steps).
There are also memory expansions for the ZX Spectrum, but these can
only swap a 16K block to #0000-#3fff (unfortunately this limitation
makes it impossible to port SymbOS to the Spectrum).
Hope this information helps!
> I'm trying to make my kernel as generic as possible
> [...]
> I think I had sent you a while ago some untested (not-working really
> buggy) code. Anyway, now it's almost all tested what I have done so
> far... and working of course - so I will soldier on - my code will be
> publicly available eventually.
Yeah, now I remember!!! It's years ago! I still have your code and the
HTML files :-) [but not the emails from these days anymore]. Your OS
is called "Kernel Z" and I am looking forward to it! :-)
I just wonder, why you still keep the CPC-OS alive while running your
kernel? (the #38 stuff)
CU,
Prodatron
> is there any advantages in using Configuration 2/3 other than something
> like CP/M Plus (I suspect that's what it's using to give a 61k TPA)?
They're handy if you're targetting a CPC+ and need to copy data out of
banked RAM into the ASIC (since that pages in at 0x4000).
AndyC
I've used modes 2 and 3 in my Virtual Processor program (single-stepper and
debugger). Mode 1 is virtually useless in CPC mode, that's the main CP/M+
mode.
--
ξ:) Proud to be curly
Interchange the alphabetic letter groups to reply