build: add the SIBO SDK
This commit is contained in:
@@ -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);
|
||||
}
|
||||
@@ -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
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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
|
||||
@@ -0,0 +1,2 @@
|
||||
@if not "%jpivid%"=="v2" set jpivid=v0
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
HELLO.C
|
||||
|
||||
CLIB Hello World application
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
int main(VOID)
|
||||
{
|
||||
printf("Hello World");
|
||||
getchar();
|
||||
return(0);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#system epoc img
|
||||
#model small jpi
|
||||
|
||||
#compile hello
|
||||
#link hello
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -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();
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
#system epoc img
|
||||
#set epocinit=iplib2
|
||||
#model small jpi
|
||||
#compile lkshell
|
||||
#link lkshell
|
||||
@@ -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
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#system epoc img
|
||||
#set epocinit=iplib
|
||||
#model small jpi
|
||||
|
||||
#compile p_hello
|
||||
#link p_hello
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#system epoc img
|
||||
#set epocinit=iplib2
|
||||
#model small jpi
|
||||
|
||||
#compile scapt
|
||||
#compile pcxsave
|
||||
#link scapt
|
||||
@@ -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(¬es1[0],¬es2[0],len1,len2,i,-1);
|
||||
p_sleep(1);
|
||||
}
|
||||
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
play_notes(¬es1[0],¬es2[0],len1,len2,-1,140+i*20);
|
||||
p_sleep(1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
typedef struct
|
||||
{
|
||||
HANDLE pid;
|
||||
VOID *poff;
|
||||
ULONG data;
|
||||
} SUBPROC_CL;
|
||||
@@ -0,0 +1,5 @@
|
||||
#system epoc img
|
||||
#set epocinit=iplib
|
||||
#model small jpi
|
||||
#compile %main
|
||||
#link %main
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user