Spectrum 128

The place for codemasters or beginners to talk about programming any language for the Spectrum.
Post Reply
dwinters18
Drutt
Posts: 20
Joined: Sat Dec 01, 2018 6:45 pm

Spectrum 128

Post by dwinters18 »

Hi,

I know this will sound like a bit of a silly question to some of you out there, but I have been doing some z80 stuff for the 48k spectrum and would like to explore the spectrum 128 side of doing z80 for it - namely accessing the extra ram and using the AY sound chip.

Is there any quick reference as to how easy it could be to start doing code for the spectrum 128 as oppsoed to the 48k?

I am using SpecNet IDE that does support spectrum 128 apparantly.

Thanks in advance for any assistance/help/thoughts!

D.
User avatar
Ast A. Moore
Rick Dangerous
Posts: 2640
Joined: Mon Nov 13, 2017 3:16 pm

Re: Spectrum 128

Post by Ast A. Moore »

Nothing silly about your question. Here’s a good place to start—a fairly comprehensive description of the 128K Spectrum architecture.
Every man should plant a tree, build a house, and write a ZX Spectrum game.

Author of A Yankee in Iraq, a 50 fps shoot-’em-up—the first game to utilize the floating bus on the +2A/+3,
and zasm Z80 Assembler syntax highlighter.
dwinters18
Drutt
Posts: 20
Joined: Sat Dec 01, 2018 6:45 pm

Re: Spectrum 128

Post by dwinters18 »

Hi.

Thanks for that link.

It doesn't seem to really outline how you would go about coding something to use the extra memory.

I know it has to be paged, but how does that affect where your code is running from if you page to elsewhere in memory?

(Told you it's a silly question!)

D
Ralf
Rick Dangerous
Posts: 2279
Joined: Mon Nov 13, 2017 11:59 am
Location: Poland

Re: Spectrum 128

Post by Ralf »

I would say it's not a big difference. You have the same CPU and the same graphic mode. Most of programs written for 48 kB will work on 128 kB as well. So you can write universal programs, working both on 48 kB and 128 kB

The differences are:

- AY music (although 48 kB may play AY as well with external interface attached)
- extra memory (but you can't access it all at the same time so problem of memory paging emerges)
- second display screen
- subtle differences with timings (ignore it now)

As for the AY, most of people don't write their own music playing routines but rather use existing tools and formats. This is relatively easy. Of course the music itself must be created first ;) but I suppose we go here beyond "coding"

As for the memory paging (which also include switching between visible screens) check this info at start:
https://www.worldofspectrum.org/faq/ref ... erence.htm

EDIT: Looks like you already have been given this link.

You ask how paging affects your code. In theory it's simple - with a single command part of your memory is replaced with a different content from different memory page.

Using it in practice may sometimes be awkward. I've seen several people on the forums claiming that they hate paging ;) You just have to develop your own tricks, I guess. And keep connected stuff together so when you change the page you have everything you need in main memory
dwinters18
Drutt
Posts: 20
Joined: Sat Dec 01, 2018 6:45 pm

Re: Spectrum 128

Post by dwinters18 »

Hi,

Thanks - very interesting.

1) Out of curiosity, is the second screen something that can be used in conjunction with the first for something like double buffering for games or does it not work like that?

2) Also you say paging part of your memory - I am struggling to understand (if it's possible to answer this briefly) how the extra memory works with for example my game code (as i say for accessing maybe map data for instance)

D.
dfzx
Manic Miner
Posts: 673
Joined: Mon Nov 13, 2017 6:55 pm
Location: New Forest, UK
Contact:

Re: Spectrum 128

Post by dfzx »

dwinters18 wrote: Tue Jan 01, 2019 8:12 pm I know it has to be paged, but how does that affect where your code is running from if you page to elsewhere in memory?
Just trying to get my head around what you're actually asking here...

The paging works by changing the contents of the top 16K of RAM. You really don't want to be running code which is in that RAM bank at the point you page in a different one! You don't want your stack in there either! So generally speaking, to keep things simple you'd make sure the code you're running is in the 0x4000 to 0xbfff range, and it's data you page in an out of the top bank as needed. I'm simplifying, of course. You can do all sorts of weird things if you see advantage in it. :)

There's a long an illuminating thread on the subject of double buffering here.
Derek Fountain, author of the ZX Spectrum C Programmer's Getting Started Guide and various open source games, hardware and other projects, including an IF1 and ZX Microdrive emulator.
Post Reply