Page 1 of 1

Spectrum screen layout

Posted: Sun Nov 12, 2017 9:13 pm
by tobobobo
I have a question.

The Spectrum screen layout is well documented in books, websites, etc. but I’ve yet to learn WHY it’s the way it is?

Why is it in 3 x 8 rows of 8 - it’s the same amount of bytes, surely. Is it some bit-manipulation reason that makes addressing the screen addresses easier this way? ...easier than sequential like the attribute addresses?

So, yes, I get that it’s unusual, but why is it unusual?



T.

Re: Spectrum screen layout

Posted: Sun Nov 12, 2017 9:32 pm
by R-Tape
Hopefully some experts can answer this (i.e. not me) but one of the reasons was to make printing characters easier/faster, they certainly didn't have game sprites in mind! The distance between lines within a cell is 256, so you can just increase the high byte with a single quick instruction.

Re: Spectrum screen layout

Posted: Mon Nov 13, 2017 12:46 pm
by Ralf
I've heard it was easy to do on hardware level. And that it's described in book about ULA by Chris Smith. Unfortunately I'm crap when it comes to hardware so I won't say you more.

You must also remember that Zx Spectrum wasn't designed from the scratch. It was a development of earlier models - Z80 and Z81. I suppose it was in some way natural conitnuation to do it this way.

Besides actually many computer of the 80s had weird screen layouts and each retro communtiy complains and wonders about them. Amstrad CPC, Atari 2600, 8-bit Atari and so on. So it was nothing unusual in those days :)

Re: Spectrum screen layout

Posted: Thu Nov 16, 2017 12:21 pm
by Einar Saukas
R-Tape wrote: Sun Nov 12, 2017 9:32 pmHopefully some experts can answer this (i.e. not me) but one of the reasons was to make printing characters easier/faster, they certainly didn't have game sprites in mind! The distance between lines within a cell is 256, so you can just increase the high byte with a single quick instruction.
Exactly! In theory, it's the most efficient screen layout for rendering text on screen. Keep in mind that the Spectrum was designed for "serious" applications, not games. Some computers at the time provided different screen modes for text or graphics, but the Spectrum didn't have this distinction (probably to reduce costs) and rendered text directly into graphics mode. Designers probably wanted to ensure that printing text wouldn't be noticeably slower than other computers using text mode, so the hardware was designed to optimize this operation.

Technically, when drawing a character on screen, each character byte should be placed at consecutive line positions. It takes a single instruction INC H to move to next line position within the same row. Afterwards, it takes a single instruction INC L to move to the next character position (either next column in the same row or, after reaching last column, then first column in next row). Except this layout only works for 8 rows * 32 columns = 256 characters, thus requiring 3 sections of 256 characters each.

Re: Spectrum screen layout

Posted: Thu Nov 16, 2017 12:25 pm
by balford
For an explanation of the memory screen layout, see this page (by Chris Smith, this is the work that fed into his book):
http://www.zxdesign.info/memoryToScreen.shtml

- and for an explanation (a little technical) as to why this layout is important:
http://www.zxdesign.info/dynamicRam2.shtml

Basically this allowed the interleaving between ULA and CPU access of the lower 16K of RAM to be as efficient as was possible at the time, given the cost constraints.

Re: Spectrum screen layout

Posted: Thu Nov 16, 2017 1:28 pm
by Pobulous
I thought the main reason for splitting it into 3 sections was for ease of addressing characters.
So once you have the address of the top line of a char, then just increase the MSB to move down to the next line.
ie, if DE register pair points at the top line of char on screen, then just:
INC D
to move to the next line.

If it was all in one section, then you'd need to do:
INC D
INC D
INC D
each time.

Re: Spectrum screen layout

Posted: Thu Nov 16, 2017 3:27 pm
by 1024MAK
The simple answer is to make the hardware simpler, hence keep the cost down (hence keep the design of the ULA and it's RAM interface as low cost as possible).

For once, the design has very little in common with the ZX80 or the ZX81. They use a completely different method of screen generation and in the RAM of a ZX80 or ZX81, there is NO pixel data (only character codes) (true for the BASIC system, but people eventually found ways round this and hi-res screens then became possible).

The software tricks are solutions to the layout of the screen, not the reason for it.

Mark