Fog Creek Software
g
Discussion Board




Chris Crawford Game Design Book - what we lost?

Haven't posted here for quite a while, but then I hadn't done much development for a while either.

I am not a game programmer, but I recently enjoyed reading his book on game design.  It's like a collection of anecdotes on different games he designed with little bits of programming thrown in.

There is an interesting bit about cracker proofing a program, but the bit that has really stuck in my mind is the bit about programming the Atari VCS.

To recap briefly on the VCS you had 128 bytes RAM, 2K (later 4K) ROM

To display the screen you had to fill up a 40 bit buffer for each scan line (like bitmapping a single line), and then refill it for the next scan line (during the HBLANK), and so on as the screen displayed.

Now the fun part is you had to fill the buffer in exactly 77 machine code cycles.

That was the background, plus you got 2 8X8 pixel sprites (players).

If I calculated that right, it's 7 bytes (40 bits + 2 bytes for color) for background, 20 bytes for the players (64 bits + 2 bytes color  X 2) leaving a grand total of 101 bytes of usable RAM.  [this isn't explicitly stated in the book]

You also got an additional 3000 cycles to do other processing during the VBLANK when you didn't have to be filling up scan lines.


Now if you are old enough to remember VCS (I am) it seems pretty amazing that they were able to get any programs at all working on it.  Let alone space invaders and stuff.


From the sound of what is in the book, each game was written by 1 Atari programmer.  Crawford certainly wrote a game himself as he talks about it.


These days, of course, I am programming in relatively high languages like C++, PHP etc.

But I am struck by the amount of precision (exactly 77 cycles, 101 bytes RAM) and efficiency this old-style type of programming must have involved.  This is why I can't get it out my mind.

So my question is, is there any area of modern programming where similar levels of precision exist?  Is this a skill the world has lost forever?

(I have also been sort of thinking about things like archive which preserve digital history, e.g. archive.org, so my interest is really is there a piece of history that we've lost in there)

S. Tanna
Monday, January 19, 2004

http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?The+story+of+Mel,+a+Real+Programmer

Christopher Wells
Monday, January 19, 2004

What about Pocket PCs and Mobile phones, with only about 256K of memory (program and storage - I filled the rest up with ring tones :) ) my nokia 6610 manages to run some pretty impressive - if not useless - things.

And then there is the Pocket PC platform, where you *only* have (on mine anyway) about 15 MB memory free - and yet still manage to cover most of the requirements of the customer in an extremely small footprint (compared to the P4 2.4 GHz w/ 512MB ram sitting on my desk) . they managed to squeeze SQL into only 1-2 MB which I find impressive.

Chris Ormerod
Monday, January 19, 2004

Chris, "only" 256k?

256k is immense, four times the address space of the 8080.

I started on an 8080 with 16k of RAM, it was endless.

When you had to write something in assembly, you didn't particularly have to worry about "footprint" -- every instruction assembled to one byte :)

--------------

S. Tanna:

It's really a wonder how people were cramming games into 100 bytes and nowadays Hello World compiles to 50k.

Code today is hairier -- assembler opcodes are longer, there is a lot of support code like setup/cleanup, calling libraries with many parameters etc.

But the main thing is, libraries. They account for most of the code, and it's a pity a large majority of those functions never get called.

I'll bet the actual code that does the job in an 8-megabyte exe is about 500k, the rest is linked-in libraries.

Alex.ro
Monday, January 19, 2004

There was the 5k competition, which had some amazing entries.

http://www.the5k.org/

Of couse, it is intimate knowledge of the browser rather than the hardware that is being tested here.

Ged Byrne
Monday, January 19, 2004

Yes, I do realise the OP was talking about a device with 128 bytes of memory and I was talking about one with 256,000 bytes. But I was thinking more along the lines of comparing to the present desktop machines that most of us program for - Most wouldn't think twice if the EXE was 15 MB, and took 64 MB of RAM to start up - so in my opinion devices like my telephone are likely to be the most restricted devices you will ever be asked to program for in business today.

But to answer directly to the OPs comparison if anything like that (programming in 100's of bytes) exists today - I don't think it does for anything that is actually useful, even a CNC lathe now runs a fairly hefty OS - however there are those 256b competitions where they write some pretty impressive apps (just graphics) that fit in 256 bytes. Sorry I don't have the link but I am pretty sure it was posted here only a month or so ago.

Chris Ormerod
Monday, January 19, 2004

This reminds me of the work I did in the early 80s when I started programming, on the trusty old Sinclair Spectrum.

Two cases I particularly remember:

1) To increase the apparent colour resolution you had to swap the entries in the colour definition table of the screen RAM during the HBLANK. This lasted for a precise length of time and you had to program your machine code to be an exact number of cycles long, so that you could synchronise with the raster chip that generated the TV-out signal.

2) The Spectrum used a cassette recorder to save and load programs and data. The 1500 baud signal was sampled by an input port to read the data. In the original ROM, it would just wait for the signal to change from 0 to 1 to 0 and test how long it took, to see if the current bit was a 1 or a 0. However, you could use this "dead time" to animate things on the screen, while the data was being loaded. Again, you had to be very precise about the number of clock cycles you used to do each tiny bit of animation, so that you would not miss a transition of the tape player signal.

All of this had to happen in a small amout of RAM. The standard Spectrum had 16k, of which just over 6k was used by the screen, etc, so you only had less than 10k for everything else.

Of course, if you could, you'd upgrade to a massive 48k RAM. Then you could have some really amazing games that had over 40k to play with. This was slightly scary though, as you had to buy the raw memory chips and then plug them into the Spectrum's circuit board yourself. Often, the pins would not be aligned with the sockets, so you had to bend them and hope they didn't snap or anything.

Steve Jones (UK)
Monday, January 19, 2004

Having written two modem applications in the past two years in C# (which has no native COM port capability), I'll say I don't miss tracking state changes  or handling low-level I/O work at all.
I'm much happier with opening an FTP port, sending a file, catching errors, and closing the port, thank you very much.

It's more fun providing solutions for clients than fiddling with timing synchronizations. Isn't that what computers are for?

(I wonder if accountants sit around musing over how much better things were when they had to keep everything in ledgers in ink)

Philo

Philo
Monday, January 19, 2004

Abstraction comes with a price.  Luckily we have Moore's Law.

Him
Monday, January 19, 2004

Until a couple of years ago I was working on a motor servo controller. The control registers had to be updated every 125us.  All of the code (256KB) was written in assembly. The Timer interrupt was the most critical of course, but every line of code had the number of machine cycles as a comment. Every routine had it's min/max total number of cycles. All changes had to be careful no to upset the timing.

Of course, as we went from a 16Mhz 68000 to a 66Mhz(??) 68040 we began to get more lax as the margins increased. :)

sgf
Monday, January 19, 2004

There's plenty of stuff being done deep in embedded-land using very limited resources -- say, an 8-bit microcontroller with a few K of code space and 256 bytes of data space. Writing for such a device, you get to do all the cycle-counting and byte-counting you could possibly wish for. And maybe a little more :-).

Gareth McCaughan
Monday, January 19, 2004

"It's more fun providing solutions for clients than fiddling with timing synchronizations. Isn't that what computers are for?"

to be honest, I had more fun fiddling with timing synchronizations. Now I mostly just download and install things. And write powerpoint presentations about things my clients could possibly download and install.

If you actually know what you are doing, and truly enjoy providing "solutions for clients" you are going to be unstoppable in the world of schlocky IT consulting. Most of my acquaintances are dumbbell salespeople who couldn't give a fuck what they were selling, or else they are older engineers who are just waiting until they have enough in the bank account to retire and start an organic farm.


Monday, January 19, 2004

Gareth McCaughan: ...say, an 8-bit microcontroller with a few K of code space and 256 bytes of data space. Writing for such a device, you get to do all the cycle-counting and byte-counting you could possibly wish for.

And for those who don't play with such toys, this describes a 'top of the line' device.

Sheesh, 'a few K'.  Sheer luxury.

AJS
Monday, January 19, 2004

Thanks everybody some of this is fascinating. 

I especially liked the Spectrum cassette story. I never programmed the spectrum, so I didn't know how that was done.

Incidentally, I agree with Philo to the extent that things were obviously *not* better then - you get more done now when you don't have to worry about such stuff.  However, were I diverge, is what I'm interested in, is the lost craft aspect, especially since I'm not sure that a lot of these techniques were documented (most Atari games written by 1 person, presumably the same for Spectrum games? When that person dies or forgets, is the knowledge lost?)

Compare Faberge (sp?) eggs and such like, Stradivarius (sp?) violins, Chippendale furniture etc.  Works of extreme craftmanship.  Obviously now a days you can go to the local mall, and get jewelry, ornaments, violins or furniture for much cheaper, mass produced in a factory --- but there is a quality and craftmanship in Faberge/Stradivarius/Chippendale that the modern items simply do not produce, and presumably (?) can not reproduce because the skills have been lost.


P.S.
Also in Crawford's book, also Kim 1 1K Tank game.

1K chess on ZX81 (I just remembered that one)

My personal example: C64, the "hardware" scrolling.  There was a 3bit register that you could shift the entire screen contents left or right by 1/8th of a character (i.e. 1 pixel).  So careful timing with screen interrupts you could achieve smooth scrolling by doing:
--- Set the register to 0, then 1, to 2, to 3, ... to 7 (effectively scrolling the screen a pixel each time you do this)
--- Set the register back to 0, and shift all the characters one cell left or right at the same time (so this acts as if 8)
--- You have to do this during VBLANK interrupts (exact timing) to achieve the effect

S. Tanna
Monday, January 19, 2004

Tanna,

I had completely forgotten about that.  That was pretty slick.

The deal was, to do hi res graphics, you'd fill the screen up with configurable characters. So every little 8bit x 8 bit block was one characters. They you'd do this big calcuation with lots of MODs to convert a point (100,120) into a character and the dot within that character.

BUT... if you were scrolling the screen, you'd have to scroll it by a whole CHARACTER at a time, Shifting each row left (or right) to get it to scroll sideways, like in the old Defender game. But that looked liek CRAP.

Hence the need to move it over by 1 bit at a time until you got over 8 bit. Then you move it all BACK to 0 AND shift it all over by one whole character block.

It is AMAZING that they came out with such great games.

Hmm... I'll post a question on this on JoS:

HOW could they come up with great games for a smaller market that was willing to pay less?

The real Entrepreneur
Monday, January 19, 2004

well, all this talk remind me of Michael Abrash's books. Nice reading if you are interested in all the details.

btw any one know what happen to him? last i knew he was part of Microsoft Xbox development time.

eddy
Monday, January 19, 2004

I keep reading this thread title as the "Cindy Crawford (etc.)". How disappointing.


Tuesday, January 20, 2004

"HOW could they come up with great games for a smaller market that was willing to pay less?"

Because development costs were much lower.  A typical 80s home computer game was written by one person in four months to a year.  Very often they were written on the side, without funding, then submitted to a publisher, much like you'd do if you were writing a novel.  A typical game these days has a development budget of five to ten million dollars, with some going as high as thirty million.

I miss those days.

Junkster
Tuesday, January 20, 2004

Michael Abrash works for RAD Development tools.  They sell various libraries to game developers, such as sound drivers.

Junkster
Tuesday, January 20, 2004

*  Recent Topics

*  Fog Creek Home