0
Bookmarks:

Regs

System

Flags

Stack

Bookmarks:
No breakpoints
No labels
POKE:
Auto-Map:
XRefs:
Text:
Export: Stop:
Include:
Port I/O:
Port filter:
All ports (no filter)

                                
                            
Output
Press Assemble to compile
0000h: 8x8
ZX Spectrum Keyboard Layout

Keyboard Port (IN #xxFE)

Read keyboard half-rows via port #FE. High byte selects row(s). Bit = 0 when key pressed (active low).

High ByteBit 0Bit 1Bit 2Bit 3Bit 4
#FE (254)ShiftZXCV
#FD (253)ASDFG
#FB (251)QWERT
#F7 (247)12345
#EF (239)09876
#DF (223)POIUY
#BF (191)EnterLKJH
#7F (127)SpaceSymMNB

Bits 5-7 always return 1. Multiple rows can be scanned at once (AND high bytes together).

Kempston Joystick (IN #1F / #DF)

Read joystick state via port #1F (or #DF). Bit = 1 when pressed (active high โ€” opposite to keyboard!).

BitDirection/Button
0Right
1Left
2Down
3Up
4Fire
5-7Not used (typically 0)

Kempston Mouse

Mouse interface uses three ports:

PortFunctionNotes
#FBDFButtonsBit 0=Right, Bit 1=Left, Bit 2=Middle (active low: 0=pressed)
#FFDFX position0-255, wraps around
#FADFY position0-255, wraps around

Input State Summary

DevicePressed StateNot Pressed
Keyboard0 (active low)1
Kempston Joystick1 (active high)0
Kempston Mouse buttons0 (active low)1

Border/Attribute Colors

ValueColorBright
0BlackBlack
1BlueBright Blue
2RedBright Red
3MagentaBright Magenta
4GreenBright Green
5CyanBright Cyan
6YellowBright Yellow
7WhiteBright White

Border: bits 0-2 of port #FE. Attributes: INK (bits 0-2), PAPER (bits 3-5), BRIGHT (bit 6), FLASH (bit 7).

ULAplus (Extended Palette)

ULAplus extends the Spectrum to 64 simultaneous colors from a 256-color palette.

PortFunctionAccess
#BF3BRegister selectWrite only
#FF3BData portRead/Write

Register port (#BF3B) format:

BitsFunction
7-6Group: 00=Palette, 01=Mode
5-0Palette entry (0-63) when group=00

Palette data format (GRB):

BitsColorRange
7-5Green0-7
4-2Red0-7
1-0Blue0-3 (expanded to 0-7)

Blue expansion: 00โ†’000, 01โ†’011, 10โ†’101, 11โ†’111

Palette organization (4 CLUTs ร— 16 colors):

EntryCLUTTypeIndex
0-70INKAttr bits 0-2
8-150PAPERAttr bits 3-5
16-231INKBRIGHT=1
24-311PAPERBRIGHT=1
32-392INKFLASH=1
40-472PAPERFLASH=1
48-553INKFLASH=1, BRIGHT=1
56-633PAPERFLASH=1, BRIGHT=1

CLUT selection: (FLASH ร— 2 + BRIGHT). Border uses PAPER color from CLUT 0.

Mode register (group=01): Bit 0 = ULAplus on/off, Bit 1 = Grayscale mode.

Raster effects: HAM256 and similar demos that update palette mid-frame are fully supported. The emulator tracks palette writes with T-state timing and applies them per 16-line group.

AY-3-8910 Sound Chip (128K)

The AY sound chip is clocked at 1.7734 MHz on 128K models.

PortFunctionAccess
#FFFDRegister select / readRead/Write
#BFFDData writeWrite only

Registers:

RegFunctionBits
0Channel A pitch fine8
1Channel A pitch coarse4
2Channel B pitch fine8
3Channel B pitch coarse4
4Channel C pitch fine8
5Channel C pitch coarse4
6Noise pitch5
7Mixer control8
8Channel A volume5
9Channel B volume5
10Channel C volume5
11Envelope period fine8
12Envelope period coarse8
13Envelope shape4

Mixer (R7): Bit 0-2 = Tone off (A,B,C), Bit 3-5 = Noise off (A,B,C)

Volume (R8-10): Bit 4 = Envelope mode, Bits 0-3 = Volume (0-15)

Envelope shapes (R13):

ValueShapeDescription
0-3\___Decay, hold low
4-7/___Attack, hold low
8\\\\Decay (sawtooth)
9\___Decay, hold low
10\/\/Decay-attack (triangle)
11\ยฏยฏยฏDecay, hold high
12////Attack (sawtooth)
13/ยฏยฏยฏAttack, hold high
14/\/\Attack-decay (triangle)
15/___Attack, hold low

Frame Timing

Parameter48K128K/+2/+2APentagon/Scorpion
T-states per line224228224
Lines per frame312311320
T-states per frame698887090871680
Frame rate (Hz)50.0850.0248.83
CPU clock (MHz)3.53.54693.5
First screen line646380
INT length (T)323232

Border Sizes (pixels)

Border48K128K/+2/+2APentagon/Scorpion
Top (lines)646380
Bottom (lines)565648
Left (pixels)484848
Right (pixels)484848
Total visible width352352352
Total visible height312311320

Memory Map (128K/+2/+2A/Pentagon/Scorpion)

AddressContentContention (128K/+2)Contention (+2A)
0000-3FFFROM (128K: 0-1, +2A/Scorpion: 0-3)NoNo
4000-7FFFRAM Bank 5 (Screen)Yes (always)Yes (always)
8000-BFFFRAM Bank 2NoNo
C000-FFFFRAM Bank 0-7 (paged)Odd banks onlyBanks 4-7 only

RAM Banks Contention

Bank128K/+2+2ANotes
0NoNoDefault at C000
1YesNo
2NoNoAlways at 8000
3YesNo
4NoYes
5YesYesAlways at 4000 (screen 0)
6NoYes
7YesYesScreen 1 (when selected)

Contention Pattern

48K: Screen lines use 192 T-states for drawing. Memory contention occurs when CPU accesses 4000-7FFF during screen drawing (lines 64-255, T-states 14-126).

128K/+2: Screen lines use 196 T-states for drawing (228 total per line). Contended banks: 1, 3, 5, 7 (odd).

+2A: Same timing as 128K. Contended banks: 4, 5, 6, 7 (high). In special paging mode, contention applies per-slot based on the mapped bank.

Pattern repeats every 8 T-states: 6, 5, 4, 3, 2, 1, 0, 0 (delay in T-states)

I/O contention: ULA port (xxFE) also causes delays when accessed during screen time.

+2A Differences (vs 128K)

  • 4 ROM banks (64KB) selected via ports 0x7FFD bit 4 + 0x1FFD bit 2
  • Port 0x1FFD: special paging, ROM high bit, disk motor
  • 4 special all-RAM paging modes (port 0x1FFD bit 0 = 1)
  • Different contended banks: 4, 5, 6, 7 (not 1, 3, 5, 7)
  • 48K BASIC ROM in bank 3 (not bank 1)

Pentagon Differences

  • No memory or I/O contention
  • 320 lines per frame (more top border)
  • TR-DOS ROM pages in/out via 3Dxx trigger
  • Beta Disk interface at ports 1F, 3F, 5F, 7F, FF

Scorpion ZS 256 Differences

  • 256KB RAM (16 pages), Pentagon-compatible ULA timing
  • 4 ROM banks: ROM0=128 BASIC, ROM1=48 BASIC, ROM2=Service Monitor, ROM3=TR-DOS
  • Port 0x7FFD: standard 128K paging (RAM 0-7, ROM 0/1, screen, lock)
  • Port 0x1FFD: bit 0 = RAM over ROM, bit 1 = ROM 2 select, bit 4 = RAM page +8
  • ROM selection (3-way): 1FFD.1 set โ†’ ROM 2; unset โ†’ 7FFD.4 selects ROM 0/1
  • TR-DOS built into ROM bank 3 (no separate trdos.rom needed)
  • No memory or I/O contention (same as Pentagon)

Z80 Instruction Set Reference

Mnemonic Opcode Size Cycles Flags Description
Zoom:
Normal
Bright
โ€”
(instant)
No boot file selected
50%
Choose which machines appear in the toolbar dropdown:
System Tests FUSE Tests Assembler Tests Loading tests...
This functionality is intended for emulator developers only, not for end users.
Test Name Machine File Result
No file loaded
Load a file to view its structure
(0=โˆž)
AY Capture (PSG)
RZX Recording
Drop ROM or Snapshot here