Well, that’s embarrassing

I mentioned in my last post that I was having trouble getting my double-buffering code for the Amiga 500 working. Specifically, it would draw the first frame and then the machine would crash – sometimes spectacularly. It was kind of surprising, since I was following pretty closely to the example in the RKRM: Libraries manual.

I just got back from a short business trip and, as so often happens, fresh eyes made quick work of the problem. And what a problem: Here’s my code for initializing my array of two BitMap structures:

See the problem, right there in the first line? Where I only iterate once, and so never initialize the second BitMap, and never allocate space for its rasters? So as soon as I start drawing into my second buffer, I’m actually scribbling over a random space in the Amiga’s global, shared address space?

Man, that’s just… man.

Well, having messed up something that simple, it’s now time to get into some real math. Stay tuned…