Date : Wed, 16 Nov 2005 14:24:25 +0000
From : Richard Gellman <splodge@...>
Subject: Re:: Master Shadow RAM access?
I thought I'd do a second reply to this, more on the unlying principles
than the machine code to do what you need.
>I guess I am basically asking Is there a direct way of access the
SHADOW RAM without paging the RAM into Main Memory? I just cannot see a way.
That is correct. The Master's Shadow RAM physically occupies locations
&3000-&7FFF, overlaying the normal system RAM. Thus the only way it can
be accessed is by paging it in so that it appears in the 6502's memory
space.
There are 3 bits in ACCCON (&FE34) that govern this (from memory, called
E X and Y - I may be wrong, as may be the usage of such terms in the
following paragraph).
X controls which block is paged into memory on a "permanent" basis. That
is, when E is set, the shadow RAM *always* replaces the main memory.
Y controls VDU driver access to the shadow RAM. When Y is set, the
shadow RAM replaces the main memory *only* when the instructed being
executed is in the VDU driver space (&C000-&DFFF I think).
X overrides Y, so if both are set, the shadow RAM is always paged in.
E controls the CRTC/VIDPROC access to shadow RAM. When E is set, the
Shadow RAM will be displayed. When E is clear, the main RAM will be
displayed. Note that E is independent of X & Y, so you can configure
ACCCON to *display* shadow RAM, but have the CPU access *main* memory.
In order to modify the machine code I gave earlier to auto-detect which
bank is in use, take a look at OSBYTE 112 & 113. These set (and get)
which bank will be used for display and VDU access purposes. You can
then transfer this to a call to OSBYTE 108 to select the appropriate
bank for CPU access.
Be aware that when you "page in" the Shadow RAM/Main RAM, you don't lose
the contents of the other bank, you simply change which bank memory
access goes to. In electronic terms, it changes which RAM chips get the
access enable line.
The code I gave in a previous email will not be "page out" when the
Shadow RAM comes in, as it is outside of the shadow RAM memory range.
Addresses 0 - &2FFF only ever go to the main RAM.
The paging in/out of shadow RAM is analogous to the paged in of 2 paged
ROMs/sideways RAM banks.
Hope this helps with your coding :)
-- Richard
Peter Craven wrote:
> Richard
>
> I'm looking at making a M/Code program (that saves screen memory to
> sideway RAM) located underneath any BASIC program. The M/Code program
> would cater for the possibility that the BASIC program is using SHADOW
> mode and the BASIC program extends beyond &3000.
>
> So when the BASIC program calls the M/Code program, I want the code to
> save the screen memory to sideways RAM, but not lose the BASIC program.
>
> I guess I am basically asking Is there a direct way of access the
> SHADOW RAM without paging the RAM into Main Memory? I just cannot see
> a way. Considered using unknown plot commands, but I think this does
> page the SHADOW RAM in anyway??
>
> Cheers
>
> Pete