Posts in the Software Development category

The BipBuffer Rides Again

So a while back, I invented a datastructure I call the Bip-Buffer. It's a rather neat little thing that if you pump data through it fast enough works pretty much as fast as a true circular buffer. It has a nice data-access pattern too, based around a reserve/commit transaction to push data in one side, and to pull data out of the other side.

It works. Lots of people use it. Some people claim they did it first back in the 90s on the Amiga, but they didn't publish. (Which means, sadly for them, they don't count. No point inventing something if you don't share the knowledge). The price you pay for fame and fortune is letting other people know what you did ;-)

The moral of the story? Give your algorithms unique names. You'll be able to see where they proliferate to. As a result, I can stake a claim on my own tiny little corner of computer science.

Anyway, this is all beside the point. Why am I posting this?

Because Age of Empires Online uses my BipBuffer code & algorithm. A friend of mine is working on the source right now, and he sent me a quick email to let me know it was in there. It's great to know that it's being used :)

(And because he sent me an email, he's actually meeting terms of the licensing agreement :-) )

(more...)

New Blog from Jason Weiler (Airtight Games)

My good pal Jason Weiler has posted up his first article on his new blog - Myopic Topics (http://myopictopics.com).

This one's the first part in a series about writing an add-in for Visual Studio's Evaluation Engine (the bit that tells the locals/autos/watch window how to format and display variables).

He's also the author of the FName-Addin for Unreal Engine 3. This is an awesome, donation-ware tool for Unreal Engine, which allows you to view the actual string values of FNames in the watch window. It's an absolute must-have for anyone doing Unreal development - so download it right now!

And if you do download it, please, make a donation. I pay $150 or so (plus renewal fees every year) for Visual Assist - if I'm working on Unreal Engine, I'm pretty sure that I can throw $50 his way for something which massively takes the pain away from Unreal development.

Anyway, check it out and subscribe to his blog! He's one of the good ones :)

(more...)

Colorizing images for Windows Phone 7

I know what you're thinking... I have these great icons, and I want to display them in the system color. I need to use a PixelShader. Or some other kind of ShaderEffect.
Well, sure, you could do it that way... but that's overkill. Instead, allow me to introduce you to the OpacityMask.
Here's the idea: you paint a rectangle the size of the icon you want to render. Fill it in the color you want to paint with. And set the OpacityMask of the icon to the image you want to use as the outline.
For example:





And hey presto! One neatly colored image, for very minimal fuss. Doesn't work for tinting, but certainly works for rendering icons in the right color for the UI.
(more...)

The Darker Side of Google & Open Source: Taking without Attribution

So, once upon a time (January 2003), I wrote a rather neat little article about an algorithm I invented called a “Bip Buffer”. It’s basically a circular buffer, split into two parts. It makes writing TCP/IP networking code easier and faster, because it allows you to operate on data contiguously as much as possible. This increases throughput.

(And hey, they’re teaching it at Brunel University in the UK – EE2066 - Computer Architecture & Digital Systems has a reference to it in their powerpoints. Yay ego boost!)

I originally invented it while at Intelligent Ion, working on an ultra-fast miniaturized Mass Spectrometer. I needed something that would act as a circular buffer, and I couldn’t find anything available that didn’t write one byte at a time. So a bit of thought later, a few Aha! moments, and hey presto! Something that let me squirt data FAST through our pipes, and that actually was worthy of writing up.

So I wrote a little article and put it up on CodeProject along with full source code. The only requirement for using the code was that you send me an email if you use it, letting me know how it’s being used. Just because I’m curious.

That, by the way, was the only requirement. No, it’s not public domain, but it’s a hell of a light licensing requirement.

Anyway… fast forward to a few years later.

A Few Years Later

By now, I’ve had about 8 emails. Not bad, I thought. Okay, maybe it wasn’t as cool as  I thought, but still, it was worth it. Cool little thing to have in my bag of tricks.

One was from an observatory who were going to use it in their code. They’ve given me a standing offer to come check the place out whenever I’m in town. I love offers like that – I get to meet very cool people along the way, and I’m all about new and exciting experiences.

Fast forward even more years later, to the present day.

Even More Years Later – The Present Day

Just for kicks, I decided to do a search to see where my little chunk o’ code has been used. And that’s where things got interesting.

You see, it’s in the Google Android Source Code now. Don’t believe me? Check this out:

http://android.git.kernel.org/?p=platform/system/core.git;a=blob_plain;f=adb/sysdeps_win32.c

It’s not quite the same code, but it certainly has the same name for the data structure, and uses my algorithm. Here’s a snippet from that page:

* basically, we use two circular buffers, each one corresponding to a given
* direction.
*
* each buffer is implemented as two regions:
*
*   region A which is (a_start,a_end)
*   region B which is (0, b_end)  with b_end <= a_start
*
* an empty buffer has:  a_start = a_end = b_end = 0
*
* a_start is the pointer where we start reading data
* a_end is the pointer where we start writing data, unless it is BUFFER_SIZE,
* then you start writing at b_end
*
* the buffer is full when  b_end == a_start && a_end == BUFFER_SIZE
*
* there is room when b_end < a_start || a_end < BUFER_SIZE
*
* when reading, a_start is incremented, it a_start meets a_end, then
* we do:  a_start = 0, a_end = b_end, b_end = 0, and keep going on..

And I’ve never had an email from Google so much as telling me they’re using it. This is bad, folks. I had ONE single requirement to use that algorithm & code. Only one. And it was tiny.

On the plus side, however, my algorithm and a variant of my code has now been reused in every Android device out there. Nice kudos.

Or it would be nice kudos if they’d sent me the email. Or even left a link in the code to my original article. To add insult to injury, this is at the top of the source file:

/* Copyright (C) 2007-2008 The Android Open Source Project

**

** This software is licensed under the terms of the GNU General Public

** License version 2, as published by the Free Software Foundation, and

** may be copied, distributed, and modified under those terms.

**

** This program is distributed in the hope that it will be useful,

** but WITHOUT ANY WARRANTY; without even the implied warranty of

** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

** GNU General Public License for more details.

*/

Not only do they claim copyright over everything, but they GPL’d it as well. I hate the GPL; I don’t have a problem with the BSD license. But GPL? No, sorry, I gave away my original code for everyone to use – not to virally license it.

Here’s my original copyright, for comparison:

/*
Copyright (c) 2003 Simon Cooke, All Rights Reserved

Licensed royalty-free for commercial and non-commercial
use. All that I ask is that you send me an email
telling me that you're using my code. It'll make me
feel warm and fuzzy inside. [email protected] to prevent spam

*/

But boy, that code looks a lot different than mine. I wonder where that came from?

So Where DID It Come From?

Well, Nettee is using the code – but they attribute it to me originally in the docs. So no harm no foul there. (Thanks guys – you rock).

PyroEmu is using it too: http://svn.assembla.com/svn/pyroemu/trunk/src/pyroemu-shared/Network/CircularBuffer.cpp – and they attribute the algorithm for me, but claim the code for themselves… personally, I think my version was cleaner. Still at least they attributed it to me.

But Google? Nooooooo.

And yes, I know I’m blowing this up a bit out of proportion. I don’t mind Google using my code – and let me make that very clear yes, google, you can use my code and algorithm. Please don’t take this as any kind of request to remove it. But in this day and age when we can’t all be Donald Knuth any more, it’d be nice to get some credit for my work. Especially because that’s all I asked for it. I didn’t even patent it.

Credit where it’s due, Open Sourceys. Don’t get all giddy about your free culture without giving back to those who make it possible for you.

And stop putting GPL on my code. It’ll give you hives.

(more...)

The Second Coming of the Tablet PC

Ever since Apple announced the iPad, its been "Tablet this, tablet that", and people have been jumping up and down saying that this is the best thing since sliced bread, and totally new and innovative to boot. (I suspect that these are the same people who, when Microsoft kick-started the whole TabletPC initiative about a decade or so ago, insisted that Apple had invented it back then too, and it was called the Newton. Revisionist fan-boi history much? I think so).

What amazes me this time though is that On The Media, a radio show which comes out of WNYC (also home to the rather awesome science show RadioLab) were going gaga about this being the first instance of the "Fifth Screen" that tech geeks have been salivating over for centuries.

The screens go like this:

  1. Movie screens
  2. Television screens
  3. PC screens
  4. Cellphone screens
  5. Some kind of intermediate not-quite-a-screen which, like the One Ring, will in the darkness bind them.

(The similarities to the One Ring don't stop quite there... I'm willing to bet that most of the first people to buy the iPad will indeed look a lot like Gollum, only wearing Armani suits).

What amazes me is that this is totally revisionist history. The TabletPC came in several versions, including convertibles which had keyboards and a screen on a pivot that you could fold back over to sketch on. Like, for example, the rather splendid Toshiba Portege M200 which I once had. Unfortunately, Toshiba haven't seen fit to release one with as high a screen resolution as that wonderful little machine, or as good a GPU since - which means that no matter what kind of Tablets they're selling now, I won't be buying one... goddamn Intel Integrated Graphics... grrr.

The other versions are in what is known as Slate format - like Fujitsu's Stylistic ST6012 Tablet PC.

Woah. Wait a minute. This looks like an iPad.

And yes, it does look like an iPad. Except it has an active pen input (using RF sensors, basically) so that you can sketch high fidelity sketches on it. Or write by hand and enter all of your stuff into OneNote, where text recognition will kick in automatically and let you search your handwritten notes.

The iPad, as it happens, does not support handwriting. This should not be a surprise, as its multi-touch display really isn't designed with high enough fidelity for it. Sure, you might be able to get away with using your own nylon stylus on it (maybe steal one from a DS), but it's not going to be a high end user experience.

So yes, the iPad is not the first attempt at being the "5th screen" (heck, not even the Mira was that). Slate form-factor TabletPCs existed a LONG time ago. And they're much much more useful. If Toshiba would deign to release something akin to the M200 again, with dual core CPUs and a nice fast GPU, I'd happily consider buying one.

That's why half of my notes in OneNote from a few years ago are all handwritten. Because Tablet PCs are awesome in meetings.

End rant. Apple didn't invent this. And what they've got doesn't even measure up to what was out there a decade ago. More marketing flim-flap and frip-frappery. But hey, at least it's stylish.

(more...)