Friday, October 31, 2008

Demo coders....

There was a post on plus4 world about how to teach new people to code on the Plus4 and it got be thinking about some pet hates. Demo coders are renown for keeping sources to demos secret, never releasing anything but binarys in case someone steals their ideas. Others don't release code becasue, well... demos are usually hacks that are horrible bits of code and they don't want anyone to see just how much of a hack it is. Great Demos usually flow like works of art, but if you saw the internals, then its like being told how a magic trick was done, and the wonder falls away.

Still, I was thinking.... I never really code demos because, well... I'm not very good at them. Sure I can code things so they run quickly, and I can code things so that they're small. But I've never been good at prducing great demos folk really want to see. That said, I think theres a market (as it were) for demos that simply show how to do something. Kind of like online tutorials, simple demos that show off a simple effect and how to pull it off. This would allow others to use it and do what I can't, make great demos - or perhaps even use the effect in a game!

I was watching the demo posted here and was trying to think how they did the full screen scaling coz I think it would be cool in game. I think now I know but I also suspect that if the source was available I'd be much more interested in using/trying that I am now. Anyway, Csabo over at plus4 world is thinking about this too and I think its a great idea. If nothing else, it adds something valuable to the scene - which is what its all about now.

2 comments:

Anonymous said...

Check out:
http://www.cpcwiki.com/index.php/XEO3

MagerValp said...

While demo sources are rare, effects are often dissected and explained, e.g. at CSDB, codebase64, in Vandalism News, C= Hacking, etc. And simply asking the coder has always worked for me, though I usually prefer tracing the code in the monitor if I want to check something out. 90% of the time a demo effect just does one thing over and over for a full frame, so the code is usually (but not always) easy to follow. However, the "trick" is only what allows it to be done, actually getting the thing up on screen looking great is just plain old hard work.

Regarding bitmap zooming, it's two effects rolled into one. Vertical stretching is done with $d011, refer to the vic article and codebase. It's relatively timing sensitive, so it's not very well suited to game graphics (e.g. throwing sprites on top of it takes a bit of effort). Horizontal stretching is done with brute force, by plotting characters. When you convert a bitmap to character mode, you typically put the first four pixels in character 0, the next four pixels in character 1, and so on, so that to display the image you plot:

00 01 02 03

for a four character wide image. To prepare the image for stretching you put the first four pixels in character 0, but in character 1 you put pixels 1-4 (instead of 4-7), in character 2 you put 2-5, etc. To display the image you plot:

00 04 08 0c

The magic happens when you plot:

00 03 06 09

or:

00 05 0a 0f

This will stretch or expand the image by one pixel for each character plotted, letting you zoom ±25%.