And yes, it's a memory test. From Geoff Wearmouth's superlative ROM disassembly:
; -----------------------
; THE 'RAM CHECK' SECTION
; -----------------------
; Typically, a Spectrum will have 16K or 48K of RAM and this code will test
; it all till it finds an unpopulated location or, less likely, a faulty
; location. Usually it stops when it reaches the top $FFFF, or in the case
; of NEW the supplied top value. The entire screen turns black with
; sometimes red stripes on black paper just visible.
;; ram-check
L11DA: LD H,D ; Transfer the top value to the HL register
LD L,E ; pair.
;; RAM-FILL
L11DC: LD (HL),$02 ; Load memory with $02 - red ink on black paper.
DEC HL ; Decrement memory address.
CP H ; Have we reached ROM - $3F ?
JR NZ,L11DC ; Back to RAM-FILL if not.
;; RAM-READ
L11E2: AND A ; Clear carry - prepare to subtract.
SBC HL,DE ; subtract and add back setting
ADD HL,DE ; carry when back at start.
INC HL ; and increment for next iteration.
JR NC,L11EF ; forward to RAM-DONE if we've got back to
; starting point with no errors.
DEC (HL) ; decrement to 1.
JR Z,L11EF ; forward to RAM-DONE if faulty.
DEC (HL) ; decrement to zero.
JR Z,L11E2 ; back to RAM-READ if zero flag was set.
It basically tests each memory location with the value "2". It decrements once, tests it to make sure it equals "1", then decrements again to "0". If any of these writes to memory fails, the last known "good" address is stored in HL, and that becomes the highest RAM address you can use. This is what allows a 16k Speccy to know that it's a 16k Speccy :)
So of course, as every address is filled with "2", when it hits the attributes area (22528 to 23295) the screen is filled with black paper, red ink. As it moves into the display area (16384 to 22527), the vertical lines appear - the value "2" is 00000010 in binary, and that gets repeated throughout the screen. They disappear as the decrement tests are performed, and the screen goes totally black...
And when done, the paper is set to black-on-white and the (C) message appears. There's more done in the interim, of course, but you don't actually see that happening.
This is what I know:
Z80 restarts at adress 0.
Memory is tested.
If a tested adress returns faulty, it is signed as absent and the rest of the memory above it is also signed as absent.
(This why a 16K spectrum boots faster then a 48K.)
After this procedure, the basic system is set up and the message is printed on screen.
The garbage you mention is probably the result of the system being in a state of chaos for a brief period of time.
Here's another question - why do some crashes produce the most beautifully coloured patterns? sometimes even flashing :smile: Its as if the crash has somesort of aesthetic artistry
Here's another question - why do some crashes produce the most beautifully coloured patterns? sometimes even flashing :smile: Its as if the crash has somesort of aesthetic artistry
Usually a value somewhere gets corrupted, and this value is written to by various instructions as the Z80s PC register romps around deciding that everything should be executed! When it wanders all over the screen memory, you get the funny displays.
I am sorry to jump into this thread like this. But since you are talking reset. Do any of you know how to wire the Reset signal on the edge connector to cause the Z80 to perform a reset? I really dont like the idea of a reset button shorting out a capacitor as is done in the spectrum +, that shortens the lifespan of caps quite a lot.
If modern operating systems weren't so complex and updates could be done as easily as we update a BIOS, we could have computers that would be instantly ready to use after pressing the power button. I've always wondered if that's possible or not, and if it wouldn't be the ultimate solution against hacking, viruses, data corruption, etc. Unauthorized updates or changes to the O.S. could be prevented with a physical switch similar to what some BIOSes have, which has to be set to "write" before any flashing is allowed. If something of this magnitude is impossible due to size limitations or the complexity of an O.S. they could at least do it for recovery purposes. A "giant" O.S. recovery rom, flash or SSD instead of adding a recovery partition to a hard drive that can fail anytime.
Johan1973:
The Reset on the edge connector is connected to that same capacitor.
The capacitor is connected to the reset pin on the Z80 and with a pull-up resistor to 5 Volt.
This circuit ensures that the the reset is held logically low for a short period of time during power-up/reset, so the rest of the system can get ready for operation before the Z80 starts up.
Johan1973:
The Reset on the edge connector is connected to that same capacitor.
The capacitor is connected to the reset pin on the Z80 and with a pull-up resistor to 5 Volt.
This circuit ensures that the the reset is held logically low for a short period of time during power-up/reset, so the rest of the system can get ready for operation before the Z80 starts up.
Aha, Now I get it. Thank you for your reply.
I just hooked up my oscilloscope to that pin, and it shows a what I assume is the recharge cycle of the capacitor with a 500mV to +2.68V peak values. For a few milliseconds it drops low when powering on. Interesting :)
Comments
And yes, it's a memory test. From Geoff Wearmouth's superlative ROM disassembly:
; ----------------------- ; THE 'RAM CHECK' SECTION ; ----------------------- ; Typically, a Spectrum will have 16K or 48K of RAM and this code will test ; it all till it finds an unpopulated location or, less likely, a faulty ; location. Usually it stops when it reaches the top $FFFF, or in the case ; of NEW the supplied top value. The entire screen turns black with ; sometimes red stripes on black paper just visible. ;; ram-check L11DA: LD H,D ; Transfer the top value to the HL register LD L,E ; pair. ;; RAM-FILL L11DC: LD (HL),$02 ; Load memory with $02 - red ink on black paper. DEC HL ; Decrement memory address. CP H ; Have we reached ROM - $3F ? JR NZ,L11DC ; Back to RAM-FILL if not. ;; RAM-READ L11E2: AND A ; Clear carry - prepare to subtract. SBC HL,DE ; subtract and add back setting ADD HL,DE ; carry when back at start. INC HL ; and increment for next iteration. JR NC,L11EF ; forward to RAM-DONE if we've got back to ; starting point with no errors. DEC (HL) ; decrement to 1. JR Z,L11EF ; forward to RAM-DONE if faulty. DEC (HL) ; decrement to zero. JR Z,L11E2 ; back to RAM-READ if zero flag was set.It basically tests each memory location with the value "2". It decrements once, tests it to make sure it equals "1", then decrements again to "0". If any of these writes to memory fails, the last known "good" address is stored in HL, and that becomes the highest RAM address you can use. This is what allows a 16k Speccy to know that it's a 16k Speccy :)
So of course, as every address is filled with "2", when it hits the attributes area (22528 to 23295) the screen is filled with black paper, red ink. As it moves into the display area (16384 to 22527), the vertical lines appear - the value "2" is 00000010 in binary, and that gets repeated throughout the screen. They disappear as the decrement tests are performed, and the screen goes totally black...
And when done, the paper is set to black-on-white and the (C) message appears. There's more done in the interim, of course, but you don't actually see that happening.
D.
Z80 restarts at adress 0.
Memory is tested.
If a tested adress returns faulty, it is signed as absent and the rest of the memory above it is also signed as absent.
(This why a 16K spectrum boots faster then a 48K.)
After this procedure, the basic system is set up and the message is printed on screen.
The garbage you mention is probably the result of the system being in a state of chaos for a brief period of time.
Here's another question - why do some crashes produce the most beautifully coloured patterns? sometimes even flashing :smile: Its as if the crash has somesort of aesthetic artistry
Usually a value somewhere gets corrupted, and this value is written to by various instructions as the Z80s PC register romps around deciding that everything should be executed! When it wanders all over the screen memory, you get the funny displays.
Just wait until you see ULA snow :-p
D.
The Reset on the edge connector is connected to that same capacitor.
The capacitor is connected to the reset pin on the Z80 and with a pull-up resistor to 5 Volt.
This circuit ensures that the the reset is held logically low for a short period of time during power-up/reset, so the rest of the system can get ready for operation before the Z80 starts up.
Aha, Now I get it. Thank you for your reply.
I just hooked up my oscilloscope to that pin, and it shows a what I assume is the recharge cycle of the capacitor with a 500mV to +2.68V peak values. For a few milliseconds it drops low when powering on. Interesting :)