Skip to content
Phosphoricwiki
Contents

The emulated Oric

Before seeing how Phosphoric emulates the Oric, let us see what it emulates: four main chips on a bus, 64 KB of addresses, and a very particular way of putting colour on the screen.

On this page

Two models, one board

Phosphoric emulates both Tangerine machines:

Oric-1 (1983)Oric Atmos (1984)
ROMBASIC 1.0 (basic10.rom)BASIC 1.1 (basic11b.rom)
RESET vector$EA59$ECCC
At start-up47870 BYTES FREE37631 BYTES FREE
Choicedetected from the ROM, or -m oric1 / -m atmos

Both ROMs are 16 KB. Phosphoric recognises the version from the loaded ROM and adapts its ROM patches (fast tape loading, notably) to each one.

Oric-1 start-up screen: ORIC EXTENDED BASIC V1.0, © 1983 TANGERINE, 47870 BYTES FREE, Ready
The Oric-1 at start-up, BASIC 1.0 ROM. Compare with the Atmos one.

The chips

The machine Phosphoric emulates, and what surrounds itA MOS 6502 processor at 1 MHz and 64 KB of memory (48 KB of RAM, 16 KB of BASIC ROM) share a bus. On this bus: the VIA 6522 (keyboard, tape, printer, interrupts), the ULA (the picture), the AY-3-8912 PSG (sound, and part of the keyboard) and page 3, where expansion cards plug in. On the right, the host: SDL2 window, browser, or no display. At the bottom, the master clock moves the whole machine one cycle at a time.6502MOS 6502 NMOS · 1 MHz64 KB memory48 KB RAM · 16 KB ROMaddress and data busVIA 6522ports and timerskeyboard (8 × 8 matrix)tape, printerinterruptsULAHCS 10017 · the picture40 × 28 text240 × 200 HIRES8 colours, PALPSGAY-3-8912 · sound3 voices and noise16 envelopesport A: keyboardPage 3$0300-$03FFMicrodisc, Jasmin, LOCIACIA, DTL 2000, MIDIspeech, ULA-NGHostSDL2: picture, sound,keyboard, gamepadWebAssemblyno displayscreenshots, AVI, WAVHTTP API, --controlGDB serverMaster clock: emu_cycle() moves the whole machine one cycle (CPU, then φ2, then ULA)
The 6502 and the memory on a bus, with the VIA, the ULA, the PSG and page 3 for cards.
  • The processor, an NMOS 6502 at 1 MHz. It makes one bus access per cycle. Its NMOS version has quirks that Phosphoric reproduces: dummy accesses (reads or writes with no apparent purpose, in the middle of some instructions), 105 “illegal” opcodes on top of the 151 official ones, and a decimal mode.
  • The ULA (HCS 10017) makes the picture. It shares memory with the processor: within each microsecond, the 6502 accesses first, then the ULA reads a screen byte. So there is never a conflict, nor a stolen cycle.
  • The VIA 6522 has two 8-bit ports and two timers. It selects the keyboard column, receives the tape signal, drives the printer, and raises the system’s interrupts.
  • The AY-3-8912 PSG makes the sound: three square-wave voices, a noise generator, sixteen envelope shapes. Its port A also serves the keyboard and the IJK joystick.

The memory

The Oric's memory, from $0000 to $FFFFFrom bottom to top: zero page, stack and system variables ($0000-$02FF); page 3, reserved for input and output ($0300-$03FF, the VIA at $0300); free RAM for programs; the HIRES mode character sets ($9800); the video area ($A000-$BFFF: HIRES screen at $A000, text mode character sets at $B400 and $B800, 40 × 28 text screen at $BB80); the 16 KB BASIC ROM ($C000-$FFFF). With the Microdisc, this ROM gives way to RAM and to the controller's ROM at $E000. Not to scale.Memory map (not to scale)$C000-$FFFFBASIC ROM 1.0 or 1.116 KBMicrodisc: RAM at $C000, controller ROM at $E000$A000-$BFFFvideo areaHIRES screen or text screentext: characters at $B400 and $B800, 40 × 28 screen at $BB80HIRES: 8,000 bytes at $A000, 40 bytes per line$9800-$9FFFcharacter setsfor HIRES modeHIRES: characters at $9800 and $9C00$0400-$97FFfree RAMBASIC programs and machine code$0300-$03FFpage 3: input and outputreading page 3 queries a chip, not RAM$0000-$02FFzero page, stack, system
The Oric’s memory map. Page 3 is not RAM: reading it queries a chip.

A few addresses come up again and again:

AddressContents
$0300-$03FFpage 3: input and output. The VIA at $0300, expansion cards above it.
$A000-$BF3Fthe HIRES screen: 200 lines of 40 bytes.
$B400 and $B800the text mode character sets (standard and alternate).
$BB80-$BFDFthe text screen: 28 rows of 40 characters.
$C000-$FFFFthe BASIC ROM, or, with the Microdisc, RAM and the controller’s ROM at $E000.

In HIRES mode, the character sets move to $9800 and $9C00, since the graphics screen takes their place.

Colour through serial attributes

The ULA has no colour memory. Colour is set in the screen itself: a byte whose bits 5 and 6 are zero is not a character but an attribute, which changes the state of the rest of the line:

ValueEffect
0 to 7ink colour (INK)
8 to 15text style: alternate set, double height, blinking
16 to 23background colour (PAPER)
24 to 31video mode: text or HIRES, 50 or 60 Hz

An attribute takes its place on screen: it shows as a cell in the background colour. Bit 7 of a byte inverts its cell. Each line starts again in white ink on black paper, then the ROM puts its own attributes at the start of the line. That is why the Atmos start-up screen is black on white.

The keyboard

The keyboard is a matrix of 8 columns by 8 rows. The VIA chooses a column (bits 0 to 2 of its port B, through a 74LS138 decoder), the PSG chooses the rows to test (its register 14), and bit 3 of the VIA’s port B tells whether a key is down. The ROM scans the whole keyboard this way, column by column.

Phosphoric reproduces this matrix, offers QWERTY and AZERTY layouts, and synchronises its automatic typing (--type-keys) with this scan: no key is lost, even when a program reads the keyboard slowly.

The picture, in numbers

MeasureValue
Text40 columns × 28 rows, 6 × 8 pixel characters
HIRES240 × 200 pixels, then 3 rows of text
Colours8 (black, red, green, yellow, blue, magenta, cyan, white)
Line64 cycles, 40 of them visible cells
Frame312 PAL lines, 224 visible, 50 per second

The details of the scan are in The picture and the ULA.

Sources in the repository : README.md, docs/COMPATIBILITY.md, docs/architecture/master-clock.md, docs/ula-ng/ULA-NG-SPEC.md.