The actual truth is somewhat in-between!
8 bit processorThe 6502 processor, like many other 8 bit processors, is only able to address a 16 bit address range, from $0000 (0) to $FFFF (65535).
In this address range we must be able to fit the zero page, the I/O area to talk with hardware expansion, the video memory, and the system ROM.
Many machines are using some more or less complicated "banking" systems allowing you to select what will be accessible in some particular areas of the addressing range, which makes it possible to provide more RAM or ROM by dynamically enabling or disabling parts of the system so other can be used.
Some, like the C64 even include this feature on the processor itself1
The Oric Telestrat uses a second VIA to perform the access to the two possible cartridge ports, but I will not speak more about this machine specific set of features.
Atmos 48K or 64K?So, to go back to the previous question, the answer is that the Oric Atmos 48K does have 64K of RAM, unfortunately since the machine was built using as few as possible components2, the top 16K of memory are not accessible at all because they are hidden behind the 16KB of ROM containing the Oric BASIC.
So yes, it's an Atmos 64K, but consumer associations would probably have contested the claim in a court of law, so there you go.
Now, the good thing is that it is possible to use these additional 16KB of RAM, at the condition that you use a floppy disk controller.
Oric Disk ControllerWhen you connect an Oric floppy disk unit (Microdisc or Jasmin will both work fine), the controller board brings the missing part of the puzzle in the form of additional hardware registers you can access in page 3.
A part of these registers are used to talk to the Western Digital Floppy Disk Controller chip, but also to select what you will see when you try to access the top 16K of RAM.
On the Microdisc, the location $314 points to a 8bit register which contains two interesting bits for us:
- Bit 1: Disables the internal BASIC ROM when set to zero
- Bit 7: Disables the disk controller boot EPROM
What that means in practice, is that if you are making a small single file Oric game or demo, if you are running out of memory you can just very simply use Tap2DSK to make a Floppy version of your demo, and with these two lines of codes you can get the additional memory!
The Jasmin disk drive controller has something similar, except is uses two different registers:
- Bit 0 of location $3FA: Enables the Overlay RAM when set to one
- Bit 0 of location $3FB: Disables the internal BASIC ROM when set to one
The Disk controller maps its own Eprom that contains the bootstrap code.
Before you jump with your two feet forward and try to take this RAM all for you, you need to consider the negative consequences!
NegativesObviously, if you disable the ROM, it means you don't have access to the ROM functions, which probably means that many of the OSDK functions that were just simple mappings to the Oric Atmos Rom will stop working: paper, ink, hires, text, key, get, printf, curset, draw, fill, sound, play, music, etc... are all ROM functions, so these will stop working.
Another important parameter is that you will have to implement your own IRQ handler, because the normal Oric IRQ that handles keyboard, timers, and your own callback in page 2 will not happen, and most probably the machine will crash as soon as it tries to perform an IRQ!
PositivesAmong the positive things, we can find the following:
- Pretty much all the top 16K of RAM are free for you to use!
- The Page 2 is free for you to use as well!
- As is the entire zero page!
- And the Page 4 is free as well
- Much faster IRQ!
Implementation ExampleHere is a simple example that just enables the overlay RAM on a Microdisc based system, that setups a 50HZ IRQ handler that reads the arrow keys and the space bar:
and a small C code to go with that:
_gKey .dsb 1
_VblCounter .dsb 1
save_a .dsb 1
save_x .dsb 1
save_y .dsb 1
; Stop the IRQ while we are setting up stuff
; Enable overlay RAM
; Reset the VBL counter
; Set the VIA parameters for a 50Hz IRQ
; Our new IRQ handler
; Enable the IRQ again and quit
; Mark the IRQ as served
; For the "VSync" delay
; Save the registers
; Read the first row of the keyboard
; Restore the registers
; Return from IRQ
and a final trick for you: The reason the printf command does not work, is because it calls the Text display code in the ROM, but you can still display text by using sprintf instead.
extern unsigned char gKey;
if (gKey & 1) // LEFT
if (gKey & 2) // RIGHT
if (gKey & 4) // UP
if (gKey & 8) // DOWN
while (!(gKey & 16)); // SPACE
Just use (char*)0xBB80+X+Y*40 as the destination buffer address, and the string formating will properly appear on the screen!