128k Ram paging
Contents |
128k ram
THere are two aspects that need to be considered here. Firstly we need a latch at $7ffd, of which the first three bits are the bank number. These bits go straight to the inputs to the 74LS157 we wired to zero when doing the 48K bit. (Thats what the black flying leads are about)
The second aspect that needs to be considered is proper contention for Bank 5. When we can change the upper page, it is possible to have $c000-$FFFF pointing to Bank 5 and bank 2 which also permenently reside at $4000 and $8000 respectivey.
This isnt a problem for bank 2, however for Bank 5, which mirrors the ULA video memory, we must provide a method of ensuring that if you write to $C000 and Bank 5 is paged in there, the write gets reflected in the video Ram.
The 128K also provides a bank of shadow video memory, however this isnt dealt with here, as fortunately it isnt used much, and needs further modifications to the ULA circuitry.
Theory
THe 7ffD latch is implemented using a 74LS174, similar to to the original speccy 128. The advantage this has over other methods is that this chip provides a reset signal whcih means it can be made to default to 0 for all its outputs by simply wiring it to the CPU reset line.
Note, the Diode and resistor connected to Bit 6 of the latch. This implements the Spectrum 128's paging lock. Once this is "1", the diode will prevent any more writes to the latch until it is reset.
For Decoding logic, i used a 74LS30, (8 input NAND) connected to /A15, A14-A12, IORQ, WR, A0 /A1, (where A15, IORQ, WR and A1 were inverted with a 74LS04. At this stage, i could get away with significantly less decoding (Probably /A15, /A1 and IORQ are nessesary) however, i will come to regret it later. Likewaise, We are only currently using Bits 0,1,2 and 5 of the latch, with 3 and 4 being unused. However, both bit 3 and 4 will be used later, so it makes sense to wire them up now.
Note that i have found that LEDs to the bank pins are really useful for testing.
The ULA detects if a write is happening to the video Ram by monitoring A15 and A14 to check for A15=0, A14=1. What we want to do is arrange the ULA to write its Ram if were writing to $C000 (A15=1 A14=1) AND the current bank is 5.
So to summarise, The ULA's A15 line needs to be low if:
A15 is low (IE, writing to $4000) OR A15 is High AND A15 is high And Bank selected is 5 (IE, Writing to $C000 And bank 5)
This logic is implemented by cutting the A15 from the ULA to the CPU and taking a flying lead from the ULA to the circuit below.
Schematic
Finished product
File:Speccy 128 ram finished.jpg
Testing
Initially, you need to plug in the board and turn it on.
Hopefuly you should get the (C) 1982 sinclair research message.
Type
Clear 32767 (x 32767 <enter>)
Next, type the following:
10 for a = 0 to 7 20 out 32765,a 30 poke 49152,a 40 next a 50 for a = 0 to 7 60 out 32765,a 70 if peek 49152 <> a then print "ERROR";a 80 next a
and run it. Hopefully, it should run to completion without erroring. If you put LED's on the bank signals, you should see the LEDs counting up in binary twice.
Next we need to ensure the banks are being properly mirrored and writes to $C000 bank 5 are being properly trapped by the ULA
Type
clear 32767 out 32765,5 poke 49152,255 <Hopefully, a small blck line should appear in the top left of the screen> out 32767,2 poke 49152, 111 print peek 32768 (Hopefully "111" should be displayed)
Lastly, we need to ensure bank locking is working. To do this, we will page in bank 0, set it to a known value, then page in bank 1, set it to a differnet value, page lock, and see if bank 0 works.
clear 32767 out 32765,0 (All the LEDs should go out) out 32765,7 (All the LEDs should be lit) out 32765,7+16 (All the LEDs should now be lit. out 32765,0 (All the LEDs should remain lit)
Also, any further OUTs to 32765 should have no effect.
Lastly, if you reset the computer, the LEDs should all go out again.
Parts list
- Active
- Passive
- 680 ohm resistor
- 330 Ohm resistor x3 [*]
- 1N4148 Diode
- LED's x3 [*]
[*] optional, but highly recommended.

