Oldskooler Ramblings

the unlikely child born of the home computer wars

Archive for the ‘Vintage Computing’ Category

8088 Corruption Explained

Posted by Trixter on May 13, 2007

I had hoped to completely update the 8088 Corruption webpages before posting this, but it’s going to be at least another week and people have been asking me for it, so: An edited video of my NOTACON/Block Party 8088 Corruption Explained talk is available at archive.org. All of the embarrassing and missing parts have been fixed, added, edited, massaged, spindled, and mutilated, and it should be completely watchable. I replaced most of the bad video-camera-aimed-at-the-monitor footage with the actual conversion footage, filled in the hey-where’d-my-electricity-go? missing section with a voiceover, replaced all filmed slides with the actual slides, and took out two embarrassing swears (embarrassing not because they were swear words, but because I was nervous and stumbled over them).

While it is tempting to watch the flash version in a browser, I went through a great deal of trouble to make the MPEG-2 version perfect, including true 60Hz video in places. If you can spare the time, grab the MPEG-2 version and watch it on a real set-top dvd player for full effect. (Or a software player that isn’t broken; for example, use my favorite MPEG-2 player, VLC, with Deinterlace set to Linear.)

Work and home have been particularly busy this week and will be next week, so I apologize in advance for not having the extra movies, updated 8088 player, full source code, etc. available on the website yet. When I do, I’ll make a note of it in this blog.

Posted in Demoscene, Programming, Technology, Vintage Computing | 6 Comments »

The crazy upside-down world of 8088 hardware programming

Posted by Trixter on March 28, 2007

I’m rewriting the 8088 Corruption player for the talk I’m giving at Block Party. No doubt this is a form of procrastination (I haven’t even done any PowerPoint slides yet) but I also have a fear of the player crashing when I’m showing it off, which would be a serious blow to my fragile ego. For one particular demonstration, I was going to wow the audience with a double-rate version of Corruption. Yes, 60 frames per second on an XT. The memory speed is there, but there’s so little CPU time left over that the poor disk can’t keep memory filled, and it rebuffers constantly — every four seconds, which is hardly fun to watch.

(This is going somewhere; trust me.)

Although it would be “cheating”, I have a hardware LIM EMS 4.0 board in my 8088 with 2MB of RAM in it. Last night I started to write a version of the player that buffered to EMS, then to system RAM where it could be transferred to CGA RAM. I figured, hey, maybe I can delay the rebuffering for a few more seconds for the presentation so I don’t look like an idiot.

I found that doing so was slower than simply reading the data from disk right into regular memory. You read that correctly: RAM buffering was slower than hard disk buffering. WTF?

I thought about why this might be, and when I figured it out, I started laughing. It’s a perfect example of just how wrong it is what I’m doing. Here’s the explanation:

  • Old IBM PCs have a DMA controller in them to move memory around instead of forcing the CPU to do it. On a PC/XT, it’s primarily used when reading from disk, because the slower the disk, the slower the transfer and the longer the CPU would be hung up. The DMA controller can move a byte of memory in one cycle, giving it a maximum memory move speed of about 960KB/s.
  • My hard disk, however, is not what the DMA chip was designed to help with — it’s a 340MB IDE drive connected to an 8-bit IDE controller. It’s about 5-10x faster than what was available in 1983. It maxes out around 300KB/s.
  • Moving memory around maxes out at a top speed of 240KB/s.

Do you see where this is going? I’ve put a hard disk in my machine whose transfer speed, thanks to copying help from the DMA controller, exceeds the CPU’s ability to move memory around. Let’s word that another way in case it’s not obvious: The hard drive is faster than the RAM.

That’s just wrong.

It is probably the only configuration in the entire IBM PC/compatible family where this is the case (where the hard drive is faster than RAM). Any 286 or higher, with its 16-bit memory accesses, would be faster at moving memory around. Crazy upside-down world of 8088 hardware!!

So I’ll use this newfound realization to write a DMA version of the player to keep memory filled while playing, right? Nope. The only way to do that is to switch to reading absolute disk sectors, and that means the player would work on my machine only. Not an option.

Posted in Programming, Vintage Computing | 4 Comments »

8088 Textitude

Posted by Trixter on March 26, 2007

This weekend was spent obsessing over the fastest text editor I could find for a 4.77MHz 8088 that had a functional undo. The results were a bit too lengthy for a blog post, so you can view the article I posted regarding the subject.

Nerd Alert:  If you’ll never type on an XT for more than 10 minutes at a time for the rest of your life, don’t bother reading the article.  There are much better things to do with your time :-)

Posted in Technology, Vintage Computing | Leave a Comment »

Post something, dammit!

Posted by Trixter on March 17, 2007

That was the IM I got from a “friend” who shall remain “nameless” who was “unhappy” with the state of my “blog”. Fine, so I’ll post something, but for the record I have had excuses for not posting the last four weeks:

  • Not losing weight, so that alone is depressing
  • Went to GDC and was very sick the entire damn time (although I did have some good experiences; more on that later)
  • Still sick 2.5 weeks later (yes, I’m seeing a doctor)
  • Weathered a layoff storm at work, sometimes violent, sometimes petty
  • Child problems at school

etc. etc. My life is actually quite privileged, and it sounds utterly ridiculous to complain, but I am human, which means I’m damaged, and this stuff affects me. I know it’s irrational. I’m sorry.

So, until I can lose some weight or report on some other stuff that is actually interesting to someone, I’m going to Post Something Dammit. Today’s PSD is on the topic of: 8088 CPU bugs. It’s time for some st00pid k0mp00ter history! Yes, the 8088 had bugs in the first iterations. Forget the Pentium FDIV bug; they’ve all had issues from day one :-) Two of the bugs were caught by Intel in 1982-ish, but not until 200,000 IBM PCs were sold. The third was fixed in the 80186.

The first two bugs involved interrupts and the stack. The first bug was that a MOV to SS (the stack segment) did not disable interrupts for the next instruction, meaning that you could get an interrupt in the middle. This is bad, because the interrupt will try to set up it’s own stack (something you were trying to do with the MOV SS!) and the stack is unlikely to recover, taking the machine with it. The workaround was this:


CLI
MOV SS,DX
MOV SP,AX
STI

ie. disable interrupts before you do the switch, then re-enable them when done. Which sucks, but is a good practice that I would imagine most people were doing anyway because they didn’t know that MOV SS,reg was a special case that was supposed to disable interrupts. Hell, I didn’t even know that until I started researching the bug.

But not all was good in Intel land: If you didn’t know the state of the interrupt going in, then you were supposed to preserve it, like this:


PUSHF
POP BX
CLI
MOV SP,word ptr [my_stack]
MOV SS,word ptr [my_stack+2]
PUSH BX
POPF

…except there was a second bug in the original 8088 in the POPF opcode which meant that, even if the state was still CLI after the POPF, interrupts would still be enabled for a single cycle! Try tracking THAT bug down in your program! So the workaround, which is just st00pid, is to fake POPF using IRET. (BTW, the odds of this particular bug cropping up is somewhere in the neighborhood of 1 in 5 million, and only when you switch stacks, so it is such a longshot that I never bother in my own code.)

But wait, there’s more! There’s a third bug where, if you try to use a segment override on MOVS or LODS (ie. so you can attempt to use something other than DS as the source) and an interrupt fires off during, say, a REP MOVSW, it stores the wrong return address. This was fixed in the 80186… I think. Not sure. I’m not sure that behavior is even officially documented so I’ve never had the urge to try it.

Posted in Programming, Technology, Vintage Computing | 2 Comments »

Mirrors in DOS

Posted by Trixter on January 27, 2007

So now that I have this giant extra drive on my XT, what should I do with it? Other than the obvious frivolity (such as an entire movie 8088_corr style), backups is the obvious choice since I still actively develop software on it. The best way to do this would normally be rsync, but since I haven’t come across a 16-bit DOS port of rsync that functions properly, the obvious alternative is XXCOPY. Why XXCOPY and not DOS’ XCOPY? Because XXCOPY has rsync-like functionality, where you can have it copy only changed files and also delete non-existant files/dirs in the destination. In other words:

rsync -va --delete <source> <destination>

…is handled by XXCOPY thusly:

xxcopy <source> <destination> /clone /yy

And best of all, the author of XXCOPY is the guy who coded Mad Planets, which was an 8086, so compatibility with my XT is all but assured! (rubs hands in glee)

Posted in Vintage Computing | Leave a Comment »

The Mighty Mite

Posted by Trixter on January 26, 2007

I’ve added a CompactFlash II memory card to my XT. And it was surprisingly easy, cheap and fast! Since CompactFlash essentially follows the IDE spec, you can get gaggles of CF-to-IDE adapters from ebay for single-digit dollars, including shipping. I grabbed one, stuck an IBM Microdrive 320MB CFII card into it, and now my XT has a giant (for an XT) second hard drive on this tiny little card!

(Confession: I lied about the “easy” part. It’s very easy to physically attach the thing to the cable… it’s incredibly difficult to find an IDE adapter that works in an 8-bit ISA slot. I lucked out and found a Silicon Computer adapter (ADP50, I believe) online somewhere for cheap, but they’re incredibly uncommon.)

So, how are the benchmarks against the actual Maxtor 340MB drive that’s also in the machine? Spinrite sez:

  • Maxtor 340MB, circa 1994:
    • Average Seek: 18ms
    • Sustained transfer rate: 321KB/s
  • IBM CompactFlashII Microdrive, 320MB, circa 2002:
    • Average Seek: 25ms
    • Sustained transfer rate: 322KB/s

Well, I think it’s obvious both drives can go much faster; it’s the 8-bit ISA interface that is holding them back. Still, that’s incredibly fast hard drive access for an XT; the only faster times I know of have been obtained by my friend Michael Brutman, who has SCSI boards in his machine. SCSI isn’t a faster disk technology, but the interface boards sure are (they are memory-mapped, which means disk transfers go right into system memory, as opposed to traditionally being stored/moved by the DMA controller.)

Should you do this with any CF card you have lying around? Yes… but only if you aren’t going to write to it often. Flash is only guaranteed for something between 10,000 to 100,000 writes, then it starts to disintegrate. The only exceptions I know of are IBM Microdrives, because they’re not actually Flash memory at all — they’re tiny hard drives! Read performance is worse than actual Flash, but you can write to them all you like.

Posted in Vintage Computing | Leave a Comment »

CGA Corruption

Posted by Trixter on November 8, 2006

The majority of my 15 minutes of fame, it seems, has come from google video and youtube, with my 8088 Corruption demonstration. I did it mostly to impress other demosceners at a wild compo, but I’ve received at least 100 emails about it, had it reverse-engineered, and had unix and gameboy players made for the data file… it’s quite humbling.

Ever since then, people have asked for more. While I can easily do more — the framework supports 60 frames per second instead of the 30 used in 8088 Corruption, and let me tell you, 60fps CGA video is wickedly creepy — I have always wanted to do a “proper” 8088 megademo. This means it would work off of two floppy disks, use no more than 640K of RAM, use the internal speaker for sound, and of course, work with stock CGA.

That may not have the “wow” factor of 8088 Corruption, but just like the numa numa guy, you can never really make a sequel to an internet phenomenon, can you? It never turns out as good. So I’ve pretty much made up my mind that, should I ever have the free time to make another oldskool demo, it will feature — amongst other things — 60Hz CGA demo effects.

I can hear it now: “CGA demo effects? CGA sux! CGA has 4 ugly colors, slow memory, and only one video page! What are you going to do, make it look even shittier?” Well, non-believer, I’ve been dorking with CGA for a while and have already come up with some neat stuff. But the concept went into 2nd gear when my old friend Andrew Jenner (the guy who reverse-engineered Digger) contacted me with some CGA questions and we got to talking, then experimenting. You see, Andrew has been working with the MESS guys trying to get their CGA emulation 100% perfect, and has been studying the Motorola 6845 character generator documentation and CGA tech reference for weeks, so he had some unique insight I never had the patience for.

Here’s a taste of what we’ve been able to do with stock CGA on a regular XT:

100% successful:

  • 160×200 two video pages
  • 320×100 two video pages
  • 256×128 two video pages (great for sprites)
  • 320×100 full-screen interleaved with two video pages
  • the ability to shift the screen left and right in two-bytecolumn increments on any scanline

50% successful:

  • 640×200 in 4 colors (not a typo!) but every other column doesn’t latch memory quickly enough so every other bytecolumn is garbled)
  • 320×100 full-screen non-interleaved (desired scanline pattern would be aabbccdd but it comes out ababcdcd)
  • 160×400 interlaced (both sets of lines are generated properly by the MC6845, but the surrounding CGA hardware doesn’t half-shift the second set so you get 200 flickering lines instead of 400 individual lines)

Should Be Possible But Untested Due To Lack Of Time:

  • Changing display memory offset every other scanline
  • The ultimate bomb: Text and graphics mode splitscreen! I’m serious!

When I have trouble falling asleep at night, I think of the possibilities… then shortly before I drift off to sleep, I remind myself of what a colossal nerd I must be. But still, it’s very satisfying doing things that nobody else has done, let alone even thought of.

Posted in Demoscene, Vintage Computing | 11 Comments »

Government workers are so very helpful

Posted by Trixter on October 25, 2006

In all my days of computing, the software that has impressed me the most has been software that pushes a machine seemingly beyond its limits, making it do things that it was never meant to do. One such piece of software was ICON: The Quest For The Ring. It tweaked CGA to within an inch of its life, displaying 16-color graphics on a video card only meant for four ugly colors in graphics mode.

I’m a software collector. I collect vintage retail packages of software as a hobby. (I’m comfortable enough with my nerditude to admit this, so go ahead and mock me — I don’t mind.) So imagine the nerdly dance of joy I did when I found that ICON was up for auction, bid on it, and won! The package I’d been searching for for over two decades, the game that had inspired me to learn assembler and graphics tweaking, the game that shaped my hobbyist world, would finally be mine!

That’s where the governmental workers come into the story. It seems that they were in need of a football to relieve the overwhelming tension and stress of delivering packages, so what I actually received was this:

If you’re not familiar with the hobby of software collecting, I can sum it up in five words: The Value Is The Box. 90% of a software collectable’s value is in how good a condition the box is, then the printed materials inside it, then the diskette labels, then finally the actual software code itself. (Why? Because most software has been pirated already… and most people throw away the box and lose the manuals.)

My twenty-year dream quite literally crushed, I decided to visit my local US Postal Services office to file the claim for the $50 I had paid for it. And this is where we again meet our lovable and cute governmental workers, for here is what I learned today about insuring packages:

  1. You have to provide proof of the item’s value. So if the USPS determines that your item is worth less than what you insured it for, and you cannot provide any “documented proof” (the validity of which is at the government worker’s discretion, of course) that it is worth more, you get what they are willing to give you, not what it is actually worth. This is how they justify giving you less money than the value you wrote down on the form when requesting insurance, they always offer a very cheap car insurance but then you end up with such bad service or no service at all.
  2. You cannot insure something for more than what you paid for it. See #1 for rationale. So if you completely luck out and find an Akalabeth with a Buy It Now of $4, the most you can insure it for is $4 even though its value is anywhere from 10 to 150 times that value.
  3. If your item is only slightly damaged, and you want to keep it, you can’t. You must completely give over every single thing you are filing a claim for, never to be seen again. This means that there is no protection against *partial* damage — if it’s partially damaged, bend over, since you can’t get partial money for it.

See, all this time I was under the silly impression that, if you insured something for a certain dollar value, that was the value they were going to give you when you showed them it was damaged. Or that maybe, just maybe, you were insuring it against partial damage — like depreciation or something. How wrong I was: Insurance is only protection against complete and total destruction of property and/or complete and total loss of delivery. If it *arrives*, and is only *somewhat* damaged, you’re shit out of luck! How glad I am to be educated! (although I could have done without the “bending over the table” portion of my education)

So what did I do? I made the obvious determination that something I had been searching two decades to locate — in *any* condition — was worth more than the $15 or so they were going to give me for it. So I tore up the claim form, took back the item, and left. Since then, I have been researching cardbox box reconstruction techniques, for I am not only a nerd, but a stubborn nerd.

About the only satisfaction I got from today’s visit was the audible popping noise the government worker’s synapses made snapping apart into individual neurons as I tried to explain that, yes Daisy Mae, the value really was the BOX itself and not the contents inside it. The complete and total lack of understanding confused her to such a degree that she was unable to blink her eyes in unison for at least 10 minutes after I stopped talking. I could have done without the drool, though.

Posted in Gaming, Programming, Software Piracy, Vintage Computing | 5 Comments »

Patience

Posted by Trixter on May 24, 2006

I never said I was a patient man. As a young teen, I would cheat on book reports by reading the Cliff notes or watching the movie. I would rush to the 7-eleven directly after school on Fridays to grab the latest comic books (this is before all the comic shops standardized on Wednesdays, obviously). I loaded COMMAND.COM into a RAMDISK so I wouldn’t have to keep replacing the floppy boot disk after I ran large programs. That sort of thing. Well, I squeaked through high school. I eventually gave up reading and collecting comics. I got a hard drive in 1990 and stopped booting off of floppies. A lot of my issues corrected themselves as I got older.

Except Hack.

In January of 1985, the very first game I played on the family 8088 was Hack. It was given to me by a friend of my brother’s, and it was yet another life-defining moment; the good kind, where it shapes you positively while you’re not paying attention. Being the first PC game I had access to (my prior pirating experience was Apple II), I was determined to give it a shot. Ironically, getting Hack up and running involved some hacking in and of itself: You had to alter config.sys to add ansi.sys; you had to alter hack.cnf to define how many drives you had, or a hard disk; you had to learn several bizarre movement keys like K for up, J for down, and other stuff that didn’t make any sense. It almost wasn’t worth the trouble for a young PC user.

Once fired up, Hack treated me to a complex dungeon where almost anything could happen: Shoot a bolt of fire, have it bounce off a wall, and ricochet back to hit you and catch your scrolls on fire; or kill an animal that turns people to stone, put on some gloves, and then use the dead carcass to turn enemy monsters into stone; etc. It was complex, it was deep, and it was wonderful.

It was also harder than a motherfucker. Hack, and its descendant Nethack, are some of the less forgiving members of the Roguelike family. It was relatively easy to go from king of the world to king of the dead in as little as a three moves. Every new machine I bought or built would get Hack installed as a nice little “initiation”, and every time I wouldn’t finish. I’d fire it up a few months later, 5 or 10 times a year, still wouldn’t finish. I’d cheat terribly, even finally finding the Amulet of Yendor, and the game would catch me cheating and write “You escaped with a CHEAP PLASTIC IMITATION of the Amulet” to the high score file. The screams of frustration were audible for several city blocks.

I got better. I found all sorts of things totally by accident. Eat a floating eye and you get sick, but if something later blinds you (like a flash of yellow light, or a potion of blindness), you can suddenly see ALL of the monsters in the level. Get drunk and read a teleportation scroll, and instead of teleporting somewhere else in the level, you teleport to a different level entirely. The more I played, the more I discovered. (I also discovered later in life that hack had prepared me for Unix administration, since the movement and option setting keys are identical to the “VI” file editor.) Yet I still didn’t finish.

Two weeks ago, I decided to play Hack on my 8088. I had forgotten how slow it played; the more monsters that were roaming the level you were on, the slower it took to respond. And it was then that I realized I could use that artifact of processing speed to my advantage. Most of the time that I had died, it was through some incredibly stupid event, like a dragon turning the corner and frying me with a bolt of fire, or not knowing that an umber hulk was in the same darkened room as I was, making me confused. When a level went from fast response to slow, it meant that a large amount of monsters had suddenly materialized. I would immediately check myself and carefully consider each decision. With this newfound realization, I played with hyperfocusing intensity over the course of several days.

Today, twenty-one years after I first got Hack working on my 8088, we come full circle, back to the 8088, to what I think are the two most lovely text screens I have ever seen on any CGA monitor:

hack1

hack2

I never said I was a patient man… but I guess I am :-)

Update, 1/7/2012:  I just today learned that Donnie Russell’s excellent Windows port of Hack has now been ported to Flash and can run in any browser that supports it.  It supports saving as well as some cute sound effects.

Posted in Gaming, Vintage Computing | 5 Comments »

The Running Program

Posted by Trixter on March 13, 2006

The Running Program - Title Screen

As promised, The Running Program has been cracked and made available. I can’t take credit for the crack; my good friend Demonlord took the program and what little progress I’ve made and did a proper INT 13 redirect crack for it. (Check the file NOTE.TXT for info, and PROTECT for the “secret data” that the program was protected with.)

Demonlord, for those not familiar with his work, is the hardest-working oldskool cracker still at it today. Nowadays we have windows executables with symbol information still linked to them — this is child’s play.  Way back when, we had 512-byte boot loaders that we had to disassemble by hand. Demonlord still does this, and is the best cracker I know both two decades ago and today. He’s so good that most cracks take him less than an hour, and unlike most hack jobs, they’re quite elegant and graceful. For example, check The Running Program: His crack never even touched the .exe — instead it loads an INT 13 handler that intercepts the request and redirects it to the data saved off of the protected track.

You know how there’s one person responsible for about 95% of all the ATARI 2600 cartridge ROM dumps out there? Demonlord is responsible for cracking 95% of all the bootable PC diskette images out there. The next time you play a bootable PC game in an emulator, say a little howdy for Demonlord.

Posted in Software Piracy, Vintage Computing, Weight Loss | 2 Comments »