Spectrum screen layout

Share graphical tips, notes and queries related to our favourite screen layout and its editors.
Post Reply
tobobobo
Drutt
Posts: 11
Joined: Sun Nov 12, 2017 8:10 pm

Spectrum screen layout

Post 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.
User avatar
R-Tape
Site Admin
Posts: 6353
Joined: Thu Nov 09, 2017 11:46 am

Re: Spectrum screen layout

Post 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.
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: Spectrum screen layout

Post 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 :)
User avatar
Einar Saukas
Bugaboo
Posts: 3070
Joined: Wed Nov 15, 2017 2:48 pm

Re: Spectrum screen layout

Post 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.
User avatar
balford
Drutt
Posts: 34
Joined: Mon Nov 13, 2017 2:01 pm
Location: Ireland

Re: Spectrum screen layout

Post 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.
Fixing ZX Spectrums in the 21st Century
https://github.com/brendanalford/zx-diagnostics
User avatar
Pobulous
Dynamite Dan
Posts: 1346
Joined: Wed Nov 15, 2017 12:51 pm

Re: Spectrum screen layout

Post 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.
User avatar
1024MAK
Bugaboo
Posts: 3104
Joined: Wed Nov 15, 2017 2:52 pm
Location: Sunny Somerset in the U.K. in Europe

Re: Spectrum screen layout

Post 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
:!: Standby alert :!:
“There are four lights!”
Step up to red alert. Sir, are you absolutely sure? It does mean changing the bulb :dance
Looking forward to summer later in the year.
Post Reply