Witajcie polish coders! Try using extended memory in this way...(special message to Coders of VENT and JOURNEY)

Let me give Tamas Bene of HARD the keyboard...

"...It depends on what we call "standard". My expansion is 130XE-compatible (without Antic-switching), so all programs which is written for XE should run as well on my Atari. Actually it is a 192K expansion, so the whole memory is 256K.
The problem is that demo-coders (and others) use $d301 in a non-standard way. I mean they change bits in $d301 which work differently on different expansions, or even they store values in $d301 other than $fc-$ff, instead of masking only those bits which are intended to be changed. (Fortunately the Atari OS was written much more carefully, they even use bit masking for setting values like $ff. Otherwise even the OS might not work with extended machines. :^)
For example, I found the following instructions in the Journey demo at several places:
lda #$b3 sta $d301
This has some meaning on a particular expansion, but I have no idea what it should do. For me, it just switches OS in and BASIC out.
BTW, my 192K expansion works as follows:
bits 0,1 and 7 work as for normal Atari (switching OS/Basic/Selftest). bit 4 switches the expansion on/off, just like for 130XE. here is a table for bits 2,3,5,6:

bit6 bit5 bit3 bit2    action
------------------------------
0    0    0    0       maps base memory $0000-$3fff to $4000-$7fff
0    0    0    1       maps base memory $4000-$7fff to $4000-$7fff
0    0    1    0       maps base memory $8000-$bfff to $4000-$7fff
0    0    1    1       maps base memory $c000-$ffff to $4000-$7fff
0    1    0    0       extended bank #01 at $4000-$7fff
0    1    0    1       extended bank #02 at $4000-$7fff
0    1    1    0       extended bank #03 at $4000-$7fff
0    1    1    1       extended bank #04 at $4000-$7fff
1    0    0    0       extended bank #05 at $4000-$7fff
1    0    0    1       extended bank #06 at $4000-$7fff
1    0    1    0       extended bank #07 at $4000-$7fff
1    0    1    1       extended bank #08 at $4000-$7fff
1    1    0    0       extended bank #09 at $4000-$7fff
1    1    0    1       extended bank #10 at $4000-$7fff
1    1    1    0       extended bank #11 at $4000-$7fff
1    1    1    1       extended bank #12 at $4000-$7fff
This expansion is quite a standard, it was published in the german Atari Magazin a couple of years ago. Also, it needs the simplest hardware among all the extensions I know of, so it's the cheapest one too. I'm sure a lot of people built it for this reason.

Most programs using extended memory do some sort of memory check (at least the self-respecting ones ;-) But they usually fail on my expansion because they detect expanded banks in the first 4 cases (bit5=bit6=0) even though in these cases the base memory is mapped to the bankswitched $4000-$7fff area. I wonder why they don't do a check for this case. It would be simple - just treat the 4 16K "banks" of the base memory in the same way as expanded banks, and check if writing to any bank causes any changes in any other bank. The check could look like this:
1. Set all possible values in bits 2,3,5,6, and store a different number for each of them at $4000. (numbers 1-16)
2. Store numbers 17-20 at addresses $0000, $4000, $8000, and $c000 in the base memory.
3. Set all possible values in bits 2,3,5,6 again, and check if the value stored at $4000 in each bank is still there, or it is overwritten. If overwritten with a different value, then it is not a real, separate bank, so remove from the list of available banks.
It's so simple.
An even simpler way would be to let the user configure the number of memory banks and the actual $d301 values he want to use. For example, the ramdisk in DOSes like TurboDOS and MyDOS work in that way. Other example is the excellent game The Brundles by KE-Soft.
/Tamas"

______________________________________
 /__  __   __  _\
/  / /_|_ |   |__\  Software, Hungary
______________________________________
Here is another Description by Dracon...
XL/XE RAM expansions

There are some types of RAM expansions designed for XL and XE 
computers. The most popular in Europe are based on the general 
concept used by the Atari Corp. in the 130XE computer: a port, 
formerly responsible for controlling joysticks #2 and #3, is now used 
as a memory controller port. This port is mapped at $D301 and 
traditionally labelled as PORTB.

The general purpose of the PORTB is to control all on-board memory 
resources, i.e. the system RAM as well as the OS and BASIC ROMs.

I. ROM controller

Bits #0, #1 and #7 control the system ROM. This function is common 
for all XL and XE computers:

Bit     Meaning (if set)
---     ----------------
#0      OS ROM enable
#1      Atari BASIC ROM disable
..
#7      SELF TEST ROM disable

Bit #0 changes affect the XL OS area at $C000-$CFFF and $D800-$FFFF, 
if the bit is set, there is the XL OS ROM there, otherwise the shadow 
RAM is enabled. NOTE: the PDVREG $D1FF has higher priority than PORTB!

Bit #1 affects the area $A000-$BFFF. If this bit is cleared, there's 
Atari BASIC ROM there, RAM otherwise.

Bit #7 affects the area $5000-$57FF. If it is cleared, the SELF TEST 
ROM, located normally at $D000-$D7FF and masked out by hardware I/O 
registers, is switched to $5000-$57FF; otherwise, there's normal RAM 
there.

II. RAM controller

1) Atari 130XE

Stock 800XL and 65XE computers lack additional RAM, so the remaining 
PORTB bits do nothing. 130XE however and expanded XL/XE use them to 
control RAM extensions.

Generally, considering the 16-bit address bus, it is impossible to 
enlarge the physical address space past the existing 64k. In the 
130XE, the total amount of system RAM is split into two large parts: 
64k base RAM and 64k bank select RAM. That last is accessible as four 
16k portions to be exchanged with a 16k block belonging to the base 
RAM area.

This area is located from $4000 up to $7FFF. Both 6502 and Antic are 
granted an *independent* access to this memory. PORTB bits meaning is 
as follows:

bits #2, #3 - bank select
bits #4, #5 - access control
bit #6 - unused

The first pair (bits 2 & 3) selects one of four additional 16k banks 
you want to access to. The other pair decides, which processor will 
use the bank selected by the first two bits:

#4 - CPU access:   0 - additional RAM
                   1 - base RAM
#5 - Antic access: 0 - additional RAM
                   1 - base RAM

This gives four possible combinations:

76543210
--------
xx00xxxx - both processors use the additional bank
xx01xxxx - only Antic uses the additional RAM
xx10xxxx - only CPU uses the additional bank
xx11xxxx - both processors use the base RAM

That's all for 130XE.

2) 192k RAM expansion

The computer's behaviour is exactly the same as in 130XE besides of 
that bit #6 is used together with the bits #2 and #3 to select an 
additional banks. This gives eight combinations, i.e. eight banks may 
be accessed, 16k each.

3) 320k Compy Shop expansion

Also known as "German 320k". This type of RAM extension is quite 
popular in Europe, so that several American programs get confused 
considering this to be 192k.

Since all free bits have been used for bank selection, the Compy Shop 
expansion uses bit #7 for bank selection. This gives 16 possible 
combinations, hence the additional RAM area can be enlarged to 256k 
(256 + 64 = 320).

To get rid of possible conflicts with the SELF TEST ROM (normally 
controlled by the bit #7), this bit is used to control SELF TEST only 
when bits #4 & #5 are both set to 1. Otherwise it controls the bank 
select RAM.

4) 256k Newell Industries expansion

This expansion is NOT fully 130XE compatible. It is similar to the 
192k with except that the bit #5 is used for bank selection, not for 
Antic access control. It means, that you have four bits for bank 
selection, but both CPU and Antic must use the same memory at a time. 
Furthermore, only 12 of 16 possible combinations are used so that you 
have 192k additional RAM instead of 256k. This is the most stupid 
expansion I have ever seen (my computer has it installed).

4) 320k Newell Industries expansion

Also known as "American 320k". This expansion is NOT fully compatible 
with the 130XE standard, but it was apparently quite popular in the 
USA since some software (f.e. ICD's SpartaDOS X 4.x) seems to base on 
it. Nevertheless, some software, like "Envision" for example, may 
fail on such computers.

Only bit #4 is used to control the memory access here, which implies 
that there's no separated access for the CPU and Antic. In fact, both 
processors must use the same type of RAM at the same time; if bit #4 
is set, CPU and Antic use the base RAM, otherwise both use additional 
bank.

Bits #2, #3, #5 and #6 are used for bank selection.

5) 576k expansion.

This is similar to the American 320k with except that bit #7 is used 
the same way as in Compy Shop 320k expansion. So bits #2, #3, #5, #6 
and #7 are used for bank selection if the bit #4 is set to zero 
(CPU & Antic additional RAM access). This expansion is not fully 
compatible with the 130XE.

6) 1 MB (1088k) expansion.

The same as 576k with except that the bit #1 (normally controlling 
Atari BASIC ROM) is used for bank selection if bit #4 is set to zero. 
This gives six bits (64 banks, 16k each) for bank selection, so that 
the additional bank area may be enlarged to 1024k. This type of 
expansion isn't fully 130XE compatible either.

III. RAM detection routine

Since it is quite difficult to determine what expansion a particular 
computer has and what amount of memory is currently available, the 
most simple solution is to use the following routine. It is a 
non-destructive test, any data previously stored in the additional 
RAM will remain intact.

The routine returns the number of found additional RAM in the 
accumulator. You must multiply it by 16 then add 64 to get the total 
amount of the system RAM in kilobytes as a result.

; Bank select RAM detection
; Stolen from the SysInfo
;
; Must NOT be located within the $4000-$7FFF !!!
;
portb   =       $d301
extra   =       $4000
;
        lda portb
        pha
        lda #$00
        sta counter
        ldx #$7f        ;Save the ramdisk contents before the test
loop1   txa
        asl
        ora #$01
        sta portb
        lda extra
        sta buffer,x
        dex
        bpl loop1
        ldx #$7f        ;Clear tested RAM.
loop2   txa
        asl
        ora #$01
        sta portb
        lda #$00
        sta extra
        dex
        bpl loop2
        lda #$ff        ;Reset PORTB
        sta portb
        lda #'K         ;Mark base RAM as tested.
        sta extra
        ldx #$7f        ;Count banks.
loop3   txa
        asl
        ora #$01
        sta portb
        lda extra
        bne skip
        inc counter
        lda #'K
        sta extra
skip    dex
        bpl loop3
        ldx #$7f        ;Restore the ramdisk contents
loop4   txa
        asl
        ora #$01
        sta portb
        lda buffer,x
        sta extra
        dex
        bpl loop4
        pla
        sta portb
        lda counter
        rts
;
counter .dc     0       ;number of banks
buffer  .ds     64      ;64-byte buffer
Konrad M.Kokoszkiewicz mail:draco@mi.com.pl http://www.orient.uw.edu.pl/~conradus/ IRC:[Draco] *** Ea natura multitudinis est, *** aut servit humiliter, aut superbe dominatur. ************************************************* *** U pospolstwa normalne jest, ze albo sluzy ono *** unizenie, albo bezczelnie sie panoszy. (Liv. XXIV, 25)

back to main-index


Last changes: 19 Jun 1997

Amiga_logo

Feel free to contact me for any legal reason!
email_icon HeAvEn, Member of TaquarT