Programming vlog 0x01 - Figuring out fixed point maths
I'm on a mission to document programming the ZX Spectrum Next. Between making the instructional videos I need to learn how the machine works. I thought it might be fun to document this process too.
In this video I work out how to use fixed point maths to make things move around the screen in pleasing ways, ready for the next video I'm releasing next week.
It takes a lot of effort to produce a video explaining how to program a certain aspect of the Spectrum Next, most of that effort is me learning something new and trying to find any documentation on it. I get a bit lost along the way so if I make videos and you watch them, it'll motivate me to carry on! ... https://www.youtube.com/watch?v=H_xv1kKugzE
Grab a drink, get comfy and watch as I figure out how to write an incredibly simple program from scratch, using Z80 assembler.
I have no idea what I'm doing, but we get there in the end.
Let's explore how 8bit computers worked, looking at their memory, interrupts and DMA.
Computers from the 1980s seemed to be quite limited in their abilities, there was a bit drive to make a machine as cheaply as possible. Competition was fierce between manufacturers. Often the amount of RAM in the machine was a selling point - if you were looking for a new computer, would you buy a Commodore 64, or a Spectrum 128? Clearly 128 sounds more.
Except these machines were limited by their designs, so how exactly did something like a Spectrum 128 have 128K of RAM? What are interrupts? How do they work on a Spectrum? What is DMA and did it even exist back then, or was it not until the Amiga came along DMA became popular?
Let's look at these three topics using various models of ZX Spectrum and the new Spectrum Next.
This is an introduction to the topics of Memory Banking, Interrupts and DMA. There will be more in-depth videos coming soon on each topic, along with source code. So subscribe to be notified when they arrive.
----
Contains images from Wikipedia
Chapters
---------------
Intro 00:30
Memory Banking 01:28
Memory on 8 bit systems 02:06
Memory Banking 04:41
Interrupts 10:47
DMA Controller 18:05
Summary 20:29
...
https://www.youtube.com/watch?v=hZtFFKbBgHo
Let's look at one of the world's first mobile phones - the Motorola 8500x - released in the mid 1980s for £3,000. That's over £7,000 today!
In this video I'll explain what the 1980s was like as far as phones went, and we'll look inside this massive brick phone - does it still work? Will it switch on? What's inside it anyway?
Phones today are so common you're more likely to get funny looks if you don't have one. But that wasn't always the case. Mobile phones had been thought up, but they worked more like CB radios. You had to follow radio rules to use them and have a licence.
There's this fantastic old Tomorrow's World episode you should go and watch. Especially the bit where his call goes wrong and some random
person cuts into the call.
One thing I want to get across is just how insanely expensive owning a phone was back then. A similar model - the 8000X - was £3000 back in 1985 which is a thoroughly meaningless £7,503.49 in today's money. The average wage for the type of person who would have used this - a male between 30 and 39 - is £236 a week, or just over £12,000 a year. That's £30,000 in today's money.
There's no way your average worker would spend three month's wages on a phone, especially when nobody else had one. This is the era where phonecalls cost money. Talk was expensive, so you did it at prearranged times and made sure you had something to say.
So it's an expensive yuppie status symbol, like a sports car or private jet. If you owned one yourself, you were loaded.
If you had a company one, you must have had some high up executive job that warranted you being given one, along with your company car.
Or you were some sales guy living out of his car selling washing machines and needing the phone.
It's completely analogue. There's no 3G, 4G, it doesn't even do GSM. So what did it do? Well it's called 1G because...
it was the first generation.
There were several systems known as TACS for Total Access Communication System, and ETACS, created by Vodafone, Ericsson, and Cellnet.
Yes, these are all the same names that exist today. Although interestingly Cellnet used to be called Telecom Securicor Cellular Radio Ltd.
It was formed from the security company Securicor (who have now been absorbed and mutated into G4S) and British Telecom. If you were a
Cellnet user, you'll have noticed at some point it turned into BT Cellnet, and then O2.
The network was all analogue, and used frequencies between 935 and 949 MHz for the cell towers, and 890 to 904 for the handsets.
SIM cards didn't exist, the handsets had their identifying numbers programmed into them.
This wasn't a fashion phone to upgrade every year.
Could you do anything beyond making expensive phone calls? No. That was it.
And that's how important these devices were. Normal people used payphones. Normal British people didn't even have pagers.
Making phonecalls in the 80s from outside your house was awful. Having a magic box to carry about must have been amazing.
Merely owning one was enough. It didn't need to do anything else.
So there we go, a look inside a 1980s yuppie status symbol. Feel free to tell me about your stories of mobile phones in the comments.
You know, I remember seeing some guy on the bus in the mid 90s on his phone and I remember thinking "what a showoff". And then in 1997
pay as you go came along, Nokia plopped out successive cheap iconic handsets and seemingly overnight everyone had a phone. It happened
so fast, I've never seen anything like it.
Noticed how in science fiction stories we alway miss mobile phones being a thing? Sure, we have the idea of personal communicators in
Star Trek, but they were more like 2-way radios. Or you might have some sort of pager device, but nobody seemed to predict the entire
planet owning a personal phone number as if it was completely normal.
Blog Post: https://ncot.uk/electronics/3000-mobile-phone-motorola-8500x/
Twitter: @ncot_tech
Chapters
========
00:00 Intro
02:03 Disassembly
06:44 About the phone
10:03 Inside the Motorola Brick Phone
14:55 How expensive was the phone?
16:38 Inside the Motorola Brick Phone
20:54 What we used them for
22:25 More Insides
24:27 Battery Life
27:22 Reading the eprom
29:41 Outro
Attributions
============
Rotary phone - Video by Andrew Kota: https://www.pexels.com/video/green-rotary-phone-4520095/
BBC Tomorrow's World - https://www.youtube.com/watch?v=vix6TMnj9vY
1986 Ferrari Testarossa - Mr.choppers, CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0, via Wikimedia Commons
1980 Learjet - Stanley Howe / A private jet at Blackbushe (1980)
Richard Croft / Vandalised phone box
https://www.dailypost.co.uk/news/north-wales-news/bt-rhyl-phone-box-damage-10082143
Motorola Pager - Thiemo Schuff, CC BY-SA 3.0 https://creativecommons.org/licenses/by-sa/3.0, via Wikimedia Commons
https://rarehistoricalphotos.com/early-mobile-phones-pictures-1970-1990/
...
https://www.youtube.com/watch?v=38l9lq5XjRo
This is the third video in a short series looking at some of the more advanced parts of the Spectrum Next. If you've not seen the others, go watch them after this one. In this video we're looking at how to program the DMA controller in the Spectrum Next.
This'll be technical, it'll include code on how to do this using Z88DK and C for the Spectrum Next. It's a pretty advanced technique, but it's quite understandable and can add some nice speed boosts to code if used appropriately.
DMA or Direct Memory Access is a way to allow devices access to system RAM without the CPU being involved.
The DMA controller in the Next is a programmable device and has a few registers that need writing to. This is well documented on the Spectrum Next wiki https://wiki.specnext.dev/DMA.
There are seven registers called WR0 to WR6. Writing to them is like when we configured the sprite system in my other video. Each register is accessed through the same IO port and the pattern of the first three bits tells the DMA controller which register you're writing to.
The only thing to know is this is purely a DMA, it can copy continuous runs of bytes. It's not a blitter so it is unable to copy a rectanglular block of RAM.
Also for small copies, the setup and configuration may actually be slower than doing it by hand with memcpy. It's definitely something to use with large amounts of data though. A music playing routine running in a vblank interrupt would use this to feed the audio hardware with sound data.
Chapters:
00:00 Start!
00:45 What is DMA?
01:41 ZX Next DMA
02:01 The DMA Registers
02:32 Register WR0
03:10 Code example DMA Screen Copy
04:23 Register WR1
05:03 Registers WR2 and WR3
05:20 Register WR4
05:44 Register WR6
06:13 A note on writing to registers
06:45 Repeating DMA transfers
08:00 Closing Notes
Credits:
Casio Calculators - J. C. Barros from Portugal, CC BY 2.0, via Wikimedia Commons
Random images - Midjourney
Music - Epidemic Sounds
...
https://www.youtube.com/watch?v=6bd7LfCcID4
How I modified my Grandma Shark brand 937D+ soldering iron to be ESD Safe, so that it matches the logo they printed on the front of its case. This restores the connection between soldering iron tip and the earth/ground pin of the plug which the factory didn't bother fitting.
...
https://www.youtube.com/watch?v=0HdKISkCXIs