writing programs for hardware you don't own

Do any of you hack PalmOS? I need some advice...

<lj-cut text="hack hack">A few years ago, I ported my XDaliClock program to PalmOS. This amused me, in that the original Palm Pilots were only-slightly beefier machines than the original Macintosh was, which was the primordial soup that Dali Clock crawled out of. Of course, I don't actually have a Pilot, so I debugged it in emulators, then mailed it to people saying, ``hey, does this work?''

So, three years and many OS upgrades later, my PalmOS development environment atrophied, and I wasn't able to actually compile the thing any more. Well, tonight I got the development environment working again, and found that the code needed a lot of changes to compile: various function names and types changed; nothing that drastic...

Except... one of the tricks I did in the old version was to draw to the frame buffer directly, in cases where that was possible. I was careful to only do this on systems that were running in 1-bit mode; on grayscale or color systems, it would draw it the slower, safer way (which was fine, because those systems are faster anyway.) But drawing to the frame buffer directly sped things up a lot on the older hardware, so it was worthwhile.

I was getting the pointer to the frame buffer like so:

     frame_buffer = (unsigned char *) WinGetDisplayWindow()->displayAddr; 

That doesn't work any more. I gave this a try, based on my reading of Window.h and Bitmap.h, but it doesn't work:

    BitmapPtr b = WinGetDisplayWindow()->bitmapP;
     /* unsigned char *end = (((unsigned char *) b) + sizeof(*b)); */
     unsigned char *end = (((unsigned char *) &b->reserved)
                           + sizeof (b->reserved));
     if (b->flags.hasColorTable) end += sizeof(ColorTableType);
     if (b->flags.directColor)   end += sizeof(BitmapDirectInfoType);
     if (b->flags.indirect)   /* ptr to bits is after 'b' */
       frame_buffer = * (unsigned char **) end;
     else                     /* bits begin right after `b' */
       frame_buffer = end;

Is it possible to access the frame buffer as memory at all any more? Surely there must be some way; the old PRC file I generated years ago still works, accessing the frame buffer as bits; I just can't figure out how to generate a new PRC file that does the same thing, using the more recent SDK!

Update: I figured it out. The trick is:

    WinHandle w = WinGetDisplayWindow();
    if (!w)
    else if (rom_version < ROM_35)
      frame_buffer = (unsigned char *) w->displayAddrV20;
      { /* functions from "3.5 New Feature Set" */
        BitmapPtr b = WinGetBitmap (w);
        frame_buffer = (unsigned char *) (b ? BmpGetBits (b) : 0);
Tags: , , , , , , ,