Monday, 10 February 2020

Reverse-Engineering An AdLib Clone: Part One

A long article, so part one is about creating the schematic, while part two is about fabricating, constructing, and testing the board.

Back in November of 2016 I was fortunate enough to acquire an AdLib clone via eBay. It had been sitting in someone's loft for goodness knows how long prior to being discovered and sold so it was in bad shape. I restored it fully, however, and it worked perfectly. For a short while.

My attempts to repair the card were rushed, clumsy and ultimately destroyed the board. For many this would be the end of the road, but instead I embarked on a project to recreate the card from scratch, such was its value and uniqueness. I thought I would share the process I employed to achieve this, now that I'm on the verge of ordering a replacement board.

The first step was to take a high resolution photo of the component side of the board in its original state. This was so I would know which chips went where, and what their orientation was. The only components on the rear were resistors and non-polarised capacitors, both SMD type.


Next, I desoldered the through-hole components.



You can see on the picture of the component side where I've scorched the PCB by leaving the soldering iron on it for too long. In removing other components I lifted some pads, too. To be honest this isn't much of an issue when you've already written off a board and intend to recreate it. I have since upgraded my equipment.

I then made a list of all the component labels, thanks to the handy silkscreen, on a piece of paper and desoldered the SMD components. I used tape to stick each of the components on the page next to each label with values where known, so I could store them safely and not get them mixed up with each other. While the resistors had standard markings on them for their value the capacitors did not, so I would have to measure those later.

The final step was to get very high resolution scans of the board so that I would be able to zoom in and follow each trace. I did this at 1200dpi, giving me five times more detail than photos would.



Removing the SMD components was a lot easier and you can see how cavalier I was with the rest of the board. Partly I blame 30 year old solder. Note how I have flipped the rear scan. This is so I can import the images to Photoshop and switch between layers, which makes it a lot easier to trace the vias. This board is well and truly toast by now.

Another layer I needed to introduce was pin numbers. When you're zoomed in close on a trace and following it to an IC, you don't want to be taking your eyes off the screen. Having the pin numbers visible makes it a lot easier to transfer the information to a schematic.



What's that you say? A schematic? Yes. I previously had very little experience of creating PCB schematics. As I using an Apple Mac most of the time, KiCad seemed like an obvious choice for the task. It's very capable, easy to learn, and is powerful enough to appeal to experts too. Much like with programming when I first started learning it, I thought I'd be crap at it. It turns out my sense for structure, organisation and clean layouts works in my favour for such things.

If you do want to get into reverse engineering, starting small is a good idea. My first project was to work out how the hell the control circuit in our cooker hood worked. It was misbehaving, it used a number of relays and other discrete components, and I figured creating a schematic would be the best way to study it - sometimes just looking at things makes my head hurt. Schematics create more of an organisational view of things, so that it can be a lot easier to see how power and data flow in a circuit.


Trust me, it didn't look this neat after the first attempt. Unless you've learned electrical engineering formally, making something like this is going to be an iterative process. First it will be a complete mess and won't make much sense. Over time, things like component placement will become clearer but it's hard to teach such a thing. I think having a feel for it helps.

I fully accept that I am naive about this stuff, so I'm probably not a great example to follow. I know nothing about best practice, procedures, standards, documentation or anything like that, but I've learned a lot from looking at other people's schematics. Examples I've looked at are Sergey's AdLib clone, a replica of the original, and even an s100 board with OPL3 and game port. The more complex the project, the more experience you're going to need.

Now the laborious bit - the reverse-engineering itself. It's a bit like trying to recreate a jigsaw puzzle that you've only got a photo of. I don't know if there's a particular method that is best, but here's what I did:

1. Place each of the ICs into the schematic. This is done with models of the component, which are drawings that include information on physical form, number of pins and their designation. While KiCad has a huge component library included and many more available for download online (if you can find them), when you're dealing with obsolete components they may not exist anymore. Not only does this mean that you might not be able to buy equivalent replacements, but you will probably have to make your own models. (More on this below).

2. Voltage and ground connections. Each IC has at least one pin for power and at least one pin for ground. Labelling this pins is the easiest way to start, much like finding the corners and edge pieces of the puzzle.

3. Connecting the other pins. This is like finding all the sky bits in the puzzle, or a particular building. In the case of a computer expansion card, this usually equates to bus connections. In this case it's the ISA bus, so having the bus connector on the schematic is a good start.

4 & 5. Laying out and adding smaller components. As you add more components and connections, the schematic is going to become increasingly complex. As a result you need to stay on top of how things are organised. Keeping discrete parts of the circuit together, but separate from other parts of the circuit, is helpful. For example, the Amstrad AdLib clone is made up of the following elements:

- Sound generator
- Amplifier
- Bus logic
- Game port
- Power supply
- Timer / buffer circuits

Some are connected to each other, some aren't. Often a naturally-fitting layout will become apparent. I wish I had kept a record of the iterations that were involved in refining my schematic as an example but, much like writing an essay or an article, incremental changes overwrite the old document. Version control only really comes into it when you have a complete, initial version.

6. Fine tuning and double-checking. More than once I checked each trace from each pin on the ISA bus edge connector and each trace from each IC pin. Looking at schematics of other, similar projects can help to build a familiarity with how the circuit should work, so you can look at it and think "hmm... that ain't right" and then focus on a particular section until it makes sense.

I've never published a schematic before and I'm 99.999% sure that I've not made any mistakes but, until I build and test the board, I won't truly know.

Here's what I've produced so far, and here's a link to the PDF version.



There is a workflow that is managed by KiCad that goes in this order (summarised from this page):

1. Eeschema - schematic design and component model creation. This includes the electrical rules check, which ensures that the circuit works in theory. Errors highlighted in this check require returning to the schematic and fine tuning it.
2. Cvpcb - step one establishes how each component is connected in the circuit. Step two relates a physical footprint for each component to the eventual format of the PCB. The first two stages produce a netlist, which is the basis of step three.
3. Pcbnew - footprints are placed on a blank canvas and physical copper connections are laid out. There is a certain amount of automation available here, but it's mostly a manual process from what I understand. (I haven't done this bit yet...) This can then be checked with design rules, which ensure tracks aren't too close together, etc.
4. Gerber - this is a set of files that are used by a fabricator to make the actual boards. The closer the relationship between the PCB designer and the fabricator, the quicker errors or changes to the design can be realised. This is why it pays to spend more time getting things right if you're one person who is sending your stuff off to a fab in China. A mistake could cost weeks of progress.

Luckily I'm not in a hurry. At the moment I'm just making a replacement board for myself but I fully intend to publish the final schematic and related files when it's complete so anyone can if they want. One major obstacle to this additional step is that I need to find equivalent replacements for the SMD ICs this particular card uses and, if I can't, I might even redesign the board to use through-hole components instead. I guess we'll see.

Sunday, 9 February 2020

The Sound Blaster Fairytale

I read with interest The Sound Blaster Story on the Custom PC website today yesterday a few days ago. Except replace the word 'interest' with 'disdain' and 'The Sound Blaster Story' with 'a highly questionable piece of journalism'.

The article, written by CPC's editor Ben Hardwidge, is actually an interview with Creative Labs founder Sim Wong Hoo. I suppose you could call it a story in the sense that Jack and the Beanstalk is a story. A tall one. One that should be taken with a massive pinch of salt. Or located firmly in the fiction aisle.

I don't think anyone expects an article like that to cite sources but it's preferable if you'd like to avoid plagiarising, which the article isn't far off doing. The preamble to the interview is startlingly similar to excerpts from the 1998 book Asia's Computer Challenge. Aside from being written some ten years after the events it summarises (poorly), this book claims the "Sound Blaster hit the market just as Intel's 386 card [was] arriving..."[1This is no way to establish technical credentials. It gets better worse. The question that seems to have got everyone pretty animated (me included) from the original version, since corrected(!), was this:

"The first Sound Blaster used a Yamaha OPL2 FM synthesiser, making it AdLib compatible. If AdLib hadn’t done this first, do you think the first Sound Blaster cards have had [sic] different MIDI synthesis?"

Oops. MIDI synthesis is not a thing, but I'm not even going to get into that. I found Sim's answer to be far more interesting and far more problematic:

"The first Sound Blaster did have a different music synthesis system – that was already in our Cubic CT PC in 1986. In fact, the first generation of Sound Blaster supported both the Yamaha OPL2 FM synthesiser and our own 12-voice synthesiser, so by default, it automatically supported a wider range of software from the two standards, giving users the best of both worlds."

My proof-reading wife, a lay person, chuckled at this almost as much as I did. This is because Creative's different music synthesis system was shit[2][3][4and Sim should not be suggesting otherwise. He also quite clearly bristles at the use of AdLib and first in the same sentence like it never happened or was inconsequential. This really couldn't be further from the truth.

Advert For The Creative Music System. Source: PC Resource's PC Games, Autumn '88

Technical Limitations


The Sound Blaster's predecessor, the Creative Music System (C/MS, later rebranded Game Blaster) was released in 1988[4][5][6][7][8][9][10] (despite what other sources might say[2][11][12][13][14][15][16]). At this time there were a number of PC sound products available, the most notable being the AdLib, using Yamaha's successful FM synthesis, and Roland's MT-32 using premium LA synthesis. The latter actually isn't a sound card, but deserves a mention because it was as well supported in games as the AdLib. Each of these products were originally intended for the PC-toting musician but generally poor sales initially suggest consumer apathy.

Creative's first two sound cards used square wave synthesis exclusively. This attempts a trade-off between the qualities of a sine wave and a sawtooth wave, but ultimately achieves neither[17]. While they produce fair instrumental sounds[18], square waves are pretty crap at replicating percussion, thereby limiting their versatility. FM synthesis, on the other hand, is vastly superior in comparison[19]. The C/MS did output stereo, however, and this appears to have been how Creative tried to stand out from the competition. The limitations of the C/MS did not appeal to developers, not helped by the fact that the technical documentation did it no favours[20]. A much more interesting question to Mr Sim would have been why Creative chose Philips' product in the first place.

So the AdLib was technically superior, attracted more developers, and was released over a year before the industry heard of the C/MS or Game Blaster. Additionally, this OPL2 synthesiser Sim is talking about that Creative included in the Sound Blaster essentially WAS the AdLib. Observe:

AdLib Compatible: An Advert for the Sound Blaster. Source: Compute! Apr '90

Creative With The Truth?


To be fair to Sim he's actually an interesting guy and something of a philosopher, based on other interviews[21][22], but the true Sound Blaster Story is that Sim is a bit of a lunatic. Wait, that's not always a bad thing, right? Many successful technological dynasties have been built on the drive and passion of lunatics (Apple, Microsoft, Oracle, Amazon, Tesla...) and they wouldn't exist otherwise. I'm just saying it also means their portrayal of historical events shouldn't be taken as Gospel. He still cannot, to this day, give Ad Lib Inc. even a crumb of credit for their contribution to the development of audio hardware on the PC, efforts that were indisputably critical to Creative's eventual success.

If I haven't convinced you of this pattern yet, there are examples where Sim seems unsure about the history of his own product and, at worst, he intentionally misleads. Later in the CPC interview he claims:

"At Comdex, people lined up in 20-person queues in front of three cashiers in our tiny 300 square foot booth – we sold one Sound Blaster every four minutes."

Now let us expand this nugget by looking at the same claim from Sim's 2003 book, Chaotic Thoughts From The Old Millennium[23]:

"...over the five days of the trade show, sold 600 units of the sound card – one order every four minutes."

Source: InfoWorld, Dec 1990 
One every four minutes certainly sounds impressive but in the context of 600 in five days what does that actually mean?

600 cards / 5 days = 120 cards per day

I don't know what the hours of Comdex are but to get an answer of 4 we need to divide 120 cards by 30. That's 30 minutes. The stall was open for 30 minutes each day or they were only taking sales for 30 minutes? I'm confused. Even if we recalibrate for the 3 cards per minute claimed elsewhere[24] that's 40 minutes. Either I'm doing this wrong or this cards/minute figure is dodgy.

Either way, it took more than a few sales at Comdex in '89 to launch the Sound Blaster. Sim was giving them away at some point before December 1990 (see right), much like AdLib did with their early cards[25], so we can safely assume they weren't killing it just yet. Ultimately they did, of course, and they well and truly buried Ad Lib's asses in the desert. even if it did involve some seriously dirty tricks like manipulating the QA process so the newest AdLib was massively delayed[25].

History Is Written By The Victors


I don't like that Sim has attempted to maintain a narrative that Creative built the sound card market from nothing. It's complete bollocks and Sim's claims should be regarded as anecdotal at best. The Sound Blaster succeeded for two reasons: AdLib compatibility and a built-in game port[25], a particular technical efficiency that most people today wouldn't appreciate. It certainly did not sell for its best of both worlds synthesis for the reasons mentioned previously. No one asked for Game Blaster compatibility and no other device supported it. It was 'useful' in the Sound Blaster purely for backwards compatibility. Sound Blaster also didn't succeed because it offered digitised sound. Not initially, anyway, as this was still a gimmick in PC land. It also wasn't because it supported a wider range of software because only one game that we know of (Airball[26]) supported C/MS and not AdLib.

The bottom line is that the first two standards in PC game audio were AdLib and Roland. PC speaker aside, almost every PC game supported these two products by the time the Sound Blaster came along. As a direct result every subsequent product had to support at least one of them or be doomed to obscurity.

Just because Creative won out, it doesn't give Sim the right to misrepresent the events that built up to it. It took me three days to write and research this article so that I could reliably prove what actually happened. If we want to hold a historical record of creativity in our industry then it's what we all should be doing. And it's not that hard.

Sources:

1. Dedrick, Jason, et al. (1998) Asia’s Computer Challenge: Threat Or Opportunity for the United States and the World? Oxford University Press, USA.
2. Game Blaster & LAPC-I (crossfire-designs.de)
3. The History of Sound Cards And Computer Game Music (Computed Blg)
4. C/MS Review (PC Mag, 29 Nov '88)
5. When Sound Came On A Card (PC Mag, Feb '16)
6. Wave Of The Future (Wired, Mar '94)
7. Sound Board Duet (Compute! Oct '89)
8. IBM PC Ramblings (oldskool.org)
9. C/MS Advert (PC Resource's PC Games, Fall '98)
10. The Gamer's Guide To Sound Boards (CGW, Sep '89)
11. Corporate Milestones: 1986 - 1990 (Creative Labs)
12. Game Blaster (Pixelated Arcade)
13. Sound Blaster Reference (Wikipedia)
14. Purcaru, B, I,. (2014) Games vs. Hardware. The History of PC video games: The 80's. [online]
15. Creative Labs Soundcard Overview (The Guru of 3D, Mar '06)
17. A Young Person's Guide to the Principles of Music Synthesis (Beau Sivers, Nov '06)
18. Guide To Subtractive Synthesis (Roland)
19. Dune Soundtrack (Adlib) (YouTube)
20. All You Ever Wanted To Know About C/MS (Nerdly Pleasures)
21. Sim Hong Woo Is Back (SGSME, Jan '19)
22. 'Don't Get Married' (Yahoo Finance, Apr '19)
23. Sim, W. H, (2003) Chaotic Thoughts from the Old Millennium. National Library Board, Singapore.
24. Creative Technology (Singapore Infopedia, 2016)
25. Rick Heimlich (Topstar) Interview (YouTube)
26. Airball Tech Specs (Moby Games)

Thursday, 15 November 2018

The Web As It Was Part One: Before 1999

Introduction


To begin, this article won't make much sense if you don't know the difference between the Internet (capital I) and the Web (capital W). There are definitions at the bottom of this page but the TL;DR version is that the Internet is the 'hardware' that connects the world's computers together, and the web is the 'software' that runs on it.

I couldn't tell you the first time I heard of the Web, but the first time I accessed it was in 1997. It was at the opening of Simply Computers' new warehouse and store on Blackhorse Road in London. Although I don't remember the exact date, I do remember that Gary Mabbutt (former Tottenham Hotspur team captain) was the 'celebrity' who was invited along to cut the ribbon so for me, as a Spurs fan, this was a bonus. Simply were the first people I bought PC hardware from, specifically a CD-ROM drive and a Sound Blaster AWE32 (and probably some RAM). At the event they had a room tucked away with a bunch of PCs made available for 'surfing the web'. I don't know if you've heard of Web 2.0, but that didn't happen until about 2002 - this was very much Web 1.0.

This article has been made possible by the amazing efforts of archive.org's WayBack Machine, an archive of the Web's history since 1996.

Web 1.0


The initial format of the Web largely comprised static pages of information provided by companies, corporations and organisations. Designs were simplistic owing to HTML having not been developed significantly and were characterised by the Times New Roman font, low res images (if any) and tiled backgrounds. Here's what Yahoo looked like in October 1996:

Yahoo
This was well before Google was a thing. Another site frequently used was AltaVista:

AltaVista
Witness one of the oldest irritations known to the web: the banner ad. Oh and buttons usually with bevelled edges for that 3D look. It's just how things were done back then, mostly due to the standard domestic dial-up connection only being capable of 33.6Kb per second. That's kilobits, not kilobytes. Divide by 8 to get the latter. Even the tech giants couldn't make much more of the web than the markup language at their disposal. Check out Apple's 1996 homepage:

Apple Computer
In many cases the image files were not archived with the HTML so there are visible gaps. This actually adds to the authenticity of viewing web pages back then, because it would take significantly longer for any image data to download than it would the text. In fact, many people unchecked the 'display images' box in their preferences for speedier loading times. As a result, webmasters tended to be dillgent when it came to filling in the alt text box, which is the text displayed if the image isn't visible. You may wonder why this feature is still used today - for accessible web pages, the alt text is used by text recognition software to read out the captions. Also notice the 'where to buy' link - no e-commerce here.

One of the most remarkable things was the amount of screen real estate these pages used. These images are the actual size of the web page as it is displayed. Most were designed with an 800 x 600 pixel resolution in mind, if not 640 x 480. That's certainly the resolution I was using with Windows 95 until I upgraded my monitor in 1999. It could also be said that 'web sites' weren't really a thing either. These were homepages in the truest sense of the word. Check out id Software's site:


Quite impressive by comparison. I like how much mood they've managed to get in there, despite the limitations of the technology. Note the 'text only' option.

But it wasn't all big business and corporations. There were a small number of hosting services at this time, such as Demon and Cityscape, who provided an enormous 1MB of space for individuals to showcase their own nascent web design skills. Here are some classy examples.

The Animated Reid Family Homepage
Check Spurs Results Year by Year

You can check out the full list of sites here and it really is worth spending some time scrolling through and looking at what was on offer. The ones above are actually relatively bearable and informative compared to some. The struggle between content and appearance (and legibility) has been waged for an eternity. The site below is much more like the kind of thing people would produce with their newly-learned html skills:


Just because you can doesn't mean you should. Yep, garish was the style of the day, along with obligatory 'under construction' message (made with WordArt, I believe). There were some semi-useful pages though, striking that balance between form and function pretty well:

Sean O'Connor's Windows Games
Game demos were the kind of thing you could only get hold of on magazine coverdisks or, if you were a bit more nerdy and could afford the phone charges, bulletin boards (BBS), so being able to download games from the Web would have been pretty cool back then. Windows 95 combined with an Intel Pentium-based system had caused rapid expansion of the home PC market and you could even get Windows 3.11 connected to the Web. But it was Win95 that got Microsoft in such big trouble in 1998. Although we're accustomed to the notion of web browsers being free to download these days, browser sales were a fundamental part of Netscape's business model so, when MS started bundling Internet Explorer with Windows and making it available as a free download, Netscape collapsed and the US Government took MS to court in a landmark antitrust suit. But I digress.

Notice the multiple download links in the site above. When the Internet itself was still relatively slow, there were geographical considerations when downloading large files. With intercontinental links still developing, it was usually significantly faster to download a file that was located closer to your own country than one on the other side of the world. The longer the distance, the higher the likelihood of dropped packets, which exponentially increased the time it would take to complete a download.

That's all for part one. Part two will look at when I got my own Internet connection for the first time and created my very own website...

Glossary


The Internet (noun): also called 'the Net', a worldwide network of smaller geographically-limited computer networks. Originally ARPANET, a communications network linking U.S. government facilities and universities / research centres. Established in 1969, it was the first network to use the TCP/IP (packet data) protocol. It differs from the basic model of a WAN in that there are multiple geographical routes to any node on the network rather than one. This betrays the vulnerability of physical network links, and the need to build in redundancy in the case of a failure. Traffic is directed by devices called routers, utilising Dijkstra's algorithm (among others) to calculate the shortest path between a start and a destination, potentially with multiple 'jumps' on the way.

The World Wide Web (noun): also called 'the Web', a virtual space for sharing information, utilising the Internet to communicate data and using hypertext to link resources with Uniform Resource Locators (URL) to provide an address (web address).

Thursday, 8 November 2018

Game Gallery: 486 to Pentium

In 1995, I finally ditched the 386 and built my first PC. I searched through magazines for months, researching the best value components and finding the best prices I could. A whole world of games I had never previously been able to play were suddenly at my mercy.

For me, this era was the Golden Age of PC gaming. The things had had been holding the PC back as a legitimate gaming platform (most people had a console or an Amiga for that) were suddenly being addressed apace and, ironically, this was all down to Microsoft Windows. The need for higher bandwidth graphics to adequately run a GUI brought in local bus technology such as VESA Local Bus and PCI. Clock doubling revolutionised CPU speeds and then, in 1993, Intel's Pentium was released. Although out of reach for most home users, developers such as id Software harnessed the additional horsepower to create Quake. Both that and Doom were so revolutionary that I (and others) were willing to play them at a snail's pace on outdated hardware because they were that good. They were also the reason many people upgraded.

Wavetable audio also became standard on desktop soundcards, Windows 95 was released and, in around 1997, 3DFX completely changed the game. Although the name fizzled out in the wake of competition from ATi and nVidia, it kicked off the 3D graphics revolution.

It was also during this time that gaming on Windows really took off with the development of DirectX and DOS gaming slipped away into the past. It had a good run and produced some of the most iconic gaming titles of all time. Here are the ones I played over and over again, and still play today.

All screenshots originate from Moby Games, and each game is linked in the caption.
Battle Isle 2 (1994)
Beavis and Butthead in Virtual Stupidity (1995)
Big Red Racing (1995)
Bioforge (1995)
Blackthorne (1994)
Blake Stone: Aliens of Gold (1994)
Carmageddon (1997)
Comanche: Maximum Overkill (1992)
Corridor 7: Alien Invasion (1994)
Cyclemania (1994)
Dark Forces (1994)
Delta V (1994)
Descent (1995)
Destruction Derby (1995)
Doom II (with Simpsons mod) (1994)
Duke Nukem 3D (1996)
Earthworm Jim (1995)
FIFA International Soccer (1994)
Fade To Black (1995)
Fatal Racing (1996)
Grand Prix II (1995)
Grand Theft Auto (1997)
Heretic (1994)
Hexen: Beyond Heretic (1995)
The Hive (1995)
Hi-Octane (1995)
IndyCar Racing (1993)
Magic Carpet (1994)
Mechwarrior 2 (1995)
NASCAR Racing (1994)
Need for Speed (1995)
One Must Fall 2097 (1994)
Pyrotechnia (1995)
Quake (yes, it struggled) (1996)
Raptor: Call of the Shadows (1994)
Rise of the Robots (1994)
Rise of the Triad (1995)
Rebel Assault (1994)
The Scottish Open: Virtual Golf (1995)
Screamer (1995)
Swiv 3D (1996)
Terminal Velocity (1995)
TIE Fighter (1994)
Tubular Worlds (1994)
Turrican II: The Final Fight (1995)
The Ultimate Doom (1995)
Virtual Pool (1995)
Wipeout (1995)
Worms (1995)

Revisions


18 November 2018: added Mechwarrior 2, Beavis & Butthead and The Hive.