feat(inventory): Phase 1 - scan and validate UPC barcodes #1

Open
lyrathorpe wants to merge 54 commits from feat/inventory-phase1-scan into main
757 changed files with 97167 additions and 0 deletions
Showing only changes of commit 64e484448c - Show all commits
+2
View File
@@ -0,0 +1,2 @@
@if not "%jpivid%"=="v2" set jpivid=v0
+2
View File
@@ -0,0 +1,2 @@
kats.pic
kats.rsc
+498
View File
@@ -0,0 +1,498 @@
/*
File: KATS.C
*/
#include <ats.h>
#include <p_gen.h>
#include <p_file.h>
#include <wlib.h>
#include <olib.g>
#include <appman.g>
#include <gate.g>
#include <kats.rsg>
#define KATS_MODS (W_CTRL_MODIFIER|W_PSION_MODIFIER)
#define KATS_RECORD 0x20
#define KATS_PLAYBACK W_KEY_RETURN
#define KATS_PLAYBACK2 W_KEY_TAB
#define KATS_SAVE W_KEY_DIAMOND
#define MAX_NUM_KEYS 128 /* maximum number of keys per macro */
#define MACRO_NAME_LEN 24 /* includes zero terminator */
typedef struct
{
TEXT name[MACRO_NAME_LEN];
WORD num_keys;
ATS_KEY_DEF keys[MAX_NUM_KEYS];
} KATS_MACRO;
GLREF_D VOID *DatCommandPtr;
GLREF_D VOID *DatGate;
LOCAL_D HANDLE olib;
LOCAL_D VOID *vaxvar;
LOCAL_D UWORD nmacros;
LOCAL_D KATS_MACRO mac_rec; /* macro being recorded */
LOCAL_D ATS_KEY full_key; /* key being recorded */
LOCAL_D KATS_MACRO *mac_play; /* macro being played back */
LOCAL_D INT play_keys;
LOCAL_D INT changed;
LOCAL_D INT pid;
LOCAL_D INT record;
LOCAL_D INT playback;
LOCAL_D WS_EV event;
LOCAL_D WORD rec_stat;
LOCAL_D WORD rec_active;
LOCAL_D WORD play_stat;
LOCAL_D WORD play_active;
LOCAL_D TEXT *pmac_name;
LOCAL_D ATS_DIAL_DEF dl_edit;
LOCAL_D ATS_DIAL_DEF dl_choose;
LOCAL_D ATS_DIAL_DEF dl_confirm;
LOCAL_D ATS_DIAL_DEF dl_save;
LOCAL_C INT GetForegroundClient(VOID)
{
UWORD pids[WS_MAX_CLIENTS+1];
wGetProcessList(&pids[0]);
return(pids[0]);
}
LOCAL_C INT GetTestForegroundClient(VOID)
{
INT pid;
pid=GetForegroundClient();
if (!p_send3(DatGate,O_GT_CHECK_ATS_ON,pid))
return(pid); /* okay */
p_sound(5,320);
p_sound(5,280);
p_sound(5,240);
return(NULL);
}
LOCAL_C VOID ForegroundAtsWait(INT type,ATS_MESS_BODY *pu)
{
INT pid;
pid=GetTestForegroundClient();
if (pid)
p_msendreceivew(pid,type,pu);
}
LOCAL_C VOID Message(TEXT *msg)
{
ATS_MESS_BODY u;
u.offs=msg;
ForegroundAtsWait(TY_ATS_MESSAGE,&u);
}
LOCAL_C VOID TellErr(INT err)
{
TEXT buf[64];
if (err==E_GEN_FAIL)
return;
p_errs(&buf[0],err);
Message(&buf[0]);
}
LOCAL_C VOID TellOom(VOID)
{
TellErr(E_GEN_NOMEMORY);
}
LOCAL_C VOID PlayNextKey(VOID)
{
ATS_MESS_BODY u;
u.k=mac_play->keys[play_keys];
play_active=TRUE;
p_msendreceivea(pid,TY_ATS_KEY,&u,&play_stat);
}
LOCAL_C VOID RequestNextKey(VOID)
{
ATS_MESS_BODY u;
u.offs=(&full_key);
rec_active=TRUE;
p_msendreceivea(pid,TY_ATS_GET_KEY,&u,&rec_stat);
}
LOCAL_C VOID TransmitRecordState(VOID)
{
ATS_MESS_BODY u;
u.par=record;
p_msendreceivew(pid,TY_ATS_RECORD,&u);
}
LOCAL_C KATS_MACRO *FindMacro(INT i)
{
return((KATS_MACRO *)p_send(vaxvar,O_VA_PBUF,i));
}
LOCAL_C VOID DeleteMacro(INT i)
{
p_send3(vaxvar,O_VA_DELETE,i);
nmacros--;
changed=TRUE;
}
LOCAL_C INT QueryOverwrite(VOID)
{
ATS_MESS_BODY u;
u.d=dl_confirm;
return(p_msendreceivew(pid,TY_ATS_DIALOG,&u));
}
LOCAL_C VOID SaveIfConfirmed(VOID)
{
INT pid;
ATS_MESS_BODY u;
pid=GetTestForegroundClient();
if (!pid)
return;
u.d=dl_save;
if (p_msendreceivew(pid,TY_ATS_DIALOG,&u)==W_KEY_RETURN)
{
Message("Should save now!");
changed=FALSE;
}
}
LOCAL_C INT CheckNotMatching(VOID)
{
INT i;
KATS_MACRO *pmac;
INT key;
for (i=0; i<nmacros; i++)
{
pmac=FindMacro(i);
if (p_scmpi(&pmac->name[0],&mac_rec.name[0]))
continue;
key=QueryOverwrite();
if (key==W_KEY_ESCAPE)
return(FALSE);
DeleteMacro(i);
return(key==' ');
}
return(TRUE);
}
LOCAL_C INT GetMacroName(VOID)
{
ATS_MESS_BODY u;
INT ret;
u.d=dl_edit;
ret=p_msendreceivew(pid,TY_ATS_DIALOG,&u);
if (ret<0)
{
TellErr(ret);
return(0);
}
return(CheckNotMatching());
}
LOCAL_C VOID StartRecording(VOID)
{
pid=GetTestForegroundClient();
if (!pid)
return;
if (GetMacroName())
{
record=TRUE;
TransmitRecordState();
Message("Recording...");
mac_rec.num_keys=0;
RequestNextKey();
}
}
#pragma save,ENTER_CALL
LOCAL_C INT AppendMacro(VOID)
{
RC_VAXVAR rcv;
rcv.buf=(UBYTE *)(&mac_rec);
rcv.len=MACRO_NAME_LEN+sizeof(WORD)+mac_rec.num_keys*sizeof(ATS_KEY_DEF);
p_send3(vaxvar,O_VA_APPEND,&rcv);
nmacros++;
return(0);
}
#pragma restore
LOCAL_C VOID StopRecording(VOID)
{
record=FALSE;
TransmitRecordState();
if (!mac_rec.num_keys)
{
Message("Recording cancelled");
return;
}
if (p_enter1(AppendMacro)<0)
TellOom();
else if (mac_rec.num_keys==MAX_NUM_KEYS)
Message("Maximum number of keystrokes reached");
else
Message("Finished recording");
}
LOCAL_C VOID BuildNameList(VOID)
{
UBYTE *pb;
UBYTE *new_pb;
INT i;
INT size;
INT this_size;
KATS_MACRO *pmac;
pb=p_alloc(1);
if (!pb)
return;
size=1;
*pb=0;
for (i=0; i<nmacros; i++)
{
pmac=FindMacro(i);
this_size=p_slen(&pmac->name[0])+2; /* include LBC and ZTS */
new_pb=p_realloc(pb,size+this_size);
if (!new_pb)
{
p_free(pb);
return;
}
pb=new_pb;
*(pb+size)=this_size-1; /* leading byte count */
p_scpy(pb+size+1,&pmac->name[0]);
size+=this_size;
}
*pb=i;
dl_choose.buts=(UWORD)pb;
dl_choose.butslen=size;
}
LOCAL_C VOID FreeNameList(VOID)
{
p_free((VOID *)dl_choose.buts);
dl_choose.buts=NULL;
}
LOCAL_C VOID StartPlayback(VOID)
{
ATS_MESS_BODY u;
INT ret;
pid=GetTestForegroundClient();
if (!pid)
return;
BuildNameList();
if (!dl_choose.buts)
{
TellOom();
return;
}
u.d=dl_choose;
ret=p_msendreceivew(pid,TY_ATS_DIALOG,&u);
FreeNameList();
if (ret<0)
{
TellErr(ret);
return;
}
mac_play=FindMacro(ret);
play_keys=0;
playback=TRUE;
PlayNextKey();
}
LOCAL_C VOID StopPlayback(VOID)
{
playback=FALSE;
}
LOCAL_C VOID NextStageInRecord(VOID)
{
ATS_KEY_DEF *short_key;
short_key=(&mac_rec.keys[mac_rec.num_keys++]);
short_key->key=full_key.keycode;
short_key->mod=full_key.modifiers;
changed=TRUE;
if (mac_rec.num_keys==MAX_NUM_KEYS)
StopRecording();
else
RequestNextKey();
}
LOCAL_C VOID NextStageInPlayback(VOID)
{
play_keys++;
if (play_keys==mac_play->num_keys)
{
StopPlayback();
Message("Playback complete");
}
else
PlayNextKey();
}
LOCAL_C VOID MainLoop(VOID)
{
FOREVER
{
wGetEvent(&event);
wait:
p_iowait();
switch (event.type)
{
case E_FILE_PENDING:
if (rec_active && rec_stat!=E_FILE_PENDING)
{
rec_active=FALSE;
if (record) /* else recording cancelled */
NextStageInRecord();
}
else if (play_active && play_stat!=E_FILE_PENDING)
{
play_active=FALSE;
if (playback) /* else playback cancelled */
NextStageInPlayback();
}
goto wait;
case WM_FOREGROUND:
wClientPosition(WS_LAST_CLIENT_POSITION,0);
break;
case WM_KEY:
switch (event.p.key.keycode)
{
case KATS_SAVE:
if (record)
Message("Can't save macros while recording");
else if (playback)
Message("Can't save macros while playing back");
else if (!changed)
Message("No macro changes to save");
else
SaveIfConfirmed();
break;
case KATS_RECORD:
if (record)
StopRecording();
else if (playback)
Message("Can't record while playing back");
else
StartRecording();
break;
case KATS_PLAYBACK:
case KATS_PLAYBACK2:
if (playback)
{
Message("Playback terminated");
StopPlayback();
}
else if (record)
Message("Can't play back while recording");
else if (!nmacros)
Message("Nothing to play back");
else
StartPlayback();
}
}
}
}
LOCAL_C VOID FindOlib(VOID)
{
p_findlib("OLIB.DYL",&olib);
}
LOCAL_C VOID CreateGate(VOID)
{
HANDLE hwim;
p_findlib("HWIM.DYL",&hwim);
DatGate=f_newlibh(hwim,C_GATE);
}
LOCAL_C VOID LoadDialogData(VOID)
{
VOID *rcb;
rcb=f_newlibhsend(olib,C_RSCFILE,O_RS_INIT,DatCommandPtr);
dl_edit.mainlen=p_send4(rcb,O_RS_READ,KATS_DL_MAC_NAME,&dl_edit.main);
dl_choose.mainlen=p_send4(rcb,O_RS_READ,KATS_DL_PLAYBACK,&dl_choose.main);
dl_confirm.mainlen=p_send4(rcb,O_RS_READ,
KATS_DL_CONFIRM,&dl_confirm.main);
dl_confirm.butslen=p_send4(rcb,O_RS_READ,
KATS_AC_CONFIRM,&dl_confirm.buts);
dl_save.mainlen=p_send4(rcb,O_RS_READ,KATS_DL_SAVE,&dl_save.main);
dl_save.butslen=p_send4(rcb,O_RS_READ,KATS_AC_SAVE,&dl_save.buts);
p_send2(rcb,O_DESTROY);
dl_edit.butslen=(-2);
dl_edit.buts=(UWORD)(&pmac_name);
pmac_name=(&mac_rec.name[0]);
}
LOCAL_C VOID CreateMacroStorage(VOID)
{
vaxvar=f_newlibhsend(olib,C_VAXVAR,O_VA_INIT,48);
}
LOCAL_C VOID ConnectToWindowServer(VOID)
{
wConnect(f_alloc(sizeof(WSERV_SPEC)),0,W_CONNECT_AT_BACK);
}
LOCAL_C VOID CaptureKeys(VOID)
{
wCaptureKey(KATS_RECORD,KATS_MODS,KATS_MODS);
wCaptureKey(KATS_PLAYBACK,KATS_MODS,KATS_MODS);
wCaptureKey(KATS_PLAYBACK2,KATS_MODS,KATS_MODS);
wCaptureKey(KATS_SAVE,KATS_MODS,KATS_MODS);
}
#pragma save,ENTER_CALL
LOCAL_C INT Initialise(VOID)
{
FindOlib();
CreateGate();
LoadDialogData();
CreateMacroStorage();
ConnectToWindowServer();
CaptureKeys();
Message("Keyboard macro support loaded");
return(0);
}
#pragma restore
GLDEF_C INT main(VOID)
{
INT ret;
ret=p_enter1(Initialise);
if (!ret)
MainLoop();
return(ret);
}
Binary file not shown.
+13
View File
@@ -0,0 +1,13 @@
#system epoc img
#model small jpi
#if (%main.rsg #older %main.rss) #or (%main.rsc #older %main.rss) #then
#run "rs %main" no_window no_abort
#endif
#if (%main.img #older %main.afl) #or (%main.img #older %main.pic) #then
#file delete %main.img
#endif
#compile %main
#link %main
+102
View File
@@ -0,0 +1,102 @@
#include <hwim.rh>
#include <hwim.rg>
RESOURCE DIALOG kats_dl_mac_name
{
title="Record keyboard macro";
flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED;
controls=
{
CONTROL
{
class=C_EDWIN;
prompt="Name for macro";
info=EDWIN
{
flags=IN_EDWIN_VULEN_CHARACTERS;
vulen=16;
maxlen=23;
};
}
};
}
RESOURCE DIALOG kats_dl_playback
{
title="Playback keyboard macro";
flags=DLGBOX_NOTIFY_ENTER|DLGBOX_RBUF_FILLED;
controls=
{
CONTROL
{
class=C_CHLIST;
prompt="Macro name";
info=CHLIST { };
}
};
}
RESOURCE ACLIST_ARRAY kats_ac_confirm
{
button =
{
PUSH_BUT
{
keycode=W_KEY_ESCAPE;
str="Cancel";
},
PUSH_BUT
{
keycode=W_KEY_SPACE;
str="Overwrite";
},
PUSH_BUT
{
keycode=W_KEY_DELETE_LEFT;
str="Delete";
}
};
}
RESOURCE DIALOG kats_dl_confirm
{
title="Name already exists";
controls=
{
CONTROL
{
class=C_ACLIST;
info=ACLIST { rid=kats_ac_confirm; };
}
};
}
RESOURCE ACLIST_ARRAY kats_ac_save
{
button =
{
PUSH_BUT
{
keycode=W_KEY_ESCAPE;
str="Cancel";
},
PUSH_BUT
{
keycode=W_KEY_RETURN;
str="Confirm";
}
};
}
RESOURCE DIALOG kats_dl_save
{
title="Save macros to file";
controls=
{
CONTROL
{
class=C_ACLIST;
info=ACLIST { rid=kats_ac_save; };
}
};
}
+9
View File
@@ -0,0 +1,9 @@
@echo off
call checkvid
if not exist %1.pr goto error
tscx /m %1 /%jpivid%
tscx /m %1 /%jpivid%
goto end
:error
echo Project file %1.pr does not exist
:end
+22
View File
@@ -0,0 +1,22 @@
@echo off
goto X%1X
:Xv0X
:XoffX
set jpivid=v0
echo VID is now OFF
goto :end
:Xv2X
:XonX
set jpivid=v2
echo VID is now ON
goto :end
:XX
call checkvid
goto %jpivid%
:v0
echo VID is OFF
goto end
:v2
echo VID is ON
:end
+50
View File
@@ -0,0 +1,50 @@
#include <plib.h>
#include <wlib.h>
GLREF_D TEXT *DatStatusNamePtr;
LOCAL_D WSERV_SPEC wSpec;
LOCAL_C VOID CDECL Alert3(TEXT *m1,TEXT *m2,TEXT *m3)
{
TEXT *pt;
TEXT **pps;
DESC *pd,*pdend;
struct {
WORD zero;
DESC line[3];
TEXT buf[W_ALERT_TEXT_MAX_LEN];
} al;
al.zero=0;
pt=&al.buf[0];
pps=&m1;
for (pd=&al.line[0],pdend=pd+3;pd<pdend;pd++)
{
pd->hposition=0xff;
pd->length=p_slen(*pps);
pd->offset=pt-(TEXT *)&al;
pt=(TEXT *)p_bcpy(pt,*pps++,pd->length);
}
wsAlertW(WS_ALERT_CLIENT,(TEXT *)&al,NULL,NULL);
}
LOCAL_C VOID AlertErr(INT err,TEXT *msg)
{
TEXT bb[3];
bb[0]=0;
bb[1]=0xfe;
bb[2]=err;
wsAlertW(WS_ALERT_CLIENT,msg,&bb[0],NULL);
}
GLDEF_C INT main(VOID)
{
DatStatusNamePtr="Sample";
wConnect(&wSpec,0,W_CONNECT_PRIORITY);
wsAlertW(WS_ALERT_CLIENT,"Hello World",NULL,NULL);
AlertErr(E_GEN_NOMEMORY,"Failed to save");
Alert3("Line 1","Line 2","Line 3");
return(0);
}
+22
View File
@@ -0,0 +1,22 @@
CALL MAKE HELLO
CALL MAKE P_HELLO
CALL MAKE P_COMP
CALL MAKE P_DLIST
CALL MAKE P_PRNDIR
CALL MAKE P_SEARCH
CALL MAKE EVENTS
CALL MAKE SUBPROC
CALL MAKE EVENTS2
CALL MAKE EVENTS3
CALL MAKE EVENTS4
CALL MAKE W_HELLO
CALL MAKE GAUGE
CALL MAKE LINED
CALL MAKE SCAPT
CALL MAKE FONTS
CALL MAKE HCSHELL
CALL MAKE LKSHELL
CALL MAKE ALERT
CALL MAKE CLOCK
CALL MAKE BUTTON
CALL MAKE SOUND
+75
View File
@@ -0,0 +1,75 @@
/*
BUTTON.C
*/
#include <plib.h>
#include <wlib.h>
LOCAL_D WSERV_SPEC wSpec;
LOCAL_D UINT wMainWid;
LOCAL_D UINT FontID;
LOCAL_D UINT FontStyle;
LOCAL_D G_FONT_INFO FontInfo;
LOCAL_C VOID SetFont(INT fid,INT style)
{
gFontInfo(FontID=fid,FontStyle=style,&FontInfo);
}
LOCAL_C VOID SetGC(VOID)
{
G_GC gc;
gc.font=FontID;
gc.style=FontStyle;
gSetGC(0,G_GC_MASK_FONT|G_GC_MASK_STYLE,&gc);
}
LOCAL_C VOID DrawButton(INT state)
{
P_RECT rect;
rect.tl.x=20;
rect.tl.y=(40-2)-FontInfo.height;
rect.br.x=140;
rect.br.y=(40+2)+FontInfo.height;
wDrawButton(&rect,"Press any key",state);
}
LOCAL_C VOID MainEventLoop(VOID)
{
WS_EV event;
for (;;)
{
wGetEventWait(&event);
if (event.type==WM_REDRAW)
{
wBeginRedrawWinGC0(wMainWid);
gBorder(W_BORD_SHADOW_D|W_BORD_SHADOW_ON);
SetGC();
DrawButton(FALSE);
wEndRedraw();
continue;
}
if (event.type==WM_KEY)
{
gCreateTempGC0(wMainWid);
SetGC();
DrawButton(TRUE);
wFlush();
p_sleep(5l);
DrawButton(FALSE);
gFreeTempGC();
}
}
}
GLDEF_C VOID main(VOID)
{
wConnect(&wSpec,0,W_CONNECT_PRIORITY);
wMainWid=wCreateWindow(0,0,0,1);
wInitialiseWindowTree(wMainWid);
SetFont(WS_FONT_SYSTEM,G_STY_BOLD);
MainEventLoop();
}
+8
View File
@@ -0,0 +1,8 @@
@echo off
call checkvid
if exist %1.pr goto custom
tsc %1.c /fpunnamed /%jpivid%
goto end
:custom
tsc %1.c /fp%1 /%jpivid%
:end
+2
View File
@@ -0,0 +1,2 @@
@if not "%jpivid%"=="v2" set jpivid=v0
+40
View File
@@ -0,0 +1,40 @@
/*
CLOCK.C
*/
#include <plib.h>
#include <wlib.h>
LOCAL_D WSERV_SPEC wSpec;
LOCAL_D UINT wMainWid;
LOCAL_C VOID MainEventLoop(VOID)
{
WS_EV event;
for (;;)
{
wGetEventWait(&event);
if (event.type==WM_REDRAW)
{
wBeginRedrawWinGC0(wMainWid);
gBorder(W_BORD_SHADOW_D|W_BORD_SHADOW_ON);
wEndRedraw();
}
}
}
GLDEF_C VOID main(VOID)
{
wConnect(&wSpec,0,W_CONNECT_PRIORITY);
wMainWid=wCreateWindow(0,0,0,1);
wsCreateClock(wMainWid,WS_CLOCK_LARGE_ANALOG|WS_CLOCK_WITH_SECONDS,4,4,0);
wsCreateClock(wMainWid,WS_CLOCK_MEDIUM|WS_CLOCK_FORCE_DIGITAL|
WS_CLOCK_WITH_DATE,4+66+6,4,0);
wsCreateClock(wMainWid,WS_CLOCK_MEDIUM|WS_CLOCK_FORCE_ANALOG|
WS_CLOCK_WITH_DATE,4+66+6+36+6,4,0);
wsCreateClock(wMainWid,WS_CLOCK_SMALL_DIGITAL|WS_CLOCK_WITH_DATE|
WS_CLOCK_WITH_SECONDS,104,66,0);
wInitialiseWindowTree(wMainWid);
MainEventLoop();
}
+82
View File
@@ -0,0 +1,82 @@
DEMO.PRJ ! This file
READ.ME ! About the \sibosdk\demo directory
BLDALL.BAT ! Build everything in this directory
!
! ==========================
! General Programming Manual
!
! Building An Application
HELLO.C ! A first example application (using CLIB)
HELLO.PR ! Jpi project file for the above
P_HELLO.C ! A PLIB version of Hello World
P_HELLO.PR ! Jpi project file for the above
!
! Housekeeping batch files and re-using project files
UNNAMED.PR ! General (single source file) project file for Plib
CC.BAT ! For Brief-style test compiles
MAKE.BAT ! Intelligent make batch file
VID.BAT ! Sets/senses JPIVID environment variable
CHECKVID.BAT ! Used in above batch files
!
! Fundamental Programming Guidelines
EVENTS.C ! First version of Events
SUBPROC.H ! Header file for SUBPROC
SUBPROC.C ! Program launched as a subprocess
EVENTS2.C ! Second version of Events
EVENTS3.C ! Third version of Events
EVENTS4.C ! Fourth version of Events
!
! ====================
! HC Programming Guide
!
! Writing Software for the HC: Example programs
W_HELLO.C ! A graphics version of Hello World
GAUGE.C ! Graphics and timers illustrated
LINED.C ! Line editor code and test code
LINED.H ! Line editor header file
!
! ==========================
! Series 3/3a Programming Guide
!
! Enhanced Sound Output
SOUND.C ! Using the SND: device driver on the Series 3a
!
! =============================
! Additional System Information
!
! Resource Files
READRSC.C ! Reading the contents of a resource file
!
! ==============
! PLIB Reference
!
! Files
P_DLIST.C ! Using p_dinfo to list devices
P_PRNDIR.C ! Using p_open(P_FDIR) to list a directory
P_COMP.C ! Binary file access (comparing two files)
P_SEARCH.C ! Text file access (p_read to search a text file)
!
! =======================
! Window Server Reference
!
! Introduction: Bitmaps
PCXSAVE.C ! Capturing the screen directly to a PCX file
SCAPT.C ! Screen capture program using MCLINK RUN
SCAPT.PR ! Jpi project file for the above
!
! Introduction: Text fonts
FONTS.C ! The program that generated the font pictures
!
! Introduction: System start-up: Replacing the shell on the HC
HCSHELL.C ! Sample shell/application
LKSHELL.C ! Minimal shell for remote debugging on the HC
LKSHELL.PR ! Defines small stack
!
! General window server functions: wsAlertW
ALERT.C ! Alert3 example of calling wsAlertW
!
! Windows: Clocks
CLOCK.C ! Clocks demonstration for the HC
!
! Graphics output: wDrawButton
BUTTON.C ! Intended use of wDrawButton
+136
View File
@@ -0,0 +1,136 @@
/* EVENTS.C */
#include <p_std.h>
#include <p_file.h>
#include <p_cons.h>
#include <epoc.h>
#include <wskeys.h>
LOCAL_D VOID *timH;
LOCAL_D WORD timstat;
LOCAL_D WORD counter;
LOCAL_D ULONG timint;
LOCAL_D VOID *conH;
LOCAL_D WORD keystat;
LOCAL_D P_CON_KBREC key;
#define MAX_COUNT 100
LOCAL_C VOID QueueKey(VOID)
{
p_ioa4(conH,P_FREAD,&keystat,&key);
}
LOCAL_C VOID QueueTimer(VOID)
{
p_ioa4(timH,P_FRELATIVE,&timstat,&timint);
}
LOCAL_C VOID CancelTimer(VOID)
{
p_iow2(timH,P_FCANCEL);
p_waitstat(&timstat);
}
LOCAL_C VOID Check(INT val,TEXT *msg)
{
TEXT buf[30];
if (!val)
return;
p_atos(&buf[0],"Failed to open %s",msg);
p_notifyerr(val,&buf[0],0,0,0);
p_exit(0);
}
LOCAL_C VOID OpenTimer(VOID)
{
Check(p_open(&timH,"TIM:",-1),"timer");
}
LOCAL_C VOID OpenConsole(VOID)
{
P_RECT rect;
WORD func;
Check(p_open(&conH,"CON:",-1),"console");
rect.tl.x=rect.tl.y=0;
rect.br.x=25;
rect.br.y=9;
func=P_SCR_WSET;
Check(p_iow4(conH,P_FSET,&func,&rect),"console");
}
LOCAL_C VOID SetTimInt(INT new)
{
CancelTimer();
timint=new;
QueueTimer();
}
LOCAL_C VOID Write(INT x,INT y,TEXT *pb,INT len)
{
P_POINT pos;
WORD func;
pos.x=x;
pos.y=y;
func=P_SCR_POSA;
p_iow4(conH,P_FSET,&func,&pos);
p_write(conH,pb,len);
}
LOCAL_C VOID DisplayCount(VOID)
{
TEXT buf[4];
p_atos(&buf[0],"%3d",counter);
Write(10,2,&buf[0],3);
}
LOCAL_C VOID DrawBorder(VOID)
{
TEXT buf[26];
INT i;
p_bfil(&buf[0],26,'*');
Write(0,0,&buf[0],25);
for (i=1; i<8; i++)
{
Write(0,i,&buf[0],1);
Write(24,i,&buf[0],1);
}
Write(0,8,&buf[0],25);
}
GLDEF_C VOID main(VOID)
{
OpenConsole();
DrawBorder();
OpenTimer();
timint=10;
QueueTimer();
QueueKey();
FOREVER
{
p_iowait();
if (keystat!=E_FILE_PENDING)
{
if (key.keycode==W_KEY_ESCAPE)
p_exit(0);
if (key.keycode>='1' && key.keycode<='9')
SetTimInt(2*(key.keycode-'0'));
QueueKey();
}
else if (timstat!=E_FILE_PENDING)
{
if (counter++==MAX_COUNT)
counter=1;
DisplayCount();
QueueTimer();
}
}
}
+200
View File
@@ -0,0 +1,200 @@
/* EVENTS2.C */
#include <p_std.h>
#include <p_file.h>
#include <p_cons.h>
#include <epoc.h>
#include <wskeys.h>
#include "subproc.h"
GLREF_C TEXT *DatCommandPtr;
LOCAL_D VOID *timH;
LOCAL_D WORD timstat;
LOCAL_D WORD counter;
LOCAL_D ULONG timint;
LOCAL_D VOID *conH;
LOCAL_D WORD keystat;
LOCAL_D P_CON_KBREC key;
LOCAL_D WORD subexist;
LOCAL_D WORD substat;
LOCAL_D WORD answer;
#define MAX_COUNT 100
LOCAL_C VOID QueueKey(VOID)
{
p_ioa4(conH,P_FREAD,&keystat,&key);
}
LOCAL_C VOID QueueTimer(VOID)
{
p_ioa4(timH,P_FRELATIVE,&timstat,&timint);
}
LOCAL_C VOID CancelTimer(VOID)
{
p_iow2(timH,P_FCANCEL);
p_waitstat(&timstat);
}
LOCAL_C VOID Check(INT val,TEXT *msg)
{
TEXT buf[30];
if (!val)
return;
p_atos(&buf[0],"Failed to open %s",msg);
p_notifyerr(val,&buf[0],0,0,0);
p_exit(0);
}
LOCAL_C VOID OpenTimer(VOID)
{
Check(p_open(&timH,"TIM:",-1),"timer");
}
LOCAL_C VOID OpenConsole(VOID)
{
P_RECT rect;
WORD func;
Check(p_open(&conH,"CON:",-1),"console");
rect.tl.x=rect.tl.y=0;
rect.br.x=25;
rect.br.y=9;
func=P_SCR_WSET;
Check(p_iow4(conH,P_FSET,&func,&rect),"console");
}
LOCAL_C VOID SetTimInt(INT new)
{
CancelTimer();
timint=new;
QueueTimer();
}
LOCAL_C VOID Write(INT x,INT y,TEXT *pb,INT len)
{
P_POINT pos;
WORD func;
pos.x=x;
pos.y=y;
func=P_SCR_POSA;
p_iow4(conH,P_FSET,&func,&pos);
p_write(conH,pb,len);
}
LOCAL_C VOID DisplayCount(VOID)
{
TEXT buf[4];
p_atos(&buf[0],"%3d",counter);
Write(10,2,&buf[0],3);
}
LOCAL_C VOID DrawBorder(VOID)
{
TEXT buf[26];
INT i;
p_bfil(&buf[0],26,'*');
Write(0,0,&buf[0],25);
for (i=1; i<8; i++)
{
Write(0,i,&buf[0],1);
Write(24,i,&buf[0],1);
}
Write(0,8,&buf[0],25);
}
LOCAL_C VOID Message(TEXT *pb)
{
TEXT buf[22];
INT len;
p_bfil(&buf[0],22,' ');
len=p_slen(pb);
p_bcpy(&buf[10-len/2],pb,len);
Write(2,6,&buf[0],21);
}
LOCAL_C VOID LaunchSub(VOID)
{
HANDLE pid;
SUBPROC_CL cl;
TEXT subname[P_FNAMESIZE];
if (subexist)
{
p_sound(-5,320);
return;
}
p_fparse("subproc.img",DatCommandPtr,&subname[0],0);
cl.pid=p_getpid();
cl.poff=(&answer);
cl.data=p_date();
if ((pid=p_execc(&subname[0],&cl,sizeof(cl)))<0)
{
p_notifyerr(pid,"Failed to launch subprocess",0,0,0);
return;
}
p_logona(pid,&substat);
subexist=TRUE;
Message("Subp launched");
p_presume(pid);
}
LOCAL_C VOID ReportSub(VOID)
{
TEXT buf[22];
subexist=FALSE;
if (substat)
Message("Subp abnormal exit");
else
{
p_atos(&buf[0],"Subp slept %d ticks",answer);
Message(&buf[0]);
}
}
GLDEF_C VOID main(VOID)
{
p_unmarka();
OpenConsole();
DrawBorder();
OpenTimer();
timint=10;
QueueTimer();
QueueKey();
LaunchSub();
FOREVER
{
p_iowait();
if (keystat!=E_FILE_PENDING)
{
if (key.keycode==W_KEY_ESCAPE)
p_exit(0);
if (key.keycode==W_KEY_RETURN)
LaunchSub();
else if (key.keycode>='1' && key.keycode<='9')
SetTimInt(2*(key.keycode-'0'));
QueueKey();
}
else if (timstat!=E_FILE_PENDING)
{
if (counter++==MAX_COUNT)
counter=1;
DisplayCount();
QueueTimer();
}
else if (substat!=E_FILE_PENDING)
ReportSub();
}
}
+252
View File
@@ -0,0 +1,252 @@
/* EVENTS3.C */
#include <p_std.h>
#include <p_file.h>
#include <p_cons.h>
#include <epoc.h>
#include <wskeys.h>
#include "subproc.h"
GLREF_C TEXT *DatCommandPtr;
LOCAL_D VOID *timH;
LOCAL_D WORD timstat;
LOCAL_D WORD counter;
LOCAL_D ULONG timint;
LOCAL_D VOID *conH;
LOCAL_D WORD keystat;
LOCAL_D P_CON_KBREC key;
LOCAL_D WORD subexist;
LOCAL_D WORD substat;
LOCAL_D WORD answer;
LOCAL_D VOID *serH;
LOCAL_D WORD serstat;
LOCAL_D WORD serlen;
LOCAL_D TEXT serbuf[2];
LOCAL_D WORD serpos;
#define MAX_COUNT 100
#define MAX_SERPOS 11
LOCAL_C VOID QueueKey(VOID)
{
p_ioa4(conH,P_FREAD,&keystat,&key);
}
LOCAL_C VOID QueueTimer(VOID)
{
p_ioa4(timH,P_FRELATIVE,&timstat,&timint);
}
LOCAL_C VOID CancelTimer(VOID)
{
p_iow2(timH,P_FCANCEL);
p_waitstat(&timstat);
}
LOCAL_C VOID Check(INT val,TEXT *msg)
{
TEXT buf[30];
if (!val)
return;
p_atos(&buf[0],"Failed to open %s",msg);
p_notifyerr(val,&buf[0],0,0,0);
p_exit(0);
}
LOCAL_C VOID OpenTimer(VOID)
{
Check(p_open(&timH,"TIM:",-1),"timer");
}
LOCAL_C VOID OpenConsole(VOID)
{
P_RECT rect;
WORD func;
Check(p_open(&conH,"CON:",-1),"console");
rect.tl.x=rect.tl.y=0;
rect.br.x=25;
rect.br.y=9;
func=P_SCR_WSET;
Check(p_iow4(conH,P_FSET,&func,&rect),"console");
}
LOCAL_C VOID SetTimInt(INT new)
{
CancelTimer();
timint=new;
QueueTimer();
}
LOCAL_C VOID Write(INT x,INT y,TEXT *pb,INT len)
{
P_POINT pos;
WORD func;
pos.x=x;
pos.y=y;
func=P_SCR_POSA;
p_iow4(conH,P_FSET,&func,&pos);
p_write(conH,pb,len);
}
LOCAL_C VOID DisplayCount(VOID)
{
TEXT buf[4];
p_atos(&buf[0],"%3d",counter);
Write(10,2,&buf[0],3);
}
LOCAL_C VOID DrawBorder(VOID)
{
TEXT buf[26];
INT i;
p_bfil(&buf[0],26,'*');
Write(0,0,&buf[0],25);
for (i=1; i<8; i++)
{
Write(0,i,&buf[0],1);
Write(24,i,&buf[0],1);
}
Write(0,8,&buf[0],25);
}
LOCAL_C VOID Message(TEXT *pb)
{
TEXT buf[22];
INT len;
p_bfil(&buf[0],22,' ');
len=p_slen(pb);
p_bcpy(&buf[10-len/2],pb,len);
Write(2,6,&buf[0],21);
}
LOCAL_C VOID LaunchSub(VOID)
{
HANDLE pid;
SUBPROC_CL cl;
TEXT subname[P_FNAMESIZE];
if (subexist)
{
p_sound(-5,320);
return;
}
p_fparse("subproc.img",DatCommandPtr,&subname[0],0);
cl.pid=p_getpid();
cl.poff=(&answer);
cl.data=p_date();
if ((pid=p_execc(&subname[0],&cl,sizeof(cl)))<0)
{
p_notifyerr(pid,"Failed to launch subprocess",0,0,0);
return;
}
p_logona(pid,&substat);
subexist=TRUE;
Message("Subp launched");
p_presume(pid);
}
LOCAL_C VOID ReportSub(VOID)
{
TEXT buf[22];
subexist=FALSE;
if (substat)
Message("Subp abnormal exit");
else
{
p_atos(&buf[0],"Subp slept %d ticks",answer);
Message(&buf[0]);
}
}
LOCAL_C VOID QueueSer()
{
if (!serH)
return;
serlen=1;
p_ioa5(serH,P_FREAD,&serstat,&serbuf[0],&serlen);
}
LOCAL_C VOID OpenSer()
{
INT ret;
ret=p_open(&serH,"TTY:B",-1);
if (ret<0)
ret=p_open(&serH,"TTY:A",-1);
if (ret<0)
{
p_notifyerr(ret,"Opening serial port",0,0,0);
serH=0;
}
}
LOCAL_C VOID DisplaySerChar(VOID)
{
TEXT buf[12];
if (!serlen || !p_isprint(serbuf[0]))
return;
if (serpos++==MAX_SERPOS)
{
serpos=1;
p_bfil(&buf[0],12,' ');
Write(7,4,&buf[0],11);
}
Write(6+serpos,4,&serbuf[0],1);
}
GLDEF_C VOID main(VOID)
{
p_unmarka();
OpenConsole();
DrawBorder();
OpenTimer();
timint=10;
QueueTimer();
QueueKey();
LaunchSub();
OpenSer();
QueueSer();
FOREVER
{
p_iowait();
if (keystat!=E_FILE_PENDING)
{
if (key.keycode==W_KEY_ESCAPE)
p_exit(0);
if (key.keycode==W_KEY_RETURN)
LaunchSub();
else if (key.keycode>='1' && key.keycode<='9')
SetTimInt(2*(key.keycode-'0'));
QueueKey();
}
else if (timstat!=E_FILE_PENDING)
{
if (counter++==MAX_COUNT)
counter=1;
DisplayCount();
QueueTimer();
}
else if (subexist && substat!=E_FILE_PENDING)
ReportSub();
else if (serH && serstat!=E_FILE_PENDING)
{
p_tickle();
DisplaySerChar();
QueueSer();
}
}
}
+278
View File
@@ -0,0 +1,278 @@
/* EVENTS4.C */
#include <p_std.h>
#include <p_file.h>
#include <p_cons.h>
#include <epoc.h>
#include <wskeys.h>
#include "subproc.h"
GLREF_C TEXT *DatCommandPtr;
LOCAL_D VOID *timH;
LOCAL_D WORD timstat;
LOCAL_D WORD counter;
LOCAL_D ULONG timint;
LOCAL_D VOID *conH;
LOCAL_D WORD keystat;
LOCAL_D P_CON_KBREC key;
LOCAL_D WORD subexist;
LOCAL_D WORD substat;
LOCAL_D WORD answer;
LOCAL_D VOID *serH;
LOCAL_D WORD serstat;
LOCAL_D WORD serlen;
LOCAL_D TEXT serbuf[2];
LOCAL_D WORD serpos;
LOCAL_D WORD thinkcount;
LOCAL_D TEXT thinkchar[4]={'-','\\','|','/'};
#define MAX_COUNT 100
#define MAX_SERPOS 11
#define MAX_THINK 20
LOCAL_C VOID QueueKey(VOID)
{
p_ioa4(conH,P_FREAD,&keystat,&key);
}
LOCAL_C VOID QueueTimer(VOID)
{
p_ioa4(timH,P_FRELATIVE,&timstat,&timint);
}
LOCAL_C VOID CancelTimer(VOID)
{
p_iow2(timH,P_FCANCEL);
p_waitstat(&timstat);
}
LOCAL_C VOID Check(INT val,TEXT *msg)
{
TEXT buf[30];
if (!val)
return;
p_atos(&buf[0],"Failed to open %s",msg);
p_notifyerr(val,&buf[0],0,0,0);
p_exit(0);
}
LOCAL_C VOID OpenTimer(VOID)
{
Check(p_open(&timH,"TIM:",-1),"timer");
}
LOCAL_C VOID OpenConsole(VOID)
{
P_RECT rect;
WORD func;
Check(p_open(&conH,"CON:",-1),"console");
rect.tl.x=rect.tl.y=0;
rect.br.x=25;
rect.br.y=9;
func=P_SCR_WSET;
Check(p_iow4(conH,P_FSET,&func,&rect),"console");
}
LOCAL_C VOID SetTimInt(INT new)
{
CancelTimer();
timint=new;
QueueTimer();
}
LOCAL_C VOID Write(INT x,INT y,TEXT *pb,INT len)
{
P_POINT pos;
WORD func;
pos.x=x;
pos.y=y;
func=P_SCR_POSA;
p_iow4(conH,P_FSET,&func,&pos);
p_write(conH,pb,len);
}
LOCAL_C VOID DisplayCount(VOID)
{
TEXT buf[4];
p_atos(&buf[0],"%3d",counter);
Write(10,2,&buf[0],3);
}
LOCAL_C VOID DrawBorder(VOID)
{
TEXT buf[26];
INT i;
p_bfil(&buf[0],26,'*');
Write(0,0,&buf[0],25);
for (i=1; i<8; i++)
{
Write(0,i,&buf[0],1);
Write(24,i,&buf[0],1);
}
Write(0,8,&buf[0],25);
}
LOCAL_C VOID Message(TEXT *pb)
{
TEXT buf[22];
INT len;
p_bfil(&buf[0],22,' ');
len=p_slen(pb);
p_bcpy(&buf[10-len/2],pb,len);
Write(2,6,&buf[0],21);
}
LOCAL_C VOID LaunchSub(VOID)
{
HANDLE pid;
SUBPROC_CL cl;
TEXT subname[P_FNAMESIZE];
if (subexist)
{
p_sound(-5,320);
return;
}
p_fparse("subproc.img",DatCommandPtr,&subname[0],0);
cl.pid=p_getpid();
cl.poff=(&answer);
cl.data=p_date();
if ((pid=p_execc(&subname[0],&cl,sizeof(cl)))<0)
{
p_notifyerr(pid,"Failed to launch subprocess",0,0,0);
return;
}
p_logona(pid,&substat);
subexist=TRUE;
Message("Subp launched");
p_presume(pid);
}
LOCAL_C VOID ReportSub(VOID)
{
TEXT buf[22];
subexist=FALSE;
if (substat)
Message("Subp abnormal exit");
else
{
p_atos(&buf[0],"Subp slept %d ticks",answer);
Message(&buf[0]);
}
}
LOCAL_C VOID QueueSer()
{
if (!serH)
return;
serlen=1;
p_ioa5(serH,P_FREAD,&serstat,&serbuf[0],&serlen);
}
LOCAL_C VOID OpenSer()
{
INT ret;
ret=p_open(&serH,"TTY:B",-1);
if (ret<0)
ret=p_open(&serH,"TTY:A",-1);
if (ret<0)
{
p_notifyerr(ret,"Opening serial port",0,0,0);
serH=0;
}
}
LOCAL_C VOID DisplaySerChar(VOID)
{
TEXT buf[12];
if (!serlen || !p_isprint(serbuf[0]))
return;
if (serpos++==MAX_SERPOS)
{
serpos=1;
p_bfil(&buf[0],12,' ');
Write(7,4,&buf[0],11);
}
Write(6+serpos,4,&serbuf[0],1);
}
LOCAL_C VOID Think(VOID)
{
TEXT *pb;
if (thinkcount++==MAX_THINK)
thinkcount=0;
pb=(&thinkchar[thinkcount/5]);
Write(0,4,pb,1);
Write(25,4,pb,1);
}
LOCAL_C VOID QueueThink(VOID)
{
p_iosignal();
}
GLDEF_C VOID main(VOID)
{
p_unmarka();
OpenConsole();
DrawBorder();
OpenTimer();
timint=10;
QueueTimer();
QueueKey();
LaunchSub();
OpenSer();
QueueSer();
QueueThink();
FOREVER
{
p_iowait();
if (keystat!=E_FILE_PENDING)
{
if (key.keycode==W_KEY_ESCAPE)
p_exit(0);
if (key.keycode==W_KEY_RETURN)
LaunchSub();
else if (key.keycode>='1' && key.keycode<='9')
SetTimInt(2*(key.keycode-'0'));
QueueKey();
}
else if (timstat!=E_FILE_PENDING)
{
if (counter++==MAX_COUNT)
counter=1;
DisplayCount();
QueueTimer();
}
else if (subexist && substat!=E_FILE_PENDING)
ReportSub();
else if (serH && serstat!=E_FILE_PENDING)
{
p_tickle();
DisplaySerChar();
QueueSer();
}
else
{
Think();
QueueThink();
}
}
}
+218
View File
@@ -0,0 +1,218 @@
/*
FONTS.C - Display fonts
This program was used to produce the font displays in the Window Server
Reference manual.
*/
#include <plib.h>
#include <wlib.h>
#define MINX 2
#define MINY 2
#define WIDTH 160
LOCAL_D INT FontID;
LOCAL_D INT CurrentY,CurrentX;
LOCAL_D G_FONT_INFO FontInfo;
LOCAL_C VOID DrawSideLines(INT y1,INT dy)
{
gDrawLine(0,y1,0,y1+dy+1);
gDrawLine(WIDTH-1,y1,WIDTH-1,y1+dy+1);
}
LOCAL_C VOID PrintHexNumber(INT x,INT y,UINT n)
{
TEXT buf[5];
gPrintText(x,y,&buf[0],p_gtob(&buf[0],n,16));
}
LOCAL_C VOID CDECL PrintLine(INT style,INT final,TEXT *fmt,...)
{
INT height,ascent,len;
P_RECT box;
G_GC gc;
TEXT b[80];
height=FontInfo.height;
ascent=FontInfo.ascent;
if (style&G_STY_DOUBLE)
{
height<<=1;
ascent<<=1;
}
if (CurrentX==MINX)
DrawSideLines(CurrentY,height+1);
gc.font=FontID;
gc.style=style;
gSetGC(0,G_GC_MASK_FONT|G_GC_MASK_STYLE,&gc);
len=p_atob(&b[0],fmt,&fmt+1);
box.tl.x=CurrentX;
box.br.x=WIDTH-MINX;
box.tl.y=CurrentY;
box.br.y=box.tl.y+height;
if (box.br.x>box.tl.x)
gPrintBoxText(&box,ascent,G_TEXT_ALIGN_LEFT,0,&b[0],len);
if (final)
{
CurrentY+=height+1;
CurrentX=MINX;
}
else
CurrentX+=gTextWidth(FontID,style,&b[0],len);
}
LOCAL_C VOID SaveFontCodes(VOID)
{
INT x,y,dx,dy,xo,yo,yy;
INT bitmap;
W_OPEN_BIT_SEG bit;
G_GC gc;
P_RECT rect;
TEXT name[32];
dx=18;
dy=FontInfo.height+1;
xo=FontInfo.numeric_width+(MINX+5);
yo=FontInfo.ascent+(MINY+3);
bit.size.x=dx*16+xo+MINX;
bit.size.y=dy*16+yo+MINY;
bitmap=gCreateBit(0,&bit);
gCreateTempGC0(bitmap);
gc.font=FontID;
gSetGC(0,G_GC_MASK_FONT,&gc);
rect.tl.x=rect.tl.y=0;
rect.br=bit.size;
gClrRect(&rect,G_TRMODE_CLR);
gDrawBox(&rect);
rect.tl.x=xo-2;
rect.tl.y=yo-2;
gDrawBox(&rect);
for (x=0;x<16;x++)
PrintHexNumber(x*dx+xo,FontInfo.ascent+1,x);
name[0]=0;
for (y=0;y<16;y++)
{
PrintHexNumber(3,yy=y*dy+yo+FontInfo.ascent,y);
for (x=0;x<16;x++)
{
gPrintText(x*dx+xo,yy,&name[0],1);
name[0]++;
}
}
gFreeTempGC();
p_atos(&name[0],"rem::fcode%d.pic",FontID-WS_FONT_BASE);
gSaveBit(&name[0],bitmap);
wFree(bitmap);
}
LOCAL_C VOID DrawFontStyles(VOID)
{
P_RECT rect;
CurrentY=MINY;
CurrentX=MINX;
rect.tl.x=rect.tl.y=0;
rect.br.x=WIDTH;
rect.br.y=1000;
gClrRect(&rect,G_TRMODE_CLR);
gDrawLine(0,0,WIDTH,0);
DrawSideLines(0,MINY);
PrintLine(G_STY_NORMAL,FALSE,"Normal text (%d) ",FontInfo.height);
PrintLine(G_STY_BOLD,TRUE,"Bold text");
PrintLine(G_STY_ITALIC,FALSE,"Italic text ");
PrintLine(G_STY_MONO,TRUE,"Mono text");
PrintLine(G_STY_DOUBLE,FALSE,"Double height ");
PrintLine(G_STY_DOUBLE|G_STY_BOLD,TRUE,"Double bold");
gDrawLine(0,CurrentY,WIDTH,CurrentY);
}
LOCAL_C VOID SaveFontStyles(VOID)
{
INT bitmap;
W_OPEN_BIT_SEG bit;
TEXT name[32];
bit.size.x=WIDTH;
bit.size.y=CurrentY+1;
bitmap=gCreateBit(0,&bit);
gCreateTempGC0(bitmap);
DrawFontStyles();
gFreeTempGC();
p_atos(&name[0],"rem::font%d.pic",FontID-WS_FONT_BASE);
gSaveBit(&name[0],bitmap);
wFree(bitmap);
}
LOCAL_C VOID SetFont(INT fid)
{
gFontInfo(FontID=fid,0,&FontInfo);
}
LOCAL_C VOID HandleKeyPress(INT code)
{
INT i;
if (code=='\r')
p_exit(0);
if ('0'<=code && code<'6')
{
SetFont(code-'0'+WS_FONT_BASE);
DrawFontStyles();
}
if (code=='s')
{
wSetBusyMsg("Saving",W_CORNER_TOP_LEFT);
SaveFontStyles();
wCancelBusyMsg();
wInfoMsg("Styles bitmap saved");
}
if (code=='a')
{
wSetBusyMsg("Saving",W_CORNER_TOP_LEFT);
for (i=0;i<6;i++)
{
SetFont(i+WS_FONT_BASE);
DrawFontStyles();
SaveFontStyles();
}
wCancelBusyMsg();
wInfoMsg("Bitmaps saved");
}
if (code=='c')
{
wSetBusyMsg("Saving",W_CORNER_TOP_LEFT);
SaveFontCodes();
wCancelBusyMsg();
wInfoMsg("Codes bitmap saved");
}
if (code=='z')
{
wSetBusyMsg("Saving",W_CORNER_TOP_LEFT);
for (i=0;i<6;i++)
{
SetFont(i+WS_FONT_BASE);
SaveFontCodes();
}
wCancelBusyMsg();
wInfoMsg("Bitmaps saved");
}
}
GLDEF_C INT main(VOID)
{
WS_EV event;
wStartup();
SetFont(WS_FONT_BASE);
DrawFontStyles();
for (;;)
{
wGetEventWait(&event);
if (event.type==WM_KEY)
HandleKeyPress(event.p.key.keycode);
}
return(0);
}
+212
View File
@@ -0,0 +1,212 @@
#include <p_std.h>
#include <p_file.h>
#include <wlib.h>
LOCAL_D VOID *timH;
LOCAL_D WORD timstat;
LOCAL_D WORD counter;
LOCAL_D ULONG timint;
#define NUM_STEPS 9
#define STEP_WIDTH 16
#define BAR_LEFT 8
#define BAR_WIDTH 144
LOCAL_C VOID GetBarChartRect(P_RECT *pbox)
{
pbox->tl.x=BAR_LEFT;
pbox->br.x=BAR_LEFT+BAR_WIDTH;
pbox->br.y=80-4-1;
pbox->tl.y=80-4-1-6;
}
LOCAL_C VOID QueueTimer(VOID)
{
p_ioa4(timH,P_FRELATIVE,&timstat,&timint);
}
LOCAL_C VOID CancelTimer(VOID)
{
p_iow2(timH,P_FCANCEL);
p_waitstat(&timstat);
}
LOCAL_C VOID CentrePrint(INT y1,INT y2,INT ascent,TEXT *pb)
{
P_RECT box;
box.tl.x=4;
box.br.x=160-4;
box.tl.y=y1;
box.br.y=y2;
gPrintBoxText(&box,ascent,G_TEXT_ALIGN_CENTRE,0,pb,p_slen(pb));
}
LOCAL_C VOID SetFont(INT font)
{
G_GC gc;
gc.font=font;
gSetGC(0,G_GC_MASK_FONT,&gc);
}
LOCAL_C VOID SetStyle(INT style)
{
G_GC gc;
gc.style=style;
gSetGC(0,G_GC_MASK_STYLE,&gc);
}
LOCAL_C VOID TellCounter(VOID)
{
TEXT buf[10];
p_atos(&buf[0],"%d",counter);
SetStyle(G_STY_DOUBLE|G_STY_BOLD);
CentrePrint(46,64,16,&buf[0]);
SetStyle(G_STY_NORMAL);
}
LOCAL_C VOID DrawBar(VOID)
{
P_RECT box;
GetBarChartRect(&box);
if (!counter)
gClrRect(&box,G_TRMODE_CLR);
else
{
box.br.x=BAR_LEFT+counter*STEP_WIDTH;
gFillPattern(&box,WS_BITMAP_GREY,G_TRMODE_REPL);
}
TellCounter();
}
LOCAL_C VOID TellTimint(VOID)
{
TEXT buf[30];
p_atos(&buf[0],"Ticking every %d secs/10",(INT)timint);
CentrePrint(4,12,7,&buf[0]);
}
typedef struct
{
TEXT *msg;
WORD x;
WORD y;
} CHOICE;
LOCAL_D CHOICE ch[4]=
{
"(F) Faster",12,20,
"(S) Slower",12,30,
"(Z) Zero",88,20,
"(X) Exit",88,30
};
LOCAL_C VOID DisplayChoice(INT i)
{
P_RECT box;
TEXT *pb;
box.tl.x=ch[i].x;
box.tl.y=ch[i].y;
box.br.x=box.tl.x+65;
box.br.y=box.tl.y+8;
pb=ch[i].msg;
gPrintBoxText(&box,7,G_TEXT_ALIGN_LEFT,0,pb,p_slen(pb));
}
LOCAL_C VOID DisplayChoices(VOID)
{
INT i;
for (i=0; i<4; i++)
DisplayChoice(i);
}
#define S3_FONT WS_FONT_BASE+4
LOCAL_C VOID Flash(INT i)
{
P_EXTENT ext;
ext.tl.x=ch[i].x-1;
ext.tl.y=ch[i].y-1;
ext.width=gTextWidth(S3_FONT,G_STY_NORMAL,ch[i].msg,3)+1;
ext.height=9;
gInvObloid(&ext);
wFlush();
p_sleep(2);
gInvObloid(&ext);
}
GLDEF_C VOID main(VOID)
{
WS_EV event;
P_RECT box;
WORD wactive;
wStartup();
gBorder(W_BORD_CORNER_4);
GetBarChartRect(&box);
p_insrec(&box,-1,-1);
gBorderRect(&box,W_BORD_CORNER_1);
SetFont(S3_FONT);
DisplayChoices();
p_open(&timH,"TIM:",-1);
timint=10;
TellTimint();
QueueTimer();
wactive=FALSE;
FOREVER
{
if (wactive)
wFlush();
else
{
wGetEvent(&event);
wactive=TRUE;
}
p_iowait();
if (event.type==E_FILE_PENDING)
{
if (counter++==NUM_STEPS)
counter=0;
DrawBar();
QueueTimer();
continue;
}
wactive=FALSE;
if (event.type==WM_KEY)
{
switch (event.p.key.keycode)
{
case 'x':
Flash(3);
p_exit(0);
case 'z':
Flash(2);
CancelTimer();
counter=0;
DrawBar();
QueueTimer();
break;
case 'f':
Flash(0);
if (timint!=1)
{
timint--;
TellTimint();
}
break;
case 's':
Flash(1);
timint++;
TellTimint();
}
}
}
}
+70
View File
@@ -0,0 +1,70 @@
/*
HCSHELL.C - Sample shell for the HC
*/
#include <plib.h>
#include <wlib.h>
GLREF_D UINT wMainGc;
GLREF_D WSERV_SPEC wSpec;
LOCAL_D INT FontHeight;
LOCAL_D INT FontAscent;
LOCAL_C VOID SetFontHeight(VOID)
{
G_FONT_INFO info;
gFontInfo(WS_FONT_SYSTEM,0,&info);
FontHeight=info.height;
FontAscent=info.ascent;
}
LOCAL_C VOID CDECL PrintLine(INT line,INT align,TEXT *fmt,...)
{
INT len;
P_RECT box;
TEXT b[80];
box.tl.x=4;
box.br.x=wSpec.conn.info.pixels.x-4;
box.tl.y=FontHeight*line+4;
box.br.y=box.tl.y+FontHeight;
len=p_atob(&b[0],fmt,&fmt+1);
gPrintBoxText(&box,FontAscent,align,0,&b[0],len);
}
LOCAL_C VOID HandleKeyPress(WMSG_KEY *pk)
{
PrintLine(2,G_TEXT_ALIGN_CENTRE,"code:%02x mod:%02x count:%02x",
pk->keycode,pk->modifiers,pk->count);
}
LOCAL_C VOID MainEventLoop(VOID)
{
WS_EV event;
SetFontHeight();
gBorder(W_BORD_SHADOW_D|W_BORD_SHADOW_ON);
PrintLine(0,G_TEXT_ALIGN_LEFT,"Free memory: %dKbytes",p_sgfree()>>6);
for (;;)
{
wGetEventWait(&event);
if (event.type==WM_KEY)
HandleKeyPress(&event.p.key);
}
}
GLDEF_C INT main(VOID)
{
INT NotifierPid;
wStartup();
wSystem(WSERV_FLAG_NO_NOTIFIER_REBOOT,0xffff);
if ((NotifierPid=p_pidfind("SYS$NTFY.*"))>0)
p_pterminate(NotifierPid,0);
wSystem(WSERV_FLAG_HOOK_NOTIFIER|WSERV_FLAG_LOW_BATTERY_WARNINGS|WSERV_FLAG_HUNG_UP_SW,
WSERV_FLAG_HOOK_NOTIFIER|WSERV_FLAG_LOW_BATTERY_WARNINGS|WSERV_FLAG_HUNG_UP_SW);
MainEventLoop();
return(0);
}
+15
View File
@@ -0,0 +1,15 @@
/*
HELLO.C
CLIB Hello World application
*/
#include <stdio.h>
int main(VOID)
{
printf("Hello World");
getchar();
return(0);
}
+7
View File
@@ -0,0 +1,7 @@
#system epoc img
#model small jpi
#compile hello
#link hello
+396
View File
@@ -0,0 +1,396 @@
#include <p_std.h>
#include <wlib.h>
#include "lined.h"
GLREF_D UINT wMainWid;
LOCAL_C INT CreateGC(LINED *ed)
{
G_GC gc;
if (ed->gc)
return(FALSE);
gc.font=ed->i.font;
gc.style=ed->i.style;
gCreateTempGC(ed->i.winid,G_GC_MASK_FONT|G_GC_MASK_STYLE,&gc);
ed->gc=TRUE;
return(TRUE);
}
LOCAL_C VOID FreeGC(LINED *ed,INT gc)
{
if (!gc)
return;
ed->gc=FALSE;
gFreeTempGC();
}
LOCAL_C INT WidthTo(LINED *ed,INT blen)
{
return(gTextWidth(ed->i.font,ed->i.style,ed->pb,blen));
}
LOCAL_C VOID GetBox(LINED *ed,P_RECT *pbox)
{
pbox->tl.x=ed->i.xoff;
pbox->tl.y=ed->i.yoff;
pbox->br.x=pbox->tl.x+ed->i.width;
pbox->br.y=pbox->tl.y+ed->i.height;
}
LOCAL_C VOID DrawCursor(LINED *ed)
{
W_CURSOR flash;
flash.pos.x=ed->i.xoff+ed->marg+WidthTo(ed,ed->cur);
flash.pos.y=ed->i.yoff+ed->i.asc;
flash.height=ed->i.height;
flash.ascent=ed->i.asc;
flash.width=ed->cwidth;
flash.flags=0;
wTextCursor(ed->i.winid,&flash);
}
LOCAL_C VOID ToggleHighlight(LINED *ed)
{
P_RECT box;
INT gc;
if (ed->select)
{
gc=CreateGC(ed);
GetBox(ed,&box);
box.br.x=box.tl.x+ed->marg+WidthTo(ed,ed->blen);
gClrRect(&box,G_TRMODE_INV);
FreeGC(ed,gc);
}
}
LOCAL_C VOID DrawAll(LINED *ed)
{
P_RECT box;
INT gc;
GetBox(ed,&box);
gc=CreateGC(ed);
gPrintBoxText(&box,ed->i.asc,G_TEXT_ALIGN_LEFT,ed->marg,ed->pb,ed->blen);
if (ed->emph)
{
DrawCursor(ed);
ToggleHighlight(ed);
}
FreeGC(ed,gc);
}
GLDEF_C VOID le_destroy(LINED *ed)
{
p_free(ed->pb);
p_free(ed);
}
GLDEF_C LINED *le_init(IN_LINED *pin)
{
LINED *ed;
ed=p_alloc(sizeof(LINED));
if (!ed)
return(NULL);
p_bfil(ed,sizeof(LINED),0);
ed->cwidth=2;
ed->pb=p_alloc(pin->maxchars+1);
if (!ed->pb)
{
p_free(ed);
return(NULL);
}
ed->i=(*pin);
ed->lmarg=ed->i.width/4;
return(ed);
}
LOCAL_C VOID ScrollForCursor(LINED *ed,INT draw)
{
INT oldmarg;
INT curx;
INT exx;
INT exl;
INT exr;
oldmarg=ed->marg;
curx=WidthTo(ed,ed->cur);
exx=curx+ed->marg;
exl=exx-ed->lmarg;
exr=exx+ed->cwidth-ed->i.width;
if (exl<0 && ed->marg)
{
ed->marg-=exl-ed->scrollx;
if (ed->marg>0)
ed->marg=0;
}
else if (exr>0)
ed->marg-=exr+ed->scrollx;
if (ed->marg!=oldmarg && draw)
DrawAll(ed);
}
GLDEF_C VOID le_set_text(LINED *ed,INT blen,TEXT *pb)
{
*(p_bcpy(ed->pb,pb,blen))=0;
ed->blen=blen;
ed->marg=0;
ed->select=FALSE;
ed->cur=0;
if (ed->i.autoselect && blen)
{
ed->cur=blen;
ed->select=TRUE;
ScrollForCursor(ed,FALSE);
}
if (ed->visible)
DrawAll(ed);
}
LOCAL_C VOID DelSelRange(LINED *ed)
{
ed->select=FALSE;
ed->cur=0;
ed->marg=0;
ed->blen=0;
*ed->pb=0;
}
LOCAL_C VOID DoDelete(LINED *ed,INT modifier)
{
INT start;
INT finish;
if (ed->select)
DelSelRange(ed);
else
{
if (modifier&W_SHIFT_MODIFIER)
{
if (ed->cur==ed->blen)
return;
}
else if (!ed->cur)
return;
start=finish=ed->cur;
switch (modifier)
{
case W_SHIFT_MODIFIER:
finish++;
break;
case W_PSION_MODIFIER:
finish=ed->blen;
break;
default:
start--;
}
p_bcpy(ed->pb+start,ed->pb+finish,ed->blen+1-finish);
ed->blen-=finish-start;
ed->cur=start;
ScrollForCursor(ed,FALSE);
}
DrawAll(ed);
}
LOCAL_C VOID LoseHighlight(LINED *ed)
{
ToggleHighlight(ed);
ed->select=FALSE;
}
LOCAL_C VOID DisplayCursor(LINED *ed)
{
ScrollForCursor(ed,TRUE);
DrawCursor(ed);
}
GLDEF_C INT le_key(LINED *ed,INT keycode,INT modifier)
{
TEXT *pb;
if (keycode<0x100 && p_isprint(keycode))
{
if (ed->select)
DelSelRange(ed);
if (ed->blen==ed->i.maxchars)
{
p_sound(-5,320);
return(-1);
}
pb=ed->pb+ed->cur;
p_bcpy(pb+1,pb,ed->blen+1-ed->cur);
*pb=keycode;
(ed->blen)++;
(ed->cur)++;
ScrollForCursor(ed,FALSE);
DrawAll(ed);
return(0);
}
if (keycode==W_KEY_DELETE_LEFT || keycode==W_KEY_DELETE_RIGHT)
DoDelete(ed,modifier);
else
{
switch (keycode)
{
case W_KEY_LEFT:
if (ed->select)
{
LoseHighlight(ed);
ed->cur=0;
}
else if (!ed->cur)
return(0);
else
{
if (modifier&W_PSION_MODIFIER)
ed->cur=0;
else
(ed->cur)--;
}
DisplayCursor(ed);
break;
case W_KEY_RIGHT:
if (ed->select)
{
LoseHighlight(ed);
ed->cur=ed->blen;
}
else if (ed->cur==ed->blen)
return(0);
else
{
if (modifier&W_PSION_MODIFIER)
ed->cur=ed->blen;
else
(ed->cur)++;
}
DisplayCursor(ed);
}
}
return(0);
}
GLDEF_C VOID le_emphasise(LINED *ed,INT emph)
{
if (emph)
emph=TRUE;
if (ed->emph==emph)
return;
ed->emph=emph;
if (!ed->visible)
return;
DrawAll(ed);
if (!emph)
wEraseTextCursor();
}
GLDEF_C VOID le_set_cwidth(LINED *ed,INT cwidth)
{
ed->cwidth=cwidth;
if (ed->visible && ed->emph)
{
if (cwidth)
DrawCursor(ed);
else
wEraseTextCursor();
}
}
GLDEF_C VOID le_visible(LINED *ed,INT visible)
{
P_RECT box;
INT gc;
if (visible)
visible=TRUE;
if (ed->visible==visible)
return;
ed->visible=visible;
if (visible)
DrawAll(ed);
else
{
GetBox(ed,&box);
gc=CreateGC(ed);
gClrRect(&box,G_TRMODE_CLR);
FreeGC(ed,gc);
}
}
/************************** TEST CODE FOLLOWS ***********************/
LOCAL_C LINED *CreateLined(INT yoff,TEXT *msg,INT emph)
{
IN_LINED init;
LINED *ed;
init.maxchars=20;
init.winid=wMainWid;
init.xoff=10;
init.yoff=yoff;
init.width=80;
init.height=10;
init.asc=8;
init.font=WS_FONT_BASE+4;
init.style=0;
init.autoselect=TRUE;
ed=le_init(&init);
le_set_text(ed,p_slen(msg),msg);
le_emphasise(ed,emph);
le_visible(ed,TRUE);
return(ed);
}
GLDEF_C VOID main(VOID)
{
LINED *ed[3];
INT which;
WS_EV event;
INT keycode;
wStartup();
gBorder(W_BORD_CORNER_4);
ed[0]=CreateLined(10,"One",TRUE);
ed[1]=CreateLined(30,"Two",FALSE);
ed[2]=CreateLined(50,"Three",FALSE);
which=0;
FOREVER
{
do
{
wGetEventWait(&event);
} while (event.type!=WM_KEY);
keycode=event.p.key.keycode&(~W_SPECIAL_KEY);
switch (keycode)
{
case W_KEY_ESCAPE:
if (event.p.key.modifiers==W_PSION_MODIFIER)
p_exit(0);
case W_KEY_UP:
if (which)
{
le_emphasise(ed[which--],FALSE);
le_emphasise(ed[which],TRUE);
}
break;
case W_KEY_DOWN:
if (which<2)
{
le_emphasise(ed[which++],FALSE);
le_emphasise(ed[which],TRUE);
}
break;
default:
le_key(ed[which],keycode,event.p.key.modifiers);
}
}
}
+43
View File
@@ -0,0 +1,43 @@
#define LINED_H
#ifndef P_STD_H
#include <p_std.h>
#endif
typedef struct
{
WORD maxchars;
WORD winid;
WORD xoff;
WORD yoff;
WORD width;
WORD height;
WORD asc;
WORD font;
WORD style;
WORD autoselect;
} IN_LINED;
typedef struct
{
WORD blen;
TEXT *pb;
WORD select;
WORD emph;
WORD cur;
WORD marg;
WORD cwidth;
WORD visible;
WORD gc;
WORD scrollx;
WORD lmarg;
IN_LINED i;
} LINED;
GLREF_C LINED *le_init(IN_LINED *pin);
GLREF_C VOID le_set_text(LINED *ed,INT blen,TEXT *pb);
GLREF_C VOID le_emphasise(LINED *ed,INT emph);
GLREF_C VOID le_set_cwidth(LINED *ed,INT cwidth);
GLREF_C VOID le_visible(LINED *ed,INT visible);
GLREF_C INT le_key(LINED *ed,INT keycode,INT modifier);
GLREF_C VOID le_destroy(LINED *ed);
+79
View File
@@ -0,0 +1,79 @@
/*
LKSHELL.C - Just starts up the link
*/
#include <plib.h>
#include <wlib.h>
LOCAL_D WSERV_SPEC wSpec;
LOCAL_D UINT wMainGc;
LOCAL_D UINT wMainWid;
LOCAL_D INT FontHeight;
LOCAL_D INT FontAscent;
LOCAL_C VOID SetFontHeight(VOID)
{
G_FONT_INFO info;
gFontInfo(WS_FONT_SYSTEM,0,&info);
FontHeight=info.height;
FontAscent=info.ascent;
}
LOCAL_C VOID CDECL PrintLine(INT line,INT align,TEXT *fmt,...)
{
INT len;
P_RECT box;
TEXT b[80];
box.tl.x=4;
box.br.x=wSpec.conn.info.pixels.x-4;
box.tl.y=FontHeight*line+4;
box.br.y=box.tl.y+FontHeight;
len=p_atob(&b[0],fmt,&fmt+1);
gPrintBoxText(&box,FontAscent,align,0,&b[0],len);
}
LOCAL_C VOID MainEventLoop(VOID)
{
WS_EV event;
SetFontHeight();
for (;;)
{
wGetEventWait(&event);
if (event.type==WM_REDRAW)
{
wValidateWin(wMainWid);
gBorder(W_BORD_SHADOW_D|W_BORD_SHADOW_ON);
PrintLine(0,G_TEXT_ALIGN_LEFT,"Free memory: %dKbytes",p_sgfree()>>6);
}
else if (event.type==WM_KEY && event.p.key.keycode=='\r')
wInvalidateWin(wMainWid);
}
}
GLDEF_C VOID main(VOID)
{
INT NotifierPid;
WORD stat;
p_setonevent(TRUE);
wConnect(&wSpec,0,W_CONNECT_PRIORITY);
wSystem(WSERV_FLAG_NO_NOTIFIER_REBOOT,WSERV_FLAG_NO_NOTIFIER_REBOOT);
if ((NotifierPid=p_pidfind("SYS$NTFY.*"))>0)
{
p_logona(NotifierPid,&stat);
p_pterminate(NotifierPid,0);
p_waitstat(&stat);
}
wSystem(WSERV_FLAG_HOOK_NOTIFIER|WSERV_FLAG_LOW_BATTERY_WARNINGS|WSERV_FLAG_HUNG_UP_SW,
WSERV_FLAG_HOOK_NOTIFIER|WSERV_FLAG_LOW_BATTERY_WARNINGS|WSERV_FLAG_HUNG_UP_SW);
if (p_pidfind("SYS$NCP.*")<0)
p_presume(p_execc("ROM::LINK",NULL,0));
wMainWid=wCreateWindow(0,0,0,1);
wsCreateClock(wMainWid,WS_CLOCK_WITH_DATE|WS_CLOCK_WITH_SECONDS,104,66,0);
wInitialiseWindowTree(wMainWid);
wMainGc=gCreateGC0(wMainWid);
MainEventLoop();
}
+5
View File
@@ -0,0 +1,5 @@
#system epoc img
#set epocinit=iplib2
#model small jpi
#compile lkshell
#link lkshell
+8
View File
@@ -0,0 +1,8 @@
@echo off
call checkvid
if exist %1.pr goto custom
tsc /m unnamed.pr /smain=%1 /%jpivid%
goto end
:custom
tsc /m %1.pr /smain=%1 /%jpivid%
:end
+96
View File
@@ -0,0 +1,96 @@
/*
P_COMP.C
*/
#include <plib.h>
typedef struct
{
INT ret;
VOID *chan;
LONG len;
TEXT name[P_FNAMESIZE];
UBYTE buf[P_FBLKSIZE];
} FILE_DATA;
LOCAL_D FILE_DATA f1={0,NULL};
LOCAL_D FILE_DATA f2={0,NULL};
LOCAL_C VOID CleanUp(TEXT *msg, FILE_DATA *pf)
{
TEXT bb[E_MAX_ERROR_TEXT_SIZE];
p_close(pf->chan);
pf->chan=NULL;
if (pf->ret<0)
{
p_errs(&bb[0],pf->ret);
p_printf("Failed to %s %s\n\r%s)",msg,&pf->name[0],&bb[0]);
pf->ret=0;
}
}
LOCAL_C VOID Exit(TEXT *msg)
{
if (f1.ret>=0 && f2.ret>=0)
p_printf(msg);
CleanUp(msg,&f1);
CleanUp(msg,&f2);
p_leave(0);
}
LOCAL_C VOID OpenFile(FILE_DATA *pf, TEXT *name, TEXT *related)
{
LONG pos;
if ((pf->ret=p_fparse(name,related,&pf->name[0],NULL))<0)
Exit("parse");
if ((pf->ret=p_open(&pf->chan,&pf->name[0],P_FSTREAM|P_FSHARE|P_FRANDOM))<0)
Exit("open");
pf->len=0L; p_seek(pf->chan,P_FEND,&pf->len);
pos=0; p_seek(pf->chan,P_FABS,&pos);
}
LOCAL_C VOID ReadFile(FILE_DATA *pf)
{
pf->ret=p_read(pf->chan,&pf->buf[0],sizeof(pf->buf));
if (pf->ret!=E_FILE_EOF && pf->ret<0)
Exit("read");
}
LOCAL_C VOID CDECL CompareFiles(TEXT *file1, TEXT *file2)
{
OpenFile(&f1,file1,NULL);
OpenFile(&f2,file2,&f1.name[0]);
p_printf("Compare %s (%ld)",&f1.name[0],f1.len);
p_printf(" with %s (%ld)",&f2.name[0],f2.len);
if (f1.len!=f2.len)
Exit("Files are of different length");
FOREVER
{
ReadFile(&f1);
ReadFile(&f2);
if (f1.ret==E_FILE_EOF && f2.ret==E_FILE_EOF)
{
f1.ret=f2.ret=0;
Exit("Files are identical");
}
if (p_bcmp(&f1.buf[0],f1.ret,&f2.buf[0],f2.ret))
Exit("Files are different");
}
}
GLDEF_C INT main(VOID)
{
TEXT *p;
TEXT bb[P_FNAMESIZE];
while (p_getl("Enter <file1> <file2>?\r\n",&bb[0],P_FNAMESIZE))
{
p=p_skipch(&bb[0]);
if (*p)
*p++=0;
p_enter((VOID *)CompareFiles,&bb[0],p_skipwh(p));
}
return(0);
}
+65
View File
@@ -0,0 +1,65 @@
/*
P_DLIST.C
*/
#include <plib.h>
LOCAL_C TEXT *GetTypeText(UINT type)
{
switch (type)
{
case P_FMEDIA_FLOPPY:
return "Floppy";
case P_FMEDIA_HARDDISK:
return "Hard";
case P_FMEDIA_FLASH:
return "Flash";
case P_FMEDIA_RAM:
return "RAM";
case P_FMEDIA_ROM:
return "ROM";
case P_FMEDIA_WRITEPROTECTED:
return "Protected";
}
return "Unknown";
}
LOCAL_C VOID ListDevices(VOID)
{
VOID *ncb,*dcb;
INT ret;
TEXT device[P_FNAMESIZE];
TEXT bb[E_MAX_ERROR_TEXT_SIZE];
P_DINFO dinfo;
p_printf(" Device Name Type Size Free");
p_printf("=========== ========== ========== ======== ========");
p_open(&ncb,"FIL:",P_FNODE);
while (!p_iow(ncb,P_FREAD,&device[0],NULL))
{
p_scat(&device[0],"a:\\");
if (p_open(&dcb,&device[0],P_FDEVICE))
continue;
while (!p_read(dcb,&device[P_FSYSNAMESIZE],0))
{
if ((ret=p_dinfo(&device[0],&dinfo))<0)
{
p_errs(&bb[0],ret);
p_printf("%- 12s %- 12s<%s>",&device[0],"**Failed**",&bb[0]);
continue;
}
p_printf("%- 12s %- 12s%- 11s %7ldK %7ldK",
&device[0],&dinfo.name[0],GetTypeText(dinfo.mediatype&0xff),
(dinfo.size+512)>>10,(dinfo.free+512)>>10);
}
p_close(dcb);
}
p_close(ncb);
}
GLDEF_C INT main(VOID)
{
ListDevices();
p_getch();
return(0);
}
+15
View File
@@ -0,0 +1,15 @@
/*
P_HELLO.C
PLIB Hello World application
*/
#include <plib.h>
GLDEF_C INT main(VOID)
{
p_printf("Hello World");
p_getch();
return(0);
}
+7
View File
@@ -0,0 +1,7 @@
#system epoc img
#set epocinit=iplib
#model small jpi
#compile p_hello
#link p_hello
+75
View File
@@ -0,0 +1,75 @@
/*
P_PRNDIR.C
*/
#include <plib.h>
LOCAL_D VOID *dcb=NULL;
LOCAL_C VOID panic(TEXT *msg, INT errno)
{
TEXT bb[E_MAX_ERROR_TEXT_SIZE];
p_close(dcb); dcb=NULL;
p_errs(&bb[0],errno);
p_printf("%s: %s",msg,&bb[0]);
p_leave(errno);
}
LOCAL_C VOID PrintDirLine(TEXT *name, P_INFO *pinfo)
{
P_DAYSEC ds;
P_DATE dt;
TEXT *p,b[40];
p=&b[0];
if (pinfo->status&P_FAVOLUME)
p=p_scpy(p,"Vol,");
if (pinfo->status&P_FADIR)
p=p_scpy(p,"Dir,");
if (pinfo->status&P_FAMOD)
p=p_scpy(p,"Mod,");
if (!(pinfo->status&P_FAWRITE))
p=p_scpy(p,"Read,");
if (pinfo->status&P_FASYSTEM)
p=p_scpy(p,"Sys,");
if (pinfo->status&P_FAHIDDEN)
p=p_scpy(p,"Hid,");
if (*(p-1)==',')
*--p=0;
p_sttods(&pinfo->modst,&ds);
p_dstodt(&ds,&dt);
p_printf("%- 12s %8lu %02u-%02u-%02u %02u:%02u %s",
name,pinfo->size,dt.day+1,dt.month+1,dt.year,dt.hour,dt.minute,&b[0]);
}
LOCAL_C INT CDECL PrintDirList(TEXT *dir)
{
INT ret,NoFiles;
P_INFO info;
TEXT name[P_FNAMESIZE];
if ((ret=p_open(&dcb,dir,P_FDIR))!=0)
panic("Failed to open directory file",ret);
NoFiles=TRUE;
while (!(ret=p_iow(dcb,P_FREAD,&name[0],&info)))
{
NoFiles=FALSE;
PrintDirLine(&name[0],&info);
}
p_close(dcb); dcb=NULL;
if (ret!=E_FILE_EOF)
panic("Failed to read directory",ret);
if (NoFiles)
p_printf("No files found");
return(0);
}
GLDEF_C INT main(VOID)
{
TEXT name[P_FNAMESIZE];
while (p_getl(">",&name[0],P_FNAMESIZE))
p_enter((VOID *)PrintDirList,&name[0]);
return(0);
}
+56
View File
@@ -0,0 +1,56 @@
/*
P_SEARCH.C
*/
#include <plib.h>
LOCAL_D VOID *fcb=NULL;
LOCAL_C VOID panic(TEXT *msg, INT errno)
{
TEXT bb[E_MAX_ERROR_TEXT_SIZE];
p_errs(&bb[0],errno);
p_printf("%s: %s",msg,&bb[0]);
p_leave(errno);
}
#pragma save
#pragma ENTER_CALL
LOCAL_C INT CDECL SearchFile(TEXT *file, TEXT *pattern)
{
INT ret;
TEXT line[P_FMAXRSIZE];
if ((ret=p_open(&fcb,file,P_FTEXT))<0)
panic("Failed to open file",ret);
while ((ret=p_read(fcb,&line[0],sizeof(line)))>=0)
{
line[ret]=0;
if (ret && p_ssubi(&line[0],pattern)>=0)
p_printf(&line[0]);
}
p_close(fcb);
if (ret!=E_FILE_EOF)
panic("Failed to read file",ret);
return(0);
}
#pragma restore
GLDEF_C INT main(VOID)
{
TEXT *p;
TEXT bb[P_FNAMESIZE];
while (p_getl(">",&bb[0],P_FNAMESIZE))
{
p=p_skipch(&bb[0]);
*p++=0;
p=p_skipwh(p);
p_printf("Searching %s for %s",&bb[0],p);
p_enter3(SearchFile,&bb[0],p);
}
return(0);
}
+139
View File
@@ -0,0 +1,139 @@
/*
Save the screen to PCX file
*/
#include <plib.h>
#include <wlib.h>
#define BUFLEN 256
GLREF_D WSERV_SPEC *wserv_channel;
LOCAL_D VOID *fcb;
LOCAL_D UBYTE *pbuf;
LOCAL_D UBYTE *pobuf;
LOCAL_D UBYTE obuf[BUFLEN];
LOCAL_C VOID FlushBuffer(VOID)
{
f_write(fcb,&obuf[0],pobuf-&obuf[0]);
pobuf=&obuf[0];
}
LOCAL_C VOID putb(INT b)
{
*pobuf++=b;
if (pobuf==&obuf[BUFLEN])
FlushBuffer();
}
LOCAL_C INT rev(INT dat)
{
INT i;
INT rdat;
rdat=0;
for (i=0;i<8;i++)
rdat|=((dat>>i)&1)<<(7-i);
return(rdat^0xff);
}
LOCAL_C VOID WritePCXLine(UBYTE *buf,UINT len)
{
UBYTE *p;
UINT end;
UINT count;
INT byte;
p=buf;
byte=*p++;
count=1;
do
{
end=(p==(&buf[0]+len));
if (byte==*p && count<0x3f && !end)
{
count++;
p++;
}
else
{
byte=rev(byte);
if (count>1 || (byte&0xC0)==0xC0)
putb(count+0xC0);
putb(byte);
byte=*p++;
count=1;
}
} while (!end);
}
LOCAL_C VOID WriteHeader(TEXT *name,UINT width,UINT height,UINT bytewid)
{
struct
{
UBYTE manuf;
UBYTE hard;
UBYTE encod;
UBYTE bitpx;
P_RECT rect;
WORD hres;
WORD vres;
UBYTE clrma[48];
UBYTE vmode;
UBYTE nplanes;
WORD bplin;
UBYTE padding[60];
} header;
f_open(&fcb,name,P_FREPLACE|P_FSTREAM|P_FUPDATE);
p_bfil(&header,sizeof(header),0);
header.manuf=10;
header.hard=3;
header.encod=TRUE;
header.bitpx=1;
header.rect.br.x=width-1;
header.rect.br.y=height-1;
header.hres=640;
header.vres=480;
header.nplanes=1;
header.bplin=bytewid;
f_write(fcb,&header,sizeof(header));
}
#pragma save, ENTER_CALL
LOCAL_C INT WritePCXFile(TEXT *name)
{
UINT len;
P_POINT size;
P_POINT line;
size=wserv_channel->conn.info.pixels;
len=((size.x+15)>>3)&~1;
WriteHeader(name,size.x,size.y,len);
pbuf=f_alloc(len);
line.x=0;
for (line.y=0;line.y<size.y;line.y++)
{
gPeekBit(0,&line,size.x,pbuf);
WritePCXLine(pbuf,len);
}
FlushBuffer();
return(0);
}
#pragma restore
GLDEF_C INT pcxScreenSave(TEXT *name)
{
INT ret;
fcb=NULL;
pbuf=NULL;
pobuf=&obuf[0];
ret=p_enter2((VOID *)WritePCXFile,name);
p_free(pbuf);
p_close(fcb);
return(ret);
}
+29
View File
@@ -0,0 +1,29 @@
This directory contains demonstration files that are associated with
the following manuals:
General Programming Manual
HC Programming Guide
Series 3/3a Programming Guide
Additional System Information
PLIB Reference
Window Server Reference
This directory also contains the necessary files to build programs
from the source files.
For example, you can check your installation by making \sibosdk\demo
the current directory and entering:
MAKE HELLO
to produce a HELLO.IMG that can then be run on a Series3, HC or MC.
If you wish to debug at the source code level, enter:
VID ON
before making a program (as described in the General Programming Manual).
If you move the contents of this directory to other than a
subdirectory of \sibosdk\ then you will need a different TS.RED (such
as the one in \sibosdk\sys).
See DEMO.PRJ (a plain text file) for an annotated list of the files
in this directory.
+63
View File
@@ -0,0 +1,63 @@
#include <p_std.h>
#include <p_file.h>
#include <p_sys.h>
#include <epoc.h>
GLREF_D VOID *DatCommandPtr;
LOCAL_D VOID *fcb; /* handle of resource file */
LOCAL_D UWORD resoff; /* offset to resource file within .img file */
LOCAL_D UWORD ixpos; /* offset to index table within resource file */
LOCAL_D TEXT buf[80]; /* scratch buffer used for resources loaded */
LOCAL_C VOID SeekToPos(UWORD roff)
/*
Position to offset roff within the resource file
*/
{
LONG ioff; /* offset within image file */
ioff=resoff+roff;
p_seek(fcb,P_FABS,&ioff);
}
LOCAL_C VOID InitRsc(VOID)
/*
Open resource file at add-file slot 2 inside own .img file.
Set up the values of fcb, resoff, and ixpos
*/
{
ImgHeader head;
p_open(&fcb,DatCommandPtr,P_FRANDOM|P_FSTREAM|P_FSHARE);
p_read(fcb,&head,sizeof(head));
resoff=head.Add[1].offset;
SeekToPos(0);
p_read(fcb,&ixpos,2);
}
LOCAL_C TEXT *ReadRsc(INT i)
/*
Returns pointer to buffer containing resource i.
Note that the static buffer buf[] is used in every case.
*/
{
UWORD tmp[2]; /* section of index table */
SeekToPos(ixpos+((i-1)*2)); /* position into index table */
p_read(fcb,&tmp[0],4);
SeekToPos(tmp[0]);
p_read(fcb,&buf[0],tmp[1]-tmp[0]);
return(&buf[0]);
}
GLDEF_C INT main(VOID)
{
InitRsc();
p_printf("Resource 1 is %s",ReadRsc(1));
p_printf("Resource 2 is %s",ReadRsc(2));
p_printf("Press any key to exit");
p_getch();
return(0);
}
+31
View File
@@ -0,0 +1,31 @@
/*
SCAPT.C - Capture the screen to a file
*/
#include <plib.h>
#include <wlib.h>
GLREF_D TEXT *DatCommandPtr;
GLREF_C INT pcxScreenSave(TEXT *name);
LOCAL_D WSERV_SPEC wSpec;
GLDEF_C INT main(VOID)
{
INT ret;
TEXT *pc;
TEXT name[P_FNAMESIZE];
pc=p_skipch(DatCommandPtr)+1;
if (*pc)
pc=p_skipwh(pc+1);
ret=p_fparse(pc,"REM::SCREEN.PCX",&name[0],NULL);
if (!ret)
{
wConnect(&wSpec,0,W_CONNECT_AT_BACK);
ret=pcxScreenSave(&name[0]);
p_sound(1,512);
}
return(ret);
}
+7
View File
@@ -0,0 +1,7 @@
#system epoc img
#set epocinit=iplib2
#model small jpi
#compile scapt
#compile pcxsave
#link scapt
+94
View File
@@ -0,0 +1,94 @@
#include <p_std.h>
#include <p_file.h>
#include <epoc.h>
/* Sound demo: plays the ice cream van tune at various
beat per minute ... */
GLDEF_C VOID waitstat2(WORD *pstat1, WORD *pstat2)
/*
Wait for *pstat!=E_FILE_PENDING and *pstat2 != E_FILE_PENDING
*/
{
INT i;
i = -1;
do
{
p_iowait();
i++;
}
while (*pstat1 == E_FILE_PENDING && *pstat2 == E_FILE_PENDING);
if (*pstat2 == E_FILE_PENDING)
pstat1 = pstat2;
p_waitstat(pstat1);
while (i--)
p_iosignal();
}
GLDEF_C VOID play_notes(WORD *buf1, WORD *buf2, WORD l1, WORD l2, INT volume, INT beatsPerMinute)
{
VOID *pcb;
WORD sndstat1,sndstat2;
E_SOUND sound;
INT err;
if ((err=p_open(&pcb,"SND:",-1)) < 0)
{
p_close(pcb);
p_exit(err);
}
if ((err=p_iow3(pcb,P_FSENSE,&sound)) < 0)
{
p_close(pcb);
p_exit(err);
}
if (beatsPerMinute >= 0)
sound.beatsPerMinute = (UBYTE) beatsPerMinute;
if (volume >= 0)
sound.volume = (UBYTE) volume;
if ((err=p_iow3(pcb,P_FSET,&sound)) < 0)
{
p_close(pcb);
p_exit(err);
}
p_ioc5(pcb,E_FSSOUNDCHANNEL1,&sndstat1,&buf1[0],&l1);
p_ioc5(pcb,E_FSSOUNDCHANNEL2,&sndstat2,&buf2[0],&l2);
waitstat2(&sndstat1,&sndstat2);
p_close(pcb);
if (sndstat1 != 0 || sndstat1 != 0)
p_exit(0);
}
GLDEF_C INT main(VOID)
{
WORD notes1[] = {1048,24,524,12};
WORD notes2[] = {1048,4,1320,4,1568,4,2092,4,1568,4,1320,4,1048,12};
WORD len1 = sizeof(notes1)/4,len2 = sizeof(notes2)/4;
INT i;
for (i = 0; i < 6; i++)
{
play_notes(&notes1[0],&notes2[0],len1,len2,i,-1);
p_sleep(1);
}
for (i = 0; i < 6; i++)
{
play_notes(&notes1[0],&notes2[0],len1,len2,-1,140+i*20);
p_sleep(1);
}
return(0);
}
+31
View File
@@ -0,0 +1,31 @@
/* SUBPROC.C */
#include <p_std.h>
#include <p_gen.h>
#include <p_math.h>
#include <epoc.h>
#include "subproc.h"
GLREF_C TEXT *DatCommandPtr;
GLDEF_C INT main(VOID)
{
TEXT *pb;
SUBPROC_CL *pcl;
UWORD answer;
WORD logstat;
pb=DatCommandPtr+p_slen(DatCommandPtr)+1;
if (*pb!=sizeof(SUBPROC_CL))
return(E_GEN_ARG);
pcl=(SUBPROC_CL *)(pb+1);
if (!p_logona(pcl->pid,&logstat))
{
answer=(UWORD)(p_randl(&pcl->data)%(2*60*32));
p_sleept(answer);
if (logstat<0)
p_pcpyto(pcl->pid,pcl->poff,&answer,sizeof(UWORD));
}
return(0);
}
+6
View File
@@ -0,0 +1,6 @@
typedef struct
{
HANDLE pid;
VOID *poff;
ULONG data;
} SUBPROC_CL;
+5
View File
@@ -0,0 +1,5 @@
#system epoc img
#set epocinit=iplib
#model small jpi
#compile %main
#link %main
+22
View File
@@ -0,0 +1,22 @@
@echo off
goto X%1X
:Xv0X
:XoffX
set jpivid=v0
echo VID is now OFF
goto :end
:Xv2X
:XonX
set jpivid=v2
echo VID is now ON
goto :end
:XX
call checkvid
goto %jpivid%
:v0
echo VID is OFF
goto end
:v2
echo VID is ON
:end
+16
View File
@@ -0,0 +1,16 @@
#include <p_std.h>
#include <wlib.h>
GLDEF_C INT main(VOID)
{
WS_EV event;
wStartup();
gBorder(W_BORD_CORNER_4);
wSetBusyMsg("Hello world",W_CORNER_BOTTOM_LEFT);
do
{
wGetEventWait(&event);
} while (event.type!=WM_KEY || event.p.key.keycode!=W_KEY_ESCAPE);
return(0);
}
+70
View File
@@ -0,0 +1,70 @@
/* EHBWIN.C */
#include <ehello.g>
#include <ehello.rsg>
#include <hwim.h>
LOCAL_C VOID LaunchDialog(INT class,INT resid,VOID *rbuf)
{
DL_DATA dld;
dld.id=resid;
dld.rbuf=rbuf;
dld.pdlg=NULL;
hLaunchDial(CAT_EHELLO_EHELLO,class,&dld);
}
#pragma METHOD_CALL
METHOD VOID ehbwin_wn_init(PR_EHBWIN *self)
{
W_WINDATA wd;
IN_EDWIN_X initx;
struct
{
IN_EDWIN e;
TEXT rest[21];
} init;
wd.extent.width=240-50; /* extent calculation presupposes S3 screen */
wd.extent.height=3+10+5; /* matches flags set for bwin below */
wd.extent.tl.x=0;
wd.extent.tl.y=31; /* centred vertically */
p_send5(self,O_WN_CONNECT,NULL,W_WIN_EXTENT,&wd);
hLoadResBuf(EHSTR_INIT,&init.e.contents[0]);
init.e.vulen=240-50-3-1-5-1; /* one extra pixel clearance each end */
init.e.maxlen=50;
init.e.flags=IN_EDWIN_VULEN_PIXELS|IN_EDWIN_POSITION_SUPPLIED;
initx.pos.x=3+1;
initx.pos.y=3;
self->ehbwin.edwin=f_newsend(CAT_EHELLO_HWIM,C_EDWIN,O_WN_INIT,
&init,self,&initx);
self->win.flags=IN_BWIN_SHADOW_2|IN_BWIN_CUSHION;
p_send3(self,O_WN_EMPHASISE,TRUE);
hInitVis(self);
}
METHOD VOID ehbwin_wn_emphasise(PR_EHBWIN *self,INT flag)
{
p_supersend3(self,O_WN_EMPHASISE,flag);
p_send3(self->ehbwin.edwin,O_WN_EMPHASISE,flag);
}
METHOD VOID ehbwin_wn_draw(PR_EHBWIN *self)
{
p_supersend2(self,O_WN_DRAW);
p_send2(self->ehbwin.edwin,O_WN_DRAW);
}
METHOD VOID ehbwin_wn_key(PR_EHBWIN *self,INT keycode,INT mods)
{
SE_EDWIN sense;
if (keycode!=W_KEY_RETURN)
p_send4(self->ehbwin.edwin,O_WN_KEY,keycode,mods);
else
{
p_send3(self->ehbwin.edwin,O_WN_SENSE,&sense);
LaunchDialog(C_EHDLG,EHDLG,sense.buf);
}
}
+11
View File
@@ -0,0 +1,11 @@
/* EHDLG.C */
#include <ehello.g>
#include <hwim.h>
#pragma METHOD_CALL
METHOD VOID ehdlg_dl_dyn_init(PR_DLGBOX *self)
{
hDlgSetText(1,self->dlgbox.rbuf);
}
+2
View File
@@ -0,0 +1,2 @@
ehello.pic
ehello.rzc
+29
View File
@@ -0,0 +1,29 @@
IMAGE ehello
EXTERNAL olib
EXTERNAL hwim
INCLUDE hwimman.g
INCLUDE edwin.g
CLASS ehwserv wserv
{
REPLACE ws_dyn_init
}
CLASS ehbwin bwin
{
REPLACE wn_init
REPLACE wn_emphasise
REPLACE wn_key
REPLACE wn_draw
PROPERTY
{
PR_EDWIN *edwin;
}
}
CLASS ehdlg dlgbox
{
REPLACE dl_dyn_init
}
Binary file not shown.
+31
View File
@@ -0,0 +1,31 @@
#system epoc img
#set epocinit=iplib
#model small jpi
#compile ehello.cat
#if %remake #or (ehello.rg #older ehello.re) #or (ehello.rg #older ehello.g) #then
#run "re ehello" no_window no_abort
#endif
#if (ehello.rsg #older ehello.rss) #or (ehello.rsg #older ehello.rg) #then
#run "rs ehello" no_window no_abort
#endif
#if ehello.rzc #older ehello.rsg #then
#run "rch ehello" no_window no_abort
#file delete ehello.img
#endif
#compile ehmain.c
#compile ehwserv.c
#compile ehbwin.c
#compile ehdlg.c
#if (ehello.img #older ehello.afl) #or (ehello.img #older ehello.pic) #then
#file delete ehello.img
#endif
#pragma link(hwim.lib)
#link ehello.img
+3
View File
@@ -0,0 +1,3 @@
#include <comman.g>
_O_COM_EXIT
+54
View File
@@ -0,0 +1,54 @@
/* EHELLO.RSS */
#include <hwim.rh>
#include <hwim.rg>
#include <ehello.rg>
RESOURCE WSERV_INFO ehello_accs
{
menbar_id=ehello_mbar;
first_com=O_COM_EXIT;
accel={'x'};
}
RESOURCE MENU_BAR ehello_mbar
{
items =
{
MENU_BAR_ITEM
{
menu_id=special_menu;
mb_item="Special";
}
};
}
RESOURCE MENU special_menu
{
items =
{
MENU_ITEM
{
com_id=O_COM_EXIT;
mn_item="Exit";
}
};
}
RESOURCE DIALOG ehdlg
{
title="Edit window";
flags=DLGBOX_RBUF_FILLED;
controls=
{
CONTROL
{
class=C_TEXTWIN;
flags=DLGBOX_ITEM_DEAD;
prompt="Current text";
info=TXTMESS { str="*";}; /* placeholder */
}
};
}
RESOURCE STRING ehstr_init { str="Hello world"; }
+17
View File
@@ -0,0 +1,17 @@
/* EHMAIN.C */
#include <ehello.g>
GLDEF_C VOID main(VOID)
{
IN_HWIMMAN app;
IN_WSERV wserv;
p_linklib(0);
app.flags=FLG_APPMAN_RSCFILE|FLG_APPMAN_SRSCFILE|FLG_APPMAN_CLEAN;
app.wserv_cat=p_getlibh(CAT_EHELLO_EHELLO);
app.wserv_class=C_EHWSERV;
wserv.com_cat=p_getlibh(CAT_EHELLO_HWIM);
wserv.com_class=C_COMMAN;
p_send4(p_new(CAT_EHELLO_HWIM,C_HWIMMAN),O_AM_INIT,&app,&wserv);
}
+15
View File
@@ -0,0 +1,15 @@
ehrel.prj ! releases source files
ehello.pr ! TS project file
make.bat ! makes EHELLO.IMG
!
ehello.cat ! category file
ehello.re ! resource externals file
ehello.rss ! resource script
!
ehbwin.c ! client window
ehdlg.c ! dialog
ehmain.c ! main
ehwserv.c ! window server subclass
!
ehello.afl ! add file list
ehello.pic ! icon
+11
View File
@@ -0,0 +1,11 @@
/* EHWSERV.C */
#include <ehello.g>
#pragma METHOD_CALL
METHOD VOID ehwserv_ws_dyn_init(PR_EHWSERV *self)
{
wsEnable();
self->wserv.cli=f_newsend(CAT_EHELLO_EHELLO,C_EHBWIN,O_WN_INIT);
}
+3
View File
@@ -0,0 +1,3 @@
@echo off
tscx /m ehello
tscx /m ehello
Binary file not shown.
+94
View File
@@ -0,0 +1,94 @@
/*
TXTREAD.C
*/
#include <p_std.h>
#include <p_file.h>
#include <wl$txt.g>
#include "wpfconv.h"
GLREF_D VOID *DatApp5; /* used for file conversion DYLs... */
#define FileName DatApp5 /* ...to point to the source file's name */
LOCAL_C VOID InsertBuf(PR_TXTREAD *self, TEXT *buf, UINT len)
{
InsertText(self->txtread.pos,buf,len);
self->txtread.pos+=len;
}
LOCAL_C VOID ApplyPlainStyle(PR_TXTREAD *self)
{
PARA_STYLE *para;
EMPH_STYLE *emph;
TEXT paracode[2];
TEXT emphcode[2];
*(WORD *)&paracode[0]='B'+('T'<<8);
para=SenseParaStyleBySC(&paracode[0]);
DoApplyParaStyle(self->txtread.lastpos,self->txtread.pos,para);
*(WORD *)&emphcode[0]='N'+('N'<<8);
emph=(EMPH_STYLE *)SenseEmphStyleBySC(&emphcode[0]);
DoApplyEmphasis(self->txtread.lastpos,self->txtread.pos,emph);
}
#pragma METHOD_CALL
METHOD VOID txtread_ao_init(PR_TXTREAD *self)
/*
Keep the supplied filename extension.
*/
{
f_open((VOID **)&self->active.pcb,FileName,P_FOPEN|P_FTEXT);
CloseCurrentFile();
SetDefaultStyles(4,6);
StartActive(self);
}
METHOD VOID txtread_ao_queue(PR_TXTREAD *self)
{
self->active.isactive=TRUE;
self->txtread.len=TXTREAD_BUFLEN;
p_ioc5(self->active.pcb,P_FREAD,&self->active.stat,&self->txtread.buf[0],
&self->txtread.len);
}
METHOD INT txtread_ao_run(PR_TXTREAD *self)
{
if (self->active.stat==E_FILE_EOF)
{
ApplyPlainStyle(self); /* apply style to final paragraph */
SwitchToNewFile(FileName);
p_send2(self,O_DESTROY);
return(RUN_ACTIVE_USED);
}
f_leave(self->active.stat);
if (self->txtread.pos)
{
ApplyPlainStyle(self); /* range does not include the terminating NULL */
InsertBuf(self,&self->txtread.eopara,1);
self->txtread.lastpos=self->txtread.pos;
}
InsertBuf(self,&self->txtread.buf[0],self->txtread.len); /* add text of next paragraph */
p_send2(self,O_AO_QUEUE);
return(RUN_ACTIVE_USED);
}
METHOD VOID txtread_ao_abrun(PR_TXTREAD *self)
/*
The application is shut down after reporting any error on loading.
No data is ever lost by doing this, since any previous file will
already have been saved.
*/
{
StopActive();
p_supersend2(self,O_AO_ABRUN);
p_exit(0);
}
METHOD VOID txtread_destroy(PR_TXTREAD *self)
{
StopActive();
p_supersend2(self,O_DESTROY);
}
+89
View File
@@ -0,0 +1,89 @@
/*
TXTWRITE.C
*/
#include <p_std.h>
#include <p_file.h>
#include <ws$txt.g>
#include "wpfconv.h"
GLREF_D VOID *DatApp5;
LOCAL_C INT OpenFile(PR_TXTSAVE *self)
/* forces .TXT extension */
{
TEXT extension[6];
P_INFO info;
TEXT name[P_FNAMESIZE];
*((UWORD *)&extension[0])='.'+('T'<<8);
*((UWORD *)&extension[2])='X'+('T'<<8);
extension[4]=0;
f_fparse(&extension[0],DatApp5,&name[0],NULL);
if (!p_finfo(&name[0],&info))
{
if (!DoConfirmOverwrite())
return(FALSE);
}
f_open(&self->active.pcb,&name[0],P_FUPDATE|P_FREPLACE|P_FSTREAM_TEXT);
return(TRUE);
}
LOCAL_C VOID ReplaceNulls(TEXT *p,UINT len)
{
TEXT *pe;
for (pe=p+len;p<pe;p++)
{
if (!*p)
*p=CHAR_CR;
}
}
#pragma METHOD_CALL
METHOD VOID txtsave_ao_init(PR_TXTSAVE *self)
{
OpenFile(self);
self->txtsave.ntags=CountTags();
StartActive(self);
}
METHOD VOID txtsave_ao_queue(PR_TXTSAVE *self)
{
self->active.isactive=TRUE;
p_iosignal();
}
METHOD INT txtsave_ao_run(PR_TXTSAVE *self)
{
PARA_STYLE style;
EMPH_STYLE emphasis;
UINT taglen,txtlen;
taglen=SenseTagItem(self->txtsave.curtag++,&style,&emphasis);
while (taglen)
{
txtlen=taglen>TXTSAVE_BUFFER_LEN ? TXTSAVE_BUFFER_LEN : taglen;
ExtractText(self->txtsave.pos,&self->txtsave.buf[0],txtlen);
ReplaceNulls(&self->txtsave.buf[0],txtlen);
f_write(self->active.pcb,&self->txtsave.buf[0],txtlen);
self->txtsave.pos+=txtlen;
taglen-=txtlen;
}
if (self->txtsave.curtag<self->txtsave.ntags)
p_send2(self,O_AO_QUEUE);
else
p_send2(self,O_DESTROY);
return(RUN_ACTIVE_USED);
}
METHOD VOID txtsave_ao_abrun(PR_TXTSAVE *self)
{
p_close(self->active.pcb);
StopActive();
p_supersend2(self,O_AO_ABRUN);
p_supersend2(self,O_DESTROY);
}
METHOD VOID txtsave_destroy(PR_TXTSAVE *self)
{
StopActive();
p_supersend2(self,O_DESTROY);
}
+31
View File
@@ -0,0 +1,31 @@
LIBRARY wl$txt
EXTERNAL olib
INCLUDE p_std.h
INCLUDE p_object.h
INCLUDE olib.g
INCLUDE appman.g
CLASS txtread active
NB Must be first class in DYL
{
REPLACE destroy
REPLACE ao_init
REPLACE ao_queue
REPLACE ao_run
REPLACE ao_abrun
CONSTANTS
{
TXTREAD_BUFLEN 256
}
PROPERTY
{
UWORD pos; current document character content offset
UWORD lastpos; start of previous paragraph
TEXT eopara; end of para marker
TEXT dummy;
UWORD len; length of text in buf[]
TEXT buf[TXTREAD_BUFLEN]; input text buffer
}
}
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
#system epoc dyl
#set epocinit=iplib
#model small jpi
#abort on
#set version=0x320F
#compile %main.cat
#compile txtread.c
#pragma link(s3fconv.lib)
#pragma link(olib.lib)
#pragma link(hwim.lib)
#link %main
Binary file not shown.
+82
View File
@@ -0,0 +1,82 @@
/*
WPFCONV.H
Public word processor structures and prototypes for file conversion DYL code.
*/
#ifndef SCRLAY_G
#include <scrlay.g>
#endif
#ifndef PRINTER_G
#include <printer.g>
#endif
typedef struct
{
SCRLAY_FONT sf;
UWORD inherit;
} WP_FONT;
typedef struct
{
TEXT sc[2];
TEXT tag_name[16];
UWORD sflags;
WP_FONT font;
} EMPH_DATA; /* saved emphasis style structure */
typedef struct
{
SCRLAY_MARGINS marg;
SCRLAY_SPACING spc;
UWORD olevel;
SCRLAY_TABS tabs;
} PARA_DATA; /* saved paragraph style structure */
typedef struct
{
VOID *next; /* style queue header - written by system code */
EMPH_DATA ph;
} EMPH_STYLE; /* in-memory emphasis style structure */
typedef struct
{
VOID *next; /* style queue header - written by system code */
EMPH_DATA ph;
PARA_DATA pa;
SCRLAY_MARGINS prn_mar; /* printer margin positions */
SCRLAY_MARGINS scr_mar; /* screen margin positions */
SCRLAY_SPACING prn_spc; /* printer vertical spacing data */
SCRLAY_TABS *pts; /* screen tabs data */
SCRLAY_TABS *ptp; /* printer tabs data */
} PARA_STYLE; /* in-memory paragraph style structure */
/*
Prototypes for file conversion DYL interface.
*/
GLREF_C INT CountParaStyles(VOID);
GLREF_C INT CountEmphStyles(VOID);
GLREF_C PARA_STYLE *SenseParaStyleByIndex(INT);
GLREF_C EMPH_STYLE *SenseEmphStyleByIndex(INT);
GLREF_C PARA_STYLE *SenseParaStyleBySC(TEXT *);
GLREF_C EMPH_STYLE *SenseEmphStyleBySC(TEXT *);
GLREF_C PARA_STYLE *AppendParaStyle(PARA_STYLE *);
GLREF_C EMPH_STYLE *AppendEmphStyle(EMPH_STYLE *);
GLREF_C VOID DoApplyParaStyle(UINT,UINT,PARA_STYLE *);
GLREF_C VOID DoApplyEmphasis(UINT,UINT,EMPH_STYLE *);
GLREF_C VOID SetDefaultStyles(UINT,UINT);
GLREF_C VOID SetBusyStatus(INT);
GLREF_C INT DoConfirmOverwrite(VOID);
GLREF_C PRINTER_PARAMS *SensePrinterParams(VOID **);
GLREF_C WDR_MODEL *SensePrinterModel(VOID);
GLREF_C VOID *SenseWDR(VOID);
GLREF_C VOID SetFileErr(INT);
GLREF_C VOID StartActive(VOID *);
GLREF_C VOID StopActive(VOID);
GLREF_C VOID CloseCurrentFile(VOID);
GLREF_C VOID SwitchToNewFile(TEXT *);
GLREF_C VOID InsertText(UINT,TEXT *,UINT);
GLREF_C VOID DeleteText(UINT,UINT);
GLREF_C VOID ExtractText(UINT,TEXT *,UINT);
GLREF_C UINT CountTags(VOID);
GLREF_C UINT SenseTagItem(UINT,PARA_STYLE *,EMPH_STYLE *);
+30
View File
@@ -0,0 +1,30 @@
LIBRARY ws$txt
EXTERNAL olib
INCLUDE p_std.h
INCLUDE p_object.h
INCLUDE olib.g
INCLUDE appman.g
CLASS txtsave active
NB Must be first class in DYL
{
REPLACE destroy
REPLACE ao_init
REPLACE ao_queue
REPLACE ao_run
REPLACE ao_abrun
CONSTANTS
{
CHAR_CR 13
TXTSAVE_BUFFER_LEN 256
}
PROPERTY
{
UINT ntags;
UINT curtag;
UINT pos;
TEXT buf[TXTSAVE_BUFFER_LEN];
}
}
Binary file not shown.
+18
View File
@@ -0,0 +1,18 @@
#system epoc dyl
#set epocinit=iplib
#model small jpi
#abort on
#set version=0x320F
#compile %main.cat
#compile txtwrite.c
#pragma link(s3fconv.lib)
#pragma link(olib.lib)
#pragma link(hwim.lib)
#link %main
File diff suppressed because it is too large Load Diff
+158
View File
@@ -0,0 +1,158 @@
*name Diary
*descent 0
*height 9
*maxwid 8
*char 0
00000000000 ! DY_SYMBOL_ARROW_TAIL
00011100000
00010100000
00010100000
00010100000
00010100000
00010100000
00010100000
00010100000
00010100000 ! DY_SYMBOL_ARROW_MIDDLE
00010100000
00010100000
00010100000
00010100000
00010100000
00010100000
00010100000
00010100000
00000000000 ! DY_SYMBOL_ARROW_HEAD_CLOSED
00011100000
00010100000
00010100000
01110111000
00100010000
00010100000
00001000000
00000000000
00010100000 ! DY_SYMBOL_ARROW_HEAD_OPEN
00010100000
00010100000
00010100000
01110111000
00100010000
00010100000
00001000000
00000000000
1 ! DY_SYMBOL_VERTICAL_BAR
1
1
1
1
1
1
1
1
00000000 ! Numeric space
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000
00000000 ! DY_SYMBOL_TODO_PRIORITY_ONE
00111000
01101100
11001110
11101110
11101110
01101100
00111000
00000000
00000000 ! DY_SYMBOL_TODO_PRIORITY_TWO
00111000
01000100
11110110
11101110
11011110
01000100
00111000
00000000
00000000 ! DY_SYMBOL_TODO_PRIORITY_THREE
00111000
01000100
11110110
11100110
11110110
01000100
00111000
00000000
00000000 ! DY_SYMBOL_TODO_PRIORITY_FOUR
00111000
01011100
11011110
11010110
11000110
01110100
00111000
00000000
00000000 ! DY_SYMBOL_TODO_PRIORITY_FIVE
00111000
01000100
11011110
11000110
11110110
01000100
00111000
00000000
00000000 ! DY_SYMBOL_TODO_PRIORITY_SIX
00111000
01000100
11011110
11000110
11010110
01000100
00111000
00000000
00000000 ! DY_SYMBOL_TODO_PRIORITY_SEVEN
00111000
01000100
11110110
11110110
11101110
01101100
00111000
00000000
00000000 ! DY_SYMBOL_TODO_PRIORITY_EIGHT
00111000
01000100
11010110
11000110
11010110
01000100
00111000
00000000
00000000 ! DY_SYMBOL_TODO_PRIORITY_NINE
00111000
01000100
11010110
11000110
11110110
01110100
00111000
00000000
+93
View File
@@ -0,0 +1,93 @@
*name Sys$digt
*descent 1
*height 6
*max_width 6
*char 31
000000
000000
000000
000000
000000
000000
000000
000000
000000
000000
000000
000000
*char 48
011100
100010
100010
100010
011100
000000
001000
011000
001000
001000
011100
000000
011100
100010
001100
010000
111110
000000
011100
100010
001100
100010
011100
000000
000100
001100
010100
111110
000100
000000
111110
100000
111100
000010
111100
000000
011100
100000
111100
100010
011100
000000
111110
000010
000100
001000
001000
000000
011100
100010
011100
100010
011100
000000
011100
100010
011110
000010
011100
000000
+11
View File
@@ -0,0 +1,11 @@
FONT.PRJ ! This file
!
READ.ME ! About the \sibosdk\font directory
!
! ===================
! Sample font sources
!
NORM.FSC ! A 'normal' font
BOLD.FSC ! A bolded version of the above
DIGIT.FSC ! The Series 3 'digits' font
DIARY.FSC ! The Series 3 Agenda special character font
File diff suppressed because it is too large Load Diff
+95
View File
@@ -0,0 +1,95 @@
This directory contains demonstration font source (.fsc) files.
Use the program wsfcomp.exe to generate font (.fon) files. For example,
to compile diary.fsc, producing diary.fon, just type:
wsfcomp diary
See FONT.PRJ (a plain text file) for an annotated list of the files in
this directory.
A font source file contains a header section followed by patterns
which make up the font, as in the following extract from the
beginning of a font source file:
*name System mono
*descent 2
*height 10
*maxwid 7
*flag ascii
*flag cp850
*char 28
100000000000
100001100000
100001100000
101111111100
100111111000
110011110111
000001100000
000000000000
111111111111
100000000000
0000000
0000000
0001000
0001100
1111110
1111110
0001100
0001000
0000000
0000000
0000000
0000011
0000011
0010011
0110011
1111111
1111111
0110000
0010000
0000000
The keywords have the following meanings:
-----------------------------------------
*name The font name (maximum length 16 characters)
*descent <n> The descent for the font
*height <n> The height for the font
*maxwid <n> Not the real maximum width, but the width of the
widest normal character
*flag Some informational flags
*char <n> Skip all characters up to the specified code.
Character codes start at 0 and follow sequentially
until the next *char statement
The keyword "*special 1" may also be present, to specify a font
suitable for "fast" blitting onto the screen. If present, this
keyword must come before the *height statement. ("Fast" fonts must
have all their widths less than 9 pixels.)
If the height of a character defined is less than that defined in the
header, blank rows are added at the top.
Possible values for "*flag" (each one defined on its own line) are
"ascii", "cp850", "bold", "italic", and "serif".
For more details about fonts, see the 'Text fonts' sections of both
the 'Introduction' and 'Graphics Output' chapters of the WSERV
Reference manual.
Note that only the first letter of keywords and flagnames is
significant. Thus "*max_width" and "*maxwid" have the same effect.
One tip when editing .fsc files is to temporarily change all '1's
into graphics square characters (ascii 219, say), and all '0's into
dots. Then change them back when you're finished.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because one or more lines are too long
+6
View File
@@ -0,0 +1,6 @@
@echo off
rem Specimen batch file to create master HC SSD
rem Drivers for external SSD drives must be installed
emast -u1 v033eeng.mas
echo Transferring other software...
xcopy \hcmast\*.* f:\*.* /s
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3
View File
@@ -0,0 +1,3 @@
rem Example batch file to create master file image of HC ROM
erom >sch.mep -c -m -b0xa000 -v0x033e -lsch -oENG epocchp
type sch.mep
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
cheng.cfo,sys$ctry.cfo
wsrvhch1.img,sys$wsrv.img
corpshll.img,sys$shll.img
corpntfy.img,sys$ntfy.img
sys$env.ini
sys$rfsv.img
sys$ncp.img
link.img
mclinkpa.trm,mclink.trm
olib.dyl
big.fon
small.fon
mon_5x8.fon
mono.fon
sys$norm.fon
sys$bold.fon
exopl.img
oplch.dyl,opl.dyl
batchk.img
ttest.img
pprint.img
custom$.dat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More