diff -Bbur ../../source/dc/doodle.c ./doodle.c --- ../../source/dc/doodle.c Sat Apr 26 22:36:10 1997 +++ ./doodle.c Mon Dec 21 11:52:47 1998 @@ -10,6 +10,14 @@ #include "doodle.h" +/* this is the callback stuff from Callback.h by ian in O'Reilly's book */ +register void *reg_a4 asm("%a4"); + +#define CALLBACK_PROLOGUE \ +void *save_a4 = reg_a4; asm("move.l %%a5,%%a4; sub.l #edata,%%a4" : :); + +#define CALLBACK_EPILOGUE reg_a4 = save_a4; + /* Number of pixels allowed in a pen */ #ifndef NPENPIX #define NPENPIX 32 @@ -63,6 +71,7 @@ #define cmdSmoother '>' #define cmdAbout 'a' +#define cmdBeam 'b' #define cmdClear 'c' #define cmdFill 'f' #define cmdRemove 'r' @@ -76,6 +85,11 @@ ** PalmOS includes */ #include +#include + +#define displayAddr displayAddrV20 +#define PrefSetAppPreferences PrefSetAppPreferencesV10 +#define PrefGetAppPreferences PrefGetAppPreferencesV10 /* ** Global data structure. @@ -374,6 +388,51 @@ FrmAlert(aboutDoodle); break; + case cmdBeam: + { + VoidHand t, t1; + VoidPtr px, p1; + Word err; + int xcnt,outhis; + ExgSocketType exgSocket; + + SaveImage(); + + t = DmQueryRecord(d.dbR, p.dbI); + px = MemHandleLock(t); + + t1 = MemHandleNew(64); + p1 = MemHandleLock(t1); + StrCopy(p1,"Doodle Image"); + + MemSet(&exgSocket, sizeof(exgSocket), 0); + exgSocket.description = p1; + exgSocket.name = "doodle.xxx"; + exgSocket.length = 3200; + exgSocket.target = AppType; + + err = ExgPut(&exgSocket); + + if( !err ) { + xcnt = 0; + while( xcnt < 3200 ) { + outhis = ExgSend(&exgSocket, px, 3200 - xcnt, &err); + if( err ) break; + xcnt += outhis; + px += outhis; + } + + ExgDisconnect(&exgSocket, err); + } + + MemHandleUnlock(t); + MemHandleUnlock(t1); + MemHandleFree(t1); + + } + + break; + case cmdTitle: SaveImage(); FrmGotoForm(p.formID == formDoodle ? formTDoodle : formDoodle); @@ -673,6 +732,64 @@ */ PrefSetAppPreferences(AppType, AppVersion, &p, sizeof(p)); DmCloseDatabase(d.dbR); + + } + else if (cmd == sysAppLaunchCmdExgAskUser) { + ExgAskParamPtr exgP = (ExgAskParamPtr) cmdPBP; + exgP->result = exgAskOk; /* Dialog, Ok, Cancel */ + } + else if (cmd == sysAppLaunchCmdExgReceiveData) { + DmOpenRef dbP; + ExgSocketPtr exgSocketP = (ExgSocketPtr) cmdPBP; + UInt index = 65535; + VoidHand t; + VoidPtr px; + unsigned char buf[160]; + int xcnt, inthis, incnt; + + if (!(launchFlags & sysAppLaunchFlagSubCall)) + dbP = DmOpenDatabaseByTypeCreator(DBType, AppType, dmModeReadWrite); + else { + CALLBACK_PROLOGUE + dbP = d.dbR; + CALLBACK_EPILOGUE + } + + if (dbP == NULL) return 0; + + err = ExgAccept(exgSocketP); + + if (err) return err; + + t = DmNewRecord(dbP, &index, 3200); + px = MemHandleLock(t); + + DmSet(px, 0, 3200, 0); + xcnt = 0; + while( xcnt < 20 ) { + incnt = 0; + while( incnt < 160 ) { + inthis = ExgReceive(exgSocketP, &buf[incnt], 160-incnt, &err); + if( err ) break; + incnt += inthis; + } + + DmWrite(px,160*xcnt++,buf,160); + } + MemHandleUnlock(t); + DmReleaseRecord(dbP, index, true); + + ExgDisconnect(exgSocketP, err); + + if (!(launchFlags & sysAppLaunchFlagSubCall)) + err = DmCloseDatabase(dbP); + else { + CALLBACK_PROLOGUE + p.dbI = DmNumRecords(dbP) - 1; + LoadImage(); + LabelImage(); + CALLBACK_EPILOGUE + } } return 0; Binary files ../../source/dc/doodle.prc and ./doodle.prc differ diff -Bbur ../../source/dc/doodle.rcp ./doodle.rcp --- ../../source/dc/doodle.rcp Fri Apr 25 23:00:52 1997 +++ ./doodle.rcp Fri Dec 18 11:56:51 1998 @@ -23,6 +23,7 @@ BEGIN PULLDOWN "Page" BEGIN + MENUITEM "Beam" 3098 "b" MENUITEM "Clear" 3099 "c" MENUITEM "Fill" 3102 "f" MENUITEM "New" 3110 "n"