|
The Keyboard
We can read in a row of the keyboard by setting BC to the correct value and using IN A,(C)... the resulting byte will contain a 0 if the key is pressed, 1 if it is not.
C= &FE | |||||
B=... |
4 |
3 |
2 |
1 |
0 |
%11111110 | V | C | X | Z | SHIFT |
%11111101 | G | F | D | S | A |
%11111011 | T | R | E | W | Q |
%11110111 | 5 | 4 | 3 | 2 | 1 |
%11101111 | 6 | 7 | 8 | 9 | 0 |
%11011111 | Y | U | I | O | P |
%10111111 | H | J | K | L | ENTER |
%01111111 | B | N | M | DEL | SPC |
AY-3-8910 Sound Chip:
Register | Meaning | Bit Meaning | Details |
0 | Tone Pitch L - Channel A | LLLLLLLL | Lower value = Higher pitch |
1 | Tone Pitch H - Channel A | ----HHHH | Lower value = Higher pitch |
2 | Tone Pitch L - Channel B | LLLLLLLL | Lower value = Higher pitch |
3 | Tone Pitch H - Channel B | ----HHHH | Lower value = Higher pitch |
4 | Tone Pitch L - Channel C | LLLLLLLL | Lower value = Higher pitch |
5 | Tone Pitch H - Channel C | ----HHHH | Lower value = Higher pitch |
6 | Noise Generator | ---NNNNN | Higer = Faster noise |
7 | Mixer | --NNNTTT | N=Noise T=Tone (Channel --CBACBA 1=mute 0=normal) |
8 | Amplitude - Channel A | ---EVVVV | E=Envelope (1=Enabled) VVVV=Volume |
9 | Amplitude - Channel B | ---EVVVV | E=Envelope (1=Enabled) VVVV=Volume |
10 | Amplitude - Channel C | ---EVVVV | E=Envelope (1=Enabled) VVVV=Volume |
11 | Envelope L (Volume over time) | LLLLLLLL | Lower=Faster Envelope |
12 | Envelope H (Volume over time) | HHHHHHHH | Lower=Faster Envelope |
13 | Envelope Selection | ----EEEE | Envelope number (See PDF) |
The "Beeper" sound chip is incredibly crude... it is controlled by
bit 5 of the port &FE... by turning it on and off we can make
simple sounds... See the example to the right... by changing the pause (caused by BC) we can change the pitch of the sound... 3000 will be a relatively low pitch... 500 will be higher... Some clever programs even manage to "Fake" multiple sound channels! The big disadvantage to all this is that the CPU will be busy during the whole time, so the Beeper chip isn't very helpful, and we'll want to use the AY sound chip on the 128k systems... but on the 48k machines, it's all we've got! |
xor a loopy: xor %00010000 ;---S-BBB S=Sound B=Border out (&fe),a ld bc,3000 ;Lower number=higher pitch pausey: dec c jr nz,pausey dec b jr nz,pausey jr loopy |
Port | Backup | Bits | Details |
&7FFD | &5B5C | - - IRSMMM | MMM= ram bank at C000 (0-7) S=Screen page bit R=Rom Low bit I=I/O Disabling |
&1FFD | &5B67 | - - - SDR - P | P = paging mode (0=normal 1=+3) R=Rom high bit D = Disk Motor S=Printer strobe |
ZX 128K | |
&0000 | ROM |
&4000 | Screen 1 (5)* |
&8000 | Ram (2) |
&C000 | Screen 2 (7) |
128K | +3 |
Ram 0 | Ram 0 |
Ram 1 | Ram 1 |
Ram 3 | Ram 3 |
Ram 4 | Ram 4 |
Ram 6 | Ram 6 |
Dark=Contended |
&1FFD Bits 2,1 | ||||
00 | 01 | 10 | 11 | |
&C000 | Bank 3 | Bank 7 | Bank 3 | Bank 3 |
&8000 | Bank 2 | Bank 6 | Bank 6 | Bank 6 |
&4000 | Bank 1 | Bank 5 (S) | Bank 5 (S) | Bank 7 (S) |
&0000 | Bank 0 | Bank 4 | Bank 4 | Bank 4 |
S=Screen Bank |
48k | Usage |
|
0000 | 3FFF | ROM |
4000 | 57FF | Screen Ram |
5800 | 5AFF | Screen Ram Color Data |
5B00 | 5BFF | Printer Buffer (Sysvars on +3) |
5C00 | 5CBF | System Vars |
5CC0 | 5CCA | Reserved |
5CCA | 5D3B | TR-DOS Area |
5D3B | FF57 | Available Memory (Between Prog and Ramtop |
FF58 | FFFF | Reserved (User defined characters) |
Screen Map
Calculating screen addresses for bitmap pixel data can be performed with the following 'formula'
H | L | |||||||||||||||
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
0 | 1 | 0 | Y7 | Y6 | Y2 | Y1 | Y0 | Y5 | Y4 | Y3 | X4 | X3 | X2 | X1 | X0 |
Calculating screen addresses for color block data can be performed with the following 'formula'
H | L | |||||||||||||||
7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | |
0 | 1 | 0 | 1 | 1 | 0 | Y7 | Y6 | Y5 | Y4 | Y3 | X4 | X3 | X2 | X1 | X0 |
ld a,h ;HL
is a pixel address
srl a
srl a
srl a
add &50
ld h,a ;Address is now the
equivalent color address
Each Color byte is defined in the following format:
% | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
Flash | Bright | Back | Back | Back | Fore | Fore | Fore |
FOREground and BACKground colors are defined by 3 bits each... values from 0-7:
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
Black #000000 |
Blue #0000FF |
Red #FF0000 |
Magenta #FF00FF |
Green #00FF00 |
Cyan #00FFFF |
Yellow #FFFF00 |
White #FFFFFF |
Spectrum +3 Disk File Header
Position | Bytes | Content | Details | Example |
&0000 | 8 | PLUS3DOS | Text Header | PLUS3DOS |
&0009 | 1 | EOF byte | EOF Character | 26 |
&000A | 1 | Issue Num | Issue Num | 1 |
&000B | 1 | Version Num | Version Num | 0 |
&000F | 4 | Size+128 | Size INC Header | &1080 |
&0010 | 2 | Size | Size of file | &1000 |
&0012 | 5 | Basic Header | Basic Header | &03,&00,&80,&00,&80 |
&0017 | 104 | Unused | Unused | 0 0 0 0� |
&007F | 1 | Checksum | Checksum of Header bytes 0-126 (MOD 256) | ? |
&0080 | Program Code |