Programming the 3com/USR PalmPilot
Mark Eichin, SIPB
IAP 1998Programming Model
- CPU: Dragonball 68328 (cpu32)
- 32 bit, little endian
#pragma pack(2) - RAM 128k..1M, 1M/2M ROM
Mary Chung's Menu app
GUI
- Mac heritage
- resource compiler
- dynamic resources
FORM # AT (coords)
USABLE, MODAL, HELPID #, MENUID #
TITLE "Mary Chung's"
LABEL "Mary Chung's Menu" 2000 CENTER 15
POPUPTRIGGER "soup?" ID 3000 AT (coords) LEFTANCHOR
LIST "soup?" "suan" "wonton" "H&S" "H&S w/wonton"
"Egg Drop" ID 3001 AT (coords) VISIBLEITEMS 6 NONUSABLE
POPUPLIST ID 3000 3001
Setup
DWord PilotMain(Word cmd, Ptr cmdPBP, Word launchFlags)
{
EventType e;
short err;
FormPtr fp = 0;
if (cmd != sysAppLaunchCmdNormalLaunch) { /* 0 */
return 0;
}
FrmGotoForm(1000); /* main page */
Main Loop
while(1) {
EvtGetEvent(&e, 100);
if (SysHandleEvent(&e)) continue;
if (MenuHandleEvent((void *)0, &e, &err)) continue;
switch (e.eType) {
case frmLoadEvent:
FrmSetActiveForm(fp=FrmInitForm(e.data.frmLoad.formID)); break;
case frmOpenEvent:
FrmDrawForm(FrmGetActiveForm()); break;
case menuEvent:
FrmAlert(1000); break; /* alert 1000 */
case appStopEvent:
return 0;
default:
FrmHandleEvent(FrmGetActiveForm(), &e); break;
Handle Popups
case popSelectEvent:
/* this one *actually* handles the popup menu, so recalc here */
FrmHandleEvent(FrmGetActiveForm(), &e);
updatePopup(fp,&e);
break;
case ctlSelectEvent:
FrmHandleEvent(FrmGetActiveForm(), &e);
{
if (e.data.ctlSelect.controlID == 4100)
clearEntries(fp);
}
}
}
return 0;
}
Popup
static void updatePopup(FormPtr fp, EventType *e)
{
Word lid = e->data.popSelect.listID;
ListPtr lp = FrmLookupPtr(fp,lid);
int pr, oldpr;
switch (lid) {
case 3251: /* dishsplit */
oldpr = dishprice / dishsplit;
dishsplit = lp->currentItem;
if (dishsplit == 0) dishsplit = 1;
pr = dishprice / dishsplit;
break;
Memory Management
- stack size set in pref resource
- no malloc
- database pages
- read-only pages
- calls limited to 32k
Communications
- direct serial
error = SysLibFind("Serial Library", &SerialRef);
if (error) ErrDisplay("Error trying to load the serial library");
error = SerOpen(SerialRef, 0, Baud);
if (error) ErrDisplay("Error serial open");
error = SerReceiveCheck(SerialRef, &numBytes);
if (error) ...
error = SerReceive(SerialRef, buffer, numBytes, -1); - conduits
- interface to existing programs (money extract)
Event Management
SysHandleEvent
NullEvent
frmLoadEvent
menuEvent
FrmHandleEvent
Search
Debugging
- Xcopilot
- gdb
target pilot /dev/cua0
Last processed: 1998-02-03T02:47:14